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)))
942 "Window configuration for all possible Gnus buffers.
943 This variable is a list of lists. Each of these lists has a NAME and
944 a RULE. The NAMEs are commonsense names like `group', which names a
945 rule used when displaying the group buffer; `summary', which names a
946 rule for what happens when you enter a group and do not display an
947 article buffer; and so on. See the value of this variable for a
948 complete list of NAMEs.
950 Each RULE is a list of vectors. The first element in this vector is
951 the name of the buffer to be displayed; the second element is the
952 percentage of the screen this buffer is to occupy (a number in the
953 0.0-0.99 range); the optional third element is `point', which should
954 be present to denote which buffer point is to go to after making this
955 buffer configuration.")
957 (defvar gnus-window-to-buffer
958 '((group . gnus-group-buffer)
959 (summary . gnus-summary-buffer)
960 (article . gnus-article-buffer)
961 (server . gnus-server-buffer)
962 (browse . "*Gnus Browse Server*")
963 (edit-group . gnus-group-edit-buffer)
964 (edit-server . gnus-server-edit-buffer)
965 (group-carpal . gnus-carpal-group-buffer)
966 (summary-carpal . gnus-carpal-summary-buffer)
967 (server-carpal . gnus-carpal-server-buffer)
968 (browse-carpal . gnus-carpal-browse-buffer)
969 (edit-score . gnus-score-edit-buffer)
970 (mail . gnus-mail-buffer)
971 (post . gnus-post-news-buffer)
972 (faq . gnus-faq-buffer)
973 (picons . "*Picons*")
974 (tree . gnus-tree-buffer)
975 (info . gnus-info-buffer)
976 (article-copy . gnus-article-copy)
977 (draft . gnus-draft-buffer))
978 "Mapping from short symbols to buffer names or buffer variables.")
980 (defvar gnus-carpal nil
981 "*If non-nil, display clickable icons.")
983 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
984 "*Function called with a group name when new group is detected.
985 A few pre-made functions are supplied: `gnus-subscribe-randomly'
986 inserts new groups at the beginning of the list of groups;
987 `gnus-subscribe-alphabetically' inserts new groups in strict
988 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
989 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
990 for your decision; `gnus-subscribe-killed' kills all new groups.")
992 ;; Suggested by a bug report by Hallvard B Furuseth.
993 ;; <h.b.furuseth@usit.uio.no>.
994 (defvar gnus-subscribe-options-newsgroup-method
995 (function gnus-subscribe-alphabetically)
996 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
997 If, for instance, you want to subscribe to all newsgroups in the
998 \"no\" and \"alt\" hierarchies, you'd put the following in your
1001 options -n no.all alt.all
1003 Gnus will the subscribe all new newsgroups in these hierarchies with
1004 the subscription method in this variable.")
1006 (defvar gnus-subscribe-hierarchical-interactive nil
1007 "*If non-nil, Gnus will offer to subscribe hierarchically.
1008 When a new hierarchy appears, Gnus will ask the user:
1010 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1012 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1013 subscribe to all newsgroups in the hierarchy and `s' will skip this
1014 hierarchy in its entirety.")
1016 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1017 "*Function used for sorting the group buffer.
1018 This function will be called with group info entries as the arguments
1019 for the groups to be sorted. Pre-made functions include
1020 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1021 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1022 `gnus-group-sort-by-rank'.
1024 This variable can also be a list of sorting functions. In that case,
1025 the most significant sort function should be the last function in the
1028 ;; Mark variables suggested by Thomas Michanek
1029 ;; <Thomas.Michanek@telelogic.se>.
1030 (defvar gnus-unread-mark ?
1031 "*Mark used for unread articles.")
1032 (defvar gnus-ticked-mark ?!
1033 "*Mark used for ticked articles.")
1034 (defvar gnus-dormant-mark ??
1035 "*Mark used for dormant articles.")
1036 (defvar gnus-del-mark ?r
1037 "*Mark used for del'd articles.")
1038 (defvar gnus-read-mark ?R
1039 "*Mark used for read articles.")
1040 (defvar gnus-expirable-mark ?E
1041 "*Mark used for expirable articles.")
1042 (defvar gnus-killed-mark ?K
1043 "*Mark used for killed articles.")
1044 (defvar gnus-souped-mark ?F
1045 "*Mark used for killed articles.")
1046 (defvar gnus-kill-file-mark ?X
1047 "*Mark used for articles killed by kill files.")
1048 (defvar gnus-low-score-mark ?Y
1049 "*Mark used for articles with a low score.")
1050 (defvar gnus-catchup-mark ?C
1051 "*Mark used for articles that are caught up.")
1052 (defvar gnus-replied-mark ?A
1053 "*Mark used for articles that have been replied to.")
1054 (defvar gnus-cached-mark ?*
1055 "*Mark used for articles that are in the cache.")
1056 (defvar gnus-saved-mark ?S
1057 "*Mark used for articles that have been saved to.")
1058 (defvar gnus-process-mark ?#
1060 (defvar gnus-ancient-mark ?O
1061 "*Mark used for ancient articles.")
1062 (defvar gnus-sparse-mark ?Q
1063 "*Mark used for sparsely reffed articles.")
1064 (defvar gnus-canceled-mark ?G
1065 "*Mark used for canceled articles.")
1066 (defvar gnus-score-over-mark ?+
1067 "*Score mark used for articles with high scores.")
1068 (defvar gnus-score-below-mark ?-
1069 "*Score mark used for articles with low scores.")
1070 (defvar gnus-empty-thread-mark ?
1071 "*There is no thread under the article.")
1072 (defvar gnus-not-empty-thread-mark ?=
1073 "*There is a thread under the article.")
1075 (defvar gnus-view-pseudo-asynchronously nil
1076 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1078 (defvar gnus-view-pseudos nil
1079 "*If `automatic', pseudo-articles will be viewed automatically.
1080 If `not-confirm', pseudos will be viewed automatically, and the user
1081 will not be asked to confirm the command.")
1083 (defvar gnus-view-pseudos-separately t
1084 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1085 If nil, all files that use the same viewing command will be given as a
1086 list of parameters to that command.")
1088 (defvar gnus-insert-pseudo-articles t
1089 "*If non-nil, insert pseudo-articles when decoding articles.")
1091 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1092 "*Format of group lines.
1093 It works along the same lines as a normal formatting string,
1094 with some simple extensions.
1096 %M Only marked articles (character, \"*\" or \" \")
1097 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1098 %L Level of subscribedness (integer)
1099 %N Number of unread articles (integer)
1100 %I Number of dormant articles (integer)
1101 %i Number of ticked and dormant (integer)
1102 %T Number of ticked articles (integer)
1103 %R Number of read articles (integer)
1104 %t Total number of articles (integer)
1105 %y Number of unread, unticked articles (integer)
1106 %G Group name (string)
1107 %g Qualified group name (string)
1108 %D Group description (string)
1109 %s Select method (string)
1110 %o Moderated group (char, \"m\")
1111 %p Process mark (char)
1112 %O Moderated group (string, \"(m)\" or \"\")
1113 %P Topic indentation (string)
1114 %l Whether there are GroupLens predictions for this group (string)
1115 %n Select from where (string)
1116 %z A string that look like `<%s:%n>' if a foreign select method is used
1117 %u User defined specifier. The next character in the format string should
1118 be a letter. Gnus will call the function gnus-user-format-function-X,
1119 where X is the letter following %u. The function will be passed the
1120 current header as argument. The function should return a string, which
1121 will be inserted into the buffer just like information from any other
1124 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1125 the mouse point move inside the area. There can only be one such area.
1127 Note that this format specification is not always respected. For
1128 reasons of efficiency, when listing killed groups, this specification
1129 is ignored altogether. If the spec is changed considerably, your
1130 output may end up looking strange when listing both alive and killed
1133 If you use %o or %O, reading the active file will be slower and quite
1134 a bit of extra memory will be used. %D will also worsen performance.
1135 Also note that if you change the format specification to include any
1136 of these specs, you must probably re-start Gnus to see them go into
1139 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1140 "*The format specification of the lines in the summary buffer.
1142 It works along the same lines as a normal formatting string,
1143 with some simple extensions.
1145 %N Article number, left padded with spaces (string)
1147 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1148 %n Name of the poster (string)
1149 %a Extracted name of the poster (string)
1150 %A Extracted address of the poster (string)
1151 %F Contents of the From: header (string)
1152 %x Contents of the Xref: header (string)
1153 %D Date of the article (string)
1154 %d Date of the article (string) in DD-MMM format
1155 %M Message-id of the article (string)
1156 %r References of the article (string)
1157 %c Number of characters in the article (integer)
1158 %L Number of lines in the article (integer)
1159 %I Indentation based on thread level (a string of spaces)
1160 %T A string with two possible values: 80 spaces if the article
1161 is on thread level two or larger and 0 spaces on level one
1162 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1163 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1164 %[ Opening bracket (character, \"[\" or \"<\")
1165 %] Closing bracket (character, \"]\" or \">\")
1166 %> Spaces of length thread-level (string)
1167 %< Spaces of length (- 20 thread-level) (string)
1168 %i Article score (number)
1169 %z Article zcore (character)
1170 %t Number of articles under the current thread (number).
1171 %e Whether the thread is empty or not (character).
1172 %l GroupLens score (number)
1173 %u User defined specifier. The next character in the format string should
1174 be a letter. Gnus will call the function gnus-user-format-function-X,
1175 where X is the letter following %u. The function will be passed the
1176 current header as argument. The function should return a string, which
1177 will be inserted into the summary just like information from any other
1180 Text between %( and %) will be highlighted with `gnus-mouse-face'
1181 when the mouse point is placed inside the area. There can only be one
1184 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1185 with care. For reasons of efficiency, Gnus will compute what column
1186 these characters will end up in, and \"hard-code\" that. This means that
1187 it is illegal to have these specs after a variable-length spec. Well,
1188 you might not be arrested, but your summary buffer will look strange,
1189 which is bad enough.
1191 The smart choice is to have these specs as for to the left as
1194 This restriction may disappear in later versions of Gnus.")
1196 (defvar gnus-summary-dummy-line-format
1198 "*The format specification for the dummy roots in the summary buffer.
1199 It works along the same lines as a normal formatting string,
1200 with some simple extensions.
1204 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1205 "*The format specification for the summary mode line.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions:
1210 %p Unprefixed group name
1211 %A Current article number
1213 %U Number of unread articles in the group
1214 %e Number of unselected articles in the group
1215 %Z A string with unread/unselected article counts
1216 %g Shortish group name
1217 %S Subject of the current article
1218 %u User-defined spec
1219 %s Current score file name
1220 %d Number of dormant articles
1221 %r Number of articles that have been marked as read in this session
1222 %E Number of articles expunged by the score files")
1224 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1225 "*The format specification for the article mode line.
1226 See `gnus-summary-mode-line-format' for a closer description.")
1228 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1229 "*The format specification for the group mode line.
1230 It works along the same lines as a normal formatting string,
1231 with some simple extensions:
1233 %S The native news server.
1234 %M The native select method.")
1236 (defvar gnus-valid-select-methods
1237 '(("nntp" post address prompt-address)
1238 ("nnspool" post address)
1239 ("nnvirtual" post-mail virtual prompt-address)
1240 ("nnmbox" mail respool address)
1241 ("nnml" mail respool address)
1242 ("nnmh" mail respool address)
1243 ("nndir" post-mail prompt-address address)
1244 ("nneething" none address prompt-address)
1245 ("nndoc" none address prompt-address)
1246 ("nnbabyl" mail address respool)
1247 ("nnkiboze" post address virtual)
1248 ("nnsoup" post-mail address)
1249 ("nndraft" post-mail)
1250 ("nnfolder" mail respool address))
1251 "An alist of valid select methods.
1252 The first element of each list lists should be a string with the name
1253 of the select method. The other elements may be be the category of
1254 this method (ie. `post', `mail', `none' or whatever) or other
1255 properties that this method has (like being respoolable).
1256 If you implement a new select method, all you should have to change is
1257 this variable. I think.")
1259 (defvar gnus-updated-mode-lines '(group article summary tree)
1260 "*List of buffers that should update their mode lines.
1261 The list may contain the symbols `group', `article' and `summary'. If
1262 the corresponding symbol is present, Gnus will keep that mode line
1263 updated with information that may be pertinent.
1264 If this variable is nil, screen refresh may be quicker.")
1266 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1267 (defvar gnus-mode-non-string-length nil
1268 "*Max length of mode-line non-string contents.
1269 If this is nil, Gnus will take space as is needed, leaving the rest
1270 of the modeline intact.")
1273 ;(defvar gnus-mouse-face 'highlight
1274 ; "*Face used for mouse highlighting in Gnus.
1275 ;No mouse highlights will be done if `gnus-visual' is nil.")
1277 (defvar gnus-summary-mark-below nil
1278 "*Mark all articles with a score below this variable as read.
1279 This variable is local to each summary buffer and usually set by the
1282 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1283 "*List of functions used for sorting articles in the summary buffer.
1284 This variable is only used when not using a threaded display.")
1286 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1287 "*List of functions used for sorting threads in the summary buffer.
1288 By default, threads are sorted by article number.
1290 Each function takes two threads and return non-nil if the first thread
1291 should be sorted before the other. If you use more than one function,
1292 the primary sort function should be the last. You should probably
1293 always include `gnus-thread-sort-by-number' in the list of sorting
1294 functions -- preferably first.
1296 Ready-mady functions include `gnus-thread-sort-by-number',
1297 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1298 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1299 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1301 (defvar gnus-thread-score-function '+
1302 "*Function used for calculating the total score of a thread.
1304 The function is called with the scores of the article and each
1305 subthread and should then return the score of the thread.
1307 Some functions you can use are `+', `max', or `min'.")
1309 (defvar gnus-summary-expunge-below nil
1310 "All articles that have a score less than this variable will be expunged.")
1312 (defvar gnus-thread-expunge-below nil
1313 "All threads that have a total score less than this variable will be expunged.
1314 See `gnus-thread-score-function' for en explanation of what a
1315 \"thread score\" is.")
1317 (defvar gnus-auto-subscribed-groups
1318 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1319 "*All new groups that match this regexp will be subscribed automatically.
1320 Note that this variable only deals with new groups. It has no effect
1321 whatsoever on old groups.")
1323 (defvar gnus-options-subscribe nil
1324 "*All new groups matching this regexp will be subscribed unconditionally.
1325 Note that this variable deals only with new newsgroups. This variable
1326 does not affect old newsgroups.")
1328 (defvar gnus-options-not-subscribe nil
1329 "*All new groups matching this regexp will be ignored.
1330 Note that this variable deals only with new newsgroups. This variable
1331 does not affect old (already subscribed) newsgroups.")
1333 (defvar gnus-auto-expirable-newsgroups nil
1334 "*Groups in which to automatically mark read articles as expirable.
1335 If non-nil, this should be a regexp that should match all groups in
1336 which to perform auto-expiry. This only makes sense for mail groups.")
1338 (defvar gnus-total-expirable-newsgroups nil
1339 "*Groups in which to perform expiry of all read articles.
1340 Use with extreme caution. All groups that match this regexp will be
1341 expiring - which means that all read articles will be deleted after
1342 (say) one week. (This only goes for mail groups and the like, of
1345 (defvar gnus-group-uncollapsed-levels 1
1346 "Number of group name elements to leave alone when making a short group name.")
1348 (defvar gnus-hidden-properties '(invisible t intangible t)
1349 "Property list to use for hiding text.")
1351 (defvar gnus-modtime-botch nil
1352 "*Non-nil means .newsrc should be deleted prior to save.
1353 Its use is due to the bogus appearance that .newsrc was modified on
1358 (defvar gnus-group-mode-hook nil
1359 "*A hook for Gnus group mode.")
1361 (defvar gnus-summary-mode-hook nil
1362 "*A hook for Gnus summary mode.
1363 This hook is run before any variables are set in the summary buffer.")
1365 (defvar gnus-article-mode-hook nil
1366 "*A hook for Gnus article mode.")
1368 (defvar gnus-summary-prepare-exit-hook nil
1369 "*A hook called when preparing to exit from the summary buffer.
1370 It calls `gnus-summary-expire-articles' by default.")
1371 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1373 (defvar gnus-summary-exit-hook nil
1374 "*A hook called on exit from the summary buffer.")
1376 (defvar gnus-group-catchup-group-hook nil
1377 "*A hook run when catching up a group from the group buffer.")
1379 (defvar gnus-open-server-hook nil
1380 "*A hook called just before opening connection to the news server.")
1382 (defvar gnus-load-hook nil
1383 "*A hook run while Gnus is loaded.")
1385 (defvar gnus-startup-hook nil
1386 "*A hook called at startup.
1387 This hook is called after Gnus is connected to the NNTP server.")
1389 (defvar gnus-get-new-news-hook nil
1390 "*A hook run just before Gnus checks for new news.")
1392 (defvar gnus-after-getting-new-news-hook nil
1393 "*A hook run after Gnus checks for new news.")
1395 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1396 "*A function that is called to generate the group buffer.
1397 The function is called with three arguments: The first is a number;
1398 all group with a level less or equal to that number should be listed,
1399 if the second is non-nil, empty groups should also be displayed. If
1400 the third is non-nil, it is a number. No groups with a level lower
1401 than this number should be displayed.
1403 The only current function implemented is `gnus-group-prepare-flat'.")
1405 (defvar gnus-group-prepare-hook nil
1406 "*A hook called after the group buffer has been generated.
1407 If you want to modify the group buffer, you can use this hook.")
1409 (defvar gnus-summary-prepare-hook nil
1410 "*A hook called after the summary buffer has been generated.
1411 If you want to modify the summary buffer, you can use this hook.")
1413 (defvar gnus-summary-generate-hook nil
1414 "*A hook run just before generating the summary buffer.
1415 This hook is commonly used to customize threading variables and the
1418 (defvar gnus-article-prepare-hook nil
1419 "*A hook called after an article has been prepared in the article buffer.
1420 If you want to run a special decoding program like nkf, use this hook.")
1422 ;(defvar gnus-article-display-hook nil
1423 ; "*A hook called after the article is displayed in the article buffer.
1424 ;The hook is designed to change the contents of the article
1425 ;buffer. Typical functions that this hook may contain are
1426 ;`gnus-article-hide-headers' (hide selected headers),
1427 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1428 ;`gnus-article-hide-signature' (hide signature) and
1429 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1432 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1434 (defvar gnus-article-x-face-command
1435 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1436 "String or function to be executed to display an X-Face header.
1437 If it is a string, the command will be executed in a sub-shell
1438 asynchronously. The compressed face will be piped to this command.")
1440 (defvar gnus-article-x-face-too-ugly nil
1441 "Regexp matching posters whose face shouldn't be shown automatically.")
1443 (defvar gnus-select-group-hook nil
1444 "*A hook called when a newsgroup is selected.
1446 If you'd like to simplify subjects like the
1447 `gnus-summary-next-same-subject' command does, you can use the
1450 (setq gnus-select-group-hook
1453 (mapcar (lambda (header)
1454 (mail-header-set-subject
1456 (gnus-simplify-subject
1457 (mail-header-subject header) 're-only)))
1458 gnus-newsgroup-headers))))")
1460 (defvar gnus-select-article-hook nil
1461 "*A hook called when an article is selected.")
1463 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1464 "*A hook called to apply kill files to a group.
1465 This hook is intended to apply a kill file to the selected newsgroup.
1466 The function `gnus-apply-kill-file' is called by default.
1468 Since a general kill file is too heavy to use only for a few
1469 newsgroups, I recommend you to use a lighter hook function. For
1470 example, if you'd like to apply a kill file to articles which contains
1471 a string `rmgroup' in subject in newsgroup `control', you can use the
1474 (setq gnus-apply-kill-hook
1477 (cond ((string-match \"control\" gnus-newsgroup-name)
1478 (gnus-kill \"Subject\" \"rmgroup\")
1479 (gnus-expunge \"X\"))))))")
1481 (defvar gnus-visual-mark-article-hook
1482 (list 'gnus-highlight-selected-summary)
1483 "*Hook run after selecting an article in the summary buffer.
1484 It is meant to be used for highlighting the article in some way. It
1485 is not run if `gnus-visual' is nil.")
1487 (defvar gnus-parse-headers-hook nil
1488 "*A hook called before parsing the headers.")
1490 (defvar gnus-exit-group-hook nil
1491 "*A hook called when exiting (not quitting) summary mode.")
1493 (defvar gnus-suspend-gnus-hook nil
1494 "*A hook called when suspending (not exiting) Gnus.")
1496 (defvar gnus-exit-gnus-hook nil
1497 "*A hook called when exiting Gnus.")
1499 (defvar gnus-after-exiting-gnus-hook nil
1500 "*A hook called after exiting Gnus.")
1502 (defvar gnus-save-newsrc-hook nil
1503 "*A hook called before saving any of the newsrc files.")
1505 (defvar gnus-save-quick-newsrc-hook nil
1506 "*A hook called just before saving the quick newsrc file.
1507 Can be used to turn version control on or off.")
1509 (defvar gnus-save-standard-newsrc-hook nil
1510 "*A hook called just before saving the standard newsrc file.
1511 Can be used to turn version control on or off.")
1513 (defvar gnus-summary-update-hook
1514 (list 'gnus-summary-highlight-line)
1515 "*A hook called when a summary line is changed.
1516 The hook will not be called if `gnus-visual' is nil.
1518 The default function `gnus-summary-highlight-line' will
1519 highlight the line according to the `gnus-summary-highlight'
1522 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1523 "*A hook called when a group line is changed.
1524 The hook will not be called if `gnus-visual' is nil.
1526 The default function `gnus-group-highlight-line' will
1527 highlight the line according to the `gnus-group-highlight'
1530 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1531 "*A hook called when an article is selected for the first time.
1532 The hook is intended to mark an article as read (or unread)
1533 automatically when it is selected.")
1535 (defvar gnus-group-change-level-function nil
1536 "Function run when a group level is changed.
1537 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1539 ;; Remove any hilit infestation.
1540 (add-hook 'gnus-startup-hook
1542 (remove-hook 'gnus-summary-prepare-hook
1543 'hilit-rehighlight-buffer-quietly)
1544 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1545 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1546 (remove-hook 'gnus-article-prepare-hook
1547 'hilit-rehighlight-buffer-quietly)))
1550 ;; Internal variables
1552 (defvar gnus-server-alist nil
1553 "List of available servers.")
1555 (defvar gnus-group-indentation-function nil)
1557 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1559 (defvar gnus-goto-missing-group-function nil)
1561 (defvar gnus-override-subscribe-method nil)
1563 (defvar gnus-group-goto-next-group-function nil
1564 "Function to override finding the next group after listing groups.")
1566 (defconst gnus-article-mark-lists
1567 '((marked . tick) (replied . reply)
1568 (expirable . expire) (killed . killed)
1569 (bookmarks . bookmark) (dormant . dormant)
1570 (scored . score) (saved . save)
1574 ;; Avoid highlighting in kill files.
1575 (defvar gnus-summary-inhibit-highlight nil)
1576 (defvar gnus-newsgroup-selected-overlay nil)
1578 (defvar gnus-inhibit-hiding nil)
1579 (defvar gnus-group-indentation "")
1580 (defvar gnus-inhibit-limiting nil)
1581 (defvar gnus-created-frames nil)
1583 (defvar gnus-article-mode-map nil)
1584 (defvar gnus-dribble-buffer nil)
1585 (defvar gnus-headers-retrieved-by nil)
1586 (defvar gnus-article-reply nil)
1587 (defvar gnus-override-method nil)
1588 (defvar gnus-article-check-size nil)
1590 (defvar gnus-current-score-file nil)
1591 (defvar gnus-newsgroup-adaptive-score-file nil)
1592 (defvar gnus-scores-exclude-files nil)
1594 (defvar gnus-opened-servers nil)
1596 (defvar gnus-current-move-group nil)
1598 (defvar gnus-newsgroup-dependencies nil)
1599 (defvar gnus-newsgroup-async nil)
1600 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1602 (defvar gnus-newsgroup-adaptive nil)
1604 (defvar gnus-summary-display-table nil)
1605 (defvar gnus-summary-display-article-function nil)
1607 (defvar gnus-summary-highlight-line-function nil
1608 "Function called after highlighting a summary line.")
1610 (defvar gnus-group-line-format-alist
1611 `((?M gnus-tmp-marked-mark ?c)
1612 (?S gnus-tmp-subscribed ?c)
1613 (?L gnus-tmp-level ?d)
1614 (?N (cond ((eq number t) "*" )
1618 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1619 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1621 (?R gnus-tmp-number-of-read ?s)
1622 (?t gnus-tmp-number-total ?d)
1623 (?y gnus-tmp-number-of-unread ?s)
1624 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1625 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1626 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1627 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1628 (?g gnus-tmp-group ?s)
1629 (?G gnus-tmp-qualified-group ?s)
1630 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1631 (?D gnus-tmp-newsgroup-description ?s)
1632 (?o gnus-tmp-moderated ?c)
1633 (?O gnus-tmp-moderated-string ?s)
1634 (?p gnus-tmp-process-marked ?c)
1635 (?s gnus-tmp-news-server ?s)
1636 (?n gnus-tmp-news-method ?s)
1637 (?P gnus-group-indentation ?s)
1638 (?l gnus-tmp-grouplens ?s)
1639 (?z gnus-tmp-news-method-string ?s)
1640 (?u gnus-tmp-user-defined ?s)))
1642 (defvar gnus-summary-line-format-alist
1643 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1644 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1645 (?s gnus-tmp-subject-or-nil ?s)
1646 (?n gnus-tmp-name ?s)
1647 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1649 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1651 (?F gnus-tmp-from ?s)
1652 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1653 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1654 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1655 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1656 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1657 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1658 (?L gnus-tmp-lines ?d)
1659 (?I gnus-tmp-indentation ?s)
1660 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1661 (?R gnus-tmp-replied ?c)
1662 (?\[ gnus-tmp-opening-bracket ?c)
1663 (?\] gnus-tmp-closing-bracket ?c)
1664 (?\> (make-string gnus-tmp-level ? ) ?s)
1665 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1666 (?i gnus-tmp-score ?d)
1667 (?z gnus-tmp-score-char ?c)
1668 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1669 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1670 (?U gnus-tmp-unread ?c)
1671 (?t (gnus-summary-number-of-articles-in-thread
1672 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1674 (?e (gnus-summary-number-of-articles-in-thread
1675 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1677 (?u gnus-tmp-user-defined ?s))
1678 "An alist of format specifications that can appear in summary lines,
1679 and what variables they correspond with, along with the type of the
1680 variable (string, integer, character, etc).")
1682 (defvar gnus-summary-dummy-line-format-alist
1683 `((?S gnus-tmp-subject ?s)
1684 (?N gnus-tmp-number ?d)
1685 (?u gnus-tmp-user-defined ?s)))
1687 (defvar gnus-summary-mode-line-format-alist
1688 `((?G gnus-tmp-group-name ?s)
1689 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1690 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1691 (?A gnus-tmp-article-number ?d)
1692 (?Z gnus-tmp-unread-and-unselected ?s)
1693 (?V gnus-version ?s)
1694 (?U gnus-tmp-unread ?d)
1695 (?S gnus-tmp-subject ?s)
1696 (?e gnus-tmp-unselected ?d)
1697 (?u gnus-tmp-user-defined ?s)
1698 (?d (length gnus-newsgroup-dormant) ?d)
1699 (?t (length gnus-newsgroup-marked) ?d)
1700 (?r (length gnus-newsgroup-reads) ?d)
1701 (?E gnus-newsgroup-expunged-tally ?d)
1702 (?s (gnus-current-score-file-nondirectory) ?s)))
1704 (defvar gnus-article-mode-line-format-alist
1705 gnus-summary-mode-line-format-alist)
1707 (defvar gnus-group-mode-line-format-alist
1708 `((?S gnus-tmp-news-server ?s)
1709 (?M gnus-tmp-news-method ?s)
1710 (?u gnus-tmp-user-defined ?s)))
1712 (defvar gnus-have-read-active-file nil)
1714 (defconst gnus-maintainer
1715 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1716 "The mail address of the Gnus maintainers.")
1718 (defconst gnus-version "September Gnus v0.54"
1719 "Version number for this version of Gnus.")
1721 (defvar gnus-info-nodes
1722 '((gnus-group-mode "(gnus)The Group Buffer")
1723 (gnus-summary-mode "(gnus)The Summary Buffer")
1724 (gnus-article-mode "(gnus)The Article Buffer"))
1725 "Assoc list of major modes and related Info nodes.")
1727 (defvar gnus-group-buffer "*Group*")
1728 (defvar gnus-summary-buffer "*Summary*")
1729 (defvar gnus-article-buffer "*Article*")
1730 (defvar gnus-server-buffer "*Server*")
1732 (defvar gnus-work-buffer " *gnus work*")
1734 (defvar gnus-original-article-buffer " *Original Article*")
1735 (defvar gnus-original-article nil)
1737 (defvar gnus-buffer-list nil
1738 "Gnus buffers that should be killed on exit.")
1740 (defvar gnus-slave nil
1741 "Whether this Gnus is a slave or not.")
1743 (defvar gnus-variable-list
1744 '(gnus-newsrc-options gnus-newsrc-options-n
1745 gnus-newsrc-last-checked-date
1746 gnus-newsrc-alist gnus-server-alist
1747 gnus-killed-list gnus-zombie-list
1748 gnus-topic-topology gnus-topic-alist
1750 "Gnus variables saved in the quick startup file.")
1752 (defvar gnus-newsrc-options nil
1753 "Options line in the .newsrc file.")
1755 (defvar gnus-newsrc-options-n nil
1756 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1758 (defvar gnus-newsrc-last-checked-date nil
1759 "Date Gnus last asked server for new newsgroups.")
1761 (defvar gnus-topic-topology nil
1762 "The complete topic hierarchy.")
1764 (defvar gnus-topic-alist nil
1765 "The complete topic-group alist.")
1767 (defvar gnus-newsrc-alist nil
1768 "Assoc list of read articles.
1769 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1771 (defvar gnus-newsrc-hashtb nil
1772 "Hashtable of gnus-newsrc-alist.")
1774 (defvar gnus-killed-list nil
1775 "List of killed newsgroups.")
1777 (defvar gnus-killed-hashtb nil
1778 "Hash table equivalent of gnus-killed-list.")
1780 (defvar gnus-zombie-list nil
1781 "List of almost dead newsgroups.")
1783 (defvar gnus-description-hashtb nil
1784 "Descriptions of newsgroups.")
1786 (defvar gnus-list-of-killed-groups nil
1787 "List of newsgroups that have recently been killed by the user.")
1789 (defvar gnus-active-hashtb nil
1790 "Hashtable of active articles.")
1792 (defvar gnus-moderated-list nil
1793 "List of moderated newsgroups.")
1795 (defvar gnus-group-marked nil)
1797 (defvar gnus-current-startup-file nil
1798 "Startup file for the current host.")
1800 (defvar gnus-last-search-regexp nil
1801 "Default regexp for article search command.")
1803 (defvar gnus-last-shell-command nil
1804 "Default shell command on article.")
1806 (defvar gnus-current-select-method nil
1807 "The current method for selecting a newsgroup.")
1809 (defvar gnus-group-list-mode nil)
1811 (defvar gnus-article-internal-prepare-hook nil)
1813 (defvar gnus-newsgroup-name nil)
1814 (defvar gnus-newsgroup-begin nil)
1815 (defvar gnus-newsgroup-end nil)
1816 (defvar gnus-newsgroup-last-rmail nil)
1817 (defvar gnus-newsgroup-last-mail nil)
1818 (defvar gnus-newsgroup-last-folder nil)
1819 (defvar gnus-newsgroup-last-file nil)
1820 (defvar gnus-newsgroup-auto-expire nil)
1821 (defvar gnus-newsgroup-active nil)
1823 (defvar gnus-newsgroup-data nil)
1824 (defvar gnus-newsgroup-data-reverse nil)
1825 (defvar gnus-newsgroup-limit nil)
1826 (defvar gnus-newsgroup-limits nil)
1828 (defvar gnus-newsgroup-unreads nil
1829 "List of unread articles in the current newsgroup.")
1831 (defvar gnus-newsgroup-unselected nil
1832 "List of unselected unread articles in the current newsgroup.")
1834 (defvar gnus-newsgroup-reads nil
1835 "Alist of read articles and article marks in the current newsgroup.")
1837 (defvar gnus-newsgroup-expunged-tally nil)
1839 (defvar gnus-newsgroup-marked nil
1840 "List of ticked articles in the current newsgroup (a subset of unread art).")
1842 (defvar gnus-newsgroup-killed nil
1843 "List of ranges of articles that have been through the scoring process.")
1845 (defvar gnus-newsgroup-cached nil
1846 "List of articles that come from the article cache.")
1848 (defvar gnus-newsgroup-saved nil
1849 "List of articles that have been saved.")
1851 (defvar gnus-newsgroup-kill-headers nil)
1853 (defvar gnus-newsgroup-replied nil
1854 "List of articles that have been replied to in the current newsgroup.")
1856 (defvar gnus-newsgroup-expirable nil
1857 "List of articles in the current newsgroup that can be expired.")
1859 (defvar gnus-newsgroup-processable nil
1860 "List of articles in the current newsgroup that can be processed.")
1862 (defvar gnus-newsgroup-bookmarks nil
1863 "List of articles in the current newsgroup that have bookmarks.")
1865 (defvar gnus-newsgroup-dormant nil
1866 "List of dormant articles in the current newsgroup.")
1868 (defvar gnus-newsgroup-scored nil
1869 "List of scored articles in the current newsgroup.")
1871 (defvar gnus-newsgroup-headers nil
1872 "List of article headers in the current newsgroup.")
1874 (defvar gnus-newsgroup-threads nil)
1876 (defvar gnus-newsgroup-prepared nil
1877 "Whether the current group has been prepared properly.")
1879 (defvar gnus-newsgroup-ancient nil
1880 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1882 (defvar gnus-newsgroup-sparse nil)
1884 (defvar gnus-current-article nil)
1885 (defvar gnus-article-current nil)
1886 (defvar gnus-current-headers nil)
1887 (defvar gnus-have-all-headers nil)
1888 (defvar gnus-last-article nil)
1889 (defvar gnus-newsgroup-history nil)
1890 (defvar gnus-current-kill-article nil)
1892 ;; Save window configuration.
1893 (defvar gnus-prev-winconf nil)
1895 (defvar gnus-summary-mark-positions nil)
1896 (defvar gnus-group-mark-positions nil)
1898 (defvar gnus-reffed-article-number nil)
1900 ;;; Let the byte-compiler know that we know about this variable.
1901 (defvar rmail-default-rmail-file)
1903 (defvar gnus-cache-removable-articles nil)
1905 (defvar gnus-dead-summary nil)
1907 (defconst gnus-summary-local-variables
1908 '(gnus-newsgroup-name
1909 gnus-newsgroup-begin gnus-newsgroup-end
1910 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1911 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1912 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1913 gnus-newsgroup-unselected gnus-newsgroup-marked
1914 gnus-newsgroup-reads gnus-newsgroup-saved
1915 gnus-newsgroup-replied gnus-newsgroup-expirable
1916 gnus-newsgroup-processable gnus-newsgroup-killed
1917 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1918 gnus-newsgroup-headers gnus-newsgroup-threads
1919 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1920 gnus-current-article gnus-current-headers gnus-have-all-headers
1921 gnus-last-article gnus-article-internal-prepare-hook
1922 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1923 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1924 gnus-newsgroup-async
1925 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1926 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1927 gnus-newsgroup-history gnus-newsgroup-ancient
1928 gnus-newsgroup-sparse
1929 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1930 gnus-newsgroup-adaptive-score-file
1931 (gnus-newsgroup-expunged-tally . 0)
1932 gnus-cache-removable-articles gnus-newsgroup-cached
1933 gnus-newsgroup-data gnus-newsgroup-data-reverse
1934 gnus-newsgroup-limit gnus-newsgroup-limits)
1935 "Variables that are buffer-local to the summary buffers.")
1937 (defconst gnus-bug-message
1938 "Sending a bug report to the Gnus Towers.
1939 ========================================
1941 The buffer below is a mail buffer. When you press `C-c C-c', it will
1942 be sent to the Gnus Bug Exterminators.
1944 At the bottom of the buffer you'll see lots of variable settings.
1945 Please do not delete those. They will tell the Bug People what your
1946 environment is, so that it will be easier to locate the bugs.
1948 If you have found a bug that makes Emacs go \"beep\", set
1949 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1950 and include the backtrace in your bug report.
1952 Please describe the bug in annoying, painstaking detail.
1954 Thank you for your help in stamping out bugs.
1957 ;;; End of variables.
1959 ;; Define some autoload functions Gnus might use.
1962 ;; This little mapcar goes through the list below and marks the
1963 ;; symbols in question as autoloaded functions.
1966 (let ((interactive (nth 1 (memq ':interactive package))))
1970 (when (consp function)
1971 (setq keymap (car (memq 'keymap function)))
1972 (setq function (car function)))
1973 (autoload function (car package) nil interactive keymap)))
1974 (if (eq (nth 1 package) ':interactive)
1977 '(("metamail" metamail-buffer)
1978 ("info" Info-goto-node)
1979 ("hexl" hexl-hex-string-to-integer)
1980 ("pp" pp pp-to-string pp-eval-expression)
1981 ("mail-extr" mail-extract-address-components)
1982 ("nnmail" nnmail-split-fancy nnmail-article-group)
1983 ("nnvirtual" nnvirtual-catchup-group)
1984 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1985 timezone-make-sortable-date timezone-make-time-string)
1986 ("sendmail" mail-position-on-field mail-setup)
1987 ("rmailout" rmail-output)
1988 ("rnewspost" news-mail-other-window news-reply-yank-original
1989 news-caesar-buffer-body)
1990 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1992 ("gnus-soup" :interactive t
1993 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1994 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1995 ("nnsoup" nnsoup-pack-replies)
1996 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1997 gnus-Folder-save-name gnus-folder-save-name)
1998 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1999 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2000 gnus-server-make-menu-bar gnus-article-make-menu-bar
2001 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2002 gnus-summary-highlight-line gnus-carpal-setup-buffer
2003 gnus-group-highlight-line
2004 gnus-article-add-button gnus-insert-next-page-button
2005 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2006 ("gnus-vis" :interactive t
2007 gnus-article-push-button gnus-article-press-button
2008 gnus-article-highlight gnus-article-highlight-some
2009 gnus-article-highlight-headers gnus-article-highlight-signature
2010 gnus-article-add-buttons gnus-article-add-buttons-to-head
2011 gnus-article-next-button gnus-article-prev-button)
2012 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2013 gnus-demon-add-disconnection gnus-demon-add-handler
2014 gnus-demon-remove-handler)
2015 ("gnus-demon" :interactive t
2016 gnus-demon-init gnus-demon-cancel)
2017 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2018 gnus-tree-open gnus-tree-close)
2019 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2020 gnus-nocem-unwanted-article-p)
2021 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2022 ("gnus-srvr" gnus-browse-foreign-server)
2023 ("gnus-cite" :interactive t
2024 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2025 gnus-article-hide-citation gnus-article-fill-cited-article)
2026 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2027 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2028 gnus-execute gnus-expunge)
2029 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2030 gnus-cache-possibly-remove-articles gnus-cache-request-article
2031 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2032 gnus-cache-enter-remove-article gnus-cached-article-p
2033 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2034 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2035 gnus-cache-remove-article)
2036 ("gnus-score" :interactive t
2037 gnus-summary-increase-score gnus-summary-lower-score
2038 gnus-score-flush-cache gnus-score-close
2039 gnus-score-raise-same-subject-and-select
2040 gnus-score-raise-same-subject gnus-score-default
2041 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2042 gnus-score-lower-same-subject gnus-score-lower-thread
2043 gnus-possibly-score-headers)
2045 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2046 gnus-current-score-file-nondirectory gnus-score-adaptive
2047 gnus-score-find-trace gnus-score-file-name)
2048 ("gnus-edit" :interactive t gnus-score-customize)
2049 ("gnus-topic" :interactive t gnus-topic-mode)
2050 ("gnus-topic" gnus-topic-remove-group)
2051 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2052 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2053 ("gnus-uu" :interactive t
2054 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2055 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2056 gnus-uu-mark-by-regexp gnus-uu-mark-all
2057 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2058 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2059 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2060 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2061 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2062 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2063 gnus-uu-decode-binhex-view)
2064 ("gnus-msg" (gnus-summary-send-map keymap)
2065 gnus-mail-yank-original gnus-mail-send-and-exit
2066 gnus-sendmail-setup-mail gnus-article-mail
2067 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2068 ("gnus-msg" :interactive t
2069 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2070 gnus-summary-followup gnus-summary-followup-with-original
2071 gnus-summary-followup-and-reply
2072 gnus-summary-followup-and-reply-with-original
2073 gnus-summary-cancel-article gnus-summary-supersede-article
2074 gnus-post-news gnus-inews-news gnus-cancel-news
2075 gnus-summary-reply gnus-summary-reply-with-original
2076 gnus-summary-mail-forward gnus-summary-mail-other-window
2078 ("gnus-picon" :interactive t gnus-article-display-picons
2079 gnus-group-display-picons gnus-picons-article-display-x-face)
2080 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2081 gnus-grouplens-mode)
2082 ("gnus-vm" gnus-vm-mail-setup)
2083 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2084 gnus-summary-save-article-vm gnus-yank-article))))
2088 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2089 ;; If you want the cursor to go somewhere else, set these two
2090 ;; functions in some startup hook to whatever you want.
2091 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2092 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2094 ;;; Various macros and substs.
2096 (defun gnus-header-from (header)
2097 (mail-header-from header))
2099 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2100 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2101 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2102 `(let ((,tempvar (selected-window)))
2105 (pop-to-buffer ,buffer)
2107 (select-window ,tempvar)))))
2109 (defmacro gnus-gethash (string hashtable)
2110 "Get hash value of STRING in HASHTABLE."
2111 `(symbol-value (intern-soft ,string ,hashtable)))
2113 (defmacro gnus-sethash (string value hashtable)
2114 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2115 `(set (intern ,string ,hashtable) ,value))
2117 (defmacro gnus-intern-safe (string hashtable)
2118 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2119 `(let ((symbol (intern ,string ,hashtable)))
2124 (defmacro gnus-group-unread (group)
2125 "Get the currently computed number of unread articles in GROUP."
2126 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2128 (defmacro gnus-group-entry (group)
2129 "Get the newsrc entry for GROUP."
2130 `(gnus-gethash ,group gnus-newsrc-hashtb))
2132 (defmacro gnus-active (group)
2133 "Get active info on GROUP."
2134 `(gnus-gethash ,group gnus-active-hashtb))
2136 (defmacro gnus-set-active (group active)
2137 "Set GROUP's active info."
2138 `(gnus-sethash ,group ,active gnus-active-hashtb))
2140 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2141 ;; function `substring' might cut on a middle of multi-octet
2143 (defun gnus-truncate-string (str width)
2144 (substring str 0 width))
2146 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2147 ;; to limit the length of a string. This function is necessary since
2148 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2149 (defsubst gnus-limit-string (str width)
2150 (if (> (length str) width)
2151 (substring str 0 width)
2154 (defsubst gnus-simplify-subject-re (subject)
2155 "Remove \"Re:\" from subject lines."
2156 (if (string-match "^[Rr][Ee]: *" subject)
2157 (substring subject (match-end 0))
2160 (defsubst gnus-functionp (form)
2161 "Return non-nil if FORM is funcallable."
2162 (or (and (symbolp form) (fboundp form))
2163 (and (listp form) (eq (car form) 'lambda))))
2165 (defsubst gnus-goto-char (point)
2166 (and point (goto-char point)))
2168 (defmacro gnus-buffer-exists-p (buffer)
2169 `(let ((buffer ,buffer))
2171 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2174 (defmacro gnus-kill-buffer (buffer)
2175 `(let ((buf ,buffer))
2176 (if (gnus-buffer-exists-p buf)
2177 (kill-buffer buf))))
2179 (defsubst gnus-point-at-bol ()
2180 "Return point at the beginning of the line."
2187 (defsubst gnus-point-at-eol ()
2188 "Return point at the end of the line."
2195 (defun gnus-alive-p ()
2196 "Say whether Gnus is running or not."
2197 (and gnus-group-buffer
2198 (get-buffer gnus-group-buffer)))
2200 ;; Delete the current line (and the next N lines.);
2201 (defmacro gnus-delete-line (&optional n)
2202 `(delete-region (progn (beginning-of-line) (point))
2203 (progn (forward-line ,(or n 1)) (point))))
2205 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2206 (defvar gnus-init-inhibit nil)
2207 (defun gnus-read-init-file (&optional inhibit-next)
2208 (if gnus-init-inhibit
2209 (setq gnus-init-inhibit nil)
2210 (setq gnus-init-inhibit inhibit-next)
2212 (or (and (file-exists-p gnus-init-file)
2213 ;; Don't try to load a directory.
2214 (not (file-directory-p gnus-init-file)))
2215 (file-exists-p (concat gnus-init-file ".el"))
2216 (file-exists-p (concat gnus-init-file ".elc")))
2218 (load gnus-init-file nil t)
2220 (error "Error in %s: %s" gnus-init-file var))))))
2222 ;; Info access macros.
2224 (defmacro gnus-info-group (info)
2226 (defmacro gnus-info-rank (info)
2228 (defmacro gnus-info-read (info)
2230 (defmacro gnus-info-marks (info)
2232 (defmacro gnus-info-method (info)
2234 (defmacro gnus-info-params (info)
2237 (defmacro gnus-info-level (info)
2238 `(let ((rank (gnus-info-rank ,info)))
2242 (defmacro gnus-info-score (info)
2243 `(let ((rank (gnus-info-rank ,info)))
2244 (or (and (consp rank) (cdr rank)) 0)))
2246 (defmacro gnus-info-set-group (info group)
2247 `(setcar ,info ,group))
2248 (defmacro gnus-info-set-rank (info rank)
2249 `(setcar (nthcdr 1 ,info) ,rank))
2250 (defmacro gnus-info-set-read (info read)
2251 `(setcar (nthcdr 2 ,info) ,read))
2252 (defmacro gnus-info-set-marks (info marks)
2253 `(setcar (nthcdr 3 ,info) ,marks))
2254 (defmacro gnus-info-set-method (info method)
2255 `(setcar (nthcdr 4 ,info) ,method))
2256 (defmacro gnus-info-set-params (info params)
2257 `(setcar (nthcdr 5 ,info) ,params))
2259 (defmacro gnus-info-set-level (info level)
2260 `(let ((rank (cdr ,info)))
2261 (if (consp (car rank))
2262 (setcar (car rank) ,level)
2263 (setcar rank ,level))))
2264 (defmacro gnus-info-set-score (info score)
2265 `(let ((rank (cdr ,info)))
2266 (if (consp (car rank))
2267 (setcdr (car rank) ,score)
2268 (setcar rank (cons (car rank) ,score)))))
2270 (defmacro gnus-get-info (group)
2271 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2273 (defun gnus-byte-code (func)
2274 "Return a form that can be `eval'ed based on FUNC."
2275 (let ((fval (symbol-function func)))
2276 (if (byte-code-function-p fval)
2277 (let ((flist (append fval nil)))
2278 (setcar flist 'byte-code)
2280 (cons 'progn (cddr fval)))))
2282 ;;; Load the compatability functions.
2289 ;; Format specs. The chunks below are the machine-generated forms
2290 ;; that are to be evaled as the result of the default format strings.
2291 ;; We write them in here to get them byte-compiled. That way the
2292 ;; default actions will be quite fast, while still retaining the full
2293 ;; flexibility of the user-defined format specs.
2295 ;; First we have lots of dummy defvars to let the compiler know these
2296 ;; are really dynamic variables.
2298 (defvar gnus-tmp-unread)
2299 (defvar gnus-tmp-replied)
2300 (defvar gnus-tmp-score-char)
2301 (defvar gnus-tmp-indentation)
2302 (defvar gnus-tmp-opening-bracket)
2303 (defvar gnus-tmp-lines)
2304 (defvar gnus-tmp-name)
2305 (defvar gnus-tmp-closing-bracket)
2306 (defvar gnus-tmp-subject-or-nil)
2307 (defvar gnus-tmp-subject)
2308 (defvar gnus-tmp-marked)
2309 (defvar gnus-tmp-marked-mark)
2310 (defvar gnus-tmp-subscribed)
2311 (defvar gnus-tmp-process-marked)
2312 (defvar gnus-tmp-number-of-unread)
2313 (defvar gnus-tmp-group-name)
2314 (defvar gnus-tmp-group)
2315 (defvar gnus-tmp-article-number)
2316 (defvar gnus-tmp-unread-and-unselected)
2317 (defvar gnus-tmp-news-method)
2318 (defvar gnus-tmp-news-server)
2319 (defvar gnus-tmp-article-number)
2320 (defvar gnus-mouse-face)
2321 (defvar gnus-mouse-face-prop)
2323 (defun gnus-summary-line-format-spec ()
2324 (insert gnus-tmp-unread gnus-tmp-replied
2325 gnus-tmp-score-char gnus-tmp-indentation)
2330 gnus-tmp-opening-bracket
2331 (format "%4d: %-20s"
2333 (if (> (length gnus-tmp-name) 20)
2334 (substring gnus-tmp-name 0 20)
2336 gnus-tmp-closing-bracket)
2338 gnus-mouse-face-prop gnus-mouse-face)
2339 (insert " " gnus-tmp-subject-or-nil "\n"))
2341 (defvar gnus-summary-line-format-spec
2342 (gnus-byte-code 'gnus-summary-line-format-spec))
2344 (defun gnus-summary-dummy-line-format-spec ()
2351 gnus-mouse-face-prop gnus-mouse-face)
2352 (insert " " gnus-tmp-subject "\n"))
2354 (defvar gnus-summary-dummy-line-format-spec
2355 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2357 (defun gnus-group-line-format-spec ()
2358 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2359 gnus-tmp-process-marked
2360 gnus-group-indentation
2361 (format "%5s: " gnus-tmp-number-of-unread))
2365 (insert gnus-tmp-group "\n")
2367 gnus-mouse-face-prop gnus-mouse-face))
2368 (defvar gnus-group-line-format-spec
2369 (gnus-byte-code 'gnus-group-line-format-spec))
2371 (defvar gnus-format-specs
2372 `((version . ,emacs-version)
2373 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2374 (summary-dummy ,gnus-summary-dummy-line-format
2375 ,gnus-summary-dummy-line-format-spec)
2376 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2378 (defvar gnus-article-mode-line-format-spec nil)
2379 (defvar gnus-summary-mode-line-format-spec nil)
2380 (defvar gnus-group-mode-line-format-spec nil)
2382 ;;; Phew. All that gruft is over, fortunately.
2386 ;;; Gnus Utility Functions
2389 (defun gnus-extract-address-components (from)
2391 ;; First find the address - the thing with the @ in it. This may
2392 ;; not be accurate in mail addresses, but does the trick most of
2393 ;; the time in news messages.
2394 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2395 (setq address (substring from (match-beginning 0) (match-end 0))))
2396 ;; Then we check whether the "name <address>" format is used.
2398 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2399 ;; Linear white space is not required.
2400 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2401 (and (setq name (substring from 0 (match-beginning 0)))
2402 ;; Strip any quotes from the name.
2403 (string-match "\".*\"" name)
2404 (setq name (substring name 1 (1- (match-end 0))))))
2405 ;; If not, then "address (name)" is used.
2407 (and (string-match "(.+)" from)
2408 (setq name (substring from (1+ (match-beginning 0))
2409 (1- (match-end 0)))))
2410 (and (string-match "()" from)
2411 (setq name address))
2412 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2413 ;; XOVER might not support folded From headers.
2414 (and (string-match "(.*" from)
2415 (setq name (substring from (1+ (match-beginning 0))
2417 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2418 (list (or name from) (or address from))))
2420 (defun gnus-fetch-field (field)
2421 "Return the value of the header FIELD of current article."
2424 (let ((case-fold-search t))
2425 (nnheader-narrow-to-headers)
2426 (mail-fetch-field field)))))
2428 (defun gnus-goto-colon ()
2430 (search-forward ":" (gnus-point-at-eol) t))
2433 (defun gnus-update-format (var)
2434 "Update the format specification near point."
2439 ;; Find the end of the current word.
2440 (re-search-forward "[ \t\n]" nil t)
2442 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2443 (match-string 1)))))
2444 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2445 (match-string 1 var))))
2446 (entry (assq type gnus-format-specs))
2449 (setq gnus-format-specs (delq entry gnus-format-specs)))
2451 (intern (format "%s-spec" var))
2452 (gnus-parse-format (setq value (symbol-value (intern var)))
2453 (symbol-value (intern (format "%s-alist" var)))
2454 (not (string-match "mode" var))))
2455 (setq spec (symbol-value (intern (format "%s-spec" var))))
2456 (push (list type value spec) gnus-format-specs)
2458 (pop-to-buffer "*Gnus Format*")
2460 (lisp-interaction-mode)
2461 (insert (pp-to-string spec))))
2463 (defun gnus-update-format-specifications (&optional force)
2464 "Update all (necessary) format specifications."
2465 ;; Make the indentation array.
2466 (gnus-make-thread-indent-array)
2468 ;; See whether all the stored info needs to be flushed.
2470 (not (equal emacs-version
2471 (cdr (assq 'version gnus-format-specs)))))
2472 (setq gnus-format-specs nil))
2474 ;; Go through all the formats and see whether they need updating.
2475 (let ((types '(summary summary-dummy group
2476 summary-mode group-mode article-mode))
2477 new-format entry type val)
2478 (while (setq type (pop types))
2479 ;; Jump to the proper buffer to find out the value of
2480 ;; the variable, if possible. (It may be buffer-local.)
2482 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2484 (when (and (boundp buffer)
2485 (setq val (symbol-value buffer))
2487 (buffer-name (get-buffer val)))
2488 (set-buffer (get-buffer val)))
2489 (setq new-format (symbol-value
2490 (intern (format "gnus-%s-line-format" type))))))
2491 (setq entry (cdr (assq type gnus-format-specs)))
2493 (equal (car entry) new-format))
2494 ;; Use the old format.
2495 (set (intern (format "gnus-%s-line-format-spec" type))
2497 ;; This is a new format.
2499 (if (not (stringp new-format))
2500 ;; This is a function call or something.
2502 ;; This is a "real" format.
2506 (intern (format "gnus-%s-line-format-alist"
2507 (if (eq type 'article-mode)
2508 'summary-mode type))))
2509 (not (string-match "mode$" (symbol-name type))))))
2510 ;; Enter the new format spec into the list.
2513 (setcar (cdr entry) val)
2514 (setcar entry new-format))
2515 (push (list type new-format val) gnus-format-specs))
2516 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2518 (push (cons 'version emacs-version) gnus-format-specs)
2520 (gnus-update-group-mark-positions)
2521 (gnus-update-summary-mark-positions))
2523 (defun gnus-update-summary-mark-positions ()
2524 "Compute where the summary marks are to go."
2526 (let ((gnus-replied-mark 129)
2527 (gnus-score-below-mark 130)
2528 (gnus-score-over-mark 130)
2532 (gnus-set-work-buffer)
2533 (gnus-summary-insert-line
2534 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2535 (goto-char (point-min))
2536 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2538 (goto-char (point-min))
2539 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2541 (goto-char (point-min))
2542 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2544 (setq gnus-summary-mark-positions pos))))
2546 (defun gnus-update-group-mark-positions ()
2548 (let ((gnus-process-mark 128)
2549 (gnus-group-marked '("dummy.group")))
2550 (gnus-set-active "dummy.group" '(0 . 0))
2551 (gnus-set-work-buffer)
2552 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2553 (goto-char (point-min))
2554 (setq gnus-group-mark-positions
2555 (list (cons 'process (and (search-forward "\200" nil t)
2556 (- (point) 2))))))))
2558 (defvar gnus-mouse-face-0 'highlight)
2559 (defvar gnus-mouse-face-1 'highlight)
2560 (defvar gnus-mouse-face-2 'highlight)
2561 (defvar gnus-mouse-face-3 'highlight)
2562 (defvar gnus-mouse-face-4 'highlight)
2564 (defun gnus-mouse-face-function (form type)
2566 (point) (progn ,@form (point))
2567 gnus-mouse-face-prop
2570 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2572 (defvar gnus-face-0 'bold)
2573 (defvar gnus-face-1 'italic)
2574 (defvar gnus-face-2 'bold-italic)
2575 (defvar gnus-face-3 'bold)
2576 (defvar gnus-face-4 'bold)
2578 (defun gnus-face-face-function (form type)
2580 (point) (progn ,@form (point))
2581 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2583 (defun gnus-max-width-function (el max-width)
2584 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2586 `(if (> (length ,el) ,max-width)
2587 (substring ,el 0 ,max-width)
2589 `(let ((val (eval ,el)))
2591 (setq val (int-to-string val)))
2592 (if (> (length val) ,max-width)
2593 (substring val 0 ,max-width)
2596 (defun gnus-parse-format (format spec-alist &optional insert)
2597 ;; This function parses the FORMAT string with the help of the
2598 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2599 ;; string. If the FORMAT string contains the specifiers %( and %)
2600 ;; the text between them will have the mouse-face text property.
2602 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2604 (gnus-parse-complex-format format spec-alist)
2605 ;; This is a simple format.
2606 (gnus-parse-simple-format format spec-alist insert)))
2608 (defun gnus-parse-complex-format (format spec-alist)
2610 (gnus-set-work-buffer)
2612 (goto-char (point-min))
2613 (while (re-search-forward "\"" nil t)
2614 (replace-match "\\\"" nil t))
2615 (goto-char (point-min))
2617 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2618 (let ((number (if (match-beginning 1)
2619 (match-string 1) "0"))
2620 (delim (aref (match-string 2) 0)))
2621 (if (or (= delim ?\() (= delim ?\{))
2622 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2624 (replace-match "\")\""))))
2625 (goto-char (point-max))
2627 (goto-char (point-min))
2628 (let ((form (read (current-buffer))))
2629 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2631 (defun gnus-complex-form-to-spec (form spec-alist)
2636 (gnus-parse-simple-format sform spec-alist t)
2637 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2638 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2642 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2643 ;; This function parses the FORMAT string with the help of the
2644 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2647 spec flist fstring newspec elem beg result dontinsert)
2649 (gnus-set-work-buffer)
2651 (goto-char (point-min))
2652 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2654 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2656 beg (1+ (match-beginning 0)))
2657 ;; First check if there are any specs that look anything like
2658 ;; "%12,12A", ie. with a "max width specification". These have
2659 ;; to be treated specially.
2660 (if (setq beg (match-beginning 1))
2664 (1+ (match-beginning 1)) (match-end 1))))
2666 (setq beg (match-beginning 2)))
2667 ;; Find the specification from `spec-alist'.
2668 (unless (setq elem (cdr (assq spec spec-alist)))
2669 (setq elem '("*" ?s)))
2670 ;; Treat user defined format specifiers specially.
2671 (when (eq (car elem) 'gnus-tmp-user-defined)
2674 (list (intern (concat "gnus-user-format-function-"
2676 'gnus-tmp-header) ?s))
2677 (delete-region (match-beginning 3) (match-end 3)))
2678 (if (not (zerop max-width))
2679 (let ((el (car elem)))
2680 (cond ((= (cadr elem) ?c)
2681 (setq el (list 'char-to-string el)))
2683 (setq el (list 'int-to-string el))))
2684 (setq flist (cons (gnus-max-width-function el max-width)
2688 (setq flist (cons (car elem) flist))
2689 (setq newspec (cadr elem)))))
2690 ;; Remove the old specification (and possibly a ",12" string).
2691 (delete-region beg (match-end 2))
2692 ;; Insert the new specification.
2695 (setq fstring (buffer-substring 1 (point-max))))
2696 ;; Do some postprocessing to increase efficiency.
2701 ((string= fstring "")
2703 ;; Not a format string.
2704 ((not (string-match "%" fstring))
2706 ;; A format string with just a single string spec.
2707 ((string= fstring "%s")
2709 ;; A single character.
2710 ((string= fstring "%c")
2713 ((string= fstring "%d")
2716 (list `(princ ,(car flist)))
2717 (list `(int-to-string ,(car flist)))))
2718 ;; Just lots of chars and strings.
2719 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2721 ;; A single string spec at the beginning of the spec.
2722 ((string-match "\\`%[sc][^%]+\\'" fstring)
2723 (list (car flist) (substring fstring 2)))
2724 ;; A single string spec in the middle of the spec.
2725 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2726 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2727 ;; A single string spec in the end of the spec.
2728 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2729 (list (match-string 1 fstring) (car flist)))
2730 ;; A more complex spec.
2732 (list (cons 'format (cons fstring (nreverse flist)))))))
2738 (cons 'insert result)))
2739 (cond ((stringp result)
2742 (cons 'concat result))
2745 (defun gnus-eval-format (format &optional alist props)
2746 "Eval the format variable FORMAT, using ALIST.
2747 If PROPS, insert the result."
2748 (let ((form (gnus-parse-format format alist props)))
2750 (add-text-properties (point) (progn (eval form) (point)) props)
2753 (defun gnus-remove-text-with-property (prop)
2754 "Delete all text in the current buffer with text property PROP."
2756 (goto-char (point-min))
2758 (while (get-text-property (point) prop)
2760 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2762 (defun gnus-set-work-buffer ()
2763 (if (get-buffer gnus-work-buffer)
2765 (set-buffer gnus-work-buffer)
2767 (set-buffer (get-buffer-create gnus-work-buffer))
2768 (kill-all-local-variables)
2769 (buffer-disable-undo (current-buffer))
2770 (gnus-add-current-to-buffer-list)))
2772 ;; Article file names when saving.
2774 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2775 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2776 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2777 Otherwise, it is like ~/News/news/group/num."
2780 (concat (if (gnus-use-long-file-name 'not-save)
2781 (gnus-capitalize-newsgroup newsgroup)
2782 (gnus-newsgroup-directory-form newsgroup))
2783 "/" (int-to-string (mail-header-number headers)))
2784 (or gnus-article-save-directory "~/News"))))
2786 (string-equal (file-name-directory default)
2787 (file-name-directory last-file))
2788 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2790 (or last-file default))))
2792 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2793 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2794 If variable `gnus-use-long-file-name' is non-nil, it is
2795 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2798 (concat (if (gnus-use-long-file-name 'not-save)
2800 (gnus-newsgroup-directory-form newsgroup))
2801 "/" (int-to-string (mail-header-number headers)))
2802 (or gnus-article-save-directory "~/News"))))
2804 (string-equal (file-name-directory default)
2805 (file-name-directory last-file))
2806 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2808 (or last-file default))))
2810 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2811 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2812 If variable `gnus-use-long-file-name' is non-nil, it is
2813 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2816 (if (gnus-use-long-file-name 'not-save)
2817 (gnus-capitalize-newsgroup newsgroup)
2818 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2819 (or gnus-article-save-directory "~/News"))))
2821 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2822 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2823 If variable `gnus-use-long-file-name' is non-nil, it is
2824 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2827 (if (gnus-use-long-file-name 'not-save)
2829 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2830 (or gnus-article-save-directory "~/News"))))
2832 ;; For subscribing new newsgroup
2834 (defun gnus-subscribe-hierarchical-interactive (groups)
2835 (let ((groups (sort groups 'string<))
2836 prefixes prefix start ans group starts)
2838 (setq prefixes (list "^"))
2839 (while (and groups prefixes)
2840 (while (not (string-match (car prefixes) (car groups)))
2841 (setq prefixes (cdr prefixes)))
2842 (setq prefix (car prefixes))
2843 (setq start (1- (length prefix)))
2844 (if (and (string-match "[^\\.]\\." (car groups) start)
2847 (concat "^" (substring (car groups) 0 (match-end 0))))
2848 (string-match prefix (cadr groups)))
2850 (setq prefixes (cons prefix prefixes))
2851 (message "Descend hierarchy %s? ([y]nsq): "
2852 (substring prefix 1 (1- (length prefix))))
2853 (setq ans (read-char))
2856 (string-match prefix
2857 (setq group (car groups))))
2858 (setq gnus-killed-list
2859 (cons group gnus-killed-list))
2860 (gnus-sethash group group gnus-killed-hashtb)
2861 (setq groups (cdr groups)))
2862 (setq starts (cdr starts)))
2865 (string-match prefix
2866 (setq group (car groups))))
2867 (gnus-sethash group group gnus-killed-hashtb)
2868 (gnus-subscribe-alphabetically (car groups))
2869 (setq groups (cdr groups)))
2870 (setq starts (cdr starts)))
2873 (setq group (car groups))
2874 (setq gnus-killed-list (cons group gnus-killed-list))
2875 (gnus-sethash group group gnus-killed-hashtb)
2876 (setq groups (cdr groups))))
2878 (message "Subscribe %s? ([n]yq)" (car groups))
2879 (setq ans (read-char))
2880 (setq group (car groups))
2882 (gnus-subscribe-alphabetically (car groups))
2883 (gnus-sethash group group gnus-killed-hashtb))
2886 (setq group (car groups))
2887 (setq gnus-killed-list (cons group gnus-killed-list))
2888 (gnus-sethash group group gnus-killed-hashtb)
2889 (setq groups (cdr groups))))
2891 (setq gnus-killed-list (cons group gnus-killed-list))
2892 (gnus-sethash group group gnus-killed-hashtb)))
2893 (setq groups (cdr groups)))))))
2895 (defun gnus-subscribe-randomly (newsgroup)
2896 "Subscribe new NEWSGROUP by making it the first newsgroup."
2897 (gnus-subscribe-newsgroup newsgroup))
2899 (defun gnus-subscribe-alphabetically (newgroup)
2900 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2901 (let ((groups (cdr gnus-newsrc-alist))
2903 (while (and (not before) groups)
2904 (if (string< newgroup (caar groups))
2905 (setq before (caar groups))
2906 (setq groups (cdr groups))))
2907 (gnus-subscribe-newsgroup newgroup before)))
2909 (defun gnus-subscribe-hierarchically (newgroup)
2910 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2911 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2913 (set-buffer (find-file-noselect gnus-current-startup-file))
2914 (let ((groupkey newgroup)
2916 (while (and (not before) groupkey)
2917 (goto-char (point-min))
2919 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2920 (while (and (re-search-forward groupkey-re nil t)
2922 (setq before (match-string 1))
2923 (string< before newgroup)))))
2924 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2926 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2927 (substring groupkey (match-beginning 1) (match-end 1)))))
2928 (gnus-subscribe-newsgroup newgroup before))))
2930 (defun gnus-subscribe-interactively (group)
2931 "Subscribe the new GROUP interactively.
2932 It is inserted in hierarchical newsgroup order if subscribed. If not,
2934 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2935 (gnus-subscribe-hierarchically group)
2936 (push group gnus-killed-list)))
2938 (defun gnus-subscribe-zombies (group)
2939 "Make the new GROUP into a zombie group."
2940 (push group gnus-zombie-list))
2942 (defun gnus-subscribe-killed (group)
2943 "Make the new GROUP a killed group."
2944 (push group gnus-killed-list))
2946 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2947 "Subscribe new NEWSGROUP.
2948 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2949 the first newsgroup."
2950 ;; We subscribe the group by changing its level to `subscribed'.
2951 (gnus-group-change-level
2952 newsgroup gnus-level-default-subscribed
2953 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2954 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2958 (defun gnus-newsgroup-directory-form (newsgroup)
2959 "Make hierarchical directory name from NEWSGROUP name."
2960 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2961 (len (length newsgroup))
2963 ;; If this is a foreign group, we don't want to translate the
2965 (if (setq idx (string-match ":" newsgroup))
2966 (aset newsgroup idx ?/)
2968 ;; Replace all occurrences of `.' with `/'.
2970 (if (= (aref newsgroup idx) ?.)
2971 (aset newsgroup idx ?/))
2972 (setq idx (1+ idx)))
2975 (defun gnus-newsgroup-savable-name (group)
2976 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2978 (nnheader-replace-chars-in-string group ?/ ?.))
2980 (defun gnus-make-directory (dir)
2981 "Make DIRECTORY recursively."
2982 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2983 ;; of the many mysteries of the universe.
2984 (let* ((dir (expand-file-name dir default-directory))
2986 (if (string-match "/$" dir)
2987 (setq dir (substring dir 0 (match-beginning 0))))
2988 ;; First go down the path until we find a directory that exists.
2989 (while (not (file-exists-p dir))
2990 (setq dirs (cons dir dirs))
2991 (string-match "/[^/]+$" dir)
2992 (setq dir (substring dir 0 (match-beginning 0))))
2993 ;; Then create all the subdirs.
2994 (while (and dirs (not err))
2996 (make-directory (car dirs))
2997 (error (setq err t)))
2998 (setq dirs (cdr dirs)))
2999 ;; We return whether we were successful or not.
3002 (defun gnus-capitalize-newsgroup (newsgroup)
3003 "Capitalize NEWSGROUP name."
3004 (and (not (zerop (length newsgroup)))
3005 (concat (char-to-string (upcase (aref newsgroup 0)))
3006 (substring newsgroup 1))))
3008 ;; Various... things.
3010 (defun gnus-simplify-subject (subject &optional re-only)
3011 "Remove `Re:' and words in parentheses.
3012 If RE-ONLY is non-nil, strip leading `Re:'s only."
3013 (let ((case-fold-search t)) ;Ignore case.
3014 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3015 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3016 (setq subject (substring subject (match-end 0))))
3017 ;; Remove uninteresting prefixes.
3018 (if (and (not re-only)
3019 gnus-simplify-ignored-prefixes
3020 (string-match gnus-simplify-ignored-prefixes subject))
3021 (setq subject (substring subject (match-end 0))))
3022 ;; Remove words in parentheses from end.
3024 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3025 (setq subject (substring subject 0 (match-beginning 0)))))
3026 ;; Return subject string.
3029 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3031 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3032 (defun gnus-simplify-buffer-fuzzy ()
3033 (goto-char (point-min))
3034 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3035 (goto-char (match-beginning 0))
3037 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3038 (looking-at "^[[].*:[ \t].*[]]$"))
3039 (goto-char (point-min))
3040 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3042 (replace-match "" t t))
3043 (goto-char (point-min))
3044 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3045 (goto-char (match-end 0))
3048 (progn (goto-char (match-beginning 0)))
3049 (re-search-forward ":"))))
3050 (goto-char (point-min))
3051 (while (re-search-forward "[ \t\n]*[[{(][^()\n]*[]})][ \t]*$" nil t)
3052 (replace-match "" t t))
3053 (goto-char (point-min))
3054 (while (re-search-forward "[ \t]+" nil t)
3055 (replace-match " " t t))
3056 (goto-char (point-min))
3057 (while (re-search-forward "[ \t]+$" nil t)
3058 (replace-match "" t t))
3059 (goto-char (point-min))
3060 (while (re-search-forward "^[ \t]+" nil t)
3061 (replace-match "" t t))
3062 (goto-char (point-min))
3063 (if gnus-simplify-subject-fuzzy-regexp
3064 (if (listp gnus-simplify-subject-fuzzy-regexp)
3065 (let ((list gnus-simplify-subject-fuzzy-regexp))
3067 (goto-char (point-min))
3068 (while (re-search-forward (car list) nil t)
3069 (replace-match "" t t))
3070 (setq list (cdr list))))
3071 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3072 (replace-match "" t t)))))
3074 (defun gnus-simplify-subject-fuzzy (subject)
3075 "Siplify a subject string fuzzily."
3077 (gnus-set-work-buffer)
3078 (let ((case-fold-search t))
3080 (inline (gnus-simplify-buffer-fuzzy))
3083 ;; Add the current buffer to the list of buffers to be killed on exit.
3084 (defun gnus-add-current-to-buffer-list ()
3085 (or (memq (current-buffer) gnus-buffer-list)
3086 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3088 (defun gnus-string> (s1 s2)
3089 (not (or (string< s1 s2)
3092 ;;; General various misc type functions.
3094 (defun gnus-clear-system ()
3095 "Clear all variables and buffers."
3096 ;; Clear Gnus variables.
3097 (let ((variables gnus-variable-list))
3099 (set (car variables) nil)
3100 (setq variables (cdr variables))))
3101 ;; Clear other internal variables.
3102 (setq gnus-list-of-killed-groups nil
3103 gnus-have-read-active-file nil
3104 gnus-newsrc-alist nil
3105 gnus-newsrc-hashtb nil
3106 gnus-killed-list nil
3107 gnus-zombie-list nil
3108 gnus-killed-hashtb nil
3109 gnus-active-hashtb nil
3110 gnus-moderated-list nil
3111 gnus-description-hashtb nil
3112 gnus-current-headers nil
3113 gnus-thread-indent-array nil
3114 gnus-newsgroup-headers nil
3115 gnus-newsgroup-name nil
3116 gnus-server-alist nil
3117 gnus-group-list-mode nil
3118 gnus-opened-servers nil
3119 gnus-current-select-method nil)
3120 (gnus-shutdown 'gnus)
3121 ;; Kill the startup file.
3122 (and gnus-current-startup-file
3123 (get-file-buffer gnus-current-startup-file)
3124 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3125 ;; Clear the dribble buffer.
3126 (gnus-dribble-clear)
3127 ;; Kill global KILL file buffer.
3128 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3129 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3130 (gnus-kill-buffer nntp-server-buffer)
3131 ;; Kill Gnus buffers.
3132 (while gnus-buffer-list
3133 (gnus-kill-buffer (pop gnus-buffer-list)))
3134 ;; Remove Gnus frames.
3135 (while gnus-created-frames
3136 (when (frame-live-p (car gnus-created-frames))
3137 ;; We slap a condition-case around this `delete-frame' to ensure
3138 ;; agains errors if we try do delete the single frame that's left.
3140 (delete-frame (car gnus-created-frames))
3142 (pop gnus-created-frames)))
3144 (defun gnus-windows-old-to-new (setting)
3145 ;; First we take care of the really, really old Gnus 3 actions.
3146 (when (symbolp setting)
3148 ;; Take care of ooold GNUS 3.x values.
3149 (cond ((eq setting 'SelectArticle) 'article)
3150 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3151 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3153 (if (or (listp setting)
3154 (not (and gnus-window-configuration
3155 (memq setting '(group summary article)))))
3157 (let* ((setting (if (eq setting 'group)
3158 (if (assq 'newsgroup gnus-window-configuration)
3160 'newsgroups) setting))
3161 (elem (cadr (assq setting gnus-window-configuration)))
3162 (total (apply '+ elem))
3163 (types '(group summary article))
3164 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3169 (or (not (numberp (nth i elem)))
3170 (zerop (nth i elem))
3172 (setq perc (/ (float (nth 0 elem)) total))
3173 (setq out (cons (if (eq pbuf (nth i types))
3174 (vector (nth i types) perc 'point)
3175 (vector (nth i types) perc))
3178 (list (nreverse out)))))
3181 (defun gnus-add-configuration (conf)
3182 "Add the window configuration CONF to `gnus-buffer-configuration'."
3183 (setq gnus-buffer-configuration
3184 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3185 gnus-buffer-configuration))))
3187 (defvar gnus-frame-list nil)
3189 (defun gnus-configure-frame (split &optional window)
3190 "Split WINDOW according to SPLIT."
3192 (setq window (get-buffer-window (current-buffer))))
3193 (select-window window)
3194 ;; This might be an old-stylee buffer config.
3195 (when (vectorp split)
3196 (setq split (append split nil)))
3197 (when (or (consp (car split))
3198 (vectorp (car split)))
3200 (push 'vertical split))
3201 ;; The SPLIT might be something that is to be evaled to
3202 ;; return a new SPLIT.
3203 (while (and (not (assq (car split) gnus-window-to-buffer))
3204 (gnus-functionp (car split)))
3205 (setq split (eval split)))
3206 (let* ((type (car split))
3208 (len (if (eq type 'horizontal) (window-width) (window-height)))
3210 (window-min-width (or gnus-window-min-width window-min-width))
3211 (window-min-height (or gnus-window-min-height window-min-height))
3212 s result new-win rest comp-subs size sub)
3214 ;; Nothing to do here.
3216 ;; Don't switch buffers.
3218 (and (memq 'point split) window))
3219 ;; This is a buffer to be selected.
3220 ((not (memq type '(frame horizontal vertical)))
3221 (let ((buffer (cond ((stringp type) type)
3222 (t (cdr (assq type gnus-window-to-buffer)))))
3225 (error "Illegal buffer type: %s" type))
3226 (unless (setq buf (get-buffer (if (symbolp buffer)
3227 (symbol-value buffer) buffer)))
3228 (setq buf (get-buffer-create (if (symbolp buffer)
3229 (symbol-value buffer) buffer))))
3230 (switch-to-buffer buf)
3231 ;; We return the window if it has the `point' spec.
3232 (and (memq 'point split) window)))
3233 ;; This is a frame split.
3235 (unless gnus-frame-list
3236 (setq gnus-frame-list (list (window-frame
3237 (get-buffer-window (current-buffer))))))
3239 params frame fresult)
3240 (while (< i (length subs))
3241 ;; Frame parameter is gotten from the sub-split.
3242 (setq params (cadr (elt subs i)))
3243 ;; It should be a list.
3244 (unless (listp params)
3246 ;; Create a new frame?
3247 (unless (setq frame (elt gnus-frame-list i))
3248 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3249 (push frame gnus-created-frames))
3250 ;; Is the old frame still alive?
3251 (unless (frame-live-p frame)
3252 (setcar (nthcdr i gnus-frame-list)
3253 (setq frame (make-frame params))))
3254 ;; Select the frame in question and do more splits there.
3255 (select-frame frame)
3256 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3258 ;; Select the frame that has the selected buffer.
3260 (select-frame (window-frame fresult)))))
3261 ;; This is a normal split.
3263 (when (> (length subs) 0)
3264 ;; First we have to compute the sizes of all new windows.
3266 (setq sub (append (pop subs) nil))
3267 (while (and (not (assq (car sub) gnus-window-to-buffer))
3268 (gnus-functionp (car sub)))
3269 (setq sub (eval sub)))
3271 (push sub comp-subs)
3272 (setq size (cadar comp-subs))
3273 (cond ((equal size 1.0)
3274 (setq rest (car comp-subs))
3277 (setq s (floor (* size len))))
3281 (error "Illegal size: %s" size)))
3282 ;; Try to make sure that we are inside the safe limits.
3284 ((eq type 'horizontal)
3285 (setq s (max s window-min-width)))
3286 ((eq type 'vertical)
3287 (setq s (max s window-min-height))))
3288 (setcar (cdar comp-subs) s)
3290 ;; Take care of the "1.0" spec.
3292 (setcar (cdr rest) (- len total))
3293 (error "No 1.0 specs in %s" split))
3294 ;; The we do the actual splitting in a nice recursive
3296 (setq comp-subs (nreverse comp-subs))
3298 (if (null (cdr comp-subs))
3299 (setq new-win window)
3301 (split-window window (cadar comp-subs)
3302 (eq type 'horizontal))))
3303 (setq result (or (gnus-configure-frame
3304 (car comp-subs) window) result))
3305 (select-window new-win)
3306 (setq window new-win)
3307 (setq comp-subs (cdr comp-subs))))
3308 ;; Return the proper window, if any.
3310 (select-window result))))))
3312 (defvar gnus-frame-split-p nil)
3314 (defun gnus-configure-windows (setting &optional force)
3315 (setq setting (gnus-windows-old-to-new setting))
3316 (let ((split (if (symbolp setting)
3317 (cadr (assq setting gnus-buffer-configuration))
3321 (setq gnus-frame-split-p nil)
3324 (error "No such setting: %s" setting))
3326 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3328 ;; All the windows mentioned are already visible, so we just
3329 ;; put point in the assigned buffer, and do not touch the
3331 (select-window all-visible)
3333 ;; Either remove all windows or just remove all Gnus windows.
3334 (let ((frame (selected-frame)))
3336 (if gnus-use-full-window
3337 ;; We want to remove all other windows.
3338 (if (not gnus-frame-split-p)
3339 ;; This is not a `frame' split, so we ignore the
3341 (delete-other-windows)
3342 ;; This is a `frame' split, so we delete all windows
3346 (unless (eq (cdr (assq 'minibuffer
3347 (frame-parameters frame)))
3349 (select-frame frame)
3350 (delete-other-windows)))
3352 ;; Just remove some windows.
3353 (gnus-remove-some-windows)
3354 (switch-to-buffer nntp-server-buffer))
3355 (select-frame frame)))
3357 (switch-to-buffer nntp-server-buffer)
3358 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3360 (defun gnus-all-windows-visible-p (split)
3361 "Say whether all buffers in SPLIT are currently visible.
3362 In particular, the value returned will be the window that
3364 (let ((stack (list split))
3366 type buffer win buf)
3367 (while (and (setq split (pop stack))
3369 ;; Be backwards compatible.
3370 (when (vectorp split)
3371 (setq split (append split nil)))
3372 (when (or (consp (car split))
3373 (vectorp (car split)))
3375 (push 'vertical split))
3376 ;; The SPLIT might be something that is to be evaled to
3377 ;; return a new SPLIT.
3378 (while (and (not (assq (car split) gnus-window-to-buffer))
3379 (gnus-functionp (car split)))
3380 (setq split (eval split)))
3382 (setq type (elt split 0))
3387 ((not (memq type '(horizontal vertical frame)))
3388 (setq buffer (cond ((stringp type) type)
3389 (t (cdr (assq type gnus-window-to-buffer)))))
3391 (error "Illegal buffer type: %s" type))
3392 (when (setq buf (get-buffer (if (symbolp buffer)
3393 (symbol-value buffer)
3395 (setq win (get-buffer-window buf t)))
3397 (when (memq 'point split)
3398 (setq all-visible win))
3399 (setq all-visible nil)))
3401 (when (eq type 'frame)
3402 (setq gnus-frame-split-p t))
3403 (setq stack (append (cddr split) stack)))))
3404 (unless (eq all-visible t)
3407 (defun gnus-window-top-edge (&optional window)
3408 (nth 1 (window-edges window)))
3410 (defun gnus-remove-some-windows ()
3411 (let ((buffers gnus-window-to-buffer)
3412 buf bufs lowest-buf lowest)
3414 ;; Remove windows on all known Gnus buffers.
3416 (setq buf (cdar buffers))
3418 (setq buf (and (boundp buf) (symbol-value buf))))
3420 (get-buffer-window buf)
3422 (setq bufs (cons buf bufs))
3424 (if (or (not lowest)
3425 (< (gnus-window-top-edge) lowest))
3427 (setq lowest (gnus-window-top-edge))
3428 (setq lowest-buf buf)))))
3429 (setq buffers (cdr buffers)))
3430 ;; Remove windows on *all* summary buffers.
3433 (let ((buf (window-buffer win)))
3434 (if (string-match "^\\*Summary" (buffer-name buf))
3436 (setq bufs (cons buf bufs))
3438 (if (or (not lowest)
3439 (< (gnus-window-top-edge) lowest))
3441 (setq lowest-buf buf)
3442 (setq lowest (gnus-window-top-edge)))))))))
3445 (pop-to-buffer lowest-buf)
3446 (switch-to-buffer nntp-server-buffer)))
3448 (and (not (eq (car bufs) lowest-buf))
3449 (delete-windows-on (car bufs)))
3450 (setq bufs (cdr bufs))))))
3452 (defun gnus-version ()
3453 "Version numbers of this version of Gnus."
3455 (let ((methods gnus-valid-select-methods)
3458 ;; Go through all the legal select methods and add their version
3459 ;; numbers to the total version string. Only the backends that are
3460 ;; currently in use will have their message numbers taken into
3463 (setq meth (intern (concat (caar methods) "-version")))
3465 (stringp (symbol-value meth))
3466 (setq mess (concat mess "; " (symbol-value meth))))
3467 (setq methods (cdr methods)))
3468 (gnus-message 2 mess)))
3470 (defun gnus-info-find-node ()
3471 "Find Info documentation of Gnus."
3473 ;; Enlarge info window if needed.
3474 (let ((mode major-mode)
3476 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3477 (setq gnus-info-buffer (current-buffer))
3478 (gnus-configure-windows 'info)))
3480 (defun gnus-days-between (date1 date2)
3481 ;; Return the number of days between date1 and date2.
3482 (- (gnus-day-number date1) (gnus-day-number date2)))
3484 (defun gnus-day-number (date)
3485 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3486 (timezone-parse-date date))))
3487 (timezone-absolute-from-gregorian
3488 (nth 1 dat) (nth 2 dat) (car dat))))
3490 (defun gnus-encode-date (date)
3491 "Convert DATE to internal time."
3492 (let* ((parse (timezone-parse-date date))
3493 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3494 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3495 (encode-time (caddr time) (cadr time) (car time)
3496 (caddr date) (cadr date) (car date) (nth 4 date))))
3498 (defun gnus-time-minus (t1 t2)
3499 "Subtract two internal times."
3500 (let ((borrow (< (cadr t1) (cadr t2))))
3501 (list (- (car t1) (car t2) (if borrow 1 0))
3502 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3504 (defun gnus-file-newer-than (file date)
3505 (let ((fdate (nth 5 (file-attributes file))))
3506 (or (> (car fdate) (car date))
3507 (and (= (car fdate) (car date))
3508 (> (nth 1 fdate) (nth 1 date))))))
3510 (defmacro gnus-local-set-keys (&rest plist)
3511 "Set the keys in PLIST in the current keymap."
3512 `(gnus-define-keys-1 (current-local-map) ',plist))
3514 (defmacro gnus-define-keys (keymap &rest plist)
3515 "Define all keys in PLIST in KEYMAP."
3516 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3518 (put 'gnus-define-keys 'lisp-indent-function 1)
3519 (put 'gnus-define-keys 'lisp-indent-hook 1)
3520 (put 'gnus-define-keymap 'lisp-indent-function 1)
3521 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3523 (defmacro gnus-define-keymap (keymap &rest plist)
3524 "Define all keys in PLIST in KEYMAP."
3525 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3527 (defun gnus-define-keys-1 (keymap plist)
3529 (error "Can't set keys in a null keymap"))
3530 (cond ((symbolp keymap)
3531 (setq keymap (symbol-value keymap)))
3534 (set (car keymap) nil)
3535 (define-prefix-command (car keymap))
3536 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3537 (setq keymap (symbol-value (car keymap)))))
3540 (when (symbolp (setq key (pop plist)))
3541 (setq key (symbol-value key)))
3542 (define-key keymap key (pop plist)))))
3544 (defun gnus-group-read-only-p (&optional group)
3545 "Check whether GROUP supports editing or not.
3546 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3547 that that variable is buffer-local to the summary buffers."
3548 (let ((group (or group gnus-newsgroup-name)))
3549 (not (gnus-check-backend-function 'request-replace-article group))))
3551 (defun gnus-group-total-expirable-p (group)
3552 "Check whether GROUP is total-expirable or not."
3553 (let ((params (gnus-info-params (gnus-get-info group))))
3554 (or (memq 'total-expire params)
3555 (cdr (assq 'total-expire params)) ; (total-expire . t)
3556 (and gnus-total-expirable-newsgroups ; Check var.
3557 (string-match gnus-total-expirable-newsgroups group)))))
3559 (defun gnus-group-auto-expirable-p (group)
3560 "Check whether GROUP is total-expirable or not."
3561 (let ((params (gnus-info-params (gnus-get-info group))))
3562 (or (memq 'auto-expire params)
3563 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3564 (and gnus-auto-expirable-newsgroups ; Check var.
3565 (string-match gnus-auto-expirable-newsgroups group)))))
3567 (defun gnus-virtual-group-p (group)
3568 "Say whether GROUP is virtual or not."
3569 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3570 gnus-valid-select-methods)))
3572 (defsubst gnus-simplify-subject-fully (subject)
3573 "Simplify a subject string according to the user's wishes."
3575 ((null gnus-summary-gather-subject-limit)
3576 (gnus-simplify-subject-re subject))
3577 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3578 (gnus-simplify-subject-fuzzy subject))
3579 ((numberp gnus-summary-gather-subject-limit)
3580 (gnus-limit-string (gnus-simplify-subject-re subject)
3581 gnus-summary-gather-subject-limit))
3585 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3586 "Check whether two subjects are equal. If optional argument
3587 simple-first is t, first argument is already simplified."
3589 ((null simple-first)
3590 (equal (gnus-simplify-subject-fully s1)
3591 (gnus-simplify-subject-fully s2)))
3594 (gnus-simplify-subject-fully s2)))))
3596 ;; Returns a list of writable groups.
3597 (defun gnus-writable-groups ()
3598 (let ((alist gnus-newsrc-alist)
3600 (while (setq group (car (pop alist)))
3601 (unless (gnus-group-read-only-p group)
3602 (push group groups)))
3605 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3607 (defun gnus-y-or-n-p (prompt)
3612 (defun gnus-yes-or-no-p (prompt)
3614 (yes-or-no-p prompt)
3617 ;; Check whether to use long file names.
3618 (defun gnus-use-long-file-name (symbol)
3619 ;; The variable has to be set...
3620 (and gnus-use-long-file-name
3621 ;; If it isn't a list, then we return t.
3622 (or (not (listp gnus-use-long-file-name))
3623 ;; If it is a list, and the list contains `symbol', we
3625 (not (memq symbol gnus-use-long-file-name)))))
3627 ;; I suspect there's a better way, but I haven't taken the time to do
3628 ;; it yet. -erik selberg@cs.washington.edu
3629 (defun gnus-dd-mmm (messy-date)
3630 "Return a string like DD-MMM from a big messy string"
3631 (let ((datevec (timezone-parse-date messy-date)))
3634 ;; Make sure leading zeroes are stripped.
3635 (number-to-string (string-to-number (aref datevec 2)))
3639 (nth (1- (string-to-number (aref datevec 1)))
3640 timezone-months-assoc))
3643 ;; Make a hash table (default and minimum size is 255).
3644 ;; Optional argument HASHSIZE specifies the table size.
3645 (defun gnus-make-hashtable (&optional hashsize)
3646 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3648 ;; Make a number that is suitable for hashing; bigger than MIN and one
3650 (defun gnus-create-hash-size (min)
3656 ;; Show message if message has a lower level than `gnus-verbose'.
3657 ;; Guideline for numbers:
3658 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3659 ;; for things that take a long time, 7 - not very important messages
3660 ;; on stuff, 9 - messages inside loops.
3661 (defun gnus-message (level &rest args)
3662 (if (<= level gnus-verbose)
3663 (apply 'message args)
3664 ;; We have to do this format thingy here even if the result isn't
3665 ;; shown - the return value has to be the same as the return value
3667 (apply 'format args)))
3669 ;; Generate a unique new group name.
3670 (defun gnus-generate-new-group-name (leaf)
3673 (while (gnus-gethash name gnus-newsrc-hashtb)
3674 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3677 (defsubst gnus-hide-text (b e props)
3678 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3679 (add-text-properties b e props)
3680 (when (memq 'intangible props)
3681 (put-text-property (max (1- b) (point-min))
3682 b 'intangible (cddr (memq 'intangible props)))))
3684 (defsubst gnus-unhide-text (b e)
3685 "Remove hidden text properties from region between B and E."
3686 (remove-text-properties b e gnus-hidden-properties)
3687 (when (memq 'intangible gnus-hidden-properties)
3688 (put-text-property (max (1- b) (point-min))
3689 b 'intangible nil)))
3691 (defun gnus-hide-text-type (b e type)
3692 "Hide text of TYPE between B and E."
3693 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3695 ;; Find out whether the gnus-visual TYPE is wanted.
3696 (defun gnus-visual-p (&optional type class)
3697 (and gnus-visual ; Has to be non-nil, at least.
3698 (if (not type) ; We don't care about type.
3700 (if (listp gnus-visual) ; It's a list, so we check it.
3701 (or (memq type gnus-visual)
3702 (memq class gnus-visual))
3705 (defun gnus-parent-id (references)
3706 "Return the last Message-ID in REFERENCES."
3707 (when (and references
3708 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3709 (substring references (match-beginning 1) (match-end 1))))
3711 (defun gnus-split-references (references)
3712 "Return a list of Message-IDs in REFERENCES."
3715 (while (string-match "<[^>]+>" references beg)
3716 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3720 (defun gnus-ephemeral-group-p (group)
3721 "Say whether GROUP is ephemeral or not."
3722 (gnus-group-get-parameter group 'quit-config))
3724 (defun gnus-group-quit-config (group)
3725 "Return the quit-config of GROUP."
3726 (gnus-group-get-parameter group 'quit-config))
3728 (defun gnus-simplify-mode-line ()
3729 "Make mode lines a bit simpler."
3730 (setq mode-line-modified "-- ")
3731 (when (listp mode-line-format)
3732 (make-local-variable 'mode-line-format)
3733 (setq mode-line-format (copy-sequence mode-line-format))
3734 (when (equal (nth 3 mode-line-format) " ")
3735 (setcar (nthcdr 3 mode-line-format) " "))))
3737 ;;; List and range functions
3739 (defun gnus-last-element (list)
3740 "Return last element of LIST."
3742 (setq list (cdr list)))
3745 (defun gnus-copy-sequence (list)
3746 "Do a complete, total copy of a list."
3747 (if (and (consp list) (not (consp (cdr list))))
3748 (cons (car list) (cdr list))
3749 (mapcar (lambda (elem) (if (consp elem)
3750 (if (consp (cdr elem))
3751 (gnus-copy-sequence elem)
3752 (cons (car elem) (cdr elem)))
3756 (defun gnus-set-difference (list1 list2)
3757 "Return a list of elements of LIST1 that do not appear in LIST2."
3758 (let ((list1 (copy-sequence list1)))
3760 (setq list1 (delq (car list2) list1))
3761 (setq list2 (cdr list2)))
3764 (defun gnus-sorted-complement (list1 list2)
3765 "Return a list of elements of LIST1 that do not appear in LIST2.
3766 Both lists have to be sorted over <."
3768 (if (or (null list1) (null list2))
3770 (while (and list1 list2)
3771 (cond ((= (car list1) (car list2))
3772 (setq list1 (cdr list1)
3774 ((< (car list1) (car list2))
3775 (setq out (cons (car list1) out))
3776 (setq list1 (cdr list1)))
3778 (setq out (cons (car list2) out))
3779 (setq list2 (cdr list2)))))
3780 (nconc (nreverse out) (or list1 list2)))))
3782 (defun gnus-intersection (list1 list2)
3785 (if (memq (car list2) list1)
3786 (setq result (cons (car list2) result)))
3787 (setq list2 (cdr list2)))
3790 (defun gnus-sorted-intersection (list1 list2)
3791 ;; LIST1 and LIST2 have to be sorted over <.
3793 (while (and list1 list2)
3794 (cond ((= (car list1) (car list2))
3795 (setq out (cons (car list1) out)
3798 ((< (car list1) (car list2))
3799 (setq list1 (cdr list1)))
3801 (setq list2 (cdr list2)))))
3804 (defun gnus-set-sorted-intersection (list1 list2)
3805 ;; LIST1 and LIST2 have to be sorted over <.
3806 ;; This function modifies LIST1.
3807 (let* ((top (cons nil list1))
3809 (while (and list1 list2)
3810 (cond ((= (car list1) (car list2))
3814 ((< (car list1) (car list2))
3815 (setcdr prev (cdr list1))
3816 (setq list1 (cdr list1)))
3818 (setq list2 (cdr list2)))))
3822 (defun gnus-compress-sequence (numbers &optional always-list)
3823 "Convert list of numbers to a list of ranges or a single range.
3824 If ALWAYS-LIST is non-nil, this function will always release a list of
3826 (let* ((first (car numbers))
3827 (last (car numbers))
3831 (if (not (listp (cdr numbers)))
3834 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3835 ((= (1+ last) (car numbers)) ;Still in sequence
3836 (setq last (car numbers)))
3837 (t ;End of one sequence
3839 (cons (if (= first last) first
3840 (cons first last)) result))
3841 (setq first (car numbers))
3842 (setq last (car numbers))))
3843 (setq numbers (cdr numbers)))
3844 (if (and (not always-list) (null result))
3845 (if (= first last) (list first) (cons first last))
3846 (nreverse (cons (if (= first last) first (cons first last))
3849 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3850 (defun gnus-uncompress-range (ranges)
3851 "Expand a list of ranges into a list of numbers.
3852 RANGES is either a single range on the form `(num . num)' or a list of
3854 (let (first last result)
3858 ((not (listp (cdr ranges)))
3859 (setq first (car ranges))
3860 (setq last (cdr ranges))
3861 (while (<= first last)
3862 (setq result (cons first result))
3863 (setq first (1+ first)))
3867 (if (atom (car ranges))
3868 (if (numberp (car ranges))
3869 (setq result (cons (car ranges) result)))
3870 (setq first (caar ranges))
3871 (setq last (cdar ranges))
3872 (while (<= first last)
3873 (setq result (cons first result))
3874 (setq first (1+ first))))
3875 (setq ranges (cdr ranges)))
3876 (nreverse result)))))
3878 (defun gnus-add-to-range (ranges list)
3879 "Return a list of ranges that has all articles from both RANGES and LIST.
3880 Note: LIST has to be sorted over `<'."
3882 (gnus-compress-sequence list t)
3883 (setq list (copy-sequence list))
3884 (or (listp (cdr ranges))
3885 (setq ranges (list ranges)))
3887 ilist lowest highest temp)
3888 (while (and ranges list)
3890 (setq lowest (or (and (atom (car ranges)) (car ranges))
3892 (while (and list (cdr list) (< (cadr list) lowest))
3893 (setq list (cdr list)))
3894 (if (< (car ilist) lowest)
3897 (setq list (cdr list))
3899 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3900 (setq highest (or (and (atom (car ranges)) (car ranges))
3902 (while (and list (<= (car list) highest))
3903 (setq list (cdr list)))
3904 (setq ranges (cdr ranges)))
3906 (setq out (nconc (gnus-compress-sequence list t) out)))
3907 (setq out (sort out (lambda (r1 r2)
3908 (< (or (and (atom r1) r1) (car r1))
3909 (or (and (atom r2) r2) (car r2))))))
3912 (if (atom (car ranges))
3914 (if (atom (cadr ranges))
3915 (if (= (1+ (car ranges)) (cadr ranges))
3917 (setcar ranges (cons (car ranges)
3919 (setcdr ranges (cddr ranges))))
3920 (if (= (1+ (car ranges)) (caadr ranges))
3922 (setcar (cadr ranges) (car ranges))
3923 (setcar ranges (cadr ranges))
3924 (setcdr ranges (cddr ranges))))))
3926 (if (atom (cadr ranges))
3927 (if (= (1+ (cdar ranges)) (cadr ranges))
3929 (setcdr (car ranges) (cadr ranges))
3930 (setcdr ranges (cddr ranges))))
3931 (if (= (1+ (cdar ranges)) (caadr ranges))
3933 (setcdr (car ranges) (cdadr ranges))
3934 (setcdr ranges (cddr ranges)))))))
3935 (setq ranges (cdr ranges)))
3938 (defun gnus-remove-from-range (ranges list)
3939 "Return a list of ranges that has all articles from LIST removed from RANGES.
3940 Note: LIST has to be sorted over `<'."
3941 ;; !!! This function shouldn't look like this, but I've got a headache.
3942 (gnus-compress-sequence
3943 (gnus-sorted-complement
3944 (gnus-uncompress-range ranges) list)))
3946 (defun gnus-member-of-range (number ranges)
3947 (if (not (listp (cdr ranges)))
3948 (and (>= number (car ranges))
3949 (<= number (cdr ranges)))
3952 (if (numberp (car ranges))
3953 (>= number (car ranges))
3954 (>= number (caar ranges)))
3956 (if (if (numberp (car ranges))
3957 (= number (car ranges))
3958 (and (>= number (caar ranges))
3959 (<= number (cdar ranges))))
3960 (setq not-stop nil))
3961 (setq ranges (cdr ranges)))
3964 (defun gnus-range-length (range)
3965 "Return the length RANGE would have if uncompressed."
3966 (length (gnus-uncompress-range range)))
3968 (defun gnus-sublist-p (list sublist)
3969 "Test whether all elements in SUBLIST are members of LIST."
3972 (unless (memq (pop sublist) list)
3982 (defvar gnus-group-mode-map nil)
3983 (put 'gnus-group-mode 'mode-class 'special)
3985 (unless gnus-group-mode-map
3986 (setq gnus-group-mode-map (make-keymap))
3987 (suppress-keymap gnus-group-mode-map)
3989 (gnus-define-keys gnus-group-mode-map
3990 " " gnus-group-read-group
3991 "=" gnus-group-select-group
3992 "\r" gnus-group-select-group
3993 "\M-\r" gnus-group-quick-select-group
3994 "j" gnus-group-jump-to-group
3995 "n" gnus-group-next-unread-group
3996 "p" gnus-group-prev-unread-group
3997 "\177" gnus-group-prev-unread-group
3998 [delete] gnus-group-prev-unread-group
3999 "N" gnus-group-next-group
4000 "P" gnus-group-prev-group
4001 "\M-n" gnus-group-next-unread-group-same-level
4002 "\M-p" gnus-group-prev-unread-group-same-level
4003 "," gnus-group-best-unread-group
4004 "." gnus-group-first-unread-group
4005 "u" gnus-group-unsubscribe-current-group
4006 "U" gnus-group-unsubscribe-group
4007 "c" gnus-group-catchup-current
4008 "C" gnus-group-catchup-current-all
4009 "l" gnus-group-list-groups
4010 "L" gnus-group-list-all-groups
4012 "g" gnus-group-get-new-news
4013 "\M-g" gnus-group-get-new-news-this-group
4014 "R" gnus-group-restart
4015 "r" gnus-group-read-init-file
4016 "B" gnus-group-browse-foreign-server
4017 "b" gnus-group-check-bogus-groups
4018 "F" gnus-find-new-newsgroups
4019 "\C-c\C-d" gnus-group-describe-group
4020 "\M-d" gnus-group-describe-all-groups
4021 "\C-c\C-a" gnus-group-apropos
4022 "\C-c\M-\C-a" gnus-group-description-apropos
4023 "a" gnus-group-post-news
4024 "\ek" gnus-group-edit-local-kill
4025 "\eK" gnus-group-edit-global-kill
4026 "\C-k" gnus-group-kill-group
4027 "\C-y" gnus-group-yank-group
4028 "\C-w" gnus-group-kill-region
4029 "\C-x\C-t" gnus-group-transpose-groups
4030 "\C-c\C-l" gnus-group-list-killed
4031 "\C-c\C-x" gnus-group-expire-articles
4032 "\C-c\M-\C-x" gnus-group-expire-all-groups
4034 "s" gnus-group-save-newsrc
4035 "z" gnus-group-suspend
4036 "Z" gnus-group-clear-dribble
4039 "?" gnus-group-describe-briefly
4040 "\C-c\C-i" gnus-info-find-node
4041 "\M-e" gnus-group-edit-group-method
4042 "^" gnus-group-enter-server-mode
4043 gnus-mouse-2 gnus-mouse-pick-group
4044 "<" beginning-of-buffer
4047 "\C-c\C-s" gnus-group-sort-groups
4049 "\C-c\M-g" gnus-activate-all-groups
4050 "\M-&" gnus-group-universal-argument
4051 "#" gnus-group-mark-group
4052 "\M-#" gnus-group-unmark-group)
4054 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4055 "m" gnus-group-mark-group
4056 "u" gnus-group-unmark-group
4057 "w" gnus-group-mark-region
4058 "m" gnus-group-mark-buffer
4059 "r" gnus-group-mark-regexp
4060 "U" gnus-group-unmark-all-groups)
4062 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4063 "d" gnus-group-make-directory-group
4064 "h" gnus-group-make-help-group
4065 "a" gnus-group-make-archive-group
4066 "k" gnus-group-make-kiboze-group
4067 "m" gnus-group-make-group
4068 "E" gnus-group-edit-group
4069 "e" gnus-group-edit-group-method
4070 "p" gnus-group-edit-group-parameters
4071 "v" gnus-group-add-to-virtual
4072 "V" gnus-group-make-empty-virtual
4073 "D" gnus-group-enter-directory
4074 "f" gnus-group-make-doc-group
4075 "r" gnus-group-rename-group
4076 "\177" gnus-group-delete-group
4077 [delete] gnus-group-delete-group)
4079 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4080 "b" gnus-group-brew-soup
4081 "w" gnus-soup-save-areas
4082 "s" gnus-soup-send-replies
4083 "p" gnus-soup-pack-packet
4084 "r" nnsoup-pack-replies)
4086 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4087 "s" gnus-group-sort-groups
4088 "a" gnus-group-sort-groups-by-alphabet
4089 "u" gnus-group-sort-groups-by-unread
4090 "l" gnus-group-sort-groups-by-level
4091 "v" gnus-group-sort-groups-by-score
4092 "r" gnus-group-sort-groups-by-rank
4093 "m" gnus-group-sort-groups-by-method)
4095 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4096 "k" gnus-group-list-killed
4097 "z" gnus-group-list-zombies
4098 "s" gnus-group-list-groups
4099 "u" gnus-group-list-all-groups
4100 "A" gnus-group-list-active
4101 "a" gnus-group-apropos
4102 "d" gnus-group-description-apropos
4103 "m" gnus-group-list-matching
4104 "M" gnus-group-list-all-matching
4105 "l" gnus-group-list-level)
4107 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4108 "f" gnus-score-flush-cache)
4110 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4111 "f" gnus-group-fetch-faq)
4113 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4114 "l" gnus-group-set-current-level
4115 "t" gnus-group-unsubscribe-current-group
4116 "s" gnus-group-unsubscribe-group
4117 "k" gnus-group-kill-group
4118 "y" gnus-group-yank-group
4119 "w" gnus-group-kill-region
4120 "\C-k" gnus-group-kill-level
4121 "z" gnus-group-kill-all-zombies))
4123 (defun gnus-group-mode ()
4124 "Major mode for reading news.
4126 All normal editing commands are switched off.
4127 \\<gnus-group-mode-map>
4128 The group buffer lists (some of) the groups available. For instance,
4129 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4130 lists all zombie groups.
4132 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4133 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4135 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4137 The following commands are available:
4139 \\{gnus-group-mode-map}"
4141 (when (and menu-bar-mode
4142 (gnus-visual-p 'group-menu 'menu))
4143 (gnus-group-make-menu-bar))
4144 (kill-all-local-variables)
4145 (gnus-simplify-mode-line)
4146 (setq major-mode 'gnus-group-mode)
4147 (setq mode-name "Group")
4148 (gnus-group-set-mode-line)
4149 (setq mode-line-process nil)
4150 (use-local-map gnus-group-mode-map)
4151 (buffer-disable-undo (current-buffer))
4152 (setq truncate-lines t)
4153 (setq buffer-read-only t)
4154 (run-hooks 'gnus-group-mode-hook))
4156 (defun gnus-mouse-pick-group (e)
4157 "Enter the group under the mouse pointer."
4160 (gnus-group-read-group nil))
4162 ;; Look at LEVEL and find out what the level is really supposed to be.
4163 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4164 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4165 (defun gnus-group-default-level (&optional level number-or-nil)
4167 (gnus-group-use-permanent-levels
4168 (setq gnus-group-default-list-level
4169 (or level gnus-group-default-list-level))
4170 (or gnus-group-default-list-level gnus-level-subscribed))
4174 (or level gnus-group-default-list-level gnus-level-subscribed))))
4177 (defun gnus-slave-no-server (&optional arg)
4178 "Read network news as a slave, without connecting to local server"
4180 (gnus-no-server arg t))
4183 (defun gnus-no-server (&optional arg slave)
4185 If ARG is a positive number, Gnus will use that as the
4186 startup level. If ARG is nil, Gnus will be started at level 2.
4187 If ARG is non-nil and not a positive number, Gnus will
4188 prompt the user for the name of an NNTP server to use.
4189 As opposed to `gnus', this command will not connect to the local server."
4191 (let ((gnus-group-use-permanent-levels t))
4192 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4193 (make-local-variable 'gnus-group-use-permanent-levels)
4194 (setq gnus-group-use-permanent-levels t))
4197 (defun gnus-slave (&optional arg)
4198 "Read news as a slave."
4200 (gnus arg nil 'slave))
4203 (defun gnus-other-frame (&optional arg)
4204 "Pop up a frame to read news."
4206 (if (get-buffer gnus-group-buffer)
4207 (let ((pop-up-frames t))
4209 (select-frame (make-frame))
4213 (defun gnus (&optional arg dont-connect slave)
4215 If ARG is non-nil and a positive number, Gnus will use that as the
4216 startup level. If ARG is non-nil and not a positive number, Gnus will
4217 prompt the user for the name of an NNTP server to use."
4220 (if (get-buffer gnus-group-buffer)
4222 (switch-to-buffer gnus-group-buffer)
4223 (gnus-group-get-new-news))
4226 (nnheader-init-server-buffer)
4227 (gnus-read-init-file)
4228 (setq gnus-slave slave)
4230 (gnus-group-setup-buffer)
4231 (let ((buffer-read-only nil))
4233 (if (not gnus-inhibit-startup-message)
4235 (gnus-group-startup-message)
4238 (let ((level (and (numberp arg) (> arg 0) arg))
4244 (gnus-start-news-server (and arg (not level))))))
4245 (if (and (not dont-connect)
4248 (run-hooks 'gnus-startup-hook)
4249 ;; NNTP server is successfully open.
4251 ;; Find the current startup file name.
4252 (setq gnus-current-startup-file
4253 (gnus-make-newsrc-file gnus-startup-file))
4255 ;; Read the dribble file.
4256 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4258 ;; Allow using GroupLens predictions.
4259 (when gnus-use-grouplens
4261 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4263 (gnus-summary-make-display-table)
4264 ;; Do the actual startup.
4265 (gnus-setup-news nil level dont-connect)
4266 ;; Generate the group buffer.
4267 (gnus-group-list-groups level)
4268 (gnus-group-first-unread-group)
4269 (gnus-configure-windows 'group)
4270 (gnus-group-set-mode-line))))))
4272 (defun gnus-unload ()
4273 "Unload all Gnus features."
4275 (or (boundp 'load-history)
4276 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4277 (let ((history load-history)
4280 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4281 (setq feature (cdr (assq 'provide (car history))))
4282 (unload-feature feature 'force))
4283 (setq history (cdr history)))))
4285 (defun gnus-compile ()
4286 "Byte-compile the user-defined format specs."
4288 (let ((entries gnus-format-specs)
4289 entry gnus-tmp-func)
4291 (gnus-message 7 "Compiling format specs...")
4294 (setq entry (pop entries))
4295 (if (eq (car entry) 'version)
4296 (setq gnus-format-specs (delq entry gnus-format-specs))
4297 (when (and (listp (caddr entry))
4298 (not (eq 'byte-code (caaddr entry))))
4299 (fset 'gnus-tmp-func
4300 `(lambda () ,(caddr entry)))
4301 (byte-compile 'gnus-tmp-func)
4302 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4304 (push (cons 'version emacs-version) gnus-format-specs)
4306 (gnus-message 7 "Compiling user specs...done"))))
4308 (defun gnus-indent-rigidly (start end arg)
4309 "Indent rigidly using only spaces and no tabs."
4312 (narrow-to-region start end)
4313 (indent-rigidly start end arg)
4314 (goto-char (point-min))
4315 (while (search-forward "\t" nil t)
4316 (replace-match " " t t)))))
4318 (defun gnus-group-startup-message (&optional x y)
4319 "Insert startup message in current buffer."
4320 ;; Insert the message.
4325 _ ___ __ ___ __ _ ___
4344 ;; And then hack it.
4345 (gnus-indent-rigidly (point-min) (point-max)
4346 (/ (max (- (window-width) (or x 46)) 0) 2))
4347 (goto-char (point-min))
4349 (let* ((pheight (count-lines (point-min) (point-max)))
4350 (wheight (window-height))
4351 (rest (- wheight pheight)))
4352 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4354 (goto-char (point-min))
4355 (and (search-forward "Praxis" nil t)
4356 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4357 (goto-char (point-min))
4358 (let* ((mode-string (gnus-group-set-mode-line)))
4359 (setq mode-line-buffer-identification
4360 (list (concat gnus-version (substring (car mode-string) 4))))
4361 (set-buffer-modified-p t)))
4363 (defun gnus-group-setup-buffer ()
4364 (or (get-buffer gnus-group-buffer)
4366 (switch-to-buffer gnus-group-buffer)
4367 (gnus-add-current-to-buffer-list)
4369 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4371 (defun gnus-group-list-groups (&optional level unread lowest)
4372 "List newsgroups with level LEVEL or lower that have unread articles.
4373 Default is all subscribed groups.
4374 If argument UNREAD is non-nil, groups with no unread articles are also
4376 (interactive (list (if current-prefix-arg
4377 (prefix-numeric-value current-prefix-arg)
4379 (gnus-group-default-level nil t)
4380 gnus-group-default-list-level
4381 gnus-level-subscribed))))
4383 (setq level (car gnus-group-list-mode)
4384 unread (cdr gnus-group-list-mode)))
4385 (setq level (gnus-group-default-level level))
4386 (gnus-group-setup-buffer) ;May call from out of group buffer
4387 (gnus-update-format-specifications)
4388 (let ((case-fold-search nil)
4389 (props (text-properties-at (gnus-point-at-bol)))
4390 (group (gnus-group-group-name)))
4391 (set-buffer gnus-group-buffer)
4392 (funcall gnus-group-prepare-function level unread lowest)
4393 (if (zerop (buffer-size))
4394 (gnus-message 5 gnus-no-groups-message)
4395 (goto-char (point-max))
4396 (when (or (not gnus-group-goto-next-group-function)
4397 (not (funcall gnus-group-goto-next-group-function
4400 ;; Go to the first group with unread articles.
4401 (gnus-group-search-forward t)
4402 ;; Find the right group to put point on. If the current group
4403 ;; has disappeared in the new listing, try to find the next
4404 ;; one. If no next one can be found, just leave point at the
4405 ;; first newsgroup in the buffer.
4406 (if (not (gnus-goto-char
4408 (point-min) (point-max)
4409 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4410 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4412 (not (gnus-goto-char
4414 (point-min) (point-max) 'gnus-group
4416 (caar newsrc) gnus-active-hashtb)))))
4417 (setq newsrc (cdr newsrc)))
4418 (or newsrc (progn (goto-char (point-max))
4419 (forward-line -1)))))))
4420 ;; Adjust cursor point.
4421 (gnus-group-position-point))))
4423 (defun gnus-group-list-level (level &optional all)
4424 "List groups on LEVEL.
4425 If ALL (the prefix), also list groups that have no unread articles."
4426 (interactive "nList groups on level: \nP")
4427 (gnus-group-list-groups level all level))
4429 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4430 "List all newsgroups with unread articles of level LEVEL or lower.
4431 If ALL is non-nil, list groups that have no unread articles.
4432 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4433 If REGEXP, only list groups matching REGEXP."
4434 (set-buffer gnus-group-buffer)
4435 (let ((buffer-read-only nil)
4436 (newsrc (cdr gnus-newsrc-alist))
4437 (lowest (or lowest 1))
4438 info clevel unread group params)
4440 (if (< lowest gnus-level-zombie)
4441 ;; List living groups.
4443 (setq info (car newsrc)
4444 group (gnus-info-group info)
4445 params (gnus-info-params info)
4447 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4448 (and unread ; This group might be bogus
4450 (string-match regexp group))
4451 (<= (setq clevel (gnus-info-level info)) level)
4453 (or all ; We list all groups?
4454 (if (eq unread t) ; Unactivated?
4455 gnus-group-list-inactive-groups ; We list unactivated
4456 (> unread 0)) ; We list groups with unread articles
4457 (and gnus-list-groups-with-ticked-articles
4458 (cdr (assq 'tick (gnus-info-marks info))))
4459 ; And groups with tickeds
4460 ;; Check for permanent visibility.
4461 (and gnus-permanently-visible-groups
4462 (string-match gnus-permanently-visible-groups
4464 (memq 'visible params)
4465 (cdr (assq 'visible params)))
4466 (gnus-group-insert-group-line
4467 group (gnus-info-level info)
4468 (gnus-info-marks info) unread (gnus-info-method info)))))
4470 ;; List dead groups.
4471 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4472 (gnus-group-prepare-flat-list-dead
4473 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4474 gnus-level-zombie ?Z
4476 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4477 (gnus-group-prepare-flat-list-dead
4478 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4479 gnus-level-killed ?K regexp))
4481 (gnus-group-set-mode-line)
4482 (setq gnus-group-list-mode (cons level all))
4483 (run-hooks 'gnus-group-prepare-hook)))
4485 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4486 ;; List zombies and killed lists somewhat faster, which was
4487 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4488 ;; this by ignoring the group format specification altogether.
4491 ;; This loop is used when listing groups that match some
4494 (setq group (pop groups))
4495 (when (string-match regexp group)
4496 (add-text-properties
4497 (point) (prog1 (1+ (point))
4498 (insert " " mark " *: " group "\n"))
4499 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4501 'gnus-level level))))
4502 ;; This loop is used when listing all groups.
4504 (add-text-properties
4505 (point) (prog1 (1+ (point))
4506 (insert " " mark " *: "
4507 (setq group (pop groups)) "\n"))
4508 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4510 'gnus-level level))))))
4512 (defmacro gnus-group-real-name (group)
4513 "Find the real name of a foreign newsgroup."
4514 `(let ((gname ,group))
4515 (if (string-match ":[^:]+$" gname)
4516 (substring gname (1+ (match-beginning 0)))
4519 (defsubst gnus-server-add-address (method)
4520 (let ((method-name (symbol-name (car method))))
4521 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4522 (not (assq (intern (concat method-name "-address")) method)))
4523 (append method (list (list (intern (concat method-name "-address"))
4527 (defsubst gnus-server-get-method (group method)
4528 ;; Input either a server name, and extended server name, or a
4529 ;; select method, and return a select method.
4530 (cond ((stringp method)
4531 (gnus-server-to-method method))
4532 ((and (stringp (car method)) group)
4533 (gnus-server-extend-method group method))
4535 (gnus-server-add-address method))))
4537 (defun gnus-server-to-method (server)
4538 "Map virtual server names to select methods."
4540 ;; Perhaps this is the native server?
4541 (and (equal server "native") gnus-select-method)
4542 ;; It should be in the server alist.
4543 (cdr (assoc server gnus-server-alist))
4544 ;; If not, we look through all the opened server
4545 ;; to see whether we can find it there.
4546 (let ((opened gnus-opened-servers))
4548 (not (equal server (format "%s:%s" (caaar opened)
4553 (defmacro gnus-method-equal (ss1 ss2)
4554 "Say whether two servers are equal."
4558 (and (= (length s1) (length s2))
4560 (while (and s1 (member (car s1) s2))
4564 (defun gnus-server-equal (m1 m2)
4565 "Say whether two methods are equal."
4566 (let ((m1 (cond ((null m1) gnus-select-method)
4567 ((stringp m1) (gnus-server-to-method m1))
4569 (m2 (cond ((null m2) gnus-select-method)
4570 ((stringp m2) (gnus-server-to-method m2))
4572 (gnus-method-equal m1 m2)))
4574 (defun gnus-group-prefixed-name (group method)
4575 "Return the whole name from GROUP and METHOD."
4576 (and (stringp method) (setq method (gnus-server-to-method method)))
4577 (concat (format "%s" (car method))
4579 (or (assoc (format "%s" (car method))
4580 (gnus-methods-using 'address))
4581 (gnus-server-equal method gnus-message-archive-method))
4583 (not (string= (nth 1 method) "")))
4584 (concat "+" (nth 1 method)))
4587 (defun gnus-group-real-prefix (group)
4588 "Return the prefix of the current group name."
4589 (if (string-match "^[^:]+:" group)
4590 (substring group 0 (match-end 0))
4593 (defun gnus-group-method (group)
4594 "Return the server or method used for selecting GROUP."
4595 (let ((prefix (gnus-group-real-prefix group)))
4596 (if (equal prefix "")
4598 (let ((servers gnus-opened-servers)
4600 backend possible found)
4601 (if (string-match "^[^\\+]+\\+" prefix)
4602 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4603 server (substring prefix (match-end 0) (1- (length prefix))))
4604 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4606 (when (eq (caaar servers) backend)
4607 (setq possible (caar servers))
4608 (when (equal (cadaar servers) server)
4609 (setq found (caar servers))))
4611 (or (car (rassoc found gnus-server-alist))
4613 (car (rassoc possible gnus-server-alist))
4615 (list backend server))))))
4617 (defsubst gnus-secondary-method-p (method)
4618 "Return whether METHOD is a secondary select method."
4619 (let ((methods gnus-secondary-select-methods)
4620 (gmethod (gnus-server-get-method nil method)))
4622 (not (equal (gnus-server-get-method nil (car methods))
4624 (setq methods (cdr methods)))
4627 (defun gnus-group-foreign-p (group)
4628 "Say whether a group is foreign or not."
4629 (and (not (gnus-group-native-p group))
4630 (not (gnus-group-secondary-p group))))
4632 (defun gnus-group-native-p (group)
4633 "Say whether the group is native or not."
4634 (not (string-match ":" group)))
4636 (defun gnus-group-secondary-p (group)
4637 "Say whether the group is secondary or not."
4638 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4640 (defun gnus-group-get-parameter (group &optional symbol)
4641 "Returns the group parameters for GROUP.
4642 If SYMBOL, return the value of that symbol in the group parameters."
4643 (let ((params (gnus-info-params (gnus-get-info group))))
4645 (gnus-group-parameter-value params symbol)
4648 (defun gnus-group-parameter-value (params symbol)
4649 "Return the value of SYMBOL in group PARAMS."
4650 (or (car (memq symbol params)) ; It's either a simple symbol
4651 (cdr (assq symbol params)))) ; or a cons.
4653 (defun gnus-group-add-parameter (group param)
4654 "Add parameter PARAM to GROUP."
4655 (let ((info (gnus-get-info group)))
4657 () ; This is a dead group. We just ignore it.
4658 ;; Cons the new param to the old one and update.
4659 (gnus-group-set-info (cons param (gnus-info-params info))
4662 (defun gnus-group-set-parameter (group name value)
4663 "Set parameter NAME to VALUE in GROUP."
4664 (let ((info (gnus-get-info group)))
4666 () ; This is a dead group. We just ignore it.
4667 (let ((old-params (gnus-info-params info))
4668 (new-params (list (cons name value))))
4670 (if (or (not (listp (car old-params)))
4671 (not (eq (caar old-params) name)))
4672 (setq new-params (append new-params (list (car old-params)))))
4673 (setq old-params (cdr old-params)))
4674 (gnus-group-set-info new-params group 'params)))))
4676 (defun gnus-group-add-score (group &optional score)
4677 "Add SCORE to the GROUP score.
4678 If SCORE is nil, add 1 to the score of GROUP."
4679 (let ((info (gnus-get-info group)))
4680 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4682 (defun gnus-summary-bubble-group ()
4683 "Increase the score of the current group.
4684 This is a handy function to add to `gnus-summary-exit-hook' to
4685 increase the score of each group you read."
4686 (gnus-group-add-score gnus-newsgroup-name))
4688 (defun gnus-group-set-info (info &optional method-only-group part)
4689 (let* ((entry (gnus-gethash
4690 (or method-only-group (gnus-info-group info))
4691 gnus-newsrc-hashtb))
4693 (info (if method-only-group (nth 2 entry) info))
4695 (when method-only-group
4697 (error "Trying to change non-existent group %s" method-only-group))
4698 ;; We have received parts of the actual group info - either the
4699 ;; select method or the group parameters. We first check
4700 ;; whether we have to extend the info, and if so, do that.
4701 (let ((len (length info))
4702 (total (if (eq part 'method) 5 6)))
4704 (setcdr (nthcdr (1- len) info)
4705 (make-list (- total len) nil)))
4706 ;; Then we enter the new info.
4707 (setcar (nthcdr (1- total) info) part-info)))
4709 ;; This is a new group, so we just create it.
4711 (set-buffer gnus-group-buffer)
4712 (setq method (gnus-info-method info))
4713 (when (gnus-server-equal method "native")
4716 ;; It's a foreign group...
4717 (gnus-group-make-group
4718 (gnus-group-real-name (gnus-info-group info))
4719 (if (stringp method) method
4720 (prin1-to-string (car method)))
4722 (nth 1 (gnus-info-method info))))
4723 ;; It's a native group.
4724 (gnus-group-make-group (gnus-info-group info)))
4725 (gnus-message 6 "Note: New group created")
4727 (gnus-gethash (gnus-group-prefixed-name
4728 (gnus-group-real-name (gnus-info-group info))
4729 (or (gnus-info-method info) gnus-select-method))
4730 gnus-newsrc-hashtb))))
4731 ;; Whether it was a new group or not, we now have the entry, so we
4732 ;; can do the update.
4735 (setcar (nthcdr 2 entry) info)
4736 (when (and (not (eq (car entry) t))
4737 (gnus-active (gnus-info-group info)))
4738 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4739 (error "No such group: %s" (gnus-info-group info)))))
4741 (defun gnus-group-set-method-info (group select-method)
4742 (gnus-group-set-info select-method group 'method))
4744 (defun gnus-group-set-params-info (group params)
4745 (gnus-group-set-info params group 'params))
4747 (defun gnus-group-update-group-line ()
4748 "Update the current line in the group buffer."
4749 (let* ((buffer-read-only nil)
4750 (group (gnus-group-group-name))
4751 (gnus-group-indentation (gnus-group-group-indentation))
4752 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4754 (not (gnus-ephemeral-group-p group))
4756 (concat "(gnus-group-set-info '"
4757 (prin1-to-string (nth 2 entry)) ")")))
4759 (gnus-group-insert-group-line-info group)
4761 (gnus-group-position-point)))
4763 (defun gnus-group-insert-group-line-info (group)
4764 "Insert GROUP on the current line."
4765 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4769 ;; (Un)subscribed group.
4770 (setq info (nth 2 entry))
4771 (gnus-group-insert-group-line
4772 group (gnus-info-level info) (gnus-info-marks info)
4773 (or (car entry) t) (gnus-info-method info)))
4774 ;; This group is dead.
4775 (gnus-group-insert-group-line
4777 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4779 (if (setq active (gnus-active group))
4780 (- (1+ (cdr active)) (car active)) 0)
4783 (defun gnus-group-insert-group-line
4784 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4786 "Insert a group line in the group buffer."
4787 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4788 (gnus-tmp-number-total
4790 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4792 (gnus-tmp-number-of-unread
4793 (if (numberp number) (int-to-string (max 0 number))
4795 (gnus-tmp-number-of-read
4796 (if (numberp number)
4797 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4799 (gnus-tmp-subscribed
4800 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4801 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4802 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4804 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4805 (gnus-tmp-newsgroup-description
4806 (if gnus-description-hashtb
4807 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4810 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4811 (gnus-tmp-moderated-string
4812 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4814 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4815 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4816 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4817 (gnus-tmp-news-method-string
4819 (format "(%s:%s)" (car gnus-tmp-method)
4820 (cadr gnus-tmp-method)) ""))
4821 (gnus-tmp-marked-mark
4822 (if (and (numberp number)
4824 (cdr (assq 'tick gnus-tmp-marked)))
4826 (gnus-tmp-process-marked
4827 (if (member gnus-tmp-group gnus-group-marked)
4828 gnus-process-mark ? ))
4830 (or (and gnus-use-grouplens
4831 (bbb-grouplens-group-p gnus-tmp-group))
4833 (buffer-read-only nil)
4834 header gnus-tmp-header) ; passed as parameter to user-funcs.
4836 (add-text-properties
4840 (eval gnus-group-line-format-spec))
4841 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4842 gnus-unread ,(if (numberp number)
4843 (string-to-int gnus-tmp-number-of-unread)
4845 gnus-marked ,gnus-tmp-marked-mark
4846 gnus-indentation ,gnus-group-indentation
4847 gnus-level ,gnus-tmp-level))
4848 (when (gnus-visual-p 'group-highlight 'highlight)
4850 (run-hooks 'gnus-group-update-hook)
4852 ;; Allow XEmacs to remove front-sticky text properties.
4853 (gnus-group-remove-excess-properties)))
4855 (defun gnus-group-update-group (group &optional visible-only)
4856 "Update all lines where GROUP appear.
4857 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4860 (set-buffer gnus-group-buffer)
4861 ;; The buffer may be narrowed.
4864 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4866 found buffer-read-only)
4867 ;; Enter the current status into the dribble buffer.
4868 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4869 (if (and entry (not (gnus-ephemeral-group-p group)))
4871 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4873 ;; Find all group instances. If topics are in use, each group
4874 ;; may be listed in more than once.
4875 (while (setq loc (text-property-any
4876 loc (point-max) 'gnus-group ident))
4879 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4881 (gnus-group-insert-group-line-info group))
4882 (setq loc (1+ loc)))
4883 (unless (or found visible-only)
4884 ;; No such line in the buffer, find out where it's supposed to
4885 ;; go, and insert it there (or at the end of the buffer).
4886 (if gnus-goto-missing-group-function
4887 (funcall gnus-goto-missing-group-function group)
4888 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4889 (while (and entry (car entry)
4893 (point-min) (point-max)
4894 'gnus-group (gnus-intern-safe
4895 (caar entry) gnus-active-hashtb)))))
4896 (setq entry (cdr entry)))
4897 (or entry (goto-char (point-max)))))
4898 ;; Finally insert the line.
4899 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4900 (gnus-group-insert-group-line-info group)))
4901 (gnus-group-set-mode-line)))))
4903 (defun gnus-group-set-mode-line ()
4904 (when (memq 'group gnus-updated-mode-lines)
4905 (let* ((gformat (or gnus-group-mode-line-format-spec
4906 (setq gnus-group-mode-line-format-spec
4908 gnus-group-mode-line-format
4909 gnus-group-mode-line-format-alist))))
4910 (gnus-tmp-news-server (cadr gnus-select-method))
4911 (gnus-tmp-news-method (car gnus-select-method))
4913 gnus-tmp-header ;Dummy binding for user-defined formats
4914 ;; Get the resulting string.
4915 (mode-string (eval gformat)))
4916 ;; If the line is too long, we chop it off.
4917 (when (> (length mode-string) max-len)
4918 (setq mode-string (substring mode-string 0 (- max-len 4))))
4920 (setq mode-line-buffer-identification (list mode-string))
4921 (set-buffer-modified-p t)))))
4923 (defun gnus-group-group-name ()
4924 "Get the name of the newsgroup on the current line."
4925 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4926 (and group (symbol-name group))))
4928 (defun gnus-group-group-level ()
4929 "Get the level of the newsgroup on the current line."
4930 (get-text-property (gnus-point-at-bol) 'gnus-level))
4932 (defun gnus-group-group-indentation ()
4933 "Get the indentation of the newsgroup on the current line."
4934 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4935 (and gnus-group-indentation-function
4936 (funcall gnus-group-indentation-function))
4939 (defun gnus-group-group-unread ()
4940 "Get the number of unread articles of the newsgroup on the current line."
4941 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4943 (defun gnus-group-search-forward (&optional backward all level first-too)
4944 "Find the next newsgroup with unread articles.
4945 If BACKWARD is non-nil, find the previous newsgroup instead.
4946 If ALL is non-nil, just find any newsgroup.
4947 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4949 If FIRST-TOO, the current line is also eligible as a target."
4950 (let ((way (if backward -1 1))
4951 (low gnus-level-killed)
4954 (if (and backward (progn (beginning-of-line)) (bobp))
4956 (or first-too (forward-line way))
4964 (get-text-property (point) 'gnus-unread)))
4965 (and (numberp unread) (> unread 0)))
4966 (setq lev (get-text-property (point)
4968 (<= lev gnus-level-subscribed)))
4970 (and (setq lev (get-text-property (point)
4979 (zerop (forward-line way)))))
4981 (progn (gnus-group-position-point) t)
4982 (goto-char (or pos beg))
4985 ;;; Gnus group mode commands
4989 (defun gnus-group-mark-group (n &optional unmark no-advance)
4990 "Mark the current group."
4992 (let ((buffer-read-only nil)
4996 (setq group (gnus-group-group-name))
5000 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5005 (setq gnus-group-marked (delete group gnus-group-marked)))
5007 (setq gnus-group-marked
5008 (cons group (delete group gnus-group-marked))))
5010 (or no-advance (zerop (gnus-group-next-group 1))))
5012 (gnus-summary-position-point)
5015 (defun gnus-group-unmark-group (n)
5016 "Remove the mark from the current group."
5018 (gnus-group-mark-group n 'unmark)
5019 (gnus-group-position-point))
5021 (defun gnus-group-unmark-all-groups ()
5022 "Unmark all groups."
5024 (let ((groups gnus-group-marked))
5027 (gnus-group-remove-mark (pop groups)))))
5028 (gnus-group-position-point))
5030 (defun gnus-group-mark-region (unmark beg end)
5031 "Mark all groups between point and mark.
5032 If UNMARK, remove the mark instead."
5033 (interactive "P\nr")
5034 (let ((num (count-lines beg end)))
5037 (- num (gnus-group-mark-group num unmark)))))
5039 (defun gnus-group-mark-buffer (&optional unmark)
5040 "Mark all groups in the buffer.
5041 If UNMARK, remove the mark instead."
5043 (gnus-group-mark-region unmark (point-min) (point-max)))
5045 (defun gnus-group-mark-regexp (regexp)
5046 "Mark all groups that match some regexp."
5047 (interactive "sMark (regexp): ")
5048 (let ((alist (cdr gnus-newsrc-alist))
5051 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5052 (gnus-group-set-mark group))))
5053 (gnus-group-position-point))
5055 (defun gnus-group-remove-mark (group)
5056 "Remove the process mark from GROUP and move point there.
5057 Return nil if the group isn't displayed."
5058 (if (gnus-group-goto-group group)
5060 (gnus-group-mark-group 1 'unmark t)
5062 (setq gnus-group-marked
5063 (delete group gnus-group-marked))
5066 (defun gnus-group-set-mark (group)
5067 "Set the process mark on GROUP."
5068 (if (gnus-group-goto-group group)
5070 (gnus-group-mark-group 1 nil t))
5071 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5073 (defun gnus-group-universal-argument (arg &optional groups func)
5074 "Perform any command on all groups accoring to the process/prefix convention."
5076 (let ((groups (or groups (gnus-group-process-prefix arg)))
5078 (if (eq (setq func (or func
5081 (substitute-command-keys
5082 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5085 (message "Undefined key")
5088 (gnus-group-remove-mark (setq group (pop groups)))
5089 (command-execute func))))
5090 (gnus-group-position-point))
5092 (defun gnus-group-process-prefix (n)
5093 "Return a list of groups to work on.
5094 Take into consideration N (the prefix) and the list of marked groups."
5097 (setq n (prefix-numeric-value n))
5098 ;; There is a prefix, so we return a list of the N next
5100 (let ((way (if (< n 0) -1 1))
5105 (setq group (gnus-group-group-name)))
5106 (setq groups (cons group groups))
5108 (gnus-group-next-group way)))
5110 ((and (boundp 'transient-mark-mode)
5113 ;; Work on the region between point and mark.
5114 (let ((max (max (point) (mark)))
5117 (goto-char (min (point) (mark)))
5120 (push (gnus-group-group-name) groups)
5121 (zerop (gnus-group-next-group 1))
5123 (nreverse groups))))
5125 ;; No prefix, but a list of marked articles.
5126 (reverse gnus-group-marked))
5128 ;; Neither marked articles or a prefix, so we return the
5130 (let ((group (gnus-group-group-name)))
5131 (and group (list group))))))
5133 ;; Selecting groups.
5135 (defun gnus-group-read-group (&optional all no-article group)
5136 "Read news in this newsgroup.
5137 If the prefix argument ALL is non-nil, already read articles become
5138 readable. IF ALL is a number, fetch this number of articles. If the
5139 optional argument NO-ARTICLE is non-nil, no article will be
5140 auto-selected upon group entry. If GROUP is non-nil, fetch that
5143 (let ((group (or group (gnus-group-group-name)))
5144 number active marked entry)
5145 (or group (error "No group on current line"))
5146 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5147 group gnus-newsrc-hashtb)))))
5148 ;; This group might be a dead group. In that case we have to get
5149 ;; the number of unread articles from `gnus-active-hashtb'.
5151 (cond ((numberp all) all)
5153 ((setq active (gnus-active group))
5154 (- (1+ (cdr active)) (car active)))))
5155 (gnus-summary-read-group
5156 group (or all (and (numberp number)
5157 (zerop (+ number (length (cdr (assq 'tick marked)))
5158 (length (cdr (assq 'dormant marked)))))))
5161 (defun gnus-group-select-group (&optional all)
5162 "Select this newsgroup.
5163 No article is selected automatically.
5164 If ALL is non-nil, already read articles become readable.
5165 If ALL is a number, fetch this number of articles."
5167 (gnus-group-read-group all t))
5169 (defun gnus-group-quick-select-group (&optional all)
5170 "Select the current group \"quickly\".
5171 This means that no highlighting or scoring will be performed."
5174 gnus-score-find-score-files-function
5175 gnus-apply-kill-hook
5176 gnus-summary-expunge-below)
5177 (gnus-group-read-group all t)))
5179 (defun gnus-group-visible-select-group (&optional all)
5180 "Select the current group without hiding any articles."
5182 (let ((gnus-inhibit-limiting t))
5183 (gnus-group-read-group all t)))
5186 (defun gnus-fetch-group (group)
5187 "Start Gnus if necessary and enter GROUP.
5188 Returns whether the fetching was successful or not."
5189 (interactive "sGroup name: ")
5190 (or (get-buffer gnus-group-buffer)
5192 (gnus-group-read-group nil nil group))
5194 ;; Enter a group that is not in the group buffer. Non-nil is returned
5195 ;; if selection was successful.
5196 (defun gnus-group-read-ephemeral-group
5197 (group method &optional activate quit-config)
5198 (let ((group (if (gnus-group-foreign-p group) group
5199 (gnus-group-prefixed-name group method))))
5202 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5203 ((quit-config . ,(if quit-config quit-config
5204 (cons (current-buffer) 'summary))))))
5206 (set-buffer gnus-group-buffer)
5207 (or (gnus-check-server method)
5208 (error "Unable to contact server: %s" (gnus-status-message method)))
5209 (if activate (or (gnus-request-group group)
5210 (error "Couldn't request group")))
5212 (gnus-group-read-group t t group)
5216 (defun gnus-group-jump-to-group (group)
5217 "Jump to newsgroup GROUP."
5219 (list (completing-read
5220 "Group: " gnus-active-hashtb nil
5221 (memq gnus-select-method gnus-have-read-active-file))))
5223 (if (equal group "")
5224 (error "Empty group name"))
5226 (let ((b (text-property-any
5227 (point-min) (point-max)
5228 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5229 (unless (gnus-ephemeral-group-p group)
5231 ;; Either go to the line in the group buffer...
5233 ;; ... or insert the line.
5236 (gnus-activate-group group)
5237 (error "%s error: %s" group (gnus-status-message group)))
5239 (gnus-group-update-group group)
5240 (goto-char (text-property-any
5241 (point-min) (point-max)
5242 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5243 ;; Adjust cursor point.
5244 (gnus-group-position-point)))
5246 (defun gnus-group-goto-group (group)
5247 "Goto to newsgroup GROUP."
5249 (let ((b (text-property-any (point-min) (point-max)
5250 'gnus-group (gnus-intern-safe
5251 group gnus-active-hashtb))))
5252 (and b (goto-char b)))))
5254 (defun gnus-group-next-group (n)
5255 "Go to next N'th newsgroup.
5256 If N is negative, search backward instead.
5257 Returns the difference between N and the number of skips actually
5260 (gnus-group-next-unread-group n t))
5262 (defun gnus-group-next-unread-group (n &optional all level)
5263 "Go to next N'th unread newsgroup.
5264 If N is negative, search backward instead.
5265 If ALL is non-nil, choose any newsgroup, unread or not.
5266 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5267 such group can be found, the next group with a level higher than
5269 Returns the difference between N and the number of skips actually
5272 (let ((backward (< n 0))
5275 (gnus-group-search-forward
5276 backward (or (not gnus-group-goto-unread) all) level))
5278 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5279 (if level " on this level or higher" "")))
5282 (defun gnus-group-prev-group (n)
5283 "Go to previous N'th newsgroup.
5284 Returns the difference between N and the number of skips actually
5287 (gnus-group-next-unread-group (- n) t))
5289 (defun gnus-group-prev-unread-group (n)
5290 "Go to previous N'th unread newsgroup.
5291 Returns the difference between N and the number of skips actually
5294 (gnus-group-next-unread-group (- n)))
5296 (defun gnus-group-next-unread-group-same-level (n)
5297 "Go to next N'th unread newsgroup on the same level.
5298 If N is negative, search backward instead.
5299 Returns the difference between N and the number of skips actually
5302 (gnus-group-next-unread-group n t (gnus-group-group-level))
5303 (gnus-group-position-point))
5305 (defun gnus-group-prev-unread-group-same-level (n)
5306 "Go to next N'th unread newsgroup on the same level.
5307 Returns the difference between N and the number of skips actually
5310 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5311 (gnus-group-position-point))
5313 (defun gnus-group-best-unread-group (&optional exclude-group)
5314 "Go to the group with the highest level.
5315 If EXCLUDE-GROUP, do not go to that group."
5317 (goto-char (point-min))
5320 (while (setq unread (get-text-property (point) 'gnus-unread))
5321 (if (and (numberp unread) (> unread 0))
5323 (if (and (< (get-text-property (point) 'gnus-level) best)
5324 (or (not exclude-group)
5325 (not (equal exclude-group (gnus-group-group-name)))))
5327 (setq best (get-text-property (point) 'gnus-level))
5328 (setq best-point (point))))))
5330 (if best-point (goto-char best-point))
5331 (gnus-summary-position-point)
5332 (and best-point (gnus-group-group-name))))
5334 (defun gnus-group-first-unread-group ()
5335 "Go to the first group with unread articles."
5338 (let ((opoint (point))
5340 (goto-char (point-min))
5341 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5342 (and (numberp unread) ; Not a topic.
5343 (not (zerop unread))) ; Has unread articles.
5344 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5347 nil)) ; Not success.
5348 (gnus-group-position-point)))
5350 (defun gnus-group-enter-server-mode ()
5351 "Jump to the server buffer."
5353 (gnus-enter-server-buffer))
5355 (defun gnus-group-make-group (name &optional method address)
5356 "Add a new newsgroup.
5357 The user will be prompted for a NAME, for a select METHOD, and an
5361 (read-string "Group name: ")
5364 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5366 (if (assoc method gnus-valid-select-methods)
5368 (if (memq 'prompt-address
5369 (assoc method gnus-valid-select-methods))
5370 (read-string "Address: ")
5372 (list method "")))))
5375 (set-buffer gnus-group-buffer)
5376 (let* ((meth (and method (if address (list (intern method) address)
5378 (nname (if method (gnus-group-prefixed-name name meth) name))
5380 (and (gnus-gethash nname gnus-newsrc-hashtb)
5381 (error "Group %s already exists" nname))
5382 (gnus-group-change-level
5383 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5384 gnus-level-default-subscribed gnus-level-killed
5385 (and (gnus-group-group-name)
5386 (gnus-gethash (gnus-group-group-name)
5387 gnus-newsrc-hashtb))
5389 (gnus-set-active nname (cons 1 0))
5390 (or (gnus-ephemeral-group-p name)
5392 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5393 (gnus-group-insert-group-line-info nname)
5395 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5396 (require (car meth)))
5397 (gnus-check-server meth)
5398 (and (gnus-check-backend-function 'request-create-group nname)
5399 (gnus-request-create-group nname))
5402 (defun gnus-group-delete-group (group &optional force)
5403 "Delete the current group.
5404 If FORCE (the prefix) is non-nil, all the articles in the group will
5405 be deleted. This is \"deleted\" as in \"removed forever from the face
5406 of the Earth\". There is no undo."
5408 (list (gnus-group-group-name)
5409 current-prefix-arg))
5410 (or group (error "No group to rename"))
5411 (or (gnus-check-backend-function 'request-delete-group group)
5412 (error "This backend does not support group deletion"))
5414 (if (not (gnus-yes-or-no-p
5416 "Do you really want to delete %s%s? "
5417 group (if force " and all its contents" ""))))
5419 (gnus-message 6 "Deleting group %s..." group)
5420 (if (not (gnus-request-delete-group group force))
5422 (gnus-message 3 "Couldn't delete group %s" group)
5424 (gnus-message 6 "Deleting group %s...done" group)
5425 (gnus-group-goto-group group)
5426 (gnus-group-kill-group 1 t)
5427 (gnus-sethash group nil gnus-active-hashtb)
5429 (gnus-group-position-point)))
5431 (defun gnus-group-rename-group (group new-name)
5434 (gnus-group-group-name)
5436 (or (gnus-check-backend-function
5437 'request-rename-group (gnus-group-group-name))
5438 (error "This backend does not support renaming groups"))
5439 (read-string "New group name: "))))
5441 (or (gnus-check-backend-function 'request-rename-group group)
5442 (error "This backend does not support renaming groups"))
5444 (or group (error "No group to rename"))
5445 (and (string-match "^[ \t]*$" new-name)
5446 (error "Not a valid group name"))
5448 ;; We find the proper prefixed name.
5450 (gnus-group-prefixed-name
5451 (gnus-group-real-name new-name)
5452 (gnus-info-method (gnus-get-info group))))
5454 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5456 (if (not (gnus-request-rename-group group new-name))
5458 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5460 ;; We rename the group internally by killing it...
5461 (gnus-group-goto-group group)
5462 (gnus-group-kill-group)
5463 ;; ... changing its name ...
5464 (setcar (cdar gnus-list-of-killed-groups) new-name)
5465 ;; ... and then yanking it. Magic!
5466 (gnus-group-yank-group)
5467 (gnus-set-active new-name (gnus-active group))
5468 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5470 (gnus-group-position-point)))
5472 (defun gnus-group-edit-group (group &optional part)
5473 "Edit the group on the current line."
5474 (interactive (list (gnus-group-group-name)))
5475 (let* ((part (or part 'info))
5476 (done-func `(lambda ()
5477 "Exit editing mode and update the information."
5479 (gnus-group-edit-group-done ',part ,group)))
5480 (winconf (current-window-configuration))
5482 (or group (error "No group on current line"))
5483 (or (setq info (gnus-get-info group))
5484 (error "Killed group; can't be edited"))
5485 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5486 (gnus-configure-windows 'edit-group)
5487 (gnus-add-current-to-buffer-list)
5489 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5490 (use-local-map (copy-keymap emacs-lisp-mode-map))
5491 (local-set-key "\C-c\C-c" done-func)
5492 (make-local-variable 'gnus-prev-winconf)
5493 (setq gnus-prev-winconf winconf)
5498 ";; Type `C-c C-c' after editing the select method.\n\n")
5500 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5502 ";; Type `C-c C-c' after editing the group info.\n\n")))
5505 (cond ((eq part 'method)
5506 (or (gnus-info-method info) "native"))
5508 (gnus-info-params info))
5512 (defun gnus-group-edit-group-method (group)
5513 "Edit the select method of GROUP."
5514 (interactive (list (gnus-group-group-name)))
5515 (gnus-group-edit-group group 'method))
5517 (defun gnus-group-edit-group-parameters (group)
5518 "Edit the group parameters of GROUP."
5519 (interactive (list (gnus-group-group-name)))
5520 (gnus-group-edit-group group 'params))
5522 (defun gnus-group-edit-group-done (part group)
5523 "Get info from buffer, update variables and jump to the group buffer."
5524 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5525 (goto-char (point-min))
5526 (let* ((form (read (current-buffer)))
5527 (winconf gnus-prev-winconf)
5528 (method (cond ((eq part 'info) (nth 4 form))
5529 ((eq part 'method) form)
5531 (info (cond ((eq part 'info) form)
5532 ((eq part 'method) (gnus-get-info group))
5535 (if (or (not method)
5537 gnus-select-method method))
5538 (gnus-group-real-name (car info))
5539 (gnus-group-prefixed-name
5540 (gnus-group-real-name (car info)) method))
5542 (when (and new-group
5543 (not (equal new-group group)))
5544 (when (gnus-group-goto-group group)
5545 (gnus-group-kill-group 1))
5546 (gnus-activate-group new-group))
5548 (if (and info new-group)
5550 (setq info (gnus-copy-sequence info))
5551 (setcar info new-group)
5552 (unless (gnus-server-equal method "native")
5553 (unless (nthcdr 3 info)
5554 (nconc info (list nil nil)))
5555 (unless (nthcdr 4 info)
5556 (nconc info (list nil)))
5557 (gnus-info-set-method info method))
5558 (gnus-group-set-info info))
5559 (gnus-group-set-info form (or new-group group) part))
5560 (kill-buffer (current-buffer))
5561 (and winconf (set-window-configuration winconf))
5562 (set-buffer gnus-group-buffer)
5563 (gnus-group-update-group (or new-group group))
5564 (gnus-group-position-point)))
5566 (defun gnus-group-make-help-group ()
5567 "Create the Gnus documentation group."
5569 (let ((path load-path)
5570 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5572 (and (gnus-gethash name gnus-newsrc-hashtb)
5573 (error "Documentation group already exists"))
5575 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5577 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5579 (setq file (concat (file-name-directory
5580 (directory-file-name dir))
5581 "etc/gnus-tut.txt"))))
5584 (message "Couldn't find doc group")
5585 (gnus-group-make-group
5586 (gnus-group-real-name name)
5588 (list 'nndoc-address file)
5589 (list 'nndoc-article-type 'mbox)))))
5590 (gnus-group-position-point))
5592 (defun gnus-group-make-doc-group (file type)
5593 "Create a group that uses a single file as the source."
5595 (list (read-file-name "File name: ")
5596 (and current-prefix-arg 'ask)))
5597 (when (eq type 'ask)
5602 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5604 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5605 ((= char ?b) 'babyl)
5606 ((= char ?d) 'digest)
5607 ((= char ?f) 'forward)
5609 (t (setq err (format "%c unknown. " char))
5612 (let* ((file (expand-file-name file))
5613 (name (gnus-generate-new-group-name
5614 (gnus-group-prefixed-name
5615 (file-name-nondirectory file) '(nndoc "")))))
5616 (gnus-group-make-group
5617 (gnus-group-real-name name)
5619 (list 'nndoc-address file)
5620 (list 'nndoc-article-type (or type 'guess))))
5622 (gnus-group-position-point)))
5624 (defun gnus-group-make-archive-group (&optional all)
5625 "Create the (ding) Gnus archive group of the most recent articles.
5626 Given a prefix, create a full group."
5628 (let ((group (gnus-group-prefixed-name
5629 (if all "ding.archives" "ding.recent") '(nndir ""))))
5630 (and (gnus-gethash group gnus-newsrc-hashtb)
5631 (error "Archive group already exists"))
5632 (gnus-group-make-group
5633 (gnus-group-real-name group)
5634 (list 'nndir (if all "hpc" "edu")
5635 (list 'nndir-directory
5636 (if all gnus-group-archive-directory
5637 gnus-group-recent-archive-directory)))))
5639 (gnus-group-position-point))
5641 (defun gnus-group-make-directory-group (dir)
5642 "Create an nndir group.
5643 The user will be prompted for a directory. The contents of this
5644 directory will be used as a newsgroup. The directory should contain
5645 mail messages or news articles in files that have numeric names."
5647 (list (read-file-name "Create group from directory: ")))
5648 (or (file-exists-p dir) (error "No such directory"))
5649 (or (file-directory-p dir) (error "Not a directory"))
5653 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5655 (gnus-group-prefixed-name
5656 (concat (file-name-as-directory (directory-file-name dir))
5659 (setq ext (format "<%d>" (setq i (1+ i)))))
5660 (gnus-group-make-group
5661 (gnus-group-real-name group)
5662 (list 'nndir group (list 'nndir-directory dir))))
5664 (gnus-group-position-point))
5666 (defun gnus-group-make-kiboze-group (group address scores)
5667 "Create an nnkiboze group.
5668 The user will be prompted for a name, a regexp to match groups, and
5669 score file entries for articles to include in the group."
5672 (read-string "nnkiboze group name: ")
5673 (read-string "Source groups (regexp): ")
5674 (let ((headers (mapcar (lambda (group) (list group))
5675 '("subject" "from" "number" "date" "message-id"
5676 "references" "chars" "lines" "xref"
5677 "followup" "all" "body" "head")))
5678 scores header regexp regexps)
5679 (while (not (equal "" (setq header (completing-read
5680 "Match on header: " headers nil t))))
5682 (while (not (equal "" (setq regexp (read-string
5683 (format "Match on %s (string): "
5685 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5686 (setq scores (cons (cons header regexps) scores)))
5688 (gnus-group-make-group group "nnkiboze" address)
5690 (gnus-set-work-buffer)
5691 (let (emacs-lisp-mode-hook)
5692 (pp scores (current-buffer)))
5693 (write-region (point-min) (point-max)
5694 (gnus-score-file-name (concat "nnkiboze:" group))))
5696 (gnus-group-position-point))
5698 (defun gnus-group-add-to-virtual (n vgroup)
5699 "Add the current group to a virtual group."
5701 (list current-prefix-arg
5702 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5704 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5705 (error "%s is not an nnvirtual group" vgroup))
5706 (let* ((groups (gnus-group-process-prefix n))
5707 (method (gnus-info-method (gnus-get-info vgroup))))
5708 (setcar (cdr method)
5710 (nth 1 method) "\\|"
5713 (gnus-group-remove-mark s)
5714 (concat "\\(^" (regexp-quote s) "$\\)"))
5716 (gnus-group-position-point))
5718 (defun gnus-group-make-empty-virtual (group)
5719 "Create a new, fresh, empty virtual group."
5720 (interactive "sCreate new, empty virtual group: ")
5721 (let* ((method (list 'nnvirtual "^$"))
5722 (pgroup (gnus-group-prefixed-name group method)))
5723 ;; Check whether it exists already.
5724 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5725 (error "Group %s already exists." pgroup))
5726 ;; Subscribe the new group after the group on the current line.
5727 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5728 (gnus-group-update-group pgroup)
5730 (gnus-group-position-point)))
5732 (defun gnus-group-enter-directory (dir)
5733 "Enter an ephemeral nneething group."
5734 (interactive "DDirectory to read: ")
5735 (let* ((method (list 'nneething dir))
5736 (leaf (gnus-group-prefixed-name
5737 (file-name-nondirectory (directory-file-name dir))
5739 (name (gnus-generate-new-group-name leaf)))
5740 (let ((nneething-read-only t))
5741 (or (gnus-group-read-ephemeral-group
5743 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5745 (error "Couldn't enter %s" dir)))))
5747 ;; Group sorting commands
5748 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5750 (defun gnus-group-sort-groups (func &optional reverse)
5751 "Sort the group buffer according to FUNC.
5752 If REVERSE, reverse the sorting order."
5753 (interactive (list gnus-group-sort-function
5754 current-prefix-arg))
5756 ((not (listp func)) func)
5758 ((= 1 (length func)) (car func))
5760 ,(gnus-make-sort-function
5761 (reverse func)))))))
5762 ;; We peel off the dummy group from the alist.
5764 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5765 (pop gnus-newsrc-alist))
5767 (setq gnus-newsrc-alist
5768 (sort gnus-newsrc-alist func))
5770 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5771 ;; Regenerate the hash table.
5772 (gnus-make-hashtable-from-newsrc-alist)
5773 (gnus-group-list-groups))))
5775 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5776 "Sort the group buffer alphabetically by group name.
5777 If REVERSE, sort in reverse order."
5779 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5781 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5782 "Sort the group buffer by number of unread articles.
5783 If REVERSE, sort in reverse order."
5785 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5787 (defun gnus-group-sort-groups-by-level (&optional reverse)
5788 "Sort the group buffer by group level.
5789 If REVERSE, sort in reverse order."
5791 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5793 (defun gnus-group-sort-groups-by-score (&optional reverse)
5794 "Sort the group buffer by group score.
5795 If REVERSE, sort in reverse order."
5797 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5799 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5800 "Sort the group buffer by group rank.
5801 If REVERSE, sort in reverse order."
5803 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5805 (defun gnus-group-sort-groups-by-method (&optional reverse)
5806 "Sort the group buffer alphabetically by backend name.
5807 If REVERSE, sort in reverse order."
5809 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5811 (defun gnus-group-sort-by-alphabet (info1 info2)
5812 "Sort alphabetically."
5813 (string< (gnus-info-group info1) (gnus-info-group info2)))
5815 (defun gnus-group-sort-by-unread (info1 info2)
5816 "Sort by number of unread articles."
5817 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5818 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5819 (< (or (and (numberp n1) n1) 0)
5820 (or (and (numberp n2) n2) 0))))
5822 (defun gnus-group-sort-by-level (info1 info2)
5824 (< (gnus-info-level info1) (gnus-info-level info2)))
5826 (defun gnus-group-sort-by-method (info1 info2)
5827 "Sort alphabetically by backend name."
5828 (string< (symbol-name (car (gnus-find-method-for-group
5829 (gnus-info-group info1) info1)))
5830 (symbol-name (car (gnus-find-method-for-group
5831 (gnus-info-group info2) info2)))))
5833 (defun gnus-group-sort-by-score (info1 info2)
5834 "Sort by group score."
5835 (< (gnus-info-score info1) (gnus-info-score info2)))
5837 (defun gnus-group-sort-by-rank (info1 info2)
5838 "Sort by level and score."
5839 (let ((level1 (gnus-info-level info1))
5840 (level2 (gnus-info-level info2)))
5841 (or (< level1 level2)
5842 (and (= level1 level2)
5843 (< (gnus-info-score info1) (gnus-info-score info2))))))
5845 ;; Group catching up.
5847 (defun gnus-group-catchup-current (&optional n all)
5848 "Mark all articles not marked as unread in current newsgroup as read.
5849 If prefix argument N is numeric, the ARG next newsgroups will be
5850 caught up. If ALL is non-nil, marked articles will also be marked as
5851 read. Cross references (Xref: header) of articles are ignored.
5852 The difference between N and actual number of newsgroups that were
5853 caught up is returned."
5855 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5859 "Do you really want to mark all articles as read? "
5860 "Mark all unread articles as read? "))))
5862 (let ((groups (gnus-group-process-prefix n))
5865 ;; Virtual groups have to be given special treatment.
5866 (let ((method (gnus-find-method-for-group (car groups))))
5867 (if (eq 'nnvirtual (car method))
5868 (nnvirtual-catchup-group
5869 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5870 (gnus-group-remove-mark (car groups))
5872 (gnus-group-goto-group (car groups))
5873 (gnus-group-catchup (car groups) all))
5874 (gnus-group-update-group-line)
5875 (setq ret (1+ ret)))
5876 (setq groups (cdr groups)))
5877 (gnus-group-next-unread-group 1)
5880 (defun gnus-group-catchup-current-all (&optional n)
5881 "Mark all articles in current newsgroup as read.
5882 Cross references (Xref: header) of articles are ignored."
5884 (gnus-group-catchup-current n 'all))
5886 (defun gnus-group-catchup (group &optional all)
5887 "Mark all articles in GROUP as read.
5888 If ALL is non-nil, all articles are marked as read.
5889 The return value is the number of articles that were marked as read,
5890 or nil if no action could be taken."
5891 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5893 ;; Do the updating only if the newsgroup isn't killed.
5894 (if (not (numberp (car entry)))
5895 (gnus-message 1 "Can't catch up; non-active group")
5896 ;; Do auto-expirable marks if that's required.
5897 (when (gnus-group-auto-expirable-p group)
5898 (gnus-add-marked-articles
5899 group 'expire (gnus-list-of-unread-articles group))
5901 (let ((marks (nth 3 (nth 2 entry))))
5902 (gnus-add-marked-articles
5903 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5904 (gnus-add-marked-articles
5905 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5907 (gnus-update-read-articles group nil)
5908 ;; Also nix out the lists of marks and dormants.
5910 (gnus-add-marked-articles group 'tick nil nil 'force)
5911 (gnus-add-marked-articles group 'dormant nil nil 'force))
5912 (run-hooks 'gnus-group-catchup-group-hook)
5915 (defun gnus-group-expire-articles (&optional n)
5916 "Expire all expirable articles in the current newsgroup."
5918 (let ((groups (gnus-group-process-prefix n))
5921 (error "No groups to expire"))
5922 (while (setq group (pop groups))
5923 (gnus-group-remove-mark group)
5924 (when (gnus-check-backend-function 'request-expire-articles group)
5925 (gnus-message 6 "Expiring articles in %s..." group)
5926 (let* ((info (gnus-get-info group))
5927 (expirable (if (gnus-group-total-expirable-p group)
5928 (cons nil (gnus-list-of-read-articles group))
5929 (assq 'expire (gnus-info-marks info))))
5930 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5934 (gnus-compress-sequence
5936 ;; We set the expiry variables to the groupp
5938 (let ((nnmail-expiry-wait-function nil)
5939 (nnmail-expiry-wait expiry-wait))
5940 (gnus-request-expire-articles
5941 (gnus-uncompress-sequence (cdr expirable)) group))
5942 ;; Just expire using the normal expiry values.
5943 (gnus-request-expire-articles
5944 (gnus-uncompress-sequence (cdr expirable)) group)))))
5945 (gnus-message 6 "Expiring articles in %s...done" group)))
5946 (gnus-group-position-point))))
5948 (defun gnus-group-expire-all-groups ()
5949 "Expire all expirable articles in all newsgroups."
5952 (gnus-message 5 "Expiring...")
5953 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5954 (cdr gnus-newsrc-alist))))
5955 (gnus-group-expire-articles nil)))
5956 (gnus-group-position-point)
5957 (gnus-message 5 "Expiring...done"))
5959 (defun gnus-group-set-current-level (n level)
5960 "Set the level of the next N groups to LEVEL."
5965 (let ((s (read-string
5966 (format "Level (default %s): "
5967 (or (gnus-group-group-level)
5968 gnus-level-default-subscribed)))))
5969 (if (string-match "^\\s-*$" s)
5970 (int-to-string (or (gnus-group-group-level)
5971 gnus-level-default-subscribed))
5973 (or (and (>= level 1) (<= level gnus-level-killed))
5974 (error "Illegal level: %d" level))
5975 (let ((groups (gnus-group-process-prefix n))
5977 (while (setq group (pop groups))
5978 (gnus-group-remove-mark group)
5979 (gnus-message 6 "Changed level of %s from %d to %d"
5980 group (or (gnus-group-group-level) gnus-level-killed)
5982 (gnus-group-change-level
5983 group level (or (gnus-group-group-level) gnus-level-killed))
5984 (gnus-group-update-group-line)))
5985 (gnus-group-position-point))
5987 (defun gnus-group-unsubscribe-current-group (&optional n)
5988 "Toggle subscription of the current group.
5989 If given numerical prefix, toggle the N next groups."
5991 (let ((groups (gnus-group-process-prefix n))
5994 (setq group (car groups)
5995 groups (cdr groups))
5996 (gnus-group-remove-mark group)
5997 (gnus-group-unsubscribe-group
5998 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5999 gnus-level-default-unsubscribed
6000 gnus-level-default-subscribed) t)
6001 (gnus-group-update-group-line))
6002 (gnus-group-next-group 1)))
6004 (defun gnus-group-unsubscribe-group (group &optional level silent)
6005 "Toggle subscription to GROUP.
6006 Killed newsgroups are subscribed. If SILENT, don't try to update the
6009 (list (completing-read
6010 "Group: " gnus-active-hashtb nil
6011 (memq gnus-select-method gnus-have-read-active-file))))
6012 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6014 ((string-match "^[ \t]$" group)
6015 (error "Empty group name"))
6017 ;; Toggle subscription flag.
6018 (gnus-group-change-level
6019 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6020 gnus-level-subscribed)
6021 (1+ gnus-level-subscribed)
6022 gnus-level-default-subscribed)))
6024 (gnus-group-update-group group)))
6025 ((and (stringp group)
6026 (or (not (memq gnus-select-method gnus-have-read-active-file))
6027 (gnus-active group)))
6028 ;; Add new newsgroup.
6029 (gnus-group-change-level
6031 (if level level gnus-level-default-subscribed)
6032 (or (and (member group gnus-zombie-list)
6035 (and (gnus-group-group-name)
6036 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6038 (gnus-group-update-group group)))
6039 (t (error "No such newsgroup: %s" group)))
6040 (gnus-group-position-point)))
6042 (defun gnus-group-transpose-groups (n)
6043 "Move the current newsgroup up N places.
6044 If given a negative prefix, move down instead. The difference between
6045 N and the number of steps taken is returned."
6047 (or (gnus-group-group-name)
6048 (error "No group on current line"))
6049 (gnus-group-kill-group 1)
6051 (forward-line (- n))
6052 (gnus-group-yank-group)
6053 (gnus-group-position-point)))
6055 (defun gnus-group-kill-all-zombies ()
6056 "Kill all zombie newsgroups."
6058 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6059 (setq gnus-zombie-list nil)
6060 (gnus-group-list-groups))
6062 (defun gnus-group-kill-region (begin end)
6063 "Kill newsgroups in current region (excluding current point).
6064 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6079 (beginning-of-line) ;Important when LINES < 1
6080 (gnus-group-kill-group lines)))
6082 (defun gnus-group-kill-group (&optional n discard)
6083 "Kill the next N groups.
6084 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6085 However, only groups that were alive can be yanked; already killed
6086 groups or zombie groups can't be yanked.
6087 The return value is the name of the group that was killed, or a list
6090 (let ((buffer-read-only nil)
6091 (groups (gnus-group-process-prefix n))
6092 group entry level out)
6093 (if (< (length groups) 10)
6094 ;; This is faster when there are few groups.
6096 (push (setq group (pop groups)) out)
6097 (gnus-group-remove-mark group)
6098 (setq level (gnus-group-group-level))
6100 (when (and (not discard)
6101 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6102 (push (cons (car entry) (nth 2 entry))
6103 gnus-list-of-killed-groups))
6104 (gnus-group-change-level
6105 (if entry entry group) gnus-level-killed (if entry nil level)))
6106 ;; If there are lots and lots of groups to be killed, we use
6107 ;; this thing instead.
6109 (setq groups (nreverse groups))
6111 (gnus-group-remove-mark (setq group (pop groups)))
6114 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6115 (push (cons (car entry) (nth 2 entry))
6116 gnus-list-of-killed-groups)
6117 (setcdr (cdr entry) (cdddr entry)))
6118 ((member group gnus-zombie-list)
6119 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6120 (gnus-make-hashtable-from-newsrc-alist)))
6122 (gnus-group-position-point)
6123 (if (< (length out) 2) (car out) (nreverse out))))
6125 (defun gnus-group-yank-group (&optional arg)
6126 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6127 inserting it before the current newsgroup. The numeric ARG specifies
6128 how many newsgroups are to be yanked. The name of the newsgroup yanked
6129 is returned, or (if several groups are yanked) a list of yanked groups
6132 (setq arg (or arg 1))
6133 (let (info group prev out)
6134 (while (>= (decf arg) 0)
6135 (if (not (setq info (pop gnus-list-of-killed-groups)))
6136 (error "No more newsgroups to yank"))
6137 (push (setq group (nth 1 info)) out)
6138 ;; Find which newsgroup to insert this one before - search
6139 ;; backward until something suitable is found. If there are no
6140 ;; other newsgroups in this buffer, just make this newsgroup the
6142 (setq prev (gnus-group-group-name))
6143 (gnus-group-change-level
6144 info (gnus-info-level (cdr info)) gnus-level-killed
6145 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6147 (gnus-group-insert-group-line-info group))
6149 (gnus-group-position-point)
6150 (if (< (length out) 2) (car out) (nreverse out))))
6152 (defun gnus-group-kill-level (level)
6153 "Kill all groups that is on a certain LEVEL."
6154 (interactive "nKill all groups on level: ")
6156 ((= level gnus-level-zombie)
6157 (setq gnus-killed-list
6158 (nconc gnus-zombie-list gnus-killed-list))
6159 (setq gnus-zombie-list nil))
6160 ((and (< level gnus-level-zombie)
6162 (or gnus-expert-user
6165 "Do you really want to kill all groups on level %d? "
6167 (let* ((prev gnus-newsrc-alist)
6170 (if (= (gnus-info-level level) level)
6171 (setcdr prev (cdr alist))
6173 (setq alist (cdr alist)))
6174 (gnus-make-hashtable-from-newsrc-alist)
6175 (gnus-group-list-groups)))
6177 (error "Can't kill; illegal level: %d" level))))
6179 (defun gnus-group-list-all-groups (&optional arg)
6180 "List all newsgroups with level ARG or lower.
6181 Default is gnus-level-unsubscribed, which lists all subscribed and most
6182 unsubscribed groups."
6184 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6186 ;; Redefine this to list ALL killed groups if prefix arg used.
6187 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6188 (defun gnus-group-list-killed (&optional arg)
6189 "List all killed newsgroups in the group buffer.
6190 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6191 entail asking the server for the groups."
6193 ;; Find all possible killed newsgroups if arg.
6195 ;; First make sure active file has been read.
6196 (unless gnus-have-read-active-file
6197 (let ((gnus-read-active-file t))
6198 (gnus-read-active-file)))
6199 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6200 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6204 (group (symbol-name sym)))
6205 (if (or (null group)
6206 (gnus-gethash group gnus-killed-hashtb)
6207 (gnus-gethash group gnus-newsrc-hashtb))
6209 (let ((do-sub (gnus-matches-options-n group)))
6210 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6212 (setq groups (1+ groups))
6213 (setq gnus-killed-list
6214 (cons group gnus-killed-list))
6215 (gnus-sethash group group gnus-killed-hashtb))))))
6216 gnus-active-hashtb))
6217 (if (not gnus-killed-list)
6218 (gnus-message 6 "No killed groups")
6219 (let (gnus-group-list-mode)
6220 (funcall gnus-group-prepare-function
6221 gnus-level-killed t gnus-level-killed))
6222 (goto-char (point-min)))
6223 (gnus-group-position-point))
6225 (defun gnus-group-list-zombies ()
6226 "List all zombie newsgroups in the group buffer."
6228 (if (not gnus-zombie-list)
6229 (gnus-message 6 "No zombie groups")
6230 (let (gnus-group-list-mode)
6231 (funcall gnus-group-prepare-function
6232 gnus-level-zombie t gnus-level-zombie))
6233 (goto-char (point-min)))
6234 (gnus-group-position-point))
6236 (defun gnus-group-list-active ()
6237 "List all groups that are available from the server(s)."
6239 ;; First we make sure that we have really read the active file.
6240 (unless gnus-have-read-active-file
6241 (let ((gnus-read-active-file t))
6242 (gnus-read-active-file)))
6243 ;; Find all groups and sort them.
6249 (and (symbol-value sym)
6250 (setq list (cons (symbol-name sym) list))))
6254 (buffer-read-only nil))
6257 (gnus-group-insert-group-line-info (car groups))
6258 (setq groups (cdr groups)))
6259 (goto-char (point-min))))
6261 (defun gnus-activate-all-groups (level)
6262 "Activate absolutely all groups."
6263 (interactive (list 7))
6264 (let ((gnus-activate-level level)
6265 (gnus-activate-foreign-newsgroups level))
6266 (gnus-group-get-new-news)))
6268 (defun gnus-group-get-new-news (&optional arg)
6269 "Get newly arrived articles.
6270 If ARG is a number, it specifies which levels you are interested in
6271 re-scanning. If ARG is non-nil and not a number, this will force
6272 \"hard\" re-reading of the active files from all servers."
6274 (run-hooks 'gnus-get-new-news-hook)
6275 ;; We might read in new NoCeM messages here.
6276 (when (and gnus-use-nocem
6278 (gnus-nocem-scan-groups))
6279 ;; If ARG is not a number, then we read the active file.
6280 (when (and arg (not (numberp arg)))
6281 (let ((gnus-read-active-file t))
6282 (gnus-read-active-file))
6285 (setq arg (gnus-group-default-level arg t))
6286 (if (and gnus-read-active-file (not arg))
6288 (gnus-read-active-file)
6289 (gnus-get-unread-articles arg))
6290 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6291 (gnus-get-unread-articles arg)))
6292 (run-hooks 'gnus-after-getting-new-news-hook)
6293 (gnus-group-list-groups))
6295 (defun gnus-group-get-new-news-this-group (&optional n)
6296 "Check for newly arrived news in the current group (and the N-1 next groups).
6297 The difference between N and the number of newsgroup checked is returned.
6298 If N is negative, this group and the N-1 previous groups will be checked."
6300 (let* ((groups (gnus-group-process-prefix n))
6301 (ret (if (numberp n) (- n (length groups)) 0))
6304 (setq group (car groups)
6305 groups (cdr groups))
6306 (gnus-group-remove-mark group)
6307 (unless (gnus-get-new-news-in-group group)
6309 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6310 (when gnus-goto-next-group-when-activating
6311 (gnus-group-next-unread-group 1 t))
6312 (gnus-summary-position-point)
6315 (defun gnus-get-new-news-in-group (group)
6316 (when (and group (gnus-activate-group group 'scan))
6317 (gnus-get-unread-articles-in-group
6318 (gnus-get-info group) (gnus-active group) t)
6319 (gnus-close-group group)
6320 (when (gnus-group-goto-group group)
6321 (gnus-group-update-group-line))
6324 (defun gnus-group-fetch-faq (group &optional faq-dir)
6325 "Fetch the FAQ for the current group."
6328 (gnus-group-real-name (gnus-group-group-name))
6329 (cond (current-prefix-arg
6331 "Faq dir: " (and (listp gnus-group-faq-directory)
6332 gnus-group-faq-directory))))))
6334 (setq faq-dir (if (listp gnus-group-faq-directory)
6335 (car gnus-group-faq-directory)
6336 gnus-group-faq-directory)))
6337 (or group (error "No group name given"))
6338 (let ((file (concat (file-name-as-directory faq-dir)
6339 (gnus-group-real-name group))))
6340 (if (not (file-exists-p file))
6341 (error "No such file: %s" file)
6344 (defun gnus-group-describe-group (force &optional group)
6345 "Display a description of the current newsgroup."
6346 (interactive (list current-prefix-arg (gnus-group-group-name)))
6347 (and force (setq gnus-description-hashtb nil))
6348 (let ((method (gnus-find-method-for-group group))
6350 (or group (error "No group name given"))
6351 (and (or (and gnus-description-hashtb
6352 ;; We check whether this group's method has been
6353 ;; queried for a description file.
6355 (gnus-group-prefixed-name "" method)
6356 gnus-description-hashtb))
6357 (setq desc (gnus-group-get-description group))
6358 (gnus-read-descriptions-file method))
6360 (or desc (gnus-gethash group gnus-description-hashtb)
6361 "No description available")))))
6363 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6364 (defun gnus-group-describe-all-groups (&optional force)
6365 "Pop up a buffer with descriptions of all newsgroups."
6367 (and force (setq gnus-description-hashtb nil))
6368 (if (not (or gnus-description-hashtb
6369 (gnus-read-all-descriptions-files)))
6370 (error "Couldn't request descriptions file"))
6371 (let ((buffer-read-only nil)
6377 (insert (format " *: %-20s %s\n" (symbol-name group)
6378 (symbol-value group)))
6379 (add-text-properties
6380 b (1+ b) (list 'gnus-group group
6381 'gnus-unread t 'gnus-marked nil
6382 'gnus-level (1+ gnus-level-subscribed))))
6383 gnus-description-hashtb)
6384 (goto-char (point-min))
6385 (gnus-group-position-point)))
6387 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6388 (defun gnus-group-apropos (regexp &optional search-description)
6389 "List all newsgroups that have names that match a regexp."
6390 (interactive "sGnus apropos (regexp): ")
6392 (obuf (current-buffer))
6394 ;; Go through all newsgroups that are known to Gnus.
6397 (and (symbol-name group)
6398 (string-match regexp (symbol-name group))
6399 (setq groups (cons (symbol-name group) groups))))
6401 ;; Also go through all descriptions that are known to Gnus.
6402 (when search-description
6405 (and (string-match regexp (symbol-value group))
6406 (gnus-active (symbol-name group))
6407 (setq groups (cons (symbol-name group) groups))))
6408 gnus-description-hashtb))
6410 (gnus-message 3 "No groups matched \"%s\"." regexp)
6411 ;; Print out all the groups.
6413 (pop-to-buffer "*Gnus Help*")
6414 (buffer-disable-undo (current-buffer))
6416 (setq groups (sort groups 'string<))
6418 ;; Groups may be entered twice into the list of groups.
6419 (if (not (string= (car groups) prev))
6421 (insert (setq prev (car groups)) "\n")
6422 (if (and gnus-description-hashtb
6423 (setq des (gnus-gethash (car groups)
6424 gnus-description-hashtb)))
6425 (insert " " des "\n"))))
6426 (setq groups (cdr groups)))
6427 (goto-char (point-min))))
6428 (pop-to-buffer obuf)))
6430 (defun gnus-group-description-apropos (regexp)
6431 "List all newsgroups that have names or descriptions that match a regexp."
6432 (interactive "sGnus description apropos (regexp): ")
6433 (if (not (or gnus-description-hashtb
6434 (gnus-read-all-descriptions-files)))
6435 (error "Couldn't request descriptions file"))
6436 (gnus-group-apropos regexp t))
6438 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6439 (defun gnus-group-list-matching (level regexp &optional all lowest)
6440 "List all groups with unread articles that match REGEXP.
6441 If the prefix LEVEL is non-nil, it should be a number that says which
6442 level to cut off listing groups.
6443 If ALL, also list groups with no unread articles.
6444 If LOWEST, don't list groups with level lower than LOWEST."
6445 (interactive "P\nsList newsgroups matching: ")
6446 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6447 all (or lowest 1) regexp)
6448 (goto-char (point-min))
6449 (gnus-group-position-point))
6451 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6452 "List all groups that match REGEXP.
6453 If the prefix LEVEL is non-nil, it should be a number that says which
6454 level to cut off listing groups.
6455 If LOWEST, don't list groups with level lower than LOWEST."
6456 (interactive "P\nsList newsgroups matching: ")
6457 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6459 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6460 (defun gnus-group-save-newsrc (&optional force)
6461 "Save the Gnus startup files.
6462 If FORCE, force saving whether it is necessary or not."
6464 (gnus-save-newsrc-file force))
6466 (defun gnus-group-restart (&optional arg)
6467 "Force Gnus to read the .newsrc file."
6469 (when (gnus-yes-or-no-p
6470 (format "Are you sure you want to read %s? "
6471 gnus-current-startup-file))
6472 (gnus-save-newsrc-file)
6473 (gnus-setup-news 'force)
6474 (gnus-group-list-groups arg)))
6476 (defun gnus-group-read-init-file ()
6477 "Read the Gnus elisp init file."
6479 (gnus-read-init-file))
6481 (defun gnus-group-check-bogus-groups (&optional silent)
6482 "Check bogus newsgroups.
6483 If given a prefix, don't ask for confirmation before removing a bogus
6486 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6487 (gnus-group-list-groups))
6489 (defun gnus-group-edit-global-kill (&optional article group)
6490 "Edit the global kill file.
6491 If GROUP, edit that local kill file instead."
6493 (setq gnus-current-kill-article article)
6494 (gnus-kill-file-edit-file group)
6497 (substitute-command-keys
6498 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6499 (if group "local" "global")))))
6501 (defun gnus-group-edit-local-kill (article group)
6502 "Edit a local kill file."
6503 (interactive (list nil (gnus-group-group-name)))
6504 (gnus-group-edit-global-kill article group))
6506 (defun gnus-group-force-update ()
6507 "Update `.newsrc' file."
6509 (gnus-save-newsrc-file))
6511 (defun gnus-group-suspend ()
6512 "Suspend the current Gnus session.
6513 In fact, cleanup buffers except for group mode buffer.
6514 The hook gnus-suspend-gnus-hook is called before actually suspending."
6516 (run-hooks 'gnus-suspend-gnus-hook)
6517 ;; Kill Gnus buffers except for group mode buffer.
6518 (let ((group-buf (get-buffer gnus-group-buffer)))
6519 ;; Do this on a separate list in case the user does a ^G before we finish
6520 (let ((gnus-buffer-list
6521 (delq group-buf (delq gnus-dribble-buffer
6522 (append gnus-buffer-list nil)))))
6523 (while gnus-buffer-list
6524 (gnus-kill-buffer (car gnus-buffer-list))
6525 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6528 (setq gnus-buffer-list (list group-buf))
6529 (bury-buffer group-buf)
6530 (delete-windows-on group-buf t)))))
6532 (defun gnus-group-clear-dribble ()
6533 "Clear all information from the dribble buffer."
6535 (gnus-dribble-clear)
6536 (gnus-message 7 "Cleared dribble buffer"))
6538 (defun gnus-group-exit ()
6539 "Quit reading news after updating .newsrc.eld and .newsrc.
6540 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6543 (or noninteractive ;For gnus-batch-kill
6544 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6545 (not gnus-interactive-exit) ;Without confirmation
6547 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6548 (run-hooks 'gnus-exit-gnus-hook)
6549 ;; Offer to save data from non-quitted summary buffers.
6550 (gnus-offer-save-summaries)
6551 ;; Save the newsrc file(s).
6552 (gnus-save-newsrc-file)
6554 (gnus-close-backends)
6555 ;; Reset everything.
6557 ;; Allow the user to do things after cleaning up.
6558 (run-hooks 'gnus-after-exiting-gnus-hook)))
6560 (defun gnus-close-backends ()
6561 ;; Send a close request to all backends that support such a request.
6562 (let ((methods gnus-valid-select-methods)
6565 (if (fboundp (setq func (intern (concat (caar methods)
6566 "-request-close"))))
6568 (setq methods (cdr methods)))))
6570 (defun gnus-group-quit ()
6571 "Quit reading news without updating .newsrc.eld or .newsrc.
6572 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6574 (when (or noninteractive ;For gnus-batch-kill
6575 (zerop (buffer-size))
6576 (not (gnus-server-opened gnus-select-method))
6578 (not gnus-current-startup-file)
6580 (format "Quit reading news without saving %s? "
6581 (file-name-nondirectory gnus-current-startup-file))))
6582 (run-hooks 'gnus-exit-gnus-hook)
6583 (if gnus-use-full-window
6584 (delete-other-windows)
6585 (gnus-remove-some-windows))
6587 (gnus-close-backends)
6589 ;; Allow the user to do things after cleaning up.
6590 (run-hooks 'gnus-after-exiting-gnus-hook)))
6592 (defun gnus-offer-save-summaries ()
6593 "Offer to save all active summary buffers."
6595 (let ((buflist (buffer-list))
6597 ;; Go through all buffers and find all summaries.
6599 (and (setq bufname (buffer-name (car buflist)))
6600 (string-match "Summary" bufname)
6602 (set-buffer bufname)
6603 ;; We check that this is, indeed, a summary buffer.
6604 (and (eq major-mode 'gnus-summary-mode)
6605 ;; Also make sure this isn't bogus.
6606 gnus-newsgroup-prepared))
6607 (push bufname buffers))
6608 (setq buflist (cdr buflist)))
6609 ;; Go through all these summary buffers and offer to save them.
6612 "Update summary buffer %s? "
6613 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6616 (defun gnus-group-describe-briefly ()
6617 "Give a one line description of the group mode commands."
6619 (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")))
6621 (defun gnus-group-browse-foreign-server (method)
6622 "Browse a foreign news server.
6623 If called interactively, this function will ask for a select method
6624 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6625 If not, METHOD should be a list where the first element is the method
6626 and the second element is the address."
6628 (list (let ((how (completing-read
6630 (append gnus-valid-select-methods gnus-server-alist)
6631 nil t (cons "nntp" 0))))
6632 ;; We either got a backend name or a virtual server name.
6633 ;; If the first, we also need an address.
6634 (if (assoc how gnus-valid-select-methods)
6636 ;; Suggested by mapjph@bath.ac.uk.
6639 (mapcar (lambda (server) (list server))
6640 gnus-secondary-servers)))
6641 ;; We got a server name, so we find the method.
6642 (gnus-server-to-method how)))))
6643 (gnus-browse-foreign-server method))
6647 ;;; Gnus summary mode
6650 (defvar gnus-summary-mode-map nil)
6652 (put 'gnus-summary-mode 'mode-class 'special)
6654 (unless gnus-summary-mode-map
6655 (setq gnus-summary-mode-map (make-keymap))
6656 (suppress-keymap gnus-summary-mode-map)
6658 ;; Non-orthogonal keys
6660 (gnus-define-keys gnus-summary-mode-map
6661 " " gnus-summary-next-page
6662 "\177" gnus-summary-prev-page
6663 [delete] gnus-summary-prev-page
6664 "\r" gnus-summary-scroll-up
6665 "n" gnus-summary-next-unread-article
6666 "p" gnus-summary-prev-unread-article
6667 "N" gnus-summary-next-article
6668 "P" gnus-summary-prev-article
6669 "\M-\C-n" gnus-summary-next-same-subject
6670 "\M-\C-p" gnus-summary-prev-same-subject
6671 "\M-n" gnus-summary-next-unread-subject
6672 "\M-p" gnus-summary-prev-unread-subject
6673 "." gnus-summary-first-unread-article
6674 "," gnus-summary-best-unread-article
6675 "\M-s" gnus-summary-search-article-forward
6676 "\M-r" gnus-summary-search-article-backward
6677 "<" gnus-summary-beginning-of-article
6678 ">" gnus-summary-end-of-article
6679 "j" gnus-summary-goto-article
6680 "^" gnus-summary-refer-parent-article
6681 "\M-^" gnus-summary-refer-article
6682 "u" gnus-summary-tick-article-forward
6683 "!" gnus-summary-tick-article-forward
6684 "U" gnus-summary-tick-article-backward
6685 "d" gnus-summary-mark-as-read-forward
6686 "D" gnus-summary-mark-as-read-backward
6687 "E" gnus-summary-mark-as-expirable
6688 "\M-u" gnus-summary-clear-mark-forward
6689 "\M-U" gnus-summary-clear-mark-backward
6690 "k" gnus-summary-kill-same-subject-and-select
6691 "\C-k" gnus-summary-kill-same-subject
6692 "\M-\C-k" gnus-summary-kill-thread
6693 "\M-\C-l" gnus-summary-lower-thread
6694 "e" gnus-summary-edit-article
6695 "#" gnus-summary-mark-as-processable
6696 "\M-#" gnus-summary-unmark-as-processable
6697 "\M-\C-t" gnus-summary-toggle-threads
6698 "\M-\C-s" gnus-summary-show-thread
6699 "\M-\C-h" gnus-summary-hide-thread
6700 "\M-\C-f" gnus-summary-next-thread
6701 "\M-\C-b" gnus-summary-prev-thread
6702 "\M-\C-u" gnus-summary-up-thread
6703 "\M-\C-d" gnus-summary-down-thread
6704 "&" gnus-summary-execute-command
6705 "c" gnus-summary-catchup-and-exit
6706 "\C-w" gnus-summary-mark-region-as-read
6707 "\C-t" gnus-summary-toggle-truncation
6708 "?" gnus-summary-mark-as-dormant
6709 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6710 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6711 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6712 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6713 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6714 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6715 "=" gnus-summary-expand-window
6716 "\C-x\C-s" gnus-summary-reselect-current-group
6717 "\M-g" gnus-summary-rescan-group
6718 "w" gnus-summary-stop-page-breaking
6719 "\C-c\C-r" gnus-summary-caesar-message
6720 "\M-t" gnus-summary-toggle-mime
6721 "f" gnus-summary-followup
6722 "F" gnus-summary-followup-with-original
6723 "C" gnus-summary-cancel-article
6724 "r" gnus-summary-reply
6725 "R" gnus-summary-reply-with-original
6726 "\C-c\C-f" gnus-summary-mail-forward
6727 "o" gnus-summary-save-article
6728 "\C-o" gnus-summary-save-article-mail
6729 "|" gnus-summary-pipe-output
6730 "\M-k" gnus-summary-edit-local-kill
6731 "\M-K" gnus-summary-edit-global-kill
6733 "\C-c\C-d" gnus-summary-describe-group
6734 "q" gnus-summary-exit
6735 "Q" gnus-summary-exit-no-update
6736 "\C-c\C-i" gnus-info-find-node
6737 gnus-mouse-2 gnus-mouse-pick-article
6738 "m" gnus-summary-mail-other-window
6739 "a" gnus-summary-post-news
6740 "x" gnus-summary-limit-to-unread
6741 "s" gnus-summary-isearch-article
6742 "t" gnus-article-hide-headers
6743 "g" gnus-summary-show-article
6744 "l" gnus-summary-goto-last-article
6745 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6746 "\C-d" gnus-summary-enter-digest-group
6748 "*" gnus-cache-enter-article
6749 "\M-*" gnus-cache-remove-article
6750 "\M-&" gnus-summary-universal-argument
6751 "\C-l" gnus-recenter
6752 "I" gnus-summary-increase-score
6753 "L" gnus-summary-lower-score
6755 "V" gnus-summary-score-map
6756 "X" gnus-uu-extract-map
6757 "S" gnus-summary-send-map)
6759 ;; Sort of orthogonal keymap
6760 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6761 "t" gnus-summary-tick-article-forward
6762 "!" gnus-summary-tick-article-forward
6763 "d" gnus-summary-mark-as-read-forward
6764 "r" gnus-summary-mark-as-read-forward
6765 "c" gnus-summary-clear-mark-forward
6766 " " gnus-summary-clear-mark-forward
6767 "e" gnus-summary-mark-as-expirable
6768 "x" gnus-summary-mark-as-expirable
6769 "?" gnus-summary-mark-as-dormant
6770 "b" gnus-summary-set-bookmark
6771 "B" gnus-summary-remove-bookmark
6772 "#" gnus-summary-mark-as-processable
6773 "\M-#" gnus-summary-unmark-as-processable
6774 "S" gnus-summary-limit-include-expunged
6775 "C" gnus-summary-catchup
6776 "H" gnus-summary-catchup-to-here
6777 "\C-c" gnus-summary-catchup-all
6778 "k" gnus-summary-kill-same-subject-and-select
6779 "K" gnus-summary-kill-same-subject
6780 "P" gnus-uu-mark-map)
6782 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6783 "c" gnus-summary-clear-above
6784 "u" gnus-summary-tick-above
6785 "m" gnus-summary-mark-above
6786 "k" gnus-summary-kill-below)
6788 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6789 "/" gnus-summary-limit-to-subject
6790 "n" gnus-summary-limit-to-articles
6791 "w" gnus-summary-pop-limit
6792 "s" gnus-summary-limit-to-subject
6793 "a" gnus-summary-limit-to-author
6794 "u" gnus-summary-limit-to-unread
6795 "m" gnus-summary-limit-to-marks
6796 "v" gnus-summary-limit-to-score
6797 "D" gnus-summary-limit-include-dormant
6798 "d" gnus-summary-limit-exclude-dormant
6799 ;; "t" gnus-summary-limit-exclude-thread
6800 "E" gnus-summary-limit-include-expunged
6801 "c" gnus-summary-limit-exclude-childless-dormant
6802 "C" gnus-summary-limit-mark-excluded-as-read)
6804 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6805 "n" gnus-summary-next-unread-article
6806 "p" gnus-summary-prev-unread-article
6807 "N" gnus-summary-next-article
6808 "P" gnus-summary-prev-article
6809 "\C-n" gnus-summary-next-same-subject
6810 "\C-p" gnus-summary-prev-same-subject
6811 "\M-n" gnus-summary-next-unread-subject
6812 "\M-p" gnus-summary-prev-unread-subject
6813 "f" gnus-summary-first-unread-article
6814 "b" gnus-summary-best-unread-article
6815 "j" gnus-summary-goto-article
6816 "g" gnus-summary-goto-subject
6817 "l" gnus-summary-goto-last-article
6818 "p" gnus-summary-pop-article)
6820 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6821 "k" gnus-summary-kill-thread
6822 "l" gnus-summary-lower-thread
6823 "i" gnus-summary-raise-thread
6824 "T" gnus-summary-toggle-threads
6825 "t" gnus-summary-rethread-current
6826 "^" gnus-summary-reparent-thread
6827 "s" gnus-summary-show-thread
6828 "S" gnus-summary-show-all-threads
6829 "h" gnus-summary-hide-thread
6830 "H" gnus-summary-hide-all-threads
6831 "n" gnus-summary-next-thread
6832 "p" gnus-summary-prev-thread
6833 "u" gnus-summary-up-thread
6834 "o" gnus-summary-top-thread
6835 "d" gnus-summary-down-thread
6836 "#" gnus-uu-mark-thread
6837 "\M-#" gnus-uu-unmark-thread)
6839 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6840 "c" gnus-summary-catchup-and-exit
6841 "C" gnus-summary-catchup-all-and-exit
6842 "E" gnus-summary-exit-no-update
6843 "Q" gnus-summary-exit
6844 "Z" gnus-summary-exit
6845 "n" gnus-summary-catchup-and-goto-next-group
6846 "R" gnus-summary-reselect-current-group
6847 "G" gnus-summary-rescan-group
6848 "N" gnus-summary-next-group
6849 "P" gnus-summary-prev-group)
6851 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6852 " " gnus-summary-next-page
6853 "n" gnus-summary-next-page
6854 "\177" gnus-summary-prev-page
6855 [delete] gnus-summary-prev-page
6856 "p" gnus-summary-prev-page
6857 "\r" gnus-summary-scroll-up
6858 "<" gnus-summary-beginning-of-article
6859 ">" gnus-summary-end-of-article
6860 "b" gnus-summary-beginning-of-article
6861 "e" gnus-summary-end-of-article
6862 "^" gnus-summary-refer-parent-article
6863 "r" gnus-summary-refer-parent-article
6864 "R" gnus-summary-refer-references
6865 "g" gnus-summary-show-article
6866 "s" gnus-summary-isearch-article)
6868 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6869 "b" gnus-article-add-buttons
6870 "B" gnus-article-add-buttons-to-head
6871 "o" gnus-article-treat-overstrike
6872 ;; "w" gnus-article-word-wrap
6873 "w" gnus-article-fill-cited-article
6874 "c" gnus-article-remove-cr
6875 "L" gnus-article-remove-trailing-blank-lines
6876 "q" gnus-article-de-quoted-unreadable
6877 "f" gnus-article-display-x-face
6878 "l" gnus-summary-stop-page-breaking
6879 "r" gnus-summary-caesar-message
6880 "t" gnus-article-hide-headers
6881 "v" gnus-summary-verbose-headers
6882 "m" gnus-summary-toggle-mime)
6884 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6885 "a" gnus-article-hide
6886 "h" gnus-article-hide-headers
6887 "b" gnus-article-hide-boring-headers
6888 "s" gnus-article-hide-signature
6889 "c" gnus-article-hide-citation
6890 "p" gnus-article-hide-pgp
6891 "\C-c" gnus-article-hide-citation-maybe)
6893 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6894 "a" gnus-article-highlight
6895 "h" gnus-article-highlight-headers
6896 "c" gnus-article-highlight-citation
6897 "s" gnus-article-highlight-signature)
6899 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6900 "z" gnus-article-date-ut
6901 "u" gnus-article-date-ut
6902 "l" gnus-article-date-local
6903 "e" gnus-article-date-lapsed
6904 "o" gnus-article-date-original)
6906 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6908 "f" gnus-summary-fetch-faq
6909 "d" gnus-summary-describe-group
6910 "h" gnus-summary-describe-briefly
6911 "i" gnus-info-find-node)
6913 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6914 "e" gnus-summary-expire-articles
6915 "\M-\C-e" gnus-summary-expire-articles-now
6916 "\177" gnus-summary-delete-article
6917 [delete] gnus-summary-delete-article
6918 "m" gnus-summary-move-article
6919 "r" gnus-summary-respool-article
6920 "w" gnus-summary-edit-article
6921 "c" gnus-summary-copy-article
6922 "B" gnus-summary-crosspost-article
6923 "q" gnus-summary-respool-query
6924 "i" gnus-summary-import-article)
6926 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6927 "o" gnus-summary-save-article
6928 "m" gnus-summary-save-article-mail
6929 "r" gnus-summary-save-article-rmail
6930 "f" gnus-summary-save-article-file
6931 "b" gnus-summary-save-article-body-file
6932 "h" gnus-summary-save-article-folder
6933 "v" gnus-summary-save-article-vm
6934 "p" gnus-summary-pipe-output
6935 "s" gnus-soup-add-article)
6940 (defun gnus-summary-mode (&optional group)
6941 "Major mode for reading articles.
6943 All normal editing commands are switched off.
6944 \\<gnus-summary-mode-map>
6945 Each line in this buffer represents one article. To read an
6946 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6947 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6950 You can also post articles and send mail from this buffer. To
6951 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6952 of an article, type `\\[gnus-summary-reply]'.
6954 There are approx. one gazillion commands you can execute in this
6955 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6957 The following commands are available:
6959 \\{gnus-summary-mode-map}"
6961 (when (and menu-bar-mode
6962 (gnus-visual-p 'summary-menu 'menu))
6963 (gnus-summary-make-menu-bar))
6964 (kill-all-local-variables)
6965 (let ((locals gnus-summary-local-variables))
6967 (if (consp (car locals))
6969 (make-local-variable (caar locals))
6970 (set (caar locals) (eval (cdar locals))))
6971 (make-local-variable (car locals))
6972 (set (car locals) nil))
6973 (setq locals (cdr locals))))
6974 (gnus-make-thread-indent-array)
6975 (gnus-simplify-mode-line)
6976 (setq major-mode 'gnus-summary-mode)
6977 (setq mode-name "Summary")
6978 (make-local-variable 'minor-mode-alist)
6979 (use-local-map gnus-summary-mode-map)
6980 (buffer-disable-undo (current-buffer))
6981 (setq buffer-read-only t) ;Disable modification
6982 (setq truncate-lines t)
6983 (setq selective-display t)
6984 (setq selective-display-ellipses t) ;Display `...'
6985 (setq buffer-display-table gnus-summary-display-table)
6986 (setq gnus-newsgroup-name group)
6987 (run-hooks 'gnus-summary-mode-hook))
6989 (defun gnus-summary-make-display-table ()
6990 ;; Change the display table. Odd characters have a tendency to mess
6991 ;; up nicely formatted displays - we make all possible glyphs
6992 ;; display only a single character.
6994 ;; We start from the standard display table, if any.
6995 (setq gnus-summary-display-table
6996 (or (copy-sequence standard-display-table)
6997 (make-display-table)))
6998 ;; Nix out all the control chars...
7000 (while (>= (setq i (1- i)) 0)
7001 (aset gnus-summary-display-table i [??])))
7002 ;; ... but not newline and cr, of course. (cr is necessary for the
7003 ;; selective display).
7004 (aset gnus-summary-display-table ?\n nil)
7005 (aset gnus-summary-display-table ?\r nil)
7006 ;; We nix out any glyphs over 126 that are not set already.
7008 (while (>= (setq i (1- i)) 127)
7009 ;; Only modify if the entry is nil.
7010 (or (aref gnus-summary-display-table i)
7011 (aset gnus-summary-display-table i [??])))))
7013 (defun gnus-summary-clear-local-variables ()
7014 (let ((locals gnus-summary-local-variables))
7016 (if (consp (car locals))
7017 (and (vectorp (caar locals))
7018 (set (caar locals) nil))
7019 (and (vectorp (car locals))
7020 (set (car locals) nil)))
7021 (setq locals (cdr locals)))))
7023 ;; Summary data functions.
7025 (defmacro gnus-data-number (data)
7028 (defmacro gnus-data-set-number (data number)
7029 `(setcar ,data ,number))
7031 (defmacro gnus-data-mark (data)
7034 (defmacro gnus-data-set-mark (data mark)
7035 `(setcar (nthcdr 1 ,data) ,mark))
7037 (defmacro gnus-data-pos (data)
7040 (defmacro gnus-data-set-pos (data pos)
7041 `(setcar (nthcdr 2 ,data) ,pos))
7043 (defmacro gnus-data-header (data)
7046 (defmacro gnus-data-level (data)
7049 (defmacro gnus-data-unread-p (data)
7050 `(= (nth 1 ,data) gnus-unread-mark))
7052 (defmacro gnus-data-pseudo-p (data)
7053 `(consp (nth 3 ,data)))
7055 (defmacro gnus-data-find (number)
7056 `(assq ,number gnus-newsgroup-data))
7058 (defmacro gnus-data-find-list (number &optional data)
7059 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7060 (memq (assq ,number bdata)
7063 (defmacro gnus-data-make (number mark pos header level)
7064 `(list ,number ,mark ,pos ,header ,level))
7066 (defun gnus-data-enter (after-article number mark pos header level offset)
7067 (let ((data (gnus-data-find-list after-article)))
7068 (or data (error "No such article: %d" after-article))
7069 (setcdr data (cons (gnus-data-make number mark pos header level)
7071 (setq gnus-newsgroup-data-reverse nil)
7072 (gnus-data-update-list (cddr data) offset)))
7074 (defun gnus-data-enter-list (after-article list &optional offset)
7076 (let ((data (and after-article (gnus-data-find-list after-article)))
7078 (or data (not after-article) (error "No such article: %d" after-article))
7079 ;; Find the last element in the list to be spliced into the main
7082 (setq list (cdr list)))
7085 (setcdr list gnus-newsgroup-data)
7086 (setq gnus-newsgroup-data ilist)
7087 (and offset (gnus-data-update-list (cdr list) offset)))
7088 (setcdr list (cdr data))
7090 (and offset (gnus-data-update-list (cdr data) offset)))
7091 (setq gnus-newsgroup-data-reverse nil))))
7093 (defun gnus-data-remove (article &optional offset)
7094 (let ((data gnus-newsgroup-data))
7095 (if (= (gnus-data-number (car data)) article)
7096 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7097 gnus-newsgroup-data-reverse nil)
7099 (and (= (gnus-data-number (cadr data)) article)
7101 (setcdr data (cddr data))
7102 (and offset (gnus-data-update-list (cdr data) offset))
7104 gnus-newsgroup-data-reverse nil)))
7105 (setq data (cdr data))))))
7107 (defmacro gnus-data-list (backward)
7109 (or gnus-newsgroup-data-reverse
7110 (setq gnus-newsgroup-data-reverse
7111 (reverse gnus-newsgroup-data)))
7112 gnus-newsgroup-data))
7114 (defun gnus-data-update-list (data offset)
7115 "Add OFFSET to the POS of all data entries in DATA."
7117 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7118 (setq data (cdr data))))
7120 (defun gnus-data-compute-positions ()
7121 "Compute the positions of all articles."
7122 (let ((data gnus-newsgroup-data)
7125 (when (setq pos (text-property-any
7126 (point-min) (point-max)
7127 'gnus-number (gnus-data-number (car data))))
7128 (gnus-data-set-pos (car data) (+ pos 3)))
7129 (setq data (cdr data)))))
7131 (defun gnus-summary-article-pseudo-p (article)
7132 "Say whether this article is a pseudo article or not."
7133 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7135 (defun gnus-article-parent-p (number)
7136 "Say whether this article is a parent or not."
7137 (let ((data (gnus-data-find-list number)))
7138 (and (cdr data) ; There has to be an article after...
7139 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7140 (gnus-data-level (nth 1 data))))))
7142 (defun gnus-article-children (number)
7143 "Return a list of all children to NUMBER."
7144 (let* ((data (gnus-data-find-list number))
7145 (level (gnus-data-level (car data)))
7147 (setq data (cdr data))
7149 (= (gnus-data-level (car data)) (1+ level)))
7150 (push (gnus-data-number (car data)) children)
7151 (setq data (cdr data)))
7154 (defmacro gnus-summary-skip-intangible ()
7155 "If the current article is intangible, then jump to a different article."
7156 '(let ((to (get-text-property (point) 'gnus-intangible)))
7157 (and to (gnus-summary-goto-subject to))))
7159 (defmacro gnus-summary-article-intangible-p ()
7160 "Say whether this article is intangible or not."
7161 '(get-text-property (point) 'gnus-intangible))
7163 ;; Some summary mode macros.
7165 (defmacro gnus-summary-article-number ()
7166 "The article number of the article on the current line.
7167 If there isn's an article number here, then we return the current
7170 (gnus-summary-skip-intangible)
7171 (or (get-text-property (point) 'gnus-number)
7172 (gnus-summary-last-subject))))
7174 (defmacro gnus-summary-article-header (&optional number)
7175 `(gnus-data-header (gnus-data-find
7176 ,(or number '(gnus-summary-article-number)))))
7178 (defmacro gnus-summary-thread-level (&optional number)
7179 `(if (and (eq gnus-summary-make-false-root 'dummy)
7180 (get-text-property (point) 'gnus-intangible))
7182 (gnus-data-level (gnus-data-find
7183 ,(or number '(gnus-summary-article-number))))))
7185 (defmacro gnus-summary-article-mark (&optional number)
7186 `(gnus-data-mark (gnus-data-find
7187 ,(or number '(gnus-summary-article-number)))))
7189 (defmacro gnus-summary-article-pos (&optional number)
7190 `(gnus-data-pos (gnus-data-find
7191 ,(or number '(gnus-summary-article-number)))))
7193 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7194 (defmacro gnus-summary-article-subject (&optional number)
7195 "Return current subject string or nil if nothing."
7198 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7199 '(gnus-data-header (assq (gnus-summary-article-number)
7200 gnus-newsgroup-data)))))
7203 (mail-header-subject headers))))
7205 (defmacro gnus-summary-article-score (&optional number)
7206 "Return current article score."
7207 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7208 gnus-newsgroup-scored))
7209 gnus-summary-default-score 0))
7211 (defun gnus-summary-article-children (&optional number)
7212 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7213 (level (gnus-data-level (car data)))
7215 (while (and (setq data (cdr data))
7216 (> (setq l (gnus-data-level (car data))) level))
7217 (and (= (1+ level) l)
7218 (setq children (cons (gnus-data-number (car data))
7220 (nreverse children)))
7222 (defun gnus-summary-article-parent (&optional number)
7223 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7224 (gnus-data-list t)))
7225 (level (gnus-data-level (car data))))
7227 () ; This is a root.
7228 ;; We search until we find an article with a level less than
7229 ;; this one. That function has to be the parent.
7230 (while (and (setq data (cdr data))
7231 (not (< (gnus-data-level (car data)) level))))
7232 (and data (gnus-data-number (car data))))))
7234 (defun gnus-unread-mark-p (mark)
7235 "Say whether MARK is the unread mark."
7236 (= mark gnus-unread-mark))
7238 (defun gnus-read-mark-p (mark)
7239 "Say whether MARK is one of the marks that mark as read.
7240 This is all marks except unread, ticked, dormant, and expirable."
7241 (not (or (= mark gnus-unread-mark)
7242 (= mark gnus-ticked-mark)
7243 (= mark gnus-dormant-mark)
7244 (= mark gnus-expirable-mark))))
7246 ;; Various summary mode internalish functions.
7248 (defun gnus-mouse-pick-article (e)
7251 (gnus-summary-next-page nil t))
7253 (defun gnus-summary-setup-buffer (group)
7254 "Initialize summary buffer."
7255 (let ((buffer (concat "*Summary " group "*")))
7256 (if (get-buffer buffer)
7259 (setq gnus-summary-buffer (current-buffer))
7260 (not gnus-newsgroup-prepared))
7261 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7262 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7263 (gnus-add-current-to-buffer-list)
7264 (gnus-summary-mode group)
7266 (gnus-carpal-setup-buffer 'summary))
7267 (unless gnus-single-article-buffer
7268 (make-local-variable 'gnus-article-buffer)
7269 (make-local-variable 'gnus-article-current)
7270 (make-local-variable 'gnus-original-article-buffer))
7271 (setq gnus-newsgroup-name group)
7274 (defun gnus-set-global-variables ()
7275 ;; Set the global equivalents of the summary buffer-local variables
7276 ;; to the latest values they had. These reflect the summary buffer
7277 ;; that was in action when the last article was fetched.
7278 (when (eq major-mode 'gnus-summary-mode)
7279 (setq gnus-summary-buffer (current-buffer))
7280 (let ((name gnus-newsgroup-name)
7281 (marked gnus-newsgroup-marked)
7282 (unread gnus-newsgroup-unreads)
7283 (headers gnus-current-headers)
7284 (data gnus-newsgroup-data)
7285 (summary gnus-summary-buffer)
7286 (article-buffer gnus-article-buffer)
7287 (original gnus-original-article-buffer)
7288 (gac gnus-article-current)
7289 (score-file gnus-current-score-file))
7291 (set-buffer gnus-group-buffer)
7292 (setq gnus-newsgroup-name name)
7293 (setq gnus-newsgroup-marked marked)
7294 (setq gnus-newsgroup-unreads unread)
7295 (setq gnus-current-headers headers)
7296 (setq gnus-newsgroup-data data)
7297 (setq gnus-article-current gac)
7298 (setq gnus-summary-buffer summary)
7299 (setq gnus-article-buffer article-buffer)
7300 (setq gnus-original-article-buffer original)
7301 (setq gnus-current-score-file score-file)))))
7303 (defun gnus-summary-last-article-p (&optional article)
7304 "Return whether ARTICLE is the last article in the buffer."
7305 (if (not (setq article (or article (gnus-summary-article-number))))
7306 t ; All non-existant numbers are the last article. :-)
7307 (cdr (gnus-data-find-list article))))
7309 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7310 "Insert a dummy root in the summary buffer."
7312 (add-text-properties
7313 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7314 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7316 (defvar gnus-thread-indent-array nil)
7317 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7318 (defun gnus-make-thread-indent-array ()
7320 (unless (and gnus-thread-indent-array
7321 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7322 (setq gnus-thread-indent-array (make-vector 201 "")
7323 gnus-thread-indent-array-level gnus-thread-indent-level)
7325 (aset gnus-thread-indent-array n
7326 (make-string (* n gnus-thread-indent-level) ? ))
7329 (defun gnus-summary-insert-line
7330 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7331 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7332 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7333 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7334 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7335 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7336 (gnus-tmp-score-char
7337 (if (or (null gnus-summary-default-score)
7338 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7339 gnus-summary-zcore-fuzz)) ?
7340 (if (< gnus-tmp-score gnus-summary-default-score)
7341 gnus-score-below-mark gnus-score-over-mark)))
7342 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7343 ((memq gnus-tmp-current gnus-newsgroup-cached)
7345 (gnus-tmp-replied gnus-replied-mark)
7346 ((memq gnus-tmp-current gnus-newsgroup-saved)
7348 (t gnus-unread-mark)))
7349 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7352 ((string-match "(.+)" gnus-tmp-from)
7353 (substring gnus-tmp-from
7354 (1+ (match-beginning 0)) (1- (match-end 0))))
7355 ((string-match "<[^>]+> *$" gnus-tmp-from)
7356 (let ((beg (match-beginning 0)))
7357 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7358 (substring gnus-tmp-from (1+ (match-beginning 0))
7359 (1- (match-end 0))))
7360 (substring gnus-tmp-from 0 beg))))
7362 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7363 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7364 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7365 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7366 (buffer-read-only nil))
7367 (when (string= gnus-tmp-name "")
7368 (setq gnus-tmp-name gnus-tmp-from))
7369 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7372 (progn (eval gnus-summary-line-format-spec) (point))
7373 'gnus-number gnus-tmp-number)
7374 (when (gnus-visual-p 'summary-highlight 'highlight)
7376 (run-hooks 'gnus-summary-update-hook)
7379 (defun gnus-summary-update-line (&optional dont-update)
7380 ;; Update summary line after change.
7381 (when (and gnus-summary-default-score
7382 (not gnus-summary-inhibit-highlight))
7383 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7384 (article (gnus-summary-article-number))
7385 (score (gnus-summary-article-score article)))
7387 (if (and gnus-summary-mark-below
7388 (< (gnus-summary-article-score)
7389 gnus-summary-mark-below))
7390 ;; This article has a low score, so we mark it as read.
7391 (when (memq article gnus-newsgroup-unreads)
7392 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7393 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7394 ;; This article was previously marked as read on account
7395 ;; of a low score, but now it has risen, so we mark it as
7397 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7398 (gnus-summary-update-mark
7399 (if (or (null gnus-summary-default-score)
7400 (<= (abs (- score gnus-summary-default-score))
7401 gnus-summary-zcore-fuzz)) ?
7402 (if (< score gnus-summary-default-score)
7403 gnus-score-below-mark gnus-score-over-mark)) 'score))
7404 ;; Do visual highlighting.
7405 (when (gnus-visual-p 'summary-highlight 'highlight)
7406 (run-hooks 'gnus-summary-update-hook)))))
7408 (defvar gnus-tmp-new-adopts nil)
7410 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7411 ;; Sum up all elements (and sub-elements) in a list.
7413 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7415 ((and (consp thread) (cdr thread))
7418 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7421 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7424 (when (and level (zerop level) gnus-tmp-new-adopts)
7427 'gnus-summary-number-of-articles-in-thread
7428 gnus-tmp-new-adopts))))
7430 (if (> number 1) gnus-not-empty-thread-mark
7431 gnus-empty-thread-mark)
7434 (defun gnus-summary-set-local-parameters (group)
7435 "Go through the local params of GROUP and set all variable specs in that list."
7436 (let ((params (gnus-info-params (gnus-get-info group)))
7439 (setq elem (car params)
7440 params (cdr params))
7441 (and (consp elem) ; Has to be a cons.
7442 (consp (cdr elem)) ; The cdr has to be a list.
7443 (symbolp (car elem)) ; Has to be a symbol in there.
7444 (not (memq (car elem)
7445 '(quit-config to-address to-list to-group)))
7446 (progn ; So we set it.
7447 (make-local-variable (car elem))
7448 (set (car elem) (eval (nth 1 elem))))))))
7450 (defun gnus-summary-read-group (group &optional show-all no-article
7451 kill-buffer no-display)
7452 "Start reading news in newsgroup GROUP.
7453 If SHOW-ALL is non-nil, already read articles are also listed.
7454 If NO-ARTICLE is non-nil, no article is selected initially.
7455 If NO-DISPLAY, don't generate a summary buffer."
7456 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7457 (let* ((new-group (gnus-summary-setup-buffer group))
7458 (quit-config (gnus-group-quit-config group))
7459 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7461 ;; This summary buffer exists already, so we just select it.
7463 (gnus-set-global-variables)
7465 (gnus-kill-or-deaden-summary kill-buffer))
7466 (gnus-configure-windows 'summary 'force)
7467 (gnus-set-mode-line 'summary)
7468 (gnus-summary-position-point)
7471 ;; We couldn't select this group.
7473 (when (and (eq major-mode 'gnus-summary-mode)
7474 (not (equal (current-buffer) kill-buffer)))
7475 (kill-buffer (current-buffer))
7476 (if (not quit-config)
7478 (set-buffer gnus-group-buffer)
7479 (gnus-group-jump-to-group group)
7480 (gnus-group-next-unread-group 1))
7481 (if (not (buffer-name (car quit-config)))
7482 (gnus-configure-windows 'group 'force)
7483 (set-buffer (car quit-config))
7484 (and (eq major-mode 'gnus-summary-mode)
7485 (gnus-set-global-variables))
7486 (gnus-configure-windows (cdr quit-config)))))
7487 (gnus-message 3 "Can't select group")
7489 ;; The user did a `C-g' while prompting for number of articles,
7490 ;; so we exit this group.
7491 ((eq did-select 'quit)
7492 (and (eq major-mode 'gnus-summary-mode)
7493 (not (equal (current-buffer) kill-buffer))
7494 (kill-buffer (current-buffer)))
7496 (gnus-kill-or-deaden-summary kill-buffer))
7497 (if (not quit-config)
7499 (set-buffer gnus-group-buffer)
7500 (gnus-group-jump-to-group group)
7501 (gnus-group-next-unread-group 1)
7502 (gnus-configure-windows 'group 'force))
7503 (if (not (buffer-name (car quit-config)))
7504 (gnus-configure-windows 'group 'force)
7505 (set-buffer (car quit-config))
7506 (and (eq major-mode 'gnus-summary-mode)
7507 (gnus-set-global-variables))
7508 (gnus-configure-windows (cdr quit-config))))
7509 ;; Finally signal the quit.
7511 ;; The group was successfully selected.
7513 (gnus-set-global-variables)
7514 ;; Save the active value in effect when the group was entered.
7515 (setq gnus-newsgroup-active
7517 (gnus-active gnus-newsgroup-name)))
7518 ;; You can change the summary buffer in some way with this hook.
7519 (run-hooks 'gnus-select-group-hook)
7520 ;; Set any local variables in the group parameters.
7521 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7522 (gnus-update-format-specifications)
7523 ;; Do score processing.
7524 (when gnus-use-scoring
7525 (gnus-possibly-score-headers))
7526 ;; Check whether to fill in the gaps in the threads.
7527 (when gnus-build-sparse-threads
7528 (gnus-build-sparse-threads))
7529 ;; Find the initial limit.
7531 (let ((gnus-newsgroup-dormant nil))
7532 (gnus-summary-initial-limit show-all))
7533 (gnus-summary-initial-limit show-all))
7534 ;; Generate the summary buffer.
7536 (gnus-summary-prepare))
7537 (when gnus-use-trees
7538 (gnus-tree-open group)
7539 (setq gnus-summary-highlight-line-function
7540 'gnus-tree-highlight-article))
7541 ;; If the summary buffer is empty, but there are some low-scored
7542 ;; articles or some excluded dormants, we include these in the
7544 (when (and (zerop (buffer-size))
7546 (cond (gnus-newsgroup-dormant
7547 (gnus-summary-limit-include-dormant))
7548 ((and gnus-newsgroup-scored show-all)
7549 (gnus-summary-limit-include-expunged))))
7550 ;; Function `gnus-apply-kill-file' must be called in this hook.
7551 (run-hooks 'gnus-apply-kill-hook)
7552 (if (and (zerop (buffer-size))
7555 ;; This newsgroup is empty.
7556 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7557 (gnus-message 6 "No unread news")
7559 (gnus-kill-or-deaden-summary kill-buffer))
7560 ;; Return nil from this function.
7562 ;; Hide conversation thread subtrees. We cannot do this in
7563 ;; gnus-summary-prepare-hook since kill processing may not
7564 ;; work with hidden articles.
7565 (and gnus-show-threads
7566 gnus-thread-hide-subtree
7567 (gnus-summary-hide-all-threads))
7568 ;; Show first unread article if requested.
7569 (if (and (not no-article)
7571 gnus-newsgroup-unreads
7572 gnus-auto-select-first)
7573 (if (eq gnus-auto-select-first 'best)
7574 (gnus-summary-best-unread-article)
7575 (gnus-summary-first-unread-article))
7576 ;; Don't select any articles, just move point to the first
7577 ;; article in the group.
7578 (goto-char (point-min))
7579 (gnus-summary-position-point)
7580 (gnus-set-mode-line 'summary)
7581 (gnus-configure-windows 'summary 'force))
7582 ;; If we are in async mode, we send some info to the backend.
7583 (when gnus-newsgroup-async
7584 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7586 (gnus-kill-or-deaden-summary kill-buffer))
7587 (when (get-buffer-window gnus-group-buffer t)
7588 ;; Gotta use windows, because recenter does wierd stuff if
7589 ;; the current buffer ain't the displayed window.
7590 (let ((owin (selected-window)))
7591 (select-window (get-buffer-window gnus-group-buffer t))
7592 (when (gnus-group-goto-group group)
7594 (select-window owin))))
7595 ;; Mark this buffer as "prepared".
7596 (setq gnus-newsgroup-prepared t)
7599 (defun gnus-summary-prepare ()
7600 "Generate the summary buffer."
7601 (let ((buffer-read-only nil))
7603 (setq gnus-newsgroup-data nil
7604 gnus-newsgroup-data-reverse nil)
7605 (run-hooks 'gnus-summary-generate-hook)
7606 ;; Generate the buffer, either with threads or without.
7607 (when gnus-newsgroup-headers
7608 (gnus-summary-prepare-threads
7609 (if gnus-show-threads
7610 (gnus-sort-gathered-threads
7611 (funcall gnus-summary-thread-gathering-function
7613 (gnus-cut-threads (gnus-make-threads)))))
7614 ;; Unthreaded display.
7615 (gnus-sort-articles gnus-newsgroup-headers))))
7616 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7617 ;; Call hooks for modifying summary buffer.
7618 (goto-char (point-min))
7619 (run-hooks 'gnus-summary-prepare-hook)))
7621 (defun gnus-gather-threads-by-subject (threads)
7622 "Gather threads by looking at Subject headers."
7623 (if (not gnus-summary-make-false-root)
7625 (let ((hashtb (gnus-make-hashtable 1023))
7628 subject hthread whole-subject)
7630 (setq whole-subject (mail-header-subject (caar threads)))
7631 (if (and gnus-summary-gather-exclude-subject
7632 (string-match gnus-summary-gather-exclude-subject
7634 () ; We don't want to do anything with this article.
7635 ;; We simplify the subject before looking it up in the
7639 ;; Truncate the subject.
7640 ((numberp gnus-summary-gather-subject-limit)
7641 (setq subject (gnus-simplify-subject-re whole-subject))
7642 (if (> (length subject) gnus-summary-gather-subject-limit)
7643 (substring subject 0 gnus-summary-gather-subject-limit)
7645 ;; Fuzzily simplify it.
7646 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7647 (gnus-simplify-subject-fuzzy whole-subject))
7648 ;; Just remove the leading "Re:".
7650 (gnus-simplify-subject-re whole-subject))))
7652 (if (setq hthread (gnus-gethash subject hashtb))
7654 ;; We enter a dummy root into the thread, if we
7655 ;; haven't done that already.
7656 (unless (stringp (caar hthread))
7657 (setcar hthread (list whole-subject (car hthread))))
7658 ;; We add this new gathered thread to this gathered
7660 (setcdr (car hthread)
7661 (nconc (cdar hthread) (list (car threads))))
7662 ;; Remove it from the list of threads.
7663 (setcdr prev (cdr threads))
7664 (setq threads prev))
7665 ;; Enter this thread into the hash table.
7666 (gnus-sethash subject threads hashtb)))
7668 (setq threads (cdr threads)))
7671 (defun gnus-gather-threads-by-references (threads)
7672 "Gather threads by looking at References headers."
7673 (let ((idhashtb (gnus-make-hashtable 1023))
7674 (thhashtb (gnus-make-hashtable 1023))
7677 ids references id gthread gid entered)
7679 (when (setq references (mail-header-references (caar threads)))
7680 (setq id (mail-header-id (caar threads)))
7681 (setq ids (gnus-split-references references))
7684 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7686 (gnus-sethash (car ids) id idhashtb)
7687 (gnus-sethash id threads thhashtb))
7688 (setq gthread (gnus-gethash gid thhashtb))
7690 ;; We enter a dummy root into the thread, if we
7691 ;; haven't done that already.
7692 (unless (stringp (caar gthread))
7693 (setcar gthread (list (mail-header-subject (caar gthread))
7695 ;; We add this new gathered thread to this gathered
7697 (setcdr (car gthread)
7698 (nconc (cdar gthread) (list (car threads)))))
7699 ;; Add it into the thread hash table.
7700 (gnus-sethash id gthread thhashtb)
7702 ;; Remove it from the list of threads.
7703 (setcdr prev (cdr threads))
7704 (setq threads prev))
7705 (setq ids (cdr ids))))
7707 (setq threads (cdr threads)))
7710 (defun gnus-sort-gathered-threads (threads)
7711 "Sort subtreads inside each gathered thread by article number."
7712 (let ((result threads))
7714 (when (stringp (caar threads))
7715 (setcdr (car threads)
7716 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7717 (setq threads (cdr threads)))
7720 (defun gnus-make-threads ()
7721 "Go through the dependency hashtb and find the roots. Return all threads."
7725 (unless (car (symbol-value refs))
7726 ;; These threads do not refer back to any other articles,
7727 ;; so they're roots.
7728 (setq threads (append (cdr (symbol-value refs)) threads))))
7729 gnus-newsgroup-dependencies)
7732 (defun gnus-build-sparse-threads ()
7733 (let ((headers gnus-newsgroup-headers)
7734 (deps gnus-newsgroup-dependencies)
7735 header references generation relations
7736 cthread subject child end pthread relation)
7737 ;; First we create an alist of generations/relations, where
7738 ;; generations is how much we trust the ralation, and the relation
7740 (gnus-message 7 "Making sparse threads...")
7742 (nnheader-set-temp-buffer " *gnus sparse threads*")
7743 (while (setq header (pop headers))
7744 (when (and (setq references (mail-header-references header))
7745 (not (string= references "")))
7747 (setq child (mail-header-id header)
7748 subject (mail-header-subject header))
7750 (while (search-backward ">" nil t)
7751 (setq end (1+ (point)))
7752 (when (search-backward "<" nil t)
7753 (push (list (incf generation)
7754 child (setq child (buffer-substring (point) end))
7757 (push (list (1+ generation) child nil subject) relations)
7759 (kill-buffer (current-buffer)))
7760 ;; Sort over trustworthiness.
7761 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7762 (while (setq relation (pop relations))
7763 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7764 (unless (car (symbol-value cthread))
7765 ;; Make this article the parent of these threads.
7766 (setcar (symbol-value cthread)
7767 (vector gnus-reffed-article-number
7771 (or (caddr relation) "") 0 0 "")))
7772 (set cthread (list (vector gnus-reffed-article-number
7774 "" "" (cadr relation)
7775 (or (caddr relation) "") 0 0 ""))))
7776 (push gnus-reffed-article-number gnus-newsgroup-limit)
7777 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7778 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7779 gnus-newsgroup-reads)
7780 (decf gnus-reffed-article-number)
7781 ;; Make this new thread the child of its parent.
7782 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7783 (setcdr (symbol-value pthread)
7784 (nconc (cdr (symbol-value pthread))
7785 (list (symbol-value cthread))))
7786 (set pthread (list nil (symbol-value cthread))))))
7787 (gnus-message 7 "Making sparse threads...done")))
7789 (defun gnus-build-old-threads ()
7790 ;; Look at all the articles that refer back to old articles, and
7791 ;; fetch the headers for the articles that aren't there. This will
7792 ;; build complete threads - if the roots haven't been expired by the
7797 (when (not (car (symbol-value refs)))
7798 (setq heads (cdr (symbol-value refs)))
7800 (if (memq (mail-header-number (caar heads))
7801 gnus-newsgroup-dormant)
7802 (setq heads (cdr heads))
7803 (setq id (symbol-name refs))
7804 (while (and (setq id (gnus-build-get-header id))
7805 (not (car (gnus-gethash
7806 id gnus-newsgroup-dependencies)))))
7807 (setq heads nil)))))
7808 gnus-newsgroup-dependencies)))
7810 (defun gnus-build-get-header (id)
7811 ;; Look through the buffer of NOV lines and find the header to
7812 ;; ID. Enter this line into the dependencies hash table, and return
7813 ;; the id of the parent article (if any).
7814 (let ((deps gnus-newsgroup-dependencies)
7818 (set-buffer nntp-server-buffer)
7819 (goto-char (point-min))
7820 (while (and (not found) (search-forward id nil t))
7822 (setq found (looking-at
7823 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7824 (regexp-quote id))))
7825 (or found (beginning-of-line 2)))
7829 (setq header (gnus-nov-parse-line
7830 (read (current-buffer)) deps))
7831 (gnus-parent-id (mail-header-references header)))))
7833 (let ((number (mail-header-number header)))
7834 (push number gnus-newsgroup-limit)
7835 (push header gnus-newsgroup-headers)
7836 (if (memq number gnus-newsgroup-unselected)
7838 (push number gnus-newsgroup-unreads)
7839 (setq gnus-newsgroup-unselected
7840 (delq number gnus-newsgroup-unselected)))
7841 (push number gnus-newsgroup-ancient)))))))
7843 (defun gnus-summary-update-article (article &optional header)
7844 "Update ARTICLE in the summary buffer."
7845 (set-buffer gnus-summary-buffer)
7846 (let* ((header (or header (gnus-summary-article-header article)))
7847 (id (mail-header-id header))
7848 (data (gnus-data-find article))
7849 (thread (gnus-id-to-thread id))
7851 (gnus-id-to-thread (or (gnus-parent-id
7852 (mail-header-references header))
7857 (delq thread parent))
7858 (when (gnus-summary-insert-subject id header)
7859 ;; Set the (possibly) new article number in the data structure.
7860 (gnus-data-set-number data (gnus-id-to-article id))))))
7862 (defun gnus-rebuild-thread (id)
7863 "Rebuild the thread containing ID."
7864 (let ((buffer-read-only nil)
7865 current thread data)
7866 (if (not gnus-show-threads)
7867 (setq thread (list (car (gnus-id-to-thread id))))
7868 ;; Get the thread this article is part of.
7869 (setq thread (gnus-remove-thread id)))
7870 (setq current (save-excursion
7871 (and (zerop (forward-line -1))
7872 (gnus-summary-article-number))))
7873 ;; If this is a gathered thread, we have to go some re-gathering.
7874 (when (stringp (car thread))
7875 (let ((subject (car thread))
7877 (setq thread (cdr thread))
7879 (unless (memq (setq thr (gnus-id-to-thread
7881 (mail-header-id (caar thread)))))
7884 (setq thread (cdr thread)))
7885 ;; We now have all (unique) roots.
7886 (if (= (length roots) 1)
7887 ;; All the loose roots are now one solid root.
7888 (setq thread (car roots))
7889 (setq thread (cons subject (gnus-sort-threads roots))))))
7891 ;; We then insert this thread into the summary buffer.
7892 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7893 (gnus-summary-prepare-threads (list thread))
7894 (setq data (nreverse gnus-newsgroup-data))
7895 (setq threads gnus-newsgroup-threads))
7896 ;; We splice the new data into the data structure.
7897 (gnus-data-enter-list current data)
7898 (gnus-data-compute-positions)
7899 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7901 (defun gnus-id-to-thread (id)
7902 "Return the (sub-)thread where ID appears."
7903 (gnus-gethash id gnus-newsgroup-dependencies))
7905 (defun gnus-id-to-article (id)
7906 "Return the article number of ID."
7907 (let ((thread (gnus-id-to-thread id)))
7909 (mail-header-number (car thread)))))
7911 (defun gnus-id-to-header (id)
7912 "Return the article headers of ID."
7913 (car (gnus-id-to-thread id)))
7915 (defun gnus-article-displayed-root-p (article)
7916 "Say whether ARTICLE is a root(ish) article."
7917 (let ((level (gnus-summary-thread-level article))
7923 (null (setq particle (gnus-id-to-article
7925 (mail-header-references
7926 (gnus-summary-article-header article))))))
7927 (null (gnus-summary-thread-level particle)))))))
7929 (defun gnus-root-id (id)
7930 "Return the id of the root of the thread where ID appears."
7932 (while (and id (setq prev (car (gnus-gethash
7933 id gnus-newsgroup-dependencies))))
7935 id (gnus-parent-id (mail-header-references prev))))
7938 (defun gnus-remove-thread (id &optional dont-remove)
7939 "Remove the thread that has ID in it."
7940 (let ((dep gnus-newsgroup-dependencies)
7941 headers thread last-id)
7942 ;; First go up in this thread until we find the root.
7943 (setq last-id (gnus-root-id id))
7944 (setq headers (list (car (gnus-id-to-thread last-id))
7945 (caadr (gnus-id-to-thread last-id))))
7946 ;; We have now found the real root of this thread. It might have
7947 ;; been gathered into some loose thread, so we have to search
7948 ;; through the threads to find the thread we wanted.
7949 (let ((threads gnus-newsgroup-threads)
7952 (setq sub (car threads))
7953 (if (stringp (car sub))
7954 ;; This is a gathered threads, so we look at the roots
7955 ;; below it to find whether this article in in this
7958 (setq sub (cdr sub))
7960 (when (member (caar sub) headers)
7961 (setq thread (car threads)
7964 (setq sub (cdr sub))))
7965 ;; It's an ordinary thread, so we check it.
7966 (when (eq (car sub) (car headers))
7969 (setq threads (cdr threads)))
7970 ;; If this article is in no thread, then it's a root.
7973 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7974 (setq thread (gnus-gethash last-id dep)))
7977 thread ; We return this thread.
7979 (if (stringp (car thread))
7981 ;; If we use dummy roots, then we have to remove the
7982 ;; dummy root as well.
7983 (when (eq gnus-summary-make-false-root 'dummy)
7986 (setq thread (cdr thread))
7988 (gnus-remove-thread-1 (car thread))
7989 (setq thread (cdr thread))))
7990 (gnus-remove-thread-1 thread))))))))
7992 (defun gnus-remove-thread-1 (thread)
7993 "Remove the thread THREAD recursively."
7994 (let ((number (mail-header-number (car thread)))
7996 (when (setq pos (text-property-any
7997 (point-min) (point-max) 'gnus-number number))
8000 (gnus-data-remove number))
8001 (setq thread (cdr thread))
8003 (gnus-remove-thread-1 (car thread))
8004 (setq thread (cdr thread)))))
8006 (defun gnus-sort-threads (threads)
8008 (if (not gnus-thread-sort-functions)
8010 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8011 (car gnus-thread-sort-functions)
8013 ,(gnus-make-sort-function
8014 (reverse gnus-thread-sort-functions))))))
8015 (gnus-message 7 "Sorting threads...")
8018 (gnus-message 7 "Sorting threads...done")))))
8020 (defun gnus-sort-articles (articles)
8022 (when gnus-article-sort-functions
8023 (let ((func (if (= 1 (length gnus-article-sort-functions))
8024 (car gnus-article-sort-functions)
8026 ,(gnus-make-sort-function
8027 (reverse gnus-article-sort-functions))))))
8028 (gnus-message 7 "Sorting articles...")
8030 (setq gnus-newsgroup-headers (sort articles func))
8031 (gnus-message 7 "Sorting articles...done")))))
8033 (defun gnus-make-sort-function (funs)
8034 "Return a composite sort condition based on the functions in FUNC."
8036 `(or (,(car funs) t1 t2)
8037 (and (not (,(car funs) t2 t1))
8038 ,(gnus-make-sort-function (cdr funs))))
8039 `(,(car funs) t1 t2)))
8041 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8042 (defmacro gnus-thread-header (thread)
8043 ;; Return header of first article in THREAD.
8044 ;; Note that THREAD must never, ever be anything else than a variable -
8045 ;; using some other form will lead to serious barfage.
8046 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8047 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8048 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8051 (defsubst gnus-article-sort-by-number (h1 h2)
8052 "Sort articles by article number."
8053 (< (mail-header-number h1)
8054 (mail-header-number h2)))
8056 (defun gnus-thread-sort-by-number (h1 h2)
8057 "Sort threads by root article number."
8058 (gnus-article-sort-by-number
8059 (gnus-thread-header h1) (gnus-thread-header h2)))
8061 (defsubst gnus-article-sort-by-author (h1 h2)
8062 "Sort articles by root author."
8064 (let ((extract (funcall
8065 gnus-extract-address-components
8066 (mail-header-from h1))))
8067 (or (car extract) (cdr extract)))
8068 (let ((extract (funcall
8069 gnus-extract-address-components
8070 (mail-header-from h2))))
8071 (or (car extract) (cdr extract)))))
8073 (defun gnus-thread-sort-by-author (h1 h2)
8074 "Sort threads by root author."
8075 (gnus-article-sort-by-author
8076 (gnus-thread-header h1) (gnus-thread-header h2)))
8078 (defsubst gnus-article-sort-by-subject (h1 h2)
8079 "Sort articles by root subject."
8081 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8082 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8084 (defun gnus-thread-sort-by-subject (h1 h2)
8085 "Sort threads by root subject."
8086 (gnus-article-sort-by-subject
8087 (gnus-thread-header h1) (gnus-thread-header h2)))
8089 (defsubst gnus-article-sort-by-date (h1 h2)
8090 "Sort articles by root article date."
8092 (gnus-sortable-date (mail-header-date h1))
8093 (gnus-sortable-date (mail-header-date h2))))
8095 (defun gnus-thread-sort-by-date (h1 h2)
8096 "Sort threads by root article date."
8097 (gnus-article-sort-by-date
8098 (gnus-thread-header h1) (gnus-thread-header h2)))
8100 (defsubst gnus-article-sort-by-score (h1 h2)
8101 "Sort articles by root article score.
8102 Unscored articles will be counted as having a score of zero."
8103 (> (or (cdr (assq (mail-header-number h1)
8104 gnus-newsgroup-scored))
8105 gnus-summary-default-score 0)
8106 (or (cdr (assq (mail-header-number h2)
8107 gnus-newsgroup-scored))
8108 gnus-summary-default-score 0)))
8110 (defun gnus-thread-sort-by-score (h1 h2)
8111 "Sort threads by root article score."
8112 (gnus-article-sort-by-score
8113 (gnus-thread-header h1) (gnus-thread-header h2)))
8115 (defun gnus-thread-sort-by-total-score (h1 h2)
8116 "Sort threads by the sum of all scores in the thread.
8117 Unscored articles will be counted as having a score of zero."
8118 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8120 (defun gnus-thread-total-score (thread)
8121 ;; This function find the total score of THREAD.
8123 (if (stringp (car thread))
8124 (apply gnus-thread-score-function 0
8125 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8126 (gnus-thread-total-score-1 thread))
8127 (gnus-thread-total-score-1 (list thread))))
8129 (defun gnus-thread-total-score-1 (root)
8130 ;; This function find the total score of the thread below ROOT.
8131 (setq root (car root))
8132 (apply gnus-thread-score-function
8133 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8134 gnus-summary-default-score 0)
8135 (mapcar 'gnus-thread-total-score
8136 (cdr (gnus-gethash (mail-header-id root)
8137 gnus-newsgroup-dependencies)))))
8139 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8140 (defvar gnus-tmp-prev-subject nil)
8141 (defvar gnus-tmp-false-parent nil)
8142 (defvar gnus-tmp-root-expunged nil)
8143 (defvar gnus-tmp-dummy-line nil)
8145 (defun gnus-summary-prepare-threads (threads)
8146 "Prepare summary buffer from THREADS and indentation LEVEL.
8147 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8148 or a straight list of headers."
8149 (gnus-message 7 "Generating summary...")
8151 (setq gnus-newsgroup-threads threads)
8154 (let ((gnus-tmp-level 0)
8155 (default-score (or gnus-summary-default-score 0))
8156 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8157 thread number subject stack state gnus-tmp-gathered beg-match
8158 new-roots gnus-tmp-new-adopts thread-end
8159 gnus-tmp-header gnus-tmp-unread
8160 gnus-tmp-replied gnus-tmp-subject-or-nil
8161 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8162 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8163 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8165 (setq gnus-tmp-prev-subject nil)
8167 (if (vectorp (car threads))
8168 ;; If this is a straight (sic) list of headers, then a
8169 ;; threaded summary display isn't required, so we just create
8170 ;; an unthreaded one.
8171 (gnus-summary-prepare-unthreaded threads)
8173 ;; Do the threaded display.
8175 (while (or threads stack gnus-tmp-new-adopts new-roots)
8177 (if (and (= gnus-tmp-level 0)
8178 (not (setq gnus-tmp-dummy-line nil))
8181 (not gnus-tmp-false-parent)
8182 (or gnus-tmp-new-adopts new-roots))
8183 (if gnus-tmp-new-adopts
8184 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8185 thread (list (car gnus-tmp-new-adopts))
8186 gnus-tmp-header (caar thread)
8187 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8189 (setq thread (list (car new-roots))
8190 gnus-tmp-header (caar thread)
8191 new-roots (cdr new-roots))))
8194 ;; If there are some threads, we do them before the
8195 ;; threads on the stack.
8196 (setq thread threads
8197 gnus-tmp-header (caar thread))
8198 ;; There were no current threads, so we pop something off
8200 (setq state (car stack)
8201 gnus-tmp-level (car state)
8204 gnus-tmp-header (caar thread))))
8206 (setq gnus-tmp-false-parent nil)
8207 (setq gnus-tmp-root-expunged nil)
8208 (setq thread-end nil)
8210 (if (stringp gnus-tmp-header)
8211 ;; The header is a dummy root.
8213 ((eq gnus-summary-make-false-root 'adopt)
8214 ;; We let the first article adopt the rest.
8215 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8217 (setq gnus-tmp-gathered
8219 (lambda (h) (mail-header-number (car h)))
8222 (setq thread (cons (list (caar thread)
8225 (setq gnus-tmp-level -1
8226 gnus-tmp-false-parent t))
8227 ((eq gnus-summary-make-false-root 'empty)
8228 ;; We print adopted articles with empty subject fields.
8229 (setq gnus-tmp-gathered
8231 (lambda (h) (mail-header-number (car h)))
8234 (setq gnus-tmp-level -1))
8235 ((eq gnus-summary-make-false-root 'dummy)
8236 ;; We remember that we probably want to output a dummy
8238 (setq gnus-tmp-dummy-line gnus-tmp-header)
8239 (setq gnus-tmp-prev-subject gnus-tmp-header))
8241 ;; We do not make a root for the gathered
8242 ;; sub-threads at all.
8243 (setq gnus-tmp-level -1)))
8245 (setq number (mail-header-number gnus-tmp-header)
8246 subject (mail-header-subject gnus-tmp-header))
8249 ;; If the thread has changed subject, we might want to make
8250 ;; this subthread into a root.
8251 ((and (null gnus-thread-ignore-subject)
8252 (not (zerop gnus-tmp-level))
8253 gnus-tmp-prev-subject
8255 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8256 (setq new-roots (nconc new-roots (list (car thread)))
8258 gnus-tmp-header nil))
8259 ;; If the article lies outside the current limit,
8260 ;; then we do not display it.
8261 ((and (not (memq number gnus-newsgroup-limit))
8262 (not gnus-tmp-dummy-line))
8263 (setq gnus-tmp-gathered
8265 (lambda (h) (mail-header-number (car h)))
8268 (setq gnus-tmp-new-adopts (if (cdar thread)
8269 (append gnus-tmp-new-adopts
8271 gnus-tmp-new-adopts)
8273 gnus-tmp-header nil)
8274 (when (zerop gnus-tmp-level)
8275 (setq gnus-tmp-root-expunged t)))
8276 ;; Perhaps this article is to be marked as read?
8277 ((and gnus-summary-mark-below
8278 (< (or (cdr (assq number gnus-newsgroup-scored))
8280 gnus-summary-mark-below)
8281 ;; Don't touch sparse articles.
8282 (not (memq number gnus-newsgroup-sparse)))
8283 (setq gnus-newsgroup-unreads
8284 (delq number gnus-newsgroup-unreads))
8285 (if gnus-newsgroup-auto-expire
8286 (push number gnus-newsgroup-expirable)
8287 (push (cons number gnus-low-score-mark)
8288 gnus-newsgroup-reads))))
8290 (when gnus-tmp-header
8291 ;; We may have an old dummy line to output before this
8293 (when gnus-tmp-dummy-line
8294 (gnus-summary-insert-dummy-line
8295 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8296 (setq gnus-tmp-dummy-line nil))
8298 ;; Compute the mark.
8302 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8303 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8304 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8305 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8306 (t (or (cdr (assq number gnus-newsgroup-reads))
8307 gnus-ancient-mark))))
8309 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8310 gnus-tmp-header gnus-tmp-level)
8311 gnus-newsgroup-data)
8313 ;; Actually insert the line.
8315 gnus-tmp-subject-or-nil
8317 ((and gnus-thread-ignore-subject
8318 gnus-tmp-prev-subject
8319 (not (inline (gnus-subject-equal
8320 gnus-tmp-prev-subject subject))))
8322 ((zerop gnus-tmp-level)
8323 (if (and (eq gnus-summary-make-false-root 'empty)
8324 (memq number gnus-tmp-gathered)
8325 gnus-tmp-prev-subject
8326 (inline (gnus-subject-equal
8327 gnus-tmp-prev-subject subject)))
8328 gnus-summary-same-subject
8330 (t gnus-summary-same-subject)))
8331 (if (and (eq gnus-summary-make-false-root 'adopt)
8332 (= gnus-tmp-level 1)
8333 (memq number gnus-tmp-gathered))
8334 (setq gnus-tmp-opening-bracket ?\<
8335 gnus-tmp-closing-bracket ?\>)
8336 (setq gnus-tmp-opening-bracket ?\[
8337 gnus-tmp-closing-bracket ?\]))
8339 gnus-tmp-indentation
8340 (aref gnus-thread-indent-array gnus-tmp-level)
8341 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8342 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8343 gnus-summary-default-score 0)
8345 (if (or (null gnus-summary-default-score)
8346 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8347 gnus-summary-zcore-fuzz)) ?
8348 (if (< gnus-tmp-score gnus-summary-default-score)
8349 gnus-score-below-mark gnus-score-over-mark))
8351 (cond ((memq number gnus-newsgroup-processable)
8353 ((memq number gnus-newsgroup-cached)
8355 ((memq number gnus-newsgroup-replied)
8357 (t gnus-unread-mark))
8358 gnus-tmp-from (mail-header-from gnus-tmp-header)
8361 ((string-match "(.+)" gnus-tmp-from)
8362 (substring gnus-tmp-from
8363 (1+ (match-beginning 0)) (1- (match-end 0))))
8364 ((string-match "<[^>]+> *$" gnus-tmp-from)
8365 (setq beg-match (match-beginning 0))
8366 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8367 (substring gnus-tmp-from (1+ (match-beginning 0))
8368 (1- (match-end 0))))
8369 (substring gnus-tmp-from 0 beg-match)))
8371 (when (string= gnus-tmp-name "")
8372 (setq gnus-tmp-name gnus-tmp-from))
8373 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8376 (progn (eval gnus-summary-line-format-spec) (point))
8377 'gnus-number number)
8380 (run-hooks 'gnus-summary-update-hook)
8383 (setq gnus-tmp-prev-subject subject)))
8385 (when (nth 1 thread)
8386 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8387 (incf gnus-tmp-level)
8388 (setq threads (if thread-end nil (cdar thread)))
8390 (setq gnus-tmp-level 0)))))
8391 (gnus-message 7 "Generating summary...done"))
8393 (defun gnus-summary-prepare-unthreaded (headers)
8394 "Generate an unthreaded summary buffer based on HEADERS."
8395 (let (header number mark)
8398 (setq header (car headers)
8399 headers (cdr headers)
8400 number (mail-header-number header))
8402 ;; We may have to root out some bad articles...
8403 (when (memq number gnus-newsgroup-limit)
8404 (when (and gnus-summary-mark-below
8405 (< (or (cdr (assq number gnus-newsgroup-scored))
8406 gnus-summary-default-score 0)
8407 gnus-summary-mark-below))
8408 (setq gnus-newsgroup-unreads
8409 (delq number gnus-newsgroup-unreads))
8410 (if gnus-newsgroup-auto-expire
8411 (push number gnus-newsgroup-expirable)
8412 (push (cons number gnus-low-score-mark)
8413 gnus-newsgroup-reads)))
8417 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8418 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8419 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8420 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8421 (t (or (cdr (assq number gnus-newsgroup-reads))
8422 gnus-ancient-mark))))
8423 (setq gnus-newsgroup-data
8424 (cons (gnus-data-make number mark (1+ (point)) header 0)
8425 gnus-newsgroup-data))
8426 (gnus-summary-insert-line
8427 header 0 nil mark (memq number gnus-newsgroup-replied)
8428 (memq number gnus-newsgroup-expirable)
8429 (mail-header-subject header) nil
8430 (cdr (assq number gnus-newsgroup-scored))
8431 (memq number gnus-newsgroup-processable))))))
8433 (defun gnus-select-newsgroup (group &optional read-all)
8434 "Select newsgroup GROUP.
8435 If READ-ALL is non-nil, all articles in the group are selected."
8436 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8437 (info (nth 2 entry))
8438 articles fetched-articles cached)
8440 (or (gnus-check-server
8441 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8442 (error "Couldn't open server"))
8444 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8445 (gnus-activate-group group) ; Or we can activate it...
8446 (progn ; Or we bug out.
8447 (when (equal major-mode 'gnus-summary-mode)
8448 (kill-buffer (current-buffer)))
8449 (error "Couldn't request group %s: %s"
8450 group (gnus-status-message group))))
8452 (setq gnus-newsgroup-name group)
8453 (setq gnus-newsgroup-unselected nil)
8454 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8456 (and gnus-asynchronous
8457 (gnus-check-backend-function
8458 'request-asynchronous gnus-newsgroup-name)
8459 (setq gnus-newsgroup-async
8460 (gnus-request-asynchronous gnus-newsgroup-name)))
8462 ;; Adjust and set lists of article marks.
8464 (gnus-adjust-marked-articles info))
8466 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8467 (when (gnus-virtual-group-p group)
8468 (setq cached gnus-newsgroup-cached))
8470 (setq gnus-newsgroup-unreads
8471 (gnus-set-difference
8472 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8473 gnus-newsgroup-dormant))
8475 (setq gnus-newsgroup-processable nil)
8477 (setq articles (gnus-articles-to-read group read-all))
8481 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8483 ((eq articles 0) nil)
8485 ;; Init the dependencies hash table.
8486 (setq gnus-newsgroup-dependencies
8487 (gnus-make-hashtable (length articles)))
8488 ;; Retrieve the headers and read them in.
8489 (gnus-message 5 "Fetching headers...")
8490 (setq gnus-newsgroup-headers
8492 (setq gnus-headers-retrieved-by
8493 (gnus-retrieve-headers
8494 articles gnus-newsgroup-name
8495 ;; We might want to fetch old headers, but
8496 ;; not if there is only 1 article.
8497 (and gnus-fetch-old-headers
8499 (not (eq gnus-fetch-old-headers 'some))
8500 (not (numberp gnus-fetch-old-headers)))
8501 (> (length articles) 1))))))
8502 (gnus-get-newsgroup-headers-xover articles)
8503 (gnus-get-newsgroup-headers)))
8504 (gnus-message 5 "Fetching headers...done")
8506 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8508 (setq gnus-newsgroup-cached cached))
8510 ;; Set the initial limit.
8511 (setq gnus-newsgroup-limit (copy-sequence articles))
8512 ;; Remove canceled articles from the list of unread articles.
8513 (setq gnus-newsgroup-unreads
8514 (gnus-set-sorted-intersection
8515 gnus-newsgroup-unreads
8516 (setq fetched-articles
8517 (mapcar (lambda (headers) (mail-header-number headers))
8518 gnus-newsgroup-headers))))
8519 ;; Removed marked articles that do not exist.
8520 (gnus-update-missing-marks
8521 (gnus-sorted-complement fetched-articles articles))
8522 ;; We might want to build some more threads first.
8523 (and gnus-fetch-old-headers
8524 (eq gnus-headers-retrieved-by 'nov)
8525 (gnus-build-old-threads))
8526 ;; Check whether auto-expire is to be done in this group.
8527 (setq gnus-newsgroup-auto-expire
8528 (gnus-group-auto-expirable-p group))
8529 ;; Set up the article buffer now, if necessary.
8530 (unless gnus-single-article-buffer
8531 (gnus-article-setup-buffer))
8532 ;; First and last article in this newsgroup.
8533 (and gnus-newsgroup-headers
8534 (setq gnus-newsgroup-begin
8535 (mail-header-number (car gnus-newsgroup-headers)))
8536 (setq gnus-newsgroup-end
8538 (gnus-last-element gnus-newsgroup-headers))))
8539 (setq gnus-reffed-article-number -1)
8540 ;; GROUP is successfully selected.
8541 (or gnus-newsgroup-headers t)))))
8543 (defun gnus-articles-to-read (group read-all)
8544 ;; Find out what articles the user wants to read.
8546 ;; Select all articles if `read-all' is non-nil, or if there
8547 ;; are no unread articles.
8549 (and (zerop (length gnus-newsgroup-marked))
8550 (zerop (length gnus-newsgroup-unreads))))
8551 (gnus-uncompress-range (gnus-active group))
8552 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8553 (copy-sequence gnus-newsgroup-unreads))
8555 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8556 (scored (length scored-list))
8557 (number (length articles))
8558 (marked (+ (length gnus-newsgroup-marked)
8559 (length gnus-newsgroup-dormant)))
8567 ((and (or (<= scored marked) (= scored number))
8568 (numberp gnus-large-newsgroup)
8569 (> number gnus-large-newsgroup))
8573 "How many articles from %s (default %d): "
8574 gnus-newsgroup-name number))))
8575 (if (string-match "^[ \t]*$" input) number input)))
8576 ((and (> scored marked) (< scored number))
8579 (format "%s %s (%d scored, %d total): "
8580 "How many articles from"
8581 group scored number))))
8582 (if (string-match "^[ \t]*$" input)
8586 (setq select (if (stringp select) (string-to-number select) select))
8587 (if (or (null select) (zerop select))
8589 (if (and (not (zerop scored)) (<= (abs select) scored))
8591 (setq articles (sort scored-list '<))
8592 (setq number (length articles)))
8593 (setq articles (copy-sequence articles)))
8595 (if (< (abs select) number)
8597 ;; Select the N oldest articles.
8598 (setcdr (nthcdr (1- (abs select)) articles) nil)
8599 ;; Select the N most recent articles.
8600 (setq articles (nthcdr (- number select) articles))))
8601 (setq gnus-newsgroup-unselected
8602 (gnus-sorted-intersection
8603 gnus-newsgroup-unreads
8604 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8607 (defun gnus-killed-articles (killed articles)
8610 (if (inline (gnus-member-of-range (car articles) killed))
8611 (setq out (cons (car articles) out)))
8612 (setq articles (cdr articles)))
8615 (defun gnus-uncompress-marks (marks)
8616 "Uncompress the mark ranges in MARKS."
8617 (let ((uncompressed '(score bookmark))
8620 (if (memq (caar marks) uncompressed)
8621 (push (car marks) out)
8622 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8623 (setq marks (cdr marks)))
8626 (defun gnus-adjust-marked-articles (info)
8627 "Set all article lists and remove all marks that are no longer legal."
8628 (let* ((marked-lists (gnus-info-marks info))
8629 (active (gnus-active (gnus-info-group info)))
8632 (types gnus-article-mark-lists)
8633 (uncompressed '(score bookmark))
8634 marks var articles article mark)
8637 (setq marks (pop marked-lists))
8638 (set (setq var (intern (format "gnus-newsgroup-%s"
8639 (car (rassq (setq mark (car marks))
8641 (if (memq (car marks) uncompressed) (cdr marks)
8642 (gnus-uncompress-range (cdr marks))))
8644 (setq articles (symbol-value var))
8646 ;; All articles have to be subsets of the active articles.
8648 ;; Adjust "simple" lists.
8649 ((memq mark '(tick dormant expirable reply killed save))
8651 (when (or (< (setq article (pop articles)) min) (> article max))
8652 (set var (delq article (symbol-value var))))))
8654 ((memq mark '(score bookmark))
8656 (when (or (< (car (setq article (pop articles))) min)
8657 (> (car article) max))
8658 (set var (delq article (symbol-value var))))))))))
8660 (defun gnus-update-missing-marks (missing)
8661 "Go through the list of MISSING articles and remove them mark lists."
8663 (let ((types gnus-article-mark-lists)
8665 ;; Go through all types.
8667 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8668 (when (symbol-value var)
8669 ;; This list has articles. So we delete all missing articles
8673 (set var (delq (pop m) (symbol-value var)))))))))
8675 (defun gnus-update-marks ()
8676 "Enter the various lists of marked articles into the newsgroup info list."
8677 (let ((types gnus-article-mark-lists)
8678 (info (gnus-get-info gnus-newsgroup-name))
8679 (uncompressed '(score bookmark killed))
8680 type list newmarked symbol)
8682 ;; Add all marks lists that are non-nil to the list of marks lists.
8684 (setq type (pop types))
8685 (when (setq list (symbol-value
8687 (intern (format "gnus-newsgroup-%s"
8689 (push (cons (cdr type)
8690 (if (memq (cdr type) uncompressed) list
8691 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8694 ;; Enter these new marks into the info of the group.
8696 (setcar (nthcdr 3 info) newmarked)
8697 ;; Add the marks lists to the end of the info.
8699 (setcdr (nthcdr 2 info) (list newmarked))))
8701 ;; Cut off the end of the info if there's nothing else there.
8705 (when (nthcdr (decf i) info)
8706 (setcdr (nthcdr i info) nil)))))))
8708 (defun gnus-add-marked-articles (group type articles &optional info force)
8709 ;; Add ARTICLES of TYPE to the info of GROUP.
8710 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8711 ;; add, but replace marked articles of TYPE with ARTICLES.
8712 (let ((info (or info (gnus-get-info group)))
8713 (uncompressed '(score bookmark killed))
8716 (and (not (setq marked (nthcdr 3 info)))
8718 (setcdr (nthcdr 2 info)
8719 (list (list (cons type (gnus-compress-sequence
8721 (and (not (setq m (assq type (car marked))))
8724 (cons (cons type (gnus-compress-sequence articles t) )
8728 (setcar (nthcdr 3 info)
8729 (delq (assq type (car marked)) (car marked)))
8730 (setcdr m (gnus-compress-sequence articles t)))
8731 (setcdr m (gnus-compress-sequence
8732 (sort (nconc (gnus-uncompress-range m)
8733 (copy-sequence articles)) '<) t))))))
8735 (defun gnus-set-mode-line (where)
8736 "This function sets the mode line of the article or summary buffers.
8737 If WHERE is `summary', the summary mode line format will be used."
8738 ;; Is this mode line one we keep updated?
8739 (when (memq where gnus-updated-mode-lines)
8742 ;; We evaluate this in the summary buffer since these
8743 ;; variables are buffer-local to that buffer.
8744 (set-buffer gnus-summary-buffer)
8745 ;; We bind all these variables that are used in the `eval' form
8747 (let* ((mformat (symbol-value
8749 (format "gnus-%s-mode-line-format-spec" where))))
8750 (gnus-tmp-group-name gnus-newsgroup-name)
8751 (gnus-tmp-article-number (or gnus-current-article 0))
8752 (gnus-tmp-unread gnus-newsgroup-unreads)
8753 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8754 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8755 (gnus-tmp-unread-and-unselected
8756 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8757 (zerop gnus-tmp-unselected)) "")
8758 ((zerop gnus-tmp-unselected)
8759 (format "{%d more}" gnus-tmp-unread-and-unticked))
8760 (t (format "{%d(+%d) more}"
8761 gnus-tmp-unread-and-unticked
8762 gnus-tmp-unselected))))
8764 (if (and gnus-current-headers
8765 (vectorp gnus-current-headers))
8766 (mail-header-subject gnus-current-headers) ""))
8768 gnus-tmp-header);; passed as argument to any user-format-funcs
8769 (setq mode-string (eval mformat))
8770 (setq max-len (max 4 (if gnus-mode-non-string-length
8772 gnus-mode-non-string-length)
8773 (length mode-string))))
8774 ;; We might have to chop a bit of the string off...
8775 (when (> (length mode-string) max-len)
8777 (concat (gnus-truncate-string mode-string (- max-len 3))
8779 ;; Pad the mode string a bit.
8780 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8781 ;; Update the mode line.
8782 (setq mode-line-buffer-identification (list mode-string))
8783 (set-buffer-modified-p t))))
8785 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8786 "Go through the HEADERS list and add all Xrefs to a hash table.
8787 The resulting hash table is returned, or nil if no Xrefs were found."
8788 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8789 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8790 (xref-hashtb (make-vector 63 0))
8791 start group entry number xrefs header)
8793 (setq header (pop headers))
8794 (when (and (setq xrefs (mail-header-xref header))
8795 (not (memq (setq number (mail-header-number header))
8798 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8799 (setq start (match-end 0))
8800 (setq group (concat prefix (substring xrefs (match-beginning 1)
8803 (string-to-int (substring xrefs (match-beginning 2)
8805 (if (setq entry (gnus-gethash group xref-hashtb))
8806 (setcdr entry (cons number (cdr entry)))
8807 (gnus-sethash group (cons number nil) xref-hashtb)))))
8808 (and start xref-hashtb)))
8810 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8811 "Look through all the headers and mark the Xrefs as read."
8812 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8813 name entry info xref-hashtb idlist method nth4)
8815 (set-buffer gnus-group-buffer)
8816 (when (setq xref-hashtb
8817 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8820 (unless (string= from-newsgroup (setq name (symbol-name group)))
8821 (setq idlist (symbol-value group))
8822 ;; Dead groups are not updated.
8824 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8826 (if (stringp (setq nth4 (gnus-info-method info)))
8827 (setq nth4 (gnus-server-to-method nth4))))
8828 ;; Only do the xrefs if the group has the same
8829 ;; select method as the group we have just read.
8830 (or (gnus-methods-equal-p
8831 nth4 (gnus-find-method-for-group from-newsgroup))
8833 (equal nth4 (setq method (gnus-find-method-for-group
8835 (and (equal (car nth4) (car method))
8836 (equal (nth 1 nth4) (nth 1 method))))
8837 gnus-use-cross-reference
8838 (or (not (eq gnus-use-cross-reference t))
8840 ;; Only do cross-references on subscribed
8841 ;; groups, if that is what is wanted.
8842 (<= (gnus-info-level info) gnus-level-subscribed))
8843 (gnus-group-make-articles-read name idlist))))
8846 (defun gnus-group-make-articles-read (group articles)
8848 (entry (gnus-gethash group gnus-newsrc-hashtb))
8849 (info (nth 2 entry))
8850 (active (gnus-active group))
8852 ;; First peel off all illegal article numbers.
8854 (let ((ids articles)
8858 (if (and first (> id (cdr active)))
8860 ;; We'll end up in this situation in one particular
8861 ;; obscure situation. If you re-scan a group and get
8862 ;; a new article that is cross-posted to a different
8863 ;; group that has not been re-scanned, you might get
8864 ;; crossposted article that has a higher number than
8865 ;; Gnus believes possible. So we re-activate this
8866 ;; group as well. This might mean doing the
8867 ;; crossposting thingy will *increase* the number
8868 ;; of articles in some groups. Tsk, tsk.
8869 (setq active (or (gnus-activate-group group) active))))
8870 (if (or (> id (cdr active))
8871 (< id (car active)))
8872 (setq articles (delq id articles)))
8873 (setq ids (cdr ids)))))
8874 ;; If the read list is nil, we init it.
8876 (null (gnus-info-read info))
8878 (gnus-info-set-read info (cons 1 (1- (car active)))))
8879 ;; Then we add the read articles to the range.
8884 (gnus-info-read info) (setq articles (sort articles '<)))))
8885 ;; Then we have to re-compute how many unread
8886 ;; articles there are in this group.
8891 (setq num (- (1+ (cdr active)) (car active))))
8892 ((not (listp (cdr range)))
8893 (setq num (- (cdr active) (- (1+ (cdr range))
8897 (if (numberp (car range))
8899 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8900 (setq range (cdr range)))
8901 (setq num (- (cdr active) num))))
8902 ;; Update the number of unread articles.
8904 ;; Update the group buffer.
8905 (gnus-group-update-group group t)))))
8907 (defun gnus-methods-equal-p (m1 m2)
8908 (let ((m1 (or m1 gnus-select-method))
8909 (m2 (or m2 gnus-select-method)))
8911 (and (eq (car m1) (car m2))
8912 (or (not (memq 'address (assoc (symbol-name (car m1))
8913 gnus-valid-select-methods)))
8914 (equal (nth 1 m1) (nth 1 m2)))))))
8916 (defsubst gnus-header-value ()
8917 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8919 (defvar gnus-newsgroup-none-id 0)
8921 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8922 (let ((cur nntp-server-buffer)
8925 (save-excursion (set-buffer gnus-summary-buffer)
8926 gnus-newsgroup-dependencies)))
8927 headers id id-dep ref-dep end ref)
8929 (set-buffer nntp-server-buffer)
8930 (let ((case-fold-search t)
8931 in-reply-to header p lines)
8932 (goto-char (point-min))
8933 ;; Search to the beginning of the next header. Error messages
8934 ;; do not begin with 2 or 3.
8935 (while (re-search-forward "^[23][0-9]+ " nil t)
8938 ;; This implementation of this function, with nine
8939 ;; search-forwards instead of the one re-search-forward and
8940 ;; a case (which basically was the old function) is actually
8941 ;; about twice as fast, even though it looks messier. You
8942 ;; can't have everything, I guess. Speed and elegance
8943 ;; doesn't always go hand in hand.
8952 (narrow-to-region (point)
8953 (or (and (search-forward "\n.\n" nil t)
8959 (if (search-forward "\nsubject: " nil t)
8960 (gnus-header-value) "(none)"))
8964 (if (search-forward "\nfrom: " nil t)
8965 (gnus-header-value) "(nobody)"))
8969 (if (search-forward "\ndate: " nil t)
8970 (gnus-header-value) ""))
8974 (if (search-forward "\nmessage-id: " nil t)
8975 (setq id (gnus-header-value))
8976 ;; If there was no message-id, we just fake one to make
8977 ;; subsequent routines simpler.
8978 (setq id (concat "none+"
8980 (setq gnus-newsgroup-none-id
8981 (1+ gnus-newsgroup-none-id)))))))
8985 (if (search-forward "\nreferences: " nil t)
8988 (setq end (match-end 0))
8994 (search-backward ">" end t)
8997 (search-backward "<" end t)
8999 ;; Get the references from the in-reply-to header if there
9000 ;; were no references and the in-reply-to header looks
9002 (if (and (search-forward "\nin-reply-to: " nil t)
9003 (setq in-reply-to (gnus-header-value))
9004 (string-match "<[^>]+>" in-reply-to))
9006 (setq ref (substring in-reply-to (match-beginning 0)
9015 (if (search-forward "\nlines: " nil t)
9016 (if (numberp (setq lines (read cur)))
9022 (and (search-forward "\nxref: " nil t)
9023 (gnus-header-value)))))
9024 ;; We do the threading while we read the headers. The
9025 ;; message-id and the last reference are both entered into
9026 ;; the same hash table. Some tippy-toeing around has to be
9027 ;; done in case an article has arrived before the article
9028 ;; which it refers to.
9029 (if (boundp (setq id-dep (intern id dependencies)))
9030 (if (and (car (symbol-value id-dep))
9032 ;; An article with this Message-ID has already
9033 ;; been seen, so we ignore this one, except we add
9034 ;; any additional Xrefs (in case the two articles
9035 ;; came from different servers).
9037 (mail-header-set-xref
9038 (car (symbol-value id-dep))
9039 (concat (or (mail-header-xref
9040 (car (symbol-value id-dep))) "")
9041 (or (mail-header-xref header) "")))
9043 (setcar (symbol-value id-dep) header))
9044 (set id-dep (list header)))
9046 (if (boundp (setq ref-dep (intern ref dependencies)))
9047 (setcdr (symbol-value ref-dep)
9048 (nconc (cdr (symbol-value ref-dep))
9049 (list (symbol-value id-dep))))
9050 (set ref-dep (list nil (symbol-value id-dep))))
9051 (setq headers (cons header headers)))
9052 (goto-char (point-max))
9054 (nreverse headers)))))
9056 ;; The following macros and functions were written by Felix Lee
9057 ;; <flee@cse.psu.edu>.
9059 (defmacro gnus-nov-read-integer ()
9061 (if (= (following-char) ?\t)
9063 (let ((num (condition-case nil (read buffer) (error nil))))
9064 (if (numberp num) num 0)))
9065 (or (eobp) (forward-char 1))))
9067 (defmacro gnus-nov-skip-field ()
9068 '(search-forward "\t" eol 'move))
9070 (defmacro gnus-nov-field ()
9071 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9073 ;; Goes through the xover lines and returns a list of vectors
9074 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9075 "Parse the news overview data in the server buffer, and return a
9076 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9077 ;; Get the Xref when the users reads the articles since most/some
9078 ;; NNTP servers do not include Xrefs when using XOVER.
9079 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9080 (let ((cur nntp-server-buffer)
9081 (dependencies gnus-newsgroup-dependencies)
9082 number headers header)
9084 (set-buffer nntp-server-buffer)
9085 ;; Allow the user to mangle the headers before parsing them.
9086 (run-hooks 'gnus-parse-headers-hook)
9087 ;; Allow the user to mangle the headers before parsing them.
9088 (run-hooks 'gnus-parse-headers-hook)
9089 (goto-char (point-min))
9090 (while (and sequence (not (eobp)))
9091 (setq number (read cur))
9092 (while (and sequence (< (car sequence) number))
9093 (setq sequence (cdr sequence)))
9095 (eq number (car sequence))
9097 (setq sequence (cdr sequence))
9099 (inline (gnus-nov-parse-line
9100 number dependencies force-new)))
9101 (setq headers (cons header headers)))))
9103 (setq headers (nreverse headers)))
9106 ;; This function has to be called with point after the article number
9107 ;; on the beginning of the line.
9108 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9110 (eol (gnus-point-at-eol))
9111 (buffer (current-buffer))
9112 header ref id id-dep ref-dep)
9114 ;; overview: [num subject from date id refs chars lines misc]
9115 (narrow-to-region (point) eol)
9116 (or (eobp) (forward-char))
9122 (gnus-nov-field) ; subject
9123 (gnus-nov-field) ; from
9124 (gnus-nov-field) ; date
9125 (setq id (or (gnus-nov-field)
9128 (setq none (1+ none)))))) ; id
9131 (let ((beg (point)))
9132 (search-forward "\t" eol)
9133 (if (search-backward ">" beg t)
9137 (search-backward "<" beg t)))
9139 (gnus-nov-field)) ; refs
9140 (gnus-nov-read-integer) ; chars
9141 (gnus-nov-read-integer) ; lines
9142 (if (= (following-char) ?\n)
9144 (gnus-nov-field)) ; misc
9148 (gnus-message 4 "Strange nov line")
9154 ;; We build the thread tree.
9156 (if (boundp (setq id-dep (intern id dependencies)))
9157 (if (and (car (symbol-value id-dep))
9159 ;; An article with this Message-ID has already been seen,
9160 ;; so we ignore this one, except we add any additional
9161 ;; Xrefs (in case the two articles came from different
9164 (mail-header-set-xref
9165 (car (symbol-value id-dep))
9166 (concat (or (mail-header-xref
9167 (car (symbol-value id-dep))) "")
9168 (or (mail-header-xref header) "")))
9170 (setcar (symbol-value id-dep) header))
9171 (set id-dep (list header))))
9174 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9175 (setcdr (symbol-value ref-dep)
9176 (nconc (cdr (symbol-value ref-dep))
9177 (list (symbol-value id-dep))))
9178 (set ref-dep (list nil (symbol-value id-dep))))))
9181 (defun gnus-article-get-xrefs ()
9182 "Fill in the Xref value in `gnus-current-headers', if necessary.
9183 This is meant to be called in `gnus-article-internal-prepare-hook'."
9184 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9185 gnus-current-headers)))
9186 (or (not gnus-use-cross-reference)
9188 (and (mail-header-xref headers)
9189 (not (string= (mail-header-xref headers) "")))
9190 (let ((case-fold-search t)
9193 (nnheader-narrow-to-headers)
9194 (goto-char (point-min))
9195 (if (or (and (eq (downcase (following-char)) ?x)
9196 (looking-at "Xref:"))
9197 (search-forward "\nXref:" nil t))
9199 (goto-char (1+ (match-end 0)))
9200 (setq xref (buffer-substring (point)
9201 (progn (end-of-line) (point))))
9202 (mail-header-set-xref headers xref))))))))
9204 (defun gnus-summary-insert-subject (id &optional header)
9205 "Find article ID and insert the summary line for that article."
9206 (let ((header (gnus-read-header id header))
9207 (number (and (numberp id) id)))
9209 ;; Rebuild the thread that this article is part of and go to the
9210 ;; article we have fetched.
9211 (gnus-rebuild-thread (mail-header-id header))
9212 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9213 (when (and (numberp number)
9215 ;; We have to update the boundaries even if we can't fetch the
9216 ;; article if ID is a number -- so that the next `P' or `N'
9217 ;; command will fetch the previous (or next) article even
9218 ;; if the one we tried to fetch this time has been canceled.
9219 (and (> number gnus-newsgroup-end)
9220 (setq gnus-newsgroup-end number))
9221 (and (< number gnus-newsgroup-begin)
9222 (setq gnus-newsgroup-begin number))
9223 (setq gnus-newsgroup-unselected
9224 (delq number gnus-newsgroup-unselected)))
9225 ;; Report back a success?
9226 (and header number)))
9228 (defun gnus-summary-work-articles (n)
9229 "Return a list of articles to be worked upon. The prefix argument,
9230 the list of process marked articles, and the current article will be
9231 taken into consideration."
9233 ((and n (numberp n))
9234 ;; A numerical prefix has been given.
9235 (let ((backward (< n 0))
9241 (push (setq article (gnus-summary-article-number))
9244 (gnus-summary-find-prev nil article)
9245 (gnus-summary-find-next nil article)))
9247 (nreverse articles)))
9248 ((and (boundp 'transient-mark-mode)
9251 ;; Work on the region between point and mark.
9252 (let ((max (max (point) (mark)))
9255 (goto-char (min (point) (mark)))
9258 (push (setq article (gnus-summary-article-number)) articles)
9259 (gnus-summary-find-next nil article)
9261 (nreverse articles))))
9262 (gnus-newsgroup-processable
9263 ;; There are process-marked articles present.
9264 (reverse gnus-newsgroup-processable))
9266 ;; Just return the current article.
9267 (list (gnus-summary-article-number)))))
9269 (defun gnus-summary-search-group (&optional backward use-level)
9270 "Search for next unread newsgroup.
9271 If optional argument BACKWARD is non-nil, search backward instead."
9273 (set-buffer gnus-group-buffer)
9274 (if (gnus-group-search-forward
9275 backward nil (if use-level (gnus-group-group-level) nil))
9276 (gnus-group-group-name))))
9278 (defun gnus-summary-best-group (&optional exclude-group)
9279 "Find the name of the best unread group.
9280 If EXCLUDE-GROUP, do not go to this group."
9282 (set-buffer gnus-group-buffer)
9284 (gnus-group-best-unread-group exclude-group))))
9286 (defun gnus-summary-find-next (&optional unread article backward)
9287 (if backward (gnus-summary-find-prev)
9288 (let* ((article (or article (gnus-summary-article-number)))
9289 (arts (gnus-data-find-list article))
9291 (when (or (not gnus-summary-check-current)
9293 (not (gnus-data-unread-p (car arts))))
9294 (setq arts (cdr arts)))
9299 (when (gnus-data-unread-p (car arts))
9300 (setq result (car arts)
9302 (setq arts (cdr arts)))
9305 (goto-char (gnus-data-pos result))
9306 (gnus-data-number result)))))
9308 (defun gnus-summary-find-prev (&optional unread article)
9309 (let* ((article (or article (gnus-summary-article-number)))
9310 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9312 (when (or (not gnus-summary-check-current)
9314 (not (gnus-data-unread-p (car arts))))
9315 (setq arts (cdr arts)))
9320 (and (gnus-data-unread-p (car arts))
9321 (setq result (car arts)
9323 (setq arts (cdr arts)))
9327 (goto-char (gnus-data-pos result))
9328 (gnus-data-number result)))))
9330 (defun gnus-summary-find-subject (subject &optional unread backward article)
9331 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9332 (article (or article (gnus-summary-article-number)))
9333 (articles (gnus-data-list backward))
9334 (arts (gnus-data-find-list article articles))
9336 (when (or (not gnus-summary-check-current)
9338 (not (gnus-data-unread-p (car arts))))
9339 (setq arts (cdr arts)))
9341 (and (or (not unread)
9342 (gnus-data-unread-p (car arts)))
9343 (vectorp (gnus-data-header (car arts)))
9345 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9346 (setq result (car arts)
9348 (setq arts (cdr arts)))
9350 (goto-char (gnus-data-pos result))
9351 (gnus-data-number result))))
9353 (defun gnus-summary-search-forward (&optional unread subject backward)
9354 "Search forward for an article.
9355 If UNREAD, look for unread articles. If SUBJECT, look for
9356 articles with that subject. If BACKWARD, search backward instead."
9357 (cond (subject (gnus-summary-find-subject subject unread backward))
9358 (backward (gnus-summary-find-prev unread))
9359 (t (gnus-summary-find-next unread))))
9361 (defun gnus-recenter (&optional n)
9362 "Center point in window and redisplay frame.
9363 Also do horizontal recentering."
9365 (when (and gnus-auto-center-summary
9366 (not (eq gnus-auto-center-summary 'vertical)))
9367 (gnus-horizontal-recenter))
9370 (defun gnus-summary-recenter ()
9371 "Center point in the summary window.
9372 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9373 displayed, no centering will be performed."
9374 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9375 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9376 (let* ((top (cond ((< (window-height) 4) 0)
9377 ((< (window-height) 7) 1)
9379 (height (1- (window-height)))
9380 (bottom (save-excursion (goto-char (point-max))
9381 (forward-line (- height))
9383 (window (get-buffer-window (current-buffer))))
9384 ;; The user has to want it.
9385 (when gnus-auto-center-summary
9386 (when (get-buffer-window gnus-article-buffer)
9387 ;; Only do recentering when the article buffer is displayed,
9388 ;; Set the window start to either `bottom', which is the biggest
9389 ;; possible valid number, or the second line from the top,
9390 ;; whichever is the least.
9392 window (min bottom (save-excursion
9393 (forward-line (- top)) (point)))))
9394 ;; Do horizontal recentering while we're at it.
9395 (when (and (get-buffer-window (current-buffer) t)
9396 (not (eq gnus-auto-center-summary 'vertical)))
9397 (let ((selected (selected-window)))
9398 (select-window (get-buffer-window (current-buffer) t))
9399 (gnus-summary-position-point)
9400 (gnus-horizontal-recenter)
9401 (select-window selected))))))
9403 (defun gnus-horizontal-recenter ()
9404 "Recenter the current buffer horizontally."
9405 (if (< (current-column) (/ (window-width) 2))
9406 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9407 (let* ((orig (point))
9408 (end (window-end (get-buffer-window (current-buffer) t)))
9410 ;; Find the longest line currently displayed in the window.
9411 (goto-char (window-start))
9412 (while (and (not (eobp))
9415 (setq max (max max (current-column)))
9418 ;; Scroll horizontally to center (sort of) the point.
9419 (if (> max (window-width))
9421 (get-buffer-window (current-buffer) t)
9422 (min (- (current-column) (/ (window-width) 3))
9423 (+ 2 (- max (window-width)))))
9424 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9427 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9428 (defun gnus-short-group-name (group &optional levels)
9429 "Collapse GROUP name LEVELS."
9436 (while (string-match "\\." group skip)
9437 (setq skip (match-end 0)
9440 (if (string-match ":" group)
9441 (setq foreign (substring group 0 (match-end 0))
9442 group (substring group (match-end 0))))
9444 (if (and (string-match "\\." group)
9445 (> levels (- gnus-group-uncollapsed-levels 1)))
9446 (setq name (concat name (substring group 0 1))
9447 group (substring group (match-end 0))
9449 name (concat name "."))
9450 (setq name (concat foreign name group)
9454 (defun gnus-summary-jump-to-group (newsgroup)
9455 "Move point to NEWSGROUP in group mode buffer."
9456 ;; Keep update point of group mode buffer if visible.
9457 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9458 (save-window-excursion
9459 ;; Take care of tree window mode.
9460 (if (get-buffer-window gnus-group-buffer)
9461 (pop-to-buffer gnus-group-buffer))
9462 (gnus-group-jump-to-group newsgroup))
9464 ;; Take care of tree window mode.
9465 (if (get-buffer-window gnus-group-buffer)
9466 (pop-to-buffer gnus-group-buffer)
9467 (set-buffer gnus-group-buffer))
9468 (gnus-group-jump-to-group newsgroup))))
9470 ;; This function returns a list of article numbers based on the
9471 ;; difference between the ranges of read articles in this group and
9472 ;; the range of active articles.
9473 (defun gnus-list-of-unread-articles (group)
9474 (let* ((read (gnus-info-read (gnus-get-info group)))
9475 (active (gnus-active group))
9478 ;; If none are read, then all are unread.
9480 (setq first (car active))
9481 ;; If the range of read articles is a single range, then the
9482 ;; first unread article is the article after the last read
9483 ;; article. Sounds logical, doesn't it?
9484 (if (not (listp (cdr read)))
9485 (setq first (1+ (cdr read)))
9486 ;; `read' is a list of ranges.
9487 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9492 (while (< first nlast)
9493 (setq unread (cons first unread))
9494 (setq first (1+ first))))
9495 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9496 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9497 (setq read (cdr read)))))
9498 ;; And add the last unread articles.
9499 (while (<= first last)
9500 (setq unread (cons first unread))
9501 (setq first (1+ first)))
9502 ;; Return the list of unread articles.
9505 (defun gnus-list-of-read-articles (group)
9506 "Return a list of unread, unticked and non-dormant articles."
9507 (let* ((info (gnus-get-info group))
9508 (marked (gnus-info-marks info))
9509 (active (gnus-active group)))
9511 (gnus-set-difference
9512 (gnus-sorted-complement
9513 (gnus-uncompress-range active)
9514 (gnus-list-of-unread-articles group))
9516 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9517 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9519 ;; Various summary commands
9521 (defun gnus-summary-universal-argument (arg)
9522 "Perform any operation on all articles that are process/prefixed."
9524 (gnus-set-global-variables)
9525 (let ((articles (gnus-summary-work-articles arg))
9532 (substitute-command-keys
9533 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9537 (message "Undefined key")
9541 (gnus-summary-goto-subject (setq article (pop articles)))
9542 (command-execute func)
9543 (gnus-summary-remove-process-mark article)))))
9544 (gnus-summary-position-point))
9546 (defun gnus-summary-toggle-truncation (&optional arg)
9547 "Toggle truncation of summary lines.
9548 With arg, turn line truncation on iff arg is positive."
9550 (setq truncate-lines
9551 (if (null arg) (not truncate-lines)
9552 (> (prefix-numeric-value arg) 0)))
9555 (defun gnus-summary-reselect-current-group (&optional all rescan)
9556 "Exit and then reselect the current newsgroup.
9557 The prefix argument ALL means to select all articles."
9559 (gnus-set-global-variables)
9560 (let ((current-subject (gnus-summary-article-number))
9561 (group gnus-newsgroup-name))
9562 (setq gnus-newsgroup-begin nil)
9564 ;; We have to adjust the point of group mode buffer because the
9565 ;; current point was moved to the next unread newsgroup by
9567 (gnus-summary-jump-to-group group)
9570 (gnus-group-get-new-news-this-group 1)))
9571 (gnus-group-read-group all t)
9572 (gnus-summary-goto-subject current-subject)))
9574 (defun gnus-summary-rescan-group (&optional all)
9575 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9577 (gnus-summary-reselect-current-group all t))
9579 (defun gnus-summary-update-info ()
9580 (let* ((group gnus-newsgroup-name))
9581 (when gnus-newsgroup-kill-headers
9582 (setq gnus-newsgroup-killed
9583 (gnus-compress-sequence
9585 (gnus-set-sorted-intersection
9586 (gnus-uncompress-range gnus-newsgroup-killed)
9587 (setq gnus-newsgroup-unselected
9588 (sort gnus-newsgroup-unselected '<)))
9589 (setq gnus-newsgroup-unreads
9590 (sort gnus-newsgroup-unreads '<))) t)))
9591 (unless (listp (cdr gnus-newsgroup-killed))
9592 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9593 (let ((headers gnus-newsgroup-headers))
9594 (run-hooks 'gnus-exit-group-hook)
9595 (unless gnus-save-score
9596 (setq gnus-newsgroup-scored nil))
9597 ;; Set the new ranges of read articles.
9598 (gnus-update-read-articles
9599 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9600 ;; Set the current article marks.
9602 ;; Do the cross-ref thing.
9603 (when gnus-use-cross-reference
9604 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9605 ;; Do adaptive scoring, and possibly save score files.
9606 (when gnus-newsgroup-adaptive
9607 (gnus-score-adaptive))
9608 (when gnus-use-scoring
9610 ;; Do not switch windows but change the buffer to work.
9611 (set-buffer gnus-group-buffer)
9612 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9613 (gnus-group-update-group group)))))
9615 (defun gnus-summary-exit (&optional temporary)
9616 "Exit reading current newsgroup, and then return to group selection mode.
9617 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9619 (gnus-set-global-variables)
9620 (gnus-kill-save-kill-buffer)
9621 (let* ((group gnus-newsgroup-name)
9622 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9624 (buf (current-buffer)))
9625 (run-hooks 'gnus-summary-prepare-exit-hook)
9626 ;; If we have several article buffers, we kill them at exit.
9627 (unless gnus-single-article-buffer
9628 (gnus-kill-buffer gnus-article-buffer)
9629 (gnus-kill-buffer gnus-original-article-buffer))
9630 (when gnus-use-cache
9631 (gnus-cache-possibly-remove-articles)
9632 (gnus-cache-save-buffers))
9633 (when gnus-use-trees
9634 (gnus-tree-close group))
9635 ;; Make all changes in this group permanent.
9637 (gnus-summary-update-info))
9638 (gnus-close-group group)
9639 ;; Make sure where I was, and go to next newsgroup.
9640 (set-buffer gnus-group-buffer)
9642 (gnus-group-jump-to-group group)
9643 (gnus-group-next-unread-group 1))
9644 (run-hooks 'gnus-summary-exit-hook)
9647 ;; If we have several article buffers, we kill them at exit.
9648 (unless gnus-single-article-buffer
9649 (gnus-kill-buffer gnus-article-buffer)
9650 (gnus-kill-buffer gnus-original-article-buffer))
9652 (if (not gnus-kill-summary-on-exit)
9653 (gnus-deaden-summary)
9654 ;; We set all buffer-local variables to nil. It is unclear why
9655 ;; this is needed, but if we don't, buffer-local variables are
9656 ;; not garbage-collected, it seems. This would the lead to en
9657 ;; ever-growing Emacs.
9658 (gnus-summary-clear-local-variables)
9659 (when (get-buffer gnus-article-buffer)
9660 (bury-buffer gnus-article-buffer))
9661 ;; We clear the global counterparts of the buffer-local
9662 ;; variables as well, just to be on the safe side.
9663 (gnus-configure-windows 'group 'force)
9664 (gnus-summary-clear-local-variables)
9665 ;; Return to group mode buffer.
9666 (if (eq mode 'gnus-summary-mode)
9667 (gnus-kill-buffer buf)))
9668 (setq gnus-current-select-method gnus-select-method)
9669 (pop-to-buffer gnus-group-buffer)
9670 ;; Clear the current group name.
9671 (if (not quit-config)
9673 (gnus-group-jump-to-group group)
9674 (gnus-group-next-unread-group 1)
9675 (gnus-configure-windows 'group 'force))
9676 (if (not (buffer-name (car quit-config)))
9677 (gnus-configure-windows 'group 'force)
9678 (set-buffer (car quit-config))
9679 (and (eq major-mode 'gnus-summary-mode)
9680 (gnus-set-global-variables))
9681 (gnus-configure-windows (cdr quit-config))))
9683 (setq gnus-newsgroup-name nil)))))
9685 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9686 (defun gnus-summary-exit-no-update (&optional no-questions)
9687 "Quit reading current newsgroup without updating read article info."
9689 (gnus-set-global-variables)
9690 (let* ((group gnus-newsgroup-name)
9691 (quit-config (gnus-group-quit-config group)))
9692 (when (or no-questions
9694 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9695 ;; If we have several article buffers, we kill them at exit.
9696 (unless gnus-single-article-buffer
9697 (gnus-kill-buffer gnus-article-buffer)
9698 (gnus-kill-buffer gnus-original-article-buffer))
9699 (if (not gnus-kill-summary-on-exit)
9700 (gnus-deaden-summary)
9701 (gnus-close-group group)
9702 (gnus-summary-clear-local-variables)
9703 (set-buffer gnus-group-buffer)
9704 (gnus-summary-clear-local-variables)
9705 (when (get-buffer gnus-summary-buffer)
9706 (kill-buffer gnus-summary-buffer)))
9707 (when gnus-use-trees
9708 (gnus-tree-close group))
9709 (when (get-buffer gnus-article-buffer)
9710 (bury-buffer gnus-article-buffer))
9711 ;; Return to the group buffer.
9712 (gnus-configure-windows 'group 'force)
9713 ;; Clear the current group name.
9714 (setq gnus-newsgroup-name nil)
9715 (when (equal (gnus-group-group-name) group)
9716 (gnus-group-next-unread-group 1))
9718 (if (not (buffer-name (car quit-config)))
9719 (gnus-configure-windows 'group 'force)
9720 (set-buffer (car quit-config))
9721 (when (eq major-mode 'gnus-summary-mode)
9722 (gnus-set-global-variables))
9723 (gnus-configure-windows (cdr quit-config)))))))
9727 (defvar gnus-dead-summary-mode-map nil)
9729 (if gnus-dead-summary-mode-map
9731 (setq gnus-dead-summary-mode-map (make-keymap))
9732 (suppress-keymap gnus-dead-summary-mode-map)
9733 (substitute-key-definition
9734 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9735 (let ((keys '("\C-d" "\r" "\177")))
9737 (define-key gnus-dead-summary-mode-map
9738 (pop keys) 'gnus-summary-wake-up-the-dead))))
9740 (defvar gnus-dead-summary-mode nil
9741 "Minor mode for Gnus summary buffers.")
9743 (defun gnus-dead-summary-mode (&optional arg)
9744 "Minor mode for Gnus summary buffers."
9746 (when (eq major-mode 'gnus-summary-mode)
9747 (make-local-variable 'gnus-dead-summary-mode)
9748 (setq gnus-dead-summary-mode
9749 (if (null arg) (not gnus-dead-summary-mode)
9750 (> (prefix-numeric-value arg) 0)))
9751 (when gnus-dead-summary-mode
9752 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9753 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9754 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9755 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9756 minor-mode-map-alist)))))
9758 (defun gnus-deaden-summary ()
9759 "Make the current summary buffer into a dead summary buffer."
9760 ;; Kill any previous dead summary buffer.
9761 (when (and gnus-dead-summary
9762 (buffer-name gnus-dead-summary))
9764 (set-buffer gnus-dead-summary)
9765 (when gnus-dead-summary-mode
9766 (kill-buffer (current-buffer)))))
9767 ;; Make this the current dead summary.
9768 (setq gnus-dead-summary (current-buffer))
9769 (gnus-dead-summary-mode 1)
9770 (let ((name (buffer-name)))
9771 (when (string-match "Summary" name)
9773 (concat (substring name 0 (match-beginning 0)) "Dead "
9774 (substring name (match-beginning 0))) t))))
9776 (defun gnus-kill-or-deaden-summary (buffer)
9777 "Kill or deaden the summary BUFFER."
9778 (cond (gnus-kill-summary-on-exit
9779 (when (and gnus-use-trees
9780 (and (get-buffer buffer)
9781 (buffer-name (get-buffer buffer))))
9783 (set-buffer (get-buffer buffer))
9784 (gnus-tree-close gnus-newsgroup-name)))
9785 (gnus-kill-buffer buffer))
9786 ((and (get-buffer buffer)
9787 (buffer-name (get-buffer buffer)))
9790 (gnus-deaden-summary)))))
9792 (defun gnus-summary-wake-up-the-dead (&rest args)
9793 "Wake up the dead summary buffer."
9795 (gnus-dead-summary-mode -1)
9796 (let ((name (buffer-name)))
9797 (when (string-match "Dead " name)
9799 (concat (substring name 0 (match-beginning 0))
9800 (substring name (match-end 0))) t)))
9801 (gnus-message 3 "This dead summary is now alive again"))
9803 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9804 (defun gnus-summary-fetch-faq (&optional faq-dir)
9805 "Fetch the FAQ for the current group.
9806 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9810 (if current-prefix-arg
9812 "Faq dir: " (and (listp gnus-group-faq-directory)
9813 gnus-group-faq-directory)))))
9814 (let (gnus-faq-buffer)
9815 (and (setq gnus-faq-buffer
9816 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9817 (gnus-configure-windows 'summary-faq))))
9819 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9820 (defun gnus-summary-describe-group (&optional force)
9821 "Describe the current newsgroup."
9823 (gnus-group-describe-group force gnus-newsgroup-name))
9825 (defun gnus-summary-describe-briefly ()
9826 "Describe summary mode commands briefly."
9829 (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")))
9831 ;; Walking around group mode buffer from summary mode.
9833 (defun gnus-summary-next-group (&optional no-article target-group backward)
9834 "Exit current newsgroup and then select next unread newsgroup.
9835 If prefix argument NO-ARTICLE is non-nil, no article is selected
9836 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9837 previous group instead."
9839 (gnus-set-global-variables)
9840 (let ((current-group gnus-newsgroup-name)
9841 (current-buffer (current-buffer))
9843 ;; First we semi-exit this group to update Xrefs and all variables.
9844 ;; We can't do a real exit, because the window conf must remain
9845 ;; the same in case the user is prompted for info, and we don't
9846 ;; want the window conf to change before that...
9847 (gnus-summary-exit t)
9848 (while (not entered)
9849 ;; Then we find what group we are supposed to enter.
9850 (set-buffer gnus-group-buffer)
9851 (gnus-group-jump-to-group current-group)
9854 (if (eq gnus-keep-same-level 'best)
9855 (gnus-summary-best-group gnus-newsgroup-name)
9856 (gnus-summary-search-group backward gnus-keep-same-level))))
9857 (if (not target-group)
9858 ;; There are no further groups, so we return to the group
9861 (gnus-message 5 "Returning to the group buffer")
9863 (set-buffer current-buffer)
9864 (gnus-summary-exit))
9865 ;; We try to enter the target group.
9866 (gnus-group-jump-to-group target-group)
9867 (let ((unreads (gnus-group-group-unread)))
9868 (if (and (or (eq t unreads)
9869 (and unreads (not (zerop unreads))))
9870 (gnus-summary-read-group
9871 target-group nil no-article current-buffer))
9873 (setq current-group target-group
9874 target-group nil)))))))
9876 (defun gnus-summary-prev-group (&optional no-article)
9877 "Exit current newsgroup and then select previous unread newsgroup.
9878 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9880 (gnus-summary-next-group no-article nil t))
9882 ;; Walking around summary lines.
9884 (defun gnus-summary-first-subject (&optional unread)
9885 "Go to the first unread subject.
9886 If UNREAD is non-nil, go to the first unread article.
9887 Returns the article selected or nil if there are no unread articles."
9892 ((null gnus-newsgroup-data)
9893 (gnus-message 3 "No articles in the group")
9895 ;; Pick the first article.
9897 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9898 (gnus-data-number (car gnus-newsgroup-data)))
9899 ;; No unread articles.
9900 ((null gnus-newsgroup-unreads)
9901 (gnus-message 3 "No more unread articles")
9903 ;; Find the first unread article.
9905 (let ((data gnus-newsgroup-data))
9907 (not (gnus-data-unread-p (car data))))
9908 (setq data (cdr data)))
9911 (goto-char (gnus-data-pos (car data)))
9912 (gnus-data-number (car data)))))))
9913 (gnus-summary-position-point)))
9915 (defun gnus-summary-next-subject (n &optional unread dont-display)
9916 "Go to next N'th summary line.
9917 If N is negative, go to the previous N'th subject line.
9918 If UNREAD is non-nil, only unread articles are selected.
9919 The difference between N and the actual number of steps taken is
9922 (let ((backward (< n 0))
9926 (gnus-summary-find-prev unread)
9927 (gnus-summary-find-next unread)))
9929 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9930 (if unread " unread" "")))
9931 (unless dont-display
9932 (gnus-summary-recenter)
9933 (gnus-summary-position-point))
9936 (defun gnus-summary-next-unread-subject (n)
9937 "Go to next N'th unread summary line."
9939 (gnus-summary-next-subject n t))
9941 (defun gnus-summary-prev-subject (n &optional unread)
9942 "Go to previous N'th summary line.
9943 If optional argument UNREAD is non-nil, only unread article is selected."
9945 (gnus-summary-next-subject (- n) unread))
9947 (defun gnus-summary-prev-unread-subject (n)
9948 "Go to previous N'th unread summary line."
9950 (gnus-summary-next-subject (- n) t))
9952 (defun gnus-summary-goto-subject (article &optional force silent)
9953 "Go the subject line of ARTICLE.
9954 If FORCE, also allow jumping to articles not currently shown."
9956 (data (gnus-data-find article)))
9957 ;; We read in the article if we have to.
9960 (gnus-summary-insert-subject article)
9961 (setq data (gnus-data-find article)))
9966 (gnus-message 3 "Can't find article %d" article))
9968 (goto-char (gnus-data-pos data))
9971 ;; Walking around summary lines with displaying articles.
9973 (defun gnus-summary-expand-window (&optional arg)
9974 "Make the summary buffer take up the entire Emacs frame.
9975 Given a prefix, will force an `article' buffer configuration."
9977 (gnus-set-global-variables)
9979 (gnus-configure-windows 'article 'force)
9980 (gnus-configure-windows 'summary 'force)))
9982 (defun gnus-summary-display-article (article &optional all-header)
9983 "Display ARTICLE in article buffer."
9984 (gnus-set-global-variables)
9988 (if gnus-summary-display-article-function
9989 (funcall gnus-summary-display-article-function article all-header)
9990 (gnus-article-prepare article all-header))
9991 (run-hooks 'gnus-select-article-hook)
9992 (gnus-summary-recenter)
9993 (gnus-summary-goto-subject article)
9994 (when gnus-use-trees
9995 (gnus-possibly-generate-tree article)
9996 (gnus-highlight-selected-tree article))
9997 ;; Successfully display article.
9998 (gnus-article-set-window-start
9999 (cdr (assq article gnus-newsgroup-bookmarks)))
10002 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10003 "Select the current article.
10004 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10005 non-nil, the article will be re-fetched even if it already present in
10006 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10008 (let ((article (or article (gnus-summary-article-number)))
10009 (all-headers (not (not all-headers))) ;Must be T or NIL.
10010 gnus-summary-display-article-function
10013 (gnus-summary-article-pseudo-p article)
10014 (error "This is a pseudo-article."))
10017 (set-buffer gnus-summary-buffer)
10018 (if (or (and gnus-single-article-buffer
10019 (or (null gnus-current-article)
10020 (null gnus-article-current)
10021 (null (get-buffer gnus-article-buffer))
10022 (not (eq article (cdr gnus-article-current)))
10023 (not (equal (car gnus-article-current)
10024 gnus-newsgroup-name))))
10025 (and (not gnus-single-article-buffer)
10026 (null gnus-current-article))
10028 ;; The requested article is different from the current article.
10030 (gnus-summary-display-article article all-headers)
10031 (setq did article))
10032 (if (or all-headers gnus-show-all-headers)
10033 (gnus-article-show-all-headers))
10036 (gnus-article-set-window-start
10037 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10039 (defun gnus-summary-set-current-mark (&optional current-mark)
10040 "Obsolete function."
10043 (defun gnus-summary-next-article (&optional unread subject backward push)
10044 "Select the next article.
10045 If UNREAD, only unread articles are selected.
10046 If SUBJECT, only articles with SUBJECT are selected.
10047 If BACKWARD, the previous article is selected instead of the next."
10049 (gnus-set-global-variables)
10051 ;; Is there such an article?
10052 ((and (gnus-summary-search-forward unread subject backward)
10053 (or (gnus-summary-display-article (gnus-summary-article-number))
10054 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10055 (gnus-summary-position-point))
10056 ;; If not, we try the first unread, if that is wanted.
10058 gnus-auto-select-same
10059 (or (gnus-summary-first-unread-article)
10060 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10061 (gnus-summary-position-point)
10062 (gnus-message 6 "Wrapped"))
10063 ;; Try to get next/previous article not displayed in this group.
10064 ((and gnus-auto-extend-newsgroup
10065 (not unread) (not subject))
10066 (gnus-summary-goto-article
10067 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10069 ;; Go to next/previous group.
10071 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10072 (gnus-summary-jump-to-group gnus-newsgroup-name))
10073 (let ((cmd last-command-char)
10075 (if (eq gnus-keep-same-level 'best)
10076 (gnus-summary-best-group gnus-newsgroup-name)
10077 (gnus-summary-search-group backward gnus-keep-same-level))))
10078 ;; For some reason, the group window gets selected. We change
10080 (select-window (get-buffer-window (current-buffer)))
10081 ;; Select next unread newsgroup automagically.
10083 ((not gnus-auto-select-next)
10084 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10085 ((or (eq gnus-auto-select-next 'quietly)
10086 (and (eq gnus-auto-select-next 'slightly-quietly)
10088 (and (eq gnus-auto-select-next 'almost-quietly)
10089 (gnus-summary-last-article-p)))
10091 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10092 (gnus-summary-exit)
10093 (gnus-message 7 "No more%s articles (%s)..."
10094 (if unread " unread" "")
10095 (if group (concat "selecting " group)
10097 (gnus-summary-next-group nil group backward)))
10099 (gnus-summary-walk-group-buffer
10100 gnus-newsgroup-name cmd unread backward)))))))
10102 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10103 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10104 (?\C-p (gnus-group-prev-unread-group 1))))
10105 keve key group ended)
10107 (set-buffer gnus-group-buffer)
10108 (gnus-summary-jump-to-group from-group)
10110 (if (eq gnus-keep-same-level 'best)
10111 (gnus-summary-best-group gnus-newsgroup-name)
10112 (gnus-summary-search-group backward gnus-keep-same-level))))
10115 5 "No more%s articles%s" (if unread " unread" "")
10117 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10118 (format " (Type %s for %s [%s])"
10119 (single-key-description cmd) group
10120 (car (gnus-gethash group gnus-newsrc-hashtb)))
10121 (format " (Type %s to exit %s)"
10122 (single-key-description cmd)
10123 gnus-newsgroup-name)))
10124 ;; Confirm auto selection.
10125 (setq key (car (setq keve (gnus-read-event-char))))
10128 ((assq key keystrokes)
10129 (let ((obuf (current-buffer)))
10130 (switch-to-buffer gnus-group-buffer)
10132 (gnus-group-jump-to-group group))
10133 (eval (cadr (assq key keystrokes)))
10134 (setq group (gnus-group-group-name))
10135 (switch-to-buffer obuf))
10138 (if (or (not group)
10139 (gnus-ephemeral-group-p gnus-newsgroup-name))
10140 (gnus-summary-exit)
10141 (gnus-summary-next-group nil group backward)))
10143 (push (cdr keve) unread-command-events))))))
10145 (defun gnus-read-event-char ()
10146 "Get the next event."
10147 (let ((event (read-event)))
10148 (cons (and (numberp event) event) event)))
10150 (defun gnus-summary-next-unread-article ()
10151 "Select unread article after current one."
10153 (gnus-summary-next-article t (and gnus-auto-select-same
10154 (gnus-summary-article-subject))))
10156 (defun gnus-summary-prev-article (&optional unread subject)
10157 "Select the article after the current one.
10158 If UNREAD is non-nil, only unread articles are selected."
10160 (gnus-summary-next-article unread subject t))
10162 (defun gnus-summary-prev-unread-article ()
10163 "Select unred article before current one."
10165 (gnus-summary-prev-article t (and gnus-auto-select-same
10166 (gnus-summary-article-subject))))
10168 (defun gnus-summary-next-page (&optional lines circular)
10169 "Show next page of the selected article.
10170 If at the end of the current article, select the next article.
10171 LINES says how many lines should be scrolled up.
10173 If CIRCULAR is non-nil, go to the start of the article instead of
10174 selecting the next article when reaching the end of the current
10177 (setq gnus-summary-buffer (current-buffer))
10178 (gnus-set-global-variables)
10179 (let ((article (gnus-summary-article-number))
10181 (gnus-configure-windows 'article)
10182 (if (or (null gnus-current-article)
10183 (null gnus-article-current)
10184 (/= article (cdr gnus-article-current))
10185 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10186 ;; Selected subject is different from current article's.
10187 (gnus-summary-display-article article)
10188 (gnus-eval-in-buffer-window
10189 gnus-article-buffer
10190 (setq endp (gnus-article-next-page lines)))
10193 (gnus-summary-beginning-of-article))
10195 (gnus-message 3 "End of message"))
10197 (if (and (eq gnus-summary-goto-unread 'never)
10198 (not (eq article gnus-newsgroup-end)))
10199 (gnus-summary-next-article)
10200 (gnus-summary-next-unread-article))))))
10201 (gnus-summary-recenter)
10202 (gnus-summary-position-point)))
10204 (defun gnus-summary-prev-page (&optional lines)
10205 "Show previous page of selected article.
10206 Argument LINES specifies lines to be scrolled down."
10208 (gnus-set-global-variables)
10209 (let ((article (gnus-summary-article-number)))
10210 (gnus-configure-windows 'article)
10211 (if (or (null gnus-current-article)
10212 (null gnus-article-current)
10213 (/= article (cdr gnus-article-current))
10214 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10215 ;; Selected subject is different from current article's.
10216 (gnus-summary-display-article article)
10217 (gnus-summary-recenter)
10218 (gnus-eval-in-buffer-window gnus-article-buffer
10219 (gnus-article-prev-page lines))))
10220 (gnus-summary-position-point))
10222 (defun gnus-summary-scroll-up (lines)
10223 "Scroll up (or down) one line current article.
10224 Argument LINES specifies lines to be scrolled up (or down if negative)."
10226 (gnus-set-global-variables)
10227 (gnus-configure-windows 'article)
10228 (gnus-summary-show-thread)
10229 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10230 (gnus-eval-in-buffer-window
10231 gnus-article-buffer
10233 (if (gnus-article-next-page lines)
10234 (gnus-message 3 "End of message")))
10236 (gnus-article-prev-page (- lines))))))
10237 (gnus-summary-recenter)
10238 (gnus-summary-position-point))
10240 (defun gnus-summary-next-same-subject ()
10241 "Select next article which has the same subject as current one."
10243 (gnus-set-global-variables)
10244 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10246 (defun gnus-summary-prev-same-subject ()
10247 "Select previous article which has the same subject as current one."
10249 (gnus-set-global-variables)
10250 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10252 (defun gnus-summary-next-unread-same-subject ()
10253 "Select next unread article which has the same subject as current one."
10255 (gnus-set-global-variables)
10256 (gnus-summary-next-article t (gnus-summary-article-subject)))
10258 (defun gnus-summary-prev-unread-same-subject ()
10259 "Select previous unread article which has the same subject as current one."
10261 (gnus-set-global-variables)
10262 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10264 (defun gnus-summary-first-unread-article ()
10265 "Select the first unread article.
10266 Return nil if there are no unread articles."
10268 (gnus-set-global-variables)
10270 (if (gnus-summary-first-subject t)
10272 (gnus-summary-show-thread)
10273 (gnus-summary-first-subject t)
10274 (gnus-summary-display-article (gnus-summary-article-number))))
10275 (gnus-summary-position-point)))
10277 (defun gnus-summary-best-unread-article ()
10278 "Select the unread article with the highest score."
10280 (gnus-set-global-variables)
10281 (let ((best -1000000)
10282 (data gnus-newsgroup-data)
10285 (and (gnus-data-unread-p (car data))
10287 (gnus-summary-article-score (gnus-data-number (car data))))
10290 article (gnus-data-number (car data))))
10291 (setq data (cdr data)))
10293 (gnus-summary-goto-article article)
10294 (error "No unread articles"))
10295 (gnus-summary-position-point)))
10297 (defun gnus-summary-last-subject ()
10298 "Go to the last displayed subject line in the group."
10299 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10301 (gnus-summary-goto-subject article))))
10303 (defun gnus-summary-goto-article (article &optional all-headers force)
10304 "Fetch ARTICLE and display it if it exists.
10305 If ALL-HEADERS is non-nil, no header lines are hidden."
10311 (mapcar (lambda (number) (list (int-to-string number)))
10312 gnus-newsgroup-limit)))
10316 (if (gnus-summary-goto-subject article force)
10317 (gnus-summary-display-article article all-headers)
10318 (gnus-message 4 "Couldn't go to article %s" article) nil)
10319 (gnus-summary-position-point)))
10321 (defun gnus-summary-goto-last-article ()
10322 "Go to the previously read article."
10325 (and gnus-last-article
10326 (gnus-summary-goto-article gnus-last-article))
10327 (gnus-summary-position-point)))
10329 (defun gnus-summary-pop-article (number)
10330 "Pop one article off the history and go to the previous.
10331 NUMBER articles will be popped off."
10334 (setq gnus-newsgroup-history
10335 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10337 (gnus-summary-goto-article (car to))
10338 (error "Article history empty")))
10339 (gnus-summary-position-point))
10341 ;; Summary commands and functions for limiting the summary buffer.
10343 (defun gnus-summary-limit-to-articles (n)
10344 "Limit the summary buffer to the next N articles.
10345 If not given a prefix, use the process marked articles instead."
10347 (gnus-set-global-variables)
10349 (let ((articles (gnus-summary-work-articles n)))
10350 (setq gnus-newsgroup-processable nil)
10351 (gnus-summary-limit articles))
10352 (gnus-summary-position-point)))
10354 (defun gnus-summary-pop-limit (&optional total)
10355 "Restore the previous limit.
10356 If given a prefix, remove all limits."
10358 (gnus-set-global-variables)
10360 (setq gnus-newsgroup-limits
10361 (list (mapcar (lambda (h) (mail-header-number h))
10362 gnus-newsgroup-headers))))
10363 (unless gnus-newsgroup-limits
10364 (error "No limit to pop"))
10366 (gnus-summary-limit nil 'pop)
10367 (gnus-summary-position-point)))
10369 (defun gnus-summary-limit-to-subject (subject &optional header)
10370 "Limit the summary buffer to articles that have subjects that match a regexp."
10371 (interactive "sRegexp: ")
10373 (setq header "subject"))
10374 (when (not (equal "" subject))
10376 (let ((articles (gnus-summary-find-matching
10377 (or header "subject") subject 'all)))
10378 (or articles (error "Found no matches for \"%s\"" subject))
10379 (gnus-summary-limit articles))
10380 (gnus-summary-position-point))))
10382 (defun gnus-summary-limit-to-author (from)
10383 "Limit the summary buffer to articles that have authors that match a regexp."
10384 (interactive "sRegexp: ")
10385 (gnus-summary-limit-to-subject from "from"))
10387 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10389 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10391 (defun gnus-summary-limit-to-unread (&optional all)
10392 "Limit the summary buffer to articles that are not marked as read.
10393 If ALL is non-nil, limit strictly to unread articles."
10396 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10397 (gnus-summary-limit-to-marks
10398 ;; Concat all the marks that say that an article is read and have
10400 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10401 gnus-killed-mark gnus-kill-file-mark
10402 gnus-low-score-mark gnus-expirable-mark
10403 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10406 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10407 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10409 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10410 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10411 If REVERSE, limit the summary buffer to articles that are not marked
10412 with MARKS. MARKS can either be a string of marks or a list of marks.
10413 Returns how many articles were removed."
10414 (interactive "sMarks: ")
10415 (gnus-set-global-variables)
10417 (let ((data gnus-newsgroup-data)
10418 (marks (if (listp marks) marks
10419 (append marks nil))) ; Transform to list.
10422 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10423 (memq (gnus-data-mark (car data)) marks))
10424 (setq articles (cons (gnus-data-number (car data)) articles)))
10425 (setq data (cdr data)))
10426 (gnus-summary-limit articles))
10427 (gnus-summary-position-point)))
10429 (defun gnus-summary-limit-to-score (&optional score)
10430 "Limit to articles with score at or above SCORE."
10432 (gnus-set-global-variables)
10433 (setq score (if score
10434 (prefix-numeric-value score)
10435 (or gnus-summary-default-score 0)))
10436 (let ((data gnus-newsgroup-data)
10439 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10441 (push (gnus-data-number (car data)) articles))
10442 (setq data (cdr data)))
10444 (gnus-summary-limit articles)
10445 (gnus-summary-position-point))))
10447 (defun gnus-summary-limit-include-dormant ()
10448 "Display all the hidden articles that are marked as dormant."
10450 (gnus-set-global-variables)
10451 (or gnus-newsgroup-dormant
10452 (error "There are no dormant articles in this group"))
10454 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10455 (gnus-summary-position-point)))
10457 (defun gnus-summary-limit-exclude-dormant ()
10458 "Hide all dormant articles."
10460 (gnus-set-global-variables)
10462 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10463 (gnus-summary-position-point)))
10465 (defun gnus-summary-limit-exclude-childless-dormant ()
10466 "Hide all dormant articles that have no children."
10468 (gnus-set-global-variables)
10469 (let ((data (gnus-data-list t))
10470 articles d children)
10471 ;; Find all articles that are either not dormant or have
10473 (while (setq d (pop data))
10474 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10475 (and (setq children
10476 (gnus-article-children (gnus-data-number d)))
10479 (when (memq (car children) articles)
10484 (push (gnus-data-number d) articles)))
10485 ;; Do the limiting.
10487 (gnus-summary-limit articles)
10488 (gnus-summary-position-point))))
10490 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10491 "Mark all unread excluded articles as read.
10492 If ALL, mark even excluded ticked and dormants as read."
10494 (let ((articles (gnus-sorted-complement
10496 (mapcar (lambda (h) (mail-header-number h))
10497 gnus-newsgroup-headers)
10499 (sort gnus-newsgroup-limit '<)))
10501 (setq gnus-newsgroup-unreads nil)
10503 (setq gnus-newsgroup-dormant nil
10504 gnus-newsgroup-marked nil
10505 gnus-newsgroup-reads
10507 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10508 gnus-newsgroup-reads))
10509 (while (setq article (pop articles))
10510 (unless (or (memq article gnus-newsgroup-dormant)
10511 (memq article gnus-newsgroup-marked))
10512 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10514 (defun gnus-summary-limit (articles &optional pop)
10516 ;; We pop the previous limit off the stack and use that.
10517 (setq articles (car gnus-newsgroup-limits)
10518 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10519 ;; We use the new limit, so we push the old limit on the stack.
10520 (setq gnus-newsgroup-limits
10521 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10523 (setq gnus-newsgroup-limit articles)
10524 (let ((total (length gnus-newsgroup-data))
10525 (data (gnus-data-find-list (gnus-summary-article-number)))
10527 ;; This will do all the work of generating the new summary buffer
10528 ;; according to the new limit.
10529 (gnus-summary-prepare)
10530 ;; Hide any threads, possibly.
10531 (and gnus-show-threads
10532 gnus-thread-hide-subtree
10533 (gnus-summary-hide-all-threads))
10534 ;; Try to return to the article you were at, or one in the
10537 ;; We try to find some article after the current one.
10539 (and (gnus-summary-goto-subject
10540 (gnus-data-number (car data)) nil t)
10543 (setq data (cdr data))))
10545 ;; If there is no data, that means that we were after the last
10546 ;; article. The same goes when we can't find any articles
10547 ;; after the current one.
10549 (goto-char (point-max))
10550 (gnus-summary-find-prev)))
10551 ;; We return how many articles were removed from the summary
10552 ;; buffer as a result of the new limit.
10553 (- total (length gnus-newsgroup-data))))
10555 (defsubst gnus-cut-thread (thread)
10556 "Go forwards in the thread until we find an article that we want to display."
10557 (if (eq gnus-fetch-old-headers 'some)
10559 (memq (mail-header-number (car thread))
10560 gnus-newsgroup-ancient)
10561 (<= (length (cdr thread)) 1))
10562 (setq thread (cadr thread)))
10564 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10565 (= (length (cdr thread)) 1))
10566 (setq thread (cadr thread))))
10569 (defun gnus-cut-threads (threads)
10570 "Cut off all uninteresting articles from the beginning of threads."
10571 (when (or (eq gnus-fetch-old-headers 'some)
10572 (eq gnus-build-sparse-threads 'some)
10573 (eq gnus-build-sparse-threads 'more))
10574 (let ((th threads))
10576 (setcar th (gnus-cut-thread (car th)))
10577 (setq th (cdr th)))))
10580 (defun gnus-summary-initial-limit (&optional show-if-empty)
10581 "Figure out what the initial limit is supposed to be on group entry.
10582 This entails weeding out unwanted dormants, low-scored articles,
10583 fetch-old-headers verbiage, and so on."
10584 ;; Most groups have nothing to remove.
10585 (if (or gnus-inhibit-limiting
10586 (and (null gnus-newsgroup-dormant)
10587 (not (eq gnus-fetch-old-headers 'some))
10588 (null gnus-summary-expunge-below)
10589 (not (eq gnus-build-sparse-threads 'some))
10590 (not (eq gnus-build-sparse-threads 'more))
10591 (null gnus-thread-expunge-below)
10592 (not gnus-use-nocem)))
10594 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10595 (setq gnus-newsgroup-limit nil)
10598 (unless (car (symbol-value node))
10599 ;; These threads have no parents -- they are roots.
10600 (let ((nodes (cdr (symbol-value node)))
10603 (if (and gnus-thread-expunge-below
10604 (< (gnus-thread-total-score (car nodes))
10605 gnus-thread-expunge-below))
10606 (gnus-expunge-thread (pop nodes))
10607 (setq thread (pop nodes))
10608 (gnus-summary-limit-children thread))))))
10609 gnus-newsgroup-dependencies)
10610 ;; If this limitation resulted in an empty group, we might
10611 ;; pop the previous limit and use it instead.
10612 (when (and (not gnus-newsgroup-limit)
10614 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10615 gnus-newsgroup-limit))
10617 (defun gnus-summary-limit-children (thread)
10618 "Return 1 if this subthread is visible and 0 if it is not."
10619 ;; First we get the number of visible children to this thread. This
10620 ;; is done by recursing down the thread using this function, so this
10621 ;; will really go down to a leaf article first, before slowly
10622 ;; working its way up towards the root.
10626 (apply '+ (mapcar 'gnus-summary-limit-children
10629 (number (mail-header-number (car thread)))
10632 ;; If this article is dormant and has absolutely no visible
10633 ;; children, then this article isn't visible.
10634 (and (memq number gnus-newsgroup-dormant)
10636 ;; If this is a "fetch-old-headered" and there is only one
10637 ;; visible child (or less), then we don't want this article.
10638 (and (eq gnus-fetch-old-headers 'some)
10639 (memq number gnus-newsgroup-ancient)
10641 ;; If this is a sparsely inserted article with no children,
10642 ;; we don't want it.
10643 (and (eq gnus-build-sparse-threads 'some)
10644 (memq number gnus-newsgroup-sparse)
10646 ;; If we use expunging, and this article is really
10647 ;; low-scored, then we don't want this article.
10648 (when (and gnus-summary-expunge-below
10650 (or (cdr (assq number gnus-newsgroup-scored))
10651 gnus-summary-default-score))
10652 gnus-summary-expunge-below))
10653 ;; We increase the expunge-tally here, but that has
10654 ;; nothing to do with the limits, really.
10655 (incf gnus-newsgroup-expunged-tally)
10656 ;; We also mark as read here, if that's wanted.
10657 (when (and gnus-summary-mark-below
10658 (< score gnus-summary-mark-below))
10659 (setq gnus-newsgroup-unreads
10660 (delq number gnus-newsgroup-unreads))
10661 (if gnus-newsgroup-auto-expire
10662 (push number gnus-newsgroup-expirable)
10663 (push (cons number gnus-low-score-mark)
10664 gnus-newsgroup-reads)))
10666 (and gnus-use-nocem
10667 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10668 ;; Nope, invisible article.
10670 ;; Ok, this article is to be visible, so we add it to the limit
10672 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10675 (defun gnus-expunge-thread (thread)
10676 "Mark all articles in THREAD as read."
10677 (let* ((number (mail-header-number (car thread))))
10678 (incf gnus-newsgroup-expunged-tally)
10679 ;; We also mark as read here, if that's wanted.
10680 (setq gnus-newsgroup-unreads
10681 (delq number gnus-newsgroup-unreads))
10682 (if gnus-newsgroup-auto-expire
10683 (push number gnus-newsgroup-expirable)
10684 (push (cons number gnus-low-score-mark)
10685 gnus-newsgroup-reads)))
10686 ;; Go recursively through all subthreads.
10687 (mapcar 'gnus-expunge-thread (cdr thread)))
10689 ;; Summary article oriented commands
10691 (defun gnus-summary-refer-parent-article (n)
10692 "Refer parent article N times.
10693 The difference between N and the number of articles fetched is returned."
10695 (gnus-set-global-variables)
10699 (let* ((header (gnus-summary-article-header))
10701 ;; If we try to find the parent of the currently
10702 ;; displayed article, then we take a look at the actual
10703 ;; References header, since this is slightly more
10704 ;; reliable than the References field we got from the
10706 (if (and (eq (mail-header-number header)
10707 (cdr gnus-article-current))
10708 (equal gnus-newsgroup-name
10709 (car gnus-article-current)))
10711 (set-buffer gnus-original-article-buffer)
10712 (nnheader-narrow-to-headers)
10714 (mail-fetch-field "references")
10716 ;; It's not the current article, so we take a bet on
10717 ;; the value we got from the server.
10718 (mail-header-references header))))
10719 (if (setq ref (or ref (mail-header-references header)))
10720 (or (gnus-summary-refer-article (gnus-parent-id ref))
10721 (gnus-message 1 "Couldn't find parent"))
10722 (gnus-message 1 "No references in article %d"
10723 (gnus-summary-article-number))
10726 (gnus-summary-position-point)
10729 (defun gnus-summary-refer-references ()
10730 "Fetch all articles mentioned in the References header.
10731 Return how many articles were fetched."
10733 (gnus-set-global-variables)
10734 (let ((ref (mail-header-references (gnus-summary-article-header)))
10735 (current (gnus-summary-article-number))
10737 ;; For each Message-ID in the References header...
10738 (while (string-match "<[^>]*>" ref)
10740 ;; ... fetch that article.
10741 (gnus-summary-refer-article
10742 (prog1 (match-string 0 ref)
10743 (setq ref (substring ref (match-end 0))))))
10744 (gnus-summary-goto-subject current)
10745 (gnus-summary-position-point)
10748 (defun gnus-summary-refer-article (message-id)
10749 "Fetch an article specified by MESSAGE-ID."
10750 (interactive "sMessage-ID: ")
10751 (when (and (stringp message-id)
10752 (not (zerop (length message-id))))
10753 ;; Construct the correct Message-ID if necessary.
10754 ;; Suggested by tale@pawl.rpi.edu.
10755 (unless (string-match "^<" message-id)
10756 (setq message-id (concat "<" message-id)))
10757 (unless (string-match ">$" message-id)
10758 (setq message-id (concat message-id ">")))
10759 (let ((header (car (gnus-gethash message-id
10760 gnus-newsgroup-dependencies))))
10762 ;; The article is present in the buffer, to we just go to it.
10763 (gnus-summary-goto-article (mail-header-number header) nil t)
10764 ;; We fetch the article
10765 (let ((gnus-override-method gnus-refer-article-method)
10767 ;; Start the special refer-article method, if necessary.
10768 (when gnus-refer-article-method
10769 (gnus-check-server gnus-refer-article-method))
10770 ;; Fetch the header, and display the article.
10771 (if (setq number (gnus-summary-insert-subject message-id))
10772 (gnus-summary-select-article nil nil nil number)
10773 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10775 (defun gnus-summary-enter-digest-group (&optional force)
10776 "Enter a digest group based on the current article."
10778 (gnus-set-global-variables)
10779 (gnus-summary-select-article)
10780 (let ((name (format "%s-%d"
10781 (gnus-group-prefixed-name
10782 gnus-newsgroup-name (list 'nndoc ""))
10783 gnus-current-article))
10784 (ogroup gnus-newsgroup-name)
10785 (case-fold-search t)
10786 (buf (current-buffer))
10789 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10790 (insert-buffer-substring gnus-original-article-buffer)
10792 (goto-char (point-min))
10793 (or (search-forward "\n\n" nil t) (point)))
10794 (goto-char (point-min))
10795 (delete-matching-lines "^\\(Path\\):\\|^From ")
10798 (if (gnus-group-read-ephemeral-group
10799 name `(nndoc ,name (nndoc-address
10801 (nndoc-article-type ,(if force 'digest 'guess))) t)
10802 ;; Make all postings to this group go to the parent group.
10803 (nconc (gnus-info-params (gnus-get-info name))
10804 (list (cons 'to-group ogroup)))
10805 ;; Couldn't select this doc group.
10806 (switch-to-buffer buf)
10807 (gnus-set-global-variables)
10808 (gnus-configure-windows 'summary)
10809 (gnus-message 3 "Article couldn't be entered?"))
10810 (kill-buffer dig))))
10812 (defun gnus-summary-isearch-article (&optional regexp-p)
10813 "Do incremental search forward on the current article.
10814 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10816 (gnus-set-global-variables)
10817 (gnus-summary-select-article)
10818 (gnus-configure-windows 'article)
10819 (gnus-eval-in-buffer-window
10820 gnus-article-buffer
10821 (goto-char (point-min))
10822 (isearch-forward regexp-p)))
10824 (defun gnus-summary-search-article-forward (regexp &optional backward)
10825 "Search for an article containing REGEXP forward.
10826 If BACKWARD, search backward instead."
10829 (format "Search article %s (regexp%s): "
10830 (if current-prefix-arg "backward" "forward")
10831 (if gnus-last-search-regexp
10832 (concat ", default " gnus-last-search-regexp)
10834 current-prefix-arg))
10835 (gnus-set-global-variables)
10836 (if (string-equal regexp "")
10837 (setq regexp (or gnus-last-search-regexp ""))
10838 (setq gnus-last-search-regexp regexp))
10839 (if (gnus-summary-search-article regexp backward)
10840 (gnus-article-set-window-start
10841 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10842 (error "Search failed: \"%s\"" regexp)))
10844 (defun gnus-summary-search-article-backward (regexp)
10845 "Search for an article containing REGEXP backward."
10848 (format "Search article backward (regexp%s): "
10849 (if gnus-last-search-regexp
10850 (concat ", default " gnus-last-search-regexp)
10852 (gnus-summary-search-article-forward regexp 'backward))
10854 (defun gnus-summary-search-article (regexp &optional backward)
10855 "Search for an article containing REGEXP.
10856 Optional argument BACKWARD means do search for backward.
10857 gnus-select-article-hook is not called during the search."
10858 (let ((gnus-select-article-hook nil) ;Disable hook.
10859 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10862 (function re-search-backward) (function re-search-forward)))
10865 ;; Hidden thread subtrees must be searched for ,too.
10866 (gnus-summary-show-all-threads)
10867 ;; First of all, search current article.
10868 ;; We don't want to read article again from NNTP server nor reset
10870 (gnus-summary-select-article)
10871 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10872 (setq last gnus-current-article)
10873 (gnus-eval-in-buffer-window
10874 gnus-article-buffer
10877 ;; Begin search from current point.
10878 (setq found (funcall re-search regexp nil t))))
10879 ;; Then search next articles.
10880 (while (and (not found)
10881 (gnus-summary-display-article
10882 (if backward (gnus-summary-find-prev)
10883 (gnus-summary-find-next))))
10884 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10885 (gnus-eval-in-buffer-window
10886 gnus-article-buffer
10889 (goto-char (if backward (point-max) (point-min)))
10890 (setq found (funcall re-search regexp nil t)))))
10892 ;; Adjust article pointer.
10893 (or (eq last gnus-current-article)
10894 (setq gnus-last-article last))
10895 ;; Return T if found such article.
10898 (defun gnus-summary-find-matching (header regexp &optional backward unread
10900 "Return a list of all articles that match REGEXP on HEADER.
10901 The search stars on the current article and goes forwards unless
10902 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10903 If UNREAD is non-nil, only unread articles will
10904 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10905 in the comparisons."
10906 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10907 (gnus-data-find-list
10908 (gnus-summary-article-number) (gnus-data-list backward))))
10909 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10910 (case-fold-search (not not-case-fold))
10912 (or (fboundp (intern (concat "mail-header-" header)))
10913 (error "%s is not a valid header" header))
10915 (setq d (car data))
10916 (and (or (not unread) ; We want all articles...
10917 (gnus-data-unread-p d)) ; Or just unreads.
10918 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10919 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10920 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10921 (setq data (cdr data)))
10922 (nreverse articles)))
10924 (defun gnus-summary-execute-command (header regexp command &optional backward)
10925 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10926 If HEADER is an empty string (or nil), the match is done on the entire
10927 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10929 (list (let ((completion-ignore-case t))
10932 (mapcar (lambda (string) (list string))
10933 '("Number" "Subject" "From" "Lines" "Date"
10934 "Message-ID" "Xref" "References" "Body"))
10935 nil 'require-match))
10936 (read-string "Regexp: ")
10937 (read-key-sequence "Command: ")
10938 current-prefix-arg))
10939 (when (equal header "Body")
10941 (gnus-set-global-variables)
10942 ;; Hidden thread subtrees must be searched as well.
10943 (gnus-summary-show-all-threads)
10944 ;; We don't want to change current point nor window configuration.
10946 (save-window-excursion
10947 (gnus-message 6 "Executing %s..." (key-description command))
10948 ;; We'd like to execute COMMAND interactively so as to give arguments.
10949 (gnus-execute header regexp
10950 `(lambda () (call-interactively ',(key-binding command)))
10952 (gnus-message 6 "Executing %s...done" (key-description command)))))
10954 (defun gnus-summary-beginning-of-article ()
10955 "Scroll the article back to the beginning."
10957 (gnus-set-global-variables)
10958 (gnus-summary-select-article)
10959 (gnus-configure-windows 'article)
10960 (gnus-eval-in-buffer-window
10961 gnus-article-buffer
10963 (goto-char (point-min))
10964 (and gnus-break-pages (gnus-narrow-to-page))))
10966 (defun gnus-summary-end-of-article ()
10967 "Scroll to the end of the article."
10969 (gnus-set-global-variables)
10970 (gnus-summary-select-article)
10971 (gnus-configure-windows 'article)
10972 (gnus-eval-in-buffer-window
10973 gnus-article-buffer
10975 (goto-char (point-max))
10977 (and gnus-break-pages (gnus-narrow-to-page))))
10979 (defun gnus-summary-show-article (&optional arg)
10980 "Force re-fetching of the current article.
10981 If ARG (the prefix) is non-nil, show the raw article without any
10982 article massaging functions being run."
10984 (gnus-set-global-variables)
10986 ;; Select the article the normal way.
10987 (gnus-summary-select-article nil 'force)
10988 ;; Bind the article treatment functions to nil.
10989 (let ((gnus-have-all-headers t)
10990 gnus-article-display-hook
10991 gnus-article-prepare-hook
10993 (gnus-summary-select-article nil 'force)))
10994 ; (gnus-configure-windows 'article)
10995 (gnus-summary-position-point))
10997 (defun gnus-summary-verbose-headers (&optional arg)
10998 "Toggle permanent full header display.
10999 If ARG is a positive number, turn header display on.
11000 If ARG is a negative number, turn header display off."
11002 (gnus-set-global-variables)
11003 (gnus-summary-toggle-header arg)
11004 (setq gnus-show-all-headers
11005 (cond ((or (not (numberp arg))
11007 (not gnus-show-all-headers))
11011 (defun gnus-summary-toggle-header (&optional arg)
11012 "Show the headers if they are hidden, or hide them if they are shown.
11013 If ARG is a positive number, show the entire header.
11014 If ARG is a negative number, hide the unwanted header lines."
11016 (gnus-set-global-variables)
11018 (set-buffer gnus-article-buffer)
11019 (let* ((buffer-read-only nil)
11020 (inhibit-point-motion-hooks t)
11021 (hidden (text-property-any
11022 (goto-char (point-min)) (search-forward "\n\n")
11025 (goto-char (point-min))
11026 (when (search-forward "\n\n" nil t)
11027 (delete-region (point-min) (1- (point))))
11028 (goto-char (point-min))
11030 (set-buffer gnus-original-article-buffer)
11031 (goto-char (point-min))
11032 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11033 (insert-buffer-substring gnus-original-article-buffer 1 e)
11034 (let ((gnus-inhibit-hiding t))
11035 (run-hooks 'gnus-article-display-hook))
11036 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11037 (gnus-article-hide-headers)))))
11039 (defun gnus-summary-show-all-headers ()
11040 "Make all header lines visible."
11042 (gnus-set-global-variables)
11043 (gnus-article-show-all-headers))
11045 (defun gnus-summary-toggle-mime (&optional arg)
11046 "Toggle MIME processing.
11047 If ARG is a positive number, turn MIME processing on."
11049 (gnus-set-global-variables)
11050 (setq gnus-show-mime
11051 (if (null arg) (not gnus-show-mime)
11052 (> (prefix-numeric-value arg) 0)))
11053 (gnus-summary-select-article t 'force))
11055 (defun gnus-summary-caesar-message (&optional arg)
11056 "Caesar rotate the current article by 13.
11057 The numerical prefix specifies how manu places to rotate each letter
11060 (gnus-set-global-variables)
11061 (gnus-summary-select-article)
11062 (let ((mail-header-separator ""))
11063 (gnus-eval-in-buffer-window
11064 gnus-article-buffer
11067 (let ((start (window-start)))
11068 (news-caesar-buffer-body arg)
11069 (set-window-start (get-buffer-window (current-buffer)) start))))))
11071 (defun gnus-summary-stop-page-breaking ()
11072 "Stop page breaking in the current article."
11074 (gnus-set-global-variables)
11075 (gnus-summary-select-article)
11076 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11078 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11079 "Move the current article to a different newsgroup.
11080 If N is a positive number, move the N next articles.
11081 If N is a negative number, move the N previous articles.
11082 If N is nil and any articles have been marked with the process mark,
11083 move those articles instead.
11084 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11085 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11086 re-spool using this method.
11088 For this function to work, both the current newsgroup and the
11089 newsgroup that you want to move to have to support the `request-move'
11090 and `request-accept' functions."
11092 (unless action (setq action 'move))
11093 (gnus-set-global-variables)
11094 ;; Check whether the source group supports the required functions.
11095 (cond ((and (eq action 'move)
11096 (not (gnus-check-backend-function
11097 'request-move-article gnus-newsgroup-name)))
11098 (error "The current group does not support article moving"))
11099 ((and (eq action 'crosspost)
11100 (not (gnus-check-backend-function
11101 'request-replace-article gnus-newsgroup-name)))
11102 (error "The current group does not support article editing")))
11103 (let ((articles (gnus-summary-work-articles n))
11104 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11105 (names '((move "move" "Moving")
11106 (copy "copy" "Copying")
11107 (crosspost "crosspost" "Crossposting")))
11108 (copy-buf (save-excursion
11109 (nnheader-set-temp-buffer " *copy article*")))
11110 art-group to-method new-xref article)
11111 (unless (assq action names)
11112 (error "Unknown action %s" action))
11113 ;; Read the newsgroup name.
11114 (when (and (not to-newsgroup)
11115 (not select-method))
11117 (gnus-read-move-group-name
11118 (cadr (assq action names))
11119 gnus-current-move-group articles prefix))
11120 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11121 (setq to-method (if select-method (list select-method "")
11122 (gnus-find-method-for-group to-newsgroup)))
11123 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11124 ;;(error "Can't %s to the same group you're already in" action))
11125 ;; Check the method we are to move this article to...
11126 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11127 (error "%s does not support article copying" (car to-method)))
11128 (or (gnus-check-server to-method)
11129 (error "Can't open server %s" (car to-method)))
11130 (gnus-message 6 "%s to %s: %s..."
11131 (caddr (assq action names))
11132 (or select-method to-newsgroup) articles)
11134 (setq article (pop articles))
11138 ;; Move the article.
11140 (gnus-request-move-article
11141 article ; Article to move
11142 gnus-newsgroup-name ; From newsgrouo
11143 (nth 1 (gnus-find-method-for-group
11144 gnus-newsgroup-name)) ; Server
11145 (list 'gnus-request-accept-article
11147 (list 'quote select-method)
11149 (not articles)) ; Accept form
11150 (not articles))) ; Only save nov last time
11151 ;; Copy the article.
11154 (set-buffer copy-buf)
11155 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11156 (gnus-request-accept-article
11157 (if select-method select-method to-newsgroup)
11159 ;; Crosspost the article.
11160 ((eq action 'crosspost)
11161 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11162 (setq new-xref (concat gnus-newsgroup-name ":" article))
11163 (if (and xref (not (string= xref "")))
11165 (when (string-match "^Xref: " xref)
11166 (setq xref (substring xref (match-end 0))))
11167 (setq new-xref (concat xref " " new-xref)))
11168 (setq new-xref (concat (system-name) " " new-xref)))
11170 (set-buffer copy-buf)
11171 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11172 (nnheader-replace-header "xref" new-xref)
11173 (gnus-request-accept-article
11174 (if select-method select-method to-newsgroup)
11175 (not articles)))))))
11176 (if (not art-group)
11177 (gnus-message 1 "Couldn't %s article %s"
11178 (cadr (assq action names)) article)
11181 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11183 (gnus-group-prefixed-name
11185 (if select-method (list select-method "")
11186 (gnus-find-method-for-group to-newsgroup)))
11187 gnus-newsrc-hashtb)))
11188 (info (nth 2 entry)))
11189 ;; Update the group that has been moved to.
11191 (memq action '(move copy)))
11192 (unless (memq article gnus-newsgroup-unreads)
11193 (gnus-info-set-read
11194 info (gnus-add-to-range (gnus-info-read info)
11195 (list (cdr art-group)))))
11197 ;; Copy any marks over to the new group.
11198 (let ((marks gnus-article-mark-lists)
11199 (to-article (cdr art-group)))
11201 ;; See whether the article is to be put in the cache.
11202 (when gnus-use-cache
11203 (gnus-cache-possibly-enter-article
11204 (gnus-info-group info) to-article
11205 (let ((header (copy-sequence
11206 (gnus-summary-article-header article))))
11207 (mail-header-set-number header to-article)
11209 (memq article gnus-newsgroup-marked)
11210 (memq article gnus-newsgroup-dormant)
11211 (memq article gnus-newsgroup-unreads)))
11214 (when (memq article (symbol-value
11215 (intern (format "gnus-newsgroup-%s"
11217 (gnus-add-marked-articles
11218 (gnus-info-group info) (cdar marks)
11219 (list to-article) info))
11220 (setq marks (cdr marks)))))
11222 ;; Update the Xref header in this article to point to
11223 ;; the new crossposted article we have just created.
11224 (when (eq action 'crosspost)
11226 (set-buffer copy-buf)
11227 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11228 (nnheader-replace-header
11229 "xref" (concat new-xref " " (gnus-group-prefixed-name
11230 (car art-group) to-method)
11231 ":" (cdr art-group)))
11232 (gnus-request-replace-article
11233 article gnus-newsgroup-name (current-buffer)))))
11235 (gnus-summary-goto-subject article)
11236 (when (eq action 'move)
11237 (gnus-summary-mark-article article gnus-canceled-mark)))
11238 (gnus-summary-remove-process-mark article))
11239 (gnus-kill-buffer copy-buf)
11240 (gnus-summary-position-point)
11241 (gnus-set-mode-line 'summary)))
11243 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11244 "Move the current article to a different newsgroup.
11245 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11246 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11247 re-spool using this method."
11249 (gnus-summary-move-article n nil select-method 'copy))
11251 (defun gnus-summary-crosspost-article (&optional n)
11252 "Crosspost the current article to some other group."
11254 (gnus-summary-move-article n nil nil 'crosspost))
11256 (defun gnus-summary-respool-article (&optional n respool-method)
11257 "Respool the current article.
11258 The article will be squeezed through the mail spooling process again,
11259 which means that it will be put in some mail newsgroup or other
11260 depending on `nnmail-split-methods'.
11261 If N is a positive number, respool the N next articles.
11262 If N is a negative number, respool the N previous articles.
11263 If N is nil and any articles have been marked with the process mark,
11264 respool those articles instead.
11266 Respooling can be done both from mail groups and \"real\" newsgroups.
11267 In the former case, the articles in question will be moved from the
11268 current group into whatever groups they are destined to. In the
11269 latter case, they will be copied into the relevant groups."
11271 (gnus-set-global-variables)
11272 (let ((respool-methods (gnus-methods-using 'respool))
11274 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11276 (setq respool-method
11278 "What method do you want to use when respooling? "
11279 respool-methods nil t methname)))
11280 (or (string= respool-method "")
11281 (if (assoc (symbol-name
11282 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11284 (gnus-summary-move-article n nil (intern respool-method))
11285 (gnus-summary-copy-article n nil (intern respool-method))))))
11287 (defun gnus-summary-import-article (file)
11288 "Import a random file into a mail newsgroup."
11289 (interactive "fImport file: ")
11290 (gnus-set-global-variables)
11291 (let ((group gnus-newsgroup-name)
11292 (now (current-time))
11294 (or (gnus-check-backend-function 'request-accept-article group)
11295 (error "%s does not support article importing" group))
11296 (or (file-readable-p file)
11297 (not (file-regular-p file))
11298 (error "Can't read %s" file))
11300 (set-buffer (get-buffer-create " *import file*"))
11301 (buffer-disable-undo (current-buffer))
11303 (insert-file-contents file)
11304 (goto-char (point-min))
11305 (unless (nnheader-article-p)
11306 ;; This doesn't look like an article, so we fudge some headers.
11307 (setq atts (file-attributes file)
11308 lines (count-lines (point-min) (point-max)))
11309 (insert "From: " (read-string "From: ") "\n"
11310 "Subject: " (read-string "Subject: ") "\n"
11311 "Date: " (timezone-make-date-arpa-standard
11312 (current-time-string (nth 5 atts))
11313 (current-time-zone now)
11314 (current-time-zone now)) "\n"
11315 "Message-ID: " (gnus-inews-message-id) "\n"
11316 "Lines: " (int-to-string lines) "\n"
11317 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11318 (gnus-request-accept-article group t)
11319 (kill-buffer (current-buffer)))))
11321 (defun gnus-summary-expire-articles ()
11322 "Expire all articles that are marked as expirable in the current group."
11324 (gnus-set-global-variables)
11325 (when (gnus-check-backend-function
11326 'request-expire-articles gnus-newsgroup-name)
11327 ;; This backend supports expiry.
11328 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11329 (expirable (if total
11330 (gnus-list-of-read-articles gnus-newsgroup-name)
11331 (setq gnus-newsgroup-expirable
11332 (sort gnus-newsgroup-expirable '<))))
11333 (expiry-wait (gnus-group-get-parameter
11334 gnus-newsgroup-name 'expiry-wait))
11337 ;; There are expirable articles in this group, so we run them
11338 ;; through the expiry process.
11339 (gnus-message 6 "Expiring articles...")
11340 ;; The list of articles that weren't expired is returned.
11342 (let ((nnmail-expiry-wait-function nil)
11343 (nnmail-expiry-wait expiry-wait))
11344 (setq es (gnus-request-expire-articles
11345 expirable gnus-newsgroup-name)))
11346 (setq es (gnus-request-expire-articles
11347 expirable gnus-newsgroup-name)))
11348 (or total (setq gnus-newsgroup-expirable es))
11349 ;; We go through the old list of expirable, and mark all
11350 ;; really expired articles as nonexistent.
11351 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11352 (let ((gnus-use-cache nil))
11354 (unless (memq (car expirable) es)
11355 (when (gnus-data-find (car expirable))
11356 (gnus-summary-mark-article
11357 (car expirable) gnus-canceled-mark)))
11358 (setq expirable (cdr expirable)))))
11359 (gnus-message 6 "Expiring articles...done")))))
11361 (defun gnus-summary-expire-articles-now ()
11362 "Expunge all expirable articles in the current group.
11363 This means that *all* articles that are marked as expirable will be
11364 deleted forever, right now."
11366 (gnus-set-global-variables)
11367 (or gnus-expert-user
11369 "Are you really, really, really sure you want to expunge? ")
11371 (let ((nnmail-expiry-wait 'immediate)
11372 (nnmail-expiry-wait-function nil))
11373 (gnus-summary-expire-articles)))
11375 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11376 (defun gnus-summary-delete-article (&optional n)
11377 "Delete the N next (mail) articles.
11378 This command actually deletes articles. This is not a marking
11379 command. The article will disappear forever from your life, never to
11381 If N is negative, delete backwards.
11382 If N is nil and articles have been marked with the process mark,
11383 delete these instead."
11385 (gnus-set-global-variables)
11386 (or (gnus-check-backend-function 'request-expire-articles
11387 gnus-newsgroup-name)
11388 (error "The current newsgroup does not support article deletion."))
11389 ;; Compute the list of articles to delete.
11390 (let ((articles (gnus-summary-work-articles n))
11392 (if (and gnus-novice-user
11393 (not (gnus-y-or-n-p
11394 (format "Do you really want to delete %s forever? "
11395 (if (> (length articles) 1) "these articles"
11396 "this article")))))
11398 ;; Delete the articles.
11399 (setq not-deleted (gnus-request-expire-articles
11400 articles gnus-newsgroup-name 'force))
11402 (gnus-summary-remove-process-mark (car articles))
11403 ;; The backend might not have been able to delete the article
11405 (or (memq (car articles) not-deleted)
11406 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11407 (setq articles (cdr articles))))
11408 (gnus-summary-position-point)
11409 (gnus-set-mode-line 'summary)
11412 (defun gnus-summary-edit-article (&optional force)
11413 "Enter into a buffer and edit the current article.
11414 This will have permanent effect only in mail groups.
11415 If FORCE is non-nil, allow editing of articles even in read-only
11419 (set-buffer gnus-summary-buffer)
11420 (gnus-set-global-variables)
11421 (when (and (not force)
11422 (gnus-group-read-only-p))
11423 (error "The current newsgroup does not support article editing."))
11424 (gnus-summary-select-article t nil t)
11425 (gnus-configure-windows 'article)
11426 (select-window (get-buffer-window gnus-article-buffer))
11427 (gnus-message 6 "C-c C-c to end edits")
11428 (setq buffer-read-only nil)
11430 (use-local-map (copy-keymap (current-local-map)))
11431 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11432 (buffer-enable-undo)
11434 (goto-char (point-min))
11435 (search-forward "\n\n" nil t)))
11437 (defun gnus-summary-edit-article-done ()
11438 "Make edits to the current article permanent."
11440 (if (gnus-group-read-only-p)
11442 (gnus-summary-edit-article-postpone)
11444 1 "The current newsgroup does not support article editing.")
11446 (let ((buf (format "%s" (buffer-string))))
11449 (if (not (gnus-request-replace-article
11450 (cdr gnus-article-current) (car gnus-article-current)
11452 (error "Couldn't replace article.")
11453 (gnus-article-mode)
11454 (use-local-map gnus-article-mode-map)
11455 (setq buffer-read-only t)
11456 (buffer-disable-undo (current-buffer))
11457 (gnus-configure-windows 'summary)
11458 (gnus-summary-update-article (cdr gnus-article-current))
11459 (when gnus-use-cache
11460 (gnus-cache-update-article
11461 (cdr gnus-article-current) (car gnus-article-current))))
11462 (run-hooks 'gnus-article-display-hook)
11463 (and (gnus-visual-p 'summary-highlight 'highlight)
11464 (run-hooks 'gnus-visual-mark-article-hook)))))
11466 (defun gnus-summary-edit-article-postpone ()
11467 "Postpone changes to the current article."
11469 (gnus-article-mode)
11470 (use-local-map gnus-article-mode-map)
11471 (setq buffer-read-only t)
11472 (buffer-disable-undo (current-buffer))
11473 (gnus-configure-windows 'summary)
11474 (and (gnus-visual-p 'summary-highlight 'highlight)
11475 (run-hooks 'gnus-visual-mark-article-hook)))
11477 (defun gnus-summary-respool-query ()
11478 "Query where the respool algorithm would put this article."
11480 (gnus-set-global-variables)
11481 (gnus-summary-select-article)
11483 (set-buffer gnus-article-buffer)
11485 (goto-char (point-min))
11486 (search-forward "\n\n")
11487 (narrow-to-region (point-min) (point))
11488 (pp-eval-expression
11489 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11491 ;; Summary score commands.
11493 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11495 (defun gnus-summary-raise-score (n)
11496 "Raise the score of the current article by N."
11498 (gnus-set-global-variables)
11499 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11501 (defun gnus-summary-set-score (n)
11502 "Set the score of the current article to N."
11504 (gnus-set-global-variables)
11506 (gnus-summary-show-thread)
11507 (let ((buffer-read-only nil))
11509 (gnus-summary-update-mark
11510 (if (= n (or gnus-summary-default-score 0)) ?
11511 (if (< n (or gnus-summary-default-score 0))
11512 gnus-score-below-mark gnus-score-over-mark)) 'score))
11513 (let* ((article (gnus-summary-article-number))
11514 (score (assq article gnus-newsgroup-scored)))
11515 (if score (setcdr score n)
11516 (setq gnus-newsgroup-scored
11517 (cons (cons article n) gnus-newsgroup-scored))))
11518 (gnus-summary-update-line)))
11520 (defun gnus-summary-current-score ()
11521 "Return the score of the current article."
11523 (gnus-set-global-variables)
11524 (message "%s" (gnus-summary-article-score)))
11526 ;; Summary marking commands.
11528 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11529 "Mark articles which has the same subject as read, and then select the next.
11530 If UNMARK is positive, remove any kind of mark.
11531 If UNMARK is negative, tick articles."
11533 (gnus-set-global-variables)
11535 (setq unmark (prefix-numeric-value unmark)))
11537 (gnus-summary-mark-same-subject
11538 (gnus-summary-article-subject) unmark)))
11539 ;; Select next unread article. If auto-select-same mode, should
11540 ;; select the first unread article.
11541 (gnus-summary-next-article t (and gnus-auto-select-same
11542 (gnus-summary-article-subject)))
11543 (gnus-message 7 "%d article%s marked as %s"
11544 count (if (= count 1) " is" "s are")
11545 (if unmark "unread" "read"))))
11547 (defun gnus-summary-kill-same-subject (&optional unmark)
11548 "Mark articles which has the same subject as read.
11549 If UNMARK is positive, remove any kind of mark.
11550 If UNMARK is negative, tick articles."
11552 (gnus-set-global-variables)
11554 (setq unmark (prefix-numeric-value unmark)))
11556 (gnus-summary-mark-same-subject
11557 (gnus-summary-article-subject) unmark)))
11558 ;; If marked as read, go to next unread subject.
11560 ;; Go to next unread subject.
11561 (gnus-summary-next-subject 1 t))
11562 (gnus-message 7 "%d articles are marked as %s"
11563 count (if unmark "unread" "read"))))
11565 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11566 "Mark articles with same SUBJECT as read, and return marked number.
11567 If optional argument UNMARK is positive, remove any kinds of marks.
11568 If optional argument UNMARK is negative, mark articles as unread instead."
11572 ((null unmark) ; Mark as read.
11575 (gnus-summary-mark-article-as-read gnus-killed-mark)
11576 (gnus-summary-show-thread) t)
11577 (gnus-summary-find-subject subject))
11578 (setq count (1+ count))))
11579 ((> unmark 0) ; Tick.
11582 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11583 (gnus-summary-show-thread) t)
11584 (gnus-summary-find-subject subject))
11585 (setq count (1+ count))))
11586 (t ; Mark as unread.
11589 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11590 (gnus-summary-show-thread) t)
11591 (gnus-summary-find-subject subject))
11592 (setq count (1+ count)))))
11593 (gnus-set-mode-line 'summary)
11594 ;; Return the number of marked articles.
11597 (defun gnus-summary-mark-as-processable (n &optional unmark)
11598 "Set the process mark on the next N articles.
11599 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11600 the process mark instead. The difference between N and the actual
11601 number of articles marked is returned."
11603 (gnus-set-global-variables)
11604 (let ((backward (< n 0))
11609 (gnus-summary-remove-process-mark
11610 (gnus-summary-article-number))
11611 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11612 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11614 (if (/= 0 n) (gnus-message 7 "No more articles"))
11615 (gnus-summary-recenter)
11616 (gnus-summary-position-point)
11619 (defun gnus-summary-unmark-as-processable (n)
11620 "Remove the process mark from the next N articles.
11621 If N is negative, mark backward instead. The difference between N and
11622 the actual number of articles marked is returned."
11624 (gnus-set-global-variables)
11625 (gnus-summary-mark-as-processable n t))
11627 (defun gnus-summary-unmark-all-processable ()
11628 "Remove the process mark from all articles."
11630 (gnus-set-global-variables)
11632 (while gnus-newsgroup-processable
11633 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11634 (gnus-summary-position-point))
11636 (defun gnus-summary-mark-as-expirable (n)
11637 "Mark N articles forward as expirable.
11638 If N is negative, mark backward instead. The difference between N and
11639 the actual number of articles marked is returned."
11641 (gnus-set-global-variables)
11642 (gnus-summary-mark-forward n gnus-expirable-mark))
11644 (defun gnus-summary-mark-article-as-replied (article)
11645 "Mark ARTICLE replied and update the summary line."
11646 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11647 (let ((buffer-read-only nil))
11648 (when (gnus-summary-goto-subject article)
11649 (gnus-summary-update-secondary-mark article))))
11651 (defun gnus-summary-set-bookmark (article)
11652 "Set a bookmark in current article."
11653 (interactive (list (gnus-summary-article-number)))
11654 (gnus-set-global-variables)
11655 (if (or (not (get-buffer gnus-article-buffer))
11656 (not gnus-current-article)
11657 (not gnus-article-current)
11658 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11659 (error "No current article selected"))
11660 ;; Remove old bookmark, if one exists.
11661 (let ((old (assq article gnus-newsgroup-bookmarks)))
11662 (if old (setq gnus-newsgroup-bookmarks
11663 (delq old gnus-newsgroup-bookmarks))))
11664 ;; Set the new bookmark, which is on the form
11665 ;; (article-number . line-number-in-body).
11666 (setq gnus-newsgroup-bookmarks
11670 (set-buffer gnus-article-buffer)
11674 (goto-char (point-min))
11675 (search-forward "\n\n" nil t)
11678 gnus-newsgroup-bookmarks))
11679 (gnus-message 6 "A bookmark has been added to the current article."))
11681 (defun gnus-summary-remove-bookmark (article)
11682 "Remove the bookmark from the current article."
11683 (interactive (list (gnus-summary-article-number)))
11684 (gnus-set-global-variables)
11685 ;; Remove old bookmark, if one exists.
11686 (let ((old (assq article gnus-newsgroup-bookmarks)))
11689 (setq gnus-newsgroup-bookmarks
11690 (delq old gnus-newsgroup-bookmarks))
11691 (gnus-message 6 "Removed bookmark."))
11692 (gnus-message 6 "No bookmark in current article."))))
11694 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11695 (defun gnus-summary-mark-as-dormant (n)
11696 "Mark N articles forward as dormant.
11697 If N is negative, mark backward instead. The difference between N and
11698 the actual number of articles marked is returned."
11700 (gnus-set-global-variables)
11701 (gnus-summary-mark-forward n gnus-dormant-mark))
11703 (defun gnus-summary-set-process-mark (article)
11704 "Set the process mark on ARTICLE and update the summary line."
11705 (setq gnus-newsgroup-processable
11707 (delq article gnus-newsgroup-processable)))
11708 (when (gnus-summary-goto-subject article)
11709 (gnus-summary-show-thread)
11710 (gnus-summary-update-secondary-mark article)))
11712 (defun gnus-summary-remove-process-mark (article)
11713 "Remove the process mark from ARTICLE and update the summary line."
11714 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11715 (when (gnus-summary-goto-subject article)
11716 (gnus-summary-show-thread)
11717 (gnus-summary-update-secondary-mark article)))
11719 (defun gnus-summary-set-saved-mark (article)
11720 "Set the process mark on ARTICLE and update the summary line."
11721 (push article gnus-newsgroup-saved)
11722 (when (gnus-summary-goto-subject article)
11723 (gnus-summary-update-secondary-mark article)))
11725 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11726 "Mark N articles as read forwards.
11727 If N is negative, mark backwards instead.
11728 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11730 The difference between N and the actual number of articles marked is
11733 (gnus-set-global-variables)
11734 (let ((backward (< n 0))
11735 (gnus-summary-goto-unread
11736 (and gnus-summary-goto-unread
11737 (not (eq gnus-summary-goto-unread 'never))
11738 (not (memq mark (list gnus-unread-mark
11739 gnus-ticked-mark gnus-dormant-mark)))))
11741 (mark (or mark gnus-del-mark)))
11742 (while (and (> n 0)
11743 (gnus-summary-mark-article nil mark no-expire)
11744 (zerop (gnus-summary-next-subject
11746 (and gnus-summary-goto-unread
11747 (not (eq gnus-summary-goto-unread 'never)))
11750 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11751 (gnus-summary-recenter)
11752 (gnus-summary-position-point)
11753 (gnus-set-mode-line 'summary)
11756 (defun gnus-summary-mark-article-as-read (mark)
11757 "Mark the current article quickly as read with MARK."
11758 (let ((article (gnus-summary-article-number)))
11759 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11760 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11761 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11762 (setq gnus-newsgroup-reads
11763 (cons (cons article mark) gnus-newsgroup-reads))
11764 ;; Possibly remove from cache, if that is used.
11765 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11766 ;; Allow the backend to change the mark.
11767 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11768 ;; Check for auto-expiry.
11769 (when (and gnus-newsgroup-auto-expire
11770 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11771 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11772 (= mark gnus-ancient-mark)
11773 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11774 (setq mark gnus-expirable-mark)
11775 (push article gnus-newsgroup-expirable))
11776 ;; Set the mark in the buffer.
11777 (gnus-summary-update-mark mark 'unread)
11780 (defun gnus-summary-mark-article-as-unread (mark)
11781 "Mark the current article quickly as unread with MARK."
11782 (let ((article (gnus-summary-article-number)))
11783 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11784 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11785 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11786 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11787 (cond ((= mark gnus-ticked-mark)
11788 (push article gnus-newsgroup-marked))
11789 ((= mark gnus-dormant-mark)
11790 (push article gnus-newsgroup-dormant))
11792 (push article gnus-newsgroup-unreads)))
11793 (setq gnus-newsgroup-reads
11794 (delq (assq article gnus-newsgroup-reads)
11795 gnus-newsgroup-reads))
11797 ;; See whether the article is to be put in the cache.
11798 (and gnus-use-cache
11799 (vectorp (gnus-summary-article-header article))
11801 (gnus-cache-possibly-enter-article
11802 gnus-newsgroup-name article
11803 (gnus-summary-article-header article)
11804 (= mark gnus-ticked-mark)
11805 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11808 (gnus-summary-update-mark mark 'unread)
11811 (defun gnus-summary-mark-article (&optional article mark no-expire)
11812 "Mark ARTICLE with MARK. MARK can be any character.
11813 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11814 `??' (dormant) and `?E' (expirable).
11815 If MARK is nil, then the default character `?D' is used.
11816 If ARTICLE is nil, then the article on the current line will be
11818 ;; The mark might be a string.
11819 (and (stringp mark)
11820 (setq mark (aref mark 0)))
11821 ;; If no mark is given, then we check auto-expiring.
11822 (and (not no-expire)
11823 gnus-newsgroup-auto-expire
11825 (and (numberp mark)
11826 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11827 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11828 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11829 (setq mark gnus-expirable-mark))
11830 (let* ((mark (or mark gnus-del-mark))
11831 (article (or article (gnus-summary-article-number))))
11832 (or article (error "No article on current line"))
11833 (if (or (= mark gnus-unread-mark)
11834 (= mark gnus-ticked-mark)
11835 (= mark gnus-dormant-mark))
11836 (gnus-mark-article-as-unread article mark)
11837 (gnus-mark-article-as-read article mark))
11839 ;; See whether the article is to be put in the cache.
11840 (and gnus-use-cache
11841 (not (= mark gnus-canceled-mark))
11842 (vectorp (gnus-summary-article-header article))
11844 (gnus-cache-possibly-enter-article
11845 gnus-newsgroup-name article
11846 (gnus-summary-article-header article)
11847 (= mark gnus-ticked-mark)
11848 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11850 (if (gnus-summary-goto-subject article nil t)
11851 (let ((buffer-read-only nil))
11852 (gnus-summary-show-thread)
11854 (gnus-summary-update-mark mark 'unread)
11857 (defun gnus-summary-update-secondary-mark (article)
11858 "Update the secondary (read, process, cache) mark."
11859 (gnus-summary-update-mark
11860 (cond ((memq article gnus-newsgroup-processable)
11862 ((memq article gnus-newsgroup-cached)
11864 ((memq article gnus-newsgroup-replied)
11866 ((memq article gnus-newsgroup-saved)
11868 (t gnus-unread-mark))
11870 (when (gnus-visual-p 'summary-highlight 'highlight)
11871 (run-hooks 'gnus-summary-update-hook))
11874 (defun gnus-summary-update-mark (mark type)
11875 (beginning-of-line)
11876 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11877 (buffer-read-only nil))
11879 ;; Go to the right position on the line.
11880 (forward-char forward)
11881 ;; Replace the old mark with the new mark.
11882 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11883 ;; Optionally update the marks by some user rule.
11884 (when (eq type 'unread)
11885 (gnus-data-set-mark
11886 (gnus-data-find (gnus-summary-article-number)) mark)
11887 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11889 (defun gnus-mark-article-as-read (article &optional mark)
11890 "Enter ARTICLE in the pertinent lists and remove it from others."
11891 ;; Make the article expirable.
11892 (let ((mark (or mark gnus-del-mark)))
11893 (if (= mark gnus-expirable-mark)
11894 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11895 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11896 ;; Remove from unread and marked lists.
11897 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11898 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11899 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11900 (push (cons article mark) gnus-newsgroup-reads)
11901 ;; Possibly remove from cache, if that is used.
11902 (when gnus-use-cache
11903 (gnus-cache-enter-remove-article article))))
11905 (defun gnus-mark-article-as-unread (article &optional mark)
11906 "Enter ARTICLE in the pertinent lists and remove it from others."
11907 (let ((mark (or mark gnus-ticked-mark)))
11908 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11909 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11910 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11911 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11912 (cond ((= mark gnus-ticked-mark)
11913 (push article gnus-newsgroup-marked))
11914 ((= mark gnus-dormant-mark)
11915 (push article gnus-newsgroup-dormant))
11917 (push article gnus-newsgroup-unreads)))
11918 (setq gnus-newsgroup-reads
11919 (delq (assq article gnus-newsgroup-reads)
11920 gnus-newsgroup-reads))))
11922 (defalias 'gnus-summary-mark-as-unread-forward
11923 'gnus-summary-tick-article-forward)
11924 (make-obsolete 'gnus-summary-mark-as-unread-forward
11925 'gnus-summary-tick-article-forward)
11926 (defun gnus-summary-tick-article-forward (n)
11927 "Tick N articles forwards.
11928 If N is negative, tick backwards instead.
11929 The difference between N and the number of articles ticked is returned."
11931 (gnus-summary-mark-forward n gnus-ticked-mark))
11933 (defalias 'gnus-summary-mark-as-unread-backward
11934 'gnus-summary-tick-article-backward)
11935 (make-obsolete 'gnus-summary-mark-as-unread-backward
11936 'gnus-summary-tick-article-backward)
11937 (defun gnus-summary-tick-article-backward (n)
11938 "Tick N articles backwards.
11939 The difference between N and the number of articles ticked is returned."
11941 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11943 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11944 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11945 (defun gnus-summary-tick-article (&optional article clear-mark)
11946 "Mark current article as unread.
11947 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11948 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11950 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11951 gnus-ticked-mark)))
11953 (defun gnus-summary-mark-as-read-forward (n)
11954 "Mark N articles as read forwards.
11955 If N is negative, mark backwards instead.
11956 The difference between N and the actual number of articles marked is
11959 (gnus-summary-mark-forward n gnus-del-mark t))
11961 (defun gnus-summary-mark-as-read-backward (n)
11962 "Mark the N articles as read backwards.
11963 The difference between N and the actual number of articles marked is
11966 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11968 (defun gnus-summary-mark-as-read (&optional article mark)
11969 "Mark current article as read.
11970 ARTICLE specifies the article to be marked as read.
11971 MARK specifies a string to be inserted at the beginning of the line."
11972 (gnus-summary-mark-article article mark))
11974 (defun gnus-summary-clear-mark-forward (n)
11975 "Clear marks from N articles forward.
11976 If N is negative, clear backward instead.
11977 The difference between N and the number of marks cleared is returned."
11979 (gnus-summary-mark-forward n gnus-unread-mark))
11981 (defun gnus-summary-clear-mark-backward (n)
11982 "Clear marks from N articles backward.
11983 The difference between N and the number of marks cleared is returned."
11985 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11987 (defun gnus-summary-mark-unread-as-read ()
11988 "Intended to be used by `gnus-summary-mark-article-hook'."
11989 (when (memq gnus-current-article gnus-newsgroup-unreads)
11990 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11992 (defun gnus-summary-mark-read-and-unread-as-read ()
11993 "Intended to be used by `gnus-summary-mark-article-hook'."
11994 (let ((mark (gnus-summary-article-mark)))
11995 (when (or (gnus-unread-mark-p mark)
11996 (gnus-read-mark-p mark))
11997 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11999 (defun gnus-summary-mark-region-as-read (point mark all)
12000 "Mark all unread articles between point and mark as read.
12001 If given a prefix, mark all articles between point and mark as read,
12002 even ticked and dormant ones."
12003 (interactive "r\nP")
12007 (beginning-of-line)
12012 (memq (setq article (gnus-summary-article-number))
12013 gnus-newsgroup-unreads))
12014 (gnus-summary-mark-article article gnus-del-mark))
12016 (gnus-summary-find-next))))))
12018 (defun gnus-summary-mark-below (score mark)
12019 "Mark articles with score less than SCORE with MARK."
12020 (interactive "P\ncMark: ")
12021 (gnus-set-global-variables)
12022 (setq score (if score
12023 (prefix-numeric-value score)
12024 (or gnus-summary-default-score 0)))
12026 (set-buffer gnus-summary-buffer)
12027 (goto-char (point-min))
12030 (and (< (gnus-summary-article-score) score)
12031 (gnus-summary-mark-article nil mark))
12032 (gnus-summary-find-next)))))
12034 (defun gnus-summary-kill-below (&optional score)
12035 "Mark articles with score below SCORE as read."
12037 (gnus-set-global-variables)
12038 (gnus-summary-mark-below score gnus-killed-mark))
12040 (defun gnus-summary-clear-above (&optional score)
12041 "Clear all marks from articles with score above SCORE."
12043 (gnus-set-global-variables)
12044 (gnus-summary-mark-above score gnus-unread-mark))
12046 (defun gnus-summary-tick-above (&optional score)
12047 "Tick all articles with score above SCORE."
12049 (gnus-set-global-variables)
12050 (gnus-summary-mark-above score gnus-ticked-mark))
12052 (defun gnus-summary-mark-above (score mark)
12053 "Mark articles with score over SCORE with MARK."
12054 (interactive "P\ncMark: ")
12055 (gnus-set-global-variables)
12056 (setq score (if score
12057 (prefix-numeric-value score)
12058 (or gnus-summary-default-score 0)))
12060 (set-buffer gnus-summary-buffer)
12061 (goto-char (point-min))
12063 (if (> (gnus-summary-article-score) score)
12064 (gnus-summary-mark-article nil mark))
12066 (gnus-summary-find-next)))))
12068 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12069 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12070 (defun gnus-summary-limit-include-expunged ()
12071 "Display all the hidden articles that were expunged for low scores."
12073 (gnus-set-global-variables)
12074 (let ((buffer-read-only nil))
12075 (let ((scored gnus-newsgroup-scored)
12078 (or (gnus-summary-goto-subject (caar scored))
12079 (and (setq h (gnus-summary-article-header (caar scored)))
12080 (< (cdar scored) gnus-summary-expunge-below)
12081 (setq headers (cons h headers))))
12082 (setq scored (cdr scored)))
12083 (or headers (error "No expunged articles hidden."))
12084 (goto-char (point-min))
12085 (gnus-summary-prepare-unthreaded (nreverse headers)))
12086 (goto-char (point-min))
12087 (gnus-summary-position-point)))
12089 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12090 "Mark all articles not marked as unread in this newsgroup as read.
12091 If prefix argument ALL is non-nil, all articles are marked as read.
12092 If QUIETLY is non-nil, no questions will be asked.
12093 If TO-HERE is non-nil, it should be a point in the buffer. All
12094 articles before this point will be marked as read.
12095 The number of articles marked as read is returned."
12097 (gnus-set-global-variables)
12100 (not gnus-interactive-catchup) ;Without confirmation?
12104 "Mark absolutely all articles as read? "
12105 "Mark all unread articles as read? ")))
12107 (not gnus-newsgroup-adaptive)
12108 (not gnus-newsgroup-auto-expire))
12111 (setq gnus-newsgroup-marked nil
12112 gnus-newsgroup-dormant nil))
12113 (setq gnus-newsgroup-unreads nil))
12114 ;; We actually mark all articles as canceled, which we
12115 ;; have to do when using auto-expiry or adaptive scoring.
12116 (gnus-summary-show-all-threads)
12117 (if (gnus-summary-first-subject (not all))
12119 (if to-here (< (point) to-here) t)
12120 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12121 (gnus-summary-find-next (not all)))))
12123 (setq gnus-newsgroup-unreads nil))
12124 (gnus-set-mode-line 'summary)))
12125 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12126 (if (and (not to-here) (eq 'nnvirtual (car method)))
12127 (nnvirtual-catchup-group
12128 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12129 (gnus-summary-position-point)))
12131 (defun gnus-summary-catchup-to-here (&optional all)
12132 "Mark all unticked articles before the current one as read.
12133 If ALL is non-nil, also mark ticked and dormant articles as read."
12135 (gnus-set-global-variables)
12137 (let ((beg (point)))
12138 ;; We check that there are unread articles.
12139 (when (or all (gnus-summary-find-prev))
12140 (gnus-summary-catchup all t beg))))
12141 (gnus-summary-position-point))
12143 (defun gnus-summary-catchup-all (&optional quietly)
12144 "Mark all articles in this newsgroup as read."
12146 (gnus-set-global-variables)
12147 (gnus-summary-catchup t quietly))
12149 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12150 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12151 If prefix argument ALL is non-nil, all articles are marked as read."
12153 (gnus-set-global-variables)
12154 (gnus-summary-catchup all quietly nil 'fast)
12155 ;; Select next newsgroup or exit.
12156 (if (eq gnus-auto-select-next 'quietly)
12157 (gnus-summary-next-group nil)
12158 (gnus-summary-exit)))
12160 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12161 "Mark all articles in this newsgroup as read, and then exit."
12163 (gnus-set-global-variables)
12164 (gnus-summary-catchup-and-exit t quietly))
12166 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12167 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12168 "Mark all articles in this group as read and select the next group.
12169 If given a prefix, mark all articles, unread as well as ticked, as
12172 (gnus-set-global-variables)
12174 (gnus-summary-catchup all))
12175 (gnus-summary-next-article t nil nil t))
12177 ;; Thread-based commands.
12179 (defun gnus-summary-articles-in-thread (&optional article)
12180 "Return a list of all articles in the current thread.
12181 If ARTICLE is non-nil, return all articles in the thread that starts
12182 with that article."
12183 (let* ((article (or article (gnus-summary-article-number)))
12184 (data (gnus-data-find-list article))
12185 (top-level (gnus-data-level (car data)))
12187 (cond ((null gnus-thread-operation-ignore-subject)
12188 (gnus-simplify-subject-re
12189 (mail-header-subject (gnus-data-header (car data)))))
12190 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12191 (gnus-simplify-subject-fuzzy
12192 (mail-header-subject (gnus-data-header (car data)))))
12196 () ; This article doesn't exist.
12198 (and (or (not top-subject)
12199 (string= top-subject
12200 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12201 (gnus-simplify-subject-fuzzy
12202 (mail-header-subject
12203 (gnus-data-header (car data))))
12204 (gnus-simplify-subject-re
12205 (mail-header-subject
12206 (gnus-data-header (car data)))))))
12207 (setq articles (cons (gnus-data-number (car data)) articles)))
12208 (if (and (setq data (cdr data))
12209 (> (gnus-data-level (car data)) top-level))
12212 ;; Return the list of articles.
12213 (nreverse articles))))
12215 (defun gnus-summary-rethread-current ()
12216 "Rethread the thread the current article is part of."
12218 (gnus-set-global-variables)
12219 (let* ((gnus-show-threads t)
12220 (article (gnus-summary-article-number))
12221 (id (mail-header-id (gnus-summary-article-header)))
12222 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12224 (error "No article on the current line"))
12225 (gnus-rebuild-thread id)
12226 (gnus-summary-goto-subject article)))
12228 (defun gnus-summary-reparent-thread ()
12229 "Make current article child of the marked (or previous) article.
12231 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12232 is non-nil or the Subject: of both articles are the same."
12234 (or (not (gnus-group-read-only-p))
12235 (error "The current newsgroup does not support article editing."))
12236 (or (<= (length gnus-newsgroup-processable) 1)
12237 (error "No more than one article may be marked."))
12238 (save-window-excursion
12239 (let ((gnus-article-buffer " *reparent*")
12240 (current-article (gnus-summary-article-number))
12241 ; first grab the marked article, otherwise one line up.
12242 (parent-article (if (not (null gnus-newsgroup-processable))
12243 (car gnus-newsgroup-processable)
12245 (if (eq (forward-line -1) 0)
12246 (gnus-summary-article-number)
12247 (error "Beginning of summary buffer."))))))
12248 (or (not (eq current-article parent-article))
12249 (error "An article may not be self-referential."))
12250 (let ((message-id (mail-header-id
12251 (gnus-summary-article-header parent-article))))
12252 (or (and message-id (not (equal message-id "")))
12253 (error "No message-id in desired parent."))
12254 (gnus-summary-select-article t t nil current-article)
12255 (set-buffer gnus-article-buffer)
12256 (setq buffer-read-only nil)
12257 (let ((buf (format "%s" (buffer-string))))
12260 (goto-char (point-min))
12261 (if (search-forward-regexp "^References: " nil t)
12262 (insert message-id " " )
12263 (insert "References: " message-id "\n"))
12264 (or (gnus-request-replace-article current-article
12265 (car gnus-article-current)
12266 gnus-article-buffer)
12267 (error "Couldn't replace article."))
12268 (set-buffer gnus-summary-buffer)
12269 (gnus-summary-unmark-all-processable)
12270 (gnus-summary-rethread-current)
12271 (message "Article %d is now the child of article %d."
12272 current-article parent-article)))))
12274 (defun gnus-summary-toggle-threads (&optional arg)
12275 "Toggle showing conversation threads.
12276 If ARG is positive number, turn showing conversation threads on."
12278 (gnus-set-global-variables)
12279 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12280 (setq gnus-show-threads
12281 (if (null arg) (not gnus-show-threads)
12282 (> (prefix-numeric-value arg) 0)))
12283 (gnus-summary-prepare)
12284 (gnus-summary-goto-subject current)
12285 (gnus-summary-position-point)))
12287 (defun gnus-summary-show-all-threads ()
12288 "Show all threads."
12290 (gnus-set-global-variables)
12292 (let ((buffer-read-only nil))
12293 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12294 (gnus-summary-position-point))
12296 (defun gnus-summary-show-thread ()
12297 "Show thread subtrees.
12298 Returns nil if no thread was there to be shown."
12300 (gnus-set-global-variables)
12301 (let ((buffer-read-only nil)
12303 ;; first goto end then to beg, to have point at beg after let
12304 (end (progn (end-of-line) (point)))
12305 (beg (progn (beginning-of-line) (point))))
12307 ;; Any hidden lines here?
12308 (search-forward "\r" end t)
12309 (subst-char-in-region beg end ?\^M ?\n t)
12311 (gnus-summary-position-point))))
12313 (defun gnus-summary-hide-all-threads ()
12314 "Hide all thread subtrees."
12316 (gnus-set-global-variables)
12318 (goto-char (point-min))
12319 (gnus-summary-hide-thread)
12320 (while (zerop (gnus-summary-next-thread 1 t))
12321 (gnus-summary-hide-thread)))
12322 (gnus-summary-position-point))
12324 (defun gnus-summary-hide-thread ()
12325 "Hide thread subtrees.
12326 Returns nil if no threads were there to be hidden."
12328 (gnus-set-global-variables)
12329 (let ((buffer-read-only nil)
12331 (article (gnus-summary-article-number)))
12333 ;; Go forward until either the buffer ends or the subthread
12335 (when (and (not (eobp))
12336 (or (zerop (gnus-summary-next-thread 1 t))
12337 (goto-char (point-max))))
12339 (if (and (> (point) start)
12340 (search-backward "\n" start t))
12342 (subst-char-in-region start (point) ?\n ?\^M)
12343 (gnus-summary-goto-subject article))
12346 ;;(gnus-summary-position-point)
12349 (defun gnus-summary-go-to-next-thread (&optional previous)
12350 "Go to the same level (or less) next thread.
12351 If PREVIOUS is non-nil, go to previous thread instead.
12352 Return the article number moved to, or nil if moving was impossible."
12353 (let ((level (gnus-summary-thread-level))
12354 (way (if previous -1 1))
12357 (while (and (not (eobp))
12358 (< level (gnus-summary-thread-level)))
12359 (forward-line way))
12366 (gnus-summary-article-number)
12367 (goto-char beg)))))
12369 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12370 "Go to the same level (or less) next thread.
12371 If PREVIOUS is non-nil, go to previous thread instead.
12372 Return the article number moved to, or nil if moving was impossible."
12373 (if (and (eq gnus-summary-make-false-root 'dummy)
12374 (gnus-summary-article-intangible-p))
12375 (let ((beg (point)))
12376 (while (and (zerop (forward-line 1))
12377 (not (gnus-summary-article-intangible-p))
12378 (not (zerop (save-excursion
12379 (gnus-summary-thread-level))))))
12385 (let* ((level (gnus-summary-thread-level))
12386 (article (gnus-summary-article-number))
12387 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12390 (if (<= (gnus-data-level (car data)) level)
12391 (setq oart (gnus-data-number (car data))
12393 (setq data (cdr data))))
12395 (gnus-summary-goto-subject oart)))))
12397 (defun gnus-summary-next-thread (n &optional silent)
12398 "Go to the same level next N'th thread.
12399 If N is negative, search backward instead.
12400 Returns the difference between N and the number of skips actually
12403 If SILENT, don't output messages."
12405 (gnus-set-global-variables)
12406 (let ((backward (< n 0))
12409 (while (and (> n 0)
12410 (gnus-summary-go-to-next-thread backward))
12413 (gnus-summary-position-point))
12414 (when (and (not silent) (/= 0 n))
12415 (gnus-message 7 "No more threads"))
12418 (defun gnus-summary-prev-thread (n)
12419 "Go to the same level previous N'th thread.
12420 Returns the difference between N and the number of skips actually
12423 (gnus-set-global-variables)
12424 (gnus-summary-next-thread (- n)))
12426 (defun gnus-summary-go-down-thread ()
12427 "Go down one level in the current thread."
12428 (let ((children (gnus-summary-article-children)))
12430 (gnus-summary-goto-subject (car children)))))
12432 (defun gnus-summary-go-up-thread ()
12433 "Go up one level in the current thread."
12434 (let ((parent (gnus-summary-article-parent)))
12436 (gnus-summary-goto-subject parent))))
12438 (defun gnus-summary-down-thread (n)
12439 "Go down thread N steps.
12440 If N is negative, go up instead.
12441 Returns the difference between N and how many steps down that were
12444 (gnus-set-global-variables)
12447 (while (and (> n 0)
12448 (if up (gnus-summary-go-up-thread)
12449 (gnus-summary-go-down-thread)))
12451 (gnus-summary-position-point)
12452 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12455 (defun gnus-summary-up-thread (n)
12456 "Go up thread N steps.
12457 If N is negative, go up instead.
12458 Returns the difference between N and how many steps down that were
12461 (gnus-set-global-variables)
12462 (gnus-summary-down-thread (- n)))
12464 (defun gnus-summary-top-thread ()
12465 "Go to the top of the thread."
12467 (gnus-set-global-variables)
12468 (while (gnus-summary-go-up-thread))
12469 (gnus-summary-article-number))
12471 (defun gnus-summary-kill-thread (&optional unmark)
12472 "Mark articles under current thread as read.
12473 If the prefix argument is positive, remove any kinds of marks.
12474 If the prefix argument is negative, tick articles instead."
12476 (gnus-set-global-variables)
12478 (setq unmark (prefix-numeric-value unmark)))
12479 (let ((articles (gnus-summary-articles-in-thread)))
12481 ;; Expand the thread.
12482 (gnus-summary-show-thread)
12483 ;; Mark all the articles.
12485 (gnus-summary-goto-subject (car articles))
12486 (cond ((null unmark)
12487 (gnus-summary-mark-article-as-read gnus-killed-mark))
12489 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12491 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12492 (setq articles (cdr articles))))
12493 ;; Hide killed subtrees.
12495 gnus-thread-hide-killed
12496 (gnus-summary-hide-thread))
12497 ;; If marked as read, go to next unread subject.
12499 ;; Go to next unread subject.
12500 (gnus-summary-next-subject 1 t)))
12501 (gnus-set-mode-line 'summary))
12503 ;; Summary sorting commands
12505 (defun gnus-summary-sort-by-number (&optional reverse)
12506 "Sort summary buffer by article number.
12507 Argument REVERSE means reverse order."
12509 (gnus-summary-sort 'number reverse))
12511 (defun gnus-summary-sort-by-author (&optional reverse)
12512 "Sort summary buffer by author name alphabetically.
12513 If case-fold-search is non-nil, case of letters is ignored.
12514 Argument REVERSE means reverse order."
12516 (gnus-summary-sort 'author reverse))
12518 (defun gnus-summary-sort-by-subject (&optional reverse)
12519 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12520 If case-fold-search is non-nil, case of letters is ignored.
12521 Argument REVERSE means reverse order."
12523 (gnus-summary-sort 'subject reverse))
12525 (defun gnus-summary-sort-by-date (&optional reverse)
12526 "Sort summary buffer by date.
12527 Argument REVERSE means reverse order."
12529 (gnus-summary-sort 'date reverse))
12531 (defun gnus-summary-sort-by-score (&optional reverse)
12532 "Sort summary buffer by score.
12533 Argument REVERSE means reverse order."
12535 (gnus-summary-sort 'score reverse))
12537 (defun gnus-summary-sort (predicate reverse)
12538 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12539 (gnus-set-global-variables)
12540 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12541 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12542 (gnus-thread-sort-functions
12547 (,thread t2 t1)))))
12548 (gnus-article-sort-functions
12553 (,article t2 t1)))))
12555 (gnus-summary-prepare-hook nil))
12556 ;; We do the sorting by regenerating the threads.
12557 (gnus-summary-prepare)
12558 ;; Hide subthreads if needed.
12559 (when (and gnus-show-threads gnus-thread-hide-subtree)
12560 (gnus-summary-hide-all-threads)))
12561 ;; If in async mode, we send some info to the backend.
12562 (when gnus-newsgroup-async
12563 (gnus-request-asynchronous
12564 gnus-newsgroup-name gnus-newsgroup-data)))
12566 (defun gnus-sortable-date (date)
12567 "Make sortable string by string-lessp from DATE.
12568 Timezone package is used."
12569 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12570 (year (aref date 0))
12571 (month (aref date 1))
12572 (day (aref date 2)))
12573 (timezone-make-sortable-date
12575 (timezone-make-time-string
12576 (aref date 3) (aref date 4) (aref date 5)))))
12578 ;; Summary saving commands.
12580 (defun gnus-summary-save-article (&optional n not-saved)
12581 "Save the current article using the default saver function.
12582 If N is a positive number, save the N next articles.
12583 If N is a negative number, save the N previous articles.
12584 If N is nil and any articles have been marked with the process mark,
12585 save those articles instead.
12586 The variable `gnus-default-article-saver' specifies the saver function."
12588 (gnus-set-global-variables)
12589 (let ((articles (gnus-summary-work-articles n))
12590 file header article)
12592 (setq header (gnus-summary-article-header
12593 (setq article (pop articles))))
12594 (if (not (vectorp header))
12595 ;; This is a pseudo-article.
12596 (if (assq 'name header)
12597 (gnus-copy-file (cdr (assq 'name header)))
12598 (gnus-message 1 "Article %d is unsaveable" article))
12599 ;; This is a real article.
12600 (save-window-excursion
12601 (gnus-summary-select-article t nil nil article))
12602 (unless gnus-save-all-headers
12603 ;; Remove headers accoring to `gnus-saved-headers'.
12604 (let ((gnus-visible-headers
12605 (or gnus-saved-headers gnus-visible-headers)))
12606 (gnus-article-hide-headers nil t)))
12607 ;; Remove any X-Gnus lines.
12609 (set-buffer gnus-article-buffer)
12611 (let ((buffer-read-only nil))
12612 (nnheader-narrow-to-headers)
12613 (while (re-search-forward "^X-Gnus" nil t)
12614 (gnus-delete-line)))))
12615 (save-window-excursion
12616 (if (not gnus-default-article-saver)
12617 (error "No default saver is defined.")
12618 (setq file (funcall
12619 gnus-default-article-saver
12621 ((not gnus-prompt-before-saving)
12623 ((eq gnus-prompt-before-saving 'always)
12626 (gnus-summary-remove-process-mark article)
12628 (gnus-summary-set-saved-mark article))))
12629 (gnus-summary-position-point)
12632 (defun gnus-summary-pipe-output (&optional arg)
12633 "Pipe the current article to a subprocess.
12634 If N is a positive number, pipe the N next articles.
12635 If N is a negative number, pipe the N previous articles.
12636 If N is nil and any articles have been marked with the process mark,
12637 pipe those articles instead."
12639 (gnus-set-global-variables)
12640 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12641 (gnus-summary-save-article arg t))
12642 (gnus-configure-windows 'pipe))
12644 (defun gnus-summary-save-article-mail (&optional arg)
12645 "Append the current article to an mail file.
12646 If N is a positive number, save the N next articles.
12647 If N is a negative number, save the N previous articles.
12648 If N is nil and any articles have been marked with the process mark,
12649 save those articles instead."
12651 (gnus-set-global-variables)
12652 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12653 (gnus-summary-save-article arg)))
12655 (defun gnus-summary-save-article-rmail (&optional arg)
12656 "Append the current article to an rmail file.
12657 If N is a positive number, save the N next articles.
12658 If N is a negative number, save the N previous articles.
12659 If N is nil and any articles have been marked with the process mark,
12660 save those articles instead."
12662 (gnus-set-global-variables)
12663 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12664 (gnus-summary-save-article arg)))
12666 (defun gnus-summary-save-article-file (&optional arg)
12667 "Append the current article to a file.
12668 If N is a positive number, save the N next articles.
12669 If N is a negative number, save the N previous articles.
12670 If N is nil and any articles have been marked with the process mark,
12671 save those articles instead."
12673 (gnus-set-global-variables)
12674 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12675 (gnus-summary-save-article arg)))
12677 (defun gnus-summary-save-article-body-file (&optional arg)
12678 "Append the current article body to a file.
12679 If N is a positive number, save the N next articles.
12680 If N is a negative number, save the N previous articles.
12681 If N is nil and any articles have been marked with the process mark,
12682 save those articles instead."
12684 (gnus-set-global-variables)
12685 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12686 (gnus-summary-save-article arg)))
12688 (defun gnus-get-split-value (methods)
12689 "Return a value based on the split METHODS."
12690 (let (split-name method result match)
12693 (set-buffer gnus-original-article-buffer)
12695 (nnheader-narrow-to-headers)
12697 (goto-char (point-min))
12698 (setq method (pop methods))
12699 (setq match (car method))
12702 ;; Regular expression.
12704 (re-search-forward match nil t)
12706 ((gnus-functionp match)
12710 (setq result (funcall match gnus-newsgroup-name))))
12715 (setq result (eval match)))))
12716 (setq split-name (append (cdr method) split-name))
12717 (cond ((stringp result)
12718 (push result split-name))
12720 (setq split-name (append result split-name)))))))))
12723 (defun gnus-read-move-group-name (prompt default articles prefix)
12724 "Read a group name."
12725 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12727 (format "Where do you want to %s %s? "
12729 (if (> (length articles) 1)
12730 (format "these %d articles" (length articles))
12738 (format "(default %s) " default)
12740 gnus-active-hashtb nil nil prefix))
12741 ((= 1 (length split-name))
12742 (completing-read prom gnus-active-hashtb
12743 nil nil (cons (car split-name) 0)))
12746 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12749 (if (or (string= to-newsgroup "")
12750 (string= to-newsgroup prefix))
12751 (setq to-newsgroup (or default "")))
12752 (or (gnus-active to-newsgroup)
12753 (gnus-activate-group to-newsgroup)
12754 (error "No such group: %s" to-newsgroup)))
12757 (defun gnus-read-save-file-name (prompt default-name)
12758 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12760 ;; Let the split methods have their say.
12762 ;; No split name was found.
12765 (concat prompt " (default "
12766 (file-name-nondirectory default-name) ") ")
12767 (file-name-directory default-name)
12769 ;; A single split name was found
12770 ((= 1 (length split-name))
12772 (concat prompt " (default " (car split-name) ") ")
12773 gnus-article-save-directory
12774 (concat gnus-article-save-directory (car split-name))))
12775 ;; A list of splits was found.
12777 (setq split-name (mapcar (lambda (el) (list el))
12778 (nreverse split-name)))
12779 (let ((result (completing-read
12780 (concat prompt " ") split-name nil nil)))
12781 (concat gnus-article-save-directory
12782 (if (string= result "")
12785 ;; If we have read a directory, we append the default file name.
12786 (when (file-directory-p file)
12787 (setq file (concat (file-name-as-directory file)
12788 (file-name-nondirectory default-name))))
12789 ;; Possibly translate some charaters.
12790 (nnheader-translate-file-chars file)))
12792 (defun gnus-article-archive-name (group)
12793 "Return the first instance of an \"Archive-name\" in the current buffer."
12794 (let ((case-fold-search t))
12795 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12796 (match-string 1))))
12798 (defun gnus-summary-save-in-rmail (&optional filename)
12799 "Append this article to Rmail file.
12800 Optional argument FILENAME specifies file name.
12801 Directory to save to is default to `gnus-article-save-directory' which
12802 is initialized from the SAVEDIR environment variable."
12804 (gnus-set-global-variables)
12805 (let ((default-name
12806 (funcall gnus-rmail-save-name gnus-newsgroup-name
12807 gnus-current-headers gnus-newsgroup-last-rmail)))
12809 (cond ((eq filename 'default)
12811 (filename filename)
12812 (t (gnus-read-save-file-name
12813 "Save in rmail file:" default-name))))
12814 (gnus-make-directory (file-name-directory filename))
12815 (gnus-eval-in-buffer-window
12816 gnus-original-article-buffer
12820 (gnus-output-to-rmail filename))))
12821 ;; Remember the directory name to save articles
12822 (setq gnus-newsgroup-last-rmail filename)))
12824 (defun gnus-summary-save-in-mail (&optional filename)
12825 "Append this article to Unix mail file.
12826 Optional argument FILENAME specifies file name.
12827 Directory to save to is default to `gnus-article-save-directory' which
12828 is initialized from the SAVEDIR environment variable."
12830 (gnus-set-global-variables)
12831 (let ((default-name
12832 (funcall gnus-mail-save-name gnus-newsgroup-name
12833 gnus-current-headers gnus-newsgroup-last-mail)))
12835 (cond ((eq filename 'default)
12837 (filename filename)
12838 (t (gnus-read-save-file-name
12839 "Save in Unix mail file:" default-name))))
12841 (expand-file-name filename
12843 (file-name-directory default-name))))
12844 (gnus-make-directory (file-name-directory filename))
12845 (gnus-eval-in-buffer-window
12846 gnus-original-article-buffer
12850 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12851 (gnus-output-to-rmail filename)
12852 (let ((mail-use-rfc822 t))
12853 (rmail-output filename 1 t t))))))
12854 ;; Remember the directory name to save articles.
12855 (setq gnus-newsgroup-last-mail filename)))
12857 (defun gnus-summary-save-in-file (&optional filename)
12858 "Append this article to file.
12859 Optional argument FILENAME specifies file name.
12860 Directory to save to is default to `gnus-article-save-directory' which
12861 is initialized from the SAVEDIR environment variable."
12863 (gnus-set-global-variables)
12864 (let ((default-name
12865 (funcall gnus-file-save-name gnus-newsgroup-name
12866 gnus-current-headers gnus-newsgroup-last-file)))
12868 (cond ((eq filename 'default)
12870 (filename filename)
12871 (t (gnus-read-save-file-name
12872 "Save in file:" default-name))))
12873 (gnus-make-directory (file-name-directory filename))
12874 (gnus-eval-in-buffer-window
12875 gnus-original-article-buffer
12879 (gnus-output-to-file filename))))
12880 ;; Remember the directory name to save articles.
12881 (setq gnus-newsgroup-last-file filename)))
12883 (defun gnus-summary-save-body-in-file (&optional filename)
12884 "Append this article body to a file.
12885 Optional argument FILENAME specifies file name.
12886 The directory to save in defaults to `gnus-article-save-directory' which
12887 is initialized from the SAVEDIR environment variable."
12889 (gnus-set-global-variables)
12890 (let ((default-name
12891 (funcall gnus-file-save-name gnus-newsgroup-name
12892 gnus-current-headers gnus-newsgroup-last-file)))
12894 (cond ((eq filename 'default)
12896 (filename filename)
12897 (t (gnus-read-save-file-name
12898 "Save body in file:" default-name))))
12899 (gnus-make-directory (file-name-directory filename))
12900 (gnus-eval-in-buffer-window
12901 gnus-article-buffer
12905 (goto-char (point-min))
12906 (and (search-forward "\n\n" nil t)
12907 (narrow-to-region (point) (point-max)))
12908 (gnus-output-to-file filename))))
12909 ;; Remember the directory name to save articles.
12910 (setq gnus-newsgroup-last-file filename)))
12912 (defun gnus-summary-save-in-pipe (&optional command)
12913 "Pipe this article to subprocess."
12915 (gnus-set-global-variables)
12917 (cond ((eq command 'default)
12918 gnus-last-shell-command)
12920 (t (read-string "Shell command on article: "
12921 gnus-last-shell-command))))
12922 (if (string-equal command "")
12923 (setq command gnus-last-shell-command))
12924 (gnus-eval-in-buffer-window
12925 gnus-article-buffer
12928 (shell-command-on-region (point-min) (point-max) command nil)))
12929 (setq gnus-last-shell-command command))
12931 ;; Summary extract commands
12933 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12934 (let ((buffer-read-only nil)
12935 (article (gnus-summary-article-number))
12937 (or (gnus-summary-goto-subject article)
12938 (error (format "No such article: %d" article)))
12939 (gnus-summary-position-point)
12940 ;; If all commands are to be bunched up on one line, we collect
12942 (if gnus-view-pseudos-separately
12944 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12947 (setq action (cdr (assq 'action (car ps))))
12948 (setq files (list (cdr (assq 'name (car ps)))))
12949 (while (and ps (cdr ps)
12950 (string= (or action "1")
12951 (or (cdr (assq 'action (cadr ps))) "2")))
12952 (setq files (cons (cdr (assq 'name (cadr ps))) files))
12953 (setcdr ps (cddr ps)))
12956 (if (not (string-match "%s" action))
12957 (setq files (cons " " files)))
12958 (setq files (cons " " files))
12959 (and (assq 'execute (car ps))
12960 (setcdr (assq 'execute (car ps))
12961 (funcall (if (string-match "%s" action)
12964 (mapconcat (lambda (f) f) files " ")))))
12965 (setq ps (cdr ps)))))
12966 (if (and gnus-view-pseudos (not not-view))
12968 (and (assq 'execute (car pslist))
12969 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12970 (eq gnus-view-pseudos 'not-confirm)))
12971 (setq pslist (cdr pslist)))
12974 (setq after-article (or (cdr (assq 'article (car pslist)))
12975 (gnus-summary-article-number)))
12976 (gnus-summary-goto-subject after-article)
12979 (insert " " (file-name-nondirectory
12980 (cdr (assq 'name (car pslist))))
12981 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12983 (forward-line -1) ; back to `b'
12984 (add-text-properties
12985 b e (list 'gnus-number gnus-reffed-article-number
12986 gnus-mouse-face-prop gnus-mouse-face))
12988 after-article gnus-reffed-article-number
12989 gnus-unread-mark b (car pslist) 0 (- e b))
12990 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12991 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12992 (setq pslist (cdr pslist)))))))
12994 (defun gnus-pseudos< (p1 p2)
12995 (let ((c1 (cdr (assq 'action p1)))
12996 (c2 (cdr (assq 'action p2))))
12997 (and c1 c2 (string< c1 c2))))
12999 (defun gnus-request-pseudo-article (props)
13000 (cond ((assq 'execute props)
13001 (gnus-execute-command (cdr (assq 'execute props)))))
13002 (let ((gnus-current-article (gnus-summary-article-number)))
13003 (run-hooks 'gnus-mark-article-hook)))
13005 (defun gnus-execute-command (command &optional automatic)
13007 (gnus-article-setup-buffer)
13008 (set-buffer gnus-article-buffer)
13009 (let ((command (if automatic command (read-string "Command: " command)))
13010 (buffer-read-only nil))
13012 (insert "$ " command "\n\n")
13013 (if gnus-view-pseudo-asynchronously
13014 (start-process "gnus-execute" nil "sh" "-c" command)
13015 (call-process "sh" nil t nil "-c" command)))))
13017 (defun gnus-copy-file (file &optional to)
13020 (list (read-file-name "Copy file: " default-directory)
13021 (read-file-name "Copy file to: " default-directory)))
13022 (gnus-set-global-variables)
13023 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13024 (and (file-directory-p to)
13025 (setq to (concat (file-name-as-directory to)
13026 (file-name-nondirectory file))))
13027 (copy-file file to))
13029 ;; Summary kill commands.
13031 (defun gnus-summary-edit-global-kill (article)
13032 "Edit the \"global\" kill file."
13033 (interactive (list (gnus-summary-article-number)))
13034 (gnus-set-global-variables)
13035 (gnus-group-edit-global-kill article))
13037 (defun gnus-summary-edit-local-kill ()
13038 "Edit a local kill file applied to the current newsgroup."
13040 (gnus-set-global-variables)
13041 (setq gnus-current-headers (gnus-summary-article-header))
13042 (gnus-set-global-variables)
13043 (gnus-group-edit-local-kill
13044 (gnus-summary-article-number) gnus-newsgroup-name))
13048 ;;; Gnus article mode
13051 (put 'gnus-article-mode 'mode-class 'special)
13053 (if gnus-article-mode-map
13055 (setq gnus-article-mode-map (make-keymap))
13056 (suppress-keymap gnus-article-mode-map)
13058 (gnus-define-keys gnus-article-mode-map
13059 " " gnus-article-goto-next-page
13060 "\177" gnus-article-goto-prev-page
13061 [delete] gnus-article-goto-prev-page
13062 "\C-c^" gnus-article-refer-article
13063 "h" gnus-article-show-summary
13064 "s" gnus-article-show-summary
13065 "\C-c\C-m" gnus-article-mail
13066 "?" gnus-article-describe-briefly
13067 gnus-mouse-2 gnus-article-push-button
13068 "\r" gnus-article-press-button
13069 "\t" gnus-article-next-button
13070 "\M-\t" gnus-article-prev-button
13071 "\C-c\C-b" gnus-bug)
13073 (substitute-key-definition
13074 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13076 (defun gnus-article-mode ()
13077 "Major mode for displaying an article.
13079 All normal editing commands are switched off.
13081 The following commands are available:
13083 \\<gnus-article-mode-map>
13084 \\[gnus-article-next-page]\t Scroll the article one page forwards
13085 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13086 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13087 \\[gnus-article-show-summary]\t Display the summary buffer
13088 \\[gnus-article-mail]\t Send a reply to the address near point
13089 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13090 \\[gnus-info-find-node]\t Go to the Gnus info node"
13092 (when (and menu-bar-mode
13093 (gnus-visual-p 'article-menu 'menu))
13094 (gnus-article-make-menu-bar))
13095 (kill-all-local-variables)
13096 (gnus-simplify-mode-line)
13097 (setq mode-name "Article")
13098 (setq major-mode 'gnus-article-mode)
13099 (make-local-variable 'minor-mode-alist)
13100 (or (assq 'gnus-show-mime minor-mode-alist)
13101 (setq minor-mode-alist
13102 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13103 (use-local-map gnus-article-mode-map)
13104 (make-local-variable 'page-delimiter)
13105 (setq page-delimiter gnus-page-delimiter)
13106 (buffer-disable-undo (current-buffer))
13107 (setq buffer-read-only t) ;Disable modification
13108 (run-hooks 'gnus-article-mode-hook))
13110 (defun gnus-article-setup-buffer ()
13111 "Initialize the article buffer."
13112 (let* ((name (if gnus-single-article-buffer "*Article*"
13113 (concat "*Article " gnus-newsgroup-name "*")))
13115 (progn (string-match "\\*Article" name)
13116 (concat " *Original Article"
13117 (substring name (match-end 0))))))
13118 (setq gnus-article-buffer name)
13119 (setq gnus-original-article-buffer original)
13120 ;; This might be a variable local to the summary buffer.
13121 (unless gnus-single-article-buffer
13123 (set-buffer gnus-summary-buffer)
13124 (setq gnus-article-buffer name)
13125 (setq gnus-original-article-buffer original)
13126 (gnus-set-global-variables))
13127 (make-local-variable 'gnus-summary-buffer))
13128 (if (get-buffer name)
13131 (buffer-disable-undo (current-buffer))
13132 (setq buffer-read-only t)
13133 (gnus-add-current-to-buffer-list)
13134 (or (eq major-mode 'gnus-article-mode)
13135 (gnus-article-mode))
13138 (set-buffer (get-buffer-create name))
13139 (gnus-add-current-to-buffer-list)
13140 (gnus-article-mode)
13141 (current-buffer)))))
13143 ;; Set article window start at LINE, where LINE is the number of lines
13144 ;; from the head of the article.
13145 (defun gnus-article-set-window-start (&optional line)
13147 (get-buffer-window gnus-article-buffer)
13149 (set-buffer gnus-article-buffer)
13150 (goto-char (point-min))
13153 (gnus-message 6 "Moved to bookmark")
13154 (search-forward "\n\n" nil t)
13155 (forward-line line)
13158 (defun gnus-kill-all-overlays ()
13159 "Delete all overlays in the current buffer."
13160 (when (fboundp 'overlay-lists)
13161 (let* ((overlayss (overlay-lists))
13162 (buffer-read-only nil)
13163 (overlays (nconc (car overlayss) (cdr overlayss))))
13165 (delete-overlay (pop overlays))))))
13167 (defun gnus-request-article-this-buffer (article group)
13168 "Get an article and insert it into this buffer."
13169 (let (do-update-line)
13173 (gnus-kill-all-overlays)
13174 (setq group (or group gnus-newsgroup-name))
13176 ;; Open server if it has closed.
13177 (gnus-check-server (gnus-find-method-for-group group))
13179 ;; Using `gnus-request-article' directly will insert the article into
13180 ;; `nntp-server-buffer' - so we'll save some time by not having to
13181 ;; copy it from the server buffer into the article buffer.
13183 ;; We only request an article by message-id when we do not have the
13184 ;; headers for it, so we'll have to get those.
13185 (when (stringp article)
13186 (let ((gnus-override-method gnus-refer-article-method))
13187 (gnus-read-header article)))
13189 ;; If the article number is negative, that means that this article
13190 ;; doesn't belong in this newsgroup (possibly), so we find its
13191 ;; message-id and request it by id instead of number.
13192 (when (and (numberp article)
13193 gnus-summary-buffer
13194 (get-buffer gnus-summary-buffer)
13195 (buffer-name (get-buffer gnus-summary-buffer)))
13197 (set-buffer gnus-summary-buffer)
13198 (let ((header (gnus-summary-article-header article)))
13201 ((memq article gnus-newsgroup-sparse)
13202 ;; This is a sparse gap article.
13203 (setq do-update-line article)
13204 (setq article (mail-header-id header))
13205 (let ((gnus-override-method gnus-refer-article-method))
13206 (gnus-read-header article)))
13208 ;; It's a real article.
13209 (setq article (mail-header-id header)))
13211 ;; It is an extracted pseudo-article.
13212 (setq article 'pseudo)
13213 (gnus-request-pseudo-article header))))
13215 (let ((method (gnus-find-method-for-group
13216 gnus-newsgroup-name)))
13217 (if (not (eq (car method) 'nneething))
13219 (let ((dir (concat (file-name-as-directory (nth 1 method))
13220 (mail-header-subject header))))
13221 (if (file-directory-p dir)
13223 (setq article 'nneething)
13224 (gnus-group-enter-directory dir)))))))))
13227 ;; We first check `gnus-original-article-buffer'.
13228 ((and (equal (car gnus-original-article) group)
13229 (eq (cdr gnus-original-article) article)
13230 (get-buffer gnus-original-article-buffer))
13231 (insert-buffer-substring gnus-original-article-buffer)
13233 ;; Check the backlog.
13234 ((and gnus-keep-backlog
13235 (gnus-backlog-request-article group article (current-buffer)))
13237 ;; Check the cache.
13238 ((and gnus-use-cache
13240 (gnus-cache-request-article article group))
13242 ;; Get the article and put into the article buffer.
13243 ((or (stringp article) (numberp article))
13244 (let ((gnus-override-method
13245 (and (stringp article) gnus-refer-article-method))
13246 (buffer-read-only nil))
13248 (gnus-kill-all-overlays)
13249 (if (gnus-request-article article group (current-buffer))
13251 (and gnus-keep-backlog
13252 (gnus-backlog-enter-article
13253 group article (current-buffer)))
13255 ;; It was a pseudo.
13258 ;; Take the article from the original article buffer
13259 ;; and place it in the buffer it's supposed to be in.
13260 (when (and (get-buffer gnus-article-buffer)
13261 (equal (buffer-name (current-buffer))
13262 (buffer-name (get-buffer gnus-article-buffer))))
13264 (setq gnus-original-article (cons group article))
13265 (if (get-buffer gnus-original-article-buffer)
13266 (set-buffer (get-buffer gnus-original-article-buffer))
13267 (set-buffer (get-buffer-create gnus-original-article-buffer))
13268 (buffer-disable-undo (current-buffer))
13269 (setq major-mode 'gnus-original-article-mode)
13270 (setq buffer-read-only t)
13271 (gnus-add-current-to-buffer-list))
13272 (let (buffer-read-only)
13274 (insert-buffer-substring gnus-article-buffer))))
13276 ;; Update sparse articles.
13277 (when do-update-line
13279 (set-buffer gnus-summary-buffer)
13280 (gnus-summary-update-article do-update-line)
13281 (gnus-summary-goto-subject do-update-line)
13282 (set-window-point (get-buffer-window (current-buffer) t)
13285 (defun gnus-read-header (id &optional header)
13286 "Read the headers of article ID and enter them into the Gnus system."
13287 (let ((group gnus-newsgroup-name)
13289 ;; First we check to see whether the header in question is already
13292 ;; This is a Message-ID.
13293 (setq header (or header (gnus-id-to-header id)))
13294 ;; This is an article number.
13295 (setq header (or header (gnus-summary-article-header id))))
13297 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13298 ;; We have found the header.
13300 ;; We have to really fetch the header to this article.
13302 (if (gnus-check-backend-function 'request-head group)
13303 (gnus-request-head id group)
13304 (gnus-request-article id group)))
13306 (set-buffer nntp-server-buffer)
13307 (and (search-forward "\n\n" nil t)
13308 (delete-region (1- (point)) (point-max)))
13309 (goto-char (point-max))
13311 (goto-char (point-min))
13315 ((cdr where) (cdr where))
13316 (header (mail-header-number header))
13317 (t gnus-reffed-article-number))
13319 (insert " Article retrieved.\n"))
13321 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13322 ; (setcar (gnus-id-to-thread id) nil))
13323 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13324 () ; Malformed head.
13325 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13326 (if (and (stringp id)
13327 (not (string= (gnus-group-real-name group)
13329 ;; If we fetched by Message-ID and the article came
13330 ;; from a different group, we fudge some bogus article
13331 ;; numbers for this article.
13332 (mail-header-set-number header gnus-reffed-article-number))
13333 (decf gnus-reffed-article-number)
13334 (push header gnus-newsgroup-headers)
13335 (setq gnus-current-headers header)
13336 (push (mail-header-number header) gnus-newsgroup-limit))
13339 (defun gnus-article-prepare (article &optional all-headers header)
13340 "Prepare ARTICLE in article mode buffer.
13341 ARTICLE should either be an article number or a Message-ID.
13342 If ARTICLE is an id, HEADER should be the article headers.
13343 If ALL-HEADERS is non-nil, no headers are hidden."
13345 ;; Make sure we start in a summary buffer.
13346 (unless (eq major-mode 'gnus-summary-mode)
13347 (set-buffer gnus-summary-buffer))
13348 (setq gnus-summary-buffer (current-buffer))
13349 ;; Make sure the connection to the server is alive.
13350 (unless (gnus-server-opened
13351 (gnus-find-method-for-group gnus-newsgroup-name))
13352 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13353 (gnus-request-group gnus-newsgroup-name t))
13354 (let* ((article (if header (mail-header-number header) article))
13355 (summary-buffer (current-buffer))
13356 (internal-hook gnus-article-internal-prepare-hook)
13357 (group gnus-newsgroup-name)
13360 (gnus-article-setup-buffer)
13361 (set-buffer gnus-article-buffer)
13362 ;; Deactivate active regions.
13363 (when (and (boundp 'transient-mark-mode)
13364 transient-mark-mode)
13365 (setq mark-active nil))
13366 (if (not (setq result (let ((buffer-read-only nil))
13367 (gnus-request-article-this-buffer
13369 ;; There is no such article.
13371 (when (and (numberp article)
13372 (not (memq article gnus-newsgroup-sparse)))
13373 (setq gnus-article-current
13374 (cons gnus-newsgroup-name article))
13375 (set-buffer gnus-summary-buffer)
13376 (setq gnus-current-article article)
13377 (gnus-summary-mark-article article gnus-canceled-mark))
13378 (unless (memq article gnus-newsgroup-sparse)
13380 1 "No such article (may have expired or been canceled)")
13383 (if (or (eq result 'pseudo) (eq result 'nneething))
13386 (set-buffer summary-buffer)
13387 (setq gnus-last-article gnus-current-article
13388 gnus-newsgroup-history (cons gnus-current-article
13389 gnus-newsgroup-history)
13390 gnus-current-article 0
13391 gnus-current-headers nil
13392 gnus-article-current nil)
13393 (if (eq result 'nneething)
13394 (gnus-configure-windows 'summary)
13395 (gnus-configure-windows 'article))
13396 (gnus-set-global-variables))
13397 (gnus-set-mode-line 'article))
13398 ;; The result from the `request' was an actual article -
13399 ;; or at least some text that is now displayed in the
13401 (if (and (numberp article)
13402 (not (eq article gnus-current-article)))
13403 ;; Seems like a new article has been selected.
13404 ;; `gnus-current-article' must be an article number.
13406 (set-buffer summary-buffer)
13407 (setq gnus-last-article gnus-current-article
13408 gnus-newsgroup-history (cons gnus-current-article
13409 gnus-newsgroup-history)
13410 gnus-current-article article
13411 gnus-current-headers
13412 (gnus-summary-article-header gnus-current-article)
13413 gnus-article-current
13414 (cons gnus-newsgroup-name gnus-current-article))
13415 (unless (vectorp gnus-current-headers)
13416 (setq gnus-current-headers nil))
13417 (gnus-summary-show-thread)
13418 (run-hooks 'gnus-mark-article-hook)
13419 (gnus-set-mode-line 'summary)
13420 (and (gnus-visual-p 'article-highlight 'highlight)
13421 (run-hooks 'gnus-visual-mark-article-hook))
13422 ;; Set the global newsgroup variables here.
13423 ;; Suggested by Jim Sisolak
13424 ;; <sisolak@trans4.neep.wisc.edu>.
13425 (gnus-set-global-variables)
13426 (setq gnus-have-all-headers
13427 (or all-headers gnus-show-all-headers))
13428 (and gnus-use-cache
13429 (vectorp (gnus-summary-article-header article))
13430 (gnus-cache-possibly-enter-article
13432 (gnus-summary-article-header article)
13433 (memq article gnus-newsgroup-marked)
13434 (memq article gnus-newsgroup-dormant)
13435 (memq article gnus-newsgroup-unreads)))))
13436 ;; Hooks for getting information from the article.
13437 ;; This hook must be called before being narrowed.
13438 (let (buffer-read-only)
13439 (run-hooks 'internal-hook)
13440 (run-hooks 'gnus-article-prepare-hook)
13441 ;; Decode MIME message.
13443 (if (or (not gnus-strict-mime)
13444 (gnus-fetch-field "Mime-Version"))
13445 (funcall gnus-show-mime-method)
13446 (funcall gnus-decode-encoded-word-method)))
13447 ;; Perform the article display hooks.
13448 (run-hooks 'gnus-article-display-hook))
13450 (goto-char (point-min))
13451 (and gnus-break-pages (gnus-narrow-to-page))
13452 (gnus-set-mode-line 'article)
13453 (gnus-configure-windows 'article)
13454 (goto-char (point-min))
13457 (defun gnus-article-show-all-headers ()
13458 "Show all article headers in article mode buffer."
13460 (gnus-article-setup-buffer)
13461 (set-buffer gnus-article-buffer)
13462 (let ((buffer-read-only nil))
13463 (gnus-unhide-text (point-min) (point-max)))))
13465 (defun gnus-article-hide-headers-if-wanted ()
13466 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13467 Provided for backwards compatibility."
13468 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13469 gnus-inhibit-hiding
13470 (gnus-article-hide-headers)))
13472 (defun gnus-article-hide-headers (&optional arg delete)
13473 "Toggle whether to hide unwanted headers and possibly sort them as well.
13474 If given a negative prefix, always show; if given a positive prefix,
13477 (unless (gnus-article-check-hidden-text 'headers arg)
13478 ;; This function might be inhibited.
13479 (unless gnus-inhibit-hiding
13481 (set-buffer gnus-article-buffer)
13483 (let ((buffer-read-only nil)
13484 (props (nconc (list 'gnus-type 'headers)
13485 gnus-hidden-properties))
13486 (ignored (when (not (stringp gnus-visible-headers))
13487 (cond ((stringp gnus-ignored-headers)
13488 gnus-ignored-headers)
13489 ((listp gnus-ignored-headers)
13490 (mapconcat 'identity gnus-ignored-headers
13493 (cond ((stringp gnus-visible-headers)
13494 gnus-visible-headers)
13495 ((and gnus-visible-headers
13496 (listp gnus-visible-headers))
13497 (mapconcat 'identity gnus-visible-headers "\\|"))))
13499 ;; First we narrow to just the headers.
13501 (goto-char (point-min))
13502 ;; Hide any "From " lines at the beginning of (mail) articles.
13503 (while (looking-at "From ")
13506 (gnus-hide-text (point-min) (point) props))
13507 ;; Then treat the rest of the header lines.
13510 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13511 ;; Then we use the two regular expressions
13512 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13513 ;; select which header lines is to remain visible in the
13515 (goto-char (point-min))
13516 (while (re-search-forward "^[^ \t]*:" nil t)
13517 (beginning-of-line)
13518 ;; We add the headers we want to keep to a list and delete
13519 ;; them from the buffer.
13520 (if (or (and visible (looking-at visible))
13521 (and ignored (not (looking-at ignored))))
13523 (push (buffer-substring
13527 ;; Be sure to get multi-line headers...
13528 (re-search-forward "^[^ \t]*:" nil t)
13529 (beginning-of-line)
13532 (delete-region beg (point)))
13534 ;; Sort the headers that we want to display.
13535 (setq want-list (sort want-list 'gnus-article-header-less))
13536 (goto-char (point-min))
13538 (insert (pop want-list)))
13539 ;; We make the unwanted headers invisible.
13541 (delete-region (point-min) (point-max))
13542 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13543 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13545 (defsubst gnus-article-header-rank (header)
13546 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13547 (let ((list gnus-sorted-header-list)
13550 (when (string-match (car list) header)
13552 (setq list (cdr list))
13556 (defun gnus-article-header-less (h1 h2)
13557 "Say whether string H1 is \"less\" than string H2."
13558 (< (gnus-article-header-rank h1)
13559 (gnus-article-header-rank h2)))
13561 (defun gnus-article-hide-boring-headers (&optional arg)
13562 "Toggle hiding of headers that aren't very interesting.
13563 If given a negative prefix, always show; if given a positive prefix,
13566 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13568 (set-buffer gnus-article-buffer)
13570 (let ((buffer-read-only nil)
13571 (list gnus-boring-article-headers)
13572 (inhibit-point-motion-hooks t)
13574 (nnheader-narrow-to-headers)
13576 (setq elem (pop list))
13577 (goto-char (point-min))
13579 ;; Hide empty headers.
13581 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13583 (gnus-hide-text-type
13584 (progn (beginning-of-line) (point))
13587 (if (re-search-forward "^[^ \t]" nil t)
13588 (match-beginning 0)
13591 ;; Hide boring Newsgroups header.
13592 ((eq elem 'newsgroups)
13593 (when (equal (mail-fetch-field "newsgroups")
13594 (gnus-group-real-name gnus-newsgroup-name))
13595 (gnus-article-hide-header "newsgroups")))
13596 ((eq elem 'followup-to)
13597 (when (equal (mail-fetch-field "followup-to")
13598 (mail-fetch-field "newsgroups"))
13599 (gnus-article-hide-header "followup-to")))
13600 ((eq elem 'reply-to)
13601 (let ((from (mail-fetch-field "from"))
13602 (reply-to (mail-fetch-field "reply-to")))
13606 (nth 1 (mail-extract-address-components from))
13607 (nth 1 (mail-extract-address-components reply-to))))
13608 (gnus-article-hide-header "reply-to"))))
13610 (let ((date (mail-fetch-field "date")))
13612 (< (gnus-days-between date (current-time-string))
13614 (gnus-article-hide-header "date")))))))))))
13616 (defun gnus-article-hide-header (header)
13618 (goto-char (point-min))
13619 (when (re-search-forward (concat "^" header ":") nil t)
13620 (gnus-hide-text-type
13621 (progn (beginning-of-line) (point))
13624 (if (re-search-forward "^[^ \t]" nil t)
13625 (match-beginning 0)
13627 'boring-headers))))
13629 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13630 (defun gnus-article-treat-overstrike ()
13631 "Translate overstrikes into bold text."
13634 (set-buffer gnus-article-buffer)
13635 (let ((buffer-read-only nil))
13636 (while (search-forward "\b" nil t)
13637 (let ((next (following-char))
13638 (previous (char-after (- (point) 2))))
13639 (cond ((eq next previous)
13640 (put-text-property (- (point) 2) (point) 'invisible t)
13641 (put-text-property (point) (1+ (point)) 'face 'bold))
13643 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13645 (- (point) 2) (1- (point)) 'face 'underline))
13647 (put-text-property (- (point) 2) (point) 'invisible t)
13649 (point) (1+ (point)) 'face 'underline))))))))
13651 (defun gnus-article-word-wrap ()
13652 "Format too long lines."
13655 (set-buffer gnus-article-buffer)
13656 (let ((buffer-read-only nil))
13658 (goto-char (point-min))
13659 (search-forward "\n\n" nil t)
13661 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13662 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13663 (adaptive-fill-mode t))
13664 (while (not (eobp))
13665 (and (>= (current-column) (min fill-column (window-width)))
13666 (/= (preceding-char) ?:)
13667 (fill-paragraph nil))
13668 (end-of-line 2))))))
13670 (defun gnus-article-remove-cr ()
13671 "Remove carriage returns from an article."
13674 (set-buffer gnus-article-buffer)
13675 (let ((buffer-read-only nil))
13676 (goto-char (point-min))
13677 (while (search-forward "\r" nil t)
13678 (replace-match "" t t)))))
13680 (defun gnus-article-remove-trailing-blank-lines ()
13681 "Remove all trailing blank lines from the article."
13684 (set-buffer gnus-article-buffer)
13685 (let ((buffer-read-only nil))
13686 (goto-char (point-max))
13690 (while (looking-at "^[ \t]*$")
13695 (defun gnus-article-display-x-face (&optional force)
13696 "Look for an X-Face header and display it if present."
13697 (interactive (list 'force))
13699 (set-buffer gnus-article-buffer)
13700 ;; Delete the old process, if any.
13701 (when (process-status "gnus-x-face")
13702 (delete-process "gnus-x-face"))
13703 (let ((inhibit-point-motion-hooks t)
13704 (case-fold-search nil)
13707 (nnheader-narrow-to-headers)
13708 (setq from (mail-fetch-field "from"))
13709 (goto-char (point-min))
13710 (when (and gnus-article-x-face-command
13712 ;; Check whether this face is censored.
13713 (not gnus-article-x-face-too-ugly)
13714 (and gnus-article-x-face-too-ugly from
13715 (not (string-match gnus-article-x-face-too-ugly
13717 ;; Has to be present.
13718 (re-search-forward "^X-Face: " nil t))
13719 ;; We now have the area of the buffer where the X-Face is stored.
13720 (let ((beg (point))
13721 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13722 ;; We display the face.
13723 (if (symbolp gnus-article-x-face-command)
13724 ;; The command is a lisp function, so we call it.
13725 (if (gnus-functionp gnus-article-x-face-command)
13726 (funcall gnus-article-x-face-command beg end)
13727 (error "%s is not a function" gnus-article-x-face-command))
13728 ;; The command is a string, so we interpret the command
13729 ;; as a, well, command, and fork it off.
13730 (let ((process-connection-type nil))
13731 (process-kill-without-query
13733 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13734 (process-send-region "gnus-x-face" beg end)
13735 (process-send-eof "gnus-x-face")))))))))
13737 (defun gnus-headers-decode-quoted-printable ()
13738 "Hack to remove QP encoding from headers."
13739 (let ((case-fold-search t)
13740 (inhibit-point-motion-hooks t)
13742 (goto-char (point-min))
13743 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13744 (setq string (match-string 1))
13745 (narrow-to-region (match-beginning 0) (match-end 0))
13746 (delete-region (point-min) (point-max))
13748 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13749 (subst-char-in-region (point-min) (point-max) ?_ ? )
13751 (goto-char (point-min)))))
13753 (defun gnus-article-de-quoted-unreadable (&optional force)
13754 "Do a naive translation of a quoted-printable-encoded article.
13755 This is in no way, shape or form meant as a replacement for real MIME
13756 processing, but is simply a stop-gap measure until MIME support is
13758 If FORCE, decode the article whether it is marked as quoted-printable
13760 (interactive (list 'force))
13762 (set-buffer gnus-article-buffer)
13763 (let ((case-fold-search t)
13764 (buffer-read-only nil)
13765 (type (gnus-fetch-field "content-transfer-encoding")))
13767 (and type (string-match "quoted-printable" type)))
13768 (gnus-headers-decode-quoted-printable)
13769 (goto-char (point-min))
13770 (search-forward "\n\n" nil 'move)
13771 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13773 (defun gnus-mime-decode-quoted-printable (from to)
13774 "Decode Quoted-Printable in the region between FROM and TO."
13776 (while (search-forward "=" to t)
13777 (cond ((eq (following-char) ?\n)
13780 ((looking-at "[0-9A-F][0-9A-F]")
13782 (insert (hexl-hex-string-to-integer
13783 (buffer-substring (point) (+ 2 (point)))))
13787 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13789 (defun gnus-article-hide-pgp (&optional arg)
13790 "Toggle hiding of any PGP headers and signatures in the current article.
13791 If given a negative prefix, always show; if given a positive prefix,
13794 (unless (gnus-article-check-hidden-text 'pgp arg)
13796 (set-buffer gnus-article-buffer)
13797 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13798 buffer-read-only beg end)
13800 (goto-char (point-min))
13801 ;; Hide the "header".
13802 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13803 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13805 ;; Hide the actual signature.
13806 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13807 (setq end (1+ (match-beginning 0)))
13810 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13812 ;; Perhaps we shouldn't hide to the end of the buffer
13813 ;; if there is no end to the signature?
13816 ;; Hide "- " PGP quotation markers.
13817 (when (and beg end)
13818 (narrow-to-region beg end)
13819 (goto-char (point-min))
13820 (while (re-search-forward "^- " nil t)
13821 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13824 (defun gnus-article-hide-signature (&optional arg)
13825 "Hide the signature in the current article.
13826 If given a negative prefix, always show; if given a positive prefix,
13829 (unless (gnus-article-check-hidden-text 'signature arg)
13831 (set-buffer gnus-article-buffer)
13833 (let ((buffer-read-only nil))
13834 (when (gnus-narrow-to-signature)
13835 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13837 (defun gnus-article-strip-leading-blank-lines ()
13838 "Remove all blank lines from the beginning of the article."
13841 (set-buffer gnus-article-buffer)
13842 (let (buffer-read-only)
13843 (goto-char (point-min))
13844 (when (search-forward "\n\n" nil t)
13845 (while (looking-at "[ \t]$")
13846 (gnus-delete-line))))))
13848 (defun gnus-narrow-to-signature ()
13849 "Narrow to the signature."
13851 (goto-char (point-max))
13852 (when (re-search-backward gnus-signature-separator nil t)
13854 (when (or (null gnus-signature-limit)
13855 (and (numberp gnus-signature-limit)
13856 (< (- (point-max) (point)) gnus-signature-limit))
13857 (and (gnus-functionp gnus-signature-limit)
13858 (funcall gnus-signature-limit))
13859 (and (stringp gnus-signature-limit)
13860 (not (re-search-forward gnus-signature-limit nil t))))
13861 (narrow-to-region (point) (point-max))
13864 (defun gnus-article-check-hidden-text (type arg)
13865 "Return nil if hiding is necessary."
13867 (set-buffer gnus-article-buffer)
13868 (let ((hide (gnus-article-hidden-text-p type)))
13869 (cond ((or (and (null arg) (eq hide 'hidden))
13870 (and arg (< 0 (prefix-numeric-value arg))))
13871 (gnus-article-show-hidden-text type))
13873 (gnus-article-show-hidden-text type t))
13876 (defun gnus-article-hidden-text-p (type)
13877 "Say whether the current buffer contains hidden text of type TYPE."
13878 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13880 (if (get-text-property pos 'invisible)
13884 (defun gnus-article-hide (&optional arg force)
13885 "Hide all the gruft in the current article.
13886 This means that PGP stuff, signatures, cited text and (some)
13887 headers will be hidden.
13888 If given a prefix, show the hidden text instead."
13889 (interactive (list current-prefix-arg 'force))
13890 (gnus-article-hide-headers arg)
13891 (gnus-article-hide-pgp arg)
13892 (gnus-article-hide-citation-maybe arg force)
13893 (gnus-article-hide-signature arg))
13895 (defun gnus-article-show-hidden-text (type &optional hide)
13896 "Show all hidden text of type TYPE.
13897 If HIDE, hide the text instead."
13899 (set-buffer gnus-article-buffer)
13900 (let ((buffer-read-only nil)
13901 (inhibit-point-motion-hooks t)
13903 (while (gnus-goto-char (text-property-any
13904 beg (point-max) 'gnus-type type))
13908 (gnus-hide-text beg (point) gnus-hidden-properties)
13909 (gnus-unhide-text beg (point)))
13910 (setq beg (point)))
13913 (defvar gnus-article-time-units
13914 `((year . ,(* 365.25 24 60 60))
13915 (week . ,(* 7 24 60 60))
13916 (day . ,(* 24 60 60))
13917 (hour . ,(* 60 60))
13920 "Mapping from time units to seconds.")
13922 (defun gnus-article-date-ut (&optional type highlight)
13923 "Convert DATE date to universal time in the current article.
13924 If TYPE is `local', convert to local time; if it is `lapsed', output
13925 how much time has lapsed since DATE."
13926 (interactive (list 'ut t))
13927 (let* ((header (or gnus-current-headers
13928 (gnus-summary-article-header) ""))
13929 (date (and (vectorp header) (mail-header-date header)))
13930 (date-regexp "^Date: \\|^X-Sent: ")
13931 (now (current-time))
13932 (inhibit-point-motion-hooks t))
13933 (when (and date (not (string= date "")))
13935 (set-buffer gnus-article-buffer)
13937 (nnheader-narrow-to-headers)
13938 (let ((buffer-read-only nil))
13939 ;; Delete any old Date headers.
13940 (if (zerop (nnheader-remove-header date-regexp t))
13941 (beginning-of-line)
13942 (goto-char (point-max)))
13945 ;; Convert to the local timezone. We have to slap a
13946 ;; `condition-case' round the calls to the timezone
13947 ;; functions since they aren't particularly resistant to
13950 (concat "Date: " (condition-case ()
13951 (timezone-make-date-arpa-standard date)
13954 ;; Convert to Universal Time.
13958 (timezone-make-date-arpa-standard date nil "UT")
13961 ;; Get the original date from the article.
13962 ((eq type 'original)
13963 (concat "Date: " date "\n"))
13964 ;; Do an X-Sent lapsed format.
13966 ;; If the date is seriously mangled, the timezone
13967 ;; functions are liable to bug out, so we condition-case
13968 ;; the entire thing.
13973 (timezone-make-date-arpa-standard
13974 (current-time-string now)
13975 (current-time-zone now) "UT"))
13977 (timezone-make-date-arpa-standard
13980 (real-sec (+ (* (float (car real-time)) 65536)
13982 (sec (abs real-sec))
13988 ;; This is a bit convoluted, but basically we go
13989 ;; through the time units for years, weeks, etc,
13990 ;; and divide things to see whether that results
13991 ;; in positive answers.
13994 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13995 ;; The (remaining) seconds are too few to
13996 ;; be divided into this time unit.
13998 ;; It's big enough, so we output it.
13999 (setq sec (- sec (* num (cdr unit))))
14001 (concat (if prev ", " "") (int-to-string
14003 " " (symbol-name (car unit))
14004 (if (> num 1) "s" ""))
14006 gnus-article-time-units "")
14007 ;; If dates are odd, then it might appear like the
14008 ;; article was sent in the future.
14011 " in the future\n")))))
14013 (error "Unknown conversion type: %s" type)))))
14014 ;; Do highlighting.
14015 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
14016 (gnus-article-highlight-headers)))))))
14018 (defun gnus-article-date-local (&optional highlight)
14019 "Convert the current article date to the local timezone."
14020 (interactive (list t))
14021 (gnus-article-date-ut 'local highlight))
14023 (defun gnus-article-date-original (&optional highlight)
14024 "Convert the current article date to what it was originally.
14025 This is only useful if you have used some other date conversion
14026 function and want to see what the date was before converting."
14027 (interactive (list t))
14028 (gnus-article-date-ut 'original highlight))
14030 (defun gnus-article-date-lapsed (&optional highlight)
14031 "Convert the current article date to time lapsed since it was sent."
14032 (interactive (list t))
14033 (gnus-article-date-ut 'lapsed highlight))
14035 (defun gnus-article-maybe-highlight ()
14036 "Do some article highlighting if `gnus-visual' is non-nil."
14037 (if (gnus-visual-p 'article-highlight 'highlight)
14038 (gnus-article-highlight-some)))
14042 (defun gnus-output-to-rmail (file-name)
14043 "Append the current article to an Rmail file named FILE-NAME."
14045 ;; Most of these codes are borrowed from rmailout.el.
14046 (setq file-name (expand-file-name file-name))
14047 (setq rmail-default-rmail-file file-name)
14048 (let ((artbuf (current-buffer))
14049 (tmpbuf (get-buffer-create " *Gnus-output*")))
14051 (or (get-file-buffer file-name)
14052 (file-exists-p file-name)
14053 (if (gnus-yes-or-no-p
14054 (concat "\"" file-name "\" does not exist, create it? "))
14055 (let ((file-buffer (create-file-buffer file-name)))
14057 (set-buffer file-buffer)
14058 (rmail-insert-rmail-file-header)
14059 (let ((require-final-newline nil))
14060 (write-region (point-min) (point-max) file-name t 1)))
14061 (kill-buffer file-buffer))
14062 (error "Output file does not exist")))
14063 (set-buffer tmpbuf)
14064 (buffer-disable-undo (current-buffer))
14066 (insert-buffer-substring artbuf)
14067 (gnus-convert-article-to-rmail)
14068 ;; Decide whether to append to a file or to an Emacs buffer.
14069 (let ((outbuf (get-file-buffer file-name)))
14071 (append-to-file (point-min) (point-max) file-name)
14072 ;; File has been visited, in buffer OUTBUF.
14073 (set-buffer outbuf)
14074 (let ((buffer-read-only nil)
14075 (msg (and (boundp 'rmail-current-message)
14076 (symbol-value 'rmail-current-message))))
14077 ;; If MSG is non-nil, buffer is in RMAIL mode.
14080 (narrow-to-region (point-max) (point-max))))
14081 (insert-buffer-substring tmpbuf)
14084 (goto-char (point-min))
14086 (search-backward "\^_")
14087 (narrow-to-region (point) (point-max))
14088 (goto-char (1+ (point-min)))
14089 (rmail-count-new-messages t)
14090 (rmail-show-message msg)))))))
14091 (kill-buffer tmpbuf)))
14093 (defun gnus-output-to-file (file-name)
14094 "Append the current article to a file named FILE-NAME."
14095 (setq file-name (expand-file-name file-name))
14096 (let ((artbuf (current-buffer))
14097 (tmpbuf (get-buffer-create " *Gnus-output*")))
14099 (set-buffer tmpbuf)
14100 (buffer-disable-undo (current-buffer))
14102 (insert-buffer-substring artbuf)
14103 ;; Append newline at end of the buffer as separator, and then
14104 ;; save it to file.
14105 (goto-char (point-max))
14107 (append-to-file (point-min) (point-max) file-name))
14108 (kill-buffer tmpbuf)))
14110 (defun gnus-convert-article-to-rmail ()
14111 "Convert article in current buffer to Rmail message format."
14112 (let ((buffer-read-only nil))
14113 ;; Convert article directly into Babyl format.
14114 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14115 (goto-char (point-min))
14116 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14117 (while (search-forward "\n\^_" nil t) ;single char
14118 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14119 (goto-char (point-max))
14122 (defun gnus-narrow-to-page (&optional arg)
14123 "Narrow the article buffer to a page.
14124 If given a numerical ARG, move forward ARG pages."
14126 (setq arg (if arg (prefix-numeric-value arg) 0))
14128 (set-buffer gnus-article-buffer)
14129 (goto-char (point-min))
14131 (when (gnus-visual-p 'page-marker)
14132 (let ((buffer-read-only nil))
14133 (gnus-remove-text-with-property 'gnus-prev)
14134 (gnus-remove-text-with-property 'gnus-next)))
14137 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14139 (re-search-forward page-delimiter nil 'move arg)))
14140 (goto-char (match-end 0)))
14143 (if (re-search-forward page-delimiter nil 'move)
14144 (match-beginning 0)
14146 (when (and (gnus-visual-p 'page-marker)
14147 (not (= (point-min) 1)))
14149 (goto-char (point-min))
14150 (gnus-insert-prev-page-button)))
14151 (when (and (gnus-visual-p 'page-marker)
14152 (not (= (1- (point-max)) (buffer-size))))
14154 (goto-char (point-max))
14155 (gnus-insert-next-page-button)))))
14157 ;; Article mode commands
14159 (defun gnus-article-goto-next-page ()
14160 "Show the next page of the article."
14162 (when (gnus-article-next-page)
14163 (gnus-article-read-summary-keys nil ?n)))
14165 (defun gnus-article-goto-prev-page ()
14166 "Show the next page of the article."
14168 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14169 (gnus-article-prev-page nil)))
14171 (defun gnus-article-next-page (&optional lines)
14172 "Show the next page of the current article.
14173 If end of article, return non-nil. Otherwise return nil.
14174 Argument LINES specifies lines to be scrolled up."
14176 (move-to-window-line -1)
14177 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14178 (if (save-excursion
14180 (and (pos-visible-in-window-p) ;Not continuation line.
14182 ;; Nothing in this page.
14183 (if (or (not gnus-break-pages)
14186 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14188 (gnus-narrow-to-page 1) ;Go to next page.
14190 ;; More in this page.
14194 ;; Long lines may cause an end-of-buffer error.
14195 (goto-char (point-max))))
14196 (move-to-window-line 0)
14199 (defun gnus-article-prev-page (&optional lines)
14200 "Show previous page of current article.
14201 Argument LINES specifies lines to be scrolled down."
14203 (move-to-window-line 0)
14204 (if (and gnus-break-pages
14206 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14208 (gnus-narrow-to-page -1) ;Go to previous page.
14209 (goto-char (point-max))
14213 (scroll-down lines)
14215 (move-to-window-line 0))))
14217 (defun gnus-article-refer-article ()
14218 "Read article specified by message-id around point."
14220 (let ((point (point)))
14221 (search-forward ">" nil t) ;Move point to end of "<....>".
14222 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14223 (let ((message-id (match-string 1)))
14225 (set-buffer gnus-summary-buffer)
14226 (gnus-summary-refer-article message-id))
14227 (goto-char (point))
14228 (error "No references around point"))))
14230 (defun gnus-article-show-summary ()
14231 "Reconfigure windows to show summary buffer."
14233 (gnus-configure-windows 'article)
14234 (gnus-summary-goto-subject gnus-current-article))
14236 (defun gnus-article-describe-briefly ()
14237 "Describe article mode commands briefly."
14240 (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")))
14242 (defun gnus-article-summary-command ()
14243 "Execute the last keystroke in the summary buffer."
14245 (let ((obuf (current-buffer))
14246 (owin (current-window-configuration))
14248 (switch-to-buffer gnus-summary-buffer 'norecord)
14249 (setq func (lookup-key (current-local-map) (this-command-keys)))
14250 (call-interactively func)
14252 (set-window-configuration owin)
14253 (set-window-point (get-buffer-window (current-buffer)) (point))))
14255 (defun gnus-article-summary-command-nosave ()
14256 "Execute the last keystroke in the summary buffer."
14259 (pop-to-buffer gnus-summary-buffer 'norecord)
14260 (setq func (lookup-key (current-local-map) (this-command-keys)))
14261 (call-interactively func)))
14263 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14264 "Read a summary buffer key sequence and execute it from the article buffer."
14267 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14268 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14272 (set-buffer gnus-summary-buffer)
14273 (push (or key last-command-event) unread-command-events)
14274 (setq keys (read-key-sequence nil)))
14277 (if (member keys nosaves)
14279 (pop-to-buffer gnus-summary-buffer 'norecord)
14280 (if (setq func (lookup-key (current-local-map) keys))
14281 (call-interactively func)
14283 (let ((obuf (current-buffer))
14284 (owin (current-window-configuration))
14287 (if not-restore-window
14288 (pop-to-buffer gnus-summary-buffer 'norecord)
14289 (switch-to-buffer gnus-summary-buffer 'norecord))
14290 (setq in-buffer (current-buffer))
14291 (if (setq func (lookup-key (current-local-map) keys))
14292 (call-interactively func)
14294 (when (eq in-buffer (current-buffer))
14296 (unless not-restore-window
14297 (set-window-configuration owin))
14298 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14302 ;;; Kill file handling.
14306 (defalias 'gnus-batch-kill 'gnus-batch-score)
14308 (defun gnus-batch-score ()
14309 "Run batched scoring.
14310 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14311 Newsgroups is a list of strings in Bnews format. If you want to score
14312 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14313 score the alt hierarchy, you'd say \"!alt.all\"."
14316 (gnus-newsrc-parse-options
14317 (apply (function concat)
14318 (mapcar (lambda (g) (concat g " "))
14319 command-line-args-left))))
14320 (gnus-expert-user t)
14321 (nnmail-spool-file nil)
14322 (gnus-use-dribble-file nil)
14323 (yes (car yes-and-no))
14324 (no (cdr yes-and-no))
14326 ;; Disable verbose message.
14327 gnus-novice-user gnus-large-newsgroup)
14328 ;; Eat all arguments.
14329 (setq command-line-args-left nil)
14332 ;; Apply kills to specified newsgroups in command line arguments.
14333 (setq newsrc (cdr gnus-newsrc-alist))
14335 (setq group (caar newsrc))
14336 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14337 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14339 (or (eq (car entry) t)
14340 (not (zerop (car entry)))))
14341 (if yes (string-match yes group) t)
14342 (or (null no) (not (string-match no group))))
14344 (gnus-summary-read-group group nil t nil t)
14345 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14346 (gnus-summary-exit))))
14347 (setq newsrc (cdr newsrc)))
14349 (switch-to-buffer gnus-group-buffer)
14350 (gnus-group-save-newsrc)))
14352 (defun gnus-apply-kill-file ()
14353 "Apply a kill file to the current newsgroup.
14354 Returns the number of articles marked as read."
14355 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14356 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14357 (gnus-apply-kill-file-internal)
14360 (defun gnus-kill-save-kill-buffer ()
14361 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14362 (when (get-file-buffer file)
14364 (set-buffer (get-file-buffer file))
14365 (and (buffer-modified-p) (save-buffer))
14366 (kill-buffer (current-buffer))))))
14368 (defvar gnus-kill-file-name "KILL"
14369 "Suffix of the kill files.")
14371 (defun gnus-newsgroup-kill-file (newsgroup)
14372 "Return the name of a kill file name for NEWSGROUP.
14373 If NEWSGROUP is nil, return the global kill file name instead."
14375 ;; The global KILL file is placed at top of the directory.
14376 ((or (null newsgroup)
14377 (string-equal newsgroup ""))
14378 (expand-file-name gnus-kill-file-name
14379 (or gnus-kill-files-directory "~/News")))
14380 ;; Append ".KILL" to newsgroup name.
14381 ((gnus-use-long-file-name 'not-kill)
14382 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14383 "." gnus-kill-file-name)
14384 (or gnus-kill-files-directory "~/News")))
14385 ;; Place "KILL" under the hierarchical directory.
14387 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14388 "/" gnus-kill-file-name)
14389 (or gnus-kill-files-directory "~/News")))))
14396 (defvar gnus-dribble-ignore nil)
14397 (defvar gnus-dribble-eval-file nil)
14399 (defun gnus-dribble-file-name ()
14400 "Return the dribble file for the current .newsrc."
14402 (if gnus-dribble-directory
14403 (concat (file-name-as-directory gnus-dribble-directory)
14404 (file-name-nondirectory gnus-current-startup-file))
14405 gnus-current-startup-file)
14408 (defun gnus-dribble-enter (string)
14409 "Enter STRING into the dribble buffer."
14410 (if (and (not gnus-dribble-ignore)
14411 gnus-dribble-buffer
14412 (buffer-name gnus-dribble-buffer))
14413 (let ((obuf (current-buffer)))
14414 (set-buffer gnus-dribble-buffer)
14415 (insert string "\n")
14416 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14417 (set-buffer obuf))))
14419 (defun gnus-dribble-read-file ()
14420 "Read the dribble file from disk."
14421 (let ((dribble-file (gnus-dribble-file-name)))
14423 (set-buffer (setq gnus-dribble-buffer
14425 (file-name-nondirectory dribble-file))))
14426 (gnus-add-current-to-buffer-list)
14428 (setq buffer-file-name dribble-file)
14430 (buffer-disable-undo (current-buffer))
14431 (bury-buffer (current-buffer))
14432 (set-buffer-modified-p nil)
14433 (let ((auto (make-auto-save-file-name))
14434 (gnus-dribble-ignore t))
14435 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14436 ;; Load whichever file is newest -- the auto save file
14437 ;; or the "real" file.
14438 (if (file-newer-than-file-p auto dribble-file)
14439 (insert-file-contents auto)
14440 (insert-file-contents dribble-file))
14441 (unless (zerop (buffer-size))
14442 (set-buffer-modified-p t))
14443 ;; Set the file modes to reflect the .newsrc file modes.
14445 (when (file-exists-p gnus-current-startup-file)
14446 (set-file-modes dribble-file
14447 (file-modes gnus-current-startup-file)))
14448 ;; Possibly eval the file later.
14449 (when (gnus-y-or-n-p
14450 "Auto-save file exists. Do you want to read it? ")
14451 (setq gnus-dribble-eval-file t)))))))
14453 (defun gnus-dribble-eval-file ()
14454 (if (not gnus-dribble-eval-file)
14456 (setq gnus-dribble-eval-file nil)
14458 (let ((gnus-dribble-ignore t))
14459 (set-buffer gnus-dribble-buffer)
14460 (eval-buffer (current-buffer))))))
14462 (defun gnus-dribble-delete-file ()
14463 (if (file-exists-p (gnus-dribble-file-name))
14464 (delete-file (gnus-dribble-file-name)))
14465 (if gnus-dribble-buffer
14467 (set-buffer gnus-dribble-buffer)
14468 (let ((auto (make-auto-save-file-name)))
14469 (if (file-exists-p auto)
14470 (delete-file auto))
14472 (set-buffer-modified-p nil)))))
14474 (defun gnus-dribble-save ()
14475 (if (and gnus-dribble-buffer
14476 (buffer-name gnus-dribble-buffer))
14478 (set-buffer gnus-dribble-buffer)
14481 (defun gnus-dribble-clear ()
14483 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14485 (set-buffer gnus-dribble-buffer)
14487 (set-buffer-modified-p nil)
14488 (setq buffer-saved-size (buffer-size))))))
14492 ;;; Server Communication
14495 (defun gnus-start-news-server (&optional confirm)
14496 "Open a method for getting news.
14497 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14499 (if gnus-current-select-method
14500 ;; Stream is already opened.
14502 ;; Open NNTP server.
14503 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14506 ;; Read server name with completion.
14507 (setq gnus-nntp-server
14508 (completing-read "NNTP server: "
14509 (mapcar (lambda (server) (list server))
14510 (cons (list gnus-nntp-server)
14511 gnus-secondary-servers))
14512 nil nil gnus-nntp-server))))
14514 (if (and gnus-nntp-server
14515 (stringp gnus-nntp-server)
14516 (not (string= gnus-nntp-server "")))
14517 (setq gnus-select-method
14518 (cond ((or (string= gnus-nntp-server "")
14519 (string= gnus-nntp-server "::"))
14520 (list 'nnspool (system-name)))
14521 ((string-match "^:" gnus-nntp-server)
14522 (list 'nnmh gnus-nntp-server
14523 (list 'nnmh-directory
14524 (file-name-as-directory
14526 (concat "~/" (substring
14527 gnus-nntp-server 1)))))
14528 (list 'nnmh-get-new-mail nil)))
14530 (list 'nntp gnus-nntp-server)))))
14532 (setq how (car gnus-select-method))
14533 (cond ((eq how 'nnspool)
14535 (gnus-message 5 "Looking up local news spool..."))
14538 (gnus-message 5 "Looking up mh spool..."))
14541 (setq gnus-current-select-method gnus-select-method)
14542 (run-hooks 'gnus-open-server-hook)
14544 ;; gnus-open-server-hook might have opened it
14545 (gnus-server-opened gnus-select-method)
14546 (gnus-open-server gnus-select-method)
14549 "%s (%s) open error: '%s'. Continue? "
14550 (car gnus-select-method) (cadr gnus-select-method)
14551 (gnus-status-message gnus-select-method)))
14553 (gnus-message 1 "Couldn't open server on %s"
14554 (nth 1 gnus-select-method))
14558 (defun gnus-check-group (group)
14559 "Try to make sure that the server where GROUP exists is alive."
14560 (let ((method (gnus-find-method-for-group group)))
14561 (or (gnus-server-opened method)
14562 (gnus-open-server method))))
14564 (defun gnus-check-server (&optional method silent)
14565 "Check whether the connection to METHOD is down.
14566 If METHOD is nil, use `gnus-select-method'.
14567 If it is down, start it up (again)."
14568 (let ((method (or method gnus-select-method)))
14569 ;; Transform virtual server names into select methods.
14570 (when (stringp method)
14571 (setq method (gnus-server-to-method method)))
14572 (if (gnus-server-opened method)
14573 ;; The stream is already opened.
14575 ;; Open the server.
14577 (gnus-message 5 "Opening %s server%s..." (car method)
14578 (if (equal (nth 1 method) "") ""
14579 (format " on %s" (nth 1 method)))))
14580 (run-hooks 'gnus-open-server-hook)
14582 (gnus-open-server method)
14586 (defun gnus-get-function (method function)
14587 "Return a function symbol based on METHOD and FUNCTION."
14588 ;; Translate server names into methods.
14590 (error "Attempted use of a nil select method"))
14591 (when (stringp method)
14592 (setq method (gnus-server-to-method method)))
14593 (let ((func (intern (format "%s-%s" (car method) function))))
14594 ;; If the functions isn't bound, we require the backend in
14596 (unless (fboundp func)
14597 (require (car method))
14598 (unless (fboundp func)
14599 ;; This backend doesn't implement this function.
14600 (error "No such function: %s" func)))
14605 ;;; Interface functions to the backends.
14608 (defun gnus-open-server (method)
14609 "Open a connection to METHOD."
14610 (when (stringp method)
14611 (setq method (gnus-server-to-method method)))
14612 (let ((elem (assoc method gnus-opened-servers)))
14613 ;; If this method was previously denied, we just return nil.
14614 (if (eq (nth 1 elem) 'denied)
14616 (gnus-message 1 "Denied server")
14618 ;; Open the server.
14620 (funcall (gnus-get-function method 'open-server)
14621 (nth 1 method) (nthcdr 2 method))))
14622 ;; If this hasn't been opened before, we add it to the list.
14624 (setq elem (list method nil)
14625 gnus-opened-servers (cons elem gnus-opened-servers)))
14626 ;; Set the status of this server.
14627 (setcar (cdr elem) (if result 'ok 'denied))
14628 ;; Return the result from the "open" call.
14631 (defun gnus-close-server (method)
14632 "Close the connection to METHOD."
14633 (when (stringp method)
14634 (setq method (gnus-server-to-method method)))
14635 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14637 (defun gnus-request-list (method)
14638 "Request the active file from METHOD."
14639 (when (stringp method)
14640 (setq method (gnus-server-to-method method)))
14641 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14643 (defun gnus-request-list-newsgroups (method)
14644 "Request the newsgroups file from METHOD."
14645 (when (stringp method)
14646 (setq method (gnus-server-to-method method)))
14647 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14649 (defun gnus-request-newgroups (date method)
14650 "Request all new groups since DATE from METHOD."
14651 (when (stringp method)
14652 (setq method (gnus-server-to-method method)))
14653 (funcall (gnus-get-function method 'request-newgroups)
14654 date (nth 1 method)))
14656 (defun gnus-server-opened (method)
14657 "Check whether a connection to METHOD has been opened."
14658 (when (stringp method)
14659 (setq method (gnus-server-to-method method)))
14660 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14662 (defun gnus-status-message (method)
14663 "Return the status message from METHOD.
14664 If METHOD is a string, it is interpreted as a group name. The method
14665 this group uses will be queried."
14666 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14668 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14670 (defun gnus-request-group (group &optional dont-check method)
14671 "Request GROUP. If DONT-CHECK, no information is required."
14672 (let ((method (or method (gnus-find-method-for-group group))))
14673 (when (stringp method)
14674 (setq method (gnus-server-to-method method)))
14675 (funcall (gnus-get-function method 'request-group)
14676 (gnus-group-real-name group) (nth 1 method) dont-check)))
14678 (defun gnus-request-asynchronous (group &optional articles)
14679 "Request that GROUP behave asynchronously.
14680 ARTICLES is the `data' of the group."
14681 (let ((method (gnus-find-method-for-group group)))
14682 (funcall (gnus-get-function method 'request-asynchronous)
14683 (gnus-group-real-name group) (nth 1 method) articles)))
14685 (defun gnus-list-active-group (group)
14686 "Request active information on GROUP."
14687 (let ((method (gnus-find-method-for-group group))
14688 (func 'list-active-group))
14689 (when (gnus-check-backend-function func group)
14690 (funcall (gnus-get-function method func)
14691 (gnus-group-real-name group) (nth 1 method)))))
14693 (defun gnus-request-group-description (group)
14694 "Request a description of GROUP."
14695 (let ((method (gnus-find-method-for-group group))
14696 (func 'request-group-description))
14697 (when (gnus-check-backend-function func group)
14698 (funcall (gnus-get-function method func)
14699 (gnus-group-real-name group) (nth 1 method)))))
14701 (defun gnus-close-group (group)
14702 "Request the GROUP be closed."
14703 (let ((method (gnus-find-method-for-group group)))
14704 (funcall (gnus-get-function method 'close-group)
14705 (gnus-group-real-name group) (nth 1 method))))
14707 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14708 "Request headers for ARTICLES in GROUP.
14709 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14710 (let ((method (gnus-find-method-for-group group)))
14711 (if (and gnus-use-cache (numberp (car articles)))
14712 (gnus-cache-retrieve-headers articles group fetch-old)
14713 (funcall (gnus-get-function method 'retrieve-headers)
14714 articles (gnus-group-real-name group) (nth 1 method)
14717 (defun gnus-retrieve-groups (groups method)
14718 "Request active information on GROUPS from METHOD."
14719 (when (stringp method)
14720 (setq method (gnus-server-to-method method)))
14721 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14723 (defun gnus-request-type (group &optional article)
14724 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14725 (let ((method (gnus-find-method-for-group group)))
14726 (if (not (gnus-check-backend-function 'request-type (car method)))
14728 (funcall (gnus-get-function method 'request-type)
14729 (gnus-group-real-name group) article))))
14731 (defun gnus-request-update-mark (group article mark)
14732 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14733 (let ((method (gnus-find-method-for-group group)))
14734 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14736 (funcall (gnus-get-function method 'request-update-mark)
14737 (gnus-group-real-name group) article mark))))
14739 (defun gnus-request-article (article group &optional buffer)
14740 "Request the ARTICLE in GROUP.
14741 ARTICLE can either be an article number or an article Message-ID.
14742 If BUFFER, insert the article in that group."
14743 (let ((method (gnus-find-method-for-group group)))
14744 (funcall (gnus-get-function method 'request-article)
14745 article (gnus-group-real-name group) (nth 1 method) buffer)))
14747 (defun gnus-request-head (article group)
14748 "Request the head of ARTICLE in GROUP."
14749 (let ((method (gnus-find-method-for-group group)))
14750 (funcall (gnus-get-function method 'request-head)
14751 article (gnus-group-real-name group) (nth 1 method))))
14753 (defun gnus-request-body (article group)
14754 "Request the body of ARTICLE in GROUP."
14755 (let ((method (gnus-find-method-for-group group)))
14756 (funcall (gnus-get-function method 'request-body)
14757 article (gnus-group-real-name group) (nth 1 method))))
14759 (defun gnus-request-post (method)
14760 "Post the current buffer using METHOD."
14761 (when (stringp method)
14762 (setq method (gnus-server-to-method method)))
14763 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14765 (defun gnus-request-scan (group method)
14766 "Request a SCAN being performed in GROUP from METHOD.
14767 If GROUP is nil, all groups on METHOD are scanned."
14768 (let ((method (if group (gnus-find-method-for-group group) method)))
14769 (funcall (gnus-get-function method 'request-scan)
14770 (and group (gnus-group-real-name group)) (nth 1 method))))
14772 (defsubst gnus-request-update-info (info method)
14773 "Request that METHOD update INFO."
14774 (when (stringp method)
14775 (setq method (gnus-server-to-method method)))
14776 (when (gnus-check-backend-function 'request-update-info (car method))
14777 (funcall (gnus-get-function method 'request-update-info)
14778 (gnus-group-real-name (gnus-info-group info))
14779 info (nth 1 method))))
14781 (defun gnus-request-expire-articles (articles group &optional force)
14782 (let ((method (gnus-find-method-for-group group)))
14783 (funcall (gnus-get-function method 'request-expire-articles)
14784 articles (gnus-group-real-name group) (nth 1 method)
14787 (defun gnus-request-move-article
14788 (article group server accept-function &optional last)
14789 (let ((method (gnus-find-method-for-group group)))
14790 (funcall (gnus-get-function method 'request-move-article)
14791 article (gnus-group-real-name group)
14792 (nth 1 method) accept-function last)))
14794 (defun gnus-request-accept-article (group &optional last method)
14795 ;; Make sure there's a newline at the end of the article.
14796 (when (stringp method)
14797 (setq method (gnus-server-to-method method)))
14798 (goto-char (point-max))
14801 (let ((func (if (symbolp group) group
14802 (car (or method (gnus-find-method-for-group group))))))
14803 (funcall (intern (format "%s-request-accept-article" func))
14804 (if (stringp group) (gnus-group-real-name group) group)
14807 (defun gnus-request-replace-article (article group buffer)
14808 (let ((func (car (gnus-find-method-for-group group))))
14809 (funcall (intern (format "%s-request-replace-article" func))
14810 article (gnus-group-real-name group) buffer)))
14812 (defun gnus-request-associate-buffer (group)
14813 (let ((method (gnus-find-method-for-group group)))
14814 (funcall (gnus-get-function method 'request-associate-buffer)
14815 (gnus-group-real-name group))))
14817 (defun gnus-request-restore-buffer (article group)
14818 "Request a new buffer restored to the state of ARTICLE."
14819 (let ((method (gnus-find-method-for-group group)))
14820 (funcall (gnus-get-function method 'request-restore-buffer)
14821 article (gnus-group-real-name group) (nth 1 method))))
14823 (defun gnus-request-create-group (group &optional method)
14824 (when (stringp method)
14825 (setq method (gnus-server-to-method method)))
14826 (let ((method (or method (gnus-find-method-for-group group))))
14827 (funcall (gnus-get-function method 'request-create-group)
14828 (gnus-group-real-name group) (nth 1 method))))
14830 (defun gnus-request-delete-group (group &optional force)
14831 (let ((method (gnus-find-method-for-group group)))
14832 (funcall (gnus-get-function method 'request-delete-group)
14833 (gnus-group-real-name group) force (nth 1 method))))
14835 (defun gnus-request-rename-group (group new-name)
14836 (let ((method (gnus-find-method-for-group group)))
14837 (funcall (gnus-get-function method 'request-rename-group)
14838 (gnus-group-real-name group)
14839 (gnus-group-real-name new-name) (nth 1 method))))
14841 (defun gnus-member-of-valid (symbol group)
14842 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14843 (memq symbol (assoc
14844 (symbol-name (car (gnus-find-method-for-group group)))
14845 gnus-valid-select-methods)))
14847 (defun gnus-method-option-p (method option)
14848 "Return non-nil if select METHOD has OPTION as a parameter."
14849 (when (stringp method)
14850 (setq method (gnus-server-to-method method)))
14851 (memq option (assoc (format "%s" (car method))
14852 gnus-valid-select-methods)))
14854 (defun gnus-server-extend-method (group method)
14855 ;; This function "extends" a virtual server. If the server is
14856 ;; "hello", and the select method is ("hello" (my-var "something"))
14857 ;; in the group "alt.alt", this will result in a new virtual server
14858 ;; called "hello+alt.alt".
14860 (gnus-copy-sequence
14861 (if (equal (car method) "native") gnus-select-method
14862 (cdr (assoc (car method) gnus-server-alist))))))
14863 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14864 (nconc entry (cdr method))))
14866 (defun gnus-find-method-for-group (group &optional info)
14867 "Find the select method that GROUP uses."
14868 (or gnus-override-method
14870 gnus-select-method)
14871 (let ((info (or info (gnus-get-info group)))
14874 (not (setq method (gnus-info-method info)))
14875 (equal method "native"))
14878 (cond ((stringp method)
14879 (gnus-server-to-method method))
14880 ((stringp (car method))
14881 (gnus-server-extend-method group method))
14884 (if (equal (cadr method) "")
14886 (gnus-server-add-address method))))))
14888 (defun gnus-check-backend-function (func group)
14889 "Check whether GROUP supports function FUNC."
14890 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14892 (fboundp (intern (format "%s-%s" method func)))))
14894 (defun gnus-methods-using (feature)
14895 "Find all methods that have FEATURE."
14896 (let ((valids gnus-valid-select-methods)
14899 (if (memq feature (car valids))
14900 (setq outs (cons (car valids) outs)))
14901 (setq valids (cdr valids)))
14906 ;;; Active & Newsrc File Handling
14909 (defun gnus-setup-news (&optional rawfile level dont-connect)
14910 "Setup news information.
14911 If RAWFILE is non-nil, the .newsrc file will also be read.
14912 If LEVEL is non-nil, the news will be set up at level LEVEL."
14913 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14916 ;; Clear some variables to re-initialize news information.
14917 (setq gnus-newsrc-alist nil
14918 gnus-active-hashtb nil)
14919 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14920 (gnus-read-newsrc-file rawfile))
14922 (when (and (not (assoc "archive" gnus-server-alist))
14923 gnus-message-archive-method)
14924 (push (cons "archive" gnus-message-archive-method)
14925 gnus-server-alist))
14927 ;; If we don't read the complete active file, we fill in the
14929 (if (or (null gnus-read-active-file)
14930 (eq gnus-read-active-file 'some))
14931 (gnus-update-active-hashtb-from-killed))
14933 ;; Read the active file and create `gnus-active-hashtb'.
14934 ;; If `gnus-read-active-file' is nil, then we just create an empty
14935 ;; hash table. The partial filling out of the hash table will be
14936 ;; done in `gnus-get-unread-articles'.
14937 (and gnus-read-active-file
14939 (gnus-read-active-file))
14941 (or gnus-active-hashtb
14942 (setq gnus-active-hashtb (make-vector 4095 0)))
14944 ;; Initialize the cache.
14945 (when gnus-use-cache
14948 ;; Possibly eval the dribble file.
14949 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14951 (gnus-update-format-specifications)
14953 ;; See whether we need to read the description file.
14954 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
14955 (not gnus-description-hashtb)
14957 gnus-read-active-file)
14958 (gnus-read-all-descriptions-files))
14960 ;; Find new newsgroups and treat them.
14961 (if (and init gnus-check-new-newsgroups (not level)
14962 (gnus-check-server gnus-select-method))
14963 (gnus-find-new-newsgroups))
14965 ;; We might read in new NoCeM messages here.
14966 (when gnus-use-nocem
14967 (gnus-nocem-scan-groups))
14969 ;; Find the number of unread articles in each non-dead group.
14970 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14971 (gnus-get-unread-articles level))
14973 (if (and init gnus-check-bogus-newsgroups
14974 gnus-read-active-file (not level)
14975 (gnus-server-opened gnus-select-method))
14976 (gnus-check-bogus-newsgroups))))
14978 (defun gnus-find-new-newsgroups (&optional arg)
14979 "Search for new newsgroups and add them.
14980 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14981 The `-n' option line from .newsrc is respected.
14982 If ARG (the prefix), use the `ask-server' method to query
14983 the server for new groups."
14985 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14986 (null gnus-read-active-file)
14987 (eq gnus-read-active-file 'some))
14988 'ask-server gnus-check-new-newsgroups)))
14989 (unless (gnus-check-first-time-used)
14990 (if (or (consp check)
14991 (eq check 'ask-server))
14992 ;; Ask the server for new groups.
14993 (gnus-ask-server-for-new-groups)
14994 ;; Go through the active hashtb and look for new groups.
14996 group new-newsgroups)
14997 (gnus-message 5 "Looking for new newsgroups...")
14998 (unless gnus-have-read-active-file
14999 (gnus-read-active-file))
15000 (setq gnus-newsrc-last-checked-date (current-time-string))
15001 (unless gnus-killed-hashtb
15002 (gnus-make-hashtable-from-killed))
15003 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15004 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15007 (if (or (null (setq group (symbol-name sym)))
15009 (null (symbol-value sym))
15010 (gnus-gethash group gnus-killed-hashtb)
15011 (gnus-gethash group gnus-newsrc-hashtb))
15013 (let ((do-sub (gnus-matches-options-n group)))
15015 ((eq do-sub 'subscribe)
15016 (setq groups (1+ groups))
15017 (gnus-sethash group group gnus-killed-hashtb)
15018 (funcall gnus-subscribe-options-newsgroup-method group))
15019 ((eq do-sub 'ignore)
15022 (setq groups (1+ groups))
15023 (gnus-sethash group group gnus-killed-hashtb)
15024 (if gnus-subscribe-hierarchical-interactive
15025 (setq new-newsgroups (cons group new-newsgroups))
15026 (funcall gnus-subscribe-newsgroup-method group)))))))
15027 gnus-active-hashtb)
15028 (when new-newsgroups
15029 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15030 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15032 (gnus-message 6 "%d new newsgroup%s arrived."
15033 groups (if (> groups 1) "s have" " has"))
15034 (gnus-message 6 "No new newsgroups.")))))))
15036 (defun gnus-matches-options-n (group)
15037 ;; Returns `subscribe' if the group is to be unconditionally
15038 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15039 ;; no match for the group.
15041 ;; First we check the two user variables.
15043 ((and gnus-options-subscribe
15044 (string-match gnus-options-subscribe group))
15046 ((and gnus-auto-subscribed-groups
15047 (string-match gnus-auto-subscribed-groups group))
15049 ((and gnus-options-not-subscribe
15050 (string-match gnus-options-not-subscribe group))
15052 ;; Then we go through the list that was retrieved from the .newsrc
15053 ;; file. This list has elements on the form
15054 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15055 ;; is in the reverse order of the options line) is returned.
15057 (let ((regs gnus-newsrc-options-n))
15059 (not (string-match (caar regs) group)))
15060 (setq regs (cdr regs)))
15061 (and regs (cdar regs))))))
15063 (defun gnus-ask-server-for-new-groups ()
15064 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15065 (methods (cons gnus-select-method
15067 (when gnus-message-archive-method
15070 (and (consp gnus-check-new-newsgroups)
15071 gnus-check-new-newsgroups)
15072 gnus-secondary-select-methods))))
15074 (new-date (current-time-string))
15075 group new-newsgroups got-new method hashtb
15076 gnus-override-subscribe-method)
15077 ;; Go through both primary and secondary select methods and
15078 ;; request new newsgroups.
15079 (while (setq method (gnus-server-get-method nil (pop methods)))
15080 (setq new-newsgroups nil)
15081 (setq gnus-override-subscribe-method method)
15082 (when (and (gnus-check-server method)
15083 (gnus-request-newgroups date method))
15086 (setq hashtb (gnus-make-hashtable 100))
15087 (set-buffer nntp-server-buffer)
15088 ;; Enter all the new groups into a hashtable.
15089 (gnus-active-to-gnus-format method hashtb 'ignore)))
15090 ;; Now all new groups from `method' are in `hashtb'.
15092 (lambda (group-sym)
15093 (if (or (null (setq group (symbol-name group-sym)))
15094 (null (symbol-value group-sym))
15095 (gnus-gethash group gnus-newsrc-hashtb)
15096 (member group gnus-zombie-list)
15097 (member group gnus-killed-list))
15098 ;; The group is already known.
15100 ;; Make this group active.
15101 (when (symbol-value group-sym)
15102 (gnus-set-active group (symbol-value group-sym)))
15103 ;; Check whether we want it or not.
15104 (let ((do-sub (gnus-matches-options-n group)))
15106 ((eq do-sub 'subscribe)
15108 (gnus-sethash group group gnus-killed-hashtb)
15109 (funcall gnus-subscribe-options-newsgroup-method group))
15110 ((eq do-sub 'ignore)
15114 (gnus-sethash group group gnus-killed-hashtb)
15115 (if gnus-subscribe-hierarchical-interactive
15116 (push group new-newsgroups)
15117 (funcall gnus-subscribe-newsgroup-method group)))))))
15119 (when new-newsgroups
15120 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15121 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15123 (gnus-message 6 "%d new newsgroup%s arrived."
15124 groups (if (> groups 1) "s have" " has")))
15125 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15128 (defun gnus-check-first-time-used ()
15129 (if (or (> (length gnus-newsrc-alist) 1)
15130 (file-exists-p gnus-startup-file)
15131 (file-exists-p (concat gnus-startup-file ".el"))
15132 (file-exists-p (concat gnus-startup-file ".eld")))
15134 (gnus-message 6 "First time user; subscribing you to default groups")
15135 (unless gnus-have-read-active-file
15136 (gnus-read-active-file))
15137 (setq gnus-newsrc-last-checked-date (current-time-string))
15138 (let ((groups gnus-default-subscribed-newsgroups)
15142 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15145 (if (null (setq group (symbol-name sym)))
15147 (let ((do-sub (gnus-matches-options-n group)))
15149 ((eq do-sub 'subscribe)
15150 (gnus-sethash group group gnus-killed-hashtb)
15151 (funcall gnus-subscribe-options-newsgroup-method group))
15152 ((eq do-sub 'ignore)
15155 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15156 gnus-active-hashtb)
15158 (if (gnus-active (car groups))
15159 (gnus-group-change-level
15160 (car groups) gnus-level-default-subscribed gnus-level-killed))
15161 (setq groups (cdr groups)))
15162 (gnus-group-make-help-group)
15163 (and gnus-novice-user
15164 (gnus-message 7 "`A k' to list killed groups"))))))
15166 (defun gnus-subscribe-group (group previous &optional method)
15167 (gnus-group-change-level
15169 (list t group gnus-level-default-subscribed nil nil method)
15171 gnus-level-default-subscribed gnus-level-killed previous t))
15173 ;; `gnus-group-change-level' is the fundamental function for changing
15174 ;; subscription levels of newsgroups. This might mean just changing
15175 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15176 ;; again, which subscribes/unsubscribes a group, which is equally
15177 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15178 ;; from 8-9 to 1-7 means that you remove the group from the list of
15179 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15180 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15181 ;; which is trivial.
15182 ;; ENTRY can either be a string (newsgroup name) or a list (if
15183 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15184 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15186 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15187 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15189 (defun gnus-group-change-level (entry level &optional oldlevel
15190 previous fromkilled)
15191 (let (group info active num)
15192 ;; Glean what info we can from the arguments
15194 (if fromkilled (setq group (nth 1 entry))
15195 (setq group (car (nth 2 entry))))
15196 (setq group entry))
15197 (if (and (stringp entry)
15199 (< oldlevel gnus-level-zombie))
15200 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15201 (if (and (not oldlevel)
15203 (setq oldlevel (gnus-info-level (nth 2 entry)))
15204 (setq oldlevel (or oldlevel 9)))
15205 (if (stringp previous)
15206 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15208 (if (and (>= oldlevel gnus-level-zombie)
15209 (gnus-gethash group gnus-newsrc-hashtb))
15210 ;; We are trying to subscribe a group that is already
15214 (or (gnus-ephemeral-group-p group)
15215 (gnus-dribble-enter
15216 (format "(gnus-group-change-level %S %S %S %S %S)"
15217 group level oldlevel (car (nth 2 previous)) fromkilled)))
15219 ;; Then we remove the newgroup from any old structures, if needed.
15220 ;; If the group was killed, we remove it from the killed or zombie
15221 ;; list. If not, and it is in fact going to be killed, we remove
15222 ;; it from the newsrc hash table and assoc.
15224 ((>= oldlevel gnus-level-zombie)
15225 (if (= oldlevel gnus-level-zombie)
15226 (setq gnus-zombie-list (delete group gnus-zombie-list))
15227 (setq gnus-killed-list (delete group gnus-killed-list))))
15229 (if (and (>= level gnus-level-zombie)
15232 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15234 (setcdr (gnus-gethash (car (nth 3 entry))
15235 gnus-newsrc-hashtb)
15237 (setcdr (cdr entry) (cdddr entry))))))
15239 ;; Finally we enter (if needed) the list where it is supposed to
15240 ;; go, and change the subscription level. If it is to be killed,
15241 ;; we enter it into the killed or zombie list.
15243 ((>= level gnus-level-zombie)
15244 ;; Remove from the hash table.
15245 (gnus-sethash group nil gnus-newsrc-hashtb)
15246 ;; We do not enter foreign groups into the list of dead
15248 (unless (gnus-group-foreign-p group)
15249 (if (= level gnus-level-zombie)
15250 (setq gnus-zombie-list (cons group gnus-zombie-list))
15251 (setq gnus-killed-list (cons group gnus-killed-list)))))
15253 ;; If the list is to be entered into the newsrc assoc, and
15254 ;; it was killed, we have to create an entry in the newsrc
15255 ;; hashtb format and fix the pointers in the newsrc assoc.
15256 (if (< oldlevel gnus-level-zombie)
15257 ;; It was alive, and it is going to stay alive, so we
15258 ;; just change the level and don't change any pointers or
15259 ;; hash table entries.
15260 (setcar (cdaddr entry) level)
15262 (setq info (cdr entry)
15264 (setq active (gnus-active group))
15266 (if active (- (1+ (cdr active)) (car active)) t))
15267 ;; Check whether the group is foreign. If so, the
15268 ;; foreign select method has to be entered into the
15270 (let ((method (or gnus-override-subscribe-method
15271 (gnus-group-method group))))
15272 (if (eq method gnus-select-method)
15273 (setq info (list group level nil))
15274 (setq info (list group level nil nil method)))))
15277 (let ((p gnus-newsrc-alist))
15281 (setq entry (cons info (cddr previous)))
15284 (setcdr (cdr previous) entry)
15285 (gnus-sethash group (cons num (cdr previous))
15286 gnus-newsrc-hashtb))
15287 (setcdr previous entry)
15288 (gnus-sethash group (cons num previous)
15289 gnus-newsrc-hashtb))
15291 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15292 (when gnus-group-change-level-function
15293 (funcall gnus-group-change-level-function group level oldlevel)))))
15295 (defun gnus-kill-newsgroup (newsgroup)
15296 "Obsolete function. Kills a newsgroup."
15297 (gnus-group-change-level
15298 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15300 (defun gnus-check-bogus-newsgroups (&optional confirm)
15301 "Remove bogus newsgroups.
15302 If CONFIRM is non-nil, the user has to confirm the deletion of every
15304 (let ((newsrc (cdr gnus-newsrc-alist))
15305 bogus group entry info)
15306 (gnus-message 5 "Checking bogus newsgroups...")
15307 (unless gnus-have-read-active-file
15308 (gnus-read-active-file))
15309 (when (member gnus-select-method gnus-have-read-active-file)
15310 ;; Find all bogus newsgroup that are subscribed.
15312 (setq info (pop newsrc)
15313 group (gnus-info-group info))
15314 (unless (or (gnus-active group) ; Active
15315 (gnus-info-method info) ; Foreign
15317 (not (gnus-y-or-n-p
15318 (format "Remove bogus newsgroup: %s " group)))))
15319 ;; Found a bogus newsgroup.
15320 (push group bogus)))
15321 ;; Remove all bogus subscribed groups by first killing them, and
15322 ;; then removing them from the list of killed groups.
15324 (when (setq entry (gnus-gethash (setq group (pop bogus))
15325 gnus-newsrc-hashtb))
15326 (gnus-group-change-level entry gnus-level-killed)
15327 (setq gnus-killed-list (delete group gnus-killed-list))))
15328 ;; Then we remove all bogus groups from the list of killed and
15329 ;; zombie groups. They are are removed without confirmation.
15330 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15333 (setq killed (symbol-value (car dead-lists)))
15335 (unless (gnus-active (setq group (pop killed)))
15336 ;; The group is bogus.
15337 ;; !!!Slow as hell.
15338 (set (car dead-lists)
15339 (delete group (symbol-value (car dead-lists))))))
15340 (setq dead-lists (cdr dead-lists))))
15341 (gnus-message 5 "Checking bogus newsgroups...done"))))
15343 (defun gnus-check-duplicate-killed-groups ()
15344 "Remove duplicates from the list of killed groups."
15346 (let ((killed gnus-killed-list))
15348 (gnus-message 9 "%d" (length killed))
15349 (setcdr killed (delete (car killed) (cdr killed)))
15350 (setq killed (cdr killed)))))
15352 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15353 ;; and compute how many unread articles there are in each group.
15354 (defun gnus-get-unread-articles (&optional level)
15355 (let* ((newsrc (cdr gnus-newsrc-alist))
15356 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15359 (cond ((and gnus-activate-foreign-newsgroups
15360 (not (numberp gnus-activate-foreign-newsgroups)))
15361 (1+ gnus-level-subscribed))
15362 ((numberp gnus-activate-foreign-newsgroups)
15363 gnus-activate-foreign-newsgroups)
15366 info group active method)
15367 (gnus-message 5 "Checking new news...")
15370 (setq active (gnus-active (setq group (gnus-info-group
15371 (setq info (pop newsrc))))))
15373 ;; Check newsgroups. If the user doesn't want to check them, or
15374 ;; they can't be checked (for instance, if the news server can't
15375 ;; be reached) we just set the number of unread articles in this
15376 ;; newsgroup to t. This means that Gnus thinks that there are
15377 ;; unread articles, but it has no idea how many.
15378 (if (and (setq method (gnus-info-method info))
15379 (not (gnus-server-equal
15381 (gnus-server-get-method nil method)))
15382 (not (gnus-secondary-method-p method)))
15383 ;; These groups are foreign. Check the level.
15384 (when (<= (gnus-info-level info) foreign-level)
15385 (setq active (gnus-activate-group group 'scan))
15386 (gnus-close-group group))
15388 ;; These groups are native or secondary.
15389 (when (and (<= (gnus-info-level info) level)
15390 (not gnus-read-active-file))
15391 (setq active (gnus-activate-group group 'scan))
15392 (gnus-close-group group)))
15395 (gnus-get-unread-articles-in-group info active t)
15396 ;; The group couldn't be reached, so we nix out the number of
15397 ;; unread articles and stuff.
15398 (gnus-set-active group nil)
15399 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15401 (gnus-message 5 "Checking new news...done")))
15403 ;; Create a hash table out of the newsrc alist. The `car's of the
15404 ;; alist elements are used as keys.
15405 (defun gnus-make-hashtable-from-newsrc-alist ()
15406 (let ((alist gnus-newsrc-alist)
15407 (ohashtb gnus-newsrc-hashtb)
15409 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15411 (setq prev (setq gnus-newsrc-alist
15412 (if (equal (caar gnus-newsrc-alist)
15415 (cons (list "dummy.group" 0 nil) alist)))))
15419 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15421 gnus-newsrc-hashtb)
15423 alist (cdr alist)))))
15425 (defun gnus-make-hashtable-from-killed ()
15426 "Create a hash table from the killed and zombie lists."
15427 (let ((lists '(gnus-killed-list gnus-zombie-list))
15429 (setq gnus-killed-hashtb
15430 (gnus-make-hashtable
15431 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15432 (while (setq list (symbol-value (pop lists)))
15434 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15436 (defun gnus-get-unread-articles-in-group (info active &optional update)
15438 ;; Allow the backend to update the info in the group.
15440 (gnus-request-update-info
15441 info (gnus-find-method-for-group (gnus-info-group info))))
15442 (gnus-activate-group (gnus-info-group info)))
15443 (let* ((range (gnus-info-read info))
15445 ;; If a cache is present, we may have to alter the active info.
15446 (when (and gnus-use-cache info)
15447 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15448 ;; Modify the list of read articles according to what articles
15449 ;; are available; then tally the unread articles and add the
15450 ;; number to the group hash table entry.
15452 ((zerop (cdr active))
15455 (setq num (- (1+ (cdr active)) (car active))))
15456 ((not (listp (cdr range)))
15457 ;; Fix a single (num . num) range according to the
15458 ;; active hash table.
15459 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15460 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15461 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15462 ;; Compute number of unread articles.
15463 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15465 ;; The read list is a list of ranges. Fix them according to
15466 ;; the active hash table.
15467 ;; First peel off any elements that are below the lower
15469 (while (and (cdr range)
15471 (or (and (atom (cadr range)) (cadr range))
15473 (if (numberp (car range))
15476 (or (and (numberp (cadr range))
15479 (setcdr (car range)
15480 (or (and (numberp (nth 1 range)) (nth 1 range))
15482 (setcdr range (cddr range)))
15483 ;; Adjust the first element to be the same as the lower limit.
15484 (if (and (not (atom (car range)))
15485 (< (cdar range) (car active)))
15486 (setcdr (car range) (1- (car active))))
15487 ;; Then we want to peel off any elements that are higher
15488 ;; than the upper active limit.
15489 (let ((srange range))
15490 ;; Go past all legal elements.
15491 (while (and (cdr srange)
15492 (<= (or (and (atom (cadr srange))
15494 (caadr srange)) (cdr active)))
15495 (setq srange (cdr srange)))
15497 ;; Nuke all remaining illegal elements.
15498 (setcdr srange nil))
15500 ;; Adjust the final element.
15501 (if (and (not (atom (car srange)))
15502 (> (cdar srange) (cdr active)))
15503 (setcdr (car srange) (cdr active))))
15504 ;; Compute the number of unread articles.
15506 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15508 (or (and (atom (car range)) (car range))
15510 (setq range (cdr range)))
15511 (setq num (max 0 (- (cdr active) num)))))
15512 ;; Set the number of unread articles.
15514 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15517 (defun gnus-activate-group (group &optional scan)
15518 ;; Check whether a group has been activated or not.
15519 ;; If SCAN, request a scan of that group as well.
15520 (let ((method (gnus-find-method-for-group group))
15522 (and (gnus-check-server method)
15523 ;; We escape all bugs and quit here to make it possible to
15524 ;; continue if a group is so out-there that it reports bugs
15528 (gnus-check-backend-function 'request-scan (car method))
15529 (gnus-request-scan group method))
15532 (gnus-request-group group)
15536 (set-buffer nntp-server-buffer)
15537 (goto-char (point-min))
15538 ;; Parse the result we got from `gnus-request-group'.
15539 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15541 (goto-char (match-beginning 1))
15543 group (setq active (cons (read (current-buffer))
15544 (read (current-buffer)))))
15545 ;; Return the new active info.
15548 (defun gnus-update-read-articles (group unread)
15549 "Update the list of read and ticked articles in GROUP using the
15550 UNREAD and TICKED lists.
15551 Note: UNSELECTED has to be sorted over `<'.
15552 Returns whether the updating was successful."
15553 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15554 (entry (gnus-gethash group gnus-newsrc-hashtb))
15555 (info (nth 2 entry))
15557 (unread (sort (copy-sequence unread) '<))
15559 (if (or (not info) (not active))
15560 ;; There is no info on this group if it was, in fact,
15561 ;; killed. Gnus stores no information on killed groups, so
15562 ;; there's nothing to be done.
15563 ;; One could store the information somewhere temporarily,
15564 ;; perhaps... Hmmm...
15566 ;; Remove any negative articles numbers.
15567 (while (and unread (< (car unread) 0))
15568 (setq unread (cdr unread)))
15569 ;; Remove any expired article numbers
15570 (while (and unread (< (car unread) (car active)))
15571 (setq unread (cdr unread)))
15572 ;; Compute the ranges of read articles by looking at the list of
15573 ;; unread articles.
15575 (if (/= (car unread) prev)
15576 (setq read (cons (if (= prev (1- (car unread))) prev
15577 (cons prev (1- (car unread)))) read)))
15578 (setq prev (1+ (car unread)))
15579 (setq unread (cdr unread)))
15580 (when (<= prev (cdr active))
15581 (setq read (cons (cons prev (cdr active)) read)))
15582 ;; Enter this list into the group info.
15583 (gnus-info-set-read
15584 info (if (> (length read) 1) (nreverse read) read))
15585 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15586 (gnus-get-unread-articles-in-group info (gnus-active group))
15589 (defun gnus-make-articles-unread (group articles)
15590 "Mark ARTICLES in GROUP as unread."
15591 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15592 (gnus-gethash (gnus-group-real-name group)
15593 gnus-newsrc-hashtb))))
15594 (ranges (gnus-info-read info))
15597 (when (gnus-member-of-range
15598 (setq article (pop articles)) ranges)
15599 (setq news (cons article news))))
15601 (gnus-info-set-read
15602 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15603 (gnus-group-update-group group t))))
15605 ;; Enter all dead groups into the hashtb.
15606 (defun gnus-update-active-hashtb-from-killed ()
15607 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15608 (lists (list gnus-killed-list gnus-zombie-list))
15611 (setq killed (car lists))
15613 (gnus-sethash (car killed) nil hashtb)
15614 (setq killed (cdr killed)))
15615 (setq lists (cdr lists)))))
15617 ;; Get the active file(s) from the backend(s).
15618 (defun gnus-read-active-file ()
15619 (gnus-group-set-mode-line)
15622 (if (gnus-check-server gnus-select-method)
15623 ;; The native server is available.
15624 (cons gnus-select-method gnus-secondary-select-methods)
15625 ;; The native server is down, so we just do the
15627 gnus-secondary-select-methods)
15628 ;; Also read from the archive server.
15629 (when gnus-message-archive-method
15630 (list "archive"))))
15632 (setq gnus-have-read-active-file nil)
15634 (set-buffer nntp-server-buffer)
15636 (let* ((method (if (stringp (car methods))
15637 (gnus-server-get-method nil (car methods))
15639 (where (nth 1 method))
15640 (mesg (format "Reading active file%s via %s..."
15641 (if (and where (not (zerop (length where))))
15642 (concat " from " where) "")
15644 (gnus-message 5 mesg)
15645 (when (gnus-check-server method)
15646 ;; Request that the backend scan its incoming messages.
15647 (and (gnus-check-backend-function 'request-scan (car method))
15648 (gnus-request-scan nil method))
15650 ((and (eq gnus-read-active-file 'some)
15651 (gnus-check-backend-function 'retrieve-groups (car method)))
15652 (let ((newsrc (cdr gnus-newsrc-alist))
15653 (gmethod (if (stringp method)
15654 (gnus-server-get-method nil method)
15657 (while (setq info (pop newsrc))
15658 (when (gnus-server-equal
15659 (gnus-find-method-for-group
15660 (gnus-info-group info) info)
15662 (push (gnus-group-real-name (gnus-info-group info))
15665 (gnus-check-server method)
15666 (setq list-type (gnus-retrieve-groups groups method))
15670 1 "Cannot read partial active file from %s server."
15674 ((eq list-type 'active)
15675 (gnus-active-to-gnus-format method gnus-active-hashtb))
15677 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15679 (if (not (gnus-request-list method))
15681 (unless (equal method gnus-message-archive-method)
15682 (gnus-message 1 "Cannot read active file from %s server."
15685 (gnus-active-to-gnus-format method)
15686 ;; We mark this active file as read.
15687 (push method gnus-have-read-active-file)
15688 (gnus-message 5 "%sdone" mesg))))))
15689 (setq methods (cdr methods))))))
15691 ;; Read an active file and place the results in `gnus-active-hashtb'.
15692 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15694 (setq method gnus-select-method))
15695 (let ((cur (current-buffer))
15697 (if (and gnus-active-hashtb
15698 (not (equal method gnus-select-method)))
15700 (setq gnus-active-hashtb
15701 (if (equal method gnus-select-method)
15702 (gnus-make-hashtable
15703 (count-lines (point-min) (point-max)))
15704 (gnus-make-hashtable 4096)))))))
15705 ;; Delete unnecessary lines.
15706 (goto-char (point-min))
15707 (while (search-forward "\nto." nil t)
15708 (delete-region (1+ (match-beginning 0))
15709 (progn (forward-line 1) (point))))
15710 (or (string= gnus-ignored-newsgroups "")
15712 (goto-char (point-min))
15713 (delete-matching-lines gnus-ignored-newsgroups)))
15714 ;; Make the group names readable as a lisp expression even if they
15715 ;; contain special characters.
15716 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15717 (goto-char (point-max))
15718 (while (re-search-backward "[][';?()#]" nil t)
15720 ;; If these are groups from a foreign select method, we insert the
15721 ;; group prefix in front of the group names.
15722 (and method (not (gnus-server-equal
15723 (gnus-server-get-method nil method)
15724 (gnus-server-get-method nil gnus-select-method)))
15725 (let ((prefix (gnus-group-prefixed-name "" method)))
15726 (goto-char (point-min))
15727 (while (and (not (eobp))
15728 (progn (insert prefix)
15729 (zerop (forward-line 1)))))))
15730 ;; Store the active file in a hash table.
15731 (goto-char (point-min))
15732 (if (string-match "%[oO]" gnus-group-line-format)
15733 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15734 ;; If we want information on moderated groups, we use this
15736 (let* ((mod-hashtb (make-vector 7 0))
15737 (m (intern "m" mod-hashtb))
15739 (while (not (eobp))
15740 (condition-case nil
15742 (narrow-to-region (point) (gnus-point-at-eol))
15743 (setq group (let ((obarray hashtb)) (read cur)))
15744 (if (and (numberp (setq max (read cur)))
15745 (numberp (setq min (read cur)))
15747 (skip-chars-forward " \t")
15749 (or (= (following-char) ?=)
15750 (= (following-char) ?x)
15751 (= (following-char) ?j)))))
15752 (set group (cons min max))
15754 ;; Enter moderated groups into a list.
15755 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15756 (setq gnus-moderated-list
15757 (cons (symbol-name group) gnus-moderated-list))))
15764 ;; And if we do not care about moderation, we use this loop,
15765 ;; which is faster.
15766 (let (group max min)
15767 (while (not (eobp))
15770 (narrow-to-region (point) (gnus-point-at-eol))
15771 ;; group gets set to a symbol interned in the hash table
15772 ;; (what a hack!!) - jwz
15773 (setq group (let ((obarray hashtb)) (read cur)))
15774 (if (and (numberp (setq max (read cur)))
15775 (numberp (setq min (read cur)))
15777 (skip-chars-forward " \t")
15779 (or (= (following-char) ?=)
15780 (= (following-char) ?x)
15781 (= (following-char) ?j)))))
15782 (set group (cons min max))
15790 (gnus-message 3 "Warning - illegal active: %s"
15792 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15794 (forward-line 1))))))
15796 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15797 ;; Parse a "groups" active file.
15798 (let ((cur (current-buffer))
15800 (if (and method gnus-active-hashtb)
15802 (setq gnus-active-hashtb
15803 (gnus-make-hashtable
15804 (count-lines (point-min) (point-max)))))))
15805 (prefix (and method
15806 (not (gnus-server-equal
15807 (gnus-server-get-method nil method)
15808 (gnus-server-get-method nil gnus-select-method)))
15809 (gnus-group-prefixed-name "" method))))
15811 (goto-char (point-min))
15812 ;; We split this into to separate loops, one with the prefix
15813 ;; and one without to speed the reading up somewhat.
15815 (let (min max opoint group)
15816 (while (not (eobp))
15819 (read cur) (read cur)
15820 (setq min (read cur)
15823 (skip-chars-forward " \t")
15826 (set (let ((obarray hashtb)) (read cur))
15828 (error (and group (symbolp group) (set group nil))))
15830 (let (min max group)
15831 (while (not (eobp))
15833 (if (= (following-char) ?2)
15835 (read cur) (read cur)
15836 (setq min (read cur)
15838 (set (setq group (let ((obarray hashtb)) (read cur)))
15840 (error (and group (symbolp group) (set group nil))))
15841 (forward-line 1))))))
15843 (defun gnus-read-newsrc-file (&optional force)
15844 "Read startup file.
15845 If FORCE is non-nil, the .newsrc file is read."
15846 ;; Reset variables that might be defined in the .newsrc.eld file.
15847 (let ((variables gnus-variable-list))
15849 (set (car variables) nil)
15850 (setq variables (cdr variables))))
15851 (let* ((newsrc-file gnus-current-startup-file)
15852 (quick-file (concat newsrc-file ".el")))
15854 ;; We always load the .newsrc.eld file. If always contains
15855 ;; much information that can not be gotten from the .newsrc
15856 ;; file (ticked articles, killed groups, foreign methods, etc.)
15857 (gnus-read-newsrc-el-file quick-file)
15859 (if (and (file-exists-p gnus-current-startup-file)
15861 (and (file-newer-than-file-p newsrc-file quick-file)
15862 (file-newer-than-file-p newsrc-file
15863 (concat quick-file "d")))
15864 (not gnus-newsrc-alist)))
15865 ;; We read the .newsrc file. Note that if there if a
15866 ;; .newsrc.eld file exists, it has already been read, and
15867 ;; the `gnus-newsrc-hashtb' has been created. While reading
15868 ;; the .newsrc file, Gnus will only use the information it
15869 ;; can find there for changing the data already read -
15870 ;; ie. reading the .newsrc file will not trash the data
15871 ;; already read (except for read articles).
15873 (gnus-message 5 "Reading %s..." newsrc-file)
15874 (set-buffer (find-file-noselect newsrc-file))
15875 (buffer-disable-undo (current-buffer))
15876 (gnus-newsrc-to-gnus-format)
15877 (kill-buffer (current-buffer))
15878 (gnus-message 5 "Reading %s...done" newsrc-file)))
15880 ;; Read any slave files.
15882 (gnus-master-read-slave-newsrc)))))
15884 (defun gnus-read-newsrc-el-file (file)
15885 (let ((ding-file (concat file "d")))
15886 ;; We always, always read the .eld file.
15887 (gnus-message 5 "Reading %s..." ding-file)
15888 (let (gnus-newsrc-assoc)
15889 (condition-case nil
15890 (load ding-file t t t)
15892 (gnus-message 1 "Error in %s" ding-file)
15894 (when gnus-newsrc-assoc
15895 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15896 (gnus-make-hashtable-from-newsrc-alist)
15897 (when (file-newer-than-file-p file ding-file)
15898 ;; Old format quick file
15899 (gnus-message 5 "Reading %s..." file)
15900 ;; The .el file is newer than the .eld file, so we read that one
15902 (gnus-read-old-newsrc-el-file file))))
15904 ;; Parse the old-style quick startup file
15905 (defun gnus-read-old-newsrc-el-file (file)
15906 (let (newsrc killed marked group m info)
15908 (let ((gnus-killed-assoc nil)
15909 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15911 (condition-case nil
15914 (setq newsrc gnus-newsrc-assoc
15915 killed gnus-killed-assoc
15916 marked gnus-marked-assoc)))
15917 (setq gnus-newsrc-alist nil)
15918 (while (setq info (gnus-get-info (setq group (pop newsrc))))
15921 (gnus-info-set-read info (cddr group))
15922 (gnus-info-set-level
15923 info (if (nth 1 group) gnus-level-default-subscribed
15924 gnus-level-default-unsubscribed))
15925 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15928 (if (nth 1 group) gnus-level-default-subscribed
15929 gnus-level-default-unsubscribed)
15931 gnus-newsrc-alist))
15932 ;; Copy marks into info.
15933 (when (setq m (assoc (car group) marked))
15934 (unless (nthcdr 3 info)
15935 (nconc info (list nil)))
15936 (gnus-info-set-marks
15937 info (list (cons 'tick (gnus-compress-sequence
15938 (sort (cdr m) '<) t))))))
15939 (setq newsrc killed)
15941 (setcar newsrc (caar newsrc))
15942 (setq newsrc (cdr newsrc)))
15943 (setq gnus-killed-list killed))
15944 ;; The .el file version of this variable does not begin with
15945 ;; "options", while the .eld version does, so we just add it if it
15948 gnus-newsrc-options
15950 (and (not (string-match "^ *options" gnus-newsrc-options))
15951 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15952 (and (not (string-match "\n$" gnus-newsrc-options))
15953 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15954 ;; Finally, if we read some options lines, we parse them.
15955 (or (string= gnus-newsrc-options "")
15956 (gnus-newsrc-parse-options gnus-newsrc-options))))
15958 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15959 (gnus-make-hashtable-from-newsrc-alist)))
15961 (defun gnus-make-newsrc-file (file)
15962 "Make server dependent file name by catenating FILE and server host name."
15963 (let* ((file (expand-file-name file nil))
15964 (real-file (concat file "-" (nth 1 gnus-select-method))))
15965 (if (or (file-exists-p real-file)
15966 (file-exists-p (concat real-file ".el"))
15967 (file-exists-p (concat real-file ".eld")))
15970 (defun gnus-newsrc-to-gnus-format ()
15971 (setq gnus-newsrc-options "")
15972 (setq gnus-newsrc-options-n nil)
15974 (or gnus-active-hashtb
15975 (setq gnus-active-hashtb (make-vector 4095 0)))
15976 (let ((buf (current-buffer))
15977 (already-read (> (length gnus-newsrc-alist) 1))
15978 group subscribed options-symbol newsrc Options-symbol
15980 (goto-char (point-min))
15981 ;; We intern the symbol `options' in the active hashtb so that we
15982 ;; can `eq' against it later.
15983 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15984 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15986 (while (not (eobp))
15987 ;; We first read the first word on the line by narrowing and
15988 ;; then reading into `gnus-active-hashtb'. Most groups will
15989 ;; already exist in that hashtb, so this will save some string
15993 (progn (skip-chars-forward "^ \t!:\n") (point)))
15994 (goto-char (point-min))
15996 (and (/= (point-min) (point-max))
15997 (let ((obarray gnus-active-hashtb)) (read buf))))
15999 ;; Now, the symbol we have read is either `options' or a group
16000 ;; name. If it is an options line, we just add it to a string.
16002 ((or (eq symbol options-symbol)
16003 (eq symbol Options-symbol))
16004 (setq gnus-newsrc-options
16005 ;; This concating is quite inefficient, but since our
16006 ;; thorough studies show that approx 99.37% of all
16007 ;; .newsrc files only contain a single options line, we
16008 ;; don't give a damn, frankly, my dear.
16009 (concat gnus-newsrc-options
16011 (gnus-point-at-bol)
16012 ;; Options may continue on the next line.
16013 (or (and (re-search-forward "^[^ \t]" nil 'move)
16014 (progn (beginning-of-line) (point)))
16018 ;; Group names can be just numbers.
16019 (when (numberp symbol)
16020 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16021 (or (boundp symbol) (set symbol nil))
16022 ;; It was a group name.
16023 (setq subscribed (= (following-char) ?:)
16024 group (symbol-name symbol)
16027 ;; If the line ends here, this is clearly a buggy line, so
16028 ;; we put point a the beginning of line and let the cond
16029 ;; below do the error handling.
16030 (beginning-of-line)
16031 ;; We skip to the beginning of the ranges.
16032 (skip-chars-forward "!: \t"))
16033 ;; We are now at the beginning of the list of read articles.
16034 ;; We read them range by range.
16037 ((looking-at "[0-9]+")
16038 ;; We narrow and read a number instead of buffer-substring/
16039 ;; string-to-int because it's faster. narrow/widen is
16040 ;; faster than save-restriction/narrow, and save-restriction
16041 ;; produces a garbage object.
16043 (narrow-to-region (match-beginning 0) (match-end 0))
16046 ;; If the next character is a dash, then this is a range.
16047 (if (= (following-char) ?-)
16049 ;; We read the upper bound of the range.
16051 (if (not (looking-at "[0-9]+"))
16052 ;; This is a buggy line, by we pretend that
16053 ;; it's kinda OK. Perhaps the user should be
16055 (setq reads (cons num1 reads))
16060 (narrow-to-region (match-beginning 0)
16065 ;; It was just a simple number, so we add it to the
16067 (setq reads (cons num1 reads)))
16068 ;; If the next char in ?\n, then we have reached the end
16069 ;; of the line and return nil.
16070 (/= (following-char) ?\n))
16071 ((= (following-char) ?\n)
16072 ;; End of line, so we end.
16075 ;; Not numbers and not eol, so this might be a buggy
16078 ;; If it was eob instead of ?\n, we allow it.
16080 ;; The line was buggy.
16082 (gnus-message 3 "Mangled line: %s"
16083 (buffer-substring (gnus-point-at-bol)
16084 (gnus-point-at-eol)))
16088 ;; Skip past ", ". Spaces are illegal in these ranges, but
16089 ;; we allow them, because it's a common mistake to put a
16090 ;; space after the comma.
16091 (skip-chars-forward ", "))
16093 ;; We have already read .newsrc.eld, so we gently update the
16094 ;; data in the hash table with the information we have just
16097 (let ((info (gnus-get-info group))
16100 ;; There is an entry for this file in the alist.
16102 (gnus-info-set-read info (nreverse reads))
16103 ;; We update the level very gently. In fact, we
16104 ;; only change it if there's been a status change
16105 ;; from subscribed to unsubscribed, or vice versa.
16106 (setq level (gnus-info-level info))
16107 (cond ((and (<= level gnus-level-subscribed)
16109 (setq level (if reads
16110 gnus-level-default-unsubscribed
16111 (1+ gnus-level-default-unsubscribed))))
16112 ((and (> level gnus-level-subscribed) subscribed)
16113 (setq level gnus-level-default-subscribed)))
16114 (gnus-info-set-level info level))
16115 ;; This is a new group.
16116 (setq info (list group
16118 gnus-level-default-subscribed
16120 (1+ gnus-level-subscribed)
16121 gnus-level-default-unsubscribed))
16122 (nreverse reads))))
16123 (setq newsrc (cons info newsrc))))))
16126 (setq newsrc (nreverse newsrc))
16128 (if (not already-read)
16130 ;; We now have two newsrc lists - `newsrc', which is what we
16131 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16132 ;; what we've read from .newsrc.eld. We have to merge these
16133 ;; lists. We do this by "attaching" any (foreign) groups in the
16134 ;; gnus-newsrc-alist to the (native) group that precedes them.
16135 (let ((rc (cdr gnus-newsrc-alist))
16136 (prev gnus-newsrc-alist)
16139 (or (null (nth 4 (car rc))) ; It's a native group.
16140 (assoc (caar rc) newsrc) ; It's already in the alist.
16141 (if (setq entry (assoc (caar prev) newsrc))
16142 (setcdr (setq mentry (memq entry newsrc))
16143 (cons (car rc) (cdr mentry)))
16144 (setq newsrc (cons (car rc) newsrc))))
16148 (setq gnus-newsrc-alist newsrc)
16149 ;; We make the newsrc hashtb.
16150 (gnus-make-hashtable-from-newsrc-alist)
16152 ;; Finally, if we read some options lines, we parse them.
16153 (or (string= gnus-newsrc-options "")
16154 (gnus-newsrc-parse-options gnus-newsrc-options))))
16156 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16157 ;; The return value will be a list on the form
16158 ;; ((regexp1 . ignore)
16159 ;; (regexp2 . subscribe)...)
16160 ;; When handling new newsgroups, groups that match a `ignore' regexp
16161 ;; will be ignored, and groups that match a `subscribe' regexp will be
16162 ;; subscribed. A line like
16163 ;; options -n !all rec.all
16164 ;; will lead to a list that looks like
16165 ;; (("^rec\\..+" . subscribe)
16166 ;; ("^.+" . ignore))
16167 ;; So all "rec.*" groups will be subscribed, while all the other
16168 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16169 ;; different from "options -n rec.all !all".
16170 (defun gnus-newsrc-parse-options (options)
16173 (gnus-set-work-buffer)
16174 (insert (regexp-quote options))
16175 ;; First we treat all continuation lines.
16176 (goto-char (point-min))
16177 (while (re-search-forward "\n[ \t]+" nil t)
16178 (replace-match " " t t))
16179 ;; Then we transform all "all"s into ".+"s.
16180 (goto-char (point-min))
16181 (while (re-search-forward "\\ball\\b" nil t)
16182 (replace-match ".+" t t))
16183 (goto-char (point-min))
16184 ;; We remove all other options than the "-n" ones.
16185 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16186 (replace-match " ")
16188 (goto-char (point-min))
16190 ;; We are only interested in "options -n" lines - we
16191 ;; ignore the other option lines.
16192 (while (re-search-forward "[ \t]-n" nil t)
16194 (or (save-excursion
16195 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16197 (gnus-point-at-eol)))
16198 ;; Search for all "words"...
16199 (while (re-search-forward "[^ \t,\n]+" eol t)
16200 (if (= (char-after (match-beginning 0)) ?!)
16201 ;; If the word begins with a bang (!), this is a "not"
16202 ;; spec. We put this spec (minus the bang) and the
16203 ;; symbol `ignore' into the list.
16204 (setq out (cons (cons (concat
16205 "^" (buffer-substring
16206 (1+ (match-beginning 0))
16209 ;; There was no bang, so this is a "yes" spec.
16210 (setq out (cons (cons (concat "^" (match-string 0))
16211 'subscribe) out)))))
16213 (setq gnus-newsrc-options-n out))))
16215 (defun gnus-save-newsrc-file (&optional force)
16216 "Save .newsrc file."
16217 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16218 ;; from the variable gnus-newsrc-alist.
16219 (when (and (or gnus-newsrc-alist gnus-killed-list)
16220 gnus-current-startup-file)
16222 (if (and (or gnus-use-dribble-file gnus-slave)
16224 (or (not gnus-dribble-buffer)
16225 (not (buffer-name gnus-dribble-buffer))
16226 (zerop (save-excursion
16227 (set-buffer gnus-dribble-buffer)
16229 (gnus-message 4 "(No changes need to be saved)")
16230 (run-hooks 'gnus-save-newsrc-hook)
16232 (gnus-slave-save-newsrc)
16234 (when gnus-save-newsrc-file
16235 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16236 (gnus-gnus-to-newsrc-format)
16237 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16238 ;; Save .newsrc.eld.
16239 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16240 (make-local-variable 'version-control)
16241 (setq version-control 'never)
16242 (setq buffer-file-name
16243 (concat gnus-current-startup-file ".eld"))
16244 (gnus-add-current-to-buffer-list)
16245 (buffer-disable-undo (current-buffer))
16247 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16248 (gnus-gnus-to-quick-newsrc-format)
16249 (run-hooks 'gnus-save-quick-newsrc-hook)
16251 (kill-buffer (current-buffer))
16253 5 "Saving %s.eld...done" gnus-current-startup-file))
16254 (gnus-dribble-delete-file)))))
16256 (defun gnus-gnus-to-quick-newsrc-format ()
16257 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16258 (insert ";; Gnus startup file.\n")
16259 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16260 (insert ";; to read .newsrc.\n")
16261 (insert "(setq gnus-newsrc-file-version "
16262 (prin1-to-string gnus-version) ")\n")
16264 (if gnus-save-killed-list gnus-variable-list
16265 ;; Remove the `gnus-killed-list' from the list of variables
16266 ;; to be saved, if required.
16267 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16268 ;; Peel off the "dummy" group.
16269 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16271 ;; Insert the variables into the file.
16273 (when (and (boundp (setq variable (pop variables)))
16274 (symbol-value variable))
16275 (insert "(setq " (symbol-name variable) " '")
16276 (prin1 (symbol-value variable) (current-buffer))
16279 (defun gnus-gnus-to-newsrc-format ()
16280 ;; Generate and save the .newsrc file.
16282 (set-buffer (create-file-buffer gnus-current-startup-file))
16283 (let ((newsrc (cdr gnus-newsrc-alist))
16284 (standard-output (current-buffer))
16285 info ranges range method)
16286 (setq buffer-file-name gnus-current-startup-file)
16287 (buffer-disable-undo (current-buffer))
16290 (if gnus-newsrc-options (insert gnus-newsrc-options))
16291 ;; Write subscribed and unsubscribed.
16292 (while (setq info (pop newsrc))
16293 ;; Don't write foreign groups to .newsrc.
16294 (when (or (null (setq method (gnus-info-method info)))
16295 (equal method "native")
16296 (gnus-server-equal method gnus-select-method))
16297 (insert (gnus-info-group info)
16298 (if (> (gnus-info-level info) gnus-level-subscribed)
16300 (when (setq ranges (gnus-info-read info))
16302 (if (not (listp (cdr ranges)))
16303 (if (= (car ranges) (cdr ranges))
16304 (princ (car ranges))
16305 (princ (car ranges))
16307 (princ (cdr ranges)))
16308 (while (setq range (pop ranges))
16309 (if (or (atom range) (= (car range) (cdr range)))
16310 (princ (or (and (atom range) range) (car range)))
16311 (princ (car range))
16313 (princ (cdr range)))
16314 (if ranges (insert ",")))))
16316 (make-local-variable 'version-control)
16317 (setq version-control 'never)
16318 ;; It has been reported that sometime the modtime on the .newsrc
16319 ;; file seems to be off. We really do want to overwrite it, so
16320 ;; we clear the modtime here before saving. It's a bit odd,
16322 ;; sometimes the modtime clear isn't sufficient. most brute force:
16323 ;; delete the silly thing entirely first. but this fails to provide
16324 ;; such niceties as .newsrc~ creation.
16325 (if gnus-modtime-botch
16326 (delete-file gnus-startup-file)
16327 (clear-visited-file-modtime))
16328 (run-hooks 'gnus-save-standard-newsrc-hook)
16330 (kill-buffer (current-buffer)))))
16334 ;;; Slave functions.
16337 (defun gnus-slave-save-newsrc ()
16339 (set-buffer gnus-dribble-buffer)
16341 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16342 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16344 (defun gnus-master-read-slave-newsrc ()
16347 (file-name-directory gnus-current-startup-file)
16351 (file-name-nondirectory gnus-current-startup-file)
16355 (if (not slave-files)
16356 () ; There are no slave files to read.
16357 (gnus-message 7 "Reading slave newsrcs...")
16359 (set-buffer (get-buffer-create " *gnus slave*"))
16360 (buffer-disable-undo (current-buffer))
16362 (sort (mapcar (lambda (file)
16363 (list (nth 5 (file-attributes file)) file))
16366 (or (< (caar f1) (caar f2))
16367 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16370 (setq file (nth 1 (car slave-files)))
16371 (insert-file-contents file)
16372 (if (condition-case ()
16374 (eval-buffer (current-buffer))
16377 (gnus-message 3 "Possible error in %s" file)
16381 (or gnus-slave ; Slaves shouldn't delete these files.
16385 (setq slave-files (cdr slave-files))))
16386 (gnus-message 7 "Reading slave newsrcs...done"))))
16390 ;;; Group description.
16393 (defun gnus-read-all-descriptions-files ()
16394 (let ((methods (cons gnus-select-method
16396 (when gnus-message-archive-method
16398 gnus-secondary-select-methods))))
16400 (gnus-read-descriptions-file (car methods))
16401 (setq methods (cdr methods)))
16404 (defun gnus-read-descriptions-file (&optional method)
16405 (let ((method (or method gnus-select-method)))
16406 (when (stringp method)
16407 (setq method (gnus-server-to-method method)))
16408 ;; We create the hashtable whether we manage to read the desc file
16409 ;; to avoid trying to re-read after a failed read.
16410 (or gnus-description-hashtb
16411 (setq gnus-description-hashtb
16412 (gnus-make-hashtable (length gnus-active-hashtb))))
16413 ;; Mark this method's desc file as read.
16414 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16415 gnus-description-hashtb)
16417 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16419 ((not (gnus-check-server method))
16420 (gnus-message 1 "Couldn't open server")
16422 ((not (gnus-request-list-newsgroups method))
16423 (gnus-message 1 "Couldn't read newsgroups descriptions")
16429 (set-buffer nntp-server-buffer)
16430 (goto-char (point-min))
16431 (if (or (search-forward "\n.\n" nil t)
16432 (goto-char (point-max)))
16434 (beginning-of-line)
16435 (narrow-to-region (point-min) (point))))
16436 (goto-char (point-min))
16437 (while (not (eobp))
16438 ;; If we get an error, we set group to 0, which is not a
16442 (let ((obarray gnus-description-hashtb))
16443 ;; Group is set to a symbol interned in this
16445 (read nntp-server-buffer))
16447 (skip-chars-forward " \t")
16448 ;; ... which leads to this line being effectively ignored.
16449 (and (symbolp group)
16450 (set group (buffer-substring
16451 (point) (progn (end-of-line) (point)))))
16452 (forward-line 1))))
16453 (gnus-message 5 "Reading descriptions file...done")
16456 (defun gnus-group-get-description (group)
16457 "Get the description of a group by sending XGTITLE to the server."
16458 (when (gnus-request-group-description group)
16460 (set-buffer nntp-server-buffer)
16461 (goto-char (point-min))
16462 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16463 (match-string 1)))))
16470 (defvar gnus-shutdown-alist nil)
16472 (defun gnus-add-shutdown (function &rest symbols)
16473 "Run FUNCTION whenever one of SYMBOLS is shut down."
16474 (push (cons function symbols) gnus-shutdown-alist))
16476 (defun gnus-shutdown (symbol)
16477 "Shut down everything that waits for SYMBOL."
16478 (let ((alist gnus-shutdown-alist)
16480 (while (setq entry (pop alist))
16481 (when (memq symbol (cdr entry))
16482 (funcall (car entry))))))
16486 ;;; Buffering of read articles.
16489 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16490 (defvar gnus-backlog-articles nil)
16491 (defvar gnus-backlog-hashtb nil)
16493 (defun gnus-backlog-buffer ()
16494 "Return the backlog buffer."
16495 (or (get-buffer gnus-backlog-buffer)
16497 (set-buffer (get-buffer-create gnus-backlog-buffer))
16498 (buffer-disable-undo (current-buffer))
16499 (setq buffer-read-only t)
16500 (gnus-add-current-to-buffer-list)
16501 (get-buffer gnus-backlog-buffer))))
16503 (defun gnus-backlog-setup ()
16504 "Initialize backlog variables."
16505 (unless gnus-backlog-hashtb
16506 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16508 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16510 (defun gnus-backlog-shutdown ()
16511 "Clear all backlog variables and buffers."
16512 (when (get-buffer gnus-backlog-buffer)
16513 (kill-buffer gnus-backlog-buffer))
16514 (setq gnus-backlog-hashtb nil
16515 gnus-backlog-articles nil))
16517 (defun gnus-backlog-enter-article (group number buffer)
16518 (gnus-backlog-setup)
16519 (let ((ident (intern (concat group ":" (int-to-string number))
16520 gnus-backlog-hashtb))
16522 (if (memq ident gnus-backlog-articles)
16523 () ; It's already kept.
16524 ;; Remove the oldest article, if necessary.
16525 (and (numberp gnus-keep-backlog)
16526 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16527 (gnus-backlog-remove-oldest-article))
16528 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16529 ;; Insert the new article.
16531 (set-buffer (gnus-backlog-buffer))
16532 (let (buffer-read-only)
16533 (goto-char (point-max))
16534 (or (bolp) (insert "\n"))
16536 (insert-buffer-substring buffer)
16537 ;; Tag the beginning of the article with the ident.
16538 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16540 (defun gnus-backlog-remove-oldest-article ()
16542 (set-buffer (gnus-backlog-buffer))
16543 (goto-char (point-min))
16544 (if (zerop (buffer-size))
16545 () ; The buffer is empty.
16546 (let ((ident (get-text-property (point) 'gnus-backlog))
16548 ;; Remove the ident from the list of articles.
16550 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16551 ;; Delete the article itself.
16553 (point) (next-single-property-change
16554 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16556 (defun gnus-backlog-request-article (group number buffer)
16557 (when (numberp number)
16558 (gnus-backlog-setup)
16559 (let ((ident (intern (concat group ":" (int-to-string number))
16560 gnus-backlog-hashtb))
16562 (when (memq ident gnus-backlog-articles)
16563 ;; It was in the backlog.
16565 (set-buffer (gnus-backlog-buffer))
16566 (if (not (setq beg (text-property-any
16567 (point-min) (point-max) 'gnus-backlog
16569 ;; It wasn't in the backlog after all.
16571 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16572 ;; Find the end (i. e., the beginning of the next article).
16574 (next-single-property-change
16575 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16576 (let ((buffer-read-only nil))
16578 (insert-buffer-substring gnus-backlog-buffer beg end)
16581 ;; Allow redefinition of Gnus functions.
16583 (gnus-ems-redefine)
16587 ;;; gnus.el ends here