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))
36 (eval-when-compile (require 'cl))
38 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
39 "*Directory variable from which all other Gnus file variables are derived.")
41 ;; Site dependent variables. These variables should be defined in
44 (defvar gnus-default-nntp-server nil
45 "Specify a default NNTP server.
46 This variable should be defined in paths.el, and should never be set
48 If you want to change servers, you should use `gnus-select-method'.
49 See the documentation to that variable.")
51 (defvar gnus-backup-default-subscribed-newsgroups
52 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
53 "Default default new newsgroups the first time Gnus is run.
54 Should be set in paths.el, and shouldn't be touched by the user.")
56 (defvar gnus-local-domain nil
57 "Local domain name without a host name.
58 The DOMAINNAME environment variable is used instead if it is defined.
59 If the `system-name' function returns the full Internet name, there is
60 no need to set this variable.")
62 (defvar gnus-local-organization nil
63 "String with a description of what organization (if any) the user belongs to.
64 The ORGANIZATION environment variable is used instead if it is defined.
65 If this variable contains a function, this function will be called
66 with the current newsgroup name as the argument. The function should
69 In any case, if the string (either in the variable, in the environment
70 variable, or returned by the function) is a file name, the contents of
71 this file will be used as the organization.")
73 ;; Customization variables
75 ;; Don't touch this variable.
76 (defvar gnus-nntp-service "nntp"
77 "*NNTP service name (\"nntp\" or 119).
78 This is an obsolete variable, which is scarcely used. If you use an
79 nntp server for your newsgroup and want to change the port number
80 used to 899, you would say something along these lines:
82 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
84 (defvar gnus-nntpserver-file "/etc/nntpserver"
85 "*A file with only the name of the nntp server in it.")
87 ;; This function is used to check both the environment variable
88 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
89 ;; an nntp server name default.
90 (defun gnus-getenv-nntpserver ()
91 (or (getenv "NNTPSERVER")
92 (and (file-readable-p gnus-nntpserver-file)
94 (set-buffer (get-buffer-create " *gnus nntp*"))
95 (buffer-disable-undo (current-buffer))
96 (insert-file-contents gnus-nntpserver-file)
97 (let ((name (buffer-string)))
99 (if (string-match "^[ \t\n]*$" name)
102 (kill-buffer (current-buffer))))))))
104 (defvar gnus-select-method
106 (list 'nntp (or (condition-case ()
107 (gnus-getenv-nntpserver)
109 (if (and gnus-default-nntp-server
110 (not (string= gnus-default-nntp-server "")))
111 gnus-default-nntp-server)
113 (if (or (null gnus-nntp-service)
114 (equal gnus-nntp-service "nntp"))
116 (list gnus-nntp-service)))
117 "*Default method for selecting a newsgroup.
118 This variable should be a list, where the first element is how the
119 news is to be fetched, the second is the address.
121 For instance, if you want to get your news via NNTP from
122 \"flab.flab.edu\", you could say:
124 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
126 If you want to use your local spool, say:
128 (setq gnus-select-method (list 'nnspool (system-name)))
130 If you use this variable, you must set `gnus-nntp-server' to nil.
132 There is a lot more to know about select methods and virtual servers -
133 see the manual for details.")
135 (defvar gnus-message-archive-method
138 (nnfolder-directory (nnheader-concat message-directory "archive"))
139 (nnfolder-active-file (nnheader-concat message-directory "archive/active"))
140 (nnfolder-get-new-mail nil)
141 (nnfolder-inhibit-expiry t))
142 "*Method used for archiving messages you've sent.
143 This should be a mail method.")
145 (defvar gnus-refer-article-method nil
146 "*Preferred method for fetching an article by Message-ID.
147 If you are reading news from the local spool (with nnspool), fetching
148 articles by Message-ID is painfully slow. By setting this method to an
149 nntp method, you might get acceptable results.
151 The value of this variable must be a valid select method as discussed
152 in the documentation of `gnus-select-method'.")
154 (defvar gnus-secondary-select-methods nil
155 "*A list of secondary methods that will be used for reading news.
156 This is a list where each element is a complete select method (see
157 `gnus-select-method').
159 If, for instance, you want to read your mail with the nnml backend,
160 you could set this variable:
162 (setq gnus-secondary-select-methods '((nnml \"\")))")
164 (defvar gnus-secondary-servers nil
165 "*List of NNTP servers that the user can choose between interactively.
166 To make Gnus query you for a server, you have to give `gnus' a
167 non-numeric prefix - `C-u M-x gnus', in short.")
169 (defvar gnus-nntp-server nil
170 "*The name of the host running the NNTP server.
171 This variable is semi-obsolete. Use the `gnus-select-method'
174 (defvar gnus-startup-file "~/.newsrc"
175 "*Your `.newsrc' file.
176 `.newsrc-SERVER' will be used instead if that exists.")
178 (defvar gnus-init-file "~/.gnus"
179 "*Your Gnus elisp startup file.
180 If a file with the .el or .elc suffixes exist, it will be read
183 (defvar gnus-group-faq-directory
184 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
185 "/ftp@sunsite.auc.dk:/pub/usenet/"
186 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
187 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
188 "/ftp@rtfm.mit.edu:/pub/usenet/"
189 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
190 "/ftp@ftp.sunet.se:/pub/usenet/"
191 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
192 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
193 "/ftp@ftp.hk.super.net:/mirror/faqs/")
194 "*Directory where the group FAQs are stored.
195 This will most commonly be on a remote machine, and the file will be
198 This variable can also be a list of directories. In that case, the
199 first element in the list will be used by default, and the others will
200 be used as backup sites.
202 Note that Gnus uses an aol machine as the default directory. If this
203 feels fundamentally unclean, just think of it as a way to finally get
204 something of value back from them.
206 If the default site is too slow, try one of these:
208 North America: mirrors.aol.com /pub/rtfm/usenet
209 ftp.seas.gwu.edu /pub/rtfm
210 rtfm.mit.edu /pub/usenet
211 Europe: ftp.uni-paderborn.de /pub/FAQ
212 src.doc.ic.ac.uk /usenet/news-FAQS
213 ftp.sunet.se /pub/usenet
214 sunsite.auc.dk /pub/usenet
215 Asia: nctuccca.edu.tw /USENET/FAQ
216 hwarang.postech.ac.kr /pub/usenet
217 ftp.hk.super.net /mirror/faqs")
219 (defvar gnus-group-archive-directory
220 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
221 "*The address of the (ding) archives.")
223 (defvar gnus-group-recent-archive-directory
224 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
225 "*The address of the most recent (ding) articles.")
227 (defvar gnus-default-subscribed-newsgroups nil
228 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
229 It should be a list of strings.
230 If it is `t', Gnus will not do anything special the first time it is
231 started; it'll just use the normal newsgroups subscription methods.")
233 (defvar gnus-use-cross-reference t
234 "*Non-nil means that cross referenced articles will be marked as read.
235 If nil, ignore cross references. If t, mark articles as read in
236 subscribed newsgroups. If neither t nor nil, mark as read in all
239 (defvar gnus-single-article-buffer t
240 "*If non-nil, display all articles in the same buffer.
241 If nil, each group will get its own article buffer.")
243 (defvar gnus-use-dribble-file t
244 "*Non-nil means that Gnus will use a dribble file to store user updates.
245 If Emacs should crash without saving the .newsrc files, complete
246 information can be restored from the dribble file.")
248 (defvar gnus-dribble-directory nil
249 "*The directory where dribble files will be saved.
250 If this variable is nil, the directory where the .newsrc files are
251 saved will be used.")
253 (defvar gnus-asynchronous nil
254 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
256 (defvar gnus-kill-summary-on-exit t
257 "*If non-nil, kill the summary buffer when you exit from it.
258 If nil, the summary will become a \"*Dead Summary*\" buffer, and
259 it will be killed sometime later.")
261 (defvar gnus-large-newsgroup 200
262 "*The number of articles which indicates a large newsgroup.
263 If the number of articles in a newsgroup is greater than this value,
264 confirmation is required for selecting the newsgroup.")
266 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
267 (defvar gnus-no-groups-message "No news is horrible news"
268 "*Message displayed by Gnus when no groups are available.")
270 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
271 "*Non-nil means that the default name of a file to save articles in is the group name.
272 If it's nil, the directory form of the group name is used instead.
274 If this variable is a list, and the list contains the element
275 `not-score', long file names will not be used for score files; if it
276 contains the element `not-save', long file names will not be used for
277 saving; and if it contains the element `not-kill', long file names
278 will not be used for kill files.")
280 (defvar gnus-article-save-directory gnus-directory
281 "*Name of the directory articles will be saved in (default \"~/News\").")
283 (defvar gnus-kill-files-directory gnus-directory
284 "*Name of the directory where kill files will be stored (default \"~/News\").")
286 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
287 "*A function to save articles in your favorite format.
288 The function must be interactively callable (in other words, it must
289 be an Emacs command).
291 Gnus provides the following functions:
293 * gnus-summary-save-in-rmail (Rmail format)
294 * gnus-summary-save-in-mail (Unix mail format)
295 * gnus-summary-save-in-folder (MH folder)
296 * gnus-summary-save-in-file (article format).
297 * gnus-summary-save-in-vm (use VM's folder format).")
299 (defvar gnus-prompt-before-saving 'always
300 "*This variable says how much prompting is to be done when saving articles.
301 If it is nil, no prompting will be done, and the articles will be
302 saved to the default files. If this variable is `always', each and
303 every article that is saved will be preceded by a prompt, even when
304 saving large batches of articles. If this variable is neither nil not
305 `always', there the user will be prompted once for a file name for
306 each invocation of the saving commands.")
308 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
309 "*A function generating a file name to save articles in Rmail format.
310 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
312 (defvar gnus-mail-save-name (function gnus-plain-save-name)
313 "*A function generating a file name to save articles in Unix mail format.
314 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
316 (defvar gnus-folder-save-name (function gnus-folder-save-name)
317 "*A function generating a file name to save articles in MH folder.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
320 (defvar gnus-file-save-name (function gnus-numeric-save-name)
321 "*A function generating a file name to save articles in article format.
322 The function is called with NEWSGROUP, HEADERS, and optional
325 (defvar gnus-split-methods
326 '((gnus-article-archive-name))
327 "*Variable used to suggest where articles are to be saved.
328 For instance, if you would like to save articles related to Gnus in
329 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
330 you could set this variable to something like:
332 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
333 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
335 This variable is an alist where the where the key is the match and the
336 value is a list of possible files to save in if the match is non-nil.
338 If the match is a string, it is used as a regexp match on the
339 article. If the match is a symbol, that symbol will be funcalled
340 from the buffer of the article to be saved with the newsgroup as the
341 parameter. If it is a list, it will be evaled in the same buffer.
343 If this form or function returns a string, this string will be used as
344 a possible file name; and if it returns a non-nil list, that list will
345 be used as possible file names.")
347 (defvar gnus-move-split-methods nil
348 "*Variable used to suggest where articles are to be moved to.
349 It uses the same syntax as the `gnus-split-methods' variable.")
351 (defvar gnus-save-score nil
352 "*If non-nil, save group scoring info.")
354 (defvar gnus-use-adaptive-scoring nil
355 "*If non-nil, use some adaptive scoring scheme.")
357 (defvar gnus-use-cache nil
358 "*If nil, Gnus will ignore the article cache.
359 If `passive', it will allow entering (and reading) articles
360 explicitly entered into the cache. If anything else, use the
361 cache to the full extent of the law.")
363 (defvar gnus-use-trees nil
364 "*If non-nil, display a thread tree buffer.")
366 (defvar gnus-use-grouplens nil
367 "*If non-nil, use GroupLens ratings.")
369 (defvar gnus-keep-backlog nil
370 "*If non-nil, Gnus will keep read articles for later re-retrieval.
371 If it is a number N, then Gnus will only keep the last N articles
372 read. If it is neither nil nor a number, Gnus will keep all read
373 articles. This is not a good idea.")
375 (defvar gnus-use-nocem nil
376 "*If non-nil, Gnus will read NoCeM cancel messages.")
378 (defvar gnus-use-demon nil
379 "If non-nil, Gnus might use some demons.")
381 (defvar gnus-use-scoring t
382 "*If non-nil, enable scoring.")
384 (defvar gnus-use-picons nil
385 "*If non-nil, display picons.")
387 (defvar gnus-fetch-old-headers nil
388 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
389 If an unread article in the group refers to an older, already read (or
390 just marked as read) article, the old article will not normally be
391 displayed in the Summary buffer. If this variable is non-nil, Gnus
392 will attempt to grab the headers to the old articles, and thereby
393 build complete threads. If it has the value `some', only enough
394 headers to connect otherwise loose threads will be displayed.
395 This variable can also be a number. In that case, no more than that
396 number of old headers will be fetched.
398 The server has to support NOV for any of this to work.")
401 ;(defvar gnus-visual t
402 ; "*If non-nil, will do various highlighting.
403 ;If nil, no mouse highlights (or any other highlights) will be
404 ;performed. This might speed up Gnus some when generating large group
405 ;and summary buffers.")
407 (defvar gnus-novice-user t
408 "*Non-nil means that you are a usenet novice.
409 If non-nil, verbose messages may be displayed and confirmations may be
412 (defvar gnus-expert-user nil
413 "*Non-nil means that you will never be asked for confirmation about anything.
414 And that means *anything*.")
416 (defvar gnus-verbose 7
417 "*Integer that says how verbose Gnus should be.
418 The higher the number, the more messages Gnus will flash to say what
419 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
420 display most important messages; and at ten, Gnus will keep on
421 jabbering all the time.")
423 (defvar gnus-keep-same-level nil
424 "*Non-nil means that the next newsgroup after the current will be on the same level.
425 When you type, for instance, `n' after reading the last article in the
426 current newsgroup, you will go to the next newsgroup. If this variable
427 is nil, the next newsgroup will be the next from the group
429 If this variable is non-nil, Gnus will either put you in the
430 next newsgroup with the same level, or, if no such newsgroup is
431 available, the next newsgroup with the lowest possible level higher
432 than the current level.
433 If this variable is `best', Gnus will make the next newsgroup the one
434 with the best level.")
436 (defvar gnus-summary-make-false-root 'adopt
437 "*nil means that Gnus won't gather loose threads.
438 If the root of a thread has expired or been read in a previous
439 session, the information necessary to build a complete thread has been
440 lost. Instead of having many small sub-threads from this original thread
441 scattered all over the summary buffer, Gnus can gather them.
443 If non-nil, Gnus will try to gather all loose sub-threads from an
444 original thread into one large thread.
446 If this variable is non-nil, it should be one of `none', `adopt',
449 If this variable is `none', Gnus will not make a false root, but just
450 present the sub-threads after another.
451 If this variable is `dummy', Gnus will create a dummy root that will
452 have all the sub-threads as children.
453 If this variable is `adopt', Gnus will make one of the \"children\"
454 the parent and mark all the step-children as such.
455 If this variable is `empty', the \"children\" are printed with empty
456 subject fields. (Or rather, they will be printed with a string
457 given by the `gnus-summary-same-subject' variable.)")
459 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
460 "*A regexp to match subjects to be excluded from loose thread gathering.
461 As loose thread gathering is done on subjects only, that means that
462 there can be many false gatherings performed. By rooting out certain
463 common subjects, gathering might become saner.")
465 (defvar gnus-summary-gather-subject-limit nil
466 "*Maximum length of subject comparisons when gathering loose threads.
467 Use nil to compare full subjects. Setting this variable to a low
468 number will help gather threads that have been corrupted by
469 newsreaders chopping off subject lines, but it might also mean that
470 unrelated articles that have subject that happen to begin with the
471 same few characters will be incorrectly gathered.
473 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
474 comparing subjects.")
476 (defvar gnus-simplify-ignored-prefixes nil
477 "*Regexp, matches for which are removed from subject lines when simplifying.")
479 (defvar gnus-build-sparse-threads nil
480 "*If non-nil, fill in the gaps in threads.
481 If `some', only fill in the gaps that are needed to tie loose threads
482 together. If `more', fill in all leaf nodes that Gnus can find. If
483 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
485 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
486 "Function used for gathering loose threads.
487 There are two pre-defined functions: `gnus-gather-threads-by-subject',
488 which only takes Subjects into consideration; and
489 `gnus-gather-threads-by-references', which compared the References
490 headers of the articles to find matches.")
492 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
493 (defvar gnus-summary-same-subject ""
494 "*String indicating that the current article has the same subject as the previous.
495 This variable will only be used if the value of
496 `gnus-summary-make-false-root' is `empty'.")
498 (defvar gnus-summary-goto-unread t
499 "*If non-nil, marking commands will go to the next unread article.
500 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
501 whether it is read or not.")
503 (defvar gnus-group-goto-unread t
504 "*If non-nil, movement commands will go to the next unread and subscribed group.")
506 (defvar gnus-goto-next-group-when-activating t
507 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
509 (defvar gnus-check-new-newsgroups t
510 "*Non-nil means that Gnus will add new newsgroups at startup.
511 If this variable is `ask-server', Gnus will ask the server for new
512 groups since the last time it checked. This means that the killed list
513 is no longer necessary, so you could set `gnus-save-killed-list' to
516 A variant is to have this variable be a list of select methods. Gnus
517 will then use the `ask-server' method on all these select methods to
518 query for new groups from all those servers.
521 (setq gnus-check-new-newsgroups
522 '((nntp \"some.server\") (nntp \"other.server\")))
524 If this variable is nil, then you have to tell Gnus explicitly to
525 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
527 (defvar gnus-check-bogus-newsgroups nil
528 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
529 If this variable is nil, then you have to tell Gnus explicitly to
530 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
532 (defvar gnus-read-active-file t
533 "*Non-nil means that Gnus will read the entire active file at startup.
534 If this variable is nil, Gnus will only know about the groups in your
537 If this variable is `some', Gnus will try to only read the relevant
538 parts of the active file from the server. Not all servers support
539 this, and it might be quite slow with other servers, but this should
540 generally be faster than both the t and nil value.
542 If you set this variable to nil or `some', you probably still want to
543 be told about new newsgroups that arrive. To do that, set
544 `gnus-check-new-newsgroups' to `ask-server'. This may not work
545 properly with all servers.")
547 (defvar gnus-level-subscribed 5
548 "*Groups with levels less than or equal to this variable are subscribed.")
550 (defvar gnus-level-unsubscribed 7
551 "*Groups with levels less than or equal to this variable are unsubscribed.
552 Groups with levels less than `gnus-level-subscribed', which should be
553 less than this variable, are subscribed.")
555 (defvar gnus-level-zombie 8
556 "*Groups with this level are zombie groups.")
558 (defvar gnus-level-killed 9
559 "*Groups with this level are killed.")
561 (defvar gnus-level-default-subscribed 3
562 "*New subscribed groups will be subscribed at this level.")
564 (defvar gnus-level-default-unsubscribed 6
565 "*New unsubscribed groups will be unsubscribed at this level.")
567 (defvar gnus-activate-level (1+ gnus-level-subscribed)
568 "*Groups higher than this level won't be activated on startup.
569 Setting this variable to something log might save lots of time when
570 you have many groups that you aren't interested in.")
572 (defvar gnus-activate-foreign-newsgroups 4
573 "*If nil, Gnus will not check foreign newsgroups at startup.
574 If it is non-nil, it should be a number between one and nine. Foreign
575 newsgroups that have a level lower or equal to this number will be
576 activated on startup. For instance, if you want to active all
577 subscribed newsgroups, but not the rest, you'd set this variable to
578 `gnus-level-subscribed'.
580 If you subscribe to lots of newsgroups from different servers, startup
581 might take a while. By setting this variable to nil, you'll save time,
582 but you won't be told how many unread articles there are in the
585 (defvar gnus-save-newsrc-file t
586 "*Non-nil means that Gnus will save the `.newsrc' file.
587 Gnus always saves its own startup file, which is called
588 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
589 be readily understood by other newsreaders. If you don't plan on
590 using other newsreaders, set this variable to nil to save some time on
593 (defvar gnus-save-killed-list t
594 "*If non-nil, save the list of killed groups to the startup file.
595 If you set this variable to nil, you'll save both time (when starting
596 and quitting) and space (both memory and disk), but it will also mean
597 that Gnus has no record of which groups are new and which are old, so
598 the automatic new newsgroups subscription methods become meaningless.
600 You should always set `gnus-check-new-newsgroups' to `ask-server' or
601 nil if you set this variable to nil.")
603 (defvar gnus-interactive-catchup t
604 "*If non-nil, require your confirmation when catching up a group.")
606 (defvar gnus-interactive-exit t
607 "*If non-nil, require your confirmation when exiting Gnus.")
609 (defvar gnus-kill-killed t
610 "*If non-nil, Gnus will apply kill files to already killed articles.
611 If it is nil, Gnus will never apply kill files to articles that have
612 already been through the scoring process, which might very well save lots
615 (defvar gnus-extract-address-components 'gnus-extract-address-components
616 "*Function for extracting address components from a From header.
617 Two pre-defined function exist: `gnus-extract-address-components',
618 which is the default, quite fast, and too simplistic solution, and
619 `mail-extract-address-components', which works much better, but is
622 (defvar gnus-summary-default-score 0
623 "*Default article score level.
624 If this variable is nil, scoring will be disabled.")
626 (defvar gnus-summary-zcore-fuzz 0
627 "*Fuzziness factor for the zcore in the summary buffer.
628 Articles with scores closer than this to `gnus-summary-default-score'
629 will not be marked.")
631 (defvar gnus-simplify-subject-fuzzy-regexp nil
632 "*Strings to be removed when doing fuzzy matches.
633 This can either be a regular expression or list of regular expressions
634 that will be removed from subject strings if fuzzy subject
635 simplification is selected.")
637 (defvar gnus-permanently-visible-groups nil
638 "*Regexp to match groups that should always be listed in the group buffer.
639 This means that they will still be listed when there are no unread
640 articles in the groups.")
642 (defvar gnus-list-groups-with-ticked-articles t
643 "*If non-nil, list groups that have only ticked articles.
644 If nil, only list groups that have unread articles.")
646 (defvar gnus-group-default-list-level gnus-level-subscribed
647 "*Default listing level.
648 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
650 (defvar gnus-group-use-permanent-levels nil
651 "*If non-nil, once you set a level, Gnus will use this level.")
653 (defvar gnus-group-list-inactive-groups t
654 "*If non-nil, inactive groups will be listed.")
656 (defvar gnus-show-mime nil
657 "*If non-nil, do mime processing of articles.
658 The articles will simply be fed to the function given by
659 `gnus-show-mime-method'.")
661 (defvar gnus-strict-mime t
662 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
664 (defvar gnus-show-mime-method 'metamail-buffer
665 "*Function to process a MIME message.
666 The function is called from the article buffer.")
668 (defvar gnus-decode-encoded-word-method (lambda ())
669 "*Function to decode a MIME encoded-words.
670 The function is called from the article buffer.")
672 (defvar gnus-show-threads t
673 "*If non-nil, display threads in summary mode.")
675 (defvar gnus-thread-hide-subtree nil
676 "*If non-nil, hide all threads initially.
677 If threads are hidden, you have to run the command
678 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
679 to expose hidden threads.")
681 (defvar gnus-thread-hide-killed t
682 "*If non-nil, hide killed threads automatically.")
684 (defvar gnus-thread-ignore-subject nil
685 "*If non-nil, ignore subjects and do all threading based on the Reference header.
686 If nil, which is the default, articles that have different subjects
687 from their parents will start separate threads.")
689 (defvar gnus-thread-operation-ignore-subject t
690 "*If non-nil, subjects will be ignored when doing thread commands.
691 This affects commands like `gnus-summary-kill-thread' and
692 `gnus-summary-lower-thread'.
694 If this variable is nil, articles in the same thread with different
695 subjects will not be included in the operation in question. If this
696 variable is `fuzzy', only articles that have subjects that are fuzzily
697 equal will be included.")
699 (defvar gnus-thread-indent-level 4
700 "*Number that says how much each sub-thread should be indented.")
702 (defvar gnus-ignored-newsgroups
703 (purecopy (mapconcat 'identity
704 '("^to\\." ; not "real" groups
705 "^[0-9. \t]+ " ; all digits in name
706 "[][\"#'()]" ; bogus characters
709 "*A regexp to match uninteresting newsgroups in the active file.
710 Any lines in the active file matching this regular expression are
711 removed from the newsgroup list before anything else is done to it,
712 thus making them effectively non-existent.")
714 (defvar gnus-ignored-headers
715 "^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:"
716 "*All headers that match this regexp will be hidden.
717 This variable can also be a list of regexps of headers to be ignored.
718 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
720 (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-"
721 "*All headers that do not match this regexp will be hidden.
722 This variable can also be a list of regexp of headers to remain visible.
723 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
725 (defvar gnus-sorted-header-list
726 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
727 "^Cc:" "^Date:" "^Organization:")
728 "*This variable is a list of regular expressions.
729 If it is non-nil, headers that match the regular expressions will
730 be placed first in the article buffer in the sequence specified by
733 (defvar gnus-boring-article-headers
734 '(empty followup-to reply-to)
735 "*Headers that are only to be displayed if they have interesting data.
736 Possible values in this list are `empty', `newsgroups', `followup-to',
737 `reply-to', and `date'.")
739 (defvar gnus-show-all-headers nil
740 "*If non-nil, don't hide any headers.")
742 (defvar gnus-save-all-headers t
743 "*If non-nil, don't remove any headers before saving.")
745 (defvar gnus-saved-headers gnus-visible-headers
746 "*Headers to keep if `gnus-save-all-headers' is nil.
747 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
748 If that variable is nil, however, all headers that match this regexp
749 will be kept while the rest will be deleted before saving.")
751 (defvar gnus-inhibit-startup-message nil
752 "*If non-nil, the startup message will not be displayed.")
754 (defvar gnus-signature-separator "^-- *$"
755 "Regexp matching signature separator.")
757 (defvar gnus-signature-limit nil
758 "Provide a limit to what is considered a signature.
759 If it is a number, no signature may not be longer (in characters) than
760 that number. If it is a function, the function will be called without
761 any parameters, and if it returns nil, there is no signature in the
762 buffer. If it is a string, it will be used as a regexp. If it
763 matches, the text in question is not a signature.")
765 (defvar gnus-auto-extend-newsgroup t
766 "*If non-nil, extend newsgroup forward and backward when requested.")
768 (defvar gnus-auto-select-first t
769 "*If nil, don't select the first unread article when entering a group.
770 If this variable is `best', select the highest-scored unread article
771 in the group. If neither nil nor `best', select the first unread
774 If you want to prevent automatic selection of the first unread article
775 in some newsgroups, set the variable to nil in
776 `gnus-select-group-hook'.")
778 (defvar gnus-auto-select-next t
779 "*If non-nil, offer to go to the next group from the end of the previous.
780 If the value is t and the next newsgroup is empty, Gnus will exit
781 summary mode and go back to group mode. If the value is neither nil
782 nor t, Gnus will select the following unread newsgroup. In
783 particular, if the value is the symbol `quietly', the next unread
784 newsgroup will be selected without any confirmation, and if it is
785 `almost-quietly', the next group will be selected without any
786 confirmation if you are located on the last article in the group.
787 Finally, if this variable is `slightly-quietly', the `Z n' command
788 will go to the next group without confirmation.")
790 (defvar gnus-auto-select-same nil
791 "*If non-nil, select the next article with the same subject.")
793 (defvar gnus-summary-check-current nil
794 "*If non-nil, consider the current article when moving.
795 The \"unread\" movement commands will stay on the same line if the
796 current article is unread.")
798 (defvar gnus-auto-center-summary t
799 "*If non-nil, always center the current summary buffer.
800 In particular, if `vertical' do only vertical recentering. If non-nil
801 and non-`vertical', do both horizontal and vertical recentering.")
803 (defvar gnus-break-pages t
804 "*If non-nil, do page breaking on articles.
805 The page delimiter is specified by the `gnus-page-delimiter'
808 (defvar gnus-page-delimiter "^\^L"
809 "*Regexp describing what to use as article page delimiters.
810 The default value is \"^\^L\", which is a form linefeed at the
811 beginning of a line.")
813 (defvar gnus-use-full-window t
814 "*If non-nil, use the entire Emacs screen.")
816 (defvar gnus-window-configuration nil
817 "Obsolete variable. See `gnus-buffer-configuration'.")
819 (defvar gnus-window-min-width 2
820 "*Minimum width of Gnus buffers.")
822 (defvar gnus-window-min-height 1
823 "*Minimum height of Gnus buffers.")
825 (defvar gnus-buffer-configuration
829 (if gnus-carpal '(group-carpal 4))))
833 (if gnus-carpal '(summary-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))
842 (vertical ((height . 5) (width . 15)
844 (left . -1) (top . 1))
854 (if gnus-carpal '(summary-carpal 4))
855 (if gnus-use-trees '(tree 0.25))
860 (if gnus-carpal '(server-carpal 2))))
864 (if gnus-carpal '(browse-carpal 2))))
867 (message 1.0 point)))
870 (article 1.0 point)))
881 (edit-group 1.0 point)))
885 (edit-server 1.0 point)))
889 (edit-score 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
902 (message 1.0 point)))
906 (message 1.0 point)))
913 (if gnus-carpal '(summary-carpal 4))
914 ("*Shell Command Output*" 1.0)))
917 ("*Gnus Help Bug*" 0.5)
918 ("*Gnus Bug*" 1.0 point)))
922 (message 1.0 point))))
923 "Window configuration for all possible Gnus buffers.
924 This variable is a list of lists. Each of these lists has a NAME and
925 a RULE. The NAMEs are commonsense names like `group', which names a
926 rule used when displaying the group buffer; `summary', which names a
927 rule for what happens when you enter a group and do not display an
928 article buffer; and so on. See the value of this variable for a
929 complete list of NAMEs.
931 Each RULE is a list of vectors. The first element in this vector is
932 the name of the buffer to be displayed; the second element is the
933 percentage of the screen this buffer is to occupy (a number in the
934 0.0-0.99 range); the optional third element is `point', which should
935 be present to denote which buffer point is to go to after making this
936 buffer configuration.")
938 (defvar gnus-window-to-buffer
939 '((group . gnus-group-buffer)
940 (summary . gnus-summary-buffer)
941 (article . gnus-article-buffer)
942 (server . gnus-server-buffer)
943 (browse . "*Gnus Browse Server*")
944 (edit-group . gnus-group-edit-buffer)
945 (edit-server . gnus-server-edit-buffer)
946 (group-carpal . gnus-carpal-group-buffer)
947 (summary-carpal . gnus-carpal-summary-buffer)
948 (server-carpal . gnus-carpal-server-buffer)
949 (browse-carpal . gnus-carpal-browse-buffer)
950 (edit-score . gnus-score-edit-buffer)
951 (message . gnus-message-buffer)
952 (mail . gnus-message-buffer)
953 (post-news . gnus-message-buffer)
954 (faq . gnus-faq-buffer)
955 (picons . "*Picons*")
956 (tree . gnus-tree-buffer)
957 (info . gnus-info-buffer)
958 (article-copy . gnus-article-copy)
959 (draft . gnus-draft-buffer))
960 "Mapping from short symbols to buffer names or buffer variables.")
962 (defvar gnus-carpal nil
963 "*If non-nil, display clickable icons.")
965 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
966 "*Function called with a group name when new group is detected.
967 A few pre-made functions are supplied: `gnus-subscribe-randomly'
968 inserts new groups at the beginning of the list of groups;
969 `gnus-subscribe-alphabetically' inserts new groups in strict
970 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
971 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
972 for your decision; `gnus-subscribe-killed' kills all new groups;
973 `gnus-subscribe-zombies' will make all new groups into zombies.")
975 ;; Suggested by a bug report by Hallvard B Furuseth.
976 ;; <h.b.furuseth@usit.uio.no>.
977 (defvar gnus-subscribe-options-newsgroup-method
978 (function gnus-subscribe-alphabetically)
979 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
980 If, for instance, you want to subscribe to all newsgroups in the
981 \"no\" and \"alt\" hierarchies, you'd put the following in your
984 options -n no.all alt.all
986 Gnus will the subscribe all new newsgroups in these hierarchies with
987 the subscription method in this variable.")
989 (defvar gnus-subscribe-hierarchical-interactive nil
990 "*If non-nil, Gnus will offer to subscribe hierarchically.
991 When a new hierarchy appears, Gnus will ask the user:
993 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
995 If the user pressed `d', Gnus will descend the hierarchy, `y' will
996 subscribe to all newsgroups in the hierarchy and `s' will skip this
997 hierarchy in its entirety.")
999 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1000 "*Function used for sorting the group buffer.
1001 This function will be called with group info entries as the arguments
1002 for the groups to be sorted. Pre-made functions include
1003 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1004 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1005 `gnus-group-sort-by-rank'.
1007 This variable can also be a list of sorting functions. In that case,
1008 the most significant sort function should be the last function in the
1011 ;; Mark variables suggested by Thomas Michanek
1012 ;; <Thomas.Michanek@telelogic.se>.
1013 (defvar gnus-unread-mark ?
1014 "*Mark used for unread articles.")
1015 (defvar gnus-ticked-mark ?!
1016 "*Mark used for ticked articles.")
1017 (defvar gnus-dormant-mark ??
1018 "*Mark used for dormant articles.")
1019 (defvar gnus-del-mark ?r
1020 "*Mark used for del'd articles.")
1021 (defvar gnus-read-mark ?R
1022 "*Mark used for read articles.")
1023 (defvar gnus-expirable-mark ?E
1024 "*Mark used for expirable articles.")
1025 (defvar gnus-killed-mark ?K
1026 "*Mark used for killed articles.")
1027 (defvar gnus-souped-mark ?F
1028 "*Mark used for killed articles.")
1029 (defvar gnus-kill-file-mark ?X
1030 "*Mark used for articles killed by kill files.")
1031 (defvar gnus-low-score-mark ?Y
1032 "*Mark used for articles with a low score.")
1033 (defvar gnus-catchup-mark ?C
1034 "*Mark used for articles that are caught up.")
1035 (defvar gnus-replied-mark ?A
1036 "*Mark used for articles that have been replied to.")
1037 (defvar gnus-cached-mark ?*
1038 "*Mark used for articles that are in the cache.")
1039 (defvar gnus-saved-mark ?S
1040 "*Mark used for articles that have been saved to.")
1041 (defvar gnus-process-mark ?#
1043 (defvar gnus-ancient-mark ?O
1044 "*Mark used for ancient articles.")
1045 (defvar gnus-sparse-mark ?Q
1046 "*Mark used for sparsely reffed articles.")
1047 (defvar gnus-canceled-mark ?G
1048 "*Mark used for canceled articles.")
1049 (defvar gnus-score-over-mark ?+
1050 "*Score mark used for articles with high scores.")
1051 (defvar gnus-score-below-mark ?-
1052 "*Score mark used for articles with low scores.")
1053 (defvar gnus-empty-thread-mark ?
1054 "*There is no thread under the article.")
1055 (defvar gnus-not-empty-thread-mark ?=
1056 "*There is a thread under the article.")
1058 (defvar gnus-view-pseudo-asynchronously nil
1059 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1061 (defvar gnus-view-pseudos nil
1062 "*If `automatic', pseudo-articles will be viewed automatically.
1063 If `not-confirm', pseudos will be viewed automatically, and the user
1064 will not be asked to confirm the command.")
1066 (defvar gnus-view-pseudos-separately t
1067 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1068 If nil, all files that use the same viewing command will be given as a
1069 list of parameters to that command.")
1071 (defvar gnus-insert-pseudo-articles t
1072 "*If non-nil, insert pseudo-articles when decoding articles.")
1074 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1075 "*Format of group lines.
1076 It works along the same lines as a normal formatting string,
1077 with some simple extensions.
1079 %M Only marked articles (character, \"*\" or \" \")
1080 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1081 %L Level of subscribedness (integer)
1082 %N Number of unread articles (integer)
1083 %I Number of dormant articles (integer)
1084 %i Number of ticked and dormant (integer)
1085 %T Number of ticked articles (integer)
1086 %R Number of read articles (integer)
1087 %t Total number of articles (integer)
1088 %y Number of unread, unticked articles (integer)
1089 %G Group name (string)
1090 %g Qualified group name (string)
1091 %D Group description (string)
1092 %s Select method (string)
1093 %o Moderated group (char, \"m\")
1094 %p Process mark (char)
1095 %O Moderated group (string, \"(m)\" or \"\")
1096 %P Topic indentation (string)
1097 %l Whether there are GroupLens predictions for this group (string)
1098 %n Select from where (string)
1099 %z A string that look like `<%s:%n>' if a foreign select method is used
1100 %u User defined specifier. The next character in the format string should
1101 be a letter. Gnus will call the function gnus-user-format-function-X,
1102 where X is the letter following %u. The function will be passed the
1103 current header as argument. The function should return a string, which
1104 will be inserted into the buffer just like information from any other
1107 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1108 the mouse point move inside the area. There can only be one such area.
1110 Note that this format specification is not always respected. For
1111 reasons of efficiency, when listing killed groups, this specification
1112 is ignored altogether. If the spec is changed considerably, your
1113 output may end up looking strange when listing both alive and killed
1116 If you use %o or %O, reading the active file will be slower and quite
1117 a bit of extra memory will be used. %D will also worsen performance.
1118 Also note that if you change the format specification to include any
1119 of these specs, you must probably re-start Gnus to see them go into
1122 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1123 "*The format specification of the lines in the summary buffer.
1125 It works along the same lines as a normal formatting string,
1126 with some simple extensions.
1128 %N Article number, left padded with spaces (string)
1130 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1131 %n Name of the poster (string)
1132 %a Extracted name of the poster (string)
1133 %A Extracted address of the poster (string)
1134 %F Contents of the From: header (string)
1135 %x Contents of the Xref: header (string)
1136 %D Date of the article (string)
1137 %d Date of the article (string) in DD-MMM format
1138 %M Message-id of the article (string)
1139 %r References of the article (string)
1140 %c Number of characters in the article (integer)
1141 %L Number of lines in the article (integer)
1142 %I Indentation based on thread level (a string of spaces)
1143 %T A string with two possible values: 80 spaces if the article
1144 is on thread level two or larger and 0 spaces on level one
1145 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1146 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1147 %[ Opening bracket (character, \"[\" or \"<\")
1148 %] Closing bracket (character, \"]\" or \">\")
1149 %> Spaces of length thread-level (string)
1150 %< Spaces of length (- 20 thread-level) (string)
1151 %i Article score (number)
1152 %z Article zcore (character)
1153 %t Number of articles under the current thread (number).
1154 %e Whether the thread is empty or not (character).
1155 %l GroupLens score (string).
1156 %u User defined specifier. The next character in the format string should
1157 be a letter. Gnus will call the function gnus-user-format-function-X,
1158 where X is the letter following %u. The function will be passed the
1159 current header as argument. The function should return a string, which
1160 will be inserted into the summary just like information from any other
1163 Text between %( and %) will be highlighted with `gnus-mouse-face'
1164 when the mouse point is placed inside the area. There can only be one
1167 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1168 with care. For reasons of efficiency, Gnus will compute what column
1169 these characters will end up in, and \"hard-code\" that. This means that
1170 it is illegal to have these specs after a variable-length spec. Well,
1171 you might not be arrested, but your summary buffer will look strange,
1172 which is bad enough.
1174 The smart choice is to have these specs as for to the left as
1177 This restriction may disappear in later versions of Gnus.")
1179 (defvar gnus-summary-dummy-line-format
1181 "*The format specification for the dummy roots in the summary buffer.
1182 It works along the same lines as a normal formatting string,
1183 with some simple extensions.
1187 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1188 "*The format specification for the summary mode line.
1189 It works along the same lines as a normal formatting string,
1190 with some simple extensions:
1193 %p Unprefixed group name
1194 %A Current article number
1196 %U Number of unread articles in the group
1197 %e Number of unselected articles in the group
1198 %Z A string with unread/unselected article counts
1199 %g Shortish group name
1200 %S Subject of the current article
1201 %u User-defined spec
1202 %s Current score file name
1203 %d Number of dormant articles
1204 %r Number of articles that have been marked as read in this session
1205 %E Number of articles expunged by the score files")
1207 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1208 "*The format specification for the article mode line.
1209 See `gnus-summary-mode-line-format' for a closer description.")
1211 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1212 "*The format specification for the group mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1216 %S The native news server.
1217 %M The native select method.
1218 %: \":\" if %S isn't \"\".")
1220 (defvar gnus-valid-select-methods
1221 '(("nntp" post address prompt-address)
1222 ("nnspool" post address)
1223 ("nnvirtual" post-mail virtual prompt-address)
1224 ("nnmbox" mail respool address)
1225 ("nnml" mail respool address)
1226 ("nnmh" mail respool address)
1227 ("nndir" post-mail prompt-address address)
1228 ("nneething" none address prompt-address)
1229 ("nndoc" none address prompt-address)
1230 ("nnbabyl" mail address respool)
1231 ("nnkiboze" post address virtual)
1232 ("nnsoup" post-mail address)
1233 ("nndraft" post-mail)
1234 ("nnfolder" mail respool address))
1235 "An alist of valid select methods.
1236 The first element of each list lists should be a string with the name
1237 of the select method. The other elements may be be the category of
1238 this method (ie. `post', `mail', `none' or whatever) or other
1239 properties that this method has (like being respoolable).
1240 If you implement a new select method, all you should have to change is
1241 this variable. I think.")
1243 (defvar gnus-updated-mode-lines '(group article summary tree)
1244 "*List of buffers that should update their mode lines.
1245 The list may contain the symbols `group', `article' and `summary'. If
1246 the corresponding symbol is present, Gnus will keep that mode line
1247 updated with information that may be pertinent.
1248 If this variable is nil, screen refresh may be quicker.")
1250 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1251 (defvar gnus-mode-non-string-length nil
1252 "*Max length of mode-line non-string contents.
1253 If this is nil, Gnus will take space as is needed, leaving the rest
1254 of the modeline intact.")
1257 ;(defvar gnus-mouse-face 'highlight
1258 ; "*Face used for mouse highlighting in Gnus.
1259 ;No mouse highlights will be done if `gnus-visual' is nil.")
1261 (defvar gnus-summary-mark-below nil
1262 "*Mark all articles with a score below this variable as read.
1263 This variable is local to each summary buffer and usually set by the
1266 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1267 "*List of functions used for sorting articles in the summary buffer.
1268 This variable is only used when not using a threaded display.")
1270 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1271 "*List of functions used for sorting threads in the summary buffer.
1272 By default, threads are sorted by article number.
1274 Each function takes two threads and return non-nil if the first thread
1275 should be sorted before the other. If you use more than one function,
1276 the primary sort function should be the last. You should probably
1277 always include `gnus-thread-sort-by-number' in the list of sorting
1278 functions -- preferably first.
1280 Ready-mady functions include `gnus-thread-sort-by-number',
1281 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1282 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1283 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1285 (defvar gnus-thread-score-function '+
1286 "*Function used for calculating the total score of a thread.
1288 The function is called with the scores of the article and each
1289 subthread and should then return the score of the thread.
1291 Some functions you can use are `+', `max', or `min'.")
1293 (defvar gnus-summary-expunge-below nil
1294 "All articles that have a score less than this variable will be expunged.")
1296 (defvar gnus-thread-expunge-below nil
1297 "All threads that have a total score less than this variable will be expunged.
1298 See `gnus-thread-score-function' for en explanation of what a
1299 \"thread score\" is.")
1301 (defvar gnus-auto-subscribed-groups
1302 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1303 "*All new groups that match this regexp will be subscribed automatically.
1304 Note that this variable only deals with new groups. It has no effect
1305 whatsoever on old groups.")
1307 (defvar gnus-options-subscribe nil
1308 "*All new groups matching this regexp will be subscribed unconditionally.
1309 Note that this variable deals only with new newsgroups. This variable
1310 does not affect old newsgroups.")
1312 (defvar gnus-options-not-subscribe nil
1313 "*All new groups matching this regexp will be ignored.
1314 Note that this variable deals only with new newsgroups. This variable
1315 does not affect old (already subscribed) newsgroups.")
1317 (defvar gnus-auto-expirable-newsgroups nil
1318 "*Groups in which to automatically mark read articles as expirable.
1319 If non-nil, this should be a regexp that should match all groups in
1320 which to perform auto-expiry. This only makes sense for mail groups.")
1322 (defvar gnus-total-expirable-newsgroups nil
1323 "*Groups in which to perform expiry of all read articles.
1324 Use with extreme caution. All groups that match this regexp will be
1325 expiring - which means that all read articles will be deleted after
1326 (say) one week. (This only goes for mail groups and the like, of
1329 (defvar gnus-group-uncollapsed-levels 1
1330 "Number of group name elements to leave alone when making a short group name.")
1332 (defvar gnus-hidden-properties '(invisible t intangible t)
1333 "Property list to use for hiding text.")
1335 (defvar gnus-modtime-botch nil
1336 "*Non-nil means .newsrc should be deleted prior to save.
1337 Its use is due to the bogus appearance that .newsrc was modified on
1342 (defvar gnus-group-mode-hook nil
1343 "*A hook for Gnus group mode.")
1345 (defvar gnus-summary-mode-hook nil
1346 "*A hook for Gnus summary mode.
1347 This hook is run before any variables are set in the summary buffer.")
1349 (defvar gnus-article-mode-hook nil
1350 "*A hook for Gnus article mode.")
1352 (defvar gnus-summary-prepare-exit-hook nil
1353 "*A hook called when preparing to exit from the summary buffer.
1354 It calls `gnus-summary-expire-articles' by default.")
1355 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1357 (defvar gnus-summary-exit-hook nil
1358 "*A hook called on exit from the summary buffer.")
1360 (defvar gnus-group-catchup-group-hook nil
1361 "*A hook run when catching up a group from the group buffer.")
1363 (defvar gnus-open-server-hook nil
1364 "*A hook called just before opening connection to the news server.")
1366 (defvar gnus-load-hook nil
1367 "*A hook run while Gnus is loaded.")
1369 (defvar gnus-startup-hook nil
1370 "*A hook called at startup.
1371 This hook is called after Gnus is connected to the NNTP server.")
1373 (defvar gnus-get-new-news-hook nil
1374 "*A hook run just before Gnus checks for new news.")
1376 (defvar gnus-after-getting-new-news-hook nil
1377 "*A hook run after Gnus checks for new news.")
1379 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1380 "*A function that is called to generate the group buffer.
1381 The function is called with three arguments: The first is a number;
1382 all group with a level less or equal to that number should be listed,
1383 if the second is non-nil, empty groups should also be displayed. If
1384 the third is non-nil, it is a number. No groups with a level lower
1385 than this number should be displayed.
1387 The only current function implemented is `gnus-group-prepare-flat'.")
1389 (defvar gnus-group-prepare-hook nil
1390 "*A hook called after the group buffer has been generated.
1391 If you want to modify the group buffer, you can use this hook.")
1393 (defvar gnus-summary-prepare-hook nil
1394 "*A hook called after the summary buffer has been generated.
1395 If you want to modify the summary buffer, you can use this hook.")
1397 (defvar gnus-summary-generate-hook nil
1398 "*A hook run just before generating the summary buffer.
1399 This hook is commonly used to customize threading variables and the
1402 (defvar gnus-article-prepare-hook nil
1403 "*A hook called after an article has been prepared in the article buffer.
1404 If you want to run a special decoding program like nkf, use this hook.")
1406 ;(defvar gnus-article-display-hook nil
1407 ; "*A hook called after the article is displayed in the article buffer.
1408 ;The hook is designed to change the contents of the article
1409 ;buffer. Typical functions that this hook may contain are
1410 ;`gnus-article-hide-headers' (hide selected headers),
1411 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1412 ;`gnus-article-hide-signature' (hide signature) and
1413 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1414 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1415 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1416 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1418 (defvar gnus-article-x-face-command
1419 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1420 "String or function to be executed to display an X-Face header.
1421 If it is a string, the command will be executed in a sub-shell
1422 asynchronously. The compressed face will be piped to this command.")
1424 (defvar gnus-article-x-face-too-ugly nil
1425 "Regexp matching posters whose face shouldn't be shown automatically.")
1427 (defvar gnus-select-group-hook nil
1428 "*A hook called when a newsgroup is selected.
1430 If you'd like to simplify subjects like the
1431 `gnus-summary-next-same-subject' command does, you can use the
1434 (setq gnus-select-group-hook
1437 (mapcar (lambda (header)
1438 (mail-header-set-subject
1440 (gnus-simplify-subject
1441 (mail-header-subject header) 're-only)))
1442 gnus-newsgroup-headers))))")
1444 (defvar gnus-select-article-hook nil
1445 "*A hook called when an article is selected.")
1447 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1448 "*A hook called to apply kill files to a group.
1449 This hook is intended to apply a kill file to the selected newsgroup.
1450 The function `gnus-apply-kill-file' is called by default.
1452 Since a general kill file is too heavy to use only for a few
1453 newsgroups, I recommend you to use a lighter hook function. For
1454 example, if you'd like to apply a kill file to articles which contains
1455 a string `rmgroup' in subject in newsgroup `control', you can use the
1458 (setq gnus-apply-kill-hook
1461 (cond ((string-match \"control\" gnus-newsgroup-name)
1462 (gnus-kill \"Subject\" \"rmgroup\")
1463 (gnus-expunge \"X\"))))))")
1465 (defvar gnus-visual-mark-article-hook
1466 (list 'gnus-highlight-selected-summary)
1467 "*Hook run after selecting an article in the summary buffer.
1468 It is meant to be used for highlighting the article in some way. It
1469 is not run if `gnus-visual' is nil.")
1471 (defvar gnus-parse-headers-hook nil
1472 "*A hook called before parsing the headers.")
1473 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1475 (defvar gnus-exit-group-hook nil
1476 "*A hook called when exiting (not quitting) summary mode.")
1478 (defvar gnus-suspend-gnus-hook nil
1479 "*A hook called when suspending (not exiting) Gnus.")
1481 (defvar gnus-exit-gnus-hook nil
1482 "*A hook called when exiting Gnus.")
1484 (defvar gnus-after-exiting-gnus-hook nil
1485 "*A hook called after exiting Gnus.")
1487 (defvar gnus-save-newsrc-hook nil
1488 "*A hook called before saving any of the newsrc files.")
1490 (defvar gnus-save-quick-newsrc-hook nil
1491 "*A hook called just before saving the quick newsrc file.
1492 Can be used to turn version control on or off.")
1494 (defvar gnus-save-standard-newsrc-hook nil
1495 "*A hook called just before saving the standard newsrc file.
1496 Can be used to turn version control on or off.")
1498 (defvar gnus-summary-update-hook
1499 (list 'gnus-summary-highlight-line)
1500 "*A hook called when a summary line is changed.
1501 The hook will not be called if `gnus-visual' is nil.
1503 The default function `gnus-summary-highlight-line' will
1504 highlight the line according to the `gnus-summary-highlight'
1507 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1508 "*A hook called when a group line is changed.
1509 The hook will not be called if `gnus-visual' is nil.
1511 The default function `gnus-group-highlight-line' will
1512 highlight the line according to the `gnus-group-highlight'
1515 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1516 "*A hook called when an article is selected for the first time.
1517 The hook is intended to mark an article as read (or unread)
1518 automatically when it is selected.")
1520 (defvar gnus-group-change-level-function nil
1521 "Function run when a group level is changed.
1522 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1524 ;; Remove any hilit infestation.
1525 (add-hook 'gnus-startup-hook
1527 (remove-hook 'gnus-summary-prepare-hook
1528 'hilit-rehighlight-buffer-quietly)
1529 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1530 (setq gnus-mark-article-hook
1531 '(gnus-summary-mark-read-and-unread-as-read))
1532 (remove-hook 'gnus-article-prepare-hook
1533 'hilit-rehighlight-buffer-quietly)))
1536 ;; Internal variables
1538 (defvar gnus-tree-buffer "*Tree*"
1539 "Buffer where Gnus thread trees are displayed.")
1542 (defvar gnus-use-generic-from nil)
1544 (defvar gnus-thread-indent-array nil)
1545 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1547 (defvar gnus-newsrc-file-version nil)
1549 (defvar gnus-method-history nil)
1550 ;; Variable holding the user answers to all method prompts.
1552 (defvar gnus-group-history nil)
1553 ;; Variable holding the user answers to all group prompts.
1555 (defvar gnus-server-alist nil
1556 "List of available servers.")
1558 (defvar gnus-group-indentation-function nil)
1560 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1562 (defvar gnus-goto-missing-group-function nil)
1564 (defvar gnus-override-subscribe-method nil)
1566 (defvar gnus-group-goto-next-group-function nil
1567 "Function to override finding the next group after listing groups.")
1569 (defconst gnus-article-mark-lists
1570 '((marked . tick) (replied . reply)
1571 (expirable . expire) (killed . killed)
1572 (bookmarks . bookmark) (dormant . dormant)
1573 (scored . score) (saved . save)
1577 ;; Avoid highlighting in kill files.
1578 (defvar gnus-summary-inhibit-highlight nil)
1579 (defvar gnus-newsgroup-selected-overlay nil)
1581 (defvar gnus-inhibit-hiding nil)
1582 (defvar gnus-group-indentation "")
1583 (defvar gnus-inhibit-limiting nil)
1584 (defvar gnus-created-frames nil)
1586 (defvar gnus-article-mode-map nil)
1587 (defvar gnus-dribble-buffer nil)
1588 (defvar gnus-headers-retrieved-by nil)
1589 (defvar gnus-article-reply nil)
1590 (defvar gnus-override-method nil)
1591 (defvar gnus-article-check-size nil)
1593 (defvar gnus-current-score-file nil)
1594 (defvar gnus-newsgroup-adaptive-score-file nil)
1595 (defvar gnus-scores-exclude-files nil)
1597 (defvar gnus-opened-servers nil)
1599 (defvar gnus-current-move-group nil)
1600 (defvar gnus-current-copy-group nil)
1601 (defvar gnus-current-crosspost-group nil)
1603 (defvar gnus-newsgroup-dependencies nil)
1604 (defvar gnus-newsgroup-async nil)
1605 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1607 (defvar gnus-newsgroup-adaptive nil)
1609 (defvar gnus-summary-display-table nil)
1610 (defvar gnus-summary-display-article-function nil)
1612 (defvar gnus-summary-highlight-line-function nil
1613 "Function called after highlighting a summary line.")
1615 (defvar gnus-group-line-format-alist
1616 `((?M gnus-tmp-marked-mark ?c)
1617 (?S gnus-tmp-subscribed ?c)
1618 (?L gnus-tmp-level ?d)
1619 (?N (cond ((eq number t) "*" )
1623 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1624 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1626 (?R gnus-tmp-number-of-read ?s)
1627 (?t gnus-tmp-number-total ?d)
1628 (?y gnus-tmp-number-of-unread ?s)
1629 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1630 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1631 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1632 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1633 (?g gnus-tmp-group ?s)
1634 (?G gnus-tmp-qualified-group ?s)
1635 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1636 (?D gnus-tmp-newsgroup-description ?s)
1637 (?o gnus-tmp-moderated ?c)
1638 (?O gnus-tmp-moderated-string ?s)
1639 (?p gnus-tmp-process-marked ?c)
1640 (?s gnus-tmp-news-server ?s)
1641 (?n gnus-tmp-news-method ?s)
1642 (?P gnus-group-indentation ?s)
1643 (?l gnus-tmp-grouplens ?s)
1644 (?z gnus-tmp-news-method-string ?s)
1645 (?u gnus-tmp-user-defined ?s)))
1647 (defvar gnus-summary-line-format-alist
1648 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1649 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1650 (?s gnus-tmp-subject-or-nil ?s)
1651 (?n gnus-tmp-name ?s)
1652 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1654 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1656 (?F gnus-tmp-from ?s)
1657 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1658 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1659 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1660 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1661 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1662 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1663 (?L gnus-tmp-lines ?d)
1664 (?I gnus-tmp-indentation ?s)
1665 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1666 (?R gnus-tmp-replied ?c)
1667 (?\[ gnus-tmp-opening-bracket ?c)
1668 (?\] gnus-tmp-closing-bracket ?c)
1669 (?\> (make-string gnus-tmp-level ? ) ?s)
1670 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1671 (?i gnus-tmp-score ?d)
1672 (?z gnus-tmp-score-char ?c)
1673 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1674 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1675 (?U gnus-tmp-unread ?c)
1676 (?t (gnus-summary-number-of-articles-in-thread
1677 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1679 (?e (gnus-summary-number-of-articles-in-thread
1680 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1682 (?u gnus-tmp-user-defined ?s))
1683 "An alist of format specifications that can appear in summary lines,
1684 and what variables they correspond with, along with the type of the
1685 variable (string, integer, character, etc).")
1687 (defvar gnus-summary-dummy-line-format-alist
1688 `((?S gnus-tmp-subject ?s)
1689 (?N gnus-tmp-number ?d)
1690 (?u gnus-tmp-user-defined ?s)))
1692 (defvar gnus-summary-mode-line-format-alist
1693 `((?G gnus-tmp-group-name ?s)
1694 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1695 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1696 (?A gnus-tmp-article-number ?d)
1697 (?Z gnus-tmp-unread-and-unselected ?s)
1698 (?V gnus-version ?s)
1699 (?U gnus-tmp-unread ?d)
1700 (?S gnus-tmp-subject ?s)
1701 (?e gnus-tmp-unselected ?d)
1702 (?u gnus-tmp-user-defined ?s)
1703 (?d (length gnus-newsgroup-dormant) ?d)
1704 (?t (length gnus-newsgroup-marked) ?d)
1705 (?r (length gnus-newsgroup-reads) ?d)
1706 (?E gnus-newsgroup-expunged-tally ?d)
1707 (?s (gnus-current-score-file-nondirectory) ?s)))
1709 (defvar gnus-article-mode-line-format-alist
1710 gnus-summary-mode-line-format-alist)
1712 (defvar gnus-group-mode-line-format-alist
1713 `((?S gnus-tmp-news-server ?s)
1714 (?M gnus-tmp-news-method ?s)
1715 (?u gnus-tmp-user-defined ?s)
1716 (?: gnus-tmp-colon ?s)))
1718 (defvar gnus-have-read-active-file nil)
1720 (defconst gnus-maintainer
1721 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1722 "The mail address of the Gnus maintainers.")
1724 (defconst gnus-version "September Gnus v0.90"
1725 "Version number for this version of Gnus.")
1727 (defvar gnus-info-nodes
1728 '((gnus-group-mode "(gnus)The Group Buffer")
1729 (gnus-summary-mode "(gnus)The Summary Buffer")
1730 (gnus-article-mode "(gnus)The Article Buffer"))
1731 "Assoc list of major modes and related Info nodes.")
1733 (defvar gnus-group-buffer "*Group*")
1734 (defvar gnus-summary-buffer "*Summary*")
1735 (defvar gnus-article-buffer "*Article*")
1736 (defvar gnus-server-buffer "*Server*")
1738 (defvar gnus-work-buffer " *gnus work*")
1740 (defvar gnus-original-article-buffer " *Original Article*")
1741 (defvar gnus-original-article nil)
1743 (defvar gnus-buffer-list nil
1744 "Gnus buffers that should be killed on exit.")
1746 (defvar gnus-slave nil
1747 "Whether this Gnus is a slave or not.")
1749 (defvar gnus-variable-list
1750 '(gnus-newsrc-options gnus-newsrc-options-n
1751 gnus-newsrc-last-checked-date
1752 gnus-newsrc-alist gnus-server-alist
1753 gnus-killed-list gnus-zombie-list
1754 gnus-topic-topology gnus-topic-alist
1756 "Gnus variables saved in the quick startup file.")
1758 (defvar gnus-newsrc-options nil
1759 "Options line in the .newsrc file.")
1761 (defvar gnus-newsrc-options-n nil
1762 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1764 (defvar gnus-newsrc-last-checked-date nil
1765 "Date Gnus last asked server for new newsgroups.")
1767 (defvar gnus-topic-topology nil
1768 "The complete topic hierarchy.")
1770 (defvar gnus-topic-alist nil
1771 "The complete topic-group alist.")
1773 (defvar gnus-newsrc-alist nil
1774 "Assoc list of read articles.
1775 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1777 (defvar gnus-newsrc-hashtb nil
1778 "Hashtable of gnus-newsrc-alist.")
1780 (defvar gnus-killed-list nil
1781 "List of killed newsgroups.")
1783 (defvar gnus-killed-hashtb nil
1784 "Hash table equivalent of gnus-killed-list.")
1786 (defvar gnus-zombie-list nil
1787 "List of almost dead newsgroups.")
1789 (defvar gnus-description-hashtb nil
1790 "Descriptions of newsgroups.")
1792 (defvar gnus-list-of-killed-groups nil
1793 "List of newsgroups that have recently been killed by the user.")
1795 (defvar gnus-active-hashtb nil
1796 "Hashtable of active articles.")
1798 (defvar gnus-moderated-list nil
1799 "List of moderated newsgroups.")
1801 (defvar gnus-group-marked nil)
1803 (defvar gnus-current-startup-file nil
1804 "Startup file for the current host.")
1806 (defvar gnus-last-search-regexp nil
1807 "Default regexp for article search command.")
1809 (defvar gnus-last-shell-command nil
1810 "Default shell command on article.")
1812 (defvar gnus-current-select-method nil
1813 "The current method for selecting a newsgroup.")
1815 (defvar gnus-group-list-mode nil)
1817 (defvar gnus-article-internal-prepare-hook nil)
1819 (defvar gnus-newsgroup-name nil)
1820 (defvar gnus-newsgroup-begin nil)
1821 (defvar gnus-newsgroup-end nil)
1822 (defvar gnus-newsgroup-last-rmail nil)
1823 (defvar gnus-newsgroup-last-mail nil)
1824 (defvar gnus-newsgroup-last-folder nil)
1825 (defvar gnus-newsgroup-last-file nil)
1826 (defvar gnus-newsgroup-auto-expire nil)
1827 (defvar gnus-newsgroup-active nil)
1829 (defvar gnus-newsgroup-data nil)
1830 (defvar gnus-newsgroup-data-reverse nil)
1831 (defvar gnus-newsgroup-limit nil)
1832 (defvar gnus-newsgroup-limits nil)
1834 (defvar gnus-newsgroup-unreads nil
1835 "List of unread articles in the current newsgroup.")
1837 (defvar gnus-newsgroup-unselected nil
1838 "List of unselected unread articles in the current newsgroup.")
1840 (defvar gnus-newsgroup-reads nil
1841 "Alist of read articles and article marks in the current newsgroup.")
1843 (defvar gnus-newsgroup-expunged-tally nil)
1845 (defvar gnus-newsgroup-marked nil
1846 "List of ticked articles in the current newsgroup (a subset of unread art).")
1848 (defvar gnus-newsgroup-killed nil
1849 "List of ranges of articles that have been through the scoring process.")
1851 (defvar gnus-newsgroup-cached nil
1852 "List of articles that come from the article cache.")
1854 (defvar gnus-newsgroup-saved nil
1855 "List of articles that have been saved.")
1857 (defvar gnus-newsgroup-kill-headers nil)
1859 (defvar gnus-newsgroup-replied nil
1860 "List of articles that have been replied to in the current newsgroup.")
1862 (defvar gnus-newsgroup-expirable nil
1863 "List of articles in the current newsgroup that can be expired.")
1865 (defvar gnus-newsgroup-processable nil
1866 "List of articles in the current newsgroup that can be processed.")
1868 (defvar gnus-newsgroup-bookmarks nil
1869 "List of articles in the current newsgroup that have bookmarks.")
1871 (defvar gnus-newsgroup-dormant nil
1872 "List of dormant articles in the current newsgroup.")
1874 (defvar gnus-newsgroup-scored nil
1875 "List of scored articles in the current newsgroup.")
1877 (defvar gnus-newsgroup-headers nil
1878 "List of article headers in the current newsgroup.")
1880 (defvar gnus-newsgroup-threads nil)
1882 (defvar gnus-newsgroup-prepared nil
1883 "Whether the current group has been prepared properly.")
1885 (defvar gnus-newsgroup-ancient nil
1886 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1888 (defvar gnus-newsgroup-sparse nil)
1890 (defvar gnus-current-article nil)
1891 (defvar gnus-article-current nil)
1892 (defvar gnus-current-headers nil)
1893 (defvar gnus-have-all-headers nil)
1894 (defvar gnus-last-article nil)
1895 (defvar gnus-newsgroup-history nil)
1896 (defvar gnus-current-kill-article nil)
1898 ;; Save window configuration.
1899 (defvar gnus-prev-winconf nil)
1901 (defvar gnus-summary-mark-positions nil)
1902 (defvar gnus-group-mark-positions nil)
1904 (defvar gnus-reffed-article-number nil)
1906 ;;; Let the byte-compiler know that we know about this variable.
1907 (defvar rmail-default-rmail-file)
1909 (defvar gnus-cache-removable-articles nil)
1911 (defvar gnus-dead-summary nil)
1913 (defconst gnus-summary-local-variables
1914 '(gnus-newsgroup-name
1915 gnus-newsgroup-begin gnus-newsgroup-end
1916 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1917 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1918 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1919 gnus-newsgroup-unselected gnus-newsgroup-marked
1920 gnus-newsgroup-reads gnus-newsgroup-saved
1921 gnus-newsgroup-replied gnus-newsgroup-expirable
1922 gnus-newsgroup-processable gnus-newsgroup-killed
1923 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1924 gnus-newsgroup-headers gnus-newsgroup-threads
1925 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1926 gnus-current-article gnus-current-headers gnus-have-all-headers
1927 gnus-last-article gnus-article-internal-prepare-hook
1928 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1929 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1930 gnus-newsgroup-async gnus-thread-expunge-below
1931 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1932 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1933 gnus-newsgroup-history gnus-newsgroup-ancient
1934 gnus-newsgroup-sparse
1935 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1936 gnus-newsgroup-adaptive-score-file
1937 (gnus-newsgroup-expunged-tally . 0)
1938 gnus-cache-removable-articles gnus-newsgroup-cached
1939 gnus-newsgroup-data gnus-newsgroup-data-reverse
1940 gnus-newsgroup-limit gnus-newsgroup-limits)
1941 "Variables that are buffer-local to the summary buffers.")
1943 (defconst gnus-bug-message
1944 "Sending a bug report to the Gnus Towers.
1945 ========================================
1947 The buffer below is a mail buffer. When you press `C-c C-c', it will
1948 be sent to the Gnus Bug Exterminators.
1950 At the bottom of the buffer you'll see lots of variable settings.
1951 Please do not delete those. They will tell the Bug People what your
1952 environment is, so that it will be easier to locate the bugs.
1954 If you have found a bug that makes Emacs go \"beep\", set
1955 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1956 and include the backtrace in your bug report.
1958 Please describe the bug in annoying, painstaking detail.
1960 Thank you for your help in stamping out bugs.
1963 ;;; End of variables.
1965 ;; Define some autoload functions Gnus might use.
1968 ;; This little mapcar goes through the list below and marks the
1969 ;; symbols in question as autoloaded functions.
1972 (let ((interactive (nth 1 (memq ':interactive package))))
1976 (when (consp function)
1977 (setq keymap (car (memq 'keymap function)))
1978 (setq function (car function)))
1979 (autoload function (car package) nil interactive keymap)))
1980 (if (eq (nth 1 package) ':interactive)
1983 '(("metamail" metamail-buffer)
1984 ("info" Info-goto-node)
1985 ("hexl" hexl-hex-string-to-integer)
1986 ("pp" pp pp-to-string pp-eval-expression)
1987 ("mail-extr" mail-extract-address-components)
1988 ("nnmail" nnmail-split-fancy nnmail-article-group)
1989 ("nnvirtual" nnvirtual-catchup-group)
1990 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1991 timezone-make-sortable-date timezone-make-time-string)
1992 ("sendmail" mail-position-on-field mail-setup)
1993 ("rmailout" rmail-output)
1994 ("rnewspost" news-mail-other-window news-reply-yank-original
1995 news-caesar-buffer-body)
1996 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1998 ("gnus-soup" :interactive t
1999 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2000 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2001 ("nnsoup" nnsoup-pack-replies)
2002 ("gnus-scomo" :interactive t gnus-score-mode)
2003 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2004 gnus-Folder-save-name gnus-folder-save-name)
2005 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2006 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2007 gnus-server-make-menu-bar gnus-article-make-menu-bar
2008 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2009 gnus-summary-highlight-line gnus-carpal-setup-buffer
2010 gnus-group-highlight-line
2011 gnus-article-add-button gnus-insert-next-page-button
2012 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2013 ("gnus-vis" :interactive t
2014 gnus-article-push-button gnus-article-press-button
2015 gnus-article-highlight gnus-article-highlight-some
2016 gnus-article-highlight-headers gnus-article-highlight-signature
2017 gnus-article-add-buttons gnus-article-add-buttons-to-head
2018 gnus-article-next-button gnus-article-prev-button)
2019 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2020 gnus-demon-add-disconnection gnus-demon-add-handler
2021 gnus-demon-remove-handler)
2022 ("gnus-demon" :interactive t
2023 gnus-demon-init gnus-demon-cancel)
2024 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2025 gnus-tree-open gnus-tree-close)
2026 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2027 gnus-nocem-unwanted-article-p)
2028 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2029 ("gnus-srvr" gnus-browse-foreign-server)
2030 ("gnus-cite" :interactive t
2031 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2032 gnus-article-hide-citation gnus-article-fill-cited-article
2033 gnus-article-hide-citation-in-followups)
2034 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2035 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2036 gnus-execute gnus-expunge)
2037 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2038 gnus-cache-possibly-remove-articles gnus-cache-request-article
2039 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2040 gnus-cache-enter-remove-article gnus-cached-article-p
2041 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2042 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2043 gnus-cache-remove-article)
2044 ("gnus-score" :interactive t
2045 gnus-summary-increase-score gnus-summary-lower-score
2046 gnus-score-flush-cache gnus-score-close
2047 gnus-score-raise-same-subject-and-select
2048 gnus-score-raise-same-subject gnus-score-default
2049 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2050 gnus-score-lower-same-subject gnus-score-lower-thread
2051 gnus-possibly-score-headers)
2053 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2054 gnus-current-score-file-nondirectory gnus-score-adaptive
2055 gnus-score-find-trace gnus-score-file-name)
2056 ("gnus-edit" :interactive t gnus-score-customize)
2057 ("gnus-topic" :interactive t gnus-topic-mode)
2058 ("gnus-topic" gnus-topic-remove-group)
2059 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2060 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2061 ("gnus-uu" :interactive t
2062 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2063 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2064 gnus-uu-mark-by-regexp gnus-uu-mark-all
2065 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2066 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2067 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2068 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2069 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2070 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2071 gnus-uu-decode-binhex-view)
2072 ("gnus-msg" (gnus-summary-send-map keymap)
2073 gnus-mail-yank-original gnus-mail-send-and-exit
2074 gnus-sendmail-setup-mail gnus-article-mail
2075 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2076 ("gnus-msg" :interactive t
2077 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2078 gnus-summary-followup gnus-summary-followup-with-original
2079 gnus-summary-followup-and-reply
2080 gnus-summary-followup-and-reply-with-original
2081 gnus-summary-cancel-article gnus-summary-supersede-article
2082 gnus-post-news gnus-inews-news gnus-cancel-news
2083 gnus-summary-reply gnus-summary-reply-with-original
2084 gnus-summary-mail-forward gnus-summary-mail-other-window
2086 ("gnus-picon" :interactive t gnus-article-display-picons
2087 gnus-group-display-picons gnus-picons-article-display-x-face)
2088 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2089 gnus-grouplens-mode)
2090 ("gnus-vm" gnus-vm-mail-setup)
2091 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2092 gnus-summary-save-article-vm gnus-yank-article))))
2096 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2097 ;; If you want the cursor to go somewhere else, set these two
2098 ;; functions in some startup hook to whatever you want.
2099 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2100 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2102 ;;; Various macros and substs.
2104 (defun gnus-header-from (header)
2105 (mail-header-from header))
2107 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2108 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2109 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2110 (w (make-symbol "w"))
2111 (buf (make-symbol "buf")))
2112 `(let* ((,tempvar (selected-window))
2114 (,w (get-buffer-window ,buf 'visible)))
2119 (pop-to-buffer ,buf))
2121 (select-window ,tempvar)))))
2123 (defmacro gnus-gethash (string hashtable)
2124 "Get hash value of STRING in HASHTABLE."
2125 `(symbol-value (intern-soft ,string ,hashtable)))
2127 (defmacro gnus-sethash (string value hashtable)
2128 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2129 `(set (intern ,string ,hashtable) ,value))
2131 (defmacro gnus-intern-safe (string hashtable)
2132 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2133 `(let ((symbol (intern ,string ,hashtable)))
2138 (defmacro gnus-group-unread (group)
2139 "Get the currently computed number of unread articles in GROUP."
2140 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2142 (defmacro gnus-group-entry (group)
2143 "Get the newsrc entry for GROUP."
2144 `(gnus-gethash ,group gnus-newsrc-hashtb))
2146 (defmacro gnus-active (group)
2147 "Get active info on GROUP."
2148 `(gnus-gethash ,group gnus-active-hashtb))
2150 (defmacro gnus-set-active (group active)
2151 "Set GROUP's active info."
2152 `(gnus-sethash ,group ,active gnus-active-hashtb))
2154 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2155 ;; function `substring' might cut on a middle of multi-octet
2157 (defun gnus-truncate-string (str width)
2158 (substring str 0 width))
2160 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2161 ;; to limit the length of a string. This function is necessary since
2162 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2163 (defsubst gnus-limit-string (str width)
2164 (if (> (length str) width)
2165 (substring str 0 width)
2168 (defsubst gnus-simplify-subject-re (subject)
2169 "Remove \"Re:\" from subject lines."
2170 (if (string-match "^[Rr][Ee]: *" subject)
2171 (substring subject (match-end 0))
2174 (defsubst gnus-functionp (form)
2175 "Return non-nil if FORM is funcallable."
2176 (or (and (symbolp form) (fboundp form))
2177 (and (listp form) (eq (car form) 'lambda))))
2179 (defsubst gnus-goto-char (point)
2180 (and point (goto-char point)))
2182 (defmacro gnus-buffer-exists-p (buffer)
2183 `(let ((buffer ,buffer))
2185 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2188 (defmacro gnus-kill-buffer (buffer)
2189 `(let ((buf ,buffer))
2190 (if (gnus-buffer-exists-p buf)
2191 (kill-buffer buf))))
2193 (defsubst gnus-point-at-bol ()
2194 "Return point at the beginning of the line."
2201 (defsubst gnus-point-at-eol ()
2202 "Return point at the end of the line."
2209 (defun gnus-alive-p ()
2210 "Say whether Gnus is running or not."
2211 (and gnus-group-buffer
2212 (get-buffer gnus-group-buffer)))
2214 ;; Delete the current line (and the next N lines.);
2215 (defmacro gnus-delete-line (&optional n)
2216 `(delete-region (progn (beginning-of-line) (point))
2217 (progn (forward-line ,(or n 1)) (point))))
2219 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2220 (defvar gnus-init-inhibit nil)
2221 (defun gnus-read-init-file (&optional inhibit-next)
2222 (if gnus-init-inhibit
2223 (setq gnus-init-inhibit nil)
2224 (setq gnus-init-inhibit inhibit-next)
2226 (or (and (file-exists-p gnus-init-file)
2227 ;; Don't try to load a directory.
2228 (not (file-directory-p gnus-init-file)))
2229 (file-exists-p (concat gnus-init-file ".el"))
2230 (file-exists-p (concat gnus-init-file ".elc")))
2232 (load gnus-init-file nil t)
2234 (error "Error in %s: %s" gnus-init-file var))))))
2236 ;; Info access macros.
2238 (defmacro gnus-info-group (info)
2240 (defmacro gnus-info-rank (info)
2242 (defmacro gnus-info-read (info)
2244 (defmacro gnus-info-marks (info)
2246 (defmacro gnus-info-method (info)
2248 (defmacro gnus-info-params (info)
2251 (defmacro gnus-info-level (info)
2252 `(let ((rank (gnus-info-rank ,info)))
2256 (defmacro gnus-info-score (info)
2257 `(let ((rank (gnus-info-rank ,info)))
2258 (or (and (consp rank) (cdr rank)) 0)))
2260 (defmacro gnus-info-set-group (info group)
2261 `(setcar ,info ,group))
2262 (defmacro gnus-info-set-rank (info rank)
2263 `(setcar (nthcdr 1 ,info) ,rank))
2264 (defmacro gnus-info-set-read (info read)
2265 `(setcar (nthcdr 2 ,info) ,read))
2266 (defmacro gnus-info-set-marks (info marks)
2267 `(setcar (nthcdr 3 ,info) ,marks))
2268 (defmacro gnus-info-set-method (info method)
2269 `(setcar (nthcdr 4 ,info) ,method))
2270 (defmacro gnus-info-set-params (info params)
2271 `(setcar (nthcdr 5 ,info) ,params))
2273 (defmacro gnus-info-set-level (info level)
2274 `(let ((rank (cdr ,info)))
2275 (if (consp (car rank))
2276 (setcar (car rank) ,level)
2277 (setcar rank ,level))))
2278 (defmacro gnus-info-set-score (info score)
2279 `(let ((rank (cdr ,info)))
2280 (if (consp (car rank))
2281 (setcdr (car rank) ,score)
2282 (setcar rank (cons (car rank) ,score)))))
2284 (defmacro gnus-get-info (group)
2285 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2287 (defun gnus-byte-code (func)
2288 "Return a form that can be `eval'ed based on FUNC."
2289 (let ((fval (symbol-function func)))
2290 (if (byte-code-function-p fval)
2291 (let ((flist (append fval nil)))
2292 (setcar flist 'byte-code)
2294 (cons 'progn (cddr fval)))))
2296 ;;; Load the compatability functions.
2306 (defvar gnus-shutdown-alist nil)
2308 (defun gnus-add-shutdown (function &rest symbols)
2309 "Run FUNCTION whenever one of SYMBOLS is shut down."
2310 (push (cons function symbols) gnus-shutdown-alist))
2312 (defun gnus-shutdown (symbol)
2313 "Shut down everything that waits for SYMBOL."
2314 (let ((alist gnus-shutdown-alist)
2316 (while (setq entry (pop alist))
2317 (when (memq symbol (cdr entry))
2318 (funcall (car entry))))))
2322 ;; Format specs. The chunks below are the machine-generated forms
2323 ;; that are to be evaled as the result of the default format strings.
2324 ;; We write them in here to get them byte-compiled. That way the
2325 ;; default actions will be quite fast, while still retaining the full
2326 ;; flexibility of the user-defined format specs.
2328 ;; First we have lots of dummy defvars to let the compiler know these
2329 ;; are really dynamic variables.
2331 (defvar gnus-tmp-unread)
2332 (defvar gnus-tmp-replied)
2333 (defvar gnus-tmp-score-char)
2334 (defvar gnus-tmp-indentation)
2335 (defvar gnus-tmp-opening-bracket)
2336 (defvar gnus-tmp-lines)
2337 (defvar gnus-tmp-name)
2338 (defvar gnus-tmp-closing-bracket)
2339 (defvar gnus-tmp-subject-or-nil)
2340 (defvar gnus-tmp-subject)
2341 (defvar gnus-tmp-marked)
2342 (defvar gnus-tmp-marked-mark)
2343 (defvar gnus-tmp-subscribed)
2344 (defvar gnus-tmp-process-marked)
2345 (defvar gnus-tmp-number-of-unread)
2346 (defvar gnus-tmp-group-name)
2347 (defvar gnus-tmp-group)
2348 (defvar gnus-tmp-article-number)
2349 (defvar gnus-tmp-unread-and-unselected)
2350 (defvar gnus-tmp-news-method)
2351 (defvar gnus-tmp-news-server)
2352 (defvar gnus-tmp-article-number)
2353 (defvar gnus-mouse-face)
2354 (defvar gnus-mouse-face-prop)
2356 (defun gnus-summary-line-format-spec ()
2357 (insert gnus-tmp-unread gnus-tmp-replied
2358 gnus-tmp-score-char gnus-tmp-indentation)
2359 (gnus-put-text-property
2363 gnus-tmp-opening-bracket
2364 (format "%4d: %-20s"
2366 (if (> (length gnus-tmp-name) 20)
2367 (substring gnus-tmp-name 0 20)
2369 gnus-tmp-closing-bracket)
2371 gnus-mouse-face-prop gnus-mouse-face)
2372 (insert " " gnus-tmp-subject-or-nil "\n"))
2374 (defvar gnus-summary-line-format-spec
2375 (gnus-byte-code 'gnus-summary-line-format-spec))
2377 (defun gnus-summary-dummy-line-format-spec ()
2379 (gnus-put-text-property
2384 gnus-mouse-face-prop gnus-mouse-face)
2385 (insert " " gnus-tmp-subject "\n"))
2387 (defvar gnus-summary-dummy-line-format-spec
2388 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2390 (defun gnus-group-line-format-spec ()
2391 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2392 gnus-tmp-process-marked
2393 gnus-group-indentation
2394 (format "%5s: " gnus-tmp-number-of-unread))
2395 (gnus-put-text-property
2398 (insert gnus-tmp-group "\n")
2400 gnus-mouse-face-prop gnus-mouse-face))
2401 (defvar gnus-group-line-format-spec
2402 (gnus-byte-code 'gnus-group-line-format-spec))
2404 (defvar gnus-format-specs
2405 `((version . ,emacs-version)
2406 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2407 (summary-dummy ,gnus-summary-dummy-line-format
2408 ,gnus-summary-dummy-line-format-spec)
2409 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2411 (defvar gnus-article-mode-line-format-spec nil)
2412 (defvar gnus-summary-mode-line-format-spec nil)
2413 (defvar gnus-group-mode-line-format-spec nil)
2415 ;;; Phew. All that gruft is over, fortunately.
2419 ;;; Gnus Utility Functions
2422 (defun gnus-extract-address-components (from)
2424 ;; First find the address - the thing with the @ in it. This may
2425 ;; not be accurate in mail addresses, but does the trick most of
2426 ;; the time in news messages.
2427 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2428 (setq address (substring from (match-beginning 0) (match-end 0))))
2429 ;; Then we check whether the "name <address>" format is used.
2431 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2432 ;; Linear white space is not required.
2433 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2434 (and (setq name (substring from 0 (match-beginning 0)))
2435 ;; Strip any quotes from the name.
2436 (string-match "\".*\"" name)
2437 (setq name (substring name 1 (1- (match-end 0))))))
2438 ;; If not, then "address (name)" is used.
2440 (and (string-match "(.+)" from)
2441 (setq name (substring from (1+ (match-beginning 0))
2442 (1- (match-end 0)))))
2443 (and (string-match "()" from)
2444 (setq name address))
2445 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2446 ;; XOVER might not support folded From headers.
2447 (and (string-match "(.*" from)
2448 (setq name (substring from (1+ (match-beginning 0))
2450 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2451 (list (or name from) (or address from))))
2453 (defun gnus-fetch-field (field)
2454 "Return the value of the header FIELD of current article."
2457 (let ((case-fold-search t)
2458 (inhibit-point-motion-hooks t))
2459 (nnheader-narrow-to-headers)
2460 (message-fetch-field field)))))
2462 (defun gnus-goto-colon ()
2464 (search-forward ":" (gnus-point-at-eol) t))
2467 (defun gnus-update-format (var)
2468 "Update the format specification near point."
2473 ;; Find the end of the current word.
2474 (re-search-forward "[ \t\n]" nil t)
2476 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2477 (match-string 1)))))
2478 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2479 (match-string 1 var))))
2480 (entry (assq type gnus-format-specs))
2483 (setq gnus-format-specs (delq entry gnus-format-specs)))
2485 (intern (format "%s-spec" var))
2486 (gnus-parse-format (setq value (symbol-value (intern var)))
2487 (symbol-value (intern (format "%s-alist" var)))
2488 (not (string-match "mode" var))))
2489 (setq spec (symbol-value (intern (format "%s-spec" var))))
2490 (push (list type value spec) gnus-format-specs)
2492 (pop-to-buffer "*Gnus Format*")
2494 (lisp-interaction-mode)
2495 (insert (pp-to-string spec))))
2497 (defun gnus-update-format-specifications (&optional force)
2498 "Update all (necessary) format specifications."
2499 ;; Make the indentation array.
2500 (gnus-make-thread-indent-array)
2502 ;; See whether all the stored info needs to be flushed.
2504 (not (equal emacs-version
2505 (cdr (assq 'version gnus-format-specs)))))
2506 (setq gnus-format-specs nil))
2508 ;; Go through all the formats and see whether they need updating.
2509 (let ((types '(summary summary-dummy group
2510 summary-mode group-mode article-mode))
2511 new-format entry type val)
2512 (while (setq type (pop types))
2513 ;; Jump to the proper buffer to find out the value of
2514 ;; the variable, if possible. (It may be buffer-local.)
2516 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2518 (when (and (boundp buffer)
2519 (setq val (symbol-value buffer))
2521 (buffer-name (get-buffer val)))
2522 (set-buffer (get-buffer val)))
2523 (setq new-format (symbol-value
2524 (intern (format "gnus-%s-line-format" type))))))
2525 (setq entry (cdr (assq type gnus-format-specs)))
2527 (equal (car entry) new-format))
2528 ;; Use the old format.
2529 (set (intern (format "gnus-%s-line-format-spec" type))
2531 ;; This is a new format.
2533 (if (not (stringp new-format))
2534 ;; This is a function call or something.
2536 ;; This is a "real" format.
2540 (intern (format "gnus-%s-line-format-alist"
2541 (if (eq type 'article-mode)
2542 'summary-mode type))))
2543 (not (string-match "mode$" (symbol-name type))))))
2544 ;; Enter the new format spec into the list.
2547 (setcar (cdr entry) val)
2548 (setcar entry new-format))
2549 (push (list type new-format val) gnus-format-specs))
2550 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2552 (unless (assq 'version gnus-format-specs)
2553 (push (cons 'version emacs-version) gnus-format-specs))
2555 (gnus-update-group-mark-positions)
2556 (gnus-update-summary-mark-positions))
2558 (defun gnus-update-summary-mark-positions ()
2559 "Compute where the summary marks are to go."
2561 (when (and gnus-summary-buffer
2562 (get-buffer gnus-summary-buffer)
2563 (buffer-name (get-buffer gnus-summary-buffer)))
2564 (set-buffer gnus-summary-buffer))
2565 (let ((gnus-replied-mark 129)
2566 (gnus-score-below-mark 130)
2567 (gnus-score-over-mark 130)
2570 (spec gnus-summary-line-format-spec)
2573 (gnus-set-work-buffer)
2574 (let ((gnus-summary-line-format-spec spec))
2575 (gnus-summary-insert-line
2576 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2577 (goto-char (point-min))
2578 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2580 (goto-char (point-min))
2581 (push (cons 'replied (and (search-forward "\201" nil t)
2584 (goto-char (point-min))
2585 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2587 (setq gnus-summary-mark-positions pos))))
2589 (defun gnus-update-group-mark-positions ()
2591 (let ((gnus-process-mark 128)
2592 (gnus-group-marked '("dummy.group"))
2593 (gnus-active-hashtb (make-vector 10 0)))
2594 (gnus-set-active "dummy.group" '(0 . 0))
2595 (gnus-set-work-buffer)
2596 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2597 (goto-char (point-min))
2598 (setq gnus-group-mark-positions
2599 (list (cons 'process (and (search-forward "\200" nil t)
2600 (- (point) 2))))))))
2602 (defvar gnus-mouse-face-0 'highlight)
2603 (defvar gnus-mouse-face-1 'highlight)
2604 (defvar gnus-mouse-face-2 'highlight)
2605 (defvar gnus-mouse-face-3 'highlight)
2606 (defvar gnus-mouse-face-4 'highlight)
2608 (defun gnus-mouse-face-function (form type)
2609 `(gnus-put-text-property
2610 (point) (progn ,@form (point))
2611 gnus-mouse-face-prop
2614 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2616 (defvar gnus-face-0 'bold)
2617 (defvar gnus-face-1 'italic)
2618 (defvar gnus-face-2 'bold-italic)
2619 (defvar gnus-face-3 'bold)
2620 (defvar gnus-face-4 'bold)
2622 (defun gnus-face-face-function (form type)
2623 `(gnus-put-text-property
2624 (point) (progn ,@form (point))
2625 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2627 (defun gnus-max-width-function (el max-width)
2628 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2630 `(if (> (length ,el) ,max-width)
2631 (substring ,el 0 ,max-width)
2633 `(let ((val (eval ,el)))
2635 (setq val (int-to-string val)))
2636 (if (> (length val) ,max-width)
2637 (substring val 0 ,max-width)
2640 (defun gnus-parse-format (format spec-alist &optional insert)
2641 ;; This function parses the FORMAT string with the help of the
2642 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2643 ;; string. If the FORMAT string contains the specifiers %( and %)
2644 ;; the text between them will have the mouse-face text property.
2646 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2648 (gnus-parse-complex-format format spec-alist)
2649 ;; This is a simple format.
2650 (gnus-parse-simple-format format spec-alist insert)))
2652 (defun gnus-parse-complex-format (format spec-alist)
2654 (gnus-set-work-buffer)
2656 (goto-char (point-min))
2657 (while (re-search-forward "\"" nil t)
2658 (replace-match "\\\"" nil t))
2659 (goto-char (point-min))
2661 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2662 (let ((number (if (match-beginning 1)
2663 (match-string 1) "0"))
2664 (delim (aref (match-string 2) 0)))
2665 (if (or (= delim ?\() (= delim ?\{))
2666 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2668 (replace-match "\")\""))))
2669 (goto-char (point-max))
2671 (goto-char (point-min))
2672 (let ((form (read (current-buffer))))
2673 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2675 (defun gnus-complex-form-to-spec (form spec-alist)
2680 (gnus-parse-simple-format sform spec-alist t)
2681 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2682 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2686 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2687 ;; This function parses the FORMAT string with the help of the
2688 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2691 spec flist fstring newspec elem beg result dontinsert)
2693 (gnus-set-work-buffer)
2695 (goto-char (point-min))
2696 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2698 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2700 beg (1+ (match-beginning 0)))
2701 ;; First check if there are any specs that look anything like
2702 ;; "%12,12A", ie. with a "max width specification". These have
2703 ;; to be treated specially.
2704 (if (setq beg (match-beginning 1))
2708 (1+ (match-beginning 1)) (match-end 1))))
2710 (setq beg (match-beginning 2)))
2711 ;; Find the specification from `spec-alist'.
2712 (unless (setq elem (cdr (assq spec spec-alist)))
2713 (setq elem '("*" ?s)))
2714 ;; Treat user defined format specifiers specially.
2715 (when (eq (car elem) 'gnus-tmp-user-defined)
2718 (list (intern (concat "gnus-user-format-function-"
2720 'gnus-tmp-header) ?s))
2721 (delete-region (match-beginning 3) (match-end 3)))
2722 (if (not (zerop max-width))
2723 (let ((el (car elem)))
2724 (cond ((= (cadr elem) ?c)
2725 (setq el (list 'char-to-string el)))
2727 (setq el (list 'int-to-string el))))
2728 (setq flist (cons (gnus-max-width-function el max-width)
2732 (setq flist (cons (car elem) flist))
2733 (setq newspec (cadr elem)))))
2734 ;; Remove the old specification (and possibly a ",12" string).
2735 (delete-region beg (match-end 2))
2736 ;; Insert the new specification.
2739 (setq fstring (buffer-substring 1 (point-max))))
2740 ;; Do some postprocessing to increase efficiency.
2745 ((string= fstring "")
2747 ;; Not a format string.
2748 ((not (string-match "%" fstring))
2750 ;; A format string with just a single string spec.
2751 ((string= fstring "%s")
2753 ;; A single character.
2754 ((string= fstring "%c")
2757 ((string= fstring "%d")
2760 (list `(princ ,(car flist)))
2761 (list `(int-to-string ,(car flist)))))
2762 ;; Just lots of chars and strings.
2763 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2765 ;; A single string spec at the beginning of the spec.
2766 ((string-match "\\`%[sc][^%]+\\'" fstring)
2767 (list (car flist) (substring fstring 2)))
2768 ;; A single string spec in the middle of the spec.
2769 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2770 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2771 ;; A single string spec in the end of the spec.
2772 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2773 (list (match-string 1 fstring) (car flist)))
2774 ;; A more complex spec.
2776 (list (cons 'format (cons fstring (nreverse flist)))))))
2782 (cons 'insert result)))
2783 (cond ((stringp result)
2786 (cons 'concat result))
2789 (defun gnus-eval-format (format &optional alist props)
2790 "Eval the format variable FORMAT, using ALIST.
2791 If PROPS, insert the result."
2792 (let ((form (gnus-parse-format format alist props)))
2794 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2797 (defun gnus-remove-text-with-property (prop)
2798 "Delete all text in the current buffer with text property PROP."
2800 (goto-char (point-min))
2802 (while (get-text-property (point) prop)
2804 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2806 (defun gnus-set-work-buffer ()
2807 (if (get-buffer gnus-work-buffer)
2809 (set-buffer gnus-work-buffer)
2811 (set-buffer (get-buffer-create gnus-work-buffer))
2812 (kill-all-local-variables)
2813 (buffer-disable-undo (current-buffer))
2814 (gnus-add-current-to-buffer-list)))
2816 ;; Article file names when saving.
2818 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2819 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2820 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2821 Otherwise, it is like ~/News/news/group/num."
2824 (concat (if (gnus-use-long-file-name 'not-save)
2825 (gnus-capitalize-newsgroup newsgroup)
2826 (gnus-newsgroup-directory-form newsgroup))
2827 "/" (int-to-string (mail-header-number headers)))
2828 gnus-article-save-directory)))
2830 (string-equal (file-name-directory default)
2831 (file-name-directory last-file))
2832 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2834 (or last-file default))))
2836 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2837 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2838 If variable `gnus-use-long-file-name' is non-nil, it is
2839 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2842 (concat (if (gnus-use-long-file-name 'not-save)
2844 (gnus-newsgroup-directory-form newsgroup))
2845 "/" (int-to-string (mail-header-number headers)))
2846 gnus-article-save-directory)))
2848 (string-equal (file-name-directory default)
2849 (file-name-directory last-file))
2850 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2852 (or last-file default))))
2854 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2855 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2856 If variable `gnus-use-long-file-name' is non-nil, it is
2857 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2860 (if (gnus-use-long-file-name 'not-save)
2861 (gnus-capitalize-newsgroup newsgroup)
2862 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2863 gnus-article-save-directory)))
2865 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2866 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2867 If variable `gnus-use-long-file-name' is non-nil, it is
2868 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2871 (if (gnus-use-long-file-name 'not-save)
2873 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2874 gnus-article-save-directory)))
2876 ;; For subscribing new newsgroup
2878 (defun gnus-subscribe-hierarchical-interactive (groups)
2879 (let ((groups (sort groups 'string<))
2880 prefixes prefix start ans group starts)
2882 (setq prefixes (list "^"))
2883 (while (and groups prefixes)
2884 (while (not (string-match (car prefixes) (car groups)))
2885 (setq prefixes (cdr prefixes)))
2886 (setq prefix (car prefixes))
2887 (setq start (1- (length prefix)))
2888 (if (and (string-match "[^\\.]\\." (car groups) start)
2891 (concat "^" (substring (car groups) 0 (match-end 0))))
2892 (string-match prefix (cadr groups)))
2894 (setq prefixes (cons prefix prefixes))
2895 (message "Descend hierarchy %s? ([y]nsq): "
2896 (substring prefix 1 (1- (length prefix))))
2897 (setq ans (read-char))
2900 (string-match prefix
2901 (setq group (car groups))))
2902 (setq gnus-killed-list
2903 (cons group gnus-killed-list))
2904 (gnus-sethash group group gnus-killed-hashtb)
2905 (setq groups (cdr groups)))
2906 (setq starts (cdr starts)))
2909 (string-match prefix
2910 (setq group (car groups))))
2911 (gnus-sethash group group gnus-killed-hashtb)
2912 (gnus-subscribe-alphabetically (car groups))
2913 (setq groups (cdr groups)))
2914 (setq starts (cdr starts)))
2917 (setq group (car groups))
2918 (setq gnus-killed-list (cons group gnus-killed-list))
2919 (gnus-sethash group group gnus-killed-hashtb)
2920 (setq groups (cdr groups))))
2922 (message "Subscribe %s? ([n]yq)" (car groups))
2923 (setq ans (read-char))
2924 (setq group (car groups))
2926 (gnus-subscribe-alphabetically (car groups))
2927 (gnus-sethash group group gnus-killed-hashtb))
2930 (setq group (car groups))
2931 (setq gnus-killed-list (cons group gnus-killed-list))
2932 (gnus-sethash group group gnus-killed-hashtb)
2933 (setq groups (cdr groups))))
2935 (setq gnus-killed-list (cons group gnus-killed-list))
2936 (gnus-sethash group group gnus-killed-hashtb)))
2937 (setq groups (cdr groups)))))))
2939 (defun gnus-subscribe-randomly (newsgroup)
2940 "Subscribe new NEWSGROUP by making it the first newsgroup."
2941 (gnus-subscribe-newsgroup newsgroup))
2943 (defun gnus-subscribe-alphabetically (newgroup)
2944 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2945 (let ((groups (cdr gnus-newsrc-alist))
2947 (while (and (not before) groups)
2948 (if (string< newgroup (caar groups))
2949 (setq before (caar groups))
2950 (setq groups (cdr groups))))
2951 (gnus-subscribe-newsgroup newgroup before)))
2953 (defun gnus-subscribe-hierarchically (newgroup)
2954 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2955 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2957 (set-buffer (find-file-noselect gnus-current-startup-file))
2958 (let ((groupkey newgroup)
2960 (while (and (not before) groupkey)
2961 (goto-char (point-min))
2963 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2964 (while (and (re-search-forward groupkey-re nil t)
2966 (setq before (match-string 1))
2967 (string< before newgroup)))))
2968 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2970 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2971 (substring groupkey (match-beginning 1) (match-end 1)))))
2972 (gnus-subscribe-newsgroup newgroup before))))
2974 (defun gnus-subscribe-interactively (group)
2975 "Subscribe the new GROUP interactively.
2976 It is inserted in hierarchical newsgroup order if subscribed. If not,
2978 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2979 (gnus-subscribe-hierarchically group)
2980 (push group gnus-killed-list)))
2982 (defun gnus-subscribe-zombies (group)
2983 "Make the new GROUP into a zombie group."
2984 (push group gnus-zombie-list))
2986 (defun gnus-subscribe-killed (group)
2987 "Make the new GROUP a killed group."
2988 (push group gnus-killed-list))
2990 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2991 "Subscribe new NEWSGROUP.
2992 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2993 the first newsgroup."
2994 ;; We subscribe the group by changing its level to `subscribed'.
2995 (gnus-group-change-level
2996 newsgroup gnus-level-default-subscribed
2997 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2998 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3002 (defun gnus-newsgroup-directory-form (newsgroup)
3003 "Make hierarchical directory name from NEWSGROUP name."
3004 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3005 (len (length newsgroup))
3007 ;; If this is a foreign group, we don't want to translate the
3009 (if (setq idx (string-match ":" newsgroup))
3010 (aset newsgroup idx ?/)
3012 ;; Replace all occurrences of `.' with `/'.
3014 (if (= (aref newsgroup idx) ?.)
3015 (aset newsgroup idx ?/))
3016 (setq idx (1+ idx)))
3019 (defun gnus-newsgroup-savable-name (group)
3020 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3022 (nnheader-replace-chars-in-string group ?/ ?.))
3024 (defun gnus-make-directory (dir)
3025 "Make DIRECTORY recursively."
3026 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3027 ;; of the many mysteries of the universe.
3028 (let* ((dir (expand-file-name dir default-directory))
3030 (if (string-match "/$" dir)
3031 (setq dir (substring dir 0 (match-beginning 0))))
3032 ;; First go down the path until we find a directory that exists.
3033 (while (not (file-exists-p dir))
3034 (setq dirs (cons dir dirs))
3035 (string-match "/[^/]+$" dir)
3036 (setq dir (substring dir 0 (match-beginning 0))))
3037 ;; Then create all the subdirs.
3038 (while (and dirs (not err))
3040 (make-directory (car dirs))
3041 (error (setq err t)))
3042 (setq dirs (cdr dirs)))
3043 ;; We return whether we were successful or not.
3046 (defun gnus-capitalize-newsgroup (newsgroup)
3047 "Capitalize NEWSGROUP name."
3048 (and (not (zerop (length newsgroup)))
3049 (concat (char-to-string (upcase (aref newsgroup 0)))
3050 (substring newsgroup 1))))
3052 ;; Various... things.
3054 (defun gnus-simplify-subject (subject &optional re-only)
3055 "Remove `Re:' and words in parentheses.
3056 If RE-ONLY is non-nil, strip leading `Re:'s only."
3057 (let ((case-fold-search t)) ;Ignore case.
3058 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3059 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3060 (setq subject (substring subject (match-end 0))))
3061 ;; Remove uninteresting prefixes.
3062 (if (and (not re-only)
3063 gnus-simplify-ignored-prefixes
3064 (string-match gnus-simplify-ignored-prefixes subject))
3065 (setq subject (substring subject (match-end 0))))
3066 ;; Remove words in parentheses from end.
3068 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3069 (setq subject (substring subject 0 (match-beginning 0)))))
3070 ;; Return subject string.
3073 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3075 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3076 (defun gnus-simplify-buffer-fuzzy ()
3077 (goto-char (point-min))
3078 (while (search-forward "\t" nil t)
3079 (replace-match " " t t))
3080 (goto-char (point-min))
3081 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3082 (goto-char (match-beginning 0))
3084 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3085 (looking-at "^[[].*: .*[]]$"))
3086 (goto-char (point-min))
3087 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3089 (replace-match "" t t))
3090 (goto-char (point-min))
3091 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3092 (goto-char (match-end 0))
3095 (progn (goto-char (match-beginning 0)))
3096 (re-search-forward ":"))))
3097 (goto-char (point-min))
3098 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3099 (replace-match "" t t))
3100 (goto-char (point-min))
3101 (while (re-search-forward " +" nil t)
3102 (replace-match " " t t))
3103 (goto-char (point-min))
3104 (while (re-search-forward " $" nil t)
3105 (replace-match "" t t))
3106 (goto-char (point-min))
3107 (while (re-search-forward "^ +" nil t)
3108 (replace-match "" t t))
3109 (goto-char (point-min))
3110 (when gnus-simplify-subject-fuzzy-regexp
3111 (if (listp gnus-simplify-subject-fuzzy-regexp)
3112 (let ((list gnus-simplify-subject-fuzzy-regexp))
3114 (goto-char (point-min))
3115 (while (re-search-forward (car list) nil t)
3116 (replace-match "" t t))
3117 (setq list (cdr list))))
3118 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3119 (replace-match "" t t)))))
3121 (defun gnus-simplify-subject-fuzzy (subject)
3122 "Siplify a subject string fuzzily."
3124 (gnus-set-work-buffer)
3125 (let ((case-fold-search t))
3127 (inline (gnus-simplify-buffer-fuzzy))
3130 ;; Add the current buffer to the list of buffers to be killed on exit.
3131 (defun gnus-add-current-to-buffer-list ()
3132 (or (memq (current-buffer) gnus-buffer-list)
3133 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3135 (defun gnus-string> (s1 s2)
3136 (not (or (string< s1 s2)
3139 (defun gnus-read-active-file-p ()
3140 "Say whether the active file has been read from `gnus-select-method'."
3141 (memq gnus-select-method gnus-have-read-active-file))
3143 ;;; General various misc type functions.
3145 (defun gnus-clear-system ()
3146 "Clear all variables and buffers."
3147 ;; Clear Gnus variables.
3148 (let ((variables gnus-variable-list))
3150 (set (car variables) nil)
3151 (setq variables (cdr variables))))
3152 ;; Clear other internal variables.
3153 (setq gnus-list-of-killed-groups nil
3154 gnus-have-read-active-file nil
3155 gnus-newsrc-alist nil
3156 gnus-newsrc-hashtb nil
3157 gnus-killed-list nil
3158 gnus-zombie-list nil
3159 gnus-killed-hashtb nil
3160 gnus-active-hashtb nil
3161 gnus-moderated-list nil
3162 gnus-description-hashtb nil
3163 gnus-current-headers nil
3164 gnus-thread-indent-array nil
3165 gnus-newsgroup-headers nil
3166 gnus-newsgroup-name nil
3167 gnus-server-alist nil
3168 gnus-group-list-mode nil
3169 gnus-opened-servers nil
3170 gnus-current-select-method nil)
3171 (gnus-shutdown 'gnus)
3172 ;; Kill the startup file.
3173 (and gnus-current-startup-file
3174 (get-file-buffer gnus-current-startup-file)
3175 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3176 ;; Clear the dribble buffer.
3177 (gnus-dribble-clear)
3178 ;; Kill global KILL file buffer.
3179 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3180 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3181 (gnus-kill-buffer nntp-server-buffer)
3182 ;; Kill Gnus buffers.
3183 (while gnus-buffer-list
3184 (gnus-kill-buffer (pop gnus-buffer-list)))
3185 ;; Remove Gnus frames.
3186 (while gnus-created-frames
3187 (when (frame-live-p (car gnus-created-frames))
3188 ;; We slap a condition-case around this `delete-frame' to ensure
3189 ;; agains errors if we try do delete the single frame that's left.
3191 (delete-frame (car gnus-created-frames))
3193 (pop gnus-created-frames)))
3195 (defun gnus-windows-old-to-new (setting)
3196 ;; First we take care of the really, really old Gnus 3 actions.
3197 (when (symbolp setting)
3199 ;; Take care of ooold GNUS 3.x values.
3200 (cond ((eq setting 'SelectArticle) 'article)
3201 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3202 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3204 (if (or (listp setting)
3205 (not (and gnus-window-configuration
3206 (memq setting '(group summary article)))))
3208 (let* ((setting (if (eq setting 'group)
3209 (if (assq 'newsgroup gnus-window-configuration)
3211 'newsgroups) setting))
3212 (elem (cadr (assq setting gnus-window-configuration)))
3213 (total (apply '+ elem))
3214 (types '(group summary article))
3215 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3220 (or (not (numberp (nth i elem)))
3221 (zerop (nth i elem))
3223 (setq perc (/ (float (nth 0 elem)) total))
3224 (setq out (cons (if (eq pbuf (nth i types))
3225 (vector (nth i types) perc 'point)
3226 (vector (nth i types) perc))
3229 (list (nreverse out)))))
3232 (defun gnus-add-configuration (conf)
3233 "Add the window configuration CONF to `gnus-buffer-configuration'."
3234 (setq gnus-buffer-configuration
3235 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3236 gnus-buffer-configuration))))
3238 (defvar gnus-frame-list nil)
3240 (defun gnus-configure-frame (split &optional window)
3241 "Split WINDOW according to SPLIT."
3243 (setq window (get-buffer-window (current-buffer))))
3244 (select-window window)
3245 ;; This might be an old-stylee buffer config.
3246 (when (vectorp split)
3247 (setq split (append split nil)))
3248 (when (or (consp (car split))
3249 (vectorp (car split)))
3251 (push 'vertical split))
3252 ;; The SPLIT might be something that is to be evaled to
3253 ;; return a new SPLIT.
3254 (while (and (not (assq (car split) gnus-window-to-buffer))
3255 (gnus-functionp (car split)))
3256 (setq split (eval split)))
3257 (let* ((type (car split))
3259 (len (if (eq type 'horizontal) (window-width) (window-height)))
3261 (window-min-width (or gnus-window-min-width window-min-width))
3262 (window-min-height (or gnus-window-min-height window-min-height))
3263 s result new-win rest comp-subs size sub)
3265 ;; Nothing to do here.
3267 ;; Don't switch buffers.
3269 (and (memq 'point split) window))
3270 ;; This is a buffer to be selected.
3271 ((not (memq type '(frame horizontal vertical)))
3272 (let ((buffer (cond ((stringp type) type)
3273 (t (cdr (assq type gnus-window-to-buffer)))))
3276 (error "Illegal buffer type: %s" type))
3277 (unless (setq buf (get-buffer (if (symbolp buffer)
3278 (symbol-value buffer) buffer)))
3279 (setq buf (get-buffer-create (if (symbolp buffer)
3280 (symbol-value buffer) buffer))))
3281 (switch-to-buffer buf)
3282 ;; We return the window if it has the `point' spec.
3283 (and (memq 'point split) window)))
3284 ;; This is a frame split.
3286 (unless gnus-frame-list
3287 (setq gnus-frame-list (list (window-frame
3288 (get-buffer-window (current-buffer))))))
3290 params frame fresult)
3291 (while (< i (length subs))
3292 ;; Frame parameter is gotten from the sub-split.
3293 (setq params (cadr (elt subs i)))
3294 ;; It should be a list.
3295 (unless (listp params)
3297 ;; Create a new frame?
3298 (unless (setq frame (elt gnus-frame-list i))
3299 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3300 (push frame gnus-created-frames))
3301 ;; Is the old frame still alive?
3302 (unless (frame-live-p frame)
3303 (setcar (nthcdr i gnus-frame-list)
3304 (setq frame (make-frame params))))
3305 ;; Select the frame in question and do more splits there.
3306 (select-frame frame)
3307 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3309 ;; Select the frame that has the selected buffer.
3311 (select-frame (window-frame fresult)))))
3312 ;; This is a normal split.
3314 (when (> (length subs) 0)
3315 ;; First we have to compute the sizes of all new windows.
3317 (setq sub (append (pop subs) nil))
3318 (while (and (not (assq (car sub) gnus-window-to-buffer))
3319 (gnus-functionp (car sub)))
3320 (setq sub (eval sub)))
3322 (push sub comp-subs)
3323 (setq size (cadar comp-subs))
3324 (cond ((equal size 1.0)
3325 (setq rest (car comp-subs))
3328 (setq s (floor (* size len))))
3332 (error "Illegal size: %s" size)))
3333 ;; Try to make sure that we are inside the safe limits.
3335 ((eq type 'horizontal)
3336 (setq s (max s window-min-width)))
3337 ((eq type 'vertical)
3338 (setq s (max s window-min-height))))
3339 (setcar (cdar comp-subs) s)
3341 ;; Take care of the "1.0" spec.
3343 (setcar (cdr rest) (- len total))
3344 (error "No 1.0 specs in %s" split))
3345 ;; The we do the actual splitting in a nice recursive
3347 (setq comp-subs (nreverse comp-subs))
3349 (if (null (cdr comp-subs))
3350 (setq new-win window)
3352 (split-window window (cadar comp-subs)
3353 (eq type 'horizontal))))
3354 (setq result (or (gnus-configure-frame
3355 (car comp-subs) window) result))
3356 (select-window new-win)
3357 (setq window new-win)
3358 (setq comp-subs (cdr comp-subs))))
3359 ;; Return the proper window, if any.
3361 (select-window result))))))
3363 (defvar gnus-frame-split-p nil)
3365 (defun gnus-configure-windows (setting &optional force)
3366 (setq setting (gnus-windows-old-to-new setting))
3367 (let ((split (if (symbolp setting)
3368 (cadr (assq setting gnus-buffer-configuration))
3372 (setq gnus-frame-split-p nil)
3375 (error "No such setting: %s" setting))
3377 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3379 ;; All the windows mentioned are already visible, so we just
3380 ;; put point in the assigned buffer, and do not touch the
3382 (select-window all-visible)
3384 ;; Either remove all windows or just remove all Gnus windows.
3385 (let ((frame (selected-frame)))
3387 (if gnus-use-full-window
3388 ;; We want to remove all other windows.
3389 (if (not gnus-frame-split-p)
3390 ;; This is not a `frame' split, so we ignore the
3392 (delete-other-windows)
3393 ;; This is a `frame' split, so we delete all windows
3397 (unless (eq (cdr (assq 'minibuffer
3398 (frame-parameters frame)))
3400 (select-frame frame)
3401 (delete-other-windows)))
3403 ;; Just remove some windows.
3404 (gnus-remove-some-windows)
3405 (switch-to-buffer nntp-server-buffer))
3406 (select-frame frame)))
3408 (switch-to-buffer nntp-server-buffer)
3409 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3411 (defun gnus-all-windows-visible-p (split)
3412 "Say whether all buffers in SPLIT are currently visible.
3413 In particular, the value returned will be the window that
3415 (let ((stack (list split))
3417 type buffer win buf)
3418 (while (and (setq split (pop stack))
3420 ;; Be backwards compatible.
3421 (when (vectorp split)
3422 (setq split (append split nil)))
3423 (when (or (consp (car split))
3424 (vectorp (car split)))
3426 (push 'vertical split))
3427 ;; The SPLIT might be something that is to be evaled to
3428 ;; return a new SPLIT.
3429 (while (and (not (assq (car split) gnus-window-to-buffer))
3430 (gnus-functionp (car split)))
3431 (setq split (eval split)))
3433 (setq type (elt split 0))
3438 ((not (memq type '(horizontal vertical frame)))
3439 (setq buffer (cond ((stringp type) type)
3440 (t (cdr (assq type gnus-window-to-buffer)))))
3442 (error "Illegal buffer type: %s" type))
3443 (when (setq buf (get-buffer (if (symbolp buffer)
3444 (symbol-value buffer)
3446 (setq win (get-buffer-window buf t)))
3448 (when (memq 'point split)
3449 (setq all-visible win))
3450 (setq all-visible nil)))
3452 (when (eq type 'frame)
3453 (setq gnus-frame-split-p t))
3454 (setq stack (append (cddr split) stack)))))
3455 (unless (eq all-visible t)
3458 (defun gnus-window-top-edge (&optional window)
3459 (nth 1 (window-edges window)))
3461 (defun gnus-remove-some-windows ()
3462 (let ((buffers gnus-window-to-buffer)
3463 buf bufs lowest-buf lowest)
3465 ;; Remove windows on all known Gnus buffers.
3467 (setq buf (cdar buffers))
3469 (setq buf (and (boundp buf) (symbol-value buf))))
3471 (get-buffer-window buf)
3473 (setq bufs (cons buf bufs))
3475 (if (or (not lowest)
3476 (< (gnus-window-top-edge) lowest))
3478 (setq lowest (gnus-window-top-edge))
3479 (setq lowest-buf buf)))))
3480 (setq buffers (cdr buffers)))
3481 ;; Remove windows on *all* summary buffers.
3484 (let ((buf (window-buffer win)))
3485 (if (string-match "^\\*Summary" (buffer-name buf))
3487 (setq bufs (cons buf bufs))
3489 (if (or (not lowest)
3490 (< (gnus-window-top-edge) lowest))
3492 (setq lowest-buf buf)
3493 (setq lowest (gnus-window-top-edge)))))))))
3496 (pop-to-buffer lowest-buf)
3497 (switch-to-buffer nntp-server-buffer)))
3499 (and (not (eq (car bufs) lowest-buf))
3500 (delete-windows-on (car bufs)))
3501 (setq bufs (cdr bufs))))))
3503 (defun gnus-version ()
3504 "Version numbers of this version of Gnus."
3506 (let ((methods gnus-valid-select-methods)
3509 ;; Go through all the legal select methods and add their version
3510 ;; numbers to the total version string. Only the backends that are
3511 ;; currently in use will have their message numbers taken into
3514 (setq meth (intern (concat (caar methods) "-version")))
3516 (stringp (symbol-value meth))
3517 (setq mess (concat mess "; " (symbol-value meth))))
3518 (setq methods (cdr methods)))
3519 (gnus-message 2 mess)))
3521 (defun gnus-info-find-node ()
3522 "Find Info documentation of Gnus."
3524 ;; Enlarge info window if needed.
3525 (let ((mode major-mode)
3527 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3528 (setq gnus-info-buffer (current-buffer))
3529 (gnus-configure-windows 'info)))
3531 (defun gnus-days-between (date1 date2)
3532 ;; Return the number of days between date1 and date2.
3533 (- (gnus-day-number date1) (gnus-day-number date2)))
3535 (defun gnus-day-number (date)
3536 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3537 (timezone-parse-date date))))
3538 (timezone-absolute-from-gregorian
3539 (nth 1 dat) (nth 2 dat) (car dat))))
3541 (defun gnus-encode-date (date)
3542 "Convert DATE to internal time."
3543 (let* ((parse (timezone-parse-date date))
3544 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3545 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3546 (encode-time (caddr time) (cadr time) (car time)
3547 (caddr date) (cadr date) (car date) (nth 4 date))))
3549 (defun gnus-time-minus (t1 t2)
3550 "Subtract two internal times."
3551 (let ((borrow (< (cadr t1) (cadr t2))))
3552 (list (- (car t1) (car t2) (if borrow 1 0))
3553 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3555 (defun gnus-file-newer-than (file date)
3556 (let ((fdate (nth 5 (file-attributes file))))
3557 (or (> (car fdate) (car date))
3558 (and (= (car fdate) (car date))
3559 (> (nth 1 fdate) (nth 1 date))))))
3561 (defmacro gnus-local-set-keys (&rest plist)
3562 "Set the keys in PLIST in the current keymap."
3563 `(gnus-define-keys-1 (current-local-map) ',plist))
3565 (defmacro gnus-define-keys (keymap &rest plist)
3566 "Define all keys in PLIST in KEYMAP."
3567 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3569 (put 'gnus-define-keys 'lisp-indent-function 1)
3570 (put 'gnus-define-keys 'lisp-indent-hook 1)
3571 (put 'gnus-define-keymap 'lisp-indent-function 1)
3572 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3574 (defmacro gnus-define-keymap (keymap &rest plist)
3575 "Define all keys in PLIST in KEYMAP."
3576 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3578 (defun gnus-define-keys-1 (keymap plist)
3580 (error "Can't set keys in a null keymap"))
3581 (cond ((symbolp keymap)
3582 (setq keymap (symbol-value keymap)))
3585 (set (car keymap) nil)
3586 (define-prefix-command (car keymap))
3587 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3588 (setq keymap (symbol-value (car keymap)))))
3591 (when (symbolp (setq key (pop plist)))
3592 (setq key (symbol-value key)))
3593 (define-key keymap key (pop plist)))))
3595 (defun gnus-group-read-only-p (&optional group)
3596 "Check whether GROUP supports editing or not.
3597 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3598 that that variable is buffer-local to the summary buffers."
3599 (let ((group (or group gnus-newsgroup-name)))
3600 (not (gnus-check-backend-function 'request-replace-article group))))
3602 (defun gnus-group-total-expirable-p (group)
3603 "Check whether GROUP is total-expirable or not."
3604 (let ((params (gnus-info-params (gnus-get-info group))))
3605 (or (memq 'total-expire params)
3606 (cdr (assq 'total-expire params)) ; (total-expire . t)
3607 (and gnus-total-expirable-newsgroups ; Check var.
3608 (string-match gnus-total-expirable-newsgroups group)))))
3610 (defun gnus-group-auto-expirable-p (group)
3611 "Check whether GROUP is total-expirable or not."
3612 (let ((params (gnus-info-params (gnus-get-info group))))
3613 (or (memq 'auto-expire params)
3614 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3615 (and gnus-auto-expirable-newsgroups ; Check var.
3616 (string-match gnus-auto-expirable-newsgroups group)))))
3618 (defun gnus-virtual-group-p (group)
3619 "Say whether GROUP is virtual or not."
3620 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3621 gnus-valid-select-methods)))
3623 (defun gnus-news-group-p (group &optional article)
3624 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3625 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3626 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3627 (eq (gnus-request-type group article) 'news))))
3629 (defsubst gnus-simplify-subject-fully (subject)
3630 "Simplify a subject string according to the user's wishes."
3632 ((null gnus-summary-gather-subject-limit)
3633 (gnus-simplify-subject-re subject))
3634 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3635 (gnus-simplify-subject-fuzzy subject))
3636 ((numberp gnus-summary-gather-subject-limit)
3637 (gnus-limit-string (gnus-simplify-subject-re subject)
3638 gnus-summary-gather-subject-limit))
3642 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3643 "Check whether two subjects are equal. If optional argument
3644 simple-first is t, first argument is already simplified."
3646 ((null simple-first)
3647 (equal (gnus-simplify-subject-fully s1)
3648 (gnus-simplify-subject-fully s2)))
3651 (gnus-simplify-subject-fully s2)))))
3653 ;; Returns a list of writable groups.
3654 (defun gnus-writable-groups ()
3655 (let ((alist gnus-newsrc-alist)
3657 (while (setq group (car (pop alist)))
3658 (unless (gnus-group-read-only-p group)
3659 (push group groups)))
3662 (defun gnus-completing-read (default prompt &rest args)
3663 ;; Like `completing-read', except that DEFAULT is the default argument.
3664 (let* ((prompt (if default
3665 (concat prompt " (default " default ") ")
3666 (concat prompt " ")))
3667 (answer (apply 'completing-read prompt args)))
3668 (if (or (null answer) (zerop (length answer)))
3672 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3674 (defun gnus-y-or-n-p (prompt)
3679 (defun gnus-yes-or-no-p (prompt)
3681 (yes-or-no-p prompt)
3684 ;; Check whether to use long file names.
3685 (defun gnus-use-long-file-name (symbol)
3686 ;; The variable has to be set...
3687 (and gnus-use-long-file-name
3688 ;; If it isn't a list, then we return t.
3689 (or (not (listp gnus-use-long-file-name))
3690 ;; If it is a list, and the list contains `symbol', we
3692 (not (memq symbol gnus-use-long-file-name)))))
3694 ;; I suspect there's a better way, but I haven't taken the time to do
3695 ;; it yet. -erik selberg@cs.washington.edu
3696 (defun gnus-dd-mmm (messy-date)
3697 "Return a string like DD-MMM from a big messy string"
3698 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3704 ;; Make sure leading zeroes are stripped.
3705 (number-to-string (string-to-number (aref datevec 2)))
3709 (nth (1- (string-to-number (aref datevec 1)))
3710 timezone-months-assoc))
3713 (defun gnus-mode-string-quote (string)
3714 "Quote all \"%\" in STRING."
3716 (gnus-set-work-buffer)
3718 (goto-char (point-min))
3719 (while (search-forward "%" nil t)
3723 ;; Make a hash table (default and minimum size is 255).
3724 ;; Optional argument HASHSIZE specifies the table size.
3725 (defun gnus-make-hashtable (&optional hashsize)
3726 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3728 ;; Make a number that is suitable for hashing; bigger than MIN and one
3730 (defun gnus-create-hash-size (min)
3736 ;; Show message if message has a lower level than `gnus-verbose'.
3737 ;; Guideline for numbers:
3738 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3739 ;; for things that take a long time, 7 - not very important messages
3740 ;; on stuff, 9 - messages inside loops.
3741 (defun gnus-message (level &rest args)
3742 (if (<= level gnus-verbose)
3743 (apply 'message args)
3744 ;; We have to do this format thingy here even if the result isn't
3745 ;; shown - the return value has to be the same as the return value
3747 (apply 'format args)))
3749 (defun gnus-error (level &rest args)
3750 "Beep an error if `gnus-verbose' is on LEVEL or less."
3751 (when (<= (floor level) gnus-verbose)
3752 (apply 'message args)
3755 (when (and (floatp level)
3756 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3757 (sit-for duration))))
3760 ;; Generate a unique new group name.
3761 (defun gnus-generate-new-group-name (leaf)
3764 (while (gnus-gethash name gnus-newsrc-hashtb)
3765 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3768 (defsubst gnus-hide-text (b e props)
3769 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3770 (gnus-add-text-properties b e props)
3771 (when (memq 'intangible props)
3772 (gnus-put-text-property (max (1- b) (point-min))
3773 b 'intangible (cddr (memq 'intangible props)))))
3775 (defsubst gnus-unhide-text (b e)
3776 "Remove hidden text properties from region between B and E."
3777 (remove-text-properties b e gnus-hidden-properties)
3778 (when (memq 'intangible gnus-hidden-properties)
3779 (gnus-put-text-property (max (1- b) (point-min))
3780 b 'intangible nil)))
3782 (defun gnus-hide-text-type (b e type)
3783 "Hide text of TYPE between B and E."
3784 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3786 ;; Find out whether the gnus-visual TYPE is wanted.
3787 (defun gnus-visual-p (&optional type class)
3788 (and gnus-visual ; Has to be non-nil, at least.
3789 (if (not type) ; We don't care about type.
3791 (if (listp gnus-visual) ; It's a list, so we check it.
3792 (or (memq type gnus-visual)
3793 (memq class gnus-visual))
3796 (defun gnus-parent-headers (headers &optional generation)
3797 "Return the headers of the GENERATIONeth parent of HEADERS."
3799 (setq generation 1))
3800 (let (references parent)
3801 (while (and headers (not (zerop generation)))
3802 (setq references (mail-header-references headers))
3803 (when (and references
3804 (setq parent (gnus-parent-id references))
3805 (setq headers (car (gnus-id-to-thread parent))))
3809 (defun gnus-parent-id (references)
3810 "Return the last Message-ID in REFERENCES."
3811 (when (and references
3812 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3813 (substring references (match-beginning 1) (match-end 1))))
3815 (defun gnus-split-references (references)
3816 "Return a list of Message-IDs in REFERENCES."
3819 (while (string-match "<[^>]+>" references beg)
3820 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3824 (defun gnus-buffer-live-p (buffer)
3825 "Say whether BUFFER is alive or not."
3828 (buffer-name (get-buffer buffer))))
3830 (defun gnus-ephemeral-group-p (group)
3831 "Say whether GROUP is ephemeral or not."
3832 (gnus-group-get-parameter group 'quit-config))
3834 (defun gnus-group-quit-config (group)
3835 "Return the quit-config of GROUP."
3836 (gnus-group-get-parameter group 'quit-config))
3838 (defun gnus-simplify-mode-line ()
3839 "Make mode lines a bit simpler."
3840 (setq mode-line-modified "-- ")
3841 (when (listp mode-line-format)
3842 (make-local-variable 'mode-line-format)
3843 (setq mode-line-format (copy-sequence mode-line-format))
3844 (when (equal (nth 3 mode-line-format) " ")
3845 (setcar (nthcdr 3 mode-line-format) " "))))
3847 ;;; List and range functions
3849 (defun gnus-last-element (list)
3850 "Return last element of LIST."
3852 (setq list (cdr list)))
3855 (defun gnus-copy-sequence (list)
3856 "Do a complete, total copy of a list."
3857 (if (and (consp list) (not (consp (cdr list))))
3858 (cons (car list) (cdr list))
3859 (mapcar (lambda (elem) (if (consp elem)
3860 (if (consp (cdr elem))
3861 (gnus-copy-sequence elem)
3862 (cons (car elem) (cdr elem)))
3866 (defun gnus-set-difference (list1 list2)
3867 "Return a list of elements of LIST1 that do not appear in LIST2."
3868 (let ((list1 (copy-sequence list1)))
3870 (setq list1 (delq (car list2) list1))
3871 (setq list2 (cdr list2)))
3874 (defun gnus-sorted-complement (list1 list2)
3875 "Return a list of elements of LIST1 that do not appear in LIST2.
3876 Both lists have to be sorted over <."
3878 (if (or (null list1) (null list2))
3880 (while (and list1 list2)
3881 (cond ((= (car list1) (car list2))
3882 (setq list1 (cdr list1)
3884 ((< (car list1) (car list2))
3885 (setq out (cons (car list1) out))
3886 (setq list1 (cdr list1)))
3888 (setq out (cons (car list2) out))
3889 (setq list2 (cdr list2)))))
3890 (nconc (nreverse out) (or list1 list2)))))
3892 (defun gnus-intersection (list1 list2)
3895 (if (memq (car list2) list1)
3896 (setq result (cons (car list2) result)))
3897 (setq list2 (cdr list2)))
3900 (defun gnus-sorted-intersection (list1 list2)
3901 ;; LIST1 and LIST2 have to be sorted over <.
3903 (while (and list1 list2)
3904 (cond ((= (car list1) (car list2))
3905 (setq out (cons (car list1) out)
3908 ((< (car list1) (car list2))
3909 (setq list1 (cdr list1)))
3911 (setq list2 (cdr list2)))))
3914 (defun gnus-set-sorted-intersection (list1 list2)
3915 ;; LIST1 and LIST2 have to be sorted over <.
3916 ;; This function modifies LIST1.
3917 (let* ((top (cons nil list1))
3919 (while (and list1 list2)
3920 (cond ((= (car list1) (car list2))
3924 ((< (car list1) (car list2))
3925 (setcdr prev (cdr list1))
3926 (setq list1 (cdr list1)))
3928 (setq list2 (cdr list2)))))
3932 (defun gnus-compress-sequence (numbers &optional always-list)
3933 "Convert list of numbers to a list of ranges or a single range.
3934 If ALWAYS-LIST is non-nil, this function will always release a list of
3936 (let* ((first (car numbers))
3937 (last (car numbers))
3941 (if (not (listp (cdr numbers)))
3944 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3945 ((= (1+ last) (car numbers)) ;Still in sequence
3946 (setq last (car numbers)))
3947 (t ;End of one sequence
3949 (cons (if (= first last) first
3950 (cons first last)) result))
3951 (setq first (car numbers))
3952 (setq last (car numbers))))
3953 (setq numbers (cdr numbers)))
3954 (if (and (not always-list) (null result))
3955 (if (= first last) (list first) (cons first last))
3956 (nreverse (cons (if (= first last) first (cons first last))
3959 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3960 (defun gnus-uncompress-range (ranges)
3961 "Expand a list of ranges into a list of numbers.
3962 RANGES is either a single range on the form `(num . num)' or a list of
3964 (let (first last result)
3968 ((not (listp (cdr ranges)))
3969 (setq first (car ranges))
3970 (setq last (cdr ranges))
3971 (while (<= first last)
3972 (setq result (cons first result))
3973 (setq first (1+ first)))
3977 (if (atom (car ranges))
3978 (if (numberp (car ranges))
3979 (setq result (cons (car ranges) result)))
3980 (setq first (caar ranges))
3981 (setq last (cdar ranges))
3982 (while (<= first last)
3983 (setq result (cons first result))
3984 (setq first (1+ first))))
3985 (setq ranges (cdr ranges)))
3986 (nreverse result)))))
3988 (defun gnus-add-to-range (ranges list)
3989 "Return a list of ranges that has all articles from both RANGES and LIST.
3990 Note: LIST has to be sorted over `<'."
3992 (gnus-compress-sequence list t)
3993 (setq list (copy-sequence list))
3994 (or (listp (cdr ranges))
3995 (setq ranges (list ranges)))
3997 ilist lowest highest temp)
3998 (while (and ranges list)
4000 (setq lowest (or (and (atom (car ranges)) (car ranges))
4002 (while (and list (cdr list) (< (cadr list) lowest))
4003 (setq list (cdr list)))
4004 (if (< (car ilist) lowest)
4007 (setq list (cdr list))
4009 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4010 (setq highest (or (and (atom (car ranges)) (car ranges))
4012 (while (and list (<= (car list) highest))
4013 (setq list (cdr list)))
4014 (setq ranges (cdr ranges)))
4016 (setq out (nconc (gnus-compress-sequence list t) out)))
4017 (setq out (sort out (lambda (r1 r2)
4018 (< (or (and (atom r1) r1) (car r1))
4019 (or (and (atom r2) r2) (car r2))))))
4022 (if (atom (car ranges))
4024 (if (atom (cadr ranges))
4025 (if (= (1+ (car ranges)) (cadr ranges))
4027 (setcar ranges (cons (car ranges)
4029 (setcdr ranges (cddr ranges))))
4030 (if (= (1+ (car ranges)) (caadr ranges))
4032 (setcar (cadr ranges) (car ranges))
4033 (setcar ranges (cadr ranges))
4034 (setcdr ranges (cddr ranges))))))
4036 (if (atom (cadr ranges))
4037 (if (= (1+ (cdar ranges)) (cadr ranges))
4039 (setcdr (car ranges) (cadr ranges))
4040 (setcdr ranges (cddr ranges))))
4041 (if (= (1+ (cdar ranges)) (caadr ranges))
4043 (setcdr (car ranges) (cdadr ranges))
4044 (setcdr ranges (cddr ranges)))))))
4045 (setq ranges (cdr ranges)))
4048 (defun gnus-remove-from-range (ranges list)
4049 "Return a list of ranges that has all articles from LIST removed from RANGES.
4050 Note: LIST has to be sorted over `<'."
4051 ;; !!! This function shouldn't look like this, but I've got a headache.
4052 (gnus-compress-sequence
4053 (gnus-sorted-complement
4054 (gnus-uncompress-range ranges) list)))
4056 (defun gnus-member-of-range (number ranges)
4057 (if (not (listp (cdr ranges)))
4058 (and (>= number (car ranges))
4059 (<= number (cdr ranges)))
4062 (if (numberp (car ranges))
4063 (>= number (car ranges))
4064 (>= number (caar ranges)))
4066 (if (if (numberp (car ranges))
4067 (= number (car ranges))
4068 (and (>= number (caar ranges))
4069 (<= number (cdar ranges))))
4070 (setq not-stop nil))
4071 (setq ranges (cdr ranges)))
4074 (defun gnus-range-length (range)
4075 "Return the length RANGE would have if uncompressed."
4076 (length (gnus-uncompress-range range)))
4078 (defun gnus-sublist-p (list sublist)
4079 "Test whether all elements in SUBLIST are members of LIST."
4082 (unless (memq (pop sublist) list)
4092 (defvar gnus-group-mode-map nil)
4093 (put 'gnus-group-mode 'mode-class 'special)
4095 (unless gnus-group-mode-map
4096 (setq gnus-group-mode-map (make-keymap))
4097 (suppress-keymap gnus-group-mode-map)
4099 (gnus-define-keys gnus-group-mode-map
4100 " " gnus-group-read-group
4101 "=" gnus-group-select-group
4102 "\r" gnus-group-select-group
4103 "\M-\r" gnus-group-quick-select-group
4104 "j" gnus-group-jump-to-group
4105 "n" gnus-group-next-unread-group
4106 "p" gnus-group-prev-unread-group
4107 "\177" gnus-group-prev-unread-group
4108 [delete] gnus-group-prev-unread-group
4109 "N" gnus-group-next-group
4110 "P" gnus-group-prev-group
4111 "\M-n" gnus-group-next-unread-group-same-level
4112 "\M-p" gnus-group-prev-unread-group-same-level
4113 "," gnus-group-best-unread-group
4114 "." gnus-group-first-unread-group
4115 "u" gnus-group-unsubscribe-current-group
4116 "U" gnus-group-unsubscribe-group
4117 "c" gnus-group-catchup-current
4118 "C" gnus-group-catchup-current-all
4119 "l" gnus-group-list-groups
4120 "L" gnus-group-list-all-groups
4122 "g" gnus-group-get-new-news
4123 "\M-g" gnus-group-get-new-news-this-group
4124 "R" gnus-group-restart
4125 "r" gnus-group-read-init-file
4126 "B" gnus-group-browse-foreign-server
4127 "b" gnus-group-check-bogus-groups
4128 "F" gnus-find-new-newsgroups
4129 "\C-c\C-d" gnus-group-describe-group
4130 "\M-d" gnus-group-describe-all-groups
4131 "\C-c\C-a" gnus-group-apropos
4132 "\C-c\M-\C-a" gnus-group-description-apropos
4133 "a" gnus-group-post-news
4134 "\ek" gnus-group-edit-local-kill
4135 "\eK" gnus-group-edit-global-kill
4136 "\C-k" gnus-group-kill-group
4137 "\C-y" gnus-group-yank-group
4138 "\C-w" gnus-group-kill-region
4139 "\C-x\C-t" gnus-group-transpose-groups
4140 "\C-c\C-l" gnus-group-list-killed
4141 "\C-c\C-x" gnus-group-expire-articles
4142 "\C-c\M-\C-x" gnus-group-expire-all-groups
4144 "s" gnus-group-save-newsrc
4145 "z" gnus-group-suspend
4146 "Z" gnus-group-clear-dribble
4149 "?" gnus-group-describe-briefly
4150 "\C-c\C-i" gnus-info-find-node
4151 "\M-e" gnus-group-edit-group-method
4152 "^" gnus-group-enter-server-mode
4153 gnus-mouse-2 gnus-mouse-pick-group
4154 "<" beginning-of-buffer
4157 "\C-c\C-s" gnus-group-sort-groups
4159 "\C-c\M-g" gnus-activate-all-groups
4160 "\M-&" gnus-group-universal-argument
4161 "#" gnus-group-mark-group
4162 "\M-#" gnus-group-unmark-group)
4164 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4165 "m" gnus-group-mark-group
4166 "u" gnus-group-unmark-group
4167 "w" gnus-group-mark-region
4168 "m" gnus-group-mark-buffer
4169 "r" gnus-group-mark-regexp
4170 "U" gnus-group-unmark-all-groups)
4172 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4173 "d" gnus-group-make-directory-group
4174 "h" gnus-group-make-help-group
4175 "a" gnus-group-make-archive-group
4176 "k" gnus-group-make-kiboze-group
4177 "m" gnus-group-make-group
4178 "E" gnus-group-edit-group
4179 "e" gnus-group-edit-group-method
4180 "p" gnus-group-edit-group-parameters
4181 "v" gnus-group-add-to-virtual
4182 "V" gnus-group-make-empty-virtual
4183 "D" gnus-group-enter-directory
4184 "f" gnus-group-make-doc-group
4185 "r" gnus-group-rename-group
4186 "\177" gnus-group-delete-group
4187 [delete] gnus-group-delete-group)
4189 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4190 "b" gnus-group-brew-soup
4191 "w" gnus-soup-save-areas
4192 "s" gnus-soup-send-replies
4193 "p" gnus-soup-pack-packet
4194 "r" nnsoup-pack-replies)
4196 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4197 "s" gnus-group-sort-groups
4198 "a" gnus-group-sort-groups-by-alphabet
4199 "u" gnus-group-sort-groups-by-unread
4200 "l" gnus-group-sort-groups-by-level
4201 "v" gnus-group-sort-groups-by-score
4202 "r" gnus-group-sort-groups-by-rank
4203 "m" gnus-group-sort-groups-by-method)
4205 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4206 "k" gnus-group-list-killed
4207 "z" gnus-group-list-zombies
4208 "s" gnus-group-list-groups
4209 "u" gnus-group-list-all-groups
4210 "A" gnus-group-list-active
4211 "a" gnus-group-apropos
4212 "d" gnus-group-description-apropos
4213 "m" gnus-group-list-matching
4214 "M" gnus-group-list-all-matching
4215 "l" gnus-group-list-level)
4217 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4218 "f" gnus-score-flush-cache)
4220 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4221 "f" gnus-group-fetch-faq)
4223 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4224 "l" gnus-group-set-current-level
4225 "t" gnus-group-unsubscribe-current-group
4226 "s" gnus-group-unsubscribe-group
4227 "k" gnus-group-kill-group
4228 "y" gnus-group-yank-group
4229 "w" gnus-group-kill-region
4230 "\C-k" gnus-group-kill-level
4231 "z" gnus-group-kill-all-zombies))
4233 (defun gnus-group-mode ()
4234 "Major mode for reading news.
4236 All normal editing commands are switched off.
4237 \\<gnus-group-mode-map>
4238 The group buffer lists (some of) the groups available. For instance,
4239 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4240 lists all zombie groups.
4242 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4243 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4245 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4247 The following commands are available:
4249 \\{gnus-group-mode-map}"
4251 (when (and menu-bar-mode
4252 (gnus-visual-p 'group-menu 'menu))
4253 (gnus-group-make-menu-bar))
4254 (kill-all-local-variables)
4255 (gnus-simplify-mode-line)
4256 (setq major-mode 'gnus-group-mode)
4257 (setq mode-name "Group")
4258 (gnus-group-set-mode-line)
4259 (setq mode-line-process nil)
4260 (use-local-map gnus-group-mode-map)
4261 (buffer-disable-undo (current-buffer))
4262 (setq truncate-lines t)
4263 (setq buffer-read-only t)
4264 (run-hooks 'gnus-group-mode-hook))
4266 (defun gnus-mouse-pick-group (e)
4267 "Enter the group under the mouse pointer."
4270 (gnus-group-read-group nil))
4272 ;; Look at LEVEL and find out what the level is really supposed to be.
4273 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4274 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4275 (defun gnus-group-default-level (&optional level number-or-nil)
4277 (gnus-group-use-permanent-levels
4278 (or (setq gnus-group-use-permanent-levels
4279 (or level (if (numberp gnus-group-use-permanent-levels)
4280 gnus-group-use-permanent-levels
4281 (or gnus-group-default-list-level
4282 gnus-level-subscribed))))
4283 gnus-group-default-list-level gnus-level-subscribed))
4287 (or level gnus-group-default-list-level gnus-level-subscribed))))
4290 (defun gnus-slave-no-server (&optional arg)
4291 "Read network news as a slave, without connecting to local server"
4293 (gnus-no-server arg t))
4296 (defun gnus-no-server (&optional arg slave)
4298 If ARG is a positive number, Gnus will use that as the
4299 startup level. If ARG is nil, Gnus will be started at level 2.
4300 If ARG is non-nil and not a positive number, Gnus will
4301 prompt the user for the name of an NNTP server to use.
4302 As opposed to `gnus', this command will not connect to the local server."
4304 (let ((val (or arg (1- gnus-level-default-subscribed))))
4306 (make-local-variable 'gnus-group-use-permanent-levels)
4307 (setq gnus-group-use-permanent-levels val)))
4310 (defun gnus-slave (&optional arg)
4311 "Read news as a slave."
4313 (gnus arg nil 'slave))
4316 (defun gnus-other-frame (&optional arg)
4317 "Pop up a frame to read news."
4319 (if (get-buffer gnus-group-buffer)
4320 (let ((pop-up-frames t))
4322 (select-frame (make-frame))
4326 (defun gnus (&optional arg dont-connect slave)
4328 If ARG is non-nil and a positive number, Gnus will use that as the
4329 startup level. If ARG is non-nil and not a positive number, Gnus will
4330 prompt the user for the name of an NNTP server to use."
4333 (if (get-buffer gnus-group-buffer)
4335 (switch-to-buffer gnus-group-buffer)
4336 (gnus-group-get-new-news))
4339 (nnheader-init-server-buffer)
4340 (gnus-read-init-file)
4341 (setq gnus-slave slave)
4343 (gnus-group-setup-buffer)
4344 (let ((buffer-read-only nil))
4346 (if (not gnus-inhibit-startup-message)
4348 (gnus-group-startup-message)
4351 (let ((level (and (numberp arg) (> arg 0) arg))
4357 (gnus-start-news-server (and arg (not level))))))
4358 (if (and (not dont-connect)
4361 (run-hooks 'gnus-startup-hook)
4362 ;; NNTP server is successfully open.
4364 ;; Find the current startup file name.
4365 (setq gnus-current-startup-file
4366 (gnus-make-newsrc-file gnus-startup-file))
4368 ;; Read the dribble file.
4369 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4371 ;; Allow using GroupLens predictions.
4372 (when gnus-use-grouplens
4374 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4376 (gnus-summary-make-display-table)
4377 ;; Do the actual startup.
4378 (gnus-setup-news nil level dont-connect)
4379 ;; Generate the group buffer.
4380 (gnus-group-list-groups level)
4381 (gnus-group-first-unread-group)
4382 (gnus-configure-windows 'group)
4383 (gnus-group-set-mode-line))))))
4385 (defun gnus-unload ()
4386 "Unload all Gnus features."
4388 (or (boundp 'load-history)
4389 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4390 (let ((history load-history)
4393 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4394 (setq feature (cdr (assq 'provide (car history))))
4395 (unload-feature feature 'force))
4396 (setq history (cdr history)))))
4398 (defun gnus-compile ()
4399 "Byte-compile the user-defined format specs."
4401 (let ((entries gnus-format-specs)
4402 entry gnus-tmp-func)
4404 (gnus-message 7 "Compiling format specs...")
4407 (setq entry (pop entries))
4408 (if (eq (car entry) 'version)
4409 (setq gnus-format-specs (delq entry gnus-format-specs))
4410 (when (and (listp (caddr entry))
4411 (not (eq 'byte-code (caaddr entry))))
4412 (fset 'gnus-tmp-func
4413 `(lambda () ,(caddr entry)))
4414 (byte-compile 'gnus-tmp-func)
4415 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4417 (push (cons 'version emacs-version) gnus-format-specs)
4419 (gnus-message 7 "Compiling user specs...done"))))
4421 (defun gnus-indent-rigidly (start end arg)
4422 "Indent rigidly using only spaces and no tabs."
4425 (narrow-to-region start end)
4426 (indent-rigidly start end arg)
4427 (goto-char (point-min))
4428 (while (search-forward "\t" nil t)
4429 (replace-match " " t t)))))
4431 (defun gnus-group-startup-message (&optional x y)
4432 "Insert startup message in current buffer."
4433 ;; Insert the message.
4438 _ ___ __ ___ __ _ ___
4457 ;; And then hack it.
4458 (gnus-indent-rigidly (point-min) (point-max)
4459 (/ (max (- (window-width) (or x 46)) 0) 2))
4460 (goto-char (point-min))
4462 (let* ((pheight (count-lines (point-min) (point-max)))
4463 (wheight (window-height))
4464 (rest (- wheight pheight)))
4465 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4467 (goto-char (point-min))
4468 (and (search-forward "Praxis" nil t)
4469 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4470 (goto-char (point-min))
4471 (let* ((mode-string (gnus-group-set-mode-line)))
4472 (setq mode-line-buffer-identification
4473 (list (concat gnus-version (substring (car mode-string) 4))))
4474 (set-buffer-modified-p t)))
4476 (defun gnus-group-setup-buffer ()
4477 (or (get-buffer gnus-group-buffer)
4479 (switch-to-buffer gnus-group-buffer)
4480 (gnus-add-current-to-buffer-list)
4482 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4484 (defun gnus-group-list-groups (&optional level unread lowest)
4485 "List newsgroups with level LEVEL or lower that have unread articles.
4486 Default is all subscribed groups.
4487 If argument UNREAD is non-nil, groups with no unread articles are also
4489 (interactive (list (if current-prefix-arg
4490 (prefix-numeric-value current-prefix-arg)
4492 (gnus-group-default-level nil t)
4493 gnus-group-default-list-level
4494 gnus-level-subscribed))))
4496 (setq level (car gnus-group-list-mode)
4497 unread (cdr gnus-group-list-mode)))
4498 (setq level (gnus-group-default-level level))
4499 (gnus-group-setup-buffer) ;May call from out of group buffer
4500 (gnus-update-format-specifications)
4501 (let ((case-fold-search nil)
4502 (props (text-properties-at (gnus-point-at-bol)))
4503 (group (gnus-group-group-name)))
4504 (set-buffer gnus-group-buffer)
4505 (funcall gnus-group-prepare-function level unread lowest)
4506 (if (zerop (buffer-size))
4507 (gnus-message 5 gnus-no-groups-message)
4508 (goto-char (point-max))
4509 (when (or (not gnus-group-goto-next-group-function)
4510 (not (funcall gnus-group-goto-next-group-function
4513 ;; Go to the first group with unread articles.
4514 (gnus-group-search-forward t)
4515 ;; Find the right group to put point on. If the current group
4516 ;; has disappeared in the new listing, try to find the next
4517 ;; one. If no next one can be found, just leave point at the
4518 ;; first newsgroup in the buffer.
4519 (if (not (gnus-goto-char
4521 (point-min) (point-max)
4522 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4523 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4525 (not (gnus-goto-char
4527 (point-min) (point-max) 'gnus-group
4529 (caar newsrc) gnus-active-hashtb)))))
4530 (setq newsrc (cdr newsrc)))
4531 (or newsrc (progn (goto-char (point-max))
4532 (forward-line -1)))))))
4533 ;; Adjust cursor point.
4534 (gnus-group-position-point))))
4536 (defun gnus-group-list-level (level &optional all)
4537 "List groups on LEVEL.
4538 If ALL (the prefix), also list groups that have no unread articles."
4539 (interactive "nList groups on level: \nP")
4540 (gnus-group-list-groups level all level))
4542 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4543 "List all newsgroups with unread articles of level LEVEL or lower.
4544 If ALL is non-nil, list groups that have no unread articles.
4545 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4546 If REGEXP, only list groups matching REGEXP."
4547 (set-buffer gnus-group-buffer)
4548 (let ((buffer-read-only nil)
4549 (newsrc (cdr gnus-newsrc-alist))
4550 (lowest (or lowest 1))
4551 info clevel unread group params)
4553 (if (< lowest gnus-level-zombie)
4554 ;; List living groups.
4556 (setq info (car newsrc)
4557 group (gnus-info-group info)
4558 params (gnus-info-params info)
4560 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4561 (and unread ; This group might be bogus
4563 (string-match regexp group))
4564 (<= (setq clevel (gnus-info-level info)) level)
4566 (or all ; We list all groups?
4567 (if (eq unread t) ; Unactivated?
4568 gnus-group-list-inactive-groups ; We list unactivated
4569 (> unread 0)) ; We list groups with unread articles
4570 (and gnus-list-groups-with-ticked-articles
4571 (cdr (assq 'tick (gnus-info-marks info))))
4572 ; And groups with tickeds
4573 ;; Check for permanent visibility.
4574 (and gnus-permanently-visible-groups
4575 (string-match gnus-permanently-visible-groups
4577 (memq 'visible params)
4578 (cdr (assq 'visible params)))
4579 (gnus-group-insert-group-line
4580 group (gnus-info-level info)
4581 (gnus-info-marks info) unread (gnus-info-method info)))))
4583 ;; List dead groups.
4584 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4585 (gnus-group-prepare-flat-list-dead
4586 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4587 gnus-level-zombie ?Z
4589 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4590 (gnus-group-prepare-flat-list-dead
4591 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4592 gnus-level-killed ?K regexp))
4594 (gnus-group-set-mode-line)
4595 (setq gnus-group-list-mode (cons level all))
4596 (run-hooks 'gnus-group-prepare-hook)))
4598 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4599 ;; List zombies and killed lists somewhat faster, which was
4600 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4601 ;; this by ignoring the group format specification altogether.
4604 ;; This loop is used when listing groups that match some
4607 (setq group (pop groups))
4608 (when (string-match regexp group)
4609 (gnus-add-text-properties
4610 (point) (prog1 (1+ (point))
4611 (insert " " mark " *: " group "\n"))
4612 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4614 'gnus-level level))))
4615 ;; This loop is used when listing all groups.
4617 (gnus-add-text-properties
4618 (point) (prog1 (1+ (point))
4619 (insert " " mark " *: "
4620 (setq group (pop groups)) "\n"))
4621 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4623 'gnus-level level))))))
4625 (defmacro gnus-group-real-name (group)
4626 "Find the real name of a foreign newsgroup."
4627 `(let ((gname ,group))
4628 (if (string-match ":[^:]+$" gname)
4629 (substring gname (1+ (match-beginning 0)))
4632 (defsubst gnus-server-add-address (method)
4633 (let ((method-name (symbol-name (car method))))
4634 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4635 (not (assq (intern (concat method-name "-address")) method)))
4636 (append method (list (list (intern (concat method-name "-address"))
4640 (defsubst gnus-server-get-method (group method)
4641 ;; Input either a server name, and extended server name, or a
4642 ;; select method, and return a select method.
4643 (cond ((stringp method)
4644 (gnus-server-to-method method))
4645 ((equal method gnus-select-method)
4647 ((and (stringp (car method)) group)
4648 (gnus-server-extend-method group method))
4649 ((and method (not group)
4650 (equal (cadr method) ""))
4653 (gnus-server-add-address method))))
4655 (defun gnus-server-to-method (server)
4656 "Map virtual server names to select methods."
4658 ;; Is this a method, perhaps?
4659 (and server (listp server) server)
4660 ;; Perhaps this is the native server?
4661 (and (equal server "native") gnus-select-method)
4662 ;; It should be in the server alist.
4663 (cdr (assoc server gnus-server-alist))
4664 ;; If not, we look through all the opened server
4665 ;; to see whether we can find it there.
4666 (let ((opened gnus-opened-servers))
4668 (not (equal server (format "%s:%s" (caaar opened)
4673 (defmacro gnus-method-equal (ss1 ss2)
4674 "Say whether two servers are equal."
4678 (and (= (length s1) (length s2))
4680 (while (and s1 (member (car s1) s2))
4684 (defun gnus-server-equal (m1 m2)
4685 "Say whether two methods are equal."
4686 (let ((m1 (cond ((null m1) gnus-select-method)
4687 ((stringp m1) (gnus-server-to-method m1))
4689 (m2 (cond ((null m2) gnus-select-method)
4690 ((stringp m2) (gnus-server-to-method m2))
4692 (gnus-method-equal m1 m2)))
4694 (defun gnus-servers-using-backend (backend)
4695 "Return a list of known servers using BACKEND."
4696 (let ((opened gnus-opened-servers)
4699 (when (eq backend (caaar opened))
4700 (push (caar opened) out))
4704 (defun gnus-group-prefixed-name (group method)
4705 "Return the whole name from GROUP and METHOD."
4706 (and (stringp method) (setq method (gnus-server-to-method method)))
4707 (concat (format "%s" (car method))
4709 (or (assoc (format "%s" (car method))
4710 (gnus-methods-using 'address))
4711 (gnus-server-equal method gnus-message-archive-method))
4713 (not (string= (nth 1 method) "")))
4714 (concat "+" (nth 1 method)))
4717 (defun gnus-group-real-prefix (group)
4718 "Return the prefix of the current group name."
4719 (if (string-match "^[^:]+:" group)
4720 (substring group 0 (match-end 0))
4723 (defun gnus-group-method (group)
4724 "Return the server or method used for selecting GROUP."
4725 (let ((prefix (gnus-group-real-prefix group)))
4726 (if (equal prefix "")
4728 (let ((servers gnus-opened-servers)
4730 backend possible found)
4731 (if (string-match "^[^\\+]+\\+" prefix)
4732 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4733 server (substring prefix (match-end 0) (1- (length prefix))))
4734 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4736 (when (eq (caaar servers) backend)
4737 (setq possible (caar servers))
4738 (when (equal (cadaar servers) server)
4739 (setq found (caar servers))))
4741 (or (car (rassoc found gnus-server-alist))
4743 (car (rassoc possible gnus-server-alist))
4745 (list backend server))))))
4747 (defsubst gnus-secondary-method-p (method)
4748 "Return whether METHOD is a secondary select method."
4749 (let ((methods gnus-secondary-select-methods)
4750 (gmethod (gnus-server-get-method nil method)))
4752 (not (equal (gnus-server-get-method nil (car methods))
4754 (setq methods (cdr methods)))
4757 (defun gnus-group-foreign-p (group)
4758 "Say whether a group is foreign or not."
4759 (and (not (gnus-group-native-p group))
4760 (not (gnus-group-secondary-p group))))
4762 (defun gnus-group-native-p (group)
4763 "Say whether the group is native or not."
4764 (not (string-match ":" group)))
4766 (defun gnus-group-secondary-p (group)
4767 "Say whether the group is secondary or not."
4768 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4770 (defun gnus-group-get-parameter (group &optional symbol)
4771 "Returns the group parameters for GROUP.
4772 If SYMBOL, return the value of that symbol in the group parameters."
4773 (let ((params (gnus-info-params (gnus-get-info group))))
4775 (gnus-group-parameter-value params symbol)
4778 (defun gnus-group-parameter-value (params symbol)
4779 "Return the value of SYMBOL in group PARAMS."
4780 (or (car (memq symbol params)) ; It's either a simple symbol
4781 (cdr (assq symbol params)))) ; or a cons.
4783 (defun gnus-group-add-parameter (group param)
4784 "Add parameter PARAM to GROUP."
4785 (let ((info (gnus-get-info group)))
4787 () ; This is a dead group. We just ignore it.
4788 ;; Cons the new param to the old one and update.
4789 (gnus-group-set-info (cons param (gnus-info-params info))
4792 (defun gnus-group-set-parameter (group name value)
4793 "Set parameter NAME to VALUE in GROUP."
4794 (let ((info (gnus-get-info group)))
4796 () ; This is a dead group. We just ignore it.
4797 (let ((old-params (gnus-info-params info))
4798 (new-params (list (cons name value))))
4800 (if (or (not (listp (car old-params)))
4801 (not (eq (caar old-params) name)))
4802 (setq new-params (append new-params (list (car old-params)))))
4803 (setq old-params (cdr old-params)))
4804 (gnus-group-set-info new-params group 'params)))))
4806 (defun gnus-group-add-score (group &optional score)
4807 "Add SCORE to the GROUP score.
4808 If SCORE is nil, add 1 to the score of GROUP."
4809 (let ((info (gnus-get-info group)))
4811 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4813 (defun gnus-summary-bubble-group ()
4814 "Increase the score of the current group.
4815 This is a handy function to add to `gnus-summary-exit-hook' to
4816 increase the score of each group you read."
4817 (gnus-group-add-score gnus-newsgroup-name))
4819 (defun gnus-group-set-info (info &optional method-only-group part)
4820 (let* ((entry (gnus-gethash
4821 (or method-only-group (gnus-info-group info))
4822 gnus-newsrc-hashtb))
4824 (info (if method-only-group (nth 2 entry) info))
4826 (when method-only-group
4828 (error "Trying to change non-existent group %s" method-only-group))
4829 ;; We have received parts of the actual group info - either the
4830 ;; select method or the group parameters. We first check
4831 ;; whether we have to extend the info, and if so, do that.
4832 (let ((len (length info))
4833 (total (if (eq part 'method) 5 6)))
4835 (setcdr (nthcdr (1- len) info)
4836 (make-list (- total len) nil)))
4837 ;; Then we enter the new info.
4838 (setcar (nthcdr (1- total) info) part-info)))
4840 ;; This is a new group, so we just create it.
4842 (set-buffer gnus-group-buffer)
4843 (setq method (gnus-info-method info))
4844 (when (gnus-server-equal method "native")
4847 (set-buffer gnus-group-buffer)
4849 ;; It's a foreign group...
4850 (gnus-group-make-group
4851 (gnus-group-real-name (gnus-info-group info))
4852 (if (stringp method) method
4853 (prin1-to-string (car method)))
4855 (nth 1 (gnus-info-method info))))
4856 ;; It's a native group.
4857 (gnus-group-make-group (gnus-info-group info))))
4858 (gnus-message 6 "Note: New group created")
4860 (gnus-gethash (gnus-group-prefixed-name
4861 (gnus-group-real-name (gnus-info-group info))
4862 (or (gnus-info-method info) gnus-select-method))
4863 gnus-newsrc-hashtb))))
4864 ;; Whether it was a new group or not, we now have the entry, so we
4865 ;; can do the update.
4868 (setcar (nthcdr 2 entry) info)
4869 (when (and (not (eq (car entry) t))
4870 (gnus-active (gnus-info-group info)))
4871 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4872 (error "No such group: %s" (gnus-info-group info)))))
4874 (defun gnus-group-set-method-info (group select-method)
4875 (gnus-group-set-info select-method group 'method))
4877 (defun gnus-group-set-params-info (group params)
4878 (gnus-group-set-info params group 'params))
4880 (defun gnus-group-update-group-line ()
4881 "Update the current line in the group buffer."
4882 (let* ((buffer-read-only nil)
4883 (group (gnus-group-group-name))
4884 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4885 gnus-group-indentation)
4887 (not (gnus-ephemeral-group-p group))
4889 (concat "(gnus-group-set-info '"
4890 (prin1-to-string (nth 2 entry)) ")")))
4891 (setq gnus-group-indentation (gnus-group-group-indentation))
4893 (gnus-group-insert-group-line-info group)
4895 (gnus-group-position-point)))
4897 (defun gnus-group-insert-group-line-info (group)
4898 "Insert GROUP on the current line."
4899 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4903 ;; (Un)subscribed group.
4904 (setq info (nth 2 entry))
4905 (gnus-group-insert-group-line
4906 group (gnus-info-level info) (gnus-info-marks info)
4907 (or (car entry) t) (gnus-info-method info)))
4908 ;; This group is dead.
4909 (gnus-group-insert-group-line
4911 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4913 (if (setq active (gnus-active group))
4914 (- (1+ (cdr active)) (car active)) 0)
4917 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4918 gnus-tmp-marked number
4920 "Insert a group line in the group buffer."
4921 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4922 (gnus-tmp-number-total
4924 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4926 (gnus-tmp-number-of-unread
4927 (if (numberp number) (int-to-string (max 0 number))
4929 (gnus-tmp-number-of-read
4930 (if (numberp number)
4931 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4933 (gnus-tmp-subscribed
4934 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4935 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4936 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4938 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4939 (gnus-tmp-newsgroup-description
4940 (if gnus-description-hashtb
4941 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4944 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4945 (gnus-tmp-moderated-string
4946 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4948 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4949 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4950 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4951 (gnus-tmp-news-method-string
4953 (format "(%s:%s)" (car gnus-tmp-method)
4954 (cadr gnus-tmp-method)) ""))
4955 (gnus-tmp-marked-mark
4956 (if (and (numberp number)
4958 (cdr (assq 'tick gnus-tmp-marked)))
4960 (gnus-tmp-process-marked
4961 (if (member gnus-tmp-group gnus-group-marked)
4962 gnus-process-mark ? ))
4964 (or (and gnus-use-grouplens
4965 (bbb-grouplens-group-p gnus-tmp-group))
4967 (buffer-read-only nil)
4968 header gnus-tmp-header) ; passed as parameter to user-funcs.
4970 (gnus-add-text-properties
4974 (eval gnus-group-line-format-spec))
4975 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4976 gnus-unread ,(if (numberp number)
4977 (string-to-int gnus-tmp-number-of-unread)
4979 gnus-marked ,gnus-tmp-marked-mark
4980 gnus-indentation ,gnus-group-indentation
4981 gnus-level ,gnus-tmp-level))
4982 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4984 (run-hooks 'gnus-group-update-hook)
4986 ;; Allow XEmacs to remove front-sticky text properties.
4987 (gnus-group-remove-excess-properties)))
4989 (defun gnus-group-update-group (group &optional visible-only)
4990 "Update all lines where GROUP appear.
4991 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4994 (set-buffer gnus-group-buffer)
4995 ;; The buffer may be narrowed.
4998 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5000 found buffer-read-only)
5001 ;; Enter the current status into the dribble buffer.
5002 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5003 (if (and entry (not (gnus-ephemeral-group-p group)))
5005 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5007 ;; Find all group instances. If topics are in use, each group
5008 ;; may be listed in more than once.
5009 (while (setq loc (text-property-any
5010 loc (point-max) 'gnus-group ident))
5013 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5015 (gnus-group-insert-group-line-info group))
5016 (setq loc (1+ loc)))
5017 (unless (or found visible-only)
5018 ;; No such line in the buffer, find out where it's supposed to
5019 ;; go, and insert it there (or at the end of the buffer).
5020 (if gnus-goto-missing-group-function
5021 (funcall gnus-goto-missing-group-function group)
5022 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5023 (while (and entry (car entry)
5027 (point-min) (point-max)
5028 'gnus-group (gnus-intern-safe
5029 (caar entry) gnus-active-hashtb)))))
5030 (setq entry (cdr entry)))
5031 (or entry (goto-char (point-max)))))
5032 ;; Finally insert the line.
5033 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5034 (gnus-group-insert-group-line-info group)))
5035 (gnus-group-set-mode-line)))))
5037 (defun gnus-group-set-mode-line ()
5038 "Update the mode line in the group buffer."
5039 (when (memq 'group gnus-updated-mode-lines)
5040 ;; Yes, we want to keep this mode line updated.
5042 (set-buffer gnus-group-buffer)
5043 (let* ((gformat (or gnus-group-mode-line-format-spec
5044 (setq gnus-group-mode-line-format-spec
5046 gnus-group-mode-line-format
5047 gnus-group-mode-line-format-alist))))
5048 (gnus-tmp-news-server (cadr gnus-select-method))
5049 (gnus-tmp-news-method (car gnus-select-method))
5050 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5052 gnus-tmp-header ;Dummy binding for user-defined formats
5053 ;; Get the resulting string.
5054 (mode-string (eval gformat)))
5055 ;; Say whether the dribble buffer has been modified.
5056 (setq mode-line-modified
5057 (if (and gnus-dribble-buffer
5058 (buffer-name gnus-dribble-buffer)
5059 (buffer-modified-p gnus-dribble-buffer)
5061 (set-buffer gnus-dribble-buffer)
5062 (not (zerop (buffer-size)))))
5064 ;; If the line is too long, we chop it off.
5065 (when (> (length mode-string) max-len)
5066 (setq mode-string (substring mode-string 0 (- max-len 4))))
5068 (setq mode-line-buffer-identification
5070 (set-buffer-modified-p t))))))
5072 (defun gnus-group-group-name ()
5073 "Get the name of the newsgroup on the current line."
5074 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5075 (and group (symbol-name group))))
5077 (defun gnus-group-group-level ()
5078 "Get the level of the newsgroup on the current line."
5079 (get-text-property (gnus-point-at-bol) 'gnus-level))
5081 (defun gnus-group-group-indentation ()
5082 "Get the indentation of the newsgroup on the current line."
5083 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5084 (and gnus-group-indentation-function
5085 (funcall gnus-group-indentation-function))
5088 (defun gnus-group-group-unread ()
5089 "Get the number of unread articles of the newsgroup on the current line."
5090 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5092 (defun gnus-group-search-forward (&optional backward all level first-too)
5093 "Find the next newsgroup with unread articles.
5094 If BACKWARD is non-nil, find the previous newsgroup instead.
5095 If ALL is non-nil, just find any newsgroup.
5096 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5098 If FIRST-TOO, the current line is also eligible as a target."
5099 (let ((way (if backward -1 1))
5100 (low gnus-level-killed)
5103 (if (and backward (progn (beginning-of-line)) (bobp))
5105 (or first-too (forward-line way))
5113 (get-text-property (point) 'gnus-unread)))
5114 (and (numberp unread) (> unread 0)))
5115 (setq lev (get-text-property (point)
5117 (<= lev gnus-level-subscribed)))
5119 (and (setq lev (get-text-property (point)
5128 (zerop (forward-line way)))))
5130 (progn (gnus-group-position-point) t)
5131 (goto-char (or pos beg))
5134 ;;; Gnus group mode commands
5138 (defun gnus-group-mark-group (n &optional unmark no-advance)
5139 "Mark the current group."
5141 (let ((buffer-read-only nil)
5145 (when (setq group (gnus-group-group-name))
5149 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5154 (setq gnus-group-marked (delete group gnus-group-marked)))
5156 (setq gnus-group-marked
5157 (cons group (delete group gnus-group-marked)))))
5158 (or no-advance (gnus-group-next-group 1))
5160 (gnus-summary-position-point)
5163 (defun gnus-group-unmark-group (n)
5164 "Remove the mark from the current group."
5166 (gnus-group-mark-group n 'unmark)
5167 (gnus-group-position-point))
5169 (defun gnus-group-unmark-all-groups ()
5170 "Unmark all groups."
5172 (let ((groups gnus-group-marked))
5175 (gnus-group-remove-mark (pop groups)))))
5176 (gnus-group-position-point))
5178 (defun gnus-group-mark-region (unmark beg end)
5179 "Mark all groups between point and mark.
5180 If UNMARK, remove the mark instead."
5181 (interactive "P\nr")
5182 (let ((num (count-lines beg end)))
5185 (- num (gnus-group-mark-group num unmark)))))
5187 (defun gnus-group-mark-buffer (&optional unmark)
5188 "Mark all groups in the buffer.
5189 If UNMARK, remove the mark instead."
5191 (gnus-group-mark-region unmark (point-min) (point-max)))
5193 (defun gnus-group-mark-regexp (regexp)
5194 "Mark all groups that match some regexp."
5195 (interactive "sMark (regexp): ")
5196 (let ((alist (cdr gnus-newsrc-alist))
5199 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5200 (gnus-group-set-mark group))))
5201 (gnus-group-position-point))
5203 (defun gnus-group-remove-mark (group)
5204 "Remove the process mark from GROUP and move point there.
5205 Return nil if the group isn't displayed."
5206 (if (gnus-group-goto-group group)
5208 (gnus-group-mark-group 1 'unmark t)
5210 (setq gnus-group-marked
5211 (delete group gnus-group-marked))
5214 (defun gnus-group-set-mark (group)
5215 "Set the process mark on GROUP."
5216 (if (gnus-group-goto-group group)
5218 (gnus-group-mark-group 1 nil t))
5219 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5221 (defun gnus-group-universal-argument (arg &optional groups func)
5222 "Perform any command on all groups accoring to the process/prefix convention."
5224 (let ((groups (or groups (gnus-group-process-prefix arg)))
5226 (if (eq (setq func (or func
5229 (substitute-command-keys
5230 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5232 (gnus-error 1 "Undefined key")
5234 (gnus-group-remove-mark (setq group (pop groups)))
5235 (command-execute func))))
5236 (gnus-group-position-point))
5238 (defun gnus-group-process-prefix (n)
5239 "Return a list of groups to work on.
5240 Take into consideration N (the prefix) and the list of marked groups."
5243 (setq n (prefix-numeric-value n))
5244 ;; There is a prefix, so we return a list of the N next
5246 (let ((way (if (< n 0) -1 1))
5251 (setq group (gnus-group-group-name)))
5252 (setq groups (cons group groups))
5254 (gnus-group-next-group way)))
5256 ((and (boundp 'transient-mark-mode)
5258 (boundp 'mark-active)
5260 ;; Work on the region between point and mark.
5261 (let ((max (max (point) (mark)))
5264 (goto-char (min (point) (mark)))
5267 (push (gnus-group-group-name) groups)
5268 (zerop (gnus-group-next-group 1))
5270 (nreverse groups))))
5272 ;; No prefix, but a list of marked articles.
5273 (reverse gnus-group-marked))
5275 ;; Neither marked articles or a prefix, so we return the
5277 (let ((group (gnus-group-group-name)))
5278 (and group (list group))))))
5280 ;; Selecting groups.
5282 (defun gnus-group-read-group (&optional all no-article group)
5283 "Read news in this newsgroup.
5284 If the prefix argument ALL is non-nil, already read articles become
5285 readable. IF ALL is a number, fetch this number of articles. If the
5286 optional argument NO-ARTICLE is non-nil, no article will be
5287 auto-selected upon group entry. If GROUP is non-nil, fetch that
5290 (let ((group (or group (gnus-group-group-name)))
5291 number active marked entry)
5292 (or group (error "No group on current line"))
5293 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5294 group gnus-newsrc-hashtb)))))
5295 ;; This group might be a dead group. In that case we have to get
5296 ;; the number of unread articles from `gnus-active-hashtb'.
5298 (cond ((numberp all) all)
5300 ((setq active (gnus-active group))
5301 (- (1+ (cdr active)) (car active)))))
5302 (gnus-summary-read-group
5303 group (or all (and (numberp number)
5304 (zerop (+ number (length (cdr (assq 'tick marked)))
5305 (length (cdr (assq 'dormant marked)))))))
5308 (defun gnus-group-select-group (&optional all)
5309 "Select this newsgroup.
5310 No article is selected automatically.
5311 If ALL is non-nil, already read articles become readable.
5312 If ALL is a number, fetch this number of articles."
5314 (gnus-group-read-group all t))
5316 (defun gnus-group-quick-select-group (&optional all)
5317 "Select the current group \"quickly\".
5318 This means that no highlighting or scoring will be performed."
5321 gnus-score-find-score-files-function
5322 gnus-apply-kill-hook
5323 gnus-summary-expunge-below)
5324 (gnus-group-read-group all t)))
5326 (defun gnus-group-visible-select-group (&optional all)
5327 "Select the current group without hiding any articles."
5329 (let ((gnus-inhibit-limiting t))
5330 (gnus-group-read-group all t)))
5333 (defun gnus-fetch-group (group)
5334 "Start Gnus if necessary and enter GROUP.
5335 Returns whether the fetching was successful or not."
5336 (interactive "sGroup name: ")
5337 (or (get-buffer gnus-group-buffer)
5339 (gnus-group-read-group nil nil group))
5341 ;; Enter a group that is not in the group buffer. Non-nil is returned
5342 ;; if selection was successful.
5343 (defun gnus-group-read-ephemeral-group
5344 (group method &optional activate quit-config)
5345 (let ((group (if (gnus-group-foreign-p group) group
5346 (gnus-group-prefixed-name group method))))
5349 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5350 ((quit-config . ,(if quit-config quit-config
5351 (cons (current-buffer) 'summary))))))
5353 (set-buffer gnus-group-buffer)
5354 (or (gnus-check-server method)
5355 (error "Unable to contact server: %s" (gnus-status-message method)))
5356 (if activate (or (gnus-request-group group)
5357 (error "Couldn't request group")))
5359 (gnus-group-read-group t t group)
5363 (defun gnus-group-jump-to-group (group)
5364 "Jump to newsgroup GROUP."
5366 (list (completing-read
5367 "Group: " gnus-active-hashtb nil
5368 (gnus-read-active-file-p)
5370 'gnus-group-history)))
5372 (when (equal group "")
5373 (error "Empty group name"))
5375 (when (string-match "[\000-\032]" group)
5376 (error "Control characters in group: %s" group))
5378 (let ((b (text-property-any
5379 (point-min) (point-max)
5380 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5381 (unless (gnus-ephemeral-group-p group)
5383 ;; Either go to the line in the group buffer...
5385 ;; ... or insert the line.
5388 (gnus-activate-group group)
5389 (error "%s error: %s" group (gnus-status-message group)))
5391 (gnus-group-update-group group)
5392 (goto-char (text-property-any
5393 (point-min) (point-max)
5394 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5395 ;; Adjust cursor point.
5396 (gnus-group-position-point)))
5398 (defun gnus-group-goto-group (group)
5399 "Goto to newsgroup GROUP."
5401 (let ((b (text-property-any (point-min) (point-max)
5402 'gnus-group (gnus-intern-safe
5403 group gnus-active-hashtb))))
5404 (and b (goto-char b)))))
5406 (defun gnus-group-next-group (n)
5407 "Go to next N'th newsgroup.
5408 If N is negative, search backward instead.
5409 Returns the difference between N and the number of skips actually
5412 (gnus-group-next-unread-group n t))
5414 (defun gnus-group-next-unread-group (n &optional all level)
5415 "Go to next N'th unread newsgroup.
5416 If N is negative, search backward instead.
5417 If ALL is non-nil, choose any newsgroup, unread or not.
5418 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5419 such group can be found, the next group with a level higher than
5421 Returns the difference between N and the number of skips actually
5424 (let ((backward (< n 0))
5427 (gnus-group-search-forward
5428 backward (or (not gnus-group-goto-unread) all) level))
5430 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5431 (if level " on this level or higher" "")))
5434 (defun gnus-group-prev-group (n)
5435 "Go to previous N'th newsgroup.
5436 Returns the difference between N and the number of skips actually
5439 (gnus-group-next-unread-group (- n) t))
5441 (defun gnus-group-prev-unread-group (n)
5442 "Go to previous N'th unread newsgroup.
5443 Returns the difference between N and the number of skips actually
5446 (gnus-group-next-unread-group (- n)))
5448 (defun gnus-group-next-unread-group-same-level (n)
5449 "Go to next N'th unread newsgroup on the same level.
5450 If N is negative, search backward instead.
5451 Returns the difference between N and the number of skips actually
5454 (gnus-group-next-unread-group n t (gnus-group-group-level))
5455 (gnus-group-position-point))
5457 (defun gnus-group-prev-unread-group-same-level (n)
5458 "Go to next N'th unread newsgroup on the same level.
5459 Returns the difference between N and the number of skips actually
5462 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5463 (gnus-group-position-point))
5465 (defun gnus-group-best-unread-group (&optional exclude-group)
5466 "Go to the group with the highest level.
5467 If EXCLUDE-GROUP, do not go to that group."
5469 (goto-char (point-min))
5473 (setq unread (get-text-property (point) 'gnus-unread))
5474 (if (and (numberp unread) (> unread 0))
5476 (if (and (get-text-property (point) 'gnus-level)
5477 (< (get-text-property (point) 'gnus-level) best)
5478 (or (not exclude-group)
5479 (not (equal exclude-group (gnus-group-group-name)))))
5481 (setq best (get-text-property (point) 'gnus-level))
5482 (setq best-point (point))))))
5484 (if best-point (goto-char best-point))
5485 (gnus-summary-position-point)
5486 (and best-point (gnus-group-group-name))))
5488 (defun gnus-group-first-unread-group ()
5489 "Go to the first group with unread articles."
5492 (let ((opoint (point))
5494 (goto-char (point-min))
5495 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5496 (and (numberp unread) ; Not a topic.
5497 (not (zerop unread))) ; Has unread articles.
5498 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5501 nil)) ; Not success.
5502 (gnus-group-position-point)))
5504 (defun gnus-group-enter-server-mode ()
5505 "Jump to the server buffer."
5507 (gnus-enter-server-buffer))
5509 (defun gnus-group-make-group (name &optional method address)
5510 "Add a new newsgroup.
5511 The user will be prompted for a NAME, for a select METHOD, and an
5515 (read-string "Group name: ")
5518 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5519 nil t nil 'gnus-method-history)))
5520 (cond ((assoc method gnus-valid-select-methods)
5522 (if (memq 'prompt-address
5523 (assoc method gnus-valid-select-methods))
5524 (read-string "Address: ")
5526 ((assoc method gnus-server-alist)
5529 (list method ""))))))
5531 (let* ((meth (and method (if address (list (intern method) address)
5533 (nname (if method (gnus-group-prefixed-name name meth) name))
5535 (when (gnus-gethash nname gnus-newsrc-hashtb)
5536 (error "Group %s already exists" nname))
5537 ;; Subscribe to the new group.
5538 (gnus-group-change-level
5539 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5540 gnus-level-default-subscribed gnus-level-killed
5541 (and (gnus-group-group-name)
5542 (gnus-gethash (gnus-group-group-name)
5543 gnus-newsrc-hashtb))
5546 (gnus-set-active nname (cons 1 0))
5547 (or (gnus-ephemeral-group-p name)
5549 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5551 (gnus-group-insert-group-line-info nname)
5553 (gnus-group-position-point)
5555 ;; Load the backend and try to make the backend create
5556 ;; the group as well.
5557 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5559 gnus-valid-select-methods)
5561 (gnus-check-server meth)
5562 (and (gnus-check-backend-function 'request-create-group nname)
5563 (gnus-request-create-group nname))
5566 (defun gnus-group-delete-group (group &optional force)
5567 "Delete the current group.
5568 If FORCE (the prefix) is non-nil, all the articles in the group will
5569 be deleted. This is \"deleted\" as in \"removed forever from the face
5570 of the Earth\". There is no undo."
5572 (list (gnus-group-group-name)
5573 current-prefix-arg))
5574 (or group (error "No group to rename"))
5575 (or (gnus-check-backend-function 'request-delete-group group)
5576 (error "This backend does not support group deletion"))
5578 (if (not (gnus-yes-or-no-p
5580 "Do you really want to delete %s%s? "
5581 group (if force " and all its contents" ""))))
5583 (gnus-message 6 "Deleting group %s..." group)
5584 (if (not (gnus-request-delete-group group force))
5585 (gnus-error 3 "Couldn't delete group %s" group)
5586 (gnus-message 6 "Deleting group %s...done" group)
5587 (gnus-group-goto-group group)
5588 (gnus-group-kill-group 1 t)
5589 (gnus-sethash group nil gnus-active-hashtb)
5591 (gnus-group-position-point)))
5593 (defun gnus-group-rename-group (group new-name)
5596 (gnus-group-group-name)
5598 (or (gnus-check-backend-function
5599 'request-rename-group (gnus-group-group-name))
5600 (error "This backend does not support renaming groups"))
5601 (read-string "New group name: "))))
5603 (or (gnus-check-backend-function 'request-rename-group group)
5604 (error "This backend does not support renaming groups"))
5606 (or group (error "No group to rename"))
5607 (and (string-match "^[ \t]*$" new-name)
5608 (error "Not a valid group name"))
5610 ;; We find the proper prefixed name.
5612 (gnus-group-prefixed-name
5613 (gnus-group-real-name new-name)
5614 (gnus-info-method (gnus-get-info group))))
5616 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5618 (if (not (gnus-request-rename-group group new-name))
5619 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5620 ;; We rename the group internally by killing it...
5621 (gnus-group-goto-group group)
5622 (gnus-group-kill-group)
5623 ;; ... changing its name ...
5624 (setcar (cdar gnus-list-of-killed-groups) new-name)
5625 ;; ... and then yanking it. Magic!
5626 (gnus-group-yank-group)
5627 (gnus-set-active new-name (gnus-active group))
5628 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5630 (gnus-group-position-point)))
5632 (defun gnus-group-edit-group (group &optional part)
5633 "Edit the group on the current line."
5634 (interactive (list (gnus-group-group-name)))
5635 (let* ((part (or part 'info))
5636 (done-func `(lambda ()
5637 "Exit editing mode and update the information."
5639 (gnus-group-edit-group-done ',part ,group)))
5640 (winconf (current-window-configuration))
5642 (or group (error "No group on current line"))
5643 (or (setq info (gnus-get-info group))
5644 (error "Killed group; can't be edited"))
5645 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5646 (gnus-configure-windows 'edit-group)
5647 (gnus-add-current-to-buffer-list)
5649 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5650 (use-local-map (copy-keymap emacs-lisp-mode-map))
5651 (local-set-key "\C-c\C-c" done-func)
5652 (make-local-variable 'gnus-prev-winconf)
5653 (setq gnus-prev-winconf winconf)
5658 ";; Type `C-c C-c' after editing the select method.\n\n")
5660 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5662 ";; Type `C-c C-c' after editing the group info.\n\n")))
5665 (cond ((eq part 'method)
5666 (or (gnus-info-method info) "native"))
5668 (gnus-info-params info))
5672 (defun gnus-group-edit-group-method (group)
5673 "Edit the select method of GROUP."
5674 (interactive (list (gnus-group-group-name)))
5675 (gnus-group-edit-group group 'method))
5677 (defun gnus-group-edit-group-parameters (group)
5678 "Edit the group parameters of GROUP."
5679 (interactive (list (gnus-group-group-name)))
5680 (gnus-group-edit-group group 'params))
5682 (defun gnus-group-edit-group-done (part group)
5683 "Get info from buffer, update variables and jump to the group buffer."
5684 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5685 (goto-char (point-min))
5686 (let* ((form (read (current-buffer)))
5687 (winconf gnus-prev-winconf)
5688 (method (cond ((eq part 'info) (nth 4 form))
5689 ((eq part 'method) form)
5691 (info (cond ((eq part 'info) form)
5692 ((eq part 'method) (gnus-get-info group))
5695 (if (or (not method)
5697 gnus-select-method method))
5698 (gnus-group-real-name (car info))
5699 (gnus-group-prefixed-name
5700 (gnus-group-real-name (car info)) method))
5702 (when (and new-group
5703 (not (equal new-group group)))
5704 (when (gnus-group-goto-group group)
5705 (gnus-group-kill-group 1))
5706 (gnus-activate-group new-group))
5708 (if (and info new-group)
5710 (setq info (gnus-copy-sequence info))
5711 (setcar info new-group)
5712 (unless (gnus-server-equal method "native")
5713 (unless (nthcdr 3 info)
5714 (nconc info (list nil nil)))
5715 (unless (nthcdr 4 info)
5716 (nconc info (list nil)))
5717 (gnus-info-set-method info method))
5718 (gnus-group-set-info info))
5719 (gnus-group-set-info form (or new-group group) part))
5720 (kill-buffer (current-buffer))
5721 (and winconf (set-window-configuration winconf))
5722 (set-buffer gnus-group-buffer)
5723 (gnus-group-update-group (or new-group group))
5724 (gnus-group-position-point)))
5726 (defun gnus-group-make-help-group ()
5727 "Create the Gnus documentation group."
5729 (let ((path load-path)
5730 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5732 (and (gnus-gethash name gnus-newsrc-hashtb)
5733 (error "Documentation group already exists"))
5735 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5737 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5739 (setq file (concat (file-name-directory
5740 (directory-file-name dir))
5741 "etc/gnus-tut.txt"))))
5744 (gnus-message 1 "Couldn't find doc group")
5745 (gnus-group-make-group
5746 (gnus-group-real-name name)
5747 (list 'nndoc "gnus-help"
5748 (list 'nndoc-address file)
5749 (list 'nndoc-article-type 'mbox)))))
5750 (gnus-group-position-point))
5752 (defun gnus-group-make-doc-group (file type)
5753 "Create a group that uses a single file as the source."
5755 (list (read-file-name "File name: ")
5756 (and current-prefix-arg 'ask)))
5757 (when (eq type 'ask)
5762 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5764 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5765 ((= char ?b) 'babyl)
5766 ((= char ?d) 'digest)
5767 ((= char ?f) 'forward)
5769 (t (setq err (format "%c unknown. " char))
5772 (let* ((file (expand-file-name file))
5773 (name (gnus-generate-new-group-name
5774 (gnus-group-prefixed-name
5775 (file-name-nondirectory file) '(nndoc "")))))
5776 (gnus-group-make-group
5777 (gnus-group-real-name name)
5778 (list 'nndoc (file-name-nondirectory file)
5779 (list 'nndoc-address file)
5780 (list 'nndoc-article-type (or type 'guess))))))
5782 (defun gnus-group-make-archive-group (&optional all)
5783 "Create the (ding) Gnus archive group of the most recent articles.
5784 Given a prefix, create a full group."
5786 (let ((group (gnus-group-prefixed-name
5787 (if all "ding.archives" "ding.recent") '(nndir ""))))
5788 (and (gnus-gethash group gnus-newsrc-hashtb)
5789 (error "Archive group already exists"))
5790 (gnus-group-make-group
5791 (gnus-group-real-name group)
5792 (list 'nndir (if all "hpc" "edu")
5793 (list 'nndir-directory
5794 (if all gnus-group-archive-directory
5795 gnus-group-recent-archive-directory))))))
5797 (defun gnus-group-make-directory-group (dir)
5798 "Create an nndir group.
5799 The user will be prompted for a directory. The contents of this
5800 directory will be used as a newsgroup. The directory should contain
5801 mail messages or news articles in files that have numeric names."
5803 (list (read-file-name "Create group from directory: ")))
5804 (or (file-exists-p dir) (error "No such directory"))
5805 (or (file-directory-p dir) (error "Not a directory"))
5809 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5811 (gnus-group-prefixed-name
5812 (concat (file-name-as-directory (directory-file-name dir))
5815 (setq ext (format "<%d>" (setq i (1+ i)))))
5816 (gnus-group-make-group
5817 (gnus-group-real-name group)
5818 (list 'nndir group (list 'nndir-directory dir)))))
5820 (defun gnus-group-make-kiboze-group (group address scores)
5821 "Create an nnkiboze group.
5822 The user will be prompted for a name, a regexp to match groups, and
5823 score file entries for articles to include in the group."
5826 (read-string "nnkiboze group name: ")
5827 (read-string "Source groups (regexp): ")
5828 (let ((headers (mapcar (lambda (group) (list group))
5829 '("subject" "from" "number" "date" "message-id"
5830 "references" "chars" "lines" "xref"
5831 "followup" "all" "body" "head")))
5832 scores header regexp regexps)
5833 (while (not (equal "" (setq header (completing-read
5834 "Match on header: " headers nil t))))
5836 (while (not (equal "" (setq regexp (read-string
5837 (format "Match on %s (string): "
5839 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5840 (setq scores (cons (cons header regexps) scores)))
5842 (gnus-group-make-group group "nnkiboze" address)
5843 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5844 (let (emacs-lisp-mode-hook)
5845 (pp scores (current-buffer)))))
5847 (defun gnus-group-add-to-virtual (n vgroup)
5848 "Add the current group to a virtual group."
5850 (list current-prefix-arg
5851 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5853 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5854 (error "%s is not an nnvirtual group" vgroup))
5855 (let* ((groups (gnus-group-process-prefix n))
5856 (method (gnus-info-method (gnus-get-info vgroup))))
5857 (setcar (cdr method)
5859 (nth 1 method) "\\|"
5862 (gnus-group-remove-mark s)
5863 (concat "\\(^" (regexp-quote s) "$\\)"))
5865 (gnus-group-position-point))
5867 (defun gnus-group-make-empty-virtual (group)
5868 "Create a new, fresh, empty virtual group."
5869 (interactive "sCreate new, empty virtual group: ")
5870 (let* ((method (list 'nnvirtual "^$"))
5871 (pgroup (gnus-group-prefixed-name group method)))
5872 ;; Check whether it exists already.
5873 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5874 (error "Group %s already exists." pgroup))
5875 ;; Subscribe the new group after the group on the current line.
5876 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5877 (gnus-group-update-group pgroup)
5879 (gnus-group-position-point)))
5881 (defun gnus-group-enter-directory (dir)
5882 "Enter an ephemeral nneething group."
5883 (interactive "DDirectory to read: ")
5884 (let* ((method (list 'nneething dir))
5885 (leaf (gnus-group-prefixed-name
5886 (file-name-nondirectory (directory-file-name dir))
5888 (name (gnus-generate-new-group-name leaf)))
5889 (let ((nneething-read-only t))
5890 (or (gnus-group-read-ephemeral-group
5892 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5894 (error "Couldn't enter %s" dir)))))
5896 ;; Group sorting commands
5897 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5899 (defun gnus-group-sort-groups (func &optional reverse)
5900 "Sort the group buffer according to FUNC.
5901 If REVERSE, reverse the sorting order."
5902 (interactive (list gnus-group-sort-function
5903 current-prefix-arg))
5905 ((not (listp func)) func)
5907 ((= 1 (length func)) (car func))
5909 ,(gnus-make-sort-function
5910 (reverse func)))))))
5911 ;; We peel off the dummy group from the alist.
5913 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5914 (pop gnus-newsrc-alist))
5916 (setq gnus-newsrc-alist
5917 (sort gnus-newsrc-alist func))
5919 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5920 ;; Regenerate the hash table.
5921 (gnus-make-hashtable-from-newsrc-alist)
5922 (gnus-group-list-groups))))
5924 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5925 "Sort the group buffer alphabetically by group name.
5926 If REVERSE, sort in reverse order."
5928 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5930 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5931 "Sort the group buffer by number of unread articles.
5932 If REVERSE, sort in reverse order."
5934 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5936 (defun gnus-group-sort-groups-by-level (&optional reverse)
5937 "Sort the group buffer by group level.
5938 If REVERSE, sort in reverse order."
5940 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5942 (defun gnus-group-sort-groups-by-score (&optional reverse)
5943 "Sort the group buffer by group score.
5944 If REVERSE, sort in reverse order."
5946 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5948 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5949 "Sort the group buffer by group rank.
5950 If REVERSE, sort in reverse order."
5952 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5954 (defun gnus-group-sort-groups-by-method (&optional reverse)
5955 "Sort the group buffer alphabetically by backend name.
5956 If REVERSE, sort in reverse order."
5958 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5960 (defun gnus-group-sort-by-alphabet (info1 info2)
5961 "Sort alphabetically."
5962 (string< (gnus-info-group info1) (gnus-info-group info2)))
5964 (defun gnus-group-sort-by-unread (info1 info2)
5965 "Sort by number of unread articles."
5966 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5967 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5968 (< (or (and (numberp n1) n1) 0)
5969 (or (and (numberp n2) n2) 0))))
5971 (defun gnus-group-sort-by-level (info1 info2)
5973 (< (gnus-info-level info1) (gnus-info-level info2)))
5975 (defun gnus-group-sort-by-method (info1 info2)
5976 "Sort alphabetically by backend name."
5977 (string< (symbol-name (car (gnus-find-method-for-group
5978 (gnus-info-group info1) info1)))
5979 (symbol-name (car (gnus-find-method-for-group
5980 (gnus-info-group info2) info2)))))
5982 (defun gnus-group-sort-by-score (info1 info2)
5983 "Sort by group score."
5984 (< (gnus-info-score info1) (gnus-info-score info2)))
5986 (defun gnus-group-sort-by-rank (info1 info2)
5987 "Sort by level and score."
5988 (let ((level1 (gnus-info-level info1))
5989 (level2 (gnus-info-level info2)))
5990 (or (< level1 level2)
5991 (and (= level1 level2)
5992 (> (gnus-info-score info1) (gnus-info-score info2))))))
5994 ;; Group catching up.
5996 (defun gnus-group-clear-data (n)
5997 "Clear all marks and read ranges from the current group."
5999 (let ((groups (gnus-group-process-prefix n))
6001 (while (setq group (pop groups))
6002 (setq info (gnus-get-info group))
6003 (gnus-info-set-read info nil)
6004 (when (gnus-info-marks info)
6005 (gnus-info-set-marks info nil))
6006 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6007 (when (gnus-group-goto-group group)
6008 (gnus-group-remove-mark group)
6009 (gnus-group-update-group-line)))))
6011 (defun gnus-group-catchup-current (&optional n all)
6012 "Mark all articles not marked as unread in current newsgroup as read.
6013 If prefix argument N is numeric, the ARG next newsgroups will be
6014 caught up. If ALL is non-nil, marked articles will also be marked as
6015 read. Cross references (Xref: header) of articles are ignored.
6016 The difference between N and actual number of newsgroups that were
6017 caught up is returned."
6019 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6023 "Do you really want to mark all articles as read? "
6024 "Mark all unread articles as read? "))))
6026 (let ((groups (gnus-group-process-prefix n))
6029 ;; Virtual groups have to be given special treatment.
6030 (let ((method (gnus-find-method-for-group (car groups))))
6031 (if (eq 'nnvirtual (car method))
6032 (nnvirtual-catchup-group
6033 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6034 (gnus-group-remove-mark (car groups))
6035 (if (>= (gnus-group-group-level) gnus-level-zombie)
6036 (gnus-message 2 "Dead groups can't be caught up")
6038 (gnus-group-goto-group (car groups))
6039 (gnus-group-catchup (car groups) all))
6040 (gnus-group-update-group-line)
6041 (setq ret (1+ ret))))
6042 (setq groups (cdr groups)))
6043 (gnus-group-next-unread-group 1)
6046 (defun gnus-group-catchup-current-all (&optional n)
6047 "Mark all articles in current newsgroup as read.
6048 Cross references (Xref: header) of articles are ignored."
6050 (gnus-group-catchup-current n 'all))
6052 (defun gnus-group-catchup (group &optional all)
6053 "Mark all articles in GROUP as read.
6054 If ALL is non-nil, all articles are marked as read.
6055 The return value is the number of articles that were marked as read,
6056 or nil if no action could be taken."
6057 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6059 ;; Do the updating only if the newsgroup isn't killed.
6060 (if (not (numberp (car entry)))
6061 (gnus-message 1 "Can't catch up; non-active group")
6062 ;; Do auto-expirable marks if that's required.
6063 (when (gnus-group-auto-expirable-p group)
6064 (gnus-add-marked-articles
6065 group 'expire (gnus-list-of-unread-articles group))
6067 (let ((marks (nth 3 (nth 2 entry))))
6068 (gnus-add-marked-articles
6069 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6070 (gnus-add-marked-articles
6071 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6073 (gnus-update-read-articles group nil)
6074 ;; Also nix out the lists of marks and dormants.
6076 (gnus-add-marked-articles group 'tick nil nil 'force)
6077 (gnus-add-marked-articles group 'dormant nil nil 'force))
6078 (run-hooks 'gnus-group-catchup-group-hook)
6081 (defun gnus-group-expire-articles (&optional n)
6082 "Expire all expirable articles in the current newsgroup."
6084 (let ((groups (gnus-group-process-prefix n))
6087 (error "No groups to expire"))
6088 (while (setq group (pop groups))
6089 (gnus-group-remove-mark group)
6090 (when (gnus-check-backend-function 'request-expire-articles group)
6091 (gnus-message 6 "Expiring articles in %s..." group)
6092 (let* ((info (gnus-get-info group))
6093 (expirable (if (gnus-group-total-expirable-p group)
6094 (cons nil (gnus-list-of-read-articles group))
6095 (assq 'expire (gnus-info-marks info))))
6096 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6100 (gnus-compress-sequence
6102 ;; We set the expiry variables to the groupp
6104 (let ((nnmail-expiry-wait-function nil)
6105 (nnmail-expiry-wait expiry-wait))
6106 (gnus-request-expire-articles
6107 (gnus-uncompress-sequence (cdr expirable)) group))
6108 ;; Just expire using the normal expiry values.
6109 (gnus-request-expire-articles
6110 (gnus-uncompress-sequence (cdr expirable)) group)))))
6111 (gnus-message 6 "Expiring articles in %s...done" group)))
6112 (gnus-group-position-point))))
6114 (defun gnus-group-expire-all-groups ()
6115 "Expire all expirable articles in all newsgroups."
6118 (gnus-message 5 "Expiring...")
6119 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6120 (cdr gnus-newsrc-alist))))
6121 (gnus-group-expire-articles nil)))
6122 (gnus-group-position-point)
6123 (gnus-message 5 "Expiring...done"))
6125 (defun gnus-group-set-current-level (n level)
6126 "Set the level of the next N groups to LEVEL."
6131 (let ((s (read-string
6132 (format "Level (default %s): "
6133 (or (gnus-group-group-level)
6134 gnus-level-default-subscribed)))))
6135 (if (string-match "^\\s-*$" s)
6136 (int-to-string (or (gnus-group-group-level)
6137 gnus-level-default-subscribed))
6139 (or (and (>= level 1) (<= level gnus-level-killed))
6140 (error "Illegal level: %d" level))
6141 (let ((groups (gnus-group-process-prefix n))
6143 (while (setq group (pop groups))
6144 (gnus-group-remove-mark group)
6145 (gnus-message 6 "Changed level of %s from %d to %d"
6146 group (or (gnus-group-group-level) gnus-level-killed)
6148 (gnus-group-change-level
6149 group level (or (gnus-group-group-level) gnus-level-killed))
6150 (gnus-group-update-group-line)))
6151 (gnus-group-position-point))
6153 (defun gnus-group-unsubscribe-current-group (&optional n)
6154 "Toggle subscription of the current group.
6155 If given numerical prefix, toggle the N next groups."
6157 (let ((groups (gnus-group-process-prefix n))
6160 (setq group (car groups)
6161 groups (cdr groups))
6162 (gnus-group-remove-mark group)
6163 (gnus-group-unsubscribe-group
6164 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6165 gnus-level-default-unsubscribed
6166 gnus-level-default-subscribed) t)
6167 (gnus-group-update-group-line))
6168 (gnus-group-next-group 1)))
6170 (defun gnus-group-unsubscribe-group (group &optional level silent)
6171 "Toggle subscription to GROUP.
6172 Killed newsgroups are subscribed. If SILENT, don't try to update the
6175 (list (completing-read
6176 "Group: " gnus-active-hashtb nil
6177 (gnus-read-active-file-p)
6179 'gnus-group-history)))
6180 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6182 ((string-match "^[ \t]$" group)
6183 (error "Empty group name"))
6185 ;; Toggle subscription flag.
6186 (gnus-group-change-level
6187 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6188 gnus-level-subscribed)
6189 (1+ gnus-level-subscribed)
6190 gnus-level-default-subscribed)))
6192 (gnus-group-update-group group)))
6193 ((and (stringp group)
6194 (or (not (gnus-read-active-file-p))
6195 (gnus-active group)))
6196 ;; Add new newsgroup.
6197 (gnus-group-change-level
6199 (if level level gnus-level-default-subscribed)
6200 (or (and (member group gnus-zombie-list)
6203 (and (gnus-group-group-name)
6204 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6206 (gnus-group-update-group group)))
6207 (t (error "No such newsgroup: %s" group)))
6208 (gnus-group-position-point)))
6210 (defun gnus-group-transpose-groups (n)
6211 "Move the current newsgroup up N places.
6212 If given a negative prefix, move down instead. The difference between
6213 N and the number of steps taken is returned."
6215 (or (gnus-group-group-name)
6216 (error "No group on current line"))
6217 (gnus-group-kill-group 1)
6219 (forward-line (- n))
6220 (gnus-group-yank-group)
6221 (gnus-group-position-point)))
6223 (defun gnus-group-kill-all-zombies ()
6224 "Kill all zombie newsgroups."
6226 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6227 (setq gnus-zombie-list nil)
6228 (gnus-group-list-groups))
6230 (defun gnus-group-kill-region (begin end)
6231 "Kill newsgroups in current region (excluding current point).
6232 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6247 (beginning-of-line) ;Important when LINES < 1
6248 (gnus-group-kill-group lines)))
6250 (defun gnus-group-kill-group (&optional n discard)
6251 "Kill the next N groups.
6252 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6253 However, only groups that were alive can be yanked; already killed
6254 groups or zombie groups can't be yanked.
6255 The return value is the name of the group that was killed, or a list
6258 (let ((buffer-read-only nil)
6259 (groups (gnus-group-process-prefix n))
6260 group entry level out)
6261 (if (< (length groups) 10)
6262 ;; This is faster when there are few groups.
6264 (push (setq group (pop groups)) out)
6265 (gnus-group-remove-mark group)
6266 (setq level (gnus-group-group-level))
6268 (when (and (not discard)
6269 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6270 (push (cons (car entry) (nth 2 entry))
6271 gnus-list-of-killed-groups))
6272 (gnus-group-change-level
6273 (if entry entry group) gnus-level-killed (if entry nil level)))
6274 ;; If there are lots and lots of groups to be killed, we use
6275 ;; this thing instead.
6277 (setq groups (nreverse groups))
6279 (gnus-group-remove-mark (setq group (pop groups)))
6282 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6283 (push (cons (car entry) (nth 2 entry))
6284 gnus-list-of-killed-groups)
6285 (setcdr (cdr entry) (cdddr entry)))
6286 ((member group gnus-zombie-list)
6287 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6288 (gnus-make-hashtable-from-newsrc-alist)))
6290 (gnus-group-position-point)
6291 (if (< (length out) 2) (car out) (nreverse out))))
6293 (defun gnus-group-yank-group (&optional arg)
6294 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6295 inserting it before the current newsgroup. The numeric ARG specifies
6296 how many newsgroups are to be yanked. The name of the newsgroup yanked
6297 is returned, or (if several groups are yanked) a list of yanked groups
6300 (setq arg (or arg 1))
6301 (let (info group prev out)
6302 (while (>= (decf arg) 0)
6303 (if (not (setq info (pop gnus-list-of-killed-groups)))
6304 (error "No more newsgroups to yank"))
6305 (push (setq group (nth 1 info)) out)
6306 ;; Find which newsgroup to insert this one before - search
6307 ;; backward until something suitable is found. If there are no
6308 ;; other newsgroups in this buffer, just make this newsgroup the
6310 (setq prev (gnus-group-group-name))
6311 (gnus-group-change-level
6312 info (gnus-info-level (cdr info)) gnus-level-killed
6313 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6315 (gnus-group-insert-group-line-info group))
6317 (gnus-group-position-point)
6318 (if (< (length out) 2) (car out) (nreverse out))))
6320 (defun gnus-group-kill-level (level)
6321 "Kill all groups that is on a certain LEVEL."
6322 (interactive "nKill all groups on level: ")
6324 ((= level gnus-level-zombie)
6325 (setq gnus-killed-list
6326 (nconc gnus-zombie-list gnus-killed-list))
6327 (setq gnus-zombie-list nil))
6328 ((and (< level gnus-level-zombie)
6330 (or gnus-expert-user
6333 "Do you really want to kill all groups on level %d? "
6335 (let* ((prev gnus-newsrc-alist)
6338 (if (= (gnus-info-level level) level)
6339 (setcdr prev (cdr alist))
6341 (setq alist (cdr alist)))
6342 (gnus-make-hashtable-from-newsrc-alist)
6343 (gnus-group-list-groups)))
6345 (error "Can't kill; illegal level: %d" level))))
6347 (defun gnus-group-list-all-groups (&optional arg)
6348 "List all newsgroups with level ARG or lower.
6349 Default is gnus-level-unsubscribed, which lists all subscribed and most
6350 unsubscribed groups."
6352 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6354 ;; Redefine this to list ALL killed groups if prefix arg used.
6355 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6356 (defun gnus-group-list-killed (&optional arg)
6357 "List all killed newsgroups in the group buffer.
6358 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6359 entail asking the server for the groups."
6361 ;; Find all possible killed newsgroups if arg.
6363 (gnus-get-killed-groups))
6364 (if (not gnus-killed-list)
6365 (gnus-message 6 "No killed groups")
6366 (let (gnus-group-list-mode)
6367 (funcall gnus-group-prepare-function
6368 gnus-level-killed t gnus-level-killed))
6369 (goto-char (point-min)))
6370 (gnus-group-position-point))
6372 (defun gnus-group-list-zombies ()
6373 "List all zombie newsgroups in the group buffer."
6375 (if (not gnus-zombie-list)
6376 (gnus-message 6 "No zombie groups")
6377 (let (gnus-group-list-mode)
6378 (funcall gnus-group-prepare-function
6379 gnus-level-zombie t gnus-level-zombie))
6380 (goto-char (point-min)))
6381 (gnus-group-position-point))
6383 (defun gnus-group-list-active ()
6384 "List all groups that are available from the server(s)."
6386 ;; First we make sure that we have really read the active file.
6387 (unless (gnus-read-active-file-p)
6388 (let ((gnus-read-active-file t))
6389 (gnus-read-active-file)))
6390 ;; Find all groups and sort them.
6398 (setq list (cons (symbol-name sym) list))))
6402 (buffer-read-only nil))
6405 (gnus-group-insert-group-line-info (pop groups)))
6406 (goto-char (point-min))))
6408 (defun gnus-activate-all-groups (level)
6409 "Activate absolutely all groups."
6410 (interactive (list 7))
6411 (let ((gnus-activate-level level)
6412 (gnus-activate-foreign-newsgroups level))
6413 (gnus-group-get-new-news)))
6415 (defun gnus-group-get-new-news (&optional arg)
6416 "Get newly arrived articles.
6417 If ARG is a number, it specifies which levels you are interested in
6418 re-scanning. If ARG is non-nil and not a number, this will force
6419 \"hard\" re-reading of the active files from all servers."
6421 (run-hooks 'gnus-get-new-news-hook)
6422 ;; We might read in new NoCeM messages here.
6423 (when (and gnus-use-nocem
6425 (gnus-nocem-scan-groups))
6426 ;; If ARG is not a number, then we read the active file.
6427 (when (and arg (not (numberp arg)))
6428 (let ((gnus-read-active-file t))
6429 (gnus-read-active-file))
6432 (setq arg (gnus-group-default-level arg t))
6433 (if (and gnus-read-active-file (not arg))
6435 (gnus-read-active-file)
6436 (gnus-get-unread-articles arg))
6437 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6438 (gnus-get-unread-articles arg)))
6439 (run-hooks 'gnus-after-getting-new-news-hook)
6440 (gnus-group-list-groups))
6442 (defun gnus-group-get-new-news-this-group (&optional n)
6443 "Check for newly arrived news in the current group (and the N-1 next groups).
6444 The difference between N and the number of newsgroup checked is returned.
6445 If N is negative, this group and the N-1 previous groups will be checked."
6447 (let* ((groups (gnus-group-process-prefix n))
6448 (ret (if (numberp n) (- n (length groups)) 0))
6449 (beg (unless n (point)))
6451 (while (setq group (pop groups))
6452 (gnus-group-remove-mark group)
6453 (if (gnus-activate-group group 'scan)
6455 (gnus-get-unread-articles-in-group
6456 (gnus-get-info group) (gnus-active group) t)
6457 (unless (gnus-virtual-group-p group)
6458 (gnus-close-group group))
6459 (gnus-group-update-group group))
6460 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6461 (when beg (goto-char beg))
6462 (when gnus-goto-next-group-when-activating
6463 (gnus-group-next-unread-group 1 t))
6464 (gnus-summary-position-point)
6467 (defun gnus-group-fetch-faq (group &optional faq-dir)
6468 "Fetch the FAQ for the current group."
6471 (gnus-group-real-name (gnus-group-group-name))
6472 (cond (current-prefix-arg
6474 "Faq dir: " (and (listp gnus-group-faq-directory)
6475 gnus-group-faq-directory))))))
6477 (setq faq-dir (if (listp gnus-group-faq-directory)
6478 (car gnus-group-faq-directory)
6479 gnus-group-faq-directory)))
6480 (or group (error "No group name given"))
6481 (let ((file (concat (file-name-as-directory faq-dir)
6482 (gnus-group-real-name group))))
6483 (if (not (file-exists-p file))
6484 (error "No such file: %s" file)
6487 (defun gnus-group-describe-group (force &optional group)
6488 "Display a description of the current newsgroup."
6489 (interactive (list current-prefix-arg (gnus-group-group-name)))
6490 (and force (setq gnus-description-hashtb nil))
6491 (let ((method (gnus-find-method-for-group group))
6493 (or group (error "No group name given"))
6494 (and (or (and gnus-description-hashtb
6495 ;; We check whether this group's method has been
6496 ;; queried for a description file.
6498 (gnus-group-prefixed-name "" method)
6499 gnus-description-hashtb))
6500 (setq desc (gnus-group-get-description group))
6501 (gnus-read-descriptions-file method))
6503 (or desc (gnus-gethash group gnus-description-hashtb)
6504 "No description available")))))
6506 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6507 (defun gnus-group-describe-all-groups (&optional force)
6508 "Pop up a buffer with descriptions of all newsgroups."
6510 (and force (setq gnus-description-hashtb nil))
6511 (if (not (or gnus-description-hashtb
6512 (gnus-read-all-descriptions-files)))
6513 (error "Couldn't request descriptions file"))
6514 (let ((buffer-read-only nil)
6520 (insert (format " *: %-20s %s\n" (symbol-name group)
6521 (symbol-value group)))
6522 (gnus-add-text-properties
6523 b (1+ b) (list 'gnus-group group
6524 'gnus-unread t 'gnus-marked nil
6525 'gnus-level (1+ gnus-level-subscribed))))
6526 gnus-description-hashtb)
6527 (goto-char (point-min))
6528 (gnus-group-position-point)))
6530 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6531 (defun gnus-group-apropos (regexp &optional search-description)
6532 "List all newsgroups that have names that match a regexp."
6533 (interactive "sGnus apropos (regexp): ")
6535 (obuf (current-buffer))
6537 ;; Go through all newsgroups that are known to Gnus.
6540 (and (symbol-name group)
6541 (string-match regexp (symbol-name group))
6542 (setq groups (cons (symbol-name group) groups))))
6544 ;; Also go through all descriptions that are known to Gnus.
6545 (when search-description
6548 (and (string-match regexp (symbol-value group))
6549 (gnus-active (symbol-name group))
6550 (setq groups (cons (symbol-name group) groups))))
6551 gnus-description-hashtb))
6553 (gnus-message 3 "No groups matched \"%s\"." regexp)
6554 ;; Print out all the groups.
6556 (pop-to-buffer "*Gnus Help*")
6557 (buffer-disable-undo (current-buffer))
6559 (setq groups (sort groups 'string<))
6561 ;; Groups may be entered twice into the list of groups.
6562 (if (not (string= (car groups) prev))
6564 (insert (setq prev (car groups)) "\n")
6565 (if (and gnus-description-hashtb
6566 (setq des (gnus-gethash (car groups)
6567 gnus-description-hashtb)))
6568 (insert " " des "\n"))))
6569 (setq groups (cdr groups)))
6570 (goto-char (point-min))))
6571 (pop-to-buffer obuf)))
6573 (defun gnus-group-description-apropos (regexp)
6574 "List all newsgroups that have names or descriptions that match a regexp."
6575 (interactive "sGnus description apropos (regexp): ")
6576 (if (not (or gnus-description-hashtb
6577 (gnus-read-all-descriptions-files)))
6578 (error "Couldn't request descriptions file"))
6579 (gnus-group-apropos regexp t))
6581 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6582 (defun gnus-group-list-matching (level regexp &optional all lowest)
6583 "List all groups with unread articles that match REGEXP.
6584 If the prefix LEVEL is non-nil, it should be a number that says which
6585 level to cut off listing groups.
6586 If ALL, also list groups with no unread articles.
6587 If LOWEST, don't list groups with level lower than LOWEST.
6589 This command may read the active file."
6590 (interactive "P\nsList newsgroups matching: ")
6591 ;; First make sure active file has been read.
6593 (>= (prefix-numeric-value level) gnus-level-killed))
6594 (gnus-get-killed-groups))
6595 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6596 all (or lowest 1) regexp)
6597 (goto-char (point-min))
6598 (gnus-group-position-point))
6600 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6601 "List all groups that match REGEXP.
6602 If the prefix LEVEL is non-nil, it should be a number that says which
6603 level to cut off listing groups.
6604 If LOWEST, don't list groups with level lower than LOWEST."
6605 (interactive "P\nsList newsgroups matching: ")
6606 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6608 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6609 (defun gnus-group-save-newsrc (&optional force)
6610 "Save the Gnus startup files.
6611 If FORCE, force saving whether it is necessary or not."
6613 (gnus-save-newsrc-file force))
6615 (defun gnus-group-restart (&optional arg)
6616 "Force Gnus to read the .newsrc file."
6618 (when (gnus-yes-or-no-p
6619 (format "Are you sure you want to read %s? "
6620 gnus-current-startup-file))
6621 (gnus-save-newsrc-file)
6622 (gnus-setup-news 'force)
6623 (gnus-group-list-groups arg)))
6625 (defun gnus-group-read-init-file ()
6626 "Read the Gnus elisp init file."
6628 (gnus-read-init-file))
6630 (defun gnus-group-check-bogus-groups (&optional silent)
6631 "Check bogus newsgroups.
6632 If given a prefix, don't ask for confirmation before removing a bogus
6635 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6636 (gnus-group-list-groups))
6638 (defun gnus-group-edit-global-kill (&optional article group)
6639 "Edit the global kill file.
6640 If GROUP, edit that local kill file instead."
6642 (setq gnus-current-kill-article article)
6643 (gnus-kill-file-edit-file group)
6646 (substitute-command-keys
6647 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6648 (if group "local" "global")))))
6650 (defun gnus-group-edit-local-kill (article group)
6651 "Edit a local kill file."
6652 (interactive (list nil (gnus-group-group-name)))
6653 (gnus-group-edit-global-kill article group))
6655 (defun gnus-group-force-update ()
6656 "Update `.newsrc' file."
6658 (gnus-save-newsrc-file))
6660 (defun gnus-group-suspend ()
6661 "Suspend the current Gnus session.
6662 In fact, cleanup buffers except for group mode buffer.
6663 The hook gnus-suspend-gnus-hook is called before actually suspending."
6665 (run-hooks 'gnus-suspend-gnus-hook)
6666 ;; Kill Gnus buffers except for group mode buffer.
6667 (let ((group-buf (get-buffer gnus-group-buffer)))
6668 ;; Do this on a separate list in case the user does a ^G before we finish
6669 (let ((gnus-buffer-list
6670 (delq group-buf (delq gnus-dribble-buffer
6671 (append gnus-buffer-list nil)))))
6672 (while gnus-buffer-list
6673 (gnus-kill-buffer (car gnus-buffer-list))
6674 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6677 (setq gnus-buffer-list (list group-buf))
6678 (bury-buffer group-buf)
6679 (delete-windows-on group-buf t)))))
6681 (defun gnus-group-clear-dribble ()
6682 "Clear all information from the dribble buffer."
6684 (gnus-dribble-clear)
6685 (gnus-message 7 "Cleared dribble buffer"))
6687 (defun gnus-group-exit ()
6688 "Quit reading news after updating .newsrc.eld and .newsrc.
6689 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6692 (or noninteractive ;For gnus-batch-kill
6693 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6694 (not gnus-interactive-exit) ;Without confirmation
6696 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6697 (run-hooks 'gnus-exit-gnus-hook)
6698 ;; Offer to save data from non-quitted summary buffers.
6699 (gnus-offer-save-summaries)
6700 ;; Save the newsrc file(s).
6701 (gnus-save-newsrc-file)
6703 (gnus-close-backends)
6704 ;; Reset everything.
6706 ;; Allow the user to do things after cleaning up.
6707 (run-hooks 'gnus-after-exiting-gnus-hook)))
6709 (defun gnus-close-backends ()
6710 ;; Send a close request to all backends that support such a request.
6711 (let ((methods gnus-valid-select-methods)
6714 (if (fboundp (setq func (intern (concat (caar methods)
6715 "-request-close"))))
6717 (setq methods (cdr methods)))))
6719 (defun gnus-group-quit ()
6720 "Quit reading news without updating .newsrc.eld or .newsrc.
6721 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6723 (when (or noninteractive ;For gnus-batch-kill
6724 (zerop (buffer-size))
6725 (not (gnus-server-opened gnus-select-method))
6727 (not gnus-current-startup-file)
6729 (format "Quit reading news without saving %s? "
6730 (file-name-nondirectory gnus-current-startup-file))))
6731 (run-hooks 'gnus-exit-gnus-hook)
6732 (if gnus-use-full-window
6733 (delete-other-windows)
6734 (gnus-remove-some-windows))
6736 (gnus-close-backends)
6738 ;; Allow the user to do things after cleaning up.
6739 (run-hooks 'gnus-after-exiting-gnus-hook)))
6741 (defun gnus-offer-save-summaries ()
6742 "Offer to save all active summary buffers."
6744 (let ((buflist (buffer-list))
6746 ;; Go through all buffers and find all summaries.
6748 (and (setq bufname (buffer-name (car buflist)))
6749 (string-match "Summary" bufname)
6751 (set-buffer bufname)
6752 ;; We check that this is, indeed, a summary buffer.
6753 (and (eq major-mode 'gnus-summary-mode)
6754 ;; Also make sure this isn't bogus.
6755 gnus-newsgroup-prepared))
6756 (push bufname buffers))
6757 (setq buflist (cdr buflist)))
6758 ;; Go through all these summary buffers and offer to save them.
6761 "Update summary buffer %s? "
6762 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6765 (defun gnus-group-describe-briefly ()
6766 "Give a one line description of the group mode commands."
6768 (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")))
6770 (defun gnus-group-browse-foreign-server (method)
6771 "Browse a foreign news server.
6772 If called interactively, this function will ask for a select method
6773 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6774 If not, METHOD should be a list where the first element is the method
6775 and the second element is the address."
6777 (list (let ((how (completing-read
6779 (append gnus-valid-select-methods gnus-server-alist)
6780 nil t (cons "nntp" 0) 'gnus-method-history)))
6781 ;; We either got a backend name or a virtual server name.
6782 ;; If the first, we also need an address.
6783 (if (assoc how gnus-valid-select-methods)
6785 ;; Suggested by mapjph@bath.ac.uk.
6788 (mapcar (lambda (server) (list server))
6789 gnus-secondary-servers)))
6790 ;; We got a server name, so we find the method.
6791 (gnus-server-to-method how)))))
6792 (gnus-browse-foreign-server method))
6796 ;;; Gnus summary mode
6799 (defvar gnus-summary-mode-map nil)
6801 (put 'gnus-summary-mode 'mode-class 'special)
6803 (unless gnus-summary-mode-map
6804 (setq gnus-summary-mode-map (make-keymap))
6805 (suppress-keymap gnus-summary-mode-map)
6807 ;; Non-orthogonal keys
6809 (gnus-define-keys gnus-summary-mode-map
6810 " " gnus-summary-next-page
6811 "\177" gnus-summary-prev-page
6812 [delete] gnus-summary-prev-page
6813 "\r" gnus-summary-scroll-up
6814 "n" gnus-summary-next-unread-article
6815 "p" gnus-summary-prev-unread-article
6816 "N" gnus-summary-next-article
6817 "P" gnus-summary-prev-article
6818 "\M-\C-n" gnus-summary-next-same-subject
6819 "\M-\C-p" gnus-summary-prev-same-subject
6820 "\M-n" gnus-summary-next-unread-subject
6821 "\M-p" gnus-summary-prev-unread-subject
6822 "." gnus-summary-first-unread-article
6823 "," gnus-summary-best-unread-article
6824 "\M-s" gnus-summary-search-article-forward
6825 "\M-r" gnus-summary-search-article-backward
6826 "<" gnus-summary-beginning-of-article
6827 ">" gnus-summary-end-of-article
6828 "j" gnus-summary-goto-article
6829 "^" gnus-summary-refer-parent-article
6830 "\M-^" gnus-summary-refer-article
6831 "u" gnus-summary-tick-article-forward
6832 "!" gnus-summary-tick-article-forward
6833 "U" gnus-summary-tick-article-backward
6834 "d" gnus-summary-mark-as-read-forward
6835 "D" gnus-summary-mark-as-read-backward
6836 "E" gnus-summary-mark-as-expirable
6837 "\M-u" gnus-summary-clear-mark-forward
6838 "\M-U" gnus-summary-clear-mark-backward
6839 "k" gnus-summary-kill-same-subject-and-select
6840 "\C-k" gnus-summary-kill-same-subject
6841 "\M-\C-k" gnus-summary-kill-thread
6842 "\M-\C-l" gnus-summary-lower-thread
6843 "e" gnus-summary-edit-article
6844 "#" gnus-summary-mark-as-processable
6845 "\M-#" gnus-summary-unmark-as-processable
6846 "\M-\C-t" gnus-summary-toggle-threads
6847 "\M-\C-s" gnus-summary-show-thread
6848 "\M-\C-h" gnus-summary-hide-thread
6849 "\M-\C-f" gnus-summary-next-thread
6850 "\M-\C-b" gnus-summary-prev-thread
6851 "\M-\C-u" gnus-summary-up-thread
6852 "\M-\C-d" gnus-summary-down-thread
6853 "&" gnus-summary-execute-command
6854 "c" gnus-summary-catchup-and-exit
6855 "\C-w" gnus-summary-mark-region-as-read
6856 "\C-t" gnus-summary-toggle-truncation
6857 "?" gnus-summary-mark-as-dormant
6858 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6859 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6860 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6861 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6862 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6863 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6864 "=" gnus-summary-expand-window
6865 "\C-x\C-s" gnus-summary-reselect-current-group
6866 "\M-g" gnus-summary-rescan-group
6867 "w" gnus-summary-stop-page-breaking
6868 "\C-c\C-r" gnus-summary-caesar-message
6869 "\M-t" gnus-summary-toggle-mime
6870 "f" gnus-summary-followup
6871 "F" gnus-summary-followup-with-original
6872 "C" gnus-summary-cancel-article
6873 "r" gnus-summary-reply
6874 "R" gnus-summary-reply-with-original
6875 "\C-c\C-f" gnus-summary-mail-forward
6876 "o" gnus-summary-save-article
6877 "\C-o" gnus-summary-save-article-mail
6878 "|" gnus-summary-pipe-output
6879 "\M-k" gnus-summary-edit-local-kill
6880 "\M-K" gnus-summary-edit-global-kill
6882 "\C-c\C-d" gnus-summary-describe-group
6883 "q" gnus-summary-exit
6884 "Q" gnus-summary-exit-no-update
6885 "\C-c\C-i" gnus-info-find-node
6886 gnus-mouse-2 gnus-mouse-pick-article
6887 "m" gnus-summary-mail-other-window
6888 "a" gnus-summary-post-news
6889 "x" gnus-summary-limit-to-unread
6890 "s" gnus-summary-isearch-article
6891 "t" gnus-article-hide-headers
6892 "g" gnus-summary-show-article
6893 "l" gnus-summary-goto-last-article
6894 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6895 "\C-d" gnus-summary-enter-digest-group
6897 "*" gnus-cache-enter-article
6898 "\M-*" gnus-cache-remove-article
6899 "\M-&" gnus-summary-universal-argument
6900 "\C-l" gnus-recenter
6901 "I" gnus-summary-increase-score
6902 "L" gnus-summary-lower-score
6904 "V" gnus-summary-score-map
6905 "X" gnus-uu-extract-map
6906 "S" gnus-summary-send-map)
6908 ;; Sort of orthogonal keymap
6909 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6910 "t" gnus-summary-tick-article-forward
6911 "!" gnus-summary-tick-article-forward
6912 "d" gnus-summary-mark-as-read-forward
6913 "r" gnus-summary-mark-as-read-forward
6914 "c" gnus-summary-clear-mark-forward
6915 " " gnus-summary-clear-mark-forward
6916 "e" gnus-summary-mark-as-expirable
6917 "x" gnus-summary-mark-as-expirable
6918 "?" gnus-summary-mark-as-dormant
6919 "b" gnus-summary-set-bookmark
6920 "B" gnus-summary-remove-bookmark
6921 "#" gnus-summary-mark-as-processable
6922 "\M-#" gnus-summary-unmark-as-processable
6923 "S" gnus-summary-limit-include-expunged
6924 "C" gnus-summary-catchup
6925 "H" gnus-summary-catchup-to-here
6926 "\C-c" gnus-summary-catchup-all
6927 "k" gnus-summary-kill-same-subject-and-select
6928 "K" gnus-summary-kill-same-subject
6929 "P" gnus-uu-mark-map)
6931 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6932 "c" gnus-summary-clear-above
6933 "u" gnus-summary-tick-above
6934 "m" gnus-summary-mark-above
6935 "k" gnus-summary-kill-below)
6937 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6938 "/" gnus-summary-limit-to-subject
6939 "n" gnus-summary-limit-to-articles
6940 "w" gnus-summary-pop-limit
6941 "s" gnus-summary-limit-to-subject
6942 "a" gnus-summary-limit-to-author
6943 "u" gnus-summary-limit-to-unread
6944 "m" gnus-summary-limit-to-marks
6945 "v" gnus-summary-limit-to-score
6946 "D" gnus-summary-limit-include-dormant
6947 "d" gnus-summary-limit-exclude-dormant
6948 ;; "t" gnus-summary-limit-exclude-thread
6949 "E" gnus-summary-limit-include-expunged
6950 "c" gnus-summary-limit-exclude-childless-dormant
6951 "C" gnus-summary-limit-mark-excluded-as-read)
6953 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6954 "n" gnus-summary-next-unread-article
6955 "p" gnus-summary-prev-unread-article
6956 "N" gnus-summary-next-article
6957 "P" gnus-summary-prev-article
6958 "\C-n" gnus-summary-next-same-subject
6959 "\C-p" gnus-summary-prev-same-subject
6960 "\M-n" gnus-summary-next-unread-subject
6961 "\M-p" gnus-summary-prev-unread-subject
6962 "f" gnus-summary-first-unread-article
6963 "b" gnus-summary-best-unread-article
6964 "j" gnus-summary-goto-article
6965 "g" gnus-summary-goto-subject
6966 "l" gnus-summary-goto-last-article
6967 "p" gnus-summary-pop-article)
6969 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6970 "k" gnus-summary-kill-thread
6971 "l" gnus-summary-lower-thread
6972 "i" gnus-summary-raise-thread
6973 "T" gnus-summary-toggle-threads
6974 "t" gnus-summary-rethread-current
6975 "^" gnus-summary-reparent-thread
6976 "s" gnus-summary-show-thread
6977 "S" gnus-summary-show-all-threads
6978 "h" gnus-summary-hide-thread
6979 "H" gnus-summary-hide-all-threads
6980 "n" gnus-summary-next-thread
6981 "p" gnus-summary-prev-thread
6982 "u" gnus-summary-up-thread
6983 "o" gnus-summary-top-thread
6984 "d" gnus-summary-down-thread
6985 "#" gnus-uu-mark-thread
6986 "\M-#" gnus-uu-unmark-thread)
6988 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6989 "c" gnus-summary-catchup-and-exit
6990 "C" gnus-summary-catchup-all-and-exit
6991 "E" gnus-summary-exit-no-update
6992 "Q" gnus-summary-exit
6993 "Z" gnus-summary-exit
6994 "n" gnus-summary-catchup-and-goto-next-group
6995 "R" gnus-summary-reselect-current-group
6996 "G" gnus-summary-rescan-group
6997 "N" gnus-summary-next-group
6998 "P" gnus-summary-prev-group)
7000 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7001 " " gnus-summary-next-page
7002 "n" gnus-summary-next-page
7003 "\177" gnus-summary-prev-page
7004 [delete] gnus-summary-prev-page
7005 "p" gnus-summary-prev-page
7006 "\r" gnus-summary-scroll-up
7007 "<" gnus-summary-beginning-of-article
7008 ">" gnus-summary-end-of-article
7009 "b" gnus-summary-beginning-of-article
7010 "e" gnus-summary-end-of-article
7011 "^" gnus-summary-refer-parent-article
7012 "r" gnus-summary-refer-parent-article
7013 "R" gnus-summary-refer-references
7014 "g" gnus-summary-show-article
7015 "s" gnus-summary-isearch-article)
7017 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7018 "b" gnus-article-add-buttons
7019 "B" gnus-article-add-buttons-to-head
7020 "o" gnus-article-treat-overstrike
7021 ;; "w" gnus-article-word-wrap
7022 "w" gnus-article-fill-cited-article
7023 "c" gnus-article-remove-cr
7024 "L" gnus-article-remove-trailing-blank-lines
7025 "q" gnus-article-de-quoted-unreadable
7026 "f" gnus-article-display-x-face
7027 "l" gnus-summary-stop-page-breaking
7028 "r" gnus-summary-caesar-message
7029 "t" gnus-article-hide-headers
7030 "v" gnus-summary-verbose-headers
7031 "m" gnus-summary-toggle-mime)
7033 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7034 "a" gnus-article-hide
7035 "h" gnus-article-hide-headers
7036 "b" gnus-article-hide-boring-headers
7037 "s" gnus-article-hide-signature
7038 "c" gnus-article-hide-citation
7039 "p" gnus-article-hide-pgp
7040 "\C-c" gnus-article-hide-citation-maybe)
7042 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7043 "a" gnus-article-highlight
7044 "h" gnus-article-highlight-headers
7045 "c" gnus-article-highlight-citation
7046 "s" gnus-article-highlight-signature)
7048 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7049 "z" gnus-article-date-ut
7050 "u" gnus-article-date-ut
7051 "l" gnus-article-date-local
7052 "e" gnus-article-date-lapsed
7053 "o" gnus-article-date-original)
7055 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7057 "f" gnus-summary-fetch-faq
7058 "d" gnus-summary-describe-group
7059 "h" gnus-summary-describe-briefly
7060 "i" gnus-info-find-node)
7062 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7063 "e" gnus-summary-expire-articles
7064 "\M-\C-e" gnus-summary-expire-articles-now
7065 "\177" gnus-summary-delete-article
7066 [delete] gnus-summary-delete-article
7067 "m" gnus-summary-move-article
7068 "r" gnus-summary-respool-article
7069 "w" gnus-summary-edit-article
7070 "c" gnus-summary-copy-article
7071 "B" gnus-summary-crosspost-article
7072 "q" gnus-summary-respool-query
7073 "i" gnus-summary-import-article)
7075 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7076 "o" gnus-summary-save-article
7077 "m" gnus-summary-save-article-mail
7078 "r" gnus-summary-save-article-rmail
7079 "f" gnus-summary-save-article-file
7080 "b" gnus-summary-save-article-body-file
7081 "h" gnus-summary-save-article-folder
7082 "v" gnus-summary-save-article-vm
7083 "p" gnus-summary-pipe-output
7084 "s" gnus-soup-add-article)
7089 (defun gnus-summary-mode (&optional group)
7090 "Major mode for reading articles.
7092 All normal editing commands are switched off.
7093 \\<gnus-summary-mode-map>
7094 Each line in this buffer represents one article. To read an
7095 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7096 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7099 You can also post articles and send mail from this buffer. To
7100 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7101 of an article, type `\\[gnus-summary-reply]'.
7103 There are approx. one gazillion commands you can execute in this
7104 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7106 The following commands are available:
7108 \\{gnus-summary-mode-map}"
7110 (when (and menu-bar-mode
7111 (gnus-visual-p 'summary-menu 'menu))
7112 (gnus-summary-make-menu-bar))
7113 (kill-all-local-variables)
7114 (let ((locals gnus-summary-local-variables))
7116 (if (consp (car locals))
7118 (make-local-variable (caar locals))
7119 (set (caar locals) (eval (cdar locals))))
7120 (make-local-variable (car locals))
7121 (set (car locals) nil))
7122 (setq locals (cdr locals))))
7123 (gnus-make-thread-indent-array)
7124 (gnus-simplify-mode-line)
7125 (setq major-mode 'gnus-summary-mode)
7126 (setq mode-name "Summary")
7127 (make-local-variable 'minor-mode-alist)
7128 (use-local-map gnus-summary-mode-map)
7129 (buffer-disable-undo (current-buffer))
7130 (setq buffer-read-only t) ;Disable modification
7131 (setq truncate-lines t)
7132 (setq selective-display t)
7133 (setq selective-display-ellipses t) ;Display `...'
7134 (setq buffer-display-table gnus-summary-display-table)
7135 (setq gnus-newsgroup-name group)
7136 (make-local-variable 'gnus-summary-line-format)
7137 (make-local-variable 'gnus-summary-line-format-spec)
7138 (make-local-variable 'gnus-summary-mark-positions)
7139 (run-hooks 'gnus-summary-mode-hook))
7141 (defun gnus-summary-make-display-table ()
7142 ;; Change the display table. Odd characters have a tendency to mess
7143 ;; up nicely formatted displays - we make all possible glyphs
7144 ;; display only a single character.
7146 ;; We start from the standard display table, if any.
7147 (setq gnus-summary-display-table
7148 (or (copy-sequence standard-display-table)
7149 (make-display-table)))
7150 ;; Nix out all the control chars...
7152 (while (>= (setq i (1- i)) 0)
7153 (aset gnus-summary-display-table i [??])))
7154 ;; ... but not newline and cr, of course. (cr is necessary for the
7155 ;; selective display).
7156 (aset gnus-summary-display-table ?\n nil)
7157 (aset gnus-summary-display-table ?\r nil)
7158 ;; We nix out any glyphs over 126 that are not set already.
7160 (while (>= (setq i (1- i)) 127)
7161 ;; Only modify if the entry is nil.
7162 (or (aref gnus-summary-display-table i)
7163 (aset gnus-summary-display-table i [??])))))
7165 (defun gnus-summary-clear-local-variables ()
7166 (let ((locals gnus-summary-local-variables))
7168 (if (consp (car locals))
7169 (and (vectorp (caar locals))
7170 (set (caar locals) nil))
7171 (and (vectorp (car locals))
7172 (set (car locals) nil)))
7173 (setq locals (cdr locals)))))
7175 ;; Summary data functions.
7177 (defmacro gnus-data-number (data)
7180 (defmacro gnus-data-set-number (data number)
7181 `(setcar ,data ,number))
7183 (defmacro gnus-data-mark (data)
7186 (defmacro gnus-data-set-mark (data mark)
7187 `(setcar (nthcdr 1 ,data) ,mark))
7189 (defmacro gnus-data-pos (data)
7192 (defmacro gnus-data-set-pos (data pos)
7193 `(setcar (nthcdr 2 ,data) ,pos))
7195 (defmacro gnus-data-header (data)
7198 (defmacro gnus-data-level (data)
7201 (defmacro gnus-data-unread-p (data)
7202 `(= (nth 1 ,data) gnus-unread-mark))
7204 (defmacro gnus-data-pseudo-p (data)
7205 `(consp (nth 3 ,data)))
7207 (defmacro gnus-data-find (number)
7208 `(assq ,number gnus-newsgroup-data))
7210 (defmacro gnus-data-find-list (number &optional data)
7211 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7212 (memq (assq ,number bdata)
7215 (defmacro gnus-data-make (number mark pos header level)
7216 `(list ,number ,mark ,pos ,header ,level))
7218 (defun gnus-data-enter (after-article number mark pos header level offset)
7219 (let ((data (gnus-data-find-list after-article)))
7220 (or data (error "No such article: %d" after-article))
7221 (setcdr data (cons (gnus-data-make number mark pos header level)
7223 (setq gnus-newsgroup-data-reverse nil)
7224 (gnus-data-update-list (cddr data) offset)))
7226 (defun gnus-data-enter-list (after-article list &optional offset)
7228 (let ((data (and after-article (gnus-data-find-list after-article)))
7230 (or data (not after-article) (error "No such article: %d" after-article))
7231 ;; Find the last element in the list to be spliced into the main
7234 (setq list (cdr list)))
7237 (setcdr list gnus-newsgroup-data)
7238 (setq gnus-newsgroup-data ilist)
7239 (and offset (gnus-data-update-list (cdr list) offset)))
7240 (setcdr list (cdr data))
7242 (and offset (gnus-data-update-list (cdr data) offset)))
7243 (setq gnus-newsgroup-data-reverse nil))))
7245 (defun gnus-data-remove (article &optional offset)
7246 (let ((data gnus-newsgroup-data))
7247 (if (= (gnus-data-number (car data)) article)
7248 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7249 gnus-newsgroup-data-reverse nil)
7251 (and (= (gnus-data-number (cadr data)) article)
7253 (setcdr data (cddr data))
7254 (and offset (gnus-data-update-list (cdr data) offset))
7256 gnus-newsgroup-data-reverse nil)))
7257 (setq data (cdr data))))))
7259 (defmacro gnus-data-list (backward)
7261 (or gnus-newsgroup-data-reverse
7262 (setq gnus-newsgroup-data-reverse
7263 (reverse gnus-newsgroup-data)))
7264 gnus-newsgroup-data))
7266 (defun gnus-data-update-list (data offset)
7267 "Add OFFSET to the POS of all data entries in DATA."
7269 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7270 (setq data (cdr data))))
7272 (defun gnus-data-compute-positions ()
7273 "Compute the positions of all articles."
7274 (let ((data gnus-newsgroup-data)
7277 (when (setq pos (text-property-any
7278 (point-min) (point-max)
7279 'gnus-number (gnus-data-number (car data))))
7280 (gnus-data-set-pos (car data) (+ pos 3)))
7281 (setq data (cdr data)))))
7283 (defun gnus-summary-article-pseudo-p (article)
7284 "Say whether this article is a pseudo article or not."
7285 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7287 (defun gnus-article-parent-p (number)
7288 "Say whether this article is a parent or not."
7289 (let ((data (gnus-data-find-list number)))
7290 (and (cdr data) ; There has to be an article after...
7291 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7292 (gnus-data-level (nth 1 data))))))
7294 (defun gnus-article-children (number)
7295 "Return a list of all children to NUMBER."
7296 (let* ((data (gnus-data-find-list number))
7297 (level (gnus-data-level (car data)))
7299 (setq data (cdr data))
7301 (= (gnus-data-level (car data)) (1+ level)))
7302 (push (gnus-data-number (car data)) children)
7303 (setq data (cdr data)))
7306 (defmacro gnus-summary-skip-intangible ()
7307 "If the current article is intangible, then jump to a different article."
7308 '(let ((to (get-text-property (point) 'gnus-intangible)))
7309 (and to (gnus-summary-goto-subject to))))
7311 (defmacro gnus-summary-article-intangible-p ()
7312 "Say whether this article is intangible or not."
7313 '(get-text-property (point) 'gnus-intangible))
7315 ;; Some summary mode macros.
7317 (defmacro gnus-summary-article-number ()
7318 "The article number of the article on the current line.
7319 If there isn's an article number here, then we return the current
7322 (gnus-summary-skip-intangible)
7323 (or (get-text-property (point) 'gnus-number)
7324 (gnus-summary-last-subject))))
7326 (defmacro gnus-summary-article-header (&optional number)
7327 `(gnus-data-header (gnus-data-find
7328 ,(or number '(gnus-summary-article-number)))))
7330 (defmacro gnus-summary-thread-level (&optional number)
7331 `(if (and (eq gnus-summary-make-false-root 'dummy)
7332 (get-text-property (point) 'gnus-intangible))
7334 (gnus-data-level (gnus-data-find
7335 ,(or number '(gnus-summary-article-number))))))
7337 (defmacro gnus-summary-article-mark (&optional number)
7338 `(gnus-data-mark (gnus-data-find
7339 ,(or number '(gnus-summary-article-number)))))
7341 (defmacro gnus-summary-article-pos (&optional number)
7342 `(gnus-data-pos (gnus-data-find
7343 ,(or number '(gnus-summary-article-number)))))
7345 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7346 (defmacro gnus-summary-article-subject (&optional number)
7347 "Return current subject string or nil if nothing."
7350 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7351 '(gnus-data-header (assq (gnus-summary-article-number)
7352 gnus-newsgroup-data)))))
7355 (mail-header-subject headers))))
7357 (defmacro gnus-summary-article-score (&optional number)
7358 "Return current article score."
7359 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7360 gnus-newsgroup-scored))
7361 gnus-summary-default-score 0))
7363 (defun gnus-summary-article-children (&optional number)
7364 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7365 (level (gnus-data-level (car data)))
7367 (while (and (setq data (cdr data))
7368 (> (setq l (gnus-data-level (car data))) level))
7369 (and (= (1+ level) l)
7370 (setq children (cons (gnus-data-number (car data))
7372 (nreverse children)))
7374 (defun gnus-summary-article-parent (&optional number)
7375 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7376 (gnus-data-list t)))
7377 (level (gnus-data-level (car data))))
7379 () ; This is a root.
7380 ;; We search until we find an article with a level less than
7381 ;; this one. That function has to be the parent.
7382 (while (and (setq data (cdr data))
7383 (not (< (gnus-data-level (car data)) level))))
7384 (and data (gnus-data-number (car data))))))
7386 (defun gnus-unread-mark-p (mark)
7387 "Say whether MARK is the unread mark."
7388 (= mark gnus-unread-mark))
7390 (defun gnus-read-mark-p (mark)
7391 "Say whether MARK is one of the marks that mark as read.
7392 This is all marks except unread, ticked, dormant, and expirable."
7393 (not (or (= mark gnus-unread-mark)
7394 (= mark gnus-ticked-mark)
7395 (= mark gnus-dormant-mark)
7396 (= mark gnus-expirable-mark))))
7398 ;; Various summary mode internalish functions.
7400 (defun gnus-mouse-pick-article (e)
7403 (gnus-summary-next-page nil t))
7405 (defun gnus-summary-setup-buffer (group)
7406 "Initialize summary buffer."
7407 (let ((buffer (concat "*Summary " group "*")))
7408 (if (get-buffer buffer)
7411 (setq gnus-summary-buffer (current-buffer))
7412 (not gnus-newsgroup-prepared))
7413 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7414 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7415 (gnus-add-current-to-buffer-list)
7416 (gnus-summary-mode group)
7418 (gnus-carpal-setup-buffer 'summary))
7419 (unless gnus-single-article-buffer
7420 (make-local-variable 'gnus-article-buffer)
7421 (make-local-variable 'gnus-article-current)
7422 (make-local-variable 'gnus-original-article-buffer))
7423 (setq gnus-newsgroup-name group)
7426 (defun gnus-set-global-variables ()
7427 ;; Set the global equivalents of the summary buffer-local variables
7428 ;; to the latest values they had. These reflect the summary buffer
7429 ;; that was in action when the last article was fetched.
7430 (when (eq major-mode 'gnus-summary-mode)
7431 (setq gnus-summary-buffer (current-buffer))
7432 (let ((name gnus-newsgroup-name)
7433 (marked gnus-newsgroup-marked)
7434 (unread gnus-newsgroup-unreads)
7435 (headers gnus-current-headers)
7436 (data gnus-newsgroup-data)
7437 (summary gnus-summary-buffer)
7438 (article-buffer gnus-article-buffer)
7439 (original gnus-original-article-buffer)
7440 (gac gnus-article-current)
7441 (score-file gnus-current-score-file))
7443 (set-buffer gnus-group-buffer)
7444 (setq gnus-newsgroup-name name)
7445 (setq gnus-newsgroup-marked marked)
7446 (setq gnus-newsgroup-unreads unread)
7447 (setq gnus-current-headers headers)
7448 (setq gnus-newsgroup-data data)
7449 (setq gnus-article-current gac)
7450 (setq gnus-summary-buffer summary)
7451 (setq gnus-article-buffer article-buffer)
7452 (setq gnus-original-article-buffer original)
7453 (setq gnus-current-score-file score-file)))))
7455 (defun gnus-summary-last-article-p (&optional article)
7456 "Return whether ARTICLE is the last article in the buffer."
7457 (if (not (setq article (or article (gnus-summary-article-number))))
7458 t ; All non-existant numbers are the last article. :-)
7459 (not (cdr (gnus-data-find-list article)))))
7461 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7462 "Insert a dummy root in the summary buffer."
7464 (gnus-add-text-properties
7465 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7466 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7468 (defun gnus-make-thread-indent-array ()
7470 (unless (and gnus-thread-indent-array
7471 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7472 (setq gnus-thread-indent-array (make-vector 201 "")
7473 gnus-thread-indent-array-level gnus-thread-indent-level)
7475 (aset gnus-thread-indent-array n
7476 (make-string (* n gnus-thread-indent-level) ? ))
7479 (defun gnus-summary-insert-line
7480 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7481 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7482 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7483 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7484 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7485 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7486 (gnus-tmp-score-char
7487 (if (or (null gnus-summary-default-score)
7488 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7489 gnus-summary-zcore-fuzz)) ?
7490 (if (< gnus-tmp-score gnus-summary-default-score)
7491 gnus-score-below-mark gnus-score-over-mark)))
7492 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7493 ((memq gnus-tmp-current gnus-newsgroup-cached)
7495 (gnus-tmp-replied gnus-replied-mark)
7496 ((memq gnus-tmp-current gnus-newsgroup-saved)
7498 (t gnus-unread-mark)))
7499 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7502 ((string-match "(.+)" gnus-tmp-from)
7503 (substring gnus-tmp-from
7504 (1+ (match-beginning 0)) (1- (match-end 0))))
7505 ((string-match "<[^>]+> *$" gnus-tmp-from)
7506 (let ((beg (match-beginning 0)))
7507 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7508 (substring gnus-tmp-from (1+ (match-beginning 0))
7509 (1- (match-end 0))))
7510 (substring gnus-tmp-from 0 beg))))
7512 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7513 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7514 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7515 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7516 (buffer-read-only nil))
7517 (when (string= gnus-tmp-name "")
7518 (setq gnus-tmp-name gnus-tmp-from))
7519 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7520 (gnus-put-text-property
7522 (progn (eval gnus-summary-line-format-spec) (point))
7523 'gnus-number gnus-tmp-number)
7524 (when (gnus-visual-p 'summary-highlight 'highlight)
7526 (run-hooks 'gnus-summary-update-hook)
7529 (defun gnus-summary-update-line (&optional dont-update)
7530 ;; Update summary line after change.
7531 (when (and gnus-summary-default-score
7532 (not gnus-summary-inhibit-highlight))
7533 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7534 (article (gnus-summary-article-number))
7535 (score (gnus-summary-article-score article)))
7537 (if (and gnus-summary-mark-below
7538 (< (gnus-summary-article-score)
7539 gnus-summary-mark-below))
7540 ;; This article has a low score, so we mark it as read.
7541 (when (memq article gnus-newsgroup-unreads)
7542 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7543 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7544 ;; This article was previously marked as read on account
7545 ;; of a low score, but now it has risen, so we mark it as
7547 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7548 (gnus-summary-update-mark
7549 (if (or (null gnus-summary-default-score)
7550 (<= (abs (- score gnus-summary-default-score))
7551 gnus-summary-zcore-fuzz)) ?
7552 (if (< score gnus-summary-default-score)
7553 gnus-score-below-mark gnus-score-over-mark)) 'score))
7554 ;; Do visual highlighting.
7555 (when (gnus-visual-p 'summary-highlight 'highlight)
7556 (run-hooks 'gnus-summary-update-hook)))))
7558 (defvar gnus-tmp-new-adopts nil)
7560 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7561 ;; Sum up all elements (and sub-elements) in a list.
7563 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7565 ((and (consp thread) (cdr thread))
7568 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7571 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7574 (when (and level (zerop level) gnus-tmp-new-adopts)
7577 'gnus-summary-number-of-articles-in-thread
7578 gnus-tmp-new-adopts))))
7580 (if (> number 1) gnus-not-empty-thread-mark
7581 gnus-empty-thread-mark)
7584 (defun gnus-summary-set-local-parameters (group)
7585 "Go through the local params of GROUP and set all variable specs in that list."
7586 (let ((params (gnus-info-params (gnus-get-info group)))
7589 (setq elem (car params)
7590 params (cdr params))
7591 (and (consp elem) ; Has to be a cons.
7592 (consp (cdr elem)) ; The cdr has to be a list.
7593 (symbolp (car elem)) ; Has to be a symbol in there.
7594 (not (memq (car elem)
7595 '(quit-config to-address to-list to-group)))
7596 (progn ; So we set it.
7597 (make-local-variable (car elem))
7598 (set (car elem) (eval (nth 1 elem))))))))
7600 (defun gnus-summary-read-group (group &optional show-all no-article
7601 kill-buffer no-display)
7602 "Start reading news in newsgroup GROUP.
7603 If SHOW-ALL is non-nil, already read articles are also listed.
7604 If NO-ARTICLE is non-nil, no article is selected initially.
7605 If NO-DISPLAY, don't generate a summary buffer."
7606 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7607 (let* ((new-group (gnus-summary-setup-buffer group))
7608 (quit-config (gnus-group-quit-config group))
7609 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7611 ;; This summary buffer exists already, so we just select it.
7613 (gnus-set-global-variables)
7615 (gnus-kill-or-deaden-summary kill-buffer))
7616 (gnus-configure-windows 'summary 'force)
7617 (gnus-set-mode-line 'summary)
7618 (gnus-summary-position-point)
7621 ;; We couldn't select this group.
7623 (when (and (eq major-mode 'gnus-summary-mode)
7624 (not (equal (current-buffer) kill-buffer)))
7625 (kill-buffer (current-buffer))
7626 (if (not quit-config)
7628 (set-buffer gnus-group-buffer)
7629 (gnus-group-jump-to-group group)
7630 (gnus-group-next-unread-group 1))
7631 (if (not (buffer-name (car quit-config)))
7632 (gnus-configure-windows 'group 'force)
7633 (set-buffer (car quit-config))
7634 (and (eq major-mode 'gnus-summary-mode)
7635 (gnus-set-global-variables))
7636 (gnus-configure-windows (cdr quit-config)))))
7637 (gnus-message 3 "Can't select group")
7639 ;; The user did a `C-g' while prompting for number of articles,
7640 ;; so we exit this group.
7641 ((eq did-select 'quit)
7642 (and (eq major-mode 'gnus-summary-mode)
7643 (not (equal (current-buffer) kill-buffer))
7644 (kill-buffer (current-buffer)))
7646 (gnus-kill-or-deaden-summary kill-buffer))
7647 (if (not quit-config)
7649 (set-buffer gnus-group-buffer)
7650 (gnus-group-jump-to-group group)
7651 (gnus-group-next-unread-group 1)
7652 (gnus-configure-windows 'group 'force))
7653 (if (not (buffer-name (car quit-config)))
7654 (gnus-configure-windows 'group 'force)
7655 (set-buffer (car quit-config))
7656 (and (eq major-mode 'gnus-summary-mode)
7657 (gnus-set-global-variables))
7658 (gnus-configure-windows (cdr quit-config))))
7659 ;; Finally signal the quit.
7661 ;; The group was successfully selected.
7663 (gnus-set-global-variables)
7664 ;; Save the active value in effect when the group was entered.
7665 (setq gnus-newsgroup-active
7667 (gnus-active gnus-newsgroup-name)))
7668 ;; You can change the summary buffer in some way with this hook.
7669 (run-hooks 'gnus-select-group-hook)
7670 ;; Set any local variables in the group parameters.
7671 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7672 (gnus-update-format-specifications)
7673 ;; Do score processing.
7674 (when gnus-use-scoring
7675 (gnus-possibly-score-headers))
7676 ;; Check whether to fill in the gaps in the threads.
7677 (when gnus-build-sparse-threads
7678 (gnus-build-sparse-threads))
7679 ;; Find the initial limit.
7680 (if gnus-show-threads
7682 (let ((gnus-newsgroup-dormant nil))
7683 (gnus-summary-initial-limit show-all))
7684 (gnus-summary-initial-limit show-all))
7685 (setq gnus-newsgroup-limit
7687 (lambda (header) (mail-header-number header))
7688 gnus-newsgroup-headers)))
7689 ;; Generate the summary buffer.
7691 (gnus-summary-prepare))
7692 (when gnus-use-trees
7693 (gnus-tree-open group)
7694 (setq gnus-summary-highlight-line-function
7695 'gnus-tree-highlight-article))
7696 ;; If the summary buffer is empty, but there are some low-scored
7697 ;; articles or some excluded dormants, we include these in the
7699 (when (and (zerop (buffer-size))
7701 (cond (gnus-newsgroup-dormant
7702 (gnus-summary-limit-include-dormant))
7703 ((and gnus-newsgroup-scored show-all)
7704 (gnus-summary-limit-include-expunged))))
7705 ;; Function `gnus-apply-kill-file' must be called in this hook.
7706 (run-hooks 'gnus-apply-kill-hook)
7707 (if (and (zerop (buffer-size))
7710 ;; This newsgroup is empty.
7711 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7712 (gnus-message 6 "No unread news")
7714 (gnus-kill-or-deaden-summary kill-buffer))
7715 ;; Return nil from this function.
7717 ;; Hide conversation thread subtrees. We cannot do this in
7718 ;; gnus-summary-prepare-hook since kill processing may not
7719 ;; work with hidden articles.
7720 (and gnus-show-threads
7721 gnus-thread-hide-subtree
7722 (gnus-summary-hide-all-threads))
7723 ;; Show first unread article if requested.
7724 (if (and (not no-article)
7726 gnus-newsgroup-unreads
7727 gnus-auto-select-first)
7728 (unless (if (eq gnus-auto-select-first 'best)
7729 (gnus-summary-best-unread-article)
7730 (gnus-summary-first-unread-article))
7731 (gnus-configure-windows 'summary))
7732 ;; Don't select any articles, just move point to the first
7733 ;; article in the group.
7734 (goto-char (point-min))
7735 (gnus-summary-position-point)
7736 (gnus-set-mode-line 'summary)
7737 (gnus-configure-windows 'summary 'force))
7738 ;; If we are in async mode, we send some info to the backend.
7739 (when gnus-newsgroup-async
7740 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7742 (gnus-kill-or-deaden-summary kill-buffer))
7743 (when (get-buffer-window gnus-group-buffer t)
7744 ;; Gotta use windows, because recenter does wierd stuff if
7745 ;; the current buffer ain't the displayed window.
7746 (let ((owin (selected-window)))
7747 (select-window (get-buffer-window gnus-group-buffer t))
7748 (when (gnus-group-goto-group group)
7750 (select-window owin))))
7751 ;; Mark this buffer as "prepared".
7752 (setq gnus-newsgroup-prepared t)
7755 (defun gnus-summary-prepare ()
7756 "Generate the summary buffer."
7757 (let ((buffer-read-only nil))
7759 (setq gnus-newsgroup-data nil
7760 gnus-newsgroup-data-reverse nil)
7761 (run-hooks 'gnus-summary-generate-hook)
7762 ;; Generate the buffer, either with threads or without.
7763 (when gnus-newsgroup-headers
7764 (gnus-summary-prepare-threads
7765 (if gnus-show-threads
7766 (gnus-sort-gathered-threads
7767 (funcall gnus-summary-thread-gathering-function
7769 (gnus-cut-threads (gnus-make-threads)))))
7770 ;; Unthreaded display.
7771 (gnus-sort-articles gnus-newsgroup-headers))))
7772 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7773 ;; Call hooks for modifying summary buffer.
7774 (goto-char (point-min))
7775 (run-hooks 'gnus-summary-prepare-hook)))
7777 (defun gnus-gather-threads-by-subject (threads)
7778 "Gather threads by looking at Subject headers."
7779 (if (not gnus-summary-make-false-root)
7781 (let ((hashtb (gnus-make-hashtable 1023))
7784 subject hthread whole-subject)
7786 (setq whole-subject (mail-header-subject (caar threads)))
7789 ;; Truncate the subject.
7790 ((numberp gnus-summary-gather-subject-limit)
7791 (setq subject (gnus-simplify-subject-re whole-subject))
7792 (if (> (length subject) gnus-summary-gather-subject-limit)
7793 (substring subject 0 gnus-summary-gather-subject-limit)
7795 ;; Fuzzily simplify it.
7796 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7797 (gnus-simplify-subject-fuzzy whole-subject))
7798 ;; Just remove the leading "Re:".
7800 (gnus-simplify-subject-re whole-subject))))
7802 (if (and gnus-summary-gather-exclude-subject
7803 (string-match gnus-summary-gather-exclude-subject
7805 () ; We don't want to do anything with this article.
7806 ;; We simplify the subject before looking it up in the
7809 (if (setq hthread (gnus-gethash subject hashtb))
7811 ;; We enter a dummy root into the thread, if we
7812 ;; haven't done that already.
7813 (unless (stringp (caar hthread))
7814 (setcar hthread (list whole-subject (car hthread))))
7815 ;; We add this new gathered thread to this gathered
7817 (setcdr (car hthread)
7818 (nconc (cdar hthread) (list (car threads))))
7819 ;; Remove it from the list of threads.
7820 (setcdr prev (cdr threads))
7821 (setq threads prev))
7822 ;; Enter this thread into the hash table.
7823 (gnus-sethash subject threads hashtb)))
7825 (setq threads (cdr threads)))
7828 (defun gnus-gather-threads-by-references (threads)
7829 "Gather threads by looking at References headers."
7830 (let ((idhashtb (gnus-make-hashtable 1023))
7831 (thhashtb (gnus-make-hashtable 1023))
7834 ids references id gthread gid entered)
7836 (when (setq references (mail-header-references (caar threads)))
7837 (setq id (mail-header-id (caar threads)))
7838 (setq ids (gnus-split-references references))
7841 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7843 (gnus-sethash (car ids) id idhashtb)
7844 (gnus-sethash id threads thhashtb))
7845 (setq gthread (gnus-gethash gid thhashtb))
7847 ;; We enter a dummy root into the thread, if we
7848 ;; haven't done that already.
7849 (unless (stringp (caar gthread))
7850 (setcar gthread (list (mail-header-subject (caar gthread))
7852 ;; We add this new gathered thread to this gathered
7854 (setcdr (car gthread)
7855 (nconc (cdar gthread) (list (car threads)))))
7856 ;; Add it into the thread hash table.
7857 (gnus-sethash id gthread thhashtb)
7859 ;; Remove it from the list of threads.
7860 (setcdr prev (cdr threads))
7861 (setq threads prev))
7862 (setq ids (cdr ids))))
7864 (setq threads (cdr threads)))
7867 (defun gnus-sort-gathered-threads (threads)
7868 "Sort subtreads inside each gathered thread by article number."
7869 (let ((result threads))
7871 (when (stringp (caar threads))
7872 (setcdr (car threads)
7873 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7874 (setq threads (cdr threads)))
7877 (defun gnus-make-threads ()
7878 "Go through the dependency hashtb and find the roots. Return all threads."
7882 (unless (car (symbol-value refs))
7883 ;; These threads do not refer back to any other articles,
7884 ;; so they're roots.
7885 (setq threads (append (cdr (symbol-value refs)) threads))))
7886 gnus-newsgroup-dependencies)
7889 (defun gnus-build-sparse-threads ()
7890 (let ((headers gnus-newsgroup-headers)
7891 (deps gnus-newsgroup-dependencies)
7892 header references generation relations
7893 cthread subject child end pthread relation)
7894 ;; First we create an alist of generations/relations, where
7895 ;; generations is how much we trust the ralation, and the relation
7897 (gnus-message 7 "Making sparse threads...")
7899 (nnheader-set-temp-buffer " *gnus sparse threads*")
7900 (while (setq header (pop headers))
7901 (when (and (setq references (mail-header-references header))
7902 (not (string= references "")))
7904 (setq child (mail-header-id header)
7905 subject (mail-header-subject header))
7907 (while (search-backward ">" nil t)
7908 (setq end (1+ (point)))
7909 (when (search-backward "<" nil t)
7910 (push (list (incf generation)
7911 child (setq child (buffer-substring (point) end))
7914 (push (list (1+ generation) child nil subject) relations)
7916 (kill-buffer (current-buffer)))
7917 ;; Sort over trustworthiness.
7918 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7919 (while (setq relation (pop relations))
7920 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7921 (unless (car (symbol-value cthread))
7922 ;; Make this article the parent of these threads.
7923 (setcar (symbol-value cthread)
7924 (vector gnus-reffed-article-number
7928 (or (caddr relation) "") 0 0 "")))
7929 (set cthread (list (vector gnus-reffed-article-number
7931 "" "" (cadr relation)
7932 (or (caddr relation) "") 0 0 ""))))
7933 (push gnus-reffed-article-number gnus-newsgroup-limit)
7934 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7935 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7936 gnus-newsgroup-reads)
7937 (decf gnus-reffed-article-number)
7938 ;; Make this new thread the child of its parent.
7939 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7940 (setcdr (symbol-value pthread)
7941 (nconc (cdr (symbol-value pthread))
7942 (list (symbol-value cthread))))
7943 (set pthread (list nil (symbol-value cthread))))))
7944 (gnus-message 7 "Making sparse threads...done")))
7946 (defun gnus-build-old-threads ()
7947 ;; Look at all the articles that refer back to old articles, and
7948 ;; fetch the headers for the articles that aren't there. This will
7949 ;; build complete threads - if the roots haven't been expired by the
7954 (when (not (car (symbol-value refs)))
7955 (setq heads (cdr (symbol-value refs)))
7957 (if (memq (mail-header-number (caar heads))
7958 gnus-newsgroup-dormant)
7959 (setq heads (cdr heads))
7960 (setq id (symbol-name refs))
7961 (while (and (setq id (gnus-build-get-header id))
7962 (not (car (gnus-gethash
7963 id gnus-newsgroup-dependencies)))))
7964 (setq heads nil)))))
7965 gnus-newsgroup-dependencies)))
7967 (defun gnus-build-get-header (id)
7968 ;; Look through the buffer of NOV lines and find the header to
7969 ;; ID. Enter this line into the dependencies hash table, and return
7970 ;; the id of the parent article (if any).
7971 (let ((deps gnus-newsgroup-dependencies)
7975 (set-buffer nntp-server-buffer)
7976 (goto-char (point-min))
7977 (while (and (not found) (search-forward id nil t))
7979 (setq found (looking-at
7980 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7981 (regexp-quote id))))
7982 (or found (beginning-of-line 2)))
7986 (setq header (gnus-nov-parse-line
7987 (read (current-buffer)) deps))
7988 (gnus-parent-id (mail-header-references header)))))
7990 (let ((number (mail-header-number header)))
7991 (push number gnus-newsgroup-limit)
7992 (push header gnus-newsgroup-headers)
7993 (if (memq number gnus-newsgroup-unselected)
7995 (push number gnus-newsgroup-unreads)
7996 (setq gnus-newsgroup-unselected
7997 (delq number gnus-newsgroup-unselected)))
7998 (push number gnus-newsgroup-ancient)))))))
8000 (defun gnus-summary-update-article (article &optional header)
8001 "Update ARTICLE in the summary buffer."
8002 (set-buffer gnus-summary-buffer)
8003 (let* ((header (or header (gnus-summary-article-header article)))
8004 (id (mail-header-id header))
8005 (data (gnus-data-find article))
8006 (thread (gnus-id-to-thread id))
8008 (gnus-id-to-thread (or (gnus-parent-id
8009 (mail-header-references header))
8011 (buffer-read-only nil)
8013 (number (mail-header-number header))
8018 (delq thread parent))
8019 (if (gnus-summary-insert-subject id header)
8020 ;; Set the (possibly) new article number in the data structure.
8021 (gnus-data-set-number data (gnus-id-to-article id))
8025 (defun gnus-rebuild-thread (id)
8026 "Rebuild the thread containing ID."
8027 (let ((buffer-read-only nil)
8028 current thread data)
8029 (if (not gnus-show-threads)
8030 (setq thread (list (car (gnus-id-to-thread id))))
8031 ;; Get the thread this article is part of.
8032 (setq thread (gnus-remove-thread id)))
8033 (setq current (save-excursion
8034 (and (zerop (forward-line -1))
8035 (gnus-summary-article-number))))
8036 ;; If this is a gathered thread, we have to go some re-gathering.
8037 (when (stringp (car thread))
8038 (let ((subject (car thread))
8040 (setq thread (cdr thread))
8042 (unless (memq (setq thr (gnus-id-to-thread
8044 (mail-header-id (caar thread)))))
8047 (setq thread (cdr thread)))
8048 ;; We now have all (unique) roots.
8049 (if (= (length roots) 1)
8050 ;; All the loose roots are now one solid root.
8051 (setq thread (car roots))
8052 (setq thread (cons subject (gnus-sort-threads roots))))))
8054 ;; We then insert this thread into the summary buffer.
8055 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8056 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8057 (setq data (nreverse gnus-newsgroup-data))
8058 (setq threads gnus-newsgroup-threads))
8059 ;; We splice the new data into the data structure.
8060 (gnus-data-enter-list current data)
8061 (gnus-data-compute-positions)
8062 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8064 (defun gnus-id-to-thread (id)
8065 "Return the (sub-)thread where ID appears."
8066 (gnus-gethash id gnus-newsgroup-dependencies))
8068 (defun gnus-id-to-article (id)
8069 "Return the article number of ID."
8070 (let ((thread (gnus-id-to-thread id)))
8073 (mail-header-number (car thread)))))
8075 (defun gnus-id-to-header (id)
8076 "Return the article headers of ID."
8077 (car (gnus-id-to-thread id)))
8079 (defun gnus-article-displayed-root-p (article)
8080 "Say whether ARTICLE is a root(ish) article."
8081 (let ((level (gnus-summary-thread-level article))
8082 (refs (mail-header-references (gnus-summary-article-header article)))
8088 ((null (gnus-parent-id refs)) t)
8090 (null (setq particle (gnus-id-to-article
8091 (gnus-parent-id refs))))
8092 (null (gnus-summary-thread-level particle)))))))
8094 (defun gnus-root-id (id)
8095 "Return the id of the root of the thread where ID appears."
8097 (while (and id (setq prev (car (gnus-gethash
8098 id gnus-newsgroup-dependencies))))
8100 id (gnus-parent-id (mail-header-references prev))))
8103 (defun gnus-remove-thread (id &optional dont-remove)
8104 "Remove the thread that has ID in it."
8105 (let ((dep gnus-newsgroup-dependencies)
8106 headers thread last-id)
8107 ;; First go up in this thread until we find the root.
8108 (setq last-id (gnus-root-id id))
8109 (setq headers (list (car (gnus-id-to-thread last-id))
8110 (caadr (gnus-id-to-thread last-id))))
8111 ;; We have now found the real root of this thread. It might have
8112 ;; been gathered into some loose thread, so we have to search
8113 ;; through the threads to find the thread we wanted.
8114 (let ((threads gnus-newsgroup-threads)
8117 (setq sub (car threads))
8118 (if (stringp (car sub))
8119 ;; This is a gathered threads, so we look at the roots
8120 ;; below it to find whether this article in in this
8123 (setq sub (cdr sub))
8125 (when (member (caar sub) headers)
8126 (setq thread (car threads)
8129 (setq sub (cdr sub))))
8130 ;; It's an ordinary thread, so we check it.
8131 (when (eq (car sub) (car headers))
8134 (setq threads (cdr threads)))
8135 ;; If this article is in no thread, then it's a root.
8138 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8139 (setq thread (gnus-gethash last-id dep)))
8142 thread ; We return this thread.
8144 (if (stringp (car thread))
8146 ;; If we use dummy roots, then we have to remove the
8147 ;; dummy root as well.
8148 (when (eq gnus-summary-make-false-root 'dummy)
8151 (setq thread (cdr thread))
8153 (gnus-remove-thread-1 (car thread))
8154 (setq thread (cdr thread))))
8155 (gnus-remove-thread-1 thread))))))))
8157 (defun gnus-remove-thread-1 (thread)
8158 "Remove the thread THREAD recursively."
8159 (let ((number (mail-header-number (car thread)))
8161 (when (setq pos (text-property-any
8162 (point-min) (point-max) 'gnus-number number))
8165 (gnus-data-remove number))
8166 (setq thread (cdr thread))
8168 (gnus-remove-thread-1 (pop thread)))))
8170 (defun gnus-sort-threads (threads)
8172 (if (not gnus-thread-sort-functions)
8174 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8175 (car gnus-thread-sort-functions)
8177 ,(gnus-make-sort-function
8178 (reverse gnus-thread-sort-functions))))))
8179 (gnus-message 7 "Sorting threads...")
8182 (gnus-message 7 "Sorting threads...done")))))
8184 (defun gnus-sort-articles (articles)
8186 (when gnus-article-sort-functions
8187 (let ((func (if (= 1 (length gnus-article-sort-functions))
8188 (car gnus-article-sort-functions)
8190 ,(gnus-make-sort-function
8191 (reverse gnus-article-sort-functions))))))
8192 (gnus-message 7 "Sorting articles...")
8194 (setq gnus-newsgroup-headers (sort articles func))
8195 (gnus-message 7 "Sorting articles...done")))))
8197 (defun gnus-make-sort-function (funs)
8198 "Return a composite sort condition based on the functions in FUNC."
8200 `(or (,(car funs) t1 t2)
8201 (and (not (,(car funs) t2 t1))
8202 ,(gnus-make-sort-function (cdr funs))))
8203 `(,(car funs) t1 t2)))
8205 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8206 (defmacro gnus-thread-header (thread)
8207 ;; Return header of first article in THREAD.
8208 ;; Note that THREAD must never, ever be anything else than a variable -
8209 ;; using some other form will lead to serious barfage.
8210 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8211 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8212 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8215 (defsubst gnus-article-sort-by-number (h1 h2)
8216 "Sort articles by article number."
8217 (< (mail-header-number h1)
8218 (mail-header-number h2)))
8220 (defun gnus-thread-sort-by-number (h1 h2)
8221 "Sort threads by root article number."
8222 (gnus-article-sort-by-number
8223 (gnus-thread-header h1) (gnus-thread-header h2)))
8225 (defsubst gnus-article-sort-by-author (h1 h2)
8226 "Sort articles by root author."
8228 (let ((extract (funcall
8229 gnus-extract-address-components
8230 (mail-header-from h1))))
8231 (or (car extract) (cdr extract)))
8232 (let ((extract (funcall
8233 gnus-extract-address-components
8234 (mail-header-from h2))))
8235 (or (car extract) (cdr extract)))))
8237 (defun gnus-thread-sort-by-author (h1 h2)
8238 "Sort threads by root author."
8239 (gnus-article-sort-by-author
8240 (gnus-thread-header h1) (gnus-thread-header h2)))
8242 (defsubst gnus-article-sort-by-subject (h1 h2)
8243 "Sort articles by root subject."
8245 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8246 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8248 (defun gnus-thread-sort-by-subject (h1 h2)
8249 "Sort threads by root subject."
8250 (gnus-article-sort-by-subject
8251 (gnus-thread-header h1) (gnus-thread-header h2)))
8253 (defsubst gnus-article-sort-by-date (h1 h2)
8254 "Sort articles by root article date."
8256 (gnus-sortable-date (mail-header-date h1))
8257 (gnus-sortable-date (mail-header-date h2))))
8259 (defun gnus-thread-sort-by-date (h1 h2)
8260 "Sort threads by root article date."
8261 (gnus-article-sort-by-date
8262 (gnus-thread-header h1) (gnus-thread-header h2)))
8264 (defsubst gnus-article-sort-by-score (h1 h2)
8265 "Sort articles by root article score.
8266 Unscored articles will be counted as having a score of zero."
8267 (> (or (cdr (assq (mail-header-number h1)
8268 gnus-newsgroup-scored))
8269 gnus-summary-default-score 0)
8270 (or (cdr (assq (mail-header-number h2)
8271 gnus-newsgroup-scored))
8272 gnus-summary-default-score 0)))
8274 (defun gnus-thread-sort-by-score (h1 h2)
8275 "Sort threads by root article score."
8276 (gnus-article-sort-by-score
8277 (gnus-thread-header h1) (gnus-thread-header h2)))
8279 (defun gnus-thread-sort-by-total-score (h1 h2)
8280 "Sort threads by the sum of all scores in the thread.
8281 Unscored articles will be counted as having a score of zero."
8282 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8284 (defun gnus-thread-total-score (thread)
8285 ;; This function find the total score of THREAD.
8287 (if (stringp (car thread))
8288 (apply gnus-thread-score-function 0
8289 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8290 (gnus-thread-total-score-1 thread))
8291 (gnus-thread-total-score-1 (list thread))))
8293 (defun gnus-thread-total-score-1 (root)
8294 ;; This function find the total score of the thread below ROOT.
8295 (setq root (car root))
8296 (apply gnus-thread-score-function
8297 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8298 gnus-summary-default-score 0)
8299 (mapcar 'gnus-thread-total-score
8300 (cdr (gnus-gethash (mail-header-id root)
8301 gnus-newsgroup-dependencies)))))
8303 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8304 (defvar gnus-tmp-prev-subject nil)
8305 (defvar gnus-tmp-false-parent nil)
8306 (defvar gnus-tmp-root-expunged nil)
8307 (defvar gnus-tmp-dummy-line nil)
8309 (defun gnus-summary-prepare-threads (threads)
8310 "Prepare summary buffer from THREADS and indentation LEVEL.
8311 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8312 or a straight list of headers."
8313 (gnus-message 7 "Generating summary...")
8315 (setq gnus-newsgroup-threads threads)
8318 (let ((gnus-tmp-level 0)
8319 (default-score (or gnus-summary-default-score 0))
8320 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8321 thread number subject stack state gnus-tmp-gathered beg-match
8322 new-roots gnus-tmp-new-adopts thread-end
8323 gnus-tmp-header gnus-tmp-unread
8324 gnus-tmp-replied gnus-tmp-subject-or-nil
8325 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8326 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8327 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8329 (setq gnus-tmp-prev-subject nil)
8331 (if (vectorp (car threads))
8332 ;; If this is a straight (sic) list of headers, then a
8333 ;; threaded summary display isn't required, so we just create
8334 ;; an unthreaded one.
8335 (gnus-summary-prepare-unthreaded threads)
8337 ;; Do the threaded display.
8339 (while (or threads stack gnus-tmp-new-adopts new-roots)
8341 (if (and (= gnus-tmp-level 0)
8342 (not (setq gnus-tmp-dummy-line nil))
8345 (not gnus-tmp-false-parent)
8346 (or gnus-tmp-new-adopts new-roots))
8347 (if gnus-tmp-new-adopts
8348 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8349 thread (list (car gnus-tmp-new-adopts))
8350 gnus-tmp-header (caar thread)
8351 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8353 (setq thread (list (car new-roots))
8354 gnus-tmp-header (caar thread)
8355 new-roots (cdr new-roots))))
8358 ;; If there are some threads, we do them before the
8359 ;; threads on the stack.
8360 (setq thread threads
8361 gnus-tmp-header (caar thread))
8362 ;; There were no current threads, so we pop something off
8364 (setq state (car stack)
8365 gnus-tmp-level (car state)
8368 gnus-tmp-header (caar thread))))
8370 (setq gnus-tmp-false-parent nil)
8371 (setq gnus-tmp-root-expunged nil)
8372 (setq thread-end nil)
8374 (if (stringp gnus-tmp-header)
8375 ;; The header is a dummy root.
8377 ((eq gnus-summary-make-false-root 'adopt)
8378 ;; We let the first article adopt the rest.
8379 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8381 (setq gnus-tmp-gathered
8383 (lambda (h) (mail-header-number (car h)))
8386 (setq thread (cons (list (caar thread)
8389 (setq gnus-tmp-level -1
8390 gnus-tmp-false-parent t))
8391 ((eq gnus-summary-make-false-root 'empty)
8392 ;; We print adopted articles with empty subject fields.
8393 (setq gnus-tmp-gathered
8395 (lambda (h) (mail-header-number (car h)))
8398 (setq gnus-tmp-level -1))
8399 ((eq gnus-summary-make-false-root 'dummy)
8400 ;; We remember that we probably want to output a dummy
8402 (setq gnus-tmp-dummy-line gnus-tmp-header)
8403 (setq gnus-tmp-prev-subject gnus-tmp-header))
8405 ;; We do not make a root for the gathered
8406 ;; sub-threads at all.
8407 (setq gnus-tmp-level -1)))
8409 (setq number (mail-header-number gnus-tmp-header)
8410 subject (mail-header-subject gnus-tmp-header))
8413 ;; If the thread has changed subject, we might want to make
8414 ;; this subthread into a root.
8415 ((and (null gnus-thread-ignore-subject)
8416 (not (zerop gnus-tmp-level))
8417 gnus-tmp-prev-subject
8419 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8420 (setq new-roots (nconc new-roots (list (car thread)))
8422 gnus-tmp-header nil))
8423 ;; If the article lies outside the current limit,
8424 ;; then we do not display it.
8425 ((and (not (memq number gnus-newsgroup-limit))
8426 (not gnus-tmp-dummy-line))
8427 (setq gnus-tmp-gathered
8429 (lambda (h) (mail-header-number (car h)))
8432 (setq gnus-tmp-new-adopts (if (cdar thread)
8433 (append gnus-tmp-new-adopts
8435 gnus-tmp-new-adopts)
8437 gnus-tmp-header nil)
8438 (when (zerop gnus-tmp-level)
8439 (setq gnus-tmp-root-expunged t)))
8440 ;; Perhaps this article is to be marked as read?
8441 ((and gnus-summary-mark-below
8442 (< (or (cdr (assq number gnus-newsgroup-scored))
8444 gnus-summary-mark-below)
8445 ;; Don't touch sparse articles.
8446 (not (memq number gnus-newsgroup-sparse)))
8447 (setq gnus-newsgroup-unreads
8448 (delq number gnus-newsgroup-unreads))
8449 (if gnus-newsgroup-auto-expire
8450 (push number gnus-newsgroup-expirable)
8451 (push (cons number gnus-low-score-mark)
8452 gnus-newsgroup-reads))))
8454 (when gnus-tmp-header
8455 ;; We may have an old dummy line to output before this
8457 (when gnus-tmp-dummy-line
8458 (gnus-summary-insert-dummy-line
8459 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8460 (setq gnus-tmp-dummy-line nil))
8462 ;; Compute the mark.
8466 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8467 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8468 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8469 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8470 (t (or (cdr (assq number gnus-newsgroup-reads))
8471 gnus-ancient-mark))))
8473 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8474 gnus-tmp-header gnus-tmp-level)
8475 gnus-newsgroup-data)
8477 ;; Actually insert the line.
8479 gnus-tmp-subject-or-nil
8481 ((and gnus-thread-ignore-subject
8482 gnus-tmp-prev-subject
8483 (not (inline (gnus-subject-equal
8484 gnus-tmp-prev-subject subject))))
8486 ((zerop gnus-tmp-level)
8487 (if (and (eq gnus-summary-make-false-root 'empty)
8488 (memq number gnus-tmp-gathered)
8489 gnus-tmp-prev-subject
8490 (inline (gnus-subject-equal
8491 gnus-tmp-prev-subject subject)))
8492 gnus-summary-same-subject
8494 (t gnus-summary-same-subject)))
8495 (if (and (eq gnus-summary-make-false-root 'adopt)
8496 (= gnus-tmp-level 1)
8497 (memq number gnus-tmp-gathered))
8498 (setq gnus-tmp-opening-bracket ?\<
8499 gnus-tmp-closing-bracket ?\>)
8500 (setq gnus-tmp-opening-bracket ?\[
8501 gnus-tmp-closing-bracket ?\]))
8503 gnus-tmp-indentation
8504 (aref gnus-thread-indent-array gnus-tmp-level)
8505 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8506 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8507 gnus-summary-default-score 0)
8509 (if (or (null gnus-summary-default-score)
8510 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8511 gnus-summary-zcore-fuzz)) ?
8512 (if (< gnus-tmp-score gnus-summary-default-score)
8513 gnus-score-below-mark gnus-score-over-mark))
8515 (cond ((memq number gnus-newsgroup-processable)
8517 ((memq number gnus-newsgroup-cached)
8519 ((memq number gnus-newsgroup-replied)
8521 (t gnus-unread-mark))
8522 gnus-tmp-from (mail-header-from gnus-tmp-header)
8525 ((string-match "(.+)" gnus-tmp-from)
8526 (substring gnus-tmp-from
8527 (1+ (match-beginning 0)) (1- (match-end 0))))
8528 ((string-match "<[^>]+> *$" gnus-tmp-from)
8529 (setq beg-match (match-beginning 0))
8530 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8531 (substring gnus-tmp-from (1+ (match-beginning 0))
8532 (1- (match-end 0))))
8533 (substring gnus-tmp-from 0 beg-match)))
8535 (when (string= gnus-tmp-name "")
8536 (setq gnus-tmp-name gnus-tmp-from))
8537 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8538 (gnus-put-text-property
8540 (progn (eval gnus-summary-line-format-spec) (point))
8541 'gnus-number number)
8544 (run-hooks 'gnus-summary-update-hook)
8547 (setq gnus-tmp-prev-subject subject)))
8549 (when (nth 1 thread)
8550 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8551 (incf gnus-tmp-level)
8552 (setq threads (if thread-end nil (cdar thread)))
8554 (setq gnus-tmp-level 0)))))
8555 (gnus-message 7 "Generating summary...done"))
8557 (defun gnus-summary-prepare-unthreaded (headers)
8558 "Generate an unthreaded summary buffer based on HEADERS."
8559 (let (header number mark)
8562 ;; We may have to root out some bad articles...
8563 (when (memq (setq number (mail-header-number
8564 (setq header (pop headers))))
8565 gnus-newsgroup-limit)
8566 ;; Mark article as read when it has a low score.
8567 (when (and gnus-summary-mark-below
8568 (< (or (cdr (assq number gnus-newsgroup-scored))
8569 gnus-summary-default-score 0)
8570 gnus-summary-mark-below))
8571 (setq gnus-newsgroup-unreads
8572 (delq number gnus-newsgroup-unreads))
8573 (if gnus-newsgroup-auto-expire
8574 (push number gnus-newsgroup-expirable)
8575 (push (cons number gnus-low-score-mark)
8576 gnus-newsgroup-reads)))
8580 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8581 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8582 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8583 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8584 (t (or (cdr (assq number gnus-newsgroup-reads))
8585 gnus-ancient-mark))))
8586 (setq gnus-newsgroup-data
8587 (cons (gnus-data-make number mark (1+ (point)) header 0)
8588 gnus-newsgroup-data))
8589 (gnus-summary-insert-line
8590 header 0 nil mark (memq number gnus-newsgroup-replied)
8591 (memq number gnus-newsgroup-expirable)
8592 (mail-header-subject header) nil
8593 (cdr (assq number gnus-newsgroup-scored))
8594 (memq number gnus-newsgroup-processable))))))
8596 (defun gnus-select-newsgroup (group &optional read-all)
8597 "Select newsgroup GROUP.
8598 If READ-ALL is non-nil, all articles in the group are selected."
8599 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8600 (info (nth 2 entry))
8601 articles fetched-articles cached)
8603 (or (gnus-check-server
8604 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8605 (error "Couldn't open server"))
8607 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8608 (gnus-activate-group group) ; Or we can activate it...
8609 (progn ; Or we bug out.
8610 (when (equal major-mode 'gnus-summary-mode)
8611 (kill-buffer (current-buffer)))
8612 (error "Couldn't request group %s: %s"
8613 group (gnus-status-message group))))
8615 (unless (gnus-request-group group t)
8616 (when (equal major-mode 'gnus-summary-mode)
8617 (kill-buffer (current-buffer)))
8618 (error "Couldn't request group %s: %s"
8619 group (gnus-status-message group)))
8621 (setq gnus-newsgroup-name group)
8622 (setq gnus-newsgroup-unselected nil)
8623 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8625 (and gnus-asynchronous
8626 (gnus-check-backend-function
8627 'request-asynchronous gnus-newsgroup-name)
8628 (setq gnus-newsgroup-async
8629 (gnus-request-asynchronous gnus-newsgroup-name)))
8631 ;; Adjust and set lists of article marks.
8633 (gnus-adjust-marked-articles info))
8635 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8636 (when (gnus-virtual-group-p group)
8637 (setq cached gnus-newsgroup-cached))
8639 (setq gnus-newsgroup-unreads
8640 (gnus-set-difference
8641 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8642 gnus-newsgroup-dormant))
8644 (setq gnus-newsgroup-processable nil)
8646 (setq articles (gnus-articles-to-read group read-all))
8650 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8652 ((eq articles 0) nil)
8654 ;; Init the dependencies hash table.
8655 (setq gnus-newsgroup-dependencies
8656 (gnus-make-hashtable (length articles)))
8657 ;; Retrieve the headers and read them in.
8658 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8659 (setq gnus-newsgroup-headers
8661 (setq gnus-headers-retrieved-by
8662 (gnus-retrieve-headers
8663 articles gnus-newsgroup-name
8664 ;; We might want to fetch old headers, but
8665 ;; not if there is only 1 article.
8666 (and gnus-fetch-old-headers
8668 (not (eq gnus-fetch-old-headers 'some))
8669 (not (numberp gnus-fetch-old-headers)))
8670 (> (length articles) 1))))))
8671 (gnus-get-newsgroup-headers-xover articles)
8672 (gnus-get-newsgroup-headers)))
8673 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8675 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8677 (setq gnus-newsgroup-cached cached))
8679 ;; Set the initial limit.
8680 (setq gnus-newsgroup-limit (copy-sequence articles))
8681 ;; Remove canceled articles from the list of unread articles.
8682 (setq gnus-newsgroup-unreads
8683 (gnus-set-sorted-intersection
8684 gnus-newsgroup-unreads
8685 (setq fetched-articles
8686 (mapcar (lambda (headers) (mail-header-number headers))
8687 gnus-newsgroup-headers))))
8688 ;; Removed marked articles that do not exist.
8689 (gnus-update-missing-marks
8690 (gnus-sorted-complement fetched-articles articles))
8691 ;; We might want to build some more threads first.
8692 (and gnus-fetch-old-headers
8693 (eq gnus-headers-retrieved-by 'nov)
8694 (gnus-build-old-threads))
8695 ;; Check whether auto-expire is to be done in this group.
8696 (setq gnus-newsgroup-auto-expire
8697 (gnus-group-auto-expirable-p group))
8698 ;; Set up the article buffer now, if necessary.
8699 (unless gnus-single-article-buffer
8700 (gnus-article-setup-buffer))
8701 ;; First and last article in this newsgroup.
8702 (and gnus-newsgroup-headers
8703 (setq gnus-newsgroup-begin
8704 (mail-header-number (car gnus-newsgroup-headers)))
8705 (setq gnus-newsgroup-end
8707 (gnus-last-element gnus-newsgroup-headers))))
8708 (setq gnus-reffed-article-number -1)
8709 ;; GROUP is successfully selected.
8710 (or gnus-newsgroup-headers t)))))
8712 (defun gnus-articles-to-read (group read-all)
8713 ;; Find out what articles the user wants to read.
8715 ;; Select all articles if `read-all' is non-nil, or if there
8716 ;; are no unread articles.
8718 (and (zerop (length gnus-newsgroup-marked))
8719 (zerop (length gnus-newsgroup-unreads))))
8720 (gnus-uncompress-range (gnus-active group))
8721 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8722 (copy-sequence gnus-newsgroup-unreads))
8724 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8725 (scored (length scored-list))
8726 (number (length articles))
8727 (marked (+ (length gnus-newsgroup-marked)
8728 (length gnus-newsgroup-dormant)))
8736 ((and (or (<= scored marked) (= scored number))
8737 (numberp gnus-large-newsgroup)
8738 (> number gnus-large-newsgroup))
8742 "How many articles from %s (default %d): "
8743 gnus-newsgroup-name number))))
8744 (if (string-match "^[ \t]*$" input) number input)))
8745 ((and (> scored marked) (< scored number))
8748 (format "%s %s (%d scored, %d total): "
8749 "How many articles from"
8750 group scored number))))
8751 (if (string-match "^[ \t]*$" input)
8755 (setq select (if (stringp select) (string-to-number select) select))
8756 (if (or (null select) (zerop select))
8758 (if (and (not (zerop scored)) (<= (abs select) scored))
8760 (setq articles (sort scored-list '<))
8761 (setq number (length articles)))
8762 (setq articles (copy-sequence articles)))
8764 (if (< (abs select) number)
8766 ;; Select the N oldest articles.
8767 (setcdr (nthcdr (1- (abs select)) articles) nil)
8768 ;; Select the N most recent articles.
8769 (setq articles (nthcdr (- number select) articles))))
8770 (setq gnus-newsgroup-unselected
8771 (gnus-sorted-intersection
8772 gnus-newsgroup-unreads
8773 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8776 (defun gnus-killed-articles (killed articles)
8779 (if (inline (gnus-member-of-range (car articles) killed))
8780 (setq out (cons (car articles) out)))
8781 (setq articles (cdr articles)))
8784 (defun gnus-uncompress-marks (marks)
8785 "Uncompress the mark ranges in MARKS."
8786 (let ((uncompressed '(score bookmark))
8789 (if (memq (caar marks) uncompressed)
8790 (push (car marks) out)
8791 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8792 (setq marks (cdr marks)))
8795 (defun gnus-adjust-marked-articles (info)
8796 "Set all article lists and remove all marks that are no longer legal."
8797 (let* ((marked-lists (gnus-info-marks info))
8798 (active (gnus-active (gnus-info-group info)))
8801 (types gnus-article-mark-lists)
8802 (uncompressed '(score bookmark))
8803 marks var articles article mark)
8806 (setq marks (pop marked-lists))
8807 (set (setq var (intern (format "gnus-newsgroup-%s"
8808 (car (rassq (setq mark (car marks))
8810 (if (memq (car marks) uncompressed) (cdr marks)
8811 (gnus-uncompress-range (cdr marks))))
8813 (setq articles (symbol-value var))
8815 ;; All articles have to be subsets of the active articles.
8817 ;; Adjust "simple" lists.
8818 ((memq mark '(tick dormant expirable reply killed save))
8820 (when (or (< (setq article (pop articles)) min) (> article max))
8821 (set var (delq article (symbol-value var))))))
8823 ((memq mark '(score bookmark))
8825 (when (or (< (car (setq article (pop articles))) min)
8826 (> (car article) max))
8827 (set var (delq article (symbol-value var))))))))))
8829 (defun gnus-update-missing-marks (missing)
8830 "Go through the list of MISSING articles and remove them mark lists."
8832 (let ((types gnus-article-mark-lists)
8834 ;; Go through all types.
8836 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8837 (when (symbol-value var)
8838 ;; This list has articles. So we delete all missing articles
8842 (set var (delq (pop m) (symbol-value var)))))))))
8844 (defun gnus-update-marks ()
8845 "Enter the various lists of marked articles into the newsgroup info list."
8846 (let ((types gnus-article-mark-lists)
8847 (info (gnus-get-info gnus-newsgroup-name))
8848 (uncompressed '(score bookmark killed))
8849 type list newmarked symbol)
8851 ;; Add all marks lists that are non-nil to the list of marks lists.
8853 (setq type (pop types))
8854 (when (setq list (symbol-value
8856 (intern (format "gnus-newsgroup-%s"
8858 (push (cons (cdr type)
8859 (if (memq (cdr type) uncompressed) list
8860 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8863 ;; Enter these new marks into the info of the group.
8865 (setcar (nthcdr 3 info) newmarked)
8866 ;; Add the marks lists to the end of the info.
8868 (setcdr (nthcdr 2 info) (list newmarked))))
8870 ;; Cut off the end of the info if there's nothing else there.
8874 (when (nthcdr (decf i) info)
8875 (setcdr (nthcdr i info) nil)))))))
8877 (defun gnus-add-marked-articles (group type articles &optional info force)
8878 ;; Add ARTICLES of TYPE to the info of GROUP.
8879 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8880 ;; add, but replace marked articles of TYPE with ARTICLES.
8881 (let ((info (or info (gnus-get-info group)))
8882 (uncompressed '(score bookmark killed))
8885 (and (not (setq marked (nthcdr 3 info)))
8887 (setcdr (nthcdr 2 info)
8888 (list (list (cons type (gnus-compress-sequence
8890 (and (not (setq m (assq type (car marked))))
8893 (cons (cons type (gnus-compress-sequence articles t) )
8897 (setcar (nthcdr 3 info)
8898 (delq (assq type (car marked)) (car marked)))
8899 (setcdr m (gnus-compress-sequence articles t)))
8900 (setcdr m (gnus-compress-sequence
8901 (sort (nconc (gnus-uncompress-range (cdr m))
8902 (copy-sequence articles)) '<) t))))))
8904 (defun gnus-set-mode-line (where)
8905 "This function sets the mode line of the article or summary buffers.
8906 If WHERE is `summary', the summary mode line format will be used."
8907 ;; Is this mode line one we keep updated?
8908 (when (memq where gnus-updated-mode-lines)
8911 ;; We evaluate this in the summary buffer since these
8912 ;; variables are buffer-local to that buffer.
8913 (set-buffer gnus-summary-buffer)
8914 ;; We bind all these variables that are used in the `eval' form
8916 (let* ((mformat (symbol-value
8918 (format "gnus-%s-mode-line-format-spec" where))))
8919 (gnus-tmp-group-name gnus-newsgroup-name)
8920 (gnus-tmp-article-number (or gnus-current-article 0))
8921 (gnus-tmp-unread gnus-newsgroup-unreads)
8922 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8923 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8924 (gnus-tmp-unread-and-unselected
8925 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8926 (zerop gnus-tmp-unselected)) "")
8927 ((zerop gnus-tmp-unselected)
8928 (format "{%d more}" gnus-tmp-unread-and-unticked))
8929 (t (format "{%d(+%d) more}"
8930 gnus-tmp-unread-and-unticked
8931 gnus-tmp-unselected))))
8933 (if (and gnus-current-headers
8934 (vectorp gnus-current-headers))
8935 (gnus-mode-string-quote
8936 (mail-header-subject gnus-current-headers)) ""))
8938 gnus-tmp-header);; passed as argument to any user-format-funcs
8939 (setq mode-string (eval mformat))
8940 (setq max-len (max 4 (if gnus-mode-non-string-length
8942 gnus-mode-non-string-length)
8943 (length mode-string))))
8944 ;; We might have to chop a bit of the string off...
8945 (when (> (length mode-string) max-len)
8947 (concat (gnus-truncate-string mode-string (- max-len 3))
8949 ;; Pad the mode string a bit.
8950 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8951 ;; Update the mode line.
8952 (setq mode-line-buffer-identification (list mode-string))
8953 (set-buffer-modified-p t))))
8955 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8956 "Go through the HEADERS list and add all Xrefs to a hash table.
8957 The resulting hash table is returned, or nil if no Xrefs were found."
8958 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8959 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8960 (xref-hashtb (make-vector 63 0))
8961 start group entry number xrefs header)
8963 (setq header (pop headers))
8964 (when (and (setq xrefs (mail-header-xref header))
8965 (not (memq (setq number (mail-header-number header))
8968 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8969 (setq start (match-end 0))
8970 (setq group (if prefix
8971 (concat prefix (substring xrefs (match-beginning 1)
8973 (substring xrefs (match-beginning 1) (match-end 1))))
8975 (string-to-int (substring xrefs (match-beginning 2)
8977 (if (setq entry (gnus-gethash group xref-hashtb))
8978 (setcdr entry (cons number (cdr entry)))
8979 (gnus-sethash group (cons number nil) xref-hashtb)))))
8980 (and start xref-hashtb)))
8982 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8983 "Look through all the headers and mark the Xrefs as read."
8984 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8985 name entry info xref-hashtb idlist method nth4)
8987 (set-buffer gnus-group-buffer)
8988 (when (setq xref-hashtb
8989 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8992 (unless (string= from-newsgroup (setq name (symbol-name group)))
8993 (setq idlist (symbol-value group))
8994 ;; Dead groups are not updated.
8996 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8998 (if (stringp (setq nth4 (gnus-info-method info)))
8999 (setq nth4 (gnus-server-to-method nth4))))
9000 ;; Only do the xrefs if the group has the same
9001 ;; select method as the group we have just read.
9002 (or (gnus-methods-equal-p
9003 nth4 (gnus-find-method-for-group from-newsgroup))
9005 (equal nth4 (setq method (gnus-find-method-for-group
9007 (and (equal (car nth4) (car method))
9008 (equal (nth 1 nth4) (nth 1 method))))
9009 gnus-use-cross-reference
9010 (or (not (eq gnus-use-cross-reference t))
9012 ;; Only do cross-references on subscribed
9013 ;; groups, if that is what is wanted.
9014 (<= (gnus-info-level info) gnus-level-subscribed))
9015 (gnus-group-make-articles-read name idlist))))
9018 (defun gnus-group-make-articles-read (group articles)
9020 (entry (gnus-gethash group gnus-newsrc-hashtb))
9021 (info (nth 2 entry))
9022 (active (gnus-active group))
9024 ;; First peel off all illegal article numbers.
9026 (let ((ids articles)
9030 (if (and first (> id (cdr active)))
9032 ;; We'll end up in this situation in one particular
9033 ;; obscure situation. If you re-scan a group and get
9034 ;; a new article that is cross-posted to a different
9035 ;; group that has not been re-scanned, you might get
9036 ;; crossposted article that has a higher number than
9037 ;; Gnus believes possible. So we re-activate this
9038 ;; group as well. This might mean doing the
9039 ;; crossposting thingy will *increase* the number
9040 ;; of articles in some groups. Tsk, tsk.
9041 (setq active (or (gnus-activate-group group) active))))
9042 (if (or (> id (cdr active))
9043 (< id (car active)))
9044 (setq articles (delq id articles)))
9045 (setq ids (cdr ids)))))
9046 ;; If the read list is nil, we init it.
9048 (null (gnus-info-read info))
9050 (gnus-info-set-read info (cons 1 (1- (car active)))))
9051 ;; Then we add the read articles to the range.
9056 (gnus-info-read info) (setq articles (sort articles '<)))))
9057 ;; Then we have to re-compute how many unread
9058 ;; articles there are in this group.
9063 (setq num (- (1+ (cdr active)) (car active))))
9064 ((not (listp (cdr range)))
9065 (setq num (- (cdr active) (- (1+ (cdr range))
9069 (if (numberp (car range))
9071 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9072 (setq range (cdr range)))
9073 (setq num (- (cdr active) num))))
9074 ;; Update the number of unread articles.
9076 ;; Update the group buffer.
9077 (gnus-group-update-group group t)))))
9079 (defun gnus-methods-equal-p (m1 m2)
9080 (let ((m1 (or m1 gnus-select-method))
9081 (m2 (or m2 gnus-select-method)))
9083 (and (eq (car m1) (car m2))
9084 (or (not (memq 'address (assoc (symbol-name (car m1))
9085 gnus-valid-select-methods)))
9086 (equal (nth 1 m1) (nth 1 m2)))))))
9088 (defsubst gnus-header-value ()
9089 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9091 (defvar gnus-newsgroup-none-id 0)
9093 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9094 (let ((cur nntp-server-buffer)
9097 (save-excursion (set-buffer gnus-summary-buffer)
9098 gnus-newsgroup-dependencies)))
9099 headers id id-dep ref-dep end ref)
9101 (set-buffer nntp-server-buffer)
9102 (run-hooks 'gnus-parse-headers-hook)
9103 (let ((case-fold-search t)
9104 in-reply-to header p lines)
9105 (goto-char (point-min))
9106 ;; Search to the beginning of the next header. Error messages
9107 ;; do not begin with 2 or 3.
9108 (while (re-search-forward "^[23][0-9]+ " nil t)
9111 ;; This implementation of this function, with nine
9112 ;; search-forwards instead of the one re-search-forward and
9113 ;; a case (which basically was the old function) is actually
9114 ;; about twice as fast, even though it looks messier. You
9115 ;; can't have everything, I guess. Speed and elegance
9116 ;; doesn't always go hand in hand.
9125 (narrow-to-region (point)
9126 (or (and (search-forward "\n.\n" nil t)
9132 (if (search-forward "\nsubject: " nil t)
9133 (gnus-header-value) "(none)"))
9137 (if (search-forward "\nfrom: " nil t)
9138 (gnus-header-value) "(nobody)"))
9142 (if (search-forward "\ndate: " nil t)
9143 (gnus-header-value) ""))
9147 (if (search-forward "\nmessage-id: " nil t)
9148 (setq id (gnus-header-value))
9149 ;; If there was no message-id, we just fake one to make
9150 ;; subsequent routines simpler.
9151 (setq id (concat "none+"
9153 (setq gnus-newsgroup-none-id
9154 (1+ gnus-newsgroup-none-id)))))))
9158 (if (search-forward "\nreferences: " nil t)
9161 (setq end (match-end 0))
9167 (search-backward ">" end t)
9170 (search-backward "<" end t)
9172 ;; Get the references from the in-reply-to header if there
9173 ;; were no references and the in-reply-to header looks
9175 (if (and (search-forward "\nin-reply-to: " nil t)
9176 (setq in-reply-to (gnus-header-value))
9177 (string-match "<[^>]+>" in-reply-to))
9178 (setq ref (substring in-reply-to (match-beginning 0)
9186 (if (search-forward "\nlines: " nil t)
9187 (if (numberp (setq lines (read cur)))
9193 (and (search-forward "\nxref: " nil t)
9194 (gnus-header-value)))))
9195 ;; We do the threading while we read the headers. The
9196 ;; message-id and the last reference are both entered into
9197 ;; the same hash table. Some tippy-toeing around has to be
9198 ;; done in case an article has arrived before the article
9199 ;; which it refers to.
9200 (if (boundp (setq id-dep (intern id dependencies)))
9201 (if (and (car (symbol-value id-dep))
9203 ;; An article with this Message-ID has already
9204 ;; been seen, so we ignore this one, except we add
9205 ;; any additional Xrefs (in case the two articles
9206 ;; came from different servers).
9208 (mail-header-set-xref
9209 (car (symbol-value id-dep))
9210 (concat (or (mail-header-xref
9211 (car (symbol-value id-dep))) "")
9212 (or (mail-header-xref header) "")))
9214 (setcar (symbol-value id-dep) header))
9215 (set id-dep (list header)))
9217 (if (boundp (setq ref-dep (intern ref dependencies)))
9218 (setcdr (symbol-value ref-dep)
9219 (nconc (cdr (symbol-value ref-dep))
9220 (list (symbol-value id-dep))))
9221 (set ref-dep (list nil (symbol-value id-dep))))
9222 (setq headers (cons header headers)))
9223 (goto-char (point-max))
9225 (nreverse headers)))))
9227 ;; The following macros and functions were written by Felix Lee
9228 ;; <flee@cse.psu.edu>.
9230 (defmacro gnus-nov-read-integer ()
9232 (if (= (following-char) ?\t)
9234 (let ((num (condition-case nil (read buffer) (error nil))))
9235 (if (numberp num) num 0)))
9236 (or (eobp) (forward-char 1))))
9238 (defmacro gnus-nov-skip-field ()
9239 '(search-forward "\t" eol 'move))
9241 (defmacro gnus-nov-field ()
9242 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9244 ;; Goes through the xover lines and returns a list of vectors
9245 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9246 force-new dependencies)
9247 "Parse the news overview data in the server buffer, and return a
9248 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9249 ;; Get the Xref when the users reads the articles since most/some
9250 ;; NNTP servers do not include Xrefs when using XOVER.
9251 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9252 (let ((cur nntp-server-buffer)
9253 (dependencies (or dependencies gnus-newsgroup-dependencies))
9254 number headers header)
9256 (set-buffer nntp-server-buffer)
9257 ;; Allow the user to mangle the headers before parsing them.
9258 (run-hooks 'gnus-parse-headers-hook)
9259 (goto-char (point-min))
9260 (while (and sequence (not (eobp)))
9261 (setq number (read cur))
9262 (while (and sequence (< (car sequence) number))
9263 (setq sequence (cdr sequence)))
9265 (eq number (car sequence))
9267 (setq sequence (cdr sequence))
9269 (inline (gnus-nov-parse-line
9270 number dependencies force-new)))
9271 (setq headers (cons header headers)))))
9273 (setq headers (nreverse headers)))
9276 ;; This function has to be called with point after the article number
9277 ;; on the beginning of the line.
9278 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9280 (eol (gnus-point-at-eol))
9281 (buffer (current-buffer))
9282 header ref id id-dep ref-dep)
9284 ;; overview: [num subject from date id refs chars lines misc]
9285 (narrow-to-region (point) eol)
9286 (or (eobp) (forward-char))
9292 (gnus-nov-field) ; subject
9293 (gnus-nov-field) ; from
9294 (gnus-nov-field) ; date
9295 (setq id (or (gnus-nov-field)
9298 (setq none (1+ none)))))) ; id
9301 (let ((beg (point)))
9302 (search-forward "\t" eol)
9303 (if (search-backward ">" beg t)
9307 (search-backward "<" beg t)))
9309 (gnus-nov-field)) ; refs
9310 (gnus-nov-read-integer) ; chars
9311 (gnus-nov-read-integer) ; lines
9312 (if (= (following-char) ?\n)
9314 (gnus-nov-field)) ; misc
9317 (gnus-error 4 "Strange nov line")
9323 ;; We build the thread tree.
9325 (if (boundp (setq id-dep (intern id dependencies)))
9326 (if (and (car (symbol-value id-dep))
9328 ;; An article with this Message-ID has already been seen,
9329 ;; so we ignore this one, except we add any additional
9330 ;; Xrefs (in case the two articles came from different
9333 (mail-header-set-xref
9334 (car (symbol-value id-dep))
9335 (concat (or (mail-header-xref
9336 (car (symbol-value id-dep))) "")
9337 (or (mail-header-xref header) "")))
9339 (setcar (symbol-value id-dep) header))
9340 (set id-dep (list header))))
9343 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9344 (setcdr (symbol-value ref-dep)
9345 (nconc (cdr (symbol-value ref-dep))
9346 (list (symbol-value id-dep))))
9347 (set ref-dep (list nil (symbol-value id-dep))))))
9350 (defun gnus-article-get-xrefs ()
9351 "Fill in the Xref value in `gnus-current-headers', if necessary.
9352 This is meant to be called in `gnus-article-internal-prepare-hook'."
9353 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9354 gnus-current-headers)))
9355 (or (not gnus-use-cross-reference)
9357 (and (mail-header-xref headers)
9358 (not (string= (mail-header-xref headers) "")))
9359 (let ((case-fold-search t)
9362 (nnheader-narrow-to-headers)
9363 (goto-char (point-min))
9364 (if (or (and (eq (downcase (following-char)) ?x)
9365 (looking-at "Xref:"))
9366 (search-forward "\nXref:" nil t))
9368 (goto-char (1+ (match-end 0)))
9369 (setq xref (buffer-substring (point)
9370 (progn (end-of-line) (point))))
9371 (mail-header-set-xref headers xref))))))))
9373 (defun gnus-summary-insert-subject (id &optional old-header)
9374 "Find article ID and insert the summary line for that article."
9375 (let ((header (gnus-read-header id))
9376 (number (and (numberp id) id))
9379 ;; Rebuild the thread that this article is part of and go to the
9380 ;; article we have fetched.
9382 (when (setq pos (text-property-any
9383 (point-min) (point-max) 'gnus-number
9384 (mail-header-number old-header)))
9387 (gnus-data-remove (mail-header-number old-header))))
9389 (mail-header-set-number header (mail-header-number old-header)))
9390 (setq gnus-newsgroup-sparse
9391 (delq (mail-header-number header) gnus-newsgroup-sparse))
9392 (gnus-rebuild-thread (mail-header-id header))
9393 (gnus-summary-goto-subject (setq number (mail-header-number header))
9395 (when (and (numberp number)
9397 ;; We have to update the boundaries even if we can't fetch the
9398 ;; article if ID is a number -- so that the next `P' or `N'
9399 ;; command will fetch the previous (or next) article even
9400 ;; if the one we tried to fetch this time has been canceled.
9401 (and (> number gnus-newsgroup-end)
9402 (setq gnus-newsgroup-end number))
9403 (and (< number gnus-newsgroup-begin)
9404 (setq gnus-newsgroup-begin number))
9405 (setq gnus-newsgroup-unselected
9406 (delq number gnus-newsgroup-unselected)))
9407 ;; Report back a success?
9408 (and header (mail-header-number header))))
9410 (defun gnus-summary-work-articles (n)
9411 "Return a list of articles to be worked upon. The prefix argument,
9412 the list of process marked articles, and the current article will be
9413 taken into consideration."
9415 ((and n (numberp n))
9416 ;; A numerical prefix has been given.
9417 (let ((backward (< n 0))
9423 (push (setq article (gnus-summary-article-number))
9426 (gnus-summary-find-prev nil article)
9427 (gnus-summary-find-next nil article)))
9429 (nreverse articles)))
9430 ((and (boundp 'transient-mark-mode)
9433 ;; Work on the region between point and mark.
9434 (let ((max (max (point) (mark)))
9437 (goto-char (min (point) (mark)))
9440 (push (setq article (gnus-summary-article-number)) articles)
9441 (gnus-summary-find-next nil article)
9443 (nreverse articles))))
9444 (gnus-newsgroup-processable
9445 ;; There are process-marked articles present.
9446 (reverse gnus-newsgroup-processable))
9448 ;; Just return the current article.
9449 (list (gnus-summary-article-number)))))
9451 (defun gnus-summary-search-group (&optional backward use-level)
9452 "Search for next unread newsgroup.
9453 If optional argument BACKWARD is non-nil, search backward instead."
9455 (set-buffer gnus-group-buffer)
9456 (if (gnus-group-search-forward
9457 backward nil (if use-level (gnus-group-group-level) nil))
9458 (gnus-group-group-name))))
9460 (defun gnus-summary-best-group (&optional exclude-group)
9461 "Find the name of the best unread group.
9462 If EXCLUDE-GROUP, do not go to this group."
9464 (set-buffer gnus-group-buffer)
9466 (gnus-group-best-unread-group exclude-group))))
9468 (defun gnus-summary-find-next (&optional unread article backward)
9469 (if backward (gnus-summary-find-prev)
9470 (let* ((dummy (gnus-summary-article-intangible-p))
9471 (article (or article (gnus-summary-article-number)))
9472 (arts (gnus-data-find-list article))
9474 (when (and (not dummy)
9475 (or (not gnus-summary-check-current)
9477 (not (gnus-data-unread-p (car arts)))))
9478 (setq arts (cdr arts)))
9483 (when (gnus-data-unread-p (car arts))
9484 (setq result (car arts)
9486 (setq arts (cdr arts)))
9489 (goto-char (gnus-data-pos result))
9490 (gnus-data-number result)))))
9492 (defun gnus-summary-find-prev (&optional unread article)
9493 (let* ((article (or article (gnus-summary-article-number)))
9494 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9496 (when (or (not gnus-summary-check-current)
9498 (not (gnus-data-unread-p (car arts))))
9499 (setq arts (cdr arts)))
9504 (and (gnus-data-unread-p (car arts))
9505 (setq result (car arts)
9507 (setq arts (cdr arts)))
9511 (goto-char (gnus-data-pos result))
9512 (gnus-data-number result)))))
9514 (defun gnus-summary-find-subject (subject &optional unread backward article)
9515 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9516 (article (or article (gnus-summary-article-number)))
9517 (articles (gnus-data-list backward))
9518 (arts (gnus-data-find-list article articles))
9520 (when (or (not gnus-summary-check-current)
9522 (not (gnus-data-unread-p (car arts))))
9523 (setq arts (cdr arts)))
9525 (and (or (not unread)
9526 (gnus-data-unread-p (car arts)))
9527 (vectorp (gnus-data-header (car arts)))
9529 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9530 (setq result (car arts)
9532 (setq arts (cdr arts)))
9534 (goto-char (gnus-data-pos result))
9535 (gnus-data-number result))))
9537 (defun gnus-summary-search-forward (&optional unread subject backward)
9538 "Search forward for an article.
9539 If UNREAD, look for unread articles. If SUBJECT, look for
9540 articles with that subject. If BACKWARD, search backward instead."
9541 (cond (subject (gnus-summary-find-subject subject unread backward))
9542 (backward (gnus-summary-find-prev unread))
9543 (t (gnus-summary-find-next unread))))
9545 (defun gnus-recenter (&optional n)
9546 "Center point in window and redisplay frame.
9547 Also do horizontal recentering."
9549 (when (and gnus-auto-center-summary
9550 (not (eq gnus-auto-center-summary 'vertical)))
9551 (gnus-horizontal-recenter))
9554 (defun gnus-summary-recenter ()
9555 "Center point in the summary window.
9556 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9557 displayed, no centering will be performed."
9558 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9559 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9560 (let* ((top (cond ((< (window-height) 4) 0)
9561 ((< (window-height) 7) 1)
9563 (height (1- (window-height)))
9564 (bottom (save-excursion (goto-char (point-max))
9565 (forward-line (- height))
9567 (window (get-buffer-window (current-buffer))))
9568 ;; The user has to want it.
9569 (when gnus-auto-center-summary
9570 (when (get-buffer-window gnus-article-buffer)
9571 ;; Only do recentering when the article buffer is displayed,
9572 ;; Set the window start to either `bottom', which is the biggest
9573 ;; possible valid number, or the second line from the top,
9574 ;; whichever is the least.
9576 window (min bottom (save-excursion
9577 (forward-line (- top)) (point)))))
9578 ;; Do horizontal recentering while we're at it.
9579 (when (and (get-buffer-window (current-buffer) t)
9580 (not (eq gnus-auto-center-summary 'vertical)))
9581 (let ((selected (selected-window)))
9582 (select-window (get-buffer-window (current-buffer) t))
9583 (gnus-summary-position-point)
9584 (gnus-horizontal-recenter)
9585 (select-window selected))))))
9587 (defun gnus-horizontal-recenter ()
9588 "Recenter the current buffer horizontally."
9589 (if (< (current-column) (/ (window-width) 2))
9590 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9591 (let* ((orig (point))
9592 (end (window-end (get-buffer-window (current-buffer) t)))
9594 ;; Find the longest line currently displayed in the window.
9595 (goto-char (window-start))
9596 (while (and (not (eobp))
9599 (setq max (max max (current-column)))
9602 ;; Scroll horizontally to center (sort of) the point.
9603 (if (> max (window-width))
9605 (get-buffer-window (current-buffer) t)
9606 (min (- (current-column) (/ (window-width) 3))
9607 (+ 2 (- max (window-width)))))
9608 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9611 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9612 (defun gnus-short-group-name (group &optional levels)
9613 "Collapse GROUP name LEVELS."
9620 (while (string-match "\\." group skip)
9621 (setq skip (match-end 0)
9624 (if (string-match ":" group)
9625 (setq foreign (substring group 0 (match-end 0))
9626 group (substring group (match-end 0))))
9628 (if (and (string-match "\\." group)
9629 (> levels (- gnus-group-uncollapsed-levels 1)))
9630 (setq name (concat name (substring group 0 1))
9631 group (substring group (match-end 0))
9633 name (concat name "."))
9634 (setq name (concat foreign name group)
9638 (defun gnus-summary-jump-to-group (newsgroup)
9639 "Move point to NEWSGROUP in group mode buffer."
9640 ;; Keep update point of group mode buffer if visible.
9641 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9642 (save-window-excursion
9643 ;; Take care of tree window mode.
9644 (if (get-buffer-window gnus-group-buffer)
9645 (pop-to-buffer gnus-group-buffer))
9646 (gnus-group-jump-to-group newsgroup))
9648 ;; Take care of tree window mode.
9649 (if (get-buffer-window gnus-group-buffer)
9650 (pop-to-buffer gnus-group-buffer)
9651 (set-buffer gnus-group-buffer))
9652 (gnus-group-jump-to-group newsgroup))))
9654 ;; This function returns a list of article numbers based on the
9655 ;; difference between the ranges of read articles in this group and
9656 ;; the range of active articles.
9657 (defun gnus-list-of-unread-articles (group)
9658 (let* ((read (gnus-info-read (gnus-get-info group)))
9659 (active (gnus-active group))
9662 ;; If none are read, then all are unread.
9664 (setq first (car active))
9665 ;; If the range of read articles is a single range, then the
9666 ;; first unread article is the article after the last read
9667 ;; article. Sounds logical, doesn't it?
9668 (if (not (listp (cdr read)))
9669 (setq first (1+ (cdr read)))
9670 ;; `read' is a list of ranges.
9671 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9676 (while (< first nlast)
9677 (setq unread (cons first unread))
9678 (setq first (1+ first))))
9679 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9680 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9681 (setq read (cdr read)))))
9682 ;; And add the last unread articles.
9683 (while (<= first last)
9684 (setq unread (cons first unread))
9685 (setq first (1+ first)))
9686 ;; Return the list of unread articles.
9689 (defun gnus-list-of-read-articles (group)
9690 "Return a list of unread, unticked and non-dormant articles."
9691 (let* ((info (gnus-get-info group))
9692 (marked (gnus-info-marks info))
9693 (active (gnus-active group)))
9695 (gnus-set-difference
9696 (gnus-sorted-complement
9697 (gnus-uncompress-range active)
9698 (gnus-list-of-unread-articles group))
9700 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9701 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9703 ;; Various summary commands
9705 (defun gnus-summary-universal-argument (arg)
9706 "Perform any operation on all articles that are process/prefixed."
9708 (gnus-set-global-variables)
9709 (let ((articles (gnus-summary-work-articles arg))
9716 (substitute-command-keys
9717 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9720 (gnus-error 1 "Undefined key")
9723 (gnus-summary-goto-subject (setq article (pop articles)))
9724 (command-execute func)
9725 (gnus-summary-remove-process-mark article)))))
9726 (gnus-summary-position-point))
9728 (defun gnus-summary-toggle-truncation (&optional arg)
9729 "Toggle truncation of summary lines.
9730 With arg, turn line truncation on iff arg is positive."
9732 (setq truncate-lines
9733 (if (null arg) (not truncate-lines)
9734 (> (prefix-numeric-value arg) 0)))
9737 (defun gnus-summary-reselect-current-group (&optional all rescan)
9738 "Exit and then reselect the current newsgroup.
9739 The prefix argument ALL means to select all articles."
9741 (gnus-set-global-variables)
9742 (let ((current-subject (gnus-summary-article-number))
9743 (group gnus-newsgroup-name))
9744 (setq gnus-newsgroup-begin nil)
9746 ;; We have to adjust the point of group mode buffer because the
9747 ;; current point was moved to the next unread newsgroup by
9749 (gnus-summary-jump-to-group group)
9752 (gnus-group-get-new-news-this-group 1)))
9753 (gnus-group-read-group all t)
9754 (gnus-summary-goto-subject current-subject)))
9756 (defun gnus-summary-rescan-group (&optional all)
9757 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9759 (gnus-summary-reselect-current-group all t))
9761 (defun gnus-summary-update-info ()
9762 (let* ((group gnus-newsgroup-name))
9763 (when gnus-newsgroup-kill-headers
9764 (setq gnus-newsgroup-killed
9765 (gnus-compress-sequence
9767 (gnus-set-sorted-intersection
9768 (gnus-uncompress-range gnus-newsgroup-killed)
9769 (setq gnus-newsgroup-unselected
9770 (sort gnus-newsgroup-unselected '<)))
9771 (setq gnus-newsgroup-unreads
9772 (sort gnus-newsgroup-unreads '<))) t)))
9773 (unless (listp (cdr gnus-newsgroup-killed))
9774 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9775 (let ((headers gnus-newsgroup-headers))
9776 (run-hooks 'gnus-exit-group-hook)
9777 (unless gnus-save-score
9778 (setq gnus-newsgroup-scored nil))
9779 ;; Set the new ranges of read articles.
9780 (gnus-update-read-articles
9781 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9782 ;; Set the current article marks.
9784 ;; Do the cross-ref thing.
9785 (when gnus-use-cross-reference
9786 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9787 ;; Do adaptive scoring, and possibly save score files.
9788 (when gnus-newsgroup-adaptive
9789 (gnus-score-adaptive))
9790 (when gnus-use-scoring
9792 ;; Do not switch windows but change the buffer to work.
9793 (set-buffer gnus-group-buffer)
9794 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9795 (gnus-group-update-group group)))))
9797 (defun gnus-summary-exit (&optional temporary)
9798 "Exit reading current newsgroup, and then return to group selection mode.
9799 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9801 (gnus-set-global-variables)
9802 (gnus-kill-save-kill-buffer)
9803 (let* ((group gnus-newsgroup-name)
9804 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9806 (buf (current-buffer)))
9807 (run-hooks 'gnus-summary-prepare-exit-hook)
9808 ;; If we have several article buffers, we kill them at exit.
9809 (unless gnus-single-article-buffer
9810 (gnus-kill-buffer gnus-original-article-buffer)
9811 (setq gnus-article-current nil))
9812 (when gnus-use-cache
9813 (gnus-cache-possibly-remove-articles)
9814 (gnus-cache-save-buffers))
9815 (when gnus-use-trees
9816 (gnus-tree-close group))
9817 ;; Make all changes in this group permanent.
9819 (gnus-summary-update-info))
9820 (gnus-close-group group)
9821 ;; Make sure where I was, and go to next newsgroup.
9822 (set-buffer gnus-group-buffer)
9824 (gnus-group-jump-to-group group)
9825 (gnus-group-next-unread-group 1))
9826 (run-hooks 'gnus-summary-exit-hook)
9829 ;; If we have several article buffers, we kill them at exit.
9830 (unless gnus-single-article-buffer
9831 (gnus-kill-buffer gnus-article-buffer)
9832 (gnus-kill-buffer gnus-original-article-buffer)
9833 (setq gnus-article-current nil))
9835 (if (not gnus-kill-summary-on-exit)
9836 (gnus-deaden-summary)
9837 ;; We set all buffer-local variables to nil. It is unclear why
9838 ;; this is needed, but if we don't, buffer-local variables are
9839 ;; not garbage-collected, it seems. This would the lead to en
9840 ;; ever-growing Emacs.
9841 (gnus-summary-clear-local-variables)
9842 (when (get-buffer gnus-article-buffer)
9843 (bury-buffer gnus-article-buffer))
9844 ;; We clear the global counterparts of the buffer-local
9845 ;; variables as well, just to be on the safe side.
9846 (gnus-configure-windows 'group 'force)
9847 (gnus-summary-clear-local-variables)
9848 ;; Return to group mode buffer.
9849 (if (eq mode 'gnus-summary-mode)
9850 (gnus-kill-buffer buf)))
9851 (setq gnus-current-select-method gnus-select-method)
9852 (pop-to-buffer gnus-group-buffer)
9853 ;; Clear the current group name.
9854 (if (not quit-config)
9856 (gnus-group-jump-to-group group)
9857 (gnus-group-next-unread-group 1)
9858 (gnus-configure-windows 'group 'force))
9859 (if (not (buffer-name (car quit-config)))
9860 (gnus-configure-windows 'group 'force)
9861 (set-buffer (car quit-config))
9862 (and (eq major-mode 'gnus-summary-mode)
9863 (gnus-set-global-variables))
9864 (gnus-configure-windows (cdr quit-config))))
9866 (setq gnus-newsgroup-name nil)))))
9868 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9869 (defun gnus-summary-exit-no-update (&optional no-questions)
9870 "Quit reading current newsgroup without updating read article info."
9872 (gnus-set-global-variables)
9873 (let* ((group gnus-newsgroup-name)
9874 (quit-config (gnus-group-quit-config group)))
9875 (when (or no-questions
9877 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9878 ;; If we have several article buffers, we kill them at exit.
9879 (unless gnus-single-article-buffer
9880 (gnus-kill-buffer gnus-article-buffer)
9881 (gnus-kill-buffer gnus-original-article-buffer)
9882 (setq gnus-article-current nil))
9883 (if (not gnus-kill-summary-on-exit)
9884 (gnus-deaden-summary)
9885 (gnus-close-group group)
9886 (gnus-summary-clear-local-variables)
9887 (set-buffer gnus-group-buffer)
9888 (gnus-summary-clear-local-variables)
9889 (when (get-buffer gnus-summary-buffer)
9890 (kill-buffer gnus-summary-buffer)))
9891 (unless gnus-single-article-buffer
9892 (setq gnus-article-current nil))
9893 (when gnus-use-trees
9894 (gnus-tree-close group))
9895 (when (get-buffer gnus-article-buffer)
9896 (bury-buffer gnus-article-buffer))
9897 ;; Return to the group buffer.
9898 (gnus-configure-windows 'group 'force)
9899 ;; Clear the current group name.
9900 (setq gnus-newsgroup-name nil)
9901 (when (equal (gnus-group-group-name) group)
9902 (gnus-group-next-unread-group 1))
9904 (if (not (buffer-name (car quit-config)))
9905 (gnus-configure-windows 'group 'force)
9906 (set-buffer (car quit-config))
9907 (when (eq major-mode 'gnus-summary-mode)
9908 (gnus-set-global-variables))
9909 (gnus-configure-windows (cdr quit-config)))))))
9913 (defvar gnus-dead-summary-mode-map nil)
9915 (if gnus-dead-summary-mode-map
9917 (setq gnus-dead-summary-mode-map (make-keymap))
9918 (suppress-keymap gnus-dead-summary-mode-map)
9919 (substitute-key-definition
9920 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9921 (let ((keys '("\C-d" "\r" "\177")))
9923 (define-key gnus-dead-summary-mode-map
9924 (pop keys) 'gnus-summary-wake-up-the-dead))))
9926 (defvar gnus-dead-summary-mode nil
9927 "Minor mode for Gnus summary buffers.")
9929 (defun gnus-dead-summary-mode (&optional arg)
9930 "Minor mode for Gnus summary buffers."
9932 (when (eq major-mode 'gnus-summary-mode)
9933 (make-local-variable 'gnus-dead-summary-mode)
9934 (setq gnus-dead-summary-mode
9935 (if (null arg) (not gnus-dead-summary-mode)
9936 (> (prefix-numeric-value arg) 0)))
9937 (when gnus-dead-summary-mode
9938 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9939 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9940 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9941 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9942 minor-mode-map-alist)))))
9944 (defun gnus-deaden-summary ()
9945 "Make the current summary buffer into a dead summary buffer."
9946 ;; Kill any previous dead summary buffer.
9947 (when (and gnus-dead-summary
9948 (buffer-name gnus-dead-summary))
9950 (set-buffer gnus-dead-summary)
9951 (when gnus-dead-summary-mode
9952 (kill-buffer (current-buffer)))))
9953 ;; Make this the current dead summary.
9954 (setq gnus-dead-summary (current-buffer))
9955 (gnus-dead-summary-mode 1)
9956 (let ((name (buffer-name)))
9957 (when (string-match "Summary" name)
9959 (concat (substring name 0 (match-beginning 0)) "Dead "
9960 (substring name (match-beginning 0))) t))))
9962 (defun gnus-kill-or-deaden-summary (buffer)
9963 "Kill or deaden the summary BUFFER."
9964 (when (and (buffer-name buffer)
9965 (not gnus-single-article-buffer))
9968 (gnus-kill-buffer gnus-article-buffer)
9969 (gnus-kill-buffer gnus-original-article-buffer)))
9970 (cond (gnus-kill-summary-on-exit
9971 (when (and gnus-use-trees
9972 (and (get-buffer buffer)
9973 (buffer-name (get-buffer buffer))))
9975 (set-buffer (get-buffer buffer))
9976 (gnus-tree-close gnus-newsgroup-name)))
9977 (gnus-kill-buffer buffer))
9978 ((and (get-buffer buffer)
9979 (buffer-name (get-buffer buffer)))
9982 (gnus-deaden-summary)))))
9984 (defun gnus-summary-wake-up-the-dead (&rest args)
9985 "Wake up the dead summary buffer."
9987 (gnus-dead-summary-mode -1)
9988 (let ((name (buffer-name)))
9989 (when (string-match "Dead " name)
9991 (concat (substring name 0 (match-beginning 0))
9992 (substring name (match-end 0))) t)))
9993 (gnus-message 3 "This dead summary is now alive again"))
9995 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9996 (defun gnus-summary-fetch-faq (&optional faq-dir)
9997 "Fetch the FAQ for the current group.
9998 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10002 (if current-prefix-arg
10004 "Faq dir: " (and (listp gnus-group-faq-directory)
10005 gnus-group-faq-directory)))))
10006 (let (gnus-faq-buffer)
10007 (and (setq gnus-faq-buffer
10008 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10009 (gnus-configure-windows 'summary-faq))))
10011 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10012 (defun gnus-summary-describe-group (&optional force)
10013 "Describe the current newsgroup."
10015 (gnus-group-describe-group force gnus-newsgroup-name))
10017 (defun gnus-summary-describe-briefly ()
10018 "Describe summary mode commands briefly."
10021 (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")))
10023 ;; Walking around group mode buffer from summary mode.
10025 (defun gnus-summary-next-group (&optional no-article target-group backward)
10026 "Exit current newsgroup and then select next unread newsgroup.
10027 If prefix argument NO-ARTICLE is non-nil, no article is selected
10028 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10029 previous group instead."
10031 (gnus-set-global-variables)
10032 (let ((current-group gnus-newsgroup-name)
10033 (current-buffer (current-buffer))
10035 ;; First we semi-exit this group to update Xrefs and all variables.
10036 ;; We can't do a real exit, because the window conf must remain
10037 ;; the same in case the user is prompted for info, and we don't
10038 ;; want the window conf to change before that...
10039 (gnus-summary-exit t)
10040 (while (not entered)
10041 ;; Then we find what group we are supposed to enter.
10042 (set-buffer gnus-group-buffer)
10043 (gnus-group-jump-to-group current-group)
10046 (if (eq gnus-keep-same-level 'best)
10047 (gnus-summary-best-group gnus-newsgroup-name)
10048 (gnus-summary-search-group backward gnus-keep-same-level))))
10049 (if (not target-group)
10050 ;; There are no further groups, so we return to the group
10053 (gnus-message 5 "Returning to the group buffer")
10055 (set-buffer current-buffer)
10056 (gnus-summary-exit))
10057 ;; We try to enter the target group.
10058 (gnus-group-jump-to-group target-group)
10059 (let ((unreads (gnus-group-group-unread)))
10060 (if (and (or (eq t unreads)
10061 (and unreads (not (zerop unreads))))
10062 (gnus-summary-read-group
10063 target-group nil no-article current-buffer))
10065 (setq current-group target-group
10066 target-group nil)))))))
10068 (defun gnus-summary-prev-group (&optional no-article)
10069 "Exit current newsgroup and then select previous unread newsgroup.
10070 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10072 (gnus-summary-next-group no-article nil t))
10074 ;; Walking around summary lines.
10076 (defun gnus-summary-first-subject (&optional unread)
10077 "Go to the first unread subject.
10078 If UNREAD is non-nil, go to the first unread article.
10079 Returns the article selected or nil if there are no unread articles."
10084 ((null gnus-newsgroup-data)
10085 (gnus-message 3 "No articles in the group")
10087 ;; Pick the first article.
10089 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10090 (gnus-data-number (car gnus-newsgroup-data)))
10091 ;; No unread articles.
10092 ((null gnus-newsgroup-unreads)
10093 (gnus-message 3 "No more unread articles")
10095 ;; Find the first unread article.
10097 (let ((data gnus-newsgroup-data))
10099 (not (gnus-data-unread-p (car data))))
10100 (setq data (cdr data)))
10103 (goto-char (gnus-data-pos (car data)))
10104 (gnus-data-number (car data)))))))
10105 (gnus-summary-position-point)))
10107 (defun gnus-summary-next-subject (n &optional unread dont-display)
10108 "Go to next N'th summary line.
10109 If N is negative, go to the previous N'th subject line.
10110 If UNREAD is non-nil, only unread articles are selected.
10111 The difference between N and the actual number of steps taken is
10114 (let ((backward (< n 0))
10116 (while (and (> n 0)
10118 (gnus-summary-find-prev unread)
10119 (gnus-summary-find-next unread)))
10121 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10122 (if unread " unread" "")))
10123 (unless dont-display
10124 (gnus-summary-recenter)
10125 (gnus-summary-position-point))
10128 (defun gnus-summary-next-unread-subject (n)
10129 "Go to next N'th unread summary line."
10131 (gnus-summary-next-subject n t))
10133 (defun gnus-summary-prev-subject (n &optional unread)
10134 "Go to previous N'th summary line.
10135 If optional argument UNREAD is non-nil, only unread article is selected."
10137 (gnus-summary-next-subject (- n) unread))
10139 (defun gnus-summary-prev-unread-subject (n)
10140 "Go to previous N'th unread summary line."
10142 (gnus-summary-next-subject (- n) t))
10144 (defun gnus-summary-goto-subject (article &optional force silent)
10145 "Go the subject line of ARTICLE.
10146 If FORCE, also allow jumping to articles not currently shown."
10148 (data (gnus-data-find article)))
10149 ;; We read in the article if we have to.
10152 (gnus-summary-insert-subject article)
10153 (setq data (gnus-data-find article)))
10158 (gnus-message 3 "Can't find article %d" article))
10160 (goto-char (gnus-data-pos data))
10163 ;; Walking around summary lines with displaying articles.
10165 (defun gnus-summary-expand-window (&optional arg)
10166 "Make the summary buffer take up the entire Emacs frame.
10167 Given a prefix, will force an `article' buffer configuration."
10169 (gnus-set-global-variables)
10171 (gnus-configure-windows 'article 'force)
10172 (gnus-configure-windows 'summary 'force)))
10174 (defun gnus-summary-display-article (article &optional all-header)
10175 "Display ARTICLE in article buffer."
10176 (gnus-set-global-variables)
10180 (if gnus-summary-display-article-function
10181 (funcall gnus-summary-display-article-function article all-header)
10182 (gnus-article-prepare article all-header))
10183 (run-hooks 'gnus-select-article-hook)
10184 (unless (zerop gnus-current-article)
10185 (gnus-summary-goto-subject gnus-current-article))
10186 (gnus-summary-recenter)
10187 (when gnus-use-trees
10188 (gnus-possibly-generate-tree article)
10189 (gnus-highlight-selected-tree article))
10190 ;; Successfully display article.
10191 (gnus-article-set-window-start
10192 (cdr (assq article gnus-newsgroup-bookmarks))))))
10194 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10195 "Select the current article.
10196 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10197 non-nil, the article will be re-fetched even if it already present in
10198 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10200 ;; Make sure we are in the summary buffer to work around bbdb bug.
10201 (unless (eq major-mode 'gnus-summary-mode)
10202 (set-buffer gnus-summary-buffer))
10203 (let ((article (or article (gnus-summary-article-number)))
10204 (all-headers (not (not all-headers))) ;Must be T or NIL.
10205 gnus-summary-display-article-function
10208 (gnus-summary-article-pseudo-p article)
10209 (error "This is a pseudo-article."))
10212 (set-buffer gnus-summary-buffer)
10213 (if (or (and gnus-single-article-buffer
10214 (or (null gnus-current-article)
10215 (null gnus-article-current)
10216 (null (get-buffer gnus-article-buffer))
10217 (not (eq article (cdr gnus-article-current)))
10218 (not (equal (car gnus-article-current)
10219 gnus-newsgroup-name))))
10220 (and (not gnus-single-article-buffer)
10221 (or (null gnus-current-article)
10222 (not (eq gnus-current-article article))))
10224 ;; The requested article is different from the current article.
10226 (gnus-summary-display-article article all-headers)
10227 (setq did article))
10228 (if (or all-headers gnus-show-all-headers)
10229 (gnus-article-show-all-headers))
10232 (gnus-article-set-window-start
10233 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10235 (defun gnus-summary-set-current-mark (&optional current-mark)
10236 "Obsolete function."
10239 (defun gnus-summary-next-article (&optional unread subject backward push)
10240 "Select the next article.
10241 If UNREAD, only unread articles are selected.
10242 If SUBJECT, only articles with SUBJECT are selected.
10243 If BACKWARD, the previous article is selected instead of the next."
10245 (gnus-set-global-variables)
10247 ;; Is there such an article?
10248 ((and (gnus-summary-search-forward unread subject backward)
10249 (or (gnus-summary-display-article (gnus-summary-article-number))
10250 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10251 (gnus-summary-position-point))
10252 ;; If not, we try the first unread, if that is wanted.
10254 gnus-auto-select-same
10255 (or (gnus-summary-first-unread-article)
10256 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10257 (gnus-summary-position-point)
10258 (gnus-message 6 "Wrapped"))
10259 ;; Try to get next/previous article not displayed in this group.
10260 ((and gnus-auto-extend-newsgroup
10261 (not unread) (not subject))
10262 (gnus-summary-goto-article
10263 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10265 ;; Go to next/previous group.
10267 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10268 (gnus-summary-jump-to-group gnus-newsgroup-name))
10269 (let ((cmd last-command-char)
10271 (if (eq gnus-keep-same-level 'best)
10272 (gnus-summary-best-group gnus-newsgroup-name)
10273 (gnus-summary-search-group backward gnus-keep-same-level))))
10274 ;; For some reason, the group window gets selected. We change
10276 (select-window (get-buffer-window (current-buffer)))
10277 ;; Select next unread newsgroup automagically.
10279 ((not gnus-auto-select-next)
10280 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10281 ((or (eq gnus-auto-select-next 'quietly)
10282 (and (eq gnus-auto-select-next 'slightly-quietly)
10284 (and (eq gnus-auto-select-next 'almost-quietly)
10285 (gnus-summary-last-article-p)))
10287 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10288 (gnus-summary-exit)
10289 (gnus-message 7 "No more%s articles (%s)..."
10290 (if unread " unread" "")
10291 (if group (concat "selecting " group)
10293 (gnus-summary-next-group nil group backward)))
10295 (gnus-summary-walk-group-buffer
10296 gnus-newsgroup-name cmd unread backward)))))))
10298 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10299 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10300 (?\C-p (gnus-group-prev-unread-group 1))))
10301 keve key group ended)
10303 (set-buffer gnus-group-buffer)
10304 (gnus-summary-jump-to-group from-group)
10306 (if (eq gnus-keep-same-level 'best)
10307 (gnus-summary-best-group gnus-newsgroup-name)
10308 (gnus-summary-search-group backward gnus-keep-same-level))))
10311 5 "No more%s articles%s" (if unread " unread" "")
10313 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10314 (format " (Type %s for %s [%s])"
10315 (single-key-description cmd) group
10316 (car (gnus-gethash group gnus-newsrc-hashtb)))
10317 (format " (Type %s to exit %s)"
10318 (single-key-description cmd)
10319 gnus-newsgroup-name)))
10320 ;; Confirm auto selection.
10321 (setq key (car (setq keve (gnus-read-event-char))))
10324 ((assq key keystrokes)
10325 (let ((obuf (current-buffer)))
10326 (switch-to-buffer gnus-group-buffer)
10328 (gnus-group-jump-to-group group))
10329 (eval (cadr (assq key keystrokes)))
10330 (setq group (gnus-group-group-name))
10331 (switch-to-buffer obuf))
10334 (if (or (not group)
10335 (gnus-ephemeral-group-p gnus-newsgroup-name))
10336 (gnus-summary-exit)
10337 (gnus-summary-next-group nil group backward)))
10339 (push (cdr keve) unread-command-events))))))
10341 (defun gnus-read-event-char ()
10342 "Get the next event."
10343 (let ((event (read-event)))
10344 (cons (and (numberp event) event) event)))
10346 (defun gnus-summary-next-unread-article ()
10347 "Select unread article after current one."
10349 (gnus-summary-next-article t (and gnus-auto-select-same
10350 (gnus-summary-article-subject))))
10352 (defun gnus-summary-prev-article (&optional unread subject)
10353 "Select the article after the current one.
10354 If UNREAD is non-nil, only unread articles are selected."
10356 (gnus-summary-next-article unread subject t))
10358 (defun gnus-summary-prev-unread-article ()
10359 "Select unred article before current one."
10361 (gnus-summary-prev-article t (and gnus-auto-select-same
10362 (gnus-summary-article-subject))))
10364 (defun gnus-summary-next-page (&optional lines circular)
10365 "Show next page of the selected article.
10366 If at the end of the current article, select the next article.
10367 LINES says how many lines should be scrolled up.
10369 If CIRCULAR is non-nil, go to the start of the article instead of
10370 selecting the next article when reaching the end of the current
10373 (setq gnus-summary-buffer (current-buffer))
10374 (gnus-set-global-variables)
10375 (let ((article (gnus-summary-article-number))
10377 (gnus-configure-windows 'article)
10378 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10379 (if (and (eq gnus-summary-goto-unread 'never)
10380 (not (gnus-summary-last-article-p article)))
10381 (gnus-summary-next-article)
10382 (gnus-summary-next-unread-article))
10383 (if (or (null gnus-current-article)
10384 (null gnus-article-current)
10385 (/= article (cdr gnus-article-current))
10386 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10387 ;; Selected subject is different from current article's.
10388 (gnus-summary-display-article article)
10389 (gnus-eval-in-buffer-window
10390 gnus-article-buffer
10391 (setq endp (gnus-article-next-page lines)))
10394 (gnus-summary-beginning-of-article))
10396 (gnus-message 3 "End of message"))
10398 (if (and (eq gnus-summary-goto-unread 'never)
10399 (not (gnus-summary-last-article-p article)))
10400 (gnus-summary-next-article)
10401 (gnus-summary-next-unread-article)))))))
10402 (gnus-summary-recenter)
10403 (gnus-summary-position-point)))
10405 (defun gnus-summary-prev-page (&optional lines)
10406 "Show previous page of selected article.
10407 Argument LINES specifies lines to be scrolled down."
10409 (gnus-set-global-variables)
10410 (let ((article (gnus-summary-article-number)))
10411 (gnus-configure-windows 'article)
10412 (if (or (null gnus-current-article)
10413 (null gnus-article-current)
10414 (/= article (cdr gnus-article-current))
10415 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10416 ;; Selected subject is different from current article's.
10417 (gnus-summary-display-article article)
10418 (gnus-summary-recenter)
10419 (gnus-eval-in-buffer-window gnus-article-buffer
10420 (gnus-article-prev-page lines))))
10421 (gnus-summary-position-point))
10423 (defun gnus-summary-scroll-up (lines)
10424 "Scroll up (or down) one line current article.
10425 Argument LINES specifies lines to be scrolled up (or down if negative)."
10427 (gnus-set-global-variables)
10428 (gnus-configure-windows 'article)
10429 (gnus-summary-show-thread)
10430 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10431 (gnus-eval-in-buffer-window
10432 gnus-article-buffer
10434 (if (gnus-article-next-page lines)
10435 (gnus-message 3 "End of message")))
10437 (gnus-article-prev-page (- lines))))))
10438 (gnus-summary-recenter)
10439 (gnus-summary-position-point))
10441 (defun gnus-summary-next-same-subject ()
10442 "Select next article which has the same subject as current one."
10444 (gnus-set-global-variables)
10445 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10447 (defun gnus-summary-prev-same-subject ()
10448 "Select previous article which has the same subject as current one."
10450 (gnus-set-global-variables)
10451 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10453 (defun gnus-summary-next-unread-same-subject ()
10454 "Select next unread article which has the same subject as current one."
10456 (gnus-set-global-variables)
10457 (gnus-summary-next-article t (gnus-summary-article-subject)))
10459 (defun gnus-summary-prev-unread-same-subject ()
10460 "Select previous unread article which has the same subject as current one."
10462 (gnus-set-global-variables)
10463 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10465 (defun gnus-summary-first-unread-article ()
10466 "Select the first unread article.
10467 Return nil if there are no unread articles."
10469 (gnus-set-global-variables)
10471 (if (gnus-summary-first-subject t)
10473 (gnus-summary-show-thread)
10474 (gnus-summary-first-subject t)
10475 (gnus-summary-display-article (gnus-summary-article-number))))
10476 (gnus-summary-position-point)))
10478 (defun gnus-summary-best-unread-article ()
10479 "Select the unread article with the highest score."
10481 (gnus-set-global-variables)
10482 (let ((best -1000000)
10483 (data gnus-newsgroup-data)
10486 (and (gnus-data-unread-p (car data))
10488 (gnus-summary-article-score (gnus-data-number (car data))))
10491 article (gnus-data-number (car data))))
10492 (setq data (cdr data)))
10495 (gnus-summary-goto-article article)
10496 (error "No unread articles"))
10497 (gnus-summary-position-point))))
10499 (defun gnus-summary-last-subject ()
10500 "Go to the last displayed subject line in the group."
10501 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10503 (gnus-summary-goto-subject article))))
10505 (defun gnus-summary-goto-article (article &optional all-headers force)
10506 "Fetch ARTICLE and display it if it exists.
10507 If ALL-HEADERS is non-nil, no header lines are hidden."
10513 (mapcar (lambda (number) (list (int-to-string number)))
10514 gnus-newsgroup-limit)))
10518 (if (gnus-summary-goto-subject article force)
10519 (gnus-summary-display-article article all-headers)
10520 (gnus-message 4 "Couldn't go to article %s" article) nil)
10521 (gnus-summary-position-point)))
10523 (defun gnus-summary-goto-last-article ()
10524 "Go to the previously read article."
10527 (and gnus-last-article
10528 (gnus-summary-goto-article gnus-last-article))
10529 (gnus-summary-position-point)))
10531 (defun gnus-summary-pop-article (number)
10532 "Pop one article off the history and go to the previous.
10533 NUMBER articles will be popped off."
10536 (setq gnus-newsgroup-history
10537 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10539 (gnus-summary-goto-article (car to))
10540 (error "Article history empty")))
10541 (gnus-summary-position-point))
10543 ;; Summary commands and functions for limiting the summary buffer.
10545 (defun gnus-summary-limit-to-articles (n)
10546 "Limit the summary buffer to the next N articles.
10547 If not given a prefix, use the process marked articles instead."
10549 (gnus-set-global-variables)
10551 (let ((articles (gnus-summary-work-articles n)))
10552 (setq gnus-newsgroup-processable nil)
10553 (gnus-summary-limit articles))
10554 (gnus-summary-position-point)))
10556 (defun gnus-summary-pop-limit (&optional total)
10557 "Restore the previous limit.
10558 If given a prefix, remove all limits."
10560 (gnus-set-global-variables)
10562 (setq gnus-newsgroup-limits
10563 (list (mapcar (lambda (h) (mail-header-number h))
10564 gnus-newsgroup-headers))))
10565 (unless gnus-newsgroup-limits
10566 (error "No limit to pop"))
10568 (gnus-summary-limit nil 'pop)
10569 (gnus-summary-position-point)))
10571 (defun gnus-summary-limit-to-subject (subject &optional header)
10572 "Limit the summary buffer to articles that have subjects that match a regexp."
10573 (interactive "sRegexp: ")
10575 (setq header "subject"))
10576 (when (not (equal "" subject))
10578 (let ((articles (gnus-summary-find-matching
10579 (or header "subject") subject 'all)))
10580 (or articles (error "Found no matches for \"%s\"" subject))
10581 (gnus-summary-limit articles))
10582 (gnus-summary-position-point))))
10584 (defun gnus-summary-limit-to-author (from)
10585 "Limit the summary buffer to articles that have authors that match a regexp."
10586 (interactive "sRegexp: ")
10587 (gnus-summary-limit-to-subject from "from"))
10589 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10591 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10593 (defun gnus-summary-limit-to-unread (&optional all)
10594 "Limit the summary buffer to articles that are not marked as read.
10595 If ALL is non-nil, limit strictly to unread articles."
10598 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10599 (gnus-summary-limit-to-marks
10600 ;; Concat all the marks that say that an article is read and have
10602 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10603 gnus-killed-mark gnus-kill-file-mark
10604 gnus-low-score-mark gnus-expirable-mark
10605 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10608 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10609 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10611 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10612 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10613 If REVERSE, limit the summary buffer to articles that are not marked
10614 with MARKS. MARKS can either be a string of marks or a list of marks.
10615 Returns how many articles were removed."
10616 (interactive "sMarks: ")
10617 (gnus-set-global-variables)
10619 (let ((data gnus-newsgroup-data)
10620 (marks (if (listp marks) marks
10621 (append marks nil))) ; Transform to list.
10624 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10625 (memq (gnus-data-mark (car data)) marks))
10626 (setq articles (cons (gnus-data-number (car data)) articles)))
10627 (setq data (cdr data)))
10628 (gnus-summary-limit articles))
10629 (gnus-summary-position-point)))
10631 (defun gnus-summary-limit-to-score (&optional score)
10632 "Limit to articles with score at or above SCORE."
10634 (gnus-set-global-variables)
10635 (setq score (if score
10636 (prefix-numeric-value score)
10637 (or gnus-summary-default-score 0)))
10638 (let ((data gnus-newsgroup-data)
10641 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10643 (push (gnus-data-number (car data)) articles))
10644 (setq data (cdr data)))
10646 (gnus-summary-limit articles)
10647 (gnus-summary-position-point))))
10649 (defun gnus-summary-limit-include-dormant ()
10650 "Display all the hidden articles that are marked as dormant."
10652 (gnus-set-global-variables)
10653 (or gnus-newsgroup-dormant
10654 (error "There are no dormant articles in this group"))
10656 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10657 (gnus-summary-position-point)))
10659 (defun gnus-summary-limit-exclude-dormant ()
10660 "Hide all dormant articles."
10662 (gnus-set-global-variables)
10664 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10665 (gnus-summary-position-point)))
10667 (defun gnus-summary-limit-exclude-childless-dormant ()
10668 "Hide all dormant articles that have no children."
10670 (gnus-set-global-variables)
10671 (let ((data (gnus-data-list t))
10672 articles d children)
10673 ;; Find all articles that are either not dormant or have
10675 (while (setq d (pop data))
10676 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10677 (and (setq children
10678 (gnus-article-children (gnus-data-number d)))
10681 (when (memq (car children) articles)
10686 (push (gnus-data-number d) articles)))
10687 ;; Do the limiting.
10689 (gnus-summary-limit articles)
10690 (gnus-summary-position-point))))
10692 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10693 "Mark all unread excluded articles as read.
10694 If ALL, mark even excluded ticked and dormants as read."
10696 (let ((articles (gnus-sorted-complement
10698 (mapcar (lambda (h) (mail-header-number h))
10699 gnus-newsgroup-headers)
10701 (sort gnus-newsgroup-limit '<)))
10703 (setq gnus-newsgroup-unreads nil)
10705 (setq gnus-newsgroup-dormant nil
10706 gnus-newsgroup-marked nil
10707 gnus-newsgroup-reads
10709 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10710 gnus-newsgroup-reads))
10711 (while (setq article (pop articles))
10712 (unless (or (memq article gnus-newsgroup-dormant)
10713 (memq article gnus-newsgroup-marked))
10714 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10716 (defun gnus-summary-limit (articles &optional pop)
10718 ;; We pop the previous limit off the stack and use that.
10719 (setq articles (car gnus-newsgroup-limits)
10720 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10721 ;; We use the new limit, so we push the old limit on the stack.
10722 (setq gnus-newsgroup-limits
10723 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10725 (setq gnus-newsgroup-limit articles)
10726 (let ((total (length gnus-newsgroup-data))
10727 (data (gnus-data-find-list (gnus-summary-article-number)))
10729 ;; This will do all the work of generating the new summary buffer
10730 ;; according to the new limit.
10731 (gnus-summary-prepare)
10732 ;; Hide any threads, possibly.
10733 (and gnus-show-threads
10734 gnus-thread-hide-subtree
10735 (gnus-summary-hide-all-threads))
10736 ;; Try to return to the article you were at, or one in the
10739 ;; We try to find some article after the current one.
10741 (and (gnus-summary-goto-subject
10742 (gnus-data-number (car data)) nil t)
10745 (setq data (cdr data))))
10747 ;; If there is no data, that means that we were after the last
10748 ;; article. The same goes when we can't find any articles
10749 ;; after the current one.
10751 (goto-char (point-max))
10752 (gnus-summary-find-prev)))
10753 ;; We return how many articles were removed from the summary
10754 ;; buffer as a result of the new limit.
10755 (- total (length gnus-newsgroup-data))))
10757 (defsubst gnus-cut-thread (thread)
10758 "Go forwards in the thread until we find an article that we want to display."
10759 (when (eq gnus-fetch-old-headers 'some)
10760 ;; Deal with old-fetched headers.
10762 (memq (mail-header-number (car thread))
10763 gnus-newsgroup-ancient)
10764 (<= (length (cdr thread)) 1))
10765 (setq thread (cadr thread))))
10766 ;; Deal with sparse threads.
10767 (when (or (eq gnus-build-sparse-threads 'some)
10768 (eq gnus-build-sparse-threads 'more))
10770 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10771 (= (length (cdr thread)) 1))
10772 (setq thread (cadr thread))))
10775 (defun gnus-cut-threads (threads)
10776 "Cut off all uninteresting articles from the beginning of threads."
10777 (when (or (eq gnus-fetch-old-headers 'some)
10778 (eq gnus-build-sparse-threads 'some)
10779 (eq gnus-build-sparse-threads 'more))
10780 (let ((th threads))
10782 (setcar th (gnus-cut-thread (car th)))
10783 (setq th (cdr th)))))
10784 ;; Remove nixed out threads.
10785 (delq nil threads))
10787 (defun gnus-summary-initial-limit (&optional show-if-empty)
10788 "Figure out what the initial limit is supposed to be on group entry.
10789 This entails weeding out unwanted dormants, low-scored articles,
10790 fetch-old-headers verbiage, and so on."
10791 ;; Most groups have nothing to remove.
10792 (if (or gnus-inhibit-limiting
10793 (and (null gnus-newsgroup-dormant)
10794 (not (eq gnus-fetch-old-headers 'some))
10795 (null gnus-summary-expunge-below)
10796 (not (eq gnus-build-sparse-threads 'some))
10797 (not (eq gnus-build-sparse-threads 'more))
10798 (null gnus-thread-expunge-below)
10799 (not gnus-use-nocem)))
10801 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10802 (setq gnus-newsgroup-limit nil)
10805 (unless (car (symbol-value node))
10806 ;; These threads have no parents -- they are roots.
10807 (let ((nodes (cdr (symbol-value node)))
10810 (if (and gnus-thread-expunge-below
10811 (< (gnus-thread-total-score (car nodes))
10812 gnus-thread-expunge-below))
10813 (gnus-expunge-thread (pop nodes))
10814 (setq thread (pop nodes))
10815 (gnus-summary-limit-children thread))))))
10816 gnus-newsgroup-dependencies)
10817 ;; If this limitation resulted in an empty group, we might
10818 ;; pop the previous limit and use it instead.
10819 (when (and (not gnus-newsgroup-limit)
10821 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10822 gnus-newsgroup-limit))
10824 (defun gnus-summary-limit-children (thread)
10825 "Return 1 if this subthread is visible and 0 if it is not."
10826 ;; First we get the number of visible children to this thread. This
10827 ;; is done by recursing down the thread using this function, so this
10828 ;; will really go down to a leaf article first, before slowly
10829 ;; working its way up towards the root.
10833 (apply '+ (mapcar 'gnus-summary-limit-children
10836 (number (mail-header-number (car thread)))
10839 ;; If this article is dormant and has absolutely no visible
10840 ;; children, then this article isn't visible.
10841 (and (memq number gnus-newsgroup-dormant)
10843 ;; If this is a "fetch-old-headered" and there is only one
10844 ;; visible child (or less), then we don't want this article.
10845 (and (eq gnus-fetch-old-headers 'some)
10846 (memq number gnus-newsgroup-ancient)
10848 ;; If this is a sparsely inserted article with no children,
10849 ;; we don't want it.
10850 (and (eq gnus-build-sparse-threads 'some)
10851 (memq number gnus-newsgroup-sparse)
10853 ;; If we use expunging, and this article is really
10854 ;; low-scored, then we don't want this article.
10855 (when (and gnus-summary-expunge-below
10857 (or (cdr (assq number gnus-newsgroup-scored))
10858 gnus-summary-default-score))
10859 gnus-summary-expunge-below))
10860 ;; We increase the expunge-tally here, but that has
10861 ;; nothing to do with the limits, really.
10862 (incf gnus-newsgroup-expunged-tally)
10863 ;; We also mark as read here, if that's wanted.
10864 (when (and gnus-summary-mark-below
10865 (< score gnus-summary-mark-below))
10866 (setq gnus-newsgroup-unreads
10867 (delq number gnus-newsgroup-unreads))
10868 (if gnus-newsgroup-auto-expire
10869 (push number gnus-newsgroup-expirable)
10870 (push (cons number gnus-low-score-mark)
10871 gnus-newsgroup-reads)))
10873 (and gnus-use-nocem
10874 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10875 ;; Nope, invisible article.
10877 ;; Ok, this article is to be visible, so we add it to the limit
10879 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10882 (defun gnus-expunge-thread (thread)
10883 "Mark all articles in THREAD as read."
10884 (let* ((number (mail-header-number (car thread))))
10885 (incf gnus-newsgroup-expunged-tally)
10886 ;; We also mark as read here, if that's wanted.
10887 (setq gnus-newsgroup-unreads
10888 (delq number gnus-newsgroup-unreads))
10889 (if gnus-newsgroup-auto-expire
10890 (push number gnus-newsgroup-expirable)
10891 (push (cons number gnus-low-score-mark)
10892 gnus-newsgroup-reads)))
10893 ;; Go recursively through all subthreads.
10894 (mapcar 'gnus-expunge-thread (cdr thread)))
10896 ;; Summary article oriented commands
10898 (defun gnus-summary-refer-parent-article (n)
10899 "Refer parent article N times.
10900 The difference between N and the number of articles fetched is returned."
10902 (gnus-set-global-variables)
10906 (let* ((header (gnus-summary-article-header))
10908 ;; If we try to find the parent of the currently
10909 ;; displayed article, then we take a look at the actual
10910 ;; References header, since this is slightly more
10911 ;; reliable than the References field we got from the
10913 (if (and (eq (mail-header-number header)
10914 (cdr gnus-article-current))
10915 (equal gnus-newsgroup-name
10916 (car gnus-article-current)))
10918 (set-buffer gnus-original-article-buffer)
10919 (nnheader-narrow-to-headers)
10921 (message-fetch-field "references")
10923 ;; It's not the current article, so we take a bet on
10924 ;; the value we got from the server.
10925 (mail-header-references header))))
10926 (if (setq ref (or ref (mail-header-references header)))
10927 (or (gnus-summary-refer-article (gnus-parent-id ref))
10928 (gnus-message 1 "Couldn't find parent"))
10929 (gnus-message 1 "No references in article %d"
10930 (gnus-summary-article-number))
10933 (gnus-summary-position-point)
10936 (defun gnus-summary-refer-references ()
10937 "Fetch all articles mentioned in the References header.
10938 Return how many articles were fetched."
10940 (gnus-set-global-variables)
10941 (let ((ref (mail-header-references (gnus-summary-article-header)))
10942 (current (gnus-summary-article-number))
10944 ;; For each Message-ID in the References header...
10945 (while (string-match "<[^>]*>" ref)
10947 ;; ... fetch that article.
10948 (gnus-summary-refer-article
10949 (prog1 (match-string 0 ref)
10950 (setq ref (substring ref (match-end 0))))))
10951 (gnus-summary-goto-subject current)
10952 (gnus-summary-position-point)
10955 (defun gnus-summary-refer-article (message-id)
10956 "Fetch an article specified by MESSAGE-ID."
10957 (interactive "sMessage-ID: ")
10958 (when (and (stringp message-id)
10959 (not (zerop (length message-id))))
10960 ;; Construct the correct Message-ID if necessary.
10961 ;; Suggested by tale@pawl.rpi.edu.
10962 (unless (string-match "^<" message-id)
10963 (setq message-id (concat "<" message-id)))
10964 (unless (string-match ">$" message-id)
10965 (setq message-id (concat message-id ">")))
10966 (let ((header (car (gnus-gethash message-id
10967 gnus-newsgroup-dependencies))))
10969 ;; The article is present in the buffer, to we just go to it.
10970 (gnus-summary-goto-article (mail-header-number header) nil t)
10971 ;; We fetch the article
10972 (let ((gnus-override-method
10973 (and (gnus-news-group-p gnus-newsgroup-name)
10974 gnus-refer-article-method))
10976 ;; Start the special refer-article method, if necessary.
10977 (when (and gnus-refer-article-method
10978 (gnus-news-group-p gnus-newsgroup-name))
10979 (gnus-check-server gnus-refer-article-method))
10980 ;; Fetch the header, and display the article.
10981 (if (setq number (gnus-summary-insert-subject message-id))
10982 (gnus-summary-select-article nil nil nil number)
10983 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10985 (defun gnus-summary-enter-digest-group (&optional force)
10986 "Enter a digest group based on the current article."
10988 (gnus-set-global-variables)
10989 (gnus-summary-select-article)
10990 (let ((name (format "%s-%d"
10991 (gnus-group-prefixed-name
10992 gnus-newsgroup-name (list 'nndoc ""))
10993 gnus-current-article))
10994 (ogroup gnus-newsgroup-name)
10995 (case-fold-search t)
10996 (buf (current-buffer))
10999 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11000 (insert-buffer-substring gnus-original-article-buffer)
11002 (goto-char (point-min))
11003 (or (search-forward "\n\n" nil t) (point)))
11004 (goto-char (point-min))
11005 (delete-matching-lines "^\\(Path\\):\\|^From ")
11008 (if (gnus-group-read-ephemeral-group
11009 name `(nndoc ,name (nndoc-address
11011 (nndoc-article-type ,(if force 'digest 'guess))) t)
11012 ;; Make all postings to this group go to the parent group.
11013 (nconc (gnus-info-params (gnus-get-info name))
11014 (list (cons 'to-group ogroup)))
11015 ;; Couldn't select this doc group.
11016 (switch-to-buffer buf)
11017 (gnus-set-global-variables)
11018 (gnus-configure-windows 'summary)
11019 (gnus-message 3 "Article couldn't be entered?"))
11020 (kill-buffer dig))))
11022 (defun gnus-summary-isearch-article (&optional regexp-p)
11023 "Do incremental search forward on the current article.
11024 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11026 (gnus-set-global-variables)
11027 (gnus-summary-select-article)
11028 (gnus-configure-windows 'article)
11029 (gnus-eval-in-buffer-window
11030 gnus-article-buffer
11031 (goto-char (point-min))
11032 (isearch-forward regexp-p)))
11034 (defun gnus-summary-search-article-forward (regexp &optional backward)
11035 "Search for an article containing REGEXP forward.
11036 If BACKWARD, search backward instead."
11039 (format "Search article %s (regexp%s): "
11040 (if current-prefix-arg "backward" "forward")
11041 (if gnus-last-search-regexp
11042 (concat ", default " gnus-last-search-regexp)
11044 current-prefix-arg))
11045 (gnus-set-global-variables)
11046 (if (string-equal regexp "")
11047 (setq regexp (or gnus-last-search-regexp ""))
11048 (setq gnus-last-search-regexp regexp))
11049 (if (gnus-summary-search-article regexp backward)
11050 (gnus-article-set-window-start
11051 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
11052 (error "Search failed: \"%s\"" regexp)))
11054 (defun gnus-summary-search-article-backward (regexp)
11055 "Search for an article containing REGEXP backward."
11058 (format "Search article backward (regexp%s): "
11059 (if gnus-last-search-regexp
11060 (concat ", default " gnus-last-search-regexp)
11062 (gnus-summary-search-article-forward regexp 'backward))
11064 (defun gnus-summary-search-article (regexp &optional backward)
11065 "Search for an article containing REGEXP.
11066 Optional argument BACKWARD means do search for backward.
11067 `gnus-select-article-hook' is not called during the search."
11068 (let ((gnus-select-article-hook nil) ;Disable hook.
11069 (gnus-article-display-hook nil)
11070 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11073 're-search-backward 're-search-forward))
11074 (sum (current-buffer))
11076 ;; Hidden thread subtrees must be searched, too.
11077 (gnus-summary-show-all-threads)
11078 (gnus-summary-select-article)
11079 (set-buffer gnus-article-buffer)
11081 (gnus-message 7 "Searching article: %d..." gnus-current-article)
11083 (re-search-backward regexp nil t)
11084 (re-search-forward regexp nil t))
11085 ;; We found the regexp.
11087 (setq found 'found)
11088 (beginning-of-line)
11090 (get-buffer-window (current-buffer))
11092 ;; We didn't find it, so we go to the next article.
11094 (if (not (if backward (gnus-summary-find-prev)
11095 (gnus-summary-find-next)))
11096 ;; No more articles.
11098 ;; Select the next article and adjust point.
11099 (gnus-summary-select-article)
11100 (set-buffer gnus-article-buffer)
11102 (goto-char (if backward (point-max) (point-min))))))
11104 ;; Return whether we found the regexp.
11105 (eq found 'found)))
11107 (defun gnus-summary-find-matching (header regexp &optional backward unread
11109 "Return a list of all articles that match REGEXP on HEADER.
11110 The search stars on the current article and goes forwards unless
11111 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11112 If UNREAD is non-nil, only unread articles will
11113 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11114 in the comparisons."
11115 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11116 (gnus-data-find-list
11117 (gnus-summary-article-number) (gnus-data-list backward))))
11118 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11119 (case-fold-search (not not-case-fold))
11121 (or (fboundp (intern (concat "mail-header-" header)))
11122 (error "%s is not a valid header" header))
11124 (setq d (car data))
11125 (and (or (not unread) ; We want all articles...
11126 (gnus-data-unread-p d)) ; Or just unreads.
11127 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11128 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11129 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11130 (setq data (cdr data)))
11131 (nreverse articles)))
11133 (defun gnus-summary-execute-command (header regexp command &optional backward)
11134 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11135 If HEADER is an empty string (or nil), the match is done on the entire
11136 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11138 (list (let ((completion-ignore-case t))
11141 (mapcar (lambda (string) (list string))
11142 '("Number" "Subject" "From" "Lines" "Date"
11143 "Message-ID" "Xref" "References" "Body"))
11144 nil 'require-match))
11145 (read-string "Regexp: ")
11146 (read-key-sequence "Command: ")
11147 current-prefix-arg))
11148 (when (equal header "Body")
11150 (gnus-set-global-variables)
11151 ;; Hidden thread subtrees must be searched as well.
11152 (gnus-summary-show-all-threads)
11153 ;; We don't want to change current point nor window configuration.
11155 (save-window-excursion
11156 (gnus-message 6 "Executing %s..." (key-description command))
11157 ;; We'd like to execute COMMAND interactively so as to give arguments.
11158 (gnus-execute header regexp
11159 `(lambda () (call-interactively ',(key-binding command)))
11161 (gnus-message 6 "Executing %s...done" (key-description command)))))
11163 (defun gnus-summary-beginning-of-article ()
11164 "Scroll the article back to the beginning."
11166 (gnus-set-global-variables)
11167 (gnus-summary-select-article)
11168 (gnus-configure-windows 'article)
11169 (gnus-eval-in-buffer-window
11170 gnus-article-buffer
11172 (goto-char (point-min))
11173 (and gnus-break-pages (gnus-narrow-to-page))))
11175 (defun gnus-summary-end-of-article ()
11176 "Scroll to the end of the article."
11178 (gnus-set-global-variables)
11179 (gnus-summary-select-article)
11180 (gnus-configure-windows 'article)
11181 (gnus-eval-in-buffer-window
11182 gnus-article-buffer
11184 (goto-char (point-max))
11186 (and gnus-break-pages (gnus-narrow-to-page))))
11188 (defun gnus-summary-show-article (&optional arg)
11189 "Force re-fetching of the current article.
11190 If ARG (the prefix) is non-nil, show the raw article without any
11191 article massaging functions being run."
11193 (gnus-set-global-variables)
11195 ;; Select the article the normal way.
11196 (gnus-summary-select-article nil 'force)
11197 ;; Bind the article treatment functions to nil.
11198 (let ((gnus-have-all-headers t)
11199 gnus-article-display-hook
11200 gnus-article-prepare-hook
11203 (gnus-summary-select-article nil 'force)))
11204 (gnus-summary-goto-subject gnus-current-article)
11205 ; (gnus-configure-windows 'article)
11206 (gnus-summary-position-point))
11208 (defun gnus-summary-verbose-headers (&optional arg)
11209 "Toggle permanent full header display.
11210 If ARG is a positive number, turn header display on.
11211 If ARG is a negative number, turn header display off."
11213 (gnus-set-global-variables)
11214 (gnus-summary-toggle-header arg)
11215 (setq gnus-show-all-headers
11216 (cond ((or (not (numberp arg))
11218 (not gnus-show-all-headers))
11222 (defun gnus-summary-toggle-header (&optional arg)
11223 "Show the headers if they are hidden, or hide them if they are shown.
11224 If ARG is a positive number, show the entire header.
11225 If ARG is a negative number, hide the unwanted header lines."
11227 (gnus-set-global-variables)
11229 (set-buffer gnus-article-buffer)
11230 (let* ((buffer-read-only nil)
11231 (inhibit-point-motion-hooks t)
11232 (hidden (text-property-any
11233 (goto-char (point-min)) (search-forward "\n\n")
11236 (goto-char (point-min))
11237 (when (search-forward "\n\n" nil t)
11238 (delete-region (point-min) (1- (point))))
11239 (goto-char (point-min))
11241 (set-buffer gnus-original-article-buffer)
11242 (goto-char (point-min))
11243 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11244 (insert-buffer-substring gnus-original-article-buffer 1 e)
11245 (let ((gnus-inhibit-hiding t))
11246 (run-hooks 'gnus-article-display-hook))
11247 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11248 (gnus-article-hide-headers)))))
11250 (defun gnus-summary-show-all-headers ()
11251 "Make all header lines visible."
11253 (gnus-set-global-variables)
11254 (gnus-article-show-all-headers))
11256 (defun gnus-summary-toggle-mime (&optional arg)
11257 "Toggle MIME processing.
11258 If ARG is a positive number, turn MIME processing on."
11260 (gnus-set-global-variables)
11261 (setq gnus-show-mime
11262 (if (null arg) (not gnus-show-mime)
11263 (> (prefix-numeric-value arg) 0)))
11264 (gnus-summary-select-article t 'force))
11266 (defun gnus-summary-caesar-message (&optional arg)
11267 "Caesar rotate the current article by 13.
11268 The numerical prefix specifies how manu places to rotate each letter
11271 (gnus-set-global-variables)
11272 (gnus-summary-select-article)
11273 (let ((mail-header-separator ""))
11274 (gnus-eval-in-buffer-window
11275 gnus-article-buffer
11278 (let ((start (window-start)))
11279 (news-caesar-buffer-body arg)
11280 (set-window-start (get-buffer-window (current-buffer)) start))))))
11282 (defun gnus-summary-stop-page-breaking ()
11283 "Stop page breaking in the current article."
11285 (gnus-set-global-variables)
11286 (gnus-summary-select-article)
11287 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11289 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11290 "Move the current article to a different newsgroup.
11291 If N is a positive number, move the N next articles.
11292 If N is a negative number, move the N previous articles.
11293 If N is nil and any articles have been marked with the process mark,
11294 move those articles instead.
11295 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11296 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11297 re-spool using this method.
11299 For this function to work, both the current newsgroup and the
11300 newsgroup that you want to move to have to support the `request-move'
11301 and `request-accept' functions."
11303 (unless action (setq action 'move))
11304 (gnus-set-global-variables)
11305 ;; Check whether the source group supports the required functions.
11306 (cond ((and (eq action 'move)
11307 (not (gnus-check-backend-function
11308 'request-move-article gnus-newsgroup-name)))
11309 (error "The current group does not support article moving"))
11310 ((and (eq action 'crosspost)
11311 (not (gnus-check-backend-function
11312 'request-replace-article gnus-newsgroup-name)))
11313 (error "The current group does not support article editing")))
11314 (let ((articles (gnus-summary-work-articles n))
11315 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11316 (names '((move "Move" "Moving")
11317 (copy "Copy" "Copying")
11318 (crosspost "Crosspost" "Crossposting")))
11319 (copy-buf (save-excursion
11320 (nnheader-set-temp-buffer " *copy article*")))
11321 art-group to-method new-xref article to-groups)
11322 (unless (assq action names)
11323 (error "Unknown action %s" action))
11324 ;; Read the newsgroup name.
11325 (when (and (not to-newsgroup)
11326 (not select-method))
11328 (gnus-read-move-group-name
11329 (cadr (assq action names))
11330 (symbol-value (intern (format "gnus-current-%s-group" action)))
11332 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11333 (setq to-method (or select-method
11334 (gnus-find-method-for-group to-newsgroup)))
11335 ;; Check the method we are to move this article to...
11336 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11337 (error "%s does not support article copying" (car to-method)))
11338 (or (gnus-check-server to-method)
11339 (error "Can't open server %s" (car to-method)))
11340 (gnus-message 6 "%s to %s: %s..."
11341 (caddr (assq action names))
11342 (or (car select-method) to-newsgroup) articles)
11344 (setq article (pop articles))
11348 ;; Move the article.
11350 (gnus-request-move-article
11351 article ; Article to move
11352 gnus-newsgroup-name ; From newsgrouo
11353 (nth 1 (gnus-find-method-for-group
11354 gnus-newsgroup-name)) ; Server
11355 (list 'gnus-request-accept-article
11356 to-newsgroup (list 'quote select-method)
11357 (not articles)) ; Accept form
11358 (not articles))) ; Only save nov last time
11359 ;; Copy the article.
11362 (set-buffer copy-buf)
11363 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11364 (gnus-request-accept-article
11365 to-newsgroup select-method (not articles))))
11366 ;; Crosspost the article.
11367 ((eq action 'crosspost)
11368 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11369 (setq new-xref (concat gnus-newsgroup-name ":" article))
11370 (if (and xref (not (string= xref "")))
11372 (when (string-match "^Xref: " xref)
11373 (setq xref (substring xref (match-end 0))))
11374 (setq new-xref (concat xref " " new-xref)))
11375 (setq new-xref (concat (system-name) " " new-xref)))
11377 (set-buffer copy-buf)
11378 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11379 (nnheader-replace-header "xref" new-xref)
11380 (gnus-request-accept-article
11381 to-newsgroup select-method (not articles)))))))
11382 (if (not art-group)
11383 (gnus-message 1 "Couldn't %s article %s"
11384 (cadr (assq action names)) article)
11387 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11389 (gnus-group-prefixed-name
11392 (gnus-find-method-for-group to-newsgroup)))
11393 gnus-newsrc-hashtb)))
11394 (info (nth 2 entry))
11395 (to-group (gnus-info-group info)))
11396 ;; Update the group that has been moved to.
11398 (memq action '(move copy)))
11399 (unless (member to-group to-groups)
11400 (push to-group to-groups))
11402 (unless (memq article gnus-newsgroup-unreads)
11403 (gnus-info-set-read
11404 info (gnus-add-to-range (gnus-info-read info)
11405 (list (cdr art-group)))))
11407 ;; Copy any marks over to the new group.
11408 (let ((marks gnus-article-mark-lists)
11409 (to-article (cdr art-group)))
11411 ;; See whether the article is to be put in the cache.
11412 (when gnus-use-cache
11413 (gnus-cache-possibly-enter-article
11414 to-group to-article
11415 (let ((header (copy-sequence
11416 (gnus-summary-article-header article))))
11417 (mail-header-set-number header to-article)
11419 (memq article gnus-newsgroup-marked)
11420 (memq article gnus-newsgroup-dormant)
11421 (memq article gnus-newsgroup-unreads)))
11424 (when (memq article (symbol-value
11425 (intern (format "gnus-newsgroup-%s"
11427 ;; If the other group is the same as this group,
11428 ;; then we have to add the mark to the list.
11429 (when (equal to-group gnus-newsgroup-name)
11430 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11433 (intern (format "gnus-newsgroup-%s"
11435 ;; Copy mark to other group.
11436 (gnus-add-marked-articles
11437 to-group (cdar marks) (list to-article) info))
11438 (setq marks (cdr marks)))))
11440 ;; Update the Xref header in this article to point to
11441 ;; the new crossposted article we have just created.
11442 (when (eq action 'crosspost)
11444 (set-buffer copy-buf)
11445 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11446 (nnheader-replace-header
11447 "xref" (concat new-xref " " (gnus-group-prefixed-name
11448 (car art-group) to-method)
11449 ":" (cdr art-group)))
11450 (gnus-request-replace-article
11451 article gnus-newsgroup-name (current-buffer)))))
11453 (gnus-summary-goto-subject article)
11454 (when (eq action 'move)
11455 (gnus-summary-mark-article article gnus-canceled-mark)))
11456 (gnus-summary-remove-process-mark article))
11457 ;; Re-activate all groups that have been moved to.
11459 (gnus-activate-group (pop to-groups)))
11461 (gnus-kill-buffer copy-buf)
11462 (gnus-summary-position-point)
11463 (gnus-set-mode-line 'summary)))
11465 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11466 "Move the current article to a different newsgroup.
11467 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11468 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11469 re-spool using this method."
11471 (gnus-summary-move-article n nil select-method 'copy))
11473 (defun gnus-summary-crosspost-article (&optional n)
11474 "Crosspost the current article to some other group."
11476 (gnus-summary-move-article n nil nil 'crosspost))
11478 (defvar gnus-summary-respool-default-method nil
11479 "Default method for respooling an article.
11480 If nil, use to the current newsgroup method.")
11482 (defun gnus-summary-respool-article (&optional n method)
11483 "Respool the current article.
11484 The article will be squeezed through the mail spooling process again,
11485 which means that it will be put in some mail newsgroup or other
11486 depending on `nnmail-split-methods'.
11487 If N is a positive number, respool the N next articles.
11488 If N is a negative number, respool the N previous articles.
11489 If N is nil and any articles have been marked with the process mark,
11490 respool those articles instead.
11492 Respooling can be done both from mail groups and \"real\" newsgroups.
11493 In the former case, the articles in question will be moved from the
11494 current group into whatever groups they are destined to. In the
11495 latter case, they will be copied into the relevant groups."
11497 (list current-prefix-arg
11498 (let* ((methods (gnus-methods-using 'respool))
11500 (symbol-name (or gnus-summary-respool-default-method
11501 (car (gnus-find-method-for-group
11502 gnus-newsgroup-name)))))
11504 (gnus-completing-read
11505 methname "What backend do you want to use when? "
11506 methods nil t nil 'gnus-method-history))
11509 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11510 (list (intern method) ""))
11514 (cdr (completing-read
11516 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11517 (gnus-set-global-variables)
11519 (error "No method given for respooling"))
11520 (if (assoc (symbol-name
11521 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11522 (gnus-methods-using 'respool))
11523 (gnus-summary-move-article n nil method)
11524 (gnus-summary-copy-article n nil method)))
11526 (defun gnus-summary-import-article (file)
11527 "Import a random file into a mail newsgroup."
11528 (interactive "fImport file: ")
11529 (gnus-set-global-variables)
11530 (let ((group gnus-newsgroup-name)
11531 (now (current-time))
11533 (or (gnus-check-backend-function 'request-accept-article group)
11534 (error "%s does not support article importing" group))
11535 (or (file-readable-p file)
11536 (not (file-regular-p file))
11537 (error "Can't read %s" file))
11539 (set-buffer (get-buffer-create " *import file*"))
11540 (buffer-disable-undo (current-buffer))
11542 (insert-file-contents file)
11543 (goto-char (point-min))
11544 (unless (nnheader-article-p)
11545 ;; This doesn't look like an article, so we fudge some headers.
11546 (setq atts (file-attributes file)
11547 lines (count-lines (point-min) (point-max)))
11548 (insert "From: " (read-string "From: ") "\n"
11549 "Subject: " (read-string "Subject: ") "\n"
11550 "Date: " (timezone-make-date-arpa-standard
11551 (current-time-string (nth 5 atts))
11552 (current-time-zone now)
11553 (current-time-zone now)) "\n"
11554 "Message-ID: " (gnus-inews-message-id) "\n"
11555 "Lines: " (int-to-string lines) "\n"
11556 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11557 (gnus-request-accept-article group nil t)
11558 (kill-buffer (current-buffer)))))
11560 (defun gnus-summary-expire-articles (&optional now)
11561 "Expire all articles that are marked as expirable in the current group."
11563 (gnus-set-global-variables)
11564 (when (gnus-check-backend-function
11565 'request-expire-articles gnus-newsgroup-name)
11566 ;; This backend supports expiry.
11567 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11568 (expirable (if total
11569 (gnus-list-of-read-articles gnus-newsgroup-name)
11570 (setq gnus-newsgroup-expirable
11571 (sort gnus-newsgroup-expirable '<))))
11572 (expiry-wait (if now 'immediate
11573 (gnus-group-get-parameter
11574 gnus-newsgroup-name 'expiry-wait)))
11577 ;; There are expirable articles in this group, so we run them
11578 ;; through the expiry process.
11579 (gnus-message 6 "Expiring articles...")
11580 ;; The list of articles that weren't expired is returned.
11582 (let ((nnmail-expiry-wait-function nil)
11583 (nnmail-expiry-wait expiry-wait))
11584 (setq es (gnus-request-expire-articles
11585 expirable gnus-newsgroup-name)))
11586 (setq es (gnus-request-expire-articles
11587 expirable gnus-newsgroup-name)))
11588 (or total (setq gnus-newsgroup-expirable es))
11589 ;; We go through the old list of expirable, and mark all
11590 ;; really expired articles as nonexistent.
11591 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11592 (let ((gnus-use-cache nil))
11594 (unless (memq (car expirable) es)
11595 (when (gnus-data-find (car expirable))
11596 (gnus-summary-mark-article
11597 (car expirable) gnus-canceled-mark)))
11598 (setq expirable (cdr expirable)))))
11599 (gnus-message 6 "Expiring articles...done")))))
11601 (defun gnus-summary-expire-articles-now ()
11602 "Expunge all expirable articles in the current group.
11603 This means that *all* articles that are marked as expirable will be
11604 deleted forever, right now."
11606 (gnus-set-global-variables)
11607 (or gnus-expert-user
11609 "Are you really, really, really sure you want to delete all these messages? ")
11611 (gnus-summary-expire-articles t))
11613 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11614 (defun gnus-summary-delete-article (&optional n)
11615 "Delete the N next (mail) articles.
11616 This command actually deletes articles. This is not a marking
11617 command. The article will disappear forever from your life, never to
11619 If N is negative, delete backwards.
11620 If N is nil and articles have been marked with the process mark,
11621 delete these instead."
11623 (gnus-set-global-variables)
11624 (or (gnus-check-backend-function 'request-expire-articles
11625 gnus-newsgroup-name)
11626 (error "The current newsgroup does not support article deletion."))
11627 ;; Compute the list of articles to delete.
11628 (let ((articles (gnus-summary-work-articles n))
11630 (if (and gnus-novice-user
11631 (not (gnus-y-or-n-p
11632 (format "Do you really want to delete %s forever? "
11633 (if (> (length articles) 1)
11634 (format "these %s articles" (length articles))
11635 "this article")))))
11637 ;; Delete the articles.
11638 (setq not-deleted (gnus-request-expire-articles
11639 articles gnus-newsgroup-name 'force))
11641 (gnus-summary-remove-process-mark (car articles))
11642 ;; The backend might not have been able to delete the article
11644 (or (memq (car articles) not-deleted)
11645 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11646 (setq articles (cdr articles))))
11647 (gnus-summary-position-point)
11648 (gnus-set-mode-line 'summary)
11651 (defun gnus-summary-edit-article (&optional force)
11652 "Enter into a buffer and edit the current article.
11653 This will have permanent effect only in mail groups.
11654 If FORCE is non-nil, allow editing of articles even in read-only
11658 (set-buffer gnus-summary-buffer)
11659 (gnus-set-global-variables)
11660 (when (and (not force)
11661 (gnus-group-read-only-p))
11662 (error "The current newsgroup does not support article editing."))
11663 (gnus-summary-select-article t nil t)
11664 (gnus-configure-windows 'article)
11665 (select-window (get-buffer-window gnus-article-buffer))
11666 (gnus-message 6 "C-c C-c to end edits")
11667 (setq buffer-read-only nil)
11669 (use-local-map (copy-keymap (current-local-map)))
11670 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11671 (buffer-enable-undo)
11673 (goto-char (point-min))
11674 (search-forward "\n\n" nil t)))
11676 (defun gnus-summary-edit-article-done ()
11677 "Make edits to the current article permanent."
11679 (if (gnus-group-read-only-p)
11681 (gnus-summary-edit-article-postpone)
11683 1 "The current newsgroup does not support article editing."))
11684 (let ((buf (format "%s" (buffer-string))))
11687 (if (not (gnus-request-replace-article
11688 (cdr gnus-article-current) (car gnus-article-current)
11690 (error "Couldn't replace article.")
11691 (gnus-article-mode)
11692 (use-local-map gnus-article-mode-map)
11693 (setq buffer-read-only t)
11694 (buffer-disable-undo (current-buffer))
11695 (gnus-configure-windows 'summary)
11696 (gnus-summary-update-article (cdr gnus-article-current))
11697 (when gnus-use-cache
11698 (gnus-cache-update-article
11699 (cdr gnus-article-current) (car gnus-article-current)))
11700 (when gnus-keep-backlog
11701 (gnus-backlog-remove-article
11702 (car gnus-article-current) (cdr gnus-article-current))))
11704 (when (get-buffer gnus-original-article-buffer)
11705 (set-buffer gnus-original-article-buffer)
11706 (setq gnus-original-article nil)))
11707 (setq gnus-article-current nil
11708 gnus-current-article nil)
11709 (run-hooks 'gnus-article-display-hook)
11710 (and (gnus-visual-p 'summary-highlight 'highlight)
11711 (run-hooks 'gnus-visual-mark-article-hook)))))
11713 (defun gnus-summary-edit-article-postpone ()
11714 "Postpone changes to the current article."
11716 (gnus-article-mode)
11717 (use-local-map gnus-article-mode-map)
11718 (setq buffer-read-only t)
11719 (buffer-disable-undo (current-buffer))
11720 (gnus-configure-windows 'summary)
11721 (and (gnus-visual-p 'summary-highlight 'highlight)
11722 (run-hooks 'gnus-visual-mark-article-hook)))
11724 (defun gnus-summary-respool-query ()
11725 "Query where the respool algorithm would put this article."
11727 (gnus-set-global-variables)
11728 (gnus-summary-select-article)
11730 (set-buffer gnus-article-buffer)
11732 (goto-char (point-min))
11733 (search-forward "\n\n")
11734 (narrow-to-region (point-min) (point))
11735 (pp-eval-expression
11736 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11738 ;; Summary score commands.
11740 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11742 (defun gnus-summary-raise-score (n)
11743 "Raise the score of the current article by N."
11745 (gnus-set-global-variables)
11746 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11748 (defun gnus-summary-set-score (n)
11749 "Set the score of the current article to N."
11751 (gnus-set-global-variables)
11753 (gnus-summary-show-thread)
11754 (let ((buffer-read-only nil))
11756 (gnus-summary-update-mark
11757 (if (= n (or gnus-summary-default-score 0)) ?
11758 (if (< n (or gnus-summary-default-score 0))
11759 gnus-score-below-mark gnus-score-over-mark)) 'score))
11760 (let* ((article (gnus-summary-article-number))
11761 (score (assq article gnus-newsgroup-scored)))
11762 (if score (setcdr score n)
11763 (setq gnus-newsgroup-scored
11764 (cons (cons article n) gnus-newsgroup-scored))))
11765 (gnus-summary-update-line)))
11767 (defun gnus-summary-current-score ()
11768 "Return the score of the current article."
11770 (gnus-set-global-variables)
11771 (gnus-message 1 "%s" (gnus-summary-article-score)))
11773 ;; Summary marking commands.
11775 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11776 "Mark articles which has the same subject as read, and then select the next.
11777 If UNMARK is positive, remove any kind of mark.
11778 If UNMARK is negative, tick articles."
11780 (gnus-set-global-variables)
11782 (setq unmark (prefix-numeric-value unmark)))
11784 (gnus-summary-mark-same-subject
11785 (gnus-summary-article-subject) unmark)))
11786 ;; Select next unread article. If auto-select-same mode, should
11787 ;; select the first unread article.
11788 (gnus-summary-next-article t (and gnus-auto-select-same
11789 (gnus-summary-article-subject)))
11790 (gnus-message 7 "%d article%s marked as %s"
11791 count (if (= count 1) " is" "s are")
11792 (if unmark "unread" "read"))))
11794 (defun gnus-summary-kill-same-subject (&optional unmark)
11795 "Mark articles which has the same subject as read.
11796 If UNMARK is positive, remove any kind of mark.
11797 If UNMARK is negative, tick articles."
11799 (gnus-set-global-variables)
11801 (setq unmark (prefix-numeric-value unmark)))
11803 (gnus-summary-mark-same-subject
11804 (gnus-summary-article-subject) unmark)))
11805 ;; If marked as read, go to next unread subject.
11807 ;; Go to next unread subject.
11808 (gnus-summary-next-subject 1 t))
11809 (gnus-message 7 "%d articles are marked as %s"
11810 count (if unmark "unread" "read"))))
11812 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11813 "Mark articles with same SUBJECT as read, and return marked number.
11814 If optional argument UNMARK is positive, remove any kinds of marks.
11815 If optional argument UNMARK is negative, mark articles as unread instead."
11819 ((null unmark) ; Mark as read.
11822 (gnus-summary-mark-article-as-read gnus-killed-mark)
11823 (gnus-summary-show-thread) t)
11824 (gnus-summary-find-subject subject))
11825 (setq count (1+ count))))
11826 ((> unmark 0) ; Tick.
11829 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11830 (gnus-summary-show-thread) t)
11831 (gnus-summary-find-subject subject))
11832 (setq count (1+ count))))
11833 (t ; Mark as unread.
11836 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11837 (gnus-summary-show-thread) t)
11838 (gnus-summary-find-subject subject))
11839 (setq count (1+ count)))))
11840 (gnus-set-mode-line 'summary)
11841 ;; Return the number of marked articles.
11844 (defun gnus-summary-mark-as-processable (n &optional unmark)
11845 "Set the process mark on the next N articles.
11846 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11847 the process mark instead. The difference between N and the actual
11848 number of articles marked is returned."
11850 (gnus-set-global-variables)
11851 (let ((backward (< n 0))
11856 (gnus-summary-remove-process-mark
11857 (gnus-summary-article-number))
11858 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11859 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11861 (if (/= 0 n) (gnus-message 7 "No more articles"))
11862 (gnus-summary-recenter)
11863 (gnus-summary-position-point)
11866 (defun gnus-summary-unmark-as-processable (n)
11867 "Remove the process mark from the next N articles.
11868 If N is negative, mark backward instead. The difference between N and
11869 the actual number of articles marked is returned."
11871 (gnus-set-global-variables)
11872 (gnus-summary-mark-as-processable n t))
11874 (defun gnus-summary-unmark-all-processable ()
11875 "Remove the process mark from all articles."
11877 (gnus-set-global-variables)
11879 (while gnus-newsgroup-processable
11880 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11881 (gnus-summary-position-point))
11883 (defun gnus-summary-mark-as-expirable (n)
11884 "Mark N articles forward as expirable.
11885 If N is negative, mark backward instead. The difference between N and
11886 the actual number of articles marked is returned."
11888 (gnus-set-global-variables)
11889 (gnus-summary-mark-forward n gnus-expirable-mark))
11891 (defun gnus-summary-mark-article-as-replied (article)
11892 "Mark ARTICLE replied and update the summary line."
11893 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11894 (let ((buffer-read-only nil))
11895 (when (gnus-summary-goto-subject article)
11896 (gnus-summary-update-secondary-mark article))))
11898 (defun gnus-summary-set-bookmark (article)
11899 "Set a bookmark in current article."
11900 (interactive (list (gnus-summary-article-number)))
11901 (gnus-set-global-variables)
11902 (if (or (not (get-buffer gnus-article-buffer))
11903 (not gnus-current-article)
11904 (not gnus-article-current)
11905 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11906 (error "No current article selected"))
11907 ;; Remove old bookmark, if one exists.
11908 (let ((old (assq article gnus-newsgroup-bookmarks)))
11909 (if old (setq gnus-newsgroup-bookmarks
11910 (delq old gnus-newsgroup-bookmarks))))
11911 ;; Set the new bookmark, which is on the form
11912 ;; (article-number . line-number-in-body).
11913 (setq gnus-newsgroup-bookmarks
11917 (set-buffer gnus-article-buffer)
11921 (goto-char (point-min))
11922 (search-forward "\n\n" nil t)
11925 gnus-newsgroup-bookmarks))
11926 (gnus-message 6 "A bookmark has been added to the current article."))
11928 (defun gnus-summary-remove-bookmark (article)
11929 "Remove the bookmark from the current article."
11930 (interactive (list (gnus-summary-article-number)))
11931 (gnus-set-global-variables)
11932 ;; Remove old bookmark, if one exists.
11933 (let ((old (assq article gnus-newsgroup-bookmarks)))
11936 (setq gnus-newsgroup-bookmarks
11937 (delq old gnus-newsgroup-bookmarks))
11938 (gnus-message 6 "Removed bookmark."))
11939 (gnus-message 6 "No bookmark in current article."))))
11941 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11942 (defun gnus-summary-mark-as-dormant (n)
11943 "Mark N articles forward as dormant.
11944 If N is negative, mark backward instead. The difference between N and
11945 the actual number of articles marked is returned."
11947 (gnus-set-global-variables)
11948 (gnus-summary-mark-forward n gnus-dormant-mark))
11950 (defun gnus-summary-set-process-mark (article)
11951 "Set the process mark on ARTICLE and update the summary line."
11952 (setq gnus-newsgroup-processable
11954 (delq article gnus-newsgroup-processable)))
11955 (when (gnus-summary-goto-subject article)
11956 (gnus-summary-show-thread)
11957 (gnus-summary-update-secondary-mark article)))
11959 (defun gnus-summary-remove-process-mark (article)
11960 "Remove the process mark from ARTICLE and update the summary line."
11961 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11962 (when (gnus-summary-goto-subject article)
11963 (gnus-summary-show-thread)
11964 (gnus-summary-update-secondary-mark article)))
11966 (defun gnus-summary-set-saved-mark (article)
11967 "Set the process mark on ARTICLE and update the summary line."
11968 (push article gnus-newsgroup-saved)
11969 (when (gnus-summary-goto-subject article)
11970 (gnus-summary-update-secondary-mark article)))
11972 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11973 "Mark N articles as read forwards.
11974 If N is negative, mark backwards instead.
11975 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11977 The difference between N and the actual number of articles marked is
11980 (gnus-set-global-variables)
11981 (let ((backward (< n 0))
11982 (gnus-summary-goto-unread
11983 (and gnus-summary-goto-unread
11984 (not (eq gnus-summary-goto-unread 'never))
11985 (not (memq mark (list gnus-unread-mark
11986 gnus-ticked-mark gnus-dormant-mark)))))
11988 (mark (or mark gnus-del-mark)))
11989 (while (and (> n 0)
11990 (gnus-summary-mark-article nil mark no-expire)
11991 (zerop (gnus-summary-next-subject
11993 (and gnus-summary-goto-unread
11994 (not (eq gnus-summary-goto-unread 'never)))
11997 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11998 (gnus-summary-recenter)
11999 (gnus-summary-position-point)
12000 (gnus-set-mode-line 'summary)
12003 (defun gnus-summary-mark-article-as-read (mark)
12004 "Mark the current article quickly as read with MARK."
12005 (let ((article (gnus-summary-article-number)))
12006 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12007 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12008 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12009 (setq gnus-newsgroup-reads
12010 (cons (cons article mark) gnus-newsgroup-reads))
12011 ;; Possibly remove from cache, if that is used.
12012 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12013 ;; Allow the backend to change the mark.
12014 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12015 ;; Check for auto-expiry.
12016 (when (and gnus-newsgroup-auto-expire
12017 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12018 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12019 (= mark gnus-ancient-mark)
12020 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12021 (setq mark gnus-expirable-mark)
12022 (push article gnus-newsgroup-expirable))
12023 ;; Set the mark in the buffer.
12024 (gnus-summary-update-mark mark 'unread)
12027 (defun gnus-summary-mark-article-as-unread (mark)
12028 "Mark the current article quickly as unread with MARK."
12029 (let ((article (gnus-summary-article-number)))
12030 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12031 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12032 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12033 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12034 (cond ((= mark gnus-ticked-mark)
12035 (push article gnus-newsgroup-marked))
12036 ((= mark gnus-dormant-mark)
12037 (push article gnus-newsgroup-dormant))
12039 (push article gnus-newsgroup-unreads)))
12040 (setq gnus-newsgroup-reads
12041 (delq (assq article gnus-newsgroup-reads)
12042 gnus-newsgroup-reads))
12044 ;; See whether the article is to be put in the cache.
12045 (and gnus-use-cache
12046 (vectorp (gnus-summary-article-header article))
12048 (gnus-cache-possibly-enter-article
12049 gnus-newsgroup-name article
12050 (gnus-summary-article-header article)
12051 (= mark gnus-ticked-mark)
12052 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12055 (gnus-summary-update-mark mark 'unread)
12058 (defun gnus-summary-mark-article (&optional article mark no-expire)
12059 "Mark ARTICLE with MARK. MARK can be any character.
12060 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12061 `??' (dormant) and `?E' (expirable).
12062 If MARK is nil, then the default character `?D' is used.
12063 If ARTICLE is nil, then the article on the current line will be
12065 ;; The mark might be a string.
12066 (and (stringp mark)
12067 (setq mark (aref mark 0)))
12068 ;; If no mark is given, then we check auto-expiring.
12069 (and (not no-expire)
12070 gnus-newsgroup-auto-expire
12072 (and (numberp mark)
12073 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12074 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12075 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12076 (setq mark gnus-expirable-mark))
12077 (let* ((mark (or mark gnus-del-mark))
12078 (article (or article (gnus-summary-article-number))))
12079 (or article (error "No article on current line"))
12080 (if (or (= mark gnus-unread-mark)
12081 (= mark gnus-ticked-mark)
12082 (= mark gnus-dormant-mark))
12083 (gnus-mark-article-as-unread article mark)
12084 (gnus-mark-article-as-read article mark))
12086 ;; See whether the article is to be put in the cache.
12087 (and gnus-use-cache
12088 (not (= mark gnus-canceled-mark))
12089 (vectorp (gnus-summary-article-header article))
12091 (gnus-cache-possibly-enter-article
12092 gnus-newsgroup-name article
12093 (gnus-summary-article-header article)
12094 (= mark gnus-ticked-mark)
12095 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12097 (if (gnus-summary-goto-subject article nil t)
12098 (let ((buffer-read-only nil))
12099 (gnus-summary-show-thread)
12101 (gnus-summary-update-mark mark 'unread)
12104 (defun gnus-summary-update-secondary-mark (article)
12105 "Update the secondary (read, process, cache) mark."
12106 (gnus-summary-update-mark
12107 (cond ((memq article gnus-newsgroup-processable)
12109 ((memq article gnus-newsgroup-cached)
12111 ((memq article gnus-newsgroup-replied)
12113 ((memq article gnus-newsgroup-saved)
12115 (t gnus-unread-mark))
12117 (when (gnus-visual-p 'summary-highlight 'highlight)
12118 (run-hooks 'gnus-summary-update-hook))
12121 (defun gnus-summary-update-mark (mark type)
12122 (beginning-of-line)
12123 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12124 (buffer-read-only nil))
12126 (<= (+ forward (point)) (point-max)))
12127 ;; Go to the right position on the line.
12128 (goto-char (+ forward (point)))
12129 ;; Replace the old mark with the new mark.
12130 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12131 ;; Optionally update the marks by some user rule.
12132 (when (eq type 'unread)
12133 (gnus-data-set-mark
12134 (gnus-data-find (gnus-summary-article-number)) mark)
12135 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12137 (defun gnus-mark-article-as-read (article &optional mark)
12138 "Enter ARTICLE in the pertinent lists and remove it from others."
12139 ;; Make the article expirable.
12140 (let ((mark (or mark gnus-del-mark)))
12141 (if (= mark gnus-expirable-mark)
12142 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12143 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12144 ;; Remove from unread and marked lists.
12145 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12146 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12147 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12148 (push (cons article mark) gnus-newsgroup-reads)
12149 ;; Possibly remove from cache, if that is used.
12150 (when gnus-use-cache
12151 (gnus-cache-enter-remove-article article))))
12153 (defun gnus-mark-article-as-unread (article &optional mark)
12154 "Enter ARTICLE in the pertinent lists and remove it from others."
12155 (let ((mark (or mark gnus-ticked-mark)))
12156 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12157 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12158 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12159 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12160 (cond ((= mark gnus-ticked-mark)
12161 (push article gnus-newsgroup-marked))
12162 ((= mark gnus-dormant-mark)
12163 (push article gnus-newsgroup-dormant))
12165 (push article gnus-newsgroup-unreads)))
12166 (setq gnus-newsgroup-reads
12167 (delq (assq article gnus-newsgroup-reads)
12168 gnus-newsgroup-reads))))
12170 (defalias 'gnus-summary-mark-as-unread-forward
12171 'gnus-summary-tick-article-forward)
12172 (make-obsolete 'gnus-summary-mark-as-unread-forward
12173 'gnus-summary-tick-article-forward)
12174 (defun gnus-summary-tick-article-forward (n)
12175 "Tick N articles forwards.
12176 If N is negative, tick backwards instead.
12177 The difference between N and the number of articles ticked is returned."
12179 (gnus-summary-mark-forward n gnus-ticked-mark))
12181 (defalias 'gnus-summary-mark-as-unread-backward
12182 'gnus-summary-tick-article-backward)
12183 (make-obsolete 'gnus-summary-mark-as-unread-backward
12184 'gnus-summary-tick-article-backward)
12185 (defun gnus-summary-tick-article-backward (n)
12186 "Tick N articles backwards.
12187 The difference between N and the number of articles ticked is returned."
12189 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12191 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12192 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12193 (defun gnus-summary-tick-article (&optional article clear-mark)
12194 "Mark current article as unread.
12195 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12196 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12198 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12199 gnus-ticked-mark)))
12201 (defun gnus-summary-mark-as-read-forward (n)
12202 "Mark N articles as read forwards.
12203 If N is negative, mark backwards instead.
12204 The difference between N and the actual number of articles marked is
12207 (gnus-summary-mark-forward n gnus-del-mark t))
12209 (defun gnus-summary-mark-as-read-backward (n)
12210 "Mark the N articles as read backwards.
12211 The difference between N and the actual number of articles marked is
12214 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12216 (defun gnus-summary-mark-as-read (&optional article mark)
12217 "Mark current article as read.
12218 ARTICLE specifies the article to be marked as read.
12219 MARK specifies a string to be inserted at the beginning of the line."
12220 (gnus-summary-mark-article article mark))
12222 (defun gnus-summary-clear-mark-forward (n)
12223 "Clear marks from N articles forward.
12224 If N is negative, clear backward instead.
12225 The difference between N and the number of marks cleared is returned."
12227 (gnus-summary-mark-forward n gnus-unread-mark))
12229 (defun gnus-summary-clear-mark-backward (n)
12230 "Clear marks from N articles backward.
12231 The difference between N and the number of marks cleared is returned."
12233 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12235 (defun gnus-summary-mark-unread-as-read ()
12236 "Intended to be used by `gnus-summary-mark-article-hook'."
12237 (when (memq gnus-current-article gnus-newsgroup-unreads)
12238 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12240 (defun gnus-summary-mark-read-and-unread-as-read ()
12241 "Intended to be used by `gnus-summary-mark-article-hook'."
12242 (let ((mark (gnus-summary-article-mark)))
12243 (when (or (gnus-unread-mark-p mark)
12244 (gnus-read-mark-p mark))
12245 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12247 (defun gnus-summary-mark-region-as-read (point mark all)
12248 "Mark all unread articles between point and mark as read.
12249 If given a prefix, mark all articles between point and mark as read,
12250 even ticked and dormant ones."
12251 (interactive "r\nP")
12255 (beginning-of-line)
12260 (memq (setq article (gnus-summary-article-number))
12261 gnus-newsgroup-unreads))
12262 (gnus-summary-mark-article article gnus-del-mark))
12264 (gnus-summary-find-next))))))
12266 (defun gnus-summary-mark-below (score mark)
12267 "Mark articles with score less than SCORE with MARK."
12268 (interactive "P\ncMark: ")
12269 (gnus-set-global-variables)
12270 (setq score (if score
12271 (prefix-numeric-value score)
12272 (or gnus-summary-default-score 0)))
12274 (set-buffer gnus-summary-buffer)
12275 (goto-char (point-min))
12278 (and (< (gnus-summary-article-score) score)
12279 (gnus-summary-mark-article nil mark))
12280 (gnus-summary-find-next)))))
12282 (defun gnus-summary-kill-below (&optional score)
12283 "Mark articles with score below SCORE as read."
12285 (gnus-set-global-variables)
12286 (gnus-summary-mark-below score gnus-killed-mark))
12288 (defun gnus-summary-clear-above (&optional score)
12289 "Clear all marks from articles with score above SCORE."
12291 (gnus-set-global-variables)
12292 (gnus-summary-mark-above score gnus-unread-mark))
12294 (defun gnus-summary-tick-above (&optional score)
12295 "Tick all articles with score above SCORE."
12297 (gnus-set-global-variables)
12298 (gnus-summary-mark-above score gnus-ticked-mark))
12300 (defun gnus-summary-mark-above (score mark)
12301 "Mark articles with score over SCORE with MARK."
12302 (interactive "P\ncMark: ")
12303 (gnus-set-global-variables)
12304 (setq score (if score
12305 (prefix-numeric-value score)
12306 (or gnus-summary-default-score 0)))
12308 (set-buffer gnus-summary-buffer)
12309 (goto-char (point-min))
12311 (if (> (gnus-summary-article-score) score)
12312 (gnus-summary-mark-article nil mark))
12314 (gnus-summary-find-next)))))
12316 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12317 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12318 (defun gnus-summary-limit-include-expunged ()
12319 "Display all the hidden articles that were expunged for low scores."
12321 (gnus-set-global-variables)
12322 (let ((buffer-read-only nil))
12323 (let ((scored gnus-newsgroup-scored)
12326 (or (gnus-summary-goto-subject (caar scored))
12327 (and (setq h (gnus-summary-article-header (caar scored)))
12328 (< (cdar scored) gnus-summary-expunge-below)
12329 (setq headers (cons h headers))))
12330 (setq scored (cdr scored)))
12331 (or headers (error "No expunged articles hidden."))
12332 (goto-char (point-min))
12333 (gnus-summary-prepare-unthreaded (nreverse headers)))
12334 (goto-char (point-min))
12335 (gnus-summary-position-point)))
12337 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12338 "Mark all articles not marked as unread in this newsgroup as read.
12339 If prefix argument ALL is non-nil, all articles are marked as read.
12340 If QUIETLY is non-nil, no questions will be asked.
12341 If TO-HERE is non-nil, it should be a point in the buffer. All
12342 articles before this point will be marked as read.
12343 The number of articles marked as read is returned."
12345 (gnus-set-global-variables)
12348 (not gnus-interactive-catchup) ;Without confirmation?
12352 "Mark absolutely all articles as read? "
12353 "Mark all unread articles as read? ")))
12355 (not gnus-newsgroup-adaptive)
12356 (not gnus-newsgroup-auto-expire))
12359 (setq gnus-newsgroup-marked nil
12360 gnus-newsgroup-dormant nil))
12361 (setq gnus-newsgroup-unreads nil))
12362 ;; We actually mark all articles as canceled, which we
12363 ;; have to do when using auto-expiry or adaptive scoring.
12364 (gnus-summary-show-all-threads)
12365 (if (gnus-summary-first-subject (not all))
12367 (if to-here (< (point) to-here) t)
12368 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12369 (gnus-summary-find-next (not all)))))
12371 (setq gnus-newsgroup-unreads nil))
12372 (gnus-set-mode-line 'summary)))
12373 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12374 (if (and (not to-here) (eq 'nnvirtual (car method)))
12375 (nnvirtual-catchup-group
12376 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12377 (gnus-summary-position-point)))
12379 (defun gnus-summary-catchup-to-here (&optional all)
12380 "Mark all unticked articles before the current one as read.
12381 If ALL is non-nil, also mark ticked and dormant articles as read."
12383 (gnus-set-global-variables)
12385 (let ((beg (point)))
12386 ;; We check that there are unread articles.
12387 (when (or all (gnus-summary-find-prev))
12388 (gnus-summary-catchup all t beg))))
12389 (gnus-summary-position-point))
12391 (defun gnus-summary-catchup-all (&optional quietly)
12392 "Mark all articles in this newsgroup as read."
12394 (gnus-set-global-variables)
12395 (gnus-summary-catchup t quietly))
12397 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12398 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12399 If prefix argument ALL is non-nil, all articles are marked as read."
12401 (gnus-set-global-variables)
12402 (gnus-summary-catchup all quietly nil 'fast)
12403 ;; Select next newsgroup or exit.
12404 (if (eq gnus-auto-select-next 'quietly)
12405 (gnus-summary-next-group nil)
12406 (gnus-summary-exit)))
12408 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12409 "Mark all articles in this newsgroup as read, and then exit."
12411 (gnus-set-global-variables)
12412 (gnus-summary-catchup-and-exit t quietly))
12414 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12415 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12416 "Mark all articles in this group as read and select the next group.
12417 If given a prefix, mark all articles, unread as well as ticked, as
12420 (gnus-set-global-variables)
12422 (gnus-summary-catchup all))
12423 (gnus-summary-next-article t nil nil t))
12425 ;; Thread-based commands.
12427 (defun gnus-summary-articles-in-thread (&optional article)
12428 "Return a list of all articles in the current thread.
12429 If ARTICLE is non-nil, return all articles in the thread that starts
12430 with that article."
12431 (let* ((article (or article (gnus-summary-article-number)))
12432 (data (gnus-data-find-list article))
12433 (top-level (gnus-data-level (car data)))
12435 (cond ((null gnus-thread-operation-ignore-subject)
12436 (gnus-simplify-subject-re
12437 (mail-header-subject (gnus-data-header (car data)))))
12438 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12439 (gnus-simplify-subject-fuzzy
12440 (mail-header-subject (gnus-data-header (car data)))))
12442 (end-point (save-excursion
12443 (if (gnus-summary-go-to-next-thread)
12444 (point) (point-max))))
12447 (< (gnus-data-pos (car data)) end-point))
12448 (when (or (not top-subject)
12449 (string= top-subject
12450 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12451 (gnus-simplify-subject-fuzzy
12452 (mail-header-subject
12453 (gnus-data-header (car data))))
12454 (gnus-simplify-subject-re
12455 (mail-header-subject
12456 (gnus-data-header (car data)))))))
12457 (push (gnus-data-number (car data)) articles))
12458 (unless (and (setq data (cdr data))
12459 (> (gnus-data-level (car data)) top-level))
12461 ;; Return the list of articles.
12462 (nreverse articles)))
12464 (defun gnus-summary-rethread-current ()
12465 "Rethread the thread the current article is part of."
12467 (gnus-set-global-variables)
12468 (let* ((gnus-show-threads t)
12469 (article (gnus-summary-article-number))
12470 (id (mail-header-id (gnus-summary-article-header)))
12471 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12473 (error "No article on the current line"))
12474 (gnus-rebuild-thread id)
12475 (gnus-summary-goto-subject article)))
12477 (defun gnus-summary-reparent-thread ()
12478 "Make current article child of the marked (or previous) article.
12480 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12481 is non-nil or the Subject: of both articles are the same."
12483 (or (not (gnus-group-read-only-p))
12484 (error "The current newsgroup does not support article editing."))
12485 (or (<= (length gnus-newsgroup-processable) 1)
12486 (error "No more than one article may be marked."))
12487 (save-window-excursion
12488 (let ((gnus-article-buffer " *reparent*")
12489 (current-article (gnus-summary-article-number))
12490 ; first grab the marked article, otherwise one line up.
12491 (parent-article (if (not (null gnus-newsgroup-processable))
12492 (car gnus-newsgroup-processable)
12494 (if (eq (forward-line -1) 0)
12495 (gnus-summary-article-number)
12496 (error "Beginning of summary buffer."))))))
12497 (or (not (eq current-article parent-article))
12498 (error "An article may not be self-referential."))
12499 (let ((message-id (mail-header-id
12500 (gnus-summary-article-header parent-article))))
12501 (or (and message-id (not (equal message-id "")))
12502 (error "No message-id in desired parent."))
12503 (gnus-summary-select-article t t nil current-article)
12504 (set-buffer gnus-article-buffer)
12505 (setq buffer-read-only nil)
12506 (let ((buf (format "%s" (buffer-string))))
12509 (goto-char (point-min))
12510 (if (search-forward-regexp "^References: " nil t)
12511 (insert message-id " " )
12512 (insert "References: " message-id "\n"))
12513 (or (gnus-request-replace-article current-article
12514 (car gnus-article-current)
12515 gnus-article-buffer)
12516 (error "Couldn't replace article."))
12517 (set-buffer gnus-summary-buffer)
12518 (gnus-summary-unmark-all-processable)
12519 (gnus-summary-rethread-current)
12520 (gnus-message 3 "Article %d is now the child of article %d."
12521 current-article parent-article)))))
12523 (defun gnus-summary-toggle-threads (&optional arg)
12524 "Toggle showing conversation threads.
12525 If ARG is positive number, turn showing conversation threads on."
12527 (gnus-set-global-variables)
12528 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12529 (setq gnus-show-threads
12530 (if (null arg) (not gnus-show-threads)
12531 (> (prefix-numeric-value arg) 0)))
12532 (gnus-summary-prepare)
12533 (gnus-summary-goto-subject current)
12534 (gnus-summary-position-point)))
12536 (defun gnus-summary-show-all-threads ()
12537 "Show all threads."
12539 (gnus-set-global-variables)
12541 (let ((buffer-read-only nil))
12542 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12543 (gnus-summary-position-point))
12545 (defun gnus-summary-show-thread ()
12546 "Show thread subtrees.
12547 Returns nil if no thread was there to be shown."
12549 (gnus-set-global-variables)
12550 (let ((buffer-read-only nil)
12552 ;; first goto end then to beg, to have point at beg after let
12553 (end (progn (end-of-line) (point)))
12554 (beg (progn (beginning-of-line) (point))))
12556 ;; Any hidden lines here?
12557 (search-forward "\r" end t)
12558 (subst-char-in-region beg end ?\^M ?\n t)
12560 (gnus-summary-position-point))))
12562 (defun gnus-summary-hide-all-threads ()
12563 "Hide all thread subtrees."
12565 (gnus-set-global-variables)
12567 (goto-char (point-min))
12568 (gnus-summary-hide-thread)
12569 (while (zerop (gnus-summary-next-thread 1 t))
12570 (gnus-summary-hide-thread)))
12571 (gnus-summary-position-point))
12573 (defun gnus-summary-hide-thread ()
12574 "Hide thread subtrees.
12575 Returns nil if no threads were there to be hidden."
12577 (gnus-set-global-variables)
12578 (let ((buffer-read-only nil)
12580 (article (gnus-summary-article-number)))
12582 ;; Go forward until either the buffer ends or the subthread
12584 (when (and (not (eobp))
12585 (or (zerop (gnus-summary-next-thread 1 t))
12586 (goto-char (point-max))))
12588 (if (and (> (point) start)
12589 (search-backward "\n" start t))
12591 (subst-char-in-region start (point) ?\n ?\^M)
12592 (gnus-summary-goto-subject article))
12595 ;;(gnus-summary-position-point)
12598 (defun gnus-summary-go-to-next-thread (&optional previous)
12599 "Go to the same level (or less) next thread.
12600 If PREVIOUS is non-nil, go to previous thread instead.
12601 Return the article number moved to, or nil if moving was impossible."
12602 (let ((level (gnus-summary-thread-level))
12603 (way (if previous -1 1))
12606 (while (and (not (eobp))
12607 (< level (gnus-summary-thread-level)))
12608 (forward-line way))
12615 (gnus-summary-article-number)
12616 (goto-char beg)))))
12618 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12619 "Go to the same level (or less) next thread.
12620 If PREVIOUS is non-nil, go to previous thread instead.
12621 Return the article number moved to, or nil if moving was impossible."
12622 (if (and (eq gnus-summary-make-false-root 'dummy)
12623 (gnus-summary-article-intangible-p))
12624 (let ((beg (point)))
12625 (while (and (zerop (forward-line 1))
12626 (not (gnus-summary-article-intangible-p))
12627 (not (zerop (save-excursion
12628 (gnus-summary-thread-level))))))
12634 (let* ((level (gnus-summary-thread-level))
12635 (article (gnus-summary-article-number))
12636 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12639 (if (<= (gnus-data-level (car data)) level)
12640 (setq oart (gnus-data-number (car data))
12642 (setq data (cdr data))))
12644 (gnus-summary-goto-subject oart)))))
12646 (defun gnus-summary-next-thread (n &optional silent)
12647 "Go to the same level next N'th thread.
12648 If N is negative, search backward instead.
12649 Returns the difference between N and the number of skips actually
12652 If SILENT, don't output messages."
12654 (gnus-set-global-variables)
12655 (let ((backward (< n 0))
12658 (while (and (> n 0)
12659 (gnus-summary-go-to-next-thread backward))
12662 (gnus-summary-position-point))
12663 (when (and (not silent) (/= 0 n))
12664 (gnus-message 7 "No more threads"))
12667 (defun gnus-summary-prev-thread (n)
12668 "Go to the same level previous N'th thread.
12669 Returns the difference between N and the number of skips actually
12672 (gnus-set-global-variables)
12673 (gnus-summary-next-thread (- n)))
12675 (defun gnus-summary-go-down-thread ()
12676 "Go down one level in the current thread."
12677 (let ((children (gnus-summary-article-children)))
12679 (gnus-summary-goto-subject (car children)))))
12681 (defun gnus-summary-go-up-thread ()
12682 "Go up one level in the current thread."
12683 (let ((parent (gnus-summary-article-parent)))
12685 (gnus-summary-goto-subject parent))))
12687 (defun gnus-summary-down-thread (n)
12688 "Go down thread N steps.
12689 If N is negative, go up instead.
12690 Returns the difference between N and how many steps down that were
12693 (gnus-set-global-variables)
12696 (while (and (> n 0)
12697 (if up (gnus-summary-go-up-thread)
12698 (gnus-summary-go-down-thread)))
12700 (gnus-summary-position-point)
12701 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12704 (defun gnus-summary-up-thread (n)
12705 "Go up thread N steps.
12706 If N is negative, go up instead.
12707 Returns the difference between N and how many steps down that were
12710 (gnus-set-global-variables)
12711 (gnus-summary-down-thread (- n)))
12713 (defun gnus-summary-top-thread ()
12714 "Go to the top of the thread."
12716 (gnus-set-global-variables)
12717 (while (gnus-summary-go-up-thread))
12718 (gnus-summary-article-number))
12720 (defun gnus-summary-kill-thread (&optional unmark)
12721 "Mark articles under current thread as read.
12722 If the prefix argument is positive, remove any kinds of marks.
12723 If the prefix argument is negative, tick articles instead."
12725 (gnus-set-global-variables)
12727 (setq unmark (prefix-numeric-value unmark)))
12728 (let ((articles (gnus-summary-articles-in-thread)))
12730 ;; Expand the thread.
12731 (gnus-summary-show-thread)
12732 ;; Mark all the articles.
12734 (gnus-summary-goto-subject (car articles))
12735 (cond ((null unmark)
12736 (gnus-summary-mark-article-as-read gnus-killed-mark))
12738 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12740 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12741 (setq articles (cdr articles))))
12742 ;; Hide killed subtrees.
12744 gnus-thread-hide-killed
12745 (gnus-summary-hide-thread))
12746 ;; If marked as read, go to next unread subject.
12748 ;; Go to next unread subject.
12749 (gnus-summary-next-subject 1 t)))
12750 (gnus-set-mode-line 'summary))
12752 ;; Summary sorting commands
12754 (defun gnus-summary-sort-by-number (&optional reverse)
12755 "Sort summary buffer by article number.
12756 Argument REVERSE means reverse order."
12758 (gnus-summary-sort 'number reverse))
12760 (defun gnus-summary-sort-by-author (&optional reverse)
12761 "Sort summary buffer by author name alphabetically.
12762 If case-fold-search is non-nil, case of letters is ignored.
12763 Argument REVERSE means reverse order."
12765 (gnus-summary-sort 'author reverse))
12767 (defun gnus-summary-sort-by-subject (&optional reverse)
12768 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12769 If case-fold-search is non-nil, case of letters is ignored.
12770 Argument REVERSE means reverse order."
12772 (gnus-summary-sort 'subject reverse))
12774 (defun gnus-summary-sort-by-date (&optional reverse)
12775 "Sort summary buffer by date.
12776 Argument REVERSE means reverse order."
12778 (gnus-summary-sort 'date reverse))
12780 (defun gnus-summary-sort-by-score (&optional reverse)
12781 "Sort summary buffer by score.
12782 Argument REVERSE means reverse order."
12784 (gnus-summary-sort 'score reverse))
12786 (defun gnus-summary-sort (predicate reverse)
12787 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12788 (gnus-set-global-variables)
12789 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12790 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12791 (gnus-thread-sort-functions
12796 (,thread t2 t1)))))
12797 (gnus-article-sort-functions
12802 (,article t2 t1)))))
12804 (gnus-summary-prepare-hook nil))
12805 ;; We do the sorting by regenerating the threads.
12806 (gnus-summary-prepare)
12807 ;; Hide subthreads if needed.
12808 (when (and gnus-show-threads gnus-thread-hide-subtree)
12809 (gnus-summary-hide-all-threads)))
12810 ;; If in async mode, we send some info to the backend.
12811 (when gnus-newsgroup-async
12812 (gnus-request-asynchronous
12813 gnus-newsgroup-name gnus-newsgroup-data)))
12815 (defun gnus-sortable-date (date)
12816 "Make sortable string by string-lessp from DATE.
12817 Timezone package is used."
12818 (setq date (timezone-fix-time date nil nil))
12819 (timezone-make-sortable-date
12820 (aref date 0) (aref date 2) (aref date 2)
12821 (timezone-make-time-string
12822 (aref date 3) (aref date 4) (aref date 5))))
12824 ;; Summary saving commands.
12826 (defun gnus-summary-save-article (&optional n not-saved)
12827 "Save the current article using the default saver function.
12828 If N is a positive number, save the N next articles.
12829 If N is a negative number, save the N previous articles.
12830 If N is nil and any articles have been marked with the process mark,
12831 save those articles instead.
12832 The variable `gnus-default-article-saver' specifies the saver function."
12834 (gnus-set-global-variables)
12835 (let ((articles (gnus-summary-work-articles n))
12836 file header article)
12838 (setq header (gnus-summary-article-header
12839 (setq article (pop articles))))
12840 (if (not (vectorp header))
12841 ;; This is a pseudo-article.
12842 (if (assq 'name header)
12843 (gnus-copy-file (cdr (assq 'name header)))
12844 (gnus-message 1 "Article %d is unsaveable" article))
12845 ;; This is a real article.
12846 (save-window-excursion
12847 (gnus-summary-select-article t nil nil article))
12848 (unless gnus-save-all-headers
12849 ;; Remove headers accoring to `gnus-saved-headers'.
12850 (let ((gnus-visible-headers
12851 (or gnus-saved-headers gnus-visible-headers)))
12852 (gnus-article-hide-headers nil t)))
12853 ;; Remove any X-Gnus lines.
12855 (set-buffer gnus-article-buffer)
12857 (let ((buffer-read-only nil))
12858 (nnheader-narrow-to-headers)
12859 (while (re-search-forward "^X-Gnus" nil t)
12860 (gnus-delete-line)))))
12861 (save-window-excursion
12862 (if (not gnus-default-article-saver)
12863 (error "No default saver is defined.")
12864 (setq file (funcall
12865 gnus-default-article-saver
12867 ((not gnus-prompt-before-saving)
12869 ((eq gnus-prompt-before-saving 'always)
12872 (gnus-summary-remove-process-mark article)
12874 (gnus-summary-set-saved-mark article))))
12875 (gnus-summary-position-point)
12878 (defun gnus-summary-pipe-output (&optional arg)
12879 "Pipe the current article to a subprocess.
12880 If N is a positive number, pipe the N next articles.
12881 If N is a negative number, pipe the N previous articles.
12882 If N is nil and any articles have been marked with the process mark,
12883 pipe those articles instead."
12885 (gnus-set-global-variables)
12886 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12887 (gnus-summary-save-article arg t))
12888 (gnus-configure-windows 'pipe))
12890 (defun gnus-summary-save-article-mail (&optional arg)
12891 "Append the current article to an mail file.
12892 If N is a positive number, save the N next articles.
12893 If N is a negative number, save the N previous articles.
12894 If N is nil and any articles have been marked with the process mark,
12895 save those articles instead."
12897 (gnus-set-global-variables)
12898 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12899 (gnus-summary-save-article arg)))
12901 (defun gnus-summary-save-article-rmail (&optional arg)
12902 "Append the current article to an rmail file.
12903 If N is a positive number, save the N next articles.
12904 If N is a negative number, save the N previous articles.
12905 If N is nil and any articles have been marked with the process mark,
12906 save those articles instead."
12908 (gnus-set-global-variables)
12909 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12910 (gnus-summary-save-article arg)))
12912 (defun gnus-summary-save-article-file (&optional arg)
12913 "Append the current article to a file.
12914 If N is a positive number, save the N next articles.
12915 If N is a negative number, save the N previous articles.
12916 If N is nil and any articles have been marked with the process mark,
12917 save those articles instead."
12919 (gnus-set-global-variables)
12920 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12921 (gnus-summary-save-article arg)))
12923 (defun gnus-summary-save-article-body-file (&optional arg)
12924 "Append the current article body to a file.
12925 If N is a positive number, save the N next articles.
12926 If N is a negative number, save the N previous articles.
12927 If N is nil and any articles have been marked with the process mark,
12928 save those articles instead."
12930 (gnus-set-global-variables)
12931 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12932 (gnus-summary-save-article arg)))
12934 (defun gnus-get-split-value (methods)
12935 "Return a value based on the split METHODS."
12936 (let (split-name method result match)
12939 (set-buffer gnus-original-article-buffer)
12941 (nnheader-narrow-to-headers)
12943 (goto-char (point-min))
12944 (setq method (pop methods))
12945 (setq match (car method))
12948 ;; Regular expression.
12950 (re-search-forward match nil t)
12952 ((gnus-functionp match)
12956 (setq result (funcall match gnus-newsgroup-name))))
12961 (setq result (eval match)))))
12962 (setq split-name (append (cdr method) split-name))
12963 (cond ((stringp result)
12964 (push result split-name))
12966 (setq split-name (append result split-name)))))))))
12969 (defun gnus-read-move-group-name (prompt default articles prefix)
12970 "Read a group name."
12971 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12978 (assoc (symbol-name
12979 (car (gnus-find-method-for-group
12981 gnus-valid-select-methods))
12982 (push (list (symbol-name g)) group-map)))
12983 gnus-active-hashtb))
12985 (format "%s %s to:"
12987 (if (> (length articles) 1)
12988 (format "these %d articles" (length articles))
12993 (gnus-completing-read default prom
12994 group-map nil nil prefix
12995 'gnus-group-history))
12996 ((= 1 (length split-name))
12997 (gnus-completing-read (car split-name) prom group-map
12999 'gnus-group-history))
13001 (gnus-completing-read nil prom
13002 (mapcar (lambda (el) (list el))
13003 (nreverse split-name))
13005 'gnus-group-history)))))
13007 (if (or (string= to-newsgroup "")
13008 (string= to-newsgroup prefix))
13009 (setq to-newsgroup (or default "")))
13010 (or (gnus-active to-newsgroup)
13011 (gnus-activate-group to-newsgroup)
13012 (error "No such group: %s" to-newsgroup)))
13015 (defun gnus-read-save-file-name (prompt default-name)
13016 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13018 ;; Let the split methods have their say.
13020 ;; No split name was found.
13023 (concat prompt " (default "
13024 (file-name-nondirectory default-name) ") ")
13025 (file-name-directory default-name)
13027 ;; A single split name was found
13028 ((= 1 (length split-name))
13030 (concat prompt " (default " (car split-name) ") ")
13031 gnus-article-save-directory
13032 (concat gnus-article-save-directory (car split-name))))
13033 ;; A list of splits was found.
13035 (setq split-name (nreverse split-name))
13037 (let ((file-name-history (nconc split-name file-name-history)))
13040 (concat prompt " (`M-p' for defaults) ")
13041 gnus-article-save-directory
13042 (car split-name))))
13043 (car (push result file-name-history)))))))
13044 ;; If we have read a directory, we append the default file name.
13045 (when (file-directory-p file)
13046 (setq file (concat (file-name-as-directory file)
13047 (file-name-nondirectory default-name))))
13048 ;; Possibly translate some charaters.
13049 (nnheader-translate-file-chars file)))
13051 (defun gnus-article-archive-name (group)
13052 "Return the first instance of an \"Archive-name\" in the current buffer."
13053 (let ((case-fold-search t))
13054 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13055 (match-string 1))))
13057 (defun gnus-summary-save-in-rmail (&optional filename)
13058 "Append this article to Rmail file.
13059 Optional argument FILENAME specifies file name.
13060 Directory to save to is default to `gnus-article-save-directory'."
13062 (gnus-set-global-variables)
13063 (let ((default-name
13064 (funcall gnus-rmail-save-name gnus-newsgroup-name
13065 gnus-current-headers gnus-newsgroup-last-rmail)))
13067 (cond ((eq filename 'default)
13069 (filename filename)
13070 (t (gnus-read-save-file-name
13071 "Save in rmail file:" default-name))))
13072 (gnus-make-directory (file-name-directory filename))
13073 (gnus-eval-in-buffer-window
13074 gnus-original-article-buffer
13078 (gnus-output-to-rmail filename))))
13079 ;; Remember the directory name to save articles
13080 (setq gnus-newsgroup-last-rmail filename)))
13082 (defun gnus-summary-save-in-mail (&optional filename)
13083 "Append this article to Unix mail file.
13084 Optional argument FILENAME specifies file name.
13085 Directory to save to is default to `gnus-article-save-directory'."
13087 (gnus-set-global-variables)
13088 (let ((default-name
13089 (funcall gnus-mail-save-name gnus-newsgroup-name
13090 gnus-current-headers gnus-newsgroup-last-mail)))
13092 (cond ((eq filename 'default)
13094 (filename filename)
13095 (t (gnus-read-save-file-name
13096 "Save in Unix mail file:" default-name))))
13098 (expand-file-name filename
13100 (file-name-directory default-name))))
13101 (gnus-make-directory (file-name-directory filename))
13102 (gnus-eval-in-buffer-window
13103 gnus-original-article-buffer
13107 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13108 (gnus-output-to-rmail filename)
13109 (let ((mail-use-rfc822 t))
13110 (rmail-output filename 1 t t))))))
13111 ;; Remember the directory name to save articles.
13112 (setq gnus-newsgroup-last-mail filename)))
13114 (defun gnus-summary-save-in-file (&optional filename)
13115 "Append this article to file.
13116 Optional argument FILENAME specifies file name.
13117 Directory to save to is default to `gnus-article-save-directory'."
13119 (gnus-set-global-variables)
13120 (let ((default-name
13121 (funcall gnus-file-save-name gnus-newsgroup-name
13122 gnus-current-headers gnus-newsgroup-last-file)))
13124 (cond ((eq filename 'default)
13126 (filename filename)
13127 (t (gnus-read-save-file-name
13128 "Save in file:" default-name))))
13129 (gnus-make-directory (file-name-directory filename))
13130 (gnus-eval-in-buffer-window
13131 gnus-original-article-buffer
13135 (gnus-output-to-file filename))))
13136 ;; Remember the directory name to save articles.
13137 (setq gnus-newsgroup-last-file filename)))
13139 (defun gnus-summary-save-body-in-file (&optional filename)
13140 "Append this article body to a file.
13141 Optional argument FILENAME specifies file name.
13142 The directory to save in defaults to `gnus-article-save-directory'."
13144 (gnus-set-global-variables)
13145 (let ((default-name
13146 (funcall gnus-file-save-name gnus-newsgroup-name
13147 gnus-current-headers gnus-newsgroup-last-file)))
13149 (cond ((eq filename 'default)
13151 (filename filename)
13152 (t (gnus-read-save-file-name
13153 "Save body in file:" default-name))))
13154 (gnus-make-directory (file-name-directory filename))
13155 (gnus-eval-in-buffer-window
13156 gnus-article-buffer
13160 (goto-char (point-min))
13161 (and (search-forward "\n\n" nil t)
13162 (narrow-to-region (point) (point-max)))
13163 (gnus-output-to-file filename))))
13164 ;; Remember the directory name to save articles.
13165 (setq gnus-newsgroup-last-file filename)))
13167 (defun gnus-summary-save-in-pipe (&optional command)
13168 "Pipe this article to subprocess."
13170 (gnus-set-global-variables)
13172 (cond ((eq command 'default)
13173 gnus-last-shell-command)
13175 (t (read-string "Shell command on article: "
13176 gnus-last-shell-command))))
13177 (if (string-equal command "")
13178 (setq command gnus-last-shell-command))
13179 (gnus-eval-in-buffer-window
13180 gnus-article-buffer
13183 (shell-command-on-region (point-min) (point-max) command nil)))
13184 (setq gnus-last-shell-command command))
13186 ;; Summary extract commands
13188 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13189 (let ((buffer-read-only nil)
13190 (article (gnus-summary-article-number))
13192 (or (gnus-summary-goto-subject article)
13193 (error (format "No such article: %d" article)))
13194 (gnus-summary-position-point)
13195 ;; If all commands are to be bunched up on one line, we collect
13197 (if gnus-view-pseudos-separately
13199 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13202 (setq action (cdr (assq 'action (car ps))))
13203 (setq files (list (cdr (assq 'name (car ps)))))
13204 (while (and ps (cdr ps)
13205 (string= (or action "1")
13206 (or (cdr (assq 'action (cadr ps))) "2")))
13207 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13208 (setcdr ps (cddr ps)))
13211 (if (not (string-match "%s" action))
13212 (setq files (cons " " files)))
13213 (setq files (cons " " files))
13214 (and (assq 'execute (car ps))
13215 (setcdr (assq 'execute (car ps))
13216 (funcall (if (string-match "%s" action)
13219 (mapconcat (lambda (f) f) files " ")))))
13220 (setq ps (cdr ps)))))
13221 (if (and gnus-view-pseudos (not not-view))
13223 (and (assq 'execute (car pslist))
13224 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13225 (eq gnus-view-pseudos 'not-confirm)))
13226 (setq pslist (cdr pslist)))
13229 (setq after-article (or (cdr (assq 'article (car pslist)))
13230 (gnus-summary-article-number)))
13231 (gnus-summary-goto-subject after-article)
13234 (insert " " (file-name-nondirectory
13235 (cdr (assq 'name (car pslist))))
13236 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13238 (forward-line -1) ; back to `b'
13239 (gnus-add-text-properties
13240 b e (list 'gnus-number gnus-reffed-article-number
13241 gnus-mouse-face-prop gnus-mouse-face))
13243 after-article gnus-reffed-article-number
13244 gnus-unread-mark b (car pslist) 0 (- e b))
13245 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13246 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13247 (setq pslist (cdr pslist)))))))
13249 (defun gnus-pseudos< (p1 p2)
13250 (let ((c1 (cdr (assq 'action p1)))
13251 (c2 (cdr (assq 'action p2))))
13252 (and c1 c2 (string< c1 c2))))
13254 (defun gnus-request-pseudo-article (props)
13255 (cond ((assq 'execute props)
13256 (gnus-execute-command (cdr (assq 'execute props)))))
13257 (let ((gnus-current-article (gnus-summary-article-number)))
13258 (run-hooks 'gnus-mark-article-hook)))
13260 (defun gnus-execute-command (command &optional automatic)
13262 (gnus-article-setup-buffer)
13263 (set-buffer gnus-article-buffer)
13264 (setq buffer-read-only nil)
13265 (let ((command (if automatic command (read-string "Command: " command)))
13266 ;; Just binding this here doesn't help, because there might
13267 ;; be output from the process after exiting the scope of
13269 ;; (buffer-read-only nil)
13272 (insert "$ " command "\n\n")
13273 (if gnus-view-pseudo-asynchronously
13274 (start-process "gnus-execute" nil "sh" "-c" command)
13275 (call-process "sh" nil t nil "-c" command)))))
13277 (defun gnus-copy-file (file &optional to)
13280 (list (read-file-name "Copy file: " default-directory)
13281 (read-file-name "Copy file to: " default-directory)))
13282 (gnus-set-global-variables)
13283 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13284 (and (file-directory-p to)
13285 (setq to (concat (file-name-as-directory to)
13286 (file-name-nondirectory file))))
13287 (copy-file file to))
13289 ;; Summary kill commands.
13291 (defun gnus-summary-edit-global-kill (article)
13292 "Edit the \"global\" kill file."
13293 (interactive (list (gnus-summary-article-number)))
13294 (gnus-set-global-variables)
13295 (gnus-group-edit-global-kill article))
13297 (defun gnus-summary-edit-local-kill ()
13298 "Edit a local kill file applied to the current newsgroup."
13300 (gnus-set-global-variables)
13301 (setq gnus-current-headers (gnus-summary-article-header))
13302 (gnus-set-global-variables)
13303 (gnus-group-edit-local-kill
13304 (gnus-summary-article-number) gnus-newsgroup-name))
13308 ;;; Gnus article mode
13311 (put 'gnus-article-mode 'mode-class 'special)
13313 (if gnus-article-mode-map
13315 (setq gnus-article-mode-map (make-keymap))
13316 (suppress-keymap gnus-article-mode-map)
13318 (gnus-define-keys gnus-article-mode-map
13319 " " gnus-article-goto-next-page
13320 "\177" gnus-article-goto-prev-page
13321 [delete] gnus-article-goto-prev-page
13322 "\C-c^" gnus-article-refer-article
13323 "h" gnus-article-show-summary
13324 "s" gnus-article-show-summary
13325 "\C-c\C-m" gnus-article-mail
13326 "?" gnus-article-describe-briefly
13327 gnus-mouse-2 gnus-article-push-button
13328 "\r" gnus-article-press-button
13329 "\t" gnus-article-next-button
13330 "\M-\t" gnus-article-prev-button
13331 "\C-c\C-b" gnus-bug)
13333 (substitute-key-definition
13334 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13336 (defun gnus-article-mode ()
13337 "Major mode for displaying an article.
13339 All normal editing commands are switched off.
13341 The following commands are available:
13343 \\<gnus-article-mode-map>
13344 \\[gnus-article-next-page]\t Scroll the article one page forwards
13345 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13346 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13347 \\[gnus-article-show-summary]\t Display the summary buffer
13348 \\[gnus-article-mail]\t Send a reply to the address near point
13349 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13350 \\[gnus-info-find-node]\t Go to the Gnus info node"
13352 (when (and menu-bar-mode
13353 (gnus-visual-p 'article-menu 'menu))
13354 (gnus-article-make-menu-bar))
13355 (kill-all-local-variables)
13356 (gnus-simplify-mode-line)
13357 (setq mode-name "Article")
13358 (setq major-mode 'gnus-article-mode)
13359 (make-local-variable 'minor-mode-alist)
13360 (or (assq 'gnus-show-mime minor-mode-alist)
13361 (setq minor-mode-alist
13362 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13363 (use-local-map gnus-article-mode-map)
13364 (make-local-variable 'page-delimiter)
13365 (setq page-delimiter gnus-page-delimiter)
13366 (buffer-disable-undo (current-buffer))
13367 (setq buffer-read-only t) ;Disable modification
13368 (run-hooks 'gnus-article-mode-hook))
13370 (defun gnus-article-setup-buffer ()
13371 "Initialize the article buffer."
13372 (let* ((name (if gnus-single-article-buffer "*Article*"
13373 (concat "*Article " gnus-newsgroup-name "*")))
13375 (progn (string-match "\\*Article" name)
13376 (concat " *Original Article"
13377 (substring name (match-end 0))))))
13378 (setq gnus-article-buffer name)
13379 (setq gnus-original-article-buffer original)
13380 ;; This might be a variable local to the summary buffer.
13381 (unless gnus-single-article-buffer
13383 (set-buffer gnus-summary-buffer)
13384 (setq gnus-article-buffer name)
13385 (setq gnus-original-article-buffer original)
13386 (gnus-set-global-variables))
13387 (make-local-variable 'gnus-summary-buffer))
13388 ;; Init original article buffer.
13390 (set-buffer (get-buffer-create gnus-original-article-buffer))
13391 (buffer-disable-undo (current-buffer))
13392 (setq major-mode 'gnus-original-article-mode)
13393 (make-local-variable 'gnus-original-article))
13394 (if (get-buffer name)
13397 (buffer-disable-undo (current-buffer))
13398 (setq buffer-read-only t)
13399 (gnus-add-current-to-buffer-list)
13400 (or (eq major-mode 'gnus-article-mode)
13401 (gnus-article-mode))
13404 (set-buffer (get-buffer-create name))
13405 (gnus-add-current-to-buffer-list)
13406 (gnus-article-mode)
13407 (current-buffer)))))
13409 ;; Set article window start at LINE, where LINE is the number of lines
13410 ;; from the head of the article.
13411 (defun gnus-article-set-window-start (&optional line)
13413 (get-buffer-window gnus-article-buffer t)
13415 (set-buffer gnus-article-buffer)
13416 (goto-char (point-min))
13419 (gnus-message 6 "Moved to bookmark")
13420 (search-forward "\n\n" nil t)
13421 (forward-line line)
13424 (defun gnus-kill-all-overlays ()
13425 "Delete all overlays in the current buffer."
13426 (when (fboundp 'overlay-lists)
13427 (let* ((overlayss (overlay-lists))
13428 (buffer-read-only nil)
13429 (overlays (nconc (car overlayss) (cdr overlayss))))
13431 (delete-overlay (pop overlays))))))
13433 (defun gnus-request-article-this-buffer (article group)
13434 "Get an article and insert it into this buffer."
13435 (let (do-update-line)
13439 (gnus-kill-all-overlays)
13440 (setq group (or group gnus-newsgroup-name))
13442 ;; Open server if it has closed.
13443 (gnus-check-server (gnus-find-method-for-group group))
13445 ;; Using `gnus-request-article' directly will insert the article into
13446 ;; `nntp-server-buffer' - so we'll save some time by not having to
13447 ;; copy it from the server buffer into the article buffer.
13449 ;; We only request an article by message-id when we do not have the
13450 ;; headers for it, so we'll have to get those.
13451 (when (stringp article)
13452 (let ((gnus-override-method gnus-refer-article-method))
13453 (gnus-read-header article)))
13455 ;; If the article number is negative, that means that this article
13456 ;; doesn't belong in this newsgroup (possibly), so we find its
13457 ;; message-id and request it by id instead of number.
13458 (when (and (numberp article)
13459 gnus-summary-buffer
13460 (get-buffer gnus-summary-buffer)
13461 (buffer-name (get-buffer gnus-summary-buffer)))
13463 (set-buffer gnus-summary-buffer)
13464 (let ((header (gnus-summary-article-header article)))
13467 ((memq article gnus-newsgroup-sparse)
13468 ;; This is a sparse gap article.
13469 (setq do-update-line article)
13470 (setq article (mail-header-id header))
13471 (let ((gnus-override-method gnus-refer-article-method))
13472 (gnus-read-header article))
13473 (setq gnus-newsgroup-sparse
13474 (delq article gnus-newsgroup-sparse)))
13476 ;; It's a real article.
13477 (setq article (mail-header-id header)))
13479 ;; It is an extracted pseudo-article.
13480 (setq article 'pseudo)
13481 (gnus-request-pseudo-article header))))
13483 (let ((method (gnus-find-method-for-group
13484 gnus-newsgroup-name)))
13485 (if (not (eq (car method) 'nneething))
13487 (let ((dir (concat (file-name-as-directory (nth 1 method))
13488 (mail-header-subject header))))
13489 (if (file-directory-p dir)
13491 (setq article 'nneething)
13492 (gnus-group-enter-directory dir)))))))))
13495 ;; Refuse to select canceled articles.
13496 ((and (numberp article)
13497 gnus-summary-buffer
13498 (get-buffer gnus-summary-buffer)
13499 (buffer-name (get-buffer gnus-summary-buffer))
13500 (eq (cdr (save-excursion
13501 (set-buffer gnus-summary-buffer)
13502 (assq article gnus-newsgroup-reads)))
13503 gnus-canceled-mark))
13505 ;; We first check `gnus-original-article-buffer'.
13506 ((and (get-buffer gnus-original-article-buffer)
13509 (set-buffer gnus-original-article-buffer)
13510 (and (equal (car gnus-original-article) group)
13511 (eq (cdr gnus-original-article) article))))
13512 (insert-buffer-substring gnus-original-article-buffer)
13514 ;; Check the backlog.
13515 ((and gnus-keep-backlog
13516 (gnus-backlog-request-article group article (current-buffer)))
13518 ;; Check the cache.
13519 ((and gnus-use-cache
13521 (gnus-cache-request-article article group))
13523 ;; Get the article and put into the article buffer.
13524 ((or (stringp article) (numberp article))
13525 (let ((gnus-override-method
13526 (and (stringp article) gnus-refer-article-method))
13527 (buffer-read-only nil))
13529 (gnus-kill-all-overlays)
13530 (if (gnus-request-article article group (current-buffer))
13532 (and gnus-keep-backlog
13534 (gnus-backlog-enter-article
13535 group article (current-buffer)))
13537 ;; It was a pseudo.
13540 ;; Take the article from the original article buffer
13541 ;; and place it in the buffer it's supposed to be in.
13542 (when (and (get-buffer gnus-article-buffer)
13544 (equal (buffer-name (current-buffer))
13545 (buffer-name (get-buffer gnus-article-buffer))))
13547 (if (get-buffer gnus-original-article-buffer)
13548 (set-buffer (get-buffer gnus-original-article-buffer))
13549 (set-buffer (get-buffer-create gnus-original-article-buffer))
13550 (buffer-disable-undo (current-buffer))
13551 (setq major-mode 'gnus-original-article-mode)
13552 (setq buffer-read-only t)
13553 (gnus-add-current-to-buffer-list))
13554 (let (buffer-read-only)
13556 (insert-buffer-substring gnus-article-buffer))
13557 (setq gnus-original-article (cons group article))))
13559 ;; Update sparse articles.
13560 (when (and do-update-line
13561 (or (numberp article)
13562 (stringp article)))
13563 (let ((buf (current-buffer)))
13564 (set-buffer gnus-summary-buffer)
13565 (gnus-summary-update-article do-update-line)
13566 (gnus-summary-goto-subject do-update-line nil t)
13567 (set-window-point (get-buffer-window (current-buffer) t)
13569 (set-buffer buf))))))
13571 (defun gnus-read-header (id &optional header)
13572 "Read the headers of article ID and enter them into the Gnus system."
13573 (let ((group gnus-newsgroup-name)
13574 (gnus-override-method
13575 (and (gnus-news-group-p gnus-newsgroup-name)
13576 gnus-refer-article-method))
13578 ;; First we check to see whether the header in question is already
13581 ;; This is a Message-ID.
13582 (setq header (or header (gnus-id-to-header id)))
13583 ;; This is an article number.
13584 (setq header (or header (gnus-summary-article-header id))))
13586 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13587 ;; We have found the header.
13589 ;; We have to really fetch the header to this article.
13591 (if (gnus-check-backend-function 'request-head group)
13592 (gnus-request-head id group)
13593 (gnus-request-article id group)))
13595 (set-buffer nntp-server-buffer)
13596 (and (search-forward "\n\n" nil t)
13597 (delete-region (1- (point)) (point-max)))
13598 (goto-char (point-max))
13600 (goto-char (point-min))
13604 ((cdr where) (cdr where))
13605 (header (mail-header-number header))
13606 (t gnus-reffed-article-number))
13608 (insert " Article retrieved.\n"))
13610 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13611 ; (setcar (gnus-id-to-thread id) nil))
13612 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13613 () ; Malformed head.
13614 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13615 (if (and (stringp id)
13616 (not (string= (gnus-group-real-name group)
13618 ;; If we fetched by Message-ID and the article came
13619 ;; from a different group, we fudge some bogus article
13620 ;; numbers for this article.
13621 (mail-header-set-number header gnus-reffed-article-number))
13622 (decf gnus-reffed-article-number)
13623 (push header gnus-newsgroup-headers)
13624 (setq gnus-current-headers header)
13625 (push (mail-header-number header) gnus-newsgroup-limit))
13628 (defun gnus-article-prepare (article &optional all-headers header)
13629 "Prepare ARTICLE in article mode buffer.
13630 ARTICLE should either be an article number or a Message-ID.
13631 If ARTICLE is an id, HEADER should be the article headers.
13632 If ALL-HEADERS is non-nil, no headers are hidden."
13634 ;; Make sure we start in a summary buffer.
13635 (unless (eq major-mode 'gnus-summary-mode)
13636 (set-buffer gnus-summary-buffer))
13637 (setq gnus-summary-buffer (current-buffer))
13638 ;; Make sure the connection to the server is alive.
13639 (unless (gnus-server-opened
13640 (gnus-find-method-for-group gnus-newsgroup-name))
13641 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13642 (gnus-request-group gnus-newsgroup-name t))
13643 (let* ((article (if header (mail-header-number header) article))
13644 (summary-buffer (current-buffer))
13645 (internal-hook gnus-article-internal-prepare-hook)
13646 (group gnus-newsgroup-name)
13649 (gnus-article-setup-buffer)
13650 (set-buffer gnus-article-buffer)
13651 ;; Deactivate active regions.
13652 (when (and (boundp 'transient-mark-mode)
13653 transient-mark-mode)
13654 (setq mark-active nil))
13655 (if (not (setq result (let ((buffer-read-only nil))
13656 (gnus-request-article-this-buffer
13658 ;; There is no such article.
13660 (when (and (numberp article)
13661 (not (memq article gnus-newsgroup-sparse)))
13662 (setq gnus-article-current
13663 (cons gnus-newsgroup-name article))
13664 (set-buffer gnus-summary-buffer)
13665 (setq gnus-current-article article)
13666 (gnus-summary-mark-article article gnus-canceled-mark))
13667 (unless (memq article gnus-newsgroup-sparse)
13669 1 "No such article (may have expired or been canceled)")))
13670 (if (or (eq result 'pseudo) (eq result 'nneething))
13673 (set-buffer summary-buffer)
13674 (setq gnus-last-article gnus-current-article
13675 gnus-newsgroup-history (cons gnus-current-article
13676 gnus-newsgroup-history)
13677 gnus-current-article 0
13678 gnus-current-headers nil
13679 gnus-article-current nil)
13680 (if (eq result 'nneething)
13681 (gnus-configure-windows 'summary)
13682 (gnus-configure-windows 'article))
13683 (gnus-set-global-variables))
13684 (gnus-set-mode-line 'article))
13685 ;; The result from the `request' was an actual article -
13686 ;; or at least some text that is now displayed in the
13688 (if (and (numberp article)
13689 (not (eq article gnus-current-article)))
13690 ;; Seems like a new article has been selected.
13691 ;; `gnus-current-article' must be an article number.
13693 (set-buffer summary-buffer)
13694 (setq gnus-last-article gnus-current-article
13695 gnus-newsgroup-history (cons gnus-current-article
13696 gnus-newsgroup-history)
13697 gnus-current-article article
13698 gnus-current-headers
13699 (gnus-summary-article-header gnus-current-article)
13700 gnus-article-current
13701 (cons gnus-newsgroup-name gnus-current-article))
13702 (unless (vectorp gnus-current-headers)
13703 (setq gnus-current-headers nil))
13704 (gnus-summary-show-thread)
13705 (run-hooks 'gnus-mark-article-hook)
13706 (gnus-set-mode-line 'summary)
13707 (and (gnus-visual-p 'article-highlight 'highlight)
13708 (run-hooks 'gnus-visual-mark-article-hook))
13709 ;; Set the global newsgroup variables here.
13710 ;; Suggested by Jim Sisolak
13711 ;; <sisolak@trans4.neep.wisc.edu>.
13712 (gnus-set-global-variables)
13713 (setq gnus-have-all-headers
13714 (or all-headers gnus-show-all-headers))
13715 (and gnus-use-cache
13716 (vectorp (gnus-summary-article-header article))
13717 (gnus-cache-possibly-enter-article
13719 (gnus-summary-article-header article)
13720 (memq article gnus-newsgroup-marked)
13721 (memq article gnus-newsgroup-dormant)
13722 (memq article gnus-newsgroup-unreads)))))
13723 (when (or (numberp article)
13725 ;; Hooks for getting information from the article.
13726 ;; This hook must be called before being narrowed.
13727 (let (buffer-read-only)
13728 (run-hooks 'internal-hook)
13729 (run-hooks 'gnus-article-prepare-hook)
13730 ;; Decode MIME message.
13732 (if (or (not gnus-strict-mime)
13733 (gnus-fetch-field "Mime-Version"))
13734 (funcall gnus-show-mime-method)
13735 (funcall gnus-decode-encoded-word-method)))
13736 ;; Perform the article display hooks.
13737 (run-hooks 'gnus-article-display-hook))
13739 (goto-char (point-min))
13740 (and gnus-break-pages (gnus-narrow-to-page)))
13741 (gnus-set-mode-line 'article)
13742 (gnus-configure-windows 'article)
13743 (goto-char (point-min))
13746 (defun gnus-article-show-all-headers ()
13747 "Show all article headers in article mode buffer."
13749 (gnus-article-setup-buffer)
13750 (set-buffer gnus-article-buffer)
13751 (let ((buffer-read-only nil))
13752 (gnus-unhide-text (point-min) (point-max)))))
13754 (defun gnus-article-hide-headers-if-wanted ()
13755 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13756 Provided for backwards compatibility."
13757 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13758 gnus-inhibit-hiding
13759 (gnus-article-hide-headers)))
13761 (defsubst gnus-article-header-rank ()
13762 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13763 (let ((list gnus-sorted-header-list)
13766 (when (looking-at (car list))
13768 (setq list (cdr list))
13772 (defun gnus-article-hide-headers (&optional arg delete)
13773 "Toggle whether to hide unwanted headers and possibly sort them as well.
13774 If given a negative prefix, always show; if given a positive prefix,
13777 (unless (gnus-article-check-hidden-text 'headers arg)
13778 ;; This function might be inhibited.
13779 (unless gnus-inhibit-hiding
13781 (set-buffer gnus-article-buffer)
13783 (let ((buffer-read-only nil)
13784 (props (nconc (list 'gnus-type 'headers)
13785 gnus-hidden-properties))
13786 (max (1+ (length gnus-sorted-header-list)))
13787 (ignored (when (not (stringp gnus-visible-headers))
13788 (cond ((stringp gnus-ignored-headers)
13789 gnus-ignored-headers)
13790 ((listp gnus-ignored-headers)
13791 (mapconcat 'identity gnus-ignored-headers
13794 (cond ((stringp gnus-visible-headers)
13795 gnus-visible-headers)
13796 ((and gnus-visible-headers
13797 (listp gnus-visible-headers))
13798 (mapconcat 'identity gnus-visible-headers "\\|"))))
13800 ;; First we narrow to just the headers.
13802 (goto-char (point-min))
13803 ;; Hide any "From " lines at the beginning of (mail) articles.
13804 (while (looking-at "From ")
13807 (gnus-hide-text (point-min) (point) props))
13808 ;; Then treat the rest of the header lines.
13811 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13812 ;; Then we use the two regular expressions
13813 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13814 ;; select which header lines is to remain visible in the
13816 (goto-char (point-min))
13817 (while (re-search-forward "^[^ \t]*:" nil t)
13818 (beginning-of-line)
13819 ;; We add the headers we want to keep to a list and delete
13820 ;; them from the buffer.
13821 (gnus-put-text-property
13822 (point) (1+ (point)) 'message-rank
13823 (if (or (and visible (looking-at visible))
13825 (not (looking-at ignored))))
13826 (gnus-article-header-rank)
13829 (message-sort-headers-1)
13830 (when (setq beg (text-property-any
13831 (point-min) (point-max) 'message-rank (+ 2 max)))
13832 ;; We make the unwanted headers invisible.
13834 (delete-region beg (point-max))
13835 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13836 (gnus-hide-text-type beg (point-max) 'headers))
13837 ;; Work around XEmacs lossage.
13838 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13840 (defun gnus-article-hide-boring-headers (&optional arg)
13841 "Toggle hiding of headers that aren't very interesting.
13842 If given a negative prefix, always show; if given a positive prefix,
13845 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13847 (set-buffer gnus-article-buffer)
13849 (let ((buffer-read-only nil)
13850 (list gnus-boring-article-headers)
13851 (inhibit-point-motion-hooks t)
13853 (nnheader-narrow-to-headers)
13855 (setq elem (pop list))
13856 (goto-char (point-min))
13858 ;; Hide empty headers.
13860 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13862 (gnus-hide-text-type
13863 (progn (beginning-of-line) (point))
13866 (if (re-search-forward "^[^ \t]" nil t)
13867 (match-beginning 0)
13870 ;; Hide boring Newsgroups header.
13871 ((eq elem 'newsgroups)
13872 (when (equal (message-fetch-field "newsgroups")
13873 (gnus-group-real-name gnus-newsgroup-name))
13874 (gnus-article-hide-header "newsgroups")))
13875 ((eq elem 'followup-to)
13876 (when (equal (message-fetch-field "followup-to")
13877 (message-fetch-field "newsgroups"))
13878 (gnus-article-hide-header "followup-to")))
13879 ((eq elem 'reply-to)
13880 (let ((from (message-fetch-field "from"))
13881 (reply-to (message-fetch-field "reply-to")))
13885 (nth 1 (funcall gnus-extract-address-components from))
13886 (nth 1 (funcall gnus-extract-address-components
13888 (gnus-article-hide-header "reply-to"))))
13890 (let ((date (message-fetch-field "date")))
13892 (< (gnus-days-between date (current-time-string))
13894 (gnus-article-hide-header "date")))))))))))
13896 (defun gnus-article-hide-header (header)
13898 (goto-char (point-min))
13899 (when (re-search-forward (concat "^" header ":") nil t)
13900 (gnus-hide-text-type
13901 (progn (beginning-of-line) (point))
13904 (if (re-search-forward "^[^ \t]" nil t)
13905 (match-beginning 0)
13907 'boring-headers))))
13909 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13910 (defun gnus-article-treat-overstrike ()
13911 "Translate overstrikes into bold text."
13914 (set-buffer gnus-article-buffer)
13915 (let ((buffer-read-only nil))
13916 (while (search-forward "\b" nil t)
13917 (let ((next (following-char))
13918 (previous (char-after (- (point) 2))))
13919 (cond ((eq next previous)
13920 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13921 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
13923 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
13924 (gnus-put-text-property
13925 (- (point) 2) (1- (point)) 'face 'underline))
13927 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13928 (gnus-put-text-property
13929 (point) (1+ (point)) 'face 'underline))))))))
13931 (defun gnus-article-word-wrap ()
13932 "Format too long lines."
13935 (set-buffer gnus-article-buffer)
13936 (let ((buffer-read-only nil))
13938 (goto-char (point-min))
13939 (search-forward "\n\n" nil t)
13941 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13942 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13943 (adaptive-fill-mode t))
13944 (while (not (eobp))
13945 (and (>= (current-column) (min fill-column (window-width)))
13946 (/= (preceding-char) ?:)
13947 (fill-paragraph nil))
13948 (end-of-line 2))))))
13950 (defun gnus-article-remove-cr ()
13951 "Remove carriage returns from an article."
13954 (set-buffer gnus-article-buffer)
13955 (let ((buffer-read-only nil))
13956 (goto-char (point-min))
13957 (while (search-forward "\r" nil t)
13958 (replace-match "" t t)))))
13960 (defun gnus-article-remove-trailing-blank-lines ()
13961 "Remove all trailing blank lines from the article."
13964 (set-buffer gnus-article-buffer)
13965 (let ((buffer-read-only nil))
13966 (goto-char (point-max))
13970 (while (looking-at "^[ \t]*$")
13975 (defun gnus-article-display-x-face (&optional force)
13976 "Look for an X-Face header and display it if present."
13977 (interactive (list 'force))
13979 (set-buffer gnus-article-buffer)
13980 ;; Delete the old process, if any.
13981 (when (process-status "gnus-x-face")
13982 (delete-process "gnus-x-face"))
13983 (let ((inhibit-point-motion-hooks t)
13984 (case-fold-search nil)
13987 (nnheader-narrow-to-headers)
13988 (setq from (message-fetch-field "from"))
13989 (goto-char (point-min))
13990 (when (and gnus-article-x-face-command
13992 ;; Check whether this face is censored.
13993 (not gnus-article-x-face-too-ugly)
13994 (and gnus-article-x-face-too-ugly from
13995 (not (string-match gnus-article-x-face-too-ugly
13997 ;; Has to be present.
13998 (re-search-forward "^X-Face: " nil t))
13999 ;; We now have the area of the buffer where the X-Face is stored.
14000 (let ((beg (point))
14001 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14002 ;; We display the face.
14003 (if (symbolp gnus-article-x-face-command)
14004 ;; The command is a lisp function, so we call it.
14005 (if (gnus-functionp gnus-article-x-face-command)
14006 (funcall gnus-article-x-face-command beg end)
14007 (error "%s is not a function" gnus-article-x-face-command))
14008 ;; The command is a string, so we interpret the command
14009 ;; as a, well, command, and fork it off.
14010 (let ((process-connection-type nil))
14011 (process-kill-without-query
14013 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14014 (process-send-region "gnus-x-face" beg end)
14015 (process-send-eof "gnus-x-face")))))))))
14017 (defalias 'gnus-header-decode-quoted-printable 'gnus-decode-rfc1522)
14018 (defun gnus-decode-rfc1522 ()
14019 "Hack to remove QP encoding from headers."
14020 (let ((case-fold-search t)
14021 (inhibit-point-motion-hooks t)
14022 (buffer-read-only nil)
14026 (goto-char (point-min))
14027 (or (search-forward "\n\n" nil t) (point-max)))
14029 (while (re-search-forward
14030 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14031 (setq string (match-string 1))
14032 (narrow-to-region (match-beginning 0) (match-end 0))
14033 (delete-region (point-min) (point-max))
14035 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14036 (subst-char-in-region (point-min) (point-max) ?_ ? )
14038 (goto-char (point-min))))))
14040 (defun gnus-article-de-quoted-unreadable (&optional force)
14041 "Do a naive translation of a quoted-printable-encoded article.
14042 This is in no way, shape or form meant as a replacement for real MIME
14043 processing, but is simply a stop-gap measure until MIME support is
14045 If FORCE, decode the article whether it is marked as quoted-printable
14047 (interactive (list 'force))
14049 (set-buffer gnus-article-buffer)
14050 (let ((case-fold-search t)
14051 (buffer-read-only nil)
14052 (type (gnus-fetch-field "content-transfer-encoding")))
14053 (gnus-decode-rfc1522)
14055 (and type (string-match "quoted-printable" (downcase type))))
14056 (goto-char (point-min))
14057 (search-forward "\n\n" nil 'move)
14058 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14060 (defun gnus-mime-decode-quoted-printable (from to)
14061 "Decode Quoted-Printable in the region between FROM and TO."
14064 (while (search-forward "=" to t)
14065 (cond ((eq (following-char) ?\n)
14068 ((looking-at "[0-9A-F][0-9A-F]")
14069 (subst-char-in-region
14070 (1- (point)) (point) ?=
14071 (hexl-hex-string-to-integer
14072 (buffer-substring (point) (+ 2 (point)))))
14076 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14078 (defun gnus-article-hide-pgp (&optional arg)
14079 "Toggle hiding of any PGP headers and signatures in the current article.
14080 If given a negative prefix, always show; if given a positive prefix,
14083 (unless (gnus-article-check-hidden-text 'pgp arg)
14085 (set-buffer gnus-article-buffer)
14086 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14087 buffer-read-only beg end)
14089 (goto-char (point-min))
14090 ;; Hide the "header".
14091 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14092 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14094 ;; Hide the actual signature.
14095 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14096 (setq end (1+ (match-beginning 0)))
14099 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14101 ;; Perhaps we shouldn't hide to the end of the buffer
14102 ;; if there is no end to the signature?
14105 ;; Hide "- " PGP quotation markers.
14106 (when (and beg end)
14107 (narrow-to-region beg end)
14108 (goto-char (point-min))
14109 (while (re-search-forward "^- " nil t)
14110 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14113 (defun gnus-article-hide-signature (&optional arg)
14114 "Hide the signature in the current article.
14115 If given a negative prefix, always show; if given a positive prefix,
14118 (unless (gnus-article-check-hidden-text 'signature arg)
14120 (set-buffer gnus-article-buffer)
14122 (let ((buffer-read-only nil))
14123 (when (gnus-narrow-to-signature)
14124 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14126 (defun gnus-article-strip-leading-blank-lines ()
14127 "Remove all blank lines from the beginning of the article."
14130 (set-buffer gnus-article-buffer)
14131 (let (buffer-read-only)
14132 (goto-char (point-min))
14133 (when (search-forward "\n\n" nil t)
14134 (while (looking-at "[ \t]$")
14135 (gnus-delete-line))))))
14137 (defun gnus-narrow-to-signature ()
14138 "Narrow to the signature."
14140 (goto-char (point-max))
14141 (when (re-search-backward gnus-signature-separator nil t)
14143 (when (or (null gnus-signature-limit)
14144 (and (numberp gnus-signature-limit)
14145 (< (- (point-max) (point)) gnus-signature-limit))
14146 (and (gnus-functionp gnus-signature-limit)
14147 (funcall gnus-signature-limit))
14148 (and (stringp gnus-signature-limit)
14149 (not (re-search-forward gnus-signature-limit nil t))))
14150 (narrow-to-region (point) (point-max))
14153 (defun gnus-article-check-hidden-text (type arg)
14154 "Return nil if hiding is necessary."
14156 (set-buffer gnus-article-buffer)
14157 (let ((hide (gnus-article-hidden-text-p type)))
14158 (cond ((or (and (null arg) (eq hide 'hidden))
14159 (and arg (< 0 (prefix-numeric-value arg))))
14160 (gnus-article-show-hidden-text type))
14162 (gnus-article-show-hidden-text type t))
14165 (defun gnus-article-hidden-text-p (type)
14166 "Say whether the current buffer contains hidden text of type TYPE."
14167 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14169 (if (get-text-property pos 'invisible)
14173 (defun gnus-article-hide (&optional arg force)
14174 "Hide all the gruft in the current article.
14175 This means that PGP stuff, signatures, cited text and (some)
14176 headers will be hidden.
14177 If given a prefix, show the hidden text instead."
14178 (interactive (list current-prefix-arg 'force))
14179 (gnus-article-hide-headers arg)
14180 (gnus-article-hide-pgp arg)
14181 (gnus-article-hide-citation-maybe arg force)
14182 (gnus-article-hide-signature arg))
14184 (defun gnus-article-show-hidden-text (type &optional hide)
14185 "Show all hidden text of type TYPE.
14186 If HIDE, hide the text instead."
14188 (set-buffer gnus-article-buffer)
14189 (let ((buffer-read-only nil)
14190 (inhibit-point-motion-hooks t)
14192 (while (gnus-goto-char (text-property-any
14193 beg (point-max) 'gnus-type type))
14197 (gnus-hide-text beg (point) gnus-hidden-properties)
14198 (gnus-unhide-text beg (point)))
14199 (setq beg (point)))
14202 (defvar gnus-article-time-units
14203 `((year . ,(* 365.25 24 60 60))
14204 (week . ,(* 7 24 60 60))
14205 (day . ,(* 24 60 60))
14206 (hour . ,(* 60 60))
14209 "Mapping from time units to seconds.")
14211 (defun gnus-article-date-ut (&optional type highlight)
14212 "Convert DATE date to universal time in the current article.
14213 If TYPE is `local', convert to local time; if it is `lapsed', output
14214 how much time has lapsed since DATE."
14215 (interactive (list 'ut t))
14216 (let* ((header (or gnus-current-headers
14217 (gnus-summary-article-header) ""))
14218 (date (and (vectorp header) (mail-header-date header)))
14219 (date-regexp "^Date: \\|^X-Sent: ")
14220 (now (current-time))
14221 (inhibit-point-motion-hooks t)
14223 (when (and date (not (string= date "")))
14225 (set-buffer gnus-article-buffer)
14227 (nnheader-narrow-to-headers)
14228 (let ((buffer-read-only nil))
14229 ;; Delete any old Date headers.
14230 (if (re-search-forward date-regexp nil t)
14232 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14233 eface (get-text-property (1- (gnus-point-at-eol))
14235 (message-remove-header date-regexp t)
14236 (beginning-of-line))
14237 (goto-char (point-max)))
14238 (insert (gnus-make-date-line date type))
14239 ;; Do highlighting.
14241 (when (and (gnus-visual-p 'article-highlight 'highlight)
14242 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14243 (gnus-put-text-property (match-beginning 1) (match-end 1)
14245 (gnus-put-text-property (match-beginning 2) (match-end 2)
14246 'face eface))))))))
14248 (defun gnus-make-date-line (date type)
14249 "Return a DATE line of TYPE."
14251 ;; Convert to the local timezone. We have to slap a
14252 ;; `condition-case' round the calls to the timezone
14253 ;; functions since they aren't particularly resistant to
14256 (concat "Date: " (condition-case ()
14257 (timezone-make-date-arpa-standard date)
14260 ;; Convert to Universal Time.
14264 (timezone-make-date-arpa-standard date nil "UT")
14267 ;; Get the original date from the article.
14268 ((eq type 'original)
14269 (concat "Date: " date "\n"))
14270 ;; Do an X-Sent lapsed format.
14272 ;; If the date is seriously mangled, the timezone
14273 ;; functions are liable to bug out, so we condition-case
14274 ;; the entire thing.
14275 (let* ((now (current-time))
14280 (timezone-make-date-arpa-standard
14281 (current-time-string now)
14282 (current-time-zone now) "UT"))
14284 (timezone-make-date-arpa-standard
14287 (real-sec (+ (* (float (car real-time)) 65536)
14289 (sec (abs real-sec))
14292 ((equal real-time '(0 0))
14293 "X-Sent: Unknown\n")
14299 ;; This is a bit convoluted, but basically we go
14300 ;; through the time units for years, weeks, etc,
14301 ;; and divide things to see whether that results
14302 ;; in positive answers.
14305 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14306 ;; The (remaining) seconds are too few to
14307 ;; be divided into this time unit.
14309 ;; It's big enough, so we output it.
14310 (setq sec (- sec (* num (cdr unit))))
14312 (concat (if prev ", " "") (int-to-string
14314 " " (symbol-name (car unit))
14315 (if (> num 1) "s" ""))
14317 gnus-article-time-units "")
14318 ;; If dates are odd, then it might appear like the
14319 ;; article was sent in the future.
14322 " in the future\n"))))))
14324 (error "Unknown conversion type: %s" type))))
14326 (defun gnus-article-date-local (&optional highlight)
14327 "Convert the current article date to the local timezone."
14328 (interactive (list t))
14329 (gnus-article-date-ut 'local highlight))
14331 (defun gnus-article-date-original (&optional highlight)
14332 "Convert the current article date to what it was originally.
14333 This is only useful if you have used some other date conversion
14334 function and want to see what the date was before converting."
14335 (interactive (list t))
14336 (gnus-article-date-ut 'original highlight))
14338 (defun gnus-article-date-lapsed (&optional highlight)
14339 "Convert the current article date to time lapsed since it was sent."
14340 (interactive (list t))
14341 (gnus-article-date-ut 'lapsed highlight))
14343 (defun gnus-article-maybe-highlight ()
14344 "Do some article highlighting if `gnus-visual' is non-nil."
14345 (if (gnus-visual-p 'article-highlight 'highlight)
14346 (gnus-article-highlight-some)))
14350 (defun gnus-output-to-rmail (file-name)
14351 "Append the current article to an Rmail file named FILE-NAME."
14353 ;; Most of these codes are borrowed from rmailout.el.
14354 (setq file-name (expand-file-name file-name))
14355 (setq rmail-default-rmail-file file-name)
14356 (let ((artbuf (current-buffer))
14357 (tmpbuf (get-buffer-create " *Gnus-output*")))
14359 (or (get-file-buffer file-name)
14360 (file-exists-p file-name)
14361 (if (gnus-yes-or-no-p
14362 (concat "\"" file-name "\" does not exist, create it? "))
14363 (let ((file-buffer (create-file-buffer file-name)))
14365 (set-buffer file-buffer)
14366 (rmail-insert-rmail-file-header)
14367 (let ((require-final-newline nil))
14368 (write-region (point-min) (point-max) file-name t 1)))
14369 (kill-buffer file-buffer))
14370 (error "Output file does not exist")))
14371 (set-buffer tmpbuf)
14372 (buffer-disable-undo (current-buffer))
14374 (insert-buffer-substring artbuf)
14375 (gnus-convert-article-to-rmail)
14376 ;; Decide whether to append to a file or to an Emacs buffer.
14377 (let ((outbuf (get-file-buffer file-name)))
14379 (append-to-file (point-min) (point-max) file-name)
14380 ;; File has been visited, in buffer OUTBUF.
14381 (set-buffer outbuf)
14382 (let ((buffer-read-only nil)
14383 (msg (and (boundp 'rmail-current-message)
14384 (symbol-value 'rmail-current-message))))
14385 ;; If MSG is non-nil, buffer is in RMAIL mode.
14388 (narrow-to-region (point-max) (point-max))))
14389 (insert-buffer-substring tmpbuf)
14392 (goto-char (point-min))
14394 (search-backward "\^_")
14395 (narrow-to-region (point) (point-max))
14396 (goto-char (1+ (point-min)))
14397 (rmail-count-new-messages t)
14398 (rmail-show-message msg)))))))
14399 (kill-buffer tmpbuf)))
14401 (defun gnus-output-to-file (file-name)
14402 "Append the current article to a file named FILE-NAME."
14403 (setq file-name (expand-file-name file-name))
14404 (let ((artbuf (current-buffer))
14405 (tmpbuf (get-buffer-create " *Gnus-output*")))
14407 (set-buffer tmpbuf)
14408 (buffer-disable-undo (current-buffer))
14410 (insert-buffer-substring artbuf)
14411 ;; Append newline at end of the buffer as separator, and then
14412 ;; save it to file.
14413 (goto-char (point-max))
14415 (append-to-file (point-min) (point-max) file-name))
14416 (kill-buffer tmpbuf)))
14418 (defun gnus-convert-article-to-rmail ()
14419 "Convert article in current buffer to Rmail message format."
14420 (let ((buffer-read-only nil))
14421 ;; Convert article directly into Babyl format.
14422 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14423 (goto-char (point-min))
14424 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14425 (while (search-forward "\n\^_" nil t) ;single char
14426 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14427 (goto-char (point-max))
14430 (defun gnus-narrow-to-page (&optional arg)
14431 "Narrow the article buffer to a page.
14432 If given a numerical ARG, move forward ARG pages."
14434 (setq arg (if arg (prefix-numeric-value arg) 0))
14436 (set-buffer gnus-article-buffer)
14437 (goto-char (point-min))
14439 (when (gnus-visual-p 'page-marker)
14440 (let ((buffer-read-only nil))
14441 (gnus-remove-text-with-property 'gnus-prev)
14442 (gnus-remove-text-with-property 'gnus-next)))
14445 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14447 (re-search-forward page-delimiter nil 'move arg)))
14448 (goto-char (match-end 0)))
14451 (if (re-search-forward page-delimiter nil 'move)
14452 (match-beginning 0)
14454 (when (and (gnus-visual-p 'page-marker)
14455 (not (= (point-min) 1)))
14457 (goto-char (point-min))
14458 (gnus-insert-prev-page-button)))
14459 (when (and (gnus-visual-p 'page-marker)
14460 (not (= (1- (point-max)) (buffer-size))))
14462 (goto-char (point-max))
14463 (gnus-insert-next-page-button)))))
14465 ;; Article mode commands
14467 (defun gnus-article-goto-next-page ()
14468 "Show the next page of the article."
14470 (when (gnus-article-next-page)
14471 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14473 (defun gnus-article-goto-prev-page ()
14474 "Show the next page of the article."
14476 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14477 (gnus-article-prev-page nil)))
14479 (defun gnus-article-next-page (&optional lines)
14480 "Show the next page of the current article.
14481 If end of article, return non-nil. Otherwise return nil.
14482 Argument LINES specifies lines to be scrolled up."
14484 (move-to-window-line -1)
14485 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14486 (if (save-excursion
14488 (and (pos-visible-in-window-p) ;Not continuation line.
14490 ;; Nothing in this page.
14491 (if (or (not gnus-break-pages)
14494 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14496 (gnus-narrow-to-page 1) ;Go to next page.
14498 ;; More in this page.
14502 ;; Long lines may cause an end-of-buffer error.
14503 (goto-char (point-max))))
14504 (move-to-window-line 0)
14507 (defun gnus-article-prev-page (&optional lines)
14508 "Show previous page of current article.
14509 Argument LINES specifies lines to be scrolled down."
14511 (move-to-window-line 0)
14512 (if (and gnus-break-pages
14514 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14516 (gnus-narrow-to-page -1) ;Go to previous page.
14517 (goto-char (point-max))
14521 (scroll-down lines)
14523 (move-to-window-line 0))))
14525 (defun gnus-article-refer-article ()
14526 "Read article specified by message-id around point."
14528 (let ((point (point)))
14529 (search-forward ">" nil t) ;Move point to end of "<....>".
14530 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14531 (let ((message-id (match-string 1)))
14533 (set-buffer gnus-summary-buffer)
14534 (gnus-summary-refer-article message-id))
14535 (goto-char (point))
14536 (error "No references around point"))))
14538 (defun gnus-article-show-summary ()
14539 "Reconfigure windows to show summary buffer."
14541 (gnus-configure-windows 'article)
14542 (gnus-summary-goto-subject gnus-current-article))
14544 (defun gnus-article-describe-briefly ()
14545 "Describe article mode commands briefly."
14548 (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")))
14550 (defun gnus-article-summary-command ()
14551 "Execute the last keystroke in the summary buffer."
14553 (let ((obuf (current-buffer))
14554 (owin (current-window-configuration))
14556 (switch-to-buffer gnus-summary-buffer 'norecord)
14557 (setq func (lookup-key (current-local-map) (this-command-keys)))
14558 (call-interactively func)
14560 (set-window-configuration owin)
14561 (set-window-point (get-buffer-window (current-buffer)) (point))))
14563 (defun gnus-article-summary-command-nosave ()
14564 "Execute the last keystroke in the summary buffer."
14567 (pop-to-buffer gnus-summary-buffer 'norecord)
14568 (setq func (lookup-key (current-local-map) (this-command-keys)))
14569 (call-interactively func)))
14571 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14572 "Read a summary buffer key sequence and execute it from the article buffer."
14575 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14576 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14580 (set-buffer gnus-summary-buffer)
14581 (push (or key last-command-event) unread-command-events)
14582 (setq keys (read-key-sequence nil)))
14585 (if (member keys nosaves)
14587 (pop-to-buffer gnus-summary-buffer 'norecord)
14588 (if (setq func (lookup-key (current-local-map) keys))
14589 (call-interactively func)
14591 (let ((obuf (current-buffer))
14592 (owin (current-window-configuration))
14595 (if not-restore-window
14596 (pop-to-buffer gnus-summary-buffer 'norecord)
14597 (switch-to-buffer gnus-summary-buffer 'norecord))
14598 (setq in-buffer (current-buffer))
14599 (if (setq func (lookup-key (current-local-map) keys))
14600 (call-interactively func)
14602 (when (eq in-buffer (current-buffer))
14604 (unless not-restore-window
14605 (set-window-configuration owin))
14606 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14610 ;;; Kill file handling.
14614 (defalias 'gnus-batch-kill 'gnus-batch-score)
14616 (defun gnus-batch-score ()
14617 "Run batched scoring.
14618 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14619 Newsgroups is a list of strings in Bnews format. If you want to score
14620 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14621 score the alt hierarchy, you'd say \"!alt.all\"."
14624 (gnus-newsrc-parse-options
14625 (apply (function concat)
14626 (mapcar (lambda (g) (concat g " "))
14627 command-line-args-left))))
14628 (gnus-expert-user t)
14629 (nnmail-spool-file nil)
14630 (gnus-use-dribble-file nil)
14631 (yes (car yes-and-no))
14632 (no (cdr yes-and-no))
14634 ;; Disable verbose message.
14635 gnus-novice-user gnus-large-newsgroup)
14636 ;; Eat all arguments.
14637 (setq command-line-args-left nil)
14640 ;; Apply kills to specified newsgroups in command line arguments.
14641 (setq newsrc (cdr gnus-newsrc-alist))
14643 (setq group (caar newsrc))
14644 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14645 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14647 (or (eq (car entry) t)
14648 (not (zerop (car entry)))))
14649 (if yes (string-match yes group) t)
14650 (or (null no) (not (string-match no group))))
14652 (gnus-summary-read-group group nil t nil t)
14653 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14654 (gnus-summary-exit))))
14655 (setq newsrc (cdr newsrc)))
14657 (switch-to-buffer gnus-group-buffer)
14658 (gnus-group-save-newsrc)))
14660 (defun gnus-apply-kill-file ()
14661 "Apply a kill file to the current newsgroup.
14662 Returns the number of articles marked as read."
14663 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14664 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14665 (gnus-apply-kill-file-internal)
14668 (defun gnus-kill-save-kill-buffer ()
14669 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14670 (when (get-file-buffer file)
14672 (set-buffer (get-file-buffer file))
14673 (and (buffer-modified-p) (save-buffer))
14674 (kill-buffer (current-buffer))))))
14676 (defvar gnus-kill-file-name "KILL"
14677 "Suffix of the kill files.")
14679 (defun gnus-newsgroup-kill-file (newsgroup)
14680 "Return the name of a kill file name for NEWSGROUP.
14681 If NEWSGROUP is nil, return the global kill file name instead."
14683 ;; The global KILL file is placed at top of the directory.
14684 ((or (null newsgroup)
14685 (string-equal newsgroup ""))
14686 (expand-file-name gnus-kill-file-name
14687 gnus-kill-files-directory))
14688 ;; Append ".KILL" to newsgroup name.
14689 ((gnus-use-long-file-name 'not-kill)
14690 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14691 "." gnus-kill-file-name)
14692 gnus-kill-files-directory))
14693 ;; Place "KILL" under the hierarchical directory.
14695 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14696 "/" gnus-kill-file-name)
14697 gnus-kill-files-directory))))
14704 (defvar gnus-dribble-ignore nil)
14705 (defvar gnus-dribble-eval-file nil)
14707 (defun gnus-dribble-file-name ()
14708 "Return the dribble file for the current .newsrc."
14710 (if gnus-dribble-directory
14711 (concat (file-name-as-directory gnus-dribble-directory)
14712 (file-name-nondirectory gnus-current-startup-file))
14713 gnus-current-startup-file)
14716 (defun gnus-dribble-enter (string)
14717 "Enter STRING into the dribble buffer."
14718 (if (and (not gnus-dribble-ignore)
14719 gnus-dribble-buffer
14720 (buffer-name gnus-dribble-buffer))
14721 (let ((obuf (current-buffer)))
14722 (set-buffer gnus-dribble-buffer)
14723 (insert string "\n")
14724 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14725 (set-buffer obuf))))
14727 (defun gnus-dribble-read-file ()
14728 "Read the dribble file from disk."
14729 (let ((dribble-file (gnus-dribble-file-name)))
14731 (set-buffer (setq gnus-dribble-buffer
14733 (file-name-nondirectory dribble-file))))
14734 (gnus-add-current-to-buffer-list)
14736 (setq buffer-file-name dribble-file)
14738 (buffer-disable-undo (current-buffer))
14739 (bury-buffer (current-buffer))
14740 (set-buffer-modified-p nil)
14741 (let ((auto (make-auto-save-file-name))
14742 (gnus-dribble-ignore t)
14744 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14745 ;; Load whichever file is newest -- the auto save file
14746 ;; or the "real" file.
14747 (if (file-newer-than-file-p auto dribble-file)
14748 (insert-file-contents auto)
14749 (insert-file-contents dribble-file))
14750 (unless (zerop (buffer-size))
14751 (set-buffer-modified-p t))
14752 ;; Set the file modes to reflect the .newsrc file modes.
14754 (when (and (file-exists-p gnus-current-startup-file)
14755 (setq modes (file-modes gnus-current-startup-file)))
14756 (set-file-modes dribble-file modes))
14757 ;; Possibly eval the file later.
14758 (when (gnus-y-or-n-p
14759 "Auto-save file exists. Do you want to read it? ")
14760 (setq gnus-dribble-eval-file t)))))))
14762 (defun gnus-dribble-eval-file ()
14763 (if (not gnus-dribble-eval-file)
14765 (setq gnus-dribble-eval-file nil)
14767 (let ((gnus-dribble-ignore t))
14768 (set-buffer gnus-dribble-buffer)
14769 (eval-buffer (current-buffer))))))
14771 (defun gnus-dribble-delete-file ()
14772 (if (file-exists-p (gnus-dribble-file-name))
14773 (delete-file (gnus-dribble-file-name)))
14774 (if gnus-dribble-buffer
14776 (set-buffer gnus-dribble-buffer)
14777 (let ((auto (make-auto-save-file-name)))
14778 (if (file-exists-p auto)
14779 (delete-file auto))
14781 (set-buffer-modified-p nil)))))
14783 (defun gnus-dribble-save ()
14784 (if (and gnus-dribble-buffer
14785 (buffer-name gnus-dribble-buffer))
14787 (set-buffer gnus-dribble-buffer)
14790 (defun gnus-dribble-clear ()
14792 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14794 (set-buffer gnus-dribble-buffer)
14796 (set-buffer-modified-p nil)
14797 (setq buffer-saved-size (buffer-size))))))
14801 ;;; Server Communication
14804 (defun gnus-start-news-server (&optional confirm)
14805 "Open a method for getting news.
14806 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14808 (if gnus-current-select-method
14809 ;; Stream is already opened.
14811 ;; Open NNTP server.
14812 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14815 ;; Read server name with completion.
14816 (setq gnus-nntp-server
14817 (completing-read "NNTP server: "
14818 (mapcar (lambda (server) (list server))
14819 (cons (list gnus-nntp-server)
14820 gnus-secondary-servers))
14821 nil nil gnus-nntp-server))))
14823 (if (and gnus-nntp-server
14824 (stringp gnus-nntp-server)
14825 (not (string= gnus-nntp-server "")))
14826 (setq gnus-select-method
14827 (cond ((or (string= gnus-nntp-server "")
14828 (string= gnus-nntp-server "::"))
14829 (list 'nnspool (system-name)))
14830 ((string-match "^:" gnus-nntp-server)
14831 (list 'nnmh gnus-nntp-server
14832 (list 'nnmh-directory
14833 (file-name-as-directory
14835 (concat "~/" (substring
14836 gnus-nntp-server 1)))))
14837 (list 'nnmh-get-new-mail nil)))
14839 (list 'nntp gnus-nntp-server)))))
14841 (setq how (car gnus-select-method))
14842 (cond ((eq how 'nnspool)
14844 (gnus-message 5 "Looking up local news spool..."))
14847 (gnus-message 5 "Looking up mh spool..."))
14850 (setq gnus-current-select-method gnus-select-method)
14851 (run-hooks 'gnus-open-server-hook)
14853 ;; gnus-open-server-hook might have opened it
14854 (gnus-server-opened gnus-select-method)
14855 (gnus-open-server gnus-select-method)
14858 "%s (%s) open error: '%s'. Continue? "
14859 (car gnus-select-method) (cadr gnus-select-method)
14860 (gnus-status-message gnus-select-method)))
14861 (gnus-error 1 "Couldn't open server on %s"
14862 (nth 1 gnus-select-method))))))
14864 (defun gnus-check-group (group)
14865 "Try to make sure that the server where GROUP exists is alive."
14866 (let ((method (gnus-find-method-for-group group)))
14867 (or (gnus-server-opened method)
14868 (gnus-open-server method))))
14870 (defun gnus-check-server (&optional method silent)
14871 "Check whether the connection to METHOD is down.
14872 If METHOD is nil, use `gnus-select-method'.
14873 If it is down, start it up (again)."
14874 (let ((method (or method gnus-select-method)))
14875 ;; Transform virtual server names into select methods.
14876 (when (stringp method)
14877 (setq method (gnus-server-to-method method)))
14878 (if (gnus-server-opened method)
14879 ;; The stream is already opened.
14881 ;; Open the server.
14883 (gnus-message 5 "Opening %s server%s..." (car method)
14884 (if (equal (nth 1 method) "") ""
14885 (format " on %s" (nth 1 method)))))
14886 (run-hooks 'gnus-open-server-hook)
14888 (gnus-open-server method)
14892 (defun gnus-get-function (method function)
14893 "Return a function symbol based on METHOD and FUNCTION."
14894 ;; Translate server names into methods.
14896 (error "Attempted use of a nil select method"))
14897 (when (stringp method)
14898 (setq method (gnus-server-to-method method)))
14899 (let ((func (intern (format "%s-%s" (car method) function))))
14900 ;; If the functions isn't bound, we require the backend in
14902 (unless (fboundp func)
14903 (require (car method))
14904 (unless (fboundp func)
14905 ;; This backend doesn't implement this function.
14906 (error "No such function: %s" func)))
14911 ;;; Interface functions to the backends.
14914 (defun gnus-open-server (method)
14915 "Open a connection to METHOD."
14916 (when (stringp method)
14917 (setq method (gnus-server-to-method method)))
14918 (let ((elem (assoc method gnus-opened-servers)))
14919 ;; If this method was previously denied, we just return nil.
14920 (if (eq (nth 1 elem) 'denied)
14922 (gnus-message 1 "Denied server")
14924 ;; Open the server.
14926 (funcall (gnus-get-function method 'open-server)
14927 (nth 1 method) (nthcdr 2 method))))
14928 ;; If this hasn't been opened before, we add it to the list.
14930 (setq elem (list method nil)
14931 gnus-opened-servers (cons elem gnus-opened-servers)))
14932 ;; Set the status of this server.
14933 (setcar (cdr elem) (if result 'ok 'denied))
14934 ;; Return the result from the "open" call.
14937 (defun gnus-close-server (method)
14938 "Close the connection to METHOD."
14939 (when (stringp method)
14940 (setq method (gnus-server-to-method method)))
14941 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14943 (defun gnus-request-list (method)
14944 "Request the active file from METHOD."
14945 (when (stringp method)
14946 (setq method (gnus-server-to-method method)))
14947 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14949 (defun gnus-request-list-newsgroups (method)
14950 "Request the newsgroups file from METHOD."
14951 (when (stringp method)
14952 (setq method (gnus-server-to-method method)))
14953 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14955 (defun gnus-request-newgroups (date method)
14956 "Request all new groups since DATE from METHOD."
14957 (when (stringp method)
14958 (setq method (gnus-server-to-method method)))
14959 (funcall (gnus-get-function method 'request-newgroups)
14960 date (nth 1 method)))
14962 (defun gnus-server-opened (method)
14963 "Check whether a connection to METHOD has been opened."
14964 (when (stringp method)
14965 (setq method (gnus-server-to-method method)))
14966 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14968 (defun gnus-status-message (method)
14969 "Return the status message from METHOD.
14970 If METHOD is a string, it is interpreted as a group name. The method
14971 this group uses will be queried."
14972 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14974 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14976 (defun gnus-request-group (group &optional dont-check method)
14977 "Request GROUP. If DONT-CHECK, no information is required."
14978 (let ((method (or method (gnus-find-method-for-group group))))
14979 (when (stringp method)
14980 (setq method (gnus-server-to-method method)))
14981 (funcall (gnus-get-function method 'request-group)
14982 (gnus-group-real-name group) (nth 1 method) dont-check)))
14984 (defun gnus-request-asynchronous (group &optional articles)
14985 "Request that GROUP behave asynchronously.
14986 ARTICLES is the `data' of the group."
14987 (let ((method (gnus-find-method-for-group group)))
14988 (funcall (gnus-get-function method 'request-asynchronous)
14989 (gnus-group-real-name group) (nth 1 method) articles)))
14991 (defun gnus-list-active-group (group)
14992 "Request active information on GROUP."
14993 (let ((method (gnus-find-method-for-group group))
14994 (func 'list-active-group))
14995 (when (gnus-check-backend-function func group)
14996 (funcall (gnus-get-function method func)
14997 (gnus-group-real-name group) (nth 1 method)))))
14999 (defun gnus-request-group-description (group)
15000 "Request a description of GROUP."
15001 (let ((method (gnus-find-method-for-group group))
15002 (func 'request-group-description))
15003 (when (gnus-check-backend-function func group)
15004 (funcall (gnus-get-function method func)
15005 (gnus-group-real-name group) (nth 1 method)))))
15007 (defun gnus-close-group (group)
15008 "Request the GROUP be closed."
15009 (let ((method (gnus-find-method-for-group group)))
15010 (funcall (gnus-get-function method 'close-group)
15011 (gnus-group-real-name group) (nth 1 method))))
15013 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15014 "Request headers for ARTICLES in GROUP.
15015 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15016 (let ((method (gnus-find-method-for-group group)))
15017 (if (and gnus-use-cache (numberp (car articles)))
15018 (gnus-cache-retrieve-headers articles group fetch-old)
15019 (funcall (gnus-get-function method 'retrieve-headers)
15020 articles (gnus-group-real-name group) (nth 1 method)
15023 (defun gnus-retrieve-groups (groups method)
15024 "Request active information on GROUPS from METHOD."
15025 (when (stringp method)
15026 (setq method (gnus-server-to-method method)))
15027 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15029 (defun gnus-request-type (group &optional article)
15030 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15031 (let ((method (gnus-find-method-for-group group)))
15032 (if (not (gnus-check-backend-function 'request-type (car method)))
15034 (funcall (gnus-get-function method 'request-type)
15035 (gnus-group-real-name group) article))))
15037 (defun gnus-request-update-mark (group article mark)
15038 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15039 (let ((method (gnus-find-method-for-group group)))
15040 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15042 (funcall (gnus-get-function method 'request-update-mark)
15043 (gnus-group-real-name group) article mark))))
15045 (defun gnus-request-article (article group &optional buffer)
15046 "Request the ARTICLE in GROUP.
15047 ARTICLE can either be an article number or an article Message-ID.
15048 If BUFFER, insert the article in that group."
15049 (let ((method (gnus-find-method-for-group group)))
15050 (funcall (gnus-get-function method 'request-article)
15051 article (gnus-group-real-name group) (nth 1 method) buffer)))
15053 (defun gnus-request-head (article group)
15054 "Request the head of ARTICLE in GROUP."
15055 (let ((method (gnus-find-method-for-group group)))
15056 (funcall (gnus-get-function method 'request-head)
15057 article (gnus-group-real-name group) (nth 1 method))))
15059 (defun gnus-request-body (article group)
15060 "Request the body of ARTICLE in GROUP."
15061 (let ((method (gnus-find-method-for-group group)))
15062 (funcall (gnus-get-function method 'request-body)
15063 article (gnus-group-real-name group) (nth 1 method))))
15065 (defun gnus-request-post (method)
15066 "Post the current buffer using METHOD."
15067 (when (stringp method)
15068 (setq method (gnus-server-to-method method)))
15069 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15071 (defun gnus-request-scan (group method)
15072 "Request a SCAN being performed in GROUP from METHOD.
15073 If GROUP is nil, all groups on METHOD are scanned."
15074 (let ((method (if group (gnus-find-method-for-group group) method)))
15075 (funcall (gnus-get-function method 'request-scan)
15076 (and group (gnus-group-real-name group)) (nth 1 method))))
15078 (defsubst gnus-request-update-info (info method)
15079 "Request that METHOD update INFO."
15080 (when (stringp method)
15081 (setq method (gnus-server-to-method method)))
15082 (when (gnus-check-backend-function 'request-update-info (car method))
15083 (funcall (gnus-get-function method 'request-update-info)
15084 (gnus-group-real-name (gnus-info-group info))
15085 info (nth 1 method))))
15087 (defun gnus-request-expire-articles (articles group &optional force)
15088 (let ((method (gnus-find-method-for-group group)))
15089 (funcall (gnus-get-function method 'request-expire-articles)
15090 articles (gnus-group-real-name group) (nth 1 method)
15093 (defun gnus-request-move-article
15094 (article group server accept-function &optional last)
15095 (let ((method (gnus-find-method-for-group group)))
15096 (funcall (gnus-get-function method 'request-move-article)
15097 article (gnus-group-real-name group)
15098 (nth 1 method) accept-function last)))
15100 (defun gnus-request-accept-article (group method &optional last)
15101 ;; Make sure there's a newline at the end of the article.
15102 (when (stringp method)
15103 (setq method (gnus-server-to-method method)))
15104 (when (and (not method)
15106 (setq method (gnus-find-method-for-group group)))
15107 (goto-char (point-max))
15110 (let ((func (car (or method (gnus-find-method-for-group group)))))
15111 (funcall (intern (format "%s-request-accept-article" func))
15112 (if (stringp group) (gnus-group-real-name group) group)
15116 (defun gnus-request-replace-article (article group buffer)
15117 (let ((func (car (gnus-find-method-for-group group))))
15118 (funcall (intern (format "%s-request-replace-article" func))
15119 article (gnus-group-real-name group) buffer)))
15121 (defun gnus-request-associate-buffer (group)
15122 (let ((method (gnus-find-method-for-group group)))
15123 (funcall (gnus-get-function method 'request-associate-buffer)
15124 (gnus-group-real-name group))))
15126 (defun gnus-request-restore-buffer (article group)
15127 "Request a new buffer restored to the state of ARTICLE."
15128 (let ((method (gnus-find-method-for-group group)))
15129 (funcall (gnus-get-function method 'request-restore-buffer)
15130 article (gnus-group-real-name group) (nth 1 method))))
15132 (defun gnus-request-create-group (group &optional method)
15133 (when (stringp method)
15134 (setq method (gnus-server-to-method method)))
15135 (let ((method (or method (gnus-find-method-for-group group))))
15136 (funcall (gnus-get-function method 'request-create-group)
15137 (gnus-group-real-name group) (nth 1 method))))
15139 (defun gnus-request-delete-group (group &optional force)
15140 (let ((method (gnus-find-method-for-group group)))
15141 (funcall (gnus-get-function method 'request-delete-group)
15142 (gnus-group-real-name group) force (nth 1 method))))
15144 (defun gnus-request-rename-group (group new-name)
15145 (let ((method (gnus-find-method-for-group group)))
15146 (funcall (gnus-get-function method 'request-rename-group)
15147 (gnus-group-real-name group)
15148 (gnus-group-real-name new-name) (nth 1 method))))
15150 (defun gnus-member-of-valid (symbol group)
15151 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15152 (memq symbol (assoc
15153 (symbol-name (car (gnus-find-method-for-group group)))
15154 gnus-valid-select-methods)))
15156 (defun gnus-method-option-p (method option)
15157 "Return non-nil if select METHOD has OPTION as a parameter."
15158 (when (stringp method)
15159 (setq method (gnus-server-to-method method)))
15160 (memq option (assoc (format "%s" (car method))
15161 gnus-valid-select-methods)))
15163 (defun gnus-server-extend-method (group method)
15164 ;; This function "extends" a virtual server. If the server is
15165 ;; "hello", and the select method is ("hello" (my-var "something"))
15166 ;; in the group "alt.alt", this will result in a new virtual server
15167 ;; called "hello+alt.alt".
15169 (gnus-copy-sequence
15170 (if (equal (car method) "native") gnus-select-method
15171 (cdr (assoc (car method) gnus-server-alist))))))
15172 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15173 (nconc entry (cdr method))))
15175 (defun gnus-find-method-for-group (group &optional info)
15176 "Find the select method that GROUP uses."
15177 (or gnus-override-method
15179 gnus-select-method)
15180 (let ((info (or info (gnus-get-info group)))
15183 (not (setq method (gnus-info-method info)))
15184 (equal method "native"))
15187 (cond ((stringp method)
15188 (gnus-server-to-method method))
15189 ((stringp (car method))
15190 (gnus-server-extend-method group method))
15193 (cond ((equal (cadr method) "")
15195 ((null (cadr method))
15196 (list (car method) ""))
15198 (gnus-server-add-address method)))))))
15200 (defun gnus-check-backend-function (func group)
15201 "Check whether GROUP supports function FUNC."
15202 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15204 (fboundp (intern (format "%s-%s" method func)))))
15206 (defun gnus-methods-using (feature)
15207 "Find all methods that have FEATURE."
15208 (let ((valids gnus-valid-select-methods)
15211 (if (memq feature (car valids))
15212 (setq outs (cons (car valids) outs)))
15213 (setq valids (cdr valids)))
15218 ;;; Active & Newsrc File Handling
15221 (defun gnus-setup-news (&optional rawfile level dont-connect)
15222 "Setup news information.
15223 If RAWFILE is non-nil, the .newsrc file will also be read.
15224 If LEVEL is non-nil, the news will be set up at level LEVEL."
15225 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15228 ;; Clear some variables to re-initialize news information.
15229 (setq gnus-newsrc-alist nil
15230 gnus-active-hashtb nil)
15231 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15232 (gnus-read-newsrc-file rawfile))
15234 (when (and (not (assoc "archive" gnus-server-alist))
15235 gnus-message-archive-method)
15236 (push (cons "archive" gnus-message-archive-method)
15237 gnus-server-alist))
15239 ;; If we don't read the complete active file, we fill in the
15241 (if (or (null gnus-read-active-file)
15242 (eq gnus-read-active-file 'some))
15243 (gnus-update-active-hashtb-from-killed))
15245 ;; Read the active file and create `gnus-active-hashtb'.
15246 ;; If `gnus-read-active-file' is nil, then we just create an empty
15247 ;; hash table. The partial filling out of the hash table will be
15248 ;; done in `gnus-get-unread-articles'.
15249 (and gnus-read-active-file
15251 (gnus-read-active-file))
15253 (or gnus-active-hashtb
15254 (setq gnus-active-hashtb (make-vector 4095 0)))
15256 ;; Initialize the cache.
15257 (when gnus-use-cache
15260 ;; Possibly eval the dribble file.
15261 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15263 (gnus-update-format-specifications)
15265 ;; See whether we need to read the description file.
15266 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15267 (not gnus-description-hashtb)
15269 gnus-read-active-file)
15270 (gnus-read-all-descriptions-files))
15272 ;; Find new newsgroups and treat them.
15273 (if (and init gnus-check-new-newsgroups (not level)
15274 (gnus-check-server gnus-select-method))
15275 (gnus-find-new-newsgroups))
15277 ;; We might read in new NoCeM messages here.
15278 (when (and gnus-use-nocem
15280 (not dont-connect))
15281 (gnus-nocem-scan-groups))
15283 ;; Find the number of unread articles in each non-dead group.
15284 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15285 (gnus-get-unread-articles level))
15287 (if (and init gnus-check-bogus-newsgroups
15288 gnus-read-active-file (not level)
15289 (gnus-server-opened gnus-select-method))
15290 (gnus-check-bogus-newsgroups))))
15292 (defun gnus-find-new-newsgroups (&optional arg)
15293 "Search for new newsgroups and add them.
15294 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15295 The `-n' option line from .newsrc is respected.
15296 If ARG (the prefix), use the `ask-server' method to query
15297 the server for new groups."
15299 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15300 (null gnus-read-active-file)
15301 (eq gnus-read-active-file 'some))
15302 'ask-server gnus-check-new-newsgroups)))
15303 (unless (gnus-check-first-time-used)
15304 (if (or (consp check)
15305 (eq check 'ask-server))
15306 ;; Ask the server for new groups.
15307 (gnus-ask-server-for-new-groups)
15308 ;; Go through the active hashtb and look for new groups.
15310 group new-newsgroups)
15311 (gnus-message 5 "Looking for new newsgroups...")
15312 (unless gnus-have-read-active-file
15313 (gnus-read-active-file))
15314 (setq gnus-newsrc-last-checked-date (current-time-string))
15315 (unless gnus-killed-hashtb
15316 (gnus-make-hashtable-from-killed))
15317 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15318 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15321 (if (or (null (setq group (symbol-name sym)))
15323 (null (symbol-value sym))
15324 (gnus-gethash group gnus-killed-hashtb)
15325 (gnus-gethash group gnus-newsrc-hashtb))
15327 (let ((do-sub (gnus-matches-options-n group)))
15329 ((eq do-sub 'subscribe)
15330 (setq groups (1+ groups))
15331 (gnus-sethash group group gnus-killed-hashtb)
15332 (funcall gnus-subscribe-options-newsgroup-method group))
15333 ((eq do-sub 'ignore)
15336 (setq groups (1+ groups))
15337 (gnus-sethash group group gnus-killed-hashtb)
15338 (if gnus-subscribe-hierarchical-interactive
15339 (setq new-newsgroups (cons group new-newsgroups))
15340 (funcall gnus-subscribe-newsgroup-method group)))))))
15341 gnus-active-hashtb)
15342 (when new-newsgroups
15343 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15344 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15346 (gnus-message 6 "%d new newsgroup%s arrived."
15347 groups (if (> groups 1) "s have" " has"))
15348 (gnus-message 6 "No new newsgroups.")))))))
15350 (defun gnus-matches-options-n (group)
15351 ;; Returns `subscribe' if the group is to be unconditionally
15352 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15353 ;; no match for the group.
15355 ;; First we check the two user variables.
15357 ((and gnus-options-subscribe
15358 (string-match gnus-options-subscribe group))
15360 ((and gnus-auto-subscribed-groups
15361 (string-match gnus-auto-subscribed-groups group))
15363 ((and gnus-options-not-subscribe
15364 (string-match gnus-options-not-subscribe group))
15366 ;; Then we go through the list that was retrieved from the .newsrc
15367 ;; file. This list has elements on the form
15368 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15369 ;; is in the reverse order of the options line) is returned.
15371 (let ((regs gnus-newsrc-options-n))
15373 (not (string-match (caar regs) group)))
15374 (setq regs (cdr regs)))
15375 (and regs (cdar regs))))))
15377 (defun gnus-ask-server-for-new-groups ()
15378 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15379 (methods (cons gnus-select-method
15381 (when gnus-message-archive-method
15384 (and (consp gnus-check-new-newsgroups)
15385 gnus-check-new-newsgroups)
15386 gnus-secondary-select-methods))))
15388 (new-date (current-time-string))
15389 group new-newsgroups got-new method hashtb
15390 gnus-override-subscribe-method)
15391 ;; Go through both primary and secondary select methods and
15392 ;; request new newsgroups.
15393 (while (setq method (gnus-server-get-method nil (pop methods)))
15394 (setq new-newsgroups nil)
15395 (setq gnus-override-subscribe-method method)
15396 (when (and (gnus-check-server method)
15397 (gnus-request-newgroups date method))
15400 (setq hashtb (gnus-make-hashtable 100))
15401 (set-buffer nntp-server-buffer)
15402 ;; Enter all the new groups into a hashtable.
15403 (gnus-active-to-gnus-format method hashtb 'ignore))
15404 ;; Now all new groups from `method' are in `hashtb'.
15406 (lambda (group-sym)
15407 (if (or (null (setq group (symbol-name group-sym)))
15408 (not (boundp group-sym))
15409 (null (symbol-value group-sym))
15410 (gnus-gethash group gnus-newsrc-hashtb)
15411 (member group gnus-zombie-list)
15412 (member group gnus-killed-list))
15413 ;; The group is already known.
15415 ;; Make this group active.
15416 (when (symbol-value group-sym)
15417 (gnus-set-active group (symbol-value group-sym)))
15418 ;; Check whether we want it or not.
15419 (let ((do-sub (gnus-matches-options-n group)))
15421 ((eq do-sub 'subscribe)
15423 (gnus-sethash group group gnus-killed-hashtb)
15424 (funcall gnus-subscribe-options-newsgroup-method group))
15425 ((eq do-sub 'ignore)
15429 (gnus-sethash group group gnus-killed-hashtb)
15430 (if gnus-subscribe-hierarchical-interactive
15431 (push group new-newsgroups)
15432 (funcall gnus-subscribe-newsgroup-method group)))))))
15434 (when new-newsgroups
15435 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15436 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15438 (gnus-message 6 "%d new newsgroup%s arrived."
15439 groups (if (> groups 1) "s have" " has")))
15440 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15443 (defun gnus-check-first-time-used ()
15444 (if (or (> (length gnus-newsrc-alist) 1)
15445 (file-exists-p gnus-startup-file)
15446 (file-exists-p (concat gnus-startup-file ".el"))
15447 (file-exists-p (concat gnus-startup-file ".eld")))
15449 (gnus-message 6 "First time user; subscribing you to default groups")
15450 (unless (gnus-read-active-file-p)
15451 (gnus-read-active-file))
15452 (setq gnus-newsrc-last-checked-date (current-time-string))
15453 (let ((groups gnus-default-subscribed-newsgroups)
15457 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15460 (if (null (setq group (symbol-name sym)))
15462 (let ((do-sub (gnus-matches-options-n group)))
15464 ((eq do-sub 'subscribe)
15465 (gnus-sethash group group gnus-killed-hashtb)
15466 (funcall gnus-subscribe-options-newsgroup-method group))
15467 ((eq do-sub 'ignore)
15470 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15471 gnus-active-hashtb)
15473 (if (gnus-active (car groups))
15474 (gnus-group-change-level
15475 (car groups) gnus-level-default-subscribed gnus-level-killed))
15476 (setq groups (cdr groups)))
15477 (gnus-group-make-help-group)
15478 (and gnus-novice-user
15479 (gnus-message 7 "`A k' to list killed groups"))))))
15481 (defun gnus-subscribe-group (group previous &optional method)
15482 (gnus-group-change-level
15484 (list t group gnus-level-default-subscribed nil nil method)
15486 gnus-level-default-subscribed gnus-level-killed previous t))
15488 ;; `gnus-group-change-level' is the fundamental function for changing
15489 ;; subscription levels of newsgroups. This might mean just changing
15490 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15491 ;; again, which subscribes/unsubscribes a group, which is equally
15492 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15493 ;; from 8-9 to 1-7 means that you remove the group from the list of
15494 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15495 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15496 ;; which is trivial.
15497 ;; ENTRY can either be a string (newsgroup name) or a list (if
15498 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15499 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15501 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15502 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15504 (defun gnus-group-change-level (entry level &optional oldlevel
15505 previous fromkilled)
15506 (let (group info active num)
15507 ;; Glean what info we can from the arguments
15509 (if fromkilled (setq group (nth 1 entry))
15510 (setq group (car (nth 2 entry))))
15511 (setq group entry))
15512 (if (and (stringp entry)
15514 (< oldlevel gnus-level-zombie))
15515 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15516 (if (and (not oldlevel)
15518 (setq oldlevel (gnus-info-level (nth 2 entry)))
15519 (setq oldlevel (or oldlevel 9)))
15520 (if (stringp previous)
15521 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15523 (if (and (>= oldlevel gnus-level-zombie)
15524 (gnus-gethash group gnus-newsrc-hashtb))
15525 ;; We are trying to subscribe a group that is already
15529 (or (gnus-ephemeral-group-p group)
15530 (gnus-dribble-enter
15531 (format "(gnus-group-change-level %S %S %S %S %S)"
15532 group level oldlevel (car (nth 2 previous)) fromkilled)))
15534 ;; Then we remove the newgroup from any old structures, if needed.
15535 ;; If the group was killed, we remove it from the killed or zombie
15536 ;; list. If not, and it is in fact going to be killed, we remove
15537 ;; it from the newsrc hash table and assoc.
15539 ((>= oldlevel gnus-level-zombie)
15540 (if (= oldlevel gnus-level-zombie)
15541 (setq gnus-zombie-list (delete group gnus-zombie-list))
15542 (setq gnus-killed-list (delete group gnus-killed-list))))
15544 (if (and (>= level gnus-level-zombie)
15547 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15549 (setcdr (gnus-gethash (car (nth 3 entry))
15550 gnus-newsrc-hashtb)
15552 (setcdr (cdr entry) (cdddr entry))))))
15554 ;; Finally we enter (if needed) the list where it is supposed to
15555 ;; go, and change the subscription level. If it is to be killed,
15556 ;; we enter it into the killed or zombie list.
15558 ((>= level gnus-level-zombie)
15559 ;; Remove from the hash table.
15560 (gnus-sethash group nil gnus-newsrc-hashtb)
15561 ;; We do not enter foreign groups into the list of dead
15563 (unless (gnus-group-foreign-p group)
15564 (if (= level gnus-level-zombie)
15565 (setq gnus-zombie-list (cons group gnus-zombie-list))
15566 (setq gnus-killed-list (cons group gnus-killed-list)))))
15568 ;; If the list is to be entered into the newsrc assoc, and
15569 ;; it was killed, we have to create an entry in the newsrc
15570 ;; hashtb format and fix the pointers in the newsrc assoc.
15571 (if (< oldlevel gnus-level-zombie)
15572 ;; It was alive, and it is going to stay alive, so we
15573 ;; just change the level and don't change any pointers or
15574 ;; hash table entries.
15575 (setcar (cdaddr entry) level)
15577 (setq info (cdr entry)
15579 (setq active (gnus-active group))
15581 (if active (- (1+ (cdr active)) (car active)) t))
15582 ;; Check whether the group is foreign. If so, the
15583 ;; foreign select method has to be entered into the
15585 (let ((method (or gnus-override-subscribe-method
15586 (gnus-group-method group))))
15587 (if (eq method gnus-select-method)
15588 (setq info (list group level nil))
15589 (setq info (list group level nil nil method)))))
15592 (let ((p gnus-newsrc-alist))
15596 (setq entry (cons info (cddr previous)))
15599 (setcdr (cdr previous) entry)
15600 (gnus-sethash group (cons num (cdr previous))
15601 gnus-newsrc-hashtb))
15602 (setcdr previous entry)
15603 (gnus-sethash group (cons num previous)
15604 gnus-newsrc-hashtb))
15606 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15607 (when gnus-group-change-level-function
15608 (funcall gnus-group-change-level-function group level oldlevel)))))
15610 (defun gnus-kill-newsgroup (newsgroup)
15611 "Obsolete function. Kills a newsgroup."
15612 (gnus-group-change-level
15613 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15615 (defun gnus-check-bogus-newsgroups (&optional confirm)
15616 "Remove bogus newsgroups.
15617 If CONFIRM is non-nil, the user has to confirm the deletion of every
15619 (let ((newsrc (cdr gnus-newsrc-alist))
15620 bogus group entry info)
15621 (gnus-message 5 "Checking bogus newsgroups...")
15622 (unless (gnus-read-active-file-p)
15623 (gnus-read-active-file))
15624 (when (gnus-read-active-file-p)
15625 ;; Find all bogus newsgroup that are subscribed.
15627 (setq info (pop newsrc)
15628 group (gnus-info-group info))
15629 (unless (or (gnus-active group) ; Active
15630 (gnus-info-method info) ; Foreign
15632 (not (gnus-y-or-n-p
15633 (format "Remove bogus newsgroup: %s " group)))))
15634 ;; Found a bogus newsgroup.
15635 (push group bogus)))
15636 ;; Remove all bogus subscribed groups by first killing them, and
15637 ;; then removing them from the list of killed groups.
15639 (when (setq entry (gnus-gethash (setq group (pop bogus))
15640 gnus-newsrc-hashtb))
15641 (gnus-group-change-level entry gnus-level-killed)
15642 (setq gnus-killed-list (delete group gnus-killed-list))))
15643 ;; Then we remove all bogus groups from the list of killed and
15644 ;; zombie groups. They are are removed without confirmation.
15645 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15648 (setq killed (symbol-value (car dead-lists)))
15650 (unless (gnus-active (setq group (pop killed)))
15651 ;; The group is bogus.
15652 ;; !!!Slow as hell.
15653 (set (car dead-lists)
15654 (delete group (symbol-value (car dead-lists))))))
15655 (setq dead-lists (cdr dead-lists))))
15656 (gnus-message 5 "Checking bogus newsgroups...done"))))
15658 (defun gnus-check-duplicate-killed-groups ()
15659 "Remove duplicates from the list of killed groups."
15661 (let ((killed gnus-killed-list))
15663 (gnus-message 9 "%d" (length killed))
15664 (setcdr killed (delete (car killed) (cdr killed)))
15665 (setq killed (cdr killed)))))
15667 ;; We want to inline a function from gnus-cache, so we cheat here:
15670 (require 'gnus-cache))
15672 (defun gnus-get-unread-articles-in-group (info active &optional update)
15674 ;; Allow the backend to update the info in the group.
15676 (gnus-request-update-info
15677 info (gnus-find-method-for-group (gnus-info-group info))))
15678 (gnus-activate-group (gnus-info-group info) nil t))
15679 (let* ((range (gnus-info-read info))
15681 ;; If a cache is present, we may have to alter the active info.
15682 (when (and gnus-use-cache info)
15683 (inline (gnus-cache-possibly-alter-active
15684 (gnus-info-group info) active)))
15685 ;; Modify the list of read articles according to what articles
15686 ;; are available; then tally the unread articles and add the
15687 ;; number to the group hash table entry.
15689 ((zerop (cdr active))
15692 (setq num (- (1+ (cdr active)) (car active))))
15693 ((not (listp (cdr range)))
15694 ;; Fix a single (num . num) range according to the
15695 ;; active hash table.
15696 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15697 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15698 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15699 ;; Compute number of unread articles.
15700 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15702 ;; The read list is a list of ranges. Fix them according to
15703 ;; the active hash table.
15704 ;; First peel off any elements that are below the lower
15706 (while (and (cdr range)
15708 (or (and (atom (cadr range)) (cadr range))
15710 (if (numberp (car range))
15713 (or (and (numberp (cadr range))
15716 (setcdr (car range)
15717 (or (and (numberp (nth 1 range)) (nth 1 range))
15719 (setcdr range (cddr range)))
15720 ;; Adjust the first element to be the same as the lower limit.
15721 (if (and (not (atom (car range)))
15722 (< (cdar range) (car active)))
15723 (setcdr (car range) (1- (car active))))
15724 ;; Then we want to peel off any elements that are higher
15725 ;; than the upper active limit.
15726 (let ((srange range))
15727 ;; Go past all legal elements.
15728 (while (and (cdr srange)
15729 (<= (or (and (atom (cadr srange))
15731 (caadr srange)) (cdr active)))
15732 (setq srange (cdr srange)))
15734 ;; Nuke all remaining illegal elements.
15735 (setcdr srange nil))
15737 ;; Adjust the final element.
15738 (if (and (not (atom (car srange)))
15739 (> (cdar srange) (cdr active)))
15740 (setcdr (car srange) (cdr active))))
15741 ;; Compute the number of unread articles.
15743 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15745 (or (and (atom (car range)) (car range))
15747 (setq range (cdr range)))
15748 (setq num (max 0 (- (cdr active) num)))))
15749 ;; Set the number of unread articles.
15751 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15754 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15755 ;; and compute how many unread articles there are in each group.
15756 (defun gnus-get-unread-articles (&optional level)
15757 (let* ((newsrc (cdr gnus-newsrc-alist))
15758 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15761 (cond ((and gnus-activate-foreign-newsgroups
15762 (not (numberp gnus-activate-foreign-newsgroups)))
15763 (1+ gnus-level-subscribed))
15764 ((numberp gnus-activate-foreign-newsgroups)
15765 gnus-activate-foreign-newsgroups)
15768 info group active method)
15769 (gnus-message 5 "Checking new news...")
15772 (setq active (gnus-active (setq group (gnus-info-group
15773 (setq info (pop newsrc))))))
15775 ;; Check newsgroups. If the user doesn't want to check them, or
15776 ;; they can't be checked (for instance, if the news server can't
15777 ;; be reached) we just set the number of unread articles in this
15778 ;; newsgroup to t. This means that Gnus thinks that there are
15779 ;; unread articles, but it has no idea how many.
15780 (if (and (setq method (gnus-info-method info))
15781 (not (gnus-server-equal
15783 (setq method (gnus-server-get-method nil method))))
15784 (not (gnus-secondary-method-p method)))
15785 ;; These groups are foreign. Check the level.
15786 (when (<= (gnus-info-level info) foreign-level)
15787 (setq active (gnus-activate-group group 'scan))
15788 (unless (inline (gnus-virtual-group-p group))
15789 (inline (gnus-close-group group)))
15790 (when (fboundp (intern (concat (symbol-name (car method))
15791 "-request-update-info")))
15792 (inline (gnus-request-update-info info method))))
15793 ;; These groups are native or secondary.
15794 (when (and (<= (gnus-info-level info) level)
15795 (not gnus-read-active-file))
15796 (setq active (gnus-activate-group group 'scan))
15797 (inline (gnus-close-group group))))
15799 ;; Get the number of unread articles in the group.
15801 (inline (gnus-get-unread-articles-in-group info active))
15802 ;; The group couldn't be reached, so we nix out the number of
15803 ;; unread articles and stuff.
15804 (gnus-set-active group nil)
15805 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15807 (gnus-message 5 "Checking new news...done")))
15809 ;; Create a hash table out of the newsrc alist. The `car's of the
15810 ;; alist elements are used as keys.
15811 (defun gnus-make-hashtable-from-newsrc-alist ()
15812 (let ((alist gnus-newsrc-alist)
15813 (ohashtb gnus-newsrc-hashtb)
15815 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15817 (setq prev (setq gnus-newsrc-alist
15818 (if (equal (caar gnus-newsrc-alist)
15821 (cons (list "dummy.group" 0 nil) alist)))))
15825 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15827 gnus-newsrc-hashtb)
15829 alist (cdr alist)))))
15831 (defun gnus-make-hashtable-from-killed ()
15832 "Create a hash table from the killed and zombie lists."
15833 (let ((lists '(gnus-killed-list gnus-zombie-list))
15835 (setq gnus-killed-hashtb
15836 (gnus-make-hashtable
15837 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15838 (while (setq list (pop lists))
15839 (setq list (symbol-value list))
15841 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15843 (defun gnus-activate-group (group &optional scan dont-check)
15844 ;; Check whether a group has been activated or not.
15845 ;; If SCAN, request a scan of that group as well.
15846 (let ((method (gnus-find-method-for-group group))
15848 (and (gnus-check-server method)
15849 ;; We escape all bugs and quit here to make it possible to
15850 ;; continue if a group is so out-there that it reports bugs
15854 (gnus-check-backend-function 'request-scan (car method))
15855 (gnus-request-scan group method))
15858 (gnus-request-group group dont-check)
15862 (set-buffer nntp-server-buffer)
15863 (goto-char (point-min))
15864 ;; Parse the result we got from `gnus-request-group'.
15865 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15867 (goto-char (match-beginning 1))
15869 group (setq active (cons (read (current-buffer))
15870 (read (current-buffer)))))
15871 ;; Return the new active info.
15874 (defun gnus-update-read-articles (group unread)
15875 "Update the list of read and ticked articles in GROUP using the
15876 UNREAD and TICKED lists.
15877 Note: UNSELECTED has to be sorted over `<'.
15878 Returns whether the updating was successful."
15879 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15880 (entry (gnus-gethash group gnus-newsrc-hashtb))
15881 (info (nth 2 entry))
15883 (unread (sort (copy-sequence unread) '<))
15885 (if (or (not info) (not active))
15886 ;; There is no info on this group if it was, in fact,
15887 ;; killed. Gnus stores no information on killed groups, so
15888 ;; there's nothing to be done.
15889 ;; One could store the information somewhere temporarily,
15890 ;; perhaps... Hmmm...
15892 ;; Remove any negative articles numbers.
15893 (while (and unread (< (car unread) 0))
15894 (setq unread (cdr unread)))
15895 ;; Remove any expired article numbers
15896 (while (and unread (< (car unread) (car active)))
15897 (setq unread (cdr unread)))
15898 ;; Compute the ranges of read articles by looking at the list of
15899 ;; unread articles.
15901 (if (/= (car unread) prev)
15902 (setq read (cons (if (= prev (1- (car unread))) prev
15903 (cons prev (1- (car unread)))) read)))
15904 (setq prev (1+ (car unread)))
15905 (setq unread (cdr unread)))
15906 (when (<= prev (cdr active))
15907 (setq read (cons (cons prev (cdr active)) read)))
15908 ;; Enter this list into the group info.
15909 (gnus-info-set-read
15910 info (if (> (length read) 1) (nreverse read) read))
15911 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15912 (gnus-get-unread-articles-in-group info (gnus-active group))
15915 (defun gnus-make-articles-unread (group articles)
15916 "Mark ARTICLES in GROUP as unread."
15917 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15918 (gnus-gethash (gnus-group-real-name group)
15919 gnus-newsrc-hashtb))))
15920 (ranges (gnus-info-read info))
15923 (when (gnus-member-of-range
15924 (setq article (pop articles)) ranges)
15925 (setq news (cons article news))))
15927 (gnus-info-set-read
15928 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15929 (gnus-group-update-group group t))))
15931 ;; Enter all dead groups into the hashtb.
15932 (defun gnus-update-active-hashtb-from-killed ()
15933 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15934 (lists (list gnus-killed-list gnus-zombie-list))
15937 (setq killed (car lists))
15939 (gnus-sethash (car killed) nil hashtb)
15940 (setq killed (cdr killed)))
15941 (setq lists (cdr lists)))))
15943 (defun gnus-get-killed-groups ()
15944 "Go through the active hashtb and all all unknown groups as killed."
15945 ;; First make sure active file has been read.
15946 (unless (gnus-read-active-file-p)
15947 (let ((gnus-read-active-file t))
15948 (gnus-read-active-file)))
15949 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
15950 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
15954 (group (symbol-name sym)))
15955 (if (or (null group)
15956 (gnus-gethash group gnus-killed-hashtb)
15957 (gnus-gethash group gnus-newsrc-hashtb))
15959 (let ((do-sub (gnus-matches-options-n group)))
15960 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
15962 (setq groups (1+ groups))
15963 (setq gnus-killed-list
15964 (cons group gnus-killed-list))
15965 (gnus-sethash group group gnus-killed-hashtb))))))
15966 gnus-active-hashtb))
15968 ;; Get the active file(s) from the backend(s).
15969 (defun gnus-read-active-file ()
15970 (gnus-group-set-mode-line)
15973 (if (gnus-check-server gnus-select-method)
15974 ;; The native server is available.
15975 (cons gnus-select-method gnus-secondary-select-methods)
15976 ;; The native server is down, so we just do the
15978 gnus-secondary-select-methods)
15979 ;; Also read from the archive server.
15980 (when gnus-message-archive-method
15981 (list "archive"))))
15983 (setq gnus-have-read-active-file nil)
15985 (set-buffer nntp-server-buffer)
15987 (let* ((method (if (stringp (car methods))
15988 (gnus-server-get-method nil (car methods))
15990 (where (nth 1 method))
15991 (mesg (format "Reading active file%s via %s..."
15992 (if (and where (not (zerop (length where))))
15993 (concat " from " where) "")
15995 (gnus-message 5 mesg)
15996 (when (gnus-check-server method)
15997 ;; Request that the backend scan its incoming messages.
15998 (and (gnus-check-backend-function 'request-scan (car method))
15999 (gnus-request-scan nil method))
16001 ((and (eq gnus-read-active-file 'some)
16002 (gnus-check-backend-function 'retrieve-groups (car method)))
16003 (let ((newsrc (cdr gnus-newsrc-alist))
16004 (gmethod (gnus-server-get-method nil method))
16006 (while (setq info (pop newsrc))
16007 (when (gnus-server-equal
16008 (gnus-find-method-for-group
16009 (gnus-info-group info) info)
16011 (push (gnus-group-real-name (gnus-info-group info))
16014 (gnus-check-server method)
16015 (setq list-type (gnus-retrieve-groups groups method))
16019 1.2 "Cannot read partial active file from %s server."
16021 ((eq list-type 'active)
16022 (gnus-active-to-gnus-format method gnus-active-hashtb))
16024 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16026 (if (not (gnus-request-list method))
16027 (unless (equal method gnus-message-archive-method)
16028 (gnus-error 1 "Cannot read active file from %s server."
16030 (gnus-active-to-gnus-format method gnus-active-hashtb)
16031 ;; We mark this active file as read.
16032 (push method gnus-have-read-active-file)
16033 (gnus-message 5 "%sdone" mesg))))))
16034 (setq methods (cdr methods))))))
16036 ;; Read an active file and place the results in `gnus-active-hashtb'.
16037 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16039 (setq method gnus-select-method))
16040 (let ((cur (current-buffer))
16042 (if (and gnus-active-hashtb
16043 (not (equal method gnus-select-method)))
16045 (setq gnus-active-hashtb
16046 (if (equal method gnus-select-method)
16047 (gnus-make-hashtable
16048 (count-lines (point-min) (point-max)))
16049 (gnus-make-hashtable 4096)))))))
16050 ;; Delete unnecessary lines.
16051 (goto-char (point-min))
16052 (while (search-forward "\nto." nil t)
16053 (delete-region (1+ (match-beginning 0))
16054 (progn (forward-line 1) (point))))
16055 (or (string= gnus-ignored-newsgroups "")
16057 (goto-char (point-min))
16058 (delete-matching-lines gnus-ignored-newsgroups)))
16059 ;; Make the group names readable as a lisp expression even if they
16060 ;; contain special characters.
16061 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16062 (goto-char (point-max))
16063 (while (re-search-backward "[][';?()#]" nil t)
16065 ;; If these are groups from a foreign select method, we insert the
16066 ;; group prefix in front of the group names.
16067 (and method (not (gnus-server-equal
16068 (gnus-server-get-method nil method)
16069 (gnus-server-get-method nil gnus-select-method)))
16070 (let ((prefix (gnus-group-prefixed-name "" method)))
16071 (goto-char (point-min))
16072 (while (and (not (eobp))
16073 (progn (insert prefix)
16074 (zerop (forward-line 1)))))))
16075 ;; Store the active file in a hash table.
16076 (goto-char (point-min))
16077 (if (string-match "%[oO]" gnus-group-line-format)
16078 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16079 ;; If we want information on moderated groups, we use this
16081 (let* ((mod-hashtb (make-vector 7 0))
16082 (m (intern "m" mod-hashtb))
16084 (while (not (eobp))
16085 (condition-case nil
16087 (narrow-to-region (point) (gnus-point-at-eol))
16088 (setq group (let ((obarray hashtb)) (read cur)))
16089 (if (and (numberp (setq max (read cur)))
16090 (numberp (setq min (read cur)))
16092 (skip-chars-forward " \t")
16094 (or (= (following-char) ?=)
16095 (= (following-char) ?x)
16096 (= (following-char) ?j)))))
16097 (set group (cons min max))
16099 ;; Enter moderated groups into a list.
16100 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16101 (setq gnus-moderated-list
16102 (cons (symbol-name group) gnus-moderated-list))))
16109 ;; And if we do not care about moderation, we use this loop,
16110 ;; which is faster.
16111 (let (group max min)
16112 (while (not (eobp))
16115 (narrow-to-region (point) (gnus-point-at-eol))
16116 ;; group gets set to a symbol interned in the hash table
16117 ;; (what a hack!!) - jwz
16118 (setq group (let ((obarray hashtb)) (read cur)))
16119 (if (and (numberp (setq max (read cur)))
16120 (numberp (setq min (read cur)))
16122 (skip-chars-forward " \t")
16124 (or (= (following-char) ?=)
16125 (= (following-char) ?x)
16126 (= (following-char) ?j)))))
16127 (set group (cons min max))
16135 (gnus-message 3 "Warning - illegal active: %s"
16137 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16139 (forward-line 1))))))
16141 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16142 ;; Parse a "groups" active file.
16143 (let ((cur (current-buffer))
16145 (if (and method gnus-active-hashtb)
16147 (setq gnus-active-hashtb
16148 (gnus-make-hashtable
16149 (count-lines (point-min) (point-max)))))))
16150 (prefix (and method
16151 (not (gnus-server-equal
16152 (gnus-server-get-method nil method)
16153 (gnus-server-get-method nil gnus-select-method)))
16154 (gnus-group-prefixed-name "" method))))
16156 (goto-char (point-min))
16157 ;; We split this into to separate loops, one with the prefix
16158 ;; and one without to speed the reading up somewhat.
16160 (let (min max opoint group)
16161 (while (not (eobp))
16164 (read cur) (read cur)
16165 (setq min (read cur)
16168 (skip-chars-forward " \t")
16171 (set (let ((obarray hashtb)) (read cur))
16173 (error (and group (symbolp group) (set group nil))))
16175 (let (min max group)
16176 (while (not (eobp))
16178 (if (= (following-char) ?2)
16180 (read cur) (read cur)
16181 (setq min (read cur)
16183 (set (setq group (let ((obarray hashtb)) (read cur)))
16185 (error (and group (symbolp group) (set group nil))))
16186 (forward-line 1))))))
16188 (defun gnus-read-newsrc-file (&optional force)
16189 "Read startup file.
16190 If FORCE is non-nil, the .newsrc file is read."
16191 ;; Reset variables that might be defined in the .newsrc.eld file.
16192 (let ((variables gnus-variable-list))
16194 (set (car variables) nil)
16195 (setq variables (cdr variables))))
16196 (let* ((newsrc-file gnus-current-startup-file)
16197 (quick-file (concat newsrc-file ".el")))
16199 ;; We always load the .newsrc.eld file. If always contains
16200 ;; much information that can not be gotten from the .newsrc
16201 ;; file (ticked articles, killed groups, foreign methods, etc.)
16202 (gnus-read-newsrc-el-file quick-file)
16204 (if (and (file-exists-p gnus-current-startup-file)
16206 (and (file-newer-than-file-p newsrc-file quick-file)
16207 (file-newer-than-file-p newsrc-file
16208 (concat quick-file "d")))
16209 (not gnus-newsrc-alist)))
16210 ;; We read the .newsrc file. Note that if there if a
16211 ;; .newsrc.eld file exists, it has already been read, and
16212 ;; the `gnus-newsrc-hashtb' has been created. While reading
16213 ;; the .newsrc file, Gnus will only use the information it
16214 ;; can find there for changing the data already read -
16215 ;; ie. reading the .newsrc file will not trash the data
16216 ;; already read (except for read articles).
16218 (gnus-message 5 "Reading %s..." newsrc-file)
16219 (set-buffer (find-file-noselect newsrc-file))
16220 (buffer-disable-undo (current-buffer))
16221 (gnus-newsrc-to-gnus-format)
16222 (kill-buffer (current-buffer))
16223 (gnus-message 5 "Reading %s...done" newsrc-file)))
16225 ;; Read any slave files.
16227 (gnus-master-read-slave-newsrc))
16229 ;; Convert old to new.
16230 (gnus-convert-old-newsrc))))
16232 (defun gnus-continuum-version (version)
16233 "Return VERSION as a floating point number."
16234 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16235 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16236 (number (match-string 2 version))
16238 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16239 (setq major (string-to-number (match-string 1 number)))
16240 (setq minor (string-to-number (match-string 2 number)))
16241 (setq least (if (match-beginning 3)
16242 (string-to-number (match-string 3 number))
16246 (format "%s00%02d%02d"
16248 ((string= alpha "(ding)") "4.99")
16249 ((string= alpha "September") "5.01")
16250 ((string= alpha "Red") "5.03"))
16252 (format "%d.%02d%20d" major minor least))))))
16254 (defun gnus-convert-old-newsrc ()
16255 "Convert old newsrc into the new format, if needed."
16256 (let ((fcv (and gnus-newsrc-file-version
16257 (gnus-continuum-version gnus-newsrc-file-version))))
16259 ;; No .newsrc.eld file was loaded.
16261 ;; Gnus 5 .newsrc.eld was loaded.
16262 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16263 (gnus-convert-old-ticks)))))
16265 (defun gnus-convert-old-ticks ()
16266 (let ((newsrc (cdr gnus-newsrc-alist))
16267 marks info dormant ticked)
16268 (while (setq info (pop newsrc))
16269 (when (setq marks (gnus-info-marks info))
16270 (setq dormant (cdr (assq 'dormant marks))
16271 ticked (cdr (assq 'tick marks)))
16272 (when (or dormant ticked)
16273 (gnus-info-set-read
16276 (gnus-info-read info)
16277 (nconc (gnus-uncompress-range dormant)
16278 (gnus-uncompress-range ticked)))))))))
16280 (defun gnus-read-newsrc-el-file (file)
16281 (let ((ding-file (concat file "d")))
16282 ;; We always, always read the .eld file.
16283 (gnus-message 5 "Reading %s..." ding-file)
16284 (let (gnus-newsrc-assoc)
16285 (condition-case nil
16286 (load ding-file t t t)
16288 (gnus-error 1 "Error in %s" ding-file)))
16289 (when gnus-newsrc-assoc
16290 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16291 (gnus-make-hashtable-from-newsrc-alist)
16292 (when (file-newer-than-file-p file ding-file)
16293 ;; Old format quick file
16294 (gnus-message 5 "Reading %s..." file)
16295 ;; The .el file is newer than the .eld file, so we read that one
16297 (gnus-read-old-newsrc-el-file file))))
16299 ;; Parse the old-style quick startup file
16300 (defun gnus-read-old-newsrc-el-file (file)
16301 (let (newsrc killed marked group m info)
16303 (let ((gnus-killed-assoc nil)
16304 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16306 (condition-case nil
16309 (setq newsrc gnus-newsrc-assoc
16310 killed gnus-killed-assoc
16311 marked gnus-marked-assoc)))
16312 (setq gnus-newsrc-alist nil)
16313 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16316 (gnus-info-set-read info (cddr group))
16317 (gnus-info-set-level
16318 info (if (nth 1 group) gnus-level-default-subscribed
16319 gnus-level-default-unsubscribed))
16320 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16323 (if (nth 1 group) gnus-level-default-subscribed
16324 gnus-level-default-unsubscribed)
16326 gnus-newsrc-alist))
16327 ;; Copy marks into info.
16328 (when (setq m (assoc (car group) marked))
16329 (unless (nthcdr 3 info)
16330 (nconc info (list nil)))
16331 (gnus-info-set-marks
16332 info (list (cons 'tick (gnus-compress-sequence
16333 (sort (cdr m) '<) t))))))
16334 (setq newsrc killed)
16336 (setcar newsrc (caar newsrc))
16337 (setq newsrc (cdr newsrc)))
16338 (setq gnus-killed-list killed))
16339 ;; The .el file version of this variable does not begin with
16340 ;; "options", while the .eld version does, so we just add it if it
16343 gnus-newsrc-options
16345 (and (not (string-match "^ *options" gnus-newsrc-options))
16346 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16347 (and (not (string-match "\n$" gnus-newsrc-options))
16348 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16349 ;; Finally, if we read some options lines, we parse them.
16350 (or (string= gnus-newsrc-options "")
16351 (gnus-newsrc-parse-options gnus-newsrc-options))))
16353 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16354 (gnus-make-hashtable-from-newsrc-alist)))
16356 (defun gnus-make-newsrc-file (file)
16357 "Make server dependent file name by catenating FILE and server host name."
16358 (let* ((file (expand-file-name file nil))
16359 (real-file (concat file "-" (nth 1 gnus-select-method))))
16360 (if (or (file-exists-p real-file)
16361 (file-exists-p (concat real-file ".el"))
16362 (file-exists-p (concat real-file ".eld")))
16365 (defun gnus-newsrc-to-gnus-format ()
16366 (setq gnus-newsrc-options "")
16367 (setq gnus-newsrc-options-n nil)
16369 (or gnus-active-hashtb
16370 (setq gnus-active-hashtb (make-vector 4095 0)))
16371 (let ((buf (current-buffer))
16372 (already-read (> (length gnus-newsrc-alist) 1))
16373 group subscribed options-symbol newsrc Options-symbol
16375 (goto-char (point-min))
16376 ;; We intern the symbol `options' in the active hashtb so that we
16377 ;; can `eq' against it later.
16378 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16379 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16381 (while (not (eobp))
16382 ;; We first read the first word on the line by narrowing and
16383 ;; then reading into `gnus-active-hashtb'. Most groups will
16384 ;; already exist in that hashtb, so this will save some string
16388 (progn (skip-chars-forward "^ \t!:\n") (point)))
16389 (goto-char (point-min))
16391 (and (/= (point-min) (point-max))
16392 (let ((obarray gnus-active-hashtb)) (read buf))))
16394 ;; Now, the symbol we have read is either `options' or a group
16395 ;; name. If it is an options line, we just add it to a string.
16397 ((or (eq symbol options-symbol)
16398 (eq symbol Options-symbol))
16399 (setq gnus-newsrc-options
16400 ;; This concating is quite inefficient, but since our
16401 ;; thorough studies show that approx 99.37% of all
16402 ;; .newsrc files only contain a single options line, we
16403 ;; don't give a damn, frankly, my dear.
16404 (concat gnus-newsrc-options
16406 (gnus-point-at-bol)
16407 ;; Options may continue on the next line.
16408 (or (and (re-search-forward "^[^ \t]" nil 'move)
16409 (progn (beginning-of-line) (point)))
16413 ;; Group names can be just numbers.
16414 (when (numberp symbol)
16415 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16416 (or (boundp symbol) (set symbol nil))
16417 ;; It was a group name.
16418 (setq subscribed (= (following-char) ?:)
16419 group (symbol-name symbol)
16422 ;; If the line ends here, this is clearly a buggy line, so
16423 ;; we put point a the beginning of line and let the cond
16424 ;; below do the error handling.
16425 (beginning-of-line)
16426 ;; We skip to the beginning of the ranges.
16427 (skip-chars-forward "!: \t"))
16428 ;; We are now at the beginning of the list of read articles.
16429 ;; We read them range by range.
16432 ((looking-at "[0-9]+")
16433 ;; We narrow and read a number instead of buffer-substring/
16434 ;; string-to-int because it's faster. narrow/widen is
16435 ;; faster than save-restriction/narrow, and save-restriction
16436 ;; produces a garbage object.
16438 (narrow-to-region (match-beginning 0) (match-end 0))
16441 ;; If the next character is a dash, then this is a range.
16442 (if (= (following-char) ?-)
16444 ;; We read the upper bound of the range.
16446 (if (not (looking-at "[0-9]+"))
16447 ;; This is a buggy line, by we pretend that
16448 ;; it's kinda OK. Perhaps the user should be
16450 (setq reads (cons num1 reads))
16455 (narrow-to-region (match-beginning 0)
16460 ;; It was just a simple number, so we add it to the
16462 (setq reads (cons num1 reads)))
16463 ;; If the next char in ?\n, then we have reached the end
16464 ;; of the line and return nil.
16465 (/= (following-char) ?\n))
16466 ((= (following-char) ?\n)
16467 ;; End of line, so we end.
16470 ;; Not numbers and not eol, so this might be a buggy
16473 ;; If it was eob instead of ?\n, we allow it.
16475 ;; The line was buggy.
16477 (gnus-error 3.1 "Mangled line: %s"
16478 (buffer-substring (gnus-point-at-bol)
16479 (gnus-point-at-eol)))))
16481 ;; Skip past ", ". Spaces are illegal in these ranges, but
16482 ;; we allow them, because it's a common mistake to put a
16483 ;; space after the comma.
16484 (skip-chars-forward ", "))
16486 ;; We have already read .newsrc.eld, so we gently update the
16487 ;; data in the hash table with the information we have just
16490 (let ((info (gnus-get-info group))
16493 ;; There is an entry for this file in the alist.
16495 (gnus-info-set-read info (nreverse reads))
16496 ;; We update the level very gently. In fact, we
16497 ;; only change it if there's been a status change
16498 ;; from subscribed to unsubscribed, or vice versa.
16499 (setq level (gnus-info-level info))
16500 (cond ((and (<= level gnus-level-subscribed)
16502 (setq level (if reads
16503 gnus-level-default-unsubscribed
16504 (1+ gnus-level-default-unsubscribed))))
16505 ((and (> level gnus-level-subscribed) subscribed)
16506 (setq level gnus-level-default-subscribed)))
16507 (gnus-info-set-level info level))
16508 ;; This is a new group.
16509 (setq info (list group
16511 gnus-level-default-subscribed
16513 (1+ gnus-level-subscribed)
16514 gnus-level-default-unsubscribed))
16515 (nreverse reads))))
16516 (setq newsrc (cons info newsrc))))))
16519 (setq newsrc (nreverse newsrc))
16521 (if (not already-read)
16523 ;; We now have two newsrc lists - `newsrc', which is what we
16524 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16525 ;; what we've read from .newsrc.eld. We have to merge these
16526 ;; lists. We do this by "attaching" any (foreign) groups in the
16527 ;; gnus-newsrc-alist to the (native) group that precedes them.
16528 (let ((rc (cdr gnus-newsrc-alist))
16529 (prev gnus-newsrc-alist)
16532 (or (null (nth 4 (car rc))) ; It's a native group.
16533 (assoc (caar rc) newsrc) ; It's already in the alist.
16534 (if (setq entry (assoc (caar prev) newsrc))
16535 (setcdr (setq mentry (memq entry newsrc))
16536 (cons (car rc) (cdr mentry)))
16537 (setq newsrc (cons (car rc) newsrc))))
16541 (setq gnus-newsrc-alist newsrc)
16542 ;; We make the newsrc hashtb.
16543 (gnus-make-hashtable-from-newsrc-alist)
16545 ;; Finally, if we read some options lines, we parse them.
16546 (or (string= gnus-newsrc-options "")
16547 (gnus-newsrc-parse-options gnus-newsrc-options))))
16549 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16550 ;; The return value will be a list on the form
16551 ;; ((regexp1 . ignore)
16552 ;; (regexp2 . subscribe)...)
16553 ;; When handling new newsgroups, groups that match a `ignore' regexp
16554 ;; will be ignored, and groups that match a `subscribe' regexp will be
16555 ;; subscribed. A line like
16556 ;; options -n !all rec.all
16557 ;; will lead to a list that looks like
16558 ;; (("^rec\\..+" . subscribe)
16559 ;; ("^.+" . ignore))
16560 ;; So all "rec.*" groups will be subscribed, while all the other
16561 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16562 ;; different from "options -n rec.all !all".
16563 (defun gnus-newsrc-parse-options (options)
16566 (gnus-set-work-buffer)
16567 (insert (regexp-quote options))
16568 ;; First we treat all continuation lines.
16569 (goto-char (point-min))
16570 (while (re-search-forward "\n[ \t]+" nil t)
16571 (replace-match " " t t))
16572 ;; Then we transform all "all"s into ".+"s.
16573 (goto-char (point-min))
16574 (while (re-search-forward "\\ball\\b" nil t)
16575 (replace-match ".+" t t))
16576 (goto-char (point-min))
16577 ;; We remove all other options than the "-n" ones.
16578 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16579 (replace-match " ")
16581 (goto-char (point-min))
16583 ;; We are only interested in "options -n" lines - we
16584 ;; ignore the other option lines.
16585 (while (re-search-forward "[ \t]-n" nil t)
16587 (or (save-excursion
16588 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16590 (gnus-point-at-eol)))
16591 ;; Search for all "words"...
16592 (while (re-search-forward "[^ \t,\n]+" eol t)
16593 (if (= (char-after (match-beginning 0)) ?!)
16594 ;; If the word begins with a bang (!), this is a "not"
16595 ;; spec. We put this spec (minus the bang) and the
16596 ;; symbol `ignore' into the list.
16597 (setq out (cons (cons (concat
16598 "^" (buffer-substring
16599 (1+ (match-beginning 0))
16602 ;; There was no bang, so this is a "yes" spec.
16603 (setq out (cons (cons (concat "^" (match-string 0))
16604 'subscribe) out)))))
16606 (setq gnus-newsrc-options-n out))))
16608 (defun gnus-save-newsrc-file (&optional force)
16609 "Save .newsrc file."
16610 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16611 ;; from the variable gnus-newsrc-alist.
16612 (when (and (or gnus-newsrc-alist gnus-killed-list)
16613 gnus-current-startup-file)
16615 (if (and (or gnus-use-dribble-file gnus-slave)
16617 (or (not gnus-dribble-buffer)
16618 (not (buffer-name gnus-dribble-buffer))
16619 (zerop (save-excursion
16620 (set-buffer gnus-dribble-buffer)
16622 (gnus-message 4 "(No changes need to be saved)")
16623 (run-hooks 'gnus-save-newsrc-hook)
16625 (gnus-slave-save-newsrc)
16627 (when gnus-save-newsrc-file
16628 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16629 (gnus-gnus-to-newsrc-format)
16630 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16631 ;; Save .newsrc.eld.
16632 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16633 (make-local-variable 'version-control)
16634 (setq version-control 'never)
16635 (setq buffer-file-name
16636 (concat gnus-current-startup-file ".eld"))
16637 (gnus-add-current-to-buffer-list)
16638 (buffer-disable-undo (current-buffer))
16640 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16641 (gnus-gnus-to-quick-newsrc-format)
16642 (run-hooks 'gnus-save-quick-newsrc-hook)
16644 (kill-buffer (current-buffer))
16646 5 "Saving %s.eld...done" gnus-current-startup-file))
16647 (gnus-dribble-delete-file)
16648 (gnus-group-set-mode-line)))))
16650 (defun gnus-gnus-to-quick-newsrc-format ()
16651 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16652 (insert ";; Gnus startup file.\n")
16653 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16654 (insert ";; to read .newsrc.\n")
16655 (insert "(setq gnus-newsrc-file-version "
16656 (prin1-to-string gnus-version) ")\n")
16658 (if gnus-save-killed-list gnus-variable-list
16659 ;; Remove the `gnus-killed-list' from the list of variables
16660 ;; to be saved, if required.
16661 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16662 ;; Peel off the "dummy" group.
16663 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16665 ;; Insert the variables into the file.
16667 (when (and (boundp (setq variable (pop variables)))
16668 (symbol-value variable))
16669 (insert "(setq " (symbol-name variable) " '")
16670 (prin1 (symbol-value variable) (current-buffer))
16673 (defun gnus-gnus-to-newsrc-format ()
16674 ;; Generate and save the .newsrc file.
16676 (set-buffer (create-file-buffer gnus-current-startup-file))
16677 (let ((newsrc (cdr gnus-newsrc-alist))
16678 (standard-output (current-buffer))
16679 info ranges range method)
16680 (setq buffer-file-name gnus-current-startup-file)
16681 (buffer-disable-undo (current-buffer))
16684 (if gnus-newsrc-options (insert gnus-newsrc-options))
16685 ;; Write subscribed and unsubscribed.
16686 (while (setq info (pop newsrc))
16687 ;; Don't write foreign groups to .newsrc.
16688 (when (or (null (setq method (gnus-info-method info)))
16689 (equal method "native")
16690 (gnus-server-equal method gnus-select-method))
16691 (insert (gnus-info-group info)
16692 (if (> (gnus-info-level info) gnus-level-subscribed)
16694 (when (setq ranges (gnus-info-read info))
16696 (if (not (listp (cdr ranges)))
16697 (if (= (car ranges) (cdr ranges))
16698 (princ (car ranges))
16699 (princ (car ranges))
16701 (princ (cdr ranges)))
16702 (while (setq range (pop ranges))
16703 (if (or (atom range) (= (car range) (cdr range)))
16704 (princ (or (and (atom range) range) (car range)))
16705 (princ (car range))
16707 (princ (cdr range)))
16708 (if ranges (insert ",")))))
16710 (make-local-variable 'version-control)
16711 (setq version-control 'never)
16712 ;; It has been reported that sometime the modtime on the .newsrc
16713 ;; file seems to be off. We really do want to overwrite it, so
16714 ;; we clear the modtime here before saving. It's a bit odd,
16716 ;; sometimes the modtime clear isn't sufficient. most brute force:
16717 ;; delete the silly thing entirely first. but this fails to provide
16718 ;; such niceties as .newsrc~ creation.
16719 (if gnus-modtime-botch
16720 (delete-file gnus-startup-file)
16721 (clear-visited-file-modtime))
16722 (run-hooks 'gnus-save-standard-newsrc-hook)
16724 (kill-buffer (current-buffer)))))
16728 ;;; Slave functions.
16731 (defun gnus-slave-save-newsrc ()
16733 (set-buffer gnus-dribble-buffer)
16735 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16736 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16738 (defun gnus-master-read-slave-newsrc ()
16741 (file-name-directory gnus-current-startup-file)
16745 (file-name-nondirectory gnus-current-startup-file)
16749 (if (not slave-files)
16750 () ; There are no slave files to read.
16751 (gnus-message 7 "Reading slave newsrcs...")
16753 (set-buffer (get-buffer-create " *gnus slave*"))
16754 (buffer-disable-undo (current-buffer))
16756 (sort (mapcar (lambda (file)
16757 (list (nth 5 (file-attributes file)) file))
16760 (or (< (caar f1) (caar f2))
16761 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16764 (setq file (nth 1 (car slave-files)))
16765 (insert-file-contents file)
16766 (if (condition-case ()
16768 (eval-buffer (current-buffer))
16771 (gnus-error 3.2 "Possible error in %s" file)
16773 (or gnus-slave ; Slaves shouldn't delete these files.
16777 (setq slave-files (cdr slave-files))))
16778 (gnus-message 7 "Reading slave newsrcs...done"))))
16782 ;;; Group description.
16785 (defun gnus-read-all-descriptions-files ()
16786 (let ((methods (cons gnus-select-method
16788 (when gnus-message-archive-method
16790 gnus-secondary-select-methods))))
16792 (gnus-read-descriptions-file (car methods))
16793 (setq methods (cdr methods)))
16796 (defun gnus-read-descriptions-file (&optional method)
16797 (let ((method (or method gnus-select-method)))
16798 (when (stringp method)
16799 (setq method (gnus-server-to-method method)))
16800 ;; We create the hashtable whether we manage to read the desc file
16801 ;; to avoid trying to re-read after a failed read.
16802 (or gnus-description-hashtb
16803 (setq gnus-description-hashtb
16804 (gnus-make-hashtable (length gnus-active-hashtb))))
16805 ;; Mark this method's desc file as read.
16806 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16807 gnus-description-hashtb)
16809 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16811 ((not (gnus-check-server method))
16812 (gnus-message 1 "Couldn't open server")
16814 ((not (gnus-request-list-newsgroups method))
16815 (gnus-message 1 "Couldn't read newsgroups descriptions")
16821 (set-buffer nntp-server-buffer)
16822 (goto-char (point-min))
16823 (if (or (search-forward "\n.\n" nil t)
16824 (goto-char (point-max)))
16826 (beginning-of-line)
16827 (narrow-to-region (point-min) (point))))
16828 (goto-char (point-min))
16829 (while (not (eobp))
16830 ;; If we get an error, we set group to 0, which is not a
16834 (let ((obarray gnus-description-hashtb))
16835 ;; Group is set to a symbol interned in this
16837 (read nntp-server-buffer))
16839 (skip-chars-forward " \t")
16840 ;; ... which leads to this line being effectively ignored.
16841 (and (symbolp group)
16842 (set group (buffer-substring
16843 (point) (progn (end-of-line) (point)))))
16844 (forward-line 1))))
16845 (gnus-message 5 "Reading descriptions file...done")
16848 (defun gnus-group-get-description (group)
16849 "Get the description of a group by sending XGTITLE to the server."
16850 (when (gnus-request-group-description group)
16852 (set-buffer nntp-server-buffer)
16853 (goto-char (point-min))
16854 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16855 (match-string 1)))))
16859 ;;; Buffering of read articles.
16862 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16863 (defvar gnus-backlog-articles nil)
16864 (defvar gnus-backlog-hashtb nil)
16866 (defun gnus-backlog-buffer ()
16867 "Return the backlog buffer."
16868 (or (get-buffer gnus-backlog-buffer)
16870 (set-buffer (get-buffer-create gnus-backlog-buffer))
16871 (buffer-disable-undo (current-buffer))
16872 (setq buffer-read-only t)
16873 (gnus-add-current-to-buffer-list)
16874 (get-buffer gnus-backlog-buffer))))
16876 (defun gnus-backlog-setup ()
16877 "Initialize backlog variables."
16878 (unless gnus-backlog-hashtb
16879 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16881 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16883 (defun gnus-backlog-shutdown ()
16884 "Clear all backlog variables and buffers."
16885 (when (get-buffer gnus-backlog-buffer)
16886 (kill-buffer gnus-backlog-buffer))
16887 (setq gnus-backlog-hashtb nil
16888 gnus-backlog-articles nil))
16890 (defun gnus-backlog-enter-article (group number buffer)
16891 (gnus-backlog-setup)
16892 (let ((ident (intern (concat group ":" (int-to-string number))
16893 gnus-backlog-hashtb))
16895 (if (memq ident gnus-backlog-articles)
16896 () ; It's already kept.
16897 ;; Remove the oldest article, if necessary.
16898 (and (numberp gnus-keep-backlog)
16899 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16900 (gnus-backlog-remove-oldest-article))
16901 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16902 ;; Insert the new article.
16904 (set-buffer (gnus-backlog-buffer))
16905 (let (buffer-read-only)
16906 (goto-char (point-max))
16907 (or (bolp) (insert "\n"))
16909 (insert-buffer-substring buffer)
16910 ;; Tag the beginning of the article with the ident.
16911 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
16913 (defun gnus-backlog-remove-oldest-article ()
16915 (set-buffer (gnus-backlog-buffer))
16916 (goto-char (point-min))
16917 (if (zerop (buffer-size))
16918 () ; The buffer is empty.
16919 (let ((ident (get-text-property (point) 'gnus-backlog))
16921 ;; Remove the ident from the list of articles.
16923 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16924 ;; Delete the article itself.
16926 (point) (next-single-property-change
16927 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16929 (defun gnus-backlog-remove-article (group number)
16930 "Remove article NUMBER in GROUP from the backlog."
16931 (when (numberp number)
16932 (gnus-backlog-setup)
16933 (let ((ident (intern (concat group ":" (int-to-string number))
16934 gnus-backlog-hashtb))
16936 (when (memq ident gnus-backlog-articles)
16937 ;; It was in the backlog.
16939 (set-buffer (gnus-backlog-buffer))
16940 (let (buffer-read-only)
16941 (when (setq beg (text-property-any
16942 (point-min) (point-max) 'gnus-backlog
16944 ;; Find the end (i. e., the beginning of the next article).
16946 (next-single-property-change
16947 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
16948 (delete-region beg end)
16952 (defun gnus-backlog-request-article (group number buffer)
16953 (when (numberp number)
16954 (gnus-backlog-setup)
16955 (let ((ident (intern (concat group ":" (int-to-string number))
16956 gnus-backlog-hashtb))
16958 (when (memq ident gnus-backlog-articles)
16959 ;; It was in the backlog.
16961 (set-buffer (gnus-backlog-buffer))
16962 (if (not (setq beg (text-property-any
16963 (point-min) (point-max) 'gnus-backlog
16965 ;; It wasn't in the backlog after all.
16967 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16968 ;; Find the end (i. e., the beginning of the next article).
16970 (next-single-property-change
16971 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16972 (let ((buffer-read-only nil))
16974 (insert-buffer-substring gnus-backlog-buffer beg end)
16977 ;; Allow redefinition of Gnus functions.
16979 (gnus-ems-redefine)
16983 ;;; gnus.el ends here