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-refer-article-method nil
153 "*Preferred method for fetching an article by Message-ID.
154 If you are reading news from the local spool (with nnspool), fetching
155 articles by Message-ID is painfully slow. By setting this method to an
156 nntp method, you might get acceptable results.
158 The value of this variable must be a valid select method as discussed
159 in the documentation of `gnus-select-method'.")
161 (defvar gnus-secondary-select-methods nil
162 "*A list of secondary methods that will be used for reading news.
163 This is a list where each element is a complete select method (see
164 `gnus-select-method').
166 If, for instance, you want to read your mail with the nnml backend,
167 you could set this variable:
169 (setq gnus-secondary-select-methods '((nnml \"\")))")
171 (defvar gnus-secondary-servers nil
172 "*List of NNTP servers that the user can choose between interactively.
173 To make Gnus query you for a server, you have to give `gnus' a
174 non-numeric prefix - `C-u M-x gnus', in short.")
176 (defvar gnus-nntp-server nil
177 "*The name of the host running the NNTP server.
178 This variable is semi-obsolete. Use the `gnus-select-method'
181 (defvar gnus-startup-file
"~/.newsrc"
182 "*Your `.newsrc' file.
183 `.newsrc-SERVER' will be used instead if that exists.")
185 (defvar gnus-init-file
"~/.gnus"
186 "*Your Gnus elisp startup file.
187 If a file with the .el or .elc suffixes exist, it will be read
190 (defvar gnus-group-faq-directory
191 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
192 "/ftp@sunsite.auc.dk:/pub/usenet/"
193 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
194 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
195 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
196 "/ftp@rtfm.mit.edu:/pub/usenet/"
197 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
198 "/ftp@ftp.sunet.se:/pub/usenet/"
199 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
200 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
201 "/ftp@ftp.hk.super.net:/mirror/faqs/")
202 "*Directory where the group FAQs are stored.
203 This will most commonly be on a remote machine, and the file will be
206 This variable can also be a list of directories. In that case, the
207 first element in the list will be used by default, and the others will
208 be used as backup sites.
210 Note that Gnus uses an aol machine as the default directory. If this
211 feels fundamentally unclean, just think of it as a way to finally get
212 something of value back from them.
214 If the default site is too slow, try one of these:
216 North America: mirrors.aol.com /pub/rtfm/usenet
217 ftp.seas.gwu.edu /pub/rtfm
218 rtfm.mit.edu /pub/usenet
219 Europe: ftp.uni-paderborn.de /pub/FAQ
220 src.doc.ic.ac.uk /usenet/news-FAQS
221 ftp.sunet.se /pub/usenet
222 sunsite.auc.dk /pub/usenet
223 Asia: nctuccca.edu.tw /USENET/FAQ
224 hwarang.postech.ac.kr /pub/usenet
225 ftp.hk.super.net /mirror/faqs")
227 (defvar gnus-group-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
229 "*The address of the (ding) archives.")
231 (defvar gnus-group-recent-archive-directory
232 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
233 "*The address of the most recent (ding) articles.")
235 (defvar gnus-default-subscribed-newsgroups nil
236 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
237 It should be a list of strings.
238 If it is `t', Gnus will not do anything special the first time it is
239 started; it'll just use the normal newsgroups subscription methods.")
241 (defvar gnus-use-cross-reference t
242 "*Non-nil means that cross referenced articles will be marked as read.
243 If nil, ignore cross references. If t, mark articles as read in
244 subscribed newsgroups. If neither t nor nil, mark as read in all
247 (defvar gnus-single-article-buffer t
248 "*If non-nil, display all articles in the same buffer.
249 If nil, each group will get its own article buffer.")
251 (defvar gnus-use-dribble-file t
252 "*Non-nil means that Gnus will use a dribble file to store user updates.
253 If Emacs should crash without saving the .newsrc files, complete
254 information can be restored from the dribble file.")
256 (defvar gnus-dribble-directory nil
257 "*The directory where dribble files will be saved.
258 If this variable is nil, the directory where the .newsrc files are
259 saved will be used.")
261 (defvar gnus-asynchronous nil
262 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
264 (defvar gnus-kill-summary-on-exit t
265 "*If non-nil, kill the summary buffer when you exit from it.
266 If nil, the summary will become a \"*Dead Summary*\" buffer, and
267 it will be killed sometime later.")
269 (defvar gnus-large-newsgroup
200
270 "*The number of articles which indicates a large newsgroup.
271 If the number of articles in a newsgroup is greater than this value,
272 confirmation is required for selecting the newsgroup.")
274 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
275 (defvar gnus-no-groups-message
"No news is horrible news"
276 "*Message displayed by Gnus when no groups are available.")
278 (defvar gnus-use-long-file-name
(not (memq system-type
'(usg-unix-v xenix
)))
279 "*Non-nil means that the default name of a file to save articles in is the group name.
280 If it's nil, the directory form of the group name is used instead.
282 If this variable is a list, and the list contains the element
283 `not-score', long file names will not be used for score files; if it
284 contains the element `not-save', long file names will not be used for
285 saving; and if it contains the element `not-kill', long file names
286 will not be used for kill files.
288 Note that the default for this variable varies according to what system
289 type you're using. On `usg-unix-v' and `xenix' this variable defaults
290 to nil while on all other systems it defaults to t.")
292 (defvar gnus-article-save-directory gnus-directory
293 "*Name of the directory articles will be saved in (default \"~/News\").")
295 (defvar gnus-kill-files-directory gnus-directory
296 "*Name of the directory where kill files will be stored (default \"~/News\").")
298 (defvar gnus-default-article-saver
'gnus-summary-save-in-rmail
299 "*A function to save articles in your favorite format.
300 The function must be interactively callable (in other words, it must
301 be an Emacs command).
303 Gnus provides the following functions:
305 * gnus-summary-save-in-rmail (Rmail format)
306 * gnus-summary-save-in-mail (Unix mail format)
307 * gnus-summary-save-in-folder (MH folder)
308 * gnus-summary-save-in-file (article format).
309 * gnus-summary-save-in-vm (use VM's folder format).")
311 (defvar gnus-prompt-before-saving
'always
312 "*This variable says how much prompting is to be done when saving articles.
313 If it is nil, no prompting will be done, and the articles will be
314 saved to the default files. If this variable is `always', each and
315 every article that is saved will be preceded by a prompt, even when
316 saving large batches of articles. If this variable is neither nil not
317 `always', there the user will be prompted once for a file name for
318 each invocation of the saving commands.")
320 (defvar gnus-rmail-save-name
(function gnus-plain-save-name
)
321 "*A function generating a file name to save articles in Rmail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-mail-save-name
(function gnus-plain-save-name
)
325 "*A function generating a file name to save articles in Unix mail format.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
328 (defvar gnus-folder-save-name
(function gnus-folder-save-name
)
329 "*A function generating a file name to save articles in MH folder.
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
332 (defvar gnus-file-save-name
(function gnus-numeric-save-name
)
333 "*A function generating a file name to save articles in article format.
334 The function is called with NEWSGROUP, HEADERS, and optional
337 (defvar gnus-split-methods
338 '((gnus-article-archive-name))
339 "*Variable used to suggest where articles are to be saved.
340 For instance, if you would like to save articles related to Gnus in
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
342 you could set this variable to something like:
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
347 This variable is an alist where the where the key is the match and the
348 value is a list of possible files to save in if the match is non-nil.
350 If the match is a string, it is used as a regexp match on the
351 article. If the match is a symbol, that symbol will be funcalled
352 from the buffer of the article to be saved with the newsgroup as the
353 parameter. If it is a list, it will be evaled in the same buffer.
355 If this form or function returns a string, this string will be used as
356 a possible file name; and if it returns a non-nil list, that list will
357 be used as possible file names.")
359 (defvar gnus-move-split-methods nil
360 "*Variable used to suggest where articles are to be moved to.
361 It uses the same syntax as the `gnus-split-methods' variable.")
363 (defvar gnus-save-score nil
364 "*If non-nil, save group scoring info.")
366 (defvar gnus-use-adaptive-scoring nil
367 "*If non-nil, use some adaptive scoring scheme.")
369 (defvar gnus-use-cache
'passive
370 "*If nil, Gnus will ignore the article cache.
371 If `passive', it will allow entering (and reading) articles
372 explicitly entered into the cache. If anything else, use the
373 cache to the full extent of the law.")
375 (defvar gnus-use-trees nil
376 "*If non-nil, display a thread tree buffer.")
378 (defvar gnus-use-grouplens nil
379 "*If non-nil, use GroupLens ratings.")
381 (defvar gnus-keep-backlog nil
382 "*If non-nil, Gnus will keep read articles for later re-retrieval.
383 If it is a number N, then Gnus will only keep the last N articles
384 read. If it is neither nil nor a number, Gnus will keep all read
385 articles. This is not a good idea.")
387 (defvar gnus-use-nocem nil
388 "*If non-nil, Gnus will read NoCeM cancel messages.")
390 (defvar gnus-use-demon nil
391 "If non-nil, Gnus might use some demons.")
393 (defvar gnus-use-scoring t
394 "*If non-nil, enable scoring.")
396 (defvar gnus-use-picons nil
397 "*If non-nil, display picons.")
399 (defvar gnus-fetch-old-headers nil
400 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
401 If an unread article in the group refers to an older, already read (or
402 just marked as read) article, the old article will not normally be
403 displayed in the Summary buffer. If this variable is non-nil, Gnus
404 will attempt to grab the headers to the old articles, and thereby
405 build complete threads. If it has the value `some', only enough
406 headers to connect otherwise loose threads will be displayed.
407 This variable can also be a number. In that case, no more than that
408 number of old headers will be fetched.
410 The server has to support NOV for any of this to work.")
413 ;(defvar gnus-visual t
414 ; "*If non-nil, will do various highlighting.
415 ;If nil, no mouse highlights (or any other highlights) will be
416 ;performed. This might speed up Gnus some when generating large group
417 ;and summary buffers.")
419 (defvar gnus-novice-user t
420 "*Non-nil means that you are a usenet novice.
421 If non-nil, verbose messages may be displayed and confirmations may be
424 (defvar gnus-expert-user nil
425 "*Non-nil means that you will never be asked for confirmation about anything.
426 And that means *anything*.")
428 (defvar gnus-verbose
7
429 "*Integer that says how verbose Gnus should be.
430 The higher the number, the more messages Gnus will flash to say what
431 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
432 display most important messages; and at ten, Gnus will keep on
433 jabbering all the time.")
435 (defvar gnus-keep-same-level nil
436 "*Non-nil means that the next newsgroup after the current will be on the same level.
437 When you type, for instance, `n' after reading the last article in the
438 current newsgroup, you will go to the next newsgroup. If this variable
439 is nil, the next newsgroup will be the next from the group
441 If this variable is non-nil, Gnus will either put you in the
442 next newsgroup with the same level, or, if no such newsgroup is
443 available, the next newsgroup with the lowest possible level higher
444 than the current level.
445 If this variable is `best', Gnus will make the next newsgroup the one
446 with the best level.")
448 (defvar gnus-summary-make-false-root
'adopt
449 "*nil means that Gnus won't gather loose threads.
450 If the root of a thread has expired or been read in a previous
451 session, the information necessary to build a complete thread has been
452 lost. Instead of having many small sub-threads from this original thread
453 scattered all over the summary buffer, Gnus can gather them.
455 If non-nil, Gnus will try to gather all loose sub-threads from an
456 original thread into one large thread.
458 If this variable is non-nil, it should be one of `none', `adopt',
461 If this variable is `none', Gnus will not make a false root, but just
462 present the sub-threads after another.
463 If this variable is `dummy', Gnus will create a dummy root that will
464 have all the sub-threads as children.
465 If this variable is `adopt', Gnus will make one of the \"children\"
466 the parent and mark all the step-children as such.
467 If this variable is `empty', the \"children\" are printed with empty
468 subject fields. (Or rather, they will be printed with a string
469 given by the `gnus-summary-same-subject' variable.)")
471 (defvar gnus-summary-gather-exclude-subject
"^ *$\\|^(none)$"
472 "*A regexp to match subjects to be excluded from loose thread gathering.
473 As loose thread gathering is done on subjects only, that means that
474 there can be many false gatherings performed. By rooting out certain
475 common subjects, gathering might become saner.")
477 (defvar gnus-summary-gather-subject-limit nil
478 "*Maximum length of subject comparisons when gathering loose threads.
479 Use nil to compare full subjects. Setting this variable to a low
480 number will help gather threads that have been corrupted by
481 newsreaders chopping off subject lines, but it might also mean that
482 unrelated articles that have subject that happen to begin with the
483 same few characters will be incorrectly gathered.
485 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
486 comparing subjects.")
488 (defvar gnus-simplify-ignored-prefixes nil
489 "*Regexp, matches for which are removed from subject lines when simplifying.")
491 (defvar gnus-build-sparse-threads nil
492 "*If non-nil, fill in the gaps in threads.
493 If `some', only fill in the gaps that are needed to tie loose threads
494 together. If `more', fill in all leaf nodes that Gnus can find. If
495 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
497 (defvar gnus-summary-thread-gathering-function
'gnus-gather-threads-by-subject
498 "Function used for gathering loose threads.
499 There are two pre-defined functions: `gnus-gather-threads-by-subject',
500 which only takes Subjects into consideration; and
501 `gnus-gather-threads-by-references', which compared the References
502 headers of the articles to find matches.")
504 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
505 (defvar gnus-summary-same-subject
""
506 "*String indicating that the current article has the same subject as the previous.
507 This variable will only be used if the value of
508 `gnus-summary-make-false-root' is `empty'.")
510 (defvar gnus-summary-goto-unread t
511 "*If non-nil, marking commands will go to the next unread article.
512 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
513 whether it is read or not.")
515 (defvar gnus-group-goto-unread t
516 "*If non-nil, movement commands will go to the next unread and subscribed group.")
518 (defvar gnus-goto-next-group-when-activating t
519 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
521 (defvar gnus-check-new-newsgroups t
522 "*Non-nil means that Gnus will add new newsgroups at startup.
523 If this variable is `ask-server', Gnus will ask the server for new
524 groups since the last time it checked. This means that the killed list
525 is no longer necessary, so you could set `gnus-save-killed-list' to
528 A variant is to have this variable be a list of select methods. Gnus
529 will then use the `ask-server' method on all these select methods to
530 query for new groups from all those servers.
533 (setq gnus-check-new-newsgroups
534 '((nntp \"some.server\") (nntp \"other.server\")))
536 If this variable is nil, then you have to tell Gnus explicitly to
537 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
539 (defvar gnus-check-bogus-newsgroups nil
540 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
541 If this variable is nil, then you have to tell Gnus explicitly to
542 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
544 (defvar gnus-read-active-file t
545 "*Non-nil means that Gnus will read the entire active file at startup.
546 If this variable is nil, Gnus will only know about the groups in your
549 If this variable is `some', Gnus will try to only read the relevant
550 parts of the active file from the server. Not all servers support
551 this, and it might be quite slow with other servers, but this should
552 generally be faster than both the t and nil value.
554 If you set this variable to nil or `some', you probably still want to
555 be told about new newsgroups that arrive. To do that, set
556 `gnus-check-new-newsgroups' to `ask-server'. This may not work
557 properly with all servers.")
559 (defvar gnus-level-subscribed
5
560 "*Groups with levels less than or equal to this variable are subscribed.")
562 (defvar gnus-level-unsubscribed
7
563 "*Groups with levels less than or equal to this variable are unsubscribed.
564 Groups with levels less than `gnus-level-subscribed', which should be
565 less than this variable, are subscribed.")
567 (defvar gnus-level-zombie
8
568 "*Groups with this level are zombie groups.")
570 (defvar gnus-level-killed
9
571 "*Groups with this level are killed.")
573 (defvar gnus-level-default-subscribed
3
574 "*New subscribed groups will be subscribed at this level.")
576 (defvar gnus-level-default-unsubscribed
6
577 "*New unsubscribed groups will be unsubscribed at this level.")
579 (defvar gnus-activate-level
(1+ gnus-level-subscribed
)
580 "*Groups higher than this level won't be activated on startup.
581 Setting this variable to something log might save lots of time when
582 you have many groups that you aren't interested in.")
584 (defvar gnus-activate-foreign-newsgroups
4
585 "*If nil, Gnus will not check foreign newsgroups at startup.
586 If it is non-nil, it should be a number between one and nine. Foreign
587 newsgroups that have a level lower or equal to this number will be
588 activated on startup. For instance, if you want to active all
589 subscribed newsgroups, but not the rest, you'd set this variable to
590 `gnus-level-subscribed'.
592 If you subscribe to lots of newsgroups from different servers, startup
593 might take a while. By setting this variable to nil, you'll save time,
594 but you won't be told how many unread articles there are in the
597 (defvar gnus-save-newsrc-file t
598 "*Non-nil means that Gnus will save the `.newsrc' file.
599 Gnus always saves its own startup file, which is called
600 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
601 be readily understood by other newsreaders. If you don't plan on
602 using other newsreaders, set this variable to nil to save some time on
605 (defvar gnus-save-killed-list t
606 "*If non-nil, save the list of killed groups to the startup file.
607 If you set this variable to nil, you'll save both time (when starting
608 and quitting) and space (both memory and disk), but it will also mean
609 that Gnus has no record of which groups are new and which are old, so
610 the automatic new newsgroups subscription methods become meaningless.
612 You should always set `gnus-check-new-newsgroups' to `ask-server' or
613 nil if you set this variable to nil.")
615 (defvar gnus-interactive-catchup t
616 "*If non-nil, require your confirmation when catching up a group.")
618 (defvar gnus-interactive-exit t
619 "*If non-nil, require your confirmation when exiting Gnus.")
621 (defvar gnus-kill-killed t
622 "*If non-nil, Gnus will apply kill files to already killed articles.
623 If it is nil, Gnus will never apply kill files to articles that have
624 already been through the scoring process, which might very well save lots
627 (defvar gnus-extract-address-components
'gnus-extract-address-components
628 "*Function for extracting address components from a From header.
629 Two pre-defined function exist: `gnus-extract-address-components',
630 which is the default, quite fast, and too simplistic solution, and
631 `mail-extract-address-components', which works much better, but is
634 (defvar gnus-summary-default-score
0
635 "*Default article score level.
636 If this variable is nil, scoring will be disabled.")
638 (defvar gnus-summary-zcore-fuzz
0
639 "*Fuzziness factor for the zcore in the summary buffer.
640 Articles with scores closer than this to `gnus-summary-default-score'
641 will not be marked.")
643 (defvar gnus-simplify-subject-fuzzy-regexp nil
644 "*Strings to be removed when doing fuzzy matches.
645 This can either be a regular expression or list of regular expressions
646 that will be removed from subject strings if fuzzy subject
647 simplification is selected.")
649 (defvar gnus-permanently-visible-groups nil
650 "*Regexp to match groups that should always be listed in the group buffer.
651 This means that they will still be listed when there are no unread
652 articles in the groups.")
654 (defvar gnus-list-groups-with-ticked-articles t
655 "*If non-nil, list groups that have only ticked articles.
656 If nil, only list groups that have unread articles.")
658 (defvar gnus-group-default-list-level gnus-level-subscribed
659 "*Default listing level.
660 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
662 (defvar gnus-group-use-permanent-levels nil
663 "*If non-nil, once you set a level, Gnus will use this level.")
665 (defvar gnus-group-list-inactive-groups t
666 "*If non-nil, inactive groups will be listed.")
668 (defvar gnus-show-mime nil
669 "*If non-nil, do mime processing of articles.
670 The articles will simply be fed to the function given by
671 `gnus-show-mime-method'.")
673 (defvar gnus-strict-mime t
674 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
676 (defvar gnus-show-mime-method
'metamail-buffer
677 "*Function to process a MIME message.
678 The function is called from the article buffer.")
680 (defvar gnus-decode-encoded-word-method
(lambda ())
681 "*Function to decode a MIME encoded-words.
682 The function is called from the article buffer.")
684 (defvar gnus-show-threads t
685 "*If non-nil, display threads in summary mode.")
687 (defvar gnus-thread-hide-subtree nil
688 "*If non-nil, hide all threads initially.
689 If threads are hidden, you have to run the command
690 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
691 to expose hidden threads.")
693 (defvar gnus-thread-hide-killed t
694 "*If non-nil, hide killed threads automatically.")
696 (defvar gnus-thread-ignore-subject nil
697 "*If non-nil, ignore subjects and do all threading based on the Reference header.
698 If nil, which is the default, articles that have different subjects
699 from their parents will start separate threads.")
701 (defvar gnus-thread-operation-ignore-subject t
702 "*If non-nil, subjects will be ignored when doing thread commands.
703 This affects commands like `gnus-summary-kill-thread' and
704 `gnus-summary-lower-thread'.
706 If this variable is nil, articles in the same thread with different
707 subjects will not be included in the operation in question. If this
708 variable is `fuzzy', only articles that have subjects that are fuzzily
709 equal will be included.")
711 (defvar gnus-thread-indent-level
4
712 "*Number that says how much each sub-thread should be indented.")
714 (defvar gnus-ignored-newsgroups
715 (purecopy (mapconcat 'identity
716 '("^to\\." ; not "real" groups
717 "^[0-9. \t]+ " ; all digits in name
718 "[][\"#'()]" ; bogus characters
721 "*A regexp to match uninteresting newsgroups in the active file.
722 Any lines in the active file matching this regular expression are
723 removed from the newsgroup list before anything else is done to it,
724 thus making them effectively non-existent.")
726 (defvar gnus-ignored-headers
727 "^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:"
728 "*All headers that match this regexp will be hidden.
729 This variable can also be a list of regexps of headers to be ignored.
730 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
732 (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-"
733 "*All headers that do not match this regexp will be hidden.
734 This variable can also be a list of regexp of headers to remain visible.
735 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
737 (defvar gnus-sorted-header-list
738 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
739 "^Cc:" "^Date:" "^Organization:")
740 "*This variable is a list of regular expressions.
741 If it is non-nil, headers that match the regular expressions will
742 be placed first in the article buffer in the sequence specified by
745 (defvar gnus-boring-article-headers
746 '(empty followup-to reply-to
)
747 "*Headers that are only to be displayed if they have interesting data.
748 Possible values in this list are `empty', `newsgroups', `followup-to',
749 `reply-to', and `date'.")
751 (defvar gnus-show-all-headers nil
752 "*If non-nil, don't hide any headers.")
754 (defvar gnus-save-all-headers t
755 "*If non-nil, don't remove any headers before saving.")
757 (defvar gnus-saved-headers gnus-visible-headers
758 "*Headers to keep if `gnus-save-all-headers' is nil.
759 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
760 If that variable is nil, however, all headers that match this regexp
761 will be kept while the rest will be deleted before saving.")
763 (defvar gnus-inhibit-startup-message nil
764 "*If non-nil, the startup message will not be displayed.")
766 (defvar gnus-signature-separator
"^-- *$"
767 "Regexp matching signature separator.")
769 (defvar gnus-signature-limit nil
770 "Provide a limit to what is considered a signature.
771 If it is a number, no signature may not be longer (in characters) than
772 that number. If it is a function, the function will be called without
773 any parameters, and if it returns nil, there is no signature in the
774 buffer. If it is a string, it will be used as a regexp. If it
775 matches, the text in question is not a signature.")
777 (defvar gnus-auto-extend-newsgroup t
778 "*If non-nil, extend newsgroup forward and backward when requested.")
780 (defvar gnus-auto-select-first t
781 "*If nil, don't select the first unread article when entering a group.
782 If this variable is `best', select the highest-scored unread article
783 in the group. If neither nil nor `best', select the first unread
786 If you want to prevent automatic selection of the first unread article
787 in some newsgroups, set the variable to nil in
788 `gnus-select-group-hook'.")
790 (defvar gnus-auto-select-next t
791 "*If non-nil, offer to go to the next group from the end of the previous.
792 If the value is t and the next newsgroup is empty, Gnus will exit
793 summary mode and go back to group mode. If the value is neither nil
794 nor t, Gnus will select the following unread newsgroup. In
795 particular, if the value is the symbol `quietly', the next unread
796 newsgroup will be selected without any confirmation, and if it is
797 `almost-quietly', the next group will be selected without any
798 confirmation if you are located on the last article in the group.
799 Finally, if this variable is `slightly-quietly', the `Z n' command
800 will go to the next group without confirmation.")
802 (defvar gnus-auto-select-same nil
803 "*If non-nil, select the next article with the same subject.")
805 (defvar gnus-summary-check-current nil
806 "*If non-nil, consider the current article when moving.
807 The \"unread\" movement commands will stay on the same line if the
808 current article is unread.")
810 (defvar gnus-auto-center-summary t
811 "*If non-nil, always center the current summary buffer.
812 In particular, if `vertical' do only vertical recentering. If non-nil
813 and non-`vertical', do both horizontal and vertical recentering.")
815 (defvar gnus-break-pages t
816 "*If non-nil, do page breaking on articles.
817 The page delimiter is specified by the `gnus-page-delimiter'
820 (defvar gnus-page-delimiter
"^\^L"
821 "*Regexp describing what to use as article page delimiters.
822 The default value is \"^\^L\", which is a form linefeed at the
823 beginning of a line.")
825 (defvar gnus-use-full-window t
826 "*If non-nil, use the entire Emacs screen.")
828 (defvar gnus-window-configuration nil
829 "Obsolete variable. See `gnus-buffer-configuration'.")
831 (defvar gnus-window-min-width
2
832 "*Minimum width of Gnus buffers.")
834 (defvar gnus-window-min-height
1
835 "*Minimum height of Gnus buffers.")
837 (defvar gnus-buffer-configuration
841 (if gnus-carpal
'(group-carpal 4))))
845 (if gnus-carpal
'(summary-carpal 4))))
852 (if gnus-carpal
'(summary-carpal 4))
854 (vertical ((height .
5) (width .
15)
856 (left . -
1) (top .
1))
866 (if gnus-carpal
'(summary-carpal 4))
867 (if gnus-use-trees
'(tree 0.25))
872 (if gnus-carpal
'(server-carpal 2))))
876 (if gnus-carpal
'(browse-carpal 2))))
879 (message 1.0 point
)))
882 (article 1.0 point
)))
893 (edit-group 1.0 point
)))
897 (edit-server 1.0 point
)))
901 (edit-score 1.0 point
)))
908 (message 1.0 point
)))
911 (message 1.0 point
)))
914 (message 1.0 point
)))
918 (message 1.0 point
)))
925 (if gnus-carpal
'(summary-carpal 4))
926 ("*Shell Command Output*" 1.0)))
929 ("*Gnus Help Bug*" 0.5)
930 ("*Gnus Bug*" 1.0 point
)))
934 (message 1.0 point
))))
935 "Window configuration for all possible Gnus buffers.
936 This variable is a list of lists. Each of these lists has a NAME and
937 a RULE. The NAMEs are commonsense names like `group', which names a
938 rule used when displaying the group buffer; `summary', which names a
939 rule for what happens when you enter a group and do not display an
940 article buffer; and so on. See the value of this variable for a
941 complete list of NAMEs.
943 Each RULE is a list of vectors. The first element in this vector is
944 the name of the buffer to be displayed; the second element is the
945 percentage of the screen this buffer is to occupy (a number in the
946 0.0-0.99 range); the optional third element is `point', which should
947 be present to denote which buffer point is to go to after making this
948 buffer configuration.")
950 (defvar gnus-window-to-buffer
951 '((group . gnus-group-buffer
)
952 (summary . gnus-summary-buffer
)
953 (article . gnus-article-buffer
)
954 (server . gnus-server-buffer
)
955 (browse .
"*Gnus Browse Server*")
956 (edit-group . gnus-group-edit-buffer
)
957 (edit-server . gnus-server-edit-buffer
)
958 (group-carpal . gnus-carpal-group-buffer
)
959 (summary-carpal . gnus-carpal-summary-buffer
)
960 (server-carpal . gnus-carpal-server-buffer
)
961 (browse-carpal . gnus-carpal-browse-buffer
)
962 (edit-score . gnus-score-edit-buffer
)
963 (message . gnus-message-buffer
)
964 (mail . gnus-message-buffer
)
965 (post-news . gnus-message-buffer
)
966 (faq . gnus-faq-buffer
)
967 (picons .
"*Picons*")
968 (tree . gnus-tree-buffer
)
969 (info . gnus-info-buffer
)
970 (article-copy . gnus-article-copy
)
971 (draft . gnus-draft-buffer
))
972 "Mapping from short symbols to buffer names or buffer variables.")
974 (defvar gnus-carpal nil
975 "*If non-nil, display clickable icons.")
977 (defvar gnus-subscribe-newsgroup-method
'gnus-subscribe-zombies
978 "*Function called with a group name when new group is detected.
979 A few pre-made functions are supplied: `gnus-subscribe-randomly'
980 inserts new groups at the beginning of the list of groups;
981 `gnus-subscribe-alphabetically' inserts new groups in strict
982 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
983 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
984 for your decision; `gnus-subscribe-killed' kills all new groups;
985 `gnus-subscribe-zombies' will make all new groups into zombies.")
987 ;; Suggested by a bug report by Hallvard B Furuseth.
988 ;; <h.b.furuseth@usit.uio.no>.
989 (defvar gnus-subscribe-options-newsgroup-method
990 (function gnus-subscribe-alphabetically
)
991 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
992 If, for instance, you want to subscribe to all newsgroups in the
993 \"no\" and \"alt\" hierarchies, you'd put the following in your
996 options -n no.all alt.all
998 Gnus will the subscribe all new newsgroups in these hierarchies with
999 the subscription method in this variable.")
1001 (defvar gnus-subscribe-hierarchical-interactive nil
1002 "*If non-nil, Gnus will offer to subscribe hierarchically.
1003 When a new hierarchy appears, Gnus will ask the user:
1005 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1007 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1008 subscribe to all newsgroups in the hierarchy and `s' will skip this
1009 hierarchy in its entirety.")
1011 (defvar gnus-group-sort-function
'gnus-group-sort-by-alphabet
1012 "*Function used for sorting the group buffer.
1013 This function will be called with group info entries as the arguments
1014 for the groups to be sorted. Pre-made functions include
1015 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1016 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1017 `gnus-group-sort-by-rank'.
1019 This variable can also be a list of sorting functions. In that case,
1020 the most significant sort function should be the last function in the
1023 ;; Mark variables suggested by Thomas Michanek
1024 ;; <Thomas.Michanek@telelogic.se>.
1025 (defvar gnus-unread-mark ?
1026 "*Mark used for unread articles.")
1027 (defvar gnus-ticked-mark ?
!
1028 "*Mark used for ticked articles.")
1029 (defvar gnus-dormant-mark ??
1030 "*Mark used for dormant articles.")
1031 (defvar gnus-del-mark ?r
1032 "*Mark used for del'd articles.")
1033 (defvar gnus-read-mark ?R
1034 "*Mark used for read articles.")
1035 (defvar gnus-expirable-mark ?E
1036 "*Mark used for expirable articles.")
1037 (defvar gnus-killed-mark ?K
1038 "*Mark used for killed articles.")
1039 (defvar gnus-souped-mark ?F
1040 "*Mark used for killed articles.")
1041 (defvar gnus-kill-file-mark ?X
1042 "*Mark used for articles killed by kill files.")
1043 (defvar gnus-low-score-mark ?Y
1044 "*Mark used for articles with a low score.")
1045 (defvar gnus-catchup-mark ?C
1046 "*Mark used for articles that are caught up.")
1047 (defvar gnus-replied-mark ?A
1048 "*Mark used for articles that have been replied to.")
1049 (defvar gnus-cached-mark ?
*
1050 "*Mark used for articles that are in the cache.")
1051 (defvar gnus-saved-mark ?S
1052 "*Mark used for articles that have been saved to.")
1053 (defvar gnus-process-mark ?
#
1055 (defvar gnus-ancient-mark ?O
1056 "*Mark used for ancient articles.")
1057 (defvar gnus-sparse-mark ?Q
1058 "*Mark used for sparsely reffed articles.")
1059 (defvar gnus-canceled-mark ?G
1060 "*Mark used for canceled articles.")
1061 (defvar gnus-score-over-mark ?
+
1062 "*Score mark used for articles with high scores.")
1063 (defvar gnus-score-below-mark ?-
1064 "*Score mark used for articles with low scores.")
1065 (defvar gnus-empty-thread-mark ?
1066 "*There is no thread under the article.")
1067 (defvar gnus-not-empty-thread-mark ?
=
1068 "*There is a thread under the article.")
1070 (defvar gnus-view-pseudo-asynchronously nil
1071 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1073 (defvar gnus-view-pseudos nil
1074 "*If `automatic', pseudo-articles will be viewed automatically.
1075 If `not-confirm', pseudos will be viewed automatically, and the user
1076 will not be asked to confirm the command.")
1078 (defvar gnus-view-pseudos-separately t
1079 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1080 If nil, all files that use the same viewing command will be given as a
1081 list of parameters to that command.")
1083 (defvar gnus-insert-pseudo-articles t
1084 "*If non-nil, insert pseudo-articles when decoding articles.")
1086 (defvar gnus-group-line-format
"%M%S%p%P%5y: %(%g%)%l\n"
1087 "*Format of group lines.
1088 It works along the same lines as a normal formatting string,
1089 with some simple extensions.
1091 %M Only marked articles (character, \"*\" or \" \")
1092 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1093 %L Level of subscribedness (integer)
1094 %N Number of unread articles (integer)
1095 %I Number of dormant articles (integer)
1096 %i Number of ticked and dormant (integer)
1097 %T Number of ticked articles (integer)
1098 %R Number of read articles (integer)
1099 %t Total number of articles (integer)
1100 %y Number of unread, unticked articles (integer)
1101 %G Group name (string)
1102 %g Qualified group name (string)
1103 %D Group description (string)
1104 %s Select method (string)
1105 %o Moderated group (char, \"m\")
1106 %p Process mark (char)
1107 %O Moderated group (string, \"(m)\" or \"\")
1108 %P Topic indentation (string)
1109 %l Whether there are GroupLens predictions for this group (string)
1110 %n Select from where (string)
1111 %z A string that look like `<%s:%n>' if a foreign select method is used
1112 %u User defined specifier. The next character in the format string should
1113 be a letter. Gnus will call the function gnus-user-format-function-X,
1114 where X is the letter following %u. The function will be passed the
1115 current header as argument. The function should return a string, which
1116 will be inserted into the buffer just like information from any other
1119 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1120 the mouse point move inside the area. There can only be one such area.
1122 Note that this format specification is not always respected. For
1123 reasons of efficiency, when listing killed groups, this specification
1124 is ignored altogether. If the spec is changed considerably, your
1125 output may end up looking strange when listing both alive and killed
1128 If you use %o or %O, reading the active file will be slower and quite
1129 a bit of extra memory will be used. %D will also worsen performance.
1130 Also note that if you change the format specification to include any
1131 of these specs, you must probably re-start Gnus to see them go into
1134 (defvar gnus-summary-line-format
"%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1135 "*The format specification of the lines in the summary buffer.
1137 It works along the same lines as a normal formatting string,
1138 with some simple extensions.
1140 %N Article number, left padded with spaces (string)
1142 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1143 %n Name of the poster (string)
1144 %a Extracted name of the poster (string)
1145 %A Extracted address of the poster (string)
1146 %F Contents of the From: header (string)
1147 %x Contents of the Xref: header (string)
1148 %D Date of the article (string)
1149 %d Date of the article (string) in DD-MMM format
1150 %M Message-id of the article (string)
1151 %r References of the article (string)
1152 %c Number of characters in the article (integer)
1153 %L Number of lines in the article (integer)
1154 %I Indentation based on thread level (a string of spaces)
1155 %T A string with two possible values: 80 spaces if the article
1156 is on thread level two or larger and 0 spaces on level one
1157 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1158 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1159 %[ Opening bracket (character, \"[\" or \"<\")
1160 %] Closing bracket (character, \"]\" or \">\")
1161 %> Spaces of length thread-level (string)
1162 %< Spaces of length (- 20 thread-level) (string)
1163 %i Article score (number)
1164 %z Article zcore (character)
1165 %t Number of articles under the current thread (number).
1166 %e Whether the thread is empty or not (character).
1167 %l GroupLens score (string).
1168 %u User defined specifier. The next character in the format string should
1169 be a letter. Gnus will call the function gnus-user-format-function-X,
1170 where X is the letter following %u. The function will be passed the
1171 current header as argument. The function should return a string, which
1172 will be inserted into the summary just like information from any other
1175 Text between %( and %) will be highlighted with `gnus-mouse-face'
1176 when the mouse point is placed inside the area. There can only be one
1179 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1180 with care. For reasons of efficiency, Gnus will compute what column
1181 these characters will end up in, and \"hard-code\" that. This means that
1182 it is illegal to have these specs after a variable-length spec. Well,
1183 you might not be arrested, but your summary buffer will look strange,
1184 which is bad enough.
1186 The smart choice is to have these specs as for to the left as
1189 This restriction may disappear in later versions of Gnus.")
1191 (defvar gnus-summary-dummy-line-format
1193 "*The format specification for the dummy roots in the summary buffer.
1194 It works along the same lines as a normal formatting string,
1195 with some simple extensions.
1199 (defvar gnus-summary-mode-line-format
"Gnus: %%b [%A] %Z"
1200 "*The format specification for the summary mode line.
1201 It works along the same lines as a normal formatting string,
1202 with some simple extensions:
1205 %p Unprefixed group name
1206 %A Current article number
1208 %U Number of unread articles in the group
1209 %e Number of unselected articles in the group
1210 %Z A string with unread/unselected article counts
1211 %g Shortish group name
1212 %S Subject of the current article
1213 %u User-defined spec
1214 %s Current score file name
1215 %d Number of dormant articles
1216 %r Number of articles that have been marked as read in this session
1217 %E Number of articles expunged by the score files")
1219 (defvar gnus-article-mode-line-format
"Gnus: %%b %S"
1220 "*The format specification for the article mode line.
1221 See `gnus-summary-mode-line-format' for a closer description.")
1223 (defvar gnus-group-mode-line-format
"Gnus: %%b {%M%:%S}"
1224 "*The format specification for the group mode line.
1225 It works along the same lines as a normal formatting string,
1226 with some simple extensions:
1228 %S The native news server.
1229 %M The native select method.
1230 %: \":\" if %S isn't \"\".")
1232 (defvar gnus-valid-select-methods
1233 '(("nntp" post address prompt-address
)
1234 ("nnspool" post address
)
1235 ("nnvirtual" post-mail virtual prompt-address
)
1236 ("nnmbox" mail respool address
)
1237 ("nnml" mail respool address
)
1238 ("nnmh" mail respool address
)
1239 ("nndir" post-mail prompt-address address
)
1240 ("nneething" none address prompt-address
)
1241 ("nndoc" none address prompt-address
)
1242 ("nnbabyl" mail address respool
)
1243 ("nnkiboze" post virtual
)
1244 ("nnsoup" post-mail address
)
1245 ("nndraft" post-mail
)
1246 ("nnfolder" mail respool address
))
1247 "An alist of valid select methods.
1248 The first element of each list lists should be a string with the name
1249 of the select method. The other elements may be be the category of
1250 this method (ie. `post', `mail', `none' or whatever) or other
1251 properties that this method has (like being respoolable).
1252 If you implement a new select method, all you should have to change is
1253 this variable. I think.")
1255 (defvar gnus-updated-mode-lines
'(group article summary tree
)
1256 "*List of buffers that should update their mode lines.
1257 The list may contain the symbols `group', `article' and `summary'. If
1258 the corresponding symbol is present, Gnus will keep that mode line
1259 updated with information that may be pertinent.
1260 If this variable is nil, screen refresh may be quicker.")
1262 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1263 (defvar gnus-mode-non-string-length nil
1264 "*Max length of mode-line non-string contents.
1265 If this is nil, Gnus will take space as is needed, leaving the rest
1266 of the modeline intact.")
1269 ;(defvar gnus-mouse-face 'highlight
1270 ; "*Face used for mouse highlighting in Gnus.
1271 ;No mouse highlights will be done if `gnus-visual' is nil.")
1273 (defvar gnus-summary-mark-below
0
1274 "*Mark all articles with a score below this variable as read.
1275 This variable is local to each summary buffer and usually set by the
1278 (defvar gnus-article-sort-functions
'(gnus-article-sort-by-number)
1279 "*List of functions used for sorting articles in the summary buffer.
1280 This variable is only used when not using a threaded display.")
1282 (defvar gnus-thread-sort-functions
'(gnus-thread-sort-by-number)
1283 "*List of functions used for sorting threads in the summary buffer.
1284 By default, threads are sorted by article number.
1286 Each function takes two threads and return non-nil if the first thread
1287 should be sorted before the other. If you use more than one function,
1288 the primary sort function should be the last. You should probably
1289 always include `gnus-thread-sort-by-number' in the list of sorting
1290 functions -- preferably first.
1292 Ready-mady functions include `gnus-thread-sort-by-number',
1293 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1294 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1295 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1297 (defvar gnus-thread-score-function
'+
1298 "*Function used for calculating the total score of a thread.
1300 The function is called with the scores of the article and each
1301 subthread and should then return the score of the thread.
1303 Some functions you can use are `+', `max', or `min'.")
1305 (defvar gnus-summary-expunge-below nil
1306 "All articles that have a score less than this variable will be expunged.")
1308 (defvar gnus-thread-expunge-below nil
1309 "All threads that have a total score less than this variable will be expunged.
1310 See `gnus-thread-score-function' for en explanation of what a
1311 \"thread score\" is.")
1313 (defvar gnus-auto-subscribed-groups
1314 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1315 "*All new groups that match this regexp will be subscribed automatically.
1316 Note that this variable only deals with new groups. It has no effect
1317 whatsoever on old groups.")
1319 (defvar gnus-options-subscribe nil
1320 "*All new groups matching this regexp will be subscribed unconditionally.
1321 Note that this variable deals only with new newsgroups. This variable
1322 does not affect old newsgroups.")
1324 (defvar gnus-options-not-subscribe nil
1325 "*All new groups matching this regexp will be ignored.
1326 Note that this variable deals only with new newsgroups. This variable
1327 does not affect old (already subscribed) newsgroups.")
1329 (defvar gnus-auto-expirable-newsgroups nil
1330 "*Groups in which to automatically mark read articles as expirable.
1331 If non-nil, this should be a regexp that should match all groups in
1332 which to perform auto-expiry. This only makes sense for mail groups.")
1334 (defvar gnus-total-expirable-newsgroups nil
1335 "*Groups in which to perform expiry of all read articles.
1336 Use with extreme caution. All groups that match this regexp will be
1337 expiring - which means that all read articles will be deleted after
1338 (say) one week. (This only goes for mail groups and the like, of
1341 (defvar gnus-group-uncollapsed-levels
1
1342 "Number of group name elements to leave alone when making a short group name.")
1344 (defvar gnus-hidden-properties
'(invisible t intangible t
)
1345 "Property list to use for hiding text.")
1347 (defvar gnus-modtime-botch nil
1348 "*Non-nil means .newsrc should be deleted prior to save.
1349 Its use is due to the bogus appearance that .newsrc was modified on
1354 (defvar gnus-group-mode-hook nil
1355 "*A hook for Gnus group mode.")
1357 (defvar gnus-summary-mode-hook nil
1358 "*A hook for Gnus summary mode.
1359 This hook is run before any variables are set in the summary buffer.")
1361 (defvar gnus-article-mode-hook nil
1362 "*A hook for Gnus article mode.")
1364 (defvar gnus-summary-prepare-exit-hook nil
1365 "*A hook called when preparing to exit from the summary buffer.
1366 It calls `gnus-summary-expire-articles' by default.")
1367 (add-hook 'gnus-summary-prepare-exit-hook
'gnus-summary-expire-articles
)
1369 (defvar gnus-summary-exit-hook nil
1370 "*A hook called on exit from the summary buffer.")
1372 (defvar gnus-group-catchup-group-hook nil
1373 "*A hook run when catching up a group from the group buffer.")
1375 (defvar gnus-group-update-group-hook nil
1376 "*A hook called when updating group lines.")
1378 (defvar gnus-open-server-hook nil
1379 "*A hook called just before opening connection to the news server.")
1381 (defvar gnus-load-hook nil
1382 "*A hook run while Gnus is loaded.")
1384 (defvar gnus-startup-hook nil
1385 "*A hook called at startup.
1386 This hook is called after Gnus is connected to the NNTP server.")
1388 (defvar gnus-get-new-news-hook nil
1389 "*A hook run just before Gnus checks for new news.")
1391 (defvar gnus-after-getting-new-news-hook nil
1392 "*A hook run after Gnus checks for new news.")
1394 (defvar gnus-group-prepare-function
'gnus-group-prepare-flat
1395 "*A function that is called to generate the group buffer.
1396 The function is called with three arguments: The first is a number;
1397 all group with a level less or equal to that number should be listed,
1398 if the second is non-nil, empty groups should also be displayed. If
1399 the third is non-nil, it is a number. No groups with a level lower
1400 than this number should be displayed.
1402 The only current function implemented is `gnus-group-prepare-flat'.")
1404 (defvar gnus-group-prepare-hook nil
1405 "*A hook called after the group buffer has been generated.
1406 If you want to modify the group buffer, you can use this hook.")
1408 (defvar gnus-summary-prepare-hook nil
1409 "*A hook called after the summary buffer has been generated.
1410 If you want to modify the summary buffer, you can use this hook.")
1412 (defvar gnus-summary-generate-hook nil
1413 "*A hook run just before generating the summary buffer.
1414 This hook is commonly used to customize threading variables and the
1417 (defvar gnus-article-prepare-hook nil
1418 "*A hook called after an article has been prepared in the article buffer.
1419 If you want to run a special decoding program like nkf, use this hook.")
1421 ;(defvar gnus-article-display-hook nil
1422 ; "*A hook called after the article is displayed in the article buffer.
1423 ;The hook is designed to change the contents of the article
1424 ;buffer. Typical functions that this hook may contain are
1425 ;`gnus-article-hide-headers' (hide selected headers),
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1427 ;`gnus-article-hide-signature' (hide signature) and
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1433 (defvar gnus-article-x-face-too-ugly nil
1434 "Regexp matching posters whose face shouldn't be shown automatically.")
1436 (defvar gnus-select-group-hook nil
1437 "*A hook called when a newsgroup is selected.
1439 If you'd like to simplify subjects like the
1440 `gnus-summary-next-same-subject' command does, you can use the
1443 (setq gnus-select-group-hook
1446 (mapcar (lambda (header)
1447 (mail-header-set-subject
1449 (gnus-simplify-subject
1450 (mail-header-subject header) 're-only)))
1451 gnus-newsgroup-headers))))")
1453 (defvar gnus-select-article-hook nil
1454 "*A hook called when an article is selected.")
1456 (defvar gnus-apply-kill-hook
'(gnus-apply-kill-file)
1457 "*A hook called to apply kill files to a group.
1458 This hook is intended to apply a kill file to the selected newsgroup.
1459 The function `gnus-apply-kill-file' is called by default.
1461 Since a general kill file is too heavy to use only for a few
1462 newsgroups, I recommend you to use a lighter hook function. For
1463 example, if you'd like to apply a kill file to articles which contains
1464 a string `rmgroup' in subject in newsgroup `control', you can use the
1467 (setq gnus-apply-kill-hook
1470 (cond ((string-match \"control\" gnus-newsgroup-name)
1471 (gnus-kill \"Subject\" \"rmgroup\")
1472 (gnus-expunge \"X\"))))))")
1474 (defvar gnus-visual-mark-article-hook
1475 (list 'gnus-highlight-selected-summary
)
1476 "*Hook run after selecting an article in the summary buffer.
1477 It is meant to be used for highlighting the article in some way. It
1478 is not run if `gnus-visual' is nil.")
1480 (defvar gnus-parse-headers-hook nil
1481 "*A hook called before parsing the headers.")
1482 (add-hook 'gnus-parse-headers-hook
'gnus-decode-rfc1522
)
1484 (defvar gnus-exit-group-hook nil
1485 "*A hook called when exiting (not quitting) summary mode.")
1487 (defvar gnus-suspend-gnus-hook nil
1488 "*A hook called when suspending (not exiting) Gnus.")
1490 (defvar gnus-exit-gnus-hook nil
1491 "*A hook called when exiting Gnus.")
1493 (defvar gnus-after-exiting-gnus-hook nil
1494 "*A hook called after exiting Gnus.")
1496 (defvar gnus-save-newsrc-hook nil
1497 "*A hook called before saving any of the newsrc files.")
1499 (defvar gnus-save-quick-newsrc-hook nil
1500 "*A hook called just before saving the quick newsrc file.
1501 Can be used to turn version control on or off.")
1503 (defvar gnus-save-standard-newsrc-hook nil
1504 "*A hook called just before saving the standard newsrc file.
1505 Can be used to turn version control on or off.")
1507 (defvar gnus-summary-update-hook
1508 (list 'gnus-summary-highlight-line
)
1509 "*A hook called when a summary line is changed.
1510 The hook will not be called if `gnus-visual' is nil.
1512 The default function `gnus-summary-highlight-line' will
1513 highlight the line according to the `gnus-summary-highlight'
1516 (defvar gnus-group-update-hook
'(gnus-group-highlight-line)
1517 "*A hook called when a group line is changed.
1518 The hook will not be called if `gnus-visual' is nil.
1520 The default function `gnus-group-highlight-line' will
1521 highlight the line according to the `gnus-group-highlight'
1524 (defvar gnus-mark-article-hook
'(gnus-summary-mark-read-and-unread-as-read)
1525 "*A hook called when an article is selected for the first time.
1526 The hook is intended to mark an article as read (or unread)
1527 automatically when it is selected.")
1529 (defvar gnus-group-change-level-function nil
1530 "Function run when a group level is changed.
1531 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1533 ;; Remove any hilit infestation.
1534 (add-hook 'gnus-startup-hook
1536 (remove-hook 'gnus-summary-prepare-hook
1537 'hilit-rehighlight-buffer-quietly
)
1538 (remove-hook 'gnus-summary-prepare-hook
'hilit-install-line-hooks
)
1539 (setq gnus-mark-article-hook
1540 '(gnus-summary-mark-read-and-unread-as-read))
1541 (remove-hook 'gnus-article-prepare-hook
1542 'hilit-rehighlight-buffer-quietly
)))
1545 ;; Internal variables
1547 (defvar gnus-tree-buffer
"*Tree*"
1548 "Buffer where Gnus thread trees are displayed.")
1551 (defvar gnus-use-generic-from nil
)
1553 (defvar gnus-thread-indent-array nil
)
1554 (defvar gnus-thread-indent-array-level gnus-thread-indent-level
)
1556 (defvar gnus-newsrc-file-version nil
)
1558 (defvar gnus-method-history nil
)
1559 ;; Variable holding the user answers to all method prompts.
1561 (defvar gnus-group-history nil
)
1562 ;; Variable holding the user answers to all group prompts.
1564 (defvar gnus-server-alist nil
1565 "List of available servers.")
1567 (defvar gnus-group-indentation-function nil
)
1569 (defvar gnus-topic-indentation
"") ;; Obsolete variable.
1571 (defvar gnus-goto-missing-group-function nil
)
1573 (defvar gnus-override-subscribe-method nil
)
1575 (defvar gnus-group-goto-next-group-function nil
1576 "Function to override finding the next group after listing groups.")
1578 (defconst gnus-article-mark-lists
1579 '((marked . tick
) (replied . reply
)
1580 (expirable . expire
) (killed . killed
)
1581 (bookmarks . bookmark
) (dormant . dormant
)
1582 (scored . score
) (saved . save
)
1586 ;; Avoid highlighting in kill files.
1587 (defvar gnus-summary-inhibit-highlight nil
)
1588 (defvar gnus-newsgroup-selected-overlay nil
)
1590 (defvar gnus-inhibit-hiding nil
)
1591 (defvar gnus-group-indentation
"")
1592 (defvar gnus-inhibit-limiting nil
)
1593 (defvar gnus-created-frames nil
)
1595 (defvar gnus-article-mode-map nil
)
1596 (defvar gnus-dribble-buffer nil
)
1597 (defvar gnus-headers-retrieved-by nil
)
1598 (defvar gnus-article-reply nil
)
1599 (defvar gnus-override-method nil
)
1600 (defvar gnus-article-check-size nil
)
1602 (defvar gnus-current-score-file nil
)
1603 (defvar gnus-newsgroup-adaptive-score-file nil
)
1604 (defvar gnus-scores-exclude-files nil
)
1606 (defvar gnus-opened-servers nil
)
1608 (defvar gnus-current-move-group nil
)
1609 (defvar gnus-current-copy-group nil
)
1610 (defvar gnus-current-crosspost-group nil
)
1612 (defvar gnus-newsgroup-dependencies nil
)
1613 (defvar gnus-newsgroup-async nil
)
1614 (defconst gnus-group-edit-buffer
"*Gnus edit newsgroup*")
1616 (defvar gnus-newsgroup-adaptive nil
)
1618 (defvar gnus-summary-display-table nil
)
1619 (defvar gnus-summary-display-article-function nil
)
1621 (defvar gnus-summary-highlight-line-function nil
1622 "Function called after highlighting a summary line.")
1624 (defvar gnus-group-line-format-alist
1625 `((?M gnus-tmp-marked-mark ?c
)
1626 (?S gnus-tmp-subscribed ?c
)
1627 (?L gnus-tmp-level ?d
)
1628 (?N
(cond ((eq number t
) "*" )
1632 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))))))
1635 (?R gnus-tmp-number-of-read ?s
)
1636 (?t gnus-tmp-number-total ?d
)
1637 (?y gnus-tmp-number-of-unread ?s
)
1638 (?I
(gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
))) ?d
)
1639 (?T
(gnus-range-length (cdr (assq 'tick gnus-tmp-marked
))) ?d
)
1640 (?i
(+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked
)))
1641 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked
)))) ?d
)
1642 (?g gnus-tmp-group ?s
)
1643 (?G gnus-tmp-qualified-group ?s
)
1644 (?c
(gnus-short-group-name gnus-tmp-group
) ?s
)
1645 (?D gnus-tmp-newsgroup-description ?s
)
1646 (?o gnus-tmp-moderated ?c
)
1647 (?O gnus-tmp-moderated-string ?s
)
1648 (?p gnus-tmp-process-marked ?c
)
1649 (?s gnus-tmp-news-server ?s
)
1650 (?n gnus-tmp-news-method ?s
)
1651 (?P gnus-group-indentation ?s
)
1652 (?l gnus-tmp-grouplens ?s
)
1653 (?z gnus-tmp-news-method-string ?s
)
1654 (?u gnus-tmp-user-defined ?s
)))
1656 (defvar gnus-summary-line-format-alist
1657 `((?N
,(macroexpand '(mail-header-number gnus-tmp-header
)) ?d
)
1658 (?S
,(macroexpand '(mail-header-subject gnus-tmp-header
)) ?s
)
1659 (?s gnus-tmp-subject-or-nil ?s
)
1660 (?n gnus-tmp-name ?s
)
1661 (?A
(car (cdr (funcall gnus-extract-address-components gnus-tmp-from
)))
1663 (?a
(or (car (funcall gnus-extract-address-components gnus-tmp-from
))
1665 (?F gnus-tmp-from ?s
)
1666 (?x
,(macroexpand '(mail-header-xref gnus-tmp-header
)) ?s
)
1667 (?D
,(macroexpand '(mail-header-date gnus-tmp-header
)) ?s
)
1668 (?d
(gnus-dd-mmm (mail-header-date gnus-tmp-header
)) ?s
)
1669 (?M
,(macroexpand '(mail-header-id gnus-tmp-header
)) ?s
)
1670 (?r
,(macroexpand '(mail-header-references gnus-tmp-header
)) ?s
)
1671 (?c
(or (mail-header-chars gnus-tmp-header
) 0) ?d
)
1672 (?L gnus-tmp-lines ?d
)
1673 (?I gnus-tmp-indentation ?s
)
1674 (?T
(if (= gnus-tmp-level
0) "" (make-string (frame-width) ?
)) ?s
)
1675 (?R gnus-tmp-replied ?c
)
1676 (?\
[ gnus-tmp-opening-bracket ?c
)
1677 (?\
] gnus-tmp-closing-bracket ?c
)
1678 (?\
> (make-string gnus-tmp-level ?
) ?s
)
1679 (?\
< (make-string (max 0 (- 20 gnus-tmp-level
)) ?
) ?s
)
1680 (?i gnus-tmp-score ?d
)
1681 (?z gnus-tmp-score-char ?c
)
1682 (?l
(bbb-grouplens-score gnus-tmp-header
) ?s
)
1683 (?V
(gnus-thread-total-score (and (boundp 'thread
) (car thread
))) ?d
)
1684 (?U gnus-tmp-unread ?c
)
1685 (?t
(gnus-summary-number-of-articles-in-thread
1686 (and (boundp 'thread
) (car thread
)) gnus-tmp-level
)
1688 (?e
(gnus-summary-number-of-articles-in-thread
1689 (and (boundp 'thread
) (car thread
)) gnus-tmp-level t
)
1691 (?u gnus-tmp-user-defined ?s
))
1692 "An alist of format specifications that can appear in summary lines,
1693 and what variables they correspond with, along with the type of the
1694 variable (string, integer, character, etc).")
1696 (defvar gnus-summary-dummy-line-format-alist
1697 `((?S gnus-tmp-subject ?s
)
1698 (?N gnus-tmp-number ?d
)
1699 (?u gnus-tmp-user-defined ?s
)))
1701 (defvar gnus-summary-mode-line-format-alist
1702 `((?G gnus-tmp-group-name ?s
)
1703 (?g
(gnus-short-group-name gnus-tmp-group-name
) ?s
)
1704 (?p
(gnus-group-real-name gnus-tmp-group-name
) ?s
)
1705 (?A gnus-tmp-article-number ?d
)
1706 (?Z gnus-tmp-unread-and-unselected ?s
)
1707 (?V gnus-version ?s
)
1708 (?U gnus-tmp-unread-and-unticked ?d
)
1709 (?S gnus-tmp-subject ?s
)
1710 (?e gnus-tmp-unselected ?d
)
1711 (?u gnus-tmp-user-defined ?s
)
1712 (?d
(length gnus-newsgroup-dormant
) ?d
)
1713 (?t
(length gnus-newsgroup-marked
) ?d
)
1714 (?r
(length gnus-newsgroup-reads
) ?d
)
1715 (?E gnus-newsgroup-expunged-tally ?d
)
1716 (?s
(gnus-current-score-file-nondirectory) ?s
)))
1718 (defvar gnus-article-mode-line-format-alist
1719 gnus-summary-mode-line-format-alist
)
1721 (defvar gnus-group-mode-line-format-alist
1722 `((?S gnus-tmp-news-server ?s
)
1723 (?M gnus-tmp-news-method ?s
)
1724 (?u gnus-tmp-user-defined ?s
)
1725 (?
: gnus-tmp-colon ?s
)))
1727 (defvar gnus-have-read-active-file nil
)
1729 (defconst gnus-maintainer
1730 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1731 "The mail address of the Gnus maintainers.")
1733 (defconst gnus-version-number
"5.3"
1734 "Version number for this version of Gnus.")
1736 (defconst gnus-version
(format "Gnus v%s" gnus-version-number
)
1737 "Version string for this version of Gnus.")
1739 (defvar gnus-info-nodes
1740 '((gnus-group-mode "(gnus)The Group Buffer")
1741 (gnus-summary-mode "(gnus)The Summary Buffer")
1742 (gnus-article-mode "(gnus)The Article Buffer")
1743 (gnus-server-mode "(gnus)The Server Buffer")
1744 (gnus-browse-mode "(gnus)Browse Foreign Server")
1745 (gnus-tree-mode "(gnus)Tree Display")
1747 "Alist of major modes and related Info nodes.")
1749 (defvar gnus-group-buffer
"*Group*")
1750 (defvar gnus-summary-buffer
"*Summary*")
1751 (defvar gnus-article-buffer
"*Article*")
1752 (defvar gnus-server-buffer
"*Server*")
1754 (defvar gnus-work-buffer
" *gnus work*")
1756 (defvar gnus-original-article-buffer
" *Original Article*")
1757 (defvar gnus-original-article nil
)
1759 (defvar gnus-buffer-list nil
1760 "Gnus buffers that should be killed on exit.")
1762 (defvar gnus-slave nil
1763 "Whether this Gnus is a slave or not.")
1765 (defvar gnus-variable-list
1766 '(gnus-newsrc-options gnus-newsrc-options-n
1767 gnus-newsrc-last-checked-date
1768 gnus-newsrc-alist gnus-server-alist
1769 gnus-killed-list gnus-zombie-list
1770 gnus-topic-topology gnus-topic-alist
1772 "Gnus variables saved in the quick startup file.")
1774 (defvar gnus-newsrc-options nil
1775 "Options line in the .newsrc file.")
1777 (defvar gnus-newsrc-options-n nil
1778 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1780 (defvar gnus-newsrc-last-checked-date nil
1781 "Date Gnus last asked server for new newsgroups.")
1783 (defvar gnus-topic-topology nil
1784 "The complete topic hierarchy.")
1786 (defvar gnus-topic-alist nil
1787 "The complete topic-group alist.")
1789 (defvar gnus-newsrc-alist nil
1790 "Assoc list of read articles.
1791 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1793 (defvar gnus-newsrc-hashtb nil
1794 "Hashtable of gnus-newsrc-alist.")
1796 (defvar gnus-killed-list nil
1797 "List of killed newsgroups.")
1799 (defvar gnus-killed-hashtb nil
1800 "Hash table equivalent of gnus-killed-list.")
1802 (defvar gnus-zombie-list nil
1803 "List of almost dead newsgroups.")
1805 (defvar gnus-description-hashtb nil
1806 "Descriptions of newsgroups.")
1808 (defvar gnus-list-of-killed-groups nil
1809 "List of newsgroups that have recently been killed by the user.")
1811 (defvar gnus-active-hashtb nil
1812 "Hashtable of active articles.")
1814 (defvar gnus-moderated-list nil
1815 "List of moderated newsgroups.")
1817 (defvar gnus-group-marked nil
)
1819 (defvar gnus-current-startup-file nil
1820 "Startup file for the current host.")
1822 (defvar gnus-last-search-regexp nil
1823 "Default regexp for article search command.")
1825 (defvar gnus-last-shell-command nil
1826 "Default shell command on article.")
1828 (defvar gnus-current-select-method nil
1829 "The current method for selecting a newsgroup.")
1831 (defvar gnus-group-list-mode nil
)
1833 (defvar gnus-article-internal-prepare-hook nil
)
1835 (defvar gnus-newsgroup-name nil
)
1836 (defvar gnus-newsgroup-begin nil
)
1837 (defvar gnus-newsgroup-end nil
)
1838 (defvar gnus-newsgroup-last-rmail nil
)
1839 (defvar gnus-newsgroup-last-mail nil
)
1840 (defvar gnus-newsgroup-last-folder nil
)
1841 (defvar gnus-newsgroup-last-file nil
)
1842 (defvar gnus-newsgroup-auto-expire nil
)
1843 (defvar gnus-newsgroup-active nil
)
1845 (defvar gnus-newsgroup-data nil
)
1846 (defvar gnus-newsgroup-data-reverse nil
)
1847 (defvar gnus-newsgroup-limit nil
)
1848 (defvar gnus-newsgroup-limits nil
)
1850 (defvar gnus-newsgroup-unreads nil
1851 "List of unread articles in the current newsgroup.")
1853 (defvar gnus-newsgroup-unselected nil
1854 "List of unselected unread articles in the current newsgroup.")
1856 (defvar gnus-newsgroup-reads nil
1857 "Alist of read articles and article marks in the current newsgroup.")
1859 (defvar gnus-newsgroup-expunged-tally nil
)
1861 (defvar gnus-newsgroup-marked nil
1862 "List of ticked articles in the current newsgroup (a subset of unread art).")
1864 (defvar gnus-newsgroup-killed nil
1865 "List of ranges of articles that have been through the scoring process.")
1867 (defvar gnus-newsgroup-cached nil
1868 "List of articles that come from the article cache.")
1870 (defvar gnus-newsgroup-saved nil
1871 "List of articles that have been saved.")
1873 (defvar gnus-newsgroup-kill-headers nil
)
1875 (defvar gnus-newsgroup-replied nil
1876 "List of articles that have been replied to in the current newsgroup.")
1878 (defvar gnus-newsgroup-expirable nil
1879 "List of articles in the current newsgroup that can be expired.")
1881 (defvar gnus-newsgroup-processable nil
1882 "List of articles in the current newsgroup that can be processed.")
1884 (defvar gnus-newsgroup-bookmarks nil
1885 "List of articles in the current newsgroup that have bookmarks.")
1887 (defvar gnus-newsgroup-dormant nil
1888 "List of dormant articles in the current newsgroup.")
1890 (defvar gnus-newsgroup-scored nil
1891 "List of scored articles in the current newsgroup.")
1893 (defvar gnus-newsgroup-headers nil
1894 "List of article headers in the current newsgroup.")
1896 (defvar gnus-newsgroup-threads nil
)
1898 (defvar gnus-newsgroup-prepared nil
1899 "Whether the current group has been prepared properly.")
1901 (defvar gnus-newsgroup-ancient nil
1902 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1904 (defvar gnus-newsgroup-sparse nil
)
1906 (defvar gnus-current-article nil
)
1907 (defvar gnus-article-current nil
)
1908 (defvar gnus-current-headers nil
)
1909 (defvar gnus-have-all-headers nil
)
1910 (defvar gnus-last-article nil
)
1911 (defvar gnus-newsgroup-history nil
)
1912 (defvar gnus-current-kill-article nil
)
1914 ;; Save window configuration.
1915 (defvar gnus-prev-winconf nil
)
1917 (defvar gnus-summary-mark-positions nil
)
1918 (defvar gnus-group-mark-positions nil
)
1920 (defvar gnus-reffed-article-number nil
)
1922 ;;; Let the byte-compiler know that we know about this variable.
1923 (defvar rmail-default-rmail-file
)
1925 (defvar gnus-cache-removable-articles nil
)
1927 (defvar gnus-dead-summary nil
)
1929 (defconst gnus-summary-local-variables
1930 '(gnus-newsgroup-name
1931 gnus-newsgroup-begin gnus-newsgroup-end
1932 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1933 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1934 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1935 gnus-newsgroup-unselected gnus-newsgroup-marked
1936 gnus-newsgroup-reads gnus-newsgroup-saved
1937 gnus-newsgroup-replied gnus-newsgroup-expirable
1938 gnus-newsgroup-processable gnus-newsgroup-killed
1939 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1940 gnus-newsgroup-headers gnus-newsgroup-threads
1941 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1942 gnus-current-article gnus-current-headers gnus-have-all-headers
1943 gnus-last-article gnus-article-internal-prepare-hook
1944 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1945 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1946 gnus-newsgroup-async gnus-thread-expunge-below
1947 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1948 (gnus-summary-mark-below . global
)
1949 gnus-newsgroup-active gnus-scores-exclude-files
1950 gnus-newsgroup-history gnus-newsgroup-ancient
1951 gnus-newsgroup-sparse
1952 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring
)
1953 gnus-newsgroup-adaptive-score-file
1954 (gnus-newsgroup-expunged-tally .
0)
1955 gnus-cache-removable-articles gnus-newsgroup-cached
1956 gnus-newsgroup-data gnus-newsgroup-data-reverse
1957 gnus-newsgroup-limit gnus-newsgroup-limits
)
1958 "Variables that are buffer-local to the summary buffers.")
1960 (defconst gnus-bug-message
1961 "Sending a bug report to the Gnus Towers.
1962 ========================================
1964 The buffer below is a mail buffer. When you press `C-c C-c', it will
1965 be sent to the Gnus Bug Exterminators.
1967 At the bottom of the buffer you'll see lots of variable settings.
1968 Please do not delete those. They will tell the Bug People what your
1969 environment is, so that it will be easier to locate the bugs.
1971 If you have found a bug that makes Emacs go \"beep\", set
1972 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1973 and include the backtrace in your bug report.
1975 Please describe the bug in annoying, painstaking detail.
1977 Thank you for your help in stamping out bugs.
1980 ;;; End of variables.
1982 ;; Define some autoload functions Gnus might use.
1985 ;; This little mapcar goes through the list below and marks the
1986 ;; symbols in question as autoloaded functions.
1989 (let ((interactive (nth 1 (memq ':interactive package
))))
1993 (when (consp function
)
1994 (setq keymap
(car (memq 'keymap function
)))
1995 (setq function
(car function
)))
1996 (autoload function
(car package
) nil interactive keymap
)))
1997 (if (eq (nth 1 package
) ':interactive
)
2000 '(("metamail" metamail-buffer
)
2001 ("info" Info-goto-node
)
2002 ("hexl" hexl-hex-string-to-integer
)
2003 ("pp" pp pp-to-string pp-eval-expression
)
2004 ("mail-extr" mail-extract-address-components
)
2005 ("nnmail" nnmail-split-fancy nnmail-article-group
)
2006 ("nnvirtual" nnvirtual-catchup-group
)
2007 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2008 timezone-make-sortable-date timezone-make-time-string
)
2009 ("rmailout" rmail-output
)
2010 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2012 ("gnus-soup" :interactive t
2013 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2014 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet
)
2015 ("nnsoup" nnsoup-pack-replies
)
2016 ("gnus-scomo" :interactive t gnus-score-mode
)
2017 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2018 gnus-Folder-save-name gnus-folder-save-name
)
2019 ("gnus-mh" :interactive t gnus-summary-save-in-folder
)
2020 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2021 gnus-server-make-menu-bar gnus-article-make-menu-bar
2022 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2023 gnus-summary-highlight-line gnus-carpal-setup-buffer
2024 gnus-group-highlight-line
2025 gnus-article-add-button gnus-insert-next-page-button
2026 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu
)
2027 ("gnus-vis" :interactive t
2028 gnus-article-push-button gnus-article-press-button
2029 gnus-article-highlight gnus-article-highlight-some
2030 gnus-article-highlight-headers gnus-article-highlight-signature
2031 gnus-article-add-buttons gnus-article-add-buttons-to-head
2032 gnus-article-next-button gnus-article-prev-button
)
2033 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2034 gnus-demon-add-disconnection gnus-demon-add-handler
2035 gnus-demon-remove-handler
)
2036 ("gnus-demon" :interactive t
2037 gnus-demon-init gnus-demon-cancel
)
2038 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2039 gnus-tree-open gnus-tree-close
)
2040 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2041 gnus-nocem-unwanted-article-p
)
2042 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info
)
2043 ("gnus-srvr" gnus-browse-foreign-server
)
2044 ("gnus-cite" :interactive t
2045 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2046 gnus-article-hide-citation gnus-article-fill-cited-article
2047 gnus-article-hide-citation-in-followups
)
2048 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2049 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2050 gnus-execute gnus-expunge
)
2051 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2052 gnus-cache-possibly-remove-articles gnus-cache-request-article
2053 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2054 gnus-cache-enter-remove-article gnus-cached-article-p
2055 gnus-cache-open gnus-cache-close gnus-cache-update-article
)
2056 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2057 gnus-cache-remove-article
)
2058 ("gnus-score" :interactive t
2059 gnus-summary-increase-score gnus-summary-lower-score
2060 gnus-score-flush-cache gnus-score-close
2061 gnus-score-raise-same-subject-and-select
2062 gnus-score-raise-same-subject gnus-score-default
2063 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2064 gnus-score-lower-same-subject gnus-score-lower-thread
2065 gnus-possibly-score-headers gnus-summary-raise-score
2066 gnus-summary-set-score gnus-summary-current-score
)
2068 (gnus-summary-score-map keymap
) gnus-score-save gnus-score-headers
2069 gnus-current-score-file-nondirectory gnus-score-adaptive
2070 gnus-score-find-trace gnus-score-file-name
)
2071 ("gnus-edit" :interactive t gnus-score-customize
)
2072 ("gnus-topic" :interactive t gnus-topic-mode
)
2073 ("gnus-topic" gnus-topic-remove-group
)
2074 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode
)
2075 ("gnus-uu" (gnus-uu-extract-map keymap
) (gnus-uu-mark-map keymap
))
2076 ("gnus-uu" :interactive t
2077 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2078 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2079 gnus-uu-mark-by-regexp gnus-uu-mark-all
2080 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2081 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2082 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2083 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2084 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2085 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2086 gnus-uu-decode-binhex-view
)
2087 ("gnus-msg" (gnus-summary-send-map keymap
)
2088 gnus-mail-yank-original gnus-mail-send-and-exit
2089 gnus-article-mail gnus-new-mail gnus-mail-reply
)
2090 ("gnus-msg" :interactive t
2091 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2092 gnus-summary-followup gnus-summary-followup-with-original
2093 gnus-summary-cancel-article gnus-summary-supersede-article
2094 gnus-post-news gnus-inews-news
2095 gnus-summary-reply gnus-summary-reply-with-original
2096 gnus-summary-mail-forward gnus-summary-mail-other-window
2098 ("gnus-picon" :interactive t gnus-article-display-picons
2099 gnus-group-display-picons gnus-picons-article-display-x-face
)
2100 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2101 gnus-grouplens-mode
)
2102 ("smiley" :interactive t gnus-smiley-display
)
2103 ("gnus-vm" gnus-vm-mail-setup
)
2104 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2105 gnus-summary-save-article-vm
))))
2109 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2110 ;; If you want the cursor to go somewhere else, set these two
2111 ;; functions in some startup hook to whatever you want.
2112 (defalias 'gnus-summary-position-point
'gnus-goto-colon
)
2113 (defalias 'gnus-group-position-point
'gnus-goto-colon
)
2115 ;;; Various macros and substs.
2117 (defun gnus-header-from (header)
2118 (mail-header-from header
))
2120 (defmacro gnus-eval-in-buffer-window
(buffer &rest forms
)
2121 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2122 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2123 (w (make-symbol "w"))
2124 (buf (make-symbol "buf")))
2125 `(let* ((,tempvar
(selected-window))
2127 (,w
(get-buffer-window ,buf
'visible
)))
2132 (pop-to-buffer ,buf
))
2134 (select-window ,tempvar
)))))
2136 (put 'gnus-eval-in-buffer-window
'lisp-indent-function
1)
2137 (put 'gnus-eval-in-buffer-window
'lisp-indent-hook
1)
2138 (put 'gnus-eval-in-buffer-window
'edebug-form-spec
'(form body
))
2140 (defmacro gnus-gethash
(string hashtable
)
2141 "Get hash value of STRING in HASHTABLE."
2142 `(symbol-value (intern-soft ,string
,hashtable
)))
2144 (defmacro gnus-sethash
(string value hashtable
)
2145 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2146 `(set (intern ,string
,hashtable
) ,value
))
2148 (defmacro gnus-intern-safe
(string hashtable
)
2149 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2150 `(let ((symbol (intern ,string
,hashtable
)))
2155 (defmacro gnus-group-unread
(group)
2156 "Get the currently computed number of unread articles in GROUP."
2157 `(car (gnus-gethash ,group gnus-newsrc-hashtb
)))
2159 (defmacro gnus-group-entry
(group)
2160 "Get the newsrc entry for GROUP."
2161 `(gnus-gethash ,group gnus-newsrc-hashtb
))
2163 (defmacro gnus-active
(group)
2164 "Get active info on GROUP."
2165 `(gnus-gethash ,group gnus-active-hashtb
))
2167 (defmacro gnus-set-active
(group active
)
2168 "Set GROUP's active info."
2169 `(gnus-sethash ,group
,active gnus-active-hashtb
))
2171 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2172 ;; function `substring' might cut on a middle of multi-octet
2174 (defun gnus-truncate-string (str width
)
2175 (substring str
0 width
))
2177 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2178 ;; to limit the length of a string. This function is necessary since
2179 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2180 (defsubst gnus-limit-string
(str width
)
2181 (if (> (length str
) width
)
2182 (substring str
0 width
)
2185 (defsubst gnus-simplify-subject-re
(subject)
2186 "Remove \"Re:\" from subject lines."
2187 (if (string-match "^[Rr][Ee]: *" subject
)
2188 (substring subject
(match-end 0))
2191 (defsubst gnus-functionp
(form)
2192 "Return non-nil if FORM is funcallable."
2193 (or (and (symbolp form
) (fboundp form
))
2194 (and (listp form
) (eq (car form
) 'lambda
))))
2196 (defsubst gnus-goto-char
(point)
2197 (and point
(goto-char point
)))
2199 (defmacro gnus-buffer-exists-p
(buffer)
2200 `(let ((buffer ,buffer
))
2202 (funcall (if (stringp buffer
) 'get-buffer
'buffer-name
)
2205 (defmacro gnus-kill-buffer
(buffer)
2206 `(let ((buf ,buffer
))
2207 (if (gnus-buffer-exists-p buf
)
2208 (kill-buffer buf
))))
2210 (defsubst gnus-point-at-bol
()
2211 "Return point at the beginning of the line."
2218 (defsubst gnus-point-at-eol
()
2219 "Return point at the end of the line."
2226 (defun gnus-alive-p ()
2227 "Say whether Gnus is running or not."
2228 (and gnus-group-buffer
2229 (get-buffer gnus-group-buffer
)))
2231 (defun gnus-delete-first (elt list
)
2232 "Delete by side effect the first occurrence of ELT as a member of LIST."
2233 (if (equal (car list
) elt
)
2236 (while (and (cdr list
)
2237 (not (equal (cadr list
) elt
)))
2238 (setq list
(cdr list
)))
2240 (setcdr list
(cddr list
)))
2243 ;; Delete the current line (and the next N lines.);
2244 (defmacro gnus-delete-line
(&optional n
)
2245 `(delete-region (progn (beginning-of-line) (point))
2246 (progn (forward-line ,(or n
1)) (point))))
2248 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2249 (defvar gnus-init-inhibit nil
)
2250 (defun gnus-read-init-file (&optional inhibit-next
)
2251 (if gnus-init-inhibit
2252 (setq gnus-init-inhibit nil
)
2253 (setq gnus-init-inhibit inhibit-next
)
2255 (or (and (file-exists-p gnus-init-file
)
2256 ;; Don't try to load a directory.
2257 (not (file-directory-p gnus-init-file
)))
2258 (file-exists-p (concat gnus-init-file
".el"))
2259 (file-exists-p (concat gnus-init-file
".elc")))
2261 (load gnus-init-file nil t
)
2263 (error "Error in %s: %s" gnus-init-file var
))))))
2265 ;; Info access macros.
2267 (defmacro gnus-info-group
(info)
2269 (defmacro gnus-info-rank
(info)
2271 (defmacro gnus-info-read
(info)
2273 (defmacro gnus-info-marks
(info)
2275 (defmacro gnus-info-method
(info)
2277 (defmacro gnus-info-params
(info)
2280 (defmacro gnus-info-level
(info)
2281 `(let ((rank (gnus-info-rank ,info
)))
2285 (defmacro gnus-info-score
(info)
2286 `(let ((rank (gnus-info-rank ,info
)))
2287 (or (and (consp rank
) (cdr rank
)) 0)))
2289 (defmacro gnus-info-set-group
(info group
)
2290 `(setcar ,info
,group
))
2291 (defmacro gnus-info-set-rank
(info rank
)
2292 `(setcar (nthcdr 1 ,info
) ,rank
))
2293 (defmacro gnus-info-set-read
(info read
)
2294 `(setcar (nthcdr 2 ,info
) ,read
))
2295 (defmacro gnus-info-set-marks
(info marks
)
2296 `(setcar (nthcdr 3 ,info
) ,marks
))
2297 (defmacro gnus-info-set-method
(info method
)
2298 `(setcar (nthcdr 4 ,info
) ,method
))
2299 (defmacro gnus-info-set-params
(info params
)
2300 `(setcar (nthcdr 5 ,info
) ,params
))
2302 (defmacro gnus-info-set-level
(info level
)
2303 `(let ((rank (cdr ,info
)))
2304 (if (consp (car rank
))
2305 (setcar (car rank
) ,level
)
2306 (setcar rank
,level
))))
2307 (defmacro gnus-info-set-score
(info score
)
2308 `(let ((rank (cdr ,info
)))
2309 (if (consp (car rank
))
2310 (setcdr (car rank
) ,score
)
2311 (setcar rank
(cons (car rank
) ,score
)))))
2313 (defmacro gnus-get-info
(group)
2314 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb
)))
2316 (defun gnus-byte-code (func)
2317 "Return a form that can be `eval'ed based on FUNC."
2318 (let ((fval (symbol-function func
)))
2319 (if (byte-code-function-p fval
)
2320 (let ((flist (append fval nil
)))
2321 (setcar flist
'byte-code
)
2323 (cons 'progn
(cddr fval
)))))
2325 ;; Find out whether the gnus-visual TYPE is wanted.
2326 (defun gnus-visual-p (&optional type class
)
2327 (and gnus-visual
; Has to be non-nil, at least.
2328 (if (not type
) ; We don't care about type.
2330 (if (listp gnus-visual
) ; It's a list, so we check it.
2331 (or (memq type gnus-visual
)
2332 (memq class gnus-visual
))
2335 ;;; Load the compatability functions.
2345 (defvar gnus-shutdown-alist nil
)
2347 (defun gnus-add-shutdown (function &rest symbols
)
2348 "Run FUNCTION whenever one of SYMBOLS is shut down."
2349 (push (cons function symbols
) gnus-shutdown-alist
))
2351 (defun gnus-shutdown (symbol)
2352 "Shut down everything that waits for SYMBOL."
2353 (let ((alist gnus-shutdown-alist
)
2355 (while (setq entry
(pop alist
))
2356 (when (memq symbol
(cdr entry
))
2357 (funcall (car entry
))))))
2361 ;; Format specs. The chunks below are the machine-generated forms
2362 ;; that are to be evaled as the result of the default format strings.
2363 ;; We write them in here to get them byte-compiled. That way the
2364 ;; default actions will be quite fast, while still retaining the full
2365 ;; flexibility of the user-defined format specs.
2367 ;; First we have lots of dummy defvars to let the compiler know these
2368 ;; are really dynamic variables.
2370 (defvar gnus-tmp-unread
)
2371 (defvar gnus-tmp-replied
)
2372 (defvar gnus-tmp-score-char
)
2373 (defvar gnus-tmp-indentation
)
2374 (defvar gnus-tmp-opening-bracket
)
2375 (defvar gnus-tmp-lines
)
2376 (defvar gnus-tmp-name
)
2377 (defvar gnus-tmp-closing-bracket
)
2378 (defvar gnus-tmp-subject-or-nil
)
2379 (defvar gnus-tmp-subject
)
2380 (defvar gnus-tmp-marked
)
2381 (defvar gnus-tmp-marked-mark
)
2382 (defvar gnus-tmp-subscribed
)
2383 (defvar gnus-tmp-process-marked
)
2384 (defvar gnus-tmp-number-of-unread
)
2385 (defvar gnus-tmp-group-name
)
2386 (defvar gnus-tmp-group
)
2387 (defvar gnus-tmp-article-number
)
2388 (defvar gnus-tmp-unread-and-unselected
)
2389 (defvar gnus-tmp-news-method
)
2390 (defvar gnus-tmp-news-server
)
2391 (defvar gnus-tmp-article-number
)
2392 (defvar gnus-mouse-face
)
2393 (defvar gnus-mouse-face-prop
)
2395 (defun gnus-summary-line-format-spec ()
2396 (insert gnus-tmp-unread gnus-tmp-replied
2397 gnus-tmp-score-char gnus-tmp-indentation
)
2398 (gnus-put-text-property
2402 gnus-tmp-opening-bracket
2403 (format "%4d: %-20s"
2405 (if (> (length gnus-tmp-name
) 20)
2406 (substring gnus-tmp-name
0 20)
2408 gnus-tmp-closing-bracket
)
2410 gnus-mouse-face-prop gnus-mouse-face
)
2411 (insert " " gnus-tmp-subject-or-nil
"\n"))
2413 (defvar gnus-summary-line-format-spec
2414 (gnus-byte-code 'gnus-summary-line-format-spec
))
2416 (defun gnus-summary-dummy-line-format-spec ()
2418 (gnus-put-text-property
2423 gnus-mouse-face-prop gnus-mouse-face
)
2424 (insert " " gnus-tmp-subject
"\n"))
2426 (defvar gnus-summary-dummy-line-format-spec
2427 (gnus-byte-code 'gnus-summary-dummy-line-format-spec
))
2429 (defun gnus-group-line-format-spec ()
2430 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2431 gnus-tmp-process-marked
2432 gnus-group-indentation
2433 (format "%5s: " gnus-tmp-number-of-unread
))
2434 (gnus-put-text-property
2437 (insert gnus-tmp-group
"\n")
2439 gnus-mouse-face-prop gnus-mouse-face
))
2440 (defvar gnus-group-line-format-spec
2441 (gnus-byte-code 'gnus-group-line-format-spec
))
2443 (defvar gnus-format-specs
2444 `((version .
,emacs-version
)
2445 (group ,gnus-group-line-format
,gnus-group-line-format-spec
)
2446 (summary-dummy ,gnus-summary-dummy-line-format
2447 ,gnus-summary-dummy-line-format-spec
)
2448 (summary ,gnus-summary-line-format
,gnus-summary-line-format-spec
)))
2450 (defvar gnus-article-mode-line-format-spec nil
)
2451 (defvar gnus-summary-mode-line-format-spec nil
)
2452 (defvar gnus-group-mode-line-format-spec nil
)
2454 ;;; Phew. All that gruft is over, fortunately.
2458 ;;; Gnus Utility Functions
2461 (defun gnus-extract-address-components (from)
2463 ;; First find the address - the thing with the @ in it. This may
2464 ;; not be accurate in mail addresses, but does the trick most of
2465 ;; the time in news messages.
2466 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from
)
2467 (setq address
(substring from
(match-beginning 0) (match-end 0))))
2468 ;; Then we check whether the "name <address>" format is used.
2470 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2471 ;; Linear white space is not required.
2472 (string-match (concat "[ \t]*<" (regexp-quote address
) ">") from
)
2473 (and (setq name
(substring from
0 (match-beginning 0)))
2474 ;; Strip any quotes from the name.
2475 (string-match "\".*\"" name
)
2476 (setq name
(substring name
1 (1- (match-end 0))))))
2477 ;; If not, then "address (name)" is used.
2479 (and (string-match "(.+)" from
)
2480 (setq name
(substring from
(1+ (match-beginning 0))
2481 (1- (match-end 0)))))
2482 (and (string-match "()" from
)
2483 (setq name address
))
2484 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2485 ;; XOVER might not support folded From headers.
2486 (and (string-match "(.*" from
)
2487 (setq name
(substring from
(1+ (match-beginning 0))
2489 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2490 (list (or name from
) (or address from
))))
2492 (defun gnus-fetch-field (field)
2493 "Return the value of the header FIELD of current article."
2496 (let ((case-fold-search t
)
2497 (inhibit-point-motion-hooks t
))
2498 (nnheader-narrow-to-headers)
2499 (message-fetch-field field
)))))
2501 (defun gnus-goto-colon ()
2503 (search-forward ":" (gnus-point-at-eol) t
))
2506 (defun gnus-update-format (var)
2507 "Update the format specification near point."
2512 ;; Find the end of the current word.
2513 (re-search-forward "[ \t\n]" nil t
)
2515 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t
)
2516 (match-string 1)))))
2517 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var
)
2518 (match-string 1 var
))))
2519 (entry (assq type gnus-format-specs
))
2522 (setq gnus-format-specs
(delq entry gnus-format-specs
)))
2524 (intern (format "%s-spec" var
))
2525 (gnus-parse-format (setq value
(symbol-value (intern var
)))
2526 (symbol-value (intern (format "%s-alist" var
)))
2527 (not (string-match "mode" var
))))
2528 (setq spec
(symbol-value (intern (format "%s-spec" var
))))
2529 (push (list type value spec
) gnus-format-specs
)
2531 (pop-to-buffer "*Gnus Format*")
2533 (lisp-interaction-mode)
2534 (insert (pp-to-string spec
))))
2536 (defun gnus-update-format-specifications (&optional force
)
2537 "Update all (necessary) format specifications."
2538 ;; Make the indentation array.
2539 (gnus-make-thread-indent-array)
2541 ;; See whether all the stored info needs to be flushed.
2543 (not (equal emacs-version
2544 (cdr (assq 'version gnus-format-specs
)))))
2545 (setq gnus-format-specs nil
))
2547 ;; Go through all the formats and see whether they need updating.
2548 (let ((types '(summary summary-dummy group
2549 summary-mode group-mode article-mode
))
2550 new-format entry type val
)
2551 (while (setq type
(pop types
))
2552 ;; Jump to the proper buffer to find out the value of
2553 ;; the variable, if possible. (It may be buffer-local.)
2555 (let ((buffer (intern (format "gnus-%s-buffer" type
)))
2557 (when (and (boundp buffer
)
2558 (setq val
(symbol-value buffer
))
2560 (buffer-name (get-buffer val
)))
2561 (set-buffer (get-buffer val
)))
2562 (setq new-format
(symbol-value
2563 (intern (format "gnus-%s-line-format" type
))))))
2564 (setq entry
(cdr (assq type gnus-format-specs
)))
2566 (equal (car entry
) new-format
))
2567 ;; Use the old format.
2568 (set (intern (format "gnus-%s-line-format-spec" type
))
2570 ;; This is a new format.
2572 (if (not (stringp new-format
))
2573 ;; This is a function call or something.
2575 ;; This is a "real" format.
2579 (intern (format "gnus-%s-line-format-alist"
2580 (if (eq type
'article-mode
)
2581 'summary-mode type
))))
2582 (not (string-match "mode$" (symbol-name type
))))))
2583 ;; Enter the new format spec into the list.
2586 (setcar (cdr entry
) val
)
2587 (setcar entry new-format
))
2588 (push (list type new-format val
) gnus-format-specs
))
2589 (set (intern (format "gnus-%s-line-format-spec" type
)) val
))))
2591 (unless (assq 'version gnus-format-specs
)
2592 (push (cons 'version emacs-version
) gnus-format-specs
))
2594 (gnus-update-group-mark-positions)
2595 (gnus-update-summary-mark-positions))
2597 (defun gnus-update-summary-mark-positions ()
2598 "Compute where the summary marks are to go."
2600 (when (and gnus-summary-buffer
2601 (get-buffer gnus-summary-buffer
)
2602 (buffer-name (get-buffer gnus-summary-buffer
)))
2603 (set-buffer gnus-summary-buffer
))
2604 (let ((gnus-replied-mark 129)
2605 (gnus-score-below-mark 130)
2606 (gnus-score-over-mark 130)
2609 (spec gnus-summary-line-format-spec
)
2612 (gnus-set-work-buffer)
2613 (let ((gnus-summary-line-format-spec spec
))
2614 (gnus-summary-insert-line
2615 [0 "" "" "" "" "" 0 0 ""] 0 nil
128 t nil
"" nil
1)
2616 (goto-char (point-min))
2617 (setq pos
(list (cons 'unread
(and (search-forward "\200" nil t
)
2619 (goto-char (point-min))
2620 (push (cons 'replied
(and (search-forward "\201" nil t
)
2623 (goto-char (point-min))
2624 (push (cons 'score
(and (search-forward "\202" nil t
) (- (point) 2)))
2626 (setq gnus-summary-mark-positions pos
))))
2628 (defun gnus-update-group-mark-positions ()
2630 (let ((gnus-process-mark 128)
2631 (gnus-group-marked '("dummy.group"))
2632 (gnus-active-hashtb (make-vector 10 0)))
2633 (gnus-set-active "dummy.group" '(0 .
0))
2634 (gnus-set-work-buffer)
2635 (gnus-group-insert-group-line "dummy.group" 0 nil
0 nil
)
2636 (goto-char (point-min))
2637 (setq gnus-group-mark-positions
2638 (list (cons 'process
(and (search-forward "\200" nil t
)
2639 (- (point) 2))))))))
2641 (defvar gnus-mouse-face-0
'highlight
)
2642 (defvar gnus-mouse-face-1
'highlight
)
2643 (defvar gnus-mouse-face-2
'highlight
)
2644 (defvar gnus-mouse-face-3
'highlight
)
2645 (defvar gnus-mouse-face-4
'highlight
)
2647 (defun gnus-mouse-face-function (form type
)
2648 `(gnus-put-text-property
2649 (point) (progn ,@form
(point))
2650 gnus-mouse-face-prop
2653 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type
)))))))
2655 (defvar gnus-face-0
'bold
)
2656 (defvar gnus-face-1
'italic
)
2657 (defvar gnus-face-2
'bold-italic
)
2658 (defvar gnus-face-3
'bold
)
2659 (defvar gnus-face-4
'bold
)
2661 (defun gnus-face-face-function (form type
)
2662 `(gnus-put-text-property
2663 (point) (progn ,@form
(point))
2664 'face
',(symbol-value (intern (format "gnus-face-%d" type
)))))
2666 (defun gnus-max-width-function (el max-width
)
2667 (or (numberp max-width
) (signal 'wrong-type-argument
'(numberp max-width
)))
2669 `(if (> (length ,el
) ,max-width
)
2670 (substring ,el
0 ,max-width
)
2672 `(let ((val (eval ,el
)))
2674 (setq val
(int-to-string val
)))
2675 (if (> (length val
) ,max-width
)
2676 (substring val
0 ,max-width
)
2679 (defun gnus-parse-format (format spec-alist
&optional insert
)
2680 ;; This function parses the FORMAT string with the help of the
2681 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2682 ;; string. If the FORMAT string contains the specifiers %( and %)
2683 ;; the text between them will have the mouse-face text property.
2685 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2687 (gnus-parse-complex-format format spec-alist
)
2688 ;; This is a simple format.
2689 (gnus-parse-simple-format format spec-alist insert
)))
2691 (defun gnus-parse-complex-format (format spec-alist
)
2693 (gnus-set-work-buffer)
2695 (goto-char (point-min))
2696 (while (re-search-forward "\"" nil t
)
2697 (replace-match "\\\"" nil t
))
2698 (goto-char (point-min))
2700 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t
)
2701 (let ((number (if (match-beginning 1)
2702 (match-string 1) "0"))
2703 (delim (aref (match-string 2) 0)))
2704 (if (or (= delim ?\
() (= delim ?\
{))
2705 (replace-match (concat "\"(" (if (= delim ?\
() "mouse" "face")
2707 (replace-match "\")\""))))
2708 (goto-char (point-max))
2710 (goto-char (point-min))
2711 (let ((form (read (current-buffer))))
2712 (cons 'progn
(gnus-complex-form-to-spec form spec-alist
)))))
2714 (defun gnus-complex-form-to-spec (form spec-alist
)
2719 (gnus-parse-simple-format sform spec-alist t
)
2720 (funcall (intern (format "gnus-%s-face-function" (car sform
)))
2721 (gnus-complex-form-to-spec (cddr sform
) spec-alist
)
2725 (defun gnus-parse-simple-format (format spec-alist
&optional insert
)
2726 ;; This function parses the FORMAT string with the help of the
2727 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2730 spec flist fstring newspec elem beg result dontinsert
)
2732 (gnus-set-work-buffer)
2734 (goto-char (point-min))
2735 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2737 (if (= (setq spec
(string-to-char (match-string 2))) ?%
)
2739 beg
(1+ (match-beginning 0)))
2740 ;; First check if there are any specs that look anything like
2741 ;; "%12,12A", ie. with a "max width specification". These have
2742 ;; to be treated specially.
2743 (if (setq beg
(match-beginning 1))
2747 (1+ (match-beginning 1)) (match-end 1))))
2749 (setq beg
(match-beginning 2)))
2750 ;; Find the specification from `spec-alist'.
2751 (unless (setq elem
(cdr (assq spec spec-alist
)))
2752 (setq elem
'("*" ?s
)))
2753 ;; Treat user defined format specifiers specially.
2754 (when (eq (car elem
) 'gnus-tmp-user-defined
)
2757 (list (intern (concat "gnus-user-format-function-"
2759 'gnus-tmp-header
) ?s
))
2760 (delete-region (match-beginning 3) (match-end 3)))
2761 (if (not (zerop max-width
))
2762 (let ((el (car elem
)))
2763 (cond ((= (cadr elem
) ?c
)
2764 (setq el
(list 'char-to-string el
)))
2766 (setq el
(list 'int-to-string el
))))
2767 (setq flist
(cons (gnus-max-width-function el max-width
)
2771 (setq flist
(cons (car elem
) flist
))
2772 (setq newspec
(cadr elem
)))))
2773 ;; Remove the old specification (and possibly a ",12" string).
2774 (delete-region beg
(match-end 2))
2775 ;; Insert the new specification.
2778 (setq fstring
(buffer-substring 1 (point-max))))
2779 ;; Do some postprocessing to increase efficiency.
2784 ((string= fstring
"")
2786 ;; Not a format string.
2787 ((not (string-match "%" fstring
))
2789 ;; A format string with just a single string spec.
2790 ((string= fstring
"%s")
2792 ;; A single character.
2793 ((string= fstring
"%c")
2796 ((string= fstring
"%d")
2799 (list `(princ ,(car flist
)))
2800 (list `(int-to-string ,(car flist
)))))
2801 ;; Just lots of chars and strings.
2802 ((string-match "\\`\\(%[cs]\\)+\\'" fstring
)
2804 ;; A single string spec at the beginning of the spec.
2805 ((string-match "\\`%[sc][^%]+\\'" fstring
)
2806 (list (car flist
) (substring fstring
2)))
2807 ;; A single string spec in the middle of the spec.
2808 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring
)
2809 (list (match-string 1 fstring
) (car flist
) (match-string 2 fstring
)))
2810 ;; A single string spec in the end of the spec.
2811 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring
)
2812 (list (match-string 1 fstring
) (car flist
)))
2813 ;; A more complex spec.
2815 (list (cons 'format
(cons fstring
(nreverse flist
)))))))
2821 (cons 'insert result
)))
2822 (cond ((stringp result
)
2825 (cons 'concat result
))
2828 (defun gnus-eval-format (format &optional alist props
)
2829 "Eval the format variable FORMAT, using ALIST.
2830 If PROPS, insert the result."
2831 (let ((form (gnus-parse-format format alist props
)))
2833 (gnus-add-text-properties (point) (progn (eval form
) (point)) props
)
2836 (defun gnus-remove-text-with-property (prop)
2837 "Delete all text in the current buffer with text property PROP."
2839 (goto-char (point-min))
2841 (while (get-text-property (point) prop
)
2843 (goto-char (next-single-property-change (point) prop nil
(point-max))))))
2845 (defun gnus-set-work-buffer ()
2846 (if (get-buffer gnus-work-buffer
)
2848 (set-buffer gnus-work-buffer
)
2850 (set-buffer (get-buffer-create gnus-work-buffer
))
2851 (kill-all-local-variables)
2852 (buffer-disable-undo (current-buffer))
2853 (gnus-add-current-to-buffer-list)))
2855 ;; Article file names when saving.
2857 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
2858 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2859 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2860 Otherwise, it is like ~/News/news/group/num."
2863 (concat (if (gnus-use-long-file-name 'not-save
)
2864 (gnus-capitalize-newsgroup newsgroup
)
2865 (gnus-newsgroup-directory-form newsgroup
))
2866 "/" (int-to-string (mail-header-number headers
)))
2867 gnus-article-save-directory
)))
2869 (string-equal (file-name-directory default
)
2870 (file-name-directory last-file
))
2871 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2873 (or last-file default
))))
2875 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
2876 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2877 If variable `gnus-use-long-file-name' is non-nil, it is
2878 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2881 (concat (if (gnus-use-long-file-name 'not-save
)
2883 (gnus-newsgroup-directory-form newsgroup
))
2884 "/" (int-to-string (mail-header-number headers
)))
2885 gnus-article-save-directory
)))
2887 (string-equal (file-name-directory default
)
2888 (file-name-directory last-file
))
2889 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2891 (or last-file default
))))
2893 (defun gnus-Plain-save-name (newsgroup headers
&optional last-file
)
2894 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2895 If variable `gnus-use-long-file-name' is non-nil, it is
2896 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2899 (if (gnus-use-long-file-name 'not-save
)
2900 (gnus-capitalize-newsgroup newsgroup
)
2901 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2902 gnus-article-save-directory
)))
2904 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
2905 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2906 If variable `gnus-use-long-file-name' is non-nil, it is
2907 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2910 (if (gnus-use-long-file-name 'not-save
)
2912 (concat (gnus-newsgroup-directory-form newsgroup
) "/news"))
2913 gnus-article-save-directory
)))
2915 ;; For subscribing new newsgroup
2917 (defun gnus-subscribe-hierarchical-interactive (groups)
2918 (let ((groups (sort groups
'string
<))
2919 prefixes prefix start ans group starts
)
2921 (setq prefixes
(list "^"))
2922 (while (and groups prefixes
)
2923 (while (not (string-match (car prefixes
) (car groups
)))
2924 (setq prefixes
(cdr prefixes
)))
2925 (setq prefix
(car prefixes
))
2926 (setq start
(1- (length prefix
)))
2927 (if (and (string-match "[^\\.]\\." (car groups
) start
)
2930 (concat "^" (substring (car groups
) 0 (match-end 0))))
2931 (string-match prefix
(cadr groups
)))
2933 (setq prefixes
(cons prefix prefixes
))
2934 (message "Descend hierarchy %s? ([y]nsq): "
2935 (substring prefix
1 (1- (length prefix
))))
2936 (while (not (memq (setq ans
(read-char)) '(?y ?
\n ?n ?s ?q
)))
2938 (message "Descend hierarchy %s? ([y]nsq): "
2939 (substring prefix
1 (1- (length prefix
)))))
2942 (string-match prefix
2943 (setq group
(car groups
))))
2944 (setq gnus-killed-list
2945 (cons group gnus-killed-list
))
2946 (gnus-sethash group group gnus-killed-hashtb
)
2947 (setq groups
(cdr groups
)))
2948 (setq starts
(cdr starts
)))
2951 (string-match prefix
2952 (setq group
(car groups
))))
2953 (gnus-sethash group group gnus-killed-hashtb
)
2954 (gnus-subscribe-alphabetically (car groups
))
2955 (setq groups
(cdr groups
)))
2956 (setq starts
(cdr starts
)))
2959 (setq group
(car groups
))
2960 (setq gnus-killed-list
(cons group gnus-killed-list
))
2961 (gnus-sethash group group gnus-killed-hashtb
)
2962 (setq groups
(cdr groups
))))
2964 (message "Subscribe %s? ([n]yq)" (car groups
))
2965 (while (not (memq (setq ans
(read-char)) '(?y ?
\n ?q ?n
)))
2967 (message "Subscribe %s? ([n]yq)" (car groups
)))
2968 (setq group
(car groups
))
2970 (gnus-subscribe-alphabetically (car groups
))
2971 (gnus-sethash group group gnus-killed-hashtb
))
2974 (setq group
(car groups
))
2975 (setq gnus-killed-list
(cons group gnus-killed-list
))
2976 (gnus-sethash group group gnus-killed-hashtb
)
2977 (setq groups
(cdr groups
))))
2979 (setq gnus-killed-list
(cons group gnus-killed-list
))
2980 (gnus-sethash group group gnus-killed-hashtb
)))
2981 (setq groups
(cdr groups
)))))))
2983 (defun gnus-subscribe-randomly (newsgroup)
2984 "Subscribe new NEWSGROUP by making it the first newsgroup."
2985 (gnus-subscribe-newsgroup newsgroup
))
2987 (defun gnus-subscribe-alphabetically (newgroup)
2988 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2989 (let ((groups (cdr gnus-newsrc-alist
))
2991 (while (and (not before
) groups
)
2992 (if (string< newgroup
(caar groups
))
2993 (setq before
(caar groups
))
2994 (setq groups
(cdr groups
))))
2995 (gnus-subscribe-newsgroup newgroup before
)))
2997 (defun gnus-subscribe-hierarchically (newgroup)
2998 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2999 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3001 (set-buffer (find-file-noselect gnus-current-startup-file
))
3002 (let ((groupkey newgroup
)
3004 (while (and (not before
) groupkey
)
3005 (goto-char (point-min))
3007 (concat "^\\(" (regexp-quote groupkey
) ".*\\)[!:]")))
3008 (while (and (re-search-forward groupkey-re nil t
)
3010 (setq before
(match-string 1))
3011 (string< before newgroup
)))))
3012 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3014 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey
)
3015 (substring groupkey
(match-beginning 1) (match-end 1)))))
3016 (gnus-subscribe-newsgroup newgroup before
))))
3018 (defun gnus-subscribe-interactively (group)
3019 "Subscribe the new GROUP interactively.
3020 It is inserted in hierarchical newsgroup order if subscribed. If not,
3022 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group
))
3023 (gnus-subscribe-hierarchically group
)
3024 (push group gnus-killed-list
)))
3026 (defun gnus-subscribe-zombies (group)
3027 "Make the new GROUP into a zombie group."
3028 (push group gnus-zombie-list
))
3030 (defun gnus-subscribe-killed (group)
3031 "Make the new GROUP a killed group."
3032 (push group gnus-killed-list
))
3034 (defun gnus-subscribe-newsgroup (newsgroup &optional next
)
3035 "Subscribe new NEWSGROUP.
3036 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3037 the first newsgroup."
3038 ;; We subscribe the group by changing its level to `subscribed'.
3039 (gnus-group-change-level
3040 newsgroup gnus-level-default-subscribed
3041 gnus-level-killed
(gnus-gethash (or next
"dummy.group") gnus-newsrc-hashtb
))
3042 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup
))
3046 (defun gnus-newsgroup-directory-form (newsgroup)
3047 "Make hierarchical directory name from NEWSGROUP name."
3048 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup
))
3049 (len (length newsgroup
))
3051 ;; If this is a foreign group, we don't want to translate the
3053 (if (setq idx
(string-match ":" newsgroup
))
3054 (aset newsgroup idx ?
/)
3056 ;; Replace all occurrences of `.' with `/'.
3058 (if (= (aref newsgroup idx
) ?.
)
3059 (aset newsgroup idx ?
/))
3060 (setq idx
(1+ idx
)))
3063 (defun gnus-newsgroup-savable-name (group)
3064 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3066 (nnheader-replace-chars-in-string group ?
/ ?.
))
3068 (defun gnus-make-directory (dir)
3069 "Make DIRECTORY recursively."
3070 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3071 ;; of the many mysteries of the universe.
3072 (let* ((dir (expand-file-name dir default-directory
))
3074 (if (string-match "/$" dir
)
3075 (setq dir
(substring dir
0 (match-beginning 0))))
3076 ;; First go down the path until we find a directory that exists.
3077 (while (not (file-exists-p dir
))
3078 (setq dirs
(cons dir dirs
))
3079 (string-match "/[^/]+$" dir
)
3080 (setq dir
(substring dir
0 (match-beginning 0))))
3081 ;; Then create all the subdirs.
3082 (while (and dirs
(not err
))
3084 (make-directory (car dirs
))
3085 (error (setq err t
)))
3086 (setq dirs
(cdr dirs
)))
3087 ;; We return whether we were successful or not.
3090 (defun gnus-capitalize-newsgroup (newsgroup)
3091 "Capitalize NEWSGROUP name."
3092 (and (not (zerop (length newsgroup
)))
3093 (concat (char-to-string (upcase (aref newsgroup
0)))
3094 (substring newsgroup
1))))
3096 ;; Various... things.
3098 (defun gnus-simplify-subject (subject &optional re-only
)
3099 "Remove `Re:' and words in parentheses.
3100 If RE-ONLY is non-nil, strip leading `Re:'s only."
3101 (let ((case-fold-search t
)) ;Ignore case.
3102 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3103 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject
)
3104 (setq subject
(substring subject
(match-end 0))))
3105 ;; Remove uninteresting prefixes.
3106 (if (and (not re-only
)
3107 gnus-simplify-ignored-prefixes
3108 (string-match gnus-simplify-ignored-prefixes subject
))
3109 (setq subject
(substring subject
(match-end 0))))
3110 ;; Remove words in parentheses from end.
3112 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject
)
3113 (setq subject
(substring subject
0 (match-beginning 0)))))
3114 ;; Return subject string.
3117 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3119 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3120 (defun gnus-simplify-buffer-fuzzy ()
3121 (let ((case-fold-search t
))
3122 (goto-char (point-min))
3123 (while (search-forward "\t" nil t
)
3124 (replace-match " " t t
))
3125 (goto-char (point-min))
3126 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t
)
3127 (goto-char (match-beginning 0))
3129 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3130 (looking-at "^[[].*: .*[]]$"))
3131 (goto-char (point-min))
3132 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3134 (replace-match "" t t
))
3135 (goto-char (point-min))
3136 (while (re-search-forward "^[[].*: .*[]]$" nil t
)
3137 (goto-char (match-end 0))
3140 (progn (goto-char (match-beginning 0)))
3141 (re-search-forward ":"))))
3142 (goto-char (point-min))
3143 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t
)
3144 (replace-match "" t t
))
3145 (goto-char (point-min))
3146 (while (re-search-forward " +" nil t
)
3147 (replace-match " " t t
))
3148 (goto-char (point-min))
3149 (while (re-search-forward " $" nil t
)
3150 (replace-match "" t t
))
3151 (goto-char (point-min))
3152 (while (re-search-forward "^ +" nil t
)
3153 (replace-match "" t t
))
3154 (goto-char (point-min))
3155 (when gnus-simplify-subject-fuzzy-regexp
3156 (if (listp gnus-simplify-subject-fuzzy-regexp
)
3157 (let ((list gnus-simplify-subject-fuzzy-regexp
))
3159 (goto-char (point-min))
3160 (while (re-search-forward (car list
) nil t
)
3161 (replace-match "" t t
))
3162 (setq list
(cdr list
))))
3163 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t
)
3164 (replace-match "" t t
))))))
3166 (defun gnus-simplify-subject-fuzzy (subject)
3167 "Siplify a subject string fuzzily."
3169 (gnus-set-work-buffer)
3170 (let ((case-fold-search t
))
3172 (inline (gnus-simplify-buffer-fuzzy))
3175 ;; Add the current buffer to the list of buffers to be killed on exit.
3176 (defun gnus-add-current-to-buffer-list ()
3177 (or (memq (current-buffer) gnus-buffer-list
)
3178 (setq gnus-buffer-list
(cons (current-buffer) gnus-buffer-list
))))
3180 (defun gnus-string> (s1 s2
)
3181 (not (or (string< s1 s2
)
3184 (defun gnus-read-active-file-p ()
3185 "Say whether the active file has been read from `gnus-select-method'."
3186 (memq gnus-select-method gnus-have-read-active-file
))
3188 ;;; General various misc type functions.
3190 (defun gnus-clear-system ()
3191 "Clear all variables and buffers."
3192 ;; Clear Gnus variables.
3193 (let ((variables gnus-variable-list
))
3195 (set (car variables
) nil
)
3196 (setq variables
(cdr variables
))))
3197 ;; Clear other internal variables.
3198 (setq gnus-list-of-killed-groups nil
3199 gnus-have-read-active-file nil
3200 gnus-newsrc-alist nil
3201 gnus-newsrc-hashtb nil
3202 gnus-killed-list nil
3203 gnus-zombie-list nil
3204 gnus-killed-hashtb nil
3205 gnus-active-hashtb nil
3206 gnus-moderated-list nil
3207 gnus-description-hashtb nil
3208 gnus-current-headers nil
3209 gnus-thread-indent-array nil
3210 gnus-newsgroup-headers nil
3211 gnus-newsgroup-name nil
3212 gnus-server-alist nil
3213 gnus-group-list-mode nil
3214 gnus-opened-servers nil
3215 gnus-group-mark-positions nil
3216 gnus-newsgroup-data nil
3217 gnus-newsgroup-unreads nil
3218 gnus-current-select-method nil
)
3219 (gnus-shutdown 'gnus
)
3220 ;; Kill the startup file.
3221 (and gnus-current-startup-file
3222 (get-file-buffer gnus-current-startup-file
)
3223 (kill-buffer (get-file-buffer gnus-current-startup-file
)))
3224 ;; Clear the dribble buffer.
3225 (gnus-dribble-clear)
3226 ;; Kill global KILL file buffer.
3227 (when (get-file-buffer (gnus-newsgroup-kill-file nil
))
3228 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil
))))
3229 (gnus-kill-buffer nntp-server-buffer
)
3230 ;; Kill Gnus buffers.
3231 (while gnus-buffer-list
3232 (gnus-kill-buffer (pop gnus-buffer-list
)))
3233 ;; Remove Gnus frames.
3234 (gnus-kill-gnus-frames))
3236 (defun gnus-kill-gnus-frames ()
3237 "Kill all frames Gnus has created."
3238 (while gnus-created-frames
3239 (when (frame-live-p (car gnus-created-frames
))
3240 ;; We slap a condition-case around this `delete-frame' to ensure
3241 ;; against errors if we try do delete the single frame that's left.
3243 (delete-frame (car gnus-created-frames
))
3245 (pop gnus-created-frames
)))
3247 (defun gnus-windows-old-to-new (setting)
3248 ;; First we take care of the really, really old Gnus 3 actions.
3249 (when (symbolp setting
)
3251 ;; Take care of ooold GNUS 3.x values.
3252 (cond ((eq setting
'SelectArticle
) 'article
)
3253 ((memq setting
'(SelectSubject ExpandSubject
)) 'summary
)
3254 ((memq setting
'(SelectNewsgroup ExitNewsgroup
)) 'group
)
3256 (if (or (listp setting
)
3257 (not (and gnus-window-configuration
3258 (memq setting
'(group summary article
)))))
3260 (let* ((setting (if (eq setting
'group
)
3261 (if (assq 'newsgroup gnus-window-configuration
)
3263 'newsgroups
) setting
))
3264 (elem (cadr (assq setting gnus-window-configuration
)))
3265 (total (apply '+ elem
))
3266 (types '(group summary article
))
3267 (pbuf (if (eq setting
'newsgroups
) 'group
'summary
))
3272 (or (not (numberp (nth i elem
)))
3273 (zerop (nth i elem
))
3275 (setq perc
(if (= i
2)
3277 (/ (float (nth 0 elem
)) total
)))
3278 (setq out
(cons (if (eq pbuf
(nth i types
))
3279 (list (nth i types
) perc
'point
)
3280 (list (nth i types
) perc
))
3283 `(vertical 1.0 ,@(nreverse out
)))))
3286 (defun gnus-add-configuration (conf)
3287 "Add the window configuration CONF to `gnus-buffer-configuration'."
3288 (setq gnus-buffer-configuration
3289 (cons conf
(delq (assq (car conf
) gnus-buffer-configuration
)
3290 gnus-buffer-configuration
))))
3292 (defvar gnus-frame-list nil
)
3294 (defun gnus-configure-frame (split &optional window
)
3295 "Split WINDOW according to SPLIT."
3297 (setq window
(get-buffer-window (current-buffer))))
3298 (select-window window
)
3299 ;; This might be an old-stylee buffer config.
3300 (when (vectorp split
)
3301 (setq split
(append split nil
)))
3302 (when (or (consp (car split
))
3303 (vectorp (car split
)))
3305 (push 'vertical split
))
3306 ;; The SPLIT might be something that is to be evaled to
3307 ;; return a new SPLIT.
3308 (while (and (not (assq (car split
) gnus-window-to-buffer
))
3309 (gnus-functionp (car split
)))
3310 (setq split
(eval split
)))
3311 (let* ((type (car split
))
3313 (len (if (eq type
'horizontal
) (window-width) (window-height)))
3315 (window-min-width (or gnus-window-min-width window-min-width
))
3316 (window-min-height (or gnus-window-min-height window-min-height
))
3317 s result new-win rest comp-subs size sub
)
3319 ;; Nothing to do here.
3321 ;; Don't switch buffers.
3323 (and (memq 'point split
) window
))
3324 ;; This is a buffer to be selected.
3325 ((not (memq type
'(frame horizontal vertical
)))
3326 (let ((buffer (cond ((stringp type
) type
)
3327 (t (cdr (assq type gnus-window-to-buffer
)))))
3330 (error "Illegal buffer type: %s" type
))
3331 (unless (setq buf
(get-buffer (if (symbolp buffer
)
3332 (symbol-value buffer
) buffer
)))
3333 (setq buf
(get-buffer-create (if (symbolp buffer
)
3334 (symbol-value buffer
) buffer
))))
3335 (switch-to-buffer buf
)
3336 ;; We return the window if it has the `point' spec.
3337 (and (memq 'point split
) window
)))
3338 ;; This is a frame split.
3340 (unless gnus-frame-list
3341 (setq gnus-frame-list
(list (window-frame
3342 (get-buffer-window (current-buffer))))))
3344 params frame fresult
)
3345 (while (< i
(length subs
))
3346 ;; Frame parameter is gotten from the sub-split.
3347 (setq params
(cadr (elt subs i
)))
3348 ;; It should be a list.
3349 (unless (listp params
)
3351 ;; Create a new frame?
3352 (unless (setq frame
(elt gnus-frame-list i
))
3353 (nconc gnus-frame-list
(list (setq frame
(make-frame params
))))
3354 (push frame gnus-created-frames
))
3355 ;; Is the old frame still alive?
3356 (unless (frame-live-p frame
)
3357 (setcar (nthcdr i gnus-frame-list
)
3358 (setq frame
(make-frame params
))))
3359 ;; Select the frame in question and do more splits there.
3360 (select-frame frame
)
3361 (setq fresult
(or (gnus-configure-frame (elt subs i
)) fresult
))
3363 ;; Select the frame that has the selected buffer.
3365 (select-frame (window-frame fresult
)))))
3366 ;; This is a normal split.
3368 (when (> (length subs
) 0)
3369 ;; First we have to compute the sizes of all new windows.
3371 (setq sub
(append (pop subs
) nil
))
3372 (while (and (not (assq (car sub
) gnus-window-to-buffer
))
3373 (gnus-functionp (car sub
)))
3374 (setq sub
(eval sub
)))
3376 (push sub comp-subs
)
3377 (setq size
(cadar comp-subs
))
3378 (cond ((equal size
1.0)
3379 (setq rest
(car comp-subs
))
3382 (setq s
(floor (* size len
))))
3386 (error "Illegal size: %s" size
)))
3387 ;; Try to make sure that we are inside the safe limits.
3389 ((eq type
'horizontal
)
3390 (setq s
(max s window-min-width
)))
3391 ((eq type
'vertical
)
3392 (setq s
(max s window-min-height
))))
3393 (setcar (cdar comp-subs
) s
)
3395 ;; Take care of the "1.0" spec.
3397 (setcar (cdr rest
) (- len total
))
3398 (error "No 1.0 specs in %s" split
))
3399 ;; The we do the actual splitting in a nice recursive
3401 (setq comp-subs
(nreverse comp-subs
))
3403 (if (null (cdr comp-subs
))
3404 (setq new-win window
)
3406 (split-window window
(cadar comp-subs
)
3407 (eq type
'horizontal
))))
3408 (setq result
(or (gnus-configure-frame
3409 (car comp-subs
) window
) result
))
3410 (select-window new-win
)
3411 (setq window new-win
)
3412 (setq comp-subs
(cdr comp-subs
))))
3413 ;; Return the proper window, if any.
3415 (select-window result
))))))
3417 (defvar gnus-frame-split-p nil
)
3419 (defun gnus-configure-windows (setting &optional force
)
3420 (setq setting
(gnus-windows-old-to-new setting
))
3421 (let ((split (if (symbolp setting
)
3422 (cadr (assq setting gnus-buffer-configuration
))
3426 (setq gnus-frame-split-p nil
)
3429 (error "No such setting: %s" setting
))
3431 (if (and (setq all-visible
(gnus-all-windows-visible-p split
))
3433 ;; All the windows mentioned are already visible, so we just
3434 ;; put point in the assigned buffer, and do not touch the
3436 (select-window all-visible
)
3438 ;; Either remove all windows or just remove all Gnus windows.
3439 (let ((frame (selected-frame)))
3441 (if gnus-use-full-window
3442 ;; We want to remove all other windows.
3443 (if (not gnus-frame-split-p
)
3444 ;; This is not a `frame' split, so we ignore the
3446 (delete-other-windows)
3447 ;; This is a `frame' split, so we delete all windows
3451 (unless (eq (cdr (assq 'minibuffer
3452 (frame-parameters frame
)))
3454 (select-frame frame
)
3455 (delete-other-windows)))
3457 ;; Just remove some windows.
3458 (gnus-remove-some-windows)
3459 (switch-to-buffer nntp-server-buffer
))
3460 (select-frame frame
)))
3462 (switch-to-buffer nntp-server-buffer
)
3463 (gnus-configure-frame split
(get-buffer-window (current-buffer))))))
3465 (defun gnus-all-windows-visible-p (split)
3466 "Say whether all buffers in SPLIT are currently visible.
3467 In particular, the value returned will be the window that
3469 (let ((stack (list split
))
3471 type buffer win buf
)
3472 (while (and (setq split
(pop stack
))
3474 ;; Be backwards compatible.
3475 (when (vectorp split
)
3476 (setq split
(append split nil
)))
3477 (when (or (consp (car split
))
3478 (vectorp (car split
)))
3480 (push 'vertical split
))
3481 ;; The SPLIT might be something that is to be evaled to
3482 ;; return a new SPLIT.
3483 (while (and (not (assq (car split
) gnus-window-to-buffer
))
3484 (gnus-functionp (car split
)))
3485 (setq split
(eval split
)))
3487 (setq type
(elt split
0))
3492 ((not (memq type
'(horizontal vertical frame
)))
3493 (setq buffer
(cond ((stringp type
) type
)
3494 (t (cdr (assq type gnus-window-to-buffer
)))))
3496 (error "Illegal buffer type: %s" type
))
3497 (when (setq buf
(get-buffer (if (symbolp buffer
)
3498 (symbol-value buffer
)
3500 (setq win
(get-buffer-window buf t
)))
3502 (when (memq 'point split
)
3503 (setq all-visible win
))
3504 (setq all-visible nil
)))
3506 (when (eq type
'frame
)
3507 (setq gnus-frame-split-p t
))
3508 (setq stack
(append (cddr split
) stack
)))))
3509 (unless (eq all-visible t
)
3512 (defun gnus-window-top-edge (&optional window
)
3513 (nth 1 (window-edges window
)))
3515 (defun gnus-remove-some-windows ()
3516 (let ((buffers gnus-window-to-buffer
)
3517 buf bufs lowest-buf lowest
)
3519 ;; Remove windows on all known Gnus buffers.
3521 (setq buf
(cdar buffers
))
3523 (setq buf
(and (boundp buf
) (symbol-value buf
))))
3525 (get-buffer-window buf
)
3527 (setq bufs
(cons buf bufs
))
3529 (if (or (not lowest
)
3530 (< (gnus-window-top-edge) lowest
))
3532 (setq lowest
(gnus-window-top-edge))
3533 (setq lowest-buf buf
)))))
3534 (setq buffers
(cdr buffers
)))
3535 ;; Remove windows on *all* summary buffers.
3538 (let ((buf (window-buffer win
)))
3539 (if (string-match "^\\*Summary" (buffer-name buf
))
3541 (setq bufs
(cons buf bufs
))
3543 (if (or (not lowest
)
3544 (< (gnus-window-top-edge) lowest
))
3546 (setq lowest-buf buf
)
3547 (setq lowest
(gnus-window-top-edge)))))))))
3550 (pop-to-buffer lowest-buf
)
3551 (switch-to-buffer nntp-server-buffer
)))
3553 (and (not (eq (car bufs
) lowest-buf
))
3554 (delete-windows-on (car bufs
)))
3555 (setq bufs
(cdr bufs
))))))
3557 (defun gnus-version (&optional arg
)
3558 "Version number of this version of Gnus.
3559 If ARG, insert string at point."
3561 (let ((methods gnus-valid-select-methods
)
3564 ;; Go through all the legal select methods and add their version
3565 ;; numbers to the total version string. Only the backends that are
3566 ;; currently in use will have their message numbers taken into
3569 (setq meth
(intern (concat (caar methods
) "-version")))
3571 (stringp (symbol-value meth
))
3572 (setq mess
(concat mess
"; " (symbol-value meth
))))
3573 (setq methods
(cdr methods
)))
3575 (insert (message mess
))
3578 (defun gnus-info-find-node ()
3579 "Find Info documentation of Gnus."
3581 ;; Enlarge info window if needed.
3582 (let ((mode major-mode
)
3584 (Info-goto-node (cadr (assq mode gnus-info-nodes
)))
3585 (setq gnus-info-buffer
(current-buffer))
3586 (gnus-configure-windows 'info
)))
3588 (defun gnus-days-between (date1 date2
)
3589 ;; Return the number of days between date1 and date2.
3590 (- (gnus-day-number date1
) (gnus-day-number date2
)))
3592 (defun gnus-day-number (date)
3593 (let ((dat (mapcar (lambda (s) (and s
(string-to-int s
)) )
3594 (timezone-parse-date date
))))
3595 (timezone-absolute-from-gregorian
3596 (nth 1 dat
) (nth 2 dat
) (car dat
))))
3598 (defun gnus-encode-date (date)
3599 "Convert DATE to internal time."
3600 (let* ((parse (timezone-parse-date date
))
3601 (date (mapcar (lambda (d) (and d
(string-to-int d
))) parse
))
3602 (time (mapcar 'string-to-int
(timezone-parse-time (aref parse
3)))))
3603 (encode-time (caddr time
) (cadr time
) (car time
)
3604 (caddr date
) (cadr date
) (car date
) (nth 4 date
))))
3606 (defun gnus-time-minus (t1 t2
)
3607 "Subtract two internal times."
3608 (let ((borrow (< (cadr t1
) (cadr t2
))))
3609 (list (- (car t1
) (car t2
) (if borrow
1 0))
3610 (- (+ (if borrow
65536 0) (cadr t1
)) (cadr t2
)))))
3612 (defun gnus-file-newer-than (file date
)
3613 (let ((fdate (nth 5 (file-attributes file
))))
3614 (or (> (car fdate
) (car date
))
3615 (and (= (car fdate
) (car date
))
3616 (> (nth 1 fdate
) (nth 1 date
))))))
3618 (defmacro gnus-local-set-keys
(&rest plist
)
3619 "Set the keys in PLIST in the current keymap."
3620 `(gnus-define-keys-1 (current-local-map) ',plist
))
3622 (defmacro gnus-define-keys
(keymap &rest plist
)
3623 "Define all keys in PLIST in KEYMAP."
3624 `(gnus-define-keys-1 (quote ,keymap
) (quote ,plist
)))
3626 (put 'gnus-define-keys
'lisp-indent-function
1)
3627 (put 'gnus-define-keys
'lisp-indent-hook
1)
3628 (put 'gnus-define-keymap
'lisp-indent-function
1)
3629 (put 'gnus-define-keymap
'lisp-indent-hook
1)
3631 (defmacro gnus-define-keymap
(keymap &rest plist
)
3632 "Define all keys in PLIST in KEYMAP."
3633 `(gnus-define-keys-1 ,keymap
(quote ,plist
)))
3635 (defun gnus-define-keys-1 (keymap plist
)
3637 (error "Can't set keys in a null keymap"))
3638 (cond ((symbolp keymap
)
3639 (setq keymap
(symbol-value keymap
)))
3642 (set (car keymap
) nil
)
3643 (define-prefix-command (car keymap
))
3644 (define-key (symbol-value (caddr keymap
)) (cadr keymap
) (car keymap
))
3645 (setq keymap
(symbol-value (car keymap
)))))
3648 (when (symbolp (setq key
(pop plist
)))
3649 (setq key
(symbol-value key
)))
3650 (define-key keymap key
(pop plist
)))))
3652 (defun gnus-group-read-only-p (&optional group
)
3653 "Check whether GROUP supports editing or not.
3654 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3655 that that variable is buffer-local to the summary buffers."
3656 (let ((group (or group gnus-newsgroup-name
)))
3657 (not (gnus-check-backend-function 'request-replace-article group
))))
3659 (defun gnus-group-total-expirable-p (group)
3660 "Check whether GROUP is total-expirable or not."
3661 (let ((params (gnus-info-params (gnus-get-info group
))))
3662 (or (memq 'total-expire params
)
3663 (cdr (assq 'total-expire params
)) ; (total-expire . t)
3664 (and gnus-total-expirable-newsgroups
; Check var.
3665 (string-match gnus-total-expirable-newsgroups group
)))))
3667 (defun gnus-group-auto-expirable-p (group)
3668 "Check whether GROUP is total-expirable or not."
3669 (let ((params (gnus-info-params (gnus-get-info group
))))
3670 (or (memq 'auto-expire params
)
3671 (cdr (assq 'auto-expire params
)) ; (auto-expire . t)
3672 (and gnus-auto-expirable-newsgroups
; Check var.
3673 (string-match gnus-auto-expirable-newsgroups group
)))))
3675 (defun gnus-virtual-group-p (group)
3676 "Say whether GROUP is virtual or not."
3677 (memq 'virtual
(assoc (symbol-name (car (gnus-find-method-for-group group
)))
3678 gnus-valid-select-methods
)))
3680 (defun gnus-news-group-p (group &optional article
)
3681 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3682 (or (gnus-member-of-valid 'post group
) ; Ordinary news group.
3683 (and (gnus-member-of-valid 'post-mail group
) ; Combined group.
3684 (eq (gnus-request-type group article
) 'news
))))
3686 (defsubst gnus-simplify-subject-fully
(subject)
3687 "Simplify a subject string according to the user's wishes."
3689 ((null gnus-summary-gather-subject-limit
)
3690 (gnus-simplify-subject-re subject
))
3691 ((eq gnus-summary-gather-subject-limit
'fuzzy
)
3692 (gnus-simplify-subject-fuzzy subject
))
3693 ((numberp gnus-summary-gather-subject-limit
)
3694 (gnus-limit-string (gnus-simplify-subject-re subject
)
3695 gnus-summary-gather-subject-limit
))
3699 (defsubst gnus-subject-equal
(s1 s2
&optional simple-first
)
3700 "Check whether two subjects are equal. If optional argument
3701 simple-first is t, first argument is already simplified."
3703 ((null simple-first
)
3704 (equal (gnus-simplify-subject-fully s1
)
3705 (gnus-simplify-subject-fully s2
)))
3708 (gnus-simplify-subject-fully s2
)))))
3710 ;; Returns a list of writable groups.
3711 (defun gnus-writable-groups ()
3712 (let ((alist gnus-newsrc-alist
)
3714 (while (setq group
(car (pop alist
)))
3715 (unless (gnus-group-read-only-p group
)
3716 (push group groups
)))
3719 (defun gnus-completing-read (default prompt
&rest args
)
3720 ;; Like `completing-read', except that DEFAULT is the default argument.
3721 (let* ((prompt (if default
3722 (concat prompt
" (default " default
") ")
3723 (concat prompt
" ")))
3724 (answer (apply 'completing-read prompt args
)))
3725 (if (or (null answer
) (zerop (length answer
)))
3729 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3731 (defun gnus-y-or-n-p (prompt)
3736 (defun gnus-yes-or-no-p (prompt)
3738 (yes-or-no-p prompt
)
3741 ;; Check whether to use long file names.
3742 (defun gnus-use-long-file-name (symbol)
3743 ;; The variable has to be set...
3744 (and gnus-use-long-file-name
3745 ;; If it isn't a list, then we return t.
3746 (or (not (listp gnus-use-long-file-name
))
3747 ;; If it is a list, and the list contains `symbol', we
3749 (not (memq symbol gnus-use-long-file-name
)))))
3751 ;; I suspect there's a better way, but I haven't taken the time to do
3752 ;; it yet. -erik selberg@cs.washington.edu
3753 (defun gnus-dd-mmm (messy-date)
3754 "Return a string like DD-MMM from a big messy string"
3755 (let ((datevec (condition-case () (timezone-parse-date messy-date
)
3761 ;; Make sure leading zeroes are stripped.
3762 (number-to-string (string-to-number (aref datevec
2)))
3766 (nth (1- (string-to-number (aref datevec
1)))
3767 timezone-months-assoc
))
3770 (defun gnus-mode-string-quote (string)
3771 "Quote all \"%\" in STRING."
3773 (gnus-set-work-buffer)
3775 (goto-char (point-min))
3776 (while (search-forward "%" nil t
)
3780 ;; Make a hash table (default and minimum size is 255).
3781 ;; Optional argument HASHSIZE specifies the table size.
3782 (defun gnus-make-hashtable (&optional hashsize
)
3783 (make-vector (if hashsize
(max (gnus-create-hash-size hashsize
) 255) 255) 0))
3785 ;; Make a number that is suitable for hashing; bigger than MIN and one
3787 (defun gnus-create-hash-size (min)
3793 ;; Show message if message has a lower level than `gnus-verbose'.
3794 ;; Guideline for numbers:
3795 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3796 ;; for things that take a long time, 7 - not very important messages
3797 ;; on stuff, 9 - messages inside loops.
3798 (defun gnus-message (level &rest args
)
3799 (if (<= level gnus-verbose
)
3800 (apply 'message args
)
3801 ;; We have to do this format thingy here even if the result isn't
3802 ;; shown - the return value has to be the same as the return value
3804 (apply 'format args
)))
3806 (defun gnus-error (level &rest args
)
3807 "Beep an error if `gnus-verbose' is on LEVEL or less."
3808 (when (<= (floor level
) gnus-verbose
)
3809 (apply 'message args
)
3812 (when (and (floatp level
)
3813 (not (zerop (setq duration
(* 10 (- level
(floor level
)))))))
3814 (sit-for duration
))))
3817 ;; Generate a unique new group name.
3818 (defun gnus-generate-new-group-name (leaf)
3821 (while (gnus-gethash name gnus-newsrc-hashtb
)
3822 (setq name
(concat leaf
"<" (int-to-string (setq num
(1+ num
))) ">")))
3825 (defsubst gnus-hide-text
(b e props
)
3826 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3827 (gnus-add-text-properties b e props
)
3828 (when (memq 'intangible props
)
3829 (gnus-put-text-property (max (1- b
) (point-min))
3830 b
'intangible
(cddr (memq 'intangible props
)))))
3832 (defsubst gnus-unhide-text
(b e
)
3833 "Remove hidden text properties from region between B and E."
3834 (remove-text-properties b e gnus-hidden-properties
)
3835 (when (memq 'intangible gnus-hidden-properties
)
3836 (gnus-put-text-property (max (1- b
) (point-min))
3837 b
'intangible nil
)))
3839 (defun gnus-hide-text-type (b e type
)
3840 "Hide text of TYPE between B and E."
3841 (gnus-hide-text b e
(cons 'gnus-type
(cons type gnus-hidden-properties
))))
3843 (defun gnus-parent-headers (headers &optional generation
)
3844 "Return the headers of the GENERATIONeth parent of HEADERS."
3846 (setq generation
1))
3847 (let (references parent
)
3848 (while (and headers
(not (zerop generation
)))
3849 (setq references
(mail-header-references headers
))
3850 (when (and references
3851 (setq parent
(gnus-parent-id references
))
3852 (setq headers
(car (gnus-id-to-thread parent
))))
3856 (defun gnus-parent-id (references)
3857 "Return the last Message-ID in REFERENCES."
3858 (when (and references
3859 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references
))
3860 (substring references
(match-beginning 1) (match-end 1))))
3862 (defun gnus-split-references (references)
3863 "Return a list of Message-IDs in REFERENCES."
3866 (while (string-match "<[^>]+>" references beg
)
3867 (push (substring references
(match-beginning 0) (setq beg
(match-end 0)))
3871 (defun gnus-buffer-live-p (buffer)
3872 "Say whether BUFFER is alive or not."
3875 (buffer-name (get-buffer buffer
))))
3877 (defun gnus-ephemeral-group-p (group)
3878 "Say whether GROUP is ephemeral or not."
3879 (gnus-group-get-parameter group
'quit-config
))
3881 (defun gnus-group-quit-config (group)
3882 "Return the quit-config of GROUP."
3883 (gnus-group-get-parameter group
'quit-config
))
3885 (defun gnus-simplify-mode-line ()
3886 "Make mode lines a bit simpler."
3887 (setq mode-line-modified
"-- ")
3888 (when (listp mode-line-format
)
3889 (make-local-variable 'mode-line-format
)
3890 (setq mode-line-format
(copy-sequence mode-line-format
))
3891 (when (equal (nth 3 mode-line-format
) " ")
3892 (setcar (nthcdr 3 mode-line-format
) " "))))
3894 ;;; List and range functions
3896 (defun gnus-last-element (list)
3897 "Return last element of LIST."
3899 (setq list
(cdr list
)))
3902 (defun gnus-copy-sequence (list)
3903 "Do a complete, total copy of a list."
3904 (if (and (consp list
) (not (consp (cdr list
))))
3905 (cons (car list
) (cdr list
))
3906 (mapcar (lambda (elem) (if (consp elem
)
3907 (if (consp (cdr elem
))
3908 (gnus-copy-sequence elem
)
3909 (cons (car elem
) (cdr elem
)))
3913 (defun gnus-set-difference (list1 list2
)
3914 "Return a list of elements of LIST1 that do not appear in LIST2."
3915 (let ((list1 (copy-sequence list1
)))
3917 (setq list1
(delq (car list2
) list1
))
3918 (setq list2
(cdr list2
)))
3921 (defun gnus-sorted-complement (list1 list2
)
3922 "Return a list of elements of LIST1 that do not appear in LIST2.
3923 Both lists have to be sorted over <."
3925 (if (or (null list1
) (null list2
))
3927 (while (and list1 list2
)
3928 (cond ((= (car list1
) (car list2
))
3929 (setq list1
(cdr list1
)
3931 ((< (car list1
) (car list2
))
3932 (setq out
(cons (car list1
) out
))
3933 (setq list1
(cdr list1
)))
3935 (setq out
(cons (car list2
) out
))
3936 (setq list2
(cdr list2
)))))
3937 (nconc (nreverse out
) (or list1 list2
)))))
3939 (defun gnus-intersection (list1 list2
)
3942 (if (memq (car list2
) list1
)
3943 (setq result
(cons (car list2
) result
)))
3944 (setq list2
(cdr list2
)))
3947 (defun gnus-sorted-intersection (list1 list2
)
3948 ;; LIST1 and LIST2 have to be sorted over <.
3950 (while (and list1 list2
)
3951 (cond ((= (car list1
) (car list2
))
3952 (setq out
(cons (car list1
) out
)
3955 ((< (car list1
) (car list2
))
3956 (setq list1
(cdr list1
)))
3958 (setq list2
(cdr list2
)))))
3961 (defun gnus-set-sorted-intersection (list1 list2
)
3962 ;; LIST1 and LIST2 have to be sorted over <.
3963 ;; This function modifies LIST1.
3964 (let* ((top (cons nil list1
))
3966 (while (and list1 list2
)
3967 (cond ((= (car list1
) (car list2
))
3971 ((< (car list1
) (car list2
))
3972 (setcdr prev
(cdr list1
))
3973 (setq list1
(cdr list1
)))
3975 (setq list2
(cdr list2
)))))
3979 (defun gnus-compress-sequence (numbers &optional always-list
)
3980 "Convert list of numbers to a list of ranges or a single range.
3981 If ALWAYS-LIST is non-nil, this function will always release a list of
3983 (let* ((first (car numbers
))
3984 (last (car numbers
))
3988 (if (not (listp (cdr numbers
)))
3991 (cond ((= last
(car numbers
)) nil
) ;Omit duplicated number
3992 ((= (1+ last
) (car numbers
)) ;Still in sequence
3993 (setq last
(car numbers
)))
3994 (t ;End of one sequence
3996 (cons (if (= first last
) first
3997 (cons first last
)) result
))
3998 (setq first
(car numbers
))
3999 (setq last
(car numbers
))))
4000 (setq numbers
(cdr numbers
)))
4001 (if (and (not always-list
) (null result
))
4002 (if (= first last
) (list first
) (cons first last
))
4003 (nreverse (cons (if (= first last
) first
(cons first last
))
4006 (defalias 'gnus-uncompress-sequence
'gnus-uncompress-range
)
4007 (defun gnus-uncompress-range (ranges)
4008 "Expand a list of ranges into a list of numbers.
4009 RANGES is either a single range on the form `(num . num)' or a list of
4011 (let (first last result
)
4015 ((not (listp (cdr ranges
)))
4016 (setq first
(car ranges
))
4017 (setq last
(cdr ranges
))
4018 (while (<= first last
)
4019 (setq result
(cons first result
))
4020 (setq first
(1+ first
)))
4024 (if (atom (car ranges
))
4025 (if (numberp (car ranges
))
4026 (setq result
(cons (car ranges
) result
)))
4027 (setq first
(caar ranges
))
4028 (setq last
(cdar ranges
))
4029 (while (<= first last
)
4030 (setq result
(cons first result
))
4031 (setq first
(1+ first
))))
4032 (setq ranges
(cdr ranges
)))
4033 (nreverse result
)))))
4035 (defun gnus-add-to-range (ranges list
)
4036 "Return a list of ranges that has all articles from both RANGES and LIST.
4037 Note: LIST has to be sorted over `<'."
4039 (gnus-compress-sequence list t
)
4040 (setq list
(copy-sequence list
))
4041 (or (listp (cdr ranges
))
4042 (setq ranges
(list ranges
)))
4044 ilist lowest highest temp
)
4045 (while (and ranges list
)
4047 (setq lowest
(or (and (atom (car ranges
)) (car ranges
))
4049 (while (and list
(cdr list
) (< (cadr list
) lowest
))
4050 (setq list
(cdr list
)))
4051 (if (< (car ilist
) lowest
)
4054 (setq list
(cdr list
))
4056 (setq out
(nconc (gnus-compress-sequence ilist t
) out
))))
4057 (setq highest
(or (and (atom (car ranges
)) (car ranges
))
4059 (while (and list
(<= (car list
) highest
))
4060 (setq list
(cdr list
)))
4061 (setq ranges
(cdr ranges
)))
4063 (setq out
(nconc (gnus-compress-sequence list t
) out
)))
4064 (setq out
(sort out
(lambda (r1 r2
)
4065 (< (or (and (atom r1
) r1
) (car r1
))
4066 (or (and (atom r2
) r2
) (car r2
))))))
4069 (if (atom (car ranges
))
4071 (if (atom (cadr ranges
))
4072 (if (= (1+ (car ranges
)) (cadr ranges
))
4074 (setcar ranges
(cons (car ranges
)
4076 (setcdr ranges
(cddr ranges
))))
4077 (if (= (1+ (car ranges
)) (caadr ranges
))
4079 (setcar (cadr ranges
) (car ranges
))
4080 (setcar ranges
(cadr ranges
))
4081 (setcdr ranges
(cddr ranges
))))))
4083 (if (atom (cadr ranges
))
4084 (if (= (1+ (cdar ranges
)) (cadr ranges
))
4086 (setcdr (car ranges
) (cadr ranges
))
4087 (setcdr ranges
(cddr ranges
))))
4088 (if (= (1+ (cdar ranges
)) (caadr ranges
))
4090 (setcdr (car ranges
) (cdadr ranges
))
4091 (setcdr ranges
(cddr ranges
)))))))
4092 (setq ranges
(cdr ranges
)))
4095 (defun gnus-remove-from-range (ranges list
)
4096 "Return a list of ranges that has all articles from LIST removed from RANGES.
4097 Note: LIST has to be sorted over `<'."
4098 ;; !!! This function shouldn't look like this, but I've got a headache.
4099 (gnus-compress-sequence
4100 (gnus-sorted-complement
4101 (gnus-uncompress-range ranges
) list
)))
4103 (defun gnus-member-of-range (number ranges
)
4104 (if (not (listp (cdr ranges
)))
4105 (and (>= number
(car ranges
))
4106 (<= number
(cdr ranges
)))
4109 (if (numberp (car ranges
))
4110 (>= number
(car ranges
))
4111 (>= number
(caar ranges
)))
4113 (if (if (numberp (car ranges
))
4114 (= number
(car ranges
))
4115 (and (>= number
(caar ranges
))
4116 (<= number
(cdar ranges
))))
4117 (setq not-stop nil
))
4118 (setq ranges
(cdr ranges
)))
4121 (defun gnus-range-length (range)
4122 "Return the length RANGE would have if uncompressed."
4123 (length (gnus-uncompress-range range
)))
4125 (defun gnus-sublist-p (list sublist
)
4126 "Test whether all elements in SUBLIST are members of LIST."
4129 (unless (memq (pop sublist
) list
)
4139 (defvar gnus-group-mode-map nil
)
4140 (put 'gnus-group-mode
'mode-class
'special
)
4142 (unless gnus-group-mode-map
4143 (setq gnus-group-mode-map
(make-keymap))
4144 (suppress-keymap gnus-group-mode-map
)
4146 (gnus-define-keys gnus-group-mode-map
4147 " " gnus-group-read-group
4148 "=" gnus-group-select-group
4149 "\r" gnus-group-select-group
4150 "\M-\r" gnus-group-quick-select-group
4151 "j" gnus-group-jump-to-group
4152 "n" gnus-group-next-unread-group
4153 "p" gnus-group-prev-unread-group
4154 "\177" gnus-group-prev-unread-group
4155 [delete] gnus-group-prev-unread-group
4156 "N" gnus-group-next-group
4157 "P" gnus-group-prev-group
4158 "\M-n" gnus-group-next-unread-group-same-level
4159 "\M-p" gnus-group-prev-unread-group-same-level
4160 "," gnus-group-best-unread-group
4161 "." gnus-group-first-unread-group
4162 "u" gnus-group-unsubscribe-current-group
4163 "U" gnus-group-unsubscribe-group
4164 "c" gnus-group-catchup-current
4165 "C" gnus-group-catchup-current-all
4166 "l" gnus-group-list-groups
4167 "L" gnus-group-list-all-groups
4169 "g" gnus-group-get-new-news
4170 "\M-g" gnus-group-get-new-news-this-group
4171 "R" gnus-group-restart
4172 "r" gnus-group-read-init-file
4173 "B" gnus-group-browse-foreign-server
4174 "b" gnus-group-check-bogus-groups
4175 "F" gnus-find-new-newsgroups
4176 "\C-c\C-d" gnus-group-describe-group
4177 "\M-d" gnus-group-describe-all-groups
4178 "\C-c\C-a" gnus-group-apropos
4179 "\C-c\M-\C-a" gnus-group-description-apropos
4180 "a" gnus-group-post-news
4181 "\ek" gnus-group-edit-local-kill
4182 "\eK" gnus-group-edit-global-kill
4183 "\C-k" gnus-group-kill-group
4184 "\C-y" gnus-group-yank-group
4185 "\C-w" gnus-group-kill-region
4186 "\C-x\C-t" gnus-group-transpose-groups
4187 "\C-c\C-l" gnus-group-list-killed
4188 "\C-c\C-x" gnus-group-expire-articles
4189 "\C-c\M-\C-x" gnus-group-expire-all-groups
4191 "s" gnus-group-save-newsrc
4192 "z" gnus-group-suspend
4193 ; "Z" gnus-group-clear-dribble
4196 "?" gnus-group-describe-briefly
4197 "\C-c\C-i" gnus-info-find-node
4198 "\M-e" gnus-group-edit-group-method
4199 "^" gnus-group-enter-server-mode
4200 gnus-mouse-2 gnus-mouse-pick-group
4201 "<" beginning-of-buffer
4204 "\C-c\C-s" gnus-group-sort-groups
4206 "\C-c\M-g" gnus-activate-all-groups
4207 "\M-&" gnus-group-universal-argument
4208 "#" gnus-group-mark-group
4209 "\M-#" gnus-group-unmark-group)
4211 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4212 "m" gnus-group-mark-group
4213 "u" gnus-group-unmark-group
4214 "w" gnus-group-mark-region
4215 "m" gnus-group-mark-buffer
4216 "r" gnus-group-mark-regexp
4217 "U" gnus-group-unmark-all-groups)
4219 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4220 "d" gnus-group-make-directory-group
4221 "h" gnus-group-make-help-group
4222 "a" gnus-group-make-archive-group
4223 "k" gnus-group-make-kiboze-group
4224 "m" gnus-group-make-group
4225 "E" gnus-group-edit-group
4226 "e" gnus-group-edit-group-method
4227 "p" gnus-group-edit-group-parameters
4228 "v" gnus-group-add-to-virtual
4229 "V" gnus-group-make-empty-virtual
4230 "D" gnus-group-enter-directory
4231 "f" gnus-group-make-doc-group
4232 "r" gnus-group-rename-group
4233 "\177" gnus-group-delete-group
4234 [delete] gnus-group-delete-group
)
4236 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map
)
4237 "b" gnus-group-brew-soup
4238 "w" gnus-soup-save-areas
4239 "s" gnus-soup-send-replies
4240 "p" gnus-soup-pack-packet
4241 "r" nnsoup-pack-replies
)
4243 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map
)
4244 "s" gnus-group-sort-groups
4245 "a" gnus-group-sort-groups-by-alphabet
4246 "u" gnus-group-sort-groups-by-unread
4247 "l" gnus-group-sort-groups-by-level
4248 "v" gnus-group-sort-groups-by-score
4249 "r" gnus-group-sort-groups-by-rank
4250 "m" gnus-group-sort-groups-by-method
)
4252 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map
)
4253 "k" gnus-group-list-killed
4254 "z" gnus-group-list-zombies
4255 "s" gnus-group-list-groups
4256 "u" gnus-group-list-all-groups
4257 "A" gnus-group-list-active
4258 "a" gnus-group-apropos
4259 "d" gnus-group-description-apropos
4260 "m" gnus-group-list-matching
4261 "M" gnus-group-list-all-matching
4262 "l" gnus-group-list-level
)
4264 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map
)
4265 "f" gnus-score-flush-cache
)
4267 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map
)
4268 "f" gnus-group-fetch-faq
)
4270 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map
)
4271 "l" gnus-group-set-current-level
4272 "t" gnus-group-unsubscribe-current-group
4273 "s" gnus-group-unsubscribe-group
4274 "k" gnus-group-kill-group
4275 "y" gnus-group-yank-group
4276 "w" gnus-group-kill-region
4277 "\C-k" gnus-group-kill-level
4278 "z" gnus-group-kill-all-zombies
))
4280 (defun gnus-group-mode ()
4281 "Major mode for reading news.
4283 All normal editing commands are switched off.
4284 \\<gnus-group-mode-map>
4285 The group buffer lists (some of) the groups available. For instance,
4286 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4287 lists all zombie groups.
4289 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4290 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4292 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4294 The following commands are available:
4296 \\{gnus-group-mode-map}"
4298 (when (and menu-bar-mode
4299 (gnus-visual-p 'group-menu
'menu
))
4300 (gnus-group-make-menu-bar))
4301 (kill-all-local-variables)
4302 (gnus-simplify-mode-line)
4303 (setq major-mode
'gnus-group-mode
)
4304 (setq mode-name
"Group")
4305 (gnus-group-set-mode-line)
4306 (setq mode-line-process nil
)
4307 (use-local-map gnus-group-mode-map
)
4308 (buffer-disable-undo (current-buffer))
4309 (setq truncate-lines t
)
4310 (setq buffer-read-only t
)
4311 (gnus-make-local-hook 'post-command-hook
)
4312 (gnus-add-hook 'post-command-hook
'gnus-clear-inboxes-moved nil t
)
4313 (run-hooks 'gnus-group-mode-hook
))
4315 (defun gnus-clear-inboxes-moved ()
4316 (setq nnmail-moved-inboxes nil
))
4318 (defun gnus-mouse-pick-group (e)
4319 "Enter the group under the mouse pointer."
4322 (gnus-group-read-group nil
))
4324 ;; Look at LEVEL and find out what the level is really supposed to be.
4325 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4326 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4327 (defun gnus-group-default-level (&optional level number-or-nil
)
4329 (gnus-group-use-permanent-levels
4330 (or (setq gnus-group-use-permanent-levels
4331 (or level
(if (numberp gnus-group-use-permanent-levels
)
4332 gnus-group-use-permanent-levels
4333 (or gnus-group-default-list-level
4334 gnus-level-subscribed
))))
4335 gnus-group-default-list-level gnus-level-subscribed
))
4339 (or level gnus-group-default-list-level gnus-level-subscribed
))))
4342 (defun gnus-slave-no-server (&optional arg
)
4343 "Read network news as a slave, without connecting to local server"
4345 (gnus-no-server arg t
))
4348 (defun gnus-no-server (&optional arg slave
)
4350 If ARG is a positive number, Gnus will use that as the
4351 startup level. If ARG is nil, Gnus will be started at level 2.
4352 If ARG is non-nil and not a positive number, Gnus will
4353 prompt the user for the name of an NNTP server to use.
4354 As opposed to `gnus', this command will not connect to the local server."
4356 (let ((val (or arg
(1- gnus-level-default-subscribed
))))
4358 (make-local-variable 'gnus-group-use-permanent-levels
)
4359 (setq gnus-group-use-permanent-levels val
)))
4362 (defun gnus-slave (&optional arg
)
4363 "Read news as a slave."
4365 (gnus arg nil
'slave
))
4368 (defun gnus-other-frame (&optional arg
)
4369 "Pop up a frame to read news."
4371 (if (get-buffer gnus-group-buffer
)
4372 (let ((pop-up-frames t
))
4374 (select-frame (make-frame))
4378 (defun gnus (&optional arg dont-connect slave
)
4380 If ARG is non-nil and a positive number, Gnus will use that as the
4381 startup level. If ARG is non-nil and not a positive number, Gnus will
4382 prompt the user for the name of an NNTP server to use."
4385 (if (get-buffer gnus-group-buffer
)
4387 (switch-to-buffer gnus-group-buffer
)
4388 (gnus-group-get-new-news))
4391 (nnheader-init-server-buffer)
4392 (gnus-read-init-file)
4393 (setq gnus-slave slave
)
4395 (gnus-group-setup-buffer)
4396 (let ((buffer-read-only nil
))
4398 (if (not gnus-inhibit-startup-message
)
4400 (gnus-group-startup-message)
4403 (let ((level (and (numberp arg
) (> arg
0) arg
))
4409 (gnus-start-news-server (and arg
(not level
))))))
4410 (if (and (not dont-connect
)
4413 (run-hooks 'gnus-startup-hook
)
4414 ;; NNTP server is successfully open.
4416 ;; Find the current startup file name.
4417 (setq gnus-current-startup-file
4418 (gnus-make-newsrc-file gnus-startup-file
))
4420 ;; Read the dribble file.
4421 (when (or gnus-slave gnus-use-dribble-file
)
4422 (gnus-dribble-read-file))
4424 ;; Allow using GroupLens predictions.
4425 (when gnus-use-grouplens
4427 (add-hook 'gnus-summary-mode-hook
'gnus-grouplens-mode
))
4429 (gnus-summary-make-display-table)
4430 ;; Do the actual startup.
4431 (gnus-setup-news nil level dont-connect
)
4432 ;; Generate the group buffer.
4433 (gnus-group-list-groups level
)
4434 (gnus-group-first-unread-group)
4435 (gnus-configure-windows 'group
)
4436 (gnus-group-set-mode-line))))))
4438 (defun gnus-unload ()
4439 "Unload all Gnus features."
4441 (or (boundp 'load-history
)
4442 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4443 (let ((history load-history
)
4446 (and (string-match "^\\(gnus\\|nn\\)" (caar history
))
4447 (setq feature
(cdr (assq 'provide
(car history
))))
4448 (unload-feature feature
'force
))
4449 (setq history
(cdr history
)))))
4451 (defun gnus-compile ()
4452 "Byte-compile the user-defined format specs."
4454 (let ((entries gnus-format-specs
)
4455 entry gnus-tmp-func
)
4457 (gnus-message 7 "Compiling format specs...")
4460 (setq entry
(pop entries
))
4461 (if (eq (car entry
) 'version
)
4462 (setq gnus-format-specs
(delq entry gnus-format-specs
))
4463 (when (and (listp (caddr entry
))
4464 (not (eq 'byte-code
(caaddr entry
))))
4465 (fset 'gnus-tmp-func
4466 `(lambda () ,(caddr entry
)))
4467 (byte-compile 'gnus-tmp-func
)
4468 (setcar (cddr entry
) (gnus-byte-code 'gnus-tmp-func
)))))
4470 (push (cons 'version emacs-version
) gnus-format-specs
)
4472 (gnus-message 7 "Compiling user specs...done"))))
4474 (defun gnus-indent-rigidly (start end arg
)
4475 "Indent rigidly using only spaces and no tabs."
4478 (narrow-to-region start end
)
4479 (indent-rigidly start end arg
)
4480 (goto-char (point-min))
4481 (while (search-forward "\t" nil t
)
4482 (replace-match " " t t
)))))
4484 (defun gnus-group-startup-message (&optional x y
)
4485 "Insert startup message in current buffer."
4486 ;; Insert the message.
4491 _ ___ __ ___ __ _ ___
4510 ;; And then hack it.
4511 (gnus-indent-rigidly (point-min) (point-max)
4512 (/ (max (- (window-width) (or x
46)) 0) 2))
4513 (goto-char (point-min))
4515 (let* ((pheight (count-lines (point-min) (point-max)))
4516 (wheight (window-height))
4517 (rest (- wheight pheight
)))
4518 (insert (make-string (max 0 (* 2 (/ rest
3))) ?
\n)))
4520 (goto-char (point-min))
4521 (and (search-forward "Praxis" nil t
)
4522 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face
'bold
))
4523 (goto-char (point-min))
4524 (let* ((mode-string (gnus-group-set-mode-line)))
4525 (setq mode-line-buffer-identification
4526 (list (concat gnus-version
(substring (car mode-string
) 4))))
4527 (set-buffer-modified-p t
)))
4529 (defun gnus-group-setup-buffer ()
4530 (or (get-buffer gnus-group-buffer
)
4532 (switch-to-buffer gnus-group-buffer
)
4533 (gnus-add-current-to-buffer-list)
4535 (and gnus-carpal
(gnus-carpal-setup-buffer 'group
)))))
4537 (defun gnus-group-list-groups (&optional level unread lowest
)
4538 "List newsgroups with level LEVEL or lower that have unread articles.
4539 Default is all subscribed groups.
4540 If argument UNREAD is non-nil, groups with no unread articles are also
4542 (interactive (list (if current-prefix-arg
4543 (prefix-numeric-value current-prefix-arg
)
4545 (gnus-group-default-level nil t
)
4546 gnus-group-default-list-level
4547 gnus-level-subscribed
))))
4549 (setq level
(car gnus-group-list-mode
)
4550 unread
(cdr gnus-group-list-mode
)))
4551 (setq level
(gnus-group-default-level level
))
4552 (gnus-group-setup-buffer) ;May call from out of group buffer
4553 (gnus-update-format-specifications)
4554 (let ((case-fold-search nil
)
4555 (props (text-properties-at (gnus-point-at-bol)))
4556 (group (gnus-group-group-name)))
4557 (set-buffer gnus-group-buffer
)
4558 (funcall gnus-group-prepare-function level unread lowest
)
4559 (if (zerop (buffer-size))
4560 (gnus-message 5 gnus-no-groups-message
)
4561 (goto-char (point-max))
4562 (when (or (not gnus-group-goto-next-group-function
)
4563 (not (funcall gnus-group-goto-next-group-function
4566 ;; Go to the first group with unread articles.
4567 (gnus-group-search-forward t
)
4568 ;; Find the right group to put point on. If the current group
4569 ;; has disappeared in the new listing, try to find the next
4570 ;; one. If no next one can be found, just leave point at the
4571 ;; first newsgroup in the buffer.
4572 (if (not (gnus-goto-char
4574 (point-min) (point-max)
4575 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
))))
4576 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb
))))
4578 (not (gnus-goto-char
4580 (point-min) (point-max) 'gnus-group
4582 (caar newsrc
) gnus-active-hashtb
)))))
4583 (setq newsrc
(cdr newsrc
)))
4584 (or newsrc
(progn (goto-char (point-max))
4585 (forward-line -
1)))))))
4586 ;; Adjust cursor point.
4587 (gnus-group-position-point))))
4589 (defun gnus-group-list-level (level &optional all
)
4590 "List groups on LEVEL.
4591 If ALL (the prefix), also list groups that have no unread articles."
4592 (interactive "nList groups on level: \nP")
4593 (gnus-group-list-groups level all level
))
4595 (defun gnus-group-prepare-flat (level &optional all lowest regexp
)
4596 "List all newsgroups with unread articles of level LEVEL or lower.
4597 If ALL is non-nil, list groups that have no unread articles.
4598 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4599 If REGEXP, only list groups matching REGEXP."
4600 (set-buffer gnus-group-buffer
)
4601 (let ((buffer-read-only nil
)
4602 (newsrc (cdr gnus-newsrc-alist
))
4603 (lowest (or lowest
1))
4604 info clevel unread group params
)
4606 (if (< lowest gnus-level-zombie
)
4607 ;; List living groups.
4609 (setq info
(car newsrc
)
4610 group
(gnus-info-group info
)
4611 params
(gnus-info-params info
)
4613 unread
(car (gnus-gethash group gnus-newsrc-hashtb
)))
4614 (and unread
; This group might be bogus
4616 (string-match regexp group
))
4617 (<= (setq clevel
(gnus-info-level info
)) level
)
4619 (or all
; We list all groups?
4620 (if (eq unread t
) ; Unactivated?
4621 gnus-group-list-inactive-groups
; We list unactivated
4622 (> unread
0)) ; We list groups with unread articles
4623 (and gnus-list-groups-with-ticked-articles
4624 (cdr (assq 'tick
(gnus-info-marks info
))))
4625 ; And groups with tickeds
4626 ;; Check for permanent visibility.
4627 (and gnus-permanently-visible-groups
4628 (string-match gnus-permanently-visible-groups
4630 (memq 'visible params
)
4631 (cdr (assq 'visible params
)))
4632 (gnus-group-insert-group-line
4633 group
(gnus-info-level info
)
4634 (gnus-info-marks info
) unread
(gnus-info-method info
)))))
4636 ;; List dead groups.
4637 (and (>= level gnus-level-zombie
) (<= lowest gnus-level-zombie
)
4638 (gnus-group-prepare-flat-list-dead
4639 (setq gnus-zombie-list
(sort gnus-zombie-list
'string
<))
4640 gnus-level-zombie ?Z
4642 (and (>= level gnus-level-killed
) (<= lowest gnus-level-killed
)
4643 (gnus-group-prepare-flat-list-dead
4644 (setq gnus-killed-list
(sort gnus-killed-list
'string
<))
4645 gnus-level-killed ?K regexp
))
4647 (gnus-group-set-mode-line)
4648 (setq gnus-group-list-mode
(cons level all
))
4649 (run-hooks 'gnus-group-prepare-hook
)))
4651 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp
)
4652 ;; List zombies and killed lists somewhat faster, which was
4653 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4654 ;; this by ignoring the group format specification altogether.
4657 ;; This loop is used when listing groups that match some
4660 (setq group
(pop groups
))
4661 (when (string-match regexp group
)
4662 (gnus-add-text-properties
4663 (point) (prog1 (1+ (point))
4664 (insert " " mark
" *: " group
"\n"))
4665 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
4667 'gnus-level level
))))
4668 ;; This loop is used when listing all groups.
4670 (gnus-add-text-properties
4671 (point) (prog1 (1+ (point))
4672 (insert " " mark
" *: "
4673 (setq group
(pop groups
)) "\n"))
4674 (list 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)
4676 'gnus-level level
))))))
4678 (defmacro gnus-group-real-name
(group)
4679 "Find the real name of a foreign newsgroup."
4680 `(let ((gname ,group
))
4681 (if (string-match ":[^:]+$" gname
)
4682 (substring gname
(1+ (match-beginning 0)))
4685 (defsubst gnus-server-add-address
(method)
4686 (let ((method-name (symbol-name (car method
))))
4687 (if (and (memq 'address
(assoc method-name gnus-valid-select-methods
))
4688 (not (assq (intern (concat method-name
"-address")) method
)))
4689 (append method
(list (list (intern (concat method-name
"-address"))
4693 (defsubst gnus-server-get-method
(group method
)
4694 ;; Input either a server name, and extended server name, or a
4695 ;; select method, and return a select method.
4696 (cond ((stringp method
)
4697 (gnus-server-to-method method
))
4698 ((equal method gnus-select-method
)
4700 ((and (stringp (car method
)) group
)
4701 (gnus-server-extend-method group method
))
4702 ((and method
(not group
)
4703 (equal (cadr method
) ""))
4706 (gnus-server-add-address method
))))
4708 (defun gnus-server-to-method (server)
4709 "Map virtual server names to select methods."
4711 ;; Is this a method, perhaps?
4712 (and server
(listp server
) server
)
4713 ;; Perhaps this is the native server?
4714 (and (equal server
"native") gnus-select-method
)
4715 ;; It should be in the server alist.
4716 (cdr (assoc server gnus-server-alist
))
4717 ;; If not, we look through all the opened server
4718 ;; to see whether we can find it there.
4719 (let ((opened gnus-opened-servers
))
4721 (not (equal server
(format "%s:%s" (caaar opened
)
4726 (defmacro gnus-method-equal
(ss1 ss2
)
4727 "Say whether two servers are equal."
4731 (and (= (length s1
) (length s2
))
4733 (while (and s1
(member (car s1
) s2
))
4737 (defun gnus-server-equal (m1 m2
)
4738 "Say whether two methods are equal."
4739 (let ((m1 (cond ((null m1
) gnus-select-method
)
4740 ((stringp m1
) (gnus-server-to-method m1
))
4742 (m2 (cond ((null m2
) gnus-select-method
)
4743 ((stringp m2
) (gnus-server-to-method m2
))
4745 (gnus-method-equal m1 m2
)))
4747 (defun gnus-servers-using-backend (backend)
4748 "Return a list of known servers using BACKEND."
4749 (let ((opened gnus-opened-servers
)
4752 (when (eq backend
(caaar opened
))
4753 (push (caar opened
) out
))
4757 (defun gnus-group-prefixed-name (group method
)
4758 "Return the whole name from GROUP and METHOD."
4759 (and (stringp method
) (setq method
(gnus-server-to-method method
)))
4760 (concat (format "%s" (car method
))
4762 (or (assoc (format "%s" (car method
))
4763 (gnus-methods-using 'address
))
4764 (gnus-server-equal method gnus-message-archive-method
))
4766 (not (string= (nth 1 method
) "")))
4767 (concat "+" (nth 1 method
)))
4770 (defun gnus-group-real-prefix (group)
4771 "Return the prefix of the current group name."
4772 (if (string-match "^[^:]+:" group
)
4773 (substring group
0 (match-end 0))
4776 (defun gnus-group-method (group)
4777 "Return the server or method used for selecting GROUP."
4778 (let ((prefix (gnus-group-real-prefix group
)))
4779 (if (equal prefix
"")
4781 (let ((servers gnus-opened-servers
)
4783 backend possible found
)
4784 (if (string-match "^[^\\+]+\\+" prefix
)
4785 (setq backend
(intern (substring prefix
0 (1- (match-end 0))))
4786 server
(substring prefix
(match-end 0) (1- (length prefix
))))
4787 (setq backend
(intern (substring prefix
0 (1- (length prefix
))))))
4789 (when (eq (caaar servers
) backend
)
4790 (setq possible
(caar servers
))
4791 (when (equal (cadaar servers
) server
)
4792 (setq found
(caar servers
))))
4794 (or (car (rassoc found gnus-server-alist
))
4796 (car (rassoc possible gnus-server-alist
))
4798 (list backend server
))))))
4800 (defsubst gnus-secondary-method-p
(method)
4801 "Return whether METHOD is a secondary select method."
4802 (let ((methods gnus-secondary-select-methods
)
4803 (gmethod (gnus-server-get-method nil method
)))
4805 (not (equal (gnus-server-get-method nil
(car methods
))
4807 (setq methods
(cdr methods
)))
4810 (defun gnus-group-foreign-p (group)
4811 "Say whether a group is foreign or not."
4812 (and (not (gnus-group-native-p group
))
4813 (not (gnus-group-secondary-p group
))))
4815 (defun gnus-group-native-p (group)
4816 "Say whether the group is native or not."
4817 (not (string-match ":" group
)))
4819 (defun gnus-group-secondary-p (group)
4820 "Say whether the group is secondary or not."
4821 (gnus-secondary-method-p (gnus-find-method-for-group group
)))
4823 (defun gnus-group-get-parameter (group &optional symbol
)
4824 "Returns the group parameters for GROUP.
4825 If SYMBOL, return the value of that symbol in the group parameters."
4826 (let ((params (gnus-info-params (gnus-get-info group
))))
4828 (gnus-group-parameter-value params symbol
)
4831 (defun gnus-group-parameter-value (params symbol
)
4832 "Return the value of SYMBOL in group PARAMS."
4833 (or (car (memq symbol params
)) ; It's either a simple symbol
4834 (cdr (assq symbol params
)))) ; or a cons.
4836 (defun gnus-group-add-parameter (group param
)
4837 "Add parameter PARAM to GROUP."
4838 (let ((info (gnus-get-info group
)))
4840 () ; This is a dead group. We just ignore it.
4841 ;; Cons the new param to the old one and update.
4842 (gnus-group-set-info (cons param
(gnus-info-params info
))
4845 (defun gnus-group-set-parameter (group name value
)
4846 "Set parameter NAME to VALUE in GROUP."
4847 (let ((info (gnus-get-info group
)))
4849 () ; This is a dead group. We just ignore it.
4850 (let ((old-params (gnus-info-params info
))
4851 (new-params (list (cons name value
))))
4853 (if (or (not (listp (car old-params
)))
4854 (not (eq (caar old-params
) name
)))
4855 (setq new-params
(append new-params
(list (car old-params
)))))
4856 (setq old-params
(cdr old-params
)))
4857 (gnus-group-set-info new-params group
'params
)))))
4859 (defun gnus-group-add-score (group &optional score
)
4860 "Add SCORE to the GROUP score.
4861 If SCORE is nil, add 1 to the score of GROUP."
4862 (let ((info (gnus-get-info group
)))
4864 (gnus-info-set-score info
(+ (gnus-info-score info
) (or score
1))))))
4866 (defun gnus-summary-bubble-group ()
4867 "Increase the score of the current group.
4868 This is a handy function to add to `gnus-summary-exit-hook' to
4869 increase the score of each group you read."
4870 (gnus-group-add-score gnus-newsgroup-name
))
4872 (defun gnus-group-set-info (info &optional method-only-group part
)
4873 (let* ((entry (gnus-gethash
4874 (or method-only-group
(gnus-info-group info
))
4875 gnus-newsrc-hashtb
))
4877 (info (if method-only-group
(nth 2 entry
) info
))
4879 (when method-only-group
4881 (error "Trying to change non-existent group %s" method-only-group
))
4882 ;; We have received parts of the actual group info - either the
4883 ;; select method or the group parameters. We first check
4884 ;; whether we have to extend the info, and if so, do that.
4885 (let ((len (length info
))
4886 (total (if (eq part
'method
) 5 6)))
4888 (setcdr (nthcdr (1- len
) info
)
4889 (make-list (- total len
) nil
)))
4890 ;; Then we enter the new info.
4891 (setcar (nthcdr (1- total
) info
) part-info
)))
4893 ;; This is a new group, so we just create it.
4895 (set-buffer gnus-group-buffer
)
4896 (setq method
(gnus-info-method info
))
4897 (when (gnus-server-equal method
"native")
4900 (set-buffer gnus-group-buffer
)
4902 ;; It's a foreign group...
4903 (gnus-group-make-group
4904 (gnus-group-real-name (gnus-info-group info
))
4905 (if (stringp method
) method
4906 (prin1-to-string (car method
)))
4908 (nth 1 (gnus-info-method info
))))
4909 ;; It's a native group.
4910 (gnus-group-make-group (gnus-info-group info
))))
4911 (gnus-message 6 "Note: New group created")
4913 (gnus-gethash (gnus-group-prefixed-name
4914 (gnus-group-real-name (gnus-info-group info
))
4915 (or (gnus-info-method info
) gnus-select-method
))
4916 gnus-newsrc-hashtb
))))
4917 ;; Whether it was a new group or not, we now have the entry, so we
4918 ;; can do the update.
4921 (setcar (nthcdr 2 entry
) info
)
4922 (when (and (not (eq (car entry
) t
))
4923 (gnus-active (gnus-info-group info
)))
4924 (setcar entry
(length (gnus-list-of-unread-articles (car info
))))))
4925 (error "No such group: %s" (gnus-info-group info
)))))
4927 (defun gnus-group-set-method-info (group select-method
)
4928 (gnus-group-set-info select-method group
'method
))
4930 (defun gnus-group-set-params-info (group params
)
4931 (gnus-group-set-info params group
'params
))
4933 (defun gnus-group-update-group-line ()
4934 "Update the current line in the group buffer."
4935 (let* ((buffer-read-only nil
)
4936 (group (gnus-group-group-name))
4937 (entry (and group
(gnus-gethash group gnus-newsrc-hashtb
)))
4938 gnus-group-indentation
)
4941 (not (gnus-ephemeral-group-p group
))
4943 (concat "(gnus-group-set-info '"
4944 (prin1-to-string (nth 2 entry
)) ")")))
4945 (setq gnus-group-indentation
(gnus-group-group-indentation))
4947 (gnus-group-insert-group-line-info group
)
4949 (gnus-group-position-point))))
4951 (defun gnus-group-insert-group-line-info (group)
4952 "Insert GROUP on the current line."
4953 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
))
4957 ;; (Un)subscribed group.
4958 (setq info
(nth 2 entry
))
4959 (gnus-group-insert-group-line
4960 group
(gnus-info-level info
) (gnus-info-marks info
)
4961 (or (car entry
) t
) (gnus-info-method info
)))
4962 ;; This group is dead.
4963 (gnus-group-insert-group-line
4965 (if (member group gnus-zombie-list
) gnus-level-zombie gnus-level-killed
)
4967 (if (setq active
(gnus-active group
))
4968 (- (1+ (cdr active
)) (car active
)) 0)
4971 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4972 gnus-tmp-marked number
4974 "Insert a group line in the group buffer."
4975 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group
))
4976 (gnus-tmp-number-total
4978 (1+ (- (cdr gnus-tmp-active
) (car gnus-tmp-active
)))
4980 (gnus-tmp-number-of-unread
4981 (if (numberp number
) (int-to-string (max 0 number
))
4983 (gnus-tmp-number-of-read
4984 (if (numberp number
)
4985 (int-to-string (max 0 (- gnus-tmp-number-total number
)))
4987 (gnus-tmp-subscribed
4988 (cond ((<= gnus-tmp-level gnus-level-subscribed
) ?
)
4989 ((<= gnus-tmp-level gnus-level-unsubscribed
) ?U
)
4990 ((= gnus-tmp-level gnus-level-zombie
) ?Z
)
4992 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group
))
4993 (gnus-tmp-newsgroup-description
4994 (if gnus-description-hashtb
4995 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb
) "")
4998 (if (member gnus-tmp-group gnus-moderated-list
) ?m ?
))
4999 (gnus-tmp-moderated-string
5000 (if (eq gnus-tmp-moderated ?m
) "(m)" ""))
5002 (gnus-server-get-method gnus-tmp-group gnus-tmp-method
))
5003 (gnus-tmp-news-server (or (cadr gnus-tmp-method
) ""))
5004 (gnus-tmp-news-method (or (car gnus-tmp-method
) ""))
5005 (gnus-tmp-news-method-string
5007 (format "(%s:%s)" (car gnus-tmp-method
)
5008 (cadr gnus-tmp-method
)) ""))
5009 (gnus-tmp-marked-mark
5010 (if (and (numberp number
)
5012 (cdr (assq 'tick gnus-tmp-marked
)))
5014 (gnus-tmp-process-marked
5015 (if (member gnus-tmp-group gnus-group-marked
)
5016 gnus-process-mark ?
))
5018 (or (and gnus-use-grouplens
5019 (bbb-grouplens-group-p gnus-tmp-group
))
5021 (buffer-read-only nil
)
5022 header gnus-tmp-header
) ; passed as parameter to user-funcs.
5024 (gnus-add-text-properties
5028 (eval gnus-group-line-format-spec
))
5029 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb
)
5030 gnus-unread
,(if (numberp number
)
5031 (string-to-int gnus-tmp-number-of-unread
)
5033 gnus-marked
,gnus-tmp-marked-mark
5034 gnus-indentation
,gnus-group-indentation
5035 gnus-level
,gnus-tmp-level
))
5036 (when (inline (gnus-visual-p 'group-highlight
'highlight
))
5038 (run-hooks 'gnus-group-update-hook
)
5040 ;; Allow XEmacs to remove front-sticky text properties.
5041 (gnus-group-remove-excess-properties)))
5043 (defun gnus-group-update-group (group &optional visible-only
)
5044 "Update all lines where GROUP appear.
5045 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5048 (set-buffer gnus-group-buffer
)
5049 ;; The buffer may be narrowed.
5052 (let ((ident (gnus-intern-safe group gnus-active-hashtb
))
5054 found buffer-read-only
)
5055 ;; Enter the current status into the dribble buffer.
5056 (let ((entry (gnus-gethash group gnus-newsrc-hashtb
)))
5057 (if (and entry
(not (gnus-ephemeral-group-p group
)))
5059 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry
))
5061 ;; Find all group instances. If topics are in use, each group
5062 ;; may be listed in more than once.
5063 (while (setq loc
(text-property-any
5064 loc
(point-max) 'gnus-group ident
))
5067 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5069 (gnus-group-insert-group-line-info group
)
5072 (run-hooks 'gnus-group-update-group-hook
)))
5073 (setq loc
(1+ loc
)))
5074 (unless (or found visible-only
)
5075 ;; No such line in the buffer, find out where it's supposed to
5076 ;; go, and insert it there (or at the end of the buffer).
5077 (if gnus-goto-missing-group-function
5078 (funcall gnus-goto-missing-group-function group
)
5079 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb
))))
5080 (while (and entry
(car entry
)
5084 (point-min) (point-max)
5085 'gnus-group
(gnus-intern-safe
5086 (caar entry
) gnus-active-hashtb
)))))
5087 (setq entry
(cdr entry
)))
5088 (or entry
(goto-char (point-max)))))
5089 ;; Finally insert the line.
5090 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5091 (gnus-group-insert-group-line-info group
)
5094 (run-hooks 'gnus-group-update-group-hook
))))
5095 (gnus-group-set-mode-line)))))
5097 (defun gnus-group-set-mode-line ()
5098 "Update the mode line in the group buffer."
5099 (when (memq 'group gnus-updated-mode-lines
)
5100 ;; Yes, we want to keep this mode line updated.
5102 (set-buffer gnus-group-buffer
)
5103 (let* ((gformat (or gnus-group-mode-line-format-spec
5104 (setq gnus-group-mode-line-format-spec
5106 gnus-group-mode-line-format
5107 gnus-group-mode-line-format-alist
))))
5108 (gnus-tmp-news-server (cadr gnus-select-method
))
5109 (gnus-tmp-news-method (car gnus-select-method
))
5110 (gnus-tmp-colon (if (equal gnus-tmp-news-server
"") "" ":"))
5112 gnus-tmp-header
;Dummy binding for user-defined formats
5113 ;; Get the resulting string.
5115 (and gnus-dribble-buffer
5116 (buffer-name gnus-dribble-buffer
)
5117 (buffer-modified-p gnus-dribble-buffer
)
5119 (set-buffer gnus-dribble-buffer
)
5120 (not (zerop (buffer-size))))))
5121 (mode-string (eval gformat
)))
5122 ;; Say whether the dribble buffer has been modified.
5123 (setq mode-line-modified
5124 (if modified
"---*- " "----- "))
5125 ;; If the line is too long, we chop it off.
5126 (when (> (length mode-string
) max-len
)
5127 (setq mode-string
(substring mode-string
0 (- max-len
4))))
5129 (setq mode-line-buffer-identification
5130 (gnus-mode-line-buffer-identification
5131 (list mode-string
)))
5132 (set-buffer-modified-p modified
))))))
5134 (defun gnus-group-group-name ()
5135 "Get the name of the newsgroup on the current line."
5136 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group
)))
5137 (and group
(symbol-name group
))))
5139 (defun gnus-group-group-level ()
5140 "Get the level of the newsgroup on the current line."
5141 (get-text-property (gnus-point-at-bol) 'gnus-level
))
5143 (defun gnus-group-group-indentation ()
5144 "Get the indentation of the newsgroup on the current line."
5145 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation
)
5146 (and gnus-group-indentation-function
5147 (funcall gnus-group-indentation-function
))
5150 (defun gnus-group-group-unread ()
5151 "Get the number of unread articles of the newsgroup on the current line."
5152 (get-text-property (gnus-point-at-bol) 'gnus-unread
))
5154 (defun gnus-group-search-forward (&optional backward all level first-too
)
5155 "Find the next newsgroup with unread articles.
5156 If BACKWARD is non-nil, find the previous newsgroup instead.
5157 If ALL is non-nil, just find any newsgroup.
5158 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5160 If FIRST-TOO, the current line is also eligible as a target."
5161 (let ((way (if backward -
1 1))
5162 (low gnus-level-killed
)
5165 (if (and backward
(progn (beginning-of-line)) (bobp))
5167 (or first-too
(forward-line way
))
5175 (get-text-property (point) 'gnus-unread
)))
5176 (and (numberp unread
) (> unread
0)))
5177 (setq lev
(get-text-property (point)
5179 (<= lev gnus-level-subscribed
)))
5181 (and (setq lev
(get-text-property (point)
5190 (zerop (forward-line way
)))))
5192 (progn (gnus-group-position-point) t
)
5193 (goto-char (or pos beg
))
5196 ;;; Gnus group mode commands
5200 (defun gnus-group-mark-group (n &optional unmark no-advance
)
5201 "Mark the current group."
5203 (let ((buffer-read-only nil
)
5207 (when (setq group
(gnus-group-group-name))
5211 (or (cdr (assq 'process gnus-group-mark-positions
)) 2))
5216 (setq gnus-group-marked
(delete group gnus-group-marked
)))
5218 (setq gnus-group-marked
5219 (cons group
(delete group gnus-group-marked
)))))
5220 (or no-advance
(gnus-group-next-group 1))
5222 (gnus-summary-position-point)
5225 (defun gnus-group-unmark-group (n)
5226 "Remove the mark from the current group."
5228 (gnus-group-mark-group n
'unmark
)
5229 (gnus-group-position-point))
5231 (defun gnus-group-unmark-all-groups ()
5232 "Unmark all groups."
5234 (let ((groups gnus-group-marked
))
5237 (gnus-group-remove-mark (pop groups
)))))
5238 (gnus-group-position-point))
5240 (defun gnus-group-mark-region (unmark beg end
)
5241 "Mark all groups between point and mark.
5242 If UNMARK, remove the mark instead."
5243 (interactive "P\nr")
5244 (let ((num (count-lines beg end
)))
5247 (- num
(gnus-group-mark-group num unmark
)))))
5249 (defun gnus-group-mark-buffer (&optional unmark
)
5250 "Mark all groups in the buffer.
5251 If UNMARK, remove the mark instead."
5253 (gnus-group-mark-region unmark
(point-min) (point-max)))
5255 (defun gnus-group-mark-regexp (regexp)
5256 "Mark all groups that match some regexp."
5257 (interactive "sMark (regexp): ")
5258 (let ((alist (cdr gnus-newsrc-alist
))
5261 (when (string-match regexp
(setq group
(gnus-info-group (pop alist
))))
5262 (gnus-group-set-mark group
))))
5263 (gnus-group-position-point))
5265 (defun gnus-group-remove-mark (group)
5266 "Remove the process mark from GROUP and move point there.
5267 Return nil if the group isn't displayed."
5268 (if (gnus-group-goto-group group
)
5270 (gnus-group-mark-group 1 'unmark t
)
5272 (setq gnus-group-marked
5273 (delete group gnus-group-marked
))
5276 (defun gnus-group-set-mark (group)
5277 "Set the process mark on GROUP."
5278 (if (gnus-group-goto-group group
)
5280 (gnus-group-mark-group 1 nil t
))
5281 (setq gnus-group-marked
(cons group
(delete group gnus-group-marked
)))))
5283 (defun gnus-group-universal-argument (arg &optional groups func
)
5284 "Perform any command on all groups accoring to the process/prefix convention."
5286 (let ((groups (or groups
(gnus-group-process-prefix arg
)))
5288 (if (eq (setq func
(or func
5291 (substitute-command-keys
5292 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5294 (gnus-error 1 "Undefined key")
5296 (gnus-group-remove-mark (setq group
(pop groups
)))
5297 (command-execute func
))))
5298 (gnus-group-position-point))
5300 (defun gnus-group-process-prefix (n)
5301 "Return a list of groups to work on.
5302 Take into consideration N (the prefix) and the list of marked groups."
5305 (setq n
(prefix-numeric-value n
))
5306 ;; There is a prefix, so we return a list of the N next
5308 (let ((way (if (< n
0) -
1 1))
5313 (setq group
(gnus-group-group-name)))
5314 (setq groups
(cons group groups
))
5316 (gnus-group-next-group way
)))
5318 ((and (boundp 'transient-mark-mode
)
5320 (boundp 'mark-active
)
5322 ;; Work on the region between point and mark.
5323 (let ((max (max (point) (mark)))
5326 (goto-char (min (point) (mark)))
5329 (push (gnus-group-group-name) groups
)
5330 (zerop (gnus-group-next-group 1))
5332 (nreverse groups
))))
5334 ;; No prefix, but a list of marked articles.
5335 (reverse gnus-group-marked
))
5337 ;; Neither marked articles or a prefix, so we return the
5339 (let ((group (gnus-group-group-name)))
5340 (and group
(list group
))))))
5342 ;; Selecting groups.
5344 (defun gnus-group-read-group (&optional all no-article group
)
5345 "Read news in this newsgroup.
5346 If the prefix argument ALL is non-nil, already read articles become
5347 readable. IF ALL is a number, fetch this number of articles. If the
5348 optional argument NO-ARTICLE is non-nil, no article will be
5349 auto-selected upon group entry. If GROUP is non-nil, fetch that
5352 (let ((group (or group
(gnus-group-group-name)))
5353 number active marked entry
)
5354 (or group
(error "No group on current line"))
5355 (setq marked
(nth 3 (nth 2 (setq entry
(gnus-gethash
5356 group gnus-newsrc-hashtb
)))))
5357 ;; This group might be a dead group. In that case we have to get
5358 ;; the number of unread articles from `gnus-active-hashtb'.
5360 (cond ((numberp all
) all
)
5362 ((setq active
(gnus-active group
))
5363 (- (1+ (cdr active
)) (car active
)))))
5364 (gnus-summary-read-group
5365 group
(or all
(and (numberp number
)
5366 (zerop (+ number
(length (cdr (assq 'tick marked
)))
5367 (length (cdr (assq 'dormant marked
)))))))
5370 (defun gnus-group-select-group (&optional all
)
5371 "Select this newsgroup.
5372 No article is selected automatically.
5373 If ALL is non-nil, already read articles become readable.
5374 If ALL is a number, fetch this number of articles."
5376 (gnus-group-read-group all t
))
5378 (defun gnus-group-quick-select-group (&optional all
)
5379 "Select the current group \"quickly\".
5380 This means that no highlighting or scoring will be performed."
5383 gnus-score-find-score-files-function
5384 gnus-apply-kill-hook
5385 gnus-summary-expunge-below
)
5386 (gnus-group-read-group all t
)))
5388 (defun gnus-group-visible-select-group (&optional all
)
5389 "Select the current group without hiding any articles."
5391 (let ((gnus-inhibit-limiting t
))
5392 (gnus-group-read-group all t
)))
5395 (defun gnus-fetch-group (group)
5396 "Start Gnus if necessary and enter GROUP.
5397 Returns whether the fetching was successful or not."
5398 (interactive "sGroup name: ")
5399 (or (get-buffer gnus-group-buffer
)
5401 (gnus-group-read-group nil nil group
))
5403 ;; Enter a group that is not in the group buffer. Non-nil is returned
5404 ;; if selection was successful.
5405 (defun gnus-group-read-ephemeral-group
5406 (group method
&optional activate quit-config
)
5407 (let ((group (if (gnus-group-foreign-p group
) group
5408 (gnus-group-prefixed-name group method
))))
5411 `(t nil
(,group
,gnus-level-default-subscribed nil nil
,method
5412 ((quit-config .
,(if quit-config quit-config
5413 (cons (current-buffer) 'summary
))))))
5415 (set-buffer gnus-group-buffer
)
5416 (or (gnus-check-server method
)
5417 (error "Unable to contact server: %s" (gnus-status-message method
)))
5418 (if activate
(or (gnus-request-group group
)
5419 (error "Couldn't request group")))
5421 (gnus-group-read-group t t group
)
5425 (defun gnus-group-jump-to-group (group)
5426 "Jump to newsgroup GROUP."
5428 (list (completing-read
5429 "Group: " gnus-active-hashtb nil
5430 (gnus-read-active-file-p)
5432 'gnus-group-history
)))
5434 (when (equal group
"")
5435 (error "Empty group name"))
5437 (when (string-match "[\000-\032]" group
)
5438 (error "Control characters in group: %s" group
))
5440 (let ((b (text-property-any
5441 (point-min) (point-max)
5442 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
))))
5443 (unless (gnus-ephemeral-group-p group
)
5445 ;; Either go to the line in the group buffer...
5447 ;; ... or insert the line.
5450 (gnus-activate-group group
)
5451 (error "%s error: %s" group
(gnus-status-message group
)))
5453 (gnus-group-update-group group
)
5454 (goto-char (text-property-any
5455 (point-min) (point-max)
5456 'gnus-group
(gnus-intern-safe group gnus-active-hashtb
)))))
5457 ;; Adjust cursor point.
5458 (gnus-group-position-point)))
5460 (defun gnus-group-goto-group (group)
5461 "Goto to newsgroup GROUP."
5463 (let ((b (text-property-any (point-min) (point-max)
5464 'gnus-group
(gnus-intern-safe
5465 group gnus-active-hashtb
))))
5466 (and b
(goto-char b
)))))
5468 (defun gnus-group-next-group (n)
5469 "Go to next N'th newsgroup.
5470 If N is negative, search backward instead.
5471 Returns the difference between N and the number of skips actually
5474 (gnus-group-next-unread-group n t
))
5476 (defun gnus-group-next-unread-group (n &optional all level
)
5477 "Go to next N'th unread newsgroup.
5478 If N is negative, search backward instead.
5479 If ALL is non-nil, choose any newsgroup, unread or not.
5480 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5481 such group can be found, the next group with a level higher than
5483 Returns the difference between N and the number of skips actually
5486 (let ((backward (< n
0))
5489 (gnus-group-search-forward
5490 backward
(or (not gnus-group-goto-unread
) all
) level
))
5492 (if (/= 0 n
) (gnus-message 7 "No more%s newsgroups%s" (if all
"" " unread")
5493 (if level
" on this level or higher" "")))
5496 (defun gnus-group-prev-group (n)
5497 "Go to previous N'th newsgroup.
5498 Returns the difference between N and the number of skips actually
5501 (gnus-group-next-unread-group (- n
) t
))
5503 (defun gnus-group-prev-unread-group (n)
5504 "Go to previous N'th unread newsgroup.
5505 Returns the difference between N and the number of skips actually
5508 (gnus-group-next-unread-group (- n
)))
5510 (defun gnus-group-next-unread-group-same-level (n)
5511 "Go to next N'th unread newsgroup on the same level.
5512 If N is negative, search backward instead.
5513 Returns the difference between N and the number of skips actually
5516 (gnus-group-next-unread-group n t
(gnus-group-group-level))
5517 (gnus-group-position-point))
5519 (defun gnus-group-prev-unread-group-same-level (n)
5520 "Go to next N'th unread newsgroup on the same level.
5521 Returns the difference between N and the number of skips actually
5524 (gnus-group-next-unread-group (- n
) t
(gnus-group-group-level))
5525 (gnus-group-position-point))
5527 (defun gnus-group-best-unread-group (&optional exclude-group
)
5528 "Go to the group with the highest level.
5529 If EXCLUDE-GROUP, do not go to that group."
5531 (goto-char (point-min))
5535 (setq unread
(get-text-property (point) 'gnus-unread
))
5536 (if (and (numberp unread
) (> unread
0))
5538 (if (and (get-text-property (point) 'gnus-level
)
5539 (< (get-text-property (point) 'gnus-level
) best
)
5540 (or (not exclude-group
)
5541 (not (equal exclude-group
(gnus-group-group-name)))))
5543 (setq best
(get-text-property (point) 'gnus-level
))
5544 (setq best-point
(point))))))
5546 (if best-point
(goto-char best-point
))
5547 (gnus-summary-position-point)
5548 (and best-point
(gnus-group-group-name))))
5550 (defun gnus-group-first-unread-group ()
5551 "Go to the first group with unread articles."
5554 (let ((opoint (point))
5556 (goto-char (point-min))
5557 (if (or (eq (setq unread
(gnus-group-group-unread)) t
) ; Not active.
5558 (and (numberp unread
) ; Not a topic.
5559 (not (zerop unread
))) ; Has unread articles.
5560 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5563 nil
)) ; Not success.
5564 (gnus-group-position-point)))
5566 (defun gnus-group-enter-server-mode ()
5567 "Jump to the server buffer."
5569 (gnus-enter-server-buffer))
5571 (defun gnus-group-make-group (name &optional method address
)
5572 "Add a new newsgroup.
5573 The user will be prompted for a NAME, for a select METHOD, and an
5577 (read-string "Group name: ")
5580 "Method: " (append gnus-valid-select-methods gnus-server-alist
)
5581 nil t nil
'gnus-method-history
)))
5582 (cond ((assoc method gnus-valid-select-methods
)
5584 (if (memq 'prompt-address
5585 (assoc method gnus-valid-select-methods
))
5586 (read-string "Address: ")
5588 ((assoc method gnus-server-alist
)
5591 (list method
""))))))
5593 (let* ((meth (and method
(if address
(list (intern method
) address
)
5595 (nname (if method
(gnus-group-prefixed-name name meth
) name
))
5597 (when (gnus-gethash nname gnus-newsrc-hashtb
)
5598 (error "Group %s already exists" nname
))
5599 ;; Subscribe to the new group.
5600 (gnus-group-change-level
5601 (setq info
(list t nname gnus-level-default-subscribed nil nil meth
))
5602 gnus-level-default-subscribed gnus-level-killed
5603 (and (gnus-group-group-name)
5604 (gnus-gethash (gnus-group-group-name)
5605 gnus-newsrc-hashtb
))
5608 (gnus-set-active nname
(cons 1 0))
5609 (or (gnus-ephemeral-group-p name
)
5611 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info
)) ")")))
5613 (gnus-group-insert-group-line-info nname
)
5615 (gnus-group-position-point)
5617 ;; Load the backend and try to make the backend create
5618 ;; the group as well.
5619 (when (assoc (symbol-name (setq backend
(car (gnus-server-get-method
5621 gnus-valid-select-methods
)
5623 (gnus-check-server meth
)
5624 (and (gnus-check-backend-function 'request-create-group nname
)
5625 (gnus-request-create-group nname
))
5628 (defun gnus-group-delete-group (group &optional force
)
5629 "Delete the current group. Only meaningful with mail groups.
5630 If FORCE (the prefix) is non-nil, all the articles in the group will
5631 be deleted. This is \"deleted\" as in \"removed forever from the face
5632 of the Earth\". There is no undo. The user will be prompted before
5633 doing the deletion."
5635 (list (gnus-group-group-name)
5636 current-prefix-arg
))
5637 (or group
(error "No group to rename"))
5638 (or (gnus-check-backend-function 'request-delete-group group
)
5639 (error "This backend does not support group deletion"))
5641 (if (not (gnus-yes-or-no-p
5643 "Do you really want to delete %s%s? "
5644 group
(if force
" and all its contents" ""))))
5646 (gnus-message 6 "Deleting group %s..." group
)
5647 (if (not (gnus-request-delete-group group force
))
5648 (gnus-error 3 "Couldn't delete group %s" group
)
5649 (gnus-message 6 "Deleting group %s...done" group
)
5650 (gnus-group-goto-group group
)
5651 (gnus-group-kill-group 1 t
)
5652 (gnus-sethash group nil gnus-active-hashtb
)
5654 (gnus-group-position-point)))
5656 (defun gnus-group-rename-group (group new-name
)
5659 (gnus-group-group-name)
5661 (or (gnus-check-backend-function
5662 'request-rename-group
(gnus-group-group-name))
5663 (error "This backend does not support renaming groups"))
5664 (read-string "New group name: "))))
5666 (or (gnus-check-backend-function 'request-rename-group group
)
5667 (error "This backend does not support renaming groups"))
5669 (or group
(error "No group to rename"))
5670 (and (string-match "^[ \t]*$" new-name
)
5671 (error "Not a valid group name"))
5673 ;; We find the proper prefixed name.
5675 (gnus-group-prefixed-name
5676 (gnus-group-real-name new-name
)
5677 (gnus-info-method (gnus-get-info group
))))
5679 (gnus-message 6 "Renaming group %s to %s..." group new-name
)
5681 (if (not (gnus-request-rename-group group new-name
))
5682 (gnus-error 3 "Couldn't rename group %s to %s" group new-name
)
5683 ;; We rename the group internally by killing it...
5684 (gnus-group-goto-group group
)
5685 (gnus-group-kill-group)
5686 ;; ... changing its name ...
5687 (setcar (cdar gnus-list-of-killed-groups
) new-name
)
5688 ;; ... and then yanking it. Magic!
5689 (gnus-group-yank-group)
5690 (gnus-set-active new-name
(gnus-active group
))
5691 (gnus-message 6 "Renaming group %s to %s...done" group new-name
)
5693 (gnus-group-position-point)))
5695 (defun gnus-group-edit-group (group &optional part
)
5696 "Edit the group on the current line."
5697 (interactive (list (gnus-group-group-name)))
5698 (let* ((part (or part
'info
))
5699 (done-func `(lambda ()
5700 "Exit editing mode and update the information."
5702 (gnus-group-edit-group-done ',part
,group
)))
5703 (winconf (current-window-configuration))
5705 (or group
(error "No group on current line"))
5706 (or (setq info
(gnus-get-info group
))
5707 (error "Killed group; can't be edited"))
5708 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
5709 (gnus-configure-windows 'edit-group
)
5710 (gnus-add-current-to-buffer-list)
5712 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5713 (use-local-map (copy-keymap emacs-lisp-mode-map
))
5714 (local-set-key "\C-c\C-c" done-func
)
5715 (make-local-variable 'gnus-prev-winconf
)
5716 (setq gnus-prev-winconf winconf
)
5721 ";; Type `C-c C-c' after editing the select method.\n\n")
5723 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5725 ";; Type `C-c C-c' after editing the group info.\n\n")))
5728 (cond ((eq part
'method
)
5729 (or (gnus-info-method info
) "native"))
5731 (gnus-info-params info
))
5735 (defun gnus-group-edit-group-method (group)
5736 "Edit the select method of GROUP."
5737 (interactive (list (gnus-group-group-name)))
5738 (gnus-group-edit-group group
'method
))
5740 (defun gnus-group-edit-group-parameters (group)
5741 "Edit the group parameters of GROUP."
5742 (interactive (list (gnus-group-group-name)))
5743 (gnus-group-edit-group group
'params
))
5745 (defun gnus-group-edit-group-done (part group
)
5746 "Get info from buffer, update variables and jump to the group buffer."
5747 (set-buffer (get-buffer-create gnus-group-edit-buffer
))
5748 (goto-char (point-min))
5749 (let* ((form (read (current-buffer)))
5750 (winconf gnus-prev-winconf
)
5751 (method (cond ((eq part
'info
) (nth 4 form
))
5752 ((eq part
'method
) form
)
5754 (info (cond ((eq part
'info
) form
)
5755 ((eq part
'method
) (gnus-get-info group
))
5758 (if (or (not method
)
5760 gnus-select-method method
))
5761 (gnus-group-real-name (car info
))
5762 (gnus-group-prefixed-name
5763 (gnus-group-real-name (car info
)) method
))
5765 (when (and new-group
5766 (not (equal new-group group
)))
5767 (when (gnus-group-goto-group group
)
5768 (gnus-group-kill-group 1))
5769 (gnus-activate-group new-group
))
5771 (if (and info new-group
)
5773 (setq info
(gnus-copy-sequence info
))
5774 (setcar info new-group
)
5775 (unless (gnus-server-equal method
"native")
5776 (unless (nthcdr 3 info
)
5777 (nconc info
(list nil nil
)))
5778 (unless (nthcdr 4 info
)
5779 (nconc info
(list nil
)))
5780 (gnus-info-set-method info method
))
5781 (gnus-group-set-info info
))
5782 (gnus-group-set-info form
(or new-group group
) part
))
5783 (kill-buffer (current-buffer))
5784 (and winconf
(set-window-configuration winconf
))
5785 (set-buffer gnus-group-buffer
)
5786 (gnus-group-update-group (or new-group group
))
5787 (gnus-group-position-point)))
5789 (defun gnus-group-make-help-group ()
5790 "Create the Gnus documentation group."
5792 (let ((path load-path
)
5793 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5795 (and (gnus-gethash name gnus-newsrc-hashtb
)
5796 (error "Documentation group already exists"))
5798 (setq dir
(file-name-as-directory (expand-file-name (pop path
)))
5800 (when (or (file-exists-p (setq file
(concat dir
"gnus-tut.txt")))
5802 (setq file
(concat (file-name-directory
5803 (directory-file-name dir
))
5804 "etc/gnus-tut.txt"))))
5807 (gnus-message 1 "Couldn't find doc group")
5808 (gnus-group-make-group
5809 (gnus-group-real-name name
)
5810 (list 'nndoc
"gnus-help"
5811 (list 'nndoc-address file
)
5812 (list 'nndoc-article-type
'mbox
)))))
5813 (gnus-group-position-point))
5815 (defun gnus-group-make-doc-group (file type
)
5816 "Create a group that uses a single file as the source."
5818 (list (read-file-name "File name: ")
5819 (and current-prefix-arg
'ask
)))
5820 (when (eq type
'ask
)
5825 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5827 (setq found
(cond ((= (setq char
(read-char)) ?m
) 'mbox
)
5828 ((= char ?b
) 'babyl
)
5829 ((= char ?d
) 'digest
)
5830 ((= char ?f
) 'forward
)
5832 (t (setq err
(format "%c unknown. " char
))
5835 (let* ((file (expand-file-name file
))
5836 (name (gnus-generate-new-group-name
5837 (gnus-group-prefixed-name
5838 (file-name-nondirectory file
) '(nndoc "")))))
5839 (gnus-group-make-group
5840 (gnus-group-real-name name
)
5841 (list 'nndoc
(file-name-nondirectory file
)
5842 (list 'nndoc-address file
)
5843 (list 'nndoc-article-type
(or type
'guess
))))))
5845 (defun gnus-group-make-archive-group (&optional all
)
5846 "Create the (ding) Gnus archive group of the most recent articles.
5847 Given a prefix, create a full group."
5849 (let ((group (gnus-group-prefixed-name
5850 (if all
"ding.archives" "ding.recent") '(nndir ""))))
5851 (and (gnus-gethash group gnus-newsrc-hashtb
)
5852 (error "Archive group already exists"))
5853 (gnus-group-make-group
5854 (gnus-group-real-name group
)
5855 (list 'nndir
(if all
"hpc" "edu")
5856 (list 'nndir-directory
5857 (if all gnus-group-archive-directory
5858 gnus-group-recent-archive-directory
))))))
5860 (defun gnus-group-make-directory-group (dir)
5861 "Create an nndir group.
5862 The user will be prompted for a directory. The contents of this
5863 directory will be used as a newsgroup. The directory should contain
5864 mail messages or news articles in files that have numeric names."
5866 (list (read-file-name "Create group from directory: ")))
5867 (or (file-exists-p dir
) (error "No such directory"))
5868 (or (file-directory-p dir
) (error "Not a directory"))
5872 (while (or (not group
) (gnus-gethash group gnus-newsrc-hashtb
))
5874 (gnus-group-prefixed-name
5875 (concat (file-name-as-directory (directory-file-name dir
))
5878 (setq ext
(format "<%d>" (setq i
(1+ i
)))))
5879 (gnus-group-make-group
5880 (gnus-group-real-name group
)
5881 (list 'nndir group
(list 'nndir-directory dir
)))))
5883 (defun gnus-group-make-kiboze-group (group address scores
)
5884 "Create an nnkiboze group.
5885 The user will be prompted for a name, a regexp to match groups, and
5886 score file entries for articles to include in the group."
5889 (read-string "nnkiboze group name: ")
5890 (read-string "Source groups (regexp): ")
5891 (let ((headers (mapcar (lambda (group) (list group
))
5892 '("subject" "from" "number" "date" "message-id"
5893 "references" "chars" "lines" "xref"
5894 "followup" "all" "body" "head")))
5895 scores header regexp regexps
)
5896 (while (not (equal "" (setq header
(completing-read
5897 "Match on header: " headers nil t
))))
5899 (while (not (equal "" (setq regexp
(read-string
5900 (format "Match on %s (string): "
5902 (setq regexps
(cons (list regexp nil nil
'r
) regexps
)))
5903 (setq scores
(cons (cons header regexps
) scores
)))
5905 (gnus-group-make-group group
"nnkiboze" address
)
5906 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group
))
5907 (let (emacs-lisp-mode-hook)
5908 (pp scores
(current-buffer)))))
5910 (defun gnus-group-add-to-virtual (n vgroup
)
5911 "Add the current group to a virtual group."
5913 (list current-prefix-arg
5914 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5916 (or (eq (car (gnus-find-method-for-group vgroup
)) 'nnvirtual
)
5917 (error "%s is not an nnvirtual group" vgroup
))
5918 (let* ((groups (gnus-group-process-prefix n
))
5919 (method (gnus-info-method (gnus-get-info vgroup
))))
5920 (setcar (cdr method
)
5922 (nth 1 method
) "\\|"
5925 (gnus-group-remove-mark s
)
5926 (concat "\\(^" (regexp-quote s
) "$\\)"))
5928 (gnus-group-position-point))
5930 (defun gnus-group-make-empty-virtual (group)
5931 "Create a new, fresh, empty virtual group."
5932 (interactive "sCreate new, empty virtual group: ")
5933 (let* ((method (list 'nnvirtual
"^$"))
5934 (pgroup (gnus-group-prefixed-name group method
)))
5935 ;; Check whether it exists already.
5936 (and (gnus-gethash pgroup gnus-newsrc-hashtb
)
5937 (error "Group %s already exists." pgroup
))
5938 ;; Subscribe the new group after the group on the current line.
5939 (gnus-subscribe-group pgroup
(gnus-group-group-name) method
)
5940 (gnus-group-update-group pgroup
)
5942 (gnus-group-position-point)))
5944 (defun gnus-group-enter-directory (dir)
5945 "Enter an ephemeral nneething group."
5946 (interactive "DDirectory to read: ")
5947 (let* ((method (list 'nneething dir
))
5948 (leaf (gnus-group-prefixed-name
5949 (file-name-nondirectory (directory-file-name dir
))
5951 (name (gnus-generate-new-group-name leaf
)))
5952 (let ((nneething-read-only t
))
5953 (or (gnus-group-read-ephemeral-group
5955 (cons (current-buffer) (if (eq major-mode
'gnus-summary-mode
)
5957 (error "Couldn't enter %s" dir
)))))
5959 ;; Group sorting commands
5960 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5962 (defun gnus-group-sort-groups (func &optional reverse
)
5963 "Sort the group buffer according to FUNC.
5964 If REVERSE, reverse the sorting order."
5965 (interactive (list gnus-group-sort-function
5966 current-prefix-arg
))
5968 ((not (listp func
)) func
)
5970 ((= 1 (length func
)) (car func
))
5972 ,(gnus-make-sort-function
5973 (reverse func
)))))))
5974 ;; We peel off the dummy group from the alist.
5976 (when (equal (car (gnus-info-group gnus-newsrc-alist
)) "dummy.group")
5977 (pop gnus-newsrc-alist
))
5979 (setq gnus-newsrc-alist
5980 (sort gnus-newsrc-alist func
))
5982 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
)))
5983 ;; Regenerate the hash table.
5984 (gnus-make-hashtable-from-newsrc-alist)
5985 (gnus-group-list-groups))))
5987 (defun gnus-group-sort-groups-by-alphabet (&optional reverse
)
5988 "Sort the group buffer alphabetically by group name.
5989 If REVERSE, sort in reverse order."
5991 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse
))
5993 (defun gnus-group-sort-groups-by-unread (&optional reverse
)
5994 "Sort the group buffer by number of unread articles.
5995 If REVERSE, sort in reverse order."
5997 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse
))
5999 (defun gnus-group-sort-groups-by-level (&optional reverse
)
6000 "Sort the group buffer by group level.
6001 If REVERSE, sort in reverse order."
6003 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse
))
6005 (defun gnus-group-sort-groups-by-score (&optional reverse
)
6006 "Sort the group buffer by group score.
6007 If REVERSE, sort in reverse order."
6009 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse
))
6011 (defun gnus-group-sort-groups-by-rank (&optional reverse
)
6012 "Sort the group buffer by group rank.
6013 If REVERSE, sort in reverse order."
6015 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse
))
6017 (defun gnus-group-sort-groups-by-method (&optional reverse
)
6018 "Sort the group buffer alphabetically by backend name.
6019 If REVERSE, sort in reverse order."
6021 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse
))
6023 (defun gnus-group-sort-by-alphabet (info1 info2
)
6024 "Sort alphabetically."
6025 (string< (gnus-info-group info1
) (gnus-info-group info2
)))
6027 (defun gnus-group-sort-by-unread (info1 info2
)
6028 "Sort by number of unread articles."
6029 (let ((n1 (car (gnus-gethash (gnus-info-group info1
) gnus-newsrc-hashtb
)))
6030 (n2 (car (gnus-gethash (gnus-info-group info2
) gnus-newsrc-hashtb
))))
6031 (< (or (and (numberp n1
) n1
) 0)
6032 (or (and (numberp n2
) n2
) 0))))
6034 (defun gnus-group-sort-by-level (info1 info2
)
6036 (< (gnus-info-level info1
) (gnus-info-level info2
)))
6038 (defun gnus-group-sort-by-method (info1 info2
)
6039 "Sort alphabetically by backend name."
6040 (string< (symbol-name (car (gnus-find-method-for-group
6041 (gnus-info-group info1
) info1
)))
6042 (symbol-name (car (gnus-find-method-for-group
6043 (gnus-info-group info2
) info2
)))))
6045 (defun gnus-group-sort-by-score (info1 info2
)
6046 "Sort by group score."
6047 (< (gnus-info-score info1
) (gnus-info-score info2
)))
6049 (defun gnus-group-sort-by-rank (info1 info2
)
6050 "Sort by level and score."
6051 (let ((level1 (gnus-info-level info1
))
6052 (level2 (gnus-info-level info2
)))
6053 (or (< level1 level2
)
6054 (and (= level1 level2
)
6055 (> (gnus-info-score info1
) (gnus-info-score info2
))))))
6057 ;; Group catching up.
6059 (defun gnus-group-clear-data (n)
6060 "Clear all marks and read ranges from the current group."
6062 (let ((groups (gnus-group-process-prefix n
))
6064 (while (setq group
(pop groups
))
6065 (setq info
(gnus-get-info group
))
6066 (gnus-info-set-read info nil
)
6067 (when (gnus-info-marks info
)
6068 (gnus-info-set-marks info nil
))
6069 (gnus-get-unread-articles-in-group info
(gnus-active group
) t
)
6070 (when (gnus-group-goto-group group
)
6071 (gnus-group-remove-mark group
)
6072 (gnus-group-update-group-line)))))
6074 (defun gnus-group-catchup-current (&optional n all
)
6075 "Mark all articles not marked as unread in current newsgroup as read.
6076 If prefix argument N is numeric, the ARG next newsgroups will be
6077 caught up. If ALL is non-nil, marked articles will also be marked as
6078 read. Cross references (Xref: header) of articles are ignored.
6079 The difference between N and actual number of newsgroups that were
6080 caught up is returned."
6082 (unless (gnus-group-group-name)
6083 (error "No group on the current line"))
6084 (if (not (or (not gnus-interactive-catchup
) ;Without confirmation?
6088 "Do you really want to mark all articles as read? "
6089 "Mark all unread articles as read? "))))
6091 (let ((groups (gnus-group-process-prefix n
))
6094 ;; Virtual groups have to be given special treatment.
6095 (let ((method (gnus-find-method-for-group (car groups
))))
6096 (if (eq 'nnvirtual
(car method
))
6097 (nnvirtual-catchup-group
6098 (gnus-group-real-name (car groups
)) (nth 1 method
) all
)))
6099 (gnus-group-remove-mark (car groups
))
6100 (if (>= (gnus-group-group-level) gnus-level-zombie
)
6101 (gnus-message 2 "Dead groups can't be caught up")
6103 (gnus-group-goto-group (car groups
))
6104 (gnus-group-catchup (car groups
) all
))
6105 (gnus-group-update-group-line)
6106 (setq ret
(1+ ret
))))
6107 (setq groups
(cdr groups
)))
6108 (gnus-group-next-unread-group 1)
6111 (defun gnus-group-catchup-current-all (&optional n
)
6112 "Mark all articles in current newsgroup as read.
6113 Cross references (Xref: header) of articles are ignored."
6115 (gnus-group-catchup-current n
'all
))
6117 (defun gnus-group-catchup (group &optional all
)
6118 "Mark all articles in GROUP as read.
6119 If ALL is non-nil, all articles are marked as read.
6120 The return value is the number of articles that were marked as read,
6121 or nil if no action could be taken."
6122 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb
))
6124 ;; Do the updating only if the newsgroup isn't killed.
6125 (if (not (numberp (car entry
)))
6126 (gnus-message 1 "Can't catch up; non-active group")
6127 ;; Do auto-expirable marks if that's required.
6128 (when (gnus-group-auto-expirable-p group
)
6129 (gnus-add-marked-articles
6130 group
'expire
(gnus-list-of-unread-articles group
))
6132 (let ((marks (nth 3 (nth 2 entry
))))
6133 (gnus-add-marked-articles
6134 group
'expire
(gnus-uncompress-range (cdr (assq 'tick marks
))))
6135 (gnus-add-marked-articles
6136 group
'expire
(gnus-uncompress-range (cdr (assq 'tick marks
)))))))
6138 (gnus-update-read-articles group nil
)
6139 ;; Also nix out the lists of marks and dormants.
6141 (gnus-add-marked-articles group
'tick nil nil
'force
)
6142 (gnus-add-marked-articles group
'dormant nil nil
'force
))
6143 (run-hooks 'gnus-group-catchup-group-hook
)
6146 (defun gnus-group-expire-articles (&optional n
)
6147 "Expire all expirable articles in the current newsgroup."
6149 (let ((groups (gnus-group-process-prefix n
))
6152 (error "No groups to expire"))
6153 (while (setq group
(pop groups
))
6154 (gnus-group-remove-mark group
)
6155 (when (gnus-check-backend-function 'request-expire-articles group
)
6156 (gnus-message 6 "Expiring articles in %s..." group
)
6157 (let* ((info (gnus-get-info group
))
6158 (expirable (if (gnus-group-total-expirable-p group
)
6159 (cons nil
(gnus-list-of-read-articles group
))
6160 (assq 'expire
(gnus-info-marks info
))))
6161 (expiry-wait (gnus-group-get-parameter group
'expiry-wait
)))
6165 (gnus-compress-sequence
6167 ;; We set the expiry variables to the groupp
6169 (let ((nnmail-expiry-wait-function nil
)
6170 (nnmail-expiry-wait expiry-wait
))
6171 (gnus-request-expire-articles
6172 (gnus-uncompress-sequence (cdr expirable
)) group
))
6173 ;; Just expire using the normal expiry values.
6174 (gnus-request-expire-articles
6175 (gnus-uncompress-sequence (cdr expirable
)) group
))))
6176 (gnus-close-group group
))
6177 (gnus-message 6 "Expiring articles in %s...done" group
)))
6178 (gnus-group-position-point))))
6180 (defun gnus-group-expire-all-groups ()
6181 "Expire all expirable articles in all newsgroups."
6184 (gnus-message 5 "Expiring...")
6185 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info
))
6186 (cdr gnus-newsrc-alist
))))
6187 (gnus-group-expire-articles nil
)))
6188 (gnus-group-position-point)
6189 (gnus-message 5 "Expiring...done"))
6191 (defun gnus-group-set-current-level (n level
)
6192 "Set the level of the next N groups to LEVEL."
6197 (let ((s (read-string
6198 (format "Level (default %s): "
6199 (or (gnus-group-group-level)
6200 gnus-level-default-subscribed
)))))
6201 (if (string-match "^\\s-*$" s
)
6202 (int-to-string (or (gnus-group-group-level)
6203 gnus-level-default-subscribed
))
6205 (or (and (>= level
1) (<= level gnus-level-killed
))
6206 (error "Illegal level: %d" level
))
6207 (let ((groups (gnus-group-process-prefix n
))
6209 (while (setq group
(pop groups
))
6210 (gnus-group-remove-mark group
)
6211 (gnus-message 6 "Changed level of %s from %d to %d"
6212 group
(or (gnus-group-group-level) gnus-level-killed
)
6214 (gnus-group-change-level
6215 group level
(or (gnus-group-group-level) gnus-level-killed
))
6216 (gnus-group-update-group-line)))
6217 (gnus-group-position-point))
6219 (defun gnus-group-unsubscribe-current-group (&optional n
)
6220 "Toggle subscription of the current group.
6221 If given numerical prefix, toggle the N next groups."
6223 (let ((groups (gnus-group-process-prefix n
))
6226 (setq group
(car groups
)
6227 groups
(cdr groups
))
6228 (gnus-group-remove-mark group
)
6229 (gnus-group-unsubscribe-group
6230 group
(if (<= (gnus-group-group-level) gnus-level-subscribed
)
6231 gnus-level-default-unsubscribed
6232 gnus-level-default-subscribed
) t
)
6233 (gnus-group-update-group-line))
6234 (gnus-group-next-group 1)))
6236 (defun gnus-group-unsubscribe-group (group &optional level silent
)
6237 "Toggle subscription to GROUP.
6238 Killed newsgroups are subscribed. If SILENT, don't try to update the
6241 (list (completing-read
6242 "Group: " gnus-active-hashtb nil
6243 (gnus-read-active-file-p)
6245 'gnus-group-history
)))
6246 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb
)))
6248 ((string-match "^[ \t]$" group
)
6249 (error "Empty group name"))
6251 ;; Toggle subscription flag.
6252 (gnus-group-change-level
6253 newsrc
(if level level
(if (<= (nth 1 (nth 2 newsrc
))
6254 gnus-level-subscribed
)
6255 (1+ gnus-level-subscribed
)
6256 gnus-level-default-subscribed
)))
6258 (gnus-group-update-group group
)))
6259 ((and (stringp group
)
6260 (or (not (gnus-read-active-file-p))
6261 (gnus-active group
)))
6262 ;; Add new newsgroup.
6263 (gnus-group-change-level
6265 (if level level gnus-level-default-subscribed
)
6266 (or (and (member group gnus-zombie-list
)
6269 (and (gnus-group-group-name)
6270 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb
)))
6272 (gnus-group-update-group group
)))
6273 (t (error "No such newsgroup: %s" group
)))
6274 (gnus-group-position-point)))
6276 (defun gnus-group-transpose-groups (n)
6277 "Move the current newsgroup up N places.
6278 If given a negative prefix, move down instead. The difference between
6279 N and the number of steps taken is returned."
6281 (or (gnus-group-group-name)
6282 (error "No group on current line"))
6283 (gnus-group-kill-group 1)
6285 (forward-line (- n
))
6286 (gnus-group-yank-group)
6287 (gnus-group-position-point)))
6289 (defun gnus-group-kill-all-zombies ()
6290 "Kill all zombie newsgroups."
6292 (setq gnus-killed-list
(nconc gnus-zombie-list gnus-killed-list
))
6293 (setq gnus-zombie-list nil
)
6294 (gnus-group-list-groups))
6296 (defun gnus-group-kill-region (begin end
)
6297 "Kill newsgroups in current region (excluding current point).
6298 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6313 (beginning-of-line) ;Important when LINES < 1
6314 (gnus-group-kill-group lines
)))
6316 (defun gnus-group-kill-group (&optional n discard
)
6317 "Kill the next N groups.
6318 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6319 However, only groups that were alive can be yanked; already killed
6320 groups or zombie groups can't be yanked.
6321 The return value is the name of the group that was killed, or a list
6324 (let ((buffer-read-only nil
)
6325 (groups (gnus-group-process-prefix n
))
6326 group entry level out
)
6327 (if (< (length groups
) 10)
6328 ;; This is faster when there are few groups.
6330 (push (setq group
(pop groups
)) out
)
6331 (gnus-group-remove-mark group
)
6332 (setq level
(gnus-group-group-level))
6334 (when (and (not discard
)
6335 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
)))
6336 (push (cons (car entry
) (nth 2 entry
))
6337 gnus-list-of-killed-groups
))
6338 (gnus-group-change-level
6339 (if entry entry group
) gnus-level-killed
(if entry nil level
)))
6340 ;; If there are lots and lots of groups to be killed, we use
6341 ;; this thing instead.
6343 (setq groups
(nreverse groups
))
6345 (gnus-group-remove-mark (setq group
(pop groups
)))
6347 (push group gnus-killed-list
)
6348 (setq gnus-newsrc-alist
6349 (delq (assoc group gnus-newsrc-alist
)
6351 (when gnus-group-change-level-function
6352 (funcall gnus-group-change-level-function group
9 3))
6354 ((setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
6355 (push (cons (car entry
) (nth 2 entry
))
6356 gnus-list-of-killed-groups
)
6357 (setcdr (cdr entry
) (cdddr entry
)))
6358 ((member group gnus-zombie-list
)
6359 (setq gnus-zombie-list
(delete group gnus-zombie-list
)))))
6360 (gnus-make-hashtable-from-newsrc-alist)))
6362 (gnus-group-position-point)
6363 (if (< (length out
) 2) (car out
) (nreverse out
))))
6365 (defun gnus-group-yank-group (&optional arg
)
6366 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6367 inserting it before the current newsgroup. The numeric ARG specifies
6368 how many newsgroups are to be yanked. The name of the newsgroup yanked
6369 is returned, or (if several groups are yanked) a list of yanked groups
6372 (setq arg
(or arg
1))
6373 (let (info group prev out
)
6374 (while (>= (decf arg
) 0)
6375 (if (not (setq info
(pop gnus-list-of-killed-groups
)))
6376 (error "No more newsgroups to yank"))
6377 (push (setq group
(nth 1 info
)) out
)
6378 ;; Find which newsgroup to insert this one before - search
6379 ;; backward until something suitable is found. If there are no
6380 ;; other newsgroups in this buffer, just make this newsgroup the
6382 (setq prev
(gnus-group-group-name))
6383 (gnus-group-change-level
6384 info
(gnus-info-level (cdr info
)) gnus-level-killed
6385 (and prev
(gnus-gethash prev gnus-newsrc-hashtb
))
6387 (gnus-group-insert-group-line-info group
))
6389 (gnus-group-position-point)
6390 (if (< (length out
) 2) (car out
) (nreverse out
))))
6392 (defun gnus-group-kill-level (level)
6393 "Kill all groups that is on a certain LEVEL."
6394 (interactive "nKill all groups on level: ")
6396 ((= level gnus-level-zombie
)
6397 (setq gnus-killed-list
6398 (nconc gnus-zombie-list gnus-killed-list
))
6399 (setq gnus-zombie-list nil
))
6400 ((and (< level gnus-level-zombie
)
6402 (or gnus-expert-user
6405 "Do you really want to kill all groups on level %d? "
6407 (let* ((prev gnus-newsrc-alist
)
6410 (if (= (gnus-info-level level
) level
)
6411 (setcdr prev
(cdr alist
))
6413 (setq alist
(cdr alist
)))
6414 (gnus-make-hashtable-from-newsrc-alist)
6415 (gnus-group-list-groups)))
6417 (error "Can't kill; illegal level: %d" level
))))
6419 (defun gnus-group-list-all-groups (&optional arg
)
6420 "List all newsgroups with level ARG or lower.
6421 Default is gnus-level-unsubscribed, which lists all subscribed and most
6422 unsubscribed groups."
6424 (gnus-group-list-groups (or arg gnus-level-unsubscribed
) t
))
6426 ;; Redefine this to list ALL killed groups if prefix arg used.
6427 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6428 (defun gnus-group-list-killed (&optional arg
)
6429 "List all killed newsgroups in the group buffer.
6430 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6431 entail asking the server for the groups."
6433 ;; Find all possible killed newsgroups if arg.
6435 (gnus-get-killed-groups))
6436 (if (not gnus-killed-list
)
6437 (gnus-message 6 "No killed groups")
6438 (let (gnus-group-list-mode)
6439 (funcall gnus-group-prepare-function
6440 gnus-level-killed t gnus-level-killed
))
6441 (goto-char (point-min)))
6442 (gnus-group-position-point))
6444 (defun gnus-group-list-zombies ()
6445 "List all zombie newsgroups in the group buffer."
6447 (if (not gnus-zombie-list
)
6448 (gnus-message 6 "No zombie groups")
6449 (let (gnus-group-list-mode)
6450 (funcall gnus-group-prepare-function
6451 gnus-level-zombie t gnus-level-zombie
))
6452 (goto-char (point-min)))
6453 (gnus-group-position-point))
6455 (defun gnus-group-list-active ()
6456 "List all groups that are available from the server(s)."
6458 ;; First we make sure that we have really read the active file.
6459 (unless (gnus-read-active-file-p)
6460 (let ((gnus-read-active-file t
))
6461 (gnus-read-active-file)))
6462 ;; Find all groups and sort them.
6470 (setq list
(cons (symbol-name sym
) list
))))
6474 (buffer-read-only nil
))
6477 (gnus-group-insert-group-line-info (pop groups
)))
6478 (goto-char (point-min))))
6480 (defun gnus-activate-all-groups (level)
6481 "Activate absolutely all groups."
6482 (interactive (list 7))
6483 (let ((gnus-activate-level level
)
6484 (gnus-activate-foreign-newsgroups level
))
6485 (gnus-group-get-new-news)))
6487 (defun gnus-group-get-new-news (&optional arg
)
6488 "Get newly arrived articles.
6489 If ARG is a number, it specifies which levels you are interested in
6490 re-scanning. If ARG is non-nil and not a number, this will force
6491 \"hard\" re-reading of the active files from all servers."
6493 (run-hooks 'gnus-get-new-news-hook
)
6494 ;; We might read in new NoCeM messages here.
6495 (when (and gnus-use-nocem
6497 (gnus-nocem-scan-groups))
6498 ;; If ARG is not a number, then we read the active file.
6499 (when (and arg
(not (numberp arg
)))
6500 (let ((gnus-read-active-file t
))
6501 (gnus-read-active-file))
6504 (setq arg
(gnus-group-default-level arg t
))
6505 (if (and gnus-read-active-file
(not arg
))
6507 (gnus-read-active-file)
6508 (gnus-get-unread-articles arg
))
6509 (let ((gnus-read-active-file (if arg nil gnus-read-active-file
)))
6510 (gnus-get-unread-articles arg
)))
6511 (run-hooks 'gnus-after-getting-new-news-hook
)
6512 (gnus-group-list-groups))
6514 (defun gnus-group-get-new-news-this-group (&optional n
)
6515 "Check for newly arrived news in the current group (and the N-1 next groups).
6516 The difference between N and the number of newsgroup checked is returned.
6517 If N is negative, this group and the N-1 previous groups will be checked."
6519 (let* ((groups (gnus-group-process-prefix n
))
6520 (ret (if (numberp n
) (- n
(length groups
)) 0))
6521 (beg (unless n
(point)))
6523 (while (setq group
(pop groups
))
6524 (gnus-group-remove-mark group
)
6525 (if (gnus-activate-group group
'scan
)
6527 (gnus-get-unread-articles-in-group
6528 (gnus-get-info group
) (gnus-active group
) t
)
6529 (unless (gnus-virtual-group-p group
)
6530 (gnus-close-group group
))
6531 (gnus-group-update-group group
))
6532 (gnus-error 3 "%s error: %s" group
(gnus-status-message group
))))
6533 (when beg
(goto-char beg
))
6534 (when gnus-goto-next-group-when-activating
6535 (gnus-group-next-unread-group 1 t
))
6536 (gnus-summary-position-point)
6539 (defun gnus-group-fetch-faq (group &optional faq-dir
)
6540 "Fetch the FAQ for the current group."
6543 (and (gnus-group-group-name)
6544 (gnus-group-real-name (gnus-group-group-name)))
6545 (cond (current-prefix-arg
6547 "Faq dir: " (and (listp gnus-group-faq-directory
)
6548 (mapcar (lambda (file) (list file
))
6549 gnus-group-faq-directory
)))))))
6551 (setq faq-dir
(if (listp gnus-group-faq-directory
)
6552 (car gnus-group-faq-directory
)
6553 gnus-group-faq-directory
)))
6554 (or group
(error "No group name given"))
6555 (let ((file (concat (file-name-as-directory faq-dir
)
6556 (gnus-group-real-name group
))))
6557 (if (not (file-exists-p file
))
6558 (error "No such file: %s" file
)
6561 (defun gnus-group-describe-group (force &optional group
)
6562 "Display a description of the current newsgroup."
6563 (interactive (list current-prefix-arg
(gnus-group-group-name)))
6565 gnus-description-hashtb
)
6566 (gnus-sethash group nil gnus-description-hashtb
))
6567 (let ((method (gnus-find-method-for-group group
))
6569 (or group
(error "No group name given"))
6570 (and (or (and gnus-description-hashtb
6571 ;; We check whether this group's method has been
6572 ;; queried for a description file.
6574 (gnus-group-prefixed-name "" method
)
6575 gnus-description-hashtb
))
6576 (setq desc
(gnus-group-get-description group
))
6577 (gnus-read-descriptions-file method
))
6579 (or desc
(gnus-gethash group gnus-description-hashtb
)
6580 "No description available")))))
6582 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6583 (defun gnus-group-describe-all-groups (&optional force
)
6584 "Pop up a buffer with descriptions of all newsgroups."
6586 (and force
(setq gnus-description-hashtb nil
))
6587 (if (not (or gnus-description-hashtb
6588 (gnus-read-all-descriptions-files)))
6589 (error "Couldn't request descriptions file"))
6590 (let ((buffer-read-only nil
)
6596 (insert (format " *: %-20s %s\n" (symbol-name group
)
6597 (symbol-value group
)))
6598 (gnus-add-text-properties
6599 b
(1+ b
) (list 'gnus-group group
6600 'gnus-unread t
'gnus-marked nil
6601 'gnus-level
(1+ gnus-level-subscribed
))))
6602 gnus-description-hashtb
)
6603 (goto-char (point-min))
6604 (gnus-group-position-point)))
6606 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6607 (defun gnus-group-apropos (regexp &optional search-description
)
6608 "List all newsgroups that have names that match a regexp."
6609 (interactive "sGnus apropos (regexp): ")
6611 (obuf (current-buffer))
6613 ;; Go through all newsgroups that are known to Gnus.
6616 (and (symbol-name group
)
6617 (string-match regexp
(symbol-name group
))
6618 (setq groups
(cons (symbol-name group
) groups
))))
6620 ;; Also go through all descriptions that are known to Gnus.
6621 (when search-description
6624 (and (string-match regexp
(symbol-value group
))
6625 (gnus-active (symbol-name group
))
6626 (setq groups
(cons (symbol-name group
) groups
))))
6627 gnus-description-hashtb
))
6629 (gnus-message 3 "No groups matched \"%s\"." regexp
)
6630 ;; Print out all the groups.
6632 (pop-to-buffer "*Gnus Help*")
6633 (buffer-disable-undo (current-buffer))
6635 (setq groups
(sort groups
'string
<))
6637 ;; Groups may be entered twice into the list of groups.
6638 (if (not (string= (car groups
) prev
))
6640 (insert (setq prev
(car groups
)) "\n")
6641 (if (and gnus-description-hashtb
6642 (setq des
(gnus-gethash (car groups
)
6643 gnus-description-hashtb
)))
6644 (insert " " des
"\n"))))
6645 (setq groups
(cdr groups
)))
6646 (goto-char (point-min))))
6647 (pop-to-buffer obuf
)))
6649 (defun gnus-group-description-apropos (regexp)
6650 "List all newsgroups that have names or descriptions that match a regexp."
6651 (interactive "sGnus description apropos (regexp): ")
6652 (if (not (or gnus-description-hashtb
6653 (gnus-read-all-descriptions-files)))
6654 (error "Couldn't request descriptions file"))
6655 (gnus-group-apropos regexp t
))
6657 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6658 (defun gnus-group-list-matching (level regexp
&optional all lowest
)
6659 "List all groups with unread articles that match REGEXP.
6660 If the prefix LEVEL is non-nil, it should be a number that says which
6661 level to cut off listing groups.
6662 If ALL, also list groups with no unread articles.
6663 If LOWEST, don't list groups with level lower than LOWEST.
6665 This command may read the active file."
6666 (interactive "P\nsList newsgroups matching: ")
6667 ;; First make sure active file has been read.
6669 (> (prefix-numeric-value level
) gnus-level-killed
))
6670 (gnus-get-killed-groups))
6671 (gnus-group-prepare-flat (or level gnus-level-subscribed
)
6672 all
(or lowest
1) regexp
)
6673 (goto-char (point-min))
6674 (gnus-group-position-point))
6676 (defun gnus-group-list-all-matching (level regexp
&optional lowest
)
6677 "List all groups that match REGEXP.
6678 If the prefix LEVEL is non-nil, it should be a number that says which
6679 level to cut off listing groups.
6680 If LOWEST, don't list groups with level lower than LOWEST."
6681 (interactive "P\nsList newsgroups matching: ")
6682 (gnus-group-list-matching (or level gnus-level-killed
) regexp t lowest
))
6684 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6685 (defun gnus-group-save-newsrc (&optional force
)
6686 "Save the Gnus startup files.
6687 If FORCE, force saving whether it is necessary or not."
6689 (gnus-save-newsrc-file force
))
6691 (defun gnus-group-restart (&optional arg
)
6692 "Force Gnus to read the .newsrc file."
6694 (when (gnus-yes-or-no-p
6695 (format "Are you sure you want to read %s? "
6696 gnus-current-startup-file
))
6697 (gnus-save-newsrc-file)
6698 (gnus-setup-news 'force
)
6699 (gnus-group-list-groups arg
)))
6701 (defun gnus-group-read-init-file ()
6702 "Read the Gnus elisp init file."
6704 (gnus-read-init-file))
6706 (defun gnus-group-check-bogus-groups (&optional silent
)
6707 "Check bogus newsgroups.
6708 If given a prefix, don't ask for confirmation before removing a bogus
6711 (gnus-check-bogus-newsgroups (and (not silent
) (not gnus-expert-user
)))
6712 (gnus-group-list-groups))
6714 (defun gnus-group-edit-global-kill (&optional article group
)
6715 "Edit the global kill file.
6716 If GROUP, edit that local kill file instead."
6718 (setq gnus-current-kill-article article
)
6719 (gnus-kill-file-edit-file group
)
6722 (substitute-command-keys
6723 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6724 (if group
"local" "global")))))
6726 (defun gnus-group-edit-local-kill (article group
)
6727 "Edit a local kill file."
6728 (interactive (list nil
(gnus-group-group-name)))
6729 (gnus-group-edit-global-kill article group
))
6731 (defun gnus-group-force-update ()
6732 "Update `.newsrc' file."
6734 (gnus-save-newsrc-file))
6736 (defun gnus-group-suspend ()
6737 "Suspend the current Gnus session.
6738 In fact, cleanup buffers except for group mode buffer.
6739 The hook gnus-suspend-gnus-hook is called before actually suspending."
6741 (run-hooks 'gnus-suspend-gnus-hook
)
6742 ;; Kill Gnus buffers except for group mode buffer.
6743 (let* ((group-buf (get-buffer gnus-group-buffer
))
6744 ;; Do this on a separate list in case the user does a ^G before we finish
6746 (delete group-buf
(delete gnus-dribble-buffer
6747 (append gnus-buffer-list nil
)))))
6748 (while gnus-buffer-list
6749 (gnus-kill-buffer (pop gnus-buffer-list
)))
6750 (gnus-kill-gnus-frames)
6752 (setq gnus-buffer-list
(list group-buf
))
6753 (bury-buffer group-buf
)
6754 (delete-windows-on group-buf t
))))
6756 (defun gnus-group-clear-dribble ()
6757 "Clear all information from the dribble buffer."
6759 (gnus-dribble-clear)
6760 (gnus-message 7 "Cleared dribble buffer"))
6762 (defun gnus-group-exit ()
6763 "Quit reading news after updating .newsrc.eld and .newsrc.
6764 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6767 (or noninteractive
;For gnus-batch-kill
6768 (not gnus-interactive-exit
) ;Without confirmation
6770 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6771 (run-hooks 'gnus-exit-gnus-hook
)
6772 ;; Offer to save data from non-quitted summary buffers.
6773 (gnus-offer-save-summaries)
6774 ;; Save the newsrc file(s).
6775 (gnus-save-newsrc-file)
6777 (gnus-close-backends)
6778 ;; Reset everything.
6780 ;; Allow the user to do things after cleaning up.
6781 (run-hooks 'gnus-after-exiting-gnus-hook
)))
6783 (defun gnus-close-backends ()
6784 ;; Send a close request to all backends that support such a request.
6785 (let ((methods gnus-valid-select-methods
)
6788 (if (fboundp (setq func
(intern (concat (caar methods
)
6789 "-request-close"))))
6791 (setq methods
(cdr methods
)))))
6793 (defun gnus-group-quit ()
6794 "Quit reading news without updating .newsrc.eld or .newsrc.
6795 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6797 (when (or noninteractive
;For gnus-batch-kill
6798 (zerop (buffer-size))
6799 (not (gnus-server-opened gnus-select-method
))
6801 (not gnus-current-startup-file
)
6803 (format "Quit reading news without saving %s? "
6804 (file-name-nondirectory gnus-current-startup-file
))))
6805 (run-hooks 'gnus-exit-gnus-hook
)
6806 (if gnus-use-full-window
6807 (delete-other-windows)
6808 (gnus-remove-some-windows))
6810 (gnus-close-backends)
6812 ;; Allow the user to do things after cleaning up.
6813 (run-hooks 'gnus-after-exiting-gnus-hook
)))
6815 (defun gnus-offer-save-summaries ()
6816 "Offer to save all active summary buffers."
6818 (let ((buflist (buffer-list))
6820 ;; Go through all buffers and find all summaries.
6822 (and (setq bufname
(buffer-name (car buflist
)))
6823 (string-match "Summary" bufname
)
6825 (set-buffer bufname
)
6826 ;; We check that this is, indeed, a summary buffer.
6827 (and (eq major-mode
'gnus-summary-mode
)
6828 ;; Also make sure this isn't bogus.
6829 gnus-newsgroup-prepared
))
6830 (push bufname buffers
))
6831 (setq buflist
(cdr buflist
)))
6832 ;; Go through all these summary buffers and offer to save them.
6835 "Update summary buffer %s? "
6836 (lambda (buf) (set-buffer buf
) (gnus-summary-exit))
6839 (defun gnus-group-describe-briefly ()
6840 "Give a one line description of the group mode commands."
6842 (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")))
6844 (defun gnus-group-browse-foreign-server (method)
6845 "Browse a foreign news server.
6846 If called interactively, this function will ask for a select method
6847 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6848 If not, METHOD should be a list where the first element is the method
6849 and the second element is the address."
6851 (list (let ((how (completing-read
6853 (append gnus-valid-select-methods gnus-server-alist
)
6854 nil t
(cons "nntp" 0) 'gnus-method-history
)))
6855 ;; We either got a backend name or a virtual server name.
6856 ;; If the first, we also need an address.
6857 (if (assoc how gnus-valid-select-methods
)
6859 ;; Suggested by mapjph@bath.ac.uk.
6862 (mapcar (lambda (server) (list server
))
6863 gnus-secondary-servers
)))
6864 ;; We got a server name, so we find the method.
6865 (gnus-server-to-method how
)))))
6866 (gnus-browse-foreign-server method
))
6870 ;;; Gnus summary mode
6873 (defvar gnus-summary-mode-map nil
)
6875 (put 'gnus-summary-mode
'mode-class
'special
)
6877 (unless gnus-summary-mode-map
6878 (setq gnus-summary-mode-map
(make-keymap))
6879 (suppress-keymap gnus-summary-mode-map
)
6881 ;; Non-orthogonal keys
6883 (gnus-define-keys gnus-summary-mode-map
6884 " " gnus-summary-next-page
6885 "\177" gnus-summary-prev-page
6886 [delete] gnus-summary-prev-page
6887 "\r" gnus-summary-scroll-up
6888 "n" gnus-summary-next-unread-article
6889 "p" gnus-summary-prev-unread-article
6890 "N" gnus-summary-next-article
6891 "P" gnus-summary-prev-article
6892 "\M-\C-n" gnus-summary-next-same-subject
6893 "\M-\C-p" gnus-summary-prev-same-subject
6894 "\M-n" gnus-summary-next-unread-subject
6895 "\M-p" gnus-summary-prev-unread-subject
6896 "." gnus-summary-first-unread-article
6897 "," gnus-summary-best-unread-article
6898 "\M-s" gnus-summary-search-article-forward
6899 "\M-r" gnus-summary-search-article-backward
6900 "<" gnus-summary-beginning-of-article
6901 ">" gnus-summary-end-of-article
6902 "j" gnus-summary-goto-article
6903 "^" gnus-summary-refer-parent-article
6904 "\M-^" gnus-summary-refer-article
6905 "u" gnus-summary-tick-article-forward
6906 "!" gnus-summary-tick-article-forward
6907 "U" gnus-summary-tick-article-backward
6908 "d" gnus-summary-mark-as-read-forward
6909 "D" gnus-summary-mark-as-read-backward
6910 "E" gnus-summary-mark-as-expirable
6911 "\M-u" gnus-summary-clear-mark-forward
6912 "\M-U" gnus-summary-clear-mark-backward
6913 "k" gnus-summary-kill-same-subject-and-select
6914 "\C-k" gnus-summary-kill-same-subject
6915 "\M-\C-k" gnus-summary-kill-thread
6916 "\M-\C-l" gnus-summary-lower-thread
6917 "e" gnus-summary-edit-article
6918 "#" gnus-summary-mark-as-processable
6919 "\M-#" gnus-summary-unmark-as-processable
6920 "\M-\C-t" gnus-summary-toggle-threads
6921 "\M-\C-s" gnus-summary-show-thread
6922 "\M-\C-h" gnus-summary-hide-thread
6923 "\M-\C-f" gnus-summary-next-thread
6924 "\M-\C-b" gnus-summary-prev-thread
6925 "\M-\C-u" gnus-summary-up-thread
6926 "\M-\C-d" gnus-summary-down-thread
6927 "&" gnus-summary-execute-command
6928 "c" gnus-summary-catchup-and-exit
6929 "\C-w" gnus-summary-mark-region-as-read
6930 "\C-t" gnus-summary-toggle-truncation
6931 "?" gnus-summary-mark-as-dormant
6932 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6933 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6934 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6935 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6936 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6937 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6938 "=" gnus-summary-expand-window
6939 "\C-x\C-s" gnus-summary-reselect-current-group
6940 "\M-g" gnus-summary-rescan-group
6941 "w" gnus-summary-stop-page-breaking
6942 "\C-c\C-r" gnus-summary-caesar-message
6943 "\M-t" gnus-summary-toggle-mime
6944 "f" gnus-summary-followup
6945 "F" gnus-summary-followup-with-original
6946 "C" gnus-summary-cancel-article
6947 "r" gnus-summary-reply
6948 "R" gnus-summary-reply-with-original
6949 "\C-c\C-f" gnus-summary-mail-forward
6950 "o" gnus-summary-save-article
6951 "\C-o" gnus-summary-save-article-mail
6952 "|" gnus-summary-pipe-output
6953 "\M-k" gnus-summary-edit-local-kill
6954 "\M-K" gnus-summary-edit-global-kill
6956 "\C-c\C-d" gnus-summary-describe-group
6957 "q" gnus-summary-exit
6958 "Q" gnus-summary-exit-no-update
6959 "\C-c\C-i" gnus-info-find-node
6960 gnus-mouse-2 gnus-mouse-pick-article
6961 "m" gnus-summary-mail-other-window
6962 "a" gnus-summary-post-news
6963 "x" gnus-summary-limit-to-unread
6964 "s" gnus-summary-isearch-article
6965 "t" gnus-article-hide-headers
6966 "g" gnus-summary-show-article
6967 "l" gnus-summary-goto-last-article
6968 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6969 "\C-d" gnus-summary-enter-digest-group
6971 "*" gnus-cache-enter-article
6972 "\M-*" gnus-cache-remove-article
6973 "\M-&" gnus-summary-universal-argument
6974 "\C-l" gnus-recenter
6975 "I" gnus-summary-increase-score
6976 "L" gnus-summary-lower-score
6978 "V" gnus-summary-score-map
6979 "X" gnus-uu-extract-map
6980 "S" gnus-summary-send-map)
6982 ;; Sort of orthogonal keymap
6983 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6984 "t" gnus-summary-tick-article-forward
6985 "!" gnus-summary-tick-article-forward
6986 "d" gnus-summary-mark-as-read-forward
6987 "r" gnus-summary-mark-as-read-forward
6988 "c" gnus-summary-clear-mark-forward
6989 " " gnus-summary-clear-mark-forward
6990 "e" gnus-summary-mark-as-expirable
6991 "x" gnus-summary-mark-as-expirable
6992 "?" gnus-summary-mark-as-dormant
6993 "b" gnus-summary-set-bookmark
6994 "B" gnus-summary-remove-bookmark
6995 "#" gnus-summary-mark-as-processable
6996 "\M-#" gnus-summary-unmark-as-processable
6997 "S" gnus-summary-limit-include-expunged
6998 "C" gnus-summary-catchup
6999 "H" gnus-summary-catchup-to-here
7000 "\C-c" gnus-summary-catchup-all
7001 "k" gnus-summary-kill-same-subject-and-select
7002 "K" gnus-summary-kill-same-subject
7003 "P" gnus-uu-mark-map)
7005 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7006 "c" gnus-summary-clear-above
7007 "u" gnus-summary-tick-above
7008 "m" gnus-summary-mark-above
7009 "k" gnus-summary-kill-below)
7011 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7012 "/" gnus-summary-limit-to-subject
7013 "n" gnus-summary-limit-to-articles
7014 "w" gnus-summary-pop-limit
7015 "s" gnus-summary-limit-to-subject
7016 "a" gnus-summary-limit-to-author
7017 "u" gnus-summary-limit-to-unread
7018 "m" gnus-summary-limit-to-marks
7019 "v" gnus-summary-limit-to-score
7020 "D" gnus-summary-limit-include-dormant
7021 "d" gnus-summary-limit-exclude-dormant
7022 ;; "t" gnus-summary-limit-exclude-thread
7023 "E" gnus-summary-limit-include-expunged
7024 "c" gnus-summary-limit-exclude-childless-dormant
7025 "C" gnus-summary-limit-mark-excluded-as-read)
7027 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7028 "n" gnus-summary-next-unread-article
7029 "p" gnus-summary-prev-unread-article
7030 "N" gnus-summary-next-article
7031 "P" gnus-summary-prev-article
7032 "\C-n" gnus-summary-next-same-subject
7033 "\C-p" gnus-summary-prev-same-subject
7034 "\M-n" gnus-summary-next-unread-subject
7035 "\M-p" gnus-summary-prev-unread-subject
7036 "f" gnus-summary-first-unread-article
7037 "b" gnus-summary-best-unread-article
7038 "j" gnus-summary-goto-article
7039 "g" gnus-summary-goto-subject
7040 "l" gnus-summary-goto-last-article
7041 "p" gnus-summary-pop-article)
7043 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7044 "k" gnus-summary-kill-thread
7045 "l" gnus-summary-lower-thread
7046 "i" gnus-summary-raise-thread
7047 "T" gnus-summary-toggle-threads
7048 "t" gnus-summary-rethread-current
7049 "^" gnus-summary-reparent-thread
7050 "s" gnus-summary-show-thread
7051 "S" gnus-summary-show-all-threads
7052 "h" gnus-summary-hide-thread
7053 "H" gnus-summary-hide-all-threads
7054 "n" gnus-summary-next-thread
7055 "p" gnus-summary-prev-thread
7056 "u" gnus-summary-up-thread
7057 "o" gnus-summary-top-thread
7058 "d" gnus-summary-down-thread
7059 "#" gnus-uu-mark-thread
7060 "\M-#" gnus-uu-unmark-thread)
7062 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7063 "c" gnus-summary-catchup-and-exit
7064 "C" gnus-summary-catchup-all-and-exit
7065 "E" gnus-summary-exit-no-update
7066 "Q" gnus-summary-exit
7067 "Z" gnus-summary-exit
7068 "n" gnus-summary-catchup-and-goto-next-group
7069 "R" gnus-summary-reselect-current-group
7070 "G" gnus-summary-rescan-group
7071 "N" gnus-summary-next-group
7072 "P" gnus-summary-prev-group)
7074 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7075 " " gnus-summary-next-page
7076 "n" gnus-summary-next-page
7077 "\177" gnus-summary-prev-page
7078 [delete] gnus-summary-prev-page
7079 "p" gnus-summary-prev-page
7080 "\r" gnus-summary-scroll-up
7081 "<" gnus-summary-beginning-of-article
7082 ">" gnus-summary-end-of-article
7083 "b" gnus-summary-beginning-of-article
7084 "e" gnus-summary-end-of-article
7085 "^" gnus-summary-refer-parent-article
7086 "r" gnus-summary-refer-parent-article
7087 "R" gnus-summary-refer-references
7088 "g" gnus-summary-show-article
7089 "s" gnus-summary-isearch-article
)
7091 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map
)
7092 "b" gnus-article-add-buttons
7093 "B" gnus-article-add-buttons-to-head
7094 "o" gnus-article-treat-overstrike
7095 ;; "w" gnus-article-word-wrap
7096 "w" gnus-article-fill-cited-article
7097 "c" gnus-article-remove-cr
7098 "L" gnus-article-remove-trailing-blank-lines
7099 "q" gnus-article-de-quoted-unreadable
7100 "f" gnus-article-display-x-face
7101 "l" gnus-summary-stop-page-breaking
7102 "r" gnus-summary-caesar-message
7103 "t" gnus-article-hide-headers
7104 "v" gnus-summary-verbose-headers
7105 "m" gnus-summary-toggle-mime
)
7107 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map
)
7108 "a" gnus-article-hide
7109 "h" gnus-article-hide-headers
7110 "b" gnus-article-hide-boring-headers
7111 "s" gnus-article-hide-signature
7112 "c" gnus-article-hide-citation
7113 "p" gnus-article-hide-pgp
7114 "\C-c" gnus-article-hide-citation-maybe
)
7116 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map
)
7117 "a" gnus-article-highlight
7118 "h" gnus-article-highlight-headers
7119 "c" gnus-article-highlight-citation
7120 "s" gnus-article-highlight-signature
)
7122 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map
)
7123 "z" gnus-article-date-ut
7124 "u" gnus-article-date-ut
7125 "l" gnus-article-date-local
7126 "e" gnus-article-date-lapsed
7127 "o" gnus-article-date-original
)
7129 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map
)
7131 "f" gnus-summary-fetch-faq
7132 "d" gnus-summary-describe-group
7133 "h" gnus-summary-describe-briefly
7134 "i" gnus-info-find-node
)
7136 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map
)
7137 "e" gnus-summary-expire-articles
7138 "\M-\C-e" gnus-summary-expire-articles-now
7139 "\177" gnus-summary-delete-article
7140 [delete] gnus-summary-delete-article
7141 "m" gnus-summary-move-article
7142 "r" gnus-summary-respool-article
7143 "w" gnus-summary-edit-article
7144 "c" gnus-summary-copy-article
7145 "B" gnus-summary-crosspost-article
7146 "q" gnus-summary-respool-query
7147 "i" gnus-summary-import-article)
7149 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7150 "o" gnus-summary-save-article
7151 "m" gnus-summary-save-article-mail
7152 "r" gnus-summary-save-article-rmail
7153 "f" gnus-summary-save-article-file
7154 "b" gnus-summary-save-article-body-file
7155 "h" gnus-summary-save-article-folder
7156 "v" gnus-summary-save-article-vm
7157 "p" gnus-summary-pipe-output
7158 "s" gnus-soup-add-article)
7163 (defun gnus-summary-mode (&optional group)
7164 "Major mode for reading articles.
7166 All normal editing commands are switched off.
7167 \\<gnus-summary-mode-map>
7168 Each line in this buffer represents one article. To read an
7169 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7170 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7173 You can also post articles and send mail from this buffer. To
7174 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7175 of an article, type `\\[gnus-summary-reply]'.
7177 There are approx. one gazillion commands you can execute in this
7178 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7180 The following commands are available:
7182 \\{gnus-summary-mode-map}"
7184 (when (and menu-bar-mode
7185 (gnus-visual-p 'summary-menu 'menu))
7186 (gnus-summary-make-menu-bar))
7187 (kill-all-local-variables)
7188 (gnus-summary-make-local-variables)
7189 (gnus-make-thread-indent-array)
7190 (gnus-simplify-mode-line)
7191 (setq major-mode 'gnus-summary-mode)
7192 (setq mode-name "Summary")
7193 (make-local-variable 'minor-mode-alist)
7194 (use-local-map gnus-summary-mode-map)
7195 (buffer-disable-undo (current-buffer))
7196 (setq buffer-read-only t) ;Disable modification
7197 (setq truncate-lines t)
7198 (setq selective-display t)
7199 (setq selective-display-ellipses t) ;Display `...'
7200 (setq buffer-display-table gnus-summary-display-table)
7201 (setq gnus-newsgroup-name group)
7202 (make-local-variable 'gnus-summary-line-format)
7203 (make-local-variable 'gnus-summary-line-format-spec)
7204 (make-local-variable 'gnus-summary-mark-positions)
7205 (run-hooks 'gnus-summary-mode-hook))
7207 (defun gnus-summary-make-local-variables ()
7208 "Make all the local summary buffer variables."
7209 (let ((locals gnus-summary-local-variables)
7211 (while (setq local (pop locals))
7214 (if (eq (cdr local) 'global)
7215 ;; Copy the global value of the variable.
7216 (setq global (symbol-value (car local)))
7217 ;; Use the value from the list.
7218 (setq global (eval (cdr local))))
7219 (make-local-variable (car local))
7220 (set (car local) global))
7221 ;; Simple nil-valued local variable.
7222 (make-local-variable local)
7225 (defun gnus-summary-make-display-table ()
7226 ;; Change the display table. Odd characters have a tendency to mess
7227 ;; up nicely formatted displays - we make all possible glyphs
7228 ;; display only a single character.
7230 ;; We start from the standard display table, if any.
7231 (setq gnus-summary-display-table
7232 (or (copy-sequence standard-display-table)
7233 (make-display-table)))
7234 ;; Nix out all the control chars...
7236 (while (>= (setq i (1- i)) 0)
7237 (aset gnus-summary-display-table i [??])))
7238 ;; ... but not newline and cr, of course. (cr is necessary for the
7239 ;; selective display).
7240 (aset gnus-summary-display-table ?\n nil)
7241 (aset gnus-summary-display-table ?\r nil)
7242 ;; We nix out any glyphs over 126 that are not set already.
7244 (while (>= (setq i (1- i)) 127)
7245 ;; Only modify if the entry is nil.
7246 (or (aref gnus-summary-display-table i)
7247 (aset gnus-summary-display-table i [??])))))
7249 (defun gnus-summary-clear-local-variables ()
7250 (let ((locals gnus-summary-local-variables))
7252 (if (consp (car locals))
7253 (and (vectorp (caar locals))
7254 (set (caar locals) nil))
7255 (and (vectorp (car locals))
7256 (set (car locals) nil)))
7257 (setq locals (cdr locals)))))
7259 ;; Summary data functions.
7261 (defmacro gnus-data-number (data)
7264 (defmacro gnus-data-set-number (data number)
7265 `(setcar ,data ,number))
7267 (defmacro gnus-data-mark (data)
7270 (defmacro gnus-data-set-mark (data mark)
7271 `(setcar (nthcdr 1 ,data) ,mark))
7273 (defmacro gnus-data-pos (data)
7276 (defmacro gnus-data-set-pos (data pos)
7277 `(setcar (nthcdr 2 ,data) ,pos))
7279 (defmacro gnus-data-header (data)
7282 (defmacro gnus-data-level (data)
7285 (defmacro gnus-data-unread-p (data)
7286 `(= (nth 1 ,data) gnus-unread-mark))
7288 (defmacro gnus-data-pseudo-p (data)
7289 `(consp (nth 3 ,data)))
7291 (defmacro gnus-data-find (number)
7292 `(assq ,number gnus-newsgroup-data))
7294 (defmacro gnus-data-find-list (number &optional data)
7295 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7296 (memq (assq ,number bdata)
7299 (defmacro gnus-data-make (number mark pos header level)
7300 `(list ,number ,mark ,pos ,header ,level))
7302 (defun gnus-data-enter (after-article number mark pos header level offset)
7303 (let ((data (gnus-data-find-list after-article)))
7304 (or data (error "No such article: %d" after-article))
7305 (setcdr data (cons (gnus-data-make number mark pos header level)
7307 (setq gnus-newsgroup-data-reverse nil)
7308 (gnus-data-update-list (cddr data) offset)))
7310 (defun gnus-data-enter-list (after-article list &optional offset)
7312 (let ((data (and after-article (gnus-data-find-list after-article)))
7314 (or data (not after-article) (error "No such article: %d" after-article))
7315 ;; Find the last element in the list to be spliced into the main
7318 (setq list (cdr list)))
7321 (setcdr list gnus-newsgroup-data)
7322 (setq gnus-newsgroup-data ilist)
7323 (and offset (gnus-data-update-list (cdr list) offset)))
7324 (setcdr list (cdr data))
7326 (and offset (gnus-data-update-list (cdr data) offset)))
7327 (setq gnus-newsgroup-data-reverse nil))))
7329 (defun gnus-data-remove (article &optional offset)
7330 (let ((data gnus-newsgroup-data))
7331 (if (= (gnus-data-number (car data)) article)
7332 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7333 gnus-newsgroup-data-reverse nil)
7335 (and (= (gnus-data-number (cadr data)) article)
7337 (setcdr data (cddr data))
7338 (and offset (gnus-data-update-list (cdr data) offset))
7340 gnus-newsgroup-data-reverse nil)))
7341 (setq data (cdr data))))))
7343 (defmacro gnus-data-list (backward)
7345 (or gnus-newsgroup-data-reverse
7346 (setq gnus-newsgroup-data-reverse
7347 (reverse gnus-newsgroup-data)))
7348 gnus-newsgroup-data))
7350 (defun gnus-data-update-list (data offset)
7351 "Add OFFSET to the POS of all data entries in DATA."
7353 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7354 (setq data (cdr data))))
7356 (defun gnus-data-compute-positions ()
7357 "Compute the positions of all articles."
7358 (let ((data gnus-newsgroup-data)
7361 (when (setq pos (text-property-any
7362 (point-min) (point-max)
7363 'gnus-number (gnus-data-number (car data))))
7364 (gnus-data-set-pos (car data) (+ pos 3)))
7365 (setq data (cdr data)))))
7367 (defun gnus-summary-article-pseudo-p (article)
7368 "Say whether this article is a pseudo article or not."
7369 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7371 (defun gnus-article-parent-p (number)
7372 "Say whether this article is a parent or not."
7373 (let ((data (gnus-data-find-list number)))
7374 (and (cdr data) ; There has to be an article after...
7375 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7376 (gnus-data-level (nth 1 data))))))
7378 (defun gnus-article-children (number)
7379 "Return a list of all children to NUMBER."
7380 (let* ((data (gnus-data-find-list number))
7381 (level (gnus-data-level (car data)))
7383 (setq data (cdr data))
7385 (= (gnus-data-level (car data)) (1+ level)))
7386 (push (gnus-data-number (car data)) children)
7387 (setq data (cdr data)))
7390 (defmacro gnus-summary-skip-intangible ()
7391 "If the current article is intangible, then jump to a different article."
7392 '(let ((to (get-text-property (point) 'gnus-intangible)))
7393 (and to (gnus-summary-goto-subject to))))
7395 (defmacro gnus-summary-article-intangible-p ()
7396 "Say whether this article is intangible or not."
7397 '(get-text-property (point) 'gnus-intangible))
7399 ;; Some summary mode macros.
7401 (defmacro gnus-summary-article-number ()
7402 "The article number of the article on the current line.
7403 If there isn's an article number here, then we return the current
7406 (gnus-summary-skip-intangible)
7407 (or (get-text-property (point) 'gnus-number)
7408 (gnus-summary-last-subject))))
7410 (defmacro gnus-summary-article-header (&optional number)
7411 `(gnus-data-header (gnus-data-find
7412 ,(or number '(gnus-summary-article-number)))))
7414 (defmacro gnus-summary-thread-level (&optional number)
7415 `(if (and (eq gnus-summary-make-false-root 'dummy)
7416 (get-text-property (point) 'gnus-intangible))
7418 (gnus-data-level (gnus-data-find
7419 ,(or number '(gnus-summary-article-number))))))
7421 (defmacro gnus-summary-article-mark (&optional number)
7422 `(gnus-data-mark (gnus-data-find
7423 ,(or number '(gnus-summary-article-number)))))
7425 (defmacro gnus-summary-article-pos (&optional number)
7426 `(gnus-data-pos (gnus-data-find
7427 ,(or number '(gnus-summary-article-number)))))
7429 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7430 (defmacro gnus-summary-article-subject (&optional number)
7431 "Return current subject string or nil if nothing."
7434 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7435 '(gnus-data-header (assq (gnus-summary-article-number)
7436 gnus-newsgroup-data)))))
7439 (mail-header-subject headers))))
7441 (defmacro gnus-summary-article-score (&optional number)
7442 "Return current article score."
7443 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7444 gnus-newsgroup-scored))
7445 gnus-summary-default-score 0))
7447 (defun gnus-summary-article-children (&optional number)
7448 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7449 (level (gnus-data-level (car data)))
7451 (while (and (setq data (cdr data))
7452 (> (setq l (gnus-data-level (car data))) level))
7453 (and (= (1+ level) l)
7454 (setq children (cons (gnus-data-number (car data))
7456 (nreverse children)))
7458 (defun gnus-summary-article-parent (&optional number)
7459 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7460 (gnus-data-list t)))
7461 (level (gnus-data-level (car data))))
7463 () ; This is a root.
7464 ;; We search until we find an article with a level less than
7465 ;; this one. That function has to be the parent.
7466 (while (and (setq data (cdr data))
7467 (not (< (gnus-data-level (car data)) level))))
7468 (and data (gnus-data-number (car data))))))
7470 (defun gnus-unread-mark-p (mark)
7471 "Say whether MARK is the unread mark."
7472 (= mark gnus-unread-mark))
7474 (defun gnus-read-mark-p (mark)
7475 "Say whether MARK is one of the marks that mark as read.
7476 This is all marks except unread, ticked, dormant, and expirable."
7477 (not (or (= mark gnus-unread-mark)
7478 (= mark gnus-ticked-mark)
7479 (= mark gnus-dormant-mark)
7480 (= mark gnus-expirable-mark))))
7482 ;; Saving hidden threads.
7484 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7485 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7486 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7488 (defmacro gnus-save-hidden-threads (&rest forms)
7489 "Save hidden threads, eval FORMS, and restore the hidden threads."
7490 (let ((config (make-symbol "config")))
7491 `(let ((,config (gnus-hidden-threads-configuration)))
7495 (gnus-restore-hidden-threads-configuration ,config)))))
7497 (defun gnus-hidden-threads-configuration ()
7498 "Return the current hidden threads configuration."
7501 (goto-char (point-min))
7502 (while (search-forward "\r" nil t)
7503 (push (1- (point)) config))
7506 (defun gnus-restore-hidden-threads-configuration (config)
7507 "Restore hidden threads configuration from CONFIG."
7508 (let (point buffer-read-only)
7509 (while (setq point (pop config))
7510 (when (and (< point (point-max))
7512 (= (following-char) ?\n))
7513 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7515 ;; Various summary mode internalish functions.
7517 (defun gnus-mouse-pick-article (e)
7520 (gnus-summary-next-page nil t))
7522 (defun gnus-summary-setup-buffer (group)
7523 "Initialize summary buffer."
7524 (let ((buffer (concat "*Summary " group "*")))
7525 (if (get-buffer buffer)
7528 (setq gnus-summary-buffer (current-buffer))
7529 (not gnus-newsgroup-prepared))
7530 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7531 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7532 (gnus-add-current-to-buffer-list)
7533 (gnus-summary-mode group)
7535 (gnus-carpal-setup-buffer 'summary))
7536 (unless gnus-single-article-buffer
7537 (make-local-variable 'gnus-article-buffer)
7538 (make-local-variable 'gnus-article-current)
7539 (make-local-variable 'gnus-original-article-buffer))
7540 (setq gnus-newsgroup-name group)
7543 (defun gnus-set-global-variables ()
7544 ;; Set the global equivalents of the summary buffer-local variables
7545 ;; to the latest values they had. These reflect the summary buffer
7546 ;; that was in action when the last article was fetched.
7547 (when (eq major-mode 'gnus-summary-mode)
7548 (setq gnus-summary-buffer (current-buffer))
7549 (let ((name gnus-newsgroup-name)
7550 (marked gnus-newsgroup-marked)
7551 (unread gnus-newsgroup-unreads)
7552 (headers gnus-current-headers)
7553 (data gnus-newsgroup-data)
7554 (summary gnus-summary-buffer)
7555 (article-buffer gnus-article-buffer)
7556 (original gnus-original-article-buffer)
7557 (gac gnus-article-current)
7558 (score-file gnus-current-score-file))
7560 (set-buffer gnus-group-buffer)
7561 (setq gnus-newsgroup-name name)
7562 (setq gnus-newsgroup-marked marked)
7563 (setq gnus-newsgroup-unreads unread)
7564 (setq gnus-current-headers headers)
7565 (setq gnus-newsgroup-data data)
7566 (setq gnus-article-current gac)
7567 (setq gnus-summary-buffer summary)
7568 (setq gnus-article-buffer article-buffer)
7569 (setq gnus-original-article-buffer original)
7570 (setq gnus-current-score-file score-file)))))
7572 (defun gnus-summary-last-article-p (&optional article)
7573 "Return whether ARTICLE is the last article in the buffer."
7574 (if (not (setq article (or article (gnus-summary-article-number))))
7575 t ; All non-existant numbers are the last article. :-)
7576 (not (cdr (gnus-data-find-list article)))))
7578 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7579 "Insert a dummy root in the summary buffer."
7581 (gnus-add-text-properties
7582 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7583 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7585 (defun gnus-make-thread-indent-array ()
7587 (unless (and gnus-thread-indent-array
7588 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7589 (setq gnus-thread-indent-array (make-vector 201 "")
7590 gnus-thread-indent-array-level gnus-thread-indent-level)
7592 (aset gnus-thread-indent-array n
7593 (make-string (* n gnus-thread-indent-level) ? ))
7596 (defun gnus-summary-insert-line
7597 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7598 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7599 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7600 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7601 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7602 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7603 (gnus-tmp-score-char
7604 (if (or (null gnus-summary-default-score)
7605 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7606 gnus-summary-zcore-fuzz)) ?
7607 (if (< gnus-tmp-score gnus-summary-default-score)
7608 gnus-score-below-mark gnus-score-over-mark)))
7609 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7610 ((memq gnus-tmp-current gnus-newsgroup-cached)
7612 (gnus-tmp-replied gnus-replied-mark)
7613 ((memq gnus-tmp-current gnus-newsgroup-saved)
7615 (t gnus-unread-mark)))
7616 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7619 ((string-match "(.+)" gnus-tmp-from)
7620 (substring gnus-tmp-from
7621 (1+ (match-beginning 0)) (1- (match-end 0))))
7622 ((string-match "<[^>]+> *$" gnus-tmp-from)
7623 (let ((beg (match-beginning 0)))
7624 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7625 (substring gnus-tmp-from (1+ (match-beginning 0))
7626 (1- (match-end 0))))
7627 (substring gnus-tmp-from 0 beg))))
7629 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7630 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7631 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7632 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7633 (buffer-read-only nil))
7634 (when (string= gnus-tmp-name "")
7635 (setq gnus-tmp-name gnus-tmp-from))
7636 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7637 (gnus-put-text-property
7639 (progn (eval gnus-summary-line-format-spec) (point))
7640 'gnus-number gnus-tmp-number)
7641 (when (gnus-visual-p 'summary-highlight 'highlight)
7643 (run-hooks 'gnus-summary-update-hook)
7646 (defun gnus-summary-update-line (&optional dont-update)
7647 ;; Update summary line after change.
7648 (when (and gnus-summary-default-score
7649 (not gnus-summary-inhibit-highlight))
7650 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7651 (article (gnus-summary-article-number))
7652 (score (gnus-summary-article-score article)))
7654 (if (and gnus-summary-mark-below
7655 (< (gnus-summary-article-score)
7656 gnus-summary-mark-below))
7657 ;; This article has a low score, so we mark it as read.
7658 (when (memq article gnus-newsgroup-unreads)
7659 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7660 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7661 ;; This article was previously marked as read on account
7662 ;; of a low score, but now it has risen, so we mark it as
7664 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7665 (gnus-summary-update-mark
7666 (if (or (null gnus-summary-default-score)
7667 (<= (abs (- score gnus-summary-default-score))
7668 gnus-summary-zcore-fuzz)) ?
7669 (if (< score gnus-summary-default-score)
7670 gnus-score-below-mark gnus-score-over-mark)) 'score))
7671 ;; Do visual highlighting.
7672 (when (gnus-visual-p 'summary-highlight 'highlight)
7673 (run-hooks 'gnus-summary-update-hook)))))
7675 (defvar gnus-tmp-new-adopts nil)
7677 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7678 ;; Sum up all elements (and sub-elements) in a list.
7680 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7682 ((and (consp thread) (cdr thread))
7685 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7688 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7691 (when (and level (zerop level) gnus-tmp-new-adopts)
7694 'gnus-summary-number-of-articles-in-thread
7695 gnus-tmp-new-adopts))))
7697 (if (> number 1) gnus-not-empty-thread-mark
7698 gnus-empty-thread-mark)
7701 (defun gnus-summary-set-local-parameters (group)
7702 "Go through the local params of GROUP and set all variable specs in that list."
7703 (let ((params (gnus-info-params (gnus-get-info group)))
7706 (setq elem (car params)
7707 params (cdr params))
7708 (and (consp elem) ; Has to be a cons.
7709 (consp (cdr elem)) ; The cdr has to be a list.
7710 (symbolp (car elem)) ; Has to be a symbol in there.
7711 (not (memq (car elem)
7712 '(quit-config to-address to-list to-group)))
7713 (progn ; So we set it.
7714 (make-local-variable (car elem))
7715 (set (car elem) (eval (nth 1 elem))))))))
7717 (defun gnus-summary-read-group (group &optional show-all no-article
7718 kill-buffer no-display)
7719 "Start reading news in newsgroup GROUP.
7720 If SHOW-ALL is non-nil, already read articles are also listed.
7721 If NO-ARTICLE is non-nil, no article is selected initially.
7722 If NO-DISPLAY, don't generate a summary buffer."
7723 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7724 (let* ((new-group (gnus-summary-setup-buffer group))
7725 (quit-config (gnus-group-quit-config group))
7726 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7728 ;; This summary buffer exists already, so we just select it.
7730 (gnus-set-global-variables)
7732 (gnus-kill-or-deaden-summary kill-buffer))
7733 (gnus-configure-windows 'summary 'force)
7734 (gnus-set-mode-line 'summary)
7735 (gnus-summary-position-point)
7738 ;; We couldn't select this group.
7740 (when (and (eq major-mode 'gnus-summary-mode)
7741 (not (equal (current-buffer) kill-buffer)))
7742 (kill-buffer (current-buffer))
7743 (if (not quit-config)
7745 (set-buffer gnus-group-buffer)
7746 (gnus-group-jump-to-group group)
7747 (gnus-group-next-unread-group 1))
7748 (if (not (buffer-name (car quit-config)))
7749 (gnus-configure-windows 'group 'force)
7750 (set-buffer (car quit-config))
7751 (and (eq major-mode 'gnus-summary-mode)
7752 (gnus-set-global-variables))
7753 (gnus-configure-windows (cdr quit-config)))))
7754 (gnus-message 3 "Can't select group")
7756 ;; The user did a `C-g' while prompting for number of articles,
7757 ;; so we exit this group.
7758 ((eq did-select 'quit)
7759 (and (eq major-mode 'gnus-summary-mode)
7760 (not (equal (current-buffer) kill-buffer))
7761 (kill-buffer (current-buffer)))
7763 (gnus-kill-or-deaden-summary kill-buffer))
7764 (if (not quit-config)
7766 (set-buffer gnus-group-buffer)
7767 (gnus-group-jump-to-group group)
7768 (gnus-group-next-unread-group 1)
7769 (gnus-configure-windows 'group 'force))
7770 (if (not (buffer-name (car quit-config)))
7771 (gnus-configure-windows 'group 'force)
7772 (set-buffer (car quit-config))
7773 (and (eq major-mode 'gnus-summary-mode)
7774 (gnus-set-global-variables))
7775 (gnus-configure-windows (cdr quit-config))))
7776 ;; Finally signal the quit.
7778 ;; The group was successfully selected.
7780 (gnus-set-global-variables)
7781 ;; Save the active value in effect when the group was entered.
7782 (setq gnus-newsgroup-active
7784 (gnus-active gnus-newsgroup-name)))
7785 ;; You can change the summary buffer in some way with this hook.
7786 (run-hooks 'gnus-select-group-hook)
7787 ;; Set any local variables in the group parameters.
7788 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7789 (gnus-update-format-specifications)
7790 ;; Do score processing.
7791 (when gnus-use-scoring
7792 (gnus-possibly-score-headers))
7793 ;; Check whether to fill in the gaps in the threads.
7794 (when gnus-build-sparse-threads
7795 (gnus-build-sparse-threads))
7796 ;; Find the initial limit.
7797 (if gnus-show-threads
7799 (let ((gnus-newsgroup-dormant nil))
7800 (gnus-summary-initial-limit show-all))
7801 (gnus-summary-initial-limit show-all))
7802 (setq gnus-newsgroup-limit
7804 (lambda (header) (mail-header-number header))
7805 gnus-newsgroup-headers)))
7806 ;; Generate the summary buffer.
7808 (gnus-summary-prepare))
7809 (when gnus-use-trees
7810 (gnus-tree-open group)
7811 (setq gnus-summary-highlight-line-function
7812 'gnus-tree-highlight-article))
7813 ;; If the summary buffer is empty, but there are some low-scored
7814 ;; articles or some excluded dormants, we include these in the
7816 (when (and (zerop (buffer-size))
7818 (cond (gnus-newsgroup-dormant
7819 (gnus-summary-limit-include-dormant))
7820 ((and gnus-newsgroup-scored show-all)
7821 (gnus-summary-limit-include-expunged))))
7822 ;; Function `gnus-apply-kill-file' must be called in this hook.
7823 (run-hooks 'gnus-apply-kill-hook)
7824 (if (and (zerop (buffer-size))
7827 ;; This newsgroup is empty.
7828 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7829 (gnus-message 6 "No unread news")
7831 (gnus-kill-or-deaden-summary kill-buffer))
7832 ;; Return nil from this function.
7834 ;; Hide conversation thread subtrees. We cannot do this in
7835 ;; gnus-summary-prepare-hook since kill processing may not
7836 ;; work with hidden articles.
7837 (and gnus-show-threads
7838 gnus-thread-hide-subtree
7839 (gnus-summary-hide-all-threads))
7840 ;; Show first unread article if requested.
7841 (if (and (not no-article)
7843 gnus-newsgroup-unreads
7844 gnus-auto-select-first)
7845 (unless (if (eq gnus-auto-select-first 'best)
7846 (gnus-summary-best-unread-article)
7847 (gnus-summary-first-unread-article))
7848 (gnus-configure-windows 'summary))
7849 ;; Don't select any articles, just move point to the first
7850 ;; article in the group.
7851 (goto-char (point-min))
7852 (gnus-summary-position-point)
7853 (gnus-set-mode-line 'summary)
7854 (gnus-configure-windows 'summary 'force))
7855 ;; If we are in async mode, we send some info to the backend.
7856 (when gnus-newsgroup-async
7857 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7859 (gnus-kill-or-deaden-summary kill-buffer))
7860 (when (get-buffer-window gnus-group-buffer t)
7861 ;; Gotta use windows, because recenter does wierd stuff if
7862 ;; the current buffer ain't the displayed window.
7863 (let ((owin (selected-window)))
7864 (select-window (get-buffer-window gnus-group-buffer t))
7865 (when (gnus-group-goto-group group)
7867 (select-window owin))))
7868 ;; Mark this buffer as "prepared".
7869 (setq gnus-newsgroup-prepared t)
7872 (defun gnus-summary-prepare ()
7873 "Generate the summary buffer."
7874 (let ((buffer-read-only nil))
7876 (setq gnus-newsgroup-data nil
7877 gnus-newsgroup-data-reverse nil)
7878 (run-hooks 'gnus-summary-generate-hook)
7879 ;; Generate the buffer, either with threads or without.
7880 (when gnus-newsgroup-headers
7881 (gnus-summary-prepare-threads
7882 (if gnus-show-threads
7883 (gnus-sort-gathered-threads
7884 (funcall gnus-summary-thread-gathering-function
7886 (gnus-cut-threads (gnus-make-threads)))))
7887 ;; Unthreaded display.
7888 (gnus-sort-articles gnus-newsgroup-headers))))
7889 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7890 ;; Call hooks for modifying summary buffer.
7891 (goto-char (point-min))
7892 (run-hooks 'gnus-summary-prepare-hook)))
7894 (defun gnus-gather-threads-by-subject (threads)
7895 "Gather threads by looking at Subject headers."
7896 (if (not gnus-summary-make-false-root)
7898 (let ((hashtb (gnus-make-hashtable 1023))
7901 subject hthread whole-subject)
7903 (setq whole-subject (mail-header-subject (caar threads)))
7906 ;; Truncate the subject.
7907 ((numberp gnus-summary-gather-subject-limit)
7908 (setq subject (gnus-simplify-subject-re whole-subject))
7909 (if (> (length subject) gnus-summary-gather-subject-limit)
7910 (substring subject 0 gnus-summary-gather-subject-limit)
7912 ;; Fuzzily simplify it.
7913 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7914 (gnus-simplify-subject-fuzzy whole-subject))
7915 ;; Just remove the leading "Re:".
7917 (gnus-simplify-subject-re whole-subject))))
7919 (if (and gnus-summary-gather-exclude-subject
7920 (string-match gnus-summary-gather-exclude-subject
7922 () ; We don't want to do anything with this article.
7923 ;; We simplify the subject before looking it up in the
7926 (if (setq hthread (gnus-gethash subject hashtb))
7928 ;; We enter a dummy root into the thread, if we
7929 ;; haven't done that already.
7930 (unless (stringp (caar hthread))
7931 (setcar hthread (list whole-subject (car hthread))))
7932 ;; We add this new gathered thread to this gathered
7934 (setcdr (car hthread)
7935 (nconc (cdar hthread) (list (car threads))))
7936 ;; Remove it from the list of threads.
7937 (setcdr prev (cdr threads))
7938 (setq threads prev))
7939 ;; Enter this thread into the hash table.
7940 (gnus-sethash subject threads hashtb)))
7942 (setq threads (cdr threads)))
7945 (defun gnus-gather-threads-by-references (threads)
7946 "Gather threads by looking at References headers."
7947 (let ((idhashtb (gnus-make-hashtable 1023))
7948 (thhashtb (gnus-make-hashtable 1023))
7951 ids references id gthread gid entered)
7953 (when (setq references (mail-header-references (caar threads)))
7954 (setq id (mail-header-id (caar threads)))
7955 (setq ids (gnus-split-references references))
7958 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7960 (gnus-sethash (car ids) id idhashtb)
7961 (gnus-sethash id threads thhashtb))
7962 (setq gthread (gnus-gethash gid thhashtb))
7964 ;; We enter a dummy root into the thread, if we
7965 ;; haven't done that already.
7966 (unless (stringp (caar gthread))
7967 (setcar gthread (list (mail-header-subject (caar gthread))
7969 ;; We add this new gathered thread to this gathered
7971 (setcdr (car gthread)
7972 (nconc (cdar gthread) (list (car threads)))))
7973 ;; Add it into the thread hash table.
7974 (gnus-sethash id gthread thhashtb)
7976 ;; Remove it from the list of threads.
7977 (setcdr prev (cdr threads))
7978 (setq threads prev))
7979 (setq ids (cdr ids))))
7981 (setq threads (cdr threads)))
7984 (defun gnus-sort-gathered-threads (threads)
7985 "Sort subtreads inside each gathered thread by article number."
7986 (let ((result threads))
7988 (when (stringp (caar threads))
7989 (setcdr (car threads)
7990 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7991 (setq threads (cdr threads)))
7994 (defun gnus-make-threads ()
7995 "Go through the dependency hashtb and find the roots. Return all threads."
7999 (unless (car (symbol-value refs))
8000 ;; These threads do not refer back to any other articles,
8001 ;; so they're roots.
8002 (setq threads (append (cdr (symbol-value refs)) threads))))
8003 gnus-newsgroup-dependencies)
8006 (defun gnus-build-sparse-threads ()
8007 (let ((headers gnus-newsgroup-headers)
8008 (deps gnus-newsgroup-dependencies)
8009 header references generation relations
8010 cthread subject child end pthread relation)
8011 ;; First we create an alist of generations/relations, where
8012 ;; generations is how much we trust the ralation, and the relation
8014 (gnus-message 7 "Making sparse threads...")
8016 (nnheader-set-temp-buffer " *gnus sparse threads*")
8017 (while (setq header (pop headers))
8018 (when (and (setq references (mail-header-references header))
8019 (not (string= references "")))
8021 (setq child (mail-header-id header)
8022 subject (mail-header-subject header))
8024 (while (search-backward ">" nil t)
8025 (setq end (1+ (point)))
8026 (when (search-backward "<" nil t)
8027 (push (list (incf generation)
8028 child (setq child (buffer-substring (point) end))
8031 (push (list (1+ generation) child nil subject) relations)
8033 (kill-buffer (current-buffer)))
8034 ;; Sort over trustworthiness.
8035 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8036 (while (setq relation (pop relations))
8037 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8038 (unless (car (symbol-value cthread))
8039 ;; Make this article the parent of these threads.
8040 (setcar (symbol-value cthread)
8041 (vector gnus-reffed-article-number
8045 (or (caddr relation) "") 0 0 "")))
8046 (set cthread (list (vector gnus-reffed-article-number
8048 "" "" (cadr relation)
8049 (or (caddr relation) "") 0 0 ""))))
8050 (push gnus-reffed-article-number gnus-newsgroup-limit)
8051 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8052 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8053 gnus-newsgroup-reads)
8054 (decf gnus-reffed-article-number)
8055 ;; Make this new thread the child of its parent.
8056 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8057 (setcdr (symbol-value pthread)
8058 (nconc (cdr (symbol-value pthread))
8059 (list (symbol-value cthread))))
8060 (set pthread (list nil (symbol-value cthread))))))
8061 (gnus-message 7 "Making sparse threads...done")))
8063 (defun gnus-build-old-threads ()
8064 ;; Look at all the articles that refer back to old articles, and
8065 ;; fetch the headers for the articles that aren't there. This will
8066 ;; build complete threads - if the roots haven't been expired by the
8071 (when (not (car (symbol-value refs)))
8072 (setq heads (cdr (symbol-value refs)))
8074 (if (memq (mail-header-number (caar heads))
8075 gnus-newsgroup-dormant)
8076 (setq heads (cdr heads))
8077 (setq id (symbol-name refs))
8078 (while (and (setq id (gnus-build-get-header id))
8079 (not (car (gnus-gethash
8080 id gnus-newsgroup-dependencies)))))
8081 (setq heads nil)))))
8082 gnus-newsgroup-dependencies)))
8084 (defun gnus-build-get-header (id)
8085 ;; Look through the buffer of NOV lines and find the header to
8086 ;; ID. Enter this line into the dependencies hash table, and return
8087 ;; the id of the parent article (if any).
8088 (let ((deps gnus-newsgroup-dependencies)
8092 (set-buffer nntp-server-buffer)
8093 (goto-char (point-min))
8094 (while (and (not found) (search-forward id nil t))
8096 (setq found (looking-at
8097 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8098 (regexp-quote id))))
8099 (or found (beginning-of-line 2)))
8103 (setq header (gnus-nov-parse-line
8104 (read (current-buffer)) deps))
8105 (gnus-parent-id (mail-header-references header)))))
8107 (let ((number (mail-header-number header)))
8108 (push number gnus-newsgroup-limit)
8109 (push header gnus-newsgroup-headers)
8110 (if (memq number gnus-newsgroup-unselected)
8112 (push number gnus-newsgroup-unreads)
8113 (setq gnus-newsgroup-unselected
8114 (delq number gnus-newsgroup-unselected)))
8115 (push number gnus-newsgroup-ancient)))))))
8117 (defun gnus-summary-update-article (article &optional iheader)
8118 "Update ARTICLE in the summary buffer."
8119 (set-buffer gnus-summary-buffer)
8120 (let* ((header (or iheader (gnus-summary-article-header article)))
8121 (id (mail-header-id header))
8122 (data (gnus-data-find article))
8123 (thread (gnus-id-to-thread id))
8124 (references (mail-header-references header))
8129 (not (equal "" references)))
8132 (buffer-read-only nil)
8134 (number (mail-header-number header))
8137 ;; !!! Should this be in or not?
8139 (setcar thread nil))
8141 (delq thread parent))
8142 (if (gnus-summary-insert-subject id header iheader)
8143 ;; Set the (possibly) new article number in the data structure.
8144 (gnus-data-set-number data (gnus-id-to-article id))
8148 (defun gnus-rebuild-thread (id)
8149 "Rebuild the thread containing ID."
8150 (let ((buffer-read-only nil)
8151 current thread data)
8152 (if (not gnus-show-threads)
8153 (setq thread (list (car (gnus-id-to-thread id))))
8154 ;; Get the thread this article is part of.
8155 (setq thread (gnus-remove-thread id)))
8156 (setq current (save-excursion
8157 (and (zerop (forward-line -1))
8158 (gnus-summary-article-number))))
8159 ;; If this is a gathered thread, we have to go some re-gathering.
8160 (when (stringp (car thread))
8161 (let ((subject (car thread))
8163 (setq thread (cdr thread))
8165 (unless (memq (setq thr (gnus-id-to-thread
8167 (mail-header-id (caar thread)))))
8170 (setq thread (cdr thread)))
8171 ;; We now have all (unique) roots.
8172 (if (= (length roots) 1)
8173 ;; All the loose roots are now one solid root.
8174 (setq thread (car roots))
8175 (setq thread (cons subject (gnus-sort-threads roots))))))
8177 ;; We then insert this thread into the summary buffer.
8178 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8179 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8180 (setq data (nreverse gnus-newsgroup-data))
8181 (setq threads gnus-newsgroup-threads))
8182 ;; We splice the new data into the data structure.
8183 (gnus-data-enter-list current data)
8184 (gnus-data-compute-positions)
8185 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8187 (defun gnus-number-to-header (number)
8188 "Return the header for article NUMBER."
8189 (let ((headers gnus-newsgroup-headers))
8191 (not (= number (mail-header-number (car headers)))))
8196 (defun gnus-id-to-thread (id)
8197 "Return the (sub-)thread where ID appears."
8198 (gnus-gethash id gnus-newsgroup-dependencies))
8200 (defun gnus-id-to-article (id)
8201 "Return the article number of ID."
8202 (let ((thread (gnus-id-to-thread id)))
8205 (mail-header-number (car thread)))))
8207 (defun gnus-id-to-header (id)
8208 "Return the article headers of ID."
8209 (car (gnus-id-to-thread id)))
8211 (defun gnus-article-displayed-root-p (article)
8212 "Say whether ARTICLE is a root(ish) article."
8213 (let ((level (gnus-summary-thread-level article))
8214 (refs (mail-header-references (gnus-summary-article-header article)))
8220 ((null (gnus-parent-id refs)) t)
8222 (null (setq particle (gnus-id-to-article
8223 (gnus-parent-id refs))))
8224 (null (gnus-summary-thread-level particle)))))))
8226 (defun gnus-root-id (id)
8227 "Return the id of the root of the thread where ID appears."
8229 (while (and id (setq prev (car (gnus-gethash
8230 id gnus-newsgroup-dependencies))))
8232 id (gnus-parent-id (mail-header-references prev))))
8235 (defun gnus-remove-thread (id &optional dont-remove)
8236 "Remove the thread that has ID in it."
8237 (let ((dep gnus-newsgroup-dependencies)
8238 headers thread last-id)
8239 ;; First go up in this thread until we find the root.
8240 (setq last-id (gnus-root-id id))
8241 (setq headers (list (car (gnus-id-to-thread last-id))
8242 (caadr (gnus-id-to-thread last-id))))
8243 ;; We have now found the real root of this thread. It might have
8244 ;; been gathered into some loose thread, so we have to search
8245 ;; through the threads to find the thread we wanted.
8246 (let ((threads gnus-newsgroup-threads)
8249 (setq sub (car threads))
8250 (if (stringp (car sub))
8251 ;; This is a gathered threads, so we look at the roots
8252 ;; below it to find whether this article in in this
8255 (setq sub (cdr sub))
8257 (when (member (caar sub) headers)
8258 (setq thread (car threads)
8261 (setq sub (cdr sub))))
8262 ;; It's an ordinary thread, so we check it.
8263 (when (eq (car sub) (car headers))
8266 (setq threads (cdr threads)))
8267 ;; If this article is in no thread, then it's a root.
8270 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8271 (setq thread (gnus-gethash last-id dep)))
8274 thread ; We return this thread.
8276 (if (stringp (car thread))
8278 ;; If we use dummy roots, then we have to remove the
8279 ;; dummy root as well.
8280 (when (eq gnus-summary-make-false-root 'dummy)
8283 (setq thread (cdr thread))
8285 (gnus-remove-thread-1 (car thread))
8286 (setq thread (cdr thread))))
8287 (gnus-remove-thread-1 thread))))))))
8289 (defun gnus-remove-thread-1 (thread)
8290 "Remove the thread THREAD recursively."
8291 (let ((number (mail-header-number (car thread)))
8293 (when (setq pos (text-property-any
8294 (point-min) (point-max) 'gnus-number number))
8297 (gnus-data-remove number))
8298 (setq thread (cdr thread))
8300 (gnus-remove-thread-1 (pop thread)))))
8302 (defun gnus-sort-threads (threads)
8304 (if (not gnus-thread-sort-functions)
8306 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8307 (car gnus-thread-sort-functions)
8309 ,(gnus-make-sort-function
8310 (reverse gnus-thread-sort-functions))))))
8311 (gnus-message 7 "Sorting threads...")
8314 (gnus-message 7 "Sorting threads...done")))))
8316 (defun gnus-sort-articles (articles)
8318 (when gnus-article-sort-functions
8319 (let ((func (if (= 1 (length gnus-article-sort-functions))
8320 (car gnus-article-sort-functions)
8322 ,(gnus-make-sort-function
8323 (reverse gnus-article-sort-functions))))))
8324 (gnus-message 7 "Sorting articles...")
8326 (setq gnus-newsgroup-headers (sort articles func))
8327 (gnus-message 7 "Sorting articles...done")))))
8329 (defun gnus-make-sort-function (funs)
8330 "Return a composite sort condition based on the functions in FUNC."
8332 `(or (,(car funs) t1 t2)
8333 (and (not (,(car funs) t2 t1))
8334 ,(gnus-make-sort-function (cdr funs))))
8335 `(,(car funs) t1 t2)))
8337 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8338 (defmacro gnus-thread-header (thread)
8339 ;; Return header of first article in THREAD.
8340 ;; Note that THREAD must never, ever be anything else than a variable -
8341 ;; using some other form will lead to serious barfage.
8342 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8343 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8344 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8347 (defsubst gnus-article-sort-by-number (h1 h2)
8348 "Sort articles by article number."
8349 (< (mail-header-number h1)
8350 (mail-header-number h2)))
8352 (defun gnus-thread-sort-by-number (h1 h2)
8353 "Sort threads by root article number."
8354 (gnus-article-sort-by-number
8355 (gnus-thread-header h1) (gnus-thread-header h2)))
8357 (defsubst gnus-article-sort-by-author (h1 h2)
8358 "Sort articles by root author."
8360 (let ((extract (funcall
8361 gnus-extract-address-components
8362 (mail-header-from h1))))
8363 (or (car extract) (cdr extract)))
8364 (let ((extract (funcall
8365 gnus-extract-address-components
8366 (mail-header-from h2))))
8367 (or (car extract) (cdr extract)))))
8369 (defun gnus-thread-sort-by-author (h1 h2)
8370 "Sort threads by root author."
8371 (gnus-article-sort-by-author
8372 (gnus-thread-header h1) (gnus-thread-header h2)))
8374 (defsubst gnus-article-sort-by-subject (h1 h2)
8375 "Sort articles by root subject."
8377 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8378 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8380 (defun gnus-thread-sort-by-subject (h1 h2)
8381 "Sort threads by root subject."
8382 (gnus-article-sort-by-subject
8383 (gnus-thread-header h1) (gnus-thread-header h2)))
8385 (defsubst gnus-article-sort-by-date (h1 h2)
8386 "Sort articles by root article date."
8388 (inline (gnus-sortable-date (mail-header-date h1)))
8389 (inline (gnus-sortable-date (mail-header-date h2)))))
8391 (defun gnus-thread-sort-by-date (h1 h2)
8392 "Sort threads by root article date."
8393 (gnus-article-sort-by-date
8394 (gnus-thread-header h1) (gnus-thread-header h2)))
8396 (defsubst gnus-article-sort-by-score (h1 h2)
8397 "Sort articles by root article score.
8398 Unscored articles will be counted as having a score of zero."
8399 (> (or (cdr (assq (mail-header-number h1)
8400 gnus-newsgroup-scored))
8401 gnus-summary-default-score 0)
8402 (or (cdr (assq (mail-header-number h2)
8403 gnus-newsgroup-scored))
8404 gnus-summary-default-score 0)))
8406 (defun gnus-thread-sort-by-score (h1 h2)
8407 "Sort threads by root article score."
8408 (gnus-article-sort-by-score
8409 (gnus-thread-header h1) (gnus-thread-header h2)))
8411 (defun gnus-thread-sort-by-total-score (h1 h2)
8412 "Sort threads by the sum of all scores in the thread.
8413 Unscored articles will be counted as having a score of zero."
8414 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8416 (defun gnus-thread-total-score (thread)
8417 ;; This function find the total score of THREAD.
8418 (cond ((null thread)
8421 (if (stringp (car thread))
8422 (apply gnus-thread-score-function 0
8423 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8424 (gnus-thread-total-score-1 thread)))
8426 (gnus-thread-total-score-1 (list thread)))))
8428 (defun gnus-thread-total-score-1 (root)
8429 ;; This function find the total score of the thread below ROOT.
8430 (setq root (car root))
8431 (apply gnus-thread-score-function
8432 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8433 gnus-summary-default-score 0)
8434 (mapcar 'gnus-thread-total-score
8435 (cdr (gnus-gethash (mail-header-id root)
8436 gnus-newsgroup-dependencies)))))
8438 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8439 (defvar gnus-tmp-prev-subject nil)
8440 (defvar gnus-tmp-false-parent nil)
8441 (defvar gnus-tmp-root-expunged nil)
8442 (defvar gnus-tmp-dummy-line nil)
8444 (defun gnus-summary-prepare-threads (threads)
8445 "Prepare summary buffer from THREADS and indentation LEVEL.
8446 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8447 or a straight list of headers."
8448 (gnus-message 7 "Generating summary...")
8450 (setq gnus-newsgroup-threads threads)
8453 (let ((gnus-tmp-level 0)
8454 (default-score (or gnus-summary-default-score 0))
8455 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8456 thread number subject stack state gnus-tmp-gathered beg-match
8457 new-roots gnus-tmp-new-adopts thread-end
8458 gnus-tmp-header gnus-tmp-unread
8459 gnus-tmp-replied gnus-tmp-subject-or-nil
8460 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8461 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8462 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8464 (setq gnus-tmp-prev-subject nil)
8466 (if (vectorp (car threads))
8467 ;; If this is a straight (sic) list of headers, then a
8468 ;; threaded summary display isn't required, so we just create
8469 ;; an unthreaded one.
8470 (gnus-summary-prepare-unthreaded threads)
8472 ;; Do the threaded display.
8474 (while (or threads stack gnus-tmp-new-adopts new-roots)
8476 (if (and (= gnus-tmp-level 0)
8477 (not (setq gnus-tmp-dummy-line nil))
8480 (not gnus-tmp-false-parent)
8481 (or gnus-tmp-new-adopts new-roots))
8482 (if gnus-tmp-new-adopts
8483 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8484 thread (list (car gnus-tmp-new-adopts))
8485 gnus-tmp-header (caar thread)
8486 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8488 (setq thread (list (car new-roots))
8489 gnus-tmp-header (caar thread)
8490 new-roots (cdr new-roots))))
8493 ;; If there are some threads, we do them before the
8494 ;; threads on the stack.
8495 (setq thread threads
8496 gnus-tmp-header (caar thread))
8497 ;; There were no current threads, so we pop something off
8499 (setq state (car stack)
8500 gnus-tmp-level (car state)
8503 gnus-tmp-header (caar thread))))
8505 (setq gnus-tmp-false-parent nil)
8506 (setq gnus-tmp-root-expunged nil)
8507 (setq thread-end nil)
8509 (if (stringp gnus-tmp-header)
8510 ;; The header is a dummy root.
8512 ((eq gnus-summary-make-false-root 'adopt)
8513 ;; We let the first article adopt the rest.
8514 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8516 (setq gnus-tmp-gathered
8518 (lambda (h) (mail-header-number (car h)))
8521 (setq thread (cons (list (caar thread)
8524 (setq gnus-tmp-level -1
8525 gnus-tmp-false-parent t))
8526 ((eq gnus-summary-make-false-root 'empty)
8527 ;; We print adopted articles with empty subject fields.
8528 (setq gnus-tmp-gathered
8530 (lambda (h) (mail-header-number (car h)))
8533 (setq gnus-tmp-level -1))
8534 ((eq gnus-summary-make-false-root 'dummy)
8535 ;; We remember that we probably want to output a dummy
8537 (setq gnus-tmp-dummy-line gnus-tmp-header)
8538 (setq gnus-tmp-prev-subject gnus-tmp-header))
8540 ;; We do not make a root for the gathered
8541 ;; sub-threads at all.
8542 (setq gnus-tmp-level -1)))
8544 (setq number (mail-header-number gnus-tmp-header)
8545 subject (mail-header-subject gnus-tmp-header))
8548 ;; If the thread has changed subject, we might want to make
8549 ;; this subthread into a root.
8550 ((and (null gnus-thread-ignore-subject)
8551 (not (zerop gnus-tmp-level))
8552 gnus-tmp-prev-subject
8554 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8555 (setq new-roots (nconc new-roots (list (car thread)))
8557 gnus-tmp-header nil))
8558 ;; If the article lies outside the current limit,
8559 ;; then we do not display it.
8560 ((and (not (memq number gnus-newsgroup-limit))
8561 (not gnus-tmp-dummy-line))
8562 (setq gnus-tmp-gathered
8564 (lambda (h) (mail-header-number (car h)))
8567 (setq gnus-tmp-new-adopts (if (cdar thread)
8568 (append gnus-tmp-new-adopts
8570 gnus-tmp-new-adopts)
8572 gnus-tmp-header nil)
8573 (when (zerop gnus-tmp-level)
8574 (setq gnus-tmp-root-expunged t)))
8575 ;; Perhaps this article is to be marked as read?
8576 ((and gnus-summary-mark-below
8577 (< (or (cdr (assq number gnus-newsgroup-scored))
8579 gnus-summary-mark-below)
8580 ;; Don't touch sparse articles.
8581 (not (memq number gnus-newsgroup-sparse))
8582 (not (memq number gnus-newsgroup-ancient)))
8583 (setq gnus-newsgroup-unreads
8584 (delq number gnus-newsgroup-unreads))
8585 (if gnus-newsgroup-auto-expire
8586 (push number gnus-newsgroup-expirable)
8587 (push (cons number gnus-low-score-mark)
8588 gnus-newsgroup-reads))))
8590 (when gnus-tmp-header
8591 ;; We may have an old dummy line to output before this
8593 (when gnus-tmp-dummy-line
8594 (gnus-summary-insert-dummy-line
8595 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8596 (setq gnus-tmp-dummy-line nil))
8598 ;; Compute the mark.
8602 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8603 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8604 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8605 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8606 (t (or (cdr (assq number gnus-newsgroup-reads))
8607 gnus-ancient-mark))))
8609 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8610 gnus-tmp-header gnus-tmp-level)
8611 gnus-newsgroup-data)
8613 ;; Actually insert the line.
8615 gnus-tmp-subject-or-nil
8617 ((and gnus-thread-ignore-subject
8618 gnus-tmp-prev-subject
8619 (not (inline (gnus-subject-equal
8620 gnus-tmp-prev-subject subject))))
8622 ((zerop gnus-tmp-level)
8623 (if (and (eq gnus-summary-make-false-root 'empty)
8624 (memq number gnus-tmp-gathered)
8625 gnus-tmp-prev-subject
8626 (inline (gnus-subject-equal
8627 gnus-tmp-prev-subject subject)))
8628 gnus-summary-same-subject
8630 (t gnus-summary-same-subject)))
8631 (if (and (eq gnus-summary-make-false-root 'adopt)
8632 (= gnus-tmp-level 1)
8633 (memq number gnus-tmp-gathered))
8634 (setq gnus-tmp-opening-bracket ?\<
8635 gnus-tmp-closing-bracket ?\>)
8636 (setq gnus-tmp-opening-bracket ?\[
8637 gnus-tmp-closing-bracket ?\]))
8639 gnus-tmp-indentation
8640 (aref gnus-thread-indent-array gnus-tmp-level)
8641 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8642 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8643 gnus-summary-default-score 0)
8645 (if (or (null gnus-summary-default-score)
8646 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8647 gnus-summary-zcore-fuzz)) ?
8648 (if (< gnus-tmp-score gnus-summary-default-score)
8649 gnus-score-below-mark gnus-score-over-mark))
8651 (cond ((memq number gnus-newsgroup-processable)
8653 ((memq number gnus-newsgroup-cached)
8655 ((memq number gnus-newsgroup-replied)
8657 ((memq number gnus-newsgroup-saved)
8659 (t gnus-unread-mark))
8660 gnus-tmp-from (mail-header-from gnus-tmp-header)
8663 ((string-match "(.+)" gnus-tmp-from)
8664 (substring gnus-tmp-from
8665 (1+ (match-beginning 0)) (1- (match-end 0))))
8666 ((string-match "<[^>]+> *$" gnus-tmp-from)
8667 (setq beg-match (match-beginning 0))
8668 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8669 (substring gnus-tmp-from (1+ (match-beginning 0))
8670 (1- (match-end 0))))
8671 (substring gnus-tmp-from 0 beg-match)))
8673 (when (string= gnus-tmp-name "")
8674 (setq gnus-tmp-name gnus-tmp-from))
8675 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8676 (gnus-put-text-property
8678 (progn (eval gnus-summary-line-format-spec) (point))
8679 'gnus-number number)
8682 (run-hooks 'gnus-summary-update-hook)
8685 (setq gnus-tmp-prev-subject subject)))
8687 (when (nth 1 thread)
8688 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8689 (incf gnus-tmp-level)
8690 (setq threads (if thread-end nil (cdar thread)))
8692 (setq gnus-tmp-level 0)))))
8693 (gnus-message 7 "Generating summary...done"))
8695 (defun gnus-summary-prepare-unthreaded (headers)
8696 "Generate an unthreaded summary buffer based on HEADERS."
8697 (let (header number mark)
8700 ;; We may have to root out some bad articles...
8701 (when (memq (setq number (mail-header-number
8702 (setq header (pop headers))))
8703 gnus-newsgroup-limit)
8704 ;; Mark article as read when it has a low score.
8705 (when (and gnus-summary-mark-below
8706 (< (or (cdr (assq number gnus-newsgroup-scored))
8707 gnus-summary-default-score 0)
8708 gnus-summary-mark-below)
8709 (not (memq number gnus-newsgroup-ancient)))
8710 (setq gnus-newsgroup-unreads
8711 (delq number gnus-newsgroup-unreads))
8712 (if gnus-newsgroup-auto-expire
8713 (push number gnus-newsgroup-expirable)
8714 (push (cons number gnus-low-score-mark)
8715 gnus-newsgroup-reads)))
8719 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8720 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8721 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8722 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8723 (t (or (cdr (assq number gnus-newsgroup-reads))
8724 gnus-ancient-mark))))
8725 (setq gnus-newsgroup-data
8726 (cons (gnus-data-make number mark (1+ (point)) header 0)
8727 gnus-newsgroup-data))
8728 (gnus-summary-insert-line
8729 header 0 nil mark (memq number gnus-newsgroup-replied)
8730 (memq number gnus-newsgroup-expirable)
8731 (mail-header-subject header) nil
8732 (cdr (assq number gnus-newsgroup-scored))
8733 (memq number gnus-newsgroup-processable))))))
8735 (defun gnus-select-newsgroup (group &optional read-all)
8736 "Select newsgroup GROUP.
8737 If READ-ALL is non-nil, all articles in the group are selected."
8738 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8739 (info (nth 2 entry))
8740 articles fetched-articles cached)
8742 (or (gnus-check-server
8743 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8744 (error "Couldn't open server"))
8746 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8747 (gnus-activate-group group) ; Or we can activate it...
8748 (progn ; Or we bug out.
8749 (when (equal major-mode 'gnus-summary-mode)
8750 (kill-buffer (current-buffer)))
8751 (error "Couldn't request group %s: %s"
8752 group (gnus-status-message group))))
8754 (unless (gnus-request-group group t)
8755 (when (equal major-mode 'gnus-summary-mode)
8756 (kill-buffer (current-buffer)))
8757 (error "Couldn't request group %s: %s"
8758 group (gnus-status-message group)))
8760 (setq gnus-newsgroup-name group)
8761 (setq gnus-newsgroup-unselected nil)
8762 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8764 (and gnus-asynchronous
8765 (gnus-check-backend-function
8766 'request-asynchronous gnus-newsgroup-name)
8767 (setq gnus-newsgroup-async
8768 (gnus-request-asynchronous gnus-newsgroup-name)))
8770 ;; Adjust and set lists of article marks.
8772 (gnus-adjust-marked-articles info))
8774 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8775 (when (gnus-virtual-group-p group)
8776 (setq cached gnus-newsgroup-cached))
8778 (setq gnus-newsgroup-unreads
8779 (gnus-set-difference
8780 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8781 gnus-newsgroup-dormant))
8783 (setq gnus-newsgroup-processable nil)
8785 (setq articles (gnus-articles-to-read group read-all))
8789 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8791 ((eq articles 0) nil)
8793 ;; Init the dependencies hash table.
8794 (setq gnus-newsgroup-dependencies
8795 (gnus-make-hashtable (length articles)))
8796 ;; Retrieve the headers and read them in.
8797 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8798 (setq gnus-newsgroup-headers
8800 (setq gnus-headers-retrieved-by
8801 (gnus-retrieve-headers
8802 articles gnus-newsgroup-name
8803 ;; We might want to fetch old headers, but
8804 ;; not if there is only 1 article.
8805 (and gnus-fetch-old-headers
8807 (not (eq gnus-fetch-old-headers 'some))
8808 (not (numberp gnus-fetch-old-headers)))
8809 (> (length articles) 1))))))
8810 (gnus-get-newsgroup-headers-xover articles)
8811 (gnus-get-newsgroup-headers)))
8812 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8814 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8816 (setq gnus-newsgroup-cached cached))
8818 ;; Set the initial limit.
8819 (setq gnus-newsgroup-limit (copy-sequence articles))
8820 ;; Remove canceled articles from the list of unread articles.
8821 (setq gnus-newsgroup-unreads
8822 (gnus-set-sorted-intersection
8823 gnus-newsgroup-unreads
8824 (setq fetched-articles
8825 (mapcar (lambda (headers) (mail-header-number headers))
8826 gnus-newsgroup-headers))))
8827 ;; Removed marked articles that do not exist.
8828 (gnus-update-missing-marks
8829 (gnus-sorted-complement fetched-articles articles))
8830 ;; We might want to build some more threads first.
8831 (and gnus-fetch-old-headers
8832 (eq gnus-headers-retrieved-by 'nov)
8833 (gnus-build-old-threads))
8834 ;; Check whether auto-expire is to be done in this group.
8835 (setq gnus-newsgroup-auto-expire
8836 (gnus-group-auto-expirable-p group))
8837 ;; Set up the article buffer now, if necessary.
8838 (unless gnus-single-article-buffer
8839 (gnus-article-setup-buffer))
8840 ;; First and last article in this newsgroup.
8841 (when gnus-newsgroup-headers
8842 (setq gnus-newsgroup-begin
8843 (mail-header-number (car gnus-newsgroup-headers))
8846 (gnus-last-element gnus-newsgroup-headers))))
8847 (setq gnus-reffed-article-number -1)
8848 ;; GROUP is successfully selected.
8849 (or gnus-newsgroup-headers t)))))
8851 (defun gnus-articles-to-read (group read-all)
8852 ;; Find out what articles the user wants to read.
8854 ;; Select all articles if `read-all' is non-nil, or if there
8855 ;; are no unread articles.
8857 (and (zerop (length gnus-newsgroup-marked))
8858 (zerop (length gnus-newsgroup-unreads))))
8859 (gnus-uncompress-range (gnus-active group))
8860 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8861 (copy-sequence gnus-newsgroup-unreads))
8863 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8864 (scored (length scored-list))
8865 (number (length articles))
8866 (marked (+ (length gnus-newsgroup-marked)
8867 (length gnus-newsgroup-dormant)))
8875 ((and (or (<= scored marked) (= scored number))
8876 (numberp gnus-large-newsgroup)
8877 (> number gnus-large-newsgroup))
8881 "How many articles from %s (default %d): "
8882 gnus-newsgroup-name number))))
8883 (if (string-match "^[ \t]*$" input) number input)))
8884 ((and (> scored marked) (< scored number)
8885 (> (- scored number) 20))
8888 (format "%s %s (%d scored, %d total): "
8889 "How many articles from"
8890 group scored number))))
8891 (if (string-match "^[ \t]*$" input)
8895 (setq select (if (stringp select) (string-to-number select) select))
8896 (if (or (null select) (zerop select))
8898 (if (and (not (zerop scored)) (<= (abs select) scored))
8900 (setq articles (sort scored-list '<))
8901 (setq number (length articles)))
8902 (setq articles (copy-sequence articles)))
8904 (if (< (abs select) number)
8906 ;; Select the N oldest articles.
8907 (setcdr (nthcdr (1- (abs select)) articles) nil)
8908 ;; Select the N most recent articles.
8909 (setq articles (nthcdr (- number select) articles))))
8910 (setq gnus-newsgroup-unselected
8911 (gnus-sorted-intersection
8912 gnus-newsgroup-unreads
8913 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8916 (defun gnus-killed-articles (killed articles)
8919 (if (inline (gnus-member-of-range (car articles) killed))
8920 (setq out (cons (car articles) out)))
8921 (setq articles (cdr articles)))
8924 (defun gnus-uncompress-marks (marks)
8925 "Uncompress the mark ranges in MARKS."
8926 (let ((uncompressed '(score bookmark))
8929 (if (memq (caar marks) uncompressed)
8930 (push (car marks) out)
8931 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8932 (setq marks (cdr marks)))
8935 (defun gnus-adjust-marked-articles (info)
8936 "Set all article lists and remove all marks that are no longer legal."
8937 (let* ((marked-lists (gnus-info-marks info))
8938 (active (gnus-active (gnus-info-group info)))
8941 (types gnus-article-mark-lists)
8942 (uncompressed '(score bookmark))
8943 marks var articles article mark)
8946 (setq marks (pop marked-lists))
8947 (set (setq var (intern (format "gnus-newsgroup-%s"
8948 (car (rassq (setq mark (car marks))
8950 (if (memq (car marks) uncompressed) (cdr marks)
8951 (gnus-uncompress-range (cdr marks))))
8953 (setq articles (symbol-value var))
8955 ;; All articles have to be subsets of the active articles.
8957 ;; Adjust "simple" lists.
8958 ((memq mark '(tick dormant expirable reply killed save))
8960 (when (or (< (setq article (pop articles)) min) (> article max))
8961 (set var (delq article (symbol-value var))))))
8963 ((memq mark '(score bookmark))
8965 (when (or (not (consp (setq article (pop articles))))
8966 (< (car article) min)
8967 (> (car article) max))
8968 (set var (delq article (symbol-value var))))))))))
8970 (defun gnus-update-missing-marks (missing)
8971 "Go through the list of MISSING articles and remove them mark lists."
8973 (let ((types gnus-article-mark-lists)
8975 ;; Go through all types.
8977 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8978 (when (symbol-value var)
8979 ;; This list has articles. So we delete all missing articles
8983 (set var (delq (pop m) (symbol-value var)))))))))
8985 (defun gnus-update-marks ()
8986 "Enter the various lists of marked articles into the newsgroup info list."
8987 (let ((types gnus-article-mark-lists)
8988 (info (gnus-get-info gnus-newsgroup-name))
8989 (uncompressed '(score bookmark killed))
8990 type list newmarked symbol)
8992 ;; Add all marks lists that are non-nil to the list of marks lists.
8994 (setq type (pop types))
8995 (when (setq list (symbol-value
8997 (intern (format "gnus-newsgroup-%s"
8999 (push (cons (cdr type)
9000 (if (memq (cdr type) uncompressed) list
9001 (gnus-compress-sequence
9002 (set symbol (sort list '<)) t)))
9005 ;; Enter these new marks into the info of the group.
9007 (setcar (nthcdr 3 info) newmarked)
9008 ;; Add the marks lists to the end of the info.
9010 (setcdr (nthcdr 2 info) (list newmarked))))
9012 ;; Cut off the end of the info if there's nothing else there.
9016 (when (nthcdr (decf i) info)
9017 (setcdr (nthcdr i info) nil)))))))
9019 (defun gnus-add-marked-articles (group type articles &optional info force)
9020 ;; Add ARTICLES of TYPE to the info of GROUP.
9021 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9022 ;; add, but replace marked articles of TYPE with ARTICLES.
9023 (let ((info (or info (gnus-get-info group)))
9024 (uncompressed '(score bookmark killed))
9027 (and (not (setq marked (nthcdr 3 info)))
9029 (setcdr (nthcdr 2 info)
9030 (list (list (cons type (gnus-compress-sequence
9032 (and (not (setq m (assq type (car marked))))
9035 (cons (cons type (gnus-compress-sequence articles t) )
9039 (setcar (nthcdr 3 info)
9040 (delq (assq type (car marked)) (car marked)))
9041 (setcdr m (gnus-compress-sequence articles t)))
9042 (setcdr m (gnus-compress-sequence
9043 (sort (nconc (gnus-uncompress-range (cdr m))
9044 (copy-sequence articles)) '<) t))))))
9046 (defun gnus-set-mode-line (where)
9047 "This function sets the mode line of the article or summary buffers.
9048 If WHERE is `summary', the summary mode line format will be used."
9049 ;; Is this mode line one we keep updated?
9050 (when (memq where gnus-updated-mode-lines)
9053 ;; We evaluate this in the summary buffer since these
9054 ;; variables are buffer-local to that buffer.
9055 (set-buffer gnus-summary-buffer)
9056 ;; We bind all these variables that are used in the `eval' form
9058 (let* ((mformat (symbol-value
9060 (format "gnus-%s-mode-line-format-spec" where))))
9061 (gnus-tmp-group-name gnus-newsgroup-name)
9062 (gnus-tmp-article-number (or gnus-current-article 0))
9063 (gnus-tmp-unread gnus-newsgroup-unreads)
9064 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9065 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9066 (gnus-tmp-unread-and-unselected
9067 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9068 (zerop gnus-tmp-unselected)) "")
9069 ((zerop gnus-tmp-unselected)
9070 (format "{%d more}" gnus-tmp-unread-and-unticked))
9071 (t (format "{%d(+%d) more}"
9072 gnus-tmp-unread-and-unticked
9073 gnus-tmp-unselected))))
9075 (if (and gnus-current-headers
9076 (vectorp gnus-current-headers))
9077 (gnus-mode-string-quote
9078 (mail-header-subject gnus-current-headers)) ""))
9080 gnus-tmp-header);; passed as argument to any user-format-funcs
9081 (setq mode-string (eval mformat))
9082 (setq max-len (max 4 (if gnus-mode-non-string-length
9084 gnus-mode-non-string-length)
9085 (length mode-string))))
9086 ;; We might have to chop a bit of the string off...
9087 (when (> (length mode-string) max-len)
9089 (concat (gnus-truncate-string mode-string (- max-len 3))
9091 ;; Pad the mode string a bit.
9092 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9093 ;; Update the mode line.
9094 (setq mode-line-buffer-identification
9095 (gnus-mode-line-buffer-identification
9096 (list mode-string)))
9097 (set-buffer-modified-p t))))
9099 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9100 "Go through the HEADERS list and add all Xrefs to a hash table.
9101 The resulting hash table is returned, or nil if no Xrefs were found."
9102 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9103 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9104 (xref-hashtb (make-vector 63 0))
9105 start group entry number xrefs header)
9107 (setq header (pop headers))
9108 (when (and (setq xrefs (mail-header-xref header))
9109 (not (memq (setq number (mail-header-number header))
9112 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9113 (setq start (match-end 0))
9114 (setq group (if prefix
9115 (concat prefix (substring xrefs (match-beginning 1)
9117 (substring xrefs (match-beginning 1) (match-end 1))))
9119 (string-to-int (substring xrefs (match-beginning 2)
9121 (if (setq entry (gnus-gethash group xref-hashtb))
9122 (setcdr entry (cons number (cdr entry)))
9123 (gnus-sethash group (cons number nil) xref-hashtb)))))
9124 (and start xref-hashtb)))
9126 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9127 "Look through all the headers and mark the Xrefs as read."
9128 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9129 name entry info xref-hashtb idlist method nth4)
9131 (set-buffer gnus-group-buffer)
9132 (when (setq xref-hashtb
9133 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9136 (unless (string= from-newsgroup (setq name (symbol-name group)))
9137 (setq idlist (symbol-value group))
9138 ;; Dead groups are not updated.
9140 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9142 (if (stringp (setq nth4 (gnus-info-method info)))
9143 (setq nth4 (gnus-server-to-method nth4))))
9144 ;; Only do the xrefs if the group has the same
9145 ;; select method as the group we have just read.
9146 (or (gnus-methods-equal-p
9147 nth4 (gnus-find-method-for-group from-newsgroup))
9149 (equal nth4 (setq method (gnus-find-method-for-group
9151 (and (equal (car nth4) (car method))
9152 (equal (nth 1 nth4) (nth 1 method))))
9153 gnus-use-cross-reference
9154 (or (not (eq gnus-use-cross-reference t))
9156 ;; Only do cross-references on subscribed
9157 ;; groups, if that is what is wanted.
9158 (<= (gnus-info-level info) gnus-level-subscribed))
9159 (gnus-group-make-articles-read name idlist))))
9162 (defun gnus-group-make-articles-read (group articles)
9164 (entry (gnus-gethash group gnus-newsrc-hashtb))
9165 (info (nth 2 entry))
9166 (active (gnus-active group))
9168 ;; First peel off all illegal article numbers.
9170 (let ((ids articles)
9174 (if (and first (> id (cdr active)))
9176 ;; We'll end up in this situation in one particular
9177 ;; obscure situation. If you re-scan a group and get
9178 ;; a new article that is cross-posted to a different
9179 ;; group that has not been re-scanned, you might get
9180 ;; crossposted article that has a higher number than
9181 ;; Gnus believes possible. So we re-activate this
9182 ;; group as well. This might mean doing the
9183 ;; crossposting thingy will *increase* the number
9184 ;; of articles in some groups. Tsk, tsk.
9185 (setq active (or (gnus-activate-group group) active))))
9186 (if (or (> id (cdr active))
9187 (< id (car active)))
9188 (setq articles (delq id articles)))
9189 (setq ids (cdr ids)))))
9190 ;; If the read list is nil, we init it.
9192 (null (gnus-info-read info))
9194 (gnus-info-set-read info (cons 1 (1- (car active)))))
9195 ;; Then we add the read articles to the range.
9200 (gnus-info-read info) (setq articles (sort articles '<)))))
9201 ;; Then we have to re-compute how many unread
9202 ;; articles there are in this group.
9207 (setq num (- (1+ (cdr active)) (car active))))
9208 ((not (listp (cdr range)))
9209 (setq num (- (cdr active) (- (1+ (cdr range))
9213 (if (numberp (car range))
9215 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9216 (setq range (cdr range)))
9217 (setq num (- (cdr active) num))))
9218 ;; Update the number of unread articles.
9220 ;; Update the group buffer.
9221 (gnus-group-update-group group t)))))
9223 (defun gnus-methods-equal-p (m1 m2)
9224 (let ((m1 (or m1 gnus-select-method))
9225 (m2 (or m2 gnus-select-method)))
9227 (and (eq (car m1) (car m2))
9228 (or (not (memq 'address (assoc (symbol-name (car m1))
9229 gnus-valid-select-methods)))
9230 (equal (nth 1 m1) (nth 1 m2)))))))
9232 (defsubst gnus-header-value ()
9233 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9235 (defvar gnus-newsgroup-none-id 0)
9237 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9238 (let ((cur nntp-server-buffer)
9241 (save-excursion (set-buffer gnus-summary-buffer)
9242 gnus-newsgroup-dependencies)))
9243 headers id id-dep ref-dep end ref)
9245 (set-buffer nntp-server-buffer)
9246 (run-hooks 'gnus-parse-headers-hook)
9247 (let ((case-fold-search t)
9248 in-reply-to header p lines)
9249 (goto-char (point-min))
9250 ;; Search to the beginning of the next header. Error messages
9251 ;; do not begin with 2 or 3.
9252 (while (re-search-forward "^[23][0-9]+ " nil t)
9255 ;; This implementation of this function, with nine
9256 ;; search-forwards instead of the one re-search-forward and
9257 ;; a case (which basically was the old function) is actually
9258 ;; about twice as fast, even though it looks messier. You
9259 ;; can't have everything, I guess. Speed and elegance
9260 ;; doesn't always go hand in hand.
9269 (narrow-to-region (point)
9270 (or (and (search-forward "\n.\n" nil t)
9276 (if (search-forward "\nsubject: " nil t)
9277 (gnus-header-value) "(none)"))
9281 (if (search-forward "\nfrom: " nil t)
9282 (gnus-header-value) "(nobody)"))
9286 (if (search-forward "\ndate: " nil t)
9287 (gnus-header-value) ""))
9291 (if (search-forward "\nmessage-id: " nil t)
9292 (setq id (gnus-header-value))
9293 ;; If there was no message-id, we just fake one to make
9294 ;; subsequent routines simpler.
9295 (setq id (concat "none+"
9297 (setq gnus-newsgroup-none-id
9298 (1+ gnus-newsgroup-none-id)))))))
9302 (if (search-forward "\nreferences: " nil t)
9311 (search-backward ">" end t)
9314 (search-backward "<" end t)
9316 ;; Get the references from the in-reply-to header if there
9317 ;; were no references and the in-reply-to header looks
9319 (if (and (search-forward "\nin-reply-to: " nil t)
9320 (setq in-reply-to (gnus-header-value))
9321 (string-match "<[^>]+>" in-reply-to))
9322 (setq ref (substring in-reply-to (match-beginning 0)
9330 (if (search-forward "\nlines: " nil t)
9331 (if (numberp (setq lines (read cur)))
9337 (and (search-forward "\nxref: " nil t)
9338 (gnus-header-value)))))
9339 ;; We do the threading while we read the headers. The
9340 ;; message-id and the last reference are both entered into
9341 ;; the same hash table. Some tippy-toeing around has to be
9342 ;; done in case an article has arrived before the article
9343 ;; which it refers to.
9344 (if (boundp (setq id-dep (intern id dependencies)))
9345 (if (and (car (symbol-value id-dep))
9347 ;; An article with this Message-ID has already
9348 ;; been seen, so we ignore this one, except we add
9349 ;; any additional Xrefs (in case the two articles
9350 ;; came from different servers).
9352 (mail-header-set-xref
9353 (car (symbol-value id-dep))
9354 (concat (or (mail-header-xref
9355 (car (symbol-value id-dep))) "")
9356 (or (mail-header-xref header) "")))
9358 (setcar (symbol-value id-dep) header))
9359 (set id-dep (list header)))
9361 (if (boundp (setq ref-dep (intern ref dependencies)))
9362 (setcdr (symbol-value ref-dep)
9363 (nconc (cdr (symbol-value ref-dep))
9364 (list (symbol-value id-dep))))
9365 (set ref-dep (list nil (symbol-value id-dep))))
9366 (setq headers (cons header headers)))
9367 (goto-char (point-max))
9369 (nreverse headers)))))
9371 ;; The following macros and functions were written by Felix Lee
9372 ;; <flee@cse.psu.edu>.
9374 (defmacro gnus-nov-read-integer ()
9376 (if (= (following-char) ?\t)
9378 (let ((num (condition-case nil (read buffer) (error nil))))
9379 (if (numberp num) num 0)))
9380 (or (eobp) (forward-char 1))))
9382 (defmacro gnus-nov-skip-field ()
9383 '(search-forward "\t" eol 'move))
9385 (defmacro gnus-nov-field ()
9386 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9388 ;; Goes through the xover lines and returns a list of vectors
9389 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9390 force-new dependencies)
9391 "Parse the news overview data in the server buffer, and return a
9392 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9393 ;; Get the Xref when the users reads the articles since most/some
9394 ;; NNTP servers do not include Xrefs when using XOVER.
9395 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9396 (let ((cur nntp-server-buffer)
9397 (dependencies (or dependencies gnus-newsgroup-dependencies))
9398 number headers header)
9400 (set-buffer nntp-server-buffer)
9401 ;; Allow the user to mangle the headers before parsing them.
9402 (run-hooks 'gnus-parse-headers-hook)
9403 (goto-char (point-min))
9404 (while (and sequence (not (eobp)))
9405 (setq number (read cur))
9406 (while (and sequence (< (car sequence) number))
9407 (setq sequence (cdr sequence)))
9409 (eq number (car sequence))
9411 (setq sequence (cdr sequence))
9413 (inline (gnus-nov-parse-line
9414 number dependencies force-new)))
9415 (setq headers (cons header headers)))))
9417 (setq headers (nreverse headers)))
9420 ;; This function has to be called with point after the article number
9421 ;; on the beginning of the line.
9422 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9424 (eol (gnus-point-at-eol))
9425 (buffer (current-buffer))
9426 header ref id id-dep ref-dep)
9428 ;; overview: [num subject from date id refs chars lines misc]
9429 (narrow-to-region (point) eol)
9430 (or (eobp) (forward-char))
9436 (gnus-nov-field) ; subject
9437 (gnus-nov-field) ; from
9438 (gnus-nov-field) ; date
9439 (setq id (or (gnus-nov-field)
9442 (setq none (1+ none)))))) ; id
9445 (let ((beg (point)))
9446 (search-forward "\t" eol)
9447 (if (search-backward ">" beg t)
9451 (search-backward "<" beg t)))
9453 (gnus-nov-field)) ; refs
9454 (gnus-nov-read-integer) ; chars
9455 (gnus-nov-read-integer) ; lines
9456 (if (= (following-char) ?\n)
9458 (gnus-nov-field)) ; misc
9461 (gnus-error 4 "Strange nov line")
9467 ;; We build the thread tree.
9469 (if (boundp (setq id-dep (intern id dependencies)))
9470 (if (and (car (symbol-value id-dep))
9472 ;; An article with this Message-ID has already been seen,
9473 ;; so we ignore this one, except we add any additional
9474 ;; Xrefs (in case the two articles came from different
9477 (mail-header-set-xref
9478 (car (symbol-value id-dep))
9479 (concat (or (mail-header-xref
9480 (car (symbol-value id-dep))) "")
9481 (or (mail-header-xref header) "")))
9483 (setcar (symbol-value id-dep) header))
9484 (set id-dep (list header))))
9486 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9487 (setcdr (symbol-value ref-dep)
9488 (nconc (cdr (symbol-value ref-dep))
9489 (list (symbol-value id-dep))))
9490 (set ref-dep (list nil (symbol-value id-dep)))))
9493 (defun gnus-article-get-xrefs ()
9494 "Fill in the Xref value in `gnus-current-headers', if necessary.
9495 This is meant to be called in `gnus-article-internal-prepare-hook'."
9496 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9497 gnus-current-headers)))
9498 (or (not gnus-use-cross-reference)
9500 (and (mail-header-xref headers)
9501 (not (string= (mail-header-xref headers) "")))
9502 (let ((case-fold-search t)
9505 (nnheader-narrow-to-headers)
9506 (goto-char (point-min))
9507 (if (or (and (eq (downcase (following-char)) ?x)
9508 (looking-at "Xref:"))
9509 (search-forward "\nXref:" nil t))
9511 (goto-char (1+ (match-end 0)))
9512 (setq xref (buffer-substring (point)
9513 (progn (end-of-line) (point))))
9514 (mail-header-set-xref headers xref))))))))
9516 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9517 "Find article ID and insert the summary line for that article."
9518 (let ((header (if (and old-header use-old-header)
9519 old-header (gnus-read-header id)))
9520 (number (and (numberp id) id))
9523 ;; Rebuild the thread that this article is part of and go to the
9524 ;; article we have fetched.
9525 (when (and (not gnus-show-threads)
9527 (when (setq pos (text-property-any
9528 (point-min) (point-max) 'gnus-number
9529 (mail-header-number old-header)))
9532 (gnus-data-remove (mail-header-number old-header))))
9534 (mail-header-set-number header (mail-header-number old-header)))
9535 (setq gnus-newsgroup-sparse
9536 (delq (setq number (mail-header-number header))
9537 gnus-newsgroup-sparse))
9538 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9539 (gnus-rebuild-thread (mail-header-id header))
9540 (gnus-summary-goto-subject number nil t))
9541 (when (and (numberp number)
9543 ;; We have to update the boundaries even if we can't fetch the
9544 ;; article if ID is a number -- so that the next `P' or `N'
9545 ;; command will fetch the previous (or next) article even
9546 ;; if the one we tried to fetch this time has been canceled.
9547 (and (> number gnus-newsgroup-end)
9548 (setq gnus-newsgroup-end number))
9549 (and (< number gnus-newsgroup-begin)
9550 (setq gnus-newsgroup-begin number))
9551 (setq gnus-newsgroup-unselected
9552 (delq number gnus-newsgroup-unselected)))
9553 ;; Report back a success?
9554 (and header (mail-header-number header))))
9556 (defun gnus-summary-work-articles (n)
9557 "Return a list of articles to be worked upon. The prefix argument,
9558 the list of process marked articles, and the current article will be
9559 taken into consideration."
9562 ;; A numerical prefix has been given.
9563 (let ((backward (< n 0))
9564 (n (abs (prefix-numeric-value n)))
9569 (push (setq article (gnus-summary-article-number))
9572 (gnus-summary-find-prev nil article)
9573 (gnus-summary-find-next nil article)))
9575 (nreverse articles)))
9576 ((and (boundp 'transient-mark-mode)
9579 ;; Work on the region between point and mark.
9580 (let ((max (max (point) (mark)))
9583 (goto-char (min (point) (mark)))
9586 (push (setq article (gnus-summary-article-number)) articles)
9587 (gnus-summary-find-next nil article)
9589 (nreverse articles))))
9590 (gnus-newsgroup-processable
9591 ;; There are process-marked articles present.
9592 (reverse gnus-newsgroup-processable))
9594 ;; Just return the current article.
9595 (list (gnus-summary-article-number)))))
9597 (defun gnus-summary-search-group (&optional backward use-level)
9598 "Search for next unread newsgroup.
9599 If optional argument BACKWARD is non-nil, search backward instead."
9601 (set-buffer gnus-group-buffer)
9602 (if (gnus-group-search-forward
9603 backward nil (if use-level (gnus-group-group-level) nil))
9604 (gnus-group-group-name))))
9606 (defun gnus-summary-best-group (&optional exclude-group)
9607 "Find the name of the best unread group.
9608 If EXCLUDE-GROUP, do not go to this group."
9610 (set-buffer gnus-group-buffer)
9612 (gnus-group-best-unread-group exclude-group))))
9614 (defun gnus-summary-find-next (&optional unread article backward)
9615 (if backward (gnus-summary-find-prev)
9616 (let* ((dummy (gnus-summary-article-intangible-p))
9617 (article (or article (gnus-summary-article-number)))
9618 (arts (gnus-data-find-list article))
9620 (when (and (not dummy)
9621 (or (not gnus-summary-check-current)
9623 (not (gnus-data-unread-p (car arts)))))
9624 (setq arts (cdr arts)))
9629 (when (gnus-data-unread-p (car arts))
9630 (setq result (car arts)
9632 (setq arts (cdr arts)))
9635 (goto-char (gnus-data-pos result))
9636 (gnus-data-number result)))))
9638 (defun gnus-summary-find-prev (&optional unread article)
9639 (let* ((eobp (eobp))
9640 (article (or article (gnus-summary-article-number)))
9641 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9643 (when (and (not eobp)
9644 (or (not gnus-summary-check-current)
9646 (not (gnus-data-unread-p (car arts)))))
9647 (setq arts (cdr arts)))
9652 (and (gnus-data-unread-p (car arts))
9653 (setq result (car arts)
9655 (setq arts (cdr arts)))
9659 (goto-char (gnus-data-pos result))
9660 (gnus-data-number result)))))
9662 (defun gnus-summary-find-subject (subject &optional unread backward article)
9663 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9664 (article (or article (gnus-summary-article-number)))
9665 (articles (gnus-data-list backward))
9666 (arts (gnus-data-find-list article articles))
9668 (when (or (not gnus-summary-check-current)
9670 (not (gnus-data-unread-p (car arts))))
9671 (setq arts (cdr arts)))
9673 (and (or (not unread)
9674 (gnus-data-unread-p (car arts)))
9675 (vectorp (gnus-data-header (car arts)))
9677 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9678 (setq result (car arts)
9680 (setq arts (cdr arts)))
9682 (goto-char (gnus-data-pos result))
9683 (gnus-data-number result))))
9685 (defun gnus-summary-search-forward (&optional unread subject backward)
9686 "Search forward for an article.
9687 If UNREAD, look for unread articles. If SUBJECT, look for
9688 articles with that subject. If BACKWARD, search backward instead."
9689 (cond (subject (gnus-summary-find-subject subject unread backward))
9690 (backward (gnus-summary-find-prev unread))
9691 (t (gnus-summary-find-next unread))))
9693 (defun gnus-recenter (&optional n)
9694 "Center point in window and redisplay frame.
9695 Also do horizontal recentering."
9697 (when (and gnus-auto-center-summary
9698 (not (eq gnus-auto-center-summary 'vertical)))
9699 (gnus-horizontal-recenter))
9702 (defun gnus-summary-recenter ()
9703 "Center point in the summary window.
9704 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9705 displayed, no centering will be performed."
9706 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9707 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9708 (let* ((top (cond ((< (window-height) 4) 0)
9709 ((< (window-height) 7) 1)
9711 (height (1- (window-height)))
9712 (bottom (save-excursion (goto-char (point-max))
9713 (forward-line (- height))
9715 (window (get-buffer-window (current-buffer))))
9716 ;; The user has to want it.
9717 (when gnus-auto-center-summary
9718 (when (get-buffer-window gnus-article-buffer)
9719 ;; Only do recentering when the article buffer is displayed,
9720 ;; Set the window start to either `bottom', which is the biggest
9721 ;; possible valid number, or the second line from the top,
9722 ;; whichever is the least.
9724 window (min bottom (save-excursion
9725 (forward-line (- top)) (point)))))
9726 ;; Do horizontal recentering while we're at it.
9727 (when (and (get-buffer-window (current-buffer) t)
9728 (not (eq gnus-auto-center-summary 'vertical)))
9729 (let ((selected (selected-window)))
9730 (select-window (get-buffer-window (current-buffer) t))
9731 (gnus-summary-position-point)
9732 (gnus-horizontal-recenter)
9733 (select-window selected))))))
9735 (defun gnus-horizontal-recenter ()
9736 "Recenter the current buffer horizontally."
9737 (if (< (current-column) (/ (window-width) 2))
9738 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9739 (let* ((orig (point))
9740 (end (window-end (get-buffer-window (current-buffer) t)))
9742 ;; Find the longest line currently displayed in the window.
9743 (goto-char (window-start))
9744 (while (and (not (eobp))
9747 (setq max (max max (current-column)))
9750 ;; Scroll horizontally to center (sort of) the point.
9751 (if (> max (window-width))
9753 (get-buffer-window (current-buffer) t)
9754 (min (- (current-column) (/ (window-width) 3))
9755 (+ 2 (- max (window-width)))))
9756 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9759 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9760 (defun gnus-short-group-name (group &optional levels)
9761 "Collapse GROUP name LEVELS."
9768 (while (string-match "\\." group skip)
9769 (setq skip (match-end 0)
9772 (if (string-match ":" group)
9773 (setq foreign (substring group 0 (match-end 0))
9774 group (substring group (match-end 0))))
9776 (if (and (string-match "\\." group)
9777 (> levels (- gnus-group-uncollapsed-levels 1)))
9778 (setq name (concat name (substring group 0 1))
9779 group (substring group (match-end 0))
9781 name (concat name "."))
9782 (setq name (concat foreign name group)
9786 (defun gnus-summary-jump-to-group (newsgroup)
9787 "Move point to NEWSGROUP in group mode buffer."
9788 ;; Keep update point of group mode buffer if visible.
9789 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9790 (save-window-excursion
9791 ;; Take care of tree window mode.
9792 (if (get-buffer-window gnus-group-buffer)
9793 (pop-to-buffer gnus-group-buffer))
9794 (gnus-group-jump-to-group newsgroup))
9796 ;; Take care of tree window mode.
9797 (if (get-buffer-window gnus-group-buffer)
9798 (pop-to-buffer gnus-group-buffer)
9799 (set-buffer gnus-group-buffer))
9800 (gnus-group-jump-to-group newsgroup))))
9802 ;; This function returns a list of article numbers based on the
9803 ;; difference between the ranges of read articles in this group and
9804 ;; the range of active articles.
9805 (defun gnus-list-of-unread-articles (group)
9806 (let* ((read (gnus-info-read (gnus-get-info group)))
9807 (active (gnus-active group))
9810 ;; If none are read, then all are unread.
9812 (setq first (car active))
9813 ;; If the range of read articles is a single range, then the
9814 ;; first unread article is the article after the last read
9815 ;; article. Sounds logical, doesn't it?
9816 (if (not (listp (cdr read)))
9817 (setq first (1+ (cdr read)))
9818 ;; `read' is a list of ranges.
9819 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9824 (while (< first nlast)
9825 (setq unread (cons first unread))
9826 (setq first (1+ first))))
9827 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9828 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9829 (setq read (cdr read)))))
9830 ;; And add the last unread articles.
9831 (while (<= first last)
9832 (setq unread (cons first unread))
9833 (setq first (1+ first)))
9834 ;; Return the list of unread articles.
9837 (defun gnus-list-of-read-articles (group)
9838 "Return a list of unread, unticked and non-dormant articles."
9839 (let* ((info (gnus-get-info group))
9840 (marked (gnus-info-marks info))
9841 (active (gnus-active group)))
9843 (gnus-set-difference
9844 (gnus-sorted-complement
9845 (gnus-uncompress-range active)
9846 (gnus-list-of-unread-articles group))
9848 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9849 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9851 ;; Various summary commands
9853 (defun gnus-summary-universal-argument (arg)
9854 "Perform any operation on all articles that are process/prefixed."
9856 (gnus-set-global-variables)
9857 (let ((articles (gnus-summary-work-articles arg))
9864 (substitute-command-keys
9865 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9868 (gnus-error 1 "Undefined key")
9871 (gnus-summary-goto-subject (setq article (pop articles)))
9872 (command-execute func)
9873 (gnus-summary-remove-process-mark article)))))
9874 (gnus-summary-position-point))
9876 (defun gnus-summary-toggle-truncation (&optional arg)
9877 "Toggle truncation of summary lines.
9878 With arg, turn line truncation on iff arg is positive."
9880 (setq truncate-lines
9881 (if (null arg) (not truncate-lines)
9882 (> (prefix-numeric-value arg) 0)))
9885 (defun gnus-summary-reselect-current-group (&optional all rescan)
9886 "Exit and then reselect the current newsgroup.
9887 The prefix argument ALL means to select all articles."
9889 (gnus-set-global-variables)
9890 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9891 (error "Ephemeral groups can't be reselected"))
9892 (let ((current-subject (gnus-summary-article-number))
9893 (group gnus-newsgroup-name))
9894 (setq gnus-newsgroup-begin nil)
9896 ;; We have to adjust the point of group mode buffer because the
9897 ;; current point was moved to the next unread newsgroup by
9899 (gnus-summary-jump-to-group group)
9902 (gnus-group-get-new-news-this-group 1)))
9903 (gnus-group-read-group all t)
9904 (gnus-summary-goto-subject current-subject nil t)))
9906 (defun gnus-summary-rescan-group (&optional all)
9907 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9909 (gnus-summary-reselect-current-group all t))
9911 (defun gnus-summary-update-info ()
9912 (let* ((group gnus-newsgroup-name))
9913 (when gnus-newsgroup-kill-headers
9914 (setq gnus-newsgroup-killed
9915 (gnus-compress-sequence
9917 (gnus-set-sorted-intersection
9918 (gnus-uncompress-range gnus-newsgroup-killed)
9919 (setq gnus-newsgroup-unselected
9920 (sort gnus-newsgroup-unselected '<)))
9921 (setq gnus-newsgroup-unreads
9922 (sort gnus-newsgroup-unreads '<))) t)))
9923 (unless (listp (cdr gnus-newsgroup-killed))
9924 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9925 (let ((headers gnus-newsgroup-headers))
9926 (run-hooks 'gnus-exit-group-hook)
9927 (unless gnus-save-score
9928 (setq gnus-newsgroup-scored nil))
9929 ;; Set the new ranges of read articles.
9930 (gnus-update-read-articles
9931 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9932 ;; Set the current article marks.
9934 ;; Do the cross-ref thing.
9935 (when gnus-use-cross-reference
9936 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9937 ;; Do adaptive scoring, and possibly save score files.
9938 (when gnus-newsgroup-adaptive
9939 (gnus-score-adaptive))
9940 (when gnus-use-scoring
9942 ;; Do not switch windows but change the buffer to work.
9943 (set-buffer gnus-group-buffer)
9944 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9945 (gnus-group-update-group group)))))
9947 (defun gnus-summary-exit (&optional temporary)
9948 "Exit reading current newsgroup, and then return to group selection mode.
9949 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9951 (gnus-set-global-variables)
9952 (gnus-kill-save-kill-buffer)
9953 (let* ((group gnus-newsgroup-name)
9954 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9956 (buf (current-buffer)))
9957 (run-hooks 'gnus-summary-prepare-exit-hook)
9958 ;; If we have several article buffers, we kill them at exit.
9959 (unless gnus-single-article-buffer
9960 (gnus-kill-buffer gnus-original-article-buffer)
9961 (setq gnus-article-current nil))
9962 (when gnus-use-cache
9963 (gnus-cache-possibly-remove-articles)
9964 (gnus-cache-save-buffers))
9965 (when gnus-use-trees
9966 (gnus-tree-close group))
9967 ;; Make all changes in this group permanent.
9969 (gnus-summary-update-info))
9970 (gnus-close-group group)
9971 ;; Make sure where I was, and go to next newsgroup.
9972 (set-buffer gnus-group-buffer)
9974 (gnus-group-jump-to-group group))
9975 (run-hooks 'gnus-summary-exit-hook)
9977 (gnus-group-next-unread-group 1))
9980 ;; If we have several article buffers, we kill them at exit.
9981 (unless gnus-single-article-buffer
9982 (gnus-kill-buffer gnus-article-buffer)
9983 (gnus-kill-buffer gnus-original-article-buffer)
9984 (setq gnus-article-current nil))
9986 (if (not gnus-kill-summary-on-exit)
9987 (gnus-deaden-summary)
9988 ;; We set all buffer-local variables to nil. It is unclear why
9989 ;; this is needed, but if we don't, buffer-local variables are
9990 ;; not garbage-collected, it seems. This would the lead to en
9991 ;; ever-growing Emacs.
9992 (gnus-summary-clear-local-variables)
9993 (when (get-buffer gnus-article-buffer)
9994 (bury-buffer gnus-article-buffer))
9995 ;; We clear the global counterparts of the buffer-local
9996 ;; variables as well, just to be on the safe side.
9997 (gnus-configure-windows 'group 'force)
9998 (gnus-summary-clear-local-variables)
9999 ;; Return to group mode buffer.
10000 (if (eq mode 'gnus-summary-mode)
10001 (gnus-kill-buffer buf)))
10002 (setq gnus-current-select-method gnus-select-method)
10003 (pop-to-buffer gnus-group-buffer)
10004 ;; Clear the current group name.
10005 (if (not quit-config)
10007 (gnus-group-jump-to-group group)
10008 (gnus-group-next-unread-group 1)
10009 (gnus-configure-windows 'group 'force))
10010 (if (not (buffer-name (car quit-config)))
10011 (gnus-configure-windows 'group 'force)
10012 (set-buffer (car quit-config))
10013 (and (eq major-mode 'gnus-summary-mode)
10014 (gnus-set-global-variables))
10015 (gnus-configure-windows (cdr quit-config))))
10016 (unless quit-config
10017 (setq gnus-newsgroup-name nil)))))
10019 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10020 (defun gnus-summary-exit-no-update (&optional no-questions)
10021 "Quit reading current newsgroup without updating read article info."
10023 (gnus-set-global-variables)
10024 (let* ((group gnus-newsgroup-name)
10025 (quit-config (gnus-group-quit-config group)))
10026 (when (or no-questions
10028 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10029 ;; If we have several article buffers, we kill them at exit.
10030 (unless gnus-single-article-buffer
10031 (gnus-kill-buffer gnus-article-buffer)
10032 (gnus-kill-buffer gnus-original-article-buffer)
10033 (setq gnus-article-current nil))
10034 (if (not gnus-kill-summary-on-exit)
10035 (gnus-deaden-summary)
10036 (gnus-close-group group)
10037 (gnus-summary-clear-local-variables)
10038 (set-buffer gnus-group-buffer)
10039 (gnus-summary-clear-local-variables)
10040 (when (get-buffer gnus-summary-buffer)
10041 (kill-buffer gnus-summary-buffer)))
10042 (unless gnus-single-article-buffer
10043 (setq gnus-article-current nil))
10044 (when gnus-use-trees
10045 (gnus-tree-close group))
10046 (when (get-buffer gnus-article-buffer)
10047 (bury-buffer gnus-article-buffer))
10048 ;; Return to the group buffer.
10049 (gnus-configure-windows 'group 'force)
10050 ;; Clear the current group name.
10051 (setq gnus-newsgroup-name nil)
10052 (when (equal (gnus-group-group-name) group)
10053 (gnus-group-next-unread-group 1))
10055 (if (not (buffer-name (car quit-config)))
10056 (gnus-configure-windows 'group 'force)
10057 (set-buffer (car quit-config))
10058 (when (eq major-mode 'gnus-summary-mode)
10059 (gnus-set-global-variables))
10060 (gnus-configure-windows (cdr quit-config)))))))
10062 ;;; Dead summaries.
10064 (defvar gnus-dead-summary-mode-map nil)
10066 (if gnus-dead-summary-mode-map
10068 (setq gnus-dead-summary-mode-map (make-keymap))
10069 (suppress-keymap gnus-dead-summary-mode-map)
10070 (substitute-key-definition
10071 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10072 (let ((keys '("\C-d" "\r" "\177")))
10074 (define-key gnus-dead-summary-mode-map
10075 (pop keys) 'gnus-summary-wake-up-the-dead))))
10077 (defvar gnus-dead-summary-mode nil
10078 "Minor mode for Gnus summary buffers.")
10080 (defun gnus-dead-summary-mode (&optional arg)
10081 "Minor mode for Gnus summary buffers."
10083 (when (eq major-mode 'gnus-summary-mode)
10084 (make-local-variable 'gnus-dead-summary-mode)
10085 (setq gnus-dead-summary-mode
10086 (if (null arg) (not gnus-dead-summary-mode)
10087 (> (prefix-numeric-value arg) 0)))
10088 (when gnus-dead-summary-mode
10089 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10090 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10091 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10092 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10093 minor-mode-map-alist)))))
10095 (defun gnus-deaden-summary ()
10096 "Make the current summary buffer into a dead summary buffer."
10097 ;; Kill any previous dead summary buffer.
10098 (when (and gnus-dead-summary
10099 (buffer-name gnus-dead-summary))
10101 (set-buffer gnus-dead-summary)
10102 (when gnus-dead-summary-mode
10103 (kill-buffer (current-buffer)))))
10104 ;; Make this the current dead summary.
10105 (setq gnus-dead-summary (current-buffer))
10106 (gnus-dead-summary-mode 1)
10107 (let ((name (buffer-name)))
10108 (when (string-match "Summary" name)
10110 (concat (substring name 0 (match-beginning 0)) "Dead "
10111 (substring name (match-beginning 0))) t))))
10113 (defun gnus-kill-or-deaden-summary (buffer)
10114 "Kill or deaden the summary BUFFER."
10115 (when (and (buffer-name buffer)
10116 (not gnus-single-article-buffer))
10118 (set-buffer buffer)
10119 (gnus-kill-buffer gnus-article-buffer)
10120 (gnus-kill-buffer gnus-original-article-buffer)))
10121 (cond (gnus-kill-summary-on-exit
10122 (when (and gnus-use-trees
10123 (and (get-buffer buffer)
10124 (buffer-name (get-buffer buffer))))
10126 (set-buffer (get-buffer buffer))
10127 (gnus-tree-close gnus-newsgroup-name)))
10128 (gnus-kill-buffer buffer))
10129 ((and (get-buffer buffer)
10130 (buffer-name (get-buffer buffer)))
10132 (set-buffer buffer)
10133 (gnus-deaden-summary)))))
10135 (defun gnus-summary-wake-up-the-dead (&rest args)
10136 "Wake up the dead summary buffer."
10138 (gnus-dead-summary-mode -1)
10139 (let ((name (buffer-name)))
10140 (when (string-match "Dead " name)
10142 (concat (substring name 0 (match-beginning 0))
10143 (substring name (match-end 0))) t)))
10144 (gnus-message 3 "This dead summary is now alive again"))
10146 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10147 (defun gnus-summary-fetch-faq (&optional faq-dir)
10148 "Fetch the FAQ for the current group.
10149 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10153 (if current-prefix-arg
10155 "Faq dir: " (and (listp gnus-group-faq-directory)
10156 gnus-group-faq-directory)))))
10157 (let (gnus-faq-buffer)
10158 (and (setq gnus-faq-buffer
10159 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10160 (gnus-configure-windows 'summary-faq))))
10162 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10163 (defun gnus-summary-describe-group (&optional force)
10164 "Describe the current newsgroup."
10166 (gnus-group-describe-group force gnus-newsgroup-name))
10168 (defun gnus-summary-describe-briefly ()
10169 "Describe summary mode commands briefly."
10172 (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")))
10174 ;; Walking around group mode buffer from summary mode.
10176 (defun gnus-summary-next-group (&optional no-article target-group backward)
10177 "Exit current newsgroup and then select next unread newsgroup.
10178 If prefix argument NO-ARTICLE is non-nil, no article is selected
10179 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10180 previous group instead."
10182 (gnus-set-global-variables)
10183 (let ((current-group gnus-newsgroup-name)
10184 (current-buffer (current-buffer))
10186 ;; First we semi-exit this group to update Xrefs and all variables.
10187 ;; We can't do a real exit, because the window conf must remain
10188 ;; the same in case the user is prompted for info, and we don't
10189 ;; want the window conf to change before that...
10190 (gnus-summary-exit t)
10191 (while (not entered)
10192 ;; Then we find what group we are supposed to enter.
10193 (set-buffer gnus-group-buffer)
10194 (gnus-group-jump-to-group current-group)
10197 (if (eq gnus-keep-same-level 'best)
10198 (gnus-summary-best-group gnus-newsgroup-name)
10199 (gnus-summary-search-group backward gnus-keep-same-level))))
10200 (if (not target-group)
10201 ;; There are no further groups, so we return to the group
10204 (gnus-message 5 "Returning to the group buffer")
10206 (set-buffer current-buffer)
10207 (gnus-summary-exit))
10208 ;; We try to enter the target group.
10209 (gnus-group-jump-to-group target-group)
10210 (let ((unreads (gnus-group-group-unread)))
10211 (if (and (or (eq t unreads)
10212 (and unreads (not (zerop unreads))))
10213 (gnus-summary-read-group
10214 target-group nil no-article current-buffer))
10216 (setq current-group target-group
10217 target-group nil)))))))
10219 (defun gnus-summary-prev-group (&optional no-article)
10220 "Exit current newsgroup and then select previous unread newsgroup.
10221 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10223 (gnus-summary-next-group no-article nil t))
10225 ;; Walking around summary lines.
10227 (defun gnus-summary-first-subject (&optional unread)
10228 "Go to the first unread subject.
10229 If UNREAD is non-nil, go to the first unread article.
10230 Returns the article selected or nil if there are no unread articles."
10235 ((null gnus-newsgroup-data)
10236 (gnus-message 3 "No articles in the group")
10238 ;; Pick the first article.
10240 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10241 (gnus-data-number (car gnus-newsgroup-data)))
10242 ;; No unread articles.
10243 ((null gnus-newsgroup-unreads)
10244 (gnus-message 3 "No more unread articles")
10246 ;; Find the first unread article.
10248 (let ((data gnus-newsgroup-data))
10250 (not (gnus-data-unread-p (car data))))
10251 (setq data (cdr data)))
10254 (goto-char (gnus-data-pos (car data)))
10255 (gnus-data-number (car data)))))))
10256 (gnus-summary-position-point)))
10258 (defun gnus-summary-next-subject (n &optional unread dont-display)
10259 "Go to next N'th summary line.
10260 If N is negative, go to the previous N'th subject line.
10261 If UNREAD is non-nil, only unread articles are selected.
10262 The difference between N and the actual number of steps taken is
10265 (let ((backward (< n 0))
10267 (while (and (> n 0)
10269 (gnus-summary-find-prev unread)
10270 (gnus-summary-find-next unread)))
10272 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10273 (if unread " unread" "")))
10274 (unless dont-display
10275 (gnus-summary-recenter)
10276 (gnus-summary-position-point))
10279 (defun gnus-summary-next-unread-subject (n)
10280 "Go to next N'th unread summary line."
10282 (gnus-summary-next-subject n t))
10284 (defun gnus-summary-prev-subject (n &optional unread)
10285 "Go to previous N'th summary line.
10286 If optional argument UNREAD is non-nil, only unread article is selected."
10288 (gnus-summary-next-subject (- n) unread))
10290 (defun gnus-summary-prev-unread-subject (n)
10291 "Go to previous N'th unread summary line."
10293 (gnus-summary-next-subject (- n) t))
10295 (defun gnus-summary-goto-subject (article &optional force silent)
10296 "Go the subject line of ARTICLE.
10297 If FORCE, also allow jumping to articles not currently shown."
10299 (data (gnus-data-find article)))
10300 ;; We read in the article if we have to.
10303 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10304 (setq data (gnus-data-find article)))
10309 (gnus-message 3 "Can't find article %d" article))
10311 (goto-char (gnus-data-pos data))
10314 ;; Walking around summary lines with displaying articles.
10316 (defun gnus-summary-expand-window (&optional arg)
10317 "Make the summary buffer take up the entire Emacs frame.
10318 Given a prefix, will force an `article' buffer configuration."
10320 (gnus-set-global-variables)
10322 (gnus-configure-windows 'article 'force)
10323 (gnus-configure-windows 'summary 'force)))
10325 (defun gnus-summary-display-article (article &optional all-header)
10326 "Display ARTICLE in article buffer."
10327 (gnus-set-global-variables)
10331 (if gnus-summary-display-article-function
10332 (funcall gnus-summary-display-article-function article all-header)
10333 (gnus-article-prepare article all-header))
10334 (run-hooks 'gnus-select-article-hook)
10335 (unless (zerop gnus-current-article)
10336 (gnus-summary-goto-subject gnus-current-article))
10337 (gnus-summary-recenter)
10338 (when gnus-use-trees
10339 (gnus-possibly-generate-tree article)
10340 (gnus-highlight-selected-tree article))
10341 ;; Successfully display article.
10342 (gnus-article-set-window-start
10343 (cdr (assq article gnus-newsgroup-bookmarks))))))
10345 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10346 "Select the current article.
10347 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10348 non-nil, the article will be re-fetched even if it already present in
10349 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10351 ;; Make sure we are in the summary buffer to work around bbdb bug.
10352 (unless (eq major-mode 'gnus-summary-mode)
10353 (set-buffer gnus-summary-buffer))
10354 (let ((article (or article (gnus-summary-article-number)))
10355 (all-headers (not (not all-headers))) ;Must be T or NIL.
10356 gnus-summary-display-article-function
10359 (gnus-summary-article-pseudo-p article)
10360 (error "This is a pseudo-article."))
10363 (set-buffer gnus-summary-buffer)
10364 (if (or (and gnus-single-article-buffer
10365 (or (null gnus-current-article)
10366 (null gnus-article-current)
10367 (null (get-buffer gnus-article-buffer))
10368 (not (eq article (cdr gnus-article-current)))
10369 (not (equal (car gnus-article-current)
10370 gnus-newsgroup-name))))
10371 (and (not gnus-single-article-buffer)
10372 (or (null gnus-current-article)
10373 (not (eq gnus-current-article article))))
10375 ;; The requested article is different from the current article.
10377 (gnus-summary-display-article article all-headers)
10378 (setq did article))
10379 (if (or all-headers gnus-show-all-headers)
10380 (gnus-article-show-all-headers))
10383 (gnus-article-set-window-start
10384 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10386 (defun gnus-summary-set-current-mark (&optional current-mark)
10387 "Obsolete function."
10390 (defun gnus-summary-next-article (&optional unread subject backward push)
10391 "Select the next article.
10392 If UNREAD, only unread articles are selected.
10393 If SUBJECT, only articles with SUBJECT are selected.
10394 If BACKWARD, the previous article is selected instead of the next."
10396 (gnus-set-global-variables)
10398 ;; Is there such an article?
10399 ((and (gnus-summary-search-forward unread subject backward)
10400 (or (gnus-summary-display-article (gnus-summary-article-number))
10401 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10402 (gnus-summary-position-point))
10403 ;; If not, we try the first unread, if that is wanted.
10405 gnus-auto-select-same
10406 (or (gnus-summary-first-unread-article)
10407 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10408 (gnus-summary-position-point)
10409 (gnus-message 6 "Wrapped"))
10410 ;; Try to get next/previous article not displayed in this group.
10411 ((and gnus-auto-extend-newsgroup
10412 (not unread) (not subject))
10413 (gnus-summary-goto-article
10414 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10416 ;; Go to next/previous group.
10418 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10419 (gnus-summary-jump-to-group gnus-newsgroup-name))
10420 (let ((cmd last-command-char)
10422 (if (eq gnus-keep-same-level 'best)
10423 (gnus-summary-best-group gnus-newsgroup-name)
10424 (gnus-summary-search-group backward gnus-keep-same-level))))
10425 ;; For some reason, the group window gets selected. We change
10427 (select-window (get-buffer-window (current-buffer)))
10428 ;; Select next unread newsgroup automagically.
10430 ((or (not gnus-auto-select-next)
10432 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10433 ((or (eq gnus-auto-select-next 'quietly)
10434 (and (eq gnus-auto-select-next 'slightly-quietly)
10436 (and (eq gnus-auto-select-next 'almost-quietly)
10437 (gnus-summary-last-article-p)))
10439 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10440 (gnus-summary-exit)
10441 (gnus-message 7 "No more%s articles (%s)..."
10442 (if unread " unread" "")
10443 (if group (concat "selecting " group)
10445 (gnus-summary-next-group nil group backward)))
10447 (gnus-summary-walk-group-buffer
10448 gnus-newsgroup-name cmd unread backward)))))))
10450 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10451 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10452 (?\C-p (gnus-group-prev-unread-group 1))))
10453 keve key group ended)
10455 (set-buffer gnus-group-buffer)
10456 (gnus-summary-jump-to-group from-group)
10458 (if (eq gnus-keep-same-level 'best)
10459 (gnus-summary-best-group gnus-newsgroup-name)
10460 (gnus-summary-search-group backward gnus-keep-same-level))))
10463 5 "No more%s articles%s" (if unread " unread" "")
10465 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10466 (format " (Type %s for %s [%s])"
10467 (single-key-description cmd) group
10468 (car (gnus-gethash group gnus-newsrc-hashtb)))
10469 (format " (Type %s to exit %s)"
10470 (single-key-description cmd)
10471 gnus-newsgroup-name)))
10472 ;; Confirm auto selection.
10473 (setq key (car (setq keve (gnus-read-event-char))))
10476 ((assq key keystrokes)
10477 (let ((obuf (current-buffer)))
10478 (switch-to-buffer gnus-group-buffer)
10480 (gnus-group-jump-to-group group))
10481 (eval (cadr (assq key keystrokes)))
10482 (setq group (gnus-group-group-name))
10483 (switch-to-buffer obuf))
10486 (if (or (not group)
10487 (gnus-ephemeral-group-p gnus-newsgroup-name))
10488 (gnus-summary-exit)
10489 (gnus-summary-next-group nil group backward)))
10491 (push (cdr keve) unread-command-events))))))
10493 (defun gnus-read-event-char ()
10494 "Get the next event."
10495 (let ((event (read-event)))
10496 (cons (and (numberp event) event) event)))
10498 (defun gnus-summary-next-unread-article ()
10499 "Select unread article after current one."
10501 (gnus-summary-next-article t (and gnus-auto-select-same
10502 (gnus-summary-article-subject))))
10504 (defun gnus-summary-prev-article (&optional unread subject)
10505 "Select the article after the current one.
10506 If UNREAD is non-nil, only unread articles are selected."
10508 (gnus-summary-next-article unread subject t))
10510 (defun gnus-summary-prev-unread-article ()
10511 "Select unred article before current one."
10513 (gnus-summary-prev-article t (and gnus-auto-select-same
10514 (gnus-summary-article-subject))))
10516 (defun gnus-summary-next-page (&optional lines circular)
10517 "Show next page of the selected article.
10518 If at the end of the current article, select the next article.
10519 LINES says how many lines should be scrolled up.
10521 If CIRCULAR is non-nil, go to the start of the article instead of
10522 selecting the next article when reaching the end of the current
10525 (setq gnus-summary-buffer (current-buffer))
10526 (gnus-set-global-variables)
10527 (let ((article (gnus-summary-article-number))
10529 (gnus-configure-windows 'article)
10530 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10531 (if (and (eq gnus-summary-goto-unread 'never)
10532 (not (gnus-summary-last-article-p article)))
10533 (gnus-summary-next-article)
10534 (gnus-summary-next-unread-article))
10535 (if (or (null gnus-current-article)
10536 (null gnus-article-current)
10537 (/= article (cdr gnus-article-current))
10538 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10539 ;; Selected subject is different from current article's.
10540 (gnus-summary-display-article article)
10541 (gnus-eval-in-buffer-window gnus-article-buffer
10542 (setq endp (gnus-article-next-page lines)))
10545 (gnus-summary-beginning-of-article))
10547 (gnus-message 3 "End of message"))
10549 (if (and (eq gnus-summary-goto-unread 'never)
10550 (not (gnus-summary-last-article-p article)))
10551 (gnus-summary-next-article)
10552 (gnus-summary-next-unread-article)))))))
10553 (gnus-summary-recenter)
10554 (gnus-summary-position-point)))
10556 (defun gnus-summary-prev-page (&optional lines)
10557 "Show previous page of selected article.
10558 Argument LINES specifies lines to be scrolled down."
10560 (gnus-set-global-variables)
10561 (let ((article (gnus-summary-article-number)))
10562 (gnus-configure-windows 'article)
10563 (if (or (null gnus-current-article)
10564 (null gnus-article-current)
10565 (/= article (cdr gnus-article-current))
10566 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10567 ;; Selected subject is different from current article's.
10568 (gnus-summary-display-article article)
10569 (gnus-summary-recenter)
10570 (gnus-eval-in-buffer-window gnus-article-buffer
10571 (gnus-article-prev-page lines))))
10572 (gnus-summary-position-point))
10574 (defun gnus-summary-scroll-up (lines)
10575 "Scroll up (or down) one line current article.
10576 Argument LINES specifies lines to be scrolled up (or down if negative)."
10578 (gnus-set-global-variables)
10579 (gnus-configure-windows 'article)
10580 (gnus-summary-show-thread)
10581 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10582 (gnus-eval-in-buffer-window gnus-article-buffer
10584 (if (gnus-article-next-page lines)
10585 (gnus-message 3 "End of message")))
10587 (gnus-article-prev-page (- lines))))))
10588 (gnus-summary-recenter)
10589 (gnus-summary-position-point))
10591 (defun gnus-summary-next-same-subject ()
10592 "Select next article which has the same subject as current one."
10594 (gnus-set-global-variables)
10595 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10597 (defun gnus-summary-prev-same-subject ()
10598 "Select previous article which has the same subject as current one."
10600 (gnus-set-global-variables)
10601 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10603 (defun gnus-summary-next-unread-same-subject ()
10604 "Select next unread article which has the same subject as current one."
10606 (gnus-set-global-variables)
10607 (gnus-summary-next-article t (gnus-summary-article-subject)))
10609 (defun gnus-summary-prev-unread-same-subject ()
10610 "Select previous unread article which has the same subject as current one."
10612 (gnus-set-global-variables)
10613 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10615 (defun gnus-summary-first-unread-article ()
10616 "Select the first unread article.
10617 Return nil if there are no unread articles."
10619 (gnus-set-global-variables)
10621 (if (gnus-summary-first-subject t)
10623 (gnus-summary-show-thread)
10624 (gnus-summary-first-subject t)
10625 (gnus-summary-display-article (gnus-summary-article-number))))
10626 (gnus-summary-position-point)))
10628 (defun gnus-summary-best-unread-article ()
10629 "Select the unread article with the highest score."
10631 (gnus-set-global-variables)
10632 (let ((best -1000000)
10633 (data gnus-newsgroup-data)
10636 (and (gnus-data-unread-p (car data))
10638 (gnus-summary-article-score (gnus-data-number (car data))))
10641 article (gnus-data-number (car data))))
10642 (setq data (cdr data)))
10645 (gnus-summary-goto-article article)
10646 (error "No unread articles"))
10647 (gnus-summary-position-point))))
10649 (defun gnus-summary-last-subject ()
10650 "Go to the last displayed subject line in the group."
10651 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10653 (gnus-summary-goto-subject article))))
10655 (defun gnus-summary-goto-article (article &optional all-headers force)
10656 "Fetch ARTICLE and display it if it exists.
10657 If ALL-HEADERS is non-nil, no header lines are hidden."
10663 (mapcar (lambda (number) (list (int-to-string number)))
10664 gnus-newsgroup-limit)))
10668 (if (gnus-summary-goto-subject article force)
10669 (gnus-summary-display-article article all-headers)
10670 (gnus-message 4 "Couldn't go to article %s" article) nil)
10671 (gnus-summary-position-point)))
10673 (defun gnus-summary-goto-last-article ()
10674 "Go to the previously read article."
10677 (and gnus-last-article
10678 (gnus-summary-goto-article gnus-last-article))
10679 (gnus-summary-position-point)))
10681 (defun gnus-summary-pop-article (number)
10682 "Pop one article off the history and go to the previous.
10683 NUMBER articles will be popped off."
10686 (setq gnus-newsgroup-history
10687 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10689 (gnus-summary-goto-article (car to))
10690 (error "Article history empty")))
10691 (gnus-summary-position-point))
10693 ;; Summary commands and functions for limiting the summary buffer.
10695 (defun gnus-summary-limit-to-articles (n)
10696 "Limit the summary buffer to the next N articles.
10697 If not given a prefix, use the process marked articles instead."
10699 (gnus-set-global-variables)
10701 (let ((articles (gnus-summary-work-articles n)))
10702 (setq gnus-newsgroup-processable nil)
10703 (gnus-summary-limit articles))
10704 (gnus-summary-position-point)))
10706 (defun gnus-summary-pop-limit (&optional total)
10707 "Restore the previous limit.
10708 If given a prefix, remove all limits."
10710 (gnus-set-global-variables)
10712 (setq gnus-newsgroup-limits
10713 (list (mapcar (lambda (h) (mail-header-number h))
10714 gnus-newsgroup-headers))))
10715 (unless gnus-newsgroup-limits
10716 (error "No limit to pop"))
10718 (gnus-summary-limit nil 'pop)
10719 (gnus-summary-position-point)))
10721 (defun gnus-summary-limit-to-subject (subject &optional header)
10722 "Limit the summary buffer to articles that have subjects that match a regexp."
10723 (interactive "sRegexp: ")
10725 (setq header "subject"))
10726 (when (not (equal "" subject))
10728 (let ((articles (gnus-summary-find-matching
10729 (or header "subject") subject 'all)))
10730 (or articles (error "Found no matches for \"%s\"" subject))
10731 (gnus-summary-limit articles))
10732 (gnus-summary-position-point))))
10734 (defun gnus-summary-limit-to-author (from)
10735 "Limit the summary buffer to articles that have authors that match a regexp."
10736 (interactive "sRegexp: ")
10737 (gnus-summary-limit-to-subject from "from"))
10739 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10741 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10743 (defun gnus-summary-limit-to-unread (&optional all)
10744 "Limit the summary buffer to articles that are not marked as read.
10745 If ALL is non-nil, limit strictly to unread articles."
10748 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10749 (gnus-summary-limit-to-marks
10750 ;; Concat all the marks that say that an article is read and have
10752 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10753 gnus-killed-mark gnus-kill-file-mark
10754 gnus-low-score-mark gnus-expirable-mark
10755 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10758 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10759 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10761 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10762 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10763 If REVERSE, limit the summary buffer to articles that are not marked
10764 with MARKS. MARKS can either be a string of marks or a list of marks.
10765 Returns how many articles were removed."
10766 (interactive "sMarks: ")
10767 (gnus-set-global-variables)
10769 (let ((data gnus-newsgroup-data)
10770 (marks (if (listp marks) marks
10771 (append marks nil))) ; Transform to list.
10774 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10775 (memq (gnus-data-mark (car data)) marks))
10776 (setq articles (cons (gnus-data-number (car data)) articles)))
10777 (setq data (cdr data)))
10778 (gnus-summary-limit articles))
10779 (gnus-summary-position-point)))
10781 (defun gnus-summary-limit-to-score (&optional score)
10782 "Limit to articles with score at or above SCORE."
10784 (gnus-set-global-variables)
10785 (setq score (if score
10786 (prefix-numeric-value score)
10787 (or gnus-summary-default-score 0)))
10788 (let ((data gnus-newsgroup-data)
10791 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10793 (push (gnus-data-number (car data)) articles))
10794 (setq data (cdr data)))
10796 (gnus-summary-limit articles)
10797 (gnus-summary-position-point))))
10799 (defun gnus-summary-limit-include-dormant ()
10800 "Display all the hidden articles that are marked as dormant."
10802 (gnus-set-global-variables)
10803 (or gnus-newsgroup-dormant
10804 (error "There are no dormant articles in this group"))
10806 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10807 (gnus-summary-position-point)))
10809 (defun gnus-summary-limit-exclude-dormant ()
10810 "Hide all dormant articles."
10812 (gnus-set-global-variables)
10814 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10815 (gnus-summary-position-point)))
10817 (defun gnus-summary-limit-exclude-childless-dormant ()
10818 "Hide all dormant articles that have no children."
10820 (gnus-set-global-variables)
10821 (let ((data (gnus-data-list t))
10822 articles d children)
10823 ;; Find all articles that are either not dormant or have
10825 (while (setq d (pop data))
10826 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10827 (and (setq children
10828 (gnus-article-children (gnus-data-number d)))
10831 (when (memq (car children) articles)
10836 (push (gnus-data-number d) articles)))
10837 ;; Do the limiting.
10839 (gnus-summary-limit articles)
10840 (gnus-summary-position-point))))
10842 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10843 "Mark all unread excluded articles as read.
10844 If ALL, mark even excluded ticked and dormants as read."
10846 (let ((articles (gnus-sorted-complement
10848 (mapcar (lambda (h) (mail-header-number h))
10849 gnus-newsgroup-headers)
10851 (sort gnus-newsgroup-limit '<)))
10853 (setq gnus-newsgroup-unreads nil)
10855 (setq gnus-newsgroup-dormant nil
10856 gnus-newsgroup-marked nil
10857 gnus-newsgroup-reads
10859 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10860 gnus-newsgroup-reads))
10861 (while (setq article (pop articles))
10862 (unless (or (memq article gnus-newsgroup-dormant)
10863 (memq article gnus-newsgroup-marked))
10864 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10866 (defun gnus-summary-limit (articles &optional pop)
10868 ;; We pop the previous limit off the stack and use that.
10869 (setq articles (car gnus-newsgroup-limits)
10870 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10871 ;; We use the new limit, so we push the old limit on the stack.
10872 (setq gnus-newsgroup-limits
10873 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10875 (setq gnus-newsgroup-limit articles)
10876 (let ((total (length gnus-newsgroup-data))
10877 (data (gnus-data-find-list (gnus-summary-article-number)))
10879 ;; This will do all the work of generating the new summary buffer
10880 ;; according to the new limit.
10881 (gnus-summary-prepare)
10882 ;; Hide any threads, possibly.
10883 (and gnus-show-threads
10884 gnus-thread-hide-subtree
10885 (gnus-summary-hide-all-threads))
10886 ;; Try to return to the article you were at, or one in the
10889 ;; We try to find some article after the current one.
10891 (and (gnus-summary-goto-subject
10892 (gnus-data-number (car data)) nil t)
10895 (setq data (cdr data))))
10897 ;; If there is no data, that means that we were after the last
10898 ;; article. The same goes when we can't find any articles
10899 ;; after the current one.
10901 (goto-char (point-max))
10902 (gnus-summary-find-prev)))
10903 ;; We return how many articles were removed from the summary
10904 ;; buffer as a result of the new limit.
10905 (- total (length gnus-newsgroup-data))))
10907 (defsubst gnus-invisible-cut-children (threads)
10910 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10915 (defsubst gnus-cut-thread (thread)
10916 "Go forwards in the thread until we find an article that we want to display."
10917 (when (or (eq gnus-fetch-old-headers 'some)
10918 (eq gnus-build-sparse-threads 'some)
10919 (eq gnus-build-sparse-threads 'more))
10920 ;; Deal with old-fetched headers and sparse threads.
10924 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10925 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10926 (or (<= (length (cdr thread)) 1)
10927 (gnus-invisible-cut-children (cdr thread))))
10928 (setq thread (cadr thread))))
10931 (defun gnus-cut-threads (threads)
10932 "Cut off all uninteresting articles from the beginning of threads."
10933 (when (or (eq gnus-fetch-old-headers 'some)
10934 (eq gnus-build-sparse-threads 'some)
10935 (eq gnus-build-sparse-threads 'more))
10936 (let ((th threads))
10938 (setcar th (gnus-cut-thread (car th)))
10939 (setq th (cdr th)))))
10940 ;; Remove nixed out threads.
10941 (delq nil threads))
10943 (defun gnus-summary-initial-limit (&optional show-if-empty)
10944 "Figure out what the initial limit is supposed to be on group entry.
10945 This entails weeding out unwanted dormants, low-scored articles,
10946 fetch-old-headers verbiage, and so on."
10947 ;; Most groups have nothing to remove.
10948 (if (or gnus-inhibit-limiting
10949 (and (null gnus-newsgroup-dormant)
10950 (not (eq gnus-fetch-old-headers 'some))
10951 (null gnus-summary-expunge-below)
10952 (not (eq gnus-build-sparse-threads 'some))
10953 (not (eq gnus-build-sparse-threads 'more))
10954 (null gnus-thread-expunge-below)
10955 (not gnus-use-nocem)))
10957 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10958 (setq gnus-newsgroup-limit nil)
10961 (unless (car (symbol-value node))
10962 ;; These threads have no parents -- they are roots.
10963 (let ((nodes (cdr (symbol-value node)))
10966 (if (and gnus-thread-expunge-below
10967 (< (gnus-thread-total-score (car nodes))
10968 gnus-thread-expunge-below))
10969 (gnus-expunge-thread (pop nodes))
10970 (setq thread (pop nodes))
10971 (gnus-summary-limit-children thread))))))
10972 gnus-newsgroup-dependencies)
10973 ;; If this limitation resulted in an empty group, we might
10974 ;; pop the previous limit and use it instead.
10975 (when (and (not gnus-newsgroup-limit)
10977 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10978 gnus-newsgroup-limit))
10980 (defun gnus-summary-limit-children (thread)
10981 "Return 1 if this subthread is visible and 0 if it is not."
10982 ;; First we get the number of visible children to this thread. This
10983 ;; is done by recursing down the thread using this function, so this
10984 ;; will really go down to a leaf article first, before slowly
10985 ;; working its way up towards the root.
10989 (apply '+ (mapcar 'gnus-summary-limit-children
10992 (number (mail-header-number (car thread)))
10995 ;; If this article is dormant and has absolutely no visible
10996 ;; children, then this article isn't visible.
10997 (and (memq number gnus-newsgroup-dormant)
10999 ;; If this is "fetch-old-headered" and there is only one
11000 ;; visible child (or less), then we don't want this article.
11001 (and (eq gnus-fetch-old-headers 'some)
11002 (memq number gnus-newsgroup-ancient)
11004 ;; If this is a sparsely inserted article with no children,
11005 ;; we don't want it.
11006 (and (eq gnus-build-sparse-threads 'some)
11007 (memq number gnus-newsgroup-sparse)
11009 ;; If we use expunging, and this article is really
11010 ;; low-scored, then we don't want this article.
11011 (when (and gnus-summary-expunge-below
11013 (or (cdr (assq number gnus-newsgroup-scored))
11014 gnus-summary-default-score))
11015 gnus-summary-expunge-below))
11016 ;; We increase the expunge-tally here, but that has
11017 ;; nothing to do with the limits, really.
11018 (incf gnus-newsgroup-expunged-tally)
11019 ;; We also mark as read here, if that's wanted.
11020 (when (and gnus-summary-mark-below
11021 (< score gnus-summary-mark-below))
11022 (setq gnus-newsgroup-unreads
11023 (delq number gnus-newsgroup-unreads))
11024 (if gnus-newsgroup-auto-expire
11025 (push number gnus-newsgroup-expirable)
11026 (push (cons number gnus-low-score-mark)
11027 gnus-newsgroup-reads)))
11029 (and gnus-use-nocem
11030 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11031 ;; Nope, invisible article.
11033 ;; Ok, this article is to be visible, so we add it to the limit
11035 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11038 (defun gnus-expunge-thread (thread)
11039 "Mark all articles in THREAD as read."
11040 (let* ((number (mail-header-number (car thread))))
11041 (incf gnus-newsgroup-expunged-tally)
11042 ;; We also mark as read here, if that's wanted.
11043 (setq gnus-newsgroup-unreads
11044 (delq number gnus-newsgroup-unreads))
11045 (if gnus-newsgroup-auto-expire
11046 (push number gnus-newsgroup-expirable)
11047 (push (cons number gnus-low-score-mark)
11048 gnus-newsgroup-reads)))
11049 ;; Go recursively through all subthreads.
11050 (mapcar 'gnus-expunge-thread (cdr thread)))
11052 ;; Summary article oriented commands
11054 (defun gnus-summary-refer-parent-article (n)
11055 "Refer parent article N times.
11056 The difference between N and the number of articles fetched is returned."
11058 (gnus-set-global-variables)
11062 (let* ((header (gnus-summary-article-header))
11064 ;; If we try to find the parent of the currently
11065 ;; displayed article, then we take a look at the actual
11066 ;; References header, since this is slightly more
11067 ;; reliable than the References field we got from the
11069 (if (and (eq (mail-header-number header)
11070 (cdr gnus-article-current))
11071 (equal gnus-newsgroup-name
11072 (car gnus-article-current)))
11074 (set-buffer gnus-original-article-buffer)
11075 (nnheader-narrow-to-headers)
11077 (message-fetch-field "references")
11079 ;; It's not the current article, so we take a bet on
11080 ;; the value we got from the server.
11081 (mail-header-references header))))
11082 (if (setq ref (or ref (mail-header-references header)))
11083 (or (gnus-summary-refer-article (gnus-parent-id ref))
11084 (gnus-message 1 "Couldn't find parent"))
11085 (gnus-message 1 "No references in article %d"
11086 (gnus-summary-article-number))
11089 (gnus-summary-position-point)
11092 (defun gnus-summary-refer-references ()
11093 "Fetch all articles mentioned in the References header.
11094 Return how many articles were fetched."
11096 (gnus-set-global-variables)
11097 (let ((ref (mail-header-references (gnus-summary-article-header)))
11098 (current (gnus-summary-article-number))
11100 ;; For each Message-ID in the References header...
11101 (while (string-match "<[^>]*>" ref)
11103 ;; ... fetch that article.
11104 (gnus-summary-refer-article
11105 (prog1 (match-string 0 ref)
11106 (setq ref (substring ref (match-end 0))))))
11107 (gnus-summary-goto-subject current)
11108 (gnus-summary-position-point)
11111 (defun gnus-summary-refer-article (message-id)
11112 "Fetch an article specified by MESSAGE-ID."
11113 (interactive "sMessage-ID: ")
11114 (when (and (stringp message-id)
11115 (not (zerop (length message-id))))
11116 ;; Construct the correct Message-ID if necessary.
11117 ;; Suggested by tale@pawl.rpi.edu.
11118 (unless (string-match "^<" message-id)
11119 (setq message-id (concat "<" message-id)))
11120 (unless (string-match ">$" message-id)
11121 (setq message-id (concat message-id ">")))
11122 (let* ((header (gnus-id-to-header message-id))
11123 (sparse (and header
11124 (memq (mail-header-number header)
11125 gnus-newsgroup-sparse))))
11128 ;; The article is present in the buffer, to we just go to it.
11129 (gnus-summary-goto-article
11130 (mail-header-number header) nil header)
11132 (gnus-summary-update-article (mail-header-number header))))
11133 ;; We fetch the article
11134 (let ((gnus-override-method
11135 (and (gnus-news-group-p gnus-newsgroup-name)
11136 gnus-refer-article-method))
11138 ;; Start the special refer-article method, if necessary.
11139 (when (and gnus-refer-article-method
11140 (gnus-news-group-p gnus-newsgroup-name))
11141 (gnus-check-server gnus-refer-article-method))
11142 ;; Fetch the header, and display the article.
11143 (if (setq number (gnus-summary-insert-subject message-id))
11144 (gnus-summary-select-article nil nil nil number)
11145 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11147 (defun gnus-summary-enter-digest-group (&optional force)
11148 "Enter a digest group based on the current article."
11150 (gnus-set-global-variables)
11151 (gnus-summary-select-article)
11152 (let ((name (format "%s-%d"
11153 (gnus-group-prefixed-name
11154 gnus-newsgroup-name (list 'nndoc ""))
11155 gnus-current-article))
11156 (ogroup gnus-newsgroup-name)
11157 (case-fold-search t)
11158 (buf (current-buffer))
11161 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11162 (insert-buffer-substring gnus-original-article-buffer)
11164 (goto-char (point-min))
11165 (or (search-forward "\n\n" nil t) (point)))
11166 (goto-char (point-min))
11167 (delete-matching-lines "^\\(Path\\):\\|^From ")
11170 (if (gnus-group-read-ephemeral-group
11171 name `(nndoc ,name (nndoc-address
11173 (nndoc-article-type ,(if force 'digest 'guess))) t)
11174 ;; Make all postings to this group go to the parent group.
11175 (nconc (gnus-info-params (gnus-get-info name))
11176 (list (cons 'to-group ogroup)))
11177 ;; Couldn't select this doc group.
11178 (switch-to-buffer buf)
11179 (gnus-set-global-variables)
11180 (gnus-configure-windows 'summary)
11181 (gnus-message 3 "Article couldn't be entered?"))
11182 (kill-buffer dig))))
11184 (defun gnus-summary-isearch-article (&optional regexp-p)
11185 "Do incremental search forward on the current article.
11186 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11188 (gnus-set-global-variables)
11189 (gnus-summary-select-article)
11190 (gnus-configure-windows 'article)
11191 (gnus-eval-in-buffer-window gnus-article-buffer
11192 (goto-char (point-min))
11193 (isearch-forward regexp-p)))
11195 (defun gnus-summary-search-article-forward (regexp &optional backward)
11196 "Search for an article containing REGEXP forward.
11197 If BACKWARD, search backward instead."
11200 (format "Search article %s (regexp%s): "
11201 (if current-prefix-arg "backward" "forward")
11202 (if gnus-last-search-regexp
11203 (concat ", default " gnus-last-search-regexp)
11205 current-prefix-arg))
11206 (gnus-set-global-variables)
11207 (if (string-equal regexp "")
11208 (setq regexp (or gnus-last-search-regexp ""))
11209 (setq gnus-last-search-regexp regexp))
11210 (unless (gnus-summary-search-article regexp backward)
11211 (error "Search failed: \"%s\"" regexp)))
11213 (defun gnus-summary-search-article-backward (regexp)
11214 "Search for an article containing REGEXP backward."
11217 (format "Search article backward (regexp%s): "
11218 (if gnus-last-search-regexp
11219 (concat ", default " gnus-last-search-regexp)
11221 (gnus-summary-search-article-forward regexp 'backward))
11223 (defun gnus-summary-search-article (regexp &optional backward)
11224 "Search for an article containing REGEXP.
11225 Optional argument BACKWARD means do search for backward.
11226 `gnus-select-article-hook' is not called during the search."
11227 (let ((gnus-select-article-hook nil) ;Disable hook.
11228 (gnus-article-display-hook nil)
11229 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11232 're-search-backward 're-search-forward))
11233 (sum (current-buffer))
11235 (gnus-save-hidden-threads
11236 (gnus-summary-select-article)
11237 (set-buffer gnus-article-buffer)
11241 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11243 (re-search-backward regexp nil t)
11244 (re-search-forward regexp nil t))
11245 ;; We found the regexp.
11247 (setq found 'found)
11248 (beginning-of-line)
11250 (get-buffer-window (current-buffer))
11254 ;; We didn't find it, so we go to the next article.
11256 (if (not (if backward (gnus-summary-find-prev)
11257 (gnus-summary-find-next)))
11258 ;; No more articles.
11260 ;; Select the next article and adjust point.
11261 (gnus-summary-select-article)
11262 (set-buffer gnus-article-buffer)
11264 (goto-char (if backward (point-max) (point-min))))))
11265 (gnus-message 7 ""))
11266 ;; Return whether we found the regexp.
11267 (when (eq found 'found)
11268 (gnus-summary-show-thread)
11269 (gnus-summary-goto-subject gnus-current-article)
11270 (gnus-summary-position-point)
11273 (defun gnus-summary-find-matching (header regexp &optional backward unread
11275 "Return a list of all articles that match REGEXP on HEADER.
11276 The search stars on the current article and goes forwards unless
11277 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11278 If UNREAD is non-nil, only unread articles will
11279 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11280 in the comparisons."
11281 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11282 (gnus-data-find-list
11283 (gnus-summary-article-number) (gnus-data-list backward))))
11284 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11285 (case-fold-search (not not-case-fold))
11287 (or (fboundp (intern (concat "mail-header-" header)))
11288 (error "%s is not a valid header" header))
11290 (setq d (car data))
11291 (and (or (not unread) ; We want all articles...
11292 (gnus-data-unread-p d)) ; Or just unreads.
11293 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11294 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11295 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11296 (setq data (cdr data)))
11297 (nreverse articles)))
11299 (defun gnus-summary-execute-command (header regexp command &optional backward)
11300 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11301 If HEADER is an empty string (or nil), the match is done on the entire
11302 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11304 (list (let ((completion-ignore-case t))
11307 (mapcar (lambda (string) (list string))
11308 '("Number" "Subject" "From" "Lines" "Date"
11309 "Message-ID" "Xref" "References" "Body"))
11310 nil 'require-match))
11311 (read-string "Regexp: ")
11312 (read-key-sequence "Command: ")
11313 current-prefix-arg))
11314 (when (equal header "Body")
11316 (gnus-set-global-variables)
11317 ;; Hidden thread subtrees must be searched as well.
11318 (gnus-summary-show-all-threads)
11319 ;; We don't want to change current point nor window configuration.
11321 (save-window-excursion
11322 (gnus-message 6 "Executing %s..." (key-description command))
11323 ;; We'd like to execute COMMAND interactively so as to give arguments.
11324 (gnus-execute header regexp
11325 `(lambda () (call-interactively ',(key-binding command)))
11327 (gnus-message 6 "Executing %s...done" (key-description command)))))
11329 (defun gnus-summary-beginning-of-article ()
11330 "Scroll the article back to the beginning."
11332 (gnus-set-global-variables)
11333 (gnus-summary-select-article)
11334 (gnus-configure-windows 'article)
11335 (gnus-eval-in-buffer-window gnus-article-buffer
11337 (goto-char (point-min))
11338 (and gnus-break-pages (gnus-narrow-to-page))))
11340 (defun gnus-summary-end-of-article ()
11341 "Scroll to the end of the article."
11343 (gnus-set-global-variables)
11344 (gnus-summary-select-article)
11345 (gnus-configure-windows 'article)
11346 (gnus-eval-in-buffer-window gnus-article-buffer
11348 (goto-char (point-max))
11350 (and gnus-break-pages (gnus-narrow-to-page))))
11352 (defun gnus-summary-show-article (&optional arg)
11353 "Force re-fetching of the current article.
11354 If ARG (the prefix) is non-nil, show the raw article without any
11355 article massaging functions being run."
11357 (gnus-set-global-variables)
11359 ;; Select the article the normal way.
11360 (gnus-summary-select-article nil 'force)
11361 ;; Bind the article treatment functions to nil.
11362 (let ((gnus-have-all-headers t)
11363 gnus-article-display-hook
11364 gnus-article-prepare-hook
11367 (gnus-summary-select-article nil 'force)))
11368 (gnus-summary-goto-subject gnus-current-article)
11369 ; (gnus-configure-windows 'article)
11370 (gnus-summary-position-point))
11372 (defun gnus-summary-verbose-headers (&optional arg)
11373 "Toggle permanent full header display.
11374 If ARG is a positive number, turn header display on.
11375 If ARG is a negative number, turn header display off."
11377 (gnus-set-global-variables)
11378 (gnus-summary-toggle-header arg)
11379 (setq gnus-show-all-headers
11380 (cond ((or (not (numberp arg))
11382 (not gnus-show-all-headers))
11386 (defun gnus-summary-toggle-header (&optional arg)
11387 "Show the headers if they are hidden, or hide them if they are shown.
11388 If ARG is a positive number, show the entire header.
11389 If ARG is a negative number, hide the unwanted header lines."
11391 (gnus-set-global-variables)
11393 (set-buffer gnus-article-buffer)
11394 (let* ((buffer-read-only nil)
11395 (inhibit-point-motion-hooks t)
11396 (hidden (text-property-any
11397 (goto-char (point-min)) (search-forward "\n\n")
11400 (goto-char (point-min))
11401 (when (search-forward "\n\n" nil t)
11402 (delete-region (point-min) (1- (point))))
11403 (goto-char (point-min))
11405 (set-buffer gnus-original-article-buffer)
11406 (goto-char (point-min))
11407 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11408 (insert-buffer-substring gnus-original-article-buffer 1 e)
11409 (let ((gnus-inhibit-hiding t))
11410 (run-hooks 'gnus-article-display-hook))
11411 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11412 (gnus-article-hide-headers)))))
11414 (defun gnus-summary-show-all-headers ()
11415 "Make all header lines visible."
11417 (gnus-set-global-variables)
11418 (gnus-article-show-all-headers))
11420 (defun gnus-summary-toggle-mime (&optional arg)
11421 "Toggle MIME processing.
11422 If ARG is a positive number, turn MIME processing on."
11424 (gnus-set-global-variables)
11425 (setq gnus-show-mime
11426 (if (null arg) (not gnus-show-mime)
11427 (> (prefix-numeric-value arg) 0)))
11428 (gnus-summary-select-article t 'force))
11430 (defun gnus-summary-caesar-message (&optional arg)
11431 "Caesar rotate the current article by 13.
11432 The numerical prefix specifies how manu places to rotate each letter
11435 (gnus-set-global-variables)
11436 (gnus-summary-select-article)
11437 (let ((mail-header-separator ""))
11438 (gnus-eval-in-buffer-window gnus-article-buffer
11441 (let ((start (window-start))
11443 (message-caesar-buffer-body arg)
11444 (set-window-start (get-buffer-window (current-buffer)) start))))))
11446 (defun gnus-summary-stop-page-breaking ()
11447 "Stop page breaking in the current article."
11449 (gnus-set-global-variables)
11450 (gnus-summary-select-article)
11451 (gnus-eval-in-buffer-window gnus-article-buffer
11454 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11455 "Move the current article to a different newsgroup.
11456 If N is a positive number, move the N next articles.
11457 If N is a negative number, move the N previous articles.
11458 If N is nil and any articles have been marked with the process mark,
11459 move those articles instead.
11460 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11461 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11462 re-spool using this method.
11464 For this function to work, both the current newsgroup and the
11465 newsgroup that you want to move to have to support the `request-move'
11466 and `request-accept' functions."
11468 (unless action (setq action 'move))
11469 (gnus-set-global-variables)
11470 ;; Check whether the source group supports the required functions.
11471 (cond ((and (eq action 'move)
11472 (not (gnus-check-backend-function
11473 'request-move-article gnus-newsgroup-name)))
11474 (error "The current group does not support article moving"))
11475 ((and (eq action 'crosspost)
11476 (not (gnus-check-backend-function
11477 'request-replace-article gnus-newsgroup-name)))
11478 (error "The current group does not support article editing")))
11479 (let ((articles (gnus-summary-work-articles n))
11480 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11481 (names '((move "Move" "Moving")
11482 (copy "Copy" "Copying")
11483 (crosspost "Crosspost" "Crossposting")))
11484 (copy-buf (save-excursion
11485 (nnheader-set-temp-buffer " *copy article*")))
11486 art-group to-method new-xref article to-groups)
11487 (unless (assq action names)
11488 (error "Unknown action %s" action))
11489 ;; Read the newsgroup name.
11490 (when (and (not to-newsgroup)
11491 (not select-method))
11493 (gnus-read-move-group-name
11494 (cadr (assq action names))
11495 (symbol-value (intern (format "gnus-current-%s-group" action)))
11497 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11498 (setq to-method (or select-method
11499 (gnus-group-name-to-method to-newsgroup)))
11500 ;; Check the method we are to move this article to...
11501 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11502 (error "%s does not support article copying" (car to-method)))
11503 (or (gnus-check-server to-method)
11504 (error "Can't open server %s" (car to-method)))
11505 (gnus-message 6 "%s to %s: %s..."
11506 (caddr (assq action names))
11507 (or (car select-method) to-newsgroup) articles)
11509 (setq article (pop articles))
11513 ;; Move the article.
11515 (gnus-request-move-article
11516 article ; Article to move
11517 gnus-newsgroup-name ; From newsgrouo
11518 (nth 1 (gnus-find-method-for-group
11519 gnus-newsgroup-name)) ; Server
11520 (list 'gnus-request-accept-article
11521 to-newsgroup (list 'quote select-method)
11522 (not articles)) ; Accept form
11523 (not articles))) ; Only save nov last time
11524 ;; Copy the article.
11527 (set-buffer copy-buf)
11528 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11529 (gnus-request-accept-article
11530 to-newsgroup select-method (not articles))))
11531 ;; Crosspost the article.
11532 ((eq action 'crosspost)
11533 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11534 (setq new-xref (concat gnus-newsgroup-name ":" article))
11535 (if (and xref (not (string= xref "")))
11537 (when (string-match "^Xref: " xref)
11538 (setq xref (substring xref (match-end 0))))
11539 (setq new-xref (concat xref " " new-xref)))
11540 (setq new-xref (concat (system-name) " " new-xref)))
11542 (set-buffer copy-buf)
11543 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11544 (nnheader-replace-header "xref" new-xref)
11545 (gnus-request-accept-article
11546 to-newsgroup select-method (not articles)))))))
11547 (if (not art-group)
11548 (gnus-message 1 "Couldn't %s article %s"
11549 (cadr (assq action names)) article)
11552 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11554 (gnus-group-prefixed-name
11557 (gnus-find-method-for-group to-newsgroup)))
11558 gnus-newsrc-hashtb)))
11559 (info (nth 2 entry))
11560 (to-group (gnus-info-group info)))
11561 ;; Update the group that has been moved to.
11563 (memq action '(move copy)))
11564 (unless (member to-group to-groups)
11565 (push to-group to-groups))
11567 (unless (memq article gnus-newsgroup-unreads)
11568 (gnus-info-set-read
11569 info (gnus-add-to-range (gnus-info-read info)
11570 (list (cdr art-group)))))
11572 ;; Copy any marks over to the new group.
11573 (let ((marks gnus-article-mark-lists)
11574 (to-article (cdr art-group)))
11576 ;; See whether the article is to be put in the cache.
11577 (when gnus-use-cache
11578 (gnus-cache-possibly-enter-article
11579 to-group to-article
11580 (let ((header (copy-sequence
11581 (gnus-summary-article-header article))))
11582 (mail-header-set-number header to-article)
11584 (memq article gnus-newsgroup-marked)
11585 (memq article gnus-newsgroup-dormant)
11586 (memq article gnus-newsgroup-unreads)))
11589 (when (memq article (symbol-value
11590 (intern (format "gnus-newsgroup-%s"
11592 ;; If the other group is the same as this group,
11593 ;; then we have to add the mark to the list.
11594 (when (equal to-group gnus-newsgroup-name)
11595 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11598 (intern (format "gnus-newsgroup-%s"
11600 ;; Copy mark to other group.
11601 (gnus-add-marked-articles
11602 to-group (cdar marks) (list to-article) info))
11603 (setq marks (cdr marks)))))
11605 ;; Update the Xref header in this article to point to
11606 ;; the new crossposted article we have just created.
11607 (when (eq action 'crosspost)
11609 (set-buffer copy-buf)
11610 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11611 (nnheader-replace-header
11612 "xref" (concat new-xref " " (gnus-group-prefixed-name
11613 (car art-group) to-method)
11614 ":" (cdr art-group)))
11615 (gnus-request-replace-article
11616 article gnus-newsgroup-name (current-buffer)))))
11618 (gnus-summary-goto-subject article)
11619 (when (eq action 'move)
11620 (gnus-summary-mark-article article gnus-canceled-mark)))
11621 (gnus-summary-remove-process-mark article))
11622 ;; Re-activate all groups that have been moved to.
11624 (gnus-activate-group (pop to-groups)))
11626 (gnus-kill-buffer copy-buf)
11627 (gnus-summary-position-point)
11628 (gnus-set-mode-line 'summary)))
11630 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11631 "Move the current article to a different newsgroup.
11632 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11633 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11634 re-spool using this method."
11636 (gnus-summary-move-article n nil select-method 'copy))
11638 (defun gnus-summary-crosspost-article (&optional n)
11639 "Crosspost the current article to some other group."
11641 (gnus-summary-move-article n nil nil 'crosspost))
11643 (defvar gnus-summary-respool-default-method nil
11644 "Default method for respooling an article.
11645 If nil, use to the current newsgroup method.")
11647 (defun gnus-summary-respool-article (&optional n method)
11648 "Respool the current article.
11649 The article will be squeezed through the mail spooling process again,
11650 which means that it will be put in some mail newsgroup or other
11651 depending on `nnmail-split-methods'.
11652 If N is a positive number, respool the N next articles.
11653 If N is a negative number, respool the N previous articles.
11654 If N is nil and any articles have been marked with the process mark,
11655 respool those articles instead.
11657 Respooling can be done both from mail groups and \"real\" newsgroups.
11658 In the former case, the articles in question will be moved from the
11659 current group into whatever groups they are destined to. In the
11660 latter case, they will be copied into the relevant groups."
11662 (list current-prefix-arg
11663 (let* ((methods (gnus-methods-using 'respool))
11665 (symbol-name (or gnus-summary-respool-default-method
11666 (car (gnus-find-method-for-group
11667 gnus-newsgroup-name)))))
11669 (gnus-completing-read
11670 methname "What backend do you want to use when respooling?"
11671 methods nil t nil 'gnus-method-history))
11674 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11675 (list (intern method) ""))
11679 (cdr (completing-read
11681 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11682 (gnus-set-global-variables)
11684 (error "No method given for respooling"))
11685 (if (assoc (symbol-name
11686 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11687 (gnus-methods-using 'respool))
11688 (gnus-summary-move-article n nil method)
11689 (gnus-summary-copy-article n nil method)))
11691 (defun gnus-summary-import-article (file)
11692 "Import a random file into a mail newsgroup."
11693 (interactive "fImport file: ")
11694 (gnus-set-global-variables)
11695 (let ((group gnus-newsgroup-name)
11696 (now (current-time))
11698 (or (gnus-check-backend-function 'request-accept-article group)
11699 (error "%s does not support article importing" group))
11700 (or (file-readable-p file)
11701 (not (file-regular-p file))
11702 (error "Can't read %s" file))
11704 (set-buffer (get-buffer-create " *import file*"))
11705 (buffer-disable-undo (current-buffer))
11707 (insert-file-contents file)
11708 (goto-char (point-min))
11709 (unless (nnheader-article-p)
11710 ;; This doesn't look like an article, so we fudge some headers.
11711 (setq atts (file-attributes file)
11712 lines (count-lines (point-min) (point-max)))
11713 (insert "From: " (read-string "From: ") "\n"
11714 "Subject: " (read-string "Subject: ") "\n"
11715 "Date: " (timezone-make-date-arpa-standard
11716 (current-time-string (nth 5 atts))
11717 (current-time-zone now)
11718 (current-time-zone now)) "\n"
11719 "Message-ID: " (message-make-message-id) "\n"
11720 "Lines: " (int-to-string lines) "\n"
11721 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11722 (gnus-request-accept-article group nil t)
11723 (kill-buffer (current-buffer)))))
11725 (defun gnus-summary-expire-articles (&optional now)
11726 "Expire all articles that are marked as expirable in the current group."
11728 (gnus-set-global-variables)
11729 (when (gnus-check-backend-function
11730 'request-expire-articles gnus-newsgroup-name)
11731 ;; This backend supports expiry.
11732 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11733 (expirable (if total
11734 (gnus-list-of-read-articles gnus-newsgroup-name)
11735 (setq gnus-newsgroup-expirable
11736 (sort gnus-newsgroup-expirable '<))))
11737 (expiry-wait (if now 'immediate
11738 (gnus-group-get-parameter
11739 gnus-newsgroup-name 'expiry-wait)))
11742 ;; There are expirable articles in this group, so we run them
11743 ;; through the expiry process.
11744 (gnus-message 6 "Expiring articles...")
11745 ;; The list of articles that weren't expired is returned.
11747 (let ((nnmail-expiry-wait-function nil)
11748 (nnmail-expiry-wait expiry-wait))
11749 (setq es (gnus-request-expire-articles
11750 expirable gnus-newsgroup-name)))
11751 (setq es (gnus-request-expire-articles
11752 expirable gnus-newsgroup-name)))
11753 (or total (setq gnus-newsgroup-expirable es))
11754 ;; We go through the old list of expirable, and mark all
11755 ;; really expired articles as nonexistent.
11756 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11757 (let ((gnus-use-cache nil))
11759 (unless (memq (car expirable) es)
11760 (when (gnus-data-find (car expirable))
11761 (gnus-summary-mark-article
11762 (car expirable) gnus-canceled-mark)))
11763 (setq expirable (cdr expirable)))))
11764 (gnus-message 6 "Expiring articles...done")))))
11766 (defun gnus-summary-expire-articles-now ()
11767 "Expunge all expirable articles in the current group.
11768 This means that *all* articles that are marked as expirable will be
11769 deleted forever, right now."
11771 (gnus-set-global-variables)
11772 (or gnus-expert-user
11774 "Are you really, really, really sure you want to delete all these messages? ")
11776 (gnus-summary-expire-articles t))
11778 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11779 (defun gnus-summary-delete-article (&optional n)
11780 "Delete the N next (mail) articles.
11781 This command actually deletes articles. This is not a marking
11782 command. The article will disappear forever from your life, never to
11784 If N is negative, delete backwards.
11785 If N is nil and articles have been marked with the process mark,
11786 delete these instead."
11788 (gnus-set-global-variables)
11789 (or (gnus-check-backend-function 'request-expire-articles
11790 gnus-newsgroup-name)
11791 (error "The current newsgroup does not support article deletion."))
11792 ;; Compute the list of articles to delete.
11793 (let ((articles (gnus-summary-work-articles n))
11795 (if (and gnus-novice-user
11796 (not (gnus-y-or-n-p
11797 (format "Do you really want to delete %s forever? "
11798 (if (> (length articles) 1)
11799 (format "these %s articles" (length articles))
11800 "this article")))))
11802 ;; Delete the articles.
11803 (setq not-deleted (gnus-request-expire-articles
11804 articles gnus-newsgroup-name 'force))
11806 (gnus-summary-remove-process-mark (car articles))
11807 ;; The backend might not have been able to delete the article
11809 (or (memq (car articles) not-deleted)
11810 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11811 (setq articles (cdr articles))))
11812 (gnus-summary-position-point)
11813 (gnus-set-mode-line 'summary)
11816 (defun gnus-summary-edit-article (&optional force)
11817 "Enter into a buffer and edit the current article.
11818 This will have permanent effect only in mail groups.
11819 If FORCE is non-nil, allow editing of articles even in read-only
11823 (set-buffer gnus-summary-buffer)
11824 (gnus-set-global-variables)
11825 (when (and (not force)
11826 (gnus-group-read-only-p))
11827 (error "The current newsgroup does not support article editing."))
11828 (gnus-summary-select-article t nil t)
11829 (gnus-configure-windows 'article)
11830 (select-window (get-buffer-window gnus-article-buffer))
11831 (gnus-message 6 "C-c C-c to end edits")
11832 (setq buffer-read-only nil)
11834 (use-local-map (copy-keymap (current-local-map)))
11835 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11836 (buffer-enable-undo)
11838 (goto-char (point-min))
11839 (search-forward "\n\n" nil t)))
11841 (defun gnus-summary-edit-article-done ()
11842 "Make edits to the current article permanent."
11844 (if (gnus-group-read-only-p)
11846 (gnus-summary-edit-article-postpone)
11848 1 "The current newsgroup does not support article editing."))
11849 (let ((buf (format "%s" (buffer-string))))
11852 (if (not (gnus-request-replace-article
11853 (cdr gnus-article-current) (car gnus-article-current)
11855 (error "Couldn't replace article.")
11856 (gnus-article-mode)
11857 (use-local-map gnus-article-mode-map)
11858 (setq buffer-read-only t)
11859 (buffer-disable-undo (current-buffer))
11860 (gnus-configure-windows 'summary)
11861 (gnus-summary-update-article (cdr gnus-article-current))
11862 (when gnus-use-cache
11863 (gnus-cache-update-article
11864 (car gnus-article-current) (cdr gnus-article-current)))
11865 (when gnus-keep-backlog
11866 (gnus-backlog-remove-article
11867 (car gnus-article-current) (cdr gnus-article-current))))
11869 (when (get-buffer gnus-original-article-buffer)
11870 (set-buffer gnus-original-article-buffer)
11871 (setq gnus-original-article nil)))
11872 (setq gnus-article-current nil
11873 gnus-current-article nil)
11874 (run-hooks 'gnus-article-display-hook)
11875 (and (gnus-visual-p 'summary-highlight 'highlight)
11876 (run-hooks 'gnus-visual-mark-article-hook)))))
11878 (defun gnus-summary-edit-article-postpone ()
11879 "Postpone changes to the current article."
11881 (gnus-article-mode)
11882 (use-local-map gnus-article-mode-map)
11883 (setq buffer-read-only t)
11884 (buffer-disable-undo (current-buffer))
11885 (gnus-configure-windows 'summary)
11886 (and (gnus-visual-p 'summary-highlight 'highlight)
11887 (run-hooks 'gnus-visual-mark-article-hook)))
11889 (defun gnus-summary-respool-query ()
11890 "Query where the respool algorithm would put this article."
11892 (gnus-set-global-variables)
11893 (gnus-summary-select-article)
11895 (set-buffer gnus-article-buffer)
11897 (goto-char (point-min))
11898 (search-forward "\n\n")
11899 (narrow-to-region (point-min) (point))
11900 (pp-eval-expression
11901 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11903 ;; Summary marking commands.
11905 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11906 "Mark articles which has the same subject as read, and then select the next.
11907 If UNMARK is positive, remove any kind of mark.
11908 If UNMARK is negative, tick articles."
11910 (gnus-set-global-variables)
11912 (setq unmark (prefix-numeric-value unmark)))
11914 (gnus-summary-mark-same-subject
11915 (gnus-summary-article-subject) unmark)))
11916 ;; Select next unread article. If auto-select-same mode, should
11917 ;; select the first unread article.
11918 (gnus-summary-next-article t (and gnus-auto-select-same
11919 (gnus-summary-article-subject)))
11920 (gnus-message 7 "%d article%s marked as %s"
11921 count (if (= count 1) " is" "s are")
11922 (if unmark "unread" "read"))))
11924 (defun gnus-summary-kill-same-subject (&optional unmark)
11925 "Mark articles which has the same subject as read.
11926 If UNMARK is positive, remove any kind of mark.
11927 If UNMARK is negative, tick articles."
11929 (gnus-set-global-variables)
11931 (setq unmark (prefix-numeric-value unmark)))
11933 (gnus-summary-mark-same-subject
11934 (gnus-summary-article-subject) unmark)))
11935 ;; If marked as read, go to next unread subject.
11937 ;; Go to next unread subject.
11938 (gnus-summary-next-subject 1 t))
11939 (gnus-message 7 "%d articles are marked as %s"
11940 count (if unmark "unread" "read"))))
11942 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11943 "Mark articles with same SUBJECT as read, and return marked number.
11944 If optional argument UNMARK is positive, remove any kinds of marks.
11945 If optional argument UNMARK is negative, mark articles as unread instead."
11949 ((null unmark) ; Mark as read.
11952 (gnus-summary-mark-article-as-read gnus-killed-mark)
11953 (gnus-summary-show-thread) t)
11954 (gnus-summary-find-subject subject))
11955 (setq count (1+ count))))
11956 ((> unmark 0) ; Tick.
11959 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11960 (gnus-summary-show-thread) t)
11961 (gnus-summary-find-subject subject))
11962 (setq count (1+ count))))
11963 (t ; Mark as unread.
11966 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11967 (gnus-summary-show-thread) t)
11968 (gnus-summary-find-subject subject))
11969 (setq count (1+ count)))))
11970 (gnus-set-mode-line 'summary)
11971 ;; Return the number of marked articles.
11974 (defun gnus-summary-mark-as-processable (n &optional unmark)
11975 "Set the process mark on the next N articles.
11976 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11977 the process mark instead. The difference between N and the actual
11978 number of articles marked is returned."
11980 (gnus-set-global-variables)
11981 (let ((backward (< n 0))
11986 (gnus-summary-remove-process-mark
11987 (gnus-summary-article-number))
11988 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11989 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11991 (if (/= 0 n) (gnus-message 7 "No more articles"))
11992 (gnus-summary-recenter)
11993 (gnus-summary-position-point)
11996 (defun gnus-summary-unmark-as-processable (n)
11997 "Remove the process mark from the next N articles.
11998 If N is negative, mark backward instead. The difference between N and
11999 the actual number of articles marked is returned."
12001 (gnus-set-global-variables)
12002 (gnus-summary-mark-as-processable n t))
12004 (defun gnus-summary-unmark-all-processable ()
12005 "Remove the process mark from all articles."
12007 (gnus-set-global-variables)
12009 (while gnus-newsgroup-processable
12010 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12011 (gnus-summary-position-point))
12013 (defun gnus-summary-mark-as-expirable (n)
12014 "Mark N articles forward as expirable.
12015 If N is negative, mark backward instead. The difference between N and
12016 the actual number of articles marked is returned."
12018 (gnus-set-global-variables)
12019 (gnus-summary-mark-forward n gnus-expirable-mark))
12021 (defun gnus-summary-mark-article-as-replied (article)
12022 "Mark ARTICLE replied and update the summary line."
12023 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12024 (let ((buffer-read-only nil))
12025 (when (gnus-summary-goto-subject article)
12026 (gnus-summary-update-secondary-mark article))))
12028 (defun gnus-summary-set-bookmark (article)
12029 "Set a bookmark in current article."
12030 (interactive (list (gnus-summary-article-number)))
12031 (gnus-set-global-variables)
12032 (if (or (not (get-buffer gnus-article-buffer))
12033 (not gnus-current-article)
12034 (not gnus-article-current)
12035 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12036 (error "No current article selected"))
12037 ;; Remove old bookmark, if one exists.
12038 (let ((old (assq article gnus-newsgroup-bookmarks)))
12039 (if old (setq gnus-newsgroup-bookmarks
12040 (delq old gnus-newsgroup-bookmarks))))
12041 ;; Set the new bookmark, which is on the form
12042 ;; (article-number . line-number-in-body).
12043 (setq gnus-newsgroup-bookmarks
12047 (set-buffer gnus-article-buffer)
12051 (goto-char (point-min))
12052 (search-forward "\n\n" nil t)
12055 gnus-newsgroup-bookmarks))
12056 (gnus-message 6 "A bookmark has been added to the current article."))
12058 (defun gnus-summary-remove-bookmark (article)
12059 "Remove the bookmark from the current article."
12060 (interactive (list (gnus-summary-article-number)))
12061 (gnus-set-global-variables)
12062 ;; Remove old bookmark, if one exists.
12063 (let ((old (assq article gnus-newsgroup-bookmarks)))
12066 (setq gnus-newsgroup-bookmarks
12067 (delq old gnus-newsgroup-bookmarks))
12068 (gnus-message 6 "Removed bookmark."))
12069 (gnus-message 6 "No bookmark in current article."))))
12071 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12072 (defun gnus-summary-mark-as-dormant (n)
12073 "Mark N articles forward as dormant.
12074 If N is negative, mark backward instead. The difference between N and
12075 the actual number of articles marked is returned."
12077 (gnus-set-global-variables)
12078 (gnus-summary-mark-forward n gnus-dormant-mark))
12080 (defun gnus-summary-set-process-mark (article)
12081 "Set the process mark on ARTICLE and update the summary line."
12082 (setq gnus-newsgroup-processable
12084 (delq article gnus-newsgroup-processable)))
12085 (when (gnus-summary-goto-subject article)
12086 (gnus-summary-show-thread)
12087 (gnus-summary-update-secondary-mark article)))
12089 (defun gnus-summary-remove-process-mark (article)
12090 "Remove the process mark from ARTICLE and update the summary line."
12091 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12092 (when (gnus-summary-goto-subject article)
12093 (gnus-summary-show-thread)
12094 (gnus-summary-update-secondary-mark article)))
12096 (defun gnus-summary-set-saved-mark (article)
12097 "Set the process mark on ARTICLE and update the summary line."
12098 (push article gnus-newsgroup-saved)
12099 (when (gnus-summary-goto-subject article)
12100 (gnus-summary-update-secondary-mark article)))
12102 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12103 "Mark N articles as read forwards.
12104 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12105 The difference between N and the actual number of articles marked is
12108 (gnus-set-global-variables)
12109 (let ((backward (< n 0))
12110 (gnus-summary-goto-unread
12111 (and gnus-summary-goto-unread
12112 (not (eq gnus-summary-goto-unread 'never))
12113 (not (memq mark (list gnus-unread-mark
12114 gnus-ticked-mark gnus-dormant-mark)))))
12116 (mark (or mark gnus-del-mark)))
12117 (while (and (> n 0)
12118 (gnus-summary-mark-article nil mark no-expire)
12119 (zerop (gnus-summary-next-subject
12121 (and gnus-summary-goto-unread
12122 (not (eq gnus-summary-goto-unread 'never)))
12125 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12126 (gnus-summary-recenter)
12127 (gnus-summary-position-point)
12128 (gnus-set-mode-line 'summary)
12131 (defun gnus-summary-mark-article-as-read (mark)
12132 "Mark the current article quickly as read with MARK."
12133 (let ((article (gnus-summary-article-number)))
12134 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12135 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12136 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12137 (setq gnus-newsgroup-reads
12138 (cons (cons article mark) gnus-newsgroup-reads))
12139 ;; Possibly remove from cache, if that is used.
12140 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12141 ;; Allow the backend to change the mark.
12142 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12143 ;; Check for auto-expiry.
12144 (when (and gnus-newsgroup-auto-expire
12145 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12146 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12147 (= mark gnus-ancient-mark)
12148 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12149 (setq mark gnus-expirable-mark)
12150 (push article gnus-newsgroup-expirable))
12151 ;; Set the mark in the buffer.
12152 (gnus-summary-update-mark mark 'unread)
12155 (defun gnus-summary-mark-article-as-unread (mark)
12156 "Mark the current article quickly as unread with MARK."
12157 (let ((article (gnus-summary-article-number)))
12159 (gnus-error 1 "Unmarkable article")
12160 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12161 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12162 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12163 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12164 (cond ((= mark gnus-ticked-mark)
12165 (push article gnus-newsgroup-marked))
12166 ((= mark gnus-dormant-mark)
12167 (push article gnus-newsgroup-dormant))
12169 (push article gnus-newsgroup-unreads)))
12170 (setq gnus-newsgroup-reads
12171 (delq (assq article gnus-newsgroup-reads)
12172 gnus-newsgroup-reads))
12174 ;; See whether the article is to be put in the cache.
12175 (and gnus-use-cache
12176 (vectorp (gnus-summary-article-header article))
12178 (gnus-cache-possibly-enter-article
12179 gnus-newsgroup-name article
12180 (gnus-summary-article-header article)
12181 (= mark gnus-ticked-mark)
12182 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12185 (gnus-summary-update-mark mark 'unread))
12188 (defun gnus-summary-mark-article (&optional article mark no-expire)
12189 "Mark ARTICLE with MARK. MARK can be any character.
12190 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12191 `??' (dormant) and `?E' (expirable).
12192 If MARK is nil, then the default character `?D' is used.
12193 If ARTICLE is nil, then the article on the current line will be
12195 ;; The mark might be a string.
12196 (and (stringp mark)
12197 (setq mark (aref mark 0)))
12198 ;; If no mark is given, then we check auto-expiring.
12199 (and (not no-expire)
12200 gnus-newsgroup-auto-expire
12202 (and (numberp mark)
12203 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12204 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12205 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12206 (setq mark gnus-expirable-mark))
12207 (let* ((mark (or mark gnus-del-mark))
12208 (article (or article (gnus-summary-article-number))))
12209 (or article (error "No article on current line"))
12210 (if (or (= mark gnus-unread-mark)
12211 (= mark gnus-ticked-mark)
12212 (= mark gnus-dormant-mark))
12213 (gnus-mark-article-as-unread article mark)
12214 (gnus-mark-article-as-read article mark))
12216 ;; See whether the article is to be put in the cache.
12217 (and gnus-use-cache
12218 (not (= mark gnus-canceled-mark))
12219 (vectorp (gnus-summary-article-header article))
12221 (gnus-cache-possibly-enter-article
12222 gnus-newsgroup-name article
12223 (gnus-summary-article-header article)
12224 (= mark gnus-ticked-mark)
12225 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12227 (if (gnus-summary-goto-subject article nil t)
12228 (let ((buffer-read-only nil))
12229 (gnus-summary-show-thread)
12231 (gnus-summary-update-mark mark 'unread)
12234 (defun gnus-summary-update-secondary-mark (article)
12235 "Update the secondary (read, process, cache) mark."
12236 (gnus-summary-update-mark
12237 (cond ((memq article gnus-newsgroup-processable)
12239 ((memq article gnus-newsgroup-cached)
12241 ((memq article gnus-newsgroup-replied)
12243 ((memq article gnus-newsgroup-saved)
12245 (t gnus-unread-mark))
12247 (when (gnus-visual-p 'summary-highlight 'highlight)
12248 (run-hooks 'gnus-summary-update-hook))
12251 (defun gnus-summary-update-mark (mark type)
12252 (beginning-of-line)
12253 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12254 (buffer-read-only nil))
12256 (<= (+ forward (point)) (point-max)))
12257 ;; Go to the right position on the line.
12258 (goto-char (+ forward (point)))
12259 ;; Replace the old mark with the new mark.
12260 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12261 ;; Optionally update the marks by some user rule.
12262 (when (eq type 'unread)
12263 (gnus-data-set-mark
12264 (gnus-data-find (gnus-summary-article-number)) mark)
12265 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12267 (defun gnus-mark-article-as-read (article &optional mark)
12268 "Enter ARTICLE in the pertinent lists and remove it from others."
12269 ;; Make the article expirable.
12270 (let ((mark (or mark gnus-del-mark)))
12271 (if (= mark gnus-expirable-mark)
12272 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12273 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12274 ;; Remove from unread and marked lists.
12275 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12276 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12277 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12278 (push (cons article mark) gnus-newsgroup-reads)
12279 ;; Possibly remove from cache, if that is used.
12280 (when gnus-use-cache
12281 (gnus-cache-enter-remove-article article))))
12283 (defun gnus-mark-article-as-unread (article &optional mark)
12284 "Enter ARTICLE in the pertinent lists and remove it from others."
12285 (let ((mark (or mark gnus-ticked-mark)))
12286 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12287 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12288 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12289 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12290 (cond ((= mark gnus-ticked-mark)
12291 (push article gnus-newsgroup-marked))
12292 ((= mark gnus-dormant-mark)
12293 (push article gnus-newsgroup-dormant))
12295 (push article gnus-newsgroup-unreads)))
12296 (setq gnus-newsgroup-reads
12297 (delq (assq article gnus-newsgroup-reads)
12298 gnus-newsgroup-reads))))
12300 (defalias 'gnus-summary-mark-as-unread-forward
12301 'gnus-summary-tick-article-forward)
12302 (make-obsolete 'gnus-summary-mark-as-unread-forward
12303 'gnus-summary-tick-article-forward)
12304 (defun gnus-summary-tick-article-forward (n)
12305 "Tick N articles forwards.
12306 If N is negative, tick backwards instead.
12307 The difference between N and the number of articles ticked is returned."
12309 (gnus-summary-mark-forward n gnus-ticked-mark))
12311 (defalias 'gnus-summary-mark-as-unread-backward
12312 'gnus-summary-tick-article-backward)
12313 (make-obsolete 'gnus-summary-mark-as-unread-backward
12314 'gnus-summary-tick-article-backward)
12315 (defun gnus-summary-tick-article-backward (n)
12316 "Tick N articles backwards.
12317 The difference between N and the number of articles ticked is returned."
12319 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12321 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12322 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12323 (defun gnus-summary-tick-article (&optional article clear-mark)
12324 "Mark current article as unread.
12325 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12326 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12328 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12329 gnus-ticked-mark)))
12331 (defun gnus-summary-mark-as-read-forward (n)
12332 "Mark N articles as read forwards.
12333 If N is negative, mark backwards instead.
12334 The difference between N and the actual number of articles marked is
12337 (gnus-summary-mark-forward n gnus-del-mark t))
12339 (defun gnus-summary-mark-as-read-backward (n)
12340 "Mark the N articles as read backwards.
12341 The difference between N and the actual number of articles marked is
12344 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12346 (defun gnus-summary-mark-as-read (&optional article mark)
12347 "Mark current article as read.
12348 ARTICLE specifies the article to be marked as read.
12349 MARK specifies a string to be inserted at the beginning of the line."
12350 (gnus-summary-mark-article article mark))
12352 (defun gnus-summary-clear-mark-forward (n)
12353 "Clear marks from N articles forward.
12354 If N is negative, clear backward instead.
12355 The difference between N and the number of marks cleared is returned."
12357 (gnus-summary-mark-forward n gnus-unread-mark))
12359 (defun gnus-summary-clear-mark-backward (n)
12360 "Clear marks from N articles backward.
12361 The difference between N and the number of marks cleared is returned."
12363 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12365 (defun gnus-summary-mark-unread-as-read ()
12366 "Intended to be used by `gnus-summary-mark-article-hook'."
12367 (when (memq gnus-current-article gnus-newsgroup-unreads)
12368 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12370 (defun gnus-summary-mark-read-and-unread-as-read ()
12371 "Intended to be used by `gnus-summary-mark-article-hook'."
12372 (let ((mark (gnus-summary-article-mark)))
12373 (when (or (gnus-unread-mark-p mark)
12374 (gnus-read-mark-p mark))
12375 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12377 (defun gnus-summary-mark-region-as-read (point mark all)
12378 "Mark all unread articles between point and mark as read.
12379 If given a prefix, mark all articles between point and mark as read,
12380 even ticked and dormant ones."
12381 (interactive "r\nP")
12385 (beginning-of-line)
12390 (memq (setq article (gnus-summary-article-number))
12391 gnus-newsgroup-unreads))
12392 (gnus-summary-mark-article article gnus-del-mark))
12394 (gnus-summary-find-next))))))
12396 (defun gnus-summary-mark-below (score mark)
12397 "Mark articles with score less than SCORE with MARK."
12398 (interactive "P\ncMark: ")
12399 (gnus-set-global-variables)
12400 (setq score (if score
12401 (prefix-numeric-value score)
12402 (or gnus-summary-default-score 0)))
12404 (set-buffer gnus-summary-buffer)
12405 (goto-char (point-min))
12408 (and (< (gnus-summary-article-score) score)
12409 (gnus-summary-mark-article nil mark))
12410 (gnus-summary-find-next)))))
12412 (defun gnus-summary-kill-below (&optional score)
12413 "Mark articles with score below SCORE as read."
12415 (gnus-set-global-variables)
12416 (gnus-summary-mark-below score gnus-killed-mark))
12418 (defun gnus-summary-clear-above (&optional score)
12419 "Clear all marks from articles with score above SCORE."
12421 (gnus-set-global-variables)
12422 (gnus-summary-mark-above score gnus-unread-mark))
12424 (defun gnus-summary-tick-above (&optional score)
12425 "Tick all articles with score above SCORE."
12427 (gnus-set-global-variables)
12428 (gnus-summary-mark-above score gnus-ticked-mark))
12430 (defun gnus-summary-mark-above (score mark)
12431 "Mark articles with score over SCORE with MARK."
12432 (interactive "P\ncMark: ")
12433 (gnus-set-global-variables)
12434 (setq score (if score
12435 (prefix-numeric-value score)
12436 (or gnus-summary-default-score 0)))
12438 (set-buffer gnus-summary-buffer)
12439 (goto-char (point-min))
12441 (if (> (gnus-summary-article-score) score)
12442 (gnus-summary-mark-article nil mark))
12444 (gnus-summary-find-next)))))
12446 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12447 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12448 (defun gnus-summary-limit-include-expunged ()
12449 "Display all the hidden articles that were expunged for low scores."
12451 (gnus-set-global-variables)
12452 (let ((buffer-read-only nil))
12453 (let ((scored gnus-newsgroup-scored)
12456 (or (gnus-summary-goto-subject (caar scored))
12457 (and (setq h (gnus-summary-article-header (caar scored)))
12458 (< (cdar scored) gnus-summary-expunge-below)
12459 (setq headers (cons h headers))))
12460 (setq scored (cdr scored)))
12461 (or headers (error "No expunged articles hidden."))
12462 (goto-char (point-min))
12463 (gnus-summary-prepare-unthreaded (nreverse headers)))
12464 (goto-char (point-min))
12465 (gnus-summary-position-point)))
12467 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12468 "Mark all articles not marked as unread in this newsgroup as read.
12469 If prefix argument ALL is non-nil, all articles are marked as read.
12470 If QUIETLY is non-nil, no questions will be asked.
12471 If TO-HERE is non-nil, it should be a point in the buffer. All
12472 articles before this point will be marked as read.
12473 The number of articles marked as read is returned."
12475 (gnus-set-global-variables)
12478 (not gnus-interactive-catchup) ;Without confirmation?
12482 "Mark absolutely all articles as read? "
12483 "Mark all unread articles as read? ")))
12485 (not gnus-newsgroup-adaptive)
12486 (not gnus-newsgroup-auto-expire))
12489 (setq gnus-newsgroup-marked nil
12490 gnus-newsgroup-dormant nil))
12491 (setq gnus-newsgroup-unreads nil))
12492 ;; We actually mark all articles as canceled, which we
12493 ;; have to do when using auto-expiry or adaptive scoring.
12494 (gnus-summary-show-all-threads)
12495 (if (gnus-summary-first-subject (not all))
12497 (if to-here (< (point) to-here) t)
12498 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12499 (gnus-summary-find-next (not all)))))
12501 (setq gnus-newsgroup-unreads nil))
12502 (gnus-set-mode-line 'summary)))
12503 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12504 (if (and (not to-here) (eq 'nnvirtual (car method)))
12505 (nnvirtual-catchup-group
12506 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12507 (gnus-summary-position-point)))
12509 (defun gnus-summary-catchup-to-here (&optional all)
12510 "Mark all unticked articles before the current one as read.
12511 If ALL is non-nil, also mark ticked and dormant articles as read."
12513 (gnus-set-global-variables)
12515 (gnus-save-hidden-threads
12516 (let ((beg (point)))
12517 ;; We check that there are unread articles.
12518 (when (or all (gnus-summary-find-prev))
12519 (gnus-summary-catchup all t beg)))))
12520 (gnus-summary-position-point))
12522 (defun gnus-summary-catchup-all (&optional quietly)
12523 "Mark all articles in this newsgroup as read."
12525 (gnus-set-global-variables)
12526 (gnus-summary-catchup t quietly))
12528 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12529 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12530 If prefix argument ALL is non-nil, all articles are marked as read."
12532 (gnus-set-global-variables)
12533 (gnus-summary-catchup all quietly nil 'fast)
12534 ;; Select next newsgroup or exit.
12535 (if (eq gnus-auto-select-next 'quietly)
12536 (gnus-summary-next-group nil)
12537 (gnus-summary-exit)))
12539 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12540 "Mark all articles in this newsgroup as read, and then exit."
12542 (gnus-set-global-variables)
12543 (gnus-summary-catchup-and-exit t quietly))
12545 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12546 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12547 "Mark all articles in this group as read and select the next group.
12548 If given a prefix, mark all articles, unread as well as ticked, as
12551 (gnus-set-global-variables)
12553 (gnus-summary-catchup all))
12554 (gnus-summary-next-article t nil nil t))
12556 ;; Thread-based commands.
12558 (defun gnus-summary-articles-in-thread (&optional article)
12559 "Return a list of all articles in the current thread.
12560 If ARTICLE is non-nil, return all articles in the thread that starts
12561 with that article."
12562 (let* ((article (or article (gnus-summary-article-number)))
12563 (data (gnus-data-find-list article))
12564 (top-level (gnus-data-level (car data)))
12566 (cond ((null gnus-thread-operation-ignore-subject)
12567 (gnus-simplify-subject-re
12568 (mail-header-subject (gnus-data-header (car data)))))
12569 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12570 (gnus-simplify-subject-fuzzy
12571 (mail-header-subject (gnus-data-header (car data)))))
12573 (end-point (save-excursion
12574 (if (gnus-summary-go-to-next-thread)
12575 (point) (point-max))))
12578 (< (gnus-data-pos (car data)) end-point))
12579 (when (or (not top-subject)
12580 (string= top-subject
12581 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12582 (gnus-simplify-subject-fuzzy
12583 (mail-header-subject
12584 (gnus-data-header (car data))))
12585 (gnus-simplify-subject-re
12586 (mail-header-subject
12587 (gnus-data-header (car data)))))))
12588 (push (gnus-data-number (car data)) articles))
12589 (unless (and (setq data (cdr data))
12590 (> (gnus-data-level (car data)) top-level))
12592 ;; Return the list of articles.
12593 (nreverse articles)))
12595 (defun gnus-summary-rethread-current ()
12596 "Rethread the thread the current article is part of."
12598 (gnus-set-global-variables)
12599 (let* ((gnus-show-threads t)
12600 (article (gnus-summary-article-number))
12601 (id (mail-header-id (gnus-summary-article-header)))
12602 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12604 (error "No article on the current line"))
12605 (gnus-rebuild-thread id)
12606 (gnus-summary-goto-subject article)))
12608 (defun gnus-summary-reparent-thread ()
12609 "Make current article child of the marked (or previous) article.
12611 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12612 is non-nil or the Subject: of both articles are the same."
12614 (or (not (gnus-group-read-only-p))
12615 (error "The current newsgroup does not support article editing."))
12616 (or (<= (length gnus-newsgroup-processable) 1)
12617 (error "No more than one article may be marked."))
12618 (save-window-excursion
12619 (let ((gnus-article-buffer " *reparent*")
12620 (current-article (gnus-summary-article-number))
12621 ; first grab the marked article, otherwise one line up.
12622 (parent-article (if (not (null gnus-newsgroup-processable))
12623 (car gnus-newsgroup-processable)
12625 (if (eq (forward-line -1) 0)
12626 (gnus-summary-article-number)
12627 (error "Beginning of summary buffer."))))))
12628 (or (not (eq current-article parent-article))
12629 (error "An article may not be self-referential."))
12630 (let ((message-id (mail-header-id
12631 (gnus-summary-article-header parent-article))))
12632 (or (and message-id (not (equal message-id "")))
12633 (error "No message-id in desired parent."))
12634 (gnus-summary-select-article t t nil current-article)
12635 (set-buffer gnus-article-buffer)
12636 (setq buffer-read-only nil)
12637 (let ((buf (format "%s" (buffer-string))))
12640 (goto-char (point-min))
12641 (if (search-forward-regexp "^References: " nil t)
12642 (insert message-id " " )
12643 (insert "References: " message-id "\n"))
12644 (or (gnus-request-replace-article current-article
12645 (car gnus-article-current)
12646 gnus-article-buffer)
12647 (error "Couldn't replace article."))
12648 (set-buffer gnus-summary-buffer)
12649 (gnus-summary-unmark-all-processable)
12650 (gnus-summary-rethread-current)
12651 (gnus-message 3 "Article %d is now the child of article %d."
12652 current-article parent-article)))))
12654 (defun gnus-summary-toggle-threads (&optional arg)
12655 "Toggle showing conversation threads.
12656 If ARG is positive number, turn showing conversation threads on."
12658 (gnus-set-global-variables)
12659 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12660 (setq gnus-show-threads
12661 (if (null arg) (not gnus-show-threads)
12662 (> (prefix-numeric-value arg) 0)))
12663 (gnus-summary-prepare)
12664 (gnus-summary-goto-subject current)
12665 (gnus-summary-position-point)))
12667 (defun gnus-summary-show-all-threads ()
12668 "Show all threads."
12670 (gnus-set-global-variables)
12672 (let ((buffer-read-only nil))
12673 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12674 (gnus-summary-position-point))
12676 (defun gnus-summary-show-thread ()
12677 "Show thread subtrees.
12678 Returns nil if no thread was there to be shown."
12680 (gnus-set-global-variables)
12681 (let ((buffer-read-only nil)
12683 ;; first goto end then to beg, to have point at beg after let
12684 (end (progn (end-of-line) (point)))
12685 (beg (progn (beginning-of-line) (point))))
12687 ;; Any hidden lines here?
12688 (search-forward "\r" end t)
12689 (subst-char-in-region beg end ?\^M ?\n t)
12691 (gnus-summary-position-point))))
12693 (defun gnus-summary-hide-all-threads ()
12694 "Hide all thread subtrees."
12696 (gnus-set-global-variables)
12698 (goto-char (point-min))
12699 (gnus-summary-hide-thread)
12700 (while (zerop (gnus-summary-next-thread 1 t))
12701 (gnus-summary-hide-thread)))
12702 (gnus-summary-position-point))
12704 (defun gnus-summary-hide-thread ()
12705 "Hide thread subtrees.
12706 Returns nil if no threads were there to be hidden."
12708 (gnus-set-global-variables)
12709 (let ((buffer-read-only nil)
12711 (article (gnus-summary-article-number)))
12713 ;; Go forward until either the buffer ends or the subthread
12715 (when (and (not (eobp))
12716 (or (zerop (gnus-summary-next-thread 1 t))
12717 (goto-char (point-max))))
12719 (if (and (> (point) start)
12720 (search-backward "\n" start t))
12722 (subst-char-in-region start (point) ?\n ?\^M)
12723 (gnus-summary-goto-subject article))
12726 ;;(gnus-summary-position-point)
12729 (defun gnus-summary-go-to-next-thread (&optional previous)
12730 "Go to the same level (or less) next thread.
12731 If PREVIOUS is non-nil, go to previous thread instead.
12732 Return the article number moved to, or nil if moving was impossible."
12733 (let ((level (gnus-summary-thread-level))
12734 (way (if previous -1 1))
12737 (while (and (not (eobp))
12738 (< level (gnus-summary-thread-level)))
12739 (forward-line way))
12746 (gnus-summary-article-number)
12747 (goto-char beg)))))
12749 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12750 "Go to the same level (or less) next thread.
12751 If PREVIOUS is non-nil, go to previous thread instead.
12752 Return the article number moved to, or nil if moving was impossible."
12753 (if (and (eq gnus-summary-make-false-root 'dummy)
12754 (gnus-summary-article-intangible-p))
12755 (let ((beg (point)))
12756 (while (and (zerop (forward-line 1))
12757 (not (gnus-summary-article-intangible-p))
12758 (not (zerop (save-excursion
12759 (gnus-summary-thread-level))))))
12765 (let* ((level (gnus-summary-thread-level))
12766 (article (gnus-summary-article-number))
12767 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12770 (if (<= (gnus-data-level (car data)) level)
12771 (setq oart (gnus-data-number (car data))
12773 (setq data (cdr data))))
12775 (gnus-summary-goto-subject oart)))))
12777 (defun gnus-summary-next-thread (n &optional silent)
12778 "Go to the same level next N'th thread.
12779 If N is negative, search backward instead.
12780 Returns the difference between N and the number of skips actually
12783 If SILENT, don't output messages."
12785 (gnus-set-global-variables)
12786 (let ((backward (< n 0))
12789 (while (and (> n 0)
12790 (gnus-summary-go-to-next-thread backward))
12793 (gnus-summary-position-point))
12794 (when (and (not silent) (/= 0 n))
12795 (gnus-message 7 "No more threads"))
12798 (defun gnus-summary-prev-thread (n)
12799 "Go to the same level previous N'th thread.
12800 Returns the difference between N and the number of skips actually
12803 (gnus-set-global-variables)
12804 (gnus-summary-next-thread (- n)))
12806 (defun gnus-summary-go-down-thread ()
12807 "Go down one level in the current thread."
12808 (let ((children (gnus-summary-article-children)))
12810 (gnus-summary-goto-subject (car children)))))
12812 (defun gnus-summary-go-up-thread ()
12813 "Go up one level in the current thread."
12814 (let ((parent (gnus-summary-article-parent)))
12816 (gnus-summary-goto-subject parent))))
12818 (defun gnus-summary-down-thread (n)
12819 "Go down thread N steps.
12820 If N is negative, go up instead.
12821 Returns the difference between N and how many steps down that were
12824 (gnus-set-global-variables)
12827 (while (and (> n 0)
12828 (if up (gnus-summary-go-up-thread)
12829 (gnus-summary-go-down-thread)))
12831 (gnus-summary-position-point)
12832 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12835 (defun gnus-summary-up-thread (n)
12836 "Go up thread N steps.
12837 If N is negative, go up instead.
12838 Returns the difference between N and how many steps down that were
12841 (gnus-set-global-variables)
12842 (gnus-summary-down-thread (- n)))
12844 (defun gnus-summary-top-thread ()
12845 "Go to the top of the thread."
12847 (gnus-set-global-variables)
12848 (while (gnus-summary-go-up-thread))
12849 (gnus-summary-article-number))
12851 (defun gnus-summary-kill-thread (&optional unmark)
12852 "Mark articles under current thread as read.
12853 If the prefix argument is positive, remove any kinds of marks.
12854 If the prefix argument is negative, tick articles instead."
12856 (gnus-set-global-variables)
12858 (setq unmark (prefix-numeric-value unmark)))
12859 (let ((articles (gnus-summary-articles-in-thread)))
12861 ;; Expand the thread.
12862 (gnus-summary-show-thread)
12863 ;; Mark all the articles.
12865 (gnus-summary-goto-subject (car articles))
12866 (cond ((null unmark)
12867 (gnus-summary-mark-article-as-read gnus-killed-mark))
12869 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12871 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12872 (setq articles (cdr articles))))
12873 ;; Hide killed subtrees.
12875 gnus-thread-hide-killed
12876 (gnus-summary-hide-thread))
12877 ;; If marked as read, go to next unread subject.
12879 ;; Go to next unread subject.
12880 (gnus-summary-next-subject 1 t)))
12881 (gnus-set-mode-line 'summary))
12883 ;; Summary sorting commands
12885 (defun gnus-summary-sort-by-number (&optional reverse)
12886 "Sort summary buffer by article number.
12887 Argument REVERSE means reverse order."
12889 (gnus-summary-sort 'number reverse))
12891 (defun gnus-summary-sort-by-author (&optional reverse)
12892 "Sort summary buffer by author name alphabetically.
12893 If case-fold-search is non-nil, case of letters is ignored.
12894 Argument REVERSE means reverse order."
12896 (gnus-summary-sort 'author reverse))
12898 (defun gnus-summary-sort-by-subject (&optional reverse)
12899 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12900 If case-fold-search is non-nil, case of letters is ignored.
12901 Argument REVERSE means reverse order."
12903 (gnus-summary-sort 'subject reverse))
12905 (defun gnus-summary-sort-by-date (&optional reverse)
12906 "Sort summary buffer by date.
12907 Argument REVERSE means reverse order."
12909 (gnus-summary-sort 'date reverse))
12911 (defun gnus-summary-sort-by-score (&optional reverse)
12912 "Sort summary buffer by score.
12913 Argument REVERSE means reverse order."
12915 (gnus-summary-sort 'score reverse))
12917 (defun gnus-summary-sort (predicate reverse)
12918 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12919 (gnus-set-global-variables)
12920 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12921 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12922 (gnus-thread-sort-functions
12927 (,thread t2 t1)))))
12928 (gnus-article-sort-functions
12933 (,article t2 t1)))))
12935 (gnus-summary-prepare-hook nil))
12936 ;; We do the sorting by regenerating the threads.
12937 (gnus-summary-prepare)
12938 ;; Hide subthreads if needed.
12939 (when (and gnus-show-threads gnus-thread-hide-subtree)
12940 (gnus-summary-hide-all-threads)))
12941 ;; If in async mode, we send some info to the backend.
12942 (when gnus-newsgroup-async
12943 (gnus-request-asynchronous
12944 gnus-newsgroup-name gnus-newsgroup-data)))
12946 (defun gnus-sortable-date (date)
12947 "Make sortable string by string-lessp from DATE.
12948 Timezone package is used."
12951 (setq date (inline (timezone-fix-time
12953 (aref (inline (timezone-parse-date date)) 4))))
12955 (timezone-make-sortable-date
12956 (aref date 0) (aref date 1) (aref date 2)
12958 (timezone-make-time-string
12959 (aref date 3) (aref date 4) (aref date 5))))))
12962 ;; Summary saving commands.
12964 (defun gnus-summary-save-article (&optional n not-saved)
12965 "Save the current article using the default saver function.
12966 If N is a positive number, save the N next articles.
12967 If N is a negative number, save the N previous articles.
12968 If N is nil and any articles have been marked with the process mark,
12969 save those articles instead.
12970 The variable `gnus-default-article-saver' specifies the saver function."
12972 (gnus-set-global-variables)
12973 (let ((articles (gnus-summary-work-articles n))
12974 (save-buffer (save-excursion
12975 (nnheader-set-temp-buffer " *Gnus Save*")))
12976 file header article)
12978 (setq header (gnus-summary-article-header
12979 (setq article (pop articles))))
12980 (if (not (vectorp header))
12981 ;; This is a pseudo-article.
12982 (if (assq 'name header)
12983 (gnus-copy-file (cdr (assq 'name header)))
12984 (gnus-message 1 "Article %d is unsaveable" article))
12985 ;; This is a real article.
12986 (save-window-excursion
12987 (gnus-summary-select-article t nil nil article))
12989 (set-buffer save-buffer)
12991 (insert-buffer-substring gnus-original-article-buffer))
12992 (unless gnus-save-all-headers
12993 ;; Remove headers accoring to `gnus-saved-headers'.
12994 (let ((gnus-visible-headers
12995 (or gnus-saved-headers gnus-visible-headers))
12996 (gnus-article-buffer save-buffer))
12997 (gnus-article-hide-headers 1 t)))
12998 (save-window-excursion
12999 (if (not gnus-default-article-saver)
13000 (error "No default saver is defined.")
13001 ;; !!! Magic! The saving functions all save
13002 ;; `gnus-original-article-buffer' (or so they think),
13003 ;; but we bind that variable to our save-buffer.
13004 (set-buffer gnus-article-buffer)
13005 (let ((gnus-original-article-buffer save-buffer))
13006 (set-buffer gnus-summary-buffer)
13007 (setq file (funcall
13008 gnus-default-article-saver
13010 ((not gnus-prompt-before-saving)
13012 ((eq gnus-prompt-before-saving 'always)
13015 (gnus-summary-remove-process-mark article)
13017 (gnus-summary-set-saved-mark article))))
13018 (gnus-kill-buffer save-buffer)
13019 (gnus-summary-position-point)
13022 (defun gnus-summary-pipe-output (&optional arg)
13023 "Pipe the current article to a subprocess.
13024 If N is a positive number, pipe the N next articles.
13025 If N is a negative number, pipe the N previous articles.
13026 If N is nil and any articles have been marked with the process mark,
13027 pipe those articles instead."
13029 (gnus-set-global-variables)
13030 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13031 (gnus-summary-save-article arg t))
13032 (gnus-configure-windows 'pipe))
13034 (defun gnus-summary-save-article-mail (&optional arg)
13035 "Append the current article to an mail file.
13036 If N is a positive number, save the N next articles.
13037 If N is a negative number, save the N previous articles.
13038 If N is nil and any articles have been marked with the process mark,
13039 save those articles instead."
13041 (gnus-set-global-variables)
13042 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13043 (gnus-summary-save-article arg)))
13045 (defun gnus-summary-save-article-rmail (&optional arg)
13046 "Append the current article to an rmail file.
13047 If N is a positive number, save the N next articles.
13048 If N is a negative number, save the N previous articles.
13049 If N is nil and any articles have been marked with the process mark,
13050 save those articles instead."
13052 (gnus-set-global-variables)
13053 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13054 (gnus-summary-save-article arg)))
13056 (defun gnus-summary-save-article-file (&optional arg)
13057 "Append the current article to a file.
13058 If N is a positive number, save the N next articles.
13059 If N is a negative number, save the N previous articles.
13060 If N is nil and any articles have been marked with the process mark,
13061 save those articles instead."
13063 (gnus-set-global-variables)
13064 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13065 (gnus-summary-save-article arg)))
13067 (defun gnus-summary-save-article-body-file (&optional arg)
13068 "Append the current article body to a file.
13069 If N is a positive number, save the N next articles.
13070 If N is a negative number, save the N previous articles.
13071 If N is nil and any articles have been marked with the process mark,
13072 save those articles instead."
13074 (gnus-set-global-variables)
13075 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13076 (gnus-summary-save-article arg)))
13078 (defun gnus-get-split-value (methods)
13079 "Return a value based on the split METHODS."
13080 (let (split-name method result match)
13083 (set-buffer gnus-original-article-buffer)
13085 (nnheader-narrow-to-headers)
13087 (goto-char (point-min))
13088 (setq method (pop methods))
13089 (setq match (car method))
13092 ;; Regular expression.
13094 (re-search-forward match nil t)
13096 ((gnus-functionp match)
13100 (setq result (funcall match gnus-newsgroup-name))))
13105 (setq result (eval match)))))
13106 (setq split-name (append (cdr method) split-name))
13107 (cond ((stringp result)
13108 (push result split-name))
13110 (setq split-name (append result split-name)))))))))
13113 (defun gnus-read-move-group-name (prompt default articles prefix)
13114 "Read a group name."
13115 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13116 (minibuffer-confirm-incomplete nil) ; XEmacs
13123 (assoc (symbol-name
13124 (car (gnus-find-method-for-group
13126 gnus-valid-select-methods))
13127 (push (list (symbol-name g)) group-map)))
13128 gnus-active-hashtb))
13130 (format "%s %s to:"
13132 (if (> (length articles) 1)
13133 (format "these %d articles" (length articles))
13138 (gnus-completing-read default prom
13139 group-map nil nil prefix
13140 'gnus-group-history))
13141 ((= 1 (length split-name))
13142 (gnus-completing-read (car split-name) prom group-map
13144 'gnus-group-history))
13146 (gnus-completing-read nil prom
13147 (mapcar (lambda (el) (list el))
13148 (nreverse split-name))
13150 'gnus-group-history)))))
13152 (if (or (string= to-newsgroup "")
13153 (string= to-newsgroup prefix))
13154 (setq to-newsgroup (or default "")))
13155 (or (gnus-active to-newsgroup)
13156 (gnus-activate-group to-newsgroup)
13157 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13159 (or (and (gnus-request-create-group
13160 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13161 (gnus-activate-group to-newsgroup nil nil
13162 (gnus-group-name-to-method
13164 (error "Couldn't create group %s" to-newsgroup)))
13165 (error "No such group: %s" to-newsgroup)))
13168 (defun gnus-read-save-file-name (prompt default-name)
13169 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13171 ;; Let the split methods have their say.
13173 ;; No split name was found.
13176 (concat prompt " (default "
13177 (file-name-nondirectory default-name) ") ")
13178 (file-name-directory default-name)
13180 ;; A single split name was found
13181 ((= 1 (length split-name))
13182 (let* ((name (car split-name))
13183 (dir (cond ((file-directory-p name)
13184 (file-name-as-directory name))
13185 ((file-exists-p name) name)
13186 (t gnus-article-save-directory))))
13188 (concat prompt " (default " name ") ")
13190 ;; A list of splits was found.
13192 (setq split-name (nreverse split-name))
13194 (let ((file-name-history (nconc split-name file-name-history)))
13197 (concat prompt " (`M-p' for defaults) ")
13198 gnus-article-save-directory
13199 (car split-name))))
13200 (car (push result file-name-history)))))))
13201 ;; If we have read a directory, we append the default file name.
13202 (when (file-directory-p file)
13203 (setq file (concat (file-name-as-directory file)
13204 (file-name-nondirectory default-name))))
13205 ;; Possibly translate some charaters.
13206 (nnheader-translate-file-chars file)))
13208 (defun gnus-article-archive-name (group)
13209 "Return the first instance of an \"Archive-name\" in the current buffer."
13210 (let ((case-fold-search t))
13211 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13212 (match-string 1))))
13214 (defun gnus-summary-save-in-rmail (&optional filename)
13215 "Append this article to Rmail file.
13216 Optional argument FILENAME specifies file name.
13217 Directory to save to is default to `gnus-article-save-directory'."
13219 (gnus-set-global-variables)
13220 (let ((default-name
13221 (funcall gnus-rmail-save-name gnus-newsgroup-name
13222 gnus-current-headers gnus-newsgroup-last-rmail)))
13224 (cond ((eq filename 'default)
13226 (filename filename)
13227 (t (gnus-read-save-file-name
13228 "Save in rmail file:" default-name))))
13229 (gnus-make-directory (file-name-directory filename))
13230 (gnus-eval-in-buffer-window gnus-original-article-buffer
13234 (gnus-output-to-rmail filename))))
13235 ;; Remember the directory name to save articles
13236 (setq gnus-newsgroup-last-rmail filename)))
13238 (defun gnus-summary-save-in-mail (&optional filename)
13239 "Append this article to Unix mail file.
13240 Optional argument FILENAME specifies file name.
13241 Directory to save to is default to `gnus-article-save-directory'."
13243 (gnus-set-global-variables)
13244 (let ((default-name
13245 (funcall gnus-mail-save-name gnus-newsgroup-name
13246 gnus-current-headers gnus-newsgroup-last-mail)))
13248 (cond ((eq filename 'default)
13250 (filename filename)
13251 (t (gnus-read-save-file-name
13252 "Save in Unix mail file:" default-name))))
13254 (expand-file-name filename
13256 (file-name-directory default-name))))
13257 (gnus-make-directory (file-name-directory filename))
13258 (gnus-eval-in-buffer-window gnus-original-article-buffer
13262 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13263 (gnus-output-to-rmail filename)
13264 (let ((mail-use-rfc822 t))
13265 (rmail-output filename 1 t t))))))
13266 ;; Remember the directory name to save articles.
13267 (setq gnus-newsgroup-last-mail filename)))
13269 (defun gnus-summary-save-in-file (&optional filename)
13270 "Append this article to file.
13271 Optional argument FILENAME specifies file name.
13272 Directory to save to is default to `gnus-article-save-directory'."
13274 (gnus-set-global-variables)
13275 (let ((default-name
13276 (funcall gnus-file-save-name gnus-newsgroup-name
13277 gnus-current-headers gnus-newsgroup-last-file)))
13279 (cond ((eq filename 'default)
13281 (filename filename)
13282 (t (gnus-read-save-file-name
13283 "Save in file:" default-name))))
13284 (gnus-make-directory (file-name-directory filename))
13285 (gnus-eval-in-buffer-window gnus-original-article-buffer
13289 (gnus-output-to-file filename))))
13290 ;; Remember the directory name to save articles.
13291 (setq gnus-newsgroup-last-file filename)))
13293 (defun gnus-summary-save-body-in-file (&optional filename)
13294 "Append this article body to a file.
13295 Optional argument FILENAME specifies file name.
13296 The directory to save in defaults to `gnus-article-save-directory'."
13298 (gnus-set-global-variables)
13299 (let ((default-name
13300 (funcall gnus-file-save-name gnus-newsgroup-name
13301 gnus-current-headers gnus-newsgroup-last-file)))
13303 (cond ((eq filename 'default)
13305 (filename filename)
13306 (t (gnus-read-save-file-name
13307 "Save body in file:" default-name))))
13308 (gnus-make-directory (file-name-directory filename))
13309 (gnus-eval-in-buffer-window gnus-original-article-buffer
13313 (goto-char (point-min))
13314 (and (search-forward "\n\n" nil t)
13315 (narrow-to-region (point) (point-max)))
13316 (gnus-output-to-file filename))))
13317 ;; Remember the directory name to save articles.
13318 (setq gnus-newsgroup-last-file filename)))
13320 (defun gnus-summary-save-in-pipe (&optional command)
13321 "Pipe this article to subprocess."
13323 (gnus-set-global-variables)
13325 (cond ((eq command 'default)
13326 gnus-last-shell-command)
13328 (t (read-string "Shell command on article: "
13329 gnus-last-shell-command))))
13330 (if (string-equal command "")
13331 (setq command gnus-last-shell-command))
13332 (gnus-eval-in-buffer-window gnus-article-buffer
13335 (shell-command-on-region (point-min) (point-max) command nil)))
13336 (setq gnus-last-shell-command command))
13338 ;; Summary extract commands
13340 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13341 (let ((buffer-read-only nil)
13342 (article (gnus-summary-article-number))
13344 (or (gnus-summary-goto-subject article)
13345 (error (format "No such article: %d" article)))
13346 (gnus-summary-position-point)
13347 ;; If all commands are to be bunched up on one line, we collect
13349 (if gnus-view-pseudos-separately
13351 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13354 (setq action (cdr (assq 'action (car ps))))
13355 (setq files (list (cdr (assq 'name (car ps)))))
13356 (while (and ps (cdr ps)
13357 (string= (or action "1")
13358 (or (cdr (assq 'action (cadr ps))) "2")))
13359 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13360 (setcdr ps (cddr ps)))
13363 (if (not (string-match "%s" action))
13364 (setq files (cons " " files)))
13365 (setq files (cons " " files))
13366 (and (assq 'execute (car ps))
13367 (setcdr (assq 'execute (car ps))
13368 (funcall (if (string-match "%s" action)
13371 (mapconcat (lambda (f) f) files " ")))))
13372 (setq ps (cdr ps)))))
13373 (if (and gnus-view-pseudos (not not-view))
13375 (and (assq 'execute (car pslist))
13376 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13377 (eq gnus-view-pseudos 'not-confirm)))
13378 (setq pslist (cdr pslist)))
13381 (setq after-article (or (cdr (assq 'article (car pslist)))
13382 (gnus-summary-article-number)))
13383 (gnus-summary-goto-subject after-article)
13386 (insert " " (file-name-nondirectory
13387 (cdr (assq 'name (car pslist))))
13388 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13390 (forward-line -1) ; back to `b'
13391 (gnus-add-text-properties
13392 b (1- e) (list 'gnus-number gnus-reffed-article-number
13393 gnus-mouse-face-prop gnus-mouse-face))
13395 after-article gnus-reffed-article-number
13396 gnus-unread-mark b (car pslist) 0 (- e b))
13397 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13398 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13399 (setq pslist (cdr pslist)))))))
13401 (defun gnus-pseudos< (p1 p2)
13402 (let ((c1 (cdr (assq 'action p1)))
13403 (c2 (cdr (assq 'action p2))))
13404 (and c1 c2 (string< c1 c2))))
13406 (defun gnus-request-pseudo-article (props)
13407 (cond ((assq 'execute props)
13408 (gnus-execute-command (cdr (assq 'execute props)))))
13409 (let ((gnus-current-article (gnus-summary-article-number)))
13410 (run-hooks 'gnus-mark-article-hook)))
13412 (defun gnus-execute-command (command &optional automatic)
13414 (gnus-article-setup-buffer)
13415 (set-buffer gnus-article-buffer)
13416 (setq buffer-read-only nil)
13417 (let ((command (if automatic command (read-string "Command: " command)))
13418 ;; Just binding this here doesn't help, because there might
13419 ;; be output from the process after exiting the scope of
13421 ;; (buffer-read-only nil)
13424 (insert "$ " command "\n\n")
13425 (if gnus-view-pseudo-asynchronously
13426 (start-process "gnus-execute" nil shell-file-name
13427 shell-command-switch command)
13428 (call-process shell-file-name nil t nil
13429 shell-command-switch command)))))
13431 (defun gnus-copy-file (file &optional to)
13434 (list (read-file-name "Copy file: " default-directory)
13435 (read-file-name "Copy file to: " default-directory)))
13436 (gnus-set-global-variables)
13437 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13438 (and (file-directory-p to)
13439 (setq to (concat (file-name-as-directory to)
13440 (file-name-nondirectory file))))
13441 (copy-file file to))
13443 ;; Summary kill commands.
13445 (defun gnus-summary-edit-global-kill (article)
13446 "Edit the \"global\" kill file."
13447 (interactive (list (gnus-summary-article-number)))
13448 (gnus-set-global-variables)
13449 (gnus-group-edit-global-kill article))
13451 (defun gnus-summary-edit-local-kill ()
13452 "Edit a local kill file applied to the current newsgroup."
13454 (gnus-set-global-variables)
13455 (setq gnus-current-headers (gnus-summary-article-header))
13456 (gnus-set-global-variables)
13457 (gnus-group-edit-local-kill
13458 (gnus-summary-article-number) gnus-newsgroup-name))
13462 ;;; Gnus article mode
13465 (put 'gnus-article-mode 'mode-class 'special)
13467 (if gnus-article-mode-map
13469 (setq gnus-article-mode-map (make-keymap))
13470 (suppress-keymap gnus-article-mode-map)
13472 (gnus-define-keys gnus-article-mode-map
13473 " " gnus-article-goto-next-page
13474 "\177" gnus-article-goto-prev-page
13475 [delete] gnus-article-goto-prev-page
13476 "\C-c^" gnus-article-refer-article
13477 "h" gnus-article-show-summary
13478 "s" gnus-article-show-summary
13479 "\C-c\C-m" gnus-article-mail
13480 "?" gnus-article-describe-briefly
13481 gnus-mouse-2 gnus-article-push-button
13482 "\r" gnus-article-press-button
13483 "\t" gnus-article-next-button
13484 "\M-\t" gnus-article-prev-button
13485 "<" beginning-of-buffer
13487 "\C-c\C-b" gnus-bug
)
13489 (substitute-key-definition
13490 'undefined
'gnus-article-read-summary-keys gnus-article-mode-map
))
13492 (defun gnus-article-mode ()
13493 "Major mode for displaying an article.
13495 All normal editing commands are switched off.
13497 The following commands are available:
13499 \\<gnus-article-mode-map>
13500 \\[gnus-article-next-page]\t Scroll the article one page forwards
13501 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13502 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13503 \\[gnus-article-show-summary]\t Display the summary buffer
13504 \\[gnus-article-mail]\t Send a reply to the address near point
13505 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13506 \\[gnus-info-find-node]\t Go to the Gnus info node"
13508 (when (and menu-bar-mode
13509 (gnus-visual-p 'article-menu
'menu
))
13510 (gnus-article-make-menu-bar))
13511 (kill-all-local-variables)
13512 (gnus-simplify-mode-line)
13513 (setq mode-name
"Article")
13514 (setq major-mode
'gnus-article-mode
)
13515 (make-local-variable 'minor-mode-alist
)
13516 (or (assq 'gnus-show-mime minor-mode-alist
)
13517 (setq minor-mode-alist
13518 (cons (list 'gnus-show-mime
" MIME") minor-mode-alist
)))
13519 (use-local-map gnus-article-mode-map
)
13520 (make-local-variable 'page-delimiter
)
13521 (setq page-delimiter gnus-page-delimiter
)
13522 (buffer-disable-undo (current-buffer))
13523 (setq buffer-read-only t
) ;Disable modification
13524 (run-hooks 'gnus-article-mode-hook
))
13526 (defun gnus-article-setup-buffer ()
13527 "Initialize the article buffer."
13528 (let* ((name (if gnus-single-article-buffer
"*Article*"
13529 (concat "*Article " gnus-newsgroup-name
"*")))
13531 (progn (string-match "\\*Article" name
)
13532 (concat " *Original Article"
13533 (substring name
(match-end 0))))))
13534 (setq gnus-article-buffer name
)
13535 (setq gnus-original-article-buffer original
)
13536 ;; This might be a variable local to the summary buffer.
13537 (unless gnus-single-article-buffer
13539 (set-buffer gnus-summary-buffer
)
13540 (setq gnus-article-buffer name
)
13541 (setq gnus-original-article-buffer original
)
13542 (gnus-set-global-variables))
13543 (make-local-variable 'gnus-summary-buffer
))
13544 ;; Init original article buffer.
13546 (set-buffer (get-buffer-create gnus-original-article-buffer
))
13547 (buffer-disable-undo (current-buffer))
13548 (setq major-mode
'gnus-original-article-mode
)
13549 (make-local-variable 'gnus-original-article
))
13550 (if (get-buffer name
)
13553 (buffer-disable-undo (current-buffer))
13554 (setq buffer-read-only t
)
13555 (gnus-add-current-to-buffer-list)
13556 (or (eq major-mode
'gnus-article-mode
)
13557 (gnus-article-mode))
13560 (set-buffer (get-buffer-create name
))
13561 (gnus-add-current-to-buffer-list)
13562 (gnus-article-mode)
13563 (current-buffer)))))
13565 ;; Set article window start at LINE, where LINE is the number of lines
13566 ;; from the head of the article.
13567 (defun gnus-article-set-window-start (&optional line
)
13569 (get-buffer-window gnus-article-buffer t
)
13571 (set-buffer gnus-article-buffer
)
13572 (goto-char (point-min))
13575 (gnus-message 6 "Moved to bookmark")
13576 (search-forward "\n\n" nil t
)
13577 (forward-line line
)
13580 (defun gnus-kill-all-overlays ()
13581 "Delete all overlays in the current buffer."
13582 (when (fboundp 'overlay-lists
)
13583 (let* ((overlayss (overlay-lists))
13584 (buffer-read-only nil
)
13585 (overlays (nconc (car overlayss
) (cdr overlayss
))))
13587 (delete-overlay (pop overlays
))))))
13589 (defun gnus-request-article-this-buffer (article group
)
13590 "Get an article and insert it into this buffer."
13591 (let (do-update-line)
13595 (gnus-kill-all-overlays)
13596 (setq group
(or group gnus-newsgroup-name
))
13598 ;; Open server if it has closed.
13599 (gnus-check-server (gnus-find-method-for-group group
))
13601 ;; Using `gnus-request-article' directly will insert the article into
13602 ;; `nntp-server-buffer' - so we'll save some time by not having to
13603 ;; copy it from the server buffer into the article buffer.
13605 ;; We only request an article by message-id when we do not have the
13606 ;; headers for it, so we'll have to get those.
13607 (when (stringp article
)
13608 (let ((gnus-override-method gnus-refer-article-method
))
13609 (gnus-read-header article
)))
13611 ;; If the article number is negative, that means that this article
13612 ;; doesn't belong in this newsgroup (possibly), so we find its
13613 ;; message-id and request it by id instead of number.
13614 (when (and (numberp article
)
13615 gnus-summary-buffer
13616 (get-buffer gnus-summary-buffer
)
13617 (buffer-name (get-buffer gnus-summary-buffer
)))
13619 (set-buffer gnus-summary-buffer
)
13620 (let ((header (gnus-summary-article-header article
)))
13623 ((memq article gnus-newsgroup-sparse
)
13624 ;; This is a sparse gap article.
13625 (setq do-update-line article
)
13626 (setq article
(mail-header-id header
))
13627 (let ((gnus-override-method gnus-refer-article-method
))
13628 (gnus-read-header article
))
13629 (setq gnus-newsgroup-sparse
13630 (delq article gnus-newsgroup-sparse
)))
13632 ;; It's a real article.
13633 (setq article
(mail-header-id header
)))
13635 ;; It is an extracted pseudo-article.
13636 (setq article
'pseudo
)
13637 (gnus-request-pseudo-article header
))))
13639 (let ((method (gnus-find-method-for-group
13640 gnus-newsgroup-name
)))
13641 (if (not (eq (car method
) 'nneething
))
13643 (let ((dir (concat (file-name-as-directory (nth 1 method
))
13644 (mail-header-subject header
))))
13645 (if (file-directory-p dir
)
13647 (setq article
'nneething
)
13648 (gnus-group-enter-directory dir
)))))))))
13651 ;; Refuse to select canceled articles.
13652 ((and (numberp article
)
13653 gnus-summary-buffer
13654 (get-buffer gnus-summary-buffer
)
13655 (buffer-name (get-buffer gnus-summary-buffer
))
13656 (eq (cdr (save-excursion
13657 (set-buffer gnus-summary-buffer
)
13658 (assq article gnus-newsgroup-reads
)))
13659 gnus-canceled-mark
))
13661 ;; We first check `gnus-original-article-buffer'.
13662 ((and (get-buffer gnus-original-article-buffer
)
13665 (set-buffer gnus-original-article-buffer
)
13666 (and (equal (car gnus-original-article
) group
)
13667 (eq (cdr gnus-original-article
) article
))))
13668 (insert-buffer-substring gnus-original-article-buffer
)
13670 ;; Check the backlog.
13671 ((and gnus-keep-backlog
13672 (gnus-backlog-request-article group article
(current-buffer)))
13674 ;; Check the cache.
13675 ((and gnus-use-cache
13677 (gnus-cache-request-article article group
))
13679 ;; Get the article and put into the article buffer.
13680 ((or (stringp article
) (numberp article
))
13681 (let ((gnus-override-method
13682 (and (stringp article
) gnus-refer-article-method
))
13683 (buffer-read-only nil
))
13685 (gnus-kill-all-overlays)
13686 (if (gnus-request-article article group
(current-buffer))
13688 (and gnus-keep-backlog
13690 (gnus-backlog-enter-article
13691 group article
(current-buffer)))
13693 ;; It was a pseudo.
13696 ;; Take the article from the original article buffer
13697 ;; and place it in the buffer it's supposed to be in.
13698 (when (and (get-buffer gnus-article-buffer
)
13699 ;;(numberp article)
13700 (equal (buffer-name (current-buffer))
13701 (buffer-name (get-buffer gnus-article-buffer
))))
13703 (if (get-buffer gnus-original-article-buffer
)
13704 (set-buffer (get-buffer gnus-original-article-buffer
))
13705 (set-buffer (get-buffer-create gnus-original-article-buffer
))
13706 (buffer-disable-undo (current-buffer))
13707 (setq major-mode
'gnus-original-article-mode
)
13708 (setq buffer-read-only t
)
13709 (gnus-add-current-to-buffer-list))
13710 (let (buffer-read-only)
13712 (insert-buffer-substring gnus-article-buffer
))
13713 (setq gnus-original-article
(cons group article
))))
13715 ;; Update sparse articles.
13716 (when (and do-update-line
13717 (or (numberp article
)
13718 (stringp article
)))
13719 (let ((buf (current-buffer)))
13720 (set-buffer gnus-summary-buffer
)
13721 (gnus-summary-update-article do-update-line
)
13722 (gnus-summary-goto-subject do-update-line nil t
)
13723 (set-window-point (get-buffer-window (current-buffer) t
)
13725 (set-buffer buf
))))))
13727 (defun gnus-read-header (id &optional header
)
13728 "Read the headers of article ID and enter them into the Gnus system."
13729 (let ((group gnus-newsgroup-name
)
13730 (gnus-override-method
13731 (and (gnus-news-group-p gnus-newsgroup-name
)
13732 gnus-refer-article-method
))
13734 ;; First we check to see whether the header in question is already
13737 ;; This is a Message-ID.
13738 (setq header
(or header
(gnus-id-to-header id
)))
13739 ;; This is an article number.
13740 (setq header
(or header
(gnus-summary-article-header id
))))
13742 (not (memq (mail-header-number header
) gnus-newsgroup-sparse
)))
13743 ;; We have found the header.
13745 ;; We have to really fetch the header to this article.
13746 (when (setq where
(gnus-request-head id group
))
13748 (set-buffer nntp-server-buffer
)
13749 (goto-char (point-max))
13751 (goto-char (point-min))
13755 ((cdr where
) (cdr where
))
13756 (header (mail-header-number header
))
13757 (t gnus-reffed-article-number
))
13759 (insert " Article retrieved.\n"))
13761 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13762 ; (setcar (gnus-id-to-thread id) nil))
13763 (if (not (setq header
(car (gnus-get-newsgroup-headers))))
13764 () ; Malformed head.
13765 (unless (memq (mail-header-number header
) gnus-newsgroup-sparse
)
13766 (if (and (stringp id
)
13767 (not (string= (gnus-group-real-name group
)
13769 ;; If we fetched by Message-ID and the article came
13770 ;; from a different group, we fudge some bogus article
13771 ;; numbers for this article.
13772 (mail-header-set-number header gnus-reffed-article-number
))
13773 (decf gnus-reffed-article-number
)
13774 (gnus-remove-header (mail-header-number header
))
13775 (push header gnus-newsgroup-headers
)
13776 (setq gnus-current-headers header
)
13777 (push (mail-header-number header
) gnus-newsgroup-limit
))
13780 (defun gnus-remove-header (number)
13781 "Remove header NUMBER from `gnus-newsgroup-headers'."
13782 (if (and gnus-newsgroup-headers
13783 (= number
(mail-header-number (car gnus-newsgroup-headers
))))
13784 (pop gnus-newsgroup-headers
)
13785 (let ((headers gnus-newsgroup-headers
))
13786 (while (and (cdr headers
)
13787 (not (= number
(mail-header-number (cadr headers
)))))
13789 (when (cdr headers
)
13790 (setcdr headers
(cddr headers
))))))
13792 (defun gnus-article-prepare (article &optional all-headers header
)
13793 "Prepare ARTICLE in article mode buffer.
13794 ARTICLE should either be an article number or a Message-ID.
13795 If ARTICLE is an id, HEADER should be the article headers.
13796 If ALL-HEADERS is non-nil, no headers are hidden."
13798 ;; Make sure we start in a summary buffer.
13799 (unless (eq major-mode
'gnus-summary-mode
)
13800 (set-buffer gnus-summary-buffer
))
13801 (setq gnus-summary-buffer
(current-buffer))
13802 ;; Make sure the connection to the server is alive.
13803 (unless (gnus-server-opened
13804 (gnus-find-method-for-group gnus-newsgroup-name
))
13805 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name
))
13806 (gnus-request-group gnus-newsgroup-name t
))
13807 (let* ((article (if header
(mail-header-number header
) article
))
13808 (summary-buffer (current-buffer))
13809 (internal-hook gnus-article-internal-prepare-hook
)
13810 (group gnus-newsgroup-name
)
13813 (gnus-article-setup-buffer)
13814 (set-buffer gnus-article-buffer
)
13815 ;; Deactivate active regions.
13816 (when (and (boundp 'transient-mark-mode
)
13817 transient-mark-mode
)
13818 (setq mark-active nil
))
13819 (if (not (setq result
(let ((buffer-read-only nil
))
13820 (gnus-request-article-this-buffer
13822 ;; There is no such article.
13824 (when (and (numberp article
)
13825 (not (memq article gnus-newsgroup-sparse
)))
13826 (setq gnus-article-current
13827 (cons gnus-newsgroup-name article
))
13828 (set-buffer gnus-summary-buffer
)
13829 (setq gnus-current-article article
)
13830 (gnus-summary-mark-article article gnus-canceled-mark
))
13831 (unless (memq article gnus-newsgroup-sparse
)
13833 1 "No such article (may have expired or been canceled)")))
13834 (if (or (eq result
'pseudo
) (eq result
'nneething
))
13837 (set-buffer summary-buffer
)
13838 (setq gnus-last-article gnus-current-article
13839 gnus-newsgroup-history
(cons gnus-current-article
13840 gnus-newsgroup-history
)
13841 gnus-current-article
0
13842 gnus-current-headers nil
13843 gnus-article-current nil
)
13844 (if (eq result
'nneething
)
13845 (gnus-configure-windows 'summary
)
13846 (gnus-configure-windows 'article
))
13847 (gnus-set-global-variables))
13848 (gnus-set-mode-line 'article
))
13849 ;; The result from the `request' was an actual article -
13850 ;; or at least some text that is now displayed in the
13852 (if (and (numberp article
)
13853 (not (eq article gnus-current-article
)))
13854 ;; Seems like a new article has been selected.
13855 ;; `gnus-current-article' must be an article number.
13857 (set-buffer summary-buffer
)
13858 (setq gnus-last-article gnus-current-article
13859 gnus-newsgroup-history
(cons gnus-current-article
13860 gnus-newsgroup-history
)
13861 gnus-current-article article
13862 gnus-current-headers
13863 (gnus-summary-article-header gnus-current-article
)
13864 gnus-article-current
13865 (cons gnus-newsgroup-name gnus-current-article
))
13866 (unless (vectorp gnus-current-headers
)
13867 (setq gnus-current-headers nil
))
13868 (gnus-summary-show-thread)
13869 (run-hooks 'gnus-mark-article-hook
)
13870 (gnus-set-mode-line 'summary
)
13871 (and (gnus-visual-p 'article-highlight
'highlight
)
13872 (run-hooks 'gnus-visual-mark-article-hook
))
13873 ;; Set the global newsgroup variables here.
13874 ;; Suggested by Jim Sisolak
13875 ;; <sisolak@trans4.neep.wisc.edu>.
13876 (gnus-set-global-variables)
13877 (setq gnus-have-all-headers
13878 (or all-headers gnus-show-all-headers
))
13879 (and gnus-use-cache
13880 (vectorp (gnus-summary-article-header article
))
13881 (gnus-cache-possibly-enter-article
13883 (gnus-summary-article-header article
)
13884 (memq article gnus-newsgroup-marked
)
13885 (memq article gnus-newsgroup-dormant
)
13886 (memq article gnus-newsgroup-unreads
)))))
13887 (when (or (numberp article
)
13889 ;; Hooks for getting information from the article.
13890 ;; This hook must be called before being narrowed.
13891 (let (buffer-read-only)
13892 (run-hooks 'internal-hook
)
13893 (run-hooks 'gnus-article-prepare-hook
)
13894 ;; Decode MIME message.
13896 (if (or (not gnus-strict-mime
)
13897 (gnus-fetch-field "Mime-Version"))
13898 (funcall gnus-show-mime-method
)
13899 (funcall gnus-decode-encoded-word-method
)))
13900 ;; Perform the article display hooks.
13901 (run-hooks 'gnus-article-display-hook
))
13903 (goto-char (point-min))
13904 (and gnus-break-pages
(gnus-narrow-to-page)))
13905 (gnus-set-mode-line 'article
)
13906 (gnus-configure-windows 'article
)
13907 (goto-char (point-min))
13910 (defun gnus-article-show-all-headers ()
13911 "Show all article headers in article mode buffer."
13913 (gnus-article-setup-buffer)
13914 (set-buffer gnus-article-buffer
)
13915 (let ((buffer-read-only nil
))
13916 (gnus-unhide-text (point-min) (point-max)))))
13918 (defun gnus-article-hide-headers-if-wanted ()
13919 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13920 Provided for backwards compatibility."
13921 (or (save-excursion (set-buffer gnus-summary-buffer
) gnus-have-all-headers
)
13922 gnus-inhibit-hiding
13923 (gnus-article-hide-headers)))
13925 (defsubst gnus-article-header-rank
()
13926 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13927 (let ((list gnus-sorted-header-list
)
13930 (when (looking-at (car list
))
13932 (setq list
(cdr list
))
13936 (defun gnus-article-hide-headers (&optional arg delete
)
13937 "Toggle whether to hide unwanted headers and possibly sort them as well.
13938 If given a negative prefix, always show; if given a positive prefix,
13940 (interactive (gnus-hidden-arg))
13941 (if (gnus-article-check-hidden-text 'headers arg
)
13942 ;; Show boring headers as well.
13943 (gnus-article-show-hidden-text 'boring-headers
)
13944 ;; This function might be inhibited.
13945 (unless gnus-inhibit-hiding
13947 (set-buffer gnus-article-buffer
)
13949 (let ((buffer-read-only nil
)
13950 (props (nconc (list 'gnus-type
'headers
)
13951 gnus-hidden-properties
))
13952 (max (1+ (length gnus-sorted-header-list
)))
13953 (ignored (when (not (stringp gnus-visible-headers
))
13954 (cond ((stringp gnus-ignored-headers
)
13955 gnus-ignored-headers
)
13956 ((listp gnus-ignored-headers
)
13957 (mapconcat 'identity gnus-ignored-headers
13960 (cond ((stringp gnus-visible-headers
)
13961 gnus-visible-headers
)
13962 ((and gnus-visible-headers
13963 (listp gnus-visible-headers
))
13964 (mapconcat 'identity gnus-visible-headers
"\\|"))))
13965 (inhibit-point-motion-hooks t
)
13967 ;; First we narrow to just the headers.
13969 (goto-char (point-min))
13970 ;; Hide any "From " lines at the beginning of (mail) articles.
13971 (while (looking-at "From ")
13975 (delete-region (point-min) (point))
13976 (gnus-hide-text (point-min) (point) props
)))
13977 ;; Then treat the rest of the header lines.
13980 (progn (search-forward "\n\n" nil t
) (forward-line -
1) (point)))
13981 ;; Then we use the two regular expressions
13982 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13983 ;; select which header lines is to remain visible in the
13985 (goto-char (point-min))
13986 (while (re-search-forward "^[^ \t]*:" nil t
)
13987 (beginning-of-line)
13988 ;; We add the headers we want to keep to a list and delete
13989 ;; them from the buffer.
13990 (gnus-put-text-property
13991 (point) (1+ (point)) 'message-rank
13992 (if (or (and visible
(looking-at visible
))
13994 (not (looking-at ignored
))))
13995 (gnus-article-header-rank)
13998 (message-sort-headers-1)
13999 (when (setq beg
(text-property-any
14000 (point-min) (point-max) 'message-rank
(+ 2 max
)))
14001 ;; We make the unwanted headers invisible.
14003 (delete-region beg
(point-max))
14004 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14005 (gnus-hide-text-type beg
(point-max) 'headers
))
14006 ;; Work around XEmacs lossage.
14007 (gnus-put-text-property (point-min) beg
'invisible nil
))))))))
14009 (defun gnus-article-hide-boring-headers (&optional arg
)
14010 "Toggle hiding of headers that aren't very interesting.
14011 If given a negative prefix, always show; if given a positive prefix,
14013 (interactive (gnus-hidden-arg))
14014 (unless (gnus-article-check-hidden-text 'boring-headers arg
)
14016 (set-buffer gnus-article-buffer
)
14018 (let ((buffer-read-only nil
)
14019 (list gnus-boring-article-headers
)
14020 (inhibit-point-motion-hooks t
)
14022 (nnheader-narrow-to-headers)
14024 (setq elem
(pop list
))
14025 (goto-char (point-min))
14027 ;; Hide empty headers.
14029 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t
)
14031 (gnus-hide-text-type
14032 (progn (beginning-of-line) (point))
14035 (if (re-search-forward "^[^ \t]" nil t
)
14036 (match-beginning 0)
14039 ;; Hide boring Newsgroups header.
14040 ((eq elem
'newsgroups
)
14041 (when (equal (message-fetch-field "newsgroups")
14042 (gnus-group-real-name gnus-newsgroup-name
))
14043 (gnus-article-hide-header "newsgroups")))
14044 ((eq elem
'followup-to
)
14045 (when (equal (message-fetch-field "followup-to")
14046 (message-fetch-field "newsgroups"))
14047 (gnus-article-hide-header "followup-to")))
14048 ((eq elem
'reply-to
)
14049 (let ((from (message-fetch-field "from"))
14050 (reply-to (message-fetch-field "reply-to")))
14054 (nth 1 (funcall gnus-extract-address-components from
))
14055 (nth 1 (funcall gnus-extract-address-components
14057 (gnus-article-hide-header "reply-to"))))
14059 (let ((date (message-fetch-field "date")))
14061 (< (gnus-days-between date
(current-time-string))
14063 (gnus-article-hide-header "date")))))))))))
14065 (defun gnus-article-hide-header (header)
14067 (goto-char (point-min))
14068 (when (re-search-forward (concat "^" header
":") nil t
)
14069 (gnus-hide-text-type
14070 (progn (beginning-of-line) (point))
14073 (if (re-search-forward "^[^ \t]" nil t
)
14074 (match-beginning 0)
14076 'boring-headers
))))
14078 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14079 (defun gnus-article-treat-overstrike ()
14080 "Translate overstrikes into bold text."
14083 (set-buffer gnus-article-buffer
)
14084 (let ((buffer-read-only nil
))
14085 (while (search-forward "\b" nil t
)
14086 (let ((next (following-char))
14087 (previous (char-after (- (point) 2))))
14089 ((eq next previous
)
14090 (gnus-put-text-property (- (point) 2) (point) 'invisible t
)
14091 (gnus-put-text-property (point) (1+ (point)) 'face
'bold
))
14093 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t
)
14094 (gnus-put-text-property
14095 (- (point) 2) (1- (point)) 'face
'underline
))
14097 (gnus-put-text-property (- (point) 2) (point) 'invisible t
)
14098 (gnus-put-text-property
14099 (point) (1+ (point)) 'face
'underline
))))))))
14101 (defun gnus-article-word-wrap ()
14102 "Format too long lines."
14105 (set-buffer gnus-article-buffer
)
14106 (let ((buffer-read-only nil
))
14108 (goto-char (point-min))
14109 (search-forward "\n\n" nil t
)
14111 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14112 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14113 (adaptive-fill-mode t
))
14114 (while (not (eobp))
14115 (and (>= (current-column) (min fill-column
(window-width)))
14116 (/= (preceding-char) ?
:)
14117 (fill-paragraph nil
))
14118 (end-of-line 2))))))
14120 (defun gnus-article-remove-cr ()
14121 "Remove carriage returns from an article."
14124 (set-buffer gnus-article-buffer
)
14125 (let ((buffer-read-only nil
))
14126 (goto-char (point-min))
14127 (while (search-forward "\r" nil t
)
14128 (replace-match "" t t
)))))
14130 (defun gnus-article-remove-trailing-blank-lines ()
14131 "Remove all trailing blank lines from the article."
14134 (set-buffer gnus-article-buffer
)
14135 (let ((buffer-read-only nil
))
14136 (goto-char (point-max))
14140 (while (looking-at "^[ \t]*$")
14145 (defun gnus-article-display-x-face (&optional force
)
14146 "Look for an X-Face header and display it if present."
14147 (interactive (list 'force
))
14149 (set-buffer gnus-article-buffer
)
14150 ;; Delete the old process, if any.
14151 (when (process-status "gnus-x-face")
14152 (delete-process "gnus-x-face"))
14153 (let ((inhibit-point-motion-hooks t
)
14154 (case-fold-search nil
)
14157 (nnheader-narrow-to-headers)
14158 (setq from
(message-fetch-field "from"))
14159 (goto-char (point-min))
14160 (when (and gnus-article-x-face-command
14162 ;; Check whether this face is censored.
14163 (not gnus-article-x-face-too-ugly
)
14164 (and gnus-article-x-face-too-ugly from
14165 (not (string-match gnus-article-x-face-too-ugly
14167 ;; Has to be present.
14168 (re-search-forward "^X-Face: " nil t
))
14169 ;; We now have the area of the buffer where the X-Face is stored.
14170 (let ((beg (point))
14171 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t
))))
14172 ;; We display the face.
14173 (if (symbolp gnus-article-x-face-command
)
14174 ;; The command is a lisp function, so we call it.
14175 (if (gnus-functionp gnus-article-x-face-command
)
14176 (funcall gnus-article-x-face-command beg end
)
14177 (error "%s is not a function" gnus-article-x-face-command
))
14178 ;; The command is a string, so we interpret the command
14179 ;; as a, well, command, and fork it off.
14180 (let ((process-connection-type nil
))
14181 (process-kill-without-query
14183 "gnus-x-face" nil shell-file-name shell-command-switch
14184 gnus-article-x-face-command
))
14185 (process-send-region "gnus-x-face" beg end
)
14186 (process-send-eof "gnus-x-face")))))))))
14188 (defalias 'gnus-headers-decode-quoted-printable
'gnus-decode-rfc1522
)
14189 (defun gnus-decode-rfc1522 ()
14190 "Hack to remove QP encoding from headers."
14191 (let ((case-fold-search t
)
14192 (inhibit-point-motion-hooks t
)
14193 (buffer-read-only nil
)
14197 (goto-char (point-min))
14198 (or (search-forward "\n\n" nil t
) (point-max)))
14200 (while (re-search-forward
14201 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t
)
14202 (setq string
(match-string 1))
14203 (narrow-to-region (match-beginning 0) (match-end 0))
14204 (delete-region (point-min) (point-max))
14206 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14207 (subst-char-in-region (point-min) (point-max) ?_ ?
)
14209 (goto-char (point-min))))))
14211 (defun gnus-article-de-quoted-unreadable (&optional force
)
14212 "Do a naive translation of a quoted-printable-encoded article.
14213 This is in no way, shape or form meant as a replacement for real MIME
14214 processing, but is simply a stop-gap measure until MIME support is
14216 If FORCE, decode the article whether it is marked as quoted-printable
14218 (interactive (list 'force
))
14220 (set-buffer gnus-article-buffer
)
14221 (let ((case-fold-search t
)
14222 (buffer-read-only nil
)
14223 (type (gnus-fetch-field "content-transfer-encoding")))
14224 (gnus-decode-rfc1522)
14226 (and type
(string-match "quoted-printable" (downcase type
))))
14227 (goto-char (point-min))
14228 (search-forward "\n\n" nil
'move
)
14229 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14231 (defun gnus-mime-decode-quoted-printable (from to
)
14232 "Decode Quoted-Printable in the region between FROM and TO."
14235 (while (search-forward "=" to t
)
14236 (cond ((eq (following-char) ?
\n)
14239 ((looking-at "[0-9A-F][0-9A-F]")
14240 (subst-char-in-region
14241 (1- (point)) (point) ?
=
14242 (hexl-hex-string-to-integer
14243 (buffer-substring (point) (+ 2 (point)))))
14247 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14249 (defun gnus-article-hide-pgp (&optional arg
)
14250 "Toggle hiding of any PGP headers and signatures in the current article.
14251 If given a negative prefix, always show; if given a positive prefix,
14253 (interactive (gnus-hidden-arg))
14254 (unless (gnus-article-check-hidden-text 'pgp arg
)
14256 (set-buffer gnus-article-buffer
)
14257 (let ((props (nconc (list 'gnus-type
'pgp
) gnus-hidden-properties
))
14258 buffer-read-only beg end
)
14260 (goto-char (point-min))
14261 ;; Hide the "header".
14262 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t
)
14263 (gnus-hide-text (match-beginning 0) (match-end 0) props
))
14265 ;; Hide the actual signature.
14266 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t
)
14267 (setq end
(1+ (match-beginning 0)))
14270 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t
)
14272 ;; Perhaps we shouldn't hide to the end of the buffer
14273 ;; if there is no end to the signature?
14276 ;; Hide "- " PGP quotation markers.
14277 (when (and beg end
)
14278 (narrow-to-region beg end
)
14279 (goto-char (point-min))
14280 (while (re-search-forward "^- " nil t
)
14281 (gnus-hide-text (match-beginning 0) (match-end 0) props
))
14284 (defun gnus-article-hide-signature (&optional arg
)
14285 "Hide the signature in the current article.
14286 If given a negative prefix, always show; if given a positive prefix,
14288 (interactive (gnus-hidden-arg))
14289 (unless (gnus-article-check-hidden-text 'signature arg
)
14291 (set-buffer gnus-article-buffer
)
14293 (let ((buffer-read-only nil
))
14294 (when (gnus-narrow-to-signature)
14295 (gnus-hide-text-type (point-min) (point-max) 'signature
)))))))
14297 (defun gnus-article-strip-leading-blank-lines ()
14298 "Remove all blank lines from the beginning of the article."
14301 (set-buffer gnus-article-buffer
)
14302 (let (buffer-read-only)
14303 (goto-char (point-min))
14304 (when (search-forward "\n\n" nil t
)
14305 (while (looking-at "[ \t]$")
14306 (gnus-delete-line))))))
14308 (defvar mime
::preview
/content-list
)
14309 (defvar mime
::preview-content-info
/point-min
)
14310 (defun gnus-narrow-to-signature ()
14311 "Narrow to the signature."
14313 (if (and (boundp 'mime
::preview
/content-list
)
14314 mime
::preview
/content-list
)
14315 (let ((pcinfo (car (last mime
::preview
/content-list
))))
14318 (funcall (intern "mime::preview-content-info/point-min") pcinfo
)
14321 (goto-char (point-max))
14322 (when (re-search-backward gnus-signature-separator nil t
)
14324 (when (or (null gnus-signature-limit
)
14325 (and (numberp gnus-signature-limit
)
14326 (< (- (point-max) (point)) gnus-signature-limit
))
14327 (and (gnus-functionp gnus-signature-limit
)
14328 (funcall gnus-signature-limit
))
14329 (and (stringp gnus-signature-limit
)
14330 (not (re-search-forward gnus-signature-limit nil t
))))
14331 (narrow-to-region (point) (point-max))
14334 (defun gnus-hidden-arg ()
14335 "Return the current prefix arg as a number, or 0 if no prefix."
14336 (list (if current-prefix-arg
14337 (prefix-numeric-value current-prefix-arg
)
14340 (defun gnus-article-check-hidden-text (type arg
)
14341 "Return nil if hiding is necessary.
14342 Arg can be nil or a number. Nil and positive means hide, negative
14343 means show, 0 means toggle."
14345 (set-buffer gnus-article-buffer
)
14346 (let ((hide (gnus-article-hidden-text-p type
)))
14352 (gnus-article-show-hidden-text type
))
14354 (if (eq hide
'hidden
)
14355 (gnus-article-show-hidden-text type
)
14358 (defun gnus-article-hidden-text-p (type)
14359 "Say whether the current buffer contains hidden text of type TYPE."
14360 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type
)))
14362 (if (get-text-property pos
'invisible
)
14366 (defun gnus-article-hide (&optional arg force
)
14367 "Hide all the gruft in the current article.
14368 This means that PGP stuff, signatures, cited text and (some)
14369 headers will be hidden.
14370 If given a prefix, show the hidden text instead."
14371 (interactive (list current-prefix-arg
'force
))
14372 (gnus-article-hide-headers arg
)
14373 (gnus-article-hide-pgp arg
)
14374 (gnus-article-hide-citation-maybe arg force
)
14375 (gnus-article-hide-signature arg
))
14377 (defun gnus-article-show-hidden-text (type &optional hide
)
14378 "Show all hidden text of type TYPE.
14379 If HIDE, hide the text instead."
14381 (set-buffer gnus-article-buffer
)
14382 (let ((buffer-read-only nil
)
14383 (inhibit-point-motion-hooks t
)
14385 (while (gnus-goto-char (text-property-any
14386 beg
(point-max) 'gnus-type type
))
14390 (gnus-hide-text beg
(point) gnus-hidden-properties
)
14391 (gnus-unhide-text beg
(point)))
14392 (setq beg
(point)))
14395 (defvar gnus-article-time-units
14396 `((year .
,(* 365.25 24 60 60))
14397 (week .
,(* 7 24 60 60))
14398 (day .
,(* 24 60 60))
14399 (hour .
,(* 60 60))
14402 "Mapping from time units to seconds.")
14404 (defun gnus-article-date-ut (&optional type highlight
)
14405 "Convert DATE date to universal time in the current article.
14406 If TYPE is `local', convert to local time; if it is `lapsed', output
14407 how much time has lapsed since DATE."
14408 (interactive (list 'ut t
))
14409 (let* ((header (or gnus-current-headers
14410 (gnus-summary-article-header) ""))
14411 (date (and (vectorp header
) (mail-header-date header
)))
14412 (date-regexp "^Date: \\|^X-Sent: ")
14413 (now (current-time))
14414 (inhibit-point-motion-hooks t
)
14416 (when (and date
(not (string= date
"")))
14418 (set-buffer gnus-article-buffer
)
14420 (nnheader-narrow-to-headers)
14421 (let ((buffer-read-only nil
))
14422 ;; Delete any old Date headers.
14423 (if (re-search-forward date-regexp nil t
)
14425 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
14426 eface
(get-text-property (1- (gnus-point-at-eol))
14428 (message-remove-header date-regexp t
)
14429 (beginning-of-line))
14430 (goto-char (point-max)))
14431 (insert (gnus-make-date-line date type
))
14432 ;; Do highlighting.
14434 (when (and (gnus-visual-p 'article-highlight
'highlight
)
14435 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14436 (gnus-put-text-property (match-beginning 1) (match-end 1)
14438 (gnus-put-text-property (match-beginning 2) (match-end 2)
14439 'face eface
))))))))
14441 (defun gnus-make-date-line (date type
)
14442 "Return a DATE line of TYPE."
14444 ;; Convert to the local timezone. We have to slap a
14445 ;; `condition-case' round the calls to the timezone
14446 ;; functions since they aren't particularly resistant to
14449 (concat "Date: " (condition-case ()
14450 (timezone-make-date-arpa-standard date
)
14453 ;; Convert to Universal Time.
14457 (timezone-make-date-arpa-standard date nil
"UT")
14460 ;; Get the original date from the article.
14461 ((eq type
'original
)
14462 (concat "Date: " date
"\n"))
14463 ;; Do an X-Sent lapsed format.
14465 ;; If the date is seriously mangled, the timezone
14466 ;; functions are liable to bug out, so we condition-case
14467 ;; the entire thing.
14468 (let* ((now (current-time))
14473 (timezone-make-date-arpa-standard
14474 (current-time-string now
)
14475 (current-time-zone now
) "UT"))
14477 (timezone-make-date-arpa-standard
14480 (real-sec (+ (* (float (car real-time
)) 65536)
14482 (sec (abs real-sec
))
14485 ((equal real-time
'(0 0))
14486 "X-Sent: Unknown\n")
14492 ;; This is a bit convoluted, but basically we go
14493 ;; through the time units for years, weeks, etc,
14494 ;; and divide things to see whether that results
14495 ;; in positive answers.
14498 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
14499 ;; The (remaining) seconds are too few to
14500 ;; be divided into this time unit.
14502 ;; It's big enough, so we output it.
14503 (setq sec
(- sec
(* num
(cdr unit
))))
14505 (concat (if prev
", " "") (int-to-string
14507 " " (symbol-name (car unit
))
14508 (if (> num
1) "s" ""))
14510 gnus-article-time-units
"")
14511 ;; If dates are odd, then it might appear like the
14512 ;; article was sent in the future.
14515 " in the future\n"))))))
14517 (error "Unknown conversion type: %s" type
))))
14519 (defun gnus-article-date-local (&optional highlight
)
14520 "Convert the current article date to the local timezone."
14521 (interactive (list t
))
14522 (gnus-article-date-ut 'local highlight
))
14524 (defun gnus-article-date-original (&optional highlight
)
14525 "Convert the current article date to what it was originally.
14526 This is only useful if you have used some other date conversion
14527 function and want to see what the date was before converting."
14528 (interactive (list t
))
14529 (gnus-article-date-ut 'original highlight
))
14531 (defun gnus-article-date-lapsed (&optional highlight
)
14532 "Convert the current article date to time lapsed since it was sent."
14533 (interactive (list t
))
14534 (gnus-article-date-ut 'lapsed highlight
))
14536 (defun gnus-article-maybe-highlight ()
14537 "Do some article highlighting if `gnus-visual' is non-nil."
14538 (if (gnus-visual-p 'article-highlight
'highlight
)
14539 (gnus-article-highlight-some)))
14541 ;;; Article savers.
14543 (defun gnus-output-to-rmail (file-name)
14544 "Append the current article to an Rmail file named FILE-NAME."
14546 ;; Most of these codes are borrowed from rmailout.el.
14547 (setq file-name
(expand-file-name file-name
))
14548 (setq rmail-default-rmail-file file-name
)
14549 (let ((artbuf (current-buffer))
14550 (tmpbuf (get-buffer-create " *Gnus-output*")))
14552 (or (get-file-buffer file-name
)
14553 (file-exists-p file-name
)
14554 (if (gnus-yes-or-no-p
14555 (concat "\"" file-name
"\" does not exist, create it? "))
14556 (let ((file-buffer (create-file-buffer file-name
)))
14558 (set-buffer file-buffer
)
14559 (rmail-insert-rmail-file-header)
14560 (let ((require-final-newline nil
))
14561 (write-region (point-min) (point-max) file-name t
1)))
14562 (kill-buffer file-buffer
))
14563 (error "Output file does not exist")))
14564 (set-buffer tmpbuf
)
14565 (buffer-disable-undo (current-buffer))
14567 (insert-buffer-substring artbuf
)
14568 (gnus-convert-article-to-rmail)
14569 ;; Decide whether to append to a file or to an Emacs buffer.
14570 (let ((outbuf (get-file-buffer file-name
)))
14572 (append-to-file (point-min) (point-max) file-name
)
14573 ;; File has been visited, in buffer OUTBUF.
14574 (set-buffer outbuf
)
14575 (let ((buffer-read-only nil
)
14576 (msg (and (boundp 'rmail-current-message
)
14577 (symbol-value 'rmail-current-message
))))
14578 ;; If MSG is non-nil, buffer is in RMAIL mode.
14581 (narrow-to-region (point-max) (point-max))))
14582 (insert-buffer-substring tmpbuf
)
14585 (goto-char (point-min))
14587 (search-backward "\^_")
14588 (narrow-to-region (point) (point-max))
14589 (goto-char (1+ (point-min)))
14590 (rmail-count-new-messages t
)
14591 (rmail-show-message msg
)))))))
14592 (kill-buffer tmpbuf
)))
14594 (defun gnus-output-to-file (file-name)
14595 "Append the current article to a file named FILE-NAME."
14596 (let ((artbuf (current-buffer)))
14597 (nnheader-temp-write nil
14598 (insert-buffer-substring artbuf
)
14599 ;; Append newline at end of the buffer as separator, and then
14600 ;; save it to file.
14601 (goto-char (point-max))
14603 (append-to-file (point-min) (point-max) file-name
))))
14605 (defun gnus-convert-article-to-rmail ()
14606 "Convert article in current buffer to Rmail message format."
14607 (let ((buffer-read-only nil
))
14608 ;; Convert article directly into Babyl format.
14609 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14610 (goto-char (point-min))
14611 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14612 (while (search-forward "\n\^_" nil t
) ;single char
14613 (replace-match "\n^_" t t
)) ;2 chars: "^" and "_"
14614 (goto-char (point-max))
14617 (defun gnus-narrow-to-page (&optional arg
)
14618 "Narrow the article buffer to a page.
14619 If given a numerical ARG, move forward ARG pages."
14621 (setq arg
(if arg
(prefix-numeric-value arg
) 0))
14623 (set-buffer gnus-article-buffer
)
14624 (goto-char (point-min))
14626 (when (gnus-visual-p 'page-marker
)
14627 (let ((buffer-read-only nil
))
14628 (gnus-remove-text-with-property 'gnus-prev
)
14629 (gnus-remove-text-with-property 'gnus-next
)))
14632 (re-search-backward page-delimiter nil
'move
(1+ (abs arg
))))
14634 (re-search-forward page-delimiter nil
'move arg
)))
14635 (goto-char (match-end 0)))
14638 (if (re-search-forward page-delimiter nil
'move
)
14639 (match-beginning 0)
14641 (when (and (gnus-visual-p 'page-marker
)
14642 (not (= (point-min) 1)))
14644 (goto-char (point-min))
14645 (gnus-insert-prev-page-button)))
14646 (when (and (gnus-visual-p 'page-marker
)
14647 (not (= (1- (point-max)) (buffer-size))))
14649 (goto-char (point-max))
14650 (gnus-insert-next-page-button)))))
14652 ;; Article mode commands
14654 (defun gnus-article-goto-next-page ()
14655 "Show the next page of the article."
14657 (when (gnus-article-next-page)
14658 (gnus-article-read-summary-keys nil
(gnus-character-to-event ?n
))))
14660 (defun gnus-article-goto-prev-page ()
14661 "Show the next page of the article."
14663 (if (bobp) (gnus-article-read-summary-keys nil
(gnus-character-to-event ?n
))
14664 (gnus-article-prev-page nil
)))
14666 (defun gnus-article-next-page (&optional lines
)
14667 "Show the next page of the current article.
14668 If end of article, return non-nil. Otherwise return nil.
14669 Argument LINES specifies lines to be scrolled up."
14671 (move-to-window-line -
1)
14672 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14673 (if (save-excursion
14675 (and (pos-visible-in-window-p) ;Not continuation line.
14677 ;; Nothing in this page.
14678 (if (or (not gnus-break-pages
)
14681 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14683 (gnus-narrow-to-page 1) ;Go to next page.
14685 ;; More in this page.
14689 ;; Long lines may cause an end-of-buffer error.
14690 (goto-char (point-max))))
14691 (move-to-window-line 0)
14694 (defun gnus-article-prev-page (&optional lines
)
14695 "Show previous page of current article.
14696 Argument LINES specifies lines to be scrolled down."
14698 (move-to-window-line 0)
14699 (if (and gnus-break-pages
14701 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14703 (gnus-narrow-to-page -
1) ;Go to previous page.
14704 (goto-char (point-max))
14708 (scroll-down lines
)
14710 (move-to-window-line 0))))
14712 (defun gnus-article-refer-article ()
14713 "Read article specified by message-id around point."
14715 (let ((point (point)))
14716 (search-forward ">" nil t
) ;Move point to end of "<....>".
14717 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t
)
14718 (let ((message-id (match-string 1)))
14720 (set-buffer gnus-summary-buffer
)
14721 (gnus-summary-refer-article message-id
))
14722 (goto-char (point))
14723 (error "No references around point"))))
14725 (defun gnus-article-show-summary ()
14726 "Reconfigure windows to show summary buffer."
14728 (gnus-configure-windows 'article
)
14729 (gnus-summary-goto-subject gnus-current-article
))
14731 (defun gnus-article-describe-briefly ()
14732 "Describe article mode commands briefly."
14735 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14737 (defun gnus-article-summary-command ()
14738 "Execute the last keystroke in the summary buffer."
14740 (let ((obuf (current-buffer))
14741 (owin (current-window-configuration))
14743 (switch-to-buffer gnus-summary-buffer
'norecord
)
14744 (setq func
(lookup-key (current-local-map) (this-command-keys)))
14745 (call-interactively func
)
14747 (set-window-configuration owin
)
14748 (set-window-point (get-buffer-window (current-buffer)) (point))))
14750 (defun gnus-article-summary-command-nosave ()
14751 "Execute the last keystroke in the summary buffer."
14754 (pop-to-buffer gnus-summary-buffer
'norecord
)
14755 (setq func
(lookup-key (current-local-map) (this-command-keys)))
14756 (call-interactively func
)))
14758 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window
)
14759 "Read a summary buffer key sequence and execute it from the article buffer."
14762 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14763 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14764 "=" "^" "\M-^" "|"))
14767 (set-buffer gnus-summary-buffer
)
14768 (push (or key last-command-event
) unread-command-events
)
14769 (setq keys
(read-key-sequence nil
)))
14772 (if (member keys nosaves
)
14774 (pop-to-buffer gnus-summary-buffer
'norecord
)
14775 (if (setq func
(lookup-key (current-local-map) keys
))
14776 (call-interactively func
)
14778 (let ((obuf (current-buffer))
14779 (owin (current-window-configuration))
14782 (if not-restore-window
14783 (pop-to-buffer gnus-summary-buffer
'norecord
)
14784 (switch-to-buffer gnus-summary-buffer
'norecord
))
14785 (setq in-buffer
(current-buffer))
14786 (if (setq func
(lookup-key (current-local-map) keys
))
14787 (call-interactively func
)
14789 (when (eq in-buffer
(current-buffer))
14791 (unless not-restore-window
14792 (set-window-configuration owin
))
14793 (set-window-point (get-buffer-window (current-buffer)) opoint
))))))
14797 ;;; Kill file handling.
14801 (defalias 'gnus-batch-kill
'gnus-batch-score
)
14803 (defun gnus-batch-score ()
14804 "Run batched scoring.
14805 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14806 Newsgroups is a list of strings in Bnews format. If you want to score
14807 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14808 score the alt hierarchy, you'd say \"!alt.all\"."
14811 (gnus-newsrc-parse-options
14812 (apply (function concat
)
14813 (mapcar (lambda (g) (concat g
" "))
14814 command-line-args-left
))))
14815 (gnus-expert-user t
)
14816 (nnmail-spool-file nil
)
14817 (gnus-use-dribble-file nil
)
14818 (yes (car yes-and-no
))
14819 (no (cdr yes-and-no
))
14821 ;; Disable verbose message.
14822 gnus-novice-user gnus-large-newsgroup
)
14823 ;; Eat all arguments.
14824 (setq command-line-args-left nil
)
14827 ;; Apply kills to specified newsgroups in command line arguments.
14828 (setq newsrc
(cdr gnus-newsrc-alist
))
14830 (setq group
(caar newsrc
))
14831 (setq entry
(gnus-gethash group gnus-newsrc-hashtb
))
14832 (if (and (<= (nth 1 (car newsrc
)) gnus-level-subscribed
)
14834 (or (eq (car entry
) t
)
14835 (not (zerop (car entry
)))))
14836 (if yes
(string-match yes group
) t
)
14837 (or (null no
) (not (string-match no group
))))
14839 (gnus-summary-read-group group nil t nil t
)
14840 (and (eq (current-buffer) (get-buffer gnus-summary-buffer
))
14841 (gnus-summary-exit))))
14842 (setq newsrc
(cdr newsrc
)))
14844 (switch-to-buffer gnus-group-buffer
)
14845 (gnus-group-save-newsrc)))
14847 (defun gnus-apply-kill-file ()
14848 "Apply a kill file to the current newsgroup.
14849 Returns the number of articles marked as read."
14850 (if (or (file-exists-p (gnus-newsgroup-kill-file nil
))
14851 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
14852 (gnus-apply-kill-file-internal)
14855 (defun gnus-kill-save-kill-buffer ()
14856 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name
)))
14857 (when (get-file-buffer file
)
14859 (set-buffer (get-file-buffer file
))
14860 (and (buffer-modified-p) (save-buffer))
14861 (kill-buffer (current-buffer))))))
14863 (defvar gnus-kill-file-name
"KILL"
14864 "Suffix of the kill files.")
14866 (defun gnus-newsgroup-kill-file (newsgroup)
14867 "Return the name of a kill file name for NEWSGROUP.
14868 If NEWSGROUP is nil, return the global kill file name instead."
14870 ;; The global KILL file is placed at top of the directory.
14871 ((or (null newsgroup
)
14872 (string-equal newsgroup
""))
14873 (expand-file-name gnus-kill-file-name
14874 gnus-kill-files-directory
))
14875 ;; Append ".KILL" to newsgroup name.
14876 ((gnus-use-long-file-name 'not-kill
)
14877 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup
)
14878 "." gnus-kill-file-name
)
14879 gnus-kill-files-directory
))
14880 ;; Place "KILL" under the hierarchical directory.
14882 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup
)
14883 "/" gnus-kill-file-name
)
14884 gnus-kill-files-directory
))))
14891 (defvar gnus-dribble-ignore nil
)
14892 (defvar gnus-dribble-eval-file nil
)
14894 (defun gnus-dribble-file-name ()
14895 "Return the dribble file for the current .newsrc."
14897 (if gnus-dribble-directory
14898 (concat (file-name-as-directory gnus-dribble-directory
)
14899 (file-name-nondirectory gnus-current-startup-file
))
14900 gnus-current-startup-file
)
14903 (defun gnus-dribble-enter (string)
14904 "Enter STRING into the dribble buffer."
14905 (if (and (not gnus-dribble-ignore
)
14906 gnus-dribble-buffer
14907 (buffer-name gnus-dribble-buffer
))
14908 (let ((obuf (current-buffer)))
14909 (set-buffer gnus-dribble-buffer
)
14910 (insert string
"\n")
14911 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14912 (set-buffer obuf
))))
14914 (defun gnus-dribble-read-file ()
14915 "Read the dribble file from disk."
14916 (let ((dribble-file (gnus-dribble-file-name)))
14918 (set-buffer (setq gnus-dribble-buffer
14920 (file-name-nondirectory dribble-file
))))
14921 (gnus-add-current-to-buffer-list)
14923 (setq buffer-file-name dribble-file
)
14925 (buffer-disable-undo (current-buffer))
14926 (bury-buffer (current-buffer))
14927 (set-buffer-modified-p nil
)
14928 (let ((auto (make-auto-save-file-name))
14929 (gnus-dribble-ignore t
)
14931 (when (or (file-exists-p auto
) (file-exists-p dribble-file
))
14932 ;; Load whichever file is newest -- the auto save file
14933 ;; or the "real" file.
14934 (if (file-newer-than-file-p auto dribble-file
)
14935 (insert-file-contents auto
)
14936 (insert-file-contents dribble-file
))
14937 (unless (zerop (buffer-size))
14938 (set-buffer-modified-p t
))
14939 ;; Set the file modes to reflect the .newsrc file modes.
14941 (when (and (file-exists-p gnus-current-startup-file
)
14942 (setq modes
(file-modes gnus-current-startup-file
)))
14943 (set-file-modes dribble-file modes
))
14944 ;; Possibly eval the file later.
14945 (when (gnus-y-or-n-p
14946 "Auto-save file exists. Do you want to read it? ")
14947 (setq gnus-dribble-eval-file t
)))))))
14949 (defun gnus-dribble-eval-file ()
14950 (when gnus-dribble-eval-file
14951 (setq gnus-dribble-eval-file nil
)
14953 (let ((gnus-dribble-ignore t
))
14954 (set-buffer gnus-dribble-buffer
)
14955 (eval-buffer (current-buffer))))))
14957 (defun gnus-dribble-delete-file ()
14958 (when (file-exists-p (gnus-dribble-file-name))
14959 (delete-file (gnus-dribble-file-name)))
14960 (when gnus-dribble-buffer
14962 (set-buffer gnus-dribble-buffer
)
14963 (let ((auto (make-auto-save-file-name)))
14964 (if (file-exists-p auto
)
14965 (delete-file auto
))
14967 (set-buffer-modified-p nil
)))))
14969 (defun gnus-dribble-save ()
14970 (when (and gnus-dribble-buffer
14971 (buffer-name gnus-dribble-buffer
))
14973 (set-buffer gnus-dribble-buffer
)
14976 (defun gnus-dribble-clear ()
14977 (when (gnus-buffer-exists-p gnus-dribble-buffer
)
14979 (set-buffer gnus-dribble-buffer
)
14981 (set-buffer-modified-p nil
)
14982 (setq buffer-saved-size
(buffer-size)))))
14986 ;;; Server Communication
14989 (defun gnus-start-news-server (&optional confirm
)
14990 "Open a method for getting news.
14991 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14993 (if gnus-current-select-method
14994 ;; Stream is already opened.
14996 ;; Open NNTP server.
14997 (if (null gnus-nntp-service
) (setq gnus-nntp-server nil
))
15000 ;; Read server name with completion.
15001 (setq gnus-nntp-server
15002 (completing-read "NNTP server: "
15003 (mapcar (lambda (server) (list server
))
15004 (cons (list gnus-nntp-server
)
15005 gnus-secondary-servers
))
15006 nil nil gnus-nntp-server
))))
15008 (if (and gnus-nntp-server
15009 (stringp gnus-nntp-server
)
15010 (not (string= gnus-nntp-server
"")))
15011 (setq gnus-select-method
15012 (cond ((or (string= gnus-nntp-server
"")
15013 (string= gnus-nntp-server
"::"))
15014 (list 'nnspool
(system-name)))
15015 ((string-match "^:" gnus-nntp-server
)
15016 (list 'nnmh gnus-nntp-server
15017 (list 'nnmh-directory
15018 (file-name-as-directory
15020 (concat "~/" (substring
15021 gnus-nntp-server
1)))))
15022 (list 'nnmh-get-new-mail nil
)))
15024 (list 'nntp gnus-nntp-server
)))))
15026 (setq how
(car gnus-select-method
))
15027 (cond ((eq how
'nnspool
)
15029 (gnus-message 5 "Looking up local news spool..."))
15032 (gnus-message 5 "Looking up mh spool..."))
15035 (setq gnus-current-select-method gnus-select-method
)
15036 (run-hooks 'gnus-open-server-hook
)
15038 ;; gnus-open-server-hook might have opened it
15039 (gnus-server-opened gnus-select-method
)
15040 (gnus-open-server gnus-select-method
)
15043 "%s (%s) open error: '%s'. Continue? "
15044 (car gnus-select-method
) (cadr gnus-select-method
)
15045 (gnus-status-message gnus-select-method
)))
15046 (gnus-error 1 "Couldn't open server on %s"
15047 (nth 1 gnus-select-method
))))))
15049 (defun gnus-check-group (group)
15050 "Try to make sure that the server where GROUP exists is alive."
15051 (let ((method (gnus-find-method-for-group group
)))
15052 (or (gnus-server-opened method
)
15053 (gnus-open-server method
))))
15055 (defun gnus-check-server (&optional method silent
)
15056 "Check whether the connection to METHOD is down.
15057 If METHOD is nil, use `gnus-select-method'.
15058 If it is down, start it up (again)."
15059 (let ((method (or method gnus-select-method
)))
15060 ;; Transform virtual server names into select methods.
15061 (when (stringp method
)
15062 (setq method
(gnus-server-to-method method
)))
15063 (if (gnus-server-opened method
)
15064 ;; The stream is already opened.
15066 ;; Open the server.
15068 (gnus-message 5 "Opening %s server%s..." (car method
)
15069 (if (equal (nth 1 method
) "") ""
15070 (format " on %s" (nth 1 method
)))))
15071 (run-hooks 'gnus-open-server-hook
)
15073 (gnus-open-server method
)
15077 (defun gnus-get-function (method function
&optional noerror
)
15078 "Return a function symbol based on METHOD and FUNCTION."
15079 ;; Translate server names into methods.
15081 (error "Attempted use of a nil select method"))
15082 (when (stringp method
)
15083 (setq method
(gnus-server-to-method method
)))
15084 (let ((func (intern (format "%s-%s" (car method
) function
))))
15085 ;; If the functions isn't bound, we require the backend in
15087 (unless (fboundp func
)
15088 (require (car method
))
15089 (when (and (not (fboundp func
))
15091 ;; This backend doesn't implement this function.
15092 (error "No such function: %s" func
)))
15097 ;;; Interface functions to the backends.
15100 (defun gnus-open-server (method)
15101 "Open a connection to METHOD."
15102 (when (stringp method
)
15103 (setq method
(gnus-server-to-method method
)))
15104 (let ((elem (assoc method gnus-opened-servers
)))
15105 ;; If this method was previously denied, we just return nil.
15106 (if (eq (nth 1 elem
) 'denied
)
15108 (gnus-message 1 "Denied server")
15110 ;; Open the server.
15112 (funcall (gnus-get-function method
'open-server
)
15113 (nth 1 method
) (nthcdr 2 method
))))
15114 ;; If this hasn't been opened before, we add it to the list.
15116 (setq elem
(list method nil
)
15117 gnus-opened-servers
(cons elem gnus-opened-servers
)))
15118 ;; Set the status of this server.
15119 (setcar (cdr elem
) (if result
'ok
'denied
))
15120 ;; Return the result from the "open" call.
15123 (defun gnus-close-server (method)
15124 "Close the connection to METHOD."
15125 (when (stringp method
)
15126 (setq method
(gnus-server-to-method method
)))
15127 (funcall (gnus-get-function method
'close-server
) (nth 1 method
)))
15129 (defun gnus-request-list (method)
15130 "Request the active file from METHOD."
15131 (when (stringp method
)
15132 (setq method
(gnus-server-to-method method
)))
15133 (funcall (gnus-get-function method
'request-list
) (nth 1 method
)))
15135 (defun gnus-request-list-newsgroups (method)
15136 "Request the newsgroups file from METHOD."
15137 (when (stringp method
)
15138 (setq method
(gnus-server-to-method method
)))
15139 (funcall (gnus-get-function method
'request-list-newsgroups
) (nth 1 method
)))
15141 (defun gnus-request-newgroups (date method
)
15142 "Request all new groups since DATE from METHOD."
15143 (when (stringp method
)
15144 (setq method
(gnus-server-to-method method
)))
15145 (funcall (gnus-get-function method
'request-newgroups
)
15146 date
(nth 1 method
)))
15148 (defun gnus-server-opened (method)
15149 "Check whether a connection to METHOD has been opened."
15150 (when (stringp method
)
15151 (setq method
(gnus-server-to-method method
)))
15152 (funcall (gnus-get-function method
'server-opened
) (nth 1 method
)))
15154 (defun gnus-status-message (method)
15155 "Return the status message from METHOD.
15156 If METHOD is a string, it is interpreted as a group name. The method
15157 this group uses will be queried."
15158 (let ((method (if (stringp method
) (gnus-find-method-for-group method
)
15160 (funcall (gnus-get-function method
'status-message
) (nth 1 method
))))
15162 (defun gnus-request-group (group &optional dont-check method
)
15163 "Request GROUP. If DONT-CHECK, no information is required."
15164 (let ((method (or method
(gnus-find-method-for-group group
))))
15165 (when (stringp method
)
15166 (setq method
(gnus-server-to-method method
)))
15167 (funcall (gnus-get-function method
'request-group
)
15168 (gnus-group-real-name group
) (nth 1 method
) dont-check
)))
15170 (defun gnus-request-asynchronous (group &optional articles
)
15171 "Request that GROUP behave asynchronously.
15172 ARTICLES is the `data' of the group."
15173 (let ((method (gnus-find-method-for-group group
)))
15174 (funcall (gnus-get-function method
'request-asynchronous
)
15175 (gnus-group-real-name group
) (nth 1 method
) articles
)))
15177 (defun gnus-list-active-group (group)
15178 "Request active information on GROUP."
15179 (let ((method (gnus-find-method-for-group group
))
15180 (func 'list-active-group
))
15181 (when (gnus-check-backend-function func group
)
15182 (funcall (gnus-get-function method func
)
15183 (gnus-group-real-name group
) (nth 1 method
)))))
15185 (defun gnus-request-group-description (group)
15186 "Request a description of GROUP."
15187 (let ((method (gnus-find-method-for-group group
))
15188 (func 'request-group-description
))
15189 (when (gnus-check-backend-function func group
)
15190 (funcall (gnus-get-function method func
)
15191 (gnus-group-real-name group
) (nth 1 method
)))))
15193 (defun gnus-close-group (group)
15194 "Request the GROUP be closed."
15195 (let ((method (gnus-find-method-for-group group
)))
15196 (funcall (gnus-get-function method
'close-group
)
15197 (gnus-group-real-name group
) (nth 1 method
))))
15199 (defun gnus-retrieve-headers (articles group
&optional fetch-old
)
15200 "Request headers for ARTICLES in GROUP.
15201 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15202 (let ((method (gnus-find-method-for-group group
)))
15203 (if (and gnus-use-cache
(numberp (car articles
)))
15204 (gnus-cache-retrieve-headers articles group fetch-old
)
15205 (funcall (gnus-get-function method
'retrieve-headers
)
15206 articles
(gnus-group-real-name group
) (nth 1 method
)
15209 (defun gnus-retrieve-groups (groups method
)
15210 "Request active information on GROUPS from METHOD."
15211 (when (stringp method
)
15212 (setq method
(gnus-server-to-method method
)))
15213 (funcall (gnus-get-function method
'retrieve-groups
) groups
(nth 1 method
)))
15215 (defun gnus-request-type (group &optional article
)
15216 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15217 (let ((method (gnus-find-method-for-group group
)))
15218 (if (not (gnus-check-backend-function 'request-type
(car method
)))
15220 (funcall (gnus-get-function method
'request-type
)
15221 (gnus-group-real-name group
) article
))))
15223 (defun gnus-request-update-mark (group article mark
)
15224 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15225 (let ((method (gnus-find-method-for-group group
)))
15226 (if (not (gnus-check-backend-function 'request-update-mark
(car method
)))
15228 (funcall (gnus-get-function method
'request-update-mark
)
15229 (gnus-group-real-name group
) article mark
))))
15231 (defun gnus-request-article (article group
&optional buffer
)
15232 "Request the ARTICLE in GROUP.
15233 ARTICLE can either be an article number or an article Message-ID.
15234 If BUFFER, insert the article in that group."
15235 (let ((method (gnus-find-method-for-group group
)))
15236 (funcall (gnus-get-function method
'request-article
)
15237 article
(gnus-group-real-name group
) (nth 1 method
) buffer
)))
15239 (defun gnus-request-head (article group
)
15240 "Request the head of ARTICLE in GROUP."
15241 (let* ((method (gnus-find-method-for-group group
))
15242 (head (gnus-get-function method
'request-head t
)))
15244 (funcall head article
(gnus-group-real-name group
) (nth 1 method
))
15245 (let ((res (gnus-request-article article group
)))
15248 (set-buffer nntp-server-buffer
)
15249 (goto-char (point-min))
15250 (when (search-forward "\n\n" nil t
)
15251 (delete-region (1- (point)) (point-max)))
15252 (nnheader-fold-continuation-lines)))
15255 (defun gnus-request-body (article group
)
15256 "Request the body of ARTICLE in GROUP."
15257 (let ((method (gnus-find-method-for-group group
)))
15258 (funcall (gnus-get-function method
'request-body
)
15259 article
(gnus-group-real-name group
) (nth 1 method
))))
15261 (defun gnus-request-post (method)
15262 "Post the current buffer using METHOD."
15263 (when (stringp method
)
15264 (setq method
(gnus-server-to-method method
)))
15265 (funcall (gnus-get-function method
'request-post
) (nth 1 method
)))
15267 (defun gnus-request-scan (group method
)
15268 "Request a SCAN being performed in GROUP from METHOD.
15269 If GROUP is nil, all groups on METHOD are scanned."
15270 (let ((method (if group
(gnus-find-method-for-group group
) method
)))
15271 (funcall (gnus-get-function method
'request-scan
)
15272 (and group
(gnus-group-real-name group
)) (nth 1 method
))))
15274 (defsubst gnus-request-update-info
(info method
)
15275 "Request that METHOD update INFO."
15276 (when (stringp method
)
15277 (setq method
(gnus-server-to-method method
)))
15278 (when (gnus-check-backend-function 'request-update-info
(car method
))
15279 (funcall (gnus-get-function method
'request-update-info
)
15280 (gnus-group-real-name (gnus-info-group info
))
15281 info
(nth 1 method
))))
15283 (defun gnus-request-expire-articles (articles group
&optional force
)
15284 (let ((method (gnus-find-method-for-group group
)))
15285 (funcall (gnus-get-function method
'request-expire-articles
)
15286 articles
(gnus-group-real-name group
) (nth 1 method
)
15289 (defun gnus-request-move-article
15290 (article group server accept-function
&optional last
)
15291 (let ((method (gnus-find-method-for-group group
)))
15292 (funcall (gnus-get-function method
'request-move-article
)
15293 article
(gnus-group-real-name group
)
15294 (nth 1 method
) accept-function last
)))
15296 (defun gnus-request-accept-article (group method
&optional last
)
15297 ;; Make sure there's a newline at the end of the article.
15298 (when (stringp method
)
15299 (setq method
(gnus-server-to-method method
)))
15300 (when (and (not method
)
15302 (setq method
(gnus-group-name-to-method group
)))
15303 (goto-char (point-max))
15306 (let ((func (car (or method
(gnus-find-method-for-group group
)))))
15307 (funcall (intern (format "%s-request-accept-article" func
))
15308 (if (stringp group
) (gnus-group-real-name group
) group
)
15312 (defun gnus-request-replace-article (article group buffer
)
15313 (let ((func (car (gnus-find-method-for-group group
))))
15314 (funcall (intern (format "%s-request-replace-article" func
))
15315 article
(gnus-group-real-name group
) buffer
)))
15317 (defun gnus-request-associate-buffer (group)
15318 (let ((method (gnus-find-method-for-group group
)))
15319 (funcall (gnus-get-function method
'request-associate-buffer
)
15320 (gnus-group-real-name group
))))
15322 (defun gnus-request-restore-buffer (article group
)
15323 "Request a new buffer restored to the state of ARTICLE."
15324 (let ((method (gnus-find-method-for-group group
)))
15325 (funcall (gnus-get-function method
'request-restore-buffer
)
15326 article
(gnus-group-real-name group
) (nth 1 method
))))
15328 (defun gnus-request-create-group (group &optional method
)
15329 (when (stringp method
)
15330 (setq method
(gnus-server-to-method method
)))
15331 (let ((method (or method
(gnus-find-method-for-group group
))))
15332 (funcall (gnus-get-function method
'request-create-group
)
15333 (gnus-group-real-name group
) (nth 1 method
))))
15335 (defun gnus-request-delete-group (group &optional force
)
15336 (let ((method (gnus-find-method-for-group group
)))
15337 (funcall (gnus-get-function method
'request-delete-group
)
15338 (gnus-group-real-name group
) force
(nth 1 method
))))
15340 (defun gnus-request-rename-group (group new-name
)
15341 (let ((method (gnus-find-method-for-group group
)))
15342 (funcall (gnus-get-function method
'request-rename-group
)
15343 (gnus-group-real-name group
)
15344 (gnus-group-real-name new-name
) (nth 1 method
))))
15346 (defun gnus-member-of-valid (symbol group
)
15347 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15348 (memq symbol
(assoc
15349 (symbol-name (car (gnus-find-method-for-group group
)))
15350 gnus-valid-select-methods
)))
15352 (defun gnus-method-option-p (method option
)
15353 "Return non-nil if select METHOD has OPTION as a parameter."
15354 (when (stringp method
)
15355 (setq method
(gnus-server-to-method method
)))
15356 (memq option
(assoc (format "%s" (car method
))
15357 gnus-valid-select-methods
)))
15359 (defun gnus-server-extend-method (group method
)
15360 ;; This function "extends" a virtual server. If the server is
15361 ;; "hello", and the select method is ("hello" (my-var "something"))
15362 ;; in the group "alt.alt", this will result in a new virtual server
15363 ;; called "hello+alt.alt".
15365 (gnus-copy-sequence
15366 (if (equal (car method
) "native") gnus-select-method
15367 (cdr (assoc (car method
) gnus-server-alist
))))))
15368 (setcar (cdr entry
) (concat (nth 1 entry
) "+" group
))
15369 (nconc entry
(cdr method
))))
15371 (defun gnus-group-name-to-method (group)
15372 "Return a select method suitable for GROUP."
15373 (if (string-match ":" group
)
15374 (let ((server (substring group
0 (match-beginning 0))))
15375 (if (string-match "\\+" server
)
15376 (list (intern (substring server
0 (match-beginning 0)))
15377 (substring server
(match-end 0)))
15378 (list (intern server
) "")))
15379 gnus-select-method
))
15381 (defun gnus-find-method-for-group (group &optional info
)
15382 "Find the select method that GROUP uses."
15383 (or gnus-override-method
15385 gnus-select-method
)
15386 (let ((info (or info
(gnus-get-info group
)))
15389 (not (setq method
(gnus-info-method info
)))
15390 (equal method
"native"))
15393 (cond ((stringp method
)
15394 (gnus-server-to-method method
))
15395 ((stringp (car method
))
15396 (gnus-server-extend-method group method
))
15399 (cond ((equal (cadr method
) "")
15401 ((null (cadr method
))
15402 (list (car method
) ""))
15404 (gnus-server-add-address method
)))))))
15406 (defun gnus-check-backend-function (func group
)
15407 "Check whether GROUP supports function FUNC."
15408 (let ((method (if (stringp group
) (car (gnus-find-method-for-group group
))
15410 (fboundp (intern (format "%s-%s" method func
)))))
15412 (defun gnus-methods-using (feature)
15413 "Find all methods that have FEATURE."
15414 (let ((valids gnus-valid-select-methods
)
15417 (if (memq feature
(car valids
))
15418 (setq outs
(cons (car valids
) outs
)))
15419 (setq valids
(cdr valids
)))
15424 ;;; Active & Newsrc File Handling
15427 (defun gnus-setup-news (&optional rawfile level dont-connect
)
15428 "Setup news information.
15429 If RAWFILE is non-nil, the .newsrc file will also be read.
15430 If LEVEL is non-nil, the news will be set up at level LEVEL."
15431 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb
(not rawfile
)))))
15434 ;; Clear some variables to re-initialize news information.
15435 (setq gnus-newsrc-alist nil
15436 gnus-active-hashtb nil
)
15437 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15438 (gnus-read-newsrc-file rawfile
))
15440 (when (and (not (assoc "archive" gnus-server-alist
))
15441 gnus-message-archive-method
)
15442 (push (cons "archive" gnus-message-archive-method
)
15443 gnus-server-alist
))
15445 ;; If we don't read the complete active file, we fill in the
15447 (if (or (null gnus-read-active-file
)
15448 (eq gnus-read-active-file
'some
))
15449 (gnus-update-active-hashtb-from-killed))
15451 ;; Read the active file and create `gnus-active-hashtb'.
15452 ;; If `gnus-read-active-file' is nil, then we just create an empty
15453 ;; hash table. The partial filling out of the hash table will be
15454 ;; done in `gnus-get-unread-articles'.
15455 (and gnus-read-active-file
15457 (gnus-read-active-file))
15459 (or gnus-active-hashtb
15460 (setq gnus-active-hashtb
(make-vector 4095 0)))
15462 ;; Initialize the cache.
15463 (when gnus-use-cache
15466 ;; Possibly eval the dribble file.
15467 (and init
(or gnus-use-dribble-file gnus-slave
) (gnus-dribble-eval-file))
15469 ;; Slave Gnusii should then clear the dribble buffer.
15470 (when (and init gnus-slave
)
15471 (gnus-dribble-clear))
15473 (gnus-update-format-specifications)
15475 ;; See whether we need to read the description file.
15476 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format
)
15477 (not gnus-description-hashtb
)
15479 gnus-read-active-file
)
15480 (gnus-read-all-descriptions-files))
15482 ;; Find new newsgroups and treat them.
15483 (if (and init gnus-check-new-newsgroups
(not level
)
15484 (gnus-check-server gnus-select-method
))
15485 (gnus-find-new-newsgroups))
15487 ;; We might read in new NoCeM messages here.
15488 (when (and gnus-use-nocem
15490 (not dont-connect
))
15491 (gnus-nocem-scan-groups))
15493 ;; Find the number of unread articles in each non-dead group.
15494 (let ((gnus-read-active-file (and (not level
) gnus-read-active-file
)))
15495 (gnus-get-unread-articles level
))
15497 (if (and init gnus-check-bogus-newsgroups
15498 gnus-read-active-file
(not level
)
15499 (gnus-server-opened gnus-select-method
))
15500 (gnus-check-bogus-newsgroups))))
15502 (defun gnus-find-new-newsgroups (&optional arg
)
15503 "Search for new newsgroups and add them.
15504 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15505 The `-n' option line from .newsrc is respected.
15506 If ARG (the prefix), use the `ask-server' method to query
15507 the server for new groups."
15509 (let ((check (if (or (and arg
(not (listp gnus-check-new-newsgroups
)))
15510 (null gnus-read-active-file
)
15511 (eq gnus-read-active-file
'some
))
15512 'ask-server gnus-check-new-newsgroups
)))
15513 (unless (gnus-check-first-time-used)
15514 (if (or (consp check
)
15515 (eq check
'ask-server
))
15516 ;; Ask the server for new groups.
15517 (gnus-ask-server-for-new-groups)
15518 ;; Go through the active hashtb and look for new groups.
15520 group new-newsgroups
)
15521 (gnus-message 5 "Looking for new newsgroups...")
15522 (unless gnus-have-read-active-file
15523 (gnus-read-active-file))
15524 (setq gnus-newsrc-last-checked-date
(current-time-string))
15525 (unless gnus-killed-hashtb
15526 (gnus-make-hashtable-from-killed))
15527 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15528 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15531 (if (or (null (setq group
(symbol-name sym
)))
15533 (null (symbol-value sym
))
15534 (gnus-gethash group gnus-killed-hashtb
)
15535 (gnus-gethash group gnus-newsrc-hashtb
))
15537 (let ((do-sub (gnus-matches-options-n group
)))
15539 ((eq do-sub
'subscribe
)
15540 (setq groups
(1+ groups
))
15541 (gnus-sethash group group gnus-killed-hashtb
)
15542 (funcall gnus-subscribe-options-newsgroup-method group
))
15543 ((eq do-sub
'ignore
)
15546 (setq groups
(1+ groups
))
15547 (gnus-sethash group group gnus-killed-hashtb
)
15548 (if gnus-subscribe-hierarchical-interactive
15549 (setq new-newsgroups
(cons group new-newsgroups
))
15550 (funcall gnus-subscribe-newsgroup-method group
)))))))
15551 gnus-active-hashtb
)
15552 (when new-newsgroups
15553 (gnus-subscribe-hierarchical-interactive new-newsgroups
))
15554 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15556 (gnus-message 6 "%d new newsgroup%s arrived."
15557 groups
(if (> groups
1) "s have" " has"))
15558 (gnus-message 6 "No new newsgroups.")))))))
15560 (defun gnus-matches-options-n (group)
15561 ;; Returns `subscribe' if the group is to be unconditionally
15562 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15563 ;; no match for the group.
15565 ;; First we check the two user variables.
15567 ((and gnus-options-subscribe
15568 (string-match gnus-options-subscribe group
))
15570 ((and gnus-auto-subscribed-groups
15571 (string-match gnus-auto-subscribed-groups group
))
15573 ((and gnus-options-not-subscribe
15574 (string-match gnus-options-not-subscribe group
))
15576 ;; Then we go through the list that was retrieved from the .newsrc
15577 ;; file. This list has elements on the form
15578 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15579 ;; is in the reverse order of the options line) is returned.
15581 (let ((regs gnus-newsrc-options-n
))
15583 (not (string-match (caar regs
) group
)))
15584 (setq regs
(cdr regs
)))
15585 (and regs
(cdar regs
))))))
15587 (defun gnus-ask-server-for-new-groups ()
15588 (let* ((date (or gnus-newsrc-last-checked-date
(current-time-string)))
15589 (methods (cons gnus-select-method
15591 (when gnus-message-archive-method
15594 (and (consp gnus-check-new-newsgroups
)
15595 gnus-check-new-newsgroups
)
15596 gnus-secondary-select-methods
))))
15598 (new-date (current-time-string))
15599 group new-newsgroups got-new method hashtb
15600 gnus-override-subscribe-method
)
15601 ;; Go through both primary and secondary select methods and
15602 ;; request new newsgroups.
15603 (while (setq method
(gnus-server-get-method nil
(pop methods
)))
15604 (setq new-newsgroups nil
)
15605 (setq gnus-override-subscribe-method method
)
15606 (when (and (gnus-check-server method
)
15607 (gnus-request-newgroups date method
))
15610 (setq hashtb
(gnus-make-hashtable 100))
15611 (set-buffer nntp-server-buffer
)
15612 ;; Enter all the new groups into a hashtable.
15613 (gnus-active-to-gnus-format method hashtb
'ignore
))
15614 ;; Now all new groups from `method' are in `hashtb'.
15616 (lambda (group-sym)
15617 (if (or (null (setq group
(symbol-name group-sym
)))
15618 (not (boundp group-sym
))
15619 (null (symbol-value group-sym
))
15620 (gnus-gethash group gnus-newsrc-hashtb
)
15621 (member group gnus-zombie-list
)
15622 (member group gnus-killed-list
))
15623 ;; The group is already known.
15625 ;; Make this group active.
15626 (when (symbol-value group-sym
)
15627 (gnus-set-active group
(symbol-value group-sym
)))
15628 ;; Check whether we want it or not.
15629 (let ((do-sub (gnus-matches-options-n group
)))
15631 ((eq do-sub
'subscribe
)
15633 (gnus-sethash group group gnus-killed-hashtb
)
15634 (funcall gnus-subscribe-options-newsgroup-method group
))
15635 ((eq do-sub
'ignore
)
15639 (gnus-sethash group group gnus-killed-hashtb
)
15640 (if gnus-subscribe-hierarchical-interactive
15641 (push group new-newsgroups
)
15642 (funcall gnus-subscribe-newsgroup-method group
)))))))
15644 (when new-newsgroups
15645 (gnus-subscribe-hierarchical-interactive new-newsgroups
)))
15646 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15648 (gnus-message 6 "%d new newsgroup%s arrived."
15649 groups
(if (> groups
1) "s have" " has")))
15650 (and got-new
(setq gnus-newsrc-last-checked-date new-date
))
15653 (defun gnus-check-first-time-used ()
15654 (if (or (> (length gnus-newsrc-alist
) 1)
15655 (file-exists-p gnus-startup-file
)
15656 (file-exists-p (concat gnus-startup-file
".el"))
15657 (file-exists-p (concat gnus-startup-file
".eld")))
15659 (gnus-message 6 "First time user; subscribing you to default groups")
15660 (unless (gnus-read-active-file-p)
15661 (gnus-read-active-file))
15662 (setq gnus-newsrc-last-checked-date
(current-time-string))
15663 (let ((groups gnus-default-subscribed-newsgroups
)
15667 (setq groups
(or groups gnus-backup-default-subscribed-newsgroups
))
15670 (if (null (setq group
(symbol-name sym
)))
15672 (let ((do-sub (gnus-matches-options-n group
)))
15674 ((eq do-sub
'subscribe
)
15675 (gnus-sethash group group gnus-killed-hashtb
)
15676 (funcall gnus-subscribe-options-newsgroup-method group
))
15677 ((eq do-sub
'ignore
)
15680 (setq gnus-killed-list
(cons group gnus-killed-list
)))))))
15681 gnus-active-hashtb
)
15683 (if (gnus-active (car groups
))
15684 (gnus-group-change-level
15685 (car groups
) gnus-level-default-subscribed gnus-level-killed
))
15686 (setq groups
(cdr groups
)))
15687 (gnus-group-make-help-group)
15688 (and gnus-novice-user
15689 (gnus-message 7 "`A k' to list killed groups"))))))
15691 (defun gnus-subscribe-group (group previous
&optional method
)
15692 (gnus-group-change-level
15694 (list t group gnus-level-default-subscribed nil nil method
)
15696 gnus-level-default-subscribed gnus-level-killed previous t
))
15698 ;; `gnus-group-change-level' is the fundamental function for changing
15699 ;; subscription levels of newsgroups. This might mean just changing
15700 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15701 ;; again, which subscribes/unsubscribes a group, which is equally
15702 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15703 ;; from 8-9 to 1-7 means that you remove the group from the list of
15704 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15705 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15706 ;; which is trivial.
15707 ;; ENTRY can either be a string (newsgroup name) or a list (if
15708 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15709 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15711 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15712 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15714 (defun gnus-group-change-level (entry level
&optional oldlevel
15715 previous fromkilled
)
15716 (let (group info active num
)
15717 ;; Glean what info we can from the arguments
15719 (if fromkilled
(setq group
(nth 1 entry
))
15720 (setq group
(car (nth 2 entry
))))
15721 (setq group entry
))
15722 (if (and (stringp entry
)
15724 (< oldlevel gnus-level-zombie
))
15725 (setq entry
(gnus-gethash entry gnus-newsrc-hashtb
)))
15726 (if (and (not oldlevel
)
15728 (setq oldlevel
(gnus-info-level (nth 2 entry
)))
15729 (setq oldlevel
(or oldlevel
9)))
15730 (if (stringp previous
)
15731 (setq previous
(gnus-gethash previous gnus-newsrc-hashtb
)))
15733 (if (and (>= oldlevel gnus-level-zombie
)
15734 (gnus-gethash group gnus-newsrc-hashtb
))
15735 ;; We are trying to subscribe a group that is already
15739 (or (gnus-ephemeral-group-p group
)
15740 (gnus-dribble-enter
15741 (format "(gnus-group-change-level %S %S %S %S %S)"
15742 group level oldlevel
(car (nth 2 previous
)) fromkilled
)))
15744 ;; Then we remove the newgroup from any old structures, if needed.
15745 ;; If the group was killed, we remove it from the killed or zombie
15746 ;; list. If not, and it is in fact going to be killed, we remove
15747 ;; it from the newsrc hash table and assoc.
15749 ((>= oldlevel gnus-level-zombie
)
15750 (if (= oldlevel gnus-level-zombie
)
15751 (setq gnus-zombie-list
(delete group gnus-zombie-list
))
15752 (setq gnus-killed-list
(delete group gnus-killed-list
))))
15754 (if (and (>= level gnus-level-zombie
)
15757 (gnus-sethash (car (nth 2 entry
)) nil gnus-newsrc-hashtb
)
15759 (setcdr (gnus-gethash (car (nth 3 entry
))
15760 gnus-newsrc-hashtb
)
15762 (setcdr (cdr entry
) (cdddr entry
))))))
15764 ;; Finally we enter (if needed) the list where it is supposed to
15765 ;; go, and change the subscription level. If it is to be killed,
15766 ;; we enter it into the killed or zombie list.
15768 ((>= level gnus-level-zombie
)
15769 ;; Remove from the hash table.
15770 (gnus-sethash group nil gnus-newsrc-hashtb
)
15771 ;; We do not enter foreign groups into the list of dead
15773 (unless (gnus-group-foreign-p group
)
15774 (if (= level gnus-level-zombie
)
15775 (setq gnus-zombie-list
(cons group gnus-zombie-list
))
15776 (setq gnus-killed-list
(cons group gnus-killed-list
)))))
15778 ;; If the list is to be entered into the newsrc assoc, and
15779 ;; it was killed, we have to create an entry in the newsrc
15780 ;; hashtb format and fix the pointers in the newsrc assoc.
15781 (if (< oldlevel gnus-level-zombie
)
15782 ;; It was alive, and it is going to stay alive, so we
15783 ;; just change the level and don't change any pointers or
15784 ;; hash table entries.
15785 (setcar (cdaddr entry
) level
)
15787 (setq info
(cdr entry
)
15789 (setq active
(gnus-active group
))
15791 (if active
(- (1+ (cdr active
)) (car active
)) t
))
15792 ;; Check whether the group is foreign. If so, the
15793 ;; foreign select method has to be entered into the
15795 (let ((method (or gnus-override-subscribe-method
15796 (gnus-group-method group
))))
15797 (if (eq method gnus-select-method
)
15798 (setq info
(list group level nil
))
15799 (setq info
(list group level nil nil method
)))))
15802 (let ((p gnus-newsrc-alist
))
15806 (setq entry
(cons info
(cddr previous
)))
15809 (setcdr (cdr previous
) entry
)
15810 (gnus-sethash group
(cons num
(cdr previous
))
15811 gnus-newsrc-hashtb
))
15812 (setcdr previous entry
)
15813 (gnus-sethash group
(cons num previous
)
15814 gnus-newsrc-hashtb
))
15816 (setcdr (gnus-gethash (caadr entry
) gnus-newsrc-hashtb
) entry
)))))
15817 (when gnus-group-change-level-function
15818 (funcall gnus-group-change-level-function group level oldlevel
)))))
15820 (defun gnus-kill-newsgroup (newsgroup)
15821 "Obsolete function. Kills a newsgroup."
15822 (gnus-group-change-level
15823 (gnus-gethash newsgroup gnus-newsrc-hashtb
) gnus-level-killed
))
15825 (defun gnus-check-bogus-newsgroups (&optional confirm
)
15826 "Remove bogus newsgroups.
15827 If CONFIRM is non-nil, the user has to confirm the deletion of every
15829 (let ((newsrc (cdr gnus-newsrc-alist
))
15830 bogus group entry info
)
15831 (gnus-message 5 "Checking bogus newsgroups...")
15832 (unless (gnus-read-active-file-p)
15833 (gnus-read-active-file))
15834 (when (gnus-read-active-file-p)
15835 ;; Find all bogus newsgroup that are subscribed.
15837 (setq info
(pop newsrc
)
15838 group
(gnus-info-group info
))
15839 (unless (or (gnus-active group
) ; Active
15840 (gnus-info-method info
) ; Foreign
15842 (not (gnus-y-or-n-p
15843 (format "Remove bogus newsgroup: %s " group
)))))
15844 ;; Found a bogus newsgroup.
15845 (push group bogus
)))
15846 ;; Remove all bogus subscribed groups by first killing them, and
15847 ;; then removing them from the list of killed groups.
15849 (when (setq entry
(gnus-gethash (setq group
(pop bogus
))
15850 gnus-newsrc-hashtb
))
15851 (gnus-group-change-level entry gnus-level-killed
)
15852 (setq gnus-killed-list
(delete group gnus-killed-list
))))
15853 ;; Then we remove all bogus groups from the list of killed and
15854 ;; zombie groups. They are are removed without confirmation.
15855 (let ((dead-lists '(gnus-killed-list gnus-zombie-list
))
15858 (setq killed
(symbol-value (car dead-lists
)))
15860 (unless (gnus-active (setq group
(pop killed
)))
15861 ;; The group is bogus.
15862 ;; !!!Slow as hell.
15863 (set (car dead-lists
)
15864 (delete group
(symbol-value (car dead-lists
))))))
15865 (setq dead-lists
(cdr dead-lists
))))
15866 (gnus-message 5 "Checking bogus newsgroups...done"))))
15868 (defun gnus-check-duplicate-killed-groups ()
15869 "Remove duplicates from the list of killed groups."
15871 (let ((killed gnus-killed-list
))
15873 (gnus-message 9 "%d" (length killed
))
15874 (setcdr killed
(delete (car killed
) (cdr killed
)))
15875 (setq killed
(cdr killed
)))))
15877 ;; We want to inline a function from gnus-cache, so we cheat here:
15880 (require 'gnus-cache
))
15882 (defun gnus-get-unread-articles-in-group (info active
&optional update
)
15884 ;; Allow the backend to update the info in the group.
15886 (gnus-request-update-info
15887 info
(gnus-find-method-for-group (gnus-info-group info
))))
15888 (gnus-activate-group (gnus-info-group info
) nil t
))
15889 (let* ((range (gnus-info-read info
))
15891 ;; If a cache is present, we may have to alter the active info.
15892 (when (and gnus-use-cache info
)
15893 (inline (gnus-cache-possibly-alter-active
15894 (gnus-info-group info
) active
)))
15895 ;; Modify the list of read articles according to what articles
15896 ;; are available; then tally the unread articles and add the
15897 ;; number to the group hash table entry.
15899 ((zerop (cdr active
))
15902 (setq num
(- (1+ (cdr active
)) (car active
))))
15903 ((not (listp (cdr range
)))
15904 ;; Fix a single (num . num) range according to the
15905 ;; active hash table.
15906 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15907 (and (< (cdr range
) (car active
)) (setcdr range
(1- (car active
))))
15908 (and (> (cdr range
) (cdr active
)) (setcdr range
(cdr active
)))
15909 ;; Compute number of unread articles.
15910 (setq num
(max 0 (- (cdr active
) (- (1+ (cdr range
)) (car range
))))))
15912 ;; The read list is a list of ranges. Fix them according to
15913 ;; the active hash table.
15914 ;; First peel off any elements that are below the lower
15916 (while (and (cdr range
)
15918 (or (and (atom (cadr range
)) (cadr range
))
15920 (if (numberp (car range
))
15923 (or (and (numberp (cadr range
))
15926 (setcdr (car range
)
15927 (or (and (numberp (nth 1 range
)) (nth 1 range
))
15929 (setcdr range
(cddr range
)))
15930 ;; Adjust the first element to be the same as the lower limit.
15931 (if (and (not (atom (car range
)))
15932 (< (cdar range
) (car active
)))
15933 (setcdr (car range
) (1- (car active
))))
15934 ;; Then we want to peel off any elements that are higher
15935 ;; than the upper active limit.
15936 (let ((srange range
))
15937 ;; Go past all legal elements.
15938 (while (and (cdr srange
)
15939 (<= (or (and (atom (cadr srange
))
15941 (caadr srange
)) (cdr active
)))
15942 (setq srange
(cdr srange
)))
15944 ;; Nuke all remaining illegal elements.
15945 (setcdr srange nil
))
15947 ;; Adjust the final element.
15948 (if (and (not (atom (car srange
)))
15949 (> (cdar srange
) (cdr active
)))
15950 (setcdr (car srange
) (cdr active
))))
15951 ;; Compute the number of unread articles.
15953 (setq num
(+ num
(- (1+ (or (and (atom (car range
)) (car range
))
15955 (or (and (atom (car range
)) (car range
))
15957 (setq range
(cdr range
)))
15958 (setq num
(max 0 (- (cdr active
) num
)))))
15959 ;; Set the number of unread articles.
15961 (setcar (gnus-gethash (gnus-info-group info
) gnus-newsrc-hashtb
) num
))
15964 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15965 ;; and compute how many unread articles there are in each group.
15966 (defun gnus-get-unread-articles (&optional level
)
15967 (let* ((newsrc (cdr gnus-newsrc-alist
))
15968 (level (or level gnus-activate-level
(1+ gnus-level-subscribed
)))
15971 (cond ((and gnus-activate-foreign-newsgroups
15972 (not (numberp gnus-activate-foreign-newsgroups
)))
15973 (1+ gnus-level-subscribed
))
15974 ((numberp gnus-activate-foreign-newsgroups
)
15975 gnus-activate-foreign-newsgroups
)
15978 info group active method
)
15979 (gnus-message 5 "Checking new news...")
15982 (setq active
(gnus-active (setq group
(gnus-info-group
15983 (setq info
(pop newsrc
))))))
15985 ;; Check newsgroups. If the user doesn't want to check them, or
15986 ;; they can't be checked (for instance, if the news server can't
15987 ;; be reached) we just set the number of unread articles in this
15988 ;; newsgroup to t. This means that Gnus thinks that there are
15989 ;; unread articles, but it has no idea how many.
15990 (if (and (setq method
(gnus-info-method info
))
15991 (not (gnus-server-equal
15993 (setq method
(gnus-server-get-method nil method
))))
15994 (not (gnus-secondary-method-p method
)))
15995 ;; These groups are foreign. Check the level.
15996 (when (<= (gnus-info-level info
) foreign-level
)
15997 (setq active
(gnus-activate-group group
'scan
))
15998 (unless (inline (gnus-virtual-group-p group
))
15999 (inline (gnus-close-group group
)))
16000 (when (fboundp (intern (concat (symbol-name (car method
))
16001 "-request-update-info")))
16002 (inline (gnus-request-update-info info method
))))
16003 ;; These groups are native or secondary.
16004 (when (and (<= (gnus-info-level info
) level
)
16005 (not gnus-read-active-file
))
16006 (setq active
(gnus-activate-group group
'scan
))
16007 (inline (gnus-close-group group
))))
16009 ;; Get the number of unread articles in the group.
16011 (inline (gnus-get-unread-articles-in-group info active
))
16012 ;; The group couldn't be reached, so we nix out the number of
16013 ;; unread articles and stuff.
16014 (gnus-set-active group nil
)
16015 (setcar (gnus-gethash group gnus-newsrc-hashtb
) t
)))
16017 (gnus-message 5 "Checking new news...done")))
16019 ;; Create a hash table out of the newsrc alist. The `car's of the
16020 ;; alist elements are used as keys.
16021 (defun gnus-make-hashtable-from-newsrc-alist ()
16022 (let ((alist gnus-newsrc-alist
)
16023 (ohashtb gnus-newsrc-hashtb
)
16025 (setq gnus-newsrc-hashtb
(gnus-make-hashtable (length alist
)))
16027 (setq prev
(setq gnus-newsrc-alist
16028 (if (equal (caar gnus-newsrc-alist
)
16031 (cons (list "dummy.group" 0 nil
) alist
)))))
16035 (cons (and ohashtb
(car (gnus-gethash (caar alist
) ohashtb
)))
16037 gnus-newsrc-hashtb
)
16039 alist
(cdr alist
)))))
16041 (defun gnus-make-hashtable-from-killed ()
16042 "Create a hash table from the killed and zombie lists."
16043 (let ((lists '(gnus-killed-list gnus-zombie-list
))
16045 (setq gnus-killed-hashtb
16046 (gnus-make-hashtable
16047 (+ (length gnus-killed-list
) (length gnus-zombie-list
))))
16048 (while (setq list
(pop lists
))
16049 (setq list
(symbol-value list
))
16051 (gnus-sethash (car list
) (pop list
) gnus-killed-hashtb
)))))
16053 (defun gnus-activate-group (group &optional scan dont-check method
)
16054 ;; Check whether a group has been activated or not.
16055 ;; If SCAN, request a scan of that group as well.
16056 (let ((method (or method
(gnus-find-method-for-group group
)))
16058 (and (gnus-check-server method
)
16059 ;; We escape all bugs and quit here to make it possible to
16060 ;; continue if a group is so out-there that it reports bugs
16064 (gnus-check-backend-function 'request-scan
(car method
))
16065 (gnus-request-scan group method
))
16068 (gnus-request-group group dont-check method
)
16072 (set-buffer nntp-server-buffer
)
16073 (goto-char (point-min))
16074 ;; Parse the result we got from `gnus-request-group'.
16075 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16077 (goto-char (match-beginning 1))
16079 group
(setq active
(cons (read (current-buffer))
16080 (read (current-buffer)))))
16081 ;; Return the new active info.
16084 (defun gnus-update-read-articles (group unread
)
16085 "Update the list of read and ticked articles in GROUP using the
16086 UNREAD and TICKED lists.
16087 Note: UNSELECTED has to be sorted over `<'.
16088 Returns whether the updating was successful."
16089 (let* ((active (or gnus-newsgroup-active
(gnus-active group
)))
16090 (entry (gnus-gethash group gnus-newsrc-hashtb
))
16091 (info (nth 2 entry
))
16093 (unread (sort (copy-sequence unread
) '<))
16095 (if (or (not info
) (not active
))
16096 ;; There is no info on this group if it was, in fact,
16097 ;; killed. Gnus stores no information on killed groups, so
16098 ;; there's nothing to be done.
16099 ;; One could store the information somewhere temporarily,
16100 ;; perhaps... Hmmm...
16102 ;; Remove any negative articles numbers.
16103 (while (and unread
(< (car unread
) 0))
16104 (setq unread
(cdr unread
)))
16105 ;; Remove any expired article numbers
16106 (while (and unread
(< (car unread
) (car active
)))
16107 (setq unread
(cdr unread
)))
16108 ;; Compute the ranges of read articles by looking at the list of
16109 ;; unread articles.
16111 (if (/= (car unread
) prev
)
16112 (setq read
(cons (if (= prev
(1- (car unread
))) prev
16113 (cons prev
(1- (car unread
)))) read
)))
16114 (setq prev
(1+ (car unread
)))
16115 (setq unread
(cdr unread
)))
16116 (when (<= prev
(cdr active
))
16117 (setq read
(cons (cons prev
(cdr active
)) read
)))
16118 ;; Enter this list into the group info.
16119 (gnus-info-set-read
16120 info
(if (> (length read
) 1) (nreverse read
) read
))
16121 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16122 (gnus-get-unread-articles-in-group info
(gnus-active group
))
16125 (defun gnus-make-articles-unread (group articles
)
16126 "Mark ARTICLES in GROUP as unread."
16127 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb
)
16128 (gnus-gethash (gnus-group-real-name group
)
16129 gnus-newsrc-hashtb
))))
16130 (ranges (gnus-info-read info
))
16133 (when (gnus-member-of-range
16134 (setq article
(pop articles
)) ranges
)
16135 (setq news
(cons article news
))))
16137 (gnus-info-set-read
16138 info
(gnus-remove-from-range (gnus-info-read info
) (nreverse news
)))
16139 (gnus-group-update-group group t
))))
16141 ;; Enter all dead groups into the hashtb.
16142 (defun gnus-update-active-hashtb-from-killed ()
16143 (let ((hashtb (setq gnus-active-hashtb
(make-vector 4095 0)))
16144 (lists (list gnus-killed-list gnus-zombie-list
))
16147 (setq killed
(car lists
))
16149 (gnus-sethash (car killed
) nil hashtb
)
16150 (setq killed
(cdr killed
)))
16151 (setq lists
(cdr lists
)))))
16153 (defun gnus-get-killed-groups ()
16154 "Go through the active hashtb and all all unknown groups as killed."
16155 ;; First make sure active file has been read.
16156 (unless (gnus-read-active-file-p)
16157 (let ((gnus-read-active-file t
))
16158 (gnus-read-active-file)))
16159 (or gnus-killed-hashtb
(gnus-make-hashtable-from-killed))
16160 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16164 (group (symbol-name sym
)))
16165 (if (or (null group
)
16166 (gnus-gethash group gnus-killed-hashtb
)
16167 (gnus-gethash group gnus-newsrc-hashtb
))
16169 (let ((do-sub (gnus-matches-options-n group
)))
16170 (if (or (eq do-sub
'subscribe
) (eq do-sub
'ignore
))
16172 (setq groups
(1+ groups
))
16173 (setq gnus-killed-list
16174 (cons group gnus-killed-list
))
16175 (gnus-sethash group group gnus-killed-hashtb
))))))
16176 gnus-active-hashtb
))
16178 ;; Get the active file(s) from the backend(s).
16179 (defun gnus-read-active-file ()
16180 (gnus-group-set-mode-line)
16183 (if (gnus-check-server gnus-select-method
)
16184 ;; The native server is available.
16185 (cons gnus-select-method gnus-secondary-select-methods
)
16186 ;; The native server is down, so we just do the
16188 gnus-secondary-select-methods
)
16189 ;; Also read from the archive server.
16190 (when gnus-message-archive-method
16191 (list "archive"))))
16193 (setq gnus-have-read-active-file nil
)
16195 (set-buffer nntp-server-buffer
)
16197 (let* ((method (if (stringp (car methods
))
16198 (gnus-server-get-method nil
(car methods
))
16200 (where (nth 1 method
))
16201 (mesg (format "Reading active file%s via %s..."
16202 (if (and where
(not (zerop (length where
))))
16203 (concat " from " where
) "")
16205 (gnus-message 5 mesg
)
16206 (when (gnus-check-server method
)
16207 ;; Request that the backend scan its incoming messages.
16208 (and (gnus-check-backend-function 'request-scan
(car method
))
16209 (gnus-request-scan nil method
))
16211 ((and (eq gnus-read-active-file
'some
)
16212 (gnus-check-backend-function 'retrieve-groups
(car method
)))
16213 (let ((newsrc (cdr gnus-newsrc-alist
))
16214 (gmethod (gnus-server-get-method nil method
))
16216 (while (setq info
(pop newsrc
))
16217 (when (gnus-server-equal
16218 (gnus-find-method-for-group
16219 (gnus-info-group info
) info
)
16221 (push (gnus-group-real-name (gnus-info-group info
))
16224 (gnus-check-server method
)
16225 (setq list-type
(gnus-retrieve-groups groups method
))
16229 1.2 "Cannot read partial active file from %s server."
16231 ((eq list-type
'active
)
16232 (gnus-active-to-gnus-format method gnus-active-hashtb
))
16234 (gnus-groups-to-gnus-format method gnus-active-hashtb
))))))
16236 (if (not (gnus-request-list method
))
16237 (unless (equal method gnus-message-archive-method
)
16238 (gnus-error 1 "Cannot read active file from %s server."
16240 (gnus-message 5 mesg
)
16241 (gnus-active-to-gnus-format method gnus-active-hashtb
)
16242 ;; We mark this active file as read.
16243 (push method gnus-have-read-active-file
)
16244 (gnus-message 5 "%sdone" mesg
))))))
16245 (setq methods
(cdr methods
))))))
16247 ;; Read an active file and place the results in `gnus-active-hashtb'.
16248 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors
)
16250 (setq method gnus-select-method
))
16251 (let ((cur (current-buffer))
16253 (if (and gnus-active-hashtb
16254 (not (equal method gnus-select-method
)))
16256 (setq gnus-active-hashtb
16257 (if (equal method gnus-select-method
)
16258 (gnus-make-hashtable
16259 (count-lines (point-min) (point-max)))
16260 (gnus-make-hashtable 4096)))))))
16261 ;; Delete unnecessary lines.
16262 (goto-char (point-min))
16263 (while (search-forward "\nto." nil t
)
16264 (delete-region (1+ (match-beginning 0))
16265 (progn (forward-line 1) (point))))
16266 (or (string= gnus-ignored-newsgroups
"")
16268 (goto-char (point-min))
16269 (delete-matching-lines gnus-ignored-newsgroups
)))
16270 ;; Make the group names readable as a lisp expression even if they
16271 ;; contain special characters.
16272 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16273 (goto-char (point-max))
16274 (while (re-search-backward "[][';?()#]" nil t
)
16276 ;; If these are groups from a foreign select method, we insert the
16277 ;; group prefix in front of the group names.
16278 (and method
(not (gnus-server-equal
16279 (gnus-server-get-method nil method
)
16280 (gnus-server-get-method nil gnus-select-method
)))
16281 (let ((prefix (gnus-group-prefixed-name "" method
)))
16282 (goto-char (point-min))
16283 (while (and (not (eobp))
16284 (progn (insert prefix
)
16285 (zerop (forward-line 1)))))))
16286 ;; Store the active file in a hash table.
16287 (goto-char (point-min))
16288 (if (string-match "%[oO]" gnus-group-line-format
)
16289 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16290 ;; If we want information on moderated groups, we use this
16292 (let* ((mod-hashtb (make-vector 7 0))
16293 (m (intern "m" mod-hashtb
))
16295 (while (not (eobp))
16296 (condition-case nil
16298 (narrow-to-region (point) (gnus-point-at-eol))
16299 (setq group
(let ((obarray hashtb
)) (read cur
)))
16300 (if (and (numberp (setq max
(read cur
)))
16301 (numberp (setq min
(read cur
)))
16303 (skip-chars-forward " \t")
16305 (or (= (following-char) ?
=)
16306 (= (following-char) ?x
)
16307 (= (following-char) ?j
)))))
16308 (set group
(cons min max
))
16310 ;; Enter moderated groups into a list.
16311 (if (eq (let ((obarray mod-hashtb
)) (read cur
)) m
)
16312 (setq gnus-moderated-list
16313 (cons (symbol-name group
) gnus-moderated-list
))))
16320 ;; And if we do not care about moderation, we use this loop,
16321 ;; which is faster.
16322 (let (group max min
)
16323 (while (not (eobp))
16326 (narrow-to-region (point) (gnus-point-at-eol))
16327 ;; group gets set to a symbol interned in the hash table
16328 ;; (what a hack!!) - jwz
16329 (setq group
(let ((obarray hashtb
)) (read cur
)))
16330 (if (and (numberp (setq max
(read cur
)))
16331 (numberp (setq min
(read cur
)))
16333 (skip-chars-forward " \t")
16335 (or (= (following-char) ?
=)
16336 (= (following-char) ?x
)
16337 (= (following-char) ?j
)))))
16338 (set group
(cons min max
))
16346 (gnus-message 3 "Warning - illegal active: %s"
16348 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16350 (forward-line 1))))))
16352 (defun gnus-groups-to-gnus-format (method &optional hashtb
)
16353 ;; Parse a "groups" active file.
16354 (let ((cur (current-buffer))
16356 (if (and method gnus-active-hashtb
)
16358 (setq gnus-active-hashtb
16359 (gnus-make-hashtable
16360 (count-lines (point-min) (point-max)))))))
16361 (prefix (and method
16362 (not (gnus-server-equal
16363 (gnus-server-get-method nil method
)
16364 (gnus-server-get-method nil gnus-select-method
)))
16365 (gnus-group-prefixed-name "" method
))))
16367 (goto-char (point-min))
16368 ;; We split this into to separate loops, one with the prefix
16369 ;; and one without to speed the reading up somewhat.
16371 (let (min max opoint group
)
16372 (while (not (eobp))
16375 (read cur
) (read cur
)
16376 (setq min
(read cur
)
16379 (skip-chars-forward " \t")
16382 (set (let ((obarray hashtb
)) (read cur
))
16384 (error (and group
(symbolp group
) (set group nil
))))
16386 (let (min max group
)
16387 (while (not (eobp))
16389 (if (= (following-char) ?
2)
16391 (read cur
) (read cur
)
16392 (setq min
(read cur
)
16394 (set (setq group
(let ((obarray hashtb
)) (read cur
)))
16396 (error (and group
(symbolp group
) (set group nil
))))
16397 (forward-line 1))))))
16399 (defun gnus-read-newsrc-file (&optional force
)
16400 "Read startup file.
16401 If FORCE is non-nil, the .newsrc file is read."
16402 ;; Reset variables that might be defined in the .newsrc.eld file.
16403 (let ((variables gnus-variable-list
))
16405 (set (car variables
) nil
)
16406 (setq variables
(cdr variables
))))
16407 (let* ((newsrc-file gnus-current-startup-file
)
16408 (quick-file (concat newsrc-file
".el")))
16410 ;; We always load the .newsrc.eld file. If always contains
16411 ;; much information that can not be gotten from the .newsrc
16412 ;; file (ticked articles, killed groups, foreign methods, etc.)
16413 (gnus-read-newsrc-el-file quick-file
)
16415 (if (and (file-exists-p gnus-current-startup-file
)
16417 (and (file-newer-than-file-p newsrc-file quick-file
)
16418 (file-newer-than-file-p newsrc-file
16419 (concat quick-file
"d")))
16420 (not gnus-newsrc-alist
)))
16421 ;; We read the .newsrc file. Note that if there if a
16422 ;; .newsrc.eld file exists, it has already been read, and
16423 ;; the `gnus-newsrc-hashtb' has been created. While reading
16424 ;; the .newsrc file, Gnus will only use the information it
16425 ;; can find there for changing the data already read -
16426 ;; ie. reading the .newsrc file will not trash the data
16427 ;; already read (except for read articles).
16429 (gnus-message 5 "Reading %s..." newsrc-file
)
16430 (set-buffer (find-file-noselect newsrc-file
))
16431 (buffer-disable-undo (current-buffer))
16432 (gnus-newsrc-to-gnus-format)
16433 (kill-buffer (current-buffer))
16434 (gnus-message 5 "Reading %s...done" newsrc-file
)))
16436 ;; Read any slave files.
16438 (gnus-master-read-slave-newsrc))
16440 ;; Convert old to new.
16441 (gnus-convert-old-newsrc))))
16443 (defun gnus-continuum-version (version)
16444 "Return VERSION as a floating point number."
16445 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version
)
16446 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version
))
16447 (let* ((alpha (and (match-beginning 1) (match-string 1 version
)))
16448 (number (match-string 2 version
))
16450 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number
)
16451 (setq major
(string-to-number (match-string 1 number
)))
16452 (setq minor
(string-to-number (match-string 2 number
)))
16453 (setq least
(if (match-beginning 3)
16454 (string-to-number (match-string 3 number
))
16458 (format "%s00%02d%02d"
16460 ((member alpha
'("(ding)" "d")) "4.99")
16461 ((member alpha
'("September" "s")) "5.01")
16462 ((member alpha
'("Red" "r")) "5.03"))
16464 (format "%d.%02d%02d" major minor least
))))))
16466 (defun gnus-convert-old-newsrc ()
16467 "Convert old newsrc into the new format, if needed."
16468 (let ((fcv (and gnus-newsrc-file-version
16469 (gnus-continuum-version gnus-newsrc-file-version
))))
16471 ;; No .newsrc.eld file was loaded.
16473 ;; Gnus 5 .newsrc.eld was loaded.
16474 ((< fcv
(gnus-continuum-version "September Gnus v0.1"))
16475 (gnus-convert-old-ticks)))))
16477 (defun gnus-convert-old-ticks ()
16478 (let ((newsrc (cdr gnus-newsrc-alist
))
16479 marks info dormant ticked
)
16480 (while (setq info
(pop newsrc
))
16481 (when (setq marks
(gnus-info-marks info
))
16482 (setq dormant
(cdr (assq 'dormant marks
))
16483 ticked
(cdr (assq 'tick marks
)))
16484 (when (or dormant ticked
)
16485 (gnus-info-set-read
16488 (gnus-info-read info
)
16489 (nconc (gnus-uncompress-range dormant
)
16490 (gnus-uncompress-range ticked
)))))))))
16492 (defun gnus-read-newsrc-el-file (file)
16493 (let ((ding-file (concat file
"d")))
16494 ;; We always, always read the .eld file.
16495 (gnus-message 5 "Reading %s..." ding-file
)
16496 (let (gnus-newsrc-assoc)
16497 (condition-case nil
16498 (load ding-file t t t
)
16500 (gnus-error 1 "Error in %s" ding-file
)))
16501 (when gnus-newsrc-assoc
16502 (setq gnus-newsrc-alist gnus-newsrc-assoc
)))
16503 (gnus-make-hashtable-from-newsrc-alist)
16504 (when (file-newer-than-file-p file ding-file
)
16505 ;; Old format quick file
16506 (gnus-message 5 "Reading %s..." file
)
16507 ;; The .el file is newer than the .eld file, so we read that one
16509 (gnus-read-old-newsrc-el-file file
))))
16511 ;; Parse the old-style quick startup file
16512 (defun gnus-read-old-newsrc-el-file (file)
16513 (let (newsrc killed marked group m info
)
16515 (let ((gnus-killed-assoc nil
)
16516 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc
)
16518 (condition-case nil
16521 (setq newsrc gnus-newsrc-assoc
16522 killed gnus-killed-assoc
16523 marked gnus-marked-assoc
)))
16524 (setq gnus-newsrc-alist nil
)
16525 (while (setq group
(pop newsrc
))
16526 (if (setq info
(gnus-get-info (car group
)))
16528 (gnus-info-set-read info
(cddr group
))
16529 (gnus-info-set-level
16530 info
(if (nth 1 group
) gnus-level-default-subscribed
16531 gnus-level-default-unsubscribed
))
16532 (setq gnus-newsrc-alist
(cons info gnus-newsrc-alist
)))
16535 (if (nth 1 group
) gnus-level-default-subscribed
16536 gnus-level-default-unsubscribed
)
16538 gnus-newsrc-alist
))
16539 ;; Copy marks into info.
16540 (when (setq m
(assoc (car group
) marked
))
16541 (unless (nthcdr 3 info
)
16542 (nconc info
(list nil
)))
16543 (gnus-info-set-marks
16544 info
(list (cons 'tick
(gnus-compress-sequence
16545 (sort (cdr m
) '<) t
))))))
16546 (setq newsrc killed
)
16548 (setcar newsrc
(caar newsrc
))
16549 (setq newsrc
(cdr newsrc
)))
16550 (setq gnus-killed-list killed
))
16551 ;; The .el file version of this variable does not begin with
16552 ;; "options", while the .eld version does, so we just add it if it
16555 gnus-newsrc-options
16557 (and (not (string-match "^ *options" gnus-newsrc-options
))
16558 (setq gnus-newsrc-options
(concat "options " gnus-newsrc-options
)))
16559 (and (not (string-match "\n$" gnus-newsrc-options
))
16560 (setq gnus-newsrc-options
(concat gnus-newsrc-options
"\n")))
16561 ;; Finally, if we read some options lines, we parse them.
16562 (or (string= gnus-newsrc-options
"")
16563 (gnus-newsrc-parse-options gnus-newsrc-options
))))
16565 (setq gnus-newsrc-alist
(nreverse gnus-newsrc-alist
))
16566 (gnus-make-hashtable-from-newsrc-alist)))
16568 (defun gnus-make-newsrc-file (file)
16569 "Make server dependent file name by catenating FILE and server host name."
16570 (let* ((file (expand-file-name file nil
))
16571 (real-file (concat file
"-" (nth 1 gnus-select-method
))))
16572 (if (or (file-exists-p real-file
)
16573 (file-exists-p (concat real-file
".el"))
16574 (file-exists-p (concat real-file
".eld")))
16577 (defun gnus-newsrc-to-gnus-format ()
16578 (setq gnus-newsrc-options
"")
16579 (setq gnus-newsrc-options-n nil
)
16581 (or gnus-active-hashtb
16582 (setq gnus-active-hashtb
(make-vector 4095 0)))
16583 (let ((buf (current-buffer))
16584 (already-read (> (length gnus-newsrc-alist
) 1))
16585 group subscribed options-symbol newsrc Options-symbol
16587 (goto-char (point-min))
16588 ;; We intern the symbol `options' in the active hashtb so that we
16589 ;; can `eq' against it later.
16590 (set (setq options-symbol
(intern "options" gnus-active-hashtb
)) nil
)
16591 (set (setq Options-symbol
(intern "Options" gnus-active-hashtb
)) nil
)
16593 (while (not (eobp))
16594 ;; We first read the first word on the line by narrowing and
16595 ;; then reading into `gnus-active-hashtb'. Most groups will
16596 ;; already exist in that hashtb, so this will save some string
16600 (progn (skip-chars-forward "^ \t!:\n") (point)))
16601 (goto-char (point-min))
16603 (and (/= (point-min) (point-max))
16604 (let ((obarray gnus-active-hashtb
)) (read buf
))))
16606 ;; Now, the symbol we have read is either `options' or a group
16607 ;; name. If it is an options line, we just add it to a string.
16609 ((or (eq symbol options-symbol
)
16610 (eq symbol Options-symbol
))
16611 (setq gnus-newsrc-options
16612 ;; This concating is quite inefficient, but since our
16613 ;; thorough studies show that approx 99.37% of all
16614 ;; .newsrc files only contain a single options line, we
16615 ;; don't give a damn, frankly, my dear.
16616 (concat gnus-newsrc-options
16618 (gnus-point-at-bol)
16619 ;; Options may continue on the next line.
16620 (or (and (re-search-forward "^[^ \t]" nil
'move
)
16621 (progn (beginning-of-line) (point)))
16625 ;; Group names can be just numbers.
16626 (when (numberp symbol
)
16627 (setq symbol
(intern (int-to-string symbol
) gnus-active-hashtb
)))
16628 (or (boundp symbol
) (set symbol nil
))
16629 ;; It was a group name.
16630 (setq subscribed
(= (following-char) ?
:)
16631 group
(symbol-name symbol
)
16634 ;; If the line ends here, this is clearly a buggy line, so
16635 ;; we put point a the beginning of line and let the cond
16636 ;; below do the error handling.
16637 (beginning-of-line)
16638 ;; We skip to the beginning of the ranges.
16639 (skip-chars-forward "!: \t"))
16640 ;; We are now at the beginning of the list of read articles.
16641 ;; We read them range by range.
16644 ((looking-at "[0-9]+")
16645 ;; We narrow and read a number instead of buffer-substring/
16646 ;; string-to-int because it's faster. narrow/widen is
16647 ;; faster than save-restriction/narrow, and save-restriction
16648 ;; produces a garbage object.
16650 (narrow-to-region (match-beginning 0) (match-end 0))
16653 ;; If the next character is a dash, then this is a range.
16654 (if (= (following-char) ?-
)
16656 ;; We read the upper bound of the range.
16658 (if (not (looking-at "[0-9]+"))
16659 ;; This is a buggy line, by we pretend that
16660 ;; it's kinda OK. Perhaps the user should be
16662 (setq reads
(cons num1 reads
))
16667 (narrow-to-region (match-beginning 0)
16672 ;; It was just a simple number, so we add it to the
16674 (setq reads
(cons num1 reads
)))
16675 ;; If the next char in ?\n, then we have reached the end
16676 ;; of the line and return nil.
16677 (/= (following-char) ?
\n))
16678 ((= (following-char) ?
\n)
16679 ;; End of line, so we end.
16682 ;; Not numbers and not eol, so this might be a buggy
16685 ;; If it was eob instead of ?\n, we allow it.
16687 ;; The line was buggy.
16689 (gnus-error 3.1 "Mangled line: %s"
16690 (buffer-substring (gnus-point-at-bol)
16691 (gnus-point-at-eol)))))
16693 ;; Skip past ", ". Spaces are illegal in these ranges, but
16694 ;; we allow them, because it's a common mistake to put a
16695 ;; space after the comma.
16696 (skip-chars-forward ", "))
16698 ;; We have already read .newsrc.eld, so we gently update the
16699 ;; data in the hash table with the information we have just
16702 (let ((info (gnus-get-info group
))
16705 ;; There is an entry for this file in the alist.
16707 (gnus-info-set-read info
(nreverse reads
))
16708 ;; We update the level very gently. In fact, we
16709 ;; only change it if there's been a status change
16710 ;; from subscribed to unsubscribed, or vice versa.
16711 (setq level
(gnus-info-level info
))
16712 (cond ((and (<= level gnus-level-subscribed
)
16714 (setq level
(if reads
16715 gnus-level-default-unsubscribed
16716 (1+ gnus-level-default-unsubscribed
))))
16717 ((and (> level gnus-level-subscribed
) subscribed
)
16718 (setq level gnus-level-default-subscribed
)))
16719 (gnus-info-set-level info level
))
16720 ;; This is a new group.
16721 (setq info
(list group
16723 gnus-level-default-subscribed
16725 (1+ gnus-level-subscribed
)
16726 gnus-level-default-unsubscribed
))
16727 (nreverse reads
))))
16728 (setq newsrc
(cons info newsrc
))))))
16731 (setq newsrc
(nreverse newsrc
))
16733 (if (not already-read
)
16735 ;; We now have two newsrc lists - `newsrc', which is what we
16736 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16737 ;; what we've read from .newsrc.eld. We have to merge these
16738 ;; lists. We do this by "attaching" any (foreign) groups in the
16739 ;; gnus-newsrc-alist to the (native) group that precedes them.
16740 (let ((rc (cdr gnus-newsrc-alist
))
16741 (prev gnus-newsrc-alist
)
16744 (or (null (nth 4 (car rc
))) ; It's a native group.
16745 (assoc (caar rc
) newsrc
) ; It's already in the alist.
16746 (if (setq entry
(assoc (caar prev
) newsrc
))
16747 (setcdr (setq mentry
(memq entry newsrc
))
16748 (cons (car rc
) (cdr mentry
)))
16749 (setq newsrc
(cons (car rc
) newsrc
))))
16753 (setq gnus-newsrc-alist newsrc
)
16754 ;; We make the newsrc hashtb.
16755 (gnus-make-hashtable-from-newsrc-alist)
16757 ;; Finally, if we read some options lines, we parse them.
16758 (or (string= gnus-newsrc-options
"")
16759 (gnus-newsrc-parse-options gnus-newsrc-options
))))
16761 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16762 ;; The return value will be a list on the form
16763 ;; ((regexp1 . ignore)
16764 ;; (regexp2 . subscribe)...)
16765 ;; When handling new newsgroups, groups that match a `ignore' regexp
16766 ;; will be ignored, and groups that match a `subscribe' regexp will be
16767 ;; subscribed. A line like
16768 ;; options -n !all rec.all
16769 ;; will lead to a list that looks like
16770 ;; (("^rec\\..+" . subscribe)
16771 ;; ("^.+" . ignore))
16772 ;; So all "rec.*" groups will be subscribed, while all the other
16773 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16774 ;; different from "options -n rec.all !all".
16775 (defun gnus-newsrc-parse-options (options)
16778 (gnus-set-work-buffer)
16779 (insert (regexp-quote options
))
16780 ;; First we treat all continuation lines.
16781 (goto-char (point-min))
16782 (while (re-search-forward "\n[ \t]+" nil t
)
16783 (replace-match " " t t
))
16784 ;; Then we transform all "all"s into ".+"s.
16785 (goto-char (point-min))
16786 (while (re-search-forward "\\ball\\b" nil t
)
16787 (replace-match ".+" t t
))
16788 (goto-char (point-min))
16789 ;; We remove all other options than the "-n" ones.
16790 (while (re-search-forward "[ \t]-[^n][^-]*" nil t
)
16791 (replace-match " ")
16793 (goto-char (point-min))
16795 ;; We are only interested in "options -n" lines - we
16796 ;; ignore the other option lines.
16797 (while (re-search-forward "[ \t]-n" nil t
)
16799 (or (save-excursion
16800 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t
)
16802 (gnus-point-at-eol)))
16803 ;; Search for all "words"...
16804 (while (re-search-forward "[^ \t,\n]+" eol t
)
16805 (if (= (char-after (match-beginning 0)) ?
!)
16806 ;; If the word begins with a bang (!), this is a "not"
16807 ;; spec. We put this spec (minus the bang) and the
16808 ;; symbol `ignore' into the list.
16809 (setq out
(cons (cons (concat
16810 "^" (buffer-substring
16811 (1+ (match-beginning 0))
16814 ;; There was no bang, so this is a "yes" spec.
16815 (setq out
(cons (cons (concat "^" (match-string 0))
16816 'subscribe
) out
)))))
16818 (setq gnus-newsrc-options-n out
))))
16820 (defun gnus-save-newsrc-file (&optional force
)
16821 "Save .newsrc file."
16822 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16823 ;; from the variable gnus-newsrc-alist.
16824 (when (and (or gnus-newsrc-alist gnus-killed-list
)
16825 gnus-current-startup-file
)
16827 (if (and (or gnus-use-dribble-file gnus-slave
)
16829 (or (not gnus-dribble-buffer
)
16830 (not (buffer-name gnus-dribble-buffer
))
16831 (zerop (save-excursion
16832 (set-buffer gnus-dribble-buffer
)
16834 (gnus-message 4 "(No changes need to be saved)")
16835 (run-hooks 'gnus-save-newsrc-hook
)
16837 (gnus-slave-save-newsrc)
16839 (when gnus-save-newsrc-file
16840 (gnus-message 5 "Saving %s..." gnus-current-startup-file
)
16841 (gnus-gnus-to-newsrc-format)
16842 (gnus-message 5 "Saving %s...done" gnus-current-startup-file
))
16843 ;; Save .newsrc.eld.
16844 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16845 (make-local-variable 'version-control
)
16846 (setq version-control
'never
)
16847 (setq buffer-file-name
16848 (concat gnus-current-startup-file
".eld"))
16849 (setq default-directory
(file-name-directory buffer-file-name
))
16850 (gnus-add-current-to-buffer-list)
16851 (buffer-disable-undo (current-buffer))
16853 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file
)
16854 (gnus-gnus-to-quick-newsrc-format)
16855 (run-hooks 'gnus-save-quick-newsrc-hook
)
16857 (kill-buffer (current-buffer))
16859 5 "Saving %s.eld...done" gnus-current-startup-file
))
16860 (gnus-dribble-delete-file)
16861 (gnus-group-set-mode-line)))))
16863 (defun gnus-gnus-to-quick-newsrc-format ()
16864 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16865 (insert ";; Gnus startup file.\n")
16866 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16867 (insert ";; to read .newsrc.\n")
16868 (insert "(setq gnus-newsrc-file-version "
16869 (prin1-to-string gnus-version
) ")\n")
16871 (if gnus-save-killed-list gnus-variable-list
16872 ;; Remove the `gnus-killed-list' from the list of variables
16873 ;; to be saved, if required.
16874 (delq 'gnus-killed-list
(copy-sequence gnus-variable-list
))))
16875 ;; Peel off the "dummy" group.
16876 (gnus-newsrc-alist (cdr gnus-newsrc-alist
))
16878 ;; Insert the variables into the file.
16880 (when (and (boundp (setq variable
(pop variables
)))
16881 (symbol-value variable
))
16882 (insert "(setq " (symbol-name variable
) " '")
16883 (prin1 (symbol-value variable
) (current-buffer))
16886 (defun gnus-gnus-to-newsrc-format ()
16887 ;; Generate and save the .newsrc file.
16889 (set-buffer (create-file-buffer gnus-current-startup-file
))
16890 (let ((newsrc (cdr gnus-newsrc-alist
))
16891 (standard-output (current-buffer))
16892 info ranges range method
)
16893 (setq buffer-file-name gnus-current-startup-file
)
16894 (setq default-directory
(file-name-directory buffer-file-name
))
16895 (buffer-disable-undo (current-buffer))
16898 (if gnus-newsrc-options
(insert gnus-newsrc-options
))
16899 ;; Write subscribed and unsubscribed.
16900 (while (setq info
(pop newsrc
))
16901 ;; Don't write foreign groups to .newsrc.
16902 (when (or (null (setq method
(gnus-info-method info
)))
16903 (equal method
"native")
16904 (gnus-server-equal method gnus-select-method
))
16905 (insert (gnus-info-group info
)
16906 (if (> (gnus-info-level info
) gnus-level-subscribed
)
16908 (when (setq ranges
(gnus-info-read info
))
16910 (if (not (listp (cdr ranges
)))
16911 (if (= (car ranges
) (cdr ranges
))
16912 (princ (car ranges
))
16913 (princ (car ranges
))
16915 (princ (cdr ranges
)))
16916 (while (setq range
(pop ranges
))
16917 (if (or (atom range
) (= (car range
) (cdr range
)))
16918 (princ (or (and (atom range
) range
) (car range
)))
16919 (princ (car range
))
16921 (princ (cdr range
)))
16922 (if ranges
(insert ",")))))
16924 (make-local-variable 'version-control
)
16925 (setq version-control
'never
)
16926 ;; It has been reported that sometime the modtime on the .newsrc
16927 ;; file seems to be off. We really do want to overwrite it, so
16928 ;; we clear the modtime here before saving. It's a bit odd,
16930 ;; sometimes the modtime clear isn't sufficient. most brute force:
16931 ;; delete the silly thing entirely first. but this fails to provide
16932 ;; such niceties as .newsrc~ creation.
16933 (if gnus-modtime-botch
16934 (delete-file gnus-startup-file
)
16935 (clear-visited-file-modtime))
16936 (run-hooks 'gnus-save-standard-newsrc-hook
)
16938 (kill-buffer (current-buffer)))))
16942 ;;; Slave functions.
16945 (defun gnus-slave-save-newsrc ()
16947 (set-buffer gnus-dribble-buffer
)
16949 (make-temp-name (concat gnus-current-startup-file
"-slave-"))))
16950 (write-region (point-min) (point-max) slave-name nil
'nomesg
))))
16952 (defun gnus-master-read-slave-newsrc ()
16955 (file-name-directory gnus-current-startup-file
)
16959 (file-name-nondirectory gnus-current-startup-file
)
16963 (if (not slave-files
)
16964 () ; There are no slave files to read.
16965 (gnus-message 7 "Reading slave newsrcs...")
16967 (set-buffer (get-buffer-create " *gnus slave*"))
16968 (buffer-disable-undo (current-buffer))
16970 (sort (mapcar (lambda (file)
16971 (list (nth 5 (file-attributes file
)) file
))
16974 (or (< (caar f1
) (caar f2
))
16975 (< (nth 1 (car f1
)) (nth 1 (car f2
)))))))
16978 (setq file
(nth 1 (car slave-files
)))
16979 (insert-file-contents file
)
16980 (if (condition-case ()
16982 (eval-buffer (current-buffer))
16985 (gnus-error 3.2 "Possible error in %s" file
)
16987 (or gnus-slave
; Slaves shouldn't delete these files.
16991 (setq slave-files
(cdr slave-files
))))
16992 (gnus-message 7 "Reading slave newsrcs...done"))))
16996 ;;; Group description.
16999 (defun gnus-read-all-descriptions-files ()
17000 (let ((methods (cons gnus-select-method
17002 (when gnus-message-archive-method
17004 gnus-secondary-select-methods
))))
17006 (gnus-read-descriptions-file (car methods
))
17007 (setq methods
(cdr methods
)))
17010 (defun gnus-read-descriptions-file (&optional method
)
17011 (let ((method (or method gnus-select-method
))
17013 (when (stringp method
)
17014 (setq method
(gnus-server-to-method method
)))
17015 ;; We create the hashtable whether we manage to read the desc file
17016 ;; to avoid trying to re-read after a failed read.
17017 (or gnus-description-hashtb
17018 (setq gnus-description-hashtb
17019 (gnus-make-hashtable (length gnus-active-hashtb
))))
17020 ;; Mark this method's desc file as read.
17021 (gnus-sethash (gnus-group-prefixed-name "" method
) "Has read"
17022 gnus-description-hashtb
)
17024 (gnus-message 5 "Reading descriptions file via %s..." (car method
))
17026 ((not (gnus-check-server method
))
17027 (gnus-message 1 "Couldn't open server")
17029 ((not (gnus-request-list-newsgroups method
))
17030 (gnus-message 1 "Couldn't read newsgroups descriptions")
17035 (set-buffer nntp-server-buffer
)
17036 (goto-char (point-min))
17037 (when (or (search-forward "\n.\n" nil t
)
17038 (goto-char (point-max)))
17039 (beginning-of-line)
17040 (narrow-to-region (point-min) (point)))
17041 ;; If these are groups from a foreign select method, we insert the
17042 ;; group prefix in front of the group names.
17043 (and method
(not (gnus-server-equal
17044 (gnus-server-get-method nil method
)
17045 (gnus-server-get-method nil gnus-select-method
)))
17046 (let ((prefix (gnus-group-prefixed-name "" method
)))
17047 (goto-char (point-min))
17048 (while (and (not (eobp))
17049 (progn (insert prefix
)
17050 (zerop (forward-line 1)))))))
17051 (goto-char (point-min))
17052 (while (not (eobp))
17053 ;; If we get an error, we set group to 0, which is not a
17057 (let ((obarray gnus-description-hashtb
))
17058 ;; Group is set to a symbol interned in this
17060 (read nntp-server-buffer
))
17062 (skip-chars-forward " \t")
17063 ;; ... which leads to this line being effectively ignored.
17064 (and (symbolp group
)
17065 (set group
(buffer-substring
17066 (point) (progn (end-of-line) (point)))))
17067 (forward-line 1))))
17068 (gnus-message 5 "Reading descriptions file...done")
17071 (defun gnus-group-get-description (group)
17072 "Get the description of a group by sending XGTITLE to the server."
17073 (when (gnus-request-group-description group
)
17075 (set-buffer nntp-server-buffer
)
17076 (goto-char (point-min))
17077 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17078 (match-string 1)))))
17082 ;;; Buffering of read articles.
17085 (defvar gnus-backlog-buffer
" *Gnus Backlog*")
17086 (defvar gnus-backlog-articles nil
)
17087 (defvar gnus-backlog-hashtb nil
)
17089 (defun gnus-backlog-buffer ()
17090 "Return the backlog buffer."
17091 (or (get-buffer gnus-backlog-buffer
)
17093 (set-buffer (get-buffer-create gnus-backlog-buffer
))
17094 (buffer-disable-undo (current-buffer))
17095 (setq buffer-read-only t
)
17096 (gnus-add-current-to-buffer-list)
17097 (get-buffer gnus-backlog-buffer
))))
17099 (defun gnus-backlog-setup ()
17100 "Initialize backlog variables."
17101 (unless gnus-backlog-hashtb
17102 (setq gnus-backlog-hashtb
(make-vector 1023 0))))
17104 (gnus-add-shutdown 'gnus-backlog-shutdown
'gnus
)
17106 (defun gnus-backlog-shutdown ()
17107 "Clear all backlog variables and buffers."
17108 (when (get-buffer gnus-backlog-buffer
)
17109 (kill-buffer gnus-backlog-buffer
))
17110 (setq gnus-backlog-hashtb nil
17111 gnus-backlog-articles nil
))
17113 (defun gnus-backlog-enter-article (group number buffer
)
17114 (gnus-backlog-setup)
17115 (let ((ident (intern (concat group
":" (int-to-string number
))
17116 gnus-backlog-hashtb
))
17118 (if (memq ident gnus-backlog-articles
)
17119 () ; It's already kept.
17120 ;; Remove the oldest article, if necessary.
17121 (and (numberp gnus-keep-backlog
)
17122 (>= (length gnus-backlog-articles
) gnus-keep-backlog
)
17123 (gnus-backlog-remove-oldest-article))
17124 (setq gnus-backlog-articles
(cons ident gnus-backlog-articles
))
17125 ;; Insert the new article.
17127 (set-buffer (gnus-backlog-buffer))
17128 (let (buffer-read-only)
17129 (goto-char (point-max))
17130 (or (bolp) (insert "\n"))
17132 (insert-buffer-substring buffer
)
17133 ;; Tag the beginning of the article with the ident.
17134 (gnus-put-text-property b
(1+ b
) 'gnus-backlog ident
))))))
17136 (defun gnus-backlog-remove-oldest-article ()
17138 (set-buffer (gnus-backlog-buffer))
17139 (goto-char (point-min))
17140 (if (zerop (buffer-size))
17141 () ; The buffer is empty.
17142 (let ((ident (get-text-property (point) 'gnus-backlog
))
17144 ;; Remove the ident from the list of articles.
17146 (setq gnus-backlog-articles
(delq ident gnus-backlog-articles
)))
17147 ;; Delete the article itself.
17149 (point) (next-single-property-change
17150 (1+ (point)) 'gnus-backlog nil
(point-max)))))))
17152 (defun gnus-backlog-remove-article (group number
)
17153 "Remove article NUMBER in GROUP from the backlog."
17154 (when (numberp number
)
17155 (gnus-backlog-setup)
17156 (let ((ident (intern (concat group
":" (int-to-string number
))
17157 gnus-backlog-hashtb
))
17159 (when (memq ident gnus-backlog-articles
)
17160 ;; It was in the backlog.
17162 (set-buffer (gnus-backlog-buffer))
17163 (let (buffer-read-only)
17164 (when (setq beg
(text-property-any
17165 (point-min) (point-max) 'gnus-backlog
17167 ;; Find the end (i. e., the beginning of the next article).
17169 (next-single-property-change
17170 (1+ beg
) 'gnus-backlog
(current-buffer) (point-max)))
17171 (delete-region beg end
)
17175 (defun gnus-backlog-request-article (group number buffer
)
17176 (when (numberp number
)
17177 (gnus-backlog-setup)
17178 (let ((ident (intern (concat group
":" (int-to-string number
))
17179 gnus-backlog-hashtb
))
17181 (when (memq ident gnus-backlog-articles
)
17182 ;; It was in the backlog.
17184 (set-buffer (gnus-backlog-buffer))
17185 (if (not (setq beg
(text-property-any
17186 (point-min) (point-max) 'gnus-backlog
17188 ;; It wasn't in the backlog after all.
17190 (setq gnus-backlog-articles
(delq ident gnus-backlog-articles
)))
17191 ;; Find the end (i. e., the beginning of the next article).
17193 (next-single-property-change
17194 (1+ beg
) 'gnus-backlog
(current-buffer) (point-max)))))
17195 (let ((buffer-read-only nil
))
17197 (insert-buffer-substring gnus-backlog-buffer beg end
)
17200 ;; Allow redefinition of Gnus functions.
17202 (gnus-ems-redefine)
17206 ;;; gnus.el ends here