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 ;; Site dependent variables. These variables should be defined in
41 (defvar gnus-default-nntp-server nil
42 "Specify a default NNTP server.
43 This variable should be defined in paths.el, and should never be set
45 If you want to change servers, you should use `gnus-select-method'.
46 See the documentation to that variable.")
48 (defvar gnus-backup-default-subscribed-newsgroups
49 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
50 "Default default new newsgroups the first time Gnus is run.
51 Should be set in paths.el, and shouldn't be touched by the user.")
53 (defvar gnus-local-domain nil
54 "Local domain name without a host name.
55 The DOMAINNAME environment variable is used instead if it is defined.
56 If the `system-name' function returns the full Internet name, there is
57 no need to set this variable.")
59 (defvar gnus-local-organization nil
60 "String with a description of what organization (if any) the user belongs to.
61 The ORGANIZATION environment variable is used instead if it is defined.
62 If this variable contains a function, this function will be called
63 with the current newsgroup name as the argument. The function should
66 In any case, if the string (either in the variable, in the environment
67 variable, or returned by the function) is a file name, the contents of
68 this file will be used as the organization.")
70 ;; Customization variables
72 ;; Don't touch this variable.
73 (defvar gnus-nntp-service "nntp"
74 "*NNTP service name (\"nntp\" or 119).
75 This is an obsolete variable, which is scarcely used. If you use an
76 nntp server for your newsgroup and want to change the port number
77 used to 899, you would say something along these lines:
79 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
81 (defvar gnus-nntpserver-file "/etc/nntpserver"
82 "*A file with only the name of the nntp server in it.")
84 ;; This function is used to check both the environment variable
85 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
86 ;; an nntp server name default.
87 (defun gnus-getenv-nntpserver ()
88 (or (getenv "NNTPSERVER")
89 (and (file-readable-p gnus-nntpserver-file)
91 (set-buffer (get-buffer-create " *gnus nntp*"))
92 (buffer-disable-undo (current-buffer))
93 (insert-file-contents gnus-nntpserver-file)
94 (let ((name (buffer-string)))
96 (if (string-match "^[ \t\n]*$" name)
99 (kill-buffer (current-buffer))))))))
101 (defvar gnus-select-method
103 (list 'nntp (or (condition-case ()
104 (gnus-getenv-nntpserver)
106 (if (and gnus-default-nntp-server
107 (not (string= gnus-default-nntp-server "")))
108 gnus-default-nntp-server)
110 (if (or (null gnus-nntp-service)
111 (equal gnus-nntp-service "nntp"))
113 (list gnus-nntp-service)))
114 "*Default method for selecting a newsgroup.
115 This variable should be a list, where the first element is how the
116 news is to be fetched, the second is the address.
118 For instance, if you want to get your news via NNTP from
119 \"flab.flab.edu\", you could say:
121 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
123 If you want to use your local spool, say:
125 (setq gnus-select-method (list 'nnspool (system-name)))
127 If you use this variable, you must set `gnus-nntp-server' to nil.
129 There is a lot more to know about select methods and virtual servers -
130 see the manual for details.")
132 (defvar gnus-message-archive-method
133 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
134 (nnfolder-active-file "~/Mail/archive/active")
135 (nnfolder-get-new-mail nil)
136 (nnfolder-inhibit-expiry t))
137 "*Method used for archiving messages you've sent.
138 This should be a mail method.")
140 (defvar gnus-refer-article-method nil
141 "*Preferred method for fetching an article by Message-ID.
142 If you are reading news from the local spool (with nnspool), fetching
143 articles by Message-ID is painfully slow. By setting this method to an
144 nntp method, you might get acceptable results.
146 The value of this variable must be a valid select method as discussed
147 in the documentation of `gnus-select-method'.")
149 (defvar gnus-secondary-select-methods nil
150 "*A list of secondary methods that will be used for reading news.
151 This is a list where each element is a complete select method (see
152 `gnus-select-method').
154 If, for instance, you want to read your mail with the nnml backend,
155 you could set this variable:
157 (setq gnus-secondary-select-methods '((nnml \"\")))")
159 (defvar gnus-secondary-servers nil
160 "*List of NNTP servers that the user can choose between interactively.
161 To make Gnus query you for a server, you have to give `gnus' a
162 non-numeric prefix - `C-u M-x gnus', in short.")
164 (defvar gnus-nntp-server nil
165 "*The name of the host running the NNTP server.
166 This variable is semi-obsolete. Use the `gnus-select-method'
169 (defvar gnus-startup-file "~/.newsrc"
170 "*Your `.newsrc' file.
171 `.newsrc-SERVER' will be used instead if that exists.")
173 (defvar gnus-init-file "~/.gnus"
174 "*Your Gnus elisp startup file.
175 If a file with the .el or .elc suffixes exist, it will be read
178 (defvar gnus-group-faq-directory
179 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
180 "/ftp@sunsite.auc.dk:/pub/usenet/"
181 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
182 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
183 "/ftp@rtfm.mit.edu:/pub/usenet/"
184 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
185 "/ftp@ftp.sunet.se:/pub/usenet/"
186 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
187 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
188 "/ftp@ftp.hk.super.net:/mirror/faqs/")
189 "*Directory where the group FAQs are stored.
190 This will most commonly be on a remote machine, and the file will be
193 This variable can also be a list of directories. In that case, the
194 first element in the list will be used by default, and the others will
195 be used as backup sites.
197 Note that Gnus uses an aol machine as the default directory. If this
198 feels fundamentally unclean, just think of it as a way to finally get
199 something of value back from them.
201 If the default site is too slow, try one of these:
203 North America: mirrors.aol.com /pub/rtfm/usenet
204 ftp.seas.gwu.edu /pub/rtfm
205 rtfm.mit.edu /pub/usenet
206 Europe: ftp.uni-paderborn.de /pub/FAQ
207 src.doc.ic.ac.uk /usenet/news-FAQS
208 ftp.sunet.se /pub/usenet
209 sunsite.auc.dk /pub/usenet
210 Asia: nctuccca.edu.tw /USENET/FAQ
211 hwarang.postech.ac.kr /pub/usenet
212 ftp.hk.super.net /mirror/faqs")
214 (defvar gnus-group-archive-directory
215 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
216 "*The address of the (ding) archives.")
218 (defvar gnus-group-recent-archive-directory
219 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
220 "*The address of the most recent (ding) articles.")
222 (defvar gnus-default-subscribed-newsgroups nil
223 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
224 It should be a list of strings.
225 If it is `t', Gnus will not do anything special the first time it is
226 started; it'll just use the normal newsgroups subscription methods.")
228 (defvar gnus-use-cross-reference t
229 "*Non-nil means that cross referenced articles will be marked as read.
230 If nil, ignore cross references. If t, mark articles as read in
231 subscribed newsgroups. If neither t nor nil, mark as read in all
234 (defvar gnus-single-article-buffer t
235 "*If non-nil, display all articles in the same buffer.
236 If nil, each group will get its own article buffer.")
238 (defvar gnus-use-dribble-file t
239 "*Non-nil means that Gnus will use a dribble file to store user updates.
240 If Emacs should crash without saving the .newsrc files, complete
241 information can be restored from the dribble file.")
243 (defvar gnus-dribble-directory nil
244 "*The directory where dribble files will be saved.
245 If this variable is nil, the directory where the .newsrc files are
246 saved will be used.")
248 (defvar gnus-asynchronous nil
249 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
251 (defvar gnus-kill-summary-on-exit t
252 "*If non-nil, kill the summary buffer when you exit from it.
253 If nil, the summary will become a \"*Dead Summary*\" buffer, and
254 it will be killed sometime later.")
256 (defvar gnus-large-newsgroup 200
257 "*The number of articles which indicates a large newsgroup.
258 If the number of articles in a newsgroup is greater than this value,
259 confirmation is required for selecting the newsgroup.")
261 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
262 (defvar gnus-no-groups-message "No news is horrible news"
263 "*Message displayed by Gnus when no groups are available.")
265 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
266 "*Non-nil means that the default name of a file to save articles in is the group name.
267 If it's nil, the directory form of the group name is used instead.
269 If this variable is a list, and the list contains the element
270 `not-score', long file names will not be used for score files; if it
271 contains the element `not-save', long file names will not be used for
272 saving; and if it contains the element `not-kill', long file names
273 will not be used for kill files.")
275 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
276 "*Name of the directory articles will be saved in (default \"~/News\").
277 Initialized from the SAVEDIR environment variable.")
279 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
280 "*Name of the directory where kill files will be stored (default \"~/News\").
281 Initialized from the SAVEDIR environment variable.")
283 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
284 "*A function to save articles in your favorite format.
285 The function must be interactively callable (in other words, it must
286 be an Emacs command).
288 Gnus provides the following functions:
290 * gnus-summary-save-in-rmail (Rmail format)
291 * gnus-summary-save-in-mail (Unix mail format)
292 * gnus-summary-save-in-folder (MH folder)
293 * gnus-summary-save-in-file (article format).
294 * gnus-summary-save-in-vm (use VM's folder format).")
296 (defvar gnus-prompt-before-saving 'always
297 "*This variable says how much prompting is to be done when saving articles.
298 If it is nil, no prompting will be done, and the articles will be
299 saved to the default files. If this variable is `always', each and
300 every article that is saved will be preceded by a prompt, even when
301 saving large batches of articles. If this variable is neither nil not
302 `always', there the user will be prompted once for a file name for
303 each invocation of the saving commands.")
305 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
306 "*A function generating a file name to save articles in Rmail format.
307 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
309 (defvar gnus-mail-save-name (function gnus-plain-save-name)
310 "*A function generating a file name to save articles in Unix mail format.
311 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
313 (defvar gnus-folder-save-name (function gnus-folder-save-name)
314 "*A function generating a file name to save articles in MH folder.
315 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
317 (defvar gnus-file-save-name (function gnus-numeric-save-name)
318 "*A function generating a file name to save articles in article format.
319 The function is called with NEWSGROUP, HEADERS, and optional
322 (defvar gnus-split-methods
323 '((gnus-article-archive-name))
324 "*Variable used to suggest where articles are to be saved.
325 For instance, if you would like to save articles related to Gnus in
326 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
327 you could set this variable to something like:
329 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
330 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
332 This variable is an alist where the where the key is the match and the
333 value is a list of possible files to save in if the match is non-nil.
335 If the match is a string, it is used as a regexp match on the
336 article. If the match is a symbol, that symbol will be funcalled
337 from the buffer of the article to be saved with the newsgroup as the
338 parameter. If it is a list, it will be evaled in the same buffer.
340 If this form or function returns a string, this string will be used as
341 a possible file name; and if it returns a non-nil list, that list will
342 be used as possible file names.")
344 (defvar gnus-move-split-methods nil
345 "*Variable used to suggest where articles are to be moved to.
346 It uses the same syntax as the `gnus-split-methods' variable.")
348 (defvar gnus-save-score nil
349 "*If non-nil, save group scoring info.")
351 (defvar gnus-use-adaptive-scoring nil
352 "*If non-nil, use some adaptive scoring scheme.")
354 (defvar gnus-use-cache nil
355 "*If nil, Gnus will ignore the article cache.
356 If `passive', it will allow entering (and reading) articles
357 explicitly entered into the cache. If anything else, use the
358 cache to the full extent of the law.")
360 (defvar gnus-use-trees nil
361 "*If non-nil, display a thread tree buffer.")
363 (defvar gnus-use-grouplens nil
364 "*If non-nil, use GroupLens ratings.")
366 (defvar gnus-keep-backlog nil
367 "*If non-nil, Gnus will keep read articles for later re-retrieval.
368 If it is a number N, then Gnus will only keep the last N articles
369 read. If it is neither nil nor a number, Gnus will keep all read
370 articles. This is not a good idea.")
372 (defvar gnus-use-nocem nil
373 "*If non-nil, Gnus will read NoCeM cancel messages.")
375 (defvar gnus-use-demon nil
376 "If non-nil, Gnus might use some demons.")
378 (defvar gnus-use-scoring t
379 "*If non-nil, enable scoring.")
381 (defvar gnus-use-picons nil
382 "*If non-nil, display picons.")
384 (defvar gnus-fetch-old-headers nil
385 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
386 If an unread article in the group refers to an older, already read (or
387 just marked as read) article, the old article will not normally be
388 displayed in the Summary buffer. If this variable is non-nil, Gnus
389 will attempt to grab the headers to the old articles, and thereby
390 build complete threads. If it has the value `some', only enough
391 headers to connect otherwise loose threads will be displayed.
392 This variable can also be a number. In that case, no more than that
393 number of old headers will be fetched.
395 The server has to support NOV for any of this to work.")
398 ;(defvar gnus-visual t
399 ; "*If non-nil, will do various highlighting.
400 ;If nil, no mouse highlights (or any other highlights) will be
401 ;performed. This might speed up Gnus some when generating large group
402 ;and summary buffers.")
404 (defvar gnus-novice-user t
405 "*Non-nil means that you are a usenet novice.
406 If non-nil, verbose messages may be displayed and confirmations may be
409 (defvar gnus-expert-user nil
410 "*Non-nil means that you will never be asked for confirmation about anything.
411 And that means *anything*.")
413 (defvar gnus-verbose 7
414 "*Integer that says how verbose Gnus should be.
415 The higher the number, the more messages Gnus will flash to say what
416 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
417 display most important messages; and at ten, Gnus will keep on
418 jabbering all the time.")
420 (defvar gnus-keep-same-level nil
421 "*Non-nil means that the next newsgroup after the current will be on the same level.
422 When you type, for instance, `n' after reading the last article in the
423 current newsgroup, you will go to the next newsgroup. If this variable
424 is nil, the next newsgroup will be the next from the group
426 If this variable is non-nil, Gnus will either put you in the
427 next newsgroup with the same level, or, if no such newsgroup is
428 available, the next newsgroup with the lowest possible level higher
429 than the current level.
430 If this variable is `best', Gnus will make the next newsgroup the one
431 with the best level.")
433 (defvar gnus-summary-make-false-root 'adopt
434 "*nil means that Gnus won't gather loose threads.
435 If the root of a thread has expired or been read in a previous
436 session, the information necessary to build a complete thread has been
437 lost. Instead of having many small sub-threads from this original thread
438 scattered all over the summary buffer, Gnus can gather them.
440 If non-nil, Gnus will try to gather all loose sub-threads from an
441 original thread into one large thread.
443 If this variable is non-nil, it should be one of `none', `adopt',
446 If this variable is `none', Gnus will not make a false root, but just
447 present the sub-threads after another.
448 If this variable is `dummy', Gnus will create a dummy root that will
449 have all the sub-threads as children.
450 If this variable is `adopt', Gnus will make one of the \"children\"
451 the parent and mark all the step-children as such.
452 If this variable is `empty', the \"children\" are printed with empty
453 subject fields. (Or rather, they will be printed with a string
454 given by the `gnus-summary-same-subject' variable.)")
456 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
457 "*A regexp to match subjects to be excluded from loose thread gathering.
458 As loose thread gathering is done on subjects only, that means that
459 there can be many false gatherings performed. By rooting out certain
460 common subjects, gathering might become saner.")
462 (defvar gnus-summary-gather-subject-limit nil
463 "*Maximum length of subject comparisons when gathering loose threads.
464 Use nil to compare full subjects. Setting this variable to a low
465 number will help gather threads that have been corrupted by
466 newsreaders chopping off subject lines, but it might also mean that
467 unrelated articles that have subject that happen to begin with the
468 same few characters will be incorrectly gathered.
470 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
471 comparing subjects.")
473 (defvar gnus-simplify-ignored-prefixes nil
474 "*Regexp, matches for which are removed from subject lines when simplifying.")
476 (defvar gnus-build-sparse-threads nil
477 "*If non-nil, fill in the gaps in threads.
478 If `some', only fill in the gaps that are needed to tie loose threads
479 together. If `more', fill in all leaf nodes that Gnus can find. If
480 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
482 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
483 "Function used for gathering loose threads.
484 There are two pre-defined functions: `gnus-gather-threads-by-subject',
485 which only takes Subjects into consideration; and
486 `gnus-gather-threads-by-references', which compared the References
487 headers of the articles to find matches.")
489 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
490 (defvar gnus-summary-same-subject ""
491 "*String indicating that the current article has the same subject as the previous.
492 This variable will only be used if the value of
493 `gnus-summary-make-false-root' is `empty'.")
495 (defvar gnus-summary-goto-unread t
496 "*If non-nil, marking commands will go to the next unread article.
497 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
498 whether it is read or not.")
500 (defvar gnus-group-goto-unread t
501 "*If non-nil, movement commands will go to the next unread and subscribed group.")
503 (defvar gnus-goto-next-group-when-activating t
504 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
506 (defvar gnus-check-new-newsgroups t
507 "*Non-nil means that Gnus will add new newsgroups at startup.
508 If this variable is `ask-server', Gnus will ask the server for new
509 groups since the last time it checked. This means that the killed list
510 is no longer necessary, so you could set `gnus-save-killed-list' to
513 A variant is to have this variable be a list of select methods. Gnus
514 will then use the `ask-server' method on all these select methods to
515 query for new groups from all those servers.
518 (setq gnus-check-new-newsgroups
519 '((nntp \"some.server\") (nntp \"other.server\")))
521 If this variable is nil, then you have to tell Gnus explicitly to
522 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
524 (defvar gnus-check-bogus-newsgroups nil
525 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
526 If this variable is nil, then you have to tell Gnus explicitly to
527 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
529 (defvar gnus-read-active-file t
530 "*Non-nil means that Gnus will read the entire active file at startup.
531 If this variable is nil, Gnus will only know about the groups in your
534 If this variable is `some', Gnus will try to only read the relevant
535 parts of the active file from the server. Not all servers support
536 this, and it might be quite slow with other servers, but this should
537 generally be faster than both the t and nil value.
539 If you set this variable to nil or `some', you probably still want to
540 be told about new newsgroups that arrive. To do that, set
541 `gnus-check-new-newsgroups' to `ask-server'. This may not work
542 properly with all servers.")
544 (defvar gnus-level-subscribed 5
545 "*Groups with levels less than or equal to this variable are subscribed.")
547 (defvar gnus-level-unsubscribed 7
548 "*Groups with levels less than or equal to this variable are unsubscribed.
549 Groups with levels less than `gnus-level-subscribed', which should be
550 less than this variable, are subscribed.")
552 (defvar gnus-level-zombie 8
553 "*Groups with this level are zombie groups.")
555 (defvar gnus-level-killed 9
556 "*Groups with this level are killed.")
558 (defvar gnus-level-default-subscribed 3
559 "*New subscribed groups will be subscribed at this level.")
561 (defvar gnus-level-default-unsubscribed 6
562 "*New unsubscribed groups will be unsubscribed at this level.")
564 (defvar gnus-activate-level (1+ gnus-level-subscribed)
565 "*Groups higher than this level won't be activated on startup.
566 Setting this variable to something log might save lots of time when
567 you have many groups that you aren't interested in.")
569 (defvar gnus-activate-foreign-newsgroups 4
570 "*If nil, Gnus will not check foreign newsgroups at startup.
571 If it is non-nil, it should be a number between one and nine. Foreign
572 newsgroups that have a level lower or equal to this number will be
573 activated on startup. For instance, if you want to active all
574 subscribed newsgroups, but not the rest, you'd set this variable to
575 `gnus-level-subscribed'.
577 If you subscribe to lots of newsgroups from different servers, startup
578 might take a while. By setting this variable to nil, you'll save time,
579 but you won't be told how many unread articles there are in the
582 (defvar gnus-save-newsrc-file t
583 "*Non-nil means that Gnus will save the `.newsrc' file.
584 Gnus always saves its own startup file, which is called
585 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
586 be readily understood by other newsreaders. If you don't plan on
587 using other newsreaders, set this variable to nil to save some time on
590 (defvar gnus-save-killed-list t
591 "*If non-nil, save the list of killed groups to the startup file.
592 If you set this variable to nil, you'll save both time (when starting
593 and quitting) and space (both memory and disk), but it will also mean
594 that Gnus has no record of which groups are new and which are old, so
595 the automatic new newsgroups subscription methods become meaningless.
597 You should always set `gnus-check-new-newsgroups' to `ask-server' or
598 nil if you set this variable to nil.")
600 (defvar gnus-interactive-catchup t
601 "*If non-nil, require your confirmation when catching up a group.")
603 (defvar gnus-interactive-post t
604 "*If non-nil, group name will be asked for when posting.")
606 (defvar gnus-interactive-exit t
607 "*If non-nil, require your confirmation when exiting Gnus.")
609 (defvar gnus-kill-killed t
610 "*If non-nil, Gnus will apply kill files to already killed articles.
611 If it is nil, Gnus will never apply kill files to articles that have
612 already been through the scoring process, which might very well save lots
615 (defvar gnus-extract-address-components 'gnus-extract-address-components
616 "*Function for extracting address components from a From header.
617 Two pre-defined function exist: `gnus-extract-address-components',
618 which is the default, quite fast, and too simplistic solution, and
619 `mail-extract-address-components', which works much better, but is
622 (defvar gnus-summary-default-score 0
623 "*Default article score level.
624 If this variable is nil, scoring will be disabled.")
626 (defvar gnus-summary-zcore-fuzz 0
627 "*Fuzziness factor for the zcore in the summary buffer.
628 Articles with scores closer than this to `gnus-summary-default-score'
629 will not be marked.")
631 (defvar gnus-simplify-subject-fuzzy-regexp nil
632 "*Strings to be removed when doing fuzzy matches.
633 This can either be a regular expression or list of regular expressions
634 that will be removed from subject strings if fuzzy subject
635 simplification is selected.")
637 (defvar gnus-permanently-visible-groups nil
638 "*Regexp to match groups that should always be listed in the group buffer.
639 This means that they will still be listed when there are no unread
640 articles in the groups.")
642 (defvar gnus-list-groups-with-ticked-articles t
643 "*If non-nil, list groups that have only ticked articles.
644 If nil, only list groups that have unread articles.")
646 (defvar gnus-group-default-list-level gnus-level-subscribed
647 "*Default listing level.
648 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
650 (defvar gnus-group-use-permanent-levels nil
651 "*If non-nil, once you set a level, Gnus will use this level.")
653 (defvar gnus-group-list-inactive-groups t
654 "*If non-nil, inactive groups will be listed.")
656 (defvar gnus-show-mime nil
657 "*If non-nil, do mime processing of articles.
658 The articles will simply be fed to the function given by
659 `gnus-show-mime-method'.")
661 (defvar gnus-strict-mime t
662 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
664 (defvar gnus-show-mime-method 'metamail-buffer
665 "*Function to process a MIME message.
666 The function is called from the article buffer.")
668 (defvar gnus-decode-encoded-word-method (lambda ())
669 "*Function to decode a MIME encoded-words.
670 The function is called from the article buffer.")
672 (defvar gnus-show-threads t
673 "*If non-nil, display threads in summary mode.")
675 (defvar gnus-thread-hide-subtree nil
676 "*If non-nil, hide all threads initially.
677 If threads are hidden, you have to run the command
678 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
679 to expose hidden threads.")
681 (defvar gnus-thread-hide-killed t
682 "*If non-nil, hide killed threads automatically.")
684 (defvar gnus-thread-ignore-subject nil
685 "*If non-nil, ignore subjects and do all threading based on the Reference header.
686 If nil, which is the default, articles that have different subjects
687 from their parents will start separate threads.")
689 (defvar gnus-thread-operation-ignore-subject t
690 "*If non-nil, subjects will be ignored when doing thread commands.
691 This affects commands like `gnus-summary-kill-thread' and
692 `gnus-summary-lower-thread'.
694 If this variable is nil, articles in the same thread with different
695 subjects will not be included in the operation in question. If this
696 variable is `fuzzy', only articles that have subjects that are fuzzily
697 equal will be included.")
699 (defvar gnus-thread-indent-level 4
700 "*Number that says how much each sub-thread should be indented.")
702 (defvar gnus-ignored-newsgroups
703 (purecopy (mapconcat 'identity
704 '("^to\\." ; not "real" groups
705 "^[0-9. \t]+ " ; all digits in name
706 "[][\"#'()]" ; bogus characters
709 "*A regexp to match uninteresting newsgroups in the active file.
710 Any lines in the active file matching this regular expression are
711 removed from the newsgroup list before anything else is done to it,
712 thus making them effectively non-existent.")
714 (defvar gnus-ignored-headers
715 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
716 "*All headers that match this regexp will be hidden.
717 This variable can also be a list of regexps of headers to be ignored.
718 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
720 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
721 "*All headers that do not match this regexp will be hidden.
722 This variable can also be a list of regexp of headers to remain visible.
723 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
725 (defvar gnus-sorted-header-list
726 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
727 "^Cc:" "^Date:" "^Organization:")
728 "*This variable is a list of regular expressions.
729 If it is non-nil, headers that match the regular expressions will
730 be placed first in the article buffer in the sequence specified by
733 (defvar gnus-boring-article-headers
734 '(empty followup-to reply-to)
735 "*Headers that are only to be displayed if they have interesting data.
736 Possible values in this list are `empty', `newsgroups', `followup-to',
737 `reply-to', and `date'.")
739 (defvar gnus-show-all-headers nil
740 "*If non-nil, don't hide any headers.")
742 (defvar gnus-save-all-headers t
743 "*If non-nil, don't remove any headers before saving.")
745 (defvar gnus-saved-headers gnus-visible-headers
746 "*Headers to keep if `gnus-save-all-headers' is nil.
747 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
748 If that variable is nil, however, all headers that match this regexp
749 will be kept while the rest will be deleted before saving.")
751 (defvar gnus-inhibit-startup-message nil
752 "*If non-nil, the startup message will not be displayed.")
754 (defvar gnus-signature-separator "^-- *$"
755 "Regexp matching signature separator.")
757 (defvar gnus-signature-limit nil
758 "Provide a limit to what is considered a signature.
759 If it is a number, no signature may not be longer (in characters) than
760 that number. If it is a function, the function will be called without
761 any parameters, and if it returns nil, there is no signature in the
762 buffer. If it is a string, it will be used as a regexp. If it
763 matches, the text in question is not a signature.")
765 (defvar gnus-auto-extend-newsgroup t
766 "*If non-nil, extend newsgroup forward and backward when requested.")
768 (defvar gnus-auto-select-first t
769 "*If nil, don't select the first unread article when entering a group.
770 If this variable is `best', select the highest-scored unread article
771 in the group. If neither nil nor `best', select the first unread
774 If you want to prevent automatic selection of the first unread article
775 in some newsgroups, set the variable to nil in
776 `gnus-select-group-hook'.")
778 (defvar gnus-auto-select-next t
779 "*If non-nil, offer to go to the next group from the end of the previous.
780 If the value is t and the next newsgroup is empty, Gnus will exit
781 summary mode and go back to group mode. If the value is neither nil
782 nor t, Gnus will select the following unread newsgroup. In
783 particular, if the value is the symbol `quietly', the next unread
784 newsgroup will be selected without any confirmation, and if it is
785 `almost-quietly', the next group will be selected without any
786 confirmation if you are located on the last article in the group.
787 Finally, if this variable is `slightly-quietly', the `Z n' command
788 will go to the next group without confirmation.")
790 (defvar gnus-auto-select-same nil
791 "*If non-nil, select the next article with the same subject.")
793 (defvar gnus-summary-check-current nil
794 "*If non-nil, consider the current article when moving.
795 The \"unread\" movement commands will stay on the same line if the
796 current article is unread.")
798 (defvar gnus-auto-center-summary t
799 "*If non-nil, always center the current summary buffer.
800 In particular, if `vertical' do only vertical recentering. If non-nil
801 and non-`vertical', do both horizontal and vertical recentering.")
803 (defvar gnus-break-pages t
804 "*If non-nil, do page breaking on articles.
805 The page delimiter is specified by the `gnus-page-delimiter'
808 (defvar gnus-page-delimiter "^\^L"
809 "*Regexp describing what to use as article page delimiters.
810 The default value is \"^\^L\", which is a form linefeed at the
811 beginning of a line.")
813 (defvar gnus-use-full-window t
814 "*If non-nil, use the entire Emacs screen.")
816 (defvar gnus-window-configuration nil
817 "Obsolete variable. See `gnus-buffer-configuration'.")
819 (defvar gnus-window-min-width 2
820 "*Minimum width of Gnus buffers.")
822 (defvar gnus-window-min-height 1
823 "*Minimum height of Gnus buffers.")
825 (defvar gnus-buffer-configuration
829 (if gnus-carpal '(group-carpal 4))))
833 (if gnus-carpal '(summary-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))
842 (vertical ((height . 5) (width . 15)
844 (left . -1) (top . 1))
854 (if gnus-carpal '(summary-carpal 4))
855 (if gnus-use-trees '(tree 0.25))
860 (if gnus-carpal '(server-carpal 2))))
864 (if gnus-carpal '(browse-carpal 2))))
867 (message 1.0 point)))
870 (article 1.0 point)))
881 (edit-group 1.0 point)))
885 (edit-server 1.0 point)))
889 (edit-score 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
902 (message 1.0 point)))
906 (message 1.0 point)))
913 (if gnus-carpal '(summary-carpal 4))
914 ("*Shell Command Output*" 1.0)))
917 ("*Gnus Help Bug*" 0.5)
918 ("*Gnus Bug*" 1.0 point)))
922 (message 1.0 point))))
923 "Window configuration for all possible Gnus buffers.
924 This variable is a list of lists. Each of these lists has a NAME and
925 a RULE. The NAMEs are commonsense names like `group', which names a
926 rule used when displaying the group buffer; `summary', which names a
927 rule for what happens when you enter a group and do not display an
928 article buffer; and so on. See the value of this variable for a
929 complete list of NAMEs.
931 Each RULE is a list of vectors. The first element in this vector is
932 the name of the buffer to be displayed; the second element is the
933 percentage of the screen this buffer is to occupy (a number in the
934 0.0-0.99 range); the optional third element is `point', which should
935 be present to denote which buffer point is to go to after making this
936 buffer configuration.")
938 (defvar gnus-window-to-buffer
939 '((group . gnus-group-buffer)
940 (summary . gnus-summary-buffer)
941 (article . gnus-article-buffer)
942 (server . gnus-server-buffer)
943 (browse . "*Gnus Browse Server*")
944 (edit-group . gnus-group-edit-buffer)
945 (edit-server . gnus-server-edit-buffer)
946 (group-carpal . gnus-carpal-group-buffer)
947 (summary-carpal . gnus-carpal-summary-buffer)
948 (server-carpal . gnus-carpal-server-buffer)
949 (browse-carpal . gnus-carpal-browse-buffer)
950 (edit-score . gnus-score-edit-buffer)
951 (message . gnus-message-buffer)
952 (mail . gnus-message-buffer)
953 (post-news . gnus-message-buffer)
954 (faq . gnus-faq-buffer)
955 (picons . "*Picons*")
956 (tree . gnus-tree-buffer)
957 (info . gnus-info-buffer)
958 (article-copy . gnus-article-copy)
959 (draft . gnus-draft-buffer))
960 "Mapping from short symbols to buffer names or buffer variables.")
962 (defvar gnus-carpal nil
963 "*If non-nil, display clickable icons.")
965 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
966 "*Function called with a group name when new group is detected.
967 A few pre-made functions are supplied: `gnus-subscribe-randomly'
968 inserts new groups at the beginning of the list of groups;
969 `gnus-subscribe-alphabetically' inserts new groups in strict
970 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
971 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
972 for your decision; `gnus-subscribe-killed' kills all new groups.")
974 ;; Suggested by a bug report by Hallvard B Furuseth.
975 ;; <h.b.furuseth@usit.uio.no>.
976 (defvar gnus-subscribe-options-newsgroup-method
977 (function gnus-subscribe-alphabetically)
978 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
979 If, for instance, you want to subscribe to all newsgroups in the
980 \"no\" and \"alt\" hierarchies, you'd put the following in your
983 options -n no.all alt.all
985 Gnus will the subscribe all new newsgroups in these hierarchies with
986 the subscription method in this variable.")
988 (defvar gnus-subscribe-hierarchical-interactive nil
989 "*If non-nil, Gnus will offer to subscribe hierarchically.
990 When a new hierarchy appears, Gnus will ask the user:
992 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
994 If the user pressed `d', Gnus will descend the hierarchy, `y' will
995 subscribe to all newsgroups in the hierarchy and `s' will skip this
996 hierarchy in its entirety.")
998 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
999 "*Function used for sorting the group buffer.
1000 This function will be called with group info entries as the arguments
1001 for the groups to be sorted. Pre-made functions include
1002 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1003 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1004 `gnus-group-sort-by-rank'.
1006 This variable can also be a list of sorting functions. In that case,
1007 the most significant sort function should be the last function in the
1010 ;; Mark variables suggested by Thomas Michanek
1011 ;; <Thomas.Michanek@telelogic.se>.
1012 (defvar gnus-unread-mark ?
1013 "*Mark used for unread articles.")
1014 (defvar gnus-ticked-mark ?!
1015 "*Mark used for ticked articles.")
1016 (defvar gnus-dormant-mark ??
1017 "*Mark used for dormant articles.")
1018 (defvar gnus-del-mark ?r
1019 "*Mark used for del'd articles.")
1020 (defvar gnus-read-mark ?R
1021 "*Mark used for read articles.")
1022 (defvar gnus-expirable-mark ?E
1023 "*Mark used for expirable articles.")
1024 (defvar gnus-killed-mark ?K
1025 "*Mark used for killed articles.")
1026 (defvar gnus-souped-mark ?F
1027 "*Mark used for killed articles.")
1028 (defvar gnus-kill-file-mark ?X
1029 "*Mark used for articles killed by kill files.")
1030 (defvar gnus-low-score-mark ?Y
1031 "*Mark used for articles with a low score.")
1032 (defvar gnus-catchup-mark ?C
1033 "*Mark used for articles that are caught up.")
1034 (defvar gnus-replied-mark ?A
1035 "*Mark used for articles that have been replied to.")
1036 (defvar gnus-cached-mark ?*
1037 "*Mark used for articles that are in the cache.")
1038 (defvar gnus-saved-mark ?S
1039 "*Mark used for articles that have been saved to.")
1040 (defvar gnus-process-mark ?#
1042 (defvar gnus-ancient-mark ?O
1043 "*Mark used for ancient articles.")
1044 (defvar gnus-sparse-mark ?Q
1045 "*Mark used for sparsely reffed articles.")
1046 (defvar gnus-canceled-mark ?G
1047 "*Mark used for canceled articles.")
1048 (defvar gnus-score-over-mark ?+
1049 "*Score mark used for articles with high scores.")
1050 (defvar gnus-score-below-mark ?-
1051 "*Score mark used for articles with low scores.")
1052 (defvar gnus-empty-thread-mark ?
1053 "*There is no thread under the article.")
1054 (defvar gnus-not-empty-thread-mark ?=
1055 "*There is a thread under the article.")
1057 (defvar gnus-view-pseudo-asynchronously nil
1058 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1060 (defvar gnus-view-pseudos nil
1061 "*If `automatic', pseudo-articles will be viewed automatically.
1062 If `not-confirm', pseudos will be viewed automatically, and the user
1063 will not be asked to confirm the command.")
1065 (defvar gnus-view-pseudos-separately t
1066 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1067 If nil, all files that use the same viewing command will be given as a
1068 list of parameters to that command.")
1070 (defvar gnus-insert-pseudo-articles t
1071 "*If non-nil, insert pseudo-articles when decoding articles.")
1073 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1074 "*Format of group lines.
1075 It works along the same lines as a normal formatting string,
1076 with some simple extensions.
1078 %M Only marked articles (character, \"*\" or \" \")
1079 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1080 %L Level of subscribedness (integer)
1081 %N Number of unread articles (integer)
1082 %I Number of dormant articles (integer)
1083 %i Number of ticked and dormant (integer)
1084 %T Number of ticked articles (integer)
1085 %R Number of read articles (integer)
1086 %t Total number of articles (integer)
1087 %y Number of unread, unticked articles (integer)
1088 %G Group name (string)
1089 %g Qualified group name (string)
1090 %D Group description (string)
1091 %s Select method (string)
1092 %o Moderated group (char, \"m\")
1093 %p Process mark (char)
1094 %O Moderated group (string, \"(m)\" or \"\")
1095 %P Topic indentation (string)
1096 %l Whether there are GroupLens predictions for this group (string)
1097 %n Select from where (string)
1098 %z A string that look like `<%s:%n>' if a foreign select method is used
1099 %u User defined specifier. The next character in the format string should
1100 be a letter. Gnus will call the function gnus-user-format-function-X,
1101 where X is the letter following %u. The function will be passed the
1102 current header as argument. The function should return a string, which
1103 will be inserted into the buffer just like information from any other
1106 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1107 the mouse point move inside the area. There can only be one such area.
1109 Note that this format specification is not always respected. For
1110 reasons of efficiency, when listing killed groups, this specification
1111 is ignored altogether. If the spec is changed considerably, your
1112 output may end up looking strange when listing both alive and killed
1115 If you use %o or %O, reading the active file will be slower and quite
1116 a bit of extra memory will be used. %D will also worsen performance.
1117 Also note that if you change the format specification to include any
1118 of these specs, you must probably re-start Gnus to see them go into
1121 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1122 "*The format specification of the lines in the summary buffer.
1124 It works along the same lines as a normal formatting string,
1125 with some simple extensions.
1127 %N Article number, left padded with spaces (string)
1129 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1130 %n Name of the poster (string)
1131 %a Extracted name of the poster (string)
1132 %A Extracted address of the poster (string)
1133 %F Contents of the From: header (string)
1134 %x Contents of the Xref: header (string)
1135 %D Date of the article (string)
1136 %d Date of the article (string) in DD-MMM format
1137 %M Message-id of the article (string)
1138 %r References of the article (string)
1139 %c Number of characters in the article (integer)
1140 %L Number of lines in the article (integer)
1141 %I Indentation based on thread level (a string of spaces)
1142 %T A string with two possible values: 80 spaces if the article
1143 is on thread level two or larger and 0 spaces on level one
1144 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1145 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1146 %[ Opening bracket (character, \"[\" or \"<\")
1147 %] Closing bracket (character, \"]\" or \">\")
1148 %> Spaces of length thread-level (string)
1149 %< Spaces of length (- 20 thread-level) (string)
1150 %i Article score (number)
1151 %z Article zcore (character)
1152 %t Number of articles under the current thread (number).
1153 %e Whether the thread is empty or not (character).
1154 %l GroupLens score (string).
1155 %u User defined specifier. The next character in the format string should
1156 be a letter. Gnus will call the function gnus-user-format-function-X,
1157 where X is the letter following %u. The function will be passed the
1158 current header as argument. The function should return a string, which
1159 will be inserted into the summary just like information from any other
1162 Text between %( and %) will be highlighted with `gnus-mouse-face'
1163 when the mouse point is placed inside the area. There can only be one
1166 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1167 with care. For reasons of efficiency, Gnus will compute what column
1168 these characters will end up in, and \"hard-code\" that. This means that
1169 it is illegal to have these specs after a variable-length spec. Well,
1170 you might not be arrested, but your summary buffer will look strange,
1171 which is bad enough.
1173 The smart choice is to have these specs as for to the left as
1176 This restriction may disappear in later versions of Gnus.")
1178 (defvar gnus-summary-dummy-line-format
1180 "*The format specification for the dummy roots in the summary buffer.
1181 It works along the same lines as a normal formatting string,
1182 with some simple extensions.
1186 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1187 "*The format specification for the summary mode line.
1188 It works along the same lines as a normal formatting string,
1189 with some simple extensions:
1192 %p Unprefixed group name
1193 %A Current article number
1195 %U Number of unread articles in the group
1196 %e Number of unselected articles in the group
1197 %Z A string with unread/unselected article counts
1198 %g Shortish group name
1199 %S Subject of the current article
1200 %u User-defined spec
1201 %s Current score file name
1202 %d Number of dormant articles
1203 %r Number of articles that have been marked as read in this session
1204 %E Number of articles expunged by the score files")
1206 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1207 "*The format specification for the article mode line.
1208 See `gnus-summary-mode-line-format' for a closer description.")
1210 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1211 "*The format specification for the group mode line.
1212 It works along the same lines as a normal formatting string,
1213 with some simple extensions:
1215 %S The native news server.
1216 %M The native select method.")
1218 (defvar gnus-valid-select-methods
1219 '(("nntp" post address prompt-address)
1220 ("nnspool" post address)
1221 ("nnvirtual" post-mail virtual prompt-address)
1222 ("nnmbox" mail respool address)
1223 ("nnml" mail respool address)
1224 ("nnmh" mail respool address)
1225 ("nndir" post-mail prompt-address address)
1226 ("nneething" none address prompt-address)
1227 ("nndoc" none address prompt-address)
1228 ("nnbabyl" mail address respool)
1229 ("nnkiboze" post address virtual)
1230 ("nnsoup" post-mail address)
1231 ("nndraft" post-mail)
1232 ("nnfolder" mail respool address))
1233 "An alist of valid select methods.
1234 The first element of each list lists should be a string with the name
1235 of the select method. The other elements may be be the category of
1236 this method (ie. `post', `mail', `none' or whatever) or other
1237 properties that this method has (like being respoolable).
1238 If you implement a new select method, all you should have to change is
1239 this variable. I think.")
1241 (defvar gnus-updated-mode-lines '(group article summary tree)
1242 "*List of buffers that should update their mode lines.
1243 The list may contain the symbols `group', `article' and `summary'. If
1244 the corresponding symbol is present, Gnus will keep that mode line
1245 updated with information that may be pertinent.
1246 If this variable is nil, screen refresh may be quicker.")
1248 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1249 (defvar gnus-mode-non-string-length nil
1250 "*Max length of mode-line non-string contents.
1251 If this is nil, Gnus will take space as is needed, leaving the rest
1252 of the modeline intact.")
1255 ;(defvar gnus-mouse-face 'highlight
1256 ; "*Face used for mouse highlighting in Gnus.
1257 ;No mouse highlights will be done if `gnus-visual' is nil.")
1259 (defvar gnus-summary-mark-below nil
1260 "*Mark all articles with a score below this variable as read.
1261 This variable is local to each summary buffer and usually set by the
1264 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1265 "*List of functions used for sorting articles in the summary buffer.
1266 This variable is only used when not using a threaded display.")
1268 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1269 "*List of functions used for sorting threads in the summary buffer.
1270 By default, threads are sorted by article number.
1272 Each function takes two threads and return non-nil if the first thread
1273 should be sorted before the other. If you use more than one function,
1274 the primary sort function should be the last. You should probably
1275 always include `gnus-thread-sort-by-number' in the list of sorting
1276 functions -- preferably first.
1278 Ready-mady functions include `gnus-thread-sort-by-number',
1279 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1280 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1281 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1283 (defvar gnus-thread-score-function '+
1284 "*Function used for calculating the total score of a thread.
1286 The function is called with the scores of the article and each
1287 subthread and should then return the score of the thread.
1289 Some functions you can use are `+', `max', or `min'.")
1291 (defvar gnus-summary-expunge-below nil
1292 "All articles that have a score less than this variable will be expunged.")
1294 (defvar gnus-thread-expunge-below nil
1295 "All threads that have a total score less than this variable will be expunged.
1296 See `gnus-thread-score-function' for en explanation of what a
1297 \"thread score\" is.")
1299 (defvar gnus-auto-subscribed-groups
1300 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1301 "*All new groups that match this regexp will be subscribed automatically.
1302 Note that this variable only deals with new groups. It has no effect
1303 whatsoever on old groups.")
1305 (defvar gnus-options-subscribe nil
1306 "*All new groups matching this regexp will be subscribed unconditionally.
1307 Note that this variable deals only with new newsgroups. This variable
1308 does not affect old newsgroups.")
1310 (defvar gnus-options-not-subscribe nil
1311 "*All new groups matching this regexp will be ignored.
1312 Note that this variable deals only with new newsgroups. This variable
1313 does not affect old (already subscribed) newsgroups.")
1315 (defvar gnus-auto-expirable-newsgroups nil
1316 "*Groups in which to automatically mark read articles as expirable.
1317 If non-nil, this should be a regexp that should match all groups in
1318 which to perform auto-expiry. This only makes sense for mail groups.")
1320 (defvar gnus-total-expirable-newsgroups nil
1321 "*Groups in which to perform expiry of all read articles.
1322 Use with extreme caution. All groups that match this regexp will be
1323 expiring - which means that all read articles will be deleted after
1324 (say) one week. (This only goes for mail groups and the like, of
1327 (defvar gnus-group-uncollapsed-levels 1
1328 "Number of group name elements to leave alone when making a short group name.")
1330 (defvar gnus-hidden-properties '(invisible t intangible t)
1331 "Property list to use for hiding text.")
1333 (defvar gnus-modtime-botch nil
1334 "*Non-nil means .newsrc should be deleted prior to save.
1335 Its use is due to the bogus appearance that .newsrc was modified on
1340 (defvar gnus-group-mode-hook nil
1341 "*A hook for Gnus group mode.")
1343 (defvar gnus-summary-mode-hook nil
1344 "*A hook for Gnus summary mode.
1345 This hook is run before any variables are set in the summary buffer.")
1347 (defvar gnus-article-mode-hook nil
1348 "*A hook for Gnus article mode.")
1350 (defvar gnus-summary-prepare-exit-hook nil
1351 "*A hook called when preparing to exit from the summary buffer.
1352 It calls `gnus-summary-expire-articles' by default.")
1353 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1355 (defvar gnus-summary-exit-hook nil
1356 "*A hook called on exit from the summary buffer.")
1358 (defvar gnus-group-catchup-group-hook nil
1359 "*A hook run when catching up a group from the group buffer.")
1361 (defvar gnus-open-server-hook nil
1362 "*A hook called just before opening connection to the news server.")
1364 (defvar gnus-load-hook nil
1365 "*A hook run while Gnus is loaded.")
1367 (defvar gnus-startup-hook nil
1368 "*A hook called at startup.
1369 This hook is called after Gnus is connected to the NNTP server.")
1371 (defvar gnus-get-new-news-hook nil
1372 "*A hook run just before Gnus checks for new news.")
1374 (defvar gnus-after-getting-new-news-hook nil
1375 "*A hook run after Gnus checks for new news.")
1377 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1378 "*A function that is called to generate the group buffer.
1379 The function is called with three arguments: The first is a number;
1380 all group with a level less or equal to that number should be listed,
1381 if the second is non-nil, empty groups should also be displayed. If
1382 the third is non-nil, it is a number. No groups with a level lower
1383 than this number should be displayed.
1385 The only current function implemented is `gnus-group-prepare-flat'.")
1387 (defvar gnus-group-prepare-hook nil
1388 "*A hook called after the group buffer has been generated.
1389 If you want to modify the group buffer, you can use this hook.")
1391 (defvar gnus-summary-prepare-hook nil
1392 "*A hook called after the summary buffer has been generated.
1393 If you want to modify the summary buffer, you can use this hook.")
1395 (defvar gnus-summary-generate-hook nil
1396 "*A hook run just before generating the summary buffer.
1397 This hook is commonly used to customize threading variables and the
1400 (defvar gnus-article-prepare-hook nil
1401 "*A hook called after an article has been prepared in the article buffer.
1402 If you want to run a special decoding program like nkf, use this hook.")
1404 ;(defvar gnus-article-display-hook nil
1405 ; "*A hook called after the article is displayed in the article buffer.
1406 ;The hook is designed to change the contents of the article
1407 ;buffer. Typical functions that this hook may contain are
1408 ;`gnus-article-hide-headers' (hide selected headers),
1409 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1410 ;`gnus-article-hide-signature' (hide signature) and
1411 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1412 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1413 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1414 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1416 (defvar gnus-article-x-face-command
1417 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1418 "String or function to be executed to display an X-Face header.
1419 If it is a string, the command will be executed in a sub-shell
1420 asynchronously. The compressed face will be piped to this command.")
1422 (defvar gnus-article-x-face-too-ugly nil
1423 "Regexp matching posters whose face shouldn't be shown automatically.")
1425 (defvar gnus-select-group-hook nil
1426 "*A hook called when a newsgroup is selected.
1428 If you'd like to simplify subjects like the
1429 `gnus-summary-next-same-subject' command does, you can use the
1432 (setq gnus-select-group-hook
1435 (mapcar (lambda (header)
1436 (mail-header-set-subject
1438 (gnus-simplify-subject
1439 (mail-header-subject header) 're-only)))
1440 gnus-newsgroup-headers))))")
1442 (defvar gnus-select-article-hook nil
1443 "*A hook called when an article is selected.")
1445 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1446 "*A hook called to apply kill files to a group.
1447 This hook is intended to apply a kill file to the selected newsgroup.
1448 The function `gnus-apply-kill-file' is called by default.
1450 Since a general kill file is too heavy to use only for a few
1451 newsgroups, I recommend you to use a lighter hook function. For
1452 example, if you'd like to apply a kill file to articles which contains
1453 a string `rmgroup' in subject in newsgroup `control', you can use the
1456 (setq gnus-apply-kill-hook
1459 (cond ((string-match \"control\" gnus-newsgroup-name)
1460 (gnus-kill \"Subject\" \"rmgroup\")
1461 (gnus-expunge \"X\"))))))")
1463 (defvar gnus-visual-mark-article-hook
1464 (list 'gnus-highlight-selected-summary)
1465 "*Hook run after selecting an article in the summary buffer.
1466 It is meant to be used for highlighting the article in some way. It
1467 is not run if `gnus-visual' is nil.")
1469 (defvar gnus-parse-headers-hook nil
1470 "*A hook called before parsing the headers.")
1471 (add-hook 'gnus-parse-headers-hook 'gnus-headers-decode-quoted-printable)
1473 (defvar gnus-exit-group-hook nil
1474 "*A hook called when exiting (not quitting) summary mode.")
1476 (defvar gnus-suspend-gnus-hook nil
1477 "*A hook called when suspending (not exiting) Gnus.")
1479 (defvar gnus-exit-gnus-hook nil
1480 "*A hook called when exiting Gnus.")
1482 (defvar gnus-after-exiting-gnus-hook nil
1483 "*A hook called after exiting Gnus.")
1485 (defvar gnus-save-newsrc-hook nil
1486 "*A hook called before saving any of the newsrc files.")
1488 (defvar gnus-save-quick-newsrc-hook nil
1489 "*A hook called just before saving the quick newsrc file.
1490 Can be used to turn version control on or off.")
1492 (defvar gnus-save-standard-newsrc-hook nil
1493 "*A hook called just before saving the standard newsrc file.
1494 Can be used to turn version control on or off.")
1496 (defvar gnus-summary-update-hook
1497 (list 'gnus-summary-highlight-line)
1498 "*A hook called when a summary line is changed.
1499 The hook will not be called if `gnus-visual' is nil.
1501 The default function `gnus-summary-highlight-line' will
1502 highlight the line according to the `gnus-summary-highlight'
1505 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1506 "*A hook called when a group line is changed.
1507 The hook will not be called if `gnus-visual' is nil.
1509 The default function `gnus-group-highlight-line' will
1510 highlight the line according to the `gnus-group-highlight'
1513 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1514 "*A hook called when an article is selected for the first time.
1515 The hook is intended to mark an article as read (or unread)
1516 automatically when it is selected.")
1518 (defvar gnus-group-change-level-function nil
1519 "Function run when a group level is changed.
1520 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1522 ;; Remove any hilit infestation.
1523 (add-hook 'gnus-startup-hook
1525 (remove-hook 'gnus-summary-prepare-hook
1526 'hilit-rehighlight-buffer-quietly)
1527 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1528 (setq gnus-mark-article-hook
1529 '(gnus-summary-mark-read-and-unread-as-read))
1530 (remove-hook 'gnus-article-prepare-hook
1531 'hilit-rehighlight-buffer-quietly)))
1534 ;; Internal variables
1537 (defvar gnus-use-generic-from nil)
1539 (defvar gnus-thread-indent-array nil)
1540 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1542 (defvar gnus-newsrc-file-version nil)
1544 (defvar gnus-method-history nil)
1545 ;; Variable holding the user answers to all method prompts.
1547 (defvar gnus-group-history nil)
1548 ;; Variable holding the user answers to all group prompts.
1550 (defvar gnus-server-alist nil
1551 "List of available servers.")
1553 (defvar gnus-group-indentation-function nil)
1555 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1557 (defvar gnus-goto-missing-group-function nil)
1559 (defvar gnus-override-subscribe-method nil)
1561 (defvar gnus-group-goto-next-group-function nil
1562 "Function to override finding the next group after listing groups.")
1564 (defconst gnus-article-mark-lists
1565 '((marked . tick) (replied . reply)
1566 (expirable . expire) (killed . killed)
1567 (bookmarks . bookmark) (dormant . dormant)
1568 (scored . score) (saved . save)
1572 ;; Avoid highlighting in kill files.
1573 (defvar gnus-summary-inhibit-highlight nil)
1574 (defvar gnus-newsgroup-selected-overlay nil)
1576 (defvar gnus-inhibit-hiding nil)
1577 (defvar gnus-group-indentation "")
1578 (defvar gnus-inhibit-limiting nil)
1579 (defvar gnus-created-frames nil)
1581 (defvar gnus-article-mode-map nil)
1582 (defvar gnus-dribble-buffer nil)
1583 (defvar gnus-headers-retrieved-by nil)
1584 (defvar gnus-article-reply nil)
1585 (defvar gnus-override-method nil)
1586 (defvar gnus-article-check-size nil)
1588 (defvar gnus-current-score-file nil)
1589 (defvar gnus-newsgroup-adaptive-score-file nil)
1590 (defvar gnus-scores-exclude-files nil)
1592 (defvar gnus-opened-servers nil)
1594 (defvar gnus-current-move-group nil)
1596 (defvar gnus-newsgroup-dependencies nil)
1597 (defvar gnus-newsgroup-async nil)
1598 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1600 (defvar gnus-newsgroup-adaptive nil)
1602 (defvar gnus-summary-display-table nil)
1603 (defvar gnus-summary-display-article-function nil)
1605 (defvar gnus-summary-highlight-line-function nil
1606 "Function called after highlighting a summary line.")
1608 (defvar gnus-group-line-format-alist
1609 `((?M gnus-tmp-marked-mark ?c)
1610 (?S gnus-tmp-subscribed ?c)
1611 (?L gnus-tmp-level ?d)
1612 (?N (cond ((eq number t) "*" )
1616 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1617 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1619 (?R gnus-tmp-number-of-read ?s)
1620 (?t gnus-tmp-number-total ?d)
1621 (?y gnus-tmp-number-of-unread ?s)
1622 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1623 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1624 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1625 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1626 (?g gnus-tmp-group ?s)
1627 (?G gnus-tmp-qualified-group ?s)
1628 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1629 (?D gnus-tmp-newsgroup-description ?s)
1630 (?o gnus-tmp-moderated ?c)
1631 (?O gnus-tmp-moderated-string ?s)
1632 (?p gnus-tmp-process-marked ?c)
1633 (?s gnus-tmp-news-server ?s)
1634 (?n gnus-tmp-news-method ?s)
1635 (?P gnus-group-indentation ?s)
1636 (?l gnus-tmp-grouplens ?s)
1637 (?z gnus-tmp-news-method-string ?s)
1638 (?u gnus-tmp-user-defined ?s)))
1640 (defvar gnus-summary-line-format-alist
1641 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1642 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1643 (?s gnus-tmp-subject-or-nil ?s)
1644 (?n gnus-tmp-name ?s)
1645 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1647 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1649 (?F gnus-tmp-from ?s)
1650 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1651 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1652 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1653 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1654 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1655 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1656 (?L gnus-tmp-lines ?d)
1657 (?I gnus-tmp-indentation ?s)
1658 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1659 (?R gnus-tmp-replied ?c)
1660 (?\[ gnus-tmp-opening-bracket ?c)
1661 (?\] gnus-tmp-closing-bracket ?c)
1662 (?\> (make-string gnus-tmp-level ? ) ?s)
1663 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1664 (?i gnus-tmp-score ?d)
1665 (?z gnus-tmp-score-char ?c)
1666 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1667 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1668 (?U gnus-tmp-unread ?c)
1669 (?t (gnus-summary-number-of-articles-in-thread
1670 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1672 (?e (gnus-summary-number-of-articles-in-thread
1673 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1675 (?u gnus-tmp-user-defined ?s))
1676 "An alist of format specifications that can appear in summary lines,
1677 and what variables they correspond with, along with the type of the
1678 variable (string, integer, character, etc).")
1680 (defvar gnus-summary-dummy-line-format-alist
1681 `((?S gnus-tmp-subject ?s)
1682 (?N gnus-tmp-number ?d)
1683 (?u gnus-tmp-user-defined ?s)))
1685 (defvar gnus-summary-mode-line-format-alist
1686 `((?G gnus-tmp-group-name ?s)
1687 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1688 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1689 (?A gnus-tmp-article-number ?d)
1690 (?Z gnus-tmp-unread-and-unselected ?s)
1691 (?V gnus-version ?s)
1692 (?U gnus-tmp-unread ?d)
1693 (?S gnus-tmp-subject ?s)
1694 (?e gnus-tmp-unselected ?d)
1695 (?u gnus-tmp-user-defined ?s)
1696 (?d (length gnus-newsgroup-dormant) ?d)
1697 (?t (length gnus-newsgroup-marked) ?d)
1698 (?r (length gnus-newsgroup-reads) ?d)
1699 (?E gnus-newsgroup-expunged-tally ?d)
1700 (?s (gnus-current-score-file-nondirectory) ?s)))
1702 (defvar gnus-article-mode-line-format-alist
1703 gnus-summary-mode-line-format-alist)
1705 (defvar gnus-group-mode-line-format-alist
1706 `((?S gnus-tmp-news-server ?s)
1707 (?M gnus-tmp-news-method ?s)
1708 (?u gnus-tmp-user-defined ?s)))
1710 (defvar gnus-have-read-active-file nil)
1712 (defconst gnus-maintainer
1713 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1714 "The mail address of the Gnus maintainers.")
1716 (defconst gnus-version "September Gnus v0.79"
1717 "Version number for this version of Gnus.")
1719 (defvar gnus-info-nodes
1720 '((gnus-group-mode "(gnus)The Group Buffer")
1721 (gnus-summary-mode "(gnus)The Summary Buffer")
1722 (gnus-article-mode "(gnus)The Article Buffer"))
1723 "Assoc list of major modes and related Info nodes.")
1725 (defvar gnus-group-buffer "*Group*")
1726 (defvar gnus-summary-buffer "*Summary*")
1727 (defvar gnus-article-buffer "*Article*")
1728 (defvar gnus-server-buffer "*Server*")
1730 (defvar gnus-work-buffer " *gnus work*")
1732 (defvar gnus-original-article-buffer " *Original Article*")
1733 (defvar gnus-original-article nil)
1735 (defvar gnus-buffer-list nil
1736 "Gnus buffers that should be killed on exit.")
1738 (defvar gnus-slave nil
1739 "Whether this Gnus is a slave or not.")
1741 (defvar gnus-variable-list
1742 '(gnus-newsrc-options gnus-newsrc-options-n
1743 gnus-newsrc-last-checked-date
1744 gnus-newsrc-alist gnus-server-alist
1745 gnus-killed-list gnus-zombie-list
1746 gnus-topic-topology gnus-topic-alist
1748 "Gnus variables saved in the quick startup file.")
1750 (defvar gnus-newsrc-options nil
1751 "Options line in the .newsrc file.")
1753 (defvar gnus-newsrc-options-n nil
1754 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1756 (defvar gnus-newsrc-last-checked-date nil
1757 "Date Gnus last asked server for new newsgroups.")
1759 (defvar gnus-topic-topology nil
1760 "The complete topic hierarchy.")
1762 (defvar gnus-topic-alist nil
1763 "The complete topic-group alist.")
1765 (defvar gnus-newsrc-alist nil
1766 "Assoc list of read articles.
1767 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1769 (defvar gnus-newsrc-hashtb nil
1770 "Hashtable of gnus-newsrc-alist.")
1772 (defvar gnus-killed-list nil
1773 "List of killed newsgroups.")
1775 (defvar gnus-killed-hashtb nil
1776 "Hash table equivalent of gnus-killed-list.")
1778 (defvar gnus-zombie-list nil
1779 "List of almost dead newsgroups.")
1781 (defvar gnus-description-hashtb nil
1782 "Descriptions of newsgroups.")
1784 (defvar gnus-list-of-killed-groups nil
1785 "List of newsgroups that have recently been killed by the user.")
1787 (defvar gnus-active-hashtb nil
1788 "Hashtable of active articles.")
1790 (defvar gnus-moderated-list nil
1791 "List of moderated newsgroups.")
1793 (defvar gnus-group-marked nil)
1795 (defvar gnus-current-startup-file nil
1796 "Startup file for the current host.")
1798 (defvar gnus-last-search-regexp nil
1799 "Default regexp for article search command.")
1801 (defvar gnus-last-shell-command nil
1802 "Default shell command on article.")
1804 (defvar gnus-current-select-method nil
1805 "The current method for selecting a newsgroup.")
1807 (defvar gnus-group-list-mode nil)
1809 (defvar gnus-article-internal-prepare-hook nil)
1811 (defvar gnus-newsgroup-name nil)
1812 (defvar gnus-newsgroup-begin nil)
1813 (defvar gnus-newsgroup-end nil)
1814 (defvar gnus-newsgroup-last-rmail nil)
1815 (defvar gnus-newsgroup-last-mail nil)
1816 (defvar gnus-newsgroup-last-folder nil)
1817 (defvar gnus-newsgroup-last-file nil)
1818 (defvar gnus-newsgroup-auto-expire nil)
1819 (defvar gnus-newsgroup-active nil)
1821 (defvar gnus-newsgroup-data nil)
1822 (defvar gnus-newsgroup-data-reverse nil)
1823 (defvar gnus-newsgroup-limit nil)
1824 (defvar gnus-newsgroup-limits nil)
1826 (defvar gnus-newsgroup-unreads nil
1827 "List of unread articles in the current newsgroup.")
1829 (defvar gnus-newsgroup-unselected nil
1830 "List of unselected unread articles in the current newsgroup.")
1832 (defvar gnus-newsgroup-reads nil
1833 "Alist of read articles and article marks in the current newsgroup.")
1835 (defvar gnus-newsgroup-expunged-tally nil)
1837 (defvar gnus-newsgroup-marked nil
1838 "List of ticked articles in the current newsgroup (a subset of unread art).")
1840 (defvar gnus-newsgroup-killed nil
1841 "List of ranges of articles that have been through the scoring process.")
1843 (defvar gnus-newsgroup-cached nil
1844 "List of articles that come from the article cache.")
1846 (defvar gnus-newsgroup-saved nil
1847 "List of articles that have been saved.")
1849 (defvar gnus-newsgroup-kill-headers nil)
1851 (defvar gnus-newsgroup-replied nil
1852 "List of articles that have been replied to in the current newsgroup.")
1854 (defvar gnus-newsgroup-expirable nil
1855 "List of articles in the current newsgroup that can be expired.")
1857 (defvar gnus-newsgroup-processable nil
1858 "List of articles in the current newsgroup that can be processed.")
1860 (defvar gnus-newsgroup-bookmarks nil
1861 "List of articles in the current newsgroup that have bookmarks.")
1863 (defvar gnus-newsgroup-dormant nil
1864 "List of dormant articles in the current newsgroup.")
1866 (defvar gnus-newsgroup-scored nil
1867 "List of scored articles in the current newsgroup.")
1869 (defvar gnus-newsgroup-headers nil
1870 "List of article headers in the current newsgroup.")
1872 (defvar gnus-newsgroup-threads nil)
1874 (defvar gnus-newsgroup-prepared nil
1875 "Whether the current group has been prepared properly.")
1877 (defvar gnus-newsgroup-ancient nil
1878 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1880 (defvar gnus-newsgroup-sparse nil)
1882 (defvar gnus-current-article nil)
1883 (defvar gnus-article-current nil)
1884 (defvar gnus-current-headers nil)
1885 (defvar gnus-have-all-headers nil)
1886 (defvar gnus-last-article nil)
1887 (defvar gnus-newsgroup-history nil)
1888 (defvar gnus-current-kill-article nil)
1890 ;; Save window configuration.
1891 (defvar gnus-prev-winconf nil)
1893 (defvar gnus-summary-mark-positions nil)
1894 (defvar gnus-group-mark-positions nil)
1896 (defvar gnus-reffed-article-number nil)
1898 ;;; Let the byte-compiler know that we know about this variable.
1899 (defvar rmail-default-rmail-file)
1901 (defvar gnus-cache-removable-articles nil)
1903 (defvar gnus-dead-summary nil)
1905 (defconst gnus-summary-local-variables
1906 '(gnus-newsgroup-name
1907 gnus-newsgroup-begin gnus-newsgroup-end
1908 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1909 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1910 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1911 gnus-newsgroup-unselected gnus-newsgroup-marked
1912 gnus-newsgroup-reads gnus-newsgroup-saved
1913 gnus-newsgroup-replied gnus-newsgroup-expirable
1914 gnus-newsgroup-processable gnus-newsgroup-killed
1915 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1916 gnus-newsgroup-headers gnus-newsgroup-threads
1917 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1918 gnus-current-article gnus-current-headers gnus-have-all-headers
1919 gnus-last-article gnus-article-internal-prepare-hook
1920 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1921 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1922 gnus-newsgroup-async gnus-thread-expunge-below
1923 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1924 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1925 gnus-newsgroup-history gnus-newsgroup-ancient
1926 gnus-newsgroup-sparse
1927 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1928 gnus-newsgroup-adaptive-score-file
1929 (gnus-newsgroup-expunged-tally . 0)
1930 gnus-cache-removable-articles gnus-newsgroup-cached
1931 gnus-newsgroup-data gnus-newsgroup-data-reverse
1932 gnus-newsgroup-limit gnus-newsgroup-limits)
1933 "Variables that are buffer-local to the summary buffers.")
1935 (defconst gnus-bug-message
1936 "Sending a bug report to the Gnus Towers.
1937 ========================================
1939 The buffer below is a mail buffer. When you press `C-c C-c', it will
1940 be sent to the Gnus Bug Exterminators.
1942 At the bottom of the buffer you'll see lots of variable settings.
1943 Please do not delete those. They will tell the Bug People what your
1944 environment is, so that it will be easier to locate the bugs.
1946 If you have found a bug that makes Emacs go \"beep\", set
1947 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1948 and include the backtrace in your bug report.
1950 Please describe the bug in annoying, painstaking detail.
1952 Thank you for your help in stamping out bugs.
1955 ;;; End of variables.
1957 ;; Define some autoload functions Gnus might use.
1960 ;; This little mapcar goes through the list below and marks the
1961 ;; symbols in question as autoloaded functions.
1964 (let ((interactive (nth 1 (memq ':interactive package))))
1968 (when (consp function)
1969 (setq keymap (car (memq 'keymap function)))
1970 (setq function (car function)))
1971 (autoload function (car package) nil interactive keymap)))
1972 (if (eq (nth 1 package) ':interactive)
1975 '(("metamail" metamail-buffer)
1976 ("info" Info-goto-node)
1977 ("hexl" hexl-hex-string-to-integer)
1978 ("pp" pp pp-to-string pp-eval-expression)
1979 ("mail-extr" mail-extract-address-components)
1980 ("nnmail" nnmail-split-fancy nnmail-article-group)
1981 ("nnvirtual" nnvirtual-catchup-group)
1982 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1983 timezone-make-sortable-date timezone-make-time-string)
1984 ("sendmail" mail-position-on-field mail-setup)
1985 ("rmailout" rmail-output)
1986 ("rnewspost" news-mail-other-window news-reply-yank-original
1987 news-caesar-buffer-body)
1988 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1990 ("gnus-soup" :interactive t
1991 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1992 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1993 ("nnsoup" nnsoup-pack-replies)
1994 ("gnus-scomo" :interactive t gnus-score-mode)
1995 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1996 gnus-Folder-save-name gnus-folder-save-name)
1997 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1998 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1999 gnus-server-make-menu-bar gnus-article-make-menu-bar
2000 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2001 gnus-summary-highlight-line gnus-carpal-setup-buffer
2002 gnus-group-highlight-line
2003 gnus-article-add-button gnus-insert-next-page-button
2004 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2005 ("gnus-vis" :interactive t
2006 gnus-article-push-button gnus-article-press-button
2007 gnus-article-highlight gnus-article-highlight-some
2008 gnus-article-highlight-headers gnus-article-highlight-signature
2009 gnus-article-add-buttons gnus-article-add-buttons-to-head
2010 gnus-article-next-button gnus-article-prev-button)
2011 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2012 gnus-demon-add-disconnection gnus-demon-add-handler
2013 gnus-demon-remove-handler)
2014 ("gnus-demon" :interactive t
2015 gnus-demon-init gnus-demon-cancel)
2016 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2017 gnus-tree-open gnus-tree-close)
2018 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2019 gnus-nocem-unwanted-article-p)
2020 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2021 ("gnus-srvr" gnus-browse-foreign-server)
2022 ("gnus-cite" :interactive t
2023 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2024 gnus-article-hide-citation gnus-article-fill-cited-article)
2025 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2026 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2027 gnus-execute gnus-expunge)
2028 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2029 gnus-cache-possibly-remove-articles gnus-cache-request-article
2030 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2031 gnus-cache-enter-remove-article gnus-cached-article-p
2032 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2033 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2034 gnus-cache-remove-article)
2035 ("gnus-score" :interactive t
2036 gnus-summary-increase-score gnus-summary-lower-score
2037 gnus-score-flush-cache gnus-score-close
2038 gnus-score-raise-same-subject-and-select
2039 gnus-score-raise-same-subject gnus-score-default
2040 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2041 gnus-score-lower-same-subject gnus-score-lower-thread
2042 gnus-possibly-score-headers)
2044 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2045 gnus-current-score-file-nondirectory gnus-score-adaptive
2046 gnus-score-find-trace gnus-score-file-name)
2047 ("gnus-edit" :interactive t gnus-score-customize)
2048 ("gnus-topic" :interactive t gnus-topic-mode)
2049 ("gnus-topic" gnus-topic-remove-group)
2050 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2051 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2052 ("gnus-uu" :interactive t
2053 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2054 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2055 gnus-uu-mark-by-regexp gnus-uu-mark-all
2056 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2057 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2058 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2059 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2060 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2061 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2062 gnus-uu-decode-binhex-view)
2063 ("gnus-msg" (gnus-summary-send-map keymap)
2064 gnus-mail-yank-original gnus-mail-send-and-exit
2065 gnus-sendmail-setup-mail gnus-article-mail
2066 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2067 ("gnus-msg" :interactive t
2068 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2069 gnus-summary-followup gnus-summary-followup-with-original
2070 gnus-summary-followup-and-reply
2071 gnus-summary-followup-and-reply-with-original
2072 gnus-summary-cancel-article gnus-summary-supersede-article
2073 gnus-post-news gnus-inews-news gnus-cancel-news
2074 gnus-summary-reply gnus-summary-reply-with-original
2075 gnus-summary-mail-forward gnus-summary-mail-other-window
2077 ("gnus-picon" :interactive t gnus-article-display-picons
2078 gnus-group-display-picons gnus-picons-article-display-x-face)
2079 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2080 gnus-grouplens-mode)
2081 ("gnus-vm" gnus-vm-mail-setup)
2082 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2083 gnus-summary-save-article-vm gnus-yank-article))))
2087 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2088 ;; If you want the cursor to go somewhere else, set these two
2089 ;; functions in some startup hook to whatever you want.
2090 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2091 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2093 ;;; Various macros and substs.
2095 (defun gnus-header-from (header)
2096 (mail-header-from header))
2098 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2099 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2100 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2101 `(let ((,tempvar (selected-window)))
2104 (pop-to-buffer ,buffer)
2106 (select-window ,tempvar)))))
2108 (defmacro gnus-gethash (string hashtable)
2109 "Get hash value of STRING in HASHTABLE."
2110 `(symbol-value (intern-soft ,string ,hashtable)))
2112 (defmacro gnus-sethash (string value hashtable)
2113 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2114 `(set (intern ,string ,hashtable) ,value))
2116 (defmacro gnus-intern-safe (string hashtable)
2117 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2118 `(let ((symbol (intern ,string ,hashtable)))
2123 (defmacro gnus-group-unread (group)
2124 "Get the currently computed number of unread articles in GROUP."
2125 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2127 (defmacro gnus-group-entry (group)
2128 "Get the newsrc entry for GROUP."
2129 `(gnus-gethash ,group gnus-newsrc-hashtb))
2131 (defmacro gnus-active (group)
2132 "Get active info on GROUP."
2133 `(gnus-gethash ,group gnus-active-hashtb))
2135 (defmacro gnus-set-active (group active)
2136 "Set GROUP's active info."
2137 `(gnus-sethash ,group ,active gnus-active-hashtb))
2139 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2140 ;; function `substring' might cut on a middle of multi-octet
2142 (defun gnus-truncate-string (str width)
2143 (substring str 0 width))
2145 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2146 ;; to limit the length of a string. This function is necessary since
2147 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2148 (defsubst gnus-limit-string (str width)
2149 (if (> (length str) width)
2150 (substring str 0 width)
2153 (defsubst gnus-simplify-subject-re (subject)
2154 "Remove \"Re:\" from subject lines."
2155 (if (string-match "^[Rr][Ee]: *" subject)
2156 (substring subject (match-end 0))
2159 (defsubst gnus-functionp (form)
2160 "Return non-nil if FORM is funcallable."
2161 (or (and (symbolp form) (fboundp form))
2162 (and (listp form) (eq (car form) 'lambda))))
2164 (defsubst gnus-goto-char (point)
2165 (and point (goto-char point)))
2167 (defmacro gnus-buffer-exists-p (buffer)
2168 `(let ((buffer ,buffer))
2170 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2173 (defmacro gnus-kill-buffer (buffer)
2174 `(let ((buf ,buffer))
2175 (if (gnus-buffer-exists-p buf)
2176 (kill-buffer buf))))
2178 (defsubst gnus-point-at-bol ()
2179 "Return point at the beginning of the line."
2186 (defsubst gnus-point-at-eol ()
2187 "Return point at the end of the line."
2194 (defun gnus-alive-p ()
2195 "Say whether Gnus is running or not."
2196 (and gnus-group-buffer
2197 (get-buffer gnus-group-buffer)))
2199 ;; Delete the current line (and the next N lines.);
2200 (defmacro gnus-delete-line (&optional n)
2201 `(delete-region (progn (beginning-of-line) (point))
2202 (progn (forward-line ,(or n 1)) (point))))
2204 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2205 (defvar gnus-init-inhibit nil)
2206 (defun gnus-read-init-file (&optional inhibit-next)
2207 (if gnus-init-inhibit
2208 (setq gnus-init-inhibit nil)
2209 (setq gnus-init-inhibit inhibit-next)
2211 (or (and (file-exists-p gnus-init-file)
2212 ;; Don't try to load a directory.
2213 (not (file-directory-p gnus-init-file)))
2214 (file-exists-p (concat gnus-init-file ".el"))
2215 (file-exists-p (concat gnus-init-file ".elc")))
2217 (load gnus-init-file nil t)
2219 (error "Error in %s: %s" gnus-init-file var))))))
2221 ;; Info access macros.
2223 (defmacro gnus-info-group (info)
2225 (defmacro gnus-info-rank (info)
2227 (defmacro gnus-info-read (info)
2229 (defmacro gnus-info-marks (info)
2231 (defmacro gnus-info-method (info)
2233 (defmacro gnus-info-params (info)
2236 (defmacro gnus-info-level (info)
2237 `(let ((rank (gnus-info-rank ,info)))
2241 (defmacro gnus-info-score (info)
2242 `(let ((rank (gnus-info-rank ,info)))
2243 (or (and (consp rank) (cdr rank)) 0)))
2245 (defmacro gnus-info-set-group (info group)
2246 `(setcar ,info ,group))
2247 (defmacro gnus-info-set-rank (info rank)
2248 `(setcar (nthcdr 1 ,info) ,rank))
2249 (defmacro gnus-info-set-read (info read)
2250 `(setcar (nthcdr 2 ,info) ,read))
2251 (defmacro gnus-info-set-marks (info marks)
2252 `(setcar (nthcdr 3 ,info) ,marks))
2253 (defmacro gnus-info-set-method (info method)
2254 `(setcar (nthcdr 4 ,info) ,method))
2255 (defmacro gnus-info-set-params (info params)
2256 `(setcar (nthcdr 5 ,info) ,params))
2258 (defmacro gnus-info-set-level (info level)
2259 `(let ((rank (cdr ,info)))
2260 (if (consp (car rank))
2261 (setcar (car rank) ,level)
2262 (setcar rank ,level))))
2263 (defmacro gnus-info-set-score (info score)
2264 `(let ((rank (cdr ,info)))
2265 (if (consp (car rank))
2266 (setcdr (car rank) ,score)
2267 (setcar rank (cons (car rank) ,score)))))
2269 (defmacro gnus-get-info (group)
2270 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2272 (defun gnus-byte-code (func)
2273 "Return a form that can be `eval'ed based on FUNC."
2274 (let ((fval (symbol-function func)))
2275 (if (byte-code-function-p fval)
2276 (let ((flist (append fval nil)))
2277 (setcar flist 'byte-code)
2279 (cons 'progn (cddr fval)))))
2281 ;;; Load the compatability functions.
2291 (defvar gnus-shutdown-alist nil)
2293 (defun gnus-add-shutdown (function &rest symbols)
2294 "Run FUNCTION whenever one of SYMBOLS is shut down."
2295 (push (cons function symbols) gnus-shutdown-alist))
2297 (defun gnus-shutdown (symbol)
2298 "Shut down everything that waits for SYMBOL."
2299 (let ((alist gnus-shutdown-alist)
2301 (while (setq entry (pop alist))
2302 (when (memq symbol (cdr entry))
2303 (funcall (car entry))))))
2307 ;; Format specs. The chunks below are the machine-generated forms
2308 ;; that are to be evaled as the result of the default format strings.
2309 ;; We write them in here to get them byte-compiled. That way the
2310 ;; default actions will be quite fast, while still retaining the full
2311 ;; flexibility of the user-defined format specs.
2313 ;; First we have lots of dummy defvars to let the compiler know these
2314 ;; are really dynamic variables.
2316 (defvar gnus-tmp-unread)
2317 (defvar gnus-tmp-replied)
2318 (defvar gnus-tmp-score-char)
2319 (defvar gnus-tmp-indentation)
2320 (defvar gnus-tmp-opening-bracket)
2321 (defvar gnus-tmp-lines)
2322 (defvar gnus-tmp-name)
2323 (defvar gnus-tmp-closing-bracket)
2324 (defvar gnus-tmp-subject-or-nil)
2325 (defvar gnus-tmp-subject)
2326 (defvar gnus-tmp-marked)
2327 (defvar gnus-tmp-marked-mark)
2328 (defvar gnus-tmp-subscribed)
2329 (defvar gnus-tmp-process-marked)
2330 (defvar gnus-tmp-number-of-unread)
2331 (defvar gnus-tmp-group-name)
2332 (defvar gnus-tmp-group)
2333 (defvar gnus-tmp-article-number)
2334 (defvar gnus-tmp-unread-and-unselected)
2335 (defvar gnus-tmp-news-method)
2336 (defvar gnus-tmp-news-server)
2337 (defvar gnus-tmp-article-number)
2338 (defvar gnus-mouse-face)
2339 (defvar gnus-mouse-face-prop)
2341 (defun gnus-summary-line-format-spec ()
2342 (insert gnus-tmp-unread gnus-tmp-replied
2343 gnus-tmp-score-char gnus-tmp-indentation)
2348 gnus-tmp-opening-bracket
2349 (format "%4d: %-20s"
2351 (if (> (length gnus-tmp-name) 20)
2352 (substring gnus-tmp-name 0 20)
2354 gnus-tmp-closing-bracket)
2356 gnus-mouse-face-prop gnus-mouse-face)
2357 (insert " " gnus-tmp-subject-or-nil "\n"))
2359 (defvar gnus-summary-line-format-spec
2360 (gnus-byte-code 'gnus-summary-line-format-spec))
2362 (defun gnus-summary-dummy-line-format-spec ()
2369 gnus-mouse-face-prop gnus-mouse-face)
2370 (insert " " gnus-tmp-subject "\n"))
2372 (defvar gnus-summary-dummy-line-format-spec
2373 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2375 (defun gnus-group-line-format-spec ()
2376 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2377 gnus-tmp-process-marked
2378 gnus-group-indentation
2379 (format "%5s: " gnus-tmp-number-of-unread))
2383 (insert gnus-tmp-group "\n")
2385 gnus-mouse-face-prop gnus-mouse-face))
2386 (defvar gnus-group-line-format-spec
2387 (gnus-byte-code 'gnus-group-line-format-spec))
2389 (defvar gnus-format-specs
2390 `((version . ,emacs-version)
2391 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2392 (summary-dummy ,gnus-summary-dummy-line-format
2393 ,gnus-summary-dummy-line-format-spec)
2394 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2396 (defvar gnus-article-mode-line-format-spec nil)
2397 (defvar gnus-summary-mode-line-format-spec nil)
2398 (defvar gnus-group-mode-line-format-spec nil)
2400 ;;; Phew. All that gruft is over, fortunately.
2404 ;;; Gnus Utility Functions
2407 (defun gnus-extract-address-components (from)
2409 ;; First find the address - the thing with the @ in it. This may
2410 ;; not be accurate in mail addresses, but does the trick most of
2411 ;; the time in news messages.
2412 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2413 (setq address (substring from (match-beginning 0) (match-end 0))))
2414 ;; Then we check whether the "name <address>" format is used.
2416 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2417 ;; Linear white space is not required.
2418 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2419 (and (setq name (substring from 0 (match-beginning 0)))
2420 ;; Strip any quotes from the name.
2421 (string-match "\".*\"" name)
2422 (setq name (substring name 1 (1- (match-end 0))))))
2423 ;; If not, then "address (name)" is used.
2425 (and (string-match "(.+)" from)
2426 (setq name (substring from (1+ (match-beginning 0))
2427 (1- (match-end 0)))))
2428 (and (string-match "()" from)
2429 (setq name address))
2430 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2431 ;; XOVER might not support folded From headers.
2432 (and (string-match "(.*" from)
2433 (setq name (substring from (1+ (match-beginning 0))
2435 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2436 (list (or name from) (or address from))))
2438 (defun gnus-fetch-field (field)
2439 "Return the value of the header FIELD of current article."
2442 (let ((case-fold-search t)
2443 (inhibit-point-motion-hooks t))
2444 (nnheader-narrow-to-headers)
2445 (mail-fetch-field field)))))
2447 (defun gnus-goto-colon ()
2449 (search-forward ":" (gnus-point-at-eol) t))
2452 (defun gnus-update-format (var)
2453 "Update the format specification near point."
2458 ;; Find the end of the current word.
2459 (re-search-forward "[ \t\n]" nil t)
2461 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2462 (match-string 1)))))
2463 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2464 (match-string 1 var))))
2465 (entry (assq type gnus-format-specs))
2468 (setq gnus-format-specs (delq entry gnus-format-specs)))
2470 (intern (format "%s-spec" var))
2471 (gnus-parse-format (setq value (symbol-value (intern var)))
2472 (symbol-value (intern (format "%s-alist" var)))
2473 (not (string-match "mode" var))))
2474 (setq spec (symbol-value (intern (format "%s-spec" var))))
2475 (push (list type value spec) gnus-format-specs)
2477 (pop-to-buffer "*Gnus Format*")
2479 (lisp-interaction-mode)
2480 (insert (pp-to-string spec))))
2482 (defun gnus-update-format-specifications (&optional force)
2483 "Update all (necessary) format specifications."
2484 ;; Make the indentation array.
2485 (gnus-make-thread-indent-array)
2487 ;; See whether all the stored info needs to be flushed.
2489 (not (equal emacs-version
2490 (cdr (assq 'version gnus-format-specs)))))
2491 (setq gnus-format-specs nil))
2493 ;; Go through all the formats and see whether they need updating.
2494 (let ((types '(summary summary-dummy group
2495 summary-mode group-mode article-mode))
2496 new-format entry type val)
2497 (while (setq type (pop types))
2498 ;; Jump to the proper buffer to find out the value of
2499 ;; the variable, if possible. (It may be buffer-local.)
2501 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2503 (when (and (boundp buffer)
2504 (setq val (symbol-value buffer))
2506 (buffer-name (get-buffer val)))
2507 (set-buffer (get-buffer val)))
2508 (setq new-format (symbol-value
2509 (intern (format "gnus-%s-line-format" type))))))
2510 (setq entry (cdr (assq type gnus-format-specs)))
2512 (equal (car entry) new-format))
2513 ;; Use the old format.
2514 (set (intern (format "gnus-%s-line-format-spec" type))
2516 ;; This is a new format.
2518 (if (not (stringp new-format))
2519 ;; This is a function call or something.
2521 ;; This is a "real" format.
2525 (intern (format "gnus-%s-line-format-alist"
2526 (if (eq type 'article-mode)
2527 'summary-mode type))))
2528 (not (string-match "mode$" (symbol-name type))))))
2529 ;; Enter the new format spec into the list.
2532 (setcar (cdr entry) val)
2533 (setcar entry new-format))
2534 (push (list type new-format val) gnus-format-specs))
2535 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2537 (unless (assq 'version gnus-format-specs)
2538 (push (cons 'version emacs-version) gnus-format-specs))
2540 (gnus-update-group-mark-positions)
2541 (gnus-update-summary-mark-positions))
2543 (defun gnus-update-summary-mark-positions ()
2544 "Compute where the summary marks are to go."
2546 (when (and gnus-summary-buffer
2547 (get-buffer gnus-summary-buffer)
2548 (buffer-name (get-buffer gnus-summary-buffer)))
2549 (set-buffer gnus-summary-buffer))
2550 (let ((gnus-replied-mark 129)
2551 (gnus-score-below-mark 130)
2552 (gnus-score-over-mark 130)
2555 (spec gnus-summary-line-format-spec)
2557 (gnus-set-work-buffer)
2558 (let ((gnus-summary-line-format-spec spec))
2559 (gnus-summary-insert-line
2560 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2561 (goto-char (point-min))
2562 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2564 (goto-char (point-min))
2565 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2567 (goto-char (point-min))
2568 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2570 (setq gnus-summary-mark-positions pos)))))
2572 (defun gnus-update-group-mark-positions ()
2574 (let ((gnus-process-mark 128)
2575 (gnus-group-marked '("dummy.group")))
2576 (gnus-set-active "dummy.group" '(0 . 0))
2577 (gnus-set-work-buffer)
2578 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2579 (goto-char (point-min))
2580 (setq gnus-group-mark-positions
2581 (list (cons 'process (and (search-forward "\200" nil t)
2582 (- (point) 2))))))))
2584 (defvar gnus-mouse-face-0 'highlight)
2585 (defvar gnus-mouse-face-1 'highlight)
2586 (defvar gnus-mouse-face-2 'highlight)
2587 (defvar gnus-mouse-face-3 'highlight)
2588 (defvar gnus-mouse-face-4 'highlight)
2590 (defun gnus-mouse-face-function (form type)
2592 (point) (progn ,@form (point))
2593 gnus-mouse-face-prop
2596 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2598 (defvar gnus-face-0 'bold)
2599 (defvar gnus-face-1 'italic)
2600 (defvar gnus-face-2 'bold-italic)
2601 (defvar gnus-face-3 'bold)
2602 (defvar gnus-face-4 'bold)
2604 (defun gnus-face-face-function (form type)
2606 (point) (progn ,@form (point))
2607 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2609 (defun gnus-max-width-function (el max-width)
2610 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2612 `(if (> (length ,el) ,max-width)
2613 (substring ,el 0 ,max-width)
2615 `(let ((val (eval ,el)))
2617 (setq val (int-to-string val)))
2618 (if (> (length val) ,max-width)
2619 (substring val 0 ,max-width)
2622 (defun gnus-parse-format (format spec-alist &optional insert)
2623 ;; This function parses the FORMAT string with the help of the
2624 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2625 ;; string. If the FORMAT string contains the specifiers %( and %)
2626 ;; the text between them will have the mouse-face text property.
2628 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2630 (gnus-parse-complex-format format spec-alist)
2631 ;; This is a simple format.
2632 (gnus-parse-simple-format format spec-alist insert)))
2634 (defun gnus-parse-complex-format (format spec-alist)
2636 (gnus-set-work-buffer)
2638 (goto-char (point-min))
2639 (while (re-search-forward "\"" nil t)
2640 (replace-match "\\\"" nil t))
2641 (goto-char (point-min))
2643 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2644 (let ((number (if (match-beginning 1)
2645 (match-string 1) "0"))
2646 (delim (aref (match-string 2) 0)))
2647 (if (or (= delim ?\() (= delim ?\{))
2648 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2650 (replace-match "\")\""))))
2651 (goto-char (point-max))
2653 (goto-char (point-min))
2654 (let ((form (read (current-buffer))))
2655 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2657 (defun gnus-complex-form-to-spec (form spec-alist)
2662 (gnus-parse-simple-format sform spec-alist t)
2663 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2664 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2668 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2669 ;; This function parses the FORMAT string with the help of the
2670 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2673 spec flist fstring newspec elem beg result dontinsert)
2675 (gnus-set-work-buffer)
2677 (goto-char (point-min))
2678 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2680 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2682 beg (1+ (match-beginning 0)))
2683 ;; First check if there are any specs that look anything like
2684 ;; "%12,12A", ie. with a "max width specification". These have
2685 ;; to be treated specially.
2686 (if (setq beg (match-beginning 1))
2690 (1+ (match-beginning 1)) (match-end 1))))
2692 (setq beg (match-beginning 2)))
2693 ;; Find the specification from `spec-alist'.
2694 (unless (setq elem (cdr (assq spec spec-alist)))
2695 (setq elem '("*" ?s)))
2696 ;; Treat user defined format specifiers specially.
2697 (when (eq (car elem) 'gnus-tmp-user-defined)
2700 (list (intern (concat "gnus-user-format-function-"
2702 'gnus-tmp-header) ?s))
2703 (delete-region (match-beginning 3) (match-end 3)))
2704 (if (not (zerop max-width))
2705 (let ((el (car elem)))
2706 (cond ((= (cadr elem) ?c)
2707 (setq el (list 'char-to-string el)))
2709 (setq el (list 'int-to-string el))))
2710 (setq flist (cons (gnus-max-width-function el max-width)
2714 (setq flist (cons (car elem) flist))
2715 (setq newspec (cadr elem)))))
2716 ;; Remove the old specification (and possibly a ",12" string).
2717 (delete-region beg (match-end 2))
2718 ;; Insert the new specification.
2721 (setq fstring (buffer-substring 1 (point-max))))
2722 ;; Do some postprocessing to increase efficiency.
2727 ((string= fstring "")
2729 ;; Not a format string.
2730 ((not (string-match "%" fstring))
2732 ;; A format string with just a single string spec.
2733 ((string= fstring "%s")
2735 ;; A single character.
2736 ((string= fstring "%c")
2739 ((string= fstring "%d")
2742 (list `(princ ,(car flist)))
2743 (list `(int-to-string ,(car flist)))))
2744 ;; Just lots of chars and strings.
2745 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2747 ;; A single string spec at the beginning of the spec.
2748 ((string-match "\\`%[sc][^%]+\\'" fstring)
2749 (list (car flist) (substring fstring 2)))
2750 ;; A single string spec in the middle of the spec.
2751 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2752 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2753 ;; A single string spec in the end of the spec.
2754 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2755 (list (match-string 1 fstring) (car flist)))
2756 ;; A more complex spec.
2758 (list (cons 'format (cons fstring (nreverse flist)))))))
2764 (cons 'insert result)))
2765 (cond ((stringp result)
2768 (cons 'concat result))
2771 (defun gnus-eval-format (format &optional alist props)
2772 "Eval the format variable FORMAT, using ALIST.
2773 If PROPS, insert the result."
2774 (let ((form (gnus-parse-format format alist props)))
2776 (add-text-properties (point) (progn (eval form) (point)) props)
2779 (defun gnus-remove-text-with-property (prop)
2780 "Delete all text in the current buffer with text property PROP."
2782 (goto-char (point-min))
2784 (while (get-text-property (point) prop)
2786 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2788 (defun gnus-set-work-buffer ()
2789 (if (get-buffer gnus-work-buffer)
2791 (set-buffer gnus-work-buffer)
2793 (set-buffer (get-buffer-create gnus-work-buffer))
2794 (kill-all-local-variables)
2795 (buffer-disable-undo (current-buffer))
2796 (gnus-add-current-to-buffer-list)))
2798 ;; Article file names when saving.
2800 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2801 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2802 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2803 Otherwise, it is like ~/News/news/group/num."
2806 (concat (if (gnus-use-long-file-name 'not-save)
2807 (gnus-capitalize-newsgroup newsgroup)
2808 (gnus-newsgroup-directory-form newsgroup))
2809 "/" (int-to-string (mail-header-number headers)))
2810 (or gnus-article-save-directory "~/News"))))
2812 (string-equal (file-name-directory default)
2813 (file-name-directory last-file))
2814 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2816 (or last-file default))))
2818 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2819 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2820 If variable `gnus-use-long-file-name' is non-nil, it is
2821 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2824 (concat (if (gnus-use-long-file-name 'not-save)
2826 (gnus-newsgroup-directory-form newsgroup))
2827 "/" (int-to-string (mail-header-number headers)))
2828 (or gnus-article-save-directory "~/News"))))
2830 (string-equal (file-name-directory default)
2831 (file-name-directory last-file))
2832 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2834 (or last-file default))))
2836 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2837 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2838 If variable `gnus-use-long-file-name' is non-nil, it is
2839 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2842 (if (gnus-use-long-file-name 'not-save)
2843 (gnus-capitalize-newsgroup newsgroup)
2844 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2845 (or gnus-article-save-directory "~/News"))))
2847 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2848 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2849 If variable `gnus-use-long-file-name' is non-nil, it is
2850 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2853 (if (gnus-use-long-file-name 'not-save)
2855 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2856 (or gnus-article-save-directory "~/News"))))
2858 ;; For subscribing new newsgroup
2860 (defun gnus-subscribe-hierarchical-interactive (groups)
2861 (let ((groups (sort groups 'string<))
2862 prefixes prefix start ans group starts)
2864 (setq prefixes (list "^"))
2865 (while (and groups prefixes)
2866 (while (not (string-match (car prefixes) (car groups)))
2867 (setq prefixes (cdr prefixes)))
2868 (setq prefix (car prefixes))
2869 (setq start (1- (length prefix)))
2870 (if (and (string-match "[^\\.]\\." (car groups) start)
2873 (concat "^" (substring (car groups) 0 (match-end 0))))
2874 (string-match prefix (cadr groups)))
2876 (setq prefixes (cons prefix prefixes))
2877 (message "Descend hierarchy %s? ([y]nsq): "
2878 (substring prefix 1 (1- (length prefix))))
2879 (setq ans (read-char))
2882 (string-match prefix
2883 (setq group (car groups))))
2884 (setq gnus-killed-list
2885 (cons group gnus-killed-list))
2886 (gnus-sethash group group gnus-killed-hashtb)
2887 (setq groups (cdr groups)))
2888 (setq starts (cdr starts)))
2891 (string-match prefix
2892 (setq group (car groups))))
2893 (gnus-sethash group group gnus-killed-hashtb)
2894 (gnus-subscribe-alphabetically (car groups))
2895 (setq groups (cdr groups)))
2896 (setq starts (cdr starts)))
2899 (setq group (car groups))
2900 (setq gnus-killed-list (cons group gnus-killed-list))
2901 (gnus-sethash group group gnus-killed-hashtb)
2902 (setq groups (cdr groups))))
2904 (message "Subscribe %s? ([n]yq)" (car groups))
2905 (setq ans (read-char))
2906 (setq group (car groups))
2908 (gnus-subscribe-alphabetically (car groups))
2909 (gnus-sethash group group gnus-killed-hashtb))
2912 (setq group (car groups))
2913 (setq gnus-killed-list (cons group gnus-killed-list))
2914 (gnus-sethash group group gnus-killed-hashtb)
2915 (setq groups (cdr groups))))
2917 (setq gnus-killed-list (cons group gnus-killed-list))
2918 (gnus-sethash group group gnus-killed-hashtb)))
2919 (setq groups (cdr groups)))))))
2921 (defun gnus-subscribe-randomly (newsgroup)
2922 "Subscribe new NEWSGROUP by making it the first newsgroup."
2923 (gnus-subscribe-newsgroup newsgroup))
2925 (defun gnus-subscribe-alphabetically (newgroup)
2926 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2927 (let ((groups (cdr gnus-newsrc-alist))
2929 (while (and (not before) groups)
2930 (if (string< newgroup (caar groups))
2931 (setq before (caar groups))
2932 (setq groups (cdr groups))))
2933 (gnus-subscribe-newsgroup newgroup before)))
2935 (defun gnus-subscribe-hierarchically (newgroup)
2936 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2937 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2939 (set-buffer (find-file-noselect gnus-current-startup-file))
2940 (let ((groupkey newgroup)
2942 (while (and (not before) groupkey)
2943 (goto-char (point-min))
2945 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2946 (while (and (re-search-forward groupkey-re nil t)
2948 (setq before (match-string 1))
2949 (string< before newgroup)))))
2950 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2952 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2953 (substring groupkey (match-beginning 1) (match-end 1)))))
2954 (gnus-subscribe-newsgroup newgroup before))))
2956 (defun gnus-subscribe-interactively (group)
2957 "Subscribe the new GROUP interactively.
2958 It is inserted in hierarchical newsgroup order if subscribed. If not,
2960 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2961 (gnus-subscribe-hierarchically group)
2962 (push group gnus-killed-list)))
2964 (defun gnus-subscribe-zombies (group)
2965 "Make the new GROUP into a zombie group."
2966 (push group gnus-zombie-list))
2968 (defun gnus-subscribe-killed (group)
2969 "Make the new GROUP a killed group."
2970 (push group gnus-killed-list))
2972 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2973 "Subscribe new NEWSGROUP.
2974 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2975 the first newsgroup."
2976 ;; We subscribe the group by changing its level to `subscribed'.
2977 (gnus-group-change-level
2978 newsgroup gnus-level-default-subscribed
2979 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2980 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2984 (defun gnus-newsgroup-directory-form (newsgroup)
2985 "Make hierarchical directory name from NEWSGROUP name."
2986 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2987 (len (length newsgroup))
2989 ;; If this is a foreign group, we don't want to translate the
2991 (if (setq idx (string-match ":" newsgroup))
2992 (aset newsgroup idx ?/)
2994 ;; Replace all occurrences of `.' with `/'.
2996 (if (= (aref newsgroup idx) ?.)
2997 (aset newsgroup idx ?/))
2998 (setq idx (1+ idx)))
3001 (defun gnus-newsgroup-savable-name (group)
3002 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3004 (nnheader-replace-chars-in-string group ?/ ?.))
3006 (defun gnus-make-directory (dir)
3007 "Make DIRECTORY recursively."
3008 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3009 ;; of the many mysteries of the universe.
3010 (let* ((dir (expand-file-name dir default-directory))
3012 (if (string-match "/$" dir)
3013 (setq dir (substring dir 0 (match-beginning 0))))
3014 ;; First go down the path until we find a directory that exists.
3015 (while (not (file-exists-p dir))
3016 (setq dirs (cons dir dirs))
3017 (string-match "/[^/]+$" dir)
3018 (setq dir (substring dir 0 (match-beginning 0))))
3019 ;; Then create all the subdirs.
3020 (while (and dirs (not err))
3022 (make-directory (car dirs))
3023 (error (setq err t)))
3024 (setq dirs (cdr dirs)))
3025 ;; We return whether we were successful or not.
3028 (defun gnus-capitalize-newsgroup (newsgroup)
3029 "Capitalize NEWSGROUP name."
3030 (and (not (zerop (length newsgroup)))
3031 (concat (char-to-string (upcase (aref newsgroup 0)))
3032 (substring newsgroup 1))))
3034 ;; Various... things.
3036 (defun gnus-simplify-subject (subject &optional re-only)
3037 "Remove `Re:' and words in parentheses.
3038 If RE-ONLY is non-nil, strip leading `Re:'s only."
3039 (let ((case-fold-search t)) ;Ignore case.
3040 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3041 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3042 (setq subject (substring subject (match-end 0))))
3043 ;; Remove uninteresting prefixes.
3044 (if (and (not re-only)
3045 gnus-simplify-ignored-prefixes
3046 (string-match gnus-simplify-ignored-prefixes subject))
3047 (setq subject (substring subject (match-end 0))))
3048 ;; Remove words in parentheses from end.
3050 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3051 (setq subject (substring subject 0 (match-beginning 0)))))
3052 ;; Return subject string.
3055 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3057 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3058 (defun gnus-simplify-buffer-fuzzy ()
3059 (goto-char (point-min))
3060 (while (search-forward "\t" nil t)
3061 (replace-match " " t t))
3062 (goto-char (point-min))
3063 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3064 (goto-char (match-beginning 0))
3066 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3067 (looking-at "^[[].*: .*[]]$"))
3068 (goto-char (point-min))
3069 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3071 (replace-match "" t t))
3072 (goto-char (point-min))
3073 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3074 (goto-char (match-end 0))
3077 (progn (goto-char (match-beginning 0)))
3078 (re-search-forward ":"))))
3079 (goto-char (point-min))
3080 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3081 (replace-match "" t t))
3082 (goto-char (point-min))
3083 (while (re-search-forward " +" nil t)
3084 (replace-match " " t t))
3085 (goto-char (point-min))
3086 (while (re-search-forward " $" nil t)
3087 (replace-match "" t t))
3088 (goto-char (point-min))
3089 (while (re-search-forward "^ +" nil t)
3090 (replace-match "" t t))
3091 (goto-char (point-min))
3092 (when gnus-simplify-subject-fuzzy-regexp
3093 (if (listp gnus-simplify-subject-fuzzy-regexp)
3094 (let ((list gnus-simplify-subject-fuzzy-regexp))
3096 (goto-char (point-min))
3097 (while (re-search-forward (car list) nil t)
3098 (replace-match "" t t))
3099 (setq list (cdr list))))
3100 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3101 (replace-match "" t t)))))
3103 (defun gnus-simplify-subject-fuzzy (subject)
3104 "Siplify a subject string fuzzily."
3106 (gnus-set-work-buffer)
3107 (let ((case-fold-search t))
3109 (inline (gnus-simplify-buffer-fuzzy))
3112 ;; Add the current buffer to the list of buffers to be killed on exit.
3113 (defun gnus-add-current-to-buffer-list ()
3114 (or (memq (current-buffer) gnus-buffer-list)
3115 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3117 (defun gnus-string> (s1 s2)
3118 (not (or (string< s1 s2)
3121 ;;; General various misc type functions.
3123 (defun gnus-clear-system ()
3124 "Clear all variables and buffers."
3125 ;; Clear Gnus variables.
3126 (let ((variables gnus-variable-list))
3128 (set (car variables) nil)
3129 (setq variables (cdr variables))))
3130 ;; Clear other internal variables.
3131 (setq gnus-list-of-killed-groups nil
3132 gnus-have-read-active-file nil
3133 gnus-newsrc-alist nil
3134 gnus-newsrc-hashtb nil
3135 gnus-killed-list nil
3136 gnus-zombie-list nil
3137 gnus-killed-hashtb nil
3138 gnus-active-hashtb nil
3139 gnus-moderated-list nil
3140 gnus-description-hashtb nil
3141 gnus-current-headers nil
3142 gnus-thread-indent-array nil
3143 gnus-newsgroup-headers nil
3144 gnus-newsgroup-name nil
3145 gnus-server-alist nil
3146 gnus-group-list-mode nil
3147 gnus-opened-servers nil
3148 gnus-current-select-method nil)
3149 (gnus-shutdown 'gnus)
3150 ;; Kill the startup file.
3151 (and gnus-current-startup-file
3152 (get-file-buffer gnus-current-startup-file)
3153 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3154 ;; Clear the dribble buffer.
3155 (gnus-dribble-clear)
3156 ;; Kill global KILL file buffer.
3157 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3158 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3159 (gnus-kill-buffer nntp-server-buffer)
3160 ;; Kill Gnus buffers.
3161 (while gnus-buffer-list
3162 (gnus-kill-buffer (pop gnus-buffer-list)))
3163 ;; Remove Gnus frames.
3164 (while gnus-created-frames
3165 (when (frame-live-p (car gnus-created-frames))
3166 ;; We slap a condition-case around this `delete-frame' to ensure
3167 ;; agains errors if we try do delete the single frame that's left.
3169 (delete-frame (car gnus-created-frames))
3171 (pop gnus-created-frames)))
3173 (defun gnus-windows-old-to-new (setting)
3174 ;; First we take care of the really, really old Gnus 3 actions.
3175 (when (symbolp setting)
3177 ;; Take care of ooold GNUS 3.x values.
3178 (cond ((eq setting 'SelectArticle) 'article)
3179 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3180 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3182 (if (or (listp setting)
3183 (not (and gnus-window-configuration
3184 (memq setting '(group summary article)))))
3186 (let* ((setting (if (eq setting 'group)
3187 (if (assq 'newsgroup gnus-window-configuration)
3189 'newsgroups) setting))
3190 (elem (cadr (assq setting gnus-window-configuration)))
3191 (total (apply '+ elem))
3192 (types '(group summary article))
3193 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3198 (or (not (numberp (nth i elem)))
3199 (zerop (nth i elem))
3201 (setq perc (/ (float (nth 0 elem)) total))
3202 (setq out (cons (if (eq pbuf (nth i types))
3203 (vector (nth i types) perc 'point)
3204 (vector (nth i types) perc))
3207 (list (nreverse out)))))
3210 (defun gnus-add-configuration (conf)
3211 "Add the window configuration CONF to `gnus-buffer-configuration'."
3212 (setq gnus-buffer-configuration
3213 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3214 gnus-buffer-configuration))))
3216 (defvar gnus-frame-list nil)
3218 (defun gnus-configure-frame (split &optional window)
3219 "Split WINDOW according to SPLIT."
3221 (setq window (get-buffer-window (current-buffer))))
3222 (select-window window)
3223 ;; This might be an old-stylee buffer config.
3224 (when (vectorp split)
3225 (setq split (append split nil)))
3226 (when (or (consp (car split))
3227 (vectorp (car split)))
3229 (push 'vertical split))
3230 ;; The SPLIT might be something that is to be evaled to
3231 ;; return a new SPLIT.
3232 (while (and (not (assq (car split) gnus-window-to-buffer))
3233 (gnus-functionp (car split)))
3234 (setq split (eval split)))
3235 (let* ((type (car split))
3237 (len (if (eq type 'horizontal) (window-width) (window-height)))
3239 (window-min-width (or gnus-window-min-width window-min-width))
3240 (window-min-height (or gnus-window-min-height window-min-height))
3241 s result new-win rest comp-subs size sub)
3243 ;; Nothing to do here.
3245 ;; Don't switch buffers.
3247 (and (memq 'point split) window))
3248 ;; This is a buffer to be selected.
3249 ((not (memq type '(frame horizontal vertical)))
3250 (let ((buffer (cond ((stringp type) type)
3251 (t (cdr (assq type gnus-window-to-buffer)))))
3254 (error "Illegal buffer type: %s" type))
3255 (unless (setq buf (get-buffer (if (symbolp buffer)
3256 (symbol-value buffer) buffer)))
3257 (setq buf (get-buffer-create (if (symbolp buffer)
3258 (symbol-value buffer) buffer))))
3259 (switch-to-buffer buf)
3260 ;; We return the window if it has the `point' spec.
3261 (and (memq 'point split) window)))
3262 ;; This is a frame split.
3264 (unless gnus-frame-list
3265 (setq gnus-frame-list (list (window-frame
3266 (get-buffer-window (current-buffer))))))
3268 params frame fresult)
3269 (while (< i (length subs))
3270 ;; Frame parameter is gotten from the sub-split.
3271 (setq params (cadr (elt subs i)))
3272 ;; It should be a list.
3273 (unless (listp params)
3275 ;; Create a new frame?
3276 (unless (setq frame (elt gnus-frame-list i))
3277 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3278 (push frame gnus-created-frames))
3279 ;; Is the old frame still alive?
3280 (unless (frame-live-p frame)
3281 (setcar (nthcdr i gnus-frame-list)
3282 (setq frame (make-frame params))))
3283 ;; Select the frame in question and do more splits there.
3284 (select-frame frame)
3285 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3287 ;; Select the frame that has the selected buffer.
3289 (select-frame (window-frame fresult)))))
3290 ;; This is a normal split.
3292 (when (> (length subs) 0)
3293 ;; First we have to compute the sizes of all new windows.
3295 (setq sub (append (pop subs) nil))
3296 (while (and (not (assq (car sub) gnus-window-to-buffer))
3297 (gnus-functionp (car sub)))
3298 (setq sub (eval sub)))
3300 (push sub comp-subs)
3301 (setq size (cadar comp-subs))
3302 (cond ((equal size 1.0)
3303 (setq rest (car comp-subs))
3306 (setq s (floor (* size len))))
3310 (error "Illegal size: %s" size)))
3311 ;; Try to make sure that we are inside the safe limits.
3313 ((eq type 'horizontal)
3314 (setq s (max s window-min-width)))
3315 ((eq type 'vertical)
3316 (setq s (max s window-min-height))))
3317 (setcar (cdar comp-subs) s)
3319 ;; Take care of the "1.0" spec.
3321 (setcar (cdr rest) (- len total))
3322 (error "No 1.0 specs in %s" split))
3323 ;; The we do the actual splitting in a nice recursive
3325 (setq comp-subs (nreverse comp-subs))
3327 (if (null (cdr comp-subs))
3328 (setq new-win window)
3330 (split-window window (cadar comp-subs)
3331 (eq type 'horizontal))))
3332 (setq result (or (gnus-configure-frame
3333 (car comp-subs) window) result))
3334 (select-window new-win)
3335 (setq window new-win)
3336 (setq comp-subs (cdr comp-subs))))
3337 ;; Return the proper window, if any.
3339 (select-window result))))))
3341 (defvar gnus-frame-split-p nil)
3343 (defun gnus-configure-windows (setting &optional force)
3344 (setq setting (gnus-windows-old-to-new setting))
3345 (let ((split (if (symbolp setting)
3346 (cadr (assq setting gnus-buffer-configuration))
3350 (setq gnus-frame-split-p nil)
3353 (error "No such setting: %s" setting))
3355 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3357 ;; All the windows mentioned are already visible, so we just
3358 ;; put point in the assigned buffer, and do not touch the
3360 (select-window all-visible)
3362 ;; Either remove all windows or just remove all Gnus windows.
3363 (let ((frame (selected-frame)))
3365 (if gnus-use-full-window
3366 ;; We want to remove all other windows.
3367 (if (not gnus-frame-split-p)
3368 ;; This is not a `frame' split, so we ignore the
3370 (delete-other-windows)
3371 ;; This is a `frame' split, so we delete all windows
3375 (unless (eq (cdr (assq 'minibuffer
3376 (frame-parameters frame)))
3378 (select-frame frame)
3379 (delete-other-windows)))
3381 ;; Just remove some windows.
3382 (gnus-remove-some-windows)
3383 (switch-to-buffer nntp-server-buffer))
3384 (select-frame frame)))
3386 (switch-to-buffer nntp-server-buffer)
3387 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3389 (defun gnus-all-windows-visible-p (split)
3390 "Say whether all buffers in SPLIT are currently visible.
3391 In particular, the value returned will be the window that
3393 (let ((stack (list split))
3395 type buffer win buf)
3396 (while (and (setq split (pop stack))
3398 ;; Be backwards compatible.
3399 (when (vectorp split)
3400 (setq split (append split nil)))
3401 (when (or (consp (car split))
3402 (vectorp (car split)))
3404 (push 'vertical split))
3405 ;; The SPLIT might be something that is to be evaled to
3406 ;; return a new SPLIT.
3407 (while (and (not (assq (car split) gnus-window-to-buffer))
3408 (gnus-functionp (car split)))
3409 (setq split (eval split)))
3411 (setq type (elt split 0))
3416 ((not (memq type '(horizontal vertical frame)))
3417 (setq buffer (cond ((stringp type) type)
3418 (t (cdr (assq type gnus-window-to-buffer)))))
3420 (error "Illegal buffer type: %s" type))
3421 (when (setq buf (get-buffer (if (symbolp buffer)
3422 (symbol-value buffer)
3424 (setq win (get-buffer-window buf t)))
3426 (when (memq 'point split)
3427 (setq all-visible win))
3428 (setq all-visible nil)))
3430 (when (eq type 'frame)
3431 (setq gnus-frame-split-p t))
3432 (setq stack (append (cddr split) stack)))))
3433 (unless (eq all-visible t)
3436 (defun gnus-window-top-edge (&optional window)
3437 (nth 1 (window-edges window)))
3439 (defun gnus-remove-some-windows ()
3440 (let ((buffers gnus-window-to-buffer)
3441 buf bufs lowest-buf lowest)
3443 ;; Remove windows on all known Gnus buffers.
3445 (setq buf (cdar buffers))
3447 (setq buf (and (boundp buf) (symbol-value buf))))
3449 (get-buffer-window buf)
3451 (setq bufs (cons buf bufs))
3453 (if (or (not lowest)
3454 (< (gnus-window-top-edge) lowest))
3456 (setq lowest (gnus-window-top-edge))
3457 (setq lowest-buf buf)))))
3458 (setq buffers (cdr buffers)))
3459 ;; Remove windows on *all* summary buffers.
3462 (let ((buf (window-buffer win)))
3463 (if (string-match "^\\*Summary" (buffer-name buf))
3465 (setq bufs (cons buf bufs))
3467 (if (or (not lowest)
3468 (< (gnus-window-top-edge) lowest))
3470 (setq lowest-buf buf)
3471 (setq lowest (gnus-window-top-edge)))))))))
3474 (pop-to-buffer lowest-buf)
3475 (switch-to-buffer nntp-server-buffer)))
3477 (and (not (eq (car bufs) lowest-buf))
3478 (delete-windows-on (car bufs)))
3479 (setq bufs (cdr bufs))))))
3481 (defun gnus-version ()
3482 "Version numbers of this version of Gnus."
3484 (let ((methods gnus-valid-select-methods)
3487 ;; Go through all the legal select methods and add their version
3488 ;; numbers to the total version string. Only the backends that are
3489 ;; currently in use will have their message numbers taken into
3492 (setq meth (intern (concat (caar methods) "-version")))
3494 (stringp (symbol-value meth))
3495 (setq mess (concat mess "; " (symbol-value meth))))
3496 (setq methods (cdr methods)))
3497 (gnus-message 2 mess)))
3499 (defun gnus-info-find-node ()
3500 "Find Info documentation of Gnus."
3502 ;; Enlarge info window if needed.
3503 (let ((mode major-mode)
3505 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3506 (setq gnus-info-buffer (current-buffer))
3507 (gnus-configure-windows 'info)))
3509 (defun gnus-days-between (date1 date2)
3510 ;; Return the number of days between date1 and date2.
3511 (- (gnus-day-number date1) (gnus-day-number date2)))
3513 (defun gnus-day-number (date)
3514 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3515 (timezone-parse-date date))))
3516 (timezone-absolute-from-gregorian
3517 (nth 1 dat) (nth 2 dat) (car dat))))
3519 (defun gnus-encode-date (date)
3520 "Convert DATE to internal time."
3521 (let* ((parse (timezone-parse-date date))
3522 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3523 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3524 (encode-time (caddr time) (cadr time) (car time)
3525 (caddr date) (cadr date) (car date) (nth 4 date))))
3527 (defun gnus-time-minus (t1 t2)
3528 "Subtract two internal times."
3529 (let ((borrow (< (cadr t1) (cadr t2))))
3530 (list (- (car t1) (car t2) (if borrow 1 0))
3531 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3533 (defun gnus-file-newer-than (file date)
3534 (let ((fdate (nth 5 (file-attributes file))))
3535 (or (> (car fdate) (car date))
3536 (and (= (car fdate) (car date))
3537 (> (nth 1 fdate) (nth 1 date))))))
3539 (defmacro gnus-local-set-keys (&rest plist)
3540 "Set the keys in PLIST in the current keymap."
3541 `(gnus-define-keys-1 (current-local-map) ',plist))
3543 (defmacro gnus-define-keys (keymap &rest plist)
3544 "Define all keys in PLIST in KEYMAP."
3545 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3547 (put 'gnus-define-keys 'lisp-indent-function 1)
3548 (put 'gnus-define-keys 'lisp-indent-hook 1)
3549 (put 'gnus-define-keymap 'lisp-indent-function 1)
3550 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3552 (defmacro gnus-define-keymap (keymap &rest plist)
3553 "Define all keys in PLIST in KEYMAP."
3554 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3556 (defun gnus-define-keys-1 (keymap plist)
3558 (error "Can't set keys in a null keymap"))
3559 (cond ((symbolp keymap)
3560 (setq keymap (symbol-value keymap)))
3563 (set (car keymap) nil)
3564 (define-prefix-command (car keymap))
3565 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3566 (setq keymap (symbol-value (car keymap)))))
3569 (when (symbolp (setq key (pop plist)))
3570 (setq key (symbol-value key)))
3571 (define-key keymap key (pop plist)))))
3573 (defun gnus-group-read-only-p (&optional group)
3574 "Check whether GROUP supports editing or not.
3575 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3576 that that variable is buffer-local to the summary buffers."
3577 (let ((group (or group gnus-newsgroup-name)))
3578 (not (gnus-check-backend-function 'request-replace-article group))))
3580 (defun gnus-group-total-expirable-p (group)
3581 "Check whether GROUP is total-expirable or not."
3582 (let ((params (gnus-info-params (gnus-get-info group))))
3583 (or (memq 'total-expire params)
3584 (cdr (assq 'total-expire params)) ; (total-expire . t)
3585 (and gnus-total-expirable-newsgroups ; Check var.
3586 (string-match gnus-total-expirable-newsgroups group)))))
3588 (defun gnus-group-auto-expirable-p (group)
3589 "Check whether GROUP is total-expirable or not."
3590 (let ((params (gnus-info-params (gnus-get-info group))))
3591 (or (memq 'auto-expire params)
3592 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3593 (and gnus-auto-expirable-newsgroups ; Check var.
3594 (string-match gnus-auto-expirable-newsgroups group)))))
3596 (defun gnus-virtual-group-p (group)
3597 "Say whether GROUP is virtual or not."
3598 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3599 gnus-valid-select-methods)))
3601 (defun gnus-news-group-p (group &optional article)
3602 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3603 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3604 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3605 (eq (gnus-request-type group article) 'news))))
3607 (defsubst gnus-simplify-subject-fully (subject)
3608 "Simplify a subject string according to the user's wishes."
3610 ((null gnus-summary-gather-subject-limit)
3611 (gnus-simplify-subject-re subject))
3612 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3613 (gnus-simplify-subject-fuzzy subject))
3614 ((numberp gnus-summary-gather-subject-limit)
3615 (gnus-limit-string (gnus-simplify-subject-re subject)
3616 gnus-summary-gather-subject-limit))
3620 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3621 "Check whether two subjects are equal. If optional argument
3622 simple-first is t, first argument is already simplified."
3624 ((null simple-first)
3625 (equal (gnus-simplify-subject-fully s1)
3626 (gnus-simplify-subject-fully s2)))
3629 (gnus-simplify-subject-fully s2)))))
3631 ;; Returns a list of writable groups.
3632 (defun gnus-writable-groups ()
3633 (let ((alist gnus-newsrc-alist)
3635 (while (setq group (car (pop alist)))
3636 (unless (gnus-group-read-only-p group)
3637 (push group groups)))
3640 (defun gnus-completing-read (default prompt &rest args)
3641 ;; Like `completing-read', except that DEFAULT is the default argument.
3642 (let* ((prompt (if default
3643 (concat prompt " (default " default ") ")
3644 (concat prompt " ")))
3645 (answer (apply 'completing-read prompt args)))
3646 (if (or (null answer) (zerop (length answer)))
3650 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3652 (defun gnus-y-or-n-p (prompt)
3657 (defun gnus-yes-or-no-p (prompt)
3659 (yes-or-no-p prompt)
3662 ;; Check whether to use long file names.
3663 (defun gnus-use-long-file-name (symbol)
3664 ;; The variable has to be set...
3665 (and gnus-use-long-file-name
3666 ;; If it isn't a list, then we return t.
3667 (or (not (listp gnus-use-long-file-name))
3668 ;; If it is a list, and the list contains `symbol', we
3670 (not (memq symbol gnus-use-long-file-name)))))
3672 ;; I suspect there's a better way, but I haven't taken the time to do
3673 ;; it yet. -erik selberg@cs.washington.edu
3674 (defun gnus-dd-mmm (messy-date)
3675 "Return a string like DD-MMM from a big messy string"
3676 (let ((datevec (timezone-parse-date messy-date)))
3679 ;; Make sure leading zeroes are stripped.
3680 (number-to-string (string-to-number (aref datevec 2)))
3684 (nth (1- (string-to-number (aref datevec 1)))
3685 timezone-months-assoc))
3688 ;; Make a hash table (default and minimum size is 255).
3689 ;; Optional argument HASHSIZE specifies the table size.
3690 (defun gnus-make-hashtable (&optional hashsize)
3691 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3693 ;; Make a number that is suitable for hashing; bigger than MIN and one
3695 (defun gnus-create-hash-size (min)
3701 ;; Show message if message has a lower level than `gnus-verbose'.
3702 ;; Guideline for numbers:
3703 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3704 ;; for things that take a long time, 7 - not very important messages
3705 ;; on stuff, 9 - messages inside loops.
3706 (defun gnus-message (level &rest args)
3707 (if (<= level gnus-verbose)
3708 (apply 'message args)
3709 ;; We have to do this format thingy here even if the result isn't
3710 ;; shown - the return value has to be the same as the return value
3712 (apply 'format args)))
3714 (defun gnus-error (level &rest args)
3715 "Beep an error if `gnus-verbose' is on LEVEL or less."
3716 (when (<= (floor level) gnus-verbose)
3717 (apply 'message args)
3720 (when (and (floatp level)
3721 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3722 (sit-for duration))))
3725 ;; Generate a unique new group name.
3726 (defun gnus-generate-new-group-name (leaf)
3729 (while (gnus-gethash name gnus-newsrc-hashtb)
3730 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3733 (defsubst gnus-hide-text (b e props)
3734 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3735 (add-text-properties b e props)
3736 (when (memq 'intangible props)
3737 (put-text-property (max (1- b) (point-min))
3738 b 'intangible (cddr (memq 'intangible props)))))
3740 (defsubst gnus-unhide-text (b e)
3741 "Remove hidden text properties from region between B and E."
3742 (remove-text-properties b e gnus-hidden-properties)
3743 (when (memq 'intangible gnus-hidden-properties)
3744 (put-text-property (max (1- b) (point-min))
3745 b 'intangible nil)))
3747 (defun gnus-hide-text-type (b e type)
3748 "Hide text of TYPE between B and E."
3749 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3751 ;; Find out whether the gnus-visual TYPE is wanted.
3752 (defun gnus-visual-p (&optional type class)
3753 (and gnus-visual ; Has to be non-nil, at least.
3754 (if (not type) ; We don't care about type.
3756 (if (listp gnus-visual) ; It's a list, so we check it.
3757 (or (memq type gnus-visual)
3758 (memq class gnus-visual))
3761 (defun gnus-parent-id (references)
3762 "Return the last Message-ID in REFERENCES."
3763 (when (and references
3764 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3765 (substring references (match-beginning 1) (match-end 1))))
3767 (defun gnus-split-references (references)
3768 "Return a list of Message-IDs in REFERENCES."
3771 (while (string-match "<[^>]+>" references beg)
3772 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3776 (defun gnus-buffer-live-p (buffer)
3777 "Say whether BUFFER is alive or not."
3780 (buffer-name (get-buffer buffer))))
3782 (defun gnus-ephemeral-group-p (group)
3783 "Say whether GROUP is ephemeral or not."
3784 (gnus-group-get-parameter group 'quit-config))
3786 (defun gnus-group-quit-config (group)
3787 "Return the quit-config of GROUP."
3788 (gnus-group-get-parameter group 'quit-config))
3790 (defun gnus-simplify-mode-line ()
3791 "Make mode lines a bit simpler."
3792 (setq mode-line-modified "-- ")
3793 (when (listp mode-line-format)
3794 (make-local-variable 'mode-line-format)
3795 (setq mode-line-format (copy-sequence mode-line-format))
3796 (when (equal (nth 3 mode-line-format) " ")
3797 (setcar (nthcdr 3 mode-line-format) " "))))
3799 ;;; List and range functions
3801 (defun gnus-last-element (list)
3802 "Return last element of LIST."
3804 (setq list (cdr list)))
3807 (defun gnus-copy-sequence (list)
3808 "Do a complete, total copy of a list."
3809 (if (and (consp list) (not (consp (cdr list))))
3810 (cons (car list) (cdr list))
3811 (mapcar (lambda (elem) (if (consp elem)
3812 (if (consp (cdr elem))
3813 (gnus-copy-sequence elem)
3814 (cons (car elem) (cdr elem)))
3818 (defun gnus-set-difference (list1 list2)
3819 "Return a list of elements of LIST1 that do not appear in LIST2."
3820 (let ((list1 (copy-sequence list1)))
3822 (setq list1 (delq (car list2) list1))
3823 (setq list2 (cdr list2)))
3826 (defun gnus-sorted-complement (list1 list2)
3827 "Return a list of elements of LIST1 that do not appear in LIST2.
3828 Both lists have to be sorted over <."
3830 (if (or (null list1) (null list2))
3832 (while (and list1 list2)
3833 (cond ((= (car list1) (car list2))
3834 (setq list1 (cdr list1)
3836 ((< (car list1) (car list2))
3837 (setq out (cons (car list1) out))
3838 (setq list1 (cdr list1)))
3840 (setq out (cons (car list2) out))
3841 (setq list2 (cdr list2)))))
3842 (nconc (nreverse out) (or list1 list2)))))
3844 (defun gnus-intersection (list1 list2)
3847 (if (memq (car list2) list1)
3848 (setq result (cons (car list2) result)))
3849 (setq list2 (cdr list2)))
3852 (defun gnus-sorted-intersection (list1 list2)
3853 ;; LIST1 and LIST2 have to be sorted over <.
3855 (while (and list1 list2)
3856 (cond ((= (car list1) (car list2))
3857 (setq out (cons (car list1) out)
3860 ((< (car list1) (car list2))
3861 (setq list1 (cdr list1)))
3863 (setq list2 (cdr list2)))))
3866 (defun gnus-set-sorted-intersection (list1 list2)
3867 ;; LIST1 and LIST2 have to be sorted over <.
3868 ;; This function modifies LIST1.
3869 (let* ((top (cons nil list1))
3871 (while (and list1 list2)
3872 (cond ((= (car list1) (car list2))
3876 ((< (car list1) (car list2))
3877 (setcdr prev (cdr list1))
3878 (setq list1 (cdr list1)))
3880 (setq list2 (cdr list2)))))
3884 (defun gnus-compress-sequence (numbers &optional always-list)
3885 "Convert list of numbers to a list of ranges or a single range.
3886 If ALWAYS-LIST is non-nil, this function will always release a list of
3888 (let* ((first (car numbers))
3889 (last (car numbers))
3893 (if (not (listp (cdr numbers)))
3896 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3897 ((= (1+ last) (car numbers)) ;Still in sequence
3898 (setq last (car numbers)))
3899 (t ;End of one sequence
3901 (cons (if (= first last) first
3902 (cons first last)) result))
3903 (setq first (car numbers))
3904 (setq last (car numbers))))
3905 (setq numbers (cdr numbers)))
3906 (if (and (not always-list) (null result))
3907 (if (= first last) (list first) (cons first last))
3908 (nreverse (cons (if (= first last) first (cons first last))
3911 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3912 (defun gnus-uncompress-range (ranges)
3913 "Expand a list of ranges into a list of numbers.
3914 RANGES is either a single range on the form `(num . num)' or a list of
3916 (let (first last result)
3920 ((not (listp (cdr ranges)))
3921 (setq first (car ranges))
3922 (setq last (cdr ranges))
3923 (while (<= first last)
3924 (setq result (cons first result))
3925 (setq first (1+ first)))
3929 (if (atom (car ranges))
3930 (if (numberp (car ranges))
3931 (setq result (cons (car ranges) result)))
3932 (setq first (caar ranges))
3933 (setq last (cdar ranges))
3934 (while (<= first last)
3935 (setq result (cons first result))
3936 (setq first (1+ first))))
3937 (setq ranges (cdr ranges)))
3938 (nreverse result)))))
3940 (defun gnus-add-to-range (ranges list)
3941 "Return a list of ranges that has all articles from both RANGES and LIST.
3942 Note: LIST has to be sorted over `<'."
3944 (gnus-compress-sequence list t)
3945 (setq list (copy-sequence list))
3946 (or (listp (cdr ranges))
3947 (setq ranges (list ranges)))
3949 ilist lowest highest temp)
3950 (while (and ranges list)
3952 (setq lowest (or (and (atom (car ranges)) (car ranges))
3954 (while (and list (cdr list) (< (cadr list) lowest))
3955 (setq list (cdr list)))
3956 (if (< (car ilist) lowest)
3959 (setq list (cdr list))
3961 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3962 (setq highest (or (and (atom (car ranges)) (car ranges))
3964 (while (and list (<= (car list) highest))
3965 (setq list (cdr list)))
3966 (setq ranges (cdr ranges)))
3968 (setq out (nconc (gnus-compress-sequence list t) out)))
3969 (setq out (sort out (lambda (r1 r2)
3970 (< (or (and (atom r1) r1) (car r1))
3971 (or (and (atom r2) r2) (car r2))))))
3974 (if (atom (car ranges))
3976 (if (atom (cadr ranges))
3977 (if (= (1+ (car ranges)) (cadr ranges))
3979 (setcar ranges (cons (car ranges)
3981 (setcdr ranges (cddr ranges))))
3982 (if (= (1+ (car ranges)) (caadr ranges))
3984 (setcar (cadr ranges) (car ranges))
3985 (setcar ranges (cadr ranges))
3986 (setcdr ranges (cddr ranges))))))
3988 (if (atom (cadr ranges))
3989 (if (= (1+ (cdar ranges)) (cadr ranges))
3991 (setcdr (car ranges) (cadr ranges))
3992 (setcdr ranges (cddr ranges))))
3993 (if (= (1+ (cdar ranges)) (caadr ranges))
3995 (setcdr (car ranges) (cdadr ranges))
3996 (setcdr ranges (cddr ranges)))))))
3997 (setq ranges (cdr ranges)))
4000 (defun gnus-remove-from-range (ranges list)
4001 "Return a list of ranges that has all articles from LIST removed from RANGES.
4002 Note: LIST has to be sorted over `<'."
4003 ;; !!! This function shouldn't look like this, but I've got a headache.
4004 (gnus-compress-sequence
4005 (gnus-sorted-complement
4006 (gnus-uncompress-range ranges) list)))
4008 (defun gnus-member-of-range (number ranges)
4009 (if (not (listp (cdr ranges)))
4010 (and (>= number (car ranges))
4011 (<= number (cdr ranges)))
4014 (if (numberp (car ranges))
4015 (>= number (car ranges))
4016 (>= number (caar ranges)))
4018 (if (if (numberp (car ranges))
4019 (= number (car ranges))
4020 (and (>= number (caar ranges))
4021 (<= number (cdar ranges))))
4022 (setq not-stop nil))
4023 (setq ranges (cdr ranges)))
4026 (defun gnus-range-length (range)
4027 "Return the length RANGE would have if uncompressed."
4028 (length (gnus-uncompress-range range)))
4030 (defun gnus-sublist-p (list sublist)
4031 "Test whether all elements in SUBLIST are members of LIST."
4034 (unless (memq (pop sublist) list)
4044 (defvar gnus-group-mode-map nil)
4045 (put 'gnus-group-mode 'mode-class 'special)
4047 (unless gnus-group-mode-map
4048 (setq gnus-group-mode-map (make-keymap))
4049 (suppress-keymap gnus-group-mode-map)
4051 (gnus-define-keys gnus-group-mode-map
4052 " " gnus-group-read-group
4053 "=" gnus-group-select-group
4054 "\r" gnus-group-select-group
4055 "\M-\r" gnus-group-quick-select-group
4056 "j" gnus-group-jump-to-group
4057 "n" gnus-group-next-unread-group
4058 "p" gnus-group-prev-unread-group
4059 "\177" gnus-group-prev-unread-group
4060 [delete] gnus-group-prev-unread-group
4061 "N" gnus-group-next-group
4062 "P" gnus-group-prev-group
4063 "\M-n" gnus-group-next-unread-group-same-level
4064 "\M-p" gnus-group-prev-unread-group-same-level
4065 "," gnus-group-best-unread-group
4066 "." gnus-group-first-unread-group
4067 "u" gnus-group-unsubscribe-current-group
4068 "U" gnus-group-unsubscribe-group
4069 "c" gnus-group-catchup-current
4070 "C" gnus-group-catchup-current-all
4071 "l" gnus-group-list-groups
4072 "L" gnus-group-list-all-groups
4074 "g" gnus-group-get-new-news
4075 "\M-g" gnus-group-get-new-news-this-group
4076 "R" gnus-group-restart
4077 "r" gnus-group-read-init-file
4078 "B" gnus-group-browse-foreign-server
4079 "b" gnus-group-check-bogus-groups
4080 "F" gnus-find-new-newsgroups
4081 "\C-c\C-d" gnus-group-describe-group
4082 "\M-d" gnus-group-describe-all-groups
4083 "\C-c\C-a" gnus-group-apropos
4084 "\C-c\M-\C-a" gnus-group-description-apropos
4085 "a" gnus-group-post-news
4086 "\ek" gnus-group-edit-local-kill
4087 "\eK" gnus-group-edit-global-kill
4088 "\C-k" gnus-group-kill-group
4089 "\C-y" gnus-group-yank-group
4090 "\C-w" gnus-group-kill-region
4091 "\C-x\C-t" gnus-group-transpose-groups
4092 "\C-c\C-l" gnus-group-list-killed
4093 "\C-c\C-x" gnus-group-expire-articles
4094 "\C-c\M-\C-x" gnus-group-expire-all-groups
4096 "s" gnus-group-save-newsrc
4097 "z" gnus-group-suspend
4098 "Z" gnus-group-clear-dribble
4101 "?" gnus-group-describe-briefly
4102 "\C-c\C-i" gnus-info-find-node
4103 "\M-e" gnus-group-edit-group-method
4104 "^" gnus-group-enter-server-mode
4105 gnus-mouse-2 gnus-mouse-pick-group
4106 "<" beginning-of-buffer
4109 "\C-c\C-s" gnus-group-sort-groups
4111 "\C-c\M-g" gnus-activate-all-groups
4112 "\M-&" gnus-group-universal-argument
4113 "#" gnus-group-mark-group
4114 "\M-#" gnus-group-unmark-group)
4116 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4117 "m" gnus-group-mark-group
4118 "u" gnus-group-unmark-group
4119 "w" gnus-group-mark-region
4120 "m" gnus-group-mark-buffer
4121 "r" gnus-group-mark-regexp
4122 "U" gnus-group-unmark-all-groups)
4124 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4125 "d" gnus-group-make-directory-group
4126 "h" gnus-group-make-help-group
4127 "a" gnus-group-make-archive-group
4128 "k" gnus-group-make-kiboze-group
4129 "m" gnus-group-make-group
4130 "E" gnus-group-edit-group
4131 "e" gnus-group-edit-group-method
4132 "p" gnus-group-edit-group-parameters
4133 "v" gnus-group-add-to-virtual
4134 "V" gnus-group-make-empty-virtual
4135 "D" gnus-group-enter-directory
4136 "f" gnus-group-make-doc-group
4137 "r" gnus-group-rename-group
4138 "\177" gnus-group-delete-group
4139 [delete] gnus-group-delete-group)
4141 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4142 "b" gnus-group-brew-soup
4143 "w" gnus-soup-save-areas
4144 "s" gnus-soup-send-replies
4145 "p" gnus-soup-pack-packet
4146 "r" nnsoup-pack-replies)
4148 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4149 "s" gnus-group-sort-groups
4150 "a" gnus-group-sort-groups-by-alphabet
4151 "u" gnus-group-sort-groups-by-unread
4152 "l" gnus-group-sort-groups-by-level
4153 "v" gnus-group-sort-groups-by-score
4154 "r" gnus-group-sort-groups-by-rank
4155 "m" gnus-group-sort-groups-by-method)
4157 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4158 "k" gnus-group-list-killed
4159 "z" gnus-group-list-zombies
4160 "s" gnus-group-list-groups
4161 "u" gnus-group-list-all-groups
4162 "A" gnus-group-list-active
4163 "a" gnus-group-apropos
4164 "d" gnus-group-description-apropos
4165 "m" gnus-group-list-matching
4166 "M" gnus-group-list-all-matching
4167 "l" gnus-group-list-level)
4169 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4170 "f" gnus-score-flush-cache)
4172 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4173 "f" gnus-group-fetch-faq)
4175 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4176 "l" gnus-group-set-current-level
4177 "t" gnus-group-unsubscribe-current-group
4178 "s" gnus-group-unsubscribe-group
4179 "k" gnus-group-kill-group
4180 "y" gnus-group-yank-group
4181 "w" gnus-group-kill-region
4182 "\C-k" gnus-group-kill-level
4183 "z" gnus-group-kill-all-zombies))
4185 (defun gnus-group-mode ()
4186 "Major mode for reading news.
4188 All normal editing commands are switched off.
4189 \\<gnus-group-mode-map>
4190 The group buffer lists (some of) the groups available. For instance,
4191 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4192 lists all zombie groups.
4194 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4195 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4197 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4199 The following commands are available:
4201 \\{gnus-group-mode-map}"
4203 (when (and menu-bar-mode
4204 (gnus-visual-p 'group-menu 'menu))
4205 (gnus-group-make-menu-bar))
4206 (kill-all-local-variables)
4207 (gnus-simplify-mode-line)
4208 (setq major-mode 'gnus-group-mode)
4209 (setq mode-name "Group")
4210 (gnus-group-set-mode-line)
4211 (setq mode-line-process nil)
4212 (use-local-map gnus-group-mode-map)
4213 (buffer-disable-undo (current-buffer))
4214 (setq truncate-lines t)
4215 (setq buffer-read-only t)
4216 (run-hooks 'gnus-group-mode-hook))
4218 (defun gnus-mouse-pick-group (e)
4219 "Enter the group under the mouse pointer."
4222 (gnus-group-read-group nil))
4224 ;; Look at LEVEL and find out what the level is really supposed to be.
4225 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4226 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4227 (defun gnus-group-default-level (&optional level number-or-nil)
4229 (gnus-group-use-permanent-levels
4230 ; (setq gnus-group-default-list-level
4231 ; (or level gnus-group-default-list-level))
4232 (or level gnus-group-default-list-level gnus-level-subscribed))
4236 (or level gnus-group-default-list-level gnus-level-subscribed))))
4239 (defun gnus-slave-no-server (&optional arg)
4240 "Read network news as a slave, without connecting to local server"
4242 (gnus-no-server arg t))
4245 (defun gnus-no-server (&optional arg slave)
4247 If ARG is a positive number, Gnus will use that as the
4248 startup level. If ARG is nil, Gnus will be started at level 2.
4249 If ARG is non-nil and not a positive number, Gnus will
4250 prompt the user for the name of an NNTP server to use.
4251 As opposed to `gnus', this command will not connect to the local server."
4253 (let ((gnus-group-use-permanent-levels t))
4254 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4255 (make-local-variable 'gnus-group-use-permanent-levels)
4256 (setq gnus-group-use-permanent-levels t))
4259 (defun gnus-slave (&optional arg)
4260 "Read news as a slave."
4262 (gnus arg nil 'slave))
4265 (defun gnus-other-frame (&optional arg)
4266 "Pop up a frame to read news."
4268 (if (get-buffer gnus-group-buffer)
4269 (let ((pop-up-frames t))
4271 (select-frame (make-frame))
4275 (defun gnus (&optional arg dont-connect slave)
4277 If ARG is non-nil and a positive number, Gnus will use that as the
4278 startup level. If ARG is non-nil and not a positive number, Gnus will
4279 prompt the user for the name of an NNTP server to use."
4282 (if (get-buffer gnus-group-buffer)
4284 (switch-to-buffer gnus-group-buffer)
4285 (gnus-group-get-new-news))
4288 (nnheader-init-server-buffer)
4289 (gnus-read-init-file)
4290 (setq gnus-slave slave)
4292 (gnus-group-setup-buffer)
4293 (let ((buffer-read-only nil))
4295 (if (not gnus-inhibit-startup-message)
4297 (gnus-group-startup-message)
4300 (let ((level (and (numberp arg) (> arg 0) arg))
4306 (gnus-start-news-server (and arg (not level))))))
4307 (if (and (not dont-connect)
4310 (run-hooks 'gnus-startup-hook)
4311 ;; NNTP server is successfully open.
4313 ;; Find the current startup file name.
4314 (setq gnus-current-startup-file
4315 (gnus-make-newsrc-file gnus-startup-file))
4317 ;; Read the dribble file.
4318 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4320 ;; Allow using GroupLens predictions.
4321 (when gnus-use-grouplens
4323 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4325 (gnus-summary-make-display-table)
4326 ;; Do the actual startup.
4327 (gnus-setup-news nil level dont-connect)
4328 ;; Generate the group buffer.
4329 (gnus-group-list-groups level)
4330 (gnus-group-first-unread-group)
4331 (gnus-configure-windows 'group)
4332 (gnus-group-set-mode-line))))))
4334 (defun gnus-unload ()
4335 "Unload all Gnus features."
4337 (or (boundp 'load-history)
4338 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4339 (let ((history load-history)
4342 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4343 (setq feature (cdr (assq 'provide (car history))))
4344 (unload-feature feature 'force))
4345 (setq history (cdr history)))))
4347 (defun gnus-compile ()
4348 "Byte-compile the user-defined format specs."
4350 (let ((entries gnus-format-specs)
4351 entry gnus-tmp-func)
4353 (gnus-message 7 "Compiling format specs...")
4356 (setq entry (pop entries))
4357 (if (eq (car entry) 'version)
4358 (setq gnus-format-specs (delq entry gnus-format-specs))
4359 (when (and (listp (caddr entry))
4360 (not (eq 'byte-code (caaddr entry))))
4361 (fset 'gnus-tmp-func
4362 `(lambda () ,(caddr entry)))
4363 (byte-compile 'gnus-tmp-func)
4364 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4366 (push (cons 'version emacs-version) gnus-format-specs)
4368 (gnus-message 7 "Compiling user specs...done"))))
4370 (defun gnus-indent-rigidly (start end arg)
4371 "Indent rigidly using only spaces and no tabs."
4374 (narrow-to-region start end)
4375 (indent-rigidly start end arg)
4376 (goto-char (point-min))
4377 (while (search-forward "\t" nil t)
4378 (replace-match " " t t)))))
4380 (defun gnus-group-startup-message (&optional x y)
4381 "Insert startup message in current buffer."
4382 ;; Insert the message.
4387 _ ___ __ ___ __ _ ___
4406 ;; And then hack it.
4407 (gnus-indent-rigidly (point-min) (point-max)
4408 (/ (max (- (window-width) (or x 46)) 0) 2))
4409 (goto-char (point-min))
4411 (let* ((pheight (count-lines (point-min) (point-max)))
4412 (wheight (window-height))
4413 (rest (- wheight pheight)))
4414 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4416 (goto-char (point-min))
4417 (and (search-forward "Praxis" nil t)
4418 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4419 (goto-char (point-min))
4420 (let* ((mode-string (gnus-group-set-mode-line)))
4421 (setq mode-line-buffer-identification
4422 (list (concat gnus-version (substring (car mode-string) 4))))
4423 (set-buffer-modified-p t)))
4425 (defun gnus-group-setup-buffer ()
4426 (or (get-buffer gnus-group-buffer)
4428 (switch-to-buffer gnus-group-buffer)
4429 (gnus-add-current-to-buffer-list)
4431 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4433 (defun gnus-group-list-groups (&optional level unread lowest)
4434 "List newsgroups with level LEVEL or lower that have unread articles.
4435 Default is all subscribed groups.
4436 If argument UNREAD is non-nil, groups with no unread articles are also
4438 (interactive (list (if current-prefix-arg
4439 (prefix-numeric-value current-prefix-arg)
4441 (gnus-group-default-level nil t)
4442 gnus-group-default-list-level
4443 gnus-level-subscribed))))
4445 (setq level (car gnus-group-list-mode)
4446 unread (cdr gnus-group-list-mode)))
4447 (setq level (gnus-group-default-level level))
4448 (gnus-group-setup-buffer) ;May call from out of group buffer
4449 (gnus-update-format-specifications)
4450 (let ((case-fold-search nil)
4451 (props (text-properties-at (gnus-point-at-bol)))
4452 (group (gnus-group-group-name)))
4453 (set-buffer gnus-group-buffer)
4454 (funcall gnus-group-prepare-function level unread lowest)
4455 (if (zerop (buffer-size))
4456 (gnus-message 5 gnus-no-groups-message)
4457 (goto-char (point-max))
4458 (when (or (not gnus-group-goto-next-group-function)
4459 (not (funcall gnus-group-goto-next-group-function
4462 ;; Go to the first group with unread articles.
4463 (gnus-group-search-forward t)
4464 ;; Find the right group to put point on. If the current group
4465 ;; has disappeared in the new listing, try to find the next
4466 ;; one. If no next one can be found, just leave point at the
4467 ;; first newsgroup in the buffer.
4468 (if (not (gnus-goto-char
4470 (point-min) (point-max)
4471 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4472 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4474 (not (gnus-goto-char
4476 (point-min) (point-max) 'gnus-group
4478 (caar newsrc) gnus-active-hashtb)))))
4479 (setq newsrc (cdr newsrc)))
4480 (or newsrc (progn (goto-char (point-max))
4481 (forward-line -1)))))))
4482 ;; Adjust cursor point.
4483 (gnus-group-position-point))))
4485 (defun gnus-group-list-level (level &optional all)
4486 "List groups on LEVEL.
4487 If ALL (the prefix), also list groups that have no unread articles."
4488 (interactive "nList groups on level: \nP")
4489 (gnus-group-list-groups level all level))
4491 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4492 "List all newsgroups with unread articles of level LEVEL or lower.
4493 If ALL is non-nil, list groups that have no unread articles.
4494 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4495 If REGEXP, only list groups matching REGEXP."
4496 (set-buffer gnus-group-buffer)
4497 (let ((buffer-read-only nil)
4498 (newsrc (cdr gnus-newsrc-alist))
4499 (lowest (or lowest 1))
4500 info clevel unread group params)
4502 (if (< lowest gnus-level-zombie)
4503 ;; List living groups.
4505 (setq info (car newsrc)
4506 group (gnus-info-group info)
4507 params (gnus-info-params info)
4509 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4510 (and unread ; This group might be bogus
4512 (string-match regexp group))
4513 (<= (setq clevel (gnus-info-level info)) level)
4515 (or all ; We list all groups?
4516 (if (eq unread t) ; Unactivated?
4517 gnus-group-list-inactive-groups ; We list unactivated
4518 (> unread 0)) ; We list groups with unread articles
4519 (and gnus-list-groups-with-ticked-articles
4520 (cdr (assq 'tick (gnus-info-marks info))))
4521 ; And groups with tickeds
4522 ;; Check for permanent visibility.
4523 (and gnus-permanently-visible-groups
4524 (string-match gnus-permanently-visible-groups
4526 (memq 'visible params)
4527 (cdr (assq 'visible params)))
4528 (gnus-group-insert-group-line
4529 group (gnus-info-level info)
4530 (gnus-info-marks info) unread (gnus-info-method info)))))
4532 ;; List dead groups.
4533 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4534 (gnus-group-prepare-flat-list-dead
4535 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4536 gnus-level-zombie ?Z
4538 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4539 (gnus-group-prepare-flat-list-dead
4540 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4541 gnus-level-killed ?K regexp))
4543 (gnus-group-set-mode-line)
4544 (setq gnus-group-list-mode (cons level all))
4545 (run-hooks 'gnus-group-prepare-hook)))
4547 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4548 ;; List zombies and killed lists somewhat faster, which was
4549 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4550 ;; this by ignoring the group format specification altogether.
4553 ;; This loop is used when listing groups that match some
4556 (setq group (pop groups))
4557 (when (string-match regexp group)
4558 (add-text-properties
4559 (point) (prog1 (1+ (point))
4560 (insert " " mark " *: " group "\n"))
4561 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4563 'gnus-level level))))
4564 ;; This loop is used when listing all groups.
4566 (add-text-properties
4567 (point) (prog1 (1+ (point))
4568 (insert " " mark " *: "
4569 (setq group (pop groups)) "\n"))
4570 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4572 'gnus-level level))))))
4574 (defmacro gnus-group-real-name (group)
4575 "Find the real name of a foreign newsgroup."
4576 `(let ((gname ,group))
4577 (if (string-match ":[^:]+$" gname)
4578 (substring gname (1+ (match-beginning 0)))
4581 (defsubst gnus-server-add-address (method)
4582 (let ((method-name (symbol-name (car method))))
4583 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4584 (not (assq (intern (concat method-name "-address")) method)))
4585 (append method (list (list (intern (concat method-name "-address"))
4589 (defsubst gnus-server-get-method (group method)
4590 ;; Input either a server name, and extended server name, or a
4591 ;; select method, and return a select method.
4592 (cond ((stringp method)
4593 (gnus-server-to-method method))
4594 ((equal method gnus-select-method)
4596 ((and (stringp (car method)) group)
4597 (gnus-server-extend-method group method))
4598 ((and method (not group)
4599 (equal (cadr method) ""))
4602 (gnus-server-add-address method))))
4604 (defun gnus-server-to-method (server)
4605 "Map virtual server names to select methods."
4607 ;; Perhaps this is the native server?
4608 (and (equal server "native") gnus-select-method)
4609 ;; It should be in the server alist.
4610 (cdr (assoc server gnus-server-alist))
4611 ;; If not, we look through all the opened server
4612 ;; to see whether we can find it there.
4613 (let ((opened gnus-opened-servers))
4615 (not (equal server (format "%s:%s" (caaar opened)
4620 (defmacro gnus-method-equal (ss1 ss2)
4621 "Say whether two servers are equal."
4625 (and (= (length s1) (length s2))
4627 (while (and s1 (member (car s1) s2))
4631 (defun gnus-server-equal (m1 m2)
4632 "Say whether two methods are equal."
4633 (let ((m1 (cond ((null m1) gnus-select-method)
4634 ((stringp m1) (gnus-server-to-method m1))
4636 (m2 (cond ((null m2) gnus-select-method)
4637 ((stringp m2) (gnus-server-to-method m2))
4639 (gnus-method-equal m1 m2)))
4641 (defun gnus-servers-using-backend (backend)
4642 "Return a list of known servers using BACKEND."
4643 (let ((opened gnus-opened-servers)
4646 (when (eq backend (caaar opened))
4647 (push (caar opened) out))
4651 (defun gnus-group-prefixed-name (group method)
4652 "Return the whole name from GROUP and METHOD."
4653 (and (stringp method) (setq method (gnus-server-to-method method)))
4654 (concat (format "%s" (car method))
4656 (or (assoc (format "%s" (car method))
4657 (gnus-methods-using 'address))
4658 (gnus-server-equal method gnus-message-archive-method))
4660 (not (string= (nth 1 method) "")))
4661 (concat "+" (nth 1 method)))
4664 (defun gnus-group-real-prefix (group)
4665 "Return the prefix of the current group name."
4666 (if (string-match "^[^:]+:" group)
4667 (substring group 0 (match-end 0))
4670 (defun gnus-group-method (group)
4671 "Return the server or method used for selecting GROUP."
4672 (let ((prefix (gnus-group-real-prefix group)))
4673 (if (equal prefix "")
4675 (let ((servers gnus-opened-servers)
4677 backend possible found)
4678 (if (string-match "^[^\\+]+\\+" prefix)
4679 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4680 server (substring prefix (match-end 0) (1- (length prefix))))
4681 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4683 (when (eq (caaar servers) backend)
4684 (setq possible (caar servers))
4685 (when (equal (cadaar servers) server)
4686 (setq found (caar servers))))
4688 (or (car (rassoc found gnus-server-alist))
4690 (car (rassoc possible gnus-server-alist))
4692 (list backend server))))))
4694 (defsubst gnus-secondary-method-p (method)
4695 "Return whether METHOD is a secondary select method."
4696 (let ((methods gnus-secondary-select-methods)
4697 (gmethod (gnus-server-get-method nil method)))
4699 (not (equal (gnus-server-get-method nil (car methods))
4701 (setq methods (cdr methods)))
4704 (defun gnus-group-foreign-p (group)
4705 "Say whether a group is foreign or not."
4706 (and (not (gnus-group-native-p group))
4707 (not (gnus-group-secondary-p group))))
4709 (defun gnus-group-native-p (group)
4710 "Say whether the group is native or not."
4711 (not (string-match ":" group)))
4713 (defun gnus-group-secondary-p (group)
4714 "Say whether the group is secondary or not."
4715 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4717 (defun gnus-group-get-parameter (group &optional symbol)
4718 "Returns the group parameters for GROUP.
4719 If SYMBOL, return the value of that symbol in the group parameters."
4720 (let ((params (gnus-info-params (gnus-get-info group))))
4722 (gnus-group-parameter-value params symbol)
4725 (defun gnus-group-parameter-value (params symbol)
4726 "Return the value of SYMBOL in group PARAMS."
4727 (or (car (memq symbol params)) ; It's either a simple symbol
4728 (cdr (assq symbol params)))) ; or a cons.
4730 (defun gnus-group-add-parameter (group param)
4731 "Add parameter PARAM to GROUP."
4732 (let ((info (gnus-get-info group)))
4734 () ; This is a dead group. We just ignore it.
4735 ;; Cons the new param to the old one and update.
4736 (gnus-group-set-info (cons param (gnus-info-params info))
4739 (defun gnus-group-set-parameter (group name value)
4740 "Set parameter NAME to VALUE in GROUP."
4741 (let ((info (gnus-get-info group)))
4743 () ; This is a dead group. We just ignore it.
4744 (let ((old-params (gnus-info-params info))
4745 (new-params (list (cons name value))))
4747 (if (or (not (listp (car old-params)))
4748 (not (eq (caar old-params) name)))
4749 (setq new-params (append new-params (list (car old-params)))))
4750 (setq old-params (cdr old-params)))
4751 (gnus-group-set-info new-params group 'params)))))
4753 (defun gnus-group-add-score (group &optional score)
4754 "Add SCORE to the GROUP score.
4755 If SCORE is nil, add 1 to the score of GROUP."
4756 (let ((info (gnus-get-info group)))
4758 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4760 (defun gnus-summary-bubble-group ()
4761 "Increase the score of the current group.
4762 This is a handy function to add to `gnus-summary-exit-hook' to
4763 increase the score of each group you read."
4764 (gnus-group-add-score gnus-newsgroup-name))
4766 (defun gnus-group-set-info (info &optional method-only-group part)
4767 (let* ((entry (gnus-gethash
4768 (or method-only-group (gnus-info-group info))
4769 gnus-newsrc-hashtb))
4771 (info (if method-only-group (nth 2 entry) info))
4773 (when method-only-group
4775 (error "Trying to change non-existent group %s" method-only-group))
4776 ;; We have received parts of the actual group info - either the
4777 ;; select method or the group parameters. We first check
4778 ;; whether we have to extend the info, and if so, do that.
4779 (let ((len (length info))
4780 (total (if (eq part 'method) 5 6)))
4782 (setcdr (nthcdr (1- len) info)
4783 (make-list (- total len) nil)))
4784 ;; Then we enter the new info.
4785 (setcar (nthcdr (1- total) info) part-info)))
4787 ;; This is a new group, so we just create it.
4789 (set-buffer gnus-group-buffer)
4790 (setq method (gnus-info-method info))
4791 (when (gnus-server-equal method "native")
4794 (set-buffer gnus-group-buffer)
4796 ;; It's a foreign group...
4797 (gnus-group-make-group
4798 (gnus-group-real-name (gnus-info-group info))
4799 (if (stringp method) method
4800 (prin1-to-string (car method)))
4802 (nth 1 (gnus-info-method info))))
4803 ;; It's a native group.
4804 (gnus-group-make-group (gnus-info-group info))))
4805 (gnus-message 6 "Note: New group created")
4807 (gnus-gethash (gnus-group-prefixed-name
4808 (gnus-group-real-name (gnus-info-group info))
4809 (or (gnus-info-method info) gnus-select-method))
4810 gnus-newsrc-hashtb))))
4811 ;; Whether it was a new group or not, we now have the entry, so we
4812 ;; can do the update.
4815 (setcar (nthcdr 2 entry) info)
4816 (when (and (not (eq (car entry) t))
4817 (gnus-active (gnus-info-group info)))
4818 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4819 (error "No such group: %s" (gnus-info-group info)))))
4821 (defun gnus-group-set-method-info (group select-method)
4822 (gnus-group-set-info select-method group 'method))
4824 (defun gnus-group-set-params-info (group params)
4825 (gnus-group-set-info params group 'params))
4827 (defun gnus-group-update-group-line ()
4828 "Update the current line in the group buffer."
4829 (let* ((buffer-read-only nil)
4830 (group (gnus-group-group-name))
4831 (gnus-group-indentation (gnus-group-group-indentation))
4832 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4834 (not (gnus-ephemeral-group-p group))
4836 (concat "(gnus-group-set-info '"
4837 (prin1-to-string (nth 2 entry)) ")")))
4839 (gnus-group-insert-group-line-info group)
4841 (gnus-group-position-point)))
4843 (defun gnus-group-insert-group-line-info (group)
4844 "Insert GROUP on the current line."
4845 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4847 (setq gnus-group-indentation (gnus-group-group-indentation))
4850 ;; (Un)subscribed group.
4851 (setq info (nth 2 entry))
4852 (gnus-group-insert-group-line
4853 group (gnus-info-level info) (gnus-info-marks info)
4854 (or (car entry) t) (gnus-info-method info)))
4855 ;; This group is dead.
4856 (gnus-group-insert-group-line
4858 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4860 (if (setq active (gnus-active group))
4861 (- (1+ (cdr active)) (car active)) 0)
4864 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4865 gnus-tmp-marked number
4867 "Insert a group line in the group buffer."
4868 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4869 (gnus-tmp-number-total
4871 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4873 (gnus-tmp-number-of-unread
4874 (if (numberp number) (int-to-string (max 0 number))
4876 (gnus-tmp-number-of-read
4877 (if (numberp number)
4878 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4880 (gnus-tmp-subscribed
4881 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4882 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4883 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4885 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4886 (gnus-tmp-newsgroup-description
4887 (if gnus-description-hashtb
4888 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4891 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4892 (gnus-tmp-moderated-string
4893 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4895 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4896 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4897 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4898 (gnus-tmp-news-method-string
4900 (format "(%s:%s)" (car gnus-tmp-method)
4901 (cadr gnus-tmp-method)) ""))
4902 (gnus-tmp-marked-mark
4903 (if (and (numberp number)
4905 (cdr (assq 'tick gnus-tmp-marked)))
4907 (gnus-tmp-process-marked
4908 (if (member gnus-tmp-group gnus-group-marked)
4909 gnus-process-mark ? ))
4911 (or (and gnus-use-grouplens
4912 (bbb-grouplens-group-p gnus-tmp-group))
4914 (buffer-read-only nil)
4915 header gnus-tmp-header) ; passed as parameter to user-funcs.
4917 (add-text-properties
4921 (eval gnus-group-line-format-spec))
4922 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4923 gnus-unread ,(if (numberp number)
4924 (string-to-int gnus-tmp-number-of-unread)
4926 gnus-marked ,gnus-tmp-marked-mark
4927 gnus-indentation ,gnus-group-indentation
4928 gnus-level ,gnus-tmp-level))
4929 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4931 (run-hooks 'gnus-group-update-hook)
4933 ;; Allow XEmacs to remove front-sticky text properties.
4934 (gnus-group-remove-excess-properties)))
4936 (defun gnus-group-update-group (group &optional visible-only)
4937 "Update all lines where GROUP appear.
4938 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4941 (set-buffer gnus-group-buffer)
4942 ;; The buffer may be narrowed.
4945 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4947 found buffer-read-only)
4948 ;; Enter the current status into the dribble buffer.
4949 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4950 (if (and entry (not (gnus-ephemeral-group-p group)))
4952 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4954 ;; Find all group instances. If topics are in use, each group
4955 ;; may be listed in more than once.
4956 (while (setq loc (text-property-any
4957 loc (point-max) 'gnus-group ident))
4960 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4962 (gnus-group-insert-group-line-info group))
4963 (setq loc (1+ loc)))
4964 (unless (or found visible-only)
4965 ;; No such line in the buffer, find out where it's supposed to
4966 ;; go, and insert it there (or at the end of the buffer).
4967 (if gnus-goto-missing-group-function
4968 (funcall gnus-goto-missing-group-function group)
4969 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4970 (while (and entry (car entry)
4974 (point-min) (point-max)
4975 'gnus-group (gnus-intern-safe
4976 (caar entry) gnus-active-hashtb)))))
4977 (setq entry (cdr entry)))
4978 (or entry (goto-char (point-max)))))
4979 ;; Finally insert the line.
4980 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4981 (gnus-group-insert-group-line-info group)))
4982 (gnus-group-set-mode-line)))))
4984 (defun gnus-group-set-mode-line ()
4985 (when (memq 'group gnus-updated-mode-lines)
4986 (let* ((gformat (or gnus-group-mode-line-format-spec
4987 (setq gnus-group-mode-line-format-spec
4989 gnus-group-mode-line-format
4990 gnus-group-mode-line-format-alist))))
4991 (gnus-tmp-news-server (cadr gnus-select-method))
4992 (gnus-tmp-news-method (car gnus-select-method))
4994 gnus-tmp-header ;Dummy binding for user-defined formats
4995 ;; Get the resulting string.
4996 (mode-string (eval gformat)))
4997 ;; If the line is too long, we chop it off.
4998 (when (> (length mode-string) max-len)
4999 (setq mode-string (substring mode-string 0 (- max-len 4))))
5001 (setq mode-line-buffer-identification (list mode-string))
5002 (set-buffer-modified-p t)))))
5004 (defun gnus-group-group-name ()
5005 "Get the name of the newsgroup on the current line."
5006 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5007 (and group (symbol-name group))))
5009 (defun gnus-group-group-level ()
5010 "Get the level of the newsgroup on the current line."
5011 (get-text-property (gnus-point-at-bol) 'gnus-level))
5013 (defun gnus-group-group-indentation ()
5014 "Get the indentation of the newsgroup on the current line."
5015 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5016 (and gnus-group-indentation-function
5017 (funcall gnus-group-indentation-function))
5020 (defun gnus-group-group-unread ()
5021 "Get the number of unread articles of the newsgroup on the current line."
5022 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5024 (defun gnus-group-search-forward (&optional backward all level first-too)
5025 "Find the next newsgroup with unread articles.
5026 If BACKWARD is non-nil, find the previous newsgroup instead.
5027 If ALL is non-nil, just find any newsgroup.
5028 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5030 If FIRST-TOO, the current line is also eligible as a target."
5031 (let ((way (if backward -1 1))
5032 (low gnus-level-killed)
5035 (if (and backward (progn (beginning-of-line)) (bobp))
5037 (or first-too (forward-line way))
5045 (get-text-property (point) 'gnus-unread)))
5046 (and (numberp unread) (> unread 0)))
5047 (setq lev (get-text-property (point)
5049 (<= lev gnus-level-subscribed)))
5051 (and (setq lev (get-text-property (point)
5060 (zerop (forward-line way)))))
5062 (progn (gnus-group-position-point) t)
5063 (goto-char (or pos beg))
5066 ;;; Gnus group mode commands
5070 (defun gnus-group-mark-group (n &optional unmark no-advance)
5071 "Mark the current group."
5073 (let ((buffer-read-only nil)
5077 (setq group (gnus-group-group-name))
5081 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5086 (setq gnus-group-marked (delete group gnus-group-marked)))
5088 (setq gnus-group-marked
5089 (cons group (delete group gnus-group-marked))))
5091 (or no-advance (zerop (gnus-group-next-group 1))))
5093 (gnus-summary-position-point)
5096 (defun gnus-group-unmark-group (n)
5097 "Remove the mark from the current group."
5099 (gnus-group-mark-group n 'unmark)
5100 (gnus-group-position-point))
5102 (defun gnus-group-unmark-all-groups ()
5103 "Unmark all groups."
5105 (let ((groups gnus-group-marked))
5108 (gnus-group-remove-mark (pop groups)))))
5109 (gnus-group-position-point))
5111 (defun gnus-group-mark-region (unmark beg end)
5112 "Mark all groups between point and mark.
5113 If UNMARK, remove the mark instead."
5114 (interactive "P\nr")
5115 (let ((num (count-lines beg end)))
5118 (- num (gnus-group-mark-group num unmark)))))
5120 (defun gnus-group-mark-buffer (&optional unmark)
5121 "Mark all groups in the buffer.
5122 If UNMARK, remove the mark instead."
5124 (gnus-group-mark-region unmark (point-min) (point-max)))
5126 (defun gnus-group-mark-regexp (regexp)
5127 "Mark all groups that match some regexp."
5128 (interactive "sMark (regexp): ")
5129 (let ((alist (cdr gnus-newsrc-alist))
5132 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5133 (gnus-group-set-mark group))))
5134 (gnus-group-position-point))
5136 (defun gnus-group-remove-mark (group)
5137 "Remove the process mark from GROUP and move point there.
5138 Return nil if the group isn't displayed."
5139 (if (gnus-group-goto-group group)
5141 (gnus-group-mark-group 1 'unmark t)
5143 (setq gnus-group-marked
5144 (delete group gnus-group-marked))
5147 (defun gnus-group-set-mark (group)
5148 "Set the process mark on GROUP."
5149 (if (gnus-group-goto-group group)
5151 (gnus-group-mark-group 1 nil t))
5152 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5154 (defun gnus-group-universal-argument (arg &optional groups func)
5155 "Perform any command on all groups accoring to the process/prefix convention."
5157 (let ((groups (or groups (gnus-group-process-prefix arg)))
5159 (if (eq (setq func (or func
5162 (substitute-command-keys
5163 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5165 (gnus-error 1 "Undefined key")
5167 (gnus-group-remove-mark (setq group (pop groups)))
5168 (command-execute func))))
5169 (gnus-group-position-point))
5171 (defun gnus-group-process-prefix (n)
5172 "Return a list of groups to work on.
5173 Take into consideration N (the prefix) and the list of marked groups."
5176 (setq n (prefix-numeric-value n))
5177 ;; There is a prefix, so we return a list of the N next
5179 (let ((way (if (< n 0) -1 1))
5184 (setq group (gnus-group-group-name)))
5185 (setq groups (cons group groups))
5187 (gnus-group-next-group way)))
5189 ((and (boundp 'transient-mark-mode)
5191 (boundp 'mark-active)
5193 ;; Work on the region between point and mark.
5194 (let ((max (max (point) (mark)))
5197 (goto-char (min (point) (mark)))
5200 (push (gnus-group-group-name) groups)
5201 (zerop (gnus-group-next-group 1))
5203 (nreverse groups))))
5205 ;; No prefix, but a list of marked articles.
5206 (reverse gnus-group-marked))
5208 ;; Neither marked articles or a prefix, so we return the
5210 (let ((group (gnus-group-group-name)))
5211 (and group (list group))))))
5213 ;; Selecting groups.
5215 (defun gnus-group-read-group (&optional all no-article group)
5216 "Read news in this newsgroup.
5217 If the prefix argument ALL is non-nil, already read articles become
5218 readable. IF ALL is a number, fetch this number of articles. If the
5219 optional argument NO-ARTICLE is non-nil, no article will be
5220 auto-selected upon group entry. If GROUP is non-nil, fetch that
5223 (let ((group (or group (gnus-group-group-name)))
5224 number active marked entry)
5225 (or group (error "No group on current line"))
5226 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5227 group gnus-newsrc-hashtb)))))
5228 ;; This group might be a dead group. In that case we have to get
5229 ;; the number of unread articles from `gnus-active-hashtb'.
5231 (cond ((numberp all) all)
5233 ((setq active (gnus-active group))
5234 (- (1+ (cdr active)) (car active)))))
5235 (gnus-summary-read-group
5236 group (or all (and (numberp number)
5237 (zerop (+ number (length (cdr (assq 'tick marked)))
5238 (length (cdr (assq 'dormant marked)))))))
5241 (defun gnus-group-select-group (&optional all)
5242 "Select this newsgroup.
5243 No article is selected automatically.
5244 If ALL is non-nil, already read articles become readable.
5245 If ALL is a number, fetch this number of articles."
5247 (gnus-group-read-group all t))
5249 (defun gnus-group-quick-select-group (&optional all)
5250 "Select the current group \"quickly\".
5251 This means that no highlighting or scoring will be performed."
5254 gnus-score-find-score-files-function
5255 gnus-apply-kill-hook
5256 gnus-summary-expunge-below)
5257 (gnus-group-read-group all t)))
5259 (defun gnus-group-visible-select-group (&optional all)
5260 "Select the current group without hiding any articles."
5262 (let ((gnus-inhibit-limiting t))
5263 (gnus-group-read-group all t)))
5266 (defun gnus-fetch-group (group)
5267 "Start Gnus if necessary and enter GROUP.
5268 Returns whether the fetching was successful or not."
5269 (interactive "sGroup name: ")
5270 (or (get-buffer gnus-group-buffer)
5272 (gnus-group-read-group nil nil group))
5274 ;; Enter a group that is not in the group buffer. Non-nil is returned
5275 ;; if selection was successful.
5276 (defun gnus-group-read-ephemeral-group
5277 (group method &optional activate quit-config)
5278 (let ((group (if (gnus-group-foreign-p group) group
5279 (gnus-group-prefixed-name group method))))
5282 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5283 ((quit-config . ,(if quit-config quit-config
5284 (cons (current-buffer) 'summary))))))
5286 (set-buffer gnus-group-buffer)
5287 (or (gnus-check-server method)
5288 (error "Unable to contact server: %s" (gnus-status-message method)))
5289 (if activate (or (gnus-request-group group)
5290 (error "Couldn't request group")))
5292 (gnus-group-read-group t t group)
5296 (defun gnus-group-jump-to-group (group)
5297 "Jump to newsgroup GROUP."
5299 (list (completing-read
5300 "Group: " gnus-active-hashtb nil
5301 (memq gnus-select-method gnus-have-read-active-file)
5303 'gnus-group-history)))
5305 (when (equal group "")
5306 (error "Empty group name"))
5308 (when (string-match "[\000-\032]" group)
5309 (error "Control characters in group: %s" group))
5311 (let ((b (text-property-any
5312 (point-min) (point-max)
5313 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5314 (unless (gnus-ephemeral-group-p group)
5316 ;; Either go to the line in the group buffer...
5318 ;; ... or insert the line.
5321 (gnus-activate-group group)
5322 (error "%s error: %s" group (gnus-status-message group)))
5324 (gnus-group-update-group group)
5325 (goto-char (text-property-any
5326 (point-min) (point-max)
5327 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5328 ;; Adjust cursor point.
5329 (gnus-group-position-point)))
5331 (defun gnus-group-goto-group (group)
5332 "Goto to newsgroup GROUP."
5334 (let ((b (text-property-any (point-min) (point-max)
5335 'gnus-group (gnus-intern-safe
5336 group gnus-active-hashtb))))
5337 (and b (goto-char b)))))
5339 (defun gnus-group-next-group (n)
5340 "Go to next N'th newsgroup.
5341 If N is negative, search backward instead.
5342 Returns the difference between N and the number of skips actually
5345 (gnus-group-next-unread-group n t))
5347 (defun gnus-group-next-unread-group (n &optional all level)
5348 "Go to next N'th unread newsgroup.
5349 If N is negative, search backward instead.
5350 If ALL is non-nil, choose any newsgroup, unread or not.
5351 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5352 such group can be found, the next group with a level higher than
5354 Returns the difference between N and the number of skips actually
5357 (let ((backward (< n 0))
5360 (gnus-group-search-forward
5361 backward (or (not gnus-group-goto-unread) all) level))
5363 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5364 (if level " on this level or higher" "")))
5367 (defun gnus-group-prev-group (n)
5368 "Go to previous N'th newsgroup.
5369 Returns the difference between N and the number of skips actually
5372 (gnus-group-next-unread-group (- n) t))
5374 (defun gnus-group-prev-unread-group (n)
5375 "Go to previous N'th unread newsgroup.
5376 Returns the difference between N and the number of skips actually
5379 (gnus-group-next-unread-group (- n)))
5381 (defun gnus-group-next-unread-group-same-level (n)
5382 "Go to next N'th unread newsgroup on the same level.
5383 If N is negative, search backward instead.
5384 Returns the difference between N and the number of skips actually
5387 (gnus-group-next-unread-group n t (gnus-group-group-level))
5388 (gnus-group-position-point))
5390 (defun gnus-group-prev-unread-group-same-level (n)
5391 "Go to next N'th unread newsgroup on the same level.
5392 Returns the difference between N and the number of skips actually
5395 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5396 (gnus-group-position-point))
5398 (defun gnus-group-best-unread-group (&optional exclude-group)
5399 "Go to the group with the highest level.
5400 If EXCLUDE-GROUP, do not go to that group."
5402 (goto-char (point-min))
5406 (setq unread (get-text-property (point) 'gnus-unread))
5407 (if (and (numberp unread) (> unread 0))
5409 (if (and (get-text-property (point) 'gnus-level)
5410 (< (get-text-property (point) 'gnus-level) best)
5411 (or (not exclude-group)
5412 (not (equal exclude-group (gnus-group-group-name)))))
5414 (setq best (get-text-property (point) 'gnus-level))
5415 (setq best-point (point))))))
5417 (if best-point (goto-char best-point))
5418 (gnus-summary-position-point)
5419 (and best-point (gnus-group-group-name))))
5421 (defun gnus-group-first-unread-group ()
5422 "Go to the first group with unread articles."
5425 (let ((opoint (point))
5427 (goto-char (point-min))
5428 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5429 (and (numberp unread) ; Not a topic.
5430 (not (zerop unread))) ; Has unread articles.
5431 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5434 nil)) ; Not success.
5435 (gnus-group-position-point)))
5437 (defun gnus-group-enter-server-mode ()
5438 "Jump to the server buffer."
5440 (gnus-enter-server-buffer))
5442 (defun gnus-group-make-group (name &optional method address)
5443 "Add a new newsgroup.
5444 The user will be prompted for a NAME, for a select METHOD, and an
5448 (read-string "Group name: ")
5451 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5452 nil t nil 'gnus-method-history)))
5453 (cond ((assoc method gnus-valid-select-methods)
5455 (if (memq 'prompt-address
5456 (assoc method gnus-valid-select-methods))
5457 (read-string "Address: ")
5459 ((assoc method gnus-server-alist)
5462 (list method ""))))))
5464 (let* ((meth (and method (if address (list (intern method) address)
5466 (nname (if method (gnus-group-prefixed-name name meth) name))
5468 (when (gnus-gethash nname gnus-newsrc-hashtb)
5469 (error "Group %s already exists" nname))
5470 ;; Subscribe to the new group.
5471 (gnus-group-change-level
5472 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5473 gnus-level-default-subscribed gnus-level-killed
5474 (and (gnus-group-group-name)
5475 (gnus-gethash (gnus-group-group-name)
5476 gnus-newsrc-hashtb))
5479 (gnus-set-active nname (cons 1 0))
5480 (or (gnus-ephemeral-group-p name)
5482 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5484 (gnus-group-insert-group-line-info nname)
5486 (gnus-group-position-point)
5488 ;; Load the backend and try to make the backend create
5489 ;; the group as well.
5490 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5492 gnus-valid-select-methods)
5494 (gnus-check-server meth)
5495 (and (gnus-check-backend-function 'request-create-group nname)
5496 (gnus-request-create-group nname))
5499 (defun gnus-group-delete-group (group &optional force)
5500 "Delete the current group.
5501 If FORCE (the prefix) is non-nil, all the articles in the group will
5502 be deleted. This is \"deleted\" as in \"removed forever from the face
5503 of the Earth\". There is no undo."
5505 (list (gnus-group-group-name)
5506 current-prefix-arg))
5507 (or group (error "No group to rename"))
5508 (or (gnus-check-backend-function 'request-delete-group group)
5509 (error "This backend does not support group deletion"))
5511 (if (not (gnus-yes-or-no-p
5513 "Do you really want to delete %s%s? "
5514 group (if force " and all its contents" ""))))
5516 (gnus-message 6 "Deleting group %s..." group)
5517 (if (not (gnus-request-delete-group group force))
5518 (gnus-error 3 "Couldn't delete group %s" group)
5519 (gnus-message 6 "Deleting group %s...done" group)
5520 (gnus-group-goto-group group)
5521 (gnus-group-kill-group 1 t)
5522 (gnus-sethash group nil gnus-active-hashtb)
5524 (gnus-group-position-point)))
5526 (defun gnus-group-rename-group (group new-name)
5529 (gnus-group-group-name)
5531 (or (gnus-check-backend-function
5532 'request-rename-group (gnus-group-group-name))
5533 (error "This backend does not support renaming groups"))
5534 (read-string "New group name: "))))
5536 (or (gnus-check-backend-function 'request-rename-group group)
5537 (error "This backend does not support renaming groups"))
5539 (or group (error "No group to rename"))
5540 (and (string-match "^[ \t]*$" new-name)
5541 (error "Not a valid group name"))
5543 ;; We find the proper prefixed name.
5545 (gnus-group-prefixed-name
5546 (gnus-group-real-name new-name)
5547 (gnus-info-method (gnus-get-info group))))
5549 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5551 (if (not (gnus-request-rename-group group new-name))
5552 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5553 ;; We rename the group internally by killing it...
5554 (gnus-group-goto-group group)
5555 (gnus-group-kill-group)
5556 ;; ... changing its name ...
5557 (setcar (cdar gnus-list-of-killed-groups) new-name)
5558 ;; ... and then yanking it. Magic!
5559 (gnus-group-yank-group)
5560 (gnus-set-active new-name (gnus-active group))
5561 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5563 (gnus-group-position-point)))
5565 (defun gnus-group-edit-group (group &optional part)
5566 "Edit the group on the current line."
5567 (interactive (list (gnus-group-group-name)))
5568 (let* ((part (or part 'info))
5569 (done-func `(lambda ()
5570 "Exit editing mode and update the information."
5572 (gnus-group-edit-group-done ',part ,group)))
5573 (winconf (current-window-configuration))
5575 (or group (error "No group on current line"))
5576 (or (setq info (gnus-get-info group))
5577 (error "Killed group; can't be edited"))
5578 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5579 (gnus-configure-windows 'edit-group)
5580 (gnus-add-current-to-buffer-list)
5582 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5583 (use-local-map (copy-keymap emacs-lisp-mode-map))
5584 (local-set-key "\C-c\C-c" done-func)
5585 (make-local-variable 'gnus-prev-winconf)
5586 (setq gnus-prev-winconf winconf)
5591 ";; Type `C-c C-c' after editing the select method.\n\n")
5593 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5595 ";; Type `C-c C-c' after editing the group info.\n\n")))
5598 (cond ((eq part 'method)
5599 (or (gnus-info-method info) "native"))
5601 (gnus-info-params info))
5605 (defun gnus-group-edit-group-method (group)
5606 "Edit the select method of GROUP."
5607 (interactive (list (gnus-group-group-name)))
5608 (gnus-group-edit-group group 'method))
5610 (defun gnus-group-edit-group-parameters (group)
5611 "Edit the group parameters of GROUP."
5612 (interactive (list (gnus-group-group-name)))
5613 (gnus-group-edit-group group 'params))
5615 (defun gnus-group-edit-group-done (part group)
5616 "Get info from buffer, update variables and jump to the group buffer."
5617 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5618 (goto-char (point-min))
5619 (let* ((form (read (current-buffer)))
5620 (winconf gnus-prev-winconf)
5621 (method (cond ((eq part 'info) (nth 4 form))
5622 ((eq part 'method) form)
5624 (info (cond ((eq part 'info) form)
5625 ((eq part 'method) (gnus-get-info group))
5628 (if (or (not method)
5630 gnus-select-method method))
5631 (gnus-group-real-name (car info))
5632 (gnus-group-prefixed-name
5633 (gnus-group-real-name (car info)) method))
5635 (when (and new-group
5636 (not (equal new-group group)))
5637 (when (gnus-group-goto-group group)
5638 (gnus-group-kill-group 1))
5639 (gnus-activate-group new-group))
5641 (if (and info new-group)
5643 (setq info (gnus-copy-sequence info))
5644 (setcar info new-group)
5645 (unless (gnus-server-equal method "native")
5646 (unless (nthcdr 3 info)
5647 (nconc info (list nil nil)))
5648 (unless (nthcdr 4 info)
5649 (nconc info (list nil)))
5650 (gnus-info-set-method info method))
5651 (gnus-group-set-info info))
5652 (gnus-group-set-info form (or new-group group) part))
5653 (kill-buffer (current-buffer))
5654 (and winconf (set-window-configuration winconf))
5655 (set-buffer gnus-group-buffer)
5656 (gnus-group-update-group (or new-group group))
5657 (gnus-group-position-point)))
5659 (defun gnus-group-make-help-group ()
5660 "Create the Gnus documentation group."
5662 (let ((path load-path)
5663 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5665 (and (gnus-gethash name gnus-newsrc-hashtb)
5666 (error "Documentation group already exists"))
5668 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5670 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5672 (setq file (concat (file-name-directory
5673 (directory-file-name dir))
5674 "etc/gnus-tut.txt"))))
5677 (gnus-message 1 "Couldn't find doc group")
5678 (gnus-group-make-group
5679 (gnus-group-real-name name)
5680 (list 'nndoc "gnus-help"
5681 (list 'nndoc-address file)
5682 (list 'nndoc-article-type 'mbox)))))
5683 (gnus-group-position-point))
5685 (defun gnus-group-make-doc-group (file type)
5686 "Create a group that uses a single file as the source."
5688 (list (read-file-name "File name: ")
5689 (and current-prefix-arg 'ask)))
5690 (when (eq type 'ask)
5695 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5697 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5698 ((= char ?b) 'babyl)
5699 ((= char ?d) 'digest)
5700 ((= char ?f) 'forward)
5702 (t (setq err (format "%c unknown. " char))
5705 (let* ((file (expand-file-name file))
5706 (name (gnus-generate-new-group-name
5707 (gnus-group-prefixed-name
5708 (file-name-nondirectory file) '(nndoc "")))))
5709 (gnus-group-make-group
5710 (gnus-group-real-name name)
5711 (list 'nndoc (file-name-nondirectory file)
5712 (list 'nndoc-address file)
5713 (list 'nndoc-article-type (or type 'guess))))))
5715 (defun gnus-group-make-archive-group (&optional all)
5716 "Create the (ding) Gnus archive group of the most recent articles.
5717 Given a prefix, create a full group."
5719 (let ((group (gnus-group-prefixed-name
5720 (if all "ding.archives" "ding.recent") '(nndir ""))))
5721 (and (gnus-gethash group gnus-newsrc-hashtb)
5722 (error "Archive group already exists"))
5723 (gnus-group-make-group
5724 (gnus-group-real-name group)
5725 (list 'nndir (if all "hpc" "edu")
5726 (list 'nndir-directory
5727 (if all gnus-group-archive-directory
5728 gnus-group-recent-archive-directory))))))
5730 (defun gnus-group-make-directory-group (dir)
5731 "Create an nndir group.
5732 The user will be prompted for a directory. The contents of this
5733 directory will be used as a newsgroup. The directory should contain
5734 mail messages or news articles in files that have numeric names."
5736 (list (read-file-name "Create group from directory: ")))
5737 (or (file-exists-p dir) (error "No such directory"))
5738 (or (file-directory-p dir) (error "Not a directory"))
5742 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5744 (gnus-group-prefixed-name
5745 (concat (file-name-as-directory (directory-file-name dir))
5748 (setq ext (format "<%d>" (setq i (1+ i)))))
5749 (gnus-group-make-group
5750 (gnus-group-real-name group)
5751 (list 'nndir group (list 'nndir-directory dir)))))
5753 (defun gnus-group-make-kiboze-group (group address scores)
5754 "Create an nnkiboze group.
5755 The user will be prompted for a name, a regexp to match groups, and
5756 score file entries for articles to include in the group."
5759 (read-string "nnkiboze group name: ")
5760 (read-string "Source groups (regexp): ")
5761 (let ((headers (mapcar (lambda (group) (list group))
5762 '("subject" "from" "number" "date" "message-id"
5763 "references" "chars" "lines" "xref"
5764 "followup" "all" "body" "head")))
5765 scores header regexp regexps)
5766 (while (not (equal "" (setq header (completing-read
5767 "Match on header: " headers nil t))))
5769 (while (not (equal "" (setq regexp (read-string
5770 (format "Match on %s (string): "
5772 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5773 (setq scores (cons (cons header regexps) scores)))
5775 (gnus-group-make-group group "nnkiboze" address)
5776 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5777 (let (emacs-lisp-mode-hook)
5778 (pp scores (current-buffer)))))
5780 (defun gnus-group-add-to-virtual (n vgroup)
5781 "Add the current group to a virtual group."
5783 (list current-prefix-arg
5784 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5786 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5787 (error "%s is not an nnvirtual group" vgroup))
5788 (let* ((groups (gnus-group-process-prefix n))
5789 (method (gnus-info-method (gnus-get-info vgroup))))
5790 (setcar (cdr method)
5792 (nth 1 method) "\\|"
5795 (gnus-group-remove-mark s)
5796 (concat "\\(^" (regexp-quote s) "$\\)"))
5798 (gnus-group-position-point))
5800 (defun gnus-group-make-empty-virtual (group)
5801 "Create a new, fresh, empty virtual group."
5802 (interactive "sCreate new, empty virtual group: ")
5803 (let* ((method (list 'nnvirtual "^$"))
5804 (pgroup (gnus-group-prefixed-name group method)))
5805 ;; Check whether it exists already.
5806 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5807 (error "Group %s already exists." pgroup))
5808 ;; Subscribe the new group after the group on the current line.
5809 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5810 (gnus-group-update-group pgroup)
5812 (gnus-group-position-point)))
5814 (defun gnus-group-enter-directory (dir)
5815 "Enter an ephemeral nneething group."
5816 (interactive "DDirectory to read: ")
5817 (let* ((method (list 'nneething dir))
5818 (leaf (gnus-group-prefixed-name
5819 (file-name-nondirectory (directory-file-name dir))
5821 (name (gnus-generate-new-group-name leaf)))
5822 (let ((nneething-read-only t))
5823 (or (gnus-group-read-ephemeral-group
5825 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5827 (error "Couldn't enter %s" dir)))))
5829 ;; Group sorting commands
5830 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5832 (defun gnus-group-sort-groups (func &optional reverse)
5833 "Sort the group buffer according to FUNC.
5834 If REVERSE, reverse the sorting order."
5835 (interactive (list gnus-group-sort-function
5836 current-prefix-arg))
5838 ((not (listp func)) func)
5840 ((= 1 (length func)) (car func))
5842 ,(gnus-make-sort-function
5843 (reverse func)))))))
5844 ;; We peel off the dummy group from the alist.
5846 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5847 (pop gnus-newsrc-alist))
5849 (setq gnus-newsrc-alist
5850 (sort gnus-newsrc-alist func))
5852 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5853 ;; Regenerate the hash table.
5854 (gnus-make-hashtable-from-newsrc-alist)
5855 (gnus-group-list-groups))))
5857 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5858 "Sort the group buffer alphabetically by group name.
5859 If REVERSE, sort in reverse order."
5861 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5863 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5864 "Sort the group buffer by number of unread articles.
5865 If REVERSE, sort in reverse order."
5867 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5869 (defun gnus-group-sort-groups-by-level (&optional reverse)
5870 "Sort the group buffer by group level.
5871 If REVERSE, sort in reverse order."
5873 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5875 (defun gnus-group-sort-groups-by-score (&optional reverse)
5876 "Sort the group buffer by group score.
5877 If REVERSE, sort in reverse order."
5879 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5881 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5882 "Sort the group buffer by group rank.
5883 If REVERSE, sort in reverse order."
5885 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5887 (defun gnus-group-sort-groups-by-method (&optional reverse)
5888 "Sort the group buffer alphabetically by backend name.
5889 If REVERSE, sort in reverse order."
5891 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5893 (defun gnus-group-sort-by-alphabet (info1 info2)
5894 "Sort alphabetically."
5895 (string< (gnus-info-group info1) (gnus-info-group info2)))
5897 (defun gnus-group-sort-by-unread (info1 info2)
5898 "Sort by number of unread articles."
5899 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5900 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5901 (< (or (and (numberp n1) n1) 0)
5902 (or (and (numberp n2) n2) 0))))
5904 (defun gnus-group-sort-by-level (info1 info2)
5906 (< (gnus-info-level info1) (gnus-info-level info2)))
5908 (defun gnus-group-sort-by-method (info1 info2)
5909 "Sort alphabetically by backend name."
5910 (string< (symbol-name (car (gnus-find-method-for-group
5911 (gnus-info-group info1) info1)))
5912 (symbol-name (car (gnus-find-method-for-group
5913 (gnus-info-group info2) info2)))))
5915 (defun gnus-group-sort-by-score (info1 info2)
5916 "Sort by group score."
5917 (< (gnus-info-score info1) (gnus-info-score info2)))
5919 (defun gnus-group-sort-by-rank (info1 info2)
5920 "Sort by level and score."
5921 (let ((level1 (gnus-info-level info1))
5922 (level2 (gnus-info-level info2)))
5923 (or (< level1 level2)
5924 (and (= level1 level2)
5925 (< (gnus-info-score info1) (gnus-info-score info2))))))
5927 ;; Group catching up.
5929 (defun gnus-group-clear-data (n)
5930 "Clear all marks and read ranges from the current group."
5932 (let ((groups (gnus-group-process-prefix n))
5934 (while (setq group (pop groups))
5935 (setq info (gnus-get-info group))
5936 (gnus-info-set-read info nil)
5937 (when (gnus-info-marks info)
5938 (gnus-info-set-marks info nil))
5939 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5940 (when (gnus-group-goto-group group)
5941 (gnus-group-remove-mark group)
5942 (gnus-group-update-group-line)))))
5944 (defun gnus-group-catchup-current (&optional n all)
5945 "Mark all articles not marked as unread in current newsgroup as read.
5946 If prefix argument N is numeric, the ARG next newsgroups will be
5947 caught up. If ALL is non-nil, marked articles will also be marked as
5948 read. Cross references (Xref: header) of articles are ignored.
5949 The difference between N and actual number of newsgroups that were
5950 caught up is returned."
5952 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5956 "Do you really want to mark all articles as read? "
5957 "Mark all unread articles as read? "))))
5959 (let ((groups (gnus-group-process-prefix n))
5962 ;; Virtual groups have to be given special treatment.
5963 (let ((method (gnus-find-method-for-group (car groups))))
5964 (if (eq 'nnvirtual (car method))
5965 (nnvirtual-catchup-group
5966 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5967 (gnus-group-remove-mark (car groups))
5968 (if (>= (gnus-group-group-level) gnus-level-zombie)
5969 (gnus-message 2 "Dead groups can't be caught up")
5971 (gnus-group-goto-group (car groups))
5972 (gnus-group-catchup (car groups) all))
5973 (gnus-group-update-group-line)
5974 (setq ret (1+ ret))))
5975 (setq groups (cdr groups)))
5976 (gnus-group-next-unread-group 1)
5979 (defun gnus-group-catchup-current-all (&optional n)
5980 "Mark all articles in current newsgroup as read.
5981 Cross references (Xref: header) of articles are ignored."
5983 (gnus-group-catchup-current n 'all))
5985 (defun gnus-group-catchup (group &optional all)
5986 "Mark all articles in GROUP as read.
5987 If ALL is non-nil, all articles are marked as read.
5988 The return value is the number of articles that were marked as read,
5989 or nil if no action could be taken."
5990 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5992 ;; Do the updating only if the newsgroup isn't killed.
5993 (if (not (numberp (car entry)))
5994 (gnus-message 1 "Can't catch up; non-active group")
5995 ;; Do auto-expirable marks if that's required.
5996 (when (gnus-group-auto-expirable-p group)
5997 (gnus-add-marked-articles
5998 group 'expire (gnus-list-of-unread-articles group))
6000 (let ((marks (nth 3 (nth 2 entry))))
6001 (gnus-add-marked-articles
6002 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6003 (gnus-add-marked-articles
6004 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6006 (gnus-update-read-articles group nil)
6007 ;; Also nix out the lists of marks and dormants.
6009 (gnus-add-marked-articles group 'tick nil nil 'force)
6010 (gnus-add-marked-articles group 'dormant nil nil 'force))
6011 (run-hooks 'gnus-group-catchup-group-hook)
6014 (defun gnus-group-expire-articles (&optional n)
6015 "Expire all expirable articles in the current newsgroup."
6017 (let ((groups (gnus-group-process-prefix n))
6020 (error "No groups to expire"))
6021 (while (setq group (pop groups))
6022 (gnus-group-remove-mark group)
6023 (when (gnus-check-backend-function 'request-expire-articles group)
6024 (gnus-message 6 "Expiring articles in %s..." group)
6025 (let* ((info (gnus-get-info group))
6026 (expirable (if (gnus-group-total-expirable-p group)
6027 (cons nil (gnus-list-of-read-articles group))
6028 (assq 'expire (gnus-info-marks info))))
6029 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6033 (gnus-compress-sequence
6035 ;; We set the expiry variables to the groupp
6037 (let ((nnmail-expiry-wait-function nil)
6038 (nnmail-expiry-wait expiry-wait))
6039 (gnus-request-expire-articles
6040 (gnus-uncompress-sequence (cdr expirable)) group))
6041 ;; Just expire using the normal expiry values.
6042 (gnus-request-expire-articles
6043 (gnus-uncompress-sequence (cdr expirable)) group)))))
6044 (gnus-message 6 "Expiring articles in %s...done" group)))
6045 (gnus-group-position-point))))
6047 (defun gnus-group-expire-all-groups ()
6048 "Expire all expirable articles in all newsgroups."
6051 (gnus-message 5 "Expiring...")
6052 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6053 (cdr gnus-newsrc-alist))))
6054 (gnus-group-expire-articles nil)))
6055 (gnus-group-position-point)
6056 (gnus-message 5 "Expiring...done"))
6058 (defun gnus-group-set-current-level (n level)
6059 "Set the level of the next N groups to LEVEL."
6064 (let ((s (read-string
6065 (format "Level (default %s): "
6066 (or (gnus-group-group-level)
6067 gnus-level-default-subscribed)))))
6068 (if (string-match "^\\s-*$" s)
6069 (int-to-string (or (gnus-group-group-level)
6070 gnus-level-default-subscribed))
6072 (or (and (>= level 1) (<= level gnus-level-killed))
6073 (error "Illegal level: %d" level))
6074 (let ((groups (gnus-group-process-prefix n))
6076 (while (setq group (pop groups))
6077 (gnus-group-remove-mark group)
6078 (gnus-message 6 "Changed level of %s from %d to %d"
6079 group (or (gnus-group-group-level) gnus-level-killed)
6081 (gnus-group-change-level
6082 group level (or (gnus-group-group-level) gnus-level-killed))
6083 (gnus-group-update-group-line)))
6084 (gnus-group-position-point))
6086 (defun gnus-group-unsubscribe-current-group (&optional n)
6087 "Toggle subscription of the current group.
6088 If given numerical prefix, toggle the N next groups."
6090 (let ((groups (gnus-group-process-prefix n))
6093 (setq group (car groups)
6094 groups (cdr groups))
6095 (gnus-group-remove-mark group)
6096 (gnus-group-unsubscribe-group
6097 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6098 gnus-level-default-unsubscribed
6099 gnus-level-default-subscribed) t)
6100 (gnus-group-update-group-line))
6101 (gnus-group-next-group 1)))
6103 (defun gnus-group-unsubscribe-group (group &optional level silent)
6104 "Toggle subscription to GROUP.
6105 Killed newsgroups are subscribed. If SILENT, don't try to update the
6108 (list (completing-read
6109 "Group: " gnus-active-hashtb nil
6110 (memq gnus-select-method gnus-have-read-active-file)
6112 'gnus-group-history)))
6113 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6115 ((string-match "^[ \t]$" group)
6116 (error "Empty group name"))
6118 ;; Toggle subscription flag.
6119 (gnus-group-change-level
6120 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6121 gnus-level-subscribed)
6122 (1+ gnus-level-subscribed)
6123 gnus-level-default-subscribed)))
6125 (gnus-group-update-group group)))
6126 ((and (stringp group)
6127 (or (not (memq gnus-select-method gnus-have-read-active-file))
6128 (gnus-active group)))
6129 ;; Add new newsgroup.
6130 (gnus-group-change-level
6132 (if level level gnus-level-default-subscribed)
6133 (or (and (member group gnus-zombie-list)
6136 (and (gnus-group-group-name)
6137 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6139 (gnus-group-update-group group)))
6140 (t (error "No such newsgroup: %s" group)))
6141 (gnus-group-position-point)))
6143 (defun gnus-group-transpose-groups (n)
6144 "Move the current newsgroup up N places.
6145 If given a negative prefix, move down instead. The difference between
6146 N and the number of steps taken is returned."
6148 (or (gnus-group-group-name)
6149 (error "No group on current line"))
6150 (gnus-group-kill-group 1)
6152 (forward-line (- n))
6153 (gnus-group-yank-group)
6154 (gnus-group-position-point)))
6156 (defun gnus-group-kill-all-zombies ()
6157 "Kill all zombie newsgroups."
6159 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6160 (setq gnus-zombie-list nil)
6161 (gnus-group-list-groups))
6163 (defun gnus-group-kill-region (begin end)
6164 "Kill newsgroups in current region (excluding current point).
6165 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6180 (beginning-of-line) ;Important when LINES < 1
6181 (gnus-group-kill-group lines)))
6183 (defun gnus-group-kill-group (&optional n discard)
6184 "Kill the next N groups.
6185 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6186 However, only groups that were alive can be yanked; already killed
6187 groups or zombie groups can't be yanked.
6188 The return value is the name of the group that was killed, or a list
6191 (let ((buffer-read-only nil)
6192 (groups (gnus-group-process-prefix n))
6193 group entry level out)
6194 (if (< (length groups) 10)
6195 ;; This is faster when there are few groups.
6197 (push (setq group (pop groups)) out)
6198 (gnus-group-remove-mark group)
6199 (setq level (gnus-group-group-level))
6201 (when (and (not discard)
6202 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6203 (push (cons (car entry) (nth 2 entry))
6204 gnus-list-of-killed-groups))
6205 (gnus-group-change-level
6206 (if entry entry group) gnus-level-killed (if entry nil level)))
6207 ;; If there are lots and lots of groups to be killed, we use
6208 ;; this thing instead.
6210 (setq groups (nreverse groups))
6212 (gnus-group-remove-mark (setq group (pop groups)))
6215 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6216 (push (cons (car entry) (nth 2 entry))
6217 gnus-list-of-killed-groups)
6218 (setcdr (cdr entry) (cdddr entry)))
6219 ((member group gnus-zombie-list)
6220 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6221 (gnus-make-hashtable-from-newsrc-alist)))
6223 (gnus-group-position-point)
6224 (if (< (length out) 2) (car out) (nreverse out))))
6226 (defun gnus-group-yank-group (&optional arg)
6227 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6228 inserting it before the current newsgroup. The numeric ARG specifies
6229 how many newsgroups are to be yanked. The name of the newsgroup yanked
6230 is returned, or (if several groups are yanked) a list of yanked groups
6233 (setq arg (or arg 1))
6234 (let (info group prev out)
6235 (while (>= (decf arg) 0)
6236 (if (not (setq info (pop gnus-list-of-killed-groups)))
6237 (error "No more newsgroups to yank"))
6238 (push (setq group (nth 1 info)) out)
6239 ;; Find which newsgroup to insert this one before - search
6240 ;; backward until something suitable is found. If there are no
6241 ;; other newsgroups in this buffer, just make this newsgroup the
6243 (setq prev (gnus-group-group-name))
6244 (gnus-group-change-level
6245 info (gnus-info-level (cdr info)) gnus-level-killed
6246 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6248 (gnus-group-insert-group-line-info group))
6250 (gnus-group-position-point)
6251 (if (< (length out) 2) (car out) (nreverse out))))
6253 (defun gnus-group-kill-level (level)
6254 "Kill all groups that is on a certain LEVEL."
6255 (interactive "nKill all groups on level: ")
6257 ((= level gnus-level-zombie)
6258 (setq gnus-killed-list
6259 (nconc gnus-zombie-list gnus-killed-list))
6260 (setq gnus-zombie-list nil))
6261 ((and (< level gnus-level-zombie)
6263 (or gnus-expert-user
6266 "Do you really want to kill all groups on level %d? "
6268 (let* ((prev gnus-newsrc-alist)
6271 (if (= (gnus-info-level level) level)
6272 (setcdr prev (cdr alist))
6274 (setq alist (cdr alist)))
6275 (gnus-make-hashtable-from-newsrc-alist)
6276 (gnus-group-list-groups)))
6278 (error "Can't kill; illegal level: %d" level))))
6280 (defun gnus-group-list-all-groups (&optional arg)
6281 "List all newsgroups with level ARG or lower.
6282 Default is gnus-level-unsubscribed, which lists all subscribed and most
6283 unsubscribed groups."
6285 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6287 ;; Redefine this to list ALL killed groups if prefix arg used.
6288 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6289 (defun gnus-group-list-killed (&optional arg)
6290 "List all killed newsgroups in the group buffer.
6291 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6292 entail asking the server for the groups."
6294 ;; Find all possible killed newsgroups if arg.
6296 ;; First make sure active file has been read.
6297 (unless gnus-have-read-active-file
6298 (let ((gnus-read-active-file t))
6299 (gnus-read-active-file)))
6300 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6301 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6305 (group (symbol-name sym)))
6306 (if (or (null group)
6307 (gnus-gethash group gnus-killed-hashtb)
6308 (gnus-gethash group gnus-newsrc-hashtb))
6310 (let ((do-sub (gnus-matches-options-n group)))
6311 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6313 (setq groups (1+ groups))
6314 (setq gnus-killed-list
6315 (cons group gnus-killed-list))
6316 (gnus-sethash group group gnus-killed-hashtb))))))
6317 gnus-active-hashtb))
6318 (if (not gnus-killed-list)
6319 (gnus-message 6 "No killed groups")
6320 (let (gnus-group-list-mode)
6321 (funcall gnus-group-prepare-function
6322 gnus-level-killed t gnus-level-killed))
6323 (goto-char (point-min)))
6324 (gnus-group-position-point))
6326 (defun gnus-group-list-zombies ()
6327 "List all zombie newsgroups in the group buffer."
6329 (if (not gnus-zombie-list)
6330 (gnus-message 6 "No zombie groups")
6331 (let (gnus-group-list-mode)
6332 (funcall gnus-group-prepare-function
6333 gnus-level-zombie t gnus-level-zombie))
6334 (goto-char (point-min)))
6335 (gnus-group-position-point))
6337 (defun gnus-group-list-active ()
6338 "List all groups that are available from the server(s)."
6340 ;; First we make sure that we have really read the active file.
6341 (unless gnus-have-read-active-file
6342 (let ((gnus-read-active-file t))
6343 (gnus-read-active-file)))
6344 ;; Find all groups and sort them.
6350 (and (symbol-value sym)
6351 (setq list (cons (symbol-name sym) list))))
6355 (buffer-read-only nil))
6358 (gnus-group-insert-group-line-info (pop groups)))
6359 (goto-char (point-min))))
6361 (defun gnus-activate-all-groups (level)
6362 "Activate absolutely all groups."
6363 (interactive (list 7))
6364 (let ((gnus-activate-level level)
6365 (gnus-activate-foreign-newsgroups level))
6366 (gnus-group-get-new-news)))
6368 (defun gnus-group-get-new-news (&optional arg)
6369 "Get newly arrived articles.
6370 If ARG is a number, it specifies which levels you are interested in
6371 re-scanning. If ARG is non-nil and not a number, this will force
6372 \"hard\" re-reading of the active files from all servers."
6374 (run-hooks 'gnus-get-new-news-hook)
6375 ;; We might read in new NoCeM messages here.
6376 (when (and gnus-use-nocem
6378 (gnus-nocem-scan-groups))
6379 ;; If ARG is not a number, then we read the active file.
6380 (when (and arg (not (numberp arg)))
6381 (let ((gnus-read-active-file t))
6382 (gnus-read-active-file))
6385 (setq arg (gnus-group-default-level arg t))
6386 (if (and gnus-read-active-file (not arg))
6388 (gnus-read-active-file)
6389 (gnus-get-unread-articles arg))
6390 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6391 (gnus-get-unread-articles arg)))
6392 (run-hooks 'gnus-after-getting-new-news-hook)
6393 (gnus-group-list-groups))
6395 (defun gnus-group-get-new-news-this-group (&optional n)
6396 "Check for newly arrived news in the current group (and the N-1 next groups).
6397 The difference between N and the number of newsgroup checked is returned.
6398 If N is negative, this group and the N-1 previous groups will be checked."
6400 (let* ((groups (gnus-group-process-prefix n))
6401 (ret (if (numberp n) (- n (length groups)) 0))
6402 (beg (unless n (point)))
6404 (while (setq group (pop groups))
6405 (gnus-group-remove-mark group)
6406 (if (gnus-activate-group group 'scan)
6408 (gnus-get-unread-articles-in-group
6409 (gnus-get-info group) (gnus-active group) t)
6410 (unless (gnus-virtual-group-p group)
6411 (gnus-close-group group))
6412 (gnus-group-update-group group))
6413 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6414 (when beg (goto-char beg))
6415 (when gnus-goto-next-group-when-activating
6416 (gnus-group-next-unread-group 1 t))
6417 (gnus-summary-position-point)
6420 (defun gnus-group-fetch-faq (group &optional faq-dir)
6421 "Fetch the FAQ for the current group."
6424 (gnus-group-real-name (gnus-group-group-name))
6425 (cond (current-prefix-arg
6427 "Faq dir: " (and (listp gnus-group-faq-directory)
6428 gnus-group-faq-directory))))))
6430 (setq faq-dir (if (listp gnus-group-faq-directory)
6431 (car gnus-group-faq-directory)
6432 gnus-group-faq-directory)))
6433 (or group (error "No group name given"))
6434 (let ((file (concat (file-name-as-directory faq-dir)
6435 (gnus-group-real-name group))))
6436 (if (not (file-exists-p file))
6437 (error "No such file: %s" file)
6440 (defun gnus-group-describe-group (force &optional group)
6441 "Display a description of the current newsgroup."
6442 (interactive (list current-prefix-arg (gnus-group-group-name)))
6443 (and force (setq gnus-description-hashtb nil))
6444 (let ((method (gnus-find-method-for-group group))
6446 (or group (error "No group name given"))
6447 (and (or (and gnus-description-hashtb
6448 ;; We check whether this group's method has been
6449 ;; queried for a description file.
6451 (gnus-group-prefixed-name "" method)
6452 gnus-description-hashtb))
6453 (setq desc (gnus-group-get-description group))
6454 (gnus-read-descriptions-file method))
6456 (or desc (gnus-gethash group gnus-description-hashtb)
6457 "No description available")))))
6459 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6460 (defun gnus-group-describe-all-groups (&optional force)
6461 "Pop up a buffer with descriptions of all newsgroups."
6463 (and force (setq gnus-description-hashtb nil))
6464 (if (not (or gnus-description-hashtb
6465 (gnus-read-all-descriptions-files)))
6466 (error "Couldn't request descriptions file"))
6467 (let ((buffer-read-only nil)
6473 (insert (format " *: %-20s %s\n" (symbol-name group)
6474 (symbol-value group)))
6475 (add-text-properties
6476 b (1+ b) (list 'gnus-group group
6477 'gnus-unread t 'gnus-marked nil
6478 'gnus-level (1+ gnus-level-subscribed))))
6479 gnus-description-hashtb)
6480 (goto-char (point-min))
6481 (gnus-group-position-point)))
6483 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6484 (defun gnus-group-apropos (regexp &optional search-description)
6485 "List all newsgroups that have names that match a regexp."
6486 (interactive "sGnus apropos (regexp): ")
6488 (obuf (current-buffer))
6490 ;; Go through all newsgroups that are known to Gnus.
6493 (and (symbol-name group)
6494 (string-match regexp (symbol-name group))
6495 (setq groups (cons (symbol-name group) groups))))
6497 ;; Also go through all descriptions that are known to Gnus.
6498 (when search-description
6501 (and (string-match regexp (symbol-value group))
6502 (gnus-active (symbol-name group))
6503 (setq groups (cons (symbol-name group) groups))))
6504 gnus-description-hashtb))
6506 (gnus-message 3 "No groups matched \"%s\"." regexp)
6507 ;; Print out all the groups.
6509 (pop-to-buffer "*Gnus Help*")
6510 (buffer-disable-undo (current-buffer))
6512 (setq groups (sort groups 'string<))
6514 ;; Groups may be entered twice into the list of groups.
6515 (if (not (string= (car groups) prev))
6517 (insert (setq prev (car groups)) "\n")
6518 (if (and gnus-description-hashtb
6519 (setq des (gnus-gethash (car groups)
6520 gnus-description-hashtb)))
6521 (insert " " des "\n"))))
6522 (setq groups (cdr groups)))
6523 (goto-char (point-min))))
6524 (pop-to-buffer obuf)))
6526 (defun gnus-group-description-apropos (regexp)
6527 "List all newsgroups that have names or descriptions that match a regexp."
6528 (interactive "sGnus description apropos (regexp): ")
6529 (if (not (or gnus-description-hashtb
6530 (gnus-read-all-descriptions-files)))
6531 (error "Couldn't request descriptions file"))
6532 (gnus-group-apropos regexp t))
6534 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6535 (defun gnus-group-list-matching (level regexp &optional all lowest)
6536 "List all groups with unread articles that match REGEXP.
6537 If the prefix LEVEL is non-nil, it should be a number that says which
6538 level to cut off listing groups.
6539 If ALL, also list groups with no unread articles.
6540 If LOWEST, don't list groups with level lower than LOWEST."
6541 (interactive "P\nsList newsgroups matching: ")
6542 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6543 all (or lowest 1) regexp)
6544 (goto-char (point-min))
6545 (gnus-group-position-point))
6547 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6548 "List all groups that match REGEXP.
6549 If the prefix LEVEL is non-nil, it should be a number that says which
6550 level to cut off listing groups.
6551 If LOWEST, don't list groups with level lower than LOWEST."
6552 (interactive "P\nsList newsgroups matching: ")
6553 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6555 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6556 (defun gnus-group-save-newsrc (&optional force)
6557 "Save the Gnus startup files.
6558 If FORCE, force saving whether it is necessary or not."
6560 (gnus-save-newsrc-file force))
6562 (defun gnus-group-restart (&optional arg)
6563 "Force Gnus to read the .newsrc file."
6565 (when (gnus-yes-or-no-p
6566 (format "Are you sure you want to read %s? "
6567 gnus-current-startup-file))
6568 (gnus-save-newsrc-file)
6569 (gnus-setup-news 'force)
6570 (gnus-group-list-groups arg)))
6572 (defun gnus-group-read-init-file ()
6573 "Read the Gnus elisp init file."
6575 (gnus-read-init-file))
6577 (defun gnus-group-check-bogus-groups (&optional silent)
6578 "Check bogus newsgroups.
6579 If given a prefix, don't ask for confirmation before removing a bogus
6582 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6583 (gnus-group-list-groups))
6585 (defun gnus-group-edit-global-kill (&optional article group)
6586 "Edit the global kill file.
6587 If GROUP, edit that local kill file instead."
6589 (setq gnus-current-kill-article article)
6590 (gnus-kill-file-edit-file group)
6593 (substitute-command-keys
6594 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6595 (if group "local" "global")))))
6597 (defun gnus-group-edit-local-kill (article group)
6598 "Edit a local kill file."
6599 (interactive (list nil (gnus-group-group-name)))
6600 (gnus-group-edit-global-kill article group))
6602 (defun gnus-group-force-update ()
6603 "Update `.newsrc' file."
6605 (gnus-save-newsrc-file))
6607 (defun gnus-group-suspend ()
6608 "Suspend the current Gnus session.
6609 In fact, cleanup buffers except for group mode buffer.
6610 The hook gnus-suspend-gnus-hook is called before actually suspending."
6612 (run-hooks 'gnus-suspend-gnus-hook)
6613 ;; Kill Gnus buffers except for group mode buffer.
6614 (let ((group-buf (get-buffer gnus-group-buffer)))
6615 ;; Do this on a separate list in case the user does a ^G before we finish
6616 (let ((gnus-buffer-list
6617 (delq group-buf (delq gnus-dribble-buffer
6618 (append gnus-buffer-list nil)))))
6619 (while gnus-buffer-list
6620 (gnus-kill-buffer (car gnus-buffer-list))
6621 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6624 (setq gnus-buffer-list (list group-buf))
6625 (bury-buffer group-buf)
6626 (delete-windows-on group-buf t)))))
6628 (defun gnus-group-clear-dribble ()
6629 "Clear all information from the dribble buffer."
6631 (gnus-dribble-clear)
6632 (gnus-message 7 "Cleared dribble buffer"))
6634 (defun gnus-group-exit ()
6635 "Quit reading news after updating .newsrc.eld and .newsrc.
6636 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6639 (or noninteractive ;For gnus-batch-kill
6640 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6641 (not gnus-interactive-exit) ;Without confirmation
6643 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6644 (run-hooks 'gnus-exit-gnus-hook)
6645 ;; Offer to save data from non-quitted summary buffers.
6646 (gnus-offer-save-summaries)
6647 ;; Save the newsrc file(s).
6648 (gnus-save-newsrc-file)
6650 (gnus-close-backends)
6651 ;; Reset everything.
6653 ;; Allow the user to do things after cleaning up.
6654 (run-hooks 'gnus-after-exiting-gnus-hook)))
6656 (defun gnus-close-backends ()
6657 ;; Send a close request to all backends that support such a request.
6658 (let ((methods gnus-valid-select-methods)
6661 (if (fboundp (setq func (intern (concat (caar methods)
6662 "-request-close"))))
6664 (setq methods (cdr methods)))))
6666 (defun gnus-group-quit ()
6667 "Quit reading news without updating .newsrc.eld or .newsrc.
6668 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6670 (when (or noninteractive ;For gnus-batch-kill
6671 (zerop (buffer-size))
6672 (not (gnus-server-opened gnus-select-method))
6674 (not gnus-current-startup-file)
6676 (format "Quit reading news without saving %s? "
6677 (file-name-nondirectory gnus-current-startup-file))))
6678 (run-hooks 'gnus-exit-gnus-hook)
6679 (if gnus-use-full-window
6680 (delete-other-windows)
6681 (gnus-remove-some-windows))
6683 (gnus-close-backends)
6685 ;; Allow the user to do things after cleaning up.
6686 (run-hooks 'gnus-after-exiting-gnus-hook)))
6688 (defun gnus-offer-save-summaries ()
6689 "Offer to save all active summary buffers."
6691 (let ((buflist (buffer-list))
6693 ;; Go through all buffers and find all summaries.
6695 (and (setq bufname (buffer-name (car buflist)))
6696 (string-match "Summary" bufname)
6698 (set-buffer bufname)
6699 ;; We check that this is, indeed, a summary buffer.
6700 (and (eq major-mode 'gnus-summary-mode)
6701 ;; Also make sure this isn't bogus.
6702 gnus-newsgroup-prepared))
6703 (push bufname buffers))
6704 (setq buflist (cdr buflist)))
6705 ;; Go through all these summary buffers and offer to save them.
6708 "Update summary buffer %s? "
6709 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6712 (defun gnus-group-describe-briefly ()
6713 "Give a one line description of the group mode commands."
6715 (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")))
6717 (defun gnus-group-browse-foreign-server (method)
6718 "Browse a foreign news server.
6719 If called interactively, this function will ask for a select method
6720 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6721 If not, METHOD should be a list where the first element is the method
6722 and the second element is the address."
6724 (list (let ((how (completing-read
6726 (append gnus-valid-select-methods gnus-server-alist)
6727 nil t (cons "nntp" 0) 'gnus-method-history)))
6728 ;; We either got a backend name or a virtual server name.
6729 ;; If the first, we also need an address.
6730 (if (assoc how gnus-valid-select-methods)
6732 ;; Suggested by mapjph@bath.ac.uk.
6735 (mapcar (lambda (server) (list server))
6736 gnus-secondary-servers)))
6737 ;; We got a server name, so we find the method.
6738 (gnus-server-to-method how)))))
6739 (gnus-browse-foreign-server method))
6743 ;;; Gnus summary mode
6746 (defvar gnus-summary-mode-map nil)
6748 (put 'gnus-summary-mode 'mode-class 'special)
6750 (unless gnus-summary-mode-map
6751 (setq gnus-summary-mode-map (make-keymap))
6752 (suppress-keymap gnus-summary-mode-map)
6754 ;; Non-orthogonal keys
6756 (gnus-define-keys gnus-summary-mode-map
6757 " " gnus-summary-next-page
6758 "\177" gnus-summary-prev-page
6759 [delete] gnus-summary-prev-page
6760 "\r" gnus-summary-scroll-up
6761 "n" gnus-summary-next-unread-article
6762 "p" gnus-summary-prev-unread-article
6763 "N" gnus-summary-next-article
6764 "P" gnus-summary-prev-article
6765 "\M-\C-n" gnus-summary-next-same-subject
6766 "\M-\C-p" gnus-summary-prev-same-subject
6767 "\M-n" gnus-summary-next-unread-subject
6768 "\M-p" gnus-summary-prev-unread-subject
6769 "." gnus-summary-first-unread-article
6770 "," gnus-summary-best-unread-article
6771 "\M-s" gnus-summary-search-article-forward
6772 "\M-r" gnus-summary-search-article-backward
6773 "<" gnus-summary-beginning-of-article
6774 ">" gnus-summary-end-of-article
6775 "j" gnus-summary-goto-article
6776 "^" gnus-summary-refer-parent-article
6777 "\M-^" gnus-summary-refer-article
6778 "u" gnus-summary-tick-article-forward
6779 "!" gnus-summary-tick-article-forward
6780 "U" gnus-summary-tick-article-backward
6781 "d" gnus-summary-mark-as-read-forward
6782 "D" gnus-summary-mark-as-read-backward
6783 "E" gnus-summary-mark-as-expirable
6784 "\M-u" gnus-summary-clear-mark-forward
6785 "\M-U" gnus-summary-clear-mark-backward
6786 "k" gnus-summary-kill-same-subject-and-select
6787 "\C-k" gnus-summary-kill-same-subject
6788 "\M-\C-k" gnus-summary-kill-thread
6789 "\M-\C-l" gnus-summary-lower-thread
6790 "e" gnus-summary-edit-article
6791 "#" gnus-summary-mark-as-processable
6792 "\M-#" gnus-summary-unmark-as-processable
6793 "\M-\C-t" gnus-summary-toggle-threads
6794 "\M-\C-s" gnus-summary-show-thread
6795 "\M-\C-h" gnus-summary-hide-thread
6796 "\M-\C-f" gnus-summary-next-thread
6797 "\M-\C-b" gnus-summary-prev-thread
6798 "\M-\C-u" gnus-summary-up-thread
6799 "\M-\C-d" gnus-summary-down-thread
6800 "&" gnus-summary-execute-command
6801 "c" gnus-summary-catchup-and-exit
6802 "\C-w" gnus-summary-mark-region-as-read
6803 "\C-t" gnus-summary-toggle-truncation
6804 "?" gnus-summary-mark-as-dormant
6805 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6806 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6807 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6808 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6809 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6810 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6811 "=" gnus-summary-expand-window
6812 "\C-x\C-s" gnus-summary-reselect-current-group
6813 "\M-g" gnus-summary-rescan-group
6814 "w" gnus-summary-stop-page-breaking
6815 "\C-c\C-r" gnus-summary-caesar-message
6816 "\M-t" gnus-summary-toggle-mime
6817 "f" gnus-summary-followup
6818 "F" gnus-summary-followup-with-original
6819 "C" gnus-summary-cancel-article
6820 "r" gnus-summary-reply
6821 "R" gnus-summary-reply-with-original
6822 "\C-c\C-f" gnus-summary-mail-forward
6823 "o" gnus-summary-save-article
6824 "\C-o" gnus-summary-save-article-mail
6825 "|" gnus-summary-pipe-output
6826 "\M-k" gnus-summary-edit-local-kill
6827 "\M-K" gnus-summary-edit-global-kill
6829 "\C-c\C-d" gnus-summary-describe-group
6830 "q" gnus-summary-exit
6831 "Q" gnus-summary-exit-no-update
6832 "\C-c\C-i" gnus-info-find-node
6833 gnus-mouse-2 gnus-mouse-pick-article
6834 "m" gnus-summary-mail-other-window
6835 "a" gnus-summary-post-news
6836 "x" gnus-summary-limit-to-unread
6837 "s" gnus-summary-isearch-article
6838 "t" gnus-article-hide-headers
6839 "g" gnus-summary-show-article
6840 "l" gnus-summary-goto-last-article
6841 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6842 "\C-d" gnus-summary-enter-digest-group
6844 "*" gnus-cache-enter-article
6845 "\M-*" gnus-cache-remove-article
6846 "\M-&" gnus-summary-universal-argument
6847 "\C-l" gnus-recenter
6848 "I" gnus-summary-increase-score
6849 "L" gnus-summary-lower-score
6851 "V" gnus-summary-score-map
6852 "X" gnus-uu-extract-map
6853 "S" gnus-summary-send-map)
6855 ;; Sort of orthogonal keymap
6856 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6857 "t" gnus-summary-tick-article-forward
6858 "!" gnus-summary-tick-article-forward
6859 "d" gnus-summary-mark-as-read-forward
6860 "r" gnus-summary-mark-as-read-forward
6861 "c" gnus-summary-clear-mark-forward
6862 " " gnus-summary-clear-mark-forward
6863 "e" gnus-summary-mark-as-expirable
6864 "x" gnus-summary-mark-as-expirable
6865 "?" gnus-summary-mark-as-dormant
6866 "b" gnus-summary-set-bookmark
6867 "B" gnus-summary-remove-bookmark
6868 "#" gnus-summary-mark-as-processable
6869 "\M-#" gnus-summary-unmark-as-processable
6870 "S" gnus-summary-limit-include-expunged
6871 "C" gnus-summary-catchup
6872 "H" gnus-summary-catchup-to-here
6873 "\C-c" gnus-summary-catchup-all
6874 "k" gnus-summary-kill-same-subject-and-select
6875 "K" gnus-summary-kill-same-subject
6876 "P" gnus-uu-mark-map)
6878 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6879 "c" gnus-summary-clear-above
6880 "u" gnus-summary-tick-above
6881 "m" gnus-summary-mark-above
6882 "k" gnus-summary-kill-below)
6884 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6885 "/" gnus-summary-limit-to-subject
6886 "n" gnus-summary-limit-to-articles
6887 "w" gnus-summary-pop-limit
6888 "s" gnus-summary-limit-to-subject
6889 "a" gnus-summary-limit-to-author
6890 "u" gnus-summary-limit-to-unread
6891 "m" gnus-summary-limit-to-marks
6892 "v" gnus-summary-limit-to-score
6893 "D" gnus-summary-limit-include-dormant
6894 "d" gnus-summary-limit-exclude-dormant
6895 ;; "t" gnus-summary-limit-exclude-thread
6896 "E" gnus-summary-limit-include-expunged
6897 "c" gnus-summary-limit-exclude-childless-dormant
6898 "C" gnus-summary-limit-mark-excluded-as-read)
6900 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6901 "n" gnus-summary-next-unread-article
6902 "p" gnus-summary-prev-unread-article
6903 "N" gnus-summary-next-article
6904 "P" gnus-summary-prev-article
6905 "\C-n" gnus-summary-next-same-subject
6906 "\C-p" gnus-summary-prev-same-subject
6907 "\M-n" gnus-summary-next-unread-subject
6908 "\M-p" gnus-summary-prev-unread-subject
6909 "f" gnus-summary-first-unread-article
6910 "b" gnus-summary-best-unread-article
6911 "j" gnus-summary-goto-article
6912 "g" gnus-summary-goto-subject
6913 "l" gnus-summary-goto-last-article
6914 "p" gnus-summary-pop-article)
6916 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6917 "k" gnus-summary-kill-thread
6918 "l" gnus-summary-lower-thread
6919 "i" gnus-summary-raise-thread
6920 "T" gnus-summary-toggle-threads
6921 "t" gnus-summary-rethread-current
6922 "^" gnus-summary-reparent-thread
6923 "s" gnus-summary-show-thread
6924 "S" gnus-summary-show-all-threads
6925 "h" gnus-summary-hide-thread
6926 "H" gnus-summary-hide-all-threads
6927 "n" gnus-summary-next-thread
6928 "p" gnus-summary-prev-thread
6929 "u" gnus-summary-up-thread
6930 "o" gnus-summary-top-thread
6931 "d" gnus-summary-down-thread
6932 "#" gnus-uu-mark-thread
6933 "\M-#" gnus-uu-unmark-thread)
6935 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6936 "c" gnus-summary-catchup-and-exit
6937 "C" gnus-summary-catchup-all-and-exit
6938 "E" gnus-summary-exit-no-update
6939 "Q" gnus-summary-exit
6940 "Z" gnus-summary-exit
6941 "n" gnus-summary-catchup-and-goto-next-group
6942 "R" gnus-summary-reselect-current-group
6943 "G" gnus-summary-rescan-group
6944 "N" gnus-summary-next-group
6945 "P" gnus-summary-prev-group)
6947 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6948 " " gnus-summary-next-page
6949 "n" gnus-summary-next-page
6950 "\177" gnus-summary-prev-page
6951 [delete] gnus-summary-prev-page
6952 "p" gnus-summary-prev-page
6953 "\r" gnus-summary-scroll-up
6954 "<" gnus-summary-beginning-of-article
6955 ">" gnus-summary-end-of-article
6956 "b" gnus-summary-beginning-of-article
6957 "e" gnus-summary-end-of-article
6958 "^" gnus-summary-refer-parent-article
6959 "r" gnus-summary-refer-parent-article
6960 "R" gnus-summary-refer-references
6961 "g" gnus-summary-show-article
6962 "s" gnus-summary-isearch-article)
6964 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6965 "b" gnus-article-add-buttons
6966 "B" gnus-article-add-buttons-to-head
6967 "o" gnus-article-treat-overstrike
6968 ;; "w" gnus-article-word-wrap
6969 "w" gnus-article-fill-cited-article
6970 "c" gnus-article-remove-cr
6971 "L" gnus-article-remove-trailing-blank-lines
6972 "q" gnus-article-de-quoted-unreadable
6973 "f" gnus-article-display-x-face
6974 "l" gnus-summary-stop-page-breaking
6975 "r" gnus-summary-caesar-message
6976 "t" gnus-article-hide-headers
6977 "v" gnus-summary-verbose-headers
6978 "m" gnus-summary-toggle-mime)
6980 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6981 "a" gnus-article-hide
6982 "h" gnus-article-hide-headers
6983 "b" gnus-article-hide-boring-headers
6984 "s" gnus-article-hide-signature
6985 "c" gnus-article-hide-citation
6986 "p" gnus-article-hide-pgp
6987 "\C-c" gnus-article-hide-citation-maybe)
6989 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6990 "a" gnus-article-highlight
6991 "h" gnus-article-highlight-headers
6992 "c" gnus-article-highlight-citation
6993 "s" gnus-article-highlight-signature)
6995 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6996 "z" gnus-article-date-ut
6997 "u" gnus-article-date-ut
6998 "l" gnus-article-date-local
6999 "e" gnus-article-date-lapsed
7000 "o" gnus-article-date-original)
7002 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7004 "f" gnus-summary-fetch-faq
7005 "d" gnus-summary-describe-group
7006 "h" gnus-summary-describe-briefly
7007 "i" gnus-info-find-node)
7009 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7010 "e" gnus-summary-expire-articles
7011 "\M-\C-e" gnus-summary-expire-articles-now
7012 "\177" gnus-summary-delete-article
7013 [delete] gnus-summary-delete-article
7014 "m" gnus-summary-move-article
7015 "r" gnus-summary-respool-article
7016 "w" gnus-summary-edit-article
7017 "c" gnus-summary-copy-article
7018 "B" gnus-summary-crosspost-article
7019 "q" gnus-summary-respool-query
7020 "i" gnus-summary-import-article)
7022 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7023 "o" gnus-summary-save-article
7024 "m" gnus-summary-save-article-mail
7025 "r" gnus-summary-save-article-rmail
7026 "f" gnus-summary-save-article-file
7027 "b" gnus-summary-save-article-body-file
7028 "h" gnus-summary-save-article-folder
7029 "v" gnus-summary-save-article-vm
7030 "p" gnus-summary-pipe-output
7031 "s" gnus-soup-add-article)
7036 (defun gnus-summary-mode (&optional group)
7037 "Major mode for reading articles.
7039 All normal editing commands are switched off.
7040 \\<gnus-summary-mode-map>
7041 Each line in this buffer represents one article. To read an
7042 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7043 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7046 You can also post articles and send mail from this buffer. To
7047 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7048 of an article, type `\\[gnus-summary-reply]'.
7050 There are approx. one gazillion commands you can execute in this
7051 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7053 The following commands are available:
7055 \\{gnus-summary-mode-map}"
7057 (when (and menu-bar-mode
7058 (gnus-visual-p 'summary-menu 'menu))
7059 (gnus-summary-make-menu-bar))
7060 (kill-all-local-variables)
7061 (let ((locals gnus-summary-local-variables))
7063 (if (consp (car locals))
7065 (make-local-variable (caar locals))
7066 (set (caar locals) (eval (cdar locals))))
7067 (make-local-variable (car locals))
7068 (set (car locals) nil))
7069 (setq locals (cdr locals))))
7070 (gnus-make-thread-indent-array)
7071 (gnus-simplify-mode-line)
7072 (setq major-mode 'gnus-summary-mode)
7073 (setq mode-name "Summary")
7074 (make-local-variable 'minor-mode-alist)
7075 (use-local-map gnus-summary-mode-map)
7076 (buffer-disable-undo (current-buffer))
7077 (setq buffer-read-only t) ;Disable modification
7078 (setq truncate-lines t)
7079 (setq selective-display t)
7080 (setq selective-display-ellipses t) ;Display `...'
7081 (setq buffer-display-table gnus-summary-display-table)
7082 (setq gnus-newsgroup-name group)
7083 (make-local-variable 'gnus-summary-line-format)
7084 (make-local-variable 'gnus-summary-line-format-spec)
7085 (run-hooks 'gnus-summary-mode-hook))
7087 (defun gnus-summary-make-display-table ()
7088 ;; Change the display table. Odd characters have a tendency to mess
7089 ;; up nicely formatted displays - we make all possible glyphs
7090 ;; display only a single character.
7092 ;; We start from the standard display table, if any.
7093 (setq gnus-summary-display-table
7094 (or (copy-sequence standard-display-table)
7095 (make-display-table)))
7096 ;; Nix out all the control chars...
7098 (while (>= (setq i (1- i)) 0)
7099 (aset gnus-summary-display-table i [??])))
7100 ;; ... but not newline and cr, of course. (cr is necessary for the
7101 ;; selective display).
7102 (aset gnus-summary-display-table ?\n nil)
7103 (aset gnus-summary-display-table ?\r nil)
7104 ;; We nix out any glyphs over 126 that are not set already.
7106 (while (>= (setq i (1- i)) 127)
7107 ;; Only modify if the entry is nil.
7108 (or (aref gnus-summary-display-table i)
7109 (aset gnus-summary-display-table i [??])))))
7111 (defun gnus-summary-clear-local-variables ()
7112 (let ((locals gnus-summary-local-variables))
7114 (if (consp (car locals))
7115 (and (vectorp (caar locals))
7116 (set (caar locals) nil))
7117 (and (vectorp (car locals))
7118 (set (car locals) nil)))
7119 (setq locals (cdr locals)))))
7121 ;; Summary data functions.
7123 (defmacro gnus-data-number (data)
7126 (defmacro gnus-data-set-number (data number)
7127 `(setcar ,data ,number))
7129 (defmacro gnus-data-mark (data)
7132 (defmacro gnus-data-set-mark (data mark)
7133 `(setcar (nthcdr 1 ,data) ,mark))
7135 (defmacro gnus-data-pos (data)
7138 (defmacro gnus-data-set-pos (data pos)
7139 `(setcar (nthcdr 2 ,data) ,pos))
7141 (defmacro gnus-data-header (data)
7144 (defmacro gnus-data-level (data)
7147 (defmacro gnus-data-unread-p (data)
7148 `(= (nth 1 ,data) gnus-unread-mark))
7150 (defmacro gnus-data-pseudo-p (data)
7151 `(consp (nth 3 ,data)))
7153 (defmacro gnus-data-find (number)
7154 `(assq ,number gnus-newsgroup-data))
7156 (defmacro gnus-data-find-list (number &optional data)
7157 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7158 (memq (assq ,number bdata)
7161 (defmacro gnus-data-make (number mark pos header level)
7162 `(list ,number ,mark ,pos ,header ,level))
7164 (defun gnus-data-enter (after-article number mark pos header level offset)
7165 (let ((data (gnus-data-find-list after-article)))
7166 (or data (error "No such article: %d" after-article))
7167 (setcdr data (cons (gnus-data-make number mark pos header level)
7169 (setq gnus-newsgroup-data-reverse nil)
7170 (gnus-data-update-list (cddr data) offset)))
7172 (defun gnus-data-enter-list (after-article list &optional offset)
7174 (let ((data (and after-article (gnus-data-find-list after-article)))
7176 (or data (not after-article) (error "No such article: %d" after-article))
7177 ;; Find the last element in the list to be spliced into the main
7180 (setq list (cdr list)))
7183 (setcdr list gnus-newsgroup-data)
7184 (setq gnus-newsgroup-data ilist)
7185 (and offset (gnus-data-update-list (cdr list) offset)))
7186 (setcdr list (cdr data))
7188 (and offset (gnus-data-update-list (cdr data) offset)))
7189 (setq gnus-newsgroup-data-reverse nil))))
7191 (defun gnus-data-remove (article &optional offset)
7192 (let ((data gnus-newsgroup-data))
7193 (if (= (gnus-data-number (car data)) article)
7194 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7195 gnus-newsgroup-data-reverse nil)
7197 (and (= (gnus-data-number (cadr data)) article)
7199 (setcdr data (cddr data))
7200 (and offset (gnus-data-update-list (cdr data) offset))
7202 gnus-newsgroup-data-reverse nil)))
7203 (setq data (cdr data))))))
7205 (defmacro gnus-data-list (backward)
7207 (or gnus-newsgroup-data-reverse
7208 (setq gnus-newsgroup-data-reverse
7209 (reverse gnus-newsgroup-data)))
7210 gnus-newsgroup-data))
7212 (defun gnus-data-update-list (data offset)
7213 "Add OFFSET to the POS of all data entries in DATA."
7215 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7216 (setq data (cdr data))))
7218 (defun gnus-data-compute-positions ()
7219 "Compute the positions of all articles."
7220 (let ((data gnus-newsgroup-data)
7223 (when (setq pos (text-property-any
7224 (point-min) (point-max)
7225 'gnus-number (gnus-data-number (car data))))
7226 (gnus-data-set-pos (car data) (+ pos 3)))
7227 (setq data (cdr data)))))
7229 (defun gnus-summary-article-pseudo-p (article)
7230 "Say whether this article is a pseudo article or not."
7231 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7233 (defun gnus-article-parent-p (number)
7234 "Say whether this article is a parent or not."
7235 (let ((data (gnus-data-find-list number)))
7236 (and (cdr data) ; There has to be an article after...
7237 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7238 (gnus-data-level (nth 1 data))))))
7240 (defun gnus-article-children (number)
7241 "Return a list of all children to NUMBER."
7242 (let* ((data (gnus-data-find-list number))
7243 (level (gnus-data-level (car data)))
7245 (setq data (cdr data))
7247 (= (gnus-data-level (car data)) (1+ level)))
7248 (push (gnus-data-number (car data)) children)
7249 (setq data (cdr data)))
7252 (defmacro gnus-summary-skip-intangible ()
7253 "If the current article is intangible, then jump to a different article."
7254 '(let ((to (get-text-property (point) 'gnus-intangible)))
7255 (and to (gnus-summary-goto-subject to))))
7257 (defmacro gnus-summary-article-intangible-p ()
7258 "Say whether this article is intangible or not."
7259 '(get-text-property (point) 'gnus-intangible))
7261 ;; Some summary mode macros.
7263 (defmacro gnus-summary-article-number ()
7264 "The article number of the article on the current line.
7265 If there isn's an article number here, then we return the current
7268 (gnus-summary-skip-intangible)
7269 (or (get-text-property (point) 'gnus-number)
7270 (gnus-summary-last-subject))))
7272 (defmacro gnus-summary-article-header (&optional number)
7273 `(gnus-data-header (gnus-data-find
7274 ,(or number '(gnus-summary-article-number)))))
7276 (defmacro gnus-summary-thread-level (&optional number)
7277 `(if (and (eq gnus-summary-make-false-root 'dummy)
7278 (get-text-property (point) 'gnus-intangible))
7280 (gnus-data-level (gnus-data-find
7281 ,(or number '(gnus-summary-article-number))))))
7283 (defmacro gnus-summary-article-mark (&optional number)
7284 `(gnus-data-mark (gnus-data-find
7285 ,(or number '(gnus-summary-article-number)))))
7287 (defmacro gnus-summary-article-pos (&optional number)
7288 `(gnus-data-pos (gnus-data-find
7289 ,(or number '(gnus-summary-article-number)))))
7291 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7292 (defmacro gnus-summary-article-subject (&optional number)
7293 "Return current subject string or nil if nothing."
7296 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7297 '(gnus-data-header (assq (gnus-summary-article-number)
7298 gnus-newsgroup-data)))))
7301 (mail-header-subject headers))))
7303 (defmacro gnus-summary-article-score (&optional number)
7304 "Return current article score."
7305 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7306 gnus-newsgroup-scored))
7307 gnus-summary-default-score 0))
7309 (defun gnus-summary-article-children (&optional number)
7310 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7311 (level (gnus-data-level (car data)))
7313 (while (and (setq data (cdr data))
7314 (> (setq l (gnus-data-level (car data))) level))
7315 (and (= (1+ level) l)
7316 (setq children (cons (gnus-data-number (car data))
7318 (nreverse children)))
7320 (defun gnus-summary-article-parent (&optional number)
7321 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7322 (gnus-data-list t)))
7323 (level (gnus-data-level (car data))))
7325 () ; This is a root.
7326 ;; We search until we find an article with a level less than
7327 ;; this one. That function has to be the parent.
7328 (while (and (setq data (cdr data))
7329 (not (< (gnus-data-level (car data)) level))))
7330 (and data (gnus-data-number (car data))))))
7332 (defun gnus-unread-mark-p (mark)
7333 "Say whether MARK is the unread mark."
7334 (= mark gnus-unread-mark))
7336 (defun gnus-read-mark-p (mark)
7337 "Say whether MARK is one of the marks that mark as read.
7338 This is all marks except unread, ticked, dormant, and expirable."
7339 (not (or (= mark gnus-unread-mark)
7340 (= mark gnus-ticked-mark)
7341 (= mark gnus-dormant-mark)
7342 (= mark gnus-expirable-mark))))
7344 ;; Various summary mode internalish functions.
7346 (defun gnus-mouse-pick-article (e)
7349 (gnus-summary-next-page nil t))
7351 (defun gnus-summary-setup-buffer (group)
7352 "Initialize summary buffer."
7353 (let ((buffer (concat "*Summary " group "*")))
7354 (if (get-buffer buffer)
7357 (setq gnus-summary-buffer (current-buffer))
7358 (not gnus-newsgroup-prepared))
7359 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7360 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7361 (gnus-add-current-to-buffer-list)
7362 (gnus-summary-mode group)
7364 (gnus-carpal-setup-buffer 'summary))
7365 (unless gnus-single-article-buffer
7366 (make-local-variable 'gnus-article-buffer)
7367 (make-local-variable 'gnus-article-current)
7368 (make-local-variable 'gnus-original-article-buffer))
7369 (setq gnus-newsgroup-name group)
7372 (defun gnus-set-global-variables ()
7373 ;; Set the global equivalents of the summary buffer-local variables
7374 ;; to the latest values they had. These reflect the summary buffer
7375 ;; that was in action when the last article was fetched.
7376 (when (eq major-mode 'gnus-summary-mode)
7377 (setq gnus-summary-buffer (current-buffer))
7378 (let ((name gnus-newsgroup-name)
7379 (marked gnus-newsgroup-marked)
7380 (unread gnus-newsgroup-unreads)
7381 (headers gnus-current-headers)
7382 (data gnus-newsgroup-data)
7383 (summary gnus-summary-buffer)
7384 (article-buffer gnus-article-buffer)
7385 (original gnus-original-article-buffer)
7386 (gac gnus-article-current)
7387 (score-file gnus-current-score-file))
7389 (set-buffer gnus-group-buffer)
7390 (setq gnus-newsgroup-name name)
7391 (setq gnus-newsgroup-marked marked)
7392 (setq gnus-newsgroup-unreads unread)
7393 (setq gnus-current-headers headers)
7394 (setq gnus-newsgroup-data data)
7395 (setq gnus-article-current gac)
7396 (setq gnus-summary-buffer summary)
7397 (setq gnus-article-buffer article-buffer)
7398 (setq gnus-original-article-buffer original)
7399 (setq gnus-current-score-file score-file)))))
7401 (defun gnus-summary-last-article-p (&optional article)
7402 "Return whether ARTICLE is the last article in the buffer."
7403 (if (not (setq article (or article (gnus-summary-article-number))))
7404 t ; All non-existant numbers are the last article. :-)
7405 (not (cdr (gnus-data-find-list article)))))
7407 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7408 "Insert a dummy root in the summary buffer."
7410 (add-text-properties
7411 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7412 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7414 (defun gnus-make-thread-indent-array ()
7416 (unless (and gnus-thread-indent-array
7417 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7418 (setq gnus-thread-indent-array (make-vector 201 "")
7419 gnus-thread-indent-array-level gnus-thread-indent-level)
7421 (aset gnus-thread-indent-array n
7422 (make-string (* n gnus-thread-indent-level) ? ))
7425 (defun gnus-summary-insert-line
7426 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7427 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7428 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7429 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7430 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7431 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7432 (gnus-tmp-score-char
7433 (if (or (null gnus-summary-default-score)
7434 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7435 gnus-summary-zcore-fuzz)) ?
7436 (if (< gnus-tmp-score gnus-summary-default-score)
7437 gnus-score-below-mark gnus-score-over-mark)))
7438 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7439 ((memq gnus-tmp-current gnus-newsgroup-cached)
7441 (gnus-tmp-replied gnus-replied-mark)
7442 ((memq gnus-tmp-current gnus-newsgroup-saved)
7444 (t gnus-unread-mark)))
7445 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7448 ((string-match "(.+)" gnus-tmp-from)
7449 (substring gnus-tmp-from
7450 (1+ (match-beginning 0)) (1- (match-end 0))))
7451 ((string-match "<[^>]+> *$" gnus-tmp-from)
7452 (let ((beg (match-beginning 0)))
7453 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7454 (substring gnus-tmp-from (1+ (match-beginning 0))
7455 (1- (match-end 0))))
7456 (substring gnus-tmp-from 0 beg))))
7458 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7459 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7460 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7461 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7462 (buffer-read-only nil))
7463 (when (string= gnus-tmp-name "")
7464 (setq gnus-tmp-name gnus-tmp-from))
7465 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7468 (progn (eval gnus-summary-line-format-spec) (point))
7469 'gnus-number gnus-tmp-number)
7470 (when (gnus-visual-p 'summary-highlight 'highlight)
7472 (run-hooks 'gnus-summary-update-hook)
7475 (defun gnus-summary-update-line (&optional dont-update)
7476 ;; Update summary line after change.
7477 (when (and gnus-summary-default-score
7478 (not gnus-summary-inhibit-highlight))
7479 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7480 (article (gnus-summary-article-number))
7481 (score (gnus-summary-article-score article)))
7483 (if (and gnus-summary-mark-below
7484 (< (gnus-summary-article-score)
7485 gnus-summary-mark-below))
7486 ;; This article has a low score, so we mark it as read.
7487 (when (memq article gnus-newsgroup-unreads)
7488 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7489 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7490 ;; This article was previously marked as read on account
7491 ;; of a low score, but now it has risen, so we mark it as
7493 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7494 (gnus-summary-update-mark
7495 (if (or (null gnus-summary-default-score)
7496 (<= (abs (- score gnus-summary-default-score))
7497 gnus-summary-zcore-fuzz)) ?
7498 (if (< score gnus-summary-default-score)
7499 gnus-score-below-mark gnus-score-over-mark)) 'score))
7500 ;; Do visual highlighting.
7501 (when (gnus-visual-p 'summary-highlight 'highlight)
7502 (run-hooks 'gnus-summary-update-hook)))))
7504 (defvar gnus-tmp-new-adopts nil)
7506 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7507 ;; Sum up all elements (and sub-elements) in a list.
7509 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7511 ((and (consp thread) (cdr thread))
7514 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7517 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7520 (when (and level (zerop level) gnus-tmp-new-adopts)
7523 'gnus-summary-number-of-articles-in-thread
7524 gnus-tmp-new-adopts))))
7526 (if (> number 1) gnus-not-empty-thread-mark
7527 gnus-empty-thread-mark)
7530 (defun gnus-summary-set-local-parameters (group)
7531 "Go through the local params of GROUP and set all variable specs in that list."
7532 (let ((params (gnus-info-params (gnus-get-info group)))
7535 (setq elem (car params)
7536 params (cdr params))
7537 (and (consp elem) ; Has to be a cons.
7538 (consp (cdr elem)) ; The cdr has to be a list.
7539 (symbolp (car elem)) ; Has to be a symbol in there.
7540 (not (memq (car elem)
7541 '(quit-config to-address to-list to-group)))
7542 (progn ; So we set it.
7543 (make-local-variable (car elem))
7544 (set (car elem) (eval (nth 1 elem))))))))
7546 (defun gnus-summary-read-group (group &optional show-all no-article
7547 kill-buffer no-display)
7548 "Start reading news in newsgroup GROUP.
7549 If SHOW-ALL is non-nil, already read articles are also listed.
7550 If NO-ARTICLE is non-nil, no article is selected initially.
7551 If NO-DISPLAY, don't generate a summary buffer."
7552 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7553 (let* ((new-group (gnus-summary-setup-buffer group))
7554 (quit-config (gnus-group-quit-config group))
7555 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7557 ;; This summary buffer exists already, so we just select it.
7559 (gnus-set-global-variables)
7561 (gnus-kill-or-deaden-summary kill-buffer))
7562 (gnus-configure-windows 'summary 'force)
7563 (gnus-set-mode-line 'summary)
7564 (gnus-summary-position-point)
7567 ;; We couldn't select this group.
7569 (when (and (eq major-mode 'gnus-summary-mode)
7570 (not (equal (current-buffer) kill-buffer)))
7571 (kill-buffer (current-buffer))
7572 (if (not quit-config)
7574 (set-buffer gnus-group-buffer)
7575 (gnus-group-jump-to-group group)
7576 (gnus-group-next-unread-group 1))
7577 (if (not (buffer-name (car quit-config)))
7578 (gnus-configure-windows 'group 'force)
7579 (set-buffer (car quit-config))
7580 (and (eq major-mode 'gnus-summary-mode)
7581 (gnus-set-global-variables))
7582 (gnus-configure-windows (cdr quit-config)))))
7583 (gnus-message 3 "Can't select group")
7585 ;; The user did a `C-g' while prompting for number of articles,
7586 ;; so we exit this group.
7587 ((eq did-select 'quit)
7588 (and (eq major-mode 'gnus-summary-mode)
7589 (not (equal (current-buffer) kill-buffer))
7590 (kill-buffer (current-buffer)))
7592 (gnus-kill-or-deaden-summary kill-buffer))
7593 (if (not quit-config)
7595 (set-buffer gnus-group-buffer)
7596 (gnus-group-jump-to-group group)
7597 (gnus-group-next-unread-group 1)
7598 (gnus-configure-windows 'group 'force))
7599 (if (not (buffer-name (car quit-config)))
7600 (gnus-configure-windows 'group 'force)
7601 (set-buffer (car quit-config))
7602 (and (eq major-mode 'gnus-summary-mode)
7603 (gnus-set-global-variables))
7604 (gnus-configure-windows (cdr quit-config))))
7605 ;; Finally signal the quit.
7607 ;; The group was successfully selected.
7609 (gnus-set-global-variables)
7610 ;; Save the active value in effect when the group was entered.
7611 (setq gnus-newsgroup-active
7613 (gnus-active gnus-newsgroup-name)))
7614 ;; You can change the summary buffer in some way with this hook.
7615 (run-hooks 'gnus-select-group-hook)
7616 ;; Set any local variables in the group parameters.
7617 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7618 (gnus-update-format-specifications)
7619 ;; Do score processing.
7620 (when gnus-use-scoring
7621 (gnus-possibly-score-headers))
7622 ;; Check whether to fill in the gaps in the threads.
7623 (when gnus-build-sparse-threads
7624 (gnus-build-sparse-threads))
7625 ;; Find the initial limit.
7626 (if gnus-show-threads
7628 (let ((gnus-newsgroup-dormant nil))
7629 (gnus-summary-initial-limit show-all))
7630 (gnus-summary-initial-limit show-all))
7631 (setq gnus-newsgroup-limit
7633 (lambda (header) (mail-header-number header))
7634 gnus-newsgroup-headers)))
7635 ;; Generate the summary buffer.
7637 (gnus-summary-prepare))
7638 (when gnus-use-trees
7639 (gnus-tree-open group)
7640 (setq gnus-summary-highlight-line-function
7641 'gnus-tree-highlight-article))
7642 ;; If the summary buffer is empty, but there are some low-scored
7643 ;; articles or some excluded dormants, we include these in the
7645 (when (and (zerop (buffer-size))
7647 (cond (gnus-newsgroup-dormant
7648 (gnus-summary-limit-include-dormant))
7649 ((and gnus-newsgroup-scored show-all)
7650 (gnus-summary-limit-include-expunged))))
7651 ;; Function `gnus-apply-kill-file' must be called in this hook.
7652 (run-hooks 'gnus-apply-kill-hook)
7653 (if (and (zerop (buffer-size))
7656 ;; This newsgroup is empty.
7657 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7658 (gnus-message 6 "No unread news")
7660 (gnus-kill-or-deaden-summary kill-buffer))
7661 ;; Return nil from this function.
7663 ;; Hide conversation thread subtrees. We cannot do this in
7664 ;; gnus-summary-prepare-hook since kill processing may not
7665 ;; work with hidden articles.
7666 (and gnus-show-threads
7667 gnus-thread-hide-subtree
7668 (gnus-summary-hide-all-threads))
7669 ;; Show first unread article if requested.
7670 (if (and (not no-article)
7672 gnus-newsgroup-unreads
7673 gnus-auto-select-first)
7674 (unless (if (eq gnus-auto-select-first 'best)
7675 (gnus-summary-best-unread-article)
7676 (gnus-summary-first-unread-article))
7677 (gnus-configure-windows 'summary))
7678 ;; Don't select any articles, just move point to the first
7679 ;; article in the group.
7680 (goto-char (point-min))
7681 (gnus-summary-position-point)
7682 (gnus-set-mode-line 'summary)
7683 (gnus-configure-windows 'summary 'force))
7684 ;; If we are in async mode, we send some info to the backend.
7685 (when gnus-newsgroup-async
7686 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7688 (gnus-kill-or-deaden-summary kill-buffer))
7689 (when (get-buffer-window gnus-group-buffer t)
7690 ;; Gotta use windows, because recenter does wierd stuff if
7691 ;; the current buffer ain't the displayed window.
7692 (let ((owin (selected-window)))
7693 (select-window (get-buffer-window gnus-group-buffer t))
7694 (when (gnus-group-goto-group group)
7696 (select-window owin))))
7697 ;; Mark this buffer as "prepared".
7698 (setq gnus-newsgroup-prepared t)
7701 (defun gnus-summary-prepare ()
7702 "Generate the summary buffer."
7703 (let ((buffer-read-only nil))
7705 (setq gnus-newsgroup-data nil
7706 gnus-newsgroup-data-reverse nil)
7707 (run-hooks 'gnus-summary-generate-hook)
7708 ;; Generate the buffer, either with threads or without.
7709 (when gnus-newsgroup-headers
7710 (gnus-summary-prepare-threads
7711 (if gnus-show-threads
7712 (gnus-sort-gathered-threads
7713 (funcall gnus-summary-thread-gathering-function
7715 (gnus-cut-threads (gnus-make-threads)))))
7716 ;; Unthreaded display.
7717 (gnus-sort-articles gnus-newsgroup-headers))))
7718 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7719 ;; Call hooks for modifying summary buffer.
7720 (goto-char (point-min))
7721 (run-hooks 'gnus-summary-prepare-hook)))
7723 (defun gnus-gather-threads-by-subject (threads)
7724 "Gather threads by looking at Subject headers."
7725 (if (not gnus-summary-make-false-root)
7727 (let ((hashtb (gnus-make-hashtable 1023))
7730 subject hthread whole-subject)
7732 (setq whole-subject (mail-header-subject (caar threads)))
7735 ;; Truncate the subject.
7736 ((numberp gnus-summary-gather-subject-limit)
7737 (setq subject (gnus-simplify-subject-re whole-subject))
7738 (if (> (length subject) gnus-summary-gather-subject-limit)
7739 (substring subject 0 gnus-summary-gather-subject-limit)
7741 ;; Fuzzily simplify it.
7742 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7743 (gnus-simplify-subject-fuzzy whole-subject))
7744 ;; Just remove the leading "Re:".
7746 (gnus-simplify-subject-re whole-subject))))
7748 (if (and gnus-summary-gather-exclude-subject
7749 (string-match gnus-summary-gather-exclude-subject
7751 () ; We don't want to do anything with this article.
7752 ;; We simplify the subject before looking it up in the
7755 (if (setq hthread (gnus-gethash subject hashtb))
7757 ;; We enter a dummy root into the thread, if we
7758 ;; haven't done that already.
7759 (unless (stringp (caar hthread))
7760 (setcar hthread (list whole-subject (car hthread))))
7761 ;; We add this new gathered thread to this gathered
7763 (setcdr (car hthread)
7764 (nconc (cdar hthread) (list (car threads))))
7765 ;; Remove it from the list of threads.
7766 (setcdr prev (cdr threads))
7767 (setq threads prev))
7768 ;; Enter this thread into the hash table.
7769 (gnus-sethash subject threads hashtb)))
7771 (setq threads (cdr threads)))
7774 (defun gnus-gather-threads-by-references (threads)
7775 "Gather threads by looking at References headers."
7776 (let ((idhashtb (gnus-make-hashtable 1023))
7777 (thhashtb (gnus-make-hashtable 1023))
7780 ids references id gthread gid entered)
7782 (when (setq references (mail-header-references (caar threads)))
7783 (setq id (mail-header-id (caar threads)))
7784 (setq ids (gnus-split-references references))
7787 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7789 (gnus-sethash (car ids) id idhashtb)
7790 (gnus-sethash id threads thhashtb))
7791 (setq gthread (gnus-gethash gid thhashtb))
7793 ;; We enter a dummy root into the thread, if we
7794 ;; haven't done that already.
7795 (unless (stringp (caar gthread))
7796 (setcar gthread (list (mail-header-subject (caar gthread))
7798 ;; We add this new gathered thread to this gathered
7800 (setcdr (car gthread)
7801 (nconc (cdar gthread) (list (car threads)))))
7802 ;; Add it into the thread hash table.
7803 (gnus-sethash id gthread thhashtb)
7805 ;; Remove it from the list of threads.
7806 (setcdr prev (cdr threads))
7807 (setq threads prev))
7808 (setq ids (cdr ids))))
7810 (setq threads (cdr threads)))
7813 (defun gnus-sort-gathered-threads (threads)
7814 "Sort subtreads inside each gathered thread by article number."
7815 (let ((result threads))
7817 (when (stringp (caar threads))
7818 (setcdr (car threads)
7819 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7820 (setq threads (cdr threads)))
7823 (defun gnus-make-threads ()
7824 "Go through the dependency hashtb and find the roots. Return all threads."
7828 (unless (car (symbol-value refs))
7829 ;; These threads do not refer back to any other articles,
7830 ;; so they're roots.
7831 (setq threads (append (cdr (symbol-value refs)) threads))))
7832 gnus-newsgroup-dependencies)
7835 (defun gnus-build-sparse-threads ()
7836 (let ((headers gnus-newsgroup-headers)
7837 (deps gnus-newsgroup-dependencies)
7838 header references generation relations
7839 cthread subject child end pthread relation)
7840 ;; First we create an alist of generations/relations, where
7841 ;; generations is how much we trust the ralation, and the relation
7843 (gnus-message 7 "Making sparse threads...")
7845 (nnheader-set-temp-buffer " *gnus sparse threads*")
7846 (while (setq header (pop headers))
7847 (when (and (setq references (mail-header-references header))
7848 (not (string= references "")))
7850 (setq child (mail-header-id header)
7851 subject (mail-header-subject header))
7853 (while (search-backward ">" nil t)
7854 (setq end (1+ (point)))
7855 (when (search-backward "<" nil t)
7856 (push (list (incf generation)
7857 child (setq child (buffer-substring (point) end))
7860 (push (list (1+ generation) child nil subject) relations)
7862 (kill-buffer (current-buffer)))
7863 ;; Sort over trustworthiness.
7864 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7865 (while (setq relation (pop relations))
7866 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7867 (unless (car (symbol-value cthread))
7868 ;; Make this article the parent of these threads.
7869 (setcar (symbol-value cthread)
7870 (vector gnus-reffed-article-number
7874 (or (caddr relation) "") 0 0 "")))
7875 (set cthread (list (vector gnus-reffed-article-number
7877 "" "" (cadr relation)
7878 (or (caddr relation) "") 0 0 ""))))
7879 (push gnus-reffed-article-number gnus-newsgroup-limit)
7880 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7881 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7882 gnus-newsgroup-reads)
7883 (decf gnus-reffed-article-number)
7884 ;; Make this new thread the child of its parent.
7885 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7886 (setcdr (symbol-value pthread)
7887 (nconc (cdr (symbol-value pthread))
7888 (list (symbol-value cthread))))
7889 (set pthread (list nil (symbol-value cthread))))))
7890 (gnus-message 7 "Making sparse threads...done")))
7892 (defun gnus-build-old-threads ()
7893 ;; Look at all the articles that refer back to old articles, and
7894 ;; fetch the headers for the articles that aren't there. This will
7895 ;; build complete threads - if the roots haven't been expired by the
7900 (when (not (car (symbol-value refs)))
7901 (setq heads (cdr (symbol-value refs)))
7903 (if (memq (mail-header-number (caar heads))
7904 gnus-newsgroup-dormant)
7905 (setq heads (cdr heads))
7906 (setq id (symbol-name refs))
7907 (while (and (setq id (gnus-build-get-header id))
7908 (not (car (gnus-gethash
7909 id gnus-newsgroup-dependencies)))))
7910 (setq heads nil)))))
7911 gnus-newsgroup-dependencies)))
7913 (defun gnus-build-get-header (id)
7914 ;; Look through the buffer of NOV lines and find the header to
7915 ;; ID. Enter this line into the dependencies hash table, and return
7916 ;; the id of the parent article (if any).
7917 (let ((deps gnus-newsgroup-dependencies)
7921 (set-buffer nntp-server-buffer)
7922 (goto-char (point-min))
7923 (while (and (not found) (search-forward id nil t))
7925 (setq found (looking-at
7926 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7927 (regexp-quote id))))
7928 (or found (beginning-of-line 2)))
7932 (setq header (gnus-nov-parse-line
7933 (read (current-buffer)) deps))
7934 (gnus-parent-id (mail-header-references header)))))
7936 (let ((number (mail-header-number header)))
7937 (push number gnus-newsgroup-limit)
7938 (push header gnus-newsgroup-headers)
7939 (if (memq number gnus-newsgroup-unselected)
7941 (push number gnus-newsgroup-unreads)
7942 (setq gnus-newsgroup-unselected
7943 (delq number gnus-newsgroup-unselected)))
7944 (push number gnus-newsgroup-ancient)))))))
7946 (defun gnus-summary-update-article (article &optional header)
7947 "Update ARTICLE in the summary buffer."
7948 (set-buffer gnus-summary-buffer)
7949 (let* ((header (or header (gnus-summary-article-header article)))
7950 (id (mail-header-id header))
7951 (data (gnus-data-find article))
7952 (thread (gnus-id-to-thread id))
7954 (gnus-id-to-thread (or (gnus-parent-id
7955 (mail-header-references header))
7957 (buffer-read-only nil)
7959 (number (mail-header-number header))
7964 (delq thread parent))
7965 (if (gnus-summary-insert-subject id header)
7966 ;; Set the (possibly) new article number in the data structure.
7967 (gnus-data-set-number data (gnus-id-to-article id))
7971 (defun gnus-rebuild-thread (id)
7972 "Rebuild the thread containing ID."
7973 (let ((buffer-read-only nil)
7974 current thread data)
7975 (if (not gnus-show-threads)
7976 (setq thread (list (car (gnus-id-to-thread id))))
7977 ;; Get the thread this article is part of.
7978 (setq thread (gnus-remove-thread id)))
7979 (setq current (save-excursion
7980 (and (zerop (forward-line -1))
7981 (gnus-summary-article-number))))
7982 ;; If this is a gathered thread, we have to go some re-gathering.
7983 (when (stringp (car thread))
7984 (let ((subject (car thread))
7986 (setq thread (cdr thread))
7988 (unless (memq (setq thr (gnus-id-to-thread
7990 (mail-header-id (caar thread)))))
7993 (setq thread (cdr thread)))
7994 ;; We now have all (unique) roots.
7995 (if (= (length roots) 1)
7996 ;; All the loose roots are now one solid root.
7997 (setq thread (car roots))
7998 (setq thread (cons subject (gnus-sort-threads roots))))))
8000 ;; We then insert this thread into the summary buffer.
8001 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8002 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8003 (setq data (nreverse gnus-newsgroup-data))
8004 (setq threads gnus-newsgroup-threads))
8005 ;; We splice the new data into the data structure.
8006 (gnus-data-enter-list current data)
8007 (gnus-data-compute-positions)
8008 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8010 (defun gnus-id-to-thread (id)
8011 "Return the (sub-)thread where ID appears."
8012 (gnus-gethash id gnus-newsgroup-dependencies))
8014 (defun gnus-id-to-article (id)
8015 "Return the article number of ID."
8016 (let ((thread (gnus-id-to-thread id)))
8018 (mail-header-number (car thread)))))
8020 (defun gnus-id-to-header (id)
8021 "Return the article headers of ID."
8022 (car (gnus-id-to-thread id)))
8024 (defun gnus-article-displayed-root-p (article)
8025 "Say whether ARTICLE is a root(ish) article."
8026 (let ((level (gnus-summary-thread-level article))
8032 (null (setq particle (gnus-id-to-article
8034 (mail-header-references
8035 (gnus-summary-article-header article))))))
8036 (null (gnus-summary-thread-level particle)))))))
8038 (defun gnus-root-id (id)
8039 "Return the id of the root of the thread where ID appears."
8041 (while (and id (setq prev (car (gnus-gethash
8042 id gnus-newsgroup-dependencies))))
8044 id (gnus-parent-id (mail-header-references prev))))
8047 (defun gnus-remove-thread (id &optional dont-remove)
8048 "Remove the thread that has ID in it."
8049 (let ((dep gnus-newsgroup-dependencies)
8050 headers thread last-id)
8051 ;; First go up in this thread until we find the root.
8052 (setq last-id (gnus-root-id id))
8053 (setq headers (list (car (gnus-id-to-thread last-id))
8054 (caadr (gnus-id-to-thread last-id))))
8055 ;; We have now found the real root of this thread. It might have
8056 ;; been gathered into some loose thread, so we have to search
8057 ;; through the threads to find the thread we wanted.
8058 (let ((threads gnus-newsgroup-threads)
8061 (setq sub (car threads))
8062 (if (stringp (car sub))
8063 ;; This is a gathered threads, so we look at the roots
8064 ;; below it to find whether this article in in this
8067 (setq sub (cdr sub))
8069 (when (member (caar sub) headers)
8070 (setq thread (car threads)
8073 (setq sub (cdr sub))))
8074 ;; It's an ordinary thread, so we check it.
8075 (when (eq (car sub) (car headers))
8078 (setq threads (cdr threads)))
8079 ;; If this article is in no thread, then it's a root.
8082 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8083 (setq thread (gnus-gethash last-id dep)))
8086 thread ; We return this thread.
8088 (if (stringp (car thread))
8090 ;; If we use dummy roots, then we have to remove the
8091 ;; dummy root as well.
8092 (when (eq gnus-summary-make-false-root 'dummy)
8095 (setq thread (cdr thread))
8097 (gnus-remove-thread-1 (car thread))
8098 (setq thread (cdr thread))))
8099 (gnus-remove-thread-1 thread))))))))
8101 (defun gnus-remove-thread-1 (thread)
8102 "Remove the thread THREAD recursively."
8103 (let ((number (mail-header-number (car thread)))
8105 (when (setq pos (text-property-any
8106 (point-min) (point-max) 'gnus-number number))
8109 (gnus-data-remove number))
8110 (setq thread (cdr thread))
8112 (gnus-remove-thread-1 (pop thread)))))
8114 (defun gnus-sort-threads (threads)
8116 (if (not gnus-thread-sort-functions)
8118 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8119 (car gnus-thread-sort-functions)
8121 ,(gnus-make-sort-function
8122 (reverse gnus-thread-sort-functions))))))
8123 (gnus-message 7 "Sorting threads...")
8126 (gnus-message 7 "Sorting threads...done")))))
8128 (defun gnus-sort-articles (articles)
8130 (when gnus-article-sort-functions
8131 (let ((func (if (= 1 (length gnus-article-sort-functions))
8132 (car gnus-article-sort-functions)
8134 ,(gnus-make-sort-function
8135 (reverse gnus-article-sort-functions))))))
8136 (gnus-message 7 "Sorting articles...")
8138 (setq gnus-newsgroup-headers (sort articles func))
8139 (gnus-message 7 "Sorting articles...done")))))
8141 (defun gnus-make-sort-function (funs)
8142 "Return a composite sort condition based on the functions in FUNC."
8144 `(or (,(car funs) t1 t2)
8145 (and (not (,(car funs) t2 t1))
8146 ,(gnus-make-sort-function (cdr funs))))
8147 `(,(car funs) t1 t2)))
8149 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8150 (defmacro gnus-thread-header (thread)
8151 ;; Return header of first article in THREAD.
8152 ;; Note that THREAD must never, ever be anything else than a variable -
8153 ;; using some other form will lead to serious barfage.
8154 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8155 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8156 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8159 (defsubst gnus-article-sort-by-number (h1 h2)
8160 "Sort articles by article number."
8161 (< (mail-header-number h1)
8162 (mail-header-number h2)))
8164 (defun gnus-thread-sort-by-number (h1 h2)
8165 "Sort threads by root article number."
8166 (gnus-article-sort-by-number
8167 (gnus-thread-header h1) (gnus-thread-header h2)))
8169 (defsubst gnus-article-sort-by-author (h1 h2)
8170 "Sort articles by root author."
8172 (let ((extract (funcall
8173 gnus-extract-address-components
8174 (mail-header-from h1))))
8175 (or (car extract) (cdr extract)))
8176 (let ((extract (funcall
8177 gnus-extract-address-components
8178 (mail-header-from h2))))
8179 (or (car extract) (cdr extract)))))
8181 (defun gnus-thread-sort-by-author (h1 h2)
8182 "Sort threads by root author."
8183 (gnus-article-sort-by-author
8184 (gnus-thread-header h1) (gnus-thread-header h2)))
8186 (defsubst gnus-article-sort-by-subject (h1 h2)
8187 "Sort articles by root subject."
8189 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8190 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8192 (defun gnus-thread-sort-by-subject (h1 h2)
8193 "Sort threads by root subject."
8194 (gnus-article-sort-by-subject
8195 (gnus-thread-header h1) (gnus-thread-header h2)))
8197 (defsubst gnus-article-sort-by-date (h1 h2)
8198 "Sort articles by root article date."
8200 (gnus-sortable-date (mail-header-date h1))
8201 (gnus-sortable-date (mail-header-date h2))))
8203 (defun gnus-thread-sort-by-date (h1 h2)
8204 "Sort threads by root article date."
8205 (gnus-article-sort-by-date
8206 (gnus-thread-header h1) (gnus-thread-header h2)))
8208 (defsubst gnus-article-sort-by-score (h1 h2)
8209 "Sort articles by root article score.
8210 Unscored articles will be counted as having a score of zero."
8211 (> (or (cdr (assq (mail-header-number h1)
8212 gnus-newsgroup-scored))
8213 gnus-summary-default-score 0)
8214 (or (cdr (assq (mail-header-number h2)
8215 gnus-newsgroup-scored))
8216 gnus-summary-default-score 0)))
8218 (defun gnus-thread-sort-by-score (h1 h2)
8219 "Sort threads by root article score."
8220 (gnus-article-sort-by-score
8221 (gnus-thread-header h1) (gnus-thread-header h2)))
8223 (defun gnus-thread-sort-by-total-score (h1 h2)
8224 "Sort threads by the sum of all scores in the thread.
8225 Unscored articles will be counted as having a score of zero."
8226 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8228 (defun gnus-thread-total-score (thread)
8229 ;; This function find the total score of THREAD.
8231 (if (stringp (car thread))
8232 (apply gnus-thread-score-function 0
8233 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8234 (gnus-thread-total-score-1 thread))
8235 (gnus-thread-total-score-1 (list thread))))
8237 (defun gnus-thread-total-score-1 (root)
8238 ;; This function find the total score of the thread below ROOT.
8239 (setq root (car root))
8240 (apply gnus-thread-score-function
8241 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8242 gnus-summary-default-score 0)
8243 (mapcar 'gnus-thread-total-score
8244 (cdr (gnus-gethash (mail-header-id root)
8245 gnus-newsgroup-dependencies)))))
8247 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8248 (defvar gnus-tmp-prev-subject nil)
8249 (defvar gnus-tmp-false-parent nil)
8250 (defvar gnus-tmp-root-expunged nil)
8251 (defvar gnus-tmp-dummy-line nil)
8253 (defun gnus-summary-prepare-threads (threads)
8254 "Prepare summary buffer from THREADS and indentation LEVEL.
8255 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8256 or a straight list of headers."
8257 (gnus-message 7 "Generating summary...")
8259 (setq gnus-newsgroup-threads threads)
8262 (let ((gnus-tmp-level 0)
8263 (default-score (or gnus-summary-default-score 0))
8264 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8265 thread number subject stack state gnus-tmp-gathered beg-match
8266 new-roots gnus-tmp-new-adopts thread-end
8267 gnus-tmp-header gnus-tmp-unread
8268 gnus-tmp-replied gnus-tmp-subject-or-nil
8269 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8270 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8271 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8273 (setq gnus-tmp-prev-subject nil)
8275 (if (vectorp (car threads))
8276 ;; If this is a straight (sic) list of headers, then a
8277 ;; threaded summary display isn't required, so we just create
8278 ;; an unthreaded one.
8279 (gnus-summary-prepare-unthreaded threads)
8281 ;; Do the threaded display.
8283 (while (or threads stack gnus-tmp-new-adopts new-roots)
8285 (if (and (= gnus-tmp-level 0)
8286 (not (setq gnus-tmp-dummy-line nil))
8289 (not gnus-tmp-false-parent)
8290 (or gnus-tmp-new-adopts new-roots))
8291 (if gnus-tmp-new-adopts
8292 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8293 thread (list (car gnus-tmp-new-adopts))
8294 gnus-tmp-header (caar thread)
8295 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8297 (setq thread (list (car new-roots))
8298 gnus-tmp-header (caar thread)
8299 new-roots (cdr new-roots))))
8302 ;; If there are some threads, we do them before the
8303 ;; threads on the stack.
8304 (setq thread threads
8305 gnus-tmp-header (caar thread))
8306 ;; There were no current threads, so we pop something off
8308 (setq state (car stack)
8309 gnus-tmp-level (car state)
8312 gnus-tmp-header (caar thread))))
8314 (setq gnus-tmp-false-parent nil)
8315 (setq gnus-tmp-root-expunged nil)
8316 (setq thread-end nil)
8318 (if (stringp gnus-tmp-header)
8319 ;; The header is a dummy root.
8321 ((eq gnus-summary-make-false-root 'adopt)
8322 ;; We let the first article adopt the rest.
8323 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8325 (setq gnus-tmp-gathered
8327 (lambda (h) (mail-header-number (car h)))
8330 (setq thread (cons (list (caar thread)
8333 (setq gnus-tmp-level -1
8334 gnus-tmp-false-parent t))
8335 ((eq gnus-summary-make-false-root 'empty)
8336 ;; We print adopted articles with empty subject fields.
8337 (setq gnus-tmp-gathered
8339 (lambda (h) (mail-header-number (car h)))
8342 (setq gnus-tmp-level -1))
8343 ((eq gnus-summary-make-false-root 'dummy)
8344 ;; We remember that we probably want to output a dummy
8346 (setq gnus-tmp-dummy-line gnus-tmp-header)
8347 (setq gnus-tmp-prev-subject gnus-tmp-header))
8349 ;; We do not make a root for the gathered
8350 ;; sub-threads at all.
8351 (setq gnus-tmp-level -1)))
8353 (setq number (mail-header-number gnus-tmp-header)
8354 subject (mail-header-subject gnus-tmp-header))
8357 ;; If the thread has changed subject, we might want to make
8358 ;; this subthread into a root.
8359 ((and (null gnus-thread-ignore-subject)
8360 (not (zerop gnus-tmp-level))
8361 gnus-tmp-prev-subject
8363 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8364 (setq new-roots (nconc new-roots (list (car thread)))
8366 gnus-tmp-header nil))
8367 ;; If the article lies outside the current limit,
8368 ;; then we do not display it.
8369 ((and (not (memq number gnus-newsgroup-limit))
8370 (not gnus-tmp-dummy-line))
8371 (setq gnus-tmp-gathered
8373 (lambda (h) (mail-header-number (car h)))
8376 (setq gnus-tmp-new-adopts (if (cdar thread)
8377 (append gnus-tmp-new-adopts
8379 gnus-tmp-new-adopts)
8381 gnus-tmp-header nil)
8382 (when (zerop gnus-tmp-level)
8383 (setq gnus-tmp-root-expunged t)))
8384 ;; Perhaps this article is to be marked as read?
8385 ((and gnus-summary-mark-below
8386 (< (or (cdr (assq number gnus-newsgroup-scored))
8388 gnus-summary-mark-below)
8389 ;; Don't touch sparse articles.
8390 (not (memq number gnus-newsgroup-sparse)))
8391 (setq gnus-newsgroup-unreads
8392 (delq number gnus-newsgroup-unreads))
8393 (if gnus-newsgroup-auto-expire
8394 (push number gnus-newsgroup-expirable)
8395 (push (cons number gnus-low-score-mark)
8396 gnus-newsgroup-reads))))
8398 (when gnus-tmp-header
8399 ;; We may have an old dummy line to output before this
8401 (when gnus-tmp-dummy-line
8402 (gnus-summary-insert-dummy-line
8403 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8404 (setq gnus-tmp-dummy-line nil))
8406 ;; Compute the mark.
8410 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8411 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8412 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8413 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8414 (t (or (cdr (assq number gnus-newsgroup-reads))
8415 gnus-ancient-mark))))
8417 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8418 gnus-tmp-header gnus-tmp-level)
8419 gnus-newsgroup-data)
8421 ;; Actually insert the line.
8423 gnus-tmp-subject-or-nil
8425 ((and gnus-thread-ignore-subject
8426 gnus-tmp-prev-subject
8427 (not (inline (gnus-subject-equal
8428 gnus-tmp-prev-subject subject))))
8430 ((zerop gnus-tmp-level)
8431 (if (and (eq gnus-summary-make-false-root 'empty)
8432 (memq number gnus-tmp-gathered)
8433 gnus-tmp-prev-subject
8434 (inline (gnus-subject-equal
8435 gnus-tmp-prev-subject subject)))
8436 gnus-summary-same-subject
8438 (t gnus-summary-same-subject)))
8439 (if (and (eq gnus-summary-make-false-root 'adopt)
8440 (= gnus-tmp-level 1)
8441 (memq number gnus-tmp-gathered))
8442 (setq gnus-tmp-opening-bracket ?\<
8443 gnus-tmp-closing-bracket ?\>)
8444 (setq gnus-tmp-opening-bracket ?\[
8445 gnus-tmp-closing-bracket ?\]))
8447 gnus-tmp-indentation
8448 (aref gnus-thread-indent-array gnus-tmp-level)
8449 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8450 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8451 gnus-summary-default-score 0)
8453 (if (or (null gnus-summary-default-score)
8454 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8455 gnus-summary-zcore-fuzz)) ?
8456 (if (< gnus-tmp-score gnus-summary-default-score)
8457 gnus-score-below-mark gnus-score-over-mark))
8459 (cond ((memq number gnus-newsgroup-processable)
8461 ((memq number gnus-newsgroup-cached)
8463 ((memq number gnus-newsgroup-replied)
8465 (t gnus-unread-mark))
8466 gnus-tmp-from (mail-header-from gnus-tmp-header)
8469 ((string-match "(.+)" gnus-tmp-from)
8470 (substring gnus-tmp-from
8471 (1+ (match-beginning 0)) (1- (match-end 0))))
8472 ((string-match "<[^>]+> *$" gnus-tmp-from)
8473 (setq beg-match (match-beginning 0))
8474 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8475 (substring gnus-tmp-from (1+ (match-beginning 0))
8476 (1- (match-end 0))))
8477 (substring gnus-tmp-from 0 beg-match)))
8479 (when (string= gnus-tmp-name "")
8480 (setq gnus-tmp-name gnus-tmp-from))
8481 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8484 (progn (eval gnus-summary-line-format-spec) (point))
8485 'gnus-number number)
8488 (run-hooks 'gnus-summary-update-hook)
8491 (setq gnus-tmp-prev-subject subject)))
8493 (when (nth 1 thread)
8494 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8495 (incf gnus-tmp-level)
8496 (setq threads (if thread-end nil (cdar thread)))
8498 (setq gnus-tmp-level 0)))))
8499 (gnus-message 7 "Generating summary...done"))
8501 (defun gnus-summary-prepare-unthreaded (headers)
8502 "Generate an unthreaded summary buffer based on HEADERS."
8503 (let (header number mark)
8506 ;; We may have to root out some bad articles...
8507 (when (memq (setq number (mail-header-number
8508 (setq header (pop headers))))
8509 gnus-newsgroup-limit)
8510 ;; Mark article as read when it has a low score.
8511 (when (and gnus-summary-mark-below
8512 (< (or (cdr (assq number gnus-newsgroup-scored))
8513 gnus-summary-default-score 0)
8514 gnus-summary-mark-below))
8515 (setq gnus-newsgroup-unreads
8516 (delq number gnus-newsgroup-unreads))
8517 (if gnus-newsgroup-auto-expire
8518 (push number gnus-newsgroup-expirable)
8519 (push (cons number gnus-low-score-mark)
8520 gnus-newsgroup-reads)))
8524 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8525 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8526 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8527 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8528 (t (or (cdr (assq number gnus-newsgroup-reads))
8529 gnus-ancient-mark))))
8530 (setq gnus-newsgroup-data
8531 (cons (gnus-data-make number mark (1+ (point)) header 0)
8532 gnus-newsgroup-data))
8533 (gnus-summary-insert-line
8534 header 0 nil mark (memq number gnus-newsgroup-replied)
8535 (memq number gnus-newsgroup-expirable)
8536 (mail-header-subject header) nil
8537 (cdr (assq number gnus-newsgroup-scored))
8538 (memq number gnus-newsgroup-processable))))))
8540 (defun gnus-select-newsgroup (group &optional read-all)
8541 "Select newsgroup GROUP.
8542 If READ-ALL is non-nil, all articles in the group are selected."
8543 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8544 (info (nth 2 entry))
8545 articles fetched-articles cached)
8547 (or (gnus-check-server
8548 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8549 (error "Couldn't open server"))
8551 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8552 (gnus-activate-group group) ; Or we can activate it...
8553 (progn ; Or we bug out.
8554 (when (equal major-mode 'gnus-summary-mode)
8555 (kill-buffer (current-buffer)))
8556 (error "Couldn't request group %s: %s"
8557 group (gnus-status-message group))))
8559 (setq gnus-newsgroup-name group)
8560 (setq gnus-newsgroup-unselected nil)
8561 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8563 (and gnus-asynchronous
8564 (gnus-check-backend-function
8565 'request-asynchronous gnus-newsgroup-name)
8566 (setq gnus-newsgroup-async
8567 (gnus-request-asynchronous gnus-newsgroup-name)))
8569 ;; Adjust and set lists of article marks.
8571 (gnus-adjust-marked-articles info))
8573 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8574 (when (gnus-virtual-group-p group)
8575 (setq cached gnus-newsgroup-cached))
8577 (setq gnus-newsgroup-unreads
8578 (gnus-set-difference
8579 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8580 gnus-newsgroup-dormant))
8582 (setq gnus-newsgroup-processable nil)
8584 (setq articles (gnus-articles-to-read group read-all))
8588 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8590 ((eq articles 0) nil)
8592 ;; Init the dependencies hash table.
8593 (setq gnus-newsgroup-dependencies
8594 (gnus-make-hashtable (length articles)))
8595 ;; Retrieve the headers and read them in.
8596 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8597 (setq gnus-newsgroup-headers
8599 (setq gnus-headers-retrieved-by
8600 (gnus-retrieve-headers
8601 articles gnus-newsgroup-name
8602 ;; We might want to fetch old headers, but
8603 ;; not if there is only 1 article.
8604 (and gnus-fetch-old-headers
8606 (not (eq gnus-fetch-old-headers 'some))
8607 (not (numberp gnus-fetch-old-headers)))
8608 (> (length articles) 1))))))
8609 (gnus-get-newsgroup-headers-xover articles)
8610 (gnus-get-newsgroup-headers)))
8611 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8613 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8615 (setq gnus-newsgroup-cached cached))
8617 ;; Set the initial limit.
8618 (setq gnus-newsgroup-limit (copy-sequence articles))
8619 ;; Remove canceled articles from the list of unread articles.
8620 (setq gnus-newsgroup-unreads
8621 (gnus-set-sorted-intersection
8622 gnus-newsgroup-unreads
8623 (setq fetched-articles
8624 (mapcar (lambda (headers) (mail-header-number headers))
8625 gnus-newsgroup-headers))))
8626 ;; Removed marked articles that do not exist.
8627 (gnus-update-missing-marks
8628 (gnus-sorted-complement fetched-articles articles))
8629 ;; We might want to build some more threads first.
8630 (and gnus-fetch-old-headers
8631 (eq gnus-headers-retrieved-by 'nov)
8632 (gnus-build-old-threads))
8633 ;; Check whether auto-expire is to be done in this group.
8634 (setq gnus-newsgroup-auto-expire
8635 (gnus-group-auto-expirable-p group))
8636 ;; Set up the article buffer now, if necessary.
8637 (unless gnus-single-article-buffer
8638 (gnus-article-setup-buffer))
8639 ;; First and last article in this newsgroup.
8640 (and gnus-newsgroup-headers
8641 (setq gnus-newsgroup-begin
8642 (mail-header-number (car gnus-newsgroup-headers)))
8643 (setq gnus-newsgroup-end
8645 (gnus-last-element gnus-newsgroup-headers))))
8646 (setq gnus-reffed-article-number -1)
8647 ;; GROUP is successfully selected.
8648 (or gnus-newsgroup-headers t)))))
8650 (defun gnus-articles-to-read (group read-all)
8651 ;; Find out what articles the user wants to read.
8653 ;; Select all articles if `read-all' is non-nil, or if there
8654 ;; are no unread articles.
8656 (and (zerop (length gnus-newsgroup-marked))
8657 (zerop (length gnus-newsgroup-unreads))))
8658 (gnus-uncompress-range (gnus-active group))
8659 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8660 (copy-sequence gnus-newsgroup-unreads))
8662 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8663 (scored (length scored-list))
8664 (number (length articles))
8665 (marked (+ (length gnus-newsgroup-marked)
8666 (length gnus-newsgroup-dormant)))
8674 ((and (or (<= scored marked) (= scored number))
8675 (numberp gnus-large-newsgroup)
8676 (> number gnus-large-newsgroup))
8680 "How many articles from %s (default %d): "
8681 gnus-newsgroup-name number))))
8682 (if (string-match "^[ \t]*$" input) number input)))
8683 ((and (> scored marked) (< scored number))
8686 (format "%s %s (%d scored, %d total): "
8687 "How many articles from"
8688 group scored number))))
8689 (if (string-match "^[ \t]*$" input)
8693 (setq select (if (stringp select) (string-to-number select) select))
8694 (if (or (null select) (zerop select))
8696 (if (and (not (zerop scored)) (<= (abs select) scored))
8698 (setq articles (sort scored-list '<))
8699 (setq number (length articles)))
8700 (setq articles (copy-sequence articles)))
8702 (if (< (abs select) number)
8704 ;; Select the N oldest articles.
8705 (setcdr (nthcdr (1- (abs select)) articles) nil)
8706 ;; Select the N most recent articles.
8707 (setq articles (nthcdr (- number select) articles))))
8708 (setq gnus-newsgroup-unselected
8709 (gnus-sorted-intersection
8710 gnus-newsgroup-unreads
8711 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8714 (defun gnus-killed-articles (killed articles)
8717 (if (inline (gnus-member-of-range (car articles) killed))
8718 (setq out (cons (car articles) out)))
8719 (setq articles (cdr articles)))
8722 (defun gnus-uncompress-marks (marks)
8723 "Uncompress the mark ranges in MARKS."
8724 (let ((uncompressed '(score bookmark))
8727 (if (memq (caar marks) uncompressed)
8728 (push (car marks) out)
8729 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8730 (setq marks (cdr marks)))
8733 (defun gnus-adjust-marked-articles (info)
8734 "Set all article lists and remove all marks that are no longer legal."
8735 (let* ((marked-lists (gnus-info-marks info))
8736 (active (gnus-active (gnus-info-group info)))
8739 (types gnus-article-mark-lists)
8740 (uncompressed '(score bookmark))
8741 marks var articles article mark)
8744 (setq marks (pop marked-lists))
8745 (set (setq var (intern (format "gnus-newsgroup-%s"
8746 (car (rassq (setq mark (car marks))
8748 (if (memq (car marks) uncompressed) (cdr marks)
8749 (gnus-uncompress-range (cdr marks))))
8751 (setq articles (symbol-value var))
8753 ;; All articles have to be subsets of the active articles.
8755 ;; Adjust "simple" lists.
8756 ((memq mark '(tick dormant expirable reply killed save))
8758 (when (or (< (setq article (pop articles)) min) (> article max))
8759 (set var (delq article (symbol-value var))))))
8761 ((memq mark '(score bookmark))
8763 (when (or (< (car (setq article (pop articles))) min)
8764 (> (car article) max))
8765 (set var (delq article (symbol-value var))))))))))
8767 (defun gnus-update-missing-marks (missing)
8768 "Go through the list of MISSING articles and remove them mark lists."
8770 (let ((types gnus-article-mark-lists)
8772 ;; Go through all types.
8774 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8775 (when (symbol-value var)
8776 ;; This list has articles. So we delete all missing articles
8780 (set var (delq (pop m) (symbol-value var)))))))))
8782 (defun gnus-update-marks ()
8783 "Enter the various lists of marked articles into the newsgroup info list."
8784 (let ((types gnus-article-mark-lists)
8785 (info (gnus-get-info gnus-newsgroup-name))
8786 (uncompressed '(score bookmark killed))
8787 type list newmarked symbol)
8789 ;; Add all marks lists that are non-nil to the list of marks lists.
8791 (setq type (pop types))
8792 (when (setq list (symbol-value
8794 (intern (format "gnus-newsgroup-%s"
8796 (push (cons (cdr type)
8797 (if (memq (cdr type) uncompressed) list
8798 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8801 ;; Enter these new marks into the info of the group.
8803 (setcar (nthcdr 3 info) newmarked)
8804 ;; Add the marks lists to the end of the info.
8806 (setcdr (nthcdr 2 info) (list newmarked))))
8808 ;; Cut off the end of the info if there's nothing else there.
8812 (when (nthcdr (decf i) info)
8813 (setcdr (nthcdr i info) nil)))))))
8815 (defun gnus-add-marked-articles (group type articles &optional info force)
8816 ;; Add ARTICLES of TYPE to the info of GROUP.
8817 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8818 ;; add, but replace marked articles of TYPE with ARTICLES.
8819 (let ((info (or info (gnus-get-info group)))
8820 (uncompressed '(score bookmark killed))
8823 (and (not (setq marked (nthcdr 3 info)))
8825 (setcdr (nthcdr 2 info)
8826 (list (list (cons type (gnus-compress-sequence
8828 (and (not (setq m (assq type (car marked))))
8831 (cons (cons type (gnus-compress-sequence articles t) )
8835 (setcar (nthcdr 3 info)
8836 (delq (assq type (car marked)) (car marked)))
8837 (setcdr m (gnus-compress-sequence articles t)))
8838 (setcdr m (gnus-compress-sequence
8839 (sort (nconc (gnus-uncompress-range (cdr m))
8840 (copy-sequence articles)) '<) t))))))
8842 (defun gnus-set-mode-line (where)
8843 "This function sets the mode line of the article or summary buffers.
8844 If WHERE is `summary', the summary mode line format will be used."
8845 ;; Is this mode line one we keep updated?
8846 (when (memq where gnus-updated-mode-lines)
8849 ;; We evaluate this in the summary buffer since these
8850 ;; variables are buffer-local to that buffer.
8851 (set-buffer gnus-summary-buffer)
8852 ;; We bind all these variables that are used in the `eval' form
8854 (let* ((mformat (symbol-value
8856 (format "gnus-%s-mode-line-format-spec" where))))
8857 (gnus-tmp-group-name gnus-newsgroup-name)
8858 (gnus-tmp-article-number (or gnus-current-article 0))
8859 (gnus-tmp-unread gnus-newsgroup-unreads)
8860 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8861 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8862 (gnus-tmp-unread-and-unselected
8863 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8864 (zerop gnus-tmp-unselected)) "")
8865 ((zerop gnus-tmp-unselected)
8866 (format "{%d more}" gnus-tmp-unread-and-unticked))
8867 (t (format "{%d(+%d) more}"
8868 gnus-tmp-unread-and-unticked
8869 gnus-tmp-unselected))))
8871 (if (and gnus-current-headers
8872 (vectorp gnus-current-headers))
8873 (mail-header-subject gnus-current-headers) ""))
8875 gnus-tmp-header);; passed as argument to any user-format-funcs
8876 (setq mode-string (eval mformat))
8877 (setq max-len (max 4 (if gnus-mode-non-string-length
8879 gnus-mode-non-string-length)
8880 (length mode-string))))
8881 ;; We might have to chop a bit of the string off...
8882 (when (> (length mode-string) max-len)
8884 (concat (gnus-truncate-string mode-string (- max-len 3))
8886 ;; Pad the mode string a bit.
8887 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8888 ;; Update the mode line.
8889 (setq mode-line-buffer-identification (list mode-string))
8890 (set-buffer-modified-p t))))
8892 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8893 "Go through the HEADERS list and add all Xrefs to a hash table.
8894 The resulting hash table is returned, or nil if no Xrefs were found."
8895 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8896 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8897 (xref-hashtb (make-vector 63 0))
8898 start group entry number xrefs header)
8900 (setq header (pop headers))
8901 (when (and (setq xrefs (mail-header-xref header))
8902 (not (memq (setq number (mail-header-number header))
8905 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8906 (setq start (match-end 0))
8907 (setq group (if prefix
8908 (concat prefix (substring xrefs (match-beginning 1)
8910 (substring xrefs (match-beginning 1) (match-end 1))))
8912 (string-to-int (substring xrefs (match-beginning 2)
8914 (if (setq entry (gnus-gethash group xref-hashtb))
8915 (setcdr entry (cons number (cdr entry)))
8916 (gnus-sethash group (cons number nil) xref-hashtb)))))
8917 (and start xref-hashtb)))
8919 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8920 "Look through all the headers and mark the Xrefs as read."
8921 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8922 name entry info xref-hashtb idlist method nth4)
8924 (set-buffer gnus-group-buffer)
8925 (when (setq xref-hashtb
8926 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8929 (unless (string= from-newsgroup (setq name (symbol-name group)))
8930 (setq idlist (symbol-value group))
8931 ;; Dead groups are not updated.
8933 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8935 (if (stringp (setq nth4 (gnus-info-method info)))
8936 (setq nth4 (gnus-server-to-method nth4))))
8937 ;; Only do the xrefs if the group has the same
8938 ;; select method as the group we have just read.
8939 (or (gnus-methods-equal-p
8940 nth4 (gnus-find-method-for-group from-newsgroup))
8942 (equal nth4 (setq method (gnus-find-method-for-group
8944 (and (equal (car nth4) (car method))
8945 (equal (nth 1 nth4) (nth 1 method))))
8946 gnus-use-cross-reference
8947 (or (not (eq gnus-use-cross-reference t))
8949 ;; Only do cross-references on subscribed
8950 ;; groups, if that is what is wanted.
8951 (<= (gnus-info-level info) gnus-level-subscribed))
8952 (gnus-group-make-articles-read name idlist))))
8955 (defun gnus-group-make-articles-read (group articles)
8957 (entry (gnus-gethash group gnus-newsrc-hashtb))
8958 (info (nth 2 entry))
8959 (active (gnus-active group))
8961 ;; First peel off all illegal article numbers.
8963 (let ((ids articles)
8967 (if (and first (> id (cdr active)))
8969 ;; We'll end up in this situation in one particular
8970 ;; obscure situation. If you re-scan a group and get
8971 ;; a new article that is cross-posted to a different
8972 ;; group that has not been re-scanned, you might get
8973 ;; crossposted article that has a higher number than
8974 ;; Gnus believes possible. So we re-activate this
8975 ;; group as well. This might mean doing the
8976 ;; crossposting thingy will *increase* the number
8977 ;; of articles in some groups. Tsk, tsk.
8978 (setq active (or (gnus-activate-group group) active))))
8979 (if (or (> id (cdr active))
8980 (< id (car active)))
8981 (setq articles (delq id articles)))
8982 (setq ids (cdr ids)))))
8983 ;; If the read list is nil, we init it.
8985 (null (gnus-info-read info))
8987 (gnus-info-set-read info (cons 1 (1- (car active)))))
8988 ;; Then we add the read articles to the range.
8993 (gnus-info-read info) (setq articles (sort articles '<)))))
8994 ;; Then we have to re-compute how many unread
8995 ;; articles there are in this group.
9000 (setq num (- (1+ (cdr active)) (car active))))
9001 ((not (listp (cdr range)))
9002 (setq num (- (cdr active) (- (1+ (cdr range))
9006 (if (numberp (car range))
9008 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9009 (setq range (cdr range)))
9010 (setq num (- (cdr active) num))))
9011 ;; Update the number of unread articles.
9013 ;; Update the group buffer.
9014 (gnus-group-update-group group t)))))
9016 (defun gnus-methods-equal-p (m1 m2)
9017 (let ((m1 (or m1 gnus-select-method))
9018 (m2 (or m2 gnus-select-method)))
9020 (and (eq (car m1) (car m2))
9021 (or (not (memq 'address (assoc (symbol-name (car m1))
9022 gnus-valid-select-methods)))
9023 (equal (nth 1 m1) (nth 1 m2)))))))
9025 (defsubst gnus-header-value ()
9026 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9028 (defvar gnus-newsgroup-none-id 0)
9030 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9031 (let ((cur nntp-server-buffer)
9034 (save-excursion (set-buffer gnus-summary-buffer)
9035 gnus-newsgroup-dependencies)))
9036 headers id id-dep ref-dep end ref)
9038 (set-buffer nntp-server-buffer)
9039 (run-hooks 'gnus-parse-headers-hook)
9040 (let ((case-fold-search t)
9041 in-reply-to header p lines)
9042 (goto-char (point-min))
9043 ;; Search to the beginning of the next header. Error messages
9044 ;; do not begin with 2 or 3.
9045 (while (re-search-forward "^[23][0-9]+ " nil t)
9048 ;; This implementation of this function, with nine
9049 ;; search-forwards instead of the one re-search-forward and
9050 ;; a case (which basically was the old function) is actually
9051 ;; about twice as fast, even though it looks messier. You
9052 ;; can't have everything, I guess. Speed and elegance
9053 ;; doesn't always go hand in hand.
9062 (narrow-to-region (point)
9063 (or (and (search-forward "\n.\n" nil t)
9069 (if (search-forward "\nsubject: " nil t)
9070 (gnus-header-value) "(none)"))
9074 (if (search-forward "\nfrom: " nil t)
9075 (gnus-header-value) "(nobody)"))
9079 (if (search-forward "\ndate: " nil t)
9080 (gnus-header-value) ""))
9084 (if (search-forward "\nmessage-id: " nil t)
9085 (setq id (gnus-header-value))
9086 ;; If there was no message-id, we just fake one to make
9087 ;; subsequent routines simpler.
9088 (setq id (concat "none+"
9090 (setq gnus-newsgroup-none-id
9091 (1+ gnus-newsgroup-none-id)))))))
9095 (if (search-forward "\nreferences: " nil t)
9098 (setq end (match-end 0))
9104 (search-backward ">" end t)
9107 (search-backward "<" end t)
9109 ;; Get the references from the in-reply-to header if there
9110 ;; were no references and the in-reply-to header looks
9112 (if (and (search-forward "\nin-reply-to: " nil t)
9113 (setq in-reply-to (gnus-header-value))
9114 (string-match "<[^>]+>" in-reply-to))
9115 (setq ref (substring in-reply-to (match-beginning 0)
9123 (if (search-forward "\nlines: " nil t)
9124 (if (numberp (setq lines (read cur)))
9130 (and (search-forward "\nxref: " nil t)
9131 (gnus-header-value)))))
9132 ;; We do the threading while we read the headers. The
9133 ;; message-id and the last reference are both entered into
9134 ;; the same hash table. Some tippy-toeing around has to be
9135 ;; done in case an article has arrived before the article
9136 ;; which it refers to.
9137 (if (boundp (setq id-dep (intern id dependencies)))
9138 (if (and (car (symbol-value id-dep))
9140 ;; An article with this Message-ID has already
9141 ;; been seen, so we ignore this one, except we add
9142 ;; any additional Xrefs (in case the two articles
9143 ;; came from different servers).
9145 (mail-header-set-xref
9146 (car (symbol-value id-dep))
9147 (concat (or (mail-header-xref
9148 (car (symbol-value id-dep))) "")
9149 (or (mail-header-xref header) "")))
9151 (setcar (symbol-value id-dep) header))
9152 (set id-dep (list header)))
9154 (if (boundp (setq ref-dep (intern ref dependencies)))
9155 (setcdr (symbol-value ref-dep)
9156 (nconc (cdr (symbol-value ref-dep))
9157 (list (symbol-value id-dep))))
9158 (set ref-dep (list nil (symbol-value id-dep))))
9159 (setq headers (cons header headers)))
9160 (goto-char (point-max))
9162 (nreverse headers)))))
9164 ;; The following macros and functions were written by Felix Lee
9165 ;; <flee@cse.psu.edu>.
9167 (defmacro gnus-nov-read-integer ()
9169 (if (= (following-char) ?\t)
9171 (let ((num (condition-case nil (read buffer) (error nil))))
9172 (if (numberp num) num 0)))
9173 (or (eobp) (forward-char 1))))
9175 (defmacro gnus-nov-skip-field ()
9176 '(search-forward "\t" eol 'move))
9178 (defmacro gnus-nov-field ()
9179 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9181 ;; Goes through the xover lines and returns a list of vectors
9182 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9183 force-new dependencies)
9184 "Parse the news overview data in the server buffer, and return a
9185 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9186 ;; Get the Xref when the users reads the articles since most/some
9187 ;; NNTP servers do not include Xrefs when using XOVER.
9188 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9189 (let ((cur nntp-server-buffer)
9190 (dependencies (or dependencies gnus-newsgroup-dependencies))
9191 number headers header)
9193 (set-buffer nntp-server-buffer)
9194 ;; Allow the user to mangle the headers before parsing them.
9195 (run-hooks 'gnus-parse-headers-hook)
9196 (goto-char (point-min))
9197 (while (and sequence (not (eobp)))
9198 (setq number (read cur))
9199 (while (and sequence (< (car sequence) number))
9200 (setq sequence (cdr sequence)))
9202 (eq number (car sequence))
9204 (setq sequence (cdr sequence))
9206 (inline (gnus-nov-parse-line
9207 number dependencies force-new)))
9208 (setq headers (cons header headers)))))
9210 (setq headers (nreverse headers)))
9213 ;; This function has to be called with point after the article number
9214 ;; on the beginning of the line.
9215 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9217 (eol (gnus-point-at-eol))
9218 (buffer (current-buffer))
9219 header ref id id-dep ref-dep)
9221 ;; overview: [num subject from date id refs chars lines misc]
9222 (narrow-to-region (point) eol)
9223 (or (eobp) (forward-char))
9229 (gnus-nov-field) ; subject
9230 (gnus-nov-field) ; from
9231 (gnus-nov-field) ; date
9232 (setq id (or (gnus-nov-field)
9235 (setq none (1+ none)))))) ; id
9238 (let ((beg (point)))
9239 (search-forward "\t" eol)
9240 (if (search-backward ">" beg t)
9244 (search-backward "<" beg t)))
9246 (gnus-nov-field)) ; refs
9247 (gnus-nov-read-integer) ; chars
9248 (gnus-nov-read-integer) ; lines
9249 (if (= (following-char) ?\n)
9251 (gnus-nov-field)) ; misc
9254 (gnus-error 4 "Strange nov line")
9260 ;; We build the thread tree.
9262 (if (boundp (setq id-dep (intern id dependencies)))
9263 (if (and (car (symbol-value id-dep))
9265 ;; An article with this Message-ID has already been seen,
9266 ;; so we ignore this one, except we add any additional
9267 ;; Xrefs (in case the two articles came from different
9270 (mail-header-set-xref
9271 (car (symbol-value id-dep))
9272 (concat (or (mail-header-xref
9273 (car (symbol-value id-dep))) "")
9274 (or (mail-header-xref header) "")))
9276 (setcar (symbol-value id-dep) header))
9277 (set id-dep (list header))))
9280 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9281 (setcdr (symbol-value ref-dep)
9282 (nconc (cdr (symbol-value ref-dep))
9283 (list (symbol-value id-dep))))
9284 (set ref-dep (list nil (symbol-value id-dep))))))
9287 (defun gnus-article-get-xrefs ()
9288 "Fill in the Xref value in `gnus-current-headers', if necessary.
9289 This is meant to be called in `gnus-article-internal-prepare-hook'."
9290 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9291 gnus-current-headers)))
9292 (or (not gnus-use-cross-reference)
9294 (and (mail-header-xref headers)
9295 (not (string= (mail-header-xref headers) "")))
9296 (let ((case-fold-search t)
9299 (nnheader-narrow-to-headers)
9300 (goto-char (point-min))
9301 (if (or (and (eq (downcase (following-char)) ?x)
9302 (looking-at "Xref:"))
9303 (search-forward "\nXref:" nil t))
9305 (goto-char (1+ (match-end 0)))
9306 (setq xref (buffer-substring (point)
9307 (progn (end-of-line) (point))))
9308 (mail-header-set-xref headers xref))))))))
9310 (defun gnus-summary-insert-subject (id &optional old-header)
9311 "Find article ID and insert the summary line for that article."
9312 (let ((header (gnus-read-header id))
9313 (number (and (numberp id) id))
9316 ;; Rebuild the thread that this article is part of and go to the
9317 ;; article we have fetched.
9319 (when (setq pos (text-property-any
9320 (point-min) (point-max) 'gnus-number
9321 (mail-header-number old-header)))
9324 (gnus-data-remove (mail-header-number old-header))))
9325 (gnus-rebuild-thread (mail-header-id header))
9326 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9327 (when (and (numberp number)
9329 ;; We have to update the boundaries even if we can't fetch the
9330 ;; article if ID is a number -- so that the next `P' or `N'
9331 ;; command will fetch the previous (or next) article even
9332 ;; if the one we tried to fetch this time has been canceled.
9333 (and (> number gnus-newsgroup-end)
9334 (setq gnus-newsgroup-end number))
9335 (and (< number gnus-newsgroup-begin)
9336 (setq gnus-newsgroup-begin number))
9337 (setq gnus-newsgroup-unselected
9338 (delq number gnus-newsgroup-unselected)))
9339 ;; Report back a success?
9340 (and header (mail-header-number header))))
9342 (defun gnus-summary-work-articles (n)
9343 "Return a list of articles to be worked upon. The prefix argument,
9344 the list of process marked articles, and the current article will be
9345 taken into consideration."
9347 ((and n (numberp n))
9348 ;; A numerical prefix has been given.
9349 (let ((backward (< n 0))
9355 (push (setq article (gnus-summary-article-number))
9358 (gnus-summary-find-prev nil article)
9359 (gnus-summary-find-next nil article)))
9361 (nreverse articles)))
9362 ((and (boundp 'transient-mark-mode)
9365 ;; Work on the region between point and mark.
9366 (let ((max (max (point) (mark)))
9369 (goto-char (min (point) (mark)))
9372 (push (setq article (gnus-summary-article-number)) articles)
9373 (gnus-summary-find-next nil article)
9375 (nreverse articles))))
9376 (gnus-newsgroup-processable
9377 ;; There are process-marked articles present.
9378 (reverse gnus-newsgroup-processable))
9380 ;; Just return the current article.
9381 (list (gnus-summary-article-number)))))
9383 (defun gnus-summary-search-group (&optional backward use-level)
9384 "Search for next unread newsgroup.
9385 If optional argument BACKWARD is non-nil, search backward instead."
9387 (set-buffer gnus-group-buffer)
9388 (if (gnus-group-search-forward
9389 backward nil (if use-level (gnus-group-group-level) nil))
9390 (gnus-group-group-name))))
9392 (defun gnus-summary-best-group (&optional exclude-group)
9393 "Find the name of the best unread group.
9394 If EXCLUDE-GROUP, do not go to this group."
9396 (set-buffer gnus-group-buffer)
9398 (gnus-group-best-unread-group exclude-group))))
9400 (defun gnus-summary-find-next (&optional unread article backward)
9401 (if backward (gnus-summary-find-prev)
9402 (let* ((dummy (gnus-summary-article-intangible-p))
9403 (article (or article (gnus-summary-article-number)))
9404 (arts (gnus-data-find-list article))
9406 (when (and (not dummy)
9407 (or (not gnus-summary-check-current)
9409 (not (gnus-data-unread-p (car arts)))))
9410 (setq arts (cdr arts)))
9415 (when (gnus-data-unread-p (car arts))
9416 (setq result (car arts)
9418 (setq arts (cdr arts)))
9421 (goto-char (gnus-data-pos result))
9422 (gnus-data-number result)))))
9424 (defun gnus-summary-find-prev (&optional unread article)
9425 (let* ((article (or article (gnus-summary-article-number)))
9426 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9428 (when (or (not gnus-summary-check-current)
9430 (not (gnus-data-unread-p (car arts))))
9431 (setq arts (cdr arts)))
9436 (and (gnus-data-unread-p (car arts))
9437 (setq result (car arts)
9439 (setq arts (cdr arts)))
9443 (goto-char (gnus-data-pos result))
9444 (gnus-data-number result)))))
9446 (defun gnus-summary-find-subject (subject &optional unread backward article)
9447 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9448 (article (or article (gnus-summary-article-number)))
9449 (articles (gnus-data-list backward))
9450 (arts (gnus-data-find-list article articles))
9452 (when (or (not gnus-summary-check-current)
9454 (not (gnus-data-unread-p (car arts))))
9455 (setq arts (cdr arts)))
9457 (and (or (not unread)
9458 (gnus-data-unread-p (car arts)))
9459 (vectorp (gnus-data-header (car arts)))
9461 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9462 (setq result (car arts)
9464 (setq arts (cdr arts)))
9466 (goto-char (gnus-data-pos result))
9467 (gnus-data-number result))))
9469 (defun gnus-summary-search-forward (&optional unread subject backward)
9470 "Search forward for an article.
9471 If UNREAD, look for unread articles. If SUBJECT, look for
9472 articles with that subject. If BACKWARD, search backward instead."
9473 (cond (subject (gnus-summary-find-subject subject unread backward))
9474 (backward (gnus-summary-find-prev unread))
9475 (t (gnus-summary-find-next unread))))
9477 (defun gnus-recenter (&optional n)
9478 "Center point in window and redisplay frame.
9479 Also do horizontal recentering."
9481 (when (and gnus-auto-center-summary
9482 (not (eq gnus-auto-center-summary 'vertical)))
9483 (gnus-horizontal-recenter))
9486 (defun gnus-summary-recenter ()
9487 "Center point in the summary window.
9488 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9489 displayed, no centering will be performed."
9490 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9491 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9492 (let* ((top (cond ((< (window-height) 4) 0)
9493 ((< (window-height) 7) 1)
9495 (height (1- (window-height)))
9496 (bottom (save-excursion (goto-char (point-max))
9497 (forward-line (- height))
9499 (window (get-buffer-window (current-buffer))))
9500 ;; The user has to want it.
9501 (when gnus-auto-center-summary
9502 (when (get-buffer-window gnus-article-buffer)
9503 ;; Only do recentering when the article buffer is displayed,
9504 ;; Set the window start to either `bottom', which is the biggest
9505 ;; possible valid number, or the second line from the top,
9506 ;; whichever is the least.
9508 window (min bottom (save-excursion
9509 (forward-line (- top)) (point)))))
9510 ;; Do horizontal recentering while we're at it.
9511 (when (and (get-buffer-window (current-buffer) t)
9512 (not (eq gnus-auto-center-summary 'vertical)))
9513 (let ((selected (selected-window)))
9514 (select-window (get-buffer-window (current-buffer) t))
9515 (gnus-summary-position-point)
9516 (gnus-horizontal-recenter)
9517 (select-window selected))))))
9519 (defun gnus-horizontal-recenter ()
9520 "Recenter the current buffer horizontally."
9521 (if (< (current-column) (/ (window-width) 2))
9522 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9523 (let* ((orig (point))
9524 (end (window-end (get-buffer-window (current-buffer) t)))
9526 ;; Find the longest line currently displayed in the window.
9527 (goto-char (window-start))
9528 (while (and (not (eobp))
9531 (setq max (max max (current-column)))
9534 ;; Scroll horizontally to center (sort of) the point.
9535 (if (> max (window-width))
9537 (get-buffer-window (current-buffer) t)
9538 (min (- (current-column) (/ (window-width) 3))
9539 (+ 2 (- max (window-width)))))
9540 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9543 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9544 (defun gnus-short-group-name (group &optional levels)
9545 "Collapse GROUP name LEVELS."
9552 (while (string-match "\\." group skip)
9553 (setq skip (match-end 0)
9556 (if (string-match ":" group)
9557 (setq foreign (substring group 0 (match-end 0))
9558 group (substring group (match-end 0))))
9560 (if (and (string-match "\\." group)
9561 (> levels (- gnus-group-uncollapsed-levels 1)))
9562 (setq name (concat name (substring group 0 1))
9563 group (substring group (match-end 0))
9565 name (concat name "."))
9566 (setq name (concat foreign name group)
9570 (defun gnus-summary-jump-to-group (newsgroup)
9571 "Move point to NEWSGROUP in group mode buffer."
9572 ;; Keep update point of group mode buffer if visible.
9573 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9574 (save-window-excursion
9575 ;; Take care of tree window mode.
9576 (if (get-buffer-window gnus-group-buffer)
9577 (pop-to-buffer gnus-group-buffer))
9578 (gnus-group-jump-to-group newsgroup))
9580 ;; Take care of tree window mode.
9581 (if (get-buffer-window gnus-group-buffer)
9582 (pop-to-buffer gnus-group-buffer)
9583 (set-buffer gnus-group-buffer))
9584 (gnus-group-jump-to-group newsgroup))))
9586 ;; This function returns a list of article numbers based on the
9587 ;; difference between the ranges of read articles in this group and
9588 ;; the range of active articles.
9589 (defun gnus-list-of-unread-articles (group)
9590 (let* ((read (gnus-info-read (gnus-get-info group)))
9591 (active (gnus-active group))
9594 ;; If none are read, then all are unread.
9596 (setq first (car active))
9597 ;; If the range of read articles is a single range, then the
9598 ;; first unread article is the article after the last read
9599 ;; article. Sounds logical, doesn't it?
9600 (if (not (listp (cdr read)))
9601 (setq first (1+ (cdr read)))
9602 ;; `read' is a list of ranges.
9603 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9608 (while (< first nlast)
9609 (setq unread (cons first unread))
9610 (setq first (1+ first))))
9611 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9612 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9613 (setq read (cdr read)))))
9614 ;; And add the last unread articles.
9615 (while (<= first last)
9616 (setq unread (cons first unread))
9617 (setq first (1+ first)))
9618 ;; Return the list of unread articles.
9621 (defun gnus-list-of-read-articles (group)
9622 "Return a list of unread, unticked and non-dormant articles."
9623 (let* ((info (gnus-get-info group))
9624 (marked (gnus-info-marks info))
9625 (active (gnus-active group)))
9627 (gnus-set-difference
9628 (gnus-sorted-complement
9629 (gnus-uncompress-range active)
9630 (gnus-list-of-unread-articles group))
9632 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9633 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9635 ;; Various summary commands
9637 (defun gnus-summary-universal-argument (arg)
9638 "Perform any operation on all articles that are process/prefixed."
9640 (gnus-set-global-variables)
9641 (let ((articles (gnus-summary-work-articles arg))
9648 (substitute-command-keys
9649 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9652 (gnus-error 1 "Undefined key")
9655 (gnus-summary-goto-subject (setq article (pop articles)))
9656 (command-execute func)
9657 (gnus-summary-remove-process-mark article)))))
9658 (gnus-summary-position-point))
9660 (defun gnus-summary-toggle-truncation (&optional arg)
9661 "Toggle truncation of summary lines.
9662 With arg, turn line truncation on iff arg is positive."
9664 (setq truncate-lines
9665 (if (null arg) (not truncate-lines)
9666 (> (prefix-numeric-value arg) 0)))
9669 (defun gnus-summary-reselect-current-group (&optional all rescan)
9670 "Exit and then reselect the current newsgroup.
9671 The prefix argument ALL means to select all articles."
9673 (gnus-set-global-variables)
9674 (let ((current-subject (gnus-summary-article-number))
9675 (group gnus-newsgroup-name))
9676 (setq gnus-newsgroup-begin nil)
9678 ;; We have to adjust the point of group mode buffer because the
9679 ;; current point was moved to the next unread newsgroup by
9681 (gnus-summary-jump-to-group group)
9684 (gnus-group-get-new-news-this-group 1)))
9685 (gnus-group-read-group all t)
9686 (gnus-summary-goto-subject current-subject)))
9688 (defun gnus-summary-rescan-group (&optional all)
9689 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9691 (gnus-summary-reselect-current-group all t))
9693 (defun gnus-summary-update-info ()
9694 (let* ((group gnus-newsgroup-name))
9695 (when gnus-newsgroup-kill-headers
9696 (setq gnus-newsgroup-killed
9697 (gnus-compress-sequence
9699 (gnus-set-sorted-intersection
9700 (gnus-uncompress-range gnus-newsgroup-killed)
9701 (setq gnus-newsgroup-unselected
9702 (sort gnus-newsgroup-unselected '<)))
9703 (setq gnus-newsgroup-unreads
9704 (sort gnus-newsgroup-unreads '<))) t)))
9705 (unless (listp (cdr gnus-newsgroup-killed))
9706 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9707 (let ((headers gnus-newsgroup-headers))
9708 (run-hooks 'gnus-exit-group-hook)
9709 (unless gnus-save-score
9710 (setq gnus-newsgroup-scored nil))
9711 ;; Set the new ranges of read articles.
9712 (gnus-update-read-articles
9713 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9714 ;; Set the current article marks.
9716 ;; Do the cross-ref thing.
9717 (when gnus-use-cross-reference
9718 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9719 ;; Do adaptive scoring, and possibly save score files.
9720 (when gnus-newsgroup-adaptive
9721 (gnus-score-adaptive))
9722 (when gnus-use-scoring
9724 ;; Do not switch windows but change the buffer to work.
9725 (set-buffer gnus-group-buffer)
9726 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9727 (gnus-group-update-group group)))))
9729 (defun gnus-summary-exit (&optional temporary)
9730 "Exit reading current newsgroup, and then return to group selection mode.
9731 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9733 (gnus-set-global-variables)
9734 (gnus-kill-save-kill-buffer)
9735 (let* ((group gnus-newsgroup-name)
9736 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9738 (buf (current-buffer)))
9739 (run-hooks 'gnus-summary-prepare-exit-hook)
9740 ;; If we have several article buffers, we kill them at exit.
9741 (unless gnus-single-article-buffer
9742 (gnus-kill-buffer gnus-article-buffer)
9743 (gnus-kill-buffer gnus-original-article-buffer)
9744 (setq gnus-article-current nil))
9745 (when gnus-use-cache
9746 (gnus-cache-possibly-remove-articles)
9747 (gnus-cache-save-buffers))
9748 (when gnus-use-trees
9749 (gnus-tree-close group))
9750 ;; Make all changes in this group permanent.
9752 (gnus-summary-update-info))
9753 (gnus-close-group group)
9754 ;; Make sure where I was, and go to next newsgroup.
9755 (set-buffer gnus-group-buffer)
9757 (gnus-group-jump-to-group group)
9758 (gnus-group-next-unread-group 1))
9759 (run-hooks 'gnus-summary-exit-hook)
9760 (unless gnus-single-article-buffer
9761 (setq gnus-article-current nil))
9764 ;; If we have several article buffers, we kill them at exit.
9765 (unless gnus-single-article-buffer
9766 (gnus-kill-buffer gnus-article-buffer)
9767 (gnus-kill-buffer gnus-original-article-buffer)
9768 (setq gnus-article-current nil))
9770 (if (not gnus-kill-summary-on-exit)
9771 (gnus-deaden-summary)
9772 ;; We set all buffer-local variables to nil. It is unclear why
9773 ;; this is needed, but if we don't, buffer-local variables are
9774 ;; not garbage-collected, it seems. This would the lead to en
9775 ;; ever-growing Emacs.
9776 (gnus-summary-clear-local-variables)
9777 (when (get-buffer gnus-article-buffer)
9778 (bury-buffer gnus-article-buffer))
9779 ;; We clear the global counterparts of the buffer-local
9780 ;; variables as well, just to be on the safe side.
9781 (gnus-configure-windows 'group 'force)
9782 (gnus-summary-clear-local-variables)
9783 ;; Return to group mode buffer.
9784 (if (eq mode 'gnus-summary-mode)
9785 (gnus-kill-buffer buf)))
9786 (setq gnus-current-select-method gnus-select-method)
9787 (pop-to-buffer gnus-group-buffer)
9788 ;; Clear the current group name.
9789 (if (not quit-config)
9791 (gnus-group-jump-to-group group)
9792 (gnus-group-next-unread-group 1)
9793 (gnus-configure-windows 'group 'force))
9794 (if (not (buffer-name (car quit-config)))
9795 (gnus-configure-windows 'group 'force)
9796 (set-buffer (car quit-config))
9797 (and (eq major-mode 'gnus-summary-mode)
9798 (gnus-set-global-variables))
9799 (gnus-configure-windows (cdr quit-config))))
9801 (setq gnus-newsgroup-name nil)))))
9803 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9804 (defun gnus-summary-exit-no-update (&optional no-questions)
9805 "Quit reading current newsgroup without updating read article info."
9807 (gnus-set-global-variables)
9808 (let* ((group gnus-newsgroup-name)
9809 (quit-config (gnus-group-quit-config group)))
9810 (when (or no-questions
9812 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9813 ;; If we have several article buffers, we kill them at exit.
9814 (unless gnus-single-article-buffer
9815 (gnus-kill-buffer gnus-article-buffer)
9816 (gnus-kill-buffer gnus-original-article-buffer)
9817 (setq gnus-article-current nil))
9818 (if (not gnus-kill-summary-on-exit)
9819 (gnus-deaden-summary)
9820 (gnus-close-group group)
9821 (gnus-summary-clear-local-variables)
9822 (set-buffer gnus-group-buffer)
9823 (gnus-summary-clear-local-variables)
9824 (when (get-buffer gnus-summary-buffer)
9825 (kill-buffer gnus-summary-buffer)))
9826 (unless gnus-single-article-buffer
9827 (setq gnus-article-current nil))
9828 (when gnus-use-trees
9829 (gnus-tree-close group))
9830 (when (get-buffer gnus-article-buffer)
9831 (bury-buffer gnus-article-buffer))
9832 ;; Return to the group buffer.
9833 (gnus-configure-windows 'group 'force)
9834 ;; Clear the current group name.
9835 (setq gnus-newsgroup-name nil)
9836 (when (equal (gnus-group-group-name) group)
9837 (gnus-group-next-unread-group 1))
9839 (if (not (buffer-name (car quit-config)))
9840 (gnus-configure-windows 'group 'force)
9841 (set-buffer (car quit-config))
9842 (when (eq major-mode 'gnus-summary-mode)
9843 (gnus-set-global-variables))
9844 (gnus-configure-windows (cdr quit-config)))))))
9848 (defvar gnus-dead-summary-mode-map nil)
9850 (if gnus-dead-summary-mode-map
9852 (setq gnus-dead-summary-mode-map (make-keymap))
9853 (suppress-keymap gnus-dead-summary-mode-map)
9854 (substitute-key-definition
9855 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9856 (let ((keys '("\C-d" "\r" "\177")))
9858 (define-key gnus-dead-summary-mode-map
9859 (pop keys) 'gnus-summary-wake-up-the-dead))))
9861 (defvar gnus-dead-summary-mode nil
9862 "Minor mode for Gnus summary buffers.")
9864 (defun gnus-dead-summary-mode (&optional arg)
9865 "Minor mode for Gnus summary buffers."
9867 (when (eq major-mode 'gnus-summary-mode)
9868 (make-local-variable 'gnus-dead-summary-mode)
9869 (setq gnus-dead-summary-mode
9870 (if (null arg) (not gnus-dead-summary-mode)
9871 (> (prefix-numeric-value arg) 0)))
9872 (when gnus-dead-summary-mode
9873 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9874 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9875 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9876 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9877 minor-mode-map-alist)))))
9879 (defun gnus-deaden-summary ()
9880 "Make the current summary buffer into a dead summary buffer."
9881 ;; Kill any previous dead summary buffer.
9882 (when (and gnus-dead-summary
9883 (buffer-name gnus-dead-summary))
9885 (set-buffer gnus-dead-summary)
9886 (when gnus-dead-summary-mode
9887 (kill-buffer (current-buffer)))))
9888 ;; Make this the current dead summary.
9889 (setq gnus-dead-summary (current-buffer))
9890 (gnus-dead-summary-mode 1)
9891 (let ((name (buffer-name)))
9892 (when (string-match "Summary" name)
9894 (concat (substring name 0 (match-beginning 0)) "Dead "
9895 (substring name (match-beginning 0))) t))))
9897 (defun gnus-kill-or-deaden-summary (buffer)
9898 "Kill or deaden the summary BUFFER."
9899 (cond (gnus-kill-summary-on-exit
9900 (when (and gnus-use-trees
9901 (and (get-buffer buffer)
9902 (buffer-name (get-buffer buffer))))
9904 (set-buffer (get-buffer buffer))
9905 (gnus-tree-close gnus-newsgroup-name)))
9906 (gnus-kill-buffer buffer))
9907 ((and (get-buffer buffer)
9908 (buffer-name (get-buffer buffer)))
9911 (gnus-deaden-summary)))))
9913 (defun gnus-summary-wake-up-the-dead (&rest args)
9914 "Wake up the dead summary buffer."
9916 (gnus-dead-summary-mode -1)
9917 (let ((name (buffer-name)))
9918 (when (string-match "Dead " name)
9920 (concat (substring name 0 (match-beginning 0))
9921 (substring name (match-end 0))) t)))
9922 (gnus-message 3 "This dead summary is now alive again"))
9924 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9925 (defun gnus-summary-fetch-faq (&optional faq-dir)
9926 "Fetch the FAQ for the current group.
9927 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9931 (if current-prefix-arg
9933 "Faq dir: " (and (listp gnus-group-faq-directory)
9934 gnus-group-faq-directory)))))
9935 (let (gnus-faq-buffer)
9936 (and (setq gnus-faq-buffer
9937 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9938 (gnus-configure-windows 'summary-faq))))
9940 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9941 (defun gnus-summary-describe-group (&optional force)
9942 "Describe the current newsgroup."
9944 (gnus-group-describe-group force gnus-newsgroup-name))
9946 (defun gnus-summary-describe-briefly ()
9947 "Describe summary mode commands briefly."
9950 (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")))
9952 ;; Walking around group mode buffer from summary mode.
9954 (defun gnus-summary-next-group (&optional no-article target-group backward)
9955 "Exit current newsgroup and then select next unread newsgroup.
9956 If prefix argument NO-ARTICLE is non-nil, no article is selected
9957 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9958 previous group instead."
9960 (gnus-set-global-variables)
9961 (let ((current-group gnus-newsgroup-name)
9962 (current-buffer (current-buffer))
9964 ;; First we semi-exit this group to update Xrefs and all variables.
9965 ;; We can't do a real exit, because the window conf must remain
9966 ;; the same in case the user is prompted for info, and we don't
9967 ;; want the window conf to change before that...
9968 (gnus-summary-exit t)
9969 (while (not entered)
9970 ;; Then we find what group we are supposed to enter.
9971 (set-buffer gnus-group-buffer)
9972 (gnus-group-jump-to-group current-group)
9975 (if (eq gnus-keep-same-level 'best)
9976 (gnus-summary-best-group gnus-newsgroup-name)
9977 (gnus-summary-search-group backward gnus-keep-same-level))))
9978 (if (not target-group)
9979 ;; There are no further groups, so we return to the group
9982 (gnus-message 5 "Returning to the group buffer")
9984 (set-buffer current-buffer)
9985 (gnus-summary-exit))
9986 ;; We try to enter the target group.
9987 (gnus-group-jump-to-group target-group)
9988 (let ((unreads (gnus-group-group-unread)))
9989 (if (and (or (eq t unreads)
9990 (and unreads (not (zerop unreads))))
9991 (gnus-summary-read-group
9992 target-group nil no-article current-buffer))
9994 (setq current-group target-group
9995 target-group nil)))))))
9997 (defun gnus-summary-prev-group (&optional no-article)
9998 "Exit current newsgroup and then select previous unread newsgroup.
9999 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10001 (gnus-summary-next-group no-article nil t))
10003 ;; Walking around summary lines.
10005 (defun gnus-summary-first-subject (&optional unread)
10006 "Go to the first unread subject.
10007 If UNREAD is non-nil, go to the first unread article.
10008 Returns the article selected or nil if there are no unread articles."
10013 ((null gnus-newsgroup-data)
10014 (gnus-message 3 "No articles in the group")
10016 ;; Pick the first article.
10018 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10019 (gnus-data-number (car gnus-newsgroup-data)))
10020 ;; No unread articles.
10021 ((null gnus-newsgroup-unreads)
10022 (gnus-message 3 "No more unread articles")
10024 ;; Find the first unread article.
10026 (let ((data gnus-newsgroup-data))
10028 (not (gnus-data-unread-p (car data))))
10029 (setq data (cdr data)))
10032 (goto-char (gnus-data-pos (car data)))
10033 (gnus-data-number (car data)))))))
10034 (gnus-summary-position-point)))
10036 (defun gnus-summary-next-subject (n &optional unread dont-display)
10037 "Go to next N'th summary line.
10038 If N is negative, go to the previous N'th subject line.
10039 If UNREAD is non-nil, only unread articles are selected.
10040 The difference between N and the actual number of steps taken is
10043 (let ((backward (< n 0))
10045 (while (and (> n 0)
10047 (gnus-summary-find-prev unread)
10048 (gnus-summary-find-next unread)))
10050 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10051 (if unread " unread" "")))
10052 (unless dont-display
10053 (gnus-summary-recenter)
10054 (gnus-summary-position-point))
10057 (defun gnus-summary-next-unread-subject (n)
10058 "Go to next N'th unread summary line."
10060 (gnus-summary-next-subject n t))
10062 (defun gnus-summary-prev-subject (n &optional unread)
10063 "Go to previous N'th summary line.
10064 If optional argument UNREAD is non-nil, only unread article is selected."
10066 (gnus-summary-next-subject (- n) unread))
10068 (defun gnus-summary-prev-unread-subject (n)
10069 "Go to previous N'th unread summary line."
10071 (gnus-summary-next-subject (- n) t))
10073 (defun gnus-summary-goto-subject (article &optional force silent)
10074 "Go the subject line of ARTICLE.
10075 If FORCE, also allow jumping to articles not currently shown."
10077 (data (gnus-data-find article)))
10078 ;; We read in the article if we have to.
10081 (gnus-summary-insert-subject article)
10082 (setq data (gnus-data-find article)))
10087 (gnus-message 3 "Can't find article %d" article))
10089 (goto-char (gnus-data-pos data))
10092 ;; Walking around summary lines with displaying articles.
10094 (defun gnus-summary-expand-window (&optional arg)
10095 "Make the summary buffer take up the entire Emacs frame.
10096 Given a prefix, will force an `article' buffer configuration."
10098 (gnus-set-global-variables)
10100 (gnus-configure-windows 'article 'force)
10101 (gnus-configure-windows 'summary 'force)))
10103 (defun gnus-summary-display-article (article &optional all-header)
10104 "Display ARTICLE in article buffer."
10105 (gnus-set-global-variables)
10109 (if gnus-summary-display-article-function
10110 (funcall gnus-summary-display-article-function article all-header)
10111 (gnus-article-prepare article all-header))
10112 (run-hooks 'gnus-select-article-hook)
10113 (gnus-summary-recenter)
10114 (gnus-summary-goto-subject article)
10115 (when gnus-use-trees
10116 (gnus-possibly-generate-tree article)
10117 (gnus-highlight-selected-tree article))
10118 ;; Successfully display article.
10119 (gnus-article-set-window-start
10120 (cdr (assq article gnus-newsgroup-bookmarks)))
10123 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10124 "Select the current article.
10125 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10126 non-nil, the article will be re-fetched even if it already present in
10127 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10129 (let ((article (or article (gnus-summary-article-number)))
10130 (all-headers (not (not all-headers))) ;Must be T or NIL.
10131 gnus-summary-display-article-function
10134 (gnus-summary-article-pseudo-p article)
10135 (error "This is a pseudo-article."))
10138 (set-buffer gnus-summary-buffer)
10139 (if (or (and gnus-single-article-buffer
10140 (or (null gnus-current-article)
10141 (null gnus-article-current)
10142 (null (get-buffer gnus-article-buffer))
10143 (not (eq article (cdr gnus-article-current)))
10144 (not (equal (car gnus-article-current)
10145 gnus-newsgroup-name))))
10146 (and (not gnus-single-article-buffer)
10147 (or (null gnus-current-article)
10148 (not (eq gnus-current-article article))))
10150 ;; The requested article is different from the current article.
10152 (gnus-summary-display-article article all-headers)
10153 (setq did article))
10154 (if (or all-headers gnus-show-all-headers)
10155 (gnus-article-show-all-headers))
10158 (gnus-article-set-window-start
10159 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10161 (defun gnus-summary-set-current-mark (&optional current-mark)
10162 "Obsolete function."
10165 (defun gnus-summary-next-article (&optional unread subject backward push)
10166 "Select the next article.
10167 If UNREAD, only unread articles are selected.
10168 If SUBJECT, only articles with SUBJECT are selected.
10169 If BACKWARD, the previous article is selected instead of the next."
10171 (gnus-set-global-variables)
10173 ;; Is there such an article?
10174 ((and (gnus-summary-search-forward unread subject backward)
10175 (or (gnus-summary-display-article (gnus-summary-article-number))
10176 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10177 (gnus-summary-position-point))
10178 ;; If not, we try the first unread, if that is wanted.
10180 gnus-auto-select-same
10181 (or (gnus-summary-first-unread-article)
10182 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10183 (gnus-summary-position-point)
10184 (gnus-message 6 "Wrapped"))
10185 ;; Try to get next/previous article not displayed in this group.
10186 ((and gnus-auto-extend-newsgroup
10187 (not unread) (not subject))
10188 (gnus-summary-goto-article
10189 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10191 ;; Go to next/previous group.
10193 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10194 (gnus-summary-jump-to-group gnus-newsgroup-name))
10195 (let ((cmd last-command-char)
10197 (if (eq gnus-keep-same-level 'best)
10198 (gnus-summary-best-group gnus-newsgroup-name)
10199 (gnus-summary-search-group backward gnus-keep-same-level))))
10200 ;; For some reason, the group window gets selected. We change
10202 (select-window (get-buffer-window (current-buffer)))
10203 ;; Select next unread newsgroup automagically.
10205 ((not gnus-auto-select-next)
10206 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10207 ((or (eq gnus-auto-select-next 'quietly)
10208 (and (eq gnus-auto-select-next 'slightly-quietly)
10210 (and (eq gnus-auto-select-next 'almost-quietly)
10211 (gnus-summary-last-article-p)))
10213 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10214 (gnus-summary-exit)
10215 (gnus-message 7 "No more%s articles (%s)..."
10216 (if unread " unread" "")
10217 (if group (concat "selecting " group)
10219 (gnus-summary-next-group nil group backward)))
10221 (gnus-summary-walk-group-buffer
10222 gnus-newsgroup-name cmd unread backward)))))))
10224 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10225 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10226 (?\C-p (gnus-group-prev-unread-group 1))))
10227 keve key group ended)
10229 (set-buffer gnus-group-buffer)
10230 (gnus-summary-jump-to-group from-group)
10232 (if (eq gnus-keep-same-level 'best)
10233 (gnus-summary-best-group gnus-newsgroup-name)
10234 (gnus-summary-search-group backward gnus-keep-same-level))))
10237 5 "No more%s articles%s" (if unread " unread" "")
10239 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10240 (format " (Type %s for %s [%s])"
10241 (single-key-description cmd) group
10242 (car (gnus-gethash group gnus-newsrc-hashtb)))
10243 (format " (Type %s to exit %s)"
10244 (single-key-description cmd)
10245 gnus-newsgroup-name)))
10246 ;; Confirm auto selection.
10247 (setq key (car (setq keve (gnus-read-event-char))))
10250 ((assq key keystrokes)
10251 (let ((obuf (current-buffer)))
10252 (switch-to-buffer gnus-group-buffer)
10254 (gnus-group-jump-to-group group))
10255 (eval (cadr (assq key keystrokes)))
10256 (setq group (gnus-group-group-name))
10257 (switch-to-buffer obuf))
10260 (if (or (not group)
10261 (gnus-ephemeral-group-p gnus-newsgroup-name))
10262 (gnus-summary-exit)
10263 (gnus-summary-next-group nil group backward)))
10265 (push (cdr keve) unread-command-events))))))
10267 (defun gnus-read-event-char ()
10268 "Get the next event."
10269 (let ((event (read-event)))
10270 (cons (and (numberp event) event) event)))
10272 (defun gnus-summary-next-unread-article ()
10273 "Select unread article after current one."
10275 (gnus-summary-next-article t (and gnus-auto-select-same
10276 (gnus-summary-article-subject))))
10278 (defun gnus-summary-prev-article (&optional unread subject)
10279 "Select the article after the current one.
10280 If UNREAD is non-nil, only unread articles are selected."
10282 (gnus-summary-next-article unread subject t))
10284 (defun gnus-summary-prev-unread-article ()
10285 "Select unred article before current one."
10287 (gnus-summary-prev-article t (and gnus-auto-select-same
10288 (gnus-summary-article-subject))))
10290 (defun gnus-summary-next-page (&optional lines circular)
10291 "Show next page of the selected article.
10292 If at the end of the current article, select the next article.
10293 LINES says how many lines should be scrolled up.
10295 If CIRCULAR is non-nil, go to the start of the article instead of
10296 selecting the next article when reaching the end of the current
10299 (setq gnus-summary-buffer (current-buffer))
10300 (gnus-set-global-variables)
10301 (let ((article (gnus-summary-article-number))
10303 (gnus-configure-windows 'article)
10304 (if (or (null gnus-current-article)
10305 (null gnus-article-current)
10306 (/= article (cdr gnus-article-current))
10307 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10308 ;; Selected subject is different from current article's.
10309 (gnus-summary-display-article article)
10310 (gnus-eval-in-buffer-window
10311 gnus-article-buffer
10312 (setq endp (gnus-article-next-page lines)))
10315 (gnus-summary-beginning-of-article))
10317 (gnus-message 3 "End of message"))
10319 (if (and (eq gnus-summary-goto-unread 'never)
10320 (not (gnus-summary-last-article-p article)))
10321 (gnus-summary-next-article)
10322 (gnus-summary-next-unread-article))))))
10323 (gnus-summary-recenter)
10324 (gnus-summary-position-point)))
10326 (defun gnus-summary-prev-page (&optional lines)
10327 "Show previous page of selected article.
10328 Argument LINES specifies lines to be scrolled down."
10330 (gnus-set-global-variables)
10331 (let ((article (gnus-summary-article-number)))
10332 (gnus-configure-windows 'article)
10333 (if (or (null gnus-current-article)
10334 (null gnus-article-current)
10335 (/= article (cdr gnus-article-current))
10336 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10337 ;; Selected subject is different from current article's.
10338 (gnus-summary-display-article article)
10339 (gnus-summary-recenter)
10340 (gnus-eval-in-buffer-window gnus-article-buffer
10341 (gnus-article-prev-page lines))))
10342 (gnus-summary-position-point))
10344 (defun gnus-summary-scroll-up (lines)
10345 "Scroll up (or down) one line current article.
10346 Argument LINES specifies lines to be scrolled up (or down if negative)."
10348 (gnus-set-global-variables)
10349 (gnus-configure-windows 'article)
10350 (gnus-summary-show-thread)
10351 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10352 (gnus-eval-in-buffer-window
10353 gnus-article-buffer
10355 (if (gnus-article-next-page lines)
10356 (gnus-message 3 "End of message")))
10358 (gnus-article-prev-page (- lines))))))
10359 (gnus-summary-recenter)
10360 (gnus-summary-position-point))
10362 (defun gnus-summary-next-same-subject ()
10363 "Select next article which has the same subject as current one."
10365 (gnus-set-global-variables)
10366 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10368 (defun gnus-summary-prev-same-subject ()
10369 "Select previous article which has the same subject as current one."
10371 (gnus-set-global-variables)
10372 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10374 (defun gnus-summary-next-unread-same-subject ()
10375 "Select next unread article which has the same subject as current one."
10377 (gnus-set-global-variables)
10378 (gnus-summary-next-article t (gnus-summary-article-subject)))
10380 (defun gnus-summary-prev-unread-same-subject ()
10381 "Select previous unread article which has the same subject as current one."
10383 (gnus-set-global-variables)
10384 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10386 (defun gnus-summary-first-unread-article ()
10387 "Select the first unread article.
10388 Return nil if there are no unread articles."
10390 (gnus-set-global-variables)
10392 (if (gnus-summary-first-subject t)
10394 (gnus-summary-show-thread)
10395 (gnus-summary-first-subject t)
10396 (gnus-summary-display-article (gnus-summary-article-number))))
10397 (gnus-summary-position-point)))
10399 (defun gnus-summary-best-unread-article ()
10400 "Select the unread article with the highest score."
10402 (gnus-set-global-variables)
10403 (let ((best -1000000)
10404 (data gnus-newsgroup-data)
10407 (and (gnus-data-unread-p (car data))
10409 (gnus-summary-article-score (gnus-data-number (car data))))
10412 article (gnus-data-number (car data))))
10413 (setq data (cdr data)))
10416 (gnus-summary-goto-article article)
10417 (error "No unread articles"))
10418 (gnus-summary-position-point))))
10420 (defun gnus-summary-last-subject ()
10421 "Go to the last displayed subject line in the group."
10422 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10424 (gnus-summary-goto-subject article))))
10426 (defun gnus-summary-goto-article (article &optional all-headers force)
10427 "Fetch ARTICLE and display it if it exists.
10428 If ALL-HEADERS is non-nil, no header lines are hidden."
10434 (mapcar (lambda (number) (list (int-to-string number)))
10435 gnus-newsgroup-limit)))
10439 (if (gnus-summary-goto-subject article force)
10440 (gnus-summary-display-article article all-headers)
10441 (gnus-message 4 "Couldn't go to article %s" article) nil)
10442 (gnus-summary-position-point)))
10444 (defun gnus-summary-goto-last-article ()
10445 "Go to the previously read article."
10448 (and gnus-last-article
10449 (gnus-summary-goto-article gnus-last-article))
10450 (gnus-summary-position-point)))
10452 (defun gnus-summary-pop-article (number)
10453 "Pop one article off the history and go to the previous.
10454 NUMBER articles will be popped off."
10457 (setq gnus-newsgroup-history
10458 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10460 (gnus-summary-goto-article (car to))
10461 (error "Article history empty")))
10462 (gnus-summary-position-point))
10464 ;; Summary commands and functions for limiting the summary buffer.
10466 (defun gnus-summary-limit-to-articles (n)
10467 "Limit the summary buffer to the next N articles.
10468 If not given a prefix, use the process marked articles instead."
10470 (gnus-set-global-variables)
10472 (let ((articles (gnus-summary-work-articles n)))
10473 (setq gnus-newsgroup-processable nil)
10474 (gnus-summary-limit articles))
10475 (gnus-summary-position-point)))
10477 (defun gnus-summary-pop-limit (&optional total)
10478 "Restore the previous limit.
10479 If given a prefix, remove all limits."
10481 (gnus-set-global-variables)
10483 (setq gnus-newsgroup-limits
10484 (list (mapcar (lambda (h) (mail-header-number h))
10485 gnus-newsgroup-headers))))
10486 (unless gnus-newsgroup-limits
10487 (error "No limit to pop"))
10489 (gnus-summary-limit nil 'pop)
10490 (gnus-summary-position-point)))
10492 (defun gnus-summary-limit-to-subject (subject &optional header)
10493 "Limit the summary buffer to articles that have subjects that match a regexp."
10494 (interactive "sRegexp: ")
10496 (setq header "subject"))
10497 (when (not (equal "" subject))
10499 (let ((articles (gnus-summary-find-matching
10500 (or header "subject") subject 'all)))
10501 (or articles (error "Found no matches for \"%s\"" subject))
10502 (gnus-summary-limit articles))
10503 (gnus-summary-position-point))))
10505 (defun gnus-summary-limit-to-author (from)
10506 "Limit the summary buffer to articles that have authors that match a regexp."
10507 (interactive "sRegexp: ")
10508 (gnus-summary-limit-to-subject from "from"))
10510 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10512 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10514 (defun gnus-summary-limit-to-unread (&optional all)
10515 "Limit the summary buffer to articles that are not marked as read.
10516 If ALL is non-nil, limit strictly to unread articles."
10519 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10520 (gnus-summary-limit-to-marks
10521 ;; Concat all the marks that say that an article is read and have
10523 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10524 gnus-killed-mark gnus-kill-file-mark
10525 gnus-low-score-mark gnus-expirable-mark
10526 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10529 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10530 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10532 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10533 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10534 If REVERSE, limit the summary buffer to articles that are not marked
10535 with MARKS. MARKS can either be a string of marks or a list of marks.
10536 Returns how many articles were removed."
10537 (interactive "sMarks: ")
10538 (gnus-set-global-variables)
10540 (let ((data gnus-newsgroup-data)
10541 (marks (if (listp marks) marks
10542 (append marks nil))) ; Transform to list.
10545 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10546 (memq (gnus-data-mark (car data)) marks))
10547 (setq articles (cons (gnus-data-number (car data)) articles)))
10548 (setq data (cdr data)))
10549 (gnus-summary-limit articles))
10550 (gnus-summary-position-point)))
10552 (defun gnus-summary-limit-to-score (&optional score)
10553 "Limit to articles with score at or above SCORE."
10555 (gnus-set-global-variables)
10556 (setq score (if score
10557 (prefix-numeric-value score)
10558 (or gnus-summary-default-score 0)))
10559 (let ((data gnus-newsgroup-data)
10562 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10564 (push (gnus-data-number (car data)) articles))
10565 (setq data (cdr data)))
10567 (gnus-summary-limit articles)
10568 (gnus-summary-position-point))))
10570 (defun gnus-summary-limit-include-dormant ()
10571 "Display all the hidden articles that are marked as dormant."
10573 (gnus-set-global-variables)
10574 (or gnus-newsgroup-dormant
10575 (error "There are no dormant articles in this group"))
10577 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10578 (gnus-summary-position-point)))
10580 (defun gnus-summary-limit-exclude-dormant ()
10581 "Hide all dormant articles."
10583 (gnus-set-global-variables)
10585 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10586 (gnus-summary-position-point)))
10588 (defun gnus-summary-limit-exclude-childless-dormant ()
10589 "Hide all dormant articles that have no children."
10591 (gnus-set-global-variables)
10592 (let ((data (gnus-data-list t))
10593 articles d children)
10594 ;; Find all articles that are either not dormant or have
10596 (while (setq d (pop data))
10597 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10598 (and (setq children
10599 (gnus-article-children (gnus-data-number d)))
10602 (when (memq (car children) articles)
10607 (push (gnus-data-number d) articles)))
10608 ;; Do the limiting.
10610 (gnus-summary-limit articles)
10611 (gnus-summary-position-point))))
10613 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10614 "Mark all unread excluded articles as read.
10615 If ALL, mark even excluded ticked and dormants as read."
10617 (let ((articles (gnus-sorted-complement
10619 (mapcar (lambda (h) (mail-header-number h))
10620 gnus-newsgroup-headers)
10622 (sort gnus-newsgroup-limit '<)))
10624 (setq gnus-newsgroup-unreads nil)
10626 (setq gnus-newsgroup-dormant nil
10627 gnus-newsgroup-marked nil
10628 gnus-newsgroup-reads
10630 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10631 gnus-newsgroup-reads))
10632 (while (setq article (pop articles))
10633 (unless (or (memq article gnus-newsgroup-dormant)
10634 (memq article gnus-newsgroup-marked))
10635 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10637 (defun gnus-summary-limit (articles &optional pop)
10639 ;; We pop the previous limit off the stack and use that.
10640 (setq articles (car gnus-newsgroup-limits)
10641 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10642 ;; We use the new limit, so we push the old limit on the stack.
10643 (setq gnus-newsgroup-limits
10644 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10646 (setq gnus-newsgroup-limit articles)
10647 (let ((total (length gnus-newsgroup-data))
10648 (data (gnus-data-find-list (gnus-summary-article-number)))
10650 ;; This will do all the work of generating the new summary buffer
10651 ;; according to the new limit.
10652 (gnus-summary-prepare)
10653 ;; Hide any threads, possibly.
10654 (and gnus-show-threads
10655 gnus-thread-hide-subtree
10656 (gnus-summary-hide-all-threads))
10657 ;; Try to return to the article you were at, or one in the
10660 ;; We try to find some article after the current one.
10662 (and (gnus-summary-goto-subject
10663 (gnus-data-number (car data)) nil t)
10666 (setq data (cdr data))))
10668 ;; If there is no data, that means that we were after the last
10669 ;; article. The same goes when we can't find any articles
10670 ;; after the current one.
10672 (goto-char (point-max))
10673 (gnus-summary-find-prev)))
10674 ;; We return how many articles were removed from the summary
10675 ;; buffer as a result of the new limit.
10676 (- total (length gnus-newsgroup-data))))
10678 (defsubst gnus-cut-thread (thread)
10679 "Go forwards in the thread until we find an article that we want to display."
10680 (when (eq gnus-fetch-old-headers 'some)
10681 ;; Deal with old-fetched headers.
10683 (memq (mail-header-number (car thread))
10684 gnus-newsgroup-ancient)
10685 (<= (length (cdr thread)) 1))
10686 (setq thread (cadr thread))))
10687 ;; Deal with sparse threads.
10688 (when (or (eq gnus-build-sparse-threads 'some)
10689 (eq gnus-build-sparse-threads 'more))
10691 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10692 (= (length (cdr thread)) 1))
10693 (setq thread (cadr thread))))
10696 (defun gnus-cut-threads (threads)
10697 "Cut off all uninteresting articles from the beginning of threads."
10698 (when (or (eq gnus-fetch-old-headers 'some)
10699 (eq gnus-build-sparse-threads 'some)
10700 (eq gnus-build-sparse-threads 'more))
10701 (let ((th threads))
10703 (setcar th (gnus-cut-thread (car th)))
10704 (setq th (cdr th)))))
10705 ;; Remove nixed out threads.
10706 (delq nil threads))
10708 (defun gnus-summary-initial-limit (&optional show-if-empty)
10709 "Figure out what the initial limit is supposed to be on group entry.
10710 This entails weeding out unwanted dormants, low-scored articles,
10711 fetch-old-headers verbiage, and so on."
10712 ;; Most groups have nothing to remove.
10713 (if (or gnus-inhibit-limiting
10714 (and (null gnus-newsgroup-dormant)
10715 (not (eq gnus-fetch-old-headers 'some))
10716 (null gnus-summary-expunge-below)
10717 (not (eq gnus-build-sparse-threads 'some))
10718 (not (eq gnus-build-sparse-threads 'more))
10719 (null gnus-thread-expunge-below)
10720 (not gnus-use-nocem)))
10722 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10723 (setq gnus-newsgroup-limit nil)
10726 (unless (car (symbol-value node))
10727 ;; These threads have no parents -- they are roots.
10728 (let ((nodes (cdr (symbol-value node)))
10731 (if (and gnus-thread-expunge-below
10732 (< (gnus-thread-total-score (car nodes))
10733 gnus-thread-expunge-below))
10734 (gnus-expunge-thread (pop nodes))
10735 (setq thread (pop nodes))
10736 (gnus-summary-limit-children thread))))))
10737 gnus-newsgroup-dependencies)
10738 ;; If this limitation resulted in an empty group, we might
10739 ;; pop the previous limit and use it instead.
10740 (when (and (not gnus-newsgroup-limit)
10742 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10743 gnus-newsgroup-limit))
10745 (defun gnus-summary-limit-children (thread)
10746 "Return 1 if this subthread is visible and 0 if it is not."
10747 ;; First we get the number of visible children to this thread. This
10748 ;; is done by recursing down the thread using this function, so this
10749 ;; will really go down to a leaf article first, before slowly
10750 ;; working its way up towards the root.
10754 (apply '+ (mapcar 'gnus-summary-limit-children
10757 (number (mail-header-number (car thread)))
10760 ;; If this article is dormant and has absolutely no visible
10761 ;; children, then this article isn't visible.
10762 (and (memq number gnus-newsgroup-dormant)
10764 ;; If this is a "fetch-old-headered" and there is only one
10765 ;; visible child (or less), then we don't want this article.
10766 (and (eq gnus-fetch-old-headers 'some)
10767 (memq number gnus-newsgroup-ancient)
10769 ;; If this is a sparsely inserted article with no children,
10770 ;; we don't want it.
10771 (and (eq gnus-build-sparse-threads 'some)
10772 (memq number gnus-newsgroup-sparse)
10774 ;; If we use expunging, and this article is really
10775 ;; low-scored, then we don't want this article.
10776 (when (and gnus-summary-expunge-below
10778 (or (cdr (assq number gnus-newsgroup-scored))
10779 gnus-summary-default-score))
10780 gnus-summary-expunge-below))
10781 ;; We increase the expunge-tally here, but that has
10782 ;; nothing to do with the limits, really.
10783 (incf gnus-newsgroup-expunged-tally)
10784 ;; We also mark as read here, if that's wanted.
10785 (when (and gnus-summary-mark-below
10786 (< score gnus-summary-mark-below))
10787 (setq gnus-newsgroup-unreads
10788 (delq number gnus-newsgroup-unreads))
10789 (if gnus-newsgroup-auto-expire
10790 (push number gnus-newsgroup-expirable)
10791 (push (cons number gnus-low-score-mark)
10792 gnus-newsgroup-reads)))
10794 (and gnus-use-nocem
10795 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10796 ;; Nope, invisible article.
10798 ;; Ok, this article is to be visible, so we add it to the limit
10800 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10803 (defun gnus-expunge-thread (thread)
10804 "Mark all articles in THREAD as read."
10805 (let* ((number (mail-header-number (car thread))))
10806 (incf gnus-newsgroup-expunged-tally)
10807 ;; We also mark as read here, if that's wanted.
10808 (setq gnus-newsgroup-unreads
10809 (delq number gnus-newsgroup-unreads))
10810 (if gnus-newsgroup-auto-expire
10811 (push number gnus-newsgroup-expirable)
10812 (push (cons number gnus-low-score-mark)
10813 gnus-newsgroup-reads)))
10814 ;; Go recursively through all subthreads.
10815 (mapcar 'gnus-expunge-thread (cdr thread)))
10817 ;; Summary article oriented commands
10819 (defun gnus-summary-refer-parent-article (n)
10820 "Refer parent article N times.
10821 The difference between N and the number of articles fetched is returned."
10823 (gnus-set-global-variables)
10827 (let* ((header (gnus-summary-article-header))
10829 ;; If we try to find the parent of the currently
10830 ;; displayed article, then we take a look at the actual
10831 ;; References header, since this is slightly more
10832 ;; reliable than the References field we got from the
10834 (if (and (eq (mail-header-number header)
10835 (cdr gnus-article-current))
10836 (equal gnus-newsgroup-name
10837 (car gnus-article-current)))
10839 (set-buffer gnus-original-article-buffer)
10840 (nnheader-narrow-to-headers)
10842 (mail-fetch-field "references")
10844 ;; It's not the current article, so we take a bet on
10845 ;; the value we got from the server.
10846 (mail-header-references header))))
10847 (if (setq ref (or ref (mail-header-references header)))
10848 (or (gnus-summary-refer-article (gnus-parent-id ref))
10849 (gnus-message 1 "Couldn't find parent"))
10850 (gnus-message 1 "No references in article %d"
10851 (gnus-summary-article-number))
10854 (gnus-summary-position-point)
10857 (defun gnus-summary-refer-references ()
10858 "Fetch all articles mentioned in the References header.
10859 Return how many articles were fetched."
10861 (gnus-set-global-variables)
10862 (let ((ref (mail-header-references (gnus-summary-article-header)))
10863 (current (gnus-summary-article-number))
10865 ;; For each Message-ID in the References header...
10866 (while (string-match "<[^>]*>" ref)
10868 ;; ... fetch that article.
10869 (gnus-summary-refer-article
10870 (prog1 (match-string 0 ref)
10871 (setq ref (substring ref (match-end 0))))))
10872 (gnus-summary-goto-subject current)
10873 (gnus-summary-position-point)
10876 (defun gnus-summary-refer-article (message-id)
10877 "Fetch an article specified by MESSAGE-ID."
10878 (interactive "sMessage-ID: ")
10879 (when (and (stringp message-id)
10880 (not (zerop (length message-id))))
10881 ;; Construct the correct Message-ID if necessary.
10882 ;; Suggested by tale@pawl.rpi.edu.
10883 (unless (string-match "^<" message-id)
10884 (setq message-id (concat "<" message-id)))
10885 (unless (string-match ">$" message-id)
10886 (setq message-id (concat message-id ">")))
10887 (let ((header (car (gnus-gethash message-id
10888 gnus-newsgroup-dependencies))))
10890 ;; The article is present in the buffer, to we just go to it.
10891 (gnus-summary-goto-article (mail-header-number header) nil t)
10892 ;; We fetch the article
10893 (let ((gnus-override-method
10894 (and (gnus-news-group-p gnus-newsgroup-name)
10895 gnus-refer-article-method))
10897 ;; Start the special refer-article method, if necessary.
10898 (when gnus-refer-article-method
10899 (gnus-check-server gnus-refer-article-method))
10900 ;; Fetch the header, and display the article.
10901 (if (setq number (gnus-summary-insert-subject message-id))
10902 (gnus-summary-select-article nil nil nil number)
10903 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10905 (defun gnus-summary-enter-digest-group (&optional force)
10906 "Enter a digest group based on the current article."
10908 (gnus-set-global-variables)
10909 (gnus-summary-select-article)
10910 (let ((name (format "%s-%d"
10911 (gnus-group-prefixed-name
10912 gnus-newsgroup-name (list 'nndoc ""))
10913 gnus-current-article))
10914 (ogroup gnus-newsgroup-name)
10915 (case-fold-search t)
10916 (buf (current-buffer))
10919 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10920 (insert-buffer-substring gnus-original-article-buffer)
10922 (goto-char (point-min))
10923 (or (search-forward "\n\n" nil t) (point)))
10924 (goto-char (point-min))
10925 (delete-matching-lines "^\\(Path\\):\\|^From ")
10928 (if (gnus-group-read-ephemeral-group
10929 name `(nndoc ,name (nndoc-address
10931 (nndoc-article-type ,(if force 'digest 'guess))) t)
10932 ;; Make all postings to this group go to the parent group.
10933 (nconc (gnus-info-params (gnus-get-info name))
10934 (list (cons 'to-group ogroup)))
10935 ;; Couldn't select this doc group.
10936 (switch-to-buffer buf)
10937 (gnus-set-global-variables)
10938 (gnus-configure-windows 'summary)
10939 (gnus-message 3 "Article couldn't be entered?"))
10940 (kill-buffer dig))))
10942 (defun gnus-summary-isearch-article (&optional regexp-p)
10943 "Do incremental search forward on the current article.
10944 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10946 (gnus-set-global-variables)
10947 (gnus-summary-select-article)
10948 (gnus-configure-windows 'article)
10949 (gnus-eval-in-buffer-window
10950 gnus-article-buffer
10951 (goto-char (point-min))
10952 (isearch-forward regexp-p)))
10954 (defun gnus-summary-search-article-forward (regexp &optional backward)
10955 "Search for an article containing REGEXP forward.
10956 If BACKWARD, search backward instead."
10959 (format "Search article %s (regexp%s): "
10960 (if current-prefix-arg "backward" "forward")
10961 (if gnus-last-search-regexp
10962 (concat ", default " gnus-last-search-regexp)
10964 current-prefix-arg))
10965 (gnus-set-global-variables)
10966 (if (string-equal regexp "")
10967 (setq regexp (or gnus-last-search-regexp ""))
10968 (setq gnus-last-search-regexp regexp))
10969 (if (gnus-summary-search-article regexp backward)
10970 (gnus-article-set-window-start
10971 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10972 (error "Search failed: \"%s\"" regexp)))
10974 (defun gnus-summary-search-article-backward (regexp)
10975 "Search for an article containing REGEXP backward."
10978 (format "Search article backward (regexp%s): "
10979 (if gnus-last-search-regexp
10980 (concat ", default " gnus-last-search-regexp)
10982 (gnus-summary-search-article-forward regexp 'backward))
10984 (defun gnus-summary-search-article (regexp &optional backward)
10985 "Search for an article containing REGEXP.
10986 Optional argument BACKWARD means do search for backward.
10987 gnus-select-article-hook is not called during the search."
10988 (let ((gnus-select-article-hook nil) ;Disable hook.
10989 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10992 (function re-search-backward) (function re-search-forward)))
10995 ;; Hidden thread subtrees must be searched for ,too.
10996 (gnus-summary-show-all-threads)
10997 ;; First of all, search current article.
10998 ;; We don't want to read article again from NNTP server nor reset
11000 (gnus-summary-select-article)
11001 (gnus-message 9 "Searching article: %d..." gnus-current-article)
11002 (setq last gnus-current-article)
11003 (gnus-eval-in-buffer-window
11004 gnus-article-buffer
11007 ;; Begin search from current point.
11008 (setq found (funcall re-search regexp nil t))))
11009 ;; Then search next articles.
11010 (while (and (not found)
11011 (gnus-summary-display-article
11012 (if backward (gnus-summary-find-prev)
11013 (gnus-summary-find-next))))
11014 (gnus-message 9 "Searching article: %d..." gnus-current-article)
11015 (gnus-eval-in-buffer-window
11016 gnus-article-buffer
11019 (goto-char (if backward (point-max) (point-min)))
11020 (setq found (funcall re-search regexp nil t)))))
11022 ;; Adjust article pointer.
11023 (or (eq last gnus-current-article)
11024 (setq gnus-last-article last))
11025 ;; Return T if found such article.
11028 (defun gnus-summary-find-matching (header regexp &optional backward unread
11030 "Return a list of all articles that match REGEXP on HEADER.
11031 The search stars on the current article and goes forwards unless
11032 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11033 If UNREAD is non-nil, only unread articles will
11034 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11035 in the comparisons."
11036 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11037 (gnus-data-find-list
11038 (gnus-summary-article-number) (gnus-data-list backward))))
11039 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11040 (case-fold-search (not not-case-fold))
11042 (or (fboundp (intern (concat "mail-header-" header)))
11043 (error "%s is not a valid header" header))
11045 (setq d (car data))
11046 (and (or (not unread) ; We want all articles...
11047 (gnus-data-unread-p d)) ; Or just unreads.
11048 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11049 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11050 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11051 (setq data (cdr data)))
11052 (nreverse articles)))
11054 (defun gnus-summary-execute-command (header regexp command &optional backward)
11055 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11056 If HEADER is an empty string (or nil), the match is done on the entire
11057 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11059 (list (let ((completion-ignore-case t))
11062 (mapcar (lambda (string) (list string))
11063 '("Number" "Subject" "From" "Lines" "Date"
11064 "Message-ID" "Xref" "References" "Body"))
11065 nil 'require-match))
11066 (read-string "Regexp: ")
11067 (read-key-sequence "Command: ")
11068 current-prefix-arg))
11069 (when (equal header "Body")
11071 (gnus-set-global-variables)
11072 ;; Hidden thread subtrees must be searched as well.
11073 (gnus-summary-show-all-threads)
11074 ;; We don't want to change current point nor window configuration.
11076 (save-window-excursion
11077 (gnus-message 6 "Executing %s..." (key-description command))
11078 ;; We'd like to execute COMMAND interactively so as to give arguments.
11079 (gnus-execute header regexp
11080 `(lambda () (call-interactively ',(key-binding command)))
11082 (gnus-message 6 "Executing %s...done" (key-description command)))))
11084 (defun gnus-summary-beginning-of-article ()
11085 "Scroll the article back to the beginning."
11087 (gnus-set-global-variables)
11088 (gnus-summary-select-article)
11089 (gnus-configure-windows 'article)
11090 (gnus-eval-in-buffer-window
11091 gnus-article-buffer
11093 (goto-char (point-min))
11094 (and gnus-break-pages (gnus-narrow-to-page))))
11096 (defun gnus-summary-end-of-article ()
11097 "Scroll to the end of the article."
11099 (gnus-set-global-variables)
11100 (gnus-summary-select-article)
11101 (gnus-configure-windows 'article)
11102 (gnus-eval-in-buffer-window
11103 gnus-article-buffer
11105 (goto-char (point-max))
11107 (and gnus-break-pages (gnus-narrow-to-page))))
11109 (defun gnus-summary-show-article (&optional arg)
11110 "Force re-fetching of the current article.
11111 If ARG (the prefix) is non-nil, show the raw article without any
11112 article massaging functions being run."
11114 (gnus-set-global-variables)
11116 ;; Select the article the normal way.
11117 (gnus-summary-select-article nil 'force)
11118 ;; Bind the article treatment functions to nil.
11119 (let ((gnus-have-all-headers t)
11120 gnus-article-display-hook
11121 gnus-article-prepare-hook
11124 (gnus-summary-select-article nil 'force)))
11125 ; (gnus-configure-windows 'article)
11126 (gnus-summary-position-point))
11128 (defun gnus-summary-verbose-headers (&optional arg)
11129 "Toggle permanent full header display.
11130 If ARG is a positive number, turn header display on.
11131 If ARG is a negative number, turn header display off."
11133 (gnus-set-global-variables)
11134 (gnus-summary-toggle-header arg)
11135 (setq gnus-show-all-headers
11136 (cond ((or (not (numberp arg))
11138 (not gnus-show-all-headers))
11142 (defun gnus-summary-toggle-header (&optional arg)
11143 "Show the headers if they are hidden, or hide them if they are shown.
11144 If ARG is a positive number, show the entire header.
11145 If ARG is a negative number, hide the unwanted header lines."
11147 (gnus-set-global-variables)
11149 (set-buffer gnus-article-buffer)
11150 (let* ((buffer-read-only nil)
11151 (inhibit-point-motion-hooks t)
11152 (hidden (text-property-any
11153 (goto-char (point-min)) (search-forward "\n\n")
11156 (goto-char (point-min))
11157 (when (search-forward "\n\n" nil t)
11158 (delete-region (point-min) (1- (point))))
11159 (goto-char (point-min))
11161 (set-buffer gnus-original-article-buffer)
11162 (goto-char (point-min))
11163 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11164 (insert-buffer-substring gnus-original-article-buffer 1 e)
11165 (let ((gnus-inhibit-hiding t))
11166 (run-hooks 'gnus-article-display-hook))
11167 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11168 (gnus-article-hide-headers)))))
11170 (defun gnus-summary-show-all-headers ()
11171 "Make all header lines visible."
11173 (gnus-set-global-variables)
11174 (gnus-article-show-all-headers))
11176 (defun gnus-summary-toggle-mime (&optional arg)
11177 "Toggle MIME processing.
11178 If ARG is a positive number, turn MIME processing on."
11180 (gnus-set-global-variables)
11181 (setq gnus-show-mime
11182 (if (null arg) (not gnus-show-mime)
11183 (> (prefix-numeric-value arg) 0)))
11184 (gnus-summary-select-article t 'force))
11186 (defun gnus-summary-caesar-message (&optional arg)
11187 "Caesar rotate the current article by 13.
11188 The numerical prefix specifies how manu places to rotate each letter
11191 (gnus-set-global-variables)
11192 (gnus-summary-select-article)
11193 (let ((mail-header-separator ""))
11194 (gnus-eval-in-buffer-window
11195 gnus-article-buffer
11198 (let ((start (window-start)))
11199 (news-caesar-buffer-body arg)
11200 (set-window-start (get-buffer-window (current-buffer)) start))))))
11202 (defun gnus-summary-stop-page-breaking ()
11203 "Stop page breaking in the current article."
11205 (gnus-set-global-variables)
11206 (gnus-summary-select-article)
11207 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11209 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11210 "Move the current article to a different newsgroup.
11211 If N is a positive number, move the N next articles.
11212 If N is a negative number, move the N previous articles.
11213 If N is nil and any articles have been marked with the process mark,
11214 move those articles instead.
11215 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11216 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11217 re-spool using this method.
11219 For this function to work, both the current newsgroup and the
11220 newsgroup that you want to move to have to support the `request-move'
11221 and `request-accept' functions."
11223 (unless action (setq action 'move))
11224 (gnus-set-global-variables)
11225 ;; Check whether the source group supports the required functions.
11226 (cond ((and (eq action 'move)
11227 (not (gnus-check-backend-function
11228 'request-move-article gnus-newsgroup-name)))
11229 (error "The current group does not support article moving"))
11230 ((and (eq action 'crosspost)
11231 (not (gnus-check-backend-function
11232 'request-replace-article gnus-newsgroup-name)))
11233 (error "The current group does not support article editing")))
11234 (let ((articles (gnus-summary-work-articles n))
11235 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11236 (names '((move "move" "Moving")
11237 (copy "copy" "Copying")
11238 (crosspost "crosspost" "Crossposting")))
11239 (copy-buf (save-excursion
11240 (nnheader-set-temp-buffer " *copy article*")))
11241 art-group to-method new-xref article to-groups)
11242 (unless (assq action names)
11243 (error "Unknown action %s" action))
11244 ;; Read the newsgroup name.
11245 (when (and (not to-newsgroup)
11246 (not select-method))
11248 (gnus-read-move-group-name
11249 (cadr (assq action names))
11250 gnus-current-move-group articles prefix))
11251 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11252 (setq to-method (or select-method
11253 (gnus-find-method-for-group to-newsgroup)))
11254 ;; Check the method we are to move this article to...
11255 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11256 (error "%s does not support article copying" (car to-method)))
11257 (or (gnus-check-server to-method)
11258 (error "Can't open server %s" (car to-method)))
11259 (gnus-message 6 "%s to %s: %s..."
11260 (caddr (assq action names))
11261 (or (car select-method) to-newsgroup) articles)
11263 (setq article (pop articles))
11267 ;; Move the article.
11269 (gnus-request-move-article
11270 article ; Article to move
11271 gnus-newsgroup-name ; From newsgrouo
11272 (nth 1 (gnus-find-method-for-group
11273 gnus-newsgroup-name)) ; Server
11274 (list 'gnus-request-accept-article
11275 to-newsgroup (list 'quote select-method)
11276 (not articles)) ; Accept form
11277 (not articles))) ; Only save nov last time
11278 ;; Copy the article.
11281 (set-buffer copy-buf)
11282 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11283 (gnus-request-accept-article
11284 to-newsgroup select-method (not articles))))
11285 ;; Crosspost the article.
11286 ((eq action 'crosspost)
11287 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11288 (setq new-xref (concat gnus-newsgroup-name ":" article))
11289 (if (and xref (not (string= xref "")))
11291 (when (string-match "^Xref: " xref)
11292 (setq xref (substring xref (match-end 0))))
11293 (setq new-xref (concat xref " " new-xref)))
11294 (setq new-xref (concat (system-name) " " new-xref)))
11296 (set-buffer copy-buf)
11297 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11298 (nnheader-replace-header "xref" new-xref)
11299 (gnus-request-accept-article
11300 to-newsgroup select-method (not articles)))))))
11301 (if (not art-group)
11302 (gnus-message 1 "Couldn't %s article %s"
11303 (cadr (assq action names)) article)
11306 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11308 (gnus-group-prefixed-name
11311 (gnus-find-method-for-group to-newsgroup)))
11312 gnus-newsrc-hashtb)))
11313 (info (nth 2 entry))
11314 (to-group (gnus-info-group info)))
11315 ;; Update the group that has been moved to.
11317 (memq action '(move copy)))
11318 (unless (member to-group to-groups)
11319 (push to-group to-groups))
11321 (unless (memq article gnus-newsgroup-unreads)
11322 (gnus-info-set-read
11323 info (gnus-add-to-range (gnus-info-read info)
11324 (list (cdr art-group)))))
11326 ;; Copy any marks over to the new group.
11327 (let ((marks gnus-article-mark-lists)
11328 (to-article (cdr art-group)))
11330 ;; See whether the article is to be put in the cache.
11331 (when gnus-use-cache
11332 (gnus-cache-possibly-enter-article
11333 to-group to-article
11334 (let ((header (copy-sequence
11335 (gnus-summary-article-header article))))
11336 (mail-header-set-number header to-article)
11338 (memq article gnus-newsgroup-marked)
11339 (memq article gnus-newsgroup-dormant)
11340 (memq article gnus-newsgroup-unreads)))
11343 (when (memq article (symbol-value
11344 (intern (format "gnus-newsgroup-%s"
11346 ;; If the other group is the same as this group,
11347 ;; then we have to add the mark to the list.
11348 (when (equal to-group gnus-newsgroup-name)
11349 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11352 (intern (format "gnus-newsgroup-%s"
11354 ;; Copy mark to other group.
11355 (gnus-add-marked-articles
11356 to-group (cdar marks) (list to-article) info))
11357 (setq marks (cdr marks)))))
11359 ;; Update the Xref header in this article to point to
11360 ;; the new crossposted article we have just created.
11361 (when (eq action 'crosspost)
11363 (set-buffer copy-buf)
11364 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11365 (nnheader-replace-header
11366 "xref" (concat new-xref " " (gnus-group-prefixed-name
11367 (car art-group) to-method)
11368 ":" (cdr art-group)))
11369 (gnus-request-replace-article
11370 article gnus-newsgroup-name (current-buffer)))))
11372 (gnus-summary-goto-subject article)
11373 (when (eq action 'move)
11374 (gnus-summary-mark-article article gnus-canceled-mark)))
11375 (gnus-summary-remove-process-mark article))
11376 ;; Re-activate all groups that have been moved to.
11378 (gnus-activate-group (pop to-groups)))
11380 (gnus-kill-buffer copy-buf)
11381 (gnus-summary-position-point)
11382 (gnus-set-mode-line 'summary)))
11384 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11385 "Move the current article to a different newsgroup.
11386 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11387 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11388 re-spool using this method."
11390 (gnus-summary-move-article n nil select-method 'copy))
11392 (defun gnus-summary-crosspost-article (&optional n)
11393 "Crosspost the current article to some other group."
11395 (gnus-summary-move-article n nil nil 'crosspost))
11397 (defvar gnus-summary-respool-default-method nil
11398 "Default method for respooling an article.
11399 If nil, use to the current newsgroup method.")
11401 (defun gnus-summary-respool-article (&optional n method)
11402 "Respool the current article.
11403 The article will be squeezed through the mail spooling process again,
11404 which means that it will be put in some mail newsgroup or other
11405 depending on `nnmail-split-methods'.
11406 If N is a positive number, respool the N next articles.
11407 If N is a negative number, respool the N previous articles.
11408 If N is nil and any articles have been marked with the process mark,
11409 respool those articles instead.
11411 Respooling can be done both from mail groups and \"real\" newsgroups.
11412 In the former case, the articles in question will be moved from the
11413 current group into whatever groups they are destined to. In the
11414 latter case, they will be copied into the relevant groups."
11416 (list current-prefix-arg
11417 (let* ((methods (gnus-methods-using 'respool))
11419 (symbol-name (or gnus-summary-respool-default-method
11420 (car (gnus-find-method-for-group
11421 gnus-newsgroup-name)))))
11423 (gnus-completing-read
11424 methname "What backend do you want to use when? "
11425 methods nil t nil 'gnus-method-history))
11428 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11429 (list (intern method) ""))
11433 (cdr (completing-read
11435 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11436 (gnus-set-global-variables)
11438 (error "No method given for respooling"))
11439 (if (assoc (symbol-name
11440 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11441 (gnus-methods-using 'respool))
11442 (gnus-summary-move-article n nil method)
11443 (gnus-summary-copy-article n nil method)))
11445 (defun gnus-summary-import-article (file)
11446 "Import a random file into a mail newsgroup."
11447 (interactive "fImport file: ")
11448 (gnus-set-global-variables)
11449 (let ((group gnus-newsgroup-name)
11450 (now (current-time))
11452 (or (gnus-check-backend-function 'request-accept-article group)
11453 (error "%s does not support article importing" group))
11454 (or (file-readable-p file)
11455 (not (file-regular-p file))
11456 (error "Can't read %s" file))
11458 (set-buffer (get-buffer-create " *import file*"))
11459 (buffer-disable-undo (current-buffer))
11461 (insert-file-contents file)
11462 (goto-char (point-min))
11463 (unless (nnheader-article-p)
11464 ;; This doesn't look like an article, so we fudge some headers.
11465 (setq atts (file-attributes file)
11466 lines (count-lines (point-min) (point-max)))
11467 (insert "From: " (read-string "From: ") "\n"
11468 "Subject: " (read-string "Subject: ") "\n"
11469 "Date: " (timezone-make-date-arpa-standard
11470 (current-time-string (nth 5 atts))
11471 (current-time-zone now)
11472 (current-time-zone now)) "\n"
11473 "Message-ID: " (gnus-inews-message-id) "\n"
11474 "Lines: " (int-to-string lines) "\n"
11475 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11476 (gnus-request-accept-article group nil t)
11477 (kill-buffer (current-buffer)))))
11479 (defun gnus-summary-expire-articles ()
11480 "Expire all articles that are marked as expirable in the current group."
11482 (gnus-set-global-variables)
11483 (when (gnus-check-backend-function
11484 'request-expire-articles gnus-newsgroup-name)
11485 ;; This backend supports expiry.
11486 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11487 (expirable (if total
11488 (gnus-list-of-read-articles gnus-newsgroup-name)
11489 (setq gnus-newsgroup-expirable
11490 (sort gnus-newsgroup-expirable '<))))
11491 (expiry-wait (gnus-group-get-parameter
11492 gnus-newsgroup-name 'expiry-wait))
11495 ;; There are expirable articles in this group, so we run them
11496 ;; through the expiry process.
11497 (gnus-message 6 "Expiring articles...")
11498 ;; The list of articles that weren't expired is returned.
11500 (let ((nnmail-expiry-wait-function nil)
11501 (nnmail-expiry-wait expiry-wait))
11502 (setq es (gnus-request-expire-articles
11503 expirable gnus-newsgroup-name)))
11504 (setq es (gnus-request-expire-articles
11505 expirable gnus-newsgroup-name)))
11506 (or total (setq gnus-newsgroup-expirable es))
11507 ;; We go through the old list of expirable, and mark all
11508 ;; really expired articles as nonexistent.
11509 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11510 (let ((gnus-use-cache nil))
11512 (unless (memq (car expirable) es)
11513 (when (gnus-data-find (car expirable))
11514 (gnus-summary-mark-article
11515 (car expirable) gnus-canceled-mark)))
11516 (setq expirable (cdr expirable)))))
11517 (gnus-message 6 "Expiring articles...done")))))
11519 (defun gnus-summary-expire-articles-now ()
11520 "Expunge all expirable articles in the current group.
11521 This means that *all* articles that are marked as expirable will be
11522 deleted forever, right now."
11524 (gnus-set-global-variables)
11525 (or gnus-expert-user
11527 "Are you really, really, really sure you want to expunge? ")
11529 (let ((nnmail-expiry-wait 'immediate)
11530 (nnmail-expiry-wait-function nil))
11531 (gnus-summary-expire-articles)))
11533 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11534 (defun gnus-summary-delete-article (&optional n)
11535 "Delete the N next (mail) articles.
11536 This command actually deletes articles. This is not a marking
11537 command. The article will disappear forever from your life, never to
11539 If N is negative, delete backwards.
11540 If N is nil and articles have been marked with the process mark,
11541 delete these instead."
11543 (gnus-set-global-variables)
11544 (or (gnus-check-backend-function 'request-expire-articles
11545 gnus-newsgroup-name)
11546 (error "The current newsgroup does not support article deletion."))
11547 ;; Compute the list of articles to delete.
11548 (let ((articles (gnus-summary-work-articles n))
11550 (if (and gnus-novice-user
11551 (not (gnus-y-or-n-p
11552 (format "Do you really want to delete %s forever? "
11553 (if (> (length articles) 1) "these articles"
11554 "this article")))))
11556 ;; Delete the articles.
11557 (setq not-deleted (gnus-request-expire-articles
11558 articles gnus-newsgroup-name 'force))
11560 (gnus-summary-remove-process-mark (car articles))
11561 ;; The backend might not have been able to delete the article
11563 (or (memq (car articles) not-deleted)
11564 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11565 (setq articles (cdr articles))))
11566 (gnus-summary-position-point)
11567 (gnus-set-mode-line 'summary)
11570 (defun gnus-summary-edit-article (&optional force)
11571 "Enter into a buffer and edit the current article.
11572 This will have permanent effect only in mail groups.
11573 If FORCE is non-nil, allow editing of articles even in read-only
11577 (set-buffer gnus-summary-buffer)
11578 (gnus-set-global-variables)
11579 (when (and (not force)
11580 (gnus-group-read-only-p))
11581 (error "The current newsgroup does not support article editing."))
11582 (gnus-summary-select-article t nil t)
11583 (gnus-configure-windows 'article)
11584 (select-window (get-buffer-window gnus-article-buffer))
11585 (gnus-message 6 "C-c C-c to end edits")
11586 (setq buffer-read-only nil)
11588 (use-local-map (copy-keymap (current-local-map)))
11589 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11590 (buffer-enable-undo)
11592 (goto-char (point-min))
11593 (search-forward "\n\n" nil t)))
11595 (defun gnus-summary-edit-article-done ()
11596 "Make edits to the current article permanent."
11598 (if (gnus-group-read-only-p)
11600 (gnus-summary-edit-article-postpone)
11602 1 "The current newsgroup does not support article editing."))
11603 (let ((buf (format "%s" (buffer-string))))
11606 (if (not (gnus-request-replace-article
11607 (cdr gnus-article-current) (car gnus-article-current)
11609 (error "Couldn't replace article.")
11610 (gnus-article-mode)
11611 (use-local-map gnus-article-mode-map)
11612 (setq buffer-read-only t)
11613 (buffer-disable-undo (current-buffer))
11614 (gnus-configure-windows 'summary)
11615 (gnus-summary-update-article (cdr gnus-article-current))
11616 (when gnus-use-cache
11617 (gnus-cache-update-article
11618 (cdr gnus-article-current) (car gnus-article-current))))
11620 (when (get-buffer gnus-original-article-buffer)
11621 (set-buffer gnus-original-article-buffer)
11622 (setq gnus-original-article nil)))
11623 (setq gnus-article-current nil
11624 gnus-current-article nil)
11625 (run-hooks 'gnus-article-display-hook)
11626 (and (gnus-visual-p 'summary-highlight 'highlight)
11627 (run-hooks 'gnus-visual-mark-article-hook)))))
11629 (defun gnus-summary-edit-article-postpone ()
11630 "Postpone changes to the current article."
11632 (gnus-article-mode)
11633 (use-local-map gnus-article-mode-map)
11634 (setq buffer-read-only t)
11635 (buffer-disable-undo (current-buffer))
11636 (gnus-configure-windows 'summary)
11637 (and (gnus-visual-p 'summary-highlight 'highlight)
11638 (run-hooks 'gnus-visual-mark-article-hook)))
11640 (defun gnus-summary-respool-query ()
11641 "Query where the respool algorithm would put this article."
11643 (gnus-set-global-variables)
11644 (gnus-summary-select-article)
11646 (set-buffer gnus-article-buffer)
11648 (goto-char (point-min))
11649 (search-forward "\n\n")
11650 (narrow-to-region (point-min) (point))
11651 (pp-eval-expression
11652 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11654 ;; Summary score commands.
11656 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11658 (defun gnus-summary-raise-score (n)
11659 "Raise the score of the current article by N."
11661 (gnus-set-global-variables)
11662 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11664 (defun gnus-summary-set-score (n)
11665 "Set the score of the current article to N."
11667 (gnus-set-global-variables)
11669 (gnus-summary-show-thread)
11670 (let ((buffer-read-only nil))
11672 (gnus-summary-update-mark
11673 (if (= n (or gnus-summary-default-score 0)) ?
11674 (if (< n (or gnus-summary-default-score 0))
11675 gnus-score-below-mark gnus-score-over-mark)) 'score))
11676 (let* ((article (gnus-summary-article-number))
11677 (score (assq article gnus-newsgroup-scored)))
11678 (if score (setcdr score n)
11679 (setq gnus-newsgroup-scored
11680 (cons (cons article n) gnus-newsgroup-scored))))
11681 (gnus-summary-update-line)))
11683 (defun gnus-summary-current-score ()
11684 "Return the score of the current article."
11686 (gnus-set-global-variables)
11687 (gnus-message 1 "%s" (gnus-summary-article-score)))
11689 ;; Summary marking commands.
11691 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11692 "Mark articles which has the same subject as read, and then select the next.
11693 If UNMARK is positive, remove any kind of mark.
11694 If UNMARK is negative, tick articles."
11696 (gnus-set-global-variables)
11698 (setq unmark (prefix-numeric-value unmark)))
11700 (gnus-summary-mark-same-subject
11701 (gnus-summary-article-subject) unmark)))
11702 ;; Select next unread article. If auto-select-same mode, should
11703 ;; select the first unread article.
11704 (gnus-summary-next-article t (and gnus-auto-select-same
11705 (gnus-summary-article-subject)))
11706 (gnus-message 7 "%d article%s marked as %s"
11707 count (if (= count 1) " is" "s are")
11708 (if unmark "unread" "read"))))
11710 (defun gnus-summary-kill-same-subject (&optional unmark)
11711 "Mark articles which has the same subject as read.
11712 If UNMARK is positive, remove any kind of mark.
11713 If UNMARK is negative, tick articles."
11715 (gnus-set-global-variables)
11717 (setq unmark (prefix-numeric-value unmark)))
11719 (gnus-summary-mark-same-subject
11720 (gnus-summary-article-subject) unmark)))
11721 ;; If marked as read, go to next unread subject.
11723 ;; Go to next unread subject.
11724 (gnus-summary-next-subject 1 t))
11725 (gnus-message 7 "%d articles are marked as %s"
11726 count (if unmark "unread" "read"))))
11728 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11729 "Mark articles with same SUBJECT as read, and return marked number.
11730 If optional argument UNMARK is positive, remove any kinds of marks.
11731 If optional argument UNMARK is negative, mark articles as unread instead."
11735 ((null unmark) ; Mark as read.
11738 (gnus-summary-mark-article-as-read gnus-killed-mark)
11739 (gnus-summary-show-thread) t)
11740 (gnus-summary-find-subject subject))
11741 (setq count (1+ count))))
11742 ((> unmark 0) ; Tick.
11745 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11746 (gnus-summary-show-thread) t)
11747 (gnus-summary-find-subject subject))
11748 (setq count (1+ count))))
11749 (t ; Mark as unread.
11752 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11753 (gnus-summary-show-thread) t)
11754 (gnus-summary-find-subject subject))
11755 (setq count (1+ count)))))
11756 (gnus-set-mode-line 'summary)
11757 ;; Return the number of marked articles.
11760 (defun gnus-summary-mark-as-processable (n &optional unmark)
11761 "Set the process mark on the next N articles.
11762 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11763 the process mark instead. The difference between N and the actual
11764 number of articles marked is returned."
11766 (gnus-set-global-variables)
11767 (let ((backward (< n 0))
11772 (gnus-summary-remove-process-mark
11773 (gnus-summary-article-number))
11774 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11775 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11777 (if (/= 0 n) (gnus-message 7 "No more articles"))
11778 (gnus-summary-recenter)
11779 (gnus-summary-position-point)
11782 (defun gnus-summary-unmark-as-processable (n)
11783 "Remove the process mark from the next N articles.
11784 If N is negative, mark backward instead. The difference between N and
11785 the actual number of articles marked is returned."
11787 (gnus-set-global-variables)
11788 (gnus-summary-mark-as-processable n t))
11790 (defun gnus-summary-unmark-all-processable ()
11791 "Remove the process mark from all articles."
11793 (gnus-set-global-variables)
11795 (while gnus-newsgroup-processable
11796 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11797 (gnus-summary-position-point))
11799 (defun gnus-summary-mark-as-expirable (n)
11800 "Mark N articles forward as expirable.
11801 If N is negative, mark backward instead. The difference between N and
11802 the actual number of articles marked is returned."
11804 (gnus-set-global-variables)
11805 (gnus-summary-mark-forward n gnus-expirable-mark))
11807 (defun gnus-summary-mark-article-as-replied (article)
11808 "Mark ARTICLE replied and update the summary line."
11809 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11810 (let ((buffer-read-only nil))
11811 (when (gnus-summary-goto-subject article)
11812 (gnus-summary-update-secondary-mark article))))
11814 (defun gnus-summary-set-bookmark (article)
11815 "Set a bookmark in current article."
11816 (interactive (list (gnus-summary-article-number)))
11817 (gnus-set-global-variables)
11818 (if (or (not (get-buffer gnus-article-buffer))
11819 (not gnus-current-article)
11820 (not gnus-article-current)
11821 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11822 (error "No current article selected"))
11823 ;; Remove old bookmark, if one exists.
11824 (let ((old (assq article gnus-newsgroup-bookmarks)))
11825 (if old (setq gnus-newsgroup-bookmarks
11826 (delq old gnus-newsgroup-bookmarks))))
11827 ;; Set the new bookmark, which is on the form
11828 ;; (article-number . line-number-in-body).
11829 (setq gnus-newsgroup-bookmarks
11833 (set-buffer gnus-article-buffer)
11837 (goto-char (point-min))
11838 (search-forward "\n\n" nil t)
11841 gnus-newsgroup-bookmarks))
11842 (gnus-message 6 "A bookmark has been added to the current article."))
11844 (defun gnus-summary-remove-bookmark (article)
11845 "Remove the bookmark from the current article."
11846 (interactive (list (gnus-summary-article-number)))
11847 (gnus-set-global-variables)
11848 ;; Remove old bookmark, if one exists.
11849 (let ((old (assq article gnus-newsgroup-bookmarks)))
11852 (setq gnus-newsgroup-bookmarks
11853 (delq old gnus-newsgroup-bookmarks))
11854 (gnus-message 6 "Removed bookmark."))
11855 (gnus-message 6 "No bookmark in current article."))))
11857 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11858 (defun gnus-summary-mark-as-dormant (n)
11859 "Mark N articles forward as dormant.
11860 If N is negative, mark backward instead. The difference between N and
11861 the actual number of articles marked is returned."
11863 (gnus-set-global-variables)
11864 (gnus-summary-mark-forward n gnus-dormant-mark))
11866 (defun gnus-summary-set-process-mark (article)
11867 "Set the process mark on ARTICLE and update the summary line."
11868 (setq gnus-newsgroup-processable
11870 (delq article gnus-newsgroup-processable)))
11871 (when (gnus-summary-goto-subject article)
11872 (gnus-summary-show-thread)
11873 (gnus-summary-update-secondary-mark article)))
11875 (defun gnus-summary-remove-process-mark (article)
11876 "Remove the process mark from ARTICLE and update the summary line."
11877 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11878 (when (gnus-summary-goto-subject article)
11879 (gnus-summary-show-thread)
11880 (gnus-summary-update-secondary-mark article)))
11882 (defun gnus-summary-set-saved-mark (article)
11883 "Set the process mark on ARTICLE and update the summary line."
11884 (push article gnus-newsgroup-saved)
11885 (when (gnus-summary-goto-subject article)
11886 (gnus-summary-update-secondary-mark article)))
11888 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11889 "Mark N articles as read forwards.
11890 If N is negative, mark backwards instead.
11891 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11893 The difference between N and the actual number of articles marked is
11896 (gnus-set-global-variables)
11897 (let ((backward (< n 0))
11898 (gnus-summary-goto-unread
11899 (and gnus-summary-goto-unread
11900 (not (eq gnus-summary-goto-unread 'never))
11901 (not (memq mark (list gnus-unread-mark
11902 gnus-ticked-mark gnus-dormant-mark)))))
11904 (mark (or mark gnus-del-mark)))
11905 (while (and (> n 0)
11906 (gnus-summary-mark-article nil mark no-expire)
11907 (zerop (gnus-summary-next-subject
11909 (and gnus-summary-goto-unread
11910 (not (eq gnus-summary-goto-unread 'never)))
11913 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11914 (gnus-summary-recenter)
11915 (gnus-summary-position-point)
11916 (gnus-set-mode-line 'summary)
11919 (defun gnus-summary-mark-article-as-read (mark)
11920 "Mark the current article quickly as read with MARK."
11921 (let ((article (gnus-summary-article-number)))
11922 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11923 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11924 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11925 (setq gnus-newsgroup-reads
11926 (cons (cons article mark) gnus-newsgroup-reads))
11927 ;; Possibly remove from cache, if that is used.
11928 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11929 ;; Allow the backend to change the mark.
11930 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11931 ;; Check for auto-expiry.
11932 (when (and gnus-newsgroup-auto-expire
11933 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11934 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11935 (= mark gnus-ancient-mark)
11936 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11937 (setq mark gnus-expirable-mark)
11938 (push article gnus-newsgroup-expirable))
11939 ;; Set the mark in the buffer.
11940 (gnus-summary-update-mark mark 'unread)
11943 (defun gnus-summary-mark-article-as-unread (mark)
11944 "Mark the current article quickly as unread with MARK."
11945 (let ((article (gnus-summary-article-number)))
11946 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11947 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11948 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11949 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11950 (cond ((= mark gnus-ticked-mark)
11951 (push article gnus-newsgroup-marked))
11952 ((= mark gnus-dormant-mark)
11953 (push article gnus-newsgroup-dormant))
11955 (push article gnus-newsgroup-unreads)))
11956 (setq gnus-newsgroup-reads
11957 (delq (assq article gnus-newsgroup-reads)
11958 gnus-newsgroup-reads))
11960 ;; See whether the article is to be put in the cache.
11961 (and gnus-use-cache
11962 (vectorp (gnus-summary-article-header article))
11964 (gnus-cache-possibly-enter-article
11965 gnus-newsgroup-name article
11966 (gnus-summary-article-header article)
11967 (= mark gnus-ticked-mark)
11968 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11971 (gnus-summary-update-mark mark 'unread)
11974 (defun gnus-summary-mark-article (&optional article mark no-expire)
11975 "Mark ARTICLE with MARK. MARK can be any character.
11976 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11977 `??' (dormant) and `?E' (expirable).
11978 If MARK is nil, then the default character `?D' is used.
11979 If ARTICLE is nil, then the article on the current line will be
11981 ;; The mark might be a string.
11982 (and (stringp mark)
11983 (setq mark (aref mark 0)))
11984 ;; If no mark is given, then we check auto-expiring.
11985 (and (not no-expire)
11986 gnus-newsgroup-auto-expire
11988 (and (numberp mark)
11989 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11990 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11991 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11992 (setq mark gnus-expirable-mark))
11993 (let* ((mark (or mark gnus-del-mark))
11994 (article (or article (gnus-summary-article-number))))
11995 (or article (error "No article on current line"))
11996 (if (or (= mark gnus-unread-mark)
11997 (= mark gnus-ticked-mark)
11998 (= mark gnus-dormant-mark))
11999 (gnus-mark-article-as-unread article mark)
12000 (gnus-mark-article-as-read article mark))
12002 ;; See whether the article is to be put in the cache.
12003 (and gnus-use-cache
12004 (not (= mark gnus-canceled-mark))
12005 (vectorp (gnus-summary-article-header article))
12007 (gnus-cache-possibly-enter-article
12008 gnus-newsgroup-name article
12009 (gnus-summary-article-header article)
12010 (= mark gnus-ticked-mark)
12011 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12013 (if (gnus-summary-goto-subject article nil t)
12014 (let ((buffer-read-only nil))
12015 (gnus-summary-show-thread)
12017 (gnus-summary-update-mark mark 'unread)
12020 (defun gnus-summary-update-secondary-mark (article)
12021 "Update the secondary (read, process, cache) mark."
12022 (gnus-summary-update-mark
12023 (cond ((memq article gnus-newsgroup-processable)
12025 ((memq article gnus-newsgroup-cached)
12027 ((memq article gnus-newsgroup-replied)
12029 ((memq article gnus-newsgroup-saved)
12031 (t gnus-unread-mark))
12033 (when (gnus-visual-p 'summary-highlight 'highlight)
12034 (run-hooks 'gnus-summary-update-hook))
12037 (defun gnus-summary-update-mark (mark type)
12038 (beginning-of-line)
12039 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12040 (buffer-read-only nil))
12042 (<= (+ forward (point)) (point-max)))
12043 ;; Go to the right position on the line.
12044 (goto-char (+ forward (point)))
12045 ;; Replace the old mark with the new mark.
12046 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12047 ;; Optionally update the marks by some user rule.
12048 (when (eq type 'unread)
12049 (gnus-data-set-mark
12050 (gnus-data-find (gnus-summary-article-number)) mark)
12051 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12053 (defun gnus-mark-article-as-read (article &optional mark)
12054 "Enter ARTICLE in the pertinent lists and remove it from others."
12055 ;; Make the article expirable.
12056 (let ((mark (or mark gnus-del-mark)))
12057 (if (= mark gnus-expirable-mark)
12058 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12059 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12060 ;; Remove from unread and marked lists.
12061 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12062 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12063 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12064 (push (cons article mark) gnus-newsgroup-reads)
12065 ;; Possibly remove from cache, if that is used.
12066 (when gnus-use-cache
12067 (gnus-cache-enter-remove-article article))))
12069 (defun gnus-mark-article-as-unread (article &optional mark)
12070 "Enter ARTICLE in the pertinent lists and remove it from others."
12071 (let ((mark (or mark gnus-ticked-mark)))
12072 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12073 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12074 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12075 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12076 (cond ((= mark gnus-ticked-mark)
12077 (push article gnus-newsgroup-marked))
12078 ((= mark gnus-dormant-mark)
12079 (push article gnus-newsgroup-dormant))
12081 (push article gnus-newsgroup-unreads)))
12082 (setq gnus-newsgroup-reads
12083 (delq (assq article gnus-newsgroup-reads)
12084 gnus-newsgroup-reads))))
12086 (defalias 'gnus-summary-mark-as-unread-forward
12087 'gnus-summary-tick-article-forward)
12088 (make-obsolete 'gnus-summary-mark-as-unread-forward
12089 'gnus-summary-tick-article-forward)
12090 (defun gnus-summary-tick-article-forward (n)
12091 "Tick N articles forwards.
12092 If N is negative, tick backwards instead.
12093 The difference between N and the number of articles ticked is returned."
12095 (gnus-summary-mark-forward n gnus-ticked-mark))
12097 (defalias 'gnus-summary-mark-as-unread-backward
12098 'gnus-summary-tick-article-backward)
12099 (make-obsolete 'gnus-summary-mark-as-unread-backward
12100 'gnus-summary-tick-article-backward)
12101 (defun gnus-summary-tick-article-backward (n)
12102 "Tick N articles backwards.
12103 The difference between N and the number of articles ticked is returned."
12105 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12107 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12108 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12109 (defun gnus-summary-tick-article (&optional article clear-mark)
12110 "Mark current article as unread.
12111 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12112 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12114 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12115 gnus-ticked-mark)))
12117 (defun gnus-summary-mark-as-read-forward (n)
12118 "Mark N articles as read forwards.
12119 If N is negative, mark backwards instead.
12120 The difference between N and the actual number of articles marked is
12123 (gnus-summary-mark-forward n gnus-del-mark t))
12125 (defun gnus-summary-mark-as-read-backward (n)
12126 "Mark the N articles as read backwards.
12127 The difference between N and the actual number of articles marked is
12130 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12132 (defun gnus-summary-mark-as-read (&optional article mark)
12133 "Mark current article as read.
12134 ARTICLE specifies the article to be marked as read.
12135 MARK specifies a string to be inserted at the beginning of the line."
12136 (gnus-summary-mark-article article mark))
12138 (defun gnus-summary-clear-mark-forward (n)
12139 "Clear marks from N articles forward.
12140 If N is negative, clear backward instead.
12141 The difference between N and the number of marks cleared is returned."
12143 (gnus-summary-mark-forward n gnus-unread-mark))
12145 (defun gnus-summary-clear-mark-backward (n)
12146 "Clear marks from N articles backward.
12147 The difference between N and the number of marks cleared is returned."
12149 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12151 (defun gnus-summary-mark-unread-as-read ()
12152 "Intended to be used by `gnus-summary-mark-article-hook'."
12153 (when (memq gnus-current-article gnus-newsgroup-unreads)
12154 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12156 (defun gnus-summary-mark-read-and-unread-as-read ()
12157 "Intended to be used by `gnus-summary-mark-article-hook'."
12158 (let ((mark (gnus-summary-article-mark)))
12159 (when (or (gnus-unread-mark-p mark)
12160 (gnus-read-mark-p mark))
12161 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12163 (defun gnus-summary-mark-region-as-read (point mark all)
12164 "Mark all unread articles between point and mark as read.
12165 If given a prefix, mark all articles between point and mark as read,
12166 even ticked and dormant ones."
12167 (interactive "r\nP")
12171 (beginning-of-line)
12176 (memq (setq article (gnus-summary-article-number))
12177 gnus-newsgroup-unreads))
12178 (gnus-summary-mark-article article gnus-del-mark))
12180 (gnus-summary-find-next))))))
12182 (defun gnus-summary-mark-below (score mark)
12183 "Mark articles with score less than SCORE with MARK."
12184 (interactive "P\ncMark: ")
12185 (gnus-set-global-variables)
12186 (setq score (if score
12187 (prefix-numeric-value score)
12188 (or gnus-summary-default-score 0)))
12190 (set-buffer gnus-summary-buffer)
12191 (goto-char (point-min))
12194 (and (< (gnus-summary-article-score) score)
12195 (gnus-summary-mark-article nil mark))
12196 (gnus-summary-find-next)))))
12198 (defun gnus-summary-kill-below (&optional score)
12199 "Mark articles with score below SCORE as read."
12201 (gnus-set-global-variables)
12202 (gnus-summary-mark-below score gnus-killed-mark))
12204 (defun gnus-summary-clear-above (&optional score)
12205 "Clear all marks from articles with score above SCORE."
12207 (gnus-set-global-variables)
12208 (gnus-summary-mark-above score gnus-unread-mark))
12210 (defun gnus-summary-tick-above (&optional score)
12211 "Tick all articles with score above SCORE."
12213 (gnus-set-global-variables)
12214 (gnus-summary-mark-above score gnus-ticked-mark))
12216 (defun gnus-summary-mark-above (score mark)
12217 "Mark articles with score over SCORE with MARK."
12218 (interactive "P\ncMark: ")
12219 (gnus-set-global-variables)
12220 (setq score (if score
12221 (prefix-numeric-value score)
12222 (or gnus-summary-default-score 0)))
12224 (set-buffer gnus-summary-buffer)
12225 (goto-char (point-min))
12227 (if (> (gnus-summary-article-score) score)
12228 (gnus-summary-mark-article nil mark))
12230 (gnus-summary-find-next)))))
12232 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12233 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12234 (defun gnus-summary-limit-include-expunged ()
12235 "Display all the hidden articles that were expunged for low scores."
12237 (gnus-set-global-variables)
12238 (let ((buffer-read-only nil))
12239 (let ((scored gnus-newsgroup-scored)
12242 (or (gnus-summary-goto-subject (caar scored))
12243 (and (setq h (gnus-summary-article-header (caar scored)))
12244 (< (cdar scored) gnus-summary-expunge-below)
12245 (setq headers (cons h headers))))
12246 (setq scored (cdr scored)))
12247 (or headers (error "No expunged articles hidden."))
12248 (goto-char (point-min))
12249 (gnus-summary-prepare-unthreaded (nreverse headers)))
12250 (goto-char (point-min))
12251 (gnus-summary-position-point)))
12253 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12254 "Mark all articles not marked as unread in this newsgroup as read.
12255 If prefix argument ALL is non-nil, all articles are marked as read.
12256 If QUIETLY is non-nil, no questions will be asked.
12257 If TO-HERE is non-nil, it should be a point in the buffer. All
12258 articles before this point will be marked as read.
12259 The number of articles marked as read is returned."
12261 (gnus-set-global-variables)
12264 (not gnus-interactive-catchup) ;Without confirmation?
12268 "Mark absolutely all articles as read? "
12269 "Mark all unread articles as read? ")))
12271 (not gnus-newsgroup-adaptive)
12272 (not gnus-newsgroup-auto-expire))
12275 (setq gnus-newsgroup-marked nil
12276 gnus-newsgroup-dormant nil))
12277 (setq gnus-newsgroup-unreads nil))
12278 ;; We actually mark all articles as canceled, which we
12279 ;; have to do when using auto-expiry or adaptive scoring.
12280 (gnus-summary-show-all-threads)
12281 (if (gnus-summary-first-subject (not all))
12283 (if to-here (< (point) to-here) t)
12284 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12285 (gnus-summary-find-next (not all)))))
12287 (setq gnus-newsgroup-unreads nil))
12288 (gnus-set-mode-line 'summary)))
12289 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12290 (if (and (not to-here) (eq 'nnvirtual (car method)))
12291 (nnvirtual-catchup-group
12292 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12293 (gnus-summary-position-point)))
12295 (defun gnus-summary-catchup-to-here (&optional all)
12296 "Mark all unticked articles before the current one as read.
12297 If ALL is non-nil, also mark ticked and dormant articles as read."
12299 (gnus-set-global-variables)
12301 (let ((beg (point)))
12302 ;; We check that there are unread articles.
12303 (when (or all (gnus-summary-find-prev))
12304 (gnus-summary-catchup all t beg))))
12305 (gnus-summary-position-point))
12307 (defun gnus-summary-catchup-all (&optional quietly)
12308 "Mark all articles in this newsgroup as read."
12310 (gnus-set-global-variables)
12311 (gnus-summary-catchup t quietly))
12313 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12314 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12315 If prefix argument ALL is non-nil, all articles are marked as read."
12317 (gnus-set-global-variables)
12318 (gnus-summary-catchup all quietly nil 'fast)
12319 ;; Select next newsgroup or exit.
12320 (if (eq gnus-auto-select-next 'quietly)
12321 (gnus-summary-next-group nil)
12322 (gnus-summary-exit)))
12324 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12325 "Mark all articles in this newsgroup as read, and then exit."
12327 (gnus-set-global-variables)
12328 (gnus-summary-catchup-and-exit t quietly))
12330 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12331 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12332 "Mark all articles in this group as read and select the next group.
12333 If given a prefix, mark all articles, unread as well as ticked, as
12336 (gnus-set-global-variables)
12338 (gnus-summary-catchup all))
12339 (gnus-summary-next-article t nil nil t))
12341 ;; Thread-based commands.
12343 (defun gnus-summary-articles-in-thread (&optional article)
12344 "Return a list of all articles in the current thread.
12345 If ARTICLE is non-nil, return all articles in the thread that starts
12346 with that article."
12347 (let* ((article (or article (gnus-summary-article-number)))
12348 (data (gnus-data-find-list article))
12349 (top-level (gnus-data-level (car data)))
12351 (cond ((null gnus-thread-operation-ignore-subject)
12352 (gnus-simplify-subject-re
12353 (mail-header-subject (gnus-data-header (car data)))))
12354 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12355 (gnus-simplify-subject-fuzzy
12356 (mail-header-subject (gnus-data-header (car data)))))
12358 (end-point (save-excursion
12359 (gnus-summary-go-to-next-thread) (point)))
12362 (< (gnus-data-pos (car data)) end-point))
12363 (and (or (not top-subject)
12364 (string= top-subject
12365 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12366 (gnus-simplify-subject-fuzzy
12367 (mail-header-subject
12368 (gnus-data-header (car data))))
12369 (gnus-simplify-subject-re
12370 (mail-header-subject
12371 (gnus-data-header (car data)))))))
12372 (setq articles (cons (gnus-data-number (car data)) articles)))
12373 (unless (and (setq data (cdr data))
12374 (> (gnus-data-level (car data)) top-level))
12376 ;; Return the list of articles.
12377 (nreverse articles)))
12379 (defun gnus-summary-rethread-current ()
12380 "Rethread the thread the current article is part of."
12382 (gnus-set-global-variables)
12383 (let* ((gnus-show-threads t)
12384 (article (gnus-summary-article-number))
12385 (id (mail-header-id (gnus-summary-article-header)))
12386 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12388 (error "No article on the current line"))
12389 (gnus-rebuild-thread id)
12390 (gnus-summary-goto-subject article)))
12392 (defun gnus-summary-reparent-thread ()
12393 "Make current article child of the marked (or previous) article.
12395 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12396 is non-nil or the Subject: of both articles are the same."
12398 (or (not (gnus-group-read-only-p))
12399 (error "The current newsgroup does not support article editing."))
12400 (or (<= (length gnus-newsgroup-processable) 1)
12401 (error "No more than one article may be marked."))
12402 (save-window-excursion
12403 (let ((gnus-article-buffer " *reparent*")
12404 (current-article (gnus-summary-article-number))
12405 ; first grab the marked article, otherwise one line up.
12406 (parent-article (if (not (null gnus-newsgroup-processable))
12407 (car gnus-newsgroup-processable)
12409 (if (eq (forward-line -1) 0)
12410 (gnus-summary-article-number)
12411 (error "Beginning of summary buffer."))))))
12412 (or (not (eq current-article parent-article))
12413 (error "An article may not be self-referential."))
12414 (let ((message-id (mail-header-id
12415 (gnus-summary-article-header parent-article))))
12416 (or (and message-id (not (equal message-id "")))
12417 (error "No message-id in desired parent."))
12418 (gnus-summary-select-article t t nil current-article)
12419 (set-buffer gnus-article-buffer)
12420 (setq buffer-read-only nil)
12421 (let ((buf (format "%s" (buffer-string))))
12424 (goto-char (point-min))
12425 (if (search-forward-regexp "^References: " nil t)
12426 (insert message-id " " )
12427 (insert "References: " message-id "\n"))
12428 (or (gnus-request-replace-article current-article
12429 (car gnus-article-current)
12430 gnus-article-buffer)
12431 (error "Couldn't replace article."))
12432 (set-buffer gnus-summary-buffer)
12433 (gnus-summary-unmark-all-processable)
12434 (gnus-summary-rethread-current)
12435 (gnus-message 3 "Article %d is now the child of article %d."
12436 current-article parent-article)))))
12438 (defun gnus-summary-toggle-threads (&optional arg)
12439 "Toggle showing conversation threads.
12440 If ARG is positive number, turn showing conversation threads on."
12442 (gnus-set-global-variables)
12443 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12444 (setq gnus-show-threads
12445 (if (null arg) (not gnus-show-threads)
12446 (> (prefix-numeric-value arg) 0)))
12447 (gnus-summary-prepare)
12448 (gnus-summary-goto-subject current)
12449 (gnus-summary-position-point)))
12451 (defun gnus-summary-show-all-threads ()
12452 "Show all threads."
12454 (gnus-set-global-variables)
12456 (let ((buffer-read-only nil))
12457 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12458 (gnus-summary-position-point))
12460 (defun gnus-summary-show-thread ()
12461 "Show thread subtrees.
12462 Returns nil if no thread was there to be shown."
12464 (gnus-set-global-variables)
12465 (let ((buffer-read-only nil)
12467 ;; first goto end then to beg, to have point at beg after let
12468 (end (progn (end-of-line) (point)))
12469 (beg (progn (beginning-of-line) (point))))
12471 ;; Any hidden lines here?
12472 (search-forward "\r" end t)
12473 (subst-char-in-region beg end ?\^M ?\n t)
12475 (gnus-summary-position-point))))
12477 (defun gnus-summary-hide-all-threads ()
12478 "Hide all thread subtrees."
12480 (gnus-set-global-variables)
12482 (goto-char (point-min))
12483 (gnus-summary-hide-thread)
12484 (while (zerop (gnus-summary-next-thread 1 t))
12485 (gnus-summary-hide-thread)))
12486 (gnus-summary-position-point))
12488 (defun gnus-summary-hide-thread ()
12489 "Hide thread subtrees.
12490 Returns nil if no threads were there to be hidden."
12492 (gnus-set-global-variables)
12493 (let ((buffer-read-only nil)
12495 (article (gnus-summary-article-number)))
12497 ;; Go forward until either the buffer ends or the subthread
12499 (when (and (not (eobp))
12500 (or (zerop (gnus-summary-next-thread 1 t))
12501 (goto-char (point-max))))
12503 (if (and (> (point) start)
12504 (search-backward "\n" start t))
12506 (subst-char-in-region start (point) ?\n ?\^M)
12507 (gnus-summary-goto-subject article))
12510 ;;(gnus-summary-position-point)
12513 (defun gnus-summary-go-to-next-thread (&optional previous)
12514 "Go to the same level (or less) next thread.
12515 If PREVIOUS is non-nil, go to previous thread instead.
12516 Return the article number moved to, or nil if moving was impossible."
12517 (let ((level (gnus-summary-thread-level))
12518 (way (if previous -1 1))
12521 (while (and (not (eobp))
12522 (< level (gnus-summary-thread-level)))
12523 (forward-line way))
12530 (gnus-summary-article-number)
12531 (goto-char beg)))))
12533 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12534 "Go to the same level (or less) next thread.
12535 If PREVIOUS is non-nil, go to previous thread instead.
12536 Return the article number moved to, or nil if moving was impossible."
12537 (if (and (eq gnus-summary-make-false-root 'dummy)
12538 (gnus-summary-article-intangible-p))
12539 (let ((beg (point)))
12540 (while (and (zerop (forward-line 1))
12541 (not (gnus-summary-article-intangible-p))
12542 (not (zerop (save-excursion
12543 (gnus-summary-thread-level))))))
12549 (let* ((level (gnus-summary-thread-level))
12550 (article (gnus-summary-article-number))
12551 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12554 (if (<= (gnus-data-level (car data)) level)
12555 (setq oart (gnus-data-number (car data))
12557 (setq data (cdr data))))
12559 (gnus-summary-goto-subject oart)))))
12561 (defun gnus-summary-next-thread (n &optional silent)
12562 "Go to the same level next N'th thread.
12563 If N is negative, search backward instead.
12564 Returns the difference between N and the number of skips actually
12567 If SILENT, don't output messages."
12569 (gnus-set-global-variables)
12570 (let ((backward (< n 0))
12573 (while (and (> n 0)
12574 (gnus-summary-go-to-next-thread backward))
12577 (gnus-summary-position-point))
12578 (when (and (not silent) (/= 0 n))
12579 (gnus-message 7 "No more threads"))
12582 (defun gnus-summary-prev-thread (n)
12583 "Go to the same level previous N'th thread.
12584 Returns the difference between N and the number of skips actually
12587 (gnus-set-global-variables)
12588 (gnus-summary-next-thread (- n)))
12590 (defun gnus-summary-go-down-thread ()
12591 "Go down one level in the current thread."
12592 (let ((children (gnus-summary-article-children)))
12594 (gnus-summary-goto-subject (car children)))))
12596 (defun gnus-summary-go-up-thread ()
12597 "Go up one level in the current thread."
12598 (let ((parent (gnus-summary-article-parent)))
12600 (gnus-summary-goto-subject parent))))
12602 (defun gnus-summary-down-thread (n)
12603 "Go down thread N steps.
12604 If N is negative, go up instead.
12605 Returns the difference between N and how many steps down that were
12608 (gnus-set-global-variables)
12611 (while (and (> n 0)
12612 (if up (gnus-summary-go-up-thread)
12613 (gnus-summary-go-down-thread)))
12615 (gnus-summary-position-point)
12616 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12619 (defun gnus-summary-up-thread (n)
12620 "Go up thread N steps.
12621 If N is negative, go up instead.
12622 Returns the difference between N and how many steps down that were
12625 (gnus-set-global-variables)
12626 (gnus-summary-down-thread (- n)))
12628 (defun gnus-summary-top-thread ()
12629 "Go to the top of the thread."
12631 (gnus-set-global-variables)
12632 (while (gnus-summary-go-up-thread))
12633 (gnus-summary-article-number))
12635 (defun gnus-summary-kill-thread (&optional unmark)
12636 "Mark articles under current thread as read.
12637 If the prefix argument is positive, remove any kinds of marks.
12638 If the prefix argument is negative, tick articles instead."
12640 (gnus-set-global-variables)
12642 (setq unmark (prefix-numeric-value unmark)))
12643 (let ((articles (gnus-summary-articles-in-thread)))
12645 ;; Expand the thread.
12646 (gnus-summary-show-thread)
12647 ;; Mark all the articles.
12649 (gnus-summary-goto-subject (car articles))
12650 (cond ((null unmark)
12651 (gnus-summary-mark-article-as-read gnus-killed-mark))
12653 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12655 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12656 (setq articles (cdr articles))))
12657 ;; Hide killed subtrees.
12659 gnus-thread-hide-killed
12660 (gnus-summary-hide-thread))
12661 ;; If marked as read, go to next unread subject.
12663 ;; Go to next unread subject.
12664 (gnus-summary-next-subject 1 t)))
12665 (gnus-set-mode-line 'summary))
12667 ;; Summary sorting commands
12669 (defun gnus-summary-sort-by-number (&optional reverse)
12670 "Sort summary buffer by article number.
12671 Argument REVERSE means reverse order."
12673 (gnus-summary-sort 'number reverse))
12675 (defun gnus-summary-sort-by-author (&optional reverse)
12676 "Sort summary buffer by author name alphabetically.
12677 If case-fold-search is non-nil, case of letters is ignored.
12678 Argument REVERSE means reverse order."
12680 (gnus-summary-sort 'author reverse))
12682 (defun gnus-summary-sort-by-subject (&optional reverse)
12683 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12684 If case-fold-search is non-nil, case of letters is ignored.
12685 Argument REVERSE means reverse order."
12687 (gnus-summary-sort 'subject reverse))
12689 (defun gnus-summary-sort-by-date (&optional reverse)
12690 "Sort summary buffer by date.
12691 Argument REVERSE means reverse order."
12693 (gnus-summary-sort 'date reverse))
12695 (defun gnus-summary-sort-by-score (&optional reverse)
12696 "Sort summary buffer by score.
12697 Argument REVERSE means reverse order."
12699 (gnus-summary-sort 'score reverse))
12701 (defun gnus-summary-sort (predicate reverse)
12702 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12703 (gnus-set-global-variables)
12704 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12705 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12706 (gnus-thread-sort-functions
12711 (,thread t2 t1)))))
12712 (gnus-article-sort-functions
12717 (,article t2 t1)))))
12719 (gnus-summary-prepare-hook nil))
12720 ;; We do the sorting by regenerating the threads.
12721 (gnus-summary-prepare)
12722 ;; Hide subthreads if needed.
12723 (when (and gnus-show-threads gnus-thread-hide-subtree)
12724 (gnus-summary-hide-all-threads)))
12725 ;; If in async mode, we send some info to the backend.
12726 (when gnus-newsgroup-async
12727 (gnus-request-asynchronous
12728 gnus-newsgroup-name gnus-newsgroup-data)))
12730 (defun gnus-sortable-date (date)
12731 "Make sortable string by string-lessp from DATE.
12732 Timezone package is used."
12733 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12734 (year (aref date 0))
12735 (month (aref date 1))
12736 (day (aref date 2)))
12737 (timezone-make-sortable-date
12739 (timezone-make-time-string
12740 (aref date 3) (aref date 4) (aref date 5)))))
12742 ;; Summary saving commands.
12744 (defun gnus-summary-save-article (&optional n not-saved)
12745 "Save the current article using the default saver function.
12746 If N is a positive number, save the N next articles.
12747 If N is a negative number, save the N previous articles.
12748 If N is nil and any articles have been marked with the process mark,
12749 save those articles instead.
12750 The variable `gnus-default-article-saver' specifies the saver function."
12752 (gnus-set-global-variables)
12753 (let ((articles (gnus-summary-work-articles n))
12754 file header article)
12756 (setq header (gnus-summary-article-header
12757 (setq article (pop articles))))
12758 (if (not (vectorp header))
12759 ;; This is a pseudo-article.
12760 (if (assq 'name header)
12761 (gnus-copy-file (cdr (assq 'name header)))
12762 (gnus-message 1 "Article %d is unsaveable" article))
12763 ;; This is a real article.
12764 (save-window-excursion
12765 (gnus-summary-select-article t nil nil article))
12766 (unless gnus-save-all-headers
12767 ;; Remove headers accoring to `gnus-saved-headers'.
12768 (let ((gnus-visible-headers
12769 (or gnus-saved-headers gnus-visible-headers)))
12770 (gnus-article-hide-headers nil t)))
12771 ;; Remove any X-Gnus lines.
12773 (set-buffer gnus-article-buffer)
12775 (let ((buffer-read-only nil))
12776 (nnheader-narrow-to-headers)
12777 (while (re-search-forward "^X-Gnus" nil t)
12778 (gnus-delete-line)))))
12779 (save-window-excursion
12780 (if (not gnus-default-article-saver)
12781 (error "No default saver is defined.")
12782 (setq file (funcall
12783 gnus-default-article-saver
12785 ((not gnus-prompt-before-saving)
12787 ((eq gnus-prompt-before-saving 'always)
12790 (gnus-summary-remove-process-mark article)
12792 (gnus-summary-set-saved-mark article))))
12793 (gnus-summary-position-point)
12796 (defun gnus-summary-pipe-output (&optional arg)
12797 "Pipe the current article to a subprocess.
12798 If N is a positive number, pipe the N next articles.
12799 If N is a negative number, pipe the N previous articles.
12800 If N is nil and any articles have been marked with the process mark,
12801 pipe those articles instead."
12803 (gnus-set-global-variables)
12804 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12805 (gnus-summary-save-article arg t))
12806 (gnus-configure-windows 'pipe))
12808 (defun gnus-summary-save-article-mail (&optional arg)
12809 "Append the current article to an mail file.
12810 If N is a positive number, save the N next articles.
12811 If N is a negative number, save the N previous articles.
12812 If N is nil and any articles have been marked with the process mark,
12813 save those articles instead."
12815 (gnus-set-global-variables)
12816 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12817 (gnus-summary-save-article arg)))
12819 (defun gnus-summary-save-article-rmail (&optional arg)
12820 "Append the current article to an rmail file.
12821 If N is a positive number, save the N next articles.
12822 If N is a negative number, save the N previous articles.
12823 If N is nil and any articles have been marked with the process mark,
12824 save those articles instead."
12826 (gnus-set-global-variables)
12827 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12828 (gnus-summary-save-article arg)))
12830 (defun gnus-summary-save-article-file (&optional arg)
12831 "Append the current article to a file.
12832 If N is a positive number, save the N next articles.
12833 If N is a negative number, save the N previous articles.
12834 If N is nil and any articles have been marked with the process mark,
12835 save those articles instead."
12837 (gnus-set-global-variables)
12838 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12839 (gnus-summary-save-article arg)))
12841 (defun gnus-summary-save-article-body-file (&optional arg)
12842 "Append the current article body to a file.
12843 If N is a positive number, save the N next articles.
12844 If N is a negative number, save the N previous articles.
12845 If N is nil and any articles have been marked with the process mark,
12846 save those articles instead."
12848 (gnus-set-global-variables)
12849 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12850 (gnus-summary-save-article arg)))
12852 (defun gnus-get-split-value (methods)
12853 "Return a value based on the split METHODS."
12854 (let (split-name method result match)
12857 (set-buffer gnus-original-article-buffer)
12859 (nnheader-narrow-to-headers)
12861 (goto-char (point-min))
12862 (setq method (pop methods))
12863 (setq match (car method))
12866 ;; Regular expression.
12868 (re-search-forward match nil t)
12870 ((gnus-functionp match)
12874 (setq result (funcall match gnus-newsgroup-name))))
12879 (setq result (eval match)))))
12880 (setq split-name (append (cdr method) split-name))
12881 (cond ((stringp result)
12882 (push result split-name))
12884 (setq split-name (append result split-name)))))))))
12887 (defun gnus-read-move-group-name (prompt default articles prefix)
12888 "Read a group name."
12889 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12891 (format "Where do you want to %s %s?"
12893 (if (> (length articles) 1)
12894 (format "these %d articles" (length articles))
12899 (gnus-completing-read default prom
12900 gnus-active-hashtb nil nil prefix
12901 'gnus-group-history))
12902 ((= 1 (length split-name))
12903 (gnus-completing-read (car split-name) prom gnus-active-hashtb
12905 'gnus-group-history))
12907 (gnus-completing-read nil prom
12908 (mapcar (lambda (el) (list el))
12909 (nreverse split-name))
12911 'gnus-group-history)))))
12913 (if (or (string= to-newsgroup "")
12914 (string= to-newsgroup prefix))
12915 (setq to-newsgroup (or default "")))
12916 (or (gnus-active to-newsgroup)
12917 (gnus-activate-group to-newsgroup)
12918 (error "No such group: %s" to-newsgroup)))
12921 (defun gnus-read-save-file-name (prompt default-name)
12922 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12924 ;; Let the split methods have their say.
12926 ;; No split name was found.
12929 (concat prompt " (default "
12930 (file-name-nondirectory default-name) ") ")
12931 (file-name-directory default-name)
12933 ;; A single split name was found
12934 ((= 1 (length split-name))
12936 (concat prompt " (default " (car split-name) ") ")
12937 gnus-article-save-directory
12938 (concat gnus-article-save-directory (car split-name))))
12939 ;; A list of splits was found.
12941 (setq split-name (mapcar (lambda (el) (list el))
12942 (nreverse split-name)))
12943 (let ((result (completing-read
12944 (concat prompt " ") split-name nil nil)))
12945 (concat gnus-article-save-directory
12946 (if (string= result "")
12949 ;; If we have read a directory, we append the default file name.
12950 (when (file-directory-p file)
12951 (setq file (concat (file-name-as-directory file)
12952 (file-name-nondirectory default-name))))
12953 ;; Possibly translate some charaters.
12954 (nnheader-translate-file-chars file)))
12956 (defun gnus-article-archive-name (group)
12957 "Return the first instance of an \"Archive-name\" in the current buffer."
12958 (let ((case-fold-search t))
12959 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12960 (match-string 1))))
12962 (defun gnus-summary-save-in-rmail (&optional filename)
12963 "Append this article to Rmail file.
12964 Optional argument FILENAME specifies file name.
12965 Directory to save to is default to `gnus-article-save-directory' which
12966 is initialized from the SAVEDIR environment variable."
12968 (gnus-set-global-variables)
12969 (let ((default-name
12970 (funcall gnus-rmail-save-name gnus-newsgroup-name
12971 gnus-current-headers gnus-newsgroup-last-rmail)))
12973 (cond ((eq filename 'default)
12975 (filename filename)
12976 (t (gnus-read-save-file-name
12977 "Save in rmail file:" default-name))))
12978 (gnus-make-directory (file-name-directory filename))
12979 (gnus-eval-in-buffer-window
12980 gnus-original-article-buffer
12984 (gnus-output-to-rmail filename))))
12985 ;; Remember the directory name to save articles
12986 (setq gnus-newsgroup-last-rmail filename)))
12988 (defun gnus-summary-save-in-mail (&optional filename)
12989 "Append this article to Unix mail file.
12990 Optional argument FILENAME specifies file name.
12991 Directory to save to is default to `gnus-article-save-directory' which
12992 is initialized from the SAVEDIR environment variable."
12994 (gnus-set-global-variables)
12995 (let ((default-name
12996 (funcall gnus-mail-save-name gnus-newsgroup-name
12997 gnus-current-headers gnus-newsgroup-last-mail)))
12999 (cond ((eq filename 'default)
13001 (filename filename)
13002 (t (gnus-read-save-file-name
13003 "Save in Unix mail file:" default-name))))
13005 (expand-file-name filename
13007 (file-name-directory default-name))))
13008 (gnus-make-directory (file-name-directory filename))
13009 (gnus-eval-in-buffer-window
13010 gnus-original-article-buffer
13014 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13015 (gnus-output-to-rmail filename)
13016 (let ((mail-use-rfc822 t))
13017 (rmail-output filename 1 t t))))))
13018 ;; Remember the directory name to save articles.
13019 (setq gnus-newsgroup-last-mail filename)))
13021 (defun gnus-summary-save-in-file (&optional filename)
13022 "Append this article to file.
13023 Optional argument FILENAME specifies file name.
13024 Directory to save to is default to `gnus-article-save-directory' which
13025 is initialized from the SAVEDIR environment variable."
13027 (gnus-set-global-variables)
13028 (let ((default-name
13029 (funcall gnus-file-save-name gnus-newsgroup-name
13030 gnus-current-headers gnus-newsgroup-last-file)))
13032 (cond ((eq filename 'default)
13034 (filename filename)
13035 (t (gnus-read-save-file-name
13036 "Save in file:" default-name))))
13037 (gnus-make-directory (file-name-directory filename))
13038 (gnus-eval-in-buffer-window
13039 gnus-original-article-buffer
13043 (gnus-output-to-file filename))))
13044 ;; Remember the directory name to save articles.
13045 (setq gnus-newsgroup-last-file filename)))
13047 (defun gnus-summary-save-body-in-file (&optional filename)
13048 "Append this article body to a file.
13049 Optional argument FILENAME specifies file name.
13050 The directory to save in defaults to `gnus-article-save-directory' which
13051 is initialized from the SAVEDIR environment variable."
13053 (gnus-set-global-variables)
13054 (let ((default-name
13055 (funcall gnus-file-save-name gnus-newsgroup-name
13056 gnus-current-headers gnus-newsgroup-last-file)))
13058 (cond ((eq filename 'default)
13060 (filename filename)
13061 (t (gnus-read-save-file-name
13062 "Save body in file:" default-name))))
13063 (gnus-make-directory (file-name-directory filename))
13064 (gnus-eval-in-buffer-window
13065 gnus-article-buffer
13069 (goto-char (point-min))
13070 (and (search-forward "\n\n" nil t)
13071 (narrow-to-region (point) (point-max)))
13072 (gnus-output-to-file filename))))
13073 ;; Remember the directory name to save articles.
13074 (setq gnus-newsgroup-last-file filename)))
13076 (defun gnus-summary-save-in-pipe (&optional command)
13077 "Pipe this article to subprocess."
13079 (gnus-set-global-variables)
13081 (cond ((eq command 'default)
13082 gnus-last-shell-command)
13084 (t (read-string "Shell command on article: "
13085 gnus-last-shell-command))))
13086 (if (string-equal command "")
13087 (setq command gnus-last-shell-command))
13088 (gnus-eval-in-buffer-window
13089 gnus-article-buffer
13092 (shell-command-on-region (point-min) (point-max) command nil)))
13093 (setq gnus-last-shell-command command))
13095 ;; Summary extract commands
13097 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13098 (let ((buffer-read-only nil)
13099 (article (gnus-summary-article-number))
13101 (or (gnus-summary-goto-subject article)
13102 (error (format "No such article: %d" article)))
13103 (gnus-summary-position-point)
13104 ;; If all commands are to be bunched up on one line, we collect
13106 (if gnus-view-pseudos-separately
13108 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13111 (setq action (cdr (assq 'action (car ps))))
13112 (setq files (list (cdr (assq 'name (car ps)))))
13113 (while (and ps (cdr ps)
13114 (string= (or action "1")
13115 (or (cdr (assq 'action (cadr ps))) "2")))
13116 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13117 (setcdr ps (cddr ps)))
13120 (if (not (string-match "%s" action))
13121 (setq files (cons " " files)))
13122 (setq files (cons " " files))
13123 (and (assq 'execute (car ps))
13124 (setcdr (assq 'execute (car ps))
13125 (funcall (if (string-match "%s" action)
13128 (mapconcat (lambda (f) f) files " ")))))
13129 (setq ps (cdr ps)))))
13130 (if (and gnus-view-pseudos (not not-view))
13132 (and (assq 'execute (car pslist))
13133 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13134 (eq gnus-view-pseudos 'not-confirm)))
13135 (setq pslist (cdr pslist)))
13138 (setq after-article (or (cdr (assq 'article (car pslist)))
13139 (gnus-summary-article-number)))
13140 (gnus-summary-goto-subject after-article)
13143 (insert " " (file-name-nondirectory
13144 (cdr (assq 'name (car pslist))))
13145 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13147 (forward-line -1) ; back to `b'
13148 (add-text-properties
13149 b e (list 'gnus-number gnus-reffed-article-number
13150 gnus-mouse-face-prop gnus-mouse-face))
13152 after-article gnus-reffed-article-number
13153 gnus-unread-mark b (car pslist) 0 (- e b))
13154 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13155 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13156 (setq pslist (cdr pslist)))))))
13158 (defun gnus-pseudos< (p1 p2)
13159 (let ((c1 (cdr (assq 'action p1)))
13160 (c2 (cdr (assq 'action p2))))
13161 (and c1 c2 (string< c1 c2))))
13163 (defun gnus-request-pseudo-article (props)
13164 (cond ((assq 'execute props)
13165 (gnus-execute-command (cdr (assq 'execute props)))))
13166 (let ((gnus-current-article (gnus-summary-article-number)))
13167 (run-hooks 'gnus-mark-article-hook)))
13169 (defun gnus-execute-command (command &optional automatic)
13171 (gnus-article-setup-buffer)
13172 (set-buffer gnus-article-buffer)
13173 (let ((command (if automatic command (read-string "Command: " command)))
13174 (buffer-read-only nil))
13176 (insert "$ " command "\n\n")
13177 (if gnus-view-pseudo-asynchronously
13178 (start-process "gnus-execute" nil "sh" "-c" command)
13179 (call-process "sh" nil t nil "-c" command)))))
13181 (defun gnus-copy-file (file &optional to)
13184 (list (read-file-name "Copy file: " default-directory)
13185 (read-file-name "Copy file to: " default-directory)))
13186 (gnus-set-global-variables)
13187 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13188 (and (file-directory-p to)
13189 (setq to (concat (file-name-as-directory to)
13190 (file-name-nondirectory file))))
13191 (copy-file file to))
13193 ;; Summary kill commands.
13195 (defun gnus-summary-edit-global-kill (article)
13196 "Edit the \"global\" kill file."
13197 (interactive (list (gnus-summary-article-number)))
13198 (gnus-set-global-variables)
13199 (gnus-group-edit-global-kill article))
13201 (defun gnus-summary-edit-local-kill ()
13202 "Edit a local kill file applied to the current newsgroup."
13204 (gnus-set-global-variables)
13205 (setq gnus-current-headers (gnus-summary-article-header))
13206 (gnus-set-global-variables)
13207 (gnus-group-edit-local-kill
13208 (gnus-summary-article-number) gnus-newsgroup-name))
13212 ;;; Gnus article mode
13215 (put 'gnus-article-mode 'mode-class 'special)
13217 (if gnus-article-mode-map
13219 (setq gnus-article-mode-map (make-keymap))
13220 (suppress-keymap gnus-article-mode-map)
13222 (gnus-define-keys gnus-article-mode-map
13223 " " gnus-article-goto-next-page
13224 "\177" gnus-article-goto-prev-page
13225 [delete] gnus-article-goto-prev-page
13226 "\C-c^" gnus-article-refer-article
13227 "h" gnus-article-show-summary
13228 "s" gnus-article-show-summary
13229 "\C-c\C-m" gnus-article-mail
13230 "?" gnus-article-describe-briefly
13231 gnus-mouse-2 gnus-article-push-button
13232 "\r" gnus-article-press-button
13233 "\t" gnus-article-next-button
13234 "\M-\t" gnus-article-prev-button
13235 "\C-c\C-b" gnus-bug)
13237 (substitute-key-definition
13238 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13240 (defun gnus-article-mode ()
13241 "Major mode for displaying an article.
13243 All normal editing commands are switched off.
13245 The following commands are available:
13247 \\<gnus-article-mode-map>
13248 \\[gnus-article-next-page]\t Scroll the article one page forwards
13249 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13250 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13251 \\[gnus-article-show-summary]\t Display the summary buffer
13252 \\[gnus-article-mail]\t Send a reply to the address near point
13253 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13254 \\[gnus-info-find-node]\t Go to the Gnus info node"
13256 (when (and menu-bar-mode
13257 (gnus-visual-p 'article-menu 'menu))
13258 (gnus-article-make-menu-bar))
13259 (kill-all-local-variables)
13260 (gnus-simplify-mode-line)
13261 (setq mode-name "Article")
13262 (setq major-mode 'gnus-article-mode)
13263 (make-local-variable 'minor-mode-alist)
13264 (or (assq 'gnus-show-mime minor-mode-alist)
13265 (setq minor-mode-alist
13266 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13267 (use-local-map gnus-article-mode-map)
13268 (make-local-variable 'page-delimiter)
13269 (setq page-delimiter gnus-page-delimiter)
13270 (buffer-disable-undo (current-buffer))
13271 (setq buffer-read-only t) ;Disable modification
13272 (run-hooks 'gnus-article-mode-hook))
13274 (defun gnus-article-setup-buffer ()
13275 "Initialize the article buffer."
13276 (let* ((name (if gnus-single-article-buffer "*Article*"
13277 (concat "*Article " gnus-newsgroup-name "*")))
13279 (progn (string-match "\\*Article" name)
13280 (concat " *Original Article"
13281 (substring name (match-end 0))))))
13282 (setq gnus-article-buffer name)
13283 (setq gnus-original-article-buffer original)
13284 ;; This might be a variable local to the summary buffer.
13285 (unless gnus-single-article-buffer
13287 (set-buffer gnus-summary-buffer)
13288 (setq gnus-article-buffer name)
13289 (setq gnus-original-article-buffer original)
13290 (gnus-set-global-variables))
13291 (make-local-variable 'gnus-summary-buffer))
13292 ;; Init original article buffer.
13294 (set-buffer (get-buffer-create gnus-original-article-buffer))
13295 (buffer-disable-undo (current-buffer))
13296 (setq major-mode 'gnus-original-article-mode)
13297 (make-local-variable 'gnus-original-article))
13298 (if (get-buffer name)
13301 (buffer-disable-undo (current-buffer))
13302 (setq buffer-read-only t)
13303 (gnus-add-current-to-buffer-list)
13304 (or (eq major-mode 'gnus-article-mode)
13305 (gnus-article-mode))
13308 (set-buffer (get-buffer-create name))
13309 (gnus-add-current-to-buffer-list)
13310 (gnus-article-mode)
13311 (current-buffer)))))
13313 ;; Set article window start at LINE, where LINE is the number of lines
13314 ;; from the head of the article.
13315 (defun gnus-article-set-window-start (&optional line)
13317 (get-buffer-window gnus-article-buffer)
13319 (set-buffer gnus-article-buffer)
13320 (goto-char (point-min))
13323 (gnus-message 6 "Moved to bookmark")
13324 (search-forward "\n\n" nil t)
13325 (forward-line line)
13328 (defun gnus-kill-all-overlays ()
13329 "Delete all overlays in the current buffer."
13330 (when (fboundp 'overlay-lists)
13331 (let* ((overlayss (overlay-lists))
13332 (buffer-read-only nil)
13333 (overlays (nconc (car overlayss) (cdr overlayss))))
13335 (delete-overlay (pop overlays))))))
13337 (defun gnus-request-article-this-buffer (article group)
13338 "Get an article and insert it into this buffer."
13339 (let (do-update-line)
13343 (gnus-kill-all-overlays)
13344 (setq group (or group gnus-newsgroup-name))
13346 ;; Open server if it has closed.
13347 (gnus-check-server (gnus-find-method-for-group group))
13349 ;; Using `gnus-request-article' directly will insert the article into
13350 ;; `nntp-server-buffer' - so we'll save some time by not having to
13351 ;; copy it from the server buffer into the article buffer.
13353 ;; We only request an article by message-id when we do not have the
13354 ;; headers for it, so we'll have to get those.
13355 (when (stringp article)
13356 (let ((gnus-override-method gnus-refer-article-method))
13357 (gnus-read-header article)))
13359 ;; If the article number is negative, that means that this article
13360 ;; doesn't belong in this newsgroup (possibly), so we find its
13361 ;; message-id and request it by id instead of number.
13362 (when (and (numberp article)
13363 gnus-summary-buffer
13364 (get-buffer gnus-summary-buffer)
13365 (buffer-name (get-buffer gnus-summary-buffer)))
13367 (set-buffer gnus-summary-buffer)
13368 (let ((header (gnus-summary-article-header article)))
13371 ((memq article gnus-newsgroup-sparse)
13372 ;; This is a sparse gap article.
13373 (setq do-update-line article)
13374 (setq article (mail-header-id header))
13375 (let ((gnus-override-method gnus-refer-article-method))
13376 (gnus-read-header article)))
13378 ;; It's a real article.
13379 (setq article (mail-header-id header)))
13381 ;; It is an extracted pseudo-article.
13382 (setq article 'pseudo)
13383 (gnus-request-pseudo-article header))))
13385 (let ((method (gnus-find-method-for-group
13386 gnus-newsgroup-name)))
13387 (if (not (eq (car method) 'nneething))
13389 (let ((dir (concat (file-name-as-directory (nth 1 method))
13390 (mail-header-subject header))))
13391 (if (file-directory-p dir)
13393 (setq article 'nneething)
13394 (gnus-group-enter-directory dir)))))))))
13397 ;; We first check `gnus-original-article-buffer'.
13398 ((and (get-buffer gnus-original-article-buffer)
13400 (set-buffer gnus-original-article-buffer)
13401 (and (equal (car gnus-original-article) group)
13402 (eq (cdr gnus-original-article) article))))
13403 (insert-buffer-substring gnus-original-article-buffer)
13405 ;; Check the backlog.
13406 ((and gnus-keep-backlog
13407 (gnus-backlog-request-article group article (current-buffer)))
13409 ;; Check the cache.
13410 ((and gnus-use-cache
13412 (gnus-cache-request-article article group))
13414 ;; Get the article and put into the article buffer.
13415 ((or (stringp article) (numberp article))
13416 (let ((gnus-override-method
13417 (and (stringp article) gnus-refer-article-method))
13418 (buffer-read-only nil))
13420 (gnus-kill-all-overlays)
13421 (if (gnus-request-article article group (current-buffer))
13423 (and gnus-keep-backlog
13425 (gnus-backlog-enter-article
13426 group article (current-buffer)))
13428 ;; It was a pseudo.
13431 ;; Take the article from the original article buffer
13432 ;; and place it in the buffer it's supposed to be in.
13433 (when (and (get-buffer gnus-article-buffer)
13434 (equal (buffer-name (current-buffer))
13435 (buffer-name (get-buffer gnus-article-buffer))))
13437 (if (get-buffer gnus-original-article-buffer)
13438 (set-buffer (get-buffer gnus-original-article-buffer))
13439 (set-buffer (get-buffer-create gnus-original-article-buffer))
13440 (buffer-disable-undo (current-buffer))
13441 (setq major-mode 'gnus-original-article-mode)
13442 (setq buffer-read-only t)
13443 (gnus-add-current-to-buffer-list))
13444 (let (buffer-read-only)
13446 (insert-buffer-substring gnus-article-buffer))
13447 (setq gnus-original-article (cons group article))))
13449 ;; Update sparse articles.
13450 (when do-update-line
13452 (set-buffer gnus-summary-buffer)
13453 (gnus-summary-update-article do-update-line)
13454 (gnus-summary-goto-subject do-update-line)
13455 (set-window-point (get-buffer-window (current-buffer) t)
13458 (defun gnus-read-header (id &optional header)
13459 "Read the headers of article ID and enter them into the Gnus system."
13460 (let ((group gnus-newsgroup-name)
13461 (gnus-override-method
13462 (and (gnus-news-group-p gnus-newsgroup-name)
13463 gnus-refer-article-method))
13465 ;; First we check to see whether the header in question is already
13468 ;; This is a Message-ID.
13469 (setq header (or header (gnus-id-to-header id)))
13470 ;; This is an article number.
13471 (setq header (or header (gnus-summary-article-header id))))
13473 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13474 ;; We have found the header.
13476 ;; We have to really fetch the header to this article.
13478 (if (gnus-check-backend-function 'request-head group)
13479 (gnus-request-head id group)
13480 (gnus-request-article id group)))
13482 (set-buffer nntp-server-buffer)
13483 (and (search-forward "\n\n" nil t)
13484 (delete-region (1- (point)) (point-max)))
13485 (goto-char (point-max))
13487 (goto-char (point-min))
13491 ((cdr where) (cdr where))
13492 (header (mail-header-number header))
13493 (t gnus-reffed-article-number))
13495 (insert " Article retrieved.\n"))
13497 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13498 ; (setcar (gnus-id-to-thread id) nil))
13499 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13500 () ; Malformed head.
13501 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13502 (if (and (stringp id)
13503 (not (string= (gnus-group-real-name group)
13505 ;; If we fetched by Message-ID and the article came
13506 ;; from a different group, we fudge some bogus article
13507 ;; numbers for this article.
13508 (mail-header-set-number header gnus-reffed-article-number))
13509 (decf gnus-reffed-article-number)
13510 (push header gnus-newsgroup-headers)
13511 (setq gnus-current-headers header)
13512 (push (mail-header-number header) gnus-newsgroup-limit))
13515 (defun gnus-article-prepare (article &optional all-headers header)
13516 "Prepare ARTICLE in article mode buffer.
13517 ARTICLE should either be an article number or a Message-ID.
13518 If ARTICLE is an id, HEADER should be the article headers.
13519 If ALL-HEADERS is non-nil, no headers are hidden."
13521 ;; Make sure we start in a summary buffer.
13522 (unless (eq major-mode 'gnus-summary-mode)
13523 (set-buffer gnus-summary-buffer))
13524 (setq gnus-summary-buffer (current-buffer))
13525 ;; Make sure the connection to the server is alive.
13526 (unless (gnus-server-opened
13527 (gnus-find-method-for-group gnus-newsgroup-name))
13528 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13529 (gnus-request-group gnus-newsgroup-name t))
13530 (let* ((article (if header (mail-header-number header) article))
13531 (summary-buffer (current-buffer))
13532 (internal-hook gnus-article-internal-prepare-hook)
13533 (group gnus-newsgroup-name)
13536 (gnus-article-setup-buffer)
13537 (set-buffer gnus-article-buffer)
13538 ;; Deactivate active regions.
13539 (when (and (boundp 'transient-mark-mode)
13540 transient-mark-mode)
13541 (setq mark-active nil))
13542 (if (not (setq result (let ((buffer-read-only nil))
13543 (gnus-request-article-this-buffer
13545 ;; There is no such article.
13547 (when (and (numberp article)
13548 (not (memq article gnus-newsgroup-sparse)))
13549 (setq gnus-article-current
13550 (cons gnus-newsgroup-name article))
13551 (set-buffer gnus-summary-buffer)
13552 (setq gnus-current-article article)
13553 (gnus-summary-mark-article article gnus-canceled-mark))
13554 (unless (memq article gnus-newsgroup-sparse)
13556 1 "No such article (may have expired or been canceled)")))
13557 (if (or (eq result 'pseudo) (eq result 'nneething))
13560 (set-buffer summary-buffer)
13561 (setq gnus-last-article gnus-current-article
13562 gnus-newsgroup-history (cons gnus-current-article
13563 gnus-newsgroup-history)
13564 gnus-current-article 0
13565 gnus-current-headers nil
13566 gnus-article-current nil)
13567 (if (eq result 'nneething)
13568 (gnus-configure-windows 'summary)
13569 (gnus-configure-windows 'article))
13570 (gnus-set-global-variables))
13571 (gnus-set-mode-line 'article))
13572 ;; The result from the `request' was an actual article -
13573 ;; or at least some text that is now displayed in the
13575 (if (and (numberp article)
13576 (not (eq article gnus-current-article)))
13577 ;; Seems like a new article has been selected.
13578 ;; `gnus-current-article' must be an article number.
13580 (set-buffer summary-buffer)
13581 (setq gnus-last-article gnus-current-article
13582 gnus-newsgroup-history (cons gnus-current-article
13583 gnus-newsgroup-history)
13584 gnus-current-article article
13585 gnus-current-headers
13586 (gnus-summary-article-header gnus-current-article)
13587 gnus-article-current
13588 (cons gnus-newsgroup-name gnus-current-article))
13589 (unless (vectorp gnus-current-headers)
13590 (setq gnus-current-headers nil))
13591 (gnus-summary-show-thread)
13592 (run-hooks 'gnus-mark-article-hook)
13593 (gnus-set-mode-line 'summary)
13594 (and (gnus-visual-p 'article-highlight 'highlight)
13595 (run-hooks 'gnus-visual-mark-article-hook))
13596 ;; Set the global newsgroup variables here.
13597 ;; Suggested by Jim Sisolak
13598 ;; <sisolak@trans4.neep.wisc.edu>.
13599 (gnus-set-global-variables)
13600 (setq gnus-have-all-headers
13601 (or all-headers gnus-show-all-headers))
13602 (and gnus-use-cache
13603 (vectorp (gnus-summary-article-header article))
13604 (gnus-cache-possibly-enter-article
13606 (gnus-summary-article-header article)
13607 (memq article gnus-newsgroup-marked)
13608 (memq article gnus-newsgroup-dormant)
13609 (memq article gnus-newsgroup-unreads)))))
13610 ;; Hooks for getting information from the article.
13611 ;; This hook must be called before being narrowed.
13612 (let (buffer-read-only)
13613 (run-hooks 'internal-hook)
13614 (run-hooks 'gnus-article-prepare-hook)
13615 ;; Decode MIME message.
13617 (if (or (not gnus-strict-mime)
13618 (gnus-fetch-field "Mime-Version"))
13619 (funcall gnus-show-mime-method)
13620 (funcall gnus-decode-encoded-word-method)))
13621 ;; Perform the article display hooks.
13622 (run-hooks 'gnus-article-display-hook))
13624 (goto-char (point-min))
13625 (and gnus-break-pages (gnus-narrow-to-page))
13626 (gnus-set-mode-line 'article)
13627 (gnus-configure-windows 'article)
13628 (goto-char (point-min))
13631 (defun gnus-article-show-all-headers ()
13632 "Show all article headers in article mode buffer."
13634 (gnus-article-setup-buffer)
13635 (set-buffer gnus-article-buffer)
13636 (let ((buffer-read-only nil))
13637 (gnus-unhide-text (point-min) (point-max)))))
13639 (defun gnus-article-hide-headers-if-wanted ()
13640 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13641 Provided for backwards compatibility."
13642 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13643 gnus-inhibit-hiding
13644 (gnus-article-hide-headers)))
13646 (defsubst gnus-article-header-rank ()
13647 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13648 (let ((list gnus-sorted-header-list)
13651 (when (looking-at (car list))
13653 (setq list (cdr list))
13657 (defun gnus-article-hide-headers (&optional arg delete)
13658 "Toggle whether to hide unwanted headers and possibly sort them as well.
13659 If given a negative prefix, always show; if given a positive prefix,
13662 (unless (gnus-article-check-hidden-text 'headers arg)
13663 ;; This function might be inhibited.
13664 (unless gnus-inhibit-hiding
13666 (set-buffer gnus-article-buffer)
13668 (let ((buffer-read-only nil)
13669 (props (nconc (list 'gnus-type 'headers)
13670 gnus-hidden-properties))
13671 (max (1+ (length gnus-sorted-header-list)))
13672 (ignored (when (not (stringp gnus-visible-headers))
13673 (cond ((stringp gnus-ignored-headers)
13674 gnus-ignored-headers)
13675 ((listp gnus-ignored-headers)
13676 (mapconcat 'identity gnus-ignored-headers
13679 (cond ((stringp gnus-visible-headers)
13680 gnus-visible-headers)
13681 ((and gnus-visible-headers
13682 (listp gnus-visible-headers))
13683 (mapconcat 'identity gnus-visible-headers "\\|"))))
13685 ;; First we narrow to just the headers.
13687 (goto-char (point-min))
13688 ;; Hide any "From " lines at the beginning of (mail) articles.
13689 (while (looking-at "From ")
13692 (gnus-hide-text (point-min) (point) props))
13693 ;; Then treat the rest of the header lines.
13696 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13697 ;; Then we use the two regular expressions
13698 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13699 ;; select which header lines is to remain visible in the
13701 (goto-char (point-min))
13702 (while (re-search-forward "^[^ \t]*:" nil t)
13703 (beginning-of-line)
13704 ;; We add the headers we want to keep to a list and delete
13705 ;; them from the buffer.
13707 (point) (1+ (point)) 'message-rank
13708 (if (or (and visible (looking-at visible))
13710 (not (looking-at ignored))))
13711 (gnus-article-header-rank)
13714 (message-sort-headers-1)
13715 (when (setq beg (text-property-any
13716 (point-min) (point-max) 'message-rank (+ 2 max)))
13717 ;; We make the unwanted headers invisible.
13719 (delete-region beg (point-max))
13720 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13721 (gnus-hide-text-type beg (point-max) 'headers)))))))))
13723 (defun gnus-article-hide-boring-headers (&optional arg)
13724 "Toggle hiding of headers that aren't very interesting.
13725 If given a negative prefix, always show; if given a positive prefix,
13728 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13730 (set-buffer gnus-article-buffer)
13732 (let ((buffer-read-only nil)
13733 (list gnus-boring-article-headers)
13734 (inhibit-point-motion-hooks t)
13736 (nnheader-narrow-to-headers)
13738 (setq elem (pop list))
13739 (goto-char (point-min))
13741 ;; Hide empty headers.
13743 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13745 (gnus-hide-text-type
13746 (progn (beginning-of-line) (point))
13749 (if (re-search-forward "^[^ \t]" nil t)
13750 (match-beginning 0)
13753 ;; Hide boring Newsgroups header.
13754 ((eq elem 'newsgroups)
13755 (when (equal (mail-fetch-field "newsgroups")
13756 (gnus-group-real-name gnus-newsgroup-name))
13757 (gnus-article-hide-header "newsgroups")))
13758 ((eq elem 'followup-to)
13759 (when (equal (mail-fetch-field "followup-to")
13760 (mail-fetch-field "newsgroups"))
13761 (gnus-article-hide-header "followup-to")))
13762 ((eq elem 'reply-to)
13763 (let ((from (mail-fetch-field "from"))
13764 (reply-to (mail-fetch-field "reply-to")))
13768 (nth 1 (funcall gnus-extract-address-components from))
13769 (nth 1 (funcall gnus-extract-address-components
13771 (gnus-article-hide-header "reply-to"))))
13773 (let ((date (mail-fetch-field "date")))
13775 (< (gnus-days-between date (current-time-string))
13777 (gnus-article-hide-header "date")))))))))))
13779 (defun gnus-article-hide-header (header)
13781 (goto-char (point-min))
13782 (when (re-search-forward (concat "^" header ":") nil t)
13783 (gnus-hide-text-type
13784 (progn (beginning-of-line) (point))
13787 (if (re-search-forward "^[^ \t]" nil t)
13788 (match-beginning 0)
13790 'boring-headers))))
13792 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13793 (defun gnus-article-treat-overstrike ()
13794 "Translate overstrikes into bold text."
13797 (set-buffer gnus-article-buffer)
13798 (let ((buffer-read-only nil))
13799 (while (search-forward "\b" nil t)
13800 (let ((next (following-char))
13801 (previous (char-after (- (point) 2))))
13802 (cond ((eq next previous)
13803 (put-text-property (- (point) 2) (point) 'invisible t)
13804 (put-text-property (point) (1+ (point)) 'face 'bold))
13806 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13808 (- (point) 2) (1- (point)) 'face 'underline))
13810 (put-text-property (- (point) 2) (point) 'invisible t)
13812 (point) (1+ (point)) 'face 'underline))))))))
13814 (defun gnus-article-word-wrap ()
13815 "Format too long lines."
13818 (set-buffer gnus-article-buffer)
13819 (let ((buffer-read-only nil))
13821 (goto-char (point-min))
13822 (search-forward "\n\n" nil t)
13824 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13825 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13826 (adaptive-fill-mode t))
13827 (while (not (eobp))
13828 (and (>= (current-column) (min fill-column (window-width)))
13829 (/= (preceding-char) ?:)
13830 (fill-paragraph nil))
13831 (end-of-line 2))))))
13833 (defun gnus-article-remove-cr ()
13834 "Remove carriage returns from an article."
13837 (set-buffer gnus-article-buffer)
13838 (let ((buffer-read-only nil))
13839 (goto-char (point-min))
13840 (while (search-forward "\r" nil t)
13841 (replace-match "" t t)))))
13843 (defun gnus-article-remove-trailing-blank-lines ()
13844 "Remove all trailing blank lines from the article."
13847 (set-buffer gnus-article-buffer)
13848 (let ((buffer-read-only nil))
13849 (goto-char (point-max))
13853 (while (looking-at "^[ \t]*$")
13858 (defun gnus-article-display-x-face (&optional force)
13859 "Look for an X-Face header and display it if present."
13860 (interactive (list 'force))
13862 (set-buffer gnus-article-buffer)
13863 ;; Delete the old process, if any.
13864 (when (process-status "gnus-x-face")
13865 (delete-process "gnus-x-face"))
13866 (let ((inhibit-point-motion-hooks t)
13867 (case-fold-search nil)
13870 (nnheader-narrow-to-headers)
13871 (setq from (mail-fetch-field "from"))
13872 (goto-char (point-min))
13873 (when (and gnus-article-x-face-command
13875 ;; Check whether this face is censored.
13876 (not gnus-article-x-face-too-ugly)
13877 (and gnus-article-x-face-too-ugly from
13878 (not (string-match gnus-article-x-face-too-ugly
13880 ;; Has to be present.
13881 (re-search-forward "^X-Face: " nil t))
13882 ;; We now have the area of the buffer where the X-Face is stored.
13883 (let ((beg (point))
13884 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13885 ;; We display the face.
13886 (if (symbolp gnus-article-x-face-command)
13887 ;; The command is a lisp function, so we call it.
13888 (if (gnus-functionp gnus-article-x-face-command)
13889 (funcall gnus-article-x-face-command beg end)
13890 (error "%s is not a function" gnus-article-x-face-command))
13891 ;; The command is a string, so we interpret the command
13892 ;; as a, well, command, and fork it off.
13893 (let ((process-connection-type nil))
13894 (process-kill-without-query
13896 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13897 (process-send-region "gnus-x-face" beg end)
13898 (process-send-eof "gnus-x-face")))))))))
13900 (defun gnus-headers-decode-quoted-printable ()
13901 "Hack to remove QP encoding from headers."
13902 (let ((case-fold-search t)
13903 (inhibit-point-motion-hooks t)
13905 (goto-char (point-min))
13906 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13907 (setq string (match-string 1))
13908 (narrow-to-region (match-beginning 0) (match-end 0))
13909 (delete-region (point-min) (point-max))
13911 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13912 (subst-char-in-region (point-min) (point-max) ?_ ? )
13914 (goto-char (point-min)))))
13916 (defun gnus-article-de-quoted-unreadable (&optional force)
13917 "Do a naive translation of a quoted-printable-encoded article.
13918 This is in no way, shape or form meant as a replacement for real MIME
13919 processing, but is simply a stop-gap measure until MIME support is
13921 If FORCE, decode the article whether it is marked as quoted-printable
13923 (interactive (list 'force))
13925 (set-buffer gnus-article-buffer)
13926 (let ((case-fold-search t)
13927 (buffer-read-only nil)
13928 (type (gnus-fetch-field "content-transfer-encoding")))
13930 (and type (string-match "quoted-printable" (downcase type))))
13931 (gnus-headers-decode-quoted-printable)
13932 (goto-char (point-min))
13933 (search-forward "\n\n" nil 'move)
13934 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13936 (defun gnus-mime-decode-quoted-printable (from to)
13937 "Decode Quoted-Printable in the region between FROM and TO."
13940 (while (search-forward "=" to t)
13941 (cond ((eq (following-char) ?\n)
13944 ((looking-at "[0-9A-F][0-9A-F]")
13946 (insert (hexl-hex-string-to-integer
13947 (buffer-substring (point) (+ 2 (point)))))
13951 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13953 (defun gnus-article-hide-pgp (&optional arg)
13954 "Toggle hiding of any PGP headers and signatures in the current article.
13955 If given a negative prefix, always show; if given a positive prefix,
13958 (unless (gnus-article-check-hidden-text 'pgp arg)
13960 (set-buffer gnus-article-buffer)
13961 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13962 buffer-read-only beg end)
13964 (goto-char (point-min))
13965 ;; Hide the "header".
13966 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13967 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13969 ;; Hide the actual signature.
13970 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13971 (setq end (1+ (match-beginning 0)))
13974 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13976 ;; Perhaps we shouldn't hide to the end of the buffer
13977 ;; if there is no end to the signature?
13980 ;; Hide "- " PGP quotation markers.
13981 (when (and beg end)
13982 (narrow-to-region beg end)
13983 (goto-char (point-min))
13984 (while (re-search-forward "^- " nil t)
13985 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13988 (defun gnus-article-hide-signature (&optional arg)
13989 "Hide the signature in the current article.
13990 If given a negative prefix, always show; if given a positive prefix,
13993 (unless (gnus-article-check-hidden-text 'signature arg)
13995 (set-buffer gnus-article-buffer)
13997 (let ((buffer-read-only nil))
13998 (when (gnus-narrow-to-signature)
13999 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14001 (defun gnus-article-strip-leading-blank-lines ()
14002 "Remove all blank lines from the beginning of the article."
14005 (set-buffer gnus-article-buffer)
14006 (let (buffer-read-only)
14007 (goto-char (point-min))
14008 (when (search-forward "\n\n" nil t)
14009 (while (looking-at "[ \t]$")
14010 (gnus-delete-line))))))
14012 (defun gnus-narrow-to-signature ()
14013 "Narrow to the signature."
14015 (goto-char (point-max))
14016 (when (re-search-backward gnus-signature-separator nil t)
14018 (when (or (null gnus-signature-limit)
14019 (and (numberp gnus-signature-limit)
14020 (< (- (point-max) (point)) gnus-signature-limit))
14021 (and (gnus-functionp gnus-signature-limit)
14022 (funcall gnus-signature-limit))
14023 (and (stringp gnus-signature-limit)
14024 (not (re-search-forward gnus-signature-limit nil t))))
14025 (narrow-to-region (point) (point-max))
14028 (defun gnus-article-check-hidden-text (type arg)
14029 "Return nil if hiding is necessary."
14031 (set-buffer gnus-article-buffer)
14032 (let ((hide (gnus-article-hidden-text-p type)))
14033 (cond ((or (and (null arg) (eq hide 'hidden))
14034 (and arg (< 0 (prefix-numeric-value arg))))
14035 (gnus-article-show-hidden-text type))
14037 (gnus-article-show-hidden-text type t))
14040 (defun gnus-article-hidden-text-p (type)
14041 "Say whether the current buffer contains hidden text of type TYPE."
14042 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14044 (if (get-text-property pos 'invisible)
14048 (defun gnus-article-hide (&optional arg force)
14049 "Hide all the gruft in the current article.
14050 This means that PGP stuff, signatures, cited text and (some)
14051 headers will be hidden.
14052 If given a prefix, show the hidden text instead."
14053 (interactive (list current-prefix-arg 'force))
14054 (gnus-article-hide-headers arg)
14055 (gnus-article-hide-pgp arg)
14056 (gnus-article-hide-citation-maybe arg force)
14057 (gnus-article-hide-signature arg))
14059 (defun gnus-article-show-hidden-text (type &optional hide)
14060 "Show all hidden text of type TYPE.
14061 If HIDE, hide the text instead."
14063 (set-buffer gnus-article-buffer)
14064 (let ((buffer-read-only nil)
14065 (inhibit-point-motion-hooks t)
14067 (while (gnus-goto-char (text-property-any
14068 beg (point-max) 'gnus-type type))
14072 (gnus-hide-text beg (point) gnus-hidden-properties)
14073 (gnus-unhide-text beg (point)))
14074 (setq beg (point)))
14077 (defvar gnus-article-time-units
14078 `((year . ,(* 365.25 24 60 60))
14079 (week . ,(* 7 24 60 60))
14080 (day . ,(* 24 60 60))
14081 (hour . ,(* 60 60))
14084 "Mapping from time units to seconds.")
14086 (defun gnus-article-date-ut (&optional type highlight)
14087 "Convert DATE date to universal time in the current article.
14088 If TYPE is `local', convert to local time; if it is `lapsed', output
14089 how much time has lapsed since DATE."
14090 (interactive (list 'ut t))
14091 (let* ((header (or gnus-current-headers
14092 (gnus-summary-article-header) ""))
14093 (date (and (vectorp header) (mail-header-date header)))
14094 (date-regexp "^Date: \\|^X-Sent: ")
14095 (now (current-time))
14096 (inhibit-point-motion-hooks t)
14098 (when (and date (not (string= date "")))
14100 (set-buffer gnus-article-buffer)
14102 (nnheader-narrow-to-headers)
14103 (let ((buffer-read-only nil))
14104 ;; Delete any old Date headers.
14105 (if (re-search-forward date-regexp nil t)
14107 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14108 eface (get-text-property (gnus-point-at-eol) 'face))
14109 (message-remove-header date-regexp t)
14110 (beginning-of-line))
14111 (goto-char (point-max)))
14114 ;; Convert to the local timezone. We have to slap a
14115 ;; `condition-case' round the calls to the timezone
14116 ;; functions since they aren't particularly resistant to
14119 (concat "Date: " (condition-case ()
14120 (timezone-make-date-arpa-standard date)
14123 ;; Convert to Universal Time.
14127 (timezone-make-date-arpa-standard date nil "UT")
14130 ;; Get the original date from the article.
14131 ((eq type 'original)
14132 (concat "Date: " date "\n"))
14133 ;; Do an X-Sent lapsed format.
14135 ;; If the date is seriously mangled, the timezone
14136 ;; functions are liable to bug out, so we condition-case
14137 ;; the entire thing.
14142 (timezone-make-date-arpa-standard
14143 (current-time-string now)
14144 (current-time-zone now) "UT"))
14146 (timezone-make-date-arpa-standard
14149 (real-sec (+ (* (float (car real-time)) 65536)
14151 (sec (abs real-sec))
14157 ;; This is a bit convoluted, but basically we go
14158 ;; through the time units for years, weeks, etc,
14159 ;; and divide things to see whether that results
14160 ;; in positive answers.
14163 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14164 ;; The (remaining) seconds are too few to
14165 ;; be divided into this time unit.
14167 ;; It's big enough, so we output it.
14168 (setq sec (- sec (* num (cdr unit))))
14170 (concat (if prev ", " "") (int-to-string
14172 " " (symbol-name (car unit))
14173 (if (> num 1) "s" ""))
14175 gnus-article-time-units "")
14176 ;; If dates are odd, then it might appear like the
14177 ;; article was sent in the future.
14180 " in the future\n")))))
14182 (error "Unknown conversion type: %s" type)))))
14183 ;; Do highlighting.
14184 (beginning-of-line)
14185 (when (and highlight (gnus-visual-p 'article-highlight 'highlight)
14186 (looking-at "\\([^:]\\): *\\(.*\\)$"))
14187 (put-text-property (match-beginning 1) (match-end 1)
14189 (put-text-property (match-beginning 2) (match-end 2)
14192 (defun gnus-article-date-local (&optional highlight)
14193 "Convert the current article date to the local timezone."
14194 (interactive (list t))
14195 (gnus-article-date-ut 'local highlight))
14197 (defun gnus-article-date-original (&optional highlight)
14198 "Convert the current article date to what it was originally.
14199 This is only useful if you have used some other date conversion
14200 function and want to see what the date was before converting."
14201 (interactive (list t))
14202 (gnus-article-date-ut 'original highlight))
14204 (defun gnus-article-date-lapsed (&optional highlight)
14205 "Convert the current article date to time lapsed since it was sent."
14206 (interactive (list t))
14207 (gnus-article-date-ut 'lapsed highlight))
14209 (defun gnus-article-maybe-highlight ()
14210 "Do some article highlighting if `gnus-visual' is non-nil."
14211 (if (gnus-visual-p 'article-highlight 'highlight)
14212 (gnus-article-highlight-some)))
14216 (defun gnus-output-to-rmail (file-name)
14217 "Append the current article to an Rmail file named FILE-NAME."
14219 ;; Most of these codes are borrowed from rmailout.el.
14220 (setq file-name (expand-file-name file-name))
14221 (setq rmail-default-rmail-file file-name)
14222 (let ((artbuf (current-buffer))
14223 (tmpbuf (get-buffer-create " *Gnus-output*")))
14225 (or (get-file-buffer file-name)
14226 (file-exists-p file-name)
14227 (if (gnus-yes-or-no-p
14228 (concat "\"" file-name "\" does not exist, create it? "))
14229 (let ((file-buffer (create-file-buffer file-name)))
14231 (set-buffer file-buffer)
14232 (rmail-insert-rmail-file-header)
14233 (let ((require-final-newline nil))
14234 (write-region (point-min) (point-max) file-name t 1)))
14235 (kill-buffer file-buffer))
14236 (error "Output file does not exist")))
14237 (set-buffer tmpbuf)
14238 (buffer-disable-undo (current-buffer))
14240 (insert-buffer-substring artbuf)
14241 (gnus-convert-article-to-rmail)
14242 ;; Decide whether to append to a file or to an Emacs buffer.
14243 (let ((outbuf (get-file-buffer file-name)))
14245 (append-to-file (point-min) (point-max) file-name)
14246 ;; File has been visited, in buffer OUTBUF.
14247 (set-buffer outbuf)
14248 (let ((buffer-read-only nil)
14249 (msg (and (boundp 'rmail-current-message)
14250 (symbol-value 'rmail-current-message))))
14251 ;; If MSG is non-nil, buffer is in RMAIL mode.
14254 (narrow-to-region (point-max) (point-max))))
14255 (insert-buffer-substring tmpbuf)
14258 (goto-char (point-min))
14260 (search-backward "\^_")
14261 (narrow-to-region (point) (point-max))
14262 (goto-char (1+ (point-min)))
14263 (rmail-count-new-messages t)
14264 (rmail-show-message msg)))))))
14265 (kill-buffer tmpbuf)))
14267 (defun gnus-output-to-file (file-name)
14268 "Append the current article to a file named FILE-NAME."
14269 (setq file-name (expand-file-name file-name))
14270 (let ((artbuf (current-buffer))
14271 (tmpbuf (get-buffer-create " *Gnus-output*")))
14273 (set-buffer tmpbuf)
14274 (buffer-disable-undo (current-buffer))
14276 (insert-buffer-substring artbuf)
14277 ;; Append newline at end of the buffer as separator, and then
14278 ;; save it to file.
14279 (goto-char (point-max))
14281 (append-to-file (point-min) (point-max) file-name))
14282 (kill-buffer tmpbuf)))
14284 (defun gnus-convert-article-to-rmail ()
14285 "Convert article in current buffer to Rmail message format."
14286 (let ((buffer-read-only nil))
14287 ;; Convert article directly into Babyl format.
14288 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14289 (goto-char (point-min))
14290 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14291 (while (search-forward "\n\^_" nil t) ;single char
14292 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14293 (goto-char (point-max))
14296 (defun gnus-narrow-to-page (&optional arg)
14297 "Narrow the article buffer to a page.
14298 If given a numerical ARG, move forward ARG pages."
14300 (setq arg (if arg (prefix-numeric-value arg) 0))
14302 (set-buffer gnus-article-buffer)
14303 (goto-char (point-min))
14305 (when (gnus-visual-p 'page-marker)
14306 (let ((buffer-read-only nil))
14307 (gnus-remove-text-with-property 'gnus-prev)
14308 (gnus-remove-text-with-property 'gnus-next)))
14311 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14313 (re-search-forward page-delimiter nil 'move arg)))
14314 (goto-char (match-end 0)))
14317 (if (re-search-forward page-delimiter nil 'move)
14318 (match-beginning 0)
14320 (when (and (gnus-visual-p 'page-marker)
14321 (not (= (point-min) 1)))
14323 (goto-char (point-min))
14324 (gnus-insert-prev-page-button)))
14325 (when (and (gnus-visual-p 'page-marker)
14326 (not (= (1- (point-max)) (buffer-size))))
14328 (goto-char (point-max))
14329 (gnus-insert-next-page-button)))))
14331 ;; Article mode commands
14333 (defun gnus-article-goto-next-page ()
14334 "Show the next page of the article."
14336 (when (gnus-article-next-page)
14337 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14339 (defun gnus-article-goto-prev-page ()
14340 "Show the next page of the article."
14342 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14343 (gnus-article-prev-page nil)))
14345 (defun gnus-article-next-page (&optional lines)
14346 "Show the next page of the current article.
14347 If end of article, return non-nil. Otherwise return nil.
14348 Argument LINES specifies lines to be scrolled up."
14350 (move-to-window-line -1)
14351 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14352 (if (save-excursion
14354 (and (pos-visible-in-window-p) ;Not continuation line.
14356 ;; Nothing in this page.
14357 (if (or (not gnus-break-pages)
14360 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14362 (gnus-narrow-to-page 1) ;Go to next page.
14364 ;; More in this page.
14368 ;; Long lines may cause an end-of-buffer error.
14369 (goto-char (point-max))))
14370 (move-to-window-line 0)
14373 (defun gnus-article-prev-page (&optional lines)
14374 "Show previous page of current article.
14375 Argument LINES specifies lines to be scrolled down."
14377 (move-to-window-line 0)
14378 (if (and gnus-break-pages
14380 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14382 (gnus-narrow-to-page -1) ;Go to previous page.
14383 (goto-char (point-max))
14387 (scroll-down lines)
14389 (move-to-window-line 0))))
14391 (defun gnus-article-refer-article ()
14392 "Read article specified by message-id around point."
14394 (let ((point (point)))
14395 (search-forward ">" nil t) ;Move point to end of "<....>".
14396 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14397 (let ((message-id (match-string 1)))
14399 (set-buffer gnus-summary-buffer)
14400 (gnus-summary-refer-article message-id))
14401 (goto-char (point))
14402 (error "No references around point"))))
14404 (defun gnus-article-show-summary ()
14405 "Reconfigure windows to show summary buffer."
14407 (gnus-configure-windows 'article)
14408 (gnus-summary-goto-subject gnus-current-article))
14410 (defun gnus-article-describe-briefly ()
14411 "Describe article mode commands briefly."
14414 (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")))
14416 (defun gnus-article-summary-command ()
14417 "Execute the last keystroke in the summary buffer."
14419 (let ((obuf (current-buffer))
14420 (owin (current-window-configuration))
14422 (switch-to-buffer gnus-summary-buffer 'norecord)
14423 (setq func (lookup-key (current-local-map) (this-command-keys)))
14424 (call-interactively func)
14426 (set-window-configuration owin)
14427 (set-window-point (get-buffer-window (current-buffer)) (point))))
14429 (defun gnus-article-summary-command-nosave ()
14430 "Execute the last keystroke in the summary buffer."
14433 (pop-to-buffer gnus-summary-buffer 'norecord)
14434 (setq func (lookup-key (current-local-map) (this-command-keys)))
14435 (call-interactively func)))
14437 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14438 "Read a summary buffer key sequence and execute it from the article buffer."
14441 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14442 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14446 (set-buffer gnus-summary-buffer)
14447 (push (or key last-command-event) unread-command-events)
14448 (setq keys (read-key-sequence nil)))
14451 (if (member keys nosaves)
14453 (pop-to-buffer gnus-summary-buffer 'norecord)
14454 (if (setq func (lookup-key (current-local-map) keys))
14455 (call-interactively func)
14457 (let ((obuf (current-buffer))
14458 (owin (current-window-configuration))
14461 (if not-restore-window
14462 (pop-to-buffer gnus-summary-buffer 'norecord)
14463 (switch-to-buffer gnus-summary-buffer 'norecord))
14464 (setq in-buffer (current-buffer))
14465 (if (setq func (lookup-key (current-local-map) keys))
14466 (call-interactively func)
14468 (when (eq in-buffer (current-buffer))
14470 (unless not-restore-window
14471 (set-window-configuration owin))
14472 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14476 ;;; Kill file handling.
14480 (defalias 'gnus-batch-kill 'gnus-batch-score)
14482 (defun gnus-batch-score ()
14483 "Run batched scoring.
14484 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14485 Newsgroups is a list of strings in Bnews format. If you want to score
14486 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14487 score the alt hierarchy, you'd say \"!alt.all\"."
14490 (gnus-newsrc-parse-options
14491 (apply (function concat)
14492 (mapcar (lambda (g) (concat g " "))
14493 command-line-args-left))))
14494 (gnus-expert-user t)
14495 (nnmail-spool-file nil)
14496 (gnus-use-dribble-file nil)
14497 (yes (car yes-and-no))
14498 (no (cdr yes-and-no))
14500 ;; Disable verbose message.
14501 gnus-novice-user gnus-large-newsgroup)
14502 ;; Eat all arguments.
14503 (setq command-line-args-left nil)
14506 ;; Apply kills to specified newsgroups in command line arguments.
14507 (setq newsrc (cdr gnus-newsrc-alist))
14509 (setq group (caar newsrc))
14510 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14511 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14513 (or (eq (car entry) t)
14514 (not (zerop (car entry)))))
14515 (if yes (string-match yes group) t)
14516 (or (null no) (not (string-match no group))))
14518 (gnus-summary-read-group group nil t nil t)
14519 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14520 (gnus-summary-exit))))
14521 (setq newsrc (cdr newsrc)))
14523 (switch-to-buffer gnus-group-buffer)
14524 (gnus-group-save-newsrc)))
14526 (defun gnus-apply-kill-file ()
14527 "Apply a kill file to the current newsgroup.
14528 Returns the number of articles marked as read."
14529 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14530 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14531 (gnus-apply-kill-file-internal)
14534 (defun gnus-kill-save-kill-buffer ()
14535 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14536 (when (get-file-buffer file)
14538 (set-buffer (get-file-buffer file))
14539 (and (buffer-modified-p) (save-buffer))
14540 (kill-buffer (current-buffer))))))
14542 (defvar gnus-kill-file-name "KILL"
14543 "Suffix of the kill files.")
14545 (defun gnus-newsgroup-kill-file (newsgroup)
14546 "Return the name of a kill file name for NEWSGROUP.
14547 If NEWSGROUP is nil, return the global kill file name instead."
14549 ;; The global KILL file is placed at top of the directory.
14550 ((or (null newsgroup)
14551 (string-equal newsgroup ""))
14552 (expand-file-name gnus-kill-file-name
14553 (or gnus-kill-files-directory "~/News")))
14554 ;; Append ".KILL" to newsgroup name.
14555 ((gnus-use-long-file-name 'not-kill)
14556 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14557 "." gnus-kill-file-name)
14558 (or gnus-kill-files-directory "~/News")))
14559 ;; Place "KILL" under the hierarchical directory.
14561 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14562 "/" gnus-kill-file-name)
14563 (or gnus-kill-files-directory "~/News")))))
14570 (defvar gnus-dribble-ignore nil)
14571 (defvar gnus-dribble-eval-file nil)
14573 (defun gnus-dribble-file-name ()
14574 "Return the dribble file for the current .newsrc."
14576 (if gnus-dribble-directory
14577 (concat (file-name-as-directory gnus-dribble-directory)
14578 (file-name-nondirectory gnus-current-startup-file))
14579 gnus-current-startup-file)
14582 (defun gnus-dribble-enter (string)
14583 "Enter STRING into the dribble buffer."
14584 (if (and (not gnus-dribble-ignore)
14585 gnus-dribble-buffer
14586 (buffer-name gnus-dribble-buffer))
14587 (let ((obuf (current-buffer)))
14588 (set-buffer gnus-dribble-buffer)
14589 (insert string "\n")
14590 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14591 (set-buffer obuf))))
14593 (defun gnus-dribble-read-file ()
14594 "Read the dribble file from disk."
14595 (let ((dribble-file (gnus-dribble-file-name)))
14597 (set-buffer (setq gnus-dribble-buffer
14599 (file-name-nondirectory dribble-file))))
14600 (gnus-add-current-to-buffer-list)
14602 (setq buffer-file-name dribble-file)
14604 (buffer-disable-undo (current-buffer))
14605 (bury-buffer (current-buffer))
14606 (set-buffer-modified-p nil)
14607 (let ((auto (make-auto-save-file-name))
14608 (gnus-dribble-ignore t))
14609 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14610 ;; Load whichever file is newest -- the auto save file
14611 ;; or the "real" file.
14612 (if (file-newer-than-file-p auto dribble-file)
14613 (insert-file-contents auto)
14614 (insert-file-contents dribble-file))
14615 (unless (zerop (buffer-size))
14616 (set-buffer-modified-p t))
14617 ;; Set the file modes to reflect the .newsrc file modes.
14619 (when (file-exists-p gnus-current-startup-file)
14620 (set-file-modes dribble-file
14621 (file-modes gnus-current-startup-file)))
14622 ;; Possibly eval the file later.
14623 (when (gnus-y-or-n-p
14624 "Auto-save file exists. Do you want to read it? ")
14625 (setq gnus-dribble-eval-file t)))))))
14627 (defun gnus-dribble-eval-file ()
14628 (if (not gnus-dribble-eval-file)
14630 (setq gnus-dribble-eval-file nil)
14632 (let ((gnus-dribble-ignore t))
14633 (set-buffer gnus-dribble-buffer)
14634 (eval-buffer (current-buffer))))))
14636 (defun gnus-dribble-delete-file ()
14637 (if (file-exists-p (gnus-dribble-file-name))
14638 (delete-file (gnus-dribble-file-name)))
14639 (if gnus-dribble-buffer
14641 (set-buffer gnus-dribble-buffer)
14642 (let ((auto (make-auto-save-file-name)))
14643 (if (file-exists-p auto)
14644 (delete-file auto))
14646 (set-buffer-modified-p nil)))))
14648 (defun gnus-dribble-save ()
14649 (if (and gnus-dribble-buffer
14650 (buffer-name gnus-dribble-buffer))
14652 (set-buffer gnus-dribble-buffer)
14655 (defun gnus-dribble-clear ()
14657 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14659 (set-buffer gnus-dribble-buffer)
14661 (set-buffer-modified-p nil)
14662 (setq buffer-saved-size (buffer-size))))))
14666 ;;; Server Communication
14669 (defun gnus-start-news-server (&optional confirm)
14670 "Open a method for getting news.
14671 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14673 (if gnus-current-select-method
14674 ;; Stream is already opened.
14676 ;; Open NNTP server.
14677 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14680 ;; Read server name with completion.
14681 (setq gnus-nntp-server
14682 (completing-read "NNTP server: "
14683 (mapcar (lambda (server) (list server))
14684 (cons (list gnus-nntp-server)
14685 gnus-secondary-servers))
14686 nil nil gnus-nntp-server))))
14688 (if (and gnus-nntp-server
14689 (stringp gnus-nntp-server)
14690 (not (string= gnus-nntp-server "")))
14691 (setq gnus-select-method
14692 (cond ((or (string= gnus-nntp-server "")
14693 (string= gnus-nntp-server "::"))
14694 (list 'nnspool (system-name)))
14695 ((string-match "^:" gnus-nntp-server)
14696 (list 'nnmh gnus-nntp-server
14697 (list 'nnmh-directory
14698 (file-name-as-directory
14700 (concat "~/" (substring
14701 gnus-nntp-server 1)))))
14702 (list 'nnmh-get-new-mail nil)))
14704 (list 'nntp gnus-nntp-server)))))
14706 (setq how (car gnus-select-method))
14707 (cond ((eq how 'nnspool)
14709 (gnus-message 5 "Looking up local news spool..."))
14712 (gnus-message 5 "Looking up mh spool..."))
14715 (setq gnus-current-select-method gnus-select-method)
14716 (run-hooks 'gnus-open-server-hook)
14718 ;; gnus-open-server-hook might have opened it
14719 (gnus-server-opened gnus-select-method)
14720 (gnus-open-server gnus-select-method)
14723 "%s (%s) open error: '%s'. Continue? "
14724 (car gnus-select-method) (cadr gnus-select-method)
14725 (gnus-status-message gnus-select-method)))
14726 (gnus-error 1 "Couldn't open server on %s"
14727 (nth 1 gnus-select-method))))))
14729 (defun gnus-check-group (group)
14730 "Try to make sure that the server where GROUP exists is alive."
14731 (let ((method (gnus-find-method-for-group group)))
14732 (or (gnus-server-opened method)
14733 (gnus-open-server method))))
14735 (defun gnus-check-server (&optional method silent)
14736 "Check whether the connection to METHOD is down.
14737 If METHOD is nil, use `gnus-select-method'.
14738 If it is down, start it up (again)."
14739 (let ((method (or method gnus-select-method)))
14740 ;; Transform virtual server names into select methods.
14741 (when (stringp method)
14742 (setq method (gnus-server-to-method method)))
14743 (if (gnus-server-opened method)
14744 ;; The stream is already opened.
14746 ;; Open the server.
14748 (gnus-message 5 "Opening %s server%s..." (car method)
14749 (if (equal (nth 1 method) "") ""
14750 (format " on %s" (nth 1 method)))))
14751 (run-hooks 'gnus-open-server-hook)
14753 (gnus-open-server method)
14757 (defun gnus-get-function (method function)
14758 "Return a function symbol based on METHOD and FUNCTION."
14759 ;; Translate server names into methods.
14761 (error "Attempted use of a nil select method"))
14762 (when (stringp method)
14763 (setq method (gnus-server-to-method method)))
14764 (let ((func (intern (format "%s-%s" (car method) function))))
14765 ;; If the functions isn't bound, we require the backend in
14767 (unless (fboundp func)
14768 (require (car method))
14769 (unless (fboundp func)
14770 ;; This backend doesn't implement this function.
14771 (error "No such function: %s" func)))
14776 ;;; Interface functions to the backends.
14779 (defun gnus-open-server (method)
14780 "Open a connection to METHOD."
14781 (when (stringp method)
14782 (setq method (gnus-server-to-method method)))
14783 (let ((elem (assoc method gnus-opened-servers)))
14784 ;; If this method was previously denied, we just return nil.
14785 (if (eq (nth 1 elem) 'denied)
14787 (gnus-message 1 "Denied server")
14789 ;; Open the server.
14791 (funcall (gnus-get-function method 'open-server)
14792 (nth 1 method) (nthcdr 2 method))))
14793 ;; If this hasn't been opened before, we add it to the list.
14795 (setq elem (list method nil)
14796 gnus-opened-servers (cons elem gnus-opened-servers)))
14797 ;; Set the status of this server.
14798 (setcar (cdr elem) (if result 'ok 'denied))
14799 ;; Return the result from the "open" call.
14802 (defun gnus-close-server (method)
14803 "Close the connection to METHOD."
14804 (when (stringp method)
14805 (setq method (gnus-server-to-method method)))
14806 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14808 (defun gnus-request-list (method)
14809 "Request the active file from METHOD."
14810 (when (stringp method)
14811 (setq method (gnus-server-to-method method)))
14812 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14814 (defun gnus-request-list-newsgroups (method)
14815 "Request the newsgroups file from METHOD."
14816 (when (stringp method)
14817 (setq method (gnus-server-to-method method)))
14818 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14820 (defun gnus-request-newgroups (date method)
14821 "Request all new groups since DATE from METHOD."
14822 (when (stringp method)
14823 (setq method (gnus-server-to-method method)))
14824 (funcall (gnus-get-function method 'request-newgroups)
14825 date (nth 1 method)))
14827 (defun gnus-server-opened (method)
14828 "Check whether a connection to METHOD has been opened."
14829 (when (stringp method)
14830 (setq method (gnus-server-to-method method)))
14831 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14833 (defun gnus-status-message (method)
14834 "Return the status message from METHOD.
14835 If METHOD is a string, it is interpreted as a group name. The method
14836 this group uses will be queried."
14837 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14839 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14841 (defun gnus-request-group (group &optional dont-check method)
14842 "Request GROUP. If DONT-CHECK, no information is required."
14843 (let ((method (or method (gnus-find-method-for-group group))))
14844 (when (stringp method)
14845 (setq method (gnus-server-to-method method)))
14846 (funcall (gnus-get-function method 'request-group)
14847 (gnus-group-real-name group) (nth 1 method) dont-check)))
14849 (defun gnus-request-asynchronous (group &optional articles)
14850 "Request that GROUP behave asynchronously.
14851 ARTICLES is the `data' of the group."
14852 (let ((method (gnus-find-method-for-group group)))
14853 (funcall (gnus-get-function method 'request-asynchronous)
14854 (gnus-group-real-name group) (nth 1 method) articles)))
14856 (defun gnus-list-active-group (group)
14857 "Request active information on GROUP."
14858 (let ((method (gnus-find-method-for-group group))
14859 (func 'list-active-group))
14860 (when (gnus-check-backend-function func group)
14861 (funcall (gnus-get-function method func)
14862 (gnus-group-real-name group) (nth 1 method)))))
14864 (defun gnus-request-group-description (group)
14865 "Request a description of GROUP."
14866 (let ((method (gnus-find-method-for-group group))
14867 (func 'request-group-description))
14868 (when (gnus-check-backend-function func group)
14869 (funcall (gnus-get-function method func)
14870 (gnus-group-real-name group) (nth 1 method)))))
14872 (defun gnus-close-group (group)
14873 "Request the GROUP be closed."
14874 (let ((method (gnus-find-method-for-group group)))
14875 (funcall (gnus-get-function method 'close-group)
14876 (gnus-group-real-name group) (nth 1 method))))
14878 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14879 "Request headers for ARTICLES in GROUP.
14880 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14881 (let ((method (gnus-find-method-for-group group)))
14882 (if (and gnus-use-cache (numberp (car articles)))
14883 (gnus-cache-retrieve-headers articles group fetch-old)
14884 (funcall (gnus-get-function method 'retrieve-headers)
14885 articles (gnus-group-real-name group) (nth 1 method)
14888 (defun gnus-retrieve-groups (groups method)
14889 "Request active information on GROUPS from METHOD."
14890 (when (stringp method)
14891 (setq method (gnus-server-to-method method)))
14892 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14894 (defun gnus-request-type (group &optional article)
14895 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14896 (let ((method (gnus-find-method-for-group group)))
14897 (if (not (gnus-check-backend-function 'request-type (car method)))
14899 (funcall (gnus-get-function method 'request-type)
14900 (gnus-group-real-name group) article))))
14902 (defun gnus-request-update-mark (group article mark)
14903 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14904 (let ((method (gnus-find-method-for-group group)))
14905 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14907 (funcall (gnus-get-function method 'request-update-mark)
14908 (gnus-group-real-name group) article mark))))
14910 (defun gnus-request-article (article group &optional buffer)
14911 "Request the ARTICLE in GROUP.
14912 ARTICLE can either be an article number or an article Message-ID.
14913 If BUFFER, insert the article in that group."
14914 (let ((method (gnus-find-method-for-group group)))
14915 (funcall (gnus-get-function method 'request-article)
14916 article (gnus-group-real-name group) (nth 1 method) buffer)))
14918 (defun gnus-request-head (article group)
14919 "Request the head of ARTICLE in GROUP."
14920 (let ((method (gnus-find-method-for-group group)))
14921 (funcall (gnus-get-function method 'request-head)
14922 article (gnus-group-real-name group) (nth 1 method))))
14924 (defun gnus-request-body (article group)
14925 "Request the body of ARTICLE in GROUP."
14926 (let ((method (gnus-find-method-for-group group)))
14927 (funcall (gnus-get-function method 'request-body)
14928 article (gnus-group-real-name group) (nth 1 method))))
14930 (defun gnus-request-post (method)
14931 "Post the current buffer using METHOD."
14932 (when (stringp method)
14933 (setq method (gnus-server-to-method method)))
14934 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14936 (defun gnus-request-scan (group method)
14937 "Request a SCAN being performed in GROUP from METHOD.
14938 If GROUP is nil, all groups on METHOD are scanned."
14939 (let ((method (if group (gnus-find-method-for-group group) method)))
14940 (funcall (gnus-get-function method 'request-scan)
14941 (and group (gnus-group-real-name group)) (nth 1 method))))
14943 (defsubst gnus-request-update-info (info method)
14944 "Request that METHOD update INFO."
14945 (when (stringp method)
14946 (setq method (gnus-server-to-method method)))
14947 (when (gnus-check-backend-function 'request-update-info (car method))
14948 (funcall (gnus-get-function method 'request-update-info)
14949 (gnus-group-real-name (gnus-info-group info))
14950 info (nth 1 method))))
14952 (defun gnus-request-expire-articles (articles group &optional force)
14953 (let ((method (gnus-find-method-for-group group)))
14954 (funcall (gnus-get-function method 'request-expire-articles)
14955 articles (gnus-group-real-name group) (nth 1 method)
14958 (defun gnus-request-move-article
14959 (article group server accept-function &optional last)
14960 (let ((method (gnus-find-method-for-group group)))
14961 (funcall (gnus-get-function method 'request-move-article)
14962 article (gnus-group-real-name group)
14963 (nth 1 method) accept-function last)))
14965 (defun gnus-request-accept-article (group method &optional last)
14966 ;; Make sure there's a newline at the end of the article.
14967 (when (stringp method)
14968 (setq method (gnus-server-to-method method)))
14969 (when (and (not method)
14971 (setq method (gnus-find-method-for-group group)))
14972 (goto-char (point-max))
14975 (let ((func (car (or method (gnus-find-method-for-group group)))))
14976 (funcall (intern (format "%s-request-accept-article" func))
14977 (if (stringp group) (gnus-group-real-name group) group)
14981 (defun gnus-request-replace-article (article group buffer)
14982 (let ((func (car (gnus-find-method-for-group group))))
14983 (funcall (intern (format "%s-request-replace-article" func))
14984 article (gnus-group-real-name group) buffer)))
14986 (defun gnus-request-associate-buffer (group)
14987 (let ((method (gnus-find-method-for-group group)))
14988 (funcall (gnus-get-function method 'request-associate-buffer)
14989 (gnus-group-real-name group))))
14991 (defun gnus-request-restore-buffer (article group)
14992 "Request a new buffer restored to the state of ARTICLE."
14993 (let ((method (gnus-find-method-for-group group)))
14994 (funcall (gnus-get-function method 'request-restore-buffer)
14995 article (gnus-group-real-name group) (nth 1 method))))
14997 (defun gnus-request-create-group (group &optional method)
14998 (when (stringp method)
14999 (setq method (gnus-server-to-method method)))
15000 (let ((method (or method (gnus-find-method-for-group group))))
15001 (funcall (gnus-get-function method 'request-create-group)
15002 (gnus-group-real-name group) (nth 1 method))))
15004 (defun gnus-request-delete-group (group &optional force)
15005 (let ((method (gnus-find-method-for-group group)))
15006 (funcall (gnus-get-function method 'request-delete-group)
15007 (gnus-group-real-name group) force (nth 1 method))))
15009 (defun gnus-request-rename-group (group new-name)
15010 (let ((method (gnus-find-method-for-group group)))
15011 (funcall (gnus-get-function method 'request-rename-group)
15012 (gnus-group-real-name group)
15013 (gnus-group-real-name new-name) (nth 1 method))))
15015 (defun gnus-member-of-valid (symbol group)
15016 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15017 (memq symbol (assoc
15018 (symbol-name (car (gnus-find-method-for-group group)))
15019 gnus-valid-select-methods)))
15021 (defun gnus-method-option-p (method option)
15022 "Return non-nil if select METHOD has OPTION as a parameter."
15023 (when (stringp method)
15024 (setq method (gnus-server-to-method method)))
15025 (memq option (assoc (format "%s" (car method))
15026 gnus-valid-select-methods)))
15028 (defun gnus-server-extend-method (group method)
15029 ;; This function "extends" a virtual server. If the server is
15030 ;; "hello", and the select method is ("hello" (my-var "something"))
15031 ;; in the group "alt.alt", this will result in a new virtual server
15032 ;; called "hello+alt.alt".
15034 (gnus-copy-sequence
15035 (if (equal (car method) "native") gnus-select-method
15036 (cdr (assoc (car method) gnus-server-alist))))))
15037 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15038 (nconc entry (cdr method))))
15040 (defun gnus-find-method-for-group (group &optional info)
15041 "Find the select method that GROUP uses."
15042 (or gnus-override-method
15044 gnus-select-method)
15045 (let ((info (or info (gnus-get-info group)))
15048 (not (setq method (gnus-info-method info)))
15049 (equal method "native"))
15052 (cond ((stringp method)
15053 (gnus-server-to-method method))
15054 ((stringp (car method))
15055 (gnus-server-extend-method group method))
15058 (cond ((equal (cadr method) "")
15060 ((null (cadr method))
15061 (list (car method) ""))
15063 (gnus-server-add-address method)))))))
15065 (defun gnus-check-backend-function (func group)
15066 "Check whether GROUP supports function FUNC."
15067 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15069 (fboundp (intern (format "%s-%s" method func)))))
15071 (defun gnus-methods-using (feature)
15072 "Find all methods that have FEATURE."
15073 (let ((valids gnus-valid-select-methods)
15076 (if (memq feature (car valids))
15077 (setq outs (cons (car valids) outs)))
15078 (setq valids (cdr valids)))
15083 ;;; Active & Newsrc File Handling
15086 (defun gnus-setup-news (&optional rawfile level dont-connect)
15087 "Setup news information.
15088 If RAWFILE is non-nil, the .newsrc file will also be read.
15089 If LEVEL is non-nil, the news will be set up at level LEVEL."
15090 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15093 ;; Clear some variables to re-initialize news information.
15094 (setq gnus-newsrc-alist nil
15095 gnus-active-hashtb nil)
15096 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15097 (gnus-read-newsrc-file rawfile))
15099 (when (and (not (assoc "archive" gnus-server-alist))
15100 gnus-message-archive-method)
15101 (push (cons "archive" gnus-message-archive-method)
15102 gnus-server-alist))
15104 ;; If we don't read the complete active file, we fill in the
15106 (if (or (null gnus-read-active-file)
15107 (eq gnus-read-active-file 'some))
15108 (gnus-update-active-hashtb-from-killed))
15110 ;; Read the active file and create `gnus-active-hashtb'.
15111 ;; If `gnus-read-active-file' is nil, then we just create an empty
15112 ;; hash table. The partial filling out of the hash table will be
15113 ;; done in `gnus-get-unread-articles'.
15114 (and gnus-read-active-file
15116 (gnus-read-active-file))
15118 (or gnus-active-hashtb
15119 (setq gnus-active-hashtb (make-vector 4095 0)))
15121 ;; Initialize the cache.
15122 (when gnus-use-cache
15125 ;; Possibly eval the dribble file.
15126 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15128 (gnus-update-format-specifications)
15130 ;; See whether we need to read the description file.
15131 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15132 (not gnus-description-hashtb)
15134 gnus-read-active-file)
15135 (gnus-read-all-descriptions-files))
15137 ;; Find new newsgroups and treat them.
15138 (if (and init gnus-check-new-newsgroups (not level)
15139 (gnus-check-server gnus-select-method))
15140 (gnus-find-new-newsgroups))
15142 ;; We might read in new NoCeM messages here.
15143 (when (and gnus-use-nocem
15145 (not dont-connect))
15146 (gnus-nocem-scan-groups))
15148 ;; Find the number of unread articles in each non-dead group.
15149 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15150 (gnus-get-unread-articles level))
15152 (if (and init gnus-check-bogus-newsgroups
15153 gnus-read-active-file (not level)
15154 (gnus-server-opened gnus-select-method))
15155 (gnus-check-bogus-newsgroups))))
15157 (defun gnus-find-new-newsgroups (&optional arg)
15158 "Search for new newsgroups and add them.
15159 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15160 The `-n' option line from .newsrc is respected.
15161 If ARG (the prefix), use the `ask-server' method to query
15162 the server for new groups."
15164 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15165 (null gnus-read-active-file)
15166 (eq gnus-read-active-file 'some))
15167 'ask-server gnus-check-new-newsgroups)))
15168 (unless (gnus-check-first-time-used)
15169 (if (or (consp check)
15170 (eq check 'ask-server))
15171 ;; Ask the server for new groups.
15172 (gnus-ask-server-for-new-groups)
15173 ;; Go through the active hashtb and look for new groups.
15175 group new-newsgroups)
15176 (gnus-message 5 "Looking for new newsgroups...")
15177 (unless gnus-have-read-active-file
15178 (gnus-read-active-file))
15179 (setq gnus-newsrc-last-checked-date (current-time-string))
15180 (unless gnus-killed-hashtb
15181 (gnus-make-hashtable-from-killed))
15182 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15183 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15186 (if (or (null (setq group (symbol-name sym)))
15188 (null (symbol-value sym))
15189 (gnus-gethash group gnus-killed-hashtb)
15190 (gnus-gethash group gnus-newsrc-hashtb))
15192 (let ((do-sub (gnus-matches-options-n group)))
15194 ((eq do-sub 'subscribe)
15195 (setq groups (1+ groups))
15196 (gnus-sethash group group gnus-killed-hashtb)
15197 (funcall gnus-subscribe-options-newsgroup-method group))
15198 ((eq do-sub 'ignore)
15201 (setq groups (1+ groups))
15202 (gnus-sethash group group gnus-killed-hashtb)
15203 (if gnus-subscribe-hierarchical-interactive
15204 (setq new-newsgroups (cons group new-newsgroups))
15205 (funcall gnus-subscribe-newsgroup-method group)))))))
15206 gnus-active-hashtb)
15207 (when new-newsgroups
15208 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15209 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15211 (gnus-message 6 "%d new newsgroup%s arrived."
15212 groups (if (> groups 1) "s have" " has"))
15213 (gnus-message 6 "No new newsgroups.")))))))
15215 (defun gnus-matches-options-n (group)
15216 ;; Returns `subscribe' if the group is to be unconditionally
15217 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15218 ;; no match for the group.
15220 ;; First we check the two user variables.
15222 ((and gnus-options-subscribe
15223 (string-match gnus-options-subscribe group))
15225 ((and gnus-auto-subscribed-groups
15226 (string-match gnus-auto-subscribed-groups group))
15228 ((and gnus-options-not-subscribe
15229 (string-match gnus-options-not-subscribe group))
15231 ;; Then we go through the list that was retrieved from the .newsrc
15232 ;; file. This list has elements on the form
15233 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15234 ;; is in the reverse order of the options line) is returned.
15236 (let ((regs gnus-newsrc-options-n))
15238 (not (string-match (caar regs) group)))
15239 (setq regs (cdr regs)))
15240 (and regs (cdar regs))))))
15242 (defun gnus-ask-server-for-new-groups ()
15243 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15244 (methods (cons gnus-select-method
15246 (when gnus-message-archive-method
15249 (and (consp gnus-check-new-newsgroups)
15250 gnus-check-new-newsgroups)
15251 gnus-secondary-select-methods))))
15253 (new-date (current-time-string))
15254 group new-newsgroups got-new method hashtb
15255 gnus-override-subscribe-method)
15256 ;; Go through both primary and secondary select methods and
15257 ;; request new newsgroups.
15258 (while (setq method (gnus-server-get-method nil (pop methods)))
15259 (setq new-newsgroups nil)
15260 (setq gnus-override-subscribe-method method)
15261 (when (and (gnus-check-server method)
15262 (gnus-request-newgroups date method))
15265 (setq hashtb (gnus-make-hashtable 100))
15266 (set-buffer nntp-server-buffer)
15267 ;; Enter all the new groups into a hashtable.
15268 (gnus-active-to-gnus-format method hashtb 'ignore))
15269 ;; Now all new groups from `method' are in `hashtb'.
15271 (lambda (group-sym)
15272 (if (or (null (setq group (symbol-name group-sym)))
15273 (not (boundp group-sym))
15274 (null (symbol-value group-sym))
15275 (gnus-gethash group gnus-newsrc-hashtb)
15276 (member group gnus-zombie-list)
15277 (member group gnus-killed-list))
15278 ;; The group is already known.
15280 ;; Make this group active.
15281 (when (symbol-value group-sym)
15282 (gnus-set-active group (symbol-value group-sym)))
15283 ;; Check whether we want it or not.
15284 (let ((do-sub (gnus-matches-options-n group)))
15286 ((eq do-sub 'subscribe)
15288 (gnus-sethash group group gnus-killed-hashtb)
15289 (funcall gnus-subscribe-options-newsgroup-method group))
15290 ((eq do-sub 'ignore)
15294 (gnus-sethash group group gnus-killed-hashtb)
15295 (if gnus-subscribe-hierarchical-interactive
15296 (push group new-newsgroups)
15297 (funcall gnus-subscribe-newsgroup-method group)))))))
15299 (when new-newsgroups
15300 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15301 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15303 (gnus-message 6 "%d new newsgroup%s arrived."
15304 groups (if (> groups 1) "s have" " has")))
15305 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15308 (defun gnus-check-first-time-used ()
15309 (if (or (> (length gnus-newsrc-alist) 1)
15310 (file-exists-p gnus-startup-file)
15311 (file-exists-p (concat gnus-startup-file ".el"))
15312 (file-exists-p (concat gnus-startup-file ".eld")))
15314 (gnus-message 6 "First time user; subscribing you to default groups")
15315 (unless gnus-have-read-active-file
15316 (gnus-read-active-file))
15317 (setq gnus-newsrc-last-checked-date (current-time-string))
15318 (let ((groups gnus-default-subscribed-newsgroups)
15322 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15325 (if (null (setq group (symbol-name sym)))
15327 (let ((do-sub (gnus-matches-options-n group)))
15329 ((eq do-sub 'subscribe)
15330 (gnus-sethash group group gnus-killed-hashtb)
15331 (funcall gnus-subscribe-options-newsgroup-method group))
15332 ((eq do-sub 'ignore)
15335 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15336 gnus-active-hashtb)
15338 (if (gnus-active (car groups))
15339 (gnus-group-change-level
15340 (car groups) gnus-level-default-subscribed gnus-level-killed))
15341 (setq groups (cdr groups)))
15342 (gnus-group-make-help-group)
15343 (and gnus-novice-user
15344 (gnus-message 7 "`A k' to list killed groups"))))))
15346 (defun gnus-subscribe-group (group previous &optional method)
15347 (gnus-group-change-level
15349 (list t group gnus-level-default-subscribed nil nil method)
15351 gnus-level-default-subscribed gnus-level-killed previous t))
15353 ;; `gnus-group-change-level' is the fundamental function for changing
15354 ;; subscription levels of newsgroups. This might mean just changing
15355 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15356 ;; again, which subscribes/unsubscribes a group, which is equally
15357 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15358 ;; from 8-9 to 1-7 means that you remove the group from the list of
15359 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15360 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15361 ;; which is trivial.
15362 ;; ENTRY can either be a string (newsgroup name) or a list (if
15363 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15364 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15366 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15367 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15369 (defun gnus-group-change-level (entry level &optional oldlevel
15370 previous fromkilled)
15371 (let (group info active num)
15372 ;; Glean what info we can from the arguments
15374 (if fromkilled (setq group (nth 1 entry))
15375 (setq group (car (nth 2 entry))))
15376 (setq group entry))
15377 (if (and (stringp entry)
15379 (< oldlevel gnus-level-zombie))
15380 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15381 (if (and (not oldlevel)
15383 (setq oldlevel (gnus-info-level (nth 2 entry)))
15384 (setq oldlevel (or oldlevel 9)))
15385 (if (stringp previous)
15386 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15388 (if (and (>= oldlevel gnus-level-zombie)
15389 (gnus-gethash group gnus-newsrc-hashtb))
15390 ;; We are trying to subscribe a group that is already
15394 (or (gnus-ephemeral-group-p group)
15395 (gnus-dribble-enter
15396 (format "(gnus-group-change-level %S %S %S %S %S)"
15397 group level oldlevel (car (nth 2 previous)) fromkilled)))
15399 ;; Then we remove the newgroup from any old structures, if needed.
15400 ;; If the group was killed, we remove it from the killed or zombie
15401 ;; list. If not, and it is in fact going to be killed, we remove
15402 ;; it from the newsrc hash table and assoc.
15404 ((>= oldlevel gnus-level-zombie)
15405 (if (= oldlevel gnus-level-zombie)
15406 (setq gnus-zombie-list (delete group gnus-zombie-list))
15407 (setq gnus-killed-list (delete group gnus-killed-list))))
15409 (if (and (>= level gnus-level-zombie)
15412 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15414 (setcdr (gnus-gethash (car (nth 3 entry))
15415 gnus-newsrc-hashtb)
15417 (setcdr (cdr entry) (cdddr entry))))))
15419 ;; Finally we enter (if needed) the list where it is supposed to
15420 ;; go, and change the subscription level. If it is to be killed,
15421 ;; we enter it into the killed or zombie list.
15423 ((>= level gnus-level-zombie)
15424 ;; Remove from the hash table.
15425 (gnus-sethash group nil gnus-newsrc-hashtb)
15426 ;; We do not enter foreign groups into the list of dead
15428 (unless (gnus-group-foreign-p group)
15429 (if (= level gnus-level-zombie)
15430 (setq gnus-zombie-list (cons group gnus-zombie-list))
15431 (setq gnus-killed-list (cons group gnus-killed-list)))))
15433 ;; If the list is to be entered into the newsrc assoc, and
15434 ;; it was killed, we have to create an entry in the newsrc
15435 ;; hashtb format and fix the pointers in the newsrc assoc.
15436 (if (< oldlevel gnus-level-zombie)
15437 ;; It was alive, and it is going to stay alive, so we
15438 ;; just change the level and don't change any pointers or
15439 ;; hash table entries.
15440 (setcar (cdaddr entry) level)
15442 (setq info (cdr entry)
15444 (setq active (gnus-active group))
15446 (if active (- (1+ (cdr active)) (car active)) t))
15447 ;; Check whether the group is foreign. If so, the
15448 ;; foreign select method has to be entered into the
15450 (let ((method (or gnus-override-subscribe-method
15451 (gnus-group-method group))))
15452 (if (eq method gnus-select-method)
15453 (setq info (list group level nil))
15454 (setq info (list group level nil nil method)))))
15457 (let ((p gnus-newsrc-alist))
15461 (setq entry (cons info (cddr previous)))
15464 (setcdr (cdr previous) entry)
15465 (gnus-sethash group (cons num (cdr previous))
15466 gnus-newsrc-hashtb))
15467 (setcdr previous entry)
15468 (gnus-sethash group (cons num previous)
15469 gnus-newsrc-hashtb))
15471 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15472 (when gnus-group-change-level-function
15473 (funcall gnus-group-change-level-function group level oldlevel)))))
15475 (defun gnus-kill-newsgroup (newsgroup)
15476 "Obsolete function. Kills a newsgroup."
15477 (gnus-group-change-level
15478 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15480 (defun gnus-check-bogus-newsgroups (&optional confirm)
15481 "Remove bogus newsgroups.
15482 If CONFIRM is non-nil, the user has to confirm the deletion of every
15484 (let ((newsrc (cdr gnus-newsrc-alist))
15485 bogus group entry info)
15486 (gnus-message 5 "Checking bogus newsgroups...")
15487 (unless gnus-have-read-active-file
15488 (gnus-read-active-file))
15489 (when (member gnus-select-method gnus-have-read-active-file)
15490 ;; Find all bogus newsgroup that are subscribed.
15492 (setq info (pop newsrc)
15493 group (gnus-info-group info))
15494 (unless (or (gnus-active group) ; Active
15495 (gnus-info-method info) ; Foreign
15497 (not (gnus-y-or-n-p
15498 (format "Remove bogus newsgroup: %s " group)))))
15499 ;; Found a bogus newsgroup.
15500 (push group bogus)))
15501 ;; Remove all bogus subscribed groups by first killing them, and
15502 ;; then removing them from the list of killed groups.
15504 (when (setq entry (gnus-gethash (setq group (pop bogus))
15505 gnus-newsrc-hashtb))
15506 (gnus-group-change-level entry gnus-level-killed)
15507 (setq gnus-killed-list (delete group gnus-killed-list))))
15508 ;; Then we remove all bogus groups from the list of killed and
15509 ;; zombie groups. They are are removed without confirmation.
15510 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15513 (setq killed (symbol-value (car dead-lists)))
15515 (unless (gnus-active (setq group (pop killed)))
15516 ;; The group is bogus.
15517 ;; !!!Slow as hell.
15518 (set (car dead-lists)
15519 (delete group (symbol-value (car dead-lists))))))
15520 (setq dead-lists (cdr dead-lists))))
15521 (gnus-message 5 "Checking bogus newsgroups...done"))))
15523 (defun gnus-check-duplicate-killed-groups ()
15524 "Remove duplicates from the list of killed groups."
15526 (let ((killed gnus-killed-list))
15528 (gnus-message 9 "%d" (length killed))
15529 (setcdr killed (delete (car killed) (cdr killed)))
15530 (setq killed (cdr killed)))))
15532 ;; We want to inline a function from gnus-cache, so we cheat here:
15535 (require 'gnus-cache))
15537 (defun gnus-get-unread-articles-in-group (info active &optional update)
15539 ;; Allow the backend to update the info in the group.
15541 (gnus-request-update-info
15542 info (gnus-find-method-for-group (gnus-info-group info))))
15543 (gnus-activate-group (gnus-info-group info) nil t))
15544 (let* ((range (gnus-info-read info))
15546 ;; If a cache is present, we may have to alter the active info.
15547 (when (and gnus-use-cache info)
15548 (inline (gnus-cache-possibly-alter-active
15549 (gnus-info-group info) active)))
15550 ;; Modify the list of read articles according to what articles
15551 ;; are available; then tally the unread articles and add the
15552 ;; number to the group hash table entry.
15554 ((zerop (cdr active))
15557 (setq num (- (1+ (cdr active)) (car active))))
15558 ((not (listp (cdr range)))
15559 ;; Fix a single (num . num) range according to the
15560 ;; active hash table.
15561 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15562 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15563 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15564 ;; Compute number of unread articles.
15565 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15567 ;; The read list is a list of ranges. Fix them according to
15568 ;; the active hash table.
15569 ;; First peel off any elements that are below the lower
15571 (while (and (cdr range)
15573 (or (and (atom (cadr range)) (cadr range))
15575 (if (numberp (car range))
15578 (or (and (numberp (cadr range))
15581 (setcdr (car range)
15582 (or (and (numberp (nth 1 range)) (nth 1 range))
15584 (setcdr range (cddr range)))
15585 ;; Adjust the first element to be the same as the lower limit.
15586 (if (and (not (atom (car range)))
15587 (< (cdar range) (car active)))
15588 (setcdr (car range) (1- (car active))))
15589 ;; Then we want to peel off any elements that are higher
15590 ;; than the upper active limit.
15591 (let ((srange range))
15592 ;; Go past all legal elements.
15593 (while (and (cdr srange)
15594 (<= (or (and (atom (cadr srange))
15596 (caadr srange)) (cdr active)))
15597 (setq srange (cdr srange)))
15599 ;; Nuke all remaining illegal elements.
15600 (setcdr srange nil))
15602 ;; Adjust the final element.
15603 (if (and (not (atom (car srange)))
15604 (> (cdar srange) (cdr active)))
15605 (setcdr (car srange) (cdr active))))
15606 ;; Compute the number of unread articles.
15608 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15610 (or (and (atom (car range)) (car range))
15612 (setq range (cdr range)))
15613 (setq num (max 0 (- (cdr active) num)))))
15614 ;; Set the number of unread articles.
15616 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15619 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15620 ;; and compute how many unread articles there are in each group.
15621 (defun gnus-get-unread-articles (&optional level)
15622 (let* ((newsrc (cdr gnus-newsrc-alist))
15623 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15626 (cond ((and gnus-activate-foreign-newsgroups
15627 (not (numberp gnus-activate-foreign-newsgroups)))
15628 (1+ gnus-level-subscribed))
15629 ((numberp gnus-activate-foreign-newsgroups)
15630 gnus-activate-foreign-newsgroups)
15633 info group active method)
15634 (gnus-message 5 "Checking new news...")
15637 (setq active (gnus-active (setq group (gnus-info-group
15638 (setq info (pop newsrc))))))
15640 ;; Check newsgroups. If the user doesn't want to check them, or
15641 ;; they can't be checked (for instance, if the news server can't
15642 ;; be reached) we just set the number of unread articles in this
15643 ;; newsgroup to t. This means that Gnus thinks that there are
15644 ;; unread articles, but it has no idea how many.
15645 (if (and (setq method (gnus-info-method info))
15646 (not (gnus-server-equal
15648 (setq method (gnus-server-get-method nil method))))
15649 (not (gnus-secondary-method-p method)))
15650 ;; These groups are foreign. Check the level.
15651 (when (<= (gnus-info-level info) foreign-level)
15652 (setq active (gnus-activate-group group 'scan))
15653 (unless (inline (gnus-virtual-group-p group))
15654 (inline (gnus-close-group group))))
15656 ;; These groups are native or secondary.
15657 (when (and (<= (gnus-info-level info) level)
15658 (not gnus-read-active-file))
15659 (setq active (gnus-activate-group group 'scan))
15660 (inline (gnus-close-group group))))
15663 (inline (gnus-get-unread-articles-in-group
15666 (fboundp (intern (concat (symbol-name (car method))
15667 "-request-update-info"))))))
15668 ;; The group couldn't be reached, so we nix out the number of
15669 ;; unread articles and stuff.
15670 (gnus-set-active group nil)
15671 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15673 (gnus-message 5 "Checking new news...done")))
15675 ;; Create a hash table out of the newsrc alist. The `car's of the
15676 ;; alist elements are used as keys.
15677 (defun gnus-make-hashtable-from-newsrc-alist ()
15678 (let ((alist gnus-newsrc-alist)
15679 (ohashtb gnus-newsrc-hashtb)
15681 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15683 (setq prev (setq gnus-newsrc-alist
15684 (if (equal (caar gnus-newsrc-alist)
15687 (cons (list "dummy.group" 0 nil) alist)))))
15691 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15693 gnus-newsrc-hashtb)
15695 alist (cdr alist)))))
15697 (defun gnus-make-hashtable-from-killed ()
15698 "Create a hash table from the killed and zombie lists."
15699 (let ((lists '(gnus-killed-list gnus-zombie-list))
15701 (setq gnus-killed-hashtb
15702 (gnus-make-hashtable
15703 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15704 (while (setq list (pop lists))
15705 (setq list (symbol-value list))
15707 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15709 (defun gnus-activate-group (group &optional scan dont-check)
15710 ;; Check whether a group has been activated or not.
15711 ;; If SCAN, request a scan of that group as well.
15712 (let ((method (gnus-find-method-for-group group))
15714 (and (gnus-check-server method)
15715 ;; We escape all bugs and quit here to make it possible to
15716 ;; continue if a group is so out-there that it reports bugs
15720 (gnus-check-backend-function 'request-scan (car method))
15721 (gnus-request-scan group method))
15724 (gnus-request-group group dont-check)
15728 (set-buffer nntp-server-buffer)
15729 (goto-char (point-min))
15730 ;; Parse the result we got from `gnus-request-group'.
15731 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15733 (goto-char (match-beginning 1))
15735 group (setq active (cons (read (current-buffer))
15736 (read (current-buffer)))))
15737 ;; Return the new active info.
15740 (defun gnus-update-read-articles (group unread)
15741 "Update the list of read and ticked articles in GROUP using the
15742 UNREAD and TICKED lists.
15743 Note: UNSELECTED has to be sorted over `<'.
15744 Returns whether the updating was successful."
15745 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15746 (entry (gnus-gethash group gnus-newsrc-hashtb))
15747 (info (nth 2 entry))
15749 (unread (sort (copy-sequence unread) '<))
15751 (if (or (not info) (not active))
15752 ;; There is no info on this group if it was, in fact,
15753 ;; killed. Gnus stores no information on killed groups, so
15754 ;; there's nothing to be done.
15755 ;; One could store the information somewhere temporarily,
15756 ;; perhaps... Hmmm...
15758 ;; Remove any negative articles numbers.
15759 (while (and unread (< (car unread) 0))
15760 (setq unread (cdr unread)))
15761 ;; Remove any expired article numbers
15762 (while (and unread (< (car unread) (car active)))
15763 (setq unread (cdr unread)))
15764 ;; Compute the ranges of read articles by looking at the list of
15765 ;; unread articles.
15767 (if (/= (car unread) prev)
15768 (setq read (cons (if (= prev (1- (car unread))) prev
15769 (cons prev (1- (car unread)))) read)))
15770 (setq prev (1+ (car unread)))
15771 (setq unread (cdr unread)))
15772 (when (<= prev (cdr active))
15773 (setq read (cons (cons prev (cdr active)) read)))
15774 ;; Enter this list into the group info.
15775 (gnus-info-set-read
15776 info (if (> (length read) 1) (nreverse read) read))
15777 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15778 (gnus-get-unread-articles-in-group info (gnus-active group))
15781 (defun gnus-make-articles-unread (group articles)
15782 "Mark ARTICLES in GROUP as unread."
15783 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15784 (gnus-gethash (gnus-group-real-name group)
15785 gnus-newsrc-hashtb))))
15786 (ranges (gnus-info-read info))
15789 (when (gnus-member-of-range
15790 (setq article (pop articles)) ranges)
15791 (setq news (cons article news))))
15793 (gnus-info-set-read
15794 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15795 (gnus-group-update-group group t))))
15797 ;; Enter all dead groups into the hashtb.
15798 (defun gnus-update-active-hashtb-from-killed ()
15799 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15800 (lists (list gnus-killed-list gnus-zombie-list))
15803 (setq killed (car lists))
15805 (gnus-sethash (car killed) nil hashtb)
15806 (setq killed (cdr killed)))
15807 (setq lists (cdr lists)))))
15809 ;; Get the active file(s) from the backend(s).
15810 (defun gnus-read-active-file ()
15811 (gnus-group-set-mode-line)
15814 (if (gnus-check-server gnus-select-method)
15815 ;; The native server is available.
15816 (cons gnus-select-method gnus-secondary-select-methods)
15817 ;; The native server is down, so we just do the
15819 gnus-secondary-select-methods)
15820 ;; Also read from the archive server.
15821 (when gnus-message-archive-method
15822 (list "archive"))))
15824 (setq gnus-have-read-active-file nil)
15826 (set-buffer nntp-server-buffer)
15828 (let* ((method (if (stringp (car methods))
15829 (gnus-server-get-method nil (car methods))
15831 (where (nth 1 method))
15832 (mesg (format "Reading active file%s via %s..."
15833 (if (and where (not (zerop (length where))))
15834 (concat " from " where) "")
15836 (gnus-message 5 mesg)
15837 (when (gnus-check-server method)
15838 ;; Request that the backend scan its incoming messages.
15839 (and (gnus-check-backend-function 'request-scan (car method))
15840 (gnus-request-scan nil method))
15842 ((and (eq gnus-read-active-file 'some)
15843 (gnus-check-backend-function 'retrieve-groups (car method)))
15844 (let ((newsrc (cdr gnus-newsrc-alist))
15845 (gmethod (gnus-server-get-method nil method))
15847 (while (setq info (pop newsrc))
15848 (when (gnus-server-equal
15849 (gnus-find-method-for-group
15850 (gnus-info-group info) info)
15852 (push (gnus-group-real-name (gnus-info-group info))
15855 (gnus-check-server method)
15856 (setq list-type (gnus-retrieve-groups groups method))
15860 1.2 "Cannot read partial active file from %s server."
15862 ((eq list-type 'active)
15863 (gnus-active-to-gnus-format method gnus-active-hashtb))
15865 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15867 (if (not (gnus-request-list method))
15868 (unless (equal method gnus-message-archive-method)
15869 (gnus-error 1 "Cannot read active file from %s server."
15871 (gnus-active-to-gnus-format method gnus-active-hashtb)
15872 ;; We mark this active file as read.
15873 (push method gnus-have-read-active-file)
15874 (gnus-message 5 "%sdone" mesg))))))
15875 (setq methods (cdr methods))))))
15877 ;; Read an active file and place the results in `gnus-active-hashtb'.
15878 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15880 (setq method gnus-select-method))
15881 (let ((cur (current-buffer))
15883 (if (and gnus-active-hashtb
15884 (not (equal method gnus-select-method)))
15886 (setq gnus-active-hashtb
15887 (if (equal method gnus-select-method)
15888 (gnus-make-hashtable
15889 (count-lines (point-min) (point-max)))
15890 (gnus-make-hashtable 4096)))))))
15891 ;; Delete unnecessary lines.
15892 (goto-char (point-min))
15893 (while (search-forward "\nto." nil t)
15894 (delete-region (1+ (match-beginning 0))
15895 (progn (forward-line 1) (point))))
15896 (or (string= gnus-ignored-newsgroups "")
15898 (goto-char (point-min))
15899 (delete-matching-lines gnus-ignored-newsgroups)))
15900 ;; Make the group names readable as a lisp expression even if they
15901 ;; contain special characters.
15902 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15903 (goto-char (point-max))
15904 (while (re-search-backward "[][';?()#]" nil t)
15906 ;; If these are groups from a foreign select method, we insert the
15907 ;; group prefix in front of the group names.
15908 (and method (not (gnus-server-equal
15909 (gnus-server-get-method nil method)
15910 (gnus-server-get-method nil gnus-select-method)))
15911 (let ((prefix (gnus-group-prefixed-name "" method)))
15912 (goto-char (point-min))
15913 (while (and (not (eobp))
15914 (progn (insert prefix)
15915 (zerop (forward-line 1)))))))
15916 ;; Store the active file in a hash table.
15917 (goto-char (point-min))
15918 (if (string-match "%[oO]" gnus-group-line-format)
15919 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15920 ;; If we want information on moderated groups, we use this
15922 (let* ((mod-hashtb (make-vector 7 0))
15923 (m (intern "m" mod-hashtb))
15925 (while (not (eobp))
15926 (condition-case nil
15928 (narrow-to-region (point) (gnus-point-at-eol))
15929 (setq group (let ((obarray hashtb)) (read cur)))
15930 (if (and (numberp (setq max (read cur)))
15931 (numberp (setq min (read cur)))
15933 (skip-chars-forward " \t")
15935 (or (= (following-char) ?=)
15936 (= (following-char) ?x)
15937 (= (following-char) ?j)))))
15938 (set group (cons min max))
15940 ;; Enter moderated groups into a list.
15941 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15942 (setq gnus-moderated-list
15943 (cons (symbol-name group) gnus-moderated-list))))
15950 ;; And if we do not care about moderation, we use this loop,
15951 ;; which is faster.
15952 (let (group max min)
15953 (while (not (eobp))
15956 (narrow-to-region (point) (gnus-point-at-eol))
15957 ;; group gets set to a symbol interned in the hash table
15958 ;; (what a hack!!) - jwz
15959 (setq group (let ((obarray hashtb)) (read cur)))
15960 (if (and (numberp (setq max (read cur)))
15961 (numberp (setq min (read cur)))
15963 (skip-chars-forward " \t")
15965 (or (= (following-char) ?=)
15966 (= (following-char) ?x)
15967 (= (following-char) ?j)))))
15968 (set group (cons min max))
15976 (gnus-message 3 "Warning - illegal active: %s"
15978 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15980 (forward-line 1))))))
15982 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15983 ;; Parse a "groups" active file.
15984 (let ((cur (current-buffer))
15986 (if (and method gnus-active-hashtb)
15988 (setq gnus-active-hashtb
15989 (gnus-make-hashtable
15990 (count-lines (point-min) (point-max)))))))
15991 (prefix (and method
15992 (not (gnus-server-equal
15993 (gnus-server-get-method nil method)
15994 (gnus-server-get-method nil gnus-select-method)))
15995 (gnus-group-prefixed-name "" method))))
15997 (goto-char (point-min))
15998 ;; We split this into to separate loops, one with the prefix
15999 ;; and one without to speed the reading up somewhat.
16001 (let (min max opoint group)
16002 (while (not (eobp))
16005 (read cur) (read cur)
16006 (setq min (read cur)
16009 (skip-chars-forward " \t")
16012 (set (let ((obarray hashtb)) (read cur))
16014 (error (and group (symbolp group) (set group nil))))
16016 (let (min max group)
16017 (while (not (eobp))
16019 (if (= (following-char) ?2)
16021 (read cur) (read cur)
16022 (setq min (read cur)
16024 (set (setq group (let ((obarray hashtb)) (read cur)))
16026 (error (and group (symbolp group) (set group nil))))
16027 (forward-line 1))))))
16029 (defun gnus-read-newsrc-file (&optional force)
16030 "Read startup file.
16031 If FORCE is non-nil, the .newsrc file is read."
16032 ;; Reset variables that might be defined in the .newsrc.eld file.
16033 (let ((variables gnus-variable-list))
16035 (set (car variables) nil)
16036 (setq variables (cdr variables))))
16037 (let* ((newsrc-file gnus-current-startup-file)
16038 (quick-file (concat newsrc-file ".el")))
16040 ;; We always load the .newsrc.eld file. If always contains
16041 ;; much information that can not be gotten from the .newsrc
16042 ;; file (ticked articles, killed groups, foreign methods, etc.)
16043 (gnus-read-newsrc-el-file quick-file)
16045 (if (and (file-exists-p gnus-current-startup-file)
16047 (and (file-newer-than-file-p newsrc-file quick-file)
16048 (file-newer-than-file-p newsrc-file
16049 (concat quick-file "d")))
16050 (not gnus-newsrc-alist)))
16051 ;; We read the .newsrc file. Note that if there if a
16052 ;; .newsrc.eld file exists, it has already been read, and
16053 ;; the `gnus-newsrc-hashtb' has been created. While reading
16054 ;; the .newsrc file, Gnus will only use the information it
16055 ;; can find there for changing the data already read -
16056 ;; ie. reading the .newsrc file will not trash the data
16057 ;; already read (except for read articles).
16059 (gnus-message 5 "Reading %s..." newsrc-file)
16060 (set-buffer (find-file-noselect newsrc-file))
16061 (buffer-disable-undo (current-buffer))
16062 (gnus-newsrc-to-gnus-format)
16063 (kill-buffer (current-buffer))
16064 (gnus-message 5 "Reading %s...done" newsrc-file)))
16066 ;; Read any slave files.
16068 (gnus-master-read-slave-newsrc))
16070 ;; Convert old to new.
16071 (gnus-convert-old-newsrc))))
16073 (defun gnus-continuum-version (version)
16074 "Return VERSION as a floating point number."
16075 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16076 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16077 (number (match-string 2 version))
16079 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16080 (setq major (string-to-number (match-string 1 number)))
16081 (setq minor (string-to-number (match-string 2 number)))
16082 (setq least (if (match-beginning 3)
16083 (string-to-number (match-string 3 number))
16087 (format "%s00%02d%02d"
16089 ((string= alpha "(ding)") "4.99")
16090 ((string= alpha "September") "5.01")
16091 ((string= alpha "Red") "5.03"))
16093 (format "%d.%02d%20d" major minor least))))))
16095 (defun gnus-convert-old-newsrc ()
16096 "Convert old newsrc into the new format, if needed."
16097 (let ((fcv (gnus-continuum-version gnus-newsrc-file-version)))
16099 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16100 (gnus-convert-old-ticks)))))
16102 (defun gnus-convert-old-ticks ()
16103 (let ((newsrc (cdr gnus-newsrc-alist))
16104 marks info dormant ticked)
16105 (while (setq info (pop newsrc))
16106 (when (setq marks (gnus-info-marks info))
16107 (setq dormant (cdr (assq 'dormant marks))
16108 ticked (cdr (assq 'tick marks)))
16109 (when (or dormant ticked)
16110 (gnus-info-set-read
16113 (gnus-info-read info)
16114 (nconc (gnus-uncompress-range dormant)
16115 (gnus-uncompress-range ticked)))))))))
16117 (defun gnus-read-newsrc-el-file (file)
16118 (let ((ding-file (concat file "d")))
16119 ;; We always, always read the .eld file.
16120 (gnus-message 5 "Reading %s..." ding-file)
16121 (let (gnus-newsrc-assoc)
16122 (condition-case nil
16123 (load ding-file t t t)
16125 (gnus-error 1 "Error in %s" ding-file)))
16126 (when gnus-newsrc-assoc
16127 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16128 (gnus-make-hashtable-from-newsrc-alist)
16129 (when (file-newer-than-file-p file ding-file)
16130 ;; Old format quick file
16131 (gnus-message 5 "Reading %s..." file)
16132 ;; The .el file is newer than the .eld file, so we read that one
16134 (gnus-read-old-newsrc-el-file file))))
16136 ;; Parse the old-style quick startup file
16137 (defun gnus-read-old-newsrc-el-file (file)
16138 (let (newsrc killed marked group m info)
16140 (let ((gnus-killed-assoc nil)
16141 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16143 (condition-case nil
16146 (setq newsrc gnus-newsrc-assoc
16147 killed gnus-killed-assoc
16148 marked gnus-marked-assoc)))
16149 (setq gnus-newsrc-alist nil)
16150 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16153 (gnus-info-set-read info (cddr group))
16154 (gnus-info-set-level
16155 info (if (nth 1 group) gnus-level-default-subscribed
16156 gnus-level-default-unsubscribed))
16157 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16160 (if (nth 1 group) gnus-level-default-subscribed
16161 gnus-level-default-unsubscribed)
16163 gnus-newsrc-alist))
16164 ;; Copy marks into info.
16165 (when (setq m (assoc (car group) marked))
16166 (unless (nthcdr 3 info)
16167 (nconc info (list nil)))
16168 (gnus-info-set-marks
16169 info (list (cons 'tick (gnus-compress-sequence
16170 (sort (cdr m) '<) t))))))
16171 (setq newsrc killed)
16173 (setcar newsrc (caar newsrc))
16174 (setq newsrc (cdr newsrc)))
16175 (setq gnus-killed-list killed))
16176 ;; The .el file version of this variable does not begin with
16177 ;; "options", while the .eld version does, so we just add it if it
16180 gnus-newsrc-options
16182 (and (not (string-match "^ *options" gnus-newsrc-options))
16183 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16184 (and (not (string-match "\n$" gnus-newsrc-options))
16185 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16186 ;; Finally, if we read some options lines, we parse them.
16187 (or (string= gnus-newsrc-options "")
16188 (gnus-newsrc-parse-options gnus-newsrc-options))))
16190 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16191 (gnus-make-hashtable-from-newsrc-alist)))
16193 (defun gnus-make-newsrc-file (file)
16194 "Make server dependent file name by catenating FILE and server host name."
16195 (let* ((file (expand-file-name file nil))
16196 (real-file (concat file "-" (nth 1 gnus-select-method))))
16197 (if (or (file-exists-p real-file)
16198 (file-exists-p (concat real-file ".el"))
16199 (file-exists-p (concat real-file ".eld")))
16202 (defun gnus-newsrc-to-gnus-format ()
16203 (setq gnus-newsrc-options "")
16204 (setq gnus-newsrc-options-n nil)
16206 (or gnus-active-hashtb
16207 (setq gnus-active-hashtb (make-vector 4095 0)))
16208 (let ((buf (current-buffer))
16209 (already-read (> (length gnus-newsrc-alist) 1))
16210 group subscribed options-symbol newsrc Options-symbol
16212 (goto-char (point-min))
16213 ;; We intern the symbol `options' in the active hashtb so that we
16214 ;; can `eq' against it later.
16215 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16216 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16218 (while (not (eobp))
16219 ;; We first read the first word on the line by narrowing and
16220 ;; then reading into `gnus-active-hashtb'. Most groups will
16221 ;; already exist in that hashtb, so this will save some string
16225 (progn (skip-chars-forward "^ \t!:\n") (point)))
16226 (goto-char (point-min))
16228 (and (/= (point-min) (point-max))
16229 (let ((obarray gnus-active-hashtb)) (read buf))))
16231 ;; Now, the symbol we have read is either `options' or a group
16232 ;; name. If it is an options line, we just add it to a string.
16234 ((or (eq symbol options-symbol)
16235 (eq symbol Options-symbol))
16236 (setq gnus-newsrc-options
16237 ;; This concating is quite inefficient, but since our
16238 ;; thorough studies show that approx 99.37% of all
16239 ;; .newsrc files only contain a single options line, we
16240 ;; don't give a damn, frankly, my dear.
16241 (concat gnus-newsrc-options
16243 (gnus-point-at-bol)
16244 ;; Options may continue on the next line.
16245 (or (and (re-search-forward "^[^ \t]" nil 'move)
16246 (progn (beginning-of-line) (point)))
16250 ;; Group names can be just numbers.
16251 (when (numberp symbol)
16252 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16253 (or (boundp symbol) (set symbol nil))
16254 ;; It was a group name.
16255 (setq subscribed (= (following-char) ?:)
16256 group (symbol-name symbol)
16259 ;; If the line ends here, this is clearly a buggy line, so
16260 ;; we put point a the beginning of line and let the cond
16261 ;; below do the error handling.
16262 (beginning-of-line)
16263 ;; We skip to the beginning of the ranges.
16264 (skip-chars-forward "!: \t"))
16265 ;; We are now at the beginning of the list of read articles.
16266 ;; We read them range by range.
16269 ((looking-at "[0-9]+")
16270 ;; We narrow and read a number instead of buffer-substring/
16271 ;; string-to-int because it's faster. narrow/widen is
16272 ;; faster than save-restriction/narrow, and save-restriction
16273 ;; produces a garbage object.
16275 (narrow-to-region (match-beginning 0) (match-end 0))
16278 ;; If the next character is a dash, then this is a range.
16279 (if (= (following-char) ?-)
16281 ;; We read the upper bound of the range.
16283 (if (not (looking-at "[0-9]+"))
16284 ;; This is a buggy line, by we pretend that
16285 ;; it's kinda OK. Perhaps the user should be
16287 (setq reads (cons num1 reads))
16292 (narrow-to-region (match-beginning 0)
16297 ;; It was just a simple number, so we add it to the
16299 (setq reads (cons num1 reads)))
16300 ;; If the next char in ?\n, then we have reached the end
16301 ;; of the line and return nil.
16302 (/= (following-char) ?\n))
16303 ((= (following-char) ?\n)
16304 ;; End of line, so we end.
16307 ;; Not numbers and not eol, so this might be a buggy
16310 ;; If it was eob instead of ?\n, we allow it.
16312 ;; The line was buggy.
16314 (gnus-error 3.1 "Mangled line: %s"
16315 (buffer-substring (gnus-point-at-bol)
16316 (gnus-point-at-eol)))))
16318 ;; Skip past ", ". Spaces are illegal in these ranges, but
16319 ;; we allow them, because it's a common mistake to put a
16320 ;; space after the comma.
16321 (skip-chars-forward ", "))
16323 ;; We have already read .newsrc.eld, so we gently update the
16324 ;; data in the hash table with the information we have just
16327 (let ((info (gnus-get-info group))
16330 ;; There is an entry for this file in the alist.
16332 (gnus-info-set-read info (nreverse reads))
16333 ;; We update the level very gently. In fact, we
16334 ;; only change it if there's been a status change
16335 ;; from subscribed to unsubscribed, or vice versa.
16336 (setq level (gnus-info-level info))
16337 (cond ((and (<= level gnus-level-subscribed)
16339 (setq level (if reads
16340 gnus-level-default-unsubscribed
16341 (1+ gnus-level-default-unsubscribed))))
16342 ((and (> level gnus-level-subscribed) subscribed)
16343 (setq level gnus-level-default-subscribed)))
16344 (gnus-info-set-level info level))
16345 ;; This is a new group.
16346 (setq info (list group
16348 gnus-level-default-subscribed
16350 (1+ gnus-level-subscribed)
16351 gnus-level-default-unsubscribed))
16352 (nreverse reads))))
16353 (setq newsrc (cons info newsrc))))))
16356 (setq newsrc (nreverse newsrc))
16358 (if (not already-read)
16360 ;; We now have two newsrc lists - `newsrc', which is what we
16361 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16362 ;; what we've read from .newsrc.eld. We have to merge these
16363 ;; lists. We do this by "attaching" any (foreign) groups in the
16364 ;; gnus-newsrc-alist to the (native) group that precedes them.
16365 (let ((rc (cdr gnus-newsrc-alist))
16366 (prev gnus-newsrc-alist)
16369 (or (null (nth 4 (car rc))) ; It's a native group.
16370 (assoc (caar rc) newsrc) ; It's already in the alist.
16371 (if (setq entry (assoc (caar prev) newsrc))
16372 (setcdr (setq mentry (memq entry newsrc))
16373 (cons (car rc) (cdr mentry)))
16374 (setq newsrc (cons (car rc) newsrc))))
16378 (setq gnus-newsrc-alist newsrc)
16379 ;; We make the newsrc hashtb.
16380 (gnus-make-hashtable-from-newsrc-alist)
16382 ;; Finally, if we read some options lines, we parse them.
16383 (or (string= gnus-newsrc-options "")
16384 (gnus-newsrc-parse-options gnus-newsrc-options))))
16386 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16387 ;; The return value will be a list on the form
16388 ;; ((regexp1 . ignore)
16389 ;; (regexp2 . subscribe)...)
16390 ;; When handling new newsgroups, groups that match a `ignore' regexp
16391 ;; will be ignored, and groups that match a `subscribe' regexp will be
16392 ;; subscribed. A line like
16393 ;; options -n !all rec.all
16394 ;; will lead to a list that looks like
16395 ;; (("^rec\\..+" . subscribe)
16396 ;; ("^.+" . ignore))
16397 ;; So all "rec.*" groups will be subscribed, while all the other
16398 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16399 ;; different from "options -n rec.all !all".
16400 (defun gnus-newsrc-parse-options (options)
16403 (gnus-set-work-buffer)
16404 (insert (regexp-quote options))
16405 ;; First we treat all continuation lines.
16406 (goto-char (point-min))
16407 (while (re-search-forward "\n[ \t]+" nil t)
16408 (replace-match " " t t))
16409 ;; Then we transform all "all"s into ".+"s.
16410 (goto-char (point-min))
16411 (while (re-search-forward "\\ball\\b" nil t)
16412 (replace-match ".+" t t))
16413 (goto-char (point-min))
16414 ;; We remove all other options than the "-n" ones.
16415 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16416 (replace-match " ")
16418 (goto-char (point-min))
16420 ;; We are only interested in "options -n" lines - we
16421 ;; ignore the other option lines.
16422 (while (re-search-forward "[ \t]-n" nil t)
16424 (or (save-excursion
16425 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16427 (gnus-point-at-eol)))
16428 ;; Search for all "words"...
16429 (while (re-search-forward "[^ \t,\n]+" eol t)
16430 (if (= (char-after (match-beginning 0)) ?!)
16431 ;; If the word begins with a bang (!), this is a "not"
16432 ;; spec. We put this spec (minus the bang) and the
16433 ;; symbol `ignore' into the list.
16434 (setq out (cons (cons (concat
16435 "^" (buffer-substring
16436 (1+ (match-beginning 0))
16439 ;; There was no bang, so this is a "yes" spec.
16440 (setq out (cons (cons (concat "^" (match-string 0))
16441 'subscribe) out)))))
16443 (setq gnus-newsrc-options-n out))))
16445 (defun gnus-save-newsrc-file (&optional force)
16446 "Save .newsrc file."
16447 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16448 ;; from the variable gnus-newsrc-alist.
16449 (when (and (or gnus-newsrc-alist gnus-killed-list)
16450 gnus-current-startup-file)
16452 (if (and (or gnus-use-dribble-file gnus-slave)
16454 (or (not gnus-dribble-buffer)
16455 (not (buffer-name gnus-dribble-buffer))
16456 (zerop (save-excursion
16457 (set-buffer gnus-dribble-buffer)
16459 (gnus-message 4 "(No changes need to be saved)")
16460 (run-hooks 'gnus-save-newsrc-hook)
16462 (gnus-slave-save-newsrc)
16464 (when gnus-save-newsrc-file
16465 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16466 (gnus-gnus-to-newsrc-format)
16467 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16468 ;; Save .newsrc.eld.
16469 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16470 (make-local-variable 'version-control)
16471 (setq version-control 'never)
16472 (setq buffer-file-name
16473 (concat gnus-current-startup-file ".eld"))
16474 (gnus-add-current-to-buffer-list)
16475 (buffer-disable-undo (current-buffer))
16477 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16478 (gnus-gnus-to-quick-newsrc-format)
16479 (run-hooks 'gnus-save-quick-newsrc-hook)
16481 (kill-buffer (current-buffer))
16483 5 "Saving %s.eld...done" gnus-current-startup-file))
16484 (gnus-dribble-delete-file)))))
16486 (defun gnus-gnus-to-quick-newsrc-format ()
16487 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16488 (insert ";; Gnus startup file.\n")
16489 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16490 (insert ";; to read .newsrc.\n")
16491 (insert "(setq gnus-newsrc-file-version "
16492 (prin1-to-string gnus-version) ")\n")
16494 (if gnus-save-killed-list gnus-variable-list
16495 ;; Remove the `gnus-killed-list' from the list of variables
16496 ;; to be saved, if required.
16497 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16498 ;; Peel off the "dummy" group.
16499 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16501 ;; Insert the variables into the file.
16503 (when (and (boundp (setq variable (pop variables)))
16504 (symbol-value variable))
16505 (insert "(setq " (symbol-name variable) " '")
16506 (prin1 (symbol-value variable) (current-buffer))
16509 (defun gnus-gnus-to-newsrc-format ()
16510 ;; Generate and save the .newsrc file.
16512 (set-buffer (create-file-buffer gnus-current-startup-file))
16513 (let ((newsrc (cdr gnus-newsrc-alist))
16514 (standard-output (current-buffer))
16515 info ranges range method)
16516 (setq buffer-file-name gnus-current-startup-file)
16517 (buffer-disable-undo (current-buffer))
16520 (if gnus-newsrc-options (insert gnus-newsrc-options))
16521 ;; Write subscribed and unsubscribed.
16522 (while (setq info (pop newsrc))
16523 ;; Don't write foreign groups to .newsrc.
16524 (when (or (null (setq method (gnus-info-method info)))
16525 (equal method "native")
16526 (gnus-server-equal method gnus-select-method))
16527 (insert (gnus-info-group info)
16528 (if (> (gnus-info-level info) gnus-level-subscribed)
16530 (when (setq ranges (gnus-info-read info))
16532 (if (not (listp (cdr ranges)))
16533 (if (= (car ranges) (cdr ranges))
16534 (princ (car ranges))
16535 (princ (car ranges))
16537 (princ (cdr ranges)))
16538 (while (setq range (pop ranges))
16539 (if (or (atom range) (= (car range) (cdr range)))
16540 (princ (or (and (atom range) range) (car range)))
16541 (princ (car range))
16543 (princ (cdr range)))
16544 (if ranges (insert ",")))))
16546 (make-local-variable 'version-control)
16547 (setq version-control 'never)
16548 ;; It has been reported that sometime the modtime on the .newsrc
16549 ;; file seems to be off. We really do want to overwrite it, so
16550 ;; we clear the modtime here before saving. It's a bit odd,
16552 ;; sometimes the modtime clear isn't sufficient. most brute force:
16553 ;; delete the silly thing entirely first. but this fails to provide
16554 ;; such niceties as .newsrc~ creation.
16555 (if gnus-modtime-botch
16556 (delete-file gnus-startup-file)
16557 (clear-visited-file-modtime))
16558 (run-hooks 'gnus-save-standard-newsrc-hook)
16560 (kill-buffer (current-buffer)))))
16564 ;;; Slave functions.
16567 (defun gnus-slave-save-newsrc ()
16569 (set-buffer gnus-dribble-buffer)
16571 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16572 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16574 (defun gnus-master-read-slave-newsrc ()
16577 (file-name-directory gnus-current-startup-file)
16581 (file-name-nondirectory gnus-current-startup-file)
16585 (if (not slave-files)
16586 () ; There are no slave files to read.
16587 (gnus-message 7 "Reading slave newsrcs...")
16589 (set-buffer (get-buffer-create " *gnus slave*"))
16590 (buffer-disable-undo (current-buffer))
16592 (sort (mapcar (lambda (file)
16593 (list (nth 5 (file-attributes file)) file))
16596 (or (< (caar f1) (caar f2))
16597 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16600 (setq file (nth 1 (car slave-files)))
16601 (insert-file-contents file)
16602 (if (condition-case ()
16604 (eval-buffer (current-buffer))
16607 (gnus-error 3.2 "Possible error in %s" file)
16609 (or gnus-slave ; Slaves shouldn't delete these files.
16613 (setq slave-files (cdr slave-files))))
16614 (gnus-message 7 "Reading slave newsrcs...done"))))
16618 ;;; Group description.
16621 (defun gnus-read-all-descriptions-files ()
16622 (let ((methods (cons gnus-select-method
16624 (when gnus-message-archive-method
16626 gnus-secondary-select-methods))))
16628 (gnus-read-descriptions-file (car methods))
16629 (setq methods (cdr methods)))
16632 (defun gnus-read-descriptions-file (&optional method)
16633 (let ((method (or method gnus-select-method)))
16634 (when (stringp method)
16635 (setq method (gnus-server-to-method method)))
16636 ;; We create the hashtable whether we manage to read the desc file
16637 ;; to avoid trying to re-read after a failed read.
16638 (or gnus-description-hashtb
16639 (setq gnus-description-hashtb
16640 (gnus-make-hashtable (length gnus-active-hashtb))))
16641 ;; Mark this method's desc file as read.
16642 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16643 gnus-description-hashtb)
16645 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16647 ((not (gnus-check-server method))
16648 (gnus-message 1 "Couldn't open server")
16650 ((not (gnus-request-list-newsgroups method))
16651 (gnus-message 1 "Couldn't read newsgroups descriptions")
16657 (set-buffer nntp-server-buffer)
16658 (goto-char (point-min))
16659 (if (or (search-forward "\n.\n" nil t)
16660 (goto-char (point-max)))
16662 (beginning-of-line)
16663 (narrow-to-region (point-min) (point))))
16664 (goto-char (point-min))
16665 (while (not (eobp))
16666 ;; If we get an error, we set group to 0, which is not a
16670 (let ((obarray gnus-description-hashtb))
16671 ;; Group is set to a symbol interned in this
16673 (read nntp-server-buffer))
16675 (skip-chars-forward " \t")
16676 ;; ... which leads to this line being effectively ignored.
16677 (and (symbolp group)
16678 (set group (buffer-substring
16679 (point) (progn (end-of-line) (point)))))
16680 (forward-line 1))))
16681 (gnus-message 5 "Reading descriptions file...done")
16684 (defun gnus-group-get-description (group)
16685 "Get the description of a group by sending XGTITLE to the server."
16686 (when (gnus-request-group-description group)
16688 (set-buffer nntp-server-buffer)
16689 (goto-char (point-min))
16690 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16691 (match-string 1)))))
16695 ;;; Buffering of read articles.
16698 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16699 (defvar gnus-backlog-articles nil)
16700 (defvar gnus-backlog-hashtb nil)
16702 (defun gnus-backlog-buffer ()
16703 "Return the backlog buffer."
16704 (or (get-buffer gnus-backlog-buffer)
16706 (set-buffer (get-buffer-create gnus-backlog-buffer))
16707 (buffer-disable-undo (current-buffer))
16708 (setq buffer-read-only t)
16709 (gnus-add-current-to-buffer-list)
16710 (get-buffer gnus-backlog-buffer))))
16712 (defun gnus-backlog-setup ()
16713 "Initialize backlog variables."
16714 (unless gnus-backlog-hashtb
16715 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16717 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16719 (defun gnus-backlog-shutdown ()
16720 "Clear all backlog variables and buffers."
16721 (when (get-buffer gnus-backlog-buffer)
16722 (kill-buffer gnus-backlog-buffer))
16723 (setq gnus-backlog-hashtb nil
16724 gnus-backlog-articles nil))
16726 (defun gnus-backlog-enter-article (group number buffer)
16727 (gnus-backlog-setup)
16728 (let ((ident (intern (concat group ":" (int-to-string number))
16729 gnus-backlog-hashtb))
16731 (if (memq ident gnus-backlog-articles)
16732 () ; It's already kept.
16733 ;; Remove the oldest article, if necessary.
16734 (and (numberp gnus-keep-backlog)
16735 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16736 (gnus-backlog-remove-oldest-article))
16737 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16738 ;; Insert the new article.
16740 (set-buffer (gnus-backlog-buffer))
16741 (let (buffer-read-only)
16742 (goto-char (point-max))
16743 (or (bolp) (insert "\n"))
16745 (insert-buffer-substring buffer)
16746 ;; Tag the beginning of the article with the ident.
16747 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16749 (defun gnus-backlog-remove-oldest-article ()
16751 (set-buffer (gnus-backlog-buffer))
16752 (goto-char (point-min))
16753 (if (zerop (buffer-size))
16754 () ; The buffer is empty.
16755 (let ((ident (get-text-property (point) 'gnus-backlog))
16757 ;; Remove the ident from the list of articles.
16759 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16760 ;; Delete the article itself.
16762 (point) (next-single-property-change
16763 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16765 (defun gnus-backlog-request-article (group number buffer)
16766 (when (numberp number)
16767 (gnus-backlog-setup)
16768 (let ((ident (intern (concat group ":" (int-to-string number))
16769 gnus-backlog-hashtb))
16771 (when (memq ident gnus-backlog-articles)
16772 ;; It was in the backlog.
16774 (set-buffer (gnus-backlog-buffer))
16775 (if (not (setq beg (text-property-any
16776 (point-min) (point-max) 'gnus-backlog
16778 ;; It wasn't in the backlog after all.
16780 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16781 ;; Find the end (i. e., the beginning of the next article).
16783 (next-single-property-change
16784 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16785 (let ((buffer-read-only nil))
16787 (insert-buffer-substring gnus-backlog-buffer beg end)
16790 ;; Allow redefinition of Gnus functions.
16792 (gnus-ems-redefine)
16796 ;;; gnus.el ends here