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-decode-rfc1522)
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
1536 (defvar gnus-tree-buffer "*Tree*"
1537 "Buffer where Gnus thread trees are displayed.")
1540 (defvar gnus-use-generic-from nil)
1542 (defvar gnus-thread-indent-array nil)
1543 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1545 (defvar gnus-newsrc-file-version nil)
1547 (defvar gnus-method-history nil)
1548 ;; Variable holding the user answers to all method prompts.
1550 (defvar gnus-group-history nil)
1551 ;; Variable holding the user answers to all group prompts.
1553 (defvar gnus-server-alist nil
1554 "List of available servers.")
1556 (defvar gnus-group-indentation-function nil)
1558 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1560 (defvar gnus-goto-missing-group-function nil)
1562 (defvar gnus-override-subscribe-method nil)
1564 (defvar gnus-group-goto-next-group-function nil
1565 "Function to override finding the next group after listing groups.")
1567 (defconst gnus-article-mark-lists
1568 '((marked . tick) (replied . reply)
1569 (expirable . expire) (killed . killed)
1570 (bookmarks . bookmark) (dormant . dormant)
1571 (scored . score) (saved . save)
1575 ;; Avoid highlighting in kill files.
1576 (defvar gnus-summary-inhibit-highlight nil)
1577 (defvar gnus-newsgroup-selected-overlay nil)
1579 (defvar gnus-inhibit-hiding nil)
1580 (defvar gnus-group-indentation "")
1581 (defvar gnus-inhibit-limiting nil)
1582 (defvar gnus-created-frames nil)
1584 (defvar gnus-article-mode-map nil)
1585 (defvar gnus-dribble-buffer nil)
1586 (defvar gnus-headers-retrieved-by nil)
1587 (defvar gnus-article-reply nil)
1588 (defvar gnus-override-method nil)
1589 (defvar gnus-article-check-size nil)
1591 (defvar gnus-current-score-file nil)
1592 (defvar gnus-newsgroup-adaptive-score-file nil)
1593 (defvar gnus-scores-exclude-files nil)
1595 (defvar gnus-opened-servers nil)
1597 (defvar gnus-current-move-group nil)
1598 (defvar gnus-current-copy-group nil)
1599 (defvar gnus-current-crosspost-group nil)
1601 (defvar gnus-newsgroup-dependencies nil)
1602 (defvar gnus-newsgroup-async nil)
1603 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1605 (defvar gnus-newsgroup-adaptive nil)
1607 (defvar gnus-summary-display-table nil)
1608 (defvar gnus-summary-display-article-function nil)
1610 (defvar gnus-summary-highlight-line-function nil
1611 "Function called after highlighting a summary line.")
1613 (defvar gnus-group-line-format-alist
1614 `((?M gnus-tmp-marked-mark ?c)
1615 (?S gnus-tmp-subscribed ?c)
1616 (?L gnus-tmp-level ?d)
1617 (?N (cond ((eq number t) "*" )
1621 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1622 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1624 (?R gnus-tmp-number-of-read ?s)
1625 (?t gnus-tmp-number-total ?d)
1626 (?y gnus-tmp-number-of-unread ?s)
1627 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1628 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1629 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1630 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1631 (?g gnus-tmp-group ?s)
1632 (?G gnus-tmp-qualified-group ?s)
1633 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1634 (?D gnus-tmp-newsgroup-description ?s)
1635 (?o gnus-tmp-moderated ?c)
1636 (?O gnus-tmp-moderated-string ?s)
1637 (?p gnus-tmp-process-marked ?c)
1638 (?s gnus-tmp-news-server ?s)
1639 (?n gnus-tmp-news-method ?s)
1640 (?P gnus-group-indentation ?s)
1641 (?l gnus-tmp-grouplens ?s)
1642 (?z gnus-tmp-news-method-string ?s)
1643 (?u gnus-tmp-user-defined ?s)))
1645 (defvar gnus-summary-line-format-alist
1646 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1647 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1648 (?s gnus-tmp-subject-or-nil ?s)
1649 (?n gnus-tmp-name ?s)
1650 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1652 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1654 (?F gnus-tmp-from ?s)
1655 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1656 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1657 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1658 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1659 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1660 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1661 (?L gnus-tmp-lines ?d)
1662 (?I gnus-tmp-indentation ?s)
1663 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1664 (?R gnus-tmp-replied ?c)
1665 (?\[ gnus-tmp-opening-bracket ?c)
1666 (?\] gnus-tmp-closing-bracket ?c)
1667 (?\> (make-string gnus-tmp-level ? ) ?s)
1668 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1669 (?i gnus-tmp-score ?d)
1670 (?z gnus-tmp-score-char ?c)
1671 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1672 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1673 (?U gnus-tmp-unread ?c)
1674 (?t (gnus-summary-number-of-articles-in-thread
1675 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1677 (?e (gnus-summary-number-of-articles-in-thread
1678 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1680 (?u gnus-tmp-user-defined ?s))
1681 "An alist of format specifications that can appear in summary lines,
1682 and what variables they correspond with, along with the type of the
1683 variable (string, integer, character, etc).")
1685 (defvar gnus-summary-dummy-line-format-alist
1686 `((?S gnus-tmp-subject ?s)
1687 (?N gnus-tmp-number ?d)
1688 (?u gnus-tmp-user-defined ?s)))
1690 (defvar gnus-summary-mode-line-format-alist
1691 `((?G gnus-tmp-group-name ?s)
1692 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1693 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1694 (?A gnus-tmp-article-number ?d)
1695 (?Z gnus-tmp-unread-and-unselected ?s)
1696 (?V gnus-version ?s)
1697 (?U gnus-tmp-unread ?d)
1698 (?S gnus-tmp-subject ?s)
1699 (?e gnus-tmp-unselected ?d)
1700 (?u gnus-tmp-user-defined ?s)
1701 (?d (length gnus-newsgroup-dormant) ?d)
1702 (?t (length gnus-newsgroup-marked) ?d)
1703 (?r (length gnus-newsgroup-reads) ?d)
1704 (?E gnus-newsgroup-expunged-tally ?d)
1705 (?s (gnus-current-score-file-nondirectory) ?s)))
1707 (defvar gnus-article-mode-line-format-alist
1708 gnus-summary-mode-line-format-alist)
1710 (defvar gnus-group-mode-line-format-alist
1711 `((?S gnus-tmp-news-server ?s)
1712 (?M gnus-tmp-news-method ?s)
1713 (?u gnus-tmp-user-defined ?s)))
1715 (defvar gnus-have-read-active-file nil)
1717 (defconst gnus-maintainer
1718 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1719 "The mail address of the Gnus maintainers.")
1721 (defconst gnus-version "September Gnus v0.87"
1722 "Version number for this version of Gnus.")
1724 (defvar gnus-info-nodes
1725 '((gnus-group-mode "(gnus)The Group Buffer")
1726 (gnus-summary-mode "(gnus)The Summary Buffer")
1727 (gnus-article-mode "(gnus)The Article Buffer"))
1728 "Assoc list of major modes and related Info nodes.")
1730 (defvar gnus-group-buffer "*Group*")
1731 (defvar gnus-summary-buffer "*Summary*")
1732 (defvar gnus-article-buffer "*Article*")
1733 (defvar gnus-server-buffer "*Server*")
1735 (defvar gnus-work-buffer " *gnus work*")
1737 (defvar gnus-original-article-buffer " *Original Article*")
1738 (defvar gnus-original-article nil)
1740 (defvar gnus-buffer-list nil
1741 "Gnus buffers that should be killed on exit.")
1743 (defvar gnus-slave nil
1744 "Whether this Gnus is a slave or not.")
1746 (defvar gnus-variable-list
1747 '(gnus-newsrc-options gnus-newsrc-options-n
1748 gnus-newsrc-last-checked-date
1749 gnus-newsrc-alist gnus-server-alist
1750 gnus-killed-list gnus-zombie-list
1751 gnus-topic-topology gnus-topic-alist
1753 "Gnus variables saved in the quick startup file.")
1755 (defvar gnus-newsrc-options nil
1756 "Options line in the .newsrc file.")
1758 (defvar gnus-newsrc-options-n nil
1759 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1761 (defvar gnus-newsrc-last-checked-date nil
1762 "Date Gnus last asked server for new newsgroups.")
1764 (defvar gnus-topic-topology nil
1765 "The complete topic hierarchy.")
1767 (defvar gnus-topic-alist nil
1768 "The complete topic-group alist.")
1770 (defvar gnus-newsrc-alist nil
1771 "Assoc list of read articles.
1772 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1774 (defvar gnus-newsrc-hashtb nil
1775 "Hashtable of gnus-newsrc-alist.")
1777 (defvar gnus-killed-list nil
1778 "List of killed newsgroups.")
1780 (defvar gnus-killed-hashtb nil
1781 "Hash table equivalent of gnus-killed-list.")
1783 (defvar gnus-zombie-list nil
1784 "List of almost dead newsgroups.")
1786 (defvar gnus-description-hashtb nil
1787 "Descriptions of newsgroups.")
1789 (defvar gnus-list-of-killed-groups nil
1790 "List of newsgroups that have recently been killed by the user.")
1792 (defvar gnus-active-hashtb nil
1793 "Hashtable of active articles.")
1795 (defvar gnus-moderated-list nil
1796 "List of moderated newsgroups.")
1798 (defvar gnus-group-marked nil)
1800 (defvar gnus-current-startup-file nil
1801 "Startup file for the current host.")
1803 (defvar gnus-last-search-regexp nil
1804 "Default regexp for article search command.")
1806 (defvar gnus-last-shell-command nil
1807 "Default shell command on article.")
1809 (defvar gnus-current-select-method nil
1810 "The current method for selecting a newsgroup.")
1812 (defvar gnus-group-list-mode nil)
1814 (defvar gnus-article-internal-prepare-hook nil)
1816 (defvar gnus-newsgroup-name nil)
1817 (defvar gnus-newsgroup-begin nil)
1818 (defvar gnus-newsgroup-end nil)
1819 (defvar gnus-newsgroup-last-rmail nil)
1820 (defvar gnus-newsgroup-last-mail nil)
1821 (defvar gnus-newsgroup-last-folder nil)
1822 (defvar gnus-newsgroup-last-file nil)
1823 (defvar gnus-newsgroup-auto-expire nil)
1824 (defvar gnus-newsgroup-active nil)
1826 (defvar gnus-newsgroup-data nil)
1827 (defvar gnus-newsgroup-data-reverse nil)
1828 (defvar gnus-newsgroup-limit nil)
1829 (defvar gnus-newsgroup-limits nil)
1831 (defvar gnus-newsgroup-unreads nil
1832 "List of unread articles in the current newsgroup.")
1834 (defvar gnus-newsgroup-unselected nil
1835 "List of unselected unread articles in the current newsgroup.")
1837 (defvar gnus-newsgroup-reads nil
1838 "Alist of read articles and article marks in the current newsgroup.")
1840 (defvar gnus-newsgroup-expunged-tally nil)
1842 (defvar gnus-newsgroup-marked nil
1843 "List of ticked articles in the current newsgroup (a subset of unread art).")
1845 (defvar gnus-newsgroup-killed nil
1846 "List of ranges of articles that have been through the scoring process.")
1848 (defvar gnus-newsgroup-cached nil
1849 "List of articles that come from the article cache.")
1851 (defvar gnus-newsgroup-saved nil
1852 "List of articles that have been saved.")
1854 (defvar gnus-newsgroup-kill-headers nil)
1856 (defvar gnus-newsgroup-replied nil
1857 "List of articles that have been replied to in the current newsgroup.")
1859 (defvar gnus-newsgroup-expirable nil
1860 "List of articles in the current newsgroup that can be expired.")
1862 (defvar gnus-newsgroup-processable nil
1863 "List of articles in the current newsgroup that can be processed.")
1865 (defvar gnus-newsgroup-bookmarks nil
1866 "List of articles in the current newsgroup that have bookmarks.")
1868 (defvar gnus-newsgroup-dormant nil
1869 "List of dormant articles in the current newsgroup.")
1871 (defvar gnus-newsgroup-scored nil
1872 "List of scored articles in the current newsgroup.")
1874 (defvar gnus-newsgroup-headers nil
1875 "List of article headers in the current newsgroup.")
1877 (defvar gnus-newsgroup-threads nil)
1879 (defvar gnus-newsgroup-prepared nil
1880 "Whether the current group has been prepared properly.")
1882 (defvar gnus-newsgroup-ancient nil
1883 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1885 (defvar gnus-newsgroup-sparse nil)
1887 (defvar gnus-current-article nil)
1888 (defvar gnus-article-current nil)
1889 (defvar gnus-current-headers nil)
1890 (defvar gnus-have-all-headers nil)
1891 (defvar gnus-last-article nil)
1892 (defvar gnus-newsgroup-history nil)
1893 (defvar gnus-current-kill-article nil)
1895 ;; Save window configuration.
1896 (defvar gnus-prev-winconf nil)
1898 (defvar gnus-summary-mark-positions nil)
1899 (defvar gnus-group-mark-positions nil)
1901 (defvar gnus-reffed-article-number nil)
1903 ;;; Let the byte-compiler know that we know about this variable.
1904 (defvar rmail-default-rmail-file)
1906 (defvar gnus-cache-removable-articles nil)
1908 (defvar gnus-dead-summary nil)
1910 (defconst gnus-summary-local-variables
1911 '(gnus-newsgroup-name
1912 gnus-newsgroup-begin gnus-newsgroup-end
1913 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1914 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1915 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1916 gnus-newsgroup-unselected gnus-newsgroup-marked
1917 gnus-newsgroup-reads gnus-newsgroup-saved
1918 gnus-newsgroup-replied gnus-newsgroup-expirable
1919 gnus-newsgroup-processable gnus-newsgroup-killed
1920 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1921 gnus-newsgroup-headers gnus-newsgroup-threads
1922 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1923 gnus-current-article gnus-current-headers gnus-have-all-headers
1924 gnus-last-article gnus-article-internal-prepare-hook
1925 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1926 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1927 gnus-newsgroup-async gnus-thread-expunge-below
1928 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1929 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1930 gnus-newsgroup-history gnus-newsgroup-ancient
1931 gnus-newsgroup-sparse
1932 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1933 gnus-newsgroup-adaptive-score-file
1934 (gnus-newsgroup-expunged-tally . 0)
1935 gnus-cache-removable-articles gnus-newsgroup-cached
1936 gnus-newsgroup-data gnus-newsgroup-data-reverse
1937 gnus-newsgroup-limit gnus-newsgroup-limits)
1938 "Variables that are buffer-local to the summary buffers.")
1940 (defconst gnus-bug-message
1941 "Sending a bug report to the Gnus Towers.
1942 ========================================
1944 The buffer below is a mail buffer. When you press `C-c C-c', it will
1945 be sent to the Gnus Bug Exterminators.
1947 At the bottom of the buffer you'll see lots of variable settings.
1948 Please do not delete those. They will tell the Bug People what your
1949 environment is, so that it will be easier to locate the bugs.
1951 If you have found a bug that makes Emacs go \"beep\", set
1952 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1953 and include the backtrace in your bug report.
1955 Please describe the bug in annoying, painstaking detail.
1957 Thank you for your help in stamping out bugs.
1960 ;;; End of variables.
1962 ;; Define some autoload functions Gnus might use.
1965 ;; This little mapcar goes through the list below and marks the
1966 ;; symbols in question as autoloaded functions.
1969 (let ((interactive (nth 1 (memq ':interactive package))))
1973 (when (consp function)
1974 (setq keymap (car (memq 'keymap function)))
1975 (setq function (car function)))
1976 (autoload function (car package) nil interactive keymap)))
1977 (if (eq (nth 1 package) ':interactive)
1980 '(("metamail" metamail-buffer)
1981 ("info" Info-goto-node)
1982 ("hexl" hexl-hex-string-to-integer)
1983 ("pp" pp pp-to-string pp-eval-expression)
1984 ("mail-extr" mail-extract-address-components)
1985 ("nnmail" nnmail-split-fancy nnmail-article-group)
1986 ("nnvirtual" nnvirtual-catchup-group)
1987 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1988 timezone-make-sortable-date timezone-make-time-string)
1989 ("sendmail" mail-position-on-field mail-setup)
1990 ("rmailout" rmail-output)
1991 ("rnewspost" news-mail-other-window news-reply-yank-original
1992 news-caesar-buffer-body)
1993 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1995 ("gnus-soup" :interactive t
1996 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1997 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1998 ("nnsoup" nnsoup-pack-replies)
1999 ("gnus-scomo" :interactive t gnus-score-mode)
2000 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2001 gnus-Folder-save-name gnus-folder-save-name)
2002 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2003 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2004 gnus-server-make-menu-bar gnus-article-make-menu-bar
2005 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2006 gnus-summary-highlight-line gnus-carpal-setup-buffer
2007 gnus-group-highlight-line
2008 gnus-article-add-button gnus-insert-next-page-button
2009 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2010 ("gnus-vis" :interactive t
2011 gnus-article-push-button gnus-article-press-button
2012 gnus-article-highlight gnus-article-highlight-some
2013 gnus-article-highlight-headers gnus-article-highlight-signature
2014 gnus-article-add-buttons gnus-article-add-buttons-to-head
2015 gnus-article-next-button gnus-article-prev-button)
2016 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2017 gnus-demon-add-disconnection gnus-demon-add-handler
2018 gnus-demon-remove-handler)
2019 ("gnus-demon" :interactive t
2020 gnus-demon-init gnus-demon-cancel)
2021 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2022 gnus-tree-open gnus-tree-close)
2023 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2024 gnus-nocem-unwanted-article-p)
2025 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2026 ("gnus-srvr" gnus-browse-foreign-server)
2027 ("gnus-cite" :interactive t
2028 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2029 gnus-article-hide-citation gnus-article-fill-cited-article
2030 gnus-article-hide-citation-in-followups)
2031 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2032 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2033 gnus-execute gnus-expunge)
2034 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2035 gnus-cache-possibly-remove-articles gnus-cache-request-article
2036 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2037 gnus-cache-enter-remove-article gnus-cached-article-p
2038 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2039 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2040 gnus-cache-remove-article)
2041 ("gnus-score" :interactive t
2042 gnus-summary-increase-score gnus-summary-lower-score
2043 gnus-score-flush-cache gnus-score-close
2044 gnus-score-raise-same-subject-and-select
2045 gnus-score-raise-same-subject gnus-score-default
2046 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2047 gnus-score-lower-same-subject gnus-score-lower-thread
2048 gnus-possibly-score-headers)
2050 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2051 gnus-current-score-file-nondirectory gnus-score-adaptive
2052 gnus-score-find-trace gnus-score-file-name)
2053 ("gnus-edit" :interactive t gnus-score-customize)
2054 ("gnus-topic" :interactive t gnus-topic-mode)
2055 ("gnus-topic" gnus-topic-remove-group)
2056 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2057 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2058 ("gnus-uu" :interactive t
2059 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2060 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2061 gnus-uu-mark-by-regexp gnus-uu-mark-all
2062 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2063 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2064 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2065 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2066 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2067 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2068 gnus-uu-decode-binhex-view)
2069 ("gnus-msg" (gnus-summary-send-map keymap)
2070 gnus-mail-yank-original gnus-mail-send-and-exit
2071 gnus-sendmail-setup-mail gnus-article-mail
2072 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2073 ("gnus-msg" :interactive t
2074 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2075 gnus-summary-followup gnus-summary-followup-with-original
2076 gnus-summary-followup-and-reply
2077 gnus-summary-followup-and-reply-with-original
2078 gnus-summary-cancel-article gnus-summary-supersede-article
2079 gnus-post-news gnus-inews-news gnus-cancel-news
2080 gnus-summary-reply gnus-summary-reply-with-original
2081 gnus-summary-mail-forward gnus-summary-mail-other-window
2083 ("gnus-picon" :interactive t gnus-article-display-picons
2084 gnus-group-display-picons gnus-picons-article-display-x-face)
2085 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2086 gnus-grouplens-mode)
2087 ("gnus-vm" gnus-vm-mail-setup)
2088 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2089 gnus-summary-save-article-vm gnus-yank-article))))
2093 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2094 ;; If you want the cursor to go somewhere else, set these two
2095 ;; functions in some startup hook to whatever you want.
2096 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2097 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2099 ;;; Various macros and substs.
2101 (defun gnus-header-from (header)
2102 (mail-header-from header))
2104 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2105 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2106 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2107 `(let ((,tempvar (selected-window)))
2110 (pop-to-buffer ,buffer)
2112 (select-window ,tempvar)))))
2114 (defmacro gnus-gethash (string hashtable)
2115 "Get hash value of STRING in HASHTABLE."
2116 `(symbol-value (intern-soft ,string ,hashtable)))
2118 (defmacro gnus-sethash (string value hashtable)
2119 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2120 `(set (intern ,string ,hashtable) ,value))
2122 (defmacro gnus-intern-safe (string hashtable)
2123 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2124 `(let ((symbol (intern ,string ,hashtable)))
2129 (defmacro gnus-group-unread (group)
2130 "Get the currently computed number of unread articles in GROUP."
2131 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2133 (defmacro gnus-group-entry (group)
2134 "Get the newsrc entry for GROUP."
2135 `(gnus-gethash ,group gnus-newsrc-hashtb))
2137 (defmacro gnus-active (group)
2138 "Get active info on GROUP."
2139 `(gnus-gethash ,group gnus-active-hashtb))
2141 (defmacro gnus-set-active (group active)
2142 "Set GROUP's active info."
2143 `(gnus-sethash ,group ,active gnus-active-hashtb))
2145 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2146 ;; function `substring' might cut on a middle of multi-octet
2148 (defun gnus-truncate-string (str width)
2149 (substring str 0 width))
2151 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2152 ;; to limit the length of a string. This function is necessary since
2153 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2154 (defsubst gnus-limit-string (str width)
2155 (if (> (length str) width)
2156 (substring str 0 width)
2159 (defsubst gnus-simplify-subject-re (subject)
2160 "Remove \"Re:\" from subject lines."
2161 (if (string-match "^[Rr][Ee]: *" subject)
2162 (substring subject (match-end 0))
2165 (defsubst gnus-functionp (form)
2166 "Return non-nil if FORM is funcallable."
2167 (or (and (symbolp form) (fboundp form))
2168 (and (listp form) (eq (car form) 'lambda))))
2170 (defsubst gnus-goto-char (point)
2171 (and point (goto-char point)))
2173 (defmacro gnus-buffer-exists-p (buffer)
2174 `(let ((buffer ,buffer))
2176 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2179 (defmacro gnus-kill-buffer (buffer)
2180 `(let ((buf ,buffer))
2181 (if (gnus-buffer-exists-p buf)
2182 (kill-buffer buf))))
2184 (defsubst gnus-point-at-bol ()
2185 "Return point at the beginning of the line."
2192 (defsubst gnus-point-at-eol ()
2193 "Return point at the end of the line."
2200 (defun gnus-alive-p ()
2201 "Say whether Gnus is running or not."
2202 (and gnus-group-buffer
2203 (get-buffer gnus-group-buffer)))
2205 ;; Delete the current line (and the next N lines.);
2206 (defmacro gnus-delete-line (&optional n)
2207 `(delete-region (progn (beginning-of-line) (point))
2208 (progn (forward-line ,(or n 1)) (point))))
2210 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2211 (defvar gnus-init-inhibit nil)
2212 (defun gnus-read-init-file (&optional inhibit-next)
2213 (if gnus-init-inhibit
2214 (setq gnus-init-inhibit nil)
2215 (setq gnus-init-inhibit inhibit-next)
2217 (or (and (file-exists-p gnus-init-file)
2218 ;; Don't try to load a directory.
2219 (not (file-directory-p gnus-init-file)))
2220 (file-exists-p (concat gnus-init-file ".el"))
2221 (file-exists-p (concat gnus-init-file ".elc")))
2223 (load gnus-init-file nil t)
2225 (error "Error in %s: %s" gnus-init-file var))))))
2227 ;; Info access macros.
2229 (defmacro gnus-info-group (info)
2231 (defmacro gnus-info-rank (info)
2233 (defmacro gnus-info-read (info)
2235 (defmacro gnus-info-marks (info)
2237 (defmacro gnus-info-method (info)
2239 (defmacro gnus-info-params (info)
2242 (defmacro gnus-info-level (info)
2243 `(let ((rank (gnus-info-rank ,info)))
2247 (defmacro gnus-info-score (info)
2248 `(let ((rank (gnus-info-rank ,info)))
2249 (or (and (consp rank) (cdr rank)) 0)))
2251 (defmacro gnus-info-set-group (info group)
2252 `(setcar ,info ,group))
2253 (defmacro gnus-info-set-rank (info rank)
2254 `(setcar (nthcdr 1 ,info) ,rank))
2255 (defmacro gnus-info-set-read (info read)
2256 `(setcar (nthcdr 2 ,info) ,read))
2257 (defmacro gnus-info-set-marks (info marks)
2258 `(setcar (nthcdr 3 ,info) ,marks))
2259 (defmacro gnus-info-set-method (info method)
2260 `(setcar (nthcdr 4 ,info) ,method))
2261 (defmacro gnus-info-set-params (info params)
2262 `(setcar (nthcdr 5 ,info) ,params))
2264 (defmacro gnus-info-set-level (info level)
2265 `(let ((rank (cdr ,info)))
2266 (if (consp (car rank))
2267 (setcar (car rank) ,level)
2268 (setcar rank ,level))))
2269 (defmacro gnus-info-set-score (info score)
2270 `(let ((rank (cdr ,info)))
2271 (if (consp (car rank))
2272 (setcdr (car rank) ,score)
2273 (setcar rank (cons (car rank) ,score)))))
2275 (defmacro gnus-get-info (group)
2276 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2278 (defun gnus-byte-code (func)
2279 "Return a form that can be `eval'ed based on FUNC."
2280 (let ((fval (symbol-function func)))
2281 (if (byte-code-function-p fval)
2282 (let ((flist (append fval nil)))
2283 (setcar flist 'byte-code)
2285 (cons 'progn (cddr fval)))))
2287 ;;; Load the compatability functions.
2297 (defvar gnus-shutdown-alist nil)
2299 (defun gnus-add-shutdown (function &rest symbols)
2300 "Run FUNCTION whenever one of SYMBOLS is shut down."
2301 (push (cons function symbols) gnus-shutdown-alist))
2303 (defun gnus-shutdown (symbol)
2304 "Shut down everything that waits for SYMBOL."
2305 (let ((alist gnus-shutdown-alist)
2307 (while (setq entry (pop alist))
2308 (when (memq symbol (cdr entry))
2309 (funcall (car entry))))))
2313 ;; Format specs. The chunks below are the machine-generated forms
2314 ;; that are to be evaled as the result of the default format strings.
2315 ;; We write them in here to get them byte-compiled. That way the
2316 ;; default actions will be quite fast, while still retaining the full
2317 ;; flexibility of the user-defined format specs.
2319 ;; First we have lots of dummy defvars to let the compiler know these
2320 ;; are really dynamic variables.
2322 (defvar gnus-tmp-unread)
2323 (defvar gnus-tmp-replied)
2324 (defvar gnus-tmp-score-char)
2325 (defvar gnus-tmp-indentation)
2326 (defvar gnus-tmp-opening-bracket)
2327 (defvar gnus-tmp-lines)
2328 (defvar gnus-tmp-name)
2329 (defvar gnus-tmp-closing-bracket)
2330 (defvar gnus-tmp-subject-or-nil)
2331 (defvar gnus-tmp-subject)
2332 (defvar gnus-tmp-marked)
2333 (defvar gnus-tmp-marked-mark)
2334 (defvar gnus-tmp-subscribed)
2335 (defvar gnus-tmp-process-marked)
2336 (defvar gnus-tmp-number-of-unread)
2337 (defvar gnus-tmp-group-name)
2338 (defvar gnus-tmp-group)
2339 (defvar gnus-tmp-article-number)
2340 (defvar gnus-tmp-unread-and-unselected)
2341 (defvar gnus-tmp-news-method)
2342 (defvar gnus-tmp-news-server)
2343 (defvar gnus-tmp-article-number)
2344 (defvar gnus-mouse-face)
2345 (defvar gnus-mouse-face-prop)
2347 (defun gnus-summary-line-format-spec ()
2348 (insert gnus-tmp-unread gnus-tmp-replied
2349 gnus-tmp-score-char gnus-tmp-indentation)
2354 gnus-tmp-opening-bracket
2355 (format "%4d: %-20s"
2357 (if (> (length gnus-tmp-name) 20)
2358 (substring gnus-tmp-name 0 20)
2360 gnus-tmp-closing-bracket)
2362 gnus-mouse-face-prop gnus-mouse-face)
2363 (insert " " gnus-tmp-subject-or-nil "\n"))
2365 (defvar gnus-summary-line-format-spec
2366 (gnus-byte-code 'gnus-summary-line-format-spec))
2368 (defun gnus-summary-dummy-line-format-spec ()
2375 gnus-mouse-face-prop gnus-mouse-face)
2376 (insert " " gnus-tmp-subject "\n"))
2378 (defvar gnus-summary-dummy-line-format-spec
2379 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2381 (defun gnus-group-line-format-spec ()
2382 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2383 gnus-tmp-process-marked
2384 gnus-group-indentation
2385 (format "%5s: " gnus-tmp-number-of-unread))
2389 (insert gnus-tmp-group "\n")
2391 gnus-mouse-face-prop gnus-mouse-face))
2392 (defvar gnus-group-line-format-spec
2393 (gnus-byte-code 'gnus-group-line-format-spec))
2395 (defvar gnus-format-specs
2396 `((version . ,emacs-version)
2397 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2398 (summary-dummy ,gnus-summary-dummy-line-format
2399 ,gnus-summary-dummy-line-format-spec)
2400 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2402 (defvar gnus-article-mode-line-format-spec nil)
2403 (defvar gnus-summary-mode-line-format-spec nil)
2404 (defvar gnus-group-mode-line-format-spec nil)
2406 ;;; Phew. All that gruft is over, fortunately.
2410 ;;; Gnus Utility Functions
2413 (defun gnus-extract-address-components (from)
2415 ;; First find the address - the thing with the @ in it. This may
2416 ;; not be accurate in mail addresses, but does the trick most of
2417 ;; the time in news messages.
2418 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2419 (setq address (substring from (match-beginning 0) (match-end 0))))
2420 ;; Then we check whether the "name <address>" format is used.
2422 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2423 ;; Linear white space is not required.
2424 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2425 (and (setq name (substring from 0 (match-beginning 0)))
2426 ;; Strip any quotes from the name.
2427 (string-match "\".*\"" name)
2428 (setq name (substring name 1 (1- (match-end 0))))))
2429 ;; If not, then "address (name)" is used.
2431 (and (string-match "(.+)" from)
2432 (setq name (substring from (1+ (match-beginning 0))
2433 (1- (match-end 0)))))
2434 (and (string-match "()" from)
2435 (setq name address))
2436 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2437 ;; XOVER might not support folded From headers.
2438 (and (string-match "(.*" from)
2439 (setq name (substring from (1+ (match-beginning 0))
2441 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2442 (list (or name from) (or address from))))
2444 (defun gnus-fetch-field (field)
2445 "Return the value of the header FIELD of current article."
2448 (let ((case-fold-search t)
2449 (inhibit-point-motion-hooks t))
2450 (nnheader-narrow-to-headers)
2451 (mail-fetch-field field)))))
2453 (defun gnus-goto-colon ()
2455 (search-forward ":" (gnus-point-at-eol) t))
2458 (defun gnus-update-format (var)
2459 "Update the format specification near point."
2464 ;; Find the end of the current word.
2465 (re-search-forward "[ \t\n]" nil t)
2467 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2468 (match-string 1)))))
2469 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2470 (match-string 1 var))))
2471 (entry (assq type gnus-format-specs))
2474 (setq gnus-format-specs (delq entry gnus-format-specs)))
2476 (intern (format "%s-spec" var))
2477 (gnus-parse-format (setq value (symbol-value (intern var)))
2478 (symbol-value (intern (format "%s-alist" var)))
2479 (not (string-match "mode" var))))
2480 (setq spec (symbol-value (intern (format "%s-spec" var))))
2481 (push (list type value spec) gnus-format-specs)
2483 (pop-to-buffer "*Gnus Format*")
2485 (lisp-interaction-mode)
2486 (insert (pp-to-string spec))))
2488 (defun gnus-update-format-specifications (&optional force)
2489 "Update all (necessary) format specifications."
2490 ;; Make the indentation array.
2491 (gnus-make-thread-indent-array)
2493 ;; See whether all the stored info needs to be flushed.
2495 (not (equal emacs-version
2496 (cdr (assq 'version gnus-format-specs)))))
2497 (setq gnus-format-specs nil))
2499 ;; Go through all the formats and see whether they need updating.
2500 (let ((types '(summary summary-dummy group
2501 summary-mode group-mode article-mode))
2502 new-format entry type val)
2503 (while (setq type (pop types))
2504 ;; Jump to the proper buffer to find out the value of
2505 ;; the variable, if possible. (It may be buffer-local.)
2507 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2509 (when (and (boundp buffer)
2510 (setq val (symbol-value buffer))
2512 (buffer-name (get-buffer val)))
2513 (set-buffer (get-buffer val)))
2514 (setq new-format (symbol-value
2515 (intern (format "gnus-%s-line-format" type))))))
2516 (setq entry (cdr (assq type gnus-format-specs)))
2518 (equal (car entry) new-format))
2519 ;; Use the old format.
2520 (set (intern (format "gnus-%s-line-format-spec" type))
2522 ;; This is a new format.
2524 (if (not (stringp new-format))
2525 ;; This is a function call or something.
2527 ;; This is a "real" format.
2531 (intern (format "gnus-%s-line-format-alist"
2532 (if (eq type 'article-mode)
2533 'summary-mode type))))
2534 (not (string-match "mode$" (symbol-name type))))))
2535 ;; Enter the new format spec into the list.
2538 (setcar (cdr entry) val)
2539 (setcar entry new-format))
2540 (push (list type new-format val) gnus-format-specs))
2541 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2543 (unless (assq 'version gnus-format-specs)
2544 (push (cons 'version emacs-version) gnus-format-specs))
2546 (gnus-update-group-mark-positions)
2547 (gnus-update-summary-mark-positions))
2549 (defun gnus-update-summary-mark-positions ()
2550 "Compute where the summary marks are to go."
2552 (when (and gnus-summary-buffer
2553 (get-buffer gnus-summary-buffer)
2554 (buffer-name (get-buffer gnus-summary-buffer)))
2555 (set-buffer gnus-summary-buffer))
2556 (let ((gnus-replied-mark 129)
2557 (gnus-score-below-mark 130)
2558 (gnus-score-over-mark 130)
2561 (spec gnus-summary-line-format-spec)
2564 (gnus-set-work-buffer)
2565 (let ((gnus-summary-line-format-spec spec))
2566 (gnus-summary-insert-line
2567 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2568 (goto-char (point-min))
2569 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2571 (goto-char (point-min))
2572 (push (cons 'replied (and (search-forward "\201" nil t)
2575 (goto-char (point-min))
2576 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2578 (setq gnus-summary-mark-positions pos))))
2580 (defun gnus-update-group-mark-positions ()
2582 (let ((gnus-process-mark 128)
2583 (gnus-group-marked '("dummy.group"))
2584 (gnus-active-hashtb (make-vector 10 0)))
2585 (gnus-set-active "dummy.group" '(0 . 0))
2586 (gnus-set-work-buffer)
2587 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2588 (goto-char (point-min))
2589 (setq gnus-group-mark-positions
2590 (list (cons 'process (and (search-forward "\200" nil t)
2591 (- (point) 2))))))))
2593 (defvar gnus-mouse-face-0 'highlight)
2594 (defvar gnus-mouse-face-1 'highlight)
2595 (defvar gnus-mouse-face-2 'highlight)
2596 (defvar gnus-mouse-face-3 'highlight)
2597 (defvar gnus-mouse-face-4 'highlight)
2599 (defun gnus-mouse-face-function (form type)
2601 (point) (progn ,@form (point))
2602 gnus-mouse-face-prop
2605 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2607 (defvar gnus-face-0 'bold)
2608 (defvar gnus-face-1 'italic)
2609 (defvar gnus-face-2 'bold-italic)
2610 (defvar gnus-face-3 'bold)
2611 (defvar gnus-face-4 'bold)
2613 (defun gnus-face-face-function (form type)
2615 (point) (progn ,@form (point))
2616 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2618 (defun gnus-max-width-function (el max-width)
2619 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2621 `(if (> (length ,el) ,max-width)
2622 (substring ,el 0 ,max-width)
2624 `(let ((val (eval ,el)))
2626 (setq val (int-to-string val)))
2627 (if (> (length val) ,max-width)
2628 (substring val 0 ,max-width)
2631 (defun gnus-parse-format (format spec-alist &optional insert)
2632 ;; This function parses the FORMAT string with the help of the
2633 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2634 ;; string. If the FORMAT string contains the specifiers %( and %)
2635 ;; the text between them will have the mouse-face text property.
2637 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2639 (gnus-parse-complex-format format spec-alist)
2640 ;; This is a simple format.
2641 (gnus-parse-simple-format format spec-alist insert)))
2643 (defun gnus-parse-complex-format (format spec-alist)
2645 (gnus-set-work-buffer)
2647 (goto-char (point-min))
2648 (while (re-search-forward "\"" nil t)
2649 (replace-match "\\\"" nil t))
2650 (goto-char (point-min))
2652 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2653 (let ((number (if (match-beginning 1)
2654 (match-string 1) "0"))
2655 (delim (aref (match-string 2) 0)))
2656 (if (or (= delim ?\() (= delim ?\{))
2657 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2659 (replace-match "\")\""))))
2660 (goto-char (point-max))
2662 (goto-char (point-min))
2663 (let ((form (read (current-buffer))))
2664 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2666 (defun gnus-complex-form-to-spec (form spec-alist)
2671 (gnus-parse-simple-format sform spec-alist t)
2672 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2673 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2677 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2678 ;; This function parses the FORMAT string with the help of the
2679 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2682 spec flist fstring newspec elem beg result dontinsert)
2684 (gnus-set-work-buffer)
2686 (goto-char (point-min))
2687 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2689 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2691 beg (1+ (match-beginning 0)))
2692 ;; First check if there are any specs that look anything like
2693 ;; "%12,12A", ie. with a "max width specification". These have
2694 ;; to be treated specially.
2695 (if (setq beg (match-beginning 1))
2699 (1+ (match-beginning 1)) (match-end 1))))
2701 (setq beg (match-beginning 2)))
2702 ;; Find the specification from `spec-alist'.
2703 (unless (setq elem (cdr (assq spec spec-alist)))
2704 (setq elem '("*" ?s)))
2705 ;; Treat user defined format specifiers specially.
2706 (when (eq (car elem) 'gnus-tmp-user-defined)
2709 (list (intern (concat "gnus-user-format-function-"
2711 'gnus-tmp-header) ?s))
2712 (delete-region (match-beginning 3) (match-end 3)))
2713 (if (not (zerop max-width))
2714 (let ((el (car elem)))
2715 (cond ((= (cadr elem) ?c)
2716 (setq el (list 'char-to-string el)))
2718 (setq el (list 'int-to-string el))))
2719 (setq flist (cons (gnus-max-width-function el max-width)
2723 (setq flist (cons (car elem) flist))
2724 (setq newspec (cadr elem)))))
2725 ;; Remove the old specification (and possibly a ",12" string).
2726 (delete-region beg (match-end 2))
2727 ;; Insert the new specification.
2730 (setq fstring (buffer-substring 1 (point-max))))
2731 ;; Do some postprocessing to increase efficiency.
2736 ((string= fstring "")
2738 ;; Not a format string.
2739 ((not (string-match "%" fstring))
2741 ;; A format string with just a single string spec.
2742 ((string= fstring "%s")
2744 ;; A single character.
2745 ((string= fstring "%c")
2748 ((string= fstring "%d")
2751 (list `(princ ,(car flist)))
2752 (list `(int-to-string ,(car flist)))))
2753 ;; Just lots of chars and strings.
2754 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2756 ;; A single string spec at the beginning of the spec.
2757 ((string-match "\\`%[sc][^%]+\\'" fstring)
2758 (list (car flist) (substring fstring 2)))
2759 ;; A single string spec in the middle of the spec.
2760 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2761 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2762 ;; A single string spec in the end of the spec.
2763 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2764 (list (match-string 1 fstring) (car flist)))
2765 ;; A more complex spec.
2767 (list (cons 'format (cons fstring (nreverse flist)))))))
2773 (cons 'insert result)))
2774 (cond ((stringp result)
2777 (cons 'concat result))
2780 (defun gnus-eval-format (format &optional alist props)
2781 "Eval the format variable FORMAT, using ALIST.
2782 If PROPS, insert the result."
2783 (let ((form (gnus-parse-format format alist props)))
2785 (add-text-properties (point) (progn (eval form) (point)) props)
2788 (defun gnus-remove-text-with-property (prop)
2789 "Delete all text in the current buffer with text property PROP."
2791 (goto-char (point-min))
2793 (while (get-text-property (point) prop)
2795 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2797 (defun gnus-set-work-buffer ()
2798 (if (get-buffer gnus-work-buffer)
2800 (set-buffer gnus-work-buffer)
2802 (set-buffer (get-buffer-create gnus-work-buffer))
2803 (kill-all-local-variables)
2804 (buffer-disable-undo (current-buffer))
2805 (gnus-add-current-to-buffer-list)))
2807 ;; Article file names when saving.
2809 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2810 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2811 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2812 Otherwise, it is like ~/News/news/group/num."
2815 (concat (if (gnus-use-long-file-name 'not-save)
2816 (gnus-capitalize-newsgroup newsgroup)
2817 (gnus-newsgroup-directory-form newsgroup))
2818 "/" (int-to-string (mail-header-number headers)))
2819 (or gnus-article-save-directory "~/News"))))
2821 (string-equal (file-name-directory default)
2822 (file-name-directory last-file))
2823 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2825 (or last-file default))))
2827 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2828 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2829 If variable `gnus-use-long-file-name' is non-nil, it is
2830 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2833 (concat (if (gnus-use-long-file-name 'not-save)
2835 (gnus-newsgroup-directory-form newsgroup))
2836 "/" (int-to-string (mail-header-number headers)))
2837 (or gnus-article-save-directory "~/News"))))
2839 (string-equal (file-name-directory default)
2840 (file-name-directory last-file))
2841 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2843 (or last-file default))))
2845 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2846 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2847 If variable `gnus-use-long-file-name' is non-nil, it is
2848 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2851 (if (gnus-use-long-file-name 'not-save)
2852 (gnus-capitalize-newsgroup newsgroup)
2853 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2854 (or gnus-article-save-directory "~/News"))))
2856 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2857 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2858 If variable `gnus-use-long-file-name' is non-nil, it is
2859 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2862 (if (gnus-use-long-file-name 'not-save)
2864 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2865 (or gnus-article-save-directory "~/News"))))
2867 ;; For subscribing new newsgroup
2869 (defun gnus-subscribe-hierarchical-interactive (groups)
2870 (let ((groups (sort groups 'string<))
2871 prefixes prefix start ans group starts)
2873 (setq prefixes (list "^"))
2874 (while (and groups prefixes)
2875 (while (not (string-match (car prefixes) (car groups)))
2876 (setq prefixes (cdr prefixes)))
2877 (setq prefix (car prefixes))
2878 (setq start (1- (length prefix)))
2879 (if (and (string-match "[^\\.]\\." (car groups) start)
2882 (concat "^" (substring (car groups) 0 (match-end 0))))
2883 (string-match prefix (cadr groups)))
2885 (setq prefixes (cons prefix prefixes))
2886 (message "Descend hierarchy %s? ([y]nsq): "
2887 (substring prefix 1 (1- (length prefix))))
2888 (setq ans (read-char))
2891 (string-match prefix
2892 (setq group (car groups))))
2893 (setq gnus-killed-list
2894 (cons group gnus-killed-list))
2895 (gnus-sethash group group gnus-killed-hashtb)
2896 (setq groups (cdr groups)))
2897 (setq starts (cdr starts)))
2900 (string-match prefix
2901 (setq group (car groups))))
2902 (gnus-sethash group group gnus-killed-hashtb)
2903 (gnus-subscribe-alphabetically (car groups))
2904 (setq groups (cdr groups)))
2905 (setq starts (cdr starts)))
2908 (setq group (car groups))
2909 (setq gnus-killed-list (cons group gnus-killed-list))
2910 (gnus-sethash group group gnus-killed-hashtb)
2911 (setq groups (cdr groups))))
2913 (message "Subscribe %s? ([n]yq)" (car groups))
2914 (setq ans (read-char))
2915 (setq group (car groups))
2917 (gnus-subscribe-alphabetically (car groups))
2918 (gnus-sethash group group gnus-killed-hashtb))
2921 (setq group (car groups))
2922 (setq gnus-killed-list (cons group gnus-killed-list))
2923 (gnus-sethash group group gnus-killed-hashtb)
2924 (setq groups (cdr groups))))
2926 (setq gnus-killed-list (cons group gnus-killed-list))
2927 (gnus-sethash group group gnus-killed-hashtb)))
2928 (setq groups (cdr groups)))))))
2930 (defun gnus-subscribe-randomly (newsgroup)
2931 "Subscribe new NEWSGROUP by making it the first newsgroup."
2932 (gnus-subscribe-newsgroup newsgroup))
2934 (defun gnus-subscribe-alphabetically (newgroup)
2935 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2936 (let ((groups (cdr gnus-newsrc-alist))
2938 (while (and (not before) groups)
2939 (if (string< newgroup (caar groups))
2940 (setq before (caar groups))
2941 (setq groups (cdr groups))))
2942 (gnus-subscribe-newsgroup newgroup before)))
2944 (defun gnus-subscribe-hierarchically (newgroup)
2945 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2946 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2948 (set-buffer (find-file-noselect gnus-current-startup-file))
2949 (let ((groupkey newgroup)
2951 (while (and (not before) groupkey)
2952 (goto-char (point-min))
2954 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2955 (while (and (re-search-forward groupkey-re nil t)
2957 (setq before (match-string 1))
2958 (string< before newgroup)))))
2959 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2961 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2962 (substring groupkey (match-beginning 1) (match-end 1)))))
2963 (gnus-subscribe-newsgroup newgroup before))))
2965 (defun gnus-subscribe-interactively (group)
2966 "Subscribe the new GROUP interactively.
2967 It is inserted in hierarchical newsgroup order if subscribed. If not,
2969 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2970 (gnus-subscribe-hierarchically group)
2971 (push group gnus-killed-list)))
2973 (defun gnus-subscribe-zombies (group)
2974 "Make the new GROUP into a zombie group."
2975 (push group gnus-zombie-list))
2977 (defun gnus-subscribe-killed (group)
2978 "Make the new GROUP a killed group."
2979 (push group gnus-killed-list))
2981 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2982 "Subscribe new NEWSGROUP.
2983 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2984 the first newsgroup."
2985 ;; We subscribe the group by changing its level to `subscribed'.
2986 (gnus-group-change-level
2987 newsgroup gnus-level-default-subscribed
2988 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2989 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2993 (defun gnus-newsgroup-directory-form (newsgroup)
2994 "Make hierarchical directory name from NEWSGROUP name."
2995 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2996 (len (length newsgroup))
2998 ;; If this is a foreign group, we don't want to translate the
3000 (if (setq idx (string-match ":" newsgroup))
3001 (aset newsgroup idx ?/)
3003 ;; Replace all occurrences of `.' with `/'.
3005 (if (= (aref newsgroup idx) ?.)
3006 (aset newsgroup idx ?/))
3007 (setq idx (1+ idx)))
3010 (defun gnus-newsgroup-savable-name (group)
3011 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3013 (nnheader-replace-chars-in-string group ?/ ?.))
3015 (defun gnus-make-directory (dir)
3016 "Make DIRECTORY recursively."
3017 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3018 ;; of the many mysteries of the universe.
3019 (let* ((dir (expand-file-name dir default-directory))
3021 (if (string-match "/$" dir)
3022 (setq dir (substring dir 0 (match-beginning 0))))
3023 ;; First go down the path until we find a directory that exists.
3024 (while (not (file-exists-p dir))
3025 (setq dirs (cons dir dirs))
3026 (string-match "/[^/]+$" dir)
3027 (setq dir (substring dir 0 (match-beginning 0))))
3028 ;; Then create all the subdirs.
3029 (while (and dirs (not err))
3031 (make-directory (car dirs))
3032 (error (setq err t)))
3033 (setq dirs (cdr dirs)))
3034 ;; We return whether we were successful or not.
3037 (defun gnus-capitalize-newsgroup (newsgroup)
3038 "Capitalize NEWSGROUP name."
3039 (and (not (zerop (length newsgroup)))
3040 (concat (char-to-string (upcase (aref newsgroup 0)))
3041 (substring newsgroup 1))))
3043 ;; Various... things.
3045 (defun gnus-simplify-subject (subject &optional re-only)
3046 "Remove `Re:' and words in parentheses.
3047 If RE-ONLY is non-nil, strip leading `Re:'s only."
3048 (let ((case-fold-search t)) ;Ignore case.
3049 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3050 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3051 (setq subject (substring subject (match-end 0))))
3052 ;; Remove uninteresting prefixes.
3053 (if (and (not re-only)
3054 gnus-simplify-ignored-prefixes
3055 (string-match gnus-simplify-ignored-prefixes subject))
3056 (setq subject (substring subject (match-end 0))))
3057 ;; Remove words in parentheses from end.
3059 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3060 (setq subject (substring subject 0 (match-beginning 0)))))
3061 ;; Return subject string.
3064 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3066 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3067 (defun gnus-simplify-buffer-fuzzy ()
3068 (goto-char (point-min))
3069 (while (search-forward "\t" nil t)
3070 (replace-match " " t t))
3071 (goto-char (point-min))
3072 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3073 (goto-char (match-beginning 0))
3075 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3076 (looking-at "^[[].*: .*[]]$"))
3077 (goto-char (point-min))
3078 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3080 (replace-match "" t t))
3081 (goto-char (point-min))
3082 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3083 (goto-char (match-end 0))
3086 (progn (goto-char (match-beginning 0)))
3087 (re-search-forward ":"))))
3088 (goto-char (point-min))
3089 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3090 (replace-match "" t t))
3091 (goto-char (point-min))
3092 (while (re-search-forward " +" nil t)
3093 (replace-match " " t t))
3094 (goto-char (point-min))
3095 (while (re-search-forward " $" nil t)
3096 (replace-match "" t t))
3097 (goto-char (point-min))
3098 (while (re-search-forward "^ +" nil t)
3099 (replace-match "" t t))
3100 (goto-char (point-min))
3101 (when gnus-simplify-subject-fuzzy-regexp
3102 (if (listp gnus-simplify-subject-fuzzy-regexp)
3103 (let ((list gnus-simplify-subject-fuzzy-regexp))
3105 (goto-char (point-min))
3106 (while (re-search-forward (car list) nil t)
3107 (replace-match "" t t))
3108 (setq list (cdr list))))
3109 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3110 (replace-match "" t t)))))
3112 (defun gnus-simplify-subject-fuzzy (subject)
3113 "Siplify a subject string fuzzily."
3115 (gnus-set-work-buffer)
3116 (let ((case-fold-search t))
3118 (inline (gnus-simplify-buffer-fuzzy))
3121 ;; Add the current buffer to the list of buffers to be killed on exit.
3122 (defun gnus-add-current-to-buffer-list ()
3123 (or (memq (current-buffer) gnus-buffer-list)
3124 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3126 (defun gnus-string> (s1 s2)
3127 (not (or (string< s1 s2)
3130 (defun gnus-read-active-file-p ()
3131 "Say whether the active file has been read from `gnus-select-method'."
3132 (memq gnus-select-method gnus-have-read-active-file))
3134 ;;; General various misc type functions.
3136 (defun gnus-clear-system ()
3137 "Clear all variables and buffers."
3138 ;; Clear Gnus variables.
3139 (let ((variables gnus-variable-list))
3141 (set (car variables) nil)
3142 (setq variables (cdr variables))))
3143 ;; Clear other internal variables.
3144 (setq gnus-list-of-killed-groups nil
3145 gnus-have-read-active-file nil
3146 gnus-newsrc-alist nil
3147 gnus-newsrc-hashtb nil
3148 gnus-killed-list nil
3149 gnus-zombie-list nil
3150 gnus-killed-hashtb nil
3151 gnus-active-hashtb nil
3152 gnus-moderated-list nil
3153 gnus-description-hashtb nil
3154 gnus-current-headers nil
3155 gnus-thread-indent-array nil
3156 gnus-newsgroup-headers nil
3157 gnus-newsgroup-name nil
3158 gnus-server-alist nil
3159 gnus-group-list-mode nil
3160 gnus-opened-servers nil
3161 gnus-current-select-method nil)
3162 (gnus-shutdown 'gnus)
3163 ;; Kill the startup file.
3164 (and gnus-current-startup-file
3165 (get-file-buffer gnus-current-startup-file)
3166 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3167 ;; Clear the dribble buffer.
3168 (gnus-dribble-clear)
3169 ;; Kill global KILL file buffer.
3170 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3171 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3172 (gnus-kill-buffer nntp-server-buffer)
3173 ;; Kill Gnus buffers.
3174 (while gnus-buffer-list
3175 (gnus-kill-buffer (pop gnus-buffer-list)))
3176 ;; Remove Gnus frames.
3177 (while gnus-created-frames
3178 (when (frame-live-p (car gnus-created-frames))
3179 ;; We slap a condition-case around this `delete-frame' to ensure
3180 ;; agains errors if we try do delete the single frame that's left.
3182 (delete-frame (car gnus-created-frames))
3184 (pop gnus-created-frames)))
3186 (defun gnus-windows-old-to-new (setting)
3187 ;; First we take care of the really, really old Gnus 3 actions.
3188 (when (symbolp setting)
3190 ;; Take care of ooold GNUS 3.x values.
3191 (cond ((eq setting 'SelectArticle) 'article)
3192 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3193 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3195 (if (or (listp setting)
3196 (not (and gnus-window-configuration
3197 (memq setting '(group summary article)))))
3199 (let* ((setting (if (eq setting 'group)
3200 (if (assq 'newsgroup gnus-window-configuration)
3202 'newsgroups) setting))
3203 (elem (cadr (assq setting gnus-window-configuration)))
3204 (total (apply '+ elem))
3205 (types '(group summary article))
3206 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3211 (or (not (numberp (nth i elem)))
3212 (zerop (nth i elem))
3214 (setq perc (/ (float (nth 0 elem)) total))
3215 (setq out (cons (if (eq pbuf (nth i types))
3216 (vector (nth i types) perc 'point)
3217 (vector (nth i types) perc))
3220 (list (nreverse out)))))
3223 (defun gnus-add-configuration (conf)
3224 "Add the window configuration CONF to `gnus-buffer-configuration'."
3225 (setq gnus-buffer-configuration
3226 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3227 gnus-buffer-configuration))))
3229 (defvar gnus-frame-list nil)
3231 (defun gnus-configure-frame (split &optional window)
3232 "Split WINDOW according to SPLIT."
3234 (setq window (get-buffer-window (current-buffer))))
3235 (select-window window)
3236 ;; This might be an old-stylee buffer config.
3237 (when (vectorp split)
3238 (setq split (append split nil)))
3239 (when (or (consp (car split))
3240 (vectorp (car split)))
3242 (push 'vertical split))
3243 ;; The SPLIT might be something that is to be evaled to
3244 ;; return a new SPLIT.
3245 (while (and (not (assq (car split) gnus-window-to-buffer))
3246 (gnus-functionp (car split)))
3247 (setq split (eval split)))
3248 (let* ((type (car split))
3250 (len (if (eq type 'horizontal) (window-width) (window-height)))
3252 (window-min-width (or gnus-window-min-width window-min-width))
3253 (window-min-height (or gnus-window-min-height window-min-height))
3254 s result new-win rest comp-subs size sub)
3256 ;; Nothing to do here.
3258 ;; Don't switch buffers.
3260 (and (memq 'point split) window))
3261 ;; This is a buffer to be selected.
3262 ((not (memq type '(frame horizontal vertical)))
3263 (let ((buffer (cond ((stringp type) type)
3264 (t (cdr (assq type gnus-window-to-buffer)))))
3267 (error "Illegal buffer type: %s" type))
3268 (unless (setq buf (get-buffer (if (symbolp buffer)
3269 (symbol-value buffer) buffer)))
3270 (setq buf (get-buffer-create (if (symbolp buffer)
3271 (symbol-value buffer) buffer))))
3272 (switch-to-buffer buf)
3273 ;; We return the window if it has the `point' spec.
3274 (and (memq 'point split) window)))
3275 ;; This is a frame split.
3277 (unless gnus-frame-list
3278 (setq gnus-frame-list (list (window-frame
3279 (get-buffer-window (current-buffer))))))
3281 params frame fresult)
3282 (while (< i (length subs))
3283 ;; Frame parameter is gotten from the sub-split.
3284 (setq params (cadr (elt subs i)))
3285 ;; It should be a list.
3286 (unless (listp params)
3288 ;; Create a new frame?
3289 (unless (setq frame (elt gnus-frame-list i))
3290 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3291 (push frame gnus-created-frames))
3292 ;; Is the old frame still alive?
3293 (unless (frame-live-p frame)
3294 (setcar (nthcdr i gnus-frame-list)
3295 (setq frame (make-frame params))))
3296 ;; Select the frame in question and do more splits there.
3297 (select-frame frame)
3298 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3300 ;; Select the frame that has the selected buffer.
3302 (select-frame (window-frame fresult)))))
3303 ;; This is a normal split.
3305 (when (> (length subs) 0)
3306 ;; First we have to compute the sizes of all new windows.
3308 (setq sub (append (pop subs) nil))
3309 (while (and (not (assq (car sub) gnus-window-to-buffer))
3310 (gnus-functionp (car sub)))
3311 (setq sub (eval sub)))
3313 (push sub comp-subs)
3314 (setq size (cadar comp-subs))
3315 (cond ((equal size 1.0)
3316 (setq rest (car comp-subs))
3319 (setq s (floor (* size len))))
3323 (error "Illegal size: %s" size)))
3324 ;; Try to make sure that we are inside the safe limits.
3326 ((eq type 'horizontal)
3327 (setq s (max s window-min-width)))
3328 ((eq type 'vertical)
3329 (setq s (max s window-min-height))))
3330 (setcar (cdar comp-subs) s)
3332 ;; Take care of the "1.0" spec.
3334 (setcar (cdr rest) (- len total))
3335 (error "No 1.0 specs in %s" split))
3336 ;; The we do the actual splitting in a nice recursive
3338 (setq comp-subs (nreverse comp-subs))
3340 (if (null (cdr comp-subs))
3341 (setq new-win window)
3343 (split-window window (cadar comp-subs)
3344 (eq type 'horizontal))))
3345 (setq result (or (gnus-configure-frame
3346 (car comp-subs) window) result))
3347 (select-window new-win)
3348 (setq window new-win)
3349 (setq comp-subs (cdr comp-subs))))
3350 ;; Return the proper window, if any.
3352 (select-window result))))))
3354 (defvar gnus-frame-split-p nil)
3356 (defun gnus-configure-windows (setting &optional force)
3357 (setq setting (gnus-windows-old-to-new setting))
3358 (let ((split (if (symbolp setting)
3359 (cadr (assq setting gnus-buffer-configuration))
3363 (setq gnus-frame-split-p nil)
3366 (error "No such setting: %s" setting))
3368 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3370 ;; All the windows mentioned are already visible, so we just
3371 ;; put point in the assigned buffer, and do not touch the
3373 (select-window all-visible)
3375 ;; Either remove all windows or just remove all Gnus windows.
3376 (let ((frame (selected-frame)))
3378 (if gnus-use-full-window
3379 ;; We want to remove all other windows.
3380 (if (not gnus-frame-split-p)
3381 ;; This is not a `frame' split, so we ignore the
3383 (delete-other-windows)
3384 ;; This is a `frame' split, so we delete all windows
3388 (unless (eq (cdr (assq 'minibuffer
3389 (frame-parameters frame)))
3391 (select-frame frame)
3392 (delete-other-windows)))
3394 ;; Just remove some windows.
3395 (gnus-remove-some-windows)
3396 (switch-to-buffer nntp-server-buffer))
3397 (select-frame frame)))
3399 (switch-to-buffer nntp-server-buffer)
3400 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3402 (defun gnus-all-windows-visible-p (split)
3403 "Say whether all buffers in SPLIT are currently visible.
3404 In particular, the value returned will be the window that
3406 (let ((stack (list split))
3408 type buffer win buf)
3409 (while (and (setq split (pop stack))
3411 ;; Be backwards compatible.
3412 (when (vectorp split)
3413 (setq split (append split nil)))
3414 (when (or (consp (car split))
3415 (vectorp (car split)))
3417 (push 'vertical split))
3418 ;; The SPLIT might be something that is to be evaled to
3419 ;; return a new SPLIT.
3420 (while (and (not (assq (car split) gnus-window-to-buffer))
3421 (gnus-functionp (car split)))
3422 (setq split (eval split)))
3424 (setq type (elt split 0))
3429 ((not (memq type '(horizontal vertical frame)))
3430 (setq buffer (cond ((stringp type) type)
3431 (t (cdr (assq type gnus-window-to-buffer)))))
3433 (error "Illegal buffer type: %s" type))
3434 (when (setq buf (get-buffer (if (symbolp buffer)
3435 (symbol-value buffer)
3437 (setq win (get-buffer-window buf t)))
3439 (when (memq 'point split)
3440 (setq all-visible win))
3441 (setq all-visible nil)))
3443 (when (eq type 'frame)
3444 (setq gnus-frame-split-p t))
3445 (setq stack (append (cddr split) stack)))))
3446 (unless (eq all-visible t)
3449 (defun gnus-window-top-edge (&optional window)
3450 (nth 1 (window-edges window)))
3452 (defun gnus-remove-some-windows ()
3453 (let ((buffers gnus-window-to-buffer)
3454 buf bufs lowest-buf lowest)
3456 ;; Remove windows on all known Gnus buffers.
3458 (setq buf (cdar buffers))
3460 (setq buf (and (boundp buf) (symbol-value buf))))
3462 (get-buffer-window buf)
3464 (setq bufs (cons buf bufs))
3466 (if (or (not lowest)
3467 (< (gnus-window-top-edge) lowest))
3469 (setq lowest (gnus-window-top-edge))
3470 (setq lowest-buf buf)))))
3471 (setq buffers (cdr buffers)))
3472 ;; Remove windows on *all* summary buffers.
3475 (let ((buf (window-buffer win)))
3476 (if (string-match "^\\*Summary" (buffer-name buf))
3478 (setq bufs (cons buf bufs))
3480 (if (or (not lowest)
3481 (< (gnus-window-top-edge) lowest))
3483 (setq lowest-buf buf)
3484 (setq lowest (gnus-window-top-edge)))))))))
3487 (pop-to-buffer lowest-buf)
3488 (switch-to-buffer nntp-server-buffer)))
3490 (and (not (eq (car bufs) lowest-buf))
3491 (delete-windows-on (car bufs)))
3492 (setq bufs (cdr bufs))))))
3494 (defun gnus-version ()
3495 "Version numbers of this version of Gnus."
3497 (let ((methods gnus-valid-select-methods)
3500 ;; Go through all the legal select methods and add their version
3501 ;; numbers to the total version string. Only the backends that are
3502 ;; currently in use will have their message numbers taken into
3505 (setq meth (intern (concat (caar methods) "-version")))
3507 (stringp (symbol-value meth))
3508 (setq mess (concat mess "; " (symbol-value meth))))
3509 (setq methods (cdr methods)))
3510 (gnus-message 2 mess)))
3512 (defun gnus-info-find-node ()
3513 "Find Info documentation of Gnus."
3515 ;; Enlarge info window if needed.
3516 (let ((mode major-mode)
3518 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3519 (setq gnus-info-buffer (current-buffer))
3520 (gnus-configure-windows 'info)))
3522 (defun gnus-days-between (date1 date2)
3523 ;; Return the number of days between date1 and date2.
3524 (- (gnus-day-number date1) (gnus-day-number date2)))
3526 (defun gnus-day-number (date)
3527 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3528 (timezone-parse-date date))))
3529 (timezone-absolute-from-gregorian
3530 (nth 1 dat) (nth 2 dat) (car dat))))
3532 (defun gnus-encode-date (date)
3533 "Convert DATE to internal time."
3534 (let* ((parse (timezone-parse-date date))
3535 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3536 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3537 (encode-time (caddr time) (cadr time) (car time)
3538 (caddr date) (cadr date) (car date) (nth 4 date))))
3540 (defun gnus-time-minus (t1 t2)
3541 "Subtract two internal times."
3542 (let ((borrow (< (cadr t1) (cadr t2))))
3543 (list (- (car t1) (car t2) (if borrow 1 0))
3544 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3546 (defun gnus-file-newer-than (file date)
3547 (let ((fdate (nth 5 (file-attributes file))))
3548 (or (> (car fdate) (car date))
3549 (and (= (car fdate) (car date))
3550 (> (nth 1 fdate) (nth 1 date))))))
3552 (defmacro gnus-local-set-keys (&rest plist)
3553 "Set the keys in PLIST in the current keymap."
3554 `(gnus-define-keys-1 (current-local-map) ',plist))
3556 (defmacro gnus-define-keys (keymap &rest plist)
3557 "Define all keys in PLIST in KEYMAP."
3558 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3560 (put 'gnus-define-keys 'lisp-indent-function 1)
3561 (put 'gnus-define-keys 'lisp-indent-hook 1)
3562 (put 'gnus-define-keymap 'lisp-indent-function 1)
3563 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3565 (defmacro gnus-define-keymap (keymap &rest plist)
3566 "Define all keys in PLIST in KEYMAP."
3567 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3569 (defun gnus-define-keys-1 (keymap plist)
3571 (error "Can't set keys in a null keymap"))
3572 (cond ((symbolp keymap)
3573 (setq keymap (symbol-value keymap)))
3576 (set (car keymap) nil)
3577 (define-prefix-command (car keymap))
3578 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3579 (setq keymap (symbol-value (car keymap)))))
3582 (when (symbolp (setq key (pop plist)))
3583 (setq key (symbol-value key)))
3584 (define-key keymap key (pop plist)))))
3586 (defun gnus-group-read-only-p (&optional group)
3587 "Check whether GROUP supports editing or not.
3588 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3589 that that variable is buffer-local to the summary buffers."
3590 (let ((group (or group gnus-newsgroup-name)))
3591 (not (gnus-check-backend-function 'request-replace-article group))))
3593 (defun gnus-group-total-expirable-p (group)
3594 "Check whether GROUP is total-expirable or not."
3595 (let ((params (gnus-info-params (gnus-get-info group))))
3596 (or (memq 'total-expire params)
3597 (cdr (assq 'total-expire params)) ; (total-expire . t)
3598 (and gnus-total-expirable-newsgroups ; Check var.
3599 (string-match gnus-total-expirable-newsgroups group)))))
3601 (defun gnus-group-auto-expirable-p (group)
3602 "Check whether GROUP is total-expirable or not."
3603 (let ((params (gnus-info-params (gnus-get-info group))))
3604 (or (memq 'auto-expire params)
3605 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3606 (and gnus-auto-expirable-newsgroups ; Check var.
3607 (string-match gnus-auto-expirable-newsgroups group)))))
3609 (defun gnus-virtual-group-p (group)
3610 "Say whether GROUP is virtual or not."
3611 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3612 gnus-valid-select-methods)))
3614 (defun gnus-news-group-p (group &optional article)
3615 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3616 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3617 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3618 (eq (gnus-request-type group article) 'news))))
3620 (defsubst gnus-simplify-subject-fully (subject)
3621 "Simplify a subject string according to the user's wishes."
3623 ((null gnus-summary-gather-subject-limit)
3624 (gnus-simplify-subject-re subject))
3625 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3626 (gnus-simplify-subject-fuzzy subject))
3627 ((numberp gnus-summary-gather-subject-limit)
3628 (gnus-limit-string (gnus-simplify-subject-re subject)
3629 gnus-summary-gather-subject-limit))
3633 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3634 "Check whether two subjects are equal. If optional argument
3635 simple-first is t, first argument is already simplified."
3637 ((null simple-first)
3638 (equal (gnus-simplify-subject-fully s1)
3639 (gnus-simplify-subject-fully s2)))
3642 (gnus-simplify-subject-fully s2)))))
3644 ;; Returns a list of writable groups.
3645 (defun gnus-writable-groups ()
3646 (let ((alist gnus-newsrc-alist)
3648 (while (setq group (car (pop alist)))
3649 (unless (gnus-group-read-only-p group)
3650 (push group groups)))
3653 (defun gnus-completing-read (default prompt &rest args)
3654 ;; Like `completing-read', except that DEFAULT is the default argument.
3655 (let* ((prompt (if default
3656 (concat prompt " (default " default ") ")
3657 (concat prompt " ")))
3658 (answer (apply 'completing-read prompt args)))
3659 (if (or (null answer) (zerop (length answer)))
3663 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3665 (defun gnus-y-or-n-p (prompt)
3670 (defun gnus-yes-or-no-p (prompt)
3672 (yes-or-no-p prompt)
3675 ;; Check whether to use long file names.
3676 (defun gnus-use-long-file-name (symbol)
3677 ;; The variable has to be set...
3678 (and gnus-use-long-file-name
3679 ;; If it isn't a list, then we return t.
3680 (or (not (listp gnus-use-long-file-name))
3681 ;; If it is a list, and the list contains `symbol', we
3683 (not (memq symbol gnus-use-long-file-name)))))
3685 ;; I suspect there's a better way, but I haven't taken the time to do
3686 ;; it yet. -erik selberg@cs.washington.edu
3687 (defun gnus-dd-mmm (messy-date)
3688 "Return a string like DD-MMM from a big messy string"
3689 (let ((datevec (timezone-parse-date messy-date)))
3692 ;; Make sure leading zeroes are stripped.
3693 (number-to-string (string-to-number (aref datevec 2)))
3697 (nth (1- (string-to-number (aref datevec 1)))
3698 timezone-months-assoc))
3701 ;; Make a hash table (default and minimum size is 255).
3702 ;; Optional argument HASHSIZE specifies the table size.
3703 (defun gnus-make-hashtable (&optional hashsize)
3704 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3706 ;; Make a number that is suitable for hashing; bigger than MIN and one
3708 (defun gnus-create-hash-size (min)
3714 ;; Show message if message has a lower level than `gnus-verbose'.
3715 ;; Guideline for numbers:
3716 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3717 ;; for things that take a long time, 7 - not very important messages
3718 ;; on stuff, 9 - messages inside loops.
3719 (defun gnus-message (level &rest args)
3720 (if (<= level gnus-verbose)
3721 (apply 'message args)
3722 ;; We have to do this format thingy here even if the result isn't
3723 ;; shown - the return value has to be the same as the return value
3725 (apply 'format args)))
3727 (defun gnus-error (level &rest args)
3728 "Beep an error if `gnus-verbose' is on LEVEL or less."
3729 (when (<= (floor level) gnus-verbose)
3730 (apply 'message args)
3733 (when (and (floatp level)
3734 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3735 (sit-for duration))))
3738 ;; Generate a unique new group name.
3739 (defun gnus-generate-new-group-name (leaf)
3742 (while (gnus-gethash name gnus-newsrc-hashtb)
3743 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3746 (defsubst gnus-hide-text (b e props)
3747 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3748 (add-text-properties b e props)
3749 (when (memq 'intangible props)
3750 (put-text-property (max (1- b) (point-min))
3751 b 'intangible (cddr (memq 'intangible props)))))
3753 (defsubst gnus-unhide-text (b e)
3754 "Remove hidden text properties from region between B and E."
3755 (remove-text-properties b e gnus-hidden-properties)
3756 (when (memq 'intangible gnus-hidden-properties)
3757 (put-text-property (max (1- b) (point-min))
3758 b 'intangible nil)))
3760 (defun gnus-hide-text-type (b e type)
3761 "Hide text of TYPE between B and E."
3762 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3764 ;; Find out whether the gnus-visual TYPE is wanted.
3765 (defun gnus-visual-p (&optional type class)
3766 (and gnus-visual ; Has to be non-nil, at least.
3767 (if (not type) ; We don't care about type.
3769 (if (listp gnus-visual) ; It's a list, so we check it.
3770 (or (memq type gnus-visual)
3771 (memq class gnus-visual))
3774 (defun gnus-parent-id (references)
3775 "Return the last Message-ID in REFERENCES."
3776 (when (and references
3777 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3778 (substring references (match-beginning 1) (match-end 1))))
3780 (defun gnus-split-references (references)
3781 "Return a list of Message-IDs in REFERENCES."
3784 (while (string-match "<[^>]+>" references beg)
3785 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3789 (defun gnus-buffer-live-p (buffer)
3790 "Say whether BUFFER is alive or not."
3793 (buffer-name (get-buffer buffer))))
3795 (defun gnus-ephemeral-group-p (group)
3796 "Say whether GROUP is ephemeral or not."
3797 (gnus-group-get-parameter group 'quit-config))
3799 (defun gnus-group-quit-config (group)
3800 "Return the quit-config of GROUP."
3801 (gnus-group-get-parameter group 'quit-config))
3803 (defun gnus-simplify-mode-line ()
3804 "Make mode lines a bit simpler."
3805 (setq mode-line-modified "-- ")
3806 (when (listp mode-line-format)
3807 (make-local-variable 'mode-line-format)
3808 (setq mode-line-format (copy-sequence mode-line-format))
3809 (when (equal (nth 3 mode-line-format) " ")
3810 (setcar (nthcdr 3 mode-line-format) " "))))
3812 ;;; List and range functions
3814 (defun gnus-last-element (list)
3815 "Return last element of LIST."
3817 (setq list (cdr list)))
3820 (defun gnus-copy-sequence (list)
3821 "Do a complete, total copy of a list."
3822 (if (and (consp list) (not (consp (cdr list))))
3823 (cons (car list) (cdr list))
3824 (mapcar (lambda (elem) (if (consp elem)
3825 (if (consp (cdr elem))
3826 (gnus-copy-sequence elem)
3827 (cons (car elem) (cdr elem)))
3831 (defun gnus-set-difference (list1 list2)
3832 "Return a list of elements of LIST1 that do not appear in LIST2."
3833 (let ((list1 (copy-sequence list1)))
3835 (setq list1 (delq (car list2) list1))
3836 (setq list2 (cdr list2)))
3839 (defun gnus-sorted-complement (list1 list2)
3840 "Return a list of elements of LIST1 that do not appear in LIST2.
3841 Both lists have to be sorted over <."
3843 (if (or (null list1) (null list2))
3845 (while (and list1 list2)
3846 (cond ((= (car list1) (car list2))
3847 (setq list1 (cdr list1)
3849 ((< (car list1) (car list2))
3850 (setq out (cons (car list1) out))
3851 (setq list1 (cdr list1)))
3853 (setq out (cons (car list2) out))
3854 (setq list2 (cdr list2)))))
3855 (nconc (nreverse out) (or list1 list2)))))
3857 (defun gnus-intersection (list1 list2)
3860 (if (memq (car list2) list1)
3861 (setq result (cons (car list2) result)))
3862 (setq list2 (cdr list2)))
3865 (defun gnus-sorted-intersection (list1 list2)
3866 ;; LIST1 and LIST2 have to be sorted over <.
3868 (while (and list1 list2)
3869 (cond ((= (car list1) (car list2))
3870 (setq out (cons (car list1) out)
3873 ((< (car list1) (car list2))
3874 (setq list1 (cdr list1)))
3876 (setq list2 (cdr list2)))))
3879 (defun gnus-set-sorted-intersection (list1 list2)
3880 ;; LIST1 and LIST2 have to be sorted over <.
3881 ;; This function modifies LIST1.
3882 (let* ((top (cons nil list1))
3884 (while (and list1 list2)
3885 (cond ((= (car list1) (car list2))
3889 ((< (car list1) (car list2))
3890 (setcdr prev (cdr list1))
3891 (setq list1 (cdr list1)))
3893 (setq list2 (cdr list2)))))
3897 (defun gnus-compress-sequence (numbers &optional always-list)
3898 "Convert list of numbers to a list of ranges or a single range.
3899 If ALWAYS-LIST is non-nil, this function will always release a list of
3901 (let* ((first (car numbers))
3902 (last (car numbers))
3906 (if (not (listp (cdr numbers)))
3909 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3910 ((= (1+ last) (car numbers)) ;Still in sequence
3911 (setq last (car numbers)))
3912 (t ;End of one sequence
3914 (cons (if (= first last) first
3915 (cons first last)) result))
3916 (setq first (car numbers))
3917 (setq last (car numbers))))
3918 (setq numbers (cdr numbers)))
3919 (if (and (not always-list) (null result))
3920 (if (= first last) (list first) (cons first last))
3921 (nreverse (cons (if (= first last) first (cons first last))
3924 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3925 (defun gnus-uncompress-range (ranges)
3926 "Expand a list of ranges into a list of numbers.
3927 RANGES is either a single range on the form `(num . num)' or a list of
3929 (let (first last result)
3933 ((not (listp (cdr ranges)))
3934 (setq first (car ranges))
3935 (setq last (cdr ranges))
3936 (while (<= first last)
3937 (setq result (cons first result))
3938 (setq first (1+ first)))
3942 (if (atom (car ranges))
3943 (if (numberp (car ranges))
3944 (setq result (cons (car ranges) result)))
3945 (setq first (caar ranges))
3946 (setq last (cdar ranges))
3947 (while (<= first last)
3948 (setq result (cons first result))
3949 (setq first (1+ first))))
3950 (setq ranges (cdr ranges)))
3951 (nreverse result)))))
3953 (defun gnus-add-to-range (ranges list)
3954 "Return a list of ranges that has all articles from both RANGES and LIST.
3955 Note: LIST has to be sorted over `<'."
3957 (gnus-compress-sequence list t)
3958 (setq list (copy-sequence list))
3959 (or (listp (cdr ranges))
3960 (setq ranges (list ranges)))
3962 ilist lowest highest temp)
3963 (while (and ranges list)
3965 (setq lowest (or (and (atom (car ranges)) (car ranges))
3967 (while (and list (cdr list) (< (cadr list) lowest))
3968 (setq list (cdr list)))
3969 (if (< (car ilist) lowest)
3972 (setq list (cdr list))
3974 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3975 (setq highest (or (and (atom (car ranges)) (car ranges))
3977 (while (and list (<= (car list) highest))
3978 (setq list (cdr list)))
3979 (setq ranges (cdr ranges)))
3981 (setq out (nconc (gnus-compress-sequence list t) out)))
3982 (setq out (sort out (lambda (r1 r2)
3983 (< (or (and (atom r1) r1) (car r1))
3984 (or (and (atom r2) r2) (car r2))))))
3987 (if (atom (car ranges))
3989 (if (atom (cadr ranges))
3990 (if (= (1+ (car ranges)) (cadr ranges))
3992 (setcar ranges (cons (car ranges)
3994 (setcdr ranges (cddr ranges))))
3995 (if (= (1+ (car ranges)) (caadr ranges))
3997 (setcar (cadr ranges) (car ranges))
3998 (setcar ranges (cadr ranges))
3999 (setcdr ranges (cddr ranges))))))
4001 (if (atom (cadr ranges))
4002 (if (= (1+ (cdar ranges)) (cadr ranges))
4004 (setcdr (car ranges) (cadr ranges))
4005 (setcdr ranges (cddr ranges))))
4006 (if (= (1+ (cdar ranges)) (caadr ranges))
4008 (setcdr (car ranges) (cdadr ranges))
4009 (setcdr ranges (cddr ranges)))))))
4010 (setq ranges (cdr ranges)))
4013 (defun gnus-remove-from-range (ranges list)
4014 "Return a list of ranges that has all articles from LIST removed from RANGES.
4015 Note: LIST has to be sorted over `<'."
4016 ;; !!! This function shouldn't look like this, but I've got a headache.
4017 (gnus-compress-sequence
4018 (gnus-sorted-complement
4019 (gnus-uncompress-range ranges) list)))
4021 (defun gnus-member-of-range (number ranges)
4022 (if (not (listp (cdr ranges)))
4023 (and (>= number (car ranges))
4024 (<= number (cdr ranges)))
4027 (if (numberp (car ranges))
4028 (>= number (car ranges))
4029 (>= number (caar ranges)))
4031 (if (if (numberp (car ranges))
4032 (= number (car ranges))
4033 (and (>= number (caar ranges))
4034 (<= number (cdar ranges))))
4035 (setq not-stop nil))
4036 (setq ranges (cdr ranges)))
4039 (defun gnus-range-length (range)
4040 "Return the length RANGE would have if uncompressed."
4041 (length (gnus-uncompress-range range)))
4043 (defun gnus-sublist-p (list sublist)
4044 "Test whether all elements in SUBLIST are members of LIST."
4047 (unless (memq (pop sublist) list)
4057 (defvar gnus-group-mode-map nil)
4058 (put 'gnus-group-mode 'mode-class 'special)
4060 (unless gnus-group-mode-map
4061 (setq gnus-group-mode-map (make-keymap))
4062 (suppress-keymap gnus-group-mode-map)
4064 (gnus-define-keys gnus-group-mode-map
4065 " " gnus-group-read-group
4066 "=" gnus-group-select-group
4067 "\r" gnus-group-select-group
4068 "\M-\r" gnus-group-quick-select-group
4069 "j" gnus-group-jump-to-group
4070 "n" gnus-group-next-unread-group
4071 "p" gnus-group-prev-unread-group
4072 "\177" gnus-group-prev-unread-group
4073 [delete] gnus-group-prev-unread-group
4074 "N" gnus-group-next-group
4075 "P" gnus-group-prev-group
4076 "\M-n" gnus-group-next-unread-group-same-level
4077 "\M-p" gnus-group-prev-unread-group-same-level
4078 "," gnus-group-best-unread-group
4079 "." gnus-group-first-unread-group
4080 "u" gnus-group-unsubscribe-current-group
4081 "U" gnus-group-unsubscribe-group
4082 "c" gnus-group-catchup-current
4083 "C" gnus-group-catchup-current-all
4084 "l" gnus-group-list-groups
4085 "L" gnus-group-list-all-groups
4087 "g" gnus-group-get-new-news
4088 "\M-g" gnus-group-get-new-news-this-group
4089 "R" gnus-group-restart
4090 "r" gnus-group-read-init-file
4091 "B" gnus-group-browse-foreign-server
4092 "b" gnus-group-check-bogus-groups
4093 "F" gnus-find-new-newsgroups
4094 "\C-c\C-d" gnus-group-describe-group
4095 "\M-d" gnus-group-describe-all-groups
4096 "\C-c\C-a" gnus-group-apropos
4097 "\C-c\M-\C-a" gnus-group-description-apropos
4098 "a" gnus-group-post-news
4099 "\ek" gnus-group-edit-local-kill
4100 "\eK" gnus-group-edit-global-kill
4101 "\C-k" gnus-group-kill-group
4102 "\C-y" gnus-group-yank-group
4103 "\C-w" gnus-group-kill-region
4104 "\C-x\C-t" gnus-group-transpose-groups
4105 "\C-c\C-l" gnus-group-list-killed
4106 "\C-c\C-x" gnus-group-expire-articles
4107 "\C-c\M-\C-x" gnus-group-expire-all-groups
4109 "s" gnus-group-save-newsrc
4110 "z" gnus-group-suspend
4111 "Z" gnus-group-clear-dribble
4114 "?" gnus-group-describe-briefly
4115 "\C-c\C-i" gnus-info-find-node
4116 "\M-e" gnus-group-edit-group-method
4117 "^" gnus-group-enter-server-mode
4118 gnus-mouse-2 gnus-mouse-pick-group
4119 "<" beginning-of-buffer
4122 "\C-c\C-s" gnus-group-sort-groups
4124 "\C-c\M-g" gnus-activate-all-groups
4125 "\M-&" gnus-group-universal-argument
4126 "#" gnus-group-mark-group
4127 "\M-#" gnus-group-unmark-group)
4129 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4130 "m" gnus-group-mark-group
4131 "u" gnus-group-unmark-group
4132 "w" gnus-group-mark-region
4133 "m" gnus-group-mark-buffer
4134 "r" gnus-group-mark-regexp
4135 "U" gnus-group-unmark-all-groups)
4137 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4138 "d" gnus-group-make-directory-group
4139 "h" gnus-group-make-help-group
4140 "a" gnus-group-make-archive-group
4141 "k" gnus-group-make-kiboze-group
4142 "m" gnus-group-make-group
4143 "E" gnus-group-edit-group
4144 "e" gnus-group-edit-group-method
4145 "p" gnus-group-edit-group-parameters
4146 "v" gnus-group-add-to-virtual
4147 "V" gnus-group-make-empty-virtual
4148 "D" gnus-group-enter-directory
4149 "f" gnus-group-make-doc-group
4150 "r" gnus-group-rename-group
4151 "\177" gnus-group-delete-group
4152 [delete] gnus-group-delete-group)
4154 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4155 "b" gnus-group-brew-soup
4156 "w" gnus-soup-save-areas
4157 "s" gnus-soup-send-replies
4158 "p" gnus-soup-pack-packet
4159 "r" nnsoup-pack-replies)
4161 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4162 "s" gnus-group-sort-groups
4163 "a" gnus-group-sort-groups-by-alphabet
4164 "u" gnus-group-sort-groups-by-unread
4165 "l" gnus-group-sort-groups-by-level
4166 "v" gnus-group-sort-groups-by-score
4167 "r" gnus-group-sort-groups-by-rank
4168 "m" gnus-group-sort-groups-by-method)
4170 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4171 "k" gnus-group-list-killed
4172 "z" gnus-group-list-zombies
4173 "s" gnus-group-list-groups
4174 "u" gnus-group-list-all-groups
4175 "A" gnus-group-list-active
4176 "a" gnus-group-apropos
4177 "d" gnus-group-description-apropos
4178 "m" gnus-group-list-matching
4179 "M" gnus-group-list-all-matching
4180 "l" gnus-group-list-level)
4182 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4183 "f" gnus-score-flush-cache)
4185 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4186 "f" gnus-group-fetch-faq)
4188 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4189 "l" gnus-group-set-current-level
4190 "t" gnus-group-unsubscribe-current-group
4191 "s" gnus-group-unsubscribe-group
4192 "k" gnus-group-kill-group
4193 "y" gnus-group-yank-group
4194 "w" gnus-group-kill-region
4195 "\C-k" gnus-group-kill-level
4196 "z" gnus-group-kill-all-zombies))
4198 (defun gnus-group-mode ()
4199 "Major mode for reading news.
4201 All normal editing commands are switched off.
4202 \\<gnus-group-mode-map>
4203 The group buffer lists (some of) the groups available. For instance,
4204 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4205 lists all zombie groups.
4207 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4208 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4210 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4212 The following commands are available:
4214 \\{gnus-group-mode-map}"
4216 (when (and menu-bar-mode
4217 (gnus-visual-p 'group-menu 'menu))
4218 (gnus-group-make-menu-bar))
4219 (kill-all-local-variables)
4220 (gnus-simplify-mode-line)
4221 (setq major-mode 'gnus-group-mode)
4222 (setq mode-name "Group")
4223 (gnus-group-set-mode-line)
4224 (setq mode-line-process nil)
4225 (use-local-map gnus-group-mode-map)
4226 (buffer-disable-undo (current-buffer))
4227 (setq truncate-lines t)
4228 (setq buffer-read-only t)
4229 (run-hooks 'gnus-group-mode-hook))
4231 (defun gnus-mouse-pick-group (e)
4232 "Enter the group under the mouse pointer."
4235 (gnus-group-read-group nil))
4237 ;; Look at LEVEL and find out what the level is really supposed to be.
4238 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4239 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4240 (defun gnus-group-default-level (&optional level number-or-nil)
4242 (gnus-group-use-permanent-levels
4243 (or (setq gnus-group-use-permanent-levels
4244 (or level (if (numberp gnus-group-use-permanent-levels)
4245 gnus-group-use-permanent-levels
4246 (or gnus-group-default-list-level
4247 gnus-level-subscribed))))
4248 gnus-group-default-list-level gnus-level-subscribed))
4252 (or level gnus-group-default-list-level gnus-level-subscribed))))
4255 (defun gnus-slave-no-server (&optional arg)
4256 "Read network news as a slave, without connecting to local server"
4258 (gnus-no-server arg t))
4261 (defun gnus-no-server (&optional arg slave)
4263 If ARG is a positive number, Gnus will use that as the
4264 startup level. If ARG is nil, Gnus will be started at level 2.
4265 If ARG is non-nil and not a positive number, Gnus will
4266 prompt the user for the name of an NNTP server to use.
4267 As opposed to `gnus', this command will not connect to the local server."
4269 (make-local-variable 'gnus-group-use-permanent-levels)
4270 (setq gnus-group-use-permanent-levels
4271 (or arg (1- gnus-level-default-subscribed)))
4272 (gnus gnus-group-use-permanent-levels t slave))
4275 (defun gnus-slave (&optional arg)
4276 "Read news as a slave."
4278 (gnus arg nil 'slave))
4281 (defun gnus-other-frame (&optional arg)
4282 "Pop up a frame to read news."
4284 (if (get-buffer gnus-group-buffer)
4285 (let ((pop-up-frames t))
4287 (select-frame (make-frame))
4291 (defun gnus (&optional arg dont-connect slave)
4293 If ARG is non-nil and a positive number, Gnus will use that as the
4294 startup level. If ARG is non-nil and not a positive number, Gnus will
4295 prompt the user for the name of an NNTP server to use."
4298 (if (get-buffer gnus-group-buffer)
4300 (switch-to-buffer gnus-group-buffer)
4301 (gnus-group-get-new-news))
4304 (nnheader-init-server-buffer)
4305 (gnus-read-init-file)
4306 (setq gnus-slave slave)
4308 (gnus-group-setup-buffer)
4309 (let ((buffer-read-only nil))
4311 (if (not gnus-inhibit-startup-message)
4313 (gnus-group-startup-message)
4316 (let ((level (and (numberp arg) (> arg 0) arg))
4322 (gnus-start-news-server (and arg (not level))))))
4323 (if (and (not dont-connect)
4326 (run-hooks 'gnus-startup-hook)
4327 ;; NNTP server is successfully open.
4329 ;; Find the current startup file name.
4330 (setq gnus-current-startup-file
4331 (gnus-make-newsrc-file gnus-startup-file))
4333 ;; Read the dribble file.
4334 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4336 ;; Allow using GroupLens predictions.
4337 (when gnus-use-grouplens
4339 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4341 (gnus-summary-make-display-table)
4342 ;; Do the actual startup.
4343 (gnus-setup-news nil level dont-connect)
4344 ;; Generate the group buffer.
4345 (gnus-group-list-groups level)
4346 (gnus-group-first-unread-group)
4347 (gnus-configure-windows 'group)
4348 (gnus-group-set-mode-line))))))
4350 (defun gnus-unload ()
4351 "Unload all Gnus features."
4353 (or (boundp 'load-history)
4354 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4355 (let ((history load-history)
4358 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4359 (setq feature (cdr (assq 'provide (car history))))
4360 (unload-feature feature 'force))
4361 (setq history (cdr history)))))
4363 (defun gnus-compile ()
4364 "Byte-compile the user-defined format specs."
4366 (let ((entries gnus-format-specs)
4367 entry gnus-tmp-func)
4369 (gnus-message 7 "Compiling format specs...")
4372 (setq entry (pop entries))
4373 (if (eq (car entry) 'version)
4374 (setq gnus-format-specs (delq entry gnus-format-specs))
4375 (when (and (listp (caddr entry))
4376 (not (eq 'byte-code (caaddr entry))))
4377 (fset 'gnus-tmp-func
4378 `(lambda () ,(caddr entry)))
4379 (byte-compile 'gnus-tmp-func)
4380 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4382 (push (cons 'version emacs-version) gnus-format-specs)
4384 (gnus-message 7 "Compiling user specs...done"))))
4386 (defun gnus-indent-rigidly (start end arg)
4387 "Indent rigidly using only spaces and no tabs."
4390 (narrow-to-region start end)
4391 (indent-rigidly start end arg)
4392 (goto-char (point-min))
4393 (while (search-forward "\t" nil t)
4394 (replace-match " " t t)))))
4396 (defun gnus-group-startup-message (&optional x y)
4397 "Insert startup message in current buffer."
4398 ;; Insert the message.
4403 _ ___ __ ___ __ _ ___
4422 ;; And then hack it.
4423 (gnus-indent-rigidly (point-min) (point-max)
4424 (/ (max (- (window-width) (or x 46)) 0) 2))
4425 (goto-char (point-min))
4427 (let* ((pheight (count-lines (point-min) (point-max)))
4428 (wheight (window-height))
4429 (rest (- wheight pheight)))
4430 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4432 (goto-char (point-min))
4433 (and (search-forward "Praxis" nil t)
4434 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4435 (goto-char (point-min))
4436 (let* ((mode-string (gnus-group-set-mode-line)))
4437 (setq mode-line-buffer-identification
4438 (list (concat gnus-version (substring (car mode-string) 4))))
4439 (set-buffer-modified-p t)))
4441 (defun gnus-group-setup-buffer ()
4442 (or (get-buffer gnus-group-buffer)
4444 (switch-to-buffer gnus-group-buffer)
4445 (gnus-add-current-to-buffer-list)
4447 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4449 (defun gnus-group-list-groups (&optional level unread lowest)
4450 "List newsgroups with level LEVEL or lower that have unread articles.
4451 Default is all subscribed groups.
4452 If argument UNREAD is non-nil, groups with no unread articles are also
4454 (interactive (list (if current-prefix-arg
4455 (prefix-numeric-value current-prefix-arg)
4457 (gnus-group-default-level nil t)
4458 gnus-group-default-list-level
4459 gnus-level-subscribed))))
4461 (setq level (car gnus-group-list-mode)
4462 unread (cdr gnus-group-list-mode)))
4463 (setq level (gnus-group-default-level level))
4464 (gnus-group-setup-buffer) ;May call from out of group buffer
4465 (gnus-update-format-specifications)
4466 (let ((case-fold-search nil)
4467 (props (text-properties-at (gnus-point-at-bol)))
4468 (group (gnus-group-group-name)))
4469 (set-buffer gnus-group-buffer)
4470 (funcall gnus-group-prepare-function level unread lowest)
4471 (if (zerop (buffer-size))
4472 (gnus-message 5 gnus-no-groups-message)
4473 (goto-char (point-max))
4474 (when (or (not gnus-group-goto-next-group-function)
4475 (not (funcall gnus-group-goto-next-group-function
4478 ;; Go to the first group with unread articles.
4479 (gnus-group-search-forward t)
4480 ;; Find the right group to put point on. If the current group
4481 ;; has disappeared in the new listing, try to find the next
4482 ;; one. If no next one can be found, just leave point at the
4483 ;; first newsgroup in the buffer.
4484 (if (not (gnus-goto-char
4486 (point-min) (point-max)
4487 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4488 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4490 (not (gnus-goto-char
4492 (point-min) (point-max) 'gnus-group
4494 (caar newsrc) gnus-active-hashtb)))))
4495 (setq newsrc (cdr newsrc)))
4496 (or newsrc (progn (goto-char (point-max))
4497 (forward-line -1)))))))
4498 ;; Adjust cursor point.
4499 (gnus-group-position-point))))
4501 (defun gnus-group-list-level (level &optional all)
4502 "List groups on LEVEL.
4503 If ALL (the prefix), also list groups that have no unread articles."
4504 (interactive "nList groups on level: \nP")
4505 (gnus-group-list-groups level all level))
4507 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4508 "List all newsgroups with unread articles of level LEVEL or lower.
4509 If ALL is non-nil, list groups that have no unread articles.
4510 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4511 If REGEXP, only list groups matching REGEXP."
4512 (set-buffer gnus-group-buffer)
4513 (let ((buffer-read-only nil)
4514 (newsrc (cdr gnus-newsrc-alist))
4515 (lowest (or lowest 1))
4516 info clevel unread group params)
4518 (if (< lowest gnus-level-zombie)
4519 ;; List living groups.
4521 (setq info (car newsrc)
4522 group (gnus-info-group info)
4523 params (gnus-info-params info)
4525 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4526 (and unread ; This group might be bogus
4528 (string-match regexp group))
4529 (<= (setq clevel (gnus-info-level info)) level)
4531 (or all ; We list all groups?
4532 (if (eq unread t) ; Unactivated?
4533 gnus-group-list-inactive-groups ; We list unactivated
4534 (> unread 0)) ; We list groups with unread articles
4535 (and gnus-list-groups-with-ticked-articles
4536 (cdr (assq 'tick (gnus-info-marks info))))
4537 ; And groups with tickeds
4538 ;; Check for permanent visibility.
4539 (and gnus-permanently-visible-groups
4540 (string-match gnus-permanently-visible-groups
4542 (memq 'visible params)
4543 (cdr (assq 'visible params)))
4544 (gnus-group-insert-group-line
4545 group (gnus-info-level info)
4546 (gnus-info-marks info) unread (gnus-info-method info)))))
4548 ;; List dead groups.
4549 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4550 (gnus-group-prepare-flat-list-dead
4551 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4552 gnus-level-zombie ?Z
4554 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4555 (gnus-group-prepare-flat-list-dead
4556 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4557 gnus-level-killed ?K regexp))
4559 (gnus-group-set-mode-line)
4560 (setq gnus-group-list-mode (cons level all))
4561 (run-hooks 'gnus-group-prepare-hook)))
4563 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4564 ;; List zombies and killed lists somewhat faster, which was
4565 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4566 ;; this by ignoring the group format specification altogether.
4569 ;; This loop is used when listing groups that match some
4572 (setq group (pop groups))
4573 (when (string-match regexp group)
4574 (add-text-properties
4575 (point) (prog1 (1+ (point))
4576 (insert " " mark " *: " group "\n"))
4577 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4579 'gnus-level level))))
4580 ;; This loop is used when listing all groups.
4582 (add-text-properties
4583 (point) (prog1 (1+ (point))
4584 (insert " " mark " *: "
4585 (setq group (pop groups)) "\n"))
4586 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4588 'gnus-level level))))))
4590 (defmacro gnus-group-real-name (group)
4591 "Find the real name of a foreign newsgroup."
4592 `(let ((gname ,group))
4593 (if (string-match ":[^:]+$" gname)
4594 (substring gname (1+ (match-beginning 0)))
4597 (defsubst gnus-server-add-address (method)
4598 (let ((method-name (symbol-name (car method))))
4599 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4600 (not (assq (intern (concat method-name "-address")) method)))
4601 (append method (list (list (intern (concat method-name "-address"))
4605 (defsubst gnus-server-get-method (group method)
4606 ;; Input either a server name, and extended server name, or a
4607 ;; select method, and return a select method.
4608 (cond ((stringp method)
4609 (gnus-server-to-method method))
4610 ((equal method gnus-select-method)
4612 ((and (stringp (car method)) group)
4613 (gnus-server-extend-method group method))
4614 ((and method (not group)
4615 (equal (cadr method) ""))
4618 (gnus-server-add-address method))))
4620 (defun gnus-server-to-method (server)
4621 "Map virtual server names to select methods."
4623 ;; Perhaps this is the native server?
4624 (and (equal server "native") gnus-select-method)
4625 ;; It should be in the server alist.
4626 (cdr (assoc server gnus-server-alist))
4627 ;; If not, we look through all the opened server
4628 ;; to see whether we can find it there.
4629 (let ((opened gnus-opened-servers))
4631 (not (equal server (format "%s:%s" (caaar opened)
4636 (defmacro gnus-method-equal (ss1 ss2)
4637 "Say whether two servers are equal."
4641 (and (= (length s1) (length s2))
4643 (while (and s1 (member (car s1) s2))
4647 (defun gnus-server-equal (m1 m2)
4648 "Say whether two methods are equal."
4649 (let ((m1 (cond ((null m1) gnus-select-method)
4650 ((stringp m1) (gnus-server-to-method m1))
4652 (m2 (cond ((null m2) gnus-select-method)
4653 ((stringp m2) (gnus-server-to-method m2))
4655 (gnus-method-equal m1 m2)))
4657 (defun gnus-servers-using-backend (backend)
4658 "Return a list of known servers using BACKEND."
4659 (let ((opened gnus-opened-servers)
4662 (when (eq backend (caaar opened))
4663 (push (caar opened) out))
4667 (defun gnus-group-prefixed-name (group method)
4668 "Return the whole name from GROUP and METHOD."
4669 (and (stringp method) (setq method (gnus-server-to-method method)))
4670 (concat (format "%s" (car method))
4672 (or (assoc (format "%s" (car method))
4673 (gnus-methods-using 'address))
4674 (gnus-server-equal method gnus-message-archive-method))
4676 (not (string= (nth 1 method) "")))
4677 (concat "+" (nth 1 method)))
4680 (defun gnus-group-real-prefix (group)
4681 "Return the prefix of the current group name."
4682 (if (string-match "^[^:]+:" group)
4683 (substring group 0 (match-end 0))
4686 (defun gnus-group-method (group)
4687 "Return the server or method used for selecting GROUP."
4688 (let ((prefix (gnus-group-real-prefix group)))
4689 (if (equal prefix "")
4691 (let ((servers gnus-opened-servers)
4693 backend possible found)
4694 (if (string-match "^[^\\+]+\\+" prefix)
4695 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4696 server (substring prefix (match-end 0) (1- (length prefix))))
4697 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4699 (when (eq (caaar servers) backend)
4700 (setq possible (caar servers))
4701 (when (equal (cadaar servers) server)
4702 (setq found (caar servers))))
4704 (or (car (rassoc found gnus-server-alist))
4706 (car (rassoc possible gnus-server-alist))
4708 (list backend server))))))
4710 (defsubst gnus-secondary-method-p (method)
4711 "Return whether METHOD is a secondary select method."
4712 (let ((methods gnus-secondary-select-methods)
4713 (gmethod (gnus-server-get-method nil method)))
4715 (not (equal (gnus-server-get-method nil (car methods))
4717 (setq methods (cdr methods)))
4720 (defun gnus-group-foreign-p (group)
4721 "Say whether a group is foreign or not."
4722 (and (not (gnus-group-native-p group))
4723 (not (gnus-group-secondary-p group))))
4725 (defun gnus-group-native-p (group)
4726 "Say whether the group is native or not."
4727 (not (string-match ":" group)))
4729 (defun gnus-group-secondary-p (group)
4730 "Say whether the group is secondary or not."
4731 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4733 (defun gnus-group-get-parameter (group &optional symbol)
4734 "Returns the group parameters for GROUP.
4735 If SYMBOL, return the value of that symbol in the group parameters."
4736 (let ((params (gnus-info-params (gnus-get-info group))))
4738 (gnus-group-parameter-value params symbol)
4741 (defun gnus-group-parameter-value (params symbol)
4742 "Return the value of SYMBOL in group PARAMS."
4743 (or (car (memq symbol params)) ; It's either a simple symbol
4744 (cdr (assq symbol params)))) ; or a cons.
4746 (defun gnus-group-add-parameter (group param)
4747 "Add parameter PARAM to GROUP."
4748 (let ((info (gnus-get-info group)))
4750 () ; This is a dead group. We just ignore it.
4751 ;; Cons the new param to the old one and update.
4752 (gnus-group-set-info (cons param (gnus-info-params info))
4755 (defun gnus-group-set-parameter (group name value)
4756 "Set parameter NAME to VALUE in GROUP."
4757 (let ((info (gnus-get-info group)))
4759 () ; This is a dead group. We just ignore it.
4760 (let ((old-params (gnus-info-params info))
4761 (new-params (list (cons name value))))
4763 (if (or (not (listp (car old-params)))
4764 (not (eq (caar old-params) name)))
4765 (setq new-params (append new-params (list (car old-params)))))
4766 (setq old-params (cdr old-params)))
4767 (gnus-group-set-info new-params group 'params)))))
4769 (defun gnus-group-add-score (group &optional score)
4770 "Add SCORE to the GROUP score.
4771 If SCORE is nil, add 1 to the score of GROUP."
4772 (let ((info (gnus-get-info group)))
4774 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4776 (defun gnus-summary-bubble-group ()
4777 "Increase the score of the current group.
4778 This is a handy function to add to `gnus-summary-exit-hook' to
4779 increase the score of each group you read."
4780 (gnus-group-add-score gnus-newsgroup-name))
4782 (defun gnus-group-set-info (info &optional method-only-group part)
4783 (let* ((entry (gnus-gethash
4784 (or method-only-group (gnus-info-group info))
4785 gnus-newsrc-hashtb))
4787 (info (if method-only-group (nth 2 entry) info))
4789 (when method-only-group
4791 (error "Trying to change non-existent group %s" method-only-group))
4792 ;; We have received parts of the actual group info - either the
4793 ;; select method or the group parameters. We first check
4794 ;; whether we have to extend the info, and if so, do that.
4795 (let ((len (length info))
4796 (total (if (eq part 'method) 5 6)))
4798 (setcdr (nthcdr (1- len) info)
4799 (make-list (- total len) nil)))
4800 ;; Then we enter the new info.
4801 (setcar (nthcdr (1- total) info) part-info)))
4803 ;; This is a new group, so we just create it.
4805 (set-buffer gnus-group-buffer)
4806 (setq method (gnus-info-method info))
4807 (when (gnus-server-equal method "native")
4810 (set-buffer gnus-group-buffer)
4812 ;; It's a foreign group...
4813 (gnus-group-make-group
4814 (gnus-group-real-name (gnus-info-group info))
4815 (if (stringp method) method
4816 (prin1-to-string (car method)))
4818 (nth 1 (gnus-info-method info))))
4819 ;; It's a native group.
4820 (gnus-group-make-group (gnus-info-group info))))
4821 (gnus-message 6 "Note: New group created")
4823 (gnus-gethash (gnus-group-prefixed-name
4824 (gnus-group-real-name (gnus-info-group info))
4825 (or (gnus-info-method info) gnus-select-method))
4826 gnus-newsrc-hashtb))))
4827 ;; Whether it was a new group or not, we now have the entry, so we
4828 ;; can do the update.
4831 (setcar (nthcdr 2 entry) info)
4832 (when (and (not (eq (car entry) t))
4833 (gnus-active (gnus-info-group info)))
4834 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4835 (error "No such group: %s" (gnus-info-group info)))))
4837 (defun gnus-group-set-method-info (group select-method)
4838 (gnus-group-set-info select-method group 'method))
4840 (defun gnus-group-set-params-info (group params)
4841 (gnus-group-set-info params group 'params))
4843 (defun gnus-group-update-group-line ()
4844 "Update the current line in the group buffer."
4845 (let* ((buffer-read-only nil)
4846 (group (gnus-group-group-name))
4847 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4849 (not (gnus-ephemeral-group-p group))
4851 (concat "(gnus-group-set-info '"
4852 (prin1-to-string (nth 2 entry)) ")")))
4854 (gnus-group-insert-group-line-info group)
4856 (gnus-group-position-point)))
4858 (defun gnus-group-insert-group-line-info (group)
4859 "Insert GROUP on the current line."
4860 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4864 ;; (Un)subscribed group.
4865 (setq info (nth 2 entry))
4866 (gnus-group-insert-group-line
4867 group (gnus-info-level info) (gnus-info-marks info)
4868 (or (car entry) t) (gnus-info-method info)))
4869 ;; This group is dead.
4870 (gnus-group-insert-group-line
4872 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4874 (if (setq active (gnus-active group))
4875 (- (1+ (cdr active)) (car active)) 0)
4878 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4879 gnus-tmp-marked number
4881 "Insert a group line in the group buffer."
4882 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4883 (gnus-tmp-number-total
4885 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4887 (gnus-tmp-number-of-unread
4888 (if (numberp number) (int-to-string (max 0 number))
4890 (gnus-tmp-number-of-read
4891 (if (numberp number)
4892 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4894 (gnus-tmp-subscribed
4895 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4896 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4897 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4899 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4900 (gnus-tmp-newsgroup-description
4901 (if gnus-description-hashtb
4902 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4905 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4906 (gnus-tmp-moderated-string
4907 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4909 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4910 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4911 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4912 (gnus-tmp-news-method-string
4914 (format "(%s:%s)" (car gnus-tmp-method)
4915 (cadr gnus-tmp-method)) ""))
4916 (gnus-tmp-marked-mark
4917 (if (and (numberp number)
4919 (cdr (assq 'tick gnus-tmp-marked)))
4921 (gnus-tmp-process-marked
4922 (if (member gnus-tmp-group gnus-group-marked)
4923 gnus-process-mark ? ))
4925 (or (and gnus-use-grouplens
4926 (bbb-grouplens-group-p gnus-tmp-group))
4928 (buffer-read-only nil)
4929 header gnus-tmp-header) ; passed as parameter to user-funcs.
4931 (add-text-properties
4935 (eval gnus-group-line-format-spec))
4936 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4937 gnus-unread ,(if (numberp number)
4938 (string-to-int gnus-tmp-number-of-unread)
4940 gnus-marked ,gnus-tmp-marked-mark
4941 gnus-indentation ,gnus-group-indentation
4942 gnus-level ,gnus-tmp-level))
4943 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4945 (run-hooks 'gnus-group-update-hook)
4947 ;; Allow XEmacs to remove front-sticky text properties.
4948 (gnus-group-remove-excess-properties)))
4950 (defun gnus-group-update-group (group &optional visible-only)
4951 "Update all lines where GROUP appear.
4952 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4955 (set-buffer gnus-group-buffer)
4956 ;; The buffer may be narrowed.
4959 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4961 found buffer-read-only)
4962 ;; Enter the current status into the dribble buffer.
4963 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4964 (if (and entry (not (gnus-ephemeral-group-p group)))
4966 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4968 ;; Find all group instances. If topics are in use, each group
4969 ;; may be listed in more than once.
4970 (while (setq loc (text-property-any
4971 loc (point-max) 'gnus-group ident))
4974 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4976 (gnus-group-insert-group-line-info group))
4977 (setq loc (1+ loc)))
4978 (unless (or found visible-only)
4979 ;; No such line in the buffer, find out where it's supposed to
4980 ;; go, and insert it there (or at the end of the buffer).
4981 (if gnus-goto-missing-group-function
4982 (funcall gnus-goto-missing-group-function group)
4983 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4984 (while (and entry (car entry)
4988 (point-min) (point-max)
4989 'gnus-group (gnus-intern-safe
4990 (caar entry) gnus-active-hashtb)))))
4991 (setq entry (cdr entry)))
4992 (or entry (goto-char (point-max)))))
4993 ;; Finally insert the line.
4994 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4995 (gnus-group-insert-group-line-info group)))
4996 (gnus-group-set-mode-line)))))
4998 (defun gnus-group-set-mode-line ()
4999 (when (memq 'group gnus-updated-mode-lines)
5000 (let* ((gformat (or gnus-group-mode-line-format-spec
5001 (setq gnus-group-mode-line-format-spec
5003 gnus-group-mode-line-format
5004 gnus-group-mode-line-format-alist))))
5005 (gnus-tmp-news-server (cadr gnus-select-method))
5006 (gnus-tmp-news-method (car gnus-select-method))
5008 gnus-tmp-header ;Dummy binding for user-defined formats
5009 ;; Get the resulting string.
5010 (mode-string (eval gformat)))
5011 ;; If the line is too long, we chop it off.
5012 (when (> (length mode-string) max-len)
5013 (setq mode-string (substring mode-string 0 (- max-len 4))))
5015 (setq mode-line-buffer-identification (list mode-string))
5016 (set-buffer-modified-p t)))))
5018 (defun gnus-group-group-name ()
5019 "Get the name of the newsgroup on the current line."
5020 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5021 (and group (symbol-name group))))
5023 (defun gnus-group-group-level ()
5024 "Get the level of the newsgroup on the current line."
5025 (get-text-property (gnus-point-at-bol) 'gnus-level))
5027 (defun gnus-group-group-indentation ()
5028 "Get the indentation of the newsgroup on the current line."
5029 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5030 (and gnus-group-indentation-function
5031 (funcall gnus-group-indentation-function))
5034 (defun gnus-group-group-unread ()
5035 "Get the number of unread articles of the newsgroup on the current line."
5036 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5038 (defun gnus-group-search-forward (&optional backward all level first-too)
5039 "Find the next newsgroup with unread articles.
5040 If BACKWARD is non-nil, find the previous newsgroup instead.
5041 If ALL is non-nil, just find any newsgroup.
5042 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5044 If FIRST-TOO, the current line is also eligible as a target."
5045 (let ((way (if backward -1 1))
5046 (low gnus-level-killed)
5049 (if (and backward (progn (beginning-of-line)) (bobp))
5051 (or first-too (forward-line way))
5059 (get-text-property (point) 'gnus-unread)))
5060 (and (numberp unread) (> unread 0)))
5061 (setq lev (get-text-property (point)
5063 (<= lev gnus-level-subscribed)))
5065 (and (setq lev (get-text-property (point)
5074 (zerop (forward-line way)))))
5076 (progn (gnus-group-position-point) t)
5077 (goto-char (or pos beg))
5080 ;;; Gnus group mode commands
5084 (defun gnus-group-mark-group (n &optional unmark no-advance)
5085 "Mark the current group."
5087 (let ((buffer-read-only nil)
5091 (when (setq group (gnus-group-group-name))
5095 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5100 (setq gnus-group-marked (delete group gnus-group-marked)))
5102 (setq gnus-group-marked
5103 (cons group (delete group gnus-group-marked))))
5104 (or no-advance (zerop (gnus-group-next-group 1))))
5106 (gnus-summary-position-point)
5109 (defun gnus-group-unmark-group (n)
5110 "Remove the mark from the current group."
5112 (gnus-group-mark-group n 'unmark)
5113 (gnus-group-position-point))
5115 (defun gnus-group-unmark-all-groups ()
5116 "Unmark all groups."
5118 (let ((groups gnus-group-marked))
5121 (gnus-group-remove-mark (pop groups)))))
5122 (gnus-group-position-point))
5124 (defun gnus-group-mark-region (unmark beg end)
5125 "Mark all groups between point and mark.
5126 If UNMARK, remove the mark instead."
5127 (interactive "P\nr")
5128 (let ((num (count-lines beg end)))
5131 (- num (gnus-group-mark-group num unmark)))))
5133 (defun gnus-group-mark-buffer (&optional unmark)
5134 "Mark all groups in the buffer.
5135 If UNMARK, remove the mark instead."
5137 (gnus-group-mark-region unmark (point-min) (point-max)))
5139 (defun gnus-group-mark-regexp (regexp)
5140 "Mark all groups that match some regexp."
5141 (interactive "sMark (regexp): ")
5142 (let ((alist (cdr gnus-newsrc-alist))
5145 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5146 (gnus-group-set-mark group))))
5147 (gnus-group-position-point))
5149 (defun gnus-group-remove-mark (group)
5150 "Remove the process mark from GROUP and move point there.
5151 Return nil if the group isn't displayed."
5152 (if (gnus-group-goto-group group)
5154 (gnus-group-mark-group 1 'unmark t)
5156 (setq gnus-group-marked
5157 (delete group gnus-group-marked))
5160 (defun gnus-group-set-mark (group)
5161 "Set the process mark on GROUP."
5162 (if (gnus-group-goto-group group)
5164 (gnus-group-mark-group 1 nil t))
5165 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5167 (defun gnus-group-universal-argument (arg &optional groups func)
5168 "Perform any command on all groups accoring to the process/prefix convention."
5170 (let ((groups (or groups (gnus-group-process-prefix arg)))
5172 (if (eq (setq func (or func
5175 (substitute-command-keys
5176 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5178 (gnus-error 1 "Undefined key")
5180 (gnus-group-remove-mark (setq group (pop groups)))
5181 (command-execute func))))
5182 (gnus-group-position-point))
5184 (defun gnus-group-process-prefix (n)
5185 "Return a list of groups to work on.
5186 Take into consideration N (the prefix) and the list of marked groups."
5189 (setq n (prefix-numeric-value n))
5190 ;; There is a prefix, so we return a list of the N next
5192 (let ((way (if (< n 0) -1 1))
5197 (setq group (gnus-group-group-name)))
5198 (setq groups (cons group groups))
5200 (gnus-group-next-group way)))
5202 ((and (boundp 'transient-mark-mode)
5204 (boundp 'mark-active)
5206 ;; Work on the region between point and mark.
5207 (let ((max (max (point) (mark)))
5210 (goto-char (min (point) (mark)))
5213 (push (gnus-group-group-name) groups)
5214 (zerop (gnus-group-next-group 1))
5216 (nreverse groups))))
5218 ;; No prefix, but a list of marked articles.
5219 (reverse gnus-group-marked))
5221 ;; Neither marked articles or a prefix, so we return the
5223 (let ((group (gnus-group-group-name)))
5224 (and group (list group))))))
5226 ;; Selecting groups.
5228 (defun gnus-group-read-group (&optional all no-article group)
5229 "Read news in this newsgroup.
5230 If the prefix argument ALL is non-nil, already read articles become
5231 readable. IF ALL is a number, fetch this number of articles. If the
5232 optional argument NO-ARTICLE is non-nil, no article will be
5233 auto-selected upon group entry. If GROUP is non-nil, fetch that
5236 (let ((group (or group (gnus-group-group-name)))
5237 number active marked entry)
5238 (or group (error "No group on current line"))
5239 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5240 group gnus-newsrc-hashtb)))))
5241 ;; This group might be a dead group. In that case we have to get
5242 ;; the number of unread articles from `gnus-active-hashtb'.
5244 (cond ((numberp all) all)
5246 ((setq active (gnus-active group))
5247 (- (1+ (cdr active)) (car active)))))
5248 (gnus-summary-read-group
5249 group (or all (and (numberp number)
5250 (zerop (+ number (length (cdr (assq 'tick marked)))
5251 (length (cdr (assq 'dormant marked)))))))
5254 (defun gnus-group-select-group (&optional all)
5255 "Select this newsgroup.
5256 No article is selected automatically.
5257 If ALL is non-nil, already read articles become readable.
5258 If ALL is a number, fetch this number of articles."
5260 (gnus-group-read-group all t))
5262 (defun gnus-group-quick-select-group (&optional all)
5263 "Select the current group \"quickly\".
5264 This means that no highlighting or scoring will be performed."
5267 gnus-score-find-score-files-function
5268 gnus-apply-kill-hook
5269 gnus-summary-expunge-below)
5270 (gnus-group-read-group all t)))
5272 (defun gnus-group-visible-select-group (&optional all)
5273 "Select the current group without hiding any articles."
5275 (let ((gnus-inhibit-limiting t))
5276 (gnus-group-read-group all t)))
5279 (defun gnus-fetch-group (group)
5280 "Start Gnus if necessary and enter GROUP.
5281 Returns whether the fetching was successful or not."
5282 (interactive "sGroup name: ")
5283 (or (get-buffer gnus-group-buffer)
5285 (gnus-group-read-group nil nil group))
5287 ;; Enter a group that is not in the group buffer. Non-nil is returned
5288 ;; if selection was successful.
5289 (defun gnus-group-read-ephemeral-group
5290 (group method &optional activate quit-config)
5291 (let ((group (if (gnus-group-foreign-p group) group
5292 (gnus-group-prefixed-name group method))))
5295 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5296 ((quit-config . ,(if quit-config quit-config
5297 (cons (current-buffer) 'summary))))))
5299 (set-buffer gnus-group-buffer)
5300 (or (gnus-check-server method)
5301 (error "Unable to contact server: %s" (gnus-status-message method)))
5302 (if activate (or (gnus-request-group group)
5303 (error "Couldn't request group")))
5305 (gnus-group-read-group t t group)
5309 (defun gnus-group-jump-to-group (group)
5310 "Jump to newsgroup GROUP."
5312 (list (completing-read
5313 "Group: " gnus-active-hashtb nil
5314 (gnus-read-active-file-p)
5316 'gnus-group-history)))
5318 (when (equal group "")
5319 (error "Empty group name"))
5321 (when (string-match "[\000-\032]" group)
5322 (error "Control characters in group: %s" group))
5324 (let ((b (text-property-any
5325 (point-min) (point-max)
5326 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5327 (unless (gnus-ephemeral-group-p group)
5329 ;; Either go to the line in the group buffer...
5331 ;; ... or insert the line.
5334 (gnus-activate-group group)
5335 (error "%s error: %s" group (gnus-status-message group)))
5337 (gnus-group-update-group group)
5338 (goto-char (text-property-any
5339 (point-min) (point-max)
5340 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5341 ;; Adjust cursor point.
5342 (gnus-group-position-point)))
5344 (defun gnus-group-goto-group (group)
5345 "Goto to newsgroup GROUP."
5347 (let ((b (text-property-any (point-min) (point-max)
5348 'gnus-group (gnus-intern-safe
5349 group gnus-active-hashtb))))
5350 (and b (goto-char b)))))
5352 (defun gnus-group-next-group (n)
5353 "Go to next N'th newsgroup.
5354 If N is negative, search backward instead.
5355 Returns the difference between N and the number of skips actually
5358 (gnus-group-next-unread-group n t))
5360 (defun gnus-group-next-unread-group (n &optional all level)
5361 "Go to next N'th unread newsgroup.
5362 If N is negative, search backward instead.
5363 If ALL is non-nil, choose any newsgroup, unread or not.
5364 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5365 such group can be found, the next group with a level higher than
5367 Returns the difference between N and the number of skips actually
5370 (let ((backward (< n 0))
5373 (gnus-group-search-forward
5374 backward (or (not gnus-group-goto-unread) all) level))
5376 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5377 (if level " on this level or higher" "")))
5380 (defun gnus-group-prev-group (n)
5381 "Go to previous N'th newsgroup.
5382 Returns the difference between N and the number of skips actually
5385 (gnus-group-next-unread-group (- n) t))
5387 (defun gnus-group-prev-unread-group (n)
5388 "Go to previous N'th unread newsgroup.
5389 Returns the difference between N and the number of skips actually
5392 (gnus-group-next-unread-group (- n)))
5394 (defun gnus-group-next-unread-group-same-level (n)
5395 "Go to next N'th unread newsgroup on the same level.
5396 If N is negative, search backward instead.
5397 Returns the difference between N and the number of skips actually
5400 (gnus-group-next-unread-group n t (gnus-group-group-level))
5401 (gnus-group-position-point))
5403 (defun gnus-group-prev-unread-group-same-level (n)
5404 "Go to next N'th unread newsgroup on the same level.
5405 Returns the difference between N and the number of skips actually
5408 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5409 (gnus-group-position-point))
5411 (defun gnus-group-best-unread-group (&optional exclude-group)
5412 "Go to the group with the highest level.
5413 If EXCLUDE-GROUP, do not go to that group."
5415 (goto-char (point-min))
5419 (setq unread (get-text-property (point) 'gnus-unread))
5420 (if (and (numberp unread) (> unread 0))
5422 (if (and (get-text-property (point) 'gnus-level)
5423 (< (get-text-property (point) 'gnus-level) best)
5424 (or (not exclude-group)
5425 (not (equal exclude-group (gnus-group-group-name)))))
5427 (setq best (get-text-property (point) 'gnus-level))
5428 (setq best-point (point))))))
5430 (if best-point (goto-char best-point))
5431 (gnus-summary-position-point)
5432 (and best-point (gnus-group-group-name))))
5434 (defun gnus-group-first-unread-group ()
5435 "Go to the first group with unread articles."
5438 (let ((opoint (point))
5440 (goto-char (point-min))
5441 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5442 (and (numberp unread) ; Not a topic.
5443 (not (zerop unread))) ; Has unread articles.
5444 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5447 nil)) ; Not success.
5448 (gnus-group-position-point)))
5450 (defun gnus-group-enter-server-mode ()
5451 "Jump to the server buffer."
5453 (gnus-enter-server-buffer))
5455 (defun gnus-group-make-group (name &optional method address)
5456 "Add a new newsgroup.
5457 The user will be prompted for a NAME, for a select METHOD, and an
5461 (read-string "Group name: ")
5464 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5465 nil t nil 'gnus-method-history)))
5466 (cond ((assoc method gnus-valid-select-methods)
5468 (if (memq 'prompt-address
5469 (assoc method gnus-valid-select-methods))
5470 (read-string "Address: ")
5472 ((assoc method gnus-server-alist)
5475 (list method ""))))))
5477 (let* ((meth (and method (if address (list (intern method) address)
5479 (nname (if method (gnus-group-prefixed-name name meth) name))
5481 (when (gnus-gethash nname gnus-newsrc-hashtb)
5482 (error "Group %s already exists" nname))
5483 ;; Subscribe to the new group.
5484 (gnus-group-change-level
5485 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5486 gnus-level-default-subscribed gnus-level-killed
5487 (and (gnus-group-group-name)
5488 (gnus-gethash (gnus-group-group-name)
5489 gnus-newsrc-hashtb))
5492 (gnus-set-active nname (cons 1 0))
5493 (or (gnus-ephemeral-group-p name)
5495 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5497 (gnus-group-insert-group-line-info nname)
5499 (gnus-group-position-point)
5501 ;; Load the backend and try to make the backend create
5502 ;; the group as well.
5503 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5505 gnus-valid-select-methods)
5507 (gnus-check-server meth)
5508 (and (gnus-check-backend-function 'request-create-group nname)
5509 (gnus-request-create-group nname))
5512 (defun gnus-group-delete-group (group &optional force)
5513 "Delete the current group.
5514 If FORCE (the prefix) is non-nil, all the articles in the group will
5515 be deleted. This is \"deleted\" as in \"removed forever from the face
5516 of the Earth\". There is no undo."
5518 (list (gnus-group-group-name)
5519 current-prefix-arg))
5520 (or group (error "No group to rename"))
5521 (or (gnus-check-backend-function 'request-delete-group group)
5522 (error "This backend does not support group deletion"))
5524 (if (not (gnus-yes-or-no-p
5526 "Do you really want to delete %s%s? "
5527 group (if force " and all its contents" ""))))
5529 (gnus-message 6 "Deleting group %s..." group)
5530 (if (not (gnus-request-delete-group group force))
5531 (gnus-error 3 "Couldn't delete group %s" group)
5532 (gnus-message 6 "Deleting group %s...done" group)
5533 (gnus-group-goto-group group)
5534 (gnus-group-kill-group 1 t)
5535 (gnus-sethash group nil gnus-active-hashtb)
5537 (gnus-group-position-point)))
5539 (defun gnus-group-rename-group (group new-name)
5542 (gnus-group-group-name)
5544 (or (gnus-check-backend-function
5545 'request-rename-group (gnus-group-group-name))
5546 (error "This backend does not support renaming groups"))
5547 (read-string "New group name: "))))
5549 (or (gnus-check-backend-function 'request-rename-group group)
5550 (error "This backend does not support renaming groups"))
5552 (or group (error "No group to rename"))
5553 (and (string-match "^[ \t]*$" new-name)
5554 (error "Not a valid group name"))
5556 ;; We find the proper prefixed name.
5558 (gnus-group-prefixed-name
5559 (gnus-group-real-name new-name)
5560 (gnus-info-method (gnus-get-info group))))
5562 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5564 (if (not (gnus-request-rename-group group new-name))
5565 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5566 ;; We rename the group internally by killing it...
5567 (gnus-group-goto-group group)
5568 (gnus-group-kill-group)
5569 ;; ... changing its name ...
5570 (setcar (cdar gnus-list-of-killed-groups) new-name)
5571 ;; ... and then yanking it. Magic!
5572 (gnus-group-yank-group)
5573 (gnus-set-active new-name (gnus-active group))
5574 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5576 (gnus-group-position-point)))
5578 (defun gnus-group-edit-group (group &optional part)
5579 "Edit the group on the current line."
5580 (interactive (list (gnus-group-group-name)))
5581 (let* ((part (or part 'info))
5582 (done-func `(lambda ()
5583 "Exit editing mode and update the information."
5585 (gnus-group-edit-group-done ',part ,group)))
5586 (winconf (current-window-configuration))
5588 (or group (error "No group on current line"))
5589 (or (setq info (gnus-get-info group))
5590 (error "Killed group; can't be edited"))
5591 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5592 (gnus-configure-windows 'edit-group)
5593 (gnus-add-current-to-buffer-list)
5595 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5596 (use-local-map (copy-keymap emacs-lisp-mode-map))
5597 (local-set-key "\C-c\C-c" done-func)
5598 (make-local-variable 'gnus-prev-winconf)
5599 (setq gnus-prev-winconf winconf)
5604 ";; Type `C-c C-c' after editing the select method.\n\n")
5606 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5608 ";; Type `C-c C-c' after editing the group info.\n\n")))
5611 (cond ((eq part 'method)
5612 (or (gnus-info-method info) "native"))
5614 (gnus-info-params info))
5618 (defun gnus-group-edit-group-method (group)
5619 "Edit the select method of GROUP."
5620 (interactive (list (gnus-group-group-name)))
5621 (gnus-group-edit-group group 'method))
5623 (defun gnus-group-edit-group-parameters (group)
5624 "Edit the group parameters of GROUP."
5625 (interactive (list (gnus-group-group-name)))
5626 (gnus-group-edit-group group 'params))
5628 (defun gnus-group-edit-group-done (part group)
5629 "Get info from buffer, update variables and jump to the group buffer."
5630 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5631 (goto-char (point-min))
5632 (let* ((form (read (current-buffer)))
5633 (winconf gnus-prev-winconf)
5634 (method (cond ((eq part 'info) (nth 4 form))
5635 ((eq part 'method) form)
5637 (info (cond ((eq part 'info) form)
5638 ((eq part 'method) (gnus-get-info group))
5641 (if (or (not method)
5643 gnus-select-method method))
5644 (gnus-group-real-name (car info))
5645 (gnus-group-prefixed-name
5646 (gnus-group-real-name (car info)) method))
5648 (when (and new-group
5649 (not (equal new-group group)))
5650 (when (gnus-group-goto-group group)
5651 (gnus-group-kill-group 1))
5652 (gnus-activate-group new-group))
5654 (if (and info new-group)
5656 (setq info (gnus-copy-sequence info))
5657 (setcar info new-group)
5658 (unless (gnus-server-equal method "native")
5659 (unless (nthcdr 3 info)
5660 (nconc info (list nil nil)))
5661 (unless (nthcdr 4 info)
5662 (nconc info (list nil)))
5663 (gnus-info-set-method info method))
5664 (gnus-group-set-info info))
5665 (gnus-group-set-info form (or new-group group) part))
5666 (kill-buffer (current-buffer))
5667 (and winconf (set-window-configuration winconf))
5668 (set-buffer gnus-group-buffer)
5669 (gnus-group-update-group (or new-group group))
5670 (gnus-group-position-point)))
5672 (defun gnus-group-make-help-group ()
5673 "Create the Gnus documentation group."
5675 (let ((path load-path)
5676 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5678 (and (gnus-gethash name gnus-newsrc-hashtb)
5679 (error "Documentation group already exists"))
5681 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5683 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5685 (setq file (concat (file-name-directory
5686 (directory-file-name dir))
5687 "etc/gnus-tut.txt"))))
5690 (gnus-message 1 "Couldn't find doc group")
5691 (gnus-group-make-group
5692 (gnus-group-real-name name)
5693 (list 'nndoc "gnus-help"
5694 (list 'nndoc-address file)
5695 (list 'nndoc-article-type 'mbox)))))
5696 (gnus-group-position-point))
5698 (defun gnus-group-make-doc-group (file type)
5699 "Create a group that uses a single file as the source."
5701 (list (read-file-name "File name: ")
5702 (and current-prefix-arg 'ask)))
5703 (when (eq type 'ask)
5708 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5710 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5711 ((= char ?b) 'babyl)
5712 ((= char ?d) 'digest)
5713 ((= char ?f) 'forward)
5715 (t (setq err (format "%c unknown. " char))
5718 (let* ((file (expand-file-name file))
5719 (name (gnus-generate-new-group-name
5720 (gnus-group-prefixed-name
5721 (file-name-nondirectory file) '(nndoc "")))))
5722 (gnus-group-make-group
5723 (gnus-group-real-name name)
5724 (list 'nndoc (file-name-nondirectory file)
5725 (list 'nndoc-address file)
5726 (list 'nndoc-article-type (or type 'guess))))))
5728 (defun gnus-group-make-archive-group (&optional all)
5729 "Create the (ding) Gnus archive group of the most recent articles.
5730 Given a prefix, create a full group."
5732 (let ((group (gnus-group-prefixed-name
5733 (if all "ding.archives" "ding.recent") '(nndir ""))))
5734 (and (gnus-gethash group gnus-newsrc-hashtb)
5735 (error "Archive group already exists"))
5736 (gnus-group-make-group
5737 (gnus-group-real-name group)
5738 (list 'nndir (if all "hpc" "edu")
5739 (list 'nndir-directory
5740 (if all gnus-group-archive-directory
5741 gnus-group-recent-archive-directory))))))
5743 (defun gnus-group-make-directory-group (dir)
5744 "Create an nndir group.
5745 The user will be prompted for a directory. The contents of this
5746 directory will be used as a newsgroup. The directory should contain
5747 mail messages or news articles in files that have numeric names."
5749 (list (read-file-name "Create group from directory: ")))
5750 (or (file-exists-p dir) (error "No such directory"))
5751 (or (file-directory-p dir) (error "Not a directory"))
5755 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5757 (gnus-group-prefixed-name
5758 (concat (file-name-as-directory (directory-file-name dir))
5761 (setq ext (format "<%d>" (setq i (1+ i)))))
5762 (gnus-group-make-group
5763 (gnus-group-real-name group)
5764 (list 'nndir group (list 'nndir-directory dir)))))
5766 (defun gnus-group-make-kiboze-group (group address scores)
5767 "Create an nnkiboze group.
5768 The user will be prompted for a name, a regexp to match groups, and
5769 score file entries for articles to include in the group."
5772 (read-string "nnkiboze group name: ")
5773 (read-string "Source groups (regexp): ")
5774 (let ((headers (mapcar (lambda (group) (list group))
5775 '("subject" "from" "number" "date" "message-id"
5776 "references" "chars" "lines" "xref"
5777 "followup" "all" "body" "head")))
5778 scores header regexp regexps)
5779 (while (not (equal "" (setq header (completing-read
5780 "Match on header: " headers nil t))))
5782 (while (not (equal "" (setq regexp (read-string
5783 (format "Match on %s (string): "
5785 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5786 (setq scores (cons (cons header regexps) scores)))
5788 (gnus-group-make-group group "nnkiboze" address)
5789 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5790 (let (emacs-lisp-mode-hook)
5791 (pp scores (current-buffer)))))
5793 (defun gnus-group-add-to-virtual (n vgroup)
5794 "Add the current group to a virtual group."
5796 (list current-prefix-arg
5797 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5799 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5800 (error "%s is not an nnvirtual group" vgroup))
5801 (let* ((groups (gnus-group-process-prefix n))
5802 (method (gnus-info-method (gnus-get-info vgroup))))
5803 (setcar (cdr method)
5805 (nth 1 method) "\\|"
5808 (gnus-group-remove-mark s)
5809 (concat "\\(^" (regexp-quote s) "$\\)"))
5811 (gnus-group-position-point))
5813 (defun gnus-group-make-empty-virtual (group)
5814 "Create a new, fresh, empty virtual group."
5815 (interactive "sCreate new, empty virtual group: ")
5816 (let* ((method (list 'nnvirtual "^$"))
5817 (pgroup (gnus-group-prefixed-name group method)))
5818 ;; Check whether it exists already.
5819 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5820 (error "Group %s already exists." pgroup))
5821 ;; Subscribe the new group after the group on the current line.
5822 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5823 (gnus-group-update-group pgroup)
5825 (gnus-group-position-point)))
5827 (defun gnus-group-enter-directory (dir)
5828 "Enter an ephemeral nneething group."
5829 (interactive "DDirectory to read: ")
5830 (let* ((method (list 'nneething dir))
5831 (leaf (gnus-group-prefixed-name
5832 (file-name-nondirectory (directory-file-name dir))
5834 (name (gnus-generate-new-group-name leaf)))
5835 (let ((nneething-read-only t))
5836 (or (gnus-group-read-ephemeral-group
5838 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5840 (error "Couldn't enter %s" dir)))))
5842 ;; Group sorting commands
5843 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5845 (defun gnus-group-sort-groups (func &optional reverse)
5846 "Sort the group buffer according to FUNC.
5847 If REVERSE, reverse the sorting order."
5848 (interactive (list gnus-group-sort-function
5849 current-prefix-arg))
5851 ((not (listp func)) func)
5853 ((= 1 (length func)) (car func))
5855 ,(gnus-make-sort-function
5856 (reverse func)))))))
5857 ;; We peel off the dummy group from the alist.
5859 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5860 (pop gnus-newsrc-alist))
5862 (setq gnus-newsrc-alist
5863 (sort gnus-newsrc-alist func))
5865 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5866 ;; Regenerate the hash table.
5867 (gnus-make-hashtable-from-newsrc-alist)
5868 (gnus-group-list-groups))))
5870 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5871 "Sort the group buffer alphabetically by group name.
5872 If REVERSE, sort in reverse order."
5874 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5876 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5877 "Sort the group buffer by number of unread articles.
5878 If REVERSE, sort in reverse order."
5880 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5882 (defun gnus-group-sort-groups-by-level (&optional reverse)
5883 "Sort the group buffer by group level.
5884 If REVERSE, sort in reverse order."
5886 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5888 (defun gnus-group-sort-groups-by-score (&optional reverse)
5889 "Sort the group buffer by group score.
5890 If REVERSE, sort in reverse order."
5892 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5894 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5895 "Sort the group buffer by group rank.
5896 If REVERSE, sort in reverse order."
5898 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5900 (defun gnus-group-sort-groups-by-method (&optional reverse)
5901 "Sort the group buffer alphabetically by backend name.
5902 If REVERSE, sort in reverse order."
5904 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5906 (defun gnus-group-sort-by-alphabet (info1 info2)
5907 "Sort alphabetically."
5908 (string< (gnus-info-group info1) (gnus-info-group info2)))
5910 (defun gnus-group-sort-by-unread (info1 info2)
5911 "Sort by number of unread articles."
5912 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5913 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5914 (< (or (and (numberp n1) n1) 0)
5915 (or (and (numberp n2) n2) 0))))
5917 (defun gnus-group-sort-by-level (info1 info2)
5919 (< (gnus-info-level info1) (gnus-info-level info2)))
5921 (defun gnus-group-sort-by-method (info1 info2)
5922 "Sort alphabetically by backend name."
5923 (string< (symbol-name (car (gnus-find-method-for-group
5924 (gnus-info-group info1) info1)))
5925 (symbol-name (car (gnus-find-method-for-group
5926 (gnus-info-group info2) info2)))))
5928 (defun gnus-group-sort-by-score (info1 info2)
5929 "Sort by group score."
5930 (< (gnus-info-score info1) (gnus-info-score info2)))
5932 (defun gnus-group-sort-by-rank (info1 info2)
5933 "Sort by level and score."
5934 (let ((level1 (gnus-info-level info1))
5935 (level2 (gnus-info-level info2)))
5936 (or (< level1 level2)
5937 (and (= level1 level2)
5938 (> (gnus-info-score info1) (gnus-info-score info2))))))
5940 ;; Group catching up.
5942 (defun gnus-group-clear-data (n)
5943 "Clear all marks and read ranges from the current group."
5945 (let ((groups (gnus-group-process-prefix n))
5947 (while (setq group (pop groups))
5948 (setq info (gnus-get-info group))
5949 (gnus-info-set-read info nil)
5950 (when (gnus-info-marks info)
5951 (gnus-info-set-marks info nil))
5952 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5953 (when (gnus-group-goto-group group)
5954 (gnus-group-remove-mark group)
5955 (gnus-group-update-group-line)))))
5957 (defun gnus-group-catchup-current (&optional n all)
5958 "Mark all articles not marked as unread in current newsgroup as read.
5959 If prefix argument N is numeric, the ARG next newsgroups will be
5960 caught up. If ALL is non-nil, marked articles will also be marked as
5961 read. Cross references (Xref: header) of articles are ignored.
5962 The difference between N and actual number of newsgroups that were
5963 caught up is returned."
5965 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5969 "Do you really want to mark all articles as read? "
5970 "Mark all unread articles as read? "))))
5972 (let ((groups (gnus-group-process-prefix n))
5975 ;; Virtual groups have to be given special treatment.
5976 (let ((method (gnus-find-method-for-group (car groups))))
5977 (if (eq 'nnvirtual (car method))
5978 (nnvirtual-catchup-group
5979 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5980 (gnus-group-remove-mark (car groups))
5981 (if (>= (gnus-group-group-level) gnus-level-zombie)
5982 (gnus-message 2 "Dead groups can't be caught up")
5984 (gnus-group-goto-group (car groups))
5985 (gnus-group-catchup (car groups) all))
5986 (gnus-group-update-group-line)
5987 (setq ret (1+ ret))))
5988 (setq groups (cdr groups)))
5989 (gnus-group-next-unread-group 1)
5992 (defun gnus-group-catchup-current-all (&optional n)
5993 "Mark all articles in current newsgroup as read.
5994 Cross references (Xref: header) of articles are ignored."
5996 (gnus-group-catchup-current n 'all))
5998 (defun gnus-group-catchup (group &optional all)
5999 "Mark all articles in GROUP as read.
6000 If ALL is non-nil, all articles are marked as read.
6001 The return value is the number of articles that were marked as read,
6002 or nil if no action could be taken."
6003 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6005 ;; Do the updating only if the newsgroup isn't killed.
6006 (if (not (numberp (car entry)))
6007 (gnus-message 1 "Can't catch up; non-active group")
6008 ;; Do auto-expirable marks if that's required.
6009 (when (gnus-group-auto-expirable-p group)
6010 (gnus-add-marked-articles
6011 group 'expire (gnus-list-of-unread-articles group))
6013 (let ((marks (nth 3 (nth 2 entry))))
6014 (gnus-add-marked-articles
6015 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6016 (gnus-add-marked-articles
6017 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6019 (gnus-update-read-articles group nil)
6020 ;; Also nix out the lists of marks and dormants.
6022 (gnus-add-marked-articles group 'tick nil nil 'force)
6023 (gnus-add-marked-articles group 'dormant nil nil 'force))
6024 (run-hooks 'gnus-group-catchup-group-hook)
6027 (defun gnus-group-expire-articles (&optional n)
6028 "Expire all expirable articles in the current newsgroup."
6030 (let ((groups (gnus-group-process-prefix n))
6033 (error "No groups to expire"))
6034 (while (setq group (pop groups))
6035 (gnus-group-remove-mark group)
6036 (when (gnus-check-backend-function 'request-expire-articles group)
6037 (gnus-message 6 "Expiring articles in %s..." group)
6038 (let* ((info (gnus-get-info group))
6039 (expirable (if (gnus-group-total-expirable-p group)
6040 (cons nil (gnus-list-of-read-articles group))
6041 (assq 'expire (gnus-info-marks info))))
6042 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6046 (gnus-compress-sequence
6048 ;; We set the expiry variables to the groupp
6050 (let ((nnmail-expiry-wait-function nil)
6051 (nnmail-expiry-wait expiry-wait))
6052 (gnus-request-expire-articles
6053 (gnus-uncompress-sequence (cdr expirable)) group))
6054 ;; Just expire using the normal expiry values.
6055 (gnus-request-expire-articles
6056 (gnus-uncompress-sequence (cdr expirable)) group)))))
6057 (gnus-message 6 "Expiring articles in %s...done" group)))
6058 (gnus-group-position-point))))
6060 (defun gnus-group-expire-all-groups ()
6061 "Expire all expirable articles in all newsgroups."
6064 (gnus-message 5 "Expiring...")
6065 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6066 (cdr gnus-newsrc-alist))))
6067 (gnus-group-expire-articles nil)))
6068 (gnus-group-position-point)
6069 (gnus-message 5 "Expiring...done"))
6071 (defun gnus-group-set-current-level (n level)
6072 "Set the level of the next N groups to LEVEL."
6077 (let ((s (read-string
6078 (format "Level (default %s): "
6079 (or (gnus-group-group-level)
6080 gnus-level-default-subscribed)))))
6081 (if (string-match "^\\s-*$" s)
6082 (int-to-string (or (gnus-group-group-level)
6083 gnus-level-default-subscribed))
6085 (or (and (>= level 1) (<= level gnus-level-killed))
6086 (error "Illegal level: %d" level))
6087 (let ((groups (gnus-group-process-prefix n))
6089 (while (setq group (pop groups))
6090 (gnus-group-remove-mark group)
6091 (gnus-message 6 "Changed level of %s from %d to %d"
6092 group (or (gnus-group-group-level) gnus-level-killed)
6094 (gnus-group-change-level
6095 group level (or (gnus-group-group-level) gnus-level-killed))
6096 (gnus-group-update-group-line)))
6097 (gnus-group-position-point))
6099 (defun gnus-group-unsubscribe-current-group (&optional n)
6100 "Toggle subscription of the current group.
6101 If given numerical prefix, toggle the N next groups."
6103 (let ((groups (gnus-group-process-prefix n))
6106 (setq group (car groups)
6107 groups (cdr groups))
6108 (gnus-group-remove-mark group)
6109 (gnus-group-unsubscribe-group
6110 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6111 gnus-level-default-unsubscribed
6112 gnus-level-default-subscribed) t)
6113 (gnus-group-update-group-line))
6114 (gnus-group-next-group 1)))
6116 (defun gnus-group-unsubscribe-group (group &optional level silent)
6117 "Toggle subscription to GROUP.
6118 Killed newsgroups are subscribed. If SILENT, don't try to update the
6121 (list (completing-read
6122 "Group: " gnus-active-hashtb nil
6123 (gnus-read-active-file-p)
6125 'gnus-group-history)))
6126 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6128 ((string-match "^[ \t]$" group)
6129 (error "Empty group name"))
6131 ;; Toggle subscription flag.
6132 (gnus-group-change-level
6133 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6134 gnus-level-subscribed)
6135 (1+ gnus-level-subscribed)
6136 gnus-level-default-subscribed)))
6138 (gnus-group-update-group group)))
6139 ((and (stringp group)
6140 (or (not (gnus-read-active-file-p))
6141 (gnus-active group)))
6142 ;; Add new newsgroup.
6143 (gnus-group-change-level
6145 (if level level gnus-level-default-subscribed)
6146 (or (and (member group gnus-zombie-list)
6149 (and (gnus-group-group-name)
6150 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6152 (gnus-group-update-group group)))
6153 (t (error "No such newsgroup: %s" group)))
6154 (gnus-group-position-point)))
6156 (defun gnus-group-transpose-groups (n)
6157 "Move the current newsgroup up N places.
6158 If given a negative prefix, move down instead. The difference between
6159 N and the number of steps taken is returned."
6161 (or (gnus-group-group-name)
6162 (error "No group on current line"))
6163 (gnus-group-kill-group 1)
6165 (forward-line (- n))
6166 (gnus-group-yank-group)
6167 (gnus-group-position-point)))
6169 (defun gnus-group-kill-all-zombies ()
6170 "Kill all zombie newsgroups."
6172 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6173 (setq gnus-zombie-list nil)
6174 (gnus-group-list-groups))
6176 (defun gnus-group-kill-region (begin end)
6177 "Kill newsgroups in current region (excluding current point).
6178 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6193 (beginning-of-line) ;Important when LINES < 1
6194 (gnus-group-kill-group lines)))
6196 (defun gnus-group-kill-group (&optional n discard)
6197 "Kill the next N groups.
6198 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6199 However, only groups that were alive can be yanked; already killed
6200 groups or zombie groups can't be yanked.
6201 The return value is the name of the group that was killed, or a list
6204 (let ((buffer-read-only nil)
6205 (groups (gnus-group-process-prefix n))
6206 group entry level out)
6207 (if (< (length groups) 10)
6208 ;; This is faster when there are few groups.
6210 (push (setq group (pop groups)) out)
6211 (gnus-group-remove-mark group)
6212 (setq level (gnus-group-group-level))
6214 (when (and (not discard)
6215 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6216 (push (cons (car entry) (nth 2 entry))
6217 gnus-list-of-killed-groups))
6218 (gnus-group-change-level
6219 (if entry entry group) gnus-level-killed (if entry nil level)))
6220 ;; If there are lots and lots of groups to be killed, we use
6221 ;; this thing instead.
6223 (setq groups (nreverse groups))
6225 (gnus-group-remove-mark (setq group (pop groups)))
6228 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6229 (push (cons (car entry) (nth 2 entry))
6230 gnus-list-of-killed-groups)
6231 (setcdr (cdr entry) (cdddr entry)))
6232 ((member group gnus-zombie-list)
6233 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6234 (gnus-make-hashtable-from-newsrc-alist)))
6236 (gnus-group-position-point)
6237 (if (< (length out) 2) (car out) (nreverse out))))
6239 (defun gnus-group-yank-group (&optional arg)
6240 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6241 inserting it before the current newsgroup. The numeric ARG specifies
6242 how many newsgroups are to be yanked. The name of the newsgroup yanked
6243 is returned, or (if several groups are yanked) a list of yanked groups
6246 (setq arg (or arg 1))
6247 (let (info group prev out)
6248 (while (>= (decf arg) 0)
6249 (if (not (setq info (pop gnus-list-of-killed-groups)))
6250 (error "No more newsgroups to yank"))
6251 (push (setq group (nth 1 info)) out)
6252 ;; Find which newsgroup to insert this one before - search
6253 ;; backward until something suitable is found. If there are no
6254 ;; other newsgroups in this buffer, just make this newsgroup the
6256 (setq prev (gnus-group-group-name))
6257 (gnus-group-change-level
6258 info (gnus-info-level (cdr info)) gnus-level-killed
6259 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6261 (gnus-group-insert-group-line-info group))
6263 (gnus-group-position-point)
6264 (if (< (length out) 2) (car out) (nreverse out))))
6266 (defun gnus-group-kill-level (level)
6267 "Kill all groups that is on a certain LEVEL."
6268 (interactive "nKill all groups on level: ")
6270 ((= level gnus-level-zombie)
6271 (setq gnus-killed-list
6272 (nconc gnus-zombie-list gnus-killed-list))
6273 (setq gnus-zombie-list nil))
6274 ((and (< level gnus-level-zombie)
6276 (or gnus-expert-user
6279 "Do you really want to kill all groups on level %d? "
6281 (let* ((prev gnus-newsrc-alist)
6284 (if (= (gnus-info-level level) level)
6285 (setcdr prev (cdr alist))
6287 (setq alist (cdr alist)))
6288 (gnus-make-hashtable-from-newsrc-alist)
6289 (gnus-group-list-groups)))
6291 (error "Can't kill; illegal level: %d" level))))
6293 (defun gnus-group-list-all-groups (&optional arg)
6294 "List all newsgroups with level ARG or lower.
6295 Default is gnus-level-unsubscribed, which lists all subscribed and most
6296 unsubscribed groups."
6298 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6300 ;; Redefine this to list ALL killed groups if prefix arg used.
6301 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6302 (defun gnus-group-list-killed (&optional arg)
6303 "List all killed newsgroups in the group buffer.
6304 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6305 entail asking the server for the groups."
6307 ;; Find all possible killed newsgroups if arg.
6309 (gnus-get-killed-groups))
6310 (if (not gnus-killed-list)
6311 (gnus-message 6 "No killed groups")
6312 (let (gnus-group-list-mode)
6313 (funcall gnus-group-prepare-function
6314 gnus-level-killed t gnus-level-killed))
6315 (goto-char (point-min)))
6316 (gnus-group-position-point))
6318 (defun gnus-group-list-zombies ()
6319 "List all zombie newsgroups in the group buffer."
6321 (if (not gnus-zombie-list)
6322 (gnus-message 6 "No zombie groups")
6323 (let (gnus-group-list-mode)
6324 (funcall gnus-group-prepare-function
6325 gnus-level-zombie t gnus-level-zombie))
6326 (goto-char (point-min)))
6327 (gnus-group-position-point))
6329 (defun gnus-group-list-active ()
6330 "List all groups that are available from the server(s)."
6332 ;; First we make sure that we have really read the active file.
6333 (unless (gnus-read-active-file-p)
6334 (let ((gnus-read-active-file t))
6335 (gnus-read-active-file)))
6336 ;; Find all groups and sort them.
6342 (and (symbol-value sym)
6343 (setq list (cons (symbol-name sym) list))))
6347 (buffer-read-only nil))
6350 (gnus-group-insert-group-line-info (pop groups)))
6351 (goto-char (point-min))))
6353 (defun gnus-activate-all-groups (level)
6354 "Activate absolutely all groups."
6355 (interactive (list 7))
6356 (let ((gnus-activate-level level)
6357 (gnus-activate-foreign-newsgroups level))
6358 (gnus-group-get-new-news)))
6360 (defun gnus-group-get-new-news (&optional arg)
6361 "Get newly arrived articles.
6362 If ARG is a number, it specifies which levels you are interested in
6363 re-scanning. If ARG is non-nil and not a number, this will force
6364 \"hard\" re-reading of the active files from all servers."
6366 (run-hooks 'gnus-get-new-news-hook)
6367 ;; We might read in new NoCeM messages here.
6368 (when (and gnus-use-nocem
6370 (gnus-nocem-scan-groups))
6371 ;; If ARG is not a number, then we read the active file.
6372 (when (and arg (not (numberp arg)))
6373 (let ((gnus-read-active-file t))
6374 (gnus-read-active-file))
6377 (setq arg (gnus-group-default-level arg t))
6378 (if (and gnus-read-active-file (not arg))
6380 (gnus-read-active-file)
6381 (gnus-get-unread-articles arg))
6382 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6383 (gnus-get-unread-articles arg)))
6384 (run-hooks 'gnus-after-getting-new-news-hook)
6385 (gnus-group-list-groups))
6387 (defun gnus-group-get-new-news-this-group (&optional n)
6388 "Check for newly arrived news in the current group (and the N-1 next groups).
6389 The difference between N and the number of newsgroup checked is returned.
6390 If N is negative, this group and the N-1 previous groups will be checked."
6392 (let* ((groups (gnus-group-process-prefix n))
6393 (ret (if (numberp n) (- n (length groups)) 0))
6394 (beg (unless n (point)))
6396 (while (setq group (pop groups))
6397 (gnus-group-remove-mark group)
6398 (if (gnus-activate-group group 'scan)
6400 (gnus-get-unread-articles-in-group
6401 (gnus-get-info group) (gnus-active group) t)
6402 (unless (gnus-virtual-group-p group)
6403 (gnus-close-group group))
6404 (gnus-group-update-group group))
6405 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6406 (when beg (goto-char beg))
6407 (when gnus-goto-next-group-when-activating
6408 (gnus-group-next-unread-group 1 t))
6409 (gnus-summary-position-point)
6412 (defun gnus-group-fetch-faq (group &optional faq-dir)
6413 "Fetch the FAQ for the current group."
6416 (gnus-group-real-name (gnus-group-group-name))
6417 (cond (current-prefix-arg
6419 "Faq dir: " (and (listp gnus-group-faq-directory)
6420 gnus-group-faq-directory))))))
6422 (setq faq-dir (if (listp gnus-group-faq-directory)
6423 (car gnus-group-faq-directory)
6424 gnus-group-faq-directory)))
6425 (or group (error "No group name given"))
6426 (let ((file (concat (file-name-as-directory faq-dir)
6427 (gnus-group-real-name group))))
6428 (if (not (file-exists-p file))
6429 (error "No such file: %s" file)
6432 (defun gnus-group-describe-group (force &optional group)
6433 "Display a description of the current newsgroup."
6434 (interactive (list current-prefix-arg (gnus-group-group-name)))
6435 (and force (setq gnus-description-hashtb nil))
6436 (let ((method (gnus-find-method-for-group group))
6438 (or group (error "No group name given"))
6439 (and (or (and gnus-description-hashtb
6440 ;; We check whether this group's method has been
6441 ;; queried for a description file.
6443 (gnus-group-prefixed-name "" method)
6444 gnus-description-hashtb))
6445 (setq desc (gnus-group-get-description group))
6446 (gnus-read-descriptions-file method))
6448 (or desc (gnus-gethash group gnus-description-hashtb)
6449 "No description available")))))
6451 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6452 (defun gnus-group-describe-all-groups (&optional force)
6453 "Pop up a buffer with descriptions of all newsgroups."
6455 (and force (setq gnus-description-hashtb nil))
6456 (if (not (or gnus-description-hashtb
6457 (gnus-read-all-descriptions-files)))
6458 (error "Couldn't request descriptions file"))
6459 (let ((buffer-read-only nil)
6465 (insert (format " *: %-20s %s\n" (symbol-name group)
6466 (symbol-value group)))
6467 (add-text-properties
6468 b (1+ b) (list 'gnus-group group
6469 'gnus-unread t 'gnus-marked nil
6470 'gnus-level (1+ gnus-level-subscribed))))
6471 gnus-description-hashtb)
6472 (goto-char (point-min))
6473 (gnus-group-position-point)))
6475 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6476 (defun gnus-group-apropos (regexp &optional search-description)
6477 "List all newsgroups that have names that match a regexp."
6478 (interactive "sGnus apropos (regexp): ")
6480 (obuf (current-buffer))
6482 ;; Go through all newsgroups that are known to Gnus.
6485 (and (symbol-name group)
6486 (string-match regexp (symbol-name group))
6487 (setq groups (cons (symbol-name group) groups))))
6489 ;; Also go through all descriptions that are known to Gnus.
6490 (when search-description
6493 (and (string-match regexp (symbol-value group))
6494 (gnus-active (symbol-name group))
6495 (setq groups (cons (symbol-name group) groups))))
6496 gnus-description-hashtb))
6498 (gnus-message 3 "No groups matched \"%s\"." regexp)
6499 ;; Print out all the groups.
6501 (pop-to-buffer "*Gnus Help*")
6502 (buffer-disable-undo (current-buffer))
6504 (setq groups (sort groups 'string<))
6506 ;; Groups may be entered twice into the list of groups.
6507 (if (not (string= (car groups) prev))
6509 (insert (setq prev (car groups)) "\n")
6510 (if (and gnus-description-hashtb
6511 (setq des (gnus-gethash (car groups)
6512 gnus-description-hashtb)))
6513 (insert " " des "\n"))))
6514 (setq groups (cdr groups)))
6515 (goto-char (point-min))))
6516 (pop-to-buffer obuf)))
6518 (defun gnus-group-description-apropos (regexp)
6519 "List all newsgroups that have names or descriptions that match a regexp."
6520 (interactive "sGnus description apropos (regexp): ")
6521 (if (not (or gnus-description-hashtb
6522 (gnus-read-all-descriptions-files)))
6523 (error "Couldn't request descriptions file"))
6524 (gnus-group-apropos regexp t))
6526 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6527 (defun gnus-group-list-matching (level regexp &optional all lowest)
6528 "List all groups with unread articles that match REGEXP.
6529 If the prefix LEVEL is non-nil, it should be a number that says which
6530 level to cut off listing groups.
6531 If ALL, also list groups with no unread articles.
6532 If LOWEST, don't list groups with level lower than LOWEST.
6534 This command may read the active file."
6535 (interactive "P\nsList newsgroups matching: ")
6536 ;; First make sure active file has been read.
6538 (>= (prefix-numeric-value level) gnus-level-killed))
6539 (gnus-get-killed-groups))
6540 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6541 all (or lowest 1) regexp)
6542 (goto-char (point-min))
6543 (gnus-group-position-point))
6545 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6546 "List all groups that match REGEXP.
6547 If the prefix LEVEL is non-nil, it should be a number that says which
6548 level to cut off listing groups.
6549 If LOWEST, don't list groups with level lower than LOWEST."
6550 (interactive "P\nsList newsgroups matching: ")
6551 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6553 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6554 (defun gnus-group-save-newsrc (&optional force)
6555 "Save the Gnus startup files.
6556 If FORCE, force saving whether it is necessary or not."
6558 (gnus-save-newsrc-file force))
6560 (defun gnus-group-restart (&optional arg)
6561 "Force Gnus to read the .newsrc file."
6563 (when (gnus-yes-or-no-p
6564 (format "Are you sure you want to read %s? "
6565 gnus-current-startup-file))
6566 (gnus-save-newsrc-file)
6567 (gnus-setup-news 'force)
6568 (gnus-group-list-groups arg)))
6570 (defun gnus-group-read-init-file ()
6571 "Read the Gnus elisp init file."
6573 (gnus-read-init-file))
6575 (defun gnus-group-check-bogus-groups (&optional silent)
6576 "Check bogus newsgroups.
6577 If given a prefix, don't ask for confirmation before removing a bogus
6580 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6581 (gnus-group-list-groups))
6583 (defun gnus-group-edit-global-kill (&optional article group)
6584 "Edit the global kill file.
6585 If GROUP, edit that local kill file instead."
6587 (setq gnus-current-kill-article article)
6588 (gnus-kill-file-edit-file group)
6591 (substitute-command-keys
6592 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6593 (if group "local" "global")))))
6595 (defun gnus-group-edit-local-kill (article group)
6596 "Edit a local kill file."
6597 (interactive (list nil (gnus-group-group-name)))
6598 (gnus-group-edit-global-kill article group))
6600 (defun gnus-group-force-update ()
6601 "Update `.newsrc' file."
6603 (gnus-save-newsrc-file))
6605 (defun gnus-group-suspend ()
6606 "Suspend the current Gnus session.
6607 In fact, cleanup buffers except for group mode buffer.
6608 The hook gnus-suspend-gnus-hook is called before actually suspending."
6610 (run-hooks 'gnus-suspend-gnus-hook)
6611 ;; Kill Gnus buffers except for group mode buffer.
6612 (let ((group-buf (get-buffer gnus-group-buffer)))
6613 ;; Do this on a separate list in case the user does a ^G before we finish
6614 (let ((gnus-buffer-list
6615 (delq group-buf (delq gnus-dribble-buffer
6616 (append gnus-buffer-list nil)))))
6617 (while gnus-buffer-list
6618 (gnus-kill-buffer (car gnus-buffer-list))
6619 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6622 (setq gnus-buffer-list (list group-buf))
6623 (bury-buffer group-buf)
6624 (delete-windows-on group-buf t)))))
6626 (defun gnus-group-clear-dribble ()
6627 "Clear all information from the dribble buffer."
6629 (gnus-dribble-clear)
6630 (gnus-message 7 "Cleared dribble buffer"))
6632 (defun gnus-group-exit ()
6633 "Quit reading news after updating .newsrc.eld and .newsrc.
6634 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6637 (or noninteractive ;For gnus-batch-kill
6638 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6639 (not gnus-interactive-exit) ;Without confirmation
6641 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6642 (run-hooks 'gnus-exit-gnus-hook)
6643 ;; Offer to save data from non-quitted summary buffers.
6644 (gnus-offer-save-summaries)
6645 ;; Save the newsrc file(s).
6646 (gnus-save-newsrc-file)
6648 (gnus-close-backends)
6649 ;; Reset everything.
6651 ;; Allow the user to do things after cleaning up.
6652 (run-hooks 'gnus-after-exiting-gnus-hook)))
6654 (defun gnus-close-backends ()
6655 ;; Send a close request to all backends that support such a request.
6656 (let ((methods gnus-valid-select-methods)
6659 (if (fboundp (setq func (intern (concat (caar methods)
6660 "-request-close"))))
6662 (setq methods (cdr methods)))))
6664 (defun gnus-group-quit ()
6665 "Quit reading news without updating .newsrc.eld or .newsrc.
6666 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6668 (when (or noninteractive ;For gnus-batch-kill
6669 (zerop (buffer-size))
6670 (not (gnus-server-opened gnus-select-method))
6672 (not gnus-current-startup-file)
6674 (format "Quit reading news without saving %s? "
6675 (file-name-nondirectory gnus-current-startup-file))))
6676 (run-hooks 'gnus-exit-gnus-hook)
6677 (if gnus-use-full-window
6678 (delete-other-windows)
6679 (gnus-remove-some-windows))
6681 (gnus-close-backends)
6683 ;; Allow the user to do things after cleaning up.
6684 (run-hooks 'gnus-after-exiting-gnus-hook)))
6686 (defun gnus-offer-save-summaries ()
6687 "Offer to save all active summary buffers."
6689 (let ((buflist (buffer-list))
6691 ;; Go through all buffers and find all summaries.
6693 (and (setq bufname (buffer-name (car buflist)))
6694 (string-match "Summary" bufname)
6696 (set-buffer bufname)
6697 ;; We check that this is, indeed, a summary buffer.
6698 (and (eq major-mode 'gnus-summary-mode)
6699 ;; Also make sure this isn't bogus.
6700 gnus-newsgroup-prepared))
6701 (push bufname buffers))
6702 (setq buflist (cdr buflist)))
6703 ;; Go through all these summary buffers and offer to save them.
6706 "Update summary buffer %s? "
6707 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6710 (defun gnus-group-describe-briefly ()
6711 "Give a one line description of the group mode commands."
6713 (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")))
6715 (defun gnus-group-browse-foreign-server (method)
6716 "Browse a foreign news server.
6717 If called interactively, this function will ask for a select method
6718 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6719 If not, METHOD should be a list where the first element is the method
6720 and the second element is the address."
6722 (list (let ((how (completing-read
6724 (append gnus-valid-select-methods gnus-server-alist)
6725 nil t (cons "nntp" 0) 'gnus-method-history)))
6726 ;; We either got a backend name or a virtual server name.
6727 ;; If the first, we also need an address.
6728 (if (assoc how gnus-valid-select-methods)
6730 ;; Suggested by mapjph@bath.ac.uk.
6733 (mapcar (lambda (server) (list server))
6734 gnus-secondary-servers)))
6735 ;; We got a server name, so we find the method.
6736 (gnus-server-to-method how)))))
6737 (gnus-browse-foreign-server method))
6741 ;;; Gnus summary mode
6744 (defvar gnus-summary-mode-map nil)
6746 (put 'gnus-summary-mode 'mode-class 'special)
6748 (unless gnus-summary-mode-map
6749 (setq gnus-summary-mode-map (make-keymap))
6750 (suppress-keymap gnus-summary-mode-map)
6752 ;; Non-orthogonal keys
6754 (gnus-define-keys gnus-summary-mode-map
6755 " " gnus-summary-next-page
6756 "\177" gnus-summary-prev-page
6757 [delete] gnus-summary-prev-page
6758 "\r" gnus-summary-scroll-up
6759 "n" gnus-summary-next-unread-article
6760 "p" gnus-summary-prev-unread-article
6761 "N" gnus-summary-next-article
6762 "P" gnus-summary-prev-article
6763 "\M-\C-n" gnus-summary-next-same-subject
6764 "\M-\C-p" gnus-summary-prev-same-subject
6765 "\M-n" gnus-summary-next-unread-subject
6766 "\M-p" gnus-summary-prev-unread-subject
6767 "." gnus-summary-first-unread-article
6768 "," gnus-summary-best-unread-article
6769 "\M-s" gnus-summary-search-article-forward
6770 "\M-r" gnus-summary-search-article-backward
6771 "<" gnus-summary-beginning-of-article
6772 ">" gnus-summary-end-of-article
6773 "j" gnus-summary-goto-article
6774 "^" gnus-summary-refer-parent-article
6775 "\M-^" gnus-summary-refer-article
6776 "u" gnus-summary-tick-article-forward
6777 "!" gnus-summary-tick-article-forward
6778 "U" gnus-summary-tick-article-backward
6779 "d" gnus-summary-mark-as-read-forward
6780 "D" gnus-summary-mark-as-read-backward
6781 "E" gnus-summary-mark-as-expirable
6782 "\M-u" gnus-summary-clear-mark-forward
6783 "\M-U" gnus-summary-clear-mark-backward
6784 "k" gnus-summary-kill-same-subject-and-select
6785 "\C-k" gnus-summary-kill-same-subject
6786 "\M-\C-k" gnus-summary-kill-thread
6787 "\M-\C-l" gnus-summary-lower-thread
6788 "e" gnus-summary-edit-article
6789 "#" gnus-summary-mark-as-processable
6790 "\M-#" gnus-summary-unmark-as-processable
6791 "\M-\C-t" gnus-summary-toggle-threads
6792 "\M-\C-s" gnus-summary-show-thread
6793 "\M-\C-h" gnus-summary-hide-thread
6794 "\M-\C-f" gnus-summary-next-thread
6795 "\M-\C-b" gnus-summary-prev-thread
6796 "\M-\C-u" gnus-summary-up-thread
6797 "\M-\C-d" gnus-summary-down-thread
6798 "&" gnus-summary-execute-command
6799 "c" gnus-summary-catchup-and-exit
6800 "\C-w" gnus-summary-mark-region-as-read
6801 "\C-t" gnus-summary-toggle-truncation
6802 "?" gnus-summary-mark-as-dormant
6803 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6804 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6805 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6806 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6807 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6808 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6809 "=" gnus-summary-expand-window
6810 "\C-x\C-s" gnus-summary-reselect-current-group
6811 "\M-g" gnus-summary-rescan-group
6812 "w" gnus-summary-stop-page-breaking
6813 "\C-c\C-r" gnus-summary-caesar-message
6814 "\M-t" gnus-summary-toggle-mime
6815 "f" gnus-summary-followup
6816 "F" gnus-summary-followup-with-original
6817 "C" gnus-summary-cancel-article
6818 "r" gnus-summary-reply
6819 "R" gnus-summary-reply-with-original
6820 "\C-c\C-f" gnus-summary-mail-forward
6821 "o" gnus-summary-save-article
6822 "\C-o" gnus-summary-save-article-mail
6823 "|" gnus-summary-pipe-output
6824 "\M-k" gnus-summary-edit-local-kill
6825 "\M-K" gnus-summary-edit-global-kill
6827 "\C-c\C-d" gnus-summary-describe-group
6828 "q" gnus-summary-exit
6829 "Q" gnus-summary-exit-no-update
6830 "\C-c\C-i" gnus-info-find-node
6831 gnus-mouse-2 gnus-mouse-pick-article
6832 "m" gnus-summary-mail-other-window
6833 "a" gnus-summary-post-news
6834 "x" gnus-summary-limit-to-unread
6835 "s" gnus-summary-isearch-article
6836 "t" gnus-article-hide-headers
6837 "g" gnus-summary-show-article
6838 "l" gnus-summary-goto-last-article
6839 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6840 "\C-d" gnus-summary-enter-digest-group
6842 "*" gnus-cache-enter-article
6843 "\M-*" gnus-cache-remove-article
6844 "\M-&" gnus-summary-universal-argument
6845 "\C-l" gnus-recenter
6846 "I" gnus-summary-increase-score
6847 "L" gnus-summary-lower-score
6849 "V" gnus-summary-score-map
6850 "X" gnus-uu-extract-map
6851 "S" gnus-summary-send-map)
6853 ;; Sort of orthogonal keymap
6854 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6855 "t" gnus-summary-tick-article-forward
6856 "!" gnus-summary-tick-article-forward
6857 "d" gnus-summary-mark-as-read-forward
6858 "r" gnus-summary-mark-as-read-forward
6859 "c" gnus-summary-clear-mark-forward
6860 " " gnus-summary-clear-mark-forward
6861 "e" gnus-summary-mark-as-expirable
6862 "x" gnus-summary-mark-as-expirable
6863 "?" gnus-summary-mark-as-dormant
6864 "b" gnus-summary-set-bookmark
6865 "B" gnus-summary-remove-bookmark
6866 "#" gnus-summary-mark-as-processable
6867 "\M-#" gnus-summary-unmark-as-processable
6868 "S" gnus-summary-limit-include-expunged
6869 "C" gnus-summary-catchup
6870 "H" gnus-summary-catchup-to-here
6871 "\C-c" gnus-summary-catchup-all
6872 "k" gnus-summary-kill-same-subject-and-select
6873 "K" gnus-summary-kill-same-subject
6874 "P" gnus-uu-mark-map)
6876 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6877 "c" gnus-summary-clear-above
6878 "u" gnus-summary-tick-above
6879 "m" gnus-summary-mark-above
6880 "k" gnus-summary-kill-below)
6882 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6883 "/" gnus-summary-limit-to-subject
6884 "n" gnus-summary-limit-to-articles
6885 "w" gnus-summary-pop-limit
6886 "s" gnus-summary-limit-to-subject
6887 "a" gnus-summary-limit-to-author
6888 "u" gnus-summary-limit-to-unread
6889 "m" gnus-summary-limit-to-marks
6890 "v" gnus-summary-limit-to-score
6891 "D" gnus-summary-limit-include-dormant
6892 "d" gnus-summary-limit-exclude-dormant
6893 ;; "t" gnus-summary-limit-exclude-thread
6894 "E" gnus-summary-limit-include-expunged
6895 "c" gnus-summary-limit-exclude-childless-dormant
6896 "C" gnus-summary-limit-mark-excluded-as-read)
6898 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6899 "n" gnus-summary-next-unread-article
6900 "p" gnus-summary-prev-unread-article
6901 "N" gnus-summary-next-article
6902 "P" gnus-summary-prev-article
6903 "\C-n" gnus-summary-next-same-subject
6904 "\C-p" gnus-summary-prev-same-subject
6905 "\M-n" gnus-summary-next-unread-subject
6906 "\M-p" gnus-summary-prev-unread-subject
6907 "f" gnus-summary-first-unread-article
6908 "b" gnus-summary-best-unread-article
6909 "j" gnus-summary-goto-article
6910 "g" gnus-summary-goto-subject
6911 "l" gnus-summary-goto-last-article
6912 "p" gnus-summary-pop-article)
6914 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6915 "k" gnus-summary-kill-thread
6916 "l" gnus-summary-lower-thread
6917 "i" gnus-summary-raise-thread
6918 "T" gnus-summary-toggle-threads
6919 "t" gnus-summary-rethread-current
6920 "^" gnus-summary-reparent-thread
6921 "s" gnus-summary-show-thread
6922 "S" gnus-summary-show-all-threads
6923 "h" gnus-summary-hide-thread
6924 "H" gnus-summary-hide-all-threads
6925 "n" gnus-summary-next-thread
6926 "p" gnus-summary-prev-thread
6927 "u" gnus-summary-up-thread
6928 "o" gnus-summary-top-thread
6929 "d" gnus-summary-down-thread
6930 "#" gnus-uu-mark-thread
6931 "\M-#" gnus-uu-unmark-thread)
6933 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6934 "c" gnus-summary-catchup-and-exit
6935 "C" gnus-summary-catchup-all-and-exit
6936 "E" gnus-summary-exit-no-update
6937 "Q" gnus-summary-exit
6938 "Z" gnus-summary-exit
6939 "n" gnus-summary-catchup-and-goto-next-group
6940 "R" gnus-summary-reselect-current-group
6941 "G" gnus-summary-rescan-group
6942 "N" gnus-summary-next-group
6943 "P" gnus-summary-prev-group)
6945 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6946 " " gnus-summary-next-page
6947 "n" gnus-summary-next-page
6948 "\177" gnus-summary-prev-page
6949 [delete] gnus-summary-prev-page
6950 "p" gnus-summary-prev-page
6951 "\r" gnus-summary-scroll-up
6952 "<" gnus-summary-beginning-of-article
6953 ">" gnus-summary-end-of-article
6954 "b" gnus-summary-beginning-of-article
6955 "e" gnus-summary-end-of-article
6956 "^" gnus-summary-refer-parent-article
6957 "r" gnus-summary-refer-parent-article
6958 "R" gnus-summary-refer-references
6959 "g" gnus-summary-show-article
6960 "s" gnus-summary-isearch-article)
6962 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6963 "b" gnus-article-add-buttons
6964 "B" gnus-article-add-buttons-to-head
6965 "o" gnus-article-treat-overstrike
6966 ;; "w" gnus-article-word-wrap
6967 "w" gnus-article-fill-cited-article
6968 "c" gnus-article-remove-cr
6969 "L" gnus-article-remove-trailing-blank-lines
6970 "q" gnus-article-de-quoted-unreadable
6971 "f" gnus-article-display-x-face
6972 "l" gnus-summary-stop-page-breaking
6973 "r" gnus-summary-caesar-message
6974 "t" gnus-article-hide-headers
6975 "v" gnus-summary-verbose-headers
6976 "m" gnus-summary-toggle-mime)
6978 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6979 "a" gnus-article-hide
6980 "h" gnus-article-hide-headers
6981 "b" gnus-article-hide-boring-headers
6982 "s" gnus-article-hide-signature
6983 "c" gnus-article-hide-citation
6984 "p" gnus-article-hide-pgp
6985 "\C-c" gnus-article-hide-citation-maybe)
6987 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6988 "a" gnus-article-highlight
6989 "h" gnus-article-highlight-headers
6990 "c" gnus-article-highlight-citation
6991 "s" gnus-article-highlight-signature)
6993 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6994 "z" gnus-article-date-ut
6995 "u" gnus-article-date-ut
6996 "l" gnus-article-date-local
6997 "e" gnus-article-date-lapsed
6998 "o" gnus-article-date-original)
7000 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7002 "f" gnus-summary-fetch-faq
7003 "d" gnus-summary-describe-group
7004 "h" gnus-summary-describe-briefly
7005 "i" gnus-info-find-node)
7007 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7008 "e" gnus-summary-expire-articles
7009 "\M-\C-e" gnus-summary-expire-articles-now
7010 "\177" gnus-summary-delete-article
7011 [delete] gnus-summary-delete-article
7012 "m" gnus-summary-move-article
7013 "r" gnus-summary-respool-article
7014 "w" gnus-summary-edit-article
7015 "c" gnus-summary-copy-article
7016 "B" gnus-summary-crosspost-article
7017 "q" gnus-summary-respool-query
7018 "i" gnus-summary-import-article)
7020 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7021 "o" gnus-summary-save-article
7022 "m" gnus-summary-save-article-mail
7023 "r" gnus-summary-save-article-rmail
7024 "f" gnus-summary-save-article-file
7025 "b" gnus-summary-save-article-body-file
7026 "h" gnus-summary-save-article-folder
7027 "v" gnus-summary-save-article-vm
7028 "p" gnus-summary-pipe-output
7029 "s" gnus-soup-add-article)
7034 (defun gnus-summary-mode (&optional group)
7035 "Major mode for reading articles.
7037 All normal editing commands are switched off.
7038 \\<gnus-summary-mode-map>
7039 Each line in this buffer represents one article. To read an
7040 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7041 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7044 You can also post articles and send mail from this buffer. To
7045 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7046 of an article, type `\\[gnus-summary-reply]'.
7048 There are approx. one gazillion commands you can execute in this
7049 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7051 The following commands are available:
7053 \\{gnus-summary-mode-map}"
7055 (when (and menu-bar-mode
7056 (gnus-visual-p 'summary-menu 'menu))
7057 (gnus-summary-make-menu-bar))
7058 (kill-all-local-variables)
7059 (let ((locals gnus-summary-local-variables))
7061 (if (consp (car locals))
7063 (make-local-variable (caar locals))
7064 (set (caar locals) (eval (cdar locals))))
7065 (make-local-variable (car locals))
7066 (set (car locals) nil))
7067 (setq locals (cdr locals))))
7068 (gnus-make-thread-indent-array)
7069 (gnus-simplify-mode-line)
7070 (setq major-mode 'gnus-summary-mode)
7071 (setq mode-name "Summary")
7072 (make-local-variable 'minor-mode-alist)
7073 (use-local-map gnus-summary-mode-map)
7074 (buffer-disable-undo (current-buffer))
7075 (setq buffer-read-only t) ;Disable modification
7076 (setq truncate-lines t)
7077 (setq selective-display t)
7078 (setq selective-display-ellipses t) ;Display `...'
7079 (setq buffer-display-table gnus-summary-display-table)
7080 (setq gnus-newsgroup-name group)
7081 (make-local-variable 'gnus-summary-line-format)
7082 (make-local-variable 'gnus-summary-line-format-spec)
7083 (make-local-variable 'gnus-summary-mark-positions)
7084 (run-hooks 'gnus-summary-mode-hook))
7086 (defun gnus-summary-make-display-table ()
7087 ;; Change the display table. Odd characters have a tendency to mess
7088 ;; up nicely formatted displays - we make all possible glyphs
7089 ;; display only a single character.
7091 ;; We start from the standard display table, if any.
7092 (setq gnus-summary-display-table
7093 (or (copy-sequence standard-display-table)
7094 (make-display-table)))
7095 ;; Nix out all the control chars...
7097 (while (>= (setq i (1- i)) 0)
7098 (aset gnus-summary-display-table i [??])))
7099 ;; ... but not newline and cr, of course. (cr is necessary for the
7100 ;; selective display).
7101 (aset gnus-summary-display-table ?\n nil)
7102 (aset gnus-summary-display-table ?\r nil)
7103 ;; We nix out any glyphs over 126 that are not set already.
7105 (while (>= (setq i (1- i)) 127)
7106 ;; Only modify if the entry is nil.
7107 (or (aref gnus-summary-display-table i)
7108 (aset gnus-summary-display-table i [??])))))
7110 (defun gnus-summary-clear-local-variables ()
7111 (let ((locals gnus-summary-local-variables))
7113 (if (consp (car locals))
7114 (and (vectorp (caar locals))
7115 (set (caar locals) nil))
7116 (and (vectorp (car locals))
7117 (set (car locals) nil)))
7118 (setq locals (cdr locals)))))
7120 ;; Summary data functions.
7122 (defmacro gnus-data-number (data)
7125 (defmacro gnus-data-set-number (data number)
7126 `(setcar ,data ,number))
7128 (defmacro gnus-data-mark (data)
7131 (defmacro gnus-data-set-mark (data mark)
7132 `(setcar (nthcdr 1 ,data) ,mark))
7134 (defmacro gnus-data-pos (data)
7137 (defmacro gnus-data-set-pos (data pos)
7138 `(setcar (nthcdr 2 ,data) ,pos))
7140 (defmacro gnus-data-header (data)
7143 (defmacro gnus-data-level (data)
7146 (defmacro gnus-data-unread-p (data)
7147 `(= (nth 1 ,data) gnus-unread-mark))
7149 (defmacro gnus-data-pseudo-p (data)
7150 `(consp (nth 3 ,data)))
7152 (defmacro gnus-data-find (number)
7153 `(assq ,number gnus-newsgroup-data))
7155 (defmacro gnus-data-find-list (number &optional data)
7156 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7157 (memq (assq ,number bdata)
7160 (defmacro gnus-data-make (number mark pos header level)
7161 `(list ,number ,mark ,pos ,header ,level))
7163 (defun gnus-data-enter (after-article number mark pos header level offset)
7164 (let ((data (gnus-data-find-list after-article)))
7165 (or data (error "No such article: %d" after-article))
7166 (setcdr data (cons (gnus-data-make number mark pos header level)
7168 (setq gnus-newsgroup-data-reverse nil)
7169 (gnus-data-update-list (cddr data) offset)))
7171 (defun gnus-data-enter-list (after-article list &optional offset)
7173 (let ((data (and after-article (gnus-data-find-list after-article)))
7175 (or data (not after-article) (error "No such article: %d" after-article))
7176 ;; Find the last element in the list to be spliced into the main
7179 (setq list (cdr list)))
7182 (setcdr list gnus-newsgroup-data)
7183 (setq gnus-newsgroup-data ilist)
7184 (and offset (gnus-data-update-list (cdr list) offset)))
7185 (setcdr list (cdr data))
7187 (and offset (gnus-data-update-list (cdr data) offset)))
7188 (setq gnus-newsgroup-data-reverse nil))))
7190 (defun gnus-data-remove (article &optional offset)
7191 (let ((data gnus-newsgroup-data))
7192 (if (= (gnus-data-number (car data)) article)
7193 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7194 gnus-newsgroup-data-reverse nil)
7196 (and (= (gnus-data-number (cadr data)) article)
7198 (setcdr data (cddr data))
7199 (and offset (gnus-data-update-list (cdr data) offset))
7201 gnus-newsgroup-data-reverse nil)))
7202 (setq data (cdr data))))))
7204 (defmacro gnus-data-list (backward)
7206 (or gnus-newsgroup-data-reverse
7207 (setq gnus-newsgroup-data-reverse
7208 (reverse gnus-newsgroup-data)))
7209 gnus-newsgroup-data))
7211 (defun gnus-data-update-list (data offset)
7212 "Add OFFSET to the POS of all data entries in DATA."
7214 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7215 (setq data (cdr data))))
7217 (defun gnus-data-compute-positions ()
7218 "Compute the positions of all articles."
7219 (let ((data gnus-newsgroup-data)
7222 (when (setq pos (text-property-any
7223 (point-min) (point-max)
7224 'gnus-number (gnus-data-number (car data))))
7225 (gnus-data-set-pos (car data) (+ pos 3)))
7226 (setq data (cdr data)))))
7228 (defun gnus-summary-article-pseudo-p (article)
7229 "Say whether this article is a pseudo article or not."
7230 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7232 (defun gnus-article-parent-p (number)
7233 "Say whether this article is a parent or not."
7234 (let ((data (gnus-data-find-list number)))
7235 (and (cdr data) ; There has to be an article after...
7236 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7237 (gnus-data-level (nth 1 data))))))
7239 (defun gnus-article-children (number)
7240 "Return a list of all children to NUMBER."
7241 (let* ((data (gnus-data-find-list number))
7242 (level (gnus-data-level (car data)))
7244 (setq data (cdr data))
7246 (= (gnus-data-level (car data)) (1+ level)))
7247 (push (gnus-data-number (car data)) children)
7248 (setq data (cdr data)))
7251 (defmacro gnus-summary-skip-intangible ()
7252 "If the current article is intangible, then jump to a different article."
7253 '(let ((to (get-text-property (point) 'gnus-intangible)))
7254 (and to (gnus-summary-goto-subject to))))
7256 (defmacro gnus-summary-article-intangible-p ()
7257 "Say whether this article is intangible or not."
7258 '(get-text-property (point) 'gnus-intangible))
7260 ;; Some summary mode macros.
7262 (defmacro gnus-summary-article-number ()
7263 "The article number of the article on the current line.
7264 If there isn's an article number here, then we return the current
7267 (gnus-summary-skip-intangible)
7268 (or (get-text-property (point) 'gnus-number)
7269 (gnus-summary-last-subject))))
7271 (defmacro gnus-summary-article-header (&optional number)
7272 `(gnus-data-header (gnus-data-find
7273 ,(or number '(gnus-summary-article-number)))))
7275 (defmacro gnus-summary-thread-level (&optional number)
7276 `(if (and (eq gnus-summary-make-false-root 'dummy)
7277 (get-text-property (point) 'gnus-intangible))
7279 (gnus-data-level (gnus-data-find
7280 ,(or number '(gnus-summary-article-number))))))
7282 (defmacro gnus-summary-article-mark (&optional number)
7283 `(gnus-data-mark (gnus-data-find
7284 ,(or number '(gnus-summary-article-number)))))
7286 (defmacro gnus-summary-article-pos (&optional number)
7287 `(gnus-data-pos (gnus-data-find
7288 ,(or number '(gnus-summary-article-number)))))
7290 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7291 (defmacro gnus-summary-article-subject (&optional number)
7292 "Return current subject string or nil if nothing."
7295 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7296 '(gnus-data-header (assq (gnus-summary-article-number)
7297 gnus-newsgroup-data)))))
7300 (mail-header-subject headers))))
7302 (defmacro gnus-summary-article-score (&optional number)
7303 "Return current article score."
7304 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7305 gnus-newsgroup-scored))
7306 gnus-summary-default-score 0))
7308 (defun gnus-summary-article-children (&optional number)
7309 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7310 (level (gnus-data-level (car data)))
7312 (while (and (setq data (cdr data))
7313 (> (setq l (gnus-data-level (car data))) level))
7314 (and (= (1+ level) l)
7315 (setq children (cons (gnus-data-number (car data))
7317 (nreverse children)))
7319 (defun gnus-summary-article-parent (&optional number)
7320 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7321 (gnus-data-list t)))
7322 (level (gnus-data-level (car data))))
7324 () ; This is a root.
7325 ;; We search until we find an article with a level less than
7326 ;; this one. That function has to be the parent.
7327 (while (and (setq data (cdr data))
7328 (not (< (gnus-data-level (car data)) level))))
7329 (and data (gnus-data-number (car data))))))
7331 (defun gnus-unread-mark-p (mark)
7332 "Say whether MARK is the unread mark."
7333 (= mark gnus-unread-mark))
7335 (defun gnus-read-mark-p (mark)
7336 "Say whether MARK is one of the marks that mark as read.
7337 This is all marks except unread, ticked, dormant, and expirable."
7338 (not (or (= mark gnus-unread-mark)
7339 (= mark gnus-ticked-mark)
7340 (= mark gnus-dormant-mark)
7341 (= mark gnus-expirable-mark))))
7343 ;; Various summary mode internalish functions.
7345 (defun gnus-mouse-pick-article (e)
7348 (gnus-summary-next-page nil t))
7350 (defun gnus-summary-setup-buffer (group)
7351 "Initialize summary buffer."
7352 (let ((buffer (concat "*Summary " group "*")))
7353 (if (get-buffer buffer)
7356 (setq gnus-summary-buffer (current-buffer))
7357 (not gnus-newsgroup-prepared))
7358 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7359 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7360 (gnus-add-current-to-buffer-list)
7361 (gnus-summary-mode group)
7363 (gnus-carpal-setup-buffer 'summary))
7364 (unless gnus-single-article-buffer
7365 (make-local-variable 'gnus-article-buffer)
7366 (make-local-variable 'gnus-article-current)
7367 (make-local-variable 'gnus-original-article-buffer))
7368 (setq gnus-newsgroup-name group)
7371 (defun gnus-set-global-variables ()
7372 ;; Set the global equivalents of the summary buffer-local variables
7373 ;; to the latest values they had. These reflect the summary buffer
7374 ;; that was in action when the last article was fetched.
7375 (when (eq major-mode 'gnus-summary-mode)
7376 (setq gnus-summary-buffer (current-buffer))
7377 (let ((name gnus-newsgroup-name)
7378 (marked gnus-newsgroup-marked)
7379 (unread gnus-newsgroup-unreads)
7380 (headers gnus-current-headers)
7381 (data gnus-newsgroup-data)
7382 (summary gnus-summary-buffer)
7383 (article-buffer gnus-article-buffer)
7384 (original gnus-original-article-buffer)
7385 (gac gnus-article-current)
7386 (score-file gnus-current-score-file))
7388 (set-buffer gnus-group-buffer)
7389 (setq gnus-newsgroup-name name)
7390 (setq gnus-newsgroup-marked marked)
7391 (setq gnus-newsgroup-unreads unread)
7392 (setq gnus-current-headers headers)
7393 (setq gnus-newsgroup-data data)
7394 (setq gnus-article-current gac)
7395 (setq gnus-summary-buffer summary)
7396 (setq gnus-article-buffer article-buffer)
7397 (setq gnus-original-article-buffer original)
7398 (setq gnus-current-score-file score-file)))))
7400 (defun gnus-summary-last-article-p (&optional article)
7401 "Return whether ARTICLE is the last article in the buffer."
7402 (if (not (setq article (or article (gnus-summary-article-number))))
7403 t ; All non-existant numbers are the last article. :-)
7404 (not (cdr (gnus-data-find-list article)))))
7406 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7407 "Insert a dummy root in the summary buffer."
7409 (add-text-properties
7410 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7411 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7413 (defun gnus-make-thread-indent-array ()
7415 (unless (and gnus-thread-indent-array
7416 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7417 (setq gnus-thread-indent-array (make-vector 201 "")
7418 gnus-thread-indent-array-level gnus-thread-indent-level)
7420 (aset gnus-thread-indent-array n
7421 (make-string (* n gnus-thread-indent-level) ? ))
7424 (defun gnus-summary-insert-line
7425 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7426 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7427 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7428 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7429 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7430 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7431 (gnus-tmp-score-char
7432 (if (or (null gnus-summary-default-score)
7433 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7434 gnus-summary-zcore-fuzz)) ?
7435 (if (< gnus-tmp-score gnus-summary-default-score)
7436 gnus-score-below-mark gnus-score-over-mark)))
7437 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7438 ((memq gnus-tmp-current gnus-newsgroup-cached)
7440 (gnus-tmp-replied gnus-replied-mark)
7441 ((memq gnus-tmp-current gnus-newsgroup-saved)
7443 (t gnus-unread-mark)))
7444 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7447 ((string-match "(.+)" gnus-tmp-from)
7448 (substring gnus-tmp-from
7449 (1+ (match-beginning 0)) (1- (match-end 0))))
7450 ((string-match "<[^>]+> *$" gnus-tmp-from)
7451 (let ((beg (match-beginning 0)))
7452 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7453 (substring gnus-tmp-from (1+ (match-beginning 0))
7454 (1- (match-end 0))))
7455 (substring gnus-tmp-from 0 beg))))
7457 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7458 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7459 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7460 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7461 (buffer-read-only nil))
7462 (when (string= gnus-tmp-name "")
7463 (setq gnus-tmp-name gnus-tmp-from))
7464 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7467 (progn (eval gnus-summary-line-format-spec) (point))
7468 'gnus-number gnus-tmp-number)
7469 (when (gnus-visual-p 'summary-highlight 'highlight)
7471 (run-hooks 'gnus-summary-update-hook)
7474 (defun gnus-summary-update-line (&optional dont-update)
7475 ;; Update summary line after change.
7476 (when (and gnus-summary-default-score
7477 (not gnus-summary-inhibit-highlight))
7478 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7479 (article (gnus-summary-article-number))
7480 (score (gnus-summary-article-score article)))
7482 (if (and gnus-summary-mark-below
7483 (< (gnus-summary-article-score)
7484 gnus-summary-mark-below))
7485 ;; This article has a low score, so we mark it as read.
7486 (when (memq article gnus-newsgroup-unreads)
7487 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7488 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7489 ;; This article was previously marked as read on account
7490 ;; of a low score, but now it has risen, so we mark it as
7492 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7493 (gnus-summary-update-mark
7494 (if (or (null gnus-summary-default-score)
7495 (<= (abs (- score gnus-summary-default-score))
7496 gnus-summary-zcore-fuzz)) ?
7497 (if (< score gnus-summary-default-score)
7498 gnus-score-below-mark gnus-score-over-mark)) 'score))
7499 ;; Do visual highlighting.
7500 (when (gnus-visual-p 'summary-highlight 'highlight)
7501 (run-hooks 'gnus-summary-update-hook)))))
7503 (defvar gnus-tmp-new-adopts nil)
7505 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7506 ;; Sum up all elements (and sub-elements) in a list.
7508 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7510 ((and (consp thread) (cdr thread))
7513 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7516 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7519 (when (and level (zerop level) gnus-tmp-new-adopts)
7522 'gnus-summary-number-of-articles-in-thread
7523 gnus-tmp-new-adopts))))
7525 (if (> number 1) gnus-not-empty-thread-mark
7526 gnus-empty-thread-mark)
7529 (defun gnus-summary-set-local-parameters (group)
7530 "Go through the local params of GROUP and set all variable specs in that list."
7531 (let ((params (gnus-info-params (gnus-get-info group)))
7534 (setq elem (car params)
7535 params (cdr params))
7536 (and (consp elem) ; Has to be a cons.
7537 (consp (cdr elem)) ; The cdr has to be a list.
7538 (symbolp (car elem)) ; Has to be a symbol in there.
7539 (not (memq (car elem)
7540 '(quit-config to-address to-list to-group)))
7541 (progn ; So we set it.
7542 (make-local-variable (car elem))
7543 (set (car elem) (eval (nth 1 elem))))))))
7545 (defun gnus-summary-read-group (group &optional show-all no-article
7546 kill-buffer no-display)
7547 "Start reading news in newsgroup GROUP.
7548 If SHOW-ALL is non-nil, already read articles are also listed.
7549 If NO-ARTICLE is non-nil, no article is selected initially.
7550 If NO-DISPLAY, don't generate a summary buffer."
7551 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7552 (let* ((new-group (gnus-summary-setup-buffer group))
7553 (quit-config (gnus-group-quit-config group))
7554 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7556 ;; This summary buffer exists already, so we just select it.
7558 (gnus-set-global-variables)
7560 (gnus-kill-or-deaden-summary kill-buffer))
7561 (gnus-configure-windows 'summary 'force)
7562 (gnus-set-mode-line 'summary)
7563 (gnus-summary-position-point)
7566 ;; We couldn't select this group.
7568 (when (and (eq major-mode 'gnus-summary-mode)
7569 (not (equal (current-buffer) kill-buffer)))
7570 (kill-buffer (current-buffer))
7571 (if (not quit-config)
7573 (set-buffer gnus-group-buffer)
7574 (gnus-group-jump-to-group group)
7575 (gnus-group-next-unread-group 1))
7576 (if (not (buffer-name (car quit-config)))
7577 (gnus-configure-windows 'group 'force)
7578 (set-buffer (car quit-config))
7579 (and (eq major-mode 'gnus-summary-mode)
7580 (gnus-set-global-variables))
7581 (gnus-configure-windows (cdr quit-config)))))
7582 (gnus-message 3 "Can't select group")
7584 ;; The user did a `C-g' while prompting for number of articles,
7585 ;; so we exit this group.
7586 ((eq did-select 'quit)
7587 (and (eq major-mode 'gnus-summary-mode)
7588 (not (equal (current-buffer) kill-buffer))
7589 (kill-buffer (current-buffer)))
7591 (gnus-kill-or-deaden-summary kill-buffer))
7592 (if (not quit-config)
7594 (set-buffer gnus-group-buffer)
7595 (gnus-group-jump-to-group group)
7596 (gnus-group-next-unread-group 1)
7597 (gnus-configure-windows 'group 'force))
7598 (if (not (buffer-name (car quit-config)))
7599 (gnus-configure-windows 'group 'force)
7600 (set-buffer (car quit-config))
7601 (and (eq major-mode 'gnus-summary-mode)
7602 (gnus-set-global-variables))
7603 (gnus-configure-windows (cdr quit-config))))
7604 ;; Finally signal the quit.
7606 ;; The group was successfully selected.
7608 (gnus-set-global-variables)
7609 ;; Save the active value in effect when the group was entered.
7610 (setq gnus-newsgroup-active
7612 (gnus-active gnus-newsgroup-name)))
7613 ;; You can change the summary buffer in some way with this hook.
7614 (run-hooks 'gnus-select-group-hook)
7615 ;; Set any local variables in the group parameters.
7616 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7617 (gnus-update-format-specifications)
7618 ;; Do score processing.
7619 (when gnus-use-scoring
7620 (gnus-possibly-score-headers))
7621 ;; Check whether to fill in the gaps in the threads.
7622 (when gnus-build-sparse-threads
7623 (gnus-build-sparse-threads))
7624 ;; Find the initial limit.
7625 (if gnus-show-threads
7627 (let ((gnus-newsgroup-dormant nil))
7628 (gnus-summary-initial-limit show-all))
7629 (gnus-summary-initial-limit show-all))
7630 (setq gnus-newsgroup-limit
7632 (lambda (header) (mail-header-number header))
7633 gnus-newsgroup-headers)))
7634 ;; Generate the summary buffer.
7636 (gnus-summary-prepare))
7637 (when gnus-use-trees
7638 (gnus-tree-open group)
7639 (setq gnus-summary-highlight-line-function
7640 'gnus-tree-highlight-article))
7641 ;; If the summary buffer is empty, but there are some low-scored
7642 ;; articles or some excluded dormants, we include these in the
7644 (when (and (zerop (buffer-size))
7646 (cond (gnus-newsgroup-dormant
7647 (gnus-summary-limit-include-dormant))
7648 ((and gnus-newsgroup-scored show-all)
7649 (gnus-summary-limit-include-expunged))))
7650 ;; Function `gnus-apply-kill-file' must be called in this hook.
7651 (run-hooks 'gnus-apply-kill-hook)
7652 (if (and (zerop (buffer-size))
7655 ;; This newsgroup is empty.
7656 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7657 (gnus-message 6 "No unread news")
7659 (gnus-kill-or-deaden-summary kill-buffer))
7660 ;; Return nil from this function.
7662 ;; Hide conversation thread subtrees. We cannot do this in
7663 ;; gnus-summary-prepare-hook since kill processing may not
7664 ;; work with hidden articles.
7665 (and gnus-show-threads
7666 gnus-thread-hide-subtree
7667 (gnus-summary-hide-all-threads))
7668 ;; Show first unread article if requested.
7669 (if (and (not no-article)
7671 gnus-newsgroup-unreads
7672 gnus-auto-select-first)
7673 (unless (if (eq gnus-auto-select-first 'best)
7674 (gnus-summary-best-unread-article)
7675 (gnus-summary-first-unread-article))
7676 (gnus-configure-windows 'summary))
7677 ;; Don't select any articles, just move point to the first
7678 ;; article in the group.
7679 (goto-char (point-min))
7680 (gnus-summary-position-point)
7681 (gnus-set-mode-line 'summary)
7682 (gnus-configure-windows 'summary 'force))
7683 ;; If we are in async mode, we send some info to the backend.
7684 (when gnus-newsgroup-async
7685 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7687 (gnus-kill-or-deaden-summary kill-buffer))
7688 (when (get-buffer-window gnus-group-buffer t)
7689 ;; Gotta use windows, because recenter does wierd stuff if
7690 ;; the current buffer ain't the displayed window.
7691 (let ((owin (selected-window)))
7692 (select-window (get-buffer-window gnus-group-buffer t))
7693 (when (gnus-group-goto-group group)
7695 (select-window owin))))
7696 ;; Mark this buffer as "prepared".
7697 (setq gnus-newsgroup-prepared t)
7700 (defun gnus-summary-prepare ()
7701 "Generate the summary buffer."
7702 (let ((buffer-read-only nil))
7704 (setq gnus-newsgroup-data nil
7705 gnus-newsgroup-data-reverse nil)
7706 (run-hooks 'gnus-summary-generate-hook)
7707 ;; Generate the buffer, either with threads or without.
7708 (when gnus-newsgroup-headers
7709 (gnus-summary-prepare-threads
7710 (if gnus-show-threads
7711 (gnus-sort-gathered-threads
7712 (funcall gnus-summary-thread-gathering-function
7714 (gnus-cut-threads (gnus-make-threads)))))
7715 ;; Unthreaded display.
7716 (gnus-sort-articles gnus-newsgroup-headers))))
7717 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7718 ;; Call hooks for modifying summary buffer.
7719 (goto-char (point-min))
7720 (run-hooks 'gnus-summary-prepare-hook)))
7722 (defun gnus-gather-threads-by-subject (threads)
7723 "Gather threads by looking at Subject headers."
7724 (if (not gnus-summary-make-false-root)
7726 (let ((hashtb (gnus-make-hashtable 1023))
7729 subject hthread whole-subject)
7731 (setq whole-subject (mail-header-subject (caar threads)))
7734 ;; Truncate the subject.
7735 ((numberp gnus-summary-gather-subject-limit)
7736 (setq subject (gnus-simplify-subject-re whole-subject))
7737 (if (> (length subject) gnus-summary-gather-subject-limit)
7738 (substring subject 0 gnus-summary-gather-subject-limit)
7740 ;; Fuzzily simplify it.
7741 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7742 (gnus-simplify-subject-fuzzy whole-subject))
7743 ;; Just remove the leading "Re:".
7745 (gnus-simplify-subject-re whole-subject))))
7747 (if (and gnus-summary-gather-exclude-subject
7748 (string-match gnus-summary-gather-exclude-subject
7750 () ; We don't want to do anything with this article.
7751 ;; We simplify the subject before looking it up in the
7754 (if (setq hthread (gnus-gethash subject hashtb))
7756 ;; We enter a dummy root into the thread, if we
7757 ;; haven't done that already.
7758 (unless (stringp (caar hthread))
7759 (setcar hthread (list whole-subject (car hthread))))
7760 ;; We add this new gathered thread to this gathered
7762 (setcdr (car hthread)
7763 (nconc (cdar hthread) (list (car threads))))
7764 ;; Remove it from the list of threads.
7765 (setcdr prev (cdr threads))
7766 (setq threads prev))
7767 ;; Enter this thread into the hash table.
7768 (gnus-sethash subject threads hashtb)))
7770 (setq threads (cdr threads)))
7773 (defun gnus-gather-threads-by-references (threads)
7774 "Gather threads by looking at References headers."
7775 (let ((idhashtb (gnus-make-hashtable 1023))
7776 (thhashtb (gnus-make-hashtable 1023))
7779 ids references id gthread gid entered)
7781 (when (setq references (mail-header-references (caar threads)))
7782 (setq id (mail-header-id (caar threads)))
7783 (setq ids (gnus-split-references references))
7786 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7788 (gnus-sethash (car ids) id idhashtb)
7789 (gnus-sethash id threads thhashtb))
7790 (setq gthread (gnus-gethash gid thhashtb))
7792 ;; We enter a dummy root into the thread, if we
7793 ;; haven't done that already.
7794 (unless (stringp (caar gthread))
7795 (setcar gthread (list (mail-header-subject (caar gthread))
7797 ;; We add this new gathered thread to this gathered
7799 (setcdr (car gthread)
7800 (nconc (cdar gthread) (list (car threads)))))
7801 ;; Add it into the thread hash table.
7802 (gnus-sethash id gthread thhashtb)
7804 ;; Remove it from the list of threads.
7805 (setcdr prev (cdr threads))
7806 (setq threads prev))
7807 (setq ids (cdr ids))))
7809 (setq threads (cdr threads)))
7812 (defun gnus-sort-gathered-threads (threads)
7813 "Sort subtreads inside each gathered thread by article number."
7814 (let ((result threads))
7816 (when (stringp (caar threads))
7817 (setcdr (car threads)
7818 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7819 (setq threads (cdr threads)))
7822 (defun gnus-make-threads ()
7823 "Go through the dependency hashtb and find the roots. Return all threads."
7827 (unless (car (symbol-value refs))
7828 ;; These threads do not refer back to any other articles,
7829 ;; so they're roots.
7830 (setq threads (append (cdr (symbol-value refs)) threads))))
7831 gnus-newsgroup-dependencies)
7834 (defun gnus-build-sparse-threads ()
7835 (let ((headers gnus-newsgroup-headers)
7836 (deps gnus-newsgroup-dependencies)
7837 header references generation relations
7838 cthread subject child end pthread relation)
7839 ;; First we create an alist of generations/relations, where
7840 ;; generations is how much we trust the ralation, and the relation
7842 (gnus-message 7 "Making sparse threads...")
7844 (nnheader-set-temp-buffer " *gnus sparse threads*")
7845 (while (setq header (pop headers))
7846 (when (and (setq references (mail-header-references header))
7847 (not (string= references "")))
7849 (setq child (mail-header-id header)
7850 subject (mail-header-subject header))
7852 (while (search-backward ">" nil t)
7853 (setq end (1+ (point)))
7854 (when (search-backward "<" nil t)
7855 (push (list (incf generation)
7856 child (setq child (buffer-substring (point) end))
7859 (push (list (1+ generation) child nil subject) relations)
7861 (kill-buffer (current-buffer)))
7862 ;; Sort over trustworthiness.
7863 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7864 (while (setq relation (pop relations))
7865 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7866 (unless (car (symbol-value cthread))
7867 ;; Make this article the parent of these threads.
7868 (setcar (symbol-value cthread)
7869 (vector gnus-reffed-article-number
7873 (or (caddr relation) "") 0 0 "")))
7874 (set cthread (list (vector gnus-reffed-article-number
7876 "" "" (cadr relation)
7877 (or (caddr relation) "") 0 0 ""))))
7878 (push gnus-reffed-article-number gnus-newsgroup-limit)
7879 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7880 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7881 gnus-newsgroup-reads)
7882 (decf gnus-reffed-article-number)
7883 ;; Make this new thread the child of its parent.
7884 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7885 (setcdr (symbol-value pthread)
7886 (nconc (cdr (symbol-value pthread))
7887 (list (symbol-value cthread))))
7888 (set pthread (list nil (symbol-value cthread))))))
7889 (gnus-message 7 "Making sparse threads...done")))
7891 (defun gnus-build-old-threads ()
7892 ;; Look at all the articles that refer back to old articles, and
7893 ;; fetch the headers for the articles that aren't there. This will
7894 ;; build complete threads - if the roots haven't been expired by the
7899 (when (not (car (symbol-value refs)))
7900 (setq heads (cdr (symbol-value refs)))
7902 (if (memq (mail-header-number (caar heads))
7903 gnus-newsgroup-dormant)
7904 (setq heads (cdr heads))
7905 (setq id (symbol-name refs))
7906 (while (and (setq id (gnus-build-get-header id))
7907 (not (car (gnus-gethash
7908 id gnus-newsgroup-dependencies)))))
7909 (setq heads nil)))))
7910 gnus-newsgroup-dependencies)))
7912 (defun gnus-build-get-header (id)
7913 ;; Look through the buffer of NOV lines and find the header to
7914 ;; ID. Enter this line into the dependencies hash table, and return
7915 ;; the id of the parent article (if any).
7916 (let ((deps gnus-newsgroup-dependencies)
7920 (set-buffer nntp-server-buffer)
7921 (goto-char (point-min))
7922 (while (and (not found) (search-forward id nil t))
7924 (setq found (looking-at
7925 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7926 (regexp-quote id))))
7927 (or found (beginning-of-line 2)))
7931 (setq header (gnus-nov-parse-line
7932 (read (current-buffer)) deps))
7933 (gnus-parent-id (mail-header-references header)))))
7935 (let ((number (mail-header-number header)))
7936 (push number gnus-newsgroup-limit)
7937 (push header gnus-newsgroup-headers)
7938 (if (memq number gnus-newsgroup-unselected)
7940 (push number gnus-newsgroup-unreads)
7941 (setq gnus-newsgroup-unselected
7942 (delq number gnus-newsgroup-unselected)))
7943 (push number gnus-newsgroup-ancient)))))))
7945 (defun gnus-summary-update-article (article &optional header)
7946 "Update ARTICLE in the summary buffer."
7947 (set-buffer gnus-summary-buffer)
7948 (let* ((header (or header (gnus-summary-article-header article)))
7949 (id (mail-header-id header))
7950 (data (gnus-data-find article))
7951 (thread (gnus-id-to-thread id))
7953 (gnus-id-to-thread (or (gnus-parent-id
7954 (mail-header-references header))
7956 (buffer-read-only nil)
7958 (number (mail-header-number header))
7963 (delq thread parent))
7964 (if (gnus-summary-insert-subject id header)
7965 ;; Set the (possibly) new article number in the data structure.
7966 (gnus-data-set-number data (gnus-id-to-article id))
7970 (defun gnus-rebuild-thread (id)
7971 "Rebuild the thread containing ID."
7972 (let ((buffer-read-only nil)
7973 current thread data)
7974 (if (not gnus-show-threads)
7975 (setq thread (list (car (gnus-id-to-thread id))))
7976 ;; Get the thread this article is part of.
7977 (setq thread (gnus-remove-thread id)))
7978 (setq current (save-excursion
7979 (and (zerop (forward-line -1))
7980 (gnus-summary-article-number))))
7981 ;; If this is a gathered thread, we have to go some re-gathering.
7982 (when (stringp (car thread))
7983 (let ((subject (car thread))
7985 (setq thread (cdr thread))
7987 (unless (memq (setq thr (gnus-id-to-thread
7989 (mail-header-id (caar thread)))))
7992 (setq thread (cdr thread)))
7993 ;; We now have all (unique) roots.
7994 (if (= (length roots) 1)
7995 ;; All the loose roots are now one solid root.
7996 (setq thread (car roots))
7997 (setq thread (cons subject (gnus-sort-threads roots))))))
7999 ;; We then insert this thread into the summary buffer.
8000 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8001 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8002 (setq data (nreverse gnus-newsgroup-data))
8003 (setq threads gnus-newsgroup-threads))
8004 ;; We splice the new data into the data structure.
8005 (gnus-data-enter-list current data)
8006 (gnus-data-compute-positions)
8007 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8009 (defun gnus-id-to-thread (id)
8010 "Return the (sub-)thread where ID appears."
8011 (gnus-gethash id gnus-newsgroup-dependencies))
8013 (defun gnus-id-to-article (id)
8014 "Return the article number of ID."
8015 (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))
8027 (refs (mail-header-references (gnus-summary-article-header article)))
8033 ((null(gnus-parent-id refs)) t)
8035 (null (setq particle (gnus-id-to-article
8036 (gnus-parent-id refs))))
8037 (null (gnus-summary-thread-level particle)))))))
8039 (defun gnus-root-id (id)
8040 "Return the id of the root of the thread where ID appears."
8042 (while (and id (setq prev (car (gnus-gethash
8043 id gnus-newsgroup-dependencies))))
8045 id (gnus-parent-id (mail-header-references prev))))
8048 (defun gnus-remove-thread (id &optional dont-remove)
8049 "Remove the thread that has ID in it."
8050 (let ((dep gnus-newsgroup-dependencies)
8051 headers thread last-id)
8052 ;; First go up in this thread until we find the root.
8053 (setq last-id (gnus-root-id id))
8054 (setq headers (list (car (gnus-id-to-thread last-id))
8055 (caadr (gnus-id-to-thread last-id))))
8056 ;; We have now found the real root of this thread. It might have
8057 ;; been gathered into some loose thread, so we have to search
8058 ;; through the threads to find the thread we wanted.
8059 (let ((threads gnus-newsgroup-threads)
8062 (setq sub (car threads))
8063 (if (stringp (car sub))
8064 ;; This is a gathered threads, so we look at the roots
8065 ;; below it to find whether this article in in this
8068 (setq sub (cdr sub))
8070 (when (member (caar sub) headers)
8071 (setq thread (car threads)
8074 (setq sub (cdr sub))))
8075 ;; It's an ordinary thread, so we check it.
8076 (when (eq (car sub) (car headers))
8079 (setq threads (cdr threads)))
8080 ;; If this article is in no thread, then it's a root.
8083 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8084 (setq thread (gnus-gethash last-id dep)))
8087 thread ; We return this thread.
8089 (if (stringp (car thread))
8091 ;; If we use dummy roots, then we have to remove the
8092 ;; dummy root as well.
8093 (when (eq gnus-summary-make-false-root 'dummy)
8096 (setq thread (cdr thread))
8098 (gnus-remove-thread-1 (car thread))
8099 (setq thread (cdr thread))))
8100 (gnus-remove-thread-1 thread))))))))
8102 (defun gnus-remove-thread-1 (thread)
8103 "Remove the thread THREAD recursively."
8104 (let ((number (mail-header-number (car thread)))
8106 (when (setq pos (text-property-any
8107 (point-min) (point-max) 'gnus-number number))
8110 (gnus-data-remove number))
8111 (setq thread (cdr thread))
8113 (gnus-remove-thread-1 (pop thread)))))
8115 (defun gnus-sort-threads (threads)
8117 (if (not gnus-thread-sort-functions)
8119 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8120 (car gnus-thread-sort-functions)
8122 ,(gnus-make-sort-function
8123 (reverse gnus-thread-sort-functions))))))
8124 (gnus-message 7 "Sorting threads...")
8127 (gnus-message 7 "Sorting threads...done")))))
8129 (defun gnus-sort-articles (articles)
8131 (when gnus-article-sort-functions
8132 (let ((func (if (= 1 (length gnus-article-sort-functions))
8133 (car gnus-article-sort-functions)
8135 ,(gnus-make-sort-function
8136 (reverse gnus-article-sort-functions))))))
8137 (gnus-message 7 "Sorting articles...")
8139 (setq gnus-newsgroup-headers (sort articles func))
8140 (gnus-message 7 "Sorting articles...done")))))
8142 (defun gnus-make-sort-function (funs)
8143 "Return a composite sort condition based on the functions in FUNC."
8145 `(or (,(car funs) t1 t2)
8146 (and (not (,(car funs) t2 t1))
8147 ,(gnus-make-sort-function (cdr funs))))
8148 `(,(car funs) t1 t2)))
8150 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8151 (defmacro gnus-thread-header (thread)
8152 ;; Return header of first article in THREAD.
8153 ;; Note that THREAD must never, ever be anything else than a variable -
8154 ;; using some other form will lead to serious barfage.
8155 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8156 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8157 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8160 (defsubst gnus-article-sort-by-number (h1 h2)
8161 "Sort articles by article number."
8162 (< (mail-header-number h1)
8163 (mail-header-number h2)))
8165 (defun gnus-thread-sort-by-number (h1 h2)
8166 "Sort threads by root article number."
8167 (gnus-article-sort-by-number
8168 (gnus-thread-header h1) (gnus-thread-header h2)))
8170 (defsubst gnus-article-sort-by-author (h1 h2)
8171 "Sort articles by root author."
8173 (let ((extract (funcall
8174 gnus-extract-address-components
8175 (mail-header-from h1))))
8176 (or (car extract) (cdr extract)))
8177 (let ((extract (funcall
8178 gnus-extract-address-components
8179 (mail-header-from h2))))
8180 (or (car extract) (cdr extract)))))
8182 (defun gnus-thread-sort-by-author (h1 h2)
8183 "Sort threads by root author."
8184 (gnus-article-sort-by-author
8185 (gnus-thread-header h1) (gnus-thread-header h2)))
8187 (defsubst gnus-article-sort-by-subject (h1 h2)
8188 "Sort articles by root subject."
8190 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8191 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8193 (defun gnus-thread-sort-by-subject (h1 h2)
8194 "Sort threads by root subject."
8195 (gnus-article-sort-by-subject
8196 (gnus-thread-header h1) (gnus-thread-header h2)))
8198 (defsubst gnus-article-sort-by-date (h1 h2)
8199 "Sort articles by root article date."
8201 (gnus-sortable-date (mail-header-date h1))
8202 (gnus-sortable-date (mail-header-date h2))))
8204 (defun gnus-thread-sort-by-date (h1 h2)
8205 "Sort threads by root article date."
8206 (gnus-article-sort-by-date
8207 (gnus-thread-header h1) (gnus-thread-header h2)))
8209 (defsubst gnus-article-sort-by-score (h1 h2)
8210 "Sort articles by root article score.
8211 Unscored articles will be counted as having a score of zero."
8212 (> (or (cdr (assq (mail-header-number h1)
8213 gnus-newsgroup-scored))
8214 gnus-summary-default-score 0)
8215 (or (cdr (assq (mail-header-number h2)
8216 gnus-newsgroup-scored))
8217 gnus-summary-default-score 0)))
8219 (defun gnus-thread-sort-by-score (h1 h2)
8220 "Sort threads by root article score."
8221 (gnus-article-sort-by-score
8222 (gnus-thread-header h1) (gnus-thread-header h2)))
8224 (defun gnus-thread-sort-by-total-score (h1 h2)
8225 "Sort threads by the sum of all scores in the thread.
8226 Unscored articles will be counted as having a score of zero."
8227 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8229 (defun gnus-thread-total-score (thread)
8230 ;; This function find the total score of THREAD.
8232 (if (stringp (car thread))
8233 (apply gnus-thread-score-function 0
8234 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8235 (gnus-thread-total-score-1 thread))
8236 (gnus-thread-total-score-1 (list thread))))
8238 (defun gnus-thread-total-score-1 (root)
8239 ;; This function find the total score of the thread below ROOT.
8240 (setq root (car root))
8241 (apply gnus-thread-score-function
8242 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8243 gnus-summary-default-score 0)
8244 (mapcar 'gnus-thread-total-score
8245 (cdr (gnus-gethash (mail-header-id root)
8246 gnus-newsgroup-dependencies)))))
8248 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8249 (defvar gnus-tmp-prev-subject nil)
8250 (defvar gnus-tmp-false-parent nil)
8251 (defvar gnus-tmp-root-expunged nil)
8252 (defvar gnus-tmp-dummy-line nil)
8254 (defun gnus-summary-prepare-threads (threads)
8255 "Prepare summary buffer from THREADS and indentation LEVEL.
8256 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8257 or a straight list of headers."
8258 (gnus-message 7 "Generating summary...")
8260 (setq gnus-newsgroup-threads threads)
8263 (let ((gnus-tmp-level 0)
8264 (default-score (or gnus-summary-default-score 0))
8265 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8266 thread number subject stack state gnus-tmp-gathered beg-match
8267 new-roots gnus-tmp-new-adopts thread-end
8268 gnus-tmp-header gnus-tmp-unread
8269 gnus-tmp-replied gnus-tmp-subject-or-nil
8270 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8271 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8272 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8274 (setq gnus-tmp-prev-subject nil)
8276 (if (vectorp (car threads))
8277 ;; If this is a straight (sic) list of headers, then a
8278 ;; threaded summary display isn't required, so we just create
8279 ;; an unthreaded one.
8280 (gnus-summary-prepare-unthreaded threads)
8282 ;; Do the threaded display.
8284 (while (or threads stack gnus-tmp-new-adopts new-roots)
8286 (if (and (= gnus-tmp-level 0)
8287 (not (setq gnus-tmp-dummy-line nil))
8290 (not gnus-tmp-false-parent)
8291 (or gnus-tmp-new-adopts new-roots))
8292 (if gnus-tmp-new-adopts
8293 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8294 thread (list (car gnus-tmp-new-adopts))
8295 gnus-tmp-header (caar thread)
8296 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8298 (setq thread (list (car new-roots))
8299 gnus-tmp-header (caar thread)
8300 new-roots (cdr new-roots))))
8303 ;; If there are some threads, we do them before the
8304 ;; threads on the stack.
8305 (setq thread threads
8306 gnus-tmp-header (caar thread))
8307 ;; There were no current threads, so we pop something off
8309 (setq state (car stack)
8310 gnus-tmp-level (car state)
8313 gnus-tmp-header (caar thread))))
8315 (setq gnus-tmp-false-parent nil)
8316 (setq gnus-tmp-root-expunged nil)
8317 (setq thread-end nil)
8319 (if (stringp gnus-tmp-header)
8320 ;; The header is a dummy root.
8322 ((eq gnus-summary-make-false-root 'adopt)
8323 ;; We let the first article adopt the rest.
8324 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8326 (setq gnus-tmp-gathered
8328 (lambda (h) (mail-header-number (car h)))
8331 (setq thread (cons (list (caar thread)
8334 (setq gnus-tmp-level -1
8335 gnus-tmp-false-parent t))
8336 ((eq gnus-summary-make-false-root 'empty)
8337 ;; We print adopted articles with empty subject fields.
8338 (setq gnus-tmp-gathered
8340 (lambda (h) (mail-header-number (car h)))
8343 (setq gnus-tmp-level -1))
8344 ((eq gnus-summary-make-false-root 'dummy)
8345 ;; We remember that we probably want to output a dummy
8347 (setq gnus-tmp-dummy-line gnus-tmp-header)
8348 (setq gnus-tmp-prev-subject gnus-tmp-header))
8350 ;; We do not make a root for the gathered
8351 ;; sub-threads at all.
8352 (setq gnus-tmp-level -1)))
8354 (setq number (mail-header-number gnus-tmp-header)
8355 subject (mail-header-subject gnus-tmp-header))
8358 ;; If the thread has changed subject, we might want to make
8359 ;; this subthread into a root.
8360 ((and (null gnus-thread-ignore-subject)
8361 (not (zerop gnus-tmp-level))
8362 gnus-tmp-prev-subject
8364 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8365 (setq new-roots (nconc new-roots (list (car thread)))
8367 gnus-tmp-header nil))
8368 ;; If the article lies outside the current limit,
8369 ;; then we do not display it.
8370 ((and (not (memq number gnus-newsgroup-limit))
8371 (not gnus-tmp-dummy-line))
8372 (setq gnus-tmp-gathered
8374 (lambda (h) (mail-header-number (car h)))
8377 (setq gnus-tmp-new-adopts (if (cdar thread)
8378 (append gnus-tmp-new-adopts
8380 gnus-tmp-new-adopts)
8382 gnus-tmp-header nil)
8383 (when (zerop gnus-tmp-level)
8384 (setq gnus-tmp-root-expunged t)))
8385 ;; Perhaps this article is to be marked as read?
8386 ((and gnus-summary-mark-below
8387 (< (or (cdr (assq number gnus-newsgroup-scored))
8389 gnus-summary-mark-below)
8390 ;; Don't touch sparse articles.
8391 (not (memq number gnus-newsgroup-sparse)))
8392 (setq gnus-newsgroup-unreads
8393 (delq number gnus-newsgroup-unreads))
8394 (if gnus-newsgroup-auto-expire
8395 (push number gnus-newsgroup-expirable)
8396 (push (cons number gnus-low-score-mark)
8397 gnus-newsgroup-reads))))
8399 (when gnus-tmp-header
8400 ;; We may have an old dummy line to output before this
8402 (when gnus-tmp-dummy-line
8403 (gnus-summary-insert-dummy-line
8404 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8405 (setq gnus-tmp-dummy-line nil))
8407 ;; Compute the mark.
8411 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8412 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8413 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8414 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8415 (t (or (cdr (assq number gnus-newsgroup-reads))
8416 gnus-ancient-mark))))
8418 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8419 gnus-tmp-header gnus-tmp-level)
8420 gnus-newsgroup-data)
8422 ;; Actually insert the line.
8424 gnus-tmp-subject-or-nil
8426 ((and gnus-thread-ignore-subject
8427 gnus-tmp-prev-subject
8428 (not (inline (gnus-subject-equal
8429 gnus-tmp-prev-subject subject))))
8431 ((zerop gnus-tmp-level)
8432 (if (and (eq gnus-summary-make-false-root 'empty)
8433 (memq number gnus-tmp-gathered)
8434 gnus-tmp-prev-subject
8435 (inline (gnus-subject-equal
8436 gnus-tmp-prev-subject subject)))
8437 gnus-summary-same-subject
8439 (t gnus-summary-same-subject)))
8440 (if (and (eq gnus-summary-make-false-root 'adopt)
8441 (= gnus-tmp-level 1)
8442 (memq number gnus-tmp-gathered))
8443 (setq gnus-tmp-opening-bracket ?\<
8444 gnus-tmp-closing-bracket ?\>)
8445 (setq gnus-tmp-opening-bracket ?\[
8446 gnus-tmp-closing-bracket ?\]))
8448 gnus-tmp-indentation
8449 (aref gnus-thread-indent-array gnus-tmp-level)
8450 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8451 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8452 gnus-summary-default-score 0)
8454 (if (or (null gnus-summary-default-score)
8455 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8456 gnus-summary-zcore-fuzz)) ?
8457 (if (< gnus-tmp-score gnus-summary-default-score)
8458 gnus-score-below-mark gnus-score-over-mark))
8460 (cond ((memq number gnus-newsgroup-processable)
8462 ((memq number gnus-newsgroup-cached)
8464 ((memq number gnus-newsgroup-replied)
8466 (t gnus-unread-mark))
8467 gnus-tmp-from (mail-header-from gnus-tmp-header)
8470 ((string-match "(.+)" gnus-tmp-from)
8471 (substring gnus-tmp-from
8472 (1+ (match-beginning 0)) (1- (match-end 0))))
8473 ((string-match "<[^>]+> *$" gnus-tmp-from)
8474 (setq beg-match (match-beginning 0))
8475 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8476 (substring gnus-tmp-from (1+ (match-beginning 0))
8477 (1- (match-end 0))))
8478 (substring gnus-tmp-from 0 beg-match)))
8480 (when (string= gnus-tmp-name "")
8481 (setq gnus-tmp-name gnus-tmp-from))
8482 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8485 (progn (eval gnus-summary-line-format-spec) (point))
8486 'gnus-number number)
8489 (run-hooks 'gnus-summary-update-hook)
8492 (setq gnus-tmp-prev-subject subject)))
8494 (when (nth 1 thread)
8495 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8496 (incf gnus-tmp-level)
8497 (setq threads (if thread-end nil (cdar thread)))
8499 (setq gnus-tmp-level 0)))))
8500 (gnus-message 7 "Generating summary...done"))
8502 (defun gnus-summary-prepare-unthreaded (headers)
8503 "Generate an unthreaded summary buffer based on HEADERS."
8504 (let (header number mark)
8507 ;; We may have to root out some bad articles...
8508 (when (memq (setq number (mail-header-number
8509 (setq header (pop headers))))
8510 gnus-newsgroup-limit)
8511 ;; Mark article as read when it has a low score.
8512 (when (and gnus-summary-mark-below
8513 (< (or (cdr (assq number gnus-newsgroup-scored))
8514 gnus-summary-default-score 0)
8515 gnus-summary-mark-below))
8516 (setq gnus-newsgroup-unreads
8517 (delq number gnus-newsgroup-unreads))
8518 (if gnus-newsgroup-auto-expire
8519 (push number gnus-newsgroup-expirable)
8520 (push (cons number gnus-low-score-mark)
8521 gnus-newsgroup-reads)))
8525 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8526 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8527 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8528 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8529 (t (or (cdr (assq number gnus-newsgroup-reads))
8530 gnus-ancient-mark))))
8531 (setq gnus-newsgroup-data
8532 (cons (gnus-data-make number mark (1+ (point)) header 0)
8533 gnus-newsgroup-data))
8534 (gnus-summary-insert-line
8535 header 0 nil mark (memq number gnus-newsgroup-replied)
8536 (memq number gnus-newsgroup-expirable)
8537 (mail-header-subject header) nil
8538 (cdr (assq number gnus-newsgroup-scored))
8539 (memq number gnus-newsgroup-processable))))))
8541 (defun gnus-select-newsgroup (group &optional read-all)
8542 "Select newsgroup GROUP.
8543 If READ-ALL is non-nil, all articles in the group are selected."
8544 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8545 (info (nth 2 entry))
8546 articles fetched-articles cached)
8548 (or (gnus-check-server
8549 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8550 (error "Couldn't open server"))
8552 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8553 (gnus-activate-group group) ; Or we can activate it...
8554 (progn ; Or we bug out.
8555 (when (equal major-mode 'gnus-summary-mode)
8556 (kill-buffer (current-buffer)))
8557 (error "Couldn't request group %s: %s"
8558 group (gnus-status-message group))))
8560 (setq gnus-newsgroup-name group)
8561 (setq gnus-newsgroup-unselected nil)
8562 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8564 (and gnus-asynchronous
8565 (gnus-check-backend-function
8566 'request-asynchronous gnus-newsgroup-name)
8567 (setq gnus-newsgroup-async
8568 (gnus-request-asynchronous gnus-newsgroup-name)))
8570 ;; Adjust and set lists of article marks.
8572 (gnus-adjust-marked-articles info))
8574 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8575 (when (gnus-virtual-group-p group)
8576 (setq cached gnus-newsgroup-cached))
8578 (setq gnus-newsgroup-unreads
8579 (gnus-set-difference
8580 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8581 gnus-newsgroup-dormant))
8583 (setq gnus-newsgroup-processable nil)
8585 (setq articles (gnus-articles-to-read group read-all))
8589 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8591 ((eq articles 0) nil)
8593 ;; Init the dependencies hash table.
8594 (setq gnus-newsgroup-dependencies
8595 (gnus-make-hashtable (length articles)))
8596 ;; Retrieve the headers and read them in.
8597 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8598 (setq gnus-newsgroup-headers
8600 (setq gnus-headers-retrieved-by
8601 (gnus-retrieve-headers
8602 articles gnus-newsgroup-name
8603 ;; We might want to fetch old headers, but
8604 ;; not if there is only 1 article.
8605 (and gnus-fetch-old-headers
8607 (not (eq gnus-fetch-old-headers 'some))
8608 (not (numberp gnus-fetch-old-headers)))
8609 (> (length articles) 1))))))
8610 (gnus-get-newsgroup-headers-xover articles)
8611 (gnus-get-newsgroup-headers)))
8612 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8614 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8616 (setq gnus-newsgroup-cached cached))
8618 ;; Set the initial limit.
8619 (setq gnus-newsgroup-limit (copy-sequence articles))
8620 ;; Remove canceled articles from the list of unread articles.
8621 (setq gnus-newsgroup-unreads
8622 (gnus-set-sorted-intersection
8623 gnus-newsgroup-unreads
8624 (setq fetched-articles
8625 (mapcar (lambda (headers) (mail-header-number headers))
8626 gnus-newsgroup-headers))))
8627 ;; Removed marked articles that do not exist.
8628 (gnus-update-missing-marks
8629 (gnus-sorted-complement fetched-articles articles))
8630 ;; We might want to build some more threads first.
8631 (and gnus-fetch-old-headers
8632 (eq gnus-headers-retrieved-by 'nov)
8633 (gnus-build-old-threads))
8634 ;; Check whether auto-expire is to be done in this group.
8635 (setq gnus-newsgroup-auto-expire
8636 (gnus-group-auto-expirable-p group))
8637 ;; Set up the article buffer now, if necessary.
8638 (unless gnus-single-article-buffer
8639 (gnus-article-setup-buffer))
8640 ;; First and last article in this newsgroup.
8641 (and gnus-newsgroup-headers
8642 (setq gnus-newsgroup-begin
8643 (mail-header-number (car gnus-newsgroup-headers)))
8644 (setq gnus-newsgroup-end
8646 (gnus-last-element gnus-newsgroup-headers))))
8647 (setq gnus-reffed-article-number -1)
8648 ;; GROUP is successfully selected.
8649 (or gnus-newsgroup-headers t)))))
8651 (defun gnus-articles-to-read (group read-all)
8652 ;; Find out what articles the user wants to read.
8654 ;; Select all articles if `read-all' is non-nil, or if there
8655 ;; are no unread articles.
8657 (and (zerop (length gnus-newsgroup-marked))
8658 (zerop (length gnus-newsgroup-unreads))))
8659 (gnus-uncompress-range (gnus-active group))
8660 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8661 (copy-sequence gnus-newsgroup-unreads))
8663 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8664 (scored (length scored-list))
8665 (number (length articles))
8666 (marked (+ (length gnus-newsgroup-marked)
8667 (length gnus-newsgroup-dormant)))
8675 ((and (or (<= scored marked) (= scored number))
8676 (numberp gnus-large-newsgroup)
8677 (> number gnus-large-newsgroup))
8681 "How many articles from %s (default %d): "
8682 gnus-newsgroup-name number))))
8683 (if (string-match "^[ \t]*$" input) number input)))
8684 ((and (> scored marked) (< scored number))
8687 (format "%s %s (%d scored, %d total): "
8688 "How many articles from"
8689 group scored number))))
8690 (if (string-match "^[ \t]*$" input)
8694 (setq select (if (stringp select) (string-to-number select) select))
8695 (if (or (null select) (zerop select))
8697 (if (and (not (zerop scored)) (<= (abs select) scored))
8699 (setq articles (sort scored-list '<))
8700 (setq number (length articles)))
8701 (setq articles (copy-sequence articles)))
8703 (if (< (abs select) number)
8705 ;; Select the N oldest articles.
8706 (setcdr (nthcdr (1- (abs select)) articles) nil)
8707 ;; Select the N most recent articles.
8708 (setq articles (nthcdr (- number select) articles))))
8709 (setq gnus-newsgroup-unselected
8710 (gnus-sorted-intersection
8711 gnus-newsgroup-unreads
8712 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8715 (defun gnus-killed-articles (killed articles)
8718 (if (inline (gnus-member-of-range (car articles) killed))
8719 (setq out (cons (car articles) out)))
8720 (setq articles (cdr articles)))
8723 (defun gnus-uncompress-marks (marks)
8724 "Uncompress the mark ranges in MARKS."
8725 (let ((uncompressed '(score bookmark))
8728 (if (memq (caar marks) uncompressed)
8729 (push (car marks) out)
8730 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8731 (setq marks (cdr marks)))
8734 (defun gnus-adjust-marked-articles (info)
8735 "Set all article lists and remove all marks that are no longer legal."
8736 (let* ((marked-lists (gnus-info-marks info))
8737 (active (gnus-active (gnus-info-group info)))
8740 (types gnus-article-mark-lists)
8741 (uncompressed '(score bookmark))
8742 marks var articles article mark)
8745 (setq marks (pop marked-lists))
8746 (set (setq var (intern (format "gnus-newsgroup-%s"
8747 (car (rassq (setq mark (car marks))
8749 (if (memq (car marks) uncompressed) (cdr marks)
8750 (gnus-uncompress-range (cdr marks))))
8752 (setq articles (symbol-value var))
8754 ;; All articles have to be subsets of the active articles.
8756 ;; Adjust "simple" lists.
8757 ((memq mark '(tick dormant expirable reply killed save))
8759 (when (or (< (setq article (pop articles)) min) (> article max))
8760 (set var (delq article (symbol-value var))))))
8762 ((memq mark '(score bookmark))
8764 (when (or (< (car (setq article (pop articles))) min)
8765 (> (car article) max))
8766 (set var (delq article (symbol-value var))))))))))
8768 (defun gnus-update-missing-marks (missing)
8769 "Go through the list of MISSING articles and remove them mark lists."
8771 (let ((types gnus-article-mark-lists)
8773 ;; Go through all types.
8775 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8776 (when (symbol-value var)
8777 ;; This list has articles. So we delete all missing articles
8781 (set var (delq (pop m) (symbol-value var)))))))))
8783 (defun gnus-update-marks ()
8784 "Enter the various lists of marked articles into the newsgroup info list."
8785 (let ((types gnus-article-mark-lists)
8786 (info (gnus-get-info gnus-newsgroup-name))
8787 (uncompressed '(score bookmark killed))
8788 type list newmarked symbol)
8790 ;; Add all marks lists that are non-nil to the list of marks lists.
8792 (setq type (pop types))
8793 (when (setq list (symbol-value
8795 (intern (format "gnus-newsgroup-%s"
8797 (push (cons (cdr type)
8798 (if (memq (cdr type) uncompressed) list
8799 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8802 ;; Enter these new marks into the info of the group.
8804 (setcar (nthcdr 3 info) newmarked)
8805 ;; Add the marks lists to the end of the info.
8807 (setcdr (nthcdr 2 info) (list newmarked))))
8809 ;; Cut off the end of the info if there's nothing else there.
8813 (when (nthcdr (decf i) info)
8814 (setcdr (nthcdr i info) nil)))))))
8816 (defun gnus-add-marked-articles (group type articles &optional info force)
8817 ;; Add ARTICLES of TYPE to the info of GROUP.
8818 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8819 ;; add, but replace marked articles of TYPE with ARTICLES.
8820 (let ((info (or info (gnus-get-info group)))
8821 (uncompressed '(score bookmark killed))
8824 (and (not (setq marked (nthcdr 3 info)))
8826 (setcdr (nthcdr 2 info)
8827 (list (list (cons type (gnus-compress-sequence
8829 (and (not (setq m (assq type (car marked))))
8832 (cons (cons type (gnus-compress-sequence articles t) )
8836 (setcar (nthcdr 3 info)
8837 (delq (assq type (car marked)) (car marked)))
8838 (setcdr m (gnus-compress-sequence articles t)))
8839 (setcdr m (gnus-compress-sequence
8840 (sort (nconc (gnus-uncompress-range (cdr m))
8841 (copy-sequence articles)) '<) t))))))
8843 (defun gnus-set-mode-line (where)
8844 "This function sets the mode line of the article or summary buffers.
8845 If WHERE is `summary', the summary mode line format will be used."
8846 ;; Is this mode line one we keep updated?
8847 (when (memq where gnus-updated-mode-lines)
8850 ;; We evaluate this in the summary buffer since these
8851 ;; variables are buffer-local to that buffer.
8852 (set-buffer gnus-summary-buffer)
8853 ;; We bind all these variables that are used in the `eval' form
8855 (let* ((mformat (symbol-value
8857 (format "gnus-%s-mode-line-format-spec" where))))
8858 (gnus-tmp-group-name gnus-newsgroup-name)
8859 (gnus-tmp-article-number (or gnus-current-article 0))
8860 (gnus-tmp-unread gnus-newsgroup-unreads)
8861 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8862 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8863 (gnus-tmp-unread-and-unselected
8864 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8865 (zerop gnus-tmp-unselected)) "")
8866 ((zerop gnus-tmp-unselected)
8867 (format "{%d more}" gnus-tmp-unread-and-unticked))
8868 (t (format "{%d(+%d) more}"
8869 gnus-tmp-unread-and-unticked
8870 gnus-tmp-unselected))))
8872 (if (and gnus-current-headers
8873 (vectorp gnus-current-headers))
8874 (mail-header-subject gnus-current-headers) ""))
8876 gnus-tmp-header);; passed as argument to any user-format-funcs
8877 (setq mode-string (eval mformat))
8878 (setq max-len (max 4 (if gnus-mode-non-string-length
8880 gnus-mode-non-string-length)
8881 (length mode-string))))
8882 ;; We might have to chop a bit of the string off...
8883 (when (> (length mode-string) max-len)
8885 (concat (gnus-truncate-string mode-string (- max-len 3))
8887 ;; Pad the mode string a bit.
8888 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8889 ;; Update the mode line.
8890 (setq mode-line-buffer-identification (list mode-string))
8891 (set-buffer-modified-p t))))
8893 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8894 "Go through the HEADERS list and add all Xrefs to a hash table.
8895 The resulting hash table is returned, or nil if no Xrefs were found."
8896 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8897 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8898 (xref-hashtb (make-vector 63 0))
8899 start group entry number xrefs header)
8901 (setq header (pop headers))
8902 (when (and (setq xrefs (mail-header-xref header))
8903 (not (memq (setq number (mail-header-number header))
8906 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8907 (setq start (match-end 0))
8908 (setq group (if prefix
8909 (concat prefix (substring xrefs (match-beginning 1)
8911 (substring xrefs (match-beginning 1) (match-end 1))))
8913 (string-to-int (substring xrefs (match-beginning 2)
8915 (if (setq entry (gnus-gethash group xref-hashtb))
8916 (setcdr entry (cons number (cdr entry)))
8917 (gnus-sethash group (cons number nil) xref-hashtb)))))
8918 (and start xref-hashtb)))
8920 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8921 "Look through all the headers and mark the Xrefs as read."
8922 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8923 name entry info xref-hashtb idlist method nth4)
8925 (set-buffer gnus-group-buffer)
8926 (when (setq xref-hashtb
8927 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8930 (unless (string= from-newsgroup (setq name (symbol-name group)))
8931 (setq idlist (symbol-value group))
8932 ;; Dead groups are not updated.
8934 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8936 (if (stringp (setq nth4 (gnus-info-method info)))
8937 (setq nth4 (gnus-server-to-method nth4))))
8938 ;; Only do the xrefs if the group has the same
8939 ;; select method as the group we have just read.
8940 (or (gnus-methods-equal-p
8941 nth4 (gnus-find-method-for-group from-newsgroup))
8943 (equal nth4 (setq method (gnus-find-method-for-group
8945 (and (equal (car nth4) (car method))
8946 (equal (nth 1 nth4) (nth 1 method))))
8947 gnus-use-cross-reference
8948 (or (not (eq gnus-use-cross-reference t))
8950 ;; Only do cross-references on subscribed
8951 ;; groups, if that is what is wanted.
8952 (<= (gnus-info-level info) gnus-level-subscribed))
8953 (gnus-group-make-articles-read name idlist))))
8956 (defun gnus-group-make-articles-read (group articles)
8958 (entry (gnus-gethash group gnus-newsrc-hashtb))
8959 (info (nth 2 entry))
8960 (active (gnus-active group))
8962 ;; First peel off all illegal article numbers.
8964 (let ((ids articles)
8968 (if (and first (> id (cdr active)))
8970 ;; We'll end up in this situation in one particular
8971 ;; obscure situation. If you re-scan a group and get
8972 ;; a new article that is cross-posted to a different
8973 ;; group that has not been re-scanned, you might get
8974 ;; crossposted article that has a higher number than
8975 ;; Gnus believes possible. So we re-activate this
8976 ;; group as well. This might mean doing the
8977 ;; crossposting thingy will *increase* the number
8978 ;; of articles in some groups. Tsk, tsk.
8979 (setq active (or (gnus-activate-group group) active))))
8980 (if (or (> id (cdr active))
8981 (< id (car active)))
8982 (setq articles (delq id articles)))
8983 (setq ids (cdr ids)))))
8984 ;; If the read list is nil, we init it.
8986 (null (gnus-info-read info))
8988 (gnus-info-set-read info (cons 1 (1- (car active)))))
8989 ;; Then we add the read articles to the range.
8994 (gnus-info-read info) (setq articles (sort articles '<)))))
8995 ;; Then we have to re-compute how many unread
8996 ;; articles there are in this group.
9001 (setq num (- (1+ (cdr active)) (car active))))
9002 ((not (listp (cdr range)))
9003 (setq num (- (cdr active) (- (1+ (cdr range))
9007 (if (numberp (car range))
9009 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9010 (setq range (cdr range)))
9011 (setq num (- (cdr active) num))))
9012 ;; Update the number of unread articles.
9014 ;; Update the group buffer.
9015 (gnus-group-update-group group t)))))
9017 (defun gnus-methods-equal-p (m1 m2)
9018 (let ((m1 (or m1 gnus-select-method))
9019 (m2 (or m2 gnus-select-method)))
9021 (and (eq (car m1) (car m2))
9022 (or (not (memq 'address (assoc (symbol-name (car m1))
9023 gnus-valid-select-methods)))
9024 (equal (nth 1 m1) (nth 1 m2)))))))
9026 (defsubst gnus-header-value ()
9027 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9029 (defvar gnus-newsgroup-none-id 0)
9031 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9032 (let ((cur nntp-server-buffer)
9035 (save-excursion (set-buffer gnus-summary-buffer)
9036 gnus-newsgroup-dependencies)))
9037 headers id id-dep ref-dep end ref)
9039 (set-buffer nntp-server-buffer)
9040 (run-hooks 'gnus-parse-headers-hook)
9041 (let ((case-fold-search t)
9042 in-reply-to header p lines)
9043 (goto-char (point-min))
9044 ;; Search to the beginning of the next header. Error messages
9045 ;; do not begin with 2 or 3.
9046 (while (re-search-forward "^[23][0-9]+ " nil t)
9049 ;; This implementation of this function, with nine
9050 ;; search-forwards instead of the one re-search-forward and
9051 ;; a case (which basically was the old function) is actually
9052 ;; about twice as fast, even though it looks messier. You
9053 ;; can't have everything, I guess. Speed and elegance
9054 ;; doesn't always go hand in hand.
9063 (narrow-to-region (point)
9064 (or (and (search-forward "\n.\n" nil t)
9070 (if (search-forward "\nsubject: " nil t)
9071 (gnus-header-value) "(none)"))
9075 (if (search-forward "\nfrom: " nil t)
9076 (gnus-header-value) "(nobody)"))
9080 (if (search-forward "\ndate: " nil t)
9081 (gnus-header-value) ""))
9085 (if (search-forward "\nmessage-id: " nil t)
9086 (setq id (gnus-header-value))
9087 ;; If there was no message-id, we just fake one to make
9088 ;; subsequent routines simpler.
9089 (setq id (concat "none+"
9091 (setq gnus-newsgroup-none-id
9092 (1+ gnus-newsgroup-none-id)))))))
9096 (if (search-forward "\nreferences: " nil t)
9099 (setq end (match-end 0))
9105 (search-backward ">" end t)
9108 (search-backward "<" end t)
9110 ;; Get the references from the in-reply-to header if there
9111 ;; were no references and the in-reply-to header looks
9113 (if (and (search-forward "\nin-reply-to: " nil t)
9114 (setq in-reply-to (gnus-header-value))
9115 (string-match "<[^>]+>" in-reply-to))
9116 (setq ref (substring in-reply-to (match-beginning 0)
9124 (if (search-forward "\nlines: " nil t)
9125 (if (numberp (setq lines (read cur)))
9131 (and (search-forward "\nxref: " nil t)
9132 (gnus-header-value)))))
9133 ;; We do the threading while we read the headers. The
9134 ;; message-id and the last reference are both entered into
9135 ;; the same hash table. Some tippy-toeing around has to be
9136 ;; done in case an article has arrived before the article
9137 ;; which it refers to.
9138 (if (boundp (setq id-dep (intern id dependencies)))
9139 (if (and (car (symbol-value id-dep))
9141 ;; An article with this Message-ID has already
9142 ;; been seen, so we ignore this one, except we add
9143 ;; any additional Xrefs (in case the two articles
9144 ;; came from different servers).
9146 (mail-header-set-xref
9147 (car (symbol-value id-dep))
9148 (concat (or (mail-header-xref
9149 (car (symbol-value id-dep))) "")
9150 (or (mail-header-xref header) "")))
9152 (setcar (symbol-value id-dep) header))
9153 (set id-dep (list header)))
9155 (if (boundp (setq ref-dep (intern ref dependencies)))
9156 (setcdr (symbol-value ref-dep)
9157 (nconc (cdr (symbol-value ref-dep))
9158 (list (symbol-value id-dep))))
9159 (set ref-dep (list nil (symbol-value id-dep))))
9160 (setq headers (cons header headers)))
9161 (goto-char (point-max))
9163 (nreverse headers)))))
9165 ;; The following macros and functions were written by Felix Lee
9166 ;; <flee@cse.psu.edu>.
9168 (defmacro gnus-nov-read-integer ()
9170 (if (= (following-char) ?\t)
9172 (let ((num (condition-case nil (read buffer) (error nil))))
9173 (if (numberp num) num 0)))
9174 (or (eobp) (forward-char 1))))
9176 (defmacro gnus-nov-skip-field ()
9177 '(search-forward "\t" eol 'move))
9179 (defmacro gnus-nov-field ()
9180 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9182 ;; Goes through the xover lines and returns a list of vectors
9183 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9184 force-new dependencies)
9185 "Parse the news overview data in the server buffer, and return a
9186 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9187 ;; Get the Xref when the users reads the articles since most/some
9188 ;; NNTP servers do not include Xrefs when using XOVER.
9189 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9190 (let ((cur nntp-server-buffer)
9191 (dependencies (or dependencies gnus-newsgroup-dependencies))
9192 number headers header)
9194 (set-buffer nntp-server-buffer)
9195 ;; Allow the user to mangle the headers before parsing them.
9196 (run-hooks 'gnus-parse-headers-hook)
9197 (goto-char (point-min))
9198 (while (and sequence (not (eobp)))
9199 (setq number (read cur))
9200 (while (and sequence (< (car sequence) number))
9201 (setq sequence (cdr sequence)))
9203 (eq number (car sequence))
9205 (setq sequence (cdr sequence))
9207 (inline (gnus-nov-parse-line
9208 number dependencies force-new)))
9209 (setq headers (cons header headers)))))
9211 (setq headers (nreverse headers)))
9214 ;; This function has to be called with point after the article number
9215 ;; on the beginning of the line.
9216 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9218 (eol (gnus-point-at-eol))
9219 (buffer (current-buffer))
9220 header ref id id-dep ref-dep)
9222 ;; overview: [num subject from date id refs chars lines misc]
9223 (narrow-to-region (point) eol)
9224 (or (eobp) (forward-char))
9230 (gnus-nov-field) ; subject
9231 (gnus-nov-field) ; from
9232 (gnus-nov-field) ; date
9233 (setq id (or (gnus-nov-field)
9236 (setq none (1+ none)))))) ; id
9239 (let ((beg (point)))
9240 (search-forward "\t" eol)
9241 (if (search-backward ">" beg t)
9245 (search-backward "<" beg t)))
9247 (gnus-nov-field)) ; refs
9248 (gnus-nov-read-integer) ; chars
9249 (gnus-nov-read-integer) ; lines
9250 (if (= (following-char) ?\n)
9252 (gnus-nov-field)) ; misc
9255 (gnus-error 4 "Strange nov line")
9261 ;; We build the thread tree.
9263 (if (boundp (setq id-dep (intern id dependencies)))
9264 (if (and (car (symbol-value id-dep))
9266 ;; An article with this Message-ID has already been seen,
9267 ;; so we ignore this one, except we add any additional
9268 ;; Xrefs (in case the two articles came from different
9271 (mail-header-set-xref
9272 (car (symbol-value id-dep))
9273 (concat (or (mail-header-xref
9274 (car (symbol-value id-dep))) "")
9275 (or (mail-header-xref header) "")))
9277 (setcar (symbol-value id-dep) header))
9278 (set id-dep (list header))))
9281 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9282 (setcdr (symbol-value ref-dep)
9283 (nconc (cdr (symbol-value ref-dep))
9284 (list (symbol-value id-dep))))
9285 (set ref-dep (list nil (symbol-value id-dep))))))
9288 (defun gnus-article-get-xrefs ()
9289 "Fill in the Xref value in `gnus-current-headers', if necessary.
9290 This is meant to be called in `gnus-article-internal-prepare-hook'."
9291 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9292 gnus-current-headers)))
9293 (or (not gnus-use-cross-reference)
9295 (and (mail-header-xref headers)
9296 (not (string= (mail-header-xref headers) "")))
9297 (let ((case-fold-search t)
9300 (nnheader-narrow-to-headers)
9301 (goto-char (point-min))
9302 (if (or (and (eq (downcase (following-char)) ?x)
9303 (looking-at "Xref:"))
9304 (search-forward "\nXref:" nil t))
9306 (goto-char (1+ (match-end 0)))
9307 (setq xref (buffer-substring (point)
9308 (progn (end-of-line) (point))))
9309 (mail-header-set-xref headers xref))))))))
9311 (defun gnus-summary-insert-subject (id &optional old-header)
9312 "Find article ID and insert the summary line for that article."
9313 (let ((header (gnus-read-header id))
9314 (number (and (numberp id) id))
9317 ;; Rebuild the thread that this article is part of and go to the
9318 ;; article we have fetched.
9320 (when (setq pos (text-property-any
9321 (point-min) (point-max) 'gnus-number
9322 (mail-header-number old-header)))
9325 (gnus-data-remove (mail-header-number old-header))))
9327 (mail-header-set-number header (mail-header-number old-header)))
9328 (setq gnus-newsgroup-sparse
9329 (delq (mail-header-number header) gnus-newsgroup-sparse))
9330 (gnus-rebuild-thread (mail-header-id header))
9331 (gnus-summary-goto-subject (setq number (mail-header-number header))
9333 (when (and (numberp number)
9335 ;; We have to update the boundaries even if we can't fetch the
9336 ;; article if ID is a number -- so that the next `P' or `N'
9337 ;; command will fetch the previous (or next) article even
9338 ;; if the one we tried to fetch this time has been canceled.
9339 (and (> number gnus-newsgroup-end)
9340 (setq gnus-newsgroup-end number))
9341 (and (< number gnus-newsgroup-begin)
9342 (setq gnus-newsgroup-begin number))
9343 (setq gnus-newsgroup-unselected
9344 (delq number gnus-newsgroup-unselected)))
9345 ;; Report back a success?
9346 (and header (mail-header-number header))))
9348 (defun gnus-summary-work-articles (n)
9349 "Return a list of articles to be worked upon. The prefix argument,
9350 the list of process marked articles, and the current article will be
9351 taken into consideration."
9353 ((and n (numberp n))
9354 ;; A numerical prefix has been given.
9355 (let ((backward (< n 0))
9361 (push (setq article (gnus-summary-article-number))
9364 (gnus-summary-find-prev nil article)
9365 (gnus-summary-find-next nil article)))
9367 (nreverse articles)))
9368 ((and (boundp 'transient-mark-mode)
9371 ;; Work on the region between point and mark.
9372 (let ((max (max (point) (mark)))
9375 (goto-char (min (point) (mark)))
9378 (push (setq article (gnus-summary-article-number)) articles)
9379 (gnus-summary-find-next nil article)
9381 (nreverse articles))))
9382 (gnus-newsgroup-processable
9383 ;; There are process-marked articles present.
9384 (reverse gnus-newsgroup-processable))
9386 ;; Just return the current article.
9387 (list (gnus-summary-article-number)))))
9389 (defun gnus-summary-search-group (&optional backward use-level)
9390 "Search for next unread newsgroup.
9391 If optional argument BACKWARD is non-nil, search backward instead."
9393 (set-buffer gnus-group-buffer)
9394 (if (gnus-group-search-forward
9395 backward nil (if use-level (gnus-group-group-level) nil))
9396 (gnus-group-group-name))))
9398 (defun gnus-summary-best-group (&optional exclude-group)
9399 "Find the name of the best unread group.
9400 If EXCLUDE-GROUP, do not go to this group."
9402 (set-buffer gnus-group-buffer)
9404 (gnus-group-best-unread-group exclude-group))))
9406 (defun gnus-summary-find-next (&optional unread article backward)
9407 (if backward (gnus-summary-find-prev)
9408 (let* ((dummy (gnus-summary-article-intangible-p))
9409 (article (or article (gnus-summary-article-number)))
9410 (arts (gnus-data-find-list article))
9412 (when (and (not dummy)
9413 (or (not gnus-summary-check-current)
9415 (not (gnus-data-unread-p (car arts)))))
9416 (setq arts (cdr arts)))
9421 (when (gnus-data-unread-p (car arts))
9422 (setq result (car arts)
9424 (setq arts (cdr arts)))
9427 (goto-char (gnus-data-pos result))
9428 (gnus-data-number result)))))
9430 (defun gnus-summary-find-prev (&optional unread article)
9431 (let* ((article (or article (gnus-summary-article-number)))
9432 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9434 (when (or (not gnus-summary-check-current)
9436 (not (gnus-data-unread-p (car arts))))
9437 (setq arts (cdr arts)))
9442 (and (gnus-data-unread-p (car arts))
9443 (setq result (car arts)
9445 (setq arts (cdr arts)))
9449 (goto-char (gnus-data-pos result))
9450 (gnus-data-number result)))))
9452 (defun gnus-summary-find-subject (subject &optional unread backward article)
9453 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9454 (article (or article (gnus-summary-article-number)))
9455 (articles (gnus-data-list backward))
9456 (arts (gnus-data-find-list article articles))
9458 (when (or (not gnus-summary-check-current)
9460 (not (gnus-data-unread-p (car arts))))
9461 (setq arts (cdr arts)))
9463 (and (or (not unread)
9464 (gnus-data-unread-p (car arts)))
9465 (vectorp (gnus-data-header (car arts)))
9467 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9468 (setq result (car arts)
9470 (setq arts (cdr arts)))
9472 (goto-char (gnus-data-pos result))
9473 (gnus-data-number result))))
9475 (defun gnus-summary-search-forward (&optional unread subject backward)
9476 "Search forward for an article.
9477 If UNREAD, look for unread articles. If SUBJECT, look for
9478 articles with that subject. If BACKWARD, search backward instead."
9479 (cond (subject (gnus-summary-find-subject subject unread backward))
9480 (backward (gnus-summary-find-prev unread))
9481 (t (gnus-summary-find-next unread))))
9483 (defun gnus-recenter (&optional n)
9484 "Center point in window and redisplay frame.
9485 Also do horizontal recentering."
9487 (when (and gnus-auto-center-summary
9488 (not (eq gnus-auto-center-summary 'vertical)))
9489 (gnus-horizontal-recenter))
9492 (defun gnus-summary-recenter ()
9493 "Center point in the summary window.
9494 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9495 displayed, no centering will be performed."
9496 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9497 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9498 (let* ((top (cond ((< (window-height) 4) 0)
9499 ((< (window-height) 7) 1)
9501 (height (1- (window-height)))
9502 (bottom (save-excursion (goto-char (point-max))
9503 (forward-line (- height))
9505 (window (get-buffer-window (current-buffer))))
9506 ;; The user has to want it.
9507 (when gnus-auto-center-summary
9508 (when (get-buffer-window gnus-article-buffer)
9509 ;; Only do recentering when the article buffer is displayed,
9510 ;; Set the window start to either `bottom', which is the biggest
9511 ;; possible valid number, or the second line from the top,
9512 ;; whichever is the least.
9514 window (min bottom (save-excursion
9515 (forward-line (- top)) (point)))))
9516 ;; Do horizontal recentering while we're at it.
9517 (when (and (get-buffer-window (current-buffer) t)
9518 (not (eq gnus-auto-center-summary 'vertical)))
9519 (let ((selected (selected-window)))
9520 (select-window (get-buffer-window (current-buffer) t))
9521 (gnus-summary-position-point)
9522 (gnus-horizontal-recenter)
9523 (select-window selected))))))
9525 (defun gnus-horizontal-recenter ()
9526 "Recenter the current buffer horizontally."
9527 (if (< (current-column) (/ (window-width) 2))
9528 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9529 (let* ((orig (point))
9530 (end (window-end (get-buffer-window (current-buffer) t)))
9532 ;; Find the longest line currently displayed in the window.
9533 (goto-char (window-start))
9534 (while (and (not (eobp))
9537 (setq max (max max (current-column)))
9540 ;; Scroll horizontally to center (sort of) the point.
9541 (if (> max (window-width))
9543 (get-buffer-window (current-buffer) t)
9544 (min (- (current-column) (/ (window-width) 3))
9545 (+ 2 (- max (window-width)))))
9546 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9549 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9550 (defun gnus-short-group-name (group &optional levels)
9551 "Collapse GROUP name LEVELS."
9558 (while (string-match "\\." group skip)
9559 (setq skip (match-end 0)
9562 (if (string-match ":" group)
9563 (setq foreign (substring group 0 (match-end 0))
9564 group (substring group (match-end 0))))
9566 (if (and (string-match "\\." group)
9567 (> levels (- gnus-group-uncollapsed-levels 1)))
9568 (setq name (concat name (substring group 0 1))
9569 group (substring group (match-end 0))
9571 name (concat name "."))
9572 (setq name (concat foreign name group)
9576 (defun gnus-summary-jump-to-group (newsgroup)
9577 "Move point to NEWSGROUP in group mode buffer."
9578 ;; Keep update point of group mode buffer if visible.
9579 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9580 (save-window-excursion
9581 ;; Take care of tree window mode.
9582 (if (get-buffer-window gnus-group-buffer)
9583 (pop-to-buffer gnus-group-buffer))
9584 (gnus-group-jump-to-group newsgroup))
9586 ;; Take care of tree window mode.
9587 (if (get-buffer-window gnus-group-buffer)
9588 (pop-to-buffer gnus-group-buffer)
9589 (set-buffer gnus-group-buffer))
9590 (gnus-group-jump-to-group newsgroup))))
9592 ;; This function returns a list of article numbers based on the
9593 ;; difference between the ranges of read articles in this group and
9594 ;; the range of active articles.
9595 (defun gnus-list-of-unread-articles (group)
9596 (let* ((read (gnus-info-read (gnus-get-info group)))
9597 (active (gnus-active group))
9600 ;; If none are read, then all are unread.
9602 (setq first (car active))
9603 ;; If the range of read articles is a single range, then the
9604 ;; first unread article is the article after the last read
9605 ;; article. Sounds logical, doesn't it?
9606 (if (not (listp (cdr read)))
9607 (setq first (1+ (cdr read)))
9608 ;; `read' is a list of ranges.
9609 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9614 (while (< first nlast)
9615 (setq unread (cons first unread))
9616 (setq first (1+ first))))
9617 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9618 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9619 (setq read (cdr read)))))
9620 ;; And add the last unread articles.
9621 (while (<= first last)
9622 (setq unread (cons first unread))
9623 (setq first (1+ first)))
9624 ;; Return the list of unread articles.
9627 (defun gnus-list-of-read-articles (group)
9628 "Return a list of unread, unticked and non-dormant articles."
9629 (let* ((info (gnus-get-info group))
9630 (marked (gnus-info-marks info))
9631 (active (gnus-active group)))
9633 (gnus-set-difference
9634 (gnus-sorted-complement
9635 (gnus-uncompress-range active)
9636 (gnus-list-of-unread-articles group))
9638 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9639 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9641 ;; Various summary commands
9643 (defun gnus-summary-universal-argument (arg)
9644 "Perform any operation on all articles that are process/prefixed."
9646 (gnus-set-global-variables)
9647 (let ((articles (gnus-summary-work-articles arg))
9654 (substitute-command-keys
9655 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9658 (gnus-error 1 "Undefined key")
9661 (gnus-summary-goto-subject (setq article (pop articles)))
9662 (command-execute func)
9663 (gnus-summary-remove-process-mark article)))))
9664 (gnus-summary-position-point))
9666 (defun gnus-summary-toggle-truncation (&optional arg)
9667 "Toggle truncation of summary lines.
9668 With arg, turn line truncation on iff arg is positive."
9670 (setq truncate-lines
9671 (if (null arg) (not truncate-lines)
9672 (> (prefix-numeric-value arg) 0)))
9675 (defun gnus-summary-reselect-current-group (&optional all rescan)
9676 "Exit and then reselect the current newsgroup.
9677 The prefix argument ALL means to select all articles."
9679 (gnus-set-global-variables)
9680 (let ((current-subject (gnus-summary-article-number))
9681 (group gnus-newsgroup-name))
9682 (setq gnus-newsgroup-begin nil)
9684 ;; We have to adjust the point of group mode buffer because the
9685 ;; current point was moved to the next unread newsgroup by
9687 (gnus-summary-jump-to-group group)
9690 (gnus-group-get-new-news-this-group 1)))
9691 (gnus-group-read-group all t)
9692 (gnus-summary-goto-subject current-subject)))
9694 (defun gnus-summary-rescan-group (&optional all)
9695 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9697 (gnus-summary-reselect-current-group all t))
9699 (defun gnus-summary-update-info ()
9700 (let* ((group gnus-newsgroup-name))
9701 (when gnus-newsgroup-kill-headers
9702 (setq gnus-newsgroup-killed
9703 (gnus-compress-sequence
9705 (gnus-set-sorted-intersection
9706 (gnus-uncompress-range gnus-newsgroup-killed)
9707 (setq gnus-newsgroup-unselected
9708 (sort gnus-newsgroup-unselected '<)))
9709 (setq gnus-newsgroup-unreads
9710 (sort gnus-newsgroup-unreads '<))) t)))
9711 (unless (listp (cdr gnus-newsgroup-killed))
9712 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9713 (let ((headers gnus-newsgroup-headers))
9714 (run-hooks 'gnus-exit-group-hook)
9715 (unless gnus-save-score
9716 (setq gnus-newsgroup-scored nil))
9717 ;; Set the new ranges of read articles.
9718 (gnus-update-read-articles
9719 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9720 ;; Set the current article marks.
9722 ;; Do the cross-ref thing.
9723 (when gnus-use-cross-reference
9724 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9725 ;; Do adaptive scoring, and possibly save score files.
9726 (when gnus-newsgroup-adaptive
9727 (gnus-score-adaptive))
9728 (when gnus-use-scoring
9730 ;; Do not switch windows but change the buffer to work.
9731 (set-buffer gnus-group-buffer)
9732 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9733 (gnus-group-update-group group)))))
9735 (defun gnus-summary-exit (&optional temporary)
9736 "Exit reading current newsgroup, and then return to group selection mode.
9737 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9739 (gnus-set-global-variables)
9740 (gnus-kill-save-kill-buffer)
9741 (let* ((group gnus-newsgroup-name)
9742 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9744 (buf (current-buffer)))
9745 (run-hooks 'gnus-summary-prepare-exit-hook)
9746 ;; If we have several article buffers, we kill them at exit.
9747 (unless gnus-single-article-buffer
9748 (gnus-kill-buffer gnus-original-article-buffer)
9749 (setq gnus-article-current nil))
9750 (when gnus-use-cache
9751 (gnus-cache-possibly-remove-articles)
9752 (gnus-cache-save-buffers))
9753 (when gnus-use-trees
9754 (gnus-tree-close group))
9755 ;; Make all changes in this group permanent.
9757 (gnus-summary-update-info))
9758 (gnus-close-group group)
9759 ;; Make sure where I was, and go to next newsgroup.
9760 (set-buffer gnus-group-buffer)
9762 (gnus-group-jump-to-group group)
9763 (gnus-group-next-unread-group 1))
9764 (run-hooks 'gnus-summary-exit-hook)
9767 ;; If we have several article buffers, we kill them at exit.
9768 (unless gnus-single-article-buffer
9769 (gnus-kill-buffer gnus-article-buffer)
9770 (gnus-kill-buffer gnus-original-article-buffer)
9771 (setq gnus-article-current nil))
9773 (if (not gnus-kill-summary-on-exit)
9774 (gnus-deaden-summary)
9775 ;; We set all buffer-local variables to nil. It is unclear why
9776 ;; this is needed, but if we don't, buffer-local variables are
9777 ;; not garbage-collected, it seems. This would the lead to en
9778 ;; ever-growing Emacs.
9779 (gnus-summary-clear-local-variables)
9780 (when (get-buffer gnus-article-buffer)
9781 (bury-buffer gnus-article-buffer))
9782 ;; We clear the global counterparts of the buffer-local
9783 ;; variables as well, just to be on the safe side.
9784 (gnus-configure-windows 'group 'force)
9785 (gnus-summary-clear-local-variables)
9786 ;; Return to group mode buffer.
9787 (if (eq mode 'gnus-summary-mode)
9788 (gnus-kill-buffer buf)))
9789 (setq gnus-current-select-method gnus-select-method)
9790 (pop-to-buffer gnus-group-buffer)
9791 ;; Clear the current group name.
9792 (if (not quit-config)
9794 (gnus-group-jump-to-group group)
9795 (gnus-group-next-unread-group 1)
9796 (gnus-configure-windows 'group 'force))
9797 (if (not (buffer-name (car quit-config)))
9798 (gnus-configure-windows 'group 'force)
9799 (set-buffer (car quit-config))
9800 (and (eq major-mode 'gnus-summary-mode)
9801 (gnus-set-global-variables))
9802 (gnus-configure-windows (cdr quit-config))))
9804 (setq gnus-newsgroup-name nil)))))
9806 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9807 (defun gnus-summary-exit-no-update (&optional no-questions)
9808 "Quit reading current newsgroup without updating read article info."
9810 (gnus-set-global-variables)
9811 (let* ((group gnus-newsgroup-name)
9812 (quit-config (gnus-group-quit-config group)))
9813 (when (or no-questions
9815 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9816 ;; If we have several article buffers, we kill them at exit.
9817 (unless gnus-single-article-buffer
9818 (gnus-kill-buffer gnus-article-buffer)
9819 (gnus-kill-buffer gnus-original-article-buffer)
9820 (setq gnus-article-current nil))
9821 (if (not gnus-kill-summary-on-exit)
9822 (gnus-deaden-summary)
9823 (gnus-close-group group)
9824 (gnus-summary-clear-local-variables)
9825 (set-buffer gnus-group-buffer)
9826 (gnus-summary-clear-local-variables)
9827 (when (get-buffer gnus-summary-buffer)
9828 (kill-buffer gnus-summary-buffer)))
9829 (unless gnus-single-article-buffer
9830 (setq gnus-article-current nil))
9831 (when gnus-use-trees
9832 (gnus-tree-close group))
9833 (when (get-buffer gnus-article-buffer)
9834 (bury-buffer gnus-article-buffer))
9835 ;; Return to the group buffer.
9836 (gnus-configure-windows 'group 'force)
9837 ;; Clear the current group name.
9838 (setq gnus-newsgroup-name nil)
9839 (when (equal (gnus-group-group-name) group)
9840 (gnus-group-next-unread-group 1))
9842 (if (not (buffer-name (car quit-config)))
9843 (gnus-configure-windows 'group 'force)
9844 (set-buffer (car quit-config))
9845 (when (eq major-mode 'gnus-summary-mode)
9846 (gnus-set-global-variables))
9847 (gnus-configure-windows (cdr quit-config)))))))
9851 (defvar gnus-dead-summary-mode-map nil)
9853 (if gnus-dead-summary-mode-map
9855 (setq gnus-dead-summary-mode-map (make-keymap))
9856 (suppress-keymap gnus-dead-summary-mode-map)
9857 (substitute-key-definition
9858 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9859 (let ((keys '("\C-d" "\r" "\177")))
9861 (define-key gnus-dead-summary-mode-map
9862 (pop keys) 'gnus-summary-wake-up-the-dead))))
9864 (defvar gnus-dead-summary-mode nil
9865 "Minor mode for Gnus summary buffers.")
9867 (defun gnus-dead-summary-mode (&optional arg)
9868 "Minor mode for Gnus summary buffers."
9870 (when (eq major-mode 'gnus-summary-mode)
9871 (make-local-variable 'gnus-dead-summary-mode)
9872 (setq gnus-dead-summary-mode
9873 (if (null arg) (not gnus-dead-summary-mode)
9874 (> (prefix-numeric-value arg) 0)))
9875 (when gnus-dead-summary-mode
9876 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9877 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9878 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9879 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9880 minor-mode-map-alist)))))
9882 (defun gnus-deaden-summary ()
9883 "Make the current summary buffer into a dead summary buffer."
9884 ;; Kill any previous dead summary buffer.
9885 (when (and gnus-dead-summary
9886 (buffer-name gnus-dead-summary))
9888 (set-buffer gnus-dead-summary)
9889 (when gnus-dead-summary-mode
9890 (kill-buffer (current-buffer)))))
9891 ;; Make this the current dead summary.
9892 (setq gnus-dead-summary (current-buffer))
9893 (gnus-dead-summary-mode 1)
9894 (let ((name (buffer-name)))
9895 (when (string-match "Summary" name)
9897 (concat (substring name 0 (match-beginning 0)) "Dead "
9898 (substring name (match-beginning 0))) t))))
9900 (defun gnus-kill-or-deaden-summary (buffer)
9901 "Kill or deaden the summary BUFFER."
9902 (when (and (buffer-name buffer)
9903 (not gnus-single-article-buffer))
9906 (gnus-kill-buffer gnus-article-buffer)
9907 (gnus-kill-buffer gnus-original-article-buffer)))
9908 (cond (gnus-kill-summary-on-exit
9909 (when (and gnus-use-trees
9910 (and (get-buffer buffer)
9911 (buffer-name (get-buffer buffer))))
9913 (set-buffer (get-buffer buffer))
9914 (gnus-tree-close gnus-newsgroup-name)))
9915 (gnus-kill-buffer buffer))
9916 ((and (get-buffer buffer)
9917 (buffer-name (get-buffer buffer)))
9920 (gnus-deaden-summary)))))
9922 (defun gnus-summary-wake-up-the-dead (&rest args)
9923 "Wake up the dead summary buffer."
9925 (gnus-dead-summary-mode -1)
9926 (let ((name (buffer-name)))
9927 (when (string-match "Dead " name)
9929 (concat (substring name 0 (match-beginning 0))
9930 (substring name (match-end 0))) t)))
9931 (gnus-message 3 "This dead summary is now alive again"))
9933 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9934 (defun gnus-summary-fetch-faq (&optional faq-dir)
9935 "Fetch the FAQ for the current group.
9936 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9940 (if current-prefix-arg
9942 "Faq dir: " (and (listp gnus-group-faq-directory)
9943 gnus-group-faq-directory)))))
9944 (let (gnus-faq-buffer)
9945 (and (setq gnus-faq-buffer
9946 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9947 (gnus-configure-windows 'summary-faq))))
9949 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9950 (defun gnus-summary-describe-group (&optional force)
9951 "Describe the current newsgroup."
9953 (gnus-group-describe-group force gnus-newsgroup-name))
9955 (defun gnus-summary-describe-briefly ()
9956 "Describe summary mode commands briefly."
9959 (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")))
9961 ;; Walking around group mode buffer from summary mode.
9963 (defun gnus-summary-next-group (&optional no-article target-group backward)
9964 "Exit current newsgroup and then select next unread newsgroup.
9965 If prefix argument NO-ARTICLE is non-nil, no article is selected
9966 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9967 previous group instead."
9969 (gnus-set-global-variables)
9970 (let ((current-group gnus-newsgroup-name)
9971 (current-buffer (current-buffer))
9973 ;; First we semi-exit this group to update Xrefs and all variables.
9974 ;; We can't do a real exit, because the window conf must remain
9975 ;; the same in case the user is prompted for info, and we don't
9976 ;; want the window conf to change before that...
9977 (gnus-summary-exit t)
9978 (while (not entered)
9979 ;; Then we find what group we are supposed to enter.
9980 (set-buffer gnus-group-buffer)
9981 (gnus-group-jump-to-group current-group)
9984 (if (eq gnus-keep-same-level 'best)
9985 (gnus-summary-best-group gnus-newsgroup-name)
9986 (gnus-summary-search-group backward gnus-keep-same-level))))
9987 (if (not target-group)
9988 ;; There are no further groups, so we return to the group
9991 (gnus-message 5 "Returning to the group buffer")
9993 (set-buffer current-buffer)
9994 (gnus-summary-exit))
9995 ;; We try to enter the target group.
9996 (gnus-group-jump-to-group target-group)
9997 (let ((unreads (gnus-group-group-unread)))
9998 (if (and (or (eq t unreads)
9999 (and unreads (not (zerop unreads))))
10000 (gnus-summary-read-group
10001 target-group nil no-article current-buffer))
10003 (setq current-group target-group
10004 target-group nil)))))))
10006 (defun gnus-summary-prev-group (&optional no-article)
10007 "Exit current newsgroup and then select previous unread newsgroup.
10008 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10010 (gnus-summary-next-group no-article nil t))
10012 ;; Walking around summary lines.
10014 (defun gnus-summary-first-subject (&optional unread)
10015 "Go to the first unread subject.
10016 If UNREAD is non-nil, go to the first unread article.
10017 Returns the article selected or nil if there are no unread articles."
10022 ((null gnus-newsgroup-data)
10023 (gnus-message 3 "No articles in the group")
10025 ;; Pick the first article.
10027 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10028 (gnus-data-number (car gnus-newsgroup-data)))
10029 ;; No unread articles.
10030 ((null gnus-newsgroup-unreads)
10031 (gnus-message 3 "No more unread articles")
10033 ;; Find the first unread article.
10035 (let ((data gnus-newsgroup-data))
10037 (not (gnus-data-unread-p (car data))))
10038 (setq data (cdr data)))
10041 (goto-char (gnus-data-pos (car data)))
10042 (gnus-data-number (car data)))))))
10043 (gnus-summary-position-point)))
10045 (defun gnus-summary-next-subject (n &optional unread dont-display)
10046 "Go to next N'th summary line.
10047 If N is negative, go to the previous N'th subject line.
10048 If UNREAD is non-nil, only unread articles are selected.
10049 The difference between N and the actual number of steps taken is
10052 (let ((backward (< n 0))
10054 (while (and (> n 0)
10056 (gnus-summary-find-prev unread)
10057 (gnus-summary-find-next unread)))
10059 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10060 (if unread " unread" "")))
10061 (unless dont-display
10062 (gnus-summary-recenter)
10063 (gnus-summary-position-point))
10066 (defun gnus-summary-next-unread-subject (n)
10067 "Go to next N'th unread summary line."
10069 (gnus-summary-next-subject n t))
10071 (defun gnus-summary-prev-subject (n &optional unread)
10072 "Go to previous N'th summary line.
10073 If optional argument UNREAD is non-nil, only unread article is selected."
10075 (gnus-summary-next-subject (- n) unread))
10077 (defun gnus-summary-prev-unread-subject (n)
10078 "Go to previous N'th unread summary line."
10080 (gnus-summary-next-subject (- n) t))
10082 (defun gnus-summary-goto-subject (article &optional force silent)
10083 "Go the subject line of ARTICLE.
10084 If FORCE, also allow jumping to articles not currently shown."
10086 (data (gnus-data-find article)))
10087 ;; We read in the article if we have to.
10090 (gnus-summary-insert-subject article)
10091 (setq data (gnus-data-find article)))
10096 (gnus-message 3 "Can't find article %d" article))
10098 (goto-char (gnus-data-pos data))
10101 ;; Walking around summary lines with displaying articles.
10103 (defun gnus-summary-expand-window (&optional arg)
10104 "Make the summary buffer take up the entire Emacs frame.
10105 Given a prefix, will force an `article' buffer configuration."
10107 (gnus-set-global-variables)
10109 (gnus-configure-windows 'article 'force)
10110 (gnus-configure-windows 'summary 'force)))
10112 (defun gnus-summary-display-article (article &optional all-header)
10113 "Display ARTICLE in article buffer."
10114 (gnus-set-global-variables)
10118 (if gnus-summary-display-article-function
10119 (funcall gnus-summary-display-article-function article all-header)
10120 (gnus-article-prepare article all-header))
10121 (run-hooks 'gnus-select-article-hook)
10122 (unless (zerop gnus-current-article)
10123 (gnus-summary-goto-subject gnus-current-article))
10124 (gnus-summary-recenter)
10125 (when gnus-use-trees
10126 (gnus-possibly-generate-tree article)
10127 (gnus-highlight-selected-tree article))
10128 ;; Successfully display article.
10129 (gnus-article-set-window-start
10130 (cdr (assq article gnus-newsgroup-bookmarks))))))
10132 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10133 "Select the current article.
10134 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10135 non-nil, the article will be re-fetched even if it already present in
10136 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10138 ;; Make sure we are in the summary buffer to work around bbdb bug.
10139 (unless (eq major-mode 'gnus-summary-mode)
10140 (set-buffer gnus-summary-buffer))
10141 (let ((article (or article (gnus-summary-article-number)))
10142 (all-headers (not (not all-headers))) ;Must be T or NIL.
10143 gnus-summary-display-article-function
10146 (gnus-summary-article-pseudo-p article)
10147 (error "This is a pseudo-article."))
10150 (set-buffer gnus-summary-buffer)
10151 (if (or (and gnus-single-article-buffer
10152 (or (null gnus-current-article)
10153 (null gnus-article-current)
10154 (null (get-buffer gnus-article-buffer))
10155 (not (eq article (cdr gnus-article-current)))
10156 (not (equal (car gnus-article-current)
10157 gnus-newsgroup-name))))
10158 (and (not gnus-single-article-buffer)
10159 (or (null gnus-current-article)
10160 (not (eq gnus-current-article article))))
10162 ;; The requested article is different from the current article.
10164 (gnus-summary-display-article article all-headers)
10165 (setq did article))
10166 (if (or all-headers gnus-show-all-headers)
10167 (gnus-article-show-all-headers))
10170 (gnus-article-set-window-start
10171 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10173 (defun gnus-summary-set-current-mark (&optional current-mark)
10174 "Obsolete function."
10177 (defun gnus-summary-next-article (&optional unread subject backward push)
10178 "Select the next article.
10179 If UNREAD, only unread articles are selected.
10180 If SUBJECT, only articles with SUBJECT are selected.
10181 If BACKWARD, the previous article is selected instead of the next."
10183 (gnus-set-global-variables)
10185 ;; Is there such an article?
10186 ((and (gnus-summary-search-forward unread subject backward)
10187 (or (gnus-summary-display-article (gnus-summary-article-number))
10188 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10189 (gnus-summary-position-point))
10190 ;; If not, we try the first unread, if that is wanted.
10192 gnus-auto-select-same
10193 (or (gnus-summary-first-unread-article)
10194 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10195 (gnus-summary-position-point)
10196 (gnus-message 6 "Wrapped"))
10197 ;; Try to get next/previous article not displayed in this group.
10198 ((and gnus-auto-extend-newsgroup
10199 (not unread) (not subject))
10200 (gnus-summary-goto-article
10201 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10203 ;; Go to next/previous group.
10205 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10206 (gnus-summary-jump-to-group gnus-newsgroup-name))
10207 (let ((cmd last-command-char)
10209 (if (eq gnus-keep-same-level 'best)
10210 (gnus-summary-best-group gnus-newsgroup-name)
10211 (gnus-summary-search-group backward gnus-keep-same-level))))
10212 ;; For some reason, the group window gets selected. We change
10214 (select-window (get-buffer-window (current-buffer)))
10215 ;; Select next unread newsgroup automagically.
10217 ((not gnus-auto-select-next)
10218 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10219 ((or (eq gnus-auto-select-next 'quietly)
10220 (and (eq gnus-auto-select-next 'slightly-quietly)
10222 (and (eq gnus-auto-select-next 'almost-quietly)
10223 (gnus-summary-last-article-p)))
10225 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10226 (gnus-summary-exit)
10227 (gnus-message 7 "No more%s articles (%s)..."
10228 (if unread " unread" "")
10229 (if group (concat "selecting " group)
10231 (gnus-summary-next-group nil group backward)))
10233 (gnus-summary-walk-group-buffer
10234 gnus-newsgroup-name cmd unread backward)))))))
10236 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10237 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10238 (?\C-p (gnus-group-prev-unread-group 1))))
10239 keve key group ended)
10241 (set-buffer gnus-group-buffer)
10242 (gnus-summary-jump-to-group from-group)
10244 (if (eq gnus-keep-same-level 'best)
10245 (gnus-summary-best-group gnus-newsgroup-name)
10246 (gnus-summary-search-group backward gnus-keep-same-level))))
10249 5 "No more%s articles%s" (if unread " unread" "")
10251 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10252 (format " (Type %s for %s [%s])"
10253 (single-key-description cmd) group
10254 (car (gnus-gethash group gnus-newsrc-hashtb)))
10255 (format " (Type %s to exit %s)"
10256 (single-key-description cmd)
10257 gnus-newsgroup-name)))
10258 ;; Confirm auto selection.
10259 (setq key (car (setq keve (gnus-read-event-char))))
10262 ((assq key keystrokes)
10263 (let ((obuf (current-buffer)))
10264 (switch-to-buffer gnus-group-buffer)
10266 (gnus-group-jump-to-group group))
10267 (eval (cadr (assq key keystrokes)))
10268 (setq group (gnus-group-group-name))
10269 (switch-to-buffer obuf))
10272 (if (or (not group)
10273 (gnus-ephemeral-group-p gnus-newsgroup-name))
10274 (gnus-summary-exit)
10275 (gnus-summary-next-group nil group backward)))
10277 (push (cdr keve) unread-command-events))))))
10279 (defun gnus-read-event-char ()
10280 "Get the next event."
10281 (let ((event (read-event)))
10282 (cons (and (numberp event) event) event)))
10284 (defun gnus-summary-next-unread-article ()
10285 "Select unread article after current one."
10287 (gnus-summary-next-article t (and gnus-auto-select-same
10288 (gnus-summary-article-subject))))
10290 (defun gnus-summary-prev-article (&optional unread subject)
10291 "Select the article after the current one.
10292 If UNREAD is non-nil, only unread articles are selected."
10294 (gnus-summary-next-article unread subject t))
10296 (defun gnus-summary-prev-unread-article ()
10297 "Select unred article before current one."
10299 (gnus-summary-prev-article t (and gnus-auto-select-same
10300 (gnus-summary-article-subject))))
10302 (defun gnus-summary-next-page (&optional lines circular)
10303 "Show next page of the selected article.
10304 If at the end of the current article, select the next article.
10305 LINES says how many lines should be scrolled up.
10307 If CIRCULAR is non-nil, go to the start of the article instead of
10308 selecting the next article when reaching the end of the current
10311 (setq gnus-summary-buffer (current-buffer))
10312 (gnus-set-global-variables)
10313 (let ((article (gnus-summary-article-number))
10315 (gnus-configure-windows 'article)
10316 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10317 (if (and (eq gnus-summary-goto-unread 'never)
10318 (not (gnus-summary-last-article-p article)))
10319 (gnus-summary-next-article)
10320 (gnus-summary-next-unread-article))
10321 (if (or (null gnus-current-article)
10322 (null gnus-article-current)
10323 (/= article (cdr gnus-article-current))
10324 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10325 ;; Selected subject is different from current article's.
10326 (gnus-summary-display-article article)
10327 (gnus-eval-in-buffer-window
10328 gnus-article-buffer
10329 (setq endp (gnus-article-next-page lines)))
10332 (gnus-summary-beginning-of-article))
10334 (gnus-message 3 "End of message"))
10336 (if (and (eq gnus-summary-goto-unread 'never)
10337 (not (gnus-summary-last-article-p article)))
10338 (gnus-summary-next-article)
10339 (gnus-summary-next-unread-article)))))))
10340 (gnus-summary-recenter)
10341 (gnus-summary-position-point)))
10343 (defun gnus-summary-prev-page (&optional lines)
10344 "Show previous page of selected article.
10345 Argument LINES specifies lines to be scrolled down."
10347 (gnus-set-global-variables)
10348 (let ((article (gnus-summary-article-number)))
10349 (gnus-configure-windows 'article)
10350 (if (or (null gnus-current-article)
10351 (null gnus-article-current)
10352 (/= article (cdr gnus-article-current))
10353 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10354 ;; Selected subject is different from current article's.
10355 (gnus-summary-display-article article)
10356 (gnus-summary-recenter)
10357 (gnus-eval-in-buffer-window gnus-article-buffer
10358 (gnus-article-prev-page lines))))
10359 (gnus-summary-position-point))
10361 (defun gnus-summary-scroll-up (lines)
10362 "Scroll up (or down) one line current article.
10363 Argument LINES specifies lines to be scrolled up (or down if negative)."
10365 (gnus-set-global-variables)
10366 (gnus-configure-windows 'article)
10367 (gnus-summary-show-thread)
10368 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10369 (gnus-eval-in-buffer-window
10370 gnus-article-buffer
10372 (if (gnus-article-next-page lines)
10373 (gnus-message 3 "End of message")))
10375 (gnus-article-prev-page (- lines))))))
10376 (gnus-summary-recenter)
10377 (gnus-summary-position-point))
10379 (defun gnus-summary-next-same-subject ()
10380 "Select next article which has the same subject as current one."
10382 (gnus-set-global-variables)
10383 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10385 (defun gnus-summary-prev-same-subject ()
10386 "Select previous article which has the same subject as current one."
10388 (gnus-set-global-variables)
10389 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10391 (defun gnus-summary-next-unread-same-subject ()
10392 "Select next unread article which has the same subject as current one."
10394 (gnus-set-global-variables)
10395 (gnus-summary-next-article t (gnus-summary-article-subject)))
10397 (defun gnus-summary-prev-unread-same-subject ()
10398 "Select previous unread article which has the same subject as current one."
10400 (gnus-set-global-variables)
10401 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10403 (defun gnus-summary-first-unread-article ()
10404 "Select the first unread article.
10405 Return nil if there are no unread articles."
10407 (gnus-set-global-variables)
10409 (if (gnus-summary-first-subject t)
10411 (gnus-summary-show-thread)
10412 (gnus-summary-first-subject t)
10413 (gnus-summary-display-article (gnus-summary-article-number))))
10414 (gnus-summary-position-point)))
10416 (defun gnus-summary-best-unread-article ()
10417 "Select the unread article with the highest score."
10419 (gnus-set-global-variables)
10420 (let ((best -1000000)
10421 (data gnus-newsgroup-data)
10424 (and (gnus-data-unread-p (car data))
10426 (gnus-summary-article-score (gnus-data-number (car data))))
10429 article (gnus-data-number (car data))))
10430 (setq data (cdr data)))
10433 (gnus-summary-goto-article article)
10434 (error "No unread articles"))
10435 (gnus-summary-position-point))))
10437 (defun gnus-summary-last-subject ()
10438 "Go to the last displayed subject line in the group."
10439 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10441 (gnus-summary-goto-subject article))))
10443 (defun gnus-summary-goto-article (article &optional all-headers force)
10444 "Fetch ARTICLE and display it if it exists.
10445 If ALL-HEADERS is non-nil, no header lines are hidden."
10451 (mapcar (lambda (number) (list (int-to-string number)))
10452 gnus-newsgroup-limit)))
10456 (if (gnus-summary-goto-subject article force)
10457 (gnus-summary-display-article article all-headers)
10458 (gnus-message 4 "Couldn't go to article %s" article) nil)
10459 (gnus-summary-position-point)))
10461 (defun gnus-summary-goto-last-article ()
10462 "Go to the previously read article."
10465 (and gnus-last-article
10466 (gnus-summary-goto-article gnus-last-article))
10467 (gnus-summary-position-point)))
10469 (defun gnus-summary-pop-article (number)
10470 "Pop one article off the history and go to the previous.
10471 NUMBER articles will be popped off."
10474 (setq gnus-newsgroup-history
10475 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10477 (gnus-summary-goto-article (car to))
10478 (error "Article history empty")))
10479 (gnus-summary-position-point))
10481 ;; Summary commands and functions for limiting the summary buffer.
10483 (defun gnus-summary-limit-to-articles (n)
10484 "Limit the summary buffer to the next N articles.
10485 If not given a prefix, use the process marked articles instead."
10487 (gnus-set-global-variables)
10489 (let ((articles (gnus-summary-work-articles n)))
10490 (setq gnus-newsgroup-processable nil)
10491 (gnus-summary-limit articles))
10492 (gnus-summary-position-point)))
10494 (defun gnus-summary-pop-limit (&optional total)
10495 "Restore the previous limit.
10496 If given a prefix, remove all limits."
10498 (gnus-set-global-variables)
10500 (setq gnus-newsgroup-limits
10501 (list (mapcar (lambda (h) (mail-header-number h))
10502 gnus-newsgroup-headers))))
10503 (unless gnus-newsgroup-limits
10504 (error "No limit to pop"))
10506 (gnus-summary-limit nil 'pop)
10507 (gnus-summary-position-point)))
10509 (defun gnus-summary-limit-to-subject (subject &optional header)
10510 "Limit the summary buffer to articles that have subjects that match a regexp."
10511 (interactive "sRegexp: ")
10513 (setq header "subject"))
10514 (when (not (equal "" subject))
10516 (let ((articles (gnus-summary-find-matching
10517 (or header "subject") subject 'all)))
10518 (or articles (error "Found no matches for \"%s\"" subject))
10519 (gnus-summary-limit articles))
10520 (gnus-summary-position-point))))
10522 (defun gnus-summary-limit-to-author (from)
10523 "Limit the summary buffer to articles that have authors that match a regexp."
10524 (interactive "sRegexp: ")
10525 (gnus-summary-limit-to-subject from "from"))
10527 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10529 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10531 (defun gnus-summary-limit-to-unread (&optional all)
10532 "Limit the summary buffer to articles that are not marked as read.
10533 If ALL is non-nil, limit strictly to unread articles."
10536 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10537 (gnus-summary-limit-to-marks
10538 ;; Concat all the marks that say that an article is read and have
10540 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10541 gnus-killed-mark gnus-kill-file-mark
10542 gnus-low-score-mark gnus-expirable-mark
10543 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10546 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10547 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10549 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10550 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10551 If REVERSE, limit the summary buffer to articles that are not marked
10552 with MARKS. MARKS can either be a string of marks or a list of marks.
10553 Returns how many articles were removed."
10554 (interactive "sMarks: ")
10555 (gnus-set-global-variables)
10557 (let ((data gnus-newsgroup-data)
10558 (marks (if (listp marks) marks
10559 (append marks nil))) ; Transform to list.
10562 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10563 (memq (gnus-data-mark (car data)) marks))
10564 (setq articles (cons (gnus-data-number (car data)) articles)))
10565 (setq data (cdr data)))
10566 (gnus-summary-limit articles))
10567 (gnus-summary-position-point)))
10569 (defun gnus-summary-limit-to-score (&optional score)
10570 "Limit to articles with score at or above SCORE."
10572 (gnus-set-global-variables)
10573 (setq score (if score
10574 (prefix-numeric-value score)
10575 (or gnus-summary-default-score 0)))
10576 (let ((data gnus-newsgroup-data)
10579 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10581 (push (gnus-data-number (car data)) articles))
10582 (setq data (cdr data)))
10584 (gnus-summary-limit articles)
10585 (gnus-summary-position-point))))
10587 (defun gnus-summary-limit-include-dormant ()
10588 "Display all the hidden articles that are marked as dormant."
10590 (gnus-set-global-variables)
10591 (or gnus-newsgroup-dormant
10592 (error "There are no dormant articles in this group"))
10594 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10595 (gnus-summary-position-point)))
10597 (defun gnus-summary-limit-exclude-dormant ()
10598 "Hide all dormant articles."
10600 (gnus-set-global-variables)
10602 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10603 (gnus-summary-position-point)))
10605 (defun gnus-summary-limit-exclude-childless-dormant ()
10606 "Hide all dormant articles that have no children."
10608 (gnus-set-global-variables)
10609 (let ((data (gnus-data-list t))
10610 articles d children)
10611 ;; Find all articles that are either not dormant or have
10613 (while (setq d (pop data))
10614 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10615 (and (setq children
10616 (gnus-article-children (gnus-data-number d)))
10619 (when (memq (car children) articles)
10624 (push (gnus-data-number d) articles)))
10625 ;; Do the limiting.
10627 (gnus-summary-limit articles)
10628 (gnus-summary-position-point))))
10630 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10631 "Mark all unread excluded articles as read.
10632 If ALL, mark even excluded ticked and dormants as read."
10634 (let ((articles (gnus-sorted-complement
10636 (mapcar (lambda (h) (mail-header-number h))
10637 gnus-newsgroup-headers)
10639 (sort gnus-newsgroup-limit '<)))
10641 (setq gnus-newsgroup-unreads nil)
10643 (setq gnus-newsgroup-dormant nil
10644 gnus-newsgroup-marked nil
10645 gnus-newsgroup-reads
10647 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10648 gnus-newsgroup-reads))
10649 (while (setq article (pop articles))
10650 (unless (or (memq article gnus-newsgroup-dormant)
10651 (memq article gnus-newsgroup-marked))
10652 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10654 (defun gnus-summary-limit (articles &optional pop)
10656 ;; We pop the previous limit off the stack and use that.
10657 (setq articles (car gnus-newsgroup-limits)
10658 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10659 ;; We use the new limit, so we push the old limit on the stack.
10660 (setq gnus-newsgroup-limits
10661 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10663 (setq gnus-newsgroup-limit articles)
10664 (let ((total (length gnus-newsgroup-data))
10665 (data (gnus-data-find-list (gnus-summary-article-number)))
10667 ;; This will do all the work of generating the new summary buffer
10668 ;; according to the new limit.
10669 (gnus-summary-prepare)
10670 ;; Hide any threads, possibly.
10671 (and gnus-show-threads
10672 gnus-thread-hide-subtree
10673 (gnus-summary-hide-all-threads))
10674 ;; Try to return to the article you were at, or one in the
10677 ;; We try to find some article after the current one.
10679 (and (gnus-summary-goto-subject
10680 (gnus-data-number (car data)) nil t)
10683 (setq data (cdr data))))
10685 ;; If there is no data, that means that we were after the last
10686 ;; article. The same goes when we can't find any articles
10687 ;; after the current one.
10689 (goto-char (point-max))
10690 (gnus-summary-find-prev)))
10691 ;; We return how many articles were removed from the summary
10692 ;; buffer as a result of the new limit.
10693 (- total (length gnus-newsgroup-data))))
10695 (defsubst gnus-cut-thread (thread)
10696 "Go forwards in the thread until we find an article that we want to display."
10697 (when (eq gnus-fetch-old-headers 'some)
10698 ;; Deal with old-fetched headers.
10700 (memq (mail-header-number (car thread))
10701 gnus-newsgroup-ancient)
10702 (<= (length (cdr thread)) 1))
10703 (setq thread (cadr thread))))
10704 ;; Deal with sparse threads.
10705 (when (or (eq gnus-build-sparse-threads 'some)
10706 (eq gnus-build-sparse-threads 'more))
10708 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10709 (= (length (cdr thread)) 1))
10710 (setq thread (cadr thread))))
10713 (defun gnus-cut-threads (threads)
10714 "Cut off all uninteresting articles from the beginning of threads."
10715 (when (or (eq gnus-fetch-old-headers 'some)
10716 (eq gnus-build-sparse-threads 'some)
10717 (eq gnus-build-sparse-threads 'more))
10718 (let ((th threads))
10720 (setcar th (gnus-cut-thread (car th)))
10721 (setq th (cdr th)))))
10722 ;; Remove nixed out threads.
10723 (delq nil threads))
10725 (defun gnus-summary-initial-limit (&optional show-if-empty)
10726 "Figure out what the initial limit is supposed to be on group entry.
10727 This entails weeding out unwanted dormants, low-scored articles,
10728 fetch-old-headers verbiage, and so on."
10729 ;; Most groups have nothing to remove.
10730 (if (or gnus-inhibit-limiting
10731 (and (null gnus-newsgroup-dormant)
10732 (not (eq gnus-fetch-old-headers 'some))
10733 (null gnus-summary-expunge-below)
10734 (not (eq gnus-build-sparse-threads 'some))
10735 (not (eq gnus-build-sparse-threads 'more))
10736 (null gnus-thread-expunge-below)
10737 (not gnus-use-nocem)))
10739 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10740 (setq gnus-newsgroup-limit nil)
10743 (unless (car (symbol-value node))
10744 ;; These threads have no parents -- they are roots.
10745 (let ((nodes (cdr (symbol-value node)))
10748 (if (and gnus-thread-expunge-below
10749 (< (gnus-thread-total-score (car nodes))
10750 gnus-thread-expunge-below))
10751 (gnus-expunge-thread (pop nodes))
10752 (setq thread (pop nodes))
10753 (gnus-summary-limit-children thread))))))
10754 gnus-newsgroup-dependencies)
10755 ;; If this limitation resulted in an empty group, we might
10756 ;; pop the previous limit and use it instead.
10757 (when (and (not gnus-newsgroup-limit)
10759 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10760 gnus-newsgroup-limit))
10762 (defun gnus-summary-limit-children (thread)
10763 "Return 1 if this subthread is visible and 0 if it is not."
10764 ;; First we get the number of visible children to this thread. This
10765 ;; is done by recursing down the thread using this function, so this
10766 ;; will really go down to a leaf article first, before slowly
10767 ;; working its way up towards the root.
10771 (apply '+ (mapcar 'gnus-summary-limit-children
10774 (number (mail-header-number (car thread)))
10777 ;; If this article is dormant and has absolutely no visible
10778 ;; children, then this article isn't visible.
10779 (and (memq number gnus-newsgroup-dormant)
10781 ;; If this is a "fetch-old-headered" and there is only one
10782 ;; visible child (or less), then we don't want this article.
10783 (and (eq gnus-fetch-old-headers 'some)
10784 (memq number gnus-newsgroup-ancient)
10786 ;; If this is a sparsely inserted article with no children,
10787 ;; we don't want it.
10788 (and (eq gnus-build-sparse-threads 'some)
10789 (memq number gnus-newsgroup-sparse)
10791 ;; If we use expunging, and this article is really
10792 ;; low-scored, then we don't want this article.
10793 (when (and gnus-summary-expunge-below
10795 (or (cdr (assq number gnus-newsgroup-scored))
10796 gnus-summary-default-score))
10797 gnus-summary-expunge-below))
10798 ;; We increase the expunge-tally here, but that has
10799 ;; nothing to do with the limits, really.
10800 (incf gnus-newsgroup-expunged-tally)
10801 ;; We also mark as read here, if that's wanted.
10802 (when (and gnus-summary-mark-below
10803 (< score gnus-summary-mark-below))
10804 (setq gnus-newsgroup-unreads
10805 (delq number gnus-newsgroup-unreads))
10806 (if gnus-newsgroup-auto-expire
10807 (push number gnus-newsgroup-expirable)
10808 (push (cons number gnus-low-score-mark)
10809 gnus-newsgroup-reads)))
10811 (and gnus-use-nocem
10812 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10813 ;; Nope, invisible article.
10815 ;; Ok, this article is to be visible, so we add it to the limit
10817 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10820 (defun gnus-expunge-thread (thread)
10821 "Mark all articles in THREAD as read."
10822 (let* ((number (mail-header-number (car thread))))
10823 (incf gnus-newsgroup-expunged-tally)
10824 ;; We also mark as read here, if that's wanted.
10825 (setq gnus-newsgroup-unreads
10826 (delq number gnus-newsgroup-unreads))
10827 (if gnus-newsgroup-auto-expire
10828 (push number gnus-newsgroup-expirable)
10829 (push (cons number gnus-low-score-mark)
10830 gnus-newsgroup-reads)))
10831 ;; Go recursively through all subthreads.
10832 (mapcar 'gnus-expunge-thread (cdr thread)))
10834 ;; Summary article oriented commands
10836 (defun gnus-summary-refer-parent-article (n)
10837 "Refer parent article N times.
10838 The difference between N and the number of articles fetched is returned."
10840 (gnus-set-global-variables)
10844 (let* ((header (gnus-summary-article-header))
10846 ;; If we try to find the parent of the currently
10847 ;; displayed article, then we take a look at the actual
10848 ;; References header, since this is slightly more
10849 ;; reliable than the References field we got from the
10851 (if (and (eq (mail-header-number header)
10852 (cdr gnus-article-current))
10853 (equal gnus-newsgroup-name
10854 (car gnus-article-current)))
10856 (set-buffer gnus-original-article-buffer)
10857 (nnheader-narrow-to-headers)
10859 (mail-fetch-field "references")
10861 ;; It's not the current article, so we take a bet on
10862 ;; the value we got from the server.
10863 (mail-header-references header))))
10864 (if (setq ref (or ref (mail-header-references header)))
10865 (or (gnus-summary-refer-article (gnus-parent-id ref))
10866 (gnus-message 1 "Couldn't find parent"))
10867 (gnus-message 1 "No references in article %d"
10868 (gnus-summary-article-number))
10871 (gnus-summary-position-point)
10874 (defun gnus-summary-refer-references ()
10875 "Fetch all articles mentioned in the References header.
10876 Return how many articles were fetched."
10878 (gnus-set-global-variables)
10879 (let ((ref (mail-header-references (gnus-summary-article-header)))
10880 (current (gnus-summary-article-number))
10882 ;; For each Message-ID in the References header...
10883 (while (string-match "<[^>]*>" ref)
10885 ;; ... fetch that article.
10886 (gnus-summary-refer-article
10887 (prog1 (match-string 0 ref)
10888 (setq ref (substring ref (match-end 0))))))
10889 (gnus-summary-goto-subject current)
10890 (gnus-summary-position-point)
10893 (defun gnus-summary-refer-article (message-id)
10894 "Fetch an article specified by MESSAGE-ID."
10895 (interactive "sMessage-ID: ")
10896 (when (and (stringp message-id)
10897 (not (zerop (length message-id))))
10898 ;; Construct the correct Message-ID if necessary.
10899 ;; Suggested by tale@pawl.rpi.edu.
10900 (unless (string-match "^<" message-id)
10901 (setq message-id (concat "<" message-id)))
10902 (unless (string-match ">$" message-id)
10903 (setq message-id (concat message-id ">")))
10904 (let ((header (car (gnus-gethash message-id
10905 gnus-newsgroup-dependencies))))
10907 ;; The article is present in the buffer, to we just go to it.
10908 (gnus-summary-goto-article (mail-header-number header) nil t)
10909 ;; We fetch the article
10910 (let ((gnus-override-method
10911 (and (gnus-news-group-p gnus-newsgroup-name)
10912 gnus-refer-article-method))
10914 ;; Start the special refer-article method, if necessary.
10915 (when (and gnus-refer-article-method
10916 (gnus-news-group-p gnus-newsgroup-name))
10917 (gnus-check-server gnus-refer-article-method))
10918 ;; Fetch the header, and display the article.
10919 (if (setq number (gnus-summary-insert-subject message-id))
10920 (gnus-summary-select-article nil nil nil number)
10921 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10923 (defun gnus-summary-enter-digest-group (&optional force)
10924 "Enter a digest group based on the current article."
10926 (gnus-set-global-variables)
10927 (gnus-summary-select-article)
10928 (let ((name (format "%s-%d"
10929 (gnus-group-prefixed-name
10930 gnus-newsgroup-name (list 'nndoc ""))
10931 gnus-current-article))
10932 (ogroup gnus-newsgroup-name)
10933 (case-fold-search t)
10934 (buf (current-buffer))
10937 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10938 (insert-buffer-substring gnus-original-article-buffer)
10940 (goto-char (point-min))
10941 (or (search-forward "\n\n" nil t) (point)))
10942 (goto-char (point-min))
10943 (delete-matching-lines "^\\(Path\\):\\|^From ")
10946 (if (gnus-group-read-ephemeral-group
10947 name `(nndoc ,name (nndoc-address
10949 (nndoc-article-type ,(if force 'digest 'guess))) t)
10950 ;; Make all postings to this group go to the parent group.
10951 (nconc (gnus-info-params (gnus-get-info name))
10952 (list (cons 'to-group ogroup)))
10953 ;; Couldn't select this doc group.
10954 (switch-to-buffer buf)
10955 (gnus-set-global-variables)
10956 (gnus-configure-windows 'summary)
10957 (gnus-message 3 "Article couldn't be entered?"))
10958 (kill-buffer dig))))
10960 (defun gnus-summary-isearch-article (&optional regexp-p)
10961 "Do incremental search forward on the current article.
10962 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10964 (gnus-set-global-variables)
10965 (gnus-summary-select-article)
10966 (gnus-configure-windows 'article)
10967 (gnus-eval-in-buffer-window
10968 gnus-article-buffer
10969 (goto-char (point-min))
10970 (isearch-forward regexp-p)))
10972 (defun gnus-summary-search-article-forward (regexp &optional backward)
10973 "Search for an article containing REGEXP forward.
10974 If BACKWARD, search backward instead."
10977 (format "Search article %s (regexp%s): "
10978 (if current-prefix-arg "backward" "forward")
10979 (if gnus-last-search-regexp
10980 (concat ", default " gnus-last-search-regexp)
10982 current-prefix-arg))
10983 (gnus-set-global-variables)
10984 (if (string-equal regexp "")
10985 (setq regexp (or gnus-last-search-regexp ""))
10986 (setq gnus-last-search-regexp regexp))
10987 (if (gnus-summary-search-article regexp backward)
10988 (gnus-article-set-window-start
10989 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10990 (error "Search failed: \"%s\"" regexp)))
10992 (defun gnus-summary-search-article-backward (regexp)
10993 "Search for an article containing REGEXP backward."
10996 (format "Search article backward (regexp%s): "
10997 (if gnus-last-search-regexp
10998 (concat ", default " gnus-last-search-regexp)
11000 (gnus-summary-search-article-forward regexp 'backward))
11002 (defun gnus-summary-search-article (regexp &optional backward)
11003 "Search for an article containing REGEXP.
11004 Optional argument BACKWARD means do search for backward.
11005 gnus-select-article-hook is not called during the search."
11006 (let ((gnus-select-article-hook nil) ;Disable hook.
11007 (gnus-article-display-hook nil)
11008 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11011 (function re-search-backward) (function re-search-forward)))
11014 ;; Hidden thread subtrees must be searched for ,too.
11015 (gnus-summary-show-all-threads)
11016 ;; First of all, search current article.
11017 ;; We don't want to read article again from NNTP server nor reset
11019 (gnus-summary-select-article)
11020 (gnus-message 9 "Searching article: %d..." gnus-current-article)
11021 (setq last gnus-current-article)
11022 (gnus-eval-in-buffer-window
11023 gnus-article-buffer
11026 ;; Begin search from current point.
11027 (setq found (funcall re-search regexp nil t))))
11028 ;; Then search next articles.
11029 (while (and (not found)
11030 (gnus-summary-display-article
11031 (if backward (gnus-summary-find-prev)
11032 (gnus-summary-find-next))))
11033 (gnus-message 9 "Searching article: %d..." gnus-current-article)
11034 (gnus-eval-in-buffer-window
11035 gnus-article-buffer
11038 (goto-char (if backward (point-max) (point-min)))
11039 (setq found (funcall re-search regexp nil t)))))
11041 ;; Adjust article pointer.
11042 (or (eq last gnus-current-article)
11043 (setq gnus-last-article last))
11044 ;; Return T if found such article.
11047 (defun gnus-summary-find-matching (header regexp &optional backward unread
11049 "Return a list of all articles that match REGEXP on HEADER.
11050 The search stars on the current article and goes forwards unless
11051 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11052 If UNREAD is non-nil, only unread articles will
11053 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11054 in the comparisons."
11055 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11056 (gnus-data-find-list
11057 (gnus-summary-article-number) (gnus-data-list backward))))
11058 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11059 (case-fold-search (not not-case-fold))
11061 (or (fboundp (intern (concat "mail-header-" header)))
11062 (error "%s is not a valid header" header))
11064 (setq d (car data))
11065 (and (or (not unread) ; We want all articles...
11066 (gnus-data-unread-p d)) ; Or just unreads.
11067 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11068 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11069 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11070 (setq data (cdr data)))
11071 (nreverse articles)))
11073 (defun gnus-summary-execute-command (header regexp command &optional backward)
11074 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11075 If HEADER is an empty string (or nil), the match is done on the entire
11076 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11078 (list (let ((completion-ignore-case t))
11081 (mapcar (lambda (string) (list string))
11082 '("Number" "Subject" "From" "Lines" "Date"
11083 "Message-ID" "Xref" "References" "Body"))
11084 nil 'require-match))
11085 (read-string "Regexp: ")
11086 (read-key-sequence "Command: ")
11087 current-prefix-arg))
11088 (when (equal header "Body")
11090 (gnus-set-global-variables)
11091 ;; Hidden thread subtrees must be searched as well.
11092 (gnus-summary-show-all-threads)
11093 ;; We don't want to change current point nor window configuration.
11095 (save-window-excursion
11096 (gnus-message 6 "Executing %s..." (key-description command))
11097 ;; We'd like to execute COMMAND interactively so as to give arguments.
11098 (gnus-execute header regexp
11099 `(lambda () (call-interactively ',(key-binding command)))
11101 (gnus-message 6 "Executing %s...done" (key-description command)))))
11103 (defun gnus-summary-beginning-of-article ()
11104 "Scroll the article back to the beginning."
11106 (gnus-set-global-variables)
11107 (gnus-summary-select-article)
11108 (gnus-configure-windows 'article)
11109 (gnus-eval-in-buffer-window
11110 gnus-article-buffer
11112 (goto-char (point-min))
11113 (and gnus-break-pages (gnus-narrow-to-page))))
11115 (defun gnus-summary-end-of-article ()
11116 "Scroll to the end of the article."
11118 (gnus-set-global-variables)
11119 (gnus-summary-select-article)
11120 (gnus-configure-windows 'article)
11121 (gnus-eval-in-buffer-window
11122 gnus-article-buffer
11124 (goto-char (point-max))
11126 (and gnus-break-pages (gnus-narrow-to-page))))
11128 (defun gnus-summary-show-article (&optional arg)
11129 "Force re-fetching of the current article.
11130 If ARG (the prefix) is non-nil, show the raw article without any
11131 article massaging functions being run."
11133 (gnus-set-global-variables)
11135 ;; Select the article the normal way.
11136 (gnus-summary-select-article nil 'force)
11137 ;; Bind the article treatment functions to nil.
11138 (let ((gnus-have-all-headers t)
11139 gnus-article-display-hook
11140 gnus-article-prepare-hook
11143 (gnus-summary-select-article nil 'force)))
11144 (gnus-summary-goto-subject gnus-current-article)
11145 ; (gnus-configure-windows 'article)
11146 (gnus-summary-position-point))
11148 (defun gnus-summary-verbose-headers (&optional arg)
11149 "Toggle permanent full header display.
11150 If ARG is a positive number, turn header display on.
11151 If ARG is a negative number, turn header display off."
11153 (gnus-set-global-variables)
11154 (gnus-summary-toggle-header arg)
11155 (setq gnus-show-all-headers
11156 (cond ((or (not (numberp arg))
11158 (not gnus-show-all-headers))
11162 (defun gnus-summary-toggle-header (&optional arg)
11163 "Show the headers if they are hidden, or hide them if they are shown.
11164 If ARG is a positive number, show the entire header.
11165 If ARG is a negative number, hide the unwanted header lines."
11167 (gnus-set-global-variables)
11169 (set-buffer gnus-article-buffer)
11170 (let* ((buffer-read-only nil)
11171 (inhibit-point-motion-hooks t)
11172 (hidden (text-property-any
11173 (goto-char (point-min)) (search-forward "\n\n")
11176 (goto-char (point-min))
11177 (when (search-forward "\n\n" nil t)
11178 (delete-region (point-min) (1- (point))))
11179 (goto-char (point-min))
11181 (set-buffer gnus-original-article-buffer)
11182 (goto-char (point-min))
11183 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11184 (insert-buffer-substring gnus-original-article-buffer 1 e)
11185 (let ((gnus-inhibit-hiding t))
11186 (run-hooks 'gnus-article-display-hook))
11187 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11188 (gnus-article-hide-headers)))))
11190 (defun gnus-summary-show-all-headers ()
11191 "Make all header lines visible."
11193 (gnus-set-global-variables)
11194 (gnus-article-show-all-headers))
11196 (defun gnus-summary-toggle-mime (&optional arg)
11197 "Toggle MIME processing.
11198 If ARG is a positive number, turn MIME processing on."
11200 (gnus-set-global-variables)
11201 (setq gnus-show-mime
11202 (if (null arg) (not gnus-show-mime)
11203 (> (prefix-numeric-value arg) 0)))
11204 (gnus-summary-select-article t 'force))
11206 (defun gnus-summary-caesar-message (&optional arg)
11207 "Caesar rotate the current article by 13.
11208 The numerical prefix specifies how manu places to rotate each letter
11211 (gnus-set-global-variables)
11212 (gnus-summary-select-article)
11213 (let ((mail-header-separator ""))
11214 (gnus-eval-in-buffer-window
11215 gnus-article-buffer
11218 (let ((start (window-start)))
11219 (news-caesar-buffer-body arg)
11220 (set-window-start (get-buffer-window (current-buffer)) start))))))
11222 (defun gnus-summary-stop-page-breaking ()
11223 "Stop page breaking in the current article."
11225 (gnus-set-global-variables)
11226 (gnus-summary-select-article)
11227 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11229 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11230 "Move the current article to a different newsgroup.
11231 If N is a positive number, move the N next articles.
11232 If N is a negative number, move the N previous articles.
11233 If N is nil and any articles have been marked with the process mark,
11234 move those articles instead.
11235 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11236 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11237 re-spool using this method.
11239 For this function to work, both the current newsgroup and the
11240 newsgroup that you want to move to have to support the `request-move'
11241 and `request-accept' functions."
11243 (unless action (setq action 'move))
11244 (gnus-set-global-variables)
11245 ;; Check whether the source group supports the required functions.
11246 (cond ((and (eq action 'move)
11247 (not (gnus-check-backend-function
11248 'request-move-article gnus-newsgroup-name)))
11249 (error "The current group does not support article moving"))
11250 ((and (eq action 'crosspost)
11251 (not (gnus-check-backend-function
11252 'request-replace-article gnus-newsgroup-name)))
11253 (error "The current group does not support article editing")))
11254 (let ((articles (gnus-summary-work-articles n))
11255 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11256 (names '((move "Move" "Moving")
11257 (copy "Copy" "Copying")
11258 (crosspost "Crosspost" "Crossposting")))
11259 (copy-buf (save-excursion
11260 (nnheader-set-temp-buffer " *copy article*")))
11261 art-group to-method new-xref article to-groups)
11262 (unless (assq action names)
11263 (error "Unknown action %s" action))
11264 ;; Read the newsgroup name.
11265 (when (and (not to-newsgroup)
11266 (not select-method))
11268 (gnus-read-move-group-name
11269 (cadr (assq action names))
11270 (symbol-value (intern (format "gnus-current-%s-group" action)))
11272 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11273 (setq to-method (or select-method
11274 (gnus-find-method-for-group to-newsgroup)))
11275 ;; Check the method we are to move this article to...
11276 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11277 (error "%s does not support article copying" (car to-method)))
11278 (or (gnus-check-server to-method)
11279 (error "Can't open server %s" (car to-method)))
11280 (gnus-message 6 "%s to %s: %s..."
11281 (caddr (assq action names))
11282 (or (car select-method) to-newsgroup) articles)
11284 (setq article (pop articles))
11288 ;; Move the article.
11290 (gnus-request-move-article
11291 article ; Article to move
11292 gnus-newsgroup-name ; From newsgrouo
11293 (nth 1 (gnus-find-method-for-group
11294 gnus-newsgroup-name)) ; Server
11295 (list 'gnus-request-accept-article
11296 to-newsgroup (list 'quote select-method)
11297 (not articles)) ; Accept form
11298 (not articles))) ; Only save nov last time
11299 ;; Copy the article.
11302 (set-buffer copy-buf)
11303 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11304 (gnus-request-accept-article
11305 to-newsgroup select-method (not articles))))
11306 ;; Crosspost the article.
11307 ((eq action 'crosspost)
11308 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11309 (setq new-xref (concat gnus-newsgroup-name ":" article))
11310 (if (and xref (not (string= xref "")))
11312 (when (string-match "^Xref: " xref)
11313 (setq xref (substring xref (match-end 0))))
11314 (setq new-xref (concat xref " " new-xref)))
11315 (setq new-xref (concat (system-name) " " new-xref)))
11317 (set-buffer copy-buf)
11318 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11319 (nnheader-replace-header "xref" new-xref)
11320 (gnus-request-accept-article
11321 to-newsgroup select-method (not articles)))))))
11322 (if (not art-group)
11323 (gnus-message 1 "Couldn't %s article %s"
11324 (cadr (assq action names)) article)
11327 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11329 (gnus-group-prefixed-name
11332 (gnus-find-method-for-group to-newsgroup)))
11333 gnus-newsrc-hashtb)))
11334 (info (nth 2 entry))
11335 (to-group (gnus-info-group info)))
11336 ;; Update the group that has been moved to.
11338 (memq action '(move copy)))
11339 (unless (member to-group to-groups)
11340 (push to-group to-groups))
11342 (unless (memq article gnus-newsgroup-unreads)
11343 (gnus-info-set-read
11344 info (gnus-add-to-range (gnus-info-read info)
11345 (list (cdr art-group)))))
11347 ;; Copy any marks over to the new group.
11348 (let ((marks gnus-article-mark-lists)
11349 (to-article (cdr art-group)))
11351 ;; See whether the article is to be put in the cache.
11352 (when gnus-use-cache
11353 (gnus-cache-possibly-enter-article
11354 to-group to-article
11355 (let ((header (copy-sequence
11356 (gnus-summary-article-header article))))
11357 (mail-header-set-number header to-article)
11359 (memq article gnus-newsgroup-marked)
11360 (memq article gnus-newsgroup-dormant)
11361 (memq article gnus-newsgroup-unreads)))
11364 (when (memq article (symbol-value
11365 (intern (format "gnus-newsgroup-%s"
11367 ;; If the other group is the same as this group,
11368 ;; then we have to add the mark to the list.
11369 (when (equal to-group gnus-newsgroup-name)
11370 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11373 (intern (format "gnus-newsgroup-%s"
11375 ;; Copy mark to other group.
11376 (gnus-add-marked-articles
11377 to-group (cdar marks) (list to-article) info))
11378 (setq marks (cdr marks)))))
11380 ;; Update the Xref header in this article to point to
11381 ;; the new crossposted article we have just created.
11382 (when (eq action 'crosspost)
11384 (set-buffer copy-buf)
11385 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11386 (nnheader-replace-header
11387 "xref" (concat new-xref " " (gnus-group-prefixed-name
11388 (car art-group) to-method)
11389 ":" (cdr art-group)))
11390 (gnus-request-replace-article
11391 article gnus-newsgroup-name (current-buffer)))))
11393 (gnus-summary-goto-subject article)
11394 (when (eq action 'move)
11395 (gnus-summary-mark-article article gnus-canceled-mark)))
11396 (gnus-summary-remove-process-mark article))
11397 ;; Re-activate all groups that have been moved to.
11399 (gnus-activate-group (pop to-groups)))
11401 (gnus-kill-buffer copy-buf)
11402 (gnus-summary-position-point)
11403 (gnus-set-mode-line 'summary)))
11405 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11406 "Move the current article to a different newsgroup.
11407 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11408 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11409 re-spool using this method."
11411 (gnus-summary-move-article n nil select-method 'copy))
11413 (defun gnus-summary-crosspost-article (&optional n)
11414 "Crosspost the current article to some other group."
11416 (gnus-summary-move-article n nil nil 'crosspost))
11418 (defvar gnus-summary-respool-default-method nil
11419 "Default method for respooling an article.
11420 If nil, use to the current newsgroup method.")
11422 (defun gnus-summary-respool-article (&optional n method)
11423 "Respool the current article.
11424 The article will be squeezed through the mail spooling process again,
11425 which means that it will be put in some mail newsgroup or other
11426 depending on `nnmail-split-methods'.
11427 If N is a positive number, respool the N next articles.
11428 If N is a negative number, respool the N previous articles.
11429 If N is nil and any articles have been marked with the process mark,
11430 respool those articles instead.
11432 Respooling can be done both from mail groups and \"real\" newsgroups.
11433 In the former case, the articles in question will be moved from the
11434 current group into whatever groups they are destined to. In the
11435 latter case, they will be copied into the relevant groups."
11437 (list current-prefix-arg
11438 (let* ((methods (gnus-methods-using 'respool))
11440 (symbol-name (or gnus-summary-respool-default-method
11441 (car (gnus-find-method-for-group
11442 gnus-newsgroup-name)))))
11444 (gnus-completing-read
11445 methname "What backend do you want to use when? "
11446 methods nil t nil 'gnus-method-history))
11449 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11450 (list (intern method) ""))
11454 (cdr (completing-read
11456 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11457 (gnus-set-global-variables)
11459 (error "No method given for respooling"))
11460 (if (assoc (symbol-name
11461 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11462 (gnus-methods-using 'respool))
11463 (gnus-summary-move-article n nil method)
11464 (gnus-summary-copy-article n nil method)))
11466 (defun gnus-summary-import-article (file)
11467 "Import a random file into a mail newsgroup."
11468 (interactive "fImport file: ")
11469 (gnus-set-global-variables)
11470 (let ((group gnus-newsgroup-name)
11471 (now (current-time))
11473 (or (gnus-check-backend-function 'request-accept-article group)
11474 (error "%s does not support article importing" group))
11475 (or (file-readable-p file)
11476 (not (file-regular-p file))
11477 (error "Can't read %s" file))
11479 (set-buffer (get-buffer-create " *import file*"))
11480 (buffer-disable-undo (current-buffer))
11482 (insert-file-contents file)
11483 (goto-char (point-min))
11484 (unless (nnheader-article-p)
11485 ;; This doesn't look like an article, so we fudge some headers.
11486 (setq atts (file-attributes file)
11487 lines (count-lines (point-min) (point-max)))
11488 (insert "From: " (read-string "From: ") "\n"
11489 "Subject: " (read-string "Subject: ") "\n"
11490 "Date: " (timezone-make-date-arpa-standard
11491 (current-time-string (nth 5 atts))
11492 (current-time-zone now)
11493 (current-time-zone now)) "\n"
11494 "Message-ID: " (gnus-inews-message-id) "\n"
11495 "Lines: " (int-to-string lines) "\n"
11496 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11497 (gnus-request-accept-article group nil t)
11498 (kill-buffer (current-buffer)))))
11500 (defun gnus-summary-expire-articles (&optional now)
11501 "Expire all articles that are marked as expirable in the current group."
11503 (gnus-set-global-variables)
11504 (when (gnus-check-backend-function
11505 'request-expire-articles gnus-newsgroup-name)
11506 ;; This backend supports expiry.
11507 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11508 (expirable (if total
11509 (gnus-list-of-read-articles gnus-newsgroup-name)
11510 (setq gnus-newsgroup-expirable
11511 (sort gnus-newsgroup-expirable '<))))
11512 (expiry-wait (if now 'immediate
11513 (gnus-group-get-parameter
11514 gnus-newsgroup-name 'expiry-wait)))
11517 ;; There are expirable articles in this group, so we run them
11518 ;; through the expiry process.
11519 (gnus-message 6 "Expiring articles...")
11520 ;; The list of articles that weren't expired is returned.
11522 (let ((nnmail-expiry-wait-function nil)
11523 (nnmail-expiry-wait expiry-wait))
11524 (setq es (gnus-request-expire-articles
11525 expirable gnus-newsgroup-name)))
11526 (setq es (gnus-request-expire-articles
11527 expirable gnus-newsgroup-name)))
11528 (or total (setq gnus-newsgroup-expirable es))
11529 ;; We go through the old list of expirable, and mark all
11530 ;; really expired articles as nonexistent.
11531 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11532 (let ((gnus-use-cache nil))
11534 (unless (memq (car expirable) es)
11535 (when (gnus-data-find (car expirable))
11536 (gnus-summary-mark-article
11537 (car expirable) gnus-canceled-mark)))
11538 (setq expirable (cdr expirable)))))
11539 (gnus-message 6 "Expiring articles...done")))))
11541 (defun gnus-summary-expire-articles-now ()
11542 "Expunge all expirable articles in the current group.
11543 This means that *all* articles that are marked as expirable will be
11544 deleted forever, right now."
11546 (gnus-set-global-variables)
11547 (or gnus-expert-user
11549 "Are you really, really, really sure you want to delete all these messages? ")
11551 (gnus-summary-expire-articles t))
11553 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11554 (defun gnus-summary-delete-article (&optional n)
11555 "Delete the N next (mail) articles.
11556 This command actually deletes articles. This is not a marking
11557 command. The article will disappear forever from your life, never to
11559 If N is negative, delete backwards.
11560 If N is nil and articles have been marked with the process mark,
11561 delete these instead."
11563 (gnus-set-global-variables)
11564 (or (gnus-check-backend-function 'request-expire-articles
11565 gnus-newsgroup-name)
11566 (error "The current newsgroup does not support article deletion."))
11567 ;; Compute the list of articles to delete.
11568 (let ((articles (gnus-summary-work-articles n))
11570 (if (and gnus-novice-user
11571 (not (gnus-y-or-n-p
11572 (format "Do you really want to delete %s forever? "
11573 (if (> (length articles) 1)
11574 (format "these %s articles" (length articles))
11575 "this article")))))
11577 ;; Delete the articles.
11578 (setq not-deleted (gnus-request-expire-articles
11579 articles gnus-newsgroup-name 'force))
11581 (gnus-summary-remove-process-mark (car articles))
11582 ;; The backend might not have been able to delete the article
11584 (or (memq (car articles) not-deleted)
11585 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11586 (setq articles (cdr articles))))
11587 (gnus-summary-position-point)
11588 (gnus-set-mode-line 'summary)
11591 (defun gnus-summary-edit-article (&optional force)
11592 "Enter into a buffer and edit the current article.
11593 This will have permanent effect only in mail groups.
11594 If FORCE is non-nil, allow editing of articles even in read-only
11598 (set-buffer gnus-summary-buffer)
11599 (gnus-set-global-variables)
11600 (when (and (not force)
11601 (gnus-group-read-only-p))
11602 (error "The current newsgroup does not support article editing."))
11603 (gnus-summary-select-article t nil t)
11604 (gnus-configure-windows 'article)
11605 (select-window (get-buffer-window gnus-article-buffer))
11606 (gnus-message 6 "C-c C-c to end edits")
11607 (setq buffer-read-only nil)
11609 (use-local-map (copy-keymap (current-local-map)))
11610 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11611 (buffer-enable-undo)
11613 (goto-char (point-min))
11614 (search-forward "\n\n" nil t)))
11616 (defun gnus-summary-edit-article-done ()
11617 "Make edits to the current article permanent."
11619 (if (gnus-group-read-only-p)
11621 (gnus-summary-edit-article-postpone)
11623 1 "The current newsgroup does not support article editing."))
11624 (let ((buf (format "%s" (buffer-string))))
11627 (if (not (gnus-request-replace-article
11628 (cdr gnus-article-current) (car gnus-article-current)
11630 (error "Couldn't replace article.")
11631 (gnus-article-mode)
11632 (use-local-map gnus-article-mode-map)
11633 (setq buffer-read-only t)
11634 (buffer-disable-undo (current-buffer))
11635 (gnus-configure-windows 'summary)
11636 (gnus-summary-update-article (cdr gnus-article-current))
11637 (when gnus-use-cache
11638 (gnus-cache-update-article
11639 (cdr gnus-article-current) (car gnus-article-current)))
11640 (when gnus-keep-backlog
11641 (gnus-backlog-remove-article
11642 (car gnus-article-current) (cdr gnus-article-current))))
11644 (when (get-buffer gnus-original-article-buffer)
11645 (set-buffer gnus-original-article-buffer)
11646 (setq gnus-original-article nil)))
11647 (setq gnus-article-current nil
11648 gnus-current-article nil)
11649 (run-hooks 'gnus-article-display-hook)
11650 (and (gnus-visual-p 'summary-highlight 'highlight)
11651 (run-hooks 'gnus-visual-mark-article-hook)))))
11653 (defun gnus-summary-edit-article-postpone ()
11654 "Postpone changes to the current article."
11656 (gnus-article-mode)
11657 (use-local-map gnus-article-mode-map)
11658 (setq buffer-read-only t)
11659 (buffer-disable-undo (current-buffer))
11660 (gnus-configure-windows 'summary)
11661 (and (gnus-visual-p 'summary-highlight 'highlight)
11662 (run-hooks 'gnus-visual-mark-article-hook)))
11664 (defun gnus-summary-respool-query ()
11665 "Query where the respool algorithm would put this article."
11667 (gnus-set-global-variables)
11668 (gnus-summary-select-article)
11670 (set-buffer gnus-article-buffer)
11672 (goto-char (point-min))
11673 (search-forward "\n\n")
11674 (narrow-to-region (point-min) (point))
11675 (pp-eval-expression
11676 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11678 ;; Summary score commands.
11680 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11682 (defun gnus-summary-raise-score (n)
11683 "Raise the score of the current article by N."
11685 (gnus-set-global-variables)
11686 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11688 (defun gnus-summary-set-score (n)
11689 "Set the score of the current article to N."
11691 (gnus-set-global-variables)
11693 (gnus-summary-show-thread)
11694 (let ((buffer-read-only nil))
11696 (gnus-summary-update-mark
11697 (if (= n (or gnus-summary-default-score 0)) ?
11698 (if (< n (or gnus-summary-default-score 0))
11699 gnus-score-below-mark gnus-score-over-mark)) 'score))
11700 (let* ((article (gnus-summary-article-number))
11701 (score (assq article gnus-newsgroup-scored)))
11702 (if score (setcdr score n)
11703 (setq gnus-newsgroup-scored
11704 (cons (cons article n) gnus-newsgroup-scored))))
11705 (gnus-summary-update-line)))
11707 (defun gnus-summary-current-score ()
11708 "Return the score of the current article."
11710 (gnus-set-global-variables)
11711 (gnus-message 1 "%s" (gnus-summary-article-score)))
11713 ;; Summary marking commands.
11715 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11716 "Mark articles which has the same subject as read, and then select the next.
11717 If UNMARK is positive, remove any kind of mark.
11718 If UNMARK is negative, tick articles."
11720 (gnus-set-global-variables)
11722 (setq unmark (prefix-numeric-value unmark)))
11724 (gnus-summary-mark-same-subject
11725 (gnus-summary-article-subject) unmark)))
11726 ;; Select next unread article. If auto-select-same mode, should
11727 ;; select the first unread article.
11728 (gnus-summary-next-article t (and gnus-auto-select-same
11729 (gnus-summary-article-subject)))
11730 (gnus-message 7 "%d article%s marked as %s"
11731 count (if (= count 1) " is" "s are")
11732 (if unmark "unread" "read"))))
11734 (defun gnus-summary-kill-same-subject (&optional unmark)
11735 "Mark articles which has the same subject as read.
11736 If UNMARK is positive, remove any kind of mark.
11737 If UNMARK is negative, tick articles."
11739 (gnus-set-global-variables)
11741 (setq unmark (prefix-numeric-value unmark)))
11743 (gnus-summary-mark-same-subject
11744 (gnus-summary-article-subject) unmark)))
11745 ;; If marked as read, go to next unread subject.
11747 ;; Go to next unread subject.
11748 (gnus-summary-next-subject 1 t))
11749 (gnus-message 7 "%d articles are marked as %s"
11750 count (if unmark "unread" "read"))))
11752 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11753 "Mark articles with same SUBJECT as read, and return marked number.
11754 If optional argument UNMARK is positive, remove any kinds of marks.
11755 If optional argument UNMARK is negative, mark articles as unread instead."
11759 ((null unmark) ; Mark as read.
11762 (gnus-summary-mark-article-as-read gnus-killed-mark)
11763 (gnus-summary-show-thread) t)
11764 (gnus-summary-find-subject subject))
11765 (setq count (1+ count))))
11766 ((> unmark 0) ; Tick.
11769 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11770 (gnus-summary-show-thread) t)
11771 (gnus-summary-find-subject subject))
11772 (setq count (1+ count))))
11773 (t ; Mark as unread.
11776 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11777 (gnus-summary-show-thread) t)
11778 (gnus-summary-find-subject subject))
11779 (setq count (1+ count)))))
11780 (gnus-set-mode-line 'summary)
11781 ;; Return the number of marked articles.
11784 (defun gnus-summary-mark-as-processable (n &optional unmark)
11785 "Set the process mark on the next N articles.
11786 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11787 the process mark instead. The difference between N and the actual
11788 number of articles marked is returned."
11790 (gnus-set-global-variables)
11791 (let ((backward (< n 0))
11796 (gnus-summary-remove-process-mark
11797 (gnus-summary-article-number))
11798 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11799 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11801 (if (/= 0 n) (gnus-message 7 "No more articles"))
11802 (gnus-summary-recenter)
11803 (gnus-summary-position-point)
11806 (defun gnus-summary-unmark-as-processable (n)
11807 "Remove the process mark from the next N articles.
11808 If N is negative, mark backward instead. The difference between N and
11809 the actual number of articles marked is returned."
11811 (gnus-set-global-variables)
11812 (gnus-summary-mark-as-processable n t))
11814 (defun gnus-summary-unmark-all-processable ()
11815 "Remove the process mark from all articles."
11817 (gnus-set-global-variables)
11819 (while gnus-newsgroup-processable
11820 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11821 (gnus-summary-position-point))
11823 (defun gnus-summary-mark-as-expirable (n)
11824 "Mark N articles forward as expirable.
11825 If N is negative, mark backward instead. The difference between N and
11826 the actual number of articles marked is returned."
11828 (gnus-set-global-variables)
11829 (gnus-summary-mark-forward n gnus-expirable-mark))
11831 (defun gnus-summary-mark-article-as-replied (article)
11832 "Mark ARTICLE replied and update the summary line."
11833 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11834 (let ((buffer-read-only nil))
11835 (when (gnus-summary-goto-subject article)
11836 (gnus-summary-update-secondary-mark article))))
11838 (defun gnus-summary-set-bookmark (article)
11839 "Set a bookmark in current article."
11840 (interactive (list (gnus-summary-article-number)))
11841 (gnus-set-global-variables)
11842 (if (or (not (get-buffer gnus-article-buffer))
11843 (not gnus-current-article)
11844 (not gnus-article-current)
11845 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11846 (error "No current article selected"))
11847 ;; Remove old bookmark, if one exists.
11848 (let ((old (assq article gnus-newsgroup-bookmarks)))
11849 (if old (setq gnus-newsgroup-bookmarks
11850 (delq old gnus-newsgroup-bookmarks))))
11851 ;; Set the new bookmark, which is on the form
11852 ;; (article-number . line-number-in-body).
11853 (setq gnus-newsgroup-bookmarks
11857 (set-buffer gnus-article-buffer)
11861 (goto-char (point-min))
11862 (search-forward "\n\n" nil t)
11865 gnus-newsgroup-bookmarks))
11866 (gnus-message 6 "A bookmark has been added to the current article."))
11868 (defun gnus-summary-remove-bookmark (article)
11869 "Remove the bookmark from the current article."
11870 (interactive (list (gnus-summary-article-number)))
11871 (gnus-set-global-variables)
11872 ;; Remove old bookmark, if one exists.
11873 (let ((old (assq article gnus-newsgroup-bookmarks)))
11876 (setq gnus-newsgroup-bookmarks
11877 (delq old gnus-newsgroup-bookmarks))
11878 (gnus-message 6 "Removed bookmark."))
11879 (gnus-message 6 "No bookmark in current article."))))
11881 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11882 (defun gnus-summary-mark-as-dormant (n)
11883 "Mark N articles forward as dormant.
11884 If N is negative, mark backward instead. The difference between N and
11885 the actual number of articles marked is returned."
11887 (gnus-set-global-variables)
11888 (gnus-summary-mark-forward n gnus-dormant-mark))
11890 (defun gnus-summary-set-process-mark (article)
11891 "Set the process mark on ARTICLE and update the summary line."
11892 (setq gnus-newsgroup-processable
11894 (delq article gnus-newsgroup-processable)))
11895 (when (gnus-summary-goto-subject article)
11896 (gnus-summary-show-thread)
11897 (gnus-summary-update-secondary-mark article)))
11899 (defun gnus-summary-remove-process-mark (article)
11900 "Remove the process mark from ARTICLE and update the summary line."
11901 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11902 (when (gnus-summary-goto-subject article)
11903 (gnus-summary-show-thread)
11904 (gnus-summary-update-secondary-mark article)))
11906 (defun gnus-summary-set-saved-mark (article)
11907 "Set the process mark on ARTICLE and update the summary line."
11908 (push article gnus-newsgroup-saved)
11909 (when (gnus-summary-goto-subject article)
11910 (gnus-summary-update-secondary-mark article)))
11912 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11913 "Mark N articles as read forwards.
11914 If N is negative, mark backwards instead.
11915 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11917 The difference between N and the actual number of articles marked is
11920 (gnus-set-global-variables)
11921 (let ((backward (< n 0))
11922 (gnus-summary-goto-unread
11923 (and gnus-summary-goto-unread
11924 (not (eq gnus-summary-goto-unread 'never))
11925 (not (memq mark (list gnus-unread-mark
11926 gnus-ticked-mark gnus-dormant-mark)))))
11928 (mark (or mark gnus-del-mark)))
11929 (while (and (> n 0)
11930 (gnus-summary-mark-article nil mark no-expire)
11931 (zerop (gnus-summary-next-subject
11933 (and gnus-summary-goto-unread
11934 (not (eq gnus-summary-goto-unread 'never)))
11937 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11938 (gnus-summary-recenter)
11939 (gnus-summary-position-point)
11940 (gnus-set-mode-line 'summary)
11943 (defun gnus-summary-mark-article-as-read (mark)
11944 "Mark the current article quickly as read with MARK."
11945 (let ((article (gnus-summary-article-number)))
11946 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11947 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11948 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11949 (setq gnus-newsgroup-reads
11950 (cons (cons article mark) gnus-newsgroup-reads))
11951 ;; Possibly remove from cache, if that is used.
11952 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11953 ;; Allow the backend to change the mark.
11954 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11955 ;; Check for auto-expiry.
11956 (when (and gnus-newsgroup-auto-expire
11957 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11958 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11959 (= mark gnus-ancient-mark)
11960 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11961 (setq mark gnus-expirable-mark)
11962 (push article gnus-newsgroup-expirable))
11963 ;; Set the mark in the buffer.
11964 (gnus-summary-update-mark mark 'unread)
11967 (defun gnus-summary-mark-article-as-unread (mark)
11968 "Mark the current article quickly as unread with MARK."
11969 (let ((article (gnus-summary-article-number)))
11970 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11971 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11972 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11973 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11974 (cond ((= mark gnus-ticked-mark)
11975 (push article gnus-newsgroup-marked))
11976 ((= mark gnus-dormant-mark)
11977 (push article gnus-newsgroup-dormant))
11979 (push article gnus-newsgroup-unreads)))
11980 (setq gnus-newsgroup-reads
11981 (delq (assq article gnus-newsgroup-reads)
11982 gnus-newsgroup-reads))
11984 ;; See whether the article is to be put in the cache.
11985 (and gnus-use-cache
11986 (vectorp (gnus-summary-article-header article))
11988 (gnus-cache-possibly-enter-article
11989 gnus-newsgroup-name article
11990 (gnus-summary-article-header article)
11991 (= mark gnus-ticked-mark)
11992 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11995 (gnus-summary-update-mark mark 'unread)
11998 (defun gnus-summary-mark-article (&optional article mark no-expire)
11999 "Mark ARTICLE with MARK. MARK can be any character.
12000 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12001 `??' (dormant) and `?E' (expirable).
12002 If MARK is nil, then the default character `?D' is used.
12003 If ARTICLE is nil, then the article on the current line will be
12005 ;; The mark might be a string.
12006 (and (stringp mark)
12007 (setq mark (aref mark 0)))
12008 ;; If no mark is given, then we check auto-expiring.
12009 (and (not no-expire)
12010 gnus-newsgroup-auto-expire
12012 (and (numberp mark)
12013 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12014 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12015 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12016 (setq mark gnus-expirable-mark))
12017 (let* ((mark (or mark gnus-del-mark))
12018 (article (or article (gnus-summary-article-number))))
12019 (or article (error "No article on current line"))
12020 (if (or (= mark gnus-unread-mark)
12021 (= mark gnus-ticked-mark)
12022 (= mark gnus-dormant-mark))
12023 (gnus-mark-article-as-unread article mark)
12024 (gnus-mark-article-as-read article mark))
12026 ;; See whether the article is to be put in the cache.
12027 (and gnus-use-cache
12028 (not (= mark gnus-canceled-mark))
12029 (vectorp (gnus-summary-article-header article))
12031 (gnus-cache-possibly-enter-article
12032 gnus-newsgroup-name article
12033 (gnus-summary-article-header article)
12034 (= mark gnus-ticked-mark)
12035 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12037 (if (gnus-summary-goto-subject article nil t)
12038 (let ((buffer-read-only nil))
12039 (gnus-summary-show-thread)
12041 (gnus-summary-update-mark mark 'unread)
12044 (defun gnus-summary-update-secondary-mark (article)
12045 "Update the secondary (read, process, cache) mark."
12046 (gnus-summary-update-mark
12047 (cond ((memq article gnus-newsgroup-processable)
12049 ((memq article gnus-newsgroup-cached)
12051 ((memq article gnus-newsgroup-replied)
12053 ((memq article gnus-newsgroup-saved)
12055 (t gnus-unread-mark))
12057 (when (gnus-visual-p 'summary-highlight 'highlight)
12058 (run-hooks 'gnus-summary-update-hook))
12061 (defun gnus-summary-update-mark (mark type)
12062 (beginning-of-line)
12063 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12064 (buffer-read-only nil))
12066 (<= (+ forward (point)) (point-max)))
12067 ;; Go to the right position on the line.
12068 (goto-char (+ forward (point)))
12069 ;; Replace the old mark with the new mark.
12070 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12071 ;; Optionally update the marks by some user rule.
12072 (when (eq type 'unread)
12073 (gnus-data-set-mark
12074 (gnus-data-find (gnus-summary-article-number)) mark)
12075 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12077 (defun gnus-mark-article-as-read (article &optional mark)
12078 "Enter ARTICLE in the pertinent lists and remove it from others."
12079 ;; Make the article expirable.
12080 (let ((mark (or mark gnus-del-mark)))
12081 (if (= mark gnus-expirable-mark)
12082 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12083 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12084 ;; Remove from unread and marked lists.
12085 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12086 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12087 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12088 (push (cons article mark) gnus-newsgroup-reads)
12089 ;; Possibly remove from cache, if that is used.
12090 (when gnus-use-cache
12091 (gnus-cache-enter-remove-article article))))
12093 (defun gnus-mark-article-as-unread (article &optional mark)
12094 "Enter ARTICLE in the pertinent lists and remove it from others."
12095 (let ((mark (or mark gnus-ticked-mark)))
12096 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12097 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12098 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12099 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12100 (cond ((= mark gnus-ticked-mark)
12101 (push article gnus-newsgroup-marked))
12102 ((= mark gnus-dormant-mark)
12103 (push article gnus-newsgroup-dormant))
12105 (push article gnus-newsgroup-unreads)))
12106 (setq gnus-newsgroup-reads
12107 (delq (assq article gnus-newsgroup-reads)
12108 gnus-newsgroup-reads))))
12110 (defalias 'gnus-summary-mark-as-unread-forward
12111 'gnus-summary-tick-article-forward)
12112 (make-obsolete 'gnus-summary-mark-as-unread-forward
12113 'gnus-summary-tick-article-forward)
12114 (defun gnus-summary-tick-article-forward (n)
12115 "Tick N articles forwards.
12116 If N is negative, tick backwards instead.
12117 The difference between N and the number of articles ticked is returned."
12119 (gnus-summary-mark-forward n gnus-ticked-mark))
12121 (defalias 'gnus-summary-mark-as-unread-backward
12122 'gnus-summary-tick-article-backward)
12123 (make-obsolete 'gnus-summary-mark-as-unread-backward
12124 'gnus-summary-tick-article-backward)
12125 (defun gnus-summary-tick-article-backward (n)
12126 "Tick N articles backwards.
12127 The difference between N and the number of articles ticked is returned."
12129 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12131 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12132 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12133 (defun gnus-summary-tick-article (&optional article clear-mark)
12134 "Mark current article as unread.
12135 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12136 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12138 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12139 gnus-ticked-mark)))
12141 (defun gnus-summary-mark-as-read-forward (n)
12142 "Mark N articles as read forwards.
12143 If N is negative, mark backwards instead.
12144 The difference between N and the actual number of articles marked is
12147 (gnus-summary-mark-forward n gnus-del-mark t))
12149 (defun gnus-summary-mark-as-read-backward (n)
12150 "Mark the N articles as read backwards.
12151 The difference between N and the actual number of articles marked is
12154 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12156 (defun gnus-summary-mark-as-read (&optional article mark)
12157 "Mark current article as read.
12158 ARTICLE specifies the article to be marked as read.
12159 MARK specifies a string to be inserted at the beginning of the line."
12160 (gnus-summary-mark-article article mark))
12162 (defun gnus-summary-clear-mark-forward (n)
12163 "Clear marks from N articles forward.
12164 If N is negative, clear backward instead.
12165 The difference between N and the number of marks cleared is returned."
12167 (gnus-summary-mark-forward n gnus-unread-mark))
12169 (defun gnus-summary-clear-mark-backward (n)
12170 "Clear marks from N articles backward.
12171 The difference between N and the number of marks cleared is returned."
12173 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12175 (defun gnus-summary-mark-unread-as-read ()
12176 "Intended to be used by `gnus-summary-mark-article-hook'."
12177 (when (memq gnus-current-article gnus-newsgroup-unreads)
12178 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12180 (defun gnus-summary-mark-read-and-unread-as-read ()
12181 "Intended to be used by `gnus-summary-mark-article-hook'."
12182 (let ((mark (gnus-summary-article-mark)))
12183 (when (or (gnus-unread-mark-p mark)
12184 (gnus-read-mark-p mark))
12185 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12187 (defun gnus-summary-mark-region-as-read (point mark all)
12188 "Mark all unread articles between point and mark as read.
12189 If given a prefix, mark all articles between point and mark as read,
12190 even ticked and dormant ones."
12191 (interactive "r\nP")
12195 (beginning-of-line)
12200 (memq (setq article (gnus-summary-article-number))
12201 gnus-newsgroup-unreads))
12202 (gnus-summary-mark-article article gnus-del-mark))
12204 (gnus-summary-find-next))))))
12206 (defun gnus-summary-mark-below (score mark)
12207 "Mark articles with score less than SCORE with MARK."
12208 (interactive "P\ncMark: ")
12209 (gnus-set-global-variables)
12210 (setq score (if score
12211 (prefix-numeric-value score)
12212 (or gnus-summary-default-score 0)))
12214 (set-buffer gnus-summary-buffer)
12215 (goto-char (point-min))
12218 (and (< (gnus-summary-article-score) score)
12219 (gnus-summary-mark-article nil mark))
12220 (gnus-summary-find-next)))))
12222 (defun gnus-summary-kill-below (&optional score)
12223 "Mark articles with score below SCORE as read."
12225 (gnus-set-global-variables)
12226 (gnus-summary-mark-below score gnus-killed-mark))
12228 (defun gnus-summary-clear-above (&optional score)
12229 "Clear all marks from articles with score above SCORE."
12231 (gnus-set-global-variables)
12232 (gnus-summary-mark-above score gnus-unread-mark))
12234 (defun gnus-summary-tick-above (&optional score)
12235 "Tick all articles with score above SCORE."
12237 (gnus-set-global-variables)
12238 (gnus-summary-mark-above score gnus-ticked-mark))
12240 (defun gnus-summary-mark-above (score mark)
12241 "Mark articles with score over SCORE with MARK."
12242 (interactive "P\ncMark: ")
12243 (gnus-set-global-variables)
12244 (setq score (if score
12245 (prefix-numeric-value score)
12246 (or gnus-summary-default-score 0)))
12248 (set-buffer gnus-summary-buffer)
12249 (goto-char (point-min))
12251 (if (> (gnus-summary-article-score) score)
12252 (gnus-summary-mark-article nil mark))
12254 (gnus-summary-find-next)))))
12256 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12257 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12258 (defun gnus-summary-limit-include-expunged ()
12259 "Display all the hidden articles that were expunged for low scores."
12261 (gnus-set-global-variables)
12262 (let ((buffer-read-only nil))
12263 (let ((scored gnus-newsgroup-scored)
12266 (or (gnus-summary-goto-subject (caar scored))
12267 (and (setq h (gnus-summary-article-header (caar scored)))
12268 (< (cdar scored) gnus-summary-expunge-below)
12269 (setq headers (cons h headers))))
12270 (setq scored (cdr scored)))
12271 (or headers (error "No expunged articles hidden."))
12272 (goto-char (point-min))
12273 (gnus-summary-prepare-unthreaded (nreverse headers)))
12274 (goto-char (point-min))
12275 (gnus-summary-position-point)))
12277 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12278 "Mark all articles not marked as unread in this newsgroup as read.
12279 If prefix argument ALL is non-nil, all articles are marked as read.
12280 If QUIETLY is non-nil, no questions will be asked.
12281 If TO-HERE is non-nil, it should be a point in the buffer. All
12282 articles before this point will be marked as read.
12283 The number of articles marked as read is returned."
12285 (gnus-set-global-variables)
12288 (not gnus-interactive-catchup) ;Without confirmation?
12292 "Mark absolutely all articles as read? "
12293 "Mark all unread articles as read? ")))
12295 (not gnus-newsgroup-adaptive)
12296 (not gnus-newsgroup-auto-expire))
12299 (setq gnus-newsgroup-marked nil
12300 gnus-newsgroup-dormant nil))
12301 (setq gnus-newsgroup-unreads nil))
12302 ;; We actually mark all articles as canceled, which we
12303 ;; have to do when using auto-expiry or adaptive scoring.
12304 (gnus-summary-show-all-threads)
12305 (if (gnus-summary-first-subject (not all))
12307 (if to-here (< (point) to-here) t)
12308 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12309 (gnus-summary-find-next (not all)))))
12311 (setq gnus-newsgroup-unreads nil))
12312 (gnus-set-mode-line 'summary)))
12313 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12314 (if (and (not to-here) (eq 'nnvirtual (car method)))
12315 (nnvirtual-catchup-group
12316 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12317 (gnus-summary-position-point)))
12319 (defun gnus-summary-catchup-to-here (&optional all)
12320 "Mark all unticked articles before the current one as read.
12321 If ALL is non-nil, also mark ticked and dormant articles as read."
12323 (gnus-set-global-variables)
12325 (let ((beg (point)))
12326 ;; We check that there are unread articles.
12327 (when (or all (gnus-summary-find-prev))
12328 (gnus-summary-catchup all t beg))))
12329 (gnus-summary-position-point))
12331 (defun gnus-summary-catchup-all (&optional quietly)
12332 "Mark all articles in this newsgroup as read."
12334 (gnus-set-global-variables)
12335 (gnus-summary-catchup t quietly))
12337 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12338 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12339 If prefix argument ALL is non-nil, all articles are marked as read."
12341 (gnus-set-global-variables)
12342 (gnus-summary-catchup all quietly nil 'fast)
12343 ;; Select next newsgroup or exit.
12344 (if (eq gnus-auto-select-next 'quietly)
12345 (gnus-summary-next-group nil)
12346 (gnus-summary-exit)))
12348 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12349 "Mark all articles in this newsgroup as read, and then exit."
12351 (gnus-set-global-variables)
12352 (gnus-summary-catchup-and-exit t quietly))
12354 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12355 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12356 "Mark all articles in this group as read and select the next group.
12357 If given a prefix, mark all articles, unread as well as ticked, as
12360 (gnus-set-global-variables)
12362 (gnus-summary-catchup all))
12363 (gnus-summary-next-article t nil nil t))
12365 ;; Thread-based commands.
12367 (defun gnus-summary-articles-in-thread (&optional article)
12368 "Return a list of all articles in the current thread.
12369 If ARTICLE is non-nil, return all articles in the thread that starts
12370 with that article."
12371 (let* ((article (or article (gnus-summary-article-number)))
12372 (data (gnus-data-find-list article))
12373 (top-level (gnus-data-level (car data)))
12375 (cond ((null gnus-thread-operation-ignore-subject)
12376 (gnus-simplify-subject-re
12377 (mail-header-subject (gnus-data-header (car data)))))
12378 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12379 (gnus-simplify-subject-fuzzy
12380 (mail-header-subject (gnus-data-header (car data)))))
12382 (end-point (save-excursion
12383 (if (gnus-summary-go-to-next-thread)
12384 (point) (point-max))))
12387 (< (gnus-data-pos (car data)) end-point))
12388 (when (or (not top-subject)
12389 (string= top-subject
12390 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12391 (gnus-simplify-subject-fuzzy
12392 (mail-header-subject
12393 (gnus-data-header (car data))))
12394 (gnus-simplify-subject-re
12395 (mail-header-subject
12396 (gnus-data-header (car data)))))))
12397 (push (gnus-data-number (car data)) articles))
12398 (unless (and (setq data (cdr data))
12399 (> (gnus-data-level (car data)) top-level))
12401 ;; Return the list of articles.
12402 (nreverse articles)))
12404 (defun gnus-summary-rethread-current ()
12405 "Rethread the thread the current article is part of."
12407 (gnus-set-global-variables)
12408 (let* ((gnus-show-threads t)
12409 (article (gnus-summary-article-number))
12410 (id (mail-header-id (gnus-summary-article-header)))
12411 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12413 (error "No article on the current line"))
12414 (gnus-rebuild-thread id)
12415 (gnus-summary-goto-subject article)))
12417 (defun gnus-summary-reparent-thread ()
12418 "Make current article child of the marked (or previous) article.
12420 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12421 is non-nil or the Subject: of both articles are the same."
12423 (or (not (gnus-group-read-only-p))
12424 (error "The current newsgroup does not support article editing."))
12425 (or (<= (length gnus-newsgroup-processable) 1)
12426 (error "No more than one article may be marked."))
12427 (save-window-excursion
12428 (let ((gnus-article-buffer " *reparent*")
12429 (current-article (gnus-summary-article-number))
12430 ; first grab the marked article, otherwise one line up.
12431 (parent-article (if (not (null gnus-newsgroup-processable))
12432 (car gnus-newsgroup-processable)
12434 (if (eq (forward-line -1) 0)
12435 (gnus-summary-article-number)
12436 (error "Beginning of summary buffer."))))))
12437 (or (not (eq current-article parent-article))
12438 (error "An article may not be self-referential."))
12439 (let ((message-id (mail-header-id
12440 (gnus-summary-article-header parent-article))))
12441 (or (and message-id (not (equal message-id "")))
12442 (error "No message-id in desired parent."))
12443 (gnus-summary-select-article t t nil current-article)
12444 (set-buffer gnus-article-buffer)
12445 (setq buffer-read-only nil)
12446 (let ((buf (format "%s" (buffer-string))))
12449 (goto-char (point-min))
12450 (if (search-forward-regexp "^References: " nil t)
12451 (insert message-id " " )
12452 (insert "References: " message-id "\n"))
12453 (or (gnus-request-replace-article current-article
12454 (car gnus-article-current)
12455 gnus-article-buffer)
12456 (error "Couldn't replace article."))
12457 (set-buffer gnus-summary-buffer)
12458 (gnus-summary-unmark-all-processable)
12459 (gnus-summary-rethread-current)
12460 (gnus-message 3 "Article %d is now the child of article %d."
12461 current-article parent-article)))))
12463 (defun gnus-summary-toggle-threads (&optional arg)
12464 "Toggle showing conversation threads.
12465 If ARG is positive number, turn showing conversation threads on."
12467 (gnus-set-global-variables)
12468 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12469 (setq gnus-show-threads
12470 (if (null arg) (not gnus-show-threads)
12471 (> (prefix-numeric-value arg) 0)))
12472 (gnus-summary-prepare)
12473 (gnus-summary-goto-subject current)
12474 (gnus-summary-position-point)))
12476 (defun gnus-summary-show-all-threads ()
12477 "Show all threads."
12479 (gnus-set-global-variables)
12481 (let ((buffer-read-only nil))
12482 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12483 (gnus-summary-position-point))
12485 (defun gnus-summary-show-thread ()
12486 "Show thread subtrees.
12487 Returns nil if no thread was there to be shown."
12489 (gnus-set-global-variables)
12490 (let ((buffer-read-only nil)
12492 ;; first goto end then to beg, to have point at beg after let
12493 (end (progn (end-of-line) (point)))
12494 (beg (progn (beginning-of-line) (point))))
12496 ;; Any hidden lines here?
12497 (search-forward "\r" end t)
12498 (subst-char-in-region beg end ?\^M ?\n t)
12500 (gnus-summary-position-point))))
12502 (defun gnus-summary-hide-all-threads ()
12503 "Hide all thread subtrees."
12505 (gnus-set-global-variables)
12507 (goto-char (point-min))
12508 (gnus-summary-hide-thread)
12509 (while (zerop (gnus-summary-next-thread 1 t))
12510 (gnus-summary-hide-thread)))
12511 (gnus-summary-position-point))
12513 (defun gnus-summary-hide-thread ()
12514 "Hide thread subtrees.
12515 Returns nil if no threads were there to be hidden."
12517 (gnus-set-global-variables)
12518 (let ((buffer-read-only nil)
12520 (article (gnus-summary-article-number)))
12522 ;; Go forward until either the buffer ends or the subthread
12524 (when (and (not (eobp))
12525 (or (zerop (gnus-summary-next-thread 1 t))
12526 (goto-char (point-max))))
12528 (if (and (> (point) start)
12529 (search-backward "\n" start t))
12531 (subst-char-in-region start (point) ?\n ?\^M)
12532 (gnus-summary-goto-subject article))
12535 ;;(gnus-summary-position-point)
12538 (defun gnus-summary-go-to-next-thread (&optional previous)
12539 "Go to the same level (or less) next thread.
12540 If PREVIOUS is non-nil, go to previous thread instead.
12541 Return the article number moved to, or nil if moving was impossible."
12542 (let ((level (gnus-summary-thread-level))
12543 (way (if previous -1 1))
12546 (while (and (not (eobp))
12547 (< level (gnus-summary-thread-level)))
12548 (forward-line way))
12555 (gnus-summary-article-number)
12556 (goto-char beg)))))
12558 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12559 "Go to the same level (or less) next thread.
12560 If PREVIOUS is non-nil, go to previous thread instead.
12561 Return the article number moved to, or nil if moving was impossible."
12562 (if (and (eq gnus-summary-make-false-root 'dummy)
12563 (gnus-summary-article-intangible-p))
12564 (let ((beg (point)))
12565 (while (and (zerop (forward-line 1))
12566 (not (gnus-summary-article-intangible-p))
12567 (not (zerop (save-excursion
12568 (gnus-summary-thread-level))))))
12574 (let* ((level (gnus-summary-thread-level))
12575 (article (gnus-summary-article-number))
12576 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12579 (if (<= (gnus-data-level (car data)) level)
12580 (setq oart (gnus-data-number (car data))
12582 (setq data (cdr data))))
12584 (gnus-summary-goto-subject oart)))))
12586 (defun gnus-summary-next-thread (n &optional silent)
12587 "Go to the same level next N'th thread.
12588 If N is negative, search backward instead.
12589 Returns the difference between N and the number of skips actually
12592 If SILENT, don't output messages."
12594 (gnus-set-global-variables)
12595 (let ((backward (< n 0))
12598 (while (and (> n 0)
12599 (gnus-summary-go-to-next-thread backward))
12602 (gnus-summary-position-point))
12603 (when (and (not silent) (/= 0 n))
12604 (gnus-message 7 "No more threads"))
12607 (defun gnus-summary-prev-thread (n)
12608 "Go to the same level previous N'th thread.
12609 Returns the difference between N and the number of skips actually
12612 (gnus-set-global-variables)
12613 (gnus-summary-next-thread (- n)))
12615 (defun gnus-summary-go-down-thread ()
12616 "Go down one level in the current thread."
12617 (let ((children (gnus-summary-article-children)))
12619 (gnus-summary-goto-subject (car children)))))
12621 (defun gnus-summary-go-up-thread ()
12622 "Go up one level in the current thread."
12623 (let ((parent (gnus-summary-article-parent)))
12625 (gnus-summary-goto-subject parent))))
12627 (defun gnus-summary-down-thread (n)
12628 "Go down thread N steps.
12629 If N is negative, go up instead.
12630 Returns the difference between N and how many steps down that were
12633 (gnus-set-global-variables)
12636 (while (and (> n 0)
12637 (if up (gnus-summary-go-up-thread)
12638 (gnus-summary-go-down-thread)))
12640 (gnus-summary-position-point)
12641 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12644 (defun gnus-summary-up-thread (n)
12645 "Go up thread N steps.
12646 If N is negative, go up instead.
12647 Returns the difference between N and how many steps down that were
12650 (gnus-set-global-variables)
12651 (gnus-summary-down-thread (- n)))
12653 (defun gnus-summary-top-thread ()
12654 "Go to the top of the thread."
12656 (gnus-set-global-variables)
12657 (while (gnus-summary-go-up-thread))
12658 (gnus-summary-article-number))
12660 (defun gnus-summary-kill-thread (&optional unmark)
12661 "Mark articles under current thread as read.
12662 If the prefix argument is positive, remove any kinds of marks.
12663 If the prefix argument is negative, tick articles instead."
12665 (gnus-set-global-variables)
12667 (setq unmark (prefix-numeric-value unmark)))
12668 (let ((articles (gnus-summary-articles-in-thread)))
12670 ;; Expand the thread.
12671 (gnus-summary-show-thread)
12672 ;; Mark all the articles.
12674 (gnus-summary-goto-subject (car articles))
12675 (cond ((null unmark)
12676 (gnus-summary-mark-article-as-read gnus-killed-mark))
12678 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12680 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12681 (setq articles (cdr articles))))
12682 ;; Hide killed subtrees.
12684 gnus-thread-hide-killed
12685 (gnus-summary-hide-thread))
12686 ;; If marked as read, go to next unread subject.
12688 ;; Go to next unread subject.
12689 (gnus-summary-next-subject 1 t)))
12690 (gnus-set-mode-line 'summary))
12692 ;; Summary sorting commands
12694 (defun gnus-summary-sort-by-number (&optional reverse)
12695 "Sort summary buffer by article number.
12696 Argument REVERSE means reverse order."
12698 (gnus-summary-sort 'number reverse))
12700 (defun gnus-summary-sort-by-author (&optional reverse)
12701 "Sort summary buffer by author name alphabetically.
12702 If case-fold-search is non-nil, case of letters is ignored.
12703 Argument REVERSE means reverse order."
12705 (gnus-summary-sort 'author reverse))
12707 (defun gnus-summary-sort-by-subject (&optional reverse)
12708 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12709 If case-fold-search is non-nil, case of letters is ignored.
12710 Argument REVERSE means reverse order."
12712 (gnus-summary-sort 'subject reverse))
12714 (defun gnus-summary-sort-by-date (&optional reverse)
12715 "Sort summary buffer by date.
12716 Argument REVERSE means reverse order."
12718 (gnus-summary-sort 'date reverse))
12720 (defun gnus-summary-sort-by-score (&optional reverse)
12721 "Sort summary buffer by score.
12722 Argument REVERSE means reverse order."
12724 (gnus-summary-sort 'score reverse))
12726 (defun gnus-summary-sort (predicate reverse)
12727 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12728 (gnus-set-global-variables)
12729 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12730 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12731 (gnus-thread-sort-functions
12736 (,thread t2 t1)))))
12737 (gnus-article-sort-functions
12742 (,article t2 t1)))))
12744 (gnus-summary-prepare-hook nil))
12745 ;; We do the sorting by regenerating the threads.
12746 (gnus-summary-prepare)
12747 ;; Hide subthreads if needed.
12748 (when (and gnus-show-threads gnus-thread-hide-subtree)
12749 (gnus-summary-hide-all-threads)))
12750 ;; If in async mode, we send some info to the backend.
12751 (when gnus-newsgroup-async
12752 (gnus-request-asynchronous
12753 gnus-newsgroup-name gnus-newsgroup-data)))
12755 (defun gnus-sortable-date (date)
12756 "Make sortable string by string-lessp from DATE.
12757 Timezone package is used."
12758 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12759 (year (aref date 0))
12760 (month (aref date 1))
12761 (day (aref date 2)))
12762 (timezone-make-sortable-date
12764 (timezone-make-time-string
12765 (aref date 3) (aref date 4) (aref date 5)))))
12767 ;; Summary saving commands.
12769 (defun gnus-summary-save-article (&optional n not-saved)
12770 "Save the current article using the default saver function.
12771 If N is a positive number, save the N next articles.
12772 If N is a negative number, save the N previous articles.
12773 If N is nil and any articles have been marked with the process mark,
12774 save those articles instead.
12775 The variable `gnus-default-article-saver' specifies the saver function."
12777 (gnus-set-global-variables)
12778 (let ((articles (gnus-summary-work-articles n))
12779 file header article)
12781 (setq header (gnus-summary-article-header
12782 (setq article (pop articles))))
12783 (if (not (vectorp header))
12784 ;; This is a pseudo-article.
12785 (if (assq 'name header)
12786 (gnus-copy-file (cdr (assq 'name header)))
12787 (gnus-message 1 "Article %d is unsaveable" article))
12788 ;; This is a real article.
12789 (save-window-excursion
12790 (gnus-summary-select-article t nil nil article))
12791 (unless gnus-save-all-headers
12792 ;; Remove headers accoring to `gnus-saved-headers'.
12793 (let ((gnus-visible-headers
12794 (or gnus-saved-headers gnus-visible-headers)))
12795 (gnus-article-hide-headers nil t)))
12796 ;; Remove any X-Gnus lines.
12798 (set-buffer gnus-article-buffer)
12800 (let ((buffer-read-only nil))
12801 (nnheader-narrow-to-headers)
12802 (while (re-search-forward "^X-Gnus" nil t)
12803 (gnus-delete-line)))))
12804 (save-window-excursion
12805 (if (not gnus-default-article-saver)
12806 (error "No default saver is defined.")
12807 (setq file (funcall
12808 gnus-default-article-saver
12810 ((not gnus-prompt-before-saving)
12812 ((eq gnus-prompt-before-saving 'always)
12815 (gnus-summary-remove-process-mark article)
12817 (gnus-summary-set-saved-mark article))))
12818 (gnus-summary-position-point)
12821 (defun gnus-summary-pipe-output (&optional arg)
12822 "Pipe the current article to a subprocess.
12823 If N is a positive number, pipe the N next articles.
12824 If N is a negative number, pipe the N previous articles.
12825 If N is nil and any articles have been marked with the process mark,
12826 pipe those articles instead."
12828 (gnus-set-global-variables)
12829 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12830 (gnus-summary-save-article arg t))
12831 (gnus-configure-windows 'pipe))
12833 (defun gnus-summary-save-article-mail (&optional arg)
12834 "Append the current article to an mail file.
12835 If N is a positive number, save the N next articles.
12836 If N is a negative number, save the N previous articles.
12837 If N is nil and any articles have been marked with the process mark,
12838 save those articles instead."
12840 (gnus-set-global-variables)
12841 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12842 (gnus-summary-save-article arg)))
12844 (defun gnus-summary-save-article-rmail (&optional arg)
12845 "Append the current article to an rmail file.
12846 If N is a positive number, save the N next articles.
12847 If N is a negative number, save the N previous articles.
12848 If N is nil and any articles have been marked with the process mark,
12849 save those articles instead."
12851 (gnus-set-global-variables)
12852 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12853 (gnus-summary-save-article arg)))
12855 (defun gnus-summary-save-article-file (&optional arg)
12856 "Append the current article to a file.
12857 If N is a positive number, save the N next articles.
12858 If N is a negative number, save the N previous articles.
12859 If N is nil and any articles have been marked with the process mark,
12860 save those articles instead."
12862 (gnus-set-global-variables)
12863 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12864 (gnus-summary-save-article arg)))
12866 (defun gnus-summary-save-article-body-file (&optional arg)
12867 "Append the current article body to a file.
12868 If N is a positive number, save the N next articles.
12869 If N is a negative number, save the N previous articles.
12870 If N is nil and any articles have been marked with the process mark,
12871 save those articles instead."
12873 (gnus-set-global-variables)
12874 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12875 (gnus-summary-save-article arg)))
12877 (defun gnus-get-split-value (methods)
12878 "Return a value based on the split METHODS."
12879 (let (split-name method result match)
12882 (set-buffer gnus-original-article-buffer)
12884 (nnheader-narrow-to-headers)
12886 (goto-char (point-min))
12887 (setq method (pop methods))
12888 (setq match (car method))
12891 ;; Regular expression.
12893 (re-search-forward match nil t)
12895 ((gnus-functionp match)
12899 (setq result (funcall match gnus-newsgroup-name))))
12904 (setq result (eval match)))))
12905 (setq split-name (append (cdr method) split-name))
12906 (cond ((stringp result)
12907 (push result split-name))
12909 (setq split-name (append result split-name)))))))))
12912 (defun gnus-read-move-group-name (prompt default articles prefix)
12913 "Read a group name."
12914 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12921 (assoc (symbol-name
12922 (car (gnus-find-method-for-group
12924 gnus-valid-select-methods))
12925 (push (list (symbol-name g)) group-map)))
12926 gnus-active-hashtb))
12928 (format "%s %s to:"
12930 (if (> (length articles) 1)
12931 (format "these %d articles" (length articles))
12936 (gnus-completing-read default prom
12937 group-map nil nil prefix
12938 'gnus-group-history))
12939 ((= 1 (length split-name))
12940 (gnus-completing-read (car split-name) prom group-map
12942 'gnus-group-history))
12944 (gnus-completing-read nil prom
12945 (mapcar (lambda (el) (list el))
12946 (nreverse split-name))
12948 'gnus-group-history)))))
12950 (if (or (string= to-newsgroup "")
12951 (string= to-newsgroup prefix))
12952 (setq to-newsgroup (or default "")))
12953 (or (gnus-active to-newsgroup)
12954 (gnus-activate-group to-newsgroup)
12955 (error "No such group: %s" to-newsgroup)))
12958 (defun gnus-read-save-file-name (prompt default-name)
12959 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12961 ;; Let the split methods have their say.
12963 ;; No split name was found.
12966 (concat prompt " (default "
12967 (file-name-nondirectory default-name) ") ")
12968 (file-name-directory default-name)
12970 ;; A single split name was found
12971 ((= 1 (length split-name))
12973 (concat prompt " (default " (car split-name) ") ")
12974 gnus-article-save-directory
12975 (concat gnus-article-save-directory (car split-name))))
12976 ;; A list of splits was found.
12978 (setq split-name (nreverse split-name))
12980 (let ((file-name-history (nconc split-name file-name-history)))
12983 (concat prompt " (`M-p' for defaults) ")
12984 gnus-article-save-directory
12985 (car split-name))))
12986 (car (push result file-name-history)))))))
12987 ;; If we have read a directory, we append the default file name.
12988 (when (file-directory-p file)
12989 (setq file (concat (file-name-as-directory file)
12990 (file-name-nondirectory default-name))))
12991 ;; Possibly translate some charaters.
12992 (nnheader-translate-file-chars file)))
12994 (defun gnus-article-archive-name (group)
12995 "Return the first instance of an \"Archive-name\" in the current buffer."
12996 (let ((case-fold-search t))
12997 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12998 (match-string 1))))
13000 (defun gnus-summary-save-in-rmail (&optional filename)
13001 "Append this article to Rmail file.
13002 Optional argument FILENAME specifies file name.
13003 Directory to save to is default to `gnus-article-save-directory' which
13004 is initialized from the SAVEDIR environment variable."
13006 (gnus-set-global-variables)
13007 (let ((default-name
13008 (funcall gnus-rmail-save-name gnus-newsgroup-name
13009 gnus-current-headers gnus-newsgroup-last-rmail)))
13011 (cond ((eq filename 'default)
13013 (filename filename)
13014 (t (gnus-read-save-file-name
13015 "Save in rmail file:" default-name))))
13016 (gnus-make-directory (file-name-directory filename))
13017 (gnus-eval-in-buffer-window
13018 gnus-original-article-buffer
13022 (gnus-output-to-rmail filename))))
13023 ;; Remember the directory name to save articles
13024 (setq gnus-newsgroup-last-rmail filename)))
13026 (defun gnus-summary-save-in-mail (&optional filename)
13027 "Append this article to Unix mail file.
13028 Optional argument FILENAME specifies file name.
13029 Directory to save to is default to `gnus-article-save-directory' which
13030 is initialized from the SAVEDIR environment variable."
13032 (gnus-set-global-variables)
13033 (let ((default-name
13034 (funcall gnus-mail-save-name gnus-newsgroup-name
13035 gnus-current-headers gnus-newsgroup-last-mail)))
13037 (cond ((eq filename 'default)
13039 (filename filename)
13040 (t (gnus-read-save-file-name
13041 "Save in Unix mail file:" default-name))))
13043 (expand-file-name filename
13045 (file-name-directory default-name))))
13046 (gnus-make-directory (file-name-directory filename))
13047 (gnus-eval-in-buffer-window
13048 gnus-original-article-buffer
13052 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13053 (gnus-output-to-rmail filename)
13054 (let ((mail-use-rfc822 t))
13055 (rmail-output filename 1 t t))))))
13056 ;; Remember the directory name to save articles.
13057 (setq gnus-newsgroup-last-mail filename)))
13059 (defun gnus-summary-save-in-file (&optional filename)
13060 "Append this article to file.
13061 Optional argument FILENAME specifies file name.
13062 Directory to save to is default to `gnus-article-save-directory' which
13063 is initialized from the SAVEDIR environment variable."
13065 (gnus-set-global-variables)
13066 (let ((default-name
13067 (funcall gnus-file-save-name gnus-newsgroup-name
13068 gnus-current-headers gnus-newsgroup-last-file)))
13070 (cond ((eq filename 'default)
13072 (filename filename)
13073 (t (gnus-read-save-file-name
13074 "Save in file:" default-name))))
13075 (gnus-make-directory (file-name-directory filename))
13076 (gnus-eval-in-buffer-window
13077 gnus-original-article-buffer
13081 (gnus-output-to-file filename))))
13082 ;; Remember the directory name to save articles.
13083 (setq gnus-newsgroup-last-file filename)))
13085 (defun gnus-summary-save-body-in-file (&optional filename)
13086 "Append this article body to a file.
13087 Optional argument FILENAME specifies file name.
13088 The directory to save in defaults to `gnus-article-save-directory' which
13089 is initialized from the SAVEDIR environment variable."
13091 (gnus-set-global-variables)
13092 (let ((default-name
13093 (funcall gnus-file-save-name gnus-newsgroup-name
13094 gnus-current-headers gnus-newsgroup-last-file)))
13096 (cond ((eq filename 'default)
13098 (filename filename)
13099 (t (gnus-read-save-file-name
13100 "Save body in file:" default-name))))
13101 (gnus-make-directory (file-name-directory filename))
13102 (gnus-eval-in-buffer-window
13103 gnus-article-buffer
13107 (goto-char (point-min))
13108 (and (search-forward "\n\n" nil t)
13109 (narrow-to-region (point) (point-max)))
13110 (gnus-output-to-file filename))))
13111 ;; Remember the directory name to save articles.
13112 (setq gnus-newsgroup-last-file filename)))
13114 (defun gnus-summary-save-in-pipe (&optional command)
13115 "Pipe this article to subprocess."
13117 (gnus-set-global-variables)
13119 (cond ((eq command 'default)
13120 gnus-last-shell-command)
13122 (t (read-string "Shell command on article: "
13123 gnus-last-shell-command))))
13124 (if (string-equal command "")
13125 (setq command gnus-last-shell-command))
13126 (gnus-eval-in-buffer-window
13127 gnus-article-buffer
13130 (shell-command-on-region (point-min) (point-max) command nil)))
13131 (setq gnus-last-shell-command command))
13133 ;; Summary extract commands
13135 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13136 (let ((buffer-read-only nil)
13137 (article (gnus-summary-article-number))
13139 (or (gnus-summary-goto-subject article)
13140 (error (format "No such article: %d" article)))
13141 (gnus-summary-position-point)
13142 ;; If all commands are to be bunched up on one line, we collect
13144 (if gnus-view-pseudos-separately
13146 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13149 (setq action (cdr (assq 'action (car ps))))
13150 (setq files (list (cdr (assq 'name (car ps)))))
13151 (while (and ps (cdr ps)
13152 (string= (or action "1")
13153 (or (cdr (assq 'action (cadr ps))) "2")))
13154 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13155 (setcdr ps (cddr ps)))
13158 (if (not (string-match "%s" action))
13159 (setq files (cons " " files)))
13160 (setq files (cons " " files))
13161 (and (assq 'execute (car ps))
13162 (setcdr (assq 'execute (car ps))
13163 (funcall (if (string-match "%s" action)
13166 (mapconcat (lambda (f) f) files " ")))))
13167 (setq ps (cdr ps)))))
13168 (if (and gnus-view-pseudos (not not-view))
13170 (and (assq 'execute (car pslist))
13171 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13172 (eq gnus-view-pseudos 'not-confirm)))
13173 (setq pslist (cdr pslist)))
13176 (setq after-article (or (cdr (assq 'article (car pslist)))
13177 (gnus-summary-article-number)))
13178 (gnus-summary-goto-subject after-article)
13181 (insert " " (file-name-nondirectory
13182 (cdr (assq 'name (car pslist))))
13183 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13185 (forward-line -1) ; back to `b'
13186 (add-text-properties
13187 b e (list 'gnus-number gnus-reffed-article-number
13188 gnus-mouse-face-prop gnus-mouse-face))
13190 after-article gnus-reffed-article-number
13191 gnus-unread-mark b (car pslist) 0 (- e b))
13192 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13193 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13194 (setq pslist (cdr pslist)))))))
13196 (defun gnus-pseudos< (p1 p2)
13197 (let ((c1 (cdr (assq 'action p1)))
13198 (c2 (cdr (assq 'action p2))))
13199 (and c1 c2 (string< c1 c2))))
13201 (defun gnus-request-pseudo-article (props)
13202 (cond ((assq 'execute props)
13203 (gnus-execute-command (cdr (assq 'execute props)))))
13204 (let ((gnus-current-article (gnus-summary-article-number)))
13205 (run-hooks 'gnus-mark-article-hook)))
13207 (defun gnus-execute-command (command &optional automatic)
13209 (gnus-article-setup-buffer)
13210 (set-buffer gnus-article-buffer)
13211 (setq buffer-read-only nil)
13212 (let ((command (if automatic command (read-string "Command: " command)))
13213 ;; Just binding this here doesn't help, because there might
13214 ;; be output from the process after exiting the scope of
13216 ;; (buffer-read-only nil)
13219 (insert "$ " command "\n\n")
13220 (if gnus-view-pseudo-asynchronously
13221 (start-process "gnus-execute" nil "sh" "-c" command)
13222 (call-process "sh" nil t nil "-c" command)))))
13224 (defun gnus-copy-file (file &optional to)
13227 (list (read-file-name "Copy file: " default-directory)
13228 (read-file-name "Copy file to: " default-directory)))
13229 (gnus-set-global-variables)
13230 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13231 (and (file-directory-p to)
13232 (setq to (concat (file-name-as-directory to)
13233 (file-name-nondirectory file))))
13234 (copy-file file to))
13236 ;; Summary kill commands.
13238 (defun gnus-summary-edit-global-kill (article)
13239 "Edit the \"global\" kill file."
13240 (interactive (list (gnus-summary-article-number)))
13241 (gnus-set-global-variables)
13242 (gnus-group-edit-global-kill article))
13244 (defun gnus-summary-edit-local-kill ()
13245 "Edit a local kill file applied to the current newsgroup."
13247 (gnus-set-global-variables)
13248 (setq gnus-current-headers (gnus-summary-article-header))
13249 (gnus-set-global-variables)
13250 (gnus-group-edit-local-kill
13251 (gnus-summary-article-number) gnus-newsgroup-name))
13255 ;;; Gnus article mode
13258 (put 'gnus-article-mode 'mode-class 'special)
13260 (if gnus-article-mode-map
13262 (setq gnus-article-mode-map (make-keymap))
13263 (suppress-keymap gnus-article-mode-map)
13265 (gnus-define-keys gnus-article-mode-map
13266 " " gnus-article-goto-next-page
13267 "\177" gnus-article-goto-prev-page
13268 [delete] gnus-article-goto-prev-page
13269 "\C-c^" gnus-article-refer-article
13270 "h" gnus-article-show-summary
13271 "s" gnus-article-show-summary
13272 "\C-c\C-m" gnus-article-mail
13273 "?" gnus-article-describe-briefly
13274 gnus-mouse-2 gnus-article-push-button
13275 "\r" gnus-article-press-button
13276 "\t" gnus-article-next-button
13277 "\M-\t" gnus-article-prev-button
13278 "\C-c\C-b" gnus-bug)
13280 (substitute-key-definition
13281 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13283 (defun gnus-article-mode ()
13284 "Major mode for displaying an article.
13286 All normal editing commands are switched off.
13288 The following commands are available:
13290 \\<gnus-article-mode-map>
13291 \\[gnus-article-next-page]\t Scroll the article one page forwards
13292 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13293 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13294 \\[gnus-article-show-summary]\t Display the summary buffer
13295 \\[gnus-article-mail]\t Send a reply to the address near point
13296 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13297 \\[gnus-info-find-node]\t Go to the Gnus info node"
13299 (when (and menu-bar-mode
13300 (gnus-visual-p 'article-menu 'menu))
13301 (gnus-article-make-menu-bar))
13302 (kill-all-local-variables)
13303 (gnus-simplify-mode-line)
13304 (setq mode-name "Article")
13305 (setq major-mode 'gnus-article-mode)
13306 (make-local-variable 'minor-mode-alist)
13307 (or (assq 'gnus-show-mime minor-mode-alist)
13308 (setq minor-mode-alist
13309 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13310 (use-local-map gnus-article-mode-map)
13311 (make-local-variable 'page-delimiter)
13312 (setq page-delimiter gnus-page-delimiter)
13313 (buffer-disable-undo (current-buffer))
13314 (setq buffer-read-only t) ;Disable modification
13315 (run-hooks 'gnus-article-mode-hook))
13317 (defun gnus-article-setup-buffer ()
13318 "Initialize the article buffer."
13319 (let* ((name (if gnus-single-article-buffer "*Article*"
13320 (concat "*Article " gnus-newsgroup-name "*")))
13322 (progn (string-match "\\*Article" name)
13323 (concat " *Original Article"
13324 (substring name (match-end 0))))))
13325 (setq gnus-article-buffer name)
13326 (setq gnus-original-article-buffer original)
13327 ;; This might be a variable local to the summary buffer.
13328 (unless gnus-single-article-buffer
13330 (set-buffer gnus-summary-buffer)
13331 (setq gnus-article-buffer name)
13332 (setq gnus-original-article-buffer original)
13333 (gnus-set-global-variables))
13334 (make-local-variable 'gnus-summary-buffer))
13335 ;; Init original article buffer.
13337 (set-buffer (get-buffer-create gnus-original-article-buffer))
13338 (buffer-disable-undo (current-buffer))
13339 (setq major-mode 'gnus-original-article-mode)
13340 (make-local-variable 'gnus-original-article))
13341 (if (get-buffer name)
13344 (buffer-disable-undo (current-buffer))
13345 (setq buffer-read-only t)
13346 (gnus-add-current-to-buffer-list)
13347 (or (eq major-mode 'gnus-article-mode)
13348 (gnus-article-mode))
13351 (set-buffer (get-buffer-create name))
13352 (gnus-add-current-to-buffer-list)
13353 (gnus-article-mode)
13354 (current-buffer)))))
13356 ;; Set article window start at LINE, where LINE is the number of lines
13357 ;; from the head of the article.
13358 (defun gnus-article-set-window-start (&optional line)
13360 (get-buffer-window gnus-article-buffer)
13362 (set-buffer gnus-article-buffer)
13363 (goto-char (point-min))
13366 (gnus-message 6 "Moved to bookmark")
13367 (search-forward "\n\n" nil t)
13368 (forward-line line)
13371 (defun gnus-kill-all-overlays ()
13372 "Delete all overlays in the current buffer."
13373 (when (fboundp 'overlay-lists)
13374 (let* ((overlayss (overlay-lists))
13375 (buffer-read-only nil)
13376 (overlays (nconc (car overlayss) (cdr overlayss))))
13378 (delete-overlay (pop overlays))))))
13380 (defun gnus-request-article-this-buffer (article group)
13381 "Get an article and insert it into this buffer."
13382 (let (do-update-line)
13386 (gnus-kill-all-overlays)
13387 (setq group (or group gnus-newsgroup-name))
13389 ;; Open server if it has closed.
13390 (gnus-check-server (gnus-find-method-for-group group))
13392 ;; Using `gnus-request-article' directly will insert the article into
13393 ;; `nntp-server-buffer' - so we'll save some time by not having to
13394 ;; copy it from the server buffer into the article buffer.
13396 ;; We only request an article by message-id when we do not have the
13397 ;; headers for it, so we'll have to get those.
13398 (when (stringp article)
13399 (let ((gnus-override-method gnus-refer-article-method))
13400 (gnus-read-header article)))
13402 ;; If the article number is negative, that means that this article
13403 ;; doesn't belong in this newsgroup (possibly), so we find its
13404 ;; message-id and request it by id instead of number.
13405 (when (and (numberp article)
13406 gnus-summary-buffer
13407 (get-buffer gnus-summary-buffer)
13408 (buffer-name (get-buffer gnus-summary-buffer)))
13410 (set-buffer gnus-summary-buffer)
13411 (let ((header (gnus-summary-article-header article)))
13414 ((memq article gnus-newsgroup-sparse)
13415 ;; This is a sparse gap article.
13416 (setq do-update-line article)
13417 (setq article (mail-header-id header))
13418 (let ((gnus-override-method gnus-refer-article-method))
13419 (gnus-read-header article))
13420 (setq gnus-newsgroup-sparse
13421 (delq article gnus-newsgroup-sparse)))
13423 ;; It's a real article.
13424 (setq article (mail-header-id header)))
13426 ;; It is an extracted pseudo-article.
13427 (setq article 'pseudo)
13428 (gnus-request-pseudo-article header))))
13430 (let ((method (gnus-find-method-for-group
13431 gnus-newsgroup-name)))
13432 (if (not (eq (car method) 'nneething))
13434 (let ((dir (concat (file-name-as-directory (nth 1 method))
13435 (mail-header-subject header))))
13436 (if (file-directory-p dir)
13438 (setq article 'nneething)
13439 (gnus-group-enter-directory dir)))))))))
13442 ;; Refuse to select canceled articles.
13443 ((and (numberp article)
13444 gnus-summary-buffer
13445 (get-buffer gnus-summary-buffer)
13446 (buffer-name (get-buffer gnus-summary-buffer))
13447 (eq (cdr (save-excursion
13448 (set-buffer gnus-summary-buffer)
13449 (assq article gnus-newsgroup-reads)))
13450 gnus-canceled-mark))
13452 ;; We first check `gnus-original-article-buffer'.
13453 ((and (get-buffer gnus-original-article-buffer)
13456 (set-buffer gnus-original-article-buffer)
13457 (and (equal (car gnus-original-article) group)
13458 (eq (cdr gnus-original-article) article))))
13459 (insert-buffer-substring gnus-original-article-buffer)
13461 ;; Check the backlog.
13462 ((and gnus-keep-backlog
13463 (gnus-backlog-request-article group article (current-buffer)))
13465 ;; Check the cache.
13466 ((and gnus-use-cache
13468 (gnus-cache-request-article article group))
13470 ;; Get the article and put into the article buffer.
13471 ((or (stringp article) (numberp article))
13472 (let ((gnus-override-method
13473 (and (stringp article) gnus-refer-article-method))
13474 (buffer-read-only nil))
13476 (gnus-kill-all-overlays)
13477 (if (gnus-request-article article group (current-buffer))
13479 (and gnus-keep-backlog
13481 (gnus-backlog-enter-article
13482 group article (current-buffer)))
13484 ;; It was a pseudo.
13487 ;; Take the article from the original article buffer
13488 ;; and place it in the buffer it's supposed to be in.
13489 (when (and (get-buffer gnus-article-buffer)
13491 (equal (buffer-name (current-buffer))
13492 (buffer-name (get-buffer gnus-article-buffer))))
13494 (if (get-buffer gnus-original-article-buffer)
13495 (set-buffer (get-buffer gnus-original-article-buffer))
13496 (set-buffer (get-buffer-create gnus-original-article-buffer))
13497 (buffer-disable-undo (current-buffer))
13498 (setq major-mode 'gnus-original-article-mode)
13499 (setq buffer-read-only t)
13500 (gnus-add-current-to-buffer-list))
13501 (let (buffer-read-only)
13503 (insert-buffer-substring gnus-article-buffer))
13504 (setq gnus-original-article (cons group article))))
13506 ;; Update sparse articles.
13507 (when (and do-update-line
13508 (or (numberp article)
13509 (stringp article)))
13510 (let ((buf (current-buffer)))
13511 (set-buffer gnus-summary-buffer)
13512 (gnus-summary-update-article do-update-line)
13513 (gnus-summary-goto-subject do-update-line nil t)
13514 (set-window-point (get-buffer-window (current-buffer) t)
13516 (set-buffer buf))))))
13518 (defun gnus-read-header (id &optional header)
13519 "Read the headers of article ID and enter them into the Gnus system."
13520 (let ((group gnus-newsgroup-name)
13521 (gnus-override-method
13522 (and (gnus-news-group-p gnus-newsgroup-name)
13523 gnus-refer-article-method))
13525 ;; First we check to see whether the header in question is already
13528 ;; This is a Message-ID.
13529 (setq header (or header (gnus-id-to-header id)))
13530 ;; This is an article number.
13531 (setq header (or header (gnus-summary-article-header id))))
13533 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13534 ;; We have found the header.
13536 ;; We have to really fetch the header to this article.
13538 (if (gnus-check-backend-function 'request-head group)
13539 (gnus-request-head id group)
13540 (gnus-request-article id group)))
13542 (set-buffer nntp-server-buffer)
13543 (and (search-forward "\n\n" nil t)
13544 (delete-region (1- (point)) (point-max)))
13545 (goto-char (point-max))
13547 (goto-char (point-min))
13551 ((cdr where) (cdr where))
13552 (header (mail-header-number header))
13553 (t gnus-reffed-article-number))
13555 (insert " Article retrieved.\n"))
13557 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13558 ; (setcar (gnus-id-to-thread id) nil))
13559 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13560 () ; Malformed head.
13561 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13562 (if (and (stringp id)
13563 (not (string= (gnus-group-real-name group)
13565 ;; If we fetched by Message-ID and the article came
13566 ;; from a different group, we fudge some bogus article
13567 ;; numbers for this article.
13568 (mail-header-set-number header gnus-reffed-article-number))
13569 (decf gnus-reffed-article-number)
13570 (push header gnus-newsgroup-headers)
13571 (setq gnus-current-headers header)
13572 (push (mail-header-number header) gnus-newsgroup-limit))
13575 (defun gnus-article-prepare (article &optional all-headers header)
13576 "Prepare ARTICLE in article mode buffer.
13577 ARTICLE should either be an article number or a Message-ID.
13578 If ARTICLE is an id, HEADER should be the article headers.
13579 If ALL-HEADERS is non-nil, no headers are hidden."
13581 ;; Make sure we start in a summary buffer.
13582 (unless (eq major-mode 'gnus-summary-mode)
13583 (set-buffer gnus-summary-buffer))
13584 (setq gnus-summary-buffer (current-buffer))
13585 ;; Make sure the connection to the server is alive.
13586 (unless (gnus-server-opened
13587 (gnus-find-method-for-group gnus-newsgroup-name))
13588 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13589 (gnus-request-group gnus-newsgroup-name t))
13590 (let* ((article (if header (mail-header-number header) article))
13591 (summary-buffer (current-buffer))
13592 (internal-hook gnus-article-internal-prepare-hook)
13593 (group gnus-newsgroup-name)
13596 (gnus-article-setup-buffer)
13597 (set-buffer gnus-article-buffer)
13598 ;; Deactivate active regions.
13599 (when (and (boundp 'transient-mark-mode)
13600 transient-mark-mode)
13601 (setq mark-active nil))
13602 (if (not (setq result (let ((buffer-read-only nil))
13603 (gnus-request-article-this-buffer
13605 ;; There is no such article.
13607 (when (and (numberp article)
13608 (not (memq article gnus-newsgroup-sparse)))
13609 (setq gnus-article-current
13610 (cons gnus-newsgroup-name article))
13611 (set-buffer gnus-summary-buffer)
13612 (setq gnus-current-article article)
13613 (gnus-summary-mark-article article gnus-canceled-mark))
13614 (unless (memq article gnus-newsgroup-sparse)
13616 1 "No such article (may have expired or been canceled)")))
13617 (if (or (eq result 'pseudo) (eq result 'nneething))
13620 (set-buffer summary-buffer)
13621 (setq gnus-last-article gnus-current-article
13622 gnus-newsgroup-history (cons gnus-current-article
13623 gnus-newsgroup-history)
13624 gnus-current-article 0
13625 gnus-current-headers nil
13626 gnus-article-current nil)
13627 (if (eq result 'nneething)
13628 (gnus-configure-windows 'summary)
13629 (gnus-configure-windows 'article))
13630 (gnus-set-global-variables))
13631 (gnus-set-mode-line 'article))
13632 ;; The result from the `request' was an actual article -
13633 ;; or at least some text that is now displayed in the
13635 (if (and (numberp article)
13636 (not (eq article gnus-current-article)))
13637 ;; Seems like a new article has been selected.
13638 ;; `gnus-current-article' must be an article number.
13640 (set-buffer summary-buffer)
13641 (setq gnus-last-article gnus-current-article
13642 gnus-newsgroup-history (cons gnus-current-article
13643 gnus-newsgroup-history)
13644 gnus-current-article article
13645 gnus-current-headers
13646 (gnus-summary-article-header gnus-current-article)
13647 gnus-article-current
13648 (cons gnus-newsgroup-name gnus-current-article))
13649 (unless (vectorp gnus-current-headers)
13650 (setq gnus-current-headers nil))
13651 (gnus-summary-show-thread)
13652 (run-hooks 'gnus-mark-article-hook)
13653 (gnus-set-mode-line 'summary)
13654 (and (gnus-visual-p 'article-highlight 'highlight)
13655 (run-hooks 'gnus-visual-mark-article-hook))
13656 ;; Set the global newsgroup variables here.
13657 ;; Suggested by Jim Sisolak
13658 ;; <sisolak@trans4.neep.wisc.edu>.
13659 (gnus-set-global-variables)
13660 (setq gnus-have-all-headers
13661 (or all-headers gnus-show-all-headers))
13662 (and gnus-use-cache
13663 (vectorp (gnus-summary-article-header article))
13664 (gnus-cache-possibly-enter-article
13666 (gnus-summary-article-header article)
13667 (memq article gnus-newsgroup-marked)
13668 (memq article gnus-newsgroup-dormant)
13669 (memq article gnus-newsgroup-unreads)))))
13670 (when (or (numberp article)
13672 ;; Hooks for getting information from the article.
13673 ;; This hook must be called before being narrowed.
13674 (let (buffer-read-only)
13675 (run-hooks 'internal-hook)
13676 (run-hooks 'gnus-article-prepare-hook)
13677 ;; Decode MIME message.
13679 (if (or (not gnus-strict-mime)
13680 (gnus-fetch-field "Mime-Version"))
13681 (funcall gnus-show-mime-method)
13682 (funcall gnus-decode-encoded-word-method)))
13683 ;; Perform the article display hooks.
13684 (run-hooks 'gnus-article-display-hook))
13686 (goto-char (point-min))
13687 (and gnus-break-pages (gnus-narrow-to-page)))
13688 (gnus-set-mode-line 'article)
13689 (gnus-configure-windows 'article)
13690 (goto-char (point-min))
13693 (defun gnus-article-show-all-headers ()
13694 "Show all article headers in article mode buffer."
13696 (gnus-article-setup-buffer)
13697 (set-buffer gnus-article-buffer)
13698 (let ((buffer-read-only nil))
13699 (gnus-unhide-text (point-min) (point-max)))))
13701 (defun gnus-article-hide-headers-if-wanted ()
13702 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13703 Provided for backwards compatibility."
13704 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13705 gnus-inhibit-hiding
13706 (gnus-article-hide-headers)))
13708 (defsubst gnus-article-header-rank ()
13709 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13710 (let ((list gnus-sorted-header-list)
13713 (when (looking-at (car list))
13715 (setq list (cdr list))
13719 (defun gnus-article-hide-headers (&optional arg delete)
13720 "Toggle whether to hide unwanted headers and possibly sort them as well.
13721 If given a negative prefix, always show; if given a positive prefix,
13724 (unless (gnus-article-check-hidden-text 'headers arg)
13725 ;; This function might be inhibited.
13726 (unless gnus-inhibit-hiding
13728 (set-buffer gnus-article-buffer)
13730 (let ((buffer-read-only nil)
13731 (props (nconc (list 'gnus-type 'headers)
13732 gnus-hidden-properties))
13733 (max (1+ (length gnus-sorted-header-list)))
13734 (ignored (when (not (stringp gnus-visible-headers))
13735 (cond ((stringp gnus-ignored-headers)
13736 gnus-ignored-headers)
13737 ((listp gnus-ignored-headers)
13738 (mapconcat 'identity gnus-ignored-headers
13741 (cond ((stringp gnus-visible-headers)
13742 gnus-visible-headers)
13743 ((and gnus-visible-headers
13744 (listp gnus-visible-headers))
13745 (mapconcat 'identity gnus-visible-headers "\\|"))))
13747 ;; First we narrow to just the headers.
13749 (goto-char (point-min))
13750 ;; Hide any "From " lines at the beginning of (mail) articles.
13751 (while (looking-at "From ")
13754 (gnus-hide-text (point-min) (point) props))
13755 ;; Then treat the rest of the header lines.
13758 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13759 ;; Then we use the two regular expressions
13760 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13761 ;; select which header lines is to remain visible in the
13763 (goto-char (point-min))
13764 (while (re-search-forward "^[^ \t]*:" nil t)
13765 (beginning-of-line)
13766 ;; We add the headers we want to keep to a list and delete
13767 ;; them from the buffer.
13769 (point) (1+ (point)) 'message-rank
13770 (if (or (and visible (looking-at visible))
13772 (not (looking-at ignored))))
13773 (gnus-article-header-rank)
13776 (message-sort-headers-1)
13777 (when (setq beg (text-property-any
13778 (point-min) (point-max) 'message-rank (+ 2 max)))
13779 ;; We make the unwanted headers invisible.
13781 (delete-region beg (point-max))
13782 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13783 (gnus-hide-text-type beg (point-max) 'headers))
13784 ;; Work around XEmacs lossage.
13785 (put-text-property (point-min) beg 'invisible nil))))))))
13787 (defun gnus-article-hide-boring-headers (&optional arg)
13788 "Toggle hiding of headers that aren't very interesting.
13789 If given a negative prefix, always show; if given a positive prefix,
13792 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13794 (set-buffer gnus-article-buffer)
13796 (let ((buffer-read-only nil)
13797 (list gnus-boring-article-headers)
13798 (inhibit-point-motion-hooks t)
13800 (nnheader-narrow-to-headers)
13802 (setq elem (pop list))
13803 (goto-char (point-min))
13805 ;; Hide empty headers.
13807 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13809 (gnus-hide-text-type
13810 (progn (beginning-of-line) (point))
13813 (if (re-search-forward "^[^ \t]" nil t)
13814 (match-beginning 0)
13817 ;; Hide boring Newsgroups header.
13818 ((eq elem 'newsgroups)
13819 (when (equal (mail-fetch-field "newsgroups")
13820 (gnus-group-real-name gnus-newsgroup-name))
13821 (gnus-article-hide-header "newsgroups")))
13822 ((eq elem 'followup-to)
13823 (when (equal (mail-fetch-field "followup-to")
13824 (mail-fetch-field "newsgroups"))
13825 (gnus-article-hide-header "followup-to")))
13826 ((eq elem 'reply-to)
13827 (let ((from (mail-fetch-field "from"))
13828 (reply-to (mail-fetch-field "reply-to")))
13832 (nth 1 (funcall gnus-extract-address-components from))
13833 (nth 1 (funcall gnus-extract-address-components
13835 (gnus-article-hide-header "reply-to"))))
13837 (let ((date (mail-fetch-field "date")))
13839 (< (gnus-days-between date (current-time-string))
13841 (gnus-article-hide-header "date")))))))))))
13843 (defun gnus-article-hide-header (header)
13845 (goto-char (point-min))
13846 (when (re-search-forward (concat "^" header ":") nil t)
13847 (gnus-hide-text-type
13848 (progn (beginning-of-line) (point))
13851 (if (re-search-forward "^[^ \t]" nil t)
13852 (match-beginning 0)
13854 'boring-headers))))
13856 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13857 (defun gnus-article-treat-overstrike ()
13858 "Translate overstrikes into bold text."
13861 (set-buffer gnus-article-buffer)
13862 (let ((buffer-read-only nil))
13863 (while (search-forward "\b" nil t)
13864 (let ((next (following-char))
13865 (previous (char-after (- (point) 2))))
13866 (cond ((eq next previous)
13867 (put-text-property (- (point) 2) (point) 'invisible t)
13868 (put-text-property (point) (1+ (point)) 'face 'bold))
13870 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13872 (- (point) 2) (1- (point)) 'face 'underline))
13874 (put-text-property (- (point) 2) (point) 'invisible t)
13876 (point) (1+ (point)) 'face 'underline))))))))
13878 (defun gnus-article-word-wrap ()
13879 "Format too long lines."
13882 (set-buffer gnus-article-buffer)
13883 (let ((buffer-read-only nil))
13885 (goto-char (point-min))
13886 (search-forward "\n\n" nil t)
13888 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13889 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13890 (adaptive-fill-mode t))
13891 (while (not (eobp))
13892 (and (>= (current-column) (min fill-column (window-width)))
13893 (/= (preceding-char) ?:)
13894 (fill-paragraph nil))
13895 (end-of-line 2))))))
13897 (defun gnus-article-remove-cr ()
13898 "Remove carriage returns from an article."
13901 (set-buffer gnus-article-buffer)
13902 (let ((buffer-read-only nil))
13903 (goto-char (point-min))
13904 (while (search-forward "\r" nil t)
13905 (replace-match "" t t)))))
13907 (defun gnus-article-remove-trailing-blank-lines ()
13908 "Remove all trailing blank lines from the article."
13911 (set-buffer gnus-article-buffer)
13912 (let ((buffer-read-only nil))
13913 (goto-char (point-max))
13917 (while (looking-at "^[ \t]*$")
13922 (defun gnus-article-display-x-face (&optional force)
13923 "Look for an X-Face header and display it if present."
13924 (interactive (list 'force))
13926 (set-buffer gnus-article-buffer)
13927 ;; Delete the old process, if any.
13928 (when (process-status "gnus-x-face")
13929 (delete-process "gnus-x-face"))
13930 (let ((inhibit-point-motion-hooks t)
13931 (case-fold-search nil)
13934 (nnheader-narrow-to-headers)
13935 (setq from (mail-fetch-field "from"))
13936 (goto-char (point-min))
13937 (when (and gnus-article-x-face-command
13939 ;; Check whether this face is censored.
13940 (not gnus-article-x-face-too-ugly)
13941 (and gnus-article-x-face-too-ugly from
13942 (not (string-match gnus-article-x-face-too-ugly
13944 ;; Has to be present.
13945 (re-search-forward "^X-Face: " nil t))
13946 ;; We now have the area of the buffer where the X-Face is stored.
13947 (let ((beg (point))
13948 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13949 ;; We display the face.
13950 (if (symbolp gnus-article-x-face-command)
13951 ;; The command is a lisp function, so we call it.
13952 (if (gnus-functionp gnus-article-x-face-command)
13953 (funcall gnus-article-x-face-command beg end)
13954 (error "%s is not a function" gnus-article-x-face-command))
13955 ;; The command is a string, so we interpret the command
13956 ;; as a, well, command, and fork it off.
13957 (let ((process-connection-type nil))
13958 (process-kill-without-query
13960 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13961 (process-send-region "gnus-x-face" beg end)
13962 (process-send-eof "gnus-x-face")))))))))
13964 (defalias 'gnus-header-decode-quoted-printable 'gnus-decode-rfc1522)
13965 (defun gnus-decode-rfc1522 ()
13966 "Hack to remove QP encoding from headers."
13967 (let ((case-fold-search t)
13968 (inhibit-point-motion-hooks t)
13969 (buffer-read-only nil)
13973 (goto-char (point-min))
13974 (or (search-forward "\n\n" nil t) (point-max)))
13976 (while (re-search-forward
13977 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13978 (setq string (match-string 1))
13979 (narrow-to-region (match-beginning 0) (match-end 0))
13980 (delete-region (point-min) (point-max))
13982 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13983 (subst-char-in-region (point-min) (point-max) ?_ ? )
13985 (goto-char (point-min))))))
13987 (defun gnus-article-de-quoted-unreadable (&optional force)
13988 "Do a naive translation of a quoted-printable-encoded article.
13989 This is in no way, shape or form meant as a replacement for real MIME
13990 processing, but is simply a stop-gap measure until MIME support is
13992 If FORCE, decode the article whether it is marked as quoted-printable
13994 (interactive (list 'force))
13996 (set-buffer gnus-article-buffer)
13997 (let ((case-fold-search t)
13998 (buffer-read-only nil)
13999 (type (gnus-fetch-field "content-transfer-encoding")))
14000 (gnus-decode-rfc1522)
14002 (and type (string-match "quoted-printable" (downcase type))))
14003 (goto-char (point-min))
14004 (search-forward "\n\n" nil 'move)
14005 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14007 (defun gnus-mime-decode-quoted-printable (from to)
14008 "Decode Quoted-Printable in the region between FROM and TO."
14011 (while (search-forward "=" to t)
14012 (cond ((eq (following-char) ?\n)
14015 ((looking-at "[0-9A-F][0-9A-F]")
14016 (subst-char-in-region
14017 (1- (point)) (point) ?=
14018 (hexl-hex-string-to-integer
14019 (buffer-substring (point) (+ 2 (point)))))
14023 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14025 (defun gnus-article-hide-pgp (&optional arg)
14026 "Toggle hiding of any PGP headers and signatures in the current article.
14027 If given a negative prefix, always show; if given a positive prefix,
14030 (unless (gnus-article-check-hidden-text 'pgp arg)
14032 (set-buffer gnus-article-buffer)
14033 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14034 buffer-read-only beg end)
14036 (goto-char (point-min))
14037 ;; Hide the "header".
14038 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14039 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14041 ;; Hide the actual signature.
14042 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14043 (setq end (1+ (match-beginning 0)))
14046 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14048 ;; Perhaps we shouldn't hide to the end of the buffer
14049 ;; if there is no end to the signature?
14052 ;; Hide "- " PGP quotation markers.
14053 (when (and beg end)
14054 (narrow-to-region beg end)
14055 (goto-char (point-min))
14056 (while (re-search-forward "^- " nil t)
14057 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14060 (defun gnus-article-hide-signature (&optional arg)
14061 "Hide the signature in the current article.
14062 If given a negative prefix, always show; if given a positive prefix,
14065 (unless (gnus-article-check-hidden-text 'signature arg)
14067 (set-buffer gnus-article-buffer)
14069 (let ((buffer-read-only nil))
14070 (when (gnus-narrow-to-signature)
14071 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14073 (defun gnus-article-strip-leading-blank-lines ()
14074 "Remove all blank lines from the beginning of the article."
14077 (set-buffer gnus-article-buffer)
14078 (let (buffer-read-only)
14079 (goto-char (point-min))
14080 (when (search-forward "\n\n" nil t)
14081 (while (looking-at "[ \t]$")
14082 (gnus-delete-line))))))
14084 (defun gnus-narrow-to-signature ()
14085 "Narrow to the signature."
14087 (goto-char (point-max))
14088 (when (re-search-backward gnus-signature-separator nil t)
14090 (when (or (null gnus-signature-limit)
14091 (and (numberp gnus-signature-limit)
14092 (< (- (point-max) (point)) gnus-signature-limit))
14093 (and (gnus-functionp gnus-signature-limit)
14094 (funcall gnus-signature-limit))
14095 (and (stringp gnus-signature-limit)
14096 (not (re-search-forward gnus-signature-limit nil t))))
14097 (narrow-to-region (point) (point-max))
14100 (defun gnus-article-check-hidden-text (type arg)
14101 "Return nil if hiding is necessary."
14103 (set-buffer gnus-article-buffer)
14104 (let ((hide (gnus-article-hidden-text-p type)))
14105 (cond ((or (and (null arg) (eq hide 'hidden))
14106 (and arg (< 0 (prefix-numeric-value arg))))
14107 (gnus-article-show-hidden-text type))
14109 (gnus-article-show-hidden-text type t))
14112 (defun gnus-article-hidden-text-p (type)
14113 "Say whether the current buffer contains hidden text of type TYPE."
14114 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14116 (if (get-text-property pos 'invisible)
14120 (defun gnus-article-hide (&optional arg force)
14121 "Hide all the gruft in the current article.
14122 This means that PGP stuff, signatures, cited text and (some)
14123 headers will be hidden.
14124 If given a prefix, show the hidden text instead."
14125 (interactive (list current-prefix-arg 'force))
14126 (gnus-article-hide-headers arg)
14127 (gnus-article-hide-pgp arg)
14128 (gnus-article-hide-citation-maybe arg force)
14129 (gnus-article-hide-signature arg))
14131 (defun gnus-article-show-hidden-text (type &optional hide)
14132 "Show all hidden text of type TYPE.
14133 If HIDE, hide the text instead."
14135 (set-buffer gnus-article-buffer)
14136 (let ((buffer-read-only nil)
14137 (inhibit-point-motion-hooks t)
14139 (while (gnus-goto-char (text-property-any
14140 beg (point-max) 'gnus-type type))
14144 (gnus-hide-text beg (point) gnus-hidden-properties)
14145 (gnus-unhide-text beg (point)))
14146 (setq beg (point)))
14149 (defvar gnus-article-time-units
14150 `((year . ,(* 365.25 24 60 60))
14151 (week . ,(* 7 24 60 60))
14152 (day . ,(* 24 60 60))
14153 (hour . ,(* 60 60))
14156 "Mapping from time units to seconds.")
14158 (defun gnus-article-date-ut (&optional type highlight)
14159 "Convert DATE date to universal time in the current article.
14160 If TYPE is `local', convert to local time; if it is `lapsed', output
14161 how much time has lapsed since DATE."
14162 (interactive (list 'ut t))
14163 (let* ((header (or gnus-current-headers
14164 (gnus-summary-article-header) ""))
14165 (date (and (vectorp header) (mail-header-date header)))
14166 (date-regexp "^Date: \\|^X-Sent: ")
14167 (now (current-time))
14168 (inhibit-point-motion-hooks t)
14170 (when (and date (not (string= date "")))
14172 (set-buffer gnus-article-buffer)
14174 (nnheader-narrow-to-headers)
14175 (let ((buffer-read-only nil))
14176 ;; Delete any old Date headers.
14177 (if (re-search-forward date-regexp nil t)
14179 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14180 eface (get-text-property (1- (gnus-point-at-eol))
14182 (message-remove-header date-regexp t)
14183 (beginning-of-line))
14184 (goto-char (point-max)))
14185 (insert (gnus-make-date-line date type))
14186 ;; Do highlighting.
14188 (when (and (gnus-visual-p 'article-highlight 'highlight)
14189 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14190 (put-text-property (match-beginning 1) (match-end 1)
14192 (put-text-property (match-beginning 2) (match-end 2)
14193 'face eface))))))))
14195 (defun gnus-make-date-line (date type)
14196 "Return a DATE line of TYPE."
14198 ;; Convert to the local timezone. We have to slap a
14199 ;; `condition-case' round the calls to the timezone
14200 ;; functions since they aren't particularly resistant to
14203 (concat "Date: " (condition-case ()
14204 (timezone-make-date-arpa-standard date)
14207 ;; Convert to Universal Time.
14211 (timezone-make-date-arpa-standard date nil "UT")
14214 ;; Get the original date from the article.
14215 ((eq type 'original)
14216 (concat "Date: " date "\n"))
14217 ;; Do an X-Sent lapsed format.
14219 ;; If the date is seriously mangled, the timezone
14220 ;; functions are liable to bug out, so we condition-case
14221 ;; the entire thing.
14222 (let* ((now (current-time))
14227 (timezone-make-date-arpa-standard
14228 (current-time-string now)
14229 (current-time-zone now) "UT"))
14231 (timezone-make-date-arpa-standard
14234 (real-sec (+ (* (float (car real-time)) 65536)
14236 (sec (abs real-sec))
14239 ((equal real-time '(0 0))
14240 "X-Sent: Unknown\n")
14246 ;; This is a bit convoluted, but basically we go
14247 ;; through the time units for years, weeks, etc,
14248 ;; and divide things to see whether that results
14249 ;; in positive answers.
14252 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14253 ;; The (remaining) seconds are too few to
14254 ;; be divided into this time unit.
14256 ;; It's big enough, so we output it.
14257 (setq sec (- sec (* num (cdr unit))))
14259 (concat (if prev ", " "") (int-to-string
14261 " " (symbol-name (car unit))
14262 (if (> num 1) "s" ""))
14264 gnus-article-time-units "")
14265 ;; If dates are odd, then it might appear like the
14266 ;; article was sent in the future.
14269 " in the future\n"))))))
14271 (error "Unknown conversion type: %s" type))))
14273 (defun gnus-article-date-local (&optional highlight)
14274 "Convert the current article date to the local timezone."
14275 (interactive (list t))
14276 (gnus-article-date-ut 'local highlight))
14278 (defun gnus-article-date-original (&optional highlight)
14279 "Convert the current article date to what it was originally.
14280 This is only useful if you have used some other date conversion
14281 function and want to see what the date was before converting."
14282 (interactive (list t))
14283 (gnus-article-date-ut 'original highlight))
14285 (defun gnus-article-date-lapsed (&optional highlight)
14286 "Convert the current article date to time lapsed since it was sent."
14287 (interactive (list t))
14288 (gnus-article-date-ut 'lapsed highlight))
14290 (defun gnus-article-maybe-highlight ()
14291 "Do some article highlighting if `gnus-visual' is non-nil."
14292 (if (gnus-visual-p 'article-highlight 'highlight)
14293 (gnus-article-highlight-some)))
14297 (defun gnus-output-to-rmail (file-name)
14298 "Append the current article to an Rmail file named FILE-NAME."
14300 ;; Most of these codes are borrowed from rmailout.el.
14301 (setq file-name (expand-file-name file-name))
14302 (setq rmail-default-rmail-file file-name)
14303 (let ((artbuf (current-buffer))
14304 (tmpbuf (get-buffer-create " *Gnus-output*")))
14306 (or (get-file-buffer file-name)
14307 (file-exists-p file-name)
14308 (if (gnus-yes-or-no-p
14309 (concat "\"" file-name "\" does not exist, create it? "))
14310 (let ((file-buffer (create-file-buffer file-name)))
14312 (set-buffer file-buffer)
14313 (rmail-insert-rmail-file-header)
14314 (let ((require-final-newline nil))
14315 (write-region (point-min) (point-max) file-name t 1)))
14316 (kill-buffer file-buffer))
14317 (error "Output file does not exist")))
14318 (set-buffer tmpbuf)
14319 (buffer-disable-undo (current-buffer))
14321 (insert-buffer-substring artbuf)
14322 (gnus-convert-article-to-rmail)
14323 ;; Decide whether to append to a file or to an Emacs buffer.
14324 (let ((outbuf (get-file-buffer file-name)))
14326 (append-to-file (point-min) (point-max) file-name)
14327 ;; File has been visited, in buffer OUTBUF.
14328 (set-buffer outbuf)
14329 (let ((buffer-read-only nil)
14330 (msg (and (boundp 'rmail-current-message)
14331 (symbol-value 'rmail-current-message))))
14332 ;; If MSG is non-nil, buffer is in RMAIL mode.
14335 (narrow-to-region (point-max) (point-max))))
14336 (insert-buffer-substring tmpbuf)
14339 (goto-char (point-min))
14341 (search-backward "\^_")
14342 (narrow-to-region (point) (point-max))
14343 (goto-char (1+ (point-min)))
14344 (rmail-count-new-messages t)
14345 (rmail-show-message msg)))))))
14346 (kill-buffer tmpbuf)))
14348 (defun gnus-output-to-file (file-name)
14349 "Append the current article to a file named FILE-NAME."
14350 (setq file-name (expand-file-name file-name))
14351 (let ((artbuf (current-buffer))
14352 (tmpbuf (get-buffer-create " *Gnus-output*")))
14354 (set-buffer tmpbuf)
14355 (buffer-disable-undo (current-buffer))
14357 (insert-buffer-substring artbuf)
14358 ;; Append newline at end of the buffer as separator, and then
14359 ;; save it to file.
14360 (goto-char (point-max))
14362 (append-to-file (point-min) (point-max) file-name))
14363 (kill-buffer tmpbuf)))
14365 (defun gnus-convert-article-to-rmail ()
14366 "Convert article in current buffer to Rmail message format."
14367 (let ((buffer-read-only nil))
14368 ;; Convert article directly into Babyl format.
14369 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14370 (goto-char (point-min))
14371 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14372 (while (search-forward "\n\^_" nil t) ;single char
14373 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14374 (goto-char (point-max))
14377 (defun gnus-narrow-to-page (&optional arg)
14378 "Narrow the article buffer to a page.
14379 If given a numerical ARG, move forward ARG pages."
14381 (setq arg (if arg (prefix-numeric-value arg) 0))
14383 (set-buffer gnus-article-buffer)
14384 (goto-char (point-min))
14386 (when (gnus-visual-p 'page-marker)
14387 (let ((buffer-read-only nil))
14388 (gnus-remove-text-with-property 'gnus-prev)
14389 (gnus-remove-text-with-property 'gnus-next)))
14392 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14394 (re-search-forward page-delimiter nil 'move arg)))
14395 (goto-char (match-end 0)))
14398 (if (re-search-forward page-delimiter nil 'move)
14399 (match-beginning 0)
14401 (when (and (gnus-visual-p 'page-marker)
14402 (not (= (point-min) 1)))
14404 (goto-char (point-min))
14405 (gnus-insert-prev-page-button)))
14406 (when (and (gnus-visual-p 'page-marker)
14407 (not (= (1- (point-max)) (buffer-size))))
14409 (goto-char (point-max))
14410 (gnus-insert-next-page-button)))))
14412 ;; Article mode commands
14414 (defun gnus-article-goto-next-page ()
14415 "Show the next page of the article."
14417 (when (gnus-article-next-page)
14418 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14420 (defun gnus-article-goto-prev-page ()
14421 "Show the next page of the article."
14423 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14424 (gnus-article-prev-page nil)))
14426 (defun gnus-article-next-page (&optional lines)
14427 "Show the next page of the current article.
14428 If end of article, return non-nil. Otherwise return nil.
14429 Argument LINES specifies lines to be scrolled up."
14431 (move-to-window-line -1)
14432 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14433 (if (save-excursion
14435 (and (pos-visible-in-window-p) ;Not continuation line.
14437 ;; Nothing in this page.
14438 (if (or (not gnus-break-pages)
14441 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14443 (gnus-narrow-to-page 1) ;Go to next page.
14445 ;; More in this page.
14449 ;; Long lines may cause an end-of-buffer error.
14450 (goto-char (point-max))))
14451 (move-to-window-line 0)
14454 (defun gnus-article-prev-page (&optional lines)
14455 "Show previous page of current article.
14456 Argument LINES specifies lines to be scrolled down."
14458 (move-to-window-line 0)
14459 (if (and gnus-break-pages
14461 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14463 (gnus-narrow-to-page -1) ;Go to previous page.
14464 (goto-char (point-max))
14468 (scroll-down lines)
14470 (move-to-window-line 0))))
14472 (defun gnus-article-refer-article ()
14473 "Read article specified by message-id around point."
14475 (let ((point (point)))
14476 (search-forward ">" nil t) ;Move point to end of "<....>".
14477 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14478 (let ((message-id (match-string 1)))
14480 (set-buffer gnus-summary-buffer)
14481 (gnus-summary-refer-article message-id))
14482 (goto-char (point))
14483 (error "No references around point"))))
14485 (defun gnus-article-show-summary ()
14486 "Reconfigure windows to show summary buffer."
14488 (gnus-configure-windows 'article)
14489 (gnus-summary-goto-subject gnus-current-article))
14491 (defun gnus-article-describe-briefly ()
14492 "Describe article mode commands briefly."
14495 (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")))
14497 (defun gnus-article-summary-command ()
14498 "Execute the last keystroke in the summary buffer."
14500 (let ((obuf (current-buffer))
14501 (owin (current-window-configuration))
14503 (switch-to-buffer gnus-summary-buffer 'norecord)
14504 (setq func (lookup-key (current-local-map) (this-command-keys)))
14505 (call-interactively func)
14507 (set-window-configuration owin)
14508 (set-window-point (get-buffer-window (current-buffer)) (point))))
14510 (defun gnus-article-summary-command-nosave ()
14511 "Execute the last keystroke in the summary buffer."
14514 (pop-to-buffer gnus-summary-buffer 'norecord)
14515 (setq func (lookup-key (current-local-map) (this-command-keys)))
14516 (call-interactively func)))
14518 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14519 "Read a summary buffer key sequence and execute it from the article buffer."
14522 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14523 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14527 (set-buffer gnus-summary-buffer)
14528 (push (or key last-command-event) unread-command-events)
14529 (setq keys (read-key-sequence nil)))
14532 (if (member keys nosaves)
14534 (pop-to-buffer gnus-summary-buffer 'norecord)
14535 (if (setq func (lookup-key (current-local-map) keys))
14536 (call-interactively func)
14538 (let ((obuf (current-buffer))
14539 (owin (current-window-configuration))
14542 (if not-restore-window
14543 (pop-to-buffer gnus-summary-buffer 'norecord)
14544 (switch-to-buffer gnus-summary-buffer 'norecord))
14545 (setq in-buffer (current-buffer))
14546 (if (setq func (lookup-key (current-local-map) keys))
14547 (call-interactively func)
14549 (when (eq in-buffer (current-buffer))
14551 (unless not-restore-window
14552 (set-window-configuration owin))
14553 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14557 ;;; Kill file handling.
14561 (defalias 'gnus-batch-kill 'gnus-batch-score)
14563 (defun gnus-batch-score ()
14564 "Run batched scoring.
14565 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14566 Newsgroups is a list of strings in Bnews format. If you want to score
14567 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14568 score the alt hierarchy, you'd say \"!alt.all\"."
14571 (gnus-newsrc-parse-options
14572 (apply (function concat)
14573 (mapcar (lambda (g) (concat g " "))
14574 command-line-args-left))))
14575 (gnus-expert-user t)
14576 (nnmail-spool-file nil)
14577 (gnus-use-dribble-file nil)
14578 (yes (car yes-and-no))
14579 (no (cdr yes-and-no))
14581 ;; Disable verbose message.
14582 gnus-novice-user gnus-large-newsgroup)
14583 ;; Eat all arguments.
14584 (setq command-line-args-left nil)
14587 ;; Apply kills to specified newsgroups in command line arguments.
14588 (setq newsrc (cdr gnus-newsrc-alist))
14590 (setq group (caar newsrc))
14591 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14592 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14594 (or (eq (car entry) t)
14595 (not (zerop (car entry)))))
14596 (if yes (string-match yes group) t)
14597 (or (null no) (not (string-match no group))))
14599 (gnus-summary-read-group group nil t nil t)
14600 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14601 (gnus-summary-exit))))
14602 (setq newsrc (cdr newsrc)))
14604 (switch-to-buffer gnus-group-buffer)
14605 (gnus-group-save-newsrc)))
14607 (defun gnus-apply-kill-file ()
14608 "Apply a kill file to the current newsgroup.
14609 Returns the number of articles marked as read."
14610 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14611 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14612 (gnus-apply-kill-file-internal)
14615 (defun gnus-kill-save-kill-buffer ()
14616 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14617 (when (get-file-buffer file)
14619 (set-buffer (get-file-buffer file))
14620 (and (buffer-modified-p) (save-buffer))
14621 (kill-buffer (current-buffer))))))
14623 (defvar gnus-kill-file-name "KILL"
14624 "Suffix of the kill files.")
14626 (defun gnus-newsgroup-kill-file (newsgroup)
14627 "Return the name of a kill file name for NEWSGROUP.
14628 If NEWSGROUP is nil, return the global kill file name instead."
14630 ;; The global KILL file is placed at top of the directory.
14631 ((or (null newsgroup)
14632 (string-equal newsgroup ""))
14633 (expand-file-name gnus-kill-file-name
14634 (or gnus-kill-files-directory "~/News")))
14635 ;; Append ".KILL" to newsgroup name.
14636 ((gnus-use-long-file-name 'not-kill)
14637 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14638 "." gnus-kill-file-name)
14639 (or gnus-kill-files-directory "~/News")))
14640 ;; Place "KILL" under the hierarchical directory.
14642 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14643 "/" gnus-kill-file-name)
14644 (or gnus-kill-files-directory "~/News")))))
14651 (defvar gnus-dribble-ignore nil)
14652 (defvar gnus-dribble-eval-file nil)
14654 (defun gnus-dribble-file-name ()
14655 "Return the dribble file for the current .newsrc."
14657 (if gnus-dribble-directory
14658 (concat (file-name-as-directory gnus-dribble-directory)
14659 (file-name-nondirectory gnus-current-startup-file))
14660 gnus-current-startup-file)
14663 (defun gnus-dribble-enter (string)
14664 "Enter STRING into the dribble buffer."
14665 (if (and (not gnus-dribble-ignore)
14666 gnus-dribble-buffer
14667 (buffer-name gnus-dribble-buffer))
14668 (let ((obuf (current-buffer)))
14669 (set-buffer gnus-dribble-buffer)
14670 (insert string "\n")
14671 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14672 (set-buffer obuf))))
14674 (defun gnus-dribble-read-file ()
14675 "Read the dribble file from disk."
14676 (let ((dribble-file (gnus-dribble-file-name)))
14678 (set-buffer (setq gnus-dribble-buffer
14680 (file-name-nondirectory dribble-file))))
14681 (gnus-add-current-to-buffer-list)
14683 (setq buffer-file-name dribble-file)
14685 (buffer-disable-undo (current-buffer))
14686 (bury-buffer (current-buffer))
14687 (set-buffer-modified-p nil)
14688 (let ((auto (make-auto-save-file-name))
14689 (gnus-dribble-ignore t))
14690 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14691 ;; Load whichever file is newest -- the auto save file
14692 ;; or the "real" file.
14693 (if (file-newer-than-file-p auto dribble-file)
14694 (insert-file-contents auto)
14695 (insert-file-contents dribble-file))
14696 (unless (zerop (buffer-size))
14697 (set-buffer-modified-p t))
14698 ;; Set the file modes to reflect the .newsrc file modes.
14700 (when (file-exists-p gnus-current-startup-file)
14701 (set-file-modes dribble-file
14702 (file-modes gnus-current-startup-file)))
14703 ;; Possibly eval the file later.
14704 (when (gnus-y-or-n-p
14705 "Auto-save file exists. Do you want to read it? ")
14706 (setq gnus-dribble-eval-file t)))))))
14708 (defun gnus-dribble-eval-file ()
14709 (if (not gnus-dribble-eval-file)
14711 (setq gnus-dribble-eval-file nil)
14713 (let ((gnus-dribble-ignore t))
14714 (set-buffer gnus-dribble-buffer)
14715 (eval-buffer (current-buffer))))))
14717 (defun gnus-dribble-delete-file ()
14718 (if (file-exists-p (gnus-dribble-file-name))
14719 (delete-file (gnus-dribble-file-name)))
14720 (if gnus-dribble-buffer
14722 (set-buffer gnus-dribble-buffer)
14723 (let ((auto (make-auto-save-file-name)))
14724 (if (file-exists-p auto)
14725 (delete-file auto))
14727 (set-buffer-modified-p nil)))))
14729 (defun gnus-dribble-save ()
14730 (if (and gnus-dribble-buffer
14731 (buffer-name gnus-dribble-buffer))
14733 (set-buffer gnus-dribble-buffer)
14736 (defun gnus-dribble-clear ()
14738 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14740 (set-buffer gnus-dribble-buffer)
14742 (set-buffer-modified-p nil)
14743 (setq buffer-saved-size (buffer-size))))))
14747 ;;; Server Communication
14750 (defun gnus-start-news-server (&optional confirm)
14751 "Open a method for getting news.
14752 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14754 (if gnus-current-select-method
14755 ;; Stream is already opened.
14757 ;; Open NNTP server.
14758 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14761 ;; Read server name with completion.
14762 (setq gnus-nntp-server
14763 (completing-read "NNTP server: "
14764 (mapcar (lambda (server) (list server))
14765 (cons (list gnus-nntp-server)
14766 gnus-secondary-servers))
14767 nil nil gnus-nntp-server))))
14769 (if (and gnus-nntp-server
14770 (stringp gnus-nntp-server)
14771 (not (string= gnus-nntp-server "")))
14772 (setq gnus-select-method
14773 (cond ((or (string= gnus-nntp-server "")
14774 (string= gnus-nntp-server "::"))
14775 (list 'nnspool (system-name)))
14776 ((string-match "^:" gnus-nntp-server)
14777 (list 'nnmh gnus-nntp-server
14778 (list 'nnmh-directory
14779 (file-name-as-directory
14781 (concat "~/" (substring
14782 gnus-nntp-server 1)))))
14783 (list 'nnmh-get-new-mail nil)))
14785 (list 'nntp gnus-nntp-server)))))
14787 (setq how (car gnus-select-method))
14788 (cond ((eq how 'nnspool)
14790 (gnus-message 5 "Looking up local news spool..."))
14793 (gnus-message 5 "Looking up mh spool..."))
14796 (setq gnus-current-select-method gnus-select-method)
14797 (run-hooks 'gnus-open-server-hook)
14799 ;; gnus-open-server-hook might have opened it
14800 (gnus-server-opened gnus-select-method)
14801 (gnus-open-server gnus-select-method)
14804 "%s (%s) open error: '%s'. Continue? "
14805 (car gnus-select-method) (cadr gnus-select-method)
14806 (gnus-status-message gnus-select-method)))
14807 (gnus-error 1 "Couldn't open server on %s"
14808 (nth 1 gnus-select-method))))))
14810 (defun gnus-check-group (group)
14811 "Try to make sure that the server where GROUP exists is alive."
14812 (let ((method (gnus-find-method-for-group group)))
14813 (or (gnus-server-opened method)
14814 (gnus-open-server method))))
14816 (defun gnus-check-server (&optional method silent)
14817 "Check whether the connection to METHOD is down.
14818 If METHOD is nil, use `gnus-select-method'.
14819 If it is down, start it up (again)."
14820 (let ((method (or method gnus-select-method)))
14821 ;; Transform virtual server names into select methods.
14822 (when (stringp method)
14823 (setq method (gnus-server-to-method method)))
14824 (if (gnus-server-opened method)
14825 ;; The stream is already opened.
14827 ;; Open the server.
14829 (gnus-message 5 "Opening %s server%s..." (car method)
14830 (if (equal (nth 1 method) "") ""
14831 (format " on %s" (nth 1 method)))))
14832 (run-hooks 'gnus-open-server-hook)
14834 (gnus-open-server method)
14838 (defun gnus-get-function (method function)
14839 "Return a function symbol based on METHOD and FUNCTION."
14840 ;; Translate server names into methods.
14842 (error "Attempted use of a nil select method"))
14843 (when (stringp method)
14844 (setq method (gnus-server-to-method method)))
14845 (let ((func (intern (format "%s-%s" (car method) function))))
14846 ;; If the functions isn't bound, we require the backend in
14848 (unless (fboundp func)
14849 (require (car method))
14850 (unless (fboundp func)
14851 ;; This backend doesn't implement this function.
14852 (error "No such function: %s" func)))
14857 ;;; Interface functions to the backends.
14860 (defun gnus-open-server (method)
14861 "Open a connection to METHOD."
14862 (when (stringp method)
14863 (setq method (gnus-server-to-method method)))
14864 (let ((elem (assoc method gnus-opened-servers)))
14865 ;; If this method was previously denied, we just return nil.
14866 (if (eq (nth 1 elem) 'denied)
14868 (gnus-message 1 "Denied server")
14870 ;; Open the server.
14872 (funcall (gnus-get-function method 'open-server)
14873 (nth 1 method) (nthcdr 2 method))))
14874 ;; If this hasn't been opened before, we add it to the list.
14876 (setq elem (list method nil)
14877 gnus-opened-servers (cons elem gnus-opened-servers)))
14878 ;; Set the status of this server.
14879 (setcar (cdr elem) (if result 'ok 'denied))
14880 ;; Return the result from the "open" call.
14883 (defun gnus-close-server (method)
14884 "Close the connection to METHOD."
14885 (when (stringp method)
14886 (setq method (gnus-server-to-method method)))
14887 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14889 (defun gnus-request-list (method)
14890 "Request the active file from METHOD."
14891 (when (stringp method)
14892 (setq method (gnus-server-to-method method)))
14893 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14895 (defun gnus-request-list-newsgroups (method)
14896 "Request the newsgroups file from METHOD."
14897 (when (stringp method)
14898 (setq method (gnus-server-to-method method)))
14899 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14901 (defun gnus-request-newgroups (date method)
14902 "Request all new groups since DATE from METHOD."
14903 (when (stringp method)
14904 (setq method (gnus-server-to-method method)))
14905 (funcall (gnus-get-function method 'request-newgroups)
14906 date (nth 1 method)))
14908 (defun gnus-server-opened (method)
14909 "Check whether a connection to METHOD has been opened."
14910 (when (stringp method)
14911 (setq method (gnus-server-to-method method)))
14912 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14914 (defun gnus-status-message (method)
14915 "Return the status message from METHOD.
14916 If METHOD is a string, it is interpreted as a group name. The method
14917 this group uses will be queried."
14918 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14920 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14922 (defun gnus-request-group (group &optional dont-check method)
14923 "Request GROUP. If DONT-CHECK, no information is required."
14924 (let ((method (or method (gnus-find-method-for-group group))))
14925 (when (stringp method)
14926 (setq method (gnus-server-to-method method)))
14927 (funcall (gnus-get-function method 'request-group)
14928 (gnus-group-real-name group) (nth 1 method) dont-check)))
14930 (defun gnus-request-asynchronous (group &optional articles)
14931 "Request that GROUP behave asynchronously.
14932 ARTICLES is the `data' of the group."
14933 (let ((method (gnus-find-method-for-group group)))
14934 (funcall (gnus-get-function method 'request-asynchronous)
14935 (gnus-group-real-name group) (nth 1 method) articles)))
14937 (defun gnus-list-active-group (group)
14938 "Request active information on GROUP."
14939 (let ((method (gnus-find-method-for-group group))
14940 (func 'list-active-group))
14941 (when (gnus-check-backend-function func group)
14942 (funcall (gnus-get-function method func)
14943 (gnus-group-real-name group) (nth 1 method)))))
14945 (defun gnus-request-group-description (group)
14946 "Request a description of GROUP."
14947 (let ((method (gnus-find-method-for-group group))
14948 (func 'request-group-description))
14949 (when (gnus-check-backend-function func group)
14950 (funcall (gnus-get-function method func)
14951 (gnus-group-real-name group) (nth 1 method)))))
14953 (defun gnus-close-group (group)
14954 "Request the GROUP be closed."
14955 (let ((method (gnus-find-method-for-group group)))
14956 (funcall (gnus-get-function method 'close-group)
14957 (gnus-group-real-name group) (nth 1 method))))
14959 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14960 "Request headers for ARTICLES in GROUP.
14961 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14962 (let ((method (gnus-find-method-for-group group)))
14963 (if (and gnus-use-cache (numberp (car articles)))
14964 (gnus-cache-retrieve-headers articles group fetch-old)
14965 (funcall (gnus-get-function method 'retrieve-headers)
14966 articles (gnus-group-real-name group) (nth 1 method)
14969 (defun gnus-retrieve-groups (groups method)
14970 "Request active information on GROUPS from METHOD."
14971 (when (stringp method)
14972 (setq method (gnus-server-to-method method)))
14973 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14975 (defun gnus-request-type (group &optional article)
14976 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14977 (let ((method (gnus-find-method-for-group group)))
14978 (if (not (gnus-check-backend-function 'request-type (car method)))
14980 (funcall (gnus-get-function method 'request-type)
14981 (gnus-group-real-name group) article))))
14983 (defun gnus-request-update-mark (group article mark)
14984 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14985 (let ((method (gnus-find-method-for-group group)))
14986 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14988 (funcall (gnus-get-function method 'request-update-mark)
14989 (gnus-group-real-name group) article mark))))
14991 (defun gnus-request-article (article group &optional buffer)
14992 "Request the ARTICLE in GROUP.
14993 ARTICLE can either be an article number or an article Message-ID.
14994 If BUFFER, insert the article in that group."
14995 (let ((method (gnus-find-method-for-group group)))
14996 (funcall (gnus-get-function method 'request-article)
14997 article (gnus-group-real-name group) (nth 1 method) buffer)))
14999 (defun gnus-request-head (article group)
15000 "Request the head of ARTICLE in GROUP."
15001 (let ((method (gnus-find-method-for-group group)))
15002 (funcall (gnus-get-function method 'request-head)
15003 article (gnus-group-real-name group) (nth 1 method))))
15005 (defun gnus-request-body (article group)
15006 "Request the body of ARTICLE in GROUP."
15007 (let ((method (gnus-find-method-for-group group)))
15008 (funcall (gnus-get-function method 'request-body)
15009 article (gnus-group-real-name group) (nth 1 method))))
15011 (defun gnus-request-post (method)
15012 "Post the current buffer using METHOD."
15013 (when (stringp method)
15014 (setq method (gnus-server-to-method method)))
15015 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15017 (defun gnus-request-scan (group method)
15018 "Request a SCAN being performed in GROUP from METHOD.
15019 If GROUP is nil, all groups on METHOD are scanned."
15020 (let ((method (if group (gnus-find-method-for-group group) method)))
15021 (funcall (gnus-get-function method 'request-scan)
15022 (and group (gnus-group-real-name group)) (nth 1 method))))
15024 (defsubst gnus-request-update-info (info method)
15025 "Request that METHOD update INFO."
15026 (when (stringp method)
15027 (setq method (gnus-server-to-method method)))
15028 (when (gnus-check-backend-function 'request-update-info (car method))
15029 (funcall (gnus-get-function method 'request-update-info)
15030 (gnus-group-real-name (gnus-info-group info))
15031 info (nth 1 method))))
15033 (defun gnus-request-expire-articles (articles group &optional force)
15034 (let ((method (gnus-find-method-for-group group)))
15035 (funcall (gnus-get-function method 'request-expire-articles)
15036 articles (gnus-group-real-name group) (nth 1 method)
15039 (defun gnus-request-move-article
15040 (article group server accept-function &optional last)
15041 (let ((method (gnus-find-method-for-group group)))
15042 (funcall (gnus-get-function method 'request-move-article)
15043 article (gnus-group-real-name group)
15044 (nth 1 method) accept-function last)))
15046 (defun gnus-request-accept-article (group method &optional last)
15047 ;; Make sure there's a newline at the end of the article.
15048 (when (stringp method)
15049 (setq method (gnus-server-to-method method)))
15050 (when (and (not method)
15052 (setq method (gnus-find-method-for-group group)))
15053 (goto-char (point-max))
15056 (let ((func (car (or method (gnus-find-method-for-group group)))))
15057 (funcall (intern (format "%s-request-accept-article" func))
15058 (if (stringp group) (gnus-group-real-name group) group)
15062 (defun gnus-request-replace-article (article group buffer)
15063 (let ((func (car (gnus-find-method-for-group group))))
15064 (funcall (intern (format "%s-request-replace-article" func))
15065 article (gnus-group-real-name group) buffer)))
15067 (defun gnus-request-associate-buffer (group)
15068 (let ((method (gnus-find-method-for-group group)))
15069 (funcall (gnus-get-function method 'request-associate-buffer)
15070 (gnus-group-real-name group))))
15072 (defun gnus-request-restore-buffer (article group)
15073 "Request a new buffer restored to the state of ARTICLE."
15074 (let ((method (gnus-find-method-for-group group)))
15075 (funcall (gnus-get-function method 'request-restore-buffer)
15076 article (gnus-group-real-name group) (nth 1 method))))
15078 (defun gnus-request-create-group (group &optional method)
15079 (when (stringp method)
15080 (setq method (gnus-server-to-method method)))
15081 (let ((method (or method (gnus-find-method-for-group group))))
15082 (funcall (gnus-get-function method 'request-create-group)
15083 (gnus-group-real-name group) (nth 1 method))))
15085 (defun gnus-request-delete-group (group &optional force)
15086 (let ((method (gnus-find-method-for-group group)))
15087 (funcall (gnus-get-function method 'request-delete-group)
15088 (gnus-group-real-name group) force (nth 1 method))))
15090 (defun gnus-request-rename-group (group new-name)
15091 (let ((method (gnus-find-method-for-group group)))
15092 (funcall (gnus-get-function method 'request-rename-group)
15093 (gnus-group-real-name group)
15094 (gnus-group-real-name new-name) (nth 1 method))))
15096 (defun gnus-member-of-valid (symbol group)
15097 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15098 (memq symbol (assoc
15099 (symbol-name (car (gnus-find-method-for-group group)))
15100 gnus-valid-select-methods)))
15102 (defun gnus-method-option-p (method option)
15103 "Return non-nil if select METHOD has OPTION as a parameter."
15104 (when (stringp method)
15105 (setq method (gnus-server-to-method method)))
15106 (memq option (assoc (format "%s" (car method))
15107 gnus-valid-select-methods)))
15109 (defun gnus-server-extend-method (group method)
15110 ;; This function "extends" a virtual server. If the server is
15111 ;; "hello", and the select method is ("hello" (my-var "something"))
15112 ;; in the group "alt.alt", this will result in a new virtual server
15113 ;; called "hello+alt.alt".
15115 (gnus-copy-sequence
15116 (if (equal (car method) "native") gnus-select-method
15117 (cdr (assoc (car method) gnus-server-alist))))))
15118 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15119 (nconc entry (cdr method))))
15121 (defun gnus-find-method-for-group (group &optional info)
15122 "Find the select method that GROUP uses."
15123 (or gnus-override-method
15125 gnus-select-method)
15126 (let ((info (or info (gnus-get-info group)))
15129 (not (setq method (gnus-info-method info)))
15130 (equal method "native"))
15133 (cond ((stringp method)
15134 (gnus-server-to-method method))
15135 ((stringp (car method))
15136 (gnus-server-extend-method group method))
15139 (cond ((equal (cadr method) "")
15141 ((null (cadr method))
15142 (list (car method) ""))
15144 (gnus-server-add-address method)))))))
15146 (defun gnus-check-backend-function (func group)
15147 "Check whether GROUP supports function FUNC."
15148 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15150 (fboundp (intern (format "%s-%s" method func)))))
15152 (defun gnus-methods-using (feature)
15153 "Find all methods that have FEATURE."
15154 (let ((valids gnus-valid-select-methods)
15157 (if (memq feature (car valids))
15158 (setq outs (cons (car valids) outs)))
15159 (setq valids (cdr valids)))
15164 ;;; Active & Newsrc File Handling
15167 (defun gnus-setup-news (&optional rawfile level dont-connect)
15168 "Setup news information.
15169 If RAWFILE is non-nil, the .newsrc file will also be read.
15170 If LEVEL is non-nil, the news will be set up at level LEVEL."
15171 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15174 ;; Clear some variables to re-initialize news information.
15175 (setq gnus-newsrc-alist nil
15176 gnus-active-hashtb nil)
15177 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15178 (gnus-read-newsrc-file rawfile))
15180 (when (and (not (assoc "archive" gnus-server-alist))
15181 gnus-message-archive-method)
15182 (push (cons "archive" gnus-message-archive-method)
15183 gnus-server-alist))
15185 ;; If we don't read the complete active file, we fill in the
15187 (if (or (null gnus-read-active-file)
15188 (eq gnus-read-active-file 'some))
15189 (gnus-update-active-hashtb-from-killed))
15191 ;; Read the active file and create `gnus-active-hashtb'.
15192 ;; If `gnus-read-active-file' is nil, then we just create an empty
15193 ;; hash table. The partial filling out of the hash table will be
15194 ;; done in `gnus-get-unread-articles'.
15195 (and gnus-read-active-file
15197 (gnus-read-active-file))
15199 (or gnus-active-hashtb
15200 (setq gnus-active-hashtb (make-vector 4095 0)))
15202 ;; Initialize the cache.
15203 (when gnus-use-cache
15206 ;; Possibly eval the dribble file.
15207 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15209 (gnus-update-format-specifications)
15211 ;; See whether we need to read the description file.
15212 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15213 (not gnus-description-hashtb)
15215 gnus-read-active-file)
15216 (gnus-read-all-descriptions-files))
15218 ;; Find new newsgroups and treat them.
15219 (if (and init gnus-check-new-newsgroups (not level)
15220 (gnus-check-server gnus-select-method))
15221 (gnus-find-new-newsgroups))
15223 ;; We might read in new NoCeM messages here.
15224 (when (and gnus-use-nocem
15226 (not dont-connect))
15227 (gnus-nocem-scan-groups))
15229 ;; Find the number of unread articles in each non-dead group.
15230 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15231 (gnus-get-unread-articles level))
15233 (if (and init gnus-check-bogus-newsgroups
15234 gnus-read-active-file (not level)
15235 (gnus-server-opened gnus-select-method))
15236 (gnus-check-bogus-newsgroups))))
15238 (defun gnus-find-new-newsgroups (&optional arg)
15239 "Search for new newsgroups and add them.
15240 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15241 The `-n' option line from .newsrc is respected.
15242 If ARG (the prefix), use the `ask-server' method to query
15243 the server for new groups."
15245 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15246 (null gnus-read-active-file)
15247 (eq gnus-read-active-file 'some))
15248 'ask-server gnus-check-new-newsgroups)))
15249 (unless (gnus-check-first-time-used)
15250 (if (or (consp check)
15251 (eq check 'ask-server))
15252 ;; Ask the server for new groups.
15253 (gnus-ask-server-for-new-groups)
15254 ;; Go through the active hashtb and look for new groups.
15256 group new-newsgroups)
15257 (gnus-message 5 "Looking for new newsgroups...")
15258 (unless gnus-have-read-active-file
15259 (gnus-read-active-file))
15260 (setq gnus-newsrc-last-checked-date (current-time-string))
15261 (unless gnus-killed-hashtb
15262 (gnus-make-hashtable-from-killed))
15263 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15264 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15267 (if (or (null (setq group (symbol-name sym)))
15269 (null (symbol-value sym))
15270 (gnus-gethash group gnus-killed-hashtb)
15271 (gnus-gethash group gnus-newsrc-hashtb))
15273 (let ((do-sub (gnus-matches-options-n group)))
15275 ((eq do-sub 'subscribe)
15276 (setq groups (1+ groups))
15277 (gnus-sethash group group gnus-killed-hashtb)
15278 (funcall gnus-subscribe-options-newsgroup-method group))
15279 ((eq do-sub 'ignore)
15282 (setq groups (1+ groups))
15283 (gnus-sethash group group gnus-killed-hashtb)
15284 (if gnus-subscribe-hierarchical-interactive
15285 (setq new-newsgroups (cons group new-newsgroups))
15286 (funcall gnus-subscribe-newsgroup-method group)))))))
15287 gnus-active-hashtb)
15288 (when new-newsgroups
15289 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15290 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15292 (gnus-message 6 "%d new newsgroup%s arrived."
15293 groups (if (> groups 1) "s have" " has"))
15294 (gnus-message 6 "No new newsgroups.")))))))
15296 (defun gnus-matches-options-n (group)
15297 ;; Returns `subscribe' if the group is to be unconditionally
15298 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15299 ;; no match for the group.
15301 ;; First we check the two user variables.
15303 ((and gnus-options-subscribe
15304 (string-match gnus-options-subscribe group))
15306 ((and gnus-auto-subscribed-groups
15307 (string-match gnus-auto-subscribed-groups group))
15309 ((and gnus-options-not-subscribe
15310 (string-match gnus-options-not-subscribe group))
15312 ;; Then we go through the list that was retrieved from the .newsrc
15313 ;; file. This list has elements on the form
15314 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15315 ;; is in the reverse order of the options line) is returned.
15317 (let ((regs gnus-newsrc-options-n))
15319 (not (string-match (caar regs) group)))
15320 (setq regs (cdr regs)))
15321 (and regs (cdar regs))))))
15323 (defun gnus-ask-server-for-new-groups ()
15324 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15325 (methods (cons gnus-select-method
15327 (when gnus-message-archive-method
15330 (and (consp gnus-check-new-newsgroups)
15331 gnus-check-new-newsgroups)
15332 gnus-secondary-select-methods))))
15334 (new-date (current-time-string))
15335 group new-newsgroups got-new method hashtb
15336 gnus-override-subscribe-method)
15337 ;; Go through both primary and secondary select methods and
15338 ;; request new newsgroups.
15339 (while (setq method (gnus-server-get-method nil (pop methods)))
15340 (setq new-newsgroups nil)
15341 (setq gnus-override-subscribe-method method)
15342 (when (and (gnus-check-server method)
15343 (gnus-request-newgroups date method))
15346 (setq hashtb (gnus-make-hashtable 100))
15347 (set-buffer nntp-server-buffer)
15348 ;; Enter all the new groups into a hashtable.
15349 (gnus-active-to-gnus-format method hashtb 'ignore))
15350 ;; Now all new groups from `method' are in `hashtb'.
15352 (lambda (group-sym)
15353 (if (or (null (setq group (symbol-name group-sym)))
15354 (not (boundp group-sym))
15355 (null (symbol-value group-sym))
15356 (gnus-gethash group gnus-newsrc-hashtb)
15357 (member group gnus-zombie-list)
15358 (member group gnus-killed-list))
15359 ;; The group is already known.
15361 ;; Make this group active.
15362 (when (symbol-value group-sym)
15363 (gnus-set-active group (symbol-value group-sym)))
15364 ;; Check whether we want it or not.
15365 (let ((do-sub (gnus-matches-options-n group)))
15367 ((eq do-sub 'subscribe)
15369 (gnus-sethash group group gnus-killed-hashtb)
15370 (funcall gnus-subscribe-options-newsgroup-method group))
15371 ((eq do-sub 'ignore)
15375 (gnus-sethash group group gnus-killed-hashtb)
15376 (if gnus-subscribe-hierarchical-interactive
15377 (push group new-newsgroups)
15378 (funcall gnus-subscribe-newsgroup-method group)))))))
15380 (when new-newsgroups
15381 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15382 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15384 (gnus-message 6 "%d new newsgroup%s arrived."
15385 groups (if (> groups 1) "s have" " has")))
15386 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15389 (defun gnus-check-first-time-used ()
15390 (if (or (> (length gnus-newsrc-alist) 1)
15391 (file-exists-p gnus-startup-file)
15392 (file-exists-p (concat gnus-startup-file ".el"))
15393 (file-exists-p (concat gnus-startup-file ".eld")))
15395 (gnus-message 6 "First time user; subscribing you to default groups")
15396 (unless (gnus-read-active-file-p)
15397 (gnus-read-active-file))
15398 (setq gnus-newsrc-last-checked-date (current-time-string))
15399 (let ((groups gnus-default-subscribed-newsgroups)
15403 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15406 (if (null (setq group (symbol-name sym)))
15408 (let ((do-sub (gnus-matches-options-n group)))
15410 ((eq do-sub 'subscribe)
15411 (gnus-sethash group group gnus-killed-hashtb)
15412 (funcall gnus-subscribe-options-newsgroup-method group))
15413 ((eq do-sub 'ignore)
15416 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15417 gnus-active-hashtb)
15419 (if (gnus-active (car groups))
15420 (gnus-group-change-level
15421 (car groups) gnus-level-default-subscribed gnus-level-killed))
15422 (setq groups (cdr groups)))
15423 (gnus-group-make-help-group)
15424 (and gnus-novice-user
15425 (gnus-message 7 "`A k' to list killed groups"))))))
15427 (defun gnus-subscribe-group (group previous &optional method)
15428 (gnus-group-change-level
15430 (list t group gnus-level-default-subscribed nil nil method)
15432 gnus-level-default-subscribed gnus-level-killed previous t))
15434 ;; `gnus-group-change-level' is the fundamental function for changing
15435 ;; subscription levels of newsgroups. This might mean just changing
15436 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15437 ;; again, which subscribes/unsubscribes a group, which is equally
15438 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15439 ;; from 8-9 to 1-7 means that you remove the group from the list of
15440 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15441 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15442 ;; which is trivial.
15443 ;; ENTRY can either be a string (newsgroup name) or a list (if
15444 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15445 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15447 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15448 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15450 (defun gnus-group-change-level (entry level &optional oldlevel
15451 previous fromkilled)
15452 (let (group info active num)
15453 ;; Glean what info we can from the arguments
15455 (if fromkilled (setq group (nth 1 entry))
15456 (setq group (car (nth 2 entry))))
15457 (setq group entry))
15458 (if (and (stringp entry)
15460 (< oldlevel gnus-level-zombie))
15461 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15462 (if (and (not oldlevel)
15464 (setq oldlevel (gnus-info-level (nth 2 entry)))
15465 (setq oldlevel (or oldlevel 9)))
15466 (if (stringp previous)
15467 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15469 (if (and (>= oldlevel gnus-level-zombie)
15470 (gnus-gethash group gnus-newsrc-hashtb))
15471 ;; We are trying to subscribe a group that is already
15475 (or (gnus-ephemeral-group-p group)
15476 (gnus-dribble-enter
15477 (format "(gnus-group-change-level %S %S %S %S %S)"
15478 group level oldlevel (car (nth 2 previous)) fromkilled)))
15480 ;; Then we remove the newgroup from any old structures, if needed.
15481 ;; If the group was killed, we remove it from the killed or zombie
15482 ;; list. If not, and it is in fact going to be killed, we remove
15483 ;; it from the newsrc hash table and assoc.
15485 ((>= oldlevel gnus-level-zombie)
15486 (if (= oldlevel gnus-level-zombie)
15487 (setq gnus-zombie-list (delete group gnus-zombie-list))
15488 (setq gnus-killed-list (delete group gnus-killed-list))))
15490 (if (and (>= level gnus-level-zombie)
15493 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15495 (setcdr (gnus-gethash (car (nth 3 entry))
15496 gnus-newsrc-hashtb)
15498 (setcdr (cdr entry) (cdddr entry))))))
15500 ;; Finally we enter (if needed) the list where it is supposed to
15501 ;; go, and change the subscription level. If it is to be killed,
15502 ;; we enter it into the killed or zombie list.
15504 ((>= level gnus-level-zombie)
15505 ;; Remove from the hash table.
15506 (gnus-sethash group nil gnus-newsrc-hashtb)
15507 ;; We do not enter foreign groups into the list of dead
15509 (unless (gnus-group-foreign-p group)
15510 (if (= level gnus-level-zombie)
15511 (setq gnus-zombie-list (cons group gnus-zombie-list))
15512 (setq gnus-killed-list (cons group gnus-killed-list)))))
15514 ;; If the list is to be entered into the newsrc assoc, and
15515 ;; it was killed, we have to create an entry in the newsrc
15516 ;; hashtb format and fix the pointers in the newsrc assoc.
15517 (if (< oldlevel gnus-level-zombie)
15518 ;; It was alive, and it is going to stay alive, so we
15519 ;; just change the level and don't change any pointers or
15520 ;; hash table entries.
15521 (setcar (cdaddr entry) level)
15523 (setq info (cdr entry)
15525 (setq active (gnus-active group))
15527 (if active (- (1+ (cdr active)) (car active)) t))
15528 ;; Check whether the group is foreign. If so, the
15529 ;; foreign select method has to be entered into the
15531 (let ((method (or gnus-override-subscribe-method
15532 (gnus-group-method group))))
15533 (if (eq method gnus-select-method)
15534 (setq info (list group level nil))
15535 (setq info (list group level nil nil method)))))
15538 (let ((p gnus-newsrc-alist))
15542 (setq entry (cons info (cddr previous)))
15545 (setcdr (cdr previous) entry)
15546 (gnus-sethash group (cons num (cdr previous))
15547 gnus-newsrc-hashtb))
15548 (setcdr previous entry)
15549 (gnus-sethash group (cons num previous)
15550 gnus-newsrc-hashtb))
15552 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15553 (when gnus-group-change-level-function
15554 (funcall gnus-group-change-level-function group level oldlevel)))))
15556 (defun gnus-kill-newsgroup (newsgroup)
15557 "Obsolete function. Kills a newsgroup."
15558 (gnus-group-change-level
15559 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15561 (defun gnus-check-bogus-newsgroups (&optional confirm)
15562 "Remove bogus newsgroups.
15563 If CONFIRM is non-nil, the user has to confirm the deletion of every
15565 (let ((newsrc (cdr gnus-newsrc-alist))
15566 bogus group entry info)
15567 (gnus-message 5 "Checking bogus newsgroups...")
15568 (unless (gnus-read-active-file-p)
15569 (gnus-read-active-file))
15570 (when (gnus-read-active-file-p)
15571 ;; Find all bogus newsgroup that are subscribed.
15573 (setq info (pop newsrc)
15574 group (gnus-info-group info))
15575 (unless (or (gnus-active group) ; Active
15576 (gnus-info-method info) ; Foreign
15578 (not (gnus-y-or-n-p
15579 (format "Remove bogus newsgroup: %s " group)))))
15580 ;; Found a bogus newsgroup.
15581 (push group bogus)))
15582 ;; Remove all bogus subscribed groups by first killing them, and
15583 ;; then removing them from the list of killed groups.
15585 (when (setq entry (gnus-gethash (setq group (pop bogus))
15586 gnus-newsrc-hashtb))
15587 (gnus-group-change-level entry gnus-level-killed)
15588 (setq gnus-killed-list (delete group gnus-killed-list))))
15589 ;; Then we remove all bogus groups from the list of killed and
15590 ;; zombie groups. They are are removed without confirmation.
15591 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15594 (setq killed (symbol-value (car dead-lists)))
15596 (unless (gnus-active (setq group (pop killed)))
15597 ;; The group is bogus.
15598 ;; !!!Slow as hell.
15599 (set (car dead-lists)
15600 (delete group (symbol-value (car dead-lists))))))
15601 (setq dead-lists (cdr dead-lists))))
15602 (gnus-message 5 "Checking bogus newsgroups...done"))))
15604 (defun gnus-check-duplicate-killed-groups ()
15605 "Remove duplicates from the list of killed groups."
15607 (let ((killed gnus-killed-list))
15609 (gnus-message 9 "%d" (length killed))
15610 (setcdr killed (delete (car killed) (cdr killed)))
15611 (setq killed (cdr killed)))))
15613 ;; We want to inline a function from gnus-cache, so we cheat here:
15616 (require 'gnus-cache))
15618 (defun gnus-get-unread-articles-in-group (info active &optional update)
15620 ;; Allow the backend to update the info in the group.
15622 (gnus-request-update-info
15623 info (gnus-find-method-for-group (gnus-info-group info))))
15624 (gnus-activate-group (gnus-info-group info) nil t))
15625 (let* ((range (gnus-info-read info))
15627 ;; If a cache is present, we may have to alter the active info.
15628 (when (and gnus-use-cache info)
15629 (inline (gnus-cache-possibly-alter-active
15630 (gnus-info-group info) active)))
15631 ;; Modify the list of read articles according to what articles
15632 ;; are available; then tally the unread articles and add the
15633 ;; number to the group hash table entry.
15635 ((zerop (cdr active))
15638 (setq num (- (1+ (cdr active)) (car active))))
15639 ((not (listp (cdr range)))
15640 ;; Fix a single (num . num) range according to the
15641 ;; active hash table.
15642 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15643 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15644 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15645 ;; Compute number of unread articles.
15646 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15648 ;; The read list is a list of ranges. Fix them according to
15649 ;; the active hash table.
15650 ;; First peel off any elements that are below the lower
15652 (while (and (cdr range)
15654 (or (and (atom (cadr range)) (cadr range))
15656 (if (numberp (car range))
15659 (or (and (numberp (cadr range))
15662 (setcdr (car range)
15663 (or (and (numberp (nth 1 range)) (nth 1 range))
15665 (setcdr range (cddr range)))
15666 ;; Adjust the first element to be the same as the lower limit.
15667 (if (and (not (atom (car range)))
15668 (< (cdar range) (car active)))
15669 (setcdr (car range) (1- (car active))))
15670 ;; Then we want to peel off any elements that are higher
15671 ;; than the upper active limit.
15672 (let ((srange range))
15673 ;; Go past all legal elements.
15674 (while (and (cdr srange)
15675 (<= (or (and (atom (cadr srange))
15677 (caadr srange)) (cdr active)))
15678 (setq srange (cdr srange)))
15680 ;; Nuke all remaining illegal elements.
15681 (setcdr srange nil))
15683 ;; Adjust the final element.
15684 (if (and (not (atom (car srange)))
15685 (> (cdar srange) (cdr active)))
15686 (setcdr (car srange) (cdr active))))
15687 ;; Compute the number of unread articles.
15689 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15691 (or (and (atom (car range)) (car range))
15693 (setq range (cdr range)))
15694 (setq num (max 0 (- (cdr active) num)))))
15695 ;; Set the number of unread articles.
15697 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15700 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15701 ;; and compute how many unread articles there are in each group.
15702 (defun gnus-get-unread-articles (&optional level)
15703 (let* ((newsrc (cdr gnus-newsrc-alist))
15704 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15707 (cond ((and gnus-activate-foreign-newsgroups
15708 (not (numberp gnus-activate-foreign-newsgroups)))
15709 (1+ gnus-level-subscribed))
15710 ((numberp gnus-activate-foreign-newsgroups)
15711 gnus-activate-foreign-newsgroups)
15714 info group active method)
15715 (gnus-message 5 "Checking new news...")
15718 (setq active (gnus-active (setq group (gnus-info-group
15719 (setq info (pop newsrc))))))
15721 ;; Check newsgroups. If the user doesn't want to check them, or
15722 ;; they can't be checked (for instance, if the news server can't
15723 ;; be reached) we just set the number of unread articles in this
15724 ;; newsgroup to t. This means that Gnus thinks that there are
15725 ;; unread articles, but it has no idea how many.
15726 (if (and (setq method (gnus-info-method info))
15727 (not (gnus-server-equal
15729 (setq method (gnus-server-get-method nil method))))
15730 (not (gnus-secondary-method-p method)))
15731 ;; These groups are foreign. Check the level.
15732 (when (<= (gnus-info-level info) foreign-level)
15733 (setq active (gnus-activate-group group 'scan))
15734 (unless (inline (gnus-virtual-group-p group))
15735 (inline (gnus-close-group group))))
15737 ;; These groups are native or secondary.
15738 (when (and (<= (gnus-info-level info) level)
15739 (not gnus-read-active-file))
15740 (setq active (gnus-activate-group group 'scan))
15741 (inline (gnus-close-group group))))
15744 (inline (gnus-get-unread-articles-in-group
15747 (fboundp (intern (concat (symbol-name (car method))
15748 "-request-update-info"))))))
15749 ;; The group couldn't be reached, so we nix out the number of
15750 ;; unread articles and stuff.
15751 (gnus-set-active group nil)
15752 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15754 (gnus-message 5 "Checking new news...done")))
15756 ;; Create a hash table out of the newsrc alist. The `car's of the
15757 ;; alist elements are used as keys.
15758 (defun gnus-make-hashtable-from-newsrc-alist ()
15759 (let ((alist gnus-newsrc-alist)
15760 (ohashtb gnus-newsrc-hashtb)
15762 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15764 (setq prev (setq gnus-newsrc-alist
15765 (if (equal (caar gnus-newsrc-alist)
15768 (cons (list "dummy.group" 0 nil) alist)))))
15772 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15774 gnus-newsrc-hashtb)
15776 alist (cdr alist)))))
15778 (defun gnus-make-hashtable-from-killed ()
15779 "Create a hash table from the killed and zombie lists."
15780 (let ((lists '(gnus-killed-list gnus-zombie-list))
15782 (setq gnus-killed-hashtb
15783 (gnus-make-hashtable
15784 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15785 (while (setq list (pop lists))
15786 (setq list (symbol-value list))
15788 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15790 (defun gnus-activate-group (group &optional scan dont-check)
15791 ;; Check whether a group has been activated or not.
15792 ;; If SCAN, request a scan of that group as well.
15793 (let ((method (gnus-find-method-for-group group))
15795 (and (gnus-check-server method)
15796 ;; We escape all bugs and quit here to make it possible to
15797 ;; continue if a group is so out-there that it reports bugs
15801 (gnus-check-backend-function 'request-scan (car method))
15802 (gnus-request-scan group method))
15805 (gnus-request-group group dont-check)
15809 (set-buffer nntp-server-buffer)
15810 (goto-char (point-min))
15811 ;; Parse the result we got from `gnus-request-group'.
15812 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15814 (goto-char (match-beginning 1))
15816 group (setq active (cons (read (current-buffer))
15817 (read (current-buffer)))))
15818 ;; Return the new active info.
15821 (defun gnus-update-read-articles (group unread)
15822 "Update the list of read and ticked articles in GROUP using the
15823 UNREAD and TICKED lists.
15824 Note: UNSELECTED has to be sorted over `<'.
15825 Returns whether the updating was successful."
15826 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15827 (entry (gnus-gethash group gnus-newsrc-hashtb))
15828 (info (nth 2 entry))
15830 (unread (sort (copy-sequence unread) '<))
15832 (if (or (not info) (not active))
15833 ;; There is no info on this group if it was, in fact,
15834 ;; killed. Gnus stores no information on killed groups, so
15835 ;; there's nothing to be done.
15836 ;; One could store the information somewhere temporarily,
15837 ;; perhaps... Hmmm...
15839 ;; Remove any negative articles numbers.
15840 (while (and unread (< (car unread) 0))
15841 (setq unread (cdr unread)))
15842 ;; Remove any expired article numbers
15843 (while (and unread (< (car unread) (car active)))
15844 (setq unread (cdr unread)))
15845 ;; Compute the ranges of read articles by looking at the list of
15846 ;; unread articles.
15848 (if (/= (car unread) prev)
15849 (setq read (cons (if (= prev (1- (car unread))) prev
15850 (cons prev (1- (car unread)))) read)))
15851 (setq prev (1+ (car unread)))
15852 (setq unread (cdr unread)))
15853 (when (<= prev (cdr active))
15854 (setq read (cons (cons prev (cdr active)) read)))
15855 ;; Enter this list into the group info.
15856 (gnus-info-set-read
15857 info (if (> (length read) 1) (nreverse read) read))
15858 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15859 (gnus-get-unread-articles-in-group info (gnus-active group))
15862 (defun gnus-make-articles-unread (group articles)
15863 "Mark ARTICLES in GROUP as unread."
15864 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15865 (gnus-gethash (gnus-group-real-name group)
15866 gnus-newsrc-hashtb))))
15867 (ranges (gnus-info-read info))
15870 (when (gnus-member-of-range
15871 (setq article (pop articles)) ranges)
15872 (setq news (cons article news))))
15874 (gnus-info-set-read
15875 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15876 (gnus-group-update-group group t))))
15878 ;; Enter all dead groups into the hashtb.
15879 (defun gnus-update-active-hashtb-from-killed ()
15880 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15881 (lists (list gnus-killed-list gnus-zombie-list))
15884 (setq killed (car lists))
15886 (gnus-sethash (car killed) nil hashtb)
15887 (setq killed (cdr killed)))
15888 (setq lists (cdr lists)))))
15890 (defun gnus-get-killed-groups ()
15891 "Go through the active hashtb and all all unknown groups as killed."
15892 ;; First make sure active file has been read.
15893 (unless (gnus-read-active-file-p)
15894 (let ((gnus-read-active-file t))
15895 (gnus-read-active-file)))
15896 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
15897 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
15901 (group (symbol-name sym)))
15902 (if (or (null group)
15903 (gnus-gethash group gnus-killed-hashtb)
15904 (gnus-gethash group gnus-newsrc-hashtb))
15906 (let ((do-sub (gnus-matches-options-n group)))
15907 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
15909 (setq groups (1+ groups))
15910 (setq gnus-killed-list
15911 (cons group gnus-killed-list))
15912 (gnus-sethash group group gnus-killed-hashtb))))))
15913 gnus-active-hashtb))
15915 ;; Get the active file(s) from the backend(s).
15916 (defun gnus-read-active-file ()
15917 (gnus-group-set-mode-line)
15920 (if (gnus-check-server gnus-select-method)
15921 ;; The native server is available.
15922 (cons gnus-select-method gnus-secondary-select-methods)
15923 ;; The native server is down, so we just do the
15925 gnus-secondary-select-methods)
15926 ;; Also read from the archive server.
15927 (when gnus-message-archive-method
15928 (list "archive"))))
15930 (setq gnus-have-read-active-file nil)
15932 (set-buffer nntp-server-buffer)
15934 (let* ((method (if (stringp (car methods))
15935 (gnus-server-get-method nil (car methods))
15937 (where (nth 1 method))
15938 (mesg (format "Reading active file%s via %s..."
15939 (if (and where (not (zerop (length where))))
15940 (concat " from " where) "")
15942 (gnus-message 5 mesg)
15943 (when (gnus-check-server method)
15944 ;; Request that the backend scan its incoming messages.
15945 (and (gnus-check-backend-function 'request-scan (car method))
15946 (gnus-request-scan nil method))
15948 ((and (eq gnus-read-active-file 'some)
15949 (gnus-check-backend-function 'retrieve-groups (car method)))
15950 (let ((newsrc (cdr gnus-newsrc-alist))
15951 (gmethod (gnus-server-get-method nil method))
15953 (while (setq info (pop newsrc))
15954 (when (gnus-server-equal
15955 (gnus-find-method-for-group
15956 (gnus-info-group info) info)
15958 (push (gnus-group-real-name (gnus-info-group info))
15961 (gnus-check-server method)
15962 (setq list-type (gnus-retrieve-groups groups method))
15966 1.2 "Cannot read partial active file from %s server."
15968 ((eq list-type 'active)
15969 (gnus-active-to-gnus-format method gnus-active-hashtb))
15971 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15973 (if (not (gnus-request-list method))
15974 (unless (equal method gnus-message-archive-method)
15975 (gnus-error 1 "Cannot read active file from %s server."
15977 (gnus-active-to-gnus-format method gnus-active-hashtb)
15978 ;; We mark this active file as read.
15979 (push method gnus-have-read-active-file)
15980 (gnus-message 5 "%sdone" mesg))))))
15981 (setq methods (cdr methods))))))
15983 ;; Read an active file and place the results in `gnus-active-hashtb'.
15984 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15986 (setq method gnus-select-method))
15987 (let ((cur (current-buffer))
15989 (if (and gnus-active-hashtb
15990 (not (equal method gnus-select-method)))
15992 (setq gnus-active-hashtb
15993 (if (equal method gnus-select-method)
15994 (gnus-make-hashtable
15995 (count-lines (point-min) (point-max)))
15996 (gnus-make-hashtable 4096)))))))
15997 ;; Delete unnecessary lines.
15998 (goto-char (point-min))
15999 (while (search-forward "\nto." nil t)
16000 (delete-region (1+ (match-beginning 0))
16001 (progn (forward-line 1) (point))))
16002 (or (string= gnus-ignored-newsgroups "")
16004 (goto-char (point-min))
16005 (delete-matching-lines gnus-ignored-newsgroups)))
16006 ;; Make the group names readable as a lisp expression even if they
16007 ;; contain special characters.
16008 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16009 (goto-char (point-max))
16010 (while (re-search-backward "[][';?()#]" nil t)
16012 ;; If these are groups from a foreign select method, we insert the
16013 ;; group prefix in front of the group names.
16014 (and method (not (gnus-server-equal
16015 (gnus-server-get-method nil method)
16016 (gnus-server-get-method nil gnus-select-method)))
16017 (let ((prefix (gnus-group-prefixed-name "" method)))
16018 (goto-char (point-min))
16019 (while (and (not (eobp))
16020 (progn (insert prefix)
16021 (zerop (forward-line 1)))))))
16022 ;; Store the active file in a hash table.
16023 (goto-char (point-min))
16024 (if (string-match "%[oO]" gnus-group-line-format)
16025 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16026 ;; If we want information on moderated groups, we use this
16028 (let* ((mod-hashtb (make-vector 7 0))
16029 (m (intern "m" mod-hashtb))
16031 (while (not (eobp))
16032 (condition-case nil
16034 (narrow-to-region (point) (gnus-point-at-eol))
16035 (setq group (let ((obarray hashtb)) (read cur)))
16036 (if (and (numberp (setq max (read cur)))
16037 (numberp (setq min (read cur)))
16039 (skip-chars-forward " \t")
16041 (or (= (following-char) ?=)
16042 (= (following-char) ?x)
16043 (= (following-char) ?j)))))
16044 (set group (cons min max))
16046 ;; Enter moderated groups into a list.
16047 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16048 (setq gnus-moderated-list
16049 (cons (symbol-name group) gnus-moderated-list))))
16056 ;; And if we do not care about moderation, we use this loop,
16057 ;; which is faster.
16058 (let (group max min)
16059 (while (not (eobp))
16062 (narrow-to-region (point) (gnus-point-at-eol))
16063 ;; group gets set to a symbol interned in the hash table
16064 ;; (what a hack!!) - jwz
16065 (setq group (let ((obarray hashtb)) (read cur)))
16066 (if (and (numberp (setq max (read cur)))
16067 (numberp (setq min (read cur)))
16069 (skip-chars-forward " \t")
16071 (or (= (following-char) ?=)
16072 (= (following-char) ?x)
16073 (= (following-char) ?j)))))
16074 (set group (cons min max))
16082 (gnus-message 3 "Warning - illegal active: %s"
16084 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16086 (forward-line 1))))))
16088 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16089 ;; Parse a "groups" active file.
16090 (let ((cur (current-buffer))
16092 (if (and method gnus-active-hashtb)
16094 (setq gnus-active-hashtb
16095 (gnus-make-hashtable
16096 (count-lines (point-min) (point-max)))))))
16097 (prefix (and method
16098 (not (gnus-server-equal
16099 (gnus-server-get-method nil method)
16100 (gnus-server-get-method nil gnus-select-method)))
16101 (gnus-group-prefixed-name "" method))))
16103 (goto-char (point-min))
16104 ;; We split this into to separate loops, one with the prefix
16105 ;; and one without to speed the reading up somewhat.
16107 (let (min max opoint group)
16108 (while (not (eobp))
16111 (read cur) (read cur)
16112 (setq min (read cur)
16115 (skip-chars-forward " \t")
16118 (set (let ((obarray hashtb)) (read cur))
16120 (error (and group (symbolp group) (set group nil))))
16122 (let (min max group)
16123 (while (not (eobp))
16125 (if (= (following-char) ?2)
16127 (read cur) (read cur)
16128 (setq min (read cur)
16130 (set (setq group (let ((obarray hashtb)) (read cur)))
16132 (error (and group (symbolp group) (set group nil))))
16133 (forward-line 1))))))
16135 (defun gnus-read-newsrc-file (&optional force)
16136 "Read startup file.
16137 If FORCE is non-nil, the .newsrc file is read."
16138 ;; Reset variables that might be defined in the .newsrc.eld file.
16139 (let ((variables gnus-variable-list))
16141 (set (car variables) nil)
16142 (setq variables (cdr variables))))
16143 (let* ((newsrc-file gnus-current-startup-file)
16144 (quick-file (concat newsrc-file ".el")))
16146 ;; We always load the .newsrc.eld file. If always contains
16147 ;; much information that can not be gotten from the .newsrc
16148 ;; file (ticked articles, killed groups, foreign methods, etc.)
16149 (gnus-read-newsrc-el-file quick-file)
16151 (if (and (file-exists-p gnus-current-startup-file)
16153 (and (file-newer-than-file-p newsrc-file quick-file)
16154 (file-newer-than-file-p newsrc-file
16155 (concat quick-file "d")))
16156 (not gnus-newsrc-alist)))
16157 ;; We read the .newsrc file. Note that if there if a
16158 ;; .newsrc.eld file exists, it has already been read, and
16159 ;; the `gnus-newsrc-hashtb' has been created. While reading
16160 ;; the .newsrc file, Gnus will only use the information it
16161 ;; can find there for changing the data already read -
16162 ;; ie. reading the .newsrc file will not trash the data
16163 ;; already read (except for read articles).
16165 (gnus-message 5 "Reading %s..." newsrc-file)
16166 (set-buffer (find-file-noselect newsrc-file))
16167 (buffer-disable-undo (current-buffer))
16168 (gnus-newsrc-to-gnus-format)
16169 (kill-buffer (current-buffer))
16170 (gnus-message 5 "Reading %s...done" newsrc-file)))
16172 ;; Read any slave files.
16174 (gnus-master-read-slave-newsrc))
16176 ;; Convert old to new.
16177 (gnus-convert-old-newsrc))))
16179 (defun gnus-continuum-version (version)
16180 "Return VERSION as a floating point number."
16181 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16182 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16183 (number (match-string 2 version))
16185 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16186 (setq major (string-to-number (match-string 1 number)))
16187 (setq minor (string-to-number (match-string 2 number)))
16188 (setq least (if (match-beginning 3)
16189 (string-to-number (match-string 3 number))
16193 (format "%s00%02d%02d"
16195 ((string= alpha "(ding)") "4.99")
16196 ((string= alpha "September") "5.01")
16197 ((string= alpha "Red") "5.03"))
16199 (format "%d.%02d%20d" major minor least))))))
16201 (defun gnus-convert-old-newsrc ()
16202 "Convert old newsrc into the new format, if needed."
16203 (let ((fcv (and gnus-newsrc-file-version
16204 (gnus-continuum-version gnus-newsrc-file-version))))
16206 ;; No .newsrc.eld file was loaded.
16208 ;; Gnus 5 .newsrc.eld was loaded.
16209 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16210 (gnus-convert-old-ticks)))))
16212 (defun gnus-convert-old-ticks ()
16213 (let ((newsrc (cdr gnus-newsrc-alist))
16214 marks info dormant ticked)
16215 (while (setq info (pop newsrc))
16216 (when (setq marks (gnus-info-marks info))
16217 (setq dormant (cdr (assq 'dormant marks))
16218 ticked (cdr (assq 'tick marks)))
16219 (when (or dormant ticked)
16220 (gnus-info-set-read
16223 (gnus-info-read info)
16224 (nconc (gnus-uncompress-range dormant)
16225 (gnus-uncompress-range ticked)))))))))
16227 (defun gnus-read-newsrc-el-file (file)
16228 (let ((ding-file (concat file "d")))
16229 ;; We always, always read the .eld file.
16230 (gnus-message 5 "Reading %s..." ding-file)
16231 (let (gnus-newsrc-assoc)
16232 (condition-case nil
16233 (load ding-file t t t)
16235 (gnus-error 1 "Error in %s" ding-file)))
16236 (when gnus-newsrc-assoc
16237 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16238 (gnus-make-hashtable-from-newsrc-alist)
16239 (when (file-newer-than-file-p file ding-file)
16240 ;; Old format quick file
16241 (gnus-message 5 "Reading %s..." file)
16242 ;; The .el file is newer than the .eld file, so we read that one
16244 (gnus-read-old-newsrc-el-file file))))
16246 ;; Parse the old-style quick startup file
16247 (defun gnus-read-old-newsrc-el-file (file)
16248 (let (newsrc killed marked group m info)
16250 (let ((gnus-killed-assoc nil)
16251 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16253 (condition-case nil
16256 (setq newsrc gnus-newsrc-assoc
16257 killed gnus-killed-assoc
16258 marked gnus-marked-assoc)))
16259 (setq gnus-newsrc-alist nil)
16260 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16263 (gnus-info-set-read info (cddr group))
16264 (gnus-info-set-level
16265 info (if (nth 1 group) gnus-level-default-subscribed
16266 gnus-level-default-unsubscribed))
16267 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16270 (if (nth 1 group) gnus-level-default-subscribed
16271 gnus-level-default-unsubscribed)
16273 gnus-newsrc-alist))
16274 ;; Copy marks into info.
16275 (when (setq m (assoc (car group) marked))
16276 (unless (nthcdr 3 info)
16277 (nconc info (list nil)))
16278 (gnus-info-set-marks
16279 info (list (cons 'tick (gnus-compress-sequence
16280 (sort (cdr m) '<) t))))))
16281 (setq newsrc killed)
16283 (setcar newsrc (caar newsrc))
16284 (setq newsrc (cdr newsrc)))
16285 (setq gnus-killed-list killed))
16286 ;; The .el file version of this variable does not begin with
16287 ;; "options", while the .eld version does, so we just add it if it
16290 gnus-newsrc-options
16292 (and (not (string-match "^ *options" gnus-newsrc-options))
16293 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16294 (and (not (string-match "\n$" gnus-newsrc-options))
16295 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16296 ;; Finally, if we read some options lines, we parse them.
16297 (or (string= gnus-newsrc-options "")
16298 (gnus-newsrc-parse-options gnus-newsrc-options))))
16300 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16301 (gnus-make-hashtable-from-newsrc-alist)))
16303 (defun gnus-make-newsrc-file (file)
16304 "Make server dependent file name by catenating FILE and server host name."
16305 (let* ((file (expand-file-name file nil))
16306 (real-file (concat file "-" (nth 1 gnus-select-method))))
16307 (if (or (file-exists-p real-file)
16308 (file-exists-p (concat real-file ".el"))
16309 (file-exists-p (concat real-file ".eld")))
16312 (defun gnus-newsrc-to-gnus-format ()
16313 (setq gnus-newsrc-options "")
16314 (setq gnus-newsrc-options-n nil)
16316 (or gnus-active-hashtb
16317 (setq gnus-active-hashtb (make-vector 4095 0)))
16318 (let ((buf (current-buffer))
16319 (already-read (> (length gnus-newsrc-alist) 1))
16320 group subscribed options-symbol newsrc Options-symbol
16322 (goto-char (point-min))
16323 ;; We intern the symbol `options' in the active hashtb so that we
16324 ;; can `eq' against it later.
16325 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16326 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16328 (while (not (eobp))
16329 ;; We first read the first word on the line by narrowing and
16330 ;; then reading into `gnus-active-hashtb'. Most groups will
16331 ;; already exist in that hashtb, so this will save some string
16335 (progn (skip-chars-forward "^ \t!:\n") (point)))
16336 (goto-char (point-min))
16338 (and (/= (point-min) (point-max))
16339 (let ((obarray gnus-active-hashtb)) (read buf))))
16341 ;; Now, the symbol we have read is either `options' or a group
16342 ;; name. If it is an options line, we just add it to a string.
16344 ((or (eq symbol options-symbol)
16345 (eq symbol Options-symbol))
16346 (setq gnus-newsrc-options
16347 ;; This concating is quite inefficient, but since our
16348 ;; thorough studies show that approx 99.37% of all
16349 ;; .newsrc files only contain a single options line, we
16350 ;; don't give a damn, frankly, my dear.
16351 (concat gnus-newsrc-options
16353 (gnus-point-at-bol)
16354 ;; Options may continue on the next line.
16355 (or (and (re-search-forward "^[^ \t]" nil 'move)
16356 (progn (beginning-of-line) (point)))
16360 ;; Group names can be just numbers.
16361 (when (numberp symbol)
16362 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16363 (or (boundp symbol) (set symbol nil))
16364 ;; It was a group name.
16365 (setq subscribed (= (following-char) ?:)
16366 group (symbol-name symbol)
16369 ;; If the line ends here, this is clearly a buggy line, so
16370 ;; we put point a the beginning of line and let the cond
16371 ;; below do the error handling.
16372 (beginning-of-line)
16373 ;; We skip to the beginning of the ranges.
16374 (skip-chars-forward "!: \t"))
16375 ;; We are now at the beginning of the list of read articles.
16376 ;; We read them range by range.
16379 ((looking-at "[0-9]+")
16380 ;; We narrow and read a number instead of buffer-substring/
16381 ;; string-to-int because it's faster. narrow/widen is
16382 ;; faster than save-restriction/narrow, and save-restriction
16383 ;; produces a garbage object.
16385 (narrow-to-region (match-beginning 0) (match-end 0))
16388 ;; If the next character is a dash, then this is a range.
16389 (if (= (following-char) ?-)
16391 ;; We read the upper bound of the range.
16393 (if (not (looking-at "[0-9]+"))
16394 ;; This is a buggy line, by we pretend that
16395 ;; it's kinda OK. Perhaps the user should be
16397 (setq reads (cons num1 reads))
16402 (narrow-to-region (match-beginning 0)
16407 ;; It was just a simple number, so we add it to the
16409 (setq reads (cons num1 reads)))
16410 ;; If the next char in ?\n, then we have reached the end
16411 ;; of the line and return nil.
16412 (/= (following-char) ?\n))
16413 ((= (following-char) ?\n)
16414 ;; End of line, so we end.
16417 ;; Not numbers and not eol, so this might be a buggy
16420 ;; If it was eob instead of ?\n, we allow it.
16422 ;; The line was buggy.
16424 (gnus-error 3.1 "Mangled line: %s"
16425 (buffer-substring (gnus-point-at-bol)
16426 (gnus-point-at-eol)))))
16428 ;; Skip past ", ". Spaces are illegal in these ranges, but
16429 ;; we allow them, because it's a common mistake to put a
16430 ;; space after the comma.
16431 (skip-chars-forward ", "))
16433 ;; We have already read .newsrc.eld, so we gently update the
16434 ;; data in the hash table with the information we have just
16437 (let ((info (gnus-get-info group))
16440 ;; There is an entry for this file in the alist.
16442 (gnus-info-set-read info (nreverse reads))
16443 ;; We update the level very gently. In fact, we
16444 ;; only change it if there's been a status change
16445 ;; from subscribed to unsubscribed, or vice versa.
16446 (setq level (gnus-info-level info))
16447 (cond ((and (<= level gnus-level-subscribed)
16449 (setq level (if reads
16450 gnus-level-default-unsubscribed
16451 (1+ gnus-level-default-unsubscribed))))
16452 ((and (> level gnus-level-subscribed) subscribed)
16453 (setq level gnus-level-default-subscribed)))
16454 (gnus-info-set-level info level))
16455 ;; This is a new group.
16456 (setq info (list group
16458 gnus-level-default-subscribed
16460 (1+ gnus-level-subscribed)
16461 gnus-level-default-unsubscribed))
16462 (nreverse reads))))
16463 (setq newsrc (cons info newsrc))))))
16466 (setq newsrc (nreverse newsrc))
16468 (if (not already-read)
16470 ;; We now have two newsrc lists - `newsrc', which is what we
16471 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16472 ;; what we've read from .newsrc.eld. We have to merge these
16473 ;; lists. We do this by "attaching" any (foreign) groups in the
16474 ;; gnus-newsrc-alist to the (native) group that precedes them.
16475 (let ((rc (cdr gnus-newsrc-alist))
16476 (prev gnus-newsrc-alist)
16479 (or (null (nth 4 (car rc))) ; It's a native group.
16480 (assoc (caar rc) newsrc) ; It's already in the alist.
16481 (if (setq entry (assoc (caar prev) newsrc))
16482 (setcdr (setq mentry (memq entry newsrc))
16483 (cons (car rc) (cdr mentry)))
16484 (setq newsrc (cons (car rc) newsrc))))
16488 (setq gnus-newsrc-alist newsrc)
16489 ;; We make the newsrc hashtb.
16490 (gnus-make-hashtable-from-newsrc-alist)
16492 ;; Finally, if we read some options lines, we parse them.
16493 (or (string= gnus-newsrc-options "")
16494 (gnus-newsrc-parse-options gnus-newsrc-options))))
16496 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16497 ;; The return value will be a list on the form
16498 ;; ((regexp1 . ignore)
16499 ;; (regexp2 . subscribe)...)
16500 ;; When handling new newsgroups, groups that match a `ignore' regexp
16501 ;; will be ignored, and groups that match a `subscribe' regexp will be
16502 ;; subscribed. A line like
16503 ;; options -n !all rec.all
16504 ;; will lead to a list that looks like
16505 ;; (("^rec\\..+" . subscribe)
16506 ;; ("^.+" . ignore))
16507 ;; So all "rec.*" groups will be subscribed, while all the other
16508 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16509 ;; different from "options -n rec.all !all".
16510 (defun gnus-newsrc-parse-options (options)
16513 (gnus-set-work-buffer)
16514 (insert (regexp-quote options))
16515 ;; First we treat all continuation lines.
16516 (goto-char (point-min))
16517 (while (re-search-forward "\n[ \t]+" nil t)
16518 (replace-match " " t t))
16519 ;; Then we transform all "all"s into ".+"s.
16520 (goto-char (point-min))
16521 (while (re-search-forward "\\ball\\b" nil t)
16522 (replace-match ".+" t t))
16523 (goto-char (point-min))
16524 ;; We remove all other options than the "-n" ones.
16525 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16526 (replace-match " ")
16528 (goto-char (point-min))
16530 ;; We are only interested in "options -n" lines - we
16531 ;; ignore the other option lines.
16532 (while (re-search-forward "[ \t]-n" nil t)
16534 (or (save-excursion
16535 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16537 (gnus-point-at-eol)))
16538 ;; Search for all "words"...
16539 (while (re-search-forward "[^ \t,\n]+" eol t)
16540 (if (= (char-after (match-beginning 0)) ?!)
16541 ;; If the word begins with a bang (!), this is a "not"
16542 ;; spec. We put this spec (minus the bang) and the
16543 ;; symbol `ignore' into the list.
16544 (setq out (cons (cons (concat
16545 "^" (buffer-substring
16546 (1+ (match-beginning 0))
16549 ;; There was no bang, so this is a "yes" spec.
16550 (setq out (cons (cons (concat "^" (match-string 0))
16551 'subscribe) out)))))
16553 (setq gnus-newsrc-options-n out))))
16555 (defun gnus-save-newsrc-file (&optional force)
16556 "Save .newsrc file."
16557 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16558 ;; from the variable gnus-newsrc-alist.
16559 (when (and (or gnus-newsrc-alist gnus-killed-list)
16560 gnus-current-startup-file)
16562 (if (and (or gnus-use-dribble-file gnus-slave)
16564 (or (not gnus-dribble-buffer)
16565 (not (buffer-name gnus-dribble-buffer))
16566 (zerop (save-excursion
16567 (set-buffer gnus-dribble-buffer)
16569 (gnus-message 4 "(No changes need to be saved)")
16570 (run-hooks 'gnus-save-newsrc-hook)
16572 (gnus-slave-save-newsrc)
16574 (when gnus-save-newsrc-file
16575 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16576 (gnus-gnus-to-newsrc-format)
16577 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16578 ;; Save .newsrc.eld.
16579 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16580 (make-local-variable 'version-control)
16581 (setq version-control 'never)
16582 (setq buffer-file-name
16583 (concat gnus-current-startup-file ".eld"))
16584 (gnus-add-current-to-buffer-list)
16585 (buffer-disable-undo (current-buffer))
16587 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16588 (gnus-gnus-to-quick-newsrc-format)
16589 (run-hooks 'gnus-save-quick-newsrc-hook)
16591 (kill-buffer (current-buffer))
16593 5 "Saving %s.eld...done" gnus-current-startup-file))
16594 (gnus-dribble-delete-file)))))
16596 (defun gnus-gnus-to-quick-newsrc-format ()
16597 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16598 (insert ";; Gnus startup file.\n")
16599 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16600 (insert ";; to read .newsrc.\n")
16601 (insert "(setq gnus-newsrc-file-version "
16602 (prin1-to-string gnus-version) ")\n")
16604 (if gnus-save-killed-list gnus-variable-list
16605 ;; Remove the `gnus-killed-list' from the list of variables
16606 ;; to be saved, if required.
16607 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16608 ;; Peel off the "dummy" group.
16609 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16611 ;; Insert the variables into the file.
16613 (when (and (boundp (setq variable (pop variables)))
16614 (symbol-value variable))
16615 (insert "(setq " (symbol-name variable) " '")
16616 (prin1 (symbol-value variable) (current-buffer))
16619 (defun gnus-gnus-to-newsrc-format ()
16620 ;; Generate and save the .newsrc file.
16622 (set-buffer (create-file-buffer gnus-current-startup-file))
16623 (let ((newsrc (cdr gnus-newsrc-alist))
16624 (standard-output (current-buffer))
16625 info ranges range method)
16626 (setq buffer-file-name gnus-current-startup-file)
16627 (buffer-disable-undo (current-buffer))
16630 (if gnus-newsrc-options (insert gnus-newsrc-options))
16631 ;; Write subscribed and unsubscribed.
16632 (while (setq info (pop newsrc))
16633 ;; Don't write foreign groups to .newsrc.
16634 (when (or (null (setq method (gnus-info-method info)))
16635 (equal method "native")
16636 (gnus-server-equal method gnus-select-method))
16637 (insert (gnus-info-group info)
16638 (if (> (gnus-info-level info) gnus-level-subscribed)
16640 (when (setq ranges (gnus-info-read info))
16642 (if (not (listp (cdr ranges)))
16643 (if (= (car ranges) (cdr ranges))
16644 (princ (car ranges))
16645 (princ (car ranges))
16647 (princ (cdr ranges)))
16648 (while (setq range (pop ranges))
16649 (if (or (atom range) (= (car range) (cdr range)))
16650 (princ (or (and (atom range) range) (car range)))
16651 (princ (car range))
16653 (princ (cdr range)))
16654 (if ranges (insert ",")))))
16656 (make-local-variable 'version-control)
16657 (setq version-control 'never)
16658 ;; It has been reported that sometime the modtime on the .newsrc
16659 ;; file seems to be off. We really do want to overwrite it, so
16660 ;; we clear the modtime here before saving. It's a bit odd,
16662 ;; sometimes the modtime clear isn't sufficient. most brute force:
16663 ;; delete the silly thing entirely first. but this fails to provide
16664 ;; such niceties as .newsrc~ creation.
16665 (if gnus-modtime-botch
16666 (delete-file gnus-startup-file)
16667 (clear-visited-file-modtime))
16668 (run-hooks 'gnus-save-standard-newsrc-hook)
16670 (kill-buffer (current-buffer)))))
16674 ;;; Slave functions.
16677 (defun gnus-slave-save-newsrc ()
16679 (set-buffer gnus-dribble-buffer)
16681 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16682 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16684 (defun gnus-master-read-slave-newsrc ()
16687 (file-name-directory gnus-current-startup-file)
16691 (file-name-nondirectory gnus-current-startup-file)
16695 (if (not slave-files)
16696 () ; There are no slave files to read.
16697 (gnus-message 7 "Reading slave newsrcs...")
16699 (set-buffer (get-buffer-create " *gnus slave*"))
16700 (buffer-disable-undo (current-buffer))
16702 (sort (mapcar (lambda (file)
16703 (list (nth 5 (file-attributes file)) file))
16706 (or (< (caar f1) (caar f2))
16707 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16710 (setq file (nth 1 (car slave-files)))
16711 (insert-file-contents file)
16712 (if (condition-case ()
16714 (eval-buffer (current-buffer))
16717 (gnus-error 3.2 "Possible error in %s" file)
16719 (or gnus-slave ; Slaves shouldn't delete these files.
16723 (setq slave-files (cdr slave-files))))
16724 (gnus-message 7 "Reading slave newsrcs...done"))))
16728 ;;; Group description.
16731 (defun gnus-read-all-descriptions-files ()
16732 (let ((methods (cons gnus-select-method
16734 (when gnus-message-archive-method
16736 gnus-secondary-select-methods))))
16738 (gnus-read-descriptions-file (car methods))
16739 (setq methods (cdr methods)))
16742 (defun gnus-read-descriptions-file (&optional method)
16743 (let ((method (or method gnus-select-method)))
16744 (when (stringp method)
16745 (setq method (gnus-server-to-method method)))
16746 ;; We create the hashtable whether we manage to read the desc file
16747 ;; to avoid trying to re-read after a failed read.
16748 (or gnus-description-hashtb
16749 (setq gnus-description-hashtb
16750 (gnus-make-hashtable (length gnus-active-hashtb))))
16751 ;; Mark this method's desc file as read.
16752 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16753 gnus-description-hashtb)
16755 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16757 ((not (gnus-check-server method))
16758 (gnus-message 1 "Couldn't open server")
16760 ((not (gnus-request-list-newsgroups method))
16761 (gnus-message 1 "Couldn't read newsgroups descriptions")
16767 (set-buffer nntp-server-buffer)
16768 (goto-char (point-min))
16769 (if (or (search-forward "\n.\n" nil t)
16770 (goto-char (point-max)))
16772 (beginning-of-line)
16773 (narrow-to-region (point-min) (point))))
16774 (goto-char (point-min))
16775 (while (not (eobp))
16776 ;; If we get an error, we set group to 0, which is not a
16780 (let ((obarray gnus-description-hashtb))
16781 ;; Group is set to a symbol interned in this
16783 (read nntp-server-buffer))
16785 (skip-chars-forward " \t")
16786 ;; ... which leads to this line being effectively ignored.
16787 (and (symbolp group)
16788 (set group (buffer-substring
16789 (point) (progn (end-of-line) (point)))))
16790 (forward-line 1))))
16791 (gnus-message 5 "Reading descriptions file...done")
16794 (defun gnus-group-get-description (group)
16795 "Get the description of a group by sending XGTITLE to the server."
16796 (when (gnus-request-group-description group)
16798 (set-buffer nntp-server-buffer)
16799 (goto-char (point-min))
16800 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16801 (match-string 1)))))
16805 ;;; Buffering of read articles.
16808 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16809 (defvar gnus-backlog-articles nil)
16810 (defvar gnus-backlog-hashtb nil)
16812 (defun gnus-backlog-buffer ()
16813 "Return the backlog buffer."
16814 (or (get-buffer gnus-backlog-buffer)
16816 (set-buffer (get-buffer-create gnus-backlog-buffer))
16817 (buffer-disable-undo (current-buffer))
16818 (setq buffer-read-only t)
16819 (gnus-add-current-to-buffer-list)
16820 (get-buffer gnus-backlog-buffer))))
16822 (defun gnus-backlog-setup ()
16823 "Initialize backlog variables."
16824 (unless gnus-backlog-hashtb
16825 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16827 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16829 (defun gnus-backlog-shutdown ()
16830 "Clear all backlog variables and buffers."
16831 (when (get-buffer gnus-backlog-buffer)
16832 (kill-buffer gnus-backlog-buffer))
16833 (setq gnus-backlog-hashtb nil
16834 gnus-backlog-articles nil))
16836 (defun gnus-backlog-enter-article (group number buffer)
16837 (gnus-backlog-setup)
16838 (let ((ident (intern (concat group ":" (int-to-string number))
16839 gnus-backlog-hashtb))
16841 (if (memq ident gnus-backlog-articles)
16842 () ; It's already kept.
16843 ;; Remove the oldest article, if necessary.
16844 (and (numberp gnus-keep-backlog)
16845 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16846 (gnus-backlog-remove-oldest-article))
16847 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16848 ;; Insert the new article.
16850 (set-buffer (gnus-backlog-buffer))
16851 (let (buffer-read-only)
16852 (goto-char (point-max))
16853 (or (bolp) (insert "\n"))
16855 (insert-buffer-substring buffer)
16856 ;; Tag the beginning of the article with the ident.
16857 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16859 (defun gnus-backlog-remove-oldest-article ()
16861 (set-buffer (gnus-backlog-buffer))
16862 (goto-char (point-min))
16863 (if (zerop (buffer-size))
16864 () ; The buffer is empty.
16865 (let ((ident (get-text-property (point) 'gnus-backlog))
16867 ;; Remove the ident from the list of articles.
16869 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16870 ;; Delete the article itself.
16872 (point) (next-single-property-change
16873 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16875 (defun gnus-backlog-remove-article (group number)
16876 "Remove article NUMBER in GROUP from the backlog."
16877 (when (numberp number)
16878 (gnus-backlog-setup)
16879 (let ((ident (intern (concat group ":" (int-to-string number))
16880 gnus-backlog-hashtb))
16882 (when (memq ident gnus-backlog-articles)
16883 ;; It was in the backlog.
16885 (set-buffer (gnus-backlog-buffer))
16886 (when (setq beg (text-property-any
16887 (point-min) (point-max) 'gnus-backlog
16889 ;; Find the end (i. e., the beginning of the next article).
16891 (next-single-property-change
16892 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
16893 (delete-region beg end)
16897 (defun gnus-backlog-request-article (group number buffer)
16898 (when (numberp number)
16899 (gnus-backlog-setup)
16900 (let ((ident (intern (concat group ":" (int-to-string number))
16901 gnus-backlog-hashtb))
16903 (when (memq ident gnus-backlog-articles)
16904 ;; It was in the backlog.
16906 (set-buffer (gnus-backlog-buffer))
16907 (if (not (setq beg (text-property-any
16908 (point-min) (point-max) 'gnus-backlog
16910 ;; It wasn't in the backlog after all.
16912 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16913 ;; Find the end (i. e., the beginning of the next article).
16915 (next-single-property-change
16916 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16917 (let ((buffer-read-only nil))
16919 (insert-buffer-substring gnus-backlog-buffer beg end)
16922 ;; Allow redefinition of Gnus functions.
16924 (gnus-ems-redefine)
16928 ;;; gnus.el ends here