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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 (eval '(run-hooks 'gnus-load-hook))
34 (eval-when-compile (require 'cl))
36 ;; Site dependent variables. These variables should be defined in
39 (defvar gnus-default-nntp-server nil
40 "Specify a default NNTP server.
41 This variable should be defined in paths.el, and should never be set
43 If you want to change servers, you should use `gnus-select-method'.
44 See the documentation to that variable.")
46 (defvar gnus-backup-default-subscribed-newsgroups
47 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
48 "Default default new newsgroups the first time Gnus is run.
49 Should be set in paths.el, and shouldn't be touched by the user.")
51 (defvar gnus-local-domain nil
52 "Local domain name without a host name.
53 The DOMAINNAME environment variable is used instead if it is defined.
54 If the `system-name' function returns the full Internet name, there is
55 no need to set this variable.")
57 (defvar gnus-local-organization nil
58 "String with a description of what organization (if any) the user belongs to.
59 The ORGANIZATION environment variable is used instead if it is defined.
60 If this variable contains a function, this function will be called
61 with the current newsgroup name as the argument. The function should
64 In any case, if the string (either in the variable, in the environment
65 variable, or returned by the function) is a file name, the contents of
66 this file will be used as the organization.")
68 (defvar gnus-use-generic-from nil
69 "If nil, the full host name will be the system name prepended to the domain name.
70 If this is a string, the full host name will be this string.
71 If this is non-nil, non-string, the domain name will be used as the
74 (defvar gnus-use-generic-path nil
75 "If nil, use the NNTP server name in the Path header.
76 If stringp, use this; if non-nil, use no host name (user name only).")
79 ;; Customization variables
81 ;; Don't touch this variable.
82 (defvar gnus-nntp-service "nntp"
83 "*NNTP service name (\"nntp\" or 119).
84 This is an obsolete variable, which is scarcely used. If you use an
85 nntp server for your newsgroup and want to change the port number
86 used to 899, you would say something along these lines:
88 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
90 (defvar gnus-nntpserver-file "/etc/nntpserver"
91 "*A file with only the name of the nntp server in it.")
93 ;; This function is used to check both the environment variable
94 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
95 ;; an nntp server name default.
96 (defun gnus-getenv-nntpserver ()
97 (or (getenv "NNTPSERVER")
98 (and (file-readable-p gnus-nntpserver-file)
100 (set-buffer (get-buffer-create " *gnus nntp*"))
101 (buffer-disable-undo (current-buffer))
102 (insert-file-contents gnus-nntpserver-file)
103 (let ((name (buffer-string)))
105 (if (string-match "^[ \t\n]*$" name)
108 (kill-buffer (current-buffer))))))))
110 (defvar gnus-select-method
112 (list 'nntp (or (condition-case ()
113 (gnus-getenv-nntpserver)
115 (if (and gnus-default-nntp-server
116 (not (string= gnus-default-nntp-server "")))
117 gnus-default-nntp-server)
119 (if (or (null gnus-nntp-service)
120 (equal gnus-nntp-service "nntp"))
122 (list gnus-nntp-service)))
123 "*Default method for selecting a newsgroup.
124 This variable should be a list, where the first element is how the
125 news is to be fetched, the second is the address.
127 For instance, if you want to get your news via NNTP from
128 \"flab.flab.edu\", you could say:
130 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
132 If you want to use your local spool, say:
134 (setq gnus-select-method (list 'nnspool (system-name)))
136 If you use this variable, you must set `gnus-nntp-server' to nil.
138 There is a lot more to know about select methods and virtual servers -
139 see the manual for details.")
141 (defvar gnus-message-archive-method
142 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
143 (nnfolder-active-file "~/Mail/archive/active")
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.")
149 (defvar gnus-refer-article-method nil
150 "*Preferred method for fetching an article by Message-ID.
151 If you are reading news from the local spool (with nnspool), fetching
152 articles by Message-ID is painfully slow. By setting this method to an
153 nntp method, you might get acceptable results.
155 The value of this variable must be a valid select method as discussed
156 in the documentation of `gnus-select-method'")
158 (defvar gnus-secondary-select-methods nil
159 "*A list of secondary methods that will be used for reading news.
160 This is a list where each element is a complete select method (see
161 `gnus-select-method').
163 If, for instance, you want to read your mail with the nnml backend,
164 you could set this variable:
166 (setq gnus-secondary-select-methods '((nnml \"\")))")
168 (defvar gnus-secondary-servers nil
169 "*List of NNTP servers that the user can choose between interactively.
170 To make Gnus query you for a server, you have to give `gnus' a
171 non-numeric prefix - `C-u M-x gnus', in short.")
173 (defvar gnus-nntp-server nil
174 "*The name of the host running the NNTP server.
175 This variable is semi-obsolete. Use the `gnus-select-method'
178 (defvar gnus-startup-file "~/.newsrc"
179 "*Your `.newsrc' file.
180 `.newsrc-SERVER' will be used instead if that exists.")
182 (defvar gnus-init-file "~/.gnus"
183 "*Your Gnus elisp startup file.
184 If a file with the .el or .elc suffixes exist, it will be read
187 (defvar gnus-group-faq-directory
188 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
189 ; "/ftp@ftp.uu.net:/usenet/news.answers/"
190 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
191 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
192 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
193 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
194 ; "/ftp@ftp.Germany.EU.net:/pub/newsarchive/news.answers/"
195 "/ftp@ftp.sunet.se:/pub/usenet/"
196 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
197 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
198 "/ftp@ftp.hk.super.net:/mirror/faqs/")
199 "*Directory where the group FAQs are stored.
200 This will most commonly be on a remote machine, and the file will be
203 This variable can also be a list of directories. In that case, the
204 first element in the list will be used by default, and the others will
205 be used as backup sites.
207 Note that Gnus uses an aol machine as the default directory. If this
208 feels fundamentally unclean, just think of it as a way to finally get
209 something of value back from them.
211 If the default site is too slow, try one of these:
213 North America: mirrors.aol.com /pub/rtfm/usenet
214 ftp.seas.gwu.edu /pub/rtfm
215 rtfm.mit.edu /pub/usenet/news.answers
216 Europe: ftp.uni-paderborn.de /pub/FAQ
217 src.doc.ic.ac.uk /usenet/news-FAQS
218 ftp.sunet.se /pub/usenet
219 Asia: nctuccca.edu.tw /USENET/FAQ
220 hwarang.postech.ac.kr /pub/usenet/news.answers
221 ftp.hk.super.net /mirror/faqs")
223 (defvar gnus-group-archive-directory
224 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
225 "*The address of the (ding) archives.")
227 (defvar gnus-group-recent-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
229 "*The address of the most recent (ding) articles.")
231 (defvar gnus-default-subscribed-newsgroups nil
232 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
233 It should be a list of strings.
234 If it is `t', Gnus will not do anything special the first time it is
235 started; it'll just use the normal newsgroups subscription methods.")
237 (defvar gnus-use-cross-reference t
238 "*Non-nil means that cross referenced articles will be marked as read.
239 If nil, ignore cross references. If t, mark articles as read in
240 subscribed newsgroups. If neither t nor nil, mark as read in all
243 (defvar gnus-single-article-buffer t
244 "*If non-nil, display all articles in the same buffer.
245 If nil, each group will get its own article buffer.")
247 (defvar gnus-use-dribble-file t
248 "*Non-nil means that Gnus will use a dribble file to store user updates.
249 If Emacs should crash without saving the .newsrc files, complete
250 information can be restored from the dribble file.")
252 (defvar gnus-dribble-directory nil
253 "*The directory where dribble files will be saved.
254 If this variable is nil, the directory where the .newsrc files are
255 saved will be used.")
257 (defvar gnus-asynchronous nil
258 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
260 (defvar gnus-kill-summary-on-exit t
261 "*If non-nil, kill the summary buffer when you exit from it.
262 If nil, the summary will become a \"*Dead Summary*\" buffer, and
263 it will be killed sometime later.")
265 (defvar gnus-large-newsgroup 200
266 "*The number of articles which indicates a large newsgroup.
267 If the number of articles in a newsgroup is greater than this value,
268 confirmation is required for selecting the newsgroup.")
270 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
271 (defvar gnus-no-groups-message "No news is horrible news"
272 "*Message displayed by Gnus when no groups are available.")
274 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
275 "*Non-nil means that the default name of a file to save articles in is the group name.
276 If it's nil, the directory form of the group name is used instead.
278 If this variable is a list, and the list contains the element
279 `not-score', long file names will not be used for score files; if it
280 contains the element `not-save', long file names will not be used for
281 saving; and if it contains the element `not-kill', long file names
282 will not be used for kill files.")
284 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
285 "*Name of the directory articles will be saved in (default \"~/News\").
286 Initialized from the SAVEDIR environment variable.")
288 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
289 "*Name of the directory where kill files will be stored (default \"~/News\").
290 Initialized from the SAVEDIR environment variable.")
292 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
293 "*A function to save articles in your favorite format.
294 The function must be interactively callable (in other words, it must
295 be an Emacs command).
297 Gnus provides the following functions:
299 * gnus-summary-save-in-rmail (Rmail format)
300 * gnus-summary-save-in-mail (Unix mail format)
301 * gnus-summary-save-in-folder (MH folder)
302 * gnus-summary-save-in-file (article format).
303 * gnus-summary-save-in-vm (use VM's folder format).")
305 (defvar gnus-prompt-before-saving 'always
306 "*This variable says how much prompting is to be done when saving articles.
307 If it is nil, no prompting will be done, and the articles will be
308 saved to the default files. If this variable is `always', each and
309 every article that is saved will be preceded by a prompt, even when
310 saving large batches of articles. If this variable is neither nil not
311 `always', there the user will be prompted once for a file name for
312 each invocation of the saving commands.")
314 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
315 "*A function generating a file name to save articles in Rmail format.
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
318 (defvar gnus-mail-save-name (function gnus-plain-save-name)
319 "*A function generating a file name to save articles in Unix mail format.
320 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
322 (defvar gnus-folder-save-name (function gnus-folder-save-name)
323 "*A function generating a file name to save articles in MH folder.
324 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
326 (defvar gnus-file-save-name (function gnus-numeric-save-name)
327 "*A function generating a file name to save articles in article format.
328 The function is called with NEWSGROUP, HEADERS, and optional
331 (defvar gnus-split-methods
332 '((gnus-article-archive-name))
333 "*Variable used to suggest where articles are to be saved.
334 For instance, if you would like to save articles related to Gnus in
335 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
336 you could set this variable to something like:
338 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
339 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
341 This variable is an alist where the where the key is the match and the
342 value is a list of possible files to save in if the match is non-nil.
344 If the match is a string, it is used as a regexp match on the
345 article. If the match is a symbol, that symbol will be funcalled
346 from the buffer of the article to be saved with the newsgroup as the
347 parameter. If it is a list, it will be evaled in the same buffer.
349 If this form or function returns a string, this string will be used as
350 a possible file name; and if it returns a non-nil list, that list will
351 be used as possible file names.")
353 (defvar gnus-move-split-methods nil
354 "*Variable used to suggest where articles are to be moved to.
355 It uses the same syntax as the `gnus-split-methods' variable.")
357 (defvar gnus-save-score nil
358 "*If non-nil, save group scoring info.")
360 (defvar gnus-use-adaptive-scoring nil
361 "*If non-nil, use some adaptive scoring scheme.")
363 (defvar gnus-use-cache nil
364 "*If nil, Gnus will ignore the article cache.
365 If `passive', it will allow entering (and reading) articles
366 explicitly entered into the cache. If anything else, use the
367 cache to the full extent of the law.")
369 (defvar gnus-use-trees nil
370 "*If non-nil, display a thread tree buffer.")
372 (defvar gnus-keep-backlog nil
373 "*If non-nil, Gnus will keep read articles for later re-retrieval.
374 If it is a number N, then Gnus will only keep the last N articles
375 read. If it is neither nil nor a number, Gnus will keep all read
376 articles. This is not a good idea.")
378 (defvar gnus-use-nocem nil
379 "*If non-nil, Gnus will read NoCeM cancel messages.")
381 (defvar gnus-use-demon nil
382 "If non-nil, Gnus might use some demons.")
384 (defvar gnus-use-scoring t
385 "*If non-nil, enable scoring.")
387 (defvar gnus-use-picons nil
388 "*If non-nil, display picons.")
390 (defvar gnus-fetch-old-headers nil
391 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
392 If an unread article in the group refers to an older, already read (or
393 just marked as read) article, the old article will not normally be
394 displayed in the Summary buffer. If this variable is non-nil, Gnus
395 will attempt to grab the headers to the old articles, and thereby
396 build complete threads. If it has the value `some', only enough
397 headers to connect otherwise loose threads will be displayed.
398 This variable can also be a number. In that case, no more than that
399 number of old headers will be fetched.
401 The server has to support NOV for any of this to work.")
404 ;(defvar gnus-visual t
405 ; "*If non-nil, will do various highlighting.
406 ;If nil, no mouse highlights (or any other highlights) will be
407 ;performed. This might speed up Gnus some when generating large group
408 ;and summary buffers.")
410 (defvar gnus-novice-user t
411 "*Non-nil means that you are a usenet novice.
412 If non-nil, verbose messages may be displayed and confirmations may be
415 (defvar gnus-expert-user nil
416 "*Non-nil means that you will never be asked for confirmation about anything.
417 And that means *anything*.")
419 (defvar gnus-verbose 7
420 "*Integer that says how verbose Gnus should be.
421 The higher the number, the more messages Gnus will flash to say what
422 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
423 display most important messages; and at ten, Gnus will keep on
424 jabbering all the time.")
426 (defvar gnus-keep-same-level nil
427 "*Non-nil means that the next newsgroup after the current will be on the same level.
428 When you type, for instance, `n' after reading the last article in the
429 current newsgroup, you will go to the next newsgroup. If this variable
430 is nil, the next newsgroup will be the next from the group
432 If this variable is non-nil, Gnus will either put you in the
433 next newsgroup with the same level, or, if no such newsgroup is
434 available, the next newsgroup with the lowest possible level higher
435 than the current level.
436 If this variable is `best', Gnus will make the next newsgroup the one
437 with the best level.")
439 (defvar gnus-summary-make-false-root 'adopt
440 "*nil means that Gnus won't gather loose threads.
441 If the root of a thread has expired or been read in a previous
442 session, the information necessary to build a complete thread has been
443 lost. Instead of having many small sub-threads from this original thread
444 scattered all over the summary buffer, Gnus can gather them.
446 If non-nil, Gnus will try to gather all loose sub-threads from an
447 original thread into one large thread.
449 If this variable is non-nil, it should be one of `none', `adopt',
452 If this variable is `none', Gnus will not make a false root, but just
453 present the sub-threads after another.
454 If this variable is `dummy', Gnus will create a dummy root that will
455 have all the sub-threads as children.
456 If this variable is `adopt', Gnus will make one of the \"children\"
457 the parent and mark all the step-children as such.
458 If this variable is `empty', the \"children\" are printed with empty
459 subject fields. (Or rather, they will be printed with a string
460 given by the `gnus-summary-same-subject' variable.)")
462 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
463 "*A regexp to match subjects to be excluded from loose thread gathering.
464 As loose thread gathering is done on subjects only, that means that
465 there can be many false gatherings performed. By rooting out certain
466 common subjects, gathering might become saner.")
468 (defvar gnus-summary-gather-subject-limit nil
469 "*Maximum length of subject comparisons when gathering loose threads.
470 Use nil to compare full subjects. Setting this variable to a low
471 number will help gather threads that have been corrupted by
472 newsreaders chopping off subject lines, but it might also mean that
473 unrelated articles that have subject that happen to begin with the
474 same few characters will be incorrectly gathered.
476 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
477 comparing subjects.")
479 (defvar gnus-simplify-ignored-prefixes nil
480 "*Regexp, matches for which are removed from subject lines when simplifying.")
482 (defvar gnus-build-sparse-threads nil
483 "*If non-nil, fill in the gaps in threads.
484 If `some', only fill in the gaps that are needed to tie loose threads
485 together. If `more', fill in all leaf nodes that Gnus can find. If
486 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
488 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
489 "Function used for gathering loose threads.
490 There are two pre-defined functions: `gnus-gather-threads-by-subject',
491 which only takes Subjects into consideration; and
492 `gnus-gather-threads-by-references', which compared the References
493 headers of the articles to find matches.")
495 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
496 (defvar gnus-summary-same-subject ""
497 "*String indicating that the current article has the same subject as the previous.
498 This variable will only be used if the value of
499 `gnus-summary-make-false-root' is `empty'.")
501 (defvar gnus-summary-goto-unread t
502 "*If non-nil, marking commands will go to the next unread article.
503 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
504 whether it is read or not.")
506 (defvar gnus-group-goto-unread t
507 "*If non-nil, movement commands will go to the next unread and subscribed group.")
509 (defvar gnus-goto-next-group-when-activating t
510 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
512 (defvar gnus-check-new-newsgroups t
513 "*Non-nil means that Gnus will add new newsgroups at startup.
514 If this variable is `ask-server', Gnus will ask the server for new
515 groups since the last time it checked. This means that the killed list
516 is no longer necessary, so you could set `gnus-save-killed-list' to
519 A variant is to have this variable be a list of select methods. Gnus
520 will then use the `ask-server' method on all these select methods to
521 query for new groups from all those servers.
524 (setq gnus-check-new-newsgroups
525 '((nntp \"some.server\") (nntp \"other.server\")))
527 If this variable is nil, then you have to tell Gnus explicitly to
528 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
530 (defvar gnus-check-bogus-newsgroups nil
531 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
532 If this variable is nil, then you have to tell Gnus explicitly to
533 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
535 (defvar gnus-read-active-file t
536 "*Non-nil means that Gnus will read the entire active file at startup.
537 If this variable is nil, Gnus will only know about the groups in your
540 If this variable is `some', Gnus will try to only read the relevant
541 parts of the active file from the server. Not all servers support
542 this, and it might be quite slow with other servers, but this should
543 generally be faster than both the t and nil value.
545 If you set this variable to nil or `some', you probably still want to
546 be told about new newsgroups that arrive. To do that, set
547 `gnus-check-new-newsgroups' to `ask-server'. This may not work
548 properly with all servers.")
550 (defvar gnus-level-subscribed 5
551 "*Groups with levels less than or equal to this variable are subscribed.")
553 (defvar gnus-level-unsubscribed 7
554 "*Groups with levels less than or equal to this variable are unsubscribed.
555 Groups with levels less than `gnus-level-subscribed', which should be
556 less than this variable, are subscribed.")
558 (defvar gnus-level-zombie 8
559 "*Groups with this level are zombie groups.")
561 (defvar gnus-level-killed 9
562 "*Groups with this level are killed.")
564 (defvar gnus-level-default-subscribed 3
565 "*New subscribed groups will be subscribed at this level.")
567 (defvar gnus-level-default-unsubscribed 6
568 "*New unsubscribed groups will be unsubscribed at this level.")
570 (defvar gnus-activate-level (1+ gnus-level-subscribed)
571 "*Groups higher than this level won't be activated on startup.
572 Setting this variable to something log might save lots of time when
573 you have many groups that you aren't interested in.")
575 (defvar gnus-activate-foreign-newsgroups 4
576 "*If nil, Gnus will not check foreign newsgroups at startup.
577 If it is non-nil, it should be a number between one and nine. Foreign
578 newsgroups that have a level lower or equal to this number will be
579 activated on startup. For instance, if you want to active all
580 subscribed newsgroups, but not the rest, you'd set this variable to
581 `gnus-level-subscribed'.
583 If you subscribe to lots of newsgroups from different servers, startup
584 might take a while. By setting this variable to nil, you'll save time,
585 but you won't be told how many unread articles there are in the
588 (defvar gnus-save-newsrc-file t
589 "*Non-nil means that Gnus will save the `.newsrc' file.
590 Gnus always saves its own startup file, which is called
591 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
592 be readily understood by other newsreaders. If you don't plan on
593 using other newsreaders, set this variable to nil to save some time on
596 (defvar gnus-save-killed-list t
597 "*If non-nil, save the list of killed groups to the startup file.
598 If you set this variable to nil, you'll save both time (when starting
599 and quitting) and space (both memory and disk), but it will also mean
600 that Gnus has no record of which groups are new and which are old, so
601 the automatic new newsgroups subscription methods become meaningless.
603 You should always set `gnus-check-new-newsgroups' to `ask-server' or
604 nil if you set this variable to nil.")
606 (defvar gnus-interactive-catchup t
607 "*If non-nil, require your confirmation when catching up a group.")
609 (defvar gnus-interactive-post t
610 "*If non-nil, group name will be asked for when posting.")
612 (defvar gnus-interactive-exit t
613 "*If non-nil, require your confirmation when exiting Gnus.")
615 (defvar gnus-kill-killed t
616 "*If non-nil, Gnus will apply kill files to already killed articles.
617 If it is nil, Gnus will never apply kill files to articles that have
618 already been through the scoring process, which might very well save lots
621 (defvar gnus-extract-address-components 'gnus-extract-address-components
622 "*Function for extracting address components from a From header.
623 Two pre-defined function exist: `gnus-extract-address-components',
624 which is the default, quite fast, and too simplistic solution, and
625 `mail-extract-address-components', which works much better, but is
628 (defvar gnus-summary-default-score 0
629 "*Default article score level.
630 If this variable is nil, scoring will be disabled.")
632 (defvar gnus-summary-zcore-fuzz 0
633 "*Fuzziness factor for the zcore in the summary buffer.
634 Articles with scores closer than this to `gnus-summary-default-score'
635 will not be marked.")
637 (defvar gnus-simplify-subject-fuzzy-regexp nil
638 "*Strings to be removed when doing fuzzy matches.
639 This can either be a regular expression or list of regular expressions
640 that will be removed from subject strings if fuzzy subject
641 simplification is selected.")
643 (defvar gnus-permanently-visible-groups nil
644 "*Regexp to match groups that should always be listed in the group buffer.
645 This means that they will still be listed when there are no unread
646 articles in the groups.")
648 (defvar gnus-list-groups-with-ticked-articles t
649 "*If non-nil, list groups that have only ticked articles.
650 If nil, only list groups that have unread articles.")
652 (defvar gnus-group-default-list-level gnus-level-subscribed
653 "*Default listing level.
654 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
656 (defvar gnus-group-use-permanent-levels nil
657 "*If non-nil, once you set a level, Gnus will use this level.")
659 (defvar gnus-group-list-inactive-groups t
660 "*If non-nil, inactive groups will be listed.")
662 (defvar gnus-show-mime nil
663 "*If non-nil, do mime processing of articles.
664 The articles will simply be fed to the function given by
665 `gnus-show-mime-method'.")
667 (defvar gnus-strict-mime t
668 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
670 (defvar gnus-show-mime-method 'metamail-buffer
671 "*Function to process a MIME message.
672 The function is called from the article buffer.")
674 (defvar gnus-decode-encoded-word-method (lambda ())
675 "*Function to decode a MIME encoded-words.
676 The function is called from the article buffer.")
678 (defvar gnus-show-threads t
679 "*If non-nil, display threads in summary mode.")
681 (defvar gnus-thread-hide-subtree nil
682 "*If non-nil, hide all threads initially.
683 If threads are hidden, you have to run the command
684 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
685 to expose hidden threads.")
687 (defvar gnus-thread-hide-killed t
688 "*If non-nil, hide killed threads automatically.")
690 (defvar gnus-thread-ignore-subject nil
691 "*If non-nil, ignore subjects and do all threading based on the Reference header.
692 If nil, which is the default, articles that have different subjects
693 from their parents will start separate threads.")
695 (defvar gnus-thread-operation-ignore-subject t
696 "*If non-nil, subjects will be ignored when doing thread commands.
697 This affects commands like `gnus-summary-kill-thread' and
698 `gnus-summary-lower-thread'.
700 If this variable is nil, articles in the same thread with different
701 subjects will not be included in the operation in question. If this
702 variable is `fuzzy', only articles that have subjects that are fuzzily
703 equal will be included.")
705 (defvar gnus-thread-indent-level 4
706 "*Number that says how much each sub-thread should be indented.")
708 (defvar gnus-ignored-newsgroups
709 (purecopy (mapconcat 'identity
710 '("^to\\." ; not "real" groups
711 "^[0-9. \t]+ " ; all digits in name
712 "[][\"#'()]" ; bogus characters
715 "*A regexp to match uninteresting newsgroups in the active file.
716 Any lines in the active file matching this regular expression are
717 removed from the newsgroup list before anything else is done to it,
718 thus making them effectively non-existent.")
720 (defvar gnus-ignored-headers
721 "^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:"
722 "*All headers that match this regexp will be hidden.
723 This variable can also be a list of regexps of headers to be ignored.
724 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
726 (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-"
727 "*All headers that do not match this regexp will be hidden.
728 This variable can also be a list of regexp of headers to remain visible.
729 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
731 (defvar gnus-sorted-header-list
732 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
733 "^Cc:" "^Date:" "^Organization:")
734 "*This variable is a list of regular expressions.
735 If it is non-nil, headers that match the regular expressions will
736 be placed first in the article buffer in the sequence specified by
739 (defvar gnus-boring-article-headers
740 '(empty followup-to reply-to)
741 "*Headers that are only to be displayed if they have interesting data.
742 Possible values in this list are `empty', `newsgroups', `followup-to',
743 `reply-to', and `date'.")
745 (defvar gnus-show-all-headers nil
746 "*If non-nil, don't hide any headers.")
748 (defvar gnus-save-all-headers t
749 "*If non-nil, don't remove any headers before saving.")
751 (defvar gnus-saved-headers gnus-visible-headers
752 "*Headers to keep if `gnus-save-all-headers' is nil.
753 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
754 If that variable is nil, however, all headers that match this regexp
755 will be kept while the rest will be deleted before saving.")
757 (defvar gnus-inhibit-startup-message nil
758 "*If non-nil, the startup message will not be displayed.")
760 (defvar gnus-signature-separator "^-- *$"
761 "Regexp matching signature separator.")
763 (defvar gnus-auto-extend-newsgroup t
764 "*If non-nil, extend newsgroup forward and backward when requested.")
766 (defvar gnus-auto-select-first t
767 "*If nil, don't select the first unread article when entering a group.
768 If this variable is `best', select the highest-scored unread article
769 in the group. If neither nil nor `best', select the first unread
772 If you want to prevent automatic selection of the first unread article
773 in some newsgroups, set the variable to nil in
774 `gnus-select-group-hook'.")
776 (defvar gnus-auto-select-next t
777 "*If non-nil, offer to go to the next group from the end of the previous.
778 If the value is t and the next newsgroup is empty, Gnus will exit
779 summary mode and go back to group mode. If the value is neither nil
780 nor t, Gnus will select the following unread newsgroup. In
781 particular, if the value is the symbol `quietly', the next unread
782 newsgroup will be selected without any confirmation, and if it is
783 `almost-quietly', the next group will be selected without any
784 confirmation if you are located on the last article in the group.
785 Finally, if this variable is `slightly-quietly', the `Z n' command
786 will go to the next group without confirmation.")
788 (defvar gnus-auto-select-same nil
789 "*If non-nil, select the next article with the same subject.")
791 (defvar gnus-summary-check-current nil
792 "*If non-nil, consider the current article when moving.
793 The \"unread\" movement commands will stay on the same line if the
794 current article is unread.")
796 (defvar gnus-auto-center-summary t
797 "*If non-nil, always center the current summary buffer.")
799 (defvar gnus-break-pages t
800 "*If non-nil, do page breaking on articles.
801 The page delimiter is specified by the `gnus-page-delimiter'
804 (defvar gnus-page-delimiter "^\^L"
805 "*Regexp describing what to use as article page delimiters.
806 The default value is \"^\^L\", which is a form linefeed at the
807 beginning of a line.")
809 (defvar gnus-use-full-window t
810 "*If non-nil, use the entire Emacs screen.")
812 (defvar gnus-window-configuration nil
813 "Obsolete variable. See `gnus-buffer-configuration'.")
815 (defvar gnus-window-min-width 2
816 "*Minimum width of Gnus buffers.")
818 (defvar gnus-window-min-height 1
819 "*Minimum height of Gnus buffers.")
821 (defvar gnus-buffer-configuration
825 (if gnus-carpal '(group-carpal 4))))
829 (if gnus-carpal '(summary-carpal 4))))
836 (if gnus-carpal '(summary-carpal 4))
838 (vertical '((height . 5) (width . 15)
840 (left . -1) (top . 1))
850 (if gnus-carpal '(summary-carpal 4))
851 (if gnus-use-trees '(tree 0.25))
856 (if gnus-carpal '(server-carpal 2))))
860 (if gnus-carpal '(browse-carpal 2))))
873 (article 1.0 point)))
884 (edit-group 1.0 point)))
888 (edit-server 1.0 point)))
892 (edit-score 1.0 point)))
919 (if gnus-carpal '(summary-carpal 4))
920 ("*Shell Command Output*" 1.0)))
928 "Window configuration for all possible Gnus buffers.
929 This variable is a list of lists. Each of these lists has a NAME and
930 a RULE. The NAMEs are commonsense names like `group', which names a
931 rule used when displaying the group buffer; `summary', which names a
932 rule for what happens when you enter a group and do not display an
933 article buffer; and so on. See the value of this variable for a
934 complete list of NAMEs.
936 Each RULE is a list of vectors. The first element in this vector is
937 the name of the buffer to be displayed; the second element is the
938 percentage of the screen this buffer is to occupy (a number in the
939 0.0-0.99 range); the optional third element is `point', which should
940 be present to denote which buffer point is to go to after making this
941 buffer configuration.")
943 (defvar gnus-window-to-buffer
944 '((group . gnus-group-buffer)
945 (summary . gnus-summary-buffer)
946 (article . gnus-article-buffer)
947 (server . gnus-server-buffer)
948 (browse . "*Gnus Browse Server*")
949 (edit-group . gnus-group-edit-buffer)
950 (edit-server . gnus-server-edit-buffer)
951 (group-carpal . gnus-carpal-group-buffer)
952 (summary-carpal . gnus-carpal-summary-buffer)
953 (server-carpal . gnus-carpal-server-buffer)
954 (browse-carpal . gnus-carpal-browse-buffer)
955 (edit-score . gnus-score-edit-buffer)
956 (mail . gnus-mail-buffer)
957 (post . gnus-post-news-buffer)
958 (faq . gnus-faq-buffer)
959 (picons . "*Picons*")
960 (tree . gnus-tree-buffer)
961 (info . gnus-info-buffer)
962 (draft . gnus-draft-buffer))
963 "Mapping from short symbols to buffer names or buffer variables.")
965 (defvar gnus-carpal nil
966 "*If non-nil, display clickable icons.")
968 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
969 "*Function called with a group name when new group is detected.
970 A few pre-made functions are supplied: `gnus-subscribe-randomly'
971 inserts new groups at the beginning of the list of groups;
972 `gnus-subscribe-alphabetically' inserts new groups in strict
973 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
974 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
975 for your decision; `gnus-subscribe-killed' kills all new groups.")
977 ;; Suggested by a bug report by Hallvard B Furuseth.
978 ;; <h.b.furuseth@usit.uio.no>.
979 (defvar gnus-subscribe-options-newsgroup-method
980 (function gnus-subscribe-alphabetically)
981 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
982 If, for instance, you want to subscribe to all newsgroups in the
983 \"no\" and \"alt\" hierarchies, you'd put the following in your
986 options -n no.all alt.all
988 Gnus will the subscribe all new newsgroups in these hierarchies with
989 the subscription method in this variable.")
991 (defvar gnus-subscribe-hierarchical-interactive nil
992 "*If non-nil, Gnus will offer to subscribe hierarchically.
993 When a new hierarchy appears, Gnus will ask the user:
995 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
997 If the user pressed `d', Gnus will descend the hierarchy, `y' will
998 subscribe to all newsgroups in the hierarchy and `s' will skip this
999 hierarchy in its entirety.")
1001 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1002 "*Function used for sorting the group buffer.
1003 This function will be called with group info entries as the arguments
1004 for the groups to be sorted. Pre-made functions include
1005 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1006 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1007 `gnus-group-sort-by-rank'.
1009 This variable can also be a list of sorting functions. In that case,
1010 the most significant sort function should be the last function in the
1013 ;; Mark variables suggested by Thomas Michanek
1014 ;; <Thomas.Michanek@telelogic.se>.
1015 (defvar gnus-unread-mark ?
1016 "*Mark used for unread articles.")
1017 (defvar gnus-ticked-mark ?!
1018 "*Mark used for ticked articles.")
1019 (defvar gnus-dormant-mark ??
1020 "*Mark used for dormant articles.")
1021 (defvar gnus-del-mark ?r
1022 "*Mark used for del'd articles.")
1023 (defvar gnus-read-mark ?R
1024 "*Mark used for read articles.")
1025 (defvar gnus-expirable-mark ?E
1026 "*Mark used for expirable articles.")
1027 (defvar gnus-killed-mark ?K
1028 "*Mark used for killed articles.")
1029 (defvar gnus-souped-mark ?F
1030 "*Mark used for killed articles.")
1031 (defvar gnus-kill-file-mark ?X
1032 "*Mark used for articles killed by kill files.")
1033 (defvar gnus-low-score-mark ?Y
1034 "*Mark used for articles with a low score.")
1035 (defvar gnus-catchup-mark ?C
1036 "*Mark used for articles that are caught up.")
1037 (defvar gnus-replied-mark ?A
1038 "*Mark used for articles that have been replied to.")
1039 (defvar gnus-cached-mark ?*
1040 "*Mark used for articles that are in the cache.")
1041 (defvar gnus-saved-mark ?S
1042 "*Mark used for articles that have been saved to.")
1043 (defvar gnus-process-mark ?#
1045 (defvar gnus-ancient-mark ?O
1046 "*Mark used for ancient articles.")
1047 (defvar gnus-sparse-mark ?Q
1048 "*Mark used for sparsely reffed articles.")
1049 (defvar gnus-canceled-mark ?G
1050 "*Mark used for canceled articles.")
1051 (defvar gnus-score-over-mark ?+
1052 "*Score mark used for articles with high scores.")
1053 (defvar gnus-score-below-mark ?-
1054 "*Score mark used for articles with low scores.")
1055 (defvar gnus-empty-thread-mark ?
1056 "*There is no thread under the article.")
1057 (defvar gnus-not-empty-thread-mark ?=
1058 "*There is a thread under the article.")
1060 (defvar gnus-view-pseudo-asynchronously nil
1061 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1063 (defvar gnus-view-pseudos nil
1064 "*If `automatic', pseudo-articles will be viewed automatically.
1065 If `not-confirm', pseudos will be viewed automatically, and the user
1066 will not be asked to confirm the command.")
1068 (defvar gnus-view-pseudos-separately t
1069 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1070 If nil, all files that use the same viewing command will be given as a
1071 list of parameters to that command.")
1073 (defvar gnus-insert-pseudo-articles t
1074 "*If non-nil, insert pseudo-articles when decoding articles.")
1076 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)\n"
1077 "*Format of group lines.
1078 It works along the same lines as a normal formatting string,
1079 with some simple extensions.
1081 %M Only marked articles (character, \"*\" or \" \")
1082 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1083 %L Level of subscribedness (integer)
1084 %N Number of unread articles (integer)
1085 %I Number of dormant articles (integer)
1086 %i Number of ticked and dormant (integer)
1087 %T Number of ticked articles (integer)
1088 %R Number of read articles (integer)
1089 %t Total number of articles (integer)
1090 %y Number of unread, unticked articles (integer)
1091 %G Group name (string)
1092 %g Qualified group name (string)
1093 %D Group description (string)
1094 %s Select method (string)
1095 %o Moderated group (char, \"m\")
1096 %p Process mark (char)
1097 %O Moderated group (string, \"(m)\" or \"\")
1098 %P Topic indentation (string)
1099 %n Select from where (string)
1100 %z A string that look like `<%s:%n>' if a foreign select method is used
1101 %u User defined specifier. The next character in the format string should
1102 be a letter. Gnus will call the function gnus-user-format-function-X,
1103 where X is the letter following %u. The function will be passed the
1104 current header as argument. The function should return a string, which
1105 will be inserted into the buffer just like information from any other
1108 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1109 the mouse point move inside the area. There can only be one such area.
1111 Note that this format specification is not always respected. For
1112 reasons of efficiency, when listing killed groups, this specification
1113 is ignored altogether. If the spec is changed considerably, your
1114 output may end up looking strange when listing both alive and killed
1117 If you use %o or %O, reading the active file will be slower and quite
1118 a bit of extra memory will be used. %D will also worsen performance.
1119 Also note that if you change the format specification to include any
1120 of these specs, you must probably re-start Gnus to see them go into
1123 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1124 "*The format specification of the lines in the summary buffer.
1126 It works along the same lines as a normal formatting string,
1127 with some simple extensions.
1129 %N Article number, left padded with spaces (string)
1131 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1132 %n Name of the poster (string)
1133 %a Extracted name of the poster (string)
1134 %A Extracted address of the poster (string)
1135 %F Contents of the From: header (string)
1136 %x Contents of the Xref: header (string)
1137 %D Date of the article (string)
1138 %d Date of the article (string) in DD-MMM format
1139 %M Message-id of the article (string)
1140 %r References of the article (string)
1141 %c Number of characters in the article (integer)
1142 %L Number of lines in the article (integer)
1143 %I Indentation based on thread level (a string of spaces)
1144 %T A string with two possible values: 80 spaces if the article
1145 is on thread level two or larger and 0 spaces on level one
1146 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1147 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1148 %[ Opening bracket (character, \"[\" or \"<\")
1149 %] Closing bracket (character, \"]\" or \">\")
1150 %> Spaces of length thread-level (string)
1151 %< Spaces of length (- 20 thread-level) (string)
1152 %i Article score (number)
1153 %z Article zcore (character)
1154 %t Number of articles under the current thread (number).
1155 %e Whether the thread is empty or not (character).
1156 %u User defined specifier. The next character in the format string should
1157 be a letter. Gnus will call the function gnus-user-format-function-X,
1158 where X is the letter following %u. The function will be passed the
1159 current header as argument. The function should return a string, which
1160 will be inserted into the summary just like information from any other
1163 Text between %( and %) will be highlighted with `gnus-mouse-face'
1164 when the mouse point is placed inside the area. There can only be one
1167 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1168 with care. For reasons of efficiency, Gnus will compute what column
1169 these characters will end up in, and \"hard-code\" that. This means that
1170 it is illegal to have these specs after a variable-length spec. Well,
1171 you might not be arrested, but your summary buffer will look strange,
1172 which is bad enough.
1174 The smart choice is to have these specs as for to the left as
1177 This restriction may disappear in later versions of Gnus.")
1179 (defvar gnus-summary-dummy-line-format
1181 "*The format specification for the dummy roots in the summary buffer.
1182 It works along the same lines as a normal formatting string,
1183 with some simple extensions.
1187 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1188 "*The format specification for the summary mode line.
1189 It works along the same lines as a normal formatting string,
1190 with some simple extensions:
1193 %p Unprefixed group name
1194 %A Current article number
1196 %U Number of unread articles in the group
1197 %e Number of unselected articles in the group
1198 %Z A string with unread/unselected article counts
1199 %g Shortish group name
1200 %S Subject of the current article
1201 %u User-defined spec
1202 %s Current score file name
1203 %d Number of dormant articles
1204 %r Number of articles that have been marked as read in this session
1205 %E Number of articles expunged by the score files")
1207 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1208 "*The format specification for the article mode line.
1209 See `gnus-summary-mode-line-format' for a closer description.")
1211 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1212 "*The format specification for the group mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1216 %S The native news server.
1217 %M The native select method.")
1219 (defvar gnus-valid-select-methods
1220 '(("nntp" post address prompt-address)
1222 ("nnvirtual" post-mail virtual prompt-address)
1223 ("nnmbox" mail respool)
1224 ("nnml" mail respool)
1225 ("nnmh" mail respool)
1226 ("nndir" post-mail prompt-address address)
1227 ("nneething" none prompt-address)
1228 ("nndoc" none prompt-address)
1229 ("nnbabyl" mail respool)
1230 ("nnkiboze" post virtual)
1231 ("nnsoup" post-mail)
1232 ("nnfolder" mail respool))
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. Its use is
1335 due to the bogus appearance that .newsrc was modified on disc.")
1339 (defvar gnus-group-mode-hook nil
1340 "*A hook for Gnus group mode.")
1342 (defvar gnus-summary-mode-hook nil
1343 "*A hook for Gnus summary mode.
1344 This hook is run before any variables are set in the summary buffer.")
1346 (defvar gnus-article-mode-hook nil
1347 "*A hook for Gnus article mode.")
1349 (defvar gnus-summary-prepare-exit-hook nil
1350 "*A hook called when preparing to exit from the summary buffer.
1351 It calls `gnus-summary-expire-articles' by default.")
1352 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1354 (defvar gnus-summary-exit-hook nil
1355 "*A hook called on exit from the summary buffer.")
1357 (defvar gnus-open-server-hook nil
1358 "*A hook called just before opening connection to the news server.")
1360 (defvar gnus-load-hook nil
1361 "*A hook run while Gnus is loaded.")
1363 (defvar gnus-startup-hook nil
1364 "*A hook called at startup.
1365 This hook is called after Gnus is connected to the NNTP server.")
1367 (defvar gnus-get-new-news-hook nil
1368 "*A hook run just before Gnus checks for new news.")
1370 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1371 "*A function that is called to generate the group buffer.
1372 The function is called with three arguments: The first is a number;
1373 all group with a level less or equal to that number should be listed,
1374 if the second is non-nil, empty groups should also be displayed. If
1375 the third is non-nil, it is a number. No groups with a level lower
1376 than this number should be displayed.
1378 The only current function implemented is `gnus-group-prepare-flat'.")
1380 (defvar gnus-group-prepare-hook nil
1381 "*A hook called after the group buffer has been generated.
1382 If you want to modify the group buffer, you can use this hook.")
1384 (defvar gnus-summary-prepare-hook nil
1385 "*A hook called after the summary buffer has been generated.
1386 If you want to modify the summary buffer, you can use this hook.")
1388 (defvar gnus-summary-generate-hook nil
1389 "*A hook run just before generating the summary buffer.
1390 This hook is commonly used to customize threading variables and the
1393 (defvar gnus-article-prepare-hook nil
1394 "*A hook called after an article has been prepared in the article buffer.
1395 If you want to run a special decoding program like nkf, use this hook.")
1397 ;(defvar gnus-article-display-hook nil
1398 ; "*A hook called after the article is displayed in the article buffer.
1399 ;The hook is designed to change the contents of the article
1400 ;buffer. Typical functions that this hook may contain are
1401 ;`gnus-article-hide-headers' (hide selected headers),
1402 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1403 ;`gnus-article-hide-signature' (hide signature) and
1404 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1405 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1406 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1407 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1409 (defvar gnus-article-x-face-command
1410 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1411 "String or function to be executed to display an X-Face header.
1412 If it is a string, the command will be executed in a sub-shell
1413 asynchronously. The compressed face will be piped to this command.")
1415 (defvar gnus-article-x-face-too-ugly nil
1416 "Regexp matching posters whose face shouldn't be shown automatically.")
1418 (defvar gnus-select-group-hook nil
1419 "*A hook called when a newsgroup is selected.
1421 If you'd like to simplify subjects like the
1422 `gnus-summary-next-same-subject' command does, you can use the
1425 (setq gnus-select-group-hook
1428 (mapcar (lambda (header)
1429 (mail-header-set-subject
1431 (gnus-simplify-subject
1432 (mail-header-subject header) 're-only)))
1433 gnus-newsgroup-headers))))")
1435 (defvar gnus-select-article-hook nil
1436 "*A hook called when an article is selected.")
1438 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1439 "*A hook called to apply kill files to a group.
1440 This hook is intended to apply a kill file to the selected newsgroup.
1441 The function `gnus-apply-kill-file' is called by default.
1443 Since a general kill file is too heavy to use only for a few
1444 newsgroups, I recommend you to use a lighter hook function. For
1445 example, if you'd like to apply a kill file to articles which contains
1446 a string `rmgroup' in subject in newsgroup `control', you can use the
1449 (setq gnus-apply-kill-hook
1452 (cond ((string-match \"control\" gnus-newsgroup-name)
1453 (gnus-kill \"Subject\" \"rmgroup\")
1454 (gnus-expunge \"X\"))))))")
1456 (defvar gnus-visual-mark-article-hook
1457 (list 'gnus-highlight-selected-summary)
1458 "*Hook run after selecting an article in the summary buffer.
1459 It is meant to be used for highlighting the article in some way. It
1460 is not run if `gnus-visual' is nil.")
1462 (defvar gnus-parse-headers-hook nil
1463 "*A hook called before parsing the headers.")
1465 (defvar gnus-exit-group-hook nil
1466 "*A hook called when exiting (not quitting) summary mode.")
1468 (defvar gnus-suspend-gnus-hook nil
1469 "*A hook called when suspending (not exiting) Gnus.")
1471 (defvar gnus-exit-gnus-hook nil
1472 "*A hook called when exiting Gnus.")
1474 (defvar gnus-save-newsrc-hook nil
1475 "*A hook called before saving any of the newsrc files.")
1477 (defvar gnus-save-quick-newsrc-hook nil
1478 "*A hook called just before saving the quick newsrc file.
1479 Can be used to turn version control on or off.")
1481 (defvar gnus-save-standard-newsrc-hook nil
1482 "*A hook called just before saving the standard newsrc file.
1483 Can be used to turn version control on or off.")
1485 (defvar gnus-summary-update-hook
1486 (list 'gnus-summary-highlight-line)
1487 "*A hook called when a summary line is changed.
1488 The hook will not be called if `gnus-visual' is nil.
1490 The default function `gnus-summary-highlight-line' will
1491 highlight the line according to the `gnus-summary-highlight'
1494 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1495 "*A hook called when a group line is changed.
1496 The hook will not be called if `gnus-visual' is nil.
1498 The default function `gnus-group-highlight-line' will
1499 highlight the line according to the `gnus-group-highlight'
1502 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1503 "*A hook called when an article is selected for the first time.
1504 The hook is intended to mark an article as read (or unread)
1505 automatically when it is selected.")
1507 (defvar gnus-group-change-level-function nil
1508 "Function run when a group level is changed.
1509 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1511 ;; Remove any hilit infestation.
1512 (add-hook 'gnus-startup-hook
1514 (remove-hook 'gnus-summary-prepare-hook
1515 'hilit-rehighlight-buffer-quietly)
1516 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1517 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1518 (remove-hook 'gnus-article-prepare-hook
1519 'hilit-rehighlight-buffer-quietly)))
1523 ;; Internal variables
1525 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1527 (defvar gnus-override-subscribe-method nil)
1529 (defvar gnus-group-goto-next-group-function nil
1530 "Function to override finding the next group after listing groups.")
1532 (defconst gnus-article-mark-lists
1533 '((marked . tick) (replied . reply)
1534 (expirable . expire) (killed . killed)
1535 (bookmarks . bookmark) (dormant . dormant)
1536 (scored . score) (saved . save)
1539 ;; Avoid highlighting in kill files.
1540 (defvar gnus-summary-inhibit-highlight nil)
1541 (defvar gnus-newsgroup-selected-overlay nil)
1543 (defvar gnus-inhibit-hiding nil)
1544 (defvar gnus-group-indentation "")
1545 (defvar gnus-inhibit-limiting nil)
1547 (defvar gnus-article-mode-map nil)
1548 (defvar gnus-dribble-buffer nil)
1549 (defvar gnus-headers-retrieved-by nil)
1550 (defvar gnus-article-reply nil)
1551 (defvar gnus-override-method nil)
1552 (defvar gnus-article-check-size nil)
1554 (defvar gnus-nocem-hashtb nil)
1556 (defvar gnus-current-score-file nil)
1557 (defvar gnus-newsgroup-adaptive-score-file nil)
1558 (defvar gnus-scores-exclude-files nil)
1560 (defvar gnus-opened-servers nil)
1562 (defvar gnus-current-move-group nil)
1564 (defvar gnus-newsgroup-dependencies nil)
1565 (defvar gnus-newsgroup-async nil)
1566 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1568 (defvar gnus-newsgroup-adaptive nil)
1570 (defvar gnus-summary-display-table nil)
1571 (defvar gnus-summary-display-article-function nil)
1573 (defvar gnus-summary-highlight-line-function nil
1574 "Function called after highlighting a summary line.")
1576 (defvar gnus-group-line-format-alist
1577 `((?M gnus-tmp-marked-mark ?c)
1578 (?S gnus-tmp-subscribed ?c)
1579 (?L gnus-tmp-level ?d)
1580 (?N gnus-tmp-number ?s)
1581 (?R gnus-tmp-number-of-read ?s)
1582 (?t gnus-tmp-number-total ?s)
1583 (?y gnus-tmp-number-of-unread ?s)
1584 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1585 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1586 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1587 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1588 (?g gnus-tmp-group ?s)
1589 (?G gnus-tmp-qualified-group ?s)
1590 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1591 (?D gnus-tmp-newsgroup-description ?s)
1592 (?o gnus-tmp-moderated ?c)
1593 (?O gnus-tmp-moderated-string ?s)
1594 (?p gnus-tmp-process-marked ?c)
1595 (?s gnus-tmp-news-server ?s)
1596 (?n gnus-tmp-news-method ?s)
1597 (?P gnus-group-indentation ?s)
1598 (?z gnus-tmp-news-method-string ?s)
1599 (?u gnus-tmp-user-defined ?s)))
1601 (defvar gnus-summary-line-format-alist
1602 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1603 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1604 (?s gnus-tmp-subject-or-nil ?s)
1605 (?n gnus-tmp-name ?s)
1606 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1608 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1610 (?F gnus-tmp-from ?s)
1611 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1612 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1613 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1614 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1615 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1616 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1617 (?L gnus-tmp-lines ?d)
1618 (?I gnus-tmp-indentation ?s)
1619 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1620 (?R gnus-tmp-replied ?c)
1621 (?\[ gnus-tmp-opening-bracket ?c)
1622 (?\] gnus-tmp-closing-bracket ?c)
1623 (?\> (make-string gnus-tmp-level ? ) ?s)
1624 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1625 (?i gnus-tmp-score ?d)
1626 (?z gnus-tmp-score-char ?c)
1627 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1628 (?U gnus-tmp-unread ?c)
1629 (?t (gnus-summary-number-of-articles-in-thread
1630 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1632 (?e (gnus-summary-number-of-articles-in-thread
1633 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1635 (?u gnus-tmp-user-defined ?s))
1636 "An alist of format specifications that can appear in summary lines,
1637 and what variables they correspond with, along with the type of the
1638 variable (string, integer, character, etc).")
1640 (defvar gnus-summary-dummy-line-format-alist
1641 (` ((?S gnus-tmp-subject ?s)
1642 (?N gnus-tmp-number ?d)
1643 (?u gnus-tmp-user-defined ?s))))
1645 (defvar gnus-summary-mode-line-format-alist
1646 (` ((?G gnus-tmp-group-name ?s)
1647 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1648 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1649 (?A gnus-tmp-article-number ?d)
1650 (?Z gnus-tmp-unread-and-unselected ?s)
1651 (?V gnus-version ?s)
1652 (?U gnus-tmp-unread ?d)
1653 (?S gnus-tmp-subject ?s)
1654 (?e gnus-tmp-unselected ?d)
1655 (?u gnus-tmp-user-defined ?s)
1656 (?d (length gnus-newsgroup-dormant) ?d)
1657 (?t (length gnus-newsgroup-marked) ?d)
1658 (?r (length gnus-newsgroup-reads) ?d)
1659 (?E gnus-newsgroup-expunged-tally ?d)
1660 (?s (gnus-current-score-file-nondirectory) ?s))))
1662 (defvar gnus-article-mode-line-format-alist
1663 gnus-summary-mode-line-format-alist)
1665 (defvar gnus-group-mode-line-format-alist
1666 (` ((?S gnus-tmp-news-server ?s)
1667 (?M gnus-tmp-news-method ?s)
1668 (?u gnus-tmp-user-defined ?s))))
1670 (defvar gnus-have-read-active-file nil)
1672 (defconst gnus-maintainer
1673 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1674 "The mail address of the Gnus maintainers.")
1676 (defconst gnus-version "September Gnus v0.32"
1677 "Version number for this version of Gnus.")
1679 (defvar gnus-info-nodes
1680 '((gnus-group-mode "(gnus)The Group Buffer")
1681 (gnus-summary-mode "(gnus)The Summary Buffer")
1682 (gnus-article-mode "(gnus)The Article Buffer"))
1683 "Assoc list of major modes and related Info nodes.")
1685 (defvar gnus-group-buffer "*Group*")
1686 (defvar gnus-summary-buffer "*Summary*")
1687 (defvar gnus-article-buffer "*Article*")
1688 (defvar gnus-server-buffer "*Server*")
1690 (defvar gnus-work-buffer " *gnus work*")
1692 (defvar gnus-original-article-buffer " *Original Article*")
1693 (defvar gnus-original-article nil)
1695 (defvar gnus-buffer-list nil
1696 "Gnus buffers that should be killed on exit.")
1698 (defvar gnus-server-alist nil
1699 "List of available servers.")
1701 (defvar gnus-slave nil
1702 "Whether this Gnus is a slave or not.")
1704 (defvar gnus-variable-list
1705 '(gnus-newsrc-options gnus-newsrc-options-n
1706 gnus-newsrc-last-checked-date
1707 gnus-newsrc-alist gnus-server-alist
1708 gnus-killed-list gnus-zombie-list
1709 gnus-topic-topology gnus-topic-alist
1711 "Gnus variables saved in the quick startup file.")
1713 (defvar gnus-newsrc-options nil
1714 "Options line in the .newsrc file.")
1716 (defvar gnus-newsrc-options-n nil
1717 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1719 (defvar gnus-newsrc-last-checked-date nil
1720 "Date Gnus last asked server for new newsgroups.")
1722 (defvar gnus-topic-topology nil
1723 "The complete topic hierarchy.")
1725 (defvar gnus-topic-alist nil
1726 "The complete topic-group alist.")
1728 (defvar gnus-newsrc-alist nil
1729 "Assoc list of read articles.
1730 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1732 (defvar gnus-newsrc-hashtb nil
1733 "Hashtable of gnus-newsrc-alist.")
1735 (defvar gnus-killed-list nil
1736 "List of killed newsgroups.")
1738 (defvar gnus-killed-hashtb nil
1739 "Hash table equivalent of gnus-killed-list.")
1741 (defvar gnus-zombie-list nil
1742 "List of almost dead newsgroups.")
1744 (defvar gnus-description-hashtb nil
1745 "Descriptions of newsgroups.")
1747 (defvar gnus-list-of-killed-groups nil
1748 "List of newsgroups that have recently been killed by the user.")
1750 (defvar gnus-active-hashtb nil
1751 "Hashtable of active articles.")
1753 (defvar gnus-moderated-list nil
1754 "List of moderated newsgroups.")
1756 (defvar gnus-group-marked nil)
1758 (defvar gnus-current-startup-file nil
1759 "Startup file for the current host.")
1761 (defvar gnus-last-search-regexp nil
1762 "Default regexp for article search command.")
1764 (defvar gnus-last-shell-command nil
1765 "Default shell command on article.")
1767 (defvar gnus-current-select-method nil
1768 "The current method for selecting a newsgroup.")
1770 (defvar gnus-group-list-mode nil)
1772 (defvar gnus-article-internal-prepare-hook nil)
1774 (defvar gnus-newsgroup-name nil)
1775 (defvar gnus-newsgroup-begin nil)
1776 (defvar gnus-newsgroup-end nil)
1777 (defvar gnus-newsgroup-last-rmail nil)
1778 (defvar gnus-newsgroup-last-mail nil)
1779 (defvar gnus-newsgroup-last-folder nil)
1780 (defvar gnus-newsgroup-last-file nil)
1781 (defvar gnus-newsgroup-auto-expire nil)
1782 (defvar gnus-newsgroup-active nil)
1784 (defvar gnus-newsgroup-data nil)
1785 (defvar gnus-newsgroup-data-reverse nil)
1786 (defvar gnus-newsgroup-limit nil)
1787 (defvar gnus-newsgroup-limits nil)
1789 (defvar gnus-newsgroup-unreads nil
1790 "List of unread articles in the current newsgroup.")
1792 (defvar gnus-newsgroup-unselected nil
1793 "List of unselected unread articles in the current newsgroup.")
1795 (defvar gnus-newsgroup-reads nil
1796 "Alist of read articles and article marks in the current newsgroup.")
1798 (defvar gnus-newsgroup-expunged-tally nil)
1800 (defvar gnus-newsgroup-marked nil
1801 "List of ticked articles in the current newsgroup (a subset of unread art).")
1803 (defvar gnus-newsgroup-killed nil
1804 "List of ranges of articles that have been through the scoring process.")
1806 (defvar gnus-newsgroup-cached nil
1807 "List of articles that come from the article cache.")
1809 (defvar gnus-newsgroup-saved nil
1810 "List of articles that have been saved.")
1812 (defvar gnus-newsgroup-kill-headers nil)
1814 (defvar gnus-newsgroup-replied nil
1815 "List of articles that have been replied to in the current newsgroup.")
1817 (defvar gnus-newsgroup-expirable nil
1818 "List of articles in the current newsgroup that can be expired.")
1820 (defvar gnus-newsgroup-processable nil
1821 "List of articles in the current newsgroup that can be processed.")
1823 (defvar gnus-newsgroup-bookmarks nil
1824 "List of articles in the current newsgroup that have bookmarks.")
1826 (defvar gnus-newsgroup-dormant nil
1827 "List of dormant articles in the current newsgroup.")
1829 (defvar gnus-newsgroup-scored nil
1830 "List of scored articles in the current newsgroup.")
1832 (defvar gnus-newsgroup-headers nil
1833 "List of article headers in the current newsgroup.")
1835 (defvar gnus-newsgroup-threads nil)
1837 (defvar gnus-newsgroup-prepared nil
1838 "Whether the current group has been prepared properly.")
1840 (defvar gnus-newsgroup-ancient nil
1841 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1843 (defvar gnus-newsgroup-sparse nil)
1845 (defvar gnus-current-article nil)
1846 (defvar gnus-article-current nil)
1847 (defvar gnus-current-headers nil)
1848 (defvar gnus-have-all-headers nil)
1849 (defvar gnus-last-article nil)
1850 (defvar gnus-newsgroup-history nil)
1851 (defvar gnus-current-kill-article nil)
1853 ;; Save window configuration.
1854 (defvar gnus-prev-winconf nil)
1856 (defvar gnus-summary-mark-positions nil)
1857 (defvar gnus-group-mark-positions nil)
1859 (defvar gnus-reffed-article-number nil)
1861 ;;; Let the byte-compiler know that we know about this variable.
1862 (defvar rmail-default-rmail-file)
1864 (defvar gnus-cache-removable-articles nil)
1866 (defvar gnus-dead-summary nil)
1868 (defconst gnus-summary-local-variables
1869 '(gnus-newsgroup-name
1870 gnus-newsgroup-begin gnus-newsgroup-end
1871 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1872 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1873 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1874 gnus-newsgroup-unselected gnus-newsgroup-marked
1875 gnus-newsgroup-reads gnus-newsgroup-saved
1876 gnus-newsgroup-replied gnus-newsgroup-expirable
1877 gnus-newsgroup-processable gnus-newsgroup-killed
1878 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1879 gnus-newsgroup-headers gnus-newsgroup-threads
1880 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1881 gnus-current-article gnus-current-headers gnus-have-all-headers
1882 gnus-last-article gnus-article-internal-prepare-hook
1883 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1884 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1885 gnus-newsgroup-async
1886 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1887 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1888 gnus-newsgroup-history gnus-newsgroup-ancient
1889 gnus-newsgroup-sparse
1890 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1891 gnus-newsgroup-adaptive-score-file
1892 (gnus-newsgroup-expunged-tally . 0)
1893 gnus-cache-removeable-articles gnus-newsgroup-cached
1894 gnus-newsgroup-data gnus-newsgroup-data-reverse
1895 gnus-newsgroup-limit gnus-newsgroup-limits)
1896 "Variables that are buffer-local to the summary buffers.")
1898 (defconst gnus-bug-message
1899 "Sending a bug report to the Gnus Towers.
1900 ========================================
1902 The buffer below is a mail buffer. When you press `C-c C-c', it will
1903 be sent to the Gnus Bug Exterminators.
1905 At the bottom of the buffer you'll see lots of variable settings.
1906 Please do not delete those. They will tell the Bug People what your
1907 environment is, so that it will be easier to locate the bugs.
1909 If you have found a bug that makes Emacs go \"beep\", set
1910 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1911 and include the backtrace in your bug report.
1913 Please describe the bug in annoying, painstaking detail.
1915 Thank you for your help in stamping out bugs.
1918 ;;; End of variables.
1920 ;; Define some autoload functions Gnus might use.
1923 ;; This little mapcar goes through the list below and marks the
1924 ;; symbols in question as autoloaded functions.
1927 (let ((interactive (nth 1 (memq ':interactive package))))
1931 (when (consp function)
1932 (setq keymap (car (memq 'keymap function)))
1933 (setq function (car function)))
1934 (autoload function (car package) nil interactive keymap)))
1935 (if (eq (nth 1 package) ':interactive)
1938 '(("metamail" metamail-buffer)
1939 ("info" Info-goto-node)
1940 ("hexl" hexl-hex-string-to-integer)
1941 ("pp" pp pp-to-string pp-eval-expression)
1942 ("mail-extr" mail-extract-address-components)
1943 ("nnmail" nnmail-split-fancy nnmail-article-group)
1944 ("nnvirtual" nnvirtual-catchup-group)
1945 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1946 timezone-make-sortable-date timezone-make-time-string)
1947 ("sendmail" mail-position-on-field mail-setup)
1948 ("rmailout" rmail-output)
1949 ("rnewspost" news-mail-other-window news-reply-yank-original
1950 news-caesar-buffer-body)
1951 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1953 ("gnus-soup" :interactive t
1954 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1955 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1956 ("nnsoup" nnsoup-pack-replies)
1957 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1958 gnus-Folder-save-name gnus-folder-save-name)
1959 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1960 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1961 gnus-server-make-menu-bar gnus-article-make-menu-bar
1962 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1963 gnus-summary-highlight-line gnus-carpal-setup-buffer
1964 gnus-group-highlight-line
1965 gnus-article-add-button gnus-insert-next-page-button
1966 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1967 ("gnus-vis" :interactive t
1968 gnus-article-push-button gnus-article-press-button
1969 gnus-article-highlight gnus-article-highlight-some
1970 gnus-article-highlight-headers gnus-article-highlight-signature
1971 gnus-article-add-buttons gnus-article-add-buttons-to-head
1972 gnus-article-next-button gnus-article-prev-button)
1973 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1974 gnus-demon-add-disconnection gnus-demon-add-handler
1975 gnus-demon-remove-handler)
1976 ("gnus-demon" :interactive t
1977 gnus-demon-init gnus-demon-cancel)
1978 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1979 gnus-tree-open gnus-tree-close)
1980 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close)
1981 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1982 ("gnus-srvr" gnus-browse-foreign-server)
1983 ("gnus-cite" :interactive t
1984 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1985 gnus-article-hide-citation gnus-article-fill-cited-article)
1986 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
1987 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
1988 gnus-execute gnus-expunge)
1989 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
1990 gnus-cache-possibly-remove-articles gnus-cache-request-article
1991 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
1992 gnus-cache-enter-remove-article gnus-cached-article-p
1993 gnus-cache-open gnus-cache-close)
1994 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
1995 gnus-cache-remove-article)
1996 ("gnus-score" :interactive t
1997 gnus-summary-increase-score gnus-summary-lower-score
1998 gnus-score-flush-cache gnus-score-close
1999 gnus-score-raise-same-subject-and-select
2000 gnus-score-raise-same-subject gnus-score-default
2001 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2002 gnus-score-lower-same-subject gnus-score-lower-thread
2003 gnus-possibly-score-headers)
2005 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2006 gnus-current-score-file-nondirectory gnus-score-adaptive
2007 gnus-score-find-trace gnus-score-file-name)
2008 ("gnus-edit" :interactive t gnus-score-customize)
2009 ("gnus-topic" :interactive t gnus-topic-mode)
2010 ("gnus-topic" gnus-topic-remove-group)
2011 ("gnus-salt" :interactive t gnus-pick-mode)
2012 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2013 ("gnus-uu" :interactive t
2014 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2015 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2016 gnus-uu-mark-by-regexp gnus-uu-mark-all
2017 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2018 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2019 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2020 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2021 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2022 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2023 gnus-uu-decode-binhex-view)
2024 ("gnus-msg" (gnus-summary-send-map keymap)
2025 gnus-mail-yank-original gnus-mail-send-and-exit
2026 gnus-sendmail-setup-mail gnus-article-mail
2027 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2028 ("gnus-msg" :interactive t
2029 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2030 gnus-summary-followup gnus-summary-followup-with-original
2031 gnus-summary-followup-and-reply
2032 gnus-summary-followup-and-reply-with-original
2033 gnus-summary-cancel-article gnus-summary-supersede-article
2034 gnus-post-news gnus-inews-news gnus-cancel-news
2035 gnus-summary-reply gnus-summary-reply-with-original
2036 gnus-summary-mail-forward gnus-summary-mail-other-window
2038 ("gnus-picon" :interactive t gnus-article-display-picons
2039 gnus-group-display-picons)
2040 ("gnus-vm" gnus-vm-mail-setup)
2041 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2042 gnus-summary-save-article-vm gnus-yank-article))))
2046 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2047 ;; If you want the cursor to go somewhere else, set these two
2048 ;; functions in some startup hook to whatever you want.
2049 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2050 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2052 ;;; Various macros and substs.
2054 (defun gnus-header-from (header)
2055 (mail-header-from header))
2057 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2058 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2059 `(let ((GnusStartBufferWindow (selected-window)))
2062 (pop-to-buffer ,buffer)
2064 (select-window GnusStartBufferWindow))))
2066 (defmacro gnus-gethash (string hashtable)
2067 "Get hash value of STRING in HASHTABLE."
2068 `(symbol-value (intern-soft ,string ,hashtable)))
2070 (defmacro gnus-sethash (string value hashtable)
2071 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2072 `(set (intern ,string ,hashtable) ,value))
2074 (defmacro gnus-intern-safe (string hashtable)
2075 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2076 `(let ((symbol (intern ,string ,hashtable)))
2081 (defmacro gnus-group-unread (group)
2082 "Get the currently computed number of unread articles in GROUP."
2083 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2085 (defmacro gnus-group-entry (group)
2086 "Get the newsrc entry for GROUP."
2087 `(gnus-gethash ,group gnus-newsrc-hashtb))
2089 (defmacro gnus-active (group)
2090 "Get active info on GROUP."
2091 `(gnus-gethash ,group gnus-active-hashtb))
2093 (defmacro gnus-set-active (group active)
2094 "Set GROUP's active info."
2095 `(gnus-sethash ,group ,active gnus-active-hashtb))
2097 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2098 ;; function `substring' might cut on a middle of multi-octet
2100 (defun gnus-truncate-string (str width)
2101 (substring str 0 width))
2103 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2104 ;; to limit the length of a string. This function is necessary since
2105 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2106 (defsubst gnus-limit-string (str width)
2107 (if (> (length str) width)
2108 (substring str 0 width)
2111 (defsubst gnus-simplify-subject-re (subject)
2112 "Remove \"Re:\" from subject lines."
2113 (if (string-match "^[Rr][Ee]: *" subject)
2114 (substring subject (match-end 0))
2117 (defsubst gnus-goto-char (point)
2118 (and point (goto-char point)))
2120 (defmacro gnus-buffer-exists-p (buffer)
2122 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2125 (defmacro gnus-kill-buffer (buffer)
2126 `(let ((buf ,buffer))
2127 (if (gnus-buffer-exists-p buf)
2128 (kill-buffer buf))))
2130 (defsubst gnus-point-at-bol ()
2131 "Return point at the beginning of the line."
2138 (defsubst gnus-point-at-eol ()
2139 "Return point at the end of the line."
2146 ;; Delete the current line (and the next N lines.);
2147 (defmacro gnus-delete-line (&optional n)
2148 `(delete-region (progn (beginning-of-line) (point))
2149 (progn (forward-line ,(or n 1)) (point))))
2151 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2152 (defvar gnus-init-inhibit nil)
2153 (defun gnus-read-init-file (&optional inhibit-next)
2154 (if gnus-init-inhibit
2155 (setq gnus-init-inhibit nil)
2156 (setq gnus-init-inhibit inhibit-next)
2158 (or (and (file-exists-p gnus-init-file)
2159 ;; Don't try to load a directory.
2160 (not (file-directory-p gnus-init-file)))
2161 (file-exists-p (concat gnus-init-file ".el"))
2162 (file-exists-p (concat gnus-init-file ".elc")))
2164 (load gnus-init-file nil t)
2166 (error "Error in %s: %s" gnus-init-file var))))))
2168 ;; Info access macros.
2170 (defmacro gnus-info-group (info)
2172 (defmacro gnus-info-rank (info)
2174 (defmacro gnus-info-read (info)
2176 (defmacro gnus-info-marks (info)
2178 (defmacro gnus-info-method (info)
2180 (defmacro gnus-info-params (info)
2183 (defmacro gnus-info-level (info)
2184 `(let ((rank (gnus-info-rank ,info)))
2188 (defmacro gnus-info-score (info)
2189 `(let ((rank (gnus-info-rank ,info)))
2190 (or (and (consp rank) (cdr rank)) 0)))
2192 (defmacro gnus-info-set-group (info group)
2193 `(setcar ,info ,group))
2194 (defmacro gnus-info-set-rank (info rank)
2195 `(setcar (nthcdr 1 ,info) ,rank))
2196 (defmacro gnus-info-set-read (info read)
2197 `(setcar (nthcdr 2 ,info) ,read))
2198 (defmacro gnus-info-set-marks (info marks)
2199 `(setcar (nthcdr 3 ,info) ,marks))
2200 (defmacro gnus-info-set-method (info method)
2201 `(setcar (nthcdr 4 ,info) ,method))
2202 (defmacro gnus-info-set-params (info params)
2203 `(setcar (nthcdr 5 ,info) ,params))
2205 (defmacro gnus-info-set-level (info level)
2206 `(let ((rank (cdr ,info)))
2207 (if (consp (car rank))
2208 (setcar (car rank) ,level)
2209 (setcar rank ,level))))
2210 (defmacro gnus-info-set-score (info score)
2211 `(let ((rank (cdr ,info)))
2212 (if (consp (car rank))
2213 (setcdr (car rank) ,score)
2214 (setcar rank (cons (car rank) ,score)))))
2216 (defmacro gnus-get-info (group)
2217 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2219 (defun gnus-byte-code (func)
2220 "Return a form that can be `eval'ed based on FUNC."
2221 (let ((fval (symbol-function func)))
2222 (if (byte-code-function-p fval)
2223 (let ((flist (append fval nil)))
2224 (setcar flist 'byte-code)
2226 (cons 'progn (cdr (cdr fval))))))
2228 ;;; Load the compatability functions.
2235 ;; Format specs. The chunks below are the machine-generated forms
2236 ;; that are to be evaled as the result of the default format strings.
2237 ;; We write them in here to get them byte-compiled. That way the
2238 ;; default actions will be quite fast, while still retaining the full
2239 ;; flexibility of the user-defined format specs.
2241 ;; First we have lots of dummy defvars to let the compiler know these
2242 ;; are really dynamic variables.
2244 (defvar gnus-tmp-unread)
2245 (defvar gnus-tmp-replied)
2246 (defvar gnus-tmp-score-char)
2247 (defvar gnus-tmp-indentation)
2248 (defvar gnus-tmp-opening-bracket)
2249 (defvar gnus-tmp-lines)
2250 (defvar gnus-tmp-name)
2251 (defvar gnus-tmp-closing-bracket)
2252 (defvar gnus-tmp-subject-or-nil)
2253 (defvar gnus-tmp-subject)
2254 (defvar gnus-tmp-marked)
2255 (defvar gnus-tmp-marked-mark)
2256 (defvar gnus-tmp-subscribed)
2257 (defvar gnus-tmp-process-marked)
2258 (defvar gnus-tmp-number-of-unread)
2259 (defvar gnus-tmp-group-name)
2260 (defvar gnus-tmp-group)
2261 (defvar gnus-tmp-article-number)
2262 (defvar gnus-tmp-unread-and-unselected)
2263 (defvar gnus-tmp-news-method)
2264 (defvar gnus-tmp-news-server)
2265 (defvar gnus-tmp-article-number)
2266 (defvar gnus-mouse-face)
2267 (defvar gnus-mouse-face-prop)
2269 (defun gnus-summary-line-format-spec ()
2270 (insert gnus-tmp-unread gnus-tmp-replied
2271 gnus-tmp-score-char gnus-tmp-indentation)
2276 gnus-tmp-opening-bracket
2277 (format "%4d: %-20s"
2279 (if (> (length gnus-tmp-name) 20)
2280 (substring gnus-tmp-name 0 20)
2282 gnus-tmp-closing-bracket)
2284 gnus-mouse-face-prop gnus-mouse-face)
2285 (insert " " gnus-tmp-subject-or-nil "\n"))
2287 (defvar gnus-summary-line-format-spec
2288 (gnus-byte-code 'gnus-summary-line-format-spec))
2290 (defun gnus-summary-dummy-line-format-spec ()
2297 gnus-mouse-face-prop gnus-mouse-face)
2298 (insert " " gnus-tmp-subject "\n"))
2300 (defvar gnus-summary-dummy-line-format-spec
2301 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2303 (defun gnus-group-line-format-spec ()
2304 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2305 gnus-tmp-process-marked
2306 gnus-group-indentation
2307 (format "%5s: " gnus-tmp-number-of-unread))
2311 (insert gnus-tmp-group "\n")
2313 gnus-mouse-face-prop gnus-mouse-face))
2314 (defvar gnus-group-line-format-spec
2315 (gnus-byte-code 'gnus-group-line-format-spec))
2317 (defvar gnus-format-specs
2318 `((version . ,emacs-version)
2319 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2320 (summary-dummy ,gnus-summary-dummy-line-format
2321 ,gnus-summary-dummy-line-format-spec)
2322 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2324 (defvar gnus-article-mode-line-format-spec nil)
2325 (defvar gnus-summary-mode-line-format-spec nil)
2326 (defvar gnus-group-mode-line-format-spec nil)
2328 ;;; Phew. All that gruft is over, fortunately.
2332 ;;; Gnus Utility Functions
2335 (defun gnus-extract-address-components (from)
2337 ;; First find the address - the thing with the @ in it. This may
2338 ;; not be accurate in mail addresses, but does the trick most of
2339 ;; the time in news messages.
2340 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2341 (setq address (substring from (match-beginning 0) (match-end 0))))
2342 ;; Then we check whether the "name <address>" format is used.
2344 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2345 ;; Linear white space is not required.
2346 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2347 (and (setq name (substring from 0 (match-beginning 0)))
2348 ;; Strip any quotes from the name.
2349 (string-match "\".*\"" name)
2350 (setq name (substring name 1 (1- (match-end 0))))))
2351 ;; If not, then "address (name)" is used.
2353 (and (string-match "(.+)" from)
2354 (setq name (substring from (1+ (match-beginning 0))
2355 (1- (match-end 0)))))
2356 (and (string-match "()" from)
2357 (setq name address))
2358 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2359 ;; XOVER might not support folded From headers.
2360 (and (string-match "(.*" from)
2361 (setq name (substring from (1+ (match-beginning 0))
2363 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2364 (list (or name from) (or address from))))
2366 (defun gnus-fetch-field (field)
2367 "Return the value of the header FIELD of current article."
2370 (let ((case-fold-search t))
2371 (nnheader-narrow-to-headers)
2372 (mail-fetch-field field)))))
2374 (defun gnus-goto-colon ()
2376 (search-forward ":" (gnus-point-at-eol) t))
2379 (defun gnus-update-format (var)
2380 "Update the format specification near point."
2385 ;; Find the end of the current word.
2386 (re-search-forward "[ \t\n]" nil t)
2388 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2389 (match-string 1)))))
2390 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2391 (match-string 1 var))))
2392 (entry (assq type gnus-format-specs))
2395 (setq gnus-format-specs (delq entry gnus-format-specs)))
2397 (intern (format "%s-spec" var))
2398 (gnus-parse-format (setq value (symbol-value (intern var)))
2399 (symbol-value (intern (format "%s-alist" var)))
2400 (not (string-match "mode" var))))
2401 (setq spec (symbol-value (intern (format "%s-spec" var))))
2402 (push (list type value spec) gnus-format-specs)
2404 (pop-to-buffer "*Gnus Format*")
2406 (lisp-interaction-mode)
2407 (insert (pp-to-string spec))))
2410 (defun gnus-update-format-specifications (&optional force)
2411 "Update all (necessary) format specifications."
2412 ;; Make the indentation array.
2413 (gnus-make-thread-indent-array)
2416 (and (assq 'version gnus-format-specs)
2417 (not (equal emacs-version
2418 (cdr (assq 'version gnus-format-specs))))))
2419 (setq gnus-format-specs nil))
2421 (let ((types '(summary summary-dummy group
2422 summary-mode group-mode article-mode))
2423 old-format new-format entry type val)
2425 (setq type (pop types))
2426 (setq new-format (symbol-value
2427 (intern (format "gnus-%s-line-format" type))))
2428 (setq entry (cdr (assq type gnus-format-specs)))
2430 (equal (car entry) new-format))
2431 (set (intern (format "gnus-%s-line-format-spec" type))
2434 (if (not (stringp new-format))
2435 ;; This is a function call or something.
2437 ;; This is a "real" format.
2441 (intern (format "gnus-%s-line-format-alist"
2442 (if (eq type 'article-mode)
2443 'summary-mode type))))
2444 (not (string-match "mode$" (symbol-name type))))))
2445 (set (intern (format "gnus-%s-line-format-spec" type)) val)
2447 (setcar (cdr entry) val)
2448 (push (list type new-format val) gnus-format-specs)))))
2450 (gnus-update-group-mark-positions)
2451 (gnus-update-summary-mark-positions)
2453 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2454 (not gnus-description-hashtb)
2455 gnus-read-active-file)
2456 (gnus-read-all-descriptions-files)))
2458 (defun gnus-update-summary-mark-positions ()
2460 (let ((gnus-replied-mark 129)
2461 (gnus-score-below-mark 130)
2462 (gnus-score-over-mark 130)
2466 (gnus-set-work-buffer)
2467 (gnus-summary-insert-line
2468 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2469 (goto-char (point-min))
2470 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2472 (goto-char (point-min))
2473 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
2474 (- (point) 2))) pos))
2475 (goto-char (point-min))
2476 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
2477 (- (point) 2))) pos))
2478 (setq gnus-summary-mark-positions pos))))
2480 (defun gnus-update-group-mark-positions ()
2482 (let ((gnus-process-mark 128)
2483 (gnus-group-marked '("dummy.group")))
2484 (gnus-set-active "dummy.group" '(0 . 0))
2485 (gnus-set-work-buffer)
2486 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2487 (goto-char (point-min))
2488 (setq gnus-group-mark-positions
2489 (list (cons 'process (and (search-forward "\200" nil t)
2490 (- (point) 2))))))))
2492 (defvar gnus-mouse-face-0 'highlight)
2493 (defvar gnus-mouse-face-1 'highlight)
2494 (defvar gnus-mouse-face-2 'highlight)
2495 (defvar gnus-mouse-face-3 'highlight)
2496 (defvar gnus-mouse-face-4 'highlight)
2498 (defun gnus-mouse-face-function (form type)
2500 (point) (progn ,@form (point))
2501 gnus-mouse-face-prop
2504 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2506 (defvar gnus-face-0 'bold)
2507 (defvar gnus-face-1 'italic)
2508 (defvar gnus-face-2 'bold-italic)
2509 (defvar gnus-face-3 'bold)
2510 (defvar gnus-face-4 'bold)
2512 (defun gnus-face-face-function (form type)
2514 (point) (progn ,@form (point))
2515 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2517 (defun gnus-max-width-function (el max-width)
2518 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2520 `(if (> (length ,el) ,max-width)
2521 (substring ,el 0 ,max-width)
2523 `(let ((val (eval ,el)))
2525 (setq val (int-to-string val)))
2526 (if (> (length val) ,max-width)
2527 (substring val 0 ,max-width)
2530 (defun gnus-parse-format (format spec-alist &optional insert)
2531 ;; This function parses the FORMAT string with the help of the
2532 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2533 ;; string. If the FORMAT string contains the specifiers %( and %)
2534 ;; the text between them will have the mouse-face text property.
2536 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2538 (gnus-parse-complex-format format spec-alist)
2539 ;; This is a simple format.
2540 (gnus-parse-simple-format format spec-alist insert)))
2542 (defun gnus-parse-complex-format (format spec-alist)
2544 (gnus-set-work-buffer)
2546 (goto-char (point-min))
2547 (while (re-search-forward "\"" nil t)
2548 (replace-match "\\\"" nil t))
2549 (goto-char (point-min))
2551 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2552 (let ((number (if (match-beginning 1)
2553 (match-string 1) "0"))
2554 (delim (aref (match-string 2) 0)))
2555 (if (or (= delim ?\() (= delim ?\{))
2556 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2558 (replace-match "\")\""))))
2559 (goto-char (point-max))
2561 (goto-char (point-min))
2562 (let ((form (read (current-buffer))))
2563 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2565 (defun gnus-complex-form-to-spec (form spec-alist)
2570 (gnus-parse-simple-format sform spec-alist t)
2571 (funcall (intern (format "gnus-%s-face-function"
2573 (gnus-complex-form-to-spec
2574 (cdr (cdr sform)) spec-alist)
2578 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2579 ;; This function parses the FORMAT string with the help of the
2580 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2583 spec flist fstring newspec elem beg result dontinsert)
2585 (gnus-set-work-buffer)
2587 (goto-char (point-min))
2588 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2590 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2592 beg (1+ (match-beginning 0)))
2593 ;; First check if there are any specs that look anything like
2594 ;; "%12,12A", ie. with a "max width specification". These have
2595 ;; to be treated specially.
2596 (if (setq beg (match-beginning 1))
2600 (1+ (match-beginning 1)) (match-end 1))))
2602 (setq beg (match-beginning 2)))
2603 ;; Find the specification from `spec-alist'.
2604 (unless (setq elem (cdr (assq spec spec-alist)))
2605 (setq elem '("*" ?s)))
2606 ;; Treat user defined format specifiers specially.
2607 (when (eq (car elem) 'gnus-tmp-user-defined)
2610 (list (intern (concat "gnus-user-format-function-"
2612 'gnus-tmp-header) ?s))
2613 (delete-region (match-beginning 3) (match-end 3)))
2614 (if (not (zerop max-width))
2615 (let ((el (car elem)))
2616 (cond ((= (car (cdr elem)) ?c)
2617 (setq el (list 'char-to-string el)))
2618 ((= (car (cdr elem)) ?d)
2619 (setq el (list 'int-to-string el))))
2620 (setq flist (cons (gnus-max-width-function el max-width)
2624 (setq flist (cons (car elem) flist))
2625 (setq newspec (car (cdr elem))))))
2626 ;; Remove the old specification (and possibly a ",12" string).
2627 (delete-region beg (match-end 2))
2628 ;; Insert the new specification.
2631 (setq fstring (buffer-substring 1 (point-max))))
2632 ;; Do some postprocessing to increase efficiency.
2637 ((string= fstring "")
2639 ;; Not a format string.
2640 ((not (string-match "%" fstring))
2642 ;; A format string with just a single string spec.
2643 ((string= fstring "%s")
2645 ;; A single character.
2646 ((string= fstring "%c")
2649 ((string= fstring "%d")
2652 (list `(princ ,(car flist)))
2653 (list `(int-to-string ,(car flist)))))
2654 ;; Just lots of chars and strings.
2655 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2657 ;; A single string spec at the beginning of the spec.
2658 ((string-match "\\`%[sc][^%]+\\'" fstring)
2659 (list (car flist) (substring fstring 2)))
2660 ;; A single string spec in the middle of the spec.
2661 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2662 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2663 ;; A single string spec in the end of the spec.
2664 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2665 (list (match-string 1 fstring) (car flist)))
2666 ;; A more complex spec.
2668 (list (cons 'format (cons fstring (nreverse flist)))))))
2674 (cons 'insert result)))
2675 (cond ((stringp result)
2678 (cons 'concat result))
2681 (defun gnus-eval-format (format &optional alist props)
2682 "Eval the format variable FORMAT, using ALIST.
2683 If PROPS, insert the result."
2684 (let ((form (gnus-parse-format format alist props)))
2686 (add-text-properties (point) (progn (eval form) (point)) props)
2689 (defun gnus-remove-text-with-property (prop)
2690 "Delete all text in the current buffer with text property PROP."
2692 (goto-char (point-min))
2694 (while (get-text-property (point) prop)
2696 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2698 (defun gnus-set-work-buffer ()
2699 (if (get-buffer gnus-work-buffer)
2701 (set-buffer gnus-work-buffer)
2703 (set-buffer (get-buffer-create gnus-work-buffer))
2704 (kill-all-local-variables)
2705 (buffer-disable-undo (current-buffer))
2706 (gnus-add-current-to-buffer-list)))
2708 ;; Article file names when saving.
2710 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2711 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2712 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2713 Otherwise, it is like ~/News/news/group/num."
2716 (concat (if (gnus-use-long-file-name 'not-save)
2717 (gnus-capitalize-newsgroup newsgroup)
2718 (gnus-newsgroup-directory-form newsgroup))
2719 "/" (int-to-string (mail-header-number headers)))
2720 (or gnus-article-save-directory "~/News"))))
2722 (string-equal (file-name-directory default)
2723 (file-name-directory last-file))
2724 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2726 (or last-file default))))
2728 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2729 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2730 If variable `gnus-use-long-file-name' is non-nil, it is
2731 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2734 (concat (if (gnus-use-long-file-name 'not-save)
2736 (gnus-newsgroup-directory-form newsgroup))
2737 "/" (int-to-string (mail-header-number headers)))
2738 (or gnus-article-save-directory "~/News"))))
2740 (string-equal (file-name-directory default)
2741 (file-name-directory last-file))
2742 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2744 (or last-file default))))
2746 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2747 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2748 If variable `gnus-use-long-file-name' is non-nil, it is
2749 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2752 (if (gnus-use-long-file-name 'not-save)
2753 (gnus-capitalize-newsgroup newsgroup)
2754 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2755 (or gnus-article-save-directory "~/News"))))
2757 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2758 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2759 If variable `gnus-use-long-file-name' is non-nil, it is
2760 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2763 (if (gnus-use-long-file-name 'not-save)
2765 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2766 (or gnus-article-save-directory "~/News"))))
2768 ;; For subscribing new newsgroup
2770 (defun gnus-subscribe-hierarchical-interactive (groups)
2771 (let ((groups (sort groups 'string<))
2772 prefixes prefix start ans group starts)
2774 (setq prefixes (list "^"))
2775 (while (and groups prefixes)
2776 (while (not (string-match (car prefixes) (car groups)))
2777 (setq prefixes (cdr prefixes)))
2778 (setq prefix (car prefixes))
2779 (setq start (1- (length prefix)))
2780 (if (and (string-match "[^\\.]\\." (car groups) start)
2783 (concat "^" (substring (car groups) 0 (match-end 0))))
2784 (string-match prefix (car (cdr groups))))
2786 (setq prefixes (cons prefix prefixes))
2787 (message "Descend hierarchy %s? ([y]nsq): "
2788 (substring prefix 1 (1- (length prefix))))
2789 (setq ans (read-char))
2792 (string-match prefix
2793 (setq group (car groups))))
2794 (setq gnus-killed-list
2795 (cons group gnus-killed-list))
2796 (gnus-sethash group group gnus-killed-hashtb)
2797 (setq groups (cdr groups)))
2798 (setq starts (cdr starts)))
2801 (string-match prefix
2802 (setq group (car groups))))
2803 (gnus-sethash group group gnus-killed-hashtb)
2804 (gnus-subscribe-alphabetically (car groups))
2805 (setq groups (cdr groups)))
2806 (setq starts (cdr starts)))
2809 (setq group (car groups))
2810 (setq gnus-killed-list (cons group gnus-killed-list))
2811 (gnus-sethash group group gnus-killed-hashtb)
2812 (setq groups (cdr groups))))
2814 (message "Subscribe %s? ([n]yq)" (car groups))
2815 (setq ans (read-char))
2816 (setq group (car groups))
2818 (gnus-subscribe-alphabetically (car groups))
2819 (gnus-sethash group group gnus-killed-hashtb))
2822 (setq group (car groups))
2823 (setq gnus-killed-list (cons group gnus-killed-list))
2824 (gnus-sethash group group gnus-killed-hashtb)
2825 (setq groups (cdr groups))))
2827 (setq gnus-killed-list (cons group gnus-killed-list))
2828 (gnus-sethash group group gnus-killed-hashtb)))
2829 (setq groups (cdr groups)))))))
2831 (defun gnus-subscribe-randomly (newsgroup)
2832 "Subscribe new NEWSGROUP by making it the first newsgroup."
2833 (gnus-subscribe-newsgroup newsgroup))
2835 (defun gnus-subscribe-alphabetically (newgroup)
2836 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2837 (let ((groups (cdr gnus-newsrc-alist))
2839 (while (and (not before) groups)
2840 (if (string< newgroup (car (car groups)))
2841 (setq before (car (car groups)))
2842 (setq groups (cdr groups))))
2843 (gnus-subscribe-newsgroup newgroup before)))
2845 (defun gnus-subscribe-hierarchically (newgroup)
2846 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2847 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2849 (set-buffer (find-file-noselect gnus-current-startup-file))
2850 (let ((groupkey newgroup)
2852 (while (and (not before) groupkey)
2853 (goto-char (point-min))
2855 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2856 (while (and (re-search-forward groupkey-re nil t)
2858 (setq before (match-string 1))
2859 (string< before newgroup)))))
2860 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2862 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2863 (substring groupkey (match-beginning 1) (match-end 1)))))
2864 (gnus-subscribe-newsgroup newgroup before))))
2866 (defun gnus-subscribe-interactively (group)
2867 "Subscribe the new GROUP interactively.
2868 It is inserted in hierarchical newsgroup order if subscribed. If not,
2870 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2871 (gnus-subscribe-hierarchically group)
2872 (push group gnus-killed-list)))
2874 (defun gnus-subscribe-zombies (group)
2875 "Make the new GROUP into a zombie group."
2876 (push group gnus-zombie-list))
2878 (defun gnus-subscribe-killed (group)
2879 "Make the new GROUP a killed group."
2880 (push group gnus-killed-list))
2882 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2883 "Subscribe new NEWSGROUP.
2884 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2885 the first newsgroup."
2886 ;; We subscribe the group by changing its level to `subscribed'.
2887 (gnus-group-change-level
2888 newsgroup gnus-level-default-subscribed
2889 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2890 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2894 (defun gnus-newsgroup-directory-form (newsgroup)
2895 "Make hierarchical directory name from NEWSGROUP name."
2896 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2897 (len (length newsgroup))
2899 ;; If this is a foreign group, we don't want to translate the
2901 (if (setq idx (string-match ":" newsgroup))
2902 (aset newsgroup idx ?/)
2904 ;; Replace all occurrences of `.' with `/'.
2906 (if (= (aref newsgroup idx) ?.)
2907 (aset newsgroup idx ?/))
2908 (setq idx (1+ idx)))
2911 (defun gnus-newsgroup-savable-name (group)
2912 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2914 (nnheader-replace-chars-in-string group ?/ ?.))
2916 (defun gnus-make-directory (dir)
2917 "Make DIRECTORY recursively."
2918 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2919 ;; of the many mysteries of the universe.
2920 (let* ((dir (expand-file-name dir default-directory))
2922 (if (string-match "/$" dir)
2923 (setq dir (substring dir 0 (match-beginning 0))))
2924 ;; First go down the path until we find a directory that exists.
2925 (while (not (file-exists-p dir))
2926 (setq dirs (cons dir dirs))
2927 (string-match "/[^/]+$" dir)
2928 (setq dir (substring dir 0 (match-beginning 0))))
2929 ;; Then create all the subdirs.
2930 (while (and dirs (not err))
2932 (make-directory (car dirs))
2933 (error (setq err t)))
2934 (setq dirs (cdr dirs)))
2935 ;; We return whether we were successful or not.
2938 (defun gnus-capitalize-newsgroup (newsgroup)
2939 "Capitalize NEWSGROUP name."
2940 (and (not (zerop (length newsgroup)))
2941 (concat (char-to-string (upcase (aref newsgroup 0)))
2942 (substring newsgroup 1))))
2944 ;; Various... things.
2946 (defun gnus-simplify-subject (subject &optional re-only)
2947 "Remove `Re:' and words in parentheses.
2948 If RE-ONLY is non-nil, strip leading `Re:'s only."
2949 (let ((case-fold-search t)) ;Ignore case.
2950 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
2951 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
2952 (setq subject (substring subject (match-end 0))))
2953 ;; Remove uninteresting prefixes.
2954 (if (and (not re-only)
2955 gnus-simplify-ignored-prefixes
2956 (string-match gnus-simplify-ignored-prefixes subject))
2957 (setq subject (substring subject (match-end 0))))
2958 ;; Remove words in parentheses from end.
2960 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2961 (setq subject (substring subject 0 (match-beginning 0)))))
2962 ;; Return subject string.
2965 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2967 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2968 (defun gnus-simplify-buffer-fuzzy ()
2969 (goto-char (point-min))
2970 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
2971 (goto-char (match-beginning 0))
2973 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
2974 (looking-at "^[[].*:[ \t].*[]]$"))
2975 (goto-char (point-min))
2976 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2978 (replace-match "" t t))
2979 (goto-char (point-min))
2980 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
2981 (goto-char (match-end 0))
2984 (progn (goto-char (match-beginning 0)))
2985 (re-search-forward ":"))))
2986 (goto-char (point-min))
2987 (while (re-search-forward "[ \t\n]*([^()]*)[ \t]*$" nil t)
2988 (replace-match "" t t))
2989 (goto-char (point-min))
2990 (while (re-search-forward "[ \t]+" nil t)
2991 (replace-match " " t t))
2992 (goto-char (point-min))
2993 (while (re-search-forward "[ \t]+$" nil t)
2994 (replace-match "" t t))
2995 (goto-char (point-min))
2996 (while (re-search-forward "^[ \t]+" nil t)
2997 (replace-match "" t t))
2998 (goto-char (point-min))
2999 (if gnus-simplify-subject-fuzzy-regexp
3000 (if (listp gnus-simplify-subject-fuzzy-regexp)
3001 (let ((list gnus-simplify-subject-fuzzy-regexp))
3003 (goto-char (point-min))
3004 (while (re-search-forward (car list) nil t)
3005 (replace-match "" t t))
3006 (setq list (cdr list))))
3007 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3008 (replace-match "" t t)))))
3010 (defun gnus-simplify-subject-fuzzy (subject)
3011 "Siplify a subject string fuzzily."
3012 (let ((case-fold-search t))
3014 (gnus-set-work-buffer)
3016 (inline (gnus-simplify-buffer-fuzzy))
3019 ;; Add the current buffer to the list of buffers to be killed on exit.
3020 (defun gnus-add-current-to-buffer-list ()
3021 (or (memq (current-buffer) gnus-buffer-list)
3022 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3024 (defun gnus-string> (s1 s2)
3025 (not (or (string< s1 s2)
3028 ;;; General various misc type functions.
3030 (defun gnus-clear-system ()
3031 "Clear all variables and buffers."
3032 ;; Clear Gnus variables.
3033 (let ((variables gnus-variable-list))
3035 (set (car variables) nil)
3036 (setq variables (cdr variables))))
3037 ;; Clear other internal variables.
3038 (setq gnus-list-of-killed-groups nil
3039 gnus-have-read-active-file nil
3040 gnus-newsrc-alist nil
3041 gnus-newsrc-hashtb nil
3042 gnus-killed-list nil
3043 gnus-zombie-list nil
3044 gnus-killed-hashtb nil
3045 gnus-active-hashtb nil
3046 gnus-moderated-list nil
3047 gnus-description-hashtb nil
3048 gnus-newsgroup-headers nil
3049 gnus-newsgroup-name nil
3050 gnus-server-alist nil
3051 gnus-opened-servers nil
3052 gnus-current-select-method nil)
3053 ;; Reset any score variables.
3054 (and gnus-use-scoring (gnus-score-close))
3055 ;; Kill the startup file.
3056 (and gnus-current-startup-file
3057 (get-file-buffer gnus-current-startup-file)
3058 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3059 ;; Save any cache buffers.
3060 (and gnus-use-cache (gnus-cache-save-buffers))
3061 ;; Clear the dribble buffer.
3062 (gnus-dribble-clear)
3063 ;; Close down NoCeM.
3064 (and gnus-use-nocem (gnus-nocem-close))
3065 ;; Shut down the demons.
3066 (and gnus-use-demon (gnus-demon-cancel))
3067 ;; Kill global KILL file buffer.
3068 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
3069 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3070 (gnus-kill-buffer nntp-server-buffer)
3072 (and gnus-keep-backlog (gnus-backlog-shutdown))
3073 ;; Kill Gnus buffers.
3074 (while gnus-buffer-list
3075 (gnus-kill-buffer (car gnus-buffer-list))
3076 (setq gnus-buffer-list (cdr gnus-buffer-list))))
3078 (defun gnus-windows-old-to-new (setting)
3079 ;; First we take care of the really, really old Gnus 3 actions.
3080 (if (symbolp setting)
3082 (cond ((memq setting '(SelectArticle))
3084 ((memq setting '(SelectSubject ExpandSubject))
3086 ((memq setting '(SelectNewsgroup ExitNewsgroup))
3089 (if (or (listp setting)
3090 (not (and gnus-window-configuration
3091 (memq setting '(group summary article)))))
3093 (let* ((setting (if (eq setting 'group)
3094 (if (assq 'newsgroup gnus-window-configuration)
3096 'newsgroups) setting))
3097 (elem (car (cdr (assq setting gnus-window-configuration))))
3098 (total (apply '+ elem))
3099 (types '(group summary article))
3100 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3105 (or (not (numberp (nth i elem)))
3106 (zerop (nth i elem))
3108 (setq perc (/ (float (nth 0 elem)) total))
3109 (setq out (cons (if (eq pbuf (nth i types))
3110 (vector (nth i types) perc 'point)
3111 (vector (nth i types) perc))
3114 (list (nreverse out)))))
3116 (defun gnus-add-configuration (conf)
3117 "Add the window configuration CONF to `gnus-buffer-configuration'."
3118 (setq gnus-buffer-configuration
3119 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3120 gnus-buffer-configuration))))
3122 (defvar gnus-frame-list nil)
3124 (defun gnus-configure-frame (split &optional window)
3125 "Split WINDOW according to SPLIT."
3127 (setq window (get-buffer-window (current-buffer))))
3128 (select-window window)
3129 ;; This might be an old-stylee buffer config.
3130 (when (vectorp split)
3131 (setq split (append split nil)))
3132 (when (or (consp (car split))
3133 (vectorp (car split)))
3135 (push 'vertical split))
3136 ;; The SPLIT might be something that is to be evaled to
3137 ;; return a new SPLIT.
3138 (while (and (not (assq (car split) gnus-window-to-buffer))
3139 (gnus-functionp (car split)))
3140 (setq split (eval split)))
3141 (let* ((type (car split))
3143 (len (if (eq type 'horizontal) (window-width) (window-height)))
3145 (window-min-width (or gnus-window-min-width window-min-width))
3146 (window-min-height (or gnus-window-min-height window-min-height))
3147 s result new-win rest comp-subs size sub)
3149 ;; Nothing to do here.
3151 ;; Don't switch buffers.
3153 (and (memq 'point split) window))
3154 ;; This is a buffer to be selected.
3155 ((not (memq type '(frame horizontal vertical)))
3156 (let ((buffer (cond ((stringp type) type)
3157 (t (cdr (assq type gnus-window-to-buffer)))))
3160 (error "Illegal buffer type: %s" type))
3161 (unless (setq buf (get-buffer (if (symbolp buffer)
3162 (symbol-value buffer) buffer)))
3163 (setq buf (get-buffer-create (if (symbolp buffer)
3164 (symbol-value buffer) buffer))))
3165 (switch-to-buffer buf)
3166 ;; We return the window if it has the `point' spec.
3167 (and (memq 'point split) window)))
3168 ;; This is a frame split.
3170 (unless gnus-frame-list
3171 (setq gnus-frame-list (list (window-frame
3172 (get-buffer-window (current-buffer))))))
3174 params frame fresult)
3175 (while (< i (length subs))
3176 ;; Frame parameter is gotten from the sub-split.
3177 (setq params (cadr (elt subs i)))
3178 ;; It should be a list.
3179 (unless (listp params)
3181 ;; Create a new frame?
3182 (unless (setq frame (elt gnus-frame-list i))
3183 (nconc gnus-frame-list (list (setq frame (make-frame params)))))
3184 ;; Is the old frame still alive?
3185 (unless (frame-live-p frame)
3186 (setcar (nthcdr i gnus-frame-list)
3187 (setq frame (make-frame params))))
3188 ;; Select the frame in question and do more splits there.
3189 (select-frame frame)
3190 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3192 ;; Select the frame that has the selected buffer.
3194 (select-frame (window-frame fresult)))))
3195 ;; This is a normal split.
3197 (when (> (length subs) 0)
3198 ;; First we have to compute the sizes of all new windows.
3200 (setq sub (append (pop subs) nil))
3201 (while (and (not (assq (car sub) gnus-window-to-buffer))
3202 (gnus-functionp (car sub)))
3203 (setq sub (eval sub)))
3205 (push sub comp-subs)
3206 (setq size (cadar comp-subs))
3207 (cond ((equal size 1.0)
3208 (setq rest (car comp-subs))
3211 (setq s (floor (* size len))))
3215 (error "Illegal size: %s" size)))
3216 ;; Try to make sure that we are inside the safe limits.
3218 ((eq type 'horizontal)
3219 (setq s (max s window-min-width)))
3220 ((eq type 'vertical)
3221 (setq s (max s window-min-height))))
3222 (setcar (cdar comp-subs) s)
3224 ;; Take care of the "1.0" spec.
3226 (setcar (cdr rest) (- len total))
3227 (error "No 1.0 specs in %s" split))
3228 ;; The we do the actual splitting in a nice recursive
3230 (setq comp-subs (nreverse comp-subs))
3232 (if (null (cdr comp-subs))
3233 (setq new-win window)
3235 (split-window window (cadar comp-subs)
3236 (eq type 'horizontal))))
3237 (setq result (or (gnus-configure-frame
3238 (car comp-subs) window) result))
3239 (select-window new-win)
3240 (setq window new-win)
3241 (setq comp-subs (cdr comp-subs))))
3242 ;; Return the proper window, if any.
3244 (select-window result))))))
3246 (defun gnus-configure-windows (setting &optional force)
3247 (setq setting (gnus-windows-old-to-new setting))
3248 (let ((split (if (symbolp setting)
3249 (car (cdr (assq setting gnus-buffer-configuration)))
3251 (in-buf (current-buffer))
3252 rule val w height hor ohor heights sub jump-buffer
3253 rel total to-buf all-visible)
3256 (error "No such setting: %s" setting))
3258 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p split)))
3259 ;; All the windows mentioned are already visible, so we just
3260 ;; put point in the assigned buffer, and do not touch the
3262 (select-window all-visible)
3264 ;; Either remove all windows or just remove all Gnus windows.
3265 (if gnus-use-full-window
3266 (delete-other-windows)
3267 (gnus-remove-some-windows)
3268 (switch-to-buffer nntp-server-buffer))
3270 (switch-to-buffer nntp-server-buffer)
3271 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3273 (defun gnus-all-windows-visible-p (split)
3274 (when (vectorp split)
3275 (setq split (append split nil)))
3276 (when (or (consp (car split))
3277 (vectorp (car split)))
3279 (push 'vertical split))
3280 ;; The SPLIT might be something that is to be evaled to
3281 ;; return a new SPLIT.
3282 (while (and (not (assq (car split) gnus-window-to-buffer))
3283 (gnus-functionp (car split)))
3284 (setq split (eval split)))
3285 (let* ((type (elt split 0)))
3289 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3290 (let ((buffer (cond ((stringp type) type)
3291 (t (cdr (assq type gnus-window-to-buffer)))))
3294 (error "Illegal buffer type: %s" type))
3295 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3297 (setq win (get-buffer-window buf t)))
3299 (if (memq 'point split)
3303 (let ((n (mapcar 'gnus-all-windows-visible-p
3307 (cond ((windowp (car n))
3314 (defun gnus-window-top-edge (&optional window)
3315 (nth 1 (window-edges window)))
3317 (defun gnus-remove-some-windows ()
3318 (let ((buffers gnus-window-to-buffer)
3319 buf bufs lowest-buf lowest)
3321 ;; Remove windows on all known Gnus buffers.
3323 (setq buf (cdr (car buffers)))
3325 (setq buf (and (boundp buf) (symbol-value buf))))
3327 (get-buffer-window buf)
3329 (setq bufs (cons buf bufs))
3331 (if (or (not lowest)
3332 (< (gnus-window-top-edge) lowest))
3334 (setq lowest (gnus-window-top-edge))
3335 (setq lowest-buf buf)))))
3336 (setq buffers (cdr buffers)))
3337 ;; Remove windows on *all* summary buffers.
3341 (let ((buf (window-buffer win)))
3342 (if (string-match "^\\*Summary" (buffer-name buf))
3344 (setq bufs (cons buf bufs))
3346 (if (or (not lowest)
3347 (< (gnus-window-top-edge) lowest))
3349 (setq lowest-buf buf)
3350 (setq lowest (gnus-window-top-edge))))))))))
3353 (pop-to-buffer lowest-buf)
3354 (switch-to-buffer nntp-server-buffer)))
3356 (and (not (eq (car bufs) lowest-buf))
3357 (delete-windows-on (car bufs)))
3358 (setq bufs (cdr bufs))))))
3360 (defun gnus-version ()
3361 "Version numbers of this version of Gnus."
3363 (let ((methods gnus-valid-select-methods)
3366 ;; Go through all the legal select methods and add their version
3367 ;; numbers to the total version string. Only the backends that are
3368 ;; currently in use will have their message numbers taken into
3371 (setq meth (intern (concat (car (car methods)) "-version")))
3373 (stringp (symbol-value meth))
3374 (setq mess (concat mess "; " (symbol-value meth))))
3375 (setq methods (cdr methods)))
3376 (gnus-message 2 mess)))
3378 (defun gnus-info-find-node ()
3379 "Find Info documentation of Gnus."
3381 ;; Enlarge info window if needed.
3382 (let ((mode major-mode)
3384 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))
3385 (setq gnus-info-buffer (current-buffer))
3386 (gnus-configure-windows 'info)))
3388 (defun gnus-days-between (date1 date2)
3389 ;; Return the number of days between date1 and date2.
3390 (- (gnus-day-number date1) (gnus-day-number date2)))
3392 (defun gnus-day-number (date)
3393 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3394 (timezone-parse-date date))))
3395 (timezone-absolute-from-gregorian
3396 (nth 1 dat) (nth 2 dat) (car dat))))
3398 (defun gnus-encode-date (date)
3399 "Convert DATE to internal time."
3400 (let* ((parse (timezone-parse-date date))
3401 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3402 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3403 (encode-time (caddr time) (cadr time) (car time)
3404 (caddr date) (cadr date) (car date) (nth 4 date))))
3406 (defun gnus-time-minus (t1 t2)
3407 "Subtract two internal times."
3408 (let ((borrow (< (cadr t1) (cadr t2))))
3409 (list (- (car t1) (car t2) (if borrow 1 0))
3410 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3412 (defun gnus-file-newer-than (file date)
3413 (let ((fdate (nth 5 (file-attributes file))))
3414 (or (> (car fdate) (car date))
3415 (and (= (car fdate) (car date))
3416 (> (nth 1 fdate) (nth 1 date))))))
3418 (defmacro gnus-define-keys (keymap &rest plist)
3419 "Define all keys in PLIST in KEYMAP."
3420 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3422 (defun gnus-define-keys-1 (keymap plist)
3424 (error "Can't set keys in a null keymap"))
3425 (cond ((symbolp keymap)
3426 (setq keymap (symbol-value keymap)))
3428 (set (car keymap) nil)
3429 (define-prefix-command (car keymap))
3430 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3431 (setq keymap (symbol-value (car keymap)))))
3434 (when (symbolp (setq key (pop plist)))
3435 (setq key (symbol-value key)))
3436 (define-key keymap key (pop plist)))))
3438 (defun gnus-group-read-only-p (&optional group)
3439 "Check whether GROUP supports editing or not.
3440 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3441 that that variable is buffer-local to the summary buffers."
3442 (let ((group (or group gnus-newsgroup-name)))
3443 (not (gnus-check-backend-function 'request-replace-article group))))
3445 (defun gnus-group-total-expirable-p (group)
3446 "Check whether GROUP is total-expirable or not."
3447 (let ((params (gnus-info-params (gnus-get-info group))))
3448 (or (memq 'total-expire params)
3449 (cdr (assq 'total-expire params)) ; (total-expire . t)
3450 (and gnus-total-expirable-newsgroups ; Check var.
3451 (string-match gnus-total-expirable-newsgroups group)))))
3453 (defun gnus-group-auto-expirable-p (group)
3454 "Check whether GROUP is total-expirable or not."
3455 (let ((params (gnus-info-params (gnus-get-info group))))
3456 (or (memq 'auto-expire params)
3457 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3458 (and gnus-auto-expirable-newsgroups ; Check var.
3459 (string-match gnus-auto-expirable-newsgroups group)))))
3461 (defun gnus-virtual-group-p (group)
3462 "Say whether GROUP is virtual or not."
3463 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3464 gnus-valid-select-methods)))
3466 (defsubst gnus-simplify-subject-fully (subject)
3467 "Simplify a subject string according to the user's wishes."
3469 ((null gnus-summary-gather-subject-limit)
3470 (gnus-simplify-subject-re subject))
3471 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3472 (gnus-simplify-subject-fuzzy subject))
3473 ((numberp gnus-summary-gather-subject-limit)
3474 (gnus-limit-string (gnus-simplify-subject-re subject)
3475 gnus-summary-gather-subject-limit))
3479 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3480 "Check whether two subjects are equal. If optional argument
3481 simple-first is t, first argument is already simplified."
3483 ((null simple-first)
3484 (equal (gnus-simplify-subject-fully s1)
3485 (gnus-simplify-subject-fully s2)))
3488 (gnus-simplify-subject-fully s2)))))
3490 ;; Returns a list of writable groups.
3491 (defun gnus-writable-groups ()
3492 (let ((alist gnus-newsrc-alist)
3495 (or (gnus-group-read-only-p (car (car alist)))
3496 (setq groups (cons (car (car alist)) groups)))
3497 (setq alist (cdr alist)))
3500 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3502 (defun gnus-y-or-n-p (prompt)
3507 (defun gnus-yes-or-no-p (prompt)
3509 (yes-or-no-p prompt)
3512 ;; Check whether to use long file names.
3513 (defun gnus-use-long-file-name (symbol)
3514 ;; The variable has to be set...
3515 (and gnus-use-long-file-name
3516 ;; If it isn't a list, then we return t.
3517 (or (not (listp gnus-use-long-file-name))
3518 ;; If it is a list, and the list contains `symbol', we
3520 (not (memq symbol gnus-use-long-file-name)))))
3522 ;; I suspect there's a better way, but I haven't taken the time to do
3523 ;; it yet. -erik selberg@cs.washington.edu
3524 (defun gnus-dd-mmm (messy-date)
3525 "Return a string like DD-MMM from a big messy string"
3526 (let ((datevec (timezone-parse-date messy-date)))
3528 (or (aref datevec 2) "??")
3531 (nth (1- (string-to-number (aref datevec 1)))
3532 timezone-months-assoc))
3535 ;; Make a hash table (default and minimum size is 255).
3536 ;; Optional argument HASHSIZE specifies the table size.
3537 (defun gnus-make-hashtable (&optional hashsize)
3538 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3540 ;; Make a number that is suitable for hashing; bigger than MIN and one
3542 (defun gnus-create-hash-size (min)
3548 ;; Show message if message has a lower level than `gnus-verbose'.
3549 ;; Guideline for numbers:
3550 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3551 ;; for things that take a long time, 7 - not very important messages
3552 ;; on stuff, 9 - messages inside loops.
3553 (defun gnus-message (level &rest args)
3554 (if (<= level gnus-verbose)
3555 (apply 'message args)
3556 ;; We have to do this format thingy here even if the result isn't
3557 ;; shown - the return value has to be the same as the return value
3559 (apply 'format args)))
3561 (defun gnus-functionp (form)
3562 "Return non-nil if FORM is funcallable."
3563 (or (and (symbolp form) (fboundp form))
3564 (and (listp form) (eq (car form) 'lambda))))
3566 ;; Generate a unique new group name.
3567 (defun gnus-generate-new-group-name (leaf)
3570 (while (gnus-gethash name gnus-newsrc-hashtb)
3571 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3574 ;; Find out whether the gnus-visual TYPE is wanted.
3575 (defun gnus-visual-p (&optional type class)
3576 (and gnus-visual ; Has to be non-nil, at least.
3577 (if (not type) ; We don't care about type.
3579 (if (listp gnus-visual) ; It's a list, so we check it.
3580 (or (memq type gnus-visual)
3581 (memq class gnus-visual))
3584 (defun gnus-parent-id (references)
3585 "Return the last Message-ID in REFERENCES."
3586 (when (and references
3587 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3588 (substring references (match-beginning 1) (match-end 1))))
3590 (defun gnus-split-references (references)
3591 "Return a list of Message-IDs in REFERENCES."
3594 (while (string-match "<[^>]+>" references beg)
3595 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3599 (defun gnus-ephemeral-group-p (group)
3600 "Say whether GROUP is ephemeral or not."
3601 (assoc 'quit-config (gnus-find-method-for-group group)))
3603 (defun gnus-group-quit-config (group)
3604 "Return the quit-config of GROUP."
3605 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
3607 (defun gnus-simplify-mode-line ()
3608 "Make mode lines a bit simpler."
3609 (setq mode-line-modified "-- ")
3610 (when (listp mode-line-format)
3611 (make-local-variable 'mode-line-format)
3612 (setq mode-line-format (copy-sequence mode-line-format))
3613 (when (equal (nth 3 mode-line-format) " ")
3614 (setcar (nthcdr 3 mode-line-format) " "))))
3616 ;;; List and range functions
3618 (defun gnus-last-element (list)
3619 "Return last element of LIST."
3621 (setq list (cdr list)))
3624 (defun gnus-copy-sequence (list)
3625 "Do a complete, total copy of a list."
3626 (if (and (consp list) (not (consp (cdr list))))
3627 (cons (car list) (cdr list))
3628 (mapcar (lambda (elem) (if (consp elem)
3629 (if (consp (cdr elem))
3630 (gnus-copy-sequence elem)
3631 (cons (car elem) (cdr elem)))
3635 (defun gnus-set-difference (list1 list2)
3636 "Return a list of elements of LIST1 that do not appear in LIST2."
3637 (let ((list1 (copy-sequence list1)))
3639 (setq list1 (delq (car list2) list1))
3640 (setq list2 (cdr list2)))
3643 (defun gnus-sorted-complement (list1 list2)
3644 "Return a list of elements of LIST1 that do not appear in LIST2.
3645 Both lists have to be sorted over <."
3647 (if (or (null list1) (null list2))
3649 (while (and list1 list2)
3650 (cond ((= (car list1) (car list2))
3651 (setq list1 (cdr list1)
3653 ((< (car list1) (car list2))
3654 (setq out (cons (car list1) out))
3655 (setq list1 (cdr list1)))
3657 (setq out (cons (car list2) out))
3658 (setq list2 (cdr list2)))))
3659 (nconc (nreverse out) (or list1 list2)))))
3661 (defun gnus-intersection (list1 list2)
3664 (if (memq (car list2) list1)
3665 (setq result (cons (car list2) result)))
3666 (setq list2 (cdr list2)))
3669 (defun gnus-sorted-intersection (list1 list2)
3670 ;; LIST1 and LIST2 have to be sorted over <.
3672 (while (and list1 list2)
3673 (cond ((= (car list1) (car list2))
3674 (setq out (cons (car list1) out)
3677 ((< (car list1) (car list2))
3678 (setq list1 (cdr list1)))
3680 (setq list2 (cdr list2)))))
3683 (defun gnus-set-sorted-intersection (list1 list2)
3684 ;; LIST1 and LIST2 have to be sorted over <.
3685 ;; This function modifies LIST1.
3686 (let* ((top (cons nil list1))
3688 (while (and list1 list2)
3689 (cond ((= (car list1) (car list2))
3693 ((< (car list1) (car list2))
3694 (setcdr prev (cdr list1))
3695 (setq list1 (cdr list1)))
3697 (setq list2 (cdr list2)))))
3701 (defun gnus-compress-sequence (numbers &optional always-list)
3702 "Convert list of numbers to a list of ranges or a single range.
3703 If ALWAYS-LIST is non-nil, this function will always release a list of
3705 (let* ((first (car numbers))
3706 (last (car numbers))
3710 (if (not (listp (cdr numbers)))
3713 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3714 ((= (1+ last) (car numbers)) ;Still in sequence
3715 (setq last (car numbers)))
3716 (t ;End of one sequence
3718 (cons (if (= first last) first
3719 (cons first last)) result))
3720 (setq first (car numbers))
3721 (setq last (car numbers))))
3722 (setq numbers (cdr numbers)))
3723 (if (and (not always-list) (null result))
3724 (if (= first last) (list first) (cons first last))
3725 (nreverse (cons (if (= first last) first (cons first last))
3728 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3729 (defun gnus-uncompress-range (ranges)
3730 "Expand a list of ranges into a list of numbers.
3731 RANGES is either a single range on the form `(num . num)' or a list of
3733 (let (first last result)
3737 ((not (listp (cdr ranges)))
3738 (setq first (car ranges))
3739 (setq last (cdr ranges))
3740 (while (<= first last)
3741 (setq result (cons first result))
3742 (setq first (1+ first)))
3746 (if (atom (car ranges))
3747 (if (numberp (car ranges))
3748 (setq result (cons (car ranges) result)))
3749 (setq first (car (car ranges)))
3750 (setq last (cdr (car ranges)))
3751 (while (<= first last)
3752 (setq result (cons first result))
3753 (setq first (1+ first))))
3754 (setq ranges (cdr ranges)))
3755 (nreverse result)))))
3757 (defun gnus-add-to-range (ranges list)
3758 "Return a list of ranges that has all articles from both RANGES and LIST.
3759 Note: LIST has to be sorted over `<'."
3761 (gnus-compress-sequence list t)
3762 (setq list (copy-sequence list))
3763 (or (listp (cdr ranges))
3764 (setq ranges (list ranges)))
3766 ilist lowest highest temp)
3767 (while (and ranges list)
3769 (setq lowest (or (and (atom (car ranges)) (car ranges))
3770 (car (car ranges))))
3771 (while (and list (cdr list) (< (car (cdr list)) lowest))
3772 (setq list (cdr list)))
3773 (if (< (car ilist) lowest)
3776 (setq list (cdr list))
3778 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3779 (setq highest (or (and (atom (car ranges)) (car ranges))
3780 (cdr (car ranges))))
3781 (while (and list (<= (car list) highest))
3782 (setq list (cdr list)))
3783 (setq ranges (cdr ranges)))
3785 (setq out (nconc (gnus-compress-sequence list t) out)))
3786 (setq out (sort out (lambda (r1 r2)
3787 (< (or (and (atom r1) r1) (car r1))
3788 (or (and (atom r2) r2) (car r2))))))
3791 (if (atom (car ranges))
3793 (if (atom (car (cdr ranges)))
3794 (if (= (1+ (car ranges)) (car (cdr ranges)))
3796 (setcar ranges (cons (car ranges)
3797 (car (cdr ranges))))
3798 (setcdr ranges (cdr (cdr ranges)))))
3799 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3801 (setcar (car (cdr ranges)) (car ranges))
3802 (setcar ranges (car (cdr ranges)))
3803 (setcdr ranges (cdr (cdr ranges)))))))
3805 (if (atom (car (cdr ranges)))
3806 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3808 (setcdr (car ranges) (car (cdr ranges)))
3809 (setcdr ranges (cdr (cdr ranges)))))
3810 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3812 (setcdr (car ranges) (cdr (car (cdr ranges))))
3813 (setcdr ranges (cdr (cdr ranges))))))))
3814 (setq ranges (cdr ranges)))
3817 (defun gnus-remove-from-range (ranges list)
3818 "Return a list of ranges that has all articles from LIST removed from RANGES.
3819 Note: LIST has to be sorted over `<'."
3820 ;; !!! This function shouldn't look like this, but I've got a headache.
3821 (gnus-compress-sequence
3822 (gnus-sorted-complement
3823 (gnus-uncompress-range ranges) list)))
3825 (defun gnus-member-of-range (number ranges)
3826 (if (not (listp (cdr ranges)))
3827 (and (>= number (car ranges))
3828 (<= number (cdr ranges)))
3831 (if (numberp (car ranges))
3832 (>= number (car ranges))
3833 (>= number (car (car ranges))))
3835 (if (if (numberp (car ranges))
3836 (= number (car ranges))
3837 (and (>= number (car (car ranges)))
3838 (<= number (cdr (car ranges)))))
3839 (setq not-stop nil))
3840 (setq ranges (cdr ranges)))
3843 (defun gnus-range-length (range)
3844 "Return the length RANGE would have if uncompressed."
3845 (length (gnus-uncompress-range range)))
3847 (defun gnus-sublist-p (list sublist)
3848 "Test whether all elements in SUBLIST are members of LIST."
3851 (unless (memq (pop sublist) list)
3861 (defvar gnus-group-mode-map nil)
3862 (put 'gnus-group-mode 'mode-class 'special)
3864 (unless gnus-group-mode-map
3865 (setq gnus-group-mode-map (make-keymap))
3866 (suppress-keymap gnus-group-mode-map)
3870 " " gnus-group-read-group
3871 "=" gnus-group-select-group
3872 "\M- " gnus-group-unhidden-select-group
3873 "\r" gnus-group-select-group
3874 "\M-\r" gnus-group-quick-select-group
3875 "j" gnus-group-jump-to-group
3876 "n" gnus-group-next-unread-group
3877 "p" gnus-group-prev-unread-group
3878 "\177" gnus-group-prev-unread-group
3879 "N" gnus-group-next-group
3880 "P" gnus-group-prev-group
3881 "\M-n" gnus-group-next-unread-group-same-level
3882 "\M-p" gnus-group-prev-unread-group-same-level
3883 "," gnus-group-best-unread-group
3884 "." gnus-group-first-unread-group
3885 "u" gnus-group-unsubscribe-current-group
3886 "U" gnus-group-unsubscribe-group
3887 "c" gnus-group-catchup-current
3888 "C" gnus-group-catchup-current-all
3889 "l" gnus-group-list-groups
3890 "L" gnus-group-list-all-groups
3892 "g" gnus-group-get-new-news
3893 "\M-g" gnus-group-get-new-news-this-group
3894 "R" gnus-group-restart
3895 "r" gnus-group-read-init-file
3896 "B" gnus-group-browse-foreign-server
3897 "b" gnus-group-check-bogus-groups
3898 "F" gnus-find-new-newsgroups
3899 "\C-c\C-d" gnus-group-describe-group
3900 "\M-d" gnus-group-describe-all-groups
3901 "\C-c\C-a" gnus-group-apropos
3902 "\C-c\M-\C-a" gnus-group-description-apropos
3903 "a" gnus-group-post-news
3904 "\ek" gnus-group-edit-local-kill
3905 "\eK" gnus-group-edit-global-kill
3906 "\C-k" gnus-group-kill-group
3907 "\C-y" gnus-group-yank-group
3908 "\C-w" gnus-group-kill-region
3909 "\C-x\C-t" gnus-group-transpose-groups
3910 "\C-c\C-l" gnus-group-list-killed
3911 "\C-c\C-x" gnus-group-expire-articles
3912 "\C-c\M-\C-x" gnus-group-expire-all-groups
3914 "s" gnus-group-save-newsrc
3915 "z" gnus-group-suspend
3916 "Z" gnus-group-clear-dribble
3919 "?" gnus-group-describe-briefly
3920 "\C-c\C-i" gnus-info-find-node
3921 "\M-e" gnus-group-edit-group-method
3922 "^" gnus-group-enter-server-mode
3923 gnus-mouse-2 gnus-mouse-pick-group
3924 "<" beginning-of-buffer
3927 "\C-c\C-s" gnus-group-sort-groups
3929 "\C-c\M-g" gnus-activate-all-groups
3930 "\M-&" gnus-group-universal-argument
3931 "#" gnus-group-mark-group
3932 "\M-#" gnus-group-unmark-group)
3935 (gnus-group-mark-map "M" gnus-group-mode-map)
3936 "m" gnus-group-mark-group
3937 "u" gnus-group-unmark-group
3938 "w" gnus-group-mark-region
3939 "m" gnus-group-mark-buffer
3940 "r" gnus-group-mark-regexp
3941 "U" gnus-group-unmark-all-groups)
3944 (gnus-group-group-map "G" gnus-group-mode-map)
3945 "d" gnus-group-make-directory-group
3946 "h" gnus-group-make-help-group
3947 "a" gnus-group-make-archive-group
3948 "k" gnus-group-make-kiboze-group
3949 "m" gnus-group-make-group
3950 "E" gnus-group-edit-group
3951 "e" gnus-group-edit-group-method
3952 "p" gnus-group-edit-group-parameters
3953 "v" gnus-group-add-to-virtual
3954 "V" gnus-group-make-empty-virtual
3955 "D" gnus-group-enter-directory
3956 "f" gnus-group-make-doc-group
3957 "r" gnus-group-rename-group
3958 "\177" gnus-group-delete-group)
3961 (gnus-group-soup-map "s" gnus-group-group-map)
3962 "b" gnus-group-brew-soup
3963 "w" gnus-soup-save-areas
3964 "s" gnus-soup-send-replies
3965 "p" gnus-soup-pack-packet
3966 "r" nnsoup-pack-replies)
3969 (gnus-group-sort-map "S" gnus-group-group-map)
3970 "s" gnus-group-sort-groups
3971 "a" gnus-group-sort-groups-by-alphabet
3972 "u" gnus-group-sort-groups-by-unread
3973 "l" gnus-group-sort-groups-by-level
3974 "v" gnus-group-sort-groups-by-score
3975 "r" gnus-group-sort-groups-by-rank
3976 "m" gnus-group-sort-groups-by-method)
3979 (gnus-group-list-map "A" gnus-group-mode-map)
3980 "k" gnus-group-list-killed
3981 "z" gnus-group-list-zombies
3982 "s" gnus-group-list-groups
3983 "u" gnus-group-list-all-groups
3984 "A" gnus-group-list-active
3985 "a" gnus-group-apropos
3986 "d" gnus-group-description-apropos
3987 "m" gnus-group-list-matching
3988 "M" gnus-group-list-all-matching
3989 "l" gnus-group-list-level)
3992 (gnus-group-score-map "W" gnus-group-mode-map)
3993 "f" gnus-score-flush-cache)
3996 (gnus-group-help-map "H" gnus-group-mode-map)
3997 "f" gnus-group-fetch-faq)
4000 (gnus-group-sub-map "S" gnus-group-mode-map)
4001 "l" gnus-group-set-current-level
4002 "t" gnus-group-unsubscribe-current-group
4003 "s" gnus-group-unsubscribe-group
4004 "k" gnus-group-kill-group
4005 "y" gnus-group-yank-group
4006 "w" gnus-group-kill-region
4007 "\C-k" gnus-group-kill-level
4008 "z" gnus-group-kill-all-zombies))
4010 (defun gnus-group-mode ()
4011 "Major mode for reading news.
4013 All normal editing commands are switched off.
4014 \\<gnus-group-mode-map>
4015 The group buffer lists (some of) the groups available. For instance,
4016 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4017 lists all zombie groups.
4019 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4020 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4022 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4024 The following commands are available:
4026 \\{gnus-group-mode-map}"
4028 (when (and menu-bar-mode
4029 (gnus-visual-p 'group-menu 'menu))
4030 (gnus-group-make-menu-bar))
4031 (kill-all-local-variables)
4032 (gnus-simplify-mode-line)
4033 (setq major-mode 'gnus-group-mode)
4034 (setq mode-name "Group")
4035 (gnus-group-set-mode-line)
4036 (setq mode-line-process nil)
4037 (use-local-map gnus-group-mode-map)
4038 (buffer-disable-undo (current-buffer))
4039 (setq truncate-lines t)
4040 (setq buffer-read-only t)
4041 (run-hooks 'gnus-group-mode-hook))
4043 (defun gnus-mouse-pick-group (e)
4044 "Enter the group under the mouse pointer."
4047 (gnus-group-read-group nil))
4049 ;; Look at LEVEL and find out what the level is really supposed to be.
4050 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4051 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4052 (defun gnus-group-default-level (&optional level number-or-nil)
4054 (gnus-group-use-permanent-levels
4055 (setq gnus-group-default-list-level
4056 (or level gnus-group-default-list-level))
4057 (or gnus-group-default-list-level gnus-level-subscribed))
4061 (or level gnus-group-default-list-level gnus-level-subscribed))))
4064 (defun gnus-slave-no-server (&optional arg)
4065 "Read network news as a slave, without connecting to local server"
4067 (gnus-no-server arg t))
4070 (defun gnus-no-server (&optional arg slave)
4072 If ARG is a positive number, Gnus will use that as the
4073 startup level. If ARG is nil, Gnus will be started at level 2.
4074 If ARG is non-nil and not a positive number, Gnus will
4075 prompt the user for the name of an NNTP server to use.
4076 As opposed to `gnus', this command will not connect to the local server."
4078 (make-local-variable 'gnus-group-use-permanent-levels)
4079 (setq gnus-group-use-permanent-levels t)
4080 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4083 (defun gnus-slave (&optional arg)
4084 "Read news as a slave."
4086 (gnus arg nil 'slave))
4089 (defun gnus-other-frame (&optional arg)
4090 "Pop up a frame to read news."
4092 (if (get-buffer gnus-group-buffer)
4093 (let ((pop-up-frames t))
4095 (select-frame (make-frame))
4099 (defun gnus (&optional arg dont-connect slave)
4101 If ARG is non-nil and a positive number, Gnus will use that as the
4102 startup level. If ARG is non-nil and not a positive number, Gnus will
4103 prompt the user for the name of an NNTP server to use."
4106 (if (get-buffer gnus-group-buffer)
4108 (switch-to-buffer gnus-group-buffer)
4109 (gnus-group-get-new-news))
4112 (nnheader-init-server-buffer)
4113 (gnus-read-init-file)
4114 (setq gnus-slave slave)
4116 (gnus-group-setup-buffer)
4117 (let ((buffer-read-only nil))
4119 (if (not gnus-inhibit-startup-message)
4121 (gnus-group-startup-message)
4124 (let ((level (and (numberp arg) (> arg 0) arg))
4130 (gnus-start-news-server (and arg (not level))))))
4131 (if (and (not dont-connect)
4134 (run-hooks 'gnus-startup-hook)
4135 ;; NNTP server is successfully open.
4137 ;; Find the current startup file name.
4138 (setq gnus-current-startup-file
4139 (gnus-make-newsrc-file gnus-startup-file))
4141 ;; Read the dribble file.
4142 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4144 (gnus-summary-make-display-table)
4145 ;; Do the actual startup.
4146 (gnus-setup-news nil level)
4147 ;; Generate the group buffer.
4148 (gnus-group-list-groups level)
4149 (gnus-group-first-unread-group)
4150 (gnus-configure-windows 'group)
4151 (gnus-group-set-mode-line))))))
4153 (defun gnus-unload ()
4154 "Unload all Gnus features."
4156 (or (boundp 'load-history)
4157 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4158 (let ((history load-history)
4161 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4162 (setq feature (cdr (assq 'provide (car history))))
4163 (unload-feature feature 'force))
4164 (setq history (cdr history)))))
4166 (defun gnus-compile ()
4167 "Byte-compile the user-defined format specs."
4169 (let ((entries gnus-format-specs)
4170 entry gnus-tmp-func)
4172 (gnus-message 7 "Compiling format specs...")
4175 (setq entry (pop entries))
4176 (if (eq (car entry) 'version)
4177 (setq gnus-format-specs (delq entry gnus-format-specs))
4178 (when (and (listp (caddr entry))
4179 (not (eq 'byte-code (caaddr entry))))
4180 (fset 'gnus-tmp-func
4181 `(lambda () ,(caddr entry)))
4182 (byte-compile 'gnus-tmp-func)
4183 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4185 (push (cons 'version emacs-version) gnus-format-specs)
4187 (gnus-message 7 "Compiling user specs...done"))))
4189 (defun gnus-indent-rigidly (start end arg)
4190 "Indent rigidly using only spaces and no tabs."
4193 (narrow-to-region start end)
4194 (indent-rigidly start end arg)
4195 (goto-char (point-min))
4196 (while (search-forward "\t" nil t)
4197 (replace-match " " t t)))))
4199 (defun gnus-group-startup-message (&optional x y)
4200 "Insert startup message in current buffer."
4201 ;; Insert the message.
4206 _ ___ __ ___ __ _ ___
4225 ;; And then hack it.
4226 (gnus-indent-rigidly (point-min) (point-max)
4227 (/ (max (- (window-width) (or x 46)) 0) 2))
4228 (goto-char (point-min))
4230 (let* ((pheight (count-lines (point-min) (point-max)))
4231 (wheight (window-height))
4232 (rest (- wheight pheight)))
4233 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4235 (goto-char (point-min))
4236 (and (search-forward "Praxis" nil t)
4237 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4238 (goto-char (point-min))
4239 (let* ((mode-string (gnus-group-set-mode-line)))
4240 (setq mode-line-buffer-identification
4241 (list (concat gnus-version (substring (car mode-string) 4))))
4242 (set-buffer-modified-p t)))
4244 (defun gnus-group-setup-buffer ()
4245 (or (get-buffer gnus-group-buffer)
4247 (switch-to-buffer gnus-group-buffer)
4248 (gnus-add-current-to-buffer-list)
4250 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4252 (defun gnus-group-list-groups (&optional level unread lowest)
4253 "List newsgroups with level LEVEL or lower that have unread articles.
4254 Default is all subscribed groups.
4255 If argument UNREAD is non-nil, groups with no unread articles are also
4257 (interactive (list (if current-prefix-arg
4258 (prefix-numeric-value current-prefix-arg)
4260 (gnus-group-default-level nil t)
4261 gnus-group-default-list-level
4262 gnus-level-subscribed))))
4264 (setq level (car gnus-group-list-mode)
4265 unread (cdr gnus-group-list-mode)))
4266 (setq level (gnus-group-default-level level))
4267 (gnus-group-setup-buffer) ;May call from out of group buffer
4268 (gnus-update-format-specifications)
4269 (let ((case-fold-search nil)
4270 (props (text-properties-at (gnus-point-at-bol)))
4271 (group (gnus-group-group-name)))
4272 (funcall gnus-group-prepare-function level unread lowest)
4273 (if (zerop (buffer-size))
4274 (gnus-message 5 gnus-no-groups-message)
4275 (goto-char (point-max))
4276 (when (or (not gnus-group-goto-next-group-function)
4277 (not (funcall gnus-group-goto-next-group-function
4280 ;; Go to the first group with unread articles.
4281 (gnus-group-search-forward t)
4282 ;; Find the right group to put point on. If the current group
4283 ;; has disappeared in the new listing, try to find the next
4284 ;; one. If no next one can be found, just leave point at the
4285 ;; first newsgroup in the buffer.
4286 (if (not (gnus-goto-char
4288 (point-min) (point-max)
4289 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4290 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4292 (not (gnus-goto-char
4294 (point-min) (point-max) 'gnus-group
4296 (car (car newsrc)) gnus-active-hashtb)))))
4297 (setq newsrc (cdr newsrc)))
4298 (or newsrc (progn (goto-char (point-max))
4299 (forward-line -1)))))))
4300 ;; Adjust cursor point.
4301 (gnus-group-position-point))))
4303 (defun gnus-group-list-level (level &optional all)
4304 "List groups on LEVEL.
4305 If ALL (the prefix), also list groups that have no unread articles."
4306 (interactive "nList groups on level: \nP")
4307 (gnus-group-list-groups level all level))
4309 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4310 "List all newsgroups with unread articles of level LEVEL or lower.
4311 If ALL is non-nil, list groups that have no unread articles.
4312 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4313 If REGEXP, only list groups matching REGEXP."
4314 (set-buffer gnus-group-buffer)
4315 (let ((buffer-read-only nil)
4316 (newsrc (cdr gnus-newsrc-alist))
4317 (lowest (or lowest 1))
4318 info clevel unread group params)
4320 (if (< lowest gnus-level-zombie)
4321 ;; List living groups.
4323 (setq info (car newsrc)
4324 group (gnus-info-group info)
4325 params (gnus-info-params info)
4327 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4328 (and unread ; This group might be bogus
4330 (string-match regexp group))
4331 (<= (setq clevel (gnus-info-level info)) level)
4333 (or all ; We list all groups?
4334 (and gnus-group-list-inactive-groups
4335 (eq unread t)) ; We list unactivated groups
4336 (> unread 0) ; We list groups with unread articles
4337 (and gnus-list-groups-with-ticked-articles
4338 (cdr (assq 'tick (gnus-info-marks info))))
4339 ; And groups with tickeds
4340 ;; Check for permanent visibility.
4341 (and gnus-permanently-visible-groups
4342 (string-match gnus-permanently-visible-groups
4344 (memq 'visible params)
4345 (cdr (assq 'visible params)))
4346 (gnus-group-insert-group-line
4347 group (gnus-info-level info)
4348 (gnus-info-marks info) unread (gnus-info-method info)))))
4350 ;; List dead groups.
4351 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4352 (gnus-group-prepare-flat-list-dead
4353 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4354 gnus-level-zombie ?Z
4356 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4357 (gnus-group-prepare-flat-list-dead
4358 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4359 gnus-level-killed ?K regexp))
4361 (gnus-group-set-mode-line)
4362 (setq gnus-group-list-mode (cons level all))
4363 (run-hooks 'gnus-group-prepare-hook)))
4365 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4366 ;; List zombies and killed lists somewhat faster, which was
4367 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4368 ;; this by ignoring the group format specification altogether.
4371 ;; This loop is used when listing groups that match some
4374 (setq group (pop groups))
4375 (when (string-match regexp group)
4376 (add-text-properties
4377 (point) (prog1 (1+ (point))
4378 (insert " " mark " *: " group "\n"))
4379 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4381 'gnus-level level))))
4382 ;; This loop is used when listing all groups.
4384 (add-text-properties
4385 (point) (prog1 (1+ (point))
4386 (insert " " mark " *: "
4387 (setq group (pop groups)) "\n"))
4388 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4390 'gnus-level level))))))
4392 (defmacro gnus-group-real-name (group)
4393 "Find the real name of a foreign newsgroup."
4394 `(let ((gname ,group))
4395 (if (string-match ":[^:]+$" gname)
4396 (substring gname (1+ (match-beginning 0)))
4399 (defsubst gnus-server-add-address (method)
4400 (let ((method-name (symbol-name (car method))))
4401 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4402 (not (assq (intern (concat method-name "-address")) method)))
4403 (append method (list (list (intern (concat method-name "-address"))
4407 (defsubst gnus-server-get-method (group method)
4408 ;; Input either a server name, and extended server name, or a
4409 ;; select method, and return a select method.
4410 (cond ((stringp method)
4411 (gnus-server-to-method method))
4412 ((and (stringp (car method)) group)
4413 (gnus-server-extend-method group method))
4415 (gnus-server-add-address method))))
4417 (defun gnus-server-to-method (server)
4418 "Map virtual server names to select methods."
4419 (or (and (equal server "native") gnus-select-method)
4420 (cdr (assoc server gnus-server-alist))))
4422 (defmacro gnus-server-equal (ss1 ss2)
4423 "Say whether two servers are equal."
4427 (and (= (length s1) (length s2))
4429 (while (and s1 (member (car s1) s2))
4433 (defun gnus-group-prefixed-name (group method)
4434 "Return the whole name from GROUP and METHOD."
4435 (and (stringp method) (setq method (gnus-server-to-method method)))
4436 (concat (format "%s" (car method))
4438 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
4439 (not (string= (nth 1 method) "")))
4440 (concat "+" (nth 1 method)))
4443 (defun gnus-group-real-prefix (group)
4444 "Return the prefix of the current group name."
4445 (if (string-match "^[^:]+:" group)
4446 (substring group 0 (match-end 0))
4449 (defun gnus-group-method-name (group)
4450 "Return the method used for selecting GROUP."
4451 (let ((prefix (gnus-group-real-prefix group)))
4452 (if (equal prefix "")
4454 (if (string-match "^[^\\+]+\\+" prefix)
4455 (list (intern (substring prefix 0 (1- (match-end 0))))
4456 (substring prefix (match-end 0) (1- (length prefix))))
4457 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
4459 (defsubst gnus-secondary-method-p (method)
4460 "Return whether METHOD is a secondary select method."
4461 (let ((methods gnus-secondary-select-methods)
4462 (gmethod (gnus-server-get-method nil method)))
4464 (not (equal (gnus-server-get-method nil (car methods))
4466 (setq methods (cdr methods)))
4469 (defun gnus-group-foreign-p (group)
4470 "Say whether a group is foreign or not."
4471 (and (not (gnus-group-native-p group))
4472 (not (gnus-group-secondary-p group))))
4474 (defun gnus-group-native-p (group)
4475 "Say whether the group is native or not."
4476 (not (string-match ":" group)))
4478 (defun gnus-group-secondary-p (group)
4479 "Say whether the group is secondary or not."
4480 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4482 (defun gnus-group-get-parameter (group &optional symbol)
4483 "Returns the group parameters for GROUP.
4484 If SYMBOL, return the value of that symbol in the group parameters."
4485 (let ((params (gnus-info-params (gnus-get-info group))))
4487 (gnus-group-parameter-value params symbol)
4490 (defun gnus-group-parameter-value (params symbol)
4491 "Return the value of SYMBOL in group PARAMS."
4492 (or (car (memq symbol params)) ; It's either a simple symbol
4493 (cdr (assq symbol params)))) ; or a cons.
4495 (defun gnus-group-add-parameter (group param)
4496 "Add parameter PARAM to GROUP."
4497 (let ((info (gnus-get-info group)))
4499 () ; This is a dead group. We just ignore it.
4500 ;; Cons the new param to the old one and update.
4501 (gnus-group-set-info (cons param (gnus-info-params info))
4504 (defun gnus-group-add-score (group &optional score)
4505 "Add SCORE to the GROUP score.
4506 If SCORE is nil, add 1 to the score of GROUP."
4507 (let ((info (gnus-get-info group)))
4508 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4510 (defun gnus-summary-bubble-group ()
4511 "Increase the score of the current group.
4512 This is a handy function to add to `gnus-summary-exit-hook' to
4513 increase the score of each group you read."
4514 (gnus-group-add-score gnus-newsgroup-name))
4516 (defun gnus-group-set-info (info &optional method-only-group part)
4517 (let* ((entry (gnus-gethash
4518 (or method-only-group (gnus-info-group info))
4519 gnus-newsrc-hashtb))
4521 (info (if method-only-group (nth 2 entry) info)))
4522 (when method-only-group
4524 (error "Trying to change non-existent group %s" method-only-group))
4525 ;; We have received parts of the actual group info - either the
4526 ;; select method or the group parameters. We first check
4527 ;; whether we have to extend the info, and if so, do that.
4528 (let ((len (length info))
4529 (total (if (eq part 'method) 5 6)))
4531 (setcdr (nthcdr (1- len) info)
4532 (make-list (- total len) nil)))
4533 ;; Then we enter the new info.
4534 (setcar (nthcdr (1- total) info) part-info)))
4536 ;; This is a new group, so we just create it.
4538 (set-buffer gnus-group-buffer)
4539 (if (gnus-info-method info)
4540 ;; It's a foreign group...
4541 (gnus-group-make-group
4542 (gnus-group-real-name (gnus-info-group info))
4543 (prin1-to-string (car (gnus-info-method info)))
4544 (nth 1 (gnus-info-method info)))
4545 ;; It's a native group.
4546 (gnus-group-make-group (gnus-info-group info)))
4547 (gnus-message 6 "Note: New group created")
4549 (gnus-gethash (gnus-group-prefixed-name
4550 (gnus-group-real-name (gnus-info-group info))
4551 (or (gnus-info-method info) gnus-select-method))
4552 gnus-newsrc-hashtb))))
4553 ;; Whether it was a new group or not, we now have the entry, so we
4554 ;; can do the update.
4557 (setcar (nthcdr 2 entry) info)
4558 (when (and (not (eq (car entry) t))
4559 (gnus-active (gnus-info-group info)))
4560 (let ((marked (gnus-info-marks info)))
4561 (setcar entry (length (gnus-list-of-unread-articles
4563 (error "No such group: %s" (gnus-info-group info)))))
4565 (defun gnus-group-set-method-info (group select-method)
4566 (gnus-group-set-info select-method group 'method))
4568 (defun gnus-group-set-params-info (group params)
4569 (gnus-group-set-info params group 'params))
4571 (defun gnus-group-update-group-line ()
4572 "Update the current line in the group buffer."
4573 (let* ((buffer-read-only nil)
4574 (group (gnus-group-group-name))
4575 (gnus-group-indentation (gnus-group-group-indentation))
4576 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4578 (not (gnus-ephemeral-group-p group))
4580 (concat "(gnus-group-set-info '"
4581 (prin1-to-string (nth 2 entry)) ")")))
4583 (gnus-group-insert-group-line-info group)
4585 (gnus-group-position-point)))
4587 (defun gnus-group-insert-group-line-info (group)
4588 "Insert GROUP on the current line."
4589 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4593 ;; (Un)subscribed group.
4594 (setq info (nth 2 entry))
4595 (gnus-group-insert-group-line
4596 group (gnus-info-level info) (gnus-info-marks info)
4597 (or (car entry) t) (gnus-info-method info)))
4598 ;; This group is dead.
4599 (gnus-group-insert-group-line
4601 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4603 (if (setq active (gnus-active group))
4604 (- (1+ (cdr active)) (car active)) 0)
4607 (defun gnus-group-insert-group-line
4608 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4610 "Insert a group line in the group buffer."
4611 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4612 (gnus-tmp-number-total
4614 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4616 (gnus-tmp-number-of-unread
4617 (if (numberp number) (int-to-string (max 0 number))
4619 (gnus-tmp-number-of-read
4620 (if (numberp number)
4621 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4623 (gnus-tmp-subscribed
4624 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4625 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4626 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4628 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4629 (gnus-tmp-newsgroup-description
4630 (if gnus-description-hashtb
4631 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4634 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4635 (gnus-tmp-moderated-string
4636 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4638 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4639 (gnus-tmp-news-server (or (car (cdr gnus-tmp-method)) ""))
4640 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4641 (gnus-tmp-news-method-string
4643 (format "(%s:%s)" (car gnus-tmp-method)
4644 (car (cdr gnus-tmp-method))) ""))
4645 (gnus-tmp-marked-mark
4646 (if (and (numberp number)
4648 (cdr (assq 'tick gnus-tmp-marked)))
4651 (cond ((eq number t) "*" )
4652 ((numberp number) (int-to-string number))
4654 (gnus-tmp-process-marked
4655 (if (member gnus-tmp-group gnus-group-marked)
4656 gnus-process-mark ? ))
4657 (buffer-read-only nil)
4658 header gnus-tmp-header) ; passed as parameter to user-funcs.
4660 (add-text-properties
4664 (eval gnus-group-line-format-spec))
4665 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4666 gnus-unread ,(if (numberp number)
4667 (string-to-int gnus-tmp-number-of-unread)
4669 gnus-marked ,gnus-tmp-marked-mark
4670 gnus-indentation ,gnus-group-indentation
4671 gnus-level ,gnus-tmp-level))
4672 (when (gnus-visual-p 'group-highlight 'highlight)
4674 (run-hooks 'gnus-group-update-hook)
4676 ;; Allow XEmacs to remove front-sticky text properties.
4677 (gnus-group-remove-excess-properties)))
4679 (defun gnus-group-update-group (group &optional visible-only)
4680 "Update all lines where GROUP appear.
4681 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4684 (set-buffer gnus-group-buffer)
4685 ;; The buffer may be narrowed.
4688 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4690 found buffer-read-only visible)
4691 ;; Enter the current status into the dribble buffer.
4692 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4693 (if (and entry (not (gnus-ephemeral-group-p group)))
4695 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4697 ;; Find all group instances. If topics are in use, each group
4698 ;; may be listed in more than once.
4699 (while (setq loc (text-property-any
4700 loc (point-max) 'gnus-group ident))
4703 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4705 (gnus-group-insert-group-line-info group))
4706 (setq loc (1+ loc)))
4707 (if (or found visible-only)
4709 ;; No such line in the buffer, find out where it's supposed to
4710 ;; go, and insert it there (or at the end of the buffer).
4711 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
4712 (let ((entry (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
4713 (while (and entry (car entry)
4717 (point-min) (point-max)
4718 'gnus-group (gnus-intern-safe
4720 gnus-active-hashtb)))))
4721 (setq entry (cdr entry)))
4722 (or entry (goto-char (point-max))))
4723 ;; Finally insert the line.
4724 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4725 (gnus-group-insert-group-line-info group)))
4726 (gnus-group-set-mode-line)))))
4728 (defun gnus-group-set-mode-line ()
4729 (when (memq 'group gnus-updated-mode-lines)
4730 (let* ((gformat (or gnus-group-mode-line-format-spec
4731 (setq gnus-group-mode-line-format-spec
4733 gnus-group-mode-line-format
4734 gnus-group-mode-line-format-alist))))
4735 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4736 (gnus-tmp-news-method (car gnus-select-method))
4738 header ;Dummy binding for user-defined formats
4739 ;; Get the resulting string.
4740 (mode-string (eval gformat)))
4741 ;; If the line is too long, we chop it off.
4742 (when (> (length mode-string) max-len)
4743 (setq mode-string (substring mode-string 0 (- max-len 4))))
4745 (setq mode-line-buffer-identification (list mode-string))
4746 (set-buffer-modified-p t)))))
4748 (defun gnus-group-group-name ()
4749 "Get the name of the newsgroup on the current line."
4750 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4751 (and group (symbol-name group))))
4753 (defun gnus-group-group-level ()
4754 "Get the level of the newsgroup on the current line."
4755 (get-text-property (gnus-point-at-bol) 'gnus-level))
4757 (defun gnus-group-group-indentation ()
4758 "Get the indentation of the newsgroup on the current line."
4759 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4761 (defun gnus-group-group-unread ()
4762 "Get the number of unread articles of the newsgroup on the current line."
4763 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4765 (defun gnus-group-search-forward (&optional backward all level first-too)
4766 "Find the next newsgroup with unread articles.
4767 If BACKWARD is non-nil, find the previous newsgroup instead.
4768 If ALL is non-nil, just find any newsgroup.
4769 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4771 If FIRST-TOO, the current line is also eligible as a target."
4772 (let ((way (if backward -1 1))
4773 (low gnus-level-killed)
4776 (if (and backward (progn (beginning-of-line)) (bobp))
4778 (or first-too (forward-line way))
4786 (get-text-property (point) 'gnus-unread)))
4787 (and (numberp unread) (> unread 0)))
4788 (setq lev (get-text-property (point)
4790 (<= lev gnus-level-subscribed)))
4792 (and (setq lev (get-text-property (point)
4801 (zerop (forward-line way)))))
4803 (progn (gnus-group-position-point) t)
4804 (goto-char (or pos beg))
4807 ;;; Gnus group mode commands
4811 (defun gnus-group-mark-group (n &optional unmark no-advance)
4812 "Mark the current group."
4814 (let ((buffer-read-only nil)
4818 (setq group (gnus-group-group-name))
4822 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4827 (setq gnus-group-marked (delete group gnus-group-marked)))
4829 (setq gnus-group-marked
4830 (cons group (delete group gnus-group-marked))))
4832 (or no-advance (zerop (gnus-group-next-group 1))))
4834 (gnus-summary-position-point)
4837 (defun gnus-group-unmark-group (n)
4838 "Remove the mark from the current group."
4840 (gnus-group-mark-group n 'unmark)
4841 (gnus-group-position-point))
4843 (defun gnus-group-unmark-all-groups ()
4844 "Unmark all groups."
4845 (let ((groups gnus-group-marked))
4848 (gnus-group-remove-mark (pop groups)))))
4849 (gnus-group-position-point))
4851 (defun gnus-group-mark-region (unmark beg end)
4852 "Mark all groups between point and mark.
4853 If UNMARK, remove the mark instead."
4854 (interactive "P\nr")
4855 (let ((num (count-lines beg end)))
4858 (- num (gnus-group-mark-group num unmark)))))
4860 (defun gnus-group-mark-buffer (&optional unmark)
4861 "Mark all groups in the buffer.
4862 If UNMARK, remove the mark instead."
4864 (gnus-group-mark-region unmark (point-min) (point-max)))
4866 (defun gnus-group-mark-regexp (regexp)
4867 "Mark all groups that match some regexp."
4868 (interactive "sMark (regexp): ")
4869 (let ((alist (cdr gnus-newsrc-alist))
4872 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
4873 (gnus-group-set-mark group))))
4874 (gnus-group-position-point))
4876 (defun gnus-group-remove-mark (group)
4877 (if (gnus-group-goto-group group)
4879 (gnus-group-mark-group 1 'unmark t))
4880 (setq gnus-group-marked
4881 (delete group gnus-group-marked))))
4883 (defun gnus-group-set-mark (group)
4884 "Set the process mark on GROUP."
4885 (if (gnus-group-goto-group group)
4887 (gnus-group-mark-group 1 nil t))
4888 (setq gnus-group-marked
4889 (cons group (delete group gnus-group-marked)))))
4891 (defun gnus-group-universal-argument (arg &optional groups func)
4892 "Perform any command on all groups accoring to the process/prefix convention."
4894 (let ((groups (or groups (gnus-group-process-prefix arg)))
4896 (if (eq (setq func (or func
4899 (substitute-command-keys
4900 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
4903 (message "Undefined key")
4906 (gnus-group-remove-mark (setq group (pop groups)))
4907 (command-execute func))))
4908 (gnus-group-position-point))
4910 (defun gnus-group-process-prefix (n)
4911 "Return a list of groups to work on.
4912 Take into consideration N (the prefix) and the list of marked groups."
4915 (setq n (prefix-numeric-value n))
4916 ;; There is a prefix, so we return a list of the N next
4918 (let ((way (if (< n 0) -1 1))
4923 (setq group (gnus-group-group-name)))
4924 (setq groups (cons group groups))
4926 (gnus-group-next-group way)))
4928 ((and (boundp 'transient-mark-mode)
4931 ;; Work on the region between point and mark.
4932 (let ((max (max (point) (mark)))
4935 (goto-char (min (point) (mark)))
4938 (push (gnus-group-group-name) groups)
4939 (zerop (gnus-group-next-group 1))
4941 (nreverse groups))))
4943 ;; No prefix, but a list of marked articles.
4944 (reverse gnus-group-marked))
4946 ;; Neither marked articles or a prefix, so we return the
4948 (let ((group (gnus-group-group-name)))
4949 (and group (list group))))))
4951 ;; Selecting groups.
4953 (defun gnus-group-read-group (&optional all no-article group)
4954 "Read news in this newsgroup.
4955 If the prefix argument ALL is non-nil, already read articles become
4956 readable. IF ALL is a number, fetch this number of articles. If the
4957 optional argument NO-ARTICLE is non-nil, no article will be
4958 auto-selected upon group entry. If GROUP is non-nil, fetch that
4961 (let ((group (or group (gnus-group-group-name)))
4962 number active marked entry)
4963 (or group (error "No group on current line"))
4964 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
4965 group gnus-newsrc-hashtb)))))
4966 ;; This group might be a dead group. In that case we have to get
4967 ;; the number of unread articles from `gnus-active-hashtb'.
4969 (cond ((numberp all) all)
4971 ((setq active (gnus-active group))
4972 (- (1+ (cdr active)) (car active)))))
4973 (gnus-summary-read-group
4974 group (or all (and (numberp number)
4975 (zerop (+ number (length (cdr (assq 'tick marked)))
4976 (length (cdr (assq 'dormant marked)))))))
4979 (defun gnus-group-select-group (&optional all)
4980 "Select this newsgroup.
4981 No article is selected automatically.
4982 If ALL is non-nil, already read articles become readable.
4983 If ALL is a number, fetch this number of articles."
4985 (gnus-group-read-group all t))
4987 (defun gnus-group-quick-select-group (&optional all)
4988 "Select the current group \"quickly\".
4989 This means that no highlighting or scoring will be performed."
4992 gnus-score-find-score-files-function
4993 gnus-apply-kill-hook
4994 gnus-summary-expunge-below)
4995 (gnus-group-read-group all t)))
4997 (defun gnus-group-visible-select-group (&optional all)
4998 "Select the current group without hiding any articles."
5000 (let ((gnus-inhibit-limiting t))
5001 (gnus-group-read-group all t)))
5004 (defun gnus-fetch-group (group)
5005 "Start Gnus if necessary and enter GROUP.
5006 Returns whether the fetching was successful or not."
5007 (interactive "sGroup name: ")
5008 (or (get-buffer gnus-group-buffer)
5010 (gnus-group-select-group))
5012 ;; Enter a group that is not in the group buffer. Non-nil is returned
5013 ;; if selection was successful.
5014 (defun gnus-group-read-ephemeral-group
5015 (group method &optional activate quit-config)
5016 (let ((group (if (gnus-group-foreign-p group) group
5017 (gnus-group-prefixed-name group method))))
5020 (list t nil (list group gnus-level-default-subscribed nil nil
5024 (if quit-config quit-config
5025 (cons (current-buffer) 'summary)))))))
5027 (set-buffer gnus-group-buffer)
5028 (or (gnus-check-server method)
5029 (error "Unable to contact server: %s" (gnus-status-message method)))
5030 (if activate (or (gnus-request-group group)
5031 (error "Couldn't request group")))
5033 (gnus-group-read-group t t group)
5037 (defun gnus-group-jump-to-group (group)
5038 "Jump to newsgroup GROUP."
5040 (list (completing-read
5041 "Group: " gnus-active-hashtb nil
5042 (memq gnus-select-method gnus-have-read-active-file))))
5044 (if (equal group "")
5045 (error "Empty group name"))
5047 (let ((b (text-property-any
5048 (point-min) (point-max)
5049 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5051 ;; Either go to the line in the group buffer...
5053 ;; ... or insert the line.
5056 (gnus-activate-group group)
5057 (error "%s error: %s" group (gnus-status-message group)))
5059 (gnus-group-update-group group)
5060 (goto-char (text-property-any
5061 (point-min) (point-max)
5062 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5063 ;; Adjust cursor point.
5064 (gnus-group-position-point))
5066 (defun gnus-group-goto-group (group)
5067 "Goto to newsgroup GROUP."
5069 (let ((b (text-property-any (point-min) (point-max)
5070 'gnus-group (gnus-intern-safe
5071 group gnus-active-hashtb))))
5072 (and b (goto-char b)))))
5074 (defun gnus-group-next-group (n)
5075 "Go to next N'th newsgroup.
5076 If N is negative, search backward instead.
5077 Returns the difference between N and the number of skips actually
5080 (gnus-group-next-unread-group n t))
5082 (defun gnus-group-next-unread-group (n &optional all level)
5083 "Go to next N'th unread newsgroup.
5084 If N is negative, search backward instead.
5085 If ALL is non-nil, choose any newsgroup, unread or not.
5086 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5087 such group can be found, the next group with a level higher than
5089 Returns the difference between N and the number of skips actually
5092 (let ((backward (< n 0))
5095 (gnus-group-search-forward
5096 backward (or (not gnus-group-goto-unread) all) level))
5098 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5099 (if level " on this level or higher" "")))
5102 (defun gnus-group-prev-group (n)
5103 "Go to previous N'th newsgroup.
5104 Returns the difference between N and the number of skips actually
5107 (gnus-group-next-unread-group (- n) t))
5109 (defun gnus-group-prev-unread-group (n)
5110 "Go to previous N'th unread newsgroup.
5111 Returns the difference between N and the number of skips actually
5114 (gnus-group-next-unread-group (- n)))
5116 (defun gnus-group-next-unread-group-same-level (n)
5117 "Go to next N'th unread newsgroup on the same level.
5118 If N is negative, search backward instead.
5119 Returns the difference between N and the number of skips actually
5122 (gnus-group-next-unread-group n t (gnus-group-group-level))
5123 (gnus-group-position-point))
5125 (defun gnus-group-prev-unread-group-same-level (n)
5126 "Go to next N'th unread newsgroup on the same level.
5127 Returns the difference between N and the number of skips actually
5130 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5131 (gnus-group-position-point))
5133 (defun gnus-group-best-unread-group (&optional exclude-group)
5134 "Go to the group with the highest level.
5135 If EXCLUDE-GROUP, do not go to that group."
5137 (goto-char (point-min))
5140 (while (setq unread (get-text-property (point) 'gnus-unread))
5141 (if (and (numberp unread) (> unread 0))
5143 (if (and (< (get-text-property (point) 'gnus-level) best)
5144 (or (not exclude-group)
5145 (not (equal exclude-group (gnus-group-group-name)))))
5147 (setq best (get-text-property (point) 'gnus-level))
5148 (setq best-point (point))))))
5150 (if best-point (goto-char best-point))
5151 (gnus-summary-position-point)
5152 (and best-point (gnus-group-group-name))))
5154 (defun gnus-group-first-unread-group ()
5155 "Go to the first group with unread articles."
5158 (let ((opoint (point))
5160 (goto-char (point-min))
5161 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5162 (and (numberp unread) ; Not a topic.
5163 (not (zerop unread))) ; Has unread articles.
5164 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5167 nil)) ; Not success.
5168 (gnus-group-position-point)))
5170 (defun gnus-group-enter-server-mode ()
5171 "Jump to the server buffer."
5173 (gnus-enter-server-buffer))
5175 (defun gnus-group-make-group (name &optional method address)
5176 "Add a new newsgroup.
5177 The user will be prompted for a NAME, for a select METHOD, and an
5181 (read-string "Group name: ")
5184 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5186 (if (assoc method gnus-valid-select-methods)
5188 (if (memq 'prompt-address
5189 (assoc method gnus-valid-select-methods))
5190 (read-string "Address: ")
5192 (list method nil)))))
5195 (set-buffer gnus-group-buffer)
5196 (let* ((meth (and method (if address (list (intern method) address)
5198 (nname (if method (gnus-group-prefixed-name name meth) name))
5200 (and (gnus-gethash nname gnus-newsrc-hashtb)
5201 (error "Group %s already exists" nname))
5202 (gnus-group-change-level
5203 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5204 gnus-level-default-subscribed gnus-level-killed
5205 (and (gnus-group-group-name)
5206 (gnus-gethash (gnus-group-group-name)
5207 gnus-newsrc-hashtb))
5209 (gnus-set-active nname (cons 1 0))
5210 (or (gnus-ephemeral-group-p name)
5212 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5213 (gnus-group-insert-group-line-info nname)
5215 (if (assoc method gnus-valid-select-methods)
5216 (require (intern method)))
5217 (and (gnus-check-backend-function 'request-create-group nname)
5218 (gnus-request-create-group nname))
5221 (defun gnus-group-delete-group (group &optional force)
5222 "Delete the current group.
5223 If FORCE (the prefix) is non-nil, all the articles in the group will
5224 be deleted. This is \"deleted\" as in \"removed forever from the face
5225 of the Earth\". There is no undo."
5227 (list (gnus-group-group-name)
5228 current-prefix-arg))
5229 (or group (error "No group to rename"))
5230 (or (gnus-check-backend-function 'request-delete-group group)
5231 (error "This backend does not support group deletion"))
5233 (if (not (gnus-yes-or-no-p
5235 "Do you really want to delete %s%s? "
5236 group (if force " and all its contents" ""))))
5238 (gnus-message 6 "Deleting group %s..." group)
5239 (if (not (gnus-request-delete-group group force))
5241 (gnus-message 3 "Couldn't delete group %s" group)
5243 (gnus-message 6 "Deleting group %s...done" group)
5244 (gnus-group-goto-group group)
5245 (gnus-group-kill-group 1 t)
5247 (gnus-group-position-point)))
5249 (defun gnus-group-rename-group (group new-name)
5252 (gnus-group-group-name)
5254 (or (gnus-check-backend-function
5255 'request-rename-group (gnus-group-group-name))
5256 (error "This backend does not support renaming groups"))
5257 (read-string "New group name: "))))
5259 (or (gnus-check-backend-function 'request-rename-group group)
5260 (error "This backend does not support renaming groups"))
5262 (or group (error "No group to rename"))
5263 (and (string-match "^[ \t]*$" new-name)
5264 (error "Not a valid group name"))
5266 ;; We find the proper prefixed name.
5268 (gnus-group-prefixed-name
5269 (gnus-group-real-name new-name)
5270 (gnus-info-method (gnus-get-info group))))
5272 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5274 (if (not (gnus-request-rename-group group new-name))
5276 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5278 ;; We rename the group internally by killing it...
5279 (gnus-group-goto-group group)
5280 (gnus-group-kill-group)
5281 ;; ... changing its name ...
5282 (setcar (cdr (car gnus-list-of-killed-groups))
5284 ;; ... and then yanking it. Magic!
5285 (gnus-group-yank-group)
5286 (gnus-set-active new-name (gnus-active group))
5287 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5289 (gnus-group-position-point)))
5292 (defun gnus-group-edit-group (group &optional part)
5293 "Edit the group on the current line."
5294 (interactive (list (gnus-group-group-name)))
5295 (let ((done-func '(lambda ()
5296 "Exit editing mode and update the information."
5298 (gnus-group-edit-group-done 'part 'group)))
5299 (part (or part 'info))
5300 (winconf (current-window-configuration))
5302 (or group (error "No group on current line"))
5303 (or (setq info (gnus-get-info group))
5304 (error "Killed group; can't be edited"))
5305 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5306 (gnus-configure-windows 'edit-group)
5307 (gnus-add-current-to-buffer-list)
5309 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5310 (use-local-map (copy-keymap emacs-lisp-mode-map))
5311 (local-set-key "\C-c\C-c" done-func)
5312 (make-local-variable 'gnus-prev-winconf)
5313 (setq gnus-prev-winconf winconf)
5314 ;; We modify the func to let it know what part it is editing.
5315 (setcar (cdr (nth 4 done-func)) (list 'quote part))
5316 (setcar (cdr (cdr (nth 4 done-func))) group)
5321 ";; Type `C-c C-c' after editing the select method.\n\n")
5323 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5325 ";; Type `C-c C-c' after editing the group info.\n\n")))
5328 (cond ((eq part 'method)
5329 (or (gnus-info-method info) "native"))
5331 (gnus-info-params info))
5335 (defun gnus-group-edit-group-method (group)
5336 "Edit the select method of GROUP."
5337 (interactive (list (gnus-group-group-name)))
5338 (gnus-group-edit-group group 'method))
5340 (defun gnus-group-edit-group-parameters (group)
5341 "Edit the group parameters of GROUP."
5342 (interactive (list (gnus-group-group-name)))
5343 (gnus-group-edit-group group 'params))
5345 (defun gnus-group-edit-group-done (part group)
5346 "Get info from buffer, update variables and jump to the group buffer."
5347 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5348 (goto-char (point-min))
5349 (let* ((form (read (current-buffer)))
5350 (winconf gnus-prev-winconf)
5351 (new-group (when (eq part 'info)
5352 (if (or (not (nth 4 form))
5354 gnus-select-method (nth 4 form)))
5355 (gnus-group-real-name (car form))
5356 (gnus-group-prefixed-name
5357 (gnus-group-real-name (car form)) (nth 4 form))))))
5361 (when new-group (setcar form new-group))
5362 (gnus-group-set-info form))
5363 (gnus-group-set-info form group part))
5364 (kill-buffer (current-buffer))
5365 (and winconf (set-window-configuration winconf))
5366 (set-buffer gnus-group-buffer)
5367 (when (and new-group
5368 (not (equal new-group group)))
5369 (when (gnus-group-goto-group group)
5370 (gnus-group-kill-group 1))
5371 (gnus-activate-group new-group))
5372 (gnus-group-update-group (or new-group group))
5373 (gnus-group-position-point)))
5375 (defun gnus-group-make-help-group ()
5376 "Create the Gnus documentation group."
5378 (let ((path load-path)
5379 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5381 (and (gnus-gethash name gnus-newsrc-hashtb)
5382 (error "Documentation group already exists"))
5384 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5386 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5388 (setq file (concat (file-name-directory
5389 (directory-file-name dir))
5390 "etc/gnus-tut.txt"))))
5393 (message "Couldn't find doc group")
5394 (gnus-group-make-group
5395 (gnus-group-real-name name)
5397 (list 'nndoc-address file)
5398 (list 'nndoc-article-type 'mbox)))))
5399 (gnus-group-position-point))
5401 (defun gnus-group-make-doc-group (file type)
5402 "Create a group that uses a single file as the source."
5404 (list (read-file-name "File name: ")
5405 (and current-prefix-arg 'ask)))
5406 (when (eq type 'ask)
5411 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5413 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5414 ((= char ?b) 'babyl)
5415 ((= char ?d) 'digest)
5416 ((= char ?f) 'forward)
5418 (t (setq err (format "%c unknown. " char))
5421 (let* ((file (expand-file-name file))
5422 (name (gnus-generate-new-group-name
5423 (gnus-group-prefixed-name
5424 (file-name-nondirectory file) '(nndoc "")))))
5425 (gnus-group-make-group
5426 (gnus-group-real-name name)
5428 (list 'nndoc-address file)
5429 (list 'nndoc-article-type (or type 'guess))))
5431 (gnus-group-position-point)))
5433 (defun gnus-group-make-archive-group (&optional all)
5434 "Create the (ding) Gnus archive group of the most recent articles.
5435 Given a prefix, create a full group."
5437 (let ((group (gnus-group-prefixed-name
5438 (if all "ding.archives" "ding.recent") '(nndir ""))))
5439 (and (gnus-gethash group gnus-newsrc-hashtb)
5440 (error "Archive group already exists"))
5441 (gnus-group-make-group
5442 (gnus-group-real-name group)
5443 (list 'nndir (if all "hpc" "edu")
5444 (list 'nndir-directory
5445 (if all gnus-group-archive-directory
5446 gnus-group-recent-archive-directory)))))
5448 (gnus-group-position-point))
5450 (defun gnus-group-make-directory-group (dir)
5451 "Create an nndir group.
5452 The user will be prompted for a directory. The contents of this
5453 directory will be used as a newsgroup. The directory should contain
5454 mail messages or news articles in files that have numeric names."
5456 (list (read-file-name "Create group from directory: ")))
5457 (or (file-exists-p dir) (error "No such directory"))
5458 (or (file-directory-p dir) (error "Not a directory"))
5462 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5464 (gnus-group-prefixed-name
5465 (concat (file-name-as-directory (directory-file-name dir))
5468 (setq ext (format "<%d>" (setq i (1+ i)))))
5469 (gnus-group-make-group
5470 (gnus-group-real-name group)
5471 (list 'nndir group (list 'nndir-directory dir))))
5473 (gnus-group-position-point))
5475 (defun gnus-group-make-kiboze-group (group address scores)
5476 "Create an nnkiboze group.
5477 The user will be prompted for a name, a regexp to match groups, and
5478 score file entries for articles to include in the group."
5481 (read-string "nnkiboze group name: ")
5482 (read-string "Source groups (regexp): ")
5483 (let ((headers (mapcar (lambda (group) (list group))
5484 '("subject" "from" "number" "date" "message-id"
5485 "references" "chars" "lines" "xref"
5486 "followup" "all" "body" "head")))
5487 scores header regexp regexps)
5488 (while (not (equal "" (setq header (completing-read
5489 "Match on header: " headers nil t))))
5491 (while (not (equal "" (setq regexp (read-string
5492 (format "Match on %s (string): "
5494 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5495 (setq scores (cons (cons header regexps) scores)))
5497 (gnus-group-make-group group "nnkiboze" address)
5499 (gnus-set-work-buffer)
5500 (let (emacs-lisp-mode-hook)
5501 (pp scores (current-buffer)))
5502 (write-region (point-min) (point-max)
5503 (gnus-score-file-name (concat "nnkiboze:" group))))
5505 (gnus-group-position-point))
5507 (defun gnus-group-add-to-virtual (n vgroup)
5508 "Add the current group to a virtual group."
5510 (list current-prefix-arg
5511 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5513 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5514 (error "%s is not an nnvirtual group" vgroup))
5515 (let* ((groups (gnus-group-process-prefix n))
5516 (method (gnus-info-method (gnus-get-info vgroup))))
5517 (setcar (cdr method)
5519 (nth 1 method) "\\|"
5522 (gnus-group-remove-mark s)
5523 (concat "\\(^" (regexp-quote s) "$\\)"))
5525 (gnus-group-position-point))
5527 (defun gnus-group-make-empty-virtual (group)
5528 "Create a new, fresh, empty virtual group."
5529 (interactive "sCreate new, empty virtual group: ")
5530 (let* ((method (list 'nnvirtual "^$"))
5531 (pgroup (gnus-group-prefixed-name group method)))
5532 ;; Check whether it exists already.
5533 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5534 (error "Group %s already exists." pgroup))
5535 ;; Subscribe the new group after the group on the current line.
5536 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5537 (gnus-group-update-group pgroup)
5539 (gnus-group-position-point)))
5541 (defun gnus-group-enter-directory (dir)
5542 "Enter an ephemeral nneething group."
5543 (interactive "DDirectory to read: ")
5544 (let* ((method (list 'nneething dir))
5545 (leaf (gnus-group-prefixed-name
5546 (file-name-nondirectory (directory-file-name dir))
5548 (name (gnus-generate-new-group-name leaf)))
5549 (let ((nneething-read-only t))
5550 (or (gnus-group-read-ephemeral-group
5552 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5554 (error "Couldn't enter %s" dir)))))
5556 ;; Group sorting commands
5557 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5559 (defun gnus-group-sort-groups (func &optional reverse)
5560 "Sort the group buffer according to FUNC.
5561 If REVERSE, reverse the sorting order."
5562 (interactive (list gnus-group-sort-function
5563 current-prefix-arg))
5565 ((not (listp func)) func)
5567 ((= 1 (length func)) (car func))
5569 ,(gnus-make-sort-function
5570 (reverse func)))))))
5571 ;; We peel off the dummy group from the alist.
5573 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5574 (pop gnus-newsrc-alist))
5576 (setq gnus-newsrc-alist
5577 (sort gnus-newsrc-alist func))
5579 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5580 ;; Regenerate the hash table.
5581 (gnus-make-hashtable-from-newsrc-alist)
5582 (gnus-group-list-groups))))
5584 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5585 "Sort the group buffer alphabetically by group name.
5586 If REVERSE, sort in reverse order."
5588 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5590 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5591 "Sort the group buffer by number of unread articles.
5592 If REVERSE, sort in reverse order."
5594 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5596 (defun gnus-group-sort-groups-by-level (&optional reverse)
5597 "Sort the group buffer by group level.
5598 If REVERSE, sort in reverse order."
5600 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5602 (defun gnus-group-sort-groups-by-score (&optional reverse)
5603 "Sort the group buffer by group score.
5604 If REVERSE, sort in reverse order."
5606 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5608 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5609 "Sort the group buffer by group rank.
5610 If REVERSE, sort in reverse order."
5612 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5614 (defun gnus-group-sort-groups-by-method (&optional reverse)
5615 "Sort the group buffer alphabetically by backend name.
5616 If REVERSE, sort in reverse order."
5618 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5620 (defun gnus-group-sort-by-alphabet (info1 info2)
5621 "Sort alphabetically."
5622 (string< (gnus-info-group info1) (gnus-info-group info2)))
5624 (defun gnus-group-sort-by-unread (info1 info2)
5625 "Sort by number of unread articles."
5626 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5627 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5628 (< (or (and (numberp n1) n1) 0)
5629 (or (and (numberp n2) n2) 0))))
5631 (defun gnus-group-sort-by-level (info1 info2)
5633 (< (gnus-info-level info1) (gnus-info-level info2)))
5635 (defun gnus-group-sort-by-method (info1 info2)
5636 "Sort alphabetically by backend name."
5637 (string< (symbol-name (car (gnus-find-method-for-group
5638 (gnus-info-group info1) info1)))
5639 (symbol-name (car (gnus-find-method-for-group
5640 (gnus-info-group info2) info2)))))
5642 (defun gnus-group-sort-by-score (info1 info2)
5643 "Sort by group score."
5644 (< (gnus-info-score info1) (gnus-info-score info2)))
5646 (defun gnus-group-sort-by-rank (info1 info2)
5647 "Sort by level and score."
5648 (let ((level1 (gnus-info-level info1))
5649 (level2 (gnus-info-level info2)))
5650 (or (< level1 level2)
5651 (and (= level1 level2)
5652 (< (gnus-info-score info1) (gnus-info-score info2))))))
5654 ;; Group catching up.
5656 (defun gnus-group-catchup-current (&optional n all)
5657 "Mark all articles not marked as unread in current newsgroup as read.
5658 If prefix argument N is numeric, the ARG next newsgroups will be
5659 caught up. If ALL is non-nil, marked articles will also be marked as
5660 read. Cross references (Xref: header) of articles are ignored.
5661 The difference between N and actual number of newsgroups that were
5662 caught up is returned."
5664 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5668 "Do you really want to mark all articles as read? "
5669 "Mark all unread articles as read? "))))
5671 (let ((groups (gnus-group-process-prefix n))
5674 ;; Virtual groups have to be given special treatment.
5675 (let ((method (gnus-find-method-for-group (car groups))))
5676 (if (eq 'nnvirtual (car method))
5677 (nnvirtual-catchup-group
5678 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5679 (gnus-group-remove-mark (car groups))
5681 (gnus-group-goto-group (car groups))
5682 (gnus-group-catchup (car groups) all))
5683 (gnus-group-update-group-line)
5684 (setq ret (1+ ret)))
5685 (setq groups (cdr groups)))
5686 (gnus-group-next-unread-group 1)
5689 (defun gnus-group-catchup-current-all (&optional n)
5690 "Mark all articles in current newsgroup as read.
5691 Cross references (Xref: header) of articles are ignored."
5693 (gnus-group-catchup-current n 'all))
5695 (defun gnus-group-catchup (group &optional all)
5696 "Mark all articles in GROUP as read.
5697 If ALL is non-nil, all articles are marked as read.
5698 The return value is the number of articles that were marked as read,
5699 or nil if no action could be taken."
5700 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5702 ;; Do the updating only if the newsgroup isn't killed.
5703 (if (not (numberp (car entry)))
5704 (gnus-message 1 "Can't catch up; non-active group")
5705 ;; Do auto-expirable marks if that's required.
5706 (when (gnus-group-auto-expirable-p group)
5707 (gnus-add-marked-articles
5708 group 'expire (gnus-list-of-unread-articles group))
5710 (let ((marks (nth 3 (nth 2 entry))))
5711 (gnus-add-marked-articles
5712 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5713 (gnus-add-marked-articles
5714 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5716 (gnus-update-read-articles group nil)
5717 ;; Also nix out the lists of marks and dormants.
5719 (gnus-add-marked-articles group 'tick nil nil 'force)
5720 (gnus-add-marked-articles group 'dormant nil nil 'force))
5723 (defun gnus-group-expire-articles (&optional n)
5724 "Expire all expirable articles in the current newsgroup."
5726 (let ((groups (gnus-group-process-prefix n))
5729 (error "No groups to expire"))
5730 (while (setq group (pop groups))
5731 (gnus-group-remove-mark group)
5732 (when (gnus-check-backend-function 'request-expire-articles group)
5733 (gnus-message 6 "Expiring articles in %s..." group)
5734 (let* ((info (gnus-get-info group))
5735 (expirable (if (gnus-group-total-expirable-p group)
5736 (cons nil (gnus-list-of-read-articles group))
5737 (assq 'expire (gnus-info-marks info))))
5738 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5741 (gnus-compress-sequence
5743 (let ((nnmail-expiry-wait-function nil)
5744 (nnmail-expiry-wait expiry-wait))
5745 (gnus-request-expire-articles
5746 (gnus-uncompress-sequence (cdr expirable)) group))
5747 (gnus-request-expire-articles
5748 (gnus-uncompress-sequence (cdr expirable))
5750 (gnus-message 6 "Expiring articles in %s...done" group)))
5751 (gnus-group-position-point))))
5754 (defun gnus-group-expire-all-groups ()
5755 "Expire all expirable articles in all newsgroups."
5758 (gnus-message 5 "Expiring...")
5759 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5760 (cdr gnus-newsrc-alist))))
5761 (gnus-group-expire-articles nil)))
5762 (gnus-group-position-point)
5763 (gnus-message 5 "Expiring...done"))
5765 (defun gnus-group-set-current-level (n level)
5766 "Set the level of the next N groups to LEVEL."
5771 (let ((s (read-string
5772 (format "Level (default %s): " (gnus-group-group-level)))))
5773 (if (string-match "^\\s-*$" s)
5774 (int-to-string (gnus-group-group-level))
5776 (or (and (>= level 1) (<= level gnus-level-killed))
5777 (error "Illegal level: %d" level))
5778 (let ((groups (gnus-group-process-prefix n))
5781 (setq group (car groups)
5782 groups (cdr groups))
5783 (gnus-group-remove-mark group)
5784 (gnus-message 6 "Changed level of %s from %d to %d"
5785 group (or (gnus-group-group-level) gnus-level-killed)
5787 (gnus-group-change-level
5788 group level (or (gnus-group-group-level) gnus-level-killed))
5789 (gnus-group-update-group-line)))
5790 (gnus-group-position-point))
5792 (defun gnus-group-unsubscribe-current-group (&optional n)
5793 "Toggle subscription of the current group.
5794 If given numerical prefix, toggle the N next groups."
5796 (let ((groups (gnus-group-process-prefix n))
5799 (setq group (car groups)
5800 groups (cdr groups))
5801 (gnus-group-remove-mark group)
5802 (gnus-group-unsubscribe-group
5803 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5804 gnus-level-default-unsubscribed
5805 gnus-level-default-subscribed) t)
5806 (gnus-group-update-group-line))
5807 (gnus-group-next-group 1)))
5809 (defun gnus-group-unsubscribe-group (group &optional level silent)
5810 "Toggle subscription to GROUP.
5811 Killed newsgroups are subscribed. If SILENT, don't try to update the
5814 (list (completing-read
5815 "Group: " gnus-active-hashtb nil
5816 (memq gnus-select-method gnus-have-read-active-file))))
5817 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5819 ((string-match "^[ \t]$" group)
5820 (error "Empty group name"))
5822 ;; Toggle subscription flag.
5823 (gnus-group-change-level
5824 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5825 gnus-level-subscribed)
5826 (1+ gnus-level-subscribed)
5827 gnus-level-default-subscribed)))
5829 (gnus-group-update-group group)))
5830 ((and (stringp group)
5831 (or (not (memq gnus-select-method gnus-have-read-active-file))
5832 (gnus-active group)))
5833 ;; Add new newsgroup.
5834 (gnus-group-change-level
5836 (if level level gnus-level-default-subscribed)
5837 (or (and (member group gnus-zombie-list)
5840 (and (gnus-group-group-name)
5841 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5843 (gnus-group-update-group group)))
5844 (t (error "No such newsgroup: %s" group)))
5845 (gnus-group-position-point)))
5847 (defun gnus-group-transpose-groups (n)
5848 "Move the current newsgroup up N places.
5849 If given a negative prefix, move down instead. The difference between
5850 N and the number of steps taken is returned."
5852 (or (gnus-group-group-name)
5853 (error "No group on current line"))
5854 (gnus-group-kill-group 1)
5856 (forward-line (- n))
5857 (gnus-group-yank-group)
5858 (gnus-group-position-point)))
5860 (defun gnus-group-kill-all-zombies ()
5861 "Kill all zombie newsgroups."
5863 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
5864 (setq gnus-zombie-list nil)
5865 (gnus-group-list-groups))
5867 (defun gnus-group-kill-region (begin end)
5868 "Kill newsgroups in current region (excluding current point).
5869 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
5884 (beginning-of-line) ;Important when LINES < 1
5885 (gnus-group-kill-group lines)))
5887 (defun gnus-group-kill-group (&optional n discard)
5888 "Kill the next N groups.
5889 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
5890 However, only groups that were alive can be yanked; already killed
5891 groups or zombie groups can't be yanked.
5892 The return value is the name of the group that was killed, or a list
5895 (let ((buffer-read-only nil)
5896 (groups (gnus-group-process-prefix n))
5897 group entry level out)
5898 (if (< (length groups) 10)
5899 ;; This is faster when there are few groups.
5901 (push (setq group (pop groups)) out)
5902 (gnus-group-remove-mark group)
5903 (setq level (gnus-group-group-level))
5905 (if (and (not discard)
5906 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
5907 (setq gnus-list-of-killed-groups
5908 (cons (cons (car entry) (nth 2 entry))
5909 gnus-list-of-killed-groups)))
5910 (gnus-group-change-level
5911 (if entry entry group) gnus-level-killed (if entry nil level)))
5912 ;; If there are lots and lots of groups to be killed, we use
5913 ;; this thing instead.
5915 (setq groups (nreverse groups))
5917 (gnus-group-remove-mark (car groups))
5919 (setq entry (gnus-gethash (pop groups) gnus-newsrc-hashtb))
5920 (push (cons (car entry) (nth 2 entry))
5921 gnus-list-of-killed-groups)
5922 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))
5923 (gnus-make-hashtable-from-newsrc-alist)))
5925 (gnus-group-position-point)
5926 (if (< (length out) 2) (car out) (nreverse out))))
5928 (defun gnus-group-yank-group (&optional arg)
5929 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
5930 inserting it before the current newsgroup. The numeric ARG specifies
5931 how many newsgroups are to be yanked. The name of the newsgroup yanked
5932 is returned, or (if several groups are yanked) a list of yanked groups
5935 (setq arg (or arg 1))
5936 (let (info group prev out)
5937 (while (>= (decf arg) 0)
5938 (if (not (setq info (pop gnus-list-of-killed-groups)))
5939 (error "No more newsgroups to yank"))
5940 (push (setq group (nth 1 info)) out)
5941 ;; Find which newsgroup to insert this one before - search
5942 ;; backward until something suitable is found. If there are no
5943 ;; other newsgroups in this buffer, just make this newsgroup the
5945 (setq prev (gnus-group-group-name))
5946 (gnus-group-change-level
5947 info (nth 2 info) gnus-level-killed
5948 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
5950 (gnus-group-insert-group-line-info group))
5952 (gnus-group-position-point)
5953 (if (< (length out) 2) (car out) (nreverse out))))
5955 (defun gnus-group-kill-level (level)
5956 "Kill all groups that is on a certain LEVEL."
5957 (interactive "nKill all groups on level: ")
5959 ((= level gnus-level-zombie)
5960 (setq gnus-killed-list
5961 (nconc gnus-zombie-list gnus-killed-list))
5962 (setq gnus-zombie-list nil))
5963 ((and (< level gnus-level-zombie)
5965 (or gnus-expert-user
5968 "Do you really want to kill all groups on level %d? "
5970 (let* ((prev gnus-newsrc-alist)
5973 (if (= (gnus-info-level level) level)
5974 (setcdr prev (cdr alist))
5976 (setq alist (cdr alist)))
5977 (gnus-make-hashtable-from-newsrc-alist)
5978 (gnus-group-list-groups)))
5980 (error "Can't kill; illegal level: %d" level))))
5982 (defun gnus-group-list-all-groups (&optional arg)
5983 "List all newsgroups with level ARG or lower.
5984 Default is gnus-level-unsubscribed, which lists all subscribed and most
5985 unsubscribed groups."
5987 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
5989 ;; Redefine this to list ALL killed groups if prefix arg used.
5990 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
5991 (defun gnus-group-list-killed (&optional arg)
5992 "List all killed newsgroups in the group buffer.
5993 If ARG is non-nil, list ALL killed groups known to Gnus. This may
5994 entail asking the server for the groups."
5996 ;; Find all possible killed newsgroups if arg.
5998 ;; First make sure active file has been read.
5999 (unless gnus-have-read-active-file
6000 (let ((gnus-read-active-file t))
6001 (gnus-read-active-file)))
6002 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6003 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6007 (group (symbol-name sym)))
6008 (if (or (null group)
6009 (gnus-gethash group gnus-killed-hashtb)
6010 (gnus-gethash group gnus-newsrc-hashtb))
6012 (let ((do-sub (gnus-matches-options-n group)))
6013 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6015 (setq groups (1+ groups))
6016 (setq gnus-killed-list
6017 (cons group gnus-killed-list))
6018 (gnus-sethash group group gnus-killed-hashtb))))))
6019 gnus-active-hashtb))
6020 (if (not gnus-killed-list)
6021 (gnus-message 6 "No killed groups")
6022 (let (gnus-group-list-mode)
6023 (funcall gnus-group-prepare-function
6024 gnus-level-killed t gnus-level-killed))
6025 (goto-char (point-min)))
6026 (gnus-group-position-point))
6028 (defun gnus-group-list-zombies ()
6029 "List all zombie newsgroups in the group buffer."
6031 (if (not gnus-zombie-list)
6032 (gnus-message 6 "No zombie groups")
6033 (let (gnus-group-list-mode)
6034 (funcall gnus-group-prepare-function
6035 gnus-level-zombie t gnus-level-zombie))
6036 (goto-char (point-min)))
6037 (gnus-group-position-point))
6039 (defun gnus-group-list-active ()
6040 "List all groups that are available from the server(s)."
6042 ;; First we make sure that we have really read the active file.
6043 (unless gnus-have-read-active-file
6044 (let ((gnus-read-active-file t))
6045 (gnus-read-active-file)))
6046 ;; Find all groups and sort them.
6052 (and (symbol-value sym)
6053 (setq list (cons (symbol-name sym) list))))
6057 (buffer-read-only nil))
6060 (gnus-group-insert-group-line-info (car groups))
6061 (setq groups (cdr groups)))
6062 (goto-char (point-min))))
6064 (defun gnus-activate-all-groups (level)
6065 "Activate absolutely all groups."
6066 (interactive (list 7))
6067 (let ((gnus-activate-level level)
6068 (gnus-activate-foreign-newsgroups level))
6069 (gnus-group-get-new-news)))
6071 (defun gnus-group-get-new-news (&optional arg)
6072 "Get newly arrived articles.
6073 If ARG is a number, it specifies which levels you are interested in
6074 re-scanning. If ARG is non-nil and not a number, this will force
6075 \"hard\" re-reading of the active files from all servers."
6077 (run-hooks 'gnus-get-new-news-hook)
6078 ;; We might read in new NoCeM messages here.
6079 (and gnus-use-nocem (gnus-nocem-scan-groups))
6080 ;; If ARG is not a number, then we read the active file.
6084 (let ((gnus-read-active-file t))
6085 (gnus-read-active-file))
6088 (setq arg (gnus-group-default-level arg t))
6089 (if (and gnus-read-active-file (not arg))
6091 (gnus-read-active-file)
6092 (gnus-get-unread-articles arg))
6093 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6094 (gnus-get-unread-articles arg)))
6095 (gnus-group-list-groups))
6097 (defun gnus-group-get-new-news-this-group (&optional n)
6098 "Check for newly arrived news in the current group (and the N-1 next groups).
6099 The difference between N and the number of newsgroup checked is returned.
6100 If N is negative, this group and the N-1 previous groups will be checked."
6102 (let* ((groups (gnus-group-process-prefix n))
6103 (ret (if (numberp n) (- n (length groups)) 0))
6106 (setq group (car groups)
6107 groups (cdr groups))
6108 (gnus-group-remove-mark group)
6109 (unless (gnus-get-new-news-in-group group)
6111 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6112 (when gnus-goto-next-group-when-activating
6113 (gnus-group-next-unread-group 1 t))
6114 (gnus-summary-position-point)
6117 (defun gnus-get-new-news-in-group (group)
6118 (when (and group (gnus-activate-group group 'scan))
6119 (gnus-get-unread-articles-in-group
6120 (gnus-get-info group) (gnus-active group) t)
6121 (when (gnus-group-goto-group group)
6122 (gnus-group-update-group-line))
6125 (defun gnus-group-fetch-faq (group &optional faq-dir)
6126 "Fetch the FAQ for the current group."
6129 (gnus-group-real-name (gnus-group-group-name))
6130 (cond (current-prefix-arg
6132 "Faq dir: " (and (listp gnus-group-faq-directory)
6133 gnus-group-faq-directory))))))
6135 (setq faq-dir (if (listp gnus-group-faq-directory)
6136 (car gnus-group-faq-directory)
6137 gnus-group-faq-directory)))
6138 (or group (error "No group name given"))
6139 (let ((file (concat (file-name-as-directory faq-dir)
6140 (gnus-group-real-name group))))
6141 (if (not (file-exists-p file))
6142 (error "No such file: %s" file)
6145 (defun gnus-group-describe-group (force &optional group)
6146 "Display a description of the current newsgroup."
6147 (interactive (list current-prefix-arg (gnus-group-group-name)))
6148 (and force (setq gnus-description-hashtb nil))
6149 (let ((method (gnus-find-method-for-group group))
6151 (or group (error "No group name given"))
6152 (and (or (and gnus-description-hashtb
6153 ;; We check whether this group's method has been
6154 ;; queried for a description file.
6156 (gnus-group-prefixed-name "" method)
6157 gnus-description-hashtb))
6158 (setq desc (gnus-group-get-description group))
6159 (gnus-read-descriptions-file method))
6161 (or desc (gnus-gethash group gnus-description-hashtb)
6162 "No description available")))))
6164 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6165 (defun gnus-group-describe-all-groups (&optional force)
6166 "Pop up a buffer with descriptions of all newsgroups."
6168 (and force (setq gnus-description-hashtb nil))
6169 (if (not (or gnus-description-hashtb
6170 (gnus-read-all-descriptions-files)))
6171 (error "Couldn't request descriptions file"))
6172 (let ((buffer-read-only nil)
6178 (insert (format " *: %-20s %s\n" (symbol-name group)
6179 (symbol-value group)))
6180 (add-text-properties
6181 b (1+ b) (list 'gnus-group group
6182 'gnus-unread t 'gnus-marked nil
6183 'gnus-level (1+ gnus-level-subscribed))))
6184 gnus-description-hashtb)
6185 (goto-char (point-min))
6186 (gnus-group-position-point)))
6188 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6189 (defun gnus-group-apropos (regexp &optional search-description)
6190 "List all newsgroups that have names that match a regexp."
6191 (interactive "sGnus apropos (regexp): ")
6193 (obuf (current-buffer))
6195 ;; Go through all newsgroups that are known to Gnus.
6198 (and (symbol-name group)
6199 (string-match regexp (symbol-name group))
6200 (setq groups (cons (symbol-name group) groups))))
6202 ;; Go through all descriptions that are known to Gnus.
6203 (if search-description
6206 (and (string-match regexp (symbol-value group))
6207 (gnus-active (symbol-name group))
6208 (setq groups (cons (symbol-name group) groups))))
6209 gnus-description-hashtb))
6211 (gnus-message 3 "No groups matched \"%s\"." regexp)
6212 ;; Print out all the groups.
6214 (pop-to-buffer "*Gnus Help*")
6215 (buffer-disable-undo (current-buffer))
6217 (setq groups (sort groups 'string<))
6219 ;; Groups may be entered twice into the list of groups.
6220 (if (not (string= (car groups) prev))
6222 (insert (setq prev (car groups)) "\n")
6223 (if (and gnus-description-hashtb
6224 (setq des (gnus-gethash (car groups)
6225 gnus-description-hashtb)))
6226 (insert " " des "\n"))))
6227 (setq groups (cdr groups)))
6228 (goto-char (point-min))))
6229 (pop-to-buffer obuf)))
6231 (defun gnus-group-description-apropos (regexp)
6232 "List all newsgroups that have names or descriptions that match a regexp."
6233 (interactive "sGnus description apropos (regexp): ")
6234 (if (not (or gnus-description-hashtb
6235 (gnus-read-all-descriptions-files)))
6236 (error "Couldn't request descriptions file"))
6237 (gnus-group-apropos regexp t))
6239 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6240 (defun gnus-group-list-matching (level regexp &optional all lowest)
6241 "List all groups with unread articles that match REGEXP.
6242 If the prefix LEVEL is non-nil, it should be a number that says which
6243 level to cut off listing groups.
6244 If ALL, also list groups with no unread articles.
6245 If LOWEST, don't list groups with level lower than LOWEST."
6246 (interactive "P\nsList newsgroups matching: ")
6247 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6248 all (or lowest 1) regexp)
6249 (goto-char (point-min))
6250 (gnus-group-position-point))
6252 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6253 "List all groups that match REGEXP.
6254 If the prefix LEVEL is non-nil, it should be a number that says which
6255 level to cut off listing groups.
6256 If LOWEST, don't list groups with level lower than LOWEST."
6257 (interactive "P\nsList newsgroups matching: ")
6258 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6260 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6261 (defun gnus-group-save-newsrc (&optional force)
6262 "Save the Gnus startup files.
6263 If FORCE, force saving whether it is necessary or not."
6265 (gnus-save-newsrc-file force))
6267 (defun gnus-group-restart (&optional arg)
6268 "Force Gnus to read the .newsrc file."
6270 (gnus-save-newsrc-file)
6271 (gnus-setup-news 'force)
6272 (gnus-group-list-groups arg))
6274 (defun gnus-group-read-init-file ()
6275 "Read the Gnus elisp init file."
6277 (gnus-read-init-file))
6279 (defun gnus-group-check-bogus-groups (&optional silent)
6280 "Check bogus newsgroups.
6281 If given a prefix, don't ask for confirmation before removing a bogus
6284 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6285 (gnus-group-list-groups))
6287 (defun gnus-group-edit-global-kill (&optional article group)
6288 "Edit the global kill file.
6289 If GROUP, edit that local kill file instead."
6291 (setq gnus-current-kill-article article)
6292 (gnus-kill-file-edit-file group)
6295 (substitute-command-keys
6296 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6297 (if group "local" "global")))))
6299 (defun gnus-group-edit-local-kill (article group)
6300 "Edit a local kill file."
6301 (interactive (list nil (gnus-group-group-name)))
6302 (gnus-group-edit-global-kill article group))
6304 (defun gnus-group-force-update ()
6305 "Update `.newsrc' file."
6307 (gnus-save-newsrc-file))
6309 (defun gnus-group-suspend ()
6310 "Suspend the current Gnus session.
6311 In fact, cleanup buffers except for group mode buffer.
6312 The hook gnus-suspend-gnus-hook is called before actually suspending."
6314 (run-hooks 'gnus-suspend-gnus-hook)
6315 ;; Kill Gnus buffers except for group mode buffer.
6316 (let ((group-buf (get-buffer gnus-group-buffer)))
6317 ;; Do this on a separate list in case the user does a ^G before we finish
6318 (let ((gnus-buffer-list
6319 (delq group-buf (delq gnus-dribble-buffer
6320 (append gnus-buffer-list nil)))))
6321 (while gnus-buffer-list
6322 (gnus-kill-buffer (car gnus-buffer-list))
6323 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6326 (setq gnus-buffer-list (list group-buf))
6327 (bury-buffer group-buf)
6328 (delete-windows-on group-buf t)))))
6330 (defun gnus-group-clear-dribble ()
6331 "Clear all information from the dribble buffer."
6333 (gnus-dribble-clear)
6334 (gnus-message 7 "Cleared dribble buffer"))
6336 (defun gnus-group-exit ()
6337 "Quit reading news after updating .newsrc.eld and .newsrc.
6338 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6340 (if (or noninteractive ;For gnus-batch-kill
6341 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6342 (not gnus-interactive-exit) ;Without confirmation
6344 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6346 (run-hooks 'gnus-exit-gnus-hook)
6347 ;; Offer to save data from non-quitted summary buffers.
6348 (gnus-offer-save-summaries)
6349 ;; Save the newsrc file(s).
6350 (gnus-save-newsrc-file)
6352 (gnus-close-backends)
6353 ;; Shut down the cache.
6354 (when gnus-use-cache
6356 ;; Reset everything.
6357 (gnus-clear-system))))
6359 (defun gnus-close-backends ()
6360 ;; Send a close request to all backends that support such a request.
6361 (let ((methods gnus-valid-select-methods)
6364 (if (fboundp (setq func (intern (concat (car (car methods))
6365 "-request-close"))))
6367 (setq methods (cdr methods)))))
6369 (defun gnus-group-quit ()
6370 "Quit reading news without updating .newsrc.eld or .newsrc.
6371 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6373 (when (or noninteractive ;For gnus-batch-kill
6374 (zerop (buffer-size))
6375 (not (gnus-server-opened gnus-select-method))
6377 (not gnus-current-startup-file)
6379 (format "Quit reading news without saving %s? "
6380 (file-name-nondirectory gnus-current-startup-file))))
6381 (run-hooks 'gnus-exit-gnus-hook)
6382 (if gnus-use-full-window
6383 (delete-other-windows)
6384 (gnus-remove-some-windows))
6386 (gnus-close-backends)
6387 ;; Shut down the cache.
6388 (when gnus-use-cache
6390 (gnus-clear-system)))
6392 (defun gnus-offer-save-summaries ()
6393 "Offer to save all active summary buffers."
6395 (let ((buflist (buffer-list))
6397 ;; Go through all buffers and find all summaries.
6399 (and (setq bufname (buffer-name (car buflist)))
6400 (string-match "Summary" bufname)
6402 (set-buffer bufname)
6403 ;; We check that this is, indeed, a summary buffer.
6404 (and (eq major-mode 'gnus-summary-mode)
6405 ;; Also make sure this isn't bogus.
6406 gnus-newsgroup-prepared))
6407 (push bufname buffers))
6408 (setq buflist (cdr buflist)))
6409 ;; Go through all these summary buffers and offer to save them.
6412 "Update summary buffer %s? "
6413 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6416 (defun gnus-group-describe-briefly ()
6417 "Give a one line description of the group mode commands."
6419 (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")))
6421 (defun gnus-group-browse-foreign-server (method)
6422 "Browse a foreign news server.
6423 If called interactively, this function will ask for a select method
6424 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6425 If not, METHOD should be a list where the first element is the method
6426 and the second element is the address."
6428 (list (let ((how (completing-read
6430 (append gnus-valid-select-methods gnus-server-alist)
6431 nil t (cons "nntp" 0))))
6432 ;; We either got a backend name or a virtual server name.
6433 ;; If the first, we also need an address.
6434 (if (assoc how gnus-valid-select-methods)
6436 ;; Suggested by mapjph@bath.ac.uk.
6439 (mapcar (lambda (server) (list server))
6440 gnus-secondary-servers)))
6441 ;; We got a server name, so we find the method.
6442 (gnus-server-to-method how)))))
6443 (gnus-browse-foreign-server method))
6447 ;;; Gnus summary mode
6450 (defvar gnus-summary-mode-map nil)
6452 (put 'gnus-summary-mode 'mode-class 'special)
6454 (unless gnus-summary-mode-map
6455 (setq gnus-summary-mode-map (make-keymap))
6456 (suppress-keymap gnus-summary-mode-map)
6458 ;; Non-orthogonal keys
6461 gnus-summary-mode-map
6462 " " gnus-summary-next-page
6463 "\177" gnus-summary-prev-page
6464 "\r" gnus-summary-scroll-up
6465 "n" gnus-summary-next-unread-article
6466 "p" gnus-summary-prev-unread-article
6467 "N" gnus-summary-next-article
6468 "P" gnus-summary-prev-article
6469 "\M-\C-n" gnus-summary-next-same-subject
6470 "\M-\C-p" gnus-summary-prev-same-subject
6471 "\M-n" gnus-summary-next-unread-subject
6472 "\M-p" gnus-summary-prev-unread-subject
6473 "." gnus-summary-first-unread-article
6474 "," gnus-summary-best-unread-article
6475 "\M-s" gnus-summary-search-article-forward
6476 "\M-r" gnus-summary-search-article-backward
6477 "<" gnus-summary-beginning-of-article
6478 ">" gnus-summary-end-of-article
6479 "j" gnus-summary-goto-article
6480 "^" gnus-summary-refer-parent-article
6481 "\M-^" gnus-summary-refer-article
6482 "u" gnus-summary-tick-article-forward
6483 "!" gnus-summary-tick-article-forward
6484 "U" gnus-summary-tick-article-backward
6485 "d" gnus-summary-mark-as-read-forward
6486 "D" gnus-summary-mark-as-read-backward
6487 "E" gnus-summary-mark-as-expirable
6488 "\M-u" gnus-summary-clear-mark-forward
6489 "\M-U" gnus-summary-clear-mark-backward
6490 "k" gnus-summary-kill-same-subject-and-select
6491 "\C-k" gnus-summary-kill-same-subject
6492 "\M-\C-k" gnus-summary-kill-thread
6493 "\M-\C-l" gnus-summary-lower-thread
6494 "e" gnus-summary-edit-article
6495 "#" gnus-summary-mark-as-processable
6496 "\M-#" gnus-summary-unmark-as-processable
6497 "\M-\C-t" gnus-summary-toggle-threads
6498 "\M-\C-s" gnus-summary-show-thread
6499 "\M-\C-h" gnus-summary-hide-thread
6500 "\M-\C-f" gnus-summary-next-thread
6501 "\M-\C-b" gnus-summary-prev-thread
6502 "\M-\C-u" gnus-summary-up-thread
6503 "\M-\C-d" gnus-summary-down-thread
6504 "&" gnus-summary-execute-command
6505 "c" gnus-summary-catchup-and-exit
6506 "\C-w" gnus-summary-mark-region-as-read
6507 "\C-t" gnus-summary-toggle-truncation
6508 "?" gnus-summary-mark-as-dormant
6509 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6510 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6511 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6512 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6513 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6514 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6515 "=" gnus-summary-expand-window
6516 "\C-x\C-s" gnus-summary-reselect-current-group
6517 "\M-g" gnus-summary-rescan-group
6518 "w" gnus-summary-stop-page-breaking
6519 "\C-c\C-r" gnus-summary-caesar-message
6520 "\M-t" gnus-summary-toggle-mime
6521 "f" gnus-summary-followup
6522 "F" gnus-summary-followup-with-original
6523 "C" gnus-summary-cancel-article
6524 "r" gnus-summary-reply
6525 "R" gnus-summary-reply-with-original
6526 "\C-c\C-f" gnus-summary-mail-forward
6527 "o" gnus-summary-save-article
6528 "\C-o" gnus-summary-save-article-mail
6529 "|" gnus-summary-pipe-output
6530 "\M-k" gnus-summary-edit-local-kill
6531 "\M-K" gnus-summary-edit-global-kill
6533 "\C-c\C-d" gnus-summary-describe-group
6534 "q" gnus-summary-exit
6535 "Q" gnus-summary-exit-no-update
6536 "\C-c\C-i" gnus-info-find-node
6537 gnus-mouse-2 gnus-mouse-pick-article
6538 "m" gnus-summary-mail-other-window
6539 "a" gnus-summary-post-news
6540 "x" gnus-summary-limit-to-unread
6541 "s" gnus-summary-isearch-article
6542 "t" gnus-summary-toggle-header
6543 "g" gnus-summary-show-article
6544 "l" gnus-summary-goto-last-article
6545 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6546 "\C-d" gnus-summary-enter-digest-group
6547 "v" gnus-summary-verbose-headers
6549 "*" gnus-cache-enter-article
6550 "\M-*" gnus-cache-remove-article
6551 "\M-&" gnus-summary-universal-argument
6552 "\C-l" gnus-recenter
6553 "D" gnus-summary-enter-digest-group
6554 "I" gnus-summary-increase-score
6555 "L" gnus-summary-lower-score
6557 "V" gnus-summary-score-map
6558 "X" gnus-uu-extract-map
6559 "S" gnus-summary-send-map)
6561 ;; Sort of orthogonal keymap
6563 (gnus-summary-mark-map "M" gnus-summary-mode-map)
6564 "t" gnus-summary-tick-article-forward
6565 "!" gnus-summary-tick-article-forward
6566 "d" gnus-summary-mark-as-read-forward
6567 "r" gnus-summary-mark-as-read-forward
6568 "c" gnus-summary-clear-mark-forward
6569 " " gnus-summary-clear-mark-forward
6570 "e" gnus-summary-mark-as-expirable
6571 "x" gnus-summary-mark-as-expirable
6572 "?" gnus-summary-mark-as-dormant
6573 "b" gnus-summary-set-bookmark
6574 "B" gnus-summary-remove-bookmark
6575 "#" gnus-summary-mark-as-processable
6576 "\M-#" gnus-summary-unmark-as-processable
6577 "S" gnus-summary-limit-include-expunged
6578 "C" gnus-summary-catchup
6579 "H" gnus-summary-catchup-to-here
6580 "\C-c" gnus-summary-catchup-all
6581 "k" gnus-summary-kill-same-subject-and-select
6582 "K" gnus-summary-kill-same-subject
6583 "P" gnus-uu-mark-map)
6586 (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6587 "c" gnus-summary-clear-above
6588 "u" gnus-summary-tick-above
6589 "m" gnus-summary-mark-above
6590 "k" gnus-summary-kill-below)
6593 (gnus-summary-limit-map "/" gnus-summary-mode-map)
6594 "/" gnus-summary-limit-to-subject
6595 "n" gnus-summary-limit-to-articles
6596 "w" gnus-summary-pop-limit
6597 "s" gnus-summary-limit-to-subject
6598 "a" gnus-summary-limit-to-author
6599 "u" gnus-summary-limit-to-unread
6600 "m" gnus-summary-limit-to-marks
6601 "v" gnus-summary-limit-to-score
6602 "D" gnus-summary-limit-include-dormant
6603 "d" gnus-summary-limit-exclude-dormant
6604 ;; "t" gnus-summary-limit-exclude-thread
6605 "E" gnus-summary-limit-include-expunged
6606 "c" gnus-summary-limit-exclude-childless-dormant
6607 "C" gnus-summary-limit-mark-excluded-as-read)
6610 (gnus-summary-goto-map "G" gnus-summary-mode-map)
6611 "n" gnus-summary-next-unread-article
6612 "p" gnus-summary-prev-unread-article
6613 "N" gnus-summary-next-article
6614 "P" gnus-summary-prev-article
6615 "\C-n" gnus-summary-next-same-subject
6616 "\C-p" gnus-summary-prev-same-subject
6617 "\M-n" gnus-summary-next-unread-subject
6618 "\M-p" gnus-summary-prev-unread-subject
6619 "f" gnus-summary-first-unread-article
6620 "b" gnus-summary-best-unread-article
6621 "g" gnus-summary-goto-subject
6622 "l" gnus-summary-goto-last-article
6623 "p" gnus-summary-pop-article)
6626 (gnus-summary-thread-map "T" gnus-summary-mode-map)
6627 "k" gnus-summary-kill-thread
6628 "l" gnus-summary-lower-thread
6629 "i" gnus-summary-raise-thread
6630 "T" gnus-summary-toggle-threads
6631 "t" gnus-summary-rethread-current
6632 "^" gnus-summary-reparent-thread
6633 "s" gnus-summary-show-thread
6634 "S" gnus-summary-show-all-threads
6635 "h" gnus-summary-hide-thread
6636 "H" gnus-summary-hide-all-threads
6637 "n" gnus-summary-next-thread
6638 "p" gnus-summary-prev-thread
6639 "u" gnus-summary-up-thread
6640 "o" gnus-summary-top-thread
6641 "d" gnus-summary-down-thread
6642 "#" gnus-uu-mark-thread
6643 "\M-#" gnus-uu-unmark-thread)
6646 (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6647 "c" gnus-summary-catchup-and-exit
6648 "C" gnus-summary-catchup-all-and-exit
6649 "E" gnus-summary-exit-no-update
6650 "Q" gnus-summary-exit
6651 "Z" gnus-summary-exit
6652 "n" gnus-summary-catchup-and-goto-next-group
6653 "R" gnus-summary-reselect-current-group
6654 "G" gnus-summary-rescan-group
6655 "N" gnus-summary-next-group
6656 "P" gnus-summary-prev-group)
6659 (gnus-summary-article-map "A" gnus-summary-mode-map)
6660 " " gnus-summary-next-page
6661 "n" gnus-summary-next-page
6662 "\177" gnus-summary-prev-page
6663 "p" gnus-summary-prev-page
6664 "\r" gnus-summary-scroll-up
6665 "<" gnus-summary-beginning-of-article
6666 ">" gnus-summary-end-of-article
6667 "b" gnus-summary-beginning-of-article
6668 "e" gnus-summary-end-of-article
6669 "^" gnus-summary-refer-parent-article
6670 "r" gnus-summary-refer-parent-article
6671 "R" gnus-summary-refer-references
6672 "g" gnus-summary-show-article
6673 "s" gnus-summary-isearch-article)
6676 (gnus-summary-wash-map "W" gnus-summary-mode-map)
6677 "b" gnus-article-add-buttons
6678 "B" gnus-article-add-buttons-to-head
6679 "o" gnus-article-treat-overstrike
6680 ;; "w" gnus-article-word-wrap
6681 "w" gnus-article-fill-cited-article
6682 "c" gnus-article-remove-cr
6683 "L" gnus-article-remove-trailing-blank-lines
6684 "q" gnus-article-de-quoted-unreadable
6685 "f" gnus-article-display-x-face
6686 "l" gnus-summary-stop-page-breaking
6687 "r" gnus-summary-caesar-message
6688 "t" gnus-summary-toggle-header
6689 "m" gnus-summary-toggle-mime)
6692 (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6693 "a" gnus-article-hide
6694 "h" gnus-article-hide-headers
6695 "b" gnus-article-hide-boring-headers
6696 "s" gnus-article-hide-signature
6697 "c" gnus-article-hide-citation
6698 "p" gnus-article-hide-pgp
6699 "\C-c" gnus-article-hide-citation-maybe)
6702 (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6703 "a" gnus-article-highlight
6704 "h" gnus-article-highlight-headers
6705 "c" gnus-article-highlight-citation
6706 "s" gnus-article-highlight-signature)
6709 (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6710 "z" gnus-article-date-ut
6711 "u" gnus-article-date-ut
6712 "l" gnus-article-date-local
6713 "e" gnus-article-date-lapsed
6714 "o" gnus-article-date-original)
6717 (gnus-summary-help-map "H" gnus-summary-mode-map)
6719 "f" gnus-summary-fetch-faq
6720 "d" gnus-summary-describe-group
6721 "h" gnus-summary-describe-briefly
6722 "i" gnus-info-find-node)
6725 (gnus-summary-backend-map "B" gnus-summary-mode-map)
6726 "e" gnus-summary-expire-articles
6727 "\M-\C-e" gnus-summary-expire-articles-now
6728 "\177" gnus-summary-delete-article
6729 "m" gnus-summary-move-article
6730 "r" gnus-summary-respool-article
6731 "w" gnus-summary-edit-article
6732 "c" gnus-summary-copy-article
6733 "B" gnus-summary-crosspost-article
6734 "q" gnus-summary-respool-query
6735 "i" gnus-summary-import-article)
6738 (gnus-summary-save-map "O" gnus-summary-mode-map)
6739 "o" gnus-summary-save-article
6740 "m" gnus-summary-save-article-mail
6741 "r" gnus-summary-save-article-rmail
6742 "f" gnus-summary-save-article-file
6743 "b" gnus-summary-save-article-body-file
6744 "h" gnus-summary-save-article-folder
6745 "v" gnus-summary-save-article-vm
6746 "p" gnus-summary-pipe-output
6747 "s" gnus-soup-add-article)
6753 (defun gnus-summary-mode (&optional group)
6754 "Major mode for reading articles.
6756 All normal editing commands are switched off.
6757 \\<gnus-summary-mode-map>
6758 Each line in this buffer represents one article. To read an
6759 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6760 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6763 You can also post articles and send mail from this buffer. To
6764 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6765 of an article, type `\\[gnus-summary-reply]'.
6767 There are approx. one gazillion commands you can execute in this
6768 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6770 The following commands are available:
6772 \\{gnus-summary-mode-map}"
6774 (when (and menu-bar-mode
6775 (gnus-visual-p 'summary-menu 'menu))
6776 (gnus-summary-make-menu-bar))
6777 (kill-all-local-variables)
6778 (let ((locals gnus-summary-local-variables))
6780 (if (consp (car locals))
6782 (make-local-variable (car (car locals)))
6783 (set (car (car locals)) (eval (cdr (car locals)))))
6784 (make-local-variable (car locals))
6785 (set (car locals) nil))
6786 (setq locals (cdr locals))))
6787 (gnus-make-thread-indent-array)
6788 (gnus-simplify-mode-line)
6789 (setq major-mode 'gnus-summary-mode)
6790 (setq mode-name "Summary")
6791 (make-local-variable 'minor-mode-alist)
6792 (use-local-map gnus-summary-mode-map)
6793 (buffer-disable-undo (current-buffer))
6794 (setq buffer-read-only t) ;Disable modification
6795 (setq truncate-lines t)
6796 (setq selective-display t)
6797 (setq selective-display-ellipses t) ;Display `...'
6798 (setq buffer-display-table gnus-summary-display-table)
6799 (setq gnus-newsgroup-name group)
6800 (run-hooks 'gnus-summary-mode-hook))
6802 (defun gnus-summary-make-display-table ()
6803 ;; Change the display table. Odd characters have a tendency to mess
6804 ;; up nicely formatted displays - we make all possible glyphs
6805 ;; display only a single character.
6807 ;; We start from the standard display table, if any.
6808 (setq gnus-summary-display-table
6809 (or (copy-sequence standard-display-table)
6810 (make-display-table)))
6811 ;; Nix out all the control chars...
6813 (while (>= (setq i (1- i)) 0)
6814 (aset gnus-summary-display-table i [??])))
6815 ;; ... but not newline and cr, of course. (cr is necessary for the
6816 ;; selective display).
6817 (aset gnus-summary-display-table ?\n nil)
6818 (aset gnus-summary-display-table ?\r nil)
6819 ;; We nix out any glyphs over 126 that are not set already.
6821 (while (>= (setq i (1- i)) 127)
6822 ;; Only modify if the entry is nil.
6823 (or (aref gnus-summary-display-table i)
6824 (aset gnus-summary-display-table i [??])))))
6826 (defun gnus-summary-clear-local-variables ()
6827 (let ((locals gnus-summary-local-variables))
6829 (if (consp (car locals))
6830 (and (vectorp (car (car locals)))
6831 (set (car (car locals)) nil))
6832 (and (vectorp (car locals))
6833 (set (car locals) nil)))
6834 (setq locals (cdr locals)))))
6836 ;; Summary data functions.
6838 (defmacro gnus-data-number (data)
6841 (defmacro gnus-data-set-number (data number)
6842 `(setcar ,data ,number))
6844 (defmacro gnus-data-mark (data)
6847 (defmacro gnus-data-set-mark (data mark)
6848 `(setcar (nthcdr 1 ,data) ,mark))
6850 (defmacro gnus-data-pos (data)
6853 (defmacro gnus-data-set-pos (data pos)
6854 `(setcar (nthcdr 2 ,data) ,pos))
6856 (defmacro gnus-data-header (data)
6859 (defmacro gnus-data-level (data)
6862 (defmacro gnus-data-unread-p (data)
6863 `(= (nth 1 ,data) gnus-unread-mark))
6865 (defmacro gnus-data-pseudo-p (data)
6866 `(consp (nth 3 ,data)))
6868 (defmacro gnus-data-find (number)
6869 `(assq ,number gnus-newsgroup-data))
6871 (defmacro gnus-data-find-list (number &optional data)
6872 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
6873 (memq (assq ,number bdata)
6876 (defmacro gnus-data-make (number mark pos header level)
6877 `(list ,number ,mark ,pos ,header ,level))
6879 (defun gnus-data-enter (after-article number mark pos header level offset)
6880 (let ((data (gnus-data-find-list after-article)))
6881 (or data (error "No such article: %d" after-article))
6882 (setcdr data (cons (gnus-data-make number mark pos header level)
6884 (setq gnus-newsgroup-data-reverse nil)
6885 (gnus-data-update-list (cdr (cdr data)) offset)))
6887 (defun gnus-data-enter-list (after-article list &optional offset)
6889 (let ((data (and after-article (gnus-data-find-list after-article)))
6891 (or data (not after-article) (error "No such article: %d" after-article))
6892 ;; Find the last element in the list to be spliced into the main
6895 (setq list (cdr list)))
6898 (setcdr list gnus-newsgroup-data)
6899 (setq gnus-newsgroup-data ilist)
6900 (and offset (gnus-data-update-list (cdr list) offset)))
6901 (setcdr list (cdr data))
6903 (and offset (gnus-data-update-list (cdr data) offset)))
6904 (setq gnus-newsgroup-data-reverse nil))))
6906 (defun gnus-data-remove (article &optional offset)
6907 (let ((data gnus-newsgroup-data))
6908 (if (= (gnus-data-number (car data)) article)
6909 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
6910 gnus-newsgroup-data-reverse nil)
6912 (and (= (gnus-data-number (car (cdr data))) article)
6914 (setcdr data (cdr (cdr data)))
6915 (and offset (gnus-data-update-list (cdr data) offset))
6917 gnus-newsgroup-data-reverse nil)))
6918 (setq data (cdr data))))))
6920 (defmacro gnus-data-list (backward)
6922 (or gnus-newsgroup-data-reverse
6923 (setq gnus-newsgroup-data-reverse
6924 (reverse gnus-newsgroup-data)))
6925 gnus-newsgroup-data))
6927 (defun gnus-data-update-list (data offset)
6928 "Add OFFSET to the POS of all data entries in DATA."
6930 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
6931 (setq data (cdr data))))
6933 (defun gnus-data-compute-positions ()
6934 "Compute the positions of all articles."
6935 (let ((data gnus-newsgroup-data)
6938 (when (setq pos (text-property-any
6939 (point-min) (point-max)
6940 'gnus-number (gnus-data-number (car data))))
6941 (gnus-data-set-pos (car data) (+ pos 3)))
6942 (setq data (cdr data)))))
6944 (defun gnus-summary-article-pseudo-p (article)
6945 "Say whether this article is a pseudo article or not."
6946 (not (vectorp (gnus-data-header (gnus-data-find article)))))
6948 (defun gnus-article-parent-p (number)
6949 "Say whether this article is a parent or not."
6950 (let* ((data (gnus-data-find-list number)))
6951 (and (cdr data) ; There has to be an article after...
6952 (< (gnus-data-level (car data)) ; And it has to have a higher level.
6953 (gnus-data-level (nth 1 data))))))
6955 (defmacro gnus-summary-skip-intangible ()
6956 "If the current article is intangible, then jump to a different article."
6957 '(let ((to (get-text-property (point) 'gnus-intangible)))
6959 (gnus-summary-goto-subject to))))
6961 (defmacro gnus-summary-article-intangible-p ()
6962 "Say whether this article is intangible or not."
6963 '(get-text-property (point) 'gnus-intangible))
6965 ;; Some summary mode macros.
6967 (defmacro gnus-summary-article-number ()
6968 "The article number of the article on the current line.
6969 If there isn's an article number here, then we return the current
6972 (gnus-summary-skip-intangible)
6973 (or (get-text-property (point) 'gnus-number)
6974 (gnus-summary-last-subject))))
6976 (defmacro gnus-summary-article-header (&optional number)
6977 `(gnus-data-header (gnus-data-find
6978 ,(or number '(gnus-summary-article-number)))))
6980 (defmacro gnus-summary-thread-level (&optional number)
6981 `(if (and (eq gnus-summary-make-false-root 'dummy)
6982 (get-text-property (point) 'gnus-intangible))
6984 (gnus-data-level (gnus-data-find
6985 ,(or number '(gnus-summary-article-number))))))
6987 (defmacro gnus-summary-article-mark (&optional number)
6988 `(gnus-data-mark (gnus-data-find
6989 ,(or number '(gnus-summary-article-number)))))
6991 (defmacro gnus-summary-article-pos (&optional number)
6992 `(gnus-data-pos (gnus-data-find
6993 ,(or number '(gnus-summary-article-number)))))
6995 (defmacro gnus-summary-article-subject (&optional number)
6996 "Return current subject string or nil if nothing."
6999 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7000 '(gnus-data-header (assq (gnus-summary-article-number)
7001 gnus-newsgroup-data)))))
7004 (mail-header-subject headers))))
7006 (defmacro gnus-summary-article-score (&optional number)
7007 "Return current article score."
7008 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7009 gnus-newsgroup-scored))
7010 gnus-summary-default-score 0))
7012 (defun gnus-summary-article-children (&optional number)
7013 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7014 (level (gnus-data-level (car data)))
7016 (while (and (setq data (cdr data))
7017 (> (setq l (gnus-data-level (car data))) level))
7018 (and (= (1+ level) l)
7019 (setq children (cons (gnus-data-number (car data))
7021 (nreverse children)))
7023 (defun gnus-summary-article-parent (&optional number)
7024 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7025 (gnus-data-list t)))
7026 (level (gnus-data-level (car data)))
7029 () ; This is a root.
7030 ;; We search until we find an article with a level less than
7031 ;; this one. That function has to be the parent.
7032 (while (and (setq data (cdr data))
7033 (not (< (gnus-data-level (car data)) level))))
7034 (and data (gnus-data-number (car data))))))
7037 ;; Various summary mode internalish functions.
7039 (defun gnus-mouse-pick-article (e)
7042 (gnus-summary-next-page nil t))
7044 (defun gnus-summary-setup-buffer (group)
7045 "Initialize summary buffer."
7046 (let ((buffer (concat "*Summary " group "*")))
7047 (if (get-buffer buffer)
7050 (setq gnus-summary-buffer (current-buffer))
7051 (not gnus-newsgroup-prepared))
7052 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7053 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7054 (gnus-add-current-to-buffer-list)
7055 (gnus-summary-mode group)
7057 (gnus-carpal-setup-buffer 'summary))
7058 (unless gnus-single-article-buffer
7059 (make-local-variable 'gnus-article-buffer)
7060 (make-local-variable 'gnus-original-article-buffer))
7061 (setq gnus-newsgroup-name group)
7064 (defun gnus-set-global-variables ()
7065 ;; Set the global equivalents of the summary buffer-local variables
7066 ;; to the latest values they had. These reflect the summary buffer
7067 ;; that was in action when the last article was fetched.
7068 (when (eq major-mode 'gnus-summary-mode)
7069 (setq gnus-summary-buffer (current-buffer))
7070 (let ((name gnus-newsgroup-name)
7071 (marked gnus-newsgroup-marked)
7072 (unread gnus-newsgroup-unreads)
7073 (headers gnus-current-headers)
7074 (data gnus-newsgroup-data)
7075 (article-buffer gnus-article-buffer)
7076 (score-file gnus-current-score-file))
7078 (set-buffer gnus-group-buffer)
7079 (setq gnus-newsgroup-name name)
7080 (setq gnus-newsgroup-marked marked)
7081 (setq gnus-newsgroup-unreads unread)
7082 (setq gnus-current-headers headers)
7083 (setq gnus-newsgroup-data data)
7084 (setq gnus-article-buffer article-buffer)
7085 (setq gnus-current-score-file score-file)))))
7087 (defun gnus-summary-last-article-p (&optional article)
7088 "Return whether ARTICLE is the last article in the buffer."
7089 (if (not (setq article (or article (gnus-summary-article-number))))
7090 t ; All non-existant numbers are the last article. :-)
7091 (cdr (gnus-data-find-list article))))
7093 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7094 "Insert a dummy root in the summary buffer."
7096 (add-text-properties
7097 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7098 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7100 (defvar gnus-thread-indent-array nil)
7101 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7102 (defun gnus-make-thread-indent-array ()
7104 (if (and gnus-thread-indent-array
7105 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7107 (setq gnus-thread-indent-array (make-vector 201 "")
7108 gnus-thread-indent-array-level gnus-thread-indent-level)
7110 (aset gnus-thread-indent-array n
7111 (make-string (* n gnus-thread-indent-level) ? ))
7114 (defun gnus-summary-insert-line
7115 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7116 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7117 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7118 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7119 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7120 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7121 (gnus-tmp-score-char
7122 (if (or (null gnus-summary-default-score)
7123 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7124 gnus-summary-zcore-fuzz)) ?
7125 (if (< gnus-tmp-score gnus-summary-default-score)
7126 gnus-score-below-mark gnus-score-over-mark)))
7127 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7128 ((memq gnus-tmp-current gnus-newsgroup-cached)
7130 (gnus-tmp-replied gnus-replied-mark)
7131 ((memq gnus-tmp-current gnus-newsgroup-saved)
7133 (t gnus-unread-mark)))
7134 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7137 ((string-match "(.+)" gnus-tmp-from)
7138 (substring gnus-tmp-from
7139 (1+ (match-beginning 0)) (1- (match-end 0))))
7140 ((string-match "<[^>]+> *$" gnus-tmp-from)
7141 (let ((beg (match-beginning 0)))
7142 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7143 (substring gnus-tmp-from (1+ (match-beginning 0))
7144 (1- (match-end 0))))
7145 (substring gnus-tmp-from 0 beg))))
7147 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7148 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7149 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7150 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7151 (buffer-read-only nil))
7152 (when (string= gnus-tmp-name "")
7153 (setq gnus-tmp-name gnus-tmp-from))
7154 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7157 (progn (eval gnus-summary-line-format-spec) (point))
7158 'gnus-number gnus-tmp-number)
7159 (when (gnus-visual-p 'summary-highlight 'highlight)
7161 (run-hooks 'gnus-summary-update-hook)
7164 (defun gnus-summary-update-line (&optional dont-update)
7165 ;; Update summary line after change.
7166 (when (and gnus-summary-default-score
7167 (not gnus-summary-inhibit-highlight))
7168 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7169 (article (gnus-summary-article-number))
7170 (score (gnus-summary-article-score article)))
7172 (if (and gnus-summary-mark-below
7173 (< (gnus-summary-article-score)
7174 gnus-summary-mark-below))
7175 ;; This article has a low score, so we mark it as read.
7176 (when (memq article gnus-newsgroup-unreads)
7177 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7178 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7179 ;; This article was previously marked as read on account
7180 ;; of a low score, but now it has risen, so we mark it as
7182 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7183 (gnus-summary-update-mark
7184 (if (or (null gnus-summary-default-score)
7185 (<= (abs (- score gnus-summary-default-score))
7186 gnus-summary-zcore-fuzz)) ?
7187 (if (< score gnus-summary-default-score)
7188 gnus-score-below-mark gnus-score-over-mark)) 'score))
7189 ;; Do visual highlighting.
7190 (when (gnus-visual-p 'summary-highlight 'highlight)
7191 (run-hooks 'gnus-summary-update-hook)))))
7193 (defvar gnus-tmp-new-adopts nil)
7195 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7196 ;; Sum up all elements (and sub-elements) in a list.
7198 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7200 ((and (consp thread) (cdr thread))
7203 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7206 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7209 (when (and level (zerop level) gnus-tmp-new-adopts)
7212 'gnus-summary-number-of-articles-in-thread
7213 gnus-tmp-new-adopts))))
7215 (if (> number 1) gnus-not-empty-thread-mark
7216 gnus-empty-thread-mark)
7219 (defun gnus-summary-set-local-parameters (group)
7220 "Go through the local params of GROUP and set all variable specs in that list."
7221 (let ((params (gnus-info-params (gnus-get-info group)))
7224 (setq elem (car params)
7225 params (cdr params))
7226 (and (consp elem) ; Has to be a cons.
7227 (consp (cdr elem)) ; The cdr has to be a list.
7228 (symbolp (car elem)) ; Has to be a symbol in there.
7229 (progn ; So we set it.
7230 (make-local-variable (car elem))
7231 (set (car elem) (eval (nth 1 elem))))))))
7233 (defun gnus-summary-read-group
7234 (group &optional show-all no-article kill-buffer no-display)
7235 "Start reading news in newsgroup GROUP.
7236 If SHOW-ALL is non-nil, already read articles are also listed.
7237 If NO-ARTICLE is non-nil, no article is selected initially.
7238 If NO-DISPLAY, don't generate a summary buffer."
7239 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7240 (let* ((new-group (gnus-summary-setup-buffer group))
7241 (quit-config (gnus-group-quit-config group))
7242 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7244 ;; This summary buffer exists already, so we just select it.
7246 (gnus-set-global-variables)
7248 (gnus-kill-or-deaden-summary kill-buffer))
7249 (gnus-configure-windows 'summary 'force)
7250 (gnus-set-mode-line 'summary)
7251 (gnus-summary-position-point)
7254 ;; We couldn't select this group.
7256 (when (and (eq major-mode 'gnus-summary-mode)
7257 (not (equal (current-buffer) kill-buffer)))
7258 (kill-buffer (current-buffer))
7259 (if (not quit-config)
7261 (set-buffer gnus-group-buffer)
7262 (gnus-group-jump-to-group group)
7263 (gnus-group-next-unread-group 1))
7264 (if (not (buffer-name (car quit-config)))
7265 (gnus-configure-windows 'group 'force)
7266 (set-buffer (car quit-config))
7267 (and (eq major-mode 'gnus-summary-mode)
7268 (gnus-set-global-variables))
7269 (gnus-configure-windows (cdr quit-config)))))
7270 (gnus-message 3 "Can't select group")
7272 ;; The user did a `C-g' while prompting for number of articles,
7273 ;; so we exit this group.
7274 ((eq did-select 'quit)
7275 (and (eq major-mode 'gnus-summary-mode)
7276 (not (equal (current-buffer) kill-buffer))
7277 (kill-buffer (current-buffer)))
7279 (gnus-kill-or-deaden-summary kill-buffer))
7280 (if (not quit-config)
7282 (set-buffer gnus-group-buffer)
7283 (gnus-group-jump-to-group group)
7284 (gnus-group-next-unread-group 1)
7285 (gnus-configure-windows 'group 'force))
7286 (if (not (buffer-name (car quit-config)))
7287 (gnus-configure-windows 'group 'force)
7288 (set-buffer (car quit-config))
7289 (and (eq major-mode 'gnus-summary-mode)
7290 (gnus-set-global-variables))
7291 (gnus-configure-windows (cdr quit-config))))
7292 ;; Finally signal the quit.
7294 ;; The group was successfully selected.
7296 (gnus-set-global-variables)
7297 ;; Save the active value in effect when the group was entered.
7298 (setq gnus-newsgroup-active
7300 (gnus-active gnus-newsgroup-name)))
7301 ;; You can change the summary buffer in some way with this hook.
7302 (run-hooks 'gnus-select-group-hook)
7303 ;; Set any local variables in the group parameters.
7304 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7305 ;; Do score processing.
7306 (when gnus-use-scoring
7307 (gnus-possibly-score-headers))
7308 (gnus-update-format-specifications)
7309 ;; Check whether to fill in the gaps in the threads.
7310 (when gnus-build-sparse-threads
7311 (gnus-build-sparse-threads))
7312 ;; Find the initial limit.
7313 (gnus-summary-initial-limit show-all)
7314 ;; Generate the summary buffer.
7316 (gnus-summary-prepare))
7317 (when gnus-use-trees
7318 (gnus-tree-open group)
7319 (setq gnus-summary-highlight-line-function
7320 'gnus-tree-highlight-article))
7321 ;; If the summary buffer is empty, but there are some low-scored
7322 ;; articles or some excluded dormants, we include these in the
7324 (when (zerop (buffer-size))
7325 (cond (gnus-newsgroup-dormant
7326 (gnus-summary-limit-include-dormant))
7327 ((and gnus-newsgroup-scored show-all)
7328 (gnus-summary-limit-include-expunged))))
7329 ;; Function `gnus-apply-kill-file' must be called in this hook.
7330 (run-hooks 'gnus-apply-kill-hook)
7331 (if (zerop (buffer-size))
7333 ;; This newsgroup is empty.
7334 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7335 (gnus-message 6 "No unread news")
7337 (gnus-kill-or-deaden-summary kill-buffer))
7338 ;; Return nil from this function.
7340 ;; Hide conversation thread subtrees. We cannot do this in
7341 ;; gnus-summary-prepare-hook since kill processing may not
7342 ;; work with hidden articles.
7343 (and gnus-show-threads
7344 gnus-thread-hide-subtree
7345 (gnus-summary-hide-all-threads))
7346 ;; Show first unread article if requested.
7347 (if (and (not no-article)
7348 gnus-newsgroup-unreads
7349 gnus-auto-select-first)
7350 (if (eq gnus-auto-select-first 'best)
7351 (gnus-summary-best-unread-article)
7352 (gnus-summary-first-unread-article))
7353 ;; Don't select any articles, just move point to the first
7354 ;; article in the group.
7355 (goto-char (point-min))
7356 (gnus-summary-position-point)
7357 (gnus-set-mode-line 'summary)
7358 (gnus-configure-windows 'summary 'force))
7359 ;; If we are in async mode, we send some info to the backend.
7360 (when gnus-newsgroup-async
7361 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7363 (gnus-kill-or-deaden-summary kill-buffer))
7364 (when (get-buffer-window gnus-group-buffer)
7365 ;; Gotta use windows, because recenter does wierd stuff if
7366 ;; the current buffer ain't the displayed window.
7367 (let ((owin (selected-window)))
7368 (select-window (get-buffer-window gnus-group-buffer))
7369 (when (gnus-group-goto-group group)
7371 (select-window owin))))
7372 ;; Mark this buffer as "prepared".
7373 (setq gnus-newsgroup-prepared t)
7376 (defun gnus-summary-prepare ()
7377 "Generate the summary buffer."
7378 (let ((buffer-read-only nil))
7380 (setq gnus-newsgroup-data nil
7381 gnus-newsgroup-data-reverse nil)
7382 (run-hooks 'gnus-summary-generate-hook)
7383 ;; Generate the buffer, either with threads or without.
7384 (when gnus-newsgroup-headers
7385 (gnus-summary-prepare-threads
7386 (if gnus-show-threads
7387 (gnus-sort-gathered-threads
7388 (funcall gnus-summary-thread-gathering-function
7390 (gnus-cut-threads (gnus-make-threads)))))
7391 ;; Unthreaded display.
7392 (gnus-sort-articles gnus-newsgroup-headers))))
7393 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7394 ;; Call hooks for modifying summary buffer.
7395 (goto-char (point-min))
7396 (run-hooks 'gnus-summary-prepare-hook)))
7398 (defun gnus-gather-threads-by-subject (threads)
7399 "Gather threads by looking at Subject headers."
7400 (if (not gnus-summary-make-false-root)
7402 (let ((hashtb (gnus-make-hashtable 1023))
7405 subject hthread whole-subject)
7407 (setq whole-subject (mail-header-subject (car (car threads))))
7408 (if (and gnus-summary-gather-exclude-subject
7409 (string-match gnus-summary-gather-exclude-subject
7411 () ; We don't want to do anything with this article.
7412 ;; We simplify the subject before looking it up in the
7416 ;; Truncate the subject.
7417 ((numberp gnus-summary-gather-subject-limit)
7418 (setq subject (gnus-simplify-subject-re whole-subject))
7419 (if (> (length subject) gnus-summary-gather-subject-limit)
7420 (substring subject 0 gnus-summary-gather-subject-limit)
7422 ;; Fuzzily simplify it.
7423 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7424 (gnus-simplify-subject-fuzzy whole-subject))
7425 ;; Just remove the leading "Re:".
7427 (gnus-simplify-subject-re whole-subject))))
7429 (if (setq hthread (gnus-gethash subject hashtb))
7431 ;; We enter a dummy root into the thread, if we
7432 ;; haven't done that already.
7433 (unless (stringp (car (car hthread)))
7434 (setcar hthread (list whole-subject (car hthread))))
7435 ;; We add this new gathered thread to this gathered
7437 (setcdr (car hthread)
7438 (nconc (cdr (car hthread)) (list (car threads))))
7439 ;; Remove it from the list of threads.
7440 (setcdr prev (cdr threads))
7441 (setq threads prev))
7442 ;; Enter this thread into the hash table.
7443 (gnus-sethash subject threads hashtb)))
7445 (setq threads (cdr threads)))
7448 (defun gnus-summary-gather-threads-by-references (threads)
7449 "Gather threads by looking at References headers."
7450 (let ((idhashtb (gnus-make-hashtable 1023))
7451 (thhashtb (gnus-make-hashtable 1023))
7454 ids references id gthread gid entered)
7456 (when (setq references (mail-header-references (caar threads)))
7457 (setq id (mail-header-id (caar threads)))
7458 (setq ids (gnus-split-references references))
7461 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7463 (gnus-sethash (car ids) id idhashtb)
7464 (gnus-sethash id threads thhashtb))
7465 (setq gthread (gnus-gethash gid thhashtb))
7467 ;; We enter a dummy root into the thread, if we
7468 ;; haven't done that already.
7469 (unless (stringp (caar gthread))
7470 (setcar gthread (list (mail-header-subject (caar gthread))
7472 ;; We add this new gathered thread to this gathered
7474 (setcdr (car gthread)
7475 (nconc (cdar gthread) (list (car threads)))))
7476 ;; Add it into the thread hash table.
7477 (gnus-sethash id gthread thhashtb)
7479 ;; Remove it from the list of threads.
7480 (setcdr prev (cdr threads))
7481 (setq threads prev))
7482 (setq ids (cdr ids))))
7484 (setq threads (cdr threads)))
7487 (defun gnus-sort-gathered-threads (threads)
7488 "Sort subtreads inside each gathered thread by article number."
7489 (let ((result threads))
7491 (when (stringp (car (car threads)))
7492 (setcdr (car threads)
7493 (sort (cdr (car threads)) 'gnus-thread-sort-by-number)))
7494 (setq threads (cdr threads)))
7497 (defun gnus-make-threads ()
7498 "Go through the dependency hashtb and find the roots. Return all threads."
7502 (unless (car (symbol-value refs))
7503 ;; These threads do not refer back to any other articles,
7504 ;; so they're roots.
7505 (setq threads (append (cdr (symbol-value refs)) threads))))
7506 gnus-newsgroup-dependencies)
7509 (defun gnus-build-sparse-threads ()
7510 (let ((headers gnus-newsgroup-headers)
7511 (deps gnus-newsgroup-dependencies)
7512 header references generation relations
7513 cthread subject child end pthread relation)
7514 ;; First we create an alist of generations/relations, where
7515 ;; generations is how much we trust the ralation, and the relation
7517 (gnus-message 7 "Making sparse threads...")
7519 (nnheader-set-temp-buffer " *gnus sparse threads*")
7520 (while (setq header (pop headers))
7521 (when (and (setq references (mail-header-references header))
7522 (not (string= references "")))
7524 (setq child (downcase (mail-header-id header))
7525 subject (mail-header-subject header))
7527 (while (search-backward ">" nil t)
7528 (setq end (1+ (point)))
7529 (when (search-backward "<" nil t)
7530 (push (list (incf generation)
7531 child (setq child (downcase
7532 (buffer-substring (point) end)))
7535 (push (list (1+ generation) child nil subject) relations)
7537 (kill-buffer (current-buffer)))
7538 ;; Sort over trustworthiness.
7539 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7540 (while (setq relation (pop relations))
7541 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7542 (unless (car (symbol-value cthread))
7543 ;; Make this article the parent of these threads.
7544 (setcar (symbol-value cthread)
7545 (vector gnus-reffed-article-number
7549 (or (caddr relation) "") 0 0 "")))
7550 (set cthread (list (vector gnus-reffed-article-number
7552 "" "" (cadr relation)
7553 (or (caddr relation) "") 0 0 ""))))
7554 (push gnus-reffed-article-number gnus-newsgroup-limit)
7555 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7556 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7557 gnus-newsgroup-reads)
7558 (decf gnus-reffed-article-number)
7559 ;; Make this new thread the child of its parent.
7560 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7561 (setcdr (symbol-value pthread)
7562 (nconc (cdr (symbol-value pthread))
7563 (list (symbol-value cthread))))
7564 (set pthread (list nil (symbol-value cthread))))))
7565 (gnus-message 7 "Making sparse threads...done")))
7567 (defun gnus-build-old-threads ()
7568 ;; Look at all the articles that refer back to old articles, and
7569 ;; fetch the headers for the articles that aren't there. This will
7570 ;; build complete threads - if the roots haven't been expired by the
7575 (when (not (car (symbol-value refs)))
7576 (setq heads (cdr (symbol-value refs)))
7578 (if (memq (mail-header-number (car (car heads)))
7579 gnus-newsgroup-dormant)
7580 (setq heads (cdr heads))
7581 (setq id (symbol-name refs))
7582 (while (and (setq id (gnus-build-get-header id))
7583 (not (car (gnus-gethash
7584 id gnus-newsgroup-dependencies)))))
7585 (setq heads nil)))))
7586 gnus-newsgroup-dependencies)))
7588 (defun gnus-build-get-header (id)
7589 ;; Look through the buffer of NOV lines and find the header to
7590 ;; ID. Enter this line into the dependencies hash table, and return
7591 ;; the id of the parent article (if any).
7592 (let ((deps gnus-newsgroup-dependencies)
7596 (set-buffer nntp-server-buffer)
7597 (goto-char (point-min))
7598 (while (and (not found) (search-forward id nil t))
7600 (setq found (looking-at
7601 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7602 (regexp-quote id))))
7603 (or found (beginning-of-line 2)))
7608 (setq header (gnus-nov-parse-line
7609 (read (current-buffer)) deps))
7610 (gnus-parent-id (mail-header-references header))))))
7612 (let ((number (mail-header-number header)))
7613 (push number gnus-newsgroup-limit)
7614 (push header gnus-newsgroup-headers)
7615 (if (memq number gnus-newsgroup-unselected)
7617 (push number gnus-newsgroup-unreads)
7618 (setq gnus-newsgroup-unselected
7619 (delq number gnus-newsgroup-unselected)))
7620 (push number gnus-newsgroup-ancient)))))))
7622 (defun gnus-summary-update-article (article &optional header)
7623 "Update ARTICLE in the summary buffer."
7624 (let ((id (mail-header-id (gnus-summary-article-header article)))
7625 (data (gnus-data-find article)))
7626 (setcar (gnus-id-to-thread id) nil)
7627 (gnus-summary-insert-subject id)
7628 ;; Set the (possibly) new article number in the data structure.
7629 (gnus-data-set-number data (gnus-id-to-article id))))
7631 (defun gnus-rebuild-thread (id)
7632 "Rebuild the thread containing ID."
7633 (let ((dep gnus-newsgroup-dependencies)
7634 (buffer-read-only nil)
7635 current headers refs thread art data)
7636 (if (not gnus-show-threads)
7637 (setq thread (list (car (gnus-id-to-thread id))))
7638 ;; Get the thread this article is part of.
7639 (setq thread (gnus-remove-thread id)))
7640 (setq current (save-excursion
7641 (and (zerop (forward-line -1))
7642 (gnus-summary-article-number))))
7643 ;; If this is a gathered thread, we have to go some re-gathering.
7644 (when (stringp (car thread))
7645 (let ((subject (car thread))
7647 (setq thread (cdr thread))
7649 (unless (memq (setq thr (gnus-id-to-thread
7651 (mail-header-id (car (car thread))))))
7654 (setq thread (cdr thread)))
7655 ;; We now have all (unique) roots.
7656 (if (= (length roots) 1)
7657 ;; All the loose roots are now one solid root.
7658 (setq thread (car roots))
7659 (setq thread (cons subject (gnus-sort-threads roots))))))
7662 ;; We then insert this thread into the summary buffer.
7663 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7664 (gnus-summary-prepare-threads (list thread))
7665 (setq data (nreverse gnus-newsgroup-data))
7666 (setq threads gnus-newsgroup-threads))
7667 ;; We splice the new data into the data structure.
7668 (gnus-data-enter-list current data)
7669 (gnus-data-compute-positions)
7670 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7672 (defun gnus-id-to-thread (id)
7673 "Return the (sub-)thread where ID appears."
7674 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7676 (defun gnus-id-to-article (id)
7677 "Return the article number of ID."
7678 (let ((thread (gnus-id-to-thread id)))
7680 (mail-header-number (car thread)))))
7682 (defun gnus-id-to-header (id)
7683 "Return the article headers of ID."
7684 (car (gnus-id-to-thread id)))
7686 (defun gnus-article-displayed-root-p (article)
7687 "Say whether ARTICLE is a root(ish) article."
7688 (let ((level (gnus-summary-thread-level article))
7694 (null (setq particle (gnus-id-to-article
7696 (mail-header-references
7697 (gnus-summary-article-header article))))))
7698 (null (gnus-summary-thread-level particle)))))))
7700 (defun gnus-root-id (id)
7701 "Return the id of the root of the thread where ID appears."
7703 (while (and id (setq prev (car (gnus-gethash
7705 gnus-newsgroup-dependencies))))
7707 id (gnus-parent-id (mail-header-references prev))))
7710 (defun gnus-remove-thread (id &optional dont-remove)
7711 "Remove the thread that has ID in it."
7712 (let ((dep gnus-newsgroup-dependencies)
7713 headers thread prev last-id)
7714 ;; First go up in this thread until we find the root.
7715 (setq last-id (gnus-root-id id))
7716 (setq headers (list (car (gnus-id-to-thread last-id))
7717 (car (car (cdr (gnus-id-to-thread last-id))))))
7718 ;; We have now found the real root of this thread. It might have
7719 ;; been gathered into some loose thread, so we have to search
7720 ;; through the threads to find the thread we wanted.
7721 (let ((threads gnus-newsgroup-threads)
7724 (setq sub (car threads))
7725 (if (stringp (car sub))
7726 ;; This is a gathered threads, so we look at the roots
7727 ;; below it to find whether this article in in this
7730 (setq sub (cdr sub))
7732 (when (member (car (car sub)) headers)
7733 (setq thread (car threads)
7736 (setq sub (cdr sub))))
7737 ;; It's an ordinary thread, so we check it.
7738 (when (eq (car sub) (car headers))
7741 (setq threads (cdr threads)))
7742 ;; If this article is in no thread, then it's a root.
7745 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7746 (setq thread (gnus-gethash (downcase last-id) dep)))
7749 thread ; We return this thread.
7751 (if (stringp (car thread))
7753 ;; If we use dummy roots, then we have to remove the
7754 ;; dummy root as well.
7755 (when (eq gnus-summary-make-false-root 'dummy)
7758 (setq thread (cdr thread))
7760 (gnus-remove-thread-1 (car thread))
7761 (setq thread (cdr thread))))
7762 (gnus-remove-thread-1 thread))))))))
7764 (defun gnus-remove-thread-1 (thread)
7765 "Remove the thread THREAD recursively."
7766 (let ((number (mail-header-number (car thread)))
7768 (when (setq pos (text-property-any
7769 (point-min) (point-max) 'gnus-number number))
7772 (gnus-data-remove number))
7773 (setq thread (cdr thread))
7775 (gnus-remove-thread-1 (car thread))
7776 (setq thread (cdr thread)))))
7778 (defun gnus-sort-threads (threads)
7780 (if (not gnus-thread-sort-functions)
7782 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7783 (car gnus-thread-sort-functions)
7785 ,(gnus-make-sort-function
7786 (reverse gnus-thread-sort-functions))))))
7787 (gnus-message 7 "Sorting threads...")
7790 (gnus-message 7 "Sorting threads...done")))))
7792 (defun gnus-sort-articles (articles)
7794 (when gnus-article-sort-functions
7795 (let ((func (if (= 1 (length gnus-article-sort-functions))
7796 (car gnus-article-sort-functions)
7798 ,(gnus-make-sort-function
7799 (reverse gnus-article-sort-functions))))))
7800 (gnus-message 7 "Sorting articles...")
7802 (sort articles func)
7803 (gnus-message 7 "Sorting articles...done")))))
7805 (defun gnus-make-sort-function (funs)
7806 "Return a composite sort condition based on the functions in FUNC."
7808 `(or (,(car funs) t1 t2)
7809 (and (not (,(car funs) t2 t1))
7810 ,(gnus-make-sort-function (cdr funs))))
7811 `(,(car funs) t1 t2)))
7813 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7814 (defmacro gnus-thread-header (thread)
7815 ;; Return header of first article in THREAD.
7816 ;; Note that THREAD must never, ever be anything else than a variable -
7817 ;; using some other form will lead to serious barfage.
7818 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7819 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7820 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7823 (defsubst gnus-article-sort-by-number (h1 h2)
7824 "Sort articles by article number."
7825 (< (mail-header-number h1)
7826 (mail-header-number h2)))
7828 (defun gnus-thread-sort-by-number (h1 h2)
7829 "Sort threads by root article number."
7830 (gnus-article-sort-by-number
7831 (gnus-thread-header h1) (gnus-thread-header h2)))
7833 (defsubst gnus-article-sort-by-author (h1 h2)
7834 "Sort articles by root author."
7836 (let ((extract (funcall
7837 gnus-extract-address-components
7838 (mail-header-from h1))))
7839 (or (car extract) (cdr extract)))
7840 (let ((extract (funcall
7841 gnus-extract-address-components
7842 (mail-header-from h2))))
7843 (or (car extract) (cdr extract)))))
7845 (defun gnus-thread-sort-by-author (h1 h2)
7846 "Sort threads by root author."
7847 (gnus-article-sort-by-author
7848 (gnus-thread-header h1) (gnus-thread-header h2)))
7850 (defsubst gnus-article-sort-by-subject (h1 h2)
7851 "Sort articles by root subject."
7853 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
7854 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
7856 (defun gnus-thread-sort-by-subject (h1 h2)
7857 "Sort threads by root subject."
7858 (gnus-article-sort-by-subject
7859 (gnus-thread-header h1) (gnus-thread-header h2)))
7861 (defsubst gnus-article-sort-by-date (h1 h2)
7862 "Sort articles by root article date."
7864 (gnus-sortable-date (mail-header-date h1))
7865 (gnus-sortable-date (mail-header-date h2))))
7867 (defun gnus-thread-sort-by-date (h1 h2)
7868 "Sort threads by root article date."
7869 (gnus-article-sort-by-date
7870 (gnus-thread-header h1) (gnus-thread-header h2)))
7872 (defsubst gnus-article-sort-by-score (h1 h2)
7873 "Sort articles by root article score.
7874 Unscored articles will be counted as having a score of zero."
7875 (> (or (cdr (assq (mail-header-number h1)
7876 gnus-newsgroup-scored))
7877 gnus-summary-default-score 0)
7878 (or (cdr (assq (mail-header-number h2)
7879 gnus-newsgroup-scored))
7880 gnus-summary-default-score 0)))
7882 (defun gnus-thread-sort-by-score (h1 h2)
7883 "Sort threads by root article score."
7884 (gnus-article-sort-by-score
7885 (gnus-thread-header h1) (gnus-thread-header h2)))
7887 (defun gnus-thread-sort-by-total-score (h1 h2)
7888 "Sort threads by the sum of all scores in the thread.
7889 Unscored articles will be counted as having a score of zero."
7890 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
7892 (defun gnus-thread-total-score (thread)
7893 ;; This function find the total score of THREAD.
7895 (if (stringp (car thread))
7896 (apply gnus-thread-score-function 0
7897 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
7898 (gnus-thread-total-score-1 thread))
7899 (gnus-thread-total-score-1 (list thread))))
7901 (defun gnus-thread-total-score-1 (root)
7902 ;; This function find the total score of the thread below ROOT.
7903 (setq root (car root))
7904 (apply gnus-thread-score-function
7905 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
7906 gnus-summary-default-score 0)
7907 (mapcar 'gnus-thread-total-score
7908 (cdr (gnus-gethash (downcase (mail-header-id root))
7909 gnus-newsgroup-dependencies)))))
7911 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7912 (defvar gnus-tmp-prev-subject nil)
7913 (defvar gnus-tmp-false-parent nil)
7914 (defvar gnus-tmp-root-expunged nil)
7915 (defvar gnus-tmp-dummy-line nil)
7917 (defun gnus-summary-prepare-threads (threads)
7918 "Prepare summary buffer from THREADS and indentation LEVEL.
7919 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
7920 or a straight list of headers."
7921 (gnus-message 7 "Generating summary...")
7923 (setq gnus-newsgroup-threads threads)
7926 (let ((gnus-tmp-level 0)
7927 (default-score (or gnus-summary-default-score 0))
7928 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
7929 thread number subject stack state gnus-tmp-gathered beg-match
7930 new-roots gnus-tmp-new-adopts thread-end
7931 gnus-tmp-header gnus-tmp-unread
7932 gnus-tmp-replied gnus-tmp-subject-or-nil
7933 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
7934 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
7935 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
7937 (setq gnus-tmp-prev-subject nil)
7939 (if (vectorp (car threads))
7940 ;; If this is a straight (sic) list of headers, then a
7941 ;; threaded summary display isn't required, so we just create
7942 ;; an unthreaded one.
7943 (gnus-summary-prepare-unthreaded threads)
7945 ;; Do the threaded display.
7947 (while (or threads stack gnus-tmp-new-adopts new-roots)
7949 (if (and (= gnus-tmp-level 0)
7950 (not (setq gnus-tmp-dummy-line nil))
7952 (= (car (car stack)) 0))
7953 (not gnus-tmp-false-parent)
7954 (or gnus-tmp-new-adopts new-roots))
7955 (if gnus-tmp-new-adopts
7956 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
7957 thread (list (car gnus-tmp-new-adopts))
7958 gnus-tmp-header (car (car thread))
7959 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
7961 (setq thread (list (car new-roots))
7962 gnus-tmp-header (car (car thread))
7963 new-roots (cdr new-roots))))
7966 ;; If there are some threads, we do them before the
7967 ;; threads on the stack.
7968 (setq thread threads
7969 gnus-tmp-header (car (car thread)))
7970 ;; There were no current threads, so we pop something off
7972 (setq state (car stack)
7973 gnus-tmp-level (car state)
7976 gnus-tmp-header (car (car thread)))))
7978 (setq gnus-tmp-false-parent nil)
7979 (setq gnus-tmp-root-expunged nil)
7980 (setq thread-end nil)
7982 (if (stringp gnus-tmp-header)
7983 ;; The header is a dummy root.
7985 ((eq gnus-summary-make-false-root 'adopt)
7986 ;; We let the first article adopt the rest.
7987 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
7988 (cdr (cdr (car thread)))))
7989 (setq gnus-tmp-gathered
7991 (lambda (h) (mail-header-number (car h)))
7992 (cdr (cdr (car thread))))
7994 (setq thread (cons (list (car (car thread))
7995 (car (cdr (car thread))))
7997 (setq gnus-tmp-level -1
7998 gnus-tmp-false-parent t))
7999 ((eq gnus-summary-make-false-root 'empty)
8000 ;; We print adopted articles with empty subject fields.
8001 (setq gnus-tmp-gathered
8003 (lambda (h) (mail-header-number (car h)))
8004 (cdr (cdr (car thread))))
8006 (setq gnus-tmp-level -1))
8007 ((eq gnus-summary-make-false-root 'dummy)
8008 ;; We remember that we probably want to output a dummy
8010 (setq gnus-tmp-dummy-line gnus-tmp-header)
8011 (setq gnus-tmp-prev-subject gnus-tmp-header))
8013 ;; We do not make a root for the gathered
8014 ;; sub-threads at all.
8015 (setq gnus-tmp-level -1)))
8017 (setq number (mail-header-number gnus-tmp-header)
8018 subject (mail-header-subject gnus-tmp-header))
8021 ;; If the thread has changed subject, we might want to make
8022 ;; this subthread into a root.
8023 ((and (null gnus-thread-ignore-subject)
8024 (not (zerop gnus-tmp-level))
8025 gnus-tmp-prev-subject
8027 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8028 (setq new-roots (nconc new-roots (list (car thread)))
8030 gnus-tmp-header nil))
8031 ;; If the article lies outside the current limit,
8032 ;; then we do not display it.
8033 ((not (memq number gnus-newsgroup-limit))
8034 (setq gnus-tmp-gathered
8036 (lambda (h) (mail-header-number (car h)))
8039 (setq gnus-tmp-new-adopts (if (cdr (car thread))
8040 (append gnus-tmp-new-adopts
8042 gnus-tmp-new-adopts)
8044 gnus-tmp-header nil)
8045 (when (zerop gnus-tmp-level)
8046 (setq gnus-tmp-root-expunged t)))
8047 ;; Perhaps this article is to be marked as read?
8048 ((and gnus-summary-mark-below
8049 (< (or (cdr (assq number gnus-newsgroup-scored))
8051 gnus-summary-mark-below))
8052 (setq gnus-newsgroup-unreads
8053 (delq number gnus-newsgroup-unreads))
8054 (if gnus-newsgroup-auto-expire
8055 (push number gnus-newsgroup-expirable)
8056 (push (cons number gnus-low-score-mark)
8057 gnus-newsgroup-reads))))
8059 (when gnus-tmp-header
8060 ;; We may have an old dummy line to output before this
8062 (when gnus-tmp-dummy-line
8063 (gnus-summary-insert-dummy-line
8064 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8065 (setq gnus-tmp-dummy-line nil))
8067 ;; Compute the mark.
8071 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8072 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8073 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8074 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8075 (t (or (cdr (assq number gnus-newsgroup-reads))
8076 gnus-ancient-mark))))
8078 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8079 gnus-tmp-header gnus-tmp-level)
8080 gnus-newsgroup-data)
8082 ;; Actually insert the line.
8084 gnus-tmp-subject-or-nil
8086 ((and gnus-thread-ignore-subject
8087 gnus-tmp-prev-subject
8088 (not (inline (gnus-subject-equal
8089 gnus-tmp-prev-subject subject))))
8091 ((zerop gnus-tmp-level)
8092 (if (and (eq gnus-summary-make-false-root 'empty)
8093 (memq number gnus-tmp-gathered)
8094 gnus-tmp-prev-subject
8095 (inline (gnus-subject-equal
8096 gnus-tmp-prev-subject subject)))
8097 gnus-summary-same-subject
8099 (t gnus-summary-same-subject)))
8100 (if (and (eq gnus-summary-make-false-root 'adopt)
8101 (= gnus-tmp-level 1)
8102 (memq number gnus-tmp-gathered))
8103 (setq gnus-tmp-opening-bracket ?\<
8104 gnus-tmp-closing-bracket ?\>)
8105 (setq gnus-tmp-opening-bracket ?\[
8106 gnus-tmp-closing-bracket ?\]))
8108 gnus-tmp-indentation
8109 (aref gnus-thread-indent-array gnus-tmp-level)
8110 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8111 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8112 gnus-summary-default-score 0)
8114 (if (or (null gnus-summary-default-score)
8115 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8116 gnus-summary-zcore-fuzz)) ?
8117 (if (< gnus-tmp-score gnus-summary-default-score)
8118 gnus-score-below-mark gnus-score-over-mark))
8120 (cond ((memq number gnus-newsgroup-processable)
8122 ((memq number gnus-newsgroup-cached)
8124 ((memq number gnus-newsgroup-replied)
8126 (t gnus-unread-mark))
8127 gnus-tmp-from (mail-header-from gnus-tmp-header)
8130 ((string-match "(.+)" gnus-tmp-from)
8131 (substring gnus-tmp-from
8132 (1+ (match-beginning 0)) (1- (match-end 0))))
8133 ((string-match "<[^>]+> *$" gnus-tmp-from)
8134 (setq beg-match (match-beginning 0))
8135 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8136 (substring gnus-tmp-from (1+ (match-beginning 0))
8137 (1- (match-end 0))))
8138 (substring gnus-tmp-from 0 beg-match)))
8140 (when (string= gnus-tmp-name "")
8141 (setq gnus-tmp-name gnus-tmp-from))
8142 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8145 (progn (eval gnus-summary-line-format-spec) (point))
8146 'gnus-number number)
8149 (run-hooks 'gnus-summary-update-hook)
8152 (setq gnus-tmp-prev-subject subject)))
8154 (when (nth 1 thread)
8155 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8156 (incf gnus-tmp-level)
8157 (setq threads (if thread-end nil (cdr (car thread))))
8159 (setq gnus-tmp-level 0)))))
8160 (gnus-message 7 "Generating summary...done"))
8162 (defun gnus-summary-prepare-unthreaded (headers)
8163 "Generate an unthreaded summary buffer based on HEADERS."
8164 (let (header number mark)
8167 (setq header (car headers)
8168 headers (cdr headers)
8169 number (mail-header-number header))
8171 ;; We may have to root out some bad articles...
8172 (when (memq number gnus-newsgroup-limit)
8173 (when (and gnus-summary-mark-below
8174 (< (or (cdr (assq number gnus-newsgroup-scored))
8175 gnus-summary-default-score 0)
8176 gnus-summary-mark-below))
8177 (setq gnus-newsgroup-unreads
8178 (delq number gnus-newsgroup-unreads))
8179 (if gnus-newsgroup-auto-expire
8180 (push number gnus-newsgroup-expirable)
8181 (push (cons number gnus-low-score-mark)
8182 gnus-newsgroup-reads)))
8186 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8187 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8188 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8189 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8190 (t (or (cdr (assq number gnus-newsgroup-reads))
8191 gnus-ancient-mark))))
8192 (setq gnus-newsgroup-data
8193 (cons (gnus-data-make number mark (1+ (point)) header 0)
8194 gnus-newsgroup-data))
8195 (gnus-summary-insert-line
8196 header 0 nil mark (memq number gnus-newsgroup-replied)
8197 (memq number gnus-newsgroup-expirable)
8198 (mail-header-subject header) nil
8199 (cdr (assq number gnus-newsgroup-scored))
8200 (memq number gnus-newsgroup-processable))))))
8202 (defun gnus-select-newsgroup (group &optional read-all)
8203 "Select newsgroup GROUP.
8204 If READ-ALL is non-nil, all articles in the group are selected."
8205 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8206 (info (nth 2 entry))
8207 articles fetched-articles cached)
8209 (or (gnus-check-server
8210 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8211 (error "Couldn't open server"))
8213 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8214 (gnus-activate-group group) ; Or we can activate it...
8215 (progn ; Or we bug out.
8216 (kill-buffer (current-buffer))
8217 (error "Couldn't request group %s: %s"
8218 group (gnus-status-message group))))
8220 (setq gnus-newsgroup-name group)
8221 (setq gnus-newsgroup-unselected nil)
8222 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8224 (and gnus-asynchronous
8225 (gnus-check-backend-function
8226 'request-asynchronous gnus-newsgroup-name)
8227 (setq gnus-newsgroup-async
8228 (gnus-request-asynchronous gnus-newsgroup-name)))
8230 ;; Adjust and set lists of article marks.
8232 (gnus-adjust-marked-articles info))
8234 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8235 (when (gnus-virtual-group-p group)
8236 (setq cached gnus-newsgroup-cached))
8238 (setq gnus-newsgroup-unreads
8239 (gnus-set-difference
8240 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8241 gnus-newsgroup-dormant))
8243 (setq gnus-newsgroup-processable nil)
8245 (setq articles (gnus-articles-to-read group read-all))
8249 (gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8251 ((eq articles 0) nil)
8253 ;; Init the dependencies hash table.
8254 (setq gnus-newsgroup-dependencies
8255 (gnus-make-hashtable (length articles)))
8256 ;; Retrieve the headers and read them in.
8257 (gnus-message 5 "Fetching headers...")
8258 (setq gnus-newsgroup-headers
8260 (setq gnus-headers-retrieved-by
8261 (gnus-retrieve-headers
8262 articles gnus-newsgroup-name
8263 ;; We might want to fetch old headers, but
8264 ;; not if there is only 1 article.
8265 (and gnus-fetch-old-headers
8267 (not (eq gnus-fetch-old-headers 'some))
8268 (not (numberp gnus-fetch-old-headers)))
8269 (> (length articles) 1))))))
8270 (gnus-get-newsgroup-headers-xover articles)
8271 (gnus-get-newsgroup-headers)))
8272 (gnus-message 5 "Fetching headers...done")
8274 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8276 (setq gnus-newsgroup-cached cached))
8278 ;; Set the initial limit.
8279 (setq gnus-newsgroup-limit (copy-sequence articles))
8280 ;; Remove canceled articles from the list of unread articles.
8281 (setq gnus-newsgroup-unreads
8282 (gnus-set-sorted-intersection
8283 gnus-newsgroup-unreads
8284 (setq fetched-articles
8285 (mapcar (lambda (headers) (mail-header-number headers))
8286 gnus-newsgroup-headers))))
8287 ;; Removed marked articles that do not exist.
8288 (gnus-update-missing-marks
8289 (gnus-sorted-complement fetched-articles articles))
8290 ;; We might want to build some more threads first.
8291 (and gnus-fetch-old-headers
8292 (eq gnus-headers-retrieved-by 'nov)
8293 (gnus-build-old-threads))
8294 ;; Check whether auto-expire is to be done in this group.
8295 (setq gnus-newsgroup-auto-expire
8296 (gnus-group-auto-expirable-p group))
8297 ;; First and last article in this newsgroup.
8298 (and gnus-newsgroup-headers
8299 (setq gnus-newsgroup-begin
8300 (mail-header-number (car gnus-newsgroup-headers)))
8301 (setq gnus-newsgroup-end
8303 (gnus-last-element gnus-newsgroup-headers))))
8304 (setq gnus-reffed-article-number -1)
8305 ;; GROUP is successfully selected.
8306 (or gnus-newsgroup-headers t)))))
8308 (defun gnus-articles-to-read (group read-all)
8309 ;; Find out what articles the user wants to read.
8311 ;; Select all articles if `read-all' is non-nil, or if there
8312 ;; are no unread articles.
8314 (and (zerop (length gnus-newsgroup-marked))
8315 (zerop (length gnus-newsgroup-unreads))))
8316 (gnus-uncompress-range (gnus-active group))
8317 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8318 (copy-sequence gnus-newsgroup-unreads))
8320 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8321 (scored (length scored-list))
8322 (number (length articles))
8323 (marked (+ (length gnus-newsgroup-marked)
8324 (length gnus-newsgroup-dormant)))
8332 ((and (or (<= scored marked) (= scored number))
8333 (numberp gnus-large-newsgroup)
8334 (> number gnus-large-newsgroup))
8338 "How many articles from %s (default %d): "
8339 gnus-newsgroup-name number))))
8340 (if (string-match "^[ \t]*$" input) number input)))
8341 ((and (> scored marked) (< scored number))
8344 (format "%s %s (%d scored, %d total): "
8345 "How many articles from"
8346 group scored number))))
8347 (if (string-match "^[ \t]*$" input)
8351 (setq select (if (stringp select) (string-to-number select) select))
8352 (if (or (null select) (zerop select))
8354 (if (and (not (zerop scored)) (<= (abs select) scored))
8356 (setq articles (sort scored-list '<))
8357 (setq number (length articles)))
8358 (setq articles (copy-sequence articles)))
8360 (if (< (abs select) number)
8362 ;; Select the N oldest articles.
8363 (setcdr (nthcdr (1- (abs select)) articles) nil)
8364 ;; Select the N most recent articles.
8365 (setq articles (nthcdr (- number select) articles))))
8366 (setq gnus-newsgroup-unselected
8367 (gnus-sorted-intersection
8368 gnus-newsgroup-unreads
8369 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8372 (defun gnus-killed-articles (killed articles)
8375 (if (inline (gnus-member-of-range (car articles) killed))
8376 (setq out (cons (car articles) out)))
8377 (setq articles (cdr articles)))
8380 (defun gnus-uncompress-marks (marks)
8381 "Uncompress the mark ranges in MARKS."
8382 (let ((uncompressed '(score bookmark))
8385 (if (memq (caar marks) uncompressed)
8386 (push (car marks) out)
8387 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8388 (setq marks (cdr marks)))
8391 (defun gnus-adjust-marked-articles (info)
8392 "Set all article lists and remove all marks that are no longer legal."
8393 (let* ((marked-lists (gnus-info-marks info))
8394 (active (gnus-active (gnus-info-group info)))
8397 (types gnus-article-mark-lists)
8398 (uncompressed '(score bookmark))
8399 marks var articles article mark)
8402 (setq marks (pop marked-lists))
8403 (set (setq var (intern (format "gnus-newsgroup-%s"
8404 (car (rassq (setq mark (car marks))
8406 (if (memq (car marks) uncompressed) (cdr marks)
8407 (gnus-uncompress-range (cdr marks))))
8409 (setq articles (symbol-value var))
8411 ;; All articles have to be subsets of the active articles.
8413 ;; Adjust "simple" lists.
8414 ((memq mark '(tick dormant expirable reply killed save))
8416 (when (or (< (setq article (pop articles)) min) (> article max))
8417 (set var (delq article (symbol-value var))))))
8419 ((memq mark '(score bookmark))
8421 (when (or (< (car (setq article (pop articles))) min)
8422 (> (car article) max))
8423 (set var (delq article (symbol-value var))))))))))
8425 (defun gnus-update-missing-marks (missing)
8426 "Go through the list of MISSING articles and remove them mark lists."
8428 (let ((types gnus-article-mark-lists)
8430 ;; Go through all types.
8432 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8433 (when (symbol-value var)
8434 ;; This list has articles. So we delete all missing articles
8438 (set var (delq (pop m) (symbol-value var)))))))))
8440 (defun gnus-update-marks ()
8441 "Enter the various lists of marked articles into the newsgroup info list."
8442 (let ((types gnus-article-mark-lists)
8443 (info (gnus-get-info gnus-newsgroup-name))
8444 (uncompressed '(score bookmark killed))
8445 var type list newmarked symbol)
8447 ;; Add all marks lists that are non-nil to the list of marks lists.
8449 (setq type (pop types))
8450 (when (setq list (symbol-value
8452 (intern (format "gnus-newsgroup-%s"
8454 (push (cons (cdr type)
8455 (if (memq (cdr type) uncompressed) list
8456 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8459 ;; Enter these new marks into the info of the group.
8461 (setcar (nthcdr 3 info) newmarked)
8462 ;; Add the marks lists to the end of the info.
8464 (setcdr (nthcdr 2 info) (list newmarked))))
8466 ;; Cut off the end of the info if there's nothing else there.
8470 (when (nthcdr (decf i) info)
8471 (setcdr (nthcdr i info) nil)))))))
8473 (defun gnus-add-marked-articles (group type articles &optional info force)
8474 ;; Add ARTICLES of TYPE to the info of GROUP.
8475 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8476 ;; add, but replace marked articles of TYPE with ARTICLES.
8477 (let ((info (or info (gnus-get-info group)))
8478 (uncompressed '(score bookmark killed))
8481 (and (not (setq marked (nthcdr 3 info)))
8482 (setcdr (nthcdr 2 info)
8483 (list (list (cons type (gnus-compress-sequence
8485 (and (not (setq m (assq type (car marked))))
8487 (cons (cons type (gnus-compress-sequence articles t) )
8490 (setcdr m (gnus-compress-sequence articles t))
8491 (setcdr m (gnus-compress-sequence
8492 (sort (nconc (gnus-uncompress-range m)
8493 (copy-sequence articles)) '<) t))))))
8495 (defun gnus-set-mode-line (where)
8496 "This function sets the mode line of the article or summary buffers.
8497 If WHERE is `summary', the summary mode line format will be used."
8498 ;; Is this mode line one we keep updated?
8499 (when (memq where gnus-updated-mode-lines)
8502 ;; We evaluate this in the summary buffer since these
8503 ;; variables are buffer-local to that buffer.
8504 (set-buffer gnus-summary-buffer)
8505 ;; We bind all these variables that are used in the `eval' form
8507 (let* ((mformat (symbol-value
8509 (format "gnus-%s-mode-line-format-spec" where))))
8510 (gnus-tmp-group-name gnus-newsgroup-name)
8511 (gnus-tmp-article-number (or gnus-current-article 0))
8512 (gnus-tmp-unread gnus-newsgroup-unreads)
8513 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8514 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8515 (gnus-tmp-unread-and-unselected
8516 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8517 (zerop gnus-tmp-unselected)) "")
8518 ((zerop gnus-tmp-unselected)
8519 (format "{%d more}" gnus-tmp-unread-and-unticked))
8520 (t (format "{%d(+%d) more}"
8521 gnus-tmp-unread-and-unticked
8522 gnus-tmp-unselected))))
8524 (if (and gnus-current-headers
8525 (vectorp gnus-current-headers))
8526 (mail-header-subject gnus-current-headers) ""))
8528 header);; passed as argument to any user-format-funcs
8529 (setq mode-string (eval mformat))
8530 (setq max-len (max 4 (if gnus-mode-non-string-length
8532 gnus-mode-non-string-length)
8533 (length mode-string))))
8534 ;; We might have to chop a bit of the string off...
8535 (when (> (length mode-string) max-len)
8537 (concat (gnus-truncate-string mode-string (- max-len 3))
8539 ;; Pad the mode string a bit.
8540 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8541 ;; Update the mode line.
8542 (setq mode-line-buffer-identification (list mode-string))
8543 (set-buffer-modified-p t))))
8545 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8546 "Go through the HEADERS list and add all Xrefs to a hash table.
8547 The resulting hash table is returned, or nil if no Xrefs were found."
8548 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8549 (virtual (gnus-virtual-group-p from-newsgroup))
8550 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8551 (xref-hashtb (make-vector 63 0))
8552 start group entry number xrefs header)
8554 (setq header (pop headers))
8555 (when (and (setq xrefs (mail-header-xref header))
8556 (not (memq (setq number (mail-header-number header))
8559 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8560 (setq start (match-end 0))
8561 (setq group (concat prefix (substring xrefs (match-beginning 1)
8564 (string-to-int (substring xrefs (match-beginning 2)
8566 (if (setq entry (gnus-gethash group xref-hashtb))
8567 (setcdr entry (cons number (cdr entry)))
8568 (gnus-sethash group (cons number nil) xref-hashtb)))))
8569 (and start xref-hashtb)))
8571 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8572 "Look through all the headers and mark the Xrefs as read."
8573 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8574 name entry info xref-hashtb idlist method nth4)
8576 (set-buffer gnus-group-buffer)
8577 (when (setq xref-hashtb
8578 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8581 (unless (string= from-newsgroup (setq name (symbol-name group)))
8582 (setq idlist (symbol-value group))
8583 ;; Dead groups are not updated.
8585 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8587 (if (stringp (setq nth4 (gnus-info-method info)))
8588 (setq nth4 (gnus-server-to-method nth4))))
8589 ;; Only do the xrefs if the group has the same
8590 ;; select method as the group we have just read.
8591 (or (gnus-methods-equal-p
8592 nth4 (gnus-find-method-for-group from-newsgroup))
8594 (equal nth4 (setq method (gnus-find-method-for-group
8596 (and (equal (car nth4) (car method))
8597 (equal (nth 1 nth4) (nth 1 method))))
8598 gnus-use-cross-reference
8599 (or (not (eq gnus-use-cross-reference t))
8601 ;; Only do cross-references on subscribed
8602 ;; groups, if that is what is wanted.
8603 (<= (gnus-info-level info) gnus-level-subscribed))
8604 (gnus-group-make-articles-read name idlist))))
8607 (defun gnus-group-make-articles-read (group articles)
8609 (entry (gnus-gethash group gnus-newsrc-hashtb))
8610 (info (nth 2 entry))
8611 (active (gnus-active group))
8613 ;; First peel off all illegal article numbers.
8615 (let ((ids articles)
8619 (if (and first (> id (cdr active)))
8621 ;; We'll end up in this situation in one particular
8622 ;; obscure situation. If you re-scan a group and get
8623 ;; a new article that is cross-posted to a different
8624 ;; group that has not been re-scanned, you might get
8625 ;; crossposted article that has a higher number than
8626 ;; Gnus believes possible. So we re-activate this
8627 ;; group as well. This might mean doing the
8628 ;; crossposting thingy will *increase* the number
8629 ;; of articles in some groups. Tsk, tsk.
8630 (setq active (or (gnus-activate-group group) active))))
8631 (if (or (> id (cdr active))
8632 (< id (car active)))
8633 (setq articles (delq id articles)))
8634 (setq ids (cdr ids)))))
8635 ;; If the read list is nil, we init it.
8637 (null (gnus-info-read info))
8639 (gnus-info-set-read info (cons 1 (1- (car active)))))
8640 ;; Then we add the read articles to the range.
8645 (gnus-info-read info) (setq articles (sort articles '<)))))
8646 ;; Then we have to re-compute how many unread
8647 ;; articles there are in this group.
8652 (setq num (- (1+ (cdr active)) (car active))))
8653 ((not (listp (cdr range)))
8654 (setq num (- (cdr active) (- (1+ (cdr range))
8658 (if (numberp (car range))
8660 (setq num (+ num (- (1+ (cdr (car range)))
8661 (car (car range))))))
8662 (setq range (cdr range)))
8663 (setq num (- (cdr active) num))))
8664 ;; Update the number of unread articles.
8666 ;; Update the group buffer.
8667 (gnus-group-update-group group t)))))
8669 (defun gnus-methods-equal-p (m1 m2)
8670 (let ((m1 (or m1 gnus-select-method))
8671 (m2 (or m2 gnus-select-method)))
8673 (and (eq (car m1) (car m2))
8674 (or (not (memq 'address (assoc (symbol-name (car m1))
8675 gnus-valid-select-methods)))
8676 (equal (nth 1 m1) (nth 1 m2)))))))
8678 (defsubst gnus-header-value ()
8679 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8681 (defvar gnus-newsgroup-none-id 0)
8683 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8684 (let ((cur nntp-server-buffer)
8687 (save-excursion (set-buffer gnus-summary-buffer)
8688 gnus-newsgroup-dependencies)))
8689 headers id id-dep ref-dep end ref)
8691 (set-buffer nntp-server-buffer)
8692 (let ((case-fold-search t)
8693 in-reply-to header number p lines)
8694 (goto-char (point-min))
8695 ;; Search to the beginning of the next header. Error messages
8696 ;; do not begin with 2 or 3.
8697 (while (re-search-forward "^[23][0-9]+ " nil t)
8700 ;; This implementation of this function, with nine
8701 ;; search-forwards instead of the one re-search-forward and
8702 ;; a case (which basically was the old function) is actually
8703 ;; about twice as fast, even though it looks messier. You
8704 ;; can't have everything, I guess. Speed and elegance
8705 ;; doesn't always go hand in hand.
8714 (narrow-to-region (point)
8715 (or (and (search-forward "\n.\n" nil t)
8721 (if (search-forward "\nsubject: " nil t)
8722 (gnus-header-value) "(none)"))
8726 (if (search-forward "\nfrom: " nil t)
8727 (gnus-header-value) "(nobody)"))
8731 (if (search-forward "\ndate: " nil t)
8732 (gnus-header-value) ""))
8736 (if (search-forward "\nmessage-id: " nil t)
8737 (setq id (gnus-header-value))
8738 ;; If there was no message-id, we just fake one to make
8739 ;; subsequent routines simpler.
8740 (setq id (concat "none+"
8742 (setq gnus-newsgroup-none-id
8743 (1+ gnus-newsgroup-none-id)))))))
8747 (if (search-forward "\nreferences: " nil t)
8750 (setq end (match-end 0))
8757 (search-backward ">" end t)
8760 (search-backward "<" end t)
8762 ;; Get the references from the in-reply-to header if there
8763 ;; were no references and the in-reply-to header looks
8765 (if (and (search-forward "\nin-reply-to: " nil t)
8766 (setq in-reply-to (gnus-header-value))
8767 (string-match "<[^>]+>" in-reply-to))
8769 (setq ref (substring in-reply-to (match-beginning 0)
8771 (setq ref (downcase ref))))
8778 (if (search-forward "\nlines: " nil t)
8779 (if (numberp (setq lines (read cur)))
8785 (and (search-forward "\nxref: " nil t)
8786 (gnus-header-value)))))
8787 (if (and gnus-nocem-hashtb
8788 (gnus-gethash id gnus-nocem-hashtb))
8791 ;; We do the threading while we read the headers. The
8792 ;; message-id and the last reference are both entered into
8793 ;; the same hash table. Some tippy-toeing around has to be
8794 ;; done in case an article has arrived before the article
8795 ;; which it refers to.
8796 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8797 (if (and (car (symbol-value id-dep))
8799 ;; An article with this Message-ID has already
8800 ;; been seen, so we ignore this one, except we add
8801 ;; any additional Xrefs (in case the two articles
8802 ;; came from different servers).
8804 (mail-header-set-xref
8805 (car (symbol-value id-dep))
8806 (concat (or (mail-header-xref
8807 (car (symbol-value id-dep))) "")
8808 (or (mail-header-xref header) "")))
8810 (setcar (symbol-value id-dep) header))
8811 (set id-dep (list header))))
8813 (if (boundp (setq ref-dep (intern ref dependencies)))
8814 (setcdr (symbol-value ref-dep)
8815 (nconc (cdr (symbol-value ref-dep))
8816 (list (symbol-value id-dep))))
8817 (set ref-dep (list nil (symbol-value id-dep))))
8818 (setq headers (cons header headers)))
8819 (goto-char (point-max))
8821 (nreverse headers)))))
8823 ;; The following macros and functions were written by Felix Lee
8824 ;; <flee@cse.psu.edu>.
8826 (defmacro gnus-nov-read-integer ()
8828 (if (= (following-char) ?\t)
8830 (let ((num (condition-case nil (read buffer) (error nil))))
8831 (if (numberp num) num 0)))
8832 (or (eobp) (forward-char 1))))
8834 (defmacro gnus-nov-skip-field ()
8835 '(search-forward "\t" eol 'move))
8837 (defmacro gnus-nov-field ()
8838 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
8840 ;; Goes through the xover lines and returns a list of vectors
8841 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
8842 "Parse the news overview data in the server buffer, and return a
8843 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
8844 ;; Get the Xref when the users reads the articles since most/some
8845 ;; NNTP servers do not include Xrefs when using XOVER.
8846 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
8847 (let ((cur nntp-server-buffer)
8848 (dependencies gnus-newsgroup-dependencies)
8849 number headers header)
8851 (set-buffer nntp-server-buffer)
8852 ;; Allow the user to mangle the headers before parsing them.
8853 (run-hooks 'gnus-parse-headers-hook)
8854 ;; Allow the user to mangle the headers before parsing them.
8855 (run-hooks 'gnus-parse-headers-hook)
8856 (goto-char (point-min))
8857 (while (and sequence (not (eobp)))
8858 (setq number (read cur))
8859 (while (and sequence (< (car sequence) number))
8860 (setq sequence (cdr sequence)))
8862 (eq number (car sequence))
8864 (setq sequence (cdr sequence))
8866 (inline (gnus-nov-parse-line
8867 number dependencies force-new)))
8868 (setq headers (cons header headers)))))
8870 (setq headers (nreverse headers)))
8873 ;; This function has to be called with point after the article number
8874 ;; on the beginning of the line.
8875 (defun gnus-nov-parse-line (number dependencies &optional force-new)
8877 (eol (gnus-point-at-eol))
8878 (buffer (current-buffer))
8879 header ref id id-dep ref-dep)
8881 ;; overview: [num subject from date id refs chars lines misc]
8882 (narrow-to-region (point) eol)
8883 (or (eobp) (forward-char))
8889 (gnus-nov-field) ; subject
8890 (gnus-nov-field) ; from
8891 (gnus-nov-field) ; date
8892 (setq id (or (gnus-nov-field)
8895 (setq none (1+ none)))))) ; id
8898 (let ((beg (point)))
8899 (search-forward "\t" eol)
8900 (if (search-backward ">" beg t)
8906 (search-backward "<" beg t)
8909 (gnus-nov-field)) ; refs
8910 (gnus-nov-read-integer) ; chars
8911 (gnus-nov-read-integer) ; lines
8912 (if (= (following-char) ?\n)
8914 (gnus-nov-field)) ; misc
8918 (gnus-message 4 "Strange nov line")
8924 ;; We build the thread tree.
8926 (if (and gnus-nocem-hashtb
8927 (gnus-gethash id gnus-nocem-hashtb))
8930 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8931 (if (and (car (symbol-value id-dep))
8933 ;; An article with this Message-ID has already been seen,
8934 ;; so we ignore this one, except we add any additional
8935 ;; Xrefs (in case the two articles came from different
8938 (mail-header-set-xref
8939 (car (symbol-value id-dep))
8940 (concat (or (mail-header-xref
8941 (car (symbol-value id-dep))) "")
8942 (or (mail-header-xref header) "")))
8944 (setcar (symbol-value id-dep) header))
8945 (set id-dep (list header)))))
8948 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
8949 (setcdr (symbol-value ref-dep)
8950 (nconc (cdr (symbol-value ref-dep))
8951 (list (symbol-value id-dep))))
8952 (set ref-dep (list nil (symbol-value id-dep))))))
8955 (defun gnus-article-get-xrefs ()
8956 "Fill in the Xref value in `gnus-current-headers', if necessary.
8957 This is meant to be called in `gnus-article-internal-prepare-hook'."
8958 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
8959 gnus-current-headers)))
8960 (or (not gnus-use-cross-reference)
8962 (and (mail-header-xref headers)
8963 (not (string= (mail-header-xref headers) "")))
8964 (let ((case-fold-search t)
8967 (nnheader-narrow-to-headers)
8968 (goto-char (point-min))
8969 (if (or (and (eq (downcase (following-char)) ?x)
8970 (looking-at "Xref:"))
8971 (search-forward "\nXref:" nil t))
8973 (goto-char (1+ (match-end 0)))
8974 (setq xref (buffer-substring (point)
8975 (progn (end-of-line) (point))))
8976 (mail-header-set-xref headers xref))))))))
8978 (defun gnus-summary-insert-subject (id)
8979 "Find article ID and insert the summary line for that article."
8980 (let ((header (gnus-read-header id))
8981 (number (and (numberp id) id)))
8983 ;; Rebuild the thread that this article is part of and go to the
8984 ;; article we have fetched.
8985 (gnus-rebuild-thread (mail-header-id header))
8986 (gnus-summary-goto-subject (setq number (mail-header-number header))))
8987 (when (and (numberp number)
8989 ;; We have to update the boundaries even if we can't fetch the
8990 ;; article if ID is a number -- so that the next `P' or `N'
8991 ;; command will fetch the previous (or next) article even
8992 ;; if the one we tried to fetch this time has been canceled.
8993 (and (> number gnus-newsgroup-end)
8994 (setq gnus-newsgroup-end number))
8995 (and (< number gnus-newsgroup-begin)
8996 (setq gnus-newsgroup-begin number))
8997 (setq gnus-newsgroup-unselected
8998 (delq number gnus-newsgroup-unselected)))
8999 ;; Report back a success?
9000 (and header number)))
9002 (defun gnus-summary-work-articles (n)
9003 "Return a list of articles to be worked upon. The prefix argument,
9004 the list of process marked articles, and the current article will be
9005 taken into consideration."
9007 ((and n (numberp n))
9008 ;; A numerical prefix has been given.
9009 (let ((backward (< n 0))
9015 (push (setq article (gnus-summary-article-number))
9018 (gnus-summary-find-prev nil article)
9019 (gnus-summary-find-next nil article)))
9021 (nreverse articles)))
9022 ((and (boundp 'transient-mark-mode)
9025 ;; Work on the region between point and mark.
9026 (let ((max (max (point) (mark)))
9029 (goto-char (min (point) (mark)))
9032 (push (setq article (gnus-summary-article-number)) articles)
9033 (gnus-summary-find-next nil article)
9035 (nreverse articles))))
9036 (gnus-newsgroup-processable
9037 ;; There are process-marked articles present.
9038 (reverse gnus-newsgroup-processable))
9040 ;; Just return the current article.
9041 (list (gnus-summary-article-number)))))
9043 (defun gnus-summary-search-group (&optional backward use-level)
9044 "Search for next unread newsgroup.
9045 If optional argument BACKWARD is non-nil, search backward instead."
9047 (set-buffer gnus-group-buffer)
9048 (if (gnus-group-search-forward
9049 backward nil (if use-level (gnus-group-group-level) nil))
9050 (gnus-group-group-name))))
9052 (defun gnus-summary-best-group (&optional exclude-group)
9053 "Find the name of the best unread group.
9054 If EXCLUDE-GROUP, do not go to this group."
9056 (set-buffer gnus-group-buffer)
9058 (gnus-group-best-unread-group exclude-group))))
9060 (defun gnus-summary-find-next (&optional unread article backward)
9061 (if backward (gnus-summary-find-prev)
9062 (let* ((article (or article (gnus-summary-article-number)))
9063 (arts (gnus-data-find-list article))
9065 (when (or (not gnus-summary-check-current)
9067 (not (gnus-data-unread-p (car arts))))
9068 (setq arts (cdr arts)))
9073 (when (gnus-data-unread-p (car arts))
9074 (setq result (car arts)
9076 (setq arts (cdr arts)))
9079 (goto-char (gnus-data-pos result))
9080 (gnus-data-number result)))))
9082 (defun gnus-summary-find-prev (&optional unread article)
9083 (let* ((article (or article (gnus-summary-article-number)))
9084 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9086 (when (or (not gnus-summary-check-current)
9088 (not (gnus-data-unread-p (car arts))))
9089 (setq arts (cdr arts)))
9094 (and (gnus-data-unread-p (car arts))
9095 (setq result (car arts)
9097 (setq arts (cdr arts)))
9101 (goto-char (gnus-data-pos result))
9102 (gnus-data-number result)))))
9104 (defun gnus-summary-find-subject (subject &optional unread backward article)
9105 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9106 (article (or article (gnus-summary-article-number)))
9107 (articles (gnus-data-list backward))
9108 (arts (gnus-data-find-list article articles))
9110 (when (or (not gnus-summary-check-current)
9112 (not (gnus-data-unread-p (car arts))))
9113 (setq arts (cdr arts)))
9115 (and (or (not unread)
9116 (gnus-data-unread-p (car arts)))
9117 (vectorp (gnus-data-header (car arts)))
9119 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9120 (setq result (car arts)
9122 (setq arts (cdr arts)))
9124 (goto-char (gnus-data-pos result))
9125 (gnus-data-number result))))
9127 (defun gnus-summary-search-forward (&optional unread subject backward)
9129 (gnus-summary-find-subject subject unread backward))
9131 (gnus-summary-find-prev unread))
9133 (gnus-summary-find-next unread))))
9135 (defun gnus-recenter ()
9136 "Center point in window and redisplay frame.
9137 Also do horizontal recentering."
9139 (gnus-horizontal-recenter)
9142 (defun gnus-summary-recenter ()
9143 "Center point in the summary window.
9144 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9145 displayed, no centering will be performed."
9146 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9147 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9148 (let* ((top (cond ((< (window-height) 4) 0)
9149 ((< (window-height) 7) 1)
9151 (height (1- (window-height)))
9152 (bottom (save-excursion (goto-char (point-max))
9153 (forward-line (- height))
9155 (window (get-buffer-window (current-buffer))))
9156 ;; The user has to want it.
9157 (when gnus-auto-center-summary
9158 (when (get-buffer-window gnus-article-buffer)
9159 ;; Only do recentering when the article buffer is displayed,
9160 ;; Set the window start to either `bottom', which is the biggest
9161 ;; possible valid number, or the second line from the top,
9162 ;; whichever is the least.
9164 window (min bottom (save-excursion
9165 (forward-line (- top)) (point)))))
9166 ;; Do horizontal recentering while we're at it.
9167 (let ((selected (selected-window)))
9168 (select-window (get-buffer-window (current-buffer) t))
9169 (gnus-summary-position-point)
9170 (gnus-horizontal-recenter)
9171 (select-window selected)))))
9173 (defun gnus-horizontal-recenter ()
9174 "Recenter the current buffer horizontally."
9175 (if (< (current-column) (/ (window-width) 2))
9176 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9177 (let* ((orig (point))
9178 (end (window-end (get-buffer-window (current-buffer) t)))
9180 ;; Find the longest line currently displayed in the window.
9181 (goto-char (window-start))
9182 (while (and (not (eobp))
9185 (setq max (max max (current-column)))
9188 ;; Scroll horizontally to center (sort of) the point.
9189 (if (> max (window-width))
9191 (get-buffer-window (current-buffer) t)
9192 (min (- (current-column) (/ (window-width) 3))
9193 (+ 2 (- max (window-width)))))
9194 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9197 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9198 (defun gnus-short-group-name (group &optional levels)
9199 "Collapse GROUP name LEVELS."
9206 (while (string-match "\\." group skip)
9207 (setq skip (match-end 0)
9210 (if (string-match ":" group)
9211 (setq foreign (substring group 0 (match-end 0))
9212 group (substring group (match-end 0))))
9214 (if (and (string-match "\\." group)
9215 (> levels (- gnus-group-uncollapsed-levels 1)))
9216 (setq name (concat name (substring group 0 1))
9217 group (substring group (match-end 0))
9219 name (concat name "."))
9220 (setq name (concat foreign name group)
9224 (defun gnus-summary-jump-to-group (newsgroup)
9225 "Move point to NEWSGROUP in group mode buffer."
9226 ;; Keep update point of group mode buffer if visible.
9227 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9228 (save-window-excursion
9229 ;; Take care of tree window mode.
9230 (if (get-buffer-window gnus-group-buffer)
9231 (pop-to-buffer gnus-group-buffer))
9232 (gnus-group-jump-to-group newsgroup))
9234 ;; Take care of tree window mode.
9235 (if (get-buffer-window gnus-group-buffer)
9236 (pop-to-buffer gnus-group-buffer)
9237 (set-buffer gnus-group-buffer))
9238 (gnus-group-jump-to-group newsgroup))))
9240 ;; This function returns a list of article numbers based on the
9241 ;; difference between the ranges of read articles in this group and
9242 ;; the range of active articles.
9243 (defun gnus-list-of-unread-articles (group)
9244 (let* ((read (gnus-info-read (gnus-get-info group)))
9245 (active (gnus-active group))
9248 ;; If none are read, then all are unread.
9250 (setq first (car active))
9251 ;; If the range of read articles is a single range, then the
9252 ;; first unread article is the article after the last read
9253 ;; article. Sounds logical, doesn't it?
9254 (if (not (listp (cdr read)))
9255 (setq first (1+ (cdr read)))
9256 ;; `read' is a list of ranges.
9257 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9258 (car (car read)))) 1)
9262 (while (< first nlast)
9263 (setq unread (cons first unread))
9264 (setq first (1+ first))))
9265 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9266 (setq nlast (if (atom (car (cdr read)))
9268 (car (car (cdr read)))))
9269 (setq read (cdr read)))))
9270 ;; And add the last unread articles.
9271 (while (<= first last)
9272 (setq unread (cons first unread))
9273 (setq first (1+ first)))
9274 ;; Return the list of unread articles.
9277 (defun gnus-list-of-read-articles (group)
9278 "Return a list of unread, unticked and non-dormant articles."
9279 (let* ((info (gnus-get-info group))
9280 (marked (gnus-info-marks info))
9281 (active (gnus-active group)))
9283 (gnus-set-difference
9284 (gnus-sorted-complement
9285 (gnus-uncompress-range active)
9286 (gnus-list-of-unread-articles group))
9288 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9289 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9291 ;; Various summary commands
9293 (defun gnus-summary-universal-argument (arg)
9294 "Perform any operation on all articles that are process/prefixed."
9296 (gnus-set-global-variables)
9297 (let ((articles (gnus-summary-work-articles arg))
9304 (substitute-command-keys
9305 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9309 (message "Undefined key")
9313 (gnus-summary-goto-subject (setq article (pop articles)))
9314 (command-execute func)
9315 (gnus-summary-remove-process-mark article)))))
9316 (gnus-summary-position-point))
9318 (defun gnus-summary-toggle-truncation (&optional arg)
9319 "Toggle truncation of summary lines.
9320 With arg, turn line truncation on iff arg is positive."
9322 (setq truncate-lines
9323 (if (null arg) (not truncate-lines)
9324 (> (prefix-numeric-value arg) 0)))
9327 (defun gnus-summary-reselect-current-group (&optional all rescan)
9328 "Exit and then reselect the current newsgroup.
9329 The prefix argument ALL means to select all articles."
9331 (gnus-set-global-variables)
9332 (let ((current-subject (gnus-summary-article-number))
9333 (group gnus-newsgroup-name))
9334 (setq gnus-newsgroup-begin nil)
9336 ;; We have to adjust the point of group mode buffer because the
9337 ;; current point was moved to the next unread newsgroup by
9339 (gnus-summary-jump-to-group group)
9342 (gnus-group-get-new-news-this-group 1)))
9343 (gnus-group-read-group all t)
9344 (gnus-summary-goto-subject current-subject)))
9346 (defun gnus-summary-rescan-group (&optional all)
9347 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9349 (gnus-summary-reselect-current-group all t))
9351 (defun gnus-summary-update-info ()
9352 (let* ((group gnus-newsgroup-name))
9353 (when gnus-newsgroup-kill-headers
9354 (setq gnus-newsgroup-killed
9355 (gnus-compress-sequence
9357 (gnus-set-sorted-intersection
9358 (gnus-uncompress-range gnus-newsgroup-killed)
9359 (setq gnus-newsgroup-unselected
9360 (sort gnus-newsgroup-unselected '<)))
9361 (setq gnus-newsgroup-unreads
9362 (sort gnus-newsgroup-unreads '<))) t)))
9363 (unless (listp (cdr gnus-newsgroup-killed))
9364 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9365 (let ((headers gnus-newsgroup-headers))
9366 (gnus-close-group group)
9367 (run-hooks 'gnus-exit-group-hook)
9368 (unless gnus-save-score
9369 (setq gnus-newsgroup-scored nil))
9370 ;; Set the new ranges of read articles.
9371 (gnus-update-read-articles
9372 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9373 ;; Set the current article marks.
9375 ;; Do the cross-ref thing.
9376 (when gnus-use-cross-reference
9377 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9378 ;; Do adaptive scoring, and possibly save score files.
9379 (when gnus-newsgroup-adaptive
9380 (gnus-score-adaptive))
9381 (when gnus-use-scoring
9383 ;; Do not switch windows but change the buffer to work.
9384 (set-buffer gnus-group-buffer)
9385 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9386 (gnus-group-update-group group)))))
9388 (defun gnus-summary-exit (&optional temporary)
9389 "Exit reading current newsgroup, and then return to group selection mode.
9390 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9392 (gnus-set-global-variables)
9393 (gnus-kill-save-kill-buffer)
9394 (let* ((group gnus-newsgroup-name)
9395 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9397 (buf (current-buffer)))
9398 (run-hooks 'gnus-summary-prepare-exit-hook)
9399 (when gnus-use-cache
9400 (gnus-cache-possibly-remove-articles)
9401 (gnus-cache-save-buffers))
9402 (when gnus-use-trees
9403 (gnus-tree-close group))
9404 ;; Make all changes in this group permanent.
9405 (gnus-summary-update-info)
9406 ;; Make sure where I was, and go to next newsgroup.
9407 (set-buffer gnus-group-buffer)
9410 (gnus-group-jump-to-group group)
9411 (gnus-group-next-unread-group 1)))
9412 (run-hooks 'gnus-summary-exit-hook)
9415 ;; If we have several article buffers, we kill them at exit.
9416 (unless gnus-single-article-buffer
9417 (gnus-kill-buffer gnus-article-buffer)
9418 (gnus-kill-buffer gnus-original-article-buffer))
9420 (if (not gnus-kill-summary-on-exit)
9421 (gnus-deaden-summary)
9422 ;; We set all buffer-local variables to nil. It is unclear why
9423 ;; this is needed, but if we don't, buffer-local variables are
9424 ;; not garbage-collected, it seems. This would the lead to en
9425 ;; ever-growing Emacs.
9426 (gnus-summary-clear-local-variables)
9427 ;; We clear the global counterparts of the buffer-local
9428 ;; variables as well, just to be on the safe side.
9429 (gnus-configure-windows 'group 'force)
9430 (gnus-summary-clear-local-variables)
9431 ;; Return to group mode buffer.
9432 (if (eq mode 'gnus-summary-mode)
9433 (gnus-kill-buffer buf)))
9434 (setq gnus-current-select-method gnus-select-method)
9435 (pop-to-buffer gnus-group-buffer)
9436 ;; Clear the current group name.
9437 (if (not quit-config)
9439 (gnus-group-jump-to-group group)
9440 (gnus-group-next-unread-group 1)
9441 (gnus-configure-windows 'group 'force))
9442 (if (not (buffer-name (car quit-config)))
9443 (gnus-configure-windows 'group 'force)
9444 (set-buffer (car quit-config))
9445 (and (eq major-mode 'gnus-summary-mode)
9446 (gnus-set-global-variables))
9447 (gnus-configure-windows (cdr quit-config))))
9449 (setq gnus-newsgroup-name nil)))))
9451 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9452 (defun gnus-summary-exit-no-update (&optional no-questions)
9453 "Quit reading current newsgroup without updating read article info."
9455 (gnus-set-global-variables)
9456 (let* ((group gnus-newsgroup-name)
9457 (quit-config (gnus-group-quit-config group)))
9458 (when (or no-questions
9460 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9461 ;; If we have several article buffers, we kill them at exit.
9462 (unless gnus-single-article-buffer
9463 (gnus-kill-buffer gnus-article-buffer)
9464 (gnus-kill-buffer gnus-original-article-buffer))
9465 (if (not gnus-kill-summary-on-exit)
9466 (gnus-deaden-summary)
9467 (gnus-close-group group)
9468 (gnus-summary-clear-local-variables)
9469 (set-buffer gnus-group-buffer)
9470 (gnus-summary-clear-local-variables)
9471 (when (get-buffer gnus-summary-buffer)
9472 (kill-buffer gnus-summary-buffer)))
9473 (when gnus-use-trees
9474 (gnus-tree-close group))
9475 ;; Return to the group buffer.
9476 (gnus-configure-windows 'group 'force)
9477 ;; Clear the current group name.
9478 (setq gnus-newsgroup-name nil)
9479 (when (equal (gnus-group-group-name) group)
9480 (gnus-group-next-unread-group 1))
9482 (if (not (buffer-name (car quit-config)))
9483 (gnus-configure-windows 'group 'force)
9484 (set-buffer (car quit-config))
9485 (when (eq major-mode 'gnus-summary-mode)
9486 (gnus-set-global-variables))
9487 (gnus-configure-windows (cdr quit-config)))))))
9491 (defvar gnus-dead-summary-mode-map nil)
9493 (if gnus-dead-summary-mode-map
9495 (setq gnus-dead-summary-mode-map (make-keymap))
9496 (suppress-keymap gnus-dead-summary-mode-map)
9497 (substitute-key-definition
9498 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9499 (let ((keys '("\C-d" "\r" "\177")))
9501 (define-key gnus-dead-summary-mode-map
9502 (pop keys) 'gnus-summary-wake-up-the-dead))))
9504 (defvar gnus-dead-summary-mode nil
9505 "Minor mode for Gnus summary buffers.")
9507 (defun gnus-dead-summary-mode (&optional arg)
9508 "Minor mode for Gnus summary buffers."
9510 (when (eq major-mode 'gnus-summary-mode)
9511 (make-local-variable 'gnus-dead-summary-mode)
9512 (setq gnus-dead-summary-mode
9513 (if (null arg) (not gnus-dead-summary-mode)
9514 (> (prefix-numeric-value arg) 0)))
9515 (when gnus-dead-summary-mode
9516 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9517 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9518 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9519 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9520 minor-mode-map-alist)))))
9522 (defun gnus-deaden-summary ()
9523 "Make the current summary buffer into a dead summary buffer."
9524 ;; Kill any previous dead summary buffer.
9525 (when (and gnus-dead-summary
9526 (buffer-name gnus-dead-summary))
9528 (set-buffer gnus-dead-summary)
9529 (when gnus-dead-summary-mode
9530 (kill-buffer (current-buffer)))))
9531 ;; Make this the current dead summary.
9532 (setq gnus-dead-summary (current-buffer))
9533 (gnus-dead-summary-mode 1)
9534 (let ((name (buffer-name)))
9535 (when (string-match "Summary" name)
9537 (concat (substring name 0 (match-beginning 0)) "Dead "
9538 (substring name (match-beginning 0))) t))))
9540 (defun gnus-kill-or-deaden-summary (buffer)
9541 "Kill or deaden the summary BUFFER."
9542 (cond (gnus-kill-summary-on-exit
9543 (when (and gnus-use-trees
9544 (and (get-buffer buffer)
9545 (buffer-name (get-buffer buffer))))
9547 (set-buffer (get-buffer buffer))
9548 (gnus-tree-close gnus-newsgroup-name)))
9549 (gnus-kill-buffer buffer))
9550 ((and (get-buffer buffer)
9551 (buffer-name (get-buffer buffer)))
9554 (gnus-deaden-summary)))))
9556 (defun gnus-summary-wake-up-the-dead (&rest args)
9557 "Wake up the dead summary buffer."
9559 (gnus-dead-summary-mode -1)
9560 (let ((name (buffer-name)))
9561 (when (string-match "Dead " name)
9563 (concat (substring name 0 (match-beginning 0))
9564 (substring name (match-end 0))) t)))
9565 (gnus-message 3 "This dead summary is now alive again"))
9567 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9568 (defun gnus-summary-fetch-faq (&optional faq-dir)
9569 "Fetch the FAQ for the current group.
9570 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9574 (if current-prefix-arg
9576 "Faq dir: " (and (listp gnus-group-faq-directory)
9577 gnus-group-faq-directory)))))
9578 (let (gnus-faq-buffer)
9579 (and (setq gnus-faq-buffer
9580 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9581 (gnus-configure-windows 'summary-faq))))
9583 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9584 (defun gnus-summary-describe-group (&optional force)
9585 "Describe the current newsgroup."
9587 (gnus-group-describe-group force gnus-newsgroup-name))
9589 (defun gnus-summary-describe-briefly ()
9590 "Describe summary mode commands briefly."
9593 (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")))
9595 ;; Walking around group mode buffer from summary mode.
9597 (defun gnus-summary-next-group (&optional no-article target-group backward)
9598 "Exit current newsgroup and then select next unread newsgroup.
9599 If prefix argument NO-ARTICLE is non-nil, no article is selected
9600 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9601 previous group instead."
9603 (gnus-set-global-variables)
9604 (let ((current-group gnus-newsgroup-name)
9605 (current-buffer (current-buffer))
9607 ;; First we semi-exit this group to update Xrefs and all variables.
9608 ;; We can't do a real exit, because the window conf must remain
9609 ;; the same in case the user is prompted for info, and we don't
9610 ;; want the window conf to change before that...
9611 (gnus-summary-exit t)
9612 (while (not entered)
9613 ;; Then we find what group we are supposed to enter.
9614 (set-buffer gnus-group-buffer)
9615 (gnus-group-jump-to-group current-group)
9618 (if (eq gnus-keep-same-level 'best)
9619 (gnus-summary-best-group gnus-newsgroup-name)
9620 (gnus-summary-search-group backward gnus-keep-same-level))))
9621 (if (not target-group)
9622 ;; There are no further groups, so we return to the group
9625 (gnus-message 5 "Returning to the group buffer")
9627 (set-buffer current-buffer)
9628 (gnus-summary-exit))
9629 ;; We try to enter the target group.
9630 (gnus-group-jump-to-group target-group)
9631 (let ((unreads (gnus-group-group-unread)))
9632 (if (and (or (eq t unreads)
9633 (and unreads (not (zerop unreads))))
9634 (gnus-summary-read-group
9635 target-group nil no-article current-buffer))
9637 (setq current-group target-group
9638 target-group nil)))))))
9640 (defun gnus-summary-prev-group (&optional no-article)
9641 "Exit current newsgroup and then select previous unread newsgroup.
9642 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9644 (gnus-summary-next-group no-article nil t))
9646 ;; Walking around summary lines.
9648 (defun gnus-summary-first-subject (&optional unread)
9649 "Go to the first unread subject.
9650 If UNREAD is non-nil, go to the first unread article.
9651 Returns the article selected or nil if there are no unread articles."
9656 ((null gnus-newsgroup-data)
9657 (gnus-message 3 "No articles in the group")
9659 ;; Pick the first article.
9661 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9662 (gnus-data-number (car gnus-newsgroup-data)))
9663 ;; No unread articles.
9664 ((null gnus-newsgroup-unreads)
9665 (gnus-message 3 "No more unread articles")
9667 ;; Find the first unread article.
9669 (let ((data gnus-newsgroup-data))
9671 (not (gnus-data-unread-p (car data))))
9672 (setq data (cdr data)))
9675 (goto-char (gnus-data-pos (car data)))
9676 (gnus-data-number (car data)))))))
9677 (gnus-summary-position-point)))
9679 (defun gnus-summary-next-subject (n &optional unread dont-display)
9680 "Go to next N'th summary line.
9681 If N is negative, go to the previous N'th subject line.
9682 If UNREAD is non-nil, only unread articles are selected.
9683 The difference between N and the actual number of steps taken is
9686 (let ((backward (< n 0))
9690 (gnus-summary-find-prev unread)
9691 (gnus-summary-find-next unread)))
9693 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9694 (if unread " unread" "")))
9697 (gnus-summary-recenter)
9698 (gnus-summary-position-point)))
9701 (defun gnus-summary-next-unread-subject (n)
9702 "Go to next N'th unread summary line."
9704 (gnus-summary-next-subject n t))
9706 (defun gnus-summary-prev-subject (n &optional unread)
9707 "Go to previous N'th summary line.
9708 If optional argument UNREAD is non-nil, only unread article is selected."
9710 (gnus-summary-next-subject (- n) unread))
9712 (defun gnus-summary-prev-unread-subject (n)
9713 "Go to previous N'th unread summary line."
9715 (gnus-summary-next-subject (- n) t))
9717 (defun gnus-summary-goto-subject (article &optional force silent)
9718 "Go the subject line of ARTICLE.
9719 If FORCE, also allow jumping to articles not currently shown."
9721 (data (gnus-data-find article)))
9722 ;; We read in the article if we have to.
9725 (gnus-summary-insert-subject article)
9726 (setq data (gnus-data-find article)))
9731 (gnus-message 3 "Can't find article %d" article))
9733 (goto-char (gnus-data-pos data))
9736 ;; Walking around summary lines with displaying articles.
9738 (defun gnus-summary-expand-window (&optional arg)
9739 "Make the summary buffer take up the entire Emacs frame.
9740 Given a prefix, will force an `article' buffer configuration."
9742 (gnus-set-global-variables)
9744 (gnus-configure-windows 'article 'force)
9745 (gnus-configure-windows 'summary 'force)))
9747 (defun gnus-summary-display-article (article &optional all-header)
9748 "Display ARTICLE in article buffer."
9749 (gnus-set-global-variables)
9753 (if gnus-summary-display-article-function
9754 (funcall gnus-summary-display-article-function article all-header)
9755 (gnus-article-prepare article all-header))
9756 (run-hooks 'gnus-select-article-hook)
9757 (gnus-summary-recenter)
9758 (gnus-summary-goto-subject article)
9759 (when gnus-use-trees
9760 (gnus-possibly-generate-tree article)
9761 (gnus-highlight-selected-tree article))
9762 ;; Successfully display article.
9763 (gnus-article-set-window-start
9764 (cdr (assq article gnus-newsgroup-bookmarks)))
9767 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9768 "Select the current article.
9769 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9770 non-nil, the article will be re-fetched even if it already present in
9771 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9773 (let ((article (or article (gnus-summary-article-number)))
9774 (all-headers (not (not all-headers))) ;Must be T or NIL.
9775 gnus-summary-display-article-function
9778 (gnus-summary-article-pseudo-p article)
9779 (error "This is a pseudo-article."))
9782 (set-buffer gnus-summary-buffer)
9783 (if (or (and gnus-single-article-buffer
9784 (or (null gnus-current-article)
9785 (null gnus-article-current)
9786 (null (get-buffer gnus-article-buffer))
9787 (not (eq article (cdr gnus-article-current)))
9788 (not (equal (car gnus-article-current)
9789 gnus-newsgroup-name))))
9790 (and (not gnus-single-article-buffer)
9791 (null gnus-current-article))
9793 ;; The requested article is different from the current article.
9795 (gnus-summary-display-article article all-headers)
9797 (if (or all-headers gnus-show-all-headers)
9798 (gnus-article-show-all-headers))
9801 (gnus-article-set-window-start
9802 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9804 (defun gnus-summary-set-current-mark (&optional current-mark)
9805 "Obsolete function."
9808 (defun gnus-summary-next-article (&optional unread subject backward push)
9809 "Select the next article.
9810 If UNREAD, only unread articles are selected.
9811 If SUBJECT, only articles with SUBJECT are selected.
9812 If BACKWARD, the previous article is selected instead of the next."
9814 (gnus-set-global-variables)
9817 ;; Is there such an article?
9818 ((and (gnus-summary-search-forward unread subject backward)
9819 (or (gnus-summary-display-article (gnus-summary-article-number))
9820 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9821 (gnus-summary-position-point))
9822 ;; If not, we try the first unread, if that is wanted.
9824 gnus-auto-select-same
9825 (or (gnus-summary-first-unread-article)
9826 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9827 (gnus-summary-position-point)
9828 (gnus-message 6 "Wrapped"))
9829 ;; Try to get next/previous article not displayed in this group.
9830 ((and gnus-auto-extend-newsgroup
9831 (not unread) (not subject))
9832 (gnus-summary-goto-article
9833 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
9835 ;; Go to next/previous group.
9837 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9838 (gnus-summary-jump-to-group gnus-newsgroup-name))
9839 (let ((cmd last-command-char)
9841 (if (eq gnus-keep-same-level 'best)
9842 (gnus-summary-best-group gnus-newsgroup-name)
9843 (gnus-summary-search-group backward gnus-keep-same-level))))
9844 ;; For some reason, the group window gets selected. We change
9846 (select-window (get-buffer-window (current-buffer)))
9847 ;; Select next unread newsgroup automagically.
9849 ((not gnus-auto-select-next)
9850 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
9851 ((or (eq gnus-auto-select-next 'quietly)
9852 (and (eq gnus-auto-select-next 'slightly-quietly)
9854 (and (eq gnus-auto-select-next 'almost-quietly)
9855 (gnus-summary-last-article-p)))
9857 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
9859 (gnus-message 7 "No more%s articles (%s)..."
9860 (if unread " unread" "")
9861 (if group (concat "selecting " group)
9863 (gnus-summary-next-group nil group backward)))
9865 (gnus-summary-walk-group-buffer
9866 gnus-newsgroup-name cmd unread backward))))))))
9868 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
9869 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
9870 (?\C-p (gnus-group-prev-unread-group 1))))
9871 keve key group ended)
9873 (set-buffer gnus-group-buffer)
9874 (gnus-summary-jump-to-group from-group)
9876 (if (eq gnus-keep-same-level 'best)
9877 (gnus-summary-best-group gnus-newsgroup-name)
9878 (gnus-summary-search-group backward gnus-keep-same-level))))
9881 7 "No more%s articles%s" (if unread " unread" "")
9883 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
9884 (format " (Type %s for %s [%s])"
9885 (single-key-description cmd) group
9886 (car (gnus-gethash group gnus-newsrc-hashtb)))
9887 (format " (Type %s to exit %s)"
9888 (single-key-description cmd)
9889 gnus-newsgroup-name)))
9890 ;; Confirm auto selection.
9891 (setq key (car (setq keve (gnus-read-event-char))))
9894 ((assq key keystrokes)
9895 (let ((obuf (current-buffer)))
9896 (switch-to-buffer gnus-group-buffer)
9898 (gnus-group-jump-to-group group))
9899 (eval (car (cdr (assq key keystrokes))))
9900 (setq group (gnus-group-group-name))
9901 (switch-to-buffer obuf))
9905 (gnus-ephemeral-group-p gnus-newsgroup-name))
9907 (gnus-summary-next-group nil group backward)))
9909 (push (cdr keve) unread-command-events))))))
9911 (defun gnus-read-event-char ()
9912 "Get the next event."
9913 (let ((event (read-event)))
9914 (cons (and (numberp event) event) event)))
9916 (defun gnus-summary-next-unread-article ()
9917 "Select unread article after current one."
9919 (gnus-summary-next-article t (and gnus-auto-select-same
9920 (gnus-summary-article-subject))))
9922 (defun gnus-summary-prev-article (&optional unread subject)
9923 "Select the article after the current one.
9924 If UNREAD is non-nil, only unread articles are selected."
9926 (gnus-summary-next-article unread subject t))
9928 (defun gnus-summary-prev-unread-article ()
9929 "Select unred article before current one."
9931 (gnus-summary-prev-article t (and gnus-auto-select-same
9932 (gnus-summary-article-subject))))
9934 (defun gnus-summary-next-page (&optional lines circular)
9935 "Show next page of the selected article.
9936 If at the end of the current article, select the next article.
9937 LINES says how many lines should be scrolled up.
9939 If CIRCULAR is non-nil, go to the start of the article instead of
9940 selecting the next article when reaching the end of the current
9943 (setq gnus-summary-buffer (current-buffer))
9944 (gnus-set-global-variables)
9945 (let ((article (gnus-summary-article-number))
9947 (gnus-configure-windows 'article)
9948 (if (or (null gnus-current-article)
9949 (null gnus-article-current)
9950 (/= article (cdr gnus-article-current))
9951 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
9952 ;; Selected subject is different from current article's.
9953 (gnus-summary-display-article article)
9954 (gnus-eval-in-buffer-window
9956 (setq endp (gnus-article-next-page lines)))
9959 (gnus-summary-beginning-of-article))
9961 (gnus-message 3 "End of message"))
9963 (if (eq gnus-summary-goto-unread 'always)
9964 (gnus-summary-next-article)
9965 (gnus-summary-next-unread-article))))))
9966 (gnus-summary-recenter)
9967 (gnus-summary-position-point)))
9969 (defun gnus-summary-prev-page (&optional lines)
9970 "Show previous page of selected article.
9971 Argument LINES specifies lines to be scrolled down."
9973 (gnus-set-global-variables)
9974 (let ((article (gnus-summary-article-number)))
9975 (gnus-configure-windows 'article)
9976 (if (or (null gnus-current-article)
9977 (null gnus-article-current)
9978 (/= article (cdr gnus-article-current))
9979 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
9980 ;; Selected subject is different from current article's.
9981 (gnus-summary-display-article article)
9982 (gnus-summary-recenter)
9983 (gnus-eval-in-buffer-window gnus-article-buffer
9984 (gnus-article-prev-page lines))))
9985 (gnus-summary-position-point))
9987 (defun gnus-summary-scroll-up (lines)
9988 "Scroll up (or down) one line current article.
9989 Argument LINES specifies lines to be scrolled up (or down if negative)."
9991 (gnus-set-global-variables)
9992 (gnus-configure-windows 'article)
9993 (or (gnus-summary-select-article nil nil 'pseudo)
9994 (gnus-eval-in-buffer-window
9997 (if (gnus-article-next-page lines)
9998 (gnus-message 3 "End of message")))
10000 (gnus-article-prev-page (- lines))))))
10001 (gnus-summary-recenter)
10002 (gnus-summary-position-point))
10004 (defun gnus-summary-next-same-subject ()
10005 "Select next article which has the same subject as current one."
10007 (gnus-set-global-variables)
10008 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10010 (defun gnus-summary-prev-same-subject ()
10011 "Select previous article which has the same subject as current one."
10013 (gnus-set-global-variables)
10014 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10016 (defun gnus-summary-next-unread-same-subject ()
10017 "Select next unread article which has the same subject as current one."
10019 (gnus-set-global-variables)
10020 (gnus-summary-next-article t (gnus-summary-article-subject)))
10022 (defun gnus-summary-prev-unread-same-subject ()
10023 "Select previous unread article which has the same subject as current one."
10025 (gnus-set-global-variables)
10026 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10028 (defun gnus-summary-first-unread-article ()
10029 "Select the first unread article.
10030 Return nil if there are no unread articles."
10032 (gnus-set-global-variables)
10034 (if (gnus-summary-first-subject t)
10036 (gnus-summary-show-thread)
10037 (gnus-summary-first-subject t)
10038 (gnus-summary-display-article (gnus-summary-article-number))))
10039 (gnus-summary-position-point)))
10041 (defun gnus-summary-best-unread-article ()
10042 "Select the unread article with the highest score."
10044 (gnus-set-global-variables)
10045 (let ((best -1000000)
10046 (data gnus-newsgroup-data)
10049 (and (gnus-data-unread-p (car data))
10051 (gnus-summary-article-score (gnus-data-number (car data))))
10054 article (gnus-data-number (car data))))
10055 (setq data (cdr data)))
10057 (gnus-summary-goto-article article)
10058 (error "No unread articles"))
10059 (gnus-summary-position-point)))
10061 (defun gnus-summary-last-subject ()
10062 "Go to the last displayed subject line in the group."
10063 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10065 (gnus-summary-goto-subject article))))
10067 (defun gnus-summary-goto-article (article &optional all-headers force)
10068 "Fetch ARTICLE and display it if it exists.
10069 If ALL-HEADERS is non-nil, no header lines are hidden."
10075 (mapcar (lambda (number) (list (int-to-string number)))
10076 gnus-newsgroup-limit)))
10080 (if (gnus-summary-goto-subject article force)
10081 (gnus-summary-display-article article all-headers)
10082 (gnus-message 4 "Couldn't go to article %s" article) nil)
10083 (gnus-summary-position-point)))
10085 (defun gnus-summary-goto-last-article ()
10086 "Go to the previously read article."
10089 (and gnus-last-article
10090 (gnus-summary-goto-article gnus-last-article))
10091 (gnus-summary-position-point)))
10093 (defun gnus-summary-pop-article (number)
10094 "Pop one article off the history and go to the previous.
10095 NUMBER articles will be popped off."
10098 (setq gnus-newsgroup-history
10099 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10101 (gnus-summary-goto-article (car to))
10102 (error "Article history empty")))
10103 (gnus-summary-position-point))
10105 ;; Summary commands and functions for limiting the summary buffer.
10107 (defun gnus-summary-limit-to-articles (n)
10108 "Limit the summary buffer to the next N articles.
10109 If not given a prefix, use the process marked articles instead."
10111 (gnus-set-global-variables)
10113 (let ((articles (gnus-summary-work-articles n)))
10114 (setq gnus-newsgroup-processable nil)
10115 (gnus-summary-limit articles))
10116 (gnus-summary-position-point)))
10118 (defun gnus-summary-pop-limit (&optional total)
10119 "Restore the previous limit.
10120 If given a prefix, remove all limits."
10122 (gnus-set-global-variables)
10124 (if total (setq gnus-newsgroup-limits
10125 (list (mapcar (lambda (h) (mail-header-number h))
10126 gnus-newsgroup-headers))))
10127 (gnus-summary-limit nil 'pop)
10128 (gnus-summary-position-point)))
10130 (defun gnus-summary-limit-to-subject (subject &optional header)
10131 "Limit the summary buffer to articles that have subjects that match a regexp."
10132 (interactive "sRegexp: ")
10134 (setq header "subject"))
10135 (when (not (equal "" subject))
10137 (let ((articles (gnus-summary-find-matching "subject" subject 'all)))
10138 (or articles (error "Found no matches for \"%s\"" subject))
10139 (gnus-summary-limit articles))
10140 (gnus-summary-position-point))))
10142 (defun gnus-summary-limit-to-author (from)
10143 "Limit the summary buffer to articles that have authors that match a regexp."
10144 (interactive "sRegexp: ")
10145 (gnus-summary-limit-to-subject from "from"))
10147 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10149 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10151 (defun gnus-summary-limit-to-unread (&optional all)
10152 "Limit the summary buffer to articles that are not marked as read.
10153 If ALL is non-nil, limit strictly to unread articles."
10156 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10157 (gnus-summary-limit-to-marks
10158 ;; Concat all the marks that say that an article is read and have
10160 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10161 gnus-killed-mark gnus-kill-file-mark
10162 gnus-low-score-mark gnus-expirable-mark
10163 gnus-canceled-mark gnus-catchup-mark)
10166 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10167 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10169 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10170 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10171 If REVERSE, limit the summary buffer to articles that are not marked
10172 with MARKS. MARKS can either be a string of marks or a list of marks.
10173 Returns how many articles were removed."
10174 (interactive "sMarks: ")
10175 (gnus-set-global-variables)
10177 (let ((data gnus-newsgroup-data)
10178 (marks (if (listp marks) marks
10179 (append marks nil))) ; Transform to list.
10182 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10183 (memq (gnus-data-mark (car data)) marks))
10184 (setq articles (cons (gnus-data-number (car data)) articles)))
10185 (setq data (cdr data)))
10186 (gnus-summary-limit articles))
10187 (gnus-summary-position-point)))
10189 (defun gnus-summary-limit-to-score (&optional score)
10190 "Limit to articles with score at or above SCORE."
10192 (gnus-set-global-variables)
10193 (setq score (if score
10194 (prefix-numeric-value score)
10195 (or gnus-summary-default-score 0)))
10196 (let ((data gnus-newsgroup-data)
10199 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10201 (push (gnus-data-number (car data)) articles))
10202 (setq data (cdr data)))
10204 (gnus-summary-limit articles)
10205 (gnus-summary-position-point))))
10207 (defun gnus-summary-limit-include-dormant ()
10208 "Display all the hidden articles that are marked as dormant."
10210 (gnus-set-global-variables)
10211 (or gnus-newsgroup-dormant
10212 (error "There are no dormant articles in this group"))
10214 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10215 (gnus-summary-position-point)))
10217 (defun gnus-summary-limit-exclude-dormant ()
10218 "Hide all dormant articles."
10220 (gnus-set-global-variables)
10222 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10223 (gnus-summary-position-point)))
10225 (defun gnus-summary-limit-exclude-childless-dormant ()
10226 "Hide all dormant articles that have no children."
10228 (gnus-set-global-variables)
10229 (let ((data gnus-newsgroup-data)
10231 ;; Find all articles that are either not dormant or have
10234 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
10235 (gnus-article-parent-p (gnus-data-number (car data))))
10236 (setq articles (cons (gnus-data-number (car data))
10238 (setq data (cdr data)))
10239 ;; Do the limiting.
10241 (gnus-summary-limit articles)
10242 (gnus-summary-position-point))))
10244 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10245 "Mark all unread excluded articles as read.
10246 If ALL, mark even excluded ticked and dormants as read."
10248 (let ((articles (gnus-sorted-complement
10250 (mapcar (lambda (h) (mail-header-number h))
10251 gnus-newsgroup-headers)
10253 (sort gnus-newsgroup-limit '<)))
10255 (setq gnus-newsgroup-unreads nil)
10257 (setq gnus-newsgroup-dormant nil
10258 gnus-newsgroup-marked nil
10259 gnus-newsgroup-reads
10261 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10262 gnus-newsgroup-reads))
10263 (while (setq article (pop articles))
10264 (unless (or (memq article gnus-newsgroup-dormant)
10265 (memq article gnus-newsgroup-marked))
10266 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10269 (defun gnus-summary-limit (articles &optional pop)
10271 ;; We pop the previous limit off the stack and use that.
10272 (setq articles (car gnus-newsgroup-limits)
10273 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10274 ;; We use the new limit, so we push the old limit on the stack.
10275 (setq gnus-newsgroup-limits
10276 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10278 (setq gnus-newsgroup-limit articles)
10279 (let ((total (length gnus-newsgroup-data))
10280 (data (gnus-data-find-list (gnus-summary-article-number)))
10282 ;; This will do all the work of generating the new summary buffer
10283 ;; according to the new limit.
10284 (gnus-summary-prepare)
10285 ;; Try to return to the article you were at, or on in the
10288 ;; We try to find some article after the current one.
10290 (and (gnus-summary-goto-subject
10291 (gnus-data-number (car data)) nil t)
10294 (setq data (cdr data))))
10296 ;; If there is no data, that means that we were after the last
10297 ;; article. The same goes when we can't find any articles
10298 ;; after the current one.
10300 (goto-char (point-max))
10301 (gnus-summary-find-prev)))
10302 ;; We return how many articles were removed from the summary
10303 ;; buffer as a result of the new limit.
10304 (- total (length gnus-newsgroup-data))))
10306 (defsubst gnus-cut-thread (thread)
10307 "Go forwards in the thread until we find an article that we want to display."
10308 (if (eq gnus-fetch-old-headers 'some)
10310 (memq (mail-header-number (car thread))
10311 gnus-newsgroup-ancient)
10312 (<= (length (cdr thread)) 1))
10313 (setq thread (cadr thread)))
10315 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10316 (= (length (cdr thread)) 1))
10317 (setq thread (cadr thread))))
10320 (defun gnus-cut-threads (threads)
10321 "Cut off all uninteresting articles from the beginning of threads."
10322 (when (or (eq gnus-fetch-old-headers 'some)
10323 (eq gnus-build-sparse-threads 'some)
10324 (eq gnus-build-sparse-threads 'more))
10325 (let ((th threads))
10327 (setcar th (gnus-cut-thread (car th)))
10328 (setq th (cdr th)))))
10331 (defun gnus-summary-initial-limit (&optional show-if-empty)
10332 "Figure out what the initial limit is supposed to be on group entry.
10333 This entails weeding out unwanted dormants, low-scored articles,
10334 fetch-old-headers verbiage, and so on."
10335 ;; Most groups have nothing to remove.
10336 (if (or gnus-inhibit-limiting
10337 (and (null gnus-newsgroup-dormant)
10338 (not (eq gnus-fetch-old-headers 'some))
10339 (null gnus-summary-expunge-below)
10340 (not (eq gnus-build-sparse-threads 'some))
10341 (not (eq gnus-build-sparse-threads 'more))
10342 (null gnus-thread-expunge-below)))
10344 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10345 (setq gnus-newsgroup-limit nil)
10348 (unless (car (symbol-value node))
10349 ;; These threads have no parents -- they are roots.
10350 (let ((nodes (cdr (symbol-value node)))
10353 (if (and gnus-thread-expunge-below
10354 (< (gnus-thread-total-score (car nodes))
10355 gnus-thread-expunge-below))
10356 (gnus-expunge-thread (pop nodes))
10357 (setq thread (pop nodes))
10358 (gnus-summary-limit-children thread))))))
10359 gnus-newsgroup-dependencies)
10360 ;; If this limitation resulted in an empty group, we might
10361 ;; pop the previous limit and use it instead.
10362 (when (and (not gnus-newsgroup-limit)
10364 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10365 gnus-newsgroup-limit))
10367 (defun gnus-summary-limit-children (thread)
10368 "Return 1 if this subthread is visible and 0 if it is not."
10369 ;; First we get the number of visible children to this thread. This
10370 ;; is done by recursing down the thread using this function, so this
10371 ;; will really go down to a leaf article first, before slowly
10372 ;; working its way up towards the root.
10376 (apply '+ (mapcar 'gnus-summary-limit-children
10379 (number (mail-header-number (car thread)))
10382 ;; If this article is dormant and has absolutely no visible
10383 ;; children, then this article isn't visible.
10384 (and (memq number gnus-newsgroup-dormant)
10386 ;; If this is a "fetch-old-headered" and there is only one
10387 ;; visible child (or less), then we don't want this article.
10388 (and (eq gnus-fetch-old-headers 'some)
10389 (memq number gnus-newsgroup-ancient)
10391 ;; If this is a sparsely inserted article with no children,
10392 ;; we don't want it.
10393 (and (eq gnus-build-sparse-threads 'some)
10394 (memq number gnus-newsgroup-sparse)
10396 ;; If we use expunging, and this article is really
10397 ;; low-scored, then we don't want this article.
10398 (when (and gnus-summary-expunge-below
10400 (or (cdr (assq number gnus-newsgroup-scored))
10401 gnus-summary-default-score))
10402 gnus-summary-expunge-below))
10403 ;; We increase the expunge-tally here, but that has
10404 ;; nothing to do with the limits, really.
10405 (incf gnus-newsgroup-expunged-tally)
10406 ;; We also mark as read here, if that's wanted.
10407 (when (and gnus-summary-mark-below
10408 (< score gnus-summary-mark-below))
10409 (setq gnus-newsgroup-unreads
10410 (delq number gnus-newsgroup-unreads))
10411 (if gnus-newsgroup-auto-expire
10412 (push number gnus-newsgroup-expirable)
10413 (push (cons number gnus-low-score-mark)
10414 gnus-newsgroup-reads)))
10416 ;; Nope, invisible article.
10418 ;; Ok, this article is to be visible, so we add it to the limit
10420 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10423 (defun gnus-expunge-thread (thread)
10424 "Mark all articles in THREAD as read."
10425 (let* ((number (mail-header-number (car thread))))
10426 (incf gnus-newsgroup-expunged-tally)
10427 ;; We also mark as read here, if that's wanted.
10428 (setq gnus-newsgroup-unreads
10429 (delq number gnus-newsgroup-unreads))
10430 (if gnus-newsgroup-auto-expire
10431 (push number gnus-newsgroup-expirable)
10432 (push (cons number gnus-low-score-mark)
10433 gnus-newsgroup-reads)))
10434 ;; Go recursively through all subthreads.
10435 (mapcar 'gnus-expunge-thread (cdr thread)))
10437 ;; Summary article oriented commands
10439 (defun gnus-summary-refer-parent-article (n)
10440 "Refer parent article N times.
10441 The difference between N and the number of articles fetched is returned."
10443 (gnus-set-global-variables)
10447 (let* ((header (gnus-summary-article-header))
10449 ;; If we try to find the parent of the currently
10450 ;; displayed article, then we take a look at the actual
10451 ;; References header, since this is slightly more
10452 ;; reliable than the References field we got from the
10454 (if (and (eq (mail-header-number header)
10455 (cdr gnus-article-current))
10456 (equal gnus-newsgroup-name
10457 (car gnus-article-current)))
10459 (set-buffer gnus-original-article-buffer)
10460 (nnheader-narrow-to-headers)
10462 (mail-fetch-field "references")
10464 ;; It's not the current article, so we take a bet on
10465 ;; the value we got from the server.
10466 (mail-header-references header))))
10468 (or (gnus-summary-refer-article (gnus-parent-id ref))
10469 (gnus-message 1 "Couldn't find parent"))
10470 (gnus-message 1 "No references in article %d"
10471 (gnus-summary-article-number))
10474 (gnus-summary-position-point)
10477 (defun gnus-summary-refer-references ()
10478 "Fetch all articles mentioned in the References header.
10479 Return how many articles were fetched."
10481 (gnus-set-global-variables)
10482 (let ((ref (mail-header-references (gnus-summary-article-header)))
10483 (current (gnus-summary-article-number))
10485 ;; For each Message-ID in the References header...
10486 (while (string-match "<[^>]*>" ref)
10488 ;; ... fetch that article.
10489 (gnus-summary-refer-article
10490 (prog1 (match-string 0 ref)
10491 (setq ref (substring ref (match-end 0))))))
10492 (gnus-summary-goto-subject current)
10493 (gnus-summary-position-point)
10496 (defun gnus-summary-refer-article (message-id)
10497 "Fetch an article specified by MESSAGE-ID."
10498 (interactive "sMessage-ID: ")
10499 (when (and (stringp message-id)
10500 (not (zerop (length message-id))))
10501 ;; Construct the correct Message-ID if necessary.
10502 ;; Suggested by tale@pawl.rpi.edu.
10503 (unless (string-match "^<" message-id)
10504 (setq message-id (concat "<" message-id)))
10505 (unless (string-match ">$" message-id)
10506 (setq message-id (concat message-id ">")))
10507 (let ((header (car (gnus-gethash (downcase message-id)
10508 gnus-newsgroup-dependencies))))
10510 ;; The article is present in the buffer, to we just go to it.
10511 (gnus-summary-goto-article (mail-header-number header) nil t)
10512 ;; We fetch the article
10513 (let ((gnus-override-method gnus-refer-article-method)
10515 ;; Start the special refer-article method, if necessary.
10516 (when gnus-refer-article-method
10517 (gnus-check-server gnus-refer-article-method))
10518 ;; Fetch the header, and display the article.
10519 (if (setq number (gnus-summary-insert-subject message-id))
10520 (gnus-summary-select-article nil nil nil number)
10521 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10523 (defun gnus-summary-enter-digest-group (&optional force)
10524 "Enter a digest group based on the current article."
10526 (gnus-set-global-variables)
10527 (gnus-summary-select-article)
10528 (let ((name (format "%s-%d"
10529 (gnus-group-prefixed-name
10530 gnus-newsgroup-name (list 'nndoc ""))
10531 gnus-current-article))
10532 (ogroup gnus-newsgroup-name)
10533 (buf (current-buffer)))
10535 (set-buffer gnus-original-article-buffer)
10536 (goto-char (point-min))
10537 (search-forward "\n\n" nil t)
10538 (narrow-to-region (point) (point-max)))
10540 (if (gnus-group-read-ephemeral-group
10541 name `(nndoc ,name (nndoc-address
10542 ,(get-buffer gnus-original-article-buffer))
10543 (nndoc-article-type ,(if force 'digest 'guess))) t)
10544 ;; Make all postings to this group go to the parent group.
10545 (setcdr (nthcdr 4 (gnus-get-info name))
10546 (list (list (cons 'to-group ogroup))))
10547 ;; Couldn't select this doc group.
10548 (switch-to-buffer buf)
10549 (gnus-set-global-variables)
10550 (gnus-configure-windows 'summary)
10551 (gnus-message 3 "Article couldn't be entered?"))
10553 (set-buffer gnus-original-article-buffer)
10556 (defun gnus-summary-isearch-article (&optional regexp-p)
10557 "Do incremental search forward on the current article.
10558 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10560 (gnus-set-global-variables)
10561 (gnus-summary-select-article)
10562 (gnus-configure-windows 'article)
10563 (gnus-eval-in-buffer-window
10564 gnus-article-buffer
10565 (goto-char (point-min))
10566 (isearch-forward regexp-p)))
10568 (defun gnus-summary-search-article-forward (regexp &optional backward)
10569 "Search for an article containing REGEXP forward.
10570 If BACKWARD, search backward instead."
10573 (format "Search article %s (regexp%s): "
10574 (if current-prefix-arg "backward" "forward")
10575 (if gnus-last-search-regexp
10576 (concat ", default " gnus-last-search-regexp)
10578 current-prefix-arg))
10579 (gnus-set-global-variables)
10580 (if (string-equal regexp "")
10581 (setq regexp (or gnus-last-search-regexp ""))
10582 (setq gnus-last-search-regexp regexp))
10583 (if (gnus-summary-search-article regexp backward)
10584 (gnus-article-set-window-start
10585 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10586 (error "Search failed: \"%s\"" regexp)))
10588 (defun gnus-summary-search-article-backward (regexp)
10589 "Search for an article containing REGEXP backward."
10592 (format "Search article backward (regexp%s): "
10593 (if gnus-last-search-regexp
10594 (concat ", default " gnus-last-search-regexp)
10596 (gnus-summary-search-article-forward regexp 'backward))
10598 (defun gnus-summary-search-article (regexp &optional backward)
10599 "Search for an article containing REGEXP.
10600 Optional argument BACKWARD means do search for backward.
10601 gnus-select-article-hook is not called during the search."
10602 (let ((gnus-select-article-hook nil) ;Disable hook.
10603 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10606 (function re-search-backward) (function re-search-forward)))
10609 ;; Hidden thread subtrees must be searched for ,too.
10610 (gnus-summary-show-all-threads)
10611 ;; First of all, search current article.
10612 ;; We don't want to read article again from NNTP server nor reset
10614 (gnus-summary-select-article)
10615 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10616 (setq last gnus-current-article)
10617 (gnus-eval-in-buffer-window
10618 gnus-article-buffer
10621 ;; Begin search from current point.
10622 (setq found (funcall re-search regexp nil t))))
10623 ;; Then search next articles.
10624 (while (and (not found)
10625 (gnus-summary-display-article
10626 (if backward (gnus-summary-find-prev)
10627 (gnus-summary-find-next))))
10628 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10629 (gnus-eval-in-buffer-window
10630 gnus-article-buffer
10633 (goto-char (if backward (point-max) (point-min)))
10634 (setq found (funcall re-search regexp nil t)))))
10636 ;; Adjust article pointer.
10637 (or (eq last gnus-current-article)
10638 (setq gnus-last-article last))
10639 ;; Return T if found such article.
10642 (defun gnus-summary-find-matching (header regexp &optional backward unread
10644 "Return a list of all articles that match REGEXP on HEADER.
10645 The search stars on the current article and goes forwards unless
10646 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10647 If UNREAD is non-nil, only unread articles will
10648 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10649 in the comparisons."
10650 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10651 (gnus-data-find-list
10652 (gnus-summary-article-number) (gnus-data-list backward))))
10653 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10654 (case-fold-search (not not-case-fold))
10656 (or (fboundp (intern (concat "mail-header-" header)))
10657 (error "%s is not a valid header" header))
10659 (setq d (car data))
10660 (and (or (not unread) ; We want all articles...
10661 (gnus-data-unread-p d)) ; Or just unreads.
10662 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10663 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10664 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10665 (setq data (cdr data)))
10666 (nreverse articles)))
10668 (defun gnus-summary-execute-command (header regexp command &optional backward)
10669 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10670 If HEADER is an empty string (or nil), the match is done on the entire
10671 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10673 (list (let ((completion-ignore-case t))
10676 (mapcar (lambda (string) (list string))
10677 '("Number" "Subject" "From" "Lines" "Date"
10678 "Message-ID" "Xref" "References"))
10679 nil 'require-match))
10680 (read-string "Regexp: ")
10681 (read-key-sequence "Command: ")
10682 current-prefix-arg))
10683 (gnus-set-global-variables)
10684 ;; Hidden thread subtrees must be searched as well.
10685 (gnus-summary-show-all-threads)
10686 ;; We don't want to change current point nor window configuration.
10688 (save-window-excursion
10689 (gnus-message 6 "Executing %s..." (key-description command))
10690 ;; We'd like to execute COMMAND interactively so as to give arguments.
10691 (gnus-execute header regexp
10692 `(lambda () (call-interactively ',(key-binding command)))
10694 (gnus-message 6 "Executing %s...done" (key-description command)))))
10696 (defun gnus-summary-beginning-of-article ()
10697 "Scroll the article back to the beginning."
10699 (gnus-set-global-variables)
10700 (gnus-summary-select-article)
10701 (gnus-configure-windows 'article)
10702 (gnus-eval-in-buffer-window
10703 gnus-article-buffer
10705 (goto-char (point-min))
10706 (and gnus-break-pages (gnus-narrow-to-page))))
10708 (defun gnus-summary-end-of-article ()
10709 "Scroll to the end of the article."
10711 (gnus-set-global-variables)
10712 (gnus-summary-select-article)
10713 (gnus-configure-windows 'article)
10714 (gnus-eval-in-buffer-window
10715 gnus-article-buffer
10717 (goto-char (point-max))
10719 (and gnus-break-pages (gnus-narrow-to-page))))
10721 (defun gnus-summary-show-article (&optional arg)
10722 "Force re-fetching of the current article.
10723 If ARG (the prefix) is non-nil, show the raw article without any
10724 article massaging functions being run."
10726 (gnus-set-global-variables)
10728 ;; Select the article the normal way.
10729 (gnus-summary-select-article nil 'force)
10730 ;; Bind the article treatment functions to nil.
10731 (let ((gnus-have-all-headers t)
10732 gnus-article-display-hook
10733 gnus-article-prepare-hook
10735 (gnus-summary-select-article nil 'force)))
10736 ; (gnus-configure-windows 'article)
10737 (gnus-summary-position-point))
10739 (defun gnus-summary-verbose-headers (&optional arg)
10740 "Toggle permanent full header display.
10741 If ARG is a positive number, turn header display on.
10742 If ARG is a negative number, turn header display off."
10744 (gnus-set-global-variables)
10745 (gnus-summary-toggle-header arg)
10746 (setq gnus-show-all-headers
10747 (cond ((or (not (numberp arg))
10749 (not gnus-show-all-headers))
10753 (defun gnus-summary-toggle-header (&optional arg)
10754 "Show the headers if they are hidden, or hide them if they are shown.
10755 If ARG is a positive number, show the entire header.
10756 If ARG is a negative number, hide the unwanted header lines."
10758 (gnus-set-global-variables)
10760 (set-buffer gnus-article-buffer)
10761 (let* ((buffer-read-only nil)
10762 (inhibit-point-motion-hooks t)
10763 (hidden (text-property-any
10764 (goto-char (point-min)) (search-forward "\n\n")
10767 (goto-char (point-min))
10768 (when (search-forward "\n\n" nil t)
10769 (delete-region (point-min) (1- (point))))
10770 (goto-char (point-min))
10772 (set-buffer gnus-original-article-buffer)
10773 (goto-char (point-min))
10774 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10775 (insert-buffer-substring gnus-original-article-buffer 1 e)
10776 (let ((gnus-inhibit-hiding t))
10777 (run-hooks 'gnus-article-display-hook))
10778 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10779 (gnus-article-hide-headers)))))
10781 (defun gnus-summary-show-all-headers ()
10782 "Make all header lines visible."
10784 (gnus-set-global-variables)
10785 (gnus-article-show-all-headers))
10787 (defun gnus-summary-toggle-mime (&optional arg)
10788 "Toggle MIME processing.
10789 If ARG is a positive number, turn MIME processing on."
10791 (gnus-set-global-variables)
10792 (setq gnus-show-mime
10793 (if (null arg) (not gnus-show-mime)
10794 (> (prefix-numeric-value arg) 0)))
10795 (gnus-summary-select-article t 'force))
10797 (defun gnus-summary-caesar-message (&optional arg)
10798 "Caesar rotate the current article by 13.
10799 The numerical prefix specifies how manu places to rotate each letter
10802 (gnus-set-global-variables)
10803 (gnus-summary-select-article)
10804 (let ((mail-header-separator ""))
10805 (gnus-eval-in-buffer-window
10806 gnus-article-buffer
10809 (let ((start (window-start)))
10810 (news-caesar-buffer-body arg)
10811 (set-window-start (get-buffer-window (current-buffer)) start))))))
10813 (defun gnus-summary-stop-page-breaking ()
10814 "Stop page breaking in the current article."
10816 (gnus-set-global-variables)
10817 (gnus-summary-select-article)
10818 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
10820 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
10821 "Move the current article to a different newsgroup.
10822 If N is a positive number, move the N next articles.
10823 If N is a negative number, move the N previous articles.
10824 If N is nil and any articles have been marked with the process mark,
10825 move those articles instead.
10826 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10827 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10828 re-spool using this method.
10830 For this function to work, both the current newsgroup and the
10831 newsgroup that you want to move to have to support the `request-move'
10832 and `request-accept' functions."
10834 (unless action (setq action 'move))
10835 (gnus-set-global-variables)
10836 ;; Check whether the source group supports the required functions.
10837 (cond ((and (eq action 'move)
10838 (not (gnus-check-backend-function
10839 'request-move-article gnus-newsgroup-name)))
10840 (error "The current group does not support article moving"))
10841 ((and (eq action 'crosspost)
10842 (not (gnus-check-backend-function
10843 'request-replace-article gnus-newsgroup-name)))
10844 (error "The current group does not support article editing")))
10845 (let ((articles (gnus-summary-work-articles n))
10846 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
10847 (names '((move "move" "Moving")
10848 (copy "copy" "Copying")
10849 (crosspost "crosspost" "Crossposting")))
10850 (copy-buf (save-excursion
10851 (nnheader-set-temp-buffer " *copy article*")))
10852 art-group to-method new-xref article)
10853 (unless (assq action names)
10854 (error "Unknown action %s" action))
10855 ;; Read the newsgroup name.
10856 (when (and (not to-newsgroup)
10857 (not select-method))
10859 (gnus-read-move-group-name
10860 (cadr (assq action names))
10861 gnus-current-move-group articles prefix))
10862 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
10863 (setq to-method (if select-method (list select-method "")
10864 (gnus-find-method-for-group to-newsgroup)))
10865 ;;(when (equal to-newsgroup gnus-newsgroup-name)
10866 ;;(error "Can't %s to the same group you're already in" action))
10867 ;; Check the method we are to move this article to...
10868 (or (gnus-check-backend-function 'request-accept-article (car to-method))
10869 (error "%s does not support article copying" (car to-method)))
10870 (or (gnus-check-server to-method)
10871 (error "Can't open server %s" (car to-method)))
10872 (gnus-message 6 "%s to %s: %s..."
10873 (caddr (assq action names))
10874 (or select-method to-newsgroup) articles)
10876 (setq article (pop articles))
10880 ;; Move the article.
10882 (gnus-request-move-article
10883 article ; Article to move
10884 gnus-newsgroup-name ; From newsgrouo
10885 (nth 1 (gnus-find-method-for-group
10886 gnus-newsgroup-name)) ; Server
10887 (list 'gnus-request-accept-article
10889 (list 'quote select-method)
10891 (not articles)) ; Accept form
10892 (not articles))) ; Only save nov last time
10893 ;; Copy the article.
10896 (set-buffer copy-buf)
10897 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10898 (gnus-request-accept-article
10899 (if select-method select-method to-newsgroup)
10901 ;; Crosspost the article.
10902 ((eq action 'crosspost)
10903 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
10904 (setq new-xref (concat gnus-newsgroup-name ":" article))
10905 (if (and xref (not (string= xref "")))
10907 (when (string-match "^Xref: " xref)
10908 (setq xref (substring xref (match-end 0))))
10909 (setq new-xref (concat xref " " new-xref)))
10910 (setq new-xref (concat (system-name) " " new-xref)))
10912 (set-buffer copy-buf)
10913 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10914 (nnheader-replace-header "xref" new-xref)
10915 (gnus-request-accept-article
10916 (if select-method select-method to-newsgroup)
10917 (not articles)))))))
10918 (if (not art-group)
10919 (gnus-message 1 "Couldn't %s article %s"
10920 (cadr (assq action names)) article)
10923 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
10925 (gnus-group-prefixed-name
10927 (if select-method (list select-method "")
10928 (gnus-find-method-for-group to-newsgroup)))
10929 gnus-newsrc-hashtb)))
10930 (info (nth 2 entry)))
10931 ;; Update the group that has been moved to.
10933 (memq action '(move copy)))
10934 (unless (memq article gnus-newsgroup-unreads)
10935 (gnus-info-set-read
10936 info (gnus-add-to-range (gnus-info-read info)
10937 (list (cdr art-group)))))
10939 ;; Copy any marks over to the new group.
10940 (let ((marks gnus-article-mark-lists)
10941 (to-article (cdr art-group)))
10943 ;; See whether the article is to be put in the cache.
10944 (when gnus-use-cache
10945 (gnus-cache-possibly-enter-article
10946 (gnus-info-group info) to-article
10947 (let ((header (copy-sequence
10948 (gnus-summary-article-header article))))
10949 (mail-header-set-number header to-article)
10951 (memq article gnus-newsgroup-marked)
10952 (memq article gnus-newsgroup-dormant)
10953 (memq article gnus-newsgroup-unreads)))
10956 (when (memq article (symbol-value
10957 (intern (format "gnus-newsgroup-%s"
10959 (gnus-add-marked-articles
10960 (gnus-info-group info) (caar marks)
10961 (list to-article) info))
10962 (setq marks (cdr marks)))))
10964 ;; Update the Xref header in this article to point to
10965 ;; the new crossposted article we have just created.
10966 (when (eq action 'crosspost)
10968 (set-buffer copy-buf)
10969 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10970 (nnheader-replace-header
10971 "xref" (concat new-xref " " (gnus-group-prefixed-name
10972 (car art-group) to-method)
10973 ":" (cdr art-group)))
10974 (gnus-request-replace-article
10975 article gnus-newsgroup-name (current-buffer)))))
10977 (gnus-summary-goto-subject article)
10978 (gnus-summary-mark-article article gnus-canceled-mark))
10979 (gnus-summary-remove-process-mark article))
10980 (gnus-kill-buffer copy-buf)
10981 (gnus-set-mode-line 'summary)))
10983 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10984 "Move the current article to a different newsgroup.
10985 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10986 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10987 re-spool using this method."
10989 (gnus-summary-move-article n nil nil 'copy))
10991 (defun gnus-summary-crosspost-article (&optional n)
10992 "Crosspost the current article to some other group."
10994 (gnus-summary-move-article n nil nil 'crosspost))
10996 (defun gnus-summary-respool-article (&optional n respool-method)
10997 "Respool the current article.
10998 The article will be squeezed through the mail spooling process again,
10999 which means that it will be put in some mail newsgroup or other
11000 depending on `nnmail-split-methods'.
11001 If N is a positive number, respool the N next articles.
11002 If N is a negative number, respool the N previous articles.
11003 If N is nil and any articles have been marked with the process mark,
11004 respool those articles instead.
11006 Respooling can be done both from mail groups and \"real\" newsgroups.
11007 In the former case, the articles in question will be moved from the
11008 current group into whatever groups they are destined to. In the
11009 latter case, they will be copied into the relevant groups."
11011 (gnus-set-global-variables)
11012 (let ((respool-methods (gnus-methods-using 'respool))
11014 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11016 (setq respool-method
11018 "What method do you want to use when respooling? "
11019 respool-methods nil t methname)))
11020 (or (string= respool-method "")
11021 (if (assoc (symbol-name
11022 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11024 (gnus-summary-move-article n nil (intern respool-method))
11025 (gnus-summary-copy-article n nil (intern respool-method))))))
11027 (defun gnus-summary-import-article (file)
11028 "Import a random file into a mail newsgroup."
11029 (interactive "fImport file: ")
11030 (gnus-set-global-variables)
11031 (let ((group gnus-newsgroup-name)
11032 (now (current-time))
11034 (or (gnus-check-backend-function 'request-accept-article group)
11035 (error "%s does not support article importing" group))
11036 (or (file-readable-p file)
11037 (not (file-regular-p file))
11038 (error "Can't read %s" file))
11040 (set-buffer (get-buffer-create " *import file*"))
11041 (buffer-disable-undo (current-buffer))
11043 (insert-file-contents file)
11044 (goto-char (point-min))
11045 (unless (nnheader-article-p)
11046 ;; This doesn't look like an article, so we fudge some headers.
11047 (setq atts (file-attributes file)
11048 lines (count-lines (point-min) (point-max)))
11049 (insert "From: " (read-string "From: ") "\n"
11050 "Subject: " (read-string "Subject: ") "\n"
11051 "Date: " (timezone-make-date-arpa-standard
11052 (current-time-string (nth 5 atts))
11053 (current-time-zone now)
11054 (current-time-zone now)) "\n"
11055 "Message-ID: " (gnus-inews-message-id) "\n"
11056 "Lines: " (int-to-string lines) "\n"
11057 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11058 (gnus-request-accept-article group t)
11059 (kill-buffer (current-buffer)))))
11061 (defun gnus-summary-expire-articles ()
11062 "Expire all articles that are marked as expirable in the current group."
11064 (gnus-set-global-variables)
11065 (when (gnus-check-backend-function
11066 'request-expire-articles gnus-newsgroup-name)
11067 ;; This backend supports expiry.
11068 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11069 (expirable (if total
11070 (gnus-list-of-read-articles gnus-newsgroup-name)
11071 (setq gnus-newsgroup-expirable
11072 (sort gnus-newsgroup-expirable '<))))
11073 (expiry-wait (gnus-group-get-parameter
11074 gnus-newsgroup-name 'expiry-wait))
11077 ;; There are expirable articles in this group, so we run them
11078 ;; through the expiry process.
11079 (gnus-message 6 "Expiring articles...")
11080 ;; The list of articles that weren't expired is returned.
11082 (let ((nnmail-expiry-wait-function nil)
11083 (nnmail-expiry-wait expiry-wait))
11084 (setq es (gnus-request-expire-articles
11085 expirable gnus-newsgroup-name)))
11086 (setq es (gnus-request-expire-articles
11087 expirable gnus-newsgroup-name)))
11088 (or total (setq gnus-newsgroup-expirable es))
11089 ;; We go through the old list of expirable, and mark all
11090 ;; really expired articles as nonexistent.
11091 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11092 (let ((gnus-use-cache nil))
11094 (unless (memq (car expirable) es)
11095 (when (gnus-data-find (car expirable))
11096 (gnus-summary-mark-article
11097 (car expirable) gnus-canceled-mark)))
11098 (setq expirable (cdr expirable)))))
11099 (gnus-message 6 "Expiring articles...done")))))
11101 (defun gnus-summary-expire-articles-now ()
11102 "Expunge all expirable articles in the current group.
11103 This means that *all* articles that are marked as expirable will be
11104 deleted forever, right now."
11106 (gnus-set-global-variables)
11107 (or gnus-expert-user
11109 "Are you really, really, really sure you want to expunge? ")
11111 (let ((nnmail-expiry-wait 'immediate)
11112 (nnmail-expiry-wait-function nil))
11113 (gnus-summary-expire-articles)))
11115 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11116 (defun gnus-summary-delete-article (&optional n)
11117 "Delete the N next (mail) articles.
11118 This command actually deletes articles. This is not a marking
11119 command. The article will disappear forever from your life, never to
11121 If N is negative, delete backwards.
11122 If N is nil and articles have been marked with the process mark,
11123 delete these instead."
11125 (gnus-set-global-variables)
11126 (or (gnus-check-backend-function 'request-expire-articles
11127 gnus-newsgroup-name)
11128 (error "The current newsgroup does not support article deletion."))
11129 ;; Compute the list of articles to delete.
11130 (let ((articles (gnus-summary-work-articles n))
11132 (if (and gnus-novice-user
11133 (not (gnus-y-or-n-p
11134 (format "Do you really want to delete %s forever? "
11135 (if (> (length articles) 1) "these articles"
11136 "this article")))))
11138 ;; Delete the articles.
11139 (setq not-deleted (gnus-request-expire-articles
11140 articles gnus-newsgroup-name 'force))
11142 (gnus-summary-remove-process-mark (car articles))
11143 ;; The backend might not have been able to delete the article
11145 (or (memq (car articles) not-deleted)
11146 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11147 (setq articles (cdr articles))))
11148 (gnus-summary-position-point)
11149 (gnus-set-mode-line 'summary)
11152 (defun gnus-summary-edit-article (&optional force)
11153 "Enter into a buffer and edit the current article.
11154 This will have permanent effect only in mail groups.
11155 If FORCE is non-nil, allow editing of articles even in read-only
11158 (gnus-set-global-variables)
11159 (when (and (not force)
11160 (gnus-group-read-only-p))
11161 (error "The current newsgroup does not support article editing."))
11162 (gnus-summary-select-article t nil t)
11163 (gnus-configure-windows 'article)
11164 (select-window (get-buffer-window gnus-article-buffer))
11165 (gnus-message 6 "C-c C-c to end edits")
11166 (setq buffer-read-only nil)
11168 (use-local-map (copy-keymap (current-local-map)))
11169 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11170 (buffer-enable-undo)
11172 (goto-char (point-min))
11173 (search-forward "\n\n" nil t))
11175 (defun gnus-summary-edit-article-done ()
11176 "Make edits to the current article permanent."
11178 (if (gnus-group-read-only-p)
11180 (gnus-summary-edit-article-postpone)
11182 1 "The current newsgroup does not support article editing.")
11184 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11187 (if (not (gnus-request-replace-article
11188 (cdr gnus-article-current) (car gnus-article-current)
11190 (error "Couldn't replace article.")
11191 (gnus-article-mode)
11192 (use-local-map gnus-article-mode-map)
11193 (setq buffer-read-only t)
11194 (buffer-disable-undo (current-buffer))
11195 (gnus-configure-windows 'summary)
11196 (gnus-summary-update-article (cdr gnus-article-current)))
11197 (run-hooks 'gnus-article-display-hook)
11198 (and (gnus-visual-p 'summary-highlight 'highlight)
11199 (run-hooks 'gnus-visual-mark-article-hook)))))
11201 (defun gnus-summary-edit-article-postpone ()
11202 "Postpone changes to the current article."
11204 (gnus-article-mode)
11205 (use-local-map gnus-article-mode-map)
11206 (setq buffer-read-only t)
11207 (buffer-disable-undo (current-buffer))
11208 (gnus-configure-windows 'summary)
11209 (and (gnus-visual-p 'summary-highlight 'highlight)
11210 (run-hooks 'gnus-visual-mark-article-hook)))
11212 (defun gnus-summary-respool-query ()
11213 "Query where the respool algorithm would put this article."
11215 (gnus-set-global-variables)
11216 (gnus-summary-select-article)
11218 (set-buffer gnus-article-buffer)
11220 (goto-char (point-min))
11221 (search-forward "\n\n")
11222 (narrow-to-region (point-min) (point))
11223 (pp-eval-expression
11224 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11226 ;; Summary score commands.
11228 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11230 (defun gnus-summary-raise-score (n)
11231 "Raise the score of the current article by N."
11233 (gnus-set-global-variables)
11234 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11236 (defun gnus-summary-set-score (n)
11237 "Set the score of the current article to N."
11239 (gnus-set-global-variables)
11241 (gnus-summary-show-thread)
11242 (let ((buffer-read-only nil))
11244 (gnus-summary-update-mark
11245 (if (= n (or gnus-summary-default-score 0)) ?
11246 (if (< n (or gnus-summary-default-score 0))
11247 gnus-score-below-mark gnus-score-over-mark)) 'score))
11248 (let* ((article (gnus-summary-article-number))
11249 (score (assq article gnus-newsgroup-scored)))
11250 (if score (setcdr score n)
11251 (setq gnus-newsgroup-scored
11252 (cons (cons article n) gnus-newsgroup-scored))))
11253 (gnus-summary-update-line)))
11255 (defun gnus-summary-current-score ()
11256 "Return the score of the current article."
11258 (gnus-set-global-variables)
11259 (message "%s" (gnus-summary-article-score)))
11261 ;; Summary marking commands.
11263 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11264 "Mark articles which has the same subject as read, and then select the next.
11265 If UNMARK is positive, remove any kind of mark.
11266 If UNMARK is negative, tick articles."
11268 (gnus-set-global-variables)
11270 (setq unmark (prefix-numeric-value unmark)))
11272 (gnus-summary-mark-same-subject
11273 (gnus-summary-article-subject) unmark)))
11274 ;; Select next unread article. If auto-select-same mode, should
11275 ;; select the first unread article.
11276 (gnus-summary-next-article t (and gnus-auto-select-same
11277 (gnus-summary-article-subject)))
11278 (gnus-message 7 "%d article%s marked as %s"
11279 count (if (= count 1) " is" "s are")
11280 (if unmark "unread" "read"))))
11282 (defun gnus-summary-kill-same-subject (&optional unmark)
11283 "Mark articles which has the same subject as read.
11284 If UNMARK is positive, remove any kind of mark.
11285 If UNMARK is negative, tick articles."
11287 (gnus-set-global-variables)
11289 (setq unmark (prefix-numeric-value unmark)))
11291 (gnus-summary-mark-same-subject
11292 (gnus-summary-article-subject) unmark)))
11293 ;; If marked as read, go to next unread subject.
11295 ;; Go to next unread subject.
11296 (gnus-summary-next-subject 1 t))
11297 (gnus-message 7 "%d articles are marked as %s"
11298 count (if unmark "unread" "read"))))
11300 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11301 "Mark articles with same SUBJECT as read, and return marked number.
11302 If optional argument UNMARK is positive, remove any kinds of marks.
11303 If optional argument UNMARK is negative, mark articles as unread instead."
11307 ((null unmark) ; Mark as read.
11310 (gnus-summary-mark-article-as-read gnus-killed-mark)
11311 (gnus-summary-show-thread) t)
11312 (gnus-summary-find-subject subject))
11313 (setq count (1+ count))))
11314 ((> unmark 0) ; Tick.
11317 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11318 (gnus-summary-show-thread) t)
11319 (gnus-summary-find-subject subject))
11320 (setq count (1+ count))))
11321 (t ; Mark as unread.
11324 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11325 (gnus-summary-show-thread) t)
11326 (gnus-summary-find-subject subject))
11327 (setq count (1+ count)))))
11328 (gnus-set-mode-line 'summary)
11329 ;; Return the number of marked articles.
11332 (defun gnus-summary-mark-as-processable (n &optional unmark)
11333 "Set the process mark on the next N articles.
11334 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11335 the process mark instead. The difference between N and the actual
11336 number of articles marked is returned."
11338 (gnus-set-global-variables)
11339 (let ((backward (< n 0))
11344 (gnus-summary-remove-process-mark
11345 (gnus-summary-article-number))
11346 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11347 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11349 (if (/= 0 n) (gnus-message 7 "No more articles"))
11350 (gnus-summary-recenter)
11351 (gnus-summary-position-point)
11354 (defun gnus-summary-unmark-as-processable (n)
11355 "Remove the process mark from the next N articles.
11356 If N is negative, mark backward instead. The difference between N and
11357 the actual number of articles marked is returned."
11359 (gnus-set-global-variables)
11360 (gnus-summary-mark-as-processable n t))
11362 (defun gnus-summary-unmark-all-processable ()
11363 "Remove the process mark from all articles."
11365 (gnus-set-global-variables)
11367 (while gnus-newsgroup-processable
11368 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11369 (gnus-summary-position-point))
11371 (defun gnus-summary-mark-as-expirable (n)
11372 "Mark N articles forward as expirable.
11373 If N is negative, mark backward instead. The difference between N and
11374 the actual number of articles marked is returned."
11376 (gnus-set-global-variables)
11377 (gnus-summary-mark-forward n gnus-expirable-mark))
11379 (defun gnus-summary-mark-article-as-replied (article)
11380 "Mark ARTICLE replied and update the summary line."
11381 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11382 (let ((buffer-read-only nil))
11383 (when (gnus-summary-goto-subject article)
11384 (gnus-summary-update-secondary-mark article))))
11386 (defun gnus-summary-set-bookmark (article)
11387 "Set a bookmark in current article."
11388 (interactive (list (gnus-summary-article-number)))
11389 (gnus-set-global-variables)
11390 (if (or (not (get-buffer gnus-article-buffer))
11391 (not gnus-current-article)
11392 (not gnus-article-current)
11393 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11394 (error "No current article selected"))
11395 ;; Remove old bookmark, if one exists.
11396 (let ((old (assq article gnus-newsgroup-bookmarks)))
11397 (if old (setq gnus-newsgroup-bookmarks
11398 (delq old gnus-newsgroup-bookmarks))))
11399 ;; Set the new bookmark, which is on the form
11400 ;; (article-number . line-number-in-body).
11401 (setq gnus-newsgroup-bookmarks
11405 (set-buffer gnus-article-buffer)
11409 (goto-char (point-min))
11410 (search-forward "\n\n" nil t)
11413 gnus-newsgroup-bookmarks))
11414 (gnus-message 6 "A bookmark has been added to the current article."))
11416 (defun gnus-summary-remove-bookmark (article)
11417 "Remove the bookmark from the current article."
11418 (interactive (list (gnus-summary-article-number)))
11419 (gnus-set-global-variables)
11420 ;; Remove old bookmark, if one exists.
11421 (let ((old (assq article gnus-newsgroup-bookmarks)))
11424 (setq gnus-newsgroup-bookmarks
11425 (delq old gnus-newsgroup-bookmarks))
11426 (gnus-message 6 "Removed bookmark."))
11427 (gnus-message 6 "No bookmark in current article."))))
11429 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11430 (defun gnus-summary-mark-as-dormant (n)
11431 "Mark N articles forward as dormant.
11432 If N is negative, mark backward instead. The difference between N and
11433 the actual number of articles marked is returned."
11435 (gnus-set-global-variables)
11436 (gnus-summary-mark-forward n gnus-dormant-mark))
11438 (defun gnus-summary-set-process-mark (article)
11439 "Set the process mark on ARTICLE and update the summary line."
11440 (setq gnus-newsgroup-processable
11442 (delq article gnus-newsgroup-processable)))
11443 (when (gnus-summary-goto-subject article)
11444 (gnus-summary-show-thread)
11445 (gnus-summary-update-secondary-mark article)))
11447 (defun gnus-summary-remove-process-mark (article)
11448 "Remove the process mark from ARTICLE and update the summary line."
11449 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11450 (when (gnus-summary-goto-subject article)
11451 (gnus-summary-show-thread)
11452 (gnus-summary-update-secondary-mark article)))
11454 (defun gnus-summary-set-saved-mark (article)
11455 "Set the process mark on ARTICLE and update the summary line."
11456 (push article gnus-newsgroup-saved)
11457 (when (gnus-summary-goto-subject article)
11458 (gnus-summary-update-secondary-mark article)))
11460 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11461 "Mark N articles as read forwards.
11462 If N is negative, mark backwards instead.
11463 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11465 The difference between N and the actual number of articles marked is
11468 (gnus-set-global-variables)
11469 (let ((backward (< n 0))
11470 (gnus-summary-goto-unread
11471 (and gnus-summary-goto-unread
11472 (not (eq gnus-summary-goto-unread 'never))
11473 (not (memq mark (list gnus-unread-mark
11474 gnus-ticked-mark gnus-dormant-mark)))))
11476 (mark (or mark gnus-del-mark)))
11477 (while (and (> n 0)
11478 (gnus-summary-mark-article nil mark no-expire)
11479 (zerop (gnus-summary-next-subject
11481 (and gnus-summary-goto-unread
11482 (not (eq gnus-summary-goto-unread 'never)))
11485 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11486 (gnus-summary-recenter)
11487 (gnus-summary-position-point)
11488 (gnus-set-mode-line 'summary)
11491 (defun gnus-summary-mark-article-as-read (mark)
11492 "Mark the current article quickly as read with MARK."
11493 (let ((article (gnus-summary-article-number)))
11494 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11495 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11496 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11497 (setq gnus-newsgroup-reads
11498 (cons (cons article mark) gnus-newsgroup-reads))
11499 ;; Possibly remove from cache, if that is used.
11500 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11501 ;; Allow the backend to change the mark.
11502 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11503 ;; Check for auto-expiry.
11504 (when (and gnus-newsgroup-auto-expire
11505 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11506 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11507 (= mark gnus-ancient-mark)
11508 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11509 (setq mark gnus-expirable-mark)
11510 (push article gnus-newsgroup-expirable))
11511 ;; Set the mark in the buffer.
11512 (gnus-summary-update-mark mark 'unread)
11515 (defun gnus-summary-mark-article-as-unread (mark)
11516 "Mark the current article quickly as unread with MARK."
11517 (let ((article (gnus-summary-article-number)))
11518 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11519 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11520 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11521 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11522 (cond ((= mark gnus-ticked-mark)
11523 (push article gnus-newsgroup-marked))
11524 ((= mark gnus-dormant-mark)
11525 (push article gnus-newsgroup-dormant))
11527 (push article gnus-newsgroup-unreads)))
11528 (setq gnus-newsgroup-reads
11529 (delq (assq article gnus-newsgroup-reads)
11530 gnus-newsgroup-reads))
11532 ;; See whether the article is to be put in the cache.
11533 (and gnus-use-cache
11534 (vectorp (gnus-summary-article-header article))
11536 (gnus-cache-possibly-enter-article
11537 gnus-newsgroup-name article
11538 (gnus-summary-article-header article)
11539 (= mark gnus-ticked-mark)
11540 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11543 (gnus-summary-update-mark mark 'unread)
11546 (defun gnus-summary-mark-article (&optional article mark no-expire)
11547 "Mark ARTICLE with MARK. MARK can be any character.
11548 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11549 `??' (dormant) and `?E' (expirable).
11550 If MARK is nil, then the default character `?D' is used.
11551 If ARTICLE is nil, then the article on the current line will be
11553 ;; The mark might be a string.
11554 (and (stringp mark)
11555 (setq mark (aref mark 0)))
11556 ;; If no mark is given, then we check auto-expiring.
11557 (and (not no-expire)
11558 gnus-newsgroup-auto-expire
11560 (and (numberp mark)
11561 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11562 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11563 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11564 (setq mark gnus-expirable-mark))
11565 (let* ((mark (or mark gnus-del-mark))
11566 (article (or article (gnus-summary-article-number))))
11567 (or article (error "No article on current line"))
11568 (if (or (= mark gnus-unread-mark)
11569 (= mark gnus-ticked-mark)
11570 (= mark gnus-dormant-mark))
11571 (gnus-mark-article-as-unread article mark)
11572 (gnus-mark-article-as-read article mark))
11574 ;; See whether the article is to be put in the cache.
11575 (and gnus-use-cache
11576 (not (= mark gnus-canceled-mark))
11577 (vectorp (gnus-summary-article-header article))
11579 (gnus-cache-possibly-enter-article
11580 gnus-newsgroup-name article
11581 (gnus-summary-article-header article)
11582 (= mark gnus-ticked-mark)
11583 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11585 (if (gnus-summary-goto-subject article nil t)
11586 (let ((buffer-read-only nil))
11587 (gnus-summary-show-thread)
11589 (gnus-summary-update-mark mark 'unread)
11592 (defun gnus-summary-update-secondary-mark (article)
11593 "Update the secondary (read, process, cache) mark."
11594 (gnus-summary-update-mark
11595 (cond ((memq article gnus-newsgroup-processable)
11597 ((memq article gnus-newsgroup-cached)
11599 ((memq article gnus-newsgroup-replied)
11601 ((memq article gnus-newsgroup-saved)
11603 (t gnus-unread-mark))
11605 (when (gnus-visual-p 'summary-highlight 'highlight)
11606 (run-hooks 'gnus-summary-update-hook))
11609 (defun gnus-summary-update-mark (mark type)
11610 (beginning-of-line)
11611 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11612 (buffer-read-only nil))
11614 ;; Go to the right position on the line.
11615 (forward-char forward)
11616 ;; Replace the old mark with the new mark.
11617 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11618 ;; Optionally update the marks by some user rule.
11619 (when (eq type 'unread)
11620 (gnus-data-set-mark
11621 (gnus-data-find (gnus-summary-article-number)) mark)
11622 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11624 (defun gnus-mark-article-as-read (article &optional mark)
11625 "Enter ARTICLE in the pertinent lists and remove it from others."
11626 ;; Make the article expirable.
11627 (let ((mark (or mark gnus-del-mark)))
11628 (if (= mark gnus-expirable-mark)
11629 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11630 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11631 ;; Remove from unread and marked lists.
11632 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11633 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11634 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11635 (push (cons article mark) gnus-newsgroup-reads)
11636 ;; Possibly remove from cache, if that is used.
11637 (when gnus-use-cache
11638 (gnus-cache-enter-remove-article article))))
11640 (defun gnus-mark-article-as-unread (article &optional mark)
11641 "Enter ARTICLE in the pertinent lists and remove it from others."
11642 (let ((mark (or mark gnus-ticked-mark)))
11643 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11644 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11645 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11646 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11647 (cond ((= mark gnus-ticked-mark)
11648 (push article gnus-newsgroup-marked))
11649 ((= mark gnus-dormant-mark)
11650 (push article gnus-newsgroup-dormant))
11652 (push article gnus-newsgroup-unreads)))
11653 (setq gnus-newsgroup-reads
11654 (delq (assq article gnus-newsgroup-reads)
11655 gnus-newsgroup-reads))))
11657 (defalias 'gnus-summary-mark-as-unread-forward
11658 'gnus-summary-tick-article-forward)
11659 (make-obsolete 'gnus-summary-mark-as-unread-forward
11660 'gnus-summary-tick-article-forward)
11661 (defun gnus-summary-tick-article-forward (n)
11662 "Tick N articles forwards.
11663 If N is negative, tick backwards instead.
11664 The difference between N and the number of articles ticked is returned."
11666 (gnus-summary-mark-forward n gnus-ticked-mark))
11668 (defalias 'gnus-summary-mark-as-unread-backward
11669 'gnus-summary-tick-article-backward)
11670 (make-obsolete 'gnus-summary-mark-as-unread-backward
11671 'gnus-summary-tick-article-backward)
11672 (defun gnus-summary-tick-article-backward (n)
11673 "Tick N articles backwards.
11674 The difference between N and the number of articles ticked is returned."
11676 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11678 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11679 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11680 (defun gnus-summary-tick-article (&optional article clear-mark)
11681 "Mark current article as unread.
11682 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11683 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11684 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11685 gnus-ticked-mark)))
11687 (defun gnus-summary-mark-as-read-forward (n)
11688 "Mark N articles as read forwards.
11689 If N is negative, mark backwards instead.
11690 The difference between N and the actual number of articles marked is
11693 (gnus-summary-mark-forward n gnus-del-mark t))
11695 (defun gnus-summary-mark-as-read-backward (n)
11696 "Mark the N articles as read backwards.
11697 The difference between N and the actual number of articles marked is
11700 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11702 (defun gnus-summary-mark-as-read (&optional article mark)
11703 "Mark current article as read.
11704 ARTICLE specifies the article to be marked as read.
11705 MARK specifies a string to be inserted at the beginning of the line."
11706 (gnus-summary-mark-article article mark))
11708 (defun gnus-summary-clear-mark-forward (n)
11709 "Clear marks from N articles forward.
11710 If N is negative, clear backward instead.
11711 The difference between N and the number of marks cleared is returned."
11713 (gnus-summary-mark-forward n gnus-unread-mark))
11715 (defun gnus-summary-clear-mark-backward (n)
11716 "Clear marks from N articles backward.
11717 The difference between N and the number of marks cleared is returned."
11719 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11721 (defun gnus-summary-mark-unread-as-read ()
11722 "Intended to be used by `gnus-summary-mark-article-hook'."
11723 (when (memq gnus-current-article gnus-newsgroup-unreads)
11724 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11726 (defun gnus-summary-mark-region-as-read (point mark all)
11727 "Mark all unread articles between point and mark as read.
11728 If given a prefix, mark all articles between point and mark as read,
11729 even ticked and dormant ones."
11730 (interactive "r\nP")
11734 (beginning-of-line)
11739 (memq (setq article (gnus-summary-article-number))
11740 gnus-newsgroup-unreads))
11741 (gnus-summary-mark-article article gnus-del-mark))
11743 (gnus-summary-find-next))))))
11745 (defun gnus-summary-mark-below (score mark)
11746 "Mark articles with score less than SCORE with MARK."
11747 (interactive "P\ncMark: ")
11748 (gnus-set-global-variables)
11749 (setq score (if score
11750 (prefix-numeric-value score)
11751 (or gnus-summary-default-score 0)))
11753 (set-buffer gnus-summary-buffer)
11754 (goto-char (point-min))
11757 (and (< (gnus-summary-article-score) score)
11758 (gnus-summary-mark-article nil mark))
11759 (gnus-summary-find-next)))))
11761 (defun gnus-summary-kill-below (&optional score)
11762 "Mark articles with score below SCORE as read."
11764 (gnus-set-global-variables)
11765 (gnus-summary-mark-below score gnus-killed-mark))
11767 (defun gnus-summary-clear-above (&optional score)
11768 "Clear all marks from articles with score above SCORE."
11770 (gnus-set-global-variables)
11771 (gnus-summary-mark-above score gnus-unread-mark))
11773 (defun gnus-summary-tick-above (&optional score)
11774 "Tick all articles with score above SCORE."
11776 (gnus-set-global-variables)
11777 (gnus-summary-mark-above score gnus-ticked-mark))
11779 (defun gnus-summary-mark-above (score mark)
11780 "Mark articles with score over SCORE with MARK."
11781 (interactive "P\ncMark: ")
11782 (gnus-set-global-variables)
11783 (setq score (if score
11784 (prefix-numeric-value score)
11785 (or gnus-summary-default-score 0)))
11787 (set-buffer gnus-summary-buffer)
11788 (goto-char (point-min))
11790 (if (> (gnus-summary-article-score) score)
11791 (gnus-summary-mark-article nil mark))
11793 (gnus-summary-find-next)))))
11795 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11796 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11797 (defun gnus-summary-limit-include-expunged ()
11798 "Display all the hidden articles that were expunged for low scores."
11800 (gnus-set-global-variables)
11801 (let ((buffer-read-only nil))
11802 (let ((scored gnus-newsgroup-scored)
11805 (or (gnus-summary-goto-subject (car (car scored)))
11806 (and (setq h (gnus-summary-article-header (car (car scored))))
11807 (< (cdr (car scored)) gnus-summary-expunge-below)
11808 (setq headers (cons h headers))))
11809 (setq scored (cdr scored)))
11810 (or headers (error "No expunged articles hidden."))
11811 (goto-char (point-min))
11812 (gnus-summary-prepare-unthreaded (nreverse headers)))
11813 (goto-char (point-min))
11814 (gnus-summary-position-point)))
11816 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
11817 "Mark all articles not marked as unread in this newsgroup as read.
11818 If prefix argument ALL is non-nil, all articles are marked as read.
11819 If QUIETLY is non-nil, no questions will be asked.
11820 If TO-HERE is non-nil, it should be a point in the buffer. All
11821 articles before this point will be marked as read.
11822 The number of articles marked as read is returned."
11824 (gnus-set-global-variables)
11827 (not gnus-interactive-catchup) ;Without confirmation?
11831 "Mark absolutely all articles as read? "
11832 "Mark all unread articles as read? ")))
11834 (not gnus-newsgroup-adaptive)
11835 (not gnus-newsgroup-auto-expire))
11838 (setq gnus-newsgroup-marked nil
11839 gnus-newsgroup-dormant nil))
11840 (setq gnus-newsgroup-unreads nil))
11841 ;; We actually mark all articles as canceled, which we
11842 ;; have to do when using auto-expiry or adaptive scoring.
11843 (gnus-summary-show-all-threads)
11844 (if (gnus-summary-first-subject (not all))
11846 (if to-here (< (point) to-here) t)
11847 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11848 (gnus-summary-find-next (not all)))))
11850 (setq gnus-newsgroup-unreads nil))
11851 (gnus-set-mode-line 'summary)))
11852 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11853 (if (and (not to-here) (eq 'nnvirtual (car method)))
11854 (nnvirtual-catchup-group
11855 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
11856 (gnus-summary-position-point)))
11858 (defun gnus-summary-catchup-to-here (&optional all)
11859 "Mark all unticked articles before the current one as read.
11860 If ALL is non-nil, also mark ticked and dormant articles as read."
11862 (gnus-set-global-variables)
11864 (let ((beg (point)))
11865 ;; We check that there are unread articles.
11866 (when (or all (gnus-summary-find-prev))
11867 (gnus-summary-catchup all t beg))))
11868 (gnus-summary-position-point))
11870 (defun gnus-summary-catchup-all (&optional quietly)
11871 "Mark all articles in this newsgroup as read."
11873 (gnus-set-global-variables)
11874 (gnus-summary-catchup t quietly))
11876 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11877 "Mark all articles not marked as unread in this newsgroup as read, then exit.
11878 If prefix argument ALL is non-nil, all articles are marked as read."
11880 (gnus-set-global-variables)
11881 (gnus-summary-catchup all quietly nil 'fast)
11882 ;; Select next newsgroup or exit.
11883 (if (eq gnus-auto-select-next 'quietly)
11884 (gnus-summary-next-group nil)
11885 (gnus-summary-exit)))
11887 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11888 "Mark all articles in this newsgroup as read, and then exit."
11890 (gnus-set-global-variables)
11891 (gnus-summary-catchup-and-exit t quietly))
11893 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
11894 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11895 "Mark all articles in this group as read and select the next group.
11896 If given a prefix, mark all articles, unread as well as ticked, as
11899 (gnus-set-global-variables)
11901 (gnus-summary-catchup all))
11902 (gnus-summary-next-article t))
11904 ;; Thread-based commands.
11906 (defun gnus-summary-articles-in-thread (&optional article)
11907 "Return a list of all articles in the current thread.
11908 If ARTICLE is non-nil, return all articles in the thread that starts
11909 with that article."
11910 (let* ((article (or article (gnus-summary-article-number)))
11911 (data (gnus-data-find-list article))
11912 (top-level (gnus-data-level (car data)))
11914 (cond ((null gnus-thread-operation-ignore-subject)
11915 (gnus-simplify-subject-re
11916 (mail-header-subject (gnus-data-header (car data)))))
11917 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11918 (gnus-simplify-subject-fuzzy
11919 (mail-header-subject (gnus-data-header (car data)))))
11923 () ; This article doesn't exist.
11925 (and (or (not top-subject)
11926 (string= top-subject
11927 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11928 (gnus-simplify-subject-fuzzy
11929 (mail-header-subject
11930 (gnus-data-header (car data))))
11931 (gnus-simplify-subject-re
11932 (mail-header-subject
11933 (gnus-data-header (car data)))))))
11934 (setq articles (cons (gnus-data-number (car data)) articles)))
11935 (if (and (setq data (cdr data))
11936 (> (gnus-data-level (car data)) top-level))
11939 ;; Return the list of articles.
11940 (nreverse articles))))
11942 (defun gnus-summary-rethread-current ()
11943 "Rethread the thread the current article is part of."
11945 (gnus-set-global-variables)
11946 (let* ((gnus-show-threads t)
11947 (article (gnus-summary-article-number))
11948 (id (mail-header-id (gnus-summary-article-header)))
11949 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11951 (error "No article on the current line"))
11952 (gnus-rebuild-thread id)
11953 (gnus-summary-goto-subject article)))
11955 (defun gnus-summary-reparent-thread ()
11956 "Make current article child of the marked (or previous) article.
11958 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11959 is non-nil or the Subject: of both articles are the same."
11961 (or (not (gnus-group-read-only-p))
11962 (error "The current newsgroup does not support article editing."))
11963 (or (<= (length gnus-newsgroup-processable) 1)
11964 (error "No more than one article may be marked."))
11965 (save-window-excursion
11966 (let ((gnus-article-buffer " *reparent*")
11967 (current-article (gnus-summary-article-number))
11968 ; first grab the marked article, otherwise one line up.
11969 (parent-article (if (not (null gnus-newsgroup-processable))
11970 (car gnus-newsgroup-processable)
11972 (if (eq (forward-line -1) 0)
11973 (gnus-summary-article-number)
11974 (error "Beginning of summary buffer."))))))
11975 (or (not (eq current-article parent-article))
11976 (error "An article may not be self-referential."))
11977 (let ((message-id (mail-header-id
11978 (gnus-summary-article-header parent-article))))
11979 (or (and message-id (not (equal message-id "")))
11980 (error "No message-id in desired parent."))
11981 (gnus-summary-select-article t t nil current-article)
11982 (set-buffer gnus-article-buffer)
11983 (setq buffer-read-only nil)
11984 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11987 (goto-char (point-min))
11988 (if (search-forward-regexp "^References: " nil t)
11989 (insert message-id " " )
11990 (insert "References: " message-id "\n"))
11991 (or (gnus-request-replace-article current-article
11992 (car gnus-article-current)
11993 gnus-article-buffer)
11994 (error "Couldn't replace article."))
11995 (set-buffer gnus-summary-buffer)
11996 (gnus-summary-unmark-all-processable)
11997 (gnus-summary-rethread-current)
11998 (message "Article %d is now the child of article %d."
11999 current-article parent-article)))))
12001 (defun gnus-summary-toggle-threads (&optional arg)
12002 "Toggle showing conversation threads.
12003 If ARG is positive number, turn showing conversation threads on."
12005 (gnus-set-global-variables)
12006 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12007 (setq gnus-show-threads
12008 (if (null arg) (not gnus-show-threads)
12009 (> (prefix-numeric-value arg) 0)))
12010 (gnus-summary-prepare)
12011 (gnus-summary-goto-subject current)
12012 (gnus-summary-position-point)))
12014 (defun gnus-summary-show-all-threads ()
12015 "Show all threads."
12017 (gnus-set-global-variables)
12019 (let ((buffer-read-only nil))
12020 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12021 (gnus-summary-position-point))
12023 (defun gnus-summary-show-thread ()
12024 "Show thread subtrees.
12025 Returns nil if no thread was there to be shown."
12027 (gnus-set-global-variables)
12028 (let ((buffer-read-only nil)
12030 ;; first goto end then to beg, to have point at beg after let
12031 (end (progn (end-of-line) (point)))
12032 (beg (progn (beginning-of-line) (point))))
12034 ;; Any hidden lines here?
12035 (search-forward "\r" end t)
12036 (subst-char-in-region beg end ?\^M ?\n t)
12038 (gnus-summary-position-point))))
12040 (defun gnus-summary-hide-all-threads ()
12041 "Hide all thread subtrees."
12043 (gnus-set-global-variables)
12045 (goto-char (point-min))
12046 (gnus-summary-hide-thread)
12047 (while (zerop (gnus-summary-next-thread 1 t))
12048 (gnus-summary-hide-thread)))
12049 (gnus-summary-position-point))
12051 (defun gnus-summary-hide-thread ()
12052 "Hide thread subtrees.
12053 Returns nil if no threads were there to be hidden."
12055 (gnus-set-global-variables)
12056 (let ((buffer-read-only nil)
12058 (article (gnus-summary-article-number))
12060 ;; Go forward until either the buffer ends or the subthread
12062 (when (and (not (eobp))
12063 (or (and (zerop (gnus-summary-next-thread 1 t))
12064 (gnus-summary-find-prev))
12065 (goto-char (gnus-data-pos (car (gnus-data-list 'rev))))))
12068 (if (and (> (point) start)
12069 (search-backward "\n" start t))
12071 (subst-char-in-region start end ?\n ?\^M)
12072 (gnus-summary-goto-subject article))
12075 (gnus-summary-position-point)))))
12077 (defun gnus-summary-go-to-next-thread (&optional previous)
12078 "Go to the same level (or less) next thread.
12079 If PREVIOUS is non-nil, go to previous thread instead.
12080 Return the article number moved to, or nil if moving was impossible."
12081 (let* ((level (gnus-summary-thread-level))
12082 (article (gnus-summary-article-number))
12083 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12086 (if (<= (gnus-data-level (car data)) level)
12087 (setq oart (gnus-data-number (car data))
12089 (setq data (cdr data))))
12091 (gnus-summary-goto-subject oart))))
12093 (defun gnus-summary-next-thread (n &optional silent)
12094 "Go to the same level next N'th thread.
12095 If N is negative, search backward instead.
12096 Returns the difference between N and the number of skips actually
12099 If SILENT, don't output messages."
12101 (gnus-set-global-variables)
12102 (let ((backward (< n 0))
12105 (while (and (> n 0)
12106 (setq old (save-excursion (forward-line 1) (point)))
12107 (gnus-summary-go-to-next-thread backward))
12108 (when (and (eq gnus-summary-make-false-root 'dummy)
12109 (setq dum (text-property-not-all
12110 old (point) 'gnus-intangible nil)))
12113 (gnus-summary-position-point)
12114 (when (and (not silent) (/= 0 n))
12115 (gnus-message 7 "No more threads"))
12118 (defun gnus-summary-prev-thread (n)
12119 "Go to the same level previous N'th thread.
12120 Returns the difference between N and the number of skips actually
12123 (gnus-set-global-variables)
12124 (gnus-summary-next-thread (- n)))
12126 (defun gnus-summary-go-down-thread ()
12127 "Go down one level in the current thread."
12128 (let ((children (gnus-summary-article-children)))
12130 (gnus-summary-goto-subject (car children)))))
12132 (defun gnus-summary-go-up-thread ()
12133 "Go up one level in the current thread."
12134 (let ((parent (gnus-summary-article-parent)))
12136 (gnus-summary-goto-subject parent))))
12138 (defun gnus-summary-down-thread (n)
12139 "Go down thread N steps.
12140 If N is negative, go up instead.
12141 Returns the difference between N and how many steps down that were
12144 (gnus-set-global-variables)
12147 (while (and (> n 0)
12148 (if up (gnus-summary-go-up-thread)
12149 (gnus-summary-go-down-thread)))
12151 (gnus-summary-position-point)
12152 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12155 (defun gnus-summary-up-thread (n)
12156 "Go up thread N steps.
12157 If N is negative, go up instead.
12158 Returns the difference between N and how many steps down that were
12161 (gnus-set-global-variables)
12162 (gnus-summary-down-thread (- n)))
12164 (defun gnus-summary-top-thread ()
12165 "Go to the top of the thread."
12167 (gnus-set-global-variables)
12168 (while (gnus-summary-go-up-thread))
12169 (gnus-summary-article-number))
12171 (defun gnus-summary-kill-thread (&optional unmark)
12172 "Mark articles under current thread as read.
12173 If the prefix argument is positive, remove any kinds of marks.
12174 If the prefix argument is negative, tick articles instead."
12176 (gnus-set-global-variables)
12178 (setq unmark (prefix-numeric-value unmark)))
12179 (let ((articles (gnus-summary-articles-in-thread)))
12181 ;; Expand the thread.
12182 (gnus-summary-show-thread)
12183 ;; Mark all the articles.
12185 (gnus-summary-goto-subject (car articles))
12186 (cond ((null unmark)
12187 (gnus-summary-mark-article-as-read gnus-killed-mark))
12189 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12191 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12192 (setq articles (cdr articles))))
12193 ;; Hide killed subtrees.
12195 gnus-thread-hide-killed
12196 (gnus-summary-hide-thread))
12197 ;; If marked as read, go to next unread subject.
12199 ;; Go to next unread subject.
12200 (gnus-summary-next-subject 1 t)))
12201 (gnus-set-mode-line 'summary))
12203 ;; Summary sorting commands
12205 (defun gnus-summary-sort-by-number (&optional reverse)
12206 "Sort summary buffer by article number.
12207 Argument REVERSE means reverse order."
12209 (gnus-summary-sort 'number reverse))
12211 (defun gnus-summary-sort-by-author (&optional reverse)
12212 "Sort summary buffer by author name alphabetically.
12213 If case-fold-search is non-nil, case of letters is ignored.
12214 Argument REVERSE means reverse order."
12216 (gnus-summary-sort 'author reverse))
12218 (defun gnus-summary-sort-by-subject (&optional reverse)
12219 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12220 If case-fold-search is non-nil, case of letters is ignored.
12221 Argument REVERSE means reverse order."
12223 (gnus-summary-sort 'subject reverse))
12225 (defun gnus-summary-sort-by-date (&optional reverse)
12226 "Sort summary buffer by date.
12227 Argument REVERSE means reverse order."
12229 (gnus-summary-sort 'date reverse))
12231 (defun gnus-summary-sort-by-score (&optional reverse)
12232 "Sort summary buffer by score.
12233 Argument REVERSE means reverse order."
12235 (gnus-summary-sort 'score reverse))
12237 (defun gnus-summary-sort (predicate reverse)
12238 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12239 (gnus-set-global-variables)
12240 (let* ((gnus-thread-sort-functions
12241 (list (intern (format "gnus-thread-sort-by-%s" predicate))))
12242 (gnus-article-sort-functions
12243 (list (intern (format "gnus-article-sort-by-%s" predicate))))
12245 (gnus-summary-prepare-hook nil))
12246 ;; We do the sorting by regenerating the threads.
12247 (gnus-summary-prepare)
12248 ;; Hide subthreads if needed.
12249 (when (and gnus-show-threads gnus-thread-hide-subtree)
12250 (gnus-summary-hide-all-threads)))
12251 ;; If in async mode, we send some info to the backend.
12252 (when gnus-newsgroup-async
12253 (gnus-request-asynchronous
12254 gnus-newsgroup-name gnus-newsgroup-data)))
12256 (defun gnus-sortable-date (date)
12257 "Make sortable string by string-lessp from DATE.
12258 Timezone package is used."
12259 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12260 (year (aref date 0))
12261 (month (aref date 1))
12262 (day (aref date 2)))
12263 (timezone-make-sortable-date
12265 (timezone-make-time-string
12266 (aref date 3) (aref date 4) (aref date 5)))))
12269 ;; Summary saving commands.
12271 (defun gnus-summary-save-article (&optional n not-saved)
12272 "Save the current article using the default saver function.
12273 If N is a positive number, save the N next articles.
12274 If N is a negative number, save the N previous articles.
12275 If N is nil and any articles have been marked with the process mark,
12276 save those articles instead.
12277 The variable `gnus-default-article-saver' specifies the saver function."
12279 (gnus-set-global-variables)
12280 (let ((articles (gnus-summary-work-articles n))
12281 file header article)
12283 (setq header (gnus-summary-article-header
12284 (setq article (pop articles))))
12285 (if (not (vectorp header))
12286 ;; This is a pseudo-article.
12287 (if (assq 'name header)
12288 (gnus-copy-file (cdr (assq 'name header)))
12289 (gnus-message 1 "Article %d is unsaveable" article))
12290 ;; This is a real article.
12291 (save-window-excursion
12292 (gnus-summary-select-article t nil nil article))
12293 (unless gnus-save-all-headers
12294 ;; Remove headers accoring to `gnus-saved-headers'.
12295 (let ((gnus-visible-headers
12296 (or gnus-saved-headers gnus-visible-headers)))
12297 (gnus-article-hide-headers nil t)))
12298 ;; Remove any X-Gnus lines.
12300 (set-buffer gnus-article-buffer)
12302 (let ((buffer-read-only nil))
12303 (nnheader-narrow-to-headers)
12304 (while (re-search-forward "^X-Gnus" nil t)
12305 (gnus-delete-line)))))
12306 (save-window-excursion
12307 (if (not gnus-default-article-saver)
12308 (error "No default saver is defined.")
12309 (setq file (funcall
12310 gnus-default-article-saver
12312 ((not gnus-prompt-before-saving)
12314 ((eq gnus-prompt-before-saving 'always)
12317 (gnus-summary-remove-process-mark article)
12319 (gnus-summary-set-saved-mark article))))
12320 (gnus-summary-position-point)
12323 (defun gnus-summary-pipe-output (&optional arg)
12324 "Pipe the current article to a subprocess.
12325 If N is a positive number, pipe the N next articles.
12326 If N is a negative number, pipe the N previous articles.
12327 If N is nil and any articles have been marked with the process mark,
12328 pipe those articles instead."
12330 (gnus-set-global-variables)
12331 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12332 (gnus-summary-save-article arg t))
12333 (gnus-configure-windows 'pipe))
12335 (defun gnus-summary-save-article-mail (&optional arg)
12336 "Append the current article to an mail file.
12337 If N is a positive number, save the N next articles.
12338 If N is a negative number, save the N previous articles.
12339 If N is nil and any articles have been marked with the process mark,
12340 save those articles instead."
12342 (gnus-set-global-variables)
12343 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12344 (gnus-summary-save-article arg)))
12346 (defun gnus-summary-save-article-rmail (&optional arg)
12347 "Append the current article to an rmail file.
12348 If N is a positive number, save the N next articles.
12349 If N is a negative number, save the N previous articles.
12350 If N is nil and any articles have been marked with the process mark,
12351 save those articles instead."
12353 (gnus-set-global-variables)
12354 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12355 (gnus-summary-save-article arg)))
12357 (defun gnus-summary-save-article-file (&optional arg)
12358 "Append the current article to a file.
12359 If N is a positive number, save the N next articles.
12360 If N is a negative number, save the N previous articles.
12361 If N is nil and any articles have been marked with the process mark,
12362 save those articles instead."
12364 (gnus-set-global-variables)
12365 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12366 (gnus-summary-save-article arg)))
12368 (defun gnus-summary-save-article-body-file (&optional arg)
12369 "Append the current article body to a file.
12370 If N is a positive number, save the N next articles.
12371 If N is a negative number, save the N previous articles.
12372 If N is nil and any articles have been marked with the process mark,
12373 save those articles instead."
12375 (gnus-set-global-variables)
12376 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12377 (gnus-summary-save-article arg)))
12379 (defun gnus-get-split-value (methods)
12380 "Return a value based on the split METHODS."
12381 (let (split-name method result match)
12384 (set-buffer gnus-original-article-buffer)
12386 (nnheader-narrow-to-headers)
12388 (goto-char (point-min))
12389 (setq method (pop methods))
12390 (setq match (pop method))
12393 ;; Regular expression.
12395 (re-search-forward match nil t)
12397 ((gnus-functionp match)
12401 (setq result (funcall match gnus-newsgroup-name))))
12406 (setq result (eval match)))))
12407 (setq split-name (append (cdr methods) split-name))
12408 (cond ((stringp result)
12409 (push result split-name))
12411 (setq split-name (append result split-name)))))))))
12414 (defun gnus-read-move-group-name (prompt default articles prefix)
12415 "Read a group name."
12416 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12418 (format "Where do you want to %s %s? "
12420 (if (> (length articles) 1)
12421 (format "these %d articles" (length articles))
12429 (format "(default %s) " default)
12431 gnus-active-hashtb nil nil prefix))
12432 ((= 1 (length split-name))
12433 (completing-read prom gnus-active-hashtb
12434 nil nil (cons (car split-name) 0)))
12437 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12440 (if (or (string= to-newsgroup "")
12441 (string= to-newsgroup prefix))
12442 (setq to-newsgroup (or default "")))
12443 (or (gnus-active to-newsgroup)
12444 (gnus-activate-group to-newsgroup)
12445 (error "No such group: %s" to-newsgroup)))
12448 (defun gnus-read-save-file-name (prompt default-name)
12449 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12451 ;; Let the split methods have their say.
12453 ;; No split name was found.
12456 (concat prompt " (default "
12457 (file-name-nondirectory default-name) ") ")
12458 (file-name-directory default-name)
12460 ;; A single split name was found
12461 ((= 1 (length split-name))
12463 (concat prompt " (default " (car split-name) ") ")
12464 gnus-article-save-directory
12465 (concat gnus-article-save-directory (car split-name))))
12466 ;; A list of splits was found.
12468 (setq split-name (mapcar (lambda (el) (list el))
12469 (nreverse split-name)))
12470 (let ((result (completing-read
12471 (concat prompt " ") split-name nil nil)))
12472 (concat gnus-article-save-directory
12473 (if (string= result "")
12474 (car (car split-name))
12476 ;; If we have read a directory, we append the default file name.
12477 (when (file-directory-p file)
12478 (setq file (concat (file-name-as-directory file)
12479 (file-name-nondirectory default-name))))
12480 ;; Possibly translate some charaters.
12481 (nnheader-translate-file-chars file)))
12483 (defun gnus-article-archive-name (group)
12484 "Return the first instance of an \"Archive-name\" in the current buffer."
12485 (let ((case-fold-search t))
12486 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12487 (match-string 1))))
12489 (defun gnus-summary-save-in-rmail (&optional filename)
12490 "Append this article to Rmail file.
12491 Optional argument FILENAME specifies file name.
12492 Directory to save to is default to `gnus-article-save-directory' which
12493 is initialized from the SAVEDIR environment variable."
12495 (gnus-set-global-variables)
12496 (let ((default-name
12497 (funcall gnus-rmail-save-name gnus-newsgroup-name
12498 gnus-current-headers gnus-newsgroup-last-rmail)))
12500 (cond ((eq filename 'default)
12502 (filename filename)
12503 (t (gnus-read-save-file-name
12504 "Save in rmail file:" default-name))))
12505 (gnus-make-directory (file-name-directory filename))
12506 (gnus-eval-in-buffer-window
12507 gnus-original-article-buffer
12511 (gnus-output-to-rmail filename))))
12512 ;; Remember the directory name to save articles
12513 (setq gnus-newsgroup-last-rmail filename)))
12515 (defun gnus-summary-save-in-mail (&optional filename)
12516 "Append this article to Unix mail file.
12517 Optional argument FILENAME specifies file name.
12518 Directory to save to is default to `gnus-article-save-directory' which
12519 is initialized from the SAVEDIR environment variable."
12521 (gnus-set-global-variables)
12522 (let ((default-name
12523 (funcall gnus-mail-save-name gnus-newsgroup-name
12524 gnus-current-headers gnus-newsgroup-last-mail)))
12526 (cond ((eq filename 'default)
12528 (filename filename)
12529 (t (gnus-read-save-file-name
12530 "Save in Unix mail file:" default-name))))
12532 (expand-file-name filename
12534 (file-name-directory default-name))))
12535 (gnus-make-directory (file-name-directory filename))
12536 (gnus-eval-in-buffer-window
12537 gnus-original-article-buffer
12541 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12542 (gnus-output-to-rmail filename)
12543 (let ((mail-use-rfc822 t))
12544 (rmail-output filename 1 t t))))))
12545 ;; Remember the directory name to save articles.
12546 (setq gnus-newsgroup-last-mail filename)))
12548 (defun gnus-summary-save-in-file (&optional filename)
12549 "Append this article to file.
12550 Optional argument FILENAME specifies file name.
12551 Directory to save to is default to `gnus-article-save-directory' which
12552 is initialized from the SAVEDIR environment variable."
12554 (gnus-set-global-variables)
12555 (let ((default-name
12556 (funcall gnus-file-save-name gnus-newsgroup-name
12557 gnus-current-headers gnus-newsgroup-last-file)))
12559 (cond ((eq filename 'default)
12561 (filename filename)
12562 (t (gnus-read-save-file-name
12563 "Save in file:" default-name))))
12564 (gnus-make-directory (file-name-directory filename))
12565 (gnus-eval-in-buffer-window
12566 gnus-article-buffer
12570 (gnus-output-to-file filename))))
12571 ;; Remember the directory name to save articles.
12572 (setq gnus-newsgroup-last-file filename)))
12574 (defun gnus-summary-save-body-in-file (&optional filename)
12575 "Append this article body to a file.
12576 Optional argument FILENAME specifies file name.
12577 The directory to save in defaults to `gnus-article-save-directory' which
12578 is initialized from the SAVEDIR environment variable."
12580 (gnus-set-global-variables)
12581 (let ((default-name
12582 (funcall gnus-file-save-name gnus-newsgroup-name
12583 gnus-current-headers gnus-newsgroup-last-file)))
12585 (cond ((eq filename 'default)
12587 (filename filename)
12588 (t (gnus-read-save-file-name
12589 "Save body in file:" default-name))))
12590 (gnus-make-directory (file-name-directory filename))
12591 (gnus-eval-in-buffer-window
12592 gnus-article-buffer
12596 (goto-char (point-min))
12597 (and (search-forward "\n\n" nil t)
12598 (narrow-to-region (point) (point-max)))
12599 (gnus-output-to-file filename))))
12600 ;; Remember the directory name to save articles.
12601 (setq gnus-newsgroup-last-file filename)))
12603 (defun gnus-summary-save-in-pipe (&optional command)
12604 "Pipe this article to subprocess."
12606 (gnus-set-global-variables)
12608 (cond ((eq command 'default)
12609 gnus-last-shell-command)
12611 (t (read-string "Shell command on article: "
12612 gnus-last-shell-command))))
12613 (if (string-equal command "")
12614 (setq command gnus-last-shell-command))
12615 (gnus-eval-in-buffer-window
12616 gnus-article-buffer
12619 (shell-command-on-region (point-min) (point-max) command nil)))
12620 (setq gnus-last-shell-command command))
12622 ;; Summary extract commands
12624 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12625 (let ((buffer-read-only nil)
12626 (article (gnus-summary-article-number))
12628 (or (gnus-summary-goto-subject article)
12629 (error (format "No such article: %d" article)))
12630 (gnus-summary-position-point)
12631 ;; If all commands are to be bunched up on one line, we collect
12633 (if gnus-view-pseudos-separately
12635 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12638 (setq action (cdr (assq 'action (car ps))))
12639 (setq files (list (cdr (assq 'name (car ps)))))
12640 (while (and ps (cdr ps)
12641 (string= (or action "1")
12642 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12643 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12644 (setcdr ps (cdr (cdr ps))))
12647 (if (not (string-match "%s" action))
12648 (setq files (cons " " files)))
12649 (setq files (cons " " files))
12650 (and (assq 'execute (car ps))
12651 (setcdr (assq 'execute (car ps))
12652 (funcall (if (string-match "%s" action)
12655 (mapconcat (lambda (f) f) files " ")))))
12656 (setq ps (cdr ps)))))
12657 (if (and gnus-view-pseudos (not not-view))
12659 (and (assq 'execute (car pslist))
12660 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12661 (eq gnus-view-pseudos 'not-confirm)))
12662 (setq pslist (cdr pslist)))
12665 (setq after-article (or (cdr (assq 'article (car pslist)))
12666 (gnus-summary-article-number)))
12667 (gnus-summary-goto-subject after-article)
12670 (insert " " (file-name-nondirectory
12671 (cdr (assq 'name (car pslist))))
12672 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12674 (forward-line -1) ; back to `b'
12675 (add-text-properties
12676 b e (list 'gnus-number gnus-reffed-article-number
12677 gnus-mouse-face-prop gnus-mouse-face))
12679 after-article gnus-reffed-article-number
12680 gnus-unread-mark b (car pslist) 0 (- e b))
12681 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12682 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12683 (setq pslist (cdr pslist)))))))
12685 (defun gnus-pseudos< (p1 p2)
12686 (let ((c1 (cdr (assq 'action p1)))
12687 (c2 (cdr (assq 'action p2))))
12688 (and c1 c2 (string< c1 c2))))
12690 (defun gnus-request-pseudo-article (props)
12691 (cond ((assq 'execute props)
12692 (gnus-execute-command (cdr (assq 'execute props)))))
12693 (let ((gnus-current-article (gnus-summary-article-number)))
12694 (run-hooks 'gnus-mark-article-hook)))
12696 (defun gnus-execute-command (command &optional automatic)
12698 (gnus-article-setup-buffer)
12699 (set-buffer gnus-article-buffer)
12700 (let ((command (if automatic command (read-string "Command: " command)))
12701 (buffer-read-only nil))
12703 (insert "$ " command "\n\n")
12704 (if gnus-view-pseudo-asynchronously
12705 (start-process "gnus-execute" nil "sh" "-c" command)
12706 (call-process "sh" nil t nil "-c" command)))))
12708 (defun gnus-copy-file (file &optional to)
12711 (list (read-file-name "Copy file: " default-directory)
12712 (read-file-name "Copy file to: " default-directory)))
12713 (gnus-set-global-variables)
12714 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12715 (and (file-directory-p to)
12716 (setq to (concat (file-name-as-directory to)
12717 (file-name-nondirectory file))))
12718 (copy-file file to))
12720 ;; Summary kill commands.
12722 (defun gnus-summary-edit-global-kill (article)
12723 "Edit the \"global\" kill file."
12724 (interactive (list (gnus-summary-article-number)))
12725 (gnus-set-global-variables)
12726 (gnus-group-edit-global-kill article))
12728 (defun gnus-summary-edit-local-kill ()
12729 "Edit a local kill file applied to the current newsgroup."
12731 (gnus-set-global-variables)
12732 (setq gnus-current-headers (gnus-summary-article-header))
12733 (gnus-set-global-variables)
12734 (gnus-group-edit-local-kill
12735 (gnus-summary-article-number) gnus-newsgroup-name))
12739 ;;; Gnus article mode
12742 (put 'gnus-article-mode 'mode-class 'special)
12744 (if gnus-article-mode-map
12746 (setq gnus-article-mode-map (make-keymap))
12747 (suppress-keymap gnus-article-mode-map)
12750 gnus-article-mode-map
12751 " " gnus-article-goto-next-page
12752 "\177" gnus-article-goto-prev-page
12753 "\C-c^" gnus-article-refer-article
12754 "h" gnus-article-show-summary
12755 "s" gnus-article-show-summary
12756 "\C-c\C-m" gnus-article-mail
12757 "?" gnus-article-describe-briefly
12758 gnus-mouse-2 gnus-article-push-button
12759 "\r" gnus-article-press-button
12760 "\t" gnus-article-next-button
12761 "\M-\t" gnus-article-prev-button
12762 "\C-c\C-b" gnus-bug)
12764 (substitute-key-definition
12765 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
12768 (defun gnus-article-mode ()
12769 "Major mode for displaying an article.
12771 All normal editing commands are switched off.
12773 The following commands are available:
12775 \\<gnus-article-mode-map>
12776 \\[gnus-article-next-page]\t Scroll the article one page forwards
12777 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12778 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12779 \\[gnus-article-show-summary]\t Display the summary buffer
12780 \\[gnus-article-mail]\t Send a reply to the address near point
12781 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
12782 \\[gnus-info-find-node]\t Go to the Gnus info node"
12784 (when (and menu-bar-mode
12785 (gnus-visual-p 'article-menu 'menu))
12786 (gnus-article-make-menu-bar))
12787 (kill-all-local-variables)
12788 (gnus-simplify-mode-line)
12789 (setq mode-name "Article")
12790 (setq major-mode 'gnus-article-mode)
12791 (make-local-variable 'minor-mode-alist)
12792 (or (assq 'gnus-show-mime minor-mode-alist)
12793 (setq minor-mode-alist
12794 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
12795 (use-local-map gnus-article-mode-map)
12796 (make-local-variable 'page-delimiter)
12797 (setq page-delimiter gnus-page-delimiter)
12798 (buffer-disable-undo (current-buffer))
12799 (setq buffer-read-only t) ;Disable modification
12800 (run-hooks 'gnus-article-mode-hook))
12802 (defun gnus-article-setup-buffer ()
12803 "Initialize the article buffer."
12804 (let* ((name (if gnus-single-article-buffer "*Article*"
12805 (concat "*Article " gnus-newsgroup-name "*")))
12807 (progn (string-match "\\*Article" name)
12808 (concat " *Original Article"
12809 (substring name (match-end 0))))))
12810 (setq gnus-article-buffer name)
12811 (setq gnus-original-article-buffer original)
12812 ;; This might be a variable local to the summary buffer.
12813 (unless gnus-single-article-buffer
12815 (set-buffer gnus-summary-buffer)
12816 (setq gnus-article-buffer name)
12817 (setq gnus-original-article-buffer original))
12818 (make-local-variable 'gnus-summary-buffer))
12819 (if (get-buffer name)
12822 (buffer-disable-undo (current-buffer))
12823 (setq buffer-read-only t)
12824 (gnus-add-current-to-buffer-list)
12825 (or (eq major-mode 'gnus-article-mode)
12826 (gnus-article-mode))
12829 (set-buffer (get-buffer-create name))
12830 (gnus-add-current-to-buffer-list)
12831 (gnus-article-mode)
12832 (current-buffer)))))
12834 ;; Set article window start at LINE, where LINE is the number of lines
12835 ;; from the head of the article.
12836 (defun gnus-article-set-window-start (&optional line)
12838 (get-buffer-window gnus-article-buffer)
12840 (set-buffer gnus-article-buffer)
12841 (goto-char (point-min))
12844 (gnus-message 6 "Moved to bookmark")
12845 (search-forward "\n\n" nil t)
12846 (forward-line line)
12849 (defun gnus-kill-all-overlays ()
12850 "Delete all overlays in the current buffer."
12851 (when (fboundp 'overlay-lists)
12852 (let* ((overlayss (overlay-lists))
12853 (buffer-read-only nil)
12854 (overlays (nconc (car overlayss) (cdr overlayss))))
12856 (delete-overlay (pop overlays))))))
12858 (defun gnus-request-article-this-buffer (article group)
12859 "Get an article and insert it into this buffer."
12862 (if (get-buffer gnus-original-article-buffer)
12863 (set-buffer (get-buffer gnus-original-article-buffer))
12864 (set-buffer (get-buffer-create gnus-original-article-buffer))
12865 (buffer-disable-undo (current-buffer))
12866 (setq major-mode 'gnus-original-article-mode)
12867 (setq buffer-read-only t)
12868 (gnus-add-current-to-buffer-list))
12870 (setq group (or group gnus-newsgroup-name))
12872 ;; Open server if it has closed.
12873 (gnus-check-server (gnus-find-method-for-group group))
12875 ;; Using `gnus-request-article' directly will insert the article into
12876 ;; `nntp-server-buffer' - so we'll save some time by not having to
12877 ;; copy it from the server buffer into the article buffer.
12879 ;; We only request an article by message-id when we do not have the
12880 ;; headers for it, so we'll have to get those.
12881 (when (stringp article)
12882 (let ((gnus-override-method gnus-refer-article-method))
12883 (gnus-read-header article)))
12885 ;; If the article number is negative, that means that this article
12886 ;; doesn't belong in this newsgroup (possibly), so we find its
12887 ;; message-id and request it by id instead of number.
12888 (when (numberp article)
12890 (set-buffer gnus-summary-buffer)
12891 (let ((header (gnus-summary-article-header article)))
12894 ((memq article gnus-newsgroup-sparse)
12895 ;; This is a sparse gap article.
12896 (setq article (mail-header-id header)))
12898 ;; It's a real article.
12899 (setq article (mail-header-id header)))
12901 ;; It is an extracted pseudo-article.
12902 (setq article 'pseudo)
12903 (gnus-request-pseudo-article header))))
12905 (let ((method (gnus-find-method-for-group
12906 gnus-newsgroup-name)))
12907 (if (not (eq (car method) 'nneething))
12909 (let ((dir (concat (file-name-as-directory (nth 1 method))
12910 (mail-header-subject header))))
12911 (if (file-directory-p dir)
12913 (setq article 'nneething)
12914 (gnus-group-enter-directory dir)))))))))
12917 ;; We first check `gnus-original-article-buffer'.
12918 ((and (equal (car gnus-original-article) group)
12919 (eq (cdr gnus-original-article) article))
12920 ;; We don't have to do anything, since it's already where we
12923 ;; Check the backlog.
12924 ((and gnus-keep-backlog
12925 (gnus-backlog-request-article group article (current-buffer)))
12927 ;; Check the cache.
12928 ((and gnus-use-cache
12930 (gnus-cache-request-article article group))
12932 ;; Get the article and put into the article buffer.
12933 ((or (stringp article) (numberp article))
12934 (let ((gnus-override-method
12935 (and (stringp article) gnus-refer-article-method))
12936 (buffer-read-only nil))
12938 (gnus-kill-all-overlays)
12939 (if (gnus-request-article article group (current-buffer))
12941 (and gnus-keep-backlog
12942 (gnus-backlog-enter-article
12943 group article (current-buffer)))
12945 ;; It was a pseudo.
12948 ;; Take the article from the original article buffer
12949 ;; and place it in the buffer it's supposed to be in.
12950 (setq gnus-original-article (cons group article))
12951 (unless (equal (buffer-name (current-buffer))
12952 (buffer-name (get-buffer gnus-original-article-buffer)))
12953 (let (buffer-read-only)
12955 (gnus-kill-all-overlays)
12956 (insert-buffer-substring gnus-original-article-buffer)))
12958 ;; Update sparse articles.
12959 (when (memq article gnus-newsgroup-sparse)
12960 (gnus-summary-update-article article))))
12962 (defun gnus-read-header (id)
12963 "Read the headers of article ID and enter them into the Gnus system."
12964 (let ((group gnus-newsgroup-name)
12965 (headers gnus-newsgroup-headers)
12967 ;; First we check to see whether the header in question is already
12970 ;; This is a Message-ID.
12971 (setq header (gnus-id-to-header id))
12972 ;; This is an article number.
12973 (setq header (gnus-summary-article-header id)))
12975 ;; We have found the header.
12977 ;; We have to really fetch the header to this article.
12979 (if (gnus-check-backend-function 'request-head group)
12980 (gnus-request-head id group)
12981 (gnus-request-article id group)))
12983 (set-buffer nntp-server-buffer)
12984 (and (search-forward "\n\n" nil t)
12985 (delete-region (1- (point)) (point-max)))
12986 (goto-char (point-max))
12988 (goto-char (point-min))
12997 gnus-reffed-article-number)))
12998 " Article retrieved.\n"))
12999 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13000 () ; Malformed head.
13001 (if (and (stringp id)
13002 (not (string= (gnus-group-real-name group)
13004 ;; If we fetched by Message-ID and the article came
13005 ;; from a different group, we fudge some bogus article
13006 ;; numbers for this article.
13007 (mail-header-set-number header gnus-reffed-article-number))
13008 (decf gnus-reffed-article-number)
13009 (push header gnus-newsgroup-headers)
13010 (setq gnus-current-headers header)
13011 (push (mail-header-number header) gnus-newsgroup-limit)
13014 (defun gnus-article-prepare (article &optional all-headers header)
13015 "Prepare ARTICLE in article mode buffer.
13016 ARTICLE should either be an article number or a Message-ID.
13017 If ARTICLE is an id, HEADER should be the article headers.
13018 If ALL-HEADERS is non-nil, no headers are hidden."
13020 ;; Make sure we start in a summary buffer.
13021 (unless (eq major-mode 'gnus-summary-mode)
13022 (set-buffer gnus-summary-buffer))
13023 (setq gnus-summary-buffer (current-buffer))
13024 ;; Make sure the connection to the server is alive.
13025 (unless (gnus-server-opened
13026 (gnus-find-method-for-group gnus-newsgroup-name))
13027 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13028 (gnus-request-group gnus-newsgroup-name t))
13029 (let* ((article (if header (mail-header-number header) article))
13030 (summary-buffer (current-buffer))
13031 (internal-hook gnus-article-internal-prepare-hook)
13032 (group gnus-newsgroup-name)
13035 (gnus-article-setup-buffer)
13036 (set-buffer gnus-article-buffer)
13037 ;; Deactivate active regions.
13038 (when (and (boundp 'transient-mark-mode)
13039 transient-mark-mode)
13040 (setq mark-active nil))
13041 (if (not (setq result (let ((buffer-read-only nil))
13042 (gnus-request-article-this-buffer
13044 ;; There is no such article.
13046 (when (and (numberp article)
13047 (not (memq article gnus-newsgroup-sparse)))
13048 (setq gnus-article-current
13049 (cons gnus-newsgroup-name article))
13050 (set-buffer gnus-summary-buffer)
13051 (setq gnus-current-article article)
13052 (gnus-summary-mark-article article gnus-canceled-mark))
13053 (unless (memq article gnus-newsgroup-sparse)
13055 1 "No such article (may have expired or been canceled)")
13058 (if (or (eq result 'pseudo) (eq result 'nneething))
13061 (set-buffer summary-buffer)
13062 (setq gnus-last-article gnus-current-article
13063 gnus-newsgroup-history (cons gnus-current-article
13064 gnus-newsgroup-history)
13065 gnus-current-article 0
13066 gnus-current-headers nil
13067 gnus-article-current nil)
13068 (if (eq result 'nneething)
13069 (gnus-configure-windows 'summary)
13070 (gnus-configure-windows 'article))
13071 (gnus-set-global-variables))
13072 (gnus-set-mode-line 'article))
13073 ;; The result from the `request' was an actual article -
13074 ;; or at least some text that is now displayed in the
13076 (if (and (numberp article)
13077 (not (eq article gnus-current-article)))
13078 ;; Seems like a new article has been selected.
13079 ;; `gnus-current-article' must be an article number.
13081 (set-buffer summary-buffer)
13082 (setq gnus-last-article gnus-current-article
13083 gnus-newsgroup-history (cons gnus-current-article
13084 gnus-newsgroup-history)
13085 gnus-current-article article
13086 gnus-current-headers
13087 (gnus-summary-article-header gnus-current-article)
13088 gnus-article-current
13089 (cons gnus-newsgroup-name gnus-current-article))
13090 (unless (vectorp gnus-current-headers)
13091 (setq gnus-current-headers nil))
13092 (gnus-summary-show-thread)
13093 (run-hooks 'gnus-mark-article-hook)
13094 (gnus-set-mode-line 'summary)
13095 (and (gnus-visual-p 'article-highlight 'highlight)
13096 (run-hooks 'gnus-visual-mark-article-hook))
13097 ;; Set the global newsgroup variables here.
13098 ;; Suggested by Jim Sisolak
13099 ;; <sisolak@trans4.neep.wisc.edu>.
13100 (gnus-set-global-variables)
13101 (setq gnus-have-all-headers
13102 (or all-headers gnus-show-all-headers))
13103 (and gnus-use-cache
13104 (vectorp (gnus-summary-article-header article))
13105 (gnus-cache-possibly-enter-article
13107 (gnus-summary-article-header article)
13108 (memq article gnus-newsgroup-marked)
13109 (memq article gnus-newsgroup-dormant)
13110 (memq article gnus-newsgroup-unreads)))))
13111 ;; Hooks for getting information from the article.
13112 ;; This hook must be called before being narrowed.
13113 (let (buffer-read-only)
13114 (run-hooks 'internal-hook)
13115 (run-hooks 'gnus-article-prepare-hook)
13116 ;; Decode MIME message.
13118 (if (or (not gnus-strict-mime)
13119 (gnus-fetch-field "Mime-Version"))
13120 (funcall gnus-show-mime-method)
13121 (funcall gnus-decode-encoded-word-method)))
13122 ;; Perform the article display hooks.
13123 (run-hooks 'gnus-article-display-hook))
13125 (goto-char (point-min))
13126 (and gnus-break-pages (gnus-narrow-to-page))
13127 (gnus-set-mode-line 'article)
13128 (gnus-configure-windows 'article)
13129 (goto-char (point-min))
13132 (defun gnus-article-show-all-headers ()
13133 "Show all article headers in article mode buffer."
13135 (gnus-article-setup-buffer)
13136 (set-buffer gnus-article-buffer)
13137 (let ((buffer-read-only nil))
13138 (remove-text-properties (point-min) (point-max)
13139 gnus-hidden-properties))))
13141 (defun gnus-article-hide-headers-if-wanted ()
13142 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13143 Provided for backwards compatibility."
13144 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13145 gnus-inhibit-hiding
13146 (gnus-article-hide-headers)))
13148 (defun gnus-article-hide-headers (&optional arg delete)
13149 "Toggle whether to hide unwanted headers and possibly sort them as well.
13150 If given a negative prefix, always show; if given a positive prefix,
13153 (unless (gnus-article-check-hidden-text 'headers arg)
13154 ;; This function might be inhibited.
13155 (unless gnus-inhibit-hiding
13157 (set-buffer gnus-article-buffer)
13159 (let ((buffer-read-only nil)
13160 (ignored (when (not (stringp gnus-visible-headers))
13161 (cond ((stringp gnus-ignored-headers)
13162 gnus-ignored-headers)
13163 ((listp gnus-ignored-headers)
13164 (mapconcat 'identity gnus-ignored-headers
13166 (visible (cond ((stringp gnus-visible-headers)
13167 gnus-visible-headers)
13168 ((listp gnus-visible-headers)
13169 (mapconcat 'identity gnus-visible-headers
13171 want-list beg want-l)
13172 ;; First we narrow to just the headers.
13174 (goto-char (point-min))
13175 ;; Hide any "From " lines at the beginning of (mail) articles.
13176 (while (looking-at "From ")
13179 (add-text-properties
13180 (point-min) (point)
13181 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13182 ;; Then treat the rest of the header lines.
13185 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13186 ;; Then we use the two regular expressions
13187 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13188 ;; select which header lines is to remain visible in the
13190 (goto-char (point-min))
13191 (while (re-search-forward "^[^ \t]*:" nil t)
13192 (beginning-of-line)
13193 ;; We add the headers we want to keep to a list and delete
13194 ;; them from the buffer.
13195 (if (or (and visible (looking-at visible))
13196 (and ignored (not (looking-at ignored))))
13198 (push (buffer-substring
13202 ;; Be sure to get multi-line headers...
13203 (re-search-forward "^[^ \t]*:" nil t)
13204 (beginning-of-line)
13207 (delete-region beg (point)))
13209 ;; Sort the headers that we want to display.
13210 (setq want-list (sort want-list 'gnus-article-header-less))
13211 (goto-char (point-min))
13213 (insert (pop want-list)))
13214 ;; We make the unwanted headers invisible.
13216 (delete-region (point-min) (point-max))
13217 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13218 (add-text-properties
13219 (point) (point-max)
13220 (nconc (list 'gnus-type 'headers)
13221 gnus-hidden-properties)))))))))
13223 (defsubst gnus-article-header-rank (header)
13224 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13225 (let ((list gnus-sorted-header-list)
13228 (when (string-match (car list) header)
13230 (setq list (cdr list))
13234 (defun gnus-article-header-less (h1 h2)
13235 "Say whether string H1 is \"less\" than string H2."
13236 (< (gnus-article-header-rank h1)
13237 (gnus-article-header-rank h2)))
13239 (defun gnus-article-hide-boring-headers (&optional arg)
13240 "Toggle hiding of headers that aren't very interesting.
13241 If given a negative prefix, always show; if given a positive prefix,
13244 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13246 (set-buffer gnus-article-buffer)
13248 (let ((buffer-read-only nil)
13249 (list gnus-boring-article-headers)
13250 (inhibit-point-motion-hooks t)
13252 (nnheader-narrow-to-headers)
13254 (setq elem (pop list))
13255 (goto-char (point-min))
13257 ;; Hide empty headers.
13259 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13261 (add-text-properties
13262 (progn (beginning-of-line) (point))
13265 (if (re-search-forward "^[^ \t]" nil t)
13266 (match-beginning 0)
13268 (nconc (list 'gnus-type 'boring-headers)
13269 gnus-hidden-properties))))
13270 ;; Hide boring Newsgroups header.
13271 ((eq elem 'newsgroups)
13272 (when (equal (mail-fetch-field "newsgroups")
13273 (gnus-group-real-name gnus-newsgroup-name))
13274 (gnus-article-hide-header "newsgroups")))
13275 ((eq elem 'followup-to)
13276 (when (equal (mail-fetch-field "followup-to")
13277 (mail-fetch-field "newsgroups"))
13278 (gnus-article-hide-header "followup-to")))
13279 ((eq elem 'reply-to)
13280 (let ((from (mail-fetch-field "from"))
13281 (reply-to (mail-fetch-field "reply-to")))
13285 (nth 1 (mail-extract-address-components from))
13286 (nth 1 (mail-extract-address-components reply-to))))
13287 (gnus-article-hide-header "reply-to"))))
13289 (let ((date (mail-fetch-field "date")))
13291 (< (gnus-days-between date (current-time-string))
13293 (gnus-article-hide-header "date")))))))))))
13295 (defun gnus-article-hide-header (header)
13297 (goto-char (point-min))
13298 (when (re-search-forward (concat "^" header ":") nil t)
13299 (add-text-properties
13300 (progn (beginning-of-line) (point))
13303 (if (re-search-forward "^[^ \t]" nil t)
13304 (match-beginning 0)
13306 (nconc (list 'gnus-type 'boring-headers)
13307 gnus-hidden-properties)))))
13309 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13310 (defun gnus-article-treat-overstrike ()
13311 "Translate overstrikes into bold text."
13314 (set-buffer gnus-article-buffer)
13315 (let ((buffer-read-only nil))
13316 (while (search-forward "\b" nil t)
13317 (let ((next (following-char))
13318 (previous (char-after (- (point) 2))))
13319 (cond ((eq next previous)
13320 (put-text-property (- (point) 2) (point) 'invisible t)
13321 (put-text-property (point) (1+ (point)) 'face 'bold))
13323 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13325 (- (point) 2) (1- (point)) 'face 'underline))
13327 (put-text-property (- (point) 2) (point) 'invisible t)
13329 (point) (1+ (point)) 'face 'underline))))))))
13331 (defun gnus-article-word-wrap ()
13332 "Format too long lines."
13335 (set-buffer gnus-article-buffer)
13336 (let ((buffer-read-only nil)
13339 (goto-char (point-min))
13340 (search-forward "\n\n" nil t)
13342 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13343 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13344 (adaptive-fill-mode t))
13345 (while (not (eobp))
13346 (and (>= (current-column) (min fill-column (window-width)))
13347 (/= (preceding-char) ?:)
13348 (fill-paragraph nil))
13349 (end-of-line 2))))))
13351 (defun gnus-article-remove-cr ()
13352 "Remove carriage returns from an article."
13355 (set-buffer gnus-article-buffer)
13356 (let ((buffer-read-only nil))
13357 (goto-char (point-min))
13358 (while (search-forward "\r" nil t)
13359 (replace-match "" t t)))))
13361 (defun gnus-article-remove-trailing-blank-lines ()
13362 "Remove all trailing blank lines from the article."
13365 (set-buffer gnus-article-buffer)
13366 (let ((buffer-read-only nil))
13367 (goto-char (point-max))
13371 (while (looking-at "^[ \t]*$")
13376 (defun gnus-article-display-x-face (&optional force)
13377 "Look for an X-Face header and display it if present."
13378 (interactive (list 'force))
13380 (set-buffer gnus-article-buffer)
13381 ;; Delete the old process, if any.
13382 (when (process-status "gnus-x-face")
13383 (delete-process "gnus-x-face"))
13384 (let ((inhibit-point-motion-hooks t)
13385 (case-fold-search nil)
13388 (nnheader-narrow-to-headers)
13389 (setq from (mail-fetch-field "from"))
13390 (goto-char (point-min))
13391 (when (and gnus-article-x-face-command
13393 ;; Check whether this face is censored.
13394 (not gnus-article-x-face-too-ugly)
13395 (and gnus-article-x-face-too-ugly from
13396 (not (string-match gnus-article-x-face-too-ugly
13398 ;; Has to be present.
13399 (re-search-forward "^X-Face: " nil t))
13400 ;; We now have the area of the buffer where the X-Face is stored.
13401 (let ((beg (point))
13402 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13403 ;; We display the face.
13404 (if (symbolp gnus-article-x-face-command)
13405 ;; The command is a lisp function, so we call it.
13406 (if (gnus-functionp gnus-article-x-face-command)
13407 (funcall gnus-article-x-face-command beg end)
13408 (error "%s is not a function" gnus-article-x-face-command))
13409 ;; The command is a string, so we interpret the command
13410 ;; as a, well, command, and fork it off.
13411 (let ((process-connection-type nil))
13412 (process-kill-without-query
13414 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13415 (process-send-region "gnus-x-face" beg end)
13416 (process-send-eof "gnus-x-face")))))))))
13418 (defun gnus-headers-decode-quoted-printable ()
13419 "Hack to remove QP encoding from headers."
13420 (let ((case-fold-search t)
13421 (inhibit-point-motion-hooks t)
13423 (goto-char (point-min))
13424 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13425 (setq string (match-string 1))
13426 (narrow-to-region (match-beginning 0) (match-end 0))
13427 (delete-region (point-min) (point-max))
13429 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13430 (subst-char-in-region (point-min) (point-max) ?_ ? )
13432 (goto-char (point-min)))))
13434 (defun gnus-article-de-quoted-unreadable (&optional force)
13435 "Do a naive translation of a quoted-printable-encoded article.
13436 This is in no way, shape or form meant as a replacement for real MIME
13437 processing, but is simply a stop-gap measure until MIME support is
13439 If FORCE, decode the article whether it is marked as quoted-printable
13441 (interactive (list 'force))
13443 (set-buffer gnus-article-buffer)
13444 (let ((case-fold-search t)
13445 (buffer-read-only nil)
13446 (type (gnus-fetch-field "content-transfer-encoding")))
13448 (and type (string-match "quoted-printable" type)))
13449 (goto-char (point-min))
13450 (search-forward "\n\n" nil 'move)
13451 (gnus-mime-decode-quoted-printable (point) (point-max))
13452 (gnus-headers-decode-quoted-printable)))))
13454 (defun gnus-mime-decode-quoted-printable (from to)
13455 "Decode Quoted-Printable in the region between FROM and TO."
13457 (while (search-forward "=" to t)
13458 (cond ((eq (following-char) ?\n)
13461 ((looking-at "[0-9A-F][0-9A-F]")
13463 (insert (hexl-hex-string-to-integer
13464 (buffer-substring (point) (+ 2 (point)))))
13468 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13470 (defun gnus-article-hide-pgp (&optional arg)
13471 "Toggle hiding of any PGP headers and signatures in the current article.
13472 If given a negative prefix, always show; if given a positive prefix,
13475 (unless (gnus-article-check-hidden-text 'pgp arg)
13477 (set-buffer gnus-article-buffer)
13478 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13479 buffer-read-only beg end)
13481 (goto-char (point-min))
13482 ;; Hide the "header".
13483 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13484 (add-text-properties (match-beginning 0) (match-end 0) props))
13486 ;; Hide the actual signature.
13487 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13488 (setq end (match-beginning 0))
13489 (add-text-properties
13490 (match-beginning 0)
13491 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13493 ;; Perhaps we shouldn't hide to the end of the buffer
13494 ;; if there is no end to the signature?
13497 ;; Hide "- " PGP quotation markers.
13498 (when (and beg end)
13499 (narrow-to-region beg end)
13500 (goto-char (point-min))
13501 (while (re-search-forward "^- " nil t)
13502 (add-text-properties (match-beginning 0) (match-end 0) props))
13505 (defun gnus-article-hide-signature (&optional arg)
13506 "Hide the signature in the current article.
13507 If given a negative prefix, always show; if given a positive prefix,
13510 (unless (gnus-article-check-hidden-text 'signature arg)
13512 (set-buffer gnus-article-buffer)
13514 (let ((buffer-read-only nil))
13515 (when (gnus-narrow-to-signature)
13516 (add-text-properties
13517 (point-min) (point-max)
13518 (nconc (list 'gnus-type 'signature)
13519 gnus-hidden-properties))))))))
13521 (defvar gnus-signature-limit nil
13522 "Provide a limit to what is considered a signature.
13523 If it is a number, no signature may not be longer (in characters) than
13524 that number. If it is a function, the function will be called without
13525 any parameters, and if it returns nil, there is no signature in the
13526 buffer. If it is a string, it will be used as a regexp. If it
13527 matches, the text in question is not a signature.")
13529 (defun gnus-narrow-to-signature ()
13530 "Narrow to the signature."
13532 (goto-char (point-max))
13533 (when (re-search-backward gnus-signature-separator nil t)
13535 (when (or (null gnus-signature-limit)
13536 (and (numberp gnus-signature-limit)
13537 (< (- (point-max) (point)) gnus-signature-limit))
13538 (and (gnus-functionp gnus-signature-limit)
13539 (funcall gnus-signature-limit))
13540 (and (stringp gnus-signature-limit)
13541 (not (re-search-forward gnus-signature-limit nil t))))
13542 (narrow-to-region (point) (point-max))
13545 (defun gnus-article-check-hidden-text (type arg)
13546 "Return nil if hiding is necessary."
13547 (let ((hide (gnus-article-hidden-text-p 'signature)))
13548 (cond ((or (and (null arg) (eq hide 'hidden))
13549 (and arg (< 0 (prefix-numeric-value arg))))
13550 (gnus-article-show-hidden-text 'signature))
13552 (gnus-article-show-hidden-text 'signature t))
13555 (defun gnus-article-hidden-text-p (type)
13556 "Say whether the current buffer contains hidden text of type TYPE."
13557 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13560 (if (get-text-property pos 'invisible)
13564 (defun gnus-article-hide (&optional arg force)
13565 "Hide all the gruft in the current article.
13566 This means that PGP stuff, signatures, cited text and (some)
13567 headers will be hidden.
13568 If given a prefix, show the hidden text instead."
13569 (interactive (list current-prefix-arg 'force))
13570 (gnus-article-hide-headers arg)
13571 (gnus-article-hide-pgp arg)
13572 (gnus-article-hide-citation-maybe arg force)
13573 (gnus-article-hide-signature arg))
13575 (defun gnus-article-show-hidden-text (type &optional hide)
13576 "Show all hidden text of type TYPE.
13577 If HIDE, hide the text instead."
13579 (set-buffer gnus-article-buffer)
13580 (let ((buffer-read-only nil)
13581 (inhibit-point-motion-hooks t)
13583 (while (gnus-goto-char (text-property-any
13584 beg (point-max) 'gnus-type type))
13586 (add-text-properties (point) (setq beg (1+ (point)))
13587 gnus-hidden-properties)
13588 (remove-text-properties (point) (setq beg (1+ (point)))
13589 gnus-hidden-properties)))
13592 (defvar gnus-article-time-units
13593 `((year . ,(* 365.25 24 60 60))
13594 (week . ,(* 7 24 60 60))
13595 (day . ,(* 24 60 60))
13596 (hour . ,(* 60 60))
13599 "Mapping from time units to seconds.")
13601 (defun gnus-article-date-ut (&optional type highlight)
13602 "Convert DATE date to universal time in the current article.
13603 If TYPE is `local', convert to local time; if it is `lapsed', output
13604 how much time has lapsed since DATE."
13605 (interactive (list 'ut t))
13606 (let* ((header (or gnus-current-headers
13607 (gnus-summary-article-header) ""))
13608 (date (and (vectorp header) (mail-header-date header)))
13609 (date-regexp "^Date: \\|^X-Sent: ")
13610 (now (current-time))
13611 (inhibit-point-motion-hooks t))
13612 (when (and date (not (string= date "")))
13614 (set-buffer gnus-article-buffer)
13616 (nnheader-narrow-to-headers)
13617 (let ((buffer-read-only nil))
13618 ;; Delete any old Date headers.
13619 (if (zerop (nnheader-remove-header date-regexp t))
13620 (beginning-of-line)
13621 (goto-char (point-max)))
13624 ;; Convert to the local timezone. We have to slap a
13625 ;; `condition-case' round the calls to the timezone
13626 ;; functions since they aren't particularly resistant to
13629 (concat "Date: " (condition-case ()
13630 (timezone-make-date-arpa-standard date)
13633 ;; Convert to Universal Time.
13637 (timezone-make-date-arpa-standard date nil "UT")
13640 ;; Get the original date from the article.
13641 ((eq type 'original)
13642 (concat "Date: " date "\n"))
13643 ;; Do an X-Sent lapsed format.
13645 ;; If the date is seriously mangled, the timezone
13646 ;; functions are liable to bug out, so we condition-case
13647 ;; the entire thing.
13652 (timezone-make-date-arpa-standard
13653 (current-time-string now)
13654 (current-time-zone now) "UT"))
13656 (timezone-make-date-arpa-standard
13659 (real-sec (+ (* (float (car real-time)) 65536)
13661 (sec (abs real-sec))
13667 ;; This is a bit convoluted, but basically we go
13668 ;; through the time units for years, weeks, etc,
13669 ;; and divide things to see whether that results
13670 ;; in positive answers.
13673 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13674 ;; The (remaining) seconds are too few to
13675 ;; be divided into this time unit.
13677 ;; It's big enough, so we output it.
13678 (setq sec (- sec (* num (cdr unit))))
13680 (concat (if prev ", " "") (int-to-string
13682 " " (symbol-name (car unit))
13683 (if (> num 1) "s" ""))
13685 gnus-article-time-units "")
13686 ;; If dates are odd, then it might appear like the
13687 ;; article was sent in the future.
13690 " in the future\n")))))
13692 (error "Unknown conversion type: %s" type)))))
13693 ;; Do highlighting.
13694 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13695 (gnus-article-highlight-headers)))))))
13697 (defun gnus-article-date-local (&optional highlight)
13698 "Convert the current article date to the local timezone."
13699 (interactive (list t))
13700 (gnus-article-date-ut 'local highlight))
13702 (defun gnus-article-date-original (&optional highlight)
13703 "Convert the current article date to what it was originally.
13704 This is only useful if you have used some other date conversion
13705 function and want to see what the date was before converting."
13706 (interactive (list t))
13707 (gnus-article-date-ut 'original highlight))
13709 (defun gnus-article-date-lapsed (&optional highlight)
13710 "Convert the current article date to time lapsed since it was sent."
13711 (interactive (list t))
13712 (gnus-article-date-ut 'lapsed highlight))
13714 (defun gnus-article-maybe-highlight ()
13715 "Do some article highlighting if `gnus-visual' is non-nil."
13716 (if (gnus-visual-p 'article-highlight 'highlight)
13717 (gnus-article-highlight-some)))
13721 (defun gnus-output-to-rmail (file-name)
13722 "Append the current article to an Rmail file named FILE-NAME."
13724 ;; Most of these codes are borrowed from rmailout.el.
13725 (setq file-name (expand-file-name file-name))
13726 (setq rmail-default-rmail-file file-name)
13727 (let ((artbuf (current-buffer))
13728 (tmpbuf (get-buffer-create " *Gnus-output*")))
13730 (or (get-file-buffer file-name)
13731 (file-exists-p file-name)
13732 (if (gnus-yes-or-no-p
13733 (concat "\"" file-name "\" does not exist, create it? "))
13734 (let ((file-buffer (create-file-buffer file-name)))
13736 (set-buffer file-buffer)
13737 (rmail-insert-rmail-file-header)
13738 (let ((require-final-newline nil))
13739 (write-region (point-min) (point-max) file-name t 1)))
13740 (kill-buffer file-buffer))
13741 (error "Output file does not exist")))
13742 (set-buffer tmpbuf)
13743 (buffer-disable-undo (current-buffer))
13745 (insert-buffer-substring artbuf)
13746 (gnus-convert-article-to-rmail)
13747 ;; Decide whether to append to a file or to an Emacs buffer.
13748 (let ((outbuf (get-file-buffer file-name)))
13750 (append-to-file (point-min) (point-max) file-name)
13751 ;; File has been visited, in buffer OUTBUF.
13752 (set-buffer outbuf)
13753 (let ((buffer-read-only nil)
13754 (msg (and (boundp 'rmail-current-message)
13755 (symbol-value 'rmail-current-message))))
13756 ;; If MSG is non-nil, buffer is in RMAIL mode.
13759 (narrow-to-region (point-max) (point-max))))
13760 (insert-buffer-substring tmpbuf)
13763 (goto-char (point-min))
13765 (search-backward "\^_")
13766 (narrow-to-region (point) (point-max))
13767 (goto-char (1+ (point-min)))
13768 (rmail-count-new-messages t)
13769 (rmail-show-message msg)))))))
13770 (kill-buffer tmpbuf)))
13772 (defun gnus-output-to-file (file-name)
13773 "Append the current article to a file named FILE-NAME."
13774 (setq file-name (expand-file-name file-name))
13775 (let ((artbuf (current-buffer))
13776 (tmpbuf (get-buffer-create " *Gnus-output*")))
13778 (set-buffer tmpbuf)
13779 (buffer-disable-undo (current-buffer))
13781 (insert-buffer-substring artbuf)
13782 ;; Append newline at end of the buffer as separator, and then
13783 ;; save it to file.
13784 (goto-char (point-max))
13786 (append-to-file (point-min) (point-max) file-name))
13787 (kill-buffer tmpbuf)))
13789 (defun gnus-convert-article-to-rmail ()
13790 "Convert article in current buffer to Rmail message format."
13791 (let ((buffer-read-only nil))
13792 ;; Convert article directly into Babyl format.
13793 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
13794 (goto-char (point-min))
13795 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
13796 (while (search-forward "\n\^_" nil t) ;single char
13797 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
13798 (goto-char (point-max))
13801 (defun gnus-narrow-to-page (&optional arg)
13802 "Narrow the article buffer to a page.
13803 If given a numerical ARG, move forward ARG pages."
13805 (setq arg (if arg (prefix-numeric-value arg) 0))
13807 (set-buffer gnus-article-buffer)
13808 (goto-char (point-min))
13810 (when (gnus-visual-p 'page-marker)
13811 (let ((buffer-read-only nil))
13812 (gnus-remove-text-with-property 'gnus-prev)
13813 (gnus-remove-text-with-property 'gnus-next)))
13816 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
13818 (re-search-forward page-delimiter nil 'move arg)))
13819 (goto-char (match-end 0)))
13822 (if (re-search-forward page-delimiter nil 'move)
13823 (match-beginning 0)
13825 (when (and (gnus-visual-p 'page-marker)
13826 (not (= (point-min) 1)))
13828 (goto-char (point-min))
13829 (gnus-insert-prev-page-button)))
13830 (when (and (gnus-visual-p 'page-marker)
13831 (not (= (1- (point-max)) (buffer-size))))
13833 (goto-char (point-max))
13834 (gnus-insert-next-page-button)))))
13837 ;; Article mode commands
13839 (defun gnus-article-goto-next-page ()
13840 "Show the next page of the article."
13842 (when (gnus-article-next-page)
13843 (gnus-article-read-summary-keys nil ?n)))
13845 (defun gnus-article-goto-prev-page ()
13846 "Show the next page of the article."
13848 (if (bobp) (gnus-article-read-summary-keys nil ?n)
13849 (gnus-article-prev-page nil)))
13851 (defun gnus-article-next-page (&optional lines)
13852 "Show the next page of the current article.
13853 If end of article, return non-nil. Otherwise return nil.
13854 Argument LINES specifies lines to be scrolled up."
13856 (move-to-window-line -1)
13857 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
13858 (if (save-excursion
13860 (and (pos-visible-in-window-p) ;Not continuation line.
13862 ;; Nothing in this page.
13863 (if (or (not gnus-break-pages)
13866 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
13868 (gnus-narrow-to-page 1) ;Go to next page.
13870 ;; More in this page.
13874 ;; Long lines may cause an end-of-buffer error.
13875 (goto-char (point-max))))
13878 (defun gnus-article-prev-page (&optional lines)
13879 "Show previous page of current article.
13880 Argument LINES specifies lines to be scrolled down."
13882 (move-to-window-line 0)
13883 (if (and gnus-break-pages
13885 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
13887 (gnus-narrow-to-page -1) ;Go to previous page.
13888 (goto-char (point-max))
13891 (scroll-down lines)
13894 (defun gnus-article-refer-article ()
13895 "Read article specified by message-id around point."
13897 (let ((point (point)))
13898 (search-forward ">" nil t) ;Move point to end of "<....>".
13899 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
13900 (let ((message-id (match-string 1)))
13902 (set-buffer gnus-summary-buffer)
13903 (gnus-summary-refer-article message-id))
13904 (goto-char (point))
13905 (error "No references around point"))))
13907 (defun gnus-article-show-summary ()
13908 "Reconfigure windows to show summary buffer."
13910 (gnus-configure-windows 'article)
13911 (gnus-summary-goto-subject gnus-current-article))
13913 (defun gnus-article-describe-briefly ()
13914 "Describe article mode commands briefly."
13917 (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")))
13919 (defun gnus-article-summary-command ()
13920 "Execute the last keystroke in the summary buffer."
13922 (let ((obuf (current-buffer))
13923 (owin (current-window-configuration))
13925 (switch-to-buffer gnus-summary-buffer 'norecord)
13926 (setq func (lookup-key (current-local-map) (this-command-keys)))
13927 (call-interactively func)
13929 (set-window-configuration owin)
13930 (set-window-point (get-buffer-window (current-buffer)) (point))))
13932 (defun gnus-article-summary-command-nosave ()
13933 "Execute the last keystroke in the summary buffer."
13936 (pop-to-buffer gnus-summary-buffer 'norecord)
13937 (setq func (lookup-key (current-local-map) (this-command-keys)))
13938 (call-interactively func)))
13940 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
13941 "Read a summary buffer key sequence and execute it from the article buffer."
13944 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
13945 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
13949 (set-buffer gnus-summary-buffer)
13950 (push (or key last-command-event) unread-command-events)
13951 (setq keys (read-key-sequence nil)))
13954 (if (member keys nosaves)
13956 (pop-to-buffer gnus-summary-buffer 'norecord)
13957 (if (setq func (lookup-key (current-local-map) keys))
13958 (call-interactively func)
13960 (let ((obuf (current-buffer))
13961 (owin (current-window-configuration))
13964 (if not-restore-window
13965 (pop-to-buffer gnus-summary-buffer 'norecord)
13966 (switch-to-buffer gnus-summary-buffer 'norecord))
13967 (setq in-buffer (current-buffer))
13968 (if (setq func (lookup-key (current-local-map) keys))
13969 (call-interactively func)
13971 (when (eq in-buffer (current-buffer))
13973 (unless not-restore-window
13974 (set-window-configuration owin))
13975 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
13978 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
13981 (defalias 'gnus-batch-kill 'gnus-batch-score)
13983 (defun gnus-batch-score ()
13984 "Run batched scoring.
13985 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
13986 Newsgroups is a list of strings in Bnews format. If you want to score
13987 the comp hierarchy, you'd say \"comp.all\". If you would not like to
13988 score the alt hierarchy, you'd say \"!alt.all\"."
13991 (gnus-newsrc-parse-options
13992 (apply (function concat)
13993 (mapcar (lambda (g) (concat g " "))
13994 command-line-args-left))))
13995 (gnus-expert-user t)
13996 (nnmail-spool-file nil)
13997 (gnus-use-dribble-file nil)
13998 (yes (car yes-and-no))
13999 (no (cdr yes-and-no))
14001 ;; Disable verbose message.
14002 gnus-novice-user gnus-large-newsgroup)
14003 ;; Eat all arguments.
14004 (setq command-line-args-left nil)
14007 ;; Apply kills to specified newsgroups in command line arguments.
14008 (setq newsrc (cdr gnus-newsrc-alist))
14010 (setq group (car (car newsrc)))
14011 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14012 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14014 (or (eq (car entry) t)
14015 (not (zerop (car entry)))))
14016 (if yes (string-match yes group) t)
14017 (or (null no) (not (string-match no group))))
14019 (gnus-summary-read-group group nil t nil t)
14020 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14021 (gnus-summary-exit))))
14022 (setq newsrc (cdr newsrc)))
14024 (switch-to-buffer gnus-group-buffer)
14025 (gnus-group-save-newsrc)))
14027 (defun gnus-apply-kill-file ()
14028 "Apply a kill file to the current newsgroup.
14029 Returns the number of articles marked as read."
14030 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14031 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14032 (gnus-apply-kill-file-internal)
14035 (defun gnus-kill-save-kill-buffer ()
14037 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14038 (if (get-file-buffer file)
14040 (set-buffer (get-file-buffer file))
14041 (and (buffer-modified-p) (save-buffer))
14042 (kill-buffer (current-buffer)))))))
14044 (defvar gnus-kill-file-name "KILL"
14045 "Suffix of the kill files.")
14047 (defun gnus-newsgroup-kill-file (newsgroup)
14048 "Return the name of a kill file name for NEWSGROUP.
14049 If NEWSGROUP is nil, return the global kill file name instead."
14050 (cond ((or (null newsgroup)
14051 (string-equal newsgroup ""))
14052 ;; The global KILL file is placed at top of the directory.
14053 (expand-file-name gnus-kill-file-name
14054 (or gnus-kill-files-directory "~/News")))
14055 ((gnus-use-long-file-name 'not-kill)
14056 ;; Append ".KILL" to newsgroup name.
14057 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14058 "." gnus-kill-file-name)
14059 (or gnus-kill-files-directory "~/News")))
14061 ;; Place "KILL" under the hierarchical directory.
14062 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14063 "/" gnus-kill-file-name)
14064 (or gnus-kill-files-directory "~/News")))))
14071 (defvar gnus-dribble-ignore nil)
14072 (defvar gnus-dribble-eval-file nil)
14074 (defun gnus-dribble-file-name ()
14076 (if gnus-dribble-directory
14077 (concat (file-name-as-directory gnus-dribble-directory)
14078 (file-name-nondirectory gnus-current-startup-file))
14079 gnus-current-startup-file)
14082 (defun gnus-dribble-enter (string)
14083 (if (and (not gnus-dribble-ignore)
14084 gnus-dribble-buffer
14085 (buffer-name gnus-dribble-buffer))
14086 (let ((obuf (current-buffer)))
14087 (set-buffer gnus-dribble-buffer)
14088 (insert string "\n")
14089 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14090 (set-buffer obuf))))
14092 (defun gnus-dribble-read-file ()
14093 (let ((dribble-file (gnus-dribble-file-name)))
14095 (set-buffer (setq gnus-dribble-buffer
14097 (file-name-nondirectory dribble-file))))
14098 (gnus-add-current-to-buffer-list)
14100 (setq buffer-file-name dribble-file)
14102 (buffer-disable-undo (current-buffer))
14103 (bury-buffer (current-buffer))
14104 (set-buffer-modified-p nil)
14105 (let ((auto (make-auto-save-file-name))
14106 (gnus-dribble-ignore t))
14107 (if (or (file-exists-p auto) (file-exists-p dribble-file))
14109 (if (file-newer-than-file-p auto dribble-file)
14110 (setq dribble-file auto))
14111 (insert-file-contents dribble-file)
14112 (if (not (zerop (buffer-size)))
14113 (set-buffer-modified-p t))
14115 "Auto-save file exists. Do you want to read it? ")
14116 (setq gnus-dribble-eval-file t))))))))
14118 (defun gnus-dribble-eval-file ()
14119 (if (not gnus-dribble-eval-file)
14121 (setq gnus-dribble-eval-file nil)
14123 (let ((gnus-dribble-ignore t))
14124 (set-buffer gnus-dribble-buffer)
14125 (eval-buffer (current-buffer))))))
14127 (defun gnus-dribble-delete-file ()
14128 (if (file-exists-p (gnus-dribble-file-name))
14129 (delete-file (gnus-dribble-file-name)))
14130 (if gnus-dribble-buffer
14132 (set-buffer gnus-dribble-buffer)
14133 (let ((auto (make-auto-save-file-name)))
14134 (if (file-exists-p auto)
14135 (delete-file auto))
14137 (set-buffer-modified-p nil)))))
14139 (defun gnus-dribble-save ()
14140 (if (and gnus-dribble-buffer
14141 (buffer-name gnus-dribble-buffer))
14143 (set-buffer gnus-dribble-buffer)
14146 (defun gnus-dribble-clear ()
14148 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14150 (set-buffer gnus-dribble-buffer)
14152 (set-buffer-modified-p nil)
14153 (setq buffer-saved-size (buffer-size))))))
14156 ;;; Server Communication
14159 (defun gnus-start-news-server (&optional confirm)
14160 "Open a method for getting news.
14161 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14163 (if gnus-current-select-method
14164 ;; Stream is already opened.
14166 ;; Open NNTP server.
14167 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14170 ;; Read server name with completion.
14171 (setq gnus-nntp-server
14172 (completing-read "NNTP server: "
14173 (mapcar (lambda (server) (list server))
14174 (cons (list gnus-nntp-server)
14175 gnus-secondary-servers))
14176 nil nil gnus-nntp-server))))
14178 (if (and gnus-nntp-server
14179 (stringp gnus-nntp-server)
14180 (not (string= gnus-nntp-server "")))
14181 (setq gnus-select-method
14182 (cond ((or (string= gnus-nntp-server "")
14183 (string= gnus-nntp-server "::"))
14184 (list 'nnspool (system-name)))
14185 ((string-match "^:" gnus-nntp-server)
14186 (list 'nnmh gnus-nntp-server
14187 (list 'nnmh-directory
14188 (file-name-as-directory
14190 (concat "~/" (substring
14191 gnus-nntp-server 1)))))
14192 (list 'nnmh-get-new-mail nil)))
14194 (list 'nntp gnus-nntp-server)))))
14196 (setq how (car gnus-select-method))
14197 (cond ((eq how 'nnspool)
14199 (gnus-message 5 "Looking up local news spool..."))
14202 (gnus-message 5 "Looking up mh spool..."))
14205 (setq gnus-current-select-method gnus-select-method)
14206 (run-hooks 'gnus-open-server-hook)
14208 ;; gnus-open-server-hook might have opened it
14209 (gnus-server-opened gnus-select-method)
14210 (gnus-open-server gnus-select-method)
14213 "%s (%s) open error: '%s'. Continue? "
14214 (car gnus-select-method) (cadr gnus-select-method)
14215 (gnus-status-message gnus-select-method)))
14217 (gnus-message 1 "Couldn't open server on %s"
14218 (nth 1 gnus-select-method))
14222 (defun gnus-check-group (group)
14223 "Try to make sure that the server where GROUP exists is alive."
14224 (let ((method (gnus-find-method-for-group group)))
14225 (or (gnus-server-opened method)
14226 (gnus-open-server method))))
14228 (defun gnus-check-server (&optional method)
14229 "Check whether the connection to METHOD is down.
14230 If METHOD is nil, use `gnus-select-method'.
14231 If it is down, start it up (again)."
14232 (let ((method (or method gnus-select-method)))
14233 ;; Transform virtual server names into select methods.
14234 (when (stringp method)
14235 (setq method (gnus-server-to-method method)))
14236 (if (gnus-server-opened method)
14237 ;; The stream is already opened.
14239 ;; Open the server.
14240 (gnus-message 5 "Opening %s server on %s..." (car method) (nth 1 method))
14241 (run-hooks 'gnus-open-server-hook)
14243 (gnus-open-server method)
14246 (defun gnus-get-function (method function)
14247 "Return a function symbol based on METHOD and FUNCTION."
14248 ;; Translate server names into methods.
14250 (error "Attempted use of a nil select method"))
14251 (when (stringp method)
14252 (setq method (gnus-server-to-method method)))
14253 (let ((func (intern (format "%s-%s" (car method) function))))
14254 ;; If the functions isn't bound, we require the backend in
14256 (unless (fboundp func)
14257 (require (car method))
14258 (unless (fboundp func)
14259 ;; This backend doesn't implement this function.
14260 (error "No such function: %s" func)))
14263 ;;; Interface functions to the backends.
14265 (defun gnus-open-server (method)
14266 "Open a connection to METHOD."
14267 (let ((elem (assoc method gnus-opened-servers)))
14268 ;; If this method was previously denied, we just return nil.
14269 (if (eq (nth 1 elem) 'denied)
14271 (gnus-message 1 "Denied server")
14273 ;; Open the server.
14275 (funcall (gnus-get-function method 'open-server)
14276 (nth 1 method) (nthcdr 2 method))))
14277 ;; If this hasn't been opened before, we add it to the list.
14279 (setq elem (list method nil)
14280 gnus-opened-servers (cons elem gnus-opened-servers)))
14281 ;; Set the status of this server.
14282 (setcar (cdr elem) (if result 'ok 'denied))
14283 ;; Return the result from the "open" call.
14286 (defun gnus-close-server (method)
14287 "Close the connection to METHOD."
14288 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14290 (defun gnus-request-list (method)
14291 "Request the active file from METHOD."
14292 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14294 (defun gnus-request-list-newsgroups (method)
14295 "Request the newsgroups file from METHOD."
14296 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14298 (defun gnus-request-newgroups (date method)
14299 "Request all new groups since DATE from METHOD."
14300 (funcall (gnus-get-function method 'request-newgroups)
14301 date (nth 1 method)))
14303 (defun gnus-server-opened (method)
14304 "Check whether a connection to METHOD has been opened."
14305 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14307 (defun gnus-status-message (method)
14308 "Return the status message from METHOD.
14309 If METHOD is a string, it is interpreted as a group name. The method
14310 this group uses will be queried."
14311 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14313 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14315 (defun gnus-request-group (group &optional dont-check method)
14316 "Request GROUP. If DONT-CHECK, no information is required."
14317 (let ((method (or method (gnus-find-method-for-group group))))
14318 (funcall (gnus-get-function method 'request-group)
14319 (gnus-group-real-name group) (nth 1 method) dont-check)))
14321 (defun gnus-request-asynchronous (group &optional articles)
14322 "Request that GROUP behave asynchronously.
14323 ARTICLES is the `data' of the group."
14324 (let ((method (gnus-find-method-for-group group)))
14325 (funcall (gnus-get-function method 'request-asynchronous)
14326 (gnus-group-real-name group) (nth 1 method) articles)))
14328 (defun gnus-list-active-group (group)
14329 "Request active information on GROUP."
14330 (let ((method (gnus-find-method-for-group group))
14331 (func 'list-active-group))
14332 (when (gnus-check-backend-function func group)
14333 (funcall (gnus-get-function method func)
14334 (gnus-group-real-name group) (nth 1 method)))))
14336 (defun gnus-request-group-description (group)
14337 "Request a description of GROUP."
14338 (let ((method (gnus-find-method-for-group group))
14339 (func 'request-group-description))
14340 (when (gnus-check-backend-function func group)
14341 (funcall (gnus-get-function method func)
14342 (gnus-group-real-name group) (nth 1 method)))))
14344 (defun gnus-close-group (group)
14345 "Request the GROUP be closed."
14346 (let ((method (gnus-find-method-for-group group)))
14347 (funcall (gnus-get-function method 'close-group)
14348 (gnus-group-real-name group) (nth 1 method))))
14350 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14351 "Request headers for ARTICLES in GROUP.
14352 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14353 (let ((method (gnus-find-method-for-group group)))
14354 (if (and gnus-use-cache (numberp (car articles)))
14355 (gnus-cache-retrieve-headers articles group fetch-old)
14356 (funcall (gnus-get-function method 'retrieve-headers)
14357 articles (gnus-group-real-name group) (nth 1 method)
14360 (defun gnus-retrieve-groups (groups method)
14361 "Request active information on GROUPS from METHOD."
14362 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14364 (defun gnus-request-type (group &optional article)
14365 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14366 (let ((method (gnus-find-method-for-group group)))
14367 (if (not (gnus-check-backend-function 'request-type (car method)))
14369 (funcall (gnus-get-function method 'request-type)
14370 (gnus-group-real-name group) article))))
14372 (defun gnus-request-update-mark (group article mark)
14373 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14374 (let ((method (gnus-find-method-for-group group)))
14375 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14377 (funcall (gnus-get-function method 'request-update-mark)
14378 (gnus-group-real-name group) article mark))))
14380 (defun gnus-request-article (article group &optional buffer)
14381 "Request the ARTICLE in GROUP.
14382 ARTICLE can either be an article number or an article Message-ID.
14383 If BUFFER, insert the article in that group."
14384 (let ((method (gnus-find-method-for-group group)))
14385 (funcall (gnus-get-function method 'request-article)
14386 article (gnus-group-real-name group) (nth 1 method) buffer)))
14388 (defun gnus-request-head (article group)
14389 "Request the head of ARTICLE in GROUP."
14390 (let ((method (gnus-find-method-for-group group)))
14391 (funcall (gnus-get-function method 'request-head)
14392 article (gnus-group-real-name group) (nth 1 method))))
14394 (defun gnus-request-body (article group)
14395 "Request the body of ARTICLE in GROUP."
14396 (let ((method (gnus-find-method-for-group group)))
14397 (funcall (gnus-get-function method 'request-body)
14398 article (gnus-group-real-name group) (nth 1 method))))
14400 (defun gnus-request-post (method)
14401 "Post the current buffer using METHOD."
14402 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14404 (defun gnus-request-scan (group method)
14405 "Request a SCAN being performed in GROUP from METHOD.
14406 If GROUP is nil, all groups on METHOD are scanned."
14407 (let ((method (if group (gnus-find-method-for-group group) method)))
14408 (funcall (gnus-get-function method 'request-scan)
14409 (and group (gnus-group-real-name group)) (nth 1 method))))
14411 (defsubst gnus-request-update-info (info method)
14412 "Request that METHOD update INFO."
14413 (when (gnus-check-backend-function 'request-update-info (car method))
14414 (funcall (gnus-get-function method 'request-update-info)
14415 (gnus-group-real-name (gnus-info-group info))
14416 info (nth 1 method))))
14418 (defun gnus-request-expire-articles (articles group &optional force)
14419 (let ((method (gnus-find-method-for-group group)))
14420 (funcall (gnus-get-function method 'request-expire-articles)
14421 articles (gnus-group-real-name group) (nth 1 method)
14424 (defun gnus-request-move-article
14425 (article group server accept-function &optional last)
14426 (let ((method (gnus-find-method-for-group group)))
14427 (funcall (gnus-get-function method 'request-move-article)
14428 article (gnus-group-real-name group)
14429 (nth 1 method) accept-function last)))
14431 (defun gnus-request-accept-article (group &optional last method)
14432 ;; Make sure there's a newline at the end of the article.
14433 (goto-char (point-max))
14436 (let ((func (if (symbolp group) group
14437 (car (or method (gnus-find-method-for-group group))))))
14438 (funcall (intern (format "%s-request-accept-article" func))
14439 (if (stringp group) (gnus-group-real-name group) group)
14442 (defun gnus-request-replace-article (article group buffer)
14443 (let ((func (car (gnus-find-method-for-group group))))
14444 (funcall (intern (format "%s-request-replace-article" func))
14445 article (gnus-group-real-name group) buffer)))
14447 (defun gnus-request-associate-buffer (group)
14448 (let ((method (gnus-find-method-for-group group)))
14449 (funcall (gnus-get-function method 'request-associate-buffer)
14450 (gnus-group-real-name group))))
14452 (defun gnus-request-restore-buffer (article group)
14453 "Request a new buffer restored to the state of ARTICLE."
14454 (let ((method (gnus-find-method-for-group group)))
14455 (funcall (gnus-get-function method 'request-restore-buffer)
14456 article (gnus-group-real-name group) (nth 1 method))))
14458 (defun gnus-request-create-group (group &optional method)
14459 (let ((method (or method (gnus-find-method-for-group group))))
14460 (funcall (gnus-get-function method 'request-create-group)
14461 (gnus-group-real-name group) (nth 1 method))))
14463 (defun gnus-request-delete-group (group &optional force)
14464 (let ((method (gnus-find-method-for-group group)))
14465 (funcall (gnus-get-function method 'request-delete-group)
14466 (gnus-group-real-name group) force (nth 1 method))))
14468 (defun gnus-request-rename-group (group new-name)
14469 (let ((method (gnus-find-method-for-group group)))
14470 (funcall (gnus-get-function method 'request-rename-group)
14471 (gnus-group-real-name group)
14472 (gnus-group-real-name new-name) (nth 1 method))))
14474 (defun gnus-member-of-valid (symbol group)
14475 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14476 (memq symbol (assoc
14477 (symbol-name (car (gnus-find-method-for-group group)))
14478 gnus-valid-select-methods)))
14480 (defun gnus-method-option-p (method option)
14481 "Return non-nil if select METHOD has OPTION as a parameter."
14482 (memq option (assoc (format "%s" (car method))
14483 gnus-valid-select-methods)))
14485 (defun gnus-server-extend-method (group method)
14486 ;; This function "extends" a virtual server. If the server is
14487 ;; "hello", and the select method is ("hello" (my-var "something"))
14488 ;; in the group "alt.alt", this will result in a new virtual server
14489 ;; called "hello+alt.alt".
14491 (gnus-copy-sequence
14492 (if (equal (car method) "native") gnus-select-method
14493 (cdr (assoc (car method) gnus-server-alist))))))
14494 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14495 (nconc entry (cdr method))))
14497 (defun gnus-find-method-for-group (group &optional info)
14498 "Find the select method that GROUP uses."
14499 (or gnus-override-method
14501 gnus-select-method)
14502 (let ((info (or info (gnus-get-info group)))
14505 (not (setq method (gnus-info-method info))))
14506 (setq method gnus-select-method)
14508 (cond ((stringp method)
14509 (gnus-server-to-method method))
14510 ((stringp (car method))
14511 (gnus-server-extend-method group method))
14514 (gnus-server-add-address method))))
14516 (defun gnus-check-backend-function (func group)
14517 "Check whether GROUP supports function FUNC."
14518 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14520 (fboundp (intern (format "%s-%s" method func)))))
14522 (defun gnus-methods-using (feature)
14523 "Find all methods that have FEATURE."
14524 (let ((valids gnus-valid-select-methods)
14527 (if (memq feature (car valids))
14528 (setq outs (cons (car valids) outs)))
14529 (setq valids (cdr valids)))
14533 ;;; Active & Newsrc File Handling
14536 (defun gnus-setup-news (&optional rawfile level)
14537 "Setup news information.
14538 If RAWFILE is non-nil, the .newsrc file will also be read.
14539 If LEVEL is non-nil, the news will be set up at level LEVEL."
14540 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14541 ;; Clear some variables to re-initialize news information.
14542 (if init (setq gnus-newsrc-alist nil
14543 gnus-active-hashtb nil))
14545 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14546 (if init (gnus-read-newsrc-file rawfile))
14548 ;; If we don't read the complete active file, we fill in the
14550 (if (or (null gnus-read-active-file)
14551 (eq gnus-read-active-file 'some))
14552 (gnus-update-active-hashtb-from-killed))
14554 ;; Read the active file and create `gnus-active-hashtb'.
14555 ;; If `gnus-read-active-file' is nil, then we just create an empty
14556 ;; hash table. The partial filling out of the hash table will be
14557 ;; done in `gnus-get-unread-articles'.
14558 (and gnus-read-active-file
14560 (gnus-read-active-file))
14562 (or gnus-active-hashtb
14563 (setq gnus-active-hashtb (make-vector 4095 0)))
14565 ;; Initialize the cache.
14566 (when gnus-use-cache
14569 ;; Possibly eval the dribble file.
14570 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14572 (gnus-update-format-specifications)
14574 ;; Find new newsgroups and treat them.
14575 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
14576 (gnus-check-server gnus-select-method))
14577 (gnus-find-new-newsgroups))
14579 ;; Find the number of unread articles in each non-dead group.
14580 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14581 (gnus-get-unread-articles level))
14583 (if (and init gnus-check-bogus-newsgroups
14584 gnus-read-active-file (not level)
14585 (gnus-server-opened gnus-select-method))
14586 (gnus-check-bogus-newsgroups))))
14588 (defun gnus-find-new-newsgroups (&optional arg)
14589 "Search for new newsgroups and add them.
14590 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14591 The `-n' option line from .newsrc is respected.
14592 If ARG (the prefix), use the `ask-server' method to query
14593 the server for new groups."
14595 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14596 (null gnus-read-active-file)
14597 (eq gnus-read-active-file 'some))
14598 'ask-server gnus-check-new-newsgroups)))
14599 (unless (gnus-check-first-time-used)
14600 (if (or (consp check)
14601 (eq check 'ask-server))
14602 (gnus-ask-server-for-new-groups)
14604 group new-newsgroups)
14605 (gnus-message 5 "Looking for new newsgroups...")
14606 (or gnus-have-read-active-file (gnus-read-active-file))
14607 (setq gnus-newsrc-last-checked-date (current-time-string))
14608 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
14609 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14610 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14613 (if (or (null (setq group (symbol-name sym)))
14615 (null (symbol-value sym))
14616 (gnus-gethash group gnus-killed-hashtb)
14617 (gnus-gethash group gnus-newsrc-hashtb))
14619 (let ((do-sub (gnus-matches-options-n group)))
14621 ((eq do-sub 'subscribe)
14622 (setq groups (1+ groups))
14623 (gnus-sethash group group gnus-killed-hashtb)
14624 (funcall gnus-subscribe-options-newsgroup-method group))
14625 ((eq do-sub 'ignore)
14628 (setq groups (1+ groups))
14629 (gnus-sethash group group gnus-killed-hashtb)
14630 (if gnus-subscribe-hierarchical-interactive
14631 (setq new-newsgroups (cons group new-newsgroups))
14632 (funcall gnus-subscribe-newsgroup-method group)))))))
14633 gnus-active-hashtb)
14635 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14636 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14638 (gnus-message 6 "%d new newsgroup%s arrived."
14639 groups (if (> groups 1) "s have" " has"))
14640 (gnus-message 6 "No new newsgroups.")))))))
14642 (defun gnus-matches-options-n (group)
14643 ;; Returns `subscribe' if the group is to be unconditionally
14644 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14645 ;; no match for the group.
14647 ;; First we check the two user variables.
14649 ((and gnus-options-subscribe
14650 (string-match gnus-options-subscribe group))
14652 ((and gnus-auto-subscribed-groups
14653 (string-match gnus-auto-subscribed-groups group))
14655 ((and gnus-options-not-subscribe
14656 (string-match gnus-options-not-subscribe group))
14658 ;; Then we go through the list that was retrieved from the .newsrc
14659 ;; file. This list has elements on the form
14660 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14661 ;; is in the reverse order of the options line) is returned.
14663 (let ((regs gnus-newsrc-options-n))
14665 (not (string-match (car (car regs)) group)))
14666 (setq regs (cdr regs)))
14667 (and regs (cdr (car regs)))))))
14669 (defun gnus-ask-server-for-new-groups ()
14670 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14671 (methods (cons gnus-select-method
14673 gnus-message-archive-method
14675 (and (consp gnus-check-new-newsgroups)
14676 gnus-check-new-newsgroups)
14677 gnus-secondary-select-methods))))
14679 (new-date (current-time-string))
14680 group new-newsgroups got-new method hashtb
14681 gnus-override-subscribe-method)
14682 ;; Go through both primary and secondary select methods and
14683 ;; request new newsgroups.
14684 (while (setq method (gnus-server-get-method nil (pop methods)))
14685 (setq gnus-override-subscribe-method method)
14686 (when (and (gnus-check-server method)
14687 (gnus-request-newgroups date method))
14690 (setq hashtb (gnus-make-hashtable 100))
14691 (set-buffer nntp-server-buffer)
14692 ;; Enter all the new groups into a hashtable.
14693 (gnus-active-to-gnus-format method hashtb 'ignore)))
14694 ;; Now all new groups from `method' are in `hashtb'.
14696 (lambda (group-sym)
14697 (if (or (null (setq group (symbol-name group-sym)))
14698 (null (symbol-value group-sym))
14699 (gnus-gethash group gnus-newsrc-hashtb)
14700 (member group gnus-zombie-list)
14701 (member group gnus-killed-list))
14702 ;; The group is already known.
14704 ;; Make this group active.
14705 (when (symbol-value group-sym)
14706 (gnus-set-active group (symbol-value group-sym)))
14707 ;; Check whether we want it or not.
14708 (let ((do-sub (gnus-matches-options-n group)))
14710 ((eq do-sub 'subscribe)
14712 (gnus-sethash group group gnus-killed-hashtb)
14713 (funcall gnus-subscribe-options-newsgroup-method group))
14714 ((eq do-sub 'ignore)
14718 (gnus-sethash group group gnus-killed-hashtb)
14719 (if gnus-subscribe-hierarchical-interactive
14720 (push group new-newsgroups)
14721 (funcall gnus-subscribe-newsgroup-method group)))))))
14723 (when new-newsgroups
14724 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
14725 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14727 (gnus-message 6 "%d new newsgroup%s arrived."
14728 groups (if (> groups 1) "s have" " has")))
14729 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14732 (defun gnus-check-first-time-used ()
14733 (if (or (> (length gnus-newsrc-alist) 1)
14734 (file-exists-p gnus-startup-file)
14735 (file-exists-p (concat gnus-startup-file ".el"))
14736 (file-exists-p (concat gnus-startup-file ".eld")))
14738 (gnus-message 6 "First time user; subscribing you to default groups")
14739 (or gnus-have-read-active-file (gnus-read-active-file))
14740 (setq gnus-newsrc-last-checked-date (current-time-string))
14741 (let ((groups gnus-default-subscribed-newsgroups)
14745 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
14748 (if (null (setq group (symbol-name sym)))
14750 (let ((do-sub (gnus-matches-options-n group)))
14752 ((eq do-sub 'subscribe)
14753 (gnus-sethash group group gnus-killed-hashtb)
14754 (funcall gnus-subscribe-options-newsgroup-method group))
14755 ((eq do-sub 'ignore)
14758 (setq gnus-killed-list (cons group gnus-killed-list)))))))
14759 gnus-active-hashtb)
14761 (if (gnus-active (car groups))
14762 (gnus-group-change-level
14763 (car groups) gnus-level-default-subscribed gnus-level-killed))
14764 (setq groups (cdr groups)))
14765 (gnus-group-make-help-group)
14766 (and gnus-novice-user
14767 (gnus-message 7 "`A k' to list killed groups"))))))
14769 (defun gnus-subscribe-group (group previous &optional method)
14770 (gnus-group-change-level
14772 (list t group gnus-level-default-subscribed nil nil method)
14774 gnus-level-default-subscribed gnus-level-killed previous t))
14776 ;; `gnus-group-change-level' is the fundamental function for changing
14777 ;; subscription levels of newsgroups. This might mean just changing
14778 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
14779 ;; again, which subscribes/unsubscribes a group, which is equally
14780 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
14781 ;; from 8-9 to 1-7 means that you remove the group from the list of
14782 ;; killed (or zombie) groups and add them to the (kinda) subscribed
14783 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
14784 ;; which is trivial.
14785 ;; ENTRY can either be a string (newsgroup name) or a list (if
14786 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
14787 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
14789 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
14790 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
14792 (defun gnus-group-change-level (entry level &optional oldlevel
14793 previous fromkilled)
14794 (let (group info active num)
14795 ;; Glean what info we can from the arguments
14797 (if fromkilled (setq group (nth 1 entry))
14798 (setq group (car (nth 2 entry))))
14799 (setq group entry))
14800 (if (and (stringp entry)
14802 (< oldlevel gnus-level-zombie))
14803 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
14804 (if (and (not oldlevel)
14806 (setq oldlevel (car (cdr (nth 2 entry)))))
14807 (if (stringp previous)
14808 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
14810 (if (and (>= oldlevel gnus-level-zombie)
14811 (gnus-gethash group gnus-newsrc-hashtb))
14812 ;; We are trying to subscribe a group that is already
14816 (or (gnus-ephemeral-group-p group)
14817 (gnus-dribble-enter
14818 (format "(gnus-group-change-level %S %S %S %S %S)"
14819 group level oldlevel (car (nth 2 previous)) fromkilled)))
14821 ;; Then we remove the newgroup from any old structures, if needed.
14822 ;; If the group was killed, we remove it from the killed or zombie
14823 ;; list. If not, and it is in fact going to be killed, we remove
14824 ;; it from the newsrc hash table and assoc.
14825 (cond ((>= oldlevel gnus-level-zombie)
14826 (if (= oldlevel gnus-level-zombie)
14827 (setq gnus-zombie-list (delete group gnus-zombie-list))
14828 (setq gnus-killed-list (delete group gnus-killed-list))))
14830 (if (and (>= level gnus-level-zombie)
14833 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
14835 (setcdr (gnus-gethash (car (nth 3 entry))
14836 gnus-newsrc-hashtb)
14838 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
14840 ;; Finally we enter (if needed) the list where it is supposed to
14841 ;; go, and change the subscription level. If it is to be killed,
14842 ;; we enter it into the killed or zombie list.
14843 (cond ((>= level gnus-level-zombie)
14844 ;; Remove from the hash table.
14845 (gnus-sethash group nil gnus-newsrc-hashtb)
14846 ;; We do not enter foreign groups into the list of dead
14848 (unless (gnus-group-foreign-p group)
14849 (if (= level gnus-level-zombie)
14850 (setq gnus-zombie-list (cons group gnus-zombie-list))
14851 (setq gnus-killed-list (cons group gnus-killed-list)))))
14853 ;; If the list is to be entered into the newsrc assoc, and
14854 ;; it was killed, we have to create an entry in the newsrc
14855 ;; hashtb format and fix the pointers in the newsrc assoc.
14856 (if (>= oldlevel gnus-level-zombie)
14860 (setq info (cdr entry))
14861 (setq num (car entry)))
14862 (setq active (gnus-active group))
14864 (if active (- (1+ (cdr active)) (car active)) t))
14865 ;; Check whether the group is foreign. If so, the
14866 ;; foreign select method has to be entered into the
14868 (let ((method (or gnus-override-subscribe-method
14869 (gnus-group-method-name group))))
14870 (if (eq method gnus-select-method)
14871 (setq info (list group level nil))
14872 (setq info (list group level nil nil method)))))
14875 (let ((p gnus-newsrc-alist))
14876 (while (cdr (cdr p))
14879 (setq entry (cons info (cdr (cdr previous))))
14882 (setcdr (cdr previous) entry)
14883 (gnus-sethash group (cons num (cdr previous))
14884 gnus-newsrc-hashtb))
14885 (setcdr previous entry)
14886 (gnus-sethash group (cons num previous)
14887 gnus-newsrc-hashtb))
14889 (setcdr (gnus-gethash (car (car (cdr entry)))
14890 gnus-newsrc-hashtb)
14892 ;; It was alive, and it is going to stay alive, so we
14893 ;; just change the level and don't change any pointers or
14894 ;; hash table entries.
14895 (setcar (cdr (car (cdr (cdr entry)))) level))))
14896 (when gnus-group-change-level-function
14897 (funcall gnus-group-change-level-function group level oldlevel)))))
14899 (defun gnus-kill-newsgroup (newsgroup)
14900 "Obsolete function. Kills a newsgroup."
14901 (gnus-group-change-level
14902 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
14904 (defun gnus-check-bogus-newsgroups (&optional confirm)
14905 "Remove bogus newsgroups.
14906 If CONFIRM is non-nil, the user has to confirm the deletion of every
14908 (let ((newsrc (cdr gnus-newsrc-alist))
14909 bogus group entry info)
14910 (gnus-message 5 "Checking bogus newsgroups...")
14911 (unless gnus-have-read-active-file
14912 (gnus-read-active-file))
14913 (when (member gnus-select-method gnus-have-read-active-file)
14914 ;; Find all bogus newsgroup that are subscribed.
14916 (setq info (pop newsrc)
14917 group (gnus-info-group info))
14918 (unless (or (gnus-active group) ; Active
14919 (gnus-info-method info) ; Foreign
14921 (not (gnus-y-or-n-p
14922 (format "Remove bogus newsgroup: %s " group)))))
14923 ;; Found a bogus newsgroup.
14924 (push group bogus)))
14925 ;; Remove all bogus subscribed groups by first killing them, and
14926 ;; then removing them from the list of killed groups.
14928 (when (setq entry (gnus-gethash (setq group (pop bogus))
14929 gnus-newsrc-hashtb))
14930 (gnus-group-change-level entry gnus-level-killed)
14931 (setq gnus-killed-list (delete group gnus-killed-list))))
14932 ;; Then we remove all bogus groups from the list of killed and
14933 ;; zombie groups. They are are removed without confirmation.
14934 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
14937 (setq killed (symbol-value (car dead-lists)))
14939 (unless (gnus-active (setq group (pop killed)))
14940 ;; The group is bogus.
14941 ;; !!!Slow as hell.
14942 (set (car dead-lists)
14943 (delete group (symbol-value (car dead-lists))))))
14944 (setq dead-lists (cdr dead-lists))))
14945 (gnus-message 5 "Checking bogus newsgroups...done"))))
14947 (defun gnus-check-duplicate-killed-groups ()
14948 "Remove duplicates from the list of killed groups."
14950 (let ((killed gnus-killed-list))
14952 (gnus-message 9 "%d" (length killed))
14953 (setcdr killed (delete (car killed) (cdr killed)))
14954 (setq killed (cdr killed)))))
14956 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
14957 ;; and compute how many unread articles there are in each group.
14958 (defun gnus-get-unread-articles (&optional level)
14959 (let* ((newsrc (cdr gnus-newsrc-alist))
14960 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
14963 (cond ((and gnus-activate-foreign-newsgroups
14964 (not (numberp gnus-activate-foreign-newsgroups)))
14965 (1+ gnus-level-subscribed))
14966 ((numberp gnus-activate-foreign-newsgroups)
14967 gnus-activate-foreign-newsgroups)
14970 info group active virtuals method fmethod)
14971 (gnus-message 5 "Checking new news...")
14974 (setq info (car newsrc)
14975 group (gnus-info-group info)
14976 active (gnus-active group))
14978 ;; Check newsgroups. If the user doesn't want to check them, or
14979 ;; they can't be checked (for instance, if the news server can't
14980 ;; be reached) we just set the number of unread articles in this
14981 ;; newsgroup to t. This means that Gnus thinks that there are
14982 ;; unread articles, but it has no idea how many.
14983 (if (and (setq method (gnus-info-method info))
14984 (not (gnus-server-equal
14986 (setq fmethod (gnus-server-get-method nil method))))
14987 (not (gnus-secondary-method-p method)))
14988 ;; These groups are foreign. Check the level.
14989 (if (<= (gnus-info-level info) foreign-level)
14990 (setq active (gnus-activate-group (gnus-info-group info) 'scan)))
14992 ;; These groups are native or secondary.
14993 (if (<= (gnus-info-level info) level)
14994 (or gnus-read-active-file
14995 (setq active (gnus-activate-group
14996 (gnus-info-group info) 'scan)))))
14999 (gnus-get-unread-articles-in-group info active t)
15000 ;; The group couldn't be reached, so we nix out the number of
15001 ;; unread articles and stuff.
15002 (gnus-set-active group nil)
15003 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
15005 (setq newsrc (cdr newsrc)))
15007 (gnus-message 5 "Checking new news...done")))
15009 ;; Create a hash table out of the newsrc alist. The `car's of the
15010 ;; alist elements are used as keys.
15011 (defun gnus-make-hashtable-from-newsrc-alist ()
15012 (let ((alist gnus-newsrc-alist)
15013 (ohashtb gnus-newsrc-hashtb)
15015 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15017 (setq prev (setq gnus-newsrc-alist
15018 (if (equal (car (car gnus-newsrc-alist))
15021 (cons (list "dummy.group" 0 nil) alist)))))
15025 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
15027 gnus-newsrc-hashtb)
15029 alist (cdr alist)))))
15031 (defun gnus-make-hashtable-from-killed ()
15032 "Create a hash table from the killed and zombie lists."
15033 (let ((lists '(gnus-killed-list gnus-zombie-list))
15035 (setq gnus-killed-hashtb
15036 (gnus-make-hashtable
15037 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15039 (setq list (symbol-value (car lists)))
15040 (setq lists (cdr lists))
15042 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15043 (setq list (cdr list))))))
15045 (defun gnus-get-unread-articles-in-group (info active &optional update)
15046 ;; Allow the backend to update the info in the group.
15048 (gnus-request-update-info
15049 info (gnus-find-method-for-group (gnus-info-group info))))
15050 (let* ((range (gnus-info-read info))
15052 (marked (gnus-info-marks info)))
15053 ;; If a cache is present, we may have to alter the active info.
15054 (and gnus-use-cache
15055 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15056 ;; Modify the list of read articles according to what articles
15057 ;; are available; then tally the unread articles and add the
15058 ;; number to the group hash table entry.
15060 ((zerop (cdr active))
15063 (setq num (- (1+ (cdr active)) (car active))))
15064 ((not (listp (cdr range)))
15065 ;; Fix a single (num . num) range according to the
15066 ;; active hash table.
15067 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15068 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15069 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15070 ;; Compute number of unread articles.
15071 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15073 ;; The read list is a list of ranges. Fix them according to
15074 ;; the active hash table.
15075 ;; First peel off any elements that are below the lower
15077 (while (and (cdr range)
15079 (or (and (atom (car (cdr range))) (car (cdr range)))
15080 (car (car (cdr range))))))
15081 (if (numberp (car range))
15084 (or (and (numberp (car (cdr range)))
15086 (cdr (car (cdr range))))))
15087 (setcdr (car range)
15088 (or (and (numberp (nth 1 range)) (nth 1 range))
15089 (cdr (car (cdr range))))))
15090 (setcdr range (cdr (cdr range))))
15091 ;; Adjust the first element to be the same as the lower limit.
15092 (if (and (not (atom (car range)))
15093 (< (cdr (car range)) (car active)))
15094 (setcdr (car range) (1- (car active))))
15095 ;; Then we want to peel off any elements that are higher
15096 ;; than the upper active limit.
15097 (let ((srange range))
15098 ;; Go past all legal elements.
15099 (while (and (cdr srange)
15100 (<= (or (and (atom (car (cdr srange)))
15101 (car (cdr srange)))
15102 (car (car (cdr srange)))) (cdr active)))
15103 (setq srange (cdr srange)))
15105 ;; Nuke all remaining illegal elements.
15106 (setcdr srange nil))
15108 ;; Adjust the final element.
15109 (if (and (not (atom (car srange)))
15110 (> (cdr (car srange)) (cdr active)))
15111 (setcdr (car srange) (cdr active))))
15112 ;; Compute the number of unread articles.
15114 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15115 (cdr (car range))))
15116 (or (and (atom (car range)) (car range))
15117 (car (car range))))))
15118 (setq range (cdr range)))
15119 (setq num (max 0 (- (cdr active) num)))))
15120 ;; Set the number of unread articles.
15121 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
15124 (defun gnus-activate-group (group &optional scan)
15125 ;; Check whether a group has been activated or not.
15126 ;; If SCAN, request a scan of that group as well.
15127 (let ((method (gnus-find-method-for-group group))
15129 (and (gnus-check-server method)
15130 ;; We escape all bugs and quit here to make it possible to
15131 ;; continue if a group is so out-there that it reports bugs
15135 (gnus-check-backend-function 'request-scan (car method))
15136 (gnus-request-scan group method))
15139 (gnus-request-group group)
15143 (set-buffer nntp-server-buffer)
15144 (goto-char (point-min))
15145 ;; Parse the result we got from `gnus-request-group'.
15146 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15148 (goto-char (match-beginning 1))
15150 group (setq active (cons (read (current-buffer))
15151 (read (current-buffer)))))
15152 ;; Return the new active info.
15155 (defun gnus-update-read-articles (group unread)
15156 "Update the list of read and ticked articles in GROUP using the
15157 UNREAD and TICKED lists.
15158 Note: UNSELECTED has to be sorted over `<'.
15159 Returns whether the updating was successful."
15160 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15161 (entry (gnus-gethash group gnus-newsrc-hashtb))
15162 (info (nth 2 entry))
15163 (marked (gnus-info-marks info))
15165 (unread (sort (copy-sequence unread) '<))
15167 (if (or (not info) (not active))
15168 ;; There is no info on this group if it was, in fact,
15169 ;; killed. Gnus stores no information on killed groups, so
15170 ;; there's nothing to be done.
15171 ;; One could store the information somewhere temporarily,
15172 ;; perhaps... Hmmm...
15174 ;; Remove any negative articles numbers.
15175 (while (and unread (< (car unread) 0))
15176 (setq unread (cdr unread)))
15177 ;; Remove any expired article numbers
15178 (while (and unread (< (car unread) (car active)))
15179 (setq unread (cdr unread)))
15180 ;; Compute the ranges of read articles by looking at the list of
15181 ;; unread articles.
15183 (if (/= (car unread) prev)
15184 (setq read (cons (if (= prev (1- (car unread))) prev
15185 (cons prev (1- (car unread)))) read)))
15186 (setq prev (1+ (car unread)))
15187 (setq unread (cdr unread)))
15188 (when (<= prev (cdr active))
15189 (setq read (cons (cons prev (cdr active)) read)))
15190 ;; Enter this list into the group info.
15191 (gnus-info-set-read
15192 info (if (> (length read) 1) (nreverse read) read))
15193 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15194 (gnus-get-unread-articles-in-group info (gnus-active group))
15197 (defun gnus-make-articles-unread (group articles)
15198 "Mark ARTICLES in GROUP as unread."
15199 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15200 (gnus-gethash (gnus-group-real-name group)
15201 gnus-newsrc-hashtb))))
15202 (ranges (gnus-info-read info))
15205 (when (gnus-member-of-range
15206 (setq article (pop articles)) ranges)
15207 (setq news (cons article news))))
15209 (gnus-info-set-read
15210 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15211 (gnus-group-update-group group t))))
15213 ;; Enter all dead groups into the hashtb.
15214 (defun gnus-update-active-hashtb-from-killed ()
15215 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15216 (lists (list gnus-killed-list gnus-zombie-list))
15219 (setq killed (car lists))
15221 (gnus-sethash (car killed) nil hashtb)
15222 (setq killed (cdr killed)))
15223 (setq lists (cdr lists)))))
15225 ;; Get the active file(s) from the backend(s).
15226 (defun gnus-read-active-file ()
15227 (gnus-group-set-mode-line)
15228 (let ((methods (nconc (copy-sequence
15229 (if (gnus-check-server gnus-select-method)
15230 ;; The native server is available.
15231 (cons gnus-select-method
15232 gnus-secondary-select-methods)
15233 ;; The native server is down, so we just do the
15235 gnus-secondary-select-methods))
15236 (list gnus-message-archive-method)))
15238 (setq gnus-have-read-active-file nil)
15240 (set-buffer nntp-server-buffer)
15242 (let* ((method (gnus-server-get-method nil (car methods)))
15243 (where (nth 1 method))
15244 (mesg (format "Reading active file%s via %s..."
15245 (if (and where (not (zerop (length where))))
15246 (concat " from " where) "")
15248 (gnus-message 5 mesg)
15249 (if (not (gnus-check-server method))
15251 ;; Request that the backend scan its incoming messages.
15252 (and (gnus-check-backend-function 'request-scan (car method))
15253 (gnus-request-scan nil method))
15255 ((and (eq gnus-read-active-file 'some)
15256 (gnus-check-backend-function 'retrieve-groups (car method)))
15257 (let ((newsrc (cdr gnus-newsrc-alist))
15258 (gmethod (gnus-server-get-method nil method))
15261 (and (gnus-server-equal
15262 (gnus-find-method-for-group
15263 (car (car newsrc)) (car newsrc))
15265 (setq groups (cons (gnus-group-real-name
15266 (car (car newsrc))) groups)))
15267 (setq newsrc (cdr newsrc)))
15268 (gnus-check-server method)
15269 (setq list-type (gnus-retrieve-groups groups method))
15273 1 "Cannot read partial active file from %s server."
15277 ((eq list-type 'active)
15278 (gnus-active-to-gnus-format method gnus-active-hashtb))
15280 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
15282 (if (not (gnus-request-list method))
15284 (unless (equal method gnus-message-archive-method)
15285 (gnus-message 1 "Cannot read active file from %s server."
15288 (gnus-active-to-gnus-format method)
15289 ;; We mark this active file as read.
15290 (setq gnus-have-read-active-file
15291 (cons method gnus-have-read-active-file))
15292 (gnus-message 5 "%sdone" mesg))))))
15293 (setq methods (cdr methods))))))
15295 ;; Read an active file and place the results in `gnus-active-hashtb'.
15296 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15298 (setq method gnus-select-method))
15299 (let ((cur (current-buffer))
15301 (if (and gnus-active-hashtb
15302 (not (equal method gnus-select-method)))
15304 (setq gnus-active-hashtb
15305 (if (equal method gnus-select-method)
15306 (gnus-make-hashtable
15307 (count-lines (point-min) (point-max)))
15308 (gnus-make-hashtable 4096))))))
15309 (flag-hashtb (gnus-make-hashtable 60)))
15310 ;; Delete unnecessary lines.
15311 (goto-char (point-min))
15312 (while (search-forward "\nto." nil t)
15313 (delete-region (1+ (match-beginning 0))
15314 (progn (forward-line 1) (point))))
15315 (or (string= gnus-ignored-newsgroups "")
15317 (goto-char (point-min))
15318 (delete-matching-lines gnus-ignored-newsgroups)))
15319 ;; Make the group names readable as a lisp expression even if they
15320 ;; contain special characters.
15321 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15322 (goto-char (point-max))
15323 (while (re-search-backward "[][';?()#]" nil t)
15325 ;; If these are groups from a foreign select method, we insert the
15326 ;; group prefix in front of the group names.
15327 (and method (not (gnus-server-equal
15328 (gnus-server-get-method nil method)
15329 (gnus-server-get-method nil gnus-select-method)))
15330 (let ((prefix (gnus-group-prefixed-name "" method)))
15331 (goto-char (point-min))
15332 (while (and (not (eobp))
15333 (progn (insert prefix)
15334 (zerop (forward-line 1)))))))
15335 ;; Store the active file in a hash table.
15336 (goto-char (point-min))
15337 (if (string-match "%[oO]" gnus-group-line-format)
15338 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15339 ;; If we want information on moderated groups, we use this
15341 (let* ((mod-hashtb (make-vector 7 0))
15342 (m (intern "m" mod-hashtb))
15344 (while (not (eobp))
15345 (condition-case nil
15347 (narrow-to-region (point) (gnus-point-at-eol))
15348 (setq group (let ((obarray hashtb)) (read cur)))
15349 (if (and (numberp (setq max (read cur)))
15350 (numberp (setq min (read cur)))
15352 (skip-chars-forward " \t")
15354 (or (= (following-char) ?=)
15355 (= (following-char) ?x)
15356 (= (following-char) ?j)))))
15357 (set group (cons min max))
15359 ;; Enter moderated groups into a list.
15360 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15361 (setq gnus-moderated-list
15362 (cons (symbol-name group) gnus-moderated-list))))
15369 ;; And if we do not care about moderation, we use this loop,
15370 ;; which is faster.
15371 (let (group max min)
15372 (while (not (eobp))
15375 (narrow-to-region (point) (gnus-point-at-eol))
15376 ;; group gets set to a symbol interned in the hash table
15377 ;; (what a hack!!) - jwz
15378 (setq group (let ((obarray hashtb)) (read cur)))
15379 (if (and (numberp (setq max (read cur)))
15380 (numberp (setq min (read cur)))
15382 (skip-chars-forward " \t")
15384 (or (= (following-char) ?=)
15385 (= (following-char) ?x)
15386 (= (following-char) ?j)))))
15387 (set group (cons min max))
15395 (gnus-message 3 "Warning - illegal active: %s"
15397 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15399 (forward-line 1))))))
15401 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15402 ;; Parse a "groups" active file.
15403 (let ((cur (current-buffer))
15405 (if (and method gnus-active-hashtb)
15407 (setq gnus-active-hashtb
15408 (gnus-make-hashtable
15409 (count-lines (point-min) (point-max)))))))
15410 (prefix (and method
15411 (not (gnus-server-equal
15412 (gnus-server-get-method nil method)
15413 (gnus-server-get-method nil gnus-select-method)))
15414 (gnus-group-prefixed-name "" method))))
15416 (goto-char (point-min))
15417 ;; We split this into to separate loops, one with the prefix
15418 ;; and one without to speed the reading up somewhat.
15420 (let (min max opoint group)
15421 (while (not (eobp))
15424 (read cur) (read cur)
15425 (setq min (read cur)
15428 (skip-chars-forward " \t")
15431 (set (let ((obarray hashtb)) (read cur))
15433 (error (and group (symbolp group) (set group nil))))
15435 (let (min max group)
15436 (while (not (eobp))
15438 (if (= (following-char) ?2)
15440 (read cur) (read cur)
15441 (setq min (read cur)
15443 (set (setq group (let ((obarray hashtb)) (read cur)))
15445 (error (and group (symbolp group) (set group nil))))
15446 (forward-line 1))))))
15448 (defun gnus-read-newsrc-file (&optional force)
15449 "Read startup file.
15450 If FORCE is non-nil, the .newsrc file is read."
15451 ;; Reset variables that might be defined in the .newsrc.eld file.
15452 (let ((variables gnus-variable-list))
15454 (set (car variables) nil)
15455 (setq variables (cdr variables))))
15456 (let* ((newsrc-file gnus-current-startup-file)
15457 (quick-file (concat newsrc-file ".el")))
15459 ;; We always load the .newsrc.eld file. If always contains
15460 ;; much information that can not be gotten from the .newsrc
15461 ;; file (ticked articles, killed groups, foreign methods, etc.)
15462 (gnus-read-newsrc-el-file quick-file)
15465 (and (file-newer-than-file-p newsrc-file quick-file)
15466 (file-newer-than-file-p newsrc-file
15467 (concat quick-file "d")))
15468 (not gnus-newsrc-alist))
15469 ;; We read the .newsrc file. Note that if there if a
15470 ;; .newsrc.eld file exists, it has already been read, and
15471 ;; the `gnus-newsrc-hashtb' has been created. While reading
15472 ;; the .newsrc file, Gnus will only use the information it
15473 ;; can find there for changing the data already read -
15474 ;; ie. reading the .newsrc file will not trash the data
15475 ;; already read (except for read articles).
15477 (gnus-message 5 "Reading %s..." newsrc-file)
15478 (set-buffer (find-file-noselect newsrc-file))
15479 (buffer-disable-undo (current-buffer))
15480 (gnus-newsrc-to-gnus-format)
15481 (kill-buffer (current-buffer))
15482 (gnus-message 5 "Reading %s...done" newsrc-file)))
15484 ;; Read any slave files.
15486 (gnus-master-read-slave-newsrc)))))
15488 (defun gnus-read-newsrc-el-file (file)
15489 (let ((ding-file (concat file "d")))
15490 ;; We always, always read the .eld file.
15491 (gnus-message 5 "Reading %s..." ding-file)
15492 (let (gnus-newsrc-assoc)
15493 (condition-case nil
15494 (load ding-file t t t)
15496 (gnus-message 1 "Error in %s" ding-file)
15498 (when gnus-newsrc-assoc
15499 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15500 (gnus-make-hashtable-from-newsrc-alist)
15501 (when (file-newer-than-file-p file ding-file)
15502 ;; Old format quick file
15503 (gnus-message 5 "Reading %s..." file)
15504 ;; The .el file is newer than the .eld file, so we read that one
15506 (gnus-read-old-newsrc-el-file file))))
15508 ;; Parse the old-style quick startup file
15509 (defun gnus-read-old-newsrc-el-file (file)
15510 (let (newsrc killed marked group m)
15512 (let ((gnus-killed-assoc nil)
15513 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15515 (condition-case nil
15518 (setq newsrc gnus-newsrc-assoc
15519 killed gnus-killed-assoc
15520 marked gnus-marked-assoc)))
15521 (setq gnus-newsrc-alist nil)
15523 (setq group (car newsrc))
15524 (let ((info (gnus-get-info (car group))))
15527 (gnus-info-set-read info (cdr (cdr group)))
15528 (gnus-info-set-level
15529 info (if (nth 1 group) gnus-level-default-subscribed
15530 gnus-level-default-unsubscribed))
15531 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15532 (setq gnus-newsrc-alist
15536 (if (nth 1 group) gnus-level-default-subscribed
15537 gnus-level-default-unsubscribed)
15538 (cdr (cdr group))))
15539 gnus-newsrc-alist)))
15540 (if (setq m (assoc (car group) marked))
15541 (gnus-info-set-marks
15542 info (cons (list (cons 'tick (gnus-compress-sequence
15543 (sort (cdr m) '<) t)))
15545 (setq newsrc (cdr newsrc)))
15546 (setq newsrc killed)
15548 (setcar newsrc (car (car newsrc)))
15549 (setq newsrc (cdr newsrc)))
15550 (setq gnus-killed-list killed))
15551 ;; The .el file version of this variable does not begin with
15552 ;; "options", while the .eld version does, so we just add it if it
15555 gnus-newsrc-options
15557 (and (not (string-match "^ *options" gnus-newsrc-options))
15558 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15559 (and (not (string-match "\n$" gnus-newsrc-options))
15560 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15561 ;; Finally, if we read some options lines, we parse them.
15562 (or (string= gnus-newsrc-options "")
15563 (gnus-newsrc-parse-options gnus-newsrc-options))))
15565 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15566 (gnus-make-hashtable-from-newsrc-alist)))
15568 (defun gnus-make-newsrc-file (file)
15569 "Make server dependent file name by catenating FILE and server host name."
15570 (let* ((file (expand-file-name file nil))
15571 (real-file (concat file "-" (nth 1 gnus-select-method))))
15572 (if (or (file-exists-p real-file)
15573 (file-exists-p (concat real-file ".el"))
15574 (file-exists-p (concat real-file ".eld")))
15577 (defun gnus-newsrc-to-gnus-format ()
15578 (setq gnus-newsrc-options "")
15579 (setq gnus-newsrc-options-n nil)
15581 (or gnus-active-hashtb
15582 (setq gnus-active-hashtb (make-vector 4095 0)))
15583 (let ((buf (current-buffer))
15584 (already-read (> (length gnus-newsrc-alist) 1))
15585 group subscribed options-symbol newsrc Options-symbol
15587 (goto-char (point-min))
15588 ;; We intern the symbol `options' in the active hashtb so that we
15589 ;; can `eq' against it later.
15590 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15591 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15593 (while (not (eobp))
15594 ;; We first read the first word on the line by narrowing and
15595 ;; then reading into `gnus-active-hashtb'. Most groups will
15596 ;; already exist in that hashtb, so this will save some string
15600 (progn (skip-chars-forward "^ \t!:\n") (point)))
15601 (goto-char (point-min))
15603 (and (/= (point-min) (point-max))
15604 (let ((obarray gnus-active-hashtb)) (read buf))))
15606 ;; Now, the symbol we have read is either `options' or a group
15607 ;; name. If it is an options line, we just add it to a string.
15609 ((or (eq symbol options-symbol)
15610 (eq symbol Options-symbol))
15611 (setq gnus-newsrc-options
15612 ;; This concating is quite inefficient, but since our
15613 ;; thorough studies show that approx 99.37% of all
15614 ;; .newsrc files only contain a single options line, we
15615 ;; don't give a damn, frankly, my dear.
15616 (concat gnus-newsrc-options
15618 (gnus-point-at-bol)
15619 ;; Options may continue on the next line.
15620 (or (and (re-search-forward "^[^ \t]" nil 'move)
15621 (progn (beginning-of-line) (point)))
15625 ;; Group names can be just numbers.
15626 (when (numberp symbol)
15627 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15628 (or (boundp symbol) (set symbol nil))
15629 ;; It was a group name.
15630 (setq subscribed (= (following-char) ?:)
15631 group (symbol-name symbol)
15634 ;; If the line ends here, this is clearly a buggy line, so
15635 ;; we put point a the beginning of line and let the cond
15636 ;; below do the error handling.
15637 (beginning-of-line)
15638 ;; We skip to the beginning of the ranges.
15639 (skip-chars-forward "!: \t"))
15640 ;; We are now at the beginning of the list of read articles.
15641 ;; We read them range by range.
15644 ((looking-at "[0-9]+")
15645 ;; We narrow and read a number instead of buffer-substring/
15646 ;; string-to-int because it's faster. narrow/widen is
15647 ;; faster than save-restriction/narrow, and save-restriction
15648 ;; produces a garbage object.
15650 (narrow-to-region (match-beginning 0) (match-end 0))
15653 ;; If the next character is a dash, then this is a range.
15654 (if (= (following-char) ?-)
15656 ;; We read the upper bound of the range.
15658 (if (not (looking-at "[0-9]+"))
15659 ;; This is a buggy line, by we pretend that
15660 ;; it's kinda OK. Perhaps the user should be
15662 (setq reads (cons num1 reads))
15667 (narrow-to-region (match-beginning 0)
15672 ;; It was just a simple number, so we add it to the
15674 (setq reads (cons num1 reads)))
15675 ;; If the next char in ?\n, then we have reached the end
15676 ;; of the line and return nil.
15677 (/= (following-char) ?\n))
15678 ((= (following-char) ?\n)
15679 ;; End of line, so we end.
15682 ;; Not numbers and not eol, so this might be a buggy
15685 ;; If it was eob instead of ?\n, we allow it.
15687 ;; The line was buggy.
15689 (gnus-message 3 "Mangled line: %s"
15690 (buffer-substring (gnus-point-at-bol)
15691 (gnus-point-at-eol)))
15695 ;; Skip past ", ". Spaces are illegal in these ranges, but
15696 ;; we allow them, because it's a common mistake to put a
15697 ;; space after the comma.
15698 (skip-chars-forward ", "))
15700 ;; We have already read .newsrc.eld, so we gently update the
15701 ;; data in the hash table with the information we have just
15704 (let ((info (gnus-get-info group))
15707 ;; There is an entry for this file in the alist.
15709 (gnus-info-set-read info (nreverse reads))
15710 ;; We update the level very gently. In fact, we
15711 ;; only change it if there's been a status change
15712 ;; from subscribed to unsubscribed, or vice versa.
15713 (setq level (gnus-info-level info))
15714 (cond ((and (<= level gnus-level-subscribed)
15716 (setq level (if reads
15717 gnus-level-default-unsubscribed
15718 (1+ gnus-level-default-unsubscribed))))
15719 ((and (> level gnus-level-subscribed) subscribed)
15720 (setq level gnus-level-default-subscribed)))
15721 (gnus-info-set-level info level))
15722 ;; This is a new group.
15723 (setq info (list group
15725 gnus-level-default-subscribed
15727 (1+ gnus-level-subscribed)
15728 gnus-level-default-unsubscribed))
15729 (nreverse reads))))
15730 (setq newsrc (cons info newsrc))))))
15733 (setq newsrc (nreverse newsrc))
15735 (if (not already-read)
15737 ;; We now have two newsrc lists - `newsrc', which is what we
15738 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
15739 ;; what we've read from .newsrc.eld. We have to merge these
15740 ;; lists. We do this by "attaching" any (foreign) groups in the
15741 ;; gnus-newsrc-alist to the (native) group that precedes them.
15742 (let ((rc (cdr gnus-newsrc-alist))
15743 (prev gnus-newsrc-alist)
15746 (or (null (nth 4 (car rc))) ; It's a native group.
15747 (assoc (car (car rc)) newsrc) ; It's already in the alist.
15748 (if (setq entry (assoc (car (car prev)) newsrc))
15749 (setcdr (setq mentry (memq entry newsrc))
15750 (cons (car rc) (cdr mentry)))
15751 (setq newsrc (cons (car rc) newsrc))))
15755 (setq gnus-newsrc-alist newsrc)
15756 ;; We make the newsrc hashtb.
15757 (gnus-make-hashtable-from-newsrc-alist)
15759 ;; Finally, if we read some options lines, we parse them.
15760 (or (string= gnus-newsrc-options "")
15761 (gnus-newsrc-parse-options gnus-newsrc-options))))
15763 ;; Parse options lines to find "options -n !all rec.all" and stuff.
15764 ;; The return value will be a list on the form
15765 ;; ((regexp1 . ignore)
15766 ;; (regexp2 . subscribe)...)
15767 ;; When handling new newsgroups, groups that match a `ignore' regexp
15768 ;; will be ignored, and groups that match a `subscribe' regexp will be
15769 ;; subscribed. A line like
15770 ;; options -n !all rec.all
15771 ;; will lead to a list that looks like
15772 ;; (("^rec\\..+" . subscribe)
15773 ;; ("^.+" . ignore))
15774 ;; So all "rec.*" groups will be subscribed, while all the other
15775 ;; groups will be ignored. Note that "options -n !all rec.all" is very
15776 ;; different from "options -n rec.all !all".
15777 (defun gnus-newsrc-parse-options (options)
15780 (gnus-set-work-buffer)
15781 (insert (regexp-quote options))
15782 ;; First we treat all continuation lines.
15783 (goto-char (point-min))
15784 (while (re-search-forward "\n[ \t]+" nil t)
15785 (replace-match " " t t))
15786 ;; Then we transform all "all"s into ".+"s.
15787 (goto-char (point-min))
15788 (while (re-search-forward "\\ball\\b" nil t)
15789 (replace-match ".+" t t))
15790 (goto-char (point-min))
15791 ;; We remove all other options than the "-n" ones.
15792 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
15793 (replace-match " ")
15795 (goto-char (point-min))
15797 ;; We are only interested in "options -n" lines - we
15798 ;; ignore the other option lines.
15799 (while (re-search-forward "[ \t]-n" nil t)
15801 (or (save-excursion
15802 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
15804 (gnus-point-at-eol)))
15805 ;; Search for all "words"...
15806 (while (re-search-forward "[^ \t,\n]+" eol t)
15807 (if (= (char-after (match-beginning 0)) ?!)
15808 ;; If the word begins with a bang (!), this is a "not"
15809 ;; spec. We put this spec (minus the bang) and the
15810 ;; symbol `ignore' into the list.
15811 (setq out (cons (cons (concat
15812 "^" (buffer-substring
15813 (1+ (match-beginning 0))
15816 ;; There was no bang, so this is a "yes" spec.
15817 (setq out (cons (cons (concat "^" (match-string 0))
15818 'subscribe) out)))))
15820 (setq gnus-newsrc-options-n out))))
15822 (defun gnus-save-newsrc-file (&optional force)
15823 "Save .newsrc file."
15824 ;; Note: We cannot save .newsrc file if all newsgroups are removed
15825 ;; from the variable gnus-newsrc-alist.
15826 (when (and (or gnus-newsrc-alist gnus-killed-list)
15827 gnus-current-startup-file)
15829 (if (and (or gnus-use-dribble-file gnus-slave)
15831 (or (not gnus-dribble-buffer)
15832 (not (buffer-name gnus-dribble-buffer))
15833 (zerop (save-excursion
15834 (set-buffer gnus-dribble-buffer)
15836 (gnus-message 4 "(No changes need to be saved)")
15837 (run-hooks 'gnus-save-newsrc-hook)
15839 (gnus-slave-save-newsrc)
15841 (when gnus-save-newsrc-file
15842 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
15843 (gnus-gnus-to-newsrc-format)
15844 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
15845 ;; Save .newsrc.eld.
15846 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
15847 (make-local-variable 'version-control)
15848 (setq version-control 'never)
15849 (setq buffer-file-name
15850 (concat gnus-current-startup-file ".eld"))
15851 (gnus-add-current-to-buffer-list)
15852 (buffer-disable-undo (current-buffer))
15854 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
15855 (gnus-gnus-to-quick-newsrc-format)
15856 (run-hooks 'gnus-save-quick-newsrc-hook)
15858 (kill-buffer (current-buffer))
15860 5 "Saving %s.eld...done" gnus-current-startup-file))
15861 (gnus-dribble-delete-file)))))
15863 (defun gnus-gnus-to-quick-newsrc-format ()
15864 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
15865 (insert ";; Gnus startup file.\n")
15866 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
15867 (insert ";; to read .newsrc.\n")
15868 (insert "(setq gnus-newsrc-file-version "
15869 (prin1-to-string gnus-version) ")\n")
15871 (if gnus-save-killed-list gnus-variable-list
15872 ;; Remove the `gnus-killed-list' from the list of variables
15873 ;; to be saved, if required.
15874 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
15875 ;; Peel off the "dummy" group.
15876 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
15878 ;; Insert the variables into the file.
15880 (when (and (boundp (setq variable (pop variables)))
15881 (symbol-value variable))
15882 (insert "(setq " (symbol-name variable) " '"
15883 (prin1-to-string (symbol-value variable)) ")\n")))))
15885 (defun gnus-gnus-to-newsrc-format ()
15886 ;; Generate and save the .newsrc file.
15887 (let ((newsrc (cdr gnus-newsrc-alist))
15890 (set-buffer (create-file-buffer gnus-current-startup-file))
15891 (setq buffer-file-name gnus-current-startup-file)
15892 (buffer-disable-undo (current-buffer))
15895 (if gnus-newsrc-options (insert gnus-newsrc-options))
15896 ;; Write subscribed and unsubscribed.
15898 (setq info (car newsrc))
15899 (if (not (gnus-info-method info))
15900 ;; Don't write foreign groups to .newsrc.
15902 (insert (gnus-info-group info)
15903 (if (> (gnus-info-level info) gnus-level-subscribed)
15905 (if (setq ranges (gnus-info-read info))
15908 (if (not (listp (cdr ranges)))
15909 (if (= (car ranges) (cdr ranges))
15910 (insert (int-to-string (car ranges)))
15911 (insert (int-to-string (car ranges)) "-"
15912 (int-to-string (cdr ranges))))
15914 (setq range (car ranges)
15915 ranges (cdr ranges))
15916 (if (or (atom range) (= (car range) (cdr range)))
15917 (insert (int-to-string
15918 (or (and (atom range) range)
15920 (insert (int-to-string (car range)) "-"
15921 (int-to-string (cdr range))))
15922 (if ranges (insert ","))))))
15924 (setq newsrc (cdr newsrc)))
15925 (make-local-variable 'version-control)
15926 (setq version-control 'never)
15927 ;; It has been reported that sometime the modtime on the .newsrc
15928 ;; file seems to be off. We really do want to overwrite it, so
15929 ;; we clear the modtime here before saving. It's a bit odd,
15931 ;; sometimes the modtime clear isn't sufficient. most brute force:
15932 ;; delete the silly thing entirely first. but this fails to provide
15933 ;; such niceties as .newsrc~ creation.
15934 (if gnus-modtime-botch
15935 (delete-file gnus-startup-file)
15936 (clear-visited-file-modtime))
15937 (run-hooks 'gnus-save-standard-newsrc-hook)
15939 (kill-buffer (current-buffer)))))
15942 ;;; Slave functions.
15944 (defun gnus-slave-save-newsrc ()
15946 (set-buffer gnus-dribble-buffer)
15948 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
15949 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
15951 (defun gnus-master-read-slave-newsrc ()
15954 (file-name-directory gnus-current-startup-file)
15958 (file-name-nondirectory gnus-current-startup-file)
15962 (if (not slave-files)
15963 () ; There are no slave files to read.
15964 (gnus-message 7 "Reading slave newsrcs...")
15966 (set-buffer (get-buffer-create " *gnus slave*"))
15967 (buffer-disable-undo (current-buffer))
15969 (sort (mapcar (lambda (file)
15970 (list (nth 5 (file-attributes file)) file))
15973 (or (< (car (car f1)) (car (car f2)))
15974 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
15977 (setq file (nth 1 (car slave-files)))
15978 (insert-file-contents file)
15979 (if (condition-case ()
15981 (eval-buffer (current-buffer))
15984 (gnus-message 3 "Possible error in %s" file)
15988 (or gnus-slave ; Slaves shouldn't delete these files.
15992 (setq slave-files (cdr slave-files))))
15993 (gnus-message 7 "Reading slave newsrcs...done"))))
15996 ;;; Group description.
15998 (defun gnus-read-all-descriptions-files ()
15999 (let ((methods (cons gnus-select-method
16000 (cons gnus-message-archive-method
16001 gnus-secondary-select-methods))))
16003 (gnus-read-descriptions-file (car methods))
16004 (setq methods (cdr methods)))
16007 (defun gnus-read-descriptions-file (&optional method)
16008 (let ((method (or method gnus-select-method)))
16009 ;; We create the hashtable whether we manage to read the desc file
16010 ;; to avoid trying to re-read after a failed read.
16011 (or gnus-description-hashtb
16012 (setq gnus-description-hashtb
16013 (gnus-make-hashtable (length gnus-active-hashtb))))
16014 ;; Mark this method's desc file as read.
16015 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16016 gnus-description-hashtb)
16018 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16020 ((not (gnus-check-server method))
16021 (gnus-message 1 "Couldn't open server")
16023 ((not (gnus-request-list-newsgroups method))
16024 (gnus-message 1 "Couldn't read newsgroups descriptions")
16030 (set-buffer nntp-server-buffer)
16031 (goto-char (point-min))
16032 (if (or (search-forward "\n.\n" nil t)
16033 (goto-char (point-max)))
16035 (beginning-of-line)
16036 (narrow-to-region (point-min) (point))))
16037 (goto-char (point-min))
16038 (while (not (eobp))
16039 ;; If we get an error, we set group to 0, which is not a
16043 (let ((obarray gnus-description-hashtb))
16044 ;; Group is set to a symbol interned in this
16046 (read nntp-server-buffer))
16048 (skip-chars-forward " \t")
16049 ;; ... which leads to this line being effectively ignored.
16050 (and (symbolp group)
16051 (set group (buffer-substring
16052 (point) (progn (end-of-line) (point)))))
16053 (forward-line 1))))
16054 (gnus-message 5 "Reading descriptions file...done")
16057 (defun gnus-group-get-description (group)
16058 "Get the description of a group by sending XGTITLE to the server."
16059 (when (gnus-request-group-description group)
16061 (set-buffer nntp-server-buffer)
16062 (goto-char (point-min))
16063 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16064 (match-string 1)))))
16067 ;;; Buffering of read articles.
16070 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16071 (defvar gnus-backlog-articles nil)
16072 (defvar gnus-backlog-hashtb nil)
16074 (defun gnus-backlog-buffer ()
16075 "Return the backlog buffer."
16076 (or (get-buffer gnus-backlog-buffer)
16078 (set-buffer (get-buffer-create gnus-backlog-buffer))
16079 (buffer-disable-undo (current-buffer))
16080 (setq buffer-read-only t)
16081 (gnus-add-current-to-buffer-list)
16082 (get-buffer gnus-backlog-buffer))))
16084 (defun gnus-backlog-setup ()
16085 "Initialize backlog variables."
16086 (unless gnus-backlog-hashtb
16087 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16089 (defun gnus-backlog-shutdown ()
16090 "Clear all backlog variables and buffers."
16091 (when (get-buffer gnus-backlog-buffer)
16092 (kill-buffer gnus-backlog-buffer))
16093 (setq gnus-backlog-hashtb nil
16094 gnus-backlog-articles nil))
16096 (defun gnus-backlog-enter-article (group number buffer)
16097 (gnus-backlog-setup)
16098 (let ((ident (intern (concat group ":" (int-to-string number))
16099 gnus-backlog-hashtb))
16101 (if (memq ident gnus-backlog-articles)
16102 () ; It's already kept.
16103 ;; Remove the oldest article, if necessary.
16104 (and (numberp gnus-keep-backlog)
16105 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16106 (gnus-backlog-remove-oldest-article))
16107 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16108 ;; Insert the new article.
16110 (set-buffer (gnus-backlog-buffer))
16111 (let (buffer-read-only)
16112 (goto-char (point-max))
16113 (or (bolp) (insert "\n"))
16115 (insert-buffer-substring buffer)
16116 ;; Tag the beginning of the article with the ident.
16117 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16119 (defun gnus-backlog-remove-oldest-article ()
16121 (set-buffer (gnus-backlog-buffer))
16122 (goto-char (point-min))
16123 (if (zerop (buffer-size))
16124 () ; The buffer is empty.
16125 (let ((ident (get-text-property (point) 'gnus-backlog))
16127 ;; Remove the ident from the list of articles.
16129 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16130 ;; Delete the article itself.
16132 (point) (next-single-property-change
16133 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16135 (defun gnus-backlog-request-article (group number buffer)
16136 (gnus-backlog-setup)
16137 (let ((ident (intern (concat group ":" (int-to-string number))
16138 gnus-backlog-hashtb))
16140 (when (memq ident gnus-backlog-articles)
16141 ;; It was in the backlog.
16143 (set-buffer (gnus-backlog-buffer))
16144 (if (not (setq beg (text-property-any
16145 (point-min) (point-max) 'gnus-backlog
16147 ;; It wasn't in the backlog after all.
16149 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))
16151 ;; Find the end (i. e., the beginning of the next article).
16153 (next-single-property-change
16154 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16155 (let ((buffer-read-only nil))
16157 (insert-buffer-substring gnus-backlog-buffer beg end)
16160 ;; Allow redefinition of Gnus functions.
16162 (gnus-ems-redefine)
16166 ;;; gnus.el ends here