1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook
))
38 (eval-when-compile (require 'cl
))
40 (defvar gnus-directory
(or (getenv "SAVEDIR") "~/News/")
41 "*Directory variable from which all other Gnus file variables are derived.")
43 ;; Site dependent variables. These variables should be defined in
46 (defvar gnus-default-nntp-server nil
47 "Specify a default NNTP server.
48 This variable should be defined in paths.el, and should never be set
50 If you want to change servers, you should use `gnus-select-method'.
51 See the documentation to that variable.")
53 (defvar gnus-backup-default-subscribed-newsgroups
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
55 "Default default new newsgroups the first time Gnus is run.
56 Should be set in paths.el, and shouldn't be touched by the user.")
58 (defvar gnus-local-domain nil
59 "Local domain name without a host name.
60 The DOMAINNAME environment variable is used instead if it is defined.
61 If the `system-name' function returns the full Internet name, there is
62 no need to set this variable.")
64 (defvar gnus-local-organization nil
65 "String with a description of what organization (if any) the user belongs to.
66 The ORGANIZATION environment variable is used instead if it is defined.
67 If this variable contains a function, this function will be called
68 with the current newsgroup name as the argument. The function should
71 In any case, if the string (either in the variable, in the environment
72 variable, or returned by the function) is a file name, the contents of
73 this file will be used as the organization.")
75 ;; Customization variables
77 ;; Don't touch this variable.
78 (defvar gnus-nntp-service
"nntp"
79 "*NNTP service name (\"nntp\" or 119).
80 This is an obsolete variable, which is scarcely used. If you use an
81 nntp server for your newsgroup and want to change the port number
82 used to 899, you would say something along these lines:
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
86 (defvar gnus-nntpserver-file
"/etc/nntpserver"
87 "*A file with only the name of the nntp server in it.")
89 ;; This function is used to check both the environment variable
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
91 ;; an nntp server name default.
92 (defun gnus-getenv-nntpserver ()
93 (or (getenv "NNTPSERVER")
94 (and (file-readable-p gnus-nntpserver-file
)
96 (set-buffer (get-buffer-create " *gnus nntp*"))
97 (buffer-disable-undo (current-buffer))
98 (insert-file-contents gnus-nntpserver-file
)
99 (let ((name (buffer-string)))
101 (if (string-match "^[ \t\n]*$" name
)
104 (kill-buffer (current-buffer))))))))
106 (defvar gnus-select-method
108 (list 'nntp
(or (condition-case ()
109 (gnus-getenv-nntpserver)
111 (if (and gnus-default-nntp-server
112 (not (string= gnus-default-nntp-server
"")))
113 gnus-default-nntp-server
)
115 (if (or (null gnus-nntp-service
)
116 (equal gnus-nntp-service
"nntp"))
118 (list gnus-nntp-service
)))
119 "*Default method for selecting a newsgroup.
120 This variable should be a list, where the first element is how the
121 news is to be fetched, the second is the address.
123 For instance, if you want to get your news via NNTP from
124 \"flab.flab.edu\", you could say:
126 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
128 If you want to use your local spool, say:
130 (setq gnus-select-method (list 'nnspool (system-name)))
132 If you use this variable, you must set `gnus-nntp-server' to nil.
134 There is a lot more to know about select methods and virtual servers -
135 see the manual for details.")
137 (defvar gnus-message-archive-method
140 (nnfolder-directory ,(nnheader-concat message-directory
"archive"))
141 (nnfolder-active-file
142 ,(nnheader-concat message-directory
"archive/active"))
143 (nnfolder-get-new-mail nil
)
144 (nnfolder-inhibit-expiry t
))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.
148 It's probably not a very effective to change this variable once you've
149 run Gnus once. After doing that, you must edit this server from the
152 (defvar gnus-message-archive-group nil
153 "*Name of the group in which to save the messages you've written.
154 This can either be a string, a list of strings; or an alist
155 of regexps/functions/forms to be evaluated to return a string (or a list
156 of strings). The functions are called with the name of the current
157 group (or nil) as a parameter.
159 Normally the group names returned by this variable should be
160 unprefixed -- which implictly means \"store on the archive server\".
161 However, you may wish to store the message on some other server. In
162 that case, just return a fully prefixed name of the group --
163 \"nnml+private:mail.misc\", for instance.")
165 (defvar gnus-refer-article-method nil
166 "*Preferred method for fetching an article by Message-ID.
167 If you are reading news from the local spool (with nnspool), fetching
168 articles by Message-ID is painfully slow. By setting this method to an
169 nntp method, you might get acceptable results.
171 The value of this variable must be a valid select method as discussed
172 in the documentation of `gnus-select-method'.")
174 (defvar gnus-secondary-select-methods nil
175 "*A list of secondary methods that will be used for reading news.
176 This is a list where each element is a complete select method (see
177 `gnus-select-method').
179 If, for instance, you want to read your mail with the nnml backend,
180 you could set this variable:
182 (setq gnus-secondary-select-methods '((nnml \"\")))")
184 (defvar gnus-secondary-servers nil
185 "*List of NNTP servers that the user can choose between interactively.
186 To make Gnus query you for a server, you have to give `gnus' a
187 non-numeric prefix - `C-u M-x gnus', in short.")
189 (defvar gnus-nntp-server nil
190 "*The name of the host running the NNTP server.
191 This variable is semi-obsolete. Use the `gnus-select-method'
194 (defvar gnus-startup-file
"~/.newsrc"
195 "*Your `.newsrc' file.
196 `.newsrc-SERVER' will be used instead if that exists.")
198 (defvar gnus-init-file
"~/.gnus"
199 "*Your Gnus elisp startup file.
200 If a file with the .el or .elc suffixes exist, it will be read
203 (defvar gnus-group-faq-directory
204 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
205 "/ftp@sunsite.auc.dk:/pub/usenet/"
206 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
207 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
208 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
209 "/ftp@rtfm.mit.edu:/pub/usenet/"
210 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
211 "/ftp@ftp.sunet.se:/pub/usenet/"
212 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
213 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
214 "/ftp@ftp.hk.super.net:/mirror/faqs/")
215 "*Directory where the group FAQs are stored.
216 This will most commonly be on a remote machine, and the file will be
219 This variable can also be a list of directories. In that case, the
220 first element in the list will be used by default. The others can
221 be used when being prompted for a site.
223 Note that Gnus uses an aol machine as the default directory. If this
224 feels fundamentally unclean, just think of it as a way to finally get
225 something of value back from them.
227 If the default site is too slow, try one of these:
229 North America: mirrors.aol.com /pub/rtfm/usenet
230 ftp.seas.gwu.edu /pub/rtfm
231 rtfm.mit.edu /pub/usenet
232 Europe: ftp.uni-paderborn.de /pub/FAQ
233 src.doc.ic.ac.uk /usenet/news-FAQS
234 ftp.sunet.se /pub/usenet
235 sunsite.auc.dk /pub/usenet
236 Asia: nctuccca.edu.tw /USENET/FAQ
237 hwarang.postech.ac.kr /pub/usenet
238 ftp.hk.super.net /mirror/faqs")
240 (defvar gnus-group-archive-directory
241 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
242 "*The address of the (ding) archives.")
244 (defvar gnus-group-recent-archive-directory
245 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
246 "*The address of the most recent (ding) articles.")
248 (defvar gnus-default-subscribed-newsgroups nil
249 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
250 It should be a list of strings.
251 If it is `t', Gnus will not do anything special the first time it is
252 started; it'll just use the normal newsgroups subscription methods.")
254 (defvar gnus-use-cross-reference t
255 "*Non-nil means that cross referenced articles will be marked as read.
256 If nil, ignore cross references. If t, mark articles as read in
257 subscribed newsgroups. If neither t nor nil, mark as read in all
260 (defvar gnus-single-article-buffer t
261 "*If non-nil, display all articles in the same buffer.
262 If nil, each group will get its own article buffer.")
264 (defvar gnus-use-dribble-file t
265 "*Non-nil means that Gnus will use a dribble file to store user updates.
266 If Emacs should crash without saving the .newsrc files, complete
267 information can be restored from the dribble file.")
269 (defvar gnus-dribble-directory nil
270 "*The directory where dribble files will be saved.
271 If this variable is nil, the directory where the .newsrc files are
272 saved will be used.")
274 (defvar gnus-asynchronous nil
275 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
277 (defvar gnus-kill-summary-on-exit t
278 "*If non-nil, kill the summary buffer when you exit from it.
279 If nil, the summary will become a \"*Dead Summary*\" buffer, and
280 it will be killed sometime later.")
282 (defvar gnus-large-newsgroup
200
283 "*The number of articles which indicates a large newsgroup.
284 If the number of articles in a newsgroup is greater than this value,
285 confirmation is required for selecting the newsgroup.")
287 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
288 (defvar gnus-no-groups-message
"No news is horrible news"
289 "*Message displayed by Gnus when no groups are available.")
291 (defvar gnus-use-long-file-name
(not (memq system-type
'(usg-unix-v xenix
)))
292 "*Non-nil means that the default name of a file to save articles in is the group name.
293 If it's nil, the directory form of the group name is used instead.
295 If this variable is a list, and the list contains the element
296 `not-score', long file names will not be used for score files; if it
297 contains the element `not-save', long file names will not be used for
298 saving; and if it contains the element `not-kill', long file names
299 will not be used for kill files.
301 Note that the default for this variable varies according to what system
302 type you're using. On `usg-unix-v' and `xenix' this variable defaults
303 to nil while on all other systems it defaults to t.")
305 (defvar gnus-article-save-directory gnus-directory
306 "*Name of the directory articles will be saved in (default \"~/News\").")
308 (defvar gnus-kill-files-directory gnus-directory
309 "*Name of the directory where kill files will be stored (default \"~/News\").")
311 (defvar gnus-default-article-saver
'gnus-summary-save-in-rmail
312 "*A function to save articles in your favorite format.
313 The function must be interactively callable (in other words, it must
314 be an Emacs command).
316 Gnus provides the following functions:
318 * gnus-summary-save-in-rmail (Rmail format)
319 * gnus-summary-save-in-mail (Unix mail format)
320 * gnus-summary-save-in-folder (MH folder)
321 * gnus-summary-save-in-file (article format).
322 * gnus-summary-save-in-vm (use VM's folder format).")
324 (defvar gnus-prompt-before-saving
'always
325 "*This variable says how much prompting is to be done when saving articles.
326 If it is nil, no prompting will be done, and the articles will be
327 saved to the default files. If this variable is `always', each and
328 every article that is saved will be preceded by a prompt, even when
329 saving large batches of articles. If this variable is neither nil not
330 `always', there the user will be prompted once for a file name for
331 each invocation of the saving commands.")
333 (defvar gnus-rmail-save-name
(function gnus-plain-save-name
)
334 "*A function generating a file name to save articles in Rmail format.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
337 (defvar gnus-mail-save-name
(function gnus-plain-save-name
)
338 "*A function generating a file name to save articles in Unix mail format.
339 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
341 (defvar gnus-folder-save-name
(function gnus-folder-save-name
)
342 "*A function generating a file name to save articles in MH folder.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
345 (defvar gnus-file-save-name
(function gnus-numeric-save-name
)
346 "*A function generating a file name to save articles in article format.
347 The function is called with NEWSGROUP, HEADERS, and optional
350 (defvar gnus-split-methods
351 '((gnus-article-archive-name))
352 "*Variable used to suggest where articles are to be saved.
353 For instance, if you would like to save articles related to Gnus in
354 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
355 you could set this variable to something like:
357 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
358 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
360 This variable is an alist where the where the key is the match and the
361 value is a list of possible files to save in if the match is non-nil.
363 If the match is a string, it is used as a regexp match on the
364 article. If the match is a symbol, that symbol will be funcalled
365 from the buffer of the article to be saved with the newsgroup as the
366 parameter. If it is a list, it will be evaled in the same buffer.
368 If this form or function returns a string, this string will be used as
369 a possible file name; and if it returns a non-nil list, that list will
370 be used as possible file names.")
372 (defvar gnus-move-split-methods nil
373 "*Variable used to suggest where articles are to be moved to.
374 It uses the same syntax as the `gnus-split-methods' variable.")
376 (defvar gnus-save-score nil
377 "*If non-nil, save group scoring info.")
379 (defvar gnus-use-adaptive-scoring nil
380 "*If non-nil, use some adaptive scoring scheme.")
382 (defvar gnus-use-cache
'passive
383 "*If nil, Gnus will ignore the article cache.
384 If `passive', it will allow entering (and reading) articles
385 explicitly entered into the cache. If anything else, use the
386 cache to the full extent of the law.")
388 (defvar gnus-use-trees nil
389 "*If non-nil, display a thread tree buffer.")
391 (defvar gnus-use-grouplens nil
392 "*If non-nil, use GroupLens ratings.")
394 (defvar gnus-keep-backlog nil
395 "*If non-nil, Gnus will keep read articles for later re-retrieval.
396 If it is a number N, then Gnus will only keep the last N articles
397 read. If it is neither nil nor a number, Gnus will keep all read
398 articles. This is not a good idea.")
400 (defvar gnus-use-nocem nil
401 "*If non-nil, Gnus will read NoCeM cancel messages.")
403 (defvar gnus-use-demon nil
404 "If non-nil, Gnus might use some demons.")
406 (defvar gnus-use-scoring t
407 "*If non-nil, enable scoring.")
409 (defvar gnus-use-picons nil
410 "*If non-nil, display picons.")
412 (defvar gnus-fetch-old-headers nil
413 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
414 If an unread article in the group refers to an older, already read (or
415 just marked as read) article, the old article will not normally be
416 displayed in the Summary buffer. If this variable is non-nil, Gnus
417 will attempt to grab the headers to the old articles, and thereby
418 build complete threads. If it has the value `some', only enough
419 headers to connect otherwise loose threads will be displayed.
420 This variable can also be a number. In that case, no more than that
421 number of old headers will be fetched.
423 The server has to support NOV for any of this to work.")
426 ;(defvar gnus-visual t
427 ; "*If non-nil, will do various highlighting.
428 ;If nil, no mouse highlights (or any other highlights) will be
429 ;performed. This might speed up Gnus some when generating large group
430 ;and summary buffers.")
432 (defvar gnus-novice-user t
433 "*Non-nil means that you are a usenet novice.
434 If non-nil, verbose messages may be displayed and confirmations may be
437 (defvar gnus-expert-user nil
438 "*Non-nil means that you will never be asked for confirmation about anything.
439 And that means *anything*.")
441 (defvar gnus-verbose
7
442 "*Integer that says how verbose Gnus should be.
443 The higher the number, the more messages Gnus will flash to say what
444 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
445 display most important messages; and at ten, Gnus will keep on
446 jabbering all the time.")
448 (defvar gnus-keep-same-level nil
449 "*Non-nil means that the next newsgroup after the current will be on the same level.
450 When you type, for instance, `n' after reading the last article in the
451 current newsgroup, you will go to the next newsgroup. If this variable
452 is nil, the next newsgroup will be the next from the group
454 If this variable is non-nil, Gnus will either put you in the
455 next newsgroup with the same level, or, if no such newsgroup is
456 available, the next newsgroup with the lowest possible level higher
457 than the current level.
458 If this variable is `best', Gnus will make the next newsgroup the one
459 with the best level.")
461 (defvar gnus-summary-make-false-root
'adopt
462 "*nil means that Gnus won't gather loose threads.
463 If the root of a thread has expired or been read in a previous
464 session, the information necessary to build a complete thread has been
465 lost. Instead of having many small sub-threads from this original thread
466 scattered all over the summary buffer, Gnus can gather them.
468 If non-nil, Gnus will try to gather all loose sub-threads from an
469 original thread into one large thread.
471 If this variable is non-nil, it should be one of `none', `adopt',
474 If this variable is `none', Gnus will not make a false root, but just
475 present the sub-threads after another.
476 If this variable is `dummy', Gnus will create a dummy root that will
477 have all the sub-threads as children.
478 If this variable is `adopt', Gnus will make one of the \"children\"
479 the parent and mark all the step-children as such.
480 If this variable is `empty', the \"children\" are printed with empty
481 subject fields. (Or rather, they will be printed with a string
482 given by the `gnus-summary-same-subject' variable.)")
484 (defvar gnus-summary-gather-exclude-subject
"^ *$\\|^(none)$"
485 "*A regexp to match subjects to be excluded from loose thread gathering.
486 As loose thread gathering is done on subjects only, that means that
487 there can be many false gatherings performed. By rooting out certain
488 common subjects, gathering might become saner.")
490 (defvar gnus-summary-gather-subject-limit nil
491 "*Maximum length of subject comparisons when gathering loose threads.
492 Use nil to compare full subjects. Setting this variable to a low
493 number will help gather threads that have been corrupted by
494 newsreaders chopping off subject lines, but it might also mean that
495 unrelated articles that have subject that happen to begin with the
496 same few characters will be incorrectly gathered.
498 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
499 comparing subjects.")
501 (defvar gnus-simplify-ignored-prefixes nil
502 "*Regexp, matches for which are removed from subject lines when simplifying.")
504 (defvar gnus-build-sparse-threads nil
505 "*If non-nil, fill in the gaps in threads.
506 If `some', only fill in the gaps that are needed to tie loose threads
507 together. If `more', fill in all leaf nodes that Gnus can find. If
508 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
510 (defvar gnus-summary-thread-gathering-function
'gnus-gather-threads-by-subject
511 "Function used for gathering loose threads.
512 There are two pre-defined functions: `gnus-gather-threads-by-subject',
513 which only takes Subjects into consideration; and
514 `gnus-gather-threads-by-references', which compared the References
515 headers of the articles to find matches.")
517 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
518 (defvar gnus-summary-same-subject
""
519 "*String indicating that the current article has the same subject as the previous.
520 This variable will only be used if the value of
521 `gnus-summary-make-false-root' is `empty'.")
523 (defvar gnus-summary-goto-unread t
524 "*If non-nil, marking commands will go to the next unread article.
525 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
526 whether it is read or not.")
528 (defvar gnus-group-goto-unread t
529 "*If non-nil, movement commands will go to the next unread and subscribed group.")
531 (defvar gnus-goto-next-group-when-activating t
532 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
534 (defvar gnus-check-new-newsgroups t
535 "*Non-nil means that Gnus will add new newsgroups at startup.
536 If this variable is `ask-server', Gnus will ask the server for new
537 groups since the last time it checked. This means that the killed list
538 is no longer necessary, so you could set `gnus-save-killed-list' to
541 A variant is to have this variable be a list of select methods. Gnus
542 will then use the `ask-server' method on all these select methods to
543 query for new groups from all those servers.
546 (setq gnus-check-new-newsgroups
547 '((nntp \"some.server\") (nntp \"other.server\")))
549 If this variable is nil, then you have to tell Gnus explicitly to
550 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
552 (defvar gnus-check-bogus-newsgroups nil
553 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
554 If this variable is nil, then you have to tell Gnus explicitly to
555 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
557 (defvar gnus-read-active-file t
558 "*Non-nil means that Gnus will read the entire active file at startup.
559 If this variable is nil, Gnus will only know about the groups in your
562 If this variable is `some', Gnus will try to only read the relevant
563 parts of the active file from the server. Not all servers support
564 this, and it might be quite slow with other servers, but this should
565 generally be faster than both the t and nil value.
567 If you set this variable to nil or `some', you probably still want to
568 be told about new newsgroups that arrive. To do that, set
569 `gnus-check-new-newsgroups' to `ask-server'. This may not work
570 properly with all servers.")
572 (defvar gnus-level-subscribed
5
573 "*Groups with levels less than or equal to this variable are subscribed.")
575 (defvar gnus-level-unsubscribed
7
576 "*Groups with levels less than or equal to this variable are unsubscribed.
577 Groups with levels less than `gnus-level-subscribed', which should be
578 less than this variable, are subscribed.")
580 (defvar gnus-level-zombie
8
581 "*Groups with this level are zombie groups.")
583 (defvar gnus-level-killed
9
584 "*Groups with this level are killed.")
586 (defvar gnus-level-default-subscribed
3
587 "*New subscribed groups will be subscribed at this level.")
589 (defvar gnus-level-default-unsubscribed
6
590 "*New unsubscribed groups will be unsubscribed at this level.")
592 (defvar gnus-activate-level
(1+ gnus-level-subscribed
)
593 "*Groups higher than this level won't be activated on startup.
594 Setting this variable to something log might save lots of time when
595 you have many groups that you aren't interested in.")
597 (defvar gnus-activate-foreign-newsgroups
4
598 "*If nil, Gnus will not check foreign newsgroups at startup.
599 If it is non-nil, it should be a number between one and nine. Foreign
600 newsgroups that have a level lower or equal to this number will be
601 activated on startup. For instance, if you want to active all
602 subscribed newsgroups, but not the rest, you'd set this variable to
603 `gnus-level-subscribed'.
605 If you subscribe to lots of newsgroups from different servers, startup
606 might take a while. By setting this variable to nil, you'll save time,
607 but you won't be told how many unread articles there are in the
610 (defvar gnus-save-newsrc-file t
611 "*Non-nil means that Gnus will save the `.newsrc' file.
612 Gnus always saves its own startup file, which is called
613 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
614 be readily understood by other newsreaders. If you don't plan on
615 using other newsreaders, set this variable to nil to save some time on
618 (defvar gnus-save-killed-list t
619 "*If non-nil, save the list of killed groups to the startup file.
620 If you set this variable to nil, you'll save both time (when starting
621 and quitting) and space (both memory and disk), but it will also mean
622 that Gnus has no record of which groups are new and which are old, so
623 the automatic new newsgroups subscription methods become meaningless.
625 You should always set `gnus-check-new-newsgroups' to `ask-server' or
626 nil if you set this variable to nil.")
628 (defvar gnus-interactive-catchup t
629 "*If non-nil, require your confirmation when catching up a group.")
631 (defvar gnus-interactive-exit t
632 "*If non-nil, require your confirmation when exiting Gnus.")
634 (defvar gnus-kill-killed t
635 "*If non-nil, Gnus will apply kill files to already killed articles.
636 If it is nil, Gnus will never apply kill files to articles that have
637 already been through the scoring process, which might very well save lots
640 (defvar gnus-extract-address-components
'gnus-extract-address-components
641 "*Function for extracting address components from a From header.
642 Two pre-defined function exist: `gnus-extract-address-components',
643 which is the default, quite fast, and too simplistic solution, and
644 `mail-extract-address-components', which works much better, but is
647 (defvar gnus-summary-default-score
0
648 "*Default article score level.
649 If this variable is nil, scoring will be disabled.")
651 (defvar gnus-summary-zcore-fuzz
0
652 "*Fuzziness factor for the zcore in the summary buffer.
653 Articles with scores closer than this to `gnus-summary-default-score'
654 will not be marked.")
656 (defvar gnus-simplify-subject-fuzzy-regexp nil
657 "*Strings to be removed when doing fuzzy matches.
658 This can either be a regular expression or list of regular expressions
659 that will be removed from subject strings if fuzzy subject
660 simplification is selected.")
662 (defvar gnus-permanently-visible-groups nil
663 "*Regexp to match groups that should always be listed in the group buffer.
664 This means that they will still be listed when there are no unread
665 articles in the groups.")
667 (defvar gnus-list-groups-with-ticked-articles t
668 "*If non-nil, list groups that have only ticked articles.
669 If nil, only list groups that have unread articles.")
671 (defvar gnus-group-default-list-level gnus-level-subscribed
672 "*Default listing level.
673 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
675 (defvar gnus-group-use-permanent-levels nil
676 "*If non-nil, once you set a level, Gnus will use this level.")
678 (defvar gnus-group-list-inactive-groups t
679 "*If non-nil, inactive groups will be listed.")
681 (defvar gnus-show-mime nil
682 "*If non-nil, do mime processing of articles.
683 The articles will simply be fed to the function given by
684 `gnus-show-mime-method'.")
686 (defvar gnus-strict-mime t
687 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
689 (defvar gnus-show-mime-method
'metamail-buffer
690 "*Function to process a MIME message.
691 The function is called from the article buffer.")
693 (defvar gnus-decode-encoded-word-method
(lambda ())
694 "*Function to decode a MIME encoded-words.
695 The function is called from the article buffer.")
697 (defvar gnus-show-threads t
698 "*If non-nil, display threads in summary mode.")
700 (defvar gnus-thread-hide-subtree nil
701 "*If non-nil, hide all threads initially.
702 If threads are hidden, you have to run the command
703 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
704 to expose hidden threads.")
706 (defvar gnus-thread-hide-killed t
707 "*If non-nil, hide killed threads automatically.")
709 (defvar gnus-thread-ignore-subject nil
710 "*If non-nil, ignore subjects and do all threading based on the Reference header.
711 If nil, which is the default, articles that have different subjects
712 from their parents will start separate threads.")
714 (defvar gnus-thread-operation-ignore-subject t
715 "*If non-nil, subjects will be ignored when doing thread commands.
716 This affects commands like `gnus-summary-kill-thread' and
717 `gnus-summary-lower-thread'.
719 If this variable is nil, articles in the same thread with different
720 subjects will not be included in the operation in question. If this
721 variable is `fuzzy', only articles that have subjects that are fuzzily
722 equal will be included.")
724 (defvar gnus-thread-indent-level
4
725 "*Number that says how much each sub-thread should be indented.")
727 (defvar gnus-ignored-newsgroups
728 (purecopy (mapconcat 'identity
729 '("^to\\." ; not "real" groups
730 "^[0-9. \t]+ " ; all digits in name
731 "[][\"#'()]" ; bogus characters
734 "*A regexp to match uninteresting newsgroups in the active file.
735 Any lines in the active file matching this regular expression are
736 removed from the newsgroup list before anything else is done to it,
737 thus making them effectively non-existent.")
739 (defvar gnus-ignored-headers
740 "^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:"
741 "*All headers that match this regexp will be hidden.
742 This variable can also be a list of regexps of headers to be ignored.
743 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
745 (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-"
746 "*All headers that do not match this regexp will be hidden.
747 This variable can also be a list of regexp of headers to remain visible.
748 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
750 (defvar gnus-sorted-header-list
751 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
752 "^Cc:" "^Date:" "^Organization:")
753 "*This variable is a list of regular expressions.
754 If it is non-nil, headers that match the regular expressions will
755 be placed first in the article buffer in the sequence specified by
758 (defvar gnus-boring-article-headers
759 '(empty followup-to reply-to
)
760 "*Headers that are only to be displayed if they have interesting data.
761 Possible values in this list are `empty', `newsgroups', `followup-to',
762 `reply-to', and `date'.")
764 (defvar gnus-show-all-headers nil
765 "*If non-nil, don't hide any headers.")
767 (defvar gnus-save-all-headers t
768 "*If non-nil, don't remove any headers before saving.")
770 (defvar gnus-saved-headers gnus-visible-headers
771 "*Headers to keep if `gnus-save-all-headers' is nil.
772 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
773 If that variable is nil, however, all headers that match this regexp
774 will be kept while the rest will be deleted before saving.")
776 (defvar gnus-inhibit-startup-message nil
777 "*If non-nil, the startup message will not be displayed.")
779 (defvar gnus-signature-separator
"^-- *$"
780 "Regexp matching signature separator.")
782 (defvar gnus-signature-limit nil
783 "Provide a limit to what is considered a signature.
784 If it is a number, no signature may not be longer (in characters) than
785 that number. If it is a function, the function will be called without
786 any parameters, and if it returns nil, there is no signature in the
787 buffer. If it is a string, it will be used as a regexp. If it
788 matches, the text in question is not a signature.")
790 (defvar gnus-auto-extend-newsgroup t
791 "*If non-nil, extend newsgroup forward and backward when requested.")
793 (defvar gnus-auto-select-first t
794 "*If nil, don't select the first unread article when entering a group.
795 If this variable is `best', select the highest-scored unread article
796 in the group. If neither nil nor `best', select the first unread
799 If you want to prevent automatic selection of the first unread article
800 in some newsgroups, set the variable to nil in
801 `gnus-select-group-hook'.")
803 (defvar gnus-auto-select-next t
804 "*If non-nil, offer to go to the next group from the end of the previous.
805 If the value is t and the next newsgroup is empty, Gnus will exit
806 summary mode and go back to group mode. If the value is neither nil
807 nor t, Gnus will select the following unread newsgroup. In
808 particular, if the value is the symbol `quietly', the next unread
809 newsgroup will be selected without any confirmation, and if it is
810 `almost-quietly', the next group will be selected without any
811 confirmation if you are located on the last article in the group.
812 Finally, if this variable is `slightly-quietly', the `Z n' command
813 will go to the next group without confirmation.")
815 (defvar gnus-auto-select-same nil
816 "*If non-nil, select the next article with the same subject.")
818 (defvar gnus-summary-check-current nil
819 "*If non-nil, consider the current article when moving.
820 The \"unread\" movement commands will stay on the same line if the
821 current article is unread.")
823 (defvar gnus-auto-center-summary t
824 "*If non-nil, always center the current summary buffer.
825 In particular, if `vertical' do only vertical recentering. If non-nil
826 and non-`vertical', do both horizontal and vertical recentering.")
828 (defvar gnus-break-pages t
829 "*If non-nil, do page breaking on articles.
830 The page delimiter is specified by the `gnus-page-delimiter'
833 (defvar gnus-page-delimiter
"^\^L"
834 "*Regexp describing what to use as article page delimiters.
835 The default value is \"^\^L\", which is a form linefeed at the
836 beginning of a line.")
838 (defvar gnus-use-full-window t
839 "*If non-nil, use the entire Emacs screen.")
841 (defvar gnus-window-configuration nil
842 "Obsolete variable. See `gnus-buffer-configuration'.")
844 (defvar gnus-window-min-width
2
845 "*Minimum width of Gnus buffers.")
847 (defvar gnus-window-min-height
1
848 "*Minimum height of Gnus buffers.")
850 (defvar gnus-buffer-configuration
854 (if gnus-carpal
'(group-carpal 4))))
858 (if gnus-carpal
'(summary-carpal 4))))
865 (if gnus-carpal
'(summary-carpal 4))
867 (vertical ((height .
5) (width .
15)
869 (left . -
1) (top .
1))
879 (if gnus-carpal
'(summary-carpal 4))
884 (if gnus-carpal
'(server-carpal 2))))
888 (if gnus-carpal
'(browse-carpal 2))))
891 (message 1.0 point
)))
894 (article 1.0 point
)))
905 (edit-group 1.0 point
)))
909 (edit-server 1.0 point
)))
913 (edit-score 1.0 point
)))
920 (message 1.0 point
)))
923 (message 1.0 point
)))
926 (message 1.0 point
)))
930 (message 1.0 point
)))
937 (if gnus-carpal
'(summary-carpal 4))
938 ("*Shell Command Output*" 1.0)))
941 ("*Gnus Help Bug*" 0.5)
942 ("*Gnus Bug*" 1.0 point
)))
946 (message 1.0 point
))))
947 "Window configuration for all possible Gnus buffers.
948 This variable is a list of lists. Each of these lists has a NAME and
949 a RULE. The NAMEs are commonsense names like `group', which names a
950 rule used when displaying the group buffer; `summary', which names a
951 rule for what happens when you enter a group and do not display an
952 article buffer; and so on. See the value of this variable for a
953 complete list of NAMEs.
955 Each RULE is a list of vectors. The first element in this vector is
956 the name of the buffer to be displayed; the second element is the
957 percentage of the screen this buffer is to occupy (a number in the
958 0.0-0.99 range); the optional third element is `point', which should
959 be present to denote which buffer point is to go to after making this
960 buffer configuration.")
962 (defvar gnus-window-to-buffer
963 '((group . gnus-group-buffer
)
964 (summary . gnus-summary-buffer
)
965 (article . gnus-article-buffer
)
966 (server . gnus-server-buffer
)
967 (browse .
"*Gnus Browse Server*")
968 (edit-group . gnus-group-edit-buffer
)
969 (edit-server . gnus-server-edit-buffer
)
970 (group-carpal . gnus-carpal-group-buffer
)
971 (summary-carpal . gnus-carpal-summary-buffer
)
972 (server-carpal . gnus-carpal-server-buffer
)
973 (browse-carpal . gnus-carpal-browse-buffer
)
974 (edit-score . gnus-score-edit-buffer
)
975 (message . gnus-message-buffer
)
976 (mail . gnus-message-buffer
)
977 (post-news . gnus-message-buffer
)
978 (faq . gnus-faq-buffer
)
979 (picons .
"*Picons*")
980 (tree . gnus-tree-buffer
)
981 (info . gnus-info-buffer
)
982 (article-copy . gnus-article-copy
)
983 (draft . gnus-draft-buffer
))
984 "Mapping from short symbols to buffer names or buffer variables.")
986 (defvar gnus-carpal nil
987 "*If non-nil, display clickable icons.")
989 (defvar gnus-subscribe-newsgroup-method
'gnus-subscribe-zombies
990 "*Function called with a group name when new group is detected.
991 A few pre-made functions are supplied: `gnus-subscribe-randomly'
992 inserts new groups at the beginning of the list of groups;
993 `gnus-subscribe-alphabetically' inserts new groups in strict
994 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
995 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
996 for your decision; `gnus-subscribe-killed' kills all new groups;
997 `gnus-subscribe-zombies' will make all new groups into zombies.")
999 ;; Suggested by a bug report by Hallvard B Furuseth.
1000 ;; <h.b.furuseth@usit.uio.no>.
1001 (defvar gnus-subscribe-options-newsgroup-method
1002 (function gnus-subscribe-alphabetically
)
1003 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1004 If, for instance, you want to subscribe to all newsgroups in the
1005 \"no\" and \"alt\" hierarchies, you'd put the following in your
1008 options -n no.all alt.all
1010 Gnus will the subscribe all new newsgroups in these hierarchies with
1011 the subscription method in this variable.")
1013 (defvar gnus-subscribe-hierarchical-interactive nil
1014 "*If non-nil, Gnus will offer to subscribe hierarchically.
1015 When a new hierarchy appears, Gnus will ask the user:
1017 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1019 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1020 subscribe to all newsgroups in the hierarchy and `s' will skip this
1021 hierarchy in its entirety.")
1023 (defvar gnus-group-sort-function
'gnus-group-sort-by-alphabet
1024 "*Function used for sorting the group buffer.
1025 This function will be called with group info entries as the arguments
1026 for the groups to be sorted. Pre-made functions include
1027 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1028 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1029 `gnus-group-sort-by-rank'.
1031 This variable can also be a list of sorting functions. In that case,
1032 the most significant sort function should be the last function in the
1035 ;; Mark variables suggested by Thomas Michanek
1036 ;; <Thomas.Michanek@telelogic.se>.
1037 (defvar gnus-unread-mark ?
1038 "*Mark used for unread articles.")
1039 (defvar gnus-ticked-mark ?
!
1040 "*Mark used for ticked articles.")
1041 (defvar gnus-dormant-mark ??
1042 "*Mark used for dormant articles.")
1043 (defvar gnus-del-mark ?r
1044 "*Mark used for del'd articles.")
1045 (defvar gnus-read-mark ?R
1046 "*Mark used for read articles.")
1047 (defvar gnus-expirable-mark ?E
1048 "*Mark used for expirable articles.")
1049 (defvar gnus-killed-mark ?K
1050 "*Mark used for killed articles.")
1051 (defvar gnus-souped-mark ?F
1052 "*Mark used for killed articles.")
1053 (defvar gnus-kill-file-mark ?X
1054 "*Mark used for articles killed by kill files.")
1055 (defvar gnus-low-score-mark ?Y
1056 "*Mark used for articles with a low score.")
1057 (defvar gnus-catchup-mark ?C
1058 "*Mark used for articles that are caught up.")
1059 (defvar gnus-replied-mark ?A
1060 "*Mark used for articles that have been replied to.")
1061 (defvar gnus-cached-mark ?
*
1062 "*Mark used for articles that are in the cache.")
1063 (defvar gnus-saved-mark ?S
1064 "*Mark used for articles that have been saved to.")
1065 (defvar gnus-process-mark ?
#
1067 (defvar gnus-ancient-mark ?O
1068 "*Mark used for ancient articles.")
1069 (defvar gnus-sparse-mark ?Q
1070 "*Mark used for sparsely reffed articles.")
1071 (defvar gnus-canceled-mark ?G
1072 "*Mark used for canceled articles.")
1073 (defvar gnus-score-over-mark ?
+
1074 "*Score mark used for articles with high scores.")
1075 (defvar gnus-score-below-mark ?-
1076 "*Score mark used for articles with low scores.")
1077 (defvar gnus-empty-thread-mark ?
1078 "*There is no thread under the article.")
1079 (defvar gnus-not-empty-thread-mark ?
=
1080 "*There is a thread under the article.")
1082 (defvar gnus-view-pseudo-asynchronously nil
1083 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1085 (defvar gnus-view-pseudos nil
1086 "*If `automatic', pseudo-articles will be viewed automatically.
1087 If `not-confirm', pseudos will be viewed automatically, and the user
1088 will not be asked to confirm the command.")
1090 (defvar gnus-view-pseudos-separately t
1091 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1092 If nil, all files that use the same viewing command will be given as a
1093 list of parameters to that command.")
1095 (defvar gnus-insert-pseudo-articles t
1096 "*If non-nil, insert pseudo-articles when decoding articles.")
1098 (defvar gnus-group-line-format
"%M%S%p%P%5y: %(%g%)%l\n"
1099 "*Format of group lines.
1100 It works along the same lines as a normal formatting string,
1101 with some simple extensions.
1103 %M Only marked articles (character, \"*\" or \" \")
1104 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1105 %L Level of subscribedness (integer)
1106 %N Number of unread articles (integer)
1107 %I Number of dormant articles (integer)
1108 %i Number of ticked and dormant (integer)
1109 %T Number of ticked articles (integer)
1110 %R Number of read articles (integer)
1111 %t Total number of articles (integer)
1112 %y Number of unread, unticked articles (integer)
1113 %G Group name (string)
1114 %g Qualified group name (string)
1115 %D Group description (string)
1116 %s Select method (string)
1117 %o Moderated group (char, \"m\")
1118 %p Process mark (char)
1119 %O Moderated group (string, \"(m)\" or \"\")
1120 %P Topic indentation (string)
1121 %l Whether there are GroupLens predictions for this group (string)
1122 %n Select from where (string)
1123 %z A string that look like `<%s:%n>' if a foreign select method is used
1124 %u User defined specifier. The next character in the format string should
1125 be a letter. Gnus will call the function gnus-user-format-function-X,
1126 where X is the letter following %u. The function will be passed the
1127 current header as argument. The function should return a string, which
1128 will be inserted into the buffer just like information from any other
1131 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1132 the mouse point move inside the area. There can only be one such area.
1134 Note that this format specification is not always respected. For
1135 reasons of efficiency, when listing killed groups, this specification
1136 is ignored altogether. If the spec is changed considerably, your
1137 output may end up looking strange when listing both alive and killed
1140 If you use %o or %O, reading the active file will be slower and quite
1141 a bit of extra memory will be used. %D will also worsen performance.
1142 Also note that if you change the format specification to include any
1143 of these specs, you must probably re-start Gnus to see them go into
1146 (defvar gnus-summary-line-format
"%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1147 "*The format specification of the lines in the summary buffer.
1149 It works along the same lines as a normal formatting string,
1150 with some simple extensions.
1152 %N Article number, left padded with spaces (string)
1154 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1155 %n Name of the poster (string)
1156 %a Extracted name of the poster (string)
1157 %A Extracted address of the poster (string)
1158 %F Contents of the From: header (string)
1159 %x Contents of the Xref: header (string)
1160 %D Date of the article (string)
1161 %d Date of the article (string) in DD-MMM format
1162 %M Message-id of the article (string)
1163 %r References of the article (string)
1164 %c Number of characters in the article (integer)
1165 %L Number of lines in the article (integer)
1166 %I Indentation based on thread level (a string of spaces)
1167 %T A string with two possible values: 80 spaces if the article
1168 is on thread level two or larger and 0 spaces on level one
1169 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1170 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1171 %[ Opening bracket (character, \"[\" or \"<\")
1172 %] Closing bracket (character, \"]\" or \">\")
1173 %> Spaces of length thread-level (string)
1174 %< Spaces of length (- 20 thread-level) (string)
1175 %i Article score (number)
1176 %z Article zcore (character)
1177 %t Number of articles under the current thread (number).
1178 %e Whether the thread is empty or not (character).
1179 %l GroupLens score (string).
1180 %u User defined specifier. The next character in the format string should
1181 be a letter. Gnus will call the function gnus-user-format-function-X,
1182 where X is the letter following %u. The function will be passed the
1183 current header as argument. The function should return a string, which
1184 will be inserted into the summary just like information from any other
1187 Text between %( and %) will be highlighted with `gnus-mouse-face'
1188 when the mouse point is placed inside the area. There can only be one
1191 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1192 with care. For reasons of efficiency, Gnus will compute what column
1193 these characters will end up in, and \"hard-code\" that. This means that
1194 it is illegal to have these specs after a variable-length spec. Well,
1195 you might not be arrested, but your summary buffer will look strange,
1196 which is bad enough.
1198 The smart choice is to have these specs as for to the left as
1201 This restriction may disappear in later versions of Gnus.")
1203 (defvar gnus-summary-dummy-line-format
1205 "*The format specification for the dummy roots in the summary buffer.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions.
1211 (defvar gnus-summary-mode-line-format
"Gnus: %%b [%A] %Z"
1212 "*The format specification for the summary mode line.
1213 It works along the same lines as a normal formatting string,
1214 with some simple extensions:
1217 %p Unprefixed group name
1218 %A Current article number
1220 %U Number of unread articles in the group
1221 %e Number of unselected articles in the group
1222 %Z A string with unread/unselected article counts
1223 %g Shortish group name
1224 %S Subject of the current article
1225 %u User-defined spec
1226 %s Current score file name
1227 %d Number of dormant articles
1228 %r Number of articles that have been marked as read in this session
1229 %E Number of articles expunged by the score files")
1231 (defvar gnus-article-mode-line-format
"Gnus: %%b %S"
1232 "*The format specification for the article mode line.
1233 See `gnus-summary-mode-line-format' for a closer description.")
1235 (defvar gnus-group-mode-line-format
"Gnus: %%b {%M%:%S}"
1236 "*The format specification for the group mode line.
1237 It works along the same lines as a normal formatting string,
1238 with some simple extensions:
1240 %S The native news server.
1241 %M The native select method.
1242 %: \":\" if %S isn't \"\".")
1244 (defvar gnus-valid-select-methods
1245 '(("nntp" post address prompt-address
)
1246 ("nnspool" post address
)
1247 ("nnvirtual" post-mail virtual prompt-address
)
1248 ("nnmbox" mail respool address
)
1249 ("nnml" mail respool address
)
1250 ("nnmh" mail respool address
)
1251 ("nndir" post-mail prompt-address address
)
1252 ("nneething" none address prompt-address
)
1253 ("nndoc" none address prompt-address
)
1254 ("nnbabyl" mail address respool
)
1255 ("nnkiboze" post virtual
)
1256 ("nnsoup" post-mail address
)
1257 ("nndraft" post-mail
)
1258 ("nnfolder" mail respool address
))
1259 "An alist of valid select methods.
1260 The first element of each list lists should be a string with the name
1261 of the select method. The other elements may be be the category of
1262 this method (ie. `post', `mail', `none' or whatever) or other
1263 properties that this method has (like being respoolable).
1264 If you implement a new select method, all you should have to change is
1265 this variable. I think.")
1267 (defvar gnus-updated-mode-lines
'(group article summary tree
)
1268 "*List of buffers that should update their mode lines.
1269 The list may contain the symbols `group', `article' and `summary'. If
1270 the corresponding symbol is present, Gnus will keep that mode line
1271 updated with information that may be pertinent.
1272 If this variable is nil, screen refresh may be quicker.")
1274 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1275 (defvar gnus-mode-non-string-length nil
1276 "*Max length of mode-line non-string contents.
1277 If this is nil, Gnus will take space as is needed, leaving the rest
1278 of the modeline intact.")
1281 ;(defvar gnus-mouse-face 'highlight
1282 ; "*Face used for mouse highlighting in Gnus.
1283 ;No mouse highlights will be done if `gnus-visual' is nil.")
1285 (defvar gnus-summary-mark-below
0
1286 "*Mark all articles with a score below this variable as read.
1287 This variable is local to each summary buffer and usually set by the
1290 (defvar gnus-article-sort-functions
'(gnus-article-sort-by-number)
1291 "*List of functions used for sorting articles in the summary buffer.
1292 This variable is only used when not using a threaded display.")
1294 (defvar gnus-thread-sort-functions
'(gnus-thread-sort-by-number)
1295 "*List of functions used for sorting threads in the summary buffer.
1296 By default, threads are sorted by article number.
1298 Each function takes two threads and return non-nil if the first thread
1299 should be sorted before the other. If you use more than one function,
1300 the primary sort function should be the last. You should probably
1301 always include `gnus-thread-sort-by-number' in the list of sorting
1302 functions -- preferably first.
1304 Ready-mady functions include `gnus-thread-sort-by-number',
1305 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1306 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1307 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1309 (defvar gnus-thread-score-function
'+
1310 "*Function used for calculating the total score of a thread.
1312 The function is called with the scores of the article and each
1313 subthread and should then return the score of the thread.
1315 Some functions you can use are `+', `max', or `min'.")
1317 (defvar gnus-summary-expunge-below nil
1318 "All articles that have a score less than this variable will be expunged.")
1320 (defvar gnus-thread-expunge-below nil
1321 "All threads that have a total score less than this variable will be expunged.
1322 See `gnus-thread-score-function' for en explanation of what a
1323 \"thread score\" is.")
1325 (defvar gnus-auto-subscribed-groups
1326 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1327 "*All new groups that match this regexp will be subscribed automatically.
1328 Note that this variable only deals with new groups. It has no effect
1329 whatsoever on old groups.
1331 New groups that match this regexp will not be handled by
1332 `gnus-subscribe-newsgroup-method'. Instead, they will
1333 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1335 (defvar gnus-options-subscribe nil
1336 "*All new groups matching this regexp will be subscribed unconditionally.
1337 Note that this variable deals only with new newsgroups. This variable
1338 does not affect old newsgroups.
1340 New groups that match this regexp will not be handled by
1341 `gnus-subscribe-newsgroup-method'. Instead, they will
1342 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1344 (defvar gnus-options-not-subscribe nil
1345 "*All new groups matching this regexp will be ignored.
1346 Note that this variable deals only with new newsgroups. This variable
1347 does not affect old (already subscribed) newsgroups.")
1349 (defvar gnus-auto-expirable-newsgroups nil
1350 "*Groups in which to automatically mark read articles as expirable.
1351 If non-nil, this should be a regexp that should match all groups in
1352 which to perform auto-expiry. This only makes sense for mail groups.")
1354 (defvar gnus-total-expirable-newsgroups nil
1355 "*Groups in which to perform expiry of all read articles.
1356 Use with extreme caution. All groups that match this regexp will be
1357 expiring - which means that all read articles will be deleted after
1358 (say) one week. (This only goes for mail groups and the like, of
1361 (defvar gnus-group-uncollapsed-levels
1
1362 "Number of group name elements to leave alone when making a short group name.")
1364 (defvar gnus-hidden-properties
'(invisible t intangible t
)
1365 "Property list to use for hiding text.")
1367 (defvar gnus-modtime-botch nil
1368 "*Non-nil means .newsrc should be deleted prior to save.
1369 Its use is due to the bogus appearance that .newsrc was modified on
1374 (defvar gnus-group-mode-hook nil
1375 "*A hook for Gnus group mode.")
1377 (defvar gnus-summary-mode-hook nil
1378 "*A hook for Gnus summary mode.
1379 This hook is run before any variables are set in the summary buffer.")
1381 (defvar gnus-article-mode-hook nil
1382 "*A hook for Gnus article mode.")
1384 (defvar gnus-summary-prepare-exit-hook nil
1385 "*A hook called when preparing to exit from the summary buffer.
1386 It calls `gnus-summary-expire-articles' by default.")
1387 (add-hook 'gnus-summary-prepare-exit-hook
'gnus-summary-expire-articles
)
1389 (defvar gnus-summary-exit-hook nil
1390 "*A hook called on exit from the summary buffer.")
1392 (defvar gnus-group-catchup-group-hook nil
1393 "*A hook run when catching up a group from the group buffer.")
1395 (defvar gnus-group-update-group-hook nil
1396 "*A hook called when updating group lines.")
1398 (defvar gnus-open-server-hook nil
1399 "*A hook called just before opening connection to the news server.")
1401 (defvar gnus-load-hook nil
1402 "*A hook run while Gnus is loaded.")
1404 (defvar gnus-startup-hook nil
1405 "*A hook called at startup.
1406 This hook is called after Gnus is connected to the NNTP server.")
1408 (defvar gnus-get-new-news-hook nil
1409 "*A hook run just before Gnus checks for new news.")
1411 (defvar gnus-after-getting-new-news-hook nil
1412 "*A hook run after Gnus checks for new news.")
1414 (defvar gnus-group-prepare-function
'gnus-group-prepare-flat
1415 "*A function that is called to generate the group buffer.
1416 The function is called with three arguments: The first is a number;
1417 all group with a level less or equal to that number should be listed,
1418 if the second is non-nil, empty groups should also be displayed. If
1419 the third is non-nil, it is a number. No groups with a level lower
1420 than this number should be displayed.
1422 The only current function implemented is `gnus-group-prepare-flat'.")
1424 (defvar gnus-group-prepare-hook nil
1425 "*A hook called after the group buffer has been generated.
1426 If you want to modify the group buffer, you can use this hook.")
1428 (defvar gnus-summary-prepare-hook nil
1429 "*A hook called after the summary buffer has been generated.
1430 If you want to modify the summary buffer, you can use this hook.")
1432 (defvar gnus-summary-generate-hook nil
1433 "*A hook run just before generating the summary buffer.
1434 This hook is commonly used to customize threading variables and the
1437 (defvar gnus-article-prepare-hook nil
1438 "*A hook called after an article has been prepared in the article buffer.
1439 If you want to run a special decoding program like nkf, use this hook.")
1441 ;(defvar gnus-article-display-hook nil
1442 ; "*A hook called after the article is displayed in the article buffer.
1443 ;The hook is designed to change the contents of the article
1444 ;buffer. Typical functions that this hook may contain are
1445 ;`gnus-article-hide-headers' (hide selected headers),
1446 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1447 ;`gnus-article-hide-signature' (hide signature) and
1448 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1449 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1450 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1451 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1453 (defvar gnus-article-x-face-too-ugly nil
1454 "Regexp matching posters whose face shouldn't be shown automatically.")
1456 (defvar gnus-select-group-hook nil
1457 "*A hook called when a newsgroup is selected.
1459 If you'd like to simplify subjects like the
1460 `gnus-summary-next-same-subject' command does, you can use the
1463 (setq gnus-select-group-hook
1466 (mapcar (lambda (header)
1467 (mail-header-set-subject
1469 (gnus-simplify-subject
1470 (mail-header-subject header) 're-only)))
1471 gnus-newsgroup-headers))))")
1473 (defvar gnus-select-article-hook nil
1474 "*A hook called when an article is selected.")
1476 (defvar gnus-apply-kill-hook
'(gnus-apply-kill-file)
1477 "*A hook called to apply kill files to a group.
1478 This hook is intended to apply a kill file to the selected newsgroup.
1479 The function `gnus-apply-kill-file' is called by default.
1481 Since a general kill file is too heavy to use only for a few
1482 newsgroups, I recommend you to use a lighter hook function. For
1483 example, if you'd like to apply a kill file to articles which contains
1484 a string `rmgroup' in subject in newsgroup `control', you can use the
1487 (setq gnus-apply-kill-hook
1490 (cond ((string-match \"control\" gnus-newsgroup-name)
1491 (gnus-kill \"Subject\" \"rmgroup\")
1492 (gnus-expunge \"X\"))))))")
1494 (defvar gnus-visual-mark-article-hook
1495 (list 'gnus-highlight-selected-summary
)
1496 "*Hook run after selecting an article in the summary buffer.
1497 It is meant to be used for highlighting the article in some way. It
1498 is not run if `gnus-visual' is nil.")
1500 (defvar gnus-parse-headers-hook nil
1501 "*A hook called before parsing the headers.")
1502 (add-hook 'gnus-parse-headers-hook
'gnus-decode-rfc1522
)
1504 (defvar gnus-exit-group-hook nil
1505 "*A hook called when exiting (not quitting) summary mode.")
1507 (defvar gnus-suspend-gnus-hook nil
1508 "*A hook called when suspending (not exiting) Gnus.")
1510 (defvar gnus-exit-gnus-hook nil
1511 "*A hook called when exiting Gnus.")
1513 (defvar gnus-after-exiting-gnus-hook nil
1514 "*A hook called after exiting Gnus.")
1516 (defvar gnus-save-newsrc-hook nil
1517 "*A hook called before saving any of the newsrc files.")
1519 (defvar gnus-save-quick-newsrc-hook nil
1520 "*A hook called just before saving the quick newsrc file.
1521 Can be used to turn version control on or off.")
1523 (defvar gnus-save-standard-newsrc-hook nil
1524 "*A hook called just before saving the standard newsrc file.
1525 Can be used to turn version control on or off.")
1527 (defvar gnus-summary-update-hook
1528 (list 'gnus-summary-highlight-line
)
1529 "*A hook called when a summary line is changed.
1530 The hook will not be called if `gnus-visual' is nil.
1532 The default function `gnus-summary-highlight-line' will
1533 highlight the line according to the `gnus-summary-highlight'
1536 (defvar gnus-group-update-hook
'(gnus-group-highlight-line)
1537 "*A hook called when a group line is changed.
1538 The hook will not be called if `gnus-visual' is nil.
1540 The default function `gnus-group-highlight-line' will
1541 highlight the line according to the `gnus-group-highlight'
1544 (defvar gnus-mark-article-hook
'(gnus-summary-mark-read-and-unread-as-read)
1545 "*A hook called when an article is selected for the first time.
1546 The hook is intended to mark an article as read (or unread)
1547 automatically when it is selected.")
1549 (defvar gnus-group-change-level-function nil
1550 "Function run when a group level is changed.
1551 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1553 ;; Remove any hilit infestation.
1554 (add-hook 'gnus-startup-hook
1556 (remove-hook 'gnus-summary-prepare-hook
1557 'hilit-rehighlight-buffer-quietly
)
1558 (remove-hook 'gnus-summary-prepare-hook
'hilit-install-line-hooks
)
1559 (setq gnus-mark-article-hook
1560 '(gnus-summary-mark-read-and-unread-as-read))
1561 (remove-hook 'gnus-article-prepare-hook
1562 'hilit-rehighlight-buffer-quietly
)))
1565 ;; Internal variables
1567 (defvar gnus-tree-buffer
"*Tree*"
1568 "Buffer where Gnus thread trees are displayed.")
1571 (defvar gnus-use-generic-from nil
)
1573 (defvar gnus-thread-indent-array nil
)
1574 (defvar gnus-thread-indent-array-level gnus-thread-indent-level
)
1576 (defvar gnus-newsrc-file-version nil
)
1578 (defvar gnus-method-history nil
)
1579 ;; Variable holding the user answers to all method prompts.
1581 (defvar gnus-group-history nil
)
1582 ;; Variable holding the user answers to all group prompts.
1584 (defvar gnus-server-alist nil
1585 "List of available servers.")
1587 (defvar gnus-group-indentation-function nil
)
1589 (defvar gnus-topic-indentation
"") ;; Obsolete variable.
1591 (defvar gnus-goto-missing-group-function nil
)
1593 (defvar gnus-override-subscribe-method nil
)
1595 (defvar gnus-group-goto-next-group-function nil
1596 "Function to override finding the next group after listing groups.")
1598 (defconst gnus-article-mark-lists
1599 '((marked . tick
) (replied . reply
)
1600 (expirable . expire
) (killed . killed
)
1601 (bookmarks . bookmark
) (dormant . dormant
)
1602 (scored . score
) (saved . save
)
1606 ;; Avoid highlighting in kill files.
1607 (defvar gnus-summary-inhibit-highlight nil
)
1608 (defvar gnus-newsgroup-selected-overlay nil
)
1610 (defvar gnus-inhibit-hiding nil
)
1611 (defvar gnus-group-indentation
"")
1612 (defvar gnus-inhibit-limiting nil
)
1613 (defvar gnus-created-frames nil
)
1615 (defvar gnus-article-mode-map nil
)
1616 (defvar gnus-dribble-buffer nil
)
1617 (defvar gnus-headers-retrieved-by nil
)
1618 (defvar gnus-article-reply nil
)
1619 (defvar gnus-override-method nil
)
1620 (defvar gnus-article-check-size nil
)
1622 (defvar gnus-current-score-file nil
)
1623 (defvar gnus-newsgroup-adaptive-score-file nil
)
1624 (defvar gnus-scores-exclude-files nil
)
1626 (defvar gnus-opened-servers nil
)
1628 (defvar gnus-current-move-group nil
)
1629 (defvar gnus-current-copy-group nil
)
1630 (defvar gnus-current-crosspost-group nil
)
1632 (defvar gnus-newsgroup-dependencies nil
)
1633 (defvar gnus-newsgroup-async nil
)
1634 (defconst gnus-group-edit-buffer
"*Gnus edit newsgroup*")
1636 (defvar gnus-newsgroup-adaptive nil
)
1638 (defvar gnus-summary-display-table nil
)
1639 (defvar gnus-summary-display-article-function nil
)
1641 (defvar gnus-summary-highlight-line-function nil
1642 "Function called after highlighting a summary line.")
1644 (defvar gnus-group-line-format-alist
1645 `((?M gnus-tmp-marked-mark ?c
)
1646 (?S gnus-tmp-subscribed ?c
)
1647 (?L gnus-tmp-level ?d
)
1648 (?N
(cond ((eq number t
) "*" )
1652 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
1653 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))))))
1655 (?R gnus-tmp-number-of-read ?s
)
1656 (?t gnus-tmp-number-total ?d
)
1657 (?y gnus-tmp-number-of-unread ?s
)
1658 (?I
(gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
))) ?d
)
1659 (?T
(gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))) ?d
)
1660 (?i
(+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
1661 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
)))) ?d
)
1662 (?g gnus-tmp-group ?s
)
1663 (?G gnus-tmp-qualified-group ?s
)
1664 (?c
(gnus-short-group-name gnus-tmp-group
) ?s
)
1665 (?D gnus-tmp-newsgroup-description ?s
)
1666 (?o gnus-tmp-moderated ?c
)
1667 (?O gnus-tmp-moderated-string ?s
)
1668 (?p gnus-tmp-process-marked ?c
)
1669 (?s gnus-tmp-news-server ?s
)
1670 (?n gnus-tmp-news-method ?s
)
1671 (?P gnus-group-indentation ?s
)
1672 (?l gnus-tmp-grouplens ?s
)
1673 (?z gnus-tmp-news-method-string ?s
)
1674 (?u gnus-tmp-user-defined ?s
)))
1676 (defvar gnus-summary-line-format-alist
1677 `((?N
,(macroexpand '(mail-header-number gnus-tmp-header
)) ?d
)
1678 (?S
,(macroexpand '(mail-header-subject gnus-tmp-header
)) ?s
)
1679 (?s gnus-tmp-subject-or-nil ?s
)
1680 (?n gnus-tmp-name ?s
)
1681 (?A
(car (cdr (funcall gnus-extract-address-components gnus-tmp-from
)))
1683 (?a
(or (car (funcall gnus-extract-address-components gnus-tmp-from
))
1685 (?F gnus-tmp-from ?s
)
1686 (?x
,(macroexpand '(mail-header-xref gnus-tmp-header
)) ?s
)
1687 (?D
,(macroexpand '(mail-header-date gnus-tmp-header
)) ?s
)
1688 (?d
(gnus-dd-mmm (mail-header-date gnus-tmp-header
)) ?s
)
1689 (?M
,(macroexpand '(mail-header-id gnus-tmp-header
)) ?s
)
1690 (?r
,(macroexpand '(mail-header-references gnus-tmp-header
)) ?s
)
1691 (?c
(or (mail-header-chars gnus-tmp-header
) 0) ?d
)
1692 (?L gnus-tmp-lines ?d
)
1693 (?I gnus-tmp-indentation ?s
)
1694 (?T
(if (= gnus-tmp-level
0) "" (make-string (frame-width) ?
)) ?s
)
1695 (?R gnus-tmp-replied ?c
)
1696 (?\
[ gnus-tmp-opening-bracket ?c
)
1697 (?\
] gnus-tmp-closing-bracket ?c
)
1698 (?\
> (make-string gnus-tmp-level ?
) ?s
)
1699 (?\
< (make-string (max 0 (- 20 gnus-tmp-level
)) ?
) ?s
)
1700 (?i gnus-tmp-score ?d
)
1701 (?z gnus-tmp-score-char ?c
)
1702 (?l
(bbb-grouplens-score gnus-tmp-header
) ?s
)
1703 (?V
(gnus-thread-total-score (and (boundp 'thread
) (car thread
))) ?d
)
1704 (?U gnus-tmp-unread ?c
)
1705 (?t
(gnus-summary-number-of-articles-in-thread
1706 (and (boundp 'thread
) (car thread
)) gnus-tmp-level
)
1708 (?e
(gnus-summary-number-of-articles-in-thread
1709 (and (boundp 'thread
) (car thread
)) gnus-tmp-level t
)
1711 (?u gnus-tmp-user-defined ?s
))
1712 "An alist of format specifications that can appear in summary lines,
1713 and what variables they correspond with, along with the type of the
1714 variable (string, integer, character, etc).")
1716 (defvar gnus-summary-dummy-line-format-alist
1717 `((?S gnus-tmp-subject ?s
)
1718 (?N gnus-tmp-number ?d
)
1719 (?u gnus-tmp-user-defined ?s
)))
1721 (defvar gnus-summary-mode-line-format-alist
1722 `((?G gnus-tmp-group-name ?s
)
1723 (?g
(gnus-short-group-name gnus-tmp-group-name
) ?s
)
1724 (?p
(gnus-group-real-name gnus-tmp-group-name
) ?s
)
1725 (?A gnus-tmp-article-number ?d
)
1726 (?Z gnus-tmp-unread-and-unselected ?s
)
1727 (?V gnus-version ?s
)
1728 (?U gnus-tmp-unread-and-unticked ?d
)
1729 (?S gnus-tmp-subject ?s
)
1730 (?e gnus-tmp-unselected ?d
)
1731 (?u gnus-tmp-user-defined ?s
)
1732 (?d
(length gnus-newsgroup-dormant
) ?d
)
1733 (?t
(length gnus-newsgroup-marked
) ?d
)
1734 (?r
(length gnus-newsgroup-reads
) ?d
)
1735 (?E gnus-newsgroup-expunged-tally ?d
)
1736 (?s
(gnus-current-score-file-nondirectory) ?s
)))
1738 (defvar gnus-article-mode-line-format-alist
1739 gnus-summary-mode-line-format-alist
)
1741 (defvar gnus-group-mode-line-format-alist
1742 `((?S gnus-tmp-news-server ?s
)
1743 (?M gnus-tmp-news-method ?s
)
1744 (?u gnus-tmp-user-defined ?s
)
1745 (?
: gnus-tmp-colon ?s
)))
1747 (defvar gnus-have-read-active-file nil
)
1749 (defconst gnus-maintainer
1750 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1751 "The mail address of the Gnus maintainers.")
1753 (defconst gnus-version-number
"5.3"
1754 "Version number for this version of Gnus.")
1756 (defconst gnus-version
(format "Gnus v%s" gnus-version-number
)
1757 "Version string for this version of Gnus.")
1759 (defvar gnus-info-nodes
1760 '((gnus-group-mode "(gnus)The Group Buffer")
1761 (gnus-summary-mode "(gnus)The Summary Buffer")
1762 (gnus-article-mode "(gnus)The Article Buffer")
1763 (gnus-server-mode "(gnus)The Server Buffer")
1764 (gnus-browse-mode "(gnus)Browse Foreign Server")
1765 (gnus-tree-mode "(gnus)Tree Display")
1767 "Alist of major modes and related Info nodes.")
1769 (defvar gnus-group-buffer
"*Group*")
1770 (defvar gnus-summary-buffer
"*Summary*")
1771 (defvar gnus-article-buffer
"*Article*")
1772 (defvar gnus-server-buffer
"*Server*")
1774 (defvar gnus-work-buffer
" *gnus work*")
1776 (defvar gnus-original-article-buffer
" *Original Article*")
1777 (defvar gnus-original-article nil
)
1779 (defvar gnus-buffer-list nil
1780 "Gnus buffers that should be killed on exit.")
1782 (defvar gnus-slave nil
1783 "Whether this Gnus is a slave or not.")
1785 (defvar gnus-variable-list
1786 '(gnus-newsrc-options gnus-newsrc-options-n
1787 gnus-newsrc-last-checked-date
1788 gnus-newsrc-alist gnus-server-alist
1789 gnus-killed-list gnus-zombie-list
1790 gnus-topic-topology gnus-topic-alist
1792 "Gnus variables saved in the quick startup file.")
1794 (defvar gnus-newsrc-options nil
1795 "Options line in the .newsrc file.")
1797 (defvar gnus-newsrc-options-n nil
1798 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1800 (defvar gnus-newsrc-last-checked-date nil
1801 "Date Gnus last asked server for new newsgroups.")
1803 (defvar gnus-topic-topology nil
1804 "The complete topic hierarchy.")
1806 (defvar gnus-topic-alist nil
1807 "The complete topic-group alist.")
1809 (defvar gnus-newsrc-alist nil
1810 "Assoc list of read articles.
1811 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1813 (defvar gnus-newsrc-hashtb nil
1814 "Hashtable of gnus-newsrc-alist.")
1816 (defvar gnus-killed-list nil
1817 "List of killed newsgroups.")
1819 (defvar gnus-killed-hashtb nil
1820 "Hash table equivalent of gnus-killed-list.")
1822 (defvar gnus-zombie-list nil
1823 "List of almost dead newsgroups.")
1825 (defvar gnus-description-hashtb nil
1826 "Descriptions of newsgroups.")
1828 (defvar gnus-list-of-killed-groups nil
1829 "List of newsgroups that have recently been killed by the user.")
1831 (defvar gnus-active-hashtb nil
1832 "Hashtable of active articles.")
1834 (defvar gnus-moderated-list nil
1835 "List of moderated newsgroups.")
1837 (defvar gnus-group-marked nil
)
1839 (defvar gnus-current-startup-file nil
1840 "Startup file for the current host.")
1842 (defvar gnus-last-search-regexp nil
1843 "Default regexp for article search command.")
1845 (defvar gnus-last-shell-command nil
1846 "Default shell command on article.")
1848 (defvar gnus-current-select-method nil
1849 "The current method for selecting a newsgroup.")
1851 (defvar gnus-group-list-mode nil
)
1853 (defvar gnus-article-internal-prepare-hook nil
)
1855 (defvar gnus-newsgroup-name nil
)
1856 (defvar gnus-newsgroup-begin nil
)
1857 (defvar gnus-newsgroup-end nil
)
1858 (defvar gnus-newsgroup-last-rmail nil
)
1859 (defvar gnus-newsgroup-last-mail nil
)
1860 (defvar gnus-newsgroup-last-folder nil
)
1861 (defvar gnus-newsgroup-last-file nil
)
1862 (defvar gnus-newsgroup-auto-expire nil
)
1863 (defvar gnus-newsgroup-active nil
)
1865 (defvar gnus-newsgroup-data nil
)
1866 (defvar gnus-newsgroup-data-reverse nil
)
1867 (defvar gnus-newsgroup-limit nil
)
1868 (defvar gnus-newsgroup-limits nil
)
1870 (defvar gnus-newsgroup-unreads nil
1871 "List of unread articles in the current newsgroup.")
1873 (defvar gnus-newsgroup-unselected nil
1874 "List of unselected unread articles in the current newsgroup.")
1876 (defvar gnus-newsgroup-reads nil
1877 "Alist of read articles and article marks in the current newsgroup.")
1879 (defvar gnus-newsgroup-expunged-tally nil
)
1881 (defvar gnus-newsgroup-marked nil
1882 "List of ticked articles in the current newsgroup (a subset of unread art).")
1884 (defvar gnus-newsgroup-killed nil
1885 "List of ranges of articles that have been through the scoring process.")
1887 (defvar gnus-newsgroup-cached nil
1888 "List of articles that come from the article cache.")
1890 (defvar gnus-newsgroup-saved nil
1891 "List of articles that have been saved.")
1893 (defvar gnus-newsgroup-kill-headers nil
)
1895 (defvar gnus-newsgroup-replied nil
1896 "List of articles that have been replied to in the current newsgroup.")
1898 (defvar gnus-newsgroup-expirable nil
1899 "List of articles in the current newsgroup that can be expired.")
1901 (defvar gnus-newsgroup-processable nil
1902 "List of articles in the current newsgroup that can be processed.")
1904 (defvar gnus-newsgroup-bookmarks nil
1905 "List of articles in the current newsgroup that have bookmarks.")
1907 (defvar gnus-newsgroup-dormant nil
1908 "List of dormant articles in the current newsgroup.")
1910 (defvar gnus-newsgroup-scored nil
1911 "List of scored articles in the current newsgroup.")
1913 (defvar gnus-newsgroup-headers nil
1914 "List of article headers in the current newsgroup.")
1916 (defvar gnus-newsgroup-threads nil
)
1918 (defvar gnus-newsgroup-prepared nil
1919 "Whether the current group has been prepared properly.")
1921 (defvar gnus-newsgroup-ancient nil
1922 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1924 (defvar gnus-newsgroup-sparse nil
)
1926 (defvar gnus-current-article nil
)
1927 (defvar gnus-article-current nil
)
1928 (defvar gnus-current-headers nil
)
1929 (defvar gnus-have-all-headers nil
)
1930 (defvar gnus-last-article nil
)
1931 (defvar gnus-newsgroup-history nil
)
1932 (defvar gnus-current-kill-article nil
)
1934 ;; Save window configuration.
1935 (defvar gnus-prev-winconf nil
)
1937 (defvar gnus-summary-mark-positions nil
)
1938 (defvar gnus-group-mark-positions nil
)
1940 (defvar gnus-reffed-article-number nil
)
1942 ;;; Let the byte-compiler know that we know about this variable.
1943 (defvar rmail-default-rmail-file
)
1945 (defvar gnus-cache-removable-articles nil
)
1947 (defvar gnus-dead-summary nil
)
1949 (defconst gnus-summary-local-variables
1950 '(gnus-newsgroup-name
1951 gnus-newsgroup-begin gnus-newsgroup-end
1952 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1953 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1954 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1955 gnus-newsgroup-unselected gnus-newsgroup-marked
1956 gnus-newsgroup-reads gnus-newsgroup-saved
1957 gnus-newsgroup-replied gnus-newsgroup-expirable
1958 gnus-newsgroup-processable gnus-newsgroup-killed
1959 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1960 gnus-newsgroup-headers gnus-newsgroup-threads
1961 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1962 gnus-current-article gnus-current-headers gnus-have-all-headers
1963 gnus-last-article gnus-article-internal-prepare-hook
1964 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1965 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1966 gnus-newsgroup-async gnus-thread-expunge-below
1967 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1968 (gnus-summary-mark-below . global
)
1969 gnus-newsgroup-active gnus-scores-exclude-files
1970 gnus-newsgroup-history gnus-newsgroup-ancient
1971 gnus-newsgroup-sparse
1972 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring
)
1973 gnus-newsgroup-adaptive-score-file
1974 (gnus-newsgroup-expunged-tally .
0)
1975 gnus-cache-removable-articles gnus-newsgroup-cached
1976 gnus-newsgroup-data gnus-newsgroup-data-reverse
1977 gnus-newsgroup-limit gnus-newsgroup-limits
)
1978 "Variables that are buffer-local to the summary buffers.")
1980 (defconst gnus-bug-message
1981 "Sending a bug report to the Gnus Towers.
1982 ========================================
1984 The buffer below is a mail buffer. When you press `C-c C-c', it will
1985 be sent to the Gnus Bug Exterminators.
1987 At the bottom of the buffer you'll see lots of variable settings.
1988 Please do not delete those. They will tell the Bug People what your
1989 environment is, so that it will be easier to locate the bugs.
1991 If you have found a bug that makes Emacs go \"beep\", set
1992 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1993 and include the backtrace in your bug report.
1995 Please describe the bug in annoying, painstaking detail.
1997 Thank you for your help in stamping out bugs.
2000 ;;; End of variables.
2002 ;; Define some autoload functions Gnus might use.
2005 ;; This little mapcar goes through the list below and marks the
2006 ;; symbols in question as autoloaded functions.
2009 (let ((interactive (nth 1 (memq ':interactive package
))))
2013 (when (consp function
)
2014 (setq keymap
(car (memq 'keymap function
)))
2015 (setq function
(car function
)))
2016 (autoload function
(car package
) nil interactive keymap
)))
2017 (if (eq (nth 1 package
) ':interactive
)
2020 '(("metamail" metamail-buffer
)
2021 ("info" Info-goto-node
)
2022 ("hexl" hexl-hex-string-to-integer
)
2023 ("pp" pp pp-to-string pp-eval-expression
)
2024 ("mail-extr" mail-extract-address-components
)
2025 ("nnmail" nnmail-split-fancy nnmail-article-group
)
2026 ("nnvirtual" nnvirtual-catchup-group
)
2027 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2028 timezone-make-sortable-date timezone-make-time-string
)
2029 ("rmailout" rmail-output
)
2030 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2032 ("gnus-soup" :interactive t
2033 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2034 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet
)
2035 ("nnsoup" nnsoup-pack-replies
)
2036 ("score-mode" :interactive t gnus-score-mode
)
2037 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2038 gnus-Folder-save-name gnus-folder-save-name
)
2039 ("gnus-mh" :interactive t gnus-summary-save-in-folder
)
2040 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2041 gnus-server-make-menu-bar gnus-article-make-menu-bar
2042 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2043 gnus-summary-highlight-line gnus-carpal-setup-buffer
2044 gnus-group-highlight-line
2045 gnus-article-add-button gnus-insert-next-page-button
2046 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu
)
2047 ("gnus-vis" :interactive t
2048 gnus-article-push-button gnus-article-press-button
2049 gnus-article-highlight gnus-article-highlight-some
2050 gnus-article-highlight-headers gnus-article-highlight-signature
2051 gnus-article-add-buttons gnus-article-add-buttons-to-head
2052 gnus-article-next-button gnus-article-prev-button
)
2053 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2054 gnus-demon-add-disconnection gnus-demon-add-handler
2055 gnus-demon-remove-handler
)
2056 ("gnus-demon" :interactive t
2057 gnus-demon-init gnus-demon-cancel
)
2058 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2059 gnus-tree-open gnus-tree-close
)
2060 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2061 gnus-nocem-unwanted-article-p
)
2062 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info
)
2063 ("gnus-srvr" gnus-browse-foreign-server
)
2064 ("gnus-cite" :interactive t
2065 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2066 gnus-article-hide-citation gnus-article-fill-cited-article
2067 gnus-article-hide-citation-in-followups
)
2068 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2069 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2070 gnus-execute gnus-expunge
)
2071 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2072 gnus-cache-possibly-remove-articles gnus-cache-request-article
2073 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2074 gnus-cache-enter-remove-article gnus-cached-article-p
2075 gnus-cache-open gnus-cache-close gnus-cache-update-article
)
2076 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2077 gnus-cache-remove-article
)
2078 ("gnus-score" :interactive t
2079 gnus-summary-increase-score gnus-summary-lower-score
2080 gnus-score-flush-cache gnus-score-close
2081 gnus-score-raise-same-subject-and-select
2082 gnus-score-raise-same-subject gnus-score-default
2083 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2084 gnus-score-lower-same-subject gnus-score-lower-thread
2085 gnus-possibly-score-headers gnus-summary-raise-score
2086 gnus-summary-set-score gnus-summary-current-score
)
2088 (gnus-summary-score-map keymap
) gnus-score-save gnus-score-headers
2089 gnus-current-score-file-nondirectory gnus-score-adaptive
2090 gnus-score-find-trace gnus-score-file-name
)
2091 ("gnus-edit" :interactive t gnus-score-customize
)
2092 ("gnus-topic" :interactive t gnus-topic-mode
)
2093 ("gnus-topic" gnus-topic-remove-group
)
2094 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode
)
2095 ("gnus-uu" (gnus-uu-extract-map keymap
) (gnus-uu-mark-map keymap
))
2096 ("gnus-uu" :interactive t
2097 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2098 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2099 gnus-uu-mark-by-regexp gnus-uu-mark-all
2100 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2101 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2102 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2103 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2104 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2105 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2106 gnus-uu-decode-binhex-view
)
2107 ("gnus-msg" (gnus-summary-send-map keymap
)
2108 gnus-mail-yank-original gnus-mail-send-and-exit
2109 gnus-article-mail gnus-new-mail gnus-mail-reply
)
2110 ("gnus-msg" :interactive t
2111 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2112 gnus-summary-followup gnus-summary-followup-with-original
2113 gnus-summary-cancel-article gnus-summary-supersede-article
2114 gnus-post-news gnus-inews-news
2115 gnus-summary-reply gnus-summary-reply-with-original
2116 gnus-summary-mail-forward gnus-summary-mail-other-window
2118 ("gnus-picon" :interactive t gnus-article-display-picons
2119 gnus-group-display-picons gnus-picons-article-display-x-face
2120 gnus-picons-display-x-face
)
2121 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2122 gnus-grouplens-mode
)
2123 ("smiley" :interactive t gnus-smiley-display
)
2124 ("gnus-vm" gnus-vm-mail-setup
)
2125 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2126 gnus-summary-save-article-vm
))))
2130 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2131 ;; If you want the cursor to go somewhere else, set these two
2132 ;; functions in some startup hook to whatever you want.
2133 (defalias 'gnus-summary-position-point
'gnus-goto-colon
)
2134 (defalias 'gnus-group-position-point
'gnus-goto-colon
)
2136 ;;; Various macros and substs.
2138 (defun gnus-header-from (header)
2139 (mail-header-from header
))
2141 (defmacro gnus-eval-in-buffer-window
(buffer &rest forms
)
2142 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2143 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2144 (w (make-symbol "w"))
2145 (buf (make-symbol "buf")))
2146 `(let* ((,tempvar
(selected-window))
2148 (,w
(get-buffer-window ,buf
'visible
)))
2153 (pop-to-buffer ,buf
))
2155 (select-window ,tempvar
)))))
2157 (put 'gnus-eval-in-buffer-window
'lisp-indent-function
1)
2158 (put 'gnus-eval-in-buffer-window
'lisp-indent-hook
1)
2159 (put 'gnus-eval-in-buffer-window
'edebug-form-spec
'(form body
))
2161 (defmacro gnus-gethash
(string hashtable
)
2162 "Get hash value of STRING in HASHTABLE."
2163 `(symbol-value (intern-soft ,string
,hashtable
)))
2165 (defmacro gnus-sethash
(string value hashtable
)
2166 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2167 `(set (intern ,string
,hashtable
) ,value
))
2169 (defmacro gnus-intern-safe
(string hashtable
)
2170 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2171 `(let ((symbol (intern ,string
,hashtable
)))
2176 (defmacro gnus-group-unread
(group)
2177 "Get the currently computed number of unread articles in GROUP."
2178 `(car (gnus-gethash ,group gnus-newsrc-hashtb
)))
2180 (defmacro gnus-group-entry
(group)
2181 "Get the newsrc entry for GROUP."
2182 `(gnus-gethash ,group gnus-newsrc-hashtb
))
2184 (defmacro gnus-active
(group)
2185 "Get active info on GROUP."
2186 `(gnus-gethash ,group gnus-active-hashtb
))
2188 (defmacro gnus-set-active
(group active
)
2189 "Set GROUP's active info."
2190 `(gnus-sethash ,group
,active gnus-active-hashtb
))
2192 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2193 ;; function `substring' might cut on a middle of multi-octet
2195 (defun gnus-truncate-string (str width
)
2196 (substring str
0 width
))
2198 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2199 ;; to limit the length of a string. This function is necessary since
2200 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2201 (defsubst gnus-limit-string
(str width
)
2202 (if (> (length str
) width
)
2203 (substring str
0 width
)
2206 (defsubst gnus-simplify-subject-re
(subject)
2207 "Remove \"Re:\" from subject lines."
2208 (if (string-match "^[Rr][Ee]: *" subject
)
2209 (substring subject
(match-end 0))
2212 (defsubst gnus-functionp
(form)
2213 "Return non-nil if FORM is funcallable."
2214 (or (and (symbolp form
) (fboundp form
))
2215 (and (listp form
) (eq (car form
) 'lambda
))))
2217 (defsubst gnus-goto-char
(point)
2218 (and point
(goto-char point
)))
2220 (defmacro gnus-buffer-exists-p
(buffer)
2221 `(let ((buffer ,buffer
))
2223 (funcall (if (stringp buffer
) 'get-buffer
'buffer-name
)
2226 (defmacro gnus-kill-buffer
(buffer)
2227 `(let ((buf ,buffer
))
2228 (if (gnus-buffer-exists-p buf
)
2229 (kill-buffer buf
))))
2231 (defsubst gnus-point-at-bol
()
2232 "Return point at the beginning of the line."
2239 (defsubst gnus-point-at-eol
()
2240 "Return point at the end of the line."
2247 (defun gnus-alive-p ()
2248 "Say whether Gnus is running or not."
2249 (and gnus-group-buffer
2250 (get-buffer gnus-group-buffer
)))
2252 (defun gnus-delete-first (elt list
)
2253 "Delete by side effect the first occurrence of ELT as a member of LIST."
2254 (if (equal (car list
) elt
)
2257 (while (and (cdr list
)
2258 (not (equal (cadr list
) elt
)))
2259 (setq list
(cdr list
)))
2261 (setcdr list
(cddr list
)))
2264 ;; Delete the current line (and the next N lines.);
2265 (defmacro gnus-delete-line
(&optional n
)
2266 `(delete-region (progn (beginning-of-line) (point))
2267 (progn (forward-line ,(or n
1)) (point))))
2269 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2270 (defvar gnus-init-inhibit nil
)
2271 (defun gnus-read-init-file (&optional inhibit-next
)
2272 (if gnus-init-inhibit
2273 (setq gnus-init-inhibit nil
)
2274 (setq gnus-init-inhibit inhibit-next
)
2276 (or (and (file-exists-p gnus-init-file
)
2277 ;; Don't try to load a directory.
2278 (not (file-directory-p gnus-init-file
)))
2279 (file-exists-p (concat gnus-init-file
".el"))
2280 (file-exists-p (concat gnus-init-file
".elc")))
2282 (load gnus-init-file nil t
)
2284 (error "Error in %s: %s" gnus-init-file var
))))))
2286 ;; Info access macros.
2288 (defmacro gnus-info-group
(info)
2290 (defmacro gnus-info-rank
(info)
2292 (defmacro gnus-info-read
(info)
2294 (defmacro gnus-info-marks
(info)
2296 (defmacro gnus-info-method
(info)
2298 (defmacro gnus-info-params
(info)
2301 (defmacro gnus-info-level
(info)
2302 `(let ((rank (gnus-info-rank ,info
)))
2306 (defmacro gnus-info-score
(info)
2307 `(let ((rank (gnus-info-rank ,info
)))
2308 (or (and (consp rank
) (cdr rank
)) 0)))
2310 (defmacro gnus-info-set-group
(info group
)
2311 `(setcar ,info
,group
))
2312 (defmacro gnus-info-set-rank
(info rank
)
2313 `(setcar (nthcdr 1 ,info
) ,rank
))
2314 (defmacro gnus-info-set-read
(info read
)
2315 `(setcar (nthcdr 2 ,info
) ,read
))
2316 (defmacro gnus-info-set-marks
(info marks
)
2317 `(setcar (nthcdr 3 ,info
) ,marks
))
2318 (defmacro gnus-info-set-method
(info method
)
2319 `(setcar (nthcdr 4 ,info
) ,method
))
2320 (defmacro gnus-info-set-params
(info params
)
2321 `(setcar (nthcdr 5 ,info
) ,params
))
2323 (defmacro gnus-info-set-level
(info level
)
2324 `(let ((rank (cdr ,info
)))
2325 (if (consp (car rank
))
2326 (setcar (car rank
) ,level
)
2327 (setcar rank
,level
))))
2328 (defmacro gnus-info-set-score
(info score
)
2329 `(let ((rank (cdr ,info
)))
2330 (if (consp (car rank
))
2331 (setcdr (car rank
) ,score
)
2332 (setcar rank
(cons (car rank
) ,score
)))))
2334 (defmacro gnus-get-info
(group)
2335 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb
)))
2337 (defun gnus-byte-code (func)
2338 "Return a form that can be `eval'ed based on FUNC."
2339 (let ((fval (symbol-function func
)))
2340 (if (byte-code-function-p fval
)
2341 (let ((flist (append fval nil
)))
2342 (setcar flist
'byte-code
)
2344 (cons 'progn
(cddr fval
)))))
2346 ;; Find out whether the gnus-visual TYPE is wanted.
2347 (defun gnus-visual-p (&optional type class
)
2348 (and gnus-visual
; Has to be non-nil, at least.
2349 (if (not type
) ; We don't care about type.
2351 (if (listp gnus-visual
) ; It's a list, so we check it.
2352 (or (memq type gnus-visual
)
2353 (memq class gnus-visual
))
2356 ;;; Load the compatability functions.
2366 (defvar gnus-shutdown-alist nil
)
2368 (defun gnus-add-shutdown (function &rest symbols
)
2369 "Run FUNCTION whenever one of SYMBOLS is shut down."
2370 (push (cons function symbols
) gnus-shutdown-alist
))
2372 (defun gnus-shutdown (symbol)
2373 "Shut down everything that waits for SYMBOL."
2374 (let ((alist gnus-shutdown-alist
)
2376 (while (setq entry
(pop alist
))
2377 (when (memq symbol
(cdr entry
))
2378 (funcall (car entry
))))))
2382 ;; Format specs. The chunks below are the machine-generated forms
2383 ;; that are to be evaled as the result of the default format strings.
2384 ;; We write them in here to get them byte-compiled. That way the
2385 ;; default actions will be quite fast, while still retaining the full
2386 ;; flexibility of the user-defined format specs.
2388 ;; First we have lots of dummy defvars to let the compiler know these
2389 ;; are really dynamic variables.
2391 (defvar gnus-tmp-unread
)
2392 (defvar gnus-tmp-replied
)
2393 (defvar gnus-tmp-score-char
)
2394 (defvar gnus-tmp-indentation
)
2395 (defvar gnus-tmp-opening-bracket
)
2396 (defvar gnus-tmp-lines
)
2397 (defvar gnus-tmp-name
)
2398 (defvar gnus-tmp-closing-bracket
)
2399 (defvar gnus-tmp-subject-or-nil
)
2400 (defvar gnus-tmp-subject
)
2401 (defvar gnus-tmp-marked
)
2402 (defvar gnus-tmp-marked-mark
)
2403 (defvar gnus-tmp-subscribed
)
2404 (defvar gnus-tmp-process-marked
)
2405 (defvar gnus-tmp-number-of-unread
)
2406 (defvar gnus-tmp-group-name
)
2407 (defvar gnus-tmp-group
)
2408 (defvar gnus-tmp-article-number
)
2409 (defvar gnus-tmp-unread-and-unselected
)
2410 (defvar gnus-tmp-news-method
)
2411 (defvar gnus-tmp-news-server
)
2412 (defvar gnus-tmp-article-number
)
2413 (defvar gnus-mouse-face
)
2414 (defvar gnus-mouse-face-prop
)
2416 (defun gnus-summary-line-format-spec ()
2417 (insert gnus-tmp-unread gnus-tmp-replied
2418 gnus-tmp-score-char gnus-tmp-indentation
)
2419 (gnus-put-text-property
2423 gnus-tmp-opening-bracket
2424 (format "%4d: %-20s"
2426 (if (> (length gnus-tmp-name
) 20)
2427 (substring gnus-tmp-name
0 20)
2429 gnus-tmp-closing-bracket
)
2431 gnus-mouse-face-prop gnus-mouse-face
)
2432 (insert " " gnus-tmp-subject-or-nil
"\n"))
2434 (defvar gnus-summary-line-format-spec
2435 (gnus-byte-code 'gnus-summary-line-format-spec
))
2437 (defun gnus-summary-dummy-line-format-spec ()
2439 (gnus-put-text-property
2444 gnus-mouse-face-prop gnus-mouse-face
)
2445 (insert " " gnus-tmp-subject
"\n"))
2447 (defvar gnus-summary-dummy-line-format-spec
2448 (gnus-byte-code 'gnus-summary-dummy-line-format-spec
))
2450 (defun gnus-group-line-format-spec ()
2451 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2452 gnus-tmp-process-marked
2453 gnus-group-indentation
2454 (format "%5s: " gnus-tmp-number-of-unread
))
2455 (gnus-put-text-property
2458 (insert gnus-tmp-group
"\n")
2460 gnus-mouse-face-prop gnus-mouse-face
))
2461 (defvar gnus-group-line-format-spec
2462 (gnus-byte-code 'gnus-group-line-format-spec
))
2464 (defvar gnus-format-specs
2465 `((version .
,emacs-version
)
2466 (group ,gnus-group-line-format
,gnus-group-line-format-spec
)
2467 (summary-dummy ,gnus-summary-dummy-line-format
2468 ,gnus-summary-dummy-line-format-spec
)
2469 (summary ,gnus-summary-line-format
,gnus-summary-line-format-spec
)))
2471 (defvar gnus-article-mode-line-format-spec nil
)
2472 (defvar gnus-summary-mode-line-format-spec nil
)
2473 (defvar gnus-group-mode-line-format-spec nil
)
2475 ;;; Phew. All that gruft is over, fortunately.
2479 ;;; Gnus Utility Functions
2482 (defun gnus-extract-address-components (from)
2484 ;; First find the address - the thing with the @ in it. This may
2485 ;; not be accurate in mail addresses, but does the trick most of
2486 ;; the time in news messages.
2487 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from
)
2488 (setq address
(substring from
(match-beginning 0) (match-end 0))))
2489 ;; Then we check whether the "name <address>" format is used.
2491 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2492 ;; Linear white space is not required.
2493 (string-match (concat "[ \t]*<" (regexp-quote address
) ">") from
)
2494 (and (setq name
(substring from
0 (match-beginning 0)))
2495 ;; Strip any quotes from the name.
2496 (string-match "\".*\"" name
)
2497 (setq name
(substring name
1 (1- (match-end 0))))))
2498 ;; If not, then "address (name)" is used.
2500 (and (string-match "(.+)" from
)
2501 (setq name
(substring from
(1+ (match-beginning 0))
2502 (1- (match-end 0)))))
2503 (and (string-match "()" from
)
2504 (setq name address
))
2505 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2506 ;; XOVER might not support folded From headers.
2507 (and (string-match "(.*" from
)
2508 (setq name
(substring from
(1+ (match-beginning 0))
2510 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2511 (list (or name from
) (or address from
))))
2513 (defun gnus-fetch-field (field)
2514 "Return the value of the header FIELD of current article."
2517 (let ((case-fold-search t
)
2518 (inhibit-point-motion-hooks t
))
2519 (nnheader-narrow-to-headers)
2520 (message-fetch-field field
)))))
2522 (defun gnus-goto-colon ()
2524 (search-forward ":" (gnus-point-at-eol) t
))
2527 (defun gnus-update-format (var)
2528 "Update the format specification near point."
2533 ;; Find the end of the current word.
2534 (re-search-forward "[ \t\n]" nil t
)
2536 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t
)
2537 (match-string 1)))))
2538 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var
)
2539 (match-string 1 var
))))
2540 (entry (assq type gnus-format-specs
))
2543 (setq gnus-format-specs
(delq entry gnus-format-specs
)))
2545 (intern (format "%s-spec" var
))
2546 (gnus-parse-format (setq value
(symbol-value (intern var
)))
2547 (symbol-value (intern (format "%s-alist" var
)))
2548 (not (string-match "mode" var
))))
2549 (setq spec
(symbol-value (intern (format "%s-spec" var
))))
2550 (push (list type value spec
) gnus-format-specs
)
2552 (pop-to-buffer "*Gnus Format*")
2554 (lisp-interaction-mode)
2555 (insert (pp-to-string spec
))))
2557 (defun gnus-update-format-specifications (&optional force
)
2558 "Update all (necessary) format specifications."
2559 ;; Make the indentation array.
2560 (gnus-make-thread-indent-array)
2562 ;; See whether all the stored info needs to be flushed.
2564 (not (equal emacs-version
2565 (cdr (assq 'version gnus-format-specs
)))))
2566 (setq gnus-format-specs nil
))
2568 ;; Go through all the formats and see whether they need updating.
2569 (let ((types '(summary summary-dummy group
2570 summary-mode group-mode article-mode
))
2571 new-format entry type val
)
2572 (while (setq type
(pop types
))
2573 ;; Jump to the proper buffer to find out the value of
2574 ;; the variable, if possible. (It may be buffer-local.)
2576 (let ((buffer (intern (format "gnus-%s-buffer" type
)))
2578 (when (and (boundp buffer
)
2579 (setq val
(symbol-value buffer
))
2581 (buffer-name (get-buffer val
)))
2582 (set-buffer (get-buffer val
)))
2583 (setq new-format
(symbol-value
2584 (intern (format "gnus-%s-line-format" type
))))))
2585 (setq entry
(cdr (assq type gnus-format-specs
)))
2587 (equal (car entry
) new-format
))
2588 ;; Use the old format.
2589 (set (intern (format "gnus-%s-line-format-spec" type
))
2591 ;; This is a new format.
2593 (if (not (stringp new-format
))
2594 ;; This is a function call or something.
2596 ;; This is a "real" format.
2600 (intern (format "gnus-%s-line-format-alist"
2601 (if (eq type
'article-mode
)
2602 'summary-mode type
))))
2603 (not (string-match "mode$" (symbol-name type
))))))
2604 ;; Enter the new format spec into the list.
2607 (setcar (cdr entry
) val
)
2608 (setcar entry new-format
))
2609 (push (list type new-format val
) gnus-format-specs
))
2610 (set (intern (format "gnus-%s-line-format-spec" type
)) val
))))
2612 (unless (assq 'version gnus-format-specs
)
2613 (push (cons 'version emacs-version
) gnus-format-specs
))
2615 (gnus-update-group-mark-positions)
2616 (gnus-update-summary-mark-positions))
2618 (defun gnus-update-summary-mark-positions ()
2619 "Compute where the summary marks are to go."
2621 (when (and gnus-summary-buffer
2622 (get-buffer gnus-summary-buffer
)
2623 (buffer-name (get-buffer gnus-summary-buffer
)))
2624 (set-buffer gnus-summary-buffer
))
2625 (let ((gnus-replied-mark 129)
2626 (gnus-score-below-mark 130)
2627 (gnus-score-over-mark 130)
2630 (spec gnus-summary-line-format-spec
)
2633 (gnus-set-work-buffer)
2634 (let ((gnus-summary-line-format-spec spec
))
2635 (gnus-summary-insert-line
2636 [0 "" "" "" "" "" 0 0 ""] 0 nil
128 t nil
"" nil
1)
2637 (goto-char (point-min))
2638 (setq pos
(list (cons 'unread
(and (search-forward "\200" nil t
)
2640 (goto-char (point-min))
2641 (push (cons 'replied
(and (search-forward "\201" nil t
)
2644 (goto-char (point-min))
2645 (push (cons 'score
(and (search-forward "\202" nil t
) (- (point) 2)))
2647 (setq gnus-summary-mark-positions pos
))))
2649 (defun gnus-update-group-mark-positions ()
2651 (let ((gnus-process-mark 128)
2652 (gnus-group-marked '("dummy.group"))
2653 (gnus-active-hashtb (make-vector 10 0)))
2654 (gnus-set-active "dummy.group" '(0 .
0))
2655 (gnus-set-work-buffer)
2656 (gnus-group-insert-group-line "dummy.group" 0 nil
0 nil
)
2657 (goto-char (point-min))
2658 (setq gnus-group-mark-positions
2659 (list (cons 'process
(and (search-forward "\200" nil t
)
2660 (- (point) 2))))))))
2662 (defvar gnus-mouse-face-0
'highlight
)
2663 (defvar gnus-mouse-face-1
'highlight
)
2664 (defvar gnus-mouse-face-2
'highlight
)
2665 (defvar gnus-mouse-face-3
'highlight
)
2666 (defvar gnus-mouse-face-4
'highlight
)
2668 (defun gnus-mouse-face-function (form type
)
2669 `(gnus-put-text-property
2670 (point) (progn ,@form
(point))
2671 gnus-mouse-face-prop
2674 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type
)))))))
2676 (defvar gnus-face-0
'bold
)
2677 (defvar gnus-face-1
'italic
)
2678 (defvar gnus-face-2
'bold-italic
)
2679 (defvar gnus-face-3
'bold
)
2680 (defvar gnus-face-4
'bold
)
2682 (defun gnus-face-face-function (form type
)
2683 `(gnus-put-text-property
2684 (point) (progn ,@form
(point))
2685 'face
',(symbol-value (intern (format "gnus-face-%d" type
)))))
2687 (defun gnus-max-width-function (el max-width
)
2688 (or (numberp max-width
) (signal 'wrong-type-argument
'(numberp max-width
)))
2690 `(if (> (length ,el
) ,max-width
)
2691 (substring ,el
0 ,max-width
)
2693 `(let ((val (eval ,el
)))
2695 (setq val
(int-to-string val
)))
2696 (if (> (length val
) ,max-width
)
2697 (substring val
0 ,max-width
)
2700 (defun gnus-parse-format (format spec-alist
&optional insert
)
2701 ;; This function parses the FORMAT string with the help of the
2702 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2703 ;; string. If the FORMAT string contains the specifiers %( and %)
2704 ;; the text between them will have the mouse-face text property.
2706 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2708 (gnus-parse-complex-format format spec-alist
)
2709 ;; This is a simple format.
2710 (gnus-parse-simple-format format spec-alist insert
)))
2712 (defun gnus-parse-complex-format (format spec-alist
)
2714 (gnus-set-work-buffer)
2716 (goto-char (point-min))
2717 (while (re-search-forward "\"" nil t
)
2718 (replace-match "\\\"" nil t
))
2719 (goto-char (point-min))
2721 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t
)
2722 (let ((number (if (match-beginning 1)
2723 (match-string 1) "0"))
2724 (delim (aref (match-string 2) 0)))
2725 (if (or (= delim ?\
() (= delim ?\
{))
2726 (replace-match (concat "\"(" (if (= delim ?\
() "mouse" "face")
2728 (replace-match "\")\""))))
2729 (goto-char (point-max))
2731 (goto-char (point-min))
2732 (let ((form (read (current-buffer))))
2733 (cons 'progn
(gnus-complex-form-to-spec form spec-alist
)))))
2735 (defun gnus-complex-form-to-spec (form spec-alist
)
2740 (gnus-parse-simple-format sform spec-alist t
)
2741 (funcall (intern (format "gnus-%s-face-function" (car sform
)))
2742 (gnus-complex-form-to-spec (cddr sform
) spec-alist
)
2746 (defun gnus-parse-simple-format (format spec-alist
&optional insert
)
2747 ;; This function parses the FORMAT string with the help of the
2748 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2751 spec flist fstring newspec elem beg result dontinsert
)
2753 (gnus-set-work-buffer)
2755 (goto-char (point-min))
2756 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2758 (if (= (setq spec
(string-to-char (match-string 2))) ?%
)
2760 beg
(1+ (match-beginning 0)))
2761 ;; First check if there are any specs that look anything like
2762 ;; "%12,12A", ie. with a "max width specification". These have
2763 ;; to be treated specially.
2764 (if (setq beg
(match-beginning 1))
2768 (1+ (match-beginning 1)) (match-end 1))))
2770 (setq beg
(match-beginning 2)))
2771 ;; Find the specification from `spec-alist'.
2772 (unless (setq elem
(cdr (assq spec spec-alist
)))
2773 (setq elem
'("*" ?s
)))
2774 ;; Treat user defined format specifiers specially.
2775 (when (eq (car elem
) 'gnus-tmp-user-defined
)
2778 (list (intern (concat "gnus-user-format-function-"
2780 'gnus-tmp-header
) ?s
))
2781 (delete-region (match-beginning 3) (match-end 3)))
2782 (if (not (zerop max-width
))
2783 (let ((el (car elem
)))
2784 (cond ((= (cadr elem
) ?c
)
2785 (setq el
(list 'char-to-string el
)))
2787 (setq el
(list 'int-to-string el
))))
2788 (setq flist
(cons (gnus-max-width-function el max-width
)
2792 (setq flist
(cons (car elem
) flist
))
2793 (setq newspec
(cadr elem
)))))
2794 ;; Remove the old specification (and possibly a ",12" string).
2795 (delete-region beg
(match-end 2))
2796 ;; Insert the new specification.
2799 (setq fstring
(buffer-substring 1 (point-max))))
2800 ;; Do some postprocessing to increase efficiency.
2805 ((string= fstring
"")
2807 ;; Not a format string.
2808 ((not (string-match "%" fstring
))
2810 ;; A format string with just a single string spec.
2811 ((string= fstring
"%s")
2813 ;; A single character.
2814 ((string= fstring
"%c")
2817 ((string= fstring
"%d")
2820 (list `(princ ,(car flist
)))
2821 (list `(int-to-string ,(car flist
)))))
2822 ;; Just lots of chars and strings.
2823 ((string-match "\\`\\(%[cs]\\)+\\'" fstring
)
2825 ;; A single string spec at the beginning of the spec.
2826 ((string-match "\\`%[sc][^%]+\\'" fstring
)
2827 (list (car flist
) (substring fstring
2)))
2828 ;; A single string spec in the middle of the spec.
2829 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring
)
2830 (list (match-string 1 fstring
) (car flist
) (match-string 2 fstring
)))
2831 ;; A single string spec in the end of the spec.
2832 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring
)
2833 (list (match-string 1 fstring
) (car flist
)))
2834 ;; A more complex spec.
2836 (list (cons 'format
(cons fstring
(nreverse flist
)))))))
2842 (cons 'insert result
)))
2843 (cond ((stringp result
)
2846 (cons 'concat result
))
2849 (defun gnus-eval-format (format &optional alist props
)
2850 "Eval the format variable FORMAT, using ALIST.
2851 If PROPS, insert the result."
2852 (let ((form (gnus-parse-format format alist props
)))
2854 (gnus-add-text-properties (point) (progn (eval form
) (point)) props
)
2857 (defun gnus-remove-text-with-property (prop)
2858 "Delete all text in the current buffer with text property PROP."
2860 (goto-char (point-min))
2862 (while (get-text-property (point) prop
)
2864 (goto-char (next-single-property-change (point) prop nil
(point-max))))))
2866 (defun gnus-set-work-buffer ()
2867 (if (get-buffer gnus-work-buffer
)
2869 (set-buffer gnus-work-buffer
)
2871 (set-buffer (get-buffer-create gnus-work-buffer
))
2872 (kill-all-local-variables)
2873 (buffer-disable-undo (current-buffer))
2874 (gnus-add-current-to-buffer-list)))
2876 ;; Article file names when saving.
2878 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
2879 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2880 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2881 Otherwise, it is like ~/News/news/group/num."
2884 (concat (if (gnus-use-long-file-name 'not-save
)
2885 (gnus-capitalize-newsgroup newsgroup
)
2886 (gnus-newsgroup-directory-form newsgroup
))
2887 "/" (int-to-string (mail-header-number headers
)))
2888 gnus-article-save-directory
)))
2890 (string-equal (file-name-directory default
)
2891 (file-name-directory last-file
))
2892 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2894 (or last-file default
))))
2896 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
2897 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2898 If variable `gnus-use-long-file-name' is non-nil, it is
2899 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2902 (concat (if (gnus-use-long-file-name 'not-save
)
2904 (gnus-newsgroup-directory-form newsgroup
))
2905 "/" (int-to-string (mail-header-number headers
)))
2906 gnus-article-save-directory
)))
2908 (string-equal (file-name-directory default
)
2909 (file-name-directory last-file
))
2910 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2912 (or last-file default
))))
2914 (defun gnus-Plain-save-name (newsgroup headers
&optional last-file
)
2915 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2916 If variable `gnus-use-long-file-name' is non-nil, it is
2917 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2920 (if (gnus-use-long-file-name 'not-save
)
2921 (gnus-capitalize-newsgroup newsgroup
)
2922 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2923 gnus-article-save-directory
)))
2925 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
2926 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2927 If variable `gnus-use-long-file-name' is non-nil, it is
2928 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2931 (if (gnus-use-long-file-name 'not-save
)
2933 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2934 gnus-article-save-directory
)))
2936 ;; For subscribing new newsgroup
2938 (defun gnus-subscribe-hierarchical-interactive (groups)
2939 (let ((groups (sort groups
'string
<))
2940 prefixes prefix start ans group starts
)
2942 (setq prefixes
(list "^"))
2943 (while (and groups prefixes
)
2944 (while (not (string-match (car prefixes
) (car groups
)))
2945 (setq prefixes
(cdr prefixes
)))
2946 (setq prefix
(car prefixes
))
2947 (setq start
(1- (length prefix
)))
2948 (if (and (string-match "[^\\.]\\." (car groups
) start
)
2951 (concat "^" (substring (car groups
) 0 (match-end 0))))
2952 (string-match prefix
(cadr groups
)))
2954 (setq prefixes
(cons prefix prefixes
))
2955 (message "Descend hierarchy %s? ([y]nsq): "
2956 (substring prefix
1 (1- (length prefix
))))
2957 (while (not (memq (setq ans
(read-char)) '(?y ?
\n ?n ?s ?q
)))
2959 (message "Descend hierarchy %s? ([y]nsq): "
2960 (substring prefix
1 (1- (length prefix
)))))
2963 (string-match prefix
2964 (setq group
(car groups
))))
2965 (setq gnus-killed-list
2966 (cons group gnus-killed-list
))
2967 (gnus-sethash group group gnus-killed-hashtb
)
2968 (setq groups
(cdr groups
)))
2969 (setq starts
(cdr starts
)))
2972 (string-match prefix
2973 (setq group
(car groups
))))
2974 (gnus-sethash group group gnus-killed-hashtb
)
2975 (gnus-subscribe-alphabetically (car groups
))
2976 (setq groups
(cdr groups
)))
2977 (setq starts
(cdr starts
)))
2980 (setq group
(car groups
))
2981 (setq gnus-killed-list
(cons group gnus-killed-list
))
2982 (gnus-sethash group group gnus-killed-hashtb
)
2983 (setq groups
(cdr groups
))))
2985 (message "Subscribe %s? ([n]yq)" (car groups
))
2986 (while (not (memq (setq ans
(read-char)) '(?y ?
\n ?q ?n
)))
2988 (message "Subscribe %s? ([n]yq)" (car groups
)))
2989 (setq group
(car groups
))
2991 (gnus-subscribe-alphabetically (car groups
))
2992 (gnus-sethash group group gnus-killed-hashtb
))
2995 (setq group
(car groups
))
2996 (setq gnus-killed-list
(cons group gnus-killed-list
))
2997 (gnus-sethash group group gnus-killed-hashtb
)
2998 (setq groups
(cdr groups
))))
3000 (setq gnus-killed-list
(cons group gnus-killed-list
))
3001 (gnus-sethash group group gnus-killed-hashtb
)))
3002 (setq groups
(cdr groups
)))))))
3004 (defun gnus-subscribe-randomly (newsgroup)
3005 "Subscribe new NEWSGROUP by making it the first newsgroup."
3006 (gnus-subscribe-newsgroup newsgroup
))
3008 (defun gnus-subscribe-alphabetically (newgroup)
3009 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3010 (let ((groups (cdr gnus-newsrc-alist
))
3012 (while (and (not before
) groups
)
3013 (if (string< newgroup
(caar groups
))
3014 (setq before
(caar groups
))
3015 (setq groups
(cdr groups
))))
3016 (gnus-subscribe-newsgroup newgroup before
)))
3018 (defun gnus-subscribe-hierarchically (newgroup)
3019 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3020 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3022 (set-buffer (find-file-noselect gnus-current-startup-file
))
3023 (let ((groupkey newgroup
)
3025 (while (and (not before
) groupkey
)
3026 (goto-char (point-min))
3028 (concat "^\\(" (regexp-quote groupkey
) ".*\\)[!:]")))
3029 (while (and (re-search-forward groupkey-re nil t
)
3031 (setq before
(match-string 1))
3032 (string< before newgroup
)))))
3033 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3035 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey
)
3036 (substring groupkey
(match-beginning 1) (match-end 1)))))
3037 (gnus-subscribe-newsgroup newgroup before
))
3038 (kill-buffer (current-buffer))))
3040 (defun gnus-subscribe-interactively (group)
3041 "Subscribe the new GROUP interactively.
3042 It is inserted in hierarchical newsgroup order if subscribed. If not,
3044 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group
))
3045 (gnus-subscribe-hierarchically group
)
3046 (push group gnus-killed-list
)))
3048 (defun gnus-subscribe-zombies (group)
3049 "Make the new GROUP into a zombie group."
3050 (push group gnus-zombie-list
))
3052 (defun gnus-subscribe-killed (group)
3053 "Make the new GROUP a killed group."
3054 (push group gnus-killed-list
))
3056 (defun gnus-subscribe-newsgroup (newsgroup &optional next
)
3057 "Subscribe new NEWSGROUP.
3058 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3059 the first newsgroup."
3060 ;; We subscribe the group by changing its level to `subscribed'.
3061 (gnus-group-change-level
3062 newsgroup gnus-level-default-subscribed
3063 gnus-level-killed
(gnus-gethash (or next
"dummy.group") gnus-newsrc-hashtb
))
3064 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup
))
3068 (defun gnus-newsgroup-directory-form (newsgroup)
3069 "Make hierarchical directory name from NEWSGROUP name."
3070 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup
))
3071 (len (length newsgroup
))
3073 ;; If this is a foreign group, we don't want to translate the
3075 (if (setq idx
(string-match ":" newsgroup
))
3076 (aset newsgroup idx ?
/)
3078 ;; Replace all occurrences of `.' with `/'.
3080 (if (= (aref newsgroup idx
) ?.
)
3081 (aset newsgroup idx ?
/))
3082 (setq idx
(1+ idx
)))
3085 (defun gnus-newsgroup-savable-name (group)
3086 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3088 (nnheader-replace-chars-in-string group ?
/ ?.
))
3090 (defun gnus-make-directory (dir)
3091 "Make DIRECTORY recursively."
3092 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3093 ;; of the many mysteries of the universe.
3094 (let* ((dir (expand-file-name dir default-directory
))
3096 (if (string-match "/$" dir
)
3097 (setq dir
(substring dir
0 (match-beginning 0))))
3098 ;; First go down the path until we find a directory that exists.
3099 (while (not (file-exists-p dir
))
3100 (setq dirs
(cons dir dirs
))
3101 (string-match "/[^/]+$" dir
)
3102 (setq dir
(substring dir
0 (match-beginning 0))))
3103 ;; Then create all the subdirs.
3104 (while (and dirs
(not err
))
3106 (make-directory (car dirs
))
3107 (error (setq err t
)))
3108 (setq dirs
(cdr dirs
)))
3109 ;; We return whether we were successful or not.
3112 (defun gnus-capitalize-newsgroup (newsgroup)
3113 "Capitalize NEWSGROUP name."
3114 (and (not (zerop (length newsgroup
)))
3115 (concat (char-to-string (upcase (aref newsgroup
0)))
3116 (substring newsgroup
1))))
3118 ;; Various... things.
3120 (defun gnus-simplify-subject (subject &optional re-only
)
3121 "Remove `Re:' and words in parentheses.
3122 If RE-ONLY is non-nil, strip leading `Re:'s only."
3123 (let ((case-fold-search t
)) ;Ignore case.
3124 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3125 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject
)
3126 (setq subject
(substring subject
(match-end 0))))
3127 ;; Remove uninteresting prefixes.
3128 (if (and (not re-only
)
3129 gnus-simplify-ignored-prefixes
3130 (string-match gnus-simplify-ignored-prefixes subject
))
3131 (setq subject
(substring subject
(match-end 0))))
3132 ;; Remove words in parentheses from end.
3134 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
3135 (setq subject
(substring subject
0 (match-beginning 0)))))
3136 ;; Return subject string.
3139 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3141 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3142 (defun gnus-simplify-buffer-fuzzy ()
3143 (let ((case-fold-search t
))
3144 (goto-char (point-min))
3145 (while (search-forward "\t" nil t
)
3146 (replace-match " " t t
))
3147 (goto-char (point-min))
3148 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t
)
3149 (goto-char (match-beginning 0))
3151 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3152 (looking-at "^[[].*: .*[]]$"))
3153 (goto-char (point-min))
3154 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3156 (replace-match "" t t
))
3157 (goto-char (point-min))
3158 (while (re-search-forward "^[[].*: .*[]]$" nil t
)
3159 (goto-char (match-end 0))
3162 (progn (goto-char (match-beginning 0)))
3163 (re-search-forward ":"))))
3164 (goto-char (point-min))
3165 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t
)
3166 (replace-match "" t t
))
3167 (goto-char (point-min))
3168 (while (re-search-forward " +" nil t
)
3169 (replace-match " " t t
))
3170 (goto-char (point-min))
3171 (while (re-search-forward " $" nil t
)
3172 (replace-match "" t t
))
3173 (goto-char (point-min))
3174 (while (re-search-forward "^ +" nil t
)
3175 (replace-match "" t t
))
3176 (goto-char (point-min))
3177 (when gnus-simplify-subject-fuzzy-regexp
3178 (if (listp gnus-simplify-subject-fuzzy-regexp
)
3179 (let ((list gnus-simplify-subject-fuzzy-regexp
))
3181 (goto-char (point-min))
3182 (while (re-search-forward (car list
) nil t
)
3183 (replace-match "" t t
))
3184 (setq list
(cdr list
))))
3185 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t
)
3186 (replace-match "" t t
))))))
3188 (defun gnus-simplify-subject-fuzzy (subject)
3189 "Siplify a subject string fuzzily."
3191 (gnus-set-work-buffer)
3192 (let ((case-fold-search t
))
3194 (inline (gnus-simplify-buffer-fuzzy))
3197 ;; Add the current buffer to the list of buffers to be killed on exit.
3198 (defun gnus-add-current-to-buffer-list ()
3199 (or (memq (current-buffer) gnus-buffer-list
)
3200 (setq gnus-buffer-list
(cons (current-buffer) gnus-buffer-list
))))
3202 (defun gnus-string> (s1 s2
)
3203 (not (or (string< s1 s2
)
3206 (defun gnus-read-active-file-p ()
3207 "Say whether the active file has been read from `gnus-select-method'."
3208 (memq gnus-select-method gnus-have-read-active-file
))
3210 ;;; General various misc type functions.
3212 (defun gnus-clear-system ()
3213 "Clear all variables and buffers."
3214 ;; Clear Gnus variables.
3215 (let ((variables gnus-variable-list
))
3217 (set (car variables
) nil
)
3218 (setq variables
(cdr variables
))))
3219 ;; Clear other internal variables.
3220 (setq gnus-list-of-killed-groups nil
3221 gnus-have-read-active-file nil
3222 gnus-newsrc-alist nil
3223 gnus-newsrc-hashtb nil
3224 gnus-killed-list nil
3225 gnus-zombie-list nil
3226 gnus-killed-hashtb nil
3227 gnus-active-hashtb nil
3228 gnus-moderated-list nil
3229 gnus-description-hashtb nil
3230 gnus-current-headers nil
3231 gnus-thread-indent-array nil
3232 gnus-newsgroup-headers nil
3233 gnus-newsgroup-name nil
3234 gnus-server-alist nil
3235 gnus-group-list-mode nil
3236 gnus-opened-servers nil
3237 gnus-group-mark-positions nil
3238 gnus-newsgroup-data nil
3239 gnus-newsgroup-unreads nil
3240 nnoo-state-alist nil
3241 gnus-current-select-method nil
)
3242 (gnus-shutdown 'gnus
)
3243 ;; Kill the startup file.
3244 (and gnus-current-startup-file
3245 (get-file-buffer gnus-current-startup-file
)
3246 (kill-buffer (get-file-buffer gnus-current-startup-file
)))
3247 ;; Clear the dribble buffer.
3248 (gnus-dribble-clear)
3249 ;; Kill global KILL file buffer.
3250 (when (get-file-buffer (gnus-newsgroup-kill-file nil
))
3251 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil
))))
3252 (gnus-kill-buffer nntp-server-buffer
)
3253 ;; Kill Gnus buffers.
3254 (while gnus-buffer-list
3255 (gnus-kill-buffer (pop gnus-buffer-list
)))
3256 ;; Remove Gnus frames.
3257 (gnus-kill-gnus-frames))
3259 (defun gnus-kill-gnus-frames ()
3260 "Kill all frames Gnus has created."
3261 (while gnus-created-frames
3262 (when (frame-live-p (car gnus-created-frames
))
3263 ;; We slap a condition-case around this `delete-frame' to ensure
3264 ;; against errors if we try do delete the single frame that's left.
3266 (delete-frame (car gnus-created-frames
))
3268 (pop gnus-created-frames
)))
3270 (defun gnus-windows-old-to-new (setting)
3271 ;; First we take care of the really, really old Gnus 3 actions.
3272 (when (symbolp setting
)
3274 ;; Take care of ooold GNUS 3.x values.
3275 (cond ((eq setting
'SelectArticle
) 'article
)
3276 ((memq setting
'(SelectSubject ExpandSubject
)) 'summary
)
3277 ((memq setting
'(SelectNewsgroup ExitNewsgroup
)) 'group
)
3279 (if (or (listp setting
)
3280 (not (and gnus-window-configuration
3281 (memq setting
'(group summary article
)))))
3283 (let* ((setting (if (eq setting
'group
)
3284 (if (assq 'newsgroup gnus-window-configuration
)
3286 'newsgroups
) setting
))
3287 (elem (cadr (assq setting gnus-window-configuration
)))
3288 (total (apply '+ elem
))
3289 (types '(group summary article
))
3290 (pbuf (if (eq setting
'newsgroups
) 'group
'summary
))
3295 (or (not (numberp (nth i elem
)))
3296 (zerop (nth i elem
))
3298 (setq perc
(if (= i
2)
3300 (/ (float (nth 0 elem
)) total
)))
3301 (setq out
(cons (if (eq pbuf
(nth i types
))
3302 (list (nth i types
) perc
'point
)
3303 (list (nth i types
) perc
))
3306 `(vertical 1.0 ,@(nreverse out
)))))
3309 (defun gnus-add-configuration (conf)
3310 "Add the window configuration CONF to `gnus-buffer-configuration'."
3311 (setq gnus-buffer-configuration
3312 (cons conf
(delq (assq (car conf
) gnus-buffer-configuration
)
3313 gnus-buffer-configuration
))))
3315 (defvar gnus-frame-list nil
)
3317 (defun gnus-configure-frame (split &optional window
)
3318 "Split WINDOW according to SPLIT."
3320 (setq window
(get-buffer-window (current-buffer))))
3321 (select-window window
)
3322 ;; This might be an old-stylee buffer config.
3323 (when (vectorp split
)
3324 (setq split
(append split nil
)))
3325 (when (or (consp (car split
))
3326 (vectorp (car split
)))
3328 (push 'vertical split
))
3329 ;; The SPLIT might be something that is to be evaled to
3330 ;; return a new SPLIT.
3331 (while (and (not (assq (car split
) gnus-window-to-buffer
))
3332 (gnus-functionp (car split
)))
3333 (setq split
(eval split
)))
3334 (let* ((type (car split
))
3336 (len (if (eq type
'horizontal
) (window-width) (window-height)))
3338 (window-min-width (or gnus-window-min-width window-min-width
))
3339 (window-min-height (or gnus-window-min-height window-min-height
))
3340 s result new-win rest comp-subs size sub
)
3342 ;; Nothing to do here.
3344 ;; Don't switch buffers.
3346 (and (memq 'point split
) window
))
3347 ;; This is a buffer to be selected.
3348 ((not (memq type
'(frame horizontal vertical
)))
3349 (let ((buffer (cond ((stringp type
) type
)
3350 (t (cdr (assq type gnus-window-to-buffer
)))))
3353 (error "Illegal buffer type: %s" type
))
3354 (unless (setq buf
(get-buffer (if (symbolp buffer
)
3355 (symbol-value buffer
) buffer
)))
3356 (setq buf
(get-buffer-create (if (symbolp buffer
)
3357 (symbol-value buffer
) buffer
))))
3358 (switch-to-buffer buf
)
3359 ;; We return the window if it has the `point' spec.
3360 (and (memq 'point split
) window
)))
3361 ;; This is a frame split.
3363 (unless gnus-frame-list
3364 (setq gnus-frame-list
(list (window-frame
3365 (get-buffer-window (current-buffer))))))
3367 params frame fresult
)
3368 (while (< i
(length subs
))
3369 ;; Frame parameter is gotten from the sub-split.
3370 (setq params
(cadr (elt subs i
)))
3371 ;; It should be a list.
3372 (unless (listp params
)
3374 ;; Create a new frame?
3375 (unless (setq frame
(elt gnus-frame-list i
))
3376 (nconc gnus-frame-list
(list (setq frame
(make-frame params
))))
3377 (push frame gnus-created-frames
))
3378 ;; Is the old frame still alive?
3379 (unless (frame-live-p frame
)
3380 (setcar (nthcdr i gnus-frame-list
)
3381 (setq frame
(make-frame params
))))
3382 ;; Select the frame in question and do more splits there.
3383 (select-frame frame
)
3384 (setq fresult
(or (gnus-configure-frame (elt subs i
)) fresult
))
3386 ;; Select the frame that has the selected buffer.
3388 (select-frame (window-frame fresult
)))))
3389 ;; This is a normal split.
3391 (when (> (length subs
) 0)
3392 ;; First we have to compute the sizes of all new windows.
3394 (setq sub
(append (pop subs
) nil
))
3395 (while (and (not (assq (car sub
) gnus-window-to-buffer
))
3396 (gnus-functionp (car sub
)))
3397 (setq sub
(eval sub
)))
3399 (push sub comp-subs
)
3400 (setq size
(cadar comp-subs
))
3401 (cond ((equal size
1.0)
3402 (setq rest
(car comp-subs
))
3405 (setq s
(floor (* size len
))))
3409 (error "Illegal size: %s" size
)))
3410 ;; Try to make sure that we are inside the safe limits.
3412 ((eq type
'horizontal
)
3413 (setq s
(max s window-min-width
)))
3414 ((eq type
'vertical
)
3415 (setq s
(max s window-min-height
))))
3416 (setcar (cdar comp-subs
) s
)
3418 ;; Take care of the "1.0" spec.
3420 (setcar (cdr rest
) (- len total
))
3421 (error "No 1.0 specs in %s" split
))
3422 ;; The we do the actual splitting in a nice recursive
3424 (setq comp-subs
(nreverse comp-subs
))
3426 (if (null (cdr comp-subs
))
3427 (setq new-win window
)
3429 (split-window window
(cadar comp-subs
)
3430 (eq type
'horizontal
))))
3431 (setq result
(or (gnus-configure-frame
3432 (car comp-subs
) window
) result
))
3433 (select-window new-win
)
3434 (setq window new-win
)
3435 (setq comp-subs
(cdr comp-subs
))))
3436 ;; Return the proper window, if any.
3438 (select-window result
))))))
3440 (defvar gnus-frame-split-p nil
)
3442 (defun gnus-configure-windows (setting &optional force
)
3443 (setq setting
(gnus-windows-old-to-new setting
))
3444 (let ((split (if (symbolp setting
)
3445 (cadr (assq setting gnus-buffer-configuration
))
3449 (setq gnus-frame-split-p nil
)
3452 (error "No such setting: %s" setting
))
3454 (if (and (setq all-visible
(gnus-all-windows-visible-p split
))
3456 ;; All the windows mentioned are already visible, so we just
3457 ;; put point in the assigned buffer, and do not touch the
3459 (select-window all-visible
)
3461 ;; Either remove all windows or just remove all Gnus windows.
3462 (let ((frame (selected-frame)))
3464 (if gnus-use-full-window
3465 ;; We want to remove all other windows.
3466 (if (not gnus-frame-split-p
)
3467 ;; This is not a `frame' split, so we ignore the
3469 (delete-other-windows)
3470 ;; This is a `frame' split, so we delete all windows
3474 (unless (eq (cdr (assq 'minibuffer
3475 (frame-parameters frame
)))
3477 (select-frame frame
)
3478 (delete-other-windows)))
3480 ;; Just remove some windows.
3481 (gnus-remove-some-windows)
3482 (switch-to-buffer nntp-server-buffer
))
3483 (select-frame frame
)))
3485 (switch-to-buffer nntp-server-buffer
)
3486 (gnus-configure-frame split
(get-buffer-window (current-buffer))))))
3488 (defun gnus-all-windows-visible-p (split)
3489 "Say whether all buffers in SPLIT are currently visible.
3490 In particular, the value returned will be the window that
3492 (let ((stack (list split
))
3494 type buffer win buf
)
3495 (while (and (setq split
(pop stack
))
3497 ;; Be backwards compatible.
3498 (when (vectorp split
)
3499 (setq split
(append split nil
)))
3500 (when (or (consp (car split
))
3501 (vectorp (car split
)))
3503 (push 'vertical split
))
3504 ;; The SPLIT might be something that is to be evaled to
3505 ;; return a new SPLIT.
3506 (while (and (not (assq (car split
) gnus-window-to-buffer
))
3507 (gnus-functionp (car split
)))
3508 (setq split
(eval split
)))
3510 (setq type
(elt split
0))
3515 ((not (memq type
'(horizontal vertical frame
)))
3516 (setq buffer
(cond ((stringp type
) type
)
3517 (t (cdr (assq type gnus-window-to-buffer
)))))
3519 (error "Illegal buffer type: %s" type
))
3520 (when (setq buf
(get-buffer (if (symbolp buffer
)
3521 (symbol-value buffer
)
3523 (setq win
(get-buffer-window buf t
)))
3525 (when (memq 'point split
)
3526 (setq all-visible win
))
3527 (setq all-visible nil
)))
3529 (when (eq type
'frame
)
3530 (setq gnus-frame-split-p t
))
3531 (setq stack
(append (cddr split
) stack
)))))
3532 (unless (eq all-visible t
)
3535 (defun gnus-window-top-edge (&optional window
)
3536 (nth 1 (window-edges window
)))
3538 (defun gnus-remove-some-windows ()
3539 (let ((buffers gnus-window-to-buffer
)
3540 buf bufs lowest-buf lowest
)
3542 ;; Remove windows on all known Gnus buffers.
3544 (setq buf
(cdar buffers
))
3546 (setq buf
(and (boundp buf
) (symbol-value buf
))))
3548 (get-buffer-window buf
)
3550 (setq bufs
(cons buf bufs
))
3552 (if (or (not lowest
)
3553 (< (gnus-window-top-edge) lowest
))
3555 (setq lowest
(gnus-window-top-edge))
3556 (setq lowest-buf buf
)))))
3557 (setq buffers
(cdr buffers
)))
3558 ;; Remove windows on *all* summary buffers.
3561 (let ((buf (window-buffer win
)))
3562 (if (string-match "^\\*Summary" (buffer-name buf
))
3564 (setq bufs
(cons buf bufs
))
3566 (if (or (not lowest
)
3567 (< (gnus-window-top-edge) lowest
))
3569 (setq lowest-buf buf
)
3570 (setq lowest
(gnus-window-top-edge)))))))))
3573 (pop-to-buffer lowest-buf
)
3574 (switch-to-buffer nntp-server-buffer
)))
3576 (and (not (eq (car bufs
) lowest-buf
))
3577 (delete-windows-on (car bufs
)))
3578 (setq bufs
(cdr bufs
))))))
3580 (defun gnus-version (&optional arg
)
3581 "Version number of this version of Gnus.
3582 If ARG, insert string at point."
3584 (let ((methods gnus-valid-select-methods
)
3587 ;; Go through all the legal select methods and add their version
3588 ;; numbers to the total version string. Only the backends that are
3589 ;; currently in use will have their message numbers taken into
3592 (setq meth
(intern (concat (caar methods
) "-version")))
3594 (stringp (symbol-value meth
))
3595 (setq mess
(concat mess
"; " (symbol-value meth
))))
3596 (setq methods
(cdr methods
)))
3598 (insert (message mess
))
3601 (defun gnus-info-find-node ()
3602 "Find Info documentation of Gnus."
3604 ;; Enlarge info window if needed.
3605 (let ((mode major-mode
)
3607 (Info-goto-node (cadr (assq mode gnus-info-nodes
)))
3608 (setq gnus-info-buffer
(current-buffer))
3609 (gnus-configure-windows 'info
)))
3611 (defun gnus-days-between (date1 date2
)
3612 ;; Return the number of days between date1 and date2.
3613 (- (gnus-day-number date1
) (gnus-day-number date2
)))
3615 (defun gnus-day-number (date)
3616 (let ((dat (mapcar (lambda (s) (and s
(string-to-int s
)) )
3617 (timezone-parse-date date
))))
3618 (timezone-absolute-from-gregorian
3619 (nth 1 dat
) (nth 2 dat
) (car dat
))))
3621 (defun gnus-encode-date (date)
3622 "Convert DATE to internal time."
3623 (let* ((parse (timezone-parse-date date
))
3624 (date (mapcar (lambda (d) (and d
(string-to-int d
))) parse
))
3625 (time (mapcar 'string-to-int
(timezone-parse-time (aref parse
3)))))
3626 (encode-time (caddr time
) (cadr time
) (car time
)
3627 (caddr date
) (cadr date
) (car date
) (nth 4 date
))))
3629 (defun gnus-time-minus (t1 t2
)
3630 "Subtract two internal times."
3631 (let ((borrow (< (cadr t1
) (cadr t2
))))
3632 (list (- (car t1
) (car t2
) (if borrow
1 0))
3633 (- (+ (if borrow
65536 0) (cadr t1
)) (cadr t2
)))))
3635 (defun gnus-file-newer-than (file date
)
3636 (let ((fdate (nth 5 (file-attributes file
))))
3637 (or (> (car fdate
) (car date
))
3638 (and (= (car fdate
) (car date
))
3639 (> (nth 1 fdate
) (nth 1 date
))))))
3641 (defmacro gnus-local-set-keys
(&rest plist
)
3642 "Set the keys in PLIST in the current keymap."
3643 `(gnus-define-keys-1 (current-local-map) ',plist
))
3645 (defmacro gnus-define-keys
(keymap &rest plist
)
3646 "Define all keys in PLIST in KEYMAP."
3647 `(gnus-define-keys-1 (quote ,keymap
) (quote ,plist
)))
3649 (put 'gnus-define-keys
'lisp-indent-function
1)
3650 (put 'gnus-define-keys
'lisp-indent-hook
1)
3651 (put 'gnus-define-keymap
'lisp-indent-function
1)
3652 (put 'gnus-define-keymap
'lisp-indent-hook
1)
3654 (defmacro gnus-define-keymap
(keymap &rest plist
)
3655 "Define all keys in PLIST in KEYMAP."
3656 `(gnus-define-keys-1 ,keymap
(quote ,plist
)))
3658 (defun gnus-define-keys-1 (keymap plist
)
3660 (error "Can't set keys in a null keymap"))
3661 (cond ((symbolp keymap
)
3662 (setq keymap
(symbol-value keymap
)))
3665 (set (car keymap
) nil
)
3666 (define-prefix-command (car keymap
))
3667 (define-key (symbol-value (caddr keymap
)) (cadr keymap
) (car keymap
))
3668 (setq keymap
(symbol-value (car keymap
)))))
3671 (when (symbolp (setq key
(pop plist
)))
3672 (setq key
(symbol-value key
)))
3673 (define-key keymap key
(pop plist
)))))
3675 (defun gnus-group-read-only-p (&optional group
)
3676 "Check whether GROUP supports editing or not.
3677 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3678 that that variable is buffer-local to the summary buffers."
3679 (let ((group (or group gnus-newsgroup-name
)))
3680 (not (gnus-check-backend-function 'request-replace-article group
))))
3682 (defun gnus-group-total-expirable-p (group)
3683 "Check whether GROUP is total-expirable or not."
3684 (let ((params (gnus-info-params (gnus-get-info group
))))
3685 (or (memq 'total-expire params
)
3686 (cdr (assq 'total-expire params
)) ; (total-expire . t)
3687 (and gnus-total-expirable-newsgroups
; Check var.
3688 (string-match gnus-total-expirable-newsgroups group
)))))
3690 (defun gnus-group-auto-expirable-p (group)
3691 "Check whether GROUP is total-expirable or not."
3692 (let ((params (gnus-info-params (gnus-get-info group
))))
3693 (or (memq 'auto-expire params
)
3694 (cdr (assq 'auto-expire params
)) ; (auto-expire . t)
3695 (and gnus-auto-expirable-newsgroups
; Check var.
3696 (string-match gnus-auto-expirable-newsgroups group
)))))
3698 (defun gnus-virtual-group-p (group)
3699 "Say whether GROUP is virtual or not."
3700 (memq 'virtual
(assoc (symbol-name (car (gnus-find-method-for-group group
)))
3701 gnus-valid-select-methods
)))
3703 (defun gnus-news-group-p (group &optional article
)
3704 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3705 (or (gnus-member-of-valid 'post group
) ; Ordinary news group.
3706 (and (gnus-member-of-valid 'post-mail group
) ; Combined group.
3707 (eq (gnus-request-type group article
) 'news
))))
3709 (defsubst gnus-simplify-subject-fully
(subject)
3710 "Simplify a subject string according to the user's wishes."
3712 ((null gnus-summary-gather-subject-limit
)
3713 (gnus-simplify-subject-re subject
))
3714 ((eq gnus-summary-gather-subject-limit
'fuzzy
)
3715 (gnus-simplify-subject-fuzzy subject
))
3716 ((numberp gnus-summary-gather-subject-limit
)
3717 (gnus-limit-string (gnus-simplify-subject-re subject
)
3718 gnus-summary-gather-subject-limit
))
3722 (defsubst gnus-subject-equal
(s1 s2
&optional simple-first
)
3723 "Check whether two subjects are equal. If optional argument
3724 simple-first is t, first argument is already simplified."
3726 ((null simple-first
)
3727 (equal (gnus-simplify-subject-fully s1
)
3728 (gnus-simplify-subject-fully s2
)))
3731 (gnus-simplify-subject-fully s2
)))))
3733 ;; Returns a list of writable groups.
3734 (defun gnus-writable-groups ()
3735 (let ((alist gnus-newsrc-alist
)
3737 (while (setq group
(car (pop alist
)))
3738 (unless (gnus-group-read-only-p group
)
3739 (push group groups
)))
3742 (defun gnus-completing-read (default prompt
&rest args
)
3743 ;; Like `completing-read', except that DEFAULT is the default argument.
3744 (let* ((prompt (if default
3745 (concat prompt
" (default " default
") ")
3746 (concat prompt
" ")))
3747 (answer (apply 'completing-read prompt args
)))
3748 (if (or (null answer
) (zerop (length answer
)))
3752 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3754 (defun gnus-y-or-n-p (prompt)
3759 (defun gnus-yes-or-no-p (prompt)
3761 (yes-or-no-p prompt
)
3764 ;; Check whether to use long file names.
3765 (defun gnus-use-long-file-name (symbol)
3766 ;; The variable has to be set...
3767 (and gnus-use-long-file-name
3768 ;; If it isn't a list, then we return t.
3769 (or (not (listp gnus-use-long-file-name
))
3770 ;; If it is a list, and the list contains `symbol', we
3772 (not (memq symbol gnus-use-long-file-name
)))))
3774 ;; I suspect there's a better way, but I haven't taken the time to do
3775 ;; it yet. -erik selberg@cs.washington.edu
3776 (defun gnus-dd-mmm (messy-date)
3777 "Return a string like DD-MMM from a big messy string"
3778 (let ((datevec (condition-case () (timezone-parse-date messy-date
)
3784 ;; Make sure leading zeroes are stripped.
3785 (number-to-string (string-to-number (aref datevec
2)))
3789 (nth (1- (string-to-number (aref datevec
1)))
3790 timezone-months-assoc
))
3793 (defun gnus-mode-string-quote (string)
3794 "Quote all \"%\" in STRING."
3796 (gnus-set-work-buffer)
3798 (goto-char (point-min))
3799 (while (search-forward "%" nil t
)
3803 ;; Make a hash table (default and minimum size is 255).
3804 ;; Optional argument HASHSIZE specifies the table size.
3805 (defun gnus-make-hashtable (&optional hashsize
)
3806 (make-vector (if hashsize
(max (gnus-create-hash-size hashsize
) 255) 255) 0))
3808 ;; Make a number that is suitable for hashing; bigger than MIN and one
3810 (defun gnus-create-hash-size (min)
3816 ;; Show message if message has a lower level than `gnus-verbose'.
3817 ;; Guideline for numbers:
3818 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3819 ;; for things that take a long time, 7 - not very important messages
3820 ;; on stuff, 9 - messages inside loops.
3821 (defun gnus-message (level &rest args
)
3822 (if (<= level gnus-verbose
)
3823 (apply 'message args
)
3824 ;; We have to do this format thingy here even if the result isn't
3825 ;; shown - the return value has to be the same as the return value
3827 (apply 'format args
)))
3829 (defun gnus-error (level &rest args
)
3830 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3831 (when (<= (floor level
) gnus-verbose
)
3832 (apply 'message args
)
3835 (when (and (floatp level
)
3836 (not (zerop (setq duration
(* 10 (- level
(floor level
)))))))
3837 (sit-for duration
))))
3840 ;; Generate a unique new group name.
3841 (defun gnus-generate-new-group-name (leaf)
3844 (while (gnus-gethash name gnus-newsrc-hashtb
)
3845 (setq name
(concat leaf
"<" (int-to-string (setq num
(1+ num
))) ">")))
3848 (defsubst gnus-hide-text
(b e props
)
3849 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3850 (gnus-add-text-properties b e props
)
3851 (when (memq 'intangible props
)
3852 (gnus-put-text-property (max (1- b
) (point-min))
3853 b
'intangible
(cddr (memq 'intangible props
)))))
3855 (defsubst gnus-unhide-text
(b e
)
3856 "Remove hidden text properties from region between B and E."
3857 (remove-text-properties b e gnus-hidden-properties
)
3858 (when (memq 'intangible gnus-hidden-properties
)
3859 (gnus-put-text-property (max (1- b
) (point-min))
3860 b
'intangible nil
)))
3862 (defun gnus-hide-text-type (b e type
)
3863 "Hide text of TYPE between B and E."
3864 (gnus-hide-text b e
(cons 'gnus-type
(cons type gnus-hidden-properties
))))
3866 (defun gnus-parent-headers (headers &optional generation
)
3867 "Return the headers of the GENERATIONeth parent of HEADERS."
3869 (setq generation
1))
3870 (let (references parent
)
3871 (while (and headers
(not (zerop generation
)))
3872 (setq references
(mail-header-references headers
))
3873 (when (and references
3874 (setq parent
(gnus-parent-id references
))
3875 (setq headers
(car (gnus-id-to-thread parent
))))
3879 (defun gnus-parent-id (references)
3880 "Return the last Message-ID in REFERENCES."
3881 (when (and references
3882 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references
))
3883 (substring references
(match-beginning 1) (match-end 1))))
3885 (defun gnus-split-references (references)
3886 "Return a list of Message-IDs in REFERENCES."
3889 (while (string-match "<[^>]+>" references beg
)
3890 (push (substring references
(match-beginning 0) (setq beg
(match-end 0)))
3894 (defun gnus-buffer-live-p (buffer)
3895 "Say whether BUFFER is alive or not."
3898 (buffer-name (get-buffer buffer
))))
3900 (defun gnus-ephemeral-group-p (group)
3901 "Say whether GROUP is ephemeral or not."
3902 (gnus-group-get-parameter group
'quit-config
))
3904 (defun gnus-group-quit-config (group)
3905 "Return the quit-config of GROUP."
3906 (gnus-group-get-parameter group
'quit-config
))
3908 (defun gnus-simplify-mode-line ()
3909 "Make mode lines a bit simpler."
3910 (setq mode-line-modified
"-- ")
3911 (when (listp mode-line-format
)
3912 (make-local-variable 'mode-line-format
)
3913 (setq mode-line-format
(copy-sequence mode-line-format
))
3914 (when (equal (nth 3 mode-line-format
) " ")
3915 (setcar (nthcdr 3 mode-line-format
) " "))))
3917 ;;; List and range functions
3919 (defun gnus-last-element (list)
3920 "Return last element of LIST."
3922 (setq list
(cdr list
)))
3925 (defun gnus-copy-sequence (list)
3926 "Do a complete, total copy of a list."
3927 (if (and (consp list
) (not (consp (cdr list
))))
3928 (cons (car list
) (cdr list
))
3929 (mapcar (lambda (elem) (if (consp elem
)
3930 (if (consp (cdr elem
))
3931 (gnus-copy-sequence elem
)
3932 (cons (car elem
) (cdr elem
)))
3936 (defun gnus-set-difference (list1 list2
)
3937 "Return a list of elements of LIST1 that do not appear in LIST2."
3938 (let ((list1 (copy-sequence list1
)))
3940 (setq list1
(delq (car list2
) list1
))
3941 (setq list2
(cdr list2
)))
3944 (defun gnus-sorted-complement (list1 list2
)
3945 "Return a list of elements of LIST1 that do not appear in LIST2.
3946 Both lists have to be sorted over <."
3948 (if (or (null list1
) (null list2
))
3950 (while (and list1 list2
)
3951 (cond ((= (car list1
) (car list2
))
3952 (setq list1
(cdr list1
)
3954 ((< (car list1
) (car list2
))
3955 (setq out
(cons (car list1
) out
))
3956 (setq list1
(cdr list1
)))
3958 (setq out
(cons (car list2
) out
))
3959 (setq list2
(cdr list2
)))))
3960 (nconc (nreverse out
) (or list1 list2
)))))
3962 (defun gnus-intersection (list1 list2
)
3965 (if (memq (car list2
) list1
)
3966 (setq result
(cons (car list2
) result
)))
3967 (setq list2
(cdr list2
)))
3970 (defun gnus-sorted-intersection (list1 list2
)
3971 ;; LIST1 and LIST2 have to be sorted over <.
3973 (while (and list1 list2
)
3974 (cond ((= (car list1
) (car list2
))
3975 (setq out
(cons (car list1
) out
)
3978 ((< (car list1
) (car list2
))
3979 (setq list1
(cdr list1
)))
3981 (setq list2
(cdr list2
)))))
3984 (defun gnus-set-sorted-intersection (list1 list2
)
3985 ;; LIST1 and LIST2 have to be sorted over <.
3986 ;; This function modifies LIST1.
3987 (let* ((top (cons nil list1
))
3989 (while (and list1 list2
)
3990 (cond ((= (car list1
) (car list2
))
3994 ((< (car list1
) (car list2
))
3995 (setcdr prev
(cdr list1
))
3996 (setq list1
(cdr list1
)))
3998 (setq list2
(cdr list2
)))))
4002 (defun gnus-compress-sequence (numbers &optional always-list
)
4003 "Convert list of numbers to a list of ranges or a single range.
4004 If ALWAYS-LIST is non-nil, this function will always release a list of
4006 (let* ((first (car numbers
))
4007 (last (car numbers
))
4011 (if (not (listp (cdr numbers
)))
4014 (cond ((= last
(car numbers
)) nil
) ;Omit duplicated number
4015 ((= (1+ last
) (car numbers
)) ;Still in sequence
4016 (setq last
(car numbers
)))
4017 (t ;End of one sequence
4019 (cons (if (= first last
) first
4020 (cons first last
)) result
))
4021 (setq first
(car numbers
))
4022 (setq last
(car numbers
))))
4023 (setq numbers
(cdr numbers
)))
4024 (if (and (not always-list
) (null result
))
4025 (if (= first last
) (list first
) (cons first last
))
4026 (nreverse (cons (if (= first last
) first
(cons first last
))
4029 (defalias 'gnus-uncompress-sequence
'gnus-uncompress-range
)
4030 (defun gnus-uncompress-range (ranges)
4031 "Expand a list of ranges into a list of numbers.
4032 RANGES is either a single range on the form `(num . num)' or a list of
4034 (let (first last result
)
4038 ((not (listp (cdr ranges
)))
4039 (setq first
(car ranges
))
4040 (setq last
(cdr ranges
))
4041 (while (<= first last
)
4042 (setq result
(cons first result
))
4043 (setq first
(1+ first
)))
4047 (if (atom (car ranges
))
4048 (if (numberp (car ranges
))
4049 (setq result
(cons (car ranges
) result
)))
4050 (setq first
(caar ranges
))
4051 (setq last
(cdar ranges
))
4052 (while (<= first last
)
4053 (setq result
(cons first result
))
4054 (setq first
(1+ first
))))
4055 (setq ranges
(cdr ranges
)))
4056 (nreverse result
)))))
4058 (defun gnus-add-to-range (ranges list
)
4059 "Return a list of ranges that has all articles from both RANGES and LIST.
4060 Note: LIST has to be sorted over `<'."
4062 (gnus-compress-sequence list t
)
4063 (setq list
(copy-sequence list
))
4064 (or (listp (cdr ranges
))
4065 (setq ranges
(list ranges
)))
4067 ilist lowest highest temp
)
4068 (while (and ranges list
)
4070 (setq lowest
(or (and (atom (car ranges
)) (car ranges
))
4072 (while (and list
(cdr list
) (< (cadr list
) lowest
))
4073 (setq list
(cdr list
)))
4074 (if (< (car ilist
) lowest
)
4077 (setq list
(cdr list
))
4079 (setq out
(nconc (gnus-compress-sequence ilist t
) out
))))
4080 (setq highest
(or (and (atom (car ranges
)) (car ranges
))
4082 (while (and list
(<= (car list
) highest
))
4083 (setq list
(cdr list
)))
4084 (setq ranges
(cdr ranges
)))
4086 (setq out
(nconc (gnus-compress-sequence list t
) out
)))
4087 (setq out
(sort out
(lambda (r1 r2
)
4088 (< (or (and (atom r1
) r1
) (car r1
))
4089 (or (and (atom r2
) r2
) (car r2
))))))
4092 (if (atom (car ranges
))
4094 (if (atom (cadr ranges
))
4095 (if (= (1+ (car ranges
)) (cadr ranges
))
4097 (setcar ranges
(cons (car ranges
)
4099 (setcdr ranges
(cddr ranges
))))
4100 (if (= (1+ (car ranges
)) (caadr ranges
))
4102 (setcar (cadr ranges
) (car ranges
))
4103 (setcar ranges
(cadr ranges
))
4104 (setcdr ranges
(cddr ranges
))))))
4106 (if (atom (cadr ranges
))
4107 (if (= (1+ (cdar ranges
)) (cadr ranges
))
4109 (setcdr (car ranges
) (cadr ranges
))
4110 (setcdr ranges
(cddr ranges
))))
4111 (if (= (1+ (cdar ranges
)) (caadr ranges
))
4113 (setcdr (car ranges
) (cdadr ranges
))
4114 (setcdr ranges
(cddr ranges
)))))))
4115 (setq ranges
(cdr ranges
)))
4118 (defun gnus-remove-from-range (ranges list
)
4119 "Return a list of ranges that has all articles from LIST removed from RANGES.
4120 Note: LIST has to be sorted over `<'."
4121 ;; !!! This function shouldn't look like this, but I've got a headache.
4122 (gnus-compress-sequence
4123 (gnus-sorted-complement
4124 (gnus-uncompress-range ranges
) list
)))
4126 (defun gnus-member-of-range (number ranges
)
4127 (if (not (listp (cdr ranges
)))
4128 (and (>= number
(car ranges
))
4129 (<= number
(cdr ranges
)))
4132 (if (numberp (car ranges
))
4133 (>= number
(car ranges
))
4134 (>= number
(caar ranges
)))
4136 (if (if (numberp (car ranges
))
4137 (= number
(car ranges
))
4138 (and (>= number
(caar ranges
))
4139 (<= number
(cdar ranges
))))
4140 (setq not-stop nil
))
4141 (setq ranges
(cdr ranges
)))
4144 (defun gnus-range-length (range)
4145 "Return the length RANGE would have if uncompressed."
4146 (length (gnus-uncompress-range range
)))
4148 (defun gnus-sublist-p (list sublist
)
4149 "Test whether all elements in SUBLIST are members of LIST."
4152 (unless (memq (pop sublist
) list
)
4162 (defvar gnus-group-mode-map nil
)
4163 (put 'gnus-group-mode
'mode-class
'special
)
4165 (unless gnus-group-mode-map
4166 (setq gnus-group-mode-map
(make-keymap))
4167 (suppress-keymap gnus-group-mode-map
)
4169 (gnus-define-keys gnus-group-mode-map
4170 " " gnus-group-read-group
4171 "=" gnus-group-select-group
4172 "\r" gnus-group-select-group
4173 "\M-\r" gnus-group-quick-select-group
4174 "j" gnus-group-jump-to-group
4175 "n" gnus-group-next-unread-group
4176 "p" gnus-group-prev-unread-group
4177 "\177" gnus-group-prev-unread-group
4178 [delete] gnus-group-prev-unread-group
4179 "N" gnus-group-next-group
4180 "P" gnus-group-prev-group
4181 "\M-n" gnus-group-next-unread-group-same-level
4182 "\M-p" gnus-group-prev-unread-group-same-level
4183 "," gnus-group-best-unread-group
4184 "." gnus-group-first-unread-group
4185 "u" gnus-group-unsubscribe-current-group
4186 "U" gnus-group-unsubscribe-group
4187 "c" gnus-group-catchup-current
4188 "C" gnus-group-catchup-current-all
4189 "l" gnus-group-list-groups
4190 "L" gnus-group-list-all-groups
4192 "g" gnus-group-get-new-news
4193 "\M-g" gnus-group-get-new-news-this-group
4194 "R" gnus-group-restart
4195 "r" gnus-group-read-init-file
4196 "B" gnus-group-browse-foreign-server
4197 "b" gnus-group-check-bogus-groups
4198 "F" gnus-find-new-newsgroups
4199 "\C-c\C-d" gnus-group-describe-group
4200 "\M-d" gnus-group-describe-all-groups
4201 "\C-c\C-a" gnus-group-apropos
4202 "\C-c\M-\C-a" gnus-group-description-apropos
4203 "a" gnus-group-post-news
4204 "\ek" gnus-group-edit-local-kill
4205 "\eK" gnus-group-edit-global-kill
4206 "\C-k" gnus-group-kill-group
4207 "\C-y" gnus-group-yank-group
4208 "\C-w" gnus-group-kill-region
4209 "\C-x\C-t" gnus-group-transpose-groups
4210 "\C-c\C-l" gnus-group-list-killed
4211 "\C-c\C-x" gnus-group-expire-articles
4212 "\C-c\M-\C-x" gnus-group-expire-all-groups
4214 "s" gnus-group-save-newsrc
4215 "z" gnus-group-suspend
4216 ; "Z" gnus-group-clear-dribble
4219 "?" gnus-group-describe-briefly
4220 "\C-c\C-i" gnus-info-find-node
4221 "\M-e" gnus-group-edit-group-method
4222 "^" gnus-group-enter-server-mode
4223 gnus-mouse-2 gnus-mouse-pick-group
4224 "<" beginning-of-buffer
4227 "\C-c\C-s" gnus-group-sort-groups
4229 "\C-c\M-g" gnus-activate-all-groups
4230 "\M-&" gnus-group-universal-argument
4231 "#" gnus-group-mark-group
4232 "\M-#" gnus-group-unmark-group)
4234 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4235 "m" gnus-group-mark-group
4236 "u" gnus-group-unmark-group
4237 "w" gnus-group-mark-region
4238 "m" gnus-group-mark-buffer
4239 "r" gnus-group-mark-regexp
4240 "U" gnus-group-unmark-all-groups)
4242 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4243 "d" gnus-group-make-directory-group
4244 "h" gnus-group-make-help-group
4245 "a" gnus-group-make-archive-group
4246 "k" gnus-group-make-kiboze-group
4247 "m" gnus-group-make-group
4248 "E" gnus-group-edit-group
4249 "e" gnus-group-edit-group-method
4250 "p" gnus-group-edit-group-parameters
4251 "v" gnus-group-add-to-virtual
4252 "V" gnus-group-make-empty-virtual
4253 "D" gnus-group-enter-directory
4254 "f" gnus-group-make-doc-group
4255 "r" gnus-group-rename-group
4256 "\177" gnus-group-delete-group
4257 [delete] gnus-group-delete-group
)
4259 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map
)
4260 "b" gnus-group-brew-soup
4261 "w" gnus-soup-save-areas
4262 "s" gnus-soup-send-replies
4263 "p" gnus-soup-pack-packet
4264 "r" nnsoup-pack-replies
)
4266 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map
)
4267 "s" gnus-group-sort-groups
4268 "a" gnus-group-sort-groups-by-alphabet
4269 "u" gnus-group-sort-groups-by-unread
4270 "l" gnus-group-sort-groups-by-level
4271 "v" gnus-group-sort-groups-by-score
4272 "r" gnus-group-sort-groups-by-rank
4273 "m" gnus-group-sort-groups-by-method
)
4275 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map
)
4276 "k" gnus-group-list-killed
4277 "z" gnus-group-list-zombies
4278 "s" gnus-group-list-groups
4279 "u" gnus-group-list-all-groups
4280 "A" gnus-group-list-active
4281 "a" gnus-group-apropos
4282 "d" gnus-group-description-apropos
4283 "m" gnus-group-list-matching
4284 "M" gnus-group-list-all-matching
4285 "l" gnus-group-list-level
)
4287 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map
)
4288 "f" gnus-score-flush-cache
)
4290 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map
)
4291 "f" gnus-group-fetch-faq
)
4293 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map
)
4294 "l" gnus-group-set-current-level
4295 "t" gnus-group-unsubscribe-current-group
4296 "s" gnus-group-unsubscribe-group
4297 "k" gnus-group-kill-group
4298 "y" gnus-group-yank-group
4299 "w" gnus-group-kill-region
4300 "\C-k" gnus-group-kill-level
4301 "z" gnus-group-kill-all-zombies
))
4303 (defun gnus-group-mode ()
4304 "Major mode for reading news.
4306 All normal editing commands are switched off.
4307 \\<gnus-group-mode-map>
4308 The group buffer lists (some of) the groups available. For instance,
4309 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4310 lists all zombie groups.
4312 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4313 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4315 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4317 The following commands are available:
4319 \\{gnus-group-mode-map}"
4321 (when (and menu-bar-mode
4322 (gnus-visual-p 'group-menu
'menu
))
4323 (gnus-group-make-menu-bar))
4324 (kill-all-local-variables)
4325 (gnus-simplify-mode-line)
4326 (setq major-mode
'gnus-group-mode
)
4327 (setq mode-name
"Group")
4328 (gnus-group-set-mode-line)
4329 (setq mode-line-process nil
)
4330 (use-local-map gnus-group-mode-map
)
4331 (buffer-disable-undo (current-buffer))
4332 (setq truncate-lines t
)
4333 (setq buffer-read-only t
)
4334 (gnus-make-local-hook 'post-command-hook
)
4335 (gnus-add-hook 'post-command-hook
'gnus-clear-inboxes-moved nil t
)
4336 (run-hooks 'gnus-group-mode-hook
))
4338 (defun gnus-clear-inboxes-moved ()
4339 (setq nnmail-moved-inboxes nil
))
4341 (defun gnus-mouse-pick-group (e)
4342 "Enter the group under the mouse pointer."
4345 (gnus-group-read-group nil
))
4347 ;; Look at LEVEL and find out what the level is really supposed to be.
4348 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4349 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4350 (defun gnus-group-default-level (&optional level number-or-nil
)
4352 (gnus-group-use-permanent-levels
4353 (or (setq gnus-group-use-permanent-levels
4354 (or level
(if (numberp gnus-group-use-permanent-levels
)
4355 gnus-group-use-permanent-levels
4356 (or gnus-group-default-list-level
4357 gnus-level-subscribed
))))
4358 gnus-group-default-list-level gnus-level-subscribed
))
4362 (or level gnus-group-default-list-level gnus-level-subscribed
))))
4365 (defun gnus-slave-no-server (&optional arg
)
4366 "Read network news as a slave, without connecting to local server"
4368 (gnus-no-server arg t
))
4371 (defun gnus-no-server (&optional arg slave
)
4373 If ARG is a positive number, Gnus will use that as the
4374 startup level. If ARG is nil, Gnus will be started at level 2.
4375 If ARG is non-nil and not a positive number, Gnus will
4376 prompt the user for the name of an NNTP server to use.
4377 As opposed to `gnus', this command will not connect to the local server."
4379 (let ((val (or arg
(1- gnus-level-default-subscribed
))))
4381 (make-local-variable 'gnus-group-use-permanent-levels
)
4382 (setq gnus-group-use-permanent-levels val
)))
4385 (defun gnus-slave (&optional arg
)
4386 "Read news as a slave."
4388 (gnus arg nil
'slave
))
4391 (defun gnus-other-frame (&optional arg
)
4392 "Pop up a frame to read news."
4394 (if (get-buffer gnus-group-buffer
)
4395 (let ((pop-up-frames t
))
4397 (select-frame (make-frame))
4401 (defun gnus (&optional arg dont-connect slave
)
4403 If ARG is non-nil and a positive number, Gnus will use that as the
4404 startup level. If ARG is non-nil and not a positive number, Gnus will
4405 prompt the user for the name of an NNTP server to use."
4408 (if (get-buffer gnus-group-buffer
)
4410 (switch-to-buffer gnus-group-buffer
)
4411 (gnus-group-get-new-news))
4414 (nnheader-init-server-buffer)
4415 (gnus-read-init-file)
4416 (setq gnus-slave slave
)
4418 (gnus-group-setup-buffer)
4419 (let ((buffer-read-only nil
))
4421 (if (not gnus-inhibit-startup-message
)
4423 (gnus-group-startup-message)
4426 (let ((level (and (numberp arg
) (> arg
0) arg
))
4432 (gnus-start-news-server (and arg
(not level
))))))
4433 (if (and (not dont-connect
)
4436 (run-hooks 'gnus-startup-hook
)
4437 ;; NNTP server is successfully open.
4439 ;; Find the current startup file name.
4440 (setq gnus-current-startup-file
4441 (gnus-make-newsrc-file gnus-startup-file
))
4443 ;; Read the dribble file.
4444 (when (or gnus-slave gnus-use-dribble-file
)
4445 (gnus-dribble-read-file))
4447 ;; Allow using GroupLens predictions.
4448 (when gnus-use-grouplens
4450 (add-hook 'gnus-summary-mode-hook
'gnus-grouplens-mode
))
4452 (gnus-summary-make-display-table)
4453 ;; Do the actual startup.
4454 (gnus-setup-news nil level dont-connect
)
4455 ;; Generate the group buffer.
4456 (gnus-group-list-groups level
)
4457 (gnus-group-first-unread-group)
4458 (gnus-configure-windows 'group
)
4459 (gnus-group-set-mode-line))))))
4461 (defun gnus-unload ()
4462 "Unload all Gnus features."
4464 (or (boundp 'load-history
)
4465 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4466 (let ((history load-history
)
4469 (and (string-match "^\\(gnus\\|nn\\)" (caar history
))
4470 (setq feature
(cdr (assq 'provide
(car history
))))
4471 (unload-feature feature
'force
))
4472 (setq history
(cdr history
)))))
4474 (defun gnus-compile ()
4475 "Byte-compile the user-defined format specs."
4477 (let ((entries gnus-format-specs
)
4478 entry gnus-tmp-func
)
4480 (gnus-message 7 "Compiling format specs...")
4483 (setq entry
(pop entries
))
4484 (if (eq (car entry
) 'version
)
4485 (setq gnus-format-specs
(delq entry gnus-format-specs
))
4486 (when (and (listp (caddr entry
))
4487 (not (eq 'byte-code
(caaddr entry
))))
4488 (fset 'gnus-tmp-func
4489 `(lambda () ,(caddr entry
)))
4490 (byte-compile 'gnus-tmp-func
)
4491 (setcar (cddr entry
) (gnus-byte-code 'gnus-tmp-func
)))))
4493 (push (cons 'version emacs-version
) gnus-format-specs
)
4495 (gnus-message 7 "Compiling user specs...done"))))
4497 (defun gnus-indent-rigidly (start end arg
)
4498 "Indent rigidly using only spaces and no tabs."
4501 (narrow-to-region start end
)
4502 (indent-rigidly start end arg
)
4503 (goto-char (point-min))
4504 (while (search-forward "\t" nil t
)
4505 (replace-match " " t t
)))))
4507 (defun gnus-group-startup-message (&optional x y
)
4508 "Insert startup message in current buffer."
4509 ;; Insert the message.
4514 _ ___ __ ___ __ _ ___
4533 ;; And then hack it.
4534 (gnus-indent-rigidly (point-min) (point-max)
4535 (/ (max (- (window-width) (or x
46)) 0) 2))
4536 (goto-char (point-min))
4538 (let* ((pheight (count-lines (point-min) (point-max)))
4539 (wheight (window-height))
4540 (rest (- wheight pheight
)))
4541 (insert (make-string (max 0 (* 2 (/ rest
3))) ?
\n)))
4543 (goto-char (point-min))
4544 (and (search-forward "Praxis" nil t
)
4545 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face
'bold
))
4546 (goto-char (point-min))
4547 (let* ((mode-string (gnus-group-set-mode-line)))
4548 (setq mode-line-buffer-identification
4549 (list (concat gnus-version
(substring (car mode-string
) 4))))
4550 (set-buffer-modified-p t
)))
4552 (defun gnus-group-setup-buffer ()
4553 (or (get-buffer gnus-group-buffer
)
4555 (switch-to-buffer gnus-group-buffer
)
4556 (gnus-add-current-to-buffer-list)
4558 (and gnus-carpal
(gnus-carpal-setup-buffer 'group
)))))
4560 (defun gnus-group-list-groups (&optional level unread lowest
)
4561 "List newsgroups with level LEVEL or lower that have unread articles.
4562 Default is all subscribed groups.
4563 If argument UNREAD is non-nil, groups with no unread articles are also
4565 (interactive (list (if current-prefix-arg
4566 (prefix-numeric-value current-prefix-arg
)
4568 (gnus-group-default-level nil t
)
4569 gnus-group-default-list-level
4570 gnus-level-subscribed
))))
4572 (setq level
(car gnus-group-list-mode
)
4573 unread
(cdr gnus-group-list-mode
)))
4574 (setq level
(gnus-group-default-level level
))
4575 (gnus-group-setup-buffer) ;May call from out of group buffer
4576 (gnus-update-format-specifications)
4577 (let ((case-fold-search nil
)
4578 (props (text-properties-at (gnus-point-at-bol)))
4579 (group (gnus-group-group-name)))
4580 (set-buffer gnus-group-buffer
)
4581 (funcall gnus-group-prepare-function level unread lowest
)
4582 (if (zerop (buffer-size))
4583 (gnus-message 5 gnus-no-groups-message
)
4584 (goto-char (point-max))
4585 (when (or (not gnus-group-goto-next-group-function
)
4586 (not (funcall gnus-group-goto-next-group-function
4589 ;; Go to the first group with unread articles.
4590 (gnus-group-search-forward t
)
4591 ;; Find the right group to put point on. If the current group
4592 ;; has disappeared in the new listing, try to find the next
4593 ;; one. If no next one can be found, just leave point at the
4594 ;; first newsgroup in the buffer.
4595 (if (not (gnus-goto-char
4597 (point-min) (point-max)
4598 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
))))
4599 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb
))))
4601 (not (gnus-goto-char
4603 (point-min) (point-max) 'gnus-group
4605 (caar newsrc
) gnus-active-hashtb
)))))
4606 (setq newsrc
(cdr newsrc
)))
4607 (or newsrc
(progn (goto-char (point-max))
4608 (forward-line -
1)))))))
4609 ;; Adjust cursor point.
4610 (gnus-group-position-point))))
4612 (defun gnus-group-list-level (level &optional all
)
4613 "List groups on LEVEL.
4614 If ALL (the prefix), also list groups that have no unread articles."
4615 (interactive "nList groups on level: \nP")
4616 (gnus-group-list-groups level all level
))
4618 (defun gnus-group-prepare-flat (level &optional all lowest regexp
)
4619 "List all newsgroups with unread articles of level LEVEL or lower.
4620 If ALL is non-nil, list groups that have no unread articles.
4621 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4622 If REGEXP, only list groups matching REGEXP."
4623 (set-buffer gnus-group-buffer
)
4624 (let ((buffer-read-only nil
)
4625 (newsrc (cdr gnus-newsrc-alist
))
4626 (lowest (or lowest
1))
4627 info clevel unread group params
)
4629 (if (< lowest gnus-level-zombie
)
4630 ;; List living groups.
4632 (setq info
(car newsrc
)
4633 group
(gnus-info-group info
)
4634 params
(gnus-info-params info
)
4636 unread
(car (gnus-gethash group gnus-newsrc-hashtb
)))
4637 (and unread
; This group might be bogus
4639 (string-match regexp group
))
4640 (<= (setq clevel
(gnus-info-level info
)) level
)
4642 (or all
; We list all groups?
4643 (if (eq unread t
) ; Unactivated?
4644 gnus-group-list-inactive-groups
; We list unactivated
4645 (> unread
0)) ; We list groups with unread articles
4646 (and gnus-list-groups-with-ticked-articles
4647 (cdr (assq 'tick
(gnus-info-marks info
))))
4648 ; And groups with tickeds
4649 ;; Check for permanent visibility.
4650 (and gnus-permanently-visible-groups
4651 (string-match gnus-permanently-visible-groups
4653 (memq 'visible params
)
4654 (cdr (assq 'visible params
)))
4655 (gnus-group-insert-group-line
4656 group
(gnus-info-level info
)
4657 (gnus-info-marks info
) unread
(gnus-info-method info
)))))
4659 ;; List dead groups.
4660 (and (>= level gnus-level-zombie
) (<= lowest gnus-level-zombie
)
4661 (gnus-group-prepare-flat-list-dead
4662 (setq gnus-zombie-list
(sort gnus-zombie-list
'string
<))
4663 gnus-level-zombie ?Z
4665 (and (>= level gnus-level-killed
) (<= lowest gnus-level-killed
)
4666 (gnus-group-prepare-flat-list-dead
4667 (setq gnus-killed-list
(sort gnus-killed-list
'string
<))
4668 gnus-level-killed ?K regexp
))
4670 (gnus-group-set-mode-line)
4671 (setq gnus-group-list-mode
(cons level all
))
4672 (run-hooks 'gnus-group-prepare-hook
)))
4674 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp
)
4675 ;; List zombies and killed lists somewhat faster, which was
4676 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4677 ;; this by ignoring the group format specification altogether.
4680 ;; This loop is used when listing groups that match some
4683 (setq group
(pop groups
))
4684 (when (string-match regexp group
)
4685 (gnus-add-text-properties
4686 (point) (prog1 (1+ (point))
4687 (insert " " mark
" *: " group
"\n"))
4688 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
4690 'gnus-level level
))))
4691 ;; This loop is used when listing all groups.
4693 (gnus-add-text-properties
4694 (point) (prog1 (1+ (point))
4695 (insert " " mark
" *: "
4696 (setq group
(pop groups
)) "\n"))
4697 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
4699 'gnus-level level
))))))
4701 (defmacro gnus-group-real-name
(group)
4702 "Find the real name of a foreign newsgroup."
4703 `(let ((gname ,group
))
4704 (if (string-match ":[^:]+$" gname
)
4705 (substring gname
(1+ (match-beginning 0)))
4708 (defsubst gnus-server-add-address
(method)
4709 (let ((method-name (symbol-name (car method
))))
4710 (if (and (memq 'address
(assoc method-name gnus-valid-select-methods
))
4711 (not (assq (intern (concat method-name
"-address")) method
)))
4712 (append method
(list (list (intern (concat method-name
"-address"))
4716 (defsubst gnus-server-get-method
(group method
)
4717 ;; Input either a server name, and extended server name, or a
4718 ;; select method, and return a select method.
4719 (cond ((stringp method
)
4720 (gnus-server-to-method method
))
4721 ((equal method gnus-select-method
)
4723 ((and (stringp (car method
)) group
)
4724 (gnus-server-extend-method group method
))
4725 ((and method
(not group
)
4726 (equal (cadr method
) ""))
4729 (gnus-server-add-address method
))))
4731 (defun gnus-server-to-method (server)
4732 "Map virtual server names to select methods."
4734 ;; Is this a method, perhaps?
4735 (and server
(listp server
) server
)
4736 ;; Perhaps this is the native server?
4737 (and (equal server
"native") gnus-select-method
)
4738 ;; It should be in the server alist.
4739 (cdr (assoc server gnus-server-alist
))
4740 ;; If not, we look through all the opened server
4741 ;; to see whether we can find it there.
4742 (let ((opened gnus-opened-servers
))
4744 (not (equal server
(format "%s:%s" (caaar opened
)
4749 (defmacro gnus-method-equal
(ss1 ss2
)
4750 "Say whether two servers are equal."
4754 (and (= (length s1
) (length s2
))
4756 (while (and s1
(member (car s1
) s2
))
4760 (defun gnus-server-equal (m1 m2
)
4761 "Say whether two methods are equal."
4762 (let ((m1 (cond ((null m1
) gnus-select-method
)
4763 ((stringp m1
) (gnus-server-to-method m1
))
4765 (m2 (cond ((null m2
) gnus-select-method
)
4766 ((stringp m2
) (gnus-server-to-method m2
))
4768 (gnus-method-equal m1 m2
)))
4770 (defun gnus-servers-using-backend (backend)
4771 "Return a list of known servers using BACKEND."
4772 (let ((opened gnus-opened-servers
)
4775 (when (eq backend
(caaar opened
))
4776 (push (caar opened
) out
))
4780 (defun gnus-archive-server-wanted-p ()
4781 "Say whether the user wants to use the archive server."
4783 ((or (not gnus-message-archive-method
)
4784 (not gnus-message-archive-group
))
4786 ((and gnus-message-archive-method gnus-message-archive-group
)
4789 (let ((active (cadr (assq 'nnfolder-active-file
4790 gnus-message-archive-method
))))
4792 (file-exists-p active
))))))
4794 (defun gnus-group-prefixed-name (group method
)
4795 "Return the whole name from GROUP and METHOD."
4796 (and (stringp method
) (setq method
(gnus-server-to-method method
)))
4797 (concat (format "%s" (car method
))
4799 (or (assoc (format "%s" (car method
))
4800 (gnus-methods-using 'address
))
4801 (gnus-server-equal method gnus-message-archive-method
))
4803 (not (string= (nth 1 method
) "")))
4804 (concat "+" (nth 1 method
)))
4807 (defun gnus-group-real-prefix (group)
4808 "Return the prefix of the current group name."
4809 (if (string-match "^[^:]+:" group
)
4810 (substring group
0 (match-end 0))
4813 (defun gnus-group-method (group)
4814 "Return the server or method used for selecting GROUP."
4815 (let ((prefix (gnus-group-real-prefix group
)))
4816 (if (equal prefix
"")
4818 (let ((servers gnus-opened-servers
)
4820 backend possible found
)
4821 (if (string-match "^[^\\+]+\\+" prefix
)
4822 (setq backend
(intern (substring prefix
0 (1- (match-end 0))))
4823 server
(substring prefix
(match-end 0) (1- (length prefix
))))
4824 (setq backend
(intern (substring prefix
0 (1- (length prefix
))))))
4826 (when (eq (caaar servers
) backend
)
4827 (setq possible
(caar servers
))
4828 (when (equal (cadaar servers
) server
)
4829 (setq found
(caar servers
))))
4831 (or (car (rassoc found gnus-server-alist
))
4833 (car (rassoc possible gnus-server-alist
))
4835 (list backend server
))))))
4837 (defsubst gnus-secondary-method-p
(method)
4838 "Return whether METHOD is a secondary select method."
4839 (let ((methods gnus-secondary-select-methods
)
4840 (gmethod (gnus-server-get-method nil method
)))
4842 (not (equal (gnus-server-get-method nil
(car methods
))
4844 (setq methods
(cdr methods
)))
4847 (defun gnus-group-foreign-p (group)
4848 "Say whether a group is foreign or not."
4849 (and (not (gnus-group-native-p group
))
4850 (not (gnus-group-secondary-p group
))))
4852 (defun gnus-group-native-p (group)
4853 "Say whether the group is native or not."
4854 (not (string-match ":" group
)))
4856 (defun gnus-group-secondary-p (group)
4857 "Say whether the group is secondary or not."
4858 (gnus-secondary-method-p (gnus-find-method-for-group group
)))
4860 (defun gnus-group-get-parameter (group &optional symbol
)
4861 "Returns the group parameters for GROUP.
4862 If SYMBOL, return the value of that symbol in the group parameters."
4863 (let ((params (gnus-info-params (gnus-get-info group
))))
4865 (gnus-group-parameter-value params symbol
)
4868 (defun gnus-group-parameter-value (params symbol
)
4869 "Return the value of SYMBOL in group PARAMS."
4870 (or (car (memq symbol params
)) ; It's either a simple symbol
4871 (cdr (assq symbol params
)))) ; or a cons.
4873 (defun gnus-group-add-parameter (group param
)
4874 "Add parameter PARAM to GROUP."
4875 (let ((info (gnus-get-info group
)))
4877 () ; This is a dead group. We just ignore it.
4878 ;; Cons the new param to the old one and update.
4879 (gnus-group-set-info (cons param
(gnus-info-params info
))
4882 (defun gnus-group-set-parameter (group name value
)
4883 "Set parameter NAME to VALUE in GROUP."
4884 (let ((info (gnus-get-info group
)))
4886 () ; This is a dead group. We just ignore it.
4887 (let ((old-params (gnus-info-params info
))
4888 (new-params (list (cons name value
))))
4890 (if (or (not (listp (car old-params
)))
4891 (not (eq (caar old-params
) name
)))
4892 (setq new-params
(append new-params
(list (car old-params
)))))
4893 (setq old-params
(cdr old-params
)))
4894 (gnus-group-set-info new-params group
'params
)))))
4896 (defun gnus-group-add-score (group &optional score
)
4897 "Add SCORE to the GROUP score.
4898 If SCORE is nil, add 1 to the score of GROUP."
4899 (let ((info (gnus-get-info group
)))
4901 (gnus-info-set-score info
(+ (gnus-info-score info
) (or score
1))))))
4903 (defun gnus-summary-bubble-group ()
4904 "Increase the score of the current group.
4905 This is a handy function to add to `gnus-summary-exit-hook' to
4906 increase the score of each group you read."
4907 (gnus-group-add-score gnus-newsgroup-name
))
4909 (defun gnus-group-set-info (info &optional method-only-group part
)
4910 (let* ((entry (gnus-gethash
4911 (or method-only-group
(gnus-info-group info
))
4912 gnus-newsrc-hashtb
))
4914 (info (if method-only-group
(nth 2 entry
) info
))
4916 (when method-only-group
4918 (error "Trying to change non-existent group %s" method-only-group
))
4919 ;; We have received parts of the actual group info - either the
4920 ;; select method or the group parameters. We first check
4921 ;; whether we have to extend the info, and if so, do that.
4922 (let ((len (length info
))
4923 (total (if (eq part
'method
) 5 6)))
4925 (setcdr (nthcdr (1- len
) info
)
4926 (make-list (- total len
) nil
)))
4927 ;; Then we enter the new info.
4928 (setcar (nthcdr (1- total
) info
) part-info
)))
4930 ;; This is a new group, so we just create it.
4932 (set-buffer gnus-group-buffer
)
4933 (setq method
(gnus-info-method info
))
4934 (when (gnus-server-equal method
"native")
4937 (set-buffer gnus-group-buffer
)
4939 ;; It's a foreign group...
4940 (gnus-group-make-group
4941 (gnus-group-real-name (gnus-info-group info
))
4942 (if (stringp method
) method
4943 (prin1-to-string (car method
)))
4945 (nth 1 (gnus-info-method info
))))
4946 ;; It's a native group.
4947 (gnus-group-make-group (gnus-info-group info
))))
4948 (gnus-message 6 "Note: New group created")
4950 (gnus-gethash (gnus-group-prefixed-name
4951 (gnus-group-real-name (gnus-info-group info
))
4952 (or (gnus-info-method info
) gnus-select-method
))
4953 gnus-newsrc-hashtb
))))
4954 ;; Whether it was a new group or not, we now have the entry, so we
4955 ;; can do the update.
4958 (setcar (nthcdr 2 entry
) info
)
4959 (when (and (not (eq (car entry
) t
))
4960 (gnus-active (gnus-info-group info
)))
4961 (setcar entry
(length (gnus-list-of-unread-articles (car info
))))))
4962 (error "No such group: %s" (gnus-info-group info
)))))
4964 (defun gnus-group-set-method-info (group select-method
)
4965 (gnus-group-set-info select-method group
'method
))
4967 (defun gnus-group-set-params-info (group params
)
4968 (gnus-group-set-info params group
'params
))
4970 (defun gnus-group-update-group-line ()
4971 "Update the current line in the group buffer."
4972 (let* ((buffer-read-only nil
)
4973 (group (gnus-group-group-name))
4974 (entry (and group
(gnus-gethash group gnus-newsrc-hashtb
)))
4975 gnus-group-indentation
)
4978 (not (gnus-ephemeral-group-p group
))
4980 (concat "(gnus-group-set-info '"
4981 (prin1-to-string (nth 2 entry
)) ")")))
4982 (setq gnus-group-indentation
(gnus-group-group-indentation))
4984 (gnus-group-insert-group-line-info group
)
4986 (gnus-group-position-point))))
4988 (defun gnus-group-insert-group-line-info (group)
4989 "Insert GROUP on the current line."
4990 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
))
4994 ;; (Un)subscribed group.
4995 (setq info
(nth 2 entry
))
4996 (gnus-group-insert-group-line
4997 group
(gnus-info-level info
) (gnus-info-marks info
)
4998 (or (car entry
) t
) (gnus-info-method info
)))
4999 ;; This group is dead.
5000 (gnus-group-insert-group-line
5002 (if (member group gnus-zombie-list
) gnus-level-zombie gnus-level-killed
)
5004 (if (setq active
(gnus-active group
))
5005 (- (1+ (cdr active
)) (car active
)) 0)
5008 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5009 gnus-tmp-marked number
5011 "Insert a group line in the group buffer."
5012 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group
))
5013 (gnus-tmp-number-total
5015 (1+ (- (cdr gnus-tmp-active
) (car gnus-tmp-active
)))
5017 (gnus-tmp-number-of-unread
5018 (if (numberp number
) (int-to-string (max 0 number
))
5020 (gnus-tmp-number-of-read
5021 (if (numberp number
)
5022 (int-to-string (max 0 (- gnus-tmp-number-total number
)))
5024 (gnus-tmp-subscribed
5025 (cond ((<= gnus-tmp-level gnus-level-subscribed
) ?
)
5026 ((<= gnus-tmp-level gnus-level-unsubscribed
) ?U
)
5027 ((= gnus-tmp-level gnus-level-zombie
) ?Z
)
5029 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group
))
5030 (gnus-tmp-newsgroup-description
5031 (if gnus-description-hashtb
5032 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb
) "")
5035 (if (member gnus-tmp-group gnus-moderated-list
) ?m ?
))
5036 (gnus-tmp-moderated-string
5037 (if (eq gnus-tmp-moderated ?m
) "(m)" ""))
5039 (gnus-server-get-method gnus-tmp-group gnus-tmp-method
))
5040 (gnus-tmp-news-server (or (cadr gnus-tmp-method
) ""))
5041 (gnus-tmp-news-method (or (car gnus-tmp-method
) ""))
5042 (gnus-tmp-news-method-string
5044 (format "(%s:%s)" (car gnus-tmp-method
)
5045 (cadr gnus-tmp-method
)) ""))
5046 (gnus-tmp-marked-mark
5047 (if (and (numberp number
)
5049 (cdr (assq 'tick gnus-tmp-marked
)))
5051 (gnus-tmp-process-marked
5052 (if (member gnus-tmp-group gnus-group-marked
)
5053 gnus-process-mark ?
))
5055 (or (and gnus-use-grouplens
5056 (bbb-grouplens-group-p gnus-tmp-group
))
5058 (buffer-read-only nil
)
5059 header gnus-tmp-header
) ; passed as parameter to user-funcs.
5061 (gnus-add-text-properties
5065 (eval gnus-group-line-format-spec
))
5066 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb
)
5067 gnus-unread
,(if (numberp number
)
5068 (string-to-int gnus-tmp-number-of-unread
)
5070 gnus-marked
,gnus-tmp-marked-mark
5071 gnus-indentation
,gnus-group-indentation
5072 gnus-level
,gnus-tmp-level
))
5073 (when (inline (gnus-visual-p 'group-highlight
'highlight
))
5075 (run-hooks 'gnus-group-update-hook
)
5077 ;; Allow XEmacs to remove front-sticky text properties.
5078 (gnus-group-remove-excess-properties)))
5080 (defun gnus-group-update-group (group &optional visible-only
)
5081 "Update all lines where GROUP appear.
5082 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5085 (set-buffer gnus-group-buffer
)
5086 ;; The buffer may be narrowed.
5089 (let ((ident (gnus-intern-safe group gnus-active-hashtb
))
5091 found buffer-read-only
)
5092 ;; Enter the current status into the dribble buffer.
5093 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
)))
5094 (if (and entry
(not (gnus-ephemeral-group-p group
)))
5096 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry
))
5098 ;; Find all group instances. If topics are in use, each group
5099 ;; may be listed in more than once.
5100 (while (setq loc
(text-property-any
5101 loc
(point-max) 'gnus-group ident
))
5104 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5106 (gnus-group-insert-group-line-info group
)
5109 (run-hooks 'gnus-group-update-group-hook
)))
5110 (setq loc
(1+ loc
)))
5111 (unless (or found visible-only
)
5112 ;; No such line in the buffer, find out where it's supposed to
5113 ;; go, and insert it there (or at the end of the buffer).
5114 (if gnus-goto-missing-group-function
5115 (funcall gnus-goto-missing-group-function group
)
5116 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb
))))
5117 (while (and entry
(car entry
)
5121 (point-min) (point-max)
5122 'gnus-group
(gnus-intern-safe
5123 (caar entry
) gnus-active-hashtb
)))))
5124 (setq entry
(cdr entry
)))
5125 (or entry
(goto-char (point-max)))))
5126 ;; Finally insert the line.
5127 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5128 (gnus-group-insert-group-line-info group
)
5131 (run-hooks 'gnus-group-update-group-hook
))))
5132 (gnus-group-set-mode-line)))))
5134 (defun gnus-group-set-mode-line ()
5135 "Update the mode line in the group buffer."
5136 (when (memq 'group gnus-updated-mode-lines
)
5137 ;; Yes, we want to keep this mode line updated.
5139 (set-buffer gnus-group-buffer
)
5140 (let* ((gformat (or gnus-group-mode-line-format-spec
5141 (setq gnus-group-mode-line-format-spec
5143 gnus-group-mode-line-format
5144 gnus-group-mode-line-format-alist
))))
5145 (gnus-tmp-news-server (cadr gnus-select-method
))
5146 (gnus-tmp-news-method (car gnus-select-method
))
5147 (gnus-tmp-colon (if (equal gnus-tmp-news-server
"") "" ":"))
5149 gnus-tmp-header
;Dummy binding for user-defined formats
5150 ;; Get the resulting string.
5152 (and gnus-dribble-buffer
5153 (buffer-name gnus-dribble-buffer
)
5154 (buffer-modified-p gnus-dribble-buffer
)
5156 (set-buffer gnus-dribble-buffer
)
5157 (not (zerop (buffer-size))))))
5158 (mode-string (eval gformat
)))
5159 ;; Say whether the dribble buffer has been modified.
5160 (setq mode-line-modified
5161 (if modified
"---*- " "----- "))
5162 ;; If the line is too long, we chop it off.
5163 (when (> (length mode-string
) max-len
)
5164 (setq mode-string
(substring mode-string
0 (- max-len
4))))
5166 (setq mode-line-buffer-identification
5167 (gnus-mode-line-buffer-identification
5168 (list mode-string
)))
5169 (set-buffer-modified-p modified
))))))
5171 (defun gnus-group-group-name ()
5172 "Get the name of the newsgroup on the current line."
5173 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group
)))
5174 (and group
(symbol-name group
))))
5176 (defun gnus-group-group-level ()
5177 "Get the level of the newsgroup on the current line."
5178 (get-text-property (gnus-point-at-bol) 'gnus-level
))
5180 (defun gnus-group-group-indentation ()
5181 "Get the indentation of the newsgroup on the current line."
5182 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation
)
5183 (and gnus-group-indentation-function
5184 (funcall gnus-group-indentation-function
))
5187 (defun gnus-group-group-unread ()
5188 "Get the number of unread articles of the newsgroup on the current line."
5189 (get-text-property (gnus-point-at-bol) 'gnus-unread
))
5191 (defun gnus-group-search-forward (&optional backward all level first-too
)
5192 "Find the next newsgroup with unread articles.
5193 If BACKWARD is non-nil, find the previous newsgroup instead.
5194 If ALL is non-nil, just find any newsgroup.
5195 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5197 If FIRST-TOO, the current line is also eligible as a target."
5198 (let ((way (if backward -
1 1))
5199 (low gnus-level-killed
)
5202 (if (and backward
(progn (beginning-of-line)) (bobp))
5204 (or first-too
(forward-line way
))
5212 (get-text-property (point) 'gnus-unread
)))
5213 (and (numberp unread
) (> unread
0)))
5214 (setq lev
(get-text-property (point)
5216 (<= lev gnus-level-subscribed
)))
5218 (and (setq lev
(get-text-property (point)
5227 (zerop (forward-line way
)))))
5229 (progn (gnus-group-position-point) t
)
5230 (goto-char (or pos beg
))
5233 ;;; Gnus group mode commands
5237 (defun gnus-group-mark-group (n &optional unmark no-advance
)
5238 "Mark the current group."
5240 (let ((buffer-read-only nil
)
5244 (when (setq group
(gnus-group-group-name))
5248 (or (cdr (assq 'process gnus-group-mark-positions
)) 2))
5253 (setq gnus-group-marked
(delete group gnus-group-marked
)))
5255 (setq gnus-group-marked
5256 (cons group
(delete group gnus-group-marked
)))))
5257 (or no-advance
(gnus-group-next-group 1))
5259 (gnus-summary-position-point)
5262 (defun gnus-group-unmark-group (n)
5263 "Remove the mark from the current group."
5265 (gnus-group-mark-group n
'unmark
)
5266 (gnus-group-position-point))
5268 (defun gnus-group-unmark-all-groups ()
5269 "Unmark all groups."
5271 (let ((groups gnus-group-marked
))
5274 (gnus-group-remove-mark (pop groups
)))))
5275 (gnus-group-position-point))
5277 (defun gnus-group-mark-region (unmark beg end
)
5278 "Mark all groups between point and mark.
5279 If UNMARK, remove the mark instead."
5280 (interactive "P\nr")
5281 (let ((num (count-lines beg end
)))
5284 (- num
(gnus-group-mark-group num unmark
)))))
5286 (defun gnus-group-mark-buffer (&optional unmark
)
5287 "Mark all groups in the buffer.
5288 If UNMARK, remove the mark instead."
5290 (gnus-group-mark-region unmark
(point-min) (point-max)))
5292 (defun gnus-group-mark-regexp (regexp)
5293 "Mark all groups that match some regexp."
5294 (interactive "sMark (regexp): ")
5295 (let ((alist (cdr gnus-newsrc-alist
))
5298 (when (string-match regexp
(setq group
(gnus-info-group (pop alist
))))
5299 (gnus-group-set-mark group
))))
5300 (gnus-group-position-point))
5302 (defun gnus-group-remove-mark (group)
5303 "Remove the process mark from GROUP and move point there.
5304 Return nil if the group isn't displayed."
5305 (if (gnus-group-goto-group group
)
5307 (gnus-group-mark-group 1 'unmark t
)
5309 (setq gnus-group-marked
5310 (delete group gnus-group-marked
))
5313 (defun gnus-group-set-mark (group)
5314 "Set the process mark on GROUP."
5315 (if (gnus-group-goto-group group
)
5317 (gnus-group-mark-group 1 nil t
))
5318 (setq gnus-group-marked
(cons group
(delete group gnus-group-marked
)))))
5320 (defun gnus-group-universal-argument (arg &optional groups func
)
5321 "Perform any command on all groups accoring to the process/prefix convention."
5323 (let ((groups (or groups
(gnus-group-process-prefix arg
)))
5325 (if (eq (setq func
(or func
5328 (substitute-command-keys
5329 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5331 (gnus-error 1 "Undefined key")
5333 (gnus-group-remove-mark (setq group
(pop groups
)))
5334 (command-execute func
))))
5335 (gnus-group-position-point))
5337 (defun gnus-group-process-prefix (n)
5338 "Return a list of groups to work on.
5339 Take into consideration N (the prefix) and the list of marked groups."
5342 (setq n
(prefix-numeric-value n
))
5343 ;; There is a prefix, so we return a list of the N next
5345 (let ((way (if (< n
0) -
1 1))
5350 (setq group
(gnus-group-group-name)))
5351 (setq groups
(cons group groups
))
5353 (gnus-group-next-group way
)))
5355 ((and (boundp 'transient-mark-mode
)
5357 (boundp 'mark-active
)
5359 ;; Work on the region between point and mark.
5360 (let ((max (max (point) (mark)))
5363 (goto-char (min (point) (mark)))
5366 (push (gnus-group-group-name) groups
)
5367 (zerop (gnus-group-next-group 1))
5369 (nreverse groups
))))
5371 ;; No prefix, but a list of marked articles.
5372 (reverse gnus-group-marked
))
5374 ;; Neither marked articles or a prefix, so we return the
5376 (let ((group (gnus-group-group-name)))
5377 (and group
(list group
))))))
5379 ;; Selecting groups.
5381 (defun gnus-group-read-group (&optional all no-article group
)
5382 "Read news in this newsgroup.
5383 If the prefix argument ALL is non-nil, already read articles become
5384 readable. IF ALL is a number, fetch this number of articles. If the
5385 optional argument NO-ARTICLE is non-nil, no article will be
5386 auto-selected upon group entry. If GROUP is non-nil, fetch that
5389 (let ((group (or group
(gnus-group-group-name)))
5390 number active marked entry
)
5391 (or group
(error "No group on current line"))
5392 (setq marked
(nth 3 (nth 2 (setq entry
(gnus-gethash
5393 group gnus-newsrc-hashtb
)))))
5394 ;; This group might be a dead group. In that case we have to get
5395 ;; the number of unread articles from `gnus-active-hashtb'.
5397 (cond ((numberp all
) all
)
5399 ((setq active
(gnus-active group
))
5400 (- (1+ (cdr active
)) (car active
)))))
5401 (gnus-summary-read-group
5402 group
(or all
(and (numberp number
)
5403 (zerop (+ number
(length (cdr (assq 'tick marked
)))
5404 (length (cdr (assq 'dormant marked
)))))))
5407 (defun gnus-group-select-group (&optional all
)
5408 "Select this newsgroup.
5409 No article is selected automatically.
5410 If ALL is non-nil, already read articles become readable.
5411 If ALL is a number, fetch this number of articles."
5413 (gnus-group-read-group all t
))
5415 (defun gnus-group-quick-select-group (&optional all
)
5416 "Select the current group \"quickly\".
5417 This means that no highlighting or scoring will be performed."
5420 gnus-score-find-score-files-function
5421 gnus-apply-kill-hook
5422 gnus-summary-expunge-below
)
5423 (gnus-group-read-group all t
)))
5425 (defun gnus-group-visible-select-group (&optional all
)
5426 "Select the current group without hiding any articles."
5428 (let ((gnus-inhibit-limiting t
))
5429 (gnus-group-read-group all t
)))
5432 (defun gnus-fetch-group (group)
5433 "Start Gnus if necessary and enter GROUP.
5434 Returns whether the fetching was successful or not."
5435 (interactive "sGroup name: ")
5436 (or (get-buffer gnus-group-buffer
)
5438 (gnus-group-read-group nil nil group
))
5440 ;; Enter a group that is not in the group buffer. Non-nil is returned
5441 ;; if selection was successful.
5442 (defun gnus-group-read-ephemeral-group
5443 (group method
&optional activate quit-config
)
5444 (let ((group (if (gnus-group-foreign-p group
) group
5445 (gnus-group-prefixed-name group method
))))
5448 `(t nil
(,group
,gnus-level-default-subscribed nil nil
,method
5449 ((quit-config .
,(if quit-config quit-config
5450 (cons (current-buffer) 'summary
))))))
5452 (set-buffer gnus-group-buffer
)
5453 (or (gnus-check-server method
)
5454 (error "Unable to contact server: %s" (gnus-status-message method
)))
5455 (if activate
(or (gnus-request-group group
)
5456 (error "Couldn't request group")))
5458 (gnus-group-read-group t t group
)
5462 (defun gnus-group-jump-to-group (group)
5463 "Jump to newsgroup GROUP."
5465 (list (completing-read
5466 "Group: " gnus-active-hashtb nil
5467 (gnus-read-active-file-p)
5469 'gnus-group-history
)))
5471 (when (equal group
"")
5472 (error "Empty group name"))
5474 (when (string-match "[\000-\032]" group
)
5475 (error "Control characters in group: %s" group
))
5477 (let ((b (text-property-any
5478 (point-min) (point-max)
5479 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
))))
5480 (unless (gnus-ephemeral-group-p group
)
5482 ;; Either go to the line in the group buffer...
5484 ;; ... or insert the line.
5487 (gnus-activate-group group
)
5488 (error "%s error: %s" group
(gnus-status-message group
)))
5490 (gnus-group-update-group group
)
5491 (goto-char (text-property-any
5492 (point-min) (point-max)
5493 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)))))
5494 ;; Adjust cursor point.
5495 (gnus-group-position-point)))
5497 (defun gnus-group-goto-group (group)
5498 "Goto to newsgroup GROUP."
5500 (let ((b (text-property-any (point-min) (point-max)
5501 'gnus-group
(gnus-intern-safe
5502 group gnus-active-hashtb
))))
5503 (and b
(goto-char b
)))))
5505 (defun gnus-group-next-group (n)
5506 "Go to next N'th newsgroup.
5507 If N is negative, search backward instead.
5508 Returns the difference between N and the number of skips actually
5511 (gnus-group-next-unread-group n t
))
5513 (defun gnus-group-next-unread-group (n &optional all level
)
5514 "Go to next N'th unread newsgroup.
5515 If N is negative, search backward instead.
5516 If ALL is non-nil, choose any newsgroup, unread or not.
5517 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5518 such group can be found, the next group with a level higher than
5520 Returns the difference between N and the number of skips actually
5523 (let ((backward (< n
0))
5526 (gnus-group-search-forward
5527 backward
(or (not gnus-group-goto-unread
) all
) level
))
5529 (if (/= 0 n
) (gnus-message 7 "No more%s newsgroups%s" (if all
"" " unread")
5530 (if level
" on this level or higher" "")))
5533 (defun gnus-group-prev-group (n)
5534 "Go to previous N'th newsgroup.
5535 Returns the difference between N and the number of skips actually
5538 (gnus-group-next-unread-group (- n
) t
))
5540 (defun gnus-group-prev-unread-group (n)
5541 "Go to previous N'th unread newsgroup.
5542 Returns the difference between N and the number of skips actually
5545 (gnus-group-next-unread-group (- n
)))
5547 (defun gnus-group-next-unread-group-same-level (n)
5548 "Go to next N'th unread newsgroup on the same level.
5549 If N is negative, search backward instead.
5550 Returns the difference between N and the number of skips actually
5553 (gnus-group-next-unread-group n t
(gnus-group-group-level))
5554 (gnus-group-position-point))
5556 (defun gnus-group-prev-unread-group-same-level (n)
5557 "Go to next N'th unread newsgroup on the same level.
5558 Returns the difference between N and the number of skips actually
5561 (gnus-group-next-unread-group (- n
) t
(gnus-group-group-level))
5562 (gnus-group-position-point))
5564 (defun gnus-group-best-unread-group (&optional exclude-group
)
5565 "Go to the group with the highest level.
5566 If EXCLUDE-GROUP, do not go to that group."
5568 (goto-char (point-min))
5572 (setq unread
(get-text-property (point) 'gnus-unread
))
5573 (if (and (numberp unread
) (> unread
0))
5575 (if (and (get-text-property (point) 'gnus-level
)
5576 (< (get-text-property (point) 'gnus-level
) best
)
5577 (or (not exclude-group
)
5578 (not (equal exclude-group
(gnus-group-group-name)))))
5580 (setq best
(get-text-property (point) 'gnus-level
))
5581 (setq best-point
(point))))))
5583 (if best-point
(goto-char best-point
))
5584 (gnus-summary-position-point)
5585 (and best-point
(gnus-group-group-name))))
5587 (defun gnus-group-first-unread-group ()
5588 "Go to the first group with unread articles."
5591 (let ((opoint (point))
5593 (goto-char (point-min))
5594 (if (or (eq (setq unread
(gnus-group-group-unread)) t
) ; Not active.
5595 (and (numberp unread
) ; Not a topic.
5596 (not (zerop unread
))) ; Has unread articles.
5597 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5600 nil
)) ; Not success.
5601 (gnus-group-position-point)))
5603 (defun gnus-group-enter-server-mode ()
5604 "Jump to the server buffer."
5606 (gnus-enter-server-buffer))
5608 (defun gnus-group-make-group (name &optional method address
)
5609 "Add a new newsgroup.
5610 The user will be prompted for a NAME, for a select METHOD, and an
5614 (read-string "Group name: ")
5617 "Method: " (append gnus-valid-select-methods gnus-server-alist
)
5618 nil t nil
'gnus-method-history
)))
5619 (cond ((assoc method gnus-valid-select-methods
)
5621 (if (memq 'prompt-address
5622 (assoc method gnus-valid-select-methods
))
5623 (read-string "Address: ")
5625 ((assoc method gnus-server-alist
)
5628 (list method
""))))))
5630 (let* ((meth (and method
(if address
(list (intern method
) address
)
5632 (nname (if method
(gnus-group-prefixed-name name meth
) name
))
5634 (when (gnus-gethash nname gnus-newsrc-hashtb
)
5635 (error "Group %s already exists" nname
))
5636 ;; Subscribe to the new group.
5637 (gnus-group-change-level
5638 (setq info
(list t nname gnus-level-default-subscribed nil nil meth
))
5639 gnus-level-default-subscribed gnus-level-killed
5640 (and (gnus-group-group-name)
5641 (gnus-gethash (gnus-group-group-name)
5642 gnus-newsrc-hashtb
))
5645 (gnus-set-active nname
(cons 1 0))
5646 (or (gnus-ephemeral-group-p name
)
5648 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info
)) ")")))
5650 (gnus-group-insert-group-line-info nname
)
5652 (gnus-group-position-point)
5654 ;; Load the backend and try to make the backend create
5655 ;; the group as well.
5656 (when (assoc (symbol-name (setq backend
(car (gnus-server-get-method
5658 gnus-valid-select-methods
)
5660 (gnus-check-server meth
)
5661 (and (gnus-check-backend-function 'request-create-group nname
)
5662 (gnus-request-create-group nname
))
5665 (defun gnus-group-delete-group (group &optional force
)
5666 "Delete the current group. Only meaningful with mail groups.
5667 If FORCE (the prefix) is non-nil, all the articles in the group will
5668 be deleted. This is \"deleted\" as in \"removed forever from the face
5669 of the Earth\". There is no undo. The user will be prompted before
5670 doing the deletion."
5672 (list (gnus-group-group-name)
5673 current-prefix-arg
))
5674 (or group
(error "No group to rename"))
5675 (or (gnus-check-backend-function 'request-delete-group group
)
5676 (error "This backend does not support group deletion"))
5678 (if (not (gnus-yes-or-no-p
5680 "Do you really want to delete %s%s? "
5681 group
(if force
" and all its contents" ""))))
5683 (gnus-message 6 "Deleting group %s..." group
)
5684 (if (not (gnus-request-delete-group group force
))
5685 (gnus-error 3 "Couldn't delete group %s" group
)
5686 (gnus-message 6 "Deleting group %s...done" group
)
5687 (gnus-group-goto-group group
)
5688 (gnus-group-kill-group 1 t
)
5689 (gnus-sethash group nil gnus-active-hashtb
)
5691 (gnus-group-position-point)))
5693 (defun gnus-group-rename-group (group new-name
)
5696 (gnus-group-group-name)
5698 (or (gnus-check-backend-function
5699 'request-rename-group
(gnus-group-group-name))
5700 (error "This backend does not support renaming groups"))
5701 (read-string "New group name: "))))
5703 (or (gnus-check-backend-function 'request-rename-group group
)
5704 (error "This backend does not support renaming groups"))
5706 (or group
(error "No group to rename"))
5707 (and (string-match "^[ \t]*$" new-name
)
5708 (error "Not a valid group name"))
5710 ;; We find the proper prefixed name.
5712 (gnus-group-prefixed-name
5713 (gnus-group-real-name new-name
)
5714 (gnus-info-method (gnus-get-info group
))))
5716 (gnus-message 6 "Renaming group %s to %s..." group new-name
)
5718 (if (not (gnus-request-rename-group group new-name
))
5719 (gnus-error 3 "Couldn't rename group %s to %s" group new-name
)
5720 ;; We rename the group internally by killing it...
5721 (gnus-group-goto-group group
)
5722 (gnus-group-kill-group)
5723 ;; ... changing its name ...
5724 (setcar (cdar gnus-list-of-killed-groups
) new-name
)
5725 ;; ... and then yanking it. Magic!
5726 (gnus-group-yank-group)
5727 (gnus-set-active new-name
(gnus-active group
))
5728 (gnus-message 6 "Renaming group %s to %s...done" group new-name
)
5730 (gnus-group-position-point)))
5732 (defun gnus-group-edit-group (group &optional part
)
5733 "Edit the group on the current line."
5734 (interactive (list (gnus-group-group-name)))
5735 (let* ((part (or part
'info
))
5736 (done-func `(lambda ()
5737 "Exit editing mode and update the information."
5739 (gnus-group-edit-group-done ',part
,group
)))
5740 (winconf (current-window-configuration))
5742 (or group
(error "No group on current line"))
5743 (or (setq info
(gnus-get-info group
))
5744 (error "Killed group; can't be edited"))
5745 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
5746 (gnus-configure-windows 'edit-group
)
5747 (gnus-add-current-to-buffer-list)
5749 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5750 (use-local-map (copy-keymap emacs-lisp-mode-map
))
5751 (local-set-key "\C-c\C-c" done-func
)
5752 (make-local-variable 'gnus-prev-winconf
)
5753 (setq gnus-prev-winconf winconf
)
5758 ";; Type `C-c C-c' after editing the select method.\n\n")
5760 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5762 ";; Type `C-c C-c' after editing the group info.\n\n")))
5765 (cond ((eq part
'method
)
5766 (or (gnus-info-method info
) "native"))
5768 (gnus-info-params info
))
5772 (defun gnus-group-edit-group-method (group)
5773 "Edit the select method of GROUP."
5774 (interactive (list (gnus-group-group-name)))
5775 (gnus-group-edit-group group
'method
))
5777 (defun gnus-group-edit-group-parameters (group)
5778 "Edit the group parameters of GROUP."
5779 (interactive (list (gnus-group-group-name)))
5780 (gnus-group-edit-group group
'params
))
5782 (defun gnus-group-edit-group-done (part group
)
5783 "Get info from buffer, update variables and jump to the group buffer."
5784 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
5785 (goto-char (point-min))
5786 (let* ((form (read (current-buffer)))
5787 (winconf gnus-prev-winconf
)
5788 (method (cond ((eq part
'info
) (nth 4 form
))
5789 ((eq part
'method
) form
)
5791 (info (cond ((eq part
'info
) form
)
5792 ((eq part
'method
) (gnus-get-info group
))
5795 (if (or (not method
)
5797 gnus-select-method method
))
5798 (gnus-group-real-name (car info
))
5799 (gnus-group-prefixed-name
5800 (gnus-group-real-name (car info
)) method
))
5802 (when (and new-group
5803 (not (equal new-group group
)))
5804 (when (gnus-group-goto-group group
)
5805 (gnus-group-kill-group 1))
5806 (gnus-activate-group new-group
))
5808 (if (and info new-group
)
5810 (setq info
(gnus-copy-sequence info
))
5811 (setcar info new-group
)
5812 (unless (gnus-server-equal method
"native")
5813 (unless (nthcdr 3 info
)
5814 (nconc info
(list nil nil
)))
5815 (unless (nthcdr 4 info
)
5816 (nconc info
(list nil
)))
5817 (gnus-info-set-method info method
))
5818 (gnus-group-set-info info
))
5819 (gnus-group-set-info form
(or new-group group
) part
))
5820 (kill-buffer (current-buffer))
5821 (and winconf
(set-window-configuration winconf
))
5822 (set-buffer gnus-group-buffer
)
5823 (gnus-group-update-group (or new-group group
))
5824 (gnus-group-position-point)))
5826 (defun gnus-group-make-help-group ()
5827 "Create the Gnus documentation group."
5829 (let ((path load-path
)
5830 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5832 (and (gnus-gethash name gnus-newsrc-hashtb
)
5833 (error "Documentation group already exists"))
5835 (setq dir
(file-name-as-directory (expand-file-name (pop path
)))
5837 (when (or (file-exists-p (setq file
(concat dir
"gnus-tut.txt")))
5839 (setq file
(concat (file-name-directory
5840 (directory-file-name dir
))
5841 "etc/gnus-tut.txt"))))
5844 (gnus-message 1 "Couldn't find doc group")
5845 (gnus-group-make-group
5846 (gnus-group-real-name name
)
5847 (list 'nndoc
"gnus-help"
5848 (list 'nndoc-address file
)
5849 (list 'nndoc-article-type
'mbox
)))))
5850 (gnus-group-position-point))
5852 (defun gnus-group-make-doc-group (file type
)
5853 "Create a group that uses a single file as the source."
5855 (list (read-file-name "File name: ")
5856 (and current-prefix-arg
'ask
)))
5857 (when (eq type
'ask
)
5862 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5864 (setq found
(cond ((= (setq char
(read-char)) ?m
) 'mbox
)
5865 ((= char ?b
) 'babyl
)
5866 ((= char ?d
) 'digest
)
5867 ((= char ?f
) 'forward
)
5869 (t (setq err
(format "%c unknown. " char
))
5872 (let* ((file (expand-file-name file
))
5873 (name (gnus-generate-new-group-name
5874 (gnus-group-prefixed-name
5875 (file-name-nondirectory file
) '(nndoc "")))))
5876 (gnus-group-make-group
5877 (gnus-group-real-name name
)
5878 (list 'nndoc
(file-name-nondirectory file
)
5879 (list 'nndoc-address file
)
5880 (list 'nndoc-article-type
(or type
'guess
))))))
5882 (defun gnus-group-make-archive-group (&optional all
)
5883 "Create the (ding) Gnus archive group of the most recent articles.
5884 Given a prefix, create a full group."
5886 (let ((group (gnus-group-prefixed-name
5887 (if all
"ding.archives" "ding.recent") '(nndir ""))))
5888 (and (gnus-gethash group gnus-newsrc-hashtb
)
5889 (error "Archive group already exists"))
5890 (gnus-group-make-group
5891 (gnus-group-real-name group
)
5892 (list 'nndir
(if all
"hpc" "edu")
5893 (list 'nndir-directory
5894 (if all gnus-group-archive-directory
5895 gnus-group-recent-archive-directory
))))))
5897 (defun gnus-group-make-directory-group (dir)
5898 "Create an nndir group.
5899 The user will be prompted for a directory. The contents of this
5900 directory will be used as a newsgroup. The directory should contain
5901 mail messages or news articles in files that have numeric names."
5903 (list (read-file-name "Create group from directory: ")))
5904 (or (file-exists-p dir
) (error "No such directory"))
5905 (or (file-directory-p dir
) (error "Not a directory"))
5909 (while (or (not group
) (gnus-gethash group gnus-newsrc-hashtb
))
5911 (gnus-group-prefixed-name
5912 (concat (file-name-as-directory (directory-file-name dir
))
5915 (setq ext
(format "<%d>" (setq i
(1+ i
)))))
5916 (gnus-group-make-group
5917 (gnus-group-real-name group
)
5918 (list 'nndir group
(list 'nndir-directory dir
)))))
5920 (defun gnus-group-make-kiboze-group (group address scores
)
5921 "Create an nnkiboze group.
5922 The user will be prompted for a name, a regexp to match groups, and
5923 score file entries for articles to include in the group."
5926 (read-string "nnkiboze group name: ")
5927 (read-string "Source groups (regexp): ")
5928 (let ((headers (mapcar (lambda (group) (list group
))
5929 '("subject" "from" "number" "date" "message-id"
5930 "references" "chars" "lines" "xref"
5931 "followup" "all" "body" "head")))
5932 scores header regexp regexps
)
5933 (while (not (equal "" (setq header
(completing-read
5934 "Match on header: " headers nil t
))))
5936 (while (not (equal "" (setq regexp
(read-string
5937 (format "Match on %s (string): "
5939 (setq regexps
(cons (list regexp nil nil
'r
) regexps
)))
5940 (setq scores
(cons (cons header regexps
) scores
)))
5942 (gnus-group-make-group group
"nnkiboze" address
)
5943 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group
))
5944 (let (emacs-lisp-mode-hook)
5945 (pp scores
(current-buffer)))))
5947 (defun gnus-group-add-to-virtual (n vgroup
)
5948 "Add the current group to a virtual group."
5950 (list current-prefix-arg
5951 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5953 (or (eq (car (gnus-find-method-for-group vgroup
)) 'nnvirtual
)
5954 (error "%s is not an nnvirtual group" vgroup
))
5955 (let* ((groups (gnus-group-process-prefix n
))
5956 (method (gnus-info-method (gnus-get-info vgroup
))))
5957 (setcar (cdr method
)
5959 (nth 1 method
) "\\|"
5962 (gnus-group-remove-mark s
)
5963 (concat "\\(^" (regexp-quote s
) "$\\)"))
5965 (gnus-group-position-point))
5967 (defun gnus-group-make-empty-virtual (group)
5968 "Create a new, fresh, empty virtual group."
5969 (interactive "sCreate new, empty virtual group: ")
5970 (let* ((method (list 'nnvirtual
"^$"))
5971 (pgroup (gnus-group-prefixed-name group method
)))
5972 ;; Check whether it exists already.
5973 (and (gnus-gethash pgroup gnus-newsrc-hashtb
)
5974 (error "Group %s already exists." pgroup
))
5975 ;; Subscribe the new group after the group on the current line.
5976 (gnus-subscribe-group pgroup
(gnus-group-group-name) method
)
5977 (gnus-group-update-group pgroup
)
5979 (gnus-group-position-point)))
5981 (defun gnus-group-enter-directory (dir)
5982 "Enter an ephemeral nneething group."
5983 (interactive "DDirectory to read: ")
5984 (let* ((method (list 'nneething dir
'(nneething-read-only t
)))
5985 (leaf (gnus-group-prefixed-name
5986 (file-name-nondirectory (directory-file-name dir
))
5988 (name (gnus-generate-new-group-name leaf
)))
5989 (unless (gnus-group-read-ephemeral-group
5991 (cons (current-buffer)
5992 (if (eq major-mode
'gnus-summary-mode
)
5994 (error "Couldn't enter %s" dir
))))
5996 ;; Group sorting commands
5997 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5999 (defun gnus-group-sort-groups (func &optional reverse
)
6000 "Sort the group buffer according to FUNC.
6001 If REVERSE, reverse the sorting order."
6002 (interactive (list gnus-group-sort-function
6003 current-prefix-arg
))
6005 ((not (listp func
)) func
)
6007 ((= 1 (length func
)) (car func
))
6009 ,(gnus-make-sort-function
6010 (reverse func
)))))))
6011 ;; We peel off the dummy group from the alist.
6013 (when (equal (car (gnus-info-group gnus-newsrc-alist
)) "dummy.group")
6014 (pop gnus-newsrc-alist
))
6016 (setq gnus-newsrc-alist
6017 (sort gnus-newsrc-alist func
))
6019 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
)))
6020 ;; Regenerate the hash table.
6021 (gnus-make-hashtable-from-newsrc-alist)
6022 (gnus-group-list-groups))))
6024 (defun gnus-group-sort-groups-by-alphabet (&optional reverse
)
6025 "Sort the group buffer alphabetically by group name.
6026 If REVERSE, sort in reverse order."
6028 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse
))
6030 (defun gnus-group-sort-groups-by-unread (&optional reverse
)
6031 "Sort the group buffer by number of unread articles.
6032 If REVERSE, sort in reverse order."
6034 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse
))
6036 (defun gnus-group-sort-groups-by-level (&optional reverse
)
6037 "Sort the group buffer by group level.
6038 If REVERSE, sort in reverse order."
6040 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse
))
6042 (defun gnus-group-sort-groups-by-score (&optional reverse
)
6043 "Sort the group buffer by group score.
6044 If REVERSE, sort in reverse order."
6046 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse
))
6048 (defun gnus-group-sort-groups-by-rank (&optional reverse
)
6049 "Sort the group buffer by group rank.
6050 If REVERSE, sort in reverse order."
6052 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse
))
6054 (defun gnus-group-sort-groups-by-method (&optional reverse
)
6055 "Sort the group buffer alphabetically by backend name.
6056 If REVERSE, sort in reverse order."
6058 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse
))
6060 (defun gnus-group-sort-by-alphabet (info1 info2
)
6061 "Sort alphabetically."
6062 (string< (gnus-info-group info1
) (gnus-info-group info2
)))
6064 (defun gnus-group-sort-by-unread (info1 info2
)
6065 "Sort by number of unread articles."
6066 (let ((n1 (car (gnus-gethash (gnus-info-group info1
) gnus-newsrc-hashtb
)))
6067 (n2 (car (gnus-gethash (gnus-info-group info2
) gnus-newsrc-hashtb
))))
6068 (< (or (and (numberp n1
) n1
) 0)
6069 (or (and (numberp n2
) n2
) 0))))
6071 (defun gnus-group-sort-by-level (info1 info2
)
6073 (< (gnus-info-level info1
) (gnus-info-level info2
)))
6075 (defun gnus-group-sort-by-method (info1 info2
)
6076 "Sort alphabetically by backend name."
6077 (string< (symbol-name (car (gnus-find-method-for-group
6078 (gnus-info-group info1
) info1
)))
6079 (symbol-name (car (gnus-find-method-for-group
6080 (gnus-info-group info2
) info2
)))))
6082 (defun gnus-group-sort-by-score (info1 info2
)
6083 "Sort by group score."
6084 (< (gnus-info-score info1
) (gnus-info-score info2
)))
6086 (defun gnus-group-sort-by-rank (info1 info2
)
6087 "Sort by level and score."
6088 (let ((level1 (gnus-info-level info1
))
6089 (level2 (gnus-info-level info2
)))
6090 (or (< level1 level2
)
6091 (and (= level1 level2
)
6092 (> (gnus-info-score info1
) (gnus-info-score info2
))))))
6094 ;; Group catching up.
6096 (defun gnus-group-clear-data (n)
6097 "Clear all marks and read ranges from the current group."
6099 (let ((groups (gnus-group-process-prefix n
))
6101 (while (setq group
(pop groups
))
6102 (setq info
(gnus-get-info group
))
6103 (gnus-info-set-read info nil
)
6104 (when (gnus-info-marks info
)
6105 (gnus-info-set-marks info nil
))
6106 (gnus-get-unread-articles-in-group info
(gnus-active group
) t
)
6107 (when (gnus-group-goto-group group
)
6108 (gnus-group-remove-mark group
)
6109 (gnus-group-update-group-line)))))
6111 (defun gnus-group-catchup-current (&optional n all
)
6112 "Mark all articles not marked as unread in current newsgroup as read.
6113 If prefix argument N is numeric, the ARG next newsgroups will be
6114 caught up. If ALL is non-nil, marked articles will also be marked as
6115 read. Cross references (Xref: header) of articles are ignored.
6116 The difference between N and actual number of newsgroups that were
6117 caught up is returned."
6119 (unless (gnus-group-group-name)
6120 (error "No group on the current line"))
6121 (if (not (or (not gnus-interactive-catchup
) ;Without confirmation?
6125 "Do you really want to mark all articles as read? "
6126 "Mark all unread articles as read? "))))
6128 (let ((groups (gnus-group-process-prefix n
))
6131 ;; Virtual groups have to be given special treatment.
6132 (let ((method (gnus-find-method-for-group (car groups
))))
6133 (if (eq 'nnvirtual
(car method
))
6134 (nnvirtual-catchup-group
6135 (gnus-group-real-name (car groups
)) (nth 1 method
) all
)))
6136 (gnus-group-remove-mark (car groups
))
6137 (if (>= (gnus-group-group-level) gnus-level-zombie
)
6138 (gnus-message 2 "Dead groups can't be caught up")
6140 (gnus-group-goto-group (car groups
))
6141 (gnus-group-catchup (car groups
) all
))
6142 (gnus-group-update-group-line)
6143 (setq ret
(1+ ret
))))
6144 (setq groups
(cdr groups
)))
6145 (gnus-group-next-unread-group 1)
6148 (defun gnus-group-catchup-current-all (&optional n
)
6149 "Mark all articles in current newsgroup as read.
6150 Cross references (Xref: header) of articles are ignored."
6152 (gnus-group-catchup-current n
'all
))
6154 (defun gnus-group-catchup (group &optional all
)
6155 "Mark all articles in GROUP as read.
6156 If ALL is non-nil, all articles are marked as read.
6157 The return value is the number of articles that were marked as read,
6158 or nil if no action could be taken."
6159 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb
))
6161 ;; Do the updating only if the newsgroup isn't killed.
6162 (if (not (numberp (car entry
)))
6163 (gnus-message 1 "Can't catch up; non-active group")
6164 ;; Do auto-expirable marks if that's required.
6165 (when (gnus-group-auto-expirable-p group
)
6166 (gnus-add-marked-articles
6167 group
'expire
(gnus-list-of-unread-articles group
))
6169 (let ((marks (nth 3 (nth 2 entry
))))
6170 (gnus-add-marked-articles
6171 group
'expire
(gnus-uncompress-range (cdr (assq 'tick marks
))))
6172 (gnus-add-marked-articles
6173 group
'expire
(gnus-uncompress-range (cdr (assq 'tick marks
)))))))
6175 (gnus-update-read-articles group nil
)
6176 ;; Also nix out the lists of marks and dormants.
6178 (gnus-add-marked-articles group
'tick nil nil
'force
)
6179 (gnus-add-marked-articles group
'dormant nil nil
'force
))
6180 (run-hooks 'gnus-group-catchup-group-hook
)
6183 (defun gnus-group-expire-articles (&optional n
)
6184 "Expire all expirable articles in the current newsgroup."
6186 (let ((groups (gnus-group-process-prefix n
))
6189 (error "No groups to expire"))
6190 (while (setq group
(pop groups
))
6191 (gnus-group-remove-mark group
)
6192 (when (gnus-check-backend-function 'request-expire-articles group
)
6193 (gnus-message 6 "Expiring articles in %s..." group
)
6194 (let* ((info (gnus-get-info group
))
6195 (expirable (if (gnus-group-total-expirable-p group
)
6196 (cons nil
(gnus-list-of-read-articles group
))
6197 (assq 'expire
(gnus-info-marks info
))))
6198 (expiry-wait (gnus-group-get-parameter group
'expiry-wait
)))
6202 (gnus-compress-sequence
6204 ;; We set the expiry variables to the groupp
6206 (let ((nnmail-expiry-wait-function nil
)
6207 (nnmail-expiry-wait expiry-wait
))
6208 (gnus-request-expire-articles
6209 (gnus-uncompress-sequence (cdr expirable
)) group
))
6210 ;; Just expire using the normal expiry values.
6211 (gnus-request-expire-articles
6212 (gnus-uncompress-sequence (cdr expirable
)) group
))))
6213 (gnus-close-group group
))
6214 (gnus-message 6 "Expiring articles in %s...done" group
)))
6215 (gnus-group-position-point))))
6217 (defun gnus-group-expire-all-groups ()
6218 "Expire all expirable articles in all newsgroups."
6221 (gnus-message 5 "Expiring...")
6222 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info
))
6223 (cdr gnus-newsrc-alist
))))
6224 (gnus-group-expire-articles nil
)))
6225 (gnus-group-position-point)
6226 (gnus-message 5 "Expiring...done"))
6228 (defun gnus-group-set-current-level (n level
)
6229 "Set the level of the next N groups to LEVEL."
6234 (let ((s (read-string
6235 (format "Level (default %s): "
6236 (or (gnus-group-group-level)
6237 gnus-level-default-subscribed
)))))
6238 (if (string-match "^\\s-*$" s
)
6239 (int-to-string (or (gnus-group-group-level)
6240 gnus-level-default-subscribed
))
6242 (or (and (>= level
1) (<= level gnus-level-killed
))
6243 (error "Illegal level: %d" level
))
6244 (let ((groups (gnus-group-process-prefix n
))
6246 (while (setq group
(pop groups
))
6247 (gnus-group-remove-mark group
)
6248 (gnus-message 6 "Changed level of %s from %d to %d"
6249 group
(or (gnus-group-group-level) gnus-level-killed
)
6251 (gnus-group-change-level
6252 group level
(or (gnus-group-group-level) gnus-level-killed
))
6253 (gnus-group-update-group-line)))
6254 (gnus-group-position-point))
6256 (defun gnus-group-unsubscribe-current-group (&optional n
)
6257 "Toggle subscription of the current group.
6258 If given numerical prefix, toggle the N next groups."
6260 (let ((groups (gnus-group-process-prefix n
))
6263 (setq group
(car groups
)
6264 groups
(cdr groups
))
6265 (gnus-group-remove-mark group
)
6266 (gnus-group-unsubscribe-group
6267 group
(if (<= (gnus-group-group-level) gnus-level-subscribed
)
6268 gnus-level-default-unsubscribed
6269 gnus-level-default-subscribed
) t
)
6270 (gnus-group-update-group-line))
6271 (gnus-group-next-group 1)))
6273 (defun gnus-group-unsubscribe-group (group &optional level silent
)
6274 "Toggle subscription to GROUP.
6275 Killed newsgroups are subscribed. If SILENT, don't try to update the
6278 (list (completing-read
6279 "Group: " gnus-active-hashtb nil
6280 (gnus-read-active-file-p)
6282 'gnus-group-history
)))
6283 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb
)))
6285 ((string-match "^[ \t]$" group
)
6286 (error "Empty group name"))
6288 ;; Toggle subscription flag.
6289 (gnus-group-change-level
6290 newsrc
(if level level
(if (<= (nth 1 (nth 2 newsrc
))
6291 gnus-level-subscribed
)
6292 (1+ gnus-level-subscribed
)
6293 gnus-level-default-subscribed
)))
6295 (gnus-group-update-group group
)))
6296 ((and (stringp group
)
6297 (or (not (gnus-read-active-file-p))
6298 (gnus-active group
)))
6299 ;; Add new newsgroup.
6300 (gnus-group-change-level
6302 (if level level gnus-level-default-subscribed
)
6303 (or (and (member group gnus-zombie-list
)
6306 (and (gnus-group-group-name)
6307 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb
)))
6309 (gnus-group-update-group group
)))
6310 (t (error "No such newsgroup: %s" group
)))
6311 (gnus-group-position-point)))
6313 (defun gnus-group-transpose-groups (n)
6314 "Move the current newsgroup up N places.
6315 If given a negative prefix, move down instead. The difference between
6316 N and the number of steps taken is returned."
6318 (or (gnus-group-group-name)
6319 (error "No group on current line"))
6320 (gnus-group-kill-group 1)
6322 (forward-line (- n
))
6323 (gnus-group-yank-group)
6324 (gnus-group-position-point)))
6326 (defun gnus-group-kill-all-zombies ()
6327 "Kill all zombie newsgroups."
6329 (setq gnus-killed-list
(nconc gnus-zombie-list gnus-killed-list
))
6330 (setq gnus-zombie-list nil
)
6331 (gnus-group-list-groups))
6333 (defun gnus-group-kill-region (begin end
)
6334 "Kill newsgroups in current region (excluding current point).
6335 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6350 (beginning-of-line) ;Important when LINES < 1
6351 (gnus-group-kill-group lines
)))
6353 (defun gnus-group-kill-group (&optional n discard
)
6354 "Kill the next N groups.
6355 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6356 However, only groups that were alive can be yanked; already killed
6357 groups or zombie groups can't be yanked.
6358 The return value is the name of the group that was killed, or a list
6361 (let ((buffer-read-only nil
)
6362 (groups (gnus-group-process-prefix n
))
6363 group entry level out
)
6364 (if (< (length groups
) 10)
6365 ;; This is faster when there are few groups.
6367 (push (setq group
(pop groups
)) out
)
6368 (gnus-group-remove-mark group
)
6369 (setq level
(gnus-group-group-level))
6371 (when (and (not discard
)
6372 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
)))
6373 (push (cons (car entry
) (nth 2 entry
))
6374 gnus-list-of-killed-groups
))
6375 (gnus-group-change-level
6376 (if entry entry group
) gnus-level-killed
(if entry nil level
)))
6377 ;; If there are lots and lots of groups to be killed, we use
6378 ;; this thing instead.
6380 (setq groups
(nreverse groups
))
6382 (gnus-group-remove-mark (setq group
(pop groups
)))
6384 (push group gnus-killed-list
)
6385 (setq gnus-newsrc-alist
6386 (delq (assoc group gnus-newsrc-alist
)
6388 (when gnus-group-change-level-function
6389 (funcall gnus-group-change-level-function group
9 3))
6391 ((setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
6392 (push (cons (car entry
) (nth 2 entry
))
6393 gnus-list-of-killed-groups
)
6394 (setcdr (cdr entry
) (cdddr entry
)))
6395 ((member group gnus-zombie-list
)
6396 (setq gnus-zombie-list
(delete group gnus-zombie-list
)))))
6397 (gnus-make-hashtable-from-newsrc-alist)))
6399 (gnus-group-position-point)
6400 (if (< (length out
) 2) (car out
) (nreverse out
))))
6402 (defun gnus-group-yank-group (&optional arg
)
6403 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6404 inserting it before the current newsgroup. The numeric ARG specifies
6405 how many newsgroups are to be yanked. The name of the newsgroup yanked
6406 is returned, or (if several groups are yanked) a list of yanked groups
6409 (setq arg
(or arg
1))
6410 (let (info group prev out
)
6411 (while (>= (decf arg
) 0)
6412 (if (not (setq info
(pop gnus-list-of-killed-groups
)))
6413 (error "No more newsgroups to yank"))
6414 (push (setq group
(nth 1 info
)) out
)
6415 ;; Find which newsgroup to insert this one before - search
6416 ;; backward until something suitable is found. If there are no
6417 ;; other newsgroups in this buffer, just make this newsgroup the
6419 (setq prev
(gnus-group-group-name))
6420 (gnus-group-change-level
6421 info
(gnus-info-level (cdr info
)) gnus-level-killed
6422 (and prev
(gnus-gethash prev gnus-newsrc-hashtb
))
6424 (gnus-group-insert-group-line-info group
))
6426 (gnus-group-position-point)
6427 (if (< (length out
) 2) (car out
) (nreverse out
))))
6429 (defun gnus-group-kill-level (level)
6430 "Kill all groups that is on a certain LEVEL."
6431 (interactive "nKill all groups on level: ")
6433 ((= level gnus-level-zombie
)
6434 (setq gnus-killed-list
6435 (nconc gnus-zombie-list gnus-killed-list
))
6436 (setq gnus-zombie-list nil
))
6437 ((and (< level gnus-level-zombie
)
6439 (or gnus-expert-user
6442 "Do you really want to kill all groups on level %d? "
6444 (let* ((prev gnus-newsrc-alist
)
6447 (if (= (gnus-info-level (car alist
)) level
)
6449 (push (gnus-info-group (car alist
)) gnus-killed-list
)
6450 (setcdr prev
(cdr alist
)))
6452 (setq alist
(cdr alist
)))
6453 (gnus-make-hashtable-from-newsrc-alist)
6454 (gnus-group-list-groups)))
6456 (error "Can't kill; illegal level: %d" level
))))
6458 (defun gnus-group-list-all-groups (&optional arg
)
6459 "List all newsgroups with level ARG or lower.
6460 Default is gnus-level-unsubscribed, which lists all subscribed and most
6461 unsubscribed groups."
6463 (gnus-group-list-groups (or arg gnus-level-unsubscribed
) t
))
6465 ;; Redefine this to list ALL killed groups if prefix arg used.
6466 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6467 (defun gnus-group-list-killed (&optional arg
)
6468 "List all killed newsgroups in the group buffer.
6469 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6470 entail asking the server for the groups."
6472 ;; Find all possible killed newsgroups if arg.
6474 (gnus-get-killed-groups))
6475 (if (not gnus-killed-list
)
6476 (gnus-message 6 "No killed groups")
6477 (let (gnus-group-list-mode)
6478 (funcall gnus-group-prepare-function
6479 gnus-level-killed t gnus-level-killed
))
6480 (goto-char (point-min)))
6481 (gnus-group-position-point))
6483 (defun gnus-group-list-zombies ()
6484 "List all zombie newsgroups in the group buffer."
6486 (if (not gnus-zombie-list
)
6487 (gnus-message 6 "No zombie groups")
6488 (let (gnus-group-list-mode)
6489 (funcall gnus-group-prepare-function
6490 gnus-level-zombie t gnus-level-zombie
))
6491 (goto-char (point-min)))
6492 (gnus-group-position-point))
6494 (defun gnus-group-list-active ()
6495 "List all groups that are available from the server(s)."
6497 ;; First we make sure that we have really read the active file.
6498 (unless (gnus-read-active-file-p)
6499 (let ((gnus-read-active-file t
))
6500 (gnus-read-active-file)))
6501 ;; Find all groups and sort them.
6509 (setq list
(cons (symbol-name sym
) list
))))
6513 (buffer-read-only nil
))
6516 (gnus-group-insert-group-line-info (pop groups
)))
6517 (goto-char (point-min))))
6519 (defun gnus-activate-all-groups (level)
6520 "Activate absolutely all groups."
6521 (interactive (list 7))
6522 (let ((gnus-activate-level level
)
6523 (gnus-activate-foreign-newsgroups level
))
6524 (gnus-group-get-new-news)))
6526 (defun gnus-group-get-new-news (&optional arg
)
6527 "Get newly arrived articles.
6528 If ARG is a number, it specifies which levels you are interested in
6529 re-scanning. If ARG is non-nil and not a number, this will force
6530 \"hard\" re-reading of the active files from all servers."
6532 (run-hooks 'gnus-get-new-news-hook
)
6533 ;; We might read in new NoCeM messages here.
6534 (when (and gnus-use-nocem
6536 (gnus-nocem-scan-groups))
6537 ;; If ARG is not a number, then we read the active file.
6538 (when (and arg
(not (numberp arg
)))
6539 (let ((gnus-read-active-file t
))
6540 (gnus-read-active-file))
6543 (setq arg
(gnus-group-default-level arg t
))
6544 (if (and gnus-read-active-file
(not arg
))
6546 (gnus-read-active-file)
6547 (gnus-get-unread-articles arg
))
6548 (let ((gnus-read-active-file (if arg nil gnus-read-active-file
)))
6549 (gnus-get-unread-articles arg
)))
6550 (run-hooks 'gnus-after-getting-new-news-hook
)
6551 (gnus-group-list-groups))
6553 (defun gnus-group-get-new-news-this-group (&optional n
)
6554 "Check for newly arrived news in the current group (and the N-1 next groups).
6555 The difference between N and the number of newsgroup checked is returned.
6556 If N is negative, this group and the N-1 previous groups will be checked."
6558 (let* ((groups (gnus-group-process-prefix n
))
6559 (ret (if (numberp n
) (- n
(length groups
)) 0))
6560 (beg (unless n
(point)))
6562 (while (setq group
(pop groups
))
6563 (gnus-group-remove-mark group
)
6564 (if (gnus-activate-group group
'scan
)
6566 (gnus-get-unread-articles-in-group
6567 (gnus-get-info group
) (gnus-active group
) t
)
6568 (unless (gnus-virtual-group-p group
)
6569 (gnus-close-group group
))
6570 (gnus-group-update-group group
))
6571 (if (eq (gnus-server-status (gnus-find-method-for-group group
))
6573 (gnus-error "Server denied access")
6574 (gnus-error 3 "%s error: %s" group
(gnus-status-message group
)))))
6575 (when beg
(goto-char beg
))
6576 (when gnus-goto-next-group-when-activating
6577 (gnus-group-next-unread-group 1 t
))
6578 (gnus-summary-position-point)
6581 (defun gnus-group-fetch-faq (group &optional faq-dir
)
6582 "Fetch the FAQ for the current group."
6585 (and (gnus-group-group-name)
6586 (gnus-group-real-name (gnus-group-group-name)))
6587 (cond (current-prefix-arg
6589 "Faq dir: " (and (listp gnus-group-faq-directory
)
6590 (mapcar (lambda (file) (list file
))
6591 gnus-group-faq-directory
)))))))
6593 (setq faq-dir
(if (listp gnus-group-faq-directory
)
6594 (car gnus-group-faq-directory
)
6595 gnus-group-faq-directory
)))
6596 (or group
(error "No group name given"))
6597 (let ((file (concat (file-name-as-directory faq-dir
)
6598 (gnus-group-real-name group
))))
6599 (if (not (file-exists-p file
))
6600 (error "No such file: %s" file
)
6603 (defun gnus-group-describe-group (force &optional group
)
6604 "Display a description of the current newsgroup."
6605 (interactive (list current-prefix-arg
(gnus-group-group-name)))
6606 (let* ((method (gnus-find-method-for-group group
))
6607 (mname (gnus-group-prefixed-name "" method
))
6610 gnus-description-hashtb
)
6611 (gnus-sethash mname nil gnus-description-hashtb
))
6612 (or group
(error "No group name given"))
6613 (and (or (and gnus-description-hashtb
6614 ;; We check whether this group's method has been
6615 ;; queried for a description file.
6616 (gnus-gethash mname gnus-description-hashtb
))
6617 (setq desc
(gnus-group-get-description group
))
6618 (gnus-read-descriptions-file method
))
6620 (or desc
(gnus-gethash group gnus-description-hashtb
)
6621 "No description available")))))
6623 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6624 (defun gnus-group-describe-all-groups (&optional force
)
6625 "Pop up a buffer with descriptions of all newsgroups."
6627 (and force
(setq gnus-description-hashtb nil
))
6628 (if (not (or gnus-description-hashtb
6629 (gnus-read-all-descriptions-files)))
6630 (error "Couldn't request descriptions file"))
6631 (let ((buffer-read-only nil
)
6637 (insert (format " *: %-20s %s\n" (symbol-name group
)
6638 (symbol-value group
)))
6639 (gnus-add-text-properties
6640 b
(1+ b
) (list 'gnus-group group
6641 'gnus-unread t
'gnus-marked nil
6642 'gnus-level
(1+ gnus-level-subscribed
))))
6643 gnus-description-hashtb
)
6644 (goto-char (point-min))
6645 (gnus-group-position-point)))
6647 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6648 (defun gnus-group-apropos (regexp &optional search-description
)
6649 "List all newsgroups that have names that match a regexp."
6650 (interactive "sGnus apropos (regexp): ")
6652 (obuf (current-buffer))
6654 ;; Go through all newsgroups that are known to Gnus.
6657 (and (symbol-name group
)
6658 (string-match regexp
(symbol-name group
))
6659 (setq groups
(cons (symbol-name group
) groups
))))
6661 ;; Also go through all descriptions that are known to Gnus.
6662 (when search-description
6665 (and (string-match regexp
(symbol-value group
))
6666 (gnus-active (symbol-name group
))
6667 (setq groups
(cons (symbol-name group
) groups
))))
6668 gnus-description-hashtb
))
6670 (gnus-message 3 "No groups matched \"%s\"." regexp
)
6671 ;; Print out all the groups.
6673 (pop-to-buffer "*Gnus Help*")
6674 (buffer-disable-undo (current-buffer))
6676 (setq groups
(sort groups
'string
<))
6678 ;; Groups may be entered twice into the list of groups.
6679 (if (not (string= (car groups
) prev
))
6681 (insert (setq prev
(car groups
)) "\n")
6682 (if (and gnus-description-hashtb
6683 (setq des
(gnus-gethash (car groups
)
6684 gnus-description-hashtb
)))
6685 (insert " " des
"\n"))))
6686 (setq groups
(cdr groups
)))
6687 (goto-char (point-min))))
6688 (pop-to-buffer obuf
)))
6690 (defun gnus-group-description-apropos (regexp)
6691 "List all newsgroups that have names or descriptions that match a regexp."
6692 (interactive "sGnus description apropos (regexp): ")
6693 (if (not (or gnus-description-hashtb
6694 (gnus-read-all-descriptions-files)))
6695 (error "Couldn't request descriptions file"))
6696 (gnus-group-apropos regexp t
))
6698 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6699 (defun gnus-group-list-matching (level regexp
&optional all lowest
)
6700 "List all groups with unread articles that match REGEXP.
6701 If the prefix LEVEL is non-nil, it should be a number that says which
6702 level to cut off listing groups.
6703 If ALL, also list groups with no unread articles.
6704 If LOWEST, don't list groups with level lower than LOWEST.
6706 This command may read the active file."
6707 (interactive "P\nsList newsgroups matching: ")
6708 ;; First make sure active file has been read.
6710 (> (prefix-numeric-value level
) gnus-level-killed
))
6711 (gnus-get-killed-groups))
6712 (gnus-group-prepare-flat (or level gnus-level-subscribed
)
6713 all
(or lowest
1) regexp
)
6714 (goto-char (point-min))
6715 (gnus-group-position-point))
6717 (defun gnus-group-list-all-matching (level regexp
&optional lowest
)
6718 "List all groups that match REGEXP.
6719 If the prefix LEVEL is non-nil, it should be a number that says which
6720 level to cut off listing groups.
6721 If LOWEST, don't list groups with level lower than LOWEST."
6722 (interactive "P\nsList newsgroups matching: ")
6723 (gnus-group-list-matching (or level gnus-level-killed
) regexp t lowest
))
6725 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6726 (defun gnus-group-save-newsrc (&optional force
)
6727 "Save the Gnus startup files.
6728 If FORCE, force saving whether it is necessary or not."
6730 (gnus-save-newsrc-file force
))
6732 (defun gnus-group-restart (&optional arg
)
6733 "Force Gnus to read the .newsrc file."
6735 (when (gnus-yes-or-no-p
6736 (format "Are you sure you want to read %s? "
6737 gnus-current-startup-file
))
6738 (gnus-save-newsrc-file)
6739 (gnus-setup-news 'force
)
6740 (gnus-group-list-groups arg
)))
6742 (defun gnus-group-read-init-file ()
6743 "Read the Gnus elisp init file."
6745 (gnus-read-init-file))
6747 (defun gnus-group-check-bogus-groups (&optional silent
)
6748 "Check bogus newsgroups.
6749 If given a prefix, don't ask for confirmation before removing a bogus
6752 (gnus-check-bogus-newsgroups (and (not silent
) (not gnus-expert-user
)))
6753 (gnus-group-list-groups))
6755 (defun gnus-group-edit-global-kill (&optional article group
)
6756 "Edit the global kill file.
6757 If GROUP, edit that local kill file instead."
6759 (setq gnus-current-kill-article article
)
6760 (gnus-kill-file-edit-file group
)
6763 (substitute-command-keys
6764 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6765 (if group
"local" "global")))))
6767 (defun gnus-group-edit-local-kill (article group
)
6768 "Edit a local kill file."
6769 (interactive (list nil
(gnus-group-group-name)))
6770 (gnus-group-edit-global-kill article group
))
6772 (defun gnus-group-force-update ()
6773 "Update `.newsrc' file."
6775 (gnus-save-newsrc-file))
6777 (defun gnus-group-suspend ()
6778 "Suspend the current Gnus session.
6779 In fact, cleanup buffers except for group mode buffer.
6780 The hook gnus-suspend-gnus-hook is called before actually suspending."
6782 (run-hooks 'gnus-suspend-gnus-hook
)
6783 ;; Kill Gnus buffers except for group mode buffer.
6784 (let* ((group-buf (get-buffer gnus-group-buffer
))
6785 ;; Do this on a separate list in case the user does a ^G before we finish
6787 (delete group-buf
(delete gnus-dribble-buffer
6788 (append gnus-buffer-list nil
)))))
6789 (while gnus-buffer-list
6790 (gnus-kill-buffer (pop gnus-buffer-list
)))
6791 (gnus-kill-gnus-frames)
6793 (setq gnus-buffer-list
(list group-buf
))
6794 (bury-buffer group-buf
)
6795 (delete-windows-on group-buf t
))))
6797 (defun gnus-group-clear-dribble ()
6798 "Clear all information from the dribble buffer."
6800 (gnus-dribble-clear)
6801 (gnus-message 7 "Cleared dribble buffer"))
6803 (defun gnus-group-exit ()
6804 "Quit reading news after updating .newsrc.eld and .newsrc.
6805 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6808 (or noninteractive
;For gnus-batch-kill
6809 (not gnus-interactive-exit
) ;Without confirmation
6811 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6812 (run-hooks 'gnus-exit-gnus-hook
)
6813 ;; Offer to save data from non-quitted summary buffers.
6814 (gnus-offer-save-summaries)
6815 ;; Save the newsrc file(s).
6816 (gnus-save-newsrc-file)
6818 (gnus-close-backends)
6819 ;; Reset everything.
6821 ;; Allow the user to do things after cleaning up.
6822 (run-hooks 'gnus-after-exiting-gnus-hook
)))
6824 (defun gnus-close-backends ()
6825 ;; Send a close request to all backends that support such a request.
6826 (let ((methods gnus-valid-select-methods
)
6829 (if (fboundp (setq func
(intern (concat (caar methods
)
6830 "-request-close"))))
6832 (setq methods
(cdr methods
)))))
6834 (defun gnus-group-quit ()
6835 "Quit reading news without updating .newsrc.eld or .newsrc.
6836 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6838 (when (or noninteractive
;For gnus-batch-kill
6839 (zerop (buffer-size))
6840 (not (gnus-server-opened gnus-select-method
))
6842 (not gnus-current-startup-file
)
6844 (format "Quit reading news without saving %s? "
6845 (file-name-nondirectory gnus-current-startup-file
))))
6846 (run-hooks 'gnus-exit-gnus-hook
)
6847 (if gnus-use-full-window
6848 (delete-other-windows)
6849 (gnus-remove-some-windows))
6851 (gnus-close-backends)
6853 ;; Allow the user to do things after cleaning up.
6854 (run-hooks 'gnus-after-exiting-gnus-hook
)))
6856 (defun gnus-offer-save-summaries ()
6857 "Offer to save all active summary buffers."
6859 (let ((buflist (buffer-list))
6861 ;; Go through all buffers and find all summaries.
6863 (and (setq bufname
(buffer-name (car buflist
)))
6864 (string-match "Summary" bufname
)
6866 (set-buffer bufname
)
6867 ;; We check that this is, indeed, a summary buffer.
6868 (and (eq major-mode
'gnus-summary-mode
)
6869 ;; Also make sure this isn't bogus.
6870 gnus-newsgroup-prepared
))
6871 (push bufname buffers
))
6872 (setq buflist
(cdr buflist
)))
6873 ;; Go through all these summary buffers and offer to save them.
6876 "Update summary buffer %s? "
6877 (lambda (buf) (set-buffer buf
) (gnus-summary-exit))
6880 (defun gnus-group-describe-briefly ()
6881 "Give a one line description of the group mode commands."
6883 (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")))
6885 (defun gnus-group-browse-foreign-server (method)
6886 "Browse a foreign news server.
6887 If called interactively, this function will ask for a select method
6888 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6889 If not, METHOD should be a list where the first element is the method
6890 and the second element is the address."
6892 (list (let ((how (completing-read
6894 (append gnus-valid-select-methods gnus-server-alist
)
6895 nil t
(cons "nntp" 0) 'gnus-method-history
)))
6896 ;; We either got a backend name or a virtual server name.
6897 ;; If the first, we also need an address.
6898 (if (assoc how gnus-valid-select-methods
)
6900 ;; Suggested by mapjph@bath.ac.uk.
6903 (mapcar (lambda (server) (list server
))
6904 gnus-secondary-servers
)))
6905 ;; We got a server name, so we find the method.
6906 (gnus-server-to-method how
)))))
6907 (gnus-browse-foreign-server method
))
6911 ;;; Gnus summary mode
6914 (defvar gnus-summary-mode-map nil
)
6916 (put 'gnus-summary-mode
'mode-class
'special
)
6918 (unless gnus-summary-mode-map
6919 (setq gnus-summary-mode-map
(make-keymap))
6920 (suppress-keymap gnus-summary-mode-map
)
6922 ;; Non-orthogonal keys
6924 (gnus-define-keys gnus-summary-mode-map
6925 " " gnus-summary-next-page
6926 "\177" gnus-summary-prev-page
6927 [delete] gnus-summary-prev-page
6928 "\r" gnus-summary-scroll-up
6929 "n" gnus-summary-next-unread-article
6930 "p" gnus-summary-prev-unread-article
6931 "N" gnus-summary-next-article
6932 "P" gnus-summary-prev-article
6933 "\M-\C-n" gnus-summary-next-same-subject
6934 "\M-\C-p" gnus-summary-prev-same-subject
6935 "\M-n" gnus-summary-next-unread-subject
6936 "\M-p" gnus-summary-prev-unread-subject
6937 "." gnus-summary-first-unread-article
6938 "," gnus-summary-best-unread-article
6939 "\M-s" gnus-summary-search-article-forward
6940 "\M-r" gnus-summary-search-article-backward
6941 "<" gnus-summary-beginning-of-article
6942 ">" gnus-summary-end-of-article
6943 "j" gnus-summary-goto-article
6944 "^" gnus-summary-refer-parent-article
6945 "\M-^" gnus-summary-refer-article
6946 "u" gnus-summary-tick-article-forward
6947 "!" gnus-summary-tick-article-forward
6948 "U" gnus-summary-tick-article-backward
6949 "d" gnus-summary-mark-as-read-forward
6950 "D" gnus-summary-mark-as-read-backward
6951 "E" gnus-summary-mark-as-expirable
6952 "\M-u" gnus-summary-clear-mark-forward
6953 "\M-U" gnus-summary-clear-mark-backward
6954 "k" gnus-summary-kill-same-subject-and-select
6955 "\C-k" gnus-summary-kill-same-subject
6956 "\M-\C-k" gnus-summary-kill-thread
6957 "\M-\C-l" gnus-summary-lower-thread
6958 "e" gnus-summary-edit-article
6959 "#" gnus-summary-mark-as-processable
6960 "\M-#" gnus-summary-unmark-as-processable
6961 "\M-\C-t" gnus-summary-toggle-threads
6962 "\M-\C-s" gnus-summary-show-thread
6963 "\M-\C-h" gnus-summary-hide-thread
6964 "\M-\C-f" gnus-summary-next-thread
6965 "\M-\C-b" gnus-summary-prev-thread
6966 "\M-\C-u" gnus-summary-up-thread
6967 "\M-\C-d" gnus-summary-down-thread
6968 "&" gnus-summary-execute-command
6969 "c" gnus-summary-catchup-and-exit
6970 "\C-w" gnus-summary-mark-region-as-read
6971 "\C-t" gnus-summary-toggle-truncation
6972 "?" gnus-summary-mark-as-dormant
6973 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6974 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6975 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6976 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6977 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6978 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6979 "=" gnus-summary-expand-window
6980 "\C-x\C-s" gnus-summary-reselect-current-group
6981 "\M-g" gnus-summary-rescan-group
6982 "w" gnus-summary-stop-page-breaking
6983 "\C-c\C-r" gnus-summary-caesar-message
6984 "\M-t" gnus-summary-toggle-mime
6985 "f" gnus-summary-followup
6986 "F" gnus-summary-followup-with-original
6987 "C" gnus-summary-cancel-article
6988 "r" gnus-summary-reply
6989 "R" gnus-summary-reply-with-original
6990 "\C-c\C-f" gnus-summary-mail-forward
6991 "o" gnus-summary-save-article
6992 "\C-o" gnus-summary-save-article-mail
6993 "|" gnus-summary-pipe-output
6994 "\M-k" gnus-summary-edit-local-kill
6995 "\M-K" gnus-summary-edit-global-kill
6997 "\C-c\C-d" gnus-summary-describe-group
6998 "q" gnus-summary-exit
6999 "Q" gnus-summary-exit-no-update
7000 "\C-c\C-i" gnus-info-find-node
7001 gnus-mouse-2 gnus-mouse-pick-article
7002 "m" gnus-summary-mail-other-window
7003 "a" gnus-summary-post-news
7004 "x" gnus-summary-limit-to-unread
7005 "s" gnus-summary-isearch-article
7006 "t" gnus-article-hide-headers
7007 "g" gnus-summary-show-article
7008 "l" gnus-summary-goto-last-article
7009 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7010 "\C-d" gnus-summary-enter-digest-group
7012 "*" gnus-cache-enter-article
7013 "\M-*" gnus-cache-remove-article
7014 "\M-&" gnus-summary-universal-argument
7015 "\C-l" gnus-recenter
7016 "I" gnus-summary-increase-score
7017 "L" gnus-summary-lower-score
7019 "V" gnus-summary-score-map
7020 "X" gnus-uu-extract-map
7021 "S" gnus-summary-send-map)
7023 ;; Sort of orthogonal keymap
7024 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7025 "t" gnus-summary-tick-article-forward
7026 "!" gnus-summary-tick-article-forward
7027 "d" gnus-summary-mark-as-read-forward
7028 "r" gnus-summary-mark-as-read-forward
7029 "c" gnus-summary-clear-mark-forward
7030 " " gnus-summary-clear-mark-forward
7031 "e" gnus-summary-mark-as-expirable
7032 "x" gnus-summary-mark-as-expirable
7033 "?" gnus-summary-mark-as-dormant
7034 "b" gnus-summary-set-bookmark
7035 "B" gnus-summary-remove-bookmark
7036 "#" gnus-summary-mark-as-processable
7037 "\M-#" gnus-summary-unmark-as-processable
7038 "S" gnus-summary-limit-include-expunged
7039 "C" gnus-summary-catchup
7040 "H" gnus-summary-catchup-to-here
7041 "\C-c" gnus-summary-catchup-all
7042 "k" gnus-summary-kill-same-subject-and-select
7043 "K" gnus-summary-kill-same-subject
7044 "P" gnus-uu-mark-map)
7046 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7047 "c" gnus-summary-clear-above
7048 "u" gnus-summary-tick-above
7049 "m" gnus-summary-mark-above
7050 "k" gnus-summary-kill-below)
7052 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7053 "/" gnus-summary-limit-to-subject
7054 "n" gnus-summary-limit-to-articles
7055 "w" gnus-summary-pop-limit
7056 "s" gnus-summary-limit-to-subject
7057 "a" gnus-summary-limit-to-author
7058 "u" gnus-summary-limit-to-unread
7059 "m" gnus-summary-limit-to-marks
7060 "v" gnus-summary-limit-to-score
7061 "D" gnus-summary-limit-include-dormant
7062 "d" gnus-summary-limit-exclude-dormant
7063 ;; "t" gnus-summary-limit-exclude-thread
7064 "E" gnus-summary-limit-include-expunged
7065 "c" gnus-summary-limit-exclude-childless-dormant
7066 "C" gnus-summary-limit-mark-excluded-as-read)
7068 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7069 "n" gnus-summary-next-unread-article
7070 "p" gnus-summary-prev-unread-article
7071 "N" gnus-summary-next-article
7072 "P" gnus-summary-prev-article
7073 "\C-n" gnus-summary-next-same-subject
7074 "\C-p" gnus-summary-prev-same-subject
7075 "\M-n" gnus-summary-next-unread-subject
7076 "\M-p" gnus-summary-prev-unread-subject
7077 "f" gnus-summary-first-unread-article
7078 "b" gnus-summary-best-unread-article
7079 "j" gnus-summary-goto-article
7080 "g" gnus-summary-goto-subject
7081 "l" gnus-summary-goto-last-article
7082 "p" gnus-summary-pop-article)
7084 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7085 "k" gnus-summary-kill-thread
7086 "l" gnus-summary-lower-thread
7087 "i" gnus-summary-raise-thread
7088 "T" gnus-summary-toggle-threads
7089 "t" gnus-summary-rethread-current
7090 "^" gnus-summary-reparent-thread
7091 "s" gnus-summary-show-thread
7092 "S" gnus-summary-show-all-threads
7093 "h" gnus-summary-hide-thread
7094 "H" gnus-summary-hide-all-threads
7095 "n" gnus-summary-next-thread
7096 "p" gnus-summary-prev-thread
7097 "u" gnus-summary-up-thread
7098 "o" gnus-summary-top-thread
7099 "d" gnus-summary-down-thread
7100 "#" gnus-uu-mark-thread
7101 "\M-#" gnus-uu-unmark-thread)
7103 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7104 "c" gnus-summary-catchup-and-exit
7105 "C" gnus-summary-catchup-all-and-exit
7106 "E" gnus-summary-exit-no-update
7107 "Q" gnus-summary-exit
7108 "Z" gnus-summary-exit
7109 "n" gnus-summary-catchup-and-goto-next-group
7110 "R" gnus-summary-reselect-current-group
7111 "G" gnus-summary-rescan-group
7112 "N" gnus-summary-next-group
7113 "P" gnus-summary-prev-group)
7115 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7116 " " gnus-summary-next-page
7117 "n" gnus-summary-next-page
7118 "\177" gnus-summary-prev-page
7119 [delete] gnus-summary-prev-page
7120 "p" gnus-summary-prev-page
7121 "\r" gnus-summary-scroll-up
7122 "<" gnus-summary-beginning-of-article
7123 ">" gnus-summary-end-of-article
7124 "b" gnus-summary-beginning-of-article
7125 "e" gnus-summary-end-of-article
7126 "^" gnus-summary-refer-parent-article
7127 "r" gnus-summary-refer-parent-article
7128 "R" gnus-summary-refer-references
7129 "g" gnus-summary-show-article
7130 "s" gnus-summary-isearch-article
)
7132 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map
)
7133 "b" gnus-article-add-buttons
7134 "B" gnus-article-add-buttons-to-head
7135 "o" gnus-article-treat-overstrike
7136 ;; "w" gnus-article-word-wrap
7137 "w" gnus-article-fill-cited-article
7138 "c" gnus-article-remove-cr
7139 "L" gnus-article-remove-trailing-blank-lines
7140 "q" gnus-article-de-quoted-unreadable
7141 "f" gnus-article-display-x-face
7142 "l" gnus-summary-stop-page-breaking
7143 "r" gnus-summary-caesar-message
7144 "t" gnus-article-hide-headers
7145 "v" gnus-summary-verbose-headers
7146 "m" gnus-summary-toggle-mime
)
7148 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map
)
7149 "a" gnus-article-hide
7150 "h" gnus-article-hide-headers
7151 "b" gnus-article-hide-boring-headers
7152 "s" gnus-article-hide-signature
7153 "c" gnus-article-hide-citation
7154 "p" gnus-article-hide-pgp
7155 "\C-c" gnus-article-hide-citation-maybe
)
7157 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map
)
7158 "a" gnus-article-highlight
7159 "h" gnus-article-highlight-headers
7160 "c" gnus-article-highlight-citation
7161 "s" gnus-article-highlight-signature
)
7163 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map
)
7164 "z" gnus-article-date-ut
7165 "u" gnus-article-date-ut
7166 "l" gnus-article-date-local
7167 "e" gnus-article-date-lapsed
7168 "o" gnus-article-date-original
)
7170 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map
)
7172 "f" gnus-summary-fetch-faq
7173 "d" gnus-summary-describe-group
7174 "h" gnus-summary-describe-briefly
7175 "i" gnus-info-find-node
)
7177 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map
)
7178 "e" gnus-summary-expire-articles
7179 "\M-\C-e" gnus-summary-expire-articles-now
7180 "\177" gnus-summary-delete-article
7181 [delete] gnus-summary-delete-article
7182 "m" gnus-summary-move-article
7183 "r" gnus-summary-respool-article
7184 "w" gnus-summary-edit-article
7185 "c" gnus-summary-copy-article
7186 "B" gnus-summary-crosspost-article
7187 "q" gnus-summary-respool-query
7188 "i" gnus-summary-import-article)
7190 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7191 "o" gnus-summary-save-article
7192 "m" gnus-summary-save-article-mail
7193 "r" gnus-summary-save-article-rmail
7194 "f" gnus-summary-save-article-file
7195 "b" gnus-summary-save-article-body-file
7196 "h" gnus-summary-save-article-folder
7197 "v" gnus-summary-save-article-vm
7198 "p" gnus-summary-pipe-output
7199 "s" gnus-soup-add-article)
7204 (defun gnus-summary-mode (&optional group)
7205 "Major mode for reading articles.
7207 All normal editing commands are switched off.
7208 \\<gnus-summary-mode-map>
7209 Each line in this buffer represents one article. To read an
7210 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7211 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7214 You can also post articles and send mail from this buffer. To
7215 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7216 of an article, type `\\[gnus-summary-reply]'.
7218 There are approx. one gazillion commands you can execute in this
7219 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7221 The following commands are available:
7223 \\{gnus-summary-mode-map}"
7225 (when (and menu-bar-mode
7226 (gnus-visual-p 'summary-menu 'menu))
7227 (gnus-summary-make-menu-bar))
7228 (kill-all-local-variables)
7229 (gnus-summary-make-local-variables)
7230 (gnus-make-thread-indent-array)
7231 (gnus-simplify-mode-line)
7232 (setq major-mode 'gnus-summary-mode)
7233 (setq mode-name "Summary")
7234 (make-local-variable 'minor-mode-alist)
7235 (use-local-map gnus-summary-mode-map)
7236 (buffer-disable-undo (current-buffer))
7237 (setq buffer-read-only t) ;Disable modification
7238 (setq truncate-lines t)
7239 (setq selective-display t)
7240 (setq selective-display-ellipses t) ;Display `...'
7241 (setq buffer-display-table gnus-summary-display-table)
7242 (setq gnus-newsgroup-name group)
7243 (make-local-variable 'gnus-summary-line-format)
7244 (make-local-variable 'gnus-summary-line-format-spec)
7245 (make-local-variable 'gnus-summary-mark-positions)
7246 (gnus-make-local-hook 'post-command-hook)
7247 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7248 (run-hooks 'gnus-summary-mode-hook))
7250 (defun gnus-summary-make-local-variables ()
7251 "Make all the local summary buffer variables."
7252 (let ((locals gnus-summary-local-variables)
7254 (while (setq local (pop locals))
7257 (if (eq (cdr local) 'global)
7258 ;; Copy the global value of the variable.
7259 (setq global (symbol-value (car local)))
7260 ;; Use the value from the list.
7261 (setq global (eval (cdr local))))
7262 (make-local-variable (car local))
7263 (set (car local) global))
7264 ;; Simple nil-valued local variable.
7265 (make-local-variable local)
7268 (defun gnus-summary-make-display-table ()
7269 ;; Change the display table. Odd characters have a tendency to mess
7270 ;; up nicely formatted displays - we make all possible glyphs
7271 ;; display only a single character.
7273 ;; We start from the standard display table, if any.
7274 (setq gnus-summary-display-table
7275 (or (copy-sequence standard-display-table)
7276 (make-display-table)))
7277 ;; Nix out all the control chars...
7279 (while (>= (setq i (1- i)) 0)
7280 (aset gnus-summary-display-table i [??])))
7281 ;; ... but not newline and cr, of course. (cr is necessary for the
7282 ;; selective display).
7283 (aset gnus-summary-display-table ?\n nil)
7284 (aset gnus-summary-display-table ?\r nil)
7285 ;; We nix out any glyphs over 126 that are not set already.
7287 (while (>= (setq i (1- i)) 127)
7288 ;; Only modify if the entry is nil.
7289 (or (aref gnus-summary-display-table i)
7290 (aset gnus-summary-display-table i [??])))))
7292 (defun gnus-summary-clear-local-variables ()
7293 (let ((locals gnus-summary-local-variables))
7295 (if (consp (car locals))
7296 (and (vectorp (caar locals))
7297 (set (caar locals) nil))
7298 (and (vectorp (car locals))
7299 (set (car locals) nil)))
7300 (setq locals (cdr locals)))))
7302 ;; Summary data functions.
7304 (defmacro gnus-data-number (data)
7307 (defmacro gnus-data-set-number (data number)
7308 `(setcar ,data ,number))
7310 (defmacro gnus-data-mark (data)
7313 (defmacro gnus-data-set-mark (data mark)
7314 `(setcar (nthcdr 1 ,data) ,mark))
7316 (defmacro gnus-data-pos (data)
7319 (defmacro gnus-data-set-pos (data pos)
7320 `(setcar (nthcdr 2 ,data) ,pos))
7322 (defmacro gnus-data-header (data)
7325 (defmacro gnus-data-level (data)
7328 (defmacro gnus-data-unread-p (data)
7329 `(= (nth 1 ,data) gnus-unread-mark))
7331 (defmacro gnus-data-pseudo-p (data)
7332 `(consp (nth 3 ,data)))
7334 (defmacro gnus-data-find (number)
7335 `(assq ,number gnus-newsgroup-data))
7337 (defmacro gnus-data-find-list (number &optional data)
7338 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7339 (memq (assq ,number bdata)
7342 (defmacro gnus-data-make (number mark pos header level)
7343 `(list ,number ,mark ,pos ,header ,level))
7345 (defun gnus-data-enter (after-article number mark pos header level offset)
7346 (let ((data (gnus-data-find-list after-article)))
7347 (or data (error "No such article: %d" after-article))
7348 (setcdr data (cons (gnus-data-make number mark pos header level)
7350 (setq gnus-newsgroup-data-reverse nil)
7351 (gnus-data-update-list (cddr data) offset)))
7353 (defun gnus-data-enter-list (after-article list &optional offset)
7355 (let ((data (and after-article (gnus-data-find-list after-article)))
7357 (or data (not after-article) (error "No such article: %d" after-article))
7358 ;; Find the last element in the list to be spliced into the main
7361 (setq list (cdr list)))
7364 (setcdr list gnus-newsgroup-data)
7365 (setq gnus-newsgroup-data ilist)
7366 (and offset (gnus-data-update-list (cdr list) offset)))
7367 (setcdr list (cdr data))
7369 (and offset (gnus-data-update-list (cdr data) offset)))
7370 (setq gnus-newsgroup-data-reverse nil))))
7372 (defun gnus-data-remove (article &optional offset)
7373 (let ((data gnus-newsgroup-data))
7374 (if (= (gnus-data-number (car data)) article)
7375 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7376 gnus-newsgroup-data-reverse nil)
7378 (and (= (gnus-data-number (cadr data)) article)
7380 (setcdr data (cddr data))
7381 (and offset (gnus-data-update-list (cdr data) offset))
7383 gnus-newsgroup-data-reverse nil)))
7384 (setq data (cdr data))))))
7386 (defmacro gnus-data-list (backward)
7388 (or gnus-newsgroup-data-reverse
7389 (setq gnus-newsgroup-data-reverse
7390 (reverse gnus-newsgroup-data)))
7391 gnus-newsgroup-data))
7393 (defun gnus-data-update-list (data offset)
7394 "Add OFFSET to the POS of all data entries in DATA."
7396 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7397 (setq data (cdr data))))
7399 (defun gnus-data-compute-positions ()
7400 "Compute the positions of all articles."
7401 (let ((data gnus-newsgroup-data)
7404 (when (setq pos (text-property-any
7405 (point-min) (point-max)
7406 'gnus-number (gnus-data-number (car data))))
7407 (gnus-data-set-pos (car data) (+ pos 3)))
7408 (setq data (cdr data)))))
7410 (defun gnus-summary-article-pseudo-p (article)
7411 "Say whether this article is a pseudo article or not."
7412 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7414 (defun gnus-article-parent-p (number)
7415 "Say whether this article is a parent or not."
7416 (let ((data (gnus-data-find-list number)))
7417 (and (cdr data) ; There has to be an article after...
7418 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7419 (gnus-data-level (nth 1 data))))))
7421 (defun gnus-article-children (number)
7422 "Return a list of all children to NUMBER."
7423 (let* ((data (gnus-data-find-list number))
7424 (level (gnus-data-level (car data)))
7426 (setq data (cdr data))
7428 (= (gnus-data-level (car data)) (1+ level)))
7429 (push (gnus-data-number (car data)) children)
7430 (setq data (cdr data)))
7433 (defmacro gnus-summary-skip-intangible ()
7434 "If the current article is intangible, then jump to a different article."
7435 '(let ((to (get-text-property (point) 'gnus-intangible)))
7436 (and to (gnus-summary-goto-subject to))))
7438 (defmacro gnus-summary-article-intangible-p ()
7439 "Say whether this article is intangible or not."
7440 '(get-text-property (point) 'gnus-intangible))
7442 ;; Some summary mode macros.
7444 (defmacro gnus-summary-article-number ()
7445 "The article number of the article on the current line.
7446 If there isn's an article number here, then we return the current
7449 (gnus-summary-skip-intangible)
7450 (or (get-text-property (point) 'gnus-number)
7451 (gnus-summary-last-subject))))
7453 (defmacro gnus-summary-article-header (&optional number)
7454 `(gnus-data-header (gnus-data-find
7455 ,(or number '(gnus-summary-article-number)))))
7457 (defmacro gnus-summary-thread-level (&optional number)
7458 `(if (and (eq gnus-summary-make-false-root 'dummy)
7459 (get-text-property (point) 'gnus-intangible))
7461 (gnus-data-level (gnus-data-find
7462 ,(or number '(gnus-summary-article-number))))))
7464 (defmacro gnus-summary-article-mark (&optional number)
7465 `(gnus-data-mark (gnus-data-find
7466 ,(or number '(gnus-summary-article-number)))))
7468 (defmacro gnus-summary-article-pos (&optional number)
7469 `(gnus-data-pos (gnus-data-find
7470 ,(or number '(gnus-summary-article-number)))))
7472 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7473 (defmacro gnus-summary-article-subject (&optional number)
7474 "Return current subject string or nil if nothing."
7477 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7478 '(gnus-data-header (assq (gnus-summary-article-number)
7479 gnus-newsgroup-data)))))
7482 (mail-header-subject headers))))
7484 (defmacro gnus-summary-article-score (&optional number)
7485 "Return current article score."
7486 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7487 gnus-newsgroup-scored))
7488 gnus-summary-default-score 0))
7490 (defun gnus-summary-article-children (&optional number)
7491 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7492 (level (gnus-data-level (car data)))
7494 (while (and (setq data (cdr data))
7495 (> (setq l (gnus-data-level (car data))) level))
7496 (and (= (1+ level) l)
7497 (setq children (cons (gnus-data-number (car data))
7499 (nreverse children)))
7501 (defun gnus-summary-article-parent (&optional number)
7502 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7503 (gnus-data-list t)))
7504 (level (gnus-data-level (car data))))
7506 () ; This is a root.
7507 ;; We search until we find an article with a level less than
7508 ;; this one. That function has to be the parent.
7509 (while (and (setq data (cdr data))
7510 (not (< (gnus-data-level (car data)) level))))
7511 (and data (gnus-data-number (car data))))))
7513 (defun gnus-unread-mark-p (mark)
7514 "Say whether MARK is the unread mark."
7515 (= mark gnus-unread-mark))
7517 (defun gnus-read-mark-p (mark)
7518 "Say whether MARK is one of the marks that mark as read.
7519 This is all marks except unread, ticked, dormant, and expirable."
7520 (not (or (= mark gnus-unread-mark)
7521 (= mark gnus-ticked-mark)
7522 (= mark gnus-dormant-mark)
7523 (= mark gnus-expirable-mark))))
7525 ;; Saving hidden threads.
7527 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7528 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7529 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7531 (defmacro gnus-save-hidden-threads (&rest forms)
7532 "Save hidden threads, eval FORMS, and restore the hidden threads."
7533 (let ((config (make-symbol "config")))
7534 `(let ((,config (gnus-hidden-threads-configuration)))
7538 (gnus-restore-hidden-threads-configuration ,config)))))
7540 (defun gnus-hidden-threads-configuration ()
7541 "Return the current hidden threads configuration."
7544 (goto-char (point-min))
7545 (while (search-forward "\r" nil t)
7546 (push (1- (point)) config))
7549 (defun gnus-restore-hidden-threads-configuration (config)
7550 "Restore hidden threads configuration from CONFIG."
7551 (let (point buffer-read-only)
7552 (while (setq point (pop config))
7553 (when (and (< point (point-max))
7555 (= (following-char) ?\n))
7556 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7558 ;; Various summary mode internalish functions.
7560 (defun gnus-mouse-pick-article (e)
7563 (gnus-summary-next-page nil t))
7565 (defun gnus-summary-setup-buffer (group)
7566 "Initialize summary buffer."
7567 (let ((buffer (concat "*Summary " group "*")))
7568 (if (get-buffer buffer)
7571 (setq gnus-summary-buffer (current-buffer))
7572 (not gnus-newsgroup-prepared))
7573 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7574 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7575 (gnus-add-current-to-buffer-list)
7576 (gnus-summary-mode group)
7578 (gnus-carpal-setup-buffer 'summary))
7579 (unless gnus-single-article-buffer
7580 (make-local-variable 'gnus-article-buffer)
7581 (make-local-variable 'gnus-article-current)
7582 (make-local-variable 'gnus-original-article-buffer))
7583 (setq gnus-newsgroup-name group)
7586 (defun gnus-set-global-variables ()
7587 ;; Set the global equivalents of the summary buffer-local variables
7588 ;; to the latest values they had. These reflect the summary buffer
7589 ;; that was in action when the last article was fetched.
7590 (when (eq major-mode 'gnus-summary-mode)
7591 (setq gnus-summary-buffer (current-buffer))
7592 (let ((name gnus-newsgroup-name)
7593 (marked gnus-newsgroup-marked)
7594 (unread gnus-newsgroup-unreads)
7595 (headers gnus-current-headers)
7596 (data gnus-newsgroup-data)
7597 (summary gnus-summary-buffer)
7598 (article-buffer gnus-article-buffer)
7599 (original gnus-original-article-buffer)
7600 (gac gnus-article-current)
7601 (score-file gnus-current-score-file))
7603 (set-buffer gnus-group-buffer)
7604 (setq gnus-newsgroup-name name)
7605 (setq gnus-newsgroup-marked marked)
7606 (setq gnus-newsgroup-unreads unread)
7607 (setq gnus-current-headers headers)
7608 (setq gnus-newsgroup-data data)
7609 (setq gnus-article-current gac)
7610 (setq gnus-summary-buffer summary)
7611 (setq gnus-article-buffer article-buffer)
7612 (setq gnus-original-article-buffer original)
7613 (setq gnus-current-score-file score-file)))))
7615 (defun gnus-summary-last-article-p (&optional article)
7616 "Return whether ARTICLE is the last article in the buffer."
7617 (if (not (setq article (or article (gnus-summary-article-number))))
7618 t ; All non-existant numbers are the last article. :-)
7619 (not (cdr (gnus-data-find-list article)))))
7621 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7622 "Insert a dummy root in the summary buffer."
7624 (gnus-add-text-properties
7625 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7626 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7628 (defun gnus-make-thread-indent-array ()
7630 (unless (and gnus-thread-indent-array
7631 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7632 (setq gnus-thread-indent-array (make-vector 201 "")
7633 gnus-thread-indent-array-level gnus-thread-indent-level)
7635 (aset gnus-thread-indent-array n
7636 (make-string (* n gnus-thread-indent-level) ? ))
7639 (defun gnus-summary-insert-line
7640 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7641 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7642 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7643 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7644 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7645 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7646 (gnus-tmp-score-char
7647 (if (or (null gnus-summary-default-score)
7648 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7649 gnus-summary-zcore-fuzz)) ?
7650 (if (< gnus-tmp-score gnus-summary-default-score)
7651 gnus-score-below-mark gnus-score-over-mark)))
7652 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7653 ((memq gnus-tmp-current gnus-newsgroup-cached)
7655 (gnus-tmp-replied gnus-replied-mark)
7656 ((memq gnus-tmp-current gnus-newsgroup-saved)
7658 (t gnus-unread-mark)))
7659 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7662 ((string-match "(.+)" gnus-tmp-from)
7663 (substring gnus-tmp-from
7664 (1+ (match-beginning 0)) (1- (match-end 0))))
7665 ((string-match "<[^>]+> *$" gnus-tmp-from)
7666 (let ((beg (match-beginning 0)))
7667 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7668 (substring gnus-tmp-from (1+ (match-beginning 0))
7669 (1- (match-end 0))))
7670 (substring gnus-tmp-from 0 beg))))
7672 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7673 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7674 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7675 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7676 (buffer-read-only nil))
7677 (when (string= gnus-tmp-name "")
7678 (setq gnus-tmp-name gnus-tmp-from))
7679 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7680 (gnus-put-text-property
7682 (progn (eval gnus-summary-line-format-spec) (point))
7683 'gnus-number gnus-tmp-number)
7684 (when (gnus-visual-p 'summary-highlight 'highlight)
7686 (run-hooks 'gnus-summary-update-hook)
7689 (defun gnus-summary-update-line (&optional dont-update)
7690 ;; Update summary line after change.
7691 (when (and gnus-summary-default-score
7692 (not gnus-summary-inhibit-highlight))
7693 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7694 (article (gnus-summary-article-number))
7695 (score (gnus-summary-article-score article)))
7697 (if (and gnus-summary-mark-below
7698 (< (gnus-summary-article-score)
7699 gnus-summary-mark-below))
7700 ;; This article has a low score, so we mark it as read.
7701 (when (memq article gnus-newsgroup-unreads)
7702 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7703 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7704 ;; This article was previously marked as read on account
7705 ;; of a low score, but now it has risen, so we mark it as
7707 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7708 (gnus-summary-update-mark
7709 (if (or (null gnus-summary-default-score)
7710 (<= (abs (- score gnus-summary-default-score))
7711 gnus-summary-zcore-fuzz)) ?
7712 (if (< score gnus-summary-default-score)
7713 gnus-score-below-mark gnus-score-over-mark)) 'score))
7714 ;; Do visual highlighting.
7715 (when (gnus-visual-p 'summary-highlight 'highlight)
7716 (run-hooks 'gnus-summary-update-hook)))))
7718 (defvar gnus-tmp-new-adopts nil)
7720 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7721 ;; Sum up all elements (and sub-elements) in a list.
7723 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7725 ((and (consp thread) (cdr thread))
7728 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7731 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7734 (when (and level (zerop level) gnus-tmp-new-adopts)
7737 'gnus-summary-number-of-articles-in-thread
7738 gnus-tmp-new-adopts))))
7740 (if (> number 1) gnus-not-empty-thread-mark
7741 gnus-empty-thread-mark)
7744 (defun gnus-summary-set-local-parameters (group)
7745 "Go through the local params of GROUP and set all variable specs in that list."
7746 (let ((params (gnus-info-params (gnus-get-info group)))
7749 (setq elem (car params)
7750 params (cdr params))
7751 (and (consp elem) ; Has to be a cons.
7752 (consp (cdr elem)) ; The cdr has to be a list.
7753 (symbolp (car elem)) ; Has to be a symbol in there.
7754 (not (memq (car elem)
7755 '(quit-config to-address to-list to-group)))
7756 (progn ; So we set it.
7757 (make-local-variable (car elem))
7758 (set (car elem) (eval (nth 1 elem))))))))
7760 (defun gnus-summary-read-group (group &optional show-all no-article
7761 kill-buffer no-display)
7762 "Start reading news in newsgroup GROUP.
7763 If SHOW-ALL is non-nil, already read articles are also listed.
7764 If NO-ARTICLE is non-nil, no article is selected initially.
7765 If NO-DISPLAY, don't generate a summary buffer."
7766 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7767 (let* ((new-group (gnus-summary-setup-buffer group))
7768 (quit-config (gnus-group-quit-config group))
7769 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7771 ;; This summary buffer exists already, so we just select it.
7773 (gnus-set-global-variables)
7775 (gnus-kill-or-deaden-summary kill-buffer))
7776 (gnus-configure-windows 'summary 'force)
7777 (gnus-set-mode-line 'summary)
7778 (gnus-summary-position-point)
7781 ;; We couldn't select this group.
7783 (when (and (eq major-mode 'gnus-summary-mode)
7784 (not (equal (current-buffer) kill-buffer)))
7785 (kill-buffer (current-buffer))
7786 (if (not quit-config)
7788 (set-buffer gnus-group-buffer)
7789 (gnus-group-jump-to-group group)
7790 (gnus-group-next-unread-group 1))
7791 (if (not (buffer-name (car quit-config)))
7792 (gnus-configure-windows 'group 'force)
7793 (set-buffer (car quit-config))
7794 (and (eq major-mode 'gnus-summary-mode)
7795 (gnus-set-global-variables))
7796 (gnus-configure-windows (cdr quit-config)))))
7797 (gnus-message 3 "Can't select group")
7799 ;; The user did a `C-g' while prompting for number of articles,
7800 ;; so we exit this group.
7801 ((eq did-select 'quit)
7802 (and (eq major-mode 'gnus-summary-mode)
7803 (not (equal (current-buffer) kill-buffer))
7804 (kill-buffer (current-buffer)))
7806 (gnus-kill-or-deaden-summary kill-buffer))
7807 (if (not quit-config)
7809 (set-buffer gnus-group-buffer)
7810 (gnus-group-jump-to-group group)
7811 (gnus-group-next-unread-group 1)
7812 (gnus-configure-windows 'group 'force))
7813 (if (not (buffer-name (car quit-config)))
7814 (gnus-configure-windows 'group 'force)
7815 (set-buffer (car quit-config))
7816 (and (eq major-mode 'gnus-summary-mode)
7817 (gnus-set-global-variables))
7818 (gnus-configure-windows (cdr quit-config))))
7819 ;; Finally signal the quit.
7821 ;; The group was successfully selected.
7823 (gnus-set-global-variables)
7824 ;; Save the active value in effect when the group was entered.
7825 (setq gnus-newsgroup-active
7827 (gnus-active gnus-newsgroup-name)))
7828 ;; You can change the summary buffer in some way with this hook.
7829 (run-hooks 'gnus-select-group-hook)
7830 ;; Set any local variables in the group parameters.
7831 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7832 (gnus-update-format-specifications)
7833 ;; Do score processing.
7834 (when gnus-use-scoring
7835 (gnus-possibly-score-headers))
7836 ;; Check whether to fill in the gaps in the threads.
7837 (when gnus-build-sparse-threads
7838 (gnus-build-sparse-threads))
7839 ;; Find the initial limit.
7840 (if gnus-show-threads
7842 (let ((gnus-newsgroup-dormant nil))
7843 (gnus-summary-initial-limit show-all))
7844 (gnus-summary-initial-limit show-all))
7845 (setq gnus-newsgroup-limit
7847 (lambda (header) (mail-header-number header))
7848 gnus-newsgroup-headers)))
7849 ;; Generate the summary buffer.
7851 (gnus-summary-prepare))
7852 (when gnus-use-trees
7853 (gnus-tree-open group)
7854 (setq gnus-summary-highlight-line-function
7855 'gnus-tree-highlight-article))
7856 ;; If the summary buffer is empty, but there are some low-scored
7857 ;; articles or some excluded dormants, we include these in the
7859 (when (and (zerop (buffer-size))
7861 (cond (gnus-newsgroup-dormant
7862 (gnus-summary-limit-include-dormant))
7863 ((and gnus-newsgroup-scored show-all)
7864 (gnus-summary-limit-include-expunged))))
7865 ;; Function `gnus-apply-kill-file' must be called in this hook.
7866 (run-hooks 'gnus-apply-kill-hook)
7867 (if (and (zerop (buffer-size))
7870 ;; This newsgroup is empty.
7871 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7872 (gnus-message 6 "No unread news")
7874 (gnus-kill-or-deaden-summary kill-buffer))
7875 ;; Return nil from this function.
7877 ;; Hide conversation thread subtrees. We cannot do this in
7878 ;; gnus-summary-prepare-hook since kill processing may not
7879 ;; work with hidden articles.
7880 (and gnus-show-threads
7881 gnus-thread-hide-subtree
7882 (gnus-summary-hide-all-threads))
7883 ;; Show first unread article if requested.
7884 (if (and (not no-article)
7886 gnus-newsgroup-unreads
7887 gnus-auto-select-first)
7888 (unless (if (eq gnus-auto-select-first 'best)
7889 (gnus-summary-best-unread-article)
7890 (gnus-summary-first-unread-article))
7891 (gnus-configure-windows 'summary))
7892 ;; Don't select any articles, just move point to the first
7893 ;; article in the group.
7894 (goto-char (point-min))
7895 (gnus-summary-position-point)
7896 (gnus-set-mode-line 'summary)
7897 (gnus-configure-windows 'summary 'force))
7898 ;; If we are in async mode, we send some info to the backend.
7899 (when gnus-newsgroup-async
7900 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7902 (gnus-kill-or-deaden-summary kill-buffer))
7903 (when (get-buffer-window gnus-group-buffer t)
7904 ;; Gotta use windows, because recenter does wierd stuff if
7905 ;; the current buffer ain't the displayed window.
7906 (let ((owin (selected-window)))
7907 (select-window (get-buffer-window gnus-group-buffer t))
7908 (when (gnus-group-goto-group group)
7910 (select-window owin))))
7911 ;; Mark this buffer as "prepared".
7912 (setq gnus-newsgroup-prepared t)
7915 (defun gnus-summary-prepare ()
7916 "Generate the summary buffer."
7917 (let ((buffer-read-only nil))
7919 (setq gnus-newsgroup-data nil
7920 gnus-newsgroup-data-reverse nil)
7921 (run-hooks 'gnus-summary-generate-hook)
7922 ;; Generate the buffer, either with threads or without.
7923 (when gnus-newsgroup-headers
7924 (gnus-summary-prepare-threads
7925 (if gnus-show-threads
7926 (gnus-sort-gathered-threads
7927 (funcall gnus-summary-thread-gathering-function
7929 (gnus-cut-threads (gnus-make-threads)))))
7930 ;; Unthreaded display.
7931 (gnus-sort-articles gnus-newsgroup-headers))))
7932 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7933 ;; Call hooks for modifying summary buffer.
7934 (goto-char (point-min))
7935 (run-hooks 'gnus-summary-prepare-hook)))
7937 (defun gnus-gather-threads-by-subject (threads)
7938 "Gather threads by looking at Subject headers."
7939 (if (not gnus-summary-make-false-root)
7941 (let ((hashtb (gnus-make-hashtable 1023))
7944 subject hthread whole-subject)
7946 (setq whole-subject (mail-header-subject (caar threads)))
7949 ;; Truncate the subject.
7950 ((numberp gnus-summary-gather-subject-limit)
7951 (setq subject (gnus-simplify-subject-re whole-subject))
7952 (if (> (length subject) gnus-summary-gather-subject-limit)
7953 (substring subject 0 gnus-summary-gather-subject-limit)
7955 ;; Fuzzily simplify it.
7956 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7957 (gnus-simplify-subject-fuzzy whole-subject))
7958 ;; Just remove the leading "Re:".
7960 (gnus-simplify-subject-re whole-subject))))
7962 (if (and gnus-summary-gather-exclude-subject
7963 (string-match gnus-summary-gather-exclude-subject
7965 () ; We don't want to do anything with this article.
7966 ;; We simplify the subject before looking it up in the
7969 (if (setq hthread (gnus-gethash subject hashtb))
7971 ;; We enter a dummy root into the thread, if we
7972 ;; haven't done that already.
7973 (unless (stringp (caar hthread))
7974 (setcar hthread (list whole-subject (car hthread))))
7975 ;; We add this new gathered thread to this gathered
7977 (setcdr (car hthread)
7978 (nconc (cdar hthread) (list (car threads))))
7979 ;; Remove it from the list of threads.
7980 (setcdr prev (cdr threads))
7981 (setq threads prev))
7982 ;; Enter this thread into the hash table.
7983 (gnus-sethash subject threads hashtb)))
7985 (setq threads (cdr threads)))
7988 (defun gnus-gather-threads-by-references (threads)
7989 "Gather threads by looking at References headers."
7990 (let ((idhashtb (gnus-make-hashtable 1023))
7991 (thhashtb (gnus-make-hashtable 1023))
7994 ids references id gthread gid entered)
7996 (when (setq references (mail-header-references (caar threads)))
7997 (setq id (mail-header-id (caar threads)))
7998 (setq ids (gnus-split-references references))
8001 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8003 (gnus-sethash (car ids) id idhashtb)
8004 (gnus-sethash id threads thhashtb))
8005 (setq gthread (gnus-gethash gid thhashtb))
8007 ;; We enter a dummy root into the thread, if we
8008 ;; haven't done that already.
8009 (unless (stringp (caar gthread))
8010 (setcar gthread (list (mail-header-subject (caar gthread))
8012 ;; We add this new gathered thread to this gathered
8014 (setcdr (car gthread)
8015 (nconc (cdar gthread) (list (car threads)))))
8016 ;; Add it into the thread hash table.
8017 (gnus-sethash id gthread thhashtb)
8019 ;; Remove it from the list of threads.
8020 (setcdr prev (cdr threads))
8021 (setq threads prev))
8022 (setq ids (cdr ids))))
8024 (setq threads (cdr threads)))
8027 (defun gnus-sort-gathered-threads (threads)
8028 "Sort subtreads inside each gathered thread by article number."
8029 (let ((result threads))
8031 (when (stringp (caar threads))
8032 (setcdr (car threads)
8033 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8034 (setq threads (cdr threads)))
8037 (defun gnus-make-threads ()
8038 "Go through the dependency hashtb and find the roots. Return all threads."
8042 (unless (car (symbol-value refs))
8043 ;; These threads do not refer back to any other articles,
8044 ;; so they're roots.
8045 (setq threads (append (cdr (symbol-value refs)) threads))))
8046 gnus-newsgroup-dependencies)
8049 (defun gnus-build-sparse-threads ()
8050 (let ((headers gnus-newsgroup-headers)
8051 (deps gnus-newsgroup-dependencies)
8052 header references generation relations
8053 cthread subject child end pthread relation)
8054 ;; First we create an alist of generations/relations, where
8055 ;; generations is how much we trust the ralation, and the relation
8057 (gnus-message 7 "Making sparse threads...")
8059 (nnheader-set-temp-buffer " *gnus sparse threads*")
8060 (while (setq header (pop headers))
8061 (when (and (setq references (mail-header-references header))
8062 (not (string= references "")))
8064 (setq child (mail-header-id header)
8065 subject (mail-header-subject header))
8067 (while (search-backward ">" nil t)
8068 (setq end (1+ (point)))
8069 (when (search-backward "<" nil t)
8070 (push (list (incf generation)
8071 child (setq child (buffer-substring (point) end))
8074 (push (list (1+ generation) child nil subject) relations)
8076 (kill-buffer (current-buffer)))
8077 ;; Sort over trustworthiness.
8078 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8079 (while (setq relation (pop relations))
8080 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8081 (unless (car (symbol-value cthread))
8082 ;; Make this article the parent of these threads.
8083 (setcar (symbol-value cthread)
8084 (vector gnus-reffed-article-number
8088 (or (caddr relation) "") 0 0 "")))
8089 (set cthread (list (vector gnus-reffed-article-number
8091 "" "" (cadr relation)
8092 (or (caddr relation) "") 0 0 ""))))
8093 (push gnus-reffed-article-number gnus-newsgroup-limit)
8094 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8095 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8096 gnus-newsgroup-reads)
8097 (decf gnus-reffed-article-number)
8098 ;; Make this new thread the child of its parent.
8099 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8100 (setcdr (symbol-value pthread)
8101 (nconc (cdr (symbol-value pthread))
8102 (list (symbol-value cthread))))
8103 (set pthread (list nil (symbol-value cthread))))))
8104 (gnus-message 7 "Making sparse threads...done")))
8106 (defun gnus-build-old-threads ()
8107 ;; Look at all the articles that refer back to old articles, and
8108 ;; fetch the headers for the articles that aren't there. This will
8109 ;; build complete threads - if the roots haven't been expired by the
8114 (when (not (car (symbol-value refs)))
8115 (setq heads (cdr (symbol-value refs)))
8117 (if (memq (mail-header-number (caar heads))
8118 gnus-newsgroup-dormant)
8119 (setq heads (cdr heads))
8120 (setq id (symbol-name refs))
8121 (while (and (setq id (gnus-build-get-header id))
8122 (not (car (gnus-gethash
8123 id gnus-newsgroup-dependencies)))))
8124 (setq heads nil)))))
8125 gnus-newsgroup-dependencies)))
8127 (defun gnus-build-get-header (id)
8128 ;; Look through the buffer of NOV lines and find the header to
8129 ;; ID. Enter this line into the dependencies hash table, and return
8130 ;; the id of the parent article (if any).
8131 (let ((deps gnus-newsgroup-dependencies)
8135 (set-buffer nntp-server-buffer)
8136 (goto-char (point-min))
8137 (while (and (not found) (search-forward id nil t))
8139 (setq found (looking-at
8140 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8141 (regexp-quote id))))
8142 (or found (beginning-of-line 2)))
8146 (setq header (gnus-nov-parse-line
8147 (read (current-buffer)) deps))
8148 (gnus-parent-id (mail-header-references header)))))
8150 (let ((number (mail-header-number header)))
8151 (push number gnus-newsgroup-limit)
8152 (push header gnus-newsgroup-headers)
8153 (if (memq number gnus-newsgroup-unselected)
8155 (push number gnus-newsgroup-unreads)
8156 (setq gnus-newsgroup-unselected
8157 (delq number gnus-newsgroup-unselected)))
8158 (push number gnus-newsgroup-ancient)))))))
8160 (defun gnus-summary-update-article (article &optional iheader)
8161 "Update ARTICLE in the summary buffer."
8162 (set-buffer gnus-summary-buffer)
8163 (let* ((header (or iheader (gnus-summary-article-header article)))
8164 (id (mail-header-id header))
8165 (data (gnus-data-find article))
8166 (thread (gnus-id-to-thread id))
8167 (references (mail-header-references header))
8172 (not (equal "" references)))
8175 (buffer-read-only nil)
8177 (number (mail-header-number header))
8180 ;; !!! Should this be in or not?
8182 (setcar thread nil))
8184 (delq thread parent))
8185 (if (gnus-summary-insert-subject id header iheader)
8186 ;; Set the (possibly) new article number in the data structure.
8187 (gnus-data-set-number data (gnus-id-to-article id))
8191 (defun gnus-rebuild-thread (id)
8192 "Rebuild the thread containing ID."
8193 (let ((buffer-read-only nil)
8194 current thread data)
8195 (if (not gnus-show-threads)
8196 (setq thread (list (car (gnus-id-to-thread id))))
8197 ;; Get the thread this article is part of.
8198 (setq thread (gnus-remove-thread id)))
8199 (setq current (save-excursion
8200 (and (zerop (forward-line -1))
8201 (gnus-summary-article-number))))
8202 ;; If this is a gathered thread, we have to go some re-gathering.
8203 (when (stringp (car thread))
8204 (let ((subject (car thread))
8206 (setq thread (cdr thread))
8208 (unless (memq (setq thr (gnus-id-to-thread
8210 (mail-header-id (caar thread)))))
8213 (setq thread (cdr thread)))
8214 ;; We now have all (unique) roots.
8215 (if (= (length roots) 1)
8216 ;; All the loose roots are now one solid root.
8217 (setq thread (car roots))
8218 (setq thread (cons subject (gnus-sort-threads roots))))))
8220 ;; We then insert this thread into the summary buffer.
8221 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8222 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8223 (setq data (nreverse gnus-newsgroup-data))
8224 (setq threads gnus-newsgroup-threads))
8225 ;; We splice the new data into the data structure.
8226 (gnus-data-enter-list current data)
8227 (gnus-data-compute-positions)
8228 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8230 (defun gnus-number-to-header (number)
8231 "Return the header for article NUMBER."
8232 (let ((headers gnus-newsgroup-headers))
8234 (not (= number (mail-header-number (car headers)))))
8239 (defun gnus-id-to-thread (id)
8240 "Return the (sub-)thread where ID appears."
8241 (gnus-gethash id gnus-newsgroup-dependencies))
8243 (defun gnus-id-to-article (id)
8244 "Return the article number of ID."
8245 (let ((thread (gnus-id-to-thread id)))
8248 (mail-header-number (car thread)))))
8250 (defun gnus-id-to-header (id)
8251 "Return the article headers of ID."
8252 (car (gnus-id-to-thread id)))
8254 (defun gnus-article-displayed-root-p (article)
8255 "Say whether ARTICLE is a root(ish) article."
8256 (let ((level (gnus-summary-thread-level article))
8257 (refs (mail-header-references (gnus-summary-article-header article)))
8263 ((null (gnus-parent-id refs)) t)
8265 (null (setq particle (gnus-id-to-article
8266 (gnus-parent-id refs))))
8267 (null (gnus-summary-thread-level particle)))))))
8269 (defun gnus-root-id (id)
8270 "Return the id of the root of the thread where ID appears."
8272 (while (and id (setq prev (car (gnus-gethash
8273 id gnus-newsgroup-dependencies))))
8275 id (gnus-parent-id (mail-header-references prev))))
8278 (defun gnus-remove-thread (id &optional dont-remove)
8279 "Remove the thread that has ID in it."
8280 (let ((dep gnus-newsgroup-dependencies)
8281 headers thread last-id)
8282 ;; First go up in this thread until we find the root.
8283 (setq last-id (gnus-root-id id))
8284 (setq headers (list (car (gnus-id-to-thread last-id))
8285 (caadr (gnus-id-to-thread last-id))))
8286 ;; We have now found the real root of this thread. It might have
8287 ;; been gathered into some loose thread, so we have to search
8288 ;; through the threads to find the thread we wanted.
8289 (let ((threads gnus-newsgroup-threads)
8292 (setq sub (car threads))
8293 (if (stringp (car sub))
8294 ;; This is a gathered threads, so we look at the roots
8295 ;; below it to find whether this article in in this
8298 (setq sub (cdr sub))
8300 (when (member (caar sub) headers)
8301 (setq thread (car threads)
8304 (setq sub (cdr sub))))
8305 ;; It's an ordinary thread, so we check it.
8306 (when (eq (car sub) (car headers))
8309 (setq threads (cdr threads)))
8310 ;; If this article is in no thread, then it's a root.
8313 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8314 (setq thread (gnus-gethash last-id dep)))
8317 thread ; We return this thread.
8319 (if (stringp (car thread))
8321 ;; If we use dummy roots, then we have to remove the
8322 ;; dummy root as well.
8323 (when (eq gnus-summary-make-false-root 'dummy)
8326 (setq thread (cdr thread))
8328 (gnus-remove-thread-1 (car thread))
8329 (setq thread (cdr thread))))
8330 (gnus-remove-thread-1 thread))))))))
8332 (defun gnus-remove-thread-1 (thread)
8333 "Remove the thread THREAD recursively."
8334 (let ((number (mail-header-number (car thread)))
8336 (when (setq pos (text-property-any
8337 (point-min) (point-max) 'gnus-number number))
8340 (gnus-data-remove number))
8341 (setq thread (cdr thread))
8343 (gnus-remove-thread-1 (pop thread)))))
8345 (defun gnus-sort-threads (threads)
8347 (if (not gnus-thread-sort-functions)
8349 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8350 (car gnus-thread-sort-functions)
8352 ,(gnus-make-sort-function
8353 (reverse gnus-thread-sort-functions))))))
8354 (gnus-message 7 "Sorting threads...")
8357 (gnus-message 7 "Sorting threads...done")))))
8359 (defun gnus-sort-articles (articles)
8361 (when gnus-article-sort-functions
8362 (let ((func (if (= 1 (length gnus-article-sort-functions))
8363 (car gnus-article-sort-functions)
8365 ,(gnus-make-sort-function
8366 (reverse gnus-article-sort-functions))))))
8367 (gnus-message 7 "Sorting articles...")
8369 (setq gnus-newsgroup-headers (sort articles func))
8370 (gnus-message 7 "Sorting articles...done")))))
8372 (defun gnus-make-sort-function (funs)
8373 "Return a composite sort condition based on the functions in FUNC."
8375 `(or (,(car funs) t1 t2)
8376 (and (not (,(car funs) t2 t1))
8377 ,(gnus-make-sort-function (cdr funs))))
8378 `(,(car funs) t1 t2)))
8380 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8381 (defmacro gnus-thread-header (thread)
8382 ;; Return header of first article in THREAD.
8383 ;; Note that THREAD must never, ever be anything else than a variable -
8384 ;; using some other form will lead to serious barfage.
8385 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8386 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8387 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8390 (defsubst gnus-article-sort-by-number (h1 h2)
8391 "Sort articles by article number."
8392 (< (mail-header-number h1)
8393 (mail-header-number h2)))
8395 (defun gnus-thread-sort-by-number (h1 h2)
8396 "Sort threads by root article number."
8397 (gnus-article-sort-by-number
8398 (gnus-thread-header h1) (gnus-thread-header h2)))
8400 (defsubst gnus-article-sort-by-author (h1 h2)
8401 "Sort articles by root author."
8403 (let ((extract (funcall
8404 gnus-extract-address-components
8405 (mail-header-from h1))))
8406 (or (car extract) (cdr extract)))
8407 (let ((extract (funcall
8408 gnus-extract-address-components
8409 (mail-header-from h2))))
8410 (or (car extract) (cdr extract)))))
8412 (defun gnus-thread-sort-by-author (h1 h2)
8413 "Sort threads by root author."
8414 (gnus-article-sort-by-author
8415 (gnus-thread-header h1) (gnus-thread-header h2)))
8417 (defsubst gnus-article-sort-by-subject (h1 h2)
8418 "Sort articles by root subject."
8420 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8421 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8423 (defun gnus-thread-sort-by-subject (h1 h2)
8424 "Sort threads by root subject."
8425 (gnus-article-sort-by-subject
8426 (gnus-thread-header h1) (gnus-thread-header h2)))
8428 (defsubst gnus-article-sort-by-date (h1 h2)
8429 "Sort articles by root article date."
8431 (inline (gnus-sortable-date (mail-header-date h1)))
8432 (inline (gnus-sortable-date (mail-header-date h2)))))
8434 (defun gnus-thread-sort-by-date (h1 h2)
8435 "Sort threads by root article date."
8436 (gnus-article-sort-by-date
8437 (gnus-thread-header h1) (gnus-thread-header h2)))
8439 (defsubst gnus-article-sort-by-score (h1 h2)
8440 "Sort articles by root article score.
8441 Unscored articles will be counted as having a score of zero."
8442 (> (or (cdr (assq (mail-header-number h1)
8443 gnus-newsgroup-scored))
8444 gnus-summary-default-score 0)
8445 (or (cdr (assq (mail-header-number h2)
8446 gnus-newsgroup-scored))
8447 gnus-summary-default-score 0)))
8449 (defun gnus-thread-sort-by-score (h1 h2)
8450 "Sort threads by root article score."
8451 (gnus-article-sort-by-score
8452 (gnus-thread-header h1) (gnus-thread-header h2)))
8454 (defun gnus-thread-sort-by-total-score (h1 h2)
8455 "Sort threads by the sum of all scores in the thread.
8456 Unscored articles will be counted as having a score of zero."
8457 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8459 (defun gnus-thread-total-score (thread)
8460 ;; This function find the total score of THREAD.
8461 (cond ((null thread)
8464 (if (stringp (car thread))
8465 (apply gnus-thread-score-function 0
8466 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8467 (gnus-thread-total-score-1 thread)))
8469 (gnus-thread-total-score-1 (list thread)))))
8471 (defun gnus-thread-total-score-1 (root)
8472 ;; This function find the total score of the thread below ROOT.
8473 (setq root (car root))
8474 (apply gnus-thread-score-function
8476 (mapcar 'gnus-thread-total-score
8477 (cdr (gnus-gethash (mail-header-id root)
8478 gnus-newsgroup-dependencies)))
8479 (if (> (mail-header-number root) 0)
8480 (list (or (cdr (assq (mail-header-number root)
8481 gnus-newsgroup-scored))
8482 gnus-summary-default-score 0))))
8483 (list gnus-summary-default-score)
8486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8487 (defvar gnus-tmp-prev-subject nil)
8488 (defvar gnus-tmp-false-parent nil)
8489 (defvar gnus-tmp-root-expunged nil)
8490 (defvar gnus-tmp-dummy-line nil)
8492 (defun gnus-summary-prepare-threads (threads)
8493 "Prepare summary buffer from THREADS and indentation LEVEL.
8494 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8495 or a straight list of headers."
8496 (gnus-message 7 "Generating summary...")
8498 (setq gnus-newsgroup-threads threads)
8501 (let ((gnus-tmp-level 0)
8502 (default-score (or gnus-summary-default-score 0))
8503 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8504 thread number subject stack state gnus-tmp-gathered beg-match
8505 new-roots gnus-tmp-new-adopts thread-end
8506 gnus-tmp-header gnus-tmp-unread
8507 gnus-tmp-replied gnus-tmp-subject-or-nil
8508 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8509 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8510 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8512 (setq gnus-tmp-prev-subject nil)
8514 (if (vectorp (car threads))
8515 ;; If this is a straight (sic) list of headers, then a
8516 ;; threaded summary display isn't required, so we just create
8517 ;; an unthreaded one.
8518 (gnus-summary-prepare-unthreaded threads)
8520 ;; Do the threaded display.
8522 (while (or threads stack gnus-tmp-new-adopts new-roots)
8524 (if (and (= gnus-tmp-level 0)
8525 (not (setq gnus-tmp-dummy-line nil))
8528 (not gnus-tmp-false-parent)
8529 (or gnus-tmp-new-adopts new-roots))
8530 (if gnus-tmp-new-adopts
8531 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8532 thread (list (car gnus-tmp-new-adopts))
8533 gnus-tmp-header (caar thread)
8534 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8536 (setq thread (list (car new-roots))
8537 gnus-tmp-header (caar thread)
8538 new-roots (cdr new-roots))))
8541 ;; If there are some threads, we do them before the
8542 ;; threads on the stack.
8543 (setq thread threads
8544 gnus-tmp-header (caar thread))
8545 ;; There were no current threads, so we pop something off
8547 (setq state (car stack)
8548 gnus-tmp-level (car state)
8551 gnus-tmp-header (caar thread))))
8553 (setq gnus-tmp-false-parent nil)
8554 (setq gnus-tmp-root-expunged nil)
8555 (setq thread-end nil)
8557 (if (stringp gnus-tmp-header)
8558 ;; The header is a dummy root.
8560 ((eq gnus-summary-make-false-root 'adopt)
8561 ;; We let the first article adopt the rest.
8562 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8564 (setq gnus-tmp-gathered
8566 (lambda (h) (mail-header-number (car h)))
8569 (setq thread (cons (list (caar thread)
8572 (setq gnus-tmp-level -1
8573 gnus-tmp-false-parent t))
8574 ((eq gnus-summary-make-false-root 'empty)
8575 ;; We print adopted articles with empty subject fields.
8576 (setq gnus-tmp-gathered
8578 (lambda (h) (mail-header-number (car h)))
8581 (setq gnus-tmp-level -1))
8582 ((eq gnus-summary-make-false-root 'dummy)
8583 ;; We remember that we probably want to output a dummy
8585 (setq gnus-tmp-dummy-line gnus-tmp-header)
8586 (setq gnus-tmp-prev-subject gnus-tmp-header))
8588 ;; We do not make a root for the gathered
8589 ;; sub-threads at all.
8590 (setq gnus-tmp-level -1)))
8592 (setq number (mail-header-number gnus-tmp-header)
8593 subject (mail-header-subject gnus-tmp-header))
8596 ;; If the thread has changed subject, we might want to make
8597 ;; this subthread into a root.
8598 ((and (null gnus-thread-ignore-subject)
8599 (not (zerop gnus-tmp-level))
8600 gnus-tmp-prev-subject
8602 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8603 (setq new-roots (nconc new-roots (list (car thread)))
8605 gnus-tmp-header nil))
8606 ;; If the article lies outside the current limit,
8607 ;; then we do not display it.
8608 ((and (not (memq number gnus-newsgroup-limit))
8609 (not gnus-tmp-dummy-line))
8610 (setq gnus-tmp-gathered
8612 (lambda (h) (mail-header-number (car h)))
8615 (setq gnus-tmp-new-adopts (if (cdar thread)
8616 (append gnus-tmp-new-adopts
8618 gnus-tmp-new-adopts)
8620 gnus-tmp-header nil)
8621 (when (zerop gnus-tmp-level)
8622 (setq gnus-tmp-root-expunged t)))
8623 ;; Perhaps this article is to be marked as read?
8624 ((and gnus-summary-mark-below
8625 (< (or (cdr (assq number gnus-newsgroup-scored))
8627 gnus-summary-mark-below)
8628 ;; Don't touch sparse articles.
8629 (not (memq number gnus-newsgroup-sparse))
8630 (not (memq number gnus-newsgroup-ancient)))
8631 (setq gnus-newsgroup-unreads
8632 (delq number gnus-newsgroup-unreads))
8633 (if gnus-newsgroup-auto-expire
8634 (push number gnus-newsgroup-expirable)
8635 (push (cons number gnus-low-score-mark)
8636 gnus-newsgroup-reads))))
8638 (when gnus-tmp-header
8639 ;; We may have an old dummy line to output before this
8641 (when gnus-tmp-dummy-line
8642 (gnus-summary-insert-dummy-line
8643 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8644 (setq gnus-tmp-dummy-line nil))
8646 ;; Compute the mark.
8650 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8651 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8652 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8653 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8654 (t (or (cdr (assq number gnus-newsgroup-reads))
8655 gnus-ancient-mark))))
8657 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8658 gnus-tmp-header gnus-tmp-level)
8659 gnus-newsgroup-data)
8661 ;; Actually insert the line.
8663 gnus-tmp-subject-or-nil
8665 ((and gnus-thread-ignore-subject
8666 gnus-tmp-prev-subject
8667 (not (inline (gnus-subject-equal
8668 gnus-tmp-prev-subject subject))))
8670 ((zerop gnus-tmp-level)
8671 (if (and (eq gnus-summary-make-false-root 'empty)
8672 (memq number gnus-tmp-gathered)
8673 gnus-tmp-prev-subject
8674 (inline (gnus-subject-equal
8675 gnus-tmp-prev-subject subject)))
8676 gnus-summary-same-subject
8678 (t gnus-summary-same-subject)))
8679 (if (and (eq gnus-summary-make-false-root 'adopt)
8680 (= gnus-tmp-level 1)
8681 (memq number gnus-tmp-gathered))
8682 (setq gnus-tmp-opening-bracket ?\<
8683 gnus-tmp-closing-bracket ?\>)
8684 (setq gnus-tmp-opening-bracket ?\[
8685 gnus-tmp-closing-bracket ?\]))
8687 gnus-tmp-indentation
8688 (aref gnus-thread-indent-array gnus-tmp-level)
8689 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8690 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8691 gnus-summary-default-score 0)
8693 (if (or (null gnus-summary-default-score)
8694 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8695 gnus-summary-zcore-fuzz)) ?
8696 (if (< gnus-tmp-score gnus-summary-default-score)
8697 gnus-score-below-mark gnus-score-over-mark))
8699 (cond ((memq number gnus-newsgroup-processable)
8701 ((memq number gnus-newsgroup-cached)
8703 ((memq number gnus-newsgroup-replied)
8705 ((memq number gnus-newsgroup-saved)
8707 (t gnus-unread-mark))
8708 gnus-tmp-from (mail-header-from gnus-tmp-header)
8711 ((string-match "(.+)" gnus-tmp-from)
8712 (substring gnus-tmp-from
8713 (1+ (match-beginning 0)) (1- (match-end 0))))
8714 ((string-match "<[^>]+> *$" gnus-tmp-from)
8715 (setq beg-match (match-beginning 0))
8716 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8717 (substring gnus-tmp-from (1+ (match-beginning 0))
8718 (1- (match-end 0))))
8719 (substring gnus-tmp-from 0 beg-match)))
8721 (when (string= gnus-tmp-name "")
8722 (setq gnus-tmp-name gnus-tmp-from))
8723 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8724 (gnus-put-text-property
8726 (progn (eval gnus-summary-line-format-spec) (point))
8727 'gnus-number number)
8730 (run-hooks 'gnus-summary-update-hook)
8733 (setq gnus-tmp-prev-subject subject)))
8735 (when (nth 1 thread)
8736 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8737 (incf gnus-tmp-level)
8738 (setq threads (if thread-end nil (cdar thread)))
8740 (setq gnus-tmp-level 0)))))
8741 (gnus-message 7 "Generating summary...done"))
8743 (defun gnus-summary-prepare-unthreaded (headers)
8744 "Generate an unthreaded summary buffer based on HEADERS."
8745 (let (header number mark)
8748 ;; We may have to root out some bad articles...
8749 (when (memq (setq number (mail-header-number
8750 (setq header (pop headers))))
8751 gnus-newsgroup-limit)
8752 ;; Mark article as read when it has a low score.
8753 (when (and gnus-summary-mark-below
8754 (< (or (cdr (assq number gnus-newsgroup-scored))
8755 gnus-summary-default-score 0)
8756 gnus-summary-mark-below)
8757 (not (memq number gnus-newsgroup-ancient)))
8758 (setq gnus-newsgroup-unreads
8759 (delq number gnus-newsgroup-unreads))
8760 (if gnus-newsgroup-auto-expire
8761 (push number gnus-newsgroup-expirable)
8762 (push (cons number gnus-low-score-mark)
8763 gnus-newsgroup-reads)))
8767 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8768 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8769 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8770 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8771 (t (or (cdr (assq number gnus-newsgroup-reads))
8772 gnus-ancient-mark))))
8773 (setq gnus-newsgroup-data
8774 (cons (gnus-data-make number mark (1+ (point)) header 0)
8775 gnus-newsgroup-data))
8776 (gnus-summary-insert-line
8777 header 0 nil mark (memq number gnus-newsgroup-replied)
8778 (memq number gnus-newsgroup-expirable)
8779 (mail-header-subject header) nil
8780 (cdr (assq number gnus-newsgroup-scored))
8781 (memq number gnus-newsgroup-processable))))))
8783 (defun gnus-select-newsgroup (group &optional read-all)
8784 "Select newsgroup GROUP.
8785 If READ-ALL is non-nil, all articles in the group are selected."
8786 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8787 (info (nth 2 entry))
8788 articles fetched-articles cached)
8790 (or (gnus-check-server
8791 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8792 (error "Couldn't open server"))
8794 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8795 (gnus-activate-group group) ; Or we can activate it...
8796 (progn ; Or we bug out.
8797 (when (equal major-mode 'gnus-summary-mode)
8798 (kill-buffer (current-buffer)))
8799 (error "Couldn't request group %s: %s"
8800 group (gnus-status-message group))))
8802 (unless (gnus-request-group group t)
8803 (when (equal major-mode 'gnus-summary-mode)
8804 (kill-buffer (current-buffer)))
8805 (error "Couldn't request group %s: %s"
8806 group (gnus-status-message group)))
8808 (setq gnus-newsgroup-name group)
8809 (setq gnus-newsgroup-unselected nil)
8810 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8812 (and gnus-asynchronous
8813 (gnus-check-backend-function
8814 'request-asynchronous gnus-newsgroup-name)
8815 (setq gnus-newsgroup-async
8816 (gnus-request-asynchronous gnus-newsgroup-name)))
8818 ;; Adjust and set lists of article marks.
8820 (gnus-adjust-marked-articles info))
8822 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8823 (when (gnus-virtual-group-p group)
8824 (setq cached gnus-newsgroup-cached))
8826 (setq gnus-newsgroup-unreads
8827 (gnus-set-difference
8828 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8829 gnus-newsgroup-dormant))
8831 (setq gnus-newsgroup-processable nil)
8833 (setq articles (gnus-articles-to-read group read-all))
8837 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8839 ((eq articles 0) nil)
8841 ;; Init the dependencies hash table.
8842 (setq gnus-newsgroup-dependencies
8843 (gnus-make-hashtable (length articles)))
8844 ;; Retrieve the headers and read them in.
8845 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8846 (setq gnus-newsgroup-headers
8848 (setq gnus-headers-retrieved-by
8849 (gnus-retrieve-headers
8850 articles gnus-newsgroup-name
8851 ;; We might want to fetch old headers, but
8852 ;; not if there is only 1 article.
8853 (and gnus-fetch-old-headers
8855 (not (eq gnus-fetch-old-headers 'some))
8856 (not (numberp gnus-fetch-old-headers)))
8857 (> (length articles) 1))))))
8858 (gnus-get-newsgroup-headers-xover articles)
8859 (gnus-get-newsgroup-headers)))
8860 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8862 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8864 (setq gnus-newsgroup-cached cached))
8866 ;; Set the initial limit.
8867 (setq gnus-newsgroup-limit (copy-sequence articles))
8868 ;; Remove canceled articles from the list of unread articles.
8869 (setq gnus-newsgroup-unreads
8870 (gnus-set-sorted-intersection
8871 gnus-newsgroup-unreads
8872 (setq fetched-articles
8873 (mapcar (lambda (headers) (mail-header-number headers))
8874 gnus-newsgroup-headers))))
8875 ;; Removed marked articles that do not exist.
8876 (gnus-update-missing-marks
8877 (gnus-sorted-complement fetched-articles articles))
8878 ;; We might want to build some more threads first.
8879 (and gnus-fetch-old-headers
8880 (eq gnus-headers-retrieved-by 'nov)
8881 (gnus-build-old-threads))
8882 ;; Check whether auto-expire is to be done in this group.
8883 (setq gnus-newsgroup-auto-expire
8884 (gnus-group-auto-expirable-p group))
8885 ;; Set up the article buffer now, if necessary.
8886 (unless gnus-single-article-buffer
8887 (gnus-article-setup-buffer))
8888 ;; First and last article in this newsgroup.
8889 (when gnus-newsgroup-headers
8890 (setq gnus-newsgroup-begin
8891 (mail-header-number (car gnus-newsgroup-headers))
8894 (gnus-last-element gnus-newsgroup-headers))))
8895 (setq gnus-reffed-article-number -1)
8896 ;; GROUP is successfully selected.
8897 (or gnus-newsgroup-headers t)))))
8899 (defun gnus-articles-to-read (group read-all)
8900 ;; Find out what articles the user wants to read.
8902 ;; Select all articles if `read-all' is non-nil, or if there
8903 ;; are no unread articles.
8905 (and (zerop (length gnus-newsgroup-marked))
8906 (zerop (length gnus-newsgroup-unreads))))
8907 (gnus-uncompress-range (gnus-active group))
8908 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8909 (copy-sequence gnus-newsgroup-unreads))
8911 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8912 (scored (length scored-list))
8913 (number (length articles))
8914 (marked (+ (length gnus-newsgroup-marked)
8915 (length gnus-newsgroup-dormant)))
8923 ((and (or (<= scored marked) (= scored number))
8924 (numberp gnus-large-newsgroup)
8925 (> number gnus-large-newsgroup))
8929 "How many articles from %s (default %d): "
8930 gnus-newsgroup-name number))))
8931 (if (string-match "^[ \t]*$" input) number input)))
8932 ((and (> scored marked) (< scored number)
8933 (> (- scored number) 20))
8936 (format "%s %s (%d scored, %d total): "
8937 "How many articles from"
8938 group scored number))))
8939 (if (string-match "^[ \t]*$" input)
8943 (setq select (if (stringp select) (string-to-number select) select))
8944 (if (or (null select) (zerop select))
8946 (if (and (not (zerop scored)) (<= (abs select) scored))
8948 (setq articles (sort scored-list '<))
8949 (setq number (length articles)))
8950 (setq articles (copy-sequence articles)))
8952 (if (< (abs select) number)
8954 ;; Select the N oldest articles.
8955 (setcdr (nthcdr (1- (abs select)) articles) nil)
8956 ;; Select the N most recent articles.
8957 (setq articles (nthcdr (- number select) articles))))
8958 (setq gnus-newsgroup-unselected
8959 (gnus-sorted-intersection
8960 gnus-newsgroup-unreads
8961 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8964 (defun gnus-killed-articles (killed articles)
8967 (if (inline (gnus-member-of-range (car articles) killed))
8968 (setq out (cons (car articles) out)))
8969 (setq articles (cdr articles)))
8972 (defun gnus-uncompress-marks (marks)
8973 "Uncompress the mark ranges in MARKS."
8974 (let ((uncompressed '(score bookmark))
8977 (if (memq (caar marks) uncompressed)
8978 (push (car marks) out)
8979 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8980 (setq marks (cdr marks)))
8983 (defun gnus-adjust-marked-articles (info)
8984 "Set all article lists and remove all marks that are no longer legal."
8985 (let* ((marked-lists (gnus-info-marks info))
8986 (active (gnus-active (gnus-info-group info)))
8989 (types gnus-article-mark-lists)
8990 (uncompressed '(score bookmark killed))
8991 marks var articles article mark)
8994 (setq marks (pop marked-lists))
8995 (set (setq var (intern (format "gnus-newsgroup-%s"
8996 (car (rassq (setq mark (car marks))
8998 (if (memq (car marks) uncompressed) (cdr marks)
8999 (gnus-uncompress-range (cdr marks))))
9001 (setq articles (symbol-value var))
9003 ;; All articles have to be subsets of the active articles.
9005 ;; Adjust "simple" lists.
9006 ((memq mark '(tick dormant expirable reply save))
9008 (when (or (< (setq article (pop articles)) min) (> article max))
9009 (set var (delq article (symbol-value var))))))
9011 ((memq mark uncompressed)
9013 (when (or (not (consp (setq article (pop articles))))
9014 (< (car article) min)
9015 (> (car article) max))
9016 (set var (delq article (symbol-value var))))))))))
9018 (defun gnus-update-missing-marks (missing)
9019 "Go through the list of MISSING articles and remove them mark lists."
9021 (let ((types gnus-article-mark-lists)
9023 ;; Go through all types.
9025 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9026 (when (symbol-value var)
9027 ;; This list has articles. So we delete all missing articles
9031 (set var (delq (pop m) (symbol-value var)))))))))
9033 (defun gnus-update-marks ()
9034 "Enter the various lists of marked articles into the newsgroup info list."
9035 (let ((types gnus-article-mark-lists)
9036 (info (gnus-get-info gnus-newsgroup-name))
9037 (uncompressed '(score bookmark killed))
9038 type list newmarked symbol)
9040 ;; Add all marks lists that are non-nil to the list of marks lists.
9042 (setq type (pop types))
9043 (when (setq list (symbol-value
9045 (intern (format "gnus-newsgroup-%s"
9047 (push (cons (cdr type)
9048 (if (memq (cdr type) uncompressed) list
9049 (gnus-compress-sequence
9050 (set symbol (sort list '<)) t)))
9053 ;; Enter these new marks into the info of the group.
9055 (setcar (nthcdr 3 info) newmarked)
9056 ;; Add the marks lists to the end of the info.
9058 (setcdr (nthcdr 2 info) (list newmarked))))
9060 ;; Cut off the end of the info if there's nothing else there.
9064 (when (nthcdr (decf i) info)
9065 (setcdr (nthcdr i info) nil)))))))
9067 (defun gnus-add-marked-articles (group type articles &optional info force)
9068 ;; Add ARTICLES of TYPE to the info of GROUP.
9069 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9070 ;; add, but replace marked articles of TYPE with ARTICLES.
9071 (let ((info (or info (gnus-get-info group)))
9072 (uncompressed '(score bookmark killed))
9075 (and (not (setq marked (nthcdr 3 info)))
9077 (setcdr (nthcdr 2 info)
9078 (list (list (cons type (gnus-compress-sequence
9080 (and (not (setq m (assq type (car marked))))
9083 (cons (cons type (gnus-compress-sequence articles t) )
9087 (setcar (nthcdr 3 info)
9088 (delq (assq type (car marked)) (car marked)))
9089 (setcdr m (gnus-compress-sequence articles t)))
9090 (setcdr m (gnus-compress-sequence
9091 (sort (nconc (gnus-uncompress-range (cdr m))
9092 (copy-sequence articles)) '<) t))))))
9094 (defun gnus-set-mode-line (where)
9095 "This function sets the mode line of the article or summary buffers.
9096 If WHERE is `summary', the summary mode line format will be used."
9097 ;; Is this mode line one we keep updated?
9098 (when (memq where gnus-updated-mode-lines)
9101 ;; We evaluate this in the summary buffer since these
9102 ;; variables are buffer-local to that buffer.
9103 (set-buffer gnus-summary-buffer)
9104 ;; We bind all these variables that are used in the `eval' form
9106 (let* ((mformat (symbol-value
9108 (format "gnus-%s-mode-line-format-spec" where))))
9109 (gnus-tmp-group-name gnus-newsgroup-name)
9110 (gnus-tmp-article-number (or gnus-current-article 0))
9111 (gnus-tmp-unread gnus-newsgroup-unreads)
9112 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9113 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9114 (gnus-tmp-unread-and-unselected
9115 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9116 (zerop gnus-tmp-unselected)) "")
9117 ((zerop gnus-tmp-unselected)
9118 (format "{%d more}" gnus-tmp-unread-and-unticked))
9119 (t (format "{%d(+%d) more}"
9120 gnus-tmp-unread-and-unticked
9121 gnus-tmp-unselected))))
9123 (if (and gnus-current-headers
9124 (vectorp gnus-current-headers))
9125 (gnus-mode-string-quote
9126 (mail-header-subject gnus-current-headers)) ""))
9128 gnus-tmp-header);; passed as argument to any user-format-funcs
9129 (setq mode-string (eval mformat))
9130 (setq max-len (max 4 (if gnus-mode-non-string-length
9132 gnus-mode-non-string-length)
9133 (length mode-string))))
9134 ;; We might have to chop a bit of the string off...
9135 (when (> (length mode-string) max-len)
9137 (concat (gnus-truncate-string mode-string (- max-len 3))
9139 ;; Pad the mode string a bit.
9140 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9141 ;; Update the mode line.
9142 (setq mode-line-buffer-identification
9143 (gnus-mode-line-buffer-identification
9144 (list mode-string)))
9145 (set-buffer-modified-p t))))
9147 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9148 "Go through the HEADERS list and add all Xrefs to a hash table.
9149 The resulting hash table is returned, or nil if no Xrefs were found."
9150 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9151 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9152 (xref-hashtb (make-vector 63 0))
9153 start group entry number xrefs header)
9155 (setq header (pop headers))
9156 (when (and (setq xrefs (mail-header-xref header))
9157 (not (memq (setq number (mail-header-number header))
9160 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9161 (setq start (match-end 0))
9162 (setq group (if prefix
9163 (concat prefix (substring xrefs (match-beginning 1)
9165 (substring xrefs (match-beginning 1) (match-end 1))))
9167 (string-to-int (substring xrefs (match-beginning 2)
9169 (if (setq entry (gnus-gethash group xref-hashtb))
9170 (setcdr entry (cons number (cdr entry)))
9171 (gnus-sethash group (cons number nil) xref-hashtb)))))
9172 (and start xref-hashtb)))
9174 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9175 "Look through all the headers and mark the Xrefs as read."
9176 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9177 name entry info xref-hashtb idlist method nth4)
9179 (set-buffer gnus-group-buffer)
9180 (when (setq xref-hashtb
9181 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9184 (unless (string= from-newsgroup (setq name (symbol-name group)))
9185 (setq idlist (symbol-value group))
9186 ;; Dead groups are not updated.
9188 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9190 (if (stringp (setq nth4 (gnus-info-method info)))
9191 (setq nth4 (gnus-server-to-method nth4))))
9192 ;; Only do the xrefs if the group has the same
9193 ;; select method as the group we have just read.
9194 (or (gnus-methods-equal-p
9195 nth4 (gnus-find-method-for-group from-newsgroup))
9197 (equal nth4 (setq method (gnus-find-method-for-group
9199 (and (equal (car nth4) (car method))
9200 (equal (nth 1 nth4) (nth 1 method))))
9201 gnus-use-cross-reference
9202 (or (not (eq gnus-use-cross-reference t))
9204 ;; Only do cross-references on subscribed
9205 ;; groups, if that is what is wanted.
9206 (<= (gnus-info-level info) gnus-level-subscribed))
9207 (gnus-group-make-articles-read name idlist))))
9210 (defun gnus-group-make-articles-read (group articles)
9212 (entry (gnus-gethash group gnus-newsrc-hashtb))
9213 (info (nth 2 entry))
9214 (active (gnus-active group))
9216 ;; First peel off all illegal article numbers.
9218 (let ((ids articles)
9222 (if (and first (> id (cdr active)))
9224 ;; We'll end up in this situation in one particular
9225 ;; obscure situation. If you re-scan a group and get
9226 ;; a new article that is cross-posted to a different
9227 ;; group that has not been re-scanned, you might get
9228 ;; crossposted article that has a higher number than
9229 ;; Gnus believes possible. So we re-activate this
9230 ;; group as well. This might mean doing the
9231 ;; crossposting thingy will *increase* the number
9232 ;; of articles in some groups. Tsk, tsk.
9233 (setq active (or (gnus-activate-group group) active))))
9234 (if (or (> id (cdr active))
9235 (< id (car active)))
9236 (setq articles (delq id articles)))
9237 (setq ids (cdr ids)))))
9238 ;; If the read list is nil, we init it.
9240 (null (gnus-info-read info))
9242 (gnus-info-set-read info (cons 1 (1- (car active)))))
9243 ;; Then we add the read articles to the range.
9248 (gnus-info-read info) (setq articles (sort articles '<)))))
9249 ;; Then we have to re-compute how many unread
9250 ;; articles there are in this group.
9255 (setq num (- (1+ (cdr active)) (car active))))
9256 ((not (listp (cdr range)))
9257 (setq num (- (cdr active) (- (1+ (cdr range))
9261 (if (numberp (car range))
9263 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9264 (setq range (cdr range)))
9265 (setq num (- (cdr active) num))))
9266 ;; Update the number of unread articles.
9268 ;; Update the group buffer.
9269 (gnus-group-update-group group t)))))
9271 (defun gnus-methods-equal-p (m1 m2)
9272 (let ((m1 (or m1 gnus-select-method))
9273 (m2 (or m2 gnus-select-method)))
9275 (and (eq (car m1) (car m2))
9276 (or (not (memq 'address (assoc (symbol-name (car m1))
9277 gnus-valid-select-methods)))
9278 (equal (nth 1 m1) (nth 1 m2)))))))
9280 (defsubst gnus-header-value ()
9281 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9283 (defvar gnus-newsgroup-none-id 0)
9285 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9286 (let ((cur nntp-server-buffer)
9289 (save-excursion (set-buffer gnus-summary-buffer)
9290 gnus-newsgroup-dependencies)))
9291 headers id id-dep ref-dep end ref)
9293 (set-buffer nntp-server-buffer)
9294 (run-hooks 'gnus-parse-headers-hook)
9295 (let ((case-fold-search t)
9296 in-reply-to header p lines)
9297 (goto-char (point-min))
9298 ;; Search to the beginning of the next header. Error messages
9299 ;; do not begin with 2 or 3.
9300 (while (re-search-forward "^[23][0-9]+ " nil t)
9303 ;; This implementation of this function, with nine
9304 ;; search-forwards instead of the one re-search-forward and
9305 ;; a case (which basically was the old function) is actually
9306 ;; about twice as fast, even though it looks messier. You
9307 ;; can't have everything, I guess. Speed and elegance
9308 ;; doesn't always go hand in hand.
9317 (narrow-to-region (point)
9318 (or (and (search-forward "\n.\n" nil t)
9324 (if (search-forward "\nsubject: " nil t)
9325 (gnus-header-value) "(none)"))
9329 (if (search-forward "\nfrom: " nil t)
9330 (gnus-header-value) "(nobody)"))
9334 (if (search-forward "\ndate: " nil t)
9335 (gnus-header-value) ""))
9339 (if (search-forward "\nmessage-id: " nil t)
9340 (setq id (gnus-header-value))
9341 ;; If there was no message-id, we just fake one to make
9342 ;; subsequent routines simpler.
9343 (setq id (concat "none+"
9345 (setq gnus-newsgroup-none-id
9346 (1+ gnus-newsgroup-none-id)))))))
9350 (if (search-forward "\nreferences: " nil t)
9359 (search-backward ">" end t)
9362 (search-backward "<" end t)
9364 ;; Get the references from the in-reply-to header if there
9365 ;; were no references and the in-reply-to header looks
9367 (if (and (search-forward "\nin-reply-to: " nil t)
9368 (setq in-reply-to (gnus-header-value))
9369 (string-match "<[^>]+>" in-reply-to))
9370 (setq ref (substring in-reply-to (match-beginning 0)
9378 (if (search-forward "\nlines: " nil t)
9379 (if (numberp (setq lines (read cur)))
9385 (and (search-forward "\nxref: " nil t)
9386 (gnus-header-value)))))
9387 ;; We do the threading while we read the headers. The
9388 ;; message-id and the last reference are both entered into
9389 ;; the same hash table. Some tippy-toeing around has to be
9390 ;; done in case an article has arrived before the article
9391 ;; which it refers to.
9392 (if (boundp (setq id-dep (intern id dependencies)))
9393 (if (and (car (symbol-value id-dep))
9395 ;; An article with this Message-ID has already
9396 ;; been seen, so we ignore this one, except we add
9397 ;; any additional Xrefs (in case the two articles
9398 ;; came from different servers).
9400 (mail-header-set-xref
9401 (car (symbol-value id-dep))
9402 (concat (or (mail-header-xref
9403 (car (symbol-value id-dep))) "")
9404 (or (mail-header-xref header) "")))
9406 (setcar (symbol-value id-dep) header))
9407 (set id-dep (list header)))
9409 (if (boundp (setq ref-dep (intern ref dependencies)))
9410 (setcdr (symbol-value ref-dep)
9411 (nconc (cdr (symbol-value ref-dep))
9412 (list (symbol-value id-dep))))
9413 (set ref-dep (list nil (symbol-value id-dep))))
9414 (setq headers (cons header headers)))
9415 (goto-char (point-max))
9417 (nreverse headers)))))
9419 ;; The following macros and functions were written by Felix Lee
9420 ;; <flee@cse.psu.edu>.
9422 (defmacro gnus-nov-read-integer ()
9424 (if (= (following-char) ?\t)
9426 (let ((num (condition-case nil (read buffer) (error nil))))
9427 (if (numberp num) num 0)))
9428 (or (eobp) (forward-char 1))))
9430 (defmacro gnus-nov-skip-field ()
9431 '(search-forward "\t" eol 'move))
9433 (defmacro gnus-nov-field ()
9434 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9436 ;; Goes through the xover lines and returns a list of vectors
9437 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9438 force-new dependencies)
9439 "Parse the news overview data in the server buffer, and return a
9440 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9441 ;; Get the Xref when the users reads the articles since most/some
9442 ;; NNTP servers do not include Xrefs when using XOVER.
9443 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9444 (let ((cur nntp-server-buffer)
9445 (dependencies (or dependencies gnus-newsgroup-dependencies))
9446 number headers header)
9448 (set-buffer nntp-server-buffer)
9449 ;; Allow the user to mangle the headers before parsing them.
9450 (run-hooks 'gnus-parse-headers-hook)
9451 (goto-char (point-min))
9452 (while (and sequence (not (eobp)))
9453 (setq number (read cur))
9454 (while (and sequence (< (car sequence) number))
9455 (setq sequence (cdr sequence)))
9457 (eq number (car sequence))
9459 (setq sequence (cdr sequence))
9461 (inline (gnus-nov-parse-line
9462 number dependencies force-new)))
9463 (setq headers (cons header headers)))))
9465 (setq headers (nreverse headers)))
9468 ;; This function has to be called with point after the article number
9469 ;; on the beginning of the line.
9470 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9472 (eol (gnus-point-at-eol))
9473 (buffer (current-buffer))
9474 header ref id id-dep ref-dep)
9476 ;; overview: [num subject from date id refs chars lines misc]
9477 (narrow-to-region (point) eol)
9478 (or (eobp) (forward-char))
9484 (gnus-nov-field) ; subject
9485 (gnus-nov-field) ; from
9486 (gnus-nov-field) ; date
9487 (setq id (or (gnus-nov-field)
9490 (setq none (1+ none)))))) ; id
9493 (let ((beg (point)))
9494 (search-forward "\t" eol)
9495 (if (search-backward ">" beg t)
9499 (search-backward "<" beg t)))
9501 (gnus-nov-field)) ; refs
9502 (gnus-nov-read-integer) ; chars
9503 (gnus-nov-read-integer) ; lines
9504 (if (= (following-char) ?\n)
9506 (gnus-nov-field)) ; misc
9509 (gnus-error 4 "Strange nov line")
9515 ;; We build the thread tree.
9517 (if (boundp (setq id-dep (intern id dependencies)))
9518 (if (and (car (symbol-value id-dep))
9520 ;; An article with this Message-ID has already been seen,
9521 ;; so we ignore this one, except we add any additional
9522 ;; Xrefs (in case the two articles came from different
9525 (mail-header-set-xref
9526 (car (symbol-value id-dep))
9527 (concat (or (mail-header-xref
9528 (car (symbol-value id-dep))) "")
9529 (or (mail-header-xref header) "")))
9531 (setcar (symbol-value id-dep) header))
9532 (set id-dep (list header))))
9534 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9535 (setcdr (symbol-value ref-dep)
9536 (nconc (cdr (symbol-value ref-dep))
9537 (list (symbol-value id-dep))))
9538 (set ref-dep (list nil (symbol-value id-dep)))))
9541 (defun gnus-article-get-xrefs ()
9542 "Fill in the Xref value in `gnus-current-headers', if necessary.
9543 This is meant to be called in `gnus-article-internal-prepare-hook'."
9544 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9545 gnus-current-headers)))
9546 (or (not gnus-use-cross-reference)
9548 (and (mail-header-xref headers)
9549 (not (string= (mail-header-xref headers) "")))
9550 (let ((case-fold-search t)
9553 (nnheader-narrow-to-headers)
9554 (goto-char (point-min))
9555 (if (or (and (eq (downcase (following-char)) ?x)
9556 (looking-at "Xref:"))
9557 (search-forward "\nXref:" nil t))
9559 (goto-char (1+ (match-end 0)))
9560 (setq xref (buffer-substring (point)
9561 (progn (end-of-line) (point))))
9562 (mail-header-set-xref headers xref))))))))
9564 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9565 "Find article ID and insert the summary line for that article."
9566 (let ((header (if (and old-header use-old-header)
9567 old-header (gnus-read-header id)))
9568 (number (and (numberp id) id))
9571 ;; Rebuild the thread that this article is part of and go to the
9572 ;; article we have fetched.
9573 (when (and (not gnus-show-threads)
9575 (when (setq pos (text-property-any
9576 (point-min) (point-max) 'gnus-number
9577 (mail-header-number old-header)))
9580 (gnus-data-remove (mail-header-number old-header))))
9582 (mail-header-set-number header (mail-header-number old-header)))
9583 (setq gnus-newsgroup-sparse
9584 (delq (setq number (mail-header-number header))
9585 gnus-newsgroup-sparse))
9586 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9587 (gnus-rebuild-thread (mail-header-id header))
9588 (gnus-summary-goto-subject number nil t))
9589 (when (and (numberp number)
9591 ;; We have to update the boundaries even if we can't fetch the
9592 ;; article if ID is a number -- so that the next `P' or `N'
9593 ;; command will fetch the previous (or next) article even
9594 ;; if the one we tried to fetch this time has been canceled.
9595 (and (> number gnus-newsgroup-end)
9596 (setq gnus-newsgroup-end number))
9597 (and (< number gnus-newsgroup-begin)
9598 (setq gnus-newsgroup-begin number))
9599 (setq gnus-newsgroup-unselected
9600 (delq number gnus-newsgroup-unselected)))
9601 ;; Report back a success?
9602 (and header (mail-header-number header))))
9604 (defun gnus-summary-work-articles (n)
9605 "Return a list of articles to be worked upon. The prefix argument,
9606 the list of process marked articles, and the current article will be
9607 taken into consideration."
9610 ;; A numerical prefix has been given.
9611 (let ((backward (< n 0))
9612 (n (abs (prefix-numeric-value n)))
9617 (push (setq article (gnus-summary-article-number))
9620 (gnus-summary-find-prev nil article)
9621 (gnus-summary-find-next nil article)))
9623 (nreverse articles)))
9624 ((and (boundp 'transient-mark-mode)
9627 ;; Work on the region between point and mark.
9628 (let ((max (max (point) (mark)))
9631 (goto-char (min (point) (mark)))
9634 (push (setq article (gnus-summary-article-number)) articles)
9635 (gnus-summary-find-next nil article)
9637 (nreverse articles))))
9638 (gnus-newsgroup-processable
9639 ;; There are process-marked articles present.
9640 (reverse gnus-newsgroup-processable))
9642 ;; Just return the current article.
9643 (list (gnus-summary-article-number)))))
9645 (defun gnus-summary-search-group (&optional backward use-level)
9646 "Search for next unread newsgroup.
9647 If optional argument BACKWARD is non-nil, search backward instead."
9649 (set-buffer gnus-group-buffer)
9650 (if (gnus-group-search-forward
9651 backward nil (if use-level (gnus-group-group-level) nil))
9652 (gnus-group-group-name))))
9654 (defun gnus-summary-best-group (&optional exclude-group)
9655 "Find the name of the best unread group.
9656 If EXCLUDE-GROUP, do not go to this group."
9658 (set-buffer gnus-group-buffer)
9660 (gnus-group-best-unread-group exclude-group))))
9662 (defun gnus-summary-find-next (&optional unread article backward)
9663 (if backward (gnus-summary-find-prev)
9664 (let* ((dummy (gnus-summary-article-intangible-p))
9665 (article (or article (gnus-summary-article-number)))
9666 (arts (gnus-data-find-list article))
9668 (when (and (not dummy)
9669 (or (not gnus-summary-check-current)
9671 (not (gnus-data-unread-p (car arts)))))
9672 (setq arts (cdr arts)))
9677 (when (gnus-data-unread-p (car arts))
9678 (setq result (car arts)
9680 (setq arts (cdr arts)))
9683 (goto-char (gnus-data-pos result))
9684 (gnus-data-number result)))))
9686 (defun gnus-summary-find-prev (&optional unread article)
9687 (let* ((eobp (eobp))
9688 (article (or article (gnus-summary-article-number)))
9689 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9691 (when (and (not eobp)
9692 (or (not gnus-summary-check-current)
9694 (not (gnus-data-unread-p (car arts)))))
9695 (setq arts (cdr arts)))
9700 (and (gnus-data-unread-p (car arts))
9701 (setq result (car arts)
9703 (setq arts (cdr arts)))
9707 (goto-char (gnus-data-pos result))
9708 (gnus-data-number result)))))
9710 (defun gnus-summary-find-subject (subject &optional unread backward article)
9711 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9712 (article (or article (gnus-summary-article-number)))
9713 (articles (gnus-data-list backward))
9714 (arts (gnus-data-find-list article articles))
9716 (when (or (not gnus-summary-check-current)
9718 (not (gnus-data-unread-p (car arts))))
9719 (setq arts (cdr arts)))
9721 (and (or (not unread)
9722 (gnus-data-unread-p (car arts)))
9723 (vectorp (gnus-data-header (car arts)))
9725 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9726 (setq result (car arts)
9728 (setq arts (cdr arts)))
9730 (goto-char (gnus-data-pos result))
9731 (gnus-data-number result))))
9733 (defun gnus-summary-search-forward (&optional unread subject backward)
9734 "Search forward for an article.
9735 If UNREAD, look for unread articles. If SUBJECT, look for
9736 articles with that subject. If BACKWARD, search backward instead."
9737 (cond (subject (gnus-summary-find-subject subject unread backward))
9738 (backward (gnus-summary-find-prev unread))
9739 (t (gnus-summary-find-next unread))))
9741 (defun gnus-recenter (&optional n)
9742 "Center point in window and redisplay frame.
9743 Also do horizontal recentering."
9745 (when (and gnus-auto-center-summary
9746 (not (eq gnus-auto-center-summary 'vertical)))
9747 (gnus-horizontal-recenter))
9750 (defun gnus-summary-recenter ()
9751 "Center point in the summary window.
9752 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9753 displayed, no centering will be performed."
9754 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9755 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9756 (let* ((top (cond ((< (window-height) 4) 0)
9757 ((< (window-height) 7) 1)
9759 (height (1- (window-height)))
9760 (bottom (save-excursion (goto-char (point-max))
9761 (forward-line (- height))
9763 (window (get-buffer-window (current-buffer))))
9764 ;; The user has to want it.
9765 (when gnus-auto-center-summary
9766 (when (get-buffer-window gnus-article-buffer)
9767 ;; Only do recentering when the article buffer is displayed,
9768 ;; Set the window start to either `bottom', which is the biggest
9769 ;; possible valid number, or the second line from the top,
9770 ;; whichever is the least.
9772 window (min bottom (save-excursion
9773 (forward-line (- top)) (point)))))
9774 ;; Do horizontal recentering while we're at it.
9775 (when (and (get-buffer-window (current-buffer) t)
9776 (not (eq gnus-auto-center-summary 'vertical)))
9777 (let ((selected (selected-window)))
9778 (select-window (get-buffer-window (current-buffer) t))
9779 (gnus-summary-position-point)
9780 (gnus-horizontal-recenter)
9781 (select-window selected))))))
9783 (defun gnus-horizontal-recenter ()
9784 "Recenter the current buffer horizontally."
9785 (if (< (current-column) (/ (window-width) 2))
9786 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9787 (let* ((orig (point))
9788 (end (window-end (get-buffer-window (current-buffer) t)))
9790 ;; Find the longest line currently displayed in the window.
9791 (goto-char (window-start))
9792 (while (and (not (eobp))
9795 (setq max (max max (current-column)))
9798 ;; Scroll horizontally to center (sort of) the point.
9799 (if (> max (window-width))
9801 (get-buffer-window (current-buffer) t)
9802 (min (- (current-column) (/ (window-width) 3))
9803 (+ 2 (- max (window-width)))))
9804 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9807 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9808 (defun gnus-short-group-name (group &optional levels)
9809 "Collapse GROUP name LEVELS."
9816 (while (string-match "\\." group skip)
9817 (setq skip (match-end 0)
9820 (if (string-match ":" group)
9821 (setq foreign (substring group 0 (match-end 0))
9822 group (substring group (match-end 0))))
9824 (if (and (string-match "\\." group)
9825 (> levels (- gnus-group-uncollapsed-levels 1)))
9826 (setq name (concat name (substring group 0 1))
9827 group (substring group (match-end 0))
9829 name (concat name "."))
9830 (setq name (concat foreign name group)
9834 (defun gnus-summary-jump-to-group (newsgroup)
9835 "Move point to NEWSGROUP in group mode buffer."
9836 ;; Keep update point of group mode buffer if visible.
9837 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9838 (save-window-excursion
9839 ;; Take care of tree window mode.
9840 (if (get-buffer-window gnus-group-buffer)
9841 (pop-to-buffer gnus-group-buffer))
9842 (gnus-group-jump-to-group newsgroup))
9844 ;; Take care of tree window mode.
9845 (if (get-buffer-window gnus-group-buffer)
9846 (pop-to-buffer gnus-group-buffer)
9847 (set-buffer gnus-group-buffer))
9848 (gnus-group-jump-to-group newsgroup))))
9850 ;; This function returns a list of article numbers based on the
9851 ;; difference between the ranges of read articles in this group and
9852 ;; the range of active articles.
9853 (defun gnus-list-of-unread-articles (group)
9854 (let* ((read (gnus-info-read (gnus-get-info group)))
9855 (active (gnus-active group))
9858 ;; If none are read, then all are unread.
9860 (setq first (car active))
9861 ;; If the range of read articles is a single range, then the
9862 ;; first unread article is the article after the last read
9863 ;; article. Sounds logical, doesn't it?
9864 (if (not (listp (cdr read)))
9865 (setq first (1+ (cdr read)))
9866 ;; `read' is a list of ranges.
9867 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9872 (while (< first nlast)
9873 (setq unread (cons first unread))
9874 (setq first (1+ first))))
9875 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9876 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9877 (setq read (cdr read)))))
9878 ;; And add the last unread articles.
9879 (while (<= first last)
9880 (setq unread (cons first unread))
9881 (setq first (1+ first)))
9882 ;; Return the list of unread articles.
9885 (defun gnus-list-of-read-articles (group)
9886 "Return a list of unread, unticked and non-dormant articles."
9887 (let* ((info (gnus-get-info group))
9888 (marked (gnus-info-marks info))
9889 (active (gnus-active group)))
9891 (gnus-set-difference
9892 (gnus-sorted-complement
9893 (gnus-uncompress-range active)
9894 (gnus-list-of-unread-articles group))
9896 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9897 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9899 ;; Various summary commands
9901 (defun gnus-summary-universal-argument (arg)
9902 "Perform any operation on all articles that are process/prefixed."
9904 (gnus-set-global-variables)
9905 (let ((articles (gnus-summary-work-articles arg))
9912 (substitute-command-keys
9913 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9916 (gnus-error 1 "Undefined key")
9919 (gnus-summary-goto-subject (setq article (pop articles)))
9920 (command-execute func)
9921 (gnus-summary-remove-process-mark article)))))
9922 (gnus-summary-position-point))
9924 (defun gnus-summary-toggle-truncation (&optional arg)
9925 "Toggle truncation of summary lines.
9926 With arg, turn line truncation on iff arg is positive."
9928 (setq truncate-lines
9929 (if (null arg) (not truncate-lines)
9930 (> (prefix-numeric-value arg) 0)))
9933 (defun gnus-summary-reselect-current-group (&optional all rescan)
9934 "Exit and then reselect the current newsgroup.
9935 The prefix argument ALL means to select all articles."
9937 (gnus-set-global-variables)
9938 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9939 (error "Ephemeral groups can't be reselected"))
9940 (let ((current-subject (gnus-summary-article-number))
9941 (group gnus-newsgroup-name))
9942 (setq gnus-newsgroup-begin nil)
9944 ;; We have to adjust the point of group mode buffer because the
9945 ;; current point was moved to the next unread newsgroup by
9947 (gnus-summary-jump-to-group group)
9950 (gnus-group-get-new-news-this-group 1)))
9951 (gnus-group-read-group all t)
9952 (gnus-summary-goto-subject current-subject nil t)))
9954 (defun gnus-summary-rescan-group (&optional all)
9955 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9957 (gnus-summary-reselect-current-group all t))
9959 (defun gnus-summary-update-info ()
9960 (let* ((group gnus-newsgroup-name))
9961 (when gnus-newsgroup-kill-headers
9962 (setq gnus-newsgroup-killed
9963 (gnus-compress-sequence
9965 (gnus-set-sorted-intersection
9966 (gnus-uncompress-range gnus-newsgroup-killed)
9967 (setq gnus-newsgroup-unselected
9968 (sort gnus-newsgroup-unselected '<)))
9969 (setq gnus-newsgroup-unreads
9970 (sort gnus-newsgroup-unreads '<))) t)))
9971 (unless (listp (cdr gnus-newsgroup-killed))
9972 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9973 (let ((headers gnus-newsgroup-headers))
9974 (run-hooks 'gnus-exit-group-hook)
9975 (unless gnus-save-score
9976 (setq gnus-newsgroup-scored nil))
9977 ;; Set the new ranges of read articles.
9978 (gnus-update-read-articles
9979 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9980 ;; Set the current article marks.
9982 ;; Do the cross-ref thing.
9983 (when gnus-use-cross-reference
9984 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9985 ;; Do adaptive scoring, and possibly save score files.
9986 (when gnus-newsgroup-adaptive
9987 (gnus-score-adaptive))
9988 (when gnus-use-scoring
9990 ;; Do not switch windows but change the buffer to work.
9991 (set-buffer gnus-group-buffer)
9992 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9993 (gnus-group-update-group group)))))
9995 (defun gnus-summary-exit (&optional temporary)
9996 "Exit reading current newsgroup, and then return to group selection mode.
9997 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9999 (gnus-set-global-variables)
10000 (gnus-kill-save-kill-buffer)
10001 (let* ((group gnus-newsgroup-name)
10002 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10004 (buf (current-buffer)))
10005 (run-hooks 'gnus-summary-prepare-exit-hook)
10006 ;; If we have several article buffers, we kill them at exit.
10007 (unless gnus-single-article-buffer
10008 (gnus-kill-buffer gnus-original-article-buffer)
10009 (setq gnus-article-current nil))
10010 (when gnus-use-cache
10011 (gnus-cache-possibly-remove-articles)
10012 (gnus-cache-save-buffers))
10013 (when gnus-use-trees
10014 (gnus-tree-close group))
10015 ;; Make all changes in this group permanent.
10016 (unless quit-config
10017 (gnus-summary-update-info))
10018 (gnus-close-group group)
10019 ;; Make sure where I was, and go to next newsgroup.
10020 (set-buffer gnus-group-buffer)
10021 (unless quit-config
10022 (gnus-group-jump-to-group group))
10023 (run-hooks 'gnus-summary-exit-hook)
10024 (unless quit-config
10025 (gnus-group-next-unread-group 1))
10027 nil ;Nothing to do.
10028 ;; If we have several article buffers, we kill them at exit.
10029 (unless gnus-single-article-buffer
10030 (gnus-kill-buffer gnus-article-buffer)
10031 (gnus-kill-buffer gnus-original-article-buffer)
10032 (setq gnus-article-current nil))
10034 (if (not gnus-kill-summary-on-exit)
10035 (gnus-deaden-summary)
10036 ;; We set all buffer-local variables to nil. It is unclear why
10037 ;; this is needed, but if we don't, buffer-local variables are
10038 ;; not garbage-collected, it seems. This would the lead to en
10039 ;; ever-growing Emacs.
10040 (gnus-summary-clear-local-variables)
10041 (when (get-buffer gnus-article-buffer)
10042 (bury-buffer gnus-article-buffer))
10043 ;; We clear the global counterparts of the buffer-local
10044 ;; variables as well, just to be on the safe side.
10045 (gnus-configure-windows 'group 'force)
10046 (gnus-summary-clear-local-variables)
10047 ;; Return to group mode buffer.
10048 (if (eq mode 'gnus-summary-mode)
10049 (gnus-kill-buffer buf)))
10050 (setq gnus-current-select-method gnus-select-method)
10051 (pop-to-buffer gnus-group-buffer)
10052 ;; Clear the current group name.
10053 (if (not quit-config)
10055 (gnus-group-jump-to-group group)
10056 (gnus-group-next-unread-group 1)
10057 (gnus-configure-windows 'group 'force))
10058 (if (not (buffer-name (car quit-config)))
10059 (gnus-configure-windows 'group 'force)
10060 (set-buffer (car quit-config))
10061 (and (eq major-mode 'gnus-summary-mode)
10062 (gnus-set-global-variables))
10063 (gnus-configure-windows (cdr quit-config))))
10064 (unless quit-config
10065 (setq gnus-newsgroup-name nil)))))
10067 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10068 (defun gnus-summary-exit-no-update (&optional no-questions)
10069 "Quit reading current newsgroup without updating read article info."
10071 (gnus-set-global-variables)
10072 (let* ((group gnus-newsgroup-name)
10073 (quit-config (gnus-group-quit-config group)))
10074 (when (or no-questions
10076 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10077 ;; If we have several article buffers, we kill them at exit.
10078 (unless gnus-single-article-buffer
10079 (gnus-kill-buffer gnus-article-buffer)
10080 (gnus-kill-buffer gnus-original-article-buffer)
10081 (setq gnus-article-current nil))
10082 (if (not gnus-kill-summary-on-exit)
10083 (gnus-deaden-summary)
10084 (gnus-close-group group)
10085 (gnus-summary-clear-local-variables)
10086 (set-buffer gnus-group-buffer)
10087 (gnus-summary-clear-local-variables)
10088 (when (get-buffer gnus-summary-buffer)
10089 (kill-buffer gnus-summary-buffer)))
10090 (unless gnus-single-article-buffer
10091 (setq gnus-article-current nil))
10092 (when gnus-use-trees
10093 (gnus-tree-close group))
10094 (when (get-buffer gnus-article-buffer)
10095 (bury-buffer gnus-article-buffer))
10096 ;; Return to the group buffer.
10097 (gnus-configure-windows 'group 'force)
10098 ;; Clear the current group name.
10099 (setq gnus-newsgroup-name nil)
10100 (when (equal (gnus-group-group-name) group)
10101 (gnus-group-next-unread-group 1))
10103 (if (not (buffer-name (car quit-config)))
10104 (gnus-configure-windows 'group 'force)
10105 (set-buffer (car quit-config))
10106 (when (eq major-mode 'gnus-summary-mode)
10107 (gnus-set-global-variables))
10108 (gnus-configure-windows (cdr quit-config)))))))
10110 ;;; Dead summaries.
10112 (defvar gnus-dead-summary-mode-map nil)
10114 (if gnus-dead-summary-mode-map
10116 (setq gnus-dead-summary-mode-map (make-keymap))
10117 (suppress-keymap gnus-dead-summary-mode-map)
10118 (substitute-key-definition
10119 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10120 (let ((keys '("\C-d" "\r" "\177")))
10122 (define-key gnus-dead-summary-mode-map
10123 (pop keys) 'gnus-summary-wake-up-the-dead))))
10125 (defvar gnus-dead-summary-mode nil
10126 "Minor mode for Gnus summary buffers.")
10128 (defun gnus-dead-summary-mode (&optional arg)
10129 "Minor mode for Gnus summary buffers."
10131 (when (eq major-mode 'gnus-summary-mode)
10132 (make-local-variable 'gnus-dead-summary-mode)
10133 (setq gnus-dead-summary-mode
10134 (if (null arg) (not gnus-dead-summary-mode)
10135 (> (prefix-numeric-value arg) 0)))
10136 (when gnus-dead-summary-mode
10137 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10138 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10139 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10140 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10141 minor-mode-map-alist)))))
10143 (defun gnus-deaden-summary ()
10144 "Make the current summary buffer into a dead summary buffer."
10145 ;; Kill any previous dead summary buffer.
10146 (when (and gnus-dead-summary
10147 (buffer-name gnus-dead-summary))
10149 (set-buffer gnus-dead-summary)
10150 (when gnus-dead-summary-mode
10151 (kill-buffer (current-buffer)))))
10152 ;; Make this the current dead summary.
10153 (setq gnus-dead-summary (current-buffer))
10154 (gnus-dead-summary-mode 1)
10155 (let ((name (buffer-name)))
10156 (when (string-match "Summary" name)
10158 (concat (substring name 0 (match-beginning 0)) "Dead "
10159 (substring name (match-beginning 0))) t))))
10161 (defun gnus-kill-or-deaden-summary (buffer)
10162 "Kill or deaden the summary BUFFER."
10163 (when (and (buffer-name buffer)
10164 (not gnus-single-article-buffer))
10166 (set-buffer buffer)
10167 (gnus-kill-buffer gnus-article-buffer)
10168 (gnus-kill-buffer gnus-original-article-buffer)))
10169 (cond (gnus-kill-summary-on-exit
10170 (when (and gnus-use-trees
10171 (and (get-buffer buffer)
10172 (buffer-name (get-buffer buffer))))
10174 (set-buffer (get-buffer buffer))
10175 (gnus-tree-close gnus-newsgroup-name)))
10176 (gnus-kill-buffer buffer))
10177 ((and (get-buffer buffer)
10178 (buffer-name (get-buffer buffer)))
10180 (set-buffer buffer)
10181 (gnus-deaden-summary)))))
10183 (defun gnus-summary-wake-up-the-dead (&rest args)
10184 "Wake up the dead summary buffer."
10186 (gnus-dead-summary-mode -1)
10187 (let ((name (buffer-name)))
10188 (when (string-match "Dead " name)
10190 (concat (substring name 0 (match-beginning 0))
10191 (substring name (match-end 0))) t)))
10192 (gnus-message 3 "This dead summary is now alive again"))
10194 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10195 (defun gnus-summary-fetch-faq (&optional faq-dir)
10196 "Fetch the FAQ for the current group.
10197 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10201 (if current-prefix-arg
10203 "Faq dir: " (and (listp gnus-group-faq-directory)
10204 gnus-group-faq-directory)))))
10205 (let (gnus-faq-buffer)
10206 (and (setq gnus-faq-buffer
10207 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10208 (gnus-configure-windows 'summary-faq))))
10210 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10211 (defun gnus-summary-describe-group (&optional force)
10212 "Describe the current newsgroup."
10214 (gnus-group-describe-group force gnus-newsgroup-name))
10216 (defun gnus-summary-describe-briefly ()
10217 "Describe summary mode commands briefly."
10220 (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")))
10222 ;; Walking around group mode buffer from summary mode.
10224 (defun gnus-summary-next-group (&optional no-article target-group backward)
10225 "Exit current newsgroup and then select next unread newsgroup.
10226 If prefix argument NO-ARTICLE is non-nil, no article is selected
10227 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10228 previous group instead."
10230 (gnus-set-global-variables)
10231 (let ((current-group gnus-newsgroup-name)
10232 (current-buffer (current-buffer))
10234 ;; First we semi-exit this group to update Xrefs and all variables.
10235 ;; We can't do a real exit, because the window conf must remain
10236 ;; the same in case the user is prompted for info, and we don't
10237 ;; want the window conf to change before that...
10238 (gnus-summary-exit t)
10239 (while (not entered)
10240 ;; Then we find what group we are supposed to enter.
10241 (set-buffer gnus-group-buffer)
10242 (gnus-group-jump-to-group current-group)
10245 (if (eq gnus-keep-same-level 'best)
10246 (gnus-summary-best-group gnus-newsgroup-name)
10247 (gnus-summary-search-group backward gnus-keep-same-level))))
10248 (if (not target-group)
10249 ;; There are no further groups, so we return to the group
10252 (gnus-message 5 "Returning to the group buffer")
10254 (set-buffer current-buffer)
10255 (gnus-summary-exit))
10256 ;; We try to enter the target group.
10257 (gnus-group-jump-to-group target-group)
10258 (let ((unreads (gnus-group-group-unread)))
10259 (if (and (or (eq t unreads)
10260 (and unreads (not (zerop unreads))))
10261 (gnus-summary-read-group
10262 target-group nil no-article current-buffer))
10264 (setq current-group target-group
10265 target-group nil)))))))
10267 (defun gnus-summary-prev-group (&optional no-article)
10268 "Exit current newsgroup and then select previous unread newsgroup.
10269 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10271 (gnus-summary-next-group no-article nil t))
10273 ;; Walking around summary lines.
10275 (defun gnus-summary-first-subject (&optional unread)
10276 "Go to the first unread subject.
10277 If UNREAD is non-nil, go to the first unread article.
10278 Returns the article selected or nil if there are no unread articles."
10283 ((null gnus-newsgroup-data)
10284 (gnus-message 3 "No articles in the group")
10286 ;; Pick the first article.
10288 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10289 (gnus-data-number (car gnus-newsgroup-data)))
10290 ;; No unread articles.
10291 ((null gnus-newsgroup-unreads)
10292 (gnus-message 3 "No more unread articles")
10294 ;; Find the first unread article.
10296 (let ((data gnus-newsgroup-data))
10298 (not (gnus-data-unread-p (car data))))
10299 (setq data (cdr data)))
10302 (goto-char (gnus-data-pos (car data)))
10303 (gnus-data-number (car data)))))))
10304 (gnus-summary-position-point)))
10306 (defun gnus-summary-next-subject (n &optional unread dont-display)
10307 "Go to next N'th summary line.
10308 If N is negative, go to the previous N'th subject line.
10309 If UNREAD is non-nil, only unread articles are selected.
10310 The difference between N and the actual number of steps taken is
10313 (let ((backward (< n 0))
10315 (while (and (> n 0)
10317 (gnus-summary-find-prev unread)
10318 (gnus-summary-find-next unread)))
10320 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10321 (if unread " unread" "")))
10322 (unless dont-display
10323 (gnus-summary-recenter)
10324 (gnus-summary-position-point))
10327 (defun gnus-summary-next-unread-subject (n)
10328 "Go to next N'th unread summary line."
10330 (gnus-summary-next-subject n t))
10332 (defun gnus-summary-prev-subject (n &optional unread)
10333 "Go to previous N'th summary line.
10334 If optional argument UNREAD is non-nil, only unread article is selected."
10336 (gnus-summary-next-subject (- n) unread))
10338 (defun gnus-summary-prev-unread-subject (n)
10339 "Go to previous N'th unread summary line."
10341 (gnus-summary-next-subject (- n) t))
10343 (defun gnus-summary-goto-subject (article &optional force silent)
10344 "Go the subject line of ARTICLE.
10345 If FORCE, also allow jumping to articles not currently shown."
10347 (data (gnus-data-find article)))
10348 ;; We read in the article if we have to.
10351 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10352 (setq data (gnus-data-find article)))
10357 (gnus-message 3 "Can't find article %d" article))
10359 (goto-char (gnus-data-pos data))
10362 ;; Walking around summary lines with displaying articles.
10364 (defun gnus-summary-expand-window (&optional arg)
10365 "Make the summary buffer take up the entire Emacs frame.
10366 Given a prefix, will force an `article' buffer configuration."
10368 (gnus-set-global-variables)
10370 (gnus-configure-windows 'article 'force)
10371 (gnus-configure-windows 'summary 'force)))
10373 (defun gnus-summary-display-article (article &optional all-header)
10374 "Display ARTICLE in article buffer."
10375 (gnus-set-global-variables)
10379 (if gnus-summary-display-article-function
10380 (funcall gnus-summary-display-article-function article all-header)
10381 (gnus-article-prepare article all-header))
10382 (run-hooks 'gnus-select-article-hook)
10383 (unless (zerop gnus-current-article)
10384 (gnus-summary-goto-subject gnus-current-article))
10385 (gnus-summary-recenter)
10386 (when gnus-use-trees
10387 (gnus-possibly-generate-tree article)
10388 (gnus-highlight-selected-tree article))
10389 ;; Successfully display article.
10390 (gnus-article-set-window-start
10391 (cdr (assq article gnus-newsgroup-bookmarks))))))
10393 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10394 "Select the current article.
10395 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10396 non-nil, the article will be re-fetched even if it already present in
10397 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10399 ;; Make sure we are in the summary buffer to work around bbdb bug.
10400 (unless (eq major-mode 'gnus-summary-mode)
10401 (set-buffer gnus-summary-buffer))
10402 (let ((article (or article (gnus-summary-article-number)))
10403 (all-headers (not (not all-headers))) ;Must be T or NIL.
10404 gnus-summary-display-article-function
10407 (gnus-summary-article-pseudo-p article)
10408 (error "This is a pseudo-article."))
10411 (set-buffer gnus-summary-buffer)
10412 (if (or (and gnus-single-article-buffer
10413 (or (null gnus-current-article)
10414 (null gnus-article-current)
10415 (null (get-buffer gnus-article-buffer))
10416 (not (eq article (cdr gnus-article-current)))
10417 (not (equal (car gnus-article-current)
10418 gnus-newsgroup-name))))
10419 (and (not gnus-single-article-buffer)
10420 (or (null gnus-current-article)
10421 (not (eq gnus-current-article article))))
10423 ;; The requested article is different from the current article.
10425 (gnus-summary-display-article article all-headers)
10426 (setq did article))
10427 (if (or all-headers gnus-show-all-headers)
10428 (gnus-article-show-all-headers))
10431 (gnus-article-set-window-start
10432 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10434 (defun gnus-summary-set-current-mark (&optional current-mark)
10435 "Obsolete function."
10438 (defun gnus-summary-next-article (&optional unread subject backward push)
10439 "Select the next article.
10440 If UNREAD, only unread articles are selected.
10441 If SUBJECT, only articles with SUBJECT are selected.
10442 If BACKWARD, the previous article is selected instead of the next."
10444 (gnus-set-global-variables)
10446 ;; Is there such an article?
10447 ((and (gnus-summary-search-forward unread subject backward)
10448 (or (gnus-summary-display-article (gnus-summary-article-number))
10449 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10450 (gnus-summary-position-point))
10451 ;; If not, we try the first unread, if that is wanted.
10453 gnus-auto-select-same
10454 (gnus-summary-first-unread-article))
10455 (gnus-summary-position-point)
10456 (gnus-message 6 "Wrapped"))
10457 ;; Try to get next/previous article not displayed in this group.
10458 ((and gnus-auto-extend-newsgroup
10459 (not unread) (not subject))
10460 (gnus-summary-goto-article
10461 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10463 ;; Go to next/previous group.
10465 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10466 (gnus-summary-jump-to-group gnus-newsgroup-name))
10467 (let ((cmd last-command-char)
10469 (if (eq gnus-keep-same-level 'best)
10470 (gnus-summary-best-group gnus-newsgroup-name)
10471 (gnus-summary-search-group backward gnus-keep-same-level))))
10472 ;; For some reason, the group window gets selected. We change
10474 (select-window (get-buffer-window (current-buffer)))
10475 ;; Select next unread newsgroup automagically.
10477 ((or (not gnus-auto-select-next)
10479 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10480 ((or (eq gnus-auto-select-next 'quietly)
10481 (and (eq gnus-auto-select-next 'slightly-quietly)
10483 (and (eq gnus-auto-select-next 'almost-quietly)
10484 (gnus-summary-last-article-p)))
10486 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10487 (gnus-summary-exit)
10488 (gnus-message 7 "No more%s articles (%s)..."
10489 (if unread " unread" "")
10490 (if group (concat "selecting " group)
10492 (gnus-summary-next-group nil group backward)))
10494 (gnus-summary-walk-group-buffer
10495 gnus-newsgroup-name cmd unread backward)))))))
10497 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10498 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10499 (?\C-p (gnus-group-prev-unread-group 1))))
10500 keve key group ended)
10502 (set-buffer gnus-group-buffer)
10503 (gnus-summary-jump-to-group from-group)
10505 (if (eq gnus-keep-same-level 'best)
10506 (gnus-summary-best-group gnus-newsgroup-name)
10507 (gnus-summary-search-group backward gnus-keep-same-level))))
10510 5 "No more%s articles%s" (if unread " unread" "")
10512 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10513 (format " (Type %s for %s [%s])"
10514 (single-key-description cmd) group
10515 (car (gnus-gethash group gnus-newsrc-hashtb)))
10516 (format " (Type %s to exit %s)"
10517 (single-key-description cmd)
10518 gnus-newsgroup-name)))
10519 ;; Confirm auto selection.
10520 (setq key (car (setq keve (gnus-read-event-char))))
10523 ((assq key keystrokes)
10524 (let ((obuf (current-buffer)))
10525 (switch-to-buffer gnus-group-buffer)
10527 (gnus-group-jump-to-group group))
10528 (eval (cadr (assq key keystrokes)))
10529 (setq group (gnus-group-group-name))
10530 (switch-to-buffer obuf))
10533 (if (or (not group)
10534 (gnus-ephemeral-group-p gnus-newsgroup-name))
10535 (gnus-summary-exit)
10536 (gnus-summary-next-group nil group backward)))
10538 (push (cdr keve) unread-command-events))))))
10540 (defun gnus-read-event-char ()
10541 "Get the next event."
10542 (let ((event (read-event)))
10543 (cons (and (numberp event) event) event)))
10545 (defun gnus-summary-next-unread-article ()
10546 "Select unread article after current one."
10548 (gnus-summary-next-article t (and gnus-auto-select-same
10549 (gnus-summary-article-subject))))
10551 (defun gnus-summary-prev-article (&optional unread subject)
10552 "Select the article after the current one.
10553 If UNREAD is non-nil, only unread articles are selected."
10555 (gnus-summary-next-article unread subject t))
10557 (defun gnus-summary-prev-unread-article ()
10558 "Select unred article before current one."
10560 (gnus-summary-prev-article t (and gnus-auto-select-same
10561 (gnus-summary-article-subject))))
10563 (defun gnus-summary-next-page (&optional lines circular)
10564 "Show next page of the selected article.
10565 If at the end of the current article, select the next article.
10566 LINES says how many lines should be scrolled up.
10568 If CIRCULAR is non-nil, go to the start of the article instead of
10569 selecting the next article when reaching the end of the current
10572 (setq gnus-summary-buffer (current-buffer))
10573 (gnus-set-global-variables)
10574 (let ((article (gnus-summary-article-number))
10576 (gnus-configure-windows 'article)
10577 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10578 (if (and (eq gnus-summary-goto-unread 'never)
10579 (not (gnus-summary-last-article-p article)))
10580 (gnus-summary-next-article)
10581 (gnus-summary-next-unread-article))
10582 (if (or (null gnus-current-article)
10583 (null gnus-article-current)
10584 (/= article (cdr gnus-article-current))
10585 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10586 ;; Selected subject is different from current article's.
10587 (gnus-summary-display-article article)
10588 (gnus-eval-in-buffer-window gnus-article-buffer
10589 (setq endp (gnus-article-next-page lines)))
10592 (gnus-summary-beginning-of-article))
10594 (gnus-message 3 "End of message"))
10596 (if (and (eq gnus-summary-goto-unread 'never)
10597 (not (gnus-summary-last-article-p article)))
10598 (gnus-summary-next-article)
10599 (gnus-summary-next-unread-article)))))))
10600 (gnus-summary-recenter)
10601 (gnus-summary-position-point)))
10603 (defun gnus-summary-prev-page (&optional lines)
10604 "Show previous page of selected article.
10605 Argument LINES specifies lines to be scrolled down."
10607 (gnus-set-global-variables)
10608 (let ((article (gnus-summary-article-number)))
10609 (gnus-configure-windows 'article)
10610 (if (or (null gnus-current-article)
10611 (null gnus-article-current)
10612 (/= article (cdr gnus-article-current))
10613 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10614 ;; Selected subject is different from current article's.
10615 (gnus-summary-display-article article)
10616 (gnus-summary-recenter)
10617 (gnus-eval-in-buffer-window gnus-article-buffer
10618 (gnus-article-prev-page lines))))
10619 (gnus-summary-position-point))
10621 (defun gnus-summary-scroll-up (lines)
10622 "Scroll up (or down) one line current article.
10623 Argument LINES specifies lines to be scrolled up (or down if negative)."
10625 (gnus-set-global-variables)
10626 (gnus-configure-windows 'article)
10627 (gnus-summary-show-thread)
10628 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10629 (gnus-eval-in-buffer-window gnus-article-buffer
10631 (if (gnus-article-next-page lines)
10632 (gnus-message 3 "End of message")))
10634 (gnus-article-prev-page (- lines))))))
10635 (gnus-summary-recenter)
10636 (gnus-summary-position-point))
10638 (defun gnus-summary-next-same-subject ()
10639 "Select next article which has the same subject as current one."
10641 (gnus-set-global-variables)
10642 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10644 (defun gnus-summary-prev-same-subject ()
10645 "Select previous article which has the same subject as current one."
10647 (gnus-set-global-variables)
10648 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10650 (defun gnus-summary-next-unread-same-subject ()
10651 "Select next unread article which has the same subject as current one."
10653 (gnus-set-global-variables)
10654 (gnus-summary-next-article t (gnus-summary-article-subject)))
10656 (defun gnus-summary-prev-unread-same-subject ()
10657 "Select previous unread article which has the same subject as current one."
10659 (gnus-set-global-variables)
10660 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10662 (defun gnus-summary-first-unread-article ()
10663 "Select the first unread article.
10664 Return nil if there are no unread articles."
10666 (gnus-set-global-variables)
10668 (if (gnus-summary-first-subject t)
10670 (gnus-summary-show-thread)
10671 (gnus-summary-first-subject t)
10672 (gnus-summary-display-article (gnus-summary-article-number))))
10673 (gnus-summary-position-point)))
10675 (defun gnus-summary-best-unread-article ()
10676 "Select the unread article with the highest score."
10678 (gnus-set-global-variables)
10679 (let ((best -1000000)
10680 (data gnus-newsgroup-data)
10683 (and (gnus-data-unread-p (car data))
10685 (gnus-summary-article-score (gnus-data-number (car data))))
10688 article (gnus-data-number (car data))))
10689 (setq data (cdr data)))
10692 (gnus-summary-goto-article article)
10693 (error "No unread articles"))
10694 (gnus-summary-position-point))))
10696 (defun gnus-summary-last-subject ()
10697 "Go to the last displayed subject line in the group."
10698 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10700 (gnus-summary-goto-subject article))))
10702 (defun gnus-summary-goto-article (article &optional all-headers force)
10703 "Fetch ARTICLE and display it if it exists.
10704 If ALL-HEADERS is non-nil, no header lines are hidden."
10710 (mapcar (lambda (number) (list (int-to-string number)))
10711 gnus-newsgroup-limit)))
10715 (if (gnus-summary-goto-subject article force)
10716 (gnus-summary-display-article article all-headers)
10717 (gnus-message 4 "Couldn't go to article %s" article) nil)
10718 (gnus-summary-position-point)))
10720 (defun gnus-summary-goto-last-article ()
10721 "Go to the previously read article."
10724 (and gnus-last-article
10725 (gnus-summary-goto-article gnus-last-article))
10726 (gnus-summary-position-point)))
10728 (defun gnus-summary-pop-article (number)
10729 "Pop one article off the history and go to the previous.
10730 NUMBER articles will be popped off."
10733 (setq gnus-newsgroup-history
10734 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10736 (gnus-summary-goto-article (car to))
10737 (error "Article history empty")))
10738 (gnus-summary-position-point))
10740 ;; Summary commands and functions for limiting the summary buffer.
10742 (defun gnus-summary-limit-to-articles (n)
10743 "Limit the summary buffer to the next N articles.
10744 If not given a prefix, use the process marked articles instead."
10746 (gnus-set-global-variables)
10748 (let ((articles (gnus-summary-work-articles n)))
10749 (setq gnus-newsgroup-processable nil)
10750 (gnus-summary-limit articles))
10751 (gnus-summary-position-point)))
10753 (defun gnus-summary-pop-limit (&optional total)
10754 "Restore the previous limit.
10755 If given a prefix, remove all limits."
10757 (gnus-set-global-variables)
10759 (setq gnus-newsgroup-limits
10760 (list (mapcar (lambda (h) (mail-header-number h))
10761 gnus-newsgroup-headers))))
10762 (unless gnus-newsgroup-limits
10763 (error "No limit to pop"))
10765 (gnus-summary-limit nil 'pop)
10766 (gnus-summary-position-point)))
10768 (defun gnus-summary-limit-to-subject (subject &optional header)
10769 "Limit the summary buffer to articles that have subjects that match a regexp."
10770 (interactive "sRegexp: ")
10772 (setq header "subject"))
10773 (when (not (equal "" subject))
10775 (let ((articles (gnus-summary-find-matching
10776 (or header "subject") subject 'all)))
10777 (or articles (error "Found no matches for \"%s\"" subject))
10778 (gnus-summary-limit articles))
10779 (gnus-summary-position-point))))
10781 (defun gnus-summary-limit-to-author (from)
10782 "Limit the summary buffer to articles that have authors that match a regexp."
10783 (interactive "sRegexp: ")
10784 (gnus-summary-limit-to-subject from "from"))
10786 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10788 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10790 (defun gnus-summary-limit-to-unread (&optional all)
10791 "Limit the summary buffer to articles that are not marked as read.
10792 If ALL is non-nil, limit strictly to unread articles."
10795 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10796 (gnus-summary-limit-to-marks
10797 ;; Concat all the marks that say that an article is read and have
10799 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10800 gnus-killed-mark gnus-kill-file-mark
10801 gnus-low-score-mark gnus-expirable-mark
10802 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10805 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10806 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10808 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10809 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10810 If REVERSE, limit the summary buffer to articles that are not marked
10811 with MARKS. MARKS can either be a string of marks or a list of marks.
10812 Returns how many articles were removed."
10813 (interactive "sMarks: ")
10814 (gnus-set-global-variables)
10816 (let ((data gnus-newsgroup-data)
10817 (marks (if (listp marks) marks
10818 (append marks nil))) ; Transform to list.
10821 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10822 (memq (gnus-data-mark (car data)) marks))
10823 (setq articles (cons (gnus-data-number (car data)) articles)))
10824 (setq data (cdr data)))
10825 (gnus-summary-limit articles))
10826 (gnus-summary-position-point)))
10828 (defun gnus-summary-limit-to-score (&optional score)
10829 "Limit to articles with score at or above SCORE."
10831 (gnus-set-global-variables)
10832 (setq score (if score
10833 (prefix-numeric-value score)
10834 (or gnus-summary-default-score 0)))
10835 (let ((data gnus-newsgroup-data)
10838 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10840 (push (gnus-data-number (car data)) articles))
10841 (setq data (cdr data)))
10843 (gnus-summary-limit articles)
10844 (gnus-summary-position-point))))
10846 (defun gnus-summary-limit-include-dormant ()
10847 "Display all the hidden articles that are marked as dormant."
10849 (gnus-set-global-variables)
10850 (or gnus-newsgroup-dormant
10851 (error "There are no dormant articles in this group"))
10853 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10854 (gnus-summary-position-point)))
10856 (defun gnus-summary-limit-exclude-dormant ()
10857 "Hide all dormant articles."
10859 (gnus-set-global-variables)
10861 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10862 (gnus-summary-position-point)))
10864 (defun gnus-summary-limit-exclude-childless-dormant ()
10865 "Hide all dormant articles that have no children."
10867 (gnus-set-global-variables)
10868 (let ((data (gnus-data-list t))
10869 articles d children)
10870 ;; Find all articles that are either not dormant or have
10872 (while (setq d (pop data))
10873 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10874 (and (setq children
10875 (gnus-article-children (gnus-data-number d)))
10878 (when (memq (car children) articles)
10883 (push (gnus-data-number d) articles)))
10884 ;; Do the limiting.
10886 (gnus-summary-limit articles)
10887 (gnus-summary-position-point))))
10889 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10890 "Mark all unread excluded articles as read.
10891 If ALL, mark even excluded ticked and dormants as read."
10893 (let ((articles (gnus-sorted-complement
10895 (mapcar (lambda (h) (mail-header-number h))
10896 gnus-newsgroup-headers)
10898 (sort gnus-newsgroup-limit '<)))
10900 (setq gnus-newsgroup-unreads nil)
10902 (setq gnus-newsgroup-dormant nil
10903 gnus-newsgroup-marked nil
10904 gnus-newsgroup-reads
10906 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10907 gnus-newsgroup-reads))
10908 (while (setq article (pop articles))
10909 (unless (or (memq article gnus-newsgroup-dormant)
10910 (memq article gnus-newsgroup-marked))
10911 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10913 (defun gnus-summary-limit (articles &optional pop)
10915 ;; We pop the previous limit off the stack and use that.
10916 (setq articles (car gnus-newsgroup-limits)
10917 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10918 ;; We use the new limit, so we push the old limit on the stack.
10919 (setq gnus-newsgroup-limits
10920 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10922 (setq gnus-newsgroup-limit articles)
10923 (let ((total (length gnus-newsgroup-data))
10924 (data (gnus-data-find-list (gnus-summary-article-number)))
10925 (gnus-summary-mark-below nil) ; Inhibit this.
10927 ;; This will do all the work of generating the new summary buffer
10928 ;; according to the new limit.
10929 (gnus-summary-prepare)
10930 ;; Hide any threads, possibly.
10931 (and gnus-show-threads
10932 gnus-thread-hide-subtree
10933 (gnus-summary-hide-all-threads))
10934 ;; Try to return to the article you were at, or one in the
10937 ;; We try to find some article after the current one.
10939 (and (gnus-summary-goto-subject
10940 (gnus-data-number (car data)) nil t)
10943 (setq data (cdr data))))
10945 ;; If there is no data, that means that we were after the last
10946 ;; article. The same goes when we can't find any articles
10947 ;; after the current one.
10949 (goto-char (point-max))
10950 (gnus-summary-find-prev)))
10951 ;; We return how many articles were removed from the summary
10952 ;; buffer as a result of the new limit.
10953 (- total (length gnus-newsgroup-data))))
10955 (defsubst gnus-invisible-cut-children (threads)
10958 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10963 (defsubst gnus-cut-thread (thread)
10964 "Go forwards in the thread until we find an article that we want to display."
10965 (when (or (eq gnus-fetch-old-headers 'some)
10966 (eq gnus-build-sparse-threads 'some)
10967 (eq gnus-build-sparse-threads 'more))
10968 ;; Deal with old-fetched headers and sparse threads.
10972 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10973 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10974 (or (<= (length (cdr thread)) 1)
10975 (gnus-invisible-cut-children (cdr thread))))
10976 (setq thread (cadr thread))))
10979 (defun gnus-cut-threads (threads)
10980 "Cut off all uninteresting articles from the beginning of threads."
10981 (when (or (eq gnus-fetch-old-headers 'some)
10982 (eq gnus-build-sparse-threads 'some)
10983 (eq gnus-build-sparse-threads 'more))
10984 (let ((th threads))
10986 (setcar th (gnus-cut-thread (car th)))
10987 (setq th (cdr th)))))
10988 ;; Remove nixed out threads.
10989 (delq nil threads))
10991 (defun gnus-summary-initial-limit (&optional show-if-empty)
10992 "Figure out what the initial limit is supposed to be on group entry.
10993 This entails weeding out unwanted dormants, low-scored articles,
10994 fetch-old-headers verbiage, and so on."
10995 ;; Most groups have nothing to remove.
10996 (if (or gnus-inhibit-limiting
10997 (and (null gnus-newsgroup-dormant)
10998 (not (eq gnus-fetch-old-headers 'some))
10999 (null gnus-summary-expunge-below)
11000 (not (eq gnus-build-sparse-threads 'some))
11001 (not (eq gnus-build-sparse-threads 'more))
11002 (null gnus-thread-expunge-below)
11003 (not gnus-use-nocem)))
11005 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11006 (setq gnus-newsgroup-limit nil)
11009 (unless (car (symbol-value node))
11010 ;; These threads have no parents -- they are roots.
11011 (let ((nodes (cdr (symbol-value node)))
11014 (if (and gnus-thread-expunge-below
11015 (< (gnus-thread-total-score (car nodes))
11016 gnus-thread-expunge-below))
11017 (gnus-expunge-thread (pop nodes))
11018 (setq thread (pop nodes))
11019 (gnus-summary-limit-children thread))))))
11020 gnus-newsgroup-dependencies)
11021 ;; If this limitation resulted in an empty group, we might
11022 ;; pop the previous limit and use it instead.
11023 (when (and (not gnus-newsgroup-limit)
11025 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11026 gnus-newsgroup-limit))
11028 (defun gnus-summary-limit-children (thread)
11029 "Return 1 if this subthread is visible and 0 if it is not."
11030 ;; First we get the number of visible children to this thread. This
11031 ;; is done by recursing down the thread using this function, so this
11032 ;; will really go down to a leaf article first, before slowly
11033 ;; working its way up towards the root.
11037 (apply '+ (mapcar 'gnus-summary-limit-children
11040 (number (mail-header-number (car thread)))
11043 ;; If this article is dormant and has absolutely no visible
11044 ;; children, then this article isn't visible.
11045 (and (memq number gnus-newsgroup-dormant)
11047 ;; If this is "fetch-old-headered" and there is only one
11048 ;; visible child (or less), then we don't want this article.
11049 (and (eq gnus-fetch-old-headers 'some)
11050 (memq number gnus-newsgroup-ancient)
11052 ;; If this is a sparsely inserted article with no children,
11053 ;; we don't want it.
11054 (and (eq gnus-build-sparse-threads 'some)
11055 (memq number gnus-newsgroup-sparse)
11057 ;; If we use expunging, and this article is really
11058 ;; low-scored, then we don't want this article.
11059 (when (and gnus-summary-expunge-below
11061 (or (cdr (assq number gnus-newsgroup-scored))
11062 gnus-summary-default-score))
11063 gnus-summary-expunge-below))
11064 ;; We increase the expunge-tally here, but that has
11065 ;; nothing to do with the limits, really.
11066 (incf gnus-newsgroup-expunged-tally)
11067 ;; We also mark as read here, if that's wanted.
11068 (when (and gnus-summary-mark-below
11069 (< score gnus-summary-mark-below))
11070 (setq gnus-newsgroup-unreads
11071 (delq number gnus-newsgroup-unreads))
11072 (if gnus-newsgroup-auto-expire
11073 (push number gnus-newsgroup-expirable)
11074 (push (cons number gnus-low-score-mark)
11075 gnus-newsgroup-reads)))
11077 (and gnus-use-nocem
11078 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11079 ;; Nope, invisible article.
11081 ;; Ok, this article is to be visible, so we add it to the limit
11083 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11086 (defun gnus-expunge-thread (thread)
11087 "Mark all articles in THREAD as read."
11088 (let* ((number (mail-header-number (car thread))))
11089 (incf gnus-newsgroup-expunged-tally)
11090 ;; We also mark as read here, if that's wanted.
11091 (setq gnus-newsgroup-unreads
11092 (delq number gnus-newsgroup-unreads))
11093 (if gnus-newsgroup-auto-expire
11094 (push number gnus-newsgroup-expirable)
11095 (push (cons number gnus-low-score-mark)
11096 gnus-newsgroup-reads)))
11097 ;; Go recursively through all subthreads.
11098 (mapcar 'gnus-expunge-thread (cdr thread)))
11100 ;; Summary article oriented commands
11102 (defun gnus-summary-refer-parent-article (n)
11103 "Refer parent article N times.
11104 The difference between N and the number of articles fetched is returned."
11106 (gnus-set-global-variables)
11110 (let* ((header (gnus-summary-article-header))
11112 ;; If we try to find the parent of the currently
11113 ;; displayed article, then we take a look at the actual
11114 ;; References header, since this is slightly more
11115 ;; reliable than the References field we got from the
11117 (if (and (eq (mail-header-number header)
11118 (cdr gnus-article-current))
11119 (equal gnus-newsgroup-name
11120 (car gnus-article-current)))
11122 (set-buffer gnus-original-article-buffer)
11123 (nnheader-narrow-to-headers)
11125 (message-fetch-field "references")
11127 ;; It's not the current article, so we take a bet on
11128 ;; the value we got from the server.
11129 (mail-header-references header))))
11130 (if (setq ref (or ref (mail-header-references header)))
11131 (or (gnus-summary-refer-article (gnus-parent-id ref))
11132 (gnus-message 1 "Couldn't find parent"))
11133 (gnus-message 1 "No references in article %d"
11134 (gnus-summary-article-number))
11137 (gnus-summary-position-point)
11140 (defun gnus-summary-refer-references ()
11141 "Fetch all articles mentioned in the References header.
11142 Return how many articles were fetched."
11144 (gnus-set-global-variables)
11145 (let ((ref (mail-header-references (gnus-summary-article-header)))
11146 (current (gnus-summary-article-number))
11148 ;; For each Message-ID in the References header...
11149 (while (string-match "<[^>]*>" ref)
11151 ;; ... fetch that article.
11152 (gnus-summary-refer-article
11153 (prog1 (match-string 0 ref)
11154 (setq ref (substring ref (match-end 0))))))
11155 (gnus-summary-goto-subject current)
11156 (gnus-summary-position-point)
11159 (defun gnus-summary-refer-article (message-id)
11160 "Fetch an article specified by MESSAGE-ID."
11161 (interactive "sMessage-ID: ")
11162 (when (and (stringp message-id)
11163 (not (zerop (length message-id))))
11164 ;; Construct the correct Message-ID if necessary.
11165 ;; Suggested by tale@pawl.rpi.edu.
11166 (unless (string-match "^<" message-id)
11167 (setq message-id (concat "<" message-id)))
11168 (unless (string-match ">$" message-id)
11169 (setq message-id (concat message-id ">")))
11170 (let* ((header (gnus-id-to-header message-id))
11171 (sparse (and header
11172 (memq (mail-header-number header)
11173 gnus-newsgroup-sparse))))
11176 ;; The article is present in the buffer, to we just go to it.
11177 (gnus-summary-goto-article
11178 (mail-header-number header) nil header)
11180 (gnus-summary-update-article (mail-header-number header))))
11181 ;; We fetch the article
11182 (let ((gnus-override-method
11183 (and (gnus-news-group-p gnus-newsgroup-name)
11184 gnus-refer-article-method))
11186 ;; Start the special refer-article method, if necessary.
11187 (when (and gnus-refer-article-method
11188 (gnus-news-group-p gnus-newsgroup-name))
11189 (gnus-check-server gnus-refer-article-method))
11190 ;; Fetch the header, and display the article.
11191 (if (setq number (gnus-summary-insert-subject message-id))
11192 (gnus-summary-select-article nil nil nil number)
11193 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11195 (defun gnus-summary-enter-digest-group (&optional force)
11196 "Enter a digest group based on the current article."
11198 (gnus-set-global-variables)
11199 (gnus-summary-select-article)
11200 (let ((name (format "%s-%d"
11201 (gnus-group-prefixed-name
11202 gnus-newsgroup-name (list 'nndoc ""))
11203 gnus-current-article))
11204 (ogroup gnus-newsgroup-name)
11205 (case-fold-search t)
11206 (buf (current-buffer))
11209 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11210 (insert-buffer-substring gnus-original-article-buffer)
11212 (goto-char (point-min))
11213 (or (search-forward "\n\n" nil t) (point)))
11214 (goto-char (point-min))
11215 (delete-matching-lines "^\\(Path\\):\\|^From ")
11218 (if (gnus-group-read-ephemeral-group
11219 name `(nndoc ,name (nndoc-address
11221 (nndoc-article-type ,(if force 'digest 'guess))) t)
11222 ;; Make all postings to this group go to the parent group.
11223 (nconc (gnus-info-params (gnus-get-info name))
11224 (list (cons 'to-group ogroup)))
11225 ;; Couldn't select this doc group.
11226 (switch-to-buffer buf)
11227 (gnus-set-global-variables)
11228 (gnus-configure-windows 'summary)
11229 (gnus-message 3 "Article couldn't be entered?"))
11230 (kill-buffer dig))))
11232 (defun gnus-summary-isearch-article (&optional regexp-p)
11233 "Do incremental search forward on the current article.
11234 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11236 (gnus-set-global-variables)
11237 (gnus-summary-select-article)
11238 (gnus-configure-windows 'article)
11239 (gnus-eval-in-buffer-window gnus-article-buffer
11240 (goto-char (point-min))
11241 (isearch-forward regexp-p)))
11243 (defun gnus-summary-search-article-forward (regexp &optional backward)
11244 "Search for an article containing REGEXP forward.
11245 If BACKWARD, search backward instead."
11248 (format "Search article %s (regexp%s): "
11249 (if current-prefix-arg "backward" "forward")
11250 (if gnus-last-search-regexp
11251 (concat ", default " gnus-last-search-regexp)
11253 current-prefix-arg))
11254 (gnus-set-global-variables)
11255 (if (string-equal regexp "")
11256 (setq regexp (or gnus-last-search-regexp ""))
11257 (setq gnus-last-search-regexp regexp))
11258 (unless (gnus-summary-search-article regexp backward)
11259 (error "Search failed: \"%s\"" regexp)))
11261 (defun gnus-summary-search-article-backward (regexp)
11262 "Search for an article containing REGEXP backward."
11265 (format "Search article backward (regexp%s): "
11266 (if gnus-last-search-regexp
11267 (concat ", default " gnus-last-search-regexp)
11269 (gnus-summary-search-article-forward regexp 'backward))
11271 (defun gnus-summary-search-article (regexp &optional backward)
11272 "Search for an article containing REGEXP.
11273 Optional argument BACKWARD means do search for backward.
11274 `gnus-select-article-hook' is not called during the search."
11275 (let ((gnus-select-article-hook nil) ;Disable hook.
11276 (gnus-article-display-hook nil)
11277 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11280 're-search-backward 're-search-forward))
11281 (sum (current-buffer))
11283 (gnus-save-hidden-threads
11284 (gnus-summary-select-article)
11285 (set-buffer gnus-article-buffer)
11289 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11291 (re-search-backward regexp nil t)
11292 (re-search-forward regexp nil t))
11293 ;; We found the regexp.
11295 (setq found 'found)
11296 (beginning-of-line)
11298 (get-buffer-window (current-buffer))
11302 ;; We didn't find it, so we go to the next article.
11304 (if (not (if backward (gnus-summary-find-prev)
11305 (gnus-summary-find-next)))
11306 ;; No more articles.
11308 ;; Select the next article and adjust point.
11309 (gnus-summary-select-article)
11310 (set-buffer gnus-article-buffer)
11312 (goto-char (if backward (point-max) (point-min))))))
11313 (gnus-message 7 ""))
11314 ;; Return whether we found the regexp.
11315 (when (eq found 'found)
11316 (gnus-summary-show-thread)
11317 (gnus-summary-goto-subject gnus-current-article)
11318 (gnus-summary-position-point)
11321 (defun gnus-summary-find-matching (header regexp &optional backward unread
11323 "Return a list of all articles that match REGEXP on HEADER.
11324 The search stars on the current article and goes forwards unless
11325 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11326 If UNREAD is non-nil, only unread articles will
11327 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11328 in the comparisons."
11329 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11330 (gnus-data-find-list
11331 (gnus-summary-article-number) (gnus-data-list backward))))
11332 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11333 (case-fold-search (not not-case-fold))
11335 (or (fboundp (intern (concat "mail-header-" header)))
11336 (error "%s is not a valid header" header))
11338 (setq d (car data))
11339 (and (or (not unread) ; We want all articles...
11340 (gnus-data-unread-p d)) ; Or just unreads.
11341 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11342 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11343 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11344 (setq data (cdr data)))
11345 (nreverse articles)))
11347 (defun gnus-summary-execute-command (header regexp command &optional backward)
11348 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11349 If HEADER is an empty string (or nil), the match is done on the entire
11350 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11352 (list (let ((completion-ignore-case t))
11355 (mapcar (lambda (string) (list string))
11356 '("Number" "Subject" "From" "Lines" "Date"
11357 "Message-ID" "Xref" "References" "Body"))
11358 nil 'require-match))
11359 (read-string "Regexp: ")
11360 (read-key-sequence "Command: ")
11361 current-prefix-arg))
11362 (when (equal header "Body")
11364 (gnus-set-global-variables)
11365 ;; Hidden thread subtrees must be searched as well.
11366 (gnus-summary-show-all-threads)
11367 ;; We don't want to change current point nor window configuration.
11369 (save-window-excursion
11370 (gnus-message 6 "Executing %s..." (key-description command))
11371 ;; We'd like to execute COMMAND interactively so as to give arguments.
11372 (gnus-execute header regexp
11373 `(lambda () (call-interactively ',(key-binding command)))
11375 (gnus-message 6 "Executing %s...done" (key-description command)))))
11377 (defun gnus-summary-beginning-of-article ()
11378 "Scroll the article back to the beginning."
11380 (gnus-set-global-variables)
11381 (gnus-summary-select-article)
11382 (gnus-configure-windows 'article)
11383 (gnus-eval-in-buffer-window gnus-article-buffer
11385 (goto-char (point-min))
11386 (and gnus-break-pages (gnus-narrow-to-page))))
11388 (defun gnus-summary-end-of-article ()
11389 "Scroll to the end of the article."
11391 (gnus-set-global-variables)
11392 (gnus-summary-select-article)
11393 (gnus-configure-windows 'article)
11394 (gnus-eval-in-buffer-window gnus-article-buffer
11396 (goto-char (point-max))
11398 (and gnus-break-pages (gnus-narrow-to-page))))
11400 (defun gnus-summary-show-article (&optional arg)
11401 "Force re-fetching of the current article.
11402 If ARG (the prefix) is non-nil, show the raw article without any
11403 article massaging functions being run."
11405 (gnus-set-global-variables)
11407 ;; Select the article the normal way.
11408 (gnus-summary-select-article nil 'force)
11409 ;; Bind the article treatment functions to nil.
11410 (let ((gnus-have-all-headers t)
11411 gnus-article-display-hook
11412 gnus-article-prepare-hook
11415 (gnus-summary-select-article nil 'force)))
11416 (gnus-summary-goto-subject gnus-current-article)
11417 ; (gnus-configure-windows 'article)
11418 (gnus-summary-position-point))
11420 (defun gnus-summary-verbose-headers (&optional arg)
11421 "Toggle permanent full header display.
11422 If ARG is a positive number, turn header display on.
11423 If ARG is a negative number, turn header display off."
11425 (gnus-set-global-variables)
11426 (gnus-summary-toggle-header arg)
11427 (setq gnus-show-all-headers
11428 (cond ((or (not (numberp arg))
11430 (not gnus-show-all-headers))
11434 (defun gnus-summary-toggle-header (&optional arg)
11435 "Show the headers if they are hidden, or hide them if they are shown.
11436 If ARG is a positive number, show the entire header.
11437 If ARG is a negative number, hide the unwanted header lines."
11439 (gnus-set-global-variables)
11441 (set-buffer gnus-article-buffer)
11442 (let* ((buffer-read-only nil)
11443 (inhibit-point-motion-hooks t)
11444 (hidden (text-property-any
11445 (goto-char (point-min)) (search-forward "\n\n")
11448 (goto-char (point-min))
11449 (when (search-forward "\n\n" nil t)
11450 (delete-region (point-min) (1- (point))))
11451 (goto-char (point-min))
11453 (set-buffer gnus-original-article-buffer)
11454 (goto-char (point-min))
11455 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11456 (insert-buffer-substring gnus-original-article-buffer 1 e)
11457 (let ((gnus-inhibit-hiding t))
11458 (run-hooks 'gnus-article-display-hook))
11459 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11460 (gnus-article-hide-headers)))))
11462 (defun gnus-summary-show-all-headers ()
11463 "Make all header lines visible."
11465 (gnus-set-global-variables)
11466 (gnus-article-show-all-headers))
11468 (defun gnus-summary-toggle-mime (&optional arg)
11469 "Toggle MIME processing.
11470 If ARG is a positive number, turn MIME processing on."
11472 (gnus-set-global-variables)
11473 (setq gnus-show-mime
11474 (if (null arg) (not gnus-show-mime)
11475 (> (prefix-numeric-value arg) 0)))
11476 (gnus-summary-select-article t 'force))
11478 (defun gnus-summary-caesar-message (&optional arg)
11479 "Caesar rotate the current article by 13.
11480 The numerical prefix specifies how manu places to rotate each letter
11483 (gnus-set-global-variables)
11484 (gnus-summary-select-article)
11485 (let ((mail-header-separator ""))
11486 (gnus-eval-in-buffer-window gnus-article-buffer
11489 (let ((start (window-start))
11491 (message-caesar-buffer-body arg)
11492 (set-window-start (get-buffer-window (current-buffer)) start))))))
11494 (defun gnus-summary-stop-page-breaking ()
11495 "Stop page breaking in the current article."
11497 (gnus-set-global-variables)
11498 (gnus-summary-select-article)
11499 (gnus-eval-in-buffer-window gnus-article-buffer
11502 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11503 "Move the current article to a different newsgroup.
11504 If N is a positive number, move the N next articles.
11505 If N is a negative number, move the N previous articles.
11506 If N is nil and any articles have been marked with the process mark,
11507 move those articles instead.
11508 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11509 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11510 re-spool using this method.
11512 For this function to work, both the current newsgroup and the
11513 newsgroup that you want to move to have to support the `request-move'
11514 and `request-accept' functions."
11516 (unless action (setq action 'move))
11517 (gnus-set-global-variables)
11518 ;; Check whether the source group supports the required functions.
11519 (cond ((and (eq action 'move)
11520 (not (gnus-check-backend-function
11521 'request-move-article gnus-newsgroup-name)))
11522 (error "The current group does not support article moving"))
11523 ((and (eq action 'crosspost)
11524 (not (gnus-check-backend-function
11525 'request-replace-article gnus-newsgroup-name)))
11526 (error "The current group does not support article editing")))
11527 (let ((articles (gnus-summary-work-articles n))
11528 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11529 (names '((move "Move" "Moving")
11530 (copy "Copy" "Copying")
11531 (crosspost "Crosspost" "Crossposting")))
11532 (copy-buf (save-excursion
11533 (nnheader-set-temp-buffer " *copy article*")))
11534 art-group to-method new-xref article to-groups)
11535 (unless (assq action names)
11536 (error "Unknown action %s" action))
11537 ;; Read the newsgroup name.
11538 (when (and (not to-newsgroup)
11539 (not select-method))
11541 (gnus-read-move-group-name
11542 (cadr (assq action names))
11543 (symbol-value (intern (format "gnus-current-%s-group" action)))
11545 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11546 (setq to-method (or select-method
11547 (gnus-group-name-to-method to-newsgroup)))
11548 ;; Check the method we are to move this article to...
11549 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11550 (error "%s does not support article copying" (car to-method)))
11551 (or (gnus-check-server to-method)
11552 (error "Can't open server %s" (car to-method)))
11553 (gnus-message 6 "%s to %s: %s..."
11554 (caddr (assq action names))
11555 (or (car select-method) to-newsgroup) articles)
11557 (setq article (pop articles))
11561 ;; Move the article.
11563 (gnus-request-move-article
11564 article ; Article to move
11565 gnus-newsgroup-name ; From newsgrouo
11566 (nth 1 (gnus-find-method-for-group
11567 gnus-newsgroup-name)) ; Server
11568 (list 'gnus-request-accept-article
11569 to-newsgroup (list 'quote select-method)
11570 (not articles)) ; Accept form
11571 (not articles))) ; Only save nov last time
11572 ;; Copy the article.
11575 (set-buffer copy-buf)
11576 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11577 (gnus-request-accept-article
11578 to-newsgroup select-method (not articles))))
11579 ;; Crosspost the article.
11580 ((eq action 'crosspost)
11581 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11582 (setq new-xref (concat gnus-newsgroup-name ":" article))
11583 (if (and xref (not (string= xref "")))
11585 (when (string-match "^Xref: " xref)
11586 (setq xref (substring xref (match-end 0))))
11587 (setq new-xref (concat xref " " new-xref)))
11588 (setq new-xref (concat (system-name) " " new-xref)))
11590 (set-buffer copy-buf)
11591 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11592 (nnheader-replace-header "xref" new-xref)
11593 (gnus-request-accept-article
11594 to-newsgroup select-method (not articles)))))))
11595 (if (not art-group)
11596 (gnus-message 1 "Couldn't %s article %s"
11597 (cadr (assq action names)) article)
11600 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11602 (gnus-group-prefixed-name
11605 (gnus-find-method-for-group to-newsgroup)))
11606 gnus-newsrc-hashtb)))
11607 (info (nth 2 entry))
11608 (to-group (gnus-info-group info)))
11609 ;; Update the group that has been moved to.
11611 (memq action '(move copy)))
11612 (unless (member to-group to-groups)
11613 (push to-group to-groups))
11615 (unless (memq article gnus-newsgroup-unreads)
11616 (gnus-info-set-read
11617 info (gnus-add-to-range (gnus-info-read info)
11618 (list (cdr art-group)))))
11620 ;; Copy any marks over to the new group.
11621 (let ((marks gnus-article-mark-lists)
11622 (to-article (cdr art-group)))
11624 ;; See whether the article is to be put in the cache.
11625 (when gnus-use-cache
11626 (gnus-cache-possibly-enter-article
11627 to-group to-article
11628 (let ((header (copy-sequence
11629 (gnus-summary-article-header article))))
11630 (mail-header-set-number header to-article)
11632 (memq article gnus-newsgroup-marked)
11633 (memq article gnus-newsgroup-dormant)
11634 (memq article gnus-newsgroup-unreads)))
11637 (when (memq article (symbol-value
11638 (intern (format "gnus-newsgroup-%s"
11640 ;; If the other group is the same as this group,
11641 ;; then we have to add the mark to the list.
11642 (when (equal to-group gnus-newsgroup-name)
11643 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11646 (intern (format "gnus-newsgroup-%s"
11648 ;; Copy mark to other group.
11649 (gnus-add-marked-articles
11650 to-group (cdar marks) (list to-article) info))
11651 (setq marks (cdr marks)))))
11653 ;; Update the Xref header in this article to point to
11654 ;; the new crossposted article we have just created.
11655 (when (eq action 'crosspost)
11657 (set-buffer copy-buf)
11658 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11659 (nnheader-replace-header
11660 "xref" (concat new-xref " " (gnus-group-prefixed-name
11661 (car art-group) to-method)
11662 ":" (cdr art-group)))
11663 (gnus-request-replace-article
11664 article gnus-newsgroup-name (current-buffer)))))
11666 (gnus-summary-goto-subject article)
11667 (when (eq action 'move)
11668 (gnus-summary-mark-article article gnus-canceled-mark)))
11669 (gnus-summary-remove-process-mark article))
11670 ;; Re-activate all groups that have been moved to.
11672 (gnus-activate-group (pop to-groups)))
11674 (gnus-kill-buffer copy-buf)
11675 (gnus-summary-position-point)
11676 (gnus-set-mode-line 'summary)))
11678 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11679 "Move the current article to a different newsgroup.
11680 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11681 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11682 re-spool using this method."
11684 (gnus-summary-move-article n nil select-method 'copy))
11686 (defun gnus-summary-crosspost-article (&optional n)
11687 "Crosspost the current article to some other group."
11689 (gnus-summary-move-article n nil nil 'crosspost))
11691 (defvar gnus-summary-respool-default-method nil
11692 "Default method for respooling an article.
11693 If nil, use to the current newsgroup method.")
11695 (defun gnus-summary-respool-article (&optional n method)
11696 "Respool the current article.
11697 The article will be squeezed through the mail spooling process again,
11698 which means that it will be put in some mail newsgroup or other
11699 depending on `nnmail-split-methods'.
11700 If N is a positive number, respool the N next articles.
11701 If N is a negative number, respool the N previous articles.
11702 If N is nil and any articles have been marked with the process mark,
11703 respool those articles instead.
11705 Respooling can be done both from mail groups and \"real\" newsgroups.
11706 In the former case, the articles in question will be moved from the
11707 current group into whatever groups they are destined to. In the
11708 latter case, they will be copied into the relevant groups."
11710 (list current-prefix-arg
11711 (let* ((methods (gnus-methods-using 'respool))
11713 (symbol-name (or gnus-summary-respool-default-method
11714 (car (gnus-find-method-for-group
11715 gnus-newsgroup-name)))))
11717 (gnus-completing-read
11718 methname "What backend do you want to use when respooling?"
11719 methods nil t nil 'gnus-method-history))
11722 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11723 (list (intern method) ""))
11727 (cdr (completing-read
11729 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11730 (gnus-set-global-variables)
11732 (error "No method given for respooling"))
11733 (if (assoc (symbol-name
11734 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11735 (gnus-methods-using 'respool))
11736 (gnus-summary-move-article n nil method)
11737 (gnus-summary-copy-article n nil method)))
11739 (defun gnus-summary-import-article (file)
11740 "Import a random file into a mail newsgroup."
11741 (interactive "fImport file: ")
11742 (gnus-set-global-variables)
11743 (let ((group gnus-newsgroup-name)
11744 (now (current-time))
11746 (or (gnus-check-backend-function 'request-accept-article group)
11747 (error "%s does not support article importing" group))
11748 (or (file-readable-p file)
11749 (not (file-regular-p file))
11750 (error "Can't read %s" file))
11752 (set-buffer (get-buffer-create " *import file*"))
11753 (buffer-disable-undo (current-buffer))
11755 (insert-file-contents file)
11756 (goto-char (point-min))
11757 (unless (nnheader-article-p)
11758 ;; This doesn't look like an article, so we fudge some headers.
11759 (setq atts (file-attributes file)
11760 lines (count-lines (point-min) (point-max)))
11761 (insert "From: " (read-string "From: ") "\n"
11762 "Subject: " (read-string "Subject: ") "\n"
11763 "Date: " (timezone-make-date-arpa-standard
11764 (current-time-string (nth 5 atts))
11765 (current-time-zone now)
11766 (current-time-zone now)) "\n"
11767 "Message-ID: " (message-make-message-id) "\n"
11768 "Lines: " (int-to-string lines) "\n"
11769 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11770 (gnus-request-accept-article group nil t)
11771 (kill-buffer (current-buffer)))))
11773 (defun gnus-summary-expire-articles (&optional now)
11774 "Expire all articles that are marked as expirable in the current group."
11776 (gnus-set-global-variables)
11777 (when (gnus-check-backend-function
11778 'request-expire-articles gnus-newsgroup-name)
11779 ;; This backend supports expiry.
11780 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11781 (expirable (if total
11782 (gnus-list-of-read-articles gnus-newsgroup-name)
11783 (setq gnus-newsgroup-expirable
11784 (sort gnus-newsgroup-expirable '<))))
11785 (expiry-wait (if now 'immediate
11786 (gnus-group-get-parameter
11787 gnus-newsgroup-name 'expiry-wait)))
11790 ;; There are expirable articles in this group, so we run them
11791 ;; through the expiry process.
11792 (gnus-message 6 "Expiring articles...")
11793 ;; The list of articles that weren't expired is returned.
11795 (let ((nnmail-expiry-wait-function nil)
11796 (nnmail-expiry-wait expiry-wait))
11797 (setq es (gnus-request-expire-articles
11798 expirable gnus-newsgroup-name)))
11799 (setq es (gnus-request-expire-articles
11800 expirable gnus-newsgroup-name)))
11801 (or total (setq gnus-newsgroup-expirable es))
11802 ;; We go through the old list of expirable, and mark all
11803 ;; really expired articles as nonexistent.
11804 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11805 (let ((gnus-use-cache nil))
11807 (unless (memq (car expirable) es)
11808 (when (gnus-data-find (car expirable))
11809 (gnus-summary-mark-article
11810 (car expirable) gnus-canceled-mark)))
11811 (setq expirable (cdr expirable)))))
11812 (gnus-message 6 "Expiring articles...done")))))
11814 (defun gnus-summary-expire-articles-now ()
11815 "Expunge all expirable articles in the current group.
11816 This means that *all* articles that are marked as expirable will be
11817 deleted forever, right now."
11819 (gnus-set-global-variables)
11820 (or gnus-expert-user
11822 "Are you really, really, really sure you want to delete all these messages? ")
11824 (gnus-summary-expire-articles t))
11826 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11827 (defun gnus-summary-delete-article (&optional n)
11828 "Delete the N next (mail) articles.
11829 This command actually deletes articles. This is not a marking
11830 command. The article will disappear forever from your life, never to
11832 If N is negative, delete backwards.
11833 If N is nil and articles have been marked with the process mark,
11834 delete these instead."
11836 (gnus-set-global-variables)
11837 (or (gnus-check-backend-function 'request-expire-articles
11838 gnus-newsgroup-name)
11839 (error "The current newsgroup does not support article deletion."))
11840 ;; Compute the list of articles to delete.
11841 (let ((articles (gnus-summary-work-articles n))
11843 (if (and gnus-novice-user
11844 (not (gnus-y-or-n-p
11845 (format "Do you really want to delete %s forever? "
11846 (if (> (length articles) 1)
11847 (format "these %s articles" (length articles))
11848 "this article")))))
11850 ;; Delete the articles.
11851 (setq not-deleted (gnus-request-expire-articles
11852 articles gnus-newsgroup-name 'force))
11854 (gnus-summary-remove-process-mark (car articles))
11855 ;; The backend might not have been able to delete the article
11857 (or (memq (car articles) not-deleted)
11858 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11859 (setq articles (cdr articles))))
11860 (gnus-summary-position-point)
11861 (gnus-set-mode-line 'summary)
11864 (defun gnus-summary-edit-article (&optional force)
11865 "Enter into a buffer and edit the current article.
11866 This will have permanent effect only in mail groups.
11867 If FORCE is non-nil, allow editing of articles even in read-only
11871 (set-buffer gnus-summary-buffer)
11872 (gnus-set-global-variables)
11873 (when (and (not force)
11874 (gnus-group-read-only-p))
11875 (error "The current newsgroup does not support article editing."))
11876 (gnus-summary-select-article t nil t)
11877 (gnus-configure-windows 'article)
11878 (select-window (get-buffer-window gnus-article-buffer))
11879 (gnus-message 6 "C-c C-c to end edits")
11880 (setq buffer-read-only nil)
11882 (use-local-map (copy-keymap (current-local-map)))
11883 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11884 (buffer-enable-undo)
11886 (goto-char (point-min))
11887 (search-forward "\n\n" nil t)))
11889 (defun gnus-summary-edit-article-done ()
11890 "Make edits to the current article permanent."
11892 (if (gnus-group-read-only-p)
11894 (let ((beep (not (eq major-mode 'text-mode))))
11895 (gnus-summary-edit-article-postpone)
11898 3 "The current newsgroup does not support article editing."))))
11899 (let ((buf (format "%s" (buffer-string))))
11902 (if (not (gnus-request-replace-article
11903 (cdr gnus-article-current) (car gnus-article-current)
11905 (error "Couldn't replace article.")
11906 (gnus-article-mode)
11907 (use-local-map gnus-article-mode-map)
11908 (setq buffer-read-only t)
11909 (buffer-disable-undo (current-buffer))
11910 (gnus-configure-windows 'summary)
11911 (gnus-summary-update-article (cdr gnus-article-current))
11912 (when gnus-use-cache
11913 (gnus-cache-update-article
11914 (car gnus-article-current) (cdr gnus-article-current)))
11915 (when gnus-keep-backlog
11916 (gnus-backlog-remove-article
11917 (car gnus-article-current) (cdr gnus-article-current))))
11919 (when (get-buffer gnus-original-article-buffer)
11920 (set-buffer gnus-original-article-buffer)
11921 (setq gnus-original-article nil)))
11922 (setq gnus-article-current nil
11923 gnus-current-article nil)
11924 (run-hooks 'gnus-article-display-hook)
11925 (and (gnus-visual-p 'summary-highlight 'highlight)
11926 (run-hooks 'gnus-visual-mark-article-hook)))))
11928 (defun gnus-summary-edit-article-postpone ()
11929 "Postpone changes to the current article."
11931 (gnus-article-mode)
11932 (use-local-map gnus-article-mode-map)
11933 (setq buffer-read-only t)
11934 (buffer-disable-undo (current-buffer))
11935 (gnus-configure-windows 'summary)
11936 (and (gnus-visual-p 'summary-highlight 'highlight)
11937 (run-hooks 'gnus-visual-mark-article-hook)))
11939 (defun gnus-summary-respool-query ()
11940 "Query where the respool algorithm would put this article."
11942 (gnus-set-global-variables)
11943 (gnus-summary-select-article)
11945 (set-buffer gnus-article-buffer)
11947 (goto-char (point-min))
11948 (search-forward "\n\n")
11949 (narrow-to-region (point-min) (point))
11950 (pp-eval-expression
11951 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11953 ;; Summary marking commands.
11955 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11956 "Mark articles which has the same subject as read, and then select the next.
11957 If UNMARK is positive, remove any kind of mark.
11958 If UNMARK is negative, tick articles."
11960 (gnus-set-global-variables)
11962 (setq unmark (prefix-numeric-value unmark)))
11964 (gnus-summary-mark-same-subject
11965 (gnus-summary-article-subject) unmark)))
11966 ;; Select next unread article. If auto-select-same mode, should
11967 ;; select the first unread article.
11968 (gnus-summary-next-article t (and gnus-auto-select-same
11969 (gnus-summary-article-subject)))
11970 (gnus-message 7 "%d article%s marked as %s"
11971 count (if (= count 1) " is" "s are")
11972 (if unmark "unread" "read"))))
11974 (defun gnus-summary-kill-same-subject (&optional unmark)
11975 "Mark articles which has the same subject as read.
11976 If UNMARK is positive, remove any kind of mark.
11977 If UNMARK is negative, tick articles."
11979 (gnus-set-global-variables)
11981 (setq unmark (prefix-numeric-value unmark)))
11983 (gnus-summary-mark-same-subject
11984 (gnus-summary-article-subject) unmark)))
11985 ;; If marked as read, go to next unread subject.
11987 ;; Go to next unread subject.
11988 (gnus-summary-next-subject 1 t))
11989 (gnus-message 7 "%d articles are marked as %s"
11990 count (if unmark "unread" "read"))))
11992 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11993 "Mark articles with same SUBJECT as read, and return marked number.
11994 If optional argument UNMARK is positive, remove any kinds of marks.
11995 If optional argument UNMARK is negative, mark articles as unread instead."
11999 ((null unmark) ; Mark as read.
12002 (gnus-summary-mark-article-as-read gnus-killed-mark)
12003 (gnus-summary-show-thread) t)
12004 (gnus-summary-find-subject subject))
12005 (setq count (1+ count))))
12006 ((> unmark 0) ; Tick.
12009 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12010 (gnus-summary-show-thread) t)
12011 (gnus-summary-find-subject subject))
12012 (setq count (1+ count))))
12013 (t ; Mark as unread.
12016 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12017 (gnus-summary-show-thread) t)
12018 (gnus-summary-find-subject subject))
12019 (setq count (1+ count)))))
12020 (gnus-set-mode-line 'summary)
12021 ;; Return the number of marked articles.
12024 (defun gnus-summary-mark-as-processable (n &optional unmark)
12025 "Set the process mark on the next N articles.
12026 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12027 the process mark instead. The difference between N and the actual
12028 number of articles marked is returned."
12030 (gnus-set-global-variables)
12031 (let ((backward (< n 0))
12036 (gnus-summary-remove-process-mark
12037 (gnus-summary-article-number))
12038 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12039 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12041 (if (/= 0 n) (gnus-message 7 "No more articles"))
12042 (gnus-summary-recenter)
12043 (gnus-summary-position-point)
12046 (defun gnus-summary-unmark-as-processable (n)
12047 "Remove the process mark from the next N articles.
12048 If N is negative, mark backward instead. The difference between N and
12049 the actual number of articles marked is returned."
12051 (gnus-set-global-variables)
12052 (gnus-summary-mark-as-processable n t))
12054 (defun gnus-summary-unmark-all-processable ()
12055 "Remove the process mark from all articles."
12057 (gnus-set-global-variables)
12059 (while gnus-newsgroup-processable
12060 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12061 (gnus-summary-position-point))
12063 (defun gnus-summary-mark-as-expirable (n)
12064 "Mark N articles forward as expirable.
12065 If N is negative, mark backward instead. The difference between N and
12066 the actual number of articles marked is returned."
12068 (gnus-set-global-variables)
12069 (gnus-summary-mark-forward n gnus-expirable-mark))
12071 (defun gnus-summary-mark-article-as-replied (article)
12072 "Mark ARTICLE replied and update the summary line."
12073 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12074 (let ((buffer-read-only nil))
12075 (when (gnus-summary-goto-subject article)
12076 (gnus-summary-update-secondary-mark article))))
12078 (defun gnus-summary-set-bookmark (article)
12079 "Set a bookmark in current article."
12080 (interactive (list (gnus-summary-article-number)))
12081 (gnus-set-global-variables)
12082 (if (or (not (get-buffer gnus-article-buffer))
12083 (not gnus-current-article)
12084 (not gnus-article-current)
12085 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12086 (error "No current article selected"))
12087 ;; Remove old bookmark, if one exists.
12088 (let ((old (assq article gnus-newsgroup-bookmarks)))
12089 (if old (setq gnus-newsgroup-bookmarks
12090 (delq old gnus-newsgroup-bookmarks))))
12091 ;; Set the new bookmark, which is on the form
12092 ;; (article-number . line-number-in-body).
12093 (setq gnus-newsgroup-bookmarks
12097 (set-buffer gnus-article-buffer)
12101 (goto-char (point-min))
12102 (search-forward "\n\n" nil t)
12105 gnus-newsgroup-bookmarks))
12106 (gnus-message 6 "A bookmark has been added to the current article."))
12108 (defun gnus-summary-remove-bookmark (article)
12109 "Remove the bookmark from the current article."
12110 (interactive (list (gnus-summary-article-number)))
12111 (gnus-set-global-variables)
12112 ;; Remove old bookmark, if one exists.
12113 (let ((old (assq article gnus-newsgroup-bookmarks)))
12116 (setq gnus-newsgroup-bookmarks
12117 (delq old gnus-newsgroup-bookmarks))
12118 (gnus-message 6 "Removed bookmark."))
12119 (gnus-message 6 "No bookmark in current article."))))
12121 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12122 (defun gnus-summary-mark-as-dormant (n)
12123 "Mark N articles forward as dormant.
12124 If N is negative, mark backward instead. The difference between N and
12125 the actual number of articles marked is returned."
12127 (gnus-set-global-variables)
12128 (gnus-summary-mark-forward n gnus-dormant-mark))
12130 (defun gnus-summary-set-process-mark (article)
12131 "Set the process mark on ARTICLE and update the summary line."
12132 (setq gnus-newsgroup-processable
12134 (delq article gnus-newsgroup-processable)))
12135 (when (gnus-summary-goto-subject article)
12136 (gnus-summary-show-thread)
12137 (gnus-summary-update-secondary-mark article)))
12139 (defun gnus-summary-remove-process-mark (article)
12140 "Remove the process mark from ARTICLE and update the summary line."
12141 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12142 (when (gnus-summary-goto-subject article)
12143 (gnus-summary-show-thread)
12144 (gnus-summary-update-secondary-mark article)))
12146 (defun gnus-summary-set-saved-mark (article)
12147 "Set the process mark on ARTICLE and update the summary line."
12148 (push article gnus-newsgroup-saved)
12149 (when (gnus-summary-goto-subject article)
12150 (gnus-summary-update-secondary-mark article)))
12152 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12153 "Mark N articles as read forwards.
12154 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12155 The difference between N and the actual number of articles marked is
12158 (gnus-set-global-variables)
12159 (let ((backward (< n 0))
12160 (gnus-summary-goto-unread
12161 (and gnus-summary-goto-unread
12162 (not (eq gnus-summary-goto-unread 'never))
12163 (not (memq mark (list gnus-unread-mark
12164 gnus-ticked-mark gnus-dormant-mark)))))
12166 (mark (or mark gnus-del-mark)))
12167 (while (and (> n 0)
12168 (gnus-summary-mark-article nil mark no-expire)
12169 (zerop (gnus-summary-next-subject
12171 (and gnus-summary-goto-unread
12172 (not (eq gnus-summary-goto-unread 'never)))
12175 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12176 (gnus-summary-recenter)
12177 (gnus-summary-position-point)
12178 (gnus-set-mode-line 'summary)
12181 (defun gnus-summary-mark-article-as-read (mark)
12182 "Mark the current article quickly as read with MARK."
12183 (let ((article (gnus-summary-article-number)))
12184 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12185 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12186 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12187 (setq gnus-newsgroup-reads
12188 (cons (cons article mark) gnus-newsgroup-reads))
12189 ;; Possibly remove from cache, if that is used.
12190 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12191 ;; Allow the backend to change the mark.
12192 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12193 ;; Check for auto-expiry.
12194 (when (and gnus-newsgroup-auto-expire
12195 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12196 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12197 (= mark gnus-ancient-mark)
12198 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12199 (setq mark gnus-expirable-mark)
12200 (push article gnus-newsgroup-expirable))
12201 ;; Set the mark in the buffer.
12202 (gnus-summary-update-mark mark 'unread)
12205 (defun gnus-summary-mark-article-as-unread (mark)
12206 "Mark the current article quickly as unread with MARK."
12207 (let ((article (gnus-summary-article-number)))
12209 (gnus-error 1 "Unmarkable article")
12210 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12211 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12212 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12213 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12214 (cond ((= mark gnus-ticked-mark)
12215 (push article gnus-newsgroup-marked))
12216 ((= mark gnus-dormant-mark)
12217 (push article gnus-newsgroup-dormant))
12219 (push article gnus-newsgroup-unreads)))
12220 (setq gnus-newsgroup-reads
12221 (delq (assq article gnus-newsgroup-reads)
12222 gnus-newsgroup-reads))
12224 ;; See whether the article is to be put in the cache.
12225 (and gnus-use-cache
12226 (vectorp (gnus-summary-article-header article))
12228 (gnus-cache-possibly-enter-article
12229 gnus-newsgroup-name article
12230 (gnus-summary-article-header article)
12231 (= mark gnus-ticked-mark)
12232 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12235 (gnus-summary-update-mark mark 'unread))
12238 (defun gnus-summary-mark-article (&optional article mark no-expire)
12239 "Mark ARTICLE with MARK. MARK can be any character.
12240 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12241 `??' (dormant) and `?E' (expirable).
12242 If MARK is nil, then the default character `?D' is used.
12243 If ARTICLE is nil, then the article on the current line will be
12245 ;; The mark might be a string.
12246 (and (stringp mark)
12247 (setq mark (aref mark 0)))
12248 ;; If no mark is given, then we check auto-expiring.
12249 (and (not no-expire)
12250 gnus-newsgroup-auto-expire
12252 (and (numberp mark)
12253 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12254 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12255 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12256 (setq mark gnus-expirable-mark))
12257 (let* ((mark (or mark gnus-del-mark))
12258 (article (or article (gnus-summary-article-number))))
12259 (or article (error "No article on current line"))
12260 (if (or (= mark gnus-unread-mark)
12261 (= mark gnus-ticked-mark)
12262 (= mark gnus-dormant-mark))
12263 (gnus-mark-article-as-unread article mark)
12264 (gnus-mark-article-as-read article mark))
12266 ;; See whether the article is to be put in the cache.
12267 (and gnus-use-cache
12268 (not (= mark gnus-canceled-mark))
12269 (vectorp (gnus-summary-article-header article))
12271 (gnus-cache-possibly-enter-article
12272 gnus-newsgroup-name article
12273 (gnus-summary-article-header article)
12274 (= mark gnus-ticked-mark)
12275 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12277 (if (gnus-summary-goto-subject article nil t)
12278 (let ((buffer-read-only nil))
12279 (gnus-summary-show-thread)
12281 (gnus-summary-update-mark mark 'unread)
12284 (defun gnus-summary-update-secondary-mark (article)
12285 "Update the secondary (read, process, cache) mark."
12286 (gnus-summary-update-mark
12287 (cond ((memq article gnus-newsgroup-processable)
12289 ((memq article gnus-newsgroup-cached)
12291 ((memq article gnus-newsgroup-replied)
12293 ((memq article gnus-newsgroup-saved)
12295 (t gnus-unread-mark))
12297 (when (gnus-visual-p 'summary-highlight 'highlight)
12298 (run-hooks 'gnus-summary-update-hook))
12301 (defun gnus-summary-update-mark (mark type)
12302 (beginning-of-line)
12303 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12304 (buffer-read-only nil))
12306 (<= (+ forward (point)) (point-max)))
12307 ;; Go to the right position on the line.
12308 (goto-char (+ forward (point)))
12309 ;; Replace the old mark with the new mark.
12310 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12311 ;; Optionally update the marks by some user rule.
12312 (when (eq type 'unread)
12313 (gnus-data-set-mark
12314 (gnus-data-find (gnus-summary-article-number)) mark)
12315 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12317 (defun gnus-mark-article-as-read (article &optional mark)
12318 "Enter ARTICLE in the pertinent lists and remove it from others."
12319 ;; Make the article expirable.
12320 (let ((mark (or mark gnus-del-mark)))
12321 (if (= mark gnus-expirable-mark)
12322 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12323 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12324 ;; Remove from unread and marked lists.
12325 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12326 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12327 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12328 (push (cons article mark) gnus-newsgroup-reads)
12329 ;; Possibly remove from cache, if that is used.
12330 (when gnus-use-cache
12331 (gnus-cache-enter-remove-article article))))
12333 (defun gnus-mark-article-as-unread (article &optional mark)
12334 "Enter ARTICLE in the pertinent lists and remove it from others."
12335 (let ((mark (or mark gnus-ticked-mark)))
12336 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12337 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12338 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12339 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12340 (cond ((= mark gnus-ticked-mark)
12341 (push article gnus-newsgroup-marked))
12342 ((= mark gnus-dormant-mark)
12343 (push article gnus-newsgroup-dormant))
12345 (push article gnus-newsgroup-unreads)))
12346 (setq gnus-newsgroup-reads
12347 (delq (assq article gnus-newsgroup-reads)
12348 gnus-newsgroup-reads))))
12350 (defalias 'gnus-summary-mark-as-unread-forward
12351 'gnus-summary-tick-article-forward)
12352 (make-obsolete 'gnus-summary-mark-as-unread-forward
12353 'gnus-summary-tick-article-forward)
12354 (defun gnus-summary-tick-article-forward (n)
12355 "Tick N articles forwards.
12356 If N is negative, tick backwards instead.
12357 The difference between N and the number of articles ticked is returned."
12359 (gnus-summary-mark-forward n gnus-ticked-mark))
12361 (defalias 'gnus-summary-mark-as-unread-backward
12362 'gnus-summary-tick-article-backward)
12363 (make-obsolete 'gnus-summary-mark-as-unread-backward
12364 'gnus-summary-tick-article-backward)
12365 (defun gnus-summary-tick-article-backward (n)
12366 "Tick N articles backwards.
12367 The difference between N and the number of articles ticked is returned."
12369 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12371 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12372 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12373 (defun gnus-summary-tick-article (&optional article clear-mark)
12374 "Mark current article as unread.
12375 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12376 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12378 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12379 gnus-ticked-mark)))
12381 (defun gnus-summary-mark-as-read-forward (n)
12382 "Mark N articles as read forwards.
12383 If N is negative, mark backwards instead.
12384 The difference between N and the actual number of articles marked is
12387 (gnus-summary-mark-forward n gnus-del-mark t))
12389 (defun gnus-summary-mark-as-read-backward (n)
12390 "Mark the N articles as read backwards.
12391 The difference between N and the actual number of articles marked is
12394 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12396 (defun gnus-summary-mark-as-read (&optional article mark)
12397 "Mark current article as read.
12398 ARTICLE specifies the article to be marked as read.
12399 MARK specifies a string to be inserted at the beginning of the line."
12400 (gnus-summary-mark-article article mark))
12402 (defun gnus-summary-clear-mark-forward (n)
12403 "Clear marks from N articles forward.
12404 If N is negative, clear backward instead.
12405 The difference between N and the number of marks cleared is returned."
12407 (gnus-summary-mark-forward n gnus-unread-mark))
12409 (defun gnus-summary-clear-mark-backward (n)
12410 "Clear marks from N articles backward.
12411 The difference between N and the number of marks cleared is returned."
12413 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12415 (defun gnus-summary-mark-unread-as-read ()
12416 "Intended to be used by `gnus-summary-mark-article-hook'."
12417 (when (memq gnus-current-article gnus-newsgroup-unreads)
12418 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12420 (defun gnus-summary-mark-read-and-unread-as-read ()
12421 "Intended to be used by `gnus-summary-mark-article-hook'."
12422 (let ((mark (gnus-summary-article-mark)))
12423 (when (or (gnus-unread-mark-p mark)
12424 (gnus-read-mark-p mark))
12425 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12427 (defun gnus-summary-mark-region-as-read (point mark all)
12428 "Mark all unread articles between point and mark as read.
12429 If given a prefix, mark all articles between point and mark as read,
12430 even ticked and dormant ones."
12431 (interactive "r\nP")
12435 (beginning-of-line)
12440 (memq (setq article (gnus-summary-article-number))
12441 gnus-newsgroup-unreads))
12442 (gnus-summary-mark-article article gnus-del-mark))
12444 (gnus-summary-find-next))))))
12446 (defun gnus-summary-mark-below (score mark)
12447 "Mark articles with score less than SCORE with MARK."
12448 (interactive "P\ncMark: ")
12449 (gnus-set-global-variables)
12450 (setq score (if score
12451 (prefix-numeric-value score)
12452 (or gnus-summary-default-score 0)))
12454 (set-buffer gnus-summary-buffer)
12455 (goto-char (point-min))
12458 (and (< (gnus-summary-article-score) score)
12459 (gnus-summary-mark-article nil mark))
12460 (gnus-summary-find-next)))))
12462 (defun gnus-summary-kill-below (&optional score)
12463 "Mark articles with score below SCORE as read."
12465 (gnus-set-global-variables)
12466 (gnus-summary-mark-below score gnus-killed-mark))
12468 (defun gnus-summary-clear-above (&optional score)
12469 "Clear all marks from articles with score above SCORE."
12471 (gnus-set-global-variables)
12472 (gnus-summary-mark-above score gnus-unread-mark))
12474 (defun gnus-summary-tick-above (&optional score)
12475 "Tick all articles with score above SCORE."
12477 (gnus-set-global-variables)
12478 (gnus-summary-mark-above score gnus-ticked-mark))
12480 (defun gnus-summary-mark-above (score mark)
12481 "Mark articles with score over SCORE with MARK."
12482 (interactive "P\ncMark: ")
12483 (gnus-set-global-variables)
12484 (setq score (if score
12485 (prefix-numeric-value score)
12486 (or gnus-summary-default-score 0)))
12488 (set-buffer gnus-summary-buffer)
12489 (goto-char (point-min))
12491 (if (> (gnus-summary-article-score) score)
12492 (gnus-summary-mark-article nil mark))
12494 (gnus-summary-find-next)))))
12496 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12497 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12498 (defun gnus-summary-limit-include-expunged ()
12499 "Display all the hidden articles that were expunged for low scores."
12501 (gnus-set-global-variables)
12502 (let ((buffer-read-only nil))
12503 (let ((scored gnus-newsgroup-scored)
12506 (or (gnus-summary-goto-subject (caar scored))
12507 (and (setq h (gnus-summary-article-header (caar scored)))
12508 (< (cdar scored) gnus-summary-expunge-below)
12509 (setq headers (cons h headers))))
12510 (setq scored (cdr scored)))
12511 (or headers (error "No expunged articles hidden."))
12512 (goto-char (point-min))
12513 (gnus-summary-prepare-unthreaded (nreverse headers)))
12514 (goto-char (point-min))
12515 (gnus-summary-position-point)))
12517 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12518 "Mark all articles not marked as unread in this newsgroup as read.
12519 If prefix argument ALL is non-nil, all articles are marked as read.
12520 If QUIETLY is non-nil, no questions will be asked.
12521 If TO-HERE is non-nil, it should be a point in the buffer. All
12522 articles before this point will be marked as read.
12523 The number of articles marked as read is returned."
12525 (gnus-set-global-variables)
12528 (not gnus-interactive-catchup) ;Without confirmation?
12532 "Mark absolutely all articles as read? "
12533 "Mark all unread articles as read? ")))
12535 (not gnus-newsgroup-adaptive)
12536 (not gnus-newsgroup-auto-expire))
12539 (setq gnus-newsgroup-marked nil
12540 gnus-newsgroup-dormant nil))
12541 (setq gnus-newsgroup-unreads nil))
12542 ;; We actually mark all articles as canceled, which we
12543 ;; have to do when using auto-expiry or adaptive scoring.
12544 (gnus-summary-show-all-threads)
12545 (if (gnus-summary-first-subject (not all))
12547 (if to-here (< (point) to-here) t)
12548 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12549 (gnus-summary-find-next (not all)))))
12551 (setq gnus-newsgroup-unreads nil))
12552 (gnus-set-mode-line 'summary)))
12553 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12554 (if (and (not to-here) (eq 'nnvirtual (car method)))
12555 (nnvirtual-catchup-group
12556 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12557 (gnus-summary-position-point)))
12559 (defun gnus-summary-catchup-to-here (&optional all)
12560 "Mark all unticked articles before the current one as read.
12561 If ALL is non-nil, also mark ticked and dormant articles as read."
12563 (gnus-set-global-variables)
12565 (gnus-save-hidden-threads
12566 (let ((beg (point)))
12567 ;; We check that there are unread articles.
12568 (when (or all (gnus-summary-find-prev))
12569 (gnus-summary-catchup all t beg)))))
12570 (gnus-summary-position-point))
12572 (defun gnus-summary-catchup-all (&optional quietly)
12573 "Mark all articles in this newsgroup as read."
12575 (gnus-set-global-variables)
12576 (gnus-summary-catchup t quietly))
12578 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12579 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12580 If prefix argument ALL is non-nil, all articles are marked as read."
12582 (gnus-set-global-variables)
12583 (gnus-summary-catchup all quietly nil 'fast)
12584 ;; Select next newsgroup or exit.
12585 (if (eq gnus-auto-select-next 'quietly)
12586 (gnus-summary-next-group nil)
12587 (gnus-summary-exit)))
12589 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12590 "Mark all articles in this newsgroup as read, and then exit."
12592 (gnus-set-global-variables)
12593 (gnus-summary-catchup-and-exit t quietly))
12595 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12596 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12597 "Mark all articles in this group as read and select the next group.
12598 If given a prefix, mark all articles, unread as well as ticked, as
12601 (gnus-set-global-variables)
12603 (gnus-summary-catchup all))
12604 (gnus-summary-next-article t nil nil t))
12606 ;; Thread-based commands.
12608 (defun gnus-summary-articles-in-thread (&optional article)
12609 "Return a list of all articles in the current thread.
12610 If ARTICLE is non-nil, return all articles in the thread that starts
12611 with that article."
12612 (let* ((article (or article (gnus-summary-article-number)))
12613 (data (gnus-data-find-list article))
12614 (top-level (gnus-data-level (car data)))
12616 (cond ((null gnus-thread-operation-ignore-subject)
12617 (gnus-simplify-subject-re
12618 (mail-header-subject (gnus-data-header (car data)))))
12619 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12620 (gnus-simplify-subject-fuzzy
12621 (mail-header-subject (gnus-data-header (car data)))))
12623 (end-point (save-excursion
12624 (if (gnus-summary-go-to-next-thread)
12625 (point) (point-max))))
12628 (< (gnus-data-pos (car data)) end-point))
12629 (when (or (not top-subject)
12630 (string= top-subject
12631 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12632 (gnus-simplify-subject-fuzzy
12633 (mail-header-subject
12634 (gnus-data-header (car data))))
12635 (gnus-simplify-subject-re
12636 (mail-header-subject
12637 (gnus-data-header (car data)))))))
12638 (push (gnus-data-number (car data)) articles))
12639 (unless (and (setq data (cdr data))
12640 (> (gnus-data-level (car data)) top-level))
12642 ;; Return the list of articles.
12643 (nreverse articles)))
12645 (defun gnus-summary-rethread-current ()
12646 "Rethread the thread the current article is part of."
12648 (gnus-set-global-variables)
12649 (let* ((gnus-show-threads t)
12650 (article (gnus-summary-article-number))
12651 (id (mail-header-id (gnus-summary-article-header)))
12652 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12654 (error "No article on the current line"))
12655 (gnus-rebuild-thread id)
12656 (gnus-summary-goto-subject article)))
12658 (defun gnus-summary-reparent-thread ()
12659 "Make current article child of the marked (or previous) article.
12661 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12662 is non-nil or the Subject: of both articles are the same."
12664 (or (not (gnus-group-read-only-p))
12665 (error "The current newsgroup does not support article editing."))
12666 (or (<= (length gnus-newsgroup-processable) 1)
12667 (error "No more than one article may be marked."))
12668 (save-window-excursion
12669 (let ((gnus-article-buffer " *reparent*")
12670 (current-article (gnus-summary-article-number))
12671 ; first grab the marked article, otherwise one line up.
12672 (parent-article (if (not (null gnus-newsgroup-processable))
12673 (car gnus-newsgroup-processable)
12675 (if (eq (forward-line -1) 0)
12676 (gnus-summary-article-number)
12677 (error "Beginning of summary buffer."))))))
12678 (or (not (eq current-article parent-article))
12679 (error "An article may not be self-referential."))
12680 (let ((message-id (mail-header-id
12681 (gnus-summary-article-header parent-article))))
12682 (or (and message-id (not (equal message-id "")))
12683 (error "No message-id in desired parent."))
12684 (gnus-summary-select-article t t nil current-article)
12685 (set-buffer gnus-article-buffer)
12686 (setq buffer-read-only nil)
12687 (let ((buf (format "%s" (buffer-string))))
12690 (goto-char (point-min))
12691 (if (search-forward-regexp "^References: " nil t)
12692 (insert message-id " " )
12693 (insert "References: " message-id "\n"))
12694 (or (gnus-request-replace-article current-article
12695 (car gnus-article-current)
12696 gnus-article-buffer)
12697 (error "Couldn't replace article."))
12698 (set-buffer gnus-summary-buffer)
12699 (gnus-summary-unmark-all-processable)
12700 (gnus-summary-rethread-current)
12701 (gnus-message 3 "Article %d is now the child of article %d."
12702 current-article parent-article)))))
12704 (defun gnus-summary-toggle-threads (&optional arg)
12705 "Toggle showing conversation threads.
12706 If ARG is positive number, turn showing conversation threads on."
12708 (gnus-set-global-variables)
12709 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12710 (setq gnus-show-threads
12711 (if (null arg) (not gnus-show-threads)
12712 (> (prefix-numeric-value arg) 0)))
12713 (gnus-summary-prepare)
12714 (gnus-summary-goto-subject current)
12715 (gnus-summary-position-point)))
12717 (defun gnus-summary-show-all-threads ()
12718 "Show all threads."
12720 (gnus-set-global-variables)
12722 (let ((buffer-read-only nil))
12723 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12724 (gnus-summary-position-point))
12726 (defun gnus-summary-show-thread ()
12727 "Show thread subtrees.
12728 Returns nil if no thread was there to be shown."
12730 (gnus-set-global-variables)
12731 (let ((buffer-read-only nil)
12733 ;; first goto end then to beg, to have point at beg after let
12734 (end (progn (end-of-line) (point)))
12735 (beg (progn (beginning-of-line) (point))))
12737 ;; Any hidden lines here?
12738 (search-forward "\r" end t)
12739 (subst-char-in-region beg end ?\^M ?\n t)
12741 (gnus-summary-position-point))))
12743 (defun gnus-summary-hide-all-threads ()
12744 "Hide all thread subtrees."
12746 (gnus-set-global-variables)
12748 (goto-char (point-min))
12749 (gnus-summary-hide-thread)
12750 (while (zerop (gnus-summary-next-thread 1 t))
12751 (gnus-summary-hide-thread)))
12752 (gnus-summary-position-point))
12754 (defun gnus-summary-hide-thread ()
12755 "Hide thread subtrees.
12756 Returns nil if no threads were there to be hidden."
12758 (gnus-set-global-variables)
12759 (let ((buffer-read-only nil)
12761 (article (gnus-summary-article-number)))
12763 ;; Go forward until either the buffer ends or the subthread
12765 (when (and (not (eobp))
12766 (or (zerop (gnus-summary-next-thread 1 t))
12767 (goto-char (point-max))))
12769 (if (and (> (point) start)
12770 (search-backward "\n" start t))
12772 (subst-char-in-region start (point) ?\n ?\^M)
12773 (gnus-summary-goto-subject article))
12776 ;;(gnus-summary-position-point)
12779 (defun gnus-summary-go-to-next-thread (&optional previous)
12780 "Go to the same level (or less) next thread.
12781 If PREVIOUS is non-nil, go to previous thread instead.
12782 Return the article number moved to, or nil if moving was impossible."
12783 (let ((level (gnus-summary-thread-level))
12784 (way (if previous -1 1))
12787 (while (and (not (eobp))
12788 (< level (gnus-summary-thread-level)))
12789 (forward-line way))
12796 (gnus-summary-article-number)
12797 (goto-char beg)))))
12799 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12800 "Go to the same level (or less) next thread.
12801 If PREVIOUS is non-nil, go to previous thread instead.
12802 Return the article number moved to, or nil if moving was impossible."
12803 (if (and (eq gnus-summary-make-false-root 'dummy)
12804 (gnus-summary-article-intangible-p))
12805 (let ((beg (point)))
12806 (while (and (zerop (forward-line 1))
12807 (not (gnus-summary-article-intangible-p))
12808 (not (zerop (save-excursion
12809 (gnus-summary-thread-level))))))
12815 (let* ((level (gnus-summary-thread-level))
12816 (article (gnus-summary-article-number))
12817 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12820 (if (<= (gnus-data-level (car data)) level)
12821 (setq oart (gnus-data-number (car data))
12823 (setq data (cdr data))))
12825 (gnus-summary-goto-subject oart)))))
12827 (defun gnus-summary-next-thread (n &optional silent)
12828 "Go to the same level next N'th thread.
12829 If N is negative, search backward instead.
12830 Returns the difference between N and the number of skips actually
12833 If SILENT, don't output messages."
12835 (gnus-set-global-variables)
12836 (let ((backward (< n 0))
12839 (while (and (> n 0)
12840 (gnus-summary-go-to-next-thread backward))
12843 (gnus-summary-position-point))
12844 (when (and (not silent) (/= 0 n))
12845 (gnus-message 7 "No more threads"))
12848 (defun gnus-summary-prev-thread (n)
12849 "Go to the same level previous N'th thread.
12850 Returns the difference between N and the number of skips actually
12853 (gnus-set-global-variables)
12854 (gnus-summary-next-thread (- n)))
12856 (defun gnus-summary-go-down-thread ()
12857 "Go down one level in the current thread."
12858 (let ((children (gnus-summary-article-children)))
12860 (gnus-summary-goto-subject (car children)))))
12862 (defun gnus-summary-go-up-thread ()
12863 "Go up one level in the current thread."
12864 (let ((parent (gnus-summary-article-parent)))
12866 (gnus-summary-goto-subject parent))))
12868 (defun gnus-summary-down-thread (n)
12869 "Go down thread N steps.
12870 If N is negative, go up instead.
12871 Returns the difference between N and how many steps down that were
12874 (gnus-set-global-variables)
12877 (while (and (> n 0)
12878 (if up (gnus-summary-go-up-thread)
12879 (gnus-summary-go-down-thread)))
12881 (gnus-summary-position-point)
12882 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12885 (defun gnus-summary-up-thread (n)
12886 "Go up thread N steps.
12887 If N is negative, go up instead.
12888 Returns the difference between N and how many steps down that were
12891 (gnus-set-global-variables)
12892 (gnus-summary-down-thread (- n)))
12894 (defun gnus-summary-top-thread ()
12895 "Go to the top of the thread."
12897 (gnus-set-global-variables)
12898 (while (gnus-summary-go-up-thread))
12899 (gnus-summary-article-number))
12901 (defun gnus-summary-kill-thread (&optional unmark)
12902 "Mark articles under current thread as read.
12903 If the prefix argument is positive, remove any kinds of marks.
12904 If the prefix argument is negative, tick articles instead."
12906 (gnus-set-global-variables)
12908 (setq unmark (prefix-numeric-value unmark)))
12909 (let ((articles (gnus-summary-articles-in-thread)))
12911 ;; Expand the thread.
12912 (gnus-summary-show-thread)
12913 ;; Mark all the articles.
12915 (gnus-summary-goto-subject (car articles))
12916 (cond ((null unmark)
12917 (gnus-summary-mark-article-as-read gnus-killed-mark))
12919 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12921 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12922 (setq articles (cdr articles))))
12923 ;; Hide killed subtrees.
12925 gnus-thread-hide-killed
12926 (gnus-summary-hide-thread))
12927 ;; If marked as read, go to next unread subject.
12929 ;; Go to next unread subject.
12930 (gnus-summary-next-subject 1 t)))
12931 (gnus-set-mode-line 'summary))
12933 ;; Summary sorting commands
12935 (defun gnus-summary-sort-by-number (&optional reverse)
12936 "Sort summary buffer by article number.
12937 Argument REVERSE means reverse order."
12939 (gnus-summary-sort 'number reverse))
12941 (defun gnus-summary-sort-by-author (&optional reverse)
12942 "Sort summary buffer by author name alphabetically.
12943 If case-fold-search is non-nil, case of letters is ignored.
12944 Argument REVERSE means reverse order."
12946 (gnus-summary-sort 'author reverse))
12948 (defun gnus-summary-sort-by-subject (&optional reverse)
12949 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12950 If case-fold-search is non-nil, case of letters is ignored.
12951 Argument REVERSE means reverse order."
12953 (gnus-summary-sort 'subject reverse))
12955 (defun gnus-summary-sort-by-date (&optional reverse)
12956 "Sort summary buffer by date.
12957 Argument REVERSE means reverse order."
12959 (gnus-summary-sort 'date reverse))
12961 (defun gnus-summary-sort-by-score (&optional reverse)
12962 "Sort summary buffer by score.
12963 Argument REVERSE means reverse order."
12965 (gnus-summary-sort 'score reverse))
12967 (defun gnus-summary-sort (predicate reverse)
12968 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12969 (gnus-set-global-variables)
12970 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12971 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12972 (gnus-thread-sort-functions
12977 (,thread t2 t1)))))
12978 (gnus-article-sort-functions
12983 (,article t2 t1)))))
12985 (gnus-summary-prepare-hook nil))
12986 ;; We do the sorting by regenerating the threads.
12987 (gnus-summary-prepare)
12988 ;; Hide subthreads if needed.
12989 (when (and gnus-show-threads gnus-thread-hide-subtree)
12990 (gnus-summary-hide-all-threads)))
12991 ;; If in async mode, we send some info to the backend.
12992 (when gnus-newsgroup-async
12993 (gnus-request-asynchronous
12994 gnus-newsgroup-name gnus-newsgroup-data)))
12996 (defun gnus-sortable-date (date)
12997 "Make sortable string by string-lessp from DATE.
12998 Timezone package is used."
13001 (setq date (inline (timezone-fix-time
13003 (aref (inline (timezone-parse-date date)) 4))))
13005 (timezone-make-sortable-date
13006 (aref date 0) (aref date 1) (aref date 2)
13008 (timezone-make-time-string
13009 (aref date 3) (aref date 4) (aref date 5))))))
13012 ;; Summary saving commands.
13014 (defun gnus-summary-save-article (&optional n not-saved)
13015 "Save the current article using the default saver function.
13016 If N is a positive number, save the N next articles.
13017 If N is a negative number, save the N previous articles.
13018 If N is nil and any articles have been marked with the process mark,
13019 save those articles instead.
13020 The variable `gnus-default-article-saver' specifies the saver function."
13022 (gnus-set-global-variables)
13023 (let ((articles (gnus-summary-work-articles n))
13024 (save-buffer (save-excursion
13025 (nnheader-set-temp-buffer " *Gnus Save*")))
13026 file header article)
13028 (setq header (gnus-summary-article-header
13029 (setq article (pop articles))))
13030 (if (not (vectorp header))
13031 ;; This is a pseudo-article.
13032 (if (assq 'name header)
13033 (gnus-copy-file (cdr (assq 'name header)))
13034 (gnus-message 1 "Article %d is unsaveable" article))
13035 ;; This is a real article.
13036 (save-window-excursion
13037 (gnus-summary-select-article t nil nil article))
13039 (set-buffer save-buffer)
13041 (insert-buffer-substring gnus-original-article-buffer))
13042 (unless gnus-save-all-headers
13043 ;; Remove headers accoring to `gnus-saved-headers'.
13044 (let ((gnus-visible-headers
13045 (or gnus-saved-headers gnus-visible-headers))
13046 (gnus-article-buffer save-buffer))
13047 (gnus-article-hide-headers 1 t)))
13048 (save-window-excursion
13049 (if (not gnus-default-article-saver)
13050 (error "No default saver is defined.")
13051 ;; !!! Magic! The saving functions all save
13052 ;; `gnus-original-article-buffer' (or so they think),
13053 ;; but we bind that variable to our save-buffer.
13054 (set-buffer gnus-article-buffer)
13055 (let ((gnus-original-article-buffer save-buffer))
13056 (set-buffer gnus-summary-buffer)
13057 (setq file (funcall
13058 gnus-default-article-saver
13060 ((not gnus-prompt-before-saving)
13062 ((eq gnus-prompt-before-saving 'always)
13065 (gnus-summary-remove-process-mark article)
13067 (gnus-summary-set-saved-mark article))))
13068 (gnus-kill-buffer save-buffer)
13069 (gnus-summary-position-point)
13072 (defun gnus-summary-pipe-output (&optional arg)
13073 "Pipe the current article to a subprocess.
13074 If N is a positive number, pipe the N next articles.
13075 If N is a negative number, pipe the N previous articles.
13076 If N is nil and any articles have been marked with the process mark,
13077 pipe those articles instead."
13079 (gnus-set-global-variables)
13080 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13081 (gnus-summary-save-article arg t))
13082 (gnus-configure-windows 'pipe))
13084 (defun gnus-summary-save-article-mail (&optional arg)
13085 "Append the current article to an mail file.
13086 If N is a positive number, save the N next articles.
13087 If N is a negative number, save the N previous articles.
13088 If N is nil and any articles have been marked with the process mark,
13089 save those articles instead."
13091 (gnus-set-global-variables)
13092 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13093 (gnus-summary-save-article arg)))
13095 (defun gnus-summary-save-article-rmail (&optional arg)
13096 "Append the current article to an rmail file.
13097 If N is a positive number, save the N next articles.
13098 If N is a negative number, save the N previous articles.
13099 If N is nil and any articles have been marked with the process mark,
13100 save those articles instead."
13102 (gnus-set-global-variables)
13103 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13104 (gnus-summary-save-article arg)))
13106 (defun gnus-summary-save-article-file (&optional arg)
13107 "Append the current article to a file.
13108 If N is a positive number, save the N next articles.
13109 If N is a negative number, save the N previous articles.
13110 If N is nil and any articles have been marked with the process mark,
13111 save those articles instead."
13113 (gnus-set-global-variables)
13114 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13115 (gnus-summary-save-article arg)))
13117 (defun gnus-summary-save-article-body-file (&optional arg)
13118 "Append the current article body to a file.
13119 If N is a positive number, save the N next articles.
13120 If N is a negative number, save the N previous articles.
13121 If N is nil and any articles have been marked with the process mark,
13122 save those articles instead."
13124 (gnus-set-global-variables)
13125 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13126 (gnus-summary-save-article arg)))
13128 (defun gnus-get-split-value (methods)
13129 "Return a value based on the split METHODS."
13130 (let (split-name method result match)
13133 (set-buffer gnus-original-article-buffer)
13135 (nnheader-narrow-to-headers)
13137 (goto-char (point-min))
13138 (setq method (pop methods))
13139 (setq match (car method))
13142 ;; Regular expression.
13144 (re-search-forward match nil t)
13146 ((gnus-functionp match)
13150 (setq result (funcall match gnus-newsgroup-name))))
13155 (setq result (eval match)))))
13156 (setq split-name (append (cdr method) split-name))
13157 (cond ((stringp result)
13158 (push result split-name))
13160 (setq split-name (append result split-name)))))))))
13163 (defun gnus-read-move-group-name (prompt default articles prefix)
13164 "Read a group name."
13165 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13166 (minibuffer-confirm-incomplete nil) ; XEmacs
13173 (assoc (symbol-name
13174 (car (gnus-find-method-for-group
13176 gnus-valid-select-methods))
13177 (push (list (symbol-name g)) group-map)))
13178 gnus-active-hashtb))
13180 (format "%s %s to:"
13182 (if (> (length articles) 1)
13183 (format "these %d articles" (length articles))
13188 (gnus-completing-read default prom
13189 group-map nil nil prefix
13190 'gnus-group-history))
13191 ((= 1 (length split-name))
13192 (gnus-completing-read (car split-name) prom group-map
13194 'gnus-group-history))
13196 (gnus-completing-read nil prom
13197 (mapcar (lambda (el) (list el))
13198 (nreverse split-name))
13200 'gnus-group-history)))))
13202 (if (or (string= to-newsgroup "")
13203 (string= to-newsgroup prefix))
13204 (setq to-newsgroup (or default "")))
13205 (or (gnus-active to-newsgroup)
13206 (gnus-activate-group to-newsgroup)
13207 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13209 (or (and (gnus-request-create-group
13210 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13211 (gnus-activate-group to-newsgroup nil nil
13212 (gnus-group-name-to-method
13214 (error "Couldn't create group %s" to-newsgroup)))
13215 (error "No such group: %s" to-newsgroup)))
13218 (defun gnus-read-save-file-name (prompt default-name)
13219 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13221 ;; Let the split methods have their say.
13223 ;; No split name was found.
13226 (concat prompt " (default "
13227 (file-name-nondirectory default-name) ") ")
13228 (file-name-directory default-name)
13230 ;; A single split name was found
13231 ((= 1 (length split-name))
13232 (let* ((name (car split-name))
13233 (dir (cond ((file-directory-p name)
13234 (file-name-as-directory name))
13235 ((file-exists-p name) name)
13236 (t gnus-article-save-directory))))
13238 (concat prompt " (default " name ") ")
13240 ;; A list of splits was found.
13242 (setq split-name (nreverse split-name))
13244 (let ((file-name-history (nconc split-name file-name-history)))
13247 (concat prompt " (`M-p' for defaults) ")
13248 gnus-article-save-directory
13249 (car split-name))))
13250 (car (push result file-name-history)))))))
13251 ;; If we have read a directory, we append the default file name.
13252 (when (file-directory-p file)
13253 (setq file (concat (file-name-as-directory file)
13254 (file-name-nondirectory default-name))))
13255 ;; Possibly translate some charaters.
13256 (nnheader-translate-file-chars file)))
13258 (defun gnus-article-archive-name (group)
13259 "Return the first instance of an \"Archive-name\" in the current buffer."
13260 (let ((case-fold-search t))
13261 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13262 (match-string 1))))
13264 (defun gnus-summary-save-in-rmail (&optional filename)
13265 "Append this article to Rmail file.
13266 Optional argument FILENAME specifies file name.
13267 Directory to save to is default to `gnus-article-save-directory'."
13269 (gnus-set-global-variables)
13270 (let ((default-name
13271 (funcall gnus-rmail-save-name gnus-newsgroup-name
13272 gnus-current-headers gnus-newsgroup-last-rmail)))
13274 (cond ((eq filename 'default)
13276 (filename filename)
13277 (t (gnus-read-save-file-name
13278 "Save in rmail file:" default-name))))
13279 (gnus-make-directory (file-name-directory filename))
13280 (gnus-eval-in-buffer-window gnus-original-article-buffer
13284 (gnus-output-to-rmail filename))))
13285 ;; Remember the directory name to save articles
13286 (setq gnus-newsgroup-last-rmail filename)))
13288 (defun gnus-summary-save-in-mail (&optional filename)
13289 "Append this article to Unix mail file.
13290 Optional argument FILENAME specifies file name.
13291 Directory to save to is default to `gnus-article-save-directory'."
13293 (gnus-set-global-variables)
13294 (let ((default-name
13295 (funcall gnus-mail-save-name gnus-newsgroup-name
13296 gnus-current-headers gnus-newsgroup-last-mail)))
13298 (cond ((eq filename 'default)
13300 (filename filename)
13301 (t (gnus-read-save-file-name
13302 "Save in Unix mail file:" default-name))))
13304 (expand-file-name filename
13306 (file-name-directory default-name))))
13307 (gnus-make-directory (file-name-directory filename))
13308 (gnus-eval-in-buffer-window gnus-original-article-buffer
13312 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13313 (gnus-output-to-rmail filename)
13314 (let ((mail-use-rfc822 t))
13315 (rmail-output filename 1 t t))))))
13316 ;; Remember the directory name to save articles.
13317 (setq gnus-newsgroup-last-mail filename)))
13319 (defun gnus-summary-save-in-file (&optional filename)
13320 "Append this article to file.
13321 Optional argument FILENAME specifies file name.
13322 Directory to save to is default to `gnus-article-save-directory'."
13324 (gnus-set-global-variables)
13325 (let ((default-name
13326 (funcall gnus-file-save-name gnus-newsgroup-name
13327 gnus-current-headers gnus-newsgroup-last-file)))
13329 (cond ((eq filename 'default)
13331 (filename filename)
13332 (t (gnus-read-save-file-name
13333 "Save in file:" default-name))))
13334 (gnus-make-directory (file-name-directory filename))
13335 (gnus-eval-in-buffer-window gnus-original-article-buffer
13339 (gnus-output-to-file filename))))
13340 ;; Remember the directory name to save articles.
13341 (setq gnus-newsgroup-last-file filename)))
13343 (defun gnus-summary-save-body-in-file (&optional filename)
13344 "Append this article body to a file.
13345 Optional argument FILENAME specifies file name.
13346 The directory to save in defaults to `gnus-article-save-directory'."
13348 (gnus-set-global-variables)
13349 (let ((default-name
13350 (funcall gnus-file-save-name gnus-newsgroup-name
13351 gnus-current-headers gnus-newsgroup-last-file)))
13353 (cond ((eq filename 'default)
13355 (filename filename)
13356 (t (gnus-read-save-file-name
13357 "Save body in file:" default-name))))
13358 (gnus-make-directory (file-name-directory filename))
13359 (gnus-eval-in-buffer-window gnus-original-article-buffer
13363 (goto-char (point-min))
13364 (and (search-forward "\n\n" nil t)
13365 (narrow-to-region (point) (point-max)))
13366 (gnus-output-to-file filename))))
13367 ;; Remember the directory name to save articles.
13368 (setq gnus-newsgroup-last-file filename)))
13370 (defun gnus-summary-save-in-pipe (&optional command)
13371 "Pipe this article to subprocess."
13373 (gnus-set-global-variables)
13375 (cond ((eq command 'default)
13376 gnus-last-shell-command)
13378 (t (read-string "Shell command on article: "
13379 gnus-last-shell-command))))
13380 (if (string-equal command "")
13381 (setq command gnus-last-shell-command))
13382 (gnus-eval-in-buffer-window gnus-article-buffer
13385 (shell-command-on-region (point-min) (point-max) command nil)))
13386 (setq gnus-last-shell-command command))
13388 ;; Summary extract commands
13390 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13391 (let ((buffer-read-only nil)
13392 (article (gnus-summary-article-number))
13394 (or (gnus-summary-goto-subject article)
13395 (error (format "No such article: %d" article)))
13396 (gnus-summary-position-point)
13397 ;; If all commands are to be bunched up on one line, we collect
13399 (if gnus-view-pseudos-separately
13401 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13404 (setq action (cdr (assq 'action (car ps))))
13405 (setq files (list (cdr (assq 'name (car ps)))))
13406 (while (and ps (cdr ps)
13407 (string= (or action "1")
13408 (or (cdr (assq 'action (cadr ps))) "2")))
13409 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13410 (setcdr ps (cddr ps)))
13413 (if (not (string-match "%s" action))
13414 (setq files (cons " " files)))
13415 (setq files (cons " " files))
13416 (and (assq 'execute (car ps))
13417 (setcdr (assq 'execute (car ps))
13418 (funcall (if (string-match "%s" action)
13421 (mapconcat (lambda (f) f) files " ")))))
13422 (setq ps (cdr ps)))))
13423 (if (and gnus-view-pseudos (not not-view))
13425 (and (assq 'execute (car pslist))
13426 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13427 (eq gnus-view-pseudos 'not-confirm)))
13428 (setq pslist (cdr pslist)))
13431 (setq after-article (or (cdr (assq 'article (car pslist)))
13432 (gnus-summary-article-number)))
13433 (gnus-summary-goto-subject after-article)
13436 (insert " " (file-name-nondirectory
13437 (cdr (assq 'name (car pslist))))
13438 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13440 (forward-line -1) ; back to `b'
13441 (gnus-add-text-properties
13442 b (1- e) (list 'gnus-number gnus-reffed-article-number
13443 gnus-mouse-face-prop gnus-mouse-face))
13445 after-article gnus-reffed-article-number
13446 gnus-unread-mark b (car pslist) 0 (- e b))
13447 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13448 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13449 (setq pslist (cdr pslist)))))))
13451 (defun gnus-pseudos< (p1 p2)
13452 (let ((c1 (cdr (assq 'action p1)))
13453 (c2 (cdr (assq 'action p2))))
13454 (and c1 c2 (string< c1 c2))))
13456 (defun gnus-request-pseudo-article (props)
13457 (cond ((assq 'execute props)
13458 (gnus-execute-command (cdr (assq 'execute props)))))
13459 (let ((gnus-current-article (gnus-summary-article-number)))
13460 (run-hooks 'gnus-mark-article-hook)))
13462 (defun gnus-execute-command (command &optional automatic)
13464 (gnus-article-setup-buffer)
13465 (set-buffer gnus-article-buffer)
13466 (setq buffer-read-only nil)
13467 (let ((command (if automatic command (read-string "Command: " command)))
13468 ;; Just binding this here doesn't help, because there might
13469 ;; be output from the process after exiting the scope of
13471 ;; (buffer-read-only nil)
13474 (insert "$ " command "\n\n")
13475 (if gnus-view-pseudo-asynchronously
13476 (start-process "gnus-execute" nil shell-file-name
13477 shell-command-switch command)
13478 (call-process shell-file-name nil t nil
13479 shell-command-switch command)))))
13481 (defun gnus-copy-file (file &optional to)
13484 (list (read-file-name "Copy file: " default-directory)
13485 (read-file-name "Copy file to: " default-directory)))
13486 (gnus-set-global-variables)
13487 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13488 (and (file-directory-p to)
13489 (setq to (concat (file-name-as-directory to)
13490 (file-name-nondirectory file))))
13491 (copy-file file to))
13493 ;; Summary kill commands.
13495 (defun gnus-summary-edit-global-kill (article)
13496 "Edit the \"global\" kill file."
13497 (interactive (list (gnus-summary-article-number)))
13498 (gnus-set-global-variables)
13499 (gnus-group-edit-global-kill article))
13501 (defun gnus-summary-edit-local-kill ()
13502 "Edit a local kill file applied to the current newsgroup."
13504 (gnus-set-global-variables)
13505 (setq gnus-current-headers (gnus-summary-article-header))
13506 (gnus-set-global-variables)
13507 (gnus-group-edit-local-kill
13508 (gnus-summary-article-number) gnus-newsgroup-name))
13512 ;;; Gnus article mode
13515 (put 'gnus-article-mode 'mode-class 'special)
13517 (if gnus-article-mode-map
13519 (setq gnus-article-mode-map (make-keymap))
13520 (suppress-keymap gnus-article-mode-map)
13522 (gnus-define-keys gnus-article-mode-map
13523 " " gnus-article-goto-next-page
13524 "\177" gnus-article-goto-prev-page
13525 [delete] gnus-article-goto-prev-page
13526 "\C-c^" gnus-article-refer-article
13527 "h" gnus-article-show-summary
13528 "s" gnus-article-show-summary
13529 "\C-c\C-m" gnus-article-mail
13530 "?" gnus-article-describe-briefly
13531 gnus-mouse-2 gnus-article-push-button
13532 "\r" gnus-article-press-button
13533 "\t" gnus-article-next-button
13534 "\M-\t" gnus-article-prev-button
13535 "<" beginning-of-buffer
13537 "\C-c\C-i" gnus-info-find-node
13538 "\C-c\C-b" gnus-bug
)
13540 (substitute-key-definition
13541 'undefined
'gnus-article-read-summary-keys gnus-article-mode-map
))
13543 (defun gnus-article-mode ()
13544 "Major mode for displaying an article.
13546 All normal editing commands are switched off.
13548 The following commands are available:
13550 \\<gnus-article-mode-map>
13551 \\[gnus-article-next-page]\t Scroll the article one page forwards
13552 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13553 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13554 \\[gnus-article-show-summary]\t Display the summary buffer
13555 \\[gnus-article-mail]\t Send a reply to the address near point
13556 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13557 \\[gnus-info-find-node]\t Go to the Gnus info node"
13559 (when (and menu-bar-mode
13560 (gnus-visual-p 'article-menu
'menu
))
13561 (gnus-article-make-menu-bar))
13562 (kill-all-local-variables)
13563 (gnus-simplify-mode-line)
13564 (setq mode-name
"Article")
13565 (setq major-mode
'gnus-article-mode
)
13566 (make-local-variable 'minor-mode-alist
)
13567 (or (assq 'gnus-show-mime minor-mode-alist
)
13568 (setq minor-mode-alist
13569 (cons (list 'gnus-show-mime
" MIME") minor-mode-alist
)))
13570 (use-local-map gnus-article-mode-map
)
13571 (make-local-variable 'page-delimiter
)
13572 (setq page-delimiter gnus-page-delimiter
)
13573 (buffer-disable-undo (current-buffer))
13574 (setq buffer-read-only t
) ;Disable modification
13575 (run-hooks 'gnus-article-mode-hook
))
13577 (defun gnus-article-setup-buffer ()
13578 "Initialize the article buffer."
13579 (let* ((name (if gnus-single-article-buffer
"*Article*"
13580 (concat "*Article " gnus-newsgroup-name
"*")))
13582 (progn (string-match "\\*Article" name
)
13583 (concat " *Original Article"
13584 (substring name
(match-end 0))))))
13585 (setq gnus-article-buffer name
)
13586 (setq gnus-original-article-buffer original
)
13587 ;; This might be a variable local to the summary buffer.
13588 (unless gnus-single-article-buffer
13590 (set-buffer gnus-summary-buffer
)
13591 (setq gnus-article-buffer name
)
13592 (setq gnus-original-article-buffer original
)
13593 (gnus-set-global-variables))
13594 (make-local-variable 'gnus-summary-buffer
))
13595 ;; Init original article buffer.
13597 (set-buffer (get-buffer-create gnus-original-article-buffer
))
13598 (buffer-disable-undo (current-buffer))
13599 (setq major-mode
'gnus-original-article-mode
)
13600 (make-local-variable 'gnus-original-article
))
13601 (if (get-buffer name
)
13604 (buffer-disable-undo (current-buffer))
13605 (setq buffer-read-only t
)
13606 (gnus-add-current-to-buffer-list)
13607 (or (eq major-mode
'gnus-article-mode
)
13608 (gnus-article-mode))
13611 (set-buffer (get-buffer-create name
))
13612 (gnus-add-current-to-buffer-list)
13613 (gnus-article-mode)
13614 (current-buffer)))))
13616 ;; Set article window start at LINE, where LINE is the number of lines
13617 ;; from the head of the article.
13618 (defun gnus-article-set-window-start (&optional line
)
13620 (get-buffer-window gnus-article-buffer t
)
13622 (set-buffer gnus-article-buffer
)
13623 (goto-char (point-min))
13626 (gnus-message 6 "Moved to bookmark")
13627 (search-forward "\n\n" nil t
)
13628 (forward-line line
)
13631 (defun gnus-kill-all-overlays ()
13632 "Delete all overlays in the current buffer."
13633 (when (fboundp 'overlay-lists
)
13634 (let* ((overlayss (overlay-lists))
13635 (buffer-read-only nil
)
13636 (overlays (nconc (car overlayss
) (cdr overlayss
))))
13638 (delete-overlay (pop overlays
))))))
13640 (defun gnus-request-article-this-buffer (article group
)
13641 "Get an article and insert it into this buffer."
13642 (let (do-update-line)
13646 (gnus-kill-all-overlays)
13647 (setq group
(or group gnus-newsgroup-name
))
13649 ;; Open server if it has closed.
13650 (gnus-check-server (gnus-find-method-for-group group
))
13652 ;; Using `gnus-request-article' directly will insert the article into
13653 ;; `nntp-server-buffer' - so we'll save some time by not having to
13654 ;; copy it from the server buffer into the article buffer.
13656 ;; We only request an article by message-id when we do not have the
13657 ;; headers for it, so we'll have to get those.
13658 (when (stringp article
)
13659 (let ((gnus-override-method gnus-refer-article-method
))
13660 (gnus-read-header article
)))
13662 ;; If the article number is negative, that means that this article
13663 ;; doesn't belong in this newsgroup (possibly), so we find its
13664 ;; message-id and request it by id instead of number.
13665 (when (and (numberp article
)
13666 gnus-summary-buffer
13667 (get-buffer gnus-summary-buffer
)
13668 (buffer-name (get-buffer gnus-summary-buffer
)))
13670 (set-buffer gnus-summary-buffer
)
13671 (let ((header (gnus-summary-article-header article
)))
13674 ((memq article gnus-newsgroup-sparse
)
13675 ;; This is a sparse gap article.
13676 (setq do-update-line article
)
13677 (setq article
(mail-header-id header
))
13678 (let ((gnus-override-method gnus-refer-article-method
))
13679 (gnus-read-header article
))
13680 (setq gnus-newsgroup-sparse
13681 (delq article gnus-newsgroup-sparse
)))
13683 ;; It's a real article.
13684 (setq article
(mail-header-id header
)))
13686 ;; It is an extracted pseudo-article.
13687 (setq article
'pseudo
)
13688 (gnus-request-pseudo-article header
))))
13690 (let ((method (gnus-find-method-for-group
13691 gnus-newsgroup-name
)))
13692 (if (not (eq (car method
) 'nneething
))
13694 (let ((dir (concat (file-name-as-directory (nth 1 method
))
13695 (mail-header-subject header
))))
13696 (if (file-directory-p dir
)
13698 (setq article
'nneething
)
13699 (gnus-group-enter-directory dir
)))))))))
13702 ;; Refuse to select canceled articles.
13703 ((and (numberp article
)
13704 gnus-summary-buffer
13705 (get-buffer gnus-summary-buffer
)
13706 (buffer-name (get-buffer gnus-summary-buffer
))
13707 (eq (cdr (save-excursion
13708 (set-buffer gnus-summary-buffer
)
13709 (assq article gnus-newsgroup-reads
)))
13710 gnus-canceled-mark
))
13712 ;; We first check `gnus-original-article-buffer'.
13713 ((and (get-buffer gnus-original-article-buffer
)
13716 (set-buffer gnus-original-article-buffer
)
13717 (and (equal (car gnus-original-article
) group
)
13718 (eq (cdr gnus-original-article
) article
))))
13719 (insert-buffer-substring gnus-original-article-buffer
)
13721 ;; Check the backlog.
13722 ((and gnus-keep-backlog
13723 (gnus-backlog-request-article group article
(current-buffer)))
13725 ;; Check the cache.
13726 ((and gnus-use-cache
13728 (gnus-cache-request-article article group
))
13730 ;; Get the article and put into the article buffer.
13731 ((or (stringp article
) (numberp article
))
13732 (let ((gnus-override-method
13733 (and (stringp article
) gnus-refer-article-method
))
13734 (buffer-read-only nil
))
13736 (gnus-kill-all-overlays)
13737 (if (gnus-request-article article group
(current-buffer))
13739 (and gnus-keep-backlog
13741 (gnus-backlog-enter-article
13742 group article
(current-buffer)))
13744 ;; It was a pseudo.
13747 ;; Take the article from the original article buffer
13748 ;; and place it in the buffer it's supposed to be in.
13749 (when (and (get-buffer gnus-article-buffer
)
13750 ;;(numberp article)
13751 (equal (buffer-name (current-buffer))
13752 (buffer-name (get-buffer gnus-article-buffer
))))
13754 (if (get-buffer gnus-original-article-buffer
)
13755 (set-buffer (get-buffer gnus-original-article-buffer
))
13756 (set-buffer (get-buffer-create gnus-original-article-buffer
))
13757 (buffer-disable-undo (current-buffer))
13758 (setq major-mode
'gnus-original-article-mode
)
13759 (setq buffer-read-only t
)
13760 (gnus-add-current-to-buffer-list))
13761 (let (buffer-read-only)
13763 (insert-buffer-substring gnus-article-buffer
))
13764 (setq gnus-original-article
(cons group article
))))
13766 ;; Update sparse articles.
13767 (when (and do-update-line
13768 (or (numberp article
)
13769 (stringp article
)))
13770 (let ((buf (current-buffer)))
13771 (set-buffer gnus-summary-buffer
)
13772 (gnus-summary-update-article do-update-line
)
13773 (gnus-summary-goto-subject do-update-line nil t
)
13774 (set-window-point (get-buffer-window (current-buffer) t
)
13776 (set-buffer buf
))))))
13778 (defun gnus-read-header (id &optional header
)
13779 "Read the headers of article ID and enter them into the Gnus system."
13780 (let ((group gnus-newsgroup-name
)
13781 (gnus-override-method
13782 (and (gnus-news-group-p gnus-newsgroup-name
)
13783 gnus-refer-article-method
))
13785 ;; First we check to see whether the header in question is already
13788 ;; This is a Message-ID.
13789 (setq header
(or header
(gnus-id-to-header id
)))
13790 ;; This is an article number.
13791 (setq header
(or header
(gnus-summary-article-header id
))))
13793 (not (memq (mail-header-number header
) gnus-newsgroup-sparse
)))
13794 ;; We have found the header.
13796 ;; We have to really fetch the header to this article.
13797 (when (setq where
(gnus-request-head id group
))
13799 (set-buffer nntp-server-buffer
)
13800 (goto-char (point-max))
13802 (goto-char (point-min))
13806 ((cdr where
) (cdr where
))
13807 (header (mail-header-number header
))
13808 (t gnus-reffed-article-number
))
13810 (insert " Article retrieved.\n"))
13812 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13813 ; (setcar (gnus-id-to-thread id) nil))
13814 (if (not (setq header
(car (gnus-get-newsgroup-headers))))
13815 () ; Malformed head.
13816 (unless (memq (mail-header-number header
) gnus-newsgroup-sparse
)
13817 (if (and (stringp id
)
13818 (not (string= (gnus-group-real-name group
)
13820 ;; If we fetched by Message-ID and the article came
13821 ;; from a different group, we fudge some bogus article
13822 ;; numbers for this article.
13823 (mail-header-set-number header gnus-reffed-article-number
))
13824 (decf gnus-reffed-article-number
)
13825 (gnus-remove-header (mail-header-number header
))
13826 (push header gnus-newsgroup-headers
)
13827 (setq gnus-current-headers header
)
13828 (push (mail-header-number header
) gnus-newsgroup-limit
))
13831 (defun gnus-remove-header (number)
13832 "Remove header NUMBER from `gnus-newsgroup-headers'."
13833 (if (and gnus-newsgroup-headers
13834 (= number
(mail-header-number (car gnus-newsgroup-headers
))))
13835 (pop gnus-newsgroup-headers
)
13836 (let ((headers gnus-newsgroup-headers
))
13837 (while (and (cdr headers
)
13838 (not (= number
(mail-header-number (cadr headers
)))))
13840 (when (cdr headers
)
13841 (setcdr headers
(cddr headers
))))))
13843 (defun gnus-article-prepare (article &optional all-headers header
)
13844 "Prepare ARTICLE in article mode buffer.
13845 ARTICLE should either be an article number or a Message-ID.
13846 If ARTICLE is an id, HEADER should be the article headers.
13847 If ALL-HEADERS is non-nil, no headers are hidden."
13849 ;; Make sure we start in a summary buffer.
13850 (unless (eq major-mode
'gnus-summary-mode
)
13851 (set-buffer gnus-summary-buffer
))
13852 (setq gnus-summary-buffer
(current-buffer))
13853 ;; Make sure the connection to the server is alive.
13854 (unless (gnus-server-opened
13855 (gnus-find-method-for-group gnus-newsgroup-name
))
13856 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name
))
13857 (gnus-request-group gnus-newsgroup-name t
))
13858 (let* ((article (if header
(mail-header-number header
) article
))
13859 (summary-buffer (current-buffer))
13860 (internal-hook gnus-article-internal-prepare-hook
)
13861 (group gnus-newsgroup-name
)
13864 (gnus-article-setup-buffer)
13865 (set-buffer gnus-article-buffer
)
13866 ;; Deactivate active regions.
13867 (when (and (boundp 'transient-mark-mode
)
13868 transient-mark-mode
)
13869 (setq mark-active nil
))
13870 (if (not (setq result
(let ((buffer-read-only nil
))
13871 (gnus-request-article-this-buffer
13873 ;; There is no such article.
13875 (when (and (numberp article
)
13876 (not (memq article gnus-newsgroup-sparse
)))
13877 (setq gnus-article-current
13878 (cons gnus-newsgroup-name article
))
13879 (set-buffer gnus-summary-buffer
)
13880 (setq gnus-current-article article
)
13881 (gnus-summary-mark-article article gnus-canceled-mark
))
13882 (unless (memq article gnus-newsgroup-sparse
)
13884 1 "No such article (may have expired or been canceled)")))
13885 (if (or (eq result
'pseudo
) (eq result
'nneething
))
13888 (set-buffer summary-buffer
)
13889 (setq gnus-last-article gnus-current-article
13890 gnus-newsgroup-history
(cons gnus-current-article
13891 gnus-newsgroup-history
)
13892 gnus-current-article
0
13893 gnus-current-headers nil
13894 gnus-article-current nil
)
13895 (if (eq result
'nneething
)
13896 (gnus-configure-windows 'summary
)
13897 (gnus-configure-windows 'article
))
13898 (gnus-set-global-variables))
13899 (gnus-set-mode-line 'article
))
13900 ;; The result from the `request' was an actual article -
13901 ;; or at least some text that is now displayed in the
13903 (if (and (numberp article
)
13904 (not (eq article gnus-current-article
)))
13905 ;; Seems like a new article has been selected.
13906 ;; `gnus-current-article' must be an article number.
13908 (set-buffer summary-buffer
)
13909 (setq gnus-last-article gnus-current-article
13910 gnus-newsgroup-history
(cons gnus-current-article
13911 gnus-newsgroup-history
)
13912 gnus-current-article article
13913 gnus-current-headers
13914 (gnus-summary-article-header gnus-current-article
)
13915 gnus-article-current
13916 (cons gnus-newsgroup-name gnus-current-article
))
13917 (unless (vectorp gnus-current-headers
)
13918 (setq gnus-current-headers nil
))
13919 (gnus-summary-show-thread)
13920 (run-hooks 'gnus-mark-article-hook
)
13921 (gnus-set-mode-line 'summary
)
13922 (and (gnus-visual-p 'article-highlight
'highlight
)
13923 (run-hooks 'gnus-visual-mark-article-hook
))
13924 ;; Set the global newsgroup variables here.
13925 ;; Suggested by Jim Sisolak
13926 ;; <sisolak@trans4.neep.wisc.edu>.
13927 (gnus-set-global-variables)
13928 (setq gnus-have-all-headers
13929 (or all-headers gnus-show-all-headers
))
13930 (and gnus-use-cache
13931 (vectorp (gnus-summary-article-header article
))
13932 (gnus-cache-possibly-enter-article
13934 (gnus-summary-article-header article
)
13935 (memq article gnus-newsgroup-marked
)
13936 (memq article gnus-newsgroup-dormant
)
13937 (memq article gnus-newsgroup-unreads
)))))
13938 (when (or (numberp article
)
13940 ;; Hooks for getting information from the article.
13941 ;; This hook must be called before being narrowed.
13942 (let (buffer-read-only)
13943 (run-hooks 'internal-hook
)
13944 (run-hooks 'gnus-article-prepare-hook
)
13945 ;; Decode MIME message.
13947 (if (or (not gnus-strict-mime
)
13948 (gnus-fetch-field "Mime-Version"))
13949 (funcall gnus-show-mime-method
)
13950 (funcall gnus-decode-encoded-word-method
)))
13951 ;; Perform the article display hooks.
13952 (run-hooks 'gnus-article-display-hook
))
13954 (goto-char (point-min))
13955 (and gnus-break-pages
(gnus-narrow-to-page)))
13956 (gnus-set-mode-line 'article
)
13957 (gnus-configure-windows 'article
)
13958 (goto-char (point-min))
13961 (defun gnus-article-show-all-headers ()
13962 "Show all article headers in article mode buffer."
13964 (gnus-article-setup-buffer)
13965 (set-buffer gnus-article-buffer
)
13966 (let ((buffer-read-only nil
))
13967 (gnus-unhide-text (point-min) (point-max)))))
13969 (defun gnus-article-hide-headers-if-wanted ()
13970 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13971 Provided for backwards compatibility."
13972 (or (save-excursion (set-buffer gnus-summary-buffer
) gnus-have-all-headers
)
13973 gnus-inhibit-hiding
13974 (gnus-article-hide-headers)))
13976 (defsubst gnus-article-header-rank
()
13977 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13978 (let ((list gnus-sorted-header-list
)
13981 (when (looking-at (car list
))
13983 (setq list
(cdr list
))
13987 (defun gnus-article-hide-headers (&optional arg delete
)
13988 "Toggle whether to hide unwanted headers and possibly sort them as well.
13989 If given a negative prefix, always show; if given a positive prefix,
13991 (interactive (gnus-hidden-arg))
13992 (if (gnus-article-check-hidden-text 'headers arg
)
13993 ;; Show boring headers as well.
13994 (gnus-article-show-hidden-text 'boring-headers
)
13995 ;; This function might be inhibited.
13996 (unless gnus-inhibit-hiding
13998 (set-buffer gnus-article-buffer
)
14000 (let ((buffer-read-only nil
)
14001 (props (nconc (list 'gnus-type
'headers
)
14002 gnus-hidden-properties
))
14003 (max (1+ (length gnus-sorted-header-list
)))
14004 (ignored (when (not (stringp gnus-visible-headers
))
14005 (cond ((stringp gnus-ignored-headers
)
14006 gnus-ignored-headers
)
14007 ((listp gnus-ignored-headers
)
14008 (mapconcat 'identity gnus-ignored-headers
14011 (cond ((stringp gnus-visible-headers
)
14012 gnus-visible-headers
)
14013 ((and gnus-visible-headers
14014 (listp gnus-visible-headers
))
14015 (mapconcat 'identity gnus-visible-headers
"\\|"))))
14016 (inhibit-point-motion-hooks t
)
14018 ;; First we narrow to just the headers.
14020 (goto-char (point-min))
14021 ;; Hide any "From " lines at the beginning of (mail) articles.
14022 (while (looking-at "From ")
14026 (delete-region (point-min) (point))
14027 (gnus-hide-text (point-min) (point) props
)))
14028 ;; Then treat the rest of the header lines.
14031 (progn (search-forward "\n\n" nil t
) (forward-line -
1) (point)))
14032 ;; Then we use the two regular expressions
14033 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14034 ;; select which header lines is to remain visible in the
14036 (goto-char (point-min))
14037 (while (re-search-forward "^[^ \t]*:" nil t
)
14038 (beginning-of-line)
14039 ;; We add the headers we want to keep to a list and delete
14040 ;; them from the buffer.
14041 (gnus-put-text-property
14042 (point) (1+ (point)) 'message-rank
14043 (if (or (and visible
(looking-at visible
))
14045 (not (looking-at ignored
))))
14046 (gnus-article-header-rank)
14049 (message-sort-headers-1)
14050 (when (setq beg
(text-property-any
14051 (point-min) (point-max) 'message-rank
(+ 2 max
)))
14052 ;; We make the unwanted headers invisible.
14054 (delete-region beg
(point-max))
14055 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14056 (gnus-hide-text-type beg
(point-max) 'headers
))
14057 ;; Work around XEmacs lossage.
14058 (gnus-put-text-property (point-min) beg
'invisible nil
))))))))
14060 (defun gnus-article-hide-boring-headers (&optional arg
)
14061 "Toggle hiding of headers that aren't very interesting.
14062 If given a negative prefix, always show; if given a positive prefix,
14064 (interactive (gnus-hidden-arg))
14065 (unless (gnus-article-check-hidden-text 'boring-headers arg
)
14067 (set-buffer gnus-article-buffer
)
14069 (let ((buffer-read-only nil
)
14070 (list gnus-boring-article-headers
)
14071 (inhibit-point-motion-hooks t
)
14073 (nnheader-narrow-to-headers)
14075 (setq elem
(pop list
))
14076 (goto-char (point-min))
14078 ;; Hide empty headers.
14080 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t
)
14082 (gnus-hide-text-type
14083 (progn (beginning-of-line) (point))
14086 (if (re-search-forward "^[^ \t]" nil t
)
14087 (match-beginning 0)
14090 ;; Hide boring Newsgroups header.
14091 ((eq elem
'newsgroups
)
14092 (when (equal (message-fetch-field "newsgroups")
14093 (gnus-group-real-name gnus-newsgroup-name
))
14094 (gnus-article-hide-header "newsgroups")))
14095 ((eq elem
'followup-to
)
14096 (when (equal (message-fetch-field "followup-to")
14097 (message-fetch-field "newsgroups"))
14098 (gnus-article-hide-header "followup-to")))
14099 ((eq elem
'reply-to
)
14100 (let ((from (message-fetch-field "from"))
14101 (reply-to (message-fetch-field "reply-to")))
14105 (nth 1 (funcall gnus-extract-address-components from
))
14106 (nth 1 (funcall gnus-extract-address-components
14108 (gnus-article-hide-header "reply-to"))))
14110 (let ((date (message-fetch-field "date")))
14112 (< (gnus-days-between date
(current-time-string))
14114 (gnus-article-hide-header "date")))))))))))
14116 (defun gnus-article-hide-header (header)
14118 (goto-char (point-min))
14119 (when (re-search-forward (concat "^" header
":") nil t
)
14120 (gnus-hide-text-type
14121 (progn (beginning-of-line) (point))
14124 (if (re-search-forward "^[^ \t]" nil t
)
14125 (match-beginning 0)
14127 'boring-headers
))))
14129 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14130 (defun gnus-article-treat-overstrike ()
14131 "Translate overstrikes into bold text."
14134 (set-buffer gnus-article-buffer
)
14135 (let ((buffer-read-only nil
))
14136 (while (search-forward "\b" nil t
)
14137 (let ((next (following-char))
14138 (previous (char-after (- (point) 2))))
14140 ((eq next previous
)
14141 (gnus-put-text-property (- (point) 2) (point) 'invisible t
)
14142 (gnus-put-text-property (point) (1+ (point)) 'face
'bold
))
14144 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t
)
14145 (gnus-put-text-property
14146 (- (point) 2) (1- (point)) 'face
'underline
))
14148 (gnus-put-text-property (- (point) 2) (point) 'invisible t
)
14149 (gnus-put-text-property
14150 (point) (1+ (point)) 'face
'underline
))))))))
14152 (defun gnus-article-word-wrap ()
14153 "Format too long lines."
14156 (set-buffer gnus-article-buffer
)
14157 (let ((buffer-read-only nil
))
14159 (goto-char (point-min))
14160 (search-forward "\n\n" nil t
)
14162 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14163 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14164 (adaptive-fill-mode t
))
14165 (while (not (eobp))
14166 (and (>= (current-column) (min fill-column
(window-width)))
14167 (/= (preceding-char) ?
:)
14168 (fill-paragraph nil
))
14169 (end-of-line 2))))))
14171 (defun gnus-article-remove-cr ()
14172 "Remove carriage returns from an article."
14175 (set-buffer gnus-article-buffer
)
14176 (let ((buffer-read-only nil
))
14177 (goto-char (point-min))
14178 (while (search-forward "\r" nil t
)
14179 (replace-match "" t t
)))))
14181 (defun gnus-article-remove-trailing-blank-lines ()
14182 "Remove all trailing blank lines from the article."
14185 (set-buffer gnus-article-buffer
)
14186 (let ((buffer-read-only nil
))
14187 (goto-char (point-max))
14191 (while (looking-at "^[ \t]*$")
14196 (defun gnus-article-display-x-face (&optional force
)
14197 "Look for an X-Face header and display it if present."
14198 (interactive (list 'force
))
14200 (set-buffer gnus-article-buffer
)
14201 ;; Delete the old process, if any.
14202 (when (process-status "gnus-x-face")
14203 (delete-process "gnus-x-face"))
14204 (let ((inhibit-point-motion-hooks t
)
14205 (case-fold-search nil
)
14208 (nnheader-narrow-to-headers)
14209 (setq from
(message-fetch-field "from"))
14210 (goto-char (point-min))
14211 (when (and gnus-article-x-face-command
14213 ;; Check whether this face is censored.
14214 (not gnus-article-x-face-too-ugly
)
14215 (and gnus-article-x-face-too-ugly from
14216 (not (string-match gnus-article-x-face-too-ugly
14218 ;; Has to be present.
14219 (re-search-forward "^X-Face: " nil t
))
14220 ;; We now have the area of the buffer where the X-Face is stored.
14221 (let ((beg (point))
14222 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t
))))
14223 ;; We display the face.
14224 (if (symbolp gnus-article-x-face-command
)
14225 ;; The command is a lisp function, so we call it.
14226 (if (gnus-functionp gnus-article-x-face-command
)
14227 (funcall gnus-article-x-face-command beg end
)
14228 (error "%s is not a function" gnus-article-x-face-command
))
14229 ;; The command is a string, so we interpret the command
14230 ;; as a, well, command, and fork it off.
14231 (let ((process-connection-type nil
))
14232 (process-kill-without-query
14234 "gnus-x-face" nil shell-file-name shell-command-switch
14235 gnus-article-x-face-command
))
14236 (process-send-region "gnus-x-face" beg end
)
14237 (process-send-eof "gnus-x-face")))))))))
14239 (defalias 'gnus-headers-decode-quoted-printable
'gnus-decode-rfc1522
)
14240 (defun gnus-decode-rfc1522 ()
14241 "Hack to remove QP encoding from headers."
14242 (let ((case-fold-search t
)
14243 (inhibit-point-motion-hooks t
)
14244 (buffer-read-only nil
)
14248 (goto-char (point-min))
14249 (or (search-forward "\n\n" nil t
) (point-max)))
14251 (while (re-search-forward
14252 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t
)
14253 (setq string
(match-string 1))
14254 (narrow-to-region (match-beginning 0) (match-end 0))
14255 (delete-region (point-min) (point-max))
14257 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14258 (subst-char-in-region (point-min) (point-max) ?_ ?
)
14260 (goto-char (point-min))))))
14262 (defun gnus-article-de-quoted-unreadable (&optional force
)
14263 "Do a naive translation of a quoted-printable-encoded article.
14264 This is in no way, shape or form meant as a replacement for real MIME
14265 processing, but is simply a stop-gap measure until MIME support is
14267 If FORCE, decode the article whether it is marked as quoted-printable
14269 (interactive (list 'force
))
14271 (set-buffer gnus-article-buffer
)
14272 (let ((case-fold-search t
)
14273 (buffer-read-only nil
)
14274 (type (gnus-fetch-field "content-transfer-encoding")))
14275 (gnus-decode-rfc1522)
14277 (and type
(string-match "quoted-printable" (downcase type
))))
14278 (goto-char (point-min))
14279 (search-forward "\n\n" nil
'move
)
14280 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14282 (defun gnus-mime-decode-quoted-printable (from to
)
14283 "Decode Quoted-Printable in the region between FROM and TO."
14286 (while (search-forward "=" to t
)
14287 (cond ((eq (following-char) ?
\n)
14290 ((looking-at "[0-9A-F][0-9A-F]")
14291 (subst-char-in-region
14292 (1- (point)) (point) ?
=
14293 (hexl-hex-string-to-integer
14294 (buffer-substring (point) (+ 2 (point)))))
14298 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14300 (defun gnus-article-hide-pgp (&optional arg
)
14301 "Toggle hiding of any PGP headers and signatures in the current article.
14302 If given a negative prefix, always show; if given a positive prefix,
14304 (interactive (gnus-hidden-arg))
14305 (unless (gnus-article-check-hidden-text 'pgp arg
)
14307 (set-buffer gnus-article-buffer
)
14308 (let ((props (nconc (list 'gnus-type
'pgp
) gnus-hidden-properties
))
14309 buffer-read-only beg end
)
14311 (goto-char (point-min))
14312 ;; Hide the "header".
14313 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t
)
14314 (gnus-hide-text (match-beginning 0) (match-end 0) props
))
14316 ;; Hide the actual signature.
14317 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t
)
14318 (setq end
(1+ (match-beginning 0)))
14321 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t
)
14323 ;; Perhaps we shouldn't hide to the end of the buffer
14324 ;; if there is no end to the signature?
14327 ;; Hide "- " PGP quotation markers.
14328 (when (and beg end
)
14329 (narrow-to-region beg end
)
14330 (goto-char (point-min))
14331 (while (re-search-forward "^- " nil t
)
14332 (gnus-hide-text (match-beginning 0) (match-end 0) props
))
14335 (defun gnus-article-hide-signature (&optional arg
)
14336 "Hide the signature in the current article.
14337 If given a negative prefix, always show; if given a positive prefix,
14339 (interactive (gnus-hidden-arg))
14340 (unless (gnus-article-check-hidden-text 'signature arg
)
14342 (set-buffer gnus-article-buffer
)
14344 (let ((buffer-read-only nil
))
14345 (when (gnus-narrow-to-signature)
14346 (gnus-hide-text-type (point-min) (point-max) 'signature
)))))))
14348 (defun gnus-article-strip-leading-blank-lines ()
14349 "Remove all blank lines from the beginning of the article."
14352 (set-buffer gnus-article-buffer
)
14353 (let (buffer-read-only)
14354 (goto-char (point-min))
14355 (when (search-forward "\n\n" nil t
)
14356 (while (looking-at "[ \t]$")
14357 (gnus-delete-line))))))
14359 (defvar mime
::preview
/content-list
)
14360 (defvar mime
::preview-content-info
/point-min
)
14361 (defun gnus-narrow-to-signature ()
14362 "Narrow to the signature."
14364 (if (and (boundp 'mime
::preview
/content-list
)
14365 mime
::preview
/content-list
)
14366 (let ((pcinfo (car (last mime
::preview
/content-list
))))
14369 (funcall (intern "mime::preview-content-info/point-min") pcinfo
)
14372 (goto-char (point-max))
14373 (when (re-search-backward gnus-signature-separator nil t
)
14375 (when (or (null gnus-signature-limit
)
14376 (and (numberp gnus-signature-limit
)
14377 (< (- (point-max) (point)) gnus-signature-limit
))
14378 (and (gnus-functionp gnus-signature-limit
)
14379 (funcall gnus-signature-limit
))
14380 (and (stringp gnus-signature-limit
)
14381 (not (re-search-forward gnus-signature-limit nil t
))))
14382 (narrow-to-region (point) (point-max))
14385 (defun gnus-hidden-arg ()
14386 "Return the current prefix arg as a number, or 0 if no prefix."
14387 (list (if current-prefix-arg
14388 (prefix-numeric-value current-prefix-arg
)
14391 (defun gnus-article-check-hidden-text (type arg
)
14392 "Return nil if hiding is necessary.
14393 Arg can be nil or a number. Nil and positive means hide, negative
14394 means show, 0 means toggle."
14396 (set-buffer gnus-article-buffer
)
14397 (let ((hide (gnus-article-hidden-text-p type
)))
14403 (gnus-article-show-hidden-text type
))
14405 (if (eq hide
'hidden
)
14406 (gnus-article-show-hidden-text type
)
14409 (defun gnus-article-hidden-text-p (type)
14410 "Say whether the current buffer contains hidden text of type TYPE."
14411 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type
)))
14413 (if (get-text-property pos
'invisible
)
14417 (defun gnus-article-hide (&optional arg force
)
14418 "Hide all the gruft in the current article.
14419 This means that PGP stuff, signatures, cited text and (some)
14420 headers will be hidden.
14421 If given a prefix, show the hidden text instead."
14422 (interactive (list current-prefix-arg
'force
))
14423 (gnus-article-hide-headers arg
)
14424 (gnus-article-hide-pgp arg
)
14425 (gnus-article-hide-citation-maybe arg force
)
14426 (gnus-article-hide-signature arg
))
14428 (defun gnus-article-show-hidden-text (type &optional hide
)
14429 "Show all hidden text of type TYPE.
14430 If HIDE, hide the text instead."
14432 (set-buffer gnus-article-buffer
)
14433 (let ((buffer-read-only nil
)
14434 (inhibit-point-motion-hooks t
)
14436 (while (gnus-goto-char (text-property-any
14437 beg
(point-max) 'gnus-type type
))
14441 (gnus-hide-text beg
(point) gnus-hidden-properties
)
14442 (gnus-unhide-text beg
(point)))
14443 (setq beg
(point)))
14446 (defvar gnus-article-time-units
14447 `((year .
,(* 365.25 24 60 60))
14448 (week .
,(* 7 24 60 60))
14449 (day .
,(* 24 60 60))
14450 (hour .
,(* 60 60))
14453 "Mapping from time units to seconds.")
14455 (defun gnus-article-date-ut (&optional type highlight
)
14456 "Convert DATE date to universal time in the current article.
14457 If TYPE is `local', convert to local time; if it is `lapsed', output
14458 how much time has lapsed since DATE."
14459 (interactive (list 'ut t
))
14460 (let* ((header (or gnus-current-headers
14461 (gnus-summary-article-header) ""))
14462 (date (and (vectorp header
) (mail-header-date header
)))
14463 (date-regexp "^Date: \\|^X-Sent: ")
14464 (now (current-time))
14465 (inhibit-point-motion-hooks t
)
14467 (when (and date
(not (string= date
"")))
14469 (set-buffer gnus-article-buffer
)
14471 (nnheader-narrow-to-headers)
14472 (let ((buffer-read-only nil
))
14473 ;; Delete any old Date headers.
14474 (if (re-search-forward date-regexp nil t
)
14476 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
14477 eface
(get-text-property (1- (gnus-point-at-eol))
14479 (message-remove-header date-regexp t
)
14480 (beginning-of-line))
14481 (goto-char (point-max)))
14482 (insert (gnus-make-date-line date type
))
14483 ;; Do highlighting.
14485 (when (and (gnus-visual-p 'article-highlight
'highlight
)
14486 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14487 (gnus-put-text-property (match-beginning 1) (match-end 1)
14489 (gnus-put-text-property (match-beginning 2) (match-end 2)
14490 'face eface
))))))))
14492 (defun gnus-make-date-line (date type
)
14493 "Return a DATE line of TYPE."
14495 ;; Convert to the local timezone. We have to slap a
14496 ;; `condition-case' round the calls to the timezone
14497 ;; functions since they aren't particularly resistant to
14500 (concat "Date: " (condition-case ()
14501 (timezone-make-date-arpa-standard date
)
14504 ;; Convert to Universal Time.
14508 (timezone-make-date-arpa-standard date nil
"UT")
14511 ;; Get the original date from the article.
14512 ((eq type
'original
)
14513 (concat "Date: " date
"\n"))
14514 ;; Do an X-Sent lapsed format.
14516 ;; If the date is seriously mangled, the timezone
14517 ;; functions are liable to bug out, so we condition-case
14518 ;; the entire thing.
14519 (let* ((now (current-time))
14524 (timezone-make-date-arpa-standard
14525 (current-time-string now
)
14526 (current-time-zone now
) "UT"))
14528 (timezone-make-date-arpa-standard
14531 (real-sec (+ (* (float (car real-time
)) 65536)
14533 (sec (abs real-sec
))
14536 ((equal real-time
'(0 0))
14537 "X-Sent: Unknown\n")
14543 ;; This is a bit convoluted, but basically we go
14544 ;; through the time units for years, weeks, etc,
14545 ;; and divide things to see whether that results
14546 ;; in positive answers.
14549 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
14550 ;; The (remaining) seconds are too few to
14551 ;; be divided into this time unit.
14553 ;; It's big enough, so we output it.
14554 (setq sec
(- sec
(* num
(cdr unit
))))
14556 (concat (if prev
", " "") (int-to-string
14558 " " (symbol-name (car unit
))
14559 (if (> num
1) "s" ""))
14561 gnus-article-time-units
"")
14562 ;; If dates are odd, then it might appear like the
14563 ;; article was sent in the future.
14566 " in the future\n"))))))
14568 (error "Unknown conversion type: %s" type
))))
14570 (defun gnus-article-date-local (&optional highlight
)
14571 "Convert the current article date to the local timezone."
14572 (interactive (list t
))
14573 (gnus-article-date-ut 'local highlight
))
14575 (defun gnus-article-date-original (&optional highlight
)
14576 "Convert the current article date to what it was originally.
14577 This is only useful if you have used some other date conversion
14578 function and want to see what the date was before converting."
14579 (interactive (list t
))
14580 (gnus-article-date-ut 'original highlight
))
14582 (defun gnus-article-date-lapsed (&optional highlight
)
14583 "Convert the current article date to time lapsed since it was sent."
14584 (interactive (list t
))
14585 (gnus-article-date-ut 'lapsed highlight
))
14587 (defun gnus-article-maybe-highlight ()
14588 "Do some article highlighting if `gnus-visual' is non-nil."
14589 (if (gnus-visual-p 'article-highlight
'highlight
)
14590 (gnus-article-highlight-some)))
14592 ;;; Article savers.
14594 (defun gnus-output-to-rmail (file-name)
14595 "Append the current article to an Rmail file named FILE-NAME."
14597 ;; Most of these codes are borrowed from rmailout.el.
14598 (setq file-name
(expand-file-name file-name
))
14599 (setq rmail-default-rmail-file file-name
)
14600 (let ((artbuf (current-buffer))
14601 (tmpbuf (get-buffer-create " *Gnus-output*")))
14603 (or (get-file-buffer file-name
)
14604 (file-exists-p file-name
)
14605 (if (gnus-yes-or-no-p
14606 (concat "\"" file-name
"\" does not exist, create it? "))
14607 (let ((file-buffer (create-file-buffer file-name
)))
14609 (set-buffer file-buffer
)
14610 (rmail-insert-rmail-file-header)
14611 (let ((require-final-newline nil
))
14612 (write-region (point-min) (point-max) file-name t
1)))
14613 (kill-buffer file-buffer
))
14614 (error "Output file does not exist")))
14615 (set-buffer tmpbuf
)
14616 (buffer-disable-undo (current-buffer))
14618 (insert-buffer-substring artbuf
)
14619 (gnus-convert-article-to-rmail)
14620 ;; Decide whether to append to a file or to an Emacs buffer.
14621 (let ((outbuf (get-file-buffer file-name
)))
14623 (append-to-file (point-min) (point-max) file-name
)
14624 ;; File has been visited, in buffer OUTBUF.
14625 (set-buffer outbuf
)
14626 (let ((buffer-read-only nil
)
14627 (msg (and (boundp 'rmail-current-message
)
14628 (symbol-value 'rmail-current-message
))))
14629 ;; If MSG is non-nil, buffer is in RMAIL mode.
14632 (narrow-to-region (point-max) (point-max))))
14633 (insert-buffer-substring tmpbuf
)
14636 (goto-char (point-min))
14638 (search-backward "\^_")
14639 (narrow-to-region (point) (point-max))
14640 (goto-char (1+ (point-min)))
14641 (rmail-count-new-messages t
)
14642 (rmail-show-message msg
)))))))
14643 (kill-buffer tmpbuf
)))
14645 (defun gnus-output-to-file (file-name)
14646 "Append the current article to a file named FILE-NAME."
14647 (let ((artbuf (current-buffer)))
14648 (nnheader-temp-write nil
14649 (insert-buffer-substring artbuf
)
14650 ;; Append newline at end of the buffer as separator, and then
14651 ;; save it to file.
14652 (goto-char (point-max))
14654 (append-to-file (point-min) (point-max) file-name
))))
14656 (defun gnus-convert-article-to-rmail ()
14657 "Convert article in current buffer to Rmail message format."
14658 (let ((buffer-read-only nil
))
14659 ;; Convert article directly into Babyl format.
14660 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14661 (goto-char (point-min))
14662 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14663 (while (search-forward "\n\^_" nil t
) ;single char
14664 (replace-match "\n^_" t t
)) ;2 chars: "^" and "_"
14665 (goto-char (point-max))
14668 (defun gnus-narrow-to-page (&optional arg
)
14669 "Narrow the article buffer to a page.
14670 If given a numerical ARG, move forward ARG pages."
14672 (setq arg
(if arg
(prefix-numeric-value arg
) 0))
14674 (set-buffer gnus-article-buffer
)
14675 (goto-char (point-min))
14677 (when (gnus-visual-p 'page-marker
)
14678 (let ((buffer-read-only nil
))
14679 (gnus-remove-text-with-property 'gnus-prev
)
14680 (gnus-remove-text-with-property 'gnus-next
)))
14683 (re-search-backward page-delimiter nil
'move
(1+ (abs arg
))))
14685 (re-search-forward page-delimiter nil
'move arg
)))
14686 (goto-char (match-end 0)))
14689 (if (re-search-forward page-delimiter nil
'move
)
14690 (match-beginning 0)
14692 (when (and (gnus-visual-p 'page-marker
)
14693 (not (= (point-min) 1)))
14695 (goto-char (point-min))
14696 (gnus-insert-prev-page-button)))
14697 (when (and (gnus-visual-p 'page-marker
)
14698 (not (= (1- (point-max)) (buffer-size))))
14700 (goto-char (point-max))
14701 (gnus-insert-next-page-button)))))
14703 ;; Article mode commands
14705 (defun gnus-article-goto-next-page ()
14706 "Show the next page of the article."
14708 (when (gnus-article-next-page)
14709 (gnus-article-read-summary-keys nil
(gnus-character-to-event ?n
))))
14711 (defun gnus-article-goto-prev-page ()
14712 "Show the next page of the article."
14714 (if (bobp) (gnus-article-read-summary-keys nil
(gnus-character-to-event ?n
))
14715 (gnus-article-prev-page nil
)))
14717 (defun gnus-article-next-page (&optional lines
)
14718 "Show the next page of the current article.
14719 If end of article, return non-nil. Otherwise return nil.
14720 Argument LINES specifies lines to be scrolled up."
14722 (move-to-window-line -
1)
14723 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14724 (if (save-excursion
14726 (and (pos-visible-in-window-p) ;Not continuation line.
14728 ;; Nothing in this page.
14729 (if (or (not gnus-break-pages
)
14732 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14734 (gnus-narrow-to-page 1) ;Go to next page.
14736 ;; More in this page.
14740 ;; Long lines may cause an end-of-buffer error.
14741 (goto-char (point-max))))
14742 (move-to-window-line 0)
14745 (defun gnus-article-prev-page (&optional lines
)
14746 "Show previous page of current article.
14747 Argument LINES specifies lines to be scrolled down."
14749 (move-to-window-line 0)
14750 (if (and gnus-break-pages
14752 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14754 (gnus-narrow-to-page -
1) ;Go to previous page.
14755 (goto-char (point-max))
14759 (scroll-down lines
)
14761 (move-to-window-line 0))))
14763 (defun gnus-article-refer-article ()
14764 "Read article specified by message-id around point."
14766 (let ((point (point)))
14767 (search-forward ">" nil t
) ;Move point to end of "<....>".
14768 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t
)
14769 (let ((message-id (match-string 1)))
14771 (set-buffer gnus-summary-buffer
)
14772 (gnus-summary-refer-article message-id
))
14773 (goto-char (point))
14774 (error "No references around point"))))
14776 (defun gnus-article-show-summary ()
14777 "Reconfigure windows to show summary buffer."
14779 (gnus-configure-windows 'article
)
14780 (gnus-summary-goto-subject gnus-current-article
))
14782 (defun gnus-article-describe-briefly ()
14783 "Describe article mode commands briefly."
14786 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14788 (defun gnus-article-summary-command ()
14789 "Execute the last keystroke in the summary buffer."
14791 (let ((obuf (current-buffer))
14792 (owin (current-window-configuration))
14794 (switch-to-buffer gnus-summary-buffer
'norecord
)
14795 (setq func
(lookup-key (current-local-map) (this-command-keys)))
14796 (call-interactively func
)
14798 (set-window-configuration owin
)
14799 (set-window-point (get-buffer-window (current-buffer)) (point))))
14801 (defun gnus-article-summary-command-nosave ()
14802 "Execute the last keystroke in the summary buffer."
14805 (pop-to-buffer gnus-summary-buffer
'norecord
)
14806 (setq func
(lookup-key (current-local-map) (this-command-keys)))
14807 (call-interactively func
)))
14809 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window
)
14810 "Read a summary buffer key sequence and execute it from the article buffer."
14813 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14814 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14815 "=" "^" "\M-^" "|"))
14816 (nosave-but-article
14820 (set-buffer gnus-summary-buffer
)
14821 (push (or key last-command-event
) unread-command-events
)
14822 (setq keys
(read-key-sequence nil
)))
14825 (if (or (member keys nosaves
)
14826 (member keys nosave-but-article
))
14828 (save-window-excursion
14829 (pop-to-buffer gnus-summary-buffer
'norecord
)
14830 (setq func
(lookup-key (current-local-map) keys
)))
14833 (set-buffer gnus-summary-buffer
)
14834 (call-interactively func
))
14835 (when (member keys nosave-but-article
)
14836 (pop-to-buffer gnus-article-buffer
'norecord
)))
14837 (let ((obuf (current-buffer))
14838 (owin (current-window-configuration))
14841 (if not-restore-window
14842 (pop-to-buffer gnus-summary-buffer
'norecord
)
14843 (switch-to-buffer gnus-summary-buffer
'norecord
))
14844 (setq in-buffer
(current-buffer))
14845 (if (setq func
(lookup-key (current-local-map) keys
))
14846 (call-interactively func
)
14848 (when (eq in-buffer
(current-buffer))
14850 (unless not-restore-window
14851 (set-window-configuration owin
))
14852 (set-window-point (get-buffer-window (current-buffer)) opoint
))))))
14856 ;;; Kill file handling.
14860 (defalias 'gnus-batch-kill
'gnus-batch-score
)
14862 (defun gnus-batch-score ()
14863 "Run batched scoring.
14864 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14865 Newsgroups is a list of strings in Bnews format. If you want to score
14866 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14867 score the alt hierarchy, you'd say \"!alt.all\"."
14870 (gnus-newsrc-parse-options
14871 (apply (function concat
)
14872 (mapcar (lambda (g) (concat g
" "))
14873 command-line-args-left
))))
14874 (gnus-expert-user t
)
14875 (nnmail-spool-file nil
)
14876 (gnus-use-dribble-file nil
)
14877 (yes (car yes-and-no
))
14878 (no (cdr yes-and-no
))
14880 ;; Disable verbose message.
14881 gnus-novice-user gnus-large-newsgroup
)
14882 ;; Eat all arguments.
14883 (setq command-line-args-left nil
)
14886 ;; Apply kills to specified newsgroups in command line arguments.
14887 (setq newsrc
(cdr gnus-newsrc-alist
))
14889 (setq group
(caar newsrc
))
14890 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
14891 (if (and (<= (nth 1 (car newsrc
)) gnus-level-subscribed
)
14893 (or (eq (car entry
) t
)
14894 (not (zerop (car entry
)))))
14895 (if yes
(string-match yes group
) t
)
14896 (or (null no
) (not (string-match no group
))))
14898 (gnus-summary-read-group group nil t nil t
)
14899 (and (eq (current-buffer) (get-buffer gnus-summary-buffer
))
14900 (gnus-summary-exit))))
14901 (setq newsrc
(cdr newsrc
)))
14903 (switch-to-buffer gnus-group-buffer
)
14904 (gnus-group-save-newsrc)))
14906 (defun gnus-apply-kill-file ()
14907 "Apply a kill file to the current newsgroup.
14908 Returns the number of articles marked as read."
14909 (if (or (file-exists-p (gnus-newsgroup-kill-file nil
))
14910 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
14911 (gnus-apply-kill-file-internal)
14914 (defun gnus-kill-save-kill-buffer ()
14915 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
14916 (when (get-file-buffer file
)
14918 (set-buffer (get-file-buffer file
))
14919 (and (buffer-modified-p) (save-buffer))
14920 (kill-buffer (current-buffer))))))
14922 (defvar gnus-kill-file-name
"KILL"
14923 "Suffix of the kill files.")
14925 (defun gnus-newsgroup-kill-file (newsgroup)
14926 "Return the name of a kill file name for NEWSGROUP.
14927 If NEWSGROUP is nil, return the global kill file name instead."
14929 ;; The global KILL file is placed at top of the directory.
14930 ((or (null newsgroup
)
14931 (string-equal newsgroup
""))
14932 (expand-file-name gnus-kill-file-name
14933 gnus-kill-files-directory
))
14934 ;; Append ".KILL" to newsgroup name.
14935 ((gnus-use-long-file-name 'not-kill
)
14936 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup
)
14937 "." gnus-kill-file-name
)
14938 gnus-kill-files-directory
))
14939 ;; Place "KILL" under the hierarchical directory.
14941 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
14942 "/" gnus-kill-file-name
)
14943 gnus-kill-files-directory
))))
14950 (defvar gnus-dribble-ignore nil
)
14951 (defvar gnus-dribble-eval-file nil
)
14953 (defun gnus-dribble-file-name ()
14954 "Return the dribble file for the current .newsrc."
14956 (if gnus-dribble-directory
14957 (concat (file-name-as-directory gnus-dribble-directory
)
14958 (file-name-nondirectory gnus-current-startup-file
))
14959 gnus-current-startup-file
)
14962 (defun gnus-dribble-enter (string)
14963 "Enter STRING into the dribble buffer."
14964 (if (and (not gnus-dribble-ignore
)
14965 gnus-dribble-buffer
14966 (buffer-name gnus-dribble-buffer
))
14967 (let ((obuf (current-buffer)))
14968 (set-buffer gnus-dribble-buffer
)
14969 (insert string
"\n")
14970 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14971 (bury-buffer gnus-dribble-buffer
)
14972 (set-buffer obuf
))))
14974 (defun gnus-dribble-read-file ()
14975 "Read the dribble file from disk."
14976 (let ((dribble-file (gnus-dribble-file-name)))
14978 (set-buffer (setq gnus-dribble-buffer
14980 (file-name-nondirectory dribble-file
))))
14981 (gnus-add-current-to-buffer-list)
14983 (setq buffer-file-name dribble-file
)
14985 (buffer-disable-undo (current-buffer))
14986 (bury-buffer (current-buffer))
14987 (set-buffer-modified-p nil
)
14988 (let ((auto (make-auto-save-file-name))
14989 (gnus-dribble-ignore t
)
14991 (when (or (file-exists-p auto
) (file-exists-p dribble-file
))
14992 ;; Load whichever file is newest -- the auto save file
14993 ;; or the "real" file.
14994 (if (file-newer-than-file-p auto dribble-file
)
14995 (insert-file-contents auto
)
14996 (insert-file-contents dribble-file
))
14997 (unless (zerop (buffer-size))
14998 (set-buffer-modified-p t
))
14999 ;; Set the file modes to reflect the .newsrc file modes.
15001 (when (and (file-exists-p gnus-current-startup-file
)
15002 (setq modes
(file-modes gnus-current-startup-file
)))
15003 (set-file-modes dribble-file modes
))
15004 ;; Possibly eval the file later.
15005 (when (gnus-y-or-n-p
15006 "Auto-save file exists. Do you want to read it? ")
15007 (setq gnus-dribble-eval-file t
)))))))
15009 (defun gnus-dribble-eval-file ()
15010 (when gnus-dribble-eval-file
15011 (setq gnus-dribble-eval-file nil
)
15013 (let ((gnus-dribble-ignore t
))
15014 (set-buffer gnus-dribble-buffer
)
15015 (eval-buffer (current-buffer))))))
15017 (defun gnus-dribble-delete-file ()
15018 (when (file-exists-p (gnus-dribble-file-name))
15019 (delete-file (gnus-dribble-file-name)))
15020 (when gnus-dribble-buffer
15022 (set-buffer gnus-dribble-buffer
)
15023 (let ((auto (make-auto-save-file-name)))
15024 (if (file-exists-p auto
)
15025 (delete-file auto
))
15027 (set-buffer-modified-p nil
)))))
15029 (defun gnus-dribble-save ()
15030 (when (and gnus-dribble-buffer
15031 (buffer-name gnus-dribble-buffer
))
15033 (set-buffer gnus-dribble-buffer
)
15036 (defun gnus-dribble-clear ()
15037 (when (gnus-buffer-exists-p gnus-dribble-buffer
)
15039 (set-buffer gnus-dribble-buffer
)
15041 (set-buffer-modified-p nil
)
15042 (setq buffer-saved-size
(buffer-size)))))
15046 ;;; Server Communication
15049 (defun gnus-start-news-server (&optional confirm
)
15050 "Open a method for getting news.
15051 If CONFIRM is non-nil, the user will be asked for an NNTP server."
15053 (if gnus-current-select-method
15054 ;; Stream is already opened.
15056 ;; Open NNTP server.
15057 (if (null gnus-nntp-service
) (setq gnus-nntp-server nil
))
15060 ;; Read server name with completion.
15061 (setq gnus-nntp-server
15062 (completing-read "NNTP server: "
15063 (mapcar (lambda (server) (list server
))
15064 (cons (list gnus-nntp-server
)
15065 gnus-secondary-servers
))
15066 nil nil gnus-nntp-server
))))
15068 (if (and gnus-nntp-server
15069 (stringp gnus-nntp-server
)
15070 (not (string= gnus-nntp-server
"")))
15071 (setq gnus-select-method
15072 (cond ((or (string= gnus-nntp-server
"")
15073 (string= gnus-nntp-server
"::"))
15074 (list 'nnspool
(system-name)))
15075 ((string-match "^:" gnus-nntp-server
)
15076 (list 'nnmh gnus-nntp-server
15077 (list 'nnmh-directory
15078 (file-name-as-directory
15080 (concat "~/" (substring
15081 gnus-nntp-server
1)))))
15082 (list 'nnmh-get-new-mail nil
)))
15084 (list 'nntp gnus-nntp-server
)))))
15086 (setq how
(car gnus-select-method
))
15087 (cond ((eq how
'nnspool
)
15089 (gnus-message 5 "Looking up local news spool..."))
15092 (gnus-message 5 "Looking up mh spool..."))
15095 (setq gnus-current-select-method gnus-select-method
)
15096 (run-hooks 'gnus-open-server-hook
)
15098 ;; gnus-open-server-hook might have opened it
15099 (gnus-server-opened gnus-select-method
)
15100 (gnus-open-server gnus-select-method
)
15103 "%s (%s) open error: '%s'. Continue? "
15104 (car gnus-select-method
) (cadr gnus-select-method
)
15105 (gnus-status-message gnus-select-method
)))
15106 (gnus-error 1 "Couldn't open server on %s"
15107 (nth 1 gnus-select-method
))))))
15109 (defun gnus-check-group (group)
15110 "Try to make sure that the server where GROUP exists is alive."
15111 (let ((method (gnus-find-method-for-group group
)))
15112 (or (gnus-server-opened method
)
15113 (gnus-open-server method
))))
15115 (defun gnus-check-server (&optional method silent
)
15116 "Check whether the connection to METHOD is down.
15117 If METHOD is nil, use `gnus-select-method'.
15118 If it is down, start it up (again)."
15119 (let ((method (or method gnus-select-method
)))
15120 ;; Transform virtual server names into select methods.
15121 (when (stringp method
)
15122 (setq method
(gnus-server-to-method method
)))
15123 (if (gnus-server-opened method
)
15124 ;; The stream is already opened.
15126 ;; Open the server.
15128 (gnus-message 5 "Opening %s server%s..." (car method
)
15129 (if (equal (nth 1 method
) "") ""
15130 (format " on %s" (nth 1 method
)))))
15131 (run-hooks 'gnus-open-server-hook
)
15133 (gnus-open-server method
)
15137 (defun gnus-get-function (method function
&optional noerror
)
15138 "Return a function symbol based on METHOD and FUNCTION."
15139 ;; Translate server names into methods.
15141 (error "Attempted use of a nil select method"))
15142 (when (stringp method
)
15143 (setq method
(gnus-server-to-method method
)))
15144 (let ((func (intern (format "%s-%s" (car method
) function
))))
15145 ;; If the functions isn't bound, we require the backend in
15147 (unless (fboundp func
)
15148 (require (car method
))
15149 (when (and (not (fboundp func
))
15151 ;; This backend doesn't implement this function.
15152 (error "No such function: %s" func
)))
15157 ;;; Interface functions to the backends.
15160 (defun gnus-open-server (method)
15161 "Open a connection to METHOD."
15162 (when (stringp method
)
15163 (setq method
(gnus-server-to-method method
)))
15164 (let ((elem (assoc method gnus-opened-servers
)))
15165 ;; If this method was previously denied, we just return nil.
15166 (if (eq (nth 1 elem
) 'denied
)
15168 (gnus-message 1 "Denied server")
15170 ;; Open the server.
15172 (funcall (gnus-get-function method
'open-server
)
15173 (nth 1 method
) (nthcdr 2 method
))))
15174 ;; If this hasn't been opened before, we add it to the list.
15176 (setq elem
(list method nil
)
15177 gnus-opened-servers
(cons elem gnus-opened-servers
)))
15178 ;; Set the status of this server.
15179 (setcar (cdr elem
) (if result
'ok
'denied
))
15180 ;; Return the result from the "open" call.
15183 (defun gnus-close-server (method)
15184 "Close the connection to METHOD."
15185 (when (stringp method
)
15186 (setq method
(gnus-server-to-method method
)))
15187 (funcall (gnus-get-function method
'close-server
) (nth 1 method
)))
15189 (defun gnus-request-list (method)
15190 "Request the active file from METHOD."
15191 (when (stringp method
)
15192 (setq method
(gnus-server-to-method method
)))
15193 (funcall (gnus-get-function method
'request-list
) (nth 1 method
)))
15195 (defun gnus-request-list-newsgroups (method)
15196 "Request the newsgroups file from METHOD."
15197 (when (stringp method
)
15198 (setq method
(gnus-server-to-method method
)))
15199 (funcall (gnus-get-function method
'request-list-newsgroups
) (nth 1 method
)))
15201 (defun gnus-request-newgroups (date method
)
15202 "Request all new groups since DATE from METHOD."
15203 (when (stringp method
)
15204 (setq method
(gnus-server-to-method method
)))
15205 (funcall (gnus-get-function method
'request-newgroups
)
15206 date
(nth 1 method
)))
15208 (defun gnus-server-opened (method)
15209 "Check whether a connection to METHOD has been opened."
15210 (when (stringp method
)
15211 (setq method
(gnus-server-to-method method
)))
15212 (funcall (gnus-get-function method
'server-opened
) (nth 1 method
)))
15214 (defun gnus-status-message (method)
15215 "Return the status message from METHOD.
15216 If METHOD is a string, it is interpreted as a group name. The method
15217 this group uses will be queried."
15218 (let ((method (if (stringp method
) (gnus-find-method-for-group method
)
15220 (funcall (gnus-get-function method
'status-message
) (nth 1 method
))))
15222 (defun gnus-request-group (group &optional dont-check method
)
15223 "Request GROUP. If DONT-CHECK, no information is required."
15224 (let ((method (or method
(gnus-find-method-for-group group
))))
15225 (when (stringp method
)
15226 (setq method
(gnus-server-to-method method
)))
15227 (funcall (gnus-get-function method
'request-group
)
15228 (gnus-group-real-name group
) (nth 1 method
) dont-check
)))
15230 (defun gnus-request-asynchronous (group &optional articles
)
15231 "Request that GROUP behave asynchronously.
15232 ARTICLES is the `data' of the group."
15233 (let ((method (gnus-find-method-for-group group
)))
15234 (funcall (gnus-get-function method
'request-asynchronous
)
15235 (gnus-group-real-name group
) (nth 1 method
) articles
)))
15237 (defun gnus-list-active-group (group)
15238 "Request active information on GROUP."
15239 (let ((method (gnus-find-method-for-group group
))
15240 (func 'list-active-group
))
15241 (when (gnus-check-backend-function func group
)
15242 (funcall (gnus-get-function method func
)
15243 (gnus-group-real-name group
) (nth 1 method
)))))
15245 (defun gnus-request-group-description (group)
15246 "Request a description of GROUP."
15247 (let ((method (gnus-find-method-for-group group
))
15248 (func 'request-group-description
))
15249 (when (gnus-check-backend-function func group
)
15250 (funcall (gnus-get-function method func
)
15251 (gnus-group-real-name group
) (nth 1 method
)))))
15253 (defun gnus-close-group (group)
15254 "Request the GROUP be closed."
15255 (let ((method (gnus-find-method-for-group group
)))
15256 (funcall (gnus-get-function method
'close-group
)
15257 (gnus-group-real-name group
) (nth 1 method
))))
15259 (defun gnus-retrieve-headers (articles group
&optional fetch-old
)
15260 "Request headers for ARTICLES in GROUP.
15261 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15262 (let ((method (gnus-find-method-for-group group
)))
15263 (if (and gnus-use-cache
(numberp (car articles
)))
15264 (gnus-cache-retrieve-headers articles group fetch-old
)
15265 (funcall (gnus-get-function method
'retrieve-headers
)
15266 articles
(gnus-group-real-name group
) (nth 1 method
)
15269 (defun gnus-retrieve-groups (groups method
)
15270 "Request active information on GROUPS from METHOD."
15271 (when (stringp method
)
15272 (setq method
(gnus-server-to-method method
)))
15273 (funcall (gnus-get-function method
'retrieve-groups
) groups
(nth 1 method
)))
15275 (defun gnus-request-type (group &optional article
)
15276 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15277 (let ((method (gnus-find-method-for-group group
)))
15278 (if (not (gnus-check-backend-function 'request-type
(car method
)))
15280 (funcall (gnus-get-function method
'request-type
)
15281 (gnus-group-real-name group
) article
))))
15283 (defun gnus-request-update-mark (group article mark
)
15284 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15285 (let ((method (gnus-find-method-for-group group
)))
15286 (if (not (gnus-check-backend-function 'request-update-mark
(car method
)))
15288 (funcall (gnus-get-function method
'request-update-mark
)
15289 (gnus-group-real-name group
) article mark
))))
15291 (defun gnus-request-article (article group
&optional buffer
)
15292 "Request the ARTICLE in GROUP.
15293 ARTICLE can either be an article number or an article Message-ID.
15294 If BUFFER, insert the article in that group."
15295 (let ((method (gnus-find-method-for-group group
)))
15296 (funcall (gnus-get-function method
'request-article
)
15297 article
(gnus-group-real-name group
) (nth 1 method
) buffer
)))
15299 (defun gnus-request-head (article group
)
15300 "Request the head of ARTICLE in GROUP."
15301 (let* ((method (gnus-find-method-for-group group
))
15302 (head (gnus-get-function method
'request-head t
)))
15304 (funcall head article
(gnus-group-real-name group
) (nth 1 method
))
15305 (let ((res (gnus-request-article article group
)))
15308 (set-buffer nntp-server-buffer
)
15309 (goto-char (point-min))
15310 (when (search-forward "\n\n" nil t
)
15311 (delete-region (1- (point)) (point-max)))
15312 (nnheader-fold-continuation-lines)))
15315 (defun gnus-request-body (article group
)
15316 "Request the body of ARTICLE in GROUP."
15317 (let ((method (gnus-find-method-for-group group
)))
15318 (funcall (gnus-get-function method
'request-body
)
15319 article
(gnus-group-real-name group
) (nth 1 method
))))
15321 (defun gnus-request-post (method)
15322 "Post the current buffer using METHOD."
15323 (when (stringp method
)
15324 (setq method
(gnus-server-to-method method
)))
15325 (funcall (gnus-get-function method
'request-post
) (nth 1 method
)))
15327 (defun gnus-request-scan (group method
)
15328 "Request a SCAN being performed in GROUP from METHOD.
15329 If GROUP is nil, all groups on METHOD are scanned."
15330 (let ((method (if group
(gnus-find-method-for-group group
) method
)))
15331 (funcall (gnus-get-function method
'request-scan
)
15332 (and group
(gnus-group-real-name group
)) (nth 1 method
))))
15334 (defsubst gnus-request-update-info
(info method
)
15335 "Request that METHOD update INFO."
15336 (when (stringp method
)
15337 (setq method
(gnus-server-to-method method
)))
15338 (when (gnus-check-backend-function 'request-update-info
(car method
))
15339 (funcall (gnus-get-function method
'request-update-info
)
15340 (gnus-group-real-name (gnus-info-group info
))
15341 info
(nth 1 method
))))
15343 (defun gnus-request-expire-articles (articles group
&optional force
)
15344 (let ((method (gnus-find-method-for-group group
)))
15345 (funcall (gnus-get-function method
'request-expire-articles
)
15346 articles
(gnus-group-real-name group
) (nth 1 method
)
15349 (defun gnus-request-move-article
15350 (article group server accept-function
&optional last
)
15351 (let ((method (gnus-find-method-for-group group
)))
15352 (funcall (gnus-get-function method
'request-move-article
)
15353 article
(gnus-group-real-name group
)
15354 (nth 1 method
) accept-function last
)))
15356 (defun gnus-request-accept-article (group method
&optional last
)
15357 ;; Make sure there's a newline at the end of the article.
15358 (when (stringp method
)
15359 (setq method
(gnus-server-to-method method
)))
15360 (when (and (not method
)
15362 (setq method
(gnus-group-name-to-method group
)))
15363 (goto-char (point-max))
15366 (let ((func (car (or method
(gnus-find-method-for-group group
)))))
15367 (funcall (intern (format "%s-request-accept-article" func
))
15368 (if (stringp group
) (gnus-group-real-name group
) group
)
15372 (defun gnus-request-replace-article (article group buffer
)
15373 (let ((func (car (gnus-find-method-for-group group
))))
15374 (funcall (intern (format "%s-request-replace-article" func
))
15375 article
(gnus-group-real-name group
) buffer
)))
15377 (defun gnus-request-associate-buffer (group)
15378 (let ((method (gnus-find-method-for-group group
)))
15379 (funcall (gnus-get-function method
'request-associate-buffer
)
15380 (gnus-group-real-name group
))))
15382 (defun gnus-request-restore-buffer (article group
)
15383 "Request a new buffer restored to the state of ARTICLE."
15384 (let ((method (gnus-find-method-for-group group
)))
15385 (funcall (gnus-get-function method
'request-restore-buffer
)
15386 article
(gnus-group-real-name group
) (nth 1 method
))))
15388 (defun gnus-request-create-group (group &optional method
)
15389 (when (stringp method
)
15390 (setq method
(gnus-server-to-method method
)))
15391 (let ((method (or method
(gnus-find-method-for-group group
))))
15392 (funcall (gnus-get-function method
'request-create-group
)
15393 (gnus-group-real-name group
) (nth 1 method
))))
15395 (defun gnus-request-delete-group (group &optional force
)
15396 (let ((method (gnus-find-method-for-group group
)))
15397 (funcall (gnus-get-function method
'request-delete-group
)
15398 (gnus-group-real-name group
) force
(nth 1 method
))))
15400 (defun gnus-request-rename-group (group new-name
)
15401 (let ((method (gnus-find-method-for-group group
)))
15402 (funcall (gnus-get-function method
'request-rename-group
)
15403 (gnus-group-real-name group
)
15404 (gnus-group-real-name new-name
) (nth 1 method
))))
15406 (defun gnus-member-of-valid (symbol group
)
15407 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15408 (memq symbol
(assoc
15409 (symbol-name (car (gnus-find-method-for-group group
)))
15410 gnus-valid-select-methods
)))
15412 (defun gnus-method-option-p (method option
)
15413 "Return non-nil if select METHOD has OPTION as a parameter."
15414 (when (stringp method
)
15415 (setq method
(gnus-server-to-method method
)))
15416 (memq option
(assoc (format "%s" (car method
))
15417 gnus-valid-select-methods
)))
15419 (defun gnus-server-extend-method (group method
)
15420 ;; This function "extends" a virtual server. If the server is
15421 ;; "hello", and the select method is ("hello" (my-var "something"))
15422 ;; in the group "alt.alt", this will result in a new virtual server
15423 ;; called "hello+alt.alt".
15425 (gnus-copy-sequence
15426 (if (equal (car method
) "native") gnus-select-method
15427 (cdr (assoc (car method
) gnus-server-alist
))))))
15428 (setcar (cdr entry
) (concat (nth 1 entry
) "+" group
))
15429 (nconc entry
(cdr method
))))
15431 (defun gnus-server-status (method)
15432 "Return the status of METHOD."
15433 (nth 1 (assoc method gnus-opened-servers
)))
15435 (defun gnus-group-name-to-method (group)
15436 "Return a select method suitable for GROUP."
15437 (if (string-match ":" group
)
15438 (let ((server (substring group
0 (match-beginning 0))))
15439 (if (string-match "\\+" server
)
15440 (list (intern (substring server
0 (match-beginning 0)))
15441 (substring server
(match-end 0)))
15442 (list (intern server
) "")))
15443 gnus-select-method
))
15445 (defun gnus-find-method-for-group (group &optional info
)
15446 "Find the select method that GROUP uses."
15447 (or gnus-override-method
15449 gnus-select-method
)
15450 (let ((info (or info
(gnus-get-info group
)))
15453 (not (setq method
(gnus-info-method info
)))
15454 (equal method
"native"))
15457 (cond ((stringp method
)
15458 (gnus-server-to-method method
))
15459 ((stringp (car method
))
15460 (gnus-server-extend-method group method
))
15463 (cond ((equal (cadr method
) "")
15465 ((null (cadr method
))
15466 (list (car method
) ""))
15468 (gnus-server-add-address method
)))))))
15470 (defun gnus-check-backend-function (func group
)
15471 "Check whether GROUP supports function FUNC."
15472 (let ((method (if (stringp group
) (car (gnus-find-method-for-group group
))
15474 (fboundp (intern (format "%s-%s" method func
)))))
15476 (defun gnus-methods-using (feature)
15477 "Find all methods that have FEATURE."
15478 (let ((valids gnus-valid-select-methods
)
15481 (if (memq feature
(car valids
))
15482 (setq outs
(cons (car valids
) outs
)))
15483 (setq valids
(cdr valids
)))
15488 ;;; Active & Newsrc File Handling
15491 (defun gnus-setup-news (&optional rawfile level dont-connect
)
15492 "Setup news information.
15493 If RAWFILE is non-nil, the .newsrc file will also be read.
15494 If LEVEL is non-nil, the news will be set up at level LEVEL."
15495 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb
(not rawfile
)))))
15498 ;; Clear some variables to re-initialize news information.
15499 (setq gnus-newsrc-alist nil
15500 gnus-active-hashtb nil
)
15501 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15502 (gnus-read-newsrc-file rawfile
))
15504 (when (and (not (assoc "archive" gnus-server-alist
))
15505 (gnus-archive-server-wanted-p))
15506 (push (cons "archive" gnus-message-archive-method
)
15507 gnus-server-alist
))
15509 ;; If we don't read the complete active file, we fill in the
15511 (if (or (null gnus-read-active-file
)
15512 (eq gnus-read-active-file
'some
))
15513 (gnus-update-active-hashtb-from-killed))
15515 ;; Read the active file and create `gnus-active-hashtb'.
15516 ;; If `gnus-read-active-file' is nil, then we just create an empty
15517 ;; hash table. The partial filling out of the hash table will be
15518 ;; done in `gnus-get-unread-articles'.
15519 (and gnus-read-active-file
15521 (gnus-read-active-file))
15523 (or gnus-active-hashtb
15524 (setq gnus-active-hashtb
(make-vector 4095 0)))
15526 ;; Initialize the cache.
15527 (when gnus-use-cache
15530 ;; Possibly eval the dribble file.
15531 (and init
(or gnus-use-dribble-file gnus-slave
) (gnus-dribble-eval-file))
15533 ;; Slave Gnusii should then clear the dribble buffer.
15534 (when (and init gnus-slave
)
15535 (gnus-dribble-clear))
15537 (gnus-update-format-specifications)
15539 ;; See whether we need to read the description file.
15540 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format
)
15541 (not gnus-description-hashtb
)
15543 gnus-read-active-file
)
15544 (gnus-read-all-descriptions-files))
15546 ;; Find new newsgroups and treat them.
15547 (if (and init gnus-check-new-newsgroups
(not level
)
15548 (gnus-check-server gnus-select-method
))
15549 (gnus-find-new-newsgroups))
15551 ;; We might read in new NoCeM messages here.
15552 (when (and gnus-use-nocem
15554 (not dont-connect
))
15555 (gnus-nocem-scan-groups))
15557 ;; Find the number of unread articles in each non-dead group.
15558 (let ((gnus-read-active-file (and (not level
) gnus-read-active-file
)))
15559 (gnus-get-unread-articles level
))
15561 (if (and init gnus-check-bogus-newsgroups
15562 gnus-read-active-file
(not level
)
15563 (gnus-server-opened gnus-select-method
))
15564 (gnus-check-bogus-newsgroups))))
15566 (defun gnus-find-new-newsgroups (&optional arg
)
15567 "Search for new newsgroups and add them.
15568 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15569 The `-n' option line from .newsrc is respected.
15570 If ARG (the prefix), use the `ask-server' method to query
15571 the server for new groups."
15573 (let ((check (if (or (and arg
(not (listp gnus-check-new-newsgroups
)))
15574 (null gnus-read-active-file
)
15575 (eq gnus-read-active-file
'some
))
15576 'ask-server gnus-check-new-newsgroups
)))
15577 (unless (gnus-check-first-time-used)
15578 (if (or (consp check
)
15579 (eq check
'ask-server
))
15580 ;; Ask the server for new groups.
15581 (gnus-ask-server-for-new-groups)
15582 ;; Go through the active hashtb and look for new groups.
15584 group new-newsgroups
)
15585 (gnus-message 5 "Looking for new newsgroups...")
15586 (unless gnus-have-read-active-file
15587 (gnus-read-active-file))
15588 (setq gnus-newsrc-last-checked-date
(current-time-string))
15589 (unless gnus-killed-hashtb
15590 (gnus-make-hashtable-from-killed))
15591 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15592 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15595 (if (or (null (setq group
(symbol-name sym
)))
15597 (null (symbol-value sym
))
15598 (gnus-gethash group gnus-killed-hashtb
)
15599 (gnus-gethash group gnus-newsrc-hashtb
))
15601 (let ((do-sub (gnus-matches-options-n group
)))
15603 ((eq do-sub
'subscribe
)
15604 (setq groups
(1+ groups
))
15605 (gnus-sethash group group gnus-killed-hashtb
)
15606 (funcall gnus-subscribe-options-newsgroup-method group
))
15607 ((eq do-sub
'ignore
)
15610 (setq groups
(1+ groups
))
15611 (gnus-sethash group group gnus-killed-hashtb
)
15612 (if gnus-subscribe-hierarchical-interactive
15613 (setq new-newsgroups
(cons group new-newsgroups
))
15614 (funcall gnus-subscribe-newsgroup-method group
)))))))
15615 gnus-active-hashtb
)
15616 (when new-newsgroups
15617 (gnus-subscribe-hierarchical-interactive new-newsgroups
))
15618 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15620 (gnus-message 6 "%d new newsgroup%s arrived."
15621 groups
(if (> groups
1) "s have" " has"))
15622 (gnus-message 6 "No new newsgroups.")))))))
15624 (defun gnus-matches-options-n (group)
15625 ;; Returns `subscribe' if the group is to be unconditionally
15626 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15627 ;; no match for the group.
15629 ;; First we check the two user variables.
15631 ((and gnus-options-subscribe
15632 (string-match gnus-options-subscribe group
))
15634 ((and gnus-auto-subscribed-groups
15635 (string-match gnus-auto-subscribed-groups group
))
15637 ((and gnus-options-not-subscribe
15638 (string-match gnus-options-not-subscribe group
))
15640 ;; Then we go through the list that was retrieved from the .newsrc
15641 ;; file. This list has elements on the form
15642 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15643 ;; is in the reverse order of the options line) is returned.
15645 (let ((regs gnus-newsrc-options-n
))
15647 (not (string-match (caar regs
) group
)))
15648 (setq regs
(cdr regs
)))
15649 (and regs
(cdar regs
))))))
15651 (defun gnus-ask-server-for-new-groups ()
15652 (let* ((date (or gnus-newsrc-last-checked-date
(current-time-string)))
15653 (methods (cons gnus-select-method
15655 (when (gnus-archive-server-wanted-p)
15658 (and (consp gnus-check-new-newsgroups
)
15659 gnus-check-new-newsgroups
)
15660 gnus-secondary-select-methods
))))
15662 (new-date (current-time-string))
15663 group new-newsgroups got-new method hashtb
15664 gnus-override-subscribe-method
)
15665 ;; Go through both primary and secondary select methods and
15666 ;; request new newsgroups.
15667 (while (setq method
(gnus-server-get-method nil
(pop methods
)))
15668 (setq new-newsgroups nil
)
15669 (setq gnus-override-subscribe-method method
)
15670 (when (and (gnus-check-server method
)
15671 (gnus-request-newgroups date method
))
15674 (setq hashtb
(gnus-make-hashtable 100))
15675 (set-buffer nntp-server-buffer
)
15676 ;; Enter all the new groups into a hashtable.
15677 (gnus-active-to-gnus-format method hashtb
'ignore
))
15678 ;; Now all new groups from `method' are in `hashtb'.
15680 (lambda (group-sym)
15681 (if (or (null (setq group
(symbol-name group-sym
)))
15682 (not (boundp group-sym
))
15683 (null (symbol-value group-sym
))
15684 (gnus-gethash group gnus-newsrc-hashtb
)
15685 (member group gnus-zombie-list
)
15686 (member group gnus-killed-list
))
15687 ;; The group is already known.
15689 ;; Make this group active.
15690 (when (symbol-value group-sym
)
15691 (gnus-set-active group
(symbol-value group-sym
)))
15692 ;; Check whether we want it or not.
15693 (let ((do-sub (gnus-matches-options-n group
)))
15695 ((eq do-sub
'subscribe
)
15697 (gnus-sethash group group gnus-killed-hashtb
)
15698 (funcall gnus-subscribe-options-newsgroup-method group
))
15699 ((eq do-sub
'ignore
)
15703 (gnus-sethash group group gnus-killed-hashtb
)
15704 (if gnus-subscribe-hierarchical-interactive
15705 (push group new-newsgroups
)
15706 (funcall gnus-subscribe-newsgroup-method group
)))))))
15708 (when new-newsgroups
15709 (gnus-subscribe-hierarchical-interactive new-newsgroups
)))
15710 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15712 (gnus-message 6 "%d new newsgroup%s arrived."
15713 groups
(if (> groups
1) "s have" " has")))
15714 (and got-new
(setq gnus-newsrc-last-checked-date new-date
))
15717 (defun gnus-check-first-time-used ()
15718 (if (or (> (length gnus-newsrc-alist
) 1)
15719 (file-exists-p gnus-startup-file
)
15720 (file-exists-p (concat gnus-startup-file
".el"))
15721 (file-exists-p (concat gnus-startup-file
".eld")))
15723 (gnus-message 6 "First time user; subscribing you to default groups")
15724 (unless (gnus-read-active-file-p)
15725 (gnus-read-active-file))
15726 (setq gnus-newsrc-last-checked-date
(current-time-string))
15727 (let ((groups gnus-default-subscribed-newsgroups
)
15731 (setq groups
(or groups gnus-backup-default-subscribed-newsgroups
))
15734 (if (null (setq group
(symbol-name sym
)))
15736 (let ((do-sub (gnus-matches-options-n group
)))
15738 ((eq do-sub
'subscribe
)
15739 (gnus-sethash group group gnus-killed-hashtb
)
15740 (funcall gnus-subscribe-options-newsgroup-method group
))
15741 ((eq do-sub
'ignore
)
15744 (setq gnus-killed-list
(cons group gnus-killed-list
)))))))
15745 gnus-active-hashtb
)
15747 (if (gnus-active (car groups
))
15748 (gnus-group-change-level
15749 (car groups
) gnus-level-default-subscribed gnus-level-killed
))
15750 (setq groups
(cdr groups
)))
15751 (gnus-group-make-help-group)
15752 (and gnus-novice-user
15753 (gnus-message 7 "`A k' to list killed groups"))))))
15755 (defun gnus-subscribe-group (group previous
&optional method
)
15756 (gnus-group-change-level
15758 (list t group gnus-level-default-subscribed nil nil method
)
15760 gnus-level-default-subscribed gnus-level-killed previous t
))
15762 ;; `gnus-group-change-level' is the fundamental function for changing
15763 ;; subscription levels of newsgroups. This might mean just changing
15764 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15765 ;; again, which subscribes/unsubscribes a group, which is equally
15766 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15767 ;; from 8-9 to 1-7 means that you remove the group from the list of
15768 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15769 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15770 ;; which is trivial.
15771 ;; ENTRY can either be a string (newsgroup name) or a list (if
15772 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15773 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15775 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15776 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15778 (defun gnus-group-change-level (entry level
&optional oldlevel
15779 previous fromkilled
)
15780 (let (group info active num
)
15781 ;; Glean what info we can from the arguments
15783 (if fromkilled
(setq group
(nth 1 entry
))
15784 (setq group
(car (nth 2 entry
))))
15785 (setq group entry
))
15786 (if (and (stringp entry
)
15788 (< oldlevel gnus-level-zombie
))
15789 (setq entry
(gnus-gethash entry gnus-newsrc-hashtb
)))
15790 (if (and (not oldlevel
)
15792 (setq oldlevel
(gnus-info-level (nth 2 entry
)))
15793 (setq oldlevel
(or oldlevel
9)))
15794 (if (stringp previous
)
15795 (setq previous
(gnus-gethash previous gnus-newsrc-hashtb
)))
15797 (if (and (>= oldlevel gnus-level-zombie
)
15798 (gnus-gethash group gnus-newsrc-hashtb
))
15799 ;; We are trying to subscribe a group that is already
15803 (or (gnus-ephemeral-group-p group
)
15804 (gnus-dribble-enter
15805 (format "(gnus-group-change-level %S %S %S %S %S)"
15806 group level oldlevel
(car (nth 2 previous
)) fromkilled
)))
15808 ;; Then we remove the newgroup from any old structures, if needed.
15809 ;; If the group was killed, we remove it from the killed or zombie
15810 ;; list. If not, and it is in fact going to be killed, we remove
15811 ;; it from the newsrc hash table and assoc.
15813 ((>= oldlevel gnus-level-zombie
)
15814 (if (= oldlevel gnus-level-zombie
)
15815 (setq gnus-zombie-list
(delete group gnus-zombie-list
))
15816 (setq gnus-killed-list
(delete group gnus-killed-list
))))
15818 (if (and (>= level gnus-level-zombie
)
15821 (gnus-sethash (car (nth 2 entry
)) nil gnus-newsrc-hashtb
)
15823 (setcdr (gnus-gethash (car (nth 3 entry
))
15824 gnus-newsrc-hashtb
)
15826 (setcdr (cdr entry
) (cdddr entry
))))))
15828 ;; Finally we enter (if needed) the list where it is supposed to
15829 ;; go, and change the subscription level. If it is to be killed,
15830 ;; we enter it into the killed or zombie list.
15832 ((>= level gnus-level-zombie
)
15833 ;; Remove from the hash table.
15834 (gnus-sethash group nil gnus-newsrc-hashtb
)
15835 ;; We do not enter foreign groups into the list of dead
15837 (unless (gnus-group-foreign-p group
)
15838 (if (= level gnus-level-zombie
)
15839 (setq gnus-zombie-list
(cons group gnus-zombie-list
))
15840 (setq gnus-killed-list
(cons group gnus-killed-list
)))))
15842 ;; If the list is to be entered into the newsrc assoc, and
15843 ;; it was killed, we have to create an entry in the newsrc
15844 ;; hashtb format and fix the pointers in the newsrc assoc.
15845 (if (< oldlevel gnus-level-zombie
)
15846 ;; It was alive, and it is going to stay alive, so we
15847 ;; just change the level and don't change any pointers or
15848 ;; hash table entries.
15849 (setcar (cdaddr entry
) level
)
15851 (setq info
(cdr entry
)
15853 (setq active
(gnus-active group
))
15855 (if active
(- (1+ (cdr active
)) (car active
)) t
))
15856 ;; Check whether the group is foreign. If so, the
15857 ;; foreign select method has to be entered into the
15859 (let ((method (or gnus-override-subscribe-method
15860 (gnus-group-method group
))))
15861 (if (eq method gnus-select-method
)
15862 (setq info
(list group level nil
))
15863 (setq info
(list group level nil nil method
)))))
15866 (let ((p gnus-newsrc-alist
))
15870 (setq entry
(cons info
(cddr previous
)))
15873 (setcdr (cdr previous
) entry
)
15874 (gnus-sethash group
(cons num
(cdr previous
))
15875 gnus-newsrc-hashtb
))
15876 (setcdr previous entry
)
15877 (gnus-sethash group
(cons num previous
)
15878 gnus-newsrc-hashtb
))
15880 (setcdr (gnus-gethash (caadr entry
) gnus-newsrc-hashtb
) entry
)))))
15881 (when gnus-group-change-level-function
15882 (funcall gnus-group-change-level-function group level oldlevel
)))))
15884 (defun gnus-kill-newsgroup (newsgroup)
15885 "Obsolete function. Kills a newsgroup."
15886 (gnus-group-change-level
15887 (gnus-gethash newsgroup gnus-newsrc-hashtb
) gnus-level-killed
))
15889 (defun gnus-check-bogus-newsgroups (&optional confirm
)
15890 "Remove bogus newsgroups.
15891 If CONFIRM is non-nil, the user has to confirm the deletion of every
15893 (let ((newsrc (cdr gnus-newsrc-alist
))
15894 bogus group entry info
)
15895 (gnus-message 5 "Checking bogus newsgroups...")
15896 (unless (gnus-read-active-file-p)
15897 (gnus-read-active-file))
15898 (when (gnus-read-active-file-p)
15899 ;; Find all bogus newsgroup that are subscribed.
15901 (setq info
(pop newsrc
)
15902 group
(gnus-info-group info
))
15903 (unless (or (gnus-active group
) ; Active
15904 (gnus-info-method info
) ; Foreign
15906 (not (gnus-y-or-n-p
15907 (format "Remove bogus newsgroup: %s " group
)))))
15908 ;; Found a bogus newsgroup.
15909 (push group bogus
)))
15910 ;; Remove all bogus subscribed groups by first killing them, and
15911 ;; then removing them from the list of killed groups.
15913 (when (setq entry
(gnus-gethash (setq group
(pop bogus
))
15914 gnus-newsrc-hashtb
))
15915 (gnus-group-change-level entry gnus-level-killed
)
15916 (setq gnus-killed-list
(delete group gnus-killed-list
))))
15917 ;; Then we remove all bogus groups from the list of killed and
15918 ;; zombie groups. They are are removed without confirmation.
15919 (let ((dead-lists '(gnus-killed-list gnus-zombie-list
))
15922 (setq killed
(symbol-value (car dead-lists
)))
15924 (unless (gnus-active (setq group
(pop killed
)))
15925 ;; The group is bogus.
15926 ;; !!!Slow as hell.
15927 (set (car dead-lists
)
15928 (delete group
(symbol-value (car dead-lists
))))))
15929 (setq dead-lists
(cdr dead-lists
))))
15930 (gnus-message 5 "Checking bogus newsgroups...done"))))
15932 (defun gnus-check-duplicate-killed-groups ()
15933 "Remove duplicates from the list of killed groups."
15935 (let ((killed gnus-killed-list
))
15937 (gnus-message 9 "%d" (length killed
))
15938 (setcdr killed
(delete (car killed
) (cdr killed
)))
15939 (setq killed
(cdr killed
)))))
15941 ;; We want to inline a function from gnus-cache, so we cheat here:
15944 (setq gnus-directory
(or (getenv "SAVEDIR") "~/News/"))
15945 (require 'gnus-cache
))
15947 (defun gnus-get-unread-articles-in-group (info active
&optional update
)
15949 ;; Allow the backend to update the info in the group.
15951 (gnus-request-update-info
15952 info
(gnus-find-method-for-group (gnus-info-group info
))))
15953 (gnus-activate-group (gnus-info-group info
) nil t
))
15954 (let* ((range (gnus-info-read info
))
15956 ;; If a cache is present, we may have to alter the active info.
15957 (when (and gnus-use-cache info
)
15958 (inline (gnus-cache-possibly-alter-active
15959 (gnus-info-group info
) active
)))
15960 ;; Modify the list of read articles according to what articles
15961 ;; are available; then tally the unread articles and add the
15962 ;; number to the group hash table entry.
15964 ((zerop (cdr active
))
15967 (setq num
(- (1+ (cdr active
)) (car active
))))
15968 ((not (listp (cdr range
)))
15969 ;; Fix a single (num . num) range according to the
15970 ;; active hash table.
15971 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15972 (and (< (cdr range
) (car active
)) (setcdr range
(1- (car active
))))
15973 (and (> (cdr range
) (cdr active
)) (setcdr range
(cdr active
)))
15974 ;; Compute number of unread articles.
15975 (setq num
(max 0 (- (cdr active
) (- (1+ (cdr range
)) (car range
))))))
15977 ;; The read list is a list of ranges. Fix them according to
15978 ;; the active hash table.
15979 ;; First peel off any elements that are below the lower
15981 (while (and (cdr range
)
15983 (or (and (atom (cadr range
)) (cadr range
))
15985 (if (numberp (car range
))
15988 (or (and (numberp (cadr range
))
15991 (setcdr (car range
)
15992 (or (and (numberp (nth 1 range
)) (nth 1 range
))
15994 (setcdr range
(cddr range
)))
15995 ;; Adjust the first element to be the same as the lower limit.
15996 (if (and (not (atom (car range
)))
15997 (< (cdar range
) (car active
)))
15998 (setcdr (car range
) (1- (car active
))))
15999 ;; Then we want to peel off any elements that are higher
16000 ;; than the upper active limit.
16001 (let ((srange range
))
16002 ;; Go past all legal elements.
16003 (while (and (cdr srange
)
16004 (<= (or (and (atom (cadr srange
))
16006 (caadr srange
)) (cdr active
)))
16007 (setq srange
(cdr srange
)))
16009 ;; Nuke all remaining illegal elements.
16010 (setcdr srange nil
))
16012 ;; Adjust the final element.
16013 (if (and (not (atom (car srange
)))
16014 (> (cdar srange
) (cdr active
)))
16015 (setcdr (car srange
) (cdr active
))))
16016 ;; Compute the number of unread articles.
16018 (setq num
(+ num
(- (1+ (or (and (atom (car range
)) (car range
))
16020 (or (and (atom (car range
)) (car range
))
16022 (setq range
(cdr range
)))
16023 (setq num
(max 0 (- (cdr active
) num
)))))
16024 ;; Set the number of unread articles.
16026 (setcar (gnus-gethash (gnus-info-group info
) gnus-newsrc-hashtb
) num
))
16029 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
16030 ;; and compute how many unread articles there are in each group.
16031 (defun gnus-get-unread-articles (&optional level
)
16032 (let* ((newsrc (cdr gnus-newsrc-alist
))
16033 (level (or level gnus-activate-level
(1+ gnus-level-subscribed
)))
16036 (cond ((and gnus-activate-foreign-newsgroups
16037 (not (numberp gnus-activate-foreign-newsgroups
)))
16038 (1+ gnus-level-subscribed
))
16039 ((numberp gnus-activate-foreign-newsgroups
)
16040 gnus-activate-foreign-newsgroups
)
16043 info group active method
)
16044 (gnus-message 5 "Checking new news...")
16047 (setq active
(gnus-active (setq group
(gnus-info-group
16048 (setq info
(pop newsrc
))))))
16050 ;; Check newsgroups. If the user doesn't want to check them, or
16051 ;; they can't be checked (for instance, if the news server can't
16052 ;; be reached) we just set the number of unread articles in this
16053 ;; newsgroup to t. This means that Gnus thinks that there are
16054 ;; unread articles, but it has no idea how many.
16055 (if (and (setq method
(gnus-info-method info
))
16056 (not (gnus-server-equal
16058 (setq method
(gnus-server-get-method nil method
))))
16059 (not (gnus-secondary-method-p method
)))
16060 ;; These groups are foreign. Check the level.
16061 (when (<= (gnus-info-level info
) foreign-level
)
16062 (setq active
(gnus-activate-group group
'scan
))
16063 (unless (inline (gnus-virtual-group-p group
))
16064 (inline (gnus-close-group group
)))
16065 (when (fboundp (intern (concat (symbol-name (car method
))
16066 "-request-update-info")))
16067 (inline (gnus-request-update-info info method
))))
16068 ;; These groups are native or secondary.
16069 (when (and (<= (gnus-info-level info
) level
)
16070 (not gnus-read-active-file
))
16071 (setq active
(gnus-activate-group group
'scan
))
16072 (inline (gnus-close-group group
))))
16074 ;; Get the number of unread articles in the group.
16076 (inline (gnus-get-unread-articles-in-group info active
))
16077 ;; The group couldn't be reached, so we nix out the number of
16078 ;; unread articles and stuff.
16079 (gnus-set-active group nil
)
16080 (setcar (gnus-gethash group gnus-newsrc-hashtb
) t
)))
16082 (gnus-message 5 "Checking new news...done")))
16084 ;; Create a hash table out of the newsrc alist. The `car's of the
16085 ;; alist elements are used as keys.
16086 (defun gnus-make-hashtable-from-newsrc-alist ()
16087 (let ((alist gnus-newsrc-alist
)
16088 (ohashtb gnus-newsrc-hashtb
)
16090 (setq gnus-newsrc-hashtb
(gnus-make-hashtable (length alist
)))
16092 (setq prev
(setq gnus-newsrc-alist
16093 (if (equal (caar gnus-newsrc-alist
)
16096 (cons (list "dummy.group" 0 nil
) alist
)))))
16100 (cons (and ohashtb
(car (gnus-gethash (caar alist
) ohashtb
)))
16102 gnus-newsrc-hashtb
)
16104 alist
(cdr alist
)))))
16106 (defun gnus-make-hashtable-from-killed ()
16107 "Create a hash table from the killed and zombie lists."
16108 (let ((lists '(gnus-killed-list gnus-zombie-list
))
16110 (setq gnus-killed-hashtb
16111 (gnus-make-hashtable
16112 (+ (length gnus-killed-list
) (length gnus-zombie-list
))))
16113 (while (setq list
(pop lists
))
16114 (setq list
(symbol-value list
))
16116 (gnus-sethash (car list
) (pop list
) gnus-killed-hashtb
)))))
16118 (defun gnus-activate-group (group &optional scan dont-check method
)
16119 ;; Check whether a group has been activated or not.
16120 ;; If SCAN, request a scan of that group as well.
16121 (let ((method (or method
(gnus-find-method-for-group group
)))
16123 (and (gnus-check-server method
)
16124 ;; We escape all bugs and quit here to make it possible to
16125 ;; continue if a group is so out-there that it reports bugs
16129 (gnus-check-backend-function 'request-scan
(car method
))
16130 (gnus-request-scan group method
))
16133 (gnus-request-group group dont-check method
)
16137 (set-buffer nntp-server-buffer
)
16138 (goto-char (point-min))
16139 ;; Parse the result we got from `gnus-request-group'.
16140 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16142 (goto-char (match-beginning 1))
16144 group
(setq active
(cons (read (current-buffer))
16145 (read (current-buffer)))))
16146 ;; Return the new active info.
16149 (defun gnus-update-read-articles (group unread
)
16150 "Update the list of read and ticked articles in GROUP using the
16151 UNREAD and TICKED lists.
16152 Note: UNSELECTED has to be sorted over `<'.
16153 Returns whether the updating was successful."
16154 (let* ((active (or gnus-newsgroup-active
(gnus-active group
)))
16155 (entry (gnus-gethash group gnus-newsrc-hashtb
))
16156 (info (nth 2 entry
))
16158 (unread (sort (copy-sequence unread
) '<))
16160 (if (or (not info
) (not active
))
16161 ;; There is no info on this group if it was, in fact,
16162 ;; killed. Gnus stores no information on killed groups, so
16163 ;; there's nothing to be done.
16164 ;; One could store the information somewhere temporarily,
16165 ;; perhaps... Hmmm...
16167 ;; Remove any negative articles numbers.
16168 (while (and unread
(< (car unread
) 0))
16169 (setq unread
(cdr unread
)))
16170 ;; Remove any expired article numbers
16171 (while (and unread
(< (car unread
) (car active
)))
16172 (setq unread
(cdr unread
)))
16173 ;; Compute the ranges of read articles by looking at the list of
16174 ;; unread articles.
16176 (if (/= (car unread
) prev
)
16177 (setq read
(cons (if (= prev
(1- (car unread
))) prev
16178 (cons prev
(1- (car unread
)))) read
)))
16179 (setq prev
(1+ (car unread
)))
16180 (setq unread
(cdr unread
)))
16181 (when (<= prev
(cdr active
))
16182 (setq read
(cons (cons prev
(cdr active
)) read
)))
16183 ;; Enter this list into the group info.
16184 (gnus-info-set-read
16185 info
(if (> (length read
) 1) (nreverse read
) read
))
16186 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16187 (gnus-get-unread-articles-in-group info
(gnus-active group
))
16190 (defun gnus-make-articles-unread (group articles
)
16191 "Mark ARTICLES in GROUP as unread."
16192 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb
)
16193 (gnus-gethash (gnus-group-real-name group
)
16194 gnus-newsrc-hashtb
))))
16195 (ranges (gnus-info-read info
))
16198 (when (gnus-member-of-range
16199 (setq article
(pop articles
)) ranges
)
16200 (setq news
(cons article news
))))
16202 (gnus-info-set-read
16203 info
(gnus-remove-from-range (gnus-info-read info
) (nreverse news
)))
16204 (gnus-group-update-group group t
))))
16206 ;; Enter all dead groups into the hashtb.
16207 (defun gnus-update-active-hashtb-from-killed ()
16208 (let ((hashtb (setq gnus-active-hashtb
(make-vector 4095 0)))
16209 (lists (list gnus-killed-list gnus-zombie-list
))
16212 (setq killed
(car lists
))
16214 (gnus-sethash (car killed
) nil hashtb
)
16215 (setq killed
(cdr killed
)))
16216 (setq lists
(cdr lists
)))))
16218 (defun gnus-get-killed-groups ()
16219 "Go through the active hashtb and all all unknown groups as killed."
16220 ;; First make sure active file has been read.
16221 (unless (gnus-read-active-file-p)
16222 (let ((gnus-read-active-file t
))
16223 (gnus-read-active-file)))
16224 (or gnus-killed-hashtb
(gnus-make-hashtable-from-killed))
16225 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16229 (group (symbol-name sym
)))
16230 (if (or (null group
)
16231 (gnus-gethash group gnus-killed-hashtb
)
16232 (gnus-gethash group gnus-newsrc-hashtb
))
16234 (let ((do-sub (gnus-matches-options-n group
)))
16235 (if (or (eq do-sub
'subscribe
) (eq do-sub
'ignore
))
16237 (setq groups
(1+ groups
))
16238 (setq gnus-killed-list
16239 (cons group gnus-killed-list
))
16240 (gnus-sethash group group gnus-killed-hashtb
))))))
16241 gnus-active-hashtb
))
16243 ;; Get the active file(s) from the backend(s).
16244 (defun gnus-read-active-file ()
16245 (gnus-group-set-mode-line)
16248 (if (gnus-check-server gnus-select-method
)
16249 ;; The native server is available.
16250 (cons gnus-select-method gnus-secondary-select-methods
)
16251 ;; The native server is down, so we just do the
16253 gnus-secondary-select-methods
)
16254 ;; Also read from the archive server.
16255 (when (gnus-archive-server-wanted-p)
16256 (list "archive"))))
16258 (setq gnus-have-read-active-file nil
)
16260 (set-buffer nntp-server-buffer
)
16262 (let* ((method (if (stringp (car methods
))
16263 (gnus-server-get-method nil
(car methods
))
16265 (where (nth 1 method
))
16266 (mesg (format "Reading active file%s via %s..."
16267 (if (and where
(not (zerop (length where
))))
16268 (concat " from " where
) "")
16270 (gnus-message 5 mesg
)
16271 (when (gnus-check-server method
)
16272 ;; Request that the backend scan its incoming messages.
16273 (and (gnus-check-backend-function 'request-scan
(car method
))
16274 (gnus-request-scan nil method
))
16276 ((and (eq gnus-read-active-file
'some
)
16277 (gnus-check-backend-function 'retrieve-groups
(car method
)))
16278 (let ((newsrc (cdr gnus-newsrc-alist
))
16279 (gmethod (gnus-server-get-method nil method
))
16281 (while (setq info
(pop newsrc
))
16282 (when (gnus-server-equal
16283 (gnus-find-method-for-group
16284 (gnus-info-group info
) info
)
16286 (push (gnus-group-real-name (gnus-info-group info
))
16289 (gnus-check-server method
)
16290 (setq list-type
(gnus-retrieve-groups groups method
))
16294 1.2 "Cannot read partial active file from %s server."
16296 ((eq list-type
'active
)
16297 (gnus-active-to-gnus-format method gnus-active-hashtb
))
16299 (gnus-groups-to-gnus-format method gnus-active-hashtb
))))))
16301 (if (not (gnus-request-list method
))
16302 (unless (equal method gnus-message-archive-method
)
16303 (gnus-error 1 "Cannot read active file from %s server."
16305 (gnus-message 5 mesg
)
16306 (gnus-active-to-gnus-format method gnus-active-hashtb
)
16307 ;; We mark this active file as read.
16308 (push method gnus-have-read-active-file
)
16309 (gnus-message 5 "%sdone" mesg
))))))
16310 (setq methods
(cdr methods
))))))
16312 ;; Read an active file and place the results in `gnus-active-hashtb'.
16313 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors
)
16315 (setq method gnus-select-method
))
16316 (let ((cur (current-buffer))
16318 (if (and gnus-active-hashtb
16319 (not (equal method gnus-select-method
)))
16321 (setq gnus-active-hashtb
16322 (if (equal method gnus-select-method
)
16323 (gnus-make-hashtable
16324 (count-lines (point-min) (point-max)))
16325 (gnus-make-hashtable 4096)))))))
16326 ;; Delete unnecessary lines.
16327 (goto-char (point-min))
16328 (while (search-forward "\nto." nil t
)
16329 (delete-region (1+ (match-beginning 0))
16330 (progn (forward-line 1) (point))))
16331 (or (string= gnus-ignored-newsgroups
"")
16333 (goto-char (point-min))
16334 (delete-matching-lines gnus-ignored-newsgroups
)))
16335 ;; Make the group names readable as a lisp expression even if they
16336 ;; contain special characters.
16337 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16338 (goto-char (point-max))
16339 (while (re-search-backward "[][';?()#]" nil t
)
16341 ;; If these are groups from a foreign select method, we insert the
16342 ;; group prefix in front of the group names.
16343 (and method
(not (gnus-server-equal
16344 (gnus-server-get-method nil method
)
16345 (gnus-server-get-method nil gnus-select-method
)))
16346 (let ((prefix (gnus-group-prefixed-name "" method
)))
16347 (goto-char (point-min))
16348 (while (and (not (eobp))
16349 (progn (insert prefix
)
16350 (zerop (forward-line 1)))))))
16351 ;; Store the active file in a hash table.
16352 (goto-char (point-min))
16353 (if (string-match "%[oO]" gnus-group-line-format
)
16354 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16355 ;; If we want information on moderated groups, we use this
16357 (let* ((mod-hashtb (make-vector 7 0))
16358 (m (intern "m" mod-hashtb
))
16360 (while (not (eobp))
16361 (condition-case nil
16363 (narrow-to-region (point) (gnus-point-at-eol))
16364 (setq group
(let ((obarray hashtb
)) (read cur
)))
16365 (if (and (numberp (setq max
(read cur
)))
16366 (numberp (setq min
(read cur
)))
16368 (skip-chars-forward " \t")
16370 (or (= (following-char) ?
=)
16371 (= (following-char) ?x
)
16372 (= (following-char) ?j
)))))
16373 (set group
(cons min max
))
16375 ;; Enter moderated groups into a list.
16376 (if (eq (let ((obarray mod-hashtb
)) (read cur
)) m
)
16377 (setq gnus-moderated-list
16378 (cons (symbol-name group
) gnus-moderated-list
))))
16385 ;; And if we do not care about moderation, we use this loop,
16386 ;; which is faster.
16387 (let (group max min
)
16388 (while (not (eobp))
16391 (narrow-to-region (point) (gnus-point-at-eol))
16392 ;; group gets set to a symbol interned in the hash table
16393 ;; (what a hack!!) - jwz
16394 (setq group
(let ((obarray hashtb
)) (read cur
)))
16395 (if (and (numberp (setq max
(read cur
)))
16396 (numberp (setq min
(read cur
)))
16398 (skip-chars-forward " \t")
16400 (or (= (following-char) ?
=)
16401 (= (following-char) ?x
)
16402 (= (following-char) ?j
)))))
16403 (set group
(cons min max
))
16411 (gnus-message 3 "Warning - illegal active: %s"
16413 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16415 (forward-line 1))))))
16417 (defun gnus-groups-to-gnus-format (method &optional hashtb
)
16418 ;; Parse a "groups" active file.
16419 (let ((cur (current-buffer))
16421 (if (and method gnus-active-hashtb
)
16423 (setq gnus-active-hashtb
16424 (gnus-make-hashtable
16425 (count-lines (point-min) (point-max)))))))
16426 (prefix (and method
16427 (not (gnus-server-equal
16428 (gnus-server-get-method nil method
)
16429 (gnus-server-get-method nil gnus-select-method
)))
16430 (gnus-group-prefixed-name "" method
))))
16432 (goto-char (point-min))
16433 ;; We split this into to separate loops, one with the prefix
16434 ;; and one without to speed the reading up somewhat.
16436 (let (min max opoint group
)
16437 (while (not (eobp))
16440 (read cur
) (read cur
)
16441 (setq min
(read cur
)
16444 (skip-chars-forward " \t")
16447 (set (let ((obarray hashtb
)) (read cur
))
16449 (error (and group
(symbolp group
) (set group nil
))))
16451 (let (min max group
)
16452 (while (not (eobp))
16454 (if (= (following-char) ?
2)
16456 (read cur
) (read cur
)
16457 (setq min
(read cur
)
16459 (set (setq group
(let ((obarray hashtb
)) (read cur
)))
16461 (error (and group
(symbolp group
) (set group nil
))))
16462 (forward-line 1))))))
16464 (defun gnus-read-newsrc-file (&optional force
)
16465 "Read startup file.
16466 If FORCE is non-nil, the .newsrc file is read."
16467 ;; Reset variables that might be defined in the .newsrc.eld file.
16468 (let ((variables gnus-variable-list
))
16470 (set (car variables
) nil
)
16471 (setq variables
(cdr variables
))))
16472 (let* ((newsrc-file gnus-current-startup-file
)
16473 (quick-file (concat newsrc-file
".el")))
16475 ;; We always load the .newsrc.eld file. If always contains
16476 ;; much information that can not be gotten from the .newsrc
16477 ;; file (ticked articles, killed groups, foreign methods, etc.)
16478 (gnus-read-newsrc-el-file quick-file
)
16480 (if (and (file-exists-p gnus-current-startup-file
)
16482 (and (file-newer-than-file-p newsrc-file quick-file
)
16483 (file-newer-than-file-p newsrc-file
16484 (concat quick-file
"d")))
16485 (not gnus-newsrc-alist
)))
16486 ;; We read the .newsrc file. Note that if there if a
16487 ;; .newsrc.eld file exists, it has already been read, and
16488 ;; the `gnus-newsrc-hashtb' has been created. While reading
16489 ;; the .newsrc file, Gnus will only use the information it
16490 ;; can find there for changing the data already read -
16491 ;; ie. reading the .newsrc file will not trash the data
16492 ;; already read (except for read articles).
16494 (gnus-message 5 "Reading %s..." newsrc-file
)
16495 (set-buffer (find-file-noselect newsrc-file
))
16496 (buffer-disable-undo (current-buffer))
16497 (gnus-newsrc-to-gnus-format)
16498 (kill-buffer (current-buffer))
16499 (gnus-message 5 "Reading %s...done" newsrc-file
)))
16501 ;; Read any slave files.
16503 (gnus-master-read-slave-newsrc))
16505 ;; Convert old to new.
16506 (gnus-convert-old-newsrc))))
16508 (defun gnus-continuum-version (version)
16509 "Return VERSION as a floating point number."
16510 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version
)
16511 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version
))
16512 (let* ((alpha (and (match-beginning 1) (match-string 1 version
)))
16513 (number (match-string 2 version
))
16515 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number
)
16516 (setq major
(string-to-number (match-string 1 number
)))
16517 (setq minor
(string-to-number (match-string 2 number
)))
16518 (setq least
(if (match-beginning 3)
16519 (string-to-number (match-string 3 number
))
16523 (format "%s00%02d%02d"
16525 ((member alpha
'("(ding)" "d")) "4.99")
16526 ((member alpha
'("September" "s")) "5.01")
16527 ((member alpha
'("Red" "r")) "5.03"))
16529 (format "%d.%02d%02d" major minor least
))))))
16531 (defun gnus-convert-old-newsrc ()
16532 "Convert old newsrc into the new format, if needed."
16533 (let ((fcv (and gnus-newsrc-file-version
16534 (gnus-continuum-version gnus-newsrc-file-version
))))
16536 ;; No .newsrc.eld file was loaded.
16538 ;; Gnus 5 .newsrc.eld was loaded.
16539 ((< fcv
(gnus-continuum-version "September Gnus v0.1"))
16540 (gnus-convert-old-ticks)))))
16542 (defun gnus-convert-old-ticks ()
16543 (let ((newsrc (cdr gnus-newsrc-alist
))
16544 marks info dormant ticked
)
16545 (while (setq info
(pop newsrc
))
16546 (when (setq marks
(gnus-info-marks info
))
16547 (setq dormant
(cdr (assq 'dormant marks
))
16548 ticked
(cdr (assq 'tick marks
)))
16549 (when (or dormant ticked
)
16550 (gnus-info-set-read
16553 (gnus-info-read info
)
16554 (nconc (gnus-uncompress-range dormant
)
16555 (gnus-uncompress-range ticked
)))))))))
16557 (defun gnus-read-newsrc-el-file (file)
16558 (let ((ding-file (concat file
"d")))
16559 ;; We always, always read the .eld file.
16560 (gnus-message 5 "Reading %s..." ding-file
)
16561 (let (gnus-newsrc-assoc)
16562 (condition-case nil
16563 (load ding-file t t t
)
16565 (gnus-error 1 "Error in %s" ding-file
)))
16566 (when gnus-newsrc-assoc
16567 (setq gnus-newsrc-alist gnus-newsrc-assoc
)))
16568 (gnus-make-hashtable-from-newsrc-alist)
16569 (when (file-newer-than-file-p file ding-file
)
16570 ;; Old format quick file
16571 (gnus-message 5 "Reading %s..." file
)
16572 ;; The .el file is newer than the .eld file, so we read that one
16574 (gnus-read-old-newsrc-el-file file
))))
16576 ;; Parse the old-style quick startup file
16577 (defun gnus-read-old-newsrc-el-file (file)
16578 (let (newsrc killed marked group m info
)
16580 (let ((gnus-killed-assoc nil
)
16581 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc
)
16583 (condition-case nil
16586 (setq newsrc gnus-newsrc-assoc
16587 killed gnus-killed-assoc
16588 marked gnus-marked-assoc
)))
16589 (setq gnus-newsrc-alist nil
)
16590 (while (setq group
(pop newsrc
))
16591 (if (setq info
(gnus-get-info (car group
)))
16593 (gnus-info-set-read info
(cddr group
))
16594 (gnus-info-set-level
16595 info
(if (nth 1 group
) gnus-level-default-subscribed
16596 gnus-level-default-unsubscribed
))
16597 (setq gnus-newsrc-alist
(cons info gnus-newsrc-alist
)))
16600 (if (nth 1 group
) gnus-level-default-subscribed
16601 gnus-level-default-unsubscribed
)
16603 gnus-newsrc-alist
))
16604 ;; Copy marks into info.
16605 (when (setq m
(assoc (car group
) marked
))
16606 (unless (nthcdr 3 info
)
16607 (nconc info
(list nil
)))
16608 (gnus-info-set-marks
16609 info
(list (cons 'tick
(gnus-compress-sequence
16610 (sort (cdr m
) '<) t
))))))
16611 (setq newsrc killed
)
16613 (setcar newsrc
(caar newsrc
))
16614 (setq newsrc
(cdr newsrc
)))
16615 (setq gnus-killed-list killed
))
16616 ;; The .el file version of this variable does not begin with
16617 ;; "options", while the .eld version does, so we just add it if it
16620 gnus-newsrc-options
16622 (and (not (string-match "^ *options" gnus-newsrc-options
))
16623 (setq gnus-newsrc-options
(concat "options " gnus-newsrc-options
)))
16624 (and (not (string-match "\n$" gnus-newsrc-options
))
16625 (setq gnus-newsrc-options
(concat gnus-newsrc-options
"\n")))
16626 ;; Finally, if we read some options lines, we parse them.
16627 (or (string= gnus-newsrc-options
"")
16628 (gnus-newsrc-parse-options gnus-newsrc-options
))))
16630 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
))
16631 (gnus-make-hashtable-from-newsrc-alist)))
16633 (defun gnus-make-newsrc-file (file)
16634 "Make server dependent file name by catenating FILE and server host name."
16635 (let* ((file (expand-file-name file nil
))
16636 (real-file (concat file
"-" (nth 1 gnus-select-method
))))
16637 (if (or (file-exists-p real-file
)
16638 (file-exists-p (concat real-file
".el"))
16639 (file-exists-p (concat real-file
".eld")))
16642 (defun gnus-newsrc-to-gnus-format ()
16643 (setq gnus-newsrc-options
"")
16644 (setq gnus-newsrc-options-n nil
)
16646 (or gnus-active-hashtb
16647 (setq gnus-active-hashtb
(make-vector 4095 0)))
16648 (let ((buf (current-buffer))
16649 (already-read (> (length gnus-newsrc-alist
) 1))
16650 group subscribed options-symbol newsrc Options-symbol
16652 (goto-char (point-min))
16653 ;; We intern the symbol `options' in the active hashtb so that we
16654 ;; can `eq' against it later.
16655 (set (setq options-symbol
(intern "options" gnus-active-hashtb
)) nil
)
16656 (set (setq Options-symbol
(intern "Options" gnus-active-hashtb
)) nil
)
16658 (while (not (eobp))
16659 ;; We first read the first word on the line by narrowing and
16660 ;; then reading into `gnus-active-hashtb'. Most groups will
16661 ;; already exist in that hashtb, so this will save some string
16665 (progn (skip-chars-forward "^ \t!:\n") (point)))
16666 (goto-char (point-min))
16668 (and (/= (point-min) (point-max))
16669 (let ((obarray gnus-active-hashtb
)) (read buf
))))
16671 ;; Now, the symbol we have read is either `options' or a group
16672 ;; name. If it is an options line, we just add it to a string.
16674 ((or (eq symbol options-symbol
)
16675 (eq symbol Options-symbol
))
16676 (setq gnus-newsrc-options
16677 ;; This concating is quite inefficient, but since our
16678 ;; thorough studies show that approx 99.37% of all
16679 ;; .newsrc files only contain a single options line, we
16680 ;; don't give a damn, frankly, my dear.
16681 (concat gnus-newsrc-options
16683 (gnus-point-at-bol)
16684 ;; Options may continue on the next line.
16685 (or (and (re-search-forward "^[^ \t]" nil
'move
)
16686 (progn (beginning-of-line) (point)))
16690 ;; Group names can be just numbers.
16691 (when (numberp symbol
)
16692 (setq symbol
(intern (int-to-string symbol
) gnus-active-hashtb
)))
16693 (or (boundp symbol
) (set symbol nil
))
16694 ;; It was a group name.
16695 (setq subscribed
(= (following-char) ?
:)
16696 group
(symbol-name symbol
)
16699 ;; If the line ends here, this is clearly a buggy line, so
16700 ;; we put point a the beginning of line and let the cond
16701 ;; below do the error handling.
16702 (beginning-of-line)
16703 ;; We skip to the beginning of the ranges.
16704 (skip-chars-forward "!: \t"))
16705 ;; We are now at the beginning of the list of read articles.
16706 ;; We read them range by range.
16709 ((looking-at "[0-9]+")
16710 ;; We narrow and read a number instead of buffer-substring/
16711 ;; string-to-int because it's faster. narrow/widen is
16712 ;; faster than save-restriction/narrow, and save-restriction
16713 ;; produces a garbage object.
16715 (narrow-to-region (match-beginning 0) (match-end 0))
16718 ;; If the next character is a dash, then this is a range.
16719 (if (= (following-char) ?-
)
16721 ;; We read the upper bound of the range.
16723 (if (not (looking-at "[0-9]+"))
16724 ;; This is a buggy line, by we pretend that
16725 ;; it's kinda OK. Perhaps the user should be
16727 (setq reads
(cons num1 reads
))
16732 (narrow-to-region (match-beginning 0)
16737 ;; It was just a simple number, so we add it to the
16739 (setq reads
(cons num1 reads
)))
16740 ;; If the next char in ?\n, then we have reached the end
16741 ;; of the line and return nil.
16742 (/= (following-char) ?
\n))
16743 ((= (following-char) ?
\n)
16744 ;; End of line, so we end.
16747 ;; Not numbers and not eol, so this might be a buggy
16750 ;; If it was eob instead of ?\n, we allow it.
16752 ;; The line was buggy.
16754 (gnus-error 3.1 "Mangled line: %s"
16755 (buffer-substring (gnus-point-at-bol)
16756 (gnus-point-at-eol)))))
16758 ;; Skip past ", ". Spaces are illegal in these ranges, but
16759 ;; we allow them, because it's a common mistake to put a
16760 ;; space after the comma.
16761 (skip-chars-forward ", "))
16763 ;; We have already read .newsrc.eld, so we gently update the
16764 ;; data in the hash table with the information we have just
16767 (let ((info (gnus-get-info group
))
16770 ;; There is an entry for this file in the alist.
16772 (gnus-info-set-read info
(nreverse reads
))
16773 ;; We update the level very gently. In fact, we
16774 ;; only change it if there's been a status change
16775 ;; from subscribed to unsubscribed, or vice versa.
16776 (setq level
(gnus-info-level info
))
16777 (cond ((and (<= level gnus-level-subscribed
)
16779 (setq level
(if reads
16780 gnus-level-default-unsubscribed
16781 (1+ gnus-level-default-unsubscribed
))))
16782 ((and (> level gnus-level-subscribed
) subscribed
)
16783 (setq level gnus-level-default-subscribed
)))
16784 (gnus-info-set-level info level
))
16785 ;; This is a new group.
16786 (setq info
(list group
16788 gnus-level-default-subscribed
16790 (1+ gnus-level-subscribed
)
16791 gnus-level-default-unsubscribed
))
16792 (nreverse reads
))))
16793 (setq newsrc
(cons info newsrc
))))))
16796 (setq newsrc
(nreverse newsrc
))
16798 (if (not already-read
)
16800 ;; We now have two newsrc lists - `newsrc', which is what we
16801 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16802 ;; what we've read from .newsrc.eld. We have to merge these
16803 ;; lists. We do this by "attaching" any (foreign) groups in the
16804 ;; gnus-newsrc-alist to the (native) group that precedes them.
16805 (let ((rc (cdr gnus-newsrc-alist
))
16806 (prev gnus-newsrc-alist
)
16809 (or (null (nth 4 (car rc
))) ; It's a native group.
16810 (assoc (caar rc
) newsrc
) ; It's already in the alist.
16811 (if (setq entry
(assoc (caar prev
) newsrc
))
16812 (setcdr (setq mentry
(memq entry newsrc
))
16813 (cons (car rc
) (cdr mentry
)))
16814 (setq newsrc
(cons (car rc
) newsrc
))))
16818 (setq gnus-newsrc-alist newsrc
)
16819 ;; We make the newsrc hashtb.
16820 (gnus-make-hashtable-from-newsrc-alist)
16822 ;; Finally, if we read some options lines, we parse them.
16823 (or (string= gnus-newsrc-options
"")
16824 (gnus-newsrc-parse-options gnus-newsrc-options
))))
16826 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16827 ;; The return value will be a list on the form
16828 ;; ((regexp1 . ignore)
16829 ;; (regexp2 . subscribe)...)
16830 ;; When handling new newsgroups, groups that match a `ignore' regexp
16831 ;; will be ignored, and groups that match a `subscribe' regexp will be
16832 ;; subscribed. A line like
16833 ;; options -n !all rec.all
16834 ;; will lead to a list that looks like
16835 ;; (("^rec\\..+" . subscribe)
16836 ;; ("^.+" . ignore))
16837 ;; So all "rec.*" groups will be subscribed, while all the other
16838 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16839 ;; different from "options -n rec.all !all".
16840 (defun gnus-newsrc-parse-options (options)
16843 (gnus-set-work-buffer)
16844 (insert (regexp-quote options
))
16845 ;; First we treat all continuation lines.
16846 (goto-char (point-min))
16847 (while (re-search-forward "\n[ \t]+" nil t
)
16848 (replace-match " " t t
))
16849 ;; Then we transform all "all"s into ".+"s.
16850 (goto-char (point-min))
16851 (while (re-search-forward "\\ball\\b" nil t
)
16852 (replace-match ".+" t t
))
16853 (goto-char (point-min))
16854 ;; We remove all other options than the "-n" ones.
16855 (while (re-search-forward "[ \t]-[^n][^-]*" nil t
)
16856 (replace-match " ")
16858 (goto-char (point-min))
16860 ;; We are only interested in "options -n" lines - we
16861 ;; ignore the other option lines.
16862 (while (re-search-forward "[ \t]-n" nil t
)
16864 (or (save-excursion
16865 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t
)
16867 (gnus-point-at-eol)))
16868 ;; Search for all "words"...
16869 (while (re-search-forward "[^ \t,\n]+" eol t
)
16870 (if (= (char-after (match-beginning 0)) ?
!)
16871 ;; If the word begins with a bang (!), this is a "not"
16872 ;; spec. We put this spec (minus the bang) and the
16873 ;; symbol `ignore' into the list.
16874 (setq out
(cons (cons (concat
16875 "^" (buffer-substring
16876 (1+ (match-beginning 0))
16879 ;; There was no bang, so this is a "yes" spec.
16880 (setq out
(cons (cons (concat "^" (match-string 0))
16881 'subscribe
) out
)))))
16883 (setq gnus-newsrc-options-n out
))))
16885 (defun gnus-save-newsrc-file (&optional force
)
16886 "Save .newsrc file."
16887 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16888 ;; from the variable gnus-newsrc-alist.
16889 (when (and (or gnus-newsrc-alist gnus-killed-list
)
16890 gnus-current-startup-file
)
16892 (if (and (or gnus-use-dribble-file gnus-slave
)
16894 (or (not gnus-dribble-buffer
)
16895 (not (buffer-name gnus-dribble-buffer
))
16896 (zerop (save-excursion
16897 (set-buffer gnus-dribble-buffer
)
16899 (gnus-message 4 "(No changes need to be saved)")
16900 (run-hooks 'gnus-save-newsrc-hook
)
16902 (gnus-slave-save-newsrc)
16904 (when gnus-save-newsrc-file
16905 (gnus-message 5 "Saving %s..." gnus-current-startup-file
)
16906 (gnus-gnus-to-newsrc-format)
16907 (gnus-message 5 "Saving %s...done" gnus-current-startup-file
))
16908 ;; Save .newsrc.eld.
16909 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16910 (make-local-variable 'version-control
)
16911 (setq version-control
'never
)
16912 (setq buffer-file-name
16913 (concat gnus-current-startup-file
".eld"))
16914 (setq default-directory
(file-name-directory buffer-file-name
))
16915 (gnus-add-current-to-buffer-list)
16916 (buffer-disable-undo (current-buffer))
16918 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file
)
16919 (gnus-gnus-to-quick-newsrc-format)
16920 (run-hooks 'gnus-save-quick-newsrc-hook
)
16922 (kill-buffer (current-buffer))
16924 5 "Saving %s.eld...done" gnus-current-startup-file
))
16925 (gnus-dribble-delete-file)
16926 (gnus-group-set-mode-line)))))
16928 (defun gnus-gnus-to-quick-newsrc-format ()
16929 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16930 (insert ";; Gnus startup file.\n")
16931 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16932 (insert ";; to read .newsrc.\n")
16933 (insert "(setq gnus-newsrc-file-version "
16934 (prin1-to-string gnus-version
) ")\n")
16936 (if gnus-save-killed-list gnus-variable-list
16937 ;; Remove the `gnus-killed-list' from the list of variables
16938 ;; to be saved, if required.
16939 (delq 'gnus-killed-list
(copy-sequence gnus-variable-list
))))
16940 ;; Peel off the "dummy" group.
16941 (gnus-newsrc-alist (cdr gnus-newsrc-alist
))
16943 ;; Insert the variables into the file.
16945 (when (and (boundp (setq variable
(pop variables
)))
16946 (symbol-value variable
))
16947 (insert "(setq " (symbol-name variable
) " '")
16948 (prin1 (symbol-value variable
) (current-buffer))
16951 (defun gnus-gnus-to-newsrc-format ()
16952 ;; Generate and save the .newsrc file.
16954 (set-buffer (create-file-buffer gnus-current-startup-file
))
16955 (let ((newsrc (cdr gnus-newsrc-alist
))
16956 (standard-output (current-buffer))
16957 info ranges range method
)
16958 (setq buffer-file-name gnus-current-startup-file
)
16959 (setq default-directory
(file-name-directory buffer-file-name
))
16960 (buffer-disable-undo (current-buffer))
16963 (if gnus-newsrc-options
(insert gnus-newsrc-options
))
16964 ;; Write subscribed and unsubscribed.
16965 (while (setq info
(pop newsrc
))
16966 ;; Don't write foreign groups to .newsrc.
16967 (when (or (null (setq method
(gnus-info-method info
)))
16968 (equal method
"native")
16969 (gnus-server-equal method gnus-select-method
))
16970 (insert (gnus-info-group info
)
16971 (if (> (gnus-info-level info
) gnus-level-subscribed
)
16973 (when (setq ranges
(gnus-info-read info
))
16975 (if (not (listp (cdr ranges
)))
16976 (if (= (car ranges
) (cdr ranges
))
16977 (princ (car ranges
))
16978 (princ (car ranges
))
16980 (princ (cdr ranges
)))
16981 (while (setq range
(pop ranges
))
16982 (if (or (atom range
) (= (car range
) (cdr range
)))
16983 (princ (or (and (atom range
) range
) (car range
)))
16984 (princ (car range
))
16986 (princ (cdr range
)))
16987 (if ranges
(insert ",")))))
16989 (make-local-variable 'version-control
)
16990 (setq version-control
'never
)
16991 ;; It has been reported that sometime the modtime on the .newsrc
16992 ;; file seems to be off. We really do want to overwrite it, so
16993 ;; we clear the modtime here before saving. It's a bit odd,
16995 ;; sometimes the modtime clear isn't sufficient. most brute force:
16996 ;; delete the silly thing entirely first. but this fails to provide
16997 ;; such niceties as .newsrc~ creation.
16998 (if gnus-modtime-botch
16999 (delete-file gnus-startup-file
)
17000 (clear-visited-file-modtime))
17001 (run-hooks 'gnus-save-standard-newsrc-hook
)
17003 (kill-buffer (current-buffer)))))
17007 ;;; Slave functions.
17010 (defun gnus-slave-save-newsrc ()
17012 (set-buffer gnus-dribble-buffer
)
17014 (make-temp-name (concat gnus-current-startup-file
"-slave-"))))
17015 (write-region (point-min) (point-max) slave-name nil
'nomesg
))))
17017 (defun gnus-master-read-slave-newsrc ()
17020 (file-name-directory gnus-current-startup-file
)
17024 (file-name-nondirectory gnus-current-startup-file
)
17028 (if (not slave-files
)
17029 () ; There are no slave files to read.
17030 (gnus-message 7 "Reading slave newsrcs...")
17032 (set-buffer (get-buffer-create " *gnus slave*"))
17033 (buffer-disable-undo (current-buffer))
17035 (sort (mapcar (lambda (file)
17036 (list (nth 5 (file-attributes file
)) file
))
17039 (or (< (caar f1
) (caar f2
))
17040 (< (nth 1 (car f1
)) (nth 1 (car f2
)))))))
17043 (setq file
(nth 1 (car slave-files
)))
17044 (insert-file-contents file
)
17045 (if (condition-case ()
17047 (eval-buffer (current-buffer))
17050 (gnus-error 3.2 "Possible error in %s" file
)
17052 (or gnus-slave
; Slaves shouldn't delete these files.
17056 (setq slave-files
(cdr slave-files
))))
17057 (gnus-message 7 "Reading slave newsrcs...done"))))
17061 ;;; Group description.
17064 (defun gnus-read-all-descriptions-files ()
17065 (let ((methods (cons gnus-select-method
17067 (when (gnus-archive-server-wanted-p)
17069 gnus-secondary-select-methods
))))
17071 (gnus-read-descriptions-file (car methods
))
17072 (setq methods
(cdr methods
)))
17075 (defun gnus-read-descriptions-file (&optional method
)
17076 (let ((method (or method gnus-select-method
))
17078 (when (stringp method
)
17079 (setq method
(gnus-server-to-method method
)))
17080 ;; We create the hashtable whether we manage to read the desc file
17081 ;; to avoid trying to re-read after a failed read.
17082 (or gnus-description-hashtb
17083 (setq gnus-description-hashtb
17084 (gnus-make-hashtable (length gnus-active-hashtb
))))
17085 ;; Mark this method's desc file as read.
17086 (gnus-sethash (gnus-group-prefixed-name "" method
) "Has read"
17087 gnus-description-hashtb
)
17089 (gnus-message 5 "Reading descriptions file via %s..." (car method
))
17091 ((not (gnus-check-server method
))
17092 (gnus-message 1 "Couldn't open server")
17094 ((not (gnus-request-list-newsgroups method
))
17095 (gnus-message 1 "Couldn't read newsgroups descriptions")
17100 (set-buffer nntp-server-buffer
)
17101 (goto-char (point-min))
17102 (when (or (search-forward "\n.\n" nil t
)
17103 (goto-char (point-max)))
17104 (beginning-of-line)
17105 (narrow-to-region (point-min) (point)))
17106 ;; If these are groups from a foreign select method, we insert the
17107 ;; group prefix in front of the group names.
17108 (and method
(not (gnus-server-equal
17109 (gnus-server-get-method nil method
)
17110 (gnus-server-get-method nil gnus-select-method
)))
17111 (let ((prefix (gnus-group-prefixed-name "" method
)))
17112 (goto-char (point-min))
17113 (while (and (not (eobp))
17114 (progn (insert prefix
)
17115 (zerop (forward-line 1)))))))
17116 (goto-char (point-min))
17117 (while (not (eobp))
17118 ;; If we get an error, we set group to 0, which is not a
17122 (let ((obarray gnus-description-hashtb
))
17123 ;; Group is set to a symbol interned in this
17125 (read nntp-server-buffer
))
17127 (skip-chars-forward " \t")
17128 ;; ... which leads to this line being effectively ignored.
17129 (and (symbolp group
)
17130 (set group
(buffer-substring
17131 (point) (progn (end-of-line) (point)))))
17132 (forward-line 1))))
17133 (gnus-message 5 "Reading descriptions file...done")
17136 (defun gnus-group-get-description (group)
17137 "Get the description of a group by sending XGTITLE to the server."
17138 (when (gnus-request-group-description group
)
17140 (set-buffer nntp-server-buffer
)
17141 (goto-char (point-min))
17142 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17143 (match-string 1)))))
17147 ;;; Buffering of read articles.
17150 (defvar gnus-backlog-buffer
" *Gnus Backlog*")
17151 (defvar gnus-backlog-articles nil
)
17152 (defvar gnus-backlog-hashtb nil
)
17154 (defun gnus-backlog-buffer ()
17155 "Return the backlog buffer."
17156 (or (get-buffer gnus-backlog-buffer
)
17158 (set-buffer (get-buffer-create gnus-backlog-buffer
))
17159 (buffer-disable-undo (current-buffer))
17160 (setq buffer-read-only t
)
17161 (gnus-add-current-to-buffer-list)
17162 (get-buffer gnus-backlog-buffer
))))
17164 (defun gnus-backlog-setup ()
17165 "Initialize backlog variables."
17166 (unless gnus-backlog-hashtb
17167 (setq gnus-backlog-hashtb
(make-vector 1023 0))))
17169 (gnus-add-shutdown 'gnus-backlog-shutdown
'gnus
)
17171 (defun gnus-backlog-shutdown ()
17172 "Clear all backlog variables and buffers."
17173 (when (get-buffer gnus-backlog-buffer
)
17174 (kill-buffer gnus-backlog-buffer
))
17175 (setq gnus-backlog-hashtb nil
17176 gnus-backlog-articles nil
))
17178 (defun gnus-backlog-enter-article (group number buffer
)
17179 (gnus-backlog-setup)
17180 (let ((ident (intern (concat group
":" (int-to-string number
))
17181 gnus-backlog-hashtb
))
17183 (if (memq ident gnus-backlog-articles
)
17184 () ; It's already kept.
17185 ;; Remove the oldest article, if necessary.
17186 (and (numberp gnus-keep-backlog
)
17187 (>= (length gnus-backlog-articles
) gnus-keep-backlog
)
17188 (gnus-backlog-remove-oldest-article))
17189 (setq gnus-backlog-articles
(cons ident gnus-backlog-articles
))
17190 ;; Insert the new article.
17192 (set-buffer (gnus-backlog-buffer))
17193 (let (buffer-read-only)
17194 (goto-char (point-max))
17195 (or (bolp) (insert "\n"))
17197 (insert-buffer-substring buffer
)
17198 ;; Tag the beginning of the article with the ident.
17199 (gnus-put-text-property b
(1+ b
) 'gnus-backlog ident
))))))
17201 (defun gnus-backlog-remove-oldest-article ()
17203 (set-buffer (gnus-backlog-buffer))
17204 (goto-char (point-min))
17205 (if (zerop (buffer-size))
17206 () ; The buffer is empty.
17207 (let ((ident (get-text-property (point) 'gnus-backlog
))
17209 ;; Remove the ident from the list of articles.
17211 (setq gnus-backlog-articles
(delq ident gnus-backlog-articles
)))
17212 ;; Delete the article itself.
17214 (point) (next-single-property-change
17215 (1+ (point)) 'gnus-backlog nil
(point-max)))))))
17217 (defun gnus-backlog-remove-article (group number
)
17218 "Remove article NUMBER in GROUP from the backlog."
17219 (when (numberp number
)
17220 (gnus-backlog-setup)
17221 (let ((ident (intern (concat group
":" (int-to-string number
))
17222 gnus-backlog-hashtb
))
17224 (when (memq ident gnus-backlog-articles
)
17225 ;; It was in the backlog.
17227 (set-buffer (gnus-backlog-buffer))
17228 (let (buffer-read-only)
17229 (when (setq beg
(text-property-any
17230 (point-min) (point-max) 'gnus-backlog
17232 ;; Find the end (i. e., the beginning of the next article).
17234 (next-single-property-change
17235 (1+ beg
) 'gnus-backlog
(current-buffer) (point-max)))
17236 (delete-region beg end
)
17240 (defun gnus-backlog-request-article (group number buffer
)
17241 (when (numberp number
)
17242 (gnus-backlog-setup)
17243 (let ((ident (intern (concat group
":" (int-to-string number
))
17244 gnus-backlog-hashtb
))
17246 (when (memq ident gnus-backlog-articles
)
17247 ;; It was in the backlog.
17249 (set-buffer (gnus-backlog-buffer))
17250 (if (not (setq beg
(text-property-any
17251 (point-min) (point-max) 'gnus-backlog
17253 ;; It wasn't in the backlog after all.
17255 (setq gnus-backlog-articles
(delq ident gnus-backlog-articles
)))
17256 ;; Find the end (i. e., the beginning of the next article).
17258 (next-single-property-change
17259 (1+ beg
) 'gnus-backlog
(current-buffer) (point-max)))))
17260 (let ((buffer-read-only nil
))
17262 (insert-buffer-substring gnus-backlog-buffer beg end
)
17265 ;; Allow redefinition of Gnus functions.
17267 (gnus-ems-redefine)
17271 ;;; gnus.el ends here