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
140 ,(nnheader-concat message-directory "archive/active"))
141 (nnfolder-get-new-mail nil)
142 (nnfolder-inhibit-expiry t))
143 "*Method used for archiving messages you've sent.
144 This should be a mail method.")
146 (defvar gnus-refer-article-method nil
147 "*Preferred method for fetching an article by Message-ID.
148 If you are reading news from the local spool (with nnspool), fetching
149 articles by Message-ID is painfully slow. By setting this method to an
150 nntp method, you might get acceptable results.
152 The value of this variable must be a valid select method as discussed
153 in the documentation of `gnus-select-method'.")
155 (defvar gnus-secondary-select-methods nil
156 "*A list of secondary methods that will be used for reading news.
157 This is a list where each element is a complete select method (see
158 `gnus-select-method').
160 If, for instance, you want to read your mail with the nnml backend,
161 you could set this variable:
163 (setq gnus-secondary-select-methods '((nnml \"\")))")
165 (defvar gnus-secondary-servers nil
166 "*List of NNTP servers that the user can choose between interactively.
167 To make Gnus query you for a server, you have to give `gnus' a
168 non-numeric prefix - `C-u M-x gnus', in short.")
170 (defvar gnus-nntp-server nil
171 "*The name of the host running the NNTP server.
172 This variable is semi-obsolete. Use the `gnus-select-method'
175 (defvar gnus-startup-file "~/.newsrc"
176 "*Your `.newsrc' file.
177 `.newsrc-SERVER' will be used instead if that exists.")
179 (defvar gnus-init-file "~/.gnus"
180 "*Your Gnus elisp startup file.
181 If a file with the .el or .elc suffixes exist, it will be read
184 (defvar gnus-group-faq-directory
185 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
186 "/ftp@sunsite.auc.dk:/pub/usenet/"
187 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
188 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
189 "/ftp@rtfm.mit.edu:/pub/usenet/"
190 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
191 "/ftp@ftp.sunet.se:/pub/usenet/"
192 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
193 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
194 "/ftp@ftp.hk.super.net:/mirror/faqs/")
195 "*Directory where the group FAQs are stored.
196 This will most commonly be on a remote machine, and the file will be
199 This variable can also be a list of directories. In that case, the
200 first element in the list will be used by default, and the others will
201 be used as backup sites.
203 Note that Gnus uses an aol machine as the default directory. If this
204 feels fundamentally unclean, just think of it as a way to finally get
205 something of value back from them.
207 If the default site is too slow, try one of these:
209 North America: mirrors.aol.com /pub/rtfm/usenet
210 ftp.seas.gwu.edu /pub/rtfm
211 rtfm.mit.edu /pub/usenet
212 Europe: ftp.uni-paderborn.de /pub/FAQ
213 src.doc.ic.ac.uk /usenet/news-FAQS
214 ftp.sunet.se /pub/usenet
215 sunsite.auc.dk /pub/usenet
216 Asia: nctuccca.edu.tw /USENET/FAQ
217 hwarang.postech.ac.kr /pub/usenet
218 ftp.hk.super.net /mirror/faqs")
220 (defvar gnus-group-archive-directory
221 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
222 "*The address of the (ding) archives.")
224 (defvar gnus-group-recent-archive-directory
225 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
226 "*The address of the most recent (ding) articles.")
228 (defvar gnus-default-subscribed-newsgroups nil
229 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
230 It should be a list of strings.
231 If it is `t', Gnus will not do anything special the first time it is
232 started; it'll just use the normal newsgroups subscription methods.")
234 (defvar gnus-use-cross-reference t
235 "*Non-nil means that cross referenced articles will be marked as read.
236 If nil, ignore cross references. If t, mark articles as read in
237 subscribed newsgroups. If neither t nor nil, mark as read in all
240 (defvar gnus-single-article-buffer t
241 "*If non-nil, display all articles in the same buffer.
242 If nil, each group will get its own article buffer.")
244 (defvar gnus-use-dribble-file t
245 "*Non-nil means that Gnus will use a dribble file to store user updates.
246 If Emacs should crash without saving the .newsrc files, complete
247 information can be restored from the dribble file.")
249 (defvar gnus-dribble-directory nil
250 "*The directory where dribble files will be saved.
251 If this variable is nil, the directory where the .newsrc files are
252 saved will be used.")
254 (defvar gnus-asynchronous nil
255 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
257 (defvar gnus-kill-summary-on-exit t
258 "*If non-nil, kill the summary buffer when you exit from it.
259 If nil, the summary will become a \"*Dead Summary*\" buffer, and
260 it will be killed sometime later.")
262 (defvar gnus-large-newsgroup 200
263 "*The number of articles which indicates a large newsgroup.
264 If the number of articles in a newsgroup is greater than this value,
265 confirmation is required for selecting the newsgroup.")
267 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
268 (defvar gnus-no-groups-message "No news is horrible news"
269 "*Message displayed by Gnus when no groups are available.")
271 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
272 "*Non-nil means that the default name of a file to save articles in is the group name.
273 If it's nil, the directory form of the group name is used instead.
275 If this variable is a list, and the list contains the element
276 `not-score', long file names will not be used for score files; if it
277 contains the element `not-save', long file names will not be used for
278 saving; and if it contains the element `not-kill', long file names
279 will not be used for kill files.")
281 (defvar gnus-article-save-directory gnus-directory
282 "*Name of the directory articles will be saved in (default \"~/News\").")
284 (defvar gnus-kill-files-directory gnus-directory
285 "*Name of the directory where kill files will be stored (default \"~/News\").")
287 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
288 "*A function to save articles in your favorite format.
289 The function must be interactively callable (in other words, it must
290 be an Emacs command).
292 Gnus provides the following functions:
294 * gnus-summary-save-in-rmail (Rmail format)
295 * gnus-summary-save-in-mail (Unix mail format)
296 * gnus-summary-save-in-folder (MH folder)
297 * gnus-summary-save-in-file (article format).
298 * gnus-summary-save-in-vm (use VM's folder format).")
300 (defvar gnus-prompt-before-saving 'always
301 "*This variable says how much prompting is to be done when saving articles.
302 If it is nil, no prompting will be done, and the articles will be
303 saved to the default files. If this variable is `always', each and
304 every article that is saved will be preceded by a prompt, even when
305 saving large batches of articles. If this variable is neither nil not
306 `always', there the user will be prompted once for a file name for
307 each invocation of the saving commands.")
309 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
310 "*A function generating a file name to save articles in Rmail format.
311 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
313 (defvar gnus-mail-save-name (function gnus-plain-save-name)
314 "*A function generating a file name to save articles in Unix mail format.
315 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
317 (defvar gnus-folder-save-name (function gnus-folder-save-name)
318 "*A function generating a file name to save articles in MH folder.
319 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
321 (defvar gnus-file-save-name (function gnus-numeric-save-name)
322 "*A function generating a file name to save articles in article format.
323 The function is called with NEWSGROUP, HEADERS, and optional
326 (defvar gnus-split-methods
327 '((gnus-article-archive-name))
328 "*Variable used to suggest where articles are to be saved.
329 For instance, if you would like to save articles related to Gnus in
330 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
331 you could set this variable to something like:
333 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
334 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
336 This variable is an alist where the where the key is the match and the
337 value is a list of possible files to save in if the match is non-nil.
339 If the match is a string, it is used as a regexp match on the
340 article. If the match is a symbol, that symbol will be funcalled
341 from the buffer of the article to be saved with the newsgroup as the
342 parameter. If it is a list, it will be evaled in the same buffer.
344 If this form or function returns a string, this string will be used as
345 a possible file name; and if it returns a non-nil list, that list will
346 be used as possible file names.")
348 (defvar gnus-move-split-methods nil
349 "*Variable used to suggest where articles are to be moved to.
350 It uses the same syntax as the `gnus-split-methods' variable.")
352 (defvar gnus-save-score nil
353 "*If non-nil, save group scoring info.")
355 (defvar gnus-use-adaptive-scoring nil
356 "*If non-nil, use some adaptive scoring scheme.")
358 (defvar gnus-use-cache nil
359 "*If nil, Gnus will ignore the article cache.
360 If `passive', it will allow entering (and reading) articles
361 explicitly entered into the cache. If anything else, use the
362 cache to the full extent of the law.")
364 (defvar gnus-use-trees nil
365 "*If non-nil, display a thread tree buffer.")
367 (defvar gnus-use-grouplens nil
368 "*If non-nil, use GroupLens ratings.")
370 (defvar gnus-keep-backlog nil
371 "*If non-nil, Gnus will keep read articles for later re-retrieval.
372 If it is a number N, then Gnus will only keep the last N articles
373 read. If it is neither nil nor a number, Gnus will keep all read
374 articles. This is not a good idea.")
376 (defvar gnus-use-nocem nil
377 "*If non-nil, Gnus will read NoCeM cancel messages.")
379 (defvar gnus-use-demon nil
380 "If non-nil, Gnus might use some demons.")
382 (defvar gnus-use-scoring t
383 "*If non-nil, enable scoring.")
385 (defvar gnus-use-picons nil
386 "*If non-nil, display picons.")
388 (defvar gnus-fetch-old-headers nil
389 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
390 If an unread article in the group refers to an older, already read (or
391 just marked as read) article, the old article will not normally be
392 displayed in the Summary buffer. If this variable is non-nil, Gnus
393 will attempt to grab the headers to the old articles, and thereby
394 build complete threads. If it has the value `some', only enough
395 headers to connect otherwise loose threads will be displayed.
396 This variable can also be a number. In that case, no more than that
397 number of old headers will be fetched.
399 The server has to support NOV for any of this to work.")
402 ;(defvar gnus-visual t
403 ; "*If non-nil, will do various highlighting.
404 ;If nil, no mouse highlights (or any other highlights) will be
405 ;performed. This might speed up Gnus some when generating large group
406 ;and summary buffers.")
408 (defvar gnus-novice-user t
409 "*Non-nil means that you are a usenet novice.
410 If non-nil, verbose messages may be displayed and confirmations may be
413 (defvar gnus-expert-user nil
414 "*Non-nil means that you will never be asked for confirmation about anything.
415 And that means *anything*.")
417 (defvar gnus-verbose 7
418 "*Integer that says how verbose Gnus should be.
419 The higher the number, the more messages Gnus will flash to say what
420 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
421 display most important messages; and at ten, Gnus will keep on
422 jabbering all the time.")
424 (defvar gnus-keep-same-level nil
425 "*Non-nil means that the next newsgroup after the current will be on the same level.
426 When you type, for instance, `n' after reading the last article in the
427 current newsgroup, you will go to the next newsgroup. If this variable
428 is nil, the next newsgroup will be the next from the group
430 If this variable is non-nil, Gnus will either put you in the
431 next newsgroup with the same level, or, if no such newsgroup is
432 available, the next newsgroup with the lowest possible level higher
433 than the current level.
434 If this variable is `best', Gnus will make the next newsgroup the one
435 with the best level.")
437 (defvar gnus-summary-make-false-root 'adopt
438 "*nil means that Gnus won't gather loose threads.
439 If the root of a thread has expired or been read in a previous
440 session, the information necessary to build a complete thread has been
441 lost. Instead of having many small sub-threads from this original thread
442 scattered all over the summary buffer, Gnus can gather them.
444 If non-nil, Gnus will try to gather all loose sub-threads from an
445 original thread into one large thread.
447 If this variable is non-nil, it should be one of `none', `adopt',
450 If this variable is `none', Gnus will not make a false root, but just
451 present the sub-threads after another.
452 If this variable is `dummy', Gnus will create a dummy root that will
453 have all the sub-threads as children.
454 If this variable is `adopt', Gnus will make one of the \"children\"
455 the parent and mark all the step-children as such.
456 If this variable is `empty', the \"children\" are printed with empty
457 subject fields. (Or rather, they will be printed with a string
458 given by the `gnus-summary-same-subject' variable.)")
460 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
461 "*A regexp to match subjects to be excluded from loose thread gathering.
462 As loose thread gathering is done on subjects only, that means that
463 there can be many false gatherings performed. By rooting out certain
464 common subjects, gathering might become saner.")
466 (defvar gnus-summary-gather-subject-limit nil
467 "*Maximum length of subject comparisons when gathering loose threads.
468 Use nil to compare full subjects. Setting this variable to a low
469 number will help gather threads that have been corrupted by
470 newsreaders chopping off subject lines, but it might also mean that
471 unrelated articles that have subject that happen to begin with the
472 same few characters will be incorrectly gathered.
474 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
475 comparing subjects.")
477 (defvar gnus-simplify-ignored-prefixes nil
478 "*Regexp, matches for which are removed from subject lines when simplifying.")
480 (defvar gnus-build-sparse-threads nil
481 "*If non-nil, fill in the gaps in threads.
482 If `some', only fill in the gaps that are needed to tie loose threads
483 together. If `more', fill in all leaf nodes that Gnus can find. If
484 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
486 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
487 "Function used for gathering loose threads.
488 There are two pre-defined functions: `gnus-gather-threads-by-subject',
489 which only takes Subjects into consideration; and
490 `gnus-gather-threads-by-references', which compared the References
491 headers of the articles to find matches.")
493 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
494 (defvar gnus-summary-same-subject ""
495 "*String indicating that the current article has the same subject as the previous.
496 This variable will only be used if the value of
497 `gnus-summary-make-false-root' is `empty'.")
499 (defvar gnus-summary-goto-unread t
500 "*If non-nil, marking commands will go to the next unread article.
501 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
502 whether it is read or not.")
504 (defvar gnus-group-goto-unread t
505 "*If non-nil, movement commands will go to the next unread and subscribed group.")
507 (defvar gnus-goto-next-group-when-activating t
508 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
510 (defvar gnus-check-new-newsgroups t
511 "*Non-nil means that Gnus will add new newsgroups at startup.
512 If this variable is `ask-server', Gnus will ask the server for new
513 groups since the last time it checked. This means that the killed list
514 is no longer necessary, so you could set `gnus-save-killed-list' to
517 A variant is to have this variable be a list of select methods. Gnus
518 will then use the `ask-server' method on all these select methods to
519 query for new groups from all those servers.
522 (setq gnus-check-new-newsgroups
523 '((nntp \"some.server\") (nntp \"other.server\")))
525 If this variable is nil, then you have to tell Gnus explicitly to
526 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
528 (defvar gnus-check-bogus-newsgroups nil
529 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
530 If this variable is nil, then you have to tell Gnus explicitly to
531 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
533 (defvar gnus-read-active-file t
534 "*Non-nil means that Gnus will read the entire active file at startup.
535 If this variable is nil, Gnus will only know about the groups in your
538 If this variable is `some', Gnus will try to only read the relevant
539 parts of the active file from the server. Not all servers support
540 this, and it might be quite slow with other servers, but this should
541 generally be faster than both the t and nil value.
543 If you set this variable to nil or `some', you probably still want to
544 be told about new newsgroups that arrive. To do that, set
545 `gnus-check-new-newsgroups' to `ask-server'. This may not work
546 properly with all servers.")
548 (defvar gnus-level-subscribed 5
549 "*Groups with levels less than or equal to this variable are subscribed.")
551 (defvar gnus-level-unsubscribed 7
552 "*Groups with levels less than or equal to this variable are unsubscribed.
553 Groups with levels less than `gnus-level-subscribed', which should be
554 less than this variable, are subscribed.")
556 (defvar gnus-level-zombie 8
557 "*Groups with this level are zombie groups.")
559 (defvar gnus-level-killed 9
560 "*Groups with this level are killed.")
562 (defvar gnus-level-default-subscribed 3
563 "*New subscribed groups will be subscribed at this level.")
565 (defvar gnus-level-default-unsubscribed 6
566 "*New unsubscribed groups will be unsubscribed at this level.")
568 (defvar gnus-activate-level (1+ gnus-level-subscribed)
569 "*Groups higher than this level won't be activated on startup.
570 Setting this variable to something log might save lots of time when
571 you have many groups that you aren't interested in.")
573 (defvar gnus-activate-foreign-newsgroups 4
574 "*If nil, Gnus will not check foreign newsgroups at startup.
575 If it is non-nil, it should be a number between one and nine. Foreign
576 newsgroups that have a level lower or equal to this number will be
577 activated on startup. For instance, if you want to active all
578 subscribed newsgroups, but not the rest, you'd set this variable to
579 `gnus-level-subscribed'.
581 If you subscribe to lots of newsgroups from different servers, startup
582 might take a while. By setting this variable to nil, you'll save time,
583 but you won't be told how many unread articles there are in the
586 (defvar gnus-save-newsrc-file t
587 "*Non-nil means that Gnus will save the `.newsrc' file.
588 Gnus always saves its own startup file, which is called
589 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
590 be readily understood by other newsreaders. If you don't plan on
591 using other newsreaders, set this variable to nil to save some time on
594 (defvar gnus-save-killed-list t
595 "*If non-nil, save the list of killed groups to the startup file.
596 If you set this variable to nil, you'll save both time (when starting
597 and quitting) and space (both memory and disk), but it will also mean
598 that Gnus has no record of which groups are new and which are old, so
599 the automatic new newsgroups subscription methods become meaningless.
601 You should always set `gnus-check-new-newsgroups' to `ask-server' or
602 nil if you set this variable to nil.")
604 (defvar gnus-interactive-catchup t
605 "*If non-nil, require your confirmation when catching up a group.")
607 (defvar gnus-interactive-exit t
608 "*If non-nil, require your confirmation when exiting Gnus.")
610 (defvar gnus-kill-killed t
611 "*If non-nil, Gnus will apply kill files to already killed articles.
612 If it is nil, Gnus will never apply kill files to articles that have
613 already been through the scoring process, which might very well save lots
616 (defvar gnus-extract-address-components 'gnus-extract-address-components
617 "*Function for extracting address components from a From header.
618 Two pre-defined function exist: `gnus-extract-address-components',
619 which is the default, quite fast, and too simplistic solution, and
620 `mail-extract-address-components', which works much better, but is
623 (defvar gnus-summary-default-score 0
624 "*Default article score level.
625 If this variable is nil, scoring will be disabled.")
627 (defvar gnus-summary-zcore-fuzz 0
628 "*Fuzziness factor for the zcore in the summary buffer.
629 Articles with scores closer than this to `gnus-summary-default-score'
630 will not be marked.")
632 (defvar gnus-simplify-subject-fuzzy-regexp nil
633 "*Strings to be removed when doing fuzzy matches.
634 This can either be a regular expression or list of regular expressions
635 that will be removed from subject strings if fuzzy subject
636 simplification is selected.")
638 (defvar gnus-permanently-visible-groups nil
639 "*Regexp to match groups that should always be listed in the group buffer.
640 This means that they will still be listed when there are no unread
641 articles in the groups.")
643 (defvar gnus-list-groups-with-ticked-articles t
644 "*If non-nil, list groups that have only ticked articles.
645 If nil, only list groups that have unread articles.")
647 (defvar gnus-group-default-list-level gnus-level-subscribed
648 "*Default listing level.
649 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
651 (defvar gnus-group-use-permanent-levels nil
652 "*If non-nil, once you set a level, Gnus will use this level.")
654 (defvar gnus-group-list-inactive-groups t
655 "*If non-nil, inactive groups will be listed.")
657 (defvar gnus-show-mime nil
658 "*If non-nil, do mime processing of articles.
659 The articles will simply be fed to the function given by
660 `gnus-show-mime-method'.")
662 (defvar gnus-strict-mime t
663 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
665 (defvar gnus-show-mime-method 'metamail-buffer
666 "*Function to process a MIME message.
667 The function is called from the article buffer.")
669 (defvar gnus-decode-encoded-word-method (lambda ())
670 "*Function to decode a MIME encoded-words.
671 The function is called from the article buffer.")
673 (defvar gnus-show-threads t
674 "*If non-nil, display threads in summary mode.")
676 (defvar gnus-thread-hide-subtree nil
677 "*If non-nil, hide all threads initially.
678 If threads are hidden, you have to run the command
679 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
680 to expose hidden threads.")
682 (defvar gnus-thread-hide-killed t
683 "*If non-nil, hide killed threads automatically.")
685 (defvar gnus-thread-ignore-subject nil
686 "*If non-nil, ignore subjects and do all threading based on the Reference header.
687 If nil, which is the default, articles that have different subjects
688 from their parents will start separate threads.")
690 (defvar gnus-thread-operation-ignore-subject t
691 "*If non-nil, subjects will be ignored when doing thread commands.
692 This affects commands like `gnus-summary-kill-thread' and
693 `gnus-summary-lower-thread'.
695 If this variable is nil, articles in the same thread with different
696 subjects will not be included in the operation in question. If this
697 variable is `fuzzy', only articles that have subjects that are fuzzily
698 equal will be included.")
700 (defvar gnus-thread-indent-level 4
701 "*Number that says how much each sub-thread should be indented.")
703 (defvar gnus-ignored-newsgroups
704 (purecopy (mapconcat 'identity
705 '("^to\\." ; not "real" groups
706 "^[0-9. \t]+ " ; all digits in name
707 "[][\"#'()]" ; bogus characters
710 "*A regexp to match uninteresting newsgroups in the active file.
711 Any lines in the active file matching this regular expression are
712 removed from the newsgroup list before anything else is done to it,
713 thus making them effectively non-existent.")
715 (defvar gnus-ignored-headers
716 "^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:"
717 "*All headers that match this regexp will be hidden.
718 This variable can also be a list of regexps of headers to be ignored.
719 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
721 (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-"
722 "*All headers that do not match this regexp will be hidden.
723 This variable can also be a list of regexp of headers to remain visible.
724 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
726 (defvar gnus-sorted-header-list
727 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
728 "^Cc:" "^Date:" "^Organization:")
729 "*This variable is a list of regular expressions.
730 If it is non-nil, headers that match the regular expressions will
731 be placed first in the article buffer in the sequence specified by
734 (defvar gnus-boring-article-headers
735 '(empty followup-to reply-to)
736 "*Headers that are only to be displayed if they have interesting data.
737 Possible values in this list are `empty', `newsgroups', `followup-to',
738 `reply-to', and `date'.")
740 (defvar gnus-show-all-headers nil
741 "*If non-nil, don't hide any headers.")
743 (defvar gnus-save-all-headers t
744 "*If non-nil, don't remove any headers before saving.")
746 (defvar gnus-saved-headers gnus-visible-headers
747 "*Headers to keep if `gnus-save-all-headers' is nil.
748 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
749 If that variable is nil, however, all headers that match this regexp
750 will be kept while the rest will be deleted before saving.")
752 (defvar gnus-inhibit-startup-message nil
753 "*If non-nil, the startup message will not be displayed.")
755 (defvar gnus-signature-separator "^-- *$"
756 "Regexp matching signature separator.")
758 (defvar gnus-signature-limit nil
759 "Provide a limit to what is considered a signature.
760 If it is a number, no signature may not be longer (in characters) than
761 that number. If it is a function, the function will be called without
762 any parameters, and if it returns nil, there is no signature in the
763 buffer. If it is a string, it will be used as a regexp. If it
764 matches, the text in question is not a signature.")
766 (defvar gnus-auto-extend-newsgroup t
767 "*If non-nil, extend newsgroup forward and backward when requested.")
769 (defvar gnus-auto-select-first t
770 "*If nil, don't select the first unread article when entering a group.
771 If this variable is `best', select the highest-scored unread article
772 in the group. If neither nil nor `best', select the first unread
775 If you want to prevent automatic selection of the first unread article
776 in some newsgroups, set the variable to nil in
777 `gnus-select-group-hook'.")
779 (defvar gnus-auto-select-next t
780 "*If non-nil, offer to go to the next group from the end of the previous.
781 If the value is t and the next newsgroup is empty, Gnus will exit
782 summary mode and go back to group mode. If the value is neither nil
783 nor t, Gnus will select the following unread newsgroup. In
784 particular, if the value is the symbol `quietly', the next unread
785 newsgroup will be selected without any confirmation, and if it is
786 `almost-quietly', the next group will be selected without any
787 confirmation if you are located on the last article in the group.
788 Finally, if this variable is `slightly-quietly', the `Z n' command
789 will go to the next group without confirmation.")
791 (defvar gnus-auto-select-same nil
792 "*If non-nil, select the next article with the same subject.")
794 (defvar gnus-summary-check-current nil
795 "*If non-nil, consider the current article when moving.
796 The \"unread\" movement commands will stay on the same line if the
797 current article is unread.")
799 (defvar gnus-auto-center-summary t
800 "*If non-nil, always center the current summary buffer.
801 In particular, if `vertical' do only vertical recentering. If non-nil
802 and non-`vertical', do both horizontal and vertical recentering.")
804 (defvar gnus-break-pages t
805 "*If non-nil, do page breaking on articles.
806 The page delimiter is specified by the `gnus-page-delimiter'
809 (defvar gnus-page-delimiter "^\^L"
810 "*Regexp describing what to use as article page delimiters.
811 The default value is \"^\^L\", which is a form linefeed at the
812 beginning of a line.")
814 (defvar gnus-use-full-window t
815 "*If non-nil, use the entire Emacs screen.")
817 (defvar gnus-window-configuration nil
818 "Obsolete variable. See `gnus-buffer-configuration'.")
820 (defvar gnus-window-min-width 2
821 "*Minimum width of Gnus buffers.")
823 (defvar gnus-window-min-height 1
824 "*Minimum height of Gnus buffers.")
826 (defvar gnus-buffer-configuration
830 (if gnus-carpal '(group-carpal 4))))
834 (if gnus-carpal '(summary-carpal 4))))
841 (if gnus-carpal '(summary-carpal 4))
843 (vertical ((height . 5) (width . 15)
845 (left . -1) (top . 1))
855 (if gnus-carpal '(summary-carpal 4))
856 (if gnus-use-trees '(tree 0.25))
861 (if gnus-carpal '(server-carpal 2))))
865 (if gnus-carpal '(browse-carpal 2))))
868 (message 1.0 point)))
871 (article 1.0 point)))
882 (edit-group 1.0 point)))
886 (edit-server 1.0 point)))
890 (edit-score 1.0 point)))
897 (message 1.0 point)))
900 (message 1.0 point)))
903 (message 1.0 point)))
907 (message 1.0 point)))
914 (if gnus-carpal '(summary-carpal 4))
915 ("*Shell Command Output*" 1.0)))
918 ("*Gnus Help Bug*" 0.5)
919 ("*Gnus Bug*" 1.0 point)))
923 (message 1.0 point))))
924 "Window configuration for all possible Gnus buffers.
925 This variable is a list of lists. Each of these lists has a NAME and
926 a RULE. The NAMEs are commonsense names like `group', which names a
927 rule used when displaying the group buffer; `summary', which names a
928 rule for what happens when you enter a group and do not display an
929 article buffer; and so on. See the value of this variable for a
930 complete list of NAMEs.
932 Each RULE is a list of vectors. The first element in this vector is
933 the name of the buffer to be displayed; the second element is the
934 percentage of the screen this buffer is to occupy (a number in the
935 0.0-0.99 range); the optional third element is `point', which should
936 be present to denote which buffer point is to go to after making this
937 buffer configuration.")
939 (defvar gnus-window-to-buffer
940 '((group . gnus-group-buffer)
941 (summary . gnus-summary-buffer)
942 (article . gnus-article-buffer)
943 (server . gnus-server-buffer)
944 (browse . "*Gnus Browse Server*")
945 (edit-group . gnus-group-edit-buffer)
946 (edit-server . gnus-server-edit-buffer)
947 (group-carpal . gnus-carpal-group-buffer)
948 (summary-carpal . gnus-carpal-summary-buffer)
949 (server-carpal . gnus-carpal-server-buffer)
950 (browse-carpal . gnus-carpal-browse-buffer)
951 (edit-score . gnus-score-edit-buffer)
952 (message . gnus-message-buffer)
953 (mail . gnus-message-buffer)
954 (post-news . gnus-message-buffer)
955 (faq . gnus-faq-buffer)
956 (picons . "*Picons*")
957 (tree . gnus-tree-buffer)
958 (info . gnus-info-buffer)
959 (article-copy . gnus-article-copy)
960 (draft . gnus-draft-buffer))
961 "Mapping from short symbols to buffer names or buffer variables.")
963 (defvar gnus-carpal nil
964 "*If non-nil, display clickable icons.")
966 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
967 "*Function called with a group name when new group is detected.
968 A few pre-made functions are supplied: `gnus-subscribe-randomly'
969 inserts new groups at the beginning of the list of groups;
970 `gnus-subscribe-alphabetically' inserts new groups in strict
971 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
972 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
973 for your decision; `gnus-subscribe-killed' kills all new groups;
974 `gnus-subscribe-zombies' will make all new groups into zombies.")
976 ;; Suggested by a bug report by Hallvard B Furuseth.
977 ;; <h.b.furuseth@usit.uio.no>.
978 (defvar gnus-subscribe-options-newsgroup-method
979 (function gnus-subscribe-alphabetically)
980 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
981 If, for instance, you want to subscribe to all newsgroups in the
982 \"no\" and \"alt\" hierarchies, you'd put the following in your
985 options -n no.all alt.all
987 Gnus will the subscribe all new newsgroups in these hierarchies with
988 the subscription method in this variable.")
990 (defvar gnus-subscribe-hierarchical-interactive nil
991 "*If non-nil, Gnus will offer to subscribe hierarchically.
992 When a new hierarchy appears, Gnus will ask the user:
994 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
996 If the user pressed `d', Gnus will descend the hierarchy, `y' will
997 subscribe to all newsgroups in the hierarchy and `s' will skip this
998 hierarchy in its entirety.")
1000 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1001 "*Function used for sorting the group buffer.
1002 This function will be called with group info entries as the arguments
1003 for the groups to be sorted. Pre-made functions include
1004 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1005 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1006 `gnus-group-sort-by-rank'.
1008 This variable can also be a list of sorting functions. In that case,
1009 the most significant sort function should be the last function in the
1012 ;; Mark variables suggested by Thomas Michanek
1013 ;; <Thomas.Michanek@telelogic.se>.
1014 (defvar gnus-unread-mark ?
1015 "*Mark used for unread articles.")
1016 (defvar gnus-ticked-mark ?!
1017 "*Mark used for ticked articles.")
1018 (defvar gnus-dormant-mark ??
1019 "*Mark used for dormant articles.")
1020 (defvar gnus-del-mark ?r
1021 "*Mark used for del'd articles.")
1022 (defvar gnus-read-mark ?R
1023 "*Mark used for read articles.")
1024 (defvar gnus-expirable-mark ?E
1025 "*Mark used for expirable articles.")
1026 (defvar gnus-killed-mark ?K
1027 "*Mark used for killed articles.")
1028 (defvar gnus-souped-mark ?F
1029 "*Mark used for killed articles.")
1030 (defvar gnus-kill-file-mark ?X
1031 "*Mark used for articles killed by kill files.")
1032 (defvar gnus-low-score-mark ?Y
1033 "*Mark used for articles with a low score.")
1034 (defvar gnus-catchup-mark ?C
1035 "*Mark used for articles that are caught up.")
1036 (defvar gnus-replied-mark ?A
1037 "*Mark used for articles that have been replied to.")
1038 (defvar gnus-cached-mark ?*
1039 "*Mark used for articles that are in the cache.")
1040 (defvar gnus-saved-mark ?S
1041 "*Mark used for articles that have been saved to.")
1042 (defvar gnus-process-mark ?#
1044 (defvar gnus-ancient-mark ?O
1045 "*Mark used for ancient articles.")
1046 (defvar gnus-sparse-mark ?Q
1047 "*Mark used for sparsely reffed articles.")
1048 (defvar gnus-canceled-mark ?G
1049 "*Mark used for canceled articles.")
1050 (defvar gnus-score-over-mark ?+
1051 "*Score mark used for articles with high scores.")
1052 (defvar gnus-score-below-mark ?-
1053 "*Score mark used for articles with low scores.")
1054 (defvar gnus-empty-thread-mark ?
1055 "*There is no thread under the article.")
1056 (defvar gnus-not-empty-thread-mark ?=
1057 "*There is a thread under the article.")
1059 (defvar gnus-view-pseudo-asynchronously nil
1060 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1062 (defvar gnus-view-pseudos nil
1063 "*If `automatic', pseudo-articles will be viewed automatically.
1064 If `not-confirm', pseudos will be viewed automatically, and the user
1065 will not be asked to confirm the command.")
1067 (defvar gnus-view-pseudos-separately t
1068 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1069 If nil, all files that use the same viewing command will be given as a
1070 list of parameters to that command.")
1072 (defvar gnus-insert-pseudo-articles t
1073 "*If non-nil, insert pseudo-articles when decoding articles.")
1075 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1076 "*Format of group lines.
1077 It works along the same lines as a normal formatting string,
1078 with some simple extensions.
1080 %M Only marked articles (character, \"*\" or \" \")
1081 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1082 %L Level of subscribedness (integer)
1083 %N Number of unread articles (integer)
1084 %I Number of dormant articles (integer)
1085 %i Number of ticked and dormant (integer)
1086 %T Number of ticked articles (integer)
1087 %R Number of read articles (integer)
1088 %t Total number of articles (integer)
1089 %y Number of unread, unticked articles (integer)
1090 %G Group name (string)
1091 %g Qualified group name (string)
1092 %D Group description (string)
1093 %s Select method (string)
1094 %o Moderated group (char, \"m\")
1095 %p Process mark (char)
1096 %O Moderated group (string, \"(m)\" or \"\")
1097 %P Topic indentation (string)
1098 %l Whether there are GroupLens predictions for this group (string)
1099 %n Select from where (string)
1100 %z A string that look like `<%s:%n>' if a foreign select method is used
1101 %u User defined specifier. The next character in the format string should
1102 be a letter. Gnus will call the function gnus-user-format-function-X,
1103 where X is the letter following %u. The function will be passed the
1104 current header as argument. The function should return a string, which
1105 will be inserted into the buffer just like information from any other
1108 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1109 the mouse point move inside the area. There can only be one such area.
1111 Note that this format specification is not always respected. For
1112 reasons of efficiency, when listing killed groups, this specification
1113 is ignored altogether. If the spec is changed considerably, your
1114 output may end up looking strange when listing both alive and killed
1117 If you use %o or %O, reading the active file will be slower and quite
1118 a bit of extra memory will be used. %D will also worsen performance.
1119 Also note that if you change the format specification to include any
1120 of these specs, you must probably re-start Gnus to see them go into
1123 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1124 "*The format specification of the lines in the summary buffer.
1126 It works along the same lines as a normal formatting string,
1127 with some simple extensions.
1129 %N Article number, left padded with spaces (string)
1131 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1132 %n Name of the poster (string)
1133 %a Extracted name of the poster (string)
1134 %A Extracted address of the poster (string)
1135 %F Contents of the From: header (string)
1136 %x Contents of the Xref: header (string)
1137 %D Date of the article (string)
1138 %d Date of the article (string) in DD-MMM format
1139 %M Message-id of the article (string)
1140 %r References of the article (string)
1141 %c Number of characters in the article (integer)
1142 %L Number of lines in the article (integer)
1143 %I Indentation based on thread level (a string of spaces)
1144 %T A string with two possible values: 80 spaces if the article
1145 is on thread level two or larger and 0 spaces on level one
1146 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1147 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1148 %[ Opening bracket (character, \"[\" or \"<\")
1149 %] Closing bracket (character, \"]\" or \">\")
1150 %> Spaces of length thread-level (string)
1151 %< Spaces of length (- 20 thread-level) (string)
1152 %i Article score (number)
1153 %z Article zcore (character)
1154 %t Number of articles under the current thread (number).
1155 %e Whether the thread is empty or not (character).
1156 %l GroupLens score (string).
1157 %u User defined specifier. The next character in the format string should
1158 be a letter. Gnus will call the function gnus-user-format-function-X,
1159 where X is the letter following %u. The function will be passed the
1160 current header as argument. The function should return a string, which
1161 will be inserted into the summary just like information from any other
1164 Text between %( and %) will be highlighted with `gnus-mouse-face'
1165 when the mouse point is placed inside the area. There can only be one
1168 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1169 with care. For reasons of efficiency, Gnus will compute what column
1170 these characters will end up in, and \"hard-code\" that. This means that
1171 it is illegal to have these specs after a variable-length spec. Well,
1172 you might not be arrested, but your summary buffer will look strange,
1173 which is bad enough.
1175 The smart choice is to have these specs as for to the left as
1178 This restriction may disappear in later versions of Gnus.")
1180 (defvar gnus-summary-dummy-line-format
1182 "*The format specification for the dummy roots in the summary buffer.
1183 It works along the same lines as a normal formatting string,
1184 with some simple extensions.
1188 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1189 "*The format specification for the summary mode line.
1190 It works along the same lines as a normal formatting string,
1191 with some simple extensions:
1194 %p Unprefixed group name
1195 %A Current article number
1197 %U Number of unread articles in the group
1198 %e Number of unselected articles in the group
1199 %Z A string with unread/unselected article counts
1200 %g Shortish group name
1201 %S Subject of the current article
1202 %u User-defined spec
1203 %s Current score file name
1204 %d Number of dormant articles
1205 %r Number of articles that have been marked as read in this session
1206 %E Number of articles expunged by the score files")
1208 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1209 "*The format specification for the article mode line.
1210 See `gnus-summary-mode-line-format' for a closer description.")
1212 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1213 "*The format specification for the group mode line.
1214 It works along the same lines as a normal formatting string,
1215 with some simple extensions:
1217 %S The native news server.
1218 %M The native select method.
1219 %: \":\" if %S isn't \"\".")
1221 (defvar gnus-valid-select-methods
1222 '(("nntp" post address prompt-address)
1223 ("nnspool" post address)
1224 ("nnvirtual" post-mail virtual prompt-address)
1225 ("nnmbox" mail respool address)
1226 ("nnml" mail respool address)
1227 ("nnmh" mail respool address)
1228 ("nndir" post-mail prompt-address address)
1229 ("nneething" none address prompt-address)
1230 ("nndoc" none address prompt-address)
1231 ("nnbabyl" mail address respool)
1232 ("nnkiboze" post address virtual)
1233 ("nnsoup" post-mail address)
1234 ("nndraft" post-mail)
1235 ("nnfolder" mail respool address))
1236 "An alist of valid select methods.
1237 The first element of each list lists should be a string with the name
1238 of the select method. The other elements may be be the category of
1239 this method (ie. `post', `mail', `none' or whatever) or other
1240 properties that this method has (like being respoolable).
1241 If you implement a new select method, all you should have to change is
1242 this variable. I think.")
1244 (defvar gnus-updated-mode-lines '(group article summary tree)
1245 "*List of buffers that should update their mode lines.
1246 The list may contain the symbols `group', `article' and `summary'. If
1247 the corresponding symbol is present, Gnus will keep that mode line
1248 updated with information that may be pertinent.
1249 If this variable is nil, screen refresh may be quicker.")
1251 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1252 (defvar gnus-mode-non-string-length nil
1253 "*Max length of mode-line non-string contents.
1254 If this is nil, Gnus will take space as is needed, leaving the rest
1255 of the modeline intact.")
1258 ;(defvar gnus-mouse-face 'highlight
1259 ; "*Face used for mouse highlighting in Gnus.
1260 ;No mouse highlights will be done if `gnus-visual' is nil.")
1262 (defvar gnus-summary-mark-below nil
1263 "*Mark all articles with a score below this variable as read.
1264 This variable is local to each summary buffer and usually set by the
1267 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1268 "*List of functions used for sorting articles in the summary buffer.
1269 This variable is only used when not using a threaded display.")
1271 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1272 "*List of functions used for sorting threads in the summary buffer.
1273 By default, threads are sorted by article number.
1275 Each function takes two threads and return non-nil if the first thread
1276 should be sorted before the other. If you use more than one function,
1277 the primary sort function should be the last. You should probably
1278 always include `gnus-thread-sort-by-number' in the list of sorting
1279 functions -- preferably first.
1281 Ready-mady functions include `gnus-thread-sort-by-number',
1282 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1283 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1284 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1286 (defvar gnus-thread-score-function '+
1287 "*Function used for calculating the total score of a thread.
1289 The function is called with the scores of the article and each
1290 subthread and should then return the score of the thread.
1292 Some functions you can use are `+', `max', or `min'.")
1294 (defvar gnus-summary-expunge-below nil
1295 "All articles that have a score less than this variable will be expunged.")
1297 (defvar gnus-thread-expunge-below nil
1298 "All threads that have a total score less than this variable will be expunged.
1299 See `gnus-thread-score-function' for en explanation of what a
1300 \"thread score\" is.")
1302 (defvar gnus-auto-subscribed-groups
1303 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1304 "*All new groups that match this regexp will be subscribed automatically.
1305 Note that this variable only deals with new groups. It has no effect
1306 whatsoever on old groups.")
1308 (defvar gnus-options-subscribe nil
1309 "*All new groups matching this regexp will be subscribed unconditionally.
1310 Note that this variable deals only with new newsgroups. This variable
1311 does not affect old newsgroups.")
1313 (defvar gnus-options-not-subscribe nil
1314 "*All new groups matching this regexp will be ignored.
1315 Note that this variable deals only with new newsgroups. This variable
1316 does not affect old (already subscribed) newsgroups.")
1318 (defvar gnus-auto-expirable-newsgroups nil
1319 "*Groups in which to automatically mark read articles as expirable.
1320 If non-nil, this should be a regexp that should match all groups in
1321 which to perform auto-expiry. This only makes sense for mail groups.")
1323 (defvar gnus-total-expirable-newsgroups nil
1324 "*Groups in which to perform expiry of all read articles.
1325 Use with extreme caution. All groups that match this regexp will be
1326 expiring - which means that all read articles will be deleted after
1327 (say) one week. (This only goes for mail groups and the like, of
1330 (defvar gnus-group-uncollapsed-levels 1
1331 "Number of group name elements to leave alone when making a short group name.")
1333 (defvar gnus-hidden-properties '(invisible t intangible t)
1334 "Property list to use for hiding text.")
1336 (defvar gnus-modtime-botch nil
1337 "*Non-nil means .newsrc should be deleted prior to save.
1338 Its use is due to the bogus appearance that .newsrc was modified on
1343 (defvar gnus-group-mode-hook nil
1344 "*A hook for Gnus group mode.")
1346 (defvar gnus-summary-mode-hook nil
1347 "*A hook for Gnus summary mode.
1348 This hook is run before any variables are set in the summary buffer.")
1350 (defvar gnus-article-mode-hook nil
1351 "*A hook for Gnus article mode.")
1353 (defvar gnus-summary-prepare-exit-hook nil
1354 "*A hook called when preparing to exit from the summary buffer.
1355 It calls `gnus-summary-expire-articles' by default.")
1356 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1358 (defvar gnus-summary-exit-hook nil
1359 "*A hook called on exit from the summary buffer.")
1361 (defvar gnus-group-catchup-group-hook nil
1362 "*A hook run when catching up a group from the group buffer.")
1364 (defvar gnus-open-server-hook nil
1365 "*A hook called just before opening connection to the news server.")
1367 (defvar gnus-load-hook nil
1368 "*A hook run while Gnus is loaded.")
1370 (defvar gnus-startup-hook nil
1371 "*A hook called at startup.
1372 This hook is called after Gnus is connected to the NNTP server.")
1374 (defvar gnus-get-new-news-hook nil
1375 "*A hook run just before Gnus checks for new news.")
1377 (defvar gnus-after-getting-new-news-hook nil
1378 "*A hook run after Gnus checks for new news.")
1380 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1381 "*A function that is called to generate the group buffer.
1382 The function is called with three arguments: The first is a number;
1383 all group with a level less or equal to that number should be listed,
1384 if the second is non-nil, empty groups should also be displayed. If
1385 the third is non-nil, it is a number. No groups with a level lower
1386 than this number should be displayed.
1388 The only current function implemented is `gnus-group-prepare-flat'.")
1390 (defvar gnus-group-prepare-hook nil
1391 "*A hook called after the group buffer has been generated.
1392 If you want to modify the group buffer, you can use this hook.")
1394 (defvar gnus-summary-prepare-hook nil
1395 "*A hook called after the summary buffer has been generated.
1396 If you want to modify the summary buffer, you can use this hook.")
1398 (defvar gnus-summary-generate-hook nil
1399 "*A hook run just before generating the summary buffer.
1400 This hook is commonly used to customize threading variables and the
1403 (defvar gnus-article-prepare-hook nil
1404 "*A hook called after an article has been prepared in the article buffer.
1405 If you want to run a special decoding program like nkf, use this hook.")
1407 ;(defvar gnus-article-display-hook nil
1408 ; "*A hook called after the article is displayed in the article buffer.
1409 ;The hook is designed to change the contents of the article
1410 ;buffer. Typical functions that this hook may contain are
1411 ;`gnus-article-hide-headers' (hide selected headers),
1412 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1413 ;`gnus-article-hide-signature' (hide signature) and
1414 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1415 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1416 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1417 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1419 (defvar gnus-article-x-face-command
1420 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1421 "String or function to be executed to display an X-Face header.
1422 If it is a string, the command will be executed in a sub-shell
1423 asynchronously. The compressed face will be piped to this command.")
1425 (defvar gnus-article-x-face-too-ugly nil
1426 "Regexp matching posters whose face shouldn't be shown automatically.")
1428 (defvar gnus-select-group-hook nil
1429 "*A hook called when a newsgroup is selected.
1431 If you'd like to simplify subjects like the
1432 `gnus-summary-next-same-subject' command does, you can use the
1435 (setq gnus-select-group-hook
1438 (mapcar (lambda (header)
1439 (mail-header-set-subject
1441 (gnus-simplify-subject
1442 (mail-header-subject header) 're-only)))
1443 gnus-newsgroup-headers))))")
1445 (defvar gnus-select-article-hook nil
1446 "*A hook called when an article is selected.")
1448 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1449 "*A hook called to apply kill files to a group.
1450 This hook is intended to apply a kill file to the selected newsgroup.
1451 The function `gnus-apply-kill-file' is called by default.
1453 Since a general kill file is too heavy to use only for a few
1454 newsgroups, I recommend you to use a lighter hook function. For
1455 example, if you'd like to apply a kill file to articles which contains
1456 a string `rmgroup' in subject in newsgroup `control', you can use the
1459 (setq gnus-apply-kill-hook
1462 (cond ((string-match \"control\" gnus-newsgroup-name)
1463 (gnus-kill \"Subject\" \"rmgroup\")
1464 (gnus-expunge \"X\"))))))")
1466 (defvar gnus-visual-mark-article-hook
1467 (list 'gnus-highlight-selected-summary)
1468 "*Hook run after selecting an article in the summary buffer.
1469 It is meant to be used for highlighting the article in some way. It
1470 is not run if `gnus-visual' is nil.")
1472 (defvar gnus-parse-headers-hook nil
1473 "*A hook called before parsing the headers.")
1474 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1476 (defvar gnus-exit-group-hook nil
1477 "*A hook called when exiting (not quitting) summary mode.")
1479 (defvar gnus-suspend-gnus-hook nil
1480 "*A hook called when suspending (not exiting) Gnus.")
1482 (defvar gnus-exit-gnus-hook nil
1483 "*A hook called when exiting Gnus.")
1485 (defvar gnus-after-exiting-gnus-hook nil
1486 "*A hook called after exiting Gnus.")
1488 (defvar gnus-save-newsrc-hook nil
1489 "*A hook called before saving any of the newsrc files.")
1491 (defvar gnus-save-quick-newsrc-hook nil
1492 "*A hook called just before saving the quick newsrc file.
1493 Can be used to turn version control on or off.")
1495 (defvar gnus-save-standard-newsrc-hook nil
1496 "*A hook called just before saving the standard newsrc file.
1497 Can be used to turn version control on or off.")
1499 (defvar gnus-summary-update-hook
1500 (list 'gnus-summary-highlight-line)
1501 "*A hook called when a summary line is changed.
1502 The hook will not be called if `gnus-visual' is nil.
1504 The default function `gnus-summary-highlight-line' will
1505 highlight the line according to the `gnus-summary-highlight'
1508 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1509 "*A hook called when a group line is changed.
1510 The hook will not be called if `gnus-visual' is nil.
1512 The default function `gnus-group-highlight-line' will
1513 highlight the line according to the `gnus-group-highlight'
1516 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1517 "*A hook called when an article is selected for the first time.
1518 The hook is intended to mark an article as read (or unread)
1519 automatically when it is selected.")
1521 (defvar gnus-group-change-level-function nil
1522 "Function run when a group level is changed.
1523 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1525 ;; Remove any hilit infestation.
1526 (add-hook 'gnus-startup-hook
1528 (remove-hook 'gnus-summary-prepare-hook
1529 'hilit-rehighlight-buffer-quietly)
1530 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1531 (setq gnus-mark-article-hook
1532 '(gnus-summary-mark-read-and-unread-as-read))
1533 (remove-hook 'gnus-article-prepare-hook
1534 'hilit-rehighlight-buffer-quietly)))
1537 ;; Internal variables
1539 (defvar gnus-tree-buffer "*Tree*"
1540 "Buffer where Gnus thread trees are displayed.")
1543 (defvar gnus-use-generic-from nil)
1545 (defvar gnus-thread-indent-array nil)
1546 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1548 (defvar gnus-newsrc-file-version nil)
1550 (defvar gnus-method-history nil)
1551 ;; Variable holding the user answers to all method prompts.
1553 (defvar gnus-group-history nil)
1554 ;; Variable holding the user answers to all group prompts.
1556 (defvar gnus-server-alist nil
1557 "List of available servers.")
1559 (defvar gnus-group-indentation-function nil)
1561 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1563 (defvar gnus-goto-missing-group-function nil)
1565 (defvar gnus-override-subscribe-method nil)
1567 (defvar gnus-group-goto-next-group-function nil
1568 "Function to override finding the next group after listing groups.")
1570 (defconst gnus-article-mark-lists
1571 '((marked . tick) (replied . reply)
1572 (expirable . expire) (killed . killed)
1573 (bookmarks . bookmark) (dormant . dormant)
1574 (scored . score) (saved . save)
1578 ;; Avoid highlighting in kill files.
1579 (defvar gnus-summary-inhibit-highlight nil)
1580 (defvar gnus-newsgroup-selected-overlay nil)
1582 (defvar gnus-inhibit-hiding nil)
1583 (defvar gnus-group-indentation "")
1584 (defvar gnus-inhibit-limiting nil)
1585 (defvar gnus-created-frames nil)
1587 (defvar gnus-article-mode-map nil)
1588 (defvar gnus-dribble-buffer nil)
1589 (defvar gnus-headers-retrieved-by nil)
1590 (defvar gnus-article-reply nil)
1591 (defvar gnus-override-method nil)
1592 (defvar gnus-article-check-size nil)
1594 (defvar gnus-current-score-file nil)
1595 (defvar gnus-newsgroup-adaptive-score-file nil)
1596 (defvar gnus-scores-exclude-files nil)
1598 (defvar gnus-opened-servers nil)
1600 (defvar gnus-current-move-group nil)
1601 (defvar gnus-current-copy-group nil)
1602 (defvar gnus-current-crosspost-group nil)
1604 (defvar gnus-newsgroup-dependencies nil)
1605 (defvar gnus-newsgroup-async nil)
1606 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1608 (defvar gnus-newsgroup-adaptive nil)
1610 (defvar gnus-summary-display-table nil)
1611 (defvar gnus-summary-display-article-function nil)
1613 (defvar gnus-summary-highlight-line-function nil
1614 "Function called after highlighting a summary line.")
1616 (defvar gnus-group-line-format-alist
1617 `((?M gnus-tmp-marked-mark ?c)
1618 (?S gnus-tmp-subscribed ?c)
1619 (?L gnus-tmp-level ?d)
1620 (?N (cond ((eq number t) "*" )
1624 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1625 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1627 (?R gnus-tmp-number-of-read ?s)
1628 (?t gnus-tmp-number-total ?d)
1629 (?y gnus-tmp-number-of-unread ?s)
1630 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1631 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1632 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1634 (?g gnus-tmp-group ?s)
1635 (?G gnus-tmp-qualified-group ?s)
1636 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1637 (?D gnus-tmp-newsgroup-description ?s)
1638 (?o gnus-tmp-moderated ?c)
1639 (?O gnus-tmp-moderated-string ?s)
1640 (?p gnus-tmp-process-marked ?c)
1641 (?s gnus-tmp-news-server ?s)
1642 (?n gnus-tmp-news-method ?s)
1643 (?P gnus-group-indentation ?s)
1644 (?l gnus-tmp-grouplens ?s)
1645 (?z gnus-tmp-news-method-string ?s)
1646 (?u gnus-tmp-user-defined ?s)))
1648 (defvar gnus-summary-line-format-alist
1649 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1650 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1651 (?s gnus-tmp-subject-or-nil ?s)
1652 (?n gnus-tmp-name ?s)
1653 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1655 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1657 (?F gnus-tmp-from ?s)
1658 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1659 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1660 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1661 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1662 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1663 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1664 (?L gnus-tmp-lines ?d)
1665 (?I gnus-tmp-indentation ?s)
1666 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1667 (?R gnus-tmp-replied ?c)
1668 (?\[ gnus-tmp-opening-bracket ?c)
1669 (?\] gnus-tmp-closing-bracket ?c)
1670 (?\> (make-string gnus-tmp-level ? ) ?s)
1671 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1672 (?i gnus-tmp-score ?d)
1673 (?z gnus-tmp-score-char ?c)
1674 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1675 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1676 (?U gnus-tmp-unread ?c)
1677 (?t (gnus-summary-number-of-articles-in-thread
1678 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1680 (?e (gnus-summary-number-of-articles-in-thread
1681 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1683 (?u gnus-tmp-user-defined ?s))
1684 "An alist of format specifications that can appear in summary lines,
1685 and what variables they correspond with, along with the type of the
1686 variable (string, integer, character, etc).")
1688 (defvar gnus-summary-dummy-line-format-alist
1689 `((?S gnus-tmp-subject ?s)
1690 (?N gnus-tmp-number ?d)
1691 (?u gnus-tmp-user-defined ?s)))
1693 (defvar gnus-summary-mode-line-format-alist
1694 `((?G gnus-tmp-group-name ?s)
1695 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1696 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1697 (?A gnus-tmp-article-number ?d)
1698 (?Z gnus-tmp-unread-and-unselected ?s)
1699 (?V gnus-version ?s)
1700 (?U gnus-tmp-unread ?d)
1701 (?S gnus-tmp-subject ?s)
1702 (?e gnus-tmp-unselected ?d)
1703 (?u gnus-tmp-user-defined ?s)
1704 (?d (length gnus-newsgroup-dormant) ?d)
1705 (?t (length gnus-newsgroup-marked) ?d)
1706 (?r (length gnus-newsgroup-reads) ?d)
1707 (?E gnus-newsgroup-expunged-tally ?d)
1708 (?s (gnus-current-score-file-nondirectory) ?s)))
1710 (defvar gnus-article-mode-line-format-alist
1711 gnus-summary-mode-line-format-alist)
1713 (defvar gnus-group-mode-line-format-alist
1714 `((?S gnus-tmp-news-server ?s)
1715 (?M gnus-tmp-news-method ?s)
1716 (?u gnus-tmp-user-defined ?s)
1717 (?: gnus-tmp-colon ?s)))
1719 (defvar gnus-have-read-active-file nil)
1721 (defconst gnus-maintainer
1722 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1723 "The mail address of the Gnus maintainers.")
1725 (defconst gnus-version "September Gnus v0.91"
1726 "Version number for this version of Gnus.")
1728 (defvar gnus-info-nodes
1729 '((gnus-group-mode "(gnus)The Group Buffer")
1730 (gnus-summary-mode "(gnus)The Summary Buffer")
1731 (gnus-article-mode "(gnus)The Article Buffer"))
1732 "Assoc list of major modes and related Info nodes.")
1734 (defvar gnus-group-buffer "*Group*")
1735 (defvar gnus-summary-buffer "*Summary*")
1736 (defvar gnus-article-buffer "*Article*")
1737 (defvar gnus-server-buffer "*Server*")
1739 (defvar gnus-work-buffer " *gnus work*")
1741 (defvar gnus-original-article-buffer " *Original Article*")
1742 (defvar gnus-original-article nil)
1744 (defvar gnus-buffer-list nil
1745 "Gnus buffers that should be killed on exit.")
1747 (defvar gnus-slave nil
1748 "Whether this Gnus is a slave or not.")
1750 (defvar gnus-variable-list
1751 '(gnus-newsrc-options gnus-newsrc-options-n
1752 gnus-newsrc-last-checked-date
1753 gnus-newsrc-alist gnus-server-alist
1754 gnus-killed-list gnus-zombie-list
1755 gnus-topic-topology gnus-topic-alist
1757 "Gnus variables saved in the quick startup file.")
1759 (defvar gnus-newsrc-options nil
1760 "Options line in the .newsrc file.")
1762 (defvar gnus-newsrc-options-n nil
1763 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1765 (defvar gnus-newsrc-last-checked-date nil
1766 "Date Gnus last asked server for new newsgroups.")
1768 (defvar gnus-topic-topology nil
1769 "The complete topic hierarchy.")
1771 (defvar gnus-topic-alist nil
1772 "The complete topic-group alist.")
1774 (defvar gnus-newsrc-alist nil
1775 "Assoc list of read articles.
1776 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1778 (defvar gnus-newsrc-hashtb nil
1779 "Hashtable of gnus-newsrc-alist.")
1781 (defvar gnus-killed-list nil
1782 "List of killed newsgroups.")
1784 (defvar gnus-killed-hashtb nil
1785 "Hash table equivalent of gnus-killed-list.")
1787 (defvar gnus-zombie-list nil
1788 "List of almost dead newsgroups.")
1790 (defvar gnus-description-hashtb nil
1791 "Descriptions of newsgroups.")
1793 (defvar gnus-list-of-killed-groups nil
1794 "List of newsgroups that have recently been killed by the user.")
1796 (defvar gnus-active-hashtb nil
1797 "Hashtable of active articles.")
1799 (defvar gnus-moderated-list nil
1800 "List of moderated newsgroups.")
1802 (defvar gnus-group-marked nil)
1804 (defvar gnus-current-startup-file nil
1805 "Startup file for the current host.")
1807 (defvar gnus-last-search-regexp nil
1808 "Default regexp for article search command.")
1810 (defvar gnus-last-shell-command nil
1811 "Default shell command on article.")
1813 (defvar gnus-current-select-method nil
1814 "The current method for selecting a newsgroup.")
1816 (defvar gnus-group-list-mode nil)
1818 (defvar gnus-article-internal-prepare-hook nil)
1820 (defvar gnus-newsgroup-name nil)
1821 (defvar gnus-newsgroup-begin nil)
1822 (defvar gnus-newsgroup-end nil)
1823 (defvar gnus-newsgroup-last-rmail nil)
1824 (defvar gnus-newsgroup-last-mail nil)
1825 (defvar gnus-newsgroup-last-folder nil)
1826 (defvar gnus-newsgroup-last-file nil)
1827 (defvar gnus-newsgroup-auto-expire nil)
1828 (defvar gnus-newsgroup-active nil)
1830 (defvar gnus-newsgroup-data nil)
1831 (defvar gnus-newsgroup-data-reverse nil)
1832 (defvar gnus-newsgroup-limit nil)
1833 (defvar gnus-newsgroup-limits nil)
1835 (defvar gnus-newsgroup-unreads nil
1836 "List of unread articles in the current newsgroup.")
1838 (defvar gnus-newsgroup-unselected nil
1839 "List of unselected unread articles in the current newsgroup.")
1841 (defvar gnus-newsgroup-reads nil
1842 "Alist of read articles and article marks in the current newsgroup.")
1844 (defvar gnus-newsgroup-expunged-tally nil)
1846 (defvar gnus-newsgroup-marked nil
1847 "List of ticked articles in the current newsgroup (a subset of unread art).")
1849 (defvar gnus-newsgroup-killed nil
1850 "List of ranges of articles that have been through the scoring process.")
1852 (defvar gnus-newsgroup-cached nil
1853 "List of articles that come from the article cache.")
1855 (defvar gnus-newsgroup-saved nil
1856 "List of articles that have been saved.")
1858 (defvar gnus-newsgroup-kill-headers nil)
1860 (defvar gnus-newsgroup-replied nil
1861 "List of articles that have been replied to in the current newsgroup.")
1863 (defvar gnus-newsgroup-expirable nil
1864 "List of articles in the current newsgroup that can be expired.")
1866 (defvar gnus-newsgroup-processable nil
1867 "List of articles in the current newsgroup that can be processed.")
1869 (defvar gnus-newsgroup-bookmarks nil
1870 "List of articles in the current newsgroup that have bookmarks.")
1872 (defvar gnus-newsgroup-dormant nil
1873 "List of dormant articles in the current newsgroup.")
1875 (defvar gnus-newsgroup-scored nil
1876 "List of scored articles in the current newsgroup.")
1878 (defvar gnus-newsgroup-headers nil
1879 "List of article headers in the current newsgroup.")
1881 (defvar gnus-newsgroup-threads nil)
1883 (defvar gnus-newsgroup-prepared nil
1884 "Whether the current group has been prepared properly.")
1886 (defvar gnus-newsgroup-ancient nil
1887 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1889 (defvar gnus-newsgroup-sparse nil)
1891 (defvar gnus-current-article nil)
1892 (defvar gnus-article-current nil)
1893 (defvar gnus-current-headers nil)
1894 (defvar gnus-have-all-headers nil)
1895 (defvar gnus-last-article nil)
1896 (defvar gnus-newsgroup-history nil)
1897 (defvar gnus-current-kill-article nil)
1899 ;; Save window configuration.
1900 (defvar gnus-prev-winconf nil)
1902 (defvar gnus-summary-mark-positions nil)
1903 (defvar gnus-group-mark-positions nil)
1905 (defvar gnus-reffed-article-number nil)
1907 ;;; Let the byte-compiler know that we know about this variable.
1908 (defvar rmail-default-rmail-file)
1910 (defvar gnus-cache-removable-articles nil)
1912 (defvar gnus-dead-summary nil)
1914 (defconst gnus-summary-local-variables
1915 '(gnus-newsgroup-name
1916 gnus-newsgroup-begin gnus-newsgroup-end
1917 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1918 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1919 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1920 gnus-newsgroup-unselected gnus-newsgroup-marked
1921 gnus-newsgroup-reads gnus-newsgroup-saved
1922 gnus-newsgroup-replied gnus-newsgroup-expirable
1923 gnus-newsgroup-processable gnus-newsgroup-killed
1924 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1925 gnus-newsgroup-headers gnus-newsgroup-threads
1926 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1927 gnus-current-article gnus-current-headers gnus-have-all-headers
1928 gnus-last-article gnus-article-internal-prepare-hook
1929 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1930 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1931 gnus-newsgroup-async gnus-thread-expunge-below
1932 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1933 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1934 gnus-newsgroup-history gnus-newsgroup-ancient
1935 gnus-newsgroup-sparse
1936 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1937 gnus-newsgroup-adaptive-score-file
1938 (gnus-newsgroup-expunged-tally . 0)
1939 gnus-cache-removable-articles gnus-newsgroup-cached
1940 gnus-newsgroup-data gnus-newsgroup-data-reverse
1941 gnus-newsgroup-limit gnus-newsgroup-limits)
1942 "Variables that are buffer-local to the summary buffers.")
1944 (defconst gnus-bug-message
1945 "Sending a bug report to the Gnus Towers.
1946 ========================================
1948 The buffer below is a mail buffer. When you press `C-c C-c', it will
1949 be sent to the Gnus Bug Exterminators.
1951 At the bottom of the buffer you'll see lots of variable settings.
1952 Please do not delete those. They will tell the Bug People what your
1953 environment is, so that it will be easier to locate the bugs.
1955 If you have found a bug that makes Emacs go \"beep\", set
1956 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1957 and include the backtrace in your bug report.
1959 Please describe the bug in annoying, painstaking detail.
1961 Thank you for your help in stamping out bugs.
1964 ;;; End of variables.
1966 ;; Define some autoload functions Gnus might use.
1969 ;; This little mapcar goes through the list below and marks the
1970 ;; symbols in question as autoloaded functions.
1973 (let ((interactive (nth 1 (memq ':interactive package))))
1977 (when (consp function)
1978 (setq keymap (car (memq 'keymap function)))
1979 (setq function (car function)))
1980 (autoload function (car package) nil interactive keymap)))
1981 (if (eq (nth 1 package) ':interactive)
1984 '(("metamail" metamail-buffer)
1985 ("info" Info-goto-node)
1986 ("hexl" hexl-hex-string-to-integer)
1987 ("pp" pp pp-to-string pp-eval-expression)
1988 ("mail-extr" mail-extract-address-components)
1989 ("nnmail" nnmail-split-fancy nnmail-article-group)
1990 ("nnvirtual" nnvirtual-catchup-group)
1991 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1992 timezone-make-sortable-date timezone-make-time-string)
1993 ("sendmail" mail-position-on-field mail-setup)
1994 ("rmailout" rmail-output)
1995 ("rnewspost" news-mail-other-window news-reply-yank-original
1996 news-caesar-buffer-body)
1997 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1999 ("gnus-soup" :interactive t
2000 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2001 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2002 ("nnsoup" nnsoup-pack-replies)
2003 ("gnus-scomo" :interactive t gnus-score-mode)
2004 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2005 gnus-Folder-save-name gnus-folder-save-name)
2006 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2007 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2008 gnus-server-make-menu-bar gnus-article-make-menu-bar
2009 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2010 gnus-summary-highlight-line gnus-carpal-setup-buffer
2011 gnus-group-highlight-line
2012 gnus-article-add-button gnus-insert-next-page-button
2013 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2014 ("gnus-vis" :interactive t
2015 gnus-article-push-button gnus-article-press-button
2016 gnus-article-highlight gnus-article-highlight-some
2017 gnus-article-highlight-headers gnus-article-highlight-signature
2018 gnus-article-add-buttons gnus-article-add-buttons-to-head
2019 gnus-article-next-button gnus-article-prev-button)
2020 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2021 gnus-demon-add-disconnection gnus-demon-add-handler
2022 gnus-demon-remove-handler)
2023 ("gnus-demon" :interactive t
2024 gnus-demon-init gnus-demon-cancel)
2025 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2026 gnus-tree-open gnus-tree-close)
2027 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2028 gnus-nocem-unwanted-article-p)
2029 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2030 ("gnus-srvr" gnus-browse-foreign-server)
2031 ("gnus-cite" :interactive t
2032 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2033 gnus-article-hide-citation gnus-article-fill-cited-article
2034 gnus-article-hide-citation-in-followups)
2035 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2036 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2037 gnus-execute gnus-expunge)
2038 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2039 gnus-cache-possibly-remove-articles gnus-cache-request-article
2040 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2041 gnus-cache-enter-remove-article gnus-cached-article-p
2042 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2043 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2044 gnus-cache-remove-article)
2045 ("gnus-score" :interactive t
2046 gnus-summary-increase-score gnus-summary-lower-score
2047 gnus-score-flush-cache gnus-score-close
2048 gnus-score-raise-same-subject-and-select
2049 gnus-score-raise-same-subject gnus-score-default
2050 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2051 gnus-score-lower-same-subject gnus-score-lower-thread
2052 gnus-possibly-score-headers gnus-summary-raise-score
2053 gnus-summary-set-score gnus-summary-current-score)
2055 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2056 gnus-current-score-file-nondirectory gnus-score-adaptive
2057 gnus-score-find-trace gnus-score-file-name)
2058 ("gnus-edit" :interactive t gnus-score-customize)
2059 ("gnus-topic" :interactive t gnus-topic-mode)
2060 ("gnus-topic" gnus-topic-remove-group)
2061 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2062 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2063 ("gnus-uu" :interactive t
2064 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2065 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2066 gnus-uu-mark-by-regexp gnus-uu-mark-all
2067 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2068 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2069 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2070 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2071 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2072 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2073 gnus-uu-decode-binhex-view)
2074 ("gnus-msg" (gnus-summary-send-map keymap)
2075 gnus-mail-yank-original gnus-mail-send-and-exit
2076 gnus-sendmail-setup-mail gnus-article-mail
2077 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2078 ("gnus-msg" :interactive t
2079 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2080 gnus-summary-followup gnus-summary-followup-with-original
2081 gnus-summary-followup-and-reply
2082 gnus-summary-followup-and-reply-with-original
2083 gnus-summary-cancel-article gnus-summary-supersede-article
2084 gnus-post-news gnus-inews-news gnus-cancel-news
2085 gnus-summary-reply gnus-summary-reply-with-original
2086 gnus-summary-mail-forward gnus-summary-mail-other-window
2088 ("gnus-picon" :interactive t gnus-article-display-picons
2089 gnus-group-display-picons gnus-picons-article-display-x-face)
2090 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2091 gnus-grouplens-mode)
2092 ("gnus-vm" gnus-vm-mail-setup)
2093 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2094 gnus-summary-save-article-vm gnus-yank-article))))
2098 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2099 ;; If you want the cursor to go somewhere else, set these two
2100 ;; functions in some startup hook to whatever you want.
2101 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2102 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2104 ;;; Various macros and substs.
2106 (defun gnus-header-from (header)
2107 (mail-header-from header))
2109 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2110 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2111 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2112 (w (make-symbol "w"))
2113 (buf (make-symbol "buf")))
2114 `(let* ((,tempvar (selected-window))
2116 (,w (get-buffer-window ,buf 'visible)))
2121 (pop-to-buffer ,buf))
2123 (select-window ,tempvar)))))
2125 (defmacro gnus-gethash (string hashtable)
2126 "Get hash value of STRING in HASHTABLE."
2127 `(symbol-value (intern-soft ,string ,hashtable)))
2129 (defmacro gnus-sethash (string value hashtable)
2130 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2131 `(set (intern ,string ,hashtable) ,value))
2133 (defmacro gnus-intern-safe (string hashtable)
2134 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2135 `(let ((symbol (intern ,string ,hashtable)))
2140 (defmacro gnus-group-unread (group)
2141 "Get the currently computed number of unread articles in GROUP."
2142 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2144 (defmacro gnus-group-entry (group)
2145 "Get the newsrc entry for GROUP."
2146 `(gnus-gethash ,group gnus-newsrc-hashtb))
2148 (defmacro gnus-active (group)
2149 "Get active info on GROUP."
2150 `(gnus-gethash ,group gnus-active-hashtb))
2152 (defmacro gnus-set-active (group active)
2153 "Set GROUP's active info."
2154 `(gnus-sethash ,group ,active gnus-active-hashtb))
2156 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2157 ;; function `substring' might cut on a middle of multi-octet
2159 (defun gnus-truncate-string (str width)
2160 (substring str 0 width))
2162 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2163 ;; to limit the length of a string. This function is necessary since
2164 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2165 (defsubst gnus-limit-string (str width)
2166 (if (> (length str) width)
2167 (substring str 0 width)
2170 (defsubst gnus-simplify-subject-re (subject)
2171 "Remove \"Re:\" from subject lines."
2172 (if (string-match "^[Rr][Ee]: *" subject)
2173 (substring subject (match-end 0))
2176 (defsubst gnus-functionp (form)
2177 "Return non-nil if FORM is funcallable."
2178 (or (and (symbolp form) (fboundp form))
2179 (and (listp form) (eq (car form) 'lambda))))
2181 (defsubst gnus-goto-char (point)
2182 (and point (goto-char point)))
2184 (defmacro gnus-buffer-exists-p (buffer)
2185 `(let ((buffer ,buffer))
2187 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2190 (defmacro gnus-kill-buffer (buffer)
2191 `(let ((buf ,buffer))
2192 (if (gnus-buffer-exists-p buf)
2193 (kill-buffer buf))))
2195 (defsubst gnus-point-at-bol ()
2196 "Return point at the beginning of the line."
2203 (defsubst gnus-point-at-eol ()
2204 "Return point at the end of the line."
2211 (defun gnus-alive-p ()
2212 "Say whether Gnus is running or not."
2213 (and gnus-group-buffer
2214 (get-buffer gnus-group-buffer)))
2216 ;; Delete the current line (and the next N lines.);
2217 (defmacro gnus-delete-line (&optional n)
2218 `(delete-region (progn (beginning-of-line) (point))
2219 (progn (forward-line ,(or n 1)) (point))))
2221 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2222 (defvar gnus-init-inhibit nil)
2223 (defun gnus-read-init-file (&optional inhibit-next)
2224 (if gnus-init-inhibit
2225 (setq gnus-init-inhibit nil)
2226 (setq gnus-init-inhibit inhibit-next)
2228 (or (and (file-exists-p gnus-init-file)
2229 ;; Don't try to load a directory.
2230 (not (file-directory-p gnus-init-file)))
2231 (file-exists-p (concat gnus-init-file ".el"))
2232 (file-exists-p (concat gnus-init-file ".elc")))
2234 (load gnus-init-file nil t)
2236 (error "Error in %s: %s" gnus-init-file var))))))
2238 ;; Info access macros.
2240 (defmacro gnus-info-group (info)
2242 (defmacro gnus-info-rank (info)
2244 (defmacro gnus-info-read (info)
2246 (defmacro gnus-info-marks (info)
2248 (defmacro gnus-info-method (info)
2250 (defmacro gnus-info-params (info)
2253 (defmacro gnus-info-level (info)
2254 `(let ((rank (gnus-info-rank ,info)))
2258 (defmacro gnus-info-score (info)
2259 `(let ((rank (gnus-info-rank ,info)))
2260 (or (and (consp rank) (cdr rank)) 0)))
2262 (defmacro gnus-info-set-group (info group)
2263 `(setcar ,info ,group))
2264 (defmacro gnus-info-set-rank (info rank)
2265 `(setcar (nthcdr 1 ,info) ,rank))
2266 (defmacro gnus-info-set-read (info read)
2267 `(setcar (nthcdr 2 ,info) ,read))
2268 (defmacro gnus-info-set-marks (info marks)
2269 `(setcar (nthcdr 3 ,info) ,marks))
2270 (defmacro gnus-info-set-method (info method)
2271 `(setcar (nthcdr 4 ,info) ,method))
2272 (defmacro gnus-info-set-params (info params)
2273 `(setcar (nthcdr 5 ,info) ,params))
2275 (defmacro gnus-info-set-level (info level)
2276 `(let ((rank (cdr ,info)))
2277 (if (consp (car rank))
2278 (setcar (car rank) ,level)
2279 (setcar rank ,level))))
2280 (defmacro gnus-info-set-score (info score)
2281 `(let ((rank (cdr ,info)))
2282 (if (consp (car rank))
2283 (setcdr (car rank) ,score)
2284 (setcar rank (cons (car rank) ,score)))))
2286 (defmacro gnus-get-info (group)
2287 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2289 (defun gnus-byte-code (func)
2290 "Return a form that can be `eval'ed based on FUNC."
2291 (let ((fval (symbol-function func)))
2292 (if (byte-code-function-p fval)
2293 (let ((flist (append fval nil)))
2294 (setcar flist 'byte-code)
2296 (cons 'progn (cddr fval)))))
2298 ;;; Load the compatability functions.
2308 (defvar gnus-shutdown-alist nil)
2310 (defun gnus-add-shutdown (function &rest symbols)
2311 "Run FUNCTION whenever one of SYMBOLS is shut down."
2312 (push (cons function symbols) gnus-shutdown-alist))
2314 (defun gnus-shutdown (symbol)
2315 "Shut down everything that waits for SYMBOL."
2316 (let ((alist gnus-shutdown-alist)
2318 (while (setq entry (pop alist))
2319 (when (memq symbol (cdr entry))
2320 (funcall (car entry))))))
2324 ;; Format specs. The chunks below are the machine-generated forms
2325 ;; that are to be evaled as the result of the default format strings.
2326 ;; We write them in here to get them byte-compiled. That way the
2327 ;; default actions will be quite fast, while still retaining the full
2328 ;; flexibility of the user-defined format specs.
2330 ;; First we have lots of dummy defvars to let the compiler know these
2331 ;; are really dynamic variables.
2333 (defvar gnus-tmp-unread)
2334 (defvar gnus-tmp-replied)
2335 (defvar gnus-tmp-score-char)
2336 (defvar gnus-tmp-indentation)
2337 (defvar gnus-tmp-opening-bracket)
2338 (defvar gnus-tmp-lines)
2339 (defvar gnus-tmp-name)
2340 (defvar gnus-tmp-closing-bracket)
2341 (defvar gnus-tmp-subject-or-nil)
2342 (defvar gnus-tmp-subject)
2343 (defvar gnus-tmp-marked)
2344 (defvar gnus-tmp-marked-mark)
2345 (defvar gnus-tmp-subscribed)
2346 (defvar gnus-tmp-process-marked)
2347 (defvar gnus-tmp-number-of-unread)
2348 (defvar gnus-tmp-group-name)
2349 (defvar gnus-tmp-group)
2350 (defvar gnus-tmp-article-number)
2351 (defvar gnus-tmp-unread-and-unselected)
2352 (defvar gnus-tmp-news-method)
2353 (defvar gnus-tmp-news-server)
2354 (defvar gnus-tmp-article-number)
2355 (defvar gnus-mouse-face)
2356 (defvar gnus-mouse-face-prop)
2358 (defun gnus-summary-line-format-spec ()
2359 (insert gnus-tmp-unread gnus-tmp-replied
2360 gnus-tmp-score-char gnus-tmp-indentation)
2361 (gnus-put-text-property
2365 gnus-tmp-opening-bracket
2366 (format "%4d: %-20s"
2368 (if (> (length gnus-tmp-name) 20)
2369 (substring gnus-tmp-name 0 20)
2371 gnus-tmp-closing-bracket)
2373 gnus-mouse-face-prop gnus-mouse-face)
2374 (insert " " gnus-tmp-subject-or-nil "\n"))
2376 (defvar gnus-summary-line-format-spec
2377 (gnus-byte-code 'gnus-summary-line-format-spec))
2379 (defun gnus-summary-dummy-line-format-spec ()
2381 (gnus-put-text-property
2386 gnus-mouse-face-prop gnus-mouse-face)
2387 (insert " " gnus-tmp-subject "\n"))
2389 (defvar gnus-summary-dummy-line-format-spec
2390 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2392 (defun gnus-group-line-format-spec ()
2393 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2394 gnus-tmp-process-marked
2395 gnus-group-indentation
2396 (format "%5s: " gnus-tmp-number-of-unread))
2397 (gnus-put-text-property
2400 (insert gnus-tmp-group "\n")
2402 gnus-mouse-face-prop gnus-mouse-face))
2403 (defvar gnus-group-line-format-spec
2404 (gnus-byte-code 'gnus-group-line-format-spec))
2406 (defvar gnus-format-specs
2407 `((version . ,emacs-version)
2408 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2409 (summary-dummy ,gnus-summary-dummy-line-format
2410 ,gnus-summary-dummy-line-format-spec)
2411 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2413 (defvar gnus-article-mode-line-format-spec nil)
2414 (defvar gnus-summary-mode-line-format-spec nil)
2415 (defvar gnus-group-mode-line-format-spec nil)
2417 ;;; Phew. All that gruft is over, fortunately.
2421 ;;; Gnus Utility Functions
2424 (defun gnus-extract-address-components (from)
2426 ;; First find the address - the thing with the @ in it. This may
2427 ;; not be accurate in mail addresses, but does the trick most of
2428 ;; the time in news messages.
2429 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2430 (setq address (substring from (match-beginning 0) (match-end 0))))
2431 ;; Then we check whether the "name <address>" format is used.
2433 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2434 ;; Linear white space is not required.
2435 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2436 (and (setq name (substring from 0 (match-beginning 0)))
2437 ;; Strip any quotes from the name.
2438 (string-match "\".*\"" name)
2439 (setq name (substring name 1 (1- (match-end 0))))))
2440 ;; If not, then "address (name)" is used.
2442 (and (string-match "(.+)" from)
2443 (setq name (substring from (1+ (match-beginning 0))
2444 (1- (match-end 0)))))
2445 (and (string-match "()" from)
2446 (setq name address))
2447 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2448 ;; XOVER might not support folded From headers.
2449 (and (string-match "(.*" from)
2450 (setq name (substring from (1+ (match-beginning 0))
2452 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2453 (list (or name from) (or address from))))
2455 (defun gnus-fetch-field (field)
2456 "Return the value of the header FIELD of current article."
2459 (let ((case-fold-search t)
2460 (inhibit-point-motion-hooks t))
2461 (nnheader-narrow-to-headers)
2462 (message-fetch-field field)))))
2464 (defun gnus-goto-colon ()
2466 (search-forward ":" (gnus-point-at-eol) t))
2469 (defun gnus-update-format (var)
2470 "Update the format specification near point."
2475 ;; Find the end of the current word.
2476 (re-search-forward "[ \t\n]" nil t)
2478 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2479 (match-string 1)))))
2480 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2481 (match-string 1 var))))
2482 (entry (assq type gnus-format-specs))
2485 (setq gnus-format-specs (delq entry gnus-format-specs)))
2487 (intern (format "%s-spec" var))
2488 (gnus-parse-format (setq value (symbol-value (intern var)))
2489 (symbol-value (intern (format "%s-alist" var)))
2490 (not (string-match "mode" var))))
2491 (setq spec (symbol-value (intern (format "%s-spec" var))))
2492 (push (list type value spec) gnus-format-specs)
2494 (pop-to-buffer "*Gnus Format*")
2496 (lisp-interaction-mode)
2497 (insert (pp-to-string spec))))
2499 (defun gnus-update-format-specifications (&optional force)
2500 "Update all (necessary) format specifications."
2501 ;; Make the indentation array.
2502 (gnus-make-thread-indent-array)
2504 ;; See whether all the stored info needs to be flushed.
2506 (not (equal emacs-version
2507 (cdr (assq 'version gnus-format-specs)))))
2508 (setq gnus-format-specs nil))
2510 ;; Go through all the formats and see whether they need updating.
2511 (let ((types '(summary summary-dummy group
2512 summary-mode group-mode article-mode))
2513 new-format entry type val)
2514 (while (setq type (pop types))
2515 ;; Jump to the proper buffer to find out the value of
2516 ;; the variable, if possible. (It may be buffer-local.)
2518 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2520 (when (and (boundp buffer)
2521 (setq val (symbol-value buffer))
2523 (buffer-name (get-buffer val)))
2524 (set-buffer (get-buffer val)))
2525 (setq new-format (symbol-value
2526 (intern (format "gnus-%s-line-format" type))))))
2527 (setq entry (cdr (assq type gnus-format-specs)))
2529 (equal (car entry) new-format))
2530 ;; Use the old format.
2531 (set (intern (format "gnus-%s-line-format-spec" type))
2533 ;; This is a new format.
2535 (if (not (stringp new-format))
2536 ;; This is a function call or something.
2538 ;; This is a "real" format.
2542 (intern (format "gnus-%s-line-format-alist"
2543 (if (eq type 'article-mode)
2544 'summary-mode type))))
2545 (not (string-match "mode$" (symbol-name type))))))
2546 ;; Enter the new format spec into the list.
2549 (setcar (cdr entry) val)
2550 (setcar entry new-format))
2551 (push (list type new-format val) gnus-format-specs))
2552 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2554 (unless (assq 'version gnus-format-specs)
2555 (push (cons 'version emacs-version) gnus-format-specs))
2557 (gnus-update-group-mark-positions)
2558 (gnus-update-summary-mark-positions))
2560 (defun gnus-update-summary-mark-positions ()
2561 "Compute where the summary marks are to go."
2563 (when (and gnus-summary-buffer
2564 (get-buffer gnus-summary-buffer)
2565 (buffer-name (get-buffer gnus-summary-buffer)))
2566 (set-buffer gnus-summary-buffer))
2567 (let ((gnus-replied-mark 129)
2568 (gnus-score-below-mark 130)
2569 (gnus-score-over-mark 130)
2572 (spec gnus-summary-line-format-spec)
2575 (gnus-set-work-buffer)
2576 (let ((gnus-summary-line-format-spec spec))
2577 (gnus-summary-insert-line
2578 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2579 (goto-char (point-min))
2580 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2582 (goto-char (point-min))
2583 (push (cons 'replied (and (search-forward "\201" nil t)
2586 (goto-char (point-min))
2587 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2589 (setq gnus-summary-mark-positions pos))))
2591 (defun gnus-update-group-mark-positions ()
2593 (let ((gnus-process-mark 128)
2594 (gnus-group-marked '("dummy.group"))
2595 (gnus-active-hashtb (make-vector 10 0)))
2596 (gnus-set-active "dummy.group" '(0 . 0))
2597 (gnus-set-work-buffer)
2598 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2599 (goto-char (point-min))
2600 (setq gnus-group-mark-positions
2601 (list (cons 'process (and (search-forward "\200" nil t)
2602 (- (point) 2))))))))
2604 (defvar gnus-mouse-face-0 'highlight)
2605 (defvar gnus-mouse-face-1 'highlight)
2606 (defvar gnus-mouse-face-2 'highlight)
2607 (defvar gnus-mouse-face-3 'highlight)
2608 (defvar gnus-mouse-face-4 'highlight)
2610 (defun gnus-mouse-face-function (form type)
2611 `(gnus-put-text-property
2612 (point) (progn ,@form (point))
2613 gnus-mouse-face-prop
2616 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2618 (defvar gnus-face-0 'bold)
2619 (defvar gnus-face-1 'italic)
2620 (defvar gnus-face-2 'bold-italic)
2621 (defvar gnus-face-3 'bold)
2622 (defvar gnus-face-4 'bold)
2624 (defun gnus-face-face-function (form type)
2625 `(gnus-put-text-property
2626 (point) (progn ,@form (point))
2627 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2629 (defun gnus-max-width-function (el max-width)
2630 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2632 `(if (> (length ,el) ,max-width)
2633 (substring ,el 0 ,max-width)
2635 `(let ((val (eval ,el)))
2637 (setq val (int-to-string val)))
2638 (if (> (length val) ,max-width)
2639 (substring val 0 ,max-width)
2642 (defun gnus-parse-format (format spec-alist &optional insert)
2643 ;; This function parses the FORMAT string with the help of the
2644 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2645 ;; string. If the FORMAT string contains the specifiers %( and %)
2646 ;; the text between them will have the mouse-face text property.
2648 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2650 (gnus-parse-complex-format format spec-alist)
2651 ;; This is a simple format.
2652 (gnus-parse-simple-format format spec-alist insert)))
2654 (defun gnus-parse-complex-format (format spec-alist)
2656 (gnus-set-work-buffer)
2658 (goto-char (point-min))
2659 (while (re-search-forward "\"" nil t)
2660 (replace-match "\\\"" nil t))
2661 (goto-char (point-min))
2663 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2664 (let ((number (if (match-beginning 1)
2665 (match-string 1) "0"))
2666 (delim (aref (match-string 2) 0)))
2667 (if (or (= delim ?\() (= delim ?\{))
2668 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2670 (replace-match "\")\""))))
2671 (goto-char (point-max))
2673 (goto-char (point-min))
2674 (let ((form (read (current-buffer))))
2675 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2677 (defun gnus-complex-form-to-spec (form spec-alist)
2682 (gnus-parse-simple-format sform spec-alist t)
2683 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2684 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2688 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2689 ;; This function parses the FORMAT string with the help of the
2690 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2693 spec flist fstring newspec elem beg result dontinsert)
2695 (gnus-set-work-buffer)
2697 (goto-char (point-min))
2698 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2700 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2702 beg (1+ (match-beginning 0)))
2703 ;; First check if there are any specs that look anything like
2704 ;; "%12,12A", ie. with a "max width specification". These have
2705 ;; to be treated specially.
2706 (if (setq beg (match-beginning 1))
2710 (1+ (match-beginning 1)) (match-end 1))))
2712 (setq beg (match-beginning 2)))
2713 ;; Find the specification from `spec-alist'.
2714 (unless (setq elem (cdr (assq spec spec-alist)))
2715 (setq elem '("*" ?s)))
2716 ;; Treat user defined format specifiers specially.
2717 (when (eq (car elem) 'gnus-tmp-user-defined)
2720 (list (intern (concat "gnus-user-format-function-"
2722 'gnus-tmp-header) ?s))
2723 (delete-region (match-beginning 3) (match-end 3)))
2724 (if (not (zerop max-width))
2725 (let ((el (car elem)))
2726 (cond ((= (cadr elem) ?c)
2727 (setq el (list 'char-to-string el)))
2729 (setq el (list 'int-to-string el))))
2730 (setq flist (cons (gnus-max-width-function el max-width)
2734 (setq flist (cons (car elem) flist))
2735 (setq newspec (cadr elem)))))
2736 ;; Remove the old specification (and possibly a ",12" string).
2737 (delete-region beg (match-end 2))
2738 ;; Insert the new specification.
2741 (setq fstring (buffer-substring 1 (point-max))))
2742 ;; Do some postprocessing to increase efficiency.
2747 ((string= fstring "")
2749 ;; Not a format string.
2750 ((not (string-match "%" fstring))
2752 ;; A format string with just a single string spec.
2753 ((string= fstring "%s")
2755 ;; A single character.
2756 ((string= fstring "%c")
2759 ((string= fstring "%d")
2762 (list `(princ ,(car flist)))
2763 (list `(int-to-string ,(car flist)))))
2764 ;; Just lots of chars and strings.
2765 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2767 ;; A single string spec at the beginning of the spec.
2768 ((string-match "\\`%[sc][^%]+\\'" fstring)
2769 (list (car flist) (substring fstring 2)))
2770 ;; A single string spec in the middle of the spec.
2771 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2772 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2773 ;; A single string spec in the end of the spec.
2774 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2775 (list (match-string 1 fstring) (car flist)))
2776 ;; A more complex spec.
2778 (list (cons 'format (cons fstring (nreverse flist)))))))
2784 (cons 'insert result)))
2785 (cond ((stringp result)
2788 (cons 'concat result))
2791 (defun gnus-eval-format (format &optional alist props)
2792 "Eval the format variable FORMAT, using ALIST.
2793 If PROPS, insert the result."
2794 (let ((form (gnus-parse-format format alist props)))
2796 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2799 (defun gnus-remove-text-with-property (prop)
2800 "Delete all text in the current buffer with text property PROP."
2802 (goto-char (point-min))
2804 (while (get-text-property (point) prop)
2806 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2808 (defun gnus-set-work-buffer ()
2809 (if (get-buffer gnus-work-buffer)
2811 (set-buffer gnus-work-buffer)
2813 (set-buffer (get-buffer-create gnus-work-buffer))
2814 (kill-all-local-variables)
2815 (buffer-disable-undo (current-buffer))
2816 (gnus-add-current-to-buffer-list)))
2818 ;; Article file names when saving.
2820 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2821 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2822 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2823 Otherwise, it is like ~/News/news/group/num."
2826 (concat (if (gnus-use-long-file-name 'not-save)
2827 (gnus-capitalize-newsgroup newsgroup)
2828 (gnus-newsgroup-directory-form newsgroup))
2829 "/" (int-to-string (mail-header-number headers)))
2830 gnus-article-save-directory)))
2832 (string-equal (file-name-directory default)
2833 (file-name-directory last-file))
2834 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2836 (or last-file default))))
2838 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2839 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2840 If variable `gnus-use-long-file-name' is non-nil, it is
2841 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2844 (concat (if (gnus-use-long-file-name 'not-save)
2846 (gnus-newsgroup-directory-form newsgroup))
2847 "/" (int-to-string (mail-header-number headers)))
2848 gnus-article-save-directory)))
2850 (string-equal (file-name-directory default)
2851 (file-name-directory last-file))
2852 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2854 (or last-file default))))
2856 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2857 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2858 If variable `gnus-use-long-file-name' is non-nil, it is
2859 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2862 (if (gnus-use-long-file-name 'not-save)
2863 (gnus-capitalize-newsgroup newsgroup)
2864 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2865 gnus-article-save-directory)))
2867 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2868 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2869 If variable `gnus-use-long-file-name' is non-nil, it is
2870 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2873 (if (gnus-use-long-file-name 'not-save)
2875 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2876 gnus-article-save-directory)))
2878 ;; For subscribing new newsgroup
2880 (defun gnus-subscribe-hierarchical-interactive (groups)
2881 (let ((groups (sort groups 'string<))
2882 prefixes prefix start ans group starts)
2884 (setq prefixes (list "^"))
2885 (while (and groups prefixes)
2886 (while (not (string-match (car prefixes) (car groups)))
2887 (setq prefixes (cdr prefixes)))
2888 (setq prefix (car prefixes))
2889 (setq start (1- (length prefix)))
2890 (if (and (string-match "[^\\.]\\." (car groups) start)
2893 (concat "^" (substring (car groups) 0 (match-end 0))))
2894 (string-match prefix (cadr groups)))
2896 (setq prefixes (cons prefix prefixes))
2897 (message "Descend hierarchy %s? ([y]nsq): "
2898 (substring prefix 1 (1- (length prefix))))
2899 (setq ans (read-char))
2902 (string-match prefix
2903 (setq group (car groups))))
2904 (setq gnus-killed-list
2905 (cons group gnus-killed-list))
2906 (gnus-sethash group group gnus-killed-hashtb)
2907 (setq groups (cdr groups)))
2908 (setq starts (cdr starts)))
2911 (string-match prefix
2912 (setq group (car groups))))
2913 (gnus-sethash group group gnus-killed-hashtb)
2914 (gnus-subscribe-alphabetically (car groups))
2915 (setq groups (cdr groups)))
2916 (setq starts (cdr starts)))
2919 (setq group (car groups))
2920 (setq gnus-killed-list (cons group gnus-killed-list))
2921 (gnus-sethash group group gnus-killed-hashtb)
2922 (setq groups (cdr groups))))
2924 (message "Subscribe %s? ([n]yq)" (car groups))
2925 (setq ans (read-char))
2926 (setq group (car groups))
2928 (gnus-subscribe-alphabetically (car groups))
2929 (gnus-sethash group group gnus-killed-hashtb))
2932 (setq group (car groups))
2933 (setq gnus-killed-list (cons group gnus-killed-list))
2934 (gnus-sethash group group gnus-killed-hashtb)
2935 (setq groups (cdr groups))))
2937 (setq gnus-killed-list (cons group gnus-killed-list))
2938 (gnus-sethash group group gnus-killed-hashtb)))
2939 (setq groups (cdr groups)))))))
2941 (defun gnus-subscribe-randomly (newsgroup)
2942 "Subscribe new NEWSGROUP by making it the first newsgroup."
2943 (gnus-subscribe-newsgroup newsgroup))
2945 (defun gnus-subscribe-alphabetically (newgroup)
2946 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2947 (let ((groups (cdr gnus-newsrc-alist))
2949 (while (and (not before) groups)
2950 (if (string< newgroup (caar groups))
2951 (setq before (caar groups))
2952 (setq groups (cdr groups))))
2953 (gnus-subscribe-newsgroup newgroup before)))
2955 (defun gnus-subscribe-hierarchically (newgroup)
2956 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2957 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2959 (set-buffer (find-file-noselect gnus-current-startup-file))
2960 (let ((groupkey newgroup)
2962 (while (and (not before) groupkey)
2963 (goto-char (point-min))
2965 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2966 (while (and (re-search-forward groupkey-re nil t)
2968 (setq before (match-string 1))
2969 (string< before newgroup)))))
2970 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2972 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2973 (substring groupkey (match-beginning 1) (match-end 1)))))
2974 (gnus-subscribe-newsgroup newgroup before))))
2976 (defun gnus-subscribe-interactively (group)
2977 "Subscribe the new GROUP interactively.
2978 It is inserted in hierarchical newsgroup order if subscribed. If not,
2980 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2981 (gnus-subscribe-hierarchically group)
2982 (push group gnus-killed-list)))
2984 (defun gnus-subscribe-zombies (group)
2985 "Make the new GROUP into a zombie group."
2986 (push group gnus-zombie-list))
2988 (defun gnus-subscribe-killed (group)
2989 "Make the new GROUP a killed group."
2990 (push group gnus-killed-list))
2992 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2993 "Subscribe new NEWSGROUP.
2994 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2995 the first newsgroup."
2996 ;; We subscribe the group by changing its level to `subscribed'.
2997 (gnus-group-change-level
2998 newsgroup gnus-level-default-subscribed
2999 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3000 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3004 (defun gnus-newsgroup-directory-form (newsgroup)
3005 "Make hierarchical directory name from NEWSGROUP name."
3006 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3007 (len (length newsgroup))
3009 ;; If this is a foreign group, we don't want to translate the
3011 (if (setq idx (string-match ":" newsgroup))
3012 (aset newsgroup idx ?/)
3014 ;; Replace all occurrences of `.' with `/'.
3016 (if (= (aref newsgroup idx) ?.)
3017 (aset newsgroup idx ?/))
3018 (setq idx (1+ idx)))
3021 (defun gnus-newsgroup-savable-name (group)
3022 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3024 (nnheader-replace-chars-in-string group ?/ ?.))
3026 (defun gnus-make-directory (dir)
3027 "Make DIRECTORY recursively."
3028 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3029 ;; of the many mysteries of the universe.
3030 (let* ((dir (expand-file-name dir default-directory))
3032 (if (string-match "/$" dir)
3033 (setq dir (substring dir 0 (match-beginning 0))))
3034 ;; First go down the path until we find a directory that exists.
3035 (while (not (file-exists-p dir))
3036 (setq dirs (cons dir dirs))
3037 (string-match "/[^/]+$" dir)
3038 (setq dir (substring dir 0 (match-beginning 0))))
3039 ;; Then create all the subdirs.
3040 (while (and dirs (not err))
3042 (make-directory (car dirs))
3043 (error (setq err t)))
3044 (setq dirs (cdr dirs)))
3045 ;; We return whether we were successful or not.
3048 (defun gnus-capitalize-newsgroup (newsgroup)
3049 "Capitalize NEWSGROUP name."
3050 (and (not (zerop (length newsgroup)))
3051 (concat (char-to-string (upcase (aref newsgroup 0)))
3052 (substring newsgroup 1))))
3054 ;; Various... things.
3056 (defun gnus-simplify-subject (subject &optional re-only)
3057 "Remove `Re:' and words in parentheses.
3058 If RE-ONLY is non-nil, strip leading `Re:'s only."
3059 (let ((case-fold-search t)) ;Ignore case.
3060 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3061 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3062 (setq subject (substring subject (match-end 0))))
3063 ;; Remove uninteresting prefixes.
3064 (if (and (not re-only)
3065 gnus-simplify-ignored-prefixes
3066 (string-match gnus-simplify-ignored-prefixes subject))
3067 (setq subject (substring subject (match-end 0))))
3068 ;; Remove words in parentheses from end.
3070 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3071 (setq subject (substring subject 0 (match-beginning 0)))))
3072 ;; Return subject string.
3075 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3077 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3078 (defun gnus-simplify-buffer-fuzzy ()
3079 (goto-char (point-min))
3080 (while (search-forward "\t" nil t)
3081 (replace-match " " t t))
3082 (goto-char (point-min))
3083 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3084 (goto-char (match-beginning 0))
3086 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3087 (looking-at "^[[].*: .*[]]$"))
3088 (goto-char (point-min))
3089 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3091 (replace-match "" t t))
3092 (goto-char (point-min))
3093 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3094 (goto-char (match-end 0))
3097 (progn (goto-char (match-beginning 0)))
3098 (re-search-forward ":"))))
3099 (goto-char (point-min))
3100 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3101 (replace-match "" t t))
3102 (goto-char (point-min))
3103 (while (re-search-forward " +" nil t)
3104 (replace-match " " t t))
3105 (goto-char (point-min))
3106 (while (re-search-forward " $" nil t)
3107 (replace-match "" t t))
3108 (goto-char (point-min))
3109 (while (re-search-forward "^ +" nil t)
3110 (replace-match "" t t))
3111 (goto-char (point-min))
3112 (when gnus-simplify-subject-fuzzy-regexp
3113 (if (listp gnus-simplify-subject-fuzzy-regexp)
3114 (let ((list gnus-simplify-subject-fuzzy-regexp))
3116 (goto-char (point-min))
3117 (while (re-search-forward (car list) nil t)
3118 (replace-match "" t t))
3119 (setq list (cdr list))))
3120 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3121 (replace-match "" t t)))))
3123 (defun gnus-simplify-subject-fuzzy (subject)
3124 "Siplify a subject string fuzzily."
3126 (gnus-set-work-buffer)
3127 (let ((case-fold-search t))
3129 (inline (gnus-simplify-buffer-fuzzy))
3132 ;; Add the current buffer to the list of buffers to be killed on exit.
3133 (defun gnus-add-current-to-buffer-list ()
3134 (or (memq (current-buffer) gnus-buffer-list)
3135 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3137 (defun gnus-string> (s1 s2)
3138 (not (or (string< s1 s2)
3141 (defun gnus-read-active-file-p ()
3142 "Say whether the active file has been read from `gnus-select-method'."
3143 (memq gnus-select-method gnus-have-read-active-file))
3145 ;;; General various misc type functions.
3147 (defun gnus-clear-system ()
3148 "Clear all variables and buffers."
3149 ;; Clear Gnus variables.
3150 (let ((variables gnus-variable-list))
3152 (set (car variables) nil)
3153 (setq variables (cdr variables))))
3154 ;; Clear other internal variables.
3155 (setq gnus-list-of-killed-groups nil
3156 gnus-have-read-active-file nil
3157 gnus-newsrc-alist nil
3158 gnus-newsrc-hashtb nil
3159 gnus-killed-list nil
3160 gnus-zombie-list nil
3161 gnus-killed-hashtb nil
3162 gnus-active-hashtb nil
3163 gnus-moderated-list nil
3164 gnus-description-hashtb nil
3165 gnus-current-headers nil
3166 gnus-thread-indent-array nil
3167 gnus-newsgroup-headers nil
3168 gnus-newsgroup-name nil
3169 gnus-server-alist nil
3170 gnus-group-list-mode nil
3171 gnus-opened-servers nil
3172 gnus-current-select-method nil)
3173 (gnus-shutdown 'gnus)
3174 ;; Kill the startup file.
3175 (and gnus-current-startup-file
3176 (get-file-buffer gnus-current-startup-file)
3177 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3178 ;; Clear the dribble buffer.
3179 (gnus-dribble-clear)
3180 ;; Kill global KILL file buffer.
3181 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3182 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3183 (gnus-kill-buffer nntp-server-buffer)
3184 ;; Kill Gnus buffers.
3185 (while gnus-buffer-list
3186 (gnus-kill-buffer (pop gnus-buffer-list)))
3187 ;; Remove Gnus frames.
3188 (while gnus-created-frames
3189 (when (frame-live-p (car gnus-created-frames))
3190 ;; We slap a condition-case around this `delete-frame' to ensure
3191 ;; agains errors if we try do delete the single frame that's left.
3193 (delete-frame (car gnus-created-frames))
3195 (pop gnus-created-frames)))
3197 (defun gnus-windows-old-to-new (setting)
3198 ;; First we take care of the really, really old Gnus 3 actions.
3199 (when (symbolp setting)
3201 ;; Take care of ooold GNUS 3.x values.
3202 (cond ((eq setting 'SelectArticle) 'article)
3203 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3204 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3206 (if (or (listp setting)
3207 (not (and gnus-window-configuration
3208 (memq setting '(group summary article)))))
3210 (let* ((setting (if (eq setting 'group)
3211 (if (assq 'newsgroup gnus-window-configuration)
3213 'newsgroups) setting))
3214 (elem (cadr (assq setting gnus-window-configuration)))
3215 (total (apply '+ elem))
3216 (types '(group summary article))
3217 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3222 (or (not (numberp (nth i elem)))
3223 (zerop (nth i elem))
3225 (setq perc (/ (float (nth 0 elem)) total))
3226 (setq out (cons (if (eq pbuf (nth i types))
3227 (vector (nth i types) perc 'point)
3228 (vector (nth i types) perc))
3231 (list (nreverse out)))))
3234 (defun gnus-add-configuration (conf)
3235 "Add the window configuration CONF to `gnus-buffer-configuration'."
3236 (setq gnus-buffer-configuration
3237 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3238 gnus-buffer-configuration))))
3240 (defvar gnus-frame-list nil)
3242 (defun gnus-configure-frame (split &optional window)
3243 "Split WINDOW according to SPLIT."
3245 (setq window (get-buffer-window (current-buffer))))
3246 (select-window window)
3247 ;; This might be an old-stylee buffer config.
3248 (when (vectorp split)
3249 (setq split (append split nil)))
3250 (when (or (consp (car split))
3251 (vectorp (car split)))
3253 (push 'vertical split))
3254 ;; The SPLIT might be something that is to be evaled to
3255 ;; return a new SPLIT.
3256 (while (and (not (assq (car split) gnus-window-to-buffer))
3257 (gnus-functionp (car split)))
3258 (setq split (eval split)))
3259 (let* ((type (car split))
3261 (len (if (eq type 'horizontal) (window-width) (window-height)))
3263 (window-min-width (or gnus-window-min-width window-min-width))
3264 (window-min-height (or gnus-window-min-height window-min-height))
3265 s result new-win rest comp-subs size sub)
3267 ;; Nothing to do here.
3269 ;; Don't switch buffers.
3271 (and (memq 'point split) window))
3272 ;; This is a buffer to be selected.
3273 ((not (memq type '(frame horizontal vertical)))
3274 (let ((buffer (cond ((stringp type) type)
3275 (t (cdr (assq type gnus-window-to-buffer)))))
3278 (error "Illegal buffer type: %s" type))
3279 (unless (setq buf (get-buffer (if (symbolp buffer)
3280 (symbol-value buffer) buffer)))
3281 (setq buf (get-buffer-create (if (symbolp buffer)
3282 (symbol-value buffer) buffer))))
3283 (switch-to-buffer buf)
3284 ;; We return the window if it has the `point' spec.
3285 (and (memq 'point split) window)))
3286 ;; This is a frame split.
3288 (unless gnus-frame-list
3289 (setq gnus-frame-list (list (window-frame
3290 (get-buffer-window (current-buffer))))))
3292 params frame fresult)
3293 (while (< i (length subs))
3294 ;; Frame parameter is gotten from the sub-split.
3295 (setq params (cadr (elt subs i)))
3296 ;; It should be a list.
3297 (unless (listp params)
3299 ;; Create a new frame?
3300 (unless (setq frame (elt gnus-frame-list i))
3301 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3302 (push frame gnus-created-frames))
3303 ;; Is the old frame still alive?
3304 (unless (frame-live-p frame)
3305 (setcar (nthcdr i gnus-frame-list)
3306 (setq frame (make-frame params))))
3307 ;; Select the frame in question and do more splits there.
3308 (select-frame frame)
3309 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3311 ;; Select the frame that has the selected buffer.
3313 (select-frame (window-frame fresult)))))
3314 ;; This is a normal split.
3316 (when (> (length subs) 0)
3317 ;; First we have to compute the sizes of all new windows.
3319 (setq sub (append (pop subs) nil))
3320 (while (and (not (assq (car sub) gnus-window-to-buffer))
3321 (gnus-functionp (car sub)))
3322 (setq sub (eval sub)))
3324 (push sub comp-subs)
3325 (setq size (cadar comp-subs))
3326 (cond ((equal size 1.0)
3327 (setq rest (car comp-subs))
3330 (setq s (floor (* size len))))
3334 (error "Illegal size: %s" size)))
3335 ;; Try to make sure that we are inside the safe limits.
3337 ((eq type 'horizontal)
3338 (setq s (max s window-min-width)))
3339 ((eq type 'vertical)
3340 (setq s (max s window-min-height))))
3341 (setcar (cdar comp-subs) s)
3343 ;; Take care of the "1.0" spec.
3345 (setcar (cdr rest) (- len total))
3346 (error "No 1.0 specs in %s" split))
3347 ;; The we do the actual splitting in a nice recursive
3349 (setq comp-subs (nreverse comp-subs))
3351 (if (null (cdr comp-subs))
3352 (setq new-win window)
3354 (split-window window (cadar comp-subs)
3355 (eq type 'horizontal))))
3356 (setq result (or (gnus-configure-frame
3357 (car comp-subs) window) result))
3358 (select-window new-win)
3359 (setq window new-win)
3360 (setq comp-subs (cdr comp-subs))))
3361 ;; Return the proper window, if any.
3363 (select-window result))))))
3365 (defvar gnus-frame-split-p nil)
3367 (defun gnus-configure-windows (setting &optional force)
3368 (setq setting (gnus-windows-old-to-new setting))
3369 (let ((split (if (symbolp setting)
3370 (cadr (assq setting gnus-buffer-configuration))
3374 (setq gnus-frame-split-p nil)
3377 (error "No such setting: %s" setting))
3379 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3381 ;; All the windows mentioned are already visible, so we just
3382 ;; put point in the assigned buffer, and do not touch the
3384 (select-window all-visible)
3386 ;; Either remove all windows or just remove all Gnus windows.
3387 (let ((frame (selected-frame)))
3389 (if gnus-use-full-window
3390 ;; We want to remove all other windows.
3391 (if (not gnus-frame-split-p)
3392 ;; This is not a `frame' split, so we ignore the
3394 (delete-other-windows)
3395 ;; This is a `frame' split, so we delete all windows
3399 (unless (eq (cdr (assq 'minibuffer
3400 (frame-parameters frame)))
3402 (select-frame frame)
3403 (delete-other-windows)))
3405 ;; Just remove some windows.
3406 (gnus-remove-some-windows)
3407 (switch-to-buffer nntp-server-buffer))
3408 (select-frame frame)))
3410 (switch-to-buffer nntp-server-buffer)
3411 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3413 (defun gnus-all-windows-visible-p (split)
3414 "Say whether all buffers in SPLIT are currently visible.
3415 In particular, the value returned will be the window that
3417 (let ((stack (list split))
3419 type buffer win buf)
3420 (while (and (setq split (pop stack))
3422 ;; Be backwards compatible.
3423 (when (vectorp split)
3424 (setq split (append split nil)))
3425 (when (or (consp (car split))
3426 (vectorp (car split)))
3428 (push 'vertical split))
3429 ;; The SPLIT might be something that is to be evaled to
3430 ;; return a new SPLIT.
3431 (while (and (not (assq (car split) gnus-window-to-buffer))
3432 (gnus-functionp (car split)))
3433 (setq split (eval split)))
3435 (setq type (elt split 0))
3440 ((not (memq type '(horizontal vertical frame)))
3441 (setq buffer (cond ((stringp type) type)
3442 (t (cdr (assq type gnus-window-to-buffer)))))
3444 (error "Illegal buffer type: %s" type))
3445 (when (setq buf (get-buffer (if (symbolp buffer)
3446 (symbol-value buffer)
3448 (setq win (get-buffer-window buf t)))
3450 (when (memq 'point split)
3451 (setq all-visible win))
3452 (setq all-visible nil)))
3454 (when (eq type 'frame)
3455 (setq gnus-frame-split-p t))
3456 (setq stack (append (cddr split) stack)))))
3457 (unless (eq all-visible t)
3460 (defun gnus-window-top-edge (&optional window)
3461 (nth 1 (window-edges window)))
3463 (defun gnus-remove-some-windows ()
3464 (let ((buffers gnus-window-to-buffer)
3465 buf bufs lowest-buf lowest)
3467 ;; Remove windows on all known Gnus buffers.
3469 (setq buf (cdar buffers))
3471 (setq buf (and (boundp buf) (symbol-value buf))))
3473 (get-buffer-window buf)
3475 (setq bufs (cons buf bufs))
3477 (if (or (not lowest)
3478 (< (gnus-window-top-edge) lowest))
3480 (setq lowest (gnus-window-top-edge))
3481 (setq lowest-buf buf)))))
3482 (setq buffers (cdr buffers)))
3483 ;; Remove windows on *all* summary buffers.
3486 (let ((buf (window-buffer win)))
3487 (if (string-match "^\\*Summary" (buffer-name buf))
3489 (setq bufs (cons buf bufs))
3491 (if (or (not lowest)
3492 (< (gnus-window-top-edge) lowest))
3494 (setq lowest-buf buf)
3495 (setq lowest (gnus-window-top-edge)))))))))
3498 (pop-to-buffer lowest-buf)
3499 (switch-to-buffer nntp-server-buffer)))
3501 (and (not (eq (car bufs) lowest-buf))
3502 (delete-windows-on (car bufs)))
3503 (setq bufs (cdr bufs))))))
3505 (defun gnus-version ()
3506 "Version numbers of this version of Gnus."
3508 (let ((methods gnus-valid-select-methods)
3511 ;; Go through all the legal select methods and add their version
3512 ;; numbers to the total version string. Only the backends that are
3513 ;; currently in use will have their message numbers taken into
3516 (setq meth (intern (concat (caar methods) "-version")))
3518 (stringp (symbol-value meth))
3519 (setq mess (concat mess "; " (symbol-value meth))))
3520 (setq methods (cdr methods)))
3521 (gnus-message 2 mess)))
3523 (defun gnus-info-find-node ()
3524 "Find Info documentation of Gnus."
3526 ;; Enlarge info window if needed.
3527 (let ((mode major-mode)
3529 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3530 (setq gnus-info-buffer (current-buffer))
3531 (gnus-configure-windows 'info)))
3533 (defun gnus-days-between (date1 date2)
3534 ;; Return the number of days between date1 and date2.
3535 (- (gnus-day-number date1) (gnus-day-number date2)))
3537 (defun gnus-day-number (date)
3538 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3539 (timezone-parse-date date))))
3540 (timezone-absolute-from-gregorian
3541 (nth 1 dat) (nth 2 dat) (car dat))))
3543 (defun gnus-encode-date (date)
3544 "Convert DATE to internal time."
3545 (let* ((parse (timezone-parse-date date))
3546 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3547 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3548 (encode-time (caddr time) (cadr time) (car time)
3549 (caddr date) (cadr date) (car date) (nth 4 date))))
3551 (defun gnus-time-minus (t1 t2)
3552 "Subtract two internal times."
3553 (let ((borrow (< (cadr t1) (cadr t2))))
3554 (list (- (car t1) (car t2) (if borrow 1 0))
3555 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3557 (defun gnus-file-newer-than (file date)
3558 (let ((fdate (nth 5 (file-attributes file))))
3559 (or (> (car fdate) (car date))
3560 (and (= (car fdate) (car date))
3561 (> (nth 1 fdate) (nth 1 date))))))
3563 (defmacro gnus-local-set-keys (&rest plist)
3564 "Set the keys in PLIST in the current keymap."
3565 `(gnus-define-keys-1 (current-local-map) ',plist))
3567 (defmacro gnus-define-keys (keymap &rest plist)
3568 "Define all keys in PLIST in KEYMAP."
3569 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3571 (put 'gnus-define-keys 'lisp-indent-function 1)
3572 (put 'gnus-define-keys 'lisp-indent-hook 1)
3573 (put 'gnus-define-keymap 'lisp-indent-function 1)
3574 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3576 (defmacro gnus-define-keymap (keymap &rest plist)
3577 "Define all keys in PLIST in KEYMAP."
3578 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3580 (defun gnus-define-keys-1 (keymap plist)
3582 (error "Can't set keys in a null keymap"))
3583 (cond ((symbolp keymap)
3584 (setq keymap (symbol-value keymap)))
3587 (set (car keymap) nil)
3588 (define-prefix-command (car keymap))
3589 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3590 (setq keymap (symbol-value (car keymap)))))
3593 (when (symbolp (setq key (pop plist)))
3594 (setq key (symbol-value key)))
3595 (define-key keymap key (pop plist)))))
3597 (defun gnus-group-read-only-p (&optional group)
3598 "Check whether GROUP supports editing or not.
3599 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3600 that that variable is buffer-local to the summary buffers."
3601 (let ((group (or group gnus-newsgroup-name)))
3602 (not (gnus-check-backend-function 'request-replace-article group))))
3604 (defun gnus-group-total-expirable-p (group)
3605 "Check whether GROUP is total-expirable or not."
3606 (let ((params (gnus-info-params (gnus-get-info group))))
3607 (or (memq 'total-expire params)
3608 (cdr (assq 'total-expire params)) ; (total-expire . t)
3609 (and gnus-total-expirable-newsgroups ; Check var.
3610 (string-match gnus-total-expirable-newsgroups group)))))
3612 (defun gnus-group-auto-expirable-p (group)
3613 "Check whether GROUP is total-expirable or not."
3614 (let ((params (gnus-info-params (gnus-get-info group))))
3615 (or (memq 'auto-expire params)
3616 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3617 (and gnus-auto-expirable-newsgroups ; Check var.
3618 (string-match gnus-auto-expirable-newsgroups group)))))
3620 (defun gnus-virtual-group-p (group)
3621 "Say whether GROUP is virtual or not."
3622 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3623 gnus-valid-select-methods)))
3625 (defun gnus-news-group-p (group &optional article)
3626 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3627 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3628 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3629 (eq (gnus-request-type group article) 'news))))
3631 (defsubst gnus-simplify-subject-fully (subject)
3632 "Simplify a subject string according to the user's wishes."
3634 ((null gnus-summary-gather-subject-limit)
3635 (gnus-simplify-subject-re subject))
3636 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3637 (gnus-simplify-subject-fuzzy subject))
3638 ((numberp gnus-summary-gather-subject-limit)
3639 (gnus-limit-string (gnus-simplify-subject-re subject)
3640 gnus-summary-gather-subject-limit))
3644 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3645 "Check whether two subjects are equal. If optional argument
3646 simple-first is t, first argument is already simplified."
3648 ((null simple-first)
3649 (equal (gnus-simplify-subject-fully s1)
3650 (gnus-simplify-subject-fully s2)))
3653 (gnus-simplify-subject-fully s2)))))
3655 ;; Returns a list of writable groups.
3656 (defun gnus-writable-groups ()
3657 (let ((alist gnus-newsrc-alist)
3659 (while (setq group (car (pop alist)))
3660 (unless (gnus-group-read-only-p group)
3661 (push group groups)))
3664 (defun gnus-completing-read (default prompt &rest args)
3665 ;; Like `completing-read', except that DEFAULT is the default argument.
3666 (let* ((prompt (if default
3667 (concat prompt " (default " default ") ")
3668 (concat prompt " ")))
3669 (answer (apply 'completing-read prompt args)))
3670 (if (or (null answer) (zerop (length answer)))
3674 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3676 (defun gnus-y-or-n-p (prompt)
3681 (defun gnus-yes-or-no-p (prompt)
3683 (yes-or-no-p prompt)
3686 ;; Check whether to use long file names.
3687 (defun gnus-use-long-file-name (symbol)
3688 ;; The variable has to be set...
3689 (and gnus-use-long-file-name
3690 ;; If it isn't a list, then we return t.
3691 (or (not (listp gnus-use-long-file-name))
3692 ;; If it is a list, and the list contains `symbol', we
3694 (not (memq symbol gnus-use-long-file-name)))))
3696 ;; I suspect there's a better way, but I haven't taken the time to do
3697 ;; it yet. -erik selberg@cs.washington.edu
3698 (defun gnus-dd-mmm (messy-date)
3699 "Return a string like DD-MMM from a big messy string"
3700 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3706 ;; Make sure leading zeroes are stripped.
3707 (number-to-string (string-to-number (aref datevec 2)))
3711 (nth (1- (string-to-number (aref datevec 1)))
3712 timezone-months-assoc))
3715 (defun gnus-mode-string-quote (string)
3716 "Quote all \"%\" in STRING."
3718 (gnus-set-work-buffer)
3720 (goto-char (point-min))
3721 (while (search-forward "%" nil t)
3725 ;; Make a hash table (default and minimum size is 255).
3726 ;; Optional argument HASHSIZE specifies the table size.
3727 (defun gnus-make-hashtable (&optional hashsize)
3728 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3730 ;; Make a number that is suitable for hashing; bigger than MIN and one
3732 (defun gnus-create-hash-size (min)
3738 ;; Show message if message has a lower level than `gnus-verbose'.
3739 ;; Guideline for numbers:
3740 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3741 ;; for things that take a long time, 7 - not very important messages
3742 ;; on stuff, 9 - messages inside loops.
3743 (defun gnus-message (level &rest args)
3744 (if (<= level gnus-verbose)
3745 (apply 'message args)
3746 ;; We have to do this format thingy here even if the result isn't
3747 ;; shown - the return value has to be the same as the return value
3749 (apply 'format args)))
3751 (defun gnus-error (level &rest args)
3752 "Beep an error if `gnus-verbose' is on LEVEL or less."
3753 (when (<= (floor level) gnus-verbose)
3754 (apply 'message args)
3757 (when (and (floatp level)
3758 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3759 (sit-for duration))))
3762 ;; Generate a unique new group name.
3763 (defun gnus-generate-new-group-name (leaf)
3766 (while (gnus-gethash name gnus-newsrc-hashtb)
3767 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3770 (defsubst gnus-hide-text (b e props)
3771 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3772 (gnus-add-text-properties b e props)
3773 (when (memq 'intangible props)
3774 (gnus-put-text-property (max (1- b) (point-min))
3775 b 'intangible (cddr (memq 'intangible props)))))
3777 (defsubst gnus-unhide-text (b e)
3778 "Remove hidden text properties from region between B and E."
3779 (remove-text-properties b e gnus-hidden-properties)
3780 (when (memq 'intangible gnus-hidden-properties)
3781 (gnus-put-text-property (max (1- b) (point-min))
3782 b 'intangible nil)))
3784 (defun gnus-hide-text-type (b e type)
3785 "Hide text of TYPE between B and E."
3786 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3788 ;; Find out whether the gnus-visual TYPE is wanted.
3789 (defun gnus-visual-p (&optional type class)
3790 (and gnus-visual ; Has to be non-nil, at least.
3791 (if (not type) ; We don't care about type.
3793 (if (listp gnus-visual) ; It's a list, so we check it.
3794 (or (memq type gnus-visual)
3795 (memq class gnus-visual))
3798 (defun gnus-parent-headers (headers &optional generation)
3799 "Return the headers of the GENERATIONeth parent of HEADERS."
3801 (setq generation 1))
3802 (let (references parent)
3803 (while (and headers (not (zerop generation)))
3804 (setq references (mail-header-references headers))
3805 (when (and references
3806 (setq parent (gnus-parent-id references))
3807 (setq headers (car (gnus-id-to-thread parent))))
3811 (defun gnus-parent-id (references)
3812 "Return the last Message-ID in REFERENCES."
3813 (when (and references
3814 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3815 (substring references (match-beginning 1) (match-end 1))))
3817 (defun gnus-split-references (references)
3818 "Return a list of Message-IDs in REFERENCES."
3821 (while (string-match "<[^>]+>" references beg)
3822 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3826 (defun gnus-buffer-live-p (buffer)
3827 "Say whether BUFFER is alive or not."
3830 (buffer-name (get-buffer buffer))))
3832 (defun gnus-ephemeral-group-p (group)
3833 "Say whether GROUP is ephemeral or not."
3834 (gnus-group-get-parameter group 'quit-config))
3836 (defun gnus-group-quit-config (group)
3837 "Return the quit-config of GROUP."
3838 (gnus-group-get-parameter group 'quit-config))
3840 (defun gnus-simplify-mode-line ()
3841 "Make mode lines a bit simpler."
3842 (setq mode-line-modified "-- ")
3843 (when (listp mode-line-format)
3844 (make-local-variable 'mode-line-format)
3845 (setq mode-line-format (copy-sequence mode-line-format))
3846 (when (equal (nth 3 mode-line-format) " ")
3847 (setcar (nthcdr 3 mode-line-format) " "))))
3849 ;;; List and range functions
3851 (defun gnus-last-element (list)
3852 "Return last element of LIST."
3854 (setq list (cdr list)))
3857 (defun gnus-copy-sequence (list)
3858 "Do a complete, total copy of a list."
3859 (if (and (consp list) (not (consp (cdr list))))
3860 (cons (car list) (cdr list))
3861 (mapcar (lambda (elem) (if (consp elem)
3862 (if (consp (cdr elem))
3863 (gnus-copy-sequence elem)
3864 (cons (car elem) (cdr elem)))
3868 (defun gnus-set-difference (list1 list2)
3869 "Return a list of elements of LIST1 that do not appear in LIST2."
3870 (let ((list1 (copy-sequence list1)))
3872 (setq list1 (delq (car list2) list1))
3873 (setq list2 (cdr list2)))
3876 (defun gnus-sorted-complement (list1 list2)
3877 "Return a list of elements of LIST1 that do not appear in LIST2.
3878 Both lists have to be sorted over <."
3880 (if (or (null list1) (null list2))
3882 (while (and list1 list2)
3883 (cond ((= (car list1) (car list2))
3884 (setq list1 (cdr list1)
3886 ((< (car list1) (car list2))
3887 (setq out (cons (car list1) out))
3888 (setq list1 (cdr list1)))
3890 (setq out (cons (car list2) out))
3891 (setq list2 (cdr list2)))))
3892 (nconc (nreverse out) (or list1 list2)))))
3894 (defun gnus-intersection (list1 list2)
3897 (if (memq (car list2) list1)
3898 (setq result (cons (car list2) result)))
3899 (setq list2 (cdr list2)))
3902 (defun gnus-sorted-intersection (list1 list2)
3903 ;; LIST1 and LIST2 have to be sorted over <.
3905 (while (and list1 list2)
3906 (cond ((= (car list1) (car list2))
3907 (setq out (cons (car list1) out)
3910 ((< (car list1) (car list2))
3911 (setq list1 (cdr list1)))
3913 (setq list2 (cdr list2)))))
3916 (defun gnus-set-sorted-intersection (list1 list2)
3917 ;; LIST1 and LIST2 have to be sorted over <.
3918 ;; This function modifies LIST1.
3919 (let* ((top (cons nil list1))
3921 (while (and list1 list2)
3922 (cond ((= (car list1) (car list2))
3926 ((< (car list1) (car list2))
3927 (setcdr prev (cdr list1))
3928 (setq list1 (cdr list1)))
3930 (setq list2 (cdr list2)))))
3934 (defun gnus-compress-sequence (numbers &optional always-list)
3935 "Convert list of numbers to a list of ranges or a single range.
3936 If ALWAYS-LIST is non-nil, this function will always release a list of
3938 (let* ((first (car numbers))
3939 (last (car numbers))
3943 (if (not (listp (cdr numbers)))
3946 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3947 ((= (1+ last) (car numbers)) ;Still in sequence
3948 (setq last (car numbers)))
3949 (t ;End of one sequence
3951 (cons (if (= first last) first
3952 (cons first last)) result))
3953 (setq first (car numbers))
3954 (setq last (car numbers))))
3955 (setq numbers (cdr numbers)))
3956 (if (and (not always-list) (null result))
3957 (if (= first last) (list first) (cons first last))
3958 (nreverse (cons (if (= first last) first (cons first last))
3961 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3962 (defun gnus-uncompress-range (ranges)
3963 "Expand a list of ranges into a list of numbers.
3964 RANGES is either a single range on the form `(num . num)' or a list of
3966 (let (first last result)
3970 ((not (listp (cdr ranges)))
3971 (setq first (car ranges))
3972 (setq last (cdr ranges))
3973 (while (<= first last)
3974 (setq result (cons first result))
3975 (setq first (1+ first)))
3979 (if (atom (car ranges))
3980 (if (numberp (car ranges))
3981 (setq result (cons (car ranges) result)))
3982 (setq first (caar ranges))
3983 (setq last (cdar ranges))
3984 (while (<= first last)
3985 (setq result (cons first result))
3986 (setq first (1+ first))))
3987 (setq ranges (cdr ranges)))
3988 (nreverse result)))))
3990 (defun gnus-add-to-range (ranges list)
3991 "Return a list of ranges that has all articles from both RANGES and LIST.
3992 Note: LIST has to be sorted over `<'."
3994 (gnus-compress-sequence list t)
3995 (setq list (copy-sequence list))
3996 (or (listp (cdr ranges))
3997 (setq ranges (list ranges)))
3999 ilist lowest highest temp)
4000 (while (and ranges list)
4002 (setq lowest (or (and (atom (car ranges)) (car ranges))
4004 (while (and list (cdr list) (< (cadr list) lowest))
4005 (setq list (cdr list)))
4006 (if (< (car ilist) lowest)
4009 (setq list (cdr list))
4011 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4012 (setq highest (or (and (atom (car ranges)) (car ranges))
4014 (while (and list (<= (car list) highest))
4015 (setq list (cdr list)))
4016 (setq ranges (cdr ranges)))
4018 (setq out (nconc (gnus-compress-sequence list t) out)))
4019 (setq out (sort out (lambda (r1 r2)
4020 (< (or (and (atom r1) r1) (car r1))
4021 (or (and (atom r2) r2) (car r2))))))
4024 (if (atom (car ranges))
4026 (if (atom (cadr ranges))
4027 (if (= (1+ (car ranges)) (cadr ranges))
4029 (setcar ranges (cons (car ranges)
4031 (setcdr ranges (cddr ranges))))
4032 (if (= (1+ (car ranges)) (caadr ranges))
4034 (setcar (cadr ranges) (car ranges))
4035 (setcar ranges (cadr ranges))
4036 (setcdr ranges (cddr ranges))))))
4038 (if (atom (cadr ranges))
4039 (if (= (1+ (cdar ranges)) (cadr ranges))
4041 (setcdr (car ranges) (cadr ranges))
4042 (setcdr ranges (cddr ranges))))
4043 (if (= (1+ (cdar ranges)) (caadr ranges))
4045 (setcdr (car ranges) (cdadr ranges))
4046 (setcdr ranges (cddr ranges)))))))
4047 (setq ranges (cdr ranges)))
4050 (defun gnus-remove-from-range (ranges list)
4051 "Return a list of ranges that has all articles from LIST removed from RANGES.
4052 Note: LIST has to be sorted over `<'."
4053 ;; !!! This function shouldn't look like this, but I've got a headache.
4054 (gnus-compress-sequence
4055 (gnus-sorted-complement
4056 (gnus-uncompress-range ranges) list)))
4058 (defun gnus-member-of-range (number ranges)
4059 (if (not (listp (cdr ranges)))
4060 (and (>= number (car ranges))
4061 (<= number (cdr ranges)))
4064 (if (numberp (car ranges))
4065 (>= number (car ranges))
4066 (>= number (caar ranges)))
4068 (if (if (numberp (car ranges))
4069 (= number (car ranges))
4070 (and (>= number (caar ranges))
4071 (<= number (cdar ranges))))
4072 (setq not-stop nil))
4073 (setq ranges (cdr ranges)))
4076 (defun gnus-range-length (range)
4077 "Return the length RANGE would have if uncompressed."
4078 (length (gnus-uncompress-range range)))
4080 (defun gnus-sublist-p (list sublist)
4081 "Test whether all elements in SUBLIST are members of LIST."
4084 (unless (memq (pop sublist) list)
4094 (defvar gnus-group-mode-map nil)
4095 (put 'gnus-group-mode 'mode-class 'special)
4097 (unless gnus-group-mode-map
4098 (setq gnus-group-mode-map (make-keymap))
4099 (suppress-keymap gnus-group-mode-map)
4101 (gnus-define-keys gnus-group-mode-map
4102 " " gnus-group-read-group
4103 "=" gnus-group-select-group
4104 "\r" gnus-group-select-group
4105 "\M-\r" gnus-group-quick-select-group
4106 "j" gnus-group-jump-to-group
4107 "n" gnus-group-next-unread-group
4108 "p" gnus-group-prev-unread-group
4109 "\177" gnus-group-prev-unread-group
4110 [delete] gnus-group-prev-unread-group
4111 "N" gnus-group-next-group
4112 "P" gnus-group-prev-group
4113 "\M-n" gnus-group-next-unread-group-same-level
4114 "\M-p" gnus-group-prev-unread-group-same-level
4115 "," gnus-group-best-unread-group
4116 "." gnus-group-first-unread-group
4117 "u" gnus-group-unsubscribe-current-group
4118 "U" gnus-group-unsubscribe-group
4119 "c" gnus-group-catchup-current
4120 "C" gnus-group-catchup-current-all
4121 "l" gnus-group-list-groups
4122 "L" gnus-group-list-all-groups
4124 "g" gnus-group-get-new-news
4125 "\M-g" gnus-group-get-new-news-this-group
4126 "R" gnus-group-restart
4127 "r" gnus-group-read-init-file
4128 "B" gnus-group-browse-foreign-server
4129 "b" gnus-group-check-bogus-groups
4130 "F" gnus-find-new-newsgroups
4131 "\C-c\C-d" gnus-group-describe-group
4132 "\M-d" gnus-group-describe-all-groups
4133 "\C-c\C-a" gnus-group-apropos
4134 "\C-c\M-\C-a" gnus-group-description-apropos
4135 "a" gnus-group-post-news
4136 "\ek" gnus-group-edit-local-kill
4137 "\eK" gnus-group-edit-global-kill
4138 "\C-k" gnus-group-kill-group
4139 "\C-y" gnus-group-yank-group
4140 "\C-w" gnus-group-kill-region
4141 "\C-x\C-t" gnus-group-transpose-groups
4142 "\C-c\C-l" gnus-group-list-killed
4143 "\C-c\C-x" gnus-group-expire-articles
4144 "\C-c\M-\C-x" gnus-group-expire-all-groups
4146 "s" gnus-group-save-newsrc
4147 "z" gnus-group-suspend
4148 "Z" gnus-group-clear-dribble
4151 "?" gnus-group-describe-briefly
4152 "\C-c\C-i" gnus-info-find-node
4153 "\M-e" gnus-group-edit-group-method
4154 "^" gnus-group-enter-server-mode
4155 gnus-mouse-2 gnus-mouse-pick-group
4156 "<" beginning-of-buffer
4159 "\C-c\C-s" gnus-group-sort-groups
4161 "\C-c\M-g" gnus-activate-all-groups
4162 "\M-&" gnus-group-universal-argument
4163 "#" gnus-group-mark-group
4164 "\M-#" gnus-group-unmark-group)
4166 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4167 "m" gnus-group-mark-group
4168 "u" gnus-group-unmark-group
4169 "w" gnus-group-mark-region
4170 "m" gnus-group-mark-buffer
4171 "r" gnus-group-mark-regexp
4172 "U" gnus-group-unmark-all-groups)
4174 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4175 "d" gnus-group-make-directory-group
4176 "h" gnus-group-make-help-group
4177 "a" gnus-group-make-archive-group
4178 "k" gnus-group-make-kiboze-group
4179 "m" gnus-group-make-group
4180 "E" gnus-group-edit-group
4181 "e" gnus-group-edit-group-method
4182 "p" gnus-group-edit-group-parameters
4183 "v" gnus-group-add-to-virtual
4184 "V" gnus-group-make-empty-virtual
4185 "D" gnus-group-enter-directory
4186 "f" gnus-group-make-doc-group
4187 "r" gnus-group-rename-group
4188 "\177" gnus-group-delete-group
4189 [delete] gnus-group-delete-group)
4191 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4192 "b" gnus-group-brew-soup
4193 "w" gnus-soup-save-areas
4194 "s" gnus-soup-send-replies
4195 "p" gnus-soup-pack-packet
4196 "r" nnsoup-pack-replies)
4198 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4199 "s" gnus-group-sort-groups
4200 "a" gnus-group-sort-groups-by-alphabet
4201 "u" gnus-group-sort-groups-by-unread
4202 "l" gnus-group-sort-groups-by-level
4203 "v" gnus-group-sort-groups-by-score
4204 "r" gnus-group-sort-groups-by-rank
4205 "m" gnus-group-sort-groups-by-method)
4207 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4208 "k" gnus-group-list-killed
4209 "z" gnus-group-list-zombies
4210 "s" gnus-group-list-groups
4211 "u" gnus-group-list-all-groups
4212 "A" gnus-group-list-active
4213 "a" gnus-group-apropos
4214 "d" gnus-group-description-apropos
4215 "m" gnus-group-list-matching
4216 "M" gnus-group-list-all-matching
4217 "l" gnus-group-list-level)
4219 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4220 "f" gnus-score-flush-cache)
4222 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4223 "f" gnus-group-fetch-faq)
4225 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4226 "l" gnus-group-set-current-level
4227 "t" gnus-group-unsubscribe-current-group
4228 "s" gnus-group-unsubscribe-group
4229 "k" gnus-group-kill-group
4230 "y" gnus-group-yank-group
4231 "w" gnus-group-kill-region
4232 "\C-k" gnus-group-kill-level
4233 "z" gnus-group-kill-all-zombies))
4235 (defun gnus-group-mode ()
4236 "Major mode for reading news.
4238 All normal editing commands are switched off.
4239 \\<gnus-group-mode-map>
4240 The group buffer lists (some of) the groups available. For instance,
4241 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4242 lists all zombie groups.
4244 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4245 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4247 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4249 The following commands are available:
4251 \\{gnus-group-mode-map}"
4253 (when (and menu-bar-mode
4254 (gnus-visual-p 'group-menu 'menu))
4255 (gnus-group-make-menu-bar))
4256 (kill-all-local-variables)
4257 (gnus-simplify-mode-line)
4258 (setq major-mode 'gnus-group-mode)
4259 (setq mode-name "Group")
4260 (gnus-group-set-mode-line)
4261 (setq mode-line-process nil)
4262 (use-local-map gnus-group-mode-map)
4263 (buffer-disable-undo (current-buffer))
4264 (setq truncate-lines t)
4265 (setq buffer-read-only t)
4266 (run-hooks 'gnus-group-mode-hook))
4268 (defun gnus-mouse-pick-group (e)
4269 "Enter the group under the mouse pointer."
4272 (gnus-group-read-group nil))
4274 ;; Look at LEVEL and find out what the level is really supposed to be.
4275 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4276 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4277 (defun gnus-group-default-level (&optional level number-or-nil)
4279 (gnus-group-use-permanent-levels
4280 (or (setq gnus-group-use-permanent-levels
4281 (or level (if (numberp gnus-group-use-permanent-levels)
4282 gnus-group-use-permanent-levels
4283 (or gnus-group-default-list-level
4284 gnus-level-subscribed))))
4285 gnus-group-default-list-level gnus-level-subscribed))
4289 (or level gnus-group-default-list-level gnus-level-subscribed))))
4292 (defun gnus-slave-no-server (&optional arg)
4293 "Read network news as a slave, without connecting to local server"
4295 (gnus-no-server arg t))
4298 (defun gnus-no-server (&optional arg slave)
4300 If ARG is a positive number, Gnus will use that as the
4301 startup level. If ARG is nil, Gnus will be started at level 2.
4302 If ARG is non-nil and not a positive number, Gnus will
4303 prompt the user for the name of an NNTP server to use.
4304 As opposed to `gnus', this command will not connect to the local server."
4306 (let ((val (or arg (1- gnus-level-default-subscribed))))
4308 (make-local-variable 'gnus-group-use-permanent-levels)
4309 (setq gnus-group-use-permanent-levels val)))
4312 (defun gnus-slave (&optional arg)
4313 "Read news as a slave."
4315 (gnus arg nil 'slave))
4318 (defun gnus-other-frame (&optional arg)
4319 "Pop up a frame to read news."
4321 (if (get-buffer gnus-group-buffer)
4322 (let ((pop-up-frames t))
4324 (select-frame (make-frame))
4328 (defun gnus (&optional arg dont-connect slave)
4330 If ARG is non-nil and a positive number, Gnus will use that as the
4331 startup level. If ARG is non-nil and not a positive number, Gnus will
4332 prompt the user for the name of an NNTP server to use."
4335 (if (get-buffer gnus-group-buffer)
4337 (switch-to-buffer gnus-group-buffer)
4338 (gnus-group-get-new-news))
4341 (nnheader-init-server-buffer)
4342 (gnus-read-init-file)
4343 (setq gnus-slave slave)
4345 (gnus-group-setup-buffer)
4346 (let ((buffer-read-only nil))
4348 (if (not gnus-inhibit-startup-message)
4350 (gnus-group-startup-message)
4353 (let ((level (and (numberp arg) (> arg 0) arg))
4359 (gnus-start-news-server (and arg (not level))))))
4360 (if (and (not dont-connect)
4363 (run-hooks 'gnus-startup-hook)
4364 ;; NNTP server is successfully open.
4366 ;; Find the current startup file name.
4367 (setq gnus-current-startup-file
4368 (gnus-make-newsrc-file gnus-startup-file))
4370 ;; Read the dribble file.
4371 (when (or gnus-slave gnus-use-dribble-file)
4372 (gnus-dribble-read-file))
4374 ;; Allow using GroupLens predictions.
4375 (when gnus-use-grouplens
4377 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4379 (gnus-summary-make-display-table)
4380 ;; Do the actual startup.
4381 (gnus-setup-news nil level dont-connect)
4382 ;; Generate the group buffer.
4383 (gnus-group-list-groups level)
4384 (gnus-group-first-unread-group)
4385 (gnus-configure-windows 'group)
4386 (gnus-group-set-mode-line))))))
4388 (defun gnus-unload ()
4389 "Unload all Gnus features."
4391 (or (boundp 'load-history)
4392 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4393 (let ((history load-history)
4396 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4397 (setq feature (cdr (assq 'provide (car history))))
4398 (unload-feature feature 'force))
4399 (setq history (cdr history)))))
4401 (defun gnus-compile ()
4402 "Byte-compile the user-defined format specs."
4404 (let ((entries gnus-format-specs)
4405 entry gnus-tmp-func)
4407 (gnus-message 7 "Compiling format specs...")
4410 (setq entry (pop entries))
4411 (if (eq (car entry) 'version)
4412 (setq gnus-format-specs (delq entry gnus-format-specs))
4413 (when (and (listp (caddr entry))
4414 (not (eq 'byte-code (caaddr entry))))
4415 (fset 'gnus-tmp-func
4416 `(lambda () ,(caddr entry)))
4417 (byte-compile 'gnus-tmp-func)
4418 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4420 (push (cons 'version emacs-version) gnus-format-specs)
4422 (gnus-message 7 "Compiling user specs...done"))))
4424 (defun gnus-indent-rigidly (start end arg)
4425 "Indent rigidly using only spaces and no tabs."
4428 (narrow-to-region start end)
4429 (indent-rigidly start end arg)
4430 (goto-char (point-min))
4431 (while (search-forward "\t" nil t)
4432 (replace-match " " t t)))))
4434 (defun gnus-group-startup-message (&optional x y)
4435 "Insert startup message in current buffer."
4436 ;; Insert the message.
4441 _ ___ __ ___ __ _ ___
4460 ;; And then hack it.
4461 (gnus-indent-rigidly (point-min) (point-max)
4462 (/ (max (- (window-width) (or x 46)) 0) 2))
4463 (goto-char (point-min))
4465 (let* ((pheight (count-lines (point-min) (point-max)))
4466 (wheight (window-height))
4467 (rest (- wheight pheight)))
4468 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4470 (goto-char (point-min))
4471 (and (search-forward "Praxis" nil t)
4472 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4473 (goto-char (point-min))
4474 (let* ((mode-string (gnus-group-set-mode-line)))
4475 (setq mode-line-buffer-identification
4476 (list (concat gnus-version (substring (car mode-string) 4))))
4477 (set-buffer-modified-p t)))
4479 (defun gnus-group-setup-buffer ()
4480 (or (get-buffer gnus-group-buffer)
4482 (switch-to-buffer gnus-group-buffer)
4483 (gnus-add-current-to-buffer-list)
4485 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4487 (defun gnus-group-list-groups (&optional level unread lowest)
4488 "List newsgroups with level LEVEL or lower that have unread articles.
4489 Default is all subscribed groups.
4490 If argument UNREAD is non-nil, groups with no unread articles are also
4492 (interactive (list (if current-prefix-arg
4493 (prefix-numeric-value current-prefix-arg)
4495 (gnus-group-default-level nil t)
4496 gnus-group-default-list-level
4497 gnus-level-subscribed))))
4499 (setq level (car gnus-group-list-mode)
4500 unread (cdr gnus-group-list-mode)))
4501 (setq level (gnus-group-default-level level))
4502 (gnus-group-setup-buffer) ;May call from out of group buffer
4503 (gnus-update-format-specifications)
4504 (let ((case-fold-search nil)
4505 (props (text-properties-at (gnus-point-at-bol)))
4506 (group (gnus-group-group-name)))
4507 (set-buffer gnus-group-buffer)
4508 (funcall gnus-group-prepare-function level unread lowest)
4509 (if (zerop (buffer-size))
4510 (gnus-message 5 gnus-no-groups-message)
4511 (goto-char (point-max))
4512 (when (or (not gnus-group-goto-next-group-function)
4513 (not (funcall gnus-group-goto-next-group-function
4516 ;; Go to the first group with unread articles.
4517 (gnus-group-search-forward t)
4518 ;; Find the right group to put point on. If the current group
4519 ;; has disappeared in the new listing, try to find the next
4520 ;; one. If no next one can be found, just leave point at the
4521 ;; first newsgroup in the buffer.
4522 (if (not (gnus-goto-char
4524 (point-min) (point-max)
4525 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4526 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4528 (not (gnus-goto-char
4530 (point-min) (point-max) 'gnus-group
4532 (caar newsrc) gnus-active-hashtb)))))
4533 (setq newsrc (cdr newsrc)))
4534 (or newsrc (progn (goto-char (point-max))
4535 (forward-line -1)))))))
4536 ;; Adjust cursor point.
4537 (gnus-group-position-point))))
4539 (defun gnus-group-list-level (level &optional all)
4540 "List groups on LEVEL.
4541 If ALL (the prefix), also list groups that have no unread articles."
4542 (interactive "nList groups on level: \nP")
4543 (gnus-group-list-groups level all level))
4545 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4546 "List all newsgroups with unread articles of level LEVEL or lower.
4547 If ALL is non-nil, list groups that have no unread articles.
4548 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4549 If REGEXP, only list groups matching REGEXP."
4550 (set-buffer gnus-group-buffer)
4551 (let ((buffer-read-only nil)
4552 (newsrc (cdr gnus-newsrc-alist))
4553 (lowest (or lowest 1))
4554 info clevel unread group params)
4556 (if (< lowest gnus-level-zombie)
4557 ;; List living groups.
4559 (setq info (car newsrc)
4560 group (gnus-info-group info)
4561 params (gnus-info-params info)
4563 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4564 (and unread ; This group might be bogus
4566 (string-match regexp group))
4567 (<= (setq clevel (gnus-info-level info)) level)
4569 (or all ; We list all groups?
4570 (if (eq unread t) ; Unactivated?
4571 gnus-group-list-inactive-groups ; We list unactivated
4572 (> unread 0)) ; We list groups with unread articles
4573 (and gnus-list-groups-with-ticked-articles
4574 (cdr (assq 'tick (gnus-info-marks info))))
4575 ; And groups with tickeds
4576 ;; Check for permanent visibility.
4577 (and gnus-permanently-visible-groups
4578 (string-match gnus-permanently-visible-groups
4580 (memq 'visible params)
4581 (cdr (assq 'visible params)))
4582 (gnus-group-insert-group-line
4583 group (gnus-info-level info)
4584 (gnus-info-marks info) unread (gnus-info-method info)))))
4586 ;; List dead groups.
4587 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4588 (gnus-group-prepare-flat-list-dead
4589 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4590 gnus-level-zombie ?Z
4592 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4593 (gnus-group-prepare-flat-list-dead
4594 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4595 gnus-level-killed ?K regexp))
4597 (gnus-group-set-mode-line)
4598 (setq gnus-group-list-mode (cons level all))
4599 (run-hooks 'gnus-group-prepare-hook)))
4601 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4602 ;; List zombies and killed lists somewhat faster, which was
4603 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4604 ;; this by ignoring the group format specification altogether.
4607 ;; This loop is used when listing groups that match some
4610 (setq group (pop groups))
4611 (when (string-match regexp group)
4612 (gnus-add-text-properties
4613 (point) (prog1 (1+ (point))
4614 (insert " " mark " *: " group "\n"))
4615 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4617 'gnus-level level))))
4618 ;; This loop is used when listing all groups.
4620 (gnus-add-text-properties
4621 (point) (prog1 (1+ (point))
4622 (insert " " mark " *: "
4623 (setq group (pop groups)) "\n"))
4624 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4626 'gnus-level level))))))
4628 (defmacro gnus-group-real-name (group)
4629 "Find the real name of a foreign newsgroup."
4630 `(let ((gname ,group))
4631 (if (string-match ":[^:]+$" gname)
4632 (substring gname (1+ (match-beginning 0)))
4635 (defsubst gnus-server-add-address (method)
4636 (let ((method-name (symbol-name (car method))))
4637 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4638 (not (assq (intern (concat method-name "-address")) method)))
4639 (append method (list (list (intern (concat method-name "-address"))
4643 (defsubst gnus-server-get-method (group method)
4644 ;; Input either a server name, and extended server name, or a
4645 ;; select method, and return a select method.
4646 (cond ((stringp method)
4647 (gnus-server-to-method method))
4648 ((equal method gnus-select-method)
4650 ((and (stringp (car method)) group)
4651 (gnus-server-extend-method group method))
4652 ((and method (not group)
4653 (equal (cadr method) ""))
4656 (gnus-server-add-address method))))
4658 (defun gnus-server-to-method (server)
4659 "Map virtual server names to select methods."
4661 ;; Is this a method, perhaps?
4662 (and server (listp server) server)
4663 ;; Perhaps this is the native server?
4664 (and (equal server "native") gnus-select-method)
4665 ;; It should be in the server alist.
4666 (cdr (assoc server gnus-server-alist))
4667 ;; If not, we look through all the opened server
4668 ;; to see whether we can find it there.
4669 (let ((opened gnus-opened-servers))
4671 (not (equal server (format "%s:%s" (caaar opened)
4676 (defmacro gnus-method-equal (ss1 ss2)
4677 "Say whether two servers are equal."
4681 (and (= (length s1) (length s2))
4683 (while (and s1 (member (car s1) s2))
4687 (defun gnus-server-equal (m1 m2)
4688 "Say whether two methods are equal."
4689 (let ((m1 (cond ((null m1) gnus-select-method)
4690 ((stringp m1) (gnus-server-to-method m1))
4692 (m2 (cond ((null m2) gnus-select-method)
4693 ((stringp m2) (gnus-server-to-method m2))
4695 (gnus-method-equal m1 m2)))
4697 (defun gnus-servers-using-backend (backend)
4698 "Return a list of known servers using BACKEND."
4699 (let ((opened gnus-opened-servers)
4702 (when (eq backend (caaar opened))
4703 (push (caar opened) out))
4707 (defun gnus-group-prefixed-name (group method)
4708 "Return the whole name from GROUP and METHOD."
4709 (and (stringp method) (setq method (gnus-server-to-method method)))
4710 (concat (format "%s" (car method))
4712 (or (assoc (format "%s" (car method))
4713 (gnus-methods-using 'address))
4714 (gnus-server-equal method gnus-message-archive-method))
4716 (not (string= (nth 1 method) "")))
4717 (concat "+" (nth 1 method)))
4720 (defun gnus-group-real-prefix (group)
4721 "Return the prefix of the current group name."
4722 (if (string-match "^[^:]+:" group)
4723 (substring group 0 (match-end 0))
4726 (defun gnus-group-method (group)
4727 "Return the server or method used for selecting GROUP."
4728 (let ((prefix (gnus-group-real-prefix group)))
4729 (if (equal prefix "")
4731 (let ((servers gnus-opened-servers)
4733 backend possible found)
4734 (if (string-match "^[^\\+]+\\+" prefix)
4735 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4736 server (substring prefix (match-end 0) (1- (length prefix))))
4737 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4739 (when (eq (caaar servers) backend)
4740 (setq possible (caar servers))
4741 (when (equal (cadaar servers) server)
4742 (setq found (caar servers))))
4744 (or (car (rassoc found gnus-server-alist))
4746 (car (rassoc possible gnus-server-alist))
4748 (list backend server))))))
4750 (defsubst gnus-secondary-method-p (method)
4751 "Return whether METHOD is a secondary select method."
4752 (let ((methods gnus-secondary-select-methods)
4753 (gmethod (gnus-server-get-method nil method)))
4755 (not (equal (gnus-server-get-method nil (car methods))
4757 (setq methods (cdr methods)))
4760 (defun gnus-group-foreign-p (group)
4761 "Say whether a group is foreign or not."
4762 (and (not (gnus-group-native-p group))
4763 (not (gnus-group-secondary-p group))))
4765 (defun gnus-group-native-p (group)
4766 "Say whether the group is native or not."
4767 (not (string-match ":" group)))
4769 (defun gnus-group-secondary-p (group)
4770 "Say whether the group is secondary or not."
4771 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4773 (defun gnus-group-get-parameter (group &optional symbol)
4774 "Returns the group parameters for GROUP.
4775 If SYMBOL, return the value of that symbol in the group parameters."
4776 (let ((params (gnus-info-params (gnus-get-info group))))
4778 (gnus-group-parameter-value params symbol)
4781 (defun gnus-group-parameter-value (params symbol)
4782 "Return the value of SYMBOL in group PARAMS."
4783 (or (car (memq symbol params)) ; It's either a simple symbol
4784 (cdr (assq symbol params)))) ; or a cons.
4786 (defun gnus-group-add-parameter (group param)
4787 "Add parameter PARAM to GROUP."
4788 (let ((info (gnus-get-info group)))
4790 () ; This is a dead group. We just ignore it.
4791 ;; Cons the new param to the old one and update.
4792 (gnus-group-set-info (cons param (gnus-info-params info))
4795 (defun gnus-group-set-parameter (group name value)
4796 "Set parameter NAME to VALUE in GROUP."
4797 (let ((info (gnus-get-info group)))
4799 () ; This is a dead group. We just ignore it.
4800 (let ((old-params (gnus-info-params info))
4801 (new-params (list (cons name value))))
4803 (if (or (not (listp (car old-params)))
4804 (not (eq (caar old-params) name)))
4805 (setq new-params (append new-params (list (car old-params)))))
4806 (setq old-params (cdr old-params)))
4807 (gnus-group-set-info new-params group 'params)))))
4809 (defun gnus-group-add-score (group &optional score)
4810 "Add SCORE to the GROUP score.
4811 If SCORE is nil, add 1 to the score of GROUP."
4812 (let ((info (gnus-get-info group)))
4814 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4816 (defun gnus-summary-bubble-group ()
4817 "Increase the score of the current group.
4818 This is a handy function to add to `gnus-summary-exit-hook' to
4819 increase the score of each group you read."
4820 (gnus-group-add-score gnus-newsgroup-name))
4822 (defun gnus-group-set-info (info &optional method-only-group part)
4823 (let* ((entry (gnus-gethash
4824 (or method-only-group (gnus-info-group info))
4825 gnus-newsrc-hashtb))
4827 (info (if method-only-group (nth 2 entry) info))
4829 (when method-only-group
4831 (error "Trying to change non-existent group %s" method-only-group))
4832 ;; We have received parts of the actual group info - either the
4833 ;; select method or the group parameters. We first check
4834 ;; whether we have to extend the info, and if so, do that.
4835 (let ((len (length info))
4836 (total (if (eq part 'method) 5 6)))
4838 (setcdr (nthcdr (1- len) info)
4839 (make-list (- total len) nil)))
4840 ;; Then we enter the new info.
4841 (setcar (nthcdr (1- total) info) part-info)))
4843 ;; This is a new group, so we just create it.
4845 (set-buffer gnus-group-buffer)
4846 (setq method (gnus-info-method info))
4847 (when (gnus-server-equal method "native")
4850 (set-buffer gnus-group-buffer)
4852 ;; It's a foreign group...
4853 (gnus-group-make-group
4854 (gnus-group-real-name (gnus-info-group info))
4855 (if (stringp method) method
4856 (prin1-to-string (car method)))
4858 (nth 1 (gnus-info-method info))))
4859 ;; It's a native group.
4860 (gnus-group-make-group (gnus-info-group info))))
4861 (gnus-message 6 "Note: New group created")
4863 (gnus-gethash (gnus-group-prefixed-name
4864 (gnus-group-real-name (gnus-info-group info))
4865 (or (gnus-info-method info) gnus-select-method))
4866 gnus-newsrc-hashtb))))
4867 ;; Whether it was a new group or not, we now have the entry, so we
4868 ;; can do the update.
4871 (setcar (nthcdr 2 entry) info)
4872 (when (and (not (eq (car entry) t))
4873 (gnus-active (gnus-info-group info)))
4874 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4875 (error "No such group: %s" (gnus-info-group info)))))
4877 (defun gnus-group-set-method-info (group select-method)
4878 (gnus-group-set-info select-method group 'method))
4880 (defun gnus-group-set-params-info (group params)
4881 (gnus-group-set-info params group 'params))
4883 (defun gnus-group-update-group-line ()
4884 "Update the current line in the group buffer."
4885 (let* ((buffer-read-only nil)
4886 (group (gnus-group-group-name))
4887 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4888 gnus-group-indentation)
4890 (not (gnus-ephemeral-group-p group))
4892 (concat "(gnus-group-set-info '"
4893 (prin1-to-string (nth 2 entry)) ")")))
4894 (setq gnus-group-indentation (gnus-group-group-indentation))
4896 (gnus-group-insert-group-line-info group)
4898 (gnus-group-position-point)))
4900 (defun gnus-group-insert-group-line-info (group)
4901 "Insert GROUP on the current line."
4902 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4906 ;; (Un)subscribed group.
4907 (setq info (nth 2 entry))
4908 (gnus-group-insert-group-line
4909 group (gnus-info-level info) (gnus-info-marks info)
4910 (or (car entry) t) (gnus-info-method info)))
4911 ;; This group is dead.
4912 (gnus-group-insert-group-line
4914 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4916 (if (setq active (gnus-active group))
4917 (- (1+ (cdr active)) (car active)) 0)
4920 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4921 gnus-tmp-marked number
4923 "Insert a group line in the group buffer."
4924 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4925 (gnus-tmp-number-total
4927 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4929 (gnus-tmp-number-of-unread
4930 (if (numberp number) (int-to-string (max 0 number))
4932 (gnus-tmp-number-of-read
4933 (if (numberp number)
4934 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4936 (gnus-tmp-subscribed
4937 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4938 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4939 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4941 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4942 (gnus-tmp-newsgroup-description
4943 (if gnus-description-hashtb
4944 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4947 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4948 (gnus-tmp-moderated-string
4949 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4951 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4952 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4953 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4954 (gnus-tmp-news-method-string
4956 (format "(%s:%s)" (car gnus-tmp-method)
4957 (cadr gnus-tmp-method)) ""))
4958 (gnus-tmp-marked-mark
4959 (if (and (numberp number)
4961 (cdr (assq 'tick gnus-tmp-marked)))
4963 (gnus-tmp-process-marked
4964 (if (member gnus-tmp-group gnus-group-marked)
4965 gnus-process-mark ? ))
4967 (or (and gnus-use-grouplens
4968 (bbb-grouplens-group-p gnus-tmp-group))
4970 (buffer-read-only nil)
4971 header gnus-tmp-header) ; passed as parameter to user-funcs.
4973 (gnus-add-text-properties
4977 (eval gnus-group-line-format-spec))
4978 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4979 gnus-unread ,(if (numberp number)
4980 (string-to-int gnus-tmp-number-of-unread)
4982 gnus-marked ,gnus-tmp-marked-mark
4983 gnus-indentation ,gnus-group-indentation
4984 gnus-level ,gnus-tmp-level))
4985 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4987 (run-hooks 'gnus-group-update-hook)
4989 ;; Allow XEmacs to remove front-sticky text properties.
4990 (gnus-group-remove-excess-properties)))
4992 (defun gnus-group-update-group (group &optional visible-only)
4993 "Update all lines where GROUP appear.
4994 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4997 (set-buffer gnus-group-buffer)
4998 ;; The buffer may be narrowed.
5001 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5003 found buffer-read-only)
5004 ;; Enter the current status into the dribble buffer.
5005 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5006 (if (and entry (not (gnus-ephemeral-group-p group)))
5008 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5010 ;; Find all group instances. If topics are in use, each group
5011 ;; may be listed in more than once.
5012 (while (setq loc (text-property-any
5013 loc (point-max) 'gnus-group ident))
5016 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5018 (gnus-group-insert-group-line-info group))
5019 (setq loc (1+ loc)))
5020 (unless (or found visible-only)
5021 ;; No such line in the buffer, find out where it's supposed to
5022 ;; go, and insert it there (or at the end of the buffer).
5023 (if gnus-goto-missing-group-function
5024 (funcall gnus-goto-missing-group-function group)
5025 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5026 (while (and entry (car entry)
5030 (point-min) (point-max)
5031 'gnus-group (gnus-intern-safe
5032 (caar entry) gnus-active-hashtb)))))
5033 (setq entry (cdr entry)))
5034 (or entry (goto-char (point-max)))))
5035 ;; Finally insert the line.
5036 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5037 (gnus-group-insert-group-line-info group)))
5038 (gnus-group-set-mode-line)))))
5040 (defun gnus-group-set-mode-line ()
5041 "Update the mode line in the group buffer."
5042 (when (memq 'group gnus-updated-mode-lines)
5043 ;; Yes, we want to keep this mode line updated.
5045 (set-buffer gnus-group-buffer)
5046 (let* ((gformat (or gnus-group-mode-line-format-spec
5047 (setq gnus-group-mode-line-format-spec
5049 gnus-group-mode-line-format
5050 gnus-group-mode-line-format-alist))))
5051 (gnus-tmp-news-server (cadr gnus-select-method))
5052 (gnus-tmp-news-method (car gnus-select-method))
5053 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5055 gnus-tmp-header ;Dummy binding for user-defined formats
5056 ;; Get the resulting string.
5057 (mode-string (eval gformat)))
5058 ;; Say whether the dribble buffer has been modified.
5059 (setq mode-line-modified
5060 (if (and gnus-dribble-buffer
5061 (buffer-name gnus-dribble-buffer)
5062 (buffer-modified-p gnus-dribble-buffer)
5064 (set-buffer gnus-dribble-buffer)
5065 (not (zerop (buffer-size)))))
5067 ;; If the line is too long, we chop it off.
5068 (when (> (length mode-string) max-len)
5069 (setq mode-string (substring mode-string 0 (- max-len 4))))
5071 (setq mode-line-buffer-identification
5073 (set-buffer-modified-p t))))))
5075 (defun gnus-group-group-name ()
5076 "Get the name of the newsgroup on the current line."
5077 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5078 (and group (symbol-name group))))
5080 (defun gnus-group-group-level ()
5081 "Get the level of the newsgroup on the current line."
5082 (get-text-property (gnus-point-at-bol) 'gnus-level))
5084 (defun gnus-group-group-indentation ()
5085 "Get the indentation of the newsgroup on the current line."
5086 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5087 (and gnus-group-indentation-function
5088 (funcall gnus-group-indentation-function))
5091 (defun gnus-group-group-unread ()
5092 "Get the number of unread articles of the newsgroup on the current line."
5093 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5095 (defun gnus-group-search-forward (&optional backward all level first-too)
5096 "Find the next newsgroup with unread articles.
5097 If BACKWARD is non-nil, find the previous newsgroup instead.
5098 If ALL is non-nil, just find any newsgroup.
5099 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5101 If FIRST-TOO, the current line is also eligible as a target."
5102 (let ((way (if backward -1 1))
5103 (low gnus-level-killed)
5106 (if (and backward (progn (beginning-of-line)) (bobp))
5108 (or first-too (forward-line way))
5116 (get-text-property (point) 'gnus-unread)))
5117 (and (numberp unread) (> unread 0)))
5118 (setq lev (get-text-property (point)
5120 (<= lev gnus-level-subscribed)))
5122 (and (setq lev (get-text-property (point)
5131 (zerop (forward-line way)))))
5133 (progn (gnus-group-position-point) t)
5134 (goto-char (or pos beg))
5137 ;;; Gnus group mode commands
5141 (defun gnus-group-mark-group (n &optional unmark no-advance)
5142 "Mark the current group."
5144 (let ((buffer-read-only nil)
5148 (when (setq group (gnus-group-group-name))
5152 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5157 (setq gnus-group-marked (delete group gnus-group-marked)))
5159 (setq gnus-group-marked
5160 (cons group (delete group gnus-group-marked)))))
5161 (or no-advance (gnus-group-next-group 1))
5163 (gnus-summary-position-point)
5166 (defun gnus-group-unmark-group (n)
5167 "Remove the mark from the current group."
5169 (gnus-group-mark-group n 'unmark)
5170 (gnus-group-position-point))
5172 (defun gnus-group-unmark-all-groups ()
5173 "Unmark all groups."
5175 (let ((groups gnus-group-marked))
5178 (gnus-group-remove-mark (pop groups)))))
5179 (gnus-group-position-point))
5181 (defun gnus-group-mark-region (unmark beg end)
5182 "Mark all groups between point and mark.
5183 If UNMARK, remove the mark instead."
5184 (interactive "P\nr")
5185 (let ((num (count-lines beg end)))
5188 (- num (gnus-group-mark-group num unmark)))))
5190 (defun gnus-group-mark-buffer (&optional unmark)
5191 "Mark all groups in the buffer.
5192 If UNMARK, remove the mark instead."
5194 (gnus-group-mark-region unmark (point-min) (point-max)))
5196 (defun gnus-group-mark-regexp (regexp)
5197 "Mark all groups that match some regexp."
5198 (interactive "sMark (regexp): ")
5199 (let ((alist (cdr gnus-newsrc-alist))
5202 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5203 (gnus-group-set-mark group))))
5204 (gnus-group-position-point))
5206 (defun gnus-group-remove-mark (group)
5207 "Remove the process mark from GROUP and move point there.
5208 Return nil if the group isn't displayed."
5209 (if (gnus-group-goto-group group)
5211 (gnus-group-mark-group 1 'unmark t)
5213 (setq gnus-group-marked
5214 (delete group gnus-group-marked))
5217 (defun gnus-group-set-mark (group)
5218 "Set the process mark on GROUP."
5219 (if (gnus-group-goto-group group)
5221 (gnus-group-mark-group 1 nil t))
5222 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5224 (defun gnus-group-universal-argument (arg &optional groups func)
5225 "Perform any command on all groups accoring to the process/prefix convention."
5227 (let ((groups (or groups (gnus-group-process-prefix arg)))
5229 (if (eq (setq func (or func
5232 (substitute-command-keys
5233 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5235 (gnus-error 1 "Undefined key")
5237 (gnus-group-remove-mark (setq group (pop groups)))
5238 (command-execute func))))
5239 (gnus-group-position-point))
5241 (defun gnus-group-process-prefix (n)
5242 "Return a list of groups to work on.
5243 Take into consideration N (the prefix) and the list of marked groups."
5246 (setq n (prefix-numeric-value n))
5247 ;; There is a prefix, so we return a list of the N next
5249 (let ((way (if (< n 0) -1 1))
5254 (setq group (gnus-group-group-name)))
5255 (setq groups (cons group groups))
5257 (gnus-group-next-group way)))
5259 ((and (boundp 'transient-mark-mode)
5261 (boundp 'mark-active)
5263 ;; Work on the region between point and mark.
5264 (let ((max (max (point) (mark)))
5267 (goto-char (min (point) (mark)))
5270 (push (gnus-group-group-name) groups)
5271 (zerop (gnus-group-next-group 1))
5273 (nreverse groups))))
5275 ;; No prefix, but a list of marked articles.
5276 (reverse gnus-group-marked))
5278 ;; Neither marked articles or a prefix, so we return the
5280 (let ((group (gnus-group-group-name)))
5281 (and group (list group))))))
5283 ;; Selecting groups.
5285 (defun gnus-group-read-group (&optional all no-article group)
5286 "Read news in this newsgroup.
5287 If the prefix argument ALL is non-nil, already read articles become
5288 readable. IF ALL is a number, fetch this number of articles. If the
5289 optional argument NO-ARTICLE is non-nil, no article will be
5290 auto-selected upon group entry. If GROUP is non-nil, fetch that
5293 (let ((group (or group (gnus-group-group-name)))
5294 number active marked entry)
5295 (or group (error "No group on current line"))
5296 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5297 group gnus-newsrc-hashtb)))))
5298 ;; This group might be a dead group. In that case we have to get
5299 ;; the number of unread articles from `gnus-active-hashtb'.
5301 (cond ((numberp all) all)
5303 ((setq active (gnus-active group))
5304 (- (1+ (cdr active)) (car active)))))
5305 (gnus-summary-read-group
5306 group (or all (and (numberp number)
5307 (zerop (+ number (length (cdr (assq 'tick marked)))
5308 (length (cdr (assq 'dormant marked)))))))
5311 (defun gnus-group-select-group (&optional all)
5312 "Select this newsgroup.
5313 No article is selected automatically.
5314 If ALL is non-nil, already read articles become readable.
5315 If ALL is a number, fetch this number of articles."
5317 (gnus-group-read-group all t))
5319 (defun gnus-group-quick-select-group (&optional all)
5320 "Select the current group \"quickly\".
5321 This means that no highlighting or scoring will be performed."
5324 gnus-score-find-score-files-function
5325 gnus-apply-kill-hook
5326 gnus-summary-expunge-below)
5327 (gnus-group-read-group all t)))
5329 (defun gnus-group-visible-select-group (&optional all)
5330 "Select the current group without hiding any articles."
5332 (let ((gnus-inhibit-limiting t))
5333 (gnus-group-read-group all t)))
5336 (defun gnus-fetch-group (group)
5337 "Start Gnus if necessary and enter GROUP.
5338 Returns whether the fetching was successful or not."
5339 (interactive "sGroup name: ")
5340 (or (get-buffer gnus-group-buffer)
5342 (gnus-group-read-group nil nil group))
5344 ;; Enter a group that is not in the group buffer. Non-nil is returned
5345 ;; if selection was successful.
5346 (defun gnus-group-read-ephemeral-group
5347 (group method &optional activate quit-config)
5348 (let ((group (if (gnus-group-foreign-p group) group
5349 (gnus-group-prefixed-name group method))))
5352 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5353 ((quit-config . ,(if quit-config quit-config
5354 (cons (current-buffer) 'summary))))))
5356 (set-buffer gnus-group-buffer)
5357 (or (gnus-check-server method)
5358 (error "Unable to contact server: %s" (gnus-status-message method)))
5359 (if activate (or (gnus-request-group group)
5360 (error "Couldn't request group")))
5362 (gnus-group-read-group t t group)
5366 (defun gnus-group-jump-to-group (group)
5367 "Jump to newsgroup GROUP."
5369 (list (completing-read
5370 "Group: " gnus-active-hashtb nil
5371 (gnus-read-active-file-p)
5373 'gnus-group-history)))
5375 (when (equal group "")
5376 (error "Empty group name"))
5378 (when (string-match "[\000-\032]" group)
5379 (error "Control characters in group: %s" group))
5381 (let ((b (text-property-any
5382 (point-min) (point-max)
5383 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5384 (unless (gnus-ephemeral-group-p group)
5386 ;; Either go to the line in the group buffer...
5388 ;; ... or insert the line.
5391 (gnus-activate-group group)
5392 (error "%s error: %s" group (gnus-status-message group)))
5394 (gnus-group-update-group group)
5395 (goto-char (text-property-any
5396 (point-min) (point-max)
5397 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5398 ;; Adjust cursor point.
5399 (gnus-group-position-point)))
5401 (defun gnus-group-goto-group (group)
5402 "Goto to newsgroup GROUP."
5404 (let ((b (text-property-any (point-min) (point-max)
5405 'gnus-group (gnus-intern-safe
5406 group gnus-active-hashtb))))
5407 (and b (goto-char b)))))
5409 (defun gnus-group-next-group (n)
5410 "Go to next N'th newsgroup.
5411 If N is negative, search backward instead.
5412 Returns the difference between N and the number of skips actually
5415 (gnus-group-next-unread-group n t))
5417 (defun gnus-group-next-unread-group (n &optional all level)
5418 "Go to next N'th unread newsgroup.
5419 If N is negative, search backward instead.
5420 If ALL is non-nil, choose any newsgroup, unread or not.
5421 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5422 such group can be found, the next group with a level higher than
5424 Returns the difference between N and the number of skips actually
5427 (let ((backward (< n 0))
5430 (gnus-group-search-forward
5431 backward (or (not gnus-group-goto-unread) all) level))
5433 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5434 (if level " on this level or higher" "")))
5437 (defun gnus-group-prev-group (n)
5438 "Go to previous N'th newsgroup.
5439 Returns the difference between N and the number of skips actually
5442 (gnus-group-next-unread-group (- n) t))
5444 (defun gnus-group-prev-unread-group (n)
5445 "Go to previous N'th unread newsgroup.
5446 Returns the difference between N and the number of skips actually
5449 (gnus-group-next-unread-group (- n)))
5451 (defun gnus-group-next-unread-group-same-level (n)
5452 "Go to next N'th unread newsgroup on the same level.
5453 If N is negative, search backward instead.
5454 Returns the difference between N and the number of skips actually
5457 (gnus-group-next-unread-group n t (gnus-group-group-level))
5458 (gnus-group-position-point))
5460 (defun gnus-group-prev-unread-group-same-level (n)
5461 "Go to next N'th unread newsgroup on the same level.
5462 Returns the difference between N and the number of skips actually
5465 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5466 (gnus-group-position-point))
5468 (defun gnus-group-best-unread-group (&optional exclude-group)
5469 "Go to the group with the highest level.
5470 If EXCLUDE-GROUP, do not go to that group."
5472 (goto-char (point-min))
5476 (setq unread (get-text-property (point) 'gnus-unread))
5477 (if (and (numberp unread) (> unread 0))
5479 (if (and (get-text-property (point) 'gnus-level)
5480 (< (get-text-property (point) 'gnus-level) best)
5481 (or (not exclude-group)
5482 (not (equal exclude-group (gnus-group-group-name)))))
5484 (setq best (get-text-property (point) 'gnus-level))
5485 (setq best-point (point))))))
5487 (if best-point (goto-char best-point))
5488 (gnus-summary-position-point)
5489 (and best-point (gnus-group-group-name))))
5491 (defun gnus-group-first-unread-group ()
5492 "Go to the first group with unread articles."
5495 (let ((opoint (point))
5497 (goto-char (point-min))
5498 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5499 (and (numberp unread) ; Not a topic.
5500 (not (zerop unread))) ; Has unread articles.
5501 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5504 nil)) ; Not success.
5505 (gnus-group-position-point)))
5507 (defun gnus-group-enter-server-mode ()
5508 "Jump to the server buffer."
5510 (gnus-enter-server-buffer))
5512 (defun gnus-group-make-group (name &optional method address)
5513 "Add a new newsgroup.
5514 The user will be prompted for a NAME, for a select METHOD, and an
5518 (read-string "Group name: ")
5521 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5522 nil t nil 'gnus-method-history)))
5523 (cond ((assoc method gnus-valid-select-methods)
5525 (if (memq 'prompt-address
5526 (assoc method gnus-valid-select-methods))
5527 (read-string "Address: ")
5529 ((assoc method gnus-server-alist)
5532 (list method ""))))))
5534 (let* ((meth (and method (if address (list (intern method) address)
5536 (nname (if method (gnus-group-prefixed-name name meth) name))
5538 (when (gnus-gethash nname gnus-newsrc-hashtb)
5539 (error "Group %s already exists" nname))
5540 ;; Subscribe to the new group.
5541 (gnus-group-change-level
5542 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5543 gnus-level-default-subscribed gnus-level-killed
5544 (and (gnus-group-group-name)
5545 (gnus-gethash (gnus-group-group-name)
5546 gnus-newsrc-hashtb))
5549 (gnus-set-active nname (cons 1 0))
5550 (or (gnus-ephemeral-group-p name)
5552 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5554 (gnus-group-insert-group-line-info nname)
5556 (gnus-group-position-point)
5558 ;; Load the backend and try to make the backend create
5559 ;; the group as well.
5560 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5562 gnus-valid-select-methods)
5564 (gnus-check-server meth)
5565 (and (gnus-check-backend-function 'request-create-group nname)
5566 (gnus-request-create-group nname))
5569 (defun gnus-group-delete-group (group &optional force)
5570 "Delete the current group.
5571 If FORCE (the prefix) is non-nil, all the articles in the group will
5572 be deleted. This is \"deleted\" as in \"removed forever from the face
5573 of the Earth\". There is no undo."
5575 (list (gnus-group-group-name)
5576 current-prefix-arg))
5577 (or group (error "No group to rename"))
5578 (or (gnus-check-backend-function 'request-delete-group group)
5579 (error "This backend does not support group deletion"))
5581 (if (not (gnus-yes-or-no-p
5583 "Do you really want to delete %s%s? "
5584 group (if force " and all its contents" ""))))
5586 (gnus-message 6 "Deleting group %s..." group)
5587 (if (not (gnus-request-delete-group group force))
5588 (gnus-error 3 "Couldn't delete group %s" group)
5589 (gnus-message 6 "Deleting group %s...done" group)
5590 (gnus-group-goto-group group)
5591 (gnus-group-kill-group 1 t)
5592 (gnus-sethash group nil gnus-active-hashtb)
5594 (gnus-group-position-point)))
5596 (defun gnus-group-rename-group (group new-name)
5599 (gnus-group-group-name)
5601 (or (gnus-check-backend-function
5602 'request-rename-group (gnus-group-group-name))
5603 (error "This backend does not support renaming groups"))
5604 (read-string "New group name: "))))
5606 (or (gnus-check-backend-function 'request-rename-group group)
5607 (error "This backend does not support renaming groups"))
5609 (or group (error "No group to rename"))
5610 (and (string-match "^[ \t]*$" new-name)
5611 (error "Not a valid group name"))
5613 ;; We find the proper prefixed name.
5615 (gnus-group-prefixed-name
5616 (gnus-group-real-name new-name)
5617 (gnus-info-method (gnus-get-info group))))
5619 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5621 (if (not (gnus-request-rename-group group new-name))
5622 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5623 ;; We rename the group internally by killing it...
5624 (gnus-group-goto-group group)
5625 (gnus-group-kill-group)
5626 ;; ... changing its name ...
5627 (setcar (cdar gnus-list-of-killed-groups) new-name)
5628 ;; ... and then yanking it. Magic!
5629 (gnus-group-yank-group)
5630 (gnus-set-active new-name (gnus-active group))
5631 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5633 (gnus-group-position-point)))
5635 (defun gnus-group-edit-group (group &optional part)
5636 "Edit the group on the current line."
5637 (interactive (list (gnus-group-group-name)))
5638 (let* ((part (or part 'info))
5639 (done-func `(lambda ()
5640 "Exit editing mode and update the information."
5642 (gnus-group-edit-group-done ',part ,group)))
5643 (winconf (current-window-configuration))
5645 (or group (error "No group on current line"))
5646 (or (setq info (gnus-get-info group))
5647 (error "Killed group; can't be edited"))
5648 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5649 (gnus-configure-windows 'edit-group)
5650 (gnus-add-current-to-buffer-list)
5652 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5653 (use-local-map (copy-keymap emacs-lisp-mode-map))
5654 (local-set-key "\C-c\C-c" done-func)
5655 (make-local-variable 'gnus-prev-winconf)
5656 (setq gnus-prev-winconf winconf)
5661 ";; Type `C-c C-c' after editing the select method.\n\n")
5663 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5665 ";; Type `C-c C-c' after editing the group info.\n\n")))
5668 (cond ((eq part 'method)
5669 (or (gnus-info-method info) "native"))
5671 (gnus-info-params info))
5675 (defun gnus-group-edit-group-method (group)
5676 "Edit the select method of GROUP."
5677 (interactive (list (gnus-group-group-name)))
5678 (gnus-group-edit-group group 'method))
5680 (defun gnus-group-edit-group-parameters (group)
5681 "Edit the group parameters of GROUP."
5682 (interactive (list (gnus-group-group-name)))
5683 (gnus-group-edit-group group 'params))
5685 (defun gnus-group-edit-group-done (part group)
5686 "Get info from buffer, update variables and jump to the group buffer."
5687 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5688 (goto-char (point-min))
5689 (let* ((form (read (current-buffer)))
5690 (winconf gnus-prev-winconf)
5691 (method (cond ((eq part 'info) (nth 4 form))
5692 ((eq part 'method) form)
5694 (info (cond ((eq part 'info) form)
5695 ((eq part 'method) (gnus-get-info group))
5698 (if (or (not method)
5700 gnus-select-method method))
5701 (gnus-group-real-name (car info))
5702 (gnus-group-prefixed-name
5703 (gnus-group-real-name (car info)) method))
5705 (when (and new-group
5706 (not (equal new-group group)))
5707 (when (gnus-group-goto-group group)
5708 (gnus-group-kill-group 1))
5709 (gnus-activate-group new-group))
5711 (if (and info new-group)
5713 (setq info (gnus-copy-sequence info))
5714 (setcar info new-group)
5715 (unless (gnus-server-equal method "native")
5716 (unless (nthcdr 3 info)
5717 (nconc info (list nil nil)))
5718 (unless (nthcdr 4 info)
5719 (nconc info (list nil)))
5720 (gnus-info-set-method info method))
5721 (gnus-group-set-info info))
5722 (gnus-group-set-info form (or new-group group) part))
5723 (kill-buffer (current-buffer))
5724 (and winconf (set-window-configuration winconf))
5725 (set-buffer gnus-group-buffer)
5726 (gnus-group-update-group (or new-group group))
5727 (gnus-group-position-point)))
5729 (defun gnus-group-make-help-group ()
5730 "Create the Gnus documentation group."
5732 (let ((path load-path)
5733 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5735 (and (gnus-gethash name gnus-newsrc-hashtb)
5736 (error "Documentation group already exists"))
5738 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5740 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5742 (setq file (concat (file-name-directory
5743 (directory-file-name dir))
5744 "etc/gnus-tut.txt"))))
5747 (gnus-message 1 "Couldn't find doc group")
5748 (gnus-group-make-group
5749 (gnus-group-real-name name)
5750 (list 'nndoc "gnus-help"
5751 (list 'nndoc-address file)
5752 (list 'nndoc-article-type 'mbox)))))
5753 (gnus-group-position-point))
5755 (defun gnus-group-make-doc-group (file type)
5756 "Create a group that uses a single file as the source."
5758 (list (read-file-name "File name: ")
5759 (and current-prefix-arg 'ask)))
5760 (when (eq type 'ask)
5765 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5767 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5768 ((= char ?b) 'babyl)
5769 ((= char ?d) 'digest)
5770 ((= char ?f) 'forward)
5772 (t (setq err (format "%c unknown. " char))
5775 (let* ((file (expand-file-name file))
5776 (name (gnus-generate-new-group-name
5777 (gnus-group-prefixed-name
5778 (file-name-nondirectory file) '(nndoc "")))))
5779 (gnus-group-make-group
5780 (gnus-group-real-name name)
5781 (list 'nndoc (file-name-nondirectory file)
5782 (list 'nndoc-address file)
5783 (list 'nndoc-article-type (or type 'guess))))))
5785 (defun gnus-group-make-archive-group (&optional all)
5786 "Create the (ding) Gnus archive group of the most recent articles.
5787 Given a prefix, create a full group."
5789 (let ((group (gnus-group-prefixed-name
5790 (if all "ding.archives" "ding.recent") '(nndir ""))))
5791 (and (gnus-gethash group gnus-newsrc-hashtb)
5792 (error "Archive group already exists"))
5793 (gnus-group-make-group
5794 (gnus-group-real-name group)
5795 (list 'nndir (if all "hpc" "edu")
5796 (list 'nndir-directory
5797 (if all gnus-group-archive-directory
5798 gnus-group-recent-archive-directory))))))
5800 (defun gnus-group-make-directory-group (dir)
5801 "Create an nndir group.
5802 The user will be prompted for a directory. The contents of this
5803 directory will be used as a newsgroup. The directory should contain
5804 mail messages or news articles in files that have numeric names."
5806 (list (read-file-name "Create group from directory: ")))
5807 (or (file-exists-p dir) (error "No such directory"))
5808 (or (file-directory-p dir) (error "Not a directory"))
5812 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5814 (gnus-group-prefixed-name
5815 (concat (file-name-as-directory (directory-file-name dir))
5818 (setq ext (format "<%d>" (setq i (1+ i)))))
5819 (gnus-group-make-group
5820 (gnus-group-real-name group)
5821 (list 'nndir group (list 'nndir-directory dir)))))
5823 (defun gnus-group-make-kiboze-group (group address scores)
5824 "Create an nnkiboze group.
5825 The user will be prompted for a name, a regexp to match groups, and
5826 score file entries for articles to include in the group."
5829 (read-string "nnkiboze group name: ")
5830 (read-string "Source groups (regexp): ")
5831 (let ((headers (mapcar (lambda (group) (list group))
5832 '("subject" "from" "number" "date" "message-id"
5833 "references" "chars" "lines" "xref"
5834 "followup" "all" "body" "head")))
5835 scores header regexp regexps)
5836 (while (not (equal "" (setq header (completing-read
5837 "Match on header: " headers nil t))))
5839 (while (not (equal "" (setq regexp (read-string
5840 (format "Match on %s (string): "
5842 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5843 (setq scores (cons (cons header regexps) scores)))
5845 (gnus-group-make-group group "nnkiboze" address)
5846 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5847 (let (emacs-lisp-mode-hook)
5848 (pp scores (current-buffer)))))
5850 (defun gnus-group-add-to-virtual (n vgroup)
5851 "Add the current group to a virtual group."
5853 (list current-prefix-arg
5854 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5856 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5857 (error "%s is not an nnvirtual group" vgroup))
5858 (let* ((groups (gnus-group-process-prefix n))
5859 (method (gnus-info-method (gnus-get-info vgroup))))
5860 (setcar (cdr method)
5862 (nth 1 method) "\\|"
5865 (gnus-group-remove-mark s)
5866 (concat "\\(^" (regexp-quote s) "$\\)"))
5868 (gnus-group-position-point))
5870 (defun gnus-group-make-empty-virtual (group)
5871 "Create a new, fresh, empty virtual group."
5872 (interactive "sCreate new, empty virtual group: ")
5873 (let* ((method (list 'nnvirtual "^$"))
5874 (pgroup (gnus-group-prefixed-name group method)))
5875 ;; Check whether it exists already.
5876 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5877 (error "Group %s already exists." pgroup))
5878 ;; Subscribe the new group after the group on the current line.
5879 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5880 (gnus-group-update-group pgroup)
5882 (gnus-group-position-point)))
5884 (defun gnus-group-enter-directory (dir)
5885 "Enter an ephemeral nneething group."
5886 (interactive "DDirectory to read: ")
5887 (let* ((method (list 'nneething dir))
5888 (leaf (gnus-group-prefixed-name
5889 (file-name-nondirectory (directory-file-name dir))
5891 (name (gnus-generate-new-group-name leaf)))
5892 (let ((nneething-read-only t))
5893 (or (gnus-group-read-ephemeral-group
5895 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5897 (error "Couldn't enter %s" dir)))))
5899 ;; Group sorting commands
5900 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5902 (defun gnus-group-sort-groups (func &optional reverse)
5903 "Sort the group buffer according to FUNC.
5904 If REVERSE, reverse the sorting order."
5905 (interactive (list gnus-group-sort-function
5906 current-prefix-arg))
5908 ((not (listp func)) func)
5910 ((= 1 (length func)) (car func))
5912 ,(gnus-make-sort-function
5913 (reverse func)))))))
5914 ;; We peel off the dummy group from the alist.
5916 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5917 (pop gnus-newsrc-alist))
5919 (setq gnus-newsrc-alist
5920 (sort gnus-newsrc-alist func))
5922 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5923 ;; Regenerate the hash table.
5924 (gnus-make-hashtable-from-newsrc-alist)
5925 (gnus-group-list-groups))))
5927 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5928 "Sort the group buffer alphabetically by group name.
5929 If REVERSE, sort in reverse order."
5931 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5933 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5934 "Sort the group buffer by number of unread articles.
5935 If REVERSE, sort in reverse order."
5937 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5939 (defun gnus-group-sort-groups-by-level (&optional reverse)
5940 "Sort the group buffer by group level.
5941 If REVERSE, sort in reverse order."
5943 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5945 (defun gnus-group-sort-groups-by-score (&optional reverse)
5946 "Sort the group buffer by group score.
5947 If REVERSE, sort in reverse order."
5949 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5951 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5952 "Sort the group buffer by group rank.
5953 If REVERSE, sort in reverse order."
5955 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5957 (defun gnus-group-sort-groups-by-method (&optional reverse)
5958 "Sort the group buffer alphabetically by backend name.
5959 If REVERSE, sort in reverse order."
5961 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5963 (defun gnus-group-sort-by-alphabet (info1 info2)
5964 "Sort alphabetically."
5965 (string< (gnus-info-group info1) (gnus-info-group info2)))
5967 (defun gnus-group-sort-by-unread (info1 info2)
5968 "Sort by number of unread articles."
5969 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5970 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5971 (< (or (and (numberp n1) n1) 0)
5972 (or (and (numberp n2) n2) 0))))
5974 (defun gnus-group-sort-by-level (info1 info2)
5976 (< (gnus-info-level info1) (gnus-info-level info2)))
5978 (defun gnus-group-sort-by-method (info1 info2)
5979 "Sort alphabetically by backend name."
5980 (string< (symbol-name (car (gnus-find-method-for-group
5981 (gnus-info-group info1) info1)))
5982 (symbol-name (car (gnus-find-method-for-group
5983 (gnus-info-group info2) info2)))))
5985 (defun gnus-group-sort-by-score (info1 info2)
5986 "Sort by group score."
5987 (< (gnus-info-score info1) (gnus-info-score info2)))
5989 (defun gnus-group-sort-by-rank (info1 info2)
5990 "Sort by level and score."
5991 (let ((level1 (gnus-info-level info1))
5992 (level2 (gnus-info-level info2)))
5993 (or (< level1 level2)
5994 (and (= level1 level2)
5995 (> (gnus-info-score info1) (gnus-info-score info2))))))
5997 ;; Group catching up.
5999 (defun gnus-group-clear-data (n)
6000 "Clear all marks and read ranges from the current group."
6002 (let ((groups (gnus-group-process-prefix n))
6004 (while (setq group (pop groups))
6005 (setq info (gnus-get-info group))
6006 (gnus-info-set-read info nil)
6007 (when (gnus-info-marks info)
6008 (gnus-info-set-marks info nil))
6009 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6010 (when (gnus-group-goto-group group)
6011 (gnus-group-remove-mark group)
6012 (gnus-group-update-group-line)))))
6014 (defun gnus-group-catchup-current (&optional n all)
6015 "Mark all articles not marked as unread in current newsgroup as read.
6016 If prefix argument N is numeric, the ARG next newsgroups will be
6017 caught up. If ALL is non-nil, marked articles will also be marked as
6018 read. Cross references (Xref: header) of articles are ignored.
6019 The difference between N and actual number of newsgroups that were
6020 caught up is returned."
6022 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6026 "Do you really want to mark all articles as read? "
6027 "Mark all unread articles as read? "))))
6029 (let ((groups (gnus-group-process-prefix n))
6032 ;; Virtual groups have to be given special treatment.
6033 (let ((method (gnus-find-method-for-group (car groups))))
6034 (if (eq 'nnvirtual (car method))
6035 (nnvirtual-catchup-group
6036 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6037 (gnus-group-remove-mark (car groups))
6038 (if (>= (gnus-group-group-level) gnus-level-zombie)
6039 (gnus-message 2 "Dead groups can't be caught up")
6041 (gnus-group-goto-group (car groups))
6042 (gnus-group-catchup (car groups) all))
6043 (gnus-group-update-group-line)
6044 (setq ret (1+ ret))))
6045 (setq groups (cdr groups)))
6046 (gnus-group-next-unread-group 1)
6049 (defun gnus-group-catchup-current-all (&optional n)
6050 "Mark all articles in current newsgroup as read.
6051 Cross references (Xref: header) of articles are ignored."
6053 (gnus-group-catchup-current n 'all))
6055 (defun gnus-group-catchup (group &optional all)
6056 "Mark all articles in GROUP as read.
6057 If ALL is non-nil, all articles are marked as read.
6058 The return value is the number of articles that were marked as read,
6059 or nil if no action could be taken."
6060 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6062 ;; Do the updating only if the newsgroup isn't killed.
6063 (if (not (numberp (car entry)))
6064 (gnus-message 1 "Can't catch up; non-active group")
6065 ;; Do auto-expirable marks if that's required.
6066 (when (gnus-group-auto-expirable-p group)
6067 (gnus-add-marked-articles
6068 group 'expire (gnus-list-of-unread-articles group))
6070 (let ((marks (nth 3 (nth 2 entry))))
6071 (gnus-add-marked-articles
6072 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6073 (gnus-add-marked-articles
6074 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6076 (gnus-update-read-articles group nil)
6077 ;; Also nix out the lists of marks and dormants.
6079 (gnus-add-marked-articles group 'tick nil nil 'force)
6080 (gnus-add-marked-articles group 'dormant nil nil 'force))
6081 (run-hooks 'gnus-group-catchup-group-hook)
6084 (defun gnus-group-expire-articles (&optional n)
6085 "Expire all expirable articles in the current newsgroup."
6087 (let ((groups (gnus-group-process-prefix n))
6090 (error "No groups to expire"))
6091 (while (setq group (pop groups))
6092 (gnus-group-remove-mark group)
6093 (when (gnus-check-backend-function 'request-expire-articles group)
6094 (gnus-message 6 "Expiring articles in %s..." group)
6095 (let* ((info (gnus-get-info group))
6096 (expirable (if (gnus-group-total-expirable-p group)
6097 (cons nil (gnus-list-of-read-articles group))
6098 (assq 'expire (gnus-info-marks info))))
6099 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6103 (gnus-compress-sequence
6105 ;; We set the expiry variables to the groupp
6107 (let ((nnmail-expiry-wait-function nil)
6108 (nnmail-expiry-wait expiry-wait))
6109 (gnus-request-expire-articles
6110 (gnus-uncompress-sequence (cdr expirable)) group))
6111 ;; Just expire using the normal expiry values.
6112 (gnus-request-expire-articles
6113 (gnus-uncompress-sequence (cdr expirable)) group)))))
6114 (gnus-message 6 "Expiring articles in %s...done" group)))
6115 (gnus-group-position-point))))
6117 (defun gnus-group-expire-all-groups ()
6118 "Expire all expirable articles in all newsgroups."
6121 (gnus-message 5 "Expiring...")
6122 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6123 (cdr gnus-newsrc-alist))))
6124 (gnus-group-expire-articles nil)))
6125 (gnus-group-position-point)
6126 (gnus-message 5 "Expiring...done"))
6128 (defun gnus-group-set-current-level (n level)
6129 "Set the level of the next N groups to LEVEL."
6134 (let ((s (read-string
6135 (format "Level (default %s): "
6136 (or (gnus-group-group-level)
6137 gnus-level-default-subscribed)))))
6138 (if (string-match "^\\s-*$" s)
6139 (int-to-string (or (gnus-group-group-level)
6140 gnus-level-default-subscribed))
6142 (or (and (>= level 1) (<= level gnus-level-killed))
6143 (error "Illegal level: %d" level))
6144 (let ((groups (gnus-group-process-prefix n))
6146 (while (setq group (pop groups))
6147 (gnus-group-remove-mark group)
6148 (gnus-message 6 "Changed level of %s from %d to %d"
6149 group (or (gnus-group-group-level) gnus-level-killed)
6151 (gnus-group-change-level
6152 group level (or (gnus-group-group-level) gnus-level-killed))
6153 (gnus-group-update-group-line)))
6154 (gnus-group-position-point))
6156 (defun gnus-group-unsubscribe-current-group (&optional n)
6157 "Toggle subscription of the current group.
6158 If given numerical prefix, toggle the N next groups."
6160 (let ((groups (gnus-group-process-prefix n))
6163 (setq group (car groups)
6164 groups (cdr groups))
6165 (gnus-group-remove-mark group)
6166 (gnus-group-unsubscribe-group
6167 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6168 gnus-level-default-unsubscribed
6169 gnus-level-default-subscribed) t)
6170 (gnus-group-update-group-line))
6171 (gnus-group-next-group 1)))
6173 (defun gnus-group-unsubscribe-group (group &optional level silent)
6174 "Toggle subscription to GROUP.
6175 Killed newsgroups are subscribed. If SILENT, don't try to update the
6178 (list (completing-read
6179 "Group: " gnus-active-hashtb nil
6180 (gnus-read-active-file-p)
6182 'gnus-group-history)))
6183 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6185 ((string-match "^[ \t]$" group)
6186 (error "Empty group name"))
6188 ;; Toggle subscription flag.
6189 (gnus-group-change-level
6190 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6191 gnus-level-subscribed)
6192 (1+ gnus-level-subscribed)
6193 gnus-level-default-subscribed)))
6195 (gnus-group-update-group group)))
6196 ((and (stringp group)
6197 (or (not (gnus-read-active-file-p))
6198 (gnus-active group)))
6199 ;; Add new newsgroup.
6200 (gnus-group-change-level
6202 (if level level gnus-level-default-subscribed)
6203 (or (and (member group gnus-zombie-list)
6206 (and (gnus-group-group-name)
6207 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6209 (gnus-group-update-group group)))
6210 (t (error "No such newsgroup: %s" group)))
6211 (gnus-group-position-point)))
6213 (defun gnus-group-transpose-groups (n)
6214 "Move the current newsgroup up N places.
6215 If given a negative prefix, move down instead. The difference between
6216 N and the number of steps taken is returned."
6218 (or (gnus-group-group-name)
6219 (error "No group on current line"))
6220 (gnus-group-kill-group 1)
6222 (forward-line (- n))
6223 (gnus-group-yank-group)
6224 (gnus-group-position-point)))
6226 (defun gnus-group-kill-all-zombies ()
6227 "Kill all zombie newsgroups."
6229 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6230 (setq gnus-zombie-list nil)
6231 (gnus-group-list-groups))
6233 (defun gnus-group-kill-region (begin end)
6234 "Kill newsgroups in current region (excluding current point).
6235 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6250 (beginning-of-line) ;Important when LINES < 1
6251 (gnus-group-kill-group lines)))
6253 (defun gnus-group-kill-group (&optional n discard)
6254 "Kill the next N groups.
6255 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6256 However, only groups that were alive can be yanked; already killed
6257 groups or zombie groups can't be yanked.
6258 The return value is the name of the group that was killed, or a list
6261 (let ((buffer-read-only nil)
6262 (groups (gnus-group-process-prefix n))
6263 group entry level out)
6264 (if (< (length groups) 10)
6265 ;; This is faster when there are few groups.
6267 (push (setq group (pop groups)) out)
6268 (gnus-group-remove-mark group)
6269 (setq level (gnus-group-group-level))
6271 (when (and (not discard)
6272 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6273 (push (cons (car entry) (nth 2 entry))
6274 gnus-list-of-killed-groups))
6275 (gnus-group-change-level
6276 (if entry entry group) gnus-level-killed (if entry nil level)))
6277 ;; If there are lots and lots of groups to be killed, we use
6278 ;; this thing instead.
6280 (setq groups (nreverse groups))
6282 (gnus-group-remove-mark (setq group (pop groups)))
6285 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6286 (push (cons (car entry) (nth 2 entry))
6287 gnus-list-of-killed-groups)
6288 (setcdr (cdr entry) (cdddr entry)))
6289 ((member group gnus-zombie-list)
6290 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6291 (gnus-make-hashtable-from-newsrc-alist)))
6293 (gnus-group-position-point)
6294 (if (< (length out) 2) (car out) (nreverse out))))
6296 (defun gnus-group-yank-group (&optional arg)
6297 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6298 inserting it before the current newsgroup. The numeric ARG specifies
6299 how many newsgroups are to be yanked. The name of the newsgroup yanked
6300 is returned, or (if several groups are yanked) a list of yanked groups
6303 (setq arg (or arg 1))
6304 (let (info group prev out)
6305 (while (>= (decf arg) 0)
6306 (if (not (setq info (pop gnus-list-of-killed-groups)))
6307 (error "No more newsgroups to yank"))
6308 (push (setq group (nth 1 info)) out)
6309 ;; Find which newsgroup to insert this one before - search
6310 ;; backward until something suitable is found. If there are no
6311 ;; other newsgroups in this buffer, just make this newsgroup the
6313 (setq prev (gnus-group-group-name))
6314 (gnus-group-change-level
6315 info (gnus-info-level (cdr info)) gnus-level-killed
6316 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6318 (gnus-group-insert-group-line-info group))
6320 (gnus-group-position-point)
6321 (if (< (length out) 2) (car out) (nreverse out))))
6323 (defun gnus-group-kill-level (level)
6324 "Kill all groups that is on a certain LEVEL."
6325 (interactive "nKill all groups on level: ")
6327 ((= level gnus-level-zombie)
6328 (setq gnus-killed-list
6329 (nconc gnus-zombie-list gnus-killed-list))
6330 (setq gnus-zombie-list nil))
6331 ((and (< level gnus-level-zombie)
6333 (or gnus-expert-user
6336 "Do you really want to kill all groups on level %d? "
6338 (let* ((prev gnus-newsrc-alist)
6341 (if (= (gnus-info-level level) level)
6342 (setcdr prev (cdr alist))
6344 (setq alist (cdr alist)))
6345 (gnus-make-hashtable-from-newsrc-alist)
6346 (gnus-group-list-groups)))
6348 (error "Can't kill; illegal level: %d" level))))
6350 (defun gnus-group-list-all-groups (&optional arg)
6351 "List all newsgroups with level ARG or lower.
6352 Default is gnus-level-unsubscribed, which lists all subscribed and most
6353 unsubscribed groups."
6355 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6357 ;; Redefine this to list ALL killed groups if prefix arg used.
6358 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6359 (defun gnus-group-list-killed (&optional arg)
6360 "List all killed newsgroups in the group buffer.
6361 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6362 entail asking the server for the groups."
6364 ;; Find all possible killed newsgroups if arg.
6366 (gnus-get-killed-groups))
6367 (if (not gnus-killed-list)
6368 (gnus-message 6 "No killed groups")
6369 (let (gnus-group-list-mode)
6370 (funcall gnus-group-prepare-function
6371 gnus-level-killed t gnus-level-killed))
6372 (goto-char (point-min)))
6373 (gnus-group-position-point))
6375 (defun gnus-group-list-zombies ()
6376 "List all zombie newsgroups in the group buffer."
6378 (if (not gnus-zombie-list)
6379 (gnus-message 6 "No zombie groups")
6380 (let (gnus-group-list-mode)
6381 (funcall gnus-group-prepare-function
6382 gnus-level-zombie t gnus-level-zombie))
6383 (goto-char (point-min)))
6384 (gnus-group-position-point))
6386 (defun gnus-group-list-active ()
6387 "List all groups that are available from the server(s)."
6389 ;; First we make sure that we have really read the active file.
6390 (unless (gnus-read-active-file-p)
6391 (let ((gnus-read-active-file t))
6392 (gnus-read-active-file)))
6393 ;; Find all groups and sort them.
6401 (setq list (cons (symbol-name sym) list))))
6405 (buffer-read-only nil))
6408 (gnus-group-insert-group-line-info (pop groups)))
6409 (goto-char (point-min))))
6411 (defun gnus-activate-all-groups (level)
6412 "Activate absolutely all groups."
6413 (interactive (list 7))
6414 (let ((gnus-activate-level level)
6415 (gnus-activate-foreign-newsgroups level))
6416 (gnus-group-get-new-news)))
6418 (defun gnus-group-get-new-news (&optional arg)
6419 "Get newly arrived articles.
6420 If ARG is a number, it specifies which levels you are interested in
6421 re-scanning. If ARG is non-nil and not a number, this will force
6422 \"hard\" re-reading of the active files from all servers."
6424 (run-hooks 'gnus-get-new-news-hook)
6425 ;; We might read in new NoCeM messages here.
6426 (when (and gnus-use-nocem
6428 (gnus-nocem-scan-groups))
6429 ;; If ARG is not a number, then we read the active file.
6430 (when (and arg (not (numberp arg)))
6431 (let ((gnus-read-active-file t))
6432 (gnus-read-active-file))
6435 (setq arg (gnus-group-default-level arg t))
6436 (if (and gnus-read-active-file (not arg))
6438 (gnus-read-active-file)
6439 (gnus-get-unread-articles arg))
6440 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6441 (gnus-get-unread-articles arg)))
6442 (run-hooks 'gnus-after-getting-new-news-hook)
6443 (gnus-group-list-groups))
6445 (defun gnus-group-get-new-news-this-group (&optional n)
6446 "Check for newly arrived news in the current group (and the N-1 next groups).
6447 The difference between N and the number of newsgroup checked is returned.
6448 If N is negative, this group and the N-1 previous groups will be checked."
6450 (let* ((groups (gnus-group-process-prefix n))
6451 (ret (if (numberp n) (- n (length groups)) 0))
6452 (beg (unless n (point)))
6454 (while (setq group (pop groups))
6455 (gnus-group-remove-mark group)
6456 (if (gnus-activate-group group 'scan)
6458 (gnus-get-unread-articles-in-group
6459 (gnus-get-info group) (gnus-active group) t)
6460 (unless (gnus-virtual-group-p group)
6461 (gnus-close-group group))
6462 (gnus-group-update-group group))
6463 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6464 (when beg (goto-char beg))
6465 (when gnus-goto-next-group-when-activating
6466 (gnus-group-next-unread-group 1 t))
6467 (gnus-summary-position-point)
6470 (defun gnus-group-fetch-faq (group &optional faq-dir)
6471 "Fetch the FAQ for the current group."
6474 (gnus-group-real-name (gnus-group-group-name))
6475 (cond (current-prefix-arg
6477 "Faq dir: " (and (listp gnus-group-faq-directory)
6478 gnus-group-faq-directory))))))
6480 (setq faq-dir (if (listp gnus-group-faq-directory)
6481 (car gnus-group-faq-directory)
6482 gnus-group-faq-directory)))
6483 (or group (error "No group name given"))
6484 (let ((file (concat (file-name-as-directory faq-dir)
6485 (gnus-group-real-name group))))
6486 (if (not (file-exists-p file))
6487 (error "No such file: %s" file)
6490 (defun gnus-group-describe-group (force &optional group)
6491 "Display a description of the current newsgroup."
6492 (interactive (list current-prefix-arg (gnus-group-group-name)))
6493 (and force (setq gnus-description-hashtb nil))
6494 (let ((method (gnus-find-method-for-group group))
6496 (or group (error "No group name given"))
6497 (and (or (and gnus-description-hashtb
6498 ;; We check whether this group's method has been
6499 ;; queried for a description file.
6501 (gnus-group-prefixed-name "" method)
6502 gnus-description-hashtb))
6503 (setq desc (gnus-group-get-description group))
6504 (gnus-read-descriptions-file method))
6506 (or desc (gnus-gethash group gnus-description-hashtb)
6507 "No description available")))))
6509 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6510 (defun gnus-group-describe-all-groups (&optional force)
6511 "Pop up a buffer with descriptions of all newsgroups."
6513 (and force (setq gnus-description-hashtb nil))
6514 (if (not (or gnus-description-hashtb
6515 (gnus-read-all-descriptions-files)))
6516 (error "Couldn't request descriptions file"))
6517 (let ((buffer-read-only nil)
6523 (insert (format " *: %-20s %s\n" (symbol-name group)
6524 (symbol-value group)))
6525 (gnus-add-text-properties
6526 b (1+ b) (list 'gnus-group group
6527 'gnus-unread t 'gnus-marked nil
6528 'gnus-level (1+ gnus-level-subscribed))))
6529 gnus-description-hashtb)
6530 (goto-char (point-min))
6531 (gnus-group-position-point)))
6533 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6534 (defun gnus-group-apropos (regexp &optional search-description)
6535 "List all newsgroups that have names that match a regexp."
6536 (interactive "sGnus apropos (regexp): ")
6538 (obuf (current-buffer))
6540 ;; Go through all newsgroups that are known to Gnus.
6543 (and (symbol-name group)
6544 (string-match regexp (symbol-name group))
6545 (setq groups (cons (symbol-name group) groups))))
6547 ;; Also go through all descriptions that are known to Gnus.
6548 (when search-description
6551 (and (string-match regexp (symbol-value group))
6552 (gnus-active (symbol-name group))
6553 (setq groups (cons (symbol-name group) groups))))
6554 gnus-description-hashtb))
6556 (gnus-message 3 "No groups matched \"%s\"." regexp)
6557 ;; Print out all the groups.
6559 (pop-to-buffer "*Gnus Help*")
6560 (buffer-disable-undo (current-buffer))
6562 (setq groups (sort groups 'string<))
6564 ;; Groups may be entered twice into the list of groups.
6565 (if (not (string= (car groups) prev))
6567 (insert (setq prev (car groups)) "\n")
6568 (if (and gnus-description-hashtb
6569 (setq des (gnus-gethash (car groups)
6570 gnus-description-hashtb)))
6571 (insert " " des "\n"))))
6572 (setq groups (cdr groups)))
6573 (goto-char (point-min))))
6574 (pop-to-buffer obuf)))
6576 (defun gnus-group-description-apropos (regexp)
6577 "List all newsgroups that have names or descriptions that match a regexp."
6578 (interactive "sGnus description apropos (regexp): ")
6579 (if (not (or gnus-description-hashtb
6580 (gnus-read-all-descriptions-files)))
6581 (error "Couldn't request descriptions file"))
6582 (gnus-group-apropos regexp t))
6584 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6585 (defun gnus-group-list-matching (level regexp &optional all lowest)
6586 "List all groups with unread articles that match REGEXP.
6587 If the prefix LEVEL is non-nil, it should be a number that says which
6588 level to cut off listing groups.
6589 If ALL, also list groups with no unread articles.
6590 If LOWEST, don't list groups with level lower than LOWEST.
6592 This command may read the active file."
6593 (interactive "P\nsList newsgroups matching: ")
6594 ;; First make sure active file has been read.
6596 (>= (prefix-numeric-value level) gnus-level-killed))
6597 (gnus-get-killed-groups))
6598 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6599 all (or lowest 1) regexp)
6600 (goto-char (point-min))
6601 (gnus-group-position-point))
6603 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6604 "List all groups that match REGEXP.
6605 If the prefix LEVEL is non-nil, it should be a number that says which
6606 level to cut off listing groups.
6607 If LOWEST, don't list groups with level lower than LOWEST."
6608 (interactive "P\nsList newsgroups matching: ")
6609 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6611 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6612 (defun gnus-group-save-newsrc (&optional force)
6613 "Save the Gnus startup files.
6614 If FORCE, force saving whether it is necessary or not."
6616 (gnus-save-newsrc-file force))
6618 (defun gnus-group-restart (&optional arg)
6619 "Force Gnus to read the .newsrc file."
6621 (when (gnus-yes-or-no-p
6622 (format "Are you sure you want to read %s? "
6623 gnus-current-startup-file))
6624 (gnus-save-newsrc-file)
6625 (gnus-setup-news 'force)
6626 (gnus-group-list-groups arg)))
6628 (defun gnus-group-read-init-file ()
6629 "Read the Gnus elisp init file."
6631 (gnus-read-init-file))
6633 (defun gnus-group-check-bogus-groups (&optional silent)
6634 "Check bogus newsgroups.
6635 If given a prefix, don't ask for confirmation before removing a bogus
6638 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6639 (gnus-group-list-groups))
6641 (defun gnus-group-edit-global-kill (&optional article group)
6642 "Edit the global kill file.
6643 If GROUP, edit that local kill file instead."
6645 (setq gnus-current-kill-article article)
6646 (gnus-kill-file-edit-file group)
6649 (substitute-command-keys
6650 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6651 (if group "local" "global")))))
6653 (defun gnus-group-edit-local-kill (article group)
6654 "Edit a local kill file."
6655 (interactive (list nil (gnus-group-group-name)))
6656 (gnus-group-edit-global-kill article group))
6658 (defun gnus-group-force-update ()
6659 "Update `.newsrc' file."
6661 (gnus-save-newsrc-file))
6663 (defun gnus-group-suspend ()
6664 "Suspend the current Gnus session.
6665 In fact, cleanup buffers except for group mode buffer.
6666 The hook gnus-suspend-gnus-hook is called before actually suspending."
6668 (run-hooks 'gnus-suspend-gnus-hook)
6669 ;; Kill Gnus buffers except for group mode buffer.
6670 (let ((group-buf (get-buffer gnus-group-buffer)))
6671 ;; Do this on a separate list in case the user does a ^G before we finish
6672 (let ((gnus-buffer-list
6673 (delq group-buf (delq gnus-dribble-buffer
6674 (append gnus-buffer-list nil)))))
6675 (while gnus-buffer-list
6676 (gnus-kill-buffer (car gnus-buffer-list))
6677 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6680 (setq gnus-buffer-list (list group-buf))
6681 (bury-buffer group-buf)
6682 (delete-windows-on group-buf t)))))
6684 (defun gnus-group-clear-dribble ()
6685 "Clear all information from the dribble buffer."
6687 (gnus-dribble-clear)
6688 (gnus-message 7 "Cleared dribble buffer"))
6690 (defun gnus-group-exit ()
6691 "Quit reading news after updating .newsrc.eld and .newsrc.
6692 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6695 (or noninteractive ;For gnus-batch-kill
6696 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6697 (not gnus-interactive-exit) ;Without confirmation
6699 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6700 (run-hooks 'gnus-exit-gnus-hook)
6701 ;; Offer to save data from non-quitted summary buffers.
6702 (gnus-offer-save-summaries)
6703 ;; Save the newsrc file(s).
6704 (gnus-save-newsrc-file)
6706 (gnus-close-backends)
6707 ;; Reset everything.
6709 ;; Allow the user to do things after cleaning up.
6710 (run-hooks 'gnus-after-exiting-gnus-hook)))
6712 (defun gnus-close-backends ()
6713 ;; Send a close request to all backends that support such a request.
6714 (let ((methods gnus-valid-select-methods)
6717 (if (fboundp (setq func (intern (concat (caar methods)
6718 "-request-close"))))
6720 (setq methods (cdr methods)))))
6722 (defun gnus-group-quit ()
6723 "Quit reading news without updating .newsrc.eld or .newsrc.
6724 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6726 (when (or noninteractive ;For gnus-batch-kill
6727 (zerop (buffer-size))
6728 (not (gnus-server-opened gnus-select-method))
6730 (not gnus-current-startup-file)
6732 (format "Quit reading news without saving %s? "
6733 (file-name-nondirectory gnus-current-startup-file))))
6734 (run-hooks 'gnus-exit-gnus-hook)
6735 (if gnus-use-full-window
6736 (delete-other-windows)
6737 (gnus-remove-some-windows))
6739 (gnus-close-backends)
6741 ;; Allow the user to do things after cleaning up.
6742 (run-hooks 'gnus-after-exiting-gnus-hook)))
6744 (defun gnus-offer-save-summaries ()
6745 "Offer to save all active summary buffers."
6747 (let ((buflist (buffer-list))
6749 ;; Go through all buffers and find all summaries.
6751 (and (setq bufname (buffer-name (car buflist)))
6752 (string-match "Summary" bufname)
6754 (set-buffer bufname)
6755 ;; We check that this is, indeed, a summary buffer.
6756 (and (eq major-mode 'gnus-summary-mode)
6757 ;; Also make sure this isn't bogus.
6758 gnus-newsgroup-prepared))
6759 (push bufname buffers))
6760 (setq buflist (cdr buflist)))
6761 ;; Go through all these summary buffers and offer to save them.
6764 "Update summary buffer %s? "
6765 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6768 (defun gnus-group-describe-briefly ()
6769 "Give a one line description of the group mode commands."
6771 (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")))
6773 (defun gnus-group-browse-foreign-server (method)
6774 "Browse a foreign news server.
6775 If called interactively, this function will ask for a select method
6776 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6777 If not, METHOD should be a list where the first element is the method
6778 and the second element is the address."
6780 (list (let ((how (completing-read
6782 (append gnus-valid-select-methods gnus-server-alist)
6783 nil t (cons "nntp" 0) 'gnus-method-history)))
6784 ;; We either got a backend name or a virtual server name.
6785 ;; If the first, we also need an address.
6786 (if (assoc how gnus-valid-select-methods)
6788 ;; Suggested by mapjph@bath.ac.uk.
6791 (mapcar (lambda (server) (list server))
6792 gnus-secondary-servers)))
6793 ;; We got a server name, so we find the method.
6794 (gnus-server-to-method how)))))
6795 (gnus-browse-foreign-server method))
6799 ;;; Gnus summary mode
6802 (defvar gnus-summary-mode-map nil)
6804 (put 'gnus-summary-mode 'mode-class 'special)
6806 (unless gnus-summary-mode-map
6807 (setq gnus-summary-mode-map (make-keymap))
6808 (suppress-keymap gnus-summary-mode-map)
6810 ;; Non-orthogonal keys
6812 (gnus-define-keys gnus-summary-mode-map
6813 " " gnus-summary-next-page
6814 "\177" gnus-summary-prev-page
6815 [delete] gnus-summary-prev-page
6816 "\r" gnus-summary-scroll-up
6817 "n" gnus-summary-next-unread-article
6818 "p" gnus-summary-prev-unread-article
6819 "N" gnus-summary-next-article
6820 "P" gnus-summary-prev-article
6821 "\M-\C-n" gnus-summary-next-same-subject
6822 "\M-\C-p" gnus-summary-prev-same-subject
6823 "\M-n" gnus-summary-next-unread-subject
6824 "\M-p" gnus-summary-prev-unread-subject
6825 "." gnus-summary-first-unread-article
6826 "," gnus-summary-best-unread-article
6827 "\M-s" gnus-summary-search-article-forward
6828 "\M-r" gnus-summary-search-article-backward
6829 "<" gnus-summary-beginning-of-article
6830 ">" gnus-summary-end-of-article
6831 "j" gnus-summary-goto-article
6832 "^" gnus-summary-refer-parent-article
6833 "\M-^" gnus-summary-refer-article
6834 "u" gnus-summary-tick-article-forward
6835 "!" gnus-summary-tick-article-forward
6836 "U" gnus-summary-tick-article-backward
6837 "d" gnus-summary-mark-as-read-forward
6838 "D" gnus-summary-mark-as-read-backward
6839 "E" gnus-summary-mark-as-expirable
6840 "\M-u" gnus-summary-clear-mark-forward
6841 "\M-U" gnus-summary-clear-mark-backward
6842 "k" gnus-summary-kill-same-subject-and-select
6843 "\C-k" gnus-summary-kill-same-subject
6844 "\M-\C-k" gnus-summary-kill-thread
6845 "\M-\C-l" gnus-summary-lower-thread
6846 "e" gnus-summary-edit-article
6847 "#" gnus-summary-mark-as-processable
6848 "\M-#" gnus-summary-unmark-as-processable
6849 "\M-\C-t" gnus-summary-toggle-threads
6850 "\M-\C-s" gnus-summary-show-thread
6851 "\M-\C-h" gnus-summary-hide-thread
6852 "\M-\C-f" gnus-summary-next-thread
6853 "\M-\C-b" gnus-summary-prev-thread
6854 "\M-\C-u" gnus-summary-up-thread
6855 "\M-\C-d" gnus-summary-down-thread
6856 "&" gnus-summary-execute-command
6857 "c" gnus-summary-catchup-and-exit
6858 "\C-w" gnus-summary-mark-region-as-read
6859 "\C-t" gnus-summary-toggle-truncation
6860 "?" gnus-summary-mark-as-dormant
6861 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6862 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6863 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6864 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6865 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6866 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6867 "=" gnus-summary-expand-window
6868 "\C-x\C-s" gnus-summary-reselect-current-group
6869 "\M-g" gnus-summary-rescan-group
6870 "w" gnus-summary-stop-page-breaking
6871 "\C-c\C-r" gnus-summary-caesar-message
6872 "\M-t" gnus-summary-toggle-mime
6873 "f" gnus-summary-followup
6874 "F" gnus-summary-followup-with-original
6875 "C" gnus-summary-cancel-article
6876 "r" gnus-summary-reply
6877 "R" gnus-summary-reply-with-original
6878 "\C-c\C-f" gnus-summary-mail-forward
6879 "o" gnus-summary-save-article
6880 "\C-o" gnus-summary-save-article-mail
6881 "|" gnus-summary-pipe-output
6882 "\M-k" gnus-summary-edit-local-kill
6883 "\M-K" gnus-summary-edit-global-kill
6885 "\C-c\C-d" gnus-summary-describe-group
6886 "q" gnus-summary-exit
6887 "Q" gnus-summary-exit-no-update
6888 "\C-c\C-i" gnus-info-find-node
6889 gnus-mouse-2 gnus-mouse-pick-article
6890 "m" gnus-summary-mail-other-window
6891 "a" gnus-summary-post-news
6892 "x" gnus-summary-limit-to-unread
6893 "s" gnus-summary-isearch-article
6894 "t" gnus-article-hide-headers
6895 "g" gnus-summary-show-article
6896 "l" gnus-summary-goto-last-article
6897 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6898 "\C-d" gnus-summary-enter-digest-group
6900 "*" gnus-cache-enter-article
6901 "\M-*" gnus-cache-remove-article
6902 "\M-&" gnus-summary-universal-argument
6903 "\C-l" gnus-recenter
6904 "I" gnus-summary-increase-score
6905 "L" gnus-summary-lower-score
6907 "V" gnus-summary-score-map
6908 "X" gnus-uu-extract-map
6909 "S" gnus-summary-send-map)
6911 ;; Sort of orthogonal keymap
6912 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6913 "t" gnus-summary-tick-article-forward
6914 "!" gnus-summary-tick-article-forward
6915 "d" gnus-summary-mark-as-read-forward
6916 "r" gnus-summary-mark-as-read-forward
6917 "c" gnus-summary-clear-mark-forward
6918 " " gnus-summary-clear-mark-forward
6919 "e" gnus-summary-mark-as-expirable
6920 "x" gnus-summary-mark-as-expirable
6921 "?" gnus-summary-mark-as-dormant
6922 "b" gnus-summary-set-bookmark
6923 "B" gnus-summary-remove-bookmark
6924 "#" gnus-summary-mark-as-processable
6925 "\M-#" gnus-summary-unmark-as-processable
6926 "S" gnus-summary-limit-include-expunged
6927 "C" gnus-summary-catchup
6928 "H" gnus-summary-catchup-to-here
6929 "\C-c" gnus-summary-catchup-all
6930 "k" gnus-summary-kill-same-subject-and-select
6931 "K" gnus-summary-kill-same-subject
6932 "P" gnus-uu-mark-map)
6934 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6935 "c" gnus-summary-clear-above
6936 "u" gnus-summary-tick-above
6937 "m" gnus-summary-mark-above
6938 "k" gnus-summary-kill-below)
6940 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6941 "/" gnus-summary-limit-to-subject
6942 "n" gnus-summary-limit-to-articles
6943 "w" gnus-summary-pop-limit
6944 "s" gnus-summary-limit-to-subject
6945 "a" gnus-summary-limit-to-author
6946 "u" gnus-summary-limit-to-unread
6947 "m" gnus-summary-limit-to-marks
6948 "v" gnus-summary-limit-to-score
6949 "D" gnus-summary-limit-include-dormant
6950 "d" gnus-summary-limit-exclude-dormant
6951 ;; "t" gnus-summary-limit-exclude-thread
6952 "E" gnus-summary-limit-include-expunged
6953 "c" gnus-summary-limit-exclude-childless-dormant
6954 "C" gnus-summary-limit-mark-excluded-as-read)
6956 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6957 "n" gnus-summary-next-unread-article
6958 "p" gnus-summary-prev-unread-article
6959 "N" gnus-summary-next-article
6960 "P" gnus-summary-prev-article
6961 "\C-n" gnus-summary-next-same-subject
6962 "\C-p" gnus-summary-prev-same-subject
6963 "\M-n" gnus-summary-next-unread-subject
6964 "\M-p" gnus-summary-prev-unread-subject
6965 "f" gnus-summary-first-unread-article
6966 "b" gnus-summary-best-unread-article
6967 "j" gnus-summary-goto-article
6968 "g" gnus-summary-goto-subject
6969 "l" gnus-summary-goto-last-article
6970 "p" gnus-summary-pop-article)
6972 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6973 "k" gnus-summary-kill-thread
6974 "l" gnus-summary-lower-thread
6975 "i" gnus-summary-raise-thread
6976 "T" gnus-summary-toggle-threads
6977 "t" gnus-summary-rethread-current
6978 "^" gnus-summary-reparent-thread
6979 "s" gnus-summary-show-thread
6980 "S" gnus-summary-show-all-threads
6981 "h" gnus-summary-hide-thread
6982 "H" gnus-summary-hide-all-threads
6983 "n" gnus-summary-next-thread
6984 "p" gnus-summary-prev-thread
6985 "u" gnus-summary-up-thread
6986 "o" gnus-summary-top-thread
6987 "d" gnus-summary-down-thread
6988 "#" gnus-uu-mark-thread
6989 "\M-#" gnus-uu-unmark-thread)
6991 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6992 "c" gnus-summary-catchup-and-exit
6993 "C" gnus-summary-catchup-all-and-exit
6994 "E" gnus-summary-exit-no-update
6995 "Q" gnus-summary-exit
6996 "Z" gnus-summary-exit
6997 "n" gnus-summary-catchup-and-goto-next-group
6998 "R" gnus-summary-reselect-current-group
6999 "G" gnus-summary-rescan-group
7000 "N" gnus-summary-next-group
7001 "P" gnus-summary-prev-group)
7003 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7004 " " gnus-summary-next-page
7005 "n" gnus-summary-next-page
7006 "\177" gnus-summary-prev-page
7007 [delete] gnus-summary-prev-page
7008 "p" gnus-summary-prev-page
7009 "\r" gnus-summary-scroll-up
7010 "<" gnus-summary-beginning-of-article
7011 ">" gnus-summary-end-of-article
7012 "b" gnus-summary-beginning-of-article
7013 "e" gnus-summary-end-of-article
7014 "^" gnus-summary-refer-parent-article
7015 "r" gnus-summary-refer-parent-article
7016 "R" gnus-summary-refer-references
7017 "g" gnus-summary-show-article
7018 "s" gnus-summary-isearch-article)
7020 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7021 "b" gnus-article-add-buttons
7022 "B" gnus-article-add-buttons-to-head
7023 "o" gnus-article-treat-overstrike
7024 ;; "w" gnus-article-word-wrap
7025 "w" gnus-article-fill-cited-article
7026 "c" gnus-article-remove-cr
7027 "L" gnus-article-remove-trailing-blank-lines
7028 "q" gnus-article-de-quoted-unreadable
7029 "f" gnus-article-display-x-face
7030 "l" gnus-summary-stop-page-breaking
7031 "r" gnus-summary-caesar-message
7032 "t" gnus-article-hide-headers
7033 "v" gnus-summary-verbose-headers
7034 "m" gnus-summary-toggle-mime)
7036 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7037 "a" gnus-article-hide
7038 "h" gnus-article-hide-headers
7039 "b" gnus-article-hide-boring-headers
7040 "s" gnus-article-hide-signature
7041 "c" gnus-article-hide-citation
7042 "p" gnus-article-hide-pgp
7043 "\C-c" gnus-article-hide-citation-maybe)
7045 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7046 "a" gnus-article-highlight
7047 "h" gnus-article-highlight-headers
7048 "c" gnus-article-highlight-citation
7049 "s" gnus-article-highlight-signature)
7051 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7052 "z" gnus-article-date-ut
7053 "u" gnus-article-date-ut
7054 "l" gnus-article-date-local
7055 "e" gnus-article-date-lapsed
7056 "o" gnus-article-date-original)
7058 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7060 "f" gnus-summary-fetch-faq
7061 "d" gnus-summary-describe-group
7062 "h" gnus-summary-describe-briefly
7063 "i" gnus-info-find-node)
7065 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7066 "e" gnus-summary-expire-articles
7067 "\M-\C-e" gnus-summary-expire-articles-now
7068 "\177" gnus-summary-delete-article
7069 [delete] gnus-summary-delete-article
7070 "m" gnus-summary-move-article
7071 "r" gnus-summary-respool-article
7072 "w" gnus-summary-edit-article
7073 "c" gnus-summary-copy-article
7074 "B" gnus-summary-crosspost-article
7075 "q" gnus-summary-respool-query
7076 "i" gnus-summary-import-article)
7078 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7079 "o" gnus-summary-save-article
7080 "m" gnus-summary-save-article-mail
7081 "r" gnus-summary-save-article-rmail
7082 "f" gnus-summary-save-article-file
7083 "b" gnus-summary-save-article-body-file
7084 "h" gnus-summary-save-article-folder
7085 "v" gnus-summary-save-article-vm
7086 "p" gnus-summary-pipe-output
7087 "s" gnus-soup-add-article)
7092 (defun gnus-summary-mode (&optional group)
7093 "Major mode for reading articles.
7095 All normal editing commands are switched off.
7096 \\<gnus-summary-mode-map>
7097 Each line in this buffer represents one article. To read an
7098 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7099 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7102 You can also post articles and send mail from this buffer. To
7103 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7104 of an article, type `\\[gnus-summary-reply]'.
7106 There are approx. one gazillion commands you can execute in this
7107 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7109 The following commands are available:
7111 \\{gnus-summary-mode-map}"
7113 (when (and menu-bar-mode
7114 (gnus-visual-p 'summary-menu 'menu))
7115 (gnus-summary-make-menu-bar))
7116 (kill-all-local-variables)
7117 (let ((locals gnus-summary-local-variables))
7119 (if (consp (car locals))
7121 (make-local-variable (caar locals))
7122 (set (caar locals) (eval (cdar locals))))
7123 (make-local-variable (car locals))
7124 (set (car locals) nil))
7125 (setq locals (cdr locals))))
7126 (gnus-make-thread-indent-array)
7127 (gnus-simplify-mode-line)
7128 (setq major-mode 'gnus-summary-mode)
7129 (setq mode-name "Summary")
7130 (make-local-variable 'minor-mode-alist)
7131 (use-local-map gnus-summary-mode-map)
7132 (buffer-disable-undo (current-buffer))
7133 (setq buffer-read-only t) ;Disable modification
7134 (setq truncate-lines t)
7135 (setq selective-display t)
7136 (setq selective-display-ellipses t) ;Display `...'
7137 (setq buffer-display-table gnus-summary-display-table)
7138 (setq gnus-newsgroup-name group)
7139 (make-local-variable 'gnus-summary-line-format)
7140 (make-local-variable 'gnus-summary-line-format-spec)
7141 (make-local-variable 'gnus-summary-mark-positions)
7142 (run-hooks 'gnus-summary-mode-hook))
7144 (defun gnus-summary-make-display-table ()
7145 ;; Change the display table. Odd characters have a tendency to mess
7146 ;; up nicely formatted displays - we make all possible glyphs
7147 ;; display only a single character.
7149 ;; We start from the standard display table, if any.
7150 (setq gnus-summary-display-table
7151 (or (copy-sequence standard-display-table)
7152 (make-display-table)))
7153 ;; Nix out all the control chars...
7155 (while (>= (setq i (1- i)) 0)
7156 (aset gnus-summary-display-table i [??])))
7157 ;; ... but not newline and cr, of course. (cr is necessary for the
7158 ;; selective display).
7159 (aset gnus-summary-display-table ?\n nil)
7160 (aset gnus-summary-display-table ?\r nil)
7161 ;; We nix out any glyphs over 126 that are not set already.
7163 (while (>= (setq i (1- i)) 127)
7164 ;; Only modify if the entry is nil.
7165 (or (aref gnus-summary-display-table i)
7166 (aset gnus-summary-display-table i [??])))))
7168 (defun gnus-summary-clear-local-variables ()
7169 (let ((locals gnus-summary-local-variables))
7171 (if (consp (car locals))
7172 (and (vectorp (caar locals))
7173 (set (caar locals) nil))
7174 (and (vectorp (car locals))
7175 (set (car locals) nil)))
7176 (setq locals (cdr locals)))))
7178 ;; Summary data functions.
7180 (defmacro gnus-data-number (data)
7183 (defmacro gnus-data-set-number (data number)
7184 `(setcar ,data ,number))
7186 (defmacro gnus-data-mark (data)
7189 (defmacro gnus-data-set-mark (data mark)
7190 `(setcar (nthcdr 1 ,data) ,mark))
7192 (defmacro gnus-data-pos (data)
7195 (defmacro gnus-data-set-pos (data pos)
7196 `(setcar (nthcdr 2 ,data) ,pos))
7198 (defmacro gnus-data-header (data)
7201 (defmacro gnus-data-level (data)
7204 (defmacro gnus-data-unread-p (data)
7205 `(= (nth 1 ,data) gnus-unread-mark))
7207 (defmacro gnus-data-pseudo-p (data)
7208 `(consp (nth 3 ,data)))
7210 (defmacro gnus-data-find (number)
7211 `(assq ,number gnus-newsgroup-data))
7213 (defmacro gnus-data-find-list (number &optional data)
7214 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7215 (memq (assq ,number bdata)
7218 (defmacro gnus-data-make (number mark pos header level)
7219 `(list ,number ,mark ,pos ,header ,level))
7221 (defun gnus-data-enter (after-article number mark pos header level offset)
7222 (let ((data (gnus-data-find-list after-article)))
7223 (or data (error "No such article: %d" after-article))
7224 (setcdr data (cons (gnus-data-make number mark pos header level)
7226 (setq gnus-newsgroup-data-reverse nil)
7227 (gnus-data-update-list (cddr data) offset)))
7229 (defun gnus-data-enter-list (after-article list &optional offset)
7231 (let ((data (and after-article (gnus-data-find-list after-article)))
7233 (or data (not after-article) (error "No such article: %d" after-article))
7234 ;; Find the last element in the list to be spliced into the main
7237 (setq list (cdr list)))
7240 (setcdr list gnus-newsgroup-data)
7241 (setq gnus-newsgroup-data ilist)
7242 (and offset (gnus-data-update-list (cdr list) offset)))
7243 (setcdr list (cdr data))
7245 (and offset (gnus-data-update-list (cdr data) offset)))
7246 (setq gnus-newsgroup-data-reverse nil))))
7248 (defun gnus-data-remove (article &optional offset)
7249 (let ((data gnus-newsgroup-data))
7250 (if (= (gnus-data-number (car data)) article)
7251 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7252 gnus-newsgroup-data-reverse nil)
7254 (and (= (gnus-data-number (cadr data)) article)
7256 (setcdr data (cddr data))
7257 (and offset (gnus-data-update-list (cdr data) offset))
7259 gnus-newsgroup-data-reverse nil)))
7260 (setq data (cdr data))))))
7262 (defmacro gnus-data-list (backward)
7264 (or gnus-newsgroup-data-reverse
7265 (setq gnus-newsgroup-data-reverse
7266 (reverse gnus-newsgroup-data)))
7267 gnus-newsgroup-data))
7269 (defun gnus-data-update-list (data offset)
7270 "Add OFFSET to the POS of all data entries in DATA."
7272 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7273 (setq data (cdr data))))
7275 (defun gnus-data-compute-positions ()
7276 "Compute the positions of all articles."
7277 (let ((data gnus-newsgroup-data)
7280 (when (setq pos (text-property-any
7281 (point-min) (point-max)
7282 'gnus-number (gnus-data-number (car data))))
7283 (gnus-data-set-pos (car data) (+ pos 3)))
7284 (setq data (cdr data)))))
7286 (defun gnus-summary-article-pseudo-p (article)
7287 "Say whether this article is a pseudo article or not."
7288 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7290 (defun gnus-article-parent-p (number)
7291 "Say whether this article is a parent or not."
7292 (let ((data (gnus-data-find-list number)))
7293 (and (cdr data) ; There has to be an article after...
7294 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7295 (gnus-data-level (nth 1 data))))))
7297 (defun gnus-article-children (number)
7298 "Return a list of all children to NUMBER."
7299 (let* ((data (gnus-data-find-list number))
7300 (level (gnus-data-level (car data)))
7302 (setq data (cdr data))
7304 (= (gnus-data-level (car data)) (1+ level)))
7305 (push (gnus-data-number (car data)) children)
7306 (setq data (cdr data)))
7309 (defmacro gnus-summary-skip-intangible ()
7310 "If the current article is intangible, then jump to a different article."
7311 '(let ((to (get-text-property (point) 'gnus-intangible)))
7312 (and to (gnus-summary-goto-subject to))))
7314 (defmacro gnus-summary-article-intangible-p ()
7315 "Say whether this article is intangible or not."
7316 '(get-text-property (point) 'gnus-intangible))
7318 ;; Some summary mode macros.
7320 (defmacro gnus-summary-article-number ()
7321 "The article number of the article on the current line.
7322 If there isn's an article number here, then we return the current
7325 (gnus-summary-skip-intangible)
7326 (or (get-text-property (point) 'gnus-number)
7327 (gnus-summary-last-subject))))
7329 (defmacro gnus-summary-article-header (&optional number)
7330 `(gnus-data-header (gnus-data-find
7331 ,(or number '(gnus-summary-article-number)))))
7333 (defmacro gnus-summary-thread-level (&optional number)
7334 `(if (and (eq gnus-summary-make-false-root 'dummy)
7335 (get-text-property (point) 'gnus-intangible))
7337 (gnus-data-level (gnus-data-find
7338 ,(or number '(gnus-summary-article-number))))))
7340 (defmacro gnus-summary-article-mark (&optional number)
7341 `(gnus-data-mark (gnus-data-find
7342 ,(or number '(gnus-summary-article-number)))))
7344 (defmacro gnus-summary-article-pos (&optional number)
7345 `(gnus-data-pos (gnus-data-find
7346 ,(or number '(gnus-summary-article-number)))))
7348 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7349 (defmacro gnus-summary-article-subject (&optional number)
7350 "Return current subject string or nil if nothing."
7353 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7354 '(gnus-data-header (assq (gnus-summary-article-number)
7355 gnus-newsgroup-data)))))
7358 (mail-header-subject headers))))
7360 (defmacro gnus-summary-article-score (&optional number)
7361 "Return current article score."
7362 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7363 gnus-newsgroup-scored))
7364 gnus-summary-default-score 0))
7366 (defun gnus-summary-article-children (&optional number)
7367 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7368 (level (gnus-data-level (car data)))
7370 (while (and (setq data (cdr data))
7371 (> (setq l (gnus-data-level (car data))) level))
7372 (and (= (1+ level) l)
7373 (setq children (cons (gnus-data-number (car data))
7375 (nreverse children)))
7377 (defun gnus-summary-article-parent (&optional number)
7378 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7379 (gnus-data-list t)))
7380 (level (gnus-data-level (car data))))
7382 () ; This is a root.
7383 ;; We search until we find an article with a level less than
7384 ;; this one. That function has to be the parent.
7385 (while (and (setq data (cdr data))
7386 (not (< (gnus-data-level (car data)) level))))
7387 (and data (gnus-data-number (car data))))))
7389 (defun gnus-unread-mark-p (mark)
7390 "Say whether MARK is the unread mark."
7391 (= mark gnus-unread-mark))
7393 (defun gnus-read-mark-p (mark)
7394 "Say whether MARK is one of the marks that mark as read.
7395 This is all marks except unread, ticked, dormant, and expirable."
7396 (not (or (= mark gnus-unread-mark)
7397 (= mark gnus-ticked-mark)
7398 (= mark gnus-dormant-mark)
7399 (= mark gnus-expirable-mark))))
7401 ;; Saving hidden threads.
7403 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7404 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7406 (defmacro gnus-save-hidden-threads (&rest forms)
7407 "Save hidden threads, eval FORMS, and restore the hidden threads."
7408 (let ((config (make-symbol "config")))
7409 `(let ((,config (gnus-hidden-threads-configuration)))
7413 (gnus-restore-hidden-threads-configuration ,config)))))
7415 (defun gnus-hidden-threads-configuration ()
7416 "Return the current hidden threads configuration."
7419 (goto-char (point-min))
7420 (while (search-forward "\r" nil t)
7421 (push (1- (point)) config))
7424 (defun gnus-restore-hidden-threads-configuration (config)
7425 "Restore hidden threads configuration from CONFIG."
7426 (let (point buffer-read-only)
7427 (while (setq point (pop config))
7428 (when (and (< point (point-max))
7430 (= (following-char) ?\n))
7431 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7433 ;; Various summary mode internalish functions.
7435 (defun gnus-mouse-pick-article (e)
7438 (gnus-summary-next-page nil t))
7440 (defun gnus-summary-setup-buffer (group)
7441 "Initialize summary buffer."
7442 (let ((buffer (concat "*Summary " group "*")))
7443 (if (get-buffer buffer)
7446 (setq gnus-summary-buffer (current-buffer))
7447 (not gnus-newsgroup-prepared))
7448 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7449 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7450 (gnus-add-current-to-buffer-list)
7451 (gnus-summary-mode group)
7453 (gnus-carpal-setup-buffer 'summary))
7454 (unless gnus-single-article-buffer
7455 (make-local-variable 'gnus-article-buffer)
7456 (make-local-variable 'gnus-article-current)
7457 (make-local-variable 'gnus-original-article-buffer))
7458 (setq gnus-newsgroup-name group)
7461 (defun gnus-set-global-variables ()
7462 ;; Set the global equivalents of the summary buffer-local variables
7463 ;; to the latest values they had. These reflect the summary buffer
7464 ;; that was in action when the last article was fetched.
7465 (when (eq major-mode 'gnus-summary-mode)
7466 (setq gnus-summary-buffer (current-buffer))
7467 (let ((name gnus-newsgroup-name)
7468 (marked gnus-newsgroup-marked)
7469 (unread gnus-newsgroup-unreads)
7470 (headers gnus-current-headers)
7471 (data gnus-newsgroup-data)
7472 (summary gnus-summary-buffer)
7473 (article-buffer gnus-article-buffer)
7474 (original gnus-original-article-buffer)
7475 (gac gnus-article-current)
7476 (score-file gnus-current-score-file))
7478 (set-buffer gnus-group-buffer)
7479 (setq gnus-newsgroup-name name)
7480 (setq gnus-newsgroup-marked marked)
7481 (setq gnus-newsgroup-unreads unread)
7482 (setq gnus-current-headers headers)
7483 (setq gnus-newsgroup-data data)
7484 (setq gnus-article-current gac)
7485 (setq gnus-summary-buffer summary)
7486 (setq gnus-article-buffer article-buffer)
7487 (setq gnus-original-article-buffer original)
7488 (setq gnus-current-score-file score-file)))))
7490 (defun gnus-summary-last-article-p (&optional article)
7491 "Return whether ARTICLE is the last article in the buffer."
7492 (if (not (setq article (or article (gnus-summary-article-number))))
7493 t ; All non-existant numbers are the last article. :-)
7494 (not (cdr (gnus-data-find-list article)))))
7496 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7497 "Insert a dummy root in the summary buffer."
7499 (gnus-add-text-properties
7500 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7501 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7503 (defun gnus-make-thread-indent-array ()
7505 (unless (and gnus-thread-indent-array
7506 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7507 (setq gnus-thread-indent-array (make-vector 201 "")
7508 gnus-thread-indent-array-level gnus-thread-indent-level)
7510 (aset gnus-thread-indent-array n
7511 (make-string (* n gnus-thread-indent-level) ? ))
7514 (defun gnus-summary-insert-line
7515 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7516 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7517 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7518 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7519 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7520 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7521 (gnus-tmp-score-char
7522 (if (or (null gnus-summary-default-score)
7523 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7524 gnus-summary-zcore-fuzz)) ?
7525 (if (< gnus-tmp-score gnus-summary-default-score)
7526 gnus-score-below-mark gnus-score-over-mark)))
7527 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7528 ((memq gnus-tmp-current gnus-newsgroup-cached)
7530 (gnus-tmp-replied gnus-replied-mark)
7531 ((memq gnus-tmp-current gnus-newsgroup-saved)
7533 (t gnus-unread-mark)))
7534 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7537 ((string-match "(.+)" gnus-tmp-from)
7538 (substring gnus-tmp-from
7539 (1+ (match-beginning 0)) (1- (match-end 0))))
7540 ((string-match "<[^>]+> *$" gnus-tmp-from)
7541 (let ((beg (match-beginning 0)))
7542 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7543 (substring gnus-tmp-from (1+ (match-beginning 0))
7544 (1- (match-end 0))))
7545 (substring gnus-tmp-from 0 beg))))
7547 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7548 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7549 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7550 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7551 (buffer-read-only nil))
7552 (when (string= gnus-tmp-name "")
7553 (setq gnus-tmp-name gnus-tmp-from))
7554 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7555 (gnus-put-text-property
7557 (progn (eval gnus-summary-line-format-spec) (point))
7558 'gnus-number gnus-tmp-number)
7559 (when (gnus-visual-p 'summary-highlight 'highlight)
7561 (run-hooks 'gnus-summary-update-hook)
7564 (defun gnus-summary-update-line (&optional dont-update)
7565 ;; Update summary line after change.
7566 (when (and gnus-summary-default-score
7567 (not gnus-summary-inhibit-highlight))
7568 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7569 (article (gnus-summary-article-number))
7570 (score (gnus-summary-article-score article)))
7572 (if (and gnus-summary-mark-below
7573 (< (gnus-summary-article-score)
7574 gnus-summary-mark-below))
7575 ;; This article has a low score, so we mark it as read.
7576 (when (memq article gnus-newsgroup-unreads)
7577 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7578 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7579 ;; This article was previously marked as read on account
7580 ;; of a low score, but now it has risen, so we mark it as
7582 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7583 (gnus-summary-update-mark
7584 (if (or (null gnus-summary-default-score)
7585 (<= (abs (- score gnus-summary-default-score))
7586 gnus-summary-zcore-fuzz)) ?
7587 (if (< score gnus-summary-default-score)
7588 gnus-score-below-mark gnus-score-over-mark)) 'score))
7589 ;; Do visual highlighting.
7590 (when (gnus-visual-p 'summary-highlight 'highlight)
7591 (run-hooks 'gnus-summary-update-hook)))))
7593 (defvar gnus-tmp-new-adopts nil)
7595 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7596 ;; Sum up all elements (and sub-elements) in a list.
7598 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7600 ((and (consp thread) (cdr thread))
7603 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7606 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7609 (when (and level (zerop level) gnus-tmp-new-adopts)
7612 'gnus-summary-number-of-articles-in-thread
7613 gnus-tmp-new-adopts))))
7615 (if (> number 1) gnus-not-empty-thread-mark
7616 gnus-empty-thread-mark)
7619 (defun gnus-summary-set-local-parameters (group)
7620 "Go through the local params of GROUP and set all variable specs in that list."
7621 (let ((params (gnus-info-params (gnus-get-info group)))
7624 (setq elem (car params)
7625 params (cdr params))
7626 (and (consp elem) ; Has to be a cons.
7627 (consp (cdr elem)) ; The cdr has to be a list.
7628 (symbolp (car elem)) ; Has to be a symbol in there.
7629 (not (memq (car elem)
7630 '(quit-config to-address to-list to-group)))
7631 (progn ; So we set it.
7632 (make-local-variable (car elem))
7633 (set (car elem) (eval (nth 1 elem))))))))
7635 (defun gnus-summary-read-group (group &optional show-all no-article
7636 kill-buffer no-display)
7637 "Start reading news in newsgroup GROUP.
7638 If SHOW-ALL is non-nil, already read articles are also listed.
7639 If NO-ARTICLE is non-nil, no article is selected initially.
7640 If NO-DISPLAY, don't generate a summary buffer."
7641 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7642 (let* ((new-group (gnus-summary-setup-buffer group))
7643 (quit-config (gnus-group-quit-config group))
7644 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7646 ;; This summary buffer exists already, so we just select it.
7648 (gnus-set-global-variables)
7650 (gnus-kill-or-deaden-summary kill-buffer))
7651 (gnus-configure-windows 'summary 'force)
7652 (gnus-set-mode-line 'summary)
7653 (gnus-summary-position-point)
7656 ;; We couldn't select this group.
7658 (when (and (eq major-mode 'gnus-summary-mode)
7659 (not (equal (current-buffer) kill-buffer)))
7660 (kill-buffer (current-buffer))
7661 (if (not quit-config)
7663 (set-buffer gnus-group-buffer)
7664 (gnus-group-jump-to-group group)
7665 (gnus-group-next-unread-group 1))
7666 (if (not (buffer-name (car quit-config)))
7667 (gnus-configure-windows 'group 'force)
7668 (set-buffer (car quit-config))
7669 (and (eq major-mode 'gnus-summary-mode)
7670 (gnus-set-global-variables))
7671 (gnus-configure-windows (cdr quit-config)))))
7672 (gnus-message 3 "Can't select group")
7674 ;; The user did a `C-g' while prompting for number of articles,
7675 ;; so we exit this group.
7676 ((eq did-select 'quit)
7677 (and (eq major-mode 'gnus-summary-mode)
7678 (not (equal (current-buffer) kill-buffer))
7679 (kill-buffer (current-buffer)))
7681 (gnus-kill-or-deaden-summary kill-buffer))
7682 (if (not quit-config)
7684 (set-buffer gnus-group-buffer)
7685 (gnus-group-jump-to-group group)
7686 (gnus-group-next-unread-group 1)
7687 (gnus-configure-windows 'group 'force))
7688 (if (not (buffer-name (car quit-config)))
7689 (gnus-configure-windows 'group 'force)
7690 (set-buffer (car quit-config))
7691 (and (eq major-mode 'gnus-summary-mode)
7692 (gnus-set-global-variables))
7693 (gnus-configure-windows (cdr quit-config))))
7694 ;; Finally signal the quit.
7696 ;; The group was successfully selected.
7698 (gnus-set-global-variables)
7699 ;; Save the active value in effect when the group was entered.
7700 (setq gnus-newsgroup-active
7702 (gnus-active gnus-newsgroup-name)))
7703 ;; You can change the summary buffer in some way with this hook.
7704 (run-hooks 'gnus-select-group-hook)
7705 ;; Set any local variables in the group parameters.
7706 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7707 (gnus-update-format-specifications)
7708 ;; Do score processing.
7709 (when gnus-use-scoring
7710 (gnus-possibly-score-headers))
7711 ;; Check whether to fill in the gaps in the threads.
7712 (when gnus-build-sparse-threads
7713 (gnus-build-sparse-threads))
7714 ;; Find the initial limit.
7715 (if gnus-show-threads
7717 (let ((gnus-newsgroup-dormant nil))
7718 (gnus-summary-initial-limit show-all))
7719 (gnus-summary-initial-limit show-all))
7720 (setq gnus-newsgroup-limit
7722 (lambda (header) (mail-header-number header))
7723 gnus-newsgroup-headers)))
7724 ;; Generate the summary buffer.
7726 (gnus-summary-prepare))
7727 (when gnus-use-trees
7728 (gnus-tree-open group)
7729 (setq gnus-summary-highlight-line-function
7730 'gnus-tree-highlight-article))
7731 ;; If the summary buffer is empty, but there are some low-scored
7732 ;; articles or some excluded dormants, we include these in the
7734 (when (and (zerop (buffer-size))
7736 (cond (gnus-newsgroup-dormant
7737 (gnus-summary-limit-include-dormant))
7738 ((and gnus-newsgroup-scored show-all)
7739 (gnus-summary-limit-include-expunged))))
7740 ;; Function `gnus-apply-kill-file' must be called in this hook.
7741 (run-hooks 'gnus-apply-kill-hook)
7742 (if (and (zerop (buffer-size))
7745 ;; This newsgroup is empty.
7746 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7747 (gnus-message 6 "No unread news")
7749 (gnus-kill-or-deaden-summary kill-buffer))
7750 ;; Return nil from this function.
7752 ;; Hide conversation thread subtrees. We cannot do this in
7753 ;; gnus-summary-prepare-hook since kill processing may not
7754 ;; work with hidden articles.
7755 (and gnus-show-threads
7756 gnus-thread-hide-subtree
7757 (gnus-summary-hide-all-threads))
7758 ;; Show first unread article if requested.
7759 (if (and (not no-article)
7761 gnus-newsgroup-unreads
7762 gnus-auto-select-first)
7763 (unless (if (eq gnus-auto-select-first 'best)
7764 (gnus-summary-best-unread-article)
7765 (gnus-summary-first-unread-article))
7766 (gnus-configure-windows 'summary))
7767 ;; Don't select any articles, just move point to the first
7768 ;; article in the group.
7769 (goto-char (point-min))
7770 (gnus-summary-position-point)
7771 (gnus-set-mode-line 'summary)
7772 (gnus-configure-windows 'summary 'force))
7773 ;; If we are in async mode, we send some info to the backend.
7774 (when gnus-newsgroup-async
7775 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7777 (gnus-kill-or-deaden-summary kill-buffer))
7778 (when (get-buffer-window gnus-group-buffer t)
7779 ;; Gotta use windows, because recenter does wierd stuff if
7780 ;; the current buffer ain't the displayed window.
7781 (let ((owin (selected-window)))
7782 (select-window (get-buffer-window gnus-group-buffer t))
7783 (when (gnus-group-goto-group group)
7785 (select-window owin))))
7786 ;; Mark this buffer as "prepared".
7787 (setq gnus-newsgroup-prepared t)
7790 (defun gnus-summary-prepare ()
7791 "Generate the summary buffer."
7792 (let ((buffer-read-only nil))
7794 (setq gnus-newsgroup-data nil
7795 gnus-newsgroup-data-reverse nil)
7796 (run-hooks 'gnus-summary-generate-hook)
7797 ;; Generate the buffer, either with threads or without.
7798 (when gnus-newsgroup-headers
7799 (gnus-summary-prepare-threads
7800 (if gnus-show-threads
7801 (gnus-sort-gathered-threads
7802 (funcall gnus-summary-thread-gathering-function
7804 (gnus-cut-threads (gnus-make-threads)))))
7805 ;; Unthreaded display.
7806 (gnus-sort-articles gnus-newsgroup-headers))))
7807 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7808 ;; Call hooks for modifying summary buffer.
7809 (goto-char (point-min))
7810 (run-hooks 'gnus-summary-prepare-hook)))
7812 (defun gnus-gather-threads-by-subject (threads)
7813 "Gather threads by looking at Subject headers."
7814 (if (not gnus-summary-make-false-root)
7816 (let ((hashtb (gnus-make-hashtable 1023))
7819 subject hthread whole-subject)
7821 (setq whole-subject (mail-header-subject (caar threads)))
7824 ;; Truncate the subject.
7825 ((numberp gnus-summary-gather-subject-limit)
7826 (setq subject (gnus-simplify-subject-re whole-subject))
7827 (if (> (length subject) gnus-summary-gather-subject-limit)
7828 (substring subject 0 gnus-summary-gather-subject-limit)
7830 ;; Fuzzily simplify it.
7831 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7832 (gnus-simplify-subject-fuzzy whole-subject))
7833 ;; Just remove the leading "Re:".
7835 (gnus-simplify-subject-re whole-subject))))
7837 (if (and gnus-summary-gather-exclude-subject
7838 (string-match gnus-summary-gather-exclude-subject
7840 () ; We don't want to do anything with this article.
7841 ;; We simplify the subject before looking it up in the
7844 (if (setq hthread (gnus-gethash subject hashtb))
7846 ;; We enter a dummy root into the thread, if we
7847 ;; haven't done that already.
7848 (unless (stringp (caar hthread))
7849 (setcar hthread (list whole-subject (car hthread))))
7850 ;; We add this new gathered thread to this gathered
7852 (setcdr (car hthread)
7853 (nconc (cdar hthread) (list (car threads))))
7854 ;; Remove it from the list of threads.
7855 (setcdr prev (cdr threads))
7856 (setq threads prev))
7857 ;; Enter this thread into the hash table.
7858 (gnus-sethash subject threads hashtb)))
7860 (setq threads (cdr threads)))
7863 (defun gnus-gather-threads-by-references (threads)
7864 "Gather threads by looking at References headers."
7865 (let ((idhashtb (gnus-make-hashtable 1023))
7866 (thhashtb (gnus-make-hashtable 1023))
7869 ids references id gthread gid entered)
7871 (when (setq references (mail-header-references (caar threads)))
7872 (setq id (mail-header-id (caar threads)))
7873 (setq ids (gnus-split-references references))
7876 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7878 (gnus-sethash (car ids) id idhashtb)
7879 (gnus-sethash id threads thhashtb))
7880 (setq gthread (gnus-gethash gid thhashtb))
7882 ;; We enter a dummy root into the thread, if we
7883 ;; haven't done that already.
7884 (unless (stringp (caar gthread))
7885 (setcar gthread (list (mail-header-subject (caar gthread))
7887 ;; We add this new gathered thread to this gathered
7889 (setcdr (car gthread)
7890 (nconc (cdar gthread) (list (car threads)))))
7891 ;; Add it into the thread hash table.
7892 (gnus-sethash id gthread thhashtb)
7894 ;; Remove it from the list of threads.
7895 (setcdr prev (cdr threads))
7896 (setq threads prev))
7897 (setq ids (cdr ids))))
7899 (setq threads (cdr threads)))
7902 (defun gnus-sort-gathered-threads (threads)
7903 "Sort subtreads inside each gathered thread by article number."
7904 (let ((result threads))
7906 (when (stringp (caar threads))
7907 (setcdr (car threads)
7908 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7909 (setq threads (cdr threads)))
7912 (defun gnus-make-threads ()
7913 "Go through the dependency hashtb and find the roots. Return all threads."
7917 (unless (car (symbol-value refs))
7918 ;; These threads do not refer back to any other articles,
7919 ;; so they're roots.
7920 (setq threads (append (cdr (symbol-value refs)) threads))))
7921 gnus-newsgroup-dependencies)
7924 (defun gnus-build-sparse-threads ()
7925 (let ((headers gnus-newsgroup-headers)
7926 (deps gnus-newsgroup-dependencies)
7927 header references generation relations
7928 cthread subject child end pthread relation)
7929 ;; First we create an alist of generations/relations, where
7930 ;; generations is how much we trust the ralation, and the relation
7932 (gnus-message 7 "Making sparse threads...")
7934 (nnheader-set-temp-buffer " *gnus sparse threads*")
7935 (while (setq header (pop headers))
7936 (when (and (setq references (mail-header-references header))
7937 (not (string= references "")))
7939 (setq child (mail-header-id header)
7940 subject (mail-header-subject header))
7942 (while (search-backward ">" nil t)
7943 (setq end (1+ (point)))
7944 (when (search-backward "<" nil t)
7945 (push (list (incf generation)
7946 child (setq child (buffer-substring (point) end))
7949 (push (list (1+ generation) child nil subject) relations)
7951 (kill-buffer (current-buffer)))
7952 ;; Sort over trustworthiness.
7953 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7954 (while (setq relation (pop relations))
7955 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7956 (unless (car (symbol-value cthread))
7957 ;; Make this article the parent of these threads.
7958 (setcar (symbol-value cthread)
7959 (vector gnus-reffed-article-number
7963 (or (caddr relation) "") 0 0 "")))
7964 (set cthread (list (vector gnus-reffed-article-number
7966 "" "" (cadr relation)
7967 (or (caddr relation) "") 0 0 ""))))
7968 (push gnus-reffed-article-number gnus-newsgroup-limit)
7969 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7970 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7971 gnus-newsgroup-reads)
7972 (decf gnus-reffed-article-number)
7973 ;; Make this new thread the child of its parent.
7974 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7975 (setcdr (symbol-value pthread)
7976 (nconc (cdr (symbol-value pthread))
7977 (list (symbol-value cthread))))
7978 (set pthread (list nil (symbol-value cthread))))))
7979 (gnus-message 7 "Making sparse threads...done")))
7981 (defun gnus-build-old-threads ()
7982 ;; Look at all the articles that refer back to old articles, and
7983 ;; fetch the headers for the articles that aren't there. This will
7984 ;; build complete threads - if the roots haven't been expired by the
7989 (when (not (car (symbol-value refs)))
7990 (setq heads (cdr (symbol-value refs)))
7992 (if (memq (mail-header-number (caar heads))
7993 gnus-newsgroup-dormant)
7994 (setq heads (cdr heads))
7995 (setq id (symbol-name refs))
7996 (while (and (setq id (gnus-build-get-header id))
7997 (not (car (gnus-gethash
7998 id gnus-newsgroup-dependencies)))))
7999 (setq heads nil)))))
8000 gnus-newsgroup-dependencies)))
8002 (defun gnus-build-get-header (id)
8003 ;; Look through the buffer of NOV lines and find the header to
8004 ;; ID. Enter this line into the dependencies hash table, and return
8005 ;; the id of the parent article (if any).
8006 (let ((deps gnus-newsgroup-dependencies)
8010 (set-buffer nntp-server-buffer)
8011 (goto-char (point-min))
8012 (while (and (not found) (search-forward id nil t))
8014 (setq found (looking-at
8015 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8016 (regexp-quote id))))
8017 (or found (beginning-of-line 2)))
8021 (setq header (gnus-nov-parse-line
8022 (read (current-buffer)) deps))
8023 (gnus-parent-id (mail-header-references header)))))
8025 (let ((number (mail-header-number header)))
8026 (push number gnus-newsgroup-limit)
8027 (push header gnus-newsgroup-headers)
8028 (if (memq number gnus-newsgroup-unselected)
8030 (push number gnus-newsgroup-unreads)
8031 (setq gnus-newsgroup-unselected
8032 (delq number gnus-newsgroup-unselected)))
8033 (push number gnus-newsgroup-ancient)))))))
8035 (defun gnus-summary-update-article (article &optional header)
8036 "Update ARTICLE in the summary buffer."
8037 (set-buffer gnus-summary-buffer)
8038 (let* ((header (or header (gnus-summary-article-header article)))
8039 (id (mail-header-id header))
8040 (data (gnus-data-find article))
8041 (thread (gnus-id-to-thread id))
8043 (gnus-id-to-thread (or (gnus-parent-id
8044 (mail-header-references header))
8046 (buffer-read-only nil)
8048 (number (mail-header-number header))
8053 (delq thread parent))
8054 (if (gnus-summary-insert-subject id header)
8055 ;; Set the (possibly) new article number in the data structure.
8056 (gnus-data-set-number data (gnus-id-to-article id))
8060 (defun gnus-rebuild-thread (id)
8061 "Rebuild the thread containing ID."
8062 (let ((buffer-read-only nil)
8063 current thread data)
8064 (if (not gnus-show-threads)
8065 (setq thread (list (car (gnus-id-to-thread id))))
8066 ;; Get the thread this article is part of.
8067 (setq thread (gnus-remove-thread id)))
8068 (setq current (save-excursion
8069 (and (zerop (forward-line -1))
8070 (gnus-summary-article-number))))
8071 ;; If this is a gathered thread, we have to go some re-gathering.
8072 (when (stringp (car thread))
8073 (let ((subject (car thread))
8075 (setq thread (cdr thread))
8077 (unless (memq (setq thr (gnus-id-to-thread
8079 (mail-header-id (caar thread)))))
8082 (setq thread (cdr thread)))
8083 ;; We now have all (unique) roots.
8084 (if (= (length roots) 1)
8085 ;; All the loose roots are now one solid root.
8086 (setq thread (car roots))
8087 (setq thread (cons subject (gnus-sort-threads roots))))))
8089 ;; We then insert this thread into the summary buffer.
8090 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8091 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8092 (setq data (nreverse gnus-newsgroup-data))
8093 (setq threads gnus-newsgroup-threads))
8094 ;; We splice the new data into the data structure.
8095 (gnus-data-enter-list current data)
8096 (gnus-data-compute-positions)
8097 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8099 (defun gnus-id-to-thread (id)
8100 "Return the (sub-)thread where ID appears."
8101 (gnus-gethash id gnus-newsgroup-dependencies))
8103 (defun gnus-id-to-article (id)
8104 "Return the article number of ID."
8105 (let ((thread (gnus-id-to-thread id)))
8108 (mail-header-number (car thread)))))
8110 (defun gnus-id-to-header (id)
8111 "Return the article headers of ID."
8112 (car (gnus-id-to-thread id)))
8114 (defun gnus-article-displayed-root-p (article)
8115 "Say whether ARTICLE is a root(ish) article."
8116 (let ((level (gnus-summary-thread-level article))
8117 (refs (mail-header-references (gnus-summary-article-header article)))
8123 ((null (gnus-parent-id refs)) t)
8125 (null (setq particle (gnus-id-to-article
8126 (gnus-parent-id refs))))
8127 (null (gnus-summary-thread-level particle)))))))
8129 (defun gnus-root-id (id)
8130 "Return the id of the root of the thread where ID appears."
8132 (while (and id (setq prev (car (gnus-gethash
8133 id gnus-newsgroup-dependencies))))
8135 id (gnus-parent-id (mail-header-references prev))))
8138 (defun gnus-remove-thread (id &optional dont-remove)
8139 "Remove the thread that has ID in it."
8140 (let ((dep gnus-newsgroup-dependencies)
8141 headers thread last-id)
8142 ;; First go up in this thread until we find the root.
8143 (setq last-id (gnus-root-id id))
8144 (setq headers (list (car (gnus-id-to-thread last-id))
8145 (caadr (gnus-id-to-thread last-id))))
8146 ;; We have now found the real root of this thread. It might have
8147 ;; been gathered into some loose thread, so we have to search
8148 ;; through the threads to find the thread we wanted.
8149 (let ((threads gnus-newsgroup-threads)
8152 (setq sub (car threads))
8153 (if (stringp (car sub))
8154 ;; This is a gathered threads, so we look at the roots
8155 ;; below it to find whether this article in in this
8158 (setq sub (cdr sub))
8160 (when (member (caar sub) headers)
8161 (setq thread (car threads)
8164 (setq sub (cdr sub))))
8165 ;; It's an ordinary thread, so we check it.
8166 (when (eq (car sub) (car headers))
8169 (setq threads (cdr threads)))
8170 ;; If this article is in no thread, then it's a root.
8173 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8174 (setq thread (gnus-gethash last-id dep)))
8177 thread ; We return this thread.
8179 (if (stringp (car thread))
8181 ;; If we use dummy roots, then we have to remove the
8182 ;; dummy root as well.
8183 (when (eq gnus-summary-make-false-root 'dummy)
8186 (setq thread (cdr thread))
8188 (gnus-remove-thread-1 (car thread))
8189 (setq thread (cdr thread))))
8190 (gnus-remove-thread-1 thread))))))))
8192 (defun gnus-remove-thread-1 (thread)
8193 "Remove the thread THREAD recursively."
8194 (let ((number (mail-header-number (car thread)))
8196 (when (setq pos (text-property-any
8197 (point-min) (point-max) 'gnus-number number))
8200 (gnus-data-remove number))
8201 (setq thread (cdr thread))
8203 (gnus-remove-thread-1 (pop thread)))))
8205 (defun gnus-sort-threads (threads)
8207 (if (not gnus-thread-sort-functions)
8209 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8210 (car gnus-thread-sort-functions)
8212 ,(gnus-make-sort-function
8213 (reverse gnus-thread-sort-functions))))))
8214 (gnus-message 7 "Sorting threads...")
8217 (gnus-message 7 "Sorting threads...done")))))
8219 (defun gnus-sort-articles (articles)
8221 (when gnus-article-sort-functions
8222 (let ((func (if (= 1 (length gnus-article-sort-functions))
8223 (car gnus-article-sort-functions)
8225 ,(gnus-make-sort-function
8226 (reverse gnus-article-sort-functions))))))
8227 (gnus-message 7 "Sorting articles...")
8229 (setq gnus-newsgroup-headers (sort articles func))
8230 (gnus-message 7 "Sorting articles...done")))))
8232 (defun gnus-make-sort-function (funs)
8233 "Return a composite sort condition based on the functions in FUNC."
8235 `(or (,(car funs) t1 t2)
8236 (and (not (,(car funs) t2 t1))
8237 ,(gnus-make-sort-function (cdr funs))))
8238 `(,(car funs) t1 t2)))
8240 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8241 (defmacro gnus-thread-header (thread)
8242 ;; Return header of first article in THREAD.
8243 ;; Note that THREAD must never, ever be anything else than a variable -
8244 ;; using some other form will lead to serious barfage.
8245 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8246 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8247 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8250 (defsubst gnus-article-sort-by-number (h1 h2)
8251 "Sort articles by article number."
8252 (< (mail-header-number h1)
8253 (mail-header-number h2)))
8255 (defun gnus-thread-sort-by-number (h1 h2)
8256 "Sort threads by root article number."
8257 (gnus-article-sort-by-number
8258 (gnus-thread-header h1) (gnus-thread-header h2)))
8260 (defsubst gnus-article-sort-by-author (h1 h2)
8261 "Sort articles by root author."
8263 (let ((extract (funcall
8264 gnus-extract-address-components
8265 (mail-header-from h1))))
8266 (or (car extract) (cdr extract)))
8267 (let ((extract (funcall
8268 gnus-extract-address-components
8269 (mail-header-from h2))))
8270 (or (car extract) (cdr extract)))))
8272 (defun gnus-thread-sort-by-author (h1 h2)
8273 "Sort threads by root author."
8274 (gnus-article-sort-by-author
8275 (gnus-thread-header h1) (gnus-thread-header h2)))
8277 (defsubst gnus-article-sort-by-subject (h1 h2)
8278 "Sort articles by root subject."
8280 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8281 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8283 (defun gnus-thread-sort-by-subject (h1 h2)
8284 "Sort threads by root subject."
8285 (gnus-article-sort-by-subject
8286 (gnus-thread-header h1) (gnus-thread-header h2)))
8288 (defsubst gnus-article-sort-by-date (h1 h2)
8289 "Sort articles by root article date."
8291 (gnus-sortable-date (mail-header-date h1))
8292 (gnus-sortable-date (mail-header-date h2))))
8294 (defun gnus-thread-sort-by-date (h1 h2)
8295 "Sort threads by root article date."
8296 (gnus-article-sort-by-date
8297 (gnus-thread-header h1) (gnus-thread-header h2)))
8299 (defsubst gnus-article-sort-by-score (h1 h2)
8300 "Sort articles by root article score.
8301 Unscored articles will be counted as having a score of zero."
8302 (> (or (cdr (assq (mail-header-number h1)
8303 gnus-newsgroup-scored))
8304 gnus-summary-default-score 0)
8305 (or (cdr (assq (mail-header-number h2)
8306 gnus-newsgroup-scored))
8307 gnus-summary-default-score 0)))
8309 (defun gnus-thread-sort-by-score (h1 h2)
8310 "Sort threads by root article score."
8311 (gnus-article-sort-by-score
8312 (gnus-thread-header h1) (gnus-thread-header h2)))
8314 (defun gnus-thread-sort-by-total-score (h1 h2)
8315 "Sort threads by the sum of all scores in the thread.
8316 Unscored articles will be counted as having a score of zero."
8317 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8319 (defun gnus-thread-total-score (thread)
8320 ;; This function find the total score of THREAD.
8322 (if (stringp (car thread))
8323 (apply gnus-thread-score-function 0
8324 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8325 (gnus-thread-total-score-1 thread))
8326 (gnus-thread-total-score-1 (list thread))))
8328 (defun gnus-thread-total-score-1 (root)
8329 ;; This function find the total score of the thread below ROOT.
8330 (setq root (car root))
8331 (apply gnus-thread-score-function
8332 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8333 gnus-summary-default-score 0)
8334 (mapcar 'gnus-thread-total-score
8335 (cdr (gnus-gethash (mail-header-id root)
8336 gnus-newsgroup-dependencies)))))
8338 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8339 (defvar gnus-tmp-prev-subject nil)
8340 (defvar gnus-tmp-false-parent nil)
8341 (defvar gnus-tmp-root-expunged nil)
8342 (defvar gnus-tmp-dummy-line nil)
8344 (defun gnus-summary-prepare-threads (threads)
8345 "Prepare summary buffer from THREADS and indentation LEVEL.
8346 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8347 or a straight list of headers."
8348 (gnus-message 7 "Generating summary...")
8350 (setq gnus-newsgroup-threads threads)
8353 (let ((gnus-tmp-level 0)
8354 (default-score (or gnus-summary-default-score 0))
8355 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8356 thread number subject stack state gnus-tmp-gathered beg-match
8357 new-roots gnus-tmp-new-adopts thread-end
8358 gnus-tmp-header gnus-tmp-unread
8359 gnus-tmp-replied gnus-tmp-subject-or-nil
8360 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8361 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8362 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8364 (setq gnus-tmp-prev-subject nil)
8366 (if (vectorp (car threads))
8367 ;; If this is a straight (sic) list of headers, then a
8368 ;; threaded summary display isn't required, so we just create
8369 ;; an unthreaded one.
8370 (gnus-summary-prepare-unthreaded threads)
8372 ;; Do the threaded display.
8374 (while (or threads stack gnus-tmp-new-adopts new-roots)
8376 (if (and (= gnus-tmp-level 0)
8377 (not (setq gnus-tmp-dummy-line nil))
8380 (not gnus-tmp-false-parent)
8381 (or gnus-tmp-new-adopts new-roots))
8382 (if gnus-tmp-new-adopts
8383 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8384 thread (list (car gnus-tmp-new-adopts))
8385 gnus-tmp-header (caar thread)
8386 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8388 (setq thread (list (car new-roots))
8389 gnus-tmp-header (caar thread)
8390 new-roots (cdr new-roots))))
8393 ;; If there are some threads, we do them before the
8394 ;; threads on the stack.
8395 (setq thread threads
8396 gnus-tmp-header (caar thread))
8397 ;; There were no current threads, so we pop something off
8399 (setq state (car stack)
8400 gnus-tmp-level (car state)
8403 gnus-tmp-header (caar thread))))
8405 (setq gnus-tmp-false-parent nil)
8406 (setq gnus-tmp-root-expunged nil)
8407 (setq thread-end nil)
8409 (if (stringp gnus-tmp-header)
8410 ;; The header is a dummy root.
8412 ((eq gnus-summary-make-false-root 'adopt)
8413 ;; We let the first article adopt the rest.
8414 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8416 (setq gnus-tmp-gathered
8418 (lambda (h) (mail-header-number (car h)))
8421 (setq thread (cons (list (caar thread)
8424 (setq gnus-tmp-level -1
8425 gnus-tmp-false-parent t))
8426 ((eq gnus-summary-make-false-root 'empty)
8427 ;; We print adopted articles with empty subject fields.
8428 (setq gnus-tmp-gathered
8430 (lambda (h) (mail-header-number (car h)))
8433 (setq gnus-tmp-level -1))
8434 ((eq gnus-summary-make-false-root 'dummy)
8435 ;; We remember that we probably want to output a dummy
8437 (setq gnus-tmp-dummy-line gnus-tmp-header)
8438 (setq gnus-tmp-prev-subject gnus-tmp-header))
8440 ;; We do not make a root for the gathered
8441 ;; sub-threads at all.
8442 (setq gnus-tmp-level -1)))
8444 (setq number (mail-header-number gnus-tmp-header)
8445 subject (mail-header-subject gnus-tmp-header))
8448 ;; If the thread has changed subject, we might want to make
8449 ;; this subthread into a root.
8450 ((and (null gnus-thread-ignore-subject)
8451 (not (zerop gnus-tmp-level))
8452 gnus-tmp-prev-subject
8454 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8455 (setq new-roots (nconc new-roots (list (car thread)))
8457 gnus-tmp-header nil))
8458 ;; If the article lies outside the current limit,
8459 ;; then we do not display it.
8460 ((and (not (memq number gnus-newsgroup-limit))
8461 (not gnus-tmp-dummy-line))
8462 (setq gnus-tmp-gathered
8464 (lambda (h) (mail-header-number (car h)))
8467 (setq gnus-tmp-new-adopts (if (cdar thread)
8468 (append gnus-tmp-new-adopts
8470 gnus-tmp-new-adopts)
8472 gnus-tmp-header nil)
8473 (when (zerop gnus-tmp-level)
8474 (setq gnus-tmp-root-expunged t)))
8475 ;; Perhaps this article is to be marked as read?
8476 ((and gnus-summary-mark-below
8477 (< (or (cdr (assq number gnus-newsgroup-scored))
8479 gnus-summary-mark-below)
8480 ;; Don't touch sparse articles.
8481 (not (memq number gnus-newsgroup-sparse))
8482 (not (memq number gnus-newsgroup-ancient)))
8483 (setq gnus-newsgroup-unreads
8484 (delq number gnus-newsgroup-unreads))
8485 (if gnus-newsgroup-auto-expire
8486 (push number gnus-newsgroup-expirable)
8487 (push (cons number gnus-low-score-mark)
8488 gnus-newsgroup-reads))))
8490 (when gnus-tmp-header
8491 ;; We may have an old dummy line to output before this
8493 (when gnus-tmp-dummy-line
8494 (gnus-summary-insert-dummy-line
8495 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8496 (setq gnus-tmp-dummy-line nil))
8498 ;; Compute the mark.
8502 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8503 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8504 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8505 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8506 (t (or (cdr (assq number gnus-newsgroup-reads))
8507 gnus-ancient-mark))))
8509 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8510 gnus-tmp-header gnus-tmp-level)
8511 gnus-newsgroup-data)
8513 ;; Actually insert the line.
8515 gnus-tmp-subject-or-nil
8517 ((and gnus-thread-ignore-subject
8518 gnus-tmp-prev-subject
8519 (not (inline (gnus-subject-equal
8520 gnus-tmp-prev-subject subject))))
8522 ((zerop gnus-tmp-level)
8523 (if (and (eq gnus-summary-make-false-root 'empty)
8524 (memq number gnus-tmp-gathered)
8525 gnus-tmp-prev-subject
8526 (inline (gnus-subject-equal
8527 gnus-tmp-prev-subject subject)))
8528 gnus-summary-same-subject
8530 (t gnus-summary-same-subject)))
8531 (if (and (eq gnus-summary-make-false-root 'adopt)
8532 (= gnus-tmp-level 1)
8533 (memq number gnus-tmp-gathered))
8534 (setq gnus-tmp-opening-bracket ?\<
8535 gnus-tmp-closing-bracket ?\>)
8536 (setq gnus-tmp-opening-bracket ?\[
8537 gnus-tmp-closing-bracket ?\]))
8539 gnus-tmp-indentation
8540 (aref gnus-thread-indent-array gnus-tmp-level)
8541 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8542 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8543 gnus-summary-default-score 0)
8545 (if (or (null gnus-summary-default-score)
8546 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8547 gnus-summary-zcore-fuzz)) ?
8548 (if (< gnus-tmp-score gnus-summary-default-score)
8549 gnus-score-below-mark gnus-score-over-mark))
8551 (cond ((memq number gnus-newsgroup-processable)
8553 ((memq number gnus-newsgroup-cached)
8555 ((memq number gnus-newsgroup-replied)
8557 (t gnus-unread-mark))
8558 gnus-tmp-from (mail-header-from gnus-tmp-header)
8561 ((string-match "(.+)" gnus-tmp-from)
8562 (substring gnus-tmp-from
8563 (1+ (match-beginning 0)) (1- (match-end 0))))
8564 ((string-match "<[^>]+> *$" gnus-tmp-from)
8565 (setq beg-match (match-beginning 0))
8566 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8567 (substring gnus-tmp-from (1+ (match-beginning 0))
8568 (1- (match-end 0))))
8569 (substring gnus-tmp-from 0 beg-match)))
8571 (when (string= gnus-tmp-name "")
8572 (setq gnus-tmp-name gnus-tmp-from))
8573 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8574 (gnus-put-text-property
8576 (progn (eval gnus-summary-line-format-spec) (point))
8577 'gnus-number number)
8580 (run-hooks 'gnus-summary-update-hook)
8583 (setq gnus-tmp-prev-subject subject)))
8585 (when (nth 1 thread)
8586 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8587 (incf gnus-tmp-level)
8588 (setq threads (if thread-end nil (cdar thread)))
8590 (setq gnus-tmp-level 0)))))
8591 (gnus-message 7 "Generating summary...done"))
8593 (defun gnus-summary-prepare-unthreaded (headers)
8594 "Generate an unthreaded summary buffer based on HEADERS."
8595 (let (header number mark)
8598 ;; We may have to root out some bad articles...
8599 (when (memq (setq number (mail-header-number
8600 (setq header (pop headers))))
8601 gnus-newsgroup-limit)
8602 ;; Mark article as read when it has a low score.
8603 (when (and gnus-summary-mark-below
8604 (< (or (cdr (assq number gnus-newsgroup-scored))
8605 gnus-summary-default-score 0)
8606 gnus-summary-mark-below)
8607 (not (memq number gnus-newsgroup-ancient)))
8608 (setq gnus-newsgroup-unreads
8609 (delq number gnus-newsgroup-unreads))
8610 (if gnus-newsgroup-auto-expire
8611 (push number gnus-newsgroup-expirable)
8612 (push (cons number gnus-low-score-mark)
8613 gnus-newsgroup-reads)))
8617 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8618 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8619 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8620 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8621 (t (or (cdr (assq number gnus-newsgroup-reads))
8622 gnus-ancient-mark))))
8623 (setq gnus-newsgroup-data
8624 (cons (gnus-data-make number mark (1+ (point)) header 0)
8625 gnus-newsgroup-data))
8626 (gnus-summary-insert-line
8627 header 0 nil mark (memq number gnus-newsgroup-replied)
8628 (memq number gnus-newsgroup-expirable)
8629 (mail-header-subject header) nil
8630 (cdr (assq number gnus-newsgroup-scored))
8631 (memq number gnus-newsgroup-processable))))))
8633 (defun gnus-select-newsgroup (group &optional read-all)
8634 "Select newsgroup GROUP.
8635 If READ-ALL is non-nil, all articles in the group are selected."
8636 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8637 (info (nth 2 entry))
8638 articles fetched-articles cached)
8640 (or (gnus-check-server
8641 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8642 (error "Couldn't open server"))
8644 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8645 (gnus-activate-group group) ; Or we can activate it...
8646 (progn ; Or we bug out.
8647 (when (equal major-mode 'gnus-summary-mode)
8648 (kill-buffer (current-buffer)))
8649 (error "Couldn't request group %s: %s"
8650 group (gnus-status-message group))))
8652 (unless (gnus-request-group group t)
8653 (when (equal major-mode 'gnus-summary-mode)
8654 (kill-buffer (current-buffer)))
8655 (error "Couldn't request group %s: %s"
8656 group (gnus-status-message group)))
8658 (setq gnus-newsgroup-name group)
8659 (setq gnus-newsgroup-unselected nil)
8660 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8662 (and gnus-asynchronous
8663 (gnus-check-backend-function
8664 'request-asynchronous gnus-newsgroup-name)
8665 (setq gnus-newsgroup-async
8666 (gnus-request-asynchronous gnus-newsgroup-name)))
8668 ;; Adjust and set lists of article marks.
8670 (gnus-adjust-marked-articles info))
8672 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8673 (when (gnus-virtual-group-p group)
8674 (setq cached gnus-newsgroup-cached))
8676 (setq gnus-newsgroup-unreads
8677 (gnus-set-difference
8678 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8679 gnus-newsgroup-dormant))
8681 (setq gnus-newsgroup-processable nil)
8683 (setq articles (gnus-articles-to-read group read-all))
8687 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8689 ((eq articles 0) nil)
8691 ;; Init the dependencies hash table.
8692 (setq gnus-newsgroup-dependencies
8693 (gnus-make-hashtable (length articles)))
8694 ;; Retrieve the headers and read them in.
8695 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8696 (setq gnus-newsgroup-headers
8698 (setq gnus-headers-retrieved-by
8699 (gnus-retrieve-headers
8700 articles gnus-newsgroup-name
8701 ;; We might want to fetch old headers, but
8702 ;; not if there is only 1 article.
8703 (and gnus-fetch-old-headers
8705 (not (eq gnus-fetch-old-headers 'some))
8706 (not (numberp gnus-fetch-old-headers)))
8707 (> (length articles) 1))))))
8708 (gnus-get-newsgroup-headers-xover articles)
8709 (gnus-get-newsgroup-headers)))
8710 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8712 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8714 (setq gnus-newsgroup-cached cached))
8716 ;; Set the initial limit.
8717 (setq gnus-newsgroup-limit (copy-sequence articles))
8718 ;; Remove canceled articles from the list of unread articles.
8719 (setq gnus-newsgroup-unreads
8720 (gnus-set-sorted-intersection
8721 gnus-newsgroup-unreads
8722 (setq fetched-articles
8723 (mapcar (lambda (headers) (mail-header-number headers))
8724 gnus-newsgroup-headers))))
8725 ;; Removed marked articles that do not exist.
8726 (gnus-update-missing-marks
8727 (gnus-sorted-complement fetched-articles articles))
8728 ;; We might want to build some more threads first.
8729 (and gnus-fetch-old-headers
8730 (eq gnus-headers-retrieved-by 'nov)
8731 (gnus-build-old-threads))
8732 ;; Check whether auto-expire is to be done in this group.
8733 (setq gnus-newsgroup-auto-expire
8734 (gnus-group-auto-expirable-p group))
8735 ;; Set up the article buffer now, if necessary.
8736 (unless gnus-single-article-buffer
8737 (gnus-article-setup-buffer))
8738 ;; First and last article in this newsgroup.
8739 (and gnus-newsgroup-headers
8740 (setq gnus-newsgroup-begin
8741 (mail-header-number (car gnus-newsgroup-headers)))
8742 (setq gnus-newsgroup-end
8744 (gnus-last-element gnus-newsgroup-headers))))
8745 (setq gnus-reffed-article-number -1)
8746 ;; GROUP is successfully selected.
8747 (or gnus-newsgroup-headers t)))))
8749 (defun gnus-articles-to-read (group read-all)
8750 ;; Find out what articles the user wants to read.
8752 ;; Select all articles if `read-all' is non-nil, or if there
8753 ;; are no unread articles.
8755 (and (zerop (length gnus-newsgroup-marked))
8756 (zerop (length gnus-newsgroup-unreads))))
8757 (gnus-uncompress-range (gnus-active group))
8758 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8759 (copy-sequence gnus-newsgroup-unreads))
8761 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8762 (scored (length scored-list))
8763 (number (length articles))
8764 (marked (+ (length gnus-newsgroup-marked)
8765 (length gnus-newsgroup-dormant)))
8773 ((and (or (<= scored marked) (= scored number))
8774 (numberp gnus-large-newsgroup)
8775 (> number gnus-large-newsgroup))
8779 "How many articles from %s (default %d): "
8780 gnus-newsgroup-name number))))
8781 (if (string-match "^[ \t]*$" input) number input)))
8782 ((and (> scored marked) (< scored number))
8785 (format "%s %s (%d scored, %d total): "
8786 "How many articles from"
8787 group scored number))))
8788 (if (string-match "^[ \t]*$" input)
8792 (setq select (if (stringp select) (string-to-number select) select))
8793 (if (or (null select) (zerop select))
8795 (if (and (not (zerop scored)) (<= (abs select) scored))
8797 (setq articles (sort scored-list '<))
8798 (setq number (length articles)))
8799 (setq articles (copy-sequence articles)))
8801 (if (< (abs select) number)
8803 ;; Select the N oldest articles.
8804 (setcdr (nthcdr (1- (abs select)) articles) nil)
8805 ;; Select the N most recent articles.
8806 (setq articles (nthcdr (- number select) articles))))
8807 (setq gnus-newsgroup-unselected
8808 (gnus-sorted-intersection
8809 gnus-newsgroup-unreads
8810 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8813 (defun gnus-killed-articles (killed articles)
8816 (if (inline (gnus-member-of-range (car articles) killed))
8817 (setq out (cons (car articles) out)))
8818 (setq articles (cdr articles)))
8821 (defun gnus-uncompress-marks (marks)
8822 "Uncompress the mark ranges in MARKS."
8823 (let ((uncompressed '(score bookmark))
8826 (if (memq (caar marks) uncompressed)
8827 (push (car marks) out)
8828 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8829 (setq marks (cdr marks)))
8832 (defun gnus-adjust-marked-articles (info)
8833 "Set all article lists and remove all marks that are no longer legal."
8834 (let* ((marked-lists (gnus-info-marks info))
8835 (active (gnus-active (gnus-info-group info)))
8838 (types gnus-article-mark-lists)
8839 (uncompressed '(score bookmark))
8840 marks var articles article mark)
8843 (setq marks (pop marked-lists))
8844 (set (setq var (intern (format "gnus-newsgroup-%s"
8845 (car (rassq (setq mark (car marks))
8847 (if (memq (car marks) uncompressed) (cdr marks)
8848 (gnus-uncompress-range (cdr marks))))
8850 (setq articles (symbol-value var))
8852 ;; All articles have to be subsets of the active articles.
8854 ;; Adjust "simple" lists.
8855 ((memq mark '(tick dormant expirable reply killed save))
8857 (when (or (< (setq article (pop articles)) min) (> article max))
8858 (set var (delq article (symbol-value var))))))
8860 ((memq mark '(score bookmark))
8862 (when (or (< (car (setq article (pop articles))) min)
8863 (> (car article) max))
8864 (set var (delq article (symbol-value var))))))))))
8866 (defun gnus-update-missing-marks (missing)
8867 "Go through the list of MISSING articles and remove them mark lists."
8869 (let ((types gnus-article-mark-lists)
8871 ;; Go through all types.
8873 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8874 (when (symbol-value var)
8875 ;; This list has articles. So we delete all missing articles
8879 (set var (delq (pop m) (symbol-value var)))))))))
8881 (defun gnus-update-marks ()
8882 "Enter the various lists of marked articles into the newsgroup info list."
8883 (let ((types gnus-article-mark-lists)
8884 (info (gnus-get-info gnus-newsgroup-name))
8885 (uncompressed '(score bookmark killed))
8886 type list newmarked symbol)
8888 ;; Add all marks lists that are non-nil to the list of marks lists.
8890 (setq type (pop types))
8891 (when (setq list (symbol-value
8893 (intern (format "gnus-newsgroup-%s"
8895 (push (cons (cdr type)
8896 (if (memq (cdr type) uncompressed) list
8897 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8900 ;; Enter these new marks into the info of the group.
8902 (setcar (nthcdr 3 info) newmarked)
8903 ;; Add the marks lists to the end of the info.
8905 (setcdr (nthcdr 2 info) (list newmarked))))
8907 ;; Cut off the end of the info if there's nothing else there.
8911 (when (nthcdr (decf i) info)
8912 (setcdr (nthcdr i info) nil)))))))
8914 (defun gnus-add-marked-articles (group type articles &optional info force)
8915 ;; Add ARTICLES of TYPE to the info of GROUP.
8916 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8917 ;; add, but replace marked articles of TYPE with ARTICLES.
8918 (let ((info (or info (gnus-get-info group)))
8919 (uncompressed '(score bookmark killed))
8922 (and (not (setq marked (nthcdr 3 info)))
8924 (setcdr (nthcdr 2 info)
8925 (list (list (cons type (gnus-compress-sequence
8927 (and (not (setq m (assq type (car marked))))
8930 (cons (cons type (gnus-compress-sequence articles t) )
8934 (setcar (nthcdr 3 info)
8935 (delq (assq type (car marked)) (car marked)))
8936 (setcdr m (gnus-compress-sequence articles t)))
8937 (setcdr m (gnus-compress-sequence
8938 (sort (nconc (gnus-uncompress-range (cdr m))
8939 (copy-sequence articles)) '<) t))))))
8941 (defun gnus-set-mode-line (where)
8942 "This function sets the mode line of the article or summary buffers.
8943 If WHERE is `summary', the summary mode line format will be used."
8944 ;; Is this mode line one we keep updated?
8945 (when (memq where gnus-updated-mode-lines)
8948 ;; We evaluate this in the summary buffer since these
8949 ;; variables are buffer-local to that buffer.
8950 (set-buffer gnus-summary-buffer)
8951 ;; We bind all these variables that are used in the `eval' form
8953 (let* ((mformat (symbol-value
8955 (format "gnus-%s-mode-line-format-spec" where))))
8956 (gnus-tmp-group-name gnus-newsgroup-name)
8957 (gnus-tmp-article-number (or gnus-current-article 0))
8958 (gnus-tmp-unread gnus-newsgroup-unreads)
8959 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8960 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8961 (gnus-tmp-unread-and-unselected
8962 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8963 (zerop gnus-tmp-unselected)) "")
8964 ((zerop gnus-tmp-unselected)
8965 (format "{%d more}" gnus-tmp-unread-and-unticked))
8966 (t (format "{%d(+%d) more}"
8967 gnus-tmp-unread-and-unticked
8968 gnus-tmp-unselected))))
8970 (if (and gnus-current-headers
8971 (vectorp gnus-current-headers))
8972 (gnus-mode-string-quote
8973 (mail-header-subject gnus-current-headers)) ""))
8975 gnus-tmp-header);; passed as argument to any user-format-funcs
8976 (setq mode-string (eval mformat))
8977 (setq max-len (max 4 (if gnus-mode-non-string-length
8979 gnus-mode-non-string-length)
8980 (length mode-string))))
8981 ;; We might have to chop a bit of the string off...
8982 (when (> (length mode-string) max-len)
8984 (concat (gnus-truncate-string mode-string (- max-len 3))
8986 ;; Pad the mode string a bit.
8987 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8988 ;; Update the mode line.
8989 (setq mode-line-buffer-identification (list mode-string))
8990 (set-buffer-modified-p t))))
8992 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8993 "Go through the HEADERS list and add all Xrefs to a hash table.
8994 The resulting hash table is returned, or nil if no Xrefs were found."
8995 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8996 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8997 (xref-hashtb (make-vector 63 0))
8998 start group entry number xrefs header)
9000 (setq header (pop headers))
9001 (when (and (setq xrefs (mail-header-xref header))
9002 (not (memq (setq number (mail-header-number header))
9005 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9006 (setq start (match-end 0))
9007 (setq group (if prefix
9008 (concat prefix (substring xrefs (match-beginning 1)
9010 (substring xrefs (match-beginning 1) (match-end 1))))
9012 (string-to-int (substring xrefs (match-beginning 2)
9014 (if (setq entry (gnus-gethash group xref-hashtb))
9015 (setcdr entry (cons number (cdr entry)))
9016 (gnus-sethash group (cons number nil) xref-hashtb)))))
9017 (and start xref-hashtb)))
9019 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9020 "Look through all the headers and mark the Xrefs as read."
9021 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9022 name entry info xref-hashtb idlist method nth4)
9024 (set-buffer gnus-group-buffer)
9025 (when (setq xref-hashtb
9026 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9029 (unless (string= from-newsgroup (setq name (symbol-name group)))
9030 (setq idlist (symbol-value group))
9031 ;; Dead groups are not updated.
9033 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9035 (if (stringp (setq nth4 (gnus-info-method info)))
9036 (setq nth4 (gnus-server-to-method nth4))))
9037 ;; Only do the xrefs if the group has the same
9038 ;; select method as the group we have just read.
9039 (or (gnus-methods-equal-p
9040 nth4 (gnus-find-method-for-group from-newsgroup))
9042 (equal nth4 (setq method (gnus-find-method-for-group
9044 (and (equal (car nth4) (car method))
9045 (equal (nth 1 nth4) (nth 1 method))))
9046 gnus-use-cross-reference
9047 (or (not (eq gnus-use-cross-reference t))
9049 ;; Only do cross-references on subscribed
9050 ;; groups, if that is what is wanted.
9051 (<= (gnus-info-level info) gnus-level-subscribed))
9052 (gnus-group-make-articles-read name idlist))))
9055 (defun gnus-group-make-articles-read (group articles)
9057 (entry (gnus-gethash group gnus-newsrc-hashtb))
9058 (info (nth 2 entry))
9059 (active (gnus-active group))
9061 ;; First peel off all illegal article numbers.
9063 (let ((ids articles)
9067 (if (and first (> id (cdr active)))
9069 ;; We'll end up in this situation in one particular
9070 ;; obscure situation. If you re-scan a group and get
9071 ;; a new article that is cross-posted to a different
9072 ;; group that has not been re-scanned, you might get
9073 ;; crossposted article that has a higher number than
9074 ;; Gnus believes possible. So we re-activate this
9075 ;; group as well. This might mean doing the
9076 ;; crossposting thingy will *increase* the number
9077 ;; of articles in some groups. Tsk, tsk.
9078 (setq active (or (gnus-activate-group group) active))))
9079 (if (or (> id (cdr active))
9080 (< id (car active)))
9081 (setq articles (delq id articles)))
9082 (setq ids (cdr ids)))))
9083 ;; If the read list is nil, we init it.
9085 (null (gnus-info-read info))
9087 (gnus-info-set-read info (cons 1 (1- (car active)))))
9088 ;; Then we add the read articles to the range.
9093 (gnus-info-read info) (setq articles (sort articles '<)))))
9094 ;; Then we have to re-compute how many unread
9095 ;; articles there are in this group.
9100 (setq num (- (1+ (cdr active)) (car active))))
9101 ((not (listp (cdr range)))
9102 (setq num (- (cdr active) (- (1+ (cdr range))
9106 (if (numberp (car range))
9108 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9109 (setq range (cdr range)))
9110 (setq num (- (cdr active) num))))
9111 ;; Update the number of unread articles.
9113 ;; Update the group buffer.
9114 (gnus-group-update-group group t)))))
9116 (defun gnus-methods-equal-p (m1 m2)
9117 (let ((m1 (or m1 gnus-select-method))
9118 (m2 (or m2 gnus-select-method)))
9120 (and (eq (car m1) (car m2))
9121 (or (not (memq 'address (assoc (symbol-name (car m1))
9122 gnus-valid-select-methods)))
9123 (equal (nth 1 m1) (nth 1 m2)))))))
9125 (defsubst gnus-header-value ()
9126 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9128 (defvar gnus-newsgroup-none-id 0)
9130 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9131 (let ((cur nntp-server-buffer)
9134 (save-excursion (set-buffer gnus-summary-buffer)
9135 gnus-newsgroup-dependencies)))
9136 headers id id-dep ref-dep end ref)
9138 (set-buffer nntp-server-buffer)
9139 (run-hooks 'gnus-parse-headers-hook)
9140 (let ((case-fold-search t)
9141 in-reply-to header p lines)
9142 (goto-char (point-min))
9143 ;; Search to the beginning of the next header. Error messages
9144 ;; do not begin with 2 or 3.
9145 (while (re-search-forward "^[23][0-9]+ " nil t)
9148 ;; This implementation of this function, with nine
9149 ;; search-forwards instead of the one re-search-forward and
9150 ;; a case (which basically was the old function) is actually
9151 ;; about twice as fast, even though it looks messier. You
9152 ;; can't have everything, I guess. Speed and elegance
9153 ;; doesn't always go hand in hand.
9162 (narrow-to-region (point)
9163 (or (and (search-forward "\n.\n" nil t)
9169 (if (search-forward "\nsubject: " nil t)
9170 (gnus-header-value) "(none)"))
9174 (if (search-forward "\nfrom: " nil t)
9175 (gnus-header-value) "(nobody)"))
9179 (if (search-forward "\ndate: " nil t)
9180 (gnus-header-value) ""))
9184 (if (search-forward "\nmessage-id: " nil t)
9185 (setq id (gnus-header-value))
9186 ;; If there was no message-id, we just fake one to make
9187 ;; subsequent routines simpler.
9188 (setq id (concat "none+"
9190 (setq gnus-newsgroup-none-id
9191 (1+ gnus-newsgroup-none-id)))))))
9195 (if (search-forward "\nreferences: " nil t)
9198 (setq end (match-end 0))
9204 (search-backward ">" end t)
9207 (search-backward "<" end t)
9209 ;; Get the references from the in-reply-to header if there
9210 ;; were no references and the in-reply-to header looks
9212 (if (and (search-forward "\nin-reply-to: " nil t)
9213 (setq in-reply-to (gnus-header-value))
9214 (string-match "<[^>]+>" in-reply-to))
9215 (setq ref (substring in-reply-to (match-beginning 0)
9223 (if (search-forward "\nlines: " nil t)
9224 (if (numberp (setq lines (read cur)))
9230 (and (search-forward "\nxref: " nil t)
9231 (gnus-header-value)))))
9232 ;; We do the threading while we read the headers. The
9233 ;; message-id and the last reference are both entered into
9234 ;; the same hash table. Some tippy-toeing around has to be
9235 ;; done in case an article has arrived before the article
9236 ;; which it refers to.
9237 (if (boundp (setq id-dep (intern id dependencies)))
9238 (if (and (car (symbol-value id-dep))
9240 ;; An article with this Message-ID has already
9241 ;; been seen, so we ignore this one, except we add
9242 ;; any additional Xrefs (in case the two articles
9243 ;; came from different servers).
9245 (mail-header-set-xref
9246 (car (symbol-value id-dep))
9247 (concat (or (mail-header-xref
9248 (car (symbol-value id-dep))) "")
9249 (or (mail-header-xref header) "")))
9251 (setcar (symbol-value id-dep) header))
9252 (set id-dep (list header)))
9254 (if (boundp (setq ref-dep (intern ref dependencies)))
9255 (setcdr (symbol-value ref-dep)
9256 (nconc (cdr (symbol-value ref-dep))
9257 (list (symbol-value id-dep))))
9258 (set ref-dep (list nil (symbol-value id-dep))))
9259 (setq headers (cons header headers)))
9260 (goto-char (point-max))
9262 (nreverse headers)))))
9264 ;; The following macros and functions were written by Felix Lee
9265 ;; <flee@cse.psu.edu>.
9267 (defmacro gnus-nov-read-integer ()
9269 (if (= (following-char) ?\t)
9271 (let ((num (condition-case nil (read buffer) (error nil))))
9272 (if (numberp num) num 0)))
9273 (or (eobp) (forward-char 1))))
9275 (defmacro gnus-nov-skip-field ()
9276 '(search-forward "\t" eol 'move))
9278 (defmacro gnus-nov-field ()
9279 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9281 ;; Goes through the xover lines and returns a list of vectors
9282 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9283 force-new dependencies)
9284 "Parse the news overview data in the server buffer, and return a
9285 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9286 ;; Get the Xref when the users reads the articles since most/some
9287 ;; NNTP servers do not include Xrefs when using XOVER.
9288 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9289 (let ((cur nntp-server-buffer)
9290 (dependencies (or dependencies gnus-newsgroup-dependencies))
9291 number headers header)
9293 (set-buffer nntp-server-buffer)
9294 ;; Allow the user to mangle the headers before parsing them.
9295 (run-hooks 'gnus-parse-headers-hook)
9296 (goto-char (point-min))
9297 (while (and sequence (not (eobp)))
9298 (setq number (read cur))
9299 (while (and sequence (< (car sequence) number))
9300 (setq sequence (cdr sequence)))
9302 (eq number (car sequence))
9304 (setq sequence (cdr sequence))
9306 (inline (gnus-nov-parse-line
9307 number dependencies force-new)))
9308 (setq headers (cons header headers)))))
9310 (setq headers (nreverse headers)))
9313 ;; This function has to be called with point after the article number
9314 ;; on the beginning of the line.
9315 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9317 (eol (gnus-point-at-eol))
9318 (buffer (current-buffer))
9319 header ref id id-dep ref-dep)
9321 ;; overview: [num subject from date id refs chars lines misc]
9322 (narrow-to-region (point) eol)
9323 (or (eobp) (forward-char))
9329 (gnus-nov-field) ; subject
9330 (gnus-nov-field) ; from
9331 (gnus-nov-field) ; date
9332 (setq id (or (gnus-nov-field)
9335 (setq none (1+ none)))))) ; id
9338 (let ((beg (point)))
9339 (search-forward "\t" eol)
9340 (if (search-backward ">" beg t)
9344 (search-backward "<" beg t)))
9346 (gnus-nov-field)) ; refs
9347 (gnus-nov-read-integer) ; chars
9348 (gnus-nov-read-integer) ; lines
9349 (if (= (following-char) ?\n)
9351 (gnus-nov-field)) ; misc
9354 (gnus-error 4 "Strange nov line")
9360 ;; We build the thread tree.
9362 (if (boundp (setq id-dep (intern id dependencies)))
9363 (if (and (car (symbol-value id-dep))
9365 ;; An article with this Message-ID has already been seen,
9366 ;; so we ignore this one, except we add any additional
9367 ;; Xrefs (in case the two articles came from different
9370 (mail-header-set-xref
9371 (car (symbol-value id-dep))
9372 (concat (or (mail-header-xref
9373 (car (symbol-value id-dep))) "")
9374 (or (mail-header-xref header) "")))
9376 (setcar (symbol-value id-dep) header))
9377 (set id-dep (list header))))
9380 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9381 (setcdr (symbol-value ref-dep)
9382 (nconc (cdr (symbol-value ref-dep))
9383 (list (symbol-value id-dep))))
9384 (set ref-dep (list nil (symbol-value id-dep))))))
9387 (defun gnus-article-get-xrefs ()
9388 "Fill in the Xref value in `gnus-current-headers', if necessary.
9389 This is meant to be called in `gnus-article-internal-prepare-hook'."
9390 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9391 gnus-current-headers)))
9392 (or (not gnus-use-cross-reference)
9394 (and (mail-header-xref headers)
9395 (not (string= (mail-header-xref headers) "")))
9396 (let ((case-fold-search t)
9399 (nnheader-narrow-to-headers)
9400 (goto-char (point-min))
9401 (if (or (and (eq (downcase (following-char)) ?x)
9402 (looking-at "Xref:"))
9403 (search-forward "\nXref:" nil t))
9405 (goto-char (1+ (match-end 0)))
9406 (setq xref (buffer-substring (point)
9407 (progn (end-of-line) (point))))
9408 (mail-header-set-xref headers xref))))))))
9410 (defun gnus-summary-insert-subject (id &optional old-header)
9411 "Find article ID and insert the summary line for that article."
9412 (let ((header (gnus-read-header id))
9413 (number (and (numberp id) id))
9416 ;; Rebuild the thread that this article is part of and go to the
9417 ;; article we have fetched.
9419 (when (setq pos (text-property-any
9420 (point-min) (point-max) 'gnus-number
9421 (mail-header-number old-header)))
9424 (gnus-data-remove (mail-header-number old-header))))
9426 (mail-header-set-number header (mail-header-number old-header)))
9427 (setq gnus-newsgroup-sparse
9428 (delq (mail-header-number header) gnus-newsgroup-sparse))
9429 (gnus-rebuild-thread (mail-header-id header))
9430 (gnus-summary-goto-subject (setq number (mail-header-number header))
9432 (when (and (numberp number)
9434 ;; We have to update the boundaries even if we can't fetch the
9435 ;; article if ID is a number -- so that the next `P' or `N'
9436 ;; command will fetch the previous (or next) article even
9437 ;; if the one we tried to fetch this time has been canceled.
9438 (and (> number gnus-newsgroup-end)
9439 (setq gnus-newsgroup-end number))
9440 (and (< number gnus-newsgroup-begin)
9441 (setq gnus-newsgroup-begin number))
9442 (setq gnus-newsgroup-unselected
9443 (delq number gnus-newsgroup-unselected)))
9444 ;; Report back a success?
9445 (and header (mail-header-number header))))
9447 (defun gnus-summary-work-articles (n)
9448 "Return a list of articles to be worked upon. The prefix argument,
9449 the list of process marked articles, and the current article will be
9450 taken into consideration."
9452 ((and n (numberp n))
9453 ;; A numerical prefix has been given.
9454 (let ((backward (< n 0))
9460 (push (setq article (gnus-summary-article-number))
9463 (gnus-summary-find-prev nil article)
9464 (gnus-summary-find-next nil article)))
9466 (nreverse articles)))
9467 ((and (boundp 'transient-mark-mode)
9470 ;; Work on the region between point and mark.
9471 (let ((max (max (point) (mark)))
9474 (goto-char (min (point) (mark)))
9477 (push (setq article (gnus-summary-article-number)) articles)
9478 (gnus-summary-find-next nil article)
9480 (nreverse articles))))
9481 (gnus-newsgroup-processable
9482 ;; There are process-marked articles present.
9483 (reverse gnus-newsgroup-processable))
9485 ;; Just return the current article.
9486 (list (gnus-summary-article-number)))))
9488 (defun gnus-summary-search-group (&optional backward use-level)
9489 "Search for next unread newsgroup.
9490 If optional argument BACKWARD is non-nil, search backward instead."
9492 (set-buffer gnus-group-buffer)
9493 (if (gnus-group-search-forward
9494 backward nil (if use-level (gnus-group-group-level) nil))
9495 (gnus-group-group-name))))
9497 (defun gnus-summary-best-group (&optional exclude-group)
9498 "Find the name of the best unread group.
9499 If EXCLUDE-GROUP, do not go to this group."
9501 (set-buffer gnus-group-buffer)
9503 (gnus-group-best-unread-group exclude-group))))
9505 (defun gnus-summary-find-next (&optional unread article backward)
9506 (if backward (gnus-summary-find-prev)
9507 (let* ((dummy (gnus-summary-article-intangible-p))
9508 (article (or article (gnus-summary-article-number)))
9509 (arts (gnus-data-find-list article))
9511 (when (and (not dummy)
9512 (or (not gnus-summary-check-current)
9514 (not (gnus-data-unread-p (car arts)))))
9515 (setq arts (cdr arts)))
9520 (when (gnus-data-unread-p (car arts))
9521 (setq result (car arts)
9523 (setq arts (cdr arts)))
9526 (goto-char (gnus-data-pos result))
9527 (gnus-data-number result)))))
9529 (defun gnus-summary-find-prev (&optional unread article)
9530 (let* ((article (or article (gnus-summary-article-number)))
9531 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9533 (when (or (not gnus-summary-check-current)
9535 (not (gnus-data-unread-p (car arts))))
9536 (setq arts (cdr arts)))
9541 (and (gnus-data-unread-p (car arts))
9542 (setq result (car arts)
9544 (setq arts (cdr arts)))
9548 (goto-char (gnus-data-pos result))
9549 (gnus-data-number result)))))
9551 (defun gnus-summary-find-subject (subject &optional unread backward article)
9552 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9553 (article (or article (gnus-summary-article-number)))
9554 (articles (gnus-data-list backward))
9555 (arts (gnus-data-find-list article articles))
9557 (when (or (not gnus-summary-check-current)
9559 (not (gnus-data-unread-p (car arts))))
9560 (setq arts (cdr arts)))
9562 (and (or (not unread)
9563 (gnus-data-unread-p (car arts)))
9564 (vectorp (gnus-data-header (car arts)))
9566 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9567 (setq result (car arts)
9569 (setq arts (cdr arts)))
9571 (goto-char (gnus-data-pos result))
9572 (gnus-data-number result))))
9574 (defun gnus-summary-search-forward (&optional unread subject backward)
9575 "Search forward for an article.
9576 If UNREAD, look for unread articles. If SUBJECT, look for
9577 articles with that subject. If BACKWARD, search backward instead."
9578 (cond (subject (gnus-summary-find-subject subject unread backward))
9579 (backward (gnus-summary-find-prev unread))
9580 (t (gnus-summary-find-next unread))))
9582 (defun gnus-recenter (&optional n)
9583 "Center point in window and redisplay frame.
9584 Also do horizontal recentering."
9586 (when (and gnus-auto-center-summary
9587 (not (eq gnus-auto-center-summary 'vertical)))
9588 (gnus-horizontal-recenter))
9591 (defun gnus-summary-recenter ()
9592 "Center point in the summary window.
9593 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9594 displayed, no centering will be performed."
9595 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9596 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9597 (let* ((top (cond ((< (window-height) 4) 0)
9598 ((< (window-height) 7) 1)
9600 (height (1- (window-height)))
9601 (bottom (save-excursion (goto-char (point-max))
9602 (forward-line (- height))
9604 (window (get-buffer-window (current-buffer))))
9605 ;; The user has to want it.
9606 (when gnus-auto-center-summary
9607 (when (get-buffer-window gnus-article-buffer)
9608 ;; Only do recentering when the article buffer is displayed,
9609 ;; Set the window start to either `bottom', which is the biggest
9610 ;; possible valid number, or the second line from the top,
9611 ;; whichever is the least.
9613 window (min bottom (save-excursion
9614 (forward-line (- top)) (point)))))
9615 ;; Do horizontal recentering while we're at it.
9616 (when (and (get-buffer-window (current-buffer) t)
9617 (not (eq gnus-auto-center-summary 'vertical)))
9618 (let ((selected (selected-window)))
9619 (select-window (get-buffer-window (current-buffer) t))
9620 (gnus-summary-position-point)
9621 (gnus-horizontal-recenter)
9622 (select-window selected))))))
9624 (defun gnus-horizontal-recenter ()
9625 "Recenter the current buffer horizontally."
9626 (if (< (current-column) (/ (window-width) 2))
9627 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9628 (let* ((orig (point))
9629 (end (window-end (get-buffer-window (current-buffer) t)))
9631 ;; Find the longest line currently displayed in the window.
9632 (goto-char (window-start))
9633 (while (and (not (eobp))
9636 (setq max (max max (current-column)))
9639 ;; Scroll horizontally to center (sort of) the point.
9640 (if (> max (window-width))
9642 (get-buffer-window (current-buffer) t)
9643 (min (- (current-column) (/ (window-width) 3))
9644 (+ 2 (- max (window-width)))))
9645 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9648 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9649 (defun gnus-short-group-name (group &optional levels)
9650 "Collapse GROUP name LEVELS."
9657 (while (string-match "\\." group skip)
9658 (setq skip (match-end 0)
9661 (if (string-match ":" group)
9662 (setq foreign (substring group 0 (match-end 0))
9663 group (substring group (match-end 0))))
9665 (if (and (string-match "\\." group)
9666 (> levels (- gnus-group-uncollapsed-levels 1)))
9667 (setq name (concat name (substring group 0 1))
9668 group (substring group (match-end 0))
9670 name (concat name "."))
9671 (setq name (concat foreign name group)
9675 (defun gnus-summary-jump-to-group (newsgroup)
9676 "Move point to NEWSGROUP in group mode buffer."
9677 ;; Keep update point of group mode buffer if visible.
9678 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9679 (save-window-excursion
9680 ;; Take care of tree window mode.
9681 (if (get-buffer-window gnus-group-buffer)
9682 (pop-to-buffer gnus-group-buffer))
9683 (gnus-group-jump-to-group newsgroup))
9685 ;; Take care of tree window mode.
9686 (if (get-buffer-window gnus-group-buffer)
9687 (pop-to-buffer gnus-group-buffer)
9688 (set-buffer gnus-group-buffer))
9689 (gnus-group-jump-to-group newsgroup))))
9691 ;; This function returns a list of article numbers based on the
9692 ;; difference between the ranges of read articles in this group and
9693 ;; the range of active articles.
9694 (defun gnus-list-of-unread-articles (group)
9695 (let* ((read (gnus-info-read (gnus-get-info group)))
9696 (active (gnus-active group))
9699 ;; If none are read, then all are unread.
9701 (setq first (car active))
9702 ;; If the range of read articles is a single range, then the
9703 ;; first unread article is the article after the last read
9704 ;; article. Sounds logical, doesn't it?
9705 (if (not (listp (cdr read)))
9706 (setq first (1+ (cdr read)))
9707 ;; `read' is a list of ranges.
9708 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9713 (while (< first nlast)
9714 (setq unread (cons first unread))
9715 (setq first (1+ first))))
9716 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9717 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9718 (setq read (cdr read)))))
9719 ;; And add the last unread articles.
9720 (while (<= first last)
9721 (setq unread (cons first unread))
9722 (setq first (1+ first)))
9723 ;; Return the list of unread articles.
9726 (defun gnus-list-of-read-articles (group)
9727 "Return a list of unread, unticked and non-dormant articles."
9728 (let* ((info (gnus-get-info group))
9729 (marked (gnus-info-marks info))
9730 (active (gnus-active group)))
9732 (gnus-set-difference
9733 (gnus-sorted-complement
9734 (gnus-uncompress-range active)
9735 (gnus-list-of-unread-articles group))
9737 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9738 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9740 ;; Various summary commands
9742 (defun gnus-summary-universal-argument (arg)
9743 "Perform any operation on all articles that are process/prefixed."
9745 (gnus-set-global-variables)
9746 (let ((articles (gnus-summary-work-articles arg))
9753 (substitute-command-keys
9754 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9757 (gnus-error 1 "Undefined key")
9760 (gnus-summary-goto-subject (setq article (pop articles)))
9761 (command-execute func)
9762 (gnus-summary-remove-process-mark article)))))
9763 (gnus-summary-position-point))
9765 (defun gnus-summary-toggle-truncation (&optional arg)
9766 "Toggle truncation of summary lines.
9767 With arg, turn line truncation on iff arg is positive."
9769 (setq truncate-lines
9770 (if (null arg) (not truncate-lines)
9771 (> (prefix-numeric-value arg) 0)))
9774 (defun gnus-summary-reselect-current-group (&optional all rescan)
9775 "Exit and then reselect the current newsgroup.
9776 The prefix argument ALL means to select all articles."
9778 (gnus-set-global-variables)
9779 (let ((current-subject (gnus-summary-article-number))
9780 (group gnus-newsgroup-name))
9781 (setq gnus-newsgroup-begin nil)
9783 ;; We have to adjust the point of group mode buffer because the
9784 ;; current point was moved to the next unread newsgroup by
9786 (gnus-summary-jump-to-group group)
9789 (gnus-group-get-new-news-this-group 1)))
9790 (gnus-group-read-group all t)
9791 (gnus-summary-goto-subject current-subject)))
9793 (defun gnus-summary-rescan-group (&optional all)
9794 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9796 (gnus-summary-reselect-current-group all t))
9798 (defun gnus-summary-update-info ()
9799 (let* ((group gnus-newsgroup-name))
9800 (when gnus-newsgroup-kill-headers
9801 (setq gnus-newsgroup-killed
9802 (gnus-compress-sequence
9804 (gnus-set-sorted-intersection
9805 (gnus-uncompress-range gnus-newsgroup-killed)
9806 (setq gnus-newsgroup-unselected
9807 (sort gnus-newsgroup-unselected '<)))
9808 (setq gnus-newsgroup-unreads
9809 (sort gnus-newsgroup-unreads '<))) t)))
9810 (unless (listp (cdr gnus-newsgroup-killed))
9811 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9812 (let ((headers gnus-newsgroup-headers))
9813 (run-hooks 'gnus-exit-group-hook)
9814 (unless gnus-save-score
9815 (setq gnus-newsgroup-scored nil))
9816 ;; Set the new ranges of read articles.
9817 (gnus-update-read-articles
9818 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9819 ;; Set the current article marks.
9821 ;; Do the cross-ref thing.
9822 (when gnus-use-cross-reference
9823 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9824 ;; Do adaptive scoring, and possibly save score files.
9825 (when gnus-newsgroup-adaptive
9826 (gnus-score-adaptive))
9827 (when gnus-use-scoring
9829 ;; Do not switch windows but change the buffer to work.
9830 (set-buffer gnus-group-buffer)
9831 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9832 (gnus-group-update-group group)))))
9834 (defun gnus-summary-exit (&optional temporary)
9835 "Exit reading current newsgroup, and then return to group selection mode.
9836 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9838 (gnus-set-global-variables)
9839 (gnus-kill-save-kill-buffer)
9840 (let* ((group gnus-newsgroup-name)
9841 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9843 (buf (current-buffer)))
9844 (run-hooks 'gnus-summary-prepare-exit-hook)
9845 ;; If we have several article buffers, we kill them at exit.
9846 (unless gnus-single-article-buffer
9847 (gnus-kill-buffer gnus-original-article-buffer)
9848 (setq gnus-article-current nil))
9849 (when gnus-use-cache
9850 (gnus-cache-possibly-remove-articles)
9851 (gnus-cache-save-buffers))
9852 (when gnus-use-trees
9853 (gnus-tree-close group))
9854 ;; Make all changes in this group permanent.
9856 (gnus-summary-update-info))
9857 (gnus-close-group group)
9858 ;; Make sure where I was, and go to next newsgroup.
9859 (set-buffer gnus-group-buffer)
9861 (gnus-group-jump-to-group group)
9862 (gnus-group-next-unread-group 1))
9863 (run-hooks 'gnus-summary-exit-hook)
9866 ;; If we have several article buffers, we kill them at exit.
9867 (unless gnus-single-article-buffer
9868 (gnus-kill-buffer gnus-article-buffer)
9869 (gnus-kill-buffer gnus-original-article-buffer)
9870 (setq gnus-article-current nil))
9872 (if (not gnus-kill-summary-on-exit)
9873 (gnus-deaden-summary)
9874 ;; We set all buffer-local variables to nil. It is unclear why
9875 ;; this is needed, but if we don't, buffer-local variables are
9876 ;; not garbage-collected, it seems. This would the lead to en
9877 ;; ever-growing Emacs.
9878 (gnus-summary-clear-local-variables)
9879 (when (get-buffer gnus-article-buffer)
9880 (bury-buffer gnus-article-buffer))
9881 ;; We clear the global counterparts of the buffer-local
9882 ;; variables as well, just to be on the safe side.
9883 (gnus-configure-windows 'group 'force)
9884 (gnus-summary-clear-local-variables)
9885 ;; Return to group mode buffer.
9886 (if (eq mode 'gnus-summary-mode)
9887 (gnus-kill-buffer buf)))
9888 (setq gnus-current-select-method gnus-select-method)
9889 (pop-to-buffer gnus-group-buffer)
9890 ;; Clear the current group name.
9891 (if (not quit-config)
9893 (gnus-group-jump-to-group group)
9894 (gnus-group-next-unread-group 1)
9895 (gnus-configure-windows 'group 'force))
9896 (if (not (buffer-name (car quit-config)))
9897 (gnus-configure-windows 'group 'force)
9898 (set-buffer (car quit-config))
9899 (and (eq major-mode 'gnus-summary-mode)
9900 (gnus-set-global-variables))
9901 (gnus-configure-windows (cdr quit-config))))
9903 (setq gnus-newsgroup-name nil)))))
9905 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9906 (defun gnus-summary-exit-no-update (&optional no-questions)
9907 "Quit reading current newsgroup without updating read article info."
9909 (gnus-set-global-variables)
9910 (let* ((group gnus-newsgroup-name)
9911 (quit-config (gnus-group-quit-config group)))
9912 (when (or no-questions
9914 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9915 ;; If we have several article buffers, we kill them at exit.
9916 (unless gnus-single-article-buffer
9917 (gnus-kill-buffer gnus-article-buffer)
9918 (gnus-kill-buffer gnus-original-article-buffer)
9919 (setq gnus-article-current nil))
9920 (if (not gnus-kill-summary-on-exit)
9921 (gnus-deaden-summary)
9922 (gnus-close-group group)
9923 (gnus-summary-clear-local-variables)
9924 (set-buffer gnus-group-buffer)
9925 (gnus-summary-clear-local-variables)
9926 (when (get-buffer gnus-summary-buffer)
9927 (kill-buffer gnus-summary-buffer)))
9928 (unless gnus-single-article-buffer
9929 (setq gnus-article-current nil))
9930 (when gnus-use-trees
9931 (gnus-tree-close group))
9932 (when (get-buffer gnus-article-buffer)
9933 (bury-buffer gnus-article-buffer))
9934 ;; Return to the group buffer.
9935 (gnus-configure-windows 'group 'force)
9936 ;; Clear the current group name.
9937 (setq gnus-newsgroup-name nil)
9938 (when (equal (gnus-group-group-name) group)
9939 (gnus-group-next-unread-group 1))
9941 (if (not (buffer-name (car quit-config)))
9942 (gnus-configure-windows 'group 'force)
9943 (set-buffer (car quit-config))
9944 (when (eq major-mode 'gnus-summary-mode)
9945 (gnus-set-global-variables))
9946 (gnus-configure-windows (cdr quit-config)))))))
9950 (defvar gnus-dead-summary-mode-map nil)
9952 (if gnus-dead-summary-mode-map
9954 (setq gnus-dead-summary-mode-map (make-keymap))
9955 (suppress-keymap gnus-dead-summary-mode-map)
9956 (substitute-key-definition
9957 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9958 (let ((keys '("\C-d" "\r" "\177")))
9960 (define-key gnus-dead-summary-mode-map
9961 (pop keys) 'gnus-summary-wake-up-the-dead))))
9963 (defvar gnus-dead-summary-mode nil
9964 "Minor mode for Gnus summary buffers.")
9966 (defun gnus-dead-summary-mode (&optional arg)
9967 "Minor mode for Gnus summary buffers."
9969 (when (eq major-mode 'gnus-summary-mode)
9970 (make-local-variable 'gnus-dead-summary-mode)
9971 (setq gnus-dead-summary-mode
9972 (if (null arg) (not gnus-dead-summary-mode)
9973 (> (prefix-numeric-value arg) 0)))
9974 (when gnus-dead-summary-mode
9975 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9976 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9977 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9978 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9979 minor-mode-map-alist)))))
9981 (defun gnus-deaden-summary ()
9982 "Make the current summary buffer into a dead summary buffer."
9983 ;; Kill any previous dead summary buffer.
9984 (when (and gnus-dead-summary
9985 (buffer-name gnus-dead-summary))
9987 (set-buffer gnus-dead-summary)
9988 (when gnus-dead-summary-mode
9989 (kill-buffer (current-buffer)))))
9990 ;; Make this the current dead summary.
9991 (setq gnus-dead-summary (current-buffer))
9992 (gnus-dead-summary-mode 1)
9993 (let ((name (buffer-name)))
9994 (when (string-match "Summary" name)
9996 (concat (substring name 0 (match-beginning 0)) "Dead "
9997 (substring name (match-beginning 0))) t))))
9999 (defun gnus-kill-or-deaden-summary (buffer)
10000 "Kill or deaden the summary BUFFER."
10001 (when (and (buffer-name buffer)
10002 (not gnus-single-article-buffer))
10004 (set-buffer buffer)
10005 (gnus-kill-buffer gnus-article-buffer)
10006 (gnus-kill-buffer gnus-original-article-buffer)))
10007 (cond (gnus-kill-summary-on-exit
10008 (when (and gnus-use-trees
10009 (and (get-buffer buffer)
10010 (buffer-name (get-buffer buffer))))
10012 (set-buffer (get-buffer buffer))
10013 (gnus-tree-close gnus-newsgroup-name)))
10014 (gnus-kill-buffer buffer))
10015 ((and (get-buffer buffer)
10016 (buffer-name (get-buffer buffer)))
10018 (set-buffer buffer)
10019 (gnus-deaden-summary)))))
10021 (defun gnus-summary-wake-up-the-dead (&rest args)
10022 "Wake up the dead summary buffer."
10024 (gnus-dead-summary-mode -1)
10025 (let ((name (buffer-name)))
10026 (when (string-match "Dead " name)
10028 (concat (substring name 0 (match-beginning 0))
10029 (substring name (match-end 0))) t)))
10030 (gnus-message 3 "This dead summary is now alive again"))
10032 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10033 (defun gnus-summary-fetch-faq (&optional faq-dir)
10034 "Fetch the FAQ for the current group.
10035 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10039 (if current-prefix-arg
10041 "Faq dir: " (and (listp gnus-group-faq-directory)
10042 gnus-group-faq-directory)))))
10043 (let (gnus-faq-buffer)
10044 (and (setq gnus-faq-buffer
10045 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10046 (gnus-configure-windows 'summary-faq))))
10048 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10049 (defun gnus-summary-describe-group (&optional force)
10050 "Describe the current newsgroup."
10052 (gnus-group-describe-group force gnus-newsgroup-name))
10054 (defun gnus-summary-describe-briefly ()
10055 "Describe summary mode commands briefly."
10058 (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")))
10060 ;; Walking around group mode buffer from summary mode.
10062 (defun gnus-summary-next-group (&optional no-article target-group backward)
10063 "Exit current newsgroup and then select next unread newsgroup.
10064 If prefix argument NO-ARTICLE is non-nil, no article is selected
10065 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10066 previous group instead."
10068 (gnus-set-global-variables)
10069 (let ((current-group gnus-newsgroup-name)
10070 (current-buffer (current-buffer))
10072 ;; First we semi-exit this group to update Xrefs and all variables.
10073 ;; We can't do a real exit, because the window conf must remain
10074 ;; the same in case the user is prompted for info, and we don't
10075 ;; want the window conf to change before that...
10076 (gnus-summary-exit t)
10077 (while (not entered)
10078 ;; Then we find what group we are supposed to enter.
10079 (set-buffer gnus-group-buffer)
10080 (gnus-group-jump-to-group current-group)
10083 (if (eq gnus-keep-same-level 'best)
10084 (gnus-summary-best-group gnus-newsgroup-name)
10085 (gnus-summary-search-group backward gnus-keep-same-level))))
10086 (if (not target-group)
10087 ;; There are no further groups, so we return to the group
10090 (gnus-message 5 "Returning to the group buffer")
10092 (set-buffer current-buffer)
10093 (gnus-summary-exit))
10094 ;; We try to enter the target group.
10095 (gnus-group-jump-to-group target-group)
10096 (let ((unreads (gnus-group-group-unread)))
10097 (if (and (or (eq t unreads)
10098 (and unreads (not (zerop unreads))))
10099 (gnus-summary-read-group
10100 target-group nil no-article current-buffer))
10102 (setq current-group target-group
10103 target-group nil)))))))
10105 (defun gnus-summary-prev-group (&optional no-article)
10106 "Exit current newsgroup and then select previous unread newsgroup.
10107 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10109 (gnus-summary-next-group no-article nil t))
10111 ;; Walking around summary lines.
10113 (defun gnus-summary-first-subject (&optional unread)
10114 "Go to the first unread subject.
10115 If UNREAD is non-nil, go to the first unread article.
10116 Returns the article selected or nil if there are no unread articles."
10121 ((null gnus-newsgroup-data)
10122 (gnus-message 3 "No articles in the group")
10124 ;; Pick the first article.
10126 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10127 (gnus-data-number (car gnus-newsgroup-data)))
10128 ;; No unread articles.
10129 ((null gnus-newsgroup-unreads)
10130 (gnus-message 3 "No more unread articles")
10132 ;; Find the first unread article.
10134 (let ((data gnus-newsgroup-data))
10136 (not (gnus-data-unread-p (car data))))
10137 (setq data (cdr data)))
10140 (goto-char (gnus-data-pos (car data)))
10141 (gnus-data-number (car data)))))))
10142 (gnus-summary-position-point)))
10144 (defun gnus-summary-next-subject (n &optional unread dont-display)
10145 "Go to next N'th summary line.
10146 If N is negative, go to the previous N'th subject line.
10147 If UNREAD is non-nil, only unread articles are selected.
10148 The difference between N and the actual number of steps taken is
10151 (let ((backward (< n 0))
10153 (while (and (> n 0)
10155 (gnus-summary-find-prev unread)
10156 (gnus-summary-find-next unread)))
10158 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10159 (if unread " unread" "")))
10160 (unless dont-display
10161 (gnus-summary-recenter)
10162 (gnus-summary-position-point))
10165 (defun gnus-summary-next-unread-subject (n)
10166 "Go to next N'th unread summary line."
10168 (gnus-summary-next-subject n t))
10170 (defun gnus-summary-prev-subject (n &optional unread)
10171 "Go to previous N'th summary line.
10172 If optional argument UNREAD is non-nil, only unread article is selected."
10174 (gnus-summary-next-subject (- n) unread))
10176 (defun gnus-summary-prev-unread-subject (n)
10177 "Go to previous N'th unread summary line."
10179 (gnus-summary-next-subject (- n) t))
10181 (defun gnus-summary-goto-subject (article &optional force silent)
10182 "Go the subject line of ARTICLE.
10183 If FORCE, also allow jumping to articles not currently shown."
10185 (data (gnus-data-find article)))
10186 ;; We read in the article if we have to.
10189 (gnus-summary-insert-subject article)
10190 (setq data (gnus-data-find article)))
10195 (gnus-message 3 "Can't find article %d" article))
10197 (goto-char (gnus-data-pos data))
10200 ;; Walking around summary lines with displaying articles.
10202 (defun gnus-summary-expand-window (&optional arg)
10203 "Make the summary buffer take up the entire Emacs frame.
10204 Given a prefix, will force an `article' buffer configuration."
10206 (gnus-set-global-variables)
10208 (gnus-configure-windows 'article 'force)
10209 (gnus-configure-windows 'summary 'force)))
10211 (defun gnus-summary-display-article (article &optional all-header)
10212 "Display ARTICLE in article buffer."
10213 (gnus-set-global-variables)
10217 (if gnus-summary-display-article-function
10218 (funcall gnus-summary-display-article-function article all-header)
10219 (gnus-article-prepare article all-header))
10220 (run-hooks 'gnus-select-article-hook)
10221 (unless (zerop gnus-current-article)
10222 (gnus-summary-goto-subject gnus-current-article))
10223 (gnus-summary-recenter)
10224 (when gnus-use-trees
10225 (gnus-possibly-generate-tree article)
10226 (gnus-highlight-selected-tree article))
10227 ;; Successfully display article.
10228 (gnus-article-set-window-start
10229 (cdr (assq article gnus-newsgroup-bookmarks))))))
10231 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10232 "Select the current article.
10233 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10234 non-nil, the article will be re-fetched even if it already present in
10235 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10237 ;; Make sure we are in the summary buffer to work around bbdb bug.
10238 (unless (eq major-mode 'gnus-summary-mode)
10239 (set-buffer gnus-summary-buffer))
10240 (let ((article (or article (gnus-summary-article-number)))
10241 (all-headers (not (not all-headers))) ;Must be T or NIL.
10242 gnus-summary-display-article-function
10245 (gnus-summary-article-pseudo-p article)
10246 (error "This is a pseudo-article."))
10249 (set-buffer gnus-summary-buffer)
10250 (if (or (and gnus-single-article-buffer
10251 (or (null gnus-current-article)
10252 (null gnus-article-current)
10253 (null (get-buffer gnus-article-buffer))
10254 (not (eq article (cdr gnus-article-current)))
10255 (not (equal (car gnus-article-current)
10256 gnus-newsgroup-name))))
10257 (and (not gnus-single-article-buffer)
10258 (or (null gnus-current-article)
10259 (not (eq gnus-current-article article))))
10261 ;; The requested article is different from the current article.
10263 (gnus-summary-display-article article all-headers)
10264 (setq did article))
10265 (if (or all-headers gnus-show-all-headers)
10266 (gnus-article-show-all-headers))
10269 (gnus-article-set-window-start
10270 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10272 (defun gnus-summary-set-current-mark (&optional current-mark)
10273 "Obsolete function."
10276 (defun gnus-summary-next-article (&optional unread subject backward push)
10277 "Select the next article.
10278 If UNREAD, only unread articles are selected.
10279 If SUBJECT, only articles with SUBJECT are selected.
10280 If BACKWARD, the previous article is selected instead of the next."
10282 (gnus-set-global-variables)
10284 ;; Is there such an article?
10285 ((and (gnus-summary-search-forward unread subject backward)
10286 (or (gnus-summary-display-article (gnus-summary-article-number))
10287 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10288 (gnus-summary-position-point))
10289 ;; If not, we try the first unread, if that is wanted.
10291 gnus-auto-select-same
10292 (or (gnus-summary-first-unread-article)
10293 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10294 (gnus-summary-position-point)
10295 (gnus-message 6 "Wrapped"))
10296 ;; Try to get next/previous article not displayed in this group.
10297 ((and gnus-auto-extend-newsgroup
10298 (not unread) (not subject))
10299 (gnus-summary-goto-article
10300 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10302 ;; Go to next/previous group.
10304 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10305 (gnus-summary-jump-to-group gnus-newsgroup-name))
10306 (let ((cmd last-command-char)
10308 (if (eq gnus-keep-same-level 'best)
10309 (gnus-summary-best-group gnus-newsgroup-name)
10310 (gnus-summary-search-group backward gnus-keep-same-level))))
10311 ;; For some reason, the group window gets selected. We change
10313 (select-window (get-buffer-window (current-buffer)))
10314 ;; Select next unread newsgroup automagically.
10316 ((not gnus-auto-select-next)
10317 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10318 ((or (eq gnus-auto-select-next 'quietly)
10319 (and (eq gnus-auto-select-next 'slightly-quietly)
10321 (and (eq gnus-auto-select-next 'almost-quietly)
10322 (gnus-summary-last-article-p)))
10324 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10325 (gnus-summary-exit)
10326 (gnus-message 7 "No more%s articles (%s)..."
10327 (if unread " unread" "")
10328 (if group (concat "selecting " group)
10330 (gnus-summary-next-group nil group backward)))
10332 (gnus-summary-walk-group-buffer
10333 gnus-newsgroup-name cmd unread backward)))))))
10335 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10336 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10337 (?\C-p (gnus-group-prev-unread-group 1))))
10338 keve key group ended)
10340 (set-buffer gnus-group-buffer)
10341 (gnus-summary-jump-to-group from-group)
10343 (if (eq gnus-keep-same-level 'best)
10344 (gnus-summary-best-group gnus-newsgroup-name)
10345 (gnus-summary-search-group backward gnus-keep-same-level))))
10348 5 "No more%s articles%s" (if unread " unread" "")
10350 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10351 (format " (Type %s for %s [%s])"
10352 (single-key-description cmd) group
10353 (car (gnus-gethash group gnus-newsrc-hashtb)))
10354 (format " (Type %s to exit %s)"
10355 (single-key-description cmd)
10356 gnus-newsgroup-name)))
10357 ;; Confirm auto selection.
10358 (setq key (car (setq keve (gnus-read-event-char))))
10361 ((assq key keystrokes)
10362 (let ((obuf (current-buffer)))
10363 (switch-to-buffer gnus-group-buffer)
10365 (gnus-group-jump-to-group group))
10366 (eval (cadr (assq key keystrokes)))
10367 (setq group (gnus-group-group-name))
10368 (switch-to-buffer obuf))
10371 (if (or (not group)
10372 (gnus-ephemeral-group-p gnus-newsgroup-name))
10373 (gnus-summary-exit)
10374 (gnus-summary-next-group nil group backward)))
10376 (push (cdr keve) unread-command-events))))))
10378 (defun gnus-read-event-char ()
10379 "Get the next event."
10380 (let ((event (read-event)))
10381 (cons (and (numberp event) event) event)))
10383 (defun gnus-summary-next-unread-article ()
10384 "Select unread article after current one."
10386 (gnus-summary-next-article t (and gnus-auto-select-same
10387 (gnus-summary-article-subject))))
10389 (defun gnus-summary-prev-article (&optional unread subject)
10390 "Select the article after the current one.
10391 If UNREAD is non-nil, only unread articles are selected."
10393 (gnus-summary-next-article unread subject t))
10395 (defun gnus-summary-prev-unread-article ()
10396 "Select unred article before current one."
10398 (gnus-summary-prev-article t (and gnus-auto-select-same
10399 (gnus-summary-article-subject))))
10401 (defun gnus-summary-next-page (&optional lines circular)
10402 "Show next page of the selected article.
10403 If at the end of the current article, select the next article.
10404 LINES says how many lines should be scrolled up.
10406 If CIRCULAR is non-nil, go to the start of the article instead of
10407 selecting the next article when reaching the end of the current
10410 (setq gnus-summary-buffer (current-buffer))
10411 (gnus-set-global-variables)
10412 (let ((article (gnus-summary-article-number))
10414 (gnus-configure-windows 'article)
10415 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10416 (if (and (eq gnus-summary-goto-unread 'never)
10417 (not (gnus-summary-last-article-p article)))
10418 (gnus-summary-next-article)
10419 (gnus-summary-next-unread-article))
10420 (if (or (null gnus-current-article)
10421 (null gnus-article-current)
10422 (/= article (cdr gnus-article-current))
10423 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10424 ;; Selected subject is different from current article's.
10425 (gnus-summary-display-article article)
10426 (gnus-eval-in-buffer-window
10427 gnus-article-buffer
10428 (setq endp (gnus-article-next-page lines)))
10431 (gnus-summary-beginning-of-article))
10433 (gnus-message 3 "End of message"))
10435 (if (and (eq gnus-summary-goto-unread 'never)
10436 (not (gnus-summary-last-article-p article)))
10437 (gnus-summary-next-article)
10438 (gnus-summary-next-unread-article)))))))
10439 (gnus-summary-recenter)
10440 (gnus-summary-position-point)))
10442 (defun gnus-summary-prev-page (&optional lines)
10443 "Show previous page of selected article.
10444 Argument LINES specifies lines to be scrolled down."
10446 (gnus-set-global-variables)
10447 (let ((article (gnus-summary-article-number)))
10448 (gnus-configure-windows 'article)
10449 (if (or (null gnus-current-article)
10450 (null gnus-article-current)
10451 (/= article (cdr gnus-article-current))
10452 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10453 ;; Selected subject is different from current article's.
10454 (gnus-summary-display-article article)
10455 (gnus-summary-recenter)
10456 (gnus-eval-in-buffer-window gnus-article-buffer
10457 (gnus-article-prev-page lines))))
10458 (gnus-summary-position-point))
10460 (defun gnus-summary-scroll-up (lines)
10461 "Scroll up (or down) one line current article.
10462 Argument LINES specifies lines to be scrolled up (or down if negative)."
10464 (gnus-set-global-variables)
10465 (gnus-configure-windows 'article)
10466 (gnus-summary-show-thread)
10467 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10468 (gnus-eval-in-buffer-window
10469 gnus-article-buffer
10471 (if (gnus-article-next-page lines)
10472 (gnus-message 3 "End of message")))
10474 (gnus-article-prev-page (- lines))))))
10475 (gnus-summary-recenter)
10476 (gnus-summary-position-point))
10478 (defun gnus-summary-next-same-subject ()
10479 "Select next article which has the same subject as current one."
10481 (gnus-set-global-variables)
10482 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10484 (defun gnus-summary-prev-same-subject ()
10485 "Select previous article which has the same subject as current one."
10487 (gnus-set-global-variables)
10488 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10490 (defun gnus-summary-next-unread-same-subject ()
10491 "Select next unread article which has the same subject as current one."
10493 (gnus-set-global-variables)
10494 (gnus-summary-next-article t (gnus-summary-article-subject)))
10496 (defun gnus-summary-prev-unread-same-subject ()
10497 "Select previous unread article which has the same subject as current one."
10499 (gnus-set-global-variables)
10500 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10502 (defun gnus-summary-first-unread-article ()
10503 "Select the first unread article.
10504 Return nil if there are no unread articles."
10506 (gnus-set-global-variables)
10508 (if (gnus-summary-first-subject t)
10510 (gnus-summary-show-thread)
10511 (gnus-summary-first-subject t)
10512 (gnus-summary-display-article (gnus-summary-article-number))))
10513 (gnus-summary-position-point)))
10515 (defun gnus-summary-best-unread-article ()
10516 "Select the unread article with the highest score."
10518 (gnus-set-global-variables)
10519 (let ((best -1000000)
10520 (data gnus-newsgroup-data)
10523 (and (gnus-data-unread-p (car data))
10525 (gnus-summary-article-score (gnus-data-number (car data))))
10528 article (gnus-data-number (car data))))
10529 (setq data (cdr data)))
10532 (gnus-summary-goto-article article)
10533 (error "No unread articles"))
10534 (gnus-summary-position-point))))
10536 (defun gnus-summary-last-subject ()
10537 "Go to the last displayed subject line in the group."
10538 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10540 (gnus-summary-goto-subject article))))
10542 (defun gnus-summary-goto-article (article &optional all-headers force)
10543 "Fetch ARTICLE and display it if it exists.
10544 If ALL-HEADERS is non-nil, no header lines are hidden."
10550 (mapcar (lambda (number) (list (int-to-string number)))
10551 gnus-newsgroup-limit)))
10555 (if (gnus-summary-goto-subject article force)
10556 (gnus-summary-display-article article all-headers)
10557 (gnus-message 4 "Couldn't go to article %s" article) nil)
10558 (gnus-summary-position-point)))
10560 (defun gnus-summary-goto-last-article ()
10561 "Go to the previously read article."
10564 (and gnus-last-article
10565 (gnus-summary-goto-article gnus-last-article))
10566 (gnus-summary-position-point)))
10568 (defun gnus-summary-pop-article (number)
10569 "Pop one article off the history and go to the previous.
10570 NUMBER articles will be popped off."
10573 (setq gnus-newsgroup-history
10574 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10576 (gnus-summary-goto-article (car to))
10577 (error "Article history empty")))
10578 (gnus-summary-position-point))
10580 ;; Summary commands and functions for limiting the summary buffer.
10582 (defun gnus-summary-limit-to-articles (n)
10583 "Limit the summary buffer to the next N articles.
10584 If not given a prefix, use the process marked articles instead."
10586 (gnus-set-global-variables)
10588 (let ((articles (gnus-summary-work-articles n)))
10589 (setq gnus-newsgroup-processable nil)
10590 (gnus-summary-limit articles))
10591 (gnus-summary-position-point)))
10593 (defun gnus-summary-pop-limit (&optional total)
10594 "Restore the previous limit.
10595 If given a prefix, remove all limits."
10597 (gnus-set-global-variables)
10599 (setq gnus-newsgroup-limits
10600 (list (mapcar (lambda (h) (mail-header-number h))
10601 gnus-newsgroup-headers))))
10602 (unless gnus-newsgroup-limits
10603 (error "No limit to pop"))
10605 (gnus-summary-limit nil 'pop)
10606 (gnus-summary-position-point)))
10608 (defun gnus-summary-limit-to-subject (subject &optional header)
10609 "Limit the summary buffer to articles that have subjects that match a regexp."
10610 (interactive "sRegexp: ")
10612 (setq header "subject"))
10613 (when (not (equal "" subject))
10615 (let ((articles (gnus-summary-find-matching
10616 (or header "subject") subject 'all)))
10617 (or articles (error "Found no matches for \"%s\"" subject))
10618 (gnus-summary-limit articles))
10619 (gnus-summary-position-point))))
10621 (defun gnus-summary-limit-to-author (from)
10622 "Limit the summary buffer to articles that have authors that match a regexp."
10623 (interactive "sRegexp: ")
10624 (gnus-summary-limit-to-subject from "from"))
10626 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10628 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10630 (defun gnus-summary-limit-to-unread (&optional all)
10631 "Limit the summary buffer to articles that are not marked as read.
10632 If ALL is non-nil, limit strictly to unread articles."
10635 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10636 (gnus-summary-limit-to-marks
10637 ;; Concat all the marks that say that an article is read and have
10639 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10640 gnus-killed-mark gnus-kill-file-mark
10641 gnus-low-score-mark gnus-expirable-mark
10642 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10645 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10646 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10648 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10649 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10650 If REVERSE, limit the summary buffer to articles that are not marked
10651 with MARKS. MARKS can either be a string of marks or a list of marks.
10652 Returns how many articles were removed."
10653 (interactive "sMarks: ")
10654 (gnus-set-global-variables)
10656 (let ((data gnus-newsgroup-data)
10657 (marks (if (listp marks) marks
10658 (append marks nil))) ; Transform to list.
10661 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10662 (memq (gnus-data-mark (car data)) marks))
10663 (setq articles (cons (gnus-data-number (car data)) articles)))
10664 (setq data (cdr data)))
10665 (gnus-summary-limit articles))
10666 (gnus-summary-position-point)))
10668 (defun gnus-summary-limit-to-score (&optional score)
10669 "Limit to articles with score at or above SCORE."
10671 (gnus-set-global-variables)
10672 (setq score (if score
10673 (prefix-numeric-value score)
10674 (or gnus-summary-default-score 0)))
10675 (let ((data gnus-newsgroup-data)
10678 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10680 (push (gnus-data-number (car data)) articles))
10681 (setq data (cdr data)))
10683 (gnus-summary-limit articles)
10684 (gnus-summary-position-point))))
10686 (defun gnus-summary-limit-include-dormant ()
10687 "Display all the hidden articles that are marked as dormant."
10689 (gnus-set-global-variables)
10690 (or gnus-newsgroup-dormant
10691 (error "There are no dormant articles in this group"))
10693 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10694 (gnus-summary-position-point)))
10696 (defun gnus-summary-limit-exclude-dormant ()
10697 "Hide all dormant articles."
10699 (gnus-set-global-variables)
10701 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10702 (gnus-summary-position-point)))
10704 (defun gnus-summary-limit-exclude-childless-dormant ()
10705 "Hide all dormant articles that have no children."
10707 (gnus-set-global-variables)
10708 (let ((data (gnus-data-list t))
10709 articles d children)
10710 ;; Find all articles that are either not dormant or have
10712 (while (setq d (pop data))
10713 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10714 (and (setq children
10715 (gnus-article-children (gnus-data-number d)))
10718 (when (memq (car children) articles)
10723 (push (gnus-data-number d) articles)))
10724 ;; Do the limiting.
10726 (gnus-summary-limit articles)
10727 (gnus-summary-position-point))))
10729 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10730 "Mark all unread excluded articles as read.
10731 If ALL, mark even excluded ticked and dormants as read."
10733 (let ((articles (gnus-sorted-complement
10735 (mapcar (lambda (h) (mail-header-number h))
10736 gnus-newsgroup-headers)
10738 (sort gnus-newsgroup-limit '<)))
10740 (setq gnus-newsgroup-unreads nil)
10742 (setq gnus-newsgroup-dormant nil
10743 gnus-newsgroup-marked nil
10744 gnus-newsgroup-reads
10746 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10747 gnus-newsgroup-reads))
10748 (while (setq article (pop articles))
10749 (unless (or (memq article gnus-newsgroup-dormant)
10750 (memq article gnus-newsgroup-marked))
10751 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10753 (defun gnus-summary-limit (articles &optional pop)
10755 ;; We pop the previous limit off the stack and use that.
10756 (setq articles (car gnus-newsgroup-limits)
10757 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10758 ;; We use the new limit, so we push the old limit on the stack.
10759 (setq gnus-newsgroup-limits
10760 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10762 (setq gnus-newsgroup-limit articles)
10763 (let ((total (length gnus-newsgroup-data))
10764 (data (gnus-data-find-list (gnus-summary-article-number)))
10766 ;; This will do all the work of generating the new summary buffer
10767 ;; according to the new limit.
10768 (gnus-summary-prepare)
10769 ;; Hide any threads, possibly.
10770 (and gnus-show-threads
10771 gnus-thread-hide-subtree
10772 (gnus-summary-hide-all-threads))
10773 ;; Try to return to the article you were at, or one in the
10776 ;; We try to find some article after the current one.
10778 (and (gnus-summary-goto-subject
10779 (gnus-data-number (car data)) nil t)
10782 (setq data (cdr data))))
10784 ;; If there is no data, that means that we were after the last
10785 ;; article. The same goes when we can't find any articles
10786 ;; after the current one.
10788 (goto-char (point-max))
10789 (gnus-summary-find-prev)))
10790 ;; We return how many articles were removed from the summary
10791 ;; buffer as a result of the new limit.
10792 (- total (length gnus-newsgroup-data))))
10794 (defsubst gnus-cut-thread (thread)
10795 "Go forwards in the thread until we find an article that we want to display."
10796 (when (eq gnus-fetch-old-headers 'some)
10797 ;; Deal with old-fetched headers.
10799 (memq (mail-header-number (car thread))
10800 gnus-newsgroup-ancient)
10801 (<= (length (cdr thread)) 1))
10802 (setq thread (cadr thread))))
10803 ;; Deal with sparse threads.
10804 (when (or (eq gnus-build-sparse-threads 'some)
10805 (eq gnus-build-sparse-threads 'more))
10807 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10808 (= (length (cdr thread)) 1))
10809 (setq thread (cadr thread))))
10812 (defun gnus-cut-threads (threads)
10813 "Cut off all uninteresting articles from the beginning of threads."
10814 (when (or (eq gnus-fetch-old-headers 'some)
10815 (eq gnus-build-sparse-threads 'some)
10816 (eq gnus-build-sparse-threads 'more))
10817 (let ((th threads))
10819 (setcar th (gnus-cut-thread (car th)))
10820 (setq th (cdr th)))))
10821 ;; Remove nixed out threads.
10822 (delq nil threads))
10824 (defun gnus-summary-initial-limit (&optional show-if-empty)
10825 "Figure out what the initial limit is supposed to be on group entry.
10826 This entails weeding out unwanted dormants, low-scored articles,
10827 fetch-old-headers verbiage, and so on."
10828 ;; Most groups have nothing to remove.
10829 (if (or gnus-inhibit-limiting
10830 (and (null gnus-newsgroup-dormant)
10831 (not (eq gnus-fetch-old-headers 'some))
10832 (null gnus-summary-expunge-below)
10833 (not (eq gnus-build-sparse-threads 'some))
10834 (not (eq gnus-build-sparse-threads 'more))
10835 (null gnus-thread-expunge-below)
10836 (not gnus-use-nocem)))
10838 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10839 (setq gnus-newsgroup-limit nil)
10842 (unless (car (symbol-value node))
10843 ;; These threads have no parents -- they are roots.
10844 (let ((nodes (cdr (symbol-value node)))
10847 (if (and gnus-thread-expunge-below
10848 (< (gnus-thread-total-score (car nodes))
10849 gnus-thread-expunge-below))
10850 (gnus-expunge-thread (pop nodes))
10851 (setq thread (pop nodes))
10852 (gnus-summary-limit-children thread))))))
10853 gnus-newsgroup-dependencies)
10854 ;; If this limitation resulted in an empty group, we might
10855 ;; pop the previous limit and use it instead.
10856 (when (and (not gnus-newsgroup-limit)
10858 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10859 gnus-newsgroup-limit))
10861 (defun gnus-summary-limit-children (thread)
10862 "Return 1 if this subthread is visible and 0 if it is not."
10863 ;; First we get the number of visible children to this thread. This
10864 ;; is done by recursing down the thread using this function, so this
10865 ;; will really go down to a leaf article first, before slowly
10866 ;; working its way up towards the root.
10870 (apply '+ (mapcar 'gnus-summary-limit-children
10873 (number (mail-header-number (car thread)))
10876 ;; If this article is dormant and has absolutely no visible
10877 ;; children, then this article isn't visible.
10878 (and (memq number gnus-newsgroup-dormant)
10880 ;; If this is a "fetch-old-headered" and there is only one
10881 ;; visible child (or less), then we don't want this article.
10882 (and (eq gnus-fetch-old-headers 'some)
10883 (memq number gnus-newsgroup-ancient)
10885 ;; If this is a sparsely inserted article with no children,
10886 ;; we don't want it.
10887 (and (eq gnus-build-sparse-threads 'some)
10888 (memq number gnus-newsgroup-sparse)
10890 ;; If we use expunging, and this article is really
10891 ;; low-scored, then we don't want this article.
10892 (when (and gnus-summary-expunge-below
10894 (or (cdr (assq number gnus-newsgroup-scored))
10895 gnus-summary-default-score))
10896 gnus-summary-expunge-below))
10897 ;; We increase the expunge-tally here, but that has
10898 ;; nothing to do with the limits, really.
10899 (incf gnus-newsgroup-expunged-tally)
10900 ;; We also mark as read here, if that's wanted.
10901 (when (and gnus-summary-mark-below
10902 (< score gnus-summary-mark-below))
10903 (setq gnus-newsgroup-unreads
10904 (delq number gnus-newsgroup-unreads))
10905 (if gnus-newsgroup-auto-expire
10906 (push number gnus-newsgroup-expirable)
10907 (push (cons number gnus-low-score-mark)
10908 gnus-newsgroup-reads)))
10910 (and gnus-use-nocem
10911 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10912 ;; Nope, invisible article.
10914 ;; Ok, this article is to be visible, so we add it to the limit
10916 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10919 (defun gnus-expunge-thread (thread)
10920 "Mark all articles in THREAD as read."
10921 (let* ((number (mail-header-number (car thread))))
10922 (incf gnus-newsgroup-expunged-tally)
10923 ;; We also mark as read here, if that's wanted.
10924 (setq gnus-newsgroup-unreads
10925 (delq number gnus-newsgroup-unreads))
10926 (if gnus-newsgroup-auto-expire
10927 (push number gnus-newsgroup-expirable)
10928 (push (cons number gnus-low-score-mark)
10929 gnus-newsgroup-reads)))
10930 ;; Go recursively through all subthreads.
10931 (mapcar 'gnus-expunge-thread (cdr thread)))
10933 ;; Summary article oriented commands
10935 (defun gnus-summary-refer-parent-article (n)
10936 "Refer parent article N times.
10937 The difference between N and the number of articles fetched is returned."
10939 (gnus-set-global-variables)
10943 (let* ((header (gnus-summary-article-header))
10945 ;; If we try to find the parent of the currently
10946 ;; displayed article, then we take a look at the actual
10947 ;; References header, since this is slightly more
10948 ;; reliable than the References field we got from the
10950 (if (and (eq (mail-header-number header)
10951 (cdr gnus-article-current))
10952 (equal gnus-newsgroup-name
10953 (car gnus-article-current)))
10955 (set-buffer gnus-original-article-buffer)
10956 (nnheader-narrow-to-headers)
10958 (message-fetch-field "references")
10960 ;; It's not the current article, so we take a bet on
10961 ;; the value we got from the server.
10962 (mail-header-references header))))
10963 (if (setq ref (or ref (mail-header-references header)))
10964 (or (gnus-summary-refer-article (gnus-parent-id ref))
10965 (gnus-message 1 "Couldn't find parent"))
10966 (gnus-message 1 "No references in article %d"
10967 (gnus-summary-article-number))
10970 (gnus-summary-position-point)
10973 (defun gnus-summary-refer-references ()
10974 "Fetch all articles mentioned in the References header.
10975 Return how many articles were fetched."
10977 (gnus-set-global-variables)
10978 (let ((ref (mail-header-references (gnus-summary-article-header)))
10979 (current (gnus-summary-article-number))
10981 ;; For each Message-ID in the References header...
10982 (while (string-match "<[^>]*>" ref)
10984 ;; ... fetch that article.
10985 (gnus-summary-refer-article
10986 (prog1 (match-string 0 ref)
10987 (setq ref (substring ref (match-end 0))))))
10988 (gnus-summary-goto-subject current)
10989 (gnus-summary-position-point)
10992 (defun gnus-summary-refer-article (message-id)
10993 "Fetch an article specified by MESSAGE-ID."
10994 (interactive "sMessage-ID: ")
10995 (when (and (stringp message-id)
10996 (not (zerop (length message-id))))
10997 ;; Construct the correct Message-ID if necessary.
10998 ;; Suggested by tale@pawl.rpi.edu.
10999 (unless (string-match "^<" message-id)
11000 (setq message-id (concat "<" message-id)))
11001 (unless (string-match ">$" message-id)
11002 (setq message-id (concat message-id ">")))
11003 (let ((header (car (gnus-gethash message-id
11004 gnus-newsgroup-dependencies))))
11006 ;; The article is present in the buffer, to we just go to it.
11007 (gnus-summary-goto-article (mail-header-number header) nil t)
11008 ;; We fetch the article
11009 (let ((gnus-override-method
11010 (and (gnus-news-group-p gnus-newsgroup-name)
11011 gnus-refer-article-method))
11013 ;; Start the special refer-article method, if necessary.
11014 (when (and gnus-refer-article-method
11015 (gnus-news-group-p gnus-newsgroup-name))
11016 (gnus-check-server gnus-refer-article-method))
11017 ;; Fetch the header, and display the article.
11018 (if (setq number (gnus-summary-insert-subject message-id))
11019 (gnus-summary-select-article nil nil nil number)
11020 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11022 (defun gnus-summary-enter-digest-group (&optional force)
11023 "Enter a digest group based on the current article."
11025 (gnus-set-global-variables)
11026 (gnus-summary-select-article)
11027 (let ((name (format "%s-%d"
11028 (gnus-group-prefixed-name
11029 gnus-newsgroup-name (list 'nndoc ""))
11030 gnus-current-article))
11031 (ogroup gnus-newsgroup-name)
11032 (case-fold-search t)
11033 (buf (current-buffer))
11036 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11037 (insert-buffer-substring gnus-original-article-buffer)
11039 (goto-char (point-min))
11040 (or (search-forward "\n\n" nil t) (point)))
11041 (goto-char (point-min))
11042 (delete-matching-lines "^\\(Path\\):\\|^From ")
11045 (if (gnus-group-read-ephemeral-group
11046 name `(nndoc ,name (nndoc-address
11048 (nndoc-article-type ,(if force 'digest 'guess))) t)
11049 ;; Make all postings to this group go to the parent group.
11050 (nconc (gnus-info-params (gnus-get-info name))
11051 (list (cons 'to-group ogroup)))
11052 ;; Couldn't select this doc group.
11053 (switch-to-buffer buf)
11054 (gnus-set-global-variables)
11055 (gnus-configure-windows 'summary)
11056 (gnus-message 3 "Article couldn't be entered?"))
11057 (kill-buffer dig))))
11059 (defun gnus-summary-isearch-article (&optional regexp-p)
11060 "Do incremental search forward on the current article.
11061 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11063 (gnus-set-global-variables)
11064 (gnus-summary-select-article)
11065 (gnus-configure-windows 'article)
11066 (gnus-eval-in-buffer-window
11067 gnus-article-buffer
11068 (goto-char (point-min))
11069 (isearch-forward regexp-p)))
11071 (defun gnus-summary-search-article-forward (regexp &optional backward)
11072 "Search for an article containing REGEXP forward.
11073 If BACKWARD, search backward instead."
11076 (format "Search article %s (regexp%s): "
11077 (if current-prefix-arg "backward" "forward")
11078 (if gnus-last-search-regexp
11079 (concat ", default " gnus-last-search-regexp)
11081 current-prefix-arg))
11082 (gnus-set-global-variables)
11083 (if (string-equal regexp "")
11084 (setq regexp (or gnus-last-search-regexp ""))
11085 (setq gnus-last-search-regexp regexp))
11086 (if (gnus-summary-search-article regexp backward)
11087 (gnus-article-set-window-start
11088 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
11089 (error "Search failed: \"%s\"" regexp)))
11091 (defun gnus-summary-search-article-backward (regexp)
11092 "Search for an article containing REGEXP backward."
11095 (format "Search article backward (regexp%s): "
11096 (if gnus-last-search-regexp
11097 (concat ", default " gnus-last-search-regexp)
11099 (gnus-summary-search-article-forward regexp 'backward))
11101 (defun gnus-summary-search-article (regexp &optional backward)
11102 "Search for an article containing REGEXP.
11103 Optional argument BACKWARD means do search for backward.
11104 `gnus-select-article-hook' is not called during the search."
11105 (let ((gnus-select-article-hook nil) ;Disable hook.
11106 (gnus-article-display-hook nil)
11107 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11110 're-search-backward 're-search-forward))
11111 (sum (current-buffer))
11113 (gnus-save-hidden-threads
11114 (gnus-summary-select-article)
11115 (set-buffer gnus-article-buffer)
11117 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11119 (re-search-backward regexp nil t)
11120 (re-search-forward regexp nil t))
11121 ;; We found the regexp.
11123 (setq found 'found)
11124 (beginning-of-line)
11126 (get-buffer-window (current-buffer))
11128 ;; We didn't find it, so we go to the next article.
11130 (if (not (if backward (gnus-summary-find-prev)
11131 (gnus-summary-find-next)))
11132 ;; No more articles.
11134 ;; Select the next article and adjust point.
11135 (gnus-summary-select-article)
11136 (set-buffer gnus-article-buffer)
11138 (goto-char (if backward (point-max) (point-min))))))
11140 (gnus-message 7 ""))
11141 ;; Return whether we found the regexp.
11142 (when (eq found 'found)
11143 (gnus-summary-show-thread)
11144 (gnus-summary-goto-subject gnus-current-article)
11145 (gnus-summary-position-point)
11148 (defun gnus-summary-find-matching (header regexp &optional backward unread
11150 "Return a list of all articles that match REGEXP on HEADER.
11151 The search stars on the current article and goes forwards unless
11152 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11153 If UNREAD is non-nil, only unread articles will
11154 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11155 in the comparisons."
11156 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11157 (gnus-data-find-list
11158 (gnus-summary-article-number) (gnus-data-list backward))))
11159 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11160 (case-fold-search (not not-case-fold))
11162 (or (fboundp (intern (concat "mail-header-" header)))
11163 (error "%s is not a valid header" header))
11165 (setq d (car data))
11166 (and (or (not unread) ; We want all articles...
11167 (gnus-data-unread-p d)) ; Or just unreads.
11168 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11169 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11170 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11171 (setq data (cdr data)))
11172 (nreverse articles)))
11174 (defun gnus-summary-execute-command (header regexp command &optional backward)
11175 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11176 If HEADER is an empty string (or nil), the match is done on the entire
11177 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11179 (list (let ((completion-ignore-case t))
11182 (mapcar (lambda (string) (list string))
11183 '("Number" "Subject" "From" "Lines" "Date"
11184 "Message-ID" "Xref" "References" "Body"))
11185 nil 'require-match))
11186 (read-string "Regexp: ")
11187 (read-key-sequence "Command: ")
11188 current-prefix-arg))
11189 (when (equal header "Body")
11191 (gnus-set-global-variables)
11192 ;; Hidden thread subtrees must be searched as well.
11193 (gnus-summary-show-all-threads)
11194 ;; We don't want to change current point nor window configuration.
11196 (save-window-excursion
11197 (gnus-message 6 "Executing %s..." (key-description command))
11198 ;; We'd like to execute COMMAND interactively so as to give arguments.
11199 (gnus-execute header regexp
11200 `(lambda () (call-interactively ',(key-binding command)))
11202 (gnus-message 6 "Executing %s...done" (key-description command)))))
11204 (defun gnus-summary-beginning-of-article ()
11205 "Scroll the article back to the beginning."
11207 (gnus-set-global-variables)
11208 (gnus-summary-select-article)
11209 (gnus-configure-windows 'article)
11210 (gnus-eval-in-buffer-window
11211 gnus-article-buffer
11213 (goto-char (point-min))
11214 (and gnus-break-pages (gnus-narrow-to-page))))
11216 (defun gnus-summary-end-of-article ()
11217 "Scroll to the end of the article."
11219 (gnus-set-global-variables)
11220 (gnus-summary-select-article)
11221 (gnus-configure-windows 'article)
11222 (gnus-eval-in-buffer-window
11223 gnus-article-buffer
11225 (goto-char (point-max))
11227 (and gnus-break-pages (gnus-narrow-to-page))))
11229 (defun gnus-summary-show-article (&optional arg)
11230 "Force re-fetching of the current article.
11231 If ARG (the prefix) is non-nil, show the raw article without any
11232 article massaging functions being run."
11234 (gnus-set-global-variables)
11236 ;; Select the article the normal way.
11237 (gnus-summary-select-article nil 'force)
11238 ;; Bind the article treatment functions to nil.
11239 (let ((gnus-have-all-headers t)
11240 gnus-article-display-hook
11241 gnus-article-prepare-hook
11244 (gnus-summary-select-article nil 'force)))
11245 (gnus-summary-goto-subject gnus-current-article)
11246 ; (gnus-configure-windows 'article)
11247 (gnus-summary-position-point))
11249 (defun gnus-summary-verbose-headers (&optional arg)
11250 "Toggle permanent full header display.
11251 If ARG is a positive number, turn header display on.
11252 If ARG is a negative number, turn header display off."
11254 (gnus-set-global-variables)
11255 (gnus-summary-toggle-header arg)
11256 (setq gnus-show-all-headers
11257 (cond ((or (not (numberp arg))
11259 (not gnus-show-all-headers))
11263 (defun gnus-summary-toggle-header (&optional arg)
11264 "Show the headers if they are hidden, or hide them if they are shown.
11265 If ARG is a positive number, show the entire header.
11266 If ARG is a negative number, hide the unwanted header lines."
11268 (gnus-set-global-variables)
11270 (set-buffer gnus-article-buffer)
11271 (let* ((buffer-read-only nil)
11272 (inhibit-point-motion-hooks t)
11273 (hidden (text-property-any
11274 (goto-char (point-min)) (search-forward "\n\n")
11277 (goto-char (point-min))
11278 (when (search-forward "\n\n" nil t)
11279 (delete-region (point-min) (1- (point))))
11280 (goto-char (point-min))
11282 (set-buffer gnus-original-article-buffer)
11283 (goto-char (point-min))
11284 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11285 (insert-buffer-substring gnus-original-article-buffer 1 e)
11286 (let ((gnus-inhibit-hiding t))
11287 (run-hooks 'gnus-article-display-hook))
11288 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11289 (gnus-article-hide-headers)))))
11291 (defun gnus-summary-show-all-headers ()
11292 "Make all header lines visible."
11294 (gnus-set-global-variables)
11295 (gnus-article-show-all-headers))
11297 (defun gnus-summary-toggle-mime (&optional arg)
11298 "Toggle MIME processing.
11299 If ARG is a positive number, turn MIME processing on."
11301 (gnus-set-global-variables)
11302 (setq gnus-show-mime
11303 (if (null arg) (not gnus-show-mime)
11304 (> (prefix-numeric-value arg) 0)))
11305 (gnus-summary-select-article t 'force))
11307 (defun gnus-summary-caesar-message (&optional arg)
11308 "Caesar rotate the current article by 13.
11309 The numerical prefix specifies how manu places to rotate each letter
11312 (gnus-set-global-variables)
11313 (gnus-summary-select-article)
11314 (let ((mail-header-separator ""))
11315 (gnus-eval-in-buffer-window
11316 gnus-article-buffer
11319 (let ((start (window-start)))
11320 (news-caesar-buffer-body arg)
11321 (set-window-start (get-buffer-window (current-buffer)) start))))))
11323 (defun gnus-summary-stop-page-breaking ()
11324 "Stop page breaking in the current article."
11326 (gnus-set-global-variables)
11327 (gnus-summary-select-article)
11328 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11330 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11331 "Move the current article to a different newsgroup.
11332 If N is a positive number, move the N next articles.
11333 If N is a negative number, move the N previous articles.
11334 If N is nil and any articles have been marked with the process mark,
11335 move those articles instead.
11336 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11337 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11338 re-spool using this method.
11340 For this function to work, both the current newsgroup and the
11341 newsgroup that you want to move to have to support the `request-move'
11342 and `request-accept' functions."
11344 (unless action (setq action 'move))
11345 (gnus-set-global-variables)
11346 ;; Check whether the source group supports the required functions.
11347 (cond ((and (eq action 'move)
11348 (not (gnus-check-backend-function
11349 'request-move-article gnus-newsgroup-name)))
11350 (error "The current group does not support article moving"))
11351 ((and (eq action 'crosspost)
11352 (not (gnus-check-backend-function
11353 'request-replace-article gnus-newsgroup-name)))
11354 (error "The current group does not support article editing")))
11355 (let ((articles (gnus-summary-work-articles n))
11356 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11357 (names '((move "Move" "Moving")
11358 (copy "Copy" "Copying")
11359 (crosspost "Crosspost" "Crossposting")))
11360 (copy-buf (save-excursion
11361 (nnheader-set-temp-buffer " *copy article*")))
11362 art-group to-method new-xref article to-groups)
11363 (unless (assq action names)
11364 (error "Unknown action %s" action))
11365 ;; Read the newsgroup name.
11366 (when (and (not to-newsgroup)
11367 (not select-method))
11369 (gnus-read-move-group-name
11370 (cadr (assq action names))
11371 (symbol-value (intern (format "gnus-current-%s-group" action)))
11373 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11374 (setq to-method (or select-method
11375 (gnus-find-method-for-group to-newsgroup)))
11376 ;; Check the method we are to move this article to...
11377 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11378 (error "%s does not support article copying" (car to-method)))
11379 (or (gnus-check-server to-method)
11380 (error "Can't open server %s" (car to-method)))
11381 (gnus-message 6 "%s to %s: %s..."
11382 (caddr (assq action names))
11383 (or (car select-method) to-newsgroup) articles)
11385 (setq article (pop articles))
11389 ;; Move the article.
11391 (gnus-request-move-article
11392 article ; Article to move
11393 gnus-newsgroup-name ; From newsgrouo
11394 (nth 1 (gnus-find-method-for-group
11395 gnus-newsgroup-name)) ; Server
11396 (list 'gnus-request-accept-article
11397 to-newsgroup (list 'quote select-method)
11398 (not articles)) ; Accept form
11399 (not articles))) ; Only save nov last time
11400 ;; Copy the article.
11403 (set-buffer copy-buf)
11404 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11405 (gnus-request-accept-article
11406 to-newsgroup select-method (not articles))))
11407 ;; Crosspost the article.
11408 ((eq action 'crosspost)
11409 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11410 (setq new-xref (concat gnus-newsgroup-name ":" article))
11411 (if (and xref (not (string= xref "")))
11413 (when (string-match "^Xref: " xref)
11414 (setq xref (substring xref (match-end 0))))
11415 (setq new-xref (concat xref " " new-xref)))
11416 (setq new-xref (concat (system-name) " " new-xref)))
11418 (set-buffer copy-buf)
11419 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11420 (nnheader-replace-header "xref" new-xref)
11421 (gnus-request-accept-article
11422 to-newsgroup select-method (not articles)))))))
11423 (if (not art-group)
11424 (gnus-message 1 "Couldn't %s article %s"
11425 (cadr (assq action names)) article)
11428 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11430 (gnus-group-prefixed-name
11433 (gnus-find-method-for-group to-newsgroup)))
11434 gnus-newsrc-hashtb)))
11435 (info (nth 2 entry))
11436 (to-group (gnus-info-group info)))
11437 ;; Update the group that has been moved to.
11439 (memq action '(move copy)))
11440 (unless (member to-group to-groups)
11441 (push to-group to-groups))
11443 (unless (memq article gnus-newsgroup-unreads)
11444 (gnus-info-set-read
11445 info (gnus-add-to-range (gnus-info-read info)
11446 (list (cdr art-group)))))
11448 ;; Copy any marks over to the new group.
11449 (let ((marks gnus-article-mark-lists)
11450 (to-article (cdr art-group)))
11452 ;; See whether the article is to be put in the cache.
11453 (when gnus-use-cache
11454 (gnus-cache-possibly-enter-article
11455 to-group to-article
11456 (let ((header (copy-sequence
11457 (gnus-summary-article-header article))))
11458 (mail-header-set-number header to-article)
11460 (memq article gnus-newsgroup-marked)
11461 (memq article gnus-newsgroup-dormant)
11462 (memq article gnus-newsgroup-unreads)))
11465 (when (memq article (symbol-value
11466 (intern (format "gnus-newsgroup-%s"
11468 ;; If the other group is the same as this group,
11469 ;; then we have to add the mark to the list.
11470 (when (equal to-group gnus-newsgroup-name)
11471 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11474 (intern (format "gnus-newsgroup-%s"
11476 ;; Copy mark to other group.
11477 (gnus-add-marked-articles
11478 to-group (cdar marks) (list to-article) info))
11479 (setq marks (cdr marks)))))
11481 ;; Update the Xref header in this article to point to
11482 ;; the new crossposted article we have just created.
11483 (when (eq action 'crosspost)
11485 (set-buffer copy-buf)
11486 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11487 (nnheader-replace-header
11488 "xref" (concat new-xref " " (gnus-group-prefixed-name
11489 (car art-group) to-method)
11490 ":" (cdr art-group)))
11491 (gnus-request-replace-article
11492 article gnus-newsgroup-name (current-buffer)))))
11494 (gnus-summary-goto-subject article)
11495 (when (eq action 'move)
11496 (gnus-summary-mark-article article gnus-canceled-mark)))
11497 (gnus-summary-remove-process-mark article))
11498 ;; Re-activate all groups that have been moved to.
11500 (gnus-activate-group (pop to-groups)))
11502 (gnus-kill-buffer copy-buf)
11503 (gnus-summary-position-point)
11504 (gnus-set-mode-line 'summary)))
11506 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11507 "Move the current article to a different newsgroup.
11508 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11509 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11510 re-spool using this method."
11512 (gnus-summary-move-article n nil select-method 'copy))
11514 (defun gnus-summary-crosspost-article (&optional n)
11515 "Crosspost the current article to some other group."
11517 (gnus-summary-move-article n nil nil 'crosspost))
11519 (defvar gnus-summary-respool-default-method nil
11520 "Default method for respooling an article.
11521 If nil, use to the current newsgroup method.")
11523 (defun gnus-summary-respool-article (&optional n method)
11524 "Respool the current article.
11525 The article will be squeezed through the mail spooling process again,
11526 which means that it will be put in some mail newsgroup or other
11527 depending on `nnmail-split-methods'.
11528 If N is a positive number, respool the N next articles.
11529 If N is a negative number, respool the N previous articles.
11530 If N is nil and any articles have been marked with the process mark,
11531 respool those articles instead.
11533 Respooling can be done both from mail groups and \"real\" newsgroups.
11534 In the former case, the articles in question will be moved from the
11535 current group into whatever groups they are destined to. In the
11536 latter case, they will be copied into the relevant groups."
11538 (list current-prefix-arg
11539 (let* ((methods (gnus-methods-using 'respool))
11541 (symbol-name (or gnus-summary-respool-default-method
11542 (car (gnus-find-method-for-group
11543 gnus-newsgroup-name)))))
11545 (gnus-completing-read
11546 methname "What backend do you want to use when? "
11547 methods nil t nil 'gnus-method-history))
11550 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11551 (list (intern method) ""))
11555 (cdr (completing-read
11557 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11558 (gnus-set-global-variables)
11560 (error "No method given for respooling"))
11561 (if (assoc (symbol-name
11562 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11563 (gnus-methods-using 'respool))
11564 (gnus-summary-move-article n nil method)
11565 (gnus-summary-copy-article n nil method)))
11567 (defun gnus-summary-import-article (file)
11568 "Import a random file into a mail newsgroup."
11569 (interactive "fImport file: ")
11570 (gnus-set-global-variables)
11571 (let ((group gnus-newsgroup-name)
11572 (now (current-time))
11574 (or (gnus-check-backend-function 'request-accept-article group)
11575 (error "%s does not support article importing" group))
11576 (or (file-readable-p file)
11577 (not (file-regular-p file))
11578 (error "Can't read %s" file))
11580 (set-buffer (get-buffer-create " *import file*"))
11581 (buffer-disable-undo (current-buffer))
11583 (insert-file-contents file)
11584 (goto-char (point-min))
11585 (unless (nnheader-article-p)
11586 ;; This doesn't look like an article, so we fudge some headers.
11587 (setq atts (file-attributes file)
11588 lines (count-lines (point-min) (point-max)))
11589 (insert "From: " (read-string "From: ") "\n"
11590 "Subject: " (read-string "Subject: ") "\n"
11591 "Date: " (timezone-make-date-arpa-standard
11592 (current-time-string (nth 5 atts))
11593 (current-time-zone now)
11594 (current-time-zone now)) "\n"
11595 "Message-ID: " (gnus-inews-message-id) "\n"
11596 "Lines: " (int-to-string lines) "\n"
11597 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11598 (gnus-request-accept-article group nil t)
11599 (kill-buffer (current-buffer)))))
11601 (defun gnus-summary-expire-articles (&optional now)
11602 "Expire all articles that are marked as expirable in the current group."
11604 (gnus-set-global-variables)
11605 (when (gnus-check-backend-function
11606 'request-expire-articles gnus-newsgroup-name)
11607 ;; This backend supports expiry.
11608 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11609 (expirable (if total
11610 (gnus-list-of-read-articles gnus-newsgroup-name)
11611 (setq gnus-newsgroup-expirable
11612 (sort gnus-newsgroup-expirable '<))))
11613 (expiry-wait (if now 'immediate
11614 (gnus-group-get-parameter
11615 gnus-newsgroup-name 'expiry-wait)))
11618 ;; There are expirable articles in this group, so we run them
11619 ;; through the expiry process.
11620 (gnus-message 6 "Expiring articles...")
11621 ;; The list of articles that weren't expired is returned.
11623 (let ((nnmail-expiry-wait-function nil)
11624 (nnmail-expiry-wait expiry-wait))
11625 (setq es (gnus-request-expire-articles
11626 expirable gnus-newsgroup-name)))
11627 (setq es (gnus-request-expire-articles
11628 expirable gnus-newsgroup-name)))
11629 (or total (setq gnus-newsgroup-expirable es))
11630 ;; We go through the old list of expirable, and mark all
11631 ;; really expired articles as nonexistent.
11632 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11633 (let ((gnus-use-cache nil))
11635 (unless (memq (car expirable) es)
11636 (when (gnus-data-find (car expirable))
11637 (gnus-summary-mark-article
11638 (car expirable) gnus-canceled-mark)))
11639 (setq expirable (cdr expirable)))))
11640 (gnus-message 6 "Expiring articles...done")))))
11642 (defun gnus-summary-expire-articles-now ()
11643 "Expunge all expirable articles in the current group.
11644 This means that *all* articles that are marked as expirable will be
11645 deleted forever, right now."
11647 (gnus-set-global-variables)
11648 (or gnus-expert-user
11650 "Are you really, really, really sure you want to delete all these messages? ")
11652 (gnus-summary-expire-articles t))
11654 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11655 (defun gnus-summary-delete-article (&optional n)
11656 "Delete the N next (mail) articles.
11657 This command actually deletes articles. This is not a marking
11658 command. The article will disappear forever from your life, never to
11660 If N is negative, delete backwards.
11661 If N is nil and articles have been marked with the process mark,
11662 delete these instead."
11664 (gnus-set-global-variables)
11665 (or (gnus-check-backend-function 'request-expire-articles
11666 gnus-newsgroup-name)
11667 (error "The current newsgroup does not support article deletion."))
11668 ;; Compute the list of articles to delete.
11669 (let ((articles (gnus-summary-work-articles n))
11671 (if (and gnus-novice-user
11672 (not (gnus-y-or-n-p
11673 (format "Do you really want to delete %s forever? "
11674 (if (> (length articles) 1)
11675 (format "these %s articles" (length articles))
11676 "this article")))))
11678 ;; Delete the articles.
11679 (setq not-deleted (gnus-request-expire-articles
11680 articles gnus-newsgroup-name 'force))
11682 (gnus-summary-remove-process-mark (car articles))
11683 ;; The backend might not have been able to delete the article
11685 (or (memq (car articles) not-deleted)
11686 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11687 (setq articles (cdr articles))))
11688 (gnus-summary-position-point)
11689 (gnus-set-mode-line 'summary)
11692 (defun gnus-summary-edit-article (&optional force)
11693 "Enter into a buffer and edit the current article.
11694 This will have permanent effect only in mail groups.
11695 If FORCE is non-nil, allow editing of articles even in read-only
11699 (set-buffer gnus-summary-buffer)
11700 (gnus-set-global-variables)
11701 (when (and (not force)
11702 (gnus-group-read-only-p))
11703 (error "The current newsgroup does not support article editing."))
11704 (gnus-summary-select-article t nil t)
11705 (gnus-configure-windows 'article)
11706 (select-window (get-buffer-window gnus-article-buffer))
11707 (gnus-message 6 "C-c C-c to end edits")
11708 (setq buffer-read-only nil)
11710 (use-local-map (copy-keymap (current-local-map)))
11711 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11712 (buffer-enable-undo)
11714 (goto-char (point-min))
11715 (search-forward "\n\n" nil t)))
11717 (defun gnus-summary-edit-article-done ()
11718 "Make edits to the current article permanent."
11720 (if (gnus-group-read-only-p)
11722 (gnus-summary-edit-article-postpone)
11724 1 "The current newsgroup does not support article editing."))
11725 (let ((buf (format "%s" (buffer-string))))
11728 (if (not (gnus-request-replace-article
11729 (cdr gnus-article-current) (car gnus-article-current)
11731 (error "Couldn't replace article.")
11732 (gnus-article-mode)
11733 (use-local-map gnus-article-mode-map)
11734 (setq buffer-read-only t)
11735 (buffer-disable-undo (current-buffer))
11736 (gnus-configure-windows 'summary)
11737 (gnus-summary-update-article (cdr gnus-article-current))
11738 (when gnus-use-cache
11739 (gnus-cache-update-article
11740 (cdr gnus-article-current) (car gnus-article-current)))
11741 (when gnus-keep-backlog
11742 (gnus-backlog-remove-article
11743 (car gnus-article-current) (cdr gnus-article-current))))
11745 (when (get-buffer gnus-original-article-buffer)
11746 (set-buffer gnus-original-article-buffer)
11747 (setq gnus-original-article nil)))
11748 (setq gnus-article-current nil
11749 gnus-current-article nil)
11750 (run-hooks 'gnus-article-display-hook)
11751 (and (gnus-visual-p 'summary-highlight 'highlight)
11752 (run-hooks 'gnus-visual-mark-article-hook)))))
11754 (defun gnus-summary-edit-article-postpone ()
11755 "Postpone changes to the current article."
11757 (gnus-article-mode)
11758 (use-local-map gnus-article-mode-map)
11759 (setq buffer-read-only t)
11760 (buffer-disable-undo (current-buffer))
11761 (gnus-configure-windows 'summary)
11762 (and (gnus-visual-p 'summary-highlight 'highlight)
11763 (run-hooks 'gnus-visual-mark-article-hook)))
11765 (defun gnus-summary-respool-query ()
11766 "Query where the respool algorithm would put this article."
11768 (gnus-set-global-variables)
11769 (gnus-summary-select-article)
11771 (set-buffer gnus-article-buffer)
11773 (goto-char (point-min))
11774 (search-forward "\n\n")
11775 (narrow-to-region (point-min) (point))
11776 (pp-eval-expression
11777 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11779 ;; Summary marking commands.
11781 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11782 "Mark articles which has the same subject as read, and then select the next.
11783 If UNMARK is positive, remove any kind of mark.
11784 If UNMARK is negative, tick articles."
11786 (gnus-set-global-variables)
11788 (setq unmark (prefix-numeric-value unmark)))
11790 (gnus-summary-mark-same-subject
11791 (gnus-summary-article-subject) unmark)))
11792 ;; Select next unread article. If auto-select-same mode, should
11793 ;; select the first unread article.
11794 (gnus-summary-next-article t (and gnus-auto-select-same
11795 (gnus-summary-article-subject)))
11796 (gnus-message 7 "%d article%s marked as %s"
11797 count (if (= count 1) " is" "s are")
11798 (if unmark "unread" "read"))))
11800 (defun gnus-summary-kill-same-subject (&optional unmark)
11801 "Mark articles which has the same subject as read.
11802 If UNMARK is positive, remove any kind of mark.
11803 If UNMARK is negative, tick articles."
11805 (gnus-set-global-variables)
11807 (setq unmark (prefix-numeric-value unmark)))
11809 (gnus-summary-mark-same-subject
11810 (gnus-summary-article-subject) unmark)))
11811 ;; If marked as read, go to next unread subject.
11813 ;; Go to next unread subject.
11814 (gnus-summary-next-subject 1 t))
11815 (gnus-message 7 "%d articles are marked as %s"
11816 count (if unmark "unread" "read"))))
11818 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11819 "Mark articles with same SUBJECT as read, and return marked number.
11820 If optional argument UNMARK is positive, remove any kinds of marks.
11821 If optional argument UNMARK is negative, mark articles as unread instead."
11825 ((null unmark) ; Mark as read.
11828 (gnus-summary-mark-article-as-read gnus-killed-mark)
11829 (gnus-summary-show-thread) t)
11830 (gnus-summary-find-subject subject))
11831 (setq count (1+ count))))
11832 ((> unmark 0) ; Tick.
11835 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11836 (gnus-summary-show-thread) t)
11837 (gnus-summary-find-subject subject))
11838 (setq count (1+ count))))
11839 (t ; Mark as unread.
11842 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11843 (gnus-summary-show-thread) t)
11844 (gnus-summary-find-subject subject))
11845 (setq count (1+ count)))))
11846 (gnus-set-mode-line 'summary)
11847 ;; Return the number of marked articles.
11850 (defun gnus-summary-mark-as-processable (n &optional unmark)
11851 "Set the process mark on the next N articles.
11852 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11853 the process mark instead. The difference between N and the actual
11854 number of articles marked is returned."
11856 (gnus-set-global-variables)
11857 (let ((backward (< n 0))
11862 (gnus-summary-remove-process-mark
11863 (gnus-summary-article-number))
11864 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11865 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11867 (if (/= 0 n) (gnus-message 7 "No more articles"))
11868 (gnus-summary-recenter)
11869 (gnus-summary-position-point)
11872 (defun gnus-summary-unmark-as-processable (n)
11873 "Remove the process mark from the next N articles.
11874 If N is negative, mark backward instead. The difference between N and
11875 the actual number of articles marked is returned."
11877 (gnus-set-global-variables)
11878 (gnus-summary-mark-as-processable n t))
11880 (defun gnus-summary-unmark-all-processable ()
11881 "Remove the process mark from all articles."
11883 (gnus-set-global-variables)
11885 (while gnus-newsgroup-processable
11886 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11887 (gnus-summary-position-point))
11889 (defun gnus-summary-mark-as-expirable (n)
11890 "Mark N articles forward as expirable.
11891 If N is negative, mark backward instead. The difference between N and
11892 the actual number of articles marked is returned."
11894 (gnus-set-global-variables)
11895 (gnus-summary-mark-forward n gnus-expirable-mark))
11897 (defun gnus-summary-mark-article-as-replied (article)
11898 "Mark ARTICLE replied and update the summary line."
11899 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11900 (let ((buffer-read-only nil))
11901 (when (gnus-summary-goto-subject article)
11902 (gnus-summary-update-secondary-mark article))))
11904 (defun gnus-summary-set-bookmark (article)
11905 "Set a bookmark in current article."
11906 (interactive (list (gnus-summary-article-number)))
11907 (gnus-set-global-variables)
11908 (if (or (not (get-buffer gnus-article-buffer))
11909 (not gnus-current-article)
11910 (not gnus-article-current)
11911 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11912 (error "No current article selected"))
11913 ;; Remove old bookmark, if one exists.
11914 (let ((old (assq article gnus-newsgroup-bookmarks)))
11915 (if old (setq gnus-newsgroup-bookmarks
11916 (delq old gnus-newsgroup-bookmarks))))
11917 ;; Set the new bookmark, which is on the form
11918 ;; (article-number . line-number-in-body).
11919 (setq gnus-newsgroup-bookmarks
11923 (set-buffer gnus-article-buffer)
11927 (goto-char (point-min))
11928 (search-forward "\n\n" nil t)
11931 gnus-newsgroup-bookmarks))
11932 (gnus-message 6 "A bookmark has been added to the current article."))
11934 (defun gnus-summary-remove-bookmark (article)
11935 "Remove the bookmark from the current article."
11936 (interactive (list (gnus-summary-article-number)))
11937 (gnus-set-global-variables)
11938 ;; Remove old bookmark, if one exists.
11939 (let ((old (assq article gnus-newsgroup-bookmarks)))
11942 (setq gnus-newsgroup-bookmarks
11943 (delq old gnus-newsgroup-bookmarks))
11944 (gnus-message 6 "Removed bookmark."))
11945 (gnus-message 6 "No bookmark in current article."))))
11947 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11948 (defun gnus-summary-mark-as-dormant (n)
11949 "Mark N articles forward as dormant.
11950 If N is negative, mark backward instead. The difference between N and
11951 the actual number of articles marked is returned."
11953 (gnus-set-global-variables)
11954 (gnus-summary-mark-forward n gnus-dormant-mark))
11956 (defun gnus-summary-set-process-mark (article)
11957 "Set the process mark on ARTICLE and update the summary line."
11958 (setq gnus-newsgroup-processable
11960 (delq article gnus-newsgroup-processable)))
11961 (when (gnus-summary-goto-subject article)
11962 (gnus-summary-show-thread)
11963 (gnus-summary-update-secondary-mark article)))
11965 (defun gnus-summary-remove-process-mark (article)
11966 "Remove the process mark from ARTICLE and update the summary line."
11967 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11968 (when (gnus-summary-goto-subject article)
11969 (gnus-summary-show-thread)
11970 (gnus-summary-update-secondary-mark article)))
11972 (defun gnus-summary-set-saved-mark (article)
11973 "Set the process mark on ARTICLE and update the summary line."
11974 (push article gnus-newsgroup-saved)
11975 (when (gnus-summary-goto-subject article)
11976 (gnus-summary-update-secondary-mark article)))
11978 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11979 "Mark N articles as read forwards.
11980 If N is negative, mark backwards instead.
11981 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11983 The difference between N and the actual number of articles marked is
11986 (gnus-set-global-variables)
11987 (let ((backward (< n 0))
11988 (gnus-summary-goto-unread
11989 (and gnus-summary-goto-unread
11990 (not (eq gnus-summary-goto-unread 'never))
11991 (not (memq mark (list gnus-unread-mark
11992 gnus-ticked-mark gnus-dormant-mark)))))
11994 (mark (or mark gnus-del-mark)))
11995 (while (and (> n 0)
11996 (gnus-summary-mark-article nil mark no-expire)
11997 (zerop (gnus-summary-next-subject
11999 (and gnus-summary-goto-unread
12000 (not (eq gnus-summary-goto-unread 'never)))
12003 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12004 (gnus-summary-recenter)
12005 (gnus-summary-position-point)
12006 (gnus-set-mode-line 'summary)
12009 (defun gnus-summary-mark-article-as-read (mark)
12010 "Mark the current article quickly as read with MARK."
12011 (let ((article (gnus-summary-article-number)))
12012 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12013 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12014 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12015 (setq gnus-newsgroup-reads
12016 (cons (cons article mark) gnus-newsgroup-reads))
12017 ;; Possibly remove from cache, if that is used.
12018 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12019 ;; Allow the backend to change the mark.
12020 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12021 ;; Check for auto-expiry.
12022 (when (and gnus-newsgroup-auto-expire
12023 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12024 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12025 (= mark gnus-ancient-mark)
12026 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12027 (setq mark gnus-expirable-mark)
12028 (push article gnus-newsgroup-expirable))
12029 ;; Set the mark in the buffer.
12030 (gnus-summary-update-mark mark 'unread)
12033 (defun gnus-summary-mark-article-as-unread (mark)
12034 "Mark the current article quickly as unread with MARK."
12035 (let ((article (gnus-summary-article-number)))
12036 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12037 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12038 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12039 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12040 (cond ((= mark gnus-ticked-mark)
12041 (push article gnus-newsgroup-marked))
12042 ((= mark gnus-dormant-mark)
12043 (push article gnus-newsgroup-dormant))
12045 (push article gnus-newsgroup-unreads)))
12046 (setq gnus-newsgroup-reads
12047 (delq (assq article gnus-newsgroup-reads)
12048 gnus-newsgroup-reads))
12050 ;; See whether the article is to be put in the cache.
12051 (and gnus-use-cache
12052 (vectorp (gnus-summary-article-header article))
12054 (gnus-cache-possibly-enter-article
12055 gnus-newsgroup-name article
12056 (gnus-summary-article-header article)
12057 (= mark gnus-ticked-mark)
12058 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12061 (gnus-summary-update-mark mark 'unread)
12064 (defun gnus-summary-mark-article (&optional article mark no-expire)
12065 "Mark ARTICLE with MARK. MARK can be any character.
12066 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12067 `??' (dormant) and `?E' (expirable).
12068 If MARK is nil, then the default character `?D' is used.
12069 If ARTICLE is nil, then the article on the current line will be
12071 ;; The mark might be a string.
12072 (and (stringp mark)
12073 (setq mark (aref mark 0)))
12074 ;; If no mark is given, then we check auto-expiring.
12075 (and (not no-expire)
12076 gnus-newsgroup-auto-expire
12078 (and (numberp mark)
12079 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12080 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12081 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12082 (setq mark gnus-expirable-mark))
12083 (let* ((mark (or mark gnus-del-mark))
12084 (article (or article (gnus-summary-article-number))))
12085 (or article (error "No article on current line"))
12086 (if (or (= mark gnus-unread-mark)
12087 (= mark gnus-ticked-mark)
12088 (= mark gnus-dormant-mark))
12089 (gnus-mark-article-as-unread article mark)
12090 (gnus-mark-article-as-read article mark))
12092 ;; See whether the article is to be put in the cache.
12093 (and gnus-use-cache
12094 (not (= mark gnus-canceled-mark))
12095 (vectorp (gnus-summary-article-header article))
12097 (gnus-cache-possibly-enter-article
12098 gnus-newsgroup-name article
12099 (gnus-summary-article-header article)
12100 (= mark gnus-ticked-mark)
12101 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12103 (if (gnus-summary-goto-subject article nil t)
12104 (let ((buffer-read-only nil))
12105 (gnus-summary-show-thread)
12107 (gnus-summary-update-mark mark 'unread)
12110 (defun gnus-summary-update-secondary-mark (article)
12111 "Update the secondary (read, process, cache) mark."
12112 (gnus-summary-update-mark
12113 (cond ((memq article gnus-newsgroup-processable)
12115 ((memq article gnus-newsgroup-cached)
12117 ((memq article gnus-newsgroup-replied)
12119 ((memq article gnus-newsgroup-saved)
12121 (t gnus-unread-mark))
12123 (when (gnus-visual-p 'summary-highlight 'highlight)
12124 (run-hooks 'gnus-summary-update-hook))
12127 (defun gnus-summary-update-mark (mark type)
12128 (beginning-of-line)
12129 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12130 (buffer-read-only nil))
12132 (<= (+ forward (point)) (point-max)))
12133 ;; Go to the right position on the line.
12134 (goto-char (+ forward (point)))
12135 ;; Replace the old mark with the new mark.
12136 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12137 ;; Optionally update the marks by some user rule.
12138 (when (eq type 'unread)
12139 (gnus-data-set-mark
12140 (gnus-data-find (gnus-summary-article-number)) mark)
12141 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12143 (defun gnus-mark-article-as-read (article &optional mark)
12144 "Enter ARTICLE in the pertinent lists and remove it from others."
12145 ;; Make the article expirable.
12146 (let ((mark (or mark gnus-del-mark)))
12147 (if (= mark gnus-expirable-mark)
12148 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12149 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12150 ;; Remove from unread and marked lists.
12151 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12152 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12153 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12154 (push (cons article mark) gnus-newsgroup-reads)
12155 ;; Possibly remove from cache, if that is used.
12156 (when gnus-use-cache
12157 (gnus-cache-enter-remove-article article))))
12159 (defun gnus-mark-article-as-unread (article &optional mark)
12160 "Enter ARTICLE in the pertinent lists and remove it from others."
12161 (let ((mark (or mark gnus-ticked-mark)))
12162 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12163 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12164 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12165 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12166 (cond ((= mark gnus-ticked-mark)
12167 (push article gnus-newsgroup-marked))
12168 ((= mark gnus-dormant-mark)
12169 (push article gnus-newsgroup-dormant))
12171 (push article gnus-newsgroup-unreads)))
12172 (setq gnus-newsgroup-reads
12173 (delq (assq article gnus-newsgroup-reads)
12174 gnus-newsgroup-reads))))
12176 (defalias 'gnus-summary-mark-as-unread-forward
12177 'gnus-summary-tick-article-forward)
12178 (make-obsolete 'gnus-summary-mark-as-unread-forward
12179 'gnus-summary-tick-article-forward)
12180 (defun gnus-summary-tick-article-forward (n)
12181 "Tick N articles forwards.
12182 If N is negative, tick backwards instead.
12183 The difference between N and the number of articles ticked is returned."
12185 (gnus-summary-mark-forward n gnus-ticked-mark))
12187 (defalias 'gnus-summary-mark-as-unread-backward
12188 'gnus-summary-tick-article-backward)
12189 (make-obsolete 'gnus-summary-mark-as-unread-backward
12190 'gnus-summary-tick-article-backward)
12191 (defun gnus-summary-tick-article-backward (n)
12192 "Tick N articles backwards.
12193 The difference between N and the number of articles ticked is returned."
12195 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12197 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12198 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12199 (defun gnus-summary-tick-article (&optional article clear-mark)
12200 "Mark current article as unread.
12201 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12202 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12204 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12205 gnus-ticked-mark)))
12207 (defun gnus-summary-mark-as-read-forward (n)
12208 "Mark N articles as read forwards.
12209 If N is negative, mark backwards instead.
12210 The difference between N and the actual number of articles marked is
12213 (gnus-summary-mark-forward n gnus-del-mark t))
12215 (defun gnus-summary-mark-as-read-backward (n)
12216 "Mark the N articles as read backwards.
12217 The difference between N and the actual number of articles marked is
12220 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12222 (defun gnus-summary-mark-as-read (&optional article mark)
12223 "Mark current article as read.
12224 ARTICLE specifies the article to be marked as read.
12225 MARK specifies a string to be inserted at the beginning of the line."
12226 (gnus-summary-mark-article article mark))
12228 (defun gnus-summary-clear-mark-forward (n)
12229 "Clear marks from N articles forward.
12230 If N is negative, clear backward instead.
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-clear-mark-backward (n)
12236 "Clear marks from N articles backward.
12237 The difference between N and the number of marks cleared is returned."
12239 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12241 (defun gnus-summary-mark-unread-as-read ()
12242 "Intended to be used by `gnus-summary-mark-article-hook'."
12243 (when (memq gnus-current-article gnus-newsgroup-unreads)
12244 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12246 (defun gnus-summary-mark-read-and-unread-as-read ()
12247 "Intended to be used by `gnus-summary-mark-article-hook'."
12248 (let ((mark (gnus-summary-article-mark)))
12249 (when (or (gnus-unread-mark-p mark)
12250 (gnus-read-mark-p mark))
12251 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12253 (defun gnus-summary-mark-region-as-read (point mark all)
12254 "Mark all unread articles between point and mark as read.
12255 If given a prefix, mark all articles between point and mark as read,
12256 even ticked and dormant ones."
12257 (interactive "r\nP")
12261 (beginning-of-line)
12266 (memq (setq article (gnus-summary-article-number))
12267 gnus-newsgroup-unreads))
12268 (gnus-summary-mark-article article gnus-del-mark))
12270 (gnus-summary-find-next))))))
12272 (defun gnus-summary-mark-below (score mark)
12273 "Mark articles with score less than SCORE with MARK."
12274 (interactive "P\ncMark: ")
12275 (gnus-set-global-variables)
12276 (setq score (if score
12277 (prefix-numeric-value score)
12278 (or gnus-summary-default-score 0)))
12280 (set-buffer gnus-summary-buffer)
12281 (goto-char (point-min))
12284 (and (< (gnus-summary-article-score) score)
12285 (gnus-summary-mark-article nil mark))
12286 (gnus-summary-find-next)))))
12288 (defun gnus-summary-kill-below (&optional score)
12289 "Mark articles with score below SCORE as read."
12291 (gnus-set-global-variables)
12292 (gnus-summary-mark-below score gnus-killed-mark))
12294 (defun gnus-summary-clear-above (&optional score)
12295 "Clear all marks from articles with score above SCORE."
12297 (gnus-set-global-variables)
12298 (gnus-summary-mark-above score gnus-unread-mark))
12300 (defun gnus-summary-tick-above (&optional score)
12301 "Tick all articles with score above SCORE."
12303 (gnus-set-global-variables)
12304 (gnus-summary-mark-above score gnus-ticked-mark))
12306 (defun gnus-summary-mark-above (score mark)
12307 "Mark articles with score over SCORE with MARK."
12308 (interactive "P\ncMark: ")
12309 (gnus-set-global-variables)
12310 (setq score (if score
12311 (prefix-numeric-value score)
12312 (or gnus-summary-default-score 0)))
12314 (set-buffer gnus-summary-buffer)
12315 (goto-char (point-min))
12317 (if (> (gnus-summary-article-score) score)
12318 (gnus-summary-mark-article nil mark))
12320 (gnus-summary-find-next)))))
12322 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12323 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12324 (defun gnus-summary-limit-include-expunged ()
12325 "Display all the hidden articles that were expunged for low scores."
12327 (gnus-set-global-variables)
12328 (let ((buffer-read-only nil))
12329 (let ((scored gnus-newsgroup-scored)
12332 (or (gnus-summary-goto-subject (caar scored))
12333 (and (setq h (gnus-summary-article-header (caar scored)))
12334 (< (cdar scored) gnus-summary-expunge-below)
12335 (setq headers (cons h headers))))
12336 (setq scored (cdr scored)))
12337 (or headers (error "No expunged articles hidden."))
12338 (goto-char (point-min))
12339 (gnus-summary-prepare-unthreaded (nreverse headers)))
12340 (goto-char (point-min))
12341 (gnus-summary-position-point)))
12343 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12344 "Mark all articles not marked as unread in this newsgroup as read.
12345 If prefix argument ALL is non-nil, all articles are marked as read.
12346 If QUIETLY is non-nil, no questions will be asked.
12347 If TO-HERE is non-nil, it should be a point in the buffer. All
12348 articles before this point will be marked as read.
12349 The number of articles marked as read is returned."
12351 (gnus-set-global-variables)
12354 (not gnus-interactive-catchup) ;Without confirmation?
12358 "Mark absolutely all articles as read? "
12359 "Mark all unread articles as read? ")))
12361 (not gnus-newsgroup-adaptive)
12362 (not gnus-newsgroup-auto-expire))
12365 (setq gnus-newsgroup-marked nil
12366 gnus-newsgroup-dormant nil))
12367 (setq gnus-newsgroup-unreads nil))
12368 ;; We actually mark all articles as canceled, which we
12369 ;; have to do when using auto-expiry or adaptive scoring.
12370 (gnus-summary-show-all-threads)
12371 (if (gnus-summary-first-subject (not all))
12373 (if to-here (< (point) to-here) t)
12374 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12375 (gnus-summary-find-next (not all)))))
12377 (setq gnus-newsgroup-unreads nil))
12378 (gnus-set-mode-line 'summary)))
12379 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12380 (if (and (not to-here) (eq 'nnvirtual (car method)))
12381 (nnvirtual-catchup-group
12382 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12383 (gnus-summary-position-point)))
12385 (defun gnus-summary-catchup-to-here (&optional all)
12386 "Mark all unticked articles before the current one as read.
12387 If ALL is non-nil, also mark ticked and dormant articles as read."
12389 (gnus-set-global-variables)
12391 (let ((beg (point)))
12392 ;; We check that there are unread articles.
12393 (when (or all (gnus-summary-find-prev))
12394 (gnus-summary-catchup all t beg))))
12395 (gnus-summary-position-point))
12397 (defun gnus-summary-catchup-all (&optional quietly)
12398 "Mark all articles in this newsgroup as read."
12400 (gnus-set-global-variables)
12401 (gnus-summary-catchup t quietly))
12403 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12404 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12405 If prefix argument ALL is non-nil, all articles are marked as read."
12407 (gnus-set-global-variables)
12408 (gnus-summary-catchup all quietly nil 'fast)
12409 ;; Select next newsgroup or exit.
12410 (if (eq gnus-auto-select-next 'quietly)
12411 (gnus-summary-next-group nil)
12412 (gnus-summary-exit)))
12414 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12415 "Mark all articles in this newsgroup as read, and then exit."
12417 (gnus-set-global-variables)
12418 (gnus-summary-catchup-and-exit t quietly))
12420 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12421 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12422 "Mark all articles in this group as read and select the next group.
12423 If given a prefix, mark all articles, unread as well as ticked, as
12426 (gnus-set-global-variables)
12428 (gnus-summary-catchup all))
12429 (gnus-summary-next-article t nil nil t))
12431 ;; Thread-based commands.
12433 (defun gnus-summary-articles-in-thread (&optional article)
12434 "Return a list of all articles in the current thread.
12435 If ARTICLE is non-nil, return all articles in the thread that starts
12436 with that article."
12437 (let* ((article (or article (gnus-summary-article-number)))
12438 (data (gnus-data-find-list article))
12439 (top-level (gnus-data-level (car data)))
12441 (cond ((null gnus-thread-operation-ignore-subject)
12442 (gnus-simplify-subject-re
12443 (mail-header-subject (gnus-data-header (car data)))))
12444 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12445 (gnus-simplify-subject-fuzzy
12446 (mail-header-subject (gnus-data-header (car data)))))
12448 (end-point (save-excursion
12449 (if (gnus-summary-go-to-next-thread)
12450 (point) (point-max))))
12453 (< (gnus-data-pos (car data)) end-point))
12454 (when (or (not top-subject)
12455 (string= top-subject
12456 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12457 (gnus-simplify-subject-fuzzy
12458 (mail-header-subject
12459 (gnus-data-header (car data))))
12460 (gnus-simplify-subject-re
12461 (mail-header-subject
12462 (gnus-data-header (car data)))))))
12463 (push (gnus-data-number (car data)) articles))
12464 (unless (and (setq data (cdr data))
12465 (> (gnus-data-level (car data)) top-level))
12467 ;; Return the list of articles.
12468 (nreverse articles)))
12470 (defun gnus-summary-rethread-current ()
12471 "Rethread the thread the current article is part of."
12473 (gnus-set-global-variables)
12474 (let* ((gnus-show-threads t)
12475 (article (gnus-summary-article-number))
12476 (id (mail-header-id (gnus-summary-article-header)))
12477 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12479 (error "No article on the current line"))
12480 (gnus-rebuild-thread id)
12481 (gnus-summary-goto-subject article)))
12483 (defun gnus-summary-reparent-thread ()
12484 "Make current article child of the marked (or previous) article.
12486 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12487 is non-nil or the Subject: of both articles are the same."
12489 (or (not (gnus-group-read-only-p))
12490 (error "The current newsgroup does not support article editing."))
12491 (or (<= (length gnus-newsgroup-processable) 1)
12492 (error "No more than one article may be marked."))
12493 (save-window-excursion
12494 (let ((gnus-article-buffer " *reparent*")
12495 (current-article (gnus-summary-article-number))
12496 ; first grab the marked article, otherwise one line up.
12497 (parent-article (if (not (null gnus-newsgroup-processable))
12498 (car gnus-newsgroup-processable)
12500 (if (eq (forward-line -1) 0)
12501 (gnus-summary-article-number)
12502 (error "Beginning of summary buffer."))))))
12503 (or (not (eq current-article parent-article))
12504 (error "An article may not be self-referential."))
12505 (let ((message-id (mail-header-id
12506 (gnus-summary-article-header parent-article))))
12507 (or (and message-id (not (equal message-id "")))
12508 (error "No message-id in desired parent."))
12509 (gnus-summary-select-article t t nil current-article)
12510 (set-buffer gnus-article-buffer)
12511 (setq buffer-read-only nil)
12512 (let ((buf (format "%s" (buffer-string))))
12515 (goto-char (point-min))
12516 (if (search-forward-regexp "^References: " nil t)
12517 (insert message-id " " )
12518 (insert "References: " message-id "\n"))
12519 (or (gnus-request-replace-article current-article
12520 (car gnus-article-current)
12521 gnus-article-buffer)
12522 (error "Couldn't replace article."))
12523 (set-buffer gnus-summary-buffer)
12524 (gnus-summary-unmark-all-processable)
12525 (gnus-summary-rethread-current)
12526 (gnus-message 3 "Article %d is now the child of article %d."
12527 current-article parent-article)))))
12529 (defun gnus-summary-toggle-threads (&optional arg)
12530 "Toggle showing conversation threads.
12531 If ARG is positive number, turn showing conversation threads on."
12533 (gnus-set-global-variables)
12534 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12535 (setq gnus-show-threads
12536 (if (null arg) (not gnus-show-threads)
12537 (> (prefix-numeric-value arg) 0)))
12538 (gnus-summary-prepare)
12539 (gnus-summary-goto-subject current)
12540 (gnus-summary-position-point)))
12542 (defun gnus-summary-show-all-threads ()
12543 "Show all threads."
12545 (gnus-set-global-variables)
12547 (let ((buffer-read-only nil))
12548 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12549 (gnus-summary-position-point))
12551 (defun gnus-summary-show-thread ()
12552 "Show thread subtrees.
12553 Returns nil if no thread was there to be shown."
12555 (gnus-set-global-variables)
12556 (let ((buffer-read-only nil)
12558 ;; first goto end then to beg, to have point at beg after let
12559 (end (progn (end-of-line) (point)))
12560 (beg (progn (beginning-of-line) (point))))
12562 ;; Any hidden lines here?
12563 (search-forward "\r" end t)
12564 (subst-char-in-region beg end ?\^M ?\n t)
12566 (gnus-summary-position-point))))
12568 (defun gnus-summary-hide-all-threads ()
12569 "Hide all thread subtrees."
12571 (gnus-set-global-variables)
12573 (goto-char (point-min))
12574 (gnus-summary-hide-thread)
12575 (while (zerop (gnus-summary-next-thread 1 t))
12576 (gnus-summary-hide-thread)))
12577 (gnus-summary-position-point))
12579 (defun gnus-summary-hide-thread ()
12580 "Hide thread subtrees.
12581 Returns nil if no threads were there to be hidden."
12583 (gnus-set-global-variables)
12584 (let ((buffer-read-only nil)
12586 (article (gnus-summary-article-number)))
12588 ;; Go forward until either the buffer ends or the subthread
12590 (when (and (not (eobp))
12591 (or (zerop (gnus-summary-next-thread 1 t))
12592 (goto-char (point-max))))
12594 (if (and (> (point) start)
12595 (search-backward "\n" start t))
12597 (subst-char-in-region start (point) ?\n ?\^M)
12598 (gnus-summary-goto-subject article))
12601 ;;(gnus-summary-position-point)
12604 (defun gnus-summary-go-to-next-thread (&optional previous)
12605 "Go to the same level (or less) next thread.
12606 If PREVIOUS is non-nil, go to previous thread instead.
12607 Return the article number moved to, or nil if moving was impossible."
12608 (let ((level (gnus-summary-thread-level))
12609 (way (if previous -1 1))
12612 (while (and (not (eobp))
12613 (< level (gnus-summary-thread-level)))
12614 (forward-line way))
12621 (gnus-summary-article-number)
12622 (goto-char beg)))))
12624 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12625 "Go to the same level (or less) next thread.
12626 If PREVIOUS is non-nil, go to previous thread instead.
12627 Return the article number moved to, or nil if moving was impossible."
12628 (if (and (eq gnus-summary-make-false-root 'dummy)
12629 (gnus-summary-article-intangible-p))
12630 (let ((beg (point)))
12631 (while (and (zerop (forward-line 1))
12632 (not (gnus-summary-article-intangible-p))
12633 (not (zerop (save-excursion
12634 (gnus-summary-thread-level))))))
12640 (let* ((level (gnus-summary-thread-level))
12641 (article (gnus-summary-article-number))
12642 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12645 (if (<= (gnus-data-level (car data)) level)
12646 (setq oart (gnus-data-number (car data))
12648 (setq data (cdr data))))
12650 (gnus-summary-goto-subject oart)))))
12652 (defun gnus-summary-next-thread (n &optional silent)
12653 "Go to the same level next N'th thread.
12654 If N is negative, search backward instead.
12655 Returns the difference between N and the number of skips actually
12658 If SILENT, don't output messages."
12660 (gnus-set-global-variables)
12661 (let ((backward (< n 0))
12664 (while (and (> n 0)
12665 (gnus-summary-go-to-next-thread backward))
12668 (gnus-summary-position-point))
12669 (when (and (not silent) (/= 0 n))
12670 (gnus-message 7 "No more threads"))
12673 (defun gnus-summary-prev-thread (n)
12674 "Go to the same level previous N'th thread.
12675 Returns the difference between N and the number of skips actually
12678 (gnus-set-global-variables)
12679 (gnus-summary-next-thread (- n)))
12681 (defun gnus-summary-go-down-thread ()
12682 "Go down one level in the current thread."
12683 (let ((children (gnus-summary-article-children)))
12685 (gnus-summary-goto-subject (car children)))))
12687 (defun gnus-summary-go-up-thread ()
12688 "Go up one level in the current thread."
12689 (let ((parent (gnus-summary-article-parent)))
12691 (gnus-summary-goto-subject parent))))
12693 (defun gnus-summary-down-thread (n)
12694 "Go down thread N steps.
12695 If N is negative, go up instead.
12696 Returns the difference between N and how many steps down that were
12699 (gnus-set-global-variables)
12702 (while (and (> n 0)
12703 (if up (gnus-summary-go-up-thread)
12704 (gnus-summary-go-down-thread)))
12706 (gnus-summary-position-point)
12707 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12710 (defun gnus-summary-up-thread (n)
12711 "Go up thread N steps.
12712 If N is negative, go up instead.
12713 Returns the difference between N and how many steps down that were
12716 (gnus-set-global-variables)
12717 (gnus-summary-down-thread (- n)))
12719 (defun gnus-summary-top-thread ()
12720 "Go to the top of the thread."
12722 (gnus-set-global-variables)
12723 (while (gnus-summary-go-up-thread))
12724 (gnus-summary-article-number))
12726 (defun gnus-summary-kill-thread (&optional unmark)
12727 "Mark articles under current thread as read.
12728 If the prefix argument is positive, remove any kinds of marks.
12729 If the prefix argument is negative, tick articles instead."
12731 (gnus-set-global-variables)
12733 (setq unmark (prefix-numeric-value unmark)))
12734 (let ((articles (gnus-summary-articles-in-thread)))
12736 ;; Expand the thread.
12737 (gnus-summary-show-thread)
12738 ;; Mark all the articles.
12740 (gnus-summary-goto-subject (car articles))
12741 (cond ((null unmark)
12742 (gnus-summary-mark-article-as-read gnus-killed-mark))
12744 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12746 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12747 (setq articles (cdr articles))))
12748 ;; Hide killed subtrees.
12750 gnus-thread-hide-killed
12751 (gnus-summary-hide-thread))
12752 ;; If marked as read, go to next unread subject.
12754 ;; Go to next unread subject.
12755 (gnus-summary-next-subject 1 t)))
12756 (gnus-set-mode-line 'summary))
12758 ;; Summary sorting commands
12760 (defun gnus-summary-sort-by-number (&optional reverse)
12761 "Sort summary buffer by article number.
12762 Argument REVERSE means reverse order."
12764 (gnus-summary-sort 'number reverse))
12766 (defun gnus-summary-sort-by-author (&optional reverse)
12767 "Sort summary buffer by author name alphabetically.
12768 If case-fold-search is non-nil, case of letters is ignored.
12769 Argument REVERSE means reverse order."
12771 (gnus-summary-sort 'author reverse))
12773 (defun gnus-summary-sort-by-subject (&optional reverse)
12774 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12775 If case-fold-search is non-nil, case of letters is ignored.
12776 Argument REVERSE means reverse order."
12778 (gnus-summary-sort 'subject reverse))
12780 (defun gnus-summary-sort-by-date (&optional reverse)
12781 "Sort summary buffer by date.
12782 Argument REVERSE means reverse order."
12784 (gnus-summary-sort 'date reverse))
12786 (defun gnus-summary-sort-by-score (&optional reverse)
12787 "Sort summary buffer by score.
12788 Argument REVERSE means reverse order."
12790 (gnus-summary-sort 'score reverse))
12792 (defun gnus-summary-sort (predicate reverse)
12793 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12794 (gnus-set-global-variables)
12795 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12796 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12797 (gnus-thread-sort-functions
12802 (,thread t2 t1)))))
12803 (gnus-article-sort-functions
12808 (,article t2 t1)))))
12810 (gnus-summary-prepare-hook nil))
12811 ;; We do the sorting by regenerating the threads.
12812 (gnus-summary-prepare)
12813 ;; Hide subthreads if needed.
12814 (when (and gnus-show-threads gnus-thread-hide-subtree)
12815 (gnus-summary-hide-all-threads)))
12816 ;; If in async mode, we send some info to the backend.
12817 (when gnus-newsgroup-async
12818 (gnus-request-asynchronous
12819 gnus-newsgroup-name gnus-newsgroup-data)))
12821 (defun gnus-sortable-date (date)
12822 "Make sortable string by string-lessp from DATE.
12823 Timezone package is used."
12824 (setq date (timezone-fix-time date nil nil))
12825 (timezone-make-sortable-date
12826 (aref date 0) (aref date 2) (aref date 2)
12827 (timezone-make-time-string
12828 (aref date 3) (aref date 4) (aref date 5))))
12830 ;; Summary saving commands.
12832 (defun gnus-summary-save-article (&optional n not-saved)
12833 "Save the current article using the default saver function.
12834 If N is a positive number, save the N next articles.
12835 If N is a negative number, save the N previous articles.
12836 If N is nil and any articles have been marked with the process mark,
12837 save those articles instead.
12838 The variable `gnus-default-article-saver' specifies the saver function."
12840 (gnus-set-global-variables)
12841 (let ((articles (gnus-summary-work-articles n))
12842 file header article)
12844 (setq header (gnus-summary-article-header
12845 (setq article (pop articles))))
12846 (if (not (vectorp header))
12847 ;; This is a pseudo-article.
12848 (if (assq 'name header)
12849 (gnus-copy-file (cdr (assq 'name header)))
12850 (gnus-message 1 "Article %d is unsaveable" article))
12851 ;; This is a real article.
12852 (save-window-excursion
12853 (gnus-summary-select-article t nil nil article))
12854 (unless gnus-save-all-headers
12855 ;; Remove headers accoring to `gnus-saved-headers'.
12856 (let ((gnus-visible-headers
12857 (or gnus-saved-headers gnus-visible-headers)))
12858 (gnus-article-hide-headers nil t)))
12859 ;; Remove any X-Gnus lines.
12861 (set-buffer gnus-article-buffer)
12863 (let ((buffer-read-only nil))
12864 (nnheader-narrow-to-headers)
12865 (while (re-search-forward "^X-Gnus" nil t)
12866 (gnus-delete-line)))))
12867 (save-window-excursion
12868 (if (not gnus-default-article-saver)
12869 (error "No default saver is defined.")
12870 (setq file (funcall
12871 gnus-default-article-saver
12873 ((not gnus-prompt-before-saving)
12875 ((eq gnus-prompt-before-saving 'always)
12878 (gnus-summary-remove-process-mark article)
12880 (gnus-summary-set-saved-mark article))))
12881 (gnus-summary-position-point)
12884 (defun gnus-summary-pipe-output (&optional arg)
12885 "Pipe the current article to a subprocess.
12886 If N is a positive number, pipe the N next articles.
12887 If N is a negative number, pipe the N previous articles.
12888 If N is nil and any articles have been marked with the process mark,
12889 pipe those articles instead."
12891 (gnus-set-global-variables)
12892 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12893 (gnus-summary-save-article arg t))
12894 (gnus-configure-windows 'pipe))
12896 (defun gnus-summary-save-article-mail (&optional arg)
12897 "Append the current article to an mail file.
12898 If N is a positive number, save the N next articles.
12899 If N is a negative number, save the N previous articles.
12900 If N is nil and any articles have been marked with the process mark,
12901 save those articles instead."
12903 (gnus-set-global-variables)
12904 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12905 (gnus-summary-save-article arg)))
12907 (defun gnus-summary-save-article-rmail (&optional arg)
12908 "Append the current article to an rmail file.
12909 If N is a positive number, save the N next articles.
12910 If N is a negative number, save the N previous articles.
12911 If N is nil and any articles have been marked with the process mark,
12912 save those articles instead."
12914 (gnus-set-global-variables)
12915 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12916 (gnus-summary-save-article arg)))
12918 (defun gnus-summary-save-article-file (&optional arg)
12919 "Append the current article to a file.
12920 If N is a positive number, save the N next articles.
12921 If N is a negative number, save the N previous articles.
12922 If N is nil and any articles have been marked with the process mark,
12923 save those articles instead."
12925 (gnus-set-global-variables)
12926 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12927 (gnus-summary-save-article arg)))
12929 (defun gnus-summary-save-article-body-file (&optional arg)
12930 "Append the current article body to a file.
12931 If N is a positive number, save the N next articles.
12932 If N is a negative number, save the N previous articles.
12933 If N is nil and any articles have been marked with the process mark,
12934 save those articles instead."
12936 (gnus-set-global-variables)
12937 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12938 (gnus-summary-save-article arg)))
12940 (defun gnus-get-split-value (methods)
12941 "Return a value based on the split METHODS."
12942 (let (split-name method result match)
12945 (set-buffer gnus-original-article-buffer)
12947 (nnheader-narrow-to-headers)
12949 (goto-char (point-min))
12950 (setq method (pop methods))
12951 (setq match (car method))
12954 ;; Regular expression.
12956 (re-search-forward match nil t)
12958 ((gnus-functionp match)
12962 (setq result (funcall match gnus-newsgroup-name))))
12967 (setq result (eval match)))))
12968 (setq split-name (append (cdr method) split-name))
12969 (cond ((stringp result)
12970 (push result split-name))
12972 (setq split-name (append result split-name)))))))))
12975 (defun gnus-read-move-group-name (prompt default articles prefix)
12976 "Read a group name."
12977 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12984 (assoc (symbol-name
12985 (car (gnus-find-method-for-group
12987 gnus-valid-select-methods))
12988 (push (list (symbol-name g)) group-map)))
12989 gnus-active-hashtb))
12991 (format "%s %s to:"
12993 (if (> (length articles) 1)
12994 (format "these %d articles" (length articles))
12999 (gnus-completing-read default prom
13000 group-map nil nil prefix
13001 'gnus-group-history))
13002 ((= 1 (length split-name))
13003 (gnus-completing-read (car split-name) prom group-map
13005 'gnus-group-history))
13007 (gnus-completing-read nil prom
13008 (mapcar (lambda (el) (list el))
13009 (nreverse split-name))
13011 'gnus-group-history)))))
13013 (if (or (string= to-newsgroup "")
13014 (string= to-newsgroup prefix))
13015 (setq to-newsgroup (or default "")))
13016 (or (gnus-active to-newsgroup)
13017 (gnus-activate-group to-newsgroup)
13018 (error "No such group: %s" to-newsgroup)))
13021 (defun gnus-read-save-file-name (prompt default-name)
13022 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13024 ;; Let the split methods have their say.
13026 ;; No split name was found.
13029 (concat prompt " (default "
13030 (file-name-nondirectory default-name) ") ")
13031 (file-name-directory default-name)
13033 ;; A single split name was found
13034 ((= 1 (length split-name))
13036 (concat prompt " (default " (car split-name) ") ")
13037 gnus-article-save-directory
13038 (concat gnus-article-save-directory (car split-name))))
13039 ;; A list of splits was found.
13041 (setq split-name (nreverse split-name))
13043 (let ((file-name-history (nconc split-name file-name-history)))
13046 (concat prompt " (`M-p' for defaults) ")
13047 gnus-article-save-directory
13048 (car split-name))))
13049 (car (push result file-name-history)))))))
13050 ;; If we have read a directory, we append the default file name.
13051 (when (file-directory-p file)
13052 (setq file (concat (file-name-as-directory file)
13053 (file-name-nondirectory default-name))))
13054 ;; Possibly translate some charaters.
13055 (nnheader-translate-file-chars file)))
13057 (defun gnus-article-archive-name (group)
13058 "Return the first instance of an \"Archive-name\" in the current buffer."
13059 (let ((case-fold-search t))
13060 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13061 (match-string 1))))
13063 (defun gnus-summary-save-in-rmail (&optional filename)
13064 "Append this article to Rmail file.
13065 Optional argument FILENAME specifies file name.
13066 Directory to save to is default to `gnus-article-save-directory'."
13068 (gnus-set-global-variables)
13069 (let ((default-name
13070 (funcall gnus-rmail-save-name gnus-newsgroup-name
13071 gnus-current-headers gnus-newsgroup-last-rmail)))
13073 (cond ((eq filename 'default)
13075 (filename filename)
13076 (t (gnus-read-save-file-name
13077 "Save in rmail file:" default-name))))
13078 (gnus-make-directory (file-name-directory filename))
13079 (gnus-eval-in-buffer-window
13080 gnus-original-article-buffer
13084 (gnus-output-to-rmail filename))))
13085 ;; Remember the directory name to save articles
13086 (setq gnus-newsgroup-last-rmail filename)))
13088 (defun gnus-summary-save-in-mail (&optional filename)
13089 "Append this article to Unix mail file.
13090 Optional argument FILENAME specifies file name.
13091 Directory to save to is default to `gnus-article-save-directory'."
13093 (gnus-set-global-variables)
13094 (let ((default-name
13095 (funcall gnus-mail-save-name gnus-newsgroup-name
13096 gnus-current-headers gnus-newsgroup-last-mail)))
13098 (cond ((eq filename 'default)
13100 (filename filename)
13101 (t (gnus-read-save-file-name
13102 "Save in Unix mail file:" default-name))))
13104 (expand-file-name filename
13106 (file-name-directory default-name))))
13107 (gnus-make-directory (file-name-directory filename))
13108 (gnus-eval-in-buffer-window
13109 gnus-original-article-buffer
13113 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13114 (gnus-output-to-rmail filename)
13115 (let ((mail-use-rfc822 t))
13116 (rmail-output filename 1 t t))))))
13117 ;; Remember the directory name to save articles.
13118 (setq gnus-newsgroup-last-mail filename)))
13120 (defun gnus-summary-save-in-file (&optional filename)
13121 "Append this article to file.
13122 Optional argument FILENAME specifies file name.
13123 Directory to save to is default to `gnus-article-save-directory'."
13125 (gnus-set-global-variables)
13126 (let ((default-name
13127 (funcall gnus-file-save-name gnus-newsgroup-name
13128 gnus-current-headers gnus-newsgroup-last-file)))
13130 (cond ((eq filename 'default)
13132 (filename filename)
13133 (t (gnus-read-save-file-name
13134 "Save in file:" default-name))))
13135 (gnus-make-directory (file-name-directory filename))
13136 (gnus-eval-in-buffer-window
13137 gnus-original-article-buffer
13141 (gnus-output-to-file filename))))
13142 ;; Remember the directory name to save articles.
13143 (setq gnus-newsgroup-last-file filename)))
13145 (defun gnus-summary-save-body-in-file (&optional filename)
13146 "Append this article body to a file.
13147 Optional argument FILENAME specifies file name.
13148 The directory to save in defaults to `gnus-article-save-directory'."
13150 (gnus-set-global-variables)
13151 (let ((default-name
13152 (funcall gnus-file-save-name gnus-newsgroup-name
13153 gnus-current-headers gnus-newsgroup-last-file)))
13155 (cond ((eq filename 'default)
13157 (filename filename)
13158 (t (gnus-read-save-file-name
13159 "Save body in file:" default-name))))
13160 (gnus-make-directory (file-name-directory filename))
13161 (gnus-eval-in-buffer-window
13162 gnus-article-buffer
13166 (goto-char (point-min))
13167 (and (search-forward "\n\n" nil t)
13168 (narrow-to-region (point) (point-max)))
13169 (gnus-output-to-file filename))))
13170 ;; Remember the directory name to save articles.
13171 (setq gnus-newsgroup-last-file filename)))
13173 (defun gnus-summary-save-in-pipe (&optional command)
13174 "Pipe this article to subprocess."
13176 (gnus-set-global-variables)
13178 (cond ((eq command 'default)
13179 gnus-last-shell-command)
13181 (t (read-string "Shell command on article: "
13182 gnus-last-shell-command))))
13183 (if (string-equal command "")
13184 (setq command gnus-last-shell-command))
13185 (gnus-eval-in-buffer-window
13186 gnus-article-buffer
13189 (shell-command-on-region (point-min) (point-max) command nil)))
13190 (setq gnus-last-shell-command command))
13192 ;; Summary extract commands
13194 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13195 (let ((buffer-read-only nil)
13196 (article (gnus-summary-article-number))
13198 (or (gnus-summary-goto-subject article)
13199 (error (format "No such article: %d" article)))
13200 (gnus-summary-position-point)
13201 ;; If all commands are to be bunched up on one line, we collect
13203 (if gnus-view-pseudos-separately
13205 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13208 (setq action (cdr (assq 'action (car ps))))
13209 (setq files (list (cdr (assq 'name (car ps)))))
13210 (while (and ps (cdr ps)
13211 (string= (or action "1")
13212 (or (cdr (assq 'action (cadr ps))) "2")))
13213 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13214 (setcdr ps (cddr ps)))
13217 (if (not (string-match "%s" action))
13218 (setq files (cons " " files)))
13219 (setq files (cons " " files))
13220 (and (assq 'execute (car ps))
13221 (setcdr (assq 'execute (car ps))
13222 (funcall (if (string-match "%s" action)
13225 (mapconcat (lambda (f) f) files " ")))))
13226 (setq ps (cdr ps)))))
13227 (if (and gnus-view-pseudos (not not-view))
13229 (and (assq 'execute (car pslist))
13230 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13231 (eq gnus-view-pseudos 'not-confirm)))
13232 (setq pslist (cdr pslist)))
13235 (setq after-article (or (cdr (assq 'article (car pslist)))
13236 (gnus-summary-article-number)))
13237 (gnus-summary-goto-subject after-article)
13240 (insert " " (file-name-nondirectory
13241 (cdr (assq 'name (car pslist))))
13242 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13244 (forward-line -1) ; back to `b'
13245 (gnus-add-text-properties
13246 b e (list 'gnus-number gnus-reffed-article-number
13247 gnus-mouse-face-prop gnus-mouse-face))
13249 after-article gnus-reffed-article-number
13250 gnus-unread-mark b (car pslist) 0 (- e b))
13251 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13252 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13253 (setq pslist (cdr pslist)))))))
13255 (defun gnus-pseudos< (p1 p2)
13256 (let ((c1 (cdr (assq 'action p1)))
13257 (c2 (cdr (assq 'action p2))))
13258 (and c1 c2 (string< c1 c2))))
13260 (defun gnus-request-pseudo-article (props)
13261 (cond ((assq 'execute props)
13262 (gnus-execute-command (cdr (assq 'execute props)))))
13263 (let ((gnus-current-article (gnus-summary-article-number)))
13264 (run-hooks 'gnus-mark-article-hook)))
13266 (defun gnus-execute-command (command &optional automatic)
13268 (gnus-article-setup-buffer)
13269 (set-buffer gnus-article-buffer)
13270 (setq buffer-read-only nil)
13271 (let ((command (if automatic command (read-string "Command: " command)))
13272 ;; Just binding this here doesn't help, because there might
13273 ;; be output from the process after exiting the scope of
13275 ;; (buffer-read-only nil)
13278 (insert "$ " command "\n\n")
13279 (if gnus-view-pseudo-asynchronously
13280 (start-process "gnus-execute" nil "sh" "-c" command)
13281 (call-process "sh" nil t nil "-c" command)))))
13283 (defun gnus-copy-file (file &optional to)
13286 (list (read-file-name "Copy file: " default-directory)
13287 (read-file-name "Copy file to: " default-directory)))
13288 (gnus-set-global-variables)
13289 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13290 (and (file-directory-p to)
13291 (setq to (concat (file-name-as-directory to)
13292 (file-name-nondirectory file))))
13293 (copy-file file to))
13295 ;; Summary kill commands.
13297 (defun gnus-summary-edit-global-kill (article)
13298 "Edit the \"global\" kill file."
13299 (interactive (list (gnus-summary-article-number)))
13300 (gnus-set-global-variables)
13301 (gnus-group-edit-global-kill article))
13303 (defun gnus-summary-edit-local-kill ()
13304 "Edit a local kill file applied to the current newsgroup."
13306 (gnus-set-global-variables)
13307 (setq gnus-current-headers (gnus-summary-article-header))
13308 (gnus-set-global-variables)
13309 (gnus-group-edit-local-kill
13310 (gnus-summary-article-number) gnus-newsgroup-name))
13314 ;;; Gnus article mode
13317 (put 'gnus-article-mode 'mode-class 'special)
13319 (if gnus-article-mode-map
13321 (setq gnus-article-mode-map (make-keymap))
13322 (suppress-keymap gnus-article-mode-map)
13324 (gnus-define-keys gnus-article-mode-map
13325 " " gnus-article-goto-next-page
13326 "\177" gnus-article-goto-prev-page
13327 [delete] gnus-article-goto-prev-page
13328 "\C-c^" gnus-article-refer-article
13329 "h" gnus-article-show-summary
13330 "s" gnus-article-show-summary
13331 "\C-c\C-m" gnus-article-mail
13332 "?" gnus-article-describe-briefly
13333 gnus-mouse-2 gnus-article-push-button
13334 "\r" gnus-article-press-button
13335 "\t" gnus-article-next-button
13336 "\M-\t" gnus-article-prev-button
13337 "\C-c\C-b" gnus-bug)
13339 (substitute-key-definition
13340 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13342 (defun gnus-article-mode ()
13343 "Major mode for displaying an article.
13345 All normal editing commands are switched off.
13347 The following commands are available:
13349 \\<gnus-article-mode-map>
13350 \\[gnus-article-next-page]\t Scroll the article one page forwards
13351 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13352 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13353 \\[gnus-article-show-summary]\t Display the summary buffer
13354 \\[gnus-article-mail]\t Send a reply to the address near point
13355 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13356 \\[gnus-info-find-node]\t Go to the Gnus info node"
13358 (when (and menu-bar-mode
13359 (gnus-visual-p 'article-menu 'menu))
13360 (gnus-article-make-menu-bar))
13361 (kill-all-local-variables)
13362 (gnus-simplify-mode-line)
13363 (setq mode-name "Article")
13364 (setq major-mode 'gnus-article-mode)
13365 (make-local-variable 'minor-mode-alist)
13366 (or (assq 'gnus-show-mime minor-mode-alist)
13367 (setq minor-mode-alist
13368 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13369 (use-local-map gnus-article-mode-map)
13370 (make-local-variable 'page-delimiter)
13371 (setq page-delimiter gnus-page-delimiter)
13372 (buffer-disable-undo (current-buffer))
13373 (setq buffer-read-only t) ;Disable modification
13374 (run-hooks 'gnus-article-mode-hook))
13376 (defun gnus-article-setup-buffer ()
13377 "Initialize the article buffer."
13378 (let* ((name (if gnus-single-article-buffer "*Article*"
13379 (concat "*Article " gnus-newsgroup-name "*")))
13381 (progn (string-match "\\*Article" name)
13382 (concat " *Original Article"
13383 (substring name (match-end 0))))))
13384 (setq gnus-article-buffer name)
13385 (setq gnus-original-article-buffer original)
13386 ;; This might be a variable local to the summary buffer.
13387 (unless gnus-single-article-buffer
13389 (set-buffer gnus-summary-buffer)
13390 (setq gnus-article-buffer name)
13391 (setq gnus-original-article-buffer original)
13392 (gnus-set-global-variables))
13393 (make-local-variable 'gnus-summary-buffer))
13394 ;; Init original article buffer.
13396 (set-buffer (get-buffer-create gnus-original-article-buffer))
13397 (buffer-disable-undo (current-buffer))
13398 (setq major-mode 'gnus-original-article-mode)
13399 (make-local-variable 'gnus-original-article))
13400 (if (get-buffer name)
13403 (buffer-disable-undo (current-buffer))
13404 (setq buffer-read-only t)
13405 (gnus-add-current-to-buffer-list)
13406 (or (eq major-mode 'gnus-article-mode)
13407 (gnus-article-mode))
13410 (set-buffer (get-buffer-create name))
13411 (gnus-add-current-to-buffer-list)
13412 (gnus-article-mode)
13413 (current-buffer)))))
13415 ;; Set article window start at LINE, where LINE is the number of lines
13416 ;; from the head of the article.
13417 (defun gnus-article-set-window-start (&optional line)
13419 (get-buffer-window gnus-article-buffer t)
13421 (set-buffer gnus-article-buffer)
13422 (goto-char (point-min))
13425 (gnus-message 6 "Moved to bookmark")
13426 (search-forward "\n\n" nil t)
13427 (forward-line line)
13430 (defun gnus-kill-all-overlays ()
13431 "Delete all overlays in the current buffer."
13432 (when (fboundp 'overlay-lists)
13433 (let* ((overlayss (overlay-lists))
13434 (buffer-read-only nil)
13435 (overlays (nconc (car overlayss) (cdr overlayss))))
13437 (delete-overlay (pop overlays))))))
13439 (defun gnus-request-article-this-buffer (article group)
13440 "Get an article and insert it into this buffer."
13441 (let (do-update-line)
13445 (gnus-kill-all-overlays)
13446 (setq group (or group gnus-newsgroup-name))
13448 ;; Open server if it has closed.
13449 (gnus-check-server (gnus-find-method-for-group group))
13451 ;; Using `gnus-request-article' directly will insert the article into
13452 ;; `nntp-server-buffer' - so we'll save some time by not having to
13453 ;; copy it from the server buffer into the article buffer.
13455 ;; We only request an article by message-id when we do not have the
13456 ;; headers for it, so we'll have to get those.
13457 (when (stringp article)
13458 (let ((gnus-override-method gnus-refer-article-method))
13459 (gnus-read-header article)))
13461 ;; If the article number is negative, that means that this article
13462 ;; doesn't belong in this newsgroup (possibly), so we find its
13463 ;; message-id and request it by id instead of number.
13464 (when (and (numberp article)
13465 gnus-summary-buffer
13466 (get-buffer gnus-summary-buffer)
13467 (buffer-name (get-buffer gnus-summary-buffer)))
13469 (set-buffer gnus-summary-buffer)
13470 (let ((header (gnus-summary-article-header article)))
13473 ((memq article gnus-newsgroup-sparse)
13474 ;; This is a sparse gap article.
13475 (setq do-update-line article)
13476 (setq article (mail-header-id header))
13477 (let ((gnus-override-method gnus-refer-article-method))
13478 (gnus-read-header article))
13479 (setq gnus-newsgroup-sparse
13480 (delq article gnus-newsgroup-sparse)))
13482 ;; It's a real article.
13483 (setq article (mail-header-id header)))
13485 ;; It is an extracted pseudo-article.
13486 (setq article 'pseudo)
13487 (gnus-request-pseudo-article header))))
13489 (let ((method (gnus-find-method-for-group
13490 gnus-newsgroup-name)))
13491 (if (not (eq (car method) 'nneething))
13493 (let ((dir (concat (file-name-as-directory (nth 1 method))
13494 (mail-header-subject header))))
13495 (if (file-directory-p dir)
13497 (setq article 'nneething)
13498 (gnus-group-enter-directory dir)))))))))
13501 ;; Refuse to select canceled articles.
13502 ((and (numberp article)
13503 gnus-summary-buffer
13504 (get-buffer gnus-summary-buffer)
13505 (buffer-name (get-buffer gnus-summary-buffer))
13506 (eq (cdr (save-excursion
13507 (set-buffer gnus-summary-buffer)
13508 (assq article gnus-newsgroup-reads)))
13509 gnus-canceled-mark))
13511 ;; We first check `gnus-original-article-buffer'.
13512 ((and (get-buffer gnus-original-article-buffer)
13515 (set-buffer gnus-original-article-buffer)
13516 (and (equal (car gnus-original-article) group)
13517 (eq (cdr gnus-original-article) article))))
13518 (insert-buffer-substring gnus-original-article-buffer)
13520 ;; Check the backlog.
13521 ((and gnus-keep-backlog
13522 (gnus-backlog-request-article group article (current-buffer)))
13524 ;; Check the cache.
13525 ((and gnus-use-cache
13527 (gnus-cache-request-article article group))
13529 ;; Get the article and put into the article buffer.
13530 ((or (stringp article) (numberp article))
13531 (let ((gnus-override-method
13532 (and (stringp article) gnus-refer-article-method))
13533 (buffer-read-only nil))
13535 (gnus-kill-all-overlays)
13536 (if (gnus-request-article article group (current-buffer))
13538 (and gnus-keep-backlog
13540 (gnus-backlog-enter-article
13541 group article (current-buffer)))
13543 ;; It was a pseudo.
13546 ;; Take the article from the original article buffer
13547 ;; and place it in the buffer it's supposed to be in.
13548 (when (and (get-buffer gnus-article-buffer)
13550 (equal (buffer-name (current-buffer))
13551 (buffer-name (get-buffer gnus-article-buffer))))
13553 (if (get-buffer gnus-original-article-buffer)
13554 (set-buffer (get-buffer gnus-original-article-buffer))
13555 (set-buffer (get-buffer-create gnus-original-article-buffer))
13556 (buffer-disable-undo (current-buffer))
13557 (setq major-mode 'gnus-original-article-mode)
13558 (setq buffer-read-only t)
13559 (gnus-add-current-to-buffer-list))
13560 (let (buffer-read-only)
13562 (insert-buffer-substring gnus-article-buffer))
13563 (setq gnus-original-article (cons group article))))
13565 ;; Update sparse articles.
13566 (when (and do-update-line
13567 (or (numberp article)
13568 (stringp article)))
13569 (let ((buf (current-buffer)))
13570 (set-buffer gnus-summary-buffer)
13571 (gnus-summary-update-article do-update-line)
13572 (gnus-summary-goto-subject do-update-line nil t)
13573 (set-window-point (get-buffer-window (current-buffer) t)
13575 (set-buffer buf))))))
13577 (defun gnus-read-header (id &optional header)
13578 "Read the headers of article ID and enter them into the Gnus system."
13579 (let ((group gnus-newsgroup-name)
13580 (gnus-override-method
13581 (and (gnus-news-group-p gnus-newsgroup-name)
13582 gnus-refer-article-method))
13584 ;; First we check to see whether the header in question is already
13587 ;; This is a Message-ID.
13588 (setq header (or header (gnus-id-to-header id)))
13589 ;; This is an article number.
13590 (setq header (or header (gnus-summary-article-header id))))
13592 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13593 ;; We have found the header.
13595 ;; We have to really fetch the header to this article.
13597 (if (gnus-check-backend-function 'request-head group)
13598 (gnus-request-head id group)
13599 (gnus-request-article id group)))
13601 (set-buffer nntp-server-buffer)
13602 (and (search-forward "\n\n" nil t)
13603 (delete-region (1- (point)) (point-max)))
13604 (goto-char (point-max))
13606 (goto-char (point-min))
13610 ((cdr where) (cdr where))
13611 (header (mail-header-number header))
13612 (t gnus-reffed-article-number))
13614 (insert " Article retrieved.\n"))
13616 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13617 ; (setcar (gnus-id-to-thread id) nil))
13618 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13619 () ; Malformed head.
13620 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13621 (if (and (stringp id)
13622 (not (string= (gnus-group-real-name group)
13624 ;; If we fetched by Message-ID and the article came
13625 ;; from a different group, we fudge some bogus article
13626 ;; numbers for this article.
13627 (mail-header-set-number header gnus-reffed-article-number))
13628 (decf gnus-reffed-article-number)
13629 (push header gnus-newsgroup-headers)
13630 (setq gnus-current-headers header)
13631 (push (mail-header-number header) gnus-newsgroup-limit))
13634 (defun gnus-article-prepare (article &optional all-headers header)
13635 "Prepare ARTICLE in article mode buffer.
13636 ARTICLE should either be an article number or a Message-ID.
13637 If ARTICLE is an id, HEADER should be the article headers.
13638 If ALL-HEADERS is non-nil, no headers are hidden."
13640 ;; Make sure we start in a summary buffer.
13641 (unless (eq major-mode 'gnus-summary-mode)
13642 (set-buffer gnus-summary-buffer))
13643 (setq gnus-summary-buffer (current-buffer))
13644 ;; Make sure the connection to the server is alive.
13645 (unless (gnus-server-opened
13646 (gnus-find-method-for-group gnus-newsgroup-name))
13647 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13648 (gnus-request-group gnus-newsgroup-name t))
13649 (let* ((article (if header (mail-header-number header) article))
13650 (summary-buffer (current-buffer))
13651 (internal-hook gnus-article-internal-prepare-hook)
13652 (group gnus-newsgroup-name)
13655 (gnus-article-setup-buffer)
13656 (set-buffer gnus-article-buffer)
13657 ;; Deactivate active regions.
13658 (when (and (boundp 'transient-mark-mode)
13659 transient-mark-mode)
13660 (setq mark-active nil))
13661 (if (not (setq result (let ((buffer-read-only nil))
13662 (gnus-request-article-this-buffer
13664 ;; There is no such article.
13666 (when (and (numberp article)
13667 (not (memq article gnus-newsgroup-sparse)))
13668 (setq gnus-article-current
13669 (cons gnus-newsgroup-name article))
13670 (set-buffer gnus-summary-buffer)
13671 (setq gnus-current-article article)
13672 (gnus-summary-mark-article article gnus-canceled-mark))
13673 (unless (memq article gnus-newsgroup-sparse)
13675 1 "No such article (may have expired or been canceled)")))
13676 (if (or (eq result 'pseudo) (eq result 'nneething))
13679 (set-buffer summary-buffer)
13680 (setq gnus-last-article gnus-current-article
13681 gnus-newsgroup-history (cons gnus-current-article
13682 gnus-newsgroup-history)
13683 gnus-current-article 0
13684 gnus-current-headers nil
13685 gnus-article-current nil)
13686 (if (eq result 'nneething)
13687 (gnus-configure-windows 'summary)
13688 (gnus-configure-windows 'article))
13689 (gnus-set-global-variables))
13690 (gnus-set-mode-line 'article))
13691 ;; The result from the `request' was an actual article -
13692 ;; or at least some text that is now displayed in the
13694 (if (and (numberp article)
13695 (not (eq article gnus-current-article)))
13696 ;; Seems like a new article has been selected.
13697 ;; `gnus-current-article' must be an article number.
13699 (set-buffer summary-buffer)
13700 (setq gnus-last-article gnus-current-article
13701 gnus-newsgroup-history (cons gnus-current-article
13702 gnus-newsgroup-history)
13703 gnus-current-article article
13704 gnus-current-headers
13705 (gnus-summary-article-header gnus-current-article)
13706 gnus-article-current
13707 (cons gnus-newsgroup-name gnus-current-article))
13708 (unless (vectorp gnus-current-headers)
13709 (setq gnus-current-headers nil))
13710 (gnus-summary-show-thread)
13711 (run-hooks 'gnus-mark-article-hook)
13712 (gnus-set-mode-line 'summary)
13713 (and (gnus-visual-p 'article-highlight 'highlight)
13714 (run-hooks 'gnus-visual-mark-article-hook))
13715 ;; Set the global newsgroup variables here.
13716 ;; Suggested by Jim Sisolak
13717 ;; <sisolak@trans4.neep.wisc.edu>.
13718 (gnus-set-global-variables)
13719 (setq gnus-have-all-headers
13720 (or all-headers gnus-show-all-headers))
13721 (and gnus-use-cache
13722 (vectorp (gnus-summary-article-header article))
13723 (gnus-cache-possibly-enter-article
13725 (gnus-summary-article-header article)
13726 (memq article gnus-newsgroup-marked)
13727 (memq article gnus-newsgroup-dormant)
13728 (memq article gnus-newsgroup-unreads)))))
13729 (when (or (numberp article)
13731 ;; Hooks for getting information from the article.
13732 ;; This hook must be called before being narrowed.
13733 (let (buffer-read-only)
13734 (run-hooks 'internal-hook)
13735 (run-hooks 'gnus-article-prepare-hook)
13736 ;; Decode MIME message.
13738 (if (or (not gnus-strict-mime)
13739 (gnus-fetch-field "Mime-Version"))
13740 (funcall gnus-show-mime-method)
13741 (funcall gnus-decode-encoded-word-method)))
13742 ;; Perform the article display hooks.
13743 (run-hooks 'gnus-article-display-hook))
13745 (goto-char (point-min))
13746 (and gnus-break-pages (gnus-narrow-to-page)))
13747 (gnus-set-mode-line 'article)
13748 (gnus-configure-windows 'article)
13749 (goto-char (point-min))
13752 (defun gnus-article-show-all-headers ()
13753 "Show all article headers in article mode buffer."
13755 (gnus-article-setup-buffer)
13756 (set-buffer gnus-article-buffer)
13757 (let ((buffer-read-only nil))
13758 (gnus-unhide-text (point-min) (point-max)))))
13760 (defun gnus-article-hide-headers-if-wanted ()
13761 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13762 Provided for backwards compatibility."
13763 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13764 gnus-inhibit-hiding
13765 (gnus-article-hide-headers)))
13767 (defsubst gnus-article-header-rank ()
13768 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13769 (let ((list gnus-sorted-header-list)
13772 (when (looking-at (car list))
13774 (setq list (cdr list))
13778 (defun gnus-article-hide-headers (&optional arg delete)
13779 "Toggle whether to hide unwanted headers and possibly sort them as well.
13780 If given a negative prefix, always show; if given a positive prefix,
13783 (unless (gnus-article-check-hidden-text 'headers arg)
13784 ;; This function might be inhibited.
13785 (unless gnus-inhibit-hiding
13787 (set-buffer gnus-article-buffer)
13789 (let ((buffer-read-only nil)
13790 (props (nconc (list 'gnus-type 'headers)
13791 gnus-hidden-properties))
13792 (max (1+ (length gnus-sorted-header-list)))
13793 (ignored (when (not (stringp gnus-visible-headers))
13794 (cond ((stringp gnus-ignored-headers)
13795 gnus-ignored-headers)
13796 ((listp gnus-ignored-headers)
13797 (mapconcat 'identity gnus-ignored-headers
13800 (cond ((stringp gnus-visible-headers)
13801 gnus-visible-headers)
13802 ((and gnus-visible-headers
13803 (listp gnus-visible-headers))
13804 (mapconcat 'identity gnus-visible-headers "\\|"))))
13806 ;; First we narrow to just the headers.
13808 (goto-char (point-min))
13809 ;; Hide any "From " lines at the beginning of (mail) articles.
13810 (while (looking-at "From ")
13813 (gnus-hide-text (point-min) (point) props))
13814 ;; Then treat the rest of the header lines.
13817 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13818 ;; Then we use the two regular expressions
13819 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13820 ;; select which header lines is to remain visible in the
13822 (goto-char (point-min))
13823 (while (re-search-forward "^[^ \t]*:" nil t)
13824 (beginning-of-line)
13825 ;; We add the headers we want to keep to a list and delete
13826 ;; them from the buffer.
13827 (gnus-put-text-property
13828 (point) (1+ (point)) 'message-rank
13829 (if (or (and visible (looking-at visible))
13831 (not (looking-at ignored))))
13832 (gnus-article-header-rank)
13835 (message-sort-headers-1)
13836 (when (setq beg (text-property-any
13837 (point-min) (point-max) 'message-rank (+ 2 max)))
13838 ;; We make the unwanted headers invisible.
13840 (delete-region beg (point-max))
13841 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13842 (gnus-hide-text-type beg (point-max) 'headers))
13843 ;; Work around XEmacs lossage.
13844 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13846 (defun gnus-article-hide-boring-headers (&optional arg)
13847 "Toggle hiding of headers that aren't very interesting.
13848 If given a negative prefix, always show; if given a positive prefix,
13851 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13853 (set-buffer gnus-article-buffer)
13855 (let ((buffer-read-only nil)
13856 (list gnus-boring-article-headers)
13857 (inhibit-point-motion-hooks t)
13859 (nnheader-narrow-to-headers)
13861 (setq elem (pop list))
13862 (goto-char (point-min))
13864 ;; Hide empty headers.
13866 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13868 (gnus-hide-text-type
13869 (progn (beginning-of-line) (point))
13872 (if (re-search-forward "^[^ \t]" nil t)
13873 (match-beginning 0)
13876 ;; Hide boring Newsgroups header.
13877 ((eq elem 'newsgroups)
13878 (when (equal (message-fetch-field "newsgroups")
13879 (gnus-group-real-name gnus-newsgroup-name))
13880 (gnus-article-hide-header "newsgroups")))
13881 ((eq elem 'followup-to)
13882 (when (equal (message-fetch-field "followup-to")
13883 (message-fetch-field "newsgroups"))
13884 (gnus-article-hide-header "followup-to")))
13885 ((eq elem 'reply-to)
13886 (let ((from (message-fetch-field "from"))
13887 (reply-to (message-fetch-field "reply-to")))
13891 (nth 1 (funcall gnus-extract-address-components from))
13892 (nth 1 (funcall gnus-extract-address-components
13894 (gnus-article-hide-header "reply-to"))))
13896 (let ((date (message-fetch-field "date")))
13898 (< (gnus-days-between date (current-time-string))
13900 (gnus-article-hide-header "date")))))))))))
13902 (defun gnus-article-hide-header (header)
13904 (goto-char (point-min))
13905 (when (re-search-forward (concat "^" header ":") nil t)
13906 (gnus-hide-text-type
13907 (progn (beginning-of-line) (point))
13910 (if (re-search-forward "^[^ \t]" nil t)
13911 (match-beginning 0)
13913 'boring-headers))))
13915 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13916 (defun gnus-article-treat-overstrike ()
13917 "Translate overstrikes into bold text."
13920 (set-buffer gnus-article-buffer)
13921 (let ((buffer-read-only nil))
13922 (while (search-forward "\b" nil t)
13923 (let ((next (following-char))
13924 (previous (char-after (- (point) 2))))
13925 (cond ((eq next previous)
13926 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13927 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
13929 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
13930 (gnus-put-text-property
13931 (- (point) 2) (1- (point)) 'face 'underline))
13933 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13934 (gnus-put-text-property
13935 (point) (1+ (point)) 'face 'underline))))))))
13937 (defun gnus-article-word-wrap ()
13938 "Format too long lines."
13941 (set-buffer gnus-article-buffer)
13942 (let ((buffer-read-only nil))
13944 (goto-char (point-min))
13945 (search-forward "\n\n" nil t)
13947 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13948 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13949 (adaptive-fill-mode t))
13950 (while (not (eobp))
13951 (and (>= (current-column) (min fill-column (window-width)))
13952 (/= (preceding-char) ?:)
13953 (fill-paragraph nil))
13954 (end-of-line 2))))))
13956 (defun gnus-article-remove-cr ()
13957 "Remove carriage returns from an article."
13960 (set-buffer gnus-article-buffer)
13961 (let ((buffer-read-only nil))
13962 (goto-char (point-min))
13963 (while (search-forward "\r" nil t)
13964 (replace-match "" t t)))))
13966 (defun gnus-article-remove-trailing-blank-lines ()
13967 "Remove all trailing blank lines from the article."
13970 (set-buffer gnus-article-buffer)
13971 (let ((buffer-read-only nil))
13972 (goto-char (point-max))
13976 (while (looking-at "^[ \t]*$")
13981 (defun gnus-article-display-x-face (&optional force)
13982 "Look for an X-Face header and display it if present."
13983 (interactive (list 'force))
13985 (set-buffer gnus-article-buffer)
13986 ;; Delete the old process, if any.
13987 (when (process-status "gnus-x-face")
13988 (delete-process "gnus-x-face"))
13989 (let ((inhibit-point-motion-hooks t)
13990 (case-fold-search nil)
13993 (nnheader-narrow-to-headers)
13994 (setq from (message-fetch-field "from"))
13995 (goto-char (point-min))
13996 (when (and gnus-article-x-face-command
13998 ;; Check whether this face is censored.
13999 (not gnus-article-x-face-too-ugly)
14000 (and gnus-article-x-face-too-ugly from
14001 (not (string-match gnus-article-x-face-too-ugly
14003 ;; Has to be present.
14004 (re-search-forward "^X-Face: " nil t))
14005 ;; We now have the area of the buffer where the X-Face is stored.
14006 (let ((beg (point))
14007 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14008 ;; We display the face.
14009 (if (symbolp gnus-article-x-face-command)
14010 ;; The command is a lisp function, so we call it.
14011 (if (gnus-functionp gnus-article-x-face-command)
14012 (funcall gnus-article-x-face-command beg end)
14013 (error "%s is not a function" gnus-article-x-face-command))
14014 ;; The command is a string, so we interpret the command
14015 ;; as a, well, command, and fork it off.
14016 (let ((process-connection-type nil))
14017 (process-kill-without-query
14019 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14020 (process-send-region "gnus-x-face" beg end)
14021 (process-send-eof "gnus-x-face")))))))))
14023 (defalias 'gnus-header-decode-quoted-printable 'gnus-decode-rfc1522)
14024 (defun gnus-decode-rfc1522 ()
14025 "Hack to remove QP encoding from headers."
14026 (let ((case-fold-search t)
14027 (inhibit-point-motion-hooks t)
14028 (buffer-read-only nil)
14032 (goto-char (point-min))
14033 (or (search-forward "\n\n" nil t) (point-max)))
14035 (while (re-search-forward
14036 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14037 (setq string (match-string 1))
14038 (narrow-to-region (match-beginning 0) (match-end 0))
14039 (delete-region (point-min) (point-max))
14041 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14042 (subst-char-in-region (point-min) (point-max) ?_ ? )
14044 (goto-char (point-min))))))
14046 (defun gnus-article-de-quoted-unreadable (&optional force)
14047 "Do a naive translation of a quoted-printable-encoded article.
14048 This is in no way, shape or form meant as a replacement for real MIME
14049 processing, but is simply a stop-gap measure until MIME support is
14051 If FORCE, decode the article whether it is marked as quoted-printable
14053 (interactive (list 'force))
14055 (set-buffer gnus-article-buffer)
14056 (let ((case-fold-search t)
14057 (buffer-read-only nil)
14058 (type (gnus-fetch-field "content-transfer-encoding")))
14059 (gnus-decode-rfc1522)
14061 (and type (string-match "quoted-printable" (downcase type))))
14062 (goto-char (point-min))
14063 (search-forward "\n\n" nil 'move)
14064 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14066 (defun gnus-mime-decode-quoted-printable (from to)
14067 "Decode Quoted-Printable in the region between FROM and TO."
14070 (while (search-forward "=" to t)
14071 (cond ((eq (following-char) ?\n)
14074 ((looking-at "[0-9A-F][0-9A-F]")
14075 (subst-char-in-region
14076 (1- (point)) (point) ?=
14077 (hexl-hex-string-to-integer
14078 (buffer-substring (point) (+ 2 (point)))))
14082 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14084 (defun gnus-article-hide-pgp (&optional arg)
14085 "Toggle hiding of any PGP headers and signatures in the current article.
14086 If given a negative prefix, always show; if given a positive prefix,
14089 (unless (gnus-article-check-hidden-text 'pgp arg)
14091 (set-buffer gnus-article-buffer)
14092 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14093 buffer-read-only beg end)
14095 (goto-char (point-min))
14096 ;; Hide the "header".
14097 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14098 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14100 ;; Hide the actual signature.
14101 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14102 (setq end (1+ (match-beginning 0)))
14105 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14107 ;; Perhaps we shouldn't hide to the end of the buffer
14108 ;; if there is no end to the signature?
14111 ;; Hide "- " PGP quotation markers.
14112 (when (and beg end)
14113 (narrow-to-region beg end)
14114 (goto-char (point-min))
14115 (while (re-search-forward "^- " nil t)
14116 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14119 (defun gnus-article-hide-signature (&optional arg)
14120 "Hide the signature in the current article.
14121 If given a negative prefix, always show; if given a positive prefix,
14124 (unless (gnus-article-check-hidden-text 'signature arg)
14126 (set-buffer gnus-article-buffer)
14128 (let ((buffer-read-only nil))
14129 (when (gnus-narrow-to-signature)
14130 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14132 (defun gnus-article-strip-leading-blank-lines ()
14133 "Remove all blank lines from the beginning of the article."
14136 (set-buffer gnus-article-buffer)
14137 (let (buffer-read-only)
14138 (goto-char (point-min))
14139 (when (search-forward "\n\n" nil t)
14140 (while (looking-at "[ \t]$")
14141 (gnus-delete-line))))))
14143 (defun gnus-narrow-to-signature ()
14144 "Narrow to the signature."
14146 (goto-char (point-max))
14147 (when (re-search-backward gnus-signature-separator nil t)
14149 (when (or (null gnus-signature-limit)
14150 (and (numberp gnus-signature-limit)
14151 (< (- (point-max) (point)) gnus-signature-limit))
14152 (and (gnus-functionp gnus-signature-limit)
14153 (funcall gnus-signature-limit))
14154 (and (stringp gnus-signature-limit)
14155 (not (re-search-forward gnus-signature-limit nil t))))
14156 (narrow-to-region (point) (point-max))
14159 (defun gnus-article-check-hidden-text (type arg)
14160 "Return nil if hiding is necessary."
14162 (set-buffer gnus-article-buffer)
14163 (let ((hide (gnus-article-hidden-text-p type)))
14164 (cond ((or (and (null arg) (eq hide 'hidden))
14165 (and arg (< 0 (prefix-numeric-value arg))))
14166 (gnus-article-show-hidden-text type))
14168 (gnus-article-show-hidden-text type t))
14171 (defun gnus-article-hidden-text-p (type)
14172 "Say whether the current buffer contains hidden text of type TYPE."
14173 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14175 (if (get-text-property pos 'invisible)
14179 (defun gnus-article-hide (&optional arg force)
14180 "Hide all the gruft in the current article.
14181 This means that PGP stuff, signatures, cited text and (some)
14182 headers will be hidden.
14183 If given a prefix, show the hidden text instead."
14184 (interactive (list current-prefix-arg 'force))
14185 (gnus-article-hide-headers arg)
14186 (gnus-article-hide-pgp arg)
14187 (gnus-article-hide-citation-maybe arg force)
14188 (gnus-article-hide-signature arg))
14190 (defun gnus-article-show-hidden-text (type &optional hide)
14191 "Show all hidden text of type TYPE.
14192 If HIDE, hide the text instead."
14194 (set-buffer gnus-article-buffer)
14195 (let ((buffer-read-only nil)
14196 (inhibit-point-motion-hooks t)
14198 (while (gnus-goto-char (text-property-any
14199 beg (point-max) 'gnus-type type))
14203 (gnus-hide-text beg (point) gnus-hidden-properties)
14204 (gnus-unhide-text beg (point)))
14205 (setq beg (point)))
14208 (defvar gnus-article-time-units
14209 `((year . ,(* 365.25 24 60 60))
14210 (week . ,(* 7 24 60 60))
14211 (day . ,(* 24 60 60))
14212 (hour . ,(* 60 60))
14215 "Mapping from time units to seconds.")
14217 (defun gnus-article-date-ut (&optional type highlight)
14218 "Convert DATE date to universal time in the current article.
14219 If TYPE is `local', convert to local time; if it is `lapsed', output
14220 how much time has lapsed since DATE."
14221 (interactive (list 'ut t))
14222 (let* ((header (or gnus-current-headers
14223 (gnus-summary-article-header) ""))
14224 (date (and (vectorp header) (mail-header-date header)))
14225 (date-regexp "^Date: \\|^X-Sent: ")
14226 (now (current-time))
14227 (inhibit-point-motion-hooks t)
14229 (when (and date (not (string= date "")))
14231 (set-buffer gnus-article-buffer)
14233 (nnheader-narrow-to-headers)
14234 (let ((buffer-read-only nil))
14235 ;; Delete any old Date headers.
14236 (if (re-search-forward date-regexp nil t)
14238 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14239 eface (get-text-property (1- (gnus-point-at-eol))
14241 (message-remove-header date-regexp t)
14242 (beginning-of-line))
14243 (goto-char (point-max)))
14244 (insert (gnus-make-date-line date type))
14245 ;; Do highlighting.
14247 (when (and (gnus-visual-p 'article-highlight 'highlight)
14248 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14249 (gnus-put-text-property (match-beginning 1) (match-end 1)
14251 (gnus-put-text-property (match-beginning 2) (match-end 2)
14252 'face eface))))))))
14254 (defun gnus-make-date-line (date type)
14255 "Return a DATE line of TYPE."
14257 ;; Convert to the local timezone. We have to slap a
14258 ;; `condition-case' round the calls to the timezone
14259 ;; functions since they aren't particularly resistant to
14262 (concat "Date: " (condition-case ()
14263 (timezone-make-date-arpa-standard date)
14266 ;; Convert to Universal Time.
14270 (timezone-make-date-arpa-standard date nil "UT")
14273 ;; Get the original date from the article.
14274 ((eq type 'original)
14275 (concat "Date: " date "\n"))
14276 ;; Do an X-Sent lapsed format.
14278 ;; If the date is seriously mangled, the timezone
14279 ;; functions are liable to bug out, so we condition-case
14280 ;; the entire thing.
14281 (let* ((now (current-time))
14286 (timezone-make-date-arpa-standard
14287 (current-time-string now)
14288 (current-time-zone now) "UT"))
14290 (timezone-make-date-arpa-standard
14293 (real-sec (+ (* (float (car real-time)) 65536)
14295 (sec (abs real-sec))
14298 ((equal real-time '(0 0))
14299 "X-Sent: Unknown\n")
14305 ;; This is a bit convoluted, but basically we go
14306 ;; through the time units for years, weeks, etc,
14307 ;; and divide things to see whether that results
14308 ;; in positive answers.
14311 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14312 ;; The (remaining) seconds are too few to
14313 ;; be divided into this time unit.
14315 ;; It's big enough, so we output it.
14316 (setq sec (- sec (* num (cdr unit))))
14318 (concat (if prev ", " "") (int-to-string
14320 " " (symbol-name (car unit))
14321 (if (> num 1) "s" ""))
14323 gnus-article-time-units "")
14324 ;; If dates are odd, then it might appear like the
14325 ;; article was sent in the future.
14328 " in the future\n"))))))
14330 (error "Unknown conversion type: %s" type))))
14332 (defun gnus-article-date-local (&optional highlight)
14333 "Convert the current article date to the local timezone."
14334 (interactive (list t))
14335 (gnus-article-date-ut 'local highlight))
14337 (defun gnus-article-date-original (&optional highlight)
14338 "Convert the current article date to what it was originally.
14339 This is only useful if you have used some other date conversion
14340 function and want to see what the date was before converting."
14341 (interactive (list t))
14342 (gnus-article-date-ut 'original highlight))
14344 (defun gnus-article-date-lapsed (&optional highlight)
14345 "Convert the current article date to time lapsed since it was sent."
14346 (interactive (list t))
14347 (gnus-article-date-ut 'lapsed highlight))
14349 (defun gnus-article-maybe-highlight ()
14350 "Do some article highlighting if `gnus-visual' is non-nil."
14351 (if (gnus-visual-p 'article-highlight 'highlight)
14352 (gnus-article-highlight-some)))
14356 (defun gnus-output-to-rmail (file-name)
14357 "Append the current article to an Rmail file named FILE-NAME."
14359 ;; Most of these codes are borrowed from rmailout.el.
14360 (setq file-name (expand-file-name file-name))
14361 (setq rmail-default-rmail-file file-name)
14362 (let ((artbuf (current-buffer))
14363 (tmpbuf (get-buffer-create " *Gnus-output*")))
14365 (or (get-file-buffer file-name)
14366 (file-exists-p file-name)
14367 (if (gnus-yes-or-no-p
14368 (concat "\"" file-name "\" does not exist, create it? "))
14369 (let ((file-buffer (create-file-buffer file-name)))
14371 (set-buffer file-buffer)
14372 (rmail-insert-rmail-file-header)
14373 (let ((require-final-newline nil))
14374 (write-region (point-min) (point-max) file-name t 1)))
14375 (kill-buffer file-buffer))
14376 (error "Output file does not exist")))
14377 (set-buffer tmpbuf)
14378 (buffer-disable-undo (current-buffer))
14380 (insert-buffer-substring artbuf)
14381 (gnus-convert-article-to-rmail)
14382 ;; Decide whether to append to a file or to an Emacs buffer.
14383 (let ((outbuf (get-file-buffer file-name)))
14385 (append-to-file (point-min) (point-max) file-name)
14386 ;; File has been visited, in buffer OUTBUF.
14387 (set-buffer outbuf)
14388 (let ((buffer-read-only nil)
14389 (msg (and (boundp 'rmail-current-message)
14390 (symbol-value 'rmail-current-message))))
14391 ;; If MSG is non-nil, buffer is in RMAIL mode.
14394 (narrow-to-region (point-max) (point-max))))
14395 (insert-buffer-substring tmpbuf)
14398 (goto-char (point-min))
14400 (search-backward "\^_")
14401 (narrow-to-region (point) (point-max))
14402 (goto-char (1+ (point-min)))
14403 (rmail-count-new-messages t)
14404 (rmail-show-message msg)))))))
14405 (kill-buffer tmpbuf)))
14407 (defun gnus-output-to-file (file-name)
14408 "Append the current article to a file named FILE-NAME."
14409 (setq file-name (expand-file-name file-name))
14410 (let ((artbuf (current-buffer))
14411 (tmpbuf (get-buffer-create " *Gnus-output*")))
14413 (set-buffer tmpbuf)
14414 (buffer-disable-undo (current-buffer))
14416 (insert-buffer-substring artbuf)
14417 ;; Append newline at end of the buffer as separator, and then
14418 ;; save it to file.
14419 (goto-char (point-max))
14421 (append-to-file (point-min) (point-max) file-name))
14422 (kill-buffer tmpbuf)))
14424 (defun gnus-convert-article-to-rmail ()
14425 "Convert article in current buffer to Rmail message format."
14426 (let ((buffer-read-only nil))
14427 ;; Convert article directly into Babyl format.
14428 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14429 (goto-char (point-min))
14430 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14431 (while (search-forward "\n\^_" nil t) ;single char
14432 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14433 (goto-char (point-max))
14436 (defun gnus-narrow-to-page (&optional arg)
14437 "Narrow the article buffer to a page.
14438 If given a numerical ARG, move forward ARG pages."
14440 (setq arg (if arg (prefix-numeric-value arg) 0))
14442 (set-buffer gnus-article-buffer)
14443 (goto-char (point-min))
14445 (when (gnus-visual-p 'page-marker)
14446 (let ((buffer-read-only nil))
14447 (gnus-remove-text-with-property 'gnus-prev)
14448 (gnus-remove-text-with-property 'gnus-next)))
14451 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14453 (re-search-forward page-delimiter nil 'move arg)))
14454 (goto-char (match-end 0)))
14457 (if (re-search-forward page-delimiter nil 'move)
14458 (match-beginning 0)
14460 (when (and (gnus-visual-p 'page-marker)
14461 (not (= (point-min) 1)))
14463 (goto-char (point-min))
14464 (gnus-insert-prev-page-button)))
14465 (when (and (gnus-visual-p 'page-marker)
14466 (not (= (1- (point-max)) (buffer-size))))
14468 (goto-char (point-max))
14469 (gnus-insert-next-page-button)))))
14471 ;; Article mode commands
14473 (defun gnus-article-goto-next-page ()
14474 "Show the next page of the article."
14476 (when (gnus-article-next-page)
14477 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14479 (defun gnus-article-goto-prev-page ()
14480 "Show the next page of the article."
14482 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14483 (gnus-article-prev-page nil)))
14485 (defun gnus-article-next-page (&optional lines)
14486 "Show the next page of the current article.
14487 If end of article, return non-nil. Otherwise return nil.
14488 Argument LINES specifies lines to be scrolled up."
14490 (move-to-window-line -1)
14491 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14492 (if (save-excursion
14494 (and (pos-visible-in-window-p) ;Not continuation line.
14496 ;; Nothing in this page.
14497 (if (or (not gnus-break-pages)
14500 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14502 (gnus-narrow-to-page 1) ;Go to next page.
14504 ;; More in this page.
14508 ;; Long lines may cause an end-of-buffer error.
14509 (goto-char (point-max))))
14510 (move-to-window-line 0)
14513 (defun gnus-article-prev-page (&optional lines)
14514 "Show previous page of current article.
14515 Argument LINES specifies lines to be scrolled down."
14517 (move-to-window-line 0)
14518 (if (and gnus-break-pages
14520 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14522 (gnus-narrow-to-page -1) ;Go to previous page.
14523 (goto-char (point-max))
14527 (scroll-down lines)
14529 (move-to-window-line 0))))
14531 (defun gnus-article-refer-article ()
14532 "Read article specified by message-id around point."
14534 (let ((point (point)))
14535 (search-forward ">" nil t) ;Move point to end of "<....>".
14536 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14537 (let ((message-id (match-string 1)))
14539 (set-buffer gnus-summary-buffer)
14540 (gnus-summary-refer-article message-id))
14541 (goto-char (point))
14542 (error "No references around point"))))
14544 (defun gnus-article-show-summary ()
14545 "Reconfigure windows to show summary buffer."
14547 (gnus-configure-windows 'article)
14548 (gnus-summary-goto-subject gnus-current-article))
14550 (defun gnus-article-describe-briefly ()
14551 "Describe article mode commands briefly."
14554 (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")))
14556 (defun gnus-article-summary-command ()
14557 "Execute the last keystroke in the summary buffer."
14559 (let ((obuf (current-buffer))
14560 (owin (current-window-configuration))
14562 (switch-to-buffer gnus-summary-buffer 'norecord)
14563 (setq func (lookup-key (current-local-map) (this-command-keys)))
14564 (call-interactively func)
14566 (set-window-configuration owin)
14567 (set-window-point (get-buffer-window (current-buffer)) (point))))
14569 (defun gnus-article-summary-command-nosave ()
14570 "Execute the last keystroke in the summary buffer."
14573 (pop-to-buffer gnus-summary-buffer 'norecord)
14574 (setq func (lookup-key (current-local-map) (this-command-keys)))
14575 (call-interactively func)))
14577 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14578 "Read a summary buffer key sequence and execute it from the article buffer."
14581 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14582 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14586 (set-buffer gnus-summary-buffer)
14587 (push (or key last-command-event) unread-command-events)
14588 (setq keys (read-key-sequence nil)))
14591 (if (member keys nosaves)
14593 (pop-to-buffer gnus-summary-buffer 'norecord)
14594 (if (setq func (lookup-key (current-local-map) keys))
14595 (call-interactively func)
14597 (let ((obuf (current-buffer))
14598 (owin (current-window-configuration))
14601 (if not-restore-window
14602 (pop-to-buffer gnus-summary-buffer 'norecord)
14603 (switch-to-buffer gnus-summary-buffer 'norecord))
14604 (setq in-buffer (current-buffer))
14605 (if (setq func (lookup-key (current-local-map) keys))
14606 (call-interactively func)
14608 (when (eq in-buffer (current-buffer))
14610 (unless not-restore-window
14611 (set-window-configuration owin))
14612 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14616 ;;; Kill file handling.
14620 (defalias 'gnus-batch-kill 'gnus-batch-score)
14622 (defun gnus-batch-score ()
14623 "Run batched scoring.
14624 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14625 Newsgroups is a list of strings in Bnews format. If you want to score
14626 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14627 score the alt hierarchy, you'd say \"!alt.all\"."
14630 (gnus-newsrc-parse-options
14631 (apply (function concat)
14632 (mapcar (lambda (g) (concat g " "))
14633 command-line-args-left))))
14634 (gnus-expert-user t)
14635 (nnmail-spool-file nil)
14636 (gnus-use-dribble-file nil)
14637 (yes (car yes-and-no))
14638 (no (cdr yes-and-no))
14640 ;; Disable verbose message.
14641 gnus-novice-user gnus-large-newsgroup)
14642 ;; Eat all arguments.
14643 (setq command-line-args-left nil)
14646 ;; Apply kills to specified newsgroups in command line arguments.
14647 (setq newsrc (cdr gnus-newsrc-alist))
14649 (setq group (caar newsrc))
14650 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14651 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14653 (or (eq (car entry) t)
14654 (not (zerop (car entry)))))
14655 (if yes (string-match yes group) t)
14656 (or (null no) (not (string-match no group))))
14658 (gnus-summary-read-group group nil t nil t)
14659 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14660 (gnus-summary-exit))))
14661 (setq newsrc (cdr newsrc)))
14663 (switch-to-buffer gnus-group-buffer)
14664 (gnus-group-save-newsrc)))
14666 (defun gnus-apply-kill-file ()
14667 "Apply a kill file to the current newsgroup.
14668 Returns the number of articles marked as read."
14669 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14670 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14671 (gnus-apply-kill-file-internal)
14674 (defun gnus-kill-save-kill-buffer ()
14675 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14676 (when (get-file-buffer file)
14678 (set-buffer (get-file-buffer file))
14679 (and (buffer-modified-p) (save-buffer))
14680 (kill-buffer (current-buffer))))))
14682 (defvar gnus-kill-file-name "KILL"
14683 "Suffix of the kill files.")
14685 (defun gnus-newsgroup-kill-file (newsgroup)
14686 "Return the name of a kill file name for NEWSGROUP.
14687 If NEWSGROUP is nil, return the global kill file name instead."
14689 ;; The global KILL file is placed at top of the directory.
14690 ((or (null newsgroup)
14691 (string-equal newsgroup ""))
14692 (expand-file-name gnus-kill-file-name
14693 gnus-kill-files-directory))
14694 ;; Append ".KILL" to newsgroup name.
14695 ((gnus-use-long-file-name 'not-kill)
14696 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14697 "." gnus-kill-file-name)
14698 gnus-kill-files-directory))
14699 ;; Place "KILL" under the hierarchical directory.
14701 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14702 "/" gnus-kill-file-name)
14703 gnus-kill-files-directory))))
14710 (defvar gnus-dribble-ignore nil)
14711 (defvar gnus-dribble-eval-file nil)
14713 (defun gnus-dribble-file-name ()
14714 "Return the dribble file for the current .newsrc."
14716 (if gnus-dribble-directory
14717 (concat (file-name-as-directory gnus-dribble-directory)
14718 (file-name-nondirectory gnus-current-startup-file))
14719 gnus-current-startup-file)
14722 (defun gnus-dribble-enter (string)
14723 "Enter STRING into the dribble buffer."
14724 (if (and (not gnus-dribble-ignore)
14725 gnus-dribble-buffer
14726 (buffer-name gnus-dribble-buffer))
14727 (let ((obuf (current-buffer)))
14728 (set-buffer gnus-dribble-buffer)
14729 (insert string "\n")
14730 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14731 (set-buffer obuf))))
14733 (defun gnus-dribble-read-file ()
14734 "Read the dribble file from disk."
14735 (let ((dribble-file (gnus-dribble-file-name)))
14737 (set-buffer (setq gnus-dribble-buffer
14739 (file-name-nondirectory dribble-file))))
14740 (gnus-add-current-to-buffer-list)
14742 (setq buffer-file-name dribble-file)
14744 (buffer-disable-undo (current-buffer))
14745 (bury-buffer (current-buffer))
14746 (set-buffer-modified-p nil)
14747 (let ((auto (make-auto-save-file-name))
14748 (gnus-dribble-ignore t)
14750 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14751 ;; Load whichever file is newest -- the auto save file
14752 ;; or the "real" file.
14753 (if (file-newer-than-file-p auto dribble-file)
14754 (insert-file-contents auto)
14755 (insert-file-contents dribble-file))
14756 (unless (zerop (buffer-size))
14757 (set-buffer-modified-p t))
14758 ;; Set the file modes to reflect the .newsrc file modes.
14760 (when (and (file-exists-p gnus-current-startup-file)
14761 (setq modes (file-modes gnus-current-startup-file)))
14762 (set-file-modes dribble-file modes))
14763 ;; Possibly eval the file later.
14764 (when (gnus-y-or-n-p
14765 "Auto-save file exists. Do you want to read it? ")
14766 (setq gnus-dribble-eval-file t)))))))
14768 (defun gnus-dribble-eval-file ()
14769 (when gnus-dribble-eval-file
14770 (setq gnus-dribble-eval-file nil)
14772 (let ((gnus-dribble-ignore t))
14773 (set-buffer gnus-dribble-buffer)
14774 (eval-buffer (current-buffer))))))
14776 (defun gnus-dribble-delete-file ()
14777 (when (file-exists-p (gnus-dribble-file-name))
14778 (delete-file (gnus-dribble-file-name)))
14779 (when gnus-dribble-buffer
14781 (set-buffer gnus-dribble-buffer)
14782 (let ((auto (make-auto-save-file-name)))
14783 (if (file-exists-p auto)
14784 (delete-file auto))
14786 (set-buffer-modified-p nil)))))
14788 (defun gnus-dribble-save ()
14789 (when (and gnus-dribble-buffer
14790 (buffer-name gnus-dribble-buffer))
14792 (set-buffer gnus-dribble-buffer)
14795 (defun gnus-dribble-clear ()
14796 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14798 (set-buffer gnus-dribble-buffer)
14800 (set-buffer-modified-p nil)
14801 (setq buffer-saved-size (buffer-size)))))
14805 ;;; Server Communication
14808 (defun gnus-start-news-server (&optional confirm)
14809 "Open a method for getting news.
14810 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14812 (if gnus-current-select-method
14813 ;; Stream is already opened.
14815 ;; Open NNTP server.
14816 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14819 ;; Read server name with completion.
14820 (setq gnus-nntp-server
14821 (completing-read "NNTP server: "
14822 (mapcar (lambda (server) (list server))
14823 (cons (list gnus-nntp-server)
14824 gnus-secondary-servers))
14825 nil nil gnus-nntp-server))))
14827 (if (and gnus-nntp-server
14828 (stringp gnus-nntp-server)
14829 (not (string= gnus-nntp-server "")))
14830 (setq gnus-select-method
14831 (cond ((or (string= gnus-nntp-server "")
14832 (string= gnus-nntp-server "::"))
14833 (list 'nnspool (system-name)))
14834 ((string-match "^:" gnus-nntp-server)
14835 (list 'nnmh gnus-nntp-server
14836 (list 'nnmh-directory
14837 (file-name-as-directory
14839 (concat "~/" (substring
14840 gnus-nntp-server 1)))))
14841 (list 'nnmh-get-new-mail nil)))
14843 (list 'nntp gnus-nntp-server)))))
14845 (setq how (car gnus-select-method))
14846 (cond ((eq how 'nnspool)
14848 (gnus-message 5 "Looking up local news spool..."))
14851 (gnus-message 5 "Looking up mh spool..."))
14854 (setq gnus-current-select-method gnus-select-method)
14855 (run-hooks 'gnus-open-server-hook)
14857 ;; gnus-open-server-hook might have opened it
14858 (gnus-server-opened gnus-select-method)
14859 (gnus-open-server gnus-select-method)
14862 "%s (%s) open error: '%s'. Continue? "
14863 (car gnus-select-method) (cadr gnus-select-method)
14864 (gnus-status-message gnus-select-method)))
14865 (gnus-error 1 "Couldn't open server on %s"
14866 (nth 1 gnus-select-method))))))
14868 (defun gnus-check-group (group)
14869 "Try to make sure that the server where GROUP exists is alive."
14870 (let ((method (gnus-find-method-for-group group)))
14871 (or (gnus-server-opened method)
14872 (gnus-open-server method))))
14874 (defun gnus-check-server (&optional method silent)
14875 "Check whether the connection to METHOD is down.
14876 If METHOD is nil, use `gnus-select-method'.
14877 If it is down, start it up (again)."
14878 (let ((method (or method gnus-select-method)))
14879 ;; Transform virtual server names into select methods.
14880 (when (stringp method)
14881 (setq method (gnus-server-to-method method)))
14882 (if (gnus-server-opened method)
14883 ;; The stream is already opened.
14885 ;; Open the server.
14887 (gnus-message 5 "Opening %s server%s..." (car method)
14888 (if (equal (nth 1 method) "") ""
14889 (format " on %s" (nth 1 method)))))
14890 (run-hooks 'gnus-open-server-hook)
14892 (gnus-open-server method)
14896 (defun gnus-get-function (method function)
14897 "Return a function symbol based on METHOD and FUNCTION."
14898 ;; Translate server names into methods.
14900 (error "Attempted use of a nil select method"))
14901 (when (stringp method)
14902 (setq method (gnus-server-to-method method)))
14903 (let ((func (intern (format "%s-%s" (car method) function))))
14904 ;; If the functions isn't bound, we require the backend in
14906 (unless (fboundp func)
14907 (require (car method))
14908 (unless (fboundp func)
14909 ;; This backend doesn't implement this function.
14910 (error "No such function: %s" func)))
14915 ;;; Interface functions to the backends.
14918 (defun gnus-open-server (method)
14919 "Open a connection to METHOD."
14920 (when (stringp method)
14921 (setq method (gnus-server-to-method method)))
14922 (let ((elem (assoc method gnus-opened-servers)))
14923 ;; If this method was previously denied, we just return nil.
14924 (if (eq (nth 1 elem) 'denied)
14926 (gnus-message 1 "Denied server")
14928 ;; Open the server.
14930 (funcall (gnus-get-function method 'open-server)
14931 (nth 1 method) (nthcdr 2 method))))
14932 ;; If this hasn't been opened before, we add it to the list.
14934 (setq elem (list method nil)
14935 gnus-opened-servers (cons elem gnus-opened-servers)))
14936 ;; Set the status of this server.
14937 (setcar (cdr elem) (if result 'ok 'denied))
14938 ;; Return the result from the "open" call.
14941 (defun gnus-close-server (method)
14942 "Close the connection to METHOD."
14943 (when (stringp method)
14944 (setq method (gnus-server-to-method method)))
14945 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14947 (defun gnus-request-list (method)
14948 "Request the active file from METHOD."
14949 (when (stringp method)
14950 (setq method (gnus-server-to-method method)))
14951 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14953 (defun gnus-request-list-newsgroups (method)
14954 "Request the newsgroups file from METHOD."
14955 (when (stringp method)
14956 (setq method (gnus-server-to-method method)))
14957 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14959 (defun gnus-request-newgroups (date method)
14960 "Request all new groups since DATE from METHOD."
14961 (when (stringp method)
14962 (setq method (gnus-server-to-method method)))
14963 (funcall (gnus-get-function method 'request-newgroups)
14964 date (nth 1 method)))
14966 (defun gnus-server-opened (method)
14967 "Check whether a connection to METHOD has been opened."
14968 (when (stringp method)
14969 (setq method (gnus-server-to-method method)))
14970 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14972 (defun gnus-status-message (method)
14973 "Return the status message from METHOD.
14974 If METHOD is a string, it is interpreted as a group name. The method
14975 this group uses will be queried."
14976 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14978 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14980 (defun gnus-request-group (group &optional dont-check method)
14981 "Request GROUP. If DONT-CHECK, no information is required."
14982 (let ((method (or method (gnus-find-method-for-group group))))
14983 (when (stringp method)
14984 (setq method (gnus-server-to-method method)))
14985 (funcall (gnus-get-function method 'request-group)
14986 (gnus-group-real-name group) (nth 1 method) dont-check)))
14988 (defun gnus-request-asynchronous (group &optional articles)
14989 "Request that GROUP behave asynchronously.
14990 ARTICLES is the `data' of the group."
14991 (let ((method (gnus-find-method-for-group group)))
14992 (funcall (gnus-get-function method 'request-asynchronous)
14993 (gnus-group-real-name group) (nth 1 method) articles)))
14995 (defun gnus-list-active-group (group)
14996 "Request active information on GROUP."
14997 (let ((method (gnus-find-method-for-group group))
14998 (func 'list-active-group))
14999 (when (gnus-check-backend-function func group)
15000 (funcall (gnus-get-function method func)
15001 (gnus-group-real-name group) (nth 1 method)))))
15003 (defun gnus-request-group-description (group)
15004 "Request a description of GROUP."
15005 (let ((method (gnus-find-method-for-group group))
15006 (func 'request-group-description))
15007 (when (gnus-check-backend-function func group)
15008 (funcall (gnus-get-function method func)
15009 (gnus-group-real-name group) (nth 1 method)))))
15011 (defun gnus-close-group (group)
15012 "Request the GROUP be closed."
15013 (let ((method (gnus-find-method-for-group group)))
15014 (funcall (gnus-get-function method 'close-group)
15015 (gnus-group-real-name group) (nth 1 method))))
15017 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15018 "Request headers for ARTICLES in GROUP.
15019 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15020 (let ((method (gnus-find-method-for-group group)))
15021 (if (and gnus-use-cache (numberp (car articles)))
15022 (gnus-cache-retrieve-headers articles group fetch-old)
15023 (funcall (gnus-get-function method 'retrieve-headers)
15024 articles (gnus-group-real-name group) (nth 1 method)
15027 (defun gnus-retrieve-groups (groups method)
15028 "Request active information on GROUPS from METHOD."
15029 (when (stringp method)
15030 (setq method (gnus-server-to-method method)))
15031 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15033 (defun gnus-request-type (group &optional article)
15034 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15035 (let ((method (gnus-find-method-for-group group)))
15036 (if (not (gnus-check-backend-function 'request-type (car method)))
15038 (funcall (gnus-get-function method 'request-type)
15039 (gnus-group-real-name group) article))))
15041 (defun gnus-request-update-mark (group article mark)
15042 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15043 (let ((method (gnus-find-method-for-group group)))
15044 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15046 (funcall (gnus-get-function method 'request-update-mark)
15047 (gnus-group-real-name group) article mark))))
15049 (defun gnus-request-article (article group &optional buffer)
15050 "Request the ARTICLE in GROUP.
15051 ARTICLE can either be an article number or an article Message-ID.
15052 If BUFFER, insert the article in that group."
15053 (let ((method (gnus-find-method-for-group group)))
15054 (funcall (gnus-get-function method 'request-article)
15055 article (gnus-group-real-name group) (nth 1 method) buffer)))
15057 (defun gnus-request-head (article group)
15058 "Request the head of ARTICLE in GROUP."
15059 (let ((method (gnus-find-method-for-group group)))
15060 (funcall (gnus-get-function method 'request-head)
15061 article (gnus-group-real-name group) (nth 1 method))))
15063 (defun gnus-request-body (article group)
15064 "Request the body of ARTICLE in GROUP."
15065 (let ((method (gnus-find-method-for-group group)))
15066 (funcall (gnus-get-function method 'request-body)
15067 article (gnus-group-real-name group) (nth 1 method))))
15069 (defun gnus-request-post (method)
15070 "Post the current buffer using METHOD."
15071 (when (stringp method)
15072 (setq method (gnus-server-to-method method)))
15073 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15075 (defun gnus-request-scan (group method)
15076 "Request a SCAN being performed in GROUP from METHOD.
15077 If GROUP is nil, all groups on METHOD are scanned."
15078 (let ((method (if group (gnus-find-method-for-group group) method)))
15079 (funcall (gnus-get-function method 'request-scan)
15080 (and group (gnus-group-real-name group)) (nth 1 method))))
15082 (defsubst gnus-request-update-info (info method)
15083 "Request that METHOD update INFO."
15084 (when (stringp method)
15085 (setq method (gnus-server-to-method method)))
15086 (when (gnus-check-backend-function 'request-update-info (car method))
15087 (funcall (gnus-get-function method 'request-update-info)
15088 (gnus-group-real-name (gnus-info-group info))
15089 info (nth 1 method))))
15091 (defun gnus-request-expire-articles (articles group &optional force)
15092 (let ((method (gnus-find-method-for-group group)))
15093 (funcall (gnus-get-function method 'request-expire-articles)
15094 articles (gnus-group-real-name group) (nth 1 method)
15097 (defun gnus-request-move-article
15098 (article group server accept-function &optional last)
15099 (let ((method (gnus-find-method-for-group group)))
15100 (funcall (gnus-get-function method 'request-move-article)
15101 article (gnus-group-real-name group)
15102 (nth 1 method) accept-function last)))
15104 (defun gnus-request-accept-article (group method &optional last)
15105 ;; Make sure there's a newline at the end of the article.
15106 (when (stringp method)
15107 (setq method (gnus-server-to-method method)))
15108 (when (and (not method)
15110 (setq method (gnus-find-method-for-group group)))
15111 (goto-char (point-max))
15114 (let ((func (car (or method (gnus-find-method-for-group group)))))
15115 (funcall (intern (format "%s-request-accept-article" func))
15116 (if (stringp group) (gnus-group-real-name group) group)
15120 (defun gnus-request-replace-article (article group buffer)
15121 (let ((func (car (gnus-find-method-for-group group))))
15122 (funcall (intern (format "%s-request-replace-article" func))
15123 article (gnus-group-real-name group) buffer)))
15125 (defun gnus-request-associate-buffer (group)
15126 (let ((method (gnus-find-method-for-group group)))
15127 (funcall (gnus-get-function method 'request-associate-buffer)
15128 (gnus-group-real-name group))))
15130 (defun gnus-request-restore-buffer (article group)
15131 "Request a new buffer restored to the state of ARTICLE."
15132 (let ((method (gnus-find-method-for-group group)))
15133 (funcall (gnus-get-function method 'request-restore-buffer)
15134 article (gnus-group-real-name group) (nth 1 method))))
15136 (defun gnus-request-create-group (group &optional method)
15137 (when (stringp method)
15138 (setq method (gnus-server-to-method method)))
15139 (let ((method (or method (gnus-find-method-for-group group))))
15140 (funcall (gnus-get-function method 'request-create-group)
15141 (gnus-group-real-name group) (nth 1 method))))
15143 (defun gnus-request-delete-group (group &optional force)
15144 (let ((method (gnus-find-method-for-group group)))
15145 (funcall (gnus-get-function method 'request-delete-group)
15146 (gnus-group-real-name group) force (nth 1 method))))
15148 (defun gnus-request-rename-group (group new-name)
15149 (let ((method (gnus-find-method-for-group group)))
15150 (funcall (gnus-get-function method 'request-rename-group)
15151 (gnus-group-real-name group)
15152 (gnus-group-real-name new-name) (nth 1 method))))
15154 (defun gnus-member-of-valid (symbol group)
15155 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15156 (memq symbol (assoc
15157 (symbol-name (car (gnus-find-method-for-group group)))
15158 gnus-valid-select-methods)))
15160 (defun gnus-method-option-p (method option)
15161 "Return non-nil if select METHOD has OPTION as a parameter."
15162 (when (stringp method)
15163 (setq method (gnus-server-to-method method)))
15164 (memq option (assoc (format "%s" (car method))
15165 gnus-valid-select-methods)))
15167 (defun gnus-server-extend-method (group method)
15168 ;; This function "extends" a virtual server. If the server is
15169 ;; "hello", and the select method is ("hello" (my-var "something"))
15170 ;; in the group "alt.alt", this will result in a new virtual server
15171 ;; called "hello+alt.alt".
15173 (gnus-copy-sequence
15174 (if (equal (car method) "native") gnus-select-method
15175 (cdr (assoc (car method) gnus-server-alist))))))
15176 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15177 (nconc entry (cdr method))))
15179 (defun gnus-find-method-for-group (group &optional info)
15180 "Find the select method that GROUP uses."
15181 (or gnus-override-method
15183 gnus-select-method)
15184 (let ((info (or info (gnus-get-info group)))
15187 (not (setq method (gnus-info-method info)))
15188 (equal method "native"))
15191 (cond ((stringp method)
15192 (gnus-server-to-method method))
15193 ((stringp (car method))
15194 (gnus-server-extend-method group method))
15197 (cond ((equal (cadr method) "")
15199 ((null (cadr method))
15200 (list (car method) ""))
15202 (gnus-server-add-address method)))))))
15204 (defun gnus-check-backend-function (func group)
15205 "Check whether GROUP supports function FUNC."
15206 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15208 (fboundp (intern (format "%s-%s" method func)))))
15210 (defun gnus-methods-using (feature)
15211 "Find all methods that have FEATURE."
15212 (let ((valids gnus-valid-select-methods)
15215 (if (memq feature (car valids))
15216 (setq outs (cons (car valids) outs)))
15217 (setq valids (cdr valids)))
15222 ;;; Active & Newsrc File Handling
15225 (defun gnus-setup-news (&optional rawfile level dont-connect)
15226 "Setup news information.
15227 If RAWFILE is non-nil, the .newsrc file will also be read.
15228 If LEVEL is non-nil, the news will be set up at level LEVEL."
15229 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15232 ;; Clear some variables to re-initialize news information.
15233 (setq gnus-newsrc-alist nil
15234 gnus-active-hashtb nil)
15235 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15236 (gnus-read-newsrc-file rawfile))
15238 (when (and (not (assoc "archive" gnus-server-alist))
15239 gnus-message-archive-method)
15240 (push (cons "archive" gnus-message-archive-method)
15241 gnus-server-alist))
15243 ;; If we don't read the complete active file, we fill in the
15245 (if (or (null gnus-read-active-file)
15246 (eq gnus-read-active-file 'some))
15247 (gnus-update-active-hashtb-from-killed))
15249 ;; Read the active file and create `gnus-active-hashtb'.
15250 ;; If `gnus-read-active-file' is nil, then we just create an empty
15251 ;; hash table. The partial filling out of the hash table will be
15252 ;; done in `gnus-get-unread-articles'.
15253 (and gnus-read-active-file
15255 (gnus-read-active-file))
15257 (or gnus-active-hashtb
15258 (setq gnus-active-hashtb (make-vector 4095 0)))
15260 ;; Initialize the cache.
15261 (when gnus-use-cache
15264 ;; Possibly eval the dribble file.
15265 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15267 ;; Slave Gnusii should then clear the dribble buffer.
15268 (when (and init gnus-slave)
15269 (gnus-dribble-clear))
15271 (gnus-update-format-specifications)
15273 ;; See whether we need to read the description file.
15274 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15275 (not gnus-description-hashtb)
15277 gnus-read-active-file)
15278 (gnus-read-all-descriptions-files))
15280 ;; Find new newsgroups and treat them.
15281 (if (and init gnus-check-new-newsgroups (not level)
15282 (gnus-check-server gnus-select-method))
15283 (gnus-find-new-newsgroups))
15285 ;; We might read in new NoCeM messages here.
15286 (when (and gnus-use-nocem
15288 (not dont-connect))
15289 (gnus-nocem-scan-groups))
15291 ;; Find the number of unread articles in each non-dead group.
15292 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15293 (gnus-get-unread-articles level))
15295 (if (and init gnus-check-bogus-newsgroups
15296 gnus-read-active-file (not level)
15297 (gnus-server-opened gnus-select-method))
15298 (gnus-check-bogus-newsgroups))))
15300 (defun gnus-find-new-newsgroups (&optional arg)
15301 "Search for new newsgroups and add them.
15302 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15303 The `-n' option line from .newsrc is respected.
15304 If ARG (the prefix), use the `ask-server' method to query
15305 the server for new groups."
15307 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15308 (null gnus-read-active-file)
15309 (eq gnus-read-active-file 'some))
15310 'ask-server gnus-check-new-newsgroups)))
15311 (unless (gnus-check-first-time-used)
15312 (if (or (consp check)
15313 (eq check 'ask-server))
15314 ;; Ask the server for new groups.
15315 (gnus-ask-server-for-new-groups)
15316 ;; Go through the active hashtb and look for new groups.
15318 group new-newsgroups)
15319 (gnus-message 5 "Looking for new newsgroups...")
15320 (unless gnus-have-read-active-file
15321 (gnus-read-active-file))
15322 (setq gnus-newsrc-last-checked-date (current-time-string))
15323 (unless gnus-killed-hashtb
15324 (gnus-make-hashtable-from-killed))
15325 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15326 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15329 (if (or (null (setq group (symbol-name sym)))
15331 (null (symbol-value sym))
15332 (gnus-gethash group gnus-killed-hashtb)
15333 (gnus-gethash group gnus-newsrc-hashtb))
15335 (let ((do-sub (gnus-matches-options-n group)))
15337 ((eq do-sub 'subscribe)
15338 (setq groups (1+ groups))
15339 (gnus-sethash group group gnus-killed-hashtb)
15340 (funcall gnus-subscribe-options-newsgroup-method group))
15341 ((eq do-sub 'ignore)
15344 (setq groups (1+ groups))
15345 (gnus-sethash group group gnus-killed-hashtb)
15346 (if gnus-subscribe-hierarchical-interactive
15347 (setq new-newsgroups (cons group new-newsgroups))
15348 (funcall gnus-subscribe-newsgroup-method group)))))))
15349 gnus-active-hashtb)
15350 (when new-newsgroups
15351 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15352 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15354 (gnus-message 6 "%d new newsgroup%s arrived."
15355 groups (if (> groups 1) "s have" " has"))
15356 (gnus-message 6 "No new newsgroups.")))))))
15358 (defun gnus-matches-options-n (group)
15359 ;; Returns `subscribe' if the group is to be unconditionally
15360 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15361 ;; no match for the group.
15363 ;; First we check the two user variables.
15365 ((and gnus-options-subscribe
15366 (string-match gnus-options-subscribe group))
15368 ((and gnus-auto-subscribed-groups
15369 (string-match gnus-auto-subscribed-groups group))
15371 ((and gnus-options-not-subscribe
15372 (string-match gnus-options-not-subscribe group))
15374 ;; Then we go through the list that was retrieved from the .newsrc
15375 ;; file. This list has elements on the form
15376 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15377 ;; is in the reverse order of the options line) is returned.
15379 (let ((regs gnus-newsrc-options-n))
15381 (not (string-match (caar regs) group)))
15382 (setq regs (cdr regs)))
15383 (and regs (cdar regs))))))
15385 (defun gnus-ask-server-for-new-groups ()
15386 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15387 (methods (cons gnus-select-method
15389 (when gnus-message-archive-method
15392 (and (consp gnus-check-new-newsgroups)
15393 gnus-check-new-newsgroups)
15394 gnus-secondary-select-methods))))
15396 (new-date (current-time-string))
15397 group new-newsgroups got-new method hashtb
15398 gnus-override-subscribe-method)
15399 ;; Go through both primary and secondary select methods and
15400 ;; request new newsgroups.
15401 (while (setq method (gnus-server-get-method nil (pop methods)))
15402 (setq new-newsgroups nil)
15403 (setq gnus-override-subscribe-method method)
15404 (when (and (gnus-check-server method)
15405 (gnus-request-newgroups date method))
15408 (setq hashtb (gnus-make-hashtable 100))
15409 (set-buffer nntp-server-buffer)
15410 ;; Enter all the new groups into a hashtable.
15411 (gnus-active-to-gnus-format method hashtb 'ignore))
15412 ;; Now all new groups from `method' are in `hashtb'.
15414 (lambda (group-sym)
15415 (if (or (null (setq group (symbol-name group-sym)))
15416 (not (boundp group-sym))
15417 (null (symbol-value group-sym))
15418 (gnus-gethash group gnus-newsrc-hashtb)
15419 (member group gnus-zombie-list)
15420 (member group gnus-killed-list))
15421 ;; The group is already known.
15423 ;; Make this group active.
15424 (when (symbol-value group-sym)
15425 (gnus-set-active group (symbol-value group-sym)))
15426 ;; Check whether we want it or not.
15427 (let ((do-sub (gnus-matches-options-n group)))
15429 ((eq do-sub 'subscribe)
15431 (gnus-sethash group group gnus-killed-hashtb)
15432 (funcall gnus-subscribe-options-newsgroup-method group))
15433 ((eq do-sub 'ignore)
15437 (gnus-sethash group group gnus-killed-hashtb)
15438 (if gnus-subscribe-hierarchical-interactive
15439 (push group new-newsgroups)
15440 (funcall gnus-subscribe-newsgroup-method group)))))))
15442 (when new-newsgroups
15443 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15444 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15446 (gnus-message 6 "%d new newsgroup%s arrived."
15447 groups (if (> groups 1) "s have" " has")))
15448 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15451 (defun gnus-check-first-time-used ()
15452 (if (or (> (length gnus-newsrc-alist) 1)
15453 (file-exists-p gnus-startup-file)
15454 (file-exists-p (concat gnus-startup-file ".el"))
15455 (file-exists-p (concat gnus-startup-file ".eld")))
15457 (gnus-message 6 "First time user; subscribing you to default groups")
15458 (unless (gnus-read-active-file-p)
15459 (gnus-read-active-file))
15460 (setq gnus-newsrc-last-checked-date (current-time-string))
15461 (let ((groups gnus-default-subscribed-newsgroups)
15465 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15468 (if (null (setq group (symbol-name sym)))
15470 (let ((do-sub (gnus-matches-options-n group)))
15472 ((eq do-sub 'subscribe)
15473 (gnus-sethash group group gnus-killed-hashtb)
15474 (funcall gnus-subscribe-options-newsgroup-method group))
15475 ((eq do-sub 'ignore)
15478 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15479 gnus-active-hashtb)
15481 (if (gnus-active (car groups))
15482 (gnus-group-change-level
15483 (car groups) gnus-level-default-subscribed gnus-level-killed))
15484 (setq groups (cdr groups)))
15485 (gnus-group-make-help-group)
15486 (and gnus-novice-user
15487 (gnus-message 7 "`A k' to list killed groups"))))))
15489 (defun gnus-subscribe-group (group previous &optional method)
15490 (gnus-group-change-level
15492 (list t group gnus-level-default-subscribed nil nil method)
15494 gnus-level-default-subscribed gnus-level-killed previous t))
15496 ;; `gnus-group-change-level' is the fundamental function for changing
15497 ;; subscription levels of newsgroups. This might mean just changing
15498 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15499 ;; again, which subscribes/unsubscribes a group, which is equally
15500 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15501 ;; from 8-9 to 1-7 means that you remove the group from the list of
15502 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15503 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15504 ;; which is trivial.
15505 ;; ENTRY can either be a string (newsgroup name) or a list (if
15506 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15507 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15509 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15510 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15512 (defun gnus-group-change-level (entry level &optional oldlevel
15513 previous fromkilled)
15514 (let (group info active num)
15515 ;; Glean what info we can from the arguments
15517 (if fromkilled (setq group (nth 1 entry))
15518 (setq group (car (nth 2 entry))))
15519 (setq group entry))
15520 (if (and (stringp entry)
15522 (< oldlevel gnus-level-zombie))
15523 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15524 (if (and (not oldlevel)
15526 (setq oldlevel (gnus-info-level (nth 2 entry)))
15527 (setq oldlevel (or oldlevel 9)))
15528 (if (stringp previous)
15529 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15531 (if (and (>= oldlevel gnus-level-zombie)
15532 (gnus-gethash group gnus-newsrc-hashtb))
15533 ;; We are trying to subscribe a group that is already
15537 (or (gnus-ephemeral-group-p group)
15538 (gnus-dribble-enter
15539 (format "(gnus-group-change-level %S %S %S %S %S)"
15540 group level oldlevel (car (nth 2 previous)) fromkilled)))
15542 ;; Then we remove the newgroup from any old structures, if needed.
15543 ;; If the group was killed, we remove it from the killed or zombie
15544 ;; list. If not, and it is in fact going to be killed, we remove
15545 ;; it from the newsrc hash table and assoc.
15547 ((>= oldlevel gnus-level-zombie)
15548 (if (= oldlevel gnus-level-zombie)
15549 (setq gnus-zombie-list (delete group gnus-zombie-list))
15550 (setq gnus-killed-list (delete group gnus-killed-list))))
15552 (if (and (>= level gnus-level-zombie)
15555 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15557 (setcdr (gnus-gethash (car (nth 3 entry))
15558 gnus-newsrc-hashtb)
15560 (setcdr (cdr entry) (cdddr entry))))))
15562 ;; Finally we enter (if needed) the list where it is supposed to
15563 ;; go, and change the subscription level. If it is to be killed,
15564 ;; we enter it into the killed or zombie list.
15566 ((>= level gnus-level-zombie)
15567 ;; Remove from the hash table.
15568 (gnus-sethash group nil gnus-newsrc-hashtb)
15569 ;; We do not enter foreign groups into the list of dead
15571 (unless (gnus-group-foreign-p group)
15572 (if (= level gnus-level-zombie)
15573 (setq gnus-zombie-list (cons group gnus-zombie-list))
15574 (setq gnus-killed-list (cons group gnus-killed-list)))))
15576 ;; If the list is to be entered into the newsrc assoc, and
15577 ;; it was killed, we have to create an entry in the newsrc
15578 ;; hashtb format and fix the pointers in the newsrc assoc.
15579 (if (< oldlevel gnus-level-zombie)
15580 ;; It was alive, and it is going to stay alive, so we
15581 ;; just change the level and don't change any pointers or
15582 ;; hash table entries.
15583 (setcar (cdaddr entry) level)
15585 (setq info (cdr entry)
15587 (setq active (gnus-active group))
15589 (if active (- (1+ (cdr active)) (car active)) t))
15590 ;; Check whether the group is foreign. If so, the
15591 ;; foreign select method has to be entered into the
15593 (let ((method (or gnus-override-subscribe-method
15594 (gnus-group-method group))))
15595 (if (eq method gnus-select-method)
15596 (setq info (list group level nil))
15597 (setq info (list group level nil nil method)))))
15600 (let ((p gnus-newsrc-alist))
15604 (setq entry (cons info (cddr previous)))
15607 (setcdr (cdr previous) entry)
15608 (gnus-sethash group (cons num (cdr previous))
15609 gnus-newsrc-hashtb))
15610 (setcdr previous entry)
15611 (gnus-sethash group (cons num previous)
15612 gnus-newsrc-hashtb))
15614 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15615 (when gnus-group-change-level-function
15616 (funcall gnus-group-change-level-function group level oldlevel)))))
15618 (defun gnus-kill-newsgroup (newsgroup)
15619 "Obsolete function. Kills a newsgroup."
15620 (gnus-group-change-level
15621 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15623 (defun gnus-check-bogus-newsgroups (&optional confirm)
15624 "Remove bogus newsgroups.
15625 If CONFIRM is non-nil, the user has to confirm the deletion of every
15627 (let ((newsrc (cdr gnus-newsrc-alist))
15628 bogus group entry info)
15629 (gnus-message 5 "Checking bogus newsgroups...")
15630 (unless (gnus-read-active-file-p)
15631 (gnus-read-active-file))
15632 (when (gnus-read-active-file-p)
15633 ;; Find all bogus newsgroup that are subscribed.
15635 (setq info (pop newsrc)
15636 group (gnus-info-group info))
15637 (unless (or (gnus-active group) ; Active
15638 (gnus-info-method info) ; Foreign
15640 (not (gnus-y-or-n-p
15641 (format "Remove bogus newsgroup: %s " group)))))
15642 ;; Found a bogus newsgroup.
15643 (push group bogus)))
15644 ;; Remove all bogus subscribed groups by first killing them, and
15645 ;; then removing them from the list of killed groups.
15647 (when (setq entry (gnus-gethash (setq group (pop bogus))
15648 gnus-newsrc-hashtb))
15649 (gnus-group-change-level entry gnus-level-killed)
15650 (setq gnus-killed-list (delete group gnus-killed-list))))
15651 ;; Then we remove all bogus groups from the list of killed and
15652 ;; zombie groups. They are are removed without confirmation.
15653 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15656 (setq killed (symbol-value (car dead-lists)))
15658 (unless (gnus-active (setq group (pop killed)))
15659 ;; The group is bogus.
15660 ;; !!!Slow as hell.
15661 (set (car dead-lists)
15662 (delete group (symbol-value (car dead-lists))))))
15663 (setq dead-lists (cdr dead-lists))))
15664 (gnus-message 5 "Checking bogus newsgroups...done"))))
15666 (defun gnus-check-duplicate-killed-groups ()
15667 "Remove duplicates from the list of killed groups."
15669 (let ((killed gnus-killed-list))
15671 (gnus-message 9 "%d" (length killed))
15672 (setcdr killed (delete (car killed) (cdr killed)))
15673 (setq killed (cdr killed)))))
15675 ;; We want to inline a function from gnus-cache, so we cheat here:
15678 (require 'gnus-cache))
15680 (defun gnus-get-unread-articles-in-group (info active &optional update)
15682 ;; Allow the backend to update the info in the group.
15684 (gnus-request-update-info
15685 info (gnus-find-method-for-group (gnus-info-group info))))
15686 (gnus-activate-group (gnus-info-group info) nil t))
15687 (let* ((range (gnus-info-read info))
15689 ;; If a cache is present, we may have to alter the active info.
15690 (when (and gnus-use-cache info)
15691 (inline (gnus-cache-possibly-alter-active
15692 (gnus-info-group info) active)))
15693 ;; Modify the list of read articles according to what articles
15694 ;; are available; then tally the unread articles and add the
15695 ;; number to the group hash table entry.
15697 ((zerop (cdr active))
15700 (setq num (- (1+ (cdr active)) (car active))))
15701 ((not (listp (cdr range)))
15702 ;; Fix a single (num . num) range according to the
15703 ;; active hash table.
15704 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15705 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15706 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15707 ;; Compute number of unread articles.
15708 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15710 ;; The read list is a list of ranges. Fix them according to
15711 ;; the active hash table.
15712 ;; First peel off any elements that are below the lower
15714 (while (and (cdr range)
15716 (or (and (atom (cadr range)) (cadr range))
15718 (if (numberp (car range))
15721 (or (and (numberp (cadr range))
15724 (setcdr (car range)
15725 (or (and (numberp (nth 1 range)) (nth 1 range))
15727 (setcdr range (cddr range)))
15728 ;; Adjust the first element to be the same as the lower limit.
15729 (if (and (not (atom (car range)))
15730 (< (cdar range) (car active)))
15731 (setcdr (car range) (1- (car active))))
15732 ;; Then we want to peel off any elements that are higher
15733 ;; than the upper active limit.
15734 (let ((srange range))
15735 ;; Go past all legal elements.
15736 (while (and (cdr srange)
15737 (<= (or (and (atom (cadr srange))
15739 (caadr srange)) (cdr active)))
15740 (setq srange (cdr srange)))
15742 ;; Nuke all remaining illegal elements.
15743 (setcdr srange nil))
15745 ;; Adjust the final element.
15746 (if (and (not (atom (car srange)))
15747 (> (cdar srange) (cdr active)))
15748 (setcdr (car srange) (cdr active))))
15749 ;; Compute the number of unread articles.
15751 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15753 (or (and (atom (car range)) (car range))
15755 (setq range (cdr range)))
15756 (setq num (max 0 (- (cdr active) num)))))
15757 ;; Set the number of unread articles.
15759 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15762 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15763 ;; and compute how many unread articles there are in each group.
15764 (defun gnus-get-unread-articles (&optional level)
15765 (let* ((newsrc (cdr gnus-newsrc-alist))
15766 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15769 (cond ((and gnus-activate-foreign-newsgroups
15770 (not (numberp gnus-activate-foreign-newsgroups)))
15771 (1+ gnus-level-subscribed))
15772 ((numberp gnus-activate-foreign-newsgroups)
15773 gnus-activate-foreign-newsgroups)
15776 info group active method)
15777 (gnus-message 5 "Checking new news...")
15780 (setq active (gnus-active (setq group (gnus-info-group
15781 (setq info (pop newsrc))))))
15783 ;; Check newsgroups. If the user doesn't want to check them, or
15784 ;; they can't be checked (for instance, if the news server can't
15785 ;; be reached) we just set the number of unread articles in this
15786 ;; newsgroup to t. This means that Gnus thinks that there are
15787 ;; unread articles, but it has no idea how many.
15788 (if (and (setq method (gnus-info-method info))
15789 (not (gnus-server-equal
15791 (setq method (gnus-server-get-method nil method))))
15792 (not (gnus-secondary-method-p method)))
15793 ;; These groups are foreign. Check the level.
15794 (when (<= (gnus-info-level info) foreign-level)
15795 (setq active (gnus-activate-group group 'scan))
15796 (unless (inline (gnus-virtual-group-p group))
15797 (inline (gnus-close-group group)))
15798 (when (fboundp (intern (concat (symbol-name (car method))
15799 "-request-update-info")))
15800 (inline (gnus-request-update-info info method))))
15801 ;; These groups are native or secondary.
15802 (when (and (<= (gnus-info-level info) level)
15803 (not gnus-read-active-file))
15804 (setq active (gnus-activate-group group 'scan))
15805 (inline (gnus-close-group group))))
15807 ;; Get the number of unread articles in the group.
15809 (inline (gnus-get-unread-articles-in-group info active))
15810 ;; The group couldn't be reached, so we nix out the number of
15811 ;; unread articles and stuff.
15812 (gnus-set-active group nil)
15813 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15815 (gnus-message 5 "Checking new news...done")))
15817 ;; Create a hash table out of the newsrc alist. The `car's of the
15818 ;; alist elements are used as keys.
15819 (defun gnus-make-hashtable-from-newsrc-alist ()
15820 (let ((alist gnus-newsrc-alist)
15821 (ohashtb gnus-newsrc-hashtb)
15823 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15825 (setq prev (setq gnus-newsrc-alist
15826 (if (equal (caar gnus-newsrc-alist)
15829 (cons (list "dummy.group" 0 nil) alist)))))
15833 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15835 gnus-newsrc-hashtb)
15837 alist (cdr alist)))))
15839 (defun gnus-make-hashtable-from-killed ()
15840 "Create a hash table from the killed and zombie lists."
15841 (let ((lists '(gnus-killed-list gnus-zombie-list))
15843 (setq gnus-killed-hashtb
15844 (gnus-make-hashtable
15845 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15846 (while (setq list (pop lists))
15847 (setq list (symbol-value list))
15849 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15851 (defun gnus-activate-group (group &optional scan dont-check)
15852 ;; Check whether a group has been activated or not.
15853 ;; If SCAN, request a scan of that group as well.
15854 (let ((method (gnus-find-method-for-group group))
15856 (and (gnus-check-server method)
15857 ;; We escape all bugs and quit here to make it possible to
15858 ;; continue if a group is so out-there that it reports bugs
15862 (gnus-check-backend-function 'request-scan (car method))
15863 (gnus-request-scan group method))
15866 (gnus-request-group group dont-check)
15870 (set-buffer nntp-server-buffer)
15871 (goto-char (point-min))
15872 ;; Parse the result we got from `gnus-request-group'.
15873 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15875 (goto-char (match-beginning 1))
15877 group (setq active (cons (read (current-buffer))
15878 (read (current-buffer)))))
15879 ;; Return the new active info.
15882 (defun gnus-update-read-articles (group unread)
15883 "Update the list of read and ticked articles in GROUP using the
15884 UNREAD and TICKED lists.
15885 Note: UNSELECTED has to be sorted over `<'.
15886 Returns whether the updating was successful."
15887 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15888 (entry (gnus-gethash group gnus-newsrc-hashtb))
15889 (info (nth 2 entry))
15891 (unread (sort (copy-sequence unread) '<))
15893 (if (or (not info) (not active))
15894 ;; There is no info on this group if it was, in fact,
15895 ;; killed. Gnus stores no information on killed groups, so
15896 ;; there's nothing to be done.
15897 ;; One could store the information somewhere temporarily,
15898 ;; perhaps... Hmmm...
15900 ;; Remove any negative articles numbers.
15901 (while (and unread (< (car unread) 0))
15902 (setq unread (cdr unread)))
15903 ;; Remove any expired article numbers
15904 (while (and unread (< (car unread) (car active)))
15905 (setq unread (cdr unread)))
15906 ;; Compute the ranges of read articles by looking at the list of
15907 ;; unread articles.
15909 (if (/= (car unread) prev)
15910 (setq read (cons (if (= prev (1- (car unread))) prev
15911 (cons prev (1- (car unread)))) read)))
15912 (setq prev (1+ (car unread)))
15913 (setq unread (cdr unread)))
15914 (when (<= prev (cdr active))
15915 (setq read (cons (cons prev (cdr active)) read)))
15916 ;; Enter this list into the group info.
15917 (gnus-info-set-read
15918 info (if (> (length read) 1) (nreverse read) read))
15919 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15920 (gnus-get-unread-articles-in-group info (gnus-active group))
15923 (defun gnus-make-articles-unread (group articles)
15924 "Mark ARTICLES in GROUP as unread."
15925 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15926 (gnus-gethash (gnus-group-real-name group)
15927 gnus-newsrc-hashtb))))
15928 (ranges (gnus-info-read info))
15931 (when (gnus-member-of-range
15932 (setq article (pop articles)) ranges)
15933 (setq news (cons article news))))
15935 (gnus-info-set-read
15936 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15937 (gnus-group-update-group group t))))
15939 ;; Enter all dead groups into the hashtb.
15940 (defun gnus-update-active-hashtb-from-killed ()
15941 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15942 (lists (list gnus-killed-list gnus-zombie-list))
15945 (setq killed (car lists))
15947 (gnus-sethash (car killed) nil hashtb)
15948 (setq killed (cdr killed)))
15949 (setq lists (cdr lists)))))
15951 (defun gnus-get-killed-groups ()
15952 "Go through the active hashtb and all all unknown groups as killed."
15953 ;; First make sure active file has been read.
15954 (unless (gnus-read-active-file-p)
15955 (let ((gnus-read-active-file t))
15956 (gnus-read-active-file)))
15957 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
15958 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
15962 (group (symbol-name sym)))
15963 (if (or (null group)
15964 (gnus-gethash group gnus-killed-hashtb)
15965 (gnus-gethash group gnus-newsrc-hashtb))
15967 (let ((do-sub (gnus-matches-options-n group)))
15968 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
15970 (setq groups (1+ groups))
15971 (setq gnus-killed-list
15972 (cons group gnus-killed-list))
15973 (gnus-sethash group group gnus-killed-hashtb))))))
15974 gnus-active-hashtb))
15976 ;; Get the active file(s) from the backend(s).
15977 (defun gnus-read-active-file ()
15978 (gnus-group-set-mode-line)
15981 (if (gnus-check-server gnus-select-method)
15982 ;; The native server is available.
15983 (cons gnus-select-method gnus-secondary-select-methods)
15984 ;; The native server is down, so we just do the
15986 gnus-secondary-select-methods)
15987 ;; Also read from the archive server.
15988 (when gnus-message-archive-method
15989 (list "archive"))))
15991 (setq gnus-have-read-active-file nil)
15993 (set-buffer nntp-server-buffer)
15995 (let* ((method (if (stringp (car methods))
15996 (gnus-server-get-method nil (car methods))
15998 (where (nth 1 method))
15999 (mesg (format "Reading active file%s via %s..."
16000 (if (and where (not (zerop (length where))))
16001 (concat " from " where) "")
16003 (gnus-message 5 mesg)
16004 (when (gnus-check-server method)
16005 ;; Request that the backend scan its incoming messages.
16006 (and (gnus-check-backend-function 'request-scan (car method))
16007 (gnus-request-scan nil method))
16009 ((and (eq gnus-read-active-file 'some)
16010 (gnus-check-backend-function 'retrieve-groups (car method)))
16011 (let ((newsrc (cdr gnus-newsrc-alist))
16012 (gmethod (gnus-server-get-method nil method))
16014 (while (setq info (pop newsrc))
16015 (when (gnus-server-equal
16016 (gnus-find-method-for-group
16017 (gnus-info-group info) info)
16019 (push (gnus-group-real-name (gnus-info-group info))
16022 (gnus-check-server method)
16023 (setq list-type (gnus-retrieve-groups groups method))
16027 1.2 "Cannot read partial active file from %s server."
16029 ((eq list-type 'active)
16030 (gnus-active-to-gnus-format method gnus-active-hashtb))
16032 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16034 (if (not (gnus-request-list method))
16035 (unless (equal method gnus-message-archive-method)
16036 (gnus-error 1 "Cannot read active file from %s server."
16038 (gnus-active-to-gnus-format method gnus-active-hashtb)
16039 ;; We mark this active file as read.
16040 (push method gnus-have-read-active-file)
16041 (gnus-message 5 "%sdone" mesg))))))
16042 (setq methods (cdr methods))))))
16044 ;; Read an active file and place the results in `gnus-active-hashtb'.
16045 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16047 (setq method gnus-select-method))
16048 (let ((cur (current-buffer))
16050 (if (and gnus-active-hashtb
16051 (not (equal method gnus-select-method)))
16053 (setq gnus-active-hashtb
16054 (if (equal method gnus-select-method)
16055 (gnus-make-hashtable
16056 (count-lines (point-min) (point-max)))
16057 (gnus-make-hashtable 4096)))))))
16058 ;; Delete unnecessary lines.
16059 (goto-char (point-min))
16060 (while (search-forward "\nto." nil t)
16061 (delete-region (1+ (match-beginning 0))
16062 (progn (forward-line 1) (point))))
16063 (or (string= gnus-ignored-newsgroups "")
16065 (goto-char (point-min))
16066 (delete-matching-lines gnus-ignored-newsgroups)))
16067 ;; Make the group names readable as a lisp expression even if they
16068 ;; contain special characters.
16069 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16070 (goto-char (point-max))
16071 (while (re-search-backward "[][';?()#]" nil t)
16073 ;; If these are groups from a foreign select method, we insert the
16074 ;; group prefix in front of the group names.
16075 (and method (not (gnus-server-equal
16076 (gnus-server-get-method nil method)
16077 (gnus-server-get-method nil gnus-select-method)))
16078 (let ((prefix (gnus-group-prefixed-name "" method)))
16079 (goto-char (point-min))
16080 (while (and (not (eobp))
16081 (progn (insert prefix)
16082 (zerop (forward-line 1)))))))
16083 ;; Store the active file in a hash table.
16084 (goto-char (point-min))
16085 (if (string-match "%[oO]" gnus-group-line-format)
16086 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16087 ;; If we want information on moderated groups, we use this
16089 (let* ((mod-hashtb (make-vector 7 0))
16090 (m (intern "m" mod-hashtb))
16092 (while (not (eobp))
16093 (condition-case nil
16095 (narrow-to-region (point) (gnus-point-at-eol))
16096 (setq group (let ((obarray hashtb)) (read cur)))
16097 (if (and (numberp (setq max (read cur)))
16098 (numberp (setq min (read cur)))
16100 (skip-chars-forward " \t")
16102 (or (= (following-char) ?=)
16103 (= (following-char) ?x)
16104 (= (following-char) ?j)))))
16105 (set group (cons min max))
16107 ;; Enter moderated groups into a list.
16108 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16109 (setq gnus-moderated-list
16110 (cons (symbol-name group) gnus-moderated-list))))
16117 ;; And if we do not care about moderation, we use this loop,
16118 ;; which is faster.
16119 (let (group max min)
16120 (while (not (eobp))
16123 (narrow-to-region (point) (gnus-point-at-eol))
16124 ;; group gets set to a symbol interned in the hash table
16125 ;; (what a hack!!) - jwz
16126 (setq group (let ((obarray hashtb)) (read cur)))
16127 (if (and (numberp (setq max (read cur)))
16128 (numberp (setq min (read cur)))
16130 (skip-chars-forward " \t")
16132 (or (= (following-char) ?=)
16133 (= (following-char) ?x)
16134 (= (following-char) ?j)))))
16135 (set group (cons min max))
16143 (gnus-message 3 "Warning - illegal active: %s"
16145 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16147 (forward-line 1))))))
16149 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16150 ;; Parse a "groups" active file.
16151 (let ((cur (current-buffer))
16153 (if (and method gnus-active-hashtb)
16155 (setq gnus-active-hashtb
16156 (gnus-make-hashtable
16157 (count-lines (point-min) (point-max)))))))
16158 (prefix (and method
16159 (not (gnus-server-equal
16160 (gnus-server-get-method nil method)
16161 (gnus-server-get-method nil gnus-select-method)))
16162 (gnus-group-prefixed-name "" method))))
16164 (goto-char (point-min))
16165 ;; We split this into to separate loops, one with the prefix
16166 ;; and one without to speed the reading up somewhat.
16168 (let (min max opoint group)
16169 (while (not (eobp))
16172 (read cur) (read cur)
16173 (setq min (read cur)
16176 (skip-chars-forward " \t")
16179 (set (let ((obarray hashtb)) (read cur))
16181 (error (and group (symbolp group) (set group nil))))
16183 (let (min max group)
16184 (while (not (eobp))
16186 (if (= (following-char) ?2)
16188 (read cur) (read cur)
16189 (setq min (read cur)
16191 (set (setq group (let ((obarray hashtb)) (read cur)))
16193 (error (and group (symbolp group) (set group nil))))
16194 (forward-line 1))))))
16196 (defun gnus-read-newsrc-file (&optional force)
16197 "Read startup file.
16198 If FORCE is non-nil, the .newsrc file is read."
16199 ;; Reset variables that might be defined in the .newsrc.eld file.
16200 (let ((variables gnus-variable-list))
16202 (set (car variables) nil)
16203 (setq variables (cdr variables))))
16204 (let* ((newsrc-file gnus-current-startup-file)
16205 (quick-file (concat newsrc-file ".el")))
16207 ;; We always load the .newsrc.eld file. If always contains
16208 ;; much information that can not be gotten from the .newsrc
16209 ;; file (ticked articles, killed groups, foreign methods, etc.)
16210 (gnus-read-newsrc-el-file quick-file)
16212 (if (and (file-exists-p gnus-current-startup-file)
16214 (and (file-newer-than-file-p newsrc-file quick-file)
16215 (file-newer-than-file-p newsrc-file
16216 (concat quick-file "d")))
16217 (not gnus-newsrc-alist)))
16218 ;; We read the .newsrc file. Note that if there if a
16219 ;; .newsrc.eld file exists, it has already been read, and
16220 ;; the `gnus-newsrc-hashtb' has been created. While reading
16221 ;; the .newsrc file, Gnus will only use the information it
16222 ;; can find there for changing the data already read -
16223 ;; ie. reading the .newsrc file will not trash the data
16224 ;; already read (except for read articles).
16226 (gnus-message 5 "Reading %s..." newsrc-file)
16227 (set-buffer (find-file-noselect newsrc-file))
16228 (buffer-disable-undo (current-buffer))
16229 (gnus-newsrc-to-gnus-format)
16230 (kill-buffer (current-buffer))
16231 (gnus-message 5 "Reading %s...done" newsrc-file)))
16233 ;; Read any slave files.
16235 (gnus-master-read-slave-newsrc))
16237 ;; Convert old to new.
16238 (gnus-convert-old-newsrc))))
16240 (defun gnus-continuum-version (version)
16241 "Return VERSION as a floating point number."
16242 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16243 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16244 (number (match-string 2 version))
16246 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16247 (setq major (string-to-number (match-string 1 number)))
16248 (setq minor (string-to-number (match-string 2 number)))
16249 (setq least (if (match-beginning 3)
16250 (string-to-number (match-string 3 number))
16254 (format "%s00%02d%02d"
16256 ((string= alpha "(ding)") "4.99")
16257 ((string= alpha "September") "5.01")
16258 ((string= alpha "Red") "5.03"))
16260 (format "%d.%02d%20d" major minor least))))))
16262 (defun gnus-convert-old-newsrc ()
16263 "Convert old newsrc into the new format, if needed."
16264 (let ((fcv (and gnus-newsrc-file-version
16265 (gnus-continuum-version gnus-newsrc-file-version))))
16267 ;; No .newsrc.eld file was loaded.
16269 ;; Gnus 5 .newsrc.eld was loaded.
16270 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16271 (gnus-convert-old-ticks)))))
16273 (defun gnus-convert-old-ticks ()
16274 (let ((newsrc (cdr gnus-newsrc-alist))
16275 marks info dormant ticked)
16276 (while (setq info (pop newsrc))
16277 (when (setq marks (gnus-info-marks info))
16278 (setq dormant (cdr (assq 'dormant marks))
16279 ticked (cdr (assq 'tick marks)))
16280 (when (or dormant ticked)
16281 (gnus-info-set-read
16284 (gnus-info-read info)
16285 (nconc (gnus-uncompress-range dormant)
16286 (gnus-uncompress-range ticked)))))))))
16288 (defun gnus-read-newsrc-el-file (file)
16289 (let ((ding-file (concat file "d")))
16290 ;; We always, always read the .eld file.
16291 (gnus-message 5 "Reading %s..." ding-file)
16292 (let (gnus-newsrc-assoc)
16293 (condition-case nil
16294 (load ding-file t t t)
16296 (gnus-error 1 "Error in %s" ding-file)))
16297 (when gnus-newsrc-assoc
16298 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16299 (gnus-make-hashtable-from-newsrc-alist)
16300 (when (file-newer-than-file-p file ding-file)
16301 ;; Old format quick file
16302 (gnus-message 5 "Reading %s..." file)
16303 ;; The .el file is newer than the .eld file, so we read that one
16305 (gnus-read-old-newsrc-el-file file))))
16307 ;; Parse the old-style quick startup file
16308 (defun gnus-read-old-newsrc-el-file (file)
16309 (let (newsrc killed marked group m info)
16311 (let ((gnus-killed-assoc nil)
16312 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16314 (condition-case nil
16317 (setq newsrc gnus-newsrc-assoc
16318 killed gnus-killed-assoc
16319 marked gnus-marked-assoc)))
16320 (setq gnus-newsrc-alist nil)
16321 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16324 (gnus-info-set-read info (cddr group))
16325 (gnus-info-set-level
16326 info (if (nth 1 group) gnus-level-default-subscribed
16327 gnus-level-default-unsubscribed))
16328 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16331 (if (nth 1 group) gnus-level-default-subscribed
16332 gnus-level-default-unsubscribed)
16334 gnus-newsrc-alist))
16335 ;; Copy marks into info.
16336 (when (setq m (assoc (car group) marked))
16337 (unless (nthcdr 3 info)
16338 (nconc info (list nil)))
16339 (gnus-info-set-marks
16340 info (list (cons 'tick (gnus-compress-sequence
16341 (sort (cdr m) '<) t))))))
16342 (setq newsrc killed)
16344 (setcar newsrc (caar newsrc))
16345 (setq newsrc (cdr newsrc)))
16346 (setq gnus-killed-list killed))
16347 ;; The .el file version of this variable does not begin with
16348 ;; "options", while the .eld version does, so we just add it if it
16351 gnus-newsrc-options
16353 (and (not (string-match "^ *options" gnus-newsrc-options))
16354 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16355 (and (not (string-match "\n$" gnus-newsrc-options))
16356 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16357 ;; Finally, if we read some options lines, we parse them.
16358 (or (string= gnus-newsrc-options "")
16359 (gnus-newsrc-parse-options gnus-newsrc-options))))
16361 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16362 (gnus-make-hashtable-from-newsrc-alist)))
16364 (defun gnus-make-newsrc-file (file)
16365 "Make server dependent file name by catenating FILE and server host name."
16366 (let* ((file (expand-file-name file nil))
16367 (real-file (concat file "-" (nth 1 gnus-select-method))))
16368 (if (or (file-exists-p real-file)
16369 (file-exists-p (concat real-file ".el"))
16370 (file-exists-p (concat real-file ".eld")))
16373 (defun gnus-newsrc-to-gnus-format ()
16374 (setq gnus-newsrc-options "")
16375 (setq gnus-newsrc-options-n nil)
16377 (or gnus-active-hashtb
16378 (setq gnus-active-hashtb (make-vector 4095 0)))
16379 (let ((buf (current-buffer))
16380 (already-read (> (length gnus-newsrc-alist) 1))
16381 group subscribed options-symbol newsrc Options-symbol
16383 (goto-char (point-min))
16384 ;; We intern the symbol `options' in the active hashtb so that we
16385 ;; can `eq' against it later.
16386 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16387 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16389 (while (not (eobp))
16390 ;; We first read the first word on the line by narrowing and
16391 ;; then reading into `gnus-active-hashtb'. Most groups will
16392 ;; already exist in that hashtb, so this will save some string
16396 (progn (skip-chars-forward "^ \t!:\n") (point)))
16397 (goto-char (point-min))
16399 (and (/= (point-min) (point-max))
16400 (let ((obarray gnus-active-hashtb)) (read buf))))
16402 ;; Now, the symbol we have read is either `options' or a group
16403 ;; name. If it is an options line, we just add it to a string.
16405 ((or (eq symbol options-symbol)
16406 (eq symbol Options-symbol))
16407 (setq gnus-newsrc-options
16408 ;; This concating is quite inefficient, but since our
16409 ;; thorough studies show that approx 99.37% of all
16410 ;; .newsrc files only contain a single options line, we
16411 ;; don't give a damn, frankly, my dear.
16412 (concat gnus-newsrc-options
16414 (gnus-point-at-bol)
16415 ;; Options may continue on the next line.
16416 (or (and (re-search-forward "^[^ \t]" nil 'move)
16417 (progn (beginning-of-line) (point)))
16421 ;; Group names can be just numbers.
16422 (when (numberp symbol)
16423 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16424 (or (boundp symbol) (set symbol nil))
16425 ;; It was a group name.
16426 (setq subscribed (= (following-char) ?:)
16427 group (symbol-name symbol)
16430 ;; If the line ends here, this is clearly a buggy line, so
16431 ;; we put point a the beginning of line and let the cond
16432 ;; below do the error handling.
16433 (beginning-of-line)
16434 ;; We skip to the beginning of the ranges.
16435 (skip-chars-forward "!: \t"))
16436 ;; We are now at the beginning of the list of read articles.
16437 ;; We read them range by range.
16440 ((looking-at "[0-9]+")
16441 ;; We narrow and read a number instead of buffer-substring/
16442 ;; string-to-int because it's faster. narrow/widen is
16443 ;; faster than save-restriction/narrow, and save-restriction
16444 ;; produces a garbage object.
16446 (narrow-to-region (match-beginning 0) (match-end 0))
16449 ;; If the next character is a dash, then this is a range.
16450 (if (= (following-char) ?-)
16452 ;; We read the upper bound of the range.
16454 (if (not (looking-at "[0-9]+"))
16455 ;; This is a buggy line, by we pretend that
16456 ;; it's kinda OK. Perhaps the user should be
16458 (setq reads (cons num1 reads))
16463 (narrow-to-region (match-beginning 0)
16468 ;; It was just a simple number, so we add it to the
16470 (setq reads (cons num1 reads)))
16471 ;; If the next char in ?\n, then we have reached the end
16472 ;; of the line and return nil.
16473 (/= (following-char) ?\n))
16474 ((= (following-char) ?\n)
16475 ;; End of line, so we end.
16478 ;; Not numbers and not eol, so this might be a buggy
16481 ;; If it was eob instead of ?\n, we allow it.
16483 ;; The line was buggy.
16485 (gnus-error 3.1 "Mangled line: %s"
16486 (buffer-substring (gnus-point-at-bol)
16487 (gnus-point-at-eol)))))
16489 ;; Skip past ", ". Spaces are illegal in these ranges, but
16490 ;; we allow them, because it's a common mistake to put a
16491 ;; space after the comma.
16492 (skip-chars-forward ", "))
16494 ;; We have already read .newsrc.eld, so we gently update the
16495 ;; data in the hash table with the information we have just
16498 (let ((info (gnus-get-info group))
16501 ;; There is an entry for this file in the alist.
16503 (gnus-info-set-read info (nreverse reads))
16504 ;; We update the level very gently. In fact, we
16505 ;; only change it if there's been a status change
16506 ;; from subscribed to unsubscribed, or vice versa.
16507 (setq level (gnus-info-level info))
16508 (cond ((and (<= level gnus-level-subscribed)
16510 (setq level (if reads
16511 gnus-level-default-unsubscribed
16512 (1+ gnus-level-default-unsubscribed))))
16513 ((and (> level gnus-level-subscribed) subscribed)
16514 (setq level gnus-level-default-subscribed)))
16515 (gnus-info-set-level info level))
16516 ;; This is a new group.
16517 (setq info (list group
16519 gnus-level-default-subscribed
16521 (1+ gnus-level-subscribed)
16522 gnus-level-default-unsubscribed))
16523 (nreverse reads))))
16524 (setq newsrc (cons info newsrc))))))
16527 (setq newsrc (nreverse newsrc))
16529 (if (not already-read)
16531 ;; We now have two newsrc lists - `newsrc', which is what we
16532 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16533 ;; what we've read from .newsrc.eld. We have to merge these
16534 ;; lists. We do this by "attaching" any (foreign) groups in the
16535 ;; gnus-newsrc-alist to the (native) group that precedes them.
16536 (let ((rc (cdr gnus-newsrc-alist))
16537 (prev gnus-newsrc-alist)
16540 (or (null (nth 4 (car rc))) ; It's a native group.
16541 (assoc (caar rc) newsrc) ; It's already in the alist.
16542 (if (setq entry (assoc (caar prev) newsrc))
16543 (setcdr (setq mentry (memq entry newsrc))
16544 (cons (car rc) (cdr mentry)))
16545 (setq newsrc (cons (car rc) newsrc))))
16549 (setq gnus-newsrc-alist newsrc)
16550 ;; We make the newsrc hashtb.
16551 (gnus-make-hashtable-from-newsrc-alist)
16553 ;; Finally, if we read some options lines, we parse them.
16554 (or (string= gnus-newsrc-options "")
16555 (gnus-newsrc-parse-options gnus-newsrc-options))))
16557 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16558 ;; The return value will be a list on the form
16559 ;; ((regexp1 . ignore)
16560 ;; (regexp2 . subscribe)...)
16561 ;; When handling new newsgroups, groups that match a `ignore' regexp
16562 ;; will be ignored, and groups that match a `subscribe' regexp will be
16563 ;; subscribed. A line like
16564 ;; options -n !all rec.all
16565 ;; will lead to a list that looks like
16566 ;; (("^rec\\..+" . subscribe)
16567 ;; ("^.+" . ignore))
16568 ;; So all "rec.*" groups will be subscribed, while all the other
16569 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16570 ;; different from "options -n rec.all !all".
16571 (defun gnus-newsrc-parse-options (options)
16574 (gnus-set-work-buffer)
16575 (insert (regexp-quote options))
16576 ;; First we treat all continuation lines.
16577 (goto-char (point-min))
16578 (while (re-search-forward "\n[ \t]+" nil t)
16579 (replace-match " " t t))
16580 ;; Then we transform all "all"s into ".+"s.
16581 (goto-char (point-min))
16582 (while (re-search-forward "\\ball\\b" nil t)
16583 (replace-match ".+" t t))
16584 (goto-char (point-min))
16585 ;; We remove all other options than the "-n" ones.
16586 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16587 (replace-match " ")
16589 (goto-char (point-min))
16591 ;; We are only interested in "options -n" lines - we
16592 ;; ignore the other option lines.
16593 (while (re-search-forward "[ \t]-n" nil t)
16595 (or (save-excursion
16596 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16598 (gnus-point-at-eol)))
16599 ;; Search for all "words"...
16600 (while (re-search-forward "[^ \t,\n]+" eol t)
16601 (if (= (char-after (match-beginning 0)) ?!)
16602 ;; If the word begins with a bang (!), this is a "not"
16603 ;; spec. We put this spec (minus the bang) and the
16604 ;; symbol `ignore' into the list.
16605 (setq out (cons (cons (concat
16606 "^" (buffer-substring
16607 (1+ (match-beginning 0))
16610 ;; There was no bang, so this is a "yes" spec.
16611 (setq out (cons (cons (concat "^" (match-string 0))
16612 'subscribe) out)))))
16614 (setq gnus-newsrc-options-n out))))
16616 (defun gnus-save-newsrc-file (&optional force)
16617 "Save .newsrc file."
16618 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16619 ;; from the variable gnus-newsrc-alist.
16620 (when (and (or gnus-newsrc-alist gnus-killed-list)
16621 gnus-current-startup-file)
16623 (if (and (or gnus-use-dribble-file gnus-slave)
16625 (or (not gnus-dribble-buffer)
16626 (not (buffer-name gnus-dribble-buffer))
16627 (zerop (save-excursion
16628 (set-buffer gnus-dribble-buffer)
16630 (gnus-message 4 "(No changes need to be saved)")
16631 (run-hooks 'gnus-save-newsrc-hook)
16633 (gnus-slave-save-newsrc)
16635 (when gnus-save-newsrc-file
16636 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16637 (gnus-gnus-to-newsrc-format)
16638 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16639 ;; Save .newsrc.eld.
16640 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16641 (make-local-variable 'version-control)
16642 (setq version-control 'never)
16643 (setq buffer-file-name
16644 (concat gnus-current-startup-file ".eld"))
16645 (gnus-add-current-to-buffer-list)
16646 (buffer-disable-undo (current-buffer))
16648 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16649 (gnus-gnus-to-quick-newsrc-format)
16650 (run-hooks 'gnus-save-quick-newsrc-hook)
16652 (kill-buffer (current-buffer))
16654 5 "Saving %s.eld...done" gnus-current-startup-file))
16655 (gnus-dribble-delete-file)
16656 (gnus-group-set-mode-line)))))
16658 (defun gnus-gnus-to-quick-newsrc-format ()
16659 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16660 (insert ";; Gnus startup file.\n")
16661 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16662 (insert ";; to read .newsrc.\n")
16663 (insert "(setq gnus-newsrc-file-version "
16664 (prin1-to-string gnus-version) ")\n")
16666 (if gnus-save-killed-list gnus-variable-list
16667 ;; Remove the `gnus-killed-list' from the list of variables
16668 ;; to be saved, if required.
16669 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16670 ;; Peel off the "dummy" group.
16671 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16673 ;; Insert the variables into the file.
16675 (when (and (boundp (setq variable (pop variables)))
16676 (symbol-value variable))
16677 (insert "(setq " (symbol-name variable) " '")
16678 (prin1 (symbol-value variable) (current-buffer))
16681 (defun gnus-gnus-to-newsrc-format ()
16682 ;; Generate and save the .newsrc file.
16684 (set-buffer (create-file-buffer gnus-current-startup-file))
16685 (let ((newsrc (cdr gnus-newsrc-alist))
16686 (standard-output (current-buffer))
16687 info ranges range method)
16688 (setq buffer-file-name gnus-current-startup-file)
16689 (buffer-disable-undo (current-buffer))
16692 (if gnus-newsrc-options (insert gnus-newsrc-options))
16693 ;; Write subscribed and unsubscribed.
16694 (while (setq info (pop newsrc))
16695 ;; Don't write foreign groups to .newsrc.
16696 (when (or (null (setq method (gnus-info-method info)))
16697 (equal method "native")
16698 (gnus-server-equal method gnus-select-method))
16699 (insert (gnus-info-group info)
16700 (if (> (gnus-info-level info) gnus-level-subscribed)
16702 (when (setq ranges (gnus-info-read info))
16704 (if (not (listp (cdr ranges)))
16705 (if (= (car ranges) (cdr ranges))
16706 (princ (car ranges))
16707 (princ (car ranges))
16709 (princ (cdr ranges)))
16710 (while (setq range (pop ranges))
16711 (if (or (atom range) (= (car range) (cdr range)))
16712 (princ (or (and (atom range) range) (car range)))
16713 (princ (car range))
16715 (princ (cdr range)))
16716 (if ranges (insert ",")))))
16718 (make-local-variable 'version-control)
16719 (setq version-control 'never)
16720 ;; It has been reported that sometime the modtime on the .newsrc
16721 ;; file seems to be off. We really do want to overwrite it, so
16722 ;; we clear the modtime here before saving. It's a bit odd,
16724 ;; sometimes the modtime clear isn't sufficient. most brute force:
16725 ;; delete the silly thing entirely first. but this fails to provide
16726 ;; such niceties as .newsrc~ creation.
16727 (if gnus-modtime-botch
16728 (delete-file gnus-startup-file)
16729 (clear-visited-file-modtime))
16730 (run-hooks 'gnus-save-standard-newsrc-hook)
16732 (kill-buffer (current-buffer)))))
16736 ;;; Slave functions.
16739 (defun gnus-slave-save-newsrc ()
16741 (set-buffer gnus-dribble-buffer)
16743 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16744 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16746 (defun gnus-master-read-slave-newsrc ()
16749 (file-name-directory gnus-current-startup-file)
16753 (file-name-nondirectory gnus-current-startup-file)
16757 (if (not slave-files)
16758 () ; There are no slave files to read.
16759 (gnus-message 7 "Reading slave newsrcs...")
16761 (set-buffer (get-buffer-create " *gnus slave*"))
16762 (buffer-disable-undo (current-buffer))
16764 (sort (mapcar (lambda (file)
16765 (list (nth 5 (file-attributes file)) file))
16768 (or (< (caar f1) (caar f2))
16769 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16772 (setq file (nth 1 (car slave-files)))
16773 (insert-file-contents file)
16774 (if (condition-case ()
16776 (eval-buffer (current-buffer))
16779 (gnus-error 3.2 "Possible error in %s" file)
16781 (or gnus-slave ; Slaves shouldn't delete these files.
16785 (setq slave-files (cdr slave-files))))
16786 (gnus-message 7 "Reading slave newsrcs...done"))))
16790 ;;; Group description.
16793 (defun gnus-read-all-descriptions-files ()
16794 (let ((methods (cons gnus-select-method
16796 (when gnus-message-archive-method
16798 gnus-secondary-select-methods))))
16800 (gnus-read-descriptions-file (car methods))
16801 (setq methods (cdr methods)))
16804 (defun gnus-read-descriptions-file (&optional method)
16805 (let ((method (or method gnus-select-method)))
16806 (when (stringp method)
16807 (setq method (gnus-server-to-method method)))
16808 ;; We create the hashtable whether we manage to read the desc file
16809 ;; to avoid trying to re-read after a failed read.
16810 (or gnus-description-hashtb
16811 (setq gnus-description-hashtb
16812 (gnus-make-hashtable (length gnus-active-hashtb))))
16813 ;; Mark this method's desc file as read.
16814 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16815 gnus-description-hashtb)
16817 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16819 ((not (gnus-check-server method))
16820 (gnus-message 1 "Couldn't open server")
16822 ((not (gnus-request-list-newsgroups method))
16823 (gnus-message 1 "Couldn't read newsgroups descriptions")
16829 (set-buffer nntp-server-buffer)
16830 (goto-char (point-min))
16831 (if (or (search-forward "\n.\n" nil t)
16832 (goto-char (point-max)))
16834 (beginning-of-line)
16835 (narrow-to-region (point-min) (point))))
16836 (goto-char (point-min))
16837 (while (not (eobp))
16838 ;; If we get an error, we set group to 0, which is not a
16842 (let ((obarray gnus-description-hashtb))
16843 ;; Group is set to a symbol interned in this
16845 (read nntp-server-buffer))
16847 (skip-chars-forward " \t")
16848 ;; ... which leads to this line being effectively ignored.
16849 (and (symbolp group)
16850 (set group (buffer-substring
16851 (point) (progn (end-of-line) (point)))))
16852 (forward-line 1))))
16853 (gnus-message 5 "Reading descriptions file...done")
16856 (defun gnus-group-get-description (group)
16857 "Get the description of a group by sending XGTITLE to the server."
16858 (when (gnus-request-group-description group)
16860 (set-buffer nntp-server-buffer)
16861 (goto-char (point-min))
16862 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16863 (match-string 1)))))
16867 ;;; Buffering of read articles.
16870 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16871 (defvar gnus-backlog-articles nil)
16872 (defvar gnus-backlog-hashtb nil)
16874 (defun gnus-backlog-buffer ()
16875 "Return the backlog buffer."
16876 (or (get-buffer gnus-backlog-buffer)
16878 (set-buffer (get-buffer-create gnus-backlog-buffer))
16879 (buffer-disable-undo (current-buffer))
16880 (setq buffer-read-only t)
16881 (gnus-add-current-to-buffer-list)
16882 (get-buffer gnus-backlog-buffer))))
16884 (defun gnus-backlog-setup ()
16885 "Initialize backlog variables."
16886 (unless gnus-backlog-hashtb
16887 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16889 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16891 (defun gnus-backlog-shutdown ()
16892 "Clear all backlog variables and buffers."
16893 (when (get-buffer gnus-backlog-buffer)
16894 (kill-buffer gnus-backlog-buffer))
16895 (setq gnus-backlog-hashtb nil
16896 gnus-backlog-articles nil))
16898 (defun gnus-backlog-enter-article (group number buffer)
16899 (gnus-backlog-setup)
16900 (let ((ident (intern (concat group ":" (int-to-string number))
16901 gnus-backlog-hashtb))
16903 (if (memq ident gnus-backlog-articles)
16904 () ; It's already kept.
16905 ;; Remove the oldest article, if necessary.
16906 (and (numberp gnus-keep-backlog)
16907 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16908 (gnus-backlog-remove-oldest-article))
16909 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16910 ;; Insert the new article.
16912 (set-buffer (gnus-backlog-buffer))
16913 (let (buffer-read-only)
16914 (goto-char (point-max))
16915 (or (bolp) (insert "\n"))
16917 (insert-buffer-substring buffer)
16918 ;; Tag the beginning of the article with the ident.
16919 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
16921 (defun gnus-backlog-remove-oldest-article ()
16923 (set-buffer (gnus-backlog-buffer))
16924 (goto-char (point-min))
16925 (if (zerop (buffer-size))
16926 () ; The buffer is empty.
16927 (let ((ident (get-text-property (point) 'gnus-backlog))
16929 ;; Remove the ident from the list of articles.
16931 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16932 ;; Delete the article itself.
16934 (point) (next-single-property-change
16935 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16937 (defun gnus-backlog-remove-article (group number)
16938 "Remove article NUMBER in GROUP from the backlog."
16939 (when (numberp number)
16940 (gnus-backlog-setup)
16941 (let ((ident (intern (concat group ":" (int-to-string number))
16942 gnus-backlog-hashtb))
16944 (when (memq ident gnus-backlog-articles)
16945 ;; It was in the backlog.
16947 (set-buffer (gnus-backlog-buffer))
16948 (let (buffer-read-only)
16949 (when (setq beg (text-property-any
16950 (point-min) (point-max) 'gnus-backlog
16952 ;; Find the end (i. e., the beginning of the next article).
16954 (next-single-property-change
16955 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
16956 (delete-region beg end)
16960 (defun gnus-backlog-request-article (group number buffer)
16961 (when (numberp number)
16962 (gnus-backlog-setup)
16963 (let ((ident (intern (concat group ":" (int-to-string number))
16964 gnus-backlog-hashtb))
16966 (when (memq ident gnus-backlog-articles)
16967 ;; It was in the backlog.
16969 (set-buffer (gnus-backlog-buffer))
16970 (if (not (setq beg (text-property-any
16971 (point-min) (point-max) 'gnus-backlog
16973 ;; It wasn't in the backlog after all.
16975 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16976 ;; Find the end (i. e., the beginning of the next article).
16978 (next-single-property-change
16979 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16980 (let ((buffer-read-only nil))
16982 (insert-buffer-substring gnus-backlog-buffer beg end)
16985 ;; Allow redefinition of Gnus functions.
16987 (gnus-ems-redefine)
16991 ;;; gnus.el ends here