1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 (eval '(run-hooks 'gnus-load-hook))
34 (eval-when-compile (require 'cl))
36 ;; Site dependent variables. These variables should be defined in
39 (defvar gnus-default-nntp-server nil
40 "Specify a default NNTP server.
41 This variable should be defined in paths.el, and should never be set
43 If you want to change servers, you should use `gnus-select-method'.
44 See the documentation to that variable.")
46 (defvar gnus-backup-default-subscribed-newsgroups
47 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
48 "Default default new newsgroups the first time Gnus is run.
49 Should be set in paths.el, and shouldn't be touched by the user.")
51 (defvar gnus-local-domain nil
52 "Local domain name without a host name.
53 The DOMAINNAME environment variable is used instead if it is defined.
54 If the `system-name' function returns the full Internet name, there is
55 no need to set this variable.")
57 (defvar gnus-local-organization nil
58 "String with a description of what organization (if any) the user belongs to.
59 The ORGANIZATION environment variable is used instead if it is defined.
60 If this variable contains a function, this function will be called
61 with the current newsgroup name as the argument. The function should
64 In any case, if the string (either in the variable, in the environment
65 variable, or returned by the function) is a file name, the contents of
66 this file will be used as the organization.")
68 (defvar gnus-use-generic-from nil
69 "If nil, the full host name will be the system name prepended to the domain name.
70 If this is a string, the full host name will be this string.
71 If this is non-nil, non-string, the domain name will be used as the
74 (defvar gnus-use-generic-path nil
75 "If nil, use the NNTP server name in the Path header.
76 If stringp, use this; if non-nil, use no host name (user name only).")
78 ;; Customization variables
80 ;; Don't touch this variable.
81 (defvar gnus-nntp-service "nntp"
82 "*NNTP service name (\"nntp\" or 119).
83 This is an obsolete variable, which is scarcely used. If you use an
84 nntp server for your newsgroup and want to change the port number
85 used to 899, you would say something along these lines:
87 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
89 (defvar gnus-nntpserver-file "/etc/nntpserver"
90 "*A file with only the name of the nntp server in it.")
92 ;; This function is used to check both the environment variable
93 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
94 ;; an nntp server name default.
95 (defun gnus-getenv-nntpserver ()
96 (or (getenv "NNTPSERVER")
97 (and (file-readable-p gnus-nntpserver-file)
99 (set-buffer (get-buffer-create " *gnus nntp*"))
100 (buffer-disable-undo (current-buffer))
101 (insert-file-contents gnus-nntpserver-file)
102 (let ((name (buffer-string)))
104 (if (string-match "^[ \t\n]*$" name)
107 (kill-buffer (current-buffer))))))))
109 (defvar gnus-select-method
111 (list 'nntp (or (condition-case ()
112 (gnus-getenv-nntpserver)
114 (if (and gnus-default-nntp-server
115 (not (string= gnus-default-nntp-server "")))
116 gnus-default-nntp-server)
118 (if (or (null gnus-nntp-service)
119 (equal gnus-nntp-service "nntp"))
121 (list gnus-nntp-service)))
122 "*Default method for selecting a newsgroup.
123 This variable should be a list, where the first element is how the
124 news is to be fetched, the second is the address.
126 For instance, if you want to get your news via NNTP from
127 \"flab.flab.edu\", you could say:
129 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
131 If you want to use your local spool, say:
133 (setq gnus-select-method (list 'nnspool (system-name)))
135 If you use this variable, you must set `gnus-nntp-server' to nil.
137 There is a lot more to know about select methods and virtual servers -
138 see the manual for details.")
140 (defvar gnus-message-archive-method
141 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
142 (nnfolder-active-file "~/Mail/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 (defvar gnus-refer-article-method nil
149 "*Preferred method for fetching an article by Message-ID.
150 If you are reading news from the local spool (with nnspool), fetching
151 articles by Message-ID is painfully slow. By setting this method to an
152 nntp method, you might get acceptable results.
154 The value of this variable must be a valid select method as discussed
155 in the documentation of `gnus-select-method'.")
157 (defvar gnus-secondary-select-methods nil
158 "*A list of secondary methods that will be used for reading news.
159 This is a list where each element is a complete select method (see
160 `gnus-select-method').
162 If, for instance, you want to read your mail with the nnml backend,
163 you could set this variable:
165 (setq gnus-secondary-select-methods '((nnml \"\")))")
167 (defvar gnus-secondary-servers nil
168 "*List of NNTP servers that the user can choose between interactively.
169 To make Gnus query you for a server, you have to give `gnus' a
170 non-numeric prefix - `C-u M-x gnus', in short.")
172 (defvar gnus-nntp-server nil
173 "*The name of the host running the NNTP server.
174 This variable is semi-obsolete. Use the `gnus-select-method'
177 (defvar gnus-startup-file "~/.newsrc"
178 "*Your `.newsrc' file.
179 `.newsrc-SERVER' will be used instead if that exists.")
181 (defvar gnus-init-file "~/.gnus"
182 "*Your Gnus elisp startup file.
183 If a file with the .el or .elc suffixes exist, it will be read
186 (defvar gnus-group-faq-directory
187 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
188 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
189 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
190 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
191 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
192 "/ftp@ftp.sunet.se:/pub/usenet/"
193 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
194 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
195 "/ftp@ftp.hk.super.net:/mirror/faqs/")
196 "*Directory where the group FAQs are stored.
197 This will most commonly be on a remote machine, and the file will be
200 This variable can also be a list of directories. In that case, the
201 first element in the list will be used by default, and the others will
202 be used as backup sites.
204 Note that Gnus uses an aol machine as the default directory. If this
205 feels fundamentally unclean, just think of it as a way to finally get
206 something of value back from them.
208 If the default site is too slow, try one of these:
210 North America: mirrors.aol.com /pub/rtfm/usenet
211 ftp.seas.gwu.edu /pub/rtfm
212 rtfm.mit.edu /pub/usenet/news.answers
213 Europe: ftp.uni-paderborn.de /pub/FAQ
214 src.doc.ic.ac.uk /usenet/news-FAQS
215 ftp.sunet.se /pub/usenet
216 Asia: nctuccca.edu.tw /USENET/FAQ
217 hwarang.postech.ac.kr /pub/usenet/news.answers
218 ftp.hk.super.net /mirror/faqs")
220 (defvar gnus-group-archive-directory
221 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
222 "*The address of the (ding) archives.")
224 (defvar gnus-group-recent-archive-directory
225 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
226 "*The address of the most recent (ding) articles.")
228 (defvar gnus-default-subscribed-newsgroups nil
229 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
230 It should be a list of strings.
231 If it is `t', Gnus will not do anything special the first time it is
232 started; it'll just use the normal newsgroups subscription methods.")
234 (defvar gnus-use-cross-reference t
235 "*Non-nil means that cross referenced articles will be marked as read.
236 If nil, ignore cross references. If t, mark articles as read in
237 subscribed newsgroups. If neither t nor nil, mark as read in all
240 (defvar gnus-single-article-buffer t
241 "*If non-nil, display all articles in the same buffer.
242 If nil, each group will get its own article buffer.")
244 (defvar gnus-use-dribble-file t
245 "*Non-nil means that Gnus will use a dribble file to store user updates.
246 If Emacs should crash without saving the .newsrc files, complete
247 information can be restored from the dribble file.")
249 (defvar gnus-dribble-directory nil
250 "*The directory where dribble files will be saved.
251 If this variable is nil, the directory where the .newsrc files are
252 saved will be used.")
254 (defvar gnus-asynchronous nil
255 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
257 (defvar gnus-kill-summary-on-exit t
258 "*If non-nil, kill the summary buffer when you exit from it.
259 If nil, the summary will become a \"*Dead Summary*\" buffer, and
260 it will be killed sometime later.")
262 (defvar gnus-large-newsgroup 200
263 "*The number of articles which indicates a large newsgroup.
264 If the number of articles in a newsgroup is greater than this value,
265 confirmation is required for selecting the newsgroup.")
267 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
268 (defvar gnus-no-groups-message "No news is horrible news"
269 "*Message displayed by Gnus when no groups are available.")
271 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
272 "*Non-nil means that the default name of a file to save articles in is the group name.
273 If it's nil, the directory form of the group name is used instead.
275 If this variable is a list, and the list contains the element
276 `not-score', long file names will not be used for score files; if it
277 contains the element `not-save', long file names will not be used for
278 saving; and if it contains the element `not-kill', long file names
279 will not be used for kill files.")
281 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
282 "*Name of the directory articles will be saved in (default \"~/News\").
283 Initialized from the SAVEDIR environment variable.")
285 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
286 "*Name of the directory where kill files will be stored (default \"~/News\").
287 Initialized from the SAVEDIR environment variable.")
289 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
290 "*A function to save articles in your favorite format.
291 The function must be interactively callable (in other words, it must
292 be an Emacs command).
294 Gnus provides the following functions:
296 * gnus-summary-save-in-rmail (Rmail format)
297 * gnus-summary-save-in-mail (Unix mail format)
298 * gnus-summary-save-in-folder (MH folder)
299 * gnus-summary-save-in-file (article format).
300 * gnus-summary-save-in-vm (use VM's folder format).")
302 (defvar gnus-prompt-before-saving 'always
303 "*This variable says how much prompting is to be done when saving articles.
304 If it is nil, no prompting will be done, and the articles will be
305 saved to the default files. If this variable is `always', each and
306 every article that is saved will be preceded by a prompt, even when
307 saving large batches of articles. If this variable is neither nil not
308 `always', there the user will be prompted once for a file name for
309 each invocation of the saving commands.")
311 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
312 "*A function generating a file name to save articles in Rmail format.
313 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
315 (defvar gnus-mail-save-name (function gnus-plain-save-name)
316 "*A function generating a file name to save articles in Unix mail format.
317 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
319 (defvar gnus-folder-save-name (function gnus-folder-save-name)
320 "*A function generating a file name to save articles in MH folder.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
323 (defvar gnus-file-save-name (function gnus-numeric-save-name)
324 "*A function generating a file name to save articles in article format.
325 The function is called with NEWSGROUP, HEADERS, and optional
328 (defvar gnus-split-methods
329 '((gnus-article-archive-name))
330 "*Variable used to suggest where articles are to be saved.
331 For instance, if you would like to save articles related to Gnus in
332 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
333 you could set this variable to something like:
335 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
336 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
338 This variable is an alist where the where the key is the match and the
339 value is a list of possible files to save in if the match is non-nil.
341 If the match is a string, it is used as a regexp match on the
342 article. If the match is a symbol, that symbol will be funcalled
343 from the buffer of the article to be saved with the newsgroup as the
344 parameter. If it is a list, it will be evaled in the same buffer.
346 If this form or function returns a string, this string will be used as
347 a possible file name; and if it returns a non-nil list, that list will
348 be used as possible file names.")
350 (defvar gnus-move-split-methods nil
351 "*Variable used to suggest where articles are to be moved to.
352 It uses the same syntax as the `gnus-split-methods' variable.")
354 (defvar gnus-save-score nil
355 "*If non-nil, save group scoring info.")
357 (defvar gnus-use-adaptive-scoring nil
358 "*If non-nil, use some adaptive scoring scheme.")
360 (defvar gnus-use-cache nil
361 "*If nil, Gnus will ignore the article cache.
362 If `passive', it will allow entering (and reading) articles
363 explicitly entered into the cache. If anything else, use the
364 cache to the full extent of the law.")
366 (defvar gnus-use-trees nil
367 "*If non-nil, display a thread tree buffer.")
369 (defvar gnus-use-grouplens nil
370 "*If non-nil, use GroupLens ratings.")
372 (defvar gnus-keep-backlog nil
373 "*If non-nil, Gnus will keep read articles for later re-retrieval.
374 If it is a number N, then Gnus will only keep the last N articles
375 read. If it is neither nil nor a number, Gnus will keep all read
376 articles. This is not a good idea.")
378 (defvar gnus-use-nocem nil
379 "*If non-nil, Gnus will read NoCeM cancel messages.")
381 (defvar gnus-use-demon nil
382 "If non-nil, Gnus might use some demons.")
384 (defvar gnus-use-scoring t
385 "*If non-nil, enable scoring.")
387 (defvar gnus-use-picons nil
388 "*If non-nil, display picons.")
390 (defvar gnus-fetch-old-headers nil
391 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
392 If an unread article in the group refers to an older, already read (or
393 just marked as read) article, the old article will not normally be
394 displayed in the Summary buffer. If this variable is non-nil, Gnus
395 will attempt to grab the headers to the old articles, and thereby
396 build complete threads. If it has the value `some', only enough
397 headers to connect otherwise loose threads will be displayed.
398 This variable can also be a number. In that case, no more than that
399 number of old headers will be fetched.
401 The server has to support NOV for any of this to work.")
404 ;(defvar gnus-visual t
405 ; "*If non-nil, will do various highlighting.
406 ;If nil, no mouse highlights (or any other highlights) will be
407 ;performed. This might speed up Gnus some when generating large group
408 ;and summary buffers.")
410 (defvar gnus-novice-user t
411 "*Non-nil means that you are a usenet novice.
412 If non-nil, verbose messages may be displayed and confirmations may be
415 (defvar gnus-expert-user nil
416 "*Non-nil means that you will never be asked for confirmation about anything.
417 And that means *anything*.")
419 (defvar gnus-verbose 7
420 "*Integer that says how verbose Gnus should be.
421 The higher the number, the more messages Gnus will flash to say what
422 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
423 display most important messages; and at ten, Gnus will keep on
424 jabbering all the time.")
426 (defvar gnus-keep-same-level nil
427 "*Non-nil means that the next newsgroup after the current will be on the same level.
428 When you type, for instance, `n' after reading the last article in the
429 current newsgroup, you will go to the next newsgroup. If this variable
430 is nil, the next newsgroup will be the next from the group
432 If this variable is non-nil, Gnus will either put you in the
433 next newsgroup with the same level, or, if no such newsgroup is
434 available, the next newsgroup with the lowest possible level higher
435 than the current level.
436 If this variable is `best', Gnus will make the next newsgroup the one
437 with the best level.")
439 (defvar gnus-summary-make-false-root 'adopt
440 "*nil means that Gnus won't gather loose threads.
441 If the root of a thread has expired or been read in a previous
442 session, the information necessary to build a complete thread has been
443 lost. Instead of having many small sub-threads from this original thread
444 scattered all over the summary buffer, Gnus can gather them.
446 If non-nil, Gnus will try to gather all loose sub-threads from an
447 original thread into one large thread.
449 If this variable is non-nil, it should be one of `none', `adopt',
452 If this variable is `none', Gnus will not make a false root, but just
453 present the sub-threads after another.
454 If this variable is `dummy', Gnus will create a dummy root that will
455 have all the sub-threads as children.
456 If this variable is `adopt', Gnus will make one of the \"children\"
457 the parent and mark all the step-children as such.
458 If this variable is `empty', the \"children\" are printed with empty
459 subject fields. (Or rather, they will be printed with a string
460 given by the `gnus-summary-same-subject' variable.)")
462 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
463 "*A regexp to match subjects to be excluded from loose thread gathering.
464 As loose thread gathering is done on subjects only, that means that
465 there can be many false gatherings performed. By rooting out certain
466 common subjects, gathering might become saner.")
468 (defvar gnus-summary-gather-subject-limit nil
469 "*Maximum length of subject comparisons when gathering loose threads.
470 Use nil to compare full subjects. Setting this variable to a low
471 number will help gather threads that have been corrupted by
472 newsreaders chopping off subject lines, but it might also mean that
473 unrelated articles that have subject that happen to begin with the
474 same few characters will be incorrectly gathered.
476 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
477 comparing subjects.")
479 (defvar gnus-simplify-ignored-prefixes nil
480 "*Regexp, matches for which are removed from subject lines when simplifying.")
482 (defvar gnus-build-sparse-threads nil
483 "*If non-nil, fill in the gaps in threads.
484 If `some', only fill in the gaps that are needed to tie loose threads
485 together. If `more', fill in all leaf nodes that Gnus can find. If
486 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
488 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
489 "Function used for gathering loose threads.
490 There are two pre-defined functions: `gnus-gather-threads-by-subject',
491 which only takes Subjects into consideration; and
492 `gnus-gather-threads-by-references', which compared the References
493 headers of the articles to find matches.")
495 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
496 (defvar gnus-summary-same-subject ""
497 "*String indicating that the current article has the same subject as the previous.
498 This variable will only be used if the value of
499 `gnus-summary-make-false-root' is `empty'.")
501 (defvar gnus-summary-goto-unread t
502 "*If non-nil, marking commands will go to the next unread article.
503 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
504 whether it is read or not.")
506 (defvar gnus-group-goto-unread t
507 "*If non-nil, movement commands will go to the next unread and subscribed group.")
509 (defvar gnus-goto-next-group-when-activating t
510 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
512 (defvar gnus-check-new-newsgroups t
513 "*Non-nil means that Gnus will add new newsgroups at startup.
514 If this variable is `ask-server', Gnus will ask the server for new
515 groups since the last time it checked. This means that the killed list
516 is no longer necessary, so you could set `gnus-save-killed-list' to
519 A variant is to have this variable be a list of select methods. Gnus
520 will then use the `ask-server' method on all these select methods to
521 query for new groups from all those servers.
524 (setq gnus-check-new-newsgroups
525 '((nntp \"some.server\") (nntp \"other.server\")))
527 If this variable is nil, then you have to tell Gnus explicitly to
528 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
530 (defvar gnus-check-bogus-newsgroups nil
531 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
532 If this variable is nil, then you have to tell Gnus explicitly to
533 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
535 (defvar gnus-read-active-file t
536 "*Non-nil means that Gnus will read the entire active file at startup.
537 If this variable is nil, Gnus will only know about the groups in your
540 If this variable is `some', Gnus will try to only read the relevant
541 parts of the active file from the server. Not all servers support
542 this, and it might be quite slow with other servers, but this should
543 generally be faster than both the t and nil value.
545 If you set this variable to nil or `some', you probably still want to
546 be told about new newsgroups that arrive. To do that, set
547 `gnus-check-new-newsgroups' to `ask-server'. This may not work
548 properly with all servers.")
550 (defvar gnus-level-subscribed 5
551 "*Groups with levels less than or equal to this variable are subscribed.")
553 (defvar gnus-level-unsubscribed 7
554 "*Groups with levels less than or equal to this variable are unsubscribed.
555 Groups with levels less than `gnus-level-subscribed', which should be
556 less than this variable, are subscribed.")
558 (defvar gnus-level-zombie 8
559 "*Groups with this level are zombie groups.")
561 (defvar gnus-level-killed 9
562 "*Groups with this level are killed.")
564 (defvar gnus-level-default-subscribed 3
565 "*New subscribed groups will be subscribed at this level.")
567 (defvar gnus-level-default-unsubscribed 6
568 "*New unsubscribed groups will be unsubscribed at this level.")
570 (defvar gnus-activate-level (1+ gnus-level-subscribed)
571 "*Groups higher than this level won't be activated on startup.
572 Setting this variable to something log might save lots of time when
573 you have many groups that you aren't interested in.")
575 (defvar gnus-activate-foreign-newsgroups 4
576 "*If nil, Gnus will not check foreign newsgroups at startup.
577 If it is non-nil, it should be a number between one and nine. Foreign
578 newsgroups that have a level lower or equal to this number will be
579 activated on startup. For instance, if you want to active all
580 subscribed newsgroups, but not the rest, you'd set this variable to
581 `gnus-level-subscribed'.
583 If you subscribe to lots of newsgroups from different servers, startup
584 might take a while. By setting this variable to nil, you'll save time,
585 but you won't be told how many unread articles there are in the
588 (defvar gnus-save-newsrc-file t
589 "*Non-nil means that Gnus will save the `.newsrc' file.
590 Gnus always saves its own startup file, which is called
591 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
592 be readily understood by other newsreaders. If you don't plan on
593 using other newsreaders, set this variable to nil to save some time on
596 (defvar gnus-save-killed-list t
597 "*If non-nil, save the list of killed groups to the startup file.
598 If you set this variable to nil, you'll save both time (when starting
599 and quitting) and space (both memory and disk), but it will also mean
600 that Gnus has no record of which groups are new and which are old, so
601 the automatic new newsgroups subscription methods become meaningless.
603 You should always set `gnus-check-new-newsgroups' to `ask-server' or
604 nil if you set this variable to nil.")
606 (defvar gnus-interactive-catchup t
607 "*If non-nil, require your confirmation when catching up a group.")
609 (defvar gnus-interactive-post t
610 "*If non-nil, group name will be asked for when posting.")
612 (defvar gnus-interactive-exit t
613 "*If non-nil, require your confirmation when exiting Gnus.")
615 (defvar gnus-kill-killed t
616 "*If non-nil, Gnus will apply kill files to already killed articles.
617 If it is nil, Gnus will never apply kill files to articles that have
618 already been through the scoring process, which might very well save lots
621 (defvar gnus-extract-address-components 'gnus-extract-address-components
622 "*Function for extracting address components from a From header.
623 Two pre-defined function exist: `gnus-extract-address-components',
624 which is the default, quite fast, and too simplistic solution, and
625 `mail-extract-address-components', which works much better, but is
628 (defvar gnus-summary-default-score 0
629 "*Default article score level.
630 If this variable is nil, scoring will be disabled.")
632 (defvar gnus-summary-zcore-fuzz 0
633 "*Fuzziness factor for the zcore in the summary buffer.
634 Articles with scores closer than this to `gnus-summary-default-score'
635 will not be marked.")
637 (defvar gnus-simplify-subject-fuzzy-regexp nil
638 "*Strings to be removed when doing fuzzy matches.
639 This can either be a regular expression or list of regular expressions
640 that will be removed from subject strings if fuzzy subject
641 simplification is selected.")
643 (defvar gnus-permanently-visible-groups nil
644 "*Regexp to match groups that should always be listed in the group buffer.
645 This means that they will still be listed when there are no unread
646 articles in the groups.")
648 (defvar gnus-list-groups-with-ticked-articles t
649 "*If non-nil, list groups that have only ticked articles.
650 If nil, only list groups that have unread articles.")
652 (defvar gnus-group-default-list-level gnus-level-subscribed
653 "*Default listing level.
654 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
656 (defvar gnus-group-use-permanent-levels nil
657 "*If non-nil, once you set a level, Gnus will use this level.")
659 (defvar gnus-group-list-inactive-groups t
660 "*If non-nil, inactive groups will be listed.")
662 (defvar gnus-show-mime nil
663 "*If non-nil, do mime processing of articles.
664 The articles will simply be fed to the function given by
665 `gnus-show-mime-method'.")
667 (defvar gnus-strict-mime t
668 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
670 (defvar gnus-show-mime-method 'metamail-buffer
671 "*Function to process a MIME message.
672 The function is called from the article buffer.")
674 (defvar gnus-decode-encoded-word-method (lambda ())
675 "*Function to decode a MIME encoded-words.
676 The function is called from the article buffer.")
678 (defvar gnus-show-threads t
679 "*If non-nil, display threads in summary mode.")
681 (defvar gnus-thread-hide-subtree nil
682 "*If non-nil, hide all threads initially.
683 If threads are hidden, you have to run the command
684 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
685 to expose hidden threads.")
687 (defvar gnus-thread-hide-killed t
688 "*If non-nil, hide killed threads automatically.")
690 (defvar gnus-thread-ignore-subject nil
691 "*If non-nil, ignore subjects and do all threading based on the Reference header.
692 If nil, which is the default, articles that have different subjects
693 from their parents will start separate threads.")
695 (defvar gnus-thread-operation-ignore-subject t
696 "*If non-nil, subjects will be ignored when doing thread commands.
697 This affects commands like `gnus-summary-kill-thread' and
698 `gnus-summary-lower-thread'.
700 If this variable is nil, articles in the same thread with different
701 subjects will not be included in the operation in question. If this
702 variable is `fuzzy', only articles that have subjects that are fuzzily
703 equal will be included.")
705 (defvar gnus-thread-indent-level 4
706 "*Number that says how much each sub-thread should be indented.")
708 (defvar gnus-ignored-newsgroups
709 (purecopy (mapconcat 'identity
710 '("^to\\." ; not "real" groups
711 "^[0-9. \t]+ " ; all digits in name
712 "[][\"#'()]" ; bogus characters
715 "*A regexp to match uninteresting newsgroups in the active file.
716 Any lines in the active file matching this regular expression are
717 removed from the newsgroup list before anything else is done to it,
718 thus making them effectively non-existent.")
720 (defvar gnus-ignored-headers
721 "^Path:\\|^Posting-Version:\\|^Article-I.D.:\\|^Expires:\\|^Date-Received:\\|^References:\\|^Control:\\|^Xref:\\|^Lines:\\|^Posted:\\|^Relay-Version:\\|^Message-ID:\\|^Nf-ID:\\|^Nf-From:\\|^Approved:\\|^Sender:\\|^Received:\\|^Mail-from:"
722 "*All headers that match this regexp will be hidden.
723 This variable can also be a list of regexps of headers to be ignored.
724 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
726 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
727 "*All headers that do not match this regexp will be hidden.
728 This variable can also be a list of regexp of headers to remain visible.
729 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
731 (defvar gnus-sorted-header-list
732 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
733 "^Cc:" "^Date:" "^Organization:")
734 "*This variable is a list of regular expressions.
735 If it is non-nil, headers that match the regular expressions will
736 be placed first in the article buffer in the sequence specified by
739 (defvar gnus-boring-article-headers
740 '(empty followup-to reply-to)
741 "*Headers that are only to be displayed if they have interesting data.
742 Possible values in this list are `empty', `newsgroups', `followup-to',
743 `reply-to', and `date'.")
745 (defvar gnus-show-all-headers nil
746 "*If non-nil, don't hide any headers.")
748 (defvar gnus-save-all-headers t
749 "*If non-nil, don't remove any headers before saving.")
751 (defvar gnus-saved-headers gnus-visible-headers
752 "*Headers to keep if `gnus-save-all-headers' is nil.
753 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
754 If that variable is nil, however, all headers that match this regexp
755 will be kept while the rest will be deleted before saving.")
757 (defvar gnus-inhibit-startup-message nil
758 "*If non-nil, the startup message will not be displayed.")
760 (defvar gnus-signature-separator "^-- *$"
761 "Regexp matching signature separator.")
763 (defvar gnus-auto-extend-newsgroup t
764 "*If non-nil, extend newsgroup forward and backward when requested.")
766 (defvar gnus-auto-select-first t
767 "*If nil, don't select the first unread article when entering a group.
768 If this variable is `best', select the highest-scored unread article
769 in the group. If neither nil nor `best', select the first unread
772 If you want to prevent automatic selection of the first unread article
773 in some newsgroups, set the variable to nil in
774 `gnus-select-group-hook'.")
776 (defvar gnus-auto-select-next t
777 "*If non-nil, offer to go to the next group from the end of the previous.
778 If the value is t and the next newsgroup is empty, Gnus will exit
779 summary mode and go back to group mode. If the value is neither nil
780 nor t, Gnus will select the following unread newsgroup. In
781 particular, if the value is the symbol `quietly', the next unread
782 newsgroup will be selected without any confirmation, and if it is
783 `almost-quietly', the next group will be selected without any
784 confirmation if you are located on the last article in the group.
785 Finally, if this variable is `slightly-quietly', the `Z n' command
786 will go to the next group without confirmation.")
788 (defvar gnus-auto-select-same nil
789 "*If non-nil, select the next article with the same subject.")
791 (defvar gnus-summary-check-current nil
792 "*If non-nil, consider the current article when moving.
793 The \"unread\" movement commands will stay on the same line if the
794 current article is unread.")
796 (defvar gnus-auto-center-summary t
797 "*If non-nil, always center the current summary buffer.")
799 (defvar gnus-break-pages t
800 "*If non-nil, do page breaking on articles.
801 The page delimiter is specified by the `gnus-page-delimiter'
804 (defvar gnus-page-delimiter "^\^L"
805 "*Regexp describing what to use as article page delimiters.
806 The default value is \"^\^L\", which is a form linefeed at the
807 beginning of a line.")
809 (defvar gnus-use-full-window t
810 "*If non-nil, use the entire Emacs screen.")
812 (defvar gnus-window-configuration nil
813 "Obsolete variable. See `gnus-buffer-configuration'.")
815 (defvar gnus-window-min-width 2
816 "*Minimum width of Gnus buffers.")
818 (defvar gnus-window-min-height 1
819 "*Minimum height of Gnus buffers.")
821 (defvar gnus-buffer-configuration
825 (if gnus-carpal '(group-carpal 4))))
829 (if gnus-carpal '(summary-carpal 4))))
836 (if gnus-carpal '(summary-carpal 4))
838 (vertical ((height . 5) (width . 15)
840 (left . -1) (top . 1))
850 (if gnus-carpal '(summary-carpal 4))
851 (if gnus-use-trees '(tree 0.25))
856 (if gnus-carpal '(server-carpal 2))))
860 (if gnus-carpal '(browse-carpal 2))))
873 (article 1.0 point)))
884 (edit-group 1.0 point)))
888 (edit-server 1.0 point)))
892 (edit-score 1.0 point)))
919 (if gnus-carpal '(summary-carpal 4))
920 ("*Shell Command Output*" 1.0)))
928 "Window configuration for all possible Gnus buffers.
929 This variable is a list of lists. Each of these lists has a NAME and
930 a RULE. The NAMEs are commonsense names like `group', which names a
931 rule used when displaying the group buffer; `summary', which names a
932 rule for what happens when you enter a group and do not display an
933 article buffer; and so on. See the value of this variable for a
934 complete list of NAMEs.
936 Each RULE is a list of vectors. The first element in this vector is
937 the name of the buffer to be displayed; the second element is the
938 percentage of the screen this buffer is to occupy (a number in the
939 0.0-0.99 range); the optional third element is `point', which should
940 be present to denote which buffer point is to go to after making this
941 buffer configuration.")
943 (defvar gnus-window-to-buffer
944 '((group . gnus-group-buffer)
945 (summary . gnus-summary-buffer)
946 (article . gnus-article-buffer)
947 (server . gnus-server-buffer)
948 (browse . "*Gnus Browse Server*")
949 (edit-group . gnus-group-edit-buffer)
950 (edit-server . gnus-server-edit-buffer)
951 (group-carpal . gnus-carpal-group-buffer)
952 (summary-carpal . gnus-carpal-summary-buffer)
953 (server-carpal . gnus-carpal-server-buffer)
954 (browse-carpal . gnus-carpal-browse-buffer)
955 (edit-score . gnus-score-edit-buffer)
956 (mail . gnus-mail-buffer)
957 (post . gnus-post-news-buffer)
958 (faq . gnus-faq-buffer)
959 (picons . "*Picons*")
960 (tree . gnus-tree-buffer)
961 (info . gnus-info-buffer)
962 (draft . gnus-draft-buffer))
963 "Mapping from short symbols to buffer names or buffer variables.")
965 (defvar gnus-carpal nil
966 "*If non-nil, display clickable icons.")
968 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
969 "*Function called with a group name when new group is detected.
970 A few pre-made functions are supplied: `gnus-subscribe-randomly'
971 inserts new groups at the beginning of the list of groups;
972 `gnus-subscribe-alphabetically' inserts new groups in strict
973 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
974 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
975 for your decision; `gnus-subscribe-killed' kills all new groups.")
977 ;; Suggested by a bug report by Hallvard B Furuseth.
978 ;; <h.b.furuseth@usit.uio.no>.
979 (defvar gnus-subscribe-options-newsgroup-method
980 (function gnus-subscribe-alphabetically)
981 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
982 If, for instance, you want to subscribe to all newsgroups in the
983 \"no\" and \"alt\" hierarchies, you'd put the following in your
986 options -n no.all alt.all
988 Gnus will the subscribe all new newsgroups in these hierarchies with
989 the subscription method in this variable.")
991 (defvar gnus-subscribe-hierarchical-interactive nil
992 "*If non-nil, Gnus will offer to subscribe hierarchically.
993 When a new hierarchy appears, Gnus will ask the user:
995 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
997 If the user pressed `d', Gnus will descend the hierarchy, `y' will
998 subscribe to all newsgroups in the hierarchy and `s' will skip this
999 hierarchy in its entirety.")
1001 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1002 "*Function used for sorting the group buffer.
1003 This function will be called with group info entries as the arguments
1004 for the groups to be sorted. Pre-made functions include
1005 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1006 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1007 `gnus-group-sort-by-rank'.
1009 This variable can also be a list of sorting functions. In that case,
1010 the most significant sort function should be the last function in the
1013 ;; Mark variables suggested by Thomas Michanek
1014 ;; <Thomas.Michanek@telelogic.se>.
1015 (defvar gnus-unread-mark ?
1016 "*Mark used for unread articles.")
1017 (defvar gnus-ticked-mark ?!
1018 "*Mark used for ticked articles.")
1019 (defvar gnus-dormant-mark ??
1020 "*Mark used for dormant articles.")
1021 (defvar gnus-del-mark ?r
1022 "*Mark used for del'd articles.")
1023 (defvar gnus-read-mark ?R
1024 "*Mark used for read articles.")
1025 (defvar gnus-expirable-mark ?E
1026 "*Mark used for expirable articles.")
1027 (defvar gnus-killed-mark ?K
1028 "*Mark used for killed articles.")
1029 (defvar gnus-souped-mark ?F
1030 "*Mark used for killed articles.")
1031 (defvar gnus-kill-file-mark ?X
1032 "*Mark used for articles killed by kill files.")
1033 (defvar gnus-low-score-mark ?Y
1034 "*Mark used for articles with a low score.")
1035 (defvar gnus-catchup-mark ?C
1036 "*Mark used for articles that are caught up.")
1037 (defvar gnus-replied-mark ?A
1038 "*Mark used for articles that have been replied to.")
1039 (defvar gnus-cached-mark ?*
1040 "*Mark used for articles that are in the cache.")
1041 (defvar gnus-saved-mark ?S
1042 "*Mark used for articles that have been saved to.")
1043 (defvar gnus-process-mark ?#
1045 (defvar gnus-ancient-mark ?O
1046 "*Mark used for ancient articles.")
1047 (defvar gnus-sparse-mark ?Q
1048 "*Mark used for sparsely reffed articles.")
1049 (defvar gnus-canceled-mark ?G
1050 "*Mark used for canceled articles.")
1051 (defvar gnus-score-over-mark ?+
1052 "*Score mark used for articles with high scores.")
1053 (defvar gnus-score-below-mark ?-
1054 "*Score mark used for articles with low scores.")
1055 (defvar gnus-empty-thread-mark ?
1056 "*There is no thread under the article.")
1057 (defvar gnus-not-empty-thread-mark ?=
1058 "*There is a thread under the article.")
1060 (defvar gnus-view-pseudo-asynchronously nil
1061 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1063 (defvar gnus-view-pseudos nil
1064 "*If `automatic', pseudo-articles will be viewed automatically.
1065 If `not-confirm', pseudos will be viewed automatically, and the user
1066 will not be asked to confirm the command.")
1068 (defvar gnus-view-pseudos-separately t
1069 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1070 If nil, all files that use the same viewing command will be given as a
1071 list of parameters to that command.")
1073 (defvar gnus-insert-pseudo-articles t
1074 "*If non-nil, insert pseudo-articles when decoding articles.")
1076 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1077 "*Format of group lines.
1078 It works along the same lines as a normal formatting string,
1079 with some simple extensions.
1081 %M Only marked articles (character, \"*\" or \" \")
1082 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1083 %L Level of subscribedness (integer)
1084 %N Number of unread articles (integer)
1085 %I Number of dormant articles (integer)
1086 %i Number of ticked and dormant (integer)
1087 %T Number of ticked articles (integer)
1088 %R Number of read articles (integer)
1089 %t Total number of articles (integer)
1090 %y Number of unread, unticked articles (integer)
1091 %G Group name (string)
1092 %g Qualified group name (string)
1093 %D Group description (string)
1094 %s Select method (string)
1095 %o Moderated group (char, \"m\")
1096 %p Process mark (char)
1097 %O Moderated group (string, \"(m)\" or \"\")
1098 %P Topic indentation (string)
1099 %l Whether there are GroupLens predictions for this group (string)
1100 %n Select from where (string)
1101 %z A string that look like `<%s:%n>' if a foreign select method is used
1102 %u User defined specifier. The next character in the format string should
1103 be a letter. Gnus will call the function gnus-user-format-function-X,
1104 where X is the letter following %u. The function will be passed the
1105 current header as argument. The function should return a string, which
1106 will be inserted into the buffer just like information from any other
1109 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1110 the mouse point move inside the area. There can only be one such area.
1112 Note that this format specification is not always respected. For
1113 reasons of efficiency, when listing killed groups, this specification
1114 is ignored altogether. If the spec is changed considerably, your
1115 output may end up looking strange when listing both alive and killed
1118 If you use %o or %O, reading the active file will be slower and quite
1119 a bit of extra memory will be used. %D will also worsen performance.
1120 Also note that if you change the format specification to include any
1121 of these specs, you must probably re-start Gnus to see them go into
1124 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1125 "*The format specification of the lines in the summary buffer.
1127 It works along the same lines as a normal formatting string,
1128 with some simple extensions.
1130 %N Article number, left padded with spaces (string)
1132 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1133 %n Name of the poster (string)
1134 %a Extracted name of the poster (string)
1135 %A Extracted address of the poster (string)
1136 %F Contents of the From: header (string)
1137 %x Contents of the Xref: header (string)
1138 %D Date of the article (string)
1139 %d Date of the article (string) in DD-MMM format
1140 %M Message-id of the article (string)
1141 %r References of the article (string)
1142 %c Number of characters in the article (integer)
1143 %L Number of lines in the article (integer)
1144 %I Indentation based on thread level (a string of spaces)
1145 %T A string with two possible values: 80 spaces if the article
1146 is on thread level two or larger and 0 spaces on level one
1147 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1148 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1149 %[ Opening bracket (character, \"[\" or \"<\")
1150 %] Closing bracket (character, \"]\" or \">\")
1151 %> Spaces of length thread-level (string)
1152 %< Spaces of length (- 20 thread-level) (string)
1153 %i Article score (number)
1154 %z Article zcore (character)
1155 %t Number of articles under the current thread (number).
1156 %e Whether the thread is empty or not (character).
1157 %l GroupLens score (number)
1158 %u User defined specifier. The next character in the format string should
1159 be a letter. Gnus will call the function gnus-user-format-function-X,
1160 where X is the letter following %u. The function will be passed the
1161 current header as argument. The function should return a string, which
1162 will be inserted into the summary just like information from any other
1165 Text between %( and %) will be highlighted with `gnus-mouse-face'
1166 when the mouse point is placed inside the area. There can only be one
1169 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1170 with care. For reasons of efficiency, Gnus will compute what column
1171 these characters will end up in, and \"hard-code\" that. This means that
1172 it is illegal to have these specs after a variable-length spec. Well,
1173 you might not be arrested, but your summary buffer will look strange,
1174 which is bad enough.
1176 The smart choice is to have these specs as for to the left as
1179 This restriction may disappear in later versions of Gnus.")
1181 (defvar gnus-summary-dummy-line-format
1183 "*The format specification for the dummy roots in the summary buffer.
1184 It works along the same lines as a normal formatting string,
1185 with some simple extensions.
1189 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1190 "*The format specification for the summary mode line.
1191 It works along the same lines as a normal formatting string,
1192 with some simple extensions:
1195 %p Unprefixed group name
1196 %A Current article number
1198 %U Number of unread articles in the group
1199 %e Number of unselected articles in the group
1200 %Z A string with unread/unselected article counts
1201 %g Shortish group name
1202 %S Subject of the current article
1203 %u User-defined spec
1204 %s Current score file name
1205 %d Number of dormant articles
1206 %r Number of articles that have been marked as read in this session
1207 %E Number of articles expunged by the score files")
1209 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1210 "*The format specification for the article mode line.
1211 See `gnus-summary-mode-line-format' for a closer description.")
1213 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1214 "*The format specification for the group mode line.
1215 It works along the same lines as a normal formatting string,
1216 with some simple extensions:
1218 %S The native news server.
1219 %M The native select method.")
1221 (defvar gnus-valid-select-methods
1222 '(("nntp" post address prompt-address)
1223 ("nnspool" post address)
1224 ("nnvirtual" post-mail virtual prompt-address)
1225 ("nnmbox" mail respool address)
1226 ("nnml" mail respool address)
1227 ("nnmh" mail respool address)
1228 ("nndir" post-mail prompt-address address)
1229 ("nneething" none address prompt-address)
1230 ("nndoc" none address prompt-address)
1231 ("nnbabyl" mail address respool)
1232 ("nnkiboze" post address virtual)
1233 ("nnsoup" post-mail address)
1234 ("nndraft" post-mail)
1235 ("nnfolder" mail respool address))
1236 "An alist of valid select methods.
1237 The first element of each list lists should be a string with the name
1238 of the select method. The other elements may be be the category of
1239 this method (ie. `post', `mail', `none' or whatever) or other
1240 properties that this method has (like being respoolable).
1241 If you implement a new select method, all you should have to change is
1242 this variable. I think.")
1244 (defvar gnus-updated-mode-lines '(group article summary tree)
1245 "*List of buffers that should update their mode lines.
1246 The list may contain the symbols `group', `article' and `summary'. If
1247 the corresponding symbol is present, Gnus will keep that mode line
1248 updated with information that may be pertinent.
1249 If this variable is nil, screen refresh may be quicker.")
1251 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1252 (defvar gnus-mode-non-string-length nil
1253 "*Max length of mode-line non-string contents.
1254 If this is nil, Gnus will take space as is needed, leaving the rest
1255 of the modeline intact.")
1258 ;(defvar gnus-mouse-face 'highlight
1259 ; "*Face used for mouse highlighting in Gnus.
1260 ;No mouse highlights will be done if `gnus-visual' is nil.")
1262 (defvar gnus-summary-mark-below nil
1263 "*Mark all articles with a score below this variable as read.
1264 This variable is local to each summary buffer and usually set by the
1267 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1268 "*List of functions used for sorting articles in the summary buffer.
1269 This variable is only used when not using a threaded display.")
1271 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1272 "*List of functions used for sorting threads in the summary buffer.
1273 By default, threads are sorted by article number.
1275 Each function takes two threads and return non-nil if the first thread
1276 should be sorted before the other. If you use more than one function,
1277 the primary sort function should be the last. You should probably
1278 always include `gnus-thread-sort-by-number' in the list of sorting
1279 functions -- preferably first.
1281 Ready-mady functions include `gnus-thread-sort-by-number',
1282 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1283 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1284 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1286 (defvar gnus-thread-score-function '+
1287 "*Function used for calculating the total score of a thread.
1289 The function is called with the scores of the article and each
1290 subthread and should then return the score of the thread.
1292 Some functions you can use are `+', `max', or `min'.")
1294 (defvar gnus-summary-expunge-below nil
1295 "All articles that have a score less than this variable will be expunged.")
1297 (defvar gnus-thread-expunge-below nil
1298 "All threads that have a total score less than this variable will be expunged.
1299 See `gnus-thread-score-function' for en explanation of what a
1300 \"thread score\" is.")
1302 (defvar gnus-auto-subscribed-groups
1303 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1304 "*All new groups that match this regexp will be subscribed automatically.
1305 Note that this variable only deals with new groups. It has no effect
1306 whatsoever on old groups.")
1308 (defvar gnus-options-subscribe nil
1309 "*All new groups matching this regexp will be subscribed unconditionally.
1310 Note that this variable deals only with new newsgroups. This variable
1311 does not affect old newsgroups.")
1313 (defvar gnus-options-not-subscribe nil
1314 "*All new groups matching this regexp will be ignored.
1315 Note that this variable deals only with new newsgroups. This variable
1316 does not affect old (already subscribed) newsgroups.")
1318 (defvar gnus-auto-expirable-newsgroups nil
1319 "*Groups in which to automatically mark read articles as expirable.
1320 If non-nil, this should be a regexp that should match all groups in
1321 which to perform auto-expiry. This only makes sense for mail groups.")
1323 (defvar gnus-total-expirable-newsgroups nil
1324 "*Groups in which to perform expiry of all read articles.
1325 Use with extreme caution. All groups that match this regexp will be
1326 expiring - which means that all read articles will be deleted after
1327 (say) one week. (This only goes for mail groups and the like, of
1330 (defvar gnus-group-uncollapsed-levels 1
1331 "Number of group name elements to leave alone when making a short group name.")
1333 (defvar gnus-hidden-properties '(invisible t intangible t)
1334 "Property list to use for hiding text.")
1336 (defvar gnus-modtime-botch nil
1337 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1338 due to the bogus appearance that .newsrc was modified on disc.")
1342 (defvar gnus-group-mode-hook nil
1343 "*A hook for Gnus group mode.")
1345 (defvar gnus-summary-mode-hook nil
1346 "*A hook for Gnus summary mode.
1347 This hook is run before any variables are set in the summary buffer.")
1349 (defvar gnus-article-mode-hook nil
1350 "*A hook for Gnus article mode.")
1352 (defvar gnus-summary-prepare-exit-hook nil
1353 "*A hook called when preparing to exit from the summary buffer.
1354 It calls `gnus-summary-expire-articles' by default.")
1355 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1357 (defvar gnus-summary-exit-hook nil
1358 "*A hook called on exit from the summary buffer.")
1360 (defvar gnus-group-catchup-group-hook nil
1361 "*A hook run when catching up a group from the group buffer.")
1363 (defvar gnus-open-server-hook nil
1364 "*A hook called just before opening connection to the news server.")
1366 (defvar gnus-load-hook nil
1367 "*A hook run while Gnus is loaded.")
1369 (defvar gnus-startup-hook nil
1370 "*A hook called at startup.
1371 This hook is called after Gnus is connected to the NNTP server.")
1373 (defvar gnus-get-new-news-hook nil
1374 "*A hook run just before Gnus checks for new news.")
1376 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1377 "*A function that is called to generate the group buffer.
1378 The function is called with three arguments: The first is a number;
1379 all group with a level less or equal to that number should be listed,
1380 if the second is non-nil, empty groups should also be displayed. If
1381 the third is non-nil, it is a number. No groups with a level lower
1382 than this number should be displayed.
1384 The only current function implemented is `gnus-group-prepare-flat'.")
1386 (defvar gnus-group-prepare-hook nil
1387 "*A hook called after the group buffer has been generated.
1388 If you want to modify the group buffer, you can use this hook.")
1390 (defvar gnus-summary-prepare-hook nil
1391 "*A hook called after the summary buffer has been generated.
1392 If you want to modify the summary buffer, you can use this hook.")
1394 (defvar gnus-summary-generate-hook nil
1395 "*A hook run just before generating the summary buffer.
1396 This hook is commonly used to customize threading variables and the
1399 (defvar gnus-article-prepare-hook nil
1400 "*A hook called after an article has been prepared in the article buffer.
1401 If you want to run a special decoding program like nkf, use this hook.")
1403 ;(defvar gnus-article-display-hook nil
1404 ; "*A hook called after the article is displayed in the article buffer.
1405 ;The hook is designed to change the contents of the article
1406 ;buffer. Typical functions that this hook may contain are
1407 ;`gnus-article-hide-headers' (hide selected headers),
1408 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1409 ;`gnus-article-hide-signature' (hide signature) and
1410 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1411 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1412 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1413 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1415 (defvar gnus-article-x-face-command
1416 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1417 "String or function to be executed to display an X-Face header.
1418 If it is a string, the command will be executed in a sub-shell
1419 asynchronously. The compressed face will be piped to this command.")
1421 (defvar gnus-article-x-face-too-ugly nil
1422 "Regexp matching posters whose face shouldn't be shown automatically.")
1424 (defvar gnus-select-group-hook nil
1425 "*A hook called when a newsgroup is selected.
1427 If you'd like to simplify subjects like the
1428 `gnus-summary-next-same-subject' command does, you can use the
1431 (setq gnus-select-group-hook
1434 (mapcar (lambda (header)
1435 (mail-header-set-subject
1437 (gnus-simplify-subject
1438 (mail-header-subject header) 're-only)))
1439 gnus-newsgroup-headers))))")
1441 (defvar gnus-select-article-hook nil
1442 "*A hook called when an article is selected.")
1444 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1445 "*A hook called to apply kill files to a group.
1446 This hook is intended to apply a kill file to the selected newsgroup.
1447 The function `gnus-apply-kill-file' is called by default.
1449 Since a general kill file is too heavy to use only for a few
1450 newsgroups, I recommend you to use a lighter hook function. For
1451 example, if you'd like to apply a kill file to articles which contains
1452 a string `rmgroup' in subject in newsgroup `control', you can use the
1455 (setq gnus-apply-kill-hook
1458 (cond ((string-match \"control\" gnus-newsgroup-name)
1459 (gnus-kill \"Subject\" \"rmgroup\")
1460 (gnus-expunge \"X\"))))))")
1462 (defvar gnus-visual-mark-article-hook
1463 (list 'gnus-highlight-selected-summary)
1464 "*Hook run after selecting an article in the summary buffer.
1465 It is meant to be used for highlighting the article in some way. It
1466 is not run if `gnus-visual' is nil.")
1468 (defvar gnus-parse-headers-hook nil
1469 "*A hook called before parsing the headers.")
1471 (defvar gnus-exit-group-hook nil
1472 "*A hook called when exiting (not quitting) summary mode.")
1474 (defvar gnus-suspend-gnus-hook nil
1475 "*A hook called when suspending (not exiting) Gnus.")
1477 (defvar gnus-exit-gnus-hook nil
1478 "*A hook called when exiting Gnus.")
1480 (defvar gnus-after-exiting-gnus-hook nil
1481 "*A hook called after exiting Gnus.")
1483 (defvar gnus-save-newsrc-hook nil
1484 "*A hook called before saving any of the newsrc files.")
1486 (defvar gnus-save-quick-newsrc-hook nil
1487 "*A hook called just before saving the quick newsrc file.
1488 Can be used to turn version control on or off.")
1490 (defvar gnus-save-standard-newsrc-hook nil
1491 "*A hook called just before saving the standard newsrc file.
1492 Can be used to turn version control on or off.")
1494 (defvar gnus-summary-update-hook
1495 (list 'gnus-summary-highlight-line)
1496 "*A hook called when a summary line is changed.
1497 The hook will not be called if `gnus-visual' is nil.
1499 The default function `gnus-summary-highlight-line' will
1500 highlight the line according to the `gnus-summary-highlight'
1503 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1504 "*A hook called when a group line is changed.
1505 The hook will not be called if `gnus-visual' is nil.
1507 The default function `gnus-group-highlight-line' will
1508 highlight the line according to the `gnus-group-highlight'
1511 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1512 "*A hook called when an article is selected for the first time.
1513 The hook is intended to mark an article as read (or unread)
1514 automatically when it is selected.")
1516 (defvar gnus-group-change-level-function nil
1517 "Function run when a group level is changed.
1518 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1520 ;; Remove any hilit infestation.
1521 (add-hook 'gnus-startup-hook
1523 (remove-hook 'gnus-summary-prepare-hook
1524 'hilit-rehighlight-buffer-quietly)
1525 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1526 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1527 (remove-hook 'gnus-article-prepare-hook
1528 'hilit-rehighlight-buffer-quietly)))
1531 ;; Internal variables
1533 (defvar gnus-server-alist nil
1534 "List of available servers.")
1536 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1538 (defvar gnus-goto-missing-group-function nil)
1540 (defvar gnus-override-subscribe-method nil)
1542 (defvar gnus-group-goto-next-group-function nil
1543 "Function to override finding the next group after listing groups.")
1545 (defconst gnus-article-mark-lists
1546 '((marked . tick) (replied . reply)
1547 (expirable . expire) (killed . killed)
1548 (bookmarks . bookmark) (dormant . dormant)
1549 (scored . score) (saved . save)
1553 ;; Avoid highlighting in kill files.
1554 (defvar gnus-summary-inhibit-highlight nil)
1555 (defvar gnus-newsgroup-selected-overlay nil)
1557 (defvar gnus-inhibit-hiding nil)
1558 (defvar gnus-group-indentation "")
1559 (defvar gnus-inhibit-limiting nil)
1561 (defvar gnus-article-mode-map nil)
1562 (defvar gnus-dribble-buffer nil)
1563 (defvar gnus-headers-retrieved-by nil)
1564 (defvar gnus-article-reply nil)
1565 (defvar gnus-override-method nil)
1566 (defvar gnus-article-check-size nil)
1568 (defvar gnus-current-score-file nil)
1569 (defvar gnus-newsgroup-adaptive-score-file nil)
1570 (defvar gnus-scores-exclude-files nil)
1572 (defvar gnus-opened-servers nil)
1574 (defvar gnus-current-move-group nil)
1576 (defvar gnus-newsgroup-dependencies nil)
1577 (defvar gnus-newsgroup-async nil)
1578 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1580 (defvar gnus-newsgroup-adaptive nil)
1582 (defvar gnus-summary-display-table nil)
1583 (defvar gnus-summary-display-article-function nil)
1585 (defvar gnus-summary-highlight-line-function nil
1586 "Function called after highlighting a summary line.")
1588 (defvar gnus-group-line-format-alist
1589 `((?M gnus-tmp-marked-mark ?c)
1590 (?S gnus-tmp-subscribed ?c)
1591 (?L gnus-tmp-level ?d)
1592 (?N (cond ((eq number t) "*" )
1596 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1597 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1599 (?R gnus-tmp-number-of-read ?s)
1600 (?t gnus-tmp-number-total ?d)
1601 (?y gnus-tmp-number-of-unread ?s)
1602 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1603 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1604 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1605 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1606 (?g gnus-tmp-group ?s)
1607 (?G gnus-tmp-qualified-group ?s)
1608 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1609 (?D gnus-tmp-newsgroup-description ?s)
1610 (?o gnus-tmp-moderated ?c)
1611 (?O gnus-tmp-moderated-string ?s)
1612 (?p gnus-tmp-process-marked ?c)
1613 (?s gnus-tmp-news-server ?s)
1614 (?n gnus-tmp-news-method ?s)
1615 (?P gnus-group-indentation ?s)
1616 (?l gnus-tmp-grouplens ?s)
1617 (?z gnus-tmp-news-method-string ?s)
1618 (?u gnus-tmp-user-defined ?s)))
1620 (defvar gnus-summary-line-format-alist
1621 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1622 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1623 (?s gnus-tmp-subject-or-nil ?s)
1624 (?n gnus-tmp-name ?s)
1625 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1627 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1629 (?F gnus-tmp-from ?s)
1630 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1631 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1632 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1633 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1634 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1635 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1636 (?L gnus-tmp-lines ?d)
1637 (?I gnus-tmp-indentation ?s)
1638 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1639 (?R gnus-tmp-replied ?c)
1640 (?\[ gnus-tmp-opening-bracket ?c)
1641 (?\] gnus-tmp-closing-bracket ?c)
1642 (?\> (make-string gnus-tmp-level ? ) ?s)
1643 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1644 (?i gnus-tmp-score ?d)
1645 (?z gnus-tmp-score-char ?c)
1646 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1647 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1648 (?U gnus-tmp-unread ?c)
1649 (?t (gnus-summary-number-of-articles-in-thread
1650 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1652 (?e (gnus-summary-number-of-articles-in-thread
1653 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1655 (?u gnus-tmp-user-defined ?s))
1656 "An alist of format specifications that can appear in summary lines,
1657 and what variables they correspond with, along with the type of the
1658 variable (string, integer, character, etc).")
1660 (defvar gnus-summary-dummy-line-format-alist
1661 `((?S gnus-tmp-subject ?s)
1662 (?N gnus-tmp-number ?d)
1663 (?u gnus-tmp-user-defined ?s)))
1665 (defvar gnus-summary-mode-line-format-alist
1666 `((?G gnus-tmp-group-name ?s)
1667 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1668 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1669 (?A gnus-tmp-article-number ?d)
1670 (?Z gnus-tmp-unread-and-unselected ?s)
1671 (?V gnus-version ?s)
1672 (?U gnus-tmp-unread ?d)
1673 (?S gnus-tmp-subject ?s)
1674 (?e gnus-tmp-unselected ?d)
1675 (?u gnus-tmp-user-defined ?s)
1676 (?d (length gnus-newsgroup-dormant) ?d)
1677 (?t (length gnus-newsgroup-marked) ?d)
1678 (?r (length gnus-newsgroup-reads) ?d)
1679 (?E gnus-newsgroup-expunged-tally ?d)
1680 (?s (gnus-current-score-file-nondirectory) ?s)))
1682 (defvar gnus-article-mode-line-format-alist
1683 gnus-summary-mode-line-format-alist)
1685 (defvar gnus-group-mode-line-format-alist
1686 `((?S gnus-tmp-news-server ?s)
1687 (?M gnus-tmp-news-method ?s)
1688 (?u gnus-tmp-user-defined ?s)))
1690 (defvar gnus-have-read-active-file nil)
1692 (defconst gnus-maintainer
1693 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1694 "The mail address of the Gnus maintainers.")
1696 (defconst gnus-version "September Gnus v0.43"
1697 "Version number for this version of Gnus.")
1699 (defvar gnus-info-nodes
1700 '((gnus-group-mode "(gnus)The Group Buffer")
1701 (gnus-summary-mode "(gnus)The Summary Buffer")
1702 (gnus-article-mode "(gnus)The Article Buffer"))
1703 "Assoc list of major modes and related Info nodes.")
1705 (defvar gnus-group-buffer "*Group*")
1706 (defvar gnus-summary-buffer "*Summary*")
1707 (defvar gnus-article-buffer "*Article*")
1708 (defvar gnus-server-buffer "*Server*")
1710 (defvar gnus-work-buffer " *gnus work*")
1712 (defvar gnus-original-article-buffer " *Original Article*")
1713 (defvar gnus-original-article nil)
1715 (defvar gnus-buffer-list nil
1716 "Gnus buffers that should be killed on exit.")
1718 (defvar gnus-slave nil
1719 "Whether this Gnus is a slave or not.")
1721 (defvar gnus-variable-list
1722 '(gnus-newsrc-options gnus-newsrc-options-n
1723 gnus-newsrc-last-checked-date
1724 gnus-newsrc-alist gnus-server-alist
1725 gnus-killed-list gnus-zombie-list
1726 gnus-topic-topology gnus-topic-alist
1728 "Gnus variables saved in the quick startup file.")
1730 (defvar gnus-newsrc-options nil
1731 "Options line in the .newsrc file.")
1733 (defvar gnus-newsrc-options-n nil
1734 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1736 (defvar gnus-newsrc-last-checked-date nil
1737 "Date Gnus last asked server for new newsgroups.")
1739 (defvar gnus-topic-topology nil
1740 "The complete topic hierarchy.")
1742 (defvar gnus-topic-alist nil
1743 "The complete topic-group alist.")
1745 (defvar gnus-newsrc-alist nil
1746 "Assoc list of read articles.
1747 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1749 (defvar gnus-newsrc-hashtb nil
1750 "Hashtable of gnus-newsrc-alist.")
1752 (defvar gnus-killed-list nil
1753 "List of killed newsgroups.")
1755 (defvar gnus-killed-hashtb nil
1756 "Hash table equivalent of gnus-killed-list.")
1758 (defvar gnus-zombie-list nil
1759 "List of almost dead newsgroups.")
1761 (defvar gnus-description-hashtb nil
1762 "Descriptions of newsgroups.")
1764 (defvar gnus-list-of-killed-groups nil
1765 "List of newsgroups that have recently been killed by the user.")
1767 (defvar gnus-active-hashtb nil
1768 "Hashtable of active articles.")
1770 (defvar gnus-moderated-list nil
1771 "List of moderated newsgroups.")
1773 (defvar gnus-group-marked nil)
1775 (defvar gnus-current-startup-file nil
1776 "Startup file for the current host.")
1778 (defvar gnus-last-search-regexp nil
1779 "Default regexp for article search command.")
1781 (defvar gnus-last-shell-command nil
1782 "Default shell command on article.")
1784 (defvar gnus-current-select-method nil
1785 "The current method for selecting a newsgroup.")
1787 (defvar gnus-group-list-mode nil)
1789 (defvar gnus-article-internal-prepare-hook nil)
1791 (defvar gnus-newsgroup-name nil)
1792 (defvar gnus-newsgroup-begin nil)
1793 (defvar gnus-newsgroup-end nil)
1794 (defvar gnus-newsgroup-last-rmail nil)
1795 (defvar gnus-newsgroup-last-mail nil)
1796 (defvar gnus-newsgroup-last-folder nil)
1797 (defvar gnus-newsgroup-last-file nil)
1798 (defvar gnus-newsgroup-auto-expire nil)
1799 (defvar gnus-newsgroup-active nil)
1801 (defvar gnus-newsgroup-data nil)
1802 (defvar gnus-newsgroup-data-reverse nil)
1803 (defvar gnus-newsgroup-limit nil)
1804 (defvar gnus-newsgroup-limits nil)
1806 (defvar gnus-newsgroup-unreads nil
1807 "List of unread articles in the current newsgroup.")
1809 (defvar gnus-newsgroup-unselected nil
1810 "List of unselected unread articles in the current newsgroup.")
1812 (defvar gnus-newsgroup-reads nil
1813 "Alist of read articles and article marks in the current newsgroup.")
1815 (defvar gnus-newsgroup-expunged-tally nil)
1817 (defvar gnus-newsgroup-marked nil
1818 "List of ticked articles in the current newsgroup (a subset of unread art).")
1820 (defvar gnus-newsgroup-killed nil
1821 "List of ranges of articles that have been through the scoring process.")
1823 (defvar gnus-newsgroup-cached nil
1824 "List of articles that come from the article cache.")
1826 (defvar gnus-newsgroup-saved nil
1827 "List of articles that have been saved.")
1829 (defvar gnus-newsgroup-kill-headers nil)
1831 (defvar gnus-newsgroup-replied nil
1832 "List of articles that have been replied to in the current newsgroup.")
1834 (defvar gnus-newsgroup-expirable nil
1835 "List of articles in the current newsgroup that can be expired.")
1837 (defvar gnus-newsgroup-processable nil
1838 "List of articles in the current newsgroup that can be processed.")
1840 (defvar gnus-newsgroup-bookmarks nil
1841 "List of articles in the current newsgroup that have bookmarks.")
1843 (defvar gnus-newsgroup-dormant nil
1844 "List of dormant articles in the current newsgroup.")
1846 (defvar gnus-newsgroup-scored nil
1847 "List of scored articles in the current newsgroup.")
1849 (defvar gnus-newsgroup-headers nil
1850 "List of article headers in the current newsgroup.")
1852 (defvar gnus-newsgroup-threads nil)
1854 (defvar gnus-newsgroup-prepared nil
1855 "Whether the current group has been prepared properly.")
1857 (defvar gnus-newsgroup-ancient nil
1858 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1860 (defvar gnus-newsgroup-sparse nil)
1862 (defvar gnus-current-article nil)
1863 (defvar gnus-article-current nil)
1864 (defvar gnus-current-headers nil)
1865 (defvar gnus-have-all-headers nil)
1866 (defvar gnus-last-article nil)
1867 (defvar gnus-newsgroup-history nil)
1868 (defvar gnus-current-kill-article nil)
1870 ;; Save window configuration.
1871 (defvar gnus-prev-winconf nil)
1873 (defvar gnus-summary-mark-positions nil)
1874 (defvar gnus-group-mark-positions nil)
1876 (defvar gnus-reffed-article-number nil)
1878 ;;; Let the byte-compiler know that we know about this variable.
1879 (defvar rmail-default-rmail-file)
1881 (defvar gnus-cache-removable-articles nil)
1883 (defvar gnus-dead-summary nil)
1885 (defconst gnus-summary-local-variables
1886 '(gnus-newsgroup-name
1887 gnus-newsgroup-begin gnus-newsgroup-end
1888 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1889 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1890 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1891 gnus-newsgroup-unselected gnus-newsgroup-marked
1892 gnus-newsgroup-reads gnus-newsgroup-saved
1893 gnus-newsgroup-replied gnus-newsgroup-expirable
1894 gnus-newsgroup-processable gnus-newsgroup-killed
1895 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1896 gnus-newsgroup-headers gnus-newsgroup-threads
1897 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1898 gnus-current-article gnus-current-headers gnus-have-all-headers
1899 gnus-last-article gnus-article-internal-prepare-hook
1900 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1901 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1902 gnus-newsgroup-async
1903 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1904 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1905 gnus-newsgroup-history gnus-newsgroup-ancient
1906 gnus-newsgroup-sparse
1907 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1908 gnus-newsgroup-adaptive-score-file
1909 (gnus-newsgroup-expunged-tally . 0)
1910 gnus-cache-removeable-articles gnus-newsgroup-cached
1911 gnus-newsgroup-data gnus-newsgroup-data-reverse
1912 gnus-newsgroup-limit gnus-newsgroup-limits)
1913 "Variables that are buffer-local to the summary buffers.")
1915 (defconst gnus-bug-message
1916 "Sending a bug report to the Gnus Towers.
1917 ========================================
1919 The buffer below is a mail buffer. When you press `C-c C-c', it will
1920 be sent to the Gnus Bug Exterminators.
1922 At the bottom of the buffer you'll see lots of variable settings.
1923 Please do not delete those. They will tell the Bug People what your
1924 environment is, so that it will be easier to locate the bugs.
1926 If you have found a bug that makes Emacs go \"beep\", set
1927 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1928 and include the backtrace in your bug report.
1930 Please describe the bug in annoying, painstaking detail.
1932 Thank you for your help in stamping out bugs.
1935 ;;; End of variables.
1937 ;; Define some autoload functions Gnus might use.
1940 ;; This little mapcar goes through the list below and marks the
1941 ;; symbols in question as autoloaded functions.
1944 (let ((interactive (nth 1 (memq ':interactive package))))
1948 (when (consp function)
1949 (setq keymap (car (memq 'keymap function)))
1950 (setq function (car function)))
1951 (autoload function (car package) nil interactive keymap)))
1952 (if (eq (nth 1 package) ':interactive)
1955 '(("metamail" metamail-buffer)
1956 ("info" Info-goto-node)
1957 ("hexl" hexl-hex-string-to-integer)
1958 ("pp" pp pp-to-string pp-eval-expression)
1959 ("mail-extr" mail-extract-address-components)
1960 ("nnmail" nnmail-split-fancy nnmail-article-group)
1961 ("nnvirtual" nnvirtual-catchup-group)
1962 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1963 timezone-make-sortable-date timezone-make-time-string)
1964 ("sendmail" mail-position-on-field mail-setup)
1965 ("rmailout" rmail-output)
1966 ("rnewspost" news-mail-other-window news-reply-yank-original
1967 news-caesar-buffer-body)
1968 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1970 ("gnus-soup" :interactive t
1971 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1972 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1973 ("nnsoup" nnsoup-pack-replies)
1974 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1975 gnus-Folder-save-name gnus-folder-save-name)
1976 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1977 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1978 gnus-server-make-menu-bar gnus-article-make-menu-bar
1979 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1980 gnus-summary-highlight-line gnus-carpal-setup-buffer
1981 gnus-group-highlight-line
1982 gnus-article-add-button gnus-insert-next-page-button
1983 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1984 ("gnus-vis" :interactive t
1985 gnus-article-push-button gnus-article-press-button
1986 gnus-article-highlight gnus-article-highlight-some
1987 gnus-article-highlight-headers gnus-article-highlight-signature
1988 gnus-article-add-buttons gnus-article-add-buttons-to-head
1989 gnus-article-next-button gnus-article-prev-button)
1990 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1991 gnus-demon-add-disconnection gnus-demon-add-handler
1992 gnus-demon-remove-handler)
1993 ("gnus-demon" :interactive t
1994 gnus-demon-init gnus-demon-cancel)
1995 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1996 gnus-tree-open gnus-tree-close)
1997 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
1998 gnus-nocem-unwanted-article-p)
1999 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2000 ("gnus-srvr" gnus-browse-foreign-server)
2001 ("gnus-cite" :interactive t
2002 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2003 gnus-article-hide-citation gnus-article-fill-cited-article)
2004 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2005 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2006 gnus-execute gnus-expunge)
2007 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2008 gnus-cache-possibly-remove-articles gnus-cache-request-article
2009 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2010 gnus-cache-enter-remove-article gnus-cached-article-p
2011 gnus-cache-open gnus-cache-close)
2012 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2013 gnus-cache-remove-article)
2014 ("gnus-score" :interactive t
2015 gnus-summary-increase-score gnus-summary-lower-score
2016 gnus-score-flush-cache gnus-score-close
2017 gnus-score-raise-same-subject-and-select
2018 gnus-score-raise-same-subject gnus-score-default
2019 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2020 gnus-score-lower-same-subject gnus-score-lower-thread
2021 gnus-possibly-score-headers)
2023 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2024 gnus-current-score-file-nondirectory gnus-score-adaptive
2025 gnus-score-find-trace gnus-score-file-name)
2026 ("gnus-edit" :interactive t gnus-score-customize)
2027 ("gnus-topic" :interactive t gnus-topic-mode)
2028 ("gnus-topic" gnus-topic-remove-group)
2029 ("gnus-salt" :interactive t gnus-pick-mode)
2030 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2031 ("gnus-uu" :interactive t
2032 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2033 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2034 gnus-uu-mark-by-regexp gnus-uu-mark-all
2035 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2036 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2037 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2038 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2039 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2040 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2041 gnus-uu-decode-binhex-view)
2042 ("gnus-msg" (gnus-summary-send-map keymap)
2043 gnus-mail-yank-original gnus-mail-send-and-exit
2044 gnus-sendmail-setup-mail gnus-article-mail
2045 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2046 ("gnus-msg" :interactive t
2047 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2048 gnus-summary-followup gnus-summary-followup-with-original
2049 gnus-summary-followup-and-reply
2050 gnus-summary-followup-and-reply-with-original
2051 gnus-summary-cancel-article gnus-summary-supersede-article
2052 gnus-post-news gnus-inews-news gnus-cancel-news
2053 gnus-summary-reply gnus-summary-reply-with-original
2054 gnus-summary-mail-forward gnus-summary-mail-other-window
2056 ("gnus-picon" :interactive t gnus-article-display-picons
2057 gnus-group-display-picons gnus-picons-article-display-x-face)
2058 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2059 gnus-grouplens-mode)
2060 ("gnus-vm" gnus-vm-mail-setup)
2061 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2062 gnus-summary-save-article-vm gnus-yank-article))))
2066 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2067 ;; If you want the cursor to go somewhere else, set these two
2068 ;; functions in some startup hook to whatever you want.
2069 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2070 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2072 ;;; Various macros and substs.
2074 (defun gnus-header-from (header)
2075 (mail-header-from header))
2077 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2078 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2079 `(let ((GnusStartBufferWindow (selected-window)))
2082 (pop-to-buffer ,buffer)
2084 (select-window GnusStartBufferWindow))))
2086 (defmacro gnus-gethash (string hashtable)
2087 "Get hash value of STRING in HASHTABLE."
2088 `(symbol-value (intern-soft ,string ,hashtable)))
2090 (defmacro gnus-sethash (string value hashtable)
2091 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2092 `(set (intern ,string ,hashtable) ,value))
2094 (defmacro gnus-intern-safe (string hashtable)
2095 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2096 `(let ((symbol (intern ,string ,hashtable)))
2101 (defmacro gnus-group-unread (group)
2102 "Get the currently computed number of unread articles in GROUP."
2103 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2105 (defmacro gnus-group-entry (group)
2106 "Get the newsrc entry for GROUP."
2107 `(gnus-gethash ,group gnus-newsrc-hashtb))
2109 (defmacro gnus-active (group)
2110 "Get active info on GROUP."
2111 `(gnus-gethash ,group gnus-active-hashtb))
2113 (defmacro gnus-set-active (group active)
2114 "Set GROUP's active info."
2115 `(gnus-sethash ,group ,active gnus-active-hashtb))
2117 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2118 ;; function `substring' might cut on a middle of multi-octet
2120 (defun gnus-truncate-string (str width)
2121 (substring str 0 width))
2123 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2124 ;; to limit the length of a string. This function is necessary since
2125 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2126 (defsubst gnus-limit-string (str width)
2127 (if (> (length str) width)
2128 (substring str 0 width)
2131 (defsubst gnus-simplify-subject-re (subject)
2132 "Remove \"Re:\" from subject lines."
2133 (if (string-match "^[Rr][Ee]: *" subject)
2134 (substring subject (match-end 0))
2137 (defsubst gnus-goto-char (point)
2138 (and point (goto-char point)))
2140 (defmacro gnus-buffer-exists-p (buffer)
2142 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2145 (defmacro gnus-kill-buffer (buffer)
2146 `(let ((buf ,buffer))
2147 (if (gnus-buffer-exists-p buf)
2148 (kill-buffer buf))))
2150 (defsubst gnus-point-at-bol ()
2151 "Return point at the beginning of the line."
2158 (defsubst gnus-point-at-eol ()
2159 "Return point at the end of the line."
2166 ;; Delete the current line (and the next N lines.);
2167 (defmacro gnus-delete-line (&optional n)
2168 `(delete-region (progn (beginning-of-line) (point))
2169 (progn (forward-line ,(or n 1)) (point))))
2171 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2172 (defvar gnus-init-inhibit nil)
2173 (defun gnus-read-init-file (&optional inhibit-next)
2174 (if gnus-init-inhibit
2175 (setq gnus-init-inhibit nil)
2176 (setq gnus-init-inhibit inhibit-next)
2178 (or (and (file-exists-p gnus-init-file)
2179 ;; Don't try to load a directory.
2180 (not (file-directory-p gnus-init-file)))
2181 (file-exists-p (concat gnus-init-file ".el"))
2182 (file-exists-p (concat gnus-init-file ".elc")))
2184 (load gnus-init-file nil t)
2186 (error "Error in %s: %s" gnus-init-file var))))))
2188 ;; Info access macros.
2190 (defmacro gnus-info-group (info)
2192 (defmacro gnus-info-rank (info)
2194 (defmacro gnus-info-read (info)
2196 (defmacro gnus-info-marks (info)
2198 (defmacro gnus-info-method (info)
2200 (defmacro gnus-info-params (info)
2203 (defmacro gnus-info-level (info)
2204 `(let ((rank (gnus-info-rank ,info)))
2208 (defmacro gnus-info-score (info)
2209 `(let ((rank (gnus-info-rank ,info)))
2210 (or (and (consp rank) (cdr rank)) 0)))
2212 (defmacro gnus-info-set-group (info group)
2213 `(setcar ,info ,group))
2214 (defmacro gnus-info-set-rank (info rank)
2215 `(setcar (nthcdr 1 ,info) ,rank))
2216 (defmacro gnus-info-set-read (info read)
2217 `(setcar (nthcdr 2 ,info) ,read))
2218 (defmacro gnus-info-set-marks (info marks)
2219 `(setcar (nthcdr 3 ,info) ,marks))
2220 (defmacro gnus-info-set-method (info method)
2221 `(setcar (nthcdr 4 ,info) ,method))
2222 (defmacro gnus-info-set-params (info params)
2223 `(setcar (nthcdr 5 ,info) ,params))
2225 (defmacro gnus-info-set-level (info level)
2226 `(let ((rank (cdr ,info)))
2227 (if (consp (car rank))
2228 (setcar (car rank) ,level)
2229 (setcar rank ,level))))
2230 (defmacro gnus-info-set-score (info score)
2231 `(let ((rank (cdr ,info)))
2232 (if (consp (car rank))
2233 (setcdr (car rank) ,score)
2234 (setcar rank (cons (car rank) ,score)))))
2236 (defmacro gnus-get-info (group)
2237 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2239 (defun gnus-byte-code (func)
2240 "Return a form that can be `eval'ed based on FUNC."
2241 (let ((fval (symbol-function func)))
2242 (if (byte-code-function-p fval)
2243 (let ((flist (append fval nil)))
2244 (setcar flist 'byte-code)
2246 (cons 'progn (cddr fval)))))
2248 ;;; Load the compatability functions.
2255 ;; Format specs. The chunks below are the machine-generated forms
2256 ;; that are to be evaled as the result of the default format strings.
2257 ;; We write them in here to get them byte-compiled. That way the
2258 ;; default actions will be quite fast, while still retaining the full
2259 ;; flexibility of the user-defined format specs.
2261 ;; First we have lots of dummy defvars to let the compiler know these
2262 ;; are really dynamic variables.
2264 (defvar gnus-tmp-unread)
2265 (defvar gnus-tmp-replied)
2266 (defvar gnus-tmp-score-char)
2267 (defvar gnus-tmp-indentation)
2268 (defvar gnus-tmp-opening-bracket)
2269 (defvar gnus-tmp-lines)
2270 (defvar gnus-tmp-name)
2271 (defvar gnus-tmp-closing-bracket)
2272 (defvar gnus-tmp-subject-or-nil)
2273 (defvar gnus-tmp-subject)
2274 (defvar gnus-tmp-marked)
2275 (defvar gnus-tmp-marked-mark)
2276 (defvar gnus-tmp-subscribed)
2277 (defvar gnus-tmp-process-marked)
2278 (defvar gnus-tmp-number-of-unread)
2279 (defvar gnus-tmp-group-name)
2280 (defvar gnus-tmp-group)
2281 (defvar gnus-tmp-article-number)
2282 (defvar gnus-tmp-unread-and-unselected)
2283 (defvar gnus-tmp-news-method)
2284 (defvar gnus-tmp-news-server)
2285 (defvar gnus-tmp-article-number)
2286 (defvar gnus-mouse-face)
2287 (defvar gnus-mouse-face-prop)
2289 (defun gnus-summary-line-format-spec ()
2290 (insert gnus-tmp-unread gnus-tmp-replied
2291 gnus-tmp-score-char gnus-tmp-indentation)
2296 gnus-tmp-opening-bracket
2297 (format "%4d: %-20s"
2299 (if (> (length gnus-tmp-name) 20)
2300 (substring gnus-tmp-name 0 20)
2302 gnus-tmp-closing-bracket)
2304 gnus-mouse-face-prop gnus-mouse-face)
2305 (insert " " gnus-tmp-subject-or-nil "\n"))
2307 (defvar gnus-summary-line-format-spec
2308 (gnus-byte-code 'gnus-summary-line-format-spec))
2310 (defun gnus-summary-dummy-line-format-spec ()
2317 gnus-mouse-face-prop gnus-mouse-face)
2318 (insert " " gnus-tmp-subject "\n"))
2320 (defvar gnus-summary-dummy-line-format-spec
2321 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2323 (defun gnus-group-line-format-spec ()
2324 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2325 gnus-tmp-process-marked
2326 gnus-group-indentation
2327 (format "%5s: " gnus-tmp-number-of-unread))
2331 (insert gnus-tmp-group "\n")
2333 gnus-mouse-face-prop gnus-mouse-face))
2334 (defvar gnus-group-line-format-spec
2335 (gnus-byte-code 'gnus-group-line-format-spec))
2337 (defvar gnus-format-specs
2338 `((version . ,emacs-version)
2339 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2340 (summary-dummy ,gnus-summary-dummy-line-format
2341 ,gnus-summary-dummy-line-format-spec)
2342 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2344 (defvar gnus-article-mode-line-format-spec nil)
2345 (defvar gnus-summary-mode-line-format-spec nil)
2346 (defvar gnus-group-mode-line-format-spec nil)
2348 ;;; Phew. All that gruft is over, fortunately.
2352 ;;; Gnus Utility Functions
2355 (defun gnus-extract-address-components (from)
2357 ;; First find the address - the thing with the @ in it. This may
2358 ;; not be accurate in mail addresses, but does the trick most of
2359 ;; the time in news messages.
2360 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2361 (setq address (substring from (match-beginning 0) (match-end 0))))
2362 ;; Then we check whether the "name <address>" format is used.
2364 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2365 ;; Linear white space is not required.
2366 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2367 (and (setq name (substring from 0 (match-beginning 0)))
2368 ;; Strip any quotes from the name.
2369 (string-match "\".*\"" name)
2370 (setq name (substring name 1 (1- (match-end 0))))))
2371 ;; If not, then "address (name)" is used.
2373 (and (string-match "(.+)" from)
2374 (setq name (substring from (1+ (match-beginning 0))
2375 (1- (match-end 0)))))
2376 (and (string-match "()" from)
2377 (setq name address))
2378 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2379 ;; XOVER might not support folded From headers.
2380 (and (string-match "(.*" from)
2381 (setq name (substring from (1+ (match-beginning 0))
2383 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2384 (list (or name from) (or address from))))
2386 (defun gnus-fetch-field (field)
2387 "Return the value of the header FIELD of current article."
2390 (let ((case-fold-search t))
2391 (nnheader-narrow-to-headers)
2392 (mail-fetch-field field)))))
2394 (defun gnus-goto-colon ()
2396 (search-forward ":" (gnus-point-at-eol) t))
2399 (defun gnus-update-format (var)
2400 "Update the format specification near point."
2405 ;; Find the end of the current word.
2406 (re-search-forward "[ \t\n]" nil t)
2408 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2409 (match-string 1)))))
2410 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2411 (match-string 1 var))))
2412 (entry (assq type gnus-format-specs))
2415 (setq gnus-format-specs (delq entry gnus-format-specs)))
2417 (intern (format "%s-spec" var))
2418 (gnus-parse-format (setq value (symbol-value (intern var)))
2419 (symbol-value (intern (format "%s-alist" var)))
2420 (not (string-match "mode" var))))
2421 (setq spec (symbol-value (intern (format "%s-spec" var))))
2422 (push (list type value spec) gnus-format-specs)
2424 (pop-to-buffer "*Gnus Format*")
2426 (lisp-interaction-mode)
2427 (insert (pp-to-string spec))))
2429 (defun gnus-update-format-specifications (&optional force)
2430 "Update all (necessary) format specifications."
2431 ;; Make the indentation array.
2432 (gnus-make-thread-indent-array)
2434 ;; See whether all the stored info needs to be flushed.
2436 (not (equal emacs-version
2437 (cdr (assq 'version gnus-format-specs)))))
2438 (setq gnus-format-specs nil))
2440 ;; Go through all the formats and see whether they need updating.
2441 (let ((types '(summary summary-dummy group
2442 summary-mode group-mode article-mode))
2443 new-format entry type val)
2444 (while (setq type (pop types))
2445 ;; Jump to the proper buffer to find out the value of
2446 ;; the variable, if possible. (It may be buffer-local.)
2448 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2450 (when (and (boundp buffer)
2451 (setq val (symbol-value buffer))
2453 (buffer-name (get-buffer val)))
2454 (set-buffer (get-buffer val)))
2455 (setq new-format (symbol-value
2456 (intern (format "gnus-%s-line-format" type))))))
2457 (setq entry (cdr (assq type gnus-format-specs)))
2459 (equal (car entry) new-format))
2460 ;; Use the old format.
2461 (set (intern (format "gnus-%s-line-format-spec" type))
2463 ;; This is a new format.
2465 (if (not (stringp new-format))
2466 ;; This is a function call or something.
2468 ;; This is a "real" format.
2472 (intern (format "gnus-%s-line-format-alist"
2473 (if (eq type 'article-mode)
2474 'summary-mode type))))
2475 (not (string-match "mode$" (symbol-name type))))))
2476 ;; Enter the new format spec into the list.
2479 (setcar (cdr entry) val)
2480 (setcar entry new-format))
2481 (push (list type new-format val) gnus-format-specs))
2482 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2484 (gnus-update-group-mark-positions)
2485 (gnus-update-summary-mark-positions)
2487 ;; See whether we need to read the description file.
2488 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2489 (not gnus-description-hashtb)
2490 gnus-read-active-file)
2491 (gnus-read-all-descriptions-files)))
2493 (defun gnus-update-summary-mark-positions ()
2494 "Compute where the summary marks are to go."
2496 (let ((gnus-replied-mark 129)
2497 (gnus-score-below-mark 130)
2498 (gnus-score-over-mark 130)
2502 (gnus-set-work-buffer)
2503 (gnus-summary-insert-line
2504 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2505 (goto-char (point-min))
2506 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2508 (goto-char (point-min))
2509 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2511 (goto-char (point-min))
2512 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2514 (setq gnus-summary-mark-positions pos))))
2516 (defun gnus-update-group-mark-positions ()
2518 (let ((gnus-process-mark 128)
2519 (gnus-group-marked '("dummy.group")))
2520 (gnus-set-active "dummy.group" '(0 . 0))
2521 (gnus-set-work-buffer)
2522 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2523 (goto-char (point-min))
2524 (setq gnus-group-mark-positions
2525 (list (cons 'process (and (search-forward "\200" nil t)
2526 (- (point) 2))))))))
2528 (defvar gnus-mouse-face-0 'highlight)
2529 (defvar gnus-mouse-face-1 'highlight)
2530 (defvar gnus-mouse-face-2 'highlight)
2531 (defvar gnus-mouse-face-3 'highlight)
2532 (defvar gnus-mouse-face-4 'highlight)
2534 (defun gnus-mouse-face-function (form type)
2536 (point) (progn ,@form (point))
2537 gnus-mouse-face-prop
2540 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2542 (defvar gnus-face-0 'bold)
2543 (defvar gnus-face-1 'italic)
2544 (defvar gnus-face-2 'bold-italic)
2545 (defvar gnus-face-3 'bold)
2546 (defvar gnus-face-4 'bold)
2548 (defun gnus-face-face-function (form type)
2550 (point) (progn ,@form (point))
2551 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2553 (defun gnus-max-width-function (el max-width)
2554 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2556 `(if (> (length ,el) ,max-width)
2557 (substring ,el 0 ,max-width)
2559 `(let ((val (eval ,el)))
2561 (setq val (int-to-string val)))
2562 (if (> (length val) ,max-width)
2563 (substring val 0 ,max-width)
2566 (defun gnus-parse-format (format spec-alist &optional insert)
2567 ;; This function parses the FORMAT string with the help of the
2568 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2569 ;; string. If the FORMAT string contains the specifiers %( and %)
2570 ;; the text between them will have the mouse-face text property.
2572 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2574 (gnus-parse-complex-format format spec-alist)
2575 ;; This is a simple format.
2576 (gnus-parse-simple-format format spec-alist insert)))
2578 (defun gnus-parse-complex-format (format spec-alist)
2580 (gnus-set-work-buffer)
2582 (goto-char (point-min))
2583 (while (re-search-forward "\"" nil t)
2584 (replace-match "\\\"" nil t))
2585 (goto-char (point-min))
2587 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2588 (let ((number (if (match-beginning 1)
2589 (match-string 1) "0"))
2590 (delim (aref (match-string 2) 0)))
2591 (if (or (= delim ?\() (= delim ?\{))
2592 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2594 (replace-match "\")\""))))
2595 (goto-char (point-max))
2597 (goto-char (point-min))
2598 (let ((form (read (current-buffer))))
2599 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2601 (defun gnus-complex-form-to-spec (form spec-alist)
2606 (gnus-parse-simple-format sform spec-alist t)
2607 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2608 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2612 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2613 ;; This function parses the FORMAT string with the help of the
2614 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2617 spec flist fstring newspec elem beg result dontinsert)
2619 (gnus-set-work-buffer)
2621 (goto-char (point-min))
2622 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2624 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2626 beg (1+ (match-beginning 0)))
2627 ;; First check if there are any specs that look anything like
2628 ;; "%12,12A", ie. with a "max width specification". These have
2629 ;; to be treated specially.
2630 (if (setq beg (match-beginning 1))
2634 (1+ (match-beginning 1)) (match-end 1))))
2636 (setq beg (match-beginning 2)))
2637 ;; Find the specification from `spec-alist'.
2638 (unless (setq elem (cdr (assq spec spec-alist)))
2639 (setq elem '("*" ?s)))
2640 ;; Treat user defined format specifiers specially.
2641 (when (eq (car elem) 'gnus-tmp-user-defined)
2644 (list (intern (concat "gnus-user-format-function-"
2646 'gnus-tmp-header) ?s))
2647 (delete-region (match-beginning 3) (match-end 3)))
2648 (if (not (zerop max-width))
2649 (let ((el (car elem)))
2650 (cond ((= (cadr elem) ?c)
2651 (setq el (list 'char-to-string el)))
2653 (setq el (list 'int-to-string el))))
2654 (setq flist (cons (gnus-max-width-function el max-width)
2658 (setq flist (cons (car elem) flist))
2659 (setq newspec (cadr elem)))))
2660 ;; Remove the old specification (and possibly a ",12" string).
2661 (delete-region beg (match-end 2))
2662 ;; Insert the new specification.
2665 (setq fstring (buffer-substring 1 (point-max))))
2666 ;; Do some postprocessing to increase efficiency.
2671 ((string= fstring "")
2673 ;; Not a format string.
2674 ((not (string-match "%" fstring))
2676 ;; A format string with just a single string spec.
2677 ((string= fstring "%s")
2679 ;; A single character.
2680 ((string= fstring "%c")
2683 ((string= fstring "%d")
2686 (list `(princ ,(car flist)))
2687 (list `(int-to-string ,(car flist)))))
2688 ;; Just lots of chars and strings.
2689 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2691 ;; A single string spec at the beginning of the spec.
2692 ((string-match "\\`%[sc][^%]+\\'" fstring)
2693 (list (car flist) (substring fstring 2)))
2694 ;; A single string spec in the middle of the spec.
2695 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2696 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2697 ;; A single string spec in the end of the spec.
2698 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2699 (list (match-string 1 fstring) (car flist)))
2700 ;; A more complex spec.
2702 (list (cons 'format (cons fstring (nreverse flist)))))))
2708 (cons 'insert result)))
2709 (cond ((stringp result)
2712 (cons 'concat result))
2715 (defun gnus-eval-format (format &optional alist props)
2716 "Eval the format variable FORMAT, using ALIST.
2717 If PROPS, insert the result."
2718 (let ((form (gnus-parse-format format alist props)))
2720 (add-text-properties (point) (progn (eval form) (point)) props)
2723 (defun gnus-remove-text-with-property (prop)
2724 "Delete all text in the current buffer with text property PROP."
2726 (goto-char (point-min))
2728 (while (get-text-property (point) prop)
2730 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2732 (defun gnus-set-work-buffer ()
2733 (if (get-buffer gnus-work-buffer)
2735 (set-buffer gnus-work-buffer)
2737 (set-buffer (get-buffer-create gnus-work-buffer))
2738 (kill-all-local-variables)
2739 (buffer-disable-undo (current-buffer))
2740 (gnus-add-current-to-buffer-list)))
2742 ;; Article file names when saving.
2744 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2745 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2746 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2747 Otherwise, it is like ~/News/news/group/num."
2750 (concat (if (gnus-use-long-file-name 'not-save)
2751 (gnus-capitalize-newsgroup newsgroup)
2752 (gnus-newsgroup-directory-form newsgroup))
2753 "/" (int-to-string (mail-header-number headers)))
2754 (or gnus-article-save-directory "~/News"))))
2756 (string-equal (file-name-directory default)
2757 (file-name-directory last-file))
2758 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2760 (or last-file default))))
2762 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2763 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2764 If variable `gnus-use-long-file-name' is non-nil, it is
2765 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2768 (concat (if (gnus-use-long-file-name 'not-save)
2770 (gnus-newsgroup-directory-form newsgroup))
2771 "/" (int-to-string (mail-header-number headers)))
2772 (or gnus-article-save-directory "~/News"))))
2774 (string-equal (file-name-directory default)
2775 (file-name-directory last-file))
2776 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2778 (or last-file default))))
2780 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2781 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2782 If variable `gnus-use-long-file-name' is non-nil, it is
2783 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2786 (if (gnus-use-long-file-name 'not-save)
2787 (gnus-capitalize-newsgroup newsgroup)
2788 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2789 (or gnus-article-save-directory "~/News"))))
2791 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2792 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2793 If variable `gnus-use-long-file-name' is non-nil, it is
2794 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2797 (if (gnus-use-long-file-name 'not-save)
2799 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2800 (or gnus-article-save-directory "~/News"))))
2802 ;; For subscribing new newsgroup
2804 (defun gnus-subscribe-hierarchical-interactive (groups)
2805 (let ((groups (sort groups 'string<))
2806 prefixes prefix start ans group starts)
2808 (setq prefixes (list "^"))
2809 (while (and groups prefixes)
2810 (while (not (string-match (car prefixes) (car groups)))
2811 (setq prefixes (cdr prefixes)))
2812 (setq prefix (car prefixes))
2813 (setq start (1- (length prefix)))
2814 (if (and (string-match "[^\\.]\\." (car groups) start)
2817 (concat "^" (substring (car groups) 0 (match-end 0))))
2818 (string-match prefix (cadr groups)))
2820 (setq prefixes (cons prefix prefixes))
2821 (message "Descend hierarchy %s? ([y]nsq): "
2822 (substring prefix 1 (1- (length prefix))))
2823 (setq ans (read-char))
2826 (string-match prefix
2827 (setq group (car groups))))
2828 (setq gnus-killed-list
2829 (cons group gnus-killed-list))
2830 (gnus-sethash group group gnus-killed-hashtb)
2831 (setq groups (cdr groups)))
2832 (setq starts (cdr starts)))
2835 (string-match prefix
2836 (setq group (car groups))))
2837 (gnus-sethash group group gnus-killed-hashtb)
2838 (gnus-subscribe-alphabetically (car groups))
2839 (setq groups (cdr groups)))
2840 (setq starts (cdr starts)))
2843 (setq group (car groups))
2844 (setq gnus-killed-list (cons group gnus-killed-list))
2845 (gnus-sethash group group gnus-killed-hashtb)
2846 (setq groups (cdr groups))))
2848 (message "Subscribe %s? ([n]yq)" (car groups))
2849 (setq ans (read-char))
2850 (setq group (car groups))
2852 (gnus-subscribe-alphabetically (car groups))
2853 (gnus-sethash group group gnus-killed-hashtb))
2856 (setq group (car groups))
2857 (setq gnus-killed-list (cons group gnus-killed-list))
2858 (gnus-sethash group group gnus-killed-hashtb)
2859 (setq groups (cdr groups))))
2861 (setq gnus-killed-list (cons group gnus-killed-list))
2862 (gnus-sethash group group gnus-killed-hashtb)))
2863 (setq groups (cdr groups)))))))
2865 (defun gnus-subscribe-randomly (newsgroup)
2866 "Subscribe new NEWSGROUP by making it the first newsgroup."
2867 (gnus-subscribe-newsgroup newsgroup))
2869 (defun gnus-subscribe-alphabetically (newgroup)
2870 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2871 (let ((groups (cdr gnus-newsrc-alist))
2873 (while (and (not before) groups)
2874 (if (string< newgroup (caar groups))
2875 (setq before (caar groups))
2876 (setq groups (cdr groups))))
2877 (gnus-subscribe-newsgroup newgroup before)))
2879 (defun gnus-subscribe-hierarchically (newgroup)
2880 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2881 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2883 (set-buffer (find-file-noselect gnus-current-startup-file))
2884 (let ((groupkey newgroup)
2886 (while (and (not before) groupkey)
2887 (goto-char (point-min))
2889 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2890 (while (and (re-search-forward groupkey-re nil t)
2892 (setq before (match-string 1))
2893 (string< before newgroup)))))
2894 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2896 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2897 (substring groupkey (match-beginning 1) (match-end 1)))))
2898 (gnus-subscribe-newsgroup newgroup before))))
2900 (defun gnus-subscribe-interactively (group)
2901 "Subscribe the new GROUP interactively.
2902 It is inserted in hierarchical newsgroup order if subscribed. If not,
2904 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2905 (gnus-subscribe-hierarchically group)
2906 (push group gnus-killed-list)))
2908 (defun gnus-subscribe-zombies (group)
2909 "Make the new GROUP into a zombie group."
2910 (push group gnus-zombie-list))
2912 (defun gnus-subscribe-killed (group)
2913 "Make the new GROUP a killed group."
2914 (push group gnus-killed-list))
2916 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2917 "Subscribe new NEWSGROUP.
2918 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2919 the first newsgroup."
2920 ;; We subscribe the group by changing its level to `subscribed'.
2921 (gnus-group-change-level
2922 newsgroup gnus-level-default-subscribed
2923 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2924 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2928 (defun gnus-newsgroup-directory-form (newsgroup)
2929 "Make hierarchical directory name from NEWSGROUP name."
2930 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2931 (len (length newsgroup))
2933 ;; If this is a foreign group, we don't want to translate the
2935 (if (setq idx (string-match ":" newsgroup))
2936 (aset newsgroup idx ?/)
2938 ;; Replace all occurrences of `.' with `/'.
2940 (if (= (aref newsgroup idx) ?.)
2941 (aset newsgroup idx ?/))
2942 (setq idx (1+ idx)))
2945 (defun gnus-newsgroup-savable-name (group)
2946 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2948 (nnheader-replace-chars-in-string group ?/ ?.))
2950 (defun gnus-make-directory (dir)
2951 "Make DIRECTORY recursively."
2952 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2953 ;; of the many mysteries of the universe.
2954 (let* ((dir (expand-file-name dir default-directory))
2956 (if (string-match "/$" dir)
2957 (setq dir (substring dir 0 (match-beginning 0))))
2958 ;; First go down the path until we find a directory that exists.
2959 (while (not (file-exists-p dir))
2960 (setq dirs (cons dir dirs))
2961 (string-match "/[^/]+$" dir)
2962 (setq dir (substring dir 0 (match-beginning 0))))
2963 ;; Then create all the subdirs.
2964 (while (and dirs (not err))
2966 (make-directory (car dirs))
2967 (error (setq err t)))
2968 (setq dirs (cdr dirs)))
2969 ;; We return whether we were successful or not.
2972 (defun gnus-capitalize-newsgroup (newsgroup)
2973 "Capitalize NEWSGROUP name."
2974 (and (not (zerop (length newsgroup)))
2975 (concat (char-to-string (upcase (aref newsgroup 0)))
2976 (substring newsgroup 1))))
2978 ;; Various... things.
2980 (defun gnus-simplify-subject (subject &optional re-only)
2981 "Remove `Re:' and words in parentheses.
2982 If RE-ONLY is non-nil, strip leading `Re:'s only."
2983 (let ((case-fold-search t)) ;Ignore case.
2984 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
2985 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
2986 (setq subject (substring subject (match-end 0))))
2987 ;; Remove uninteresting prefixes.
2988 (if (and (not re-only)
2989 gnus-simplify-ignored-prefixes
2990 (string-match gnus-simplify-ignored-prefixes subject))
2991 (setq subject (substring subject (match-end 0))))
2992 ;; Remove words in parentheses from end.
2994 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2995 (setq subject (substring subject 0 (match-beginning 0)))))
2996 ;; Return subject string.
2999 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3001 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3002 (defun gnus-simplify-buffer-fuzzy ()
3003 (goto-char (point-min))
3004 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3005 (goto-char (match-beginning 0))
3007 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3008 (looking-at "^[[].*:[ \t].*[]]$"))
3009 (goto-char (point-min))
3010 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3012 (replace-match "" t t))
3013 (goto-char (point-min))
3014 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3015 (goto-char (match-end 0))
3018 (progn (goto-char (match-beginning 0)))
3019 (re-search-forward ":"))))
3020 (goto-char (point-min))
3021 (while (re-search-forward "[ \t\n]*[[{(][^()]*[]})][ \t]*$" nil t)
3022 (replace-match "" t t))
3023 (goto-char (point-min))
3024 (while (re-search-forward "[ \t]+" nil t)
3025 (replace-match " " t t))
3026 (goto-char (point-min))
3027 (while (re-search-forward "[ \t]+$" nil t)
3028 (replace-match "" t t))
3029 (goto-char (point-min))
3030 (while (re-search-forward "^[ \t]+" nil t)
3031 (replace-match "" t t))
3032 (goto-char (point-min))
3033 (if gnus-simplify-subject-fuzzy-regexp
3034 (if (listp gnus-simplify-subject-fuzzy-regexp)
3035 (let ((list gnus-simplify-subject-fuzzy-regexp))
3037 (goto-char (point-min))
3038 (while (re-search-forward (car list) nil t)
3039 (replace-match "" t t))
3040 (setq list (cdr list))))
3041 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3042 (replace-match "" t t)))))
3044 (defun gnus-simplify-subject-fuzzy (subject)
3045 "Siplify a subject string fuzzily."
3047 (gnus-set-work-buffer)
3048 (let ((case-fold-search t))
3050 (inline (gnus-simplify-buffer-fuzzy))
3053 ;; Add the current buffer to the list of buffers to be killed on exit.
3054 (defun gnus-add-current-to-buffer-list ()
3055 (or (memq (current-buffer) gnus-buffer-list)
3056 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3058 (defun gnus-string> (s1 s2)
3059 (not (or (string< s1 s2)
3062 ;;; General various misc type functions.
3064 (defun gnus-clear-system ()
3065 "Clear all variables and buffers."
3066 ;; Clear Gnus variables.
3067 (let ((variables gnus-variable-list))
3069 (set (car variables) nil)
3070 (setq variables (cdr variables))))
3071 ;; Clear other internal variables.
3072 (setq gnus-list-of-killed-groups nil
3073 gnus-have-read-active-file nil
3074 gnus-newsrc-alist nil
3075 gnus-newsrc-hashtb nil
3076 gnus-killed-list nil
3077 gnus-zombie-list nil
3078 gnus-killed-hashtb nil
3079 gnus-active-hashtb nil
3080 gnus-moderated-list nil
3081 gnus-description-hashtb nil
3082 gnus-newsgroup-headers nil
3083 gnus-newsgroup-name nil
3084 gnus-server-alist nil
3085 gnus-opened-servers nil
3086 gnus-current-select-method nil)
3087 ;; Reset any score variables.
3088 (and gnus-use-scoring (gnus-score-close))
3089 ;; Kill the startup file.
3090 (and gnus-current-startup-file
3091 (get-file-buffer gnus-current-startup-file)
3092 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3093 ;; Save any cache buffers.
3094 (and gnus-use-cache (gnus-cache-save-buffers))
3095 ;; Clear the dribble buffer.
3096 (gnus-dribble-clear)
3097 ;; Close down NoCeM.
3098 (when gnus-use-nocem
3100 ;; Shut down the demons.
3101 (when gnus-use-demon
3102 (gnus-demon-cancel))
3103 ;; Kill global KILL file buffer.
3104 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
3105 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3106 (gnus-kill-buffer nntp-server-buffer)
3108 (and gnus-keep-backlog (gnus-backlog-shutdown))
3109 ;; Kill Gnus buffers.
3110 (while gnus-buffer-list
3111 (gnus-kill-buffer (car gnus-buffer-list))
3112 (setq gnus-buffer-list (cdr gnus-buffer-list))))
3114 (defun gnus-windows-old-to-new (setting)
3115 ;; First we take care of the really, really old Gnus 3 actions.
3116 (if (symbolp setting)
3118 (cond ((memq setting '(SelectArticle))
3120 ((memq setting '(SelectSubject ExpandSubject))
3122 ((memq setting '(SelectNewsgroup ExitNewsgroup))
3125 (if (or (listp setting)
3126 (not (and gnus-window-configuration
3127 (memq setting '(group summary article)))))
3129 (let* ((setting (if (eq setting 'group)
3130 (if (assq 'newsgroup gnus-window-configuration)
3132 'newsgroups) setting))
3133 (elem (cadr (assq setting gnus-window-configuration)))
3134 (total (apply '+ elem))
3135 (types '(group summary article))
3136 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3141 (or (not (numberp (nth i elem)))
3142 (zerop (nth i elem))
3144 (setq perc (/ (float (nth 0 elem)) total))
3145 (setq out (cons (if (eq pbuf (nth i types))
3146 (vector (nth i types) perc 'point)
3147 (vector (nth i types) perc))
3150 (list (nreverse out)))))
3153 (defun gnus-add-configuration (conf)
3154 "Add the window configuration CONF to `gnus-buffer-configuration'."
3155 (setq gnus-buffer-configuration
3156 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3157 gnus-buffer-configuration))))
3159 (defvar gnus-frame-list nil)
3161 (defun gnus-configure-frame (split &optional window)
3162 "Split WINDOW according to SPLIT."
3164 (setq window (get-buffer-window (current-buffer))))
3165 (select-window window)
3166 ;; This might be an old-stylee buffer config.
3167 (when (vectorp split)
3168 (setq split (append split nil)))
3169 (when (or (consp (car split))
3170 (vectorp (car split)))
3172 (push 'vertical split))
3173 ;; The SPLIT might be something that is to be evaled to
3174 ;; return a new SPLIT.
3175 (while (and (not (assq (car split) gnus-window-to-buffer))
3176 (gnus-functionp (car split)))
3177 (setq split (eval split)))
3178 (let* ((type (car split))
3180 (len (if (eq type 'horizontal) (window-width) (window-height)))
3182 (window-min-width (or gnus-window-min-width window-min-width))
3183 (window-min-height (or gnus-window-min-height window-min-height))
3184 s result new-win rest comp-subs size sub)
3186 ;; Nothing to do here.
3188 ;; Don't switch buffers.
3190 (and (memq 'point split) window))
3191 ;; This is a buffer to be selected.
3192 ((not (memq type '(frame horizontal vertical)))
3193 (let ((buffer (cond ((stringp type) type)
3194 (t (cdr (assq type gnus-window-to-buffer)))))
3197 (error "Illegal buffer type: %s" type))
3198 (unless (setq buf (get-buffer (if (symbolp buffer)
3199 (symbol-value buffer) buffer)))
3200 (setq buf (get-buffer-create (if (symbolp buffer)
3201 (symbol-value buffer) buffer))))
3202 (switch-to-buffer buf)
3203 ;; We return the window if it has the `point' spec.
3204 (and (memq 'point split) window)))
3205 ;; This is a frame split.
3207 (unless gnus-frame-list
3208 (setq gnus-frame-list (list (window-frame
3209 (get-buffer-window (current-buffer))))))
3211 params frame fresult)
3212 (while (< i (length subs))
3213 ;; Frame parameter is gotten from the sub-split.
3214 (setq params (cadr (elt subs i)))
3215 ;; It should be a list.
3216 (unless (listp params)
3218 ;; Create a new frame?
3219 (unless (setq frame (elt gnus-frame-list i))
3220 (nconc gnus-frame-list (list (setq frame (make-frame params)))))
3221 ;; Is the old frame still alive?
3222 (unless (frame-live-p frame)
3223 (setcar (nthcdr i gnus-frame-list)
3224 (setq frame (make-frame params))))
3225 ;; Select the frame in question and do more splits there.
3226 (select-frame frame)
3227 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3229 ;; Select the frame that has the selected buffer.
3231 (select-frame (window-frame fresult)))))
3232 ;; This is a normal split.
3234 (when (> (length subs) 0)
3235 ;; First we have to compute the sizes of all new windows.
3237 (setq sub (append (pop subs) nil))
3238 (while (and (not (assq (car sub) gnus-window-to-buffer))
3239 (gnus-functionp (car sub)))
3240 (setq sub (eval sub)))
3242 (push sub comp-subs)
3243 (setq size (cadar comp-subs))
3244 (cond ((equal size 1.0)
3245 (setq rest (car comp-subs))
3248 (setq s (floor (* size len))))
3252 (error "Illegal size: %s" size)))
3253 ;; Try to make sure that we are inside the safe limits.
3255 ((eq type 'horizontal)
3256 (setq s (max s window-min-width)))
3257 ((eq type 'vertical)
3258 (setq s (max s window-min-height))))
3259 (setcar (cdar comp-subs) s)
3261 ;; Take care of the "1.0" spec.
3263 (setcar (cdr rest) (- len total))
3264 (error "No 1.0 specs in %s" split))
3265 ;; The we do the actual splitting in a nice recursive
3267 (setq comp-subs (nreverse comp-subs))
3269 (if (null (cdr comp-subs))
3270 (setq new-win window)
3272 (split-window window (cadar comp-subs)
3273 (eq type 'horizontal))))
3274 (setq result (or (gnus-configure-frame
3275 (car comp-subs) window) result))
3276 (select-window new-win)
3277 (setq window new-win)
3278 (setq comp-subs (cdr comp-subs))))
3279 ;; Return the proper window, if any.
3281 (select-window result))))))
3283 (defvar gnus-frame-split-p nil)
3285 (defun gnus-configure-windows (setting &optional force)
3286 (setq setting (gnus-windows-old-to-new setting))
3287 (let ((split (if (symbolp setting)
3288 (cadr (assq setting gnus-buffer-configuration))
3290 (in-buf (current-buffer))
3291 rule val w height hor ohor heights sub jump-buffer
3292 rel total to-buf all-visible)
3294 (setq gnus-frame-split-p nil)
3297 (error "No such setting: %s" setting))
3299 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3301 ;; All the windows mentioned are already visible, so we just
3302 ;; put point in the assigned buffer, and do not touch the
3304 (select-window all-visible)
3306 ;; Either remove all windows or just remove all Gnus windows.
3307 (let ((frame (selected-frame)))
3309 (if gnus-use-full-window
3310 ;; We want to remove all other windows.
3311 (if (not gnus-frame-split-p)
3312 ;; This is not a `frame' split, so we ignore the
3314 (delete-other-windows)
3315 ;; This is a `frame' split, so we delete all windows
3319 (unless (eq (cdr (assq 'minibuffer
3320 (frame-parameters frame)))
3322 (select-frame frame)
3323 (delete-other-windows)))
3325 ;; Just remove some windows.
3326 (gnus-remove-some-windows)
3327 (switch-to-buffer nntp-server-buffer))
3328 (select-frame frame)))
3330 (switch-to-buffer nntp-server-buffer)
3331 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3333 (defun gnus-all-windows-visible-p (split)
3334 (when (vectorp split)
3335 (setq split (append split nil)))
3336 (when (or (consp (car split))
3337 (vectorp (car split)))
3339 (push 'vertical split))
3340 ;; The SPLIT might be something that is to be evaled to
3341 ;; return a new SPLIT.
3342 (while (and (not (assq (car split) gnus-window-to-buffer))
3343 (gnus-functionp (car split)))
3344 (setq split (eval split)))
3345 (let* ((type (elt split 0)))
3349 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3350 (let ((buffer (cond ((stringp type) type)
3351 (t (cdr (assq type gnus-window-to-buffer)))))
3354 (error "Illegal buffer type: %s" type))
3355 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3357 (setq win (get-buffer-window buf t)))
3359 (if (memq 'point split)
3363 (when (eq type 'frame)
3364 (setq gnus-frame-split-p t))
3365 (let ((n (mapcar 'gnus-all-windows-visible-p
3369 (cond ((windowp (car n))
3376 (defun gnus-window-top-edge (&optional window)
3377 (nth 1 (window-edges window)))
3379 (defun gnus-remove-some-windows ()
3380 (let ((buffers gnus-window-to-buffer)
3381 buf bufs lowest-buf lowest)
3383 ;; Remove windows on all known Gnus buffers.
3385 (setq buf (cdar buffers))
3387 (setq buf (and (boundp buf) (symbol-value buf))))
3389 (get-buffer-window buf)
3391 (setq bufs (cons buf bufs))
3393 (if (or (not lowest)
3394 (< (gnus-window-top-edge) lowest))
3396 (setq lowest (gnus-window-top-edge))
3397 (setq lowest-buf buf)))))
3398 (setq buffers (cdr buffers)))
3399 ;; Remove windows on *all* summary buffers.
3403 (let ((buf (window-buffer win)))
3404 (if (string-match "^\\*Summary" (buffer-name buf))
3406 (setq bufs (cons buf bufs))
3408 (if (or (not lowest)
3409 (< (gnus-window-top-edge) lowest))
3411 (setq lowest-buf buf)
3412 (setq lowest (gnus-window-top-edge))))))))))
3415 (pop-to-buffer lowest-buf)
3416 (switch-to-buffer nntp-server-buffer)))
3418 (and (not (eq (car bufs) lowest-buf))
3419 (delete-windows-on (car bufs)))
3420 (setq bufs (cdr bufs))))))
3422 (defun gnus-version ()
3423 "Version numbers of this version of Gnus."
3425 (let ((methods gnus-valid-select-methods)
3428 ;; Go through all the legal select methods and add their version
3429 ;; numbers to the total version string. Only the backends that are
3430 ;; currently in use will have their message numbers taken into
3433 (setq meth (intern (concat (caar methods) "-version")))
3435 (stringp (symbol-value meth))
3436 (setq mess (concat mess "; " (symbol-value meth))))
3437 (setq methods (cdr methods)))
3438 (gnus-message 2 mess)))
3440 (defun gnus-info-find-node ()
3441 "Find Info documentation of Gnus."
3443 ;; Enlarge info window if needed.
3444 (let ((mode major-mode)
3446 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3447 (setq gnus-info-buffer (current-buffer))
3448 (gnus-configure-windows 'info)))
3450 (defun gnus-days-between (date1 date2)
3451 ;; Return the number of days between date1 and date2.
3452 (- (gnus-day-number date1) (gnus-day-number date2)))
3454 (defun gnus-day-number (date)
3455 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3456 (timezone-parse-date date))))
3457 (timezone-absolute-from-gregorian
3458 (nth 1 dat) (nth 2 dat) (car dat))))
3460 (defun gnus-encode-date (date)
3461 "Convert DATE to internal time."
3462 (let* ((parse (timezone-parse-date date))
3463 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3464 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3465 (encode-time (caddr time) (cadr time) (car time)
3466 (caddr date) (cadr date) (car date) (nth 4 date))))
3468 (defun gnus-time-minus (t1 t2)
3469 "Subtract two internal times."
3470 (let ((borrow (< (cadr t1) (cadr t2))))
3471 (list (- (car t1) (car t2) (if borrow 1 0))
3472 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3474 (defun gnus-file-newer-than (file date)
3475 (let ((fdate (nth 5 (file-attributes file))))
3476 (or (> (car fdate) (car date))
3477 (and (= (car fdate) (car date))
3478 (> (nth 1 fdate) (nth 1 date))))))
3480 (defmacro gnus-define-keys (keymap &rest plist)
3481 "Define all keys in PLIST in KEYMAP."
3482 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3484 (defmacro gnus-define-keymap (keymap &rest plist)
3485 "Define all keys in PLIST in KEYMAP."
3486 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3488 (defun gnus-define-keys-1 (keymap plist)
3490 (error "Can't set keys in a null keymap"))
3491 (cond ((symbolp keymap)
3492 (setq keymap (symbol-value keymap)))
3495 (set (car keymap) nil)
3496 (define-prefix-command (car keymap))
3497 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3498 (setq keymap (symbol-value (car keymap)))))
3501 (when (symbolp (setq key (pop plist)))
3502 (setq key (symbol-value key)))
3503 (define-key keymap key (pop plist)))))
3505 (defun gnus-group-read-only-p (&optional group)
3506 "Check whether GROUP supports editing or not.
3507 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3508 that that variable is buffer-local to the summary buffers."
3509 (let ((group (or group gnus-newsgroup-name)))
3510 (not (gnus-check-backend-function 'request-replace-article group))))
3512 (defun gnus-group-total-expirable-p (group)
3513 "Check whether GROUP is total-expirable or not."
3514 (let ((params (gnus-info-params (gnus-get-info group))))
3515 (or (memq 'total-expire params)
3516 (cdr (assq 'total-expire params)) ; (total-expire . t)
3517 (and gnus-total-expirable-newsgroups ; Check var.
3518 (string-match gnus-total-expirable-newsgroups group)))))
3520 (defun gnus-group-auto-expirable-p (group)
3521 "Check whether GROUP is total-expirable or not."
3522 (let ((params (gnus-info-params (gnus-get-info group))))
3523 (or (memq 'auto-expire params)
3524 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3525 (and gnus-auto-expirable-newsgroups ; Check var.
3526 (string-match gnus-auto-expirable-newsgroups group)))))
3528 (defun gnus-virtual-group-p (group)
3529 "Say whether GROUP is virtual or not."
3530 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3531 gnus-valid-select-methods)))
3533 (defsubst gnus-simplify-subject-fully (subject)
3534 "Simplify a subject string according to the user's wishes."
3536 ((null gnus-summary-gather-subject-limit)
3537 (gnus-simplify-subject-re subject))
3538 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3539 (gnus-simplify-subject-fuzzy subject))
3540 ((numberp gnus-summary-gather-subject-limit)
3541 (gnus-limit-string (gnus-simplify-subject-re subject)
3542 gnus-summary-gather-subject-limit))
3546 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3547 "Check whether two subjects are equal. If optional argument
3548 simple-first is t, first argument is already simplified."
3550 ((null simple-first)
3551 (equal (gnus-simplify-subject-fully s1)
3552 (gnus-simplify-subject-fully s2)))
3555 (gnus-simplify-subject-fully s2)))))
3557 ;; Returns a list of writable groups.
3558 (defun gnus-writable-groups ()
3559 (let ((alist gnus-newsrc-alist)
3561 (while (setq group (car (pop alist)))
3562 (unless (gnus-group-read-only-p group)
3563 (push group groups)))
3566 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3568 (defun gnus-y-or-n-p (prompt)
3573 (defun gnus-yes-or-no-p (prompt)
3575 (yes-or-no-p prompt)
3578 ;; Check whether to use long file names.
3579 (defun gnus-use-long-file-name (symbol)
3580 ;; The variable has to be set...
3581 (and gnus-use-long-file-name
3582 ;; If it isn't a list, then we return t.
3583 (or (not (listp gnus-use-long-file-name))
3584 ;; If it is a list, and the list contains `symbol', we
3586 (not (memq symbol gnus-use-long-file-name)))))
3588 ;; I suspect there's a better way, but I haven't taken the time to do
3589 ;; it yet. -erik selberg@cs.washington.edu
3590 (defun gnus-dd-mmm (messy-date)
3591 "Return a string like DD-MMM from a big messy string"
3592 (let ((datevec (timezone-parse-date messy-date)))
3594 (or (aref datevec 2) "??")
3597 (nth (1- (string-to-number (aref datevec 1)))
3598 timezone-months-assoc))
3601 ;; Make a hash table (default and minimum size is 255).
3602 ;; Optional argument HASHSIZE specifies the table size.
3603 (defun gnus-make-hashtable (&optional hashsize)
3604 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3606 ;; Make a number that is suitable for hashing; bigger than MIN and one
3608 (defun gnus-create-hash-size (min)
3614 ;; Show message if message has a lower level than `gnus-verbose'.
3615 ;; Guideline for numbers:
3616 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3617 ;; for things that take a long time, 7 - not very important messages
3618 ;; on stuff, 9 - messages inside loops.
3619 (defun gnus-message (level &rest args)
3620 (if (<= level gnus-verbose)
3621 (apply 'message args)
3622 ;; We have to do this format thingy here even if the result isn't
3623 ;; shown - the return value has to be the same as the return value
3625 (apply 'format args)))
3627 (defun gnus-functionp (form)
3628 "Return non-nil if FORM is funcallable."
3629 (or (and (symbolp form) (fboundp form))
3630 (and (listp form) (eq (car form) 'lambda))))
3632 ;; Generate a unique new group name.
3633 (defun gnus-generate-new-group-name (leaf)
3636 (while (gnus-gethash name gnus-newsrc-hashtb)
3637 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3640 ;; Find out whether the gnus-visual TYPE is wanted.
3641 (defun gnus-visual-p (&optional type class)
3642 (and gnus-visual ; Has to be non-nil, at least.
3643 (if (not type) ; We don't care about type.
3645 (if (listp gnus-visual) ; It's a list, so we check it.
3646 (or (memq type gnus-visual)
3647 (memq class gnus-visual))
3650 (defun gnus-parent-id (references)
3651 "Return the last Message-ID in REFERENCES."
3652 (when (and references
3653 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3654 (substring references (match-beginning 1) (match-end 1))))
3656 (defun gnus-split-references (references)
3657 "Return a list of Message-IDs in REFERENCES."
3660 (while (string-match "<[^>]+>" references beg)
3661 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3665 (defun gnus-ephemeral-group-p (group)
3666 "Say whether GROUP is ephemeral or not."
3667 (gnus-group-get-parameter group 'quit-config))
3669 (defun gnus-group-quit-config (group)
3670 "Return the quit-config of GROUP."
3671 (gnus-group-get-parameter group 'quit-config))
3673 (defun gnus-simplify-mode-line ()
3674 "Make mode lines a bit simpler."
3675 (setq mode-line-modified "-- ")
3676 (when (listp mode-line-format)
3677 (make-local-variable 'mode-line-format)
3678 (setq mode-line-format (copy-sequence mode-line-format))
3679 (when (equal (nth 3 mode-line-format) " ")
3680 (setcar (nthcdr 3 mode-line-format) " "))))
3682 ;;; List and range functions
3684 (defun gnus-last-element (list)
3685 "Return last element of LIST."
3687 (setq list (cdr list)))
3690 (defun gnus-copy-sequence (list)
3691 "Do a complete, total copy of a list."
3692 (if (and (consp list) (not (consp (cdr list))))
3693 (cons (car list) (cdr list))
3694 (mapcar (lambda (elem) (if (consp elem)
3695 (if (consp (cdr elem))
3696 (gnus-copy-sequence elem)
3697 (cons (car elem) (cdr elem)))
3701 (defun gnus-set-difference (list1 list2)
3702 "Return a list of elements of LIST1 that do not appear in LIST2."
3703 (let ((list1 (copy-sequence list1)))
3705 (setq list1 (delq (car list2) list1))
3706 (setq list2 (cdr list2)))
3709 (defun gnus-sorted-complement (list1 list2)
3710 "Return a list of elements of LIST1 that do not appear in LIST2.
3711 Both lists have to be sorted over <."
3713 (if (or (null list1) (null list2))
3715 (while (and list1 list2)
3716 (cond ((= (car list1) (car list2))
3717 (setq list1 (cdr list1)
3719 ((< (car list1) (car list2))
3720 (setq out (cons (car list1) out))
3721 (setq list1 (cdr list1)))
3723 (setq out (cons (car list2) out))
3724 (setq list2 (cdr list2)))))
3725 (nconc (nreverse out) (or list1 list2)))))
3727 (defun gnus-intersection (list1 list2)
3730 (if (memq (car list2) list1)
3731 (setq result (cons (car list2) result)))
3732 (setq list2 (cdr list2)))
3735 (defun gnus-sorted-intersection (list1 list2)
3736 ;; LIST1 and LIST2 have to be sorted over <.
3738 (while (and list1 list2)
3739 (cond ((= (car list1) (car list2))
3740 (setq out (cons (car list1) out)
3743 ((< (car list1) (car list2))
3744 (setq list1 (cdr list1)))
3746 (setq list2 (cdr list2)))))
3749 (defun gnus-set-sorted-intersection (list1 list2)
3750 ;; LIST1 and LIST2 have to be sorted over <.
3751 ;; This function modifies LIST1.
3752 (let* ((top (cons nil list1))
3754 (while (and list1 list2)
3755 (cond ((= (car list1) (car list2))
3759 ((< (car list1) (car list2))
3760 (setcdr prev (cdr list1))
3761 (setq list1 (cdr list1)))
3763 (setq list2 (cdr list2)))))
3767 (defun gnus-compress-sequence (numbers &optional always-list)
3768 "Convert list of numbers to a list of ranges or a single range.
3769 If ALWAYS-LIST is non-nil, this function will always release a list of
3771 (let* ((first (car numbers))
3772 (last (car numbers))
3776 (if (not (listp (cdr numbers)))
3779 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3780 ((= (1+ last) (car numbers)) ;Still in sequence
3781 (setq last (car numbers)))
3782 (t ;End of one sequence
3784 (cons (if (= first last) first
3785 (cons first last)) result))
3786 (setq first (car numbers))
3787 (setq last (car numbers))))
3788 (setq numbers (cdr numbers)))
3789 (if (and (not always-list) (null result))
3790 (if (= first last) (list first) (cons first last))
3791 (nreverse (cons (if (= first last) first (cons first last))
3794 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3795 (defun gnus-uncompress-range (ranges)
3796 "Expand a list of ranges into a list of numbers.
3797 RANGES is either a single range on the form `(num . num)' or a list of
3799 (let (first last result)
3803 ((not (listp (cdr ranges)))
3804 (setq first (car ranges))
3805 (setq last (cdr ranges))
3806 (while (<= first last)
3807 (setq result (cons first result))
3808 (setq first (1+ first)))
3812 (if (atom (car ranges))
3813 (if (numberp (car ranges))
3814 (setq result (cons (car ranges) result)))
3815 (setq first (caar ranges))
3816 (setq last (cdar ranges))
3817 (while (<= first last)
3818 (setq result (cons first result))
3819 (setq first (1+ first))))
3820 (setq ranges (cdr ranges)))
3821 (nreverse result)))))
3823 (defun gnus-add-to-range (ranges list)
3824 "Return a list of ranges that has all articles from both RANGES and LIST.
3825 Note: LIST has to be sorted over `<'."
3827 (gnus-compress-sequence list t)
3828 (setq list (copy-sequence list))
3829 (or (listp (cdr ranges))
3830 (setq ranges (list ranges)))
3832 ilist lowest highest temp)
3833 (while (and ranges list)
3835 (setq lowest (or (and (atom (car ranges)) (car ranges))
3837 (while (and list (cdr list) (< (cadr list) lowest))
3838 (setq list (cdr list)))
3839 (if (< (car ilist) lowest)
3842 (setq list (cdr list))
3844 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3845 (setq highest (or (and (atom (car ranges)) (car ranges))
3847 (while (and list (<= (car list) highest))
3848 (setq list (cdr list)))
3849 (setq ranges (cdr ranges)))
3851 (setq out (nconc (gnus-compress-sequence list t) out)))
3852 (setq out (sort out (lambda (r1 r2)
3853 (< (or (and (atom r1) r1) (car r1))
3854 (or (and (atom r2) r2) (car r2))))))
3857 (if (atom (car ranges))
3859 (if (atom (cadr ranges))
3860 (if (= (1+ (car ranges)) (cadr ranges))
3862 (setcar ranges (cons (car ranges)
3864 (setcdr ranges (cddr ranges))))
3865 (if (= (1+ (car ranges)) (caadr ranges))
3867 (setcar (cadr ranges) (car ranges))
3868 (setcar ranges (cadr ranges))
3869 (setcdr ranges (cddr ranges))))))
3871 (if (atom (cadr ranges))
3872 (if (= (1+ (cdar ranges)) (cadr ranges))
3874 (setcdr (car ranges) (cadr ranges))
3875 (setcdr ranges (cddr ranges))))
3876 (if (= (1+ (cdar ranges)) (caadr ranges))
3878 (setcdr (car ranges) (cdadr ranges))
3879 (setcdr ranges (cddr ranges)))))))
3880 (setq ranges (cdr ranges)))
3883 (defun gnus-remove-from-range (ranges list)
3884 "Return a list of ranges that has all articles from LIST removed from RANGES.
3885 Note: LIST has to be sorted over `<'."
3886 ;; !!! This function shouldn't look like this, but I've got a headache.
3887 (gnus-compress-sequence
3888 (gnus-sorted-complement
3889 (gnus-uncompress-range ranges) list)))
3891 (defun gnus-member-of-range (number ranges)
3892 (if (not (listp (cdr ranges)))
3893 (and (>= number (car ranges))
3894 (<= number (cdr ranges)))
3897 (if (numberp (car ranges))
3898 (>= number (car ranges))
3899 (>= number (caar ranges)))
3901 (if (if (numberp (car ranges))
3902 (= number (car ranges))
3903 (and (>= number (caar ranges))
3904 (<= number (cdar ranges))))
3905 (setq not-stop nil))
3906 (setq ranges (cdr ranges)))
3909 (defun gnus-range-length (range)
3910 "Return the length RANGE would have if uncompressed."
3911 (length (gnus-uncompress-range range)))
3913 (defun gnus-sublist-p (list sublist)
3914 "Test whether all elements in SUBLIST are members of LIST."
3917 (unless (memq (pop sublist) list)
3927 (defvar gnus-group-mode-map nil)
3928 (put 'gnus-group-mode 'mode-class 'special)
3930 (unless gnus-group-mode-map
3931 (setq gnus-group-mode-map (make-keymap))
3932 (suppress-keymap gnus-group-mode-map)
3936 " " gnus-group-read-group
3937 "=" gnus-group-select-group
3938 "\M- " gnus-group-unhidden-select-group
3939 "\r" gnus-group-select-group
3940 "\M-\r" gnus-group-quick-select-group
3941 "j" gnus-group-jump-to-group
3942 "n" gnus-group-next-unread-group
3943 "p" gnus-group-prev-unread-group
3944 "\177" gnus-group-prev-unread-group
3945 [delete] gnus-group-prev-unread-group
3946 "N" gnus-group-next-group
3947 "P" gnus-group-prev-group
3948 "\M-n" gnus-group-next-unread-group-same-level
3949 "\M-p" gnus-group-prev-unread-group-same-level
3950 "," gnus-group-best-unread-group
3951 "." gnus-group-first-unread-group
3952 "u" gnus-group-unsubscribe-current-group
3953 "U" gnus-group-unsubscribe-group
3954 "c" gnus-group-catchup-current
3955 "C" gnus-group-catchup-current-all
3956 "l" gnus-group-list-groups
3957 "L" gnus-group-list-all-groups
3959 "g" gnus-group-get-new-news
3960 "\M-g" gnus-group-get-new-news-this-group
3961 "R" gnus-group-restart
3962 "r" gnus-group-read-init-file
3963 "B" gnus-group-browse-foreign-server
3964 "b" gnus-group-check-bogus-groups
3965 "F" gnus-find-new-newsgroups
3966 "\C-c\C-d" gnus-group-describe-group
3967 "\M-d" gnus-group-describe-all-groups
3968 "\C-c\C-a" gnus-group-apropos
3969 "\C-c\M-\C-a" gnus-group-description-apropos
3970 "a" gnus-group-post-news
3971 "\ek" gnus-group-edit-local-kill
3972 "\eK" gnus-group-edit-global-kill
3973 "\C-k" gnus-group-kill-group
3974 "\C-y" gnus-group-yank-group
3975 "\C-w" gnus-group-kill-region
3976 "\C-x\C-t" gnus-group-transpose-groups
3977 "\C-c\C-l" gnus-group-list-killed
3978 "\C-c\C-x" gnus-group-expire-articles
3979 "\C-c\M-\C-x" gnus-group-expire-all-groups
3981 "s" gnus-group-save-newsrc
3982 "z" gnus-group-suspend
3983 "Z" gnus-group-clear-dribble
3986 "?" gnus-group-describe-briefly
3987 "\C-c\C-i" gnus-info-find-node
3988 "\M-e" gnus-group-edit-group-method
3989 "^" gnus-group-enter-server-mode
3990 gnus-mouse-2 gnus-mouse-pick-group
3991 "<" beginning-of-buffer
3994 "\C-c\C-s" gnus-group-sort-groups
3996 "\C-c\M-g" gnus-activate-all-groups
3997 "\M-&" gnus-group-universal-argument
3998 "#" gnus-group-mark-group
3999 "\M-#" gnus-group-unmark-group)
4002 (gnus-group-mark-map "M" gnus-group-mode-map)
4003 "m" gnus-group-mark-group
4004 "u" gnus-group-unmark-group
4005 "w" gnus-group-mark-region
4006 "m" gnus-group-mark-buffer
4007 "r" gnus-group-mark-regexp
4008 "U" gnus-group-unmark-all-groups)
4011 (gnus-group-group-map "G" gnus-group-mode-map)
4012 "d" gnus-group-make-directory-group
4013 "h" gnus-group-make-help-group
4014 "a" gnus-group-make-archive-group
4015 "k" gnus-group-make-kiboze-group
4016 "m" gnus-group-make-group
4017 "E" gnus-group-edit-group
4018 "e" gnus-group-edit-group-method
4019 "p" gnus-group-edit-group-parameters
4020 "v" gnus-group-add-to-virtual
4021 "V" gnus-group-make-empty-virtual
4022 "D" gnus-group-enter-directory
4023 "f" gnus-group-make-doc-group
4024 "r" gnus-group-rename-group
4025 "\177" gnus-group-delete-group
4026 [delete] gnus-group-delete-group)
4029 (gnus-group-soup-map "s" gnus-group-group-map)
4030 "b" gnus-group-brew-soup
4031 "w" gnus-soup-save-areas
4032 "s" gnus-soup-send-replies
4033 "p" gnus-soup-pack-packet
4034 "r" nnsoup-pack-replies)
4037 (gnus-group-sort-map "S" gnus-group-group-map)
4038 "s" gnus-group-sort-groups
4039 "a" gnus-group-sort-groups-by-alphabet
4040 "u" gnus-group-sort-groups-by-unread
4041 "l" gnus-group-sort-groups-by-level
4042 "v" gnus-group-sort-groups-by-score
4043 "r" gnus-group-sort-groups-by-rank
4044 "m" gnus-group-sort-groups-by-method)
4047 (gnus-group-list-map "A" gnus-group-mode-map)
4048 "k" gnus-group-list-killed
4049 "z" gnus-group-list-zombies
4050 "s" gnus-group-list-groups
4051 "u" gnus-group-list-all-groups
4052 "A" gnus-group-list-active
4053 "a" gnus-group-apropos
4054 "d" gnus-group-description-apropos
4055 "m" gnus-group-list-matching
4056 "M" gnus-group-list-all-matching
4057 "l" gnus-group-list-level)
4060 (gnus-group-score-map "W" gnus-group-mode-map)
4061 "f" gnus-score-flush-cache)
4064 (gnus-group-help-map "H" gnus-group-mode-map)
4065 "f" gnus-group-fetch-faq)
4068 (gnus-group-sub-map "S" gnus-group-mode-map)
4069 "l" gnus-group-set-current-level
4070 "t" gnus-group-unsubscribe-current-group
4071 "s" gnus-group-unsubscribe-group
4072 "k" gnus-group-kill-group
4073 "y" gnus-group-yank-group
4074 "w" gnus-group-kill-region
4075 "\C-k" gnus-group-kill-level
4076 "z" gnus-group-kill-all-zombies))
4078 (defun gnus-group-mode ()
4079 "Major mode for reading news.
4081 All normal editing commands are switched off.
4082 \\<gnus-group-mode-map>
4083 The group buffer lists (some of) the groups available. For instance,
4084 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4085 lists all zombie groups.
4087 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4088 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4090 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4092 The following commands are available:
4094 \\{gnus-group-mode-map}"
4096 (when (and menu-bar-mode
4097 (gnus-visual-p 'group-menu 'menu))
4098 (gnus-group-make-menu-bar))
4099 (kill-all-local-variables)
4100 (gnus-simplify-mode-line)
4101 (setq major-mode 'gnus-group-mode)
4102 (setq mode-name "Group")
4103 (gnus-group-set-mode-line)
4104 (setq mode-line-process nil)
4105 (use-local-map gnus-group-mode-map)
4106 (buffer-disable-undo (current-buffer))
4107 (setq truncate-lines t)
4108 (setq buffer-read-only t)
4109 (run-hooks 'gnus-group-mode-hook))
4111 (defun gnus-mouse-pick-group (e)
4112 "Enter the group under the mouse pointer."
4115 (gnus-group-read-group nil))
4117 ;; Look at LEVEL and find out what the level is really supposed to be.
4118 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4119 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4120 (defun gnus-group-default-level (&optional level number-or-nil)
4122 (gnus-group-use-permanent-levels
4123 (setq gnus-group-default-list-level
4124 (or level gnus-group-default-list-level))
4125 (or gnus-group-default-list-level gnus-level-subscribed))
4129 (or level gnus-group-default-list-level gnus-level-subscribed))))
4132 (defun gnus-slave-no-server (&optional arg)
4133 "Read network news as a slave, without connecting to local server"
4135 (gnus-no-server arg t))
4138 (defun gnus-no-server (&optional arg slave)
4140 If ARG is a positive number, Gnus will use that as the
4141 startup level. If ARG is nil, Gnus will be started at level 2.
4142 If ARG is non-nil and not a positive number, Gnus will
4143 prompt the user for the name of an NNTP server to use.
4144 As opposed to `gnus', this command will not connect to the local server."
4146 (make-local-variable 'gnus-group-use-permanent-levels)
4147 (setq gnus-group-use-permanent-levels t)
4148 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4151 (defun gnus-slave (&optional arg)
4152 "Read news as a slave."
4154 (gnus arg nil 'slave))
4157 (defun gnus-other-frame (&optional arg)
4158 "Pop up a frame to read news."
4160 (if (get-buffer gnus-group-buffer)
4161 (let ((pop-up-frames t))
4163 (select-frame (make-frame))
4167 (defun gnus (&optional arg dont-connect slave)
4169 If ARG is non-nil and a positive number, Gnus will use that as the
4170 startup level. If ARG is non-nil and not a positive number, Gnus will
4171 prompt the user for the name of an NNTP server to use."
4174 (if (get-buffer gnus-group-buffer)
4176 (switch-to-buffer gnus-group-buffer)
4177 (gnus-group-get-new-news))
4180 (nnheader-init-server-buffer)
4181 (gnus-read-init-file)
4182 (setq gnus-slave slave)
4184 (gnus-group-setup-buffer)
4185 (let ((buffer-read-only nil))
4187 (if (not gnus-inhibit-startup-message)
4189 (gnus-group-startup-message)
4192 (let ((level (and (numberp arg) (> arg 0) arg))
4198 (gnus-start-news-server (and arg (not level))))))
4199 (if (and (not dont-connect)
4202 (run-hooks 'gnus-startup-hook)
4203 ;; NNTP server is successfully open.
4205 ;; Find the current startup file name.
4206 (setq gnus-current-startup-file
4207 (gnus-make-newsrc-file gnus-startup-file))
4209 ;; Read the dribble file.
4210 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4212 ;; Allow using GroupLens predictions.
4213 (when gnus-use-grouplens
4215 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4217 (gnus-summary-make-display-table)
4218 ;; Do the actual startup.
4219 (gnus-setup-news nil level)
4220 ;; Generate the group buffer.
4221 (gnus-group-list-groups level)
4222 (gnus-group-first-unread-group)
4223 (gnus-configure-windows 'group)
4224 (gnus-group-set-mode-line))))))
4226 (defun gnus-unload ()
4227 "Unload all Gnus features."
4229 (or (boundp 'load-history)
4230 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4231 (let ((history load-history)
4234 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4235 (setq feature (cdr (assq 'provide (car history))))
4236 (unload-feature feature 'force))
4237 (setq history (cdr history)))))
4239 (defun gnus-compile ()
4240 "Byte-compile the user-defined format specs."
4242 (let ((entries gnus-format-specs)
4243 entry gnus-tmp-func)
4245 (gnus-message 7 "Compiling format specs...")
4248 (setq entry (pop entries))
4249 (if (eq (car entry) 'version)
4250 (setq gnus-format-specs (delq entry gnus-format-specs))
4251 (when (and (listp (caddr entry))
4252 (not (eq 'byte-code (caaddr entry))))
4253 (fset 'gnus-tmp-func
4254 `(lambda () ,(caddr entry)))
4255 (byte-compile 'gnus-tmp-func)
4256 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4258 (push (cons 'version emacs-version) gnus-format-specs)
4260 (gnus-message 7 "Compiling user specs...done"))))
4262 (defun gnus-indent-rigidly (start end arg)
4263 "Indent rigidly using only spaces and no tabs."
4266 (narrow-to-region start end)
4267 (indent-rigidly start end arg)
4268 (goto-char (point-min))
4269 (while (search-forward "\t" nil t)
4270 (replace-match " " t t)))))
4272 (defun gnus-group-startup-message (&optional x y)
4273 "Insert startup message in current buffer."
4274 ;; Insert the message.
4279 _ ___ __ ___ __ _ ___
4298 ;; And then hack it.
4299 (gnus-indent-rigidly (point-min) (point-max)
4300 (/ (max (- (window-width) (or x 46)) 0) 2))
4301 (goto-char (point-min))
4303 (let* ((pheight (count-lines (point-min) (point-max)))
4304 (wheight (window-height))
4305 (rest (- wheight pheight)))
4306 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4308 (goto-char (point-min))
4309 (and (search-forward "Praxis" nil t)
4310 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4311 (goto-char (point-min))
4312 (let* ((mode-string (gnus-group-set-mode-line)))
4313 (setq mode-line-buffer-identification
4314 (list (concat gnus-version (substring (car mode-string) 4))))
4315 (set-buffer-modified-p t)))
4317 (defun gnus-group-setup-buffer ()
4318 (or (get-buffer gnus-group-buffer)
4320 (switch-to-buffer gnus-group-buffer)
4321 (gnus-add-current-to-buffer-list)
4323 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4325 (defun gnus-group-list-groups (&optional level unread lowest)
4326 "List newsgroups with level LEVEL or lower that have unread articles.
4327 Default is all subscribed groups.
4328 If argument UNREAD is non-nil, groups with no unread articles are also
4330 (interactive (list (if current-prefix-arg
4331 (prefix-numeric-value current-prefix-arg)
4333 (gnus-group-default-level nil t)
4334 gnus-group-default-list-level
4335 gnus-level-subscribed))))
4337 (setq level (car gnus-group-list-mode)
4338 unread (cdr gnus-group-list-mode)))
4339 (setq level (gnus-group-default-level level))
4340 (gnus-group-setup-buffer) ;May call from out of group buffer
4341 (gnus-update-format-specifications)
4342 (let ((case-fold-search nil)
4343 (props (text-properties-at (gnus-point-at-bol)))
4344 (group (gnus-group-group-name)))
4345 (funcall gnus-group-prepare-function level unread lowest)
4346 (if (zerop (buffer-size))
4347 (gnus-message 5 gnus-no-groups-message)
4348 (goto-char (point-max))
4349 (when (or (not gnus-group-goto-next-group-function)
4350 (not (funcall gnus-group-goto-next-group-function
4353 ;; Go to the first group with unread articles.
4354 (gnus-group-search-forward t)
4355 ;; Find the right group to put point on. If the current group
4356 ;; has disappeared in the new listing, try to find the next
4357 ;; one. If no next one can be found, just leave point at the
4358 ;; first newsgroup in the buffer.
4359 (if (not (gnus-goto-char
4361 (point-min) (point-max)
4362 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4363 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4365 (not (gnus-goto-char
4367 (point-min) (point-max) 'gnus-group
4369 (caar newsrc) gnus-active-hashtb)))))
4370 (setq newsrc (cdr newsrc)))
4371 (or newsrc (progn (goto-char (point-max))
4372 (forward-line -1)))))))
4373 ;; Adjust cursor point.
4374 (gnus-group-position-point))))
4376 (defun gnus-group-list-level (level &optional all)
4377 "List groups on LEVEL.
4378 If ALL (the prefix), also list groups that have no unread articles."
4379 (interactive "nList groups on level: \nP")
4380 (gnus-group-list-groups level all level))
4382 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4383 "List all newsgroups with unread articles of level LEVEL or lower.
4384 If ALL is non-nil, list groups that have no unread articles.
4385 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4386 If REGEXP, only list groups matching REGEXP."
4387 (set-buffer gnus-group-buffer)
4388 (let ((buffer-read-only nil)
4389 (newsrc (cdr gnus-newsrc-alist))
4390 (lowest (or lowest 1))
4391 info clevel unread group params)
4393 (if (< lowest gnus-level-zombie)
4394 ;; List living groups.
4396 (setq info (car newsrc)
4397 group (gnus-info-group info)
4398 params (gnus-info-params info)
4400 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4401 (and unread ; This group might be bogus
4403 (string-match regexp group))
4404 (<= (setq clevel (gnus-info-level info)) level)
4406 (or all ; We list all groups?
4407 (and gnus-group-list-inactive-groups
4408 (eq unread t)) ; We list unactivated groups
4409 (> unread 0) ; We list groups with unread articles
4410 (and gnus-list-groups-with-ticked-articles
4411 (cdr (assq 'tick (gnus-info-marks info))))
4412 ; And groups with tickeds
4413 ;; Check for permanent visibility.
4414 (and gnus-permanently-visible-groups
4415 (string-match gnus-permanently-visible-groups
4417 (memq 'visible params)
4418 (cdr (assq 'visible params)))
4419 (gnus-group-insert-group-line
4420 group (gnus-info-level info)
4421 (gnus-info-marks info) unread (gnus-info-method info)))))
4423 ;; List dead groups.
4424 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4425 (gnus-group-prepare-flat-list-dead
4426 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4427 gnus-level-zombie ?Z
4429 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4430 (gnus-group-prepare-flat-list-dead
4431 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4432 gnus-level-killed ?K regexp))
4434 (gnus-group-set-mode-line)
4435 (setq gnus-group-list-mode (cons level all))
4436 (run-hooks 'gnus-group-prepare-hook)))
4438 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4439 ;; List zombies and killed lists somewhat faster, which was
4440 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4441 ;; this by ignoring the group format specification altogether.
4444 ;; This loop is used when listing groups that match some
4447 (setq group (pop groups))
4448 (when (string-match regexp group)
4449 (add-text-properties
4450 (point) (prog1 (1+ (point))
4451 (insert " " mark " *: " group "\n"))
4452 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4454 'gnus-level level))))
4455 ;; This loop is used when listing all groups.
4457 (add-text-properties
4458 (point) (prog1 (1+ (point))
4459 (insert " " mark " *: "
4460 (setq group (pop groups)) "\n"))
4461 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4463 'gnus-level level))))))
4465 (defmacro gnus-group-real-name (group)
4466 "Find the real name of a foreign newsgroup."
4467 `(let ((gname ,group))
4468 (if (string-match ":[^:]+$" gname)
4469 (substring gname (1+ (match-beginning 0)))
4472 (defsubst gnus-server-add-address (method)
4473 (let ((method-name (symbol-name (car method))))
4474 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4475 (not (assq (intern (concat method-name "-address")) method)))
4476 (append method (list (list (intern (concat method-name "-address"))
4480 (defsubst gnus-server-get-method (group method)
4481 ;; Input either a server name, and extended server name, or a
4482 ;; select method, and return a select method.
4483 (cond ((stringp method)
4484 (gnus-server-to-method method))
4485 ((and (stringp (car method)) group)
4486 (gnus-server-extend-method group method))
4488 (gnus-server-add-address method))))
4490 (defun gnus-server-to-method (server)
4491 "Map virtual server names to select methods."
4493 ;; Perhaps this is the native server?
4494 (and (equal server "native") gnus-select-method)
4495 ;; It should be in the server alist.
4496 (cdr (assoc server gnus-server-alist))
4497 ;; If not, we look through all the opened server
4498 ;; to see whether we can find it there.
4499 (let ((opened gnus-opened-servers))
4501 (not (equal server (format "%s:%s" (caaar opened)
4506 (defmacro gnus-server-equal (ss1 ss2)
4507 "Say whether two servers are equal."
4511 (and (= (length s1) (length s2))
4513 (while (and s1 (member (car s1) s2))
4517 (defun gnus-group-prefixed-name (group method)
4518 "Return the whole name from GROUP and METHOD."
4519 (and (stringp method) (setq method (gnus-server-to-method method)))
4520 (concat (format "%s" (car method))
4522 (or (assoc (format "%s" (car method))
4523 (gnus-methods-using 'address))
4524 (equal method gnus-message-archive-method))
4525 (not (string= (nth 1 method) "")))
4526 (concat "+" (nth 1 method)))
4529 (defun gnus-group-real-prefix (group)
4530 "Return the prefix of the current group name."
4531 (if (string-match "^[^:]+:" group)
4532 (substring group 0 (match-end 0))
4535 (defun gnus-group-method (group)
4536 "Return the server or method used for selecting GROUP."
4537 (let ((prefix (gnus-group-real-prefix group)))
4538 (if (equal prefix "")
4540 (let ((servers gnus-opened-servers)
4542 backend possible found)
4543 (if (string-match "^[^\\+]+\\+" prefix)
4544 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4545 server (substring prefix (match-end 0) (1- (length prefix))))
4546 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4548 (when (eq (caaar servers) backend)
4549 (setq possible (caar servers))
4550 (when (equal (cadaar servers) server)
4551 (setq found (caar servers))))
4553 (or (car (rassoc found gnus-server-alist))
4555 (car (rassoc possible gnus-server-alist))
4557 (list backend server))))))
4559 (defsubst gnus-secondary-method-p (method)
4560 "Return whether METHOD is a secondary select method."
4561 (let ((methods gnus-secondary-select-methods)
4562 (gmethod (gnus-server-get-method nil method)))
4564 (not (equal (gnus-server-get-method nil (car methods))
4566 (setq methods (cdr methods)))
4569 (defun gnus-group-foreign-p (group)
4570 "Say whether a group is foreign or not."
4571 (and (not (gnus-group-native-p group))
4572 (not (gnus-group-secondary-p group))))
4574 (defun gnus-group-native-p (group)
4575 "Say whether the group is native or not."
4576 (not (string-match ":" group)))
4578 (defun gnus-group-secondary-p (group)
4579 "Say whether the group is secondary or not."
4580 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4582 (defun gnus-group-get-parameter (group &optional symbol)
4583 "Returns the group parameters for GROUP.
4584 If SYMBOL, return the value of that symbol in the group parameters."
4585 (let ((params (gnus-info-params (gnus-get-info group))))
4587 (gnus-group-parameter-value params symbol)
4590 (defun gnus-group-parameter-value (params symbol)
4591 "Return the value of SYMBOL in group PARAMS."
4592 (or (car (memq symbol params)) ; It's either a simple symbol
4593 (cdr (assq symbol params)))) ; or a cons.
4595 (defun gnus-group-add-parameter (group param)
4596 "Add parameter PARAM to GROUP."
4597 (let ((info (gnus-get-info group)))
4599 () ; This is a dead group. We just ignore it.
4600 ;; Cons the new param to the old one and update.
4601 (gnus-group-set-info (cons param (gnus-info-params info))
4604 (defun gnus-group-set-parameter (group name value)
4605 "Set parameter NAME to VALUE in GROUP."
4606 (let ((info (gnus-get-info group)))
4608 () ; This is a dead group. We just ignore it.
4609 (let ((old-params (gnus-info-params info))
4610 (new-params (list (cons name value))))
4612 (if (or (not (listp (car old-params)))
4613 (not (eq (caar old-params) name)))
4614 (setq new-params (append new-params (list (car old-params)))))
4615 (setq old-params (cdr old-params)))
4616 (gnus-group-set-info new-params group 'params)))))
4618 (defun gnus-group-add-score (group &optional score)
4619 "Add SCORE to the GROUP score.
4620 If SCORE is nil, add 1 to the score of GROUP."
4621 (let ((info (gnus-get-info group)))
4622 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4624 (defun gnus-summary-bubble-group ()
4625 "Increase the score of the current group.
4626 This is a handy function to add to `gnus-summary-exit-hook' to
4627 increase the score of each group you read."
4628 (gnus-group-add-score gnus-newsgroup-name))
4630 (defun gnus-group-set-info (info &optional method-only-group part)
4631 (let* ((entry (gnus-gethash
4632 (or method-only-group (gnus-info-group info))
4633 gnus-newsrc-hashtb))
4635 (info (if method-only-group (nth 2 entry) info)))
4636 (when method-only-group
4638 (error "Trying to change non-existent group %s" method-only-group))
4639 ;; We have received parts of the actual group info - either the
4640 ;; select method or the group parameters. We first check
4641 ;; whether we have to extend the info, and if so, do that.
4642 (let ((len (length info))
4643 (total (if (eq part 'method) 5 6)))
4645 (setcdr (nthcdr (1- len) info)
4646 (make-list (- total len) nil)))
4647 ;; Then we enter the new info.
4648 (setcar (nthcdr (1- total) info) part-info)))
4650 ;; This is a new group, so we just create it.
4652 (set-buffer gnus-group-buffer)
4653 (if (gnus-info-method info)
4654 ;; It's a foreign group...
4655 (gnus-group-make-group
4656 (gnus-group-real-name (gnus-info-group info))
4657 (prin1-to-string (car (gnus-info-method info)))
4658 (nth 1 (gnus-info-method info)))
4659 ;; It's a native group.
4660 (gnus-group-make-group (gnus-info-group info)))
4661 (gnus-message 6 "Note: New group created")
4663 (gnus-gethash (gnus-group-prefixed-name
4664 (gnus-group-real-name (gnus-info-group info))
4665 (or (gnus-info-method info) gnus-select-method))
4666 gnus-newsrc-hashtb))))
4667 ;; Whether it was a new group or not, we now have the entry, so we
4668 ;; can do the update.
4671 (setcar (nthcdr 2 entry) info)
4672 (when (and (not (eq (car entry) t))
4673 (gnus-active (gnus-info-group info)))
4674 (let ((marked (gnus-info-marks info)))
4675 (setcar entry (length (gnus-list-of-unread-articles
4677 (error "No such group: %s" (gnus-info-group info)))))
4679 (defun gnus-group-set-method-info (group select-method)
4680 (gnus-group-set-info select-method group 'method))
4682 (defun gnus-group-set-params-info (group params)
4683 (gnus-group-set-info params group 'params))
4685 (defun gnus-group-update-group-line ()
4686 "Update the current line in the group buffer."
4687 (let* ((buffer-read-only nil)
4688 (group (gnus-group-group-name))
4689 (gnus-group-indentation (gnus-group-group-indentation))
4690 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4692 (not (gnus-ephemeral-group-p group))
4694 (concat "(gnus-group-set-info '"
4695 (prin1-to-string (nth 2 entry)) ")")))
4697 (gnus-group-insert-group-line-info group)
4699 (gnus-group-position-point)))
4701 (defun gnus-group-insert-group-line-info (group)
4702 "Insert GROUP on the current line."
4703 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4707 ;; (Un)subscribed group.
4708 (setq info (nth 2 entry))
4709 (gnus-group-insert-group-line
4710 group (gnus-info-level info) (gnus-info-marks info)
4711 (or (car entry) t) (gnus-info-method info)))
4712 ;; This group is dead.
4713 (gnus-group-insert-group-line
4715 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4717 (if (setq active (gnus-active group))
4718 (- (1+ (cdr active)) (car active)) 0)
4721 (defun gnus-group-insert-group-line
4722 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4724 "Insert a group line in the group buffer."
4725 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4726 (gnus-tmp-number-total
4728 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4730 (gnus-tmp-number-of-unread
4731 (if (numberp number) (int-to-string (max 0 number))
4733 (gnus-tmp-number-of-read
4734 (if (numberp number)
4735 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4737 (gnus-tmp-subscribed
4738 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4739 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4740 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4742 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4743 (gnus-tmp-newsgroup-description
4744 (if gnus-description-hashtb
4745 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4748 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4749 (gnus-tmp-moderated-string
4750 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4752 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4753 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4754 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4755 (gnus-tmp-news-method-string
4757 (format "(%s:%s)" (car gnus-tmp-method)
4758 (cadr gnus-tmp-method)) ""))
4759 (gnus-tmp-marked-mark
4760 (if (and (numberp number)
4762 (cdr (assq 'tick gnus-tmp-marked)))
4764 (gnus-tmp-process-marked
4765 (if (member gnus-tmp-group gnus-group-marked)
4766 gnus-process-mark ? ))
4768 (or (and gnus-use-grouplens
4769 (bbb-grouplens-group-p gnus-tmp-group))
4771 (buffer-read-only nil)
4772 header gnus-tmp-header) ; passed as parameter to user-funcs.
4774 (add-text-properties
4778 (eval gnus-group-line-format-spec))
4779 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4780 gnus-unread ,(if (numberp number)
4781 (string-to-int gnus-tmp-number-of-unread)
4783 gnus-marked ,gnus-tmp-marked-mark
4784 gnus-indentation ,gnus-group-indentation
4785 gnus-level ,gnus-tmp-level))
4786 (when (gnus-visual-p 'group-highlight 'highlight)
4788 (run-hooks 'gnus-group-update-hook)
4790 ;; Allow XEmacs to remove front-sticky text properties.
4791 (gnus-group-remove-excess-properties)))
4793 (defun gnus-group-update-group (group &optional visible-only)
4794 "Update all lines where GROUP appear.
4795 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4798 (set-buffer gnus-group-buffer)
4799 ;; The buffer may be narrowed.
4802 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4804 found buffer-read-only visible)
4805 ;; Enter the current status into the dribble buffer.
4806 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4807 (if (and entry (not (gnus-ephemeral-group-p group)))
4809 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4811 ;; Find all group instances. If topics are in use, each group
4812 ;; may be listed in more than once.
4813 (while (setq loc (text-property-any
4814 loc (point-max) 'gnus-group ident))
4817 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4819 (gnus-group-insert-group-line-info group))
4820 (setq loc (1+ loc)))
4821 (unless (or found visible-only)
4822 ;; No such line in the buffer, find out where it's supposed to
4823 ;; go, and insert it there (or at the end of the buffer).
4824 (if gnus-goto-missing-group-function
4825 (funcall gnus-goto-missing-group-function group)
4826 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4827 (while (and entry (car entry)
4831 (point-min) (point-max)
4832 'gnus-group (gnus-intern-safe
4833 (caar entry) gnus-active-hashtb)))))
4834 (setq entry (cdr entry)))
4835 (or entry (goto-char (point-max)))))
4836 ;; Finally insert the line.
4837 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4838 (gnus-group-insert-group-line-info group)))
4839 (gnus-group-set-mode-line)))))
4841 (defun gnus-group-set-mode-line ()
4842 (when (memq 'group gnus-updated-mode-lines)
4843 (let* ((gformat (or gnus-group-mode-line-format-spec
4844 (setq gnus-group-mode-line-format-spec
4846 gnus-group-mode-line-format
4847 gnus-group-mode-line-format-alist))))
4848 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4849 (gnus-tmp-news-method (car gnus-select-method))
4851 gnus-tmp-header ;Dummy binding for user-defined formats
4852 ;; Get the resulting string.
4853 (mode-string (eval gformat)))
4854 ;; If the line is too long, we chop it off.
4855 (when (> (length mode-string) max-len)
4856 (setq mode-string (substring mode-string 0 (- max-len 4))))
4858 (setq mode-line-buffer-identification (list mode-string))
4859 (set-buffer-modified-p t)))))
4861 (defun gnus-group-group-name ()
4862 "Get the name of the newsgroup on the current line."
4863 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4864 (and group (symbol-name group))))
4866 (defun gnus-group-group-level ()
4867 "Get the level of the newsgroup on the current line."
4868 (get-text-property (gnus-point-at-bol) 'gnus-level))
4870 (defun gnus-group-group-indentation ()
4871 "Get the indentation of the newsgroup on the current line."
4872 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4874 (defun gnus-group-group-unread ()
4875 "Get the number of unread articles of the newsgroup on the current line."
4876 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4878 (defun gnus-group-search-forward (&optional backward all level first-too)
4879 "Find the next newsgroup with unread articles.
4880 If BACKWARD is non-nil, find the previous newsgroup instead.
4881 If ALL is non-nil, just find any newsgroup.
4882 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4884 If FIRST-TOO, the current line is also eligible as a target."
4885 (let ((way (if backward -1 1))
4886 (low gnus-level-killed)
4889 (if (and backward (progn (beginning-of-line)) (bobp))
4891 (or first-too (forward-line way))
4899 (get-text-property (point) 'gnus-unread)))
4900 (and (numberp unread) (> unread 0)))
4901 (setq lev (get-text-property (point)
4903 (<= lev gnus-level-subscribed)))
4905 (and (setq lev (get-text-property (point)
4914 (zerop (forward-line way)))))
4916 (progn (gnus-group-position-point) t)
4917 (goto-char (or pos beg))
4920 ;;; Gnus group mode commands
4924 (defun gnus-group-mark-group (n &optional unmark no-advance)
4925 "Mark the current group."
4927 (let ((buffer-read-only nil)
4931 (setq group (gnus-group-group-name))
4935 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4940 (setq gnus-group-marked (delete group gnus-group-marked)))
4942 (setq gnus-group-marked
4943 (cons group (delete group gnus-group-marked))))
4945 (or no-advance (zerop (gnus-group-next-group 1))))
4947 (gnus-summary-position-point)
4950 (defun gnus-group-unmark-group (n)
4951 "Remove the mark from the current group."
4953 (gnus-group-mark-group n 'unmark)
4954 (gnus-group-position-point))
4956 (defun gnus-group-unmark-all-groups ()
4957 "Unmark all groups."
4958 (let ((groups gnus-group-marked))
4961 (gnus-group-remove-mark (pop groups)))))
4962 (gnus-group-position-point))
4964 (defun gnus-group-mark-region (unmark beg end)
4965 "Mark all groups between point and mark.
4966 If UNMARK, remove the mark instead."
4967 (interactive "P\nr")
4968 (let ((num (count-lines beg end)))
4971 (- num (gnus-group-mark-group num unmark)))))
4973 (defun gnus-group-mark-buffer (&optional unmark)
4974 "Mark all groups in the buffer.
4975 If UNMARK, remove the mark instead."
4977 (gnus-group-mark-region unmark (point-min) (point-max)))
4979 (defun gnus-group-mark-regexp (regexp)
4980 "Mark all groups that match some regexp."
4981 (interactive "sMark (regexp): ")
4982 (let ((alist (cdr gnus-newsrc-alist))
4985 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
4986 (gnus-group-set-mark group))))
4987 (gnus-group-position-point))
4989 (defun gnus-group-remove-mark (group)
4990 "Remove the process mark from GROUP and move point there.
4991 Return nil if the group isn't displayed."
4992 (if (gnus-group-goto-group group)
4994 (gnus-group-mark-group 1 'unmark t)
4996 (setq gnus-group-marked
4997 (delete group gnus-group-marked))
5000 (defun gnus-group-set-mark (group)
5001 "Set the process mark on GROUP."
5002 (if (gnus-group-goto-group group)
5004 (gnus-group-mark-group 1 nil t))
5005 (setq gnus-group-marked
5006 (cons group (delete group gnus-group-marked)))))
5008 (defun gnus-group-universal-argument (arg &optional groups func)
5009 "Perform any command on all groups accoring to the process/prefix convention."
5011 (let ((groups (or groups (gnus-group-process-prefix arg)))
5013 (if (eq (setq func (or func
5016 (substitute-command-keys
5017 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5020 (message "Undefined key")
5023 (gnus-group-remove-mark (setq group (pop groups)))
5024 (command-execute func))))
5025 (gnus-group-position-point))
5027 (defun gnus-group-process-prefix (n)
5028 "Return a list of groups to work on.
5029 Take into consideration N (the prefix) and the list of marked groups."
5032 (setq n (prefix-numeric-value n))
5033 ;; There is a prefix, so we return a list of the N next
5035 (let ((way (if (< n 0) -1 1))
5040 (setq group (gnus-group-group-name)))
5041 (setq groups (cons group groups))
5043 (gnus-group-next-group way)))
5045 ((and (boundp 'transient-mark-mode)
5048 ;; Work on the region between point and mark.
5049 (let ((max (max (point) (mark)))
5052 (goto-char (min (point) (mark)))
5055 (push (gnus-group-group-name) groups)
5056 (zerop (gnus-group-next-group 1))
5058 (nreverse groups))))
5060 ;; No prefix, but a list of marked articles.
5061 (reverse gnus-group-marked))
5063 ;; Neither marked articles or a prefix, so we return the
5065 (let ((group (gnus-group-group-name)))
5066 (and group (list group))))))
5068 ;; Selecting groups.
5070 (defun gnus-group-read-group (&optional all no-article group)
5071 "Read news in this newsgroup.
5072 If the prefix argument ALL is non-nil, already read articles become
5073 readable. IF ALL is a number, fetch this number of articles. If the
5074 optional argument NO-ARTICLE is non-nil, no article will be
5075 auto-selected upon group entry. If GROUP is non-nil, fetch that
5078 (let ((group (or group (gnus-group-group-name)))
5079 number active marked entry)
5080 (or group (error "No group on current line"))
5081 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5082 group gnus-newsrc-hashtb)))))
5083 ;; This group might be a dead group. In that case we have to get
5084 ;; the number of unread articles from `gnus-active-hashtb'.
5086 (cond ((numberp all) all)
5088 ((setq active (gnus-active group))
5089 (- (1+ (cdr active)) (car active)))))
5090 (gnus-summary-read-group
5091 group (or all (and (numberp number)
5092 (zerop (+ number (length (cdr (assq 'tick marked)))
5093 (length (cdr (assq 'dormant marked)))))))
5096 (defun gnus-group-select-group (&optional all)
5097 "Select this newsgroup.
5098 No article is selected automatically.
5099 If ALL is non-nil, already read articles become readable.
5100 If ALL is a number, fetch this number of articles."
5102 (gnus-group-read-group all t))
5104 (defun gnus-group-quick-select-group (&optional all)
5105 "Select the current group \"quickly\".
5106 This means that no highlighting or scoring will be performed."
5109 gnus-score-find-score-files-function
5110 gnus-apply-kill-hook
5111 gnus-summary-expunge-below)
5112 (gnus-group-read-group all t)))
5114 (defun gnus-group-visible-select-group (&optional all)
5115 "Select the current group without hiding any articles."
5117 (let ((gnus-inhibit-limiting t))
5118 (gnus-group-read-group all t)))
5121 (defun gnus-fetch-group (group)
5122 "Start Gnus if necessary and enter GROUP.
5123 Returns whether the fetching was successful or not."
5124 (interactive "sGroup name: ")
5125 (or (get-buffer gnus-group-buffer)
5127 (gnus-group-select-group))
5129 ;; Enter a group that is not in the group buffer. Non-nil is returned
5130 ;; if selection was successful.
5131 (defun gnus-group-read-ephemeral-group
5132 (group method &optional activate quit-config)
5133 (let ((group (if (gnus-group-foreign-p group) group
5134 (gnus-group-prefixed-name group method))))
5137 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5138 ((quit-config . ,(if quit-config quit-config
5139 (cons (current-buffer) 'summary))))))
5141 (set-buffer gnus-group-buffer)
5142 (or (gnus-check-server method)
5143 (error "Unable to contact server: %s" (gnus-status-message method)))
5144 (if activate (or (gnus-request-group group)
5145 (error "Couldn't request group")))
5147 (gnus-group-read-group t t group)
5151 (defun gnus-group-jump-to-group (group)
5152 "Jump to newsgroup GROUP."
5154 (list (completing-read
5155 "Group: " gnus-active-hashtb nil
5156 (memq gnus-select-method gnus-have-read-active-file))))
5158 (if (equal group "")
5159 (error "Empty group name"))
5161 (let ((b (text-property-any
5162 (point-min) (point-max)
5163 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5164 (unless (gnus-ephemeral-group-p group)
5166 ;; Either go to the line in the group buffer...
5168 ;; ... or insert the line.
5171 (gnus-activate-group group)
5172 (error "%s error: %s" group (gnus-status-message group)))
5174 (gnus-group-update-group group)
5175 (goto-char (text-property-any
5176 (point-min) (point-max)
5177 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5178 ;; Adjust cursor point.
5179 (gnus-group-position-point)))
5181 (defun gnus-group-goto-group (group)
5182 "Goto to newsgroup GROUP."
5184 (let ((b (text-property-any (point-min) (point-max)
5185 'gnus-group (gnus-intern-safe
5186 group gnus-active-hashtb))))
5187 (and b (goto-char b)))))
5189 (defun gnus-group-next-group (n)
5190 "Go to next N'th newsgroup.
5191 If N is negative, search backward instead.
5192 Returns the difference between N and the number of skips actually
5195 (gnus-group-next-unread-group n t))
5197 (defun gnus-group-next-unread-group (n &optional all level)
5198 "Go to next N'th unread newsgroup.
5199 If N is negative, search backward instead.
5200 If ALL is non-nil, choose any newsgroup, unread or not.
5201 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5202 such group can be found, the next group with a level higher than
5204 Returns the difference between N and the number of skips actually
5207 (let ((backward (< n 0))
5210 (gnus-group-search-forward
5211 backward (or (not gnus-group-goto-unread) all) level))
5213 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5214 (if level " on this level or higher" "")))
5217 (defun gnus-group-prev-group (n)
5218 "Go to previous N'th newsgroup.
5219 Returns the difference between N and the number of skips actually
5222 (gnus-group-next-unread-group (- n) t))
5224 (defun gnus-group-prev-unread-group (n)
5225 "Go to previous N'th unread newsgroup.
5226 Returns the difference between N and the number of skips actually
5229 (gnus-group-next-unread-group (- n)))
5231 (defun gnus-group-next-unread-group-same-level (n)
5232 "Go to next N'th unread newsgroup on the same level.
5233 If N is negative, search backward instead.
5234 Returns the difference between N and the number of skips actually
5237 (gnus-group-next-unread-group n t (gnus-group-group-level))
5238 (gnus-group-position-point))
5240 (defun gnus-group-prev-unread-group-same-level (n)
5241 "Go to next N'th unread newsgroup on the same level.
5242 Returns the difference between N and the number of skips actually
5245 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5246 (gnus-group-position-point))
5248 (defun gnus-group-best-unread-group (&optional exclude-group)
5249 "Go to the group with the highest level.
5250 If EXCLUDE-GROUP, do not go to that group."
5252 (goto-char (point-min))
5255 (while (setq unread (get-text-property (point) 'gnus-unread))
5256 (if (and (numberp unread) (> unread 0))
5258 (if (and (< (get-text-property (point) 'gnus-level) best)
5259 (or (not exclude-group)
5260 (not (equal exclude-group (gnus-group-group-name)))))
5262 (setq best (get-text-property (point) 'gnus-level))
5263 (setq best-point (point))))))
5265 (if best-point (goto-char best-point))
5266 (gnus-summary-position-point)
5267 (and best-point (gnus-group-group-name))))
5269 (defun gnus-group-first-unread-group ()
5270 "Go to the first group with unread articles."
5273 (let ((opoint (point))
5275 (goto-char (point-min))
5276 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5277 (and (numberp unread) ; Not a topic.
5278 (not (zerop unread))) ; Has unread articles.
5279 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5282 nil)) ; Not success.
5283 (gnus-group-position-point)))
5285 (defun gnus-group-enter-server-mode ()
5286 "Jump to the server buffer."
5288 (gnus-enter-server-buffer))
5290 (defun gnus-group-make-group (name &optional method address)
5291 "Add a new newsgroup.
5292 The user will be prompted for a NAME, for a select METHOD, and an
5296 (read-string "Group name: ")
5299 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5301 (if (assoc method gnus-valid-select-methods)
5303 (if (memq 'prompt-address
5304 (assoc method gnus-valid-select-methods))
5305 (read-string "Address: ")
5307 (list method "")))))
5310 (set-buffer gnus-group-buffer)
5311 (let* ((meth (and method (if address (list (intern method) address)
5313 (nname (if method (gnus-group-prefixed-name name meth) name))
5315 (and (gnus-gethash nname gnus-newsrc-hashtb)
5316 (error "Group %s already exists" nname))
5317 (gnus-group-change-level
5318 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5319 gnus-level-default-subscribed gnus-level-killed
5320 (and (gnus-group-group-name)
5321 (gnus-gethash (gnus-group-group-name)
5322 gnus-newsrc-hashtb))
5324 (gnus-set-active nname (cons 1 0))
5325 (or (gnus-ephemeral-group-p name)
5327 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5328 (gnus-group-insert-group-line-info nname)
5330 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5331 (require (car meth)))
5332 (gnus-check-server meth)
5333 (and (gnus-check-backend-function 'request-create-group nname)
5334 (gnus-request-create-group nname))
5337 (defun gnus-group-delete-group (group &optional force)
5338 "Delete the current group.
5339 If FORCE (the prefix) is non-nil, all the articles in the group will
5340 be deleted. This is \"deleted\" as in \"removed forever from the face
5341 of the Earth\". There is no undo."
5343 (list (gnus-group-group-name)
5344 current-prefix-arg))
5345 (or group (error "No group to rename"))
5346 (or (gnus-check-backend-function 'request-delete-group group)
5347 (error "This backend does not support group deletion"))
5349 (if (not (gnus-yes-or-no-p
5351 "Do you really want to delete %s%s? "
5352 group (if force " and all its contents" ""))))
5354 (gnus-message 6 "Deleting group %s..." group)
5355 (if (not (gnus-request-delete-group group force))
5357 (gnus-message 3 "Couldn't delete group %s" group)
5359 (gnus-message 6 "Deleting group %s...done" group)
5360 (gnus-group-goto-group group)
5361 (gnus-group-kill-group 1 t)
5363 (gnus-group-position-point)))
5365 (defun gnus-group-rename-group (group new-name)
5368 (gnus-group-group-name)
5370 (or (gnus-check-backend-function
5371 'request-rename-group (gnus-group-group-name))
5372 (error "This backend does not support renaming groups"))
5373 (read-string "New group name: "))))
5375 (or (gnus-check-backend-function 'request-rename-group group)
5376 (error "This backend does not support renaming groups"))
5378 (or group (error "No group to rename"))
5379 (and (string-match "^[ \t]*$" new-name)
5380 (error "Not a valid group name"))
5382 ;; We find the proper prefixed name.
5384 (gnus-group-prefixed-name
5385 (gnus-group-real-name new-name)
5386 (gnus-info-method (gnus-get-info group))))
5388 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5390 (if (not (gnus-request-rename-group group new-name))
5392 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5394 ;; We rename the group internally by killing it...
5395 (gnus-group-goto-group group)
5396 (gnus-group-kill-group)
5397 ;; ... changing its name ...
5398 (setcar (cdr (car gnus-list-of-killed-groups))
5400 ;; ... and then yanking it. Magic!
5401 (gnus-group-yank-group)
5402 (gnus-set-active new-name (gnus-active group))
5403 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5405 (gnus-group-position-point)))
5407 (defun gnus-group-edit-group (group &optional part)
5408 "Edit the group on the current line."
5409 (interactive (list (gnus-group-group-name)))
5410 (let ((done-func '(lambda ()
5411 "Exit editing mode and update the information."
5413 (gnus-group-edit-group-done 'part 'group)))
5414 (part (or part 'info))
5415 (winconf (current-window-configuration))
5417 (or group (error "No group on current line"))
5418 (or (setq info (gnus-get-info group))
5419 (error "Killed group; can't be edited"))
5420 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5421 (gnus-configure-windows 'edit-group)
5422 (gnus-add-current-to-buffer-list)
5424 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5425 (use-local-map (copy-keymap emacs-lisp-mode-map))
5426 (local-set-key "\C-c\C-c" done-func)
5427 (make-local-variable 'gnus-prev-winconf)
5428 (setq gnus-prev-winconf winconf)
5429 ;; We modify the func to let it know what part it is editing.
5430 (setcar (cdr (nth 4 done-func)) (list 'quote part))
5431 (setcar (cdr (cdr (nth 4 done-func))) group)
5436 ";; Type `C-c C-c' after editing the select method.\n\n")
5438 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5440 ";; Type `C-c C-c' after editing the group info.\n\n")))
5443 (cond ((eq part 'method)
5444 (or (gnus-info-method info) "native"))
5446 (gnus-info-params info))
5450 (defun gnus-group-edit-group-method (group)
5451 "Edit the select method of GROUP."
5452 (interactive (list (gnus-group-group-name)))
5453 (gnus-group-edit-group group 'method))
5455 (defun gnus-group-edit-group-parameters (group)
5456 "Edit the group parameters of GROUP."
5457 (interactive (list (gnus-group-group-name)))
5458 (gnus-group-edit-group group 'params))
5460 (defun gnus-group-edit-group-done (part group)
5461 "Get info from buffer, update variables and jump to the group buffer."
5462 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5463 (goto-char (point-min))
5464 (let* ((form (read (current-buffer)))
5465 (winconf gnus-prev-winconf)
5466 (new-group (when (eq part 'info)
5467 (if (or (not (nth 4 form))
5469 gnus-select-method (nth 4 form)))
5470 (gnus-group-real-name (car form))
5471 (gnus-group-prefixed-name
5472 (gnus-group-real-name (car form)) (nth 4 form))))))
5476 (when new-group (setcar form new-group))
5477 (gnus-group-set-info form))
5478 (gnus-group-set-info form group part))
5479 (kill-buffer (current-buffer))
5480 (and winconf (set-window-configuration winconf))
5481 (set-buffer gnus-group-buffer)
5482 (when (and new-group
5483 (not (equal new-group group)))
5484 (when (gnus-group-goto-group group)
5485 (gnus-group-kill-group 1))
5486 (gnus-activate-group new-group))
5487 (gnus-group-update-group (or new-group group))
5488 (gnus-group-position-point)))
5490 (defun gnus-group-make-help-group ()
5491 "Create the Gnus documentation group."
5493 (let ((path load-path)
5494 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5496 (and (gnus-gethash name gnus-newsrc-hashtb)
5497 (error "Documentation group already exists"))
5499 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5501 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5503 (setq file (concat (file-name-directory
5504 (directory-file-name dir))
5505 "etc/gnus-tut.txt"))))
5508 (message "Couldn't find doc group")
5509 (gnus-group-make-group
5510 (gnus-group-real-name name)
5512 (list 'nndoc-address file)
5513 (list 'nndoc-article-type 'mbox)))))
5514 (gnus-group-position-point))
5516 (defun gnus-group-make-doc-group (file type)
5517 "Create a group that uses a single file as the source."
5519 (list (read-file-name "File name: ")
5520 (and current-prefix-arg 'ask)))
5521 (when (eq type 'ask)
5526 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5528 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5529 ((= char ?b) 'babyl)
5530 ((= char ?d) 'digest)
5531 ((= char ?f) 'forward)
5533 (t (setq err (format "%c unknown. " char))
5536 (let* ((file (expand-file-name file))
5537 (name (gnus-generate-new-group-name
5538 (gnus-group-prefixed-name
5539 (file-name-nondirectory file) '(nndoc "")))))
5540 (gnus-group-make-group
5541 (gnus-group-real-name name)
5543 (list 'nndoc-address file)
5544 (list 'nndoc-article-type (or type 'guess))))
5546 (gnus-group-position-point)))
5548 (defun gnus-group-make-archive-group (&optional all)
5549 "Create the (ding) Gnus archive group of the most recent articles.
5550 Given a prefix, create a full group."
5552 (let ((group (gnus-group-prefixed-name
5553 (if all "ding.archives" "ding.recent") '(nndir ""))))
5554 (and (gnus-gethash group gnus-newsrc-hashtb)
5555 (error "Archive group already exists"))
5556 (gnus-group-make-group
5557 (gnus-group-real-name group)
5558 (list 'nndir (if all "hpc" "edu")
5559 (list 'nndir-directory
5560 (if all gnus-group-archive-directory
5561 gnus-group-recent-archive-directory)))))
5563 (gnus-group-position-point))
5565 (defun gnus-group-make-directory-group (dir)
5566 "Create an nndir group.
5567 The user will be prompted for a directory. The contents of this
5568 directory will be used as a newsgroup. The directory should contain
5569 mail messages or news articles in files that have numeric names."
5571 (list (read-file-name "Create group from directory: ")))
5572 (or (file-exists-p dir) (error "No such directory"))
5573 (or (file-directory-p dir) (error "Not a directory"))
5577 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5579 (gnus-group-prefixed-name
5580 (concat (file-name-as-directory (directory-file-name dir))
5583 (setq ext (format "<%d>" (setq i (1+ i)))))
5584 (gnus-group-make-group
5585 (gnus-group-real-name group)
5586 (list 'nndir group (list 'nndir-directory dir))))
5588 (gnus-group-position-point))
5590 (defun gnus-group-make-kiboze-group (group address scores)
5591 "Create an nnkiboze group.
5592 The user will be prompted for a name, a regexp to match groups, and
5593 score file entries for articles to include in the group."
5596 (read-string "nnkiboze group name: ")
5597 (read-string "Source groups (regexp): ")
5598 (let ((headers (mapcar (lambda (group) (list group))
5599 '("subject" "from" "number" "date" "message-id"
5600 "references" "chars" "lines" "xref"
5601 "followup" "all" "body" "head")))
5602 scores header regexp regexps)
5603 (while (not (equal "" (setq header (completing-read
5604 "Match on header: " headers nil t))))
5606 (while (not (equal "" (setq regexp (read-string
5607 (format "Match on %s (string): "
5609 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5610 (setq scores (cons (cons header regexps) scores)))
5612 (gnus-group-make-group group "nnkiboze" address)
5614 (gnus-set-work-buffer)
5615 (let (emacs-lisp-mode-hook)
5616 (pp scores (current-buffer)))
5617 (write-region (point-min) (point-max)
5618 (gnus-score-file-name (concat "nnkiboze:" group))))
5620 (gnus-group-position-point))
5622 (defun gnus-group-add-to-virtual (n vgroup)
5623 "Add the current group to a virtual group."
5625 (list current-prefix-arg
5626 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5628 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5629 (error "%s is not an nnvirtual group" vgroup))
5630 (let* ((groups (gnus-group-process-prefix n))
5631 (method (gnus-info-method (gnus-get-info vgroup))))
5632 (setcar (cdr method)
5634 (nth 1 method) "\\|"
5637 (gnus-group-remove-mark s)
5638 (concat "\\(^" (regexp-quote s) "$\\)"))
5640 (gnus-group-position-point))
5642 (defun gnus-group-make-empty-virtual (group)
5643 "Create a new, fresh, empty virtual group."
5644 (interactive "sCreate new, empty virtual group: ")
5645 (let* ((method (list 'nnvirtual "^$"))
5646 (pgroup (gnus-group-prefixed-name group method)))
5647 ;; Check whether it exists already.
5648 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5649 (error "Group %s already exists." pgroup))
5650 ;; Subscribe the new group after the group on the current line.
5651 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5652 (gnus-group-update-group pgroup)
5654 (gnus-group-position-point)))
5656 (defun gnus-group-enter-directory (dir)
5657 "Enter an ephemeral nneething group."
5658 (interactive "DDirectory to read: ")
5659 (let* ((method (list 'nneething dir))
5660 (leaf (gnus-group-prefixed-name
5661 (file-name-nondirectory (directory-file-name dir))
5663 (name (gnus-generate-new-group-name leaf)))
5664 (let ((nneething-read-only t))
5665 (or (gnus-group-read-ephemeral-group
5667 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5669 (error "Couldn't enter %s" dir)))))
5671 ;; Group sorting commands
5672 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5674 (defun gnus-group-sort-groups (func &optional reverse)
5675 "Sort the group buffer according to FUNC.
5676 If REVERSE, reverse the sorting order."
5677 (interactive (list gnus-group-sort-function
5678 current-prefix-arg))
5680 ((not (listp func)) func)
5682 ((= 1 (length func)) (car func))
5684 ,(gnus-make-sort-function
5685 (reverse func)))))))
5686 ;; We peel off the dummy group from the alist.
5688 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5689 (pop gnus-newsrc-alist))
5691 (setq gnus-newsrc-alist
5692 (sort gnus-newsrc-alist func))
5694 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5695 ;; Regenerate the hash table.
5696 (gnus-make-hashtable-from-newsrc-alist)
5697 (gnus-group-list-groups))))
5699 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5700 "Sort the group buffer alphabetically by group name.
5701 If REVERSE, sort in reverse order."
5703 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5705 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5706 "Sort the group buffer by number of unread articles.
5707 If REVERSE, sort in reverse order."
5709 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5711 (defun gnus-group-sort-groups-by-level (&optional reverse)
5712 "Sort the group buffer by group level.
5713 If REVERSE, sort in reverse order."
5715 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5717 (defun gnus-group-sort-groups-by-score (&optional reverse)
5718 "Sort the group buffer by group score.
5719 If REVERSE, sort in reverse order."
5721 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5723 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5724 "Sort the group buffer by group rank.
5725 If REVERSE, sort in reverse order."
5727 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5729 (defun gnus-group-sort-groups-by-method (&optional reverse)
5730 "Sort the group buffer alphabetically by backend name.
5731 If REVERSE, sort in reverse order."
5733 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5735 (defun gnus-group-sort-by-alphabet (info1 info2)
5736 "Sort alphabetically."
5737 (string< (gnus-info-group info1) (gnus-info-group info2)))
5739 (defun gnus-group-sort-by-unread (info1 info2)
5740 "Sort by number of unread articles."
5741 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5742 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5743 (< (or (and (numberp n1) n1) 0)
5744 (or (and (numberp n2) n2) 0))))
5746 (defun gnus-group-sort-by-level (info1 info2)
5748 (< (gnus-info-level info1) (gnus-info-level info2)))
5750 (defun gnus-group-sort-by-method (info1 info2)
5751 "Sort alphabetically by backend name."
5752 (string< (symbol-name (car (gnus-find-method-for-group
5753 (gnus-info-group info1) info1)))
5754 (symbol-name (car (gnus-find-method-for-group
5755 (gnus-info-group info2) info2)))))
5757 (defun gnus-group-sort-by-score (info1 info2)
5758 "Sort by group score."
5759 (< (gnus-info-score info1) (gnus-info-score info2)))
5761 (defun gnus-group-sort-by-rank (info1 info2)
5762 "Sort by level and score."
5763 (let ((level1 (gnus-info-level info1))
5764 (level2 (gnus-info-level info2)))
5765 (or (< level1 level2)
5766 (and (= level1 level2)
5767 (< (gnus-info-score info1) (gnus-info-score info2))))))
5769 ;; Group catching up.
5771 (defun gnus-group-catchup-current (&optional n all)
5772 "Mark all articles not marked as unread in current newsgroup as read.
5773 If prefix argument N is numeric, the ARG next newsgroups will be
5774 caught up. If ALL is non-nil, marked articles will also be marked as
5775 read. Cross references (Xref: header) of articles are ignored.
5776 The difference between N and actual number of newsgroups that were
5777 caught up is returned."
5779 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5783 "Do you really want to mark all articles as read? "
5784 "Mark all unread articles as read? "))))
5786 (let ((groups (gnus-group-process-prefix n))
5789 ;; Virtual groups have to be given special treatment.
5790 (let ((method (gnus-find-method-for-group (car groups))))
5791 (if (eq 'nnvirtual (car method))
5792 (nnvirtual-catchup-group
5793 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5794 (gnus-group-remove-mark (car groups))
5796 (gnus-group-goto-group (car groups))
5797 (gnus-group-catchup (car groups) all))
5798 (gnus-group-update-group-line)
5799 (setq ret (1+ ret)))
5800 (setq groups (cdr groups)))
5801 (gnus-group-next-unread-group 1)
5804 (defun gnus-group-catchup-current-all (&optional n)
5805 "Mark all articles in current newsgroup as read.
5806 Cross references (Xref: header) of articles are ignored."
5808 (gnus-group-catchup-current n 'all))
5810 (defun gnus-group-catchup (group &optional all)
5811 "Mark all articles in GROUP as read.
5812 If ALL is non-nil, all articles are marked as read.
5813 The return value is the number of articles that were marked as read,
5814 or nil if no action could be taken."
5815 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5817 ;; Do the updating only if the newsgroup isn't killed.
5818 (if (not (numberp (car entry)))
5819 (gnus-message 1 "Can't catch up; non-active group")
5820 ;; Do auto-expirable marks if that's required.
5821 (when (gnus-group-auto-expirable-p group)
5822 (gnus-add-marked-articles
5823 group 'expire (gnus-list-of-unread-articles group))
5825 (let ((marks (nth 3 (nth 2 entry))))
5826 (gnus-add-marked-articles
5827 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5828 (gnus-add-marked-articles
5829 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5831 (gnus-update-read-articles group nil)
5832 ;; Also nix out the lists of marks and dormants.
5834 (gnus-add-marked-articles group 'tick nil nil 'force)
5835 (gnus-add-marked-articles group 'dormant nil nil 'force))
5836 (run-hooks 'gnus-group-catchup-group-hook)
5839 (defun gnus-group-expire-articles (&optional n)
5840 "Expire all expirable articles in the current newsgroup."
5842 (let ((groups (gnus-group-process-prefix n))
5845 (error "No groups to expire"))
5846 (while (setq group (pop groups))
5847 (gnus-group-remove-mark group)
5848 (when (gnus-check-backend-function 'request-expire-articles group)
5849 (gnus-message 6 "Expiring articles in %s..." group)
5850 (let* ((info (gnus-get-info group))
5851 (expirable (if (gnus-group-total-expirable-p group)
5852 (cons nil (gnus-list-of-read-articles group))
5853 (assq 'expire (gnus-info-marks info))))
5854 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5858 (gnus-compress-sequence
5860 ;; We set the expiry variables to the groupp
5862 (let ((nnmail-expiry-wait-function nil)
5863 (nnmail-expiry-wait expiry-wait))
5864 (gnus-request-expire-articles
5865 (gnus-uncompress-sequence (cdr expirable)) group))
5866 ;; Just expire using the normal expiry values.
5867 (gnus-request-expire-articles
5868 (gnus-uncompress-sequence (cdr expirable)) group)))))
5869 (gnus-message 6 "Expiring articles in %s...done" group)))
5870 (gnus-group-position-point))))
5872 (defun gnus-group-expire-all-groups ()
5873 "Expire all expirable articles in all newsgroups."
5876 (gnus-message 5 "Expiring...")
5877 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5878 (cdr gnus-newsrc-alist))))
5879 (gnus-group-expire-articles nil)))
5880 (gnus-group-position-point)
5881 (gnus-message 5 "Expiring...done"))
5883 (defun gnus-group-set-current-level (n level)
5884 "Set the level of the next N groups to LEVEL."
5888 (if (not (gnus-group-group-name))
5889 (error "No group on the current line")
5891 (let ((s (read-string
5892 (format "Level (default %s): " (gnus-group-group-level)))))
5893 (if (string-match "^\\s-*$" s)
5894 (int-to-string (gnus-group-group-level))
5896 (or (and (>= level 1) (<= level gnus-level-killed))
5897 (error "Illegal level: %d" level))
5898 (let ((groups (gnus-group-process-prefix n))
5900 (while (setq group (pop groups))
5901 (gnus-group-remove-mark group)
5902 (gnus-message 6 "Changed level of %s from %d to %d"
5903 group (or (gnus-group-group-level) gnus-level-killed)
5905 (gnus-group-change-level
5906 group level (or (gnus-group-group-level) gnus-level-killed))
5907 (gnus-group-update-group-line)))
5908 (gnus-group-position-point))
5910 (defun gnus-group-unsubscribe-current-group (&optional n)
5911 "Toggle subscription of the current group.
5912 If given numerical prefix, toggle the N next groups."
5914 (let ((groups (gnus-group-process-prefix n))
5917 (setq group (car groups)
5918 groups (cdr groups))
5919 (gnus-group-remove-mark group)
5920 (gnus-group-unsubscribe-group
5921 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5922 gnus-level-default-unsubscribed
5923 gnus-level-default-subscribed) t)
5924 (gnus-group-update-group-line))
5925 (gnus-group-next-group 1)))
5927 (defun gnus-group-unsubscribe-group (group &optional level silent)
5928 "Toggle subscription to GROUP.
5929 Killed newsgroups are subscribed. If SILENT, don't try to update the
5932 (list (completing-read
5933 "Group: " gnus-active-hashtb nil
5934 (memq gnus-select-method gnus-have-read-active-file))))
5935 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5937 ((string-match "^[ \t]$" group)
5938 (error "Empty group name"))
5940 ;; Toggle subscription flag.
5941 (gnus-group-change-level
5942 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5943 gnus-level-subscribed)
5944 (1+ gnus-level-subscribed)
5945 gnus-level-default-subscribed)))
5947 (gnus-group-update-group group)))
5948 ((and (stringp group)
5949 (or (not (memq gnus-select-method gnus-have-read-active-file))
5950 (gnus-active group)))
5951 ;; Add new newsgroup.
5952 (gnus-group-change-level
5954 (if level level gnus-level-default-subscribed)
5955 (or (and (member group gnus-zombie-list)
5958 (and (gnus-group-group-name)
5959 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5961 (gnus-group-update-group group)))
5962 (t (error "No such newsgroup: %s" group)))
5963 (gnus-group-position-point)))
5965 (defun gnus-group-transpose-groups (n)
5966 "Move the current newsgroup up N places.
5967 If given a negative prefix, move down instead. The difference between
5968 N and the number of steps taken is returned."
5970 (or (gnus-group-group-name)
5971 (error "No group on current line"))
5972 (gnus-group-kill-group 1)
5974 (forward-line (- n))
5975 (gnus-group-yank-group)
5976 (gnus-group-position-point)))
5978 (defun gnus-group-kill-all-zombies ()
5979 "Kill all zombie newsgroups."
5981 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
5982 (setq gnus-zombie-list nil)
5983 (gnus-group-list-groups))
5985 (defun gnus-group-kill-region (begin end)
5986 "Kill newsgroups in current region (excluding current point).
5987 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6002 (beginning-of-line) ;Important when LINES < 1
6003 (gnus-group-kill-group lines)))
6005 (defun gnus-group-kill-group (&optional n discard)
6006 "Kill the next N groups.
6007 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6008 However, only groups that were alive can be yanked; already killed
6009 groups or zombie groups can't be yanked.
6010 The return value is the name of the group that was killed, or a list
6013 (let ((buffer-read-only nil)
6014 (groups (gnus-group-process-prefix n))
6015 group entry level out)
6016 (if (< (length groups) 10)
6017 ;; This is faster when there are few groups.
6019 (push (setq group (pop groups)) out)
6020 (gnus-group-remove-mark group)
6021 (setq level (gnus-group-group-level))
6023 (if (and (not discard)
6024 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6025 (setq gnus-list-of-killed-groups
6026 (cons (cons (car entry) (nth 2 entry))
6027 gnus-list-of-killed-groups)))
6028 (gnus-group-change-level
6029 (if entry entry group) gnus-level-killed (if entry nil level)))
6030 ;; If there are lots and lots of groups to be killed, we use
6031 ;; this thing instead.
6033 (setq groups (nreverse groups))
6035 (gnus-group-remove-mark (setq group (pop groups)))
6038 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6039 (push (cons (car entry) (nth 2 entry))
6040 gnus-list-of-killed-groups)
6041 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))
6042 ((member group gnus-zombie-list)
6043 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6044 (gnus-make-hashtable-from-newsrc-alist)))
6046 (gnus-group-position-point)
6047 (if (< (length out) 2) (car out) (nreverse out))))
6049 (defun gnus-group-yank-group (&optional arg)
6050 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6051 inserting it before the current newsgroup. The numeric ARG specifies
6052 how many newsgroups are to be yanked. The name of the newsgroup yanked
6053 is returned, or (if several groups are yanked) a list of yanked groups
6056 (setq arg (or arg 1))
6057 (let (info group prev out)
6058 (while (>= (decf arg) 0)
6059 (if (not (setq info (pop gnus-list-of-killed-groups)))
6060 (error "No more newsgroups to yank"))
6061 (push (setq group (nth 1 info)) out)
6062 ;; Find which newsgroup to insert this one before - search
6063 ;; backward until something suitable is found. If there are no
6064 ;; other newsgroups in this buffer, just make this newsgroup the
6066 (setq prev (gnus-group-group-name))
6067 (gnus-group-change-level
6068 info (nth 2 info) gnus-level-killed
6069 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6071 (gnus-group-insert-group-line-info group))
6073 (gnus-group-position-point)
6074 (if (< (length out) 2) (car out) (nreverse out))))
6076 (defun gnus-group-kill-level (level)
6077 "Kill all groups that is on a certain LEVEL."
6078 (interactive "nKill all groups on level: ")
6080 ((= level gnus-level-zombie)
6081 (setq gnus-killed-list
6082 (nconc gnus-zombie-list gnus-killed-list))
6083 (setq gnus-zombie-list nil))
6084 ((and (< level gnus-level-zombie)
6086 (or gnus-expert-user
6089 "Do you really want to kill all groups on level %d? "
6091 (let* ((prev gnus-newsrc-alist)
6094 (if (= (gnus-info-level level) level)
6095 (setcdr prev (cdr alist))
6097 (setq alist (cdr alist)))
6098 (gnus-make-hashtable-from-newsrc-alist)
6099 (gnus-group-list-groups)))
6101 (error "Can't kill; illegal level: %d" level))))
6103 (defun gnus-group-list-all-groups (&optional arg)
6104 "List all newsgroups with level ARG or lower.
6105 Default is gnus-level-unsubscribed, which lists all subscribed and most
6106 unsubscribed groups."
6108 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6110 ;; Redefine this to list ALL killed groups if prefix arg used.
6111 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6112 (defun gnus-group-list-killed (&optional arg)
6113 "List all killed newsgroups in the group buffer.
6114 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6115 entail asking the server for the groups."
6117 ;; Find all possible killed newsgroups if arg.
6119 ;; First make sure active file has been read.
6120 (unless gnus-have-read-active-file
6121 (let ((gnus-read-active-file t))
6122 (gnus-read-active-file)))
6123 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6124 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6128 (group (symbol-name sym)))
6129 (if (or (null group)
6130 (gnus-gethash group gnus-killed-hashtb)
6131 (gnus-gethash group gnus-newsrc-hashtb))
6133 (let ((do-sub (gnus-matches-options-n group)))
6134 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6136 (setq groups (1+ groups))
6137 (setq gnus-killed-list
6138 (cons group gnus-killed-list))
6139 (gnus-sethash group group gnus-killed-hashtb))))))
6140 gnus-active-hashtb))
6141 (if (not gnus-killed-list)
6142 (gnus-message 6 "No killed groups")
6143 (let (gnus-group-list-mode)
6144 (funcall gnus-group-prepare-function
6145 gnus-level-killed t gnus-level-killed))
6146 (goto-char (point-min)))
6147 (gnus-group-position-point))
6149 (defun gnus-group-list-zombies ()
6150 "List all zombie newsgroups in the group buffer."
6152 (if (not gnus-zombie-list)
6153 (gnus-message 6 "No zombie groups")
6154 (let (gnus-group-list-mode)
6155 (funcall gnus-group-prepare-function
6156 gnus-level-zombie t gnus-level-zombie))
6157 (goto-char (point-min)))
6158 (gnus-group-position-point))
6160 (defun gnus-group-list-active ()
6161 "List all groups that are available from the server(s)."
6163 ;; First we make sure that we have really read the active file.
6164 (unless gnus-have-read-active-file
6165 (let ((gnus-read-active-file t))
6166 (gnus-read-active-file)))
6167 ;; Find all groups and sort them.
6173 (and (symbol-value sym)
6174 (setq list (cons (symbol-name sym) list))))
6178 (buffer-read-only nil))
6181 (gnus-group-insert-group-line-info (car groups))
6182 (setq groups (cdr groups)))
6183 (goto-char (point-min))))
6185 (defun gnus-activate-all-groups (level)
6186 "Activate absolutely all groups."
6187 (interactive (list 7))
6188 (let ((gnus-activate-level level)
6189 (gnus-activate-foreign-newsgroups level))
6190 (gnus-group-get-new-news)))
6192 (defun gnus-group-get-new-news (&optional arg)
6193 "Get newly arrived articles.
6194 If ARG is a number, it specifies which levels you are interested in
6195 re-scanning. If ARG is non-nil and not a number, this will force
6196 \"hard\" re-reading of the active files from all servers."
6198 (run-hooks 'gnus-get-new-news-hook)
6199 ;; We might read in new NoCeM messages here.
6200 (when gnus-use-nocem
6201 (gnus-nocem-scan-groups))
6202 ;; If ARG is not a number, then we read the active file.
6203 (when (and arg (not (numberp arg)))
6204 (let ((gnus-read-active-file t))
6205 (gnus-read-active-file))
6208 (setq arg (gnus-group-default-level arg t))
6209 (if (and gnus-read-active-file (not arg))
6211 (gnus-read-active-file)
6212 (gnus-get-unread-articles arg))
6213 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6214 (gnus-get-unread-articles arg)))
6215 (gnus-group-list-groups))
6217 (defun gnus-group-get-new-news-this-group (&optional n)
6218 "Check for newly arrived news in the current group (and the N-1 next groups).
6219 The difference between N and the number of newsgroup checked is returned.
6220 If N is negative, this group and the N-1 previous groups will be checked."
6222 (let* ((groups (gnus-group-process-prefix n))
6223 (ret (if (numberp n) (- n (length groups)) 0))
6226 (setq group (car groups)
6227 groups (cdr groups))
6228 (gnus-group-remove-mark group)
6229 (unless (gnus-get-new-news-in-group group)
6231 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6232 (when gnus-goto-next-group-when-activating
6233 (gnus-group-next-unread-group 1 t))
6234 (gnus-summary-position-point)
6237 (defun gnus-get-new-news-in-group (group)
6238 (when (and group (gnus-activate-group group 'scan))
6239 (gnus-get-unread-articles-in-group
6240 (gnus-get-info group) (gnus-active group) t)
6241 (when (gnus-group-goto-group group)
6242 (gnus-group-update-group-line))
6245 (defun gnus-group-fetch-faq (group &optional faq-dir)
6246 "Fetch the FAQ for the current group."
6249 (gnus-group-real-name (gnus-group-group-name))
6250 (cond (current-prefix-arg
6252 "Faq dir: " (and (listp gnus-group-faq-directory)
6253 gnus-group-faq-directory))))))
6255 (setq faq-dir (if (listp gnus-group-faq-directory)
6256 (car gnus-group-faq-directory)
6257 gnus-group-faq-directory)))
6258 (or group (error "No group name given"))
6259 (let ((file (concat (file-name-as-directory faq-dir)
6260 (gnus-group-real-name group))))
6261 (if (not (file-exists-p file))
6262 (error "No such file: %s" file)
6265 (defun gnus-group-describe-group (force &optional group)
6266 "Display a description of the current newsgroup."
6267 (interactive (list current-prefix-arg (gnus-group-group-name)))
6268 (and force (setq gnus-description-hashtb nil))
6269 (let ((method (gnus-find-method-for-group group))
6271 (or group (error "No group name given"))
6272 (and (or (and gnus-description-hashtb
6273 ;; We check whether this group's method has been
6274 ;; queried for a description file.
6276 (gnus-group-prefixed-name "" method)
6277 gnus-description-hashtb))
6278 (setq desc (gnus-group-get-description group))
6279 (gnus-read-descriptions-file method))
6281 (or desc (gnus-gethash group gnus-description-hashtb)
6282 "No description available")))))
6284 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6285 (defun gnus-group-describe-all-groups (&optional force)
6286 "Pop up a buffer with descriptions of all newsgroups."
6288 (and force (setq gnus-description-hashtb nil))
6289 (if (not (or gnus-description-hashtb
6290 (gnus-read-all-descriptions-files)))
6291 (error "Couldn't request descriptions file"))
6292 (let ((buffer-read-only nil)
6298 (insert (format " *: %-20s %s\n" (symbol-name group)
6299 (symbol-value group)))
6300 (add-text-properties
6301 b (1+ b) (list 'gnus-group group
6302 'gnus-unread t 'gnus-marked nil
6303 'gnus-level (1+ gnus-level-subscribed))))
6304 gnus-description-hashtb)
6305 (goto-char (point-min))
6306 (gnus-group-position-point)))
6308 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6309 (defun gnus-group-apropos (regexp &optional search-description)
6310 "List all newsgroups that have names that match a regexp."
6311 (interactive "sGnus apropos (regexp): ")
6313 (obuf (current-buffer))
6315 ;; Go through all newsgroups that are known to Gnus.
6318 (and (symbol-name group)
6319 (string-match regexp (symbol-name group))
6320 (setq groups (cons (symbol-name group) groups))))
6322 ;; Go through all descriptions that are known to Gnus.
6323 (if search-description
6326 (and (string-match regexp (symbol-value group))
6327 (gnus-active (symbol-name group))
6328 (setq groups (cons (symbol-name group) groups))))
6329 gnus-description-hashtb))
6331 (gnus-message 3 "No groups matched \"%s\"." regexp)
6332 ;; Print out all the groups.
6334 (pop-to-buffer "*Gnus Help*")
6335 (buffer-disable-undo (current-buffer))
6337 (setq groups (sort groups 'string<))
6339 ;; Groups may be entered twice into the list of groups.
6340 (if (not (string= (car groups) prev))
6342 (insert (setq prev (car groups)) "\n")
6343 (if (and gnus-description-hashtb
6344 (setq des (gnus-gethash (car groups)
6345 gnus-description-hashtb)))
6346 (insert " " des "\n"))))
6347 (setq groups (cdr groups)))
6348 (goto-char (point-min))))
6349 (pop-to-buffer obuf)))
6351 (defun gnus-group-description-apropos (regexp)
6352 "List all newsgroups that have names or descriptions that match a regexp."
6353 (interactive "sGnus description apropos (regexp): ")
6354 (if (not (or gnus-description-hashtb
6355 (gnus-read-all-descriptions-files)))
6356 (error "Couldn't request descriptions file"))
6357 (gnus-group-apropos regexp t))
6359 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6360 (defun gnus-group-list-matching (level regexp &optional all lowest)
6361 "List all groups with unread articles that match REGEXP.
6362 If the prefix LEVEL is non-nil, it should be a number that says which
6363 level to cut off listing groups.
6364 If ALL, also list groups with no unread articles.
6365 If LOWEST, don't list groups with level lower than LOWEST."
6366 (interactive "P\nsList newsgroups matching: ")
6367 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6368 all (or lowest 1) regexp)
6369 (goto-char (point-min))
6370 (gnus-group-position-point))
6372 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6373 "List all groups that match REGEXP.
6374 If the prefix LEVEL is non-nil, it should be a number that says which
6375 level to cut off listing groups.
6376 If LOWEST, don't list groups with level lower than LOWEST."
6377 (interactive "P\nsList newsgroups matching: ")
6378 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6380 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6381 (defun gnus-group-save-newsrc (&optional force)
6382 "Save the Gnus startup files.
6383 If FORCE, force saving whether it is necessary or not."
6385 (gnus-save-newsrc-file force))
6387 (defun gnus-group-restart (&optional arg)
6388 "Force Gnus to read the .newsrc file."
6390 (gnus-save-newsrc-file)
6391 (gnus-setup-news 'force)
6392 (gnus-group-list-groups arg))
6394 (defun gnus-group-read-init-file ()
6395 "Read the Gnus elisp init file."
6397 (gnus-read-init-file))
6399 (defun gnus-group-check-bogus-groups (&optional silent)
6400 "Check bogus newsgroups.
6401 If given a prefix, don't ask for confirmation before removing a bogus
6404 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6405 (gnus-group-list-groups))
6407 (defun gnus-group-edit-global-kill (&optional article group)
6408 "Edit the global kill file.
6409 If GROUP, edit that local kill file instead."
6411 (setq gnus-current-kill-article article)
6412 (gnus-kill-file-edit-file group)
6415 (substitute-command-keys
6416 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6417 (if group "local" "global")))))
6419 (defun gnus-group-edit-local-kill (article group)
6420 "Edit a local kill file."
6421 (interactive (list nil (gnus-group-group-name)))
6422 (gnus-group-edit-global-kill article group))
6424 (defun gnus-group-force-update ()
6425 "Update `.newsrc' file."
6427 (gnus-save-newsrc-file))
6429 (defun gnus-group-suspend ()
6430 "Suspend the current Gnus session.
6431 In fact, cleanup buffers except for group mode buffer.
6432 The hook gnus-suspend-gnus-hook is called before actually suspending."
6434 (run-hooks 'gnus-suspend-gnus-hook)
6435 ;; Kill Gnus buffers except for group mode buffer.
6436 (let ((group-buf (get-buffer gnus-group-buffer)))
6437 ;; Do this on a separate list in case the user does a ^G before we finish
6438 (let ((gnus-buffer-list
6439 (delq group-buf (delq gnus-dribble-buffer
6440 (append gnus-buffer-list nil)))))
6441 (while gnus-buffer-list
6442 (gnus-kill-buffer (car gnus-buffer-list))
6443 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6446 (setq gnus-buffer-list (list group-buf))
6447 (bury-buffer group-buf)
6448 (delete-windows-on group-buf t)))))
6450 (defun gnus-group-clear-dribble ()
6451 "Clear all information from the dribble buffer."
6453 (gnus-dribble-clear)
6454 (gnus-message 7 "Cleared dribble buffer"))
6456 (defun gnus-group-exit ()
6457 "Quit reading news after updating .newsrc.eld and .newsrc.
6458 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6461 (or noninteractive ;For gnus-batch-kill
6462 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6463 (not gnus-interactive-exit) ;Without confirmation
6465 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6466 (run-hooks 'gnus-exit-gnus-hook)
6467 ;; Close down GroupLens.
6468 (when gnus-use-grouplens
6470 ;; Offer to save data from non-quitted summary buffers.
6471 (gnus-offer-save-summaries)
6472 ;; Save the newsrc file(s).
6473 (gnus-save-newsrc-file)
6475 (gnus-close-backends)
6476 ;; Shut down the cache.
6477 (when gnus-use-cache
6479 ;; Reset everything.
6481 ;; Allow the user to do things after cleaning up.
6482 (run-hooks 'gnus-after-exiting-gnus-hook)))
6484 (defun gnus-close-backends ()
6485 ;; Send a close request to all backends that support such a request.
6486 (let ((methods gnus-valid-select-methods)
6489 (if (fboundp (setq func (intern (concat (car (car methods))
6490 "-request-close"))))
6492 (setq methods (cdr methods)))))
6494 (defun gnus-group-quit ()
6495 "Quit reading news without updating .newsrc.eld or .newsrc.
6496 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6498 (when (or noninteractive ;For gnus-batch-kill
6499 (zerop (buffer-size))
6500 (not (gnus-server-opened gnus-select-method))
6502 (not gnus-current-startup-file)
6504 (format "Quit reading news without saving %s? "
6505 (file-name-nondirectory gnus-current-startup-file))))
6506 (run-hooks 'gnus-exit-gnus-hook)
6507 (if gnus-use-full-window
6508 (delete-other-windows)
6509 (gnus-remove-some-windows))
6511 (gnus-close-backends)
6512 ;; Shut down the cache.
6513 (when gnus-use-cache
6516 ;; Allow the user to do things after cleaning up.
6517 (run-hooks 'gnus-after-exiting-gnus-hook)))
6519 (defun gnus-offer-save-summaries ()
6520 "Offer to save all active summary buffers."
6522 (let ((buflist (buffer-list))
6524 ;; Go through all buffers and find all summaries.
6526 (and (setq bufname (buffer-name (car buflist)))
6527 (string-match "Summary" bufname)
6529 (set-buffer bufname)
6530 ;; We check that this is, indeed, a summary buffer.
6531 (and (eq major-mode 'gnus-summary-mode)
6532 ;; Also make sure this isn't bogus.
6533 gnus-newsgroup-prepared))
6534 (push bufname buffers))
6535 (setq buflist (cdr buflist)))
6536 ;; Go through all these summary buffers and offer to save them.
6539 "Update summary buffer %s? "
6540 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6543 (defun gnus-group-describe-briefly ()
6544 "Give a one line description of the group mode commands."
6546 (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")))
6548 (defun gnus-group-browse-foreign-server (method)
6549 "Browse a foreign news server.
6550 If called interactively, this function will ask for a select method
6551 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6552 If not, METHOD should be a list where the first element is the method
6553 and the second element is the address."
6555 (list (let ((how (completing-read
6557 (append gnus-valid-select-methods gnus-server-alist)
6558 nil t (cons "nntp" 0))))
6559 ;; We either got a backend name or a virtual server name.
6560 ;; If the first, we also need an address.
6561 (if (assoc how gnus-valid-select-methods)
6563 ;; Suggested by mapjph@bath.ac.uk.
6566 (mapcar (lambda (server) (list server))
6567 gnus-secondary-servers)))
6568 ;; We got a server name, so we find the method.
6569 (gnus-server-to-method how)))))
6570 (gnus-browse-foreign-server method))
6574 ;;; Gnus summary mode
6577 (defvar gnus-summary-mode-map nil)
6579 (put 'gnus-summary-mode 'mode-class 'special)
6581 (unless gnus-summary-mode-map
6582 (setq gnus-summary-mode-map (make-keymap))
6583 (suppress-keymap gnus-summary-mode-map)
6585 ;; Non-orthogonal keys
6588 gnus-summary-mode-map
6589 " " gnus-summary-next-page
6590 "\177" gnus-summary-prev-page
6591 [delete] gnus-summary-prev-page
6592 "\r" gnus-summary-scroll-up
6593 "n" gnus-summary-next-unread-article
6594 "p" gnus-summary-prev-unread-article
6595 "N" gnus-summary-next-article
6596 "P" gnus-summary-prev-article
6597 "\M-\C-n" gnus-summary-next-same-subject
6598 "\M-\C-p" gnus-summary-prev-same-subject
6599 "\M-n" gnus-summary-next-unread-subject
6600 "\M-p" gnus-summary-prev-unread-subject
6601 "." gnus-summary-first-unread-article
6602 "," gnus-summary-best-unread-article
6603 "\M-s" gnus-summary-search-article-forward
6604 "\M-r" gnus-summary-search-article-backward
6605 "<" gnus-summary-beginning-of-article
6606 ">" gnus-summary-end-of-article
6607 "j" gnus-summary-goto-article
6608 "^" gnus-summary-refer-parent-article
6609 "\M-^" gnus-summary-refer-article
6610 "u" gnus-summary-tick-article-forward
6611 "!" gnus-summary-tick-article-forward
6612 "U" gnus-summary-tick-article-backward
6613 "d" gnus-summary-mark-as-read-forward
6614 "D" gnus-summary-mark-as-read-backward
6615 "E" gnus-summary-mark-as-expirable
6616 "\M-u" gnus-summary-clear-mark-forward
6617 "\M-U" gnus-summary-clear-mark-backward
6618 "k" gnus-summary-kill-same-subject-and-select
6619 "\C-k" gnus-summary-kill-same-subject
6620 "\M-\C-k" gnus-summary-kill-thread
6621 "\M-\C-l" gnus-summary-lower-thread
6622 "e" gnus-summary-edit-article
6623 "#" gnus-summary-mark-as-processable
6624 "\M-#" gnus-summary-unmark-as-processable
6625 "\M-\C-t" gnus-summary-toggle-threads
6626 "\M-\C-s" gnus-summary-show-thread
6627 "\M-\C-h" gnus-summary-hide-thread
6628 "\M-\C-f" gnus-summary-next-thread
6629 "\M-\C-b" gnus-summary-prev-thread
6630 "\M-\C-u" gnus-summary-up-thread
6631 "\M-\C-d" gnus-summary-down-thread
6632 "&" gnus-summary-execute-command
6633 "c" gnus-summary-catchup-and-exit
6634 "\C-w" gnus-summary-mark-region-as-read
6635 "\C-t" gnus-summary-toggle-truncation
6636 "?" gnus-summary-mark-as-dormant
6637 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6638 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6639 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6640 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6641 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6642 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6643 "=" gnus-summary-expand-window
6644 "\C-x\C-s" gnus-summary-reselect-current-group
6645 "\M-g" gnus-summary-rescan-group
6646 "w" gnus-summary-stop-page-breaking
6647 "\C-c\C-r" gnus-summary-caesar-message
6648 "\M-t" gnus-summary-toggle-mime
6649 "f" gnus-summary-followup
6650 "F" gnus-summary-followup-with-original
6651 "C" gnus-summary-cancel-article
6652 "r" gnus-summary-reply
6653 "R" gnus-summary-reply-with-original
6654 "\C-c\C-f" gnus-summary-mail-forward
6655 "o" gnus-summary-save-article
6656 "\C-o" gnus-summary-save-article-mail
6657 "|" gnus-summary-pipe-output
6658 "\M-k" gnus-summary-edit-local-kill
6659 "\M-K" gnus-summary-edit-global-kill
6661 "\C-c\C-d" gnus-summary-describe-group
6662 "q" gnus-summary-exit
6663 "Q" gnus-summary-exit-no-update
6664 "\C-c\C-i" gnus-info-find-node
6665 gnus-mouse-2 gnus-mouse-pick-article
6666 "m" gnus-summary-mail-other-window
6667 "a" gnus-summary-post-news
6668 "x" gnus-summary-limit-to-unread
6669 "s" gnus-summary-isearch-article
6670 "t" gnus-article-hide-headers
6671 "g" gnus-summary-show-article
6672 "l" gnus-summary-goto-last-article
6673 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6674 "\C-d" gnus-summary-enter-digest-group
6676 "*" gnus-cache-enter-article
6677 "\M-*" gnus-cache-remove-article
6678 "\M-&" gnus-summary-universal-argument
6679 "\C-l" gnus-recenter
6680 "I" gnus-summary-increase-score
6681 "L" gnus-summary-lower-score
6683 "V" gnus-summary-score-map
6684 "X" gnus-uu-extract-map
6685 "S" gnus-summary-send-map)
6687 ;; Sort of orthogonal keymap
6689 (gnus-summary-mark-map "M" gnus-summary-mode-map)
6690 "t" gnus-summary-tick-article-forward
6691 "!" gnus-summary-tick-article-forward
6692 "d" gnus-summary-mark-as-read-forward
6693 "r" gnus-summary-mark-as-read-forward
6694 "c" gnus-summary-clear-mark-forward
6695 " " gnus-summary-clear-mark-forward
6696 "e" gnus-summary-mark-as-expirable
6697 "x" gnus-summary-mark-as-expirable
6698 "?" gnus-summary-mark-as-dormant
6699 "b" gnus-summary-set-bookmark
6700 "B" gnus-summary-remove-bookmark
6701 "#" gnus-summary-mark-as-processable
6702 "\M-#" gnus-summary-unmark-as-processable
6703 "S" gnus-summary-limit-include-expunged
6704 "C" gnus-summary-catchup
6705 "H" gnus-summary-catchup-to-here
6706 "\C-c" gnus-summary-catchup-all
6707 "k" gnus-summary-kill-same-subject-and-select
6708 "K" gnus-summary-kill-same-subject
6709 "P" gnus-uu-mark-map)
6712 (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6713 "c" gnus-summary-clear-above
6714 "u" gnus-summary-tick-above
6715 "m" gnus-summary-mark-above
6716 "k" gnus-summary-kill-below)
6719 (gnus-summary-limit-map "/" gnus-summary-mode-map)
6720 "/" gnus-summary-limit-to-subject
6721 "n" gnus-summary-limit-to-articles
6722 "w" gnus-summary-pop-limit
6723 "s" gnus-summary-limit-to-subject
6724 "a" gnus-summary-limit-to-author
6725 "u" gnus-summary-limit-to-unread
6726 "m" gnus-summary-limit-to-marks
6727 "v" gnus-summary-limit-to-score
6728 "D" gnus-summary-limit-include-dormant
6729 "d" gnus-summary-limit-exclude-dormant
6730 ;; "t" gnus-summary-limit-exclude-thread
6731 "E" gnus-summary-limit-include-expunged
6732 "c" gnus-summary-limit-exclude-childless-dormant
6733 "C" gnus-summary-limit-mark-excluded-as-read)
6736 (gnus-summary-goto-map "G" gnus-summary-mode-map)
6737 "n" gnus-summary-next-unread-article
6738 "p" gnus-summary-prev-unread-article
6739 "N" gnus-summary-next-article
6740 "P" gnus-summary-prev-article
6741 "\C-n" gnus-summary-next-same-subject
6742 "\C-p" gnus-summary-prev-same-subject
6743 "\M-n" gnus-summary-next-unread-subject
6744 "\M-p" gnus-summary-prev-unread-subject
6745 "f" gnus-summary-first-unread-article
6746 "b" gnus-summary-best-unread-article
6747 "g" gnus-summary-goto-subject
6748 "l" gnus-summary-goto-last-article
6749 "p" gnus-summary-pop-article)
6752 (gnus-summary-thread-map "T" gnus-summary-mode-map)
6753 "k" gnus-summary-kill-thread
6754 "l" gnus-summary-lower-thread
6755 "i" gnus-summary-raise-thread
6756 "T" gnus-summary-toggle-threads
6757 "t" gnus-summary-rethread-current
6758 "^" gnus-summary-reparent-thread
6759 "s" gnus-summary-show-thread
6760 "S" gnus-summary-show-all-threads
6761 "h" gnus-summary-hide-thread
6762 "H" gnus-summary-hide-all-threads
6763 "n" gnus-summary-next-thread
6764 "p" gnus-summary-prev-thread
6765 "u" gnus-summary-up-thread
6766 "o" gnus-summary-top-thread
6767 "d" gnus-summary-down-thread
6768 "#" gnus-uu-mark-thread
6769 "\M-#" gnus-uu-unmark-thread)
6772 (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6773 "c" gnus-summary-catchup-and-exit
6774 "C" gnus-summary-catchup-all-and-exit
6775 "E" gnus-summary-exit-no-update
6776 "Q" gnus-summary-exit
6777 "Z" gnus-summary-exit
6778 "n" gnus-summary-catchup-and-goto-next-group
6779 "R" gnus-summary-reselect-current-group
6780 "G" gnus-summary-rescan-group
6781 "N" gnus-summary-next-group
6782 "P" gnus-summary-prev-group)
6785 (gnus-summary-article-map "A" gnus-summary-mode-map)
6786 " " gnus-summary-next-page
6787 "n" gnus-summary-next-page
6788 "\177" gnus-summary-prev-page
6789 [delete] gnus-summary-prev-page
6790 "p" gnus-summary-prev-page
6791 "\r" gnus-summary-scroll-up
6792 "<" gnus-summary-beginning-of-article
6793 ">" gnus-summary-end-of-article
6794 "b" gnus-summary-beginning-of-article
6795 "e" gnus-summary-end-of-article
6796 "^" gnus-summary-refer-parent-article
6797 "r" gnus-summary-refer-parent-article
6798 "R" gnus-summary-refer-references
6799 "g" gnus-summary-show-article
6800 "s" gnus-summary-isearch-article)
6803 (gnus-summary-wash-map "W" gnus-summary-mode-map)
6804 "b" gnus-article-add-buttons
6805 "B" gnus-article-add-buttons-to-head
6806 "o" gnus-article-treat-overstrike
6807 ;; "w" gnus-article-word-wrap
6808 "w" gnus-article-fill-cited-article
6809 "c" gnus-article-remove-cr
6810 "L" gnus-article-remove-trailing-blank-lines
6811 "q" gnus-article-de-quoted-unreadable
6812 "f" gnus-article-display-x-face
6813 "l" gnus-summary-stop-page-breaking
6814 "r" gnus-summary-caesar-message
6815 "t" gnus-article-hide-headers
6816 "v" gnus-summary-verbose-headers
6817 "m" gnus-summary-toggle-mime)
6820 (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6821 "a" gnus-article-hide
6822 "h" gnus-article-hide-headers
6823 "b" gnus-article-hide-boring-headers
6824 "s" gnus-article-hide-signature
6825 "c" gnus-article-hide-citation
6826 "p" gnus-article-hide-pgp
6827 "\C-c" gnus-article-hide-citation-maybe)
6830 (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6831 "a" gnus-article-highlight
6832 "h" gnus-article-highlight-headers
6833 "c" gnus-article-highlight-citation
6834 "s" gnus-article-highlight-signature)
6837 (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6838 "z" gnus-article-date-ut
6839 "u" gnus-article-date-ut
6840 "l" gnus-article-date-local
6841 "e" gnus-article-date-lapsed
6842 "o" gnus-article-date-original)
6845 (gnus-summary-help-map "H" gnus-summary-mode-map)
6847 "f" gnus-summary-fetch-faq
6848 "d" gnus-summary-describe-group
6849 "h" gnus-summary-describe-briefly
6850 "i" gnus-info-find-node)
6853 (gnus-summary-backend-map "B" gnus-summary-mode-map)
6854 "e" gnus-summary-expire-articles
6855 "\M-\C-e" gnus-summary-expire-articles-now
6856 "\177" gnus-summary-delete-article
6857 [delete] gnus-summary-delete-article
6858 "m" gnus-summary-move-article
6859 "r" gnus-summary-respool-article
6860 "w" gnus-summary-edit-article
6861 "c" gnus-summary-copy-article
6862 "B" gnus-summary-crosspost-article
6863 "q" gnus-summary-respool-query
6864 "i" gnus-summary-import-article)
6867 (gnus-summary-save-map "O" gnus-summary-mode-map)
6868 "o" gnus-summary-save-article
6869 "m" gnus-summary-save-article-mail
6870 "r" gnus-summary-save-article-rmail
6871 "f" gnus-summary-save-article-file
6872 "b" gnus-summary-save-article-body-file
6873 "h" gnus-summary-save-article-folder
6874 "v" gnus-summary-save-article-vm
6875 "p" gnus-summary-pipe-output
6876 "s" gnus-soup-add-article)
6881 (defun gnus-summary-mode (&optional group)
6882 "Major mode for reading articles.
6884 All normal editing commands are switched off.
6885 \\<gnus-summary-mode-map>
6886 Each line in this buffer represents one article. To read an
6887 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6888 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6891 You can also post articles and send mail from this buffer. To
6892 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6893 of an article, type `\\[gnus-summary-reply]'.
6895 There are approx. one gazillion commands you can execute in this
6896 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6898 The following commands are available:
6900 \\{gnus-summary-mode-map}"
6902 (when (and menu-bar-mode
6903 (gnus-visual-p 'summary-menu 'menu))
6904 (gnus-summary-make-menu-bar))
6905 (kill-all-local-variables)
6906 (let ((locals gnus-summary-local-variables))
6908 (if (consp (car locals))
6910 (make-local-variable (car (car locals)))
6911 (set (car (car locals)) (eval (cdr (car locals)))))
6912 (make-local-variable (car locals))
6913 (set (car locals) nil))
6914 (setq locals (cdr locals))))
6915 (gnus-make-thread-indent-array)
6916 (gnus-simplify-mode-line)
6917 (setq major-mode 'gnus-summary-mode)
6918 (setq mode-name "Summary")
6919 (make-local-variable 'minor-mode-alist)
6920 (use-local-map gnus-summary-mode-map)
6921 (buffer-disable-undo (current-buffer))
6922 (setq buffer-read-only t) ;Disable modification
6923 (setq truncate-lines t)
6924 (setq selective-display t)
6925 (setq selective-display-ellipses t) ;Display `...'
6926 (setq buffer-display-table gnus-summary-display-table)
6927 (setq gnus-newsgroup-name group)
6928 (run-hooks 'gnus-summary-mode-hook))
6930 (defun gnus-summary-make-display-table ()
6931 ;; Change the display table. Odd characters have a tendency to mess
6932 ;; up nicely formatted displays - we make all possible glyphs
6933 ;; display only a single character.
6935 ;; We start from the standard display table, if any.
6936 (setq gnus-summary-display-table
6937 (or (copy-sequence standard-display-table)
6938 (make-display-table)))
6939 ;; Nix out all the control chars...
6941 (while (>= (setq i (1- i)) 0)
6942 (aset gnus-summary-display-table i [??])))
6943 ;; ... but not newline and cr, of course. (cr is necessary for the
6944 ;; selective display).
6945 (aset gnus-summary-display-table ?\n nil)
6946 (aset gnus-summary-display-table ?\r nil)
6947 ;; We nix out any glyphs over 126 that are not set already.
6949 (while (>= (setq i (1- i)) 127)
6950 ;; Only modify if the entry is nil.
6951 (or (aref gnus-summary-display-table i)
6952 (aset gnus-summary-display-table i [??])))))
6954 (defun gnus-summary-clear-local-variables ()
6955 (let ((locals gnus-summary-local-variables))
6957 (if (consp (car locals))
6958 (and (vectorp (car (car locals)))
6959 (set (car (car locals)) nil))
6960 (and (vectorp (car locals))
6961 (set (car locals) nil)))
6962 (setq locals (cdr locals)))))
6964 ;; Summary data functions.
6966 (defmacro gnus-data-number (data)
6969 (defmacro gnus-data-set-number (data number)
6970 `(setcar ,data ,number))
6972 (defmacro gnus-data-mark (data)
6975 (defmacro gnus-data-set-mark (data mark)
6976 `(setcar (nthcdr 1 ,data) ,mark))
6978 (defmacro gnus-data-pos (data)
6981 (defmacro gnus-data-set-pos (data pos)
6982 `(setcar (nthcdr 2 ,data) ,pos))
6984 (defmacro gnus-data-header (data)
6987 (defmacro gnus-data-level (data)
6990 (defmacro gnus-data-unread-p (data)
6991 `(= (nth 1 ,data) gnus-unread-mark))
6993 (defmacro gnus-data-pseudo-p (data)
6994 `(consp (nth 3 ,data)))
6996 (defmacro gnus-data-find (number)
6997 `(assq ,number gnus-newsgroup-data))
6999 (defmacro gnus-data-find-list (number &optional data)
7000 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7001 (memq (assq ,number bdata)
7004 (defmacro gnus-data-make (number mark pos header level)
7005 `(list ,number ,mark ,pos ,header ,level))
7007 (defun gnus-data-enter (after-article number mark pos header level offset)
7008 (let ((data (gnus-data-find-list after-article)))
7009 (or data (error "No such article: %d" after-article))
7010 (setcdr data (cons (gnus-data-make number mark pos header level)
7012 (setq gnus-newsgroup-data-reverse nil)
7013 (gnus-data-update-list (cdr (cdr data)) offset)))
7015 (defun gnus-data-enter-list (after-article list &optional offset)
7017 (let ((data (and after-article (gnus-data-find-list after-article)))
7019 (or data (not after-article) (error "No such article: %d" after-article))
7020 ;; Find the last element in the list to be spliced into the main
7023 (setq list (cdr list)))
7026 (setcdr list gnus-newsgroup-data)
7027 (setq gnus-newsgroup-data ilist)
7028 (and offset (gnus-data-update-list (cdr list) offset)))
7029 (setcdr list (cdr data))
7031 (and offset (gnus-data-update-list (cdr data) offset)))
7032 (setq gnus-newsgroup-data-reverse nil))))
7034 (defun gnus-data-remove (article &optional offset)
7035 (let ((data gnus-newsgroup-data))
7036 (if (= (gnus-data-number (car data)) article)
7037 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7038 gnus-newsgroup-data-reverse nil)
7040 (and (= (gnus-data-number (car (cdr data))) article)
7042 (setcdr data (cdr (cdr data)))
7043 (and offset (gnus-data-update-list (cdr data) offset))
7045 gnus-newsgroup-data-reverse nil)))
7046 (setq data (cdr data))))))
7048 (defmacro gnus-data-list (backward)
7050 (or gnus-newsgroup-data-reverse
7051 (setq gnus-newsgroup-data-reverse
7052 (reverse gnus-newsgroup-data)))
7053 gnus-newsgroup-data))
7055 (defun gnus-data-update-list (data offset)
7056 "Add OFFSET to the POS of all data entries in DATA."
7058 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7059 (setq data (cdr data))))
7061 (defun gnus-data-compute-positions ()
7062 "Compute the positions of all articles."
7063 (let ((data gnus-newsgroup-data)
7066 (when (setq pos (text-property-any
7067 (point-min) (point-max)
7068 'gnus-number (gnus-data-number (car data))))
7069 (gnus-data-set-pos (car data) (+ pos 3)))
7070 (setq data (cdr data)))))
7072 (defun gnus-summary-article-pseudo-p (article)
7073 "Say whether this article is a pseudo article or not."
7074 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7076 (defun gnus-article-parent-p (number)
7077 "Say whether this article is a parent or not."
7078 (let ((data (gnus-data-find-list number)))
7079 (and (cdr data) ; There has to be an article after...
7080 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7081 (gnus-data-level (nth 1 data))))))
7083 (defun gnus-article-children (number)
7084 "Return a list of all children to NUMBER."
7085 (let* ((data (gnus-data-find-list number))
7086 (level (gnus-data-level (car data)))
7088 (setq data (cdr data))
7090 (= (gnus-data-level (car data)) (1+ level)))
7091 (push (gnus-data-number (car data)) children)
7092 (setq data (cdr data)))
7095 (defmacro gnus-summary-skip-intangible ()
7096 "If the current article is intangible, then jump to a different article."
7097 '(let ((to (get-text-property (point) 'gnus-intangible)))
7098 (and to (gnus-summary-goto-subject to))))
7100 (defmacro gnus-summary-article-intangible-p ()
7101 "Say whether this article is intangible or not."
7102 '(get-text-property (point) 'gnus-intangible))
7104 ;; Some summary mode macros.
7106 (defmacro gnus-summary-article-number ()
7107 "The article number of the article on the current line.
7108 If there isn's an article number here, then we return the current
7111 (gnus-summary-skip-intangible)
7112 (or (get-text-property (point) 'gnus-number)
7113 (gnus-summary-last-subject))))
7115 (defmacro gnus-summary-article-header (&optional number)
7116 `(gnus-data-header (gnus-data-find
7117 ,(or number '(gnus-summary-article-number)))))
7119 (defmacro gnus-summary-thread-level (&optional number)
7120 `(if (and (eq gnus-summary-make-false-root 'dummy)
7121 (get-text-property (point) 'gnus-intangible))
7123 (gnus-data-level (gnus-data-find
7124 ,(or number '(gnus-summary-article-number))))))
7126 (defmacro gnus-summary-article-mark (&optional number)
7127 `(gnus-data-mark (gnus-data-find
7128 ,(or number '(gnus-summary-article-number)))))
7130 (defmacro gnus-summary-article-pos (&optional number)
7131 `(gnus-data-pos (gnus-data-find
7132 ,(or number '(gnus-summary-article-number)))))
7134 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7135 (defmacro gnus-summary-article-subject (&optional number)
7136 "Return current subject string or nil if nothing."
7139 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7140 '(gnus-data-header (assq (gnus-summary-article-number)
7141 gnus-newsgroup-data)))))
7144 (mail-header-subject headers))))
7146 (defmacro gnus-summary-article-score (&optional number)
7147 "Return current article score."
7148 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7149 gnus-newsgroup-scored))
7150 gnus-summary-default-score 0))
7152 (defun gnus-summary-article-children (&optional number)
7153 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7154 (level (gnus-data-level (car data)))
7156 (while (and (setq data (cdr data))
7157 (> (setq l (gnus-data-level (car data))) level))
7158 (and (= (1+ level) l)
7159 (setq children (cons (gnus-data-number (car data))
7161 (nreverse children)))
7163 (defun gnus-summary-article-parent (&optional number)
7164 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7165 (gnus-data-list t)))
7166 (level (gnus-data-level (car data)))
7169 () ; This is a root.
7170 ;; We search until we find an article with a level less than
7171 ;; this one. That function has to be the parent.
7172 (while (and (setq data (cdr data))
7173 (not (< (gnus-data-level (car data)) level))))
7174 (and data (gnus-data-number (car data))))))
7176 (defun gnus-unread-mark-p (mark)
7177 "Say whether MARK is the unread mark."
7178 (= mark gnus-unread-mark))
7180 (defun gnus-read-mark-p (mark)
7181 "Say whether MARK is one of the marks that mark as read.
7182 This is all marks except unread, ticked, dormant, and expirable."
7183 (not (or (= mark gnus-unread-mark)
7184 (= mark gnus-ticked-mark)
7185 (= mark gnus-dormant-mark)
7186 (= mark gnus-expirable-mark))))
7188 ;; Various summary mode internalish functions.
7190 (defun gnus-mouse-pick-article (e)
7193 (gnus-summary-next-page nil t))
7195 (defun gnus-summary-setup-buffer (group)
7196 "Initialize summary buffer."
7197 (let ((buffer (concat "*Summary " group "*")))
7198 (if (get-buffer buffer)
7201 (setq gnus-summary-buffer (current-buffer))
7202 (not gnus-newsgroup-prepared))
7203 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7204 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7205 (gnus-add-current-to-buffer-list)
7206 (gnus-summary-mode group)
7208 (gnus-carpal-setup-buffer 'summary))
7209 (unless gnus-single-article-buffer
7210 (make-local-variable 'gnus-article-buffer)
7211 (make-local-variable 'gnus-original-article-buffer))
7212 (setq gnus-newsgroup-name group)
7215 (defun gnus-set-global-variables ()
7216 ;; Set the global equivalents of the summary buffer-local variables
7217 ;; to the latest values they had. These reflect the summary buffer
7218 ;; that was in action when the last article was fetched.
7219 (when (eq major-mode 'gnus-summary-mode)
7220 (setq gnus-summary-buffer (current-buffer))
7221 (let ((name gnus-newsgroup-name)
7222 (marked gnus-newsgroup-marked)
7223 (unread gnus-newsgroup-unreads)
7224 (headers gnus-current-headers)
7225 (data gnus-newsgroup-data)
7226 (article-buffer gnus-article-buffer)
7227 (original gnus-original-article-buffer)
7228 (score-file gnus-current-score-file))
7230 (set-buffer gnus-group-buffer)
7231 (setq gnus-newsgroup-name name)
7232 (setq gnus-newsgroup-marked marked)
7233 (setq gnus-newsgroup-unreads unread)
7234 (setq gnus-current-headers headers)
7235 (setq gnus-newsgroup-data data)
7236 (setq gnus-article-buffer article-buffer)
7237 (setq gnus-original-article-buffer original)
7238 (setq gnus-current-score-file score-file)))))
7240 (defun gnus-summary-last-article-p (&optional article)
7241 "Return whether ARTICLE is the last article in the buffer."
7242 (if (not (setq article (or article (gnus-summary-article-number))))
7243 t ; All non-existant numbers are the last article. :-)
7244 (cdr (gnus-data-find-list article))))
7246 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7247 "Insert a dummy root in the summary buffer."
7249 (add-text-properties
7250 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7251 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7253 (defvar gnus-thread-indent-array nil)
7254 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7255 (defun gnus-make-thread-indent-array ()
7257 (if (and gnus-thread-indent-array
7258 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7260 (setq gnus-thread-indent-array (make-vector 201 "")
7261 gnus-thread-indent-array-level gnus-thread-indent-level)
7263 (aset gnus-thread-indent-array n
7264 (make-string (* n gnus-thread-indent-level) ? ))
7267 (defun gnus-summary-insert-line
7268 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7269 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7270 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7271 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7272 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7273 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7274 (gnus-tmp-score-char
7275 (if (or (null gnus-summary-default-score)
7276 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7277 gnus-summary-zcore-fuzz)) ?
7278 (if (< gnus-tmp-score gnus-summary-default-score)
7279 gnus-score-below-mark gnus-score-over-mark)))
7280 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7281 ((memq gnus-tmp-current gnus-newsgroup-cached)
7283 (gnus-tmp-replied gnus-replied-mark)
7284 ((memq gnus-tmp-current gnus-newsgroup-saved)
7286 (t gnus-unread-mark)))
7287 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7290 ((string-match "(.+)" gnus-tmp-from)
7291 (substring gnus-tmp-from
7292 (1+ (match-beginning 0)) (1- (match-end 0))))
7293 ((string-match "<[^>]+> *$" gnus-tmp-from)
7294 (let ((beg (match-beginning 0)))
7295 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7296 (substring gnus-tmp-from (1+ (match-beginning 0))
7297 (1- (match-end 0))))
7298 (substring gnus-tmp-from 0 beg))))
7300 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7301 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7302 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7303 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7304 (buffer-read-only nil))
7305 (when (string= gnus-tmp-name "")
7306 (setq gnus-tmp-name gnus-tmp-from))
7307 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7310 (progn (eval gnus-summary-line-format-spec) (point))
7311 'gnus-number gnus-tmp-number)
7312 (when (gnus-visual-p 'summary-highlight 'highlight)
7314 (run-hooks 'gnus-summary-update-hook)
7317 (defun gnus-summary-update-line (&optional dont-update)
7318 ;; Update summary line after change.
7319 (when (and gnus-summary-default-score
7320 (not gnus-summary-inhibit-highlight))
7321 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7322 (article (gnus-summary-article-number))
7323 (score (gnus-summary-article-score article)))
7325 (if (and gnus-summary-mark-below
7326 (< (gnus-summary-article-score)
7327 gnus-summary-mark-below))
7328 ;; This article has a low score, so we mark it as read.
7329 (when (memq article gnus-newsgroup-unreads)
7330 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7331 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7332 ;; This article was previously marked as read on account
7333 ;; of a low score, but now it has risen, so we mark it as
7335 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7336 (gnus-summary-update-mark
7337 (if (or (null gnus-summary-default-score)
7338 (<= (abs (- score gnus-summary-default-score))
7339 gnus-summary-zcore-fuzz)) ?
7340 (if (< score gnus-summary-default-score)
7341 gnus-score-below-mark gnus-score-over-mark)) 'score))
7342 ;; Do visual highlighting.
7343 (when (gnus-visual-p 'summary-highlight 'highlight)
7344 (run-hooks 'gnus-summary-update-hook)))))
7346 (defvar gnus-tmp-new-adopts nil)
7348 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7349 ;; Sum up all elements (and sub-elements) in a list.
7351 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7353 ((and (consp thread) (cdr thread))
7356 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7359 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7362 (when (and level (zerop level) gnus-tmp-new-adopts)
7365 'gnus-summary-number-of-articles-in-thread
7366 gnus-tmp-new-adopts))))
7368 (if (> number 1) gnus-not-empty-thread-mark
7369 gnus-empty-thread-mark)
7372 (defun gnus-summary-set-local-parameters (group)
7373 "Go through the local params of GROUP and set all variable specs in that list."
7374 (let ((params (gnus-info-params (gnus-get-info group)))
7377 (setq elem (car params)
7378 params (cdr params))
7379 (and (consp elem) ; Has to be a cons.
7380 (consp (cdr elem)) ; The cdr has to be a list.
7381 (symbolp (car elem)) ; Has to be a symbol in there.
7382 (not (memq (car elem)
7383 '(quit-config to-address to-list to-group)))
7384 (progn ; So we set it.
7385 (make-local-variable (car elem))
7386 (set (car elem) (eval (nth 1 elem))))))))
7388 (defun gnus-summary-read-group
7389 (group &optional show-all no-article kill-buffer no-display)
7390 "Start reading news in newsgroup GROUP.
7391 If SHOW-ALL is non-nil, already read articles are also listed.
7392 If NO-ARTICLE is non-nil, no article is selected initially.
7393 If NO-DISPLAY, don't generate a summary buffer."
7394 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7395 (let* ((new-group (gnus-summary-setup-buffer group))
7396 (quit-config (gnus-group-quit-config group))
7397 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7399 ;; This summary buffer exists already, so we just select it.
7401 (gnus-set-global-variables)
7403 (gnus-kill-or-deaden-summary kill-buffer))
7404 (gnus-configure-windows 'summary 'force)
7405 (gnus-set-mode-line 'summary)
7406 (gnus-summary-position-point)
7409 ;; We couldn't select this group.
7411 (when (and (eq major-mode 'gnus-summary-mode)
7412 (not (equal (current-buffer) kill-buffer)))
7413 (kill-buffer (current-buffer))
7414 (if (not quit-config)
7416 (set-buffer gnus-group-buffer)
7417 (gnus-group-jump-to-group group)
7418 (gnus-group-next-unread-group 1))
7419 (if (not (buffer-name (car quit-config)))
7420 (gnus-configure-windows 'group 'force)
7421 (set-buffer (car quit-config))
7422 (and (eq major-mode 'gnus-summary-mode)
7423 (gnus-set-global-variables))
7424 (gnus-configure-windows (cdr quit-config)))))
7425 (gnus-message 3 "Can't select group")
7427 ;; The user did a `C-g' while prompting for number of articles,
7428 ;; so we exit this group.
7429 ((eq did-select 'quit)
7430 (and (eq major-mode 'gnus-summary-mode)
7431 (not (equal (current-buffer) kill-buffer))
7432 (kill-buffer (current-buffer)))
7434 (gnus-kill-or-deaden-summary kill-buffer))
7435 (if (not quit-config)
7437 (set-buffer gnus-group-buffer)
7438 (gnus-group-jump-to-group group)
7439 (gnus-group-next-unread-group 1)
7440 (gnus-configure-windows 'group 'force))
7441 (if (not (buffer-name (car quit-config)))
7442 (gnus-configure-windows 'group 'force)
7443 (set-buffer (car quit-config))
7444 (and (eq major-mode 'gnus-summary-mode)
7445 (gnus-set-global-variables))
7446 (gnus-configure-windows (cdr quit-config))))
7447 ;; Finally signal the quit.
7449 ;; The group was successfully selected.
7451 (gnus-set-global-variables)
7452 ;; Save the active value in effect when the group was entered.
7453 (setq gnus-newsgroup-active
7455 (gnus-active gnus-newsgroup-name)))
7456 ;; You can change the summary buffer in some way with this hook.
7457 (run-hooks 'gnus-select-group-hook)
7458 ;; Set any local variables in the group parameters.
7459 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7460 (gnus-update-format-specifications)
7461 ;; Do score processing.
7462 (when gnus-use-scoring
7463 (gnus-possibly-score-headers))
7464 ;; Check whether to fill in the gaps in the threads.
7465 (when gnus-build-sparse-threads
7466 (gnus-build-sparse-threads))
7467 ;; Find the initial limit.
7469 (let ((gnus-newsgroup-dormant nil))
7470 (gnus-summary-initial-limit show-all))
7471 (gnus-summary-initial-limit show-all))
7472 ;; Generate the summary buffer.
7474 (gnus-summary-prepare))
7475 (when gnus-use-trees
7476 (gnus-tree-open group)
7477 (setq gnus-summary-highlight-line-function
7478 'gnus-tree-highlight-article))
7479 ;; If the summary buffer is empty, but there are some low-scored
7480 ;; articles or some excluded dormants, we include these in the
7482 (when (and (zerop (buffer-size))
7484 (cond (gnus-newsgroup-dormant
7485 (gnus-summary-limit-include-dormant))
7486 ((and gnus-newsgroup-scored show-all)
7487 (gnus-summary-limit-include-expunged))))
7488 ;; Function `gnus-apply-kill-file' must be called in this hook.
7489 (run-hooks 'gnus-apply-kill-hook)
7490 (if (and (zerop (buffer-size))
7493 ;; This newsgroup is empty.
7494 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7495 (gnus-message 6 "No unread news")
7497 (gnus-kill-or-deaden-summary kill-buffer))
7498 ;; Return nil from this function.
7500 ;; Hide conversation thread subtrees. We cannot do this in
7501 ;; gnus-summary-prepare-hook since kill processing may not
7502 ;; work with hidden articles.
7503 (and gnus-show-threads
7504 gnus-thread-hide-subtree
7505 (gnus-summary-hide-all-threads))
7506 ;; Show first unread article if requested.
7507 (if (and (not no-article)
7509 gnus-newsgroup-unreads
7510 gnus-auto-select-first)
7511 (if (eq gnus-auto-select-first 'best)
7512 (gnus-summary-best-unread-article)
7513 (gnus-summary-first-unread-article))
7514 ;; Don't select any articles, just move point to the first
7515 ;; article in the group.
7516 (goto-char (point-min))
7517 (gnus-summary-position-point)
7518 (gnus-set-mode-line 'summary)
7519 (gnus-configure-windows 'summary 'force))
7520 ;; If we are in async mode, we send some info to the backend.
7521 (when gnus-newsgroup-async
7522 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7524 (gnus-kill-or-deaden-summary kill-buffer))
7525 (when (get-buffer-window gnus-group-buffer t)
7526 ;; Gotta use windows, because recenter does wierd stuff if
7527 ;; the current buffer ain't the displayed window.
7528 (let ((owin (selected-window)))
7529 (select-window (get-buffer-window gnus-group-buffer t))
7530 (when (gnus-group-goto-group group)
7532 (select-window owin))))
7533 ;; Mark this buffer as "prepared".
7534 (setq gnus-newsgroup-prepared t)
7537 (defun gnus-summary-prepare ()
7538 "Generate the summary buffer."
7539 (let ((buffer-read-only nil))
7541 (setq gnus-newsgroup-data nil
7542 gnus-newsgroup-data-reverse nil)
7543 (run-hooks 'gnus-summary-generate-hook)
7544 ;; Generate the buffer, either with threads or without.
7545 (when gnus-newsgroup-headers
7546 (gnus-summary-prepare-threads
7547 (if gnus-show-threads
7548 (gnus-sort-gathered-threads
7549 (funcall gnus-summary-thread-gathering-function
7551 (gnus-cut-threads (gnus-make-threads)))))
7552 ;; Unthreaded display.
7553 (gnus-sort-articles gnus-newsgroup-headers))))
7554 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7555 ;; Call hooks for modifying summary buffer.
7556 (goto-char (point-min))
7557 (run-hooks 'gnus-summary-prepare-hook)))
7559 (defun gnus-gather-threads-by-subject (threads)
7560 "Gather threads by looking at Subject headers."
7561 (if (not gnus-summary-make-false-root)
7563 (let ((hashtb (gnus-make-hashtable 1023))
7566 subject hthread whole-subject)
7568 (setq whole-subject (mail-header-subject (car (car threads))))
7569 (if (and gnus-summary-gather-exclude-subject
7570 (string-match gnus-summary-gather-exclude-subject
7572 () ; We don't want to do anything with this article.
7573 ;; We simplify the subject before looking it up in the
7577 ;; Truncate the subject.
7578 ((numberp gnus-summary-gather-subject-limit)
7579 (setq subject (gnus-simplify-subject-re whole-subject))
7580 (if (> (length subject) gnus-summary-gather-subject-limit)
7581 (substring subject 0 gnus-summary-gather-subject-limit)
7583 ;; Fuzzily simplify it.
7584 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7585 (gnus-simplify-subject-fuzzy whole-subject))
7586 ;; Just remove the leading "Re:".
7588 (gnus-simplify-subject-re whole-subject))))
7590 (if (setq hthread (gnus-gethash subject hashtb))
7592 ;; We enter a dummy root into the thread, if we
7593 ;; haven't done that already.
7594 (unless (stringp (car (car hthread)))
7595 (setcar hthread (list whole-subject (car hthread))))
7596 ;; We add this new gathered thread to this gathered
7598 (setcdr (car hthread)
7599 (nconc (cdr (car hthread)) (list (car threads))))
7600 ;; Remove it from the list of threads.
7601 (setcdr prev (cdr threads))
7602 (setq threads prev))
7603 ;; Enter this thread into the hash table.
7604 (gnus-sethash subject threads hashtb)))
7606 (setq threads (cdr threads)))
7609 (defun gnus-summary-gather-threads-by-references (threads)
7610 "Gather threads by looking at References headers."
7611 (let ((idhashtb (gnus-make-hashtable 1023))
7612 (thhashtb (gnus-make-hashtable 1023))
7615 ids references id gthread gid entered)
7617 (when (setq references (mail-header-references (caar threads)))
7618 (setq id (mail-header-id (caar threads)))
7619 (setq ids (gnus-split-references references))
7622 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7624 (gnus-sethash (car ids) id idhashtb)
7625 (gnus-sethash id threads thhashtb))
7626 (setq gthread (gnus-gethash gid thhashtb))
7628 ;; We enter a dummy root into the thread, if we
7629 ;; haven't done that already.
7630 (unless (stringp (caar gthread))
7631 (setcar gthread (list (mail-header-subject (caar gthread))
7633 ;; We add this new gathered thread to this gathered
7635 (setcdr (car gthread)
7636 (nconc (cdar gthread) (list (car threads)))))
7637 ;; Add it into the thread hash table.
7638 (gnus-sethash id gthread thhashtb)
7640 ;; Remove it from the list of threads.
7641 (setcdr prev (cdr threads))
7642 (setq threads prev))
7643 (setq ids (cdr ids))))
7645 (setq threads (cdr threads)))
7648 (defun gnus-sort-gathered-threads (threads)
7649 "Sort subtreads inside each gathered thread by article number."
7650 (let ((result threads))
7652 (when (stringp (car (car threads)))
7653 (setcdr (car threads)
7654 (sort (cdr (car threads)) 'gnus-thread-sort-by-number)))
7655 (setq threads (cdr threads)))
7658 (defun gnus-make-threads ()
7659 "Go through the dependency hashtb and find the roots. Return all threads."
7663 (unless (car (symbol-value refs))
7664 ;; These threads do not refer back to any other articles,
7665 ;; so they're roots.
7666 (setq threads (append (cdr (symbol-value refs)) threads))))
7667 gnus-newsgroup-dependencies)
7670 (defun gnus-build-sparse-threads ()
7671 (let ((headers gnus-newsgroup-headers)
7672 (deps gnus-newsgroup-dependencies)
7673 header references generation relations
7674 cthread subject child end pthread relation)
7675 ;; First we create an alist of generations/relations, where
7676 ;; generations is how much we trust the ralation, and the relation
7678 (gnus-message 7 "Making sparse threads...")
7680 (nnheader-set-temp-buffer " *gnus sparse threads*")
7681 (while (setq header (pop headers))
7682 (when (and (setq references (mail-header-references header))
7683 (not (string= references "")))
7685 (setq child (downcase (mail-header-id header))
7686 subject (mail-header-subject header))
7688 (while (search-backward ">" nil t)
7689 (setq end (1+ (point)))
7690 (when (search-backward "<" nil t)
7691 (push (list (incf generation)
7692 child (setq child (downcase
7693 (buffer-substring (point) end)))
7696 (push (list (1+ generation) child nil subject) relations)
7698 (kill-buffer (current-buffer)))
7699 ;; Sort over trustworthiness.
7700 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7701 (while (setq relation (pop relations))
7702 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7703 (unless (car (symbol-value cthread))
7704 ;; Make this article the parent of these threads.
7705 (setcar (symbol-value cthread)
7706 (vector gnus-reffed-article-number
7710 (or (caddr relation) "") 0 0 "")))
7711 (set cthread (list (vector gnus-reffed-article-number
7713 "" "" (cadr relation)
7714 (or (caddr relation) "") 0 0 ""))))
7715 (push gnus-reffed-article-number gnus-newsgroup-limit)
7716 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7717 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7718 gnus-newsgroup-reads)
7719 (decf gnus-reffed-article-number)
7720 ;; Make this new thread the child of its parent.
7721 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7722 (setcdr (symbol-value pthread)
7723 (nconc (cdr (symbol-value pthread))
7724 (list (symbol-value cthread))))
7725 (set pthread (list nil (symbol-value cthread))))))
7726 (gnus-message 7 "Making sparse threads...done")))
7728 (defun gnus-build-old-threads ()
7729 ;; Look at all the articles that refer back to old articles, and
7730 ;; fetch the headers for the articles that aren't there. This will
7731 ;; build complete threads - if the roots haven't been expired by the
7736 (when (not (car (symbol-value refs)))
7737 (setq heads (cdr (symbol-value refs)))
7739 (if (memq (mail-header-number (car (car heads)))
7740 gnus-newsgroup-dormant)
7741 (setq heads (cdr heads))
7742 (setq id (symbol-name refs))
7743 (while (and (setq id (gnus-build-get-header id))
7744 (not (car (gnus-gethash
7745 id gnus-newsgroup-dependencies)))))
7746 (setq heads nil)))))
7747 gnus-newsgroup-dependencies)))
7749 (defun gnus-build-get-header (id)
7750 ;; Look through the buffer of NOV lines and find the header to
7751 ;; ID. Enter this line into the dependencies hash table, and return
7752 ;; the id of the parent article (if any).
7753 (let ((deps gnus-newsgroup-dependencies)
7757 (set-buffer nntp-server-buffer)
7758 (goto-char (point-min))
7759 (while (and (not found) (search-forward id nil t))
7761 (setq found (looking-at
7762 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7763 (regexp-quote id))))
7764 (or found (beginning-of-line 2)))
7769 (setq header (gnus-nov-parse-line
7770 (read (current-buffer)) deps))
7771 (gnus-parent-id (mail-header-references header))))))
7773 (let ((number (mail-header-number header)))
7774 (push number gnus-newsgroup-limit)
7775 (push header gnus-newsgroup-headers)
7776 (if (memq number gnus-newsgroup-unselected)
7778 (push number gnus-newsgroup-unreads)
7779 (setq gnus-newsgroup-unselected
7780 (delq number gnus-newsgroup-unselected)))
7781 (push number gnus-newsgroup-ancient)))))))
7783 (defun gnus-summary-update-article (article &optional header)
7784 "Update ARTICLE in the summary buffer."
7785 (let ((id (mail-header-id (gnus-summary-article-header article)))
7786 (data (gnus-data-find article)))
7787 (setcar (gnus-id-to-thread id) nil)
7788 (gnus-summary-insert-subject id)
7789 ;; Set the (possibly) new article number in the data structure.
7790 (gnus-data-set-number data (gnus-id-to-article id))))
7792 (defun gnus-rebuild-thread (id)
7793 "Rebuild the thread containing ID."
7794 (let ((dep gnus-newsgroup-dependencies)
7795 (buffer-read-only nil)
7796 current headers refs thread art data)
7797 (if (not gnus-show-threads)
7798 (setq thread (list (car (gnus-id-to-thread id))))
7799 ;; Get the thread this article is part of.
7800 (setq thread (gnus-remove-thread id)))
7801 (setq current (save-excursion
7802 (and (zerop (forward-line -1))
7803 (gnus-summary-article-number))))
7804 ;; If this is a gathered thread, we have to go some re-gathering.
7805 (when (stringp (car thread))
7806 (let ((subject (car thread))
7808 (setq thread (cdr thread))
7810 (unless (memq (setq thr (gnus-id-to-thread
7812 (mail-header-id (car (car thread))))))
7815 (setq thread (cdr thread)))
7816 ;; We now have all (unique) roots.
7817 (if (= (length roots) 1)
7818 ;; All the loose roots are now one solid root.
7819 (setq thread (car roots))
7820 (setq thread (cons subject (gnus-sort-threads roots))))))
7823 ;; We then insert this thread into the summary buffer.
7824 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7825 (gnus-summary-prepare-threads (list thread))
7826 (setq data (nreverse gnus-newsgroup-data))
7827 (setq threads gnus-newsgroup-threads))
7828 ;; We splice the new data into the data structure.
7829 (gnus-data-enter-list current data)
7830 (gnus-data-compute-positions)
7831 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7833 (defun gnus-id-to-thread (id)
7834 "Return the (sub-)thread where ID appears."
7835 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7837 (defun gnus-id-to-article (id)
7838 "Return the article number of ID."
7839 (let ((thread (gnus-id-to-thread id)))
7841 (mail-header-number (car thread)))))
7843 (defun gnus-id-to-header (id)
7844 "Return the article headers of ID."
7845 (car (gnus-id-to-thread id)))
7847 (defun gnus-article-displayed-root-p (article)
7848 "Say whether ARTICLE is a root(ish) article."
7849 (let ((level (gnus-summary-thread-level article))
7855 (null (setq particle (gnus-id-to-article
7857 (mail-header-references
7858 (gnus-summary-article-header article))))))
7859 (null (gnus-summary-thread-level particle)))))))
7861 (defun gnus-root-id (id)
7862 "Return the id of the root of the thread where ID appears."
7864 (while (and id (setq prev (car (gnus-gethash
7866 gnus-newsgroup-dependencies))))
7868 id (gnus-parent-id (mail-header-references prev))))
7871 (defun gnus-remove-thread (id &optional dont-remove)
7872 "Remove the thread that has ID in it."
7873 (let ((dep gnus-newsgroup-dependencies)
7874 headers thread prev last-id)
7875 ;; First go up in this thread until we find the root.
7876 (setq last-id (gnus-root-id id))
7877 (setq headers (list (car (gnus-id-to-thread last-id))
7878 (car (car (cdr (gnus-id-to-thread last-id))))))
7879 ;; We have now found the real root of this thread. It might have
7880 ;; been gathered into some loose thread, so we have to search
7881 ;; through the threads to find the thread we wanted.
7882 (let ((threads gnus-newsgroup-threads)
7885 (setq sub (car threads))
7886 (if (stringp (car sub))
7887 ;; This is a gathered threads, so we look at the roots
7888 ;; below it to find whether this article in in this
7891 (setq sub (cdr sub))
7893 (when (member (car (car sub)) headers)
7894 (setq thread (car threads)
7897 (setq sub (cdr sub))))
7898 ;; It's an ordinary thread, so we check it.
7899 (when (eq (car sub) (car headers))
7902 (setq threads (cdr threads)))
7903 ;; If this article is in no thread, then it's a root.
7906 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7907 (setq thread (gnus-gethash (downcase last-id) dep)))
7910 thread ; We return this thread.
7912 (if (stringp (car thread))
7914 ;; If we use dummy roots, then we have to remove the
7915 ;; dummy root as well.
7916 (when (eq gnus-summary-make-false-root 'dummy)
7919 (setq thread (cdr thread))
7921 (gnus-remove-thread-1 (car thread))
7922 (setq thread (cdr thread))))
7923 (gnus-remove-thread-1 thread))))))))
7925 (defun gnus-remove-thread-1 (thread)
7926 "Remove the thread THREAD recursively."
7927 (let ((number (mail-header-number (car thread)))
7929 (when (setq pos (text-property-any
7930 (point-min) (point-max) 'gnus-number number))
7933 (gnus-data-remove number))
7934 (setq thread (cdr thread))
7936 (gnus-remove-thread-1 (car thread))
7937 (setq thread (cdr thread)))))
7939 (defun gnus-sort-threads (threads)
7941 (if (not gnus-thread-sort-functions)
7943 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7944 (car gnus-thread-sort-functions)
7946 ,(gnus-make-sort-function
7947 (reverse gnus-thread-sort-functions))))))
7948 (gnus-message 7 "Sorting threads...")
7951 (gnus-message 7 "Sorting threads...done")))))
7953 (defun gnus-sort-articles (articles)
7955 (when gnus-article-sort-functions
7956 (let ((func (if (= 1 (length gnus-article-sort-functions))
7957 (car gnus-article-sort-functions)
7959 ,(gnus-make-sort-function
7960 (reverse gnus-article-sort-functions))))))
7961 (gnus-message 7 "Sorting articles...")
7963 (setq gnus-newsgroup-headers (sort articles func))
7964 (gnus-message 7 "Sorting articles...done")))))
7966 (defun gnus-make-sort-function (funs)
7967 "Return a composite sort condition based on the functions in FUNC."
7969 `(or (,(car funs) t1 t2)
7970 (and (not (,(car funs) t2 t1))
7971 ,(gnus-make-sort-function (cdr funs))))
7972 `(,(car funs) t1 t2)))
7974 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7975 (defmacro gnus-thread-header (thread)
7976 ;; Return header of first article in THREAD.
7977 ;; Note that THREAD must never, ever be anything else than a variable -
7978 ;; using some other form will lead to serious barfage.
7979 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7980 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7981 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7984 (defsubst gnus-article-sort-by-number (h1 h2)
7985 "Sort articles by article number."
7986 (< (mail-header-number h1)
7987 (mail-header-number h2)))
7989 (defun gnus-thread-sort-by-number (h1 h2)
7990 "Sort threads by root article number."
7991 (gnus-article-sort-by-number
7992 (gnus-thread-header h1) (gnus-thread-header h2)))
7994 (defsubst gnus-article-sort-by-author (h1 h2)
7995 "Sort articles by root author."
7997 (let ((extract (funcall
7998 gnus-extract-address-components
7999 (mail-header-from h1))))
8000 (or (car extract) (cdr extract)))
8001 (let ((extract (funcall
8002 gnus-extract-address-components
8003 (mail-header-from h2))))
8004 (or (car extract) (cdr extract)))))
8006 (defun gnus-thread-sort-by-author (h1 h2)
8007 "Sort threads by root author."
8008 (gnus-article-sort-by-author
8009 (gnus-thread-header h1) (gnus-thread-header h2)))
8011 (defsubst gnus-article-sort-by-subject (h1 h2)
8012 "Sort articles by root subject."
8014 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8015 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8017 (defun gnus-thread-sort-by-subject (h1 h2)
8018 "Sort threads by root subject."
8019 (gnus-article-sort-by-subject
8020 (gnus-thread-header h1) (gnus-thread-header h2)))
8022 (defsubst gnus-article-sort-by-date (h1 h2)
8023 "Sort articles by root article date."
8025 (gnus-sortable-date (mail-header-date h1))
8026 (gnus-sortable-date (mail-header-date h2))))
8028 (defun gnus-thread-sort-by-date (h1 h2)
8029 "Sort threads by root article date."
8030 (gnus-article-sort-by-date
8031 (gnus-thread-header h1) (gnus-thread-header h2)))
8033 (defsubst gnus-article-sort-by-score (h1 h2)
8034 "Sort articles by root article score.
8035 Unscored articles will be counted as having a score of zero."
8036 (> (or (cdr (assq (mail-header-number h1)
8037 gnus-newsgroup-scored))
8038 gnus-summary-default-score 0)
8039 (or (cdr (assq (mail-header-number h2)
8040 gnus-newsgroup-scored))
8041 gnus-summary-default-score 0)))
8043 (defun gnus-thread-sort-by-score (h1 h2)
8044 "Sort threads by root article score."
8045 (gnus-article-sort-by-score
8046 (gnus-thread-header h1) (gnus-thread-header h2)))
8048 (defun gnus-thread-sort-by-total-score (h1 h2)
8049 "Sort threads by the sum of all scores in the thread.
8050 Unscored articles will be counted as having a score of zero."
8051 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8053 (defun gnus-thread-total-score (thread)
8054 ;; This function find the total score of THREAD.
8056 (if (stringp (car thread))
8057 (apply gnus-thread-score-function 0
8058 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8059 (gnus-thread-total-score-1 thread))
8060 (gnus-thread-total-score-1 (list thread))))
8062 (defun gnus-thread-total-score-1 (root)
8063 ;; This function find the total score of the thread below ROOT.
8064 (setq root (car root))
8065 (apply gnus-thread-score-function
8066 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8067 gnus-summary-default-score 0)
8068 (mapcar 'gnus-thread-total-score
8069 (cdr (gnus-gethash (downcase (mail-header-id root))
8070 gnus-newsgroup-dependencies)))))
8072 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8073 (defvar gnus-tmp-prev-subject nil)
8074 (defvar gnus-tmp-false-parent nil)
8075 (defvar gnus-tmp-root-expunged nil)
8076 (defvar gnus-tmp-dummy-line nil)
8078 (defun gnus-summary-prepare-threads (threads)
8079 "Prepare summary buffer from THREADS and indentation LEVEL.
8080 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8081 or a straight list of headers."
8082 (gnus-message 7 "Generating summary...")
8084 (setq gnus-newsgroup-threads threads)
8087 (let ((gnus-tmp-level 0)
8088 (default-score (or gnus-summary-default-score 0))
8089 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8090 thread number subject stack state gnus-tmp-gathered beg-match
8091 new-roots gnus-tmp-new-adopts thread-end
8092 gnus-tmp-header gnus-tmp-unread
8093 gnus-tmp-replied gnus-tmp-subject-or-nil
8094 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8095 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8096 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8098 (setq gnus-tmp-prev-subject nil)
8100 (if (vectorp (car threads))
8101 ;; If this is a straight (sic) list of headers, then a
8102 ;; threaded summary display isn't required, so we just create
8103 ;; an unthreaded one.
8104 (gnus-summary-prepare-unthreaded threads)
8106 ;; Do the threaded display.
8108 (while (or threads stack gnus-tmp-new-adopts new-roots)
8110 (if (and (= gnus-tmp-level 0)
8111 (not (setq gnus-tmp-dummy-line nil))
8113 (= (car (car stack)) 0))
8114 (not gnus-tmp-false-parent)
8115 (or gnus-tmp-new-adopts new-roots))
8116 (if gnus-tmp-new-adopts
8117 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8118 thread (list (car gnus-tmp-new-adopts))
8119 gnus-tmp-header (car (car thread))
8120 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8122 (setq thread (list (car new-roots))
8123 gnus-tmp-header (car (car thread))
8124 new-roots (cdr new-roots))))
8127 ;; If there are some threads, we do them before the
8128 ;; threads on the stack.
8129 (setq thread threads
8130 gnus-tmp-header (car (car thread)))
8131 ;; There were no current threads, so we pop something off
8133 (setq state (car stack)
8134 gnus-tmp-level (car state)
8137 gnus-tmp-header (car (car thread)))))
8139 (setq gnus-tmp-false-parent nil)
8140 (setq gnus-tmp-root-expunged nil)
8141 (setq thread-end nil)
8143 (if (stringp gnus-tmp-header)
8144 ;; The header is a dummy root.
8146 ((eq gnus-summary-make-false-root 'adopt)
8147 ;; We let the first article adopt the rest.
8148 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8149 (cdr (cdr (car thread)))))
8150 (setq gnus-tmp-gathered
8152 (lambda (h) (mail-header-number (car h)))
8153 (cdr (cdr (car thread))))
8155 (setq thread (cons (list (car (car thread))
8156 (car (cdr (car thread))))
8158 (setq gnus-tmp-level -1
8159 gnus-tmp-false-parent t))
8160 ((eq gnus-summary-make-false-root 'empty)
8161 ;; We print adopted articles with empty subject fields.
8162 (setq gnus-tmp-gathered
8164 (lambda (h) (mail-header-number (car h)))
8165 (cdr (cdr (car thread))))
8167 (setq gnus-tmp-level -1))
8168 ((eq gnus-summary-make-false-root 'dummy)
8169 ;; We remember that we probably want to output a dummy
8171 (setq gnus-tmp-dummy-line gnus-tmp-header)
8172 (setq gnus-tmp-prev-subject gnus-tmp-header))
8174 ;; We do not make a root for the gathered
8175 ;; sub-threads at all.
8176 (setq gnus-tmp-level -1)))
8178 (setq number (mail-header-number gnus-tmp-header)
8179 subject (mail-header-subject gnus-tmp-header))
8182 ;; If the thread has changed subject, we might want to make
8183 ;; this subthread into a root.
8184 ((and (null gnus-thread-ignore-subject)
8185 (not (zerop gnus-tmp-level))
8186 gnus-tmp-prev-subject
8188 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8189 (setq new-roots (nconc new-roots (list (car thread)))
8191 gnus-tmp-header nil))
8192 ;; If the article lies outside the current limit,
8193 ;; then we do not display it.
8194 ((and (not (memq number gnus-newsgroup-limit))
8195 (not gnus-tmp-dummy-line))
8196 (setq gnus-tmp-gathered
8198 (lambda (h) (mail-header-number (car h)))
8201 (setq gnus-tmp-new-adopts (if (cdr (car thread))
8202 (append gnus-tmp-new-adopts
8204 gnus-tmp-new-adopts)
8206 gnus-tmp-header nil)
8207 (when (zerop gnus-tmp-level)
8208 (setq gnus-tmp-root-expunged t)))
8209 ;; Perhaps this article is to be marked as read?
8210 ((and gnus-summary-mark-below
8211 (< (or (cdr (assq number gnus-newsgroup-scored))
8213 gnus-summary-mark-below)
8214 ;; Don't touch sparse articles.
8215 (not (memq number gnus-newsgroup-sparse)))
8216 (setq gnus-newsgroup-unreads
8217 (delq number gnus-newsgroup-unreads))
8218 (if gnus-newsgroup-auto-expire
8219 (push number gnus-newsgroup-expirable)
8220 (push (cons number gnus-low-score-mark)
8221 gnus-newsgroup-reads))))
8223 (when gnus-tmp-header
8224 ;; We may have an old dummy line to output before this
8226 (when gnus-tmp-dummy-line
8227 (gnus-summary-insert-dummy-line
8228 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8229 (setq gnus-tmp-dummy-line nil))
8231 ;; Compute the mark.
8235 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8236 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8237 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8238 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8239 (t (or (cdr (assq number gnus-newsgroup-reads))
8240 gnus-ancient-mark))))
8242 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8243 gnus-tmp-header gnus-tmp-level)
8244 gnus-newsgroup-data)
8246 ;; Actually insert the line.
8248 gnus-tmp-subject-or-nil
8250 ((and gnus-thread-ignore-subject
8251 gnus-tmp-prev-subject
8252 (not (inline (gnus-subject-equal
8253 gnus-tmp-prev-subject subject))))
8255 ((zerop gnus-tmp-level)
8256 (if (and (eq gnus-summary-make-false-root 'empty)
8257 (memq number gnus-tmp-gathered)
8258 gnus-tmp-prev-subject
8259 (inline (gnus-subject-equal
8260 gnus-tmp-prev-subject subject)))
8261 gnus-summary-same-subject
8263 (t gnus-summary-same-subject)))
8264 (if (and (eq gnus-summary-make-false-root 'adopt)
8265 (= gnus-tmp-level 1)
8266 (memq number gnus-tmp-gathered))
8267 (setq gnus-tmp-opening-bracket ?\<
8268 gnus-tmp-closing-bracket ?\>)
8269 (setq gnus-tmp-opening-bracket ?\[
8270 gnus-tmp-closing-bracket ?\]))
8272 gnus-tmp-indentation
8273 (aref gnus-thread-indent-array gnus-tmp-level)
8274 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8275 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8276 gnus-summary-default-score 0)
8278 (if (or (null gnus-summary-default-score)
8279 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8280 gnus-summary-zcore-fuzz)) ?
8281 (if (< gnus-tmp-score gnus-summary-default-score)
8282 gnus-score-below-mark gnus-score-over-mark))
8284 (cond ((memq number gnus-newsgroup-processable)
8286 ((memq number gnus-newsgroup-cached)
8288 ((memq number gnus-newsgroup-replied)
8290 (t gnus-unread-mark))
8291 gnus-tmp-from (mail-header-from gnus-tmp-header)
8294 ((string-match "(.+)" gnus-tmp-from)
8295 (substring gnus-tmp-from
8296 (1+ (match-beginning 0)) (1- (match-end 0))))
8297 ((string-match "<[^>]+> *$" gnus-tmp-from)
8298 (setq beg-match (match-beginning 0))
8299 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8300 (substring gnus-tmp-from (1+ (match-beginning 0))
8301 (1- (match-end 0))))
8302 (substring gnus-tmp-from 0 beg-match)))
8304 (when (string= gnus-tmp-name "")
8305 (setq gnus-tmp-name gnus-tmp-from))
8306 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8309 (progn (eval gnus-summary-line-format-spec) (point))
8310 'gnus-number number)
8313 (run-hooks 'gnus-summary-update-hook)
8316 (setq gnus-tmp-prev-subject subject)))
8318 (when (nth 1 thread)
8319 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8320 (incf gnus-tmp-level)
8321 (setq threads (if thread-end nil (cdr (car thread))))
8323 (setq gnus-tmp-level 0)))))
8324 (gnus-message 7 "Generating summary...done"))
8326 (defun gnus-summary-prepare-unthreaded (headers)
8327 "Generate an unthreaded summary buffer based on HEADERS."
8328 (let (header number mark)
8331 (setq header (car headers)
8332 headers (cdr headers)
8333 number (mail-header-number header))
8335 ;; We may have to root out some bad articles...
8336 (when (memq number gnus-newsgroup-limit)
8337 (when (and gnus-summary-mark-below
8338 (< (or (cdr (assq number gnus-newsgroup-scored))
8339 gnus-summary-default-score 0)
8340 gnus-summary-mark-below))
8341 (setq gnus-newsgroup-unreads
8342 (delq number gnus-newsgroup-unreads))
8343 (if gnus-newsgroup-auto-expire
8344 (push number gnus-newsgroup-expirable)
8345 (push (cons number gnus-low-score-mark)
8346 gnus-newsgroup-reads)))
8350 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8351 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8352 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8353 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8354 (t (or (cdr (assq number gnus-newsgroup-reads))
8355 gnus-ancient-mark))))
8356 (setq gnus-newsgroup-data
8357 (cons (gnus-data-make number mark (1+ (point)) header 0)
8358 gnus-newsgroup-data))
8359 (gnus-summary-insert-line
8360 header 0 nil mark (memq number gnus-newsgroup-replied)
8361 (memq number gnus-newsgroup-expirable)
8362 (mail-header-subject header) nil
8363 (cdr (assq number gnus-newsgroup-scored))
8364 (memq number gnus-newsgroup-processable))))))
8366 (defun gnus-select-newsgroup (group &optional read-all)
8367 "Select newsgroup GROUP.
8368 If READ-ALL is non-nil, all articles in the group are selected."
8369 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8370 (info (nth 2 entry))
8371 articles fetched-articles cached)
8373 (or (gnus-check-server
8374 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8375 (error "Couldn't open server"))
8377 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8378 (gnus-activate-group group) ; Or we can activate it...
8379 (progn ; Or we bug out.
8380 (kill-buffer (current-buffer))
8381 (error "Couldn't request group %s: %s"
8382 group (gnus-status-message group))))
8384 (setq gnus-newsgroup-name group)
8385 (setq gnus-newsgroup-unselected nil)
8386 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8388 (and gnus-asynchronous
8389 (gnus-check-backend-function
8390 'request-asynchronous gnus-newsgroup-name)
8391 (setq gnus-newsgroup-async
8392 (gnus-request-asynchronous gnus-newsgroup-name)))
8394 ;; Adjust and set lists of article marks.
8396 (gnus-adjust-marked-articles info))
8398 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8399 (when (gnus-virtual-group-p group)
8400 (setq cached gnus-newsgroup-cached))
8402 (setq gnus-newsgroup-unreads
8403 (gnus-set-difference
8404 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8405 gnus-newsgroup-dormant))
8407 (setq gnus-newsgroup-processable nil)
8409 (setq articles (gnus-articles-to-read group read-all))
8413 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8415 ((eq articles 0) nil)
8417 ;; Init the dependencies hash table.
8418 (setq gnus-newsgroup-dependencies
8419 (gnus-make-hashtable (length articles)))
8420 ;; Retrieve the headers and read them in.
8421 (gnus-message 5 "Fetching headers...")
8422 (setq gnus-newsgroup-headers
8424 (setq gnus-headers-retrieved-by
8425 (gnus-retrieve-headers
8426 articles gnus-newsgroup-name
8427 ;; We might want to fetch old headers, but
8428 ;; not if there is only 1 article.
8429 (and gnus-fetch-old-headers
8431 (not (eq gnus-fetch-old-headers 'some))
8432 (not (numberp gnus-fetch-old-headers)))
8433 (> (length articles) 1))))))
8434 (gnus-get-newsgroup-headers-xover articles)
8435 (gnus-get-newsgroup-headers)))
8436 (gnus-message 5 "Fetching headers...done")
8438 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8440 (setq gnus-newsgroup-cached cached))
8442 ;; Set the initial limit.
8443 (setq gnus-newsgroup-limit (copy-sequence articles))
8444 ;; Remove canceled articles from the list of unread articles.
8445 (setq gnus-newsgroup-unreads
8446 (gnus-set-sorted-intersection
8447 gnus-newsgroup-unreads
8448 (setq fetched-articles
8449 (mapcar (lambda (headers) (mail-header-number headers))
8450 gnus-newsgroup-headers))))
8451 ;; Removed marked articles that do not exist.
8452 (gnus-update-missing-marks
8453 (gnus-sorted-complement fetched-articles articles))
8454 ;; We might want to build some more threads first.
8455 (and gnus-fetch-old-headers
8456 (eq gnus-headers-retrieved-by 'nov)
8457 (gnus-build-old-threads))
8458 ;; Check whether auto-expire is to be done in this group.
8459 (setq gnus-newsgroup-auto-expire
8460 (gnus-group-auto-expirable-p group))
8461 ;; First and last article in this newsgroup.
8462 (and gnus-newsgroup-headers
8463 (setq gnus-newsgroup-begin
8464 (mail-header-number (car gnus-newsgroup-headers)))
8465 (setq gnus-newsgroup-end
8467 (gnus-last-element gnus-newsgroup-headers))))
8468 (setq gnus-reffed-article-number -1)
8469 ;; GROUP is successfully selected.
8470 (or gnus-newsgroup-headers t)))))
8472 (defun gnus-articles-to-read (group read-all)
8473 ;; Find out what articles the user wants to read.
8475 ;; Select all articles if `read-all' is non-nil, or if there
8476 ;; are no unread articles.
8478 (and (zerop (length gnus-newsgroup-marked))
8479 (zerop (length gnus-newsgroup-unreads))))
8480 (gnus-uncompress-range (gnus-active group))
8481 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8482 (copy-sequence gnus-newsgroup-unreads))
8484 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8485 (scored (length scored-list))
8486 (number (length articles))
8487 (marked (+ (length gnus-newsgroup-marked)
8488 (length gnus-newsgroup-dormant)))
8496 ((and (or (<= scored marked) (= scored number))
8497 (numberp gnus-large-newsgroup)
8498 (> number gnus-large-newsgroup))
8502 "How many articles from %s (default %d): "
8503 gnus-newsgroup-name number))))
8504 (if (string-match "^[ \t]*$" input) number input)))
8505 ((and (> scored marked) (< scored number))
8508 (format "%s %s (%d scored, %d total): "
8509 "How many articles from"
8510 group scored number))))
8511 (if (string-match "^[ \t]*$" input)
8515 (setq select (if (stringp select) (string-to-number select) select))
8516 (if (or (null select) (zerop select))
8518 (if (and (not (zerop scored)) (<= (abs select) scored))
8520 (setq articles (sort scored-list '<))
8521 (setq number (length articles)))
8522 (setq articles (copy-sequence articles)))
8524 (if (< (abs select) number)
8526 ;; Select the N oldest articles.
8527 (setcdr (nthcdr (1- (abs select)) articles) nil)
8528 ;; Select the N most recent articles.
8529 (setq articles (nthcdr (- number select) articles))))
8530 (setq gnus-newsgroup-unselected
8531 (gnus-sorted-intersection
8532 gnus-newsgroup-unreads
8533 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8536 (defun gnus-killed-articles (killed articles)
8539 (if (inline (gnus-member-of-range (car articles) killed))
8540 (setq out (cons (car articles) out)))
8541 (setq articles (cdr articles)))
8544 (defun gnus-uncompress-marks (marks)
8545 "Uncompress the mark ranges in MARKS."
8546 (let ((uncompressed '(score bookmark))
8549 (if (memq (caar marks) uncompressed)
8550 (push (car marks) out)
8551 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8552 (setq marks (cdr marks)))
8555 (defun gnus-adjust-marked-articles (info)
8556 "Set all article lists and remove all marks that are no longer legal."
8557 (let* ((marked-lists (gnus-info-marks info))
8558 (active (gnus-active (gnus-info-group info)))
8561 (types gnus-article-mark-lists)
8562 (uncompressed '(score bookmark))
8563 marks var articles article mark)
8566 (setq marks (pop marked-lists))
8567 (set (setq var (intern (format "gnus-newsgroup-%s"
8568 (car (rassq (setq mark (car marks))
8570 (if (memq (car marks) uncompressed) (cdr marks)
8571 (gnus-uncompress-range (cdr marks))))
8573 (setq articles (symbol-value var))
8575 ;; All articles have to be subsets of the active articles.
8577 ;; Adjust "simple" lists.
8578 ((memq mark '(tick dormant expirable reply killed save))
8580 (when (or (< (setq article (pop articles)) min) (> article max))
8581 (set var (delq article (symbol-value var))))))
8583 ((memq mark '(score bookmark))
8585 (when (or (< (car (setq article (pop articles))) min)
8586 (> (car article) max))
8587 (set var (delq article (symbol-value var))))))))))
8589 (defun gnus-update-missing-marks (missing)
8590 "Go through the list of MISSING articles and remove them mark lists."
8592 (let ((types gnus-article-mark-lists)
8594 ;; Go through all types.
8596 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8597 (when (symbol-value var)
8598 ;; This list has articles. So we delete all missing articles
8602 (set var (delq (pop m) (symbol-value var)))))))))
8604 (defun gnus-update-marks ()
8605 "Enter the various lists of marked articles into the newsgroup info list."
8606 (let ((types gnus-article-mark-lists)
8607 (info (gnus-get-info gnus-newsgroup-name))
8608 (uncompressed '(score bookmark killed))
8609 var type list newmarked symbol)
8611 ;; Add all marks lists that are non-nil to the list of marks lists.
8613 (setq type (pop types))
8614 (when (setq list (symbol-value
8616 (intern (format "gnus-newsgroup-%s"
8618 (push (cons (cdr type)
8619 (if (memq (cdr type) uncompressed) list
8620 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8623 ;; Enter these new marks into the info of the group.
8625 (setcar (nthcdr 3 info) newmarked)
8626 ;; Add the marks lists to the end of the info.
8628 (setcdr (nthcdr 2 info) (list newmarked))))
8630 ;; Cut off the end of the info if there's nothing else there.
8634 (when (nthcdr (decf i) info)
8635 (setcdr (nthcdr i info) nil)))))))
8637 (defun gnus-add-marked-articles (group type articles &optional info force)
8638 ;; Add ARTICLES of TYPE to the info of GROUP.
8639 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8640 ;; add, but replace marked articles of TYPE with ARTICLES.
8641 (let ((info (or info (gnus-get-info group)))
8642 (uncompressed '(score bookmark killed))
8645 (and (not (setq marked (nthcdr 3 info)))
8646 (setcdr (nthcdr 2 info)
8647 (list (list (cons type (gnus-compress-sequence
8649 (and (not (setq m (assq type (car marked))))
8651 (cons (cons type (gnus-compress-sequence articles t) )
8654 (setcdr m (gnus-compress-sequence articles t))
8655 (setcdr m (gnus-compress-sequence
8656 (sort (nconc (gnus-uncompress-range m)
8657 (copy-sequence articles)) '<) t))))))
8659 (defun gnus-set-mode-line (where)
8660 "This function sets the mode line of the article or summary buffers.
8661 If WHERE is `summary', the summary mode line format will be used."
8662 ;; Is this mode line one we keep updated?
8663 (when (memq where gnus-updated-mode-lines)
8666 ;; We evaluate this in the summary buffer since these
8667 ;; variables are buffer-local to that buffer.
8668 (set-buffer gnus-summary-buffer)
8669 ;; We bind all these variables that are used in the `eval' form
8671 (let* ((mformat (symbol-value
8673 (format "gnus-%s-mode-line-format-spec" where))))
8674 (gnus-tmp-group-name gnus-newsgroup-name)
8675 (gnus-tmp-article-number (or gnus-current-article 0))
8676 (gnus-tmp-unread gnus-newsgroup-unreads)
8677 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8678 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8679 (gnus-tmp-unread-and-unselected
8680 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8681 (zerop gnus-tmp-unselected)) "")
8682 ((zerop gnus-tmp-unselected)
8683 (format "{%d more}" gnus-tmp-unread-and-unticked))
8684 (t (format "{%d(+%d) more}"
8685 gnus-tmp-unread-and-unticked
8686 gnus-tmp-unselected))))
8688 (if (and gnus-current-headers
8689 (vectorp gnus-current-headers))
8690 (mail-header-subject gnus-current-headers) ""))
8692 gnus-tmp-header);; passed as argument to any user-format-funcs
8693 (setq mode-string (eval mformat))
8694 (setq max-len (max 4 (if gnus-mode-non-string-length
8696 gnus-mode-non-string-length)
8697 (length mode-string))))
8698 ;; We might have to chop a bit of the string off...
8699 (when (> (length mode-string) max-len)
8701 (concat (gnus-truncate-string mode-string (- max-len 3))
8703 ;; Pad the mode string a bit.
8704 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8705 ;; Update the mode line.
8706 (setq mode-line-buffer-identification (list mode-string))
8707 (set-buffer-modified-p t))))
8709 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8710 "Go through the HEADERS list and add all Xrefs to a hash table.
8711 The resulting hash table is returned, or nil if no Xrefs were found."
8712 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8713 (virtual (gnus-virtual-group-p from-newsgroup))
8714 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8715 (xref-hashtb (make-vector 63 0))
8716 start group entry number xrefs header)
8718 (setq header (pop headers))
8719 (when (and (setq xrefs (mail-header-xref header))
8720 (not (memq (setq number (mail-header-number header))
8723 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8724 (setq start (match-end 0))
8725 (setq group (concat prefix (substring xrefs (match-beginning 1)
8728 (string-to-int (substring xrefs (match-beginning 2)
8730 (if (setq entry (gnus-gethash group xref-hashtb))
8731 (setcdr entry (cons number (cdr entry)))
8732 (gnus-sethash group (cons number nil) xref-hashtb)))))
8733 (and start xref-hashtb)))
8735 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8736 "Look through all the headers and mark the Xrefs as read."
8737 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8738 name entry info xref-hashtb idlist method nth4)
8740 (set-buffer gnus-group-buffer)
8741 (when (setq xref-hashtb
8742 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8745 (unless (string= from-newsgroup (setq name (symbol-name group)))
8746 (setq idlist (symbol-value group))
8747 ;; Dead groups are not updated.
8749 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8751 (if (stringp (setq nth4 (gnus-info-method info)))
8752 (setq nth4 (gnus-server-to-method nth4))))
8753 ;; Only do the xrefs if the group has the same
8754 ;; select method as the group we have just read.
8755 (or (gnus-methods-equal-p
8756 nth4 (gnus-find-method-for-group from-newsgroup))
8758 (equal nth4 (setq method (gnus-find-method-for-group
8760 (and (equal (car nth4) (car method))
8761 (equal (nth 1 nth4) (nth 1 method))))
8762 gnus-use-cross-reference
8763 (or (not (eq gnus-use-cross-reference t))
8765 ;; Only do cross-references on subscribed
8766 ;; groups, if that is what is wanted.
8767 (<= (gnus-info-level info) gnus-level-subscribed))
8768 (gnus-group-make-articles-read name idlist))))
8771 (defun gnus-group-make-articles-read (group articles)
8773 (entry (gnus-gethash group gnus-newsrc-hashtb))
8774 (info (nth 2 entry))
8775 (active (gnus-active group))
8777 ;; First peel off all illegal article numbers.
8779 (let ((ids articles)
8783 (if (and first (> id (cdr active)))
8785 ;; We'll end up in this situation in one particular
8786 ;; obscure situation. If you re-scan a group and get
8787 ;; a new article that is cross-posted to a different
8788 ;; group that has not been re-scanned, you might get
8789 ;; crossposted article that has a higher number than
8790 ;; Gnus believes possible. So we re-activate this
8791 ;; group as well. This might mean doing the
8792 ;; crossposting thingy will *increase* the number
8793 ;; of articles in some groups. Tsk, tsk.
8794 (setq active (or (gnus-activate-group group) active))))
8795 (if (or (> id (cdr active))
8796 (< id (car active)))
8797 (setq articles (delq id articles)))
8798 (setq ids (cdr ids)))))
8799 ;; If the read list is nil, we init it.
8801 (null (gnus-info-read info))
8803 (gnus-info-set-read info (cons 1 (1- (car active)))))
8804 ;; Then we add the read articles to the range.
8809 (gnus-info-read info) (setq articles (sort articles '<)))))
8810 ;; Then we have to re-compute how many unread
8811 ;; articles there are in this group.
8816 (setq num (- (1+ (cdr active)) (car active))))
8817 ((not (listp (cdr range)))
8818 (setq num (- (cdr active) (- (1+ (cdr range))
8822 (if (numberp (car range))
8824 (setq num (+ num (- (1+ (cdr (car range)))
8825 (car (car range))))))
8826 (setq range (cdr range)))
8827 (setq num (- (cdr active) num))))
8828 ;; Update the number of unread articles.
8830 ;; Update the group buffer.
8831 (gnus-group-update-group group t)))))
8833 (defun gnus-methods-equal-p (m1 m2)
8834 (let ((m1 (or m1 gnus-select-method))
8835 (m2 (or m2 gnus-select-method)))
8837 (and (eq (car m1) (car m2))
8838 (or (not (memq 'address (assoc (symbol-name (car m1))
8839 gnus-valid-select-methods)))
8840 (equal (nth 1 m1) (nth 1 m2)))))))
8842 (defsubst gnus-header-value ()
8843 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8845 (defvar gnus-newsgroup-none-id 0)
8847 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8848 (let ((cur nntp-server-buffer)
8851 (save-excursion (set-buffer gnus-summary-buffer)
8852 gnus-newsgroup-dependencies)))
8853 headers id id-dep ref-dep end ref)
8855 (set-buffer nntp-server-buffer)
8856 (let ((case-fold-search t)
8857 in-reply-to header number p lines)
8858 (goto-char (point-min))
8859 ;; Search to the beginning of the next header. Error messages
8860 ;; do not begin with 2 or 3.
8861 (while (re-search-forward "^[23][0-9]+ " nil t)
8864 ;; This implementation of this function, with nine
8865 ;; search-forwards instead of the one re-search-forward and
8866 ;; a case (which basically was the old function) is actually
8867 ;; about twice as fast, even though it looks messier. You
8868 ;; can't have everything, I guess. Speed and elegance
8869 ;; doesn't always go hand in hand.
8878 (narrow-to-region (point)
8879 (or (and (search-forward "\n.\n" nil t)
8885 (if (search-forward "\nsubject: " nil t)
8886 (gnus-header-value) "(none)"))
8890 (if (search-forward "\nfrom: " nil t)
8891 (gnus-header-value) "(nobody)"))
8895 (if (search-forward "\ndate: " nil t)
8896 (gnus-header-value) ""))
8900 (if (search-forward "\nmessage-id: " nil t)
8901 (setq id (gnus-header-value))
8902 ;; If there was no message-id, we just fake one to make
8903 ;; subsequent routines simpler.
8904 (setq id (concat "none+"
8906 (setq gnus-newsgroup-none-id
8907 (1+ gnus-newsgroup-none-id)))))))
8911 (if (search-forward "\nreferences: " nil t)
8914 (setq end (match-end 0))
8921 (search-backward ">" end t)
8924 (search-backward "<" end t)
8926 ;; Get the references from the in-reply-to header if there
8927 ;; were no references and the in-reply-to header looks
8929 (if (and (search-forward "\nin-reply-to: " nil t)
8930 (setq in-reply-to (gnus-header-value))
8931 (string-match "<[^>]+>" in-reply-to))
8933 (setq ref (substring in-reply-to (match-beginning 0)
8935 (setq ref (downcase ref))))
8942 (if (search-forward "\nlines: " nil t)
8943 (if (numberp (setq lines (read cur)))
8949 (and (search-forward "\nxref: " nil t)
8950 (gnus-header-value)))))
8951 ;; We do the threading while we read the headers. The
8952 ;; message-id and the last reference are both entered into
8953 ;; the same hash table. Some tippy-toeing around has to be
8954 ;; done in case an article has arrived before the article
8955 ;; which it refers to.
8956 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8957 (if (and (car (symbol-value id-dep))
8959 ;; An article with this Message-ID has already
8960 ;; been seen, so we ignore this one, except we add
8961 ;; any additional Xrefs (in case the two articles
8962 ;; came from different servers).
8964 (mail-header-set-xref
8965 (car (symbol-value id-dep))
8966 (concat (or (mail-header-xref
8967 (car (symbol-value id-dep))) "")
8968 (or (mail-header-xref header) "")))
8970 (setcar (symbol-value id-dep) header))
8971 (set id-dep (list header)))
8973 (if (boundp (setq ref-dep (intern ref dependencies)))
8974 (setcdr (symbol-value ref-dep)
8975 (nconc (cdr (symbol-value ref-dep))
8976 (list (symbol-value id-dep))))
8977 (set ref-dep (list nil (symbol-value id-dep))))
8978 (setq headers (cons header headers)))
8979 (goto-char (point-max))
8981 (nreverse headers)))))
8983 ;; The following macros and functions were written by Felix Lee
8984 ;; <flee@cse.psu.edu>.
8986 (defmacro gnus-nov-read-integer ()
8988 (if (= (following-char) ?\t)
8990 (let ((num (condition-case nil (read buffer) (error nil))))
8991 (if (numberp num) num 0)))
8992 (or (eobp) (forward-char 1))))
8994 (defmacro gnus-nov-skip-field ()
8995 '(search-forward "\t" eol 'move))
8997 (defmacro gnus-nov-field ()
8998 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9000 ;; Goes through the xover lines and returns a list of vectors
9001 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9002 "Parse the news overview data in the server buffer, and return a
9003 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9004 ;; Get the Xref when the users reads the articles since most/some
9005 ;; NNTP servers do not include Xrefs when using XOVER.
9006 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9007 (let ((cur nntp-server-buffer)
9008 (dependencies gnus-newsgroup-dependencies)
9009 number headers header)
9011 (set-buffer nntp-server-buffer)
9012 ;; Allow the user to mangle the headers before parsing them.
9013 (run-hooks 'gnus-parse-headers-hook)
9014 ;; Allow the user to mangle the headers before parsing them.
9015 (run-hooks 'gnus-parse-headers-hook)
9016 (goto-char (point-min))
9017 (while (and sequence (not (eobp)))
9018 (setq number (read cur))
9019 (while (and sequence (< (car sequence) number))
9020 (setq sequence (cdr sequence)))
9022 (eq number (car sequence))
9024 (setq sequence (cdr sequence))
9026 (inline (gnus-nov-parse-line
9027 number dependencies force-new)))
9028 (setq headers (cons header headers)))))
9030 (setq headers (nreverse headers)))
9033 ;; This function has to be called with point after the article number
9034 ;; on the beginning of the line.
9035 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9037 (eol (gnus-point-at-eol))
9038 (buffer (current-buffer))
9039 header ref id id-dep ref-dep)
9041 ;; overview: [num subject from date id refs chars lines misc]
9042 (narrow-to-region (point) eol)
9043 (or (eobp) (forward-char))
9049 (gnus-nov-field) ; subject
9050 (gnus-nov-field) ; from
9051 (gnus-nov-field) ; date
9052 (setq id (or (gnus-nov-field)
9055 (setq none (1+ none)))))) ; id
9058 (let ((beg (point)))
9059 (search-forward "\t" eol)
9060 (if (search-backward ">" beg t)
9066 (search-backward "<" beg t)
9069 (gnus-nov-field)) ; refs
9070 (gnus-nov-read-integer) ; chars
9071 (gnus-nov-read-integer) ; lines
9072 (if (= (following-char) ?\n)
9074 (gnus-nov-field)) ; misc
9078 (gnus-message 4 "Strange nov line")
9084 ;; We build the thread tree.
9086 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9087 (if (and (car (symbol-value id-dep))
9089 ;; An article with this Message-ID has already been seen,
9090 ;; so we ignore this one, except we add any additional
9091 ;; Xrefs (in case the two articles came from different
9094 (mail-header-set-xref
9095 (car (symbol-value id-dep))
9096 (concat (or (mail-header-xref
9097 (car (symbol-value id-dep))) "")
9098 (or (mail-header-xref header) "")))
9100 (setcar (symbol-value id-dep) header))
9101 (set id-dep (list header))))
9104 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9105 (setcdr (symbol-value ref-dep)
9106 (nconc (cdr (symbol-value ref-dep))
9107 (list (symbol-value id-dep))))
9108 (set ref-dep (list nil (symbol-value id-dep))))))
9111 (defun gnus-article-get-xrefs ()
9112 "Fill in the Xref value in `gnus-current-headers', if necessary.
9113 This is meant to be called in `gnus-article-internal-prepare-hook'."
9114 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9115 gnus-current-headers)))
9116 (or (not gnus-use-cross-reference)
9118 (and (mail-header-xref headers)
9119 (not (string= (mail-header-xref headers) "")))
9120 (let ((case-fold-search t)
9123 (nnheader-narrow-to-headers)
9124 (goto-char (point-min))
9125 (if (or (and (eq (downcase (following-char)) ?x)
9126 (looking-at "Xref:"))
9127 (search-forward "\nXref:" nil t))
9129 (goto-char (1+ (match-end 0)))
9130 (setq xref (buffer-substring (point)
9131 (progn (end-of-line) (point))))
9132 (mail-header-set-xref headers xref))))))))
9134 (defun gnus-summary-insert-subject (id)
9135 "Find article ID and insert the summary line for that article."
9136 (let ((header (gnus-read-header id))
9137 (number (and (numberp id) id)))
9139 ;; Rebuild the thread that this article is part of and go to the
9140 ;; article we have fetched.
9141 (gnus-rebuild-thread (mail-header-id header))
9142 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9143 (when (and (numberp number)
9145 ;; We have to update the boundaries even if we can't fetch the
9146 ;; article if ID is a number -- so that the next `P' or `N'
9147 ;; command will fetch the previous (or next) article even
9148 ;; if the one we tried to fetch this time has been canceled.
9149 (and (> number gnus-newsgroup-end)
9150 (setq gnus-newsgroup-end number))
9151 (and (< number gnus-newsgroup-begin)
9152 (setq gnus-newsgroup-begin number))
9153 (setq gnus-newsgroup-unselected
9154 (delq number gnus-newsgroup-unselected)))
9155 ;; Report back a success?
9156 (and header number)))
9158 (defun gnus-summary-work-articles (n)
9159 "Return a list of articles to be worked upon. The prefix argument,
9160 the list of process marked articles, and the current article will be
9161 taken into consideration."
9163 ((and n (numberp n))
9164 ;; A numerical prefix has been given.
9165 (let ((backward (< n 0))
9171 (push (setq article (gnus-summary-article-number))
9174 (gnus-summary-find-prev nil article)
9175 (gnus-summary-find-next nil article)))
9177 (nreverse articles)))
9178 ((and (boundp 'transient-mark-mode)
9181 ;; Work on the region between point and mark.
9182 (let ((max (max (point) (mark)))
9185 (goto-char (min (point) (mark)))
9188 (push (setq article (gnus-summary-article-number)) articles)
9189 (gnus-summary-find-next nil article)
9191 (nreverse articles))))
9192 (gnus-newsgroup-processable
9193 ;; There are process-marked articles present.
9194 (reverse gnus-newsgroup-processable))
9196 ;; Just return the current article.
9197 (list (gnus-summary-article-number)))))
9199 (defun gnus-summary-search-group (&optional backward use-level)
9200 "Search for next unread newsgroup.
9201 If optional argument BACKWARD is non-nil, search backward instead."
9203 (set-buffer gnus-group-buffer)
9204 (if (gnus-group-search-forward
9205 backward nil (if use-level (gnus-group-group-level) nil))
9206 (gnus-group-group-name))))
9208 (defun gnus-summary-best-group (&optional exclude-group)
9209 "Find the name of the best unread group.
9210 If EXCLUDE-GROUP, do not go to this group."
9212 (set-buffer gnus-group-buffer)
9214 (gnus-group-best-unread-group exclude-group))))
9216 (defun gnus-summary-find-next (&optional unread article backward)
9217 (if backward (gnus-summary-find-prev)
9218 (let* ((article (or article (gnus-summary-article-number)))
9219 (arts (gnus-data-find-list article))
9221 (when (or (not gnus-summary-check-current)
9223 (not (gnus-data-unread-p (car arts))))
9224 (setq arts (cdr arts)))
9229 (when (gnus-data-unread-p (car arts))
9230 (setq result (car arts)
9232 (setq arts (cdr arts)))
9235 (goto-char (gnus-data-pos result))
9236 (gnus-data-number result)))))
9238 (defun gnus-summary-find-prev (&optional unread article)
9239 (let* ((article (or article (gnus-summary-article-number)))
9240 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9242 (when (or (not gnus-summary-check-current)
9244 (not (gnus-data-unread-p (car arts))))
9245 (setq arts (cdr arts)))
9250 (and (gnus-data-unread-p (car arts))
9251 (setq result (car arts)
9253 (setq arts (cdr arts)))
9257 (goto-char (gnus-data-pos result))
9258 (gnus-data-number result)))))
9260 (defun gnus-summary-find-subject (subject &optional unread backward article)
9261 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9262 (article (or article (gnus-summary-article-number)))
9263 (articles (gnus-data-list backward))
9264 (arts (gnus-data-find-list article articles))
9266 (when (or (not gnus-summary-check-current)
9268 (not (gnus-data-unread-p (car arts))))
9269 (setq arts (cdr arts)))
9271 (and (or (not unread)
9272 (gnus-data-unread-p (car arts)))
9273 (vectorp (gnus-data-header (car arts)))
9275 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9276 (setq result (car arts)
9278 (setq arts (cdr arts)))
9280 (goto-char (gnus-data-pos result))
9281 (gnus-data-number result))))
9283 (defun gnus-summary-search-forward (&optional unread subject backward)
9284 "Search forward for an article.
9285 If UNREAD, look for unread articles. If SUBJECT, look for
9286 articles with that subject. If BACKWARD, search backward instead."
9287 (cond (subject (gnus-summary-find-subject subject unread backward))
9288 (backward (gnus-summary-find-prev unread))
9289 (t (gnus-summary-find-next unread))))
9291 (defun gnus-recenter (&optional n)
9292 "Center point in window and redisplay frame.
9293 Also do horizontal recentering."
9295 (gnus-horizontal-recenter)
9298 (defun gnus-summary-recenter ()
9299 "Center point in the summary window.
9300 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9301 displayed, no centering will be performed."
9302 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9303 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9304 (let* ((top (cond ((< (window-height) 4) 0)
9305 ((< (window-height) 7) 1)
9307 (height (1- (window-height)))
9308 (bottom (save-excursion (goto-char (point-max))
9309 (forward-line (- height))
9311 (window (get-buffer-window (current-buffer))))
9312 ;; The user has to want it.
9313 (when gnus-auto-center-summary
9314 (when (get-buffer-window gnus-article-buffer)
9315 ;; Only do recentering when the article buffer is displayed,
9316 ;; Set the window start to either `bottom', which is the biggest
9317 ;; possible valid number, or the second line from the top,
9318 ;; whichever is the least.
9320 window (min bottom (save-excursion
9321 (forward-line (- top)) (point)))))
9322 ;; Do horizontal recentering while we're at it.
9323 (when (get-buffer-window (current-buffer) t)
9324 (let ((selected (selected-window)))
9325 (select-window (get-buffer-window (current-buffer) t))
9326 (gnus-summary-position-point)
9327 (gnus-horizontal-recenter)
9328 (select-window selected))))))
9330 (defun gnus-horizontal-recenter ()
9331 "Recenter the current buffer horizontally."
9332 (if (< (current-column) (/ (window-width) 2))
9333 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9334 (let* ((orig (point))
9335 (end (window-end (get-buffer-window (current-buffer) t)))
9337 ;; Find the longest line currently displayed in the window.
9338 (goto-char (window-start))
9339 (while (and (not (eobp))
9342 (setq max (max max (current-column)))
9345 ;; Scroll horizontally to center (sort of) the point.
9346 (if (> max (window-width))
9348 (get-buffer-window (current-buffer) t)
9349 (min (- (current-column) (/ (window-width) 3))
9350 (+ 2 (- max (window-width)))))
9351 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9354 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9355 (defun gnus-short-group-name (group &optional levels)
9356 "Collapse GROUP name LEVELS."
9363 (while (string-match "\\." group skip)
9364 (setq skip (match-end 0)
9367 (if (string-match ":" group)
9368 (setq foreign (substring group 0 (match-end 0))
9369 group (substring group (match-end 0))))
9371 (if (and (string-match "\\." group)
9372 (> levels (- gnus-group-uncollapsed-levels 1)))
9373 (setq name (concat name (substring group 0 1))
9374 group (substring group (match-end 0))
9376 name (concat name "."))
9377 (setq name (concat foreign name group)
9381 (defun gnus-summary-jump-to-group (newsgroup)
9382 "Move point to NEWSGROUP in group mode buffer."
9383 ;; Keep update point of group mode buffer if visible.
9384 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9385 (save-window-excursion
9386 ;; Take care of tree window mode.
9387 (if (get-buffer-window gnus-group-buffer)
9388 (pop-to-buffer gnus-group-buffer))
9389 (gnus-group-jump-to-group newsgroup))
9391 ;; Take care of tree window mode.
9392 (if (get-buffer-window gnus-group-buffer)
9393 (pop-to-buffer gnus-group-buffer)
9394 (set-buffer gnus-group-buffer))
9395 (gnus-group-jump-to-group newsgroup))))
9397 ;; This function returns a list of article numbers based on the
9398 ;; difference between the ranges of read articles in this group and
9399 ;; the range of active articles.
9400 (defun gnus-list-of-unread-articles (group)
9401 (let* ((read (gnus-info-read (gnus-get-info group)))
9402 (active (gnus-active group))
9405 ;; If none are read, then all are unread.
9407 (setq first (car active))
9408 ;; If the range of read articles is a single range, then the
9409 ;; first unread article is the article after the last read
9410 ;; article. Sounds logical, doesn't it?
9411 (if (not (listp (cdr read)))
9412 (setq first (1+ (cdr read)))
9413 ;; `read' is a list of ranges.
9414 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9415 (car (car read)))) 1)
9419 (while (< first nlast)
9420 (setq unread (cons first unread))
9421 (setq first (1+ first))))
9422 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9423 (setq nlast (if (atom (car (cdr read)))
9425 (car (car (cdr read)))))
9426 (setq read (cdr read)))))
9427 ;; And add the last unread articles.
9428 (while (<= first last)
9429 (setq unread (cons first unread))
9430 (setq first (1+ first)))
9431 ;; Return the list of unread articles.
9434 (defun gnus-list-of-read-articles (group)
9435 "Return a list of unread, unticked and non-dormant articles."
9436 (let* ((info (gnus-get-info group))
9437 (marked (gnus-info-marks info))
9438 (active (gnus-active group)))
9440 (gnus-set-difference
9441 (gnus-sorted-complement
9442 (gnus-uncompress-range active)
9443 (gnus-list-of-unread-articles group))
9445 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9446 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9448 ;; Various summary commands
9450 (defun gnus-summary-universal-argument (arg)
9451 "Perform any operation on all articles that are process/prefixed."
9453 (gnus-set-global-variables)
9454 (let ((articles (gnus-summary-work-articles arg))
9461 (substitute-command-keys
9462 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9466 (message "Undefined key")
9470 (gnus-summary-goto-subject (setq article (pop articles)))
9471 (command-execute func)
9472 (gnus-summary-remove-process-mark article)))))
9473 (gnus-summary-position-point))
9475 (defun gnus-summary-toggle-truncation (&optional arg)
9476 "Toggle truncation of summary lines.
9477 With arg, turn line truncation on iff arg is positive."
9479 (setq truncate-lines
9480 (if (null arg) (not truncate-lines)
9481 (> (prefix-numeric-value arg) 0)))
9484 (defun gnus-summary-reselect-current-group (&optional all rescan)
9485 "Exit and then reselect the current newsgroup.
9486 The prefix argument ALL means to select all articles."
9488 (gnus-set-global-variables)
9489 (let ((current-subject (gnus-summary-article-number))
9490 (group gnus-newsgroup-name))
9491 (setq gnus-newsgroup-begin nil)
9493 ;; We have to adjust the point of group mode buffer because the
9494 ;; current point was moved to the next unread newsgroup by
9496 (gnus-summary-jump-to-group group)
9499 (gnus-group-get-new-news-this-group 1)))
9500 (gnus-group-read-group all t)
9501 (gnus-summary-goto-subject current-subject)))
9503 (defun gnus-summary-rescan-group (&optional all)
9504 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9506 (gnus-summary-reselect-current-group all t))
9508 (defun gnus-summary-update-info ()
9509 (let* ((group gnus-newsgroup-name))
9510 (when gnus-newsgroup-kill-headers
9511 (setq gnus-newsgroup-killed
9512 (gnus-compress-sequence
9514 (gnus-set-sorted-intersection
9515 (gnus-uncompress-range gnus-newsgroup-killed)
9516 (setq gnus-newsgroup-unselected
9517 (sort gnus-newsgroup-unselected '<)))
9518 (setq gnus-newsgroup-unreads
9519 (sort gnus-newsgroup-unreads '<))) t)))
9520 (unless (listp (cdr gnus-newsgroup-killed))
9521 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9522 (let ((headers gnus-newsgroup-headers))
9523 (gnus-close-group group)
9524 (run-hooks 'gnus-exit-group-hook)
9525 (unless gnus-save-score
9526 (setq gnus-newsgroup-scored nil))
9527 ;; Set the new ranges of read articles.
9528 (gnus-update-read-articles
9529 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9530 ;; Set the current article marks.
9532 ;; Do the cross-ref thing.
9533 (when gnus-use-cross-reference
9534 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9535 ;; Do adaptive scoring, and possibly save score files.
9536 (when gnus-newsgroup-adaptive
9537 (gnus-score-adaptive))
9538 (when gnus-use-scoring
9540 ;; Do not switch windows but change the buffer to work.
9541 (set-buffer gnus-group-buffer)
9542 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9543 (gnus-group-update-group group)))))
9545 (defun gnus-summary-exit (&optional temporary)
9546 "Exit reading current newsgroup, and then return to group selection mode.
9547 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9549 (gnus-set-global-variables)
9550 (gnus-kill-save-kill-buffer)
9551 (let* ((group gnus-newsgroup-name)
9552 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9554 (buf (current-buffer)))
9555 (run-hooks 'gnus-summary-prepare-exit-hook)
9556 ;; If we have several article buffers, we kill them at exit.
9557 (unless gnus-single-article-buffer
9558 (gnus-kill-buffer gnus-article-buffer)
9559 (gnus-kill-buffer gnus-original-article-buffer))
9560 (when gnus-use-cache
9561 (gnus-cache-possibly-remove-articles)
9562 (gnus-cache-save-buffers))
9563 (when gnus-use-trees
9564 (gnus-tree-close group))
9565 ;; Make all changes in this group permanent.
9567 (gnus-summary-update-info))
9568 ;; Make sure where I was, and go to next newsgroup.
9569 (set-buffer gnus-group-buffer)
9571 (gnus-group-jump-to-group group)
9572 (gnus-group-next-unread-group 1))
9573 (run-hooks 'gnus-summary-exit-hook)
9576 ;; If we have several article buffers, we kill them at exit.
9577 (unless gnus-single-article-buffer
9578 (gnus-kill-buffer gnus-article-buffer)
9579 (gnus-kill-buffer gnus-original-article-buffer))
9581 (if (not gnus-kill-summary-on-exit)
9582 (gnus-deaden-summary)
9583 ;; We set all buffer-local variables to nil. It is unclear why
9584 ;; this is needed, but if we don't, buffer-local variables are
9585 ;; not garbage-collected, it seems. This would the lead to en
9586 ;; ever-growing Emacs.
9587 (gnus-summary-clear-local-variables)
9588 (when (get-buffer gnus-article-buffer)
9589 (bury-buffer gnus-article-buffer))
9590 ;; We clear the global counterparts of the buffer-local
9591 ;; variables as well, just to be on the safe side.
9592 (gnus-configure-windows 'group 'force)
9593 (gnus-summary-clear-local-variables)
9594 ;; Return to group mode buffer.
9595 (if (eq mode 'gnus-summary-mode)
9596 (gnus-kill-buffer buf)))
9597 (setq gnus-current-select-method gnus-select-method)
9598 (pop-to-buffer gnus-group-buffer)
9599 ;; Clear the current group name.
9600 (if (not quit-config)
9602 (gnus-group-jump-to-group group)
9603 (gnus-group-next-unread-group 1)
9604 (gnus-configure-windows 'group 'force))
9605 (if (not (buffer-name (car quit-config)))
9606 (gnus-configure-windows 'group 'force)
9607 (set-buffer (car quit-config))
9608 (and (eq major-mode 'gnus-summary-mode)
9609 (gnus-set-global-variables))
9610 (gnus-configure-windows (cdr quit-config))))
9612 (setq gnus-newsgroup-name nil)))))
9614 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9615 (defun gnus-summary-exit-no-update (&optional no-questions)
9616 "Quit reading current newsgroup without updating read article info."
9618 (gnus-set-global-variables)
9619 (let* ((group gnus-newsgroup-name)
9620 (quit-config (gnus-group-quit-config group)))
9621 (when (or no-questions
9623 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9624 ;; If we have several article buffers, we kill them at exit.
9625 (unless gnus-single-article-buffer
9626 (gnus-kill-buffer gnus-article-buffer)
9627 (gnus-kill-buffer gnus-original-article-buffer))
9628 (if (not gnus-kill-summary-on-exit)
9629 (gnus-deaden-summary)
9630 (gnus-close-group group)
9631 (gnus-summary-clear-local-variables)
9632 (set-buffer gnus-group-buffer)
9633 (gnus-summary-clear-local-variables)
9634 (when (get-buffer gnus-summary-buffer)
9635 (kill-buffer gnus-summary-buffer)))
9636 (when gnus-use-trees
9637 (gnus-tree-close group))
9638 (when (get-buffer gnus-article-buffer)
9639 (bury-buffer gnus-article-buffer))
9640 ;; Return to the group buffer.
9641 (gnus-configure-windows 'group 'force)
9642 ;; Clear the current group name.
9643 (setq gnus-newsgroup-name nil)
9644 (when (equal (gnus-group-group-name) group)
9645 (gnus-group-next-unread-group 1))
9647 (if (not (buffer-name (car quit-config)))
9648 (gnus-configure-windows 'group 'force)
9649 (set-buffer (car quit-config))
9650 (when (eq major-mode 'gnus-summary-mode)
9651 (gnus-set-global-variables))
9652 (gnus-configure-windows (cdr quit-config)))))))
9656 (defvar gnus-dead-summary-mode-map nil)
9658 (if gnus-dead-summary-mode-map
9660 (setq gnus-dead-summary-mode-map (make-keymap))
9661 (suppress-keymap gnus-dead-summary-mode-map)
9662 (substitute-key-definition
9663 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9664 (let ((keys '("\C-d" "\r" "\177")))
9666 (define-key gnus-dead-summary-mode-map
9667 (pop keys) 'gnus-summary-wake-up-the-dead))))
9669 (defvar gnus-dead-summary-mode nil
9670 "Minor mode for Gnus summary buffers.")
9672 (defun gnus-dead-summary-mode (&optional arg)
9673 "Minor mode for Gnus summary buffers."
9675 (when (eq major-mode 'gnus-summary-mode)
9676 (make-local-variable 'gnus-dead-summary-mode)
9677 (setq gnus-dead-summary-mode
9678 (if (null arg) (not gnus-dead-summary-mode)
9679 (> (prefix-numeric-value arg) 0)))
9680 (when gnus-dead-summary-mode
9681 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9682 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9683 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9684 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9685 minor-mode-map-alist)))))
9687 (defun gnus-deaden-summary ()
9688 "Make the current summary buffer into a dead summary buffer."
9689 ;; Kill any previous dead summary buffer.
9690 (when (and gnus-dead-summary
9691 (buffer-name gnus-dead-summary))
9693 (set-buffer gnus-dead-summary)
9694 (when gnus-dead-summary-mode
9695 (kill-buffer (current-buffer)))))
9696 ;; Make this the current dead summary.
9697 (setq gnus-dead-summary (current-buffer))
9698 (gnus-dead-summary-mode 1)
9699 (let ((name (buffer-name)))
9700 (when (string-match "Summary" name)
9702 (concat (substring name 0 (match-beginning 0)) "Dead "
9703 (substring name (match-beginning 0))) t))))
9705 (defun gnus-kill-or-deaden-summary (buffer)
9706 "Kill or deaden the summary BUFFER."
9707 (cond (gnus-kill-summary-on-exit
9708 (when (and gnus-use-trees
9709 (and (get-buffer buffer)
9710 (buffer-name (get-buffer buffer))))
9712 (set-buffer (get-buffer buffer))
9713 (gnus-tree-close gnus-newsgroup-name)))
9714 (gnus-kill-buffer buffer))
9715 ((and (get-buffer buffer)
9716 (buffer-name (get-buffer buffer)))
9719 (gnus-deaden-summary)))))
9721 (defun gnus-summary-wake-up-the-dead (&rest args)
9722 "Wake up the dead summary buffer."
9724 (gnus-dead-summary-mode -1)
9725 (let ((name (buffer-name)))
9726 (when (string-match "Dead " name)
9728 (concat (substring name 0 (match-beginning 0))
9729 (substring name (match-end 0))) t)))
9730 (gnus-message 3 "This dead summary is now alive again"))
9732 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9733 (defun gnus-summary-fetch-faq (&optional faq-dir)
9734 "Fetch the FAQ for the current group.
9735 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9739 (if current-prefix-arg
9741 "Faq dir: " (and (listp gnus-group-faq-directory)
9742 gnus-group-faq-directory)))))
9743 (let (gnus-faq-buffer)
9744 (and (setq gnus-faq-buffer
9745 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9746 (gnus-configure-windows 'summary-faq))))
9748 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9749 (defun gnus-summary-describe-group (&optional force)
9750 "Describe the current newsgroup."
9752 (gnus-group-describe-group force gnus-newsgroup-name))
9754 (defun gnus-summary-describe-briefly ()
9755 "Describe summary mode commands briefly."
9758 (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")))
9760 ;; Walking around group mode buffer from summary mode.
9762 (defun gnus-summary-next-group (&optional no-article target-group backward)
9763 "Exit current newsgroup and then select next unread newsgroup.
9764 If prefix argument NO-ARTICLE is non-nil, no article is selected
9765 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9766 previous group instead."
9768 (gnus-set-global-variables)
9769 (let ((current-group gnus-newsgroup-name)
9770 (current-buffer (current-buffer))
9772 ;; First we semi-exit this group to update Xrefs and all variables.
9773 ;; We can't do a real exit, because the window conf must remain
9774 ;; the same in case the user is prompted for info, and we don't
9775 ;; want the window conf to change before that...
9776 (gnus-summary-exit t)
9777 (while (not entered)
9778 ;; Then we find what group we are supposed to enter.
9779 (set-buffer gnus-group-buffer)
9780 (gnus-group-jump-to-group current-group)
9783 (if (eq gnus-keep-same-level 'best)
9784 (gnus-summary-best-group gnus-newsgroup-name)
9785 (gnus-summary-search-group backward gnus-keep-same-level))))
9786 (if (not target-group)
9787 ;; There are no further groups, so we return to the group
9790 (gnus-message 5 "Returning to the group buffer")
9792 (set-buffer current-buffer)
9793 (gnus-summary-exit))
9794 ;; We try to enter the target group.
9795 (gnus-group-jump-to-group target-group)
9796 (let ((unreads (gnus-group-group-unread)))
9797 (if (and (or (eq t unreads)
9798 (and unreads (not (zerop unreads))))
9799 (gnus-summary-read-group
9800 target-group nil no-article current-buffer))
9802 (setq current-group target-group
9803 target-group nil)))))))
9805 (defun gnus-summary-prev-group (&optional no-article)
9806 "Exit current newsgroup and then select previous unread newsgroup.
9807 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9809 (gnus-summary-next-group no-article nil t))
9811 ;; Walking around summary lines.
9813 (defun gnus-summary-first-subject (&optional unread)
9814 "Go to the first unread subject.
9815 If UNREAD is non-nil, go to the first unread article.
9816 Returns the article selected or nil if there are no unread articles."
9821 ((null gnus-newsgroup-data)
9822 (gnus-message 3 "No articles in the group")
9824 ;; Pick the first article.
9826 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9827 (gnus-data-number (car gnus-newsgroup-data)))
9828 ;; No unread articles.
9829 ((null gnus-newsgroup-unreads)
9830 (gnus-message 3 "No more unread articles")
9832 ;; Find the first unread article.
9834 (let ((data gnus-newsgroup-data))
9836 (not (gnus-data-unread-p (car data))))
9837 (setq data (cdr data)))
9840 (goto-char (gnus-data-pos (car data)))
9841 (gnus-data-number (car data)))))))
9842 (gnus-summary-position-point)))
9844 (defun gnus-summary-next-subject (n &optional unread dont-display)
9845 "Go to next N'th summary line.
9846 If N is negative, go to the previous N'th subject line.
9847 If UNREAD is non-nil, only unread articles are selected.
9848 The difference between N and the actual number of steps taken is
9851 (let ((backward (< n 0))
9855 (gnus-summary-find-prev unread)
9856 (gnus-summary-find-next unread)))
9858 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9859 (if unread " unread" "")))
9862 (gnus-summary-recenter)
9863 (gnus-summary-position-point)))
9866 (defun gnus-summary-next-unread-subject (n)
9867 "Go to next N'th unread summary line."
9869 (gnus-summary-next-subject n t))
9871 (defun gnus-summary-prev-subject (n &optional unread)
9872 "Go to previous N'th summary line.
9873 If optional argument UNREAD is non-nil, only unread article is selected."
9875 (gnus-summary-next-subject (- n) unread))
9877 (defun gnus-summary-prev-unread-subject (n)
9878 "Go to previous N'th unread summary line."
9880 (gnus-summary-next-subject (- n) t))
9882 (defun gnus-summary-goto-subject (article &optional force silent)
9883 "Go the subject line of ARTICLE.
9884 If FORCE, also allow jumping to articles not currently shown."
9886 (data (gnus-data-find article)))
9887 ;; We read in the article if we have to.
9890 (gnus-summary-insert-subject article)
9891 (setq data (gnus-data-find article)))
9896 (gnus-message 3 "Can't find article %d" article))
9898 (goto-char (gnus-data-pos data))
9901 ;; Walking around summary lines with displaying articles.
9903 (defun gnus-summary-expand-window (&optional arg)
9904 "Make the summary buffer take up the entire Emacs frame.
9905 Given a prefix, will force an `article' buffer configuration."
9907 (gnus-set-global-variables)
9909 (gnus-configure-windows 'article 'force)
9910 (gnus-configure-windows 'summary 'force)))
9912 (defun gnus-summary-display-article (article &optional all-header)
9913 "Display ARTICLE in article buffer."
9914 (gnus-set-global-variables)
9918 (if gnus-summary-display-article-function
9919 (funcall gnus-summary-display-article-function article all-header)
9920 (gnus-article-prepare article all-header))
9921 (run-hooks 'gnus-select-article-hook)
9922 (gnus-summary-recenter)
9923 (gnus-summary-goto-subject article)
9924 (when gnus-use-trees
9925 (gnus-possibly-generate-tree article)
9926 (gnus-highlight-selected-tree article))
9927 ;; Successfully display article.
9928 (gnus-article-set-window-start
9929 (cdr (assq article gnus-newsgroup-bookmarks)))
9932 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9933 "Select the current article.
9934 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9935 non-nil, the article will be re-fetched even if it already present in
9936 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9938 (let ((article (or article (gnus-summary-article-number)))
9939 (all-headers (not (not all-headers))) ;Must be T or NIL.
9940 gnus-summary-display-article-function
9943 (gnus-summary-article-pseudo-p article)
9944 (error "This is a pseudo-article."))
9947 (set-buffer gnus-summary-buffer)
9948 (if (or (and gnus-single-article-buffer
9949 (or (null gnus-current-article)
9950 (null gnus-article-current)
9951 (null (get-buffer gnus-article-buffer))
9952 (not (eq article (cdr gnus-article-current)))
9953 (not (equal (car gnus-article-current)
9954 gnus-newsgroup-name))))
9955 (and (not gnus-single-article-buffer)
9956 (null gnus-current-article))
9958 ;; The requested article is different from the current article.
9960 (gnus-summary-display-article article all-headers)
9962 (if (or all-headers gnus-show-all-headers)
9963 (gnus-article-show-all-headers))
9966 (gnus-article-set-window-start
9967 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9969 (defun gnus-summary-set-current-mark (&optional current-mark)
9970 "Obsolete function."
9973 (defun gnus-summary-next-article (&optional unread subject backward push)
9974 "Select the next article.
9975 If UNREAD, only unread articles are selected.
9976 If SUBJECT, only articles with SUBJECT are selected.
9977 If BACKWARD, the previous article is selected instead of the next."
9979 (gnus-set-global-variables)
9982 ;; Is there such an article?
9983 ((and (gnus-summary-search-forward unread subject backward)
9984 (or (gnus-summary-display-article (gnus-summary-article-number))
9985 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9986 (gnus-summary-position-point))
9987 ;; If not, we try the first unread, if that is wanted.
9989 gnus-auto-select-same
9990 (or (gnus-summary-first-unread-article)
9991 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9992 (gnus-summary-position-point)
9993 (gnus-message 6 "Wrapped"))
9994 ;; Try to get next/previous article not displayed in this group.
9995 ((and gnus-auto-extend-newsgroup
9996 (not unread) (not subject))
9997 (gnus-summary-goto-article
9998 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10000 ;; Go to next/previous group.
10002 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10003 (gnus-summary-jump-to-group gnus-newsgroup-name))
10004 (let ((cmd last-command-char)
10006 (if (eq gnus-keep-same-level 'best)
10007 (gnus-summary-best-group gnus-newsgroup-name)
10008 (gnus-summary-search-group backward gnus-keep-same-level))))
10009 ;; For some reason, the group window gets selected. We change
10011 (select-window (get-buffer-window (current-buffer)))
10012 ;; Select next unread newsgroup automagically.
10014 ((not gnus-auto-select-next)
10015 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10016 ((or (eq gnus-auto-select-next 'quietly)
10017 (and (eq gnus-auto-select-next 'slightly-quietly)
10019 (and (eq gnus-auto-select-next 'almost-quietly)
10020 (gnus-summary-last-article-p)))
10022 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10023 (gnus-summary-exit)
10024 (gnus-message 7 "No more%s articles (%s)..."
10025 (if unread " unread" "")
10026 (if group (concat "selecting " group)
10028 (gnus-summary-next-group nil group backward)))
10030 (gnus-summary-walk-group-buffer
10031 gnus-newsgroup-name cmd unread backward))))))))
10033 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10034 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10035 (?\C-p (gnus-group-prev-unread-group 1))))
10036 keve key group ended)
10038 (set-buffer gnus-group-buffer)
10039 (gnus-summary-jump-to-group from-group)
10041 (if (eq gnus-keep-same-level 'best)
10042 (gnus-summary-best-group gnus-newsgroup-name)
10043 (gnus-summary-search-group backward gnus-keep-same-level))))
10046 5 "No more%s articles%s" (if unread " unread" "")
10048 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10049 (format " (Type %s for %s [%s])"
10050 (single-key-description cmd) group
10051 (car (gnus-gethash group gnus-newsrc-hashtb)))
10052 (format " (Type %s to exit %s)"
10053 (single-key-description cmd)
10054 gnus-newsgroup-name)))
10055 ;; Confirm auto selection.
10056 (setq key (car (setq keve (gnus-read-event-char))))
10059 ((assq key keystrokes)
10060 (let ((obuf (current-buffer)))
10061 (switch-to-buffer gnus-group-buffer)
10063 (gnus-group-jump-to-group group))
10064 (eval (car (cdr (assq key keystrokes))))
10065 (setq group (gnus-group-group-name))
10066 (switch-to-buffer obuf))
10069 (if (or (not group)
10070 (gnus-ephemeral-group-p gnus-newsgroup-name))
10071 (gnus-summary-exit)
10072 (gnus-summary-next-group nil group backward)))
10074 (push (cdr keve) unread-command-events))))))
10076 (defun gnus-read-event-char ()
10077 "Get the next event."
10078 (let ((event (read-event)))
10079 (cons (and (numberp event) event) event)))
10081 (defun gnus-summary-next-unread-article ()
10082 "Select unread article after current one."
10084 (gnus-summary-next-article t (and gnus-auto-select-same
10085 (gnus-summary-article-subject))))
10087 (defun gnus-summary-prev-article (&optional unread subject)
10088 "Select the article after the current one.
10089 If UNREAD is non-nil, only unread articles are selected."
10091 (gnus-summary-next-article unread subject t))
10093 (defun gnus-summary-prev-unread-article ()
10094 "Select unred article before current one."
10096 (gnus-summary-prev-article t (and gnus-auto-select-same
10097 (gnus-summary-article-subject))))
10099 (defun gnus-summary-next-page (&optional lines circular)
10100 "Show next page of the selected article.
10101 If at the end of the current article, select the next article.
10102 LINES says how many lines should be scrolled up.
10104 If CIRCULAR is non-nil, go to the start of the article instead of
10105 selecting the next article when reaching the end of the current
10108 (setq gnus-summary-buffer (current-buffer))
10109 (gnus-set-global-variables)
10110 (let ((article (gnus-summary-article-number))
10112 (gnus-configure-windows 'article)
10113 (if (or (null gnus-current-article)
10114 (null gnus-article-current)
10115 (/= article (cdr gnus-article-current))
10116 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10117 ;; Selected subject is different from current article's.
10118 (gnus-summary-display-article article)
10119 (gnus-eval-in-buffer-window
10120 gnus-article-buffer
10121 (setq endp (gnus-article-next-page lines)))
10124 (gnus-summary-beginning-of-article))
10126 (gnus-message 3 "End of message"))
10128 (if (and (eq gnus-summary-goto-unread 'never)
10129 (not (eq article gnus-newsgroup-end)))
10130 (gnus-summary-next-article)
10131 (gnus-summary-next-unread-article))))))
10132 (gnus-summary-recenter)
10133 (gnus-summary-position-point)))
10135 (defun gnus-summary-prev-page (&optional lines)
10136 "Show previous page of selected article.
10137 Argument LINES specifies lines to be scrolled down."
10139 (gnus-set-global-variables)
10140 (let ((article (gnus-summary-article-number)))
10141 (gnus-configure-windows 'article)
10142 (if (or (null gnus-current-article)
10143 (null gnus-article-current)
10144 (/= article (cdr gnus-article-current))
10145 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10146 ;; Selected subject is different from current article's.
10147 (gnus-summary-display-article article)
10148 (gnus-summary-recenter)
10149 (gnus-eval-in-buffer-window gnus-article-buffer
10150 (gnus-article-prev-page lines))))
10151 (gnus-summary-position-point))
10153 (defun gnus-summary-scroll-up (lines)
10154 "Scroll up (or down) one line current article.
10155 Argument LINES specifies lines to be scrolled up (or down if negative)."
10157 (gnus-set-global-variables)
10158 (gnus-configure-windows 'article)
10159 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10160 (gnus-eval-in-buffer-window
10161 gnus-article-buffer
10163 (if (gnus-article-next-page lines)
10164 (gnus-message 3 "End of message")))
10166 (gnus-article-prev-page (- lines))))))
10167 (gnus-summary-recenter)
10168 (gnus-summary-position-point))
10170 (defun gnus-summary-next-same-subject ()
10171 "Select next article which has the same subject as current one."
10173 (gnus-set-global-variables)
10174 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10176 (defun gnus-summary-prev-same-subject ()
10177 "Select previous article which has the same subject as current one."
10179 (gnus-set-global-variables)
10180 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10182 (defun gnus-summary-next-unread-same-subject ()
10183 "Select next unread article which has the same subject as current one."
10185 (gnus-set-global-variables)
10186 (gnus-summary-next-article t (gnus-summary-article-subject)))
10188 (defun gnus-summary-prev-unread-same-subject ()
10189 "Select previous unread article which has the same subject as current one."
10191 (gnus-set-global-variables)
10192 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10194 (defun gnus-summary-first-unread-article ()
10195 "Select the first unread article.
10196 Return nil if there are no unread articles."
10198 (gnus-set-global-variables)
10200 (if (gnus-summary-first-subject t)
10202 (gnus-summary-show-thread)
10203 (gnus-summary-first-subject t)
10204 (gnus-summary-display-article (gnus-summary-article-number))))
10205 (gnus-summary-position-point)))
10207 (defun gnus-summary-best-unread-article ()
10208 "Select the unread article with the highest score."
10210 (gnus-set-global-variables)
10211 (let ((best -1000000)
10212 (data gnus-newsgroup-data)
10215 (and (gnus-data-unread-p (car data))
10217 (gnus-summary-article-score (gnus-data-number (car data))))
10220 article (gnus-data-number (car data))))
10221 (setq data (cdr data)))
10223 (gnus-summary-goto-article article)
10224 (error "No unread articles"))
10225 (gnus-summary-position-point)))
10227 (defun gnus-summary-last-subject ()
10228 "Go to the last displayed subject line in the group."
10229 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10231 (gnus-summary-goto-subject article))))
10233 (defun gnus-summary-goto-article (article &optional all-headers force)
10234 "Fetch ARTICLE and display it if it exists.
10235 If ALL-HEADERS is non-nil, no header lines are hidden."
10241 (mapcar (lambda (number) (list (int-to-string number)))
10242 gnus-newsgroup-limit)))
10246 (if (gnus-summary-goto-subject article force)
10247 (gnus-summary-display-article article all-headers)
10248 (gnus-message 4 "Couldn't go to article %s" article) nil)
10249 (gnus-summary-position-point)))
10251 (defun gnus-summary-goto-last-article ()
10252 "Go to the previously read article."
10255 (and gnus-last-article
10256 (gnus-summary-goto-article gnus-last-article))
10257 (gnus-summary-position-point)))
10259 (defun gnus-summary-pop-article (number)
10260 "Pop one article off the history and go to the previous.
10261 NUMBER articles will be popped off."
10264 (setq gnus-newsgroup-history
10265 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10267 (gnus-summary-goto-article (car to))
10268 (error "Article history empty")))
10269 (gnus-summary-position-point))
10271 ;; Summary commands and functions for limiting the summary buffer.
10273 (defun gnus-summary-limit-to-articles (n)
10274 "Limit the summary buffer to the next N articles.
10275 If not given a prefix, use the process marked articles instead."
10277 (gnus-set-global-variables)
10279 (let ((articles (gnus-summary-work-articles n)))
10280 (setq gnus-newsgroup-processable nil)
10281 (gnus-summary-limit articles))
10282 (gnus-summary-position-point)))
10284 (defun gnus-summary-pop-limit (&optional total)
10285 "Restore the previous limit.
10286 If given a prefix, remove all limits."
10288 (gnus-set-global-variables)
10290 (setq gnus-newsgroup-limits
10291 (list (mapcar (lambda (h) (mail-header-number h))
10292 gnus-newsgroup-headers))))
10293 (unless gnus-newsgroup-limits
10294 (error "No limit to pop"))
10296 (gnus-summary-limit nil 'pop)
10297 (gnus-summary-position-point)))
10299 (defun gnus-summary-limit-to-subject (subject &optional header)
10300 "Limit the summary buffer to articles that have subjects that match a regexp."
10301 (interactive "sRegexp: ")
10303 (setq header "subject"))
10304 (when (not (equal "" subject))
10306 (let ((articles (gnus-summary-find-matching
10307 (or header "subject") subject 'all)))
10308 (or articles (error "Found no matches for \"%s\"" subject))
10309 (gnus-summary-limit articles))
10310 (gnus-summary-position-point))))
10312 (defun gnus-summary-limit-to-author (from)
10313 "Limit the summary buffer to articles that have authors that match a regexp."
10314 (interactive "sRegexp: ")
10315 (gnus-summary-limit-to-subject from "from"))
10317 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10319 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10321 (defun gnus-summary-limit-to-unread (&optional all)
10322 "Limit the summary buffer to articles that are not marked as read.
10323 If ALL is non-nil, limit strictly to unread articles."
10326 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10327 (gnus-summary-limit-to-marks
10328 ;; Concat all the marks that say that an article is read and have
10330 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10331 gnus-killed-mark gnus-kill-file-mark
10332 gnus-low-score-mark gnus-expirable-mark
10333 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10336 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10337 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10339 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10340 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10341 If REVERSE, limit the summary buffer to articles that are not marked
10342 with MARKS. MARKS can either be a string of marks or a list of marks.
10343 Returns how many articles were removed."
10344 (interactive "sMarks: ")
10345 (gnus-set-global-variables)
10347 (let ((data gnus-newsgroup-data)
10348 (marks (if (listp marks) marks
10349 (append marks nil))) ; Transform to list.
10352 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10353 (memq (gnus-data-mark (car data)) marks))
10354 (setq articles (cons (gnus-data-number (car data)) articles)))
10355 (setq data (cdr data)))
10356 (gnus-summary-limit articles))
10357 (gnus-summary-position-point)))
10359 (defun gnus-summary-limit-to-score (&optional score)
10360 "Limit to articles with score at or above SCORE."
10362 (gnus-set-global-variables)
10363 (setq score (if score
10364 (prefix-numeric-value score)
10365 (or gnus-summary-default-score 0)))
10366 (let ((data gnus-newsgroup-data)
10369 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10371 (push (gnus-data-number (car data)) articles))
10372 (setq data (cdr data)))
10374 (gnus-summary-limit articles)
10375 (gnus-summary-position-point))))
10377 (defun gnus-summary-limit-include-dormant ()
10378 "Display all the hidden articles that are marked as dormant."
10380 (gnus-set-global-variables)
10381 (or gnus-newsgroup-dormant
10382 (error "There are no dormant articles in this group"))
10384 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10385 (gnus-summary-position-point)))
10387 (defun gnus-summary-limit-exclude-dormant ()
10388 "Hide all dormant articles."
10390 (gnus-set-global-variables)
10392 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10393 (gnus-summary-position-point)))
10395 (defun gnus-summary-limit-exclude-childless-dormant ()
10396 "Hide all dormant articles that have no children."
10398 (gnus-set-global-variables)
10399 (let ((data (gnus-data-list t))
10400 articles d children)
10401 ;; Find all articles that are either not dormant or have
10403 (while (setq d (pop data))
10404 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10405 (and (setq children
10406 (gnus-article-children (gnus-data-number d)))
10409 (when (memq (car children) articles)
10414 (push (gnus-data-number d) articles)))
10415 ;; Do the limiting.
10417 (gnus-summary-limit articles)
10418 (gnus-summary-position-point))))
10420 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10421 "Mark all unread excluded articles as read.
10422 If ALL, mark even excluded ticked and dormants as read."
10424 (let ((articles (gnus-sorted-complement
10426 (mapcar (lambda (h) (mail-header-number h))
10427 gnus-newsgroup-headers)
10429 (sort gnus-newsgroup-limit '<)))
10431 (setq gnus-newsgroup-unreads nil)
10433 (setq gnus-newsgroup-dormant nil
10434 gnus-newsgroup-marked nil
10435 gnus-newsgroup-reads
10437 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10438 gnus-newsgroup-reads))
10439 (while (setq article (pop articles))
10440 (unless (or (memq article gnus-newsgroup-dormant)
10441 (memq article gnus-newsgroup-marked))
10442 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10444 (defun gnus-summary-limit (articles &optional pop)
10446 ;; We pop the previous limit off the stack and use that.
10447 (setq articles (car gnus-newsgroup-limits)
10448 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10449 ;; We use the new limit, so we push the old limit on the stack.
10450 (setq gnus-newsgroup-limits
10451 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10453 (setq gnus-newsgroup-limit articles)
10454 (let ((total (length gnus-newsgroup-data))
10455 (data (gnus-data-find-list (gnus-summary-article-number)))
10457 ;; This will do all the work of generating the new summary buffer
10458 ;; according to the new limit.
10459 (gnus-summary-prepare)
10460 ;; Hide any threads, possibly.
10461 (and gnus-show-threads
10462 gnus-thread-hide-subtree
10463 (gnus-summary-hide-all-threads))
10464 ;; Try to return to the article you were at, or one in the
10467 ;; We try to find some article after the current one.
10469 (and (gnus-summary-goto-subject
10470 (gnus-data-number (car data)) nil t)
10473 (setq data (cdr data))))
10475 ;; If there is no data, that means that we were after the last
10476 ;; article. The same goes when we can't find any articles
10477 ;; after the current one.
10479 (goto-char (point-max))
10480 (gnus-summary-find-prev)))
10481 ;; We return how many articles were removed from the summary
10482 ;; buffer as a result of the new limit.
10483 (- total (length gnus-newsgroup-data))))
10485 (defsubst gnus-cut-thread (thread)
10486 "Go forwards in the thread until we find an article that we want to display."
10487 (if (eq gnus-fetch-old-headers 'some)
10489 (memq (mail-header-number (car thread))
10490 gnus-newsgroup-ancient)
10491 (<= (length (cdr thread)) 1))
10492 (setq thread (cadr thread)))
10494 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10495 (= (length (cdr thread)) 1))
10496 (setq thread (cadr thread))))
10499 (defun gnus-cut-threads (threads)
10500 "Cut off all uninteresting articles from the beginning of threads."
10501 (when (or (eq gnus-fetch-old-headers 'some)
10502 (eq gnus-build-sparse-threads 'some)
10503 (eq gnus-build-sparse-threads 'more))
10504 (let ((th threads))
10506 (setcar th (gnus-cut-thread (car th)))
10507 (setq th (cdr th)))))
10510 (defun gnus-summary-initial-limit (&optional show-if-empty)
10511 "Figure out what the initial limit is supposed to be on group entry.
10512 This entails weeding out unwanted dormants, low-scored articles,
10513 fetch-old-headers verbiage, and so on."
10514 ;; Most groups have nothing to remove.
10515 (if (or gnus-inhibit-limiting
10516 (and (null gnus-newsgroup-dormant)
10517 (not (eq gnus-fetch-old-headers 'some))
10518 (null gnus-summary-expunge-below)
10519 (not (eq gnus-build-sparse-threads 'some))
10520 (not (eq gnus-build-sparse-threads 'more))
10521 (null gnus-thread-expunge-below)
10522 (not gnus-use-nocem)))
10524 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10525 (setq gnus-newsgroup-limit nil)
10528 (unless (car (symbol-value node))
10529 ;; These threads have no parents -- they are roots.
10530 (let ((nodes (cdr (symbol-value node)))
10533 (if (and gnus-thread-expunge-below
10534 (< (gnus-thread-total-score (car nodes))
10535 gnus-thread-expunge-below))
10536 (gnus-expunge-thread (pop nodes))
10537 (setq thread (pop nodes))
10538 (gnus-summary-limit-children thread))))))
10539 gnus-newsgroup-dependencies)
10540 ;; If this limitation resulted in an empty group, we might
10541 ;; pop the previous limit and use it instead.
10542 (when (and (not gnus-newsgroup-limit)
10544 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10545 gnus-newsgroup-limit))
10547 (defun gnus-summary-limit-children (thread)
10548 "Return 1 if this subthread is visible and 0 if it is not."
10549 ;; First we get the number of visible children to this thread. This
10550 ;; is done by recursing down the thread using this function, so this
10551 ;; will really go down to a leaf article first, before slowly
10552 ;; working its way up towards the root.
10556 (apply '+ (mapcar 'gnus-summary-limit-children
10559 (number (mail-header-number (car thread)))
10562 ;; If this article is dormant and has absolutely no visible
10563 ;; children, then this article isn't visible.
10564 (and (memq number gnus-newsgroup-dormant)
10566 ;; If this is a "fetch-old-headered" and there is only one
10567 ;; visible child (or less), then we don't want this article.
10568 (and (eq gnus-fetch-old-headers 'some)
10569 (memq number gnus-newsgroup-ancient)
10571 ;; If this is a sparsely inserted article with no children,
10572 ;; we don't want it.
10573 (and (eq gnus-build-sparse-threads 'some)
10574 (memq number gnus-newsgroup-sparse)
10576 ;; If we use expunging, and this article is really
10577 ;; low-scored, then we don't want this article.
10578 (when (and gnus-summary-expunge-below
10580 (or (cdr (assq number gnus-newsgroup-scored))
10581 gnus-summary-default-score))
10582 gnus-summary-expunge-below))
10583 ;; We increase the expunge-tally here, but that has
10584 ;; nothing to do with the limits, really.
10585 (incf gnus-newsgroup-expunged-tally)
10586 ;; We also mark as read here, if that's wanted.
10587 (when (and gnus-summary-mark-below
10588 (< score gnus-summary-mark-below))
10589 (setq gnus-newsgroup-unreads
10590 (delq number gnus-newsgroup-unreads))
10591 (if gnus-newsgroup-auto-expire
10592 (push number gnus-newsgroup-expirable)
10593 (push (cons number gnus-low-score-mark)
10594 gnus-newsgroup-reads)))
10596 (and gnus-use-nocem
10597 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10598 ;; Nope, invisible article.
10600 ;; Ok, this article is to be visible, so we add it to the limit
10602 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10605 (defun gnus-expunge-thread (thread)
10606 "Mark all articles in THREAD as read."
10607 (let* ((number (mail-header-number (car thread))))
10608 (incf gnus-newsgroup-expunged-tally)
10609 ;; We also mark as read here, if that's wanted.
10610 (setq gnus-newsgroup-unreads
10611 (delq number gnus-newsgroup-unreads))
10612 (if gnus-newsgroup-auto-expire
10613 (push number gnus-newsgroup-expirable)
10614 (push (cons number gnus-low-score-mark)
10615 gnus-newsgroup-reads)))
10616 ;; Go recursively through all subthreads.
10617 (mapcar 'gnus-expunge-thread (cdr thread)))
10619 ;; Summary article oriented commands
10621 (defun gnus-summary-refer-parent-article (n)
10622 "Refer parent article N times.
10623 The difference between N and the number of articles fetched is returned."
10625 (gnus-set-global-variables)
10629 (let* ((header (gnus-summary-article-header))
10631 ;; If we try to find the parent of the currently
10632 ;; displayed article, then we take a look at the actual
10633 ;; References header, since this is slightly more
10634 ;; reliable than the References field we got from the
10636 (if (and (eq (mail-header-number header)
10637 (cdr gnus-article-current))
10638 (equal gnus-newsgroup-name
10639 (car gnus-article-current)))
10641 (set-buffer gnus-original-article-buffer)
10642 (nnheader-narrow-to-headers)
10644 (mail-fetch-field "references")
10646 ;; It's not the current article, so we take a bet on
10647 ;; the value we got from the server.
10648 (mail-header-references header))))
10649 (if (setq ref (or ref (mail-header-references header)))
10650 (or (gnus-summary-refer-article (gnus-parent-id ref))
10651 (gnus-message 1 "Couldn't find parent"))
10652 (gnus-message 1 "No references in article %d"
10653 (gnus-summary-article-number))
10656 (gnus-summary-position-point)
10659 (defun gnus-summary-refer-references ()
10660 "Fetch all articles mentioned in the References header.
10661 Return how many articles were fetched."
10663 (gnus-set-global-variables)
10664 (let ((ref (mail-header-references (gnus-summary-article-header)))
10665 (current (gnus-summary-article-number))
10667 ;; For each Message-ID in the References header...
10668 (while (string-match "<[^>]*>" ref)
10670 ;; ... fetch that article.
10671 (gnus-summary-refer-article
10672 (prog1 (match-string 0 ref)
10673 (setq ref (substring ref (match-end 0))))))
10674 (gnus-summary-goto-subject current)
10675 (gnus-summary-position-point)
10678 (defun gnus-summary-refer-article (message-id)
10679 "Fetch an article specified by MESSAGE-ID."
10680 (interactive "sMessage-ID: ")
10681 (when (and (stringp message-id)
10682 (not (zerop (length message-id))))
10683 ;; Construct the correct Message-ID if necessary.
10684 ;; Suggested by tale@pawl.rpi.edu.
10685 (unless (string-match "^<" message-id)
10686 (setq message-id (concat "<" message-id)))
10687 (unless (string-match ">$" message-id)
10688 (setq message-id (concat message-id ">")))
10689 (let ((header (car (gnus-gethash (downcase message-id)
10690 gnus-newsgroup-dependencies))))
10692 ;; The article is present in the buffer, to we just go to it.
10693 (gnus-summary-goto-article (mail-header-number header) nil t)
10694 ;; We fetch the article
10695 (let ((gnus-override-method gnus-refer-article-method)
10697 ;; Start the special refer-article method, if necessary.
10698 (when gnus-refer-article-method
10699 (gnus-check-server gnus-refer-article-method))
10700 ;; Fetch the header, and display the article.
10701 (if (setq number (gnus-summary-insert-subject message-id))
10702 (gnus-summary-select-article nil nil nil number)
10703 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10705 (defun gnus-summary-enter-digest-group (&optional force)
10706 "Enter a digest group based on the current article."
10708 (gnus-set-global-variables)
10709 (gnus-summary-select-article)
10710 (let ((name (format "%s-%d"
10711 (gnus-group-prefixed-name
10712 gnus-newsgroup-name (list 'nndoc ""))
10713 gnus-current-article))
10714 (ogroup gnus-newsgroup-name)
10715 (case-fold-search t)
10716 (buf (current-buffer))
10719 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10720 (insert-buffer-substring gnus-original-article-buffer)
10722 (goto-char (point-min))
10723 (or (search-forward "\n\n" nil t) (point)))
10724 (goto-char (point-min))
10725 (delete-matching-lines "^\\(Path\\):\\|^From ")
10728 (if (gnus-group-read-ephemeral-group
10729 name `(nndoc ,name (nndoc-address
10731 (nndoc-article-type ,(if force 'digest 'guess))) t)
10732 ;; Make all postings to this group go to the parent group.
10733 (nconc (gnus-info-params (gnus-get-info name))
10734 (list (cons 'to-group ogroup)))
10735 ;; Couldn't select this doc group.
10736 (switch-to-buffer buf)
10737 (gnus-set-global-variables)
10738 (gnus-configure-windows 'summary)
10739 (gnus-message 3 "Article couldn't be entered?"))
10740 (kill-buffer dig))))
10742 (defun gnus-summary-isearch-article (&optional regexp-p)
10743 "Do incremental search forward on the current article.
10744 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10746 (gnus-set-global-variables)
10747 (gnus-summary-select-article)
10748 (gnus-configure-windows 'article)
10749 (gnus-eval-in-buffer-window
10750 gnus-article-buffer
10751 (goto-char (point-min))
10752 (isearch-forward regexp-p)))
10754 (defun gnus-summary-search-article-forward (regexp &optional backward)
10755 "Search for an article containing REGEXP forward.
10756 If BACKWARD, search backward instead."
10759 (format "Search article %s (regexp%s): "
10760 (if current-prefix-arg "backward" "forward")
10761 (if gnus-last-search-regexp
10762 (concat ", default " gnus-last-search-regexp)
10764 current-prefix-arg))
10765 (gnus-set-global-variables)
10766 (if (string-equal regexp "")
10767 (setq regexp (or gnus-last-search-regexp ""))
10768 (setq gnus-last-search-regexp regexp))
10769 (if (gnus-summary-search-article regexp backward)
10770 (gnus-article-set-window-start
10771 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10772 (error "Search failed: \"%s\"" regexp)))
10774 (defun gnus-summary-search-article-backward (regexp)
10775 "Search for an article containing REGEXP backward."
10778 (format "Search article backward (regexp%s): "
10779 (if gnus-last-search-regexp
10780 (concat ", default " gnus-last-search-regexp)
10782 (gnus-summary-search-article-forward regexp 'backward))
10784 (defun gnus-summary-search-article (regexp &optional backward)
10785 "Search for an article containing REGEXP.
10786 Optional argument BACKWARD means do search for backward.
10787 gnus-select-article-hook is not called during the search."
10788 (let ((gnus-select-article-hook nil) ;Disable hook.
10789 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10792 (function re-search-backward) (function re-search-forward)))
10795 ;; Hidden thread subtrees must be searched for ,too.
10796 (gnus-summary-show-all-threads)
10797 ;; First of all, search current article.
10798 ;; We don't want to read article again from NNTP server nor reset
10800 (gnus-summary-select-article)
10801 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10802 (setq last gnus-current-article)
10803 (gnus-eval-in-buffer-window
10804 gnus-article-buffer
10807 ;; Begin search from current point.
10808 (setq found (funcall re-search regexp nil t))))
10809 ;; Then search next articles.
10810 (while (and (not found)
10811 (gnus-summary-display-article
10812 (if backward (gnus-summary-find-prev)
10813 (gnus-summary-find-next))))
10814 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10815 (gnus-eval-in-buffer-window
10816 gnus-article-buffer
10819 (goto-char (if backward (point-max) (point-min)))
10820 (setq found (funcall re-search regexp nil t)))))
10822 ;; Adjust article pointer.
10823 (or (eq last gnus-current-article)
10824 (setq gnus-last-article last))
10825 ;; Return T if found such article.
10828 (defun gnus-summary-find-matching (header regexp &optional backward unread
10830 "Return a list of all articles that match REGEXP on HEADER.
10831 The search stars on the current article and goes forwards unless
10832 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10833 If UNREAD is non-nil, only unread articles will
10834 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10835 in the comparisons."
10836 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10837 (gnus-data-find-list
10838 (gnus-summary-article-number) (gnus-data-list backward))))
10839 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10840 (case-fold-search (not not-case-fold))
10842 (or (fboundp (intern (concat "mail-header-" header)))
10843 (error "%s is not a valid header" header))
10845 (setq d (car data))
10846 (and (or (not unread) ; We want all articles...
10847 (gnus-data-unread-p d)) ; Or just unreads.
10848 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10849 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10850 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10851 (setq data (cdr data)))
10852 (nreverse articles)))
10854 (defun gnus-summary-execute-command (header regexp command &optional backward)
10855 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10856 If HEADER is an empty string (or nil), the match is done on the entire
10857 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10859 (list (let ((completion-ignore-case t))
10862 (mapcar (lambda (string) (list string))
10863 '("Number" "Subject" "From" "Lines" "Date"
10864 "Message-ID" "Xref" "References" "Body"))
10865 nil 'require-match))
10866 (read-string "Regexp: ")
10867 (read-key-sequence "Command: ")
10868 current-prefix-arg))
10869 (when (equal header "Body")
10871 (gnus-set-global-variables)
10872 ;; Hidden thread subtrees must be searched as well.
10873 (gnus-summary-show-all-threads)
10874 ;; We don't want to change current point nor window configuration.
10876 (save-window-excursion
10877 (gnus-message 6 "Executing %s..." (key-description command))
10878 ;; We'd like to execute COMMAND interactively so as to give arguments.
10879 (gnus-execute header regexp
10880 `(lambda () (call-interactively ',(key-binding command)))
10882 (gnus-message 6 "Executing %s...done" (key-description command)))))
10884 (defun gnus-summary-beginning-of-article ()
10885 "Scroll the article back to the beginning."
10887 (gnus-set-global-variables)
10888 (gnus-summary-select-article)
10889 (gnus-configure-windows 'article)
10890 (gnus-eval-in-buffer-window
10891 gnus-article-buffer
10893 (goto-char (point-min))
10894 (and gnus-break-pages (gnus-narrow-to-page))))
10896 (defun gnus-summary-end-of-article ()
10897 "Scroll to the end of the article."
10899 (gnus-set-global-variables)
10900 (gnus-summary-select-article)
10901 (gnus-configure-windows 'article)
10902 (gnus-eval-in-buffer-window
10903 gnus-article-buffer
10905 (goto-char (point-max))
10907 (and gnus-break-pages (gnus-narrow-to-page))))
10909 (defun gnus-summary-show-article (&optional arg)
10910 "Force re-fetching of the current article.
10911 If ARG (the prefix) is non-nil, show the raw article without any
10912 article massaging functions being run."
10914 (gnus-set-global-variables)
10916 ;; Select the article the normal way.
10917 (gnus-summary-select-article nil 'force)
10918 ;; Bind the article treatment functions to nil.
10919 (let ((gnus-have-all-headers t)
10920 gnus-article-display-hook
10921 gnus-article-prepare-hook
10923 (gnus-summary-select-article nil 'force)))
10924 ; (gnus-configure-windows 'article)
10925 (gnus-summary-position-point))
10927 (defun gnus-summary-verbose-headers (&optional arg)
10928 "Toggle permanent full header display.
10929 If ARG is a positive number, turn header display on.
10930 If ARG is a negative number, turn header display off."
10932 (gnus-set-global-variables)
10933 (gnus-summary-toggle-header arg)
10934 (setq gnus-show-all-headers
10935 (cond ((or (not (numberp arg))
10937 (not gnus-show-all-headers))
10941 (defun gnus-summary-toggle-header (&optional arg)
10942 "Show the headers if they are hidden, or hide them if they are shown.
10943 If ARG is a positive number, show the entire header.
10944 If ARG is a negative number, hide the unwanted header lines."
10946 (gnus-set-global-variables)
10948 (set-buffer gnus-article-buffer)
10949 (let* ((buffer-read-only nil)
10950 (inhibit-point-motion-hooks t)
10951 (hidden (text-property-any
10952 (goto-char (point-min)) (search-forward "\n\n")
10955 (goto-char (point-min))
10956 (when (search-forward "\n\n" nil t)
10957 (delete-region (point-min) (1- (point))))
10958 (goto-char (point-min))
10960 (set-buffer gnus-original-article-buffer)
10961 (goto-char (point-min))
10962 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10963 (insert-buffer-substring gnus-original-article-buffer 1 e)
10964 (let ((gnus-inhibit-hiding t))
10965 (run-hooks 'gnus-article-display-hook))
10966 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10967 (gnus-article-hide-headers)))))
10969 (defun gnus-summary-show-all-headers ()
10970 "Make all header lines visible."
10972 (gnus-set-global-variables)
10973 (gnus-article-show-all-headers))
10975 (defun gnus-summary-toggle-mime (&optional arg)
10976 "Toggle MIME processing.
10977 If ARG is a positive number, turn MIME processing on."
10979 (gnus-set-global-variables)
10980 (setq gnus-show-mime
10981 (if (null arg) (not gnus-show-mime)
10982 (> (prefix-numeric-value arg) 0)))
10983 (gnus-summary-select-article t 'force))
10985 (defun gnus-summary-caesar-message (&optional arg)
10986 "Caesar rotate the current article by 13.
10987 The numerical prefix specifies how manu places to rotate each letter
10990 (gnus-set-global-variables)
10991 (gnus-summary-select-article)
10992 (let ((mail-header-separator ""))
10993 (gnus-eval-in-buffer-window
10994 gnus-article-buffer
10997 (let ((start (window-start)))
10998 (news-caesar-buffer-body arg)
10999 (set-window-start (get-buffer-window (current-buffer)) start))))))
11001 (defun gnus-summary-stop-page-breaking ()
11002 "Stop page breaking in the current article."
11004 (gnus-set-global-variables)
11005 (gnus-summary-select-article)
11006 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11008 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11009 "Move the current article to a different newsgroup.
11010 If N is a positive number, move the N next articles.
11011 If N is a negative number, move the N previous articles.
11012 If N is nil and any articles have been marked with the process mark,
11013 move those articles instead.
11014 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11015 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11016 re-spool using this method.
11018 For this function to work, both the current newsgroup and the
11019 newsgroup that you want to move to have to support the `request-move'
11020 and `request-accept' functions."
11022 (unless action (setq action 'move))
11023 (gnus-set-global-variables)
11024 ;; Check whether the source group supports the required functions.
11025 (cond ((and (eq action 'move)
11026 (not (gnus-check-backend-function
11027 'request-move-article gnus-newsgroup-name)))
11028 (error "The current group does not support article moving"))
11029 ((and (eq action 'crosspost)
11030 (not (gnus-check-backend-function
11031 'request-replace-article gnus-newsgroup-name)))
11032 (error "The current group does not support article editing")))
11033 (let ((articles (gnus-summary-work-articles n))
11034 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11035 (names '((move "move" "Moving")
11036 (copy "copy" "Copying")
11037 (crosspost "crosspost" "Crossposting")))
11038 (copy-buf (save-excursion
11039 (nnheader-set-temp-buffer " *copy article*")))
11040 art-group to-method new-xref article)
11041 (unless (assq action names)
11042 (error "Unknown action %s" action))
11043 ;; Read the newsgroup name.
11044 (when (and (not to-newsgroup)
11045 (not select-method))
11047 (gnus-read-move-group-name
11048 (cadr (assq action names))
11049 gnus-current-move-group articles prefix))
11050 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11051 (setq to-method (if select-method (list select-method "")
11052 (gnus-find-method-for-group to-newsgroup)))
11053 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11054 ;;(error "Can't %s to the same group you're already in" action))
11055 ;; Check the method we are to move this article to...
11056 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11057 (error "%s does not support article copying" (car to-method)))
11058 (or (gnus-check-server to-method)
11059 (error "Can't open server %s" (car to-method)))
11060 (gnus-message 6 "%s to %s: %s..."
11061 (caddr (assq action names))
11062 (or select-method to-newsgroup) articles)
11064 (setq article (pop articles))
11068 ;; Move the article.
11070 (gnus-request-move-article
11071 article ; Article to move
11072 gnus-newsgroup-name ; From newsgrouo
11073 (nth 1 (gnus-find-method-for-group
11074 gnus-newsgroup-name)) ; Server
11075 (list 'gnus-request-accept-article
11077 (list 'quote select-method)
11079 (not articles)) ; Accept form
11080 (not articles))) ; Only save nov last time
11081 ;; Copy the article.
11084 (set-buffer copy-buf)
11085 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11086 (gnus-request-accept-article
11087 (if select-method select-method to-newsgroup)
11089 ;; Crosspost the article.
11090 ((eq action 'crosspost)
11091 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11092 (setq new-xref (concat gnus-newsgroup-name ":" article))
11093 (if (and xref (not (string= xref "")))
11095 (when (string-match "^Xref: " xref)
11096 (setq xref (substring xref (match-end 0))))
11097 (setq new-xref (concat xref " " new-xref)))
11098 (setq new-xref (concat (system-name) " " new-xref)))
11100 (set-buffer copy-buf)
11101 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11102 (nnheader-replace-header "xref" new-xref)
11103 (gnus-request-accept-article
11104 (if select-method select-method to-newsgroup)
11105 (not articles)))))))
11106 (if (not art-group)
11107 (gnus-message 1 "Couldn't %s article %s"
11108 (cadr (assq action names)) article)
11111 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11113 (gnus-group-prefixed-name
11115 (if select-method (list select-method "")
11116 (gnus-find-method-for-group to-newsgroup)))
11117 gnus-newsrc-hashtb)))
11118 (info (nth 2 entry)))
11119 ;; Update the group that has been moved to.
11121 (memq action '(move copy)))
11122 (unless (memq article gnus-newsgroup-unreads)
11123 (gnus-info-set-read
11124 info (gnus-add-to-range (gnus-info-read info)
11125 (list (cdr art-group)))))
11127 ;; Copy any marks over to the new group.
11128 (let ((marks gnus-article-mark-lists)
11129 (to-article (cdr art-group)))
11131 ;; See whether the article is to be put in the cache.
11132 (when gnus-use-cache
11133 (gnus-cache-possibly-enter-article
11134 (gnus-info-group info) to-article
11135 (let ((header (copy-sequence
11136 (gnus-summary-article-header article))))
11137 (mail-header-set-number header to-article)
11139 (memq article gnus-newsgroup-marked)
11140 (memq article gnus-newsgroup-dormant)
11141 (memq article gnus-newsgroup-unreads)))
11144 (when (memq article (symbol-value
11145 (intern (format "gnus-newsgroup-%s"
11147 (gnus-add-marked-articles
11148 (gnus-info-group info) (cdar marks)
11149 (list to-article) info))
11150 (setq marks (cdr marks)))))
11152 ;; Update the Xref header in this article to point to
11153 ;; the new crossposted article we have just created.
11154 (when (eq action 'crosspost)
11156 (set-buffer copy-buf)
11157 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11158 (nnheader-replace-header
11159 "xref" (concat new-xref " " (gnus-group-prefixed-name
11160 (car art-group) to-method)
11161 ":" (cdr art-group)))
11162 (gnus-request-replace-article
11163 article gnus-newsgroup-name (current-buffer)))))
11165 (gnus-summary-goto-subject article)
11166 (when (eq action 'move)
11167 (gnus-summary-mark-article article gnus-canceled-mark)))
11168 (gnus-summary-remove-process-mark article))
11169 (gnus-kill-buffer copy-buf)
11170 (gnus-summary-position-point)
11171 (gnus-set-mode-line 'summary)))
11173 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11174 "Move the current article to a different newsgroup.
11175 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11176 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11177 re-spool using this method."
11179 (gnus-summary-move-article n nil nil 'copy))
11181 (defun gnus-summary-crosspost-article (&optional n)
11182 "Crosspost the current article to some other group."
11184 (gnus-summary-move-article n nil nil 'crosspost))
11186 (defun gnus-summary-respool-article (&optional n respool-method)
11187 "Respool the current article.
11188 The article will be squeezed through the mail spooling process again,
11189 which means that it will be put in some mail newsgroup or other
11190 depending on `nnmail-split-methods'.
11191 If N is a positive number, respool the N next articles.
11192 If N is a negative number, respool the N previous articles.
11193 If N is nil and any articles have been marked with the process mark,
11194 respool those articles instead.
11196 Respooling can be done both from mail groups and \"real\" newsgroups.
11197 In the former case, the articles in question will be moved from the
11198 current group into whatever groups they are destined to. In the
11199 latter case, they will be copied into the relevant groups."
11201 (gnus-set-global-variables)
11202 (let ((respool-methods (gnus-methods-using 'respool))
11204 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11206 (setq respool-method
11208 "What method do you want to use when respooling? "
11209 respool-methods nil t methname)))
11210 (or (string= respool-method "")
11211 (if (assoc (symbol-name
11212 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11214 (gnus-summary-move-article n nil (intern respool-method))
11215 (gnus-summary-copy-article n nil (intern respool-method))))))
11217 (defun gnus-summary-import-article (file)
11218 "Import a random file into a mail newsgroup."
11219 (interactive "fImport file: ")
11220 (gnus-set-global-variables)
11221 (let ((group gnus-newsgroup-name)
11222 (now (current-time))
11224 (or (gnus-check-backend-function 'request-accept-article group)
11225 (error "%s does not support article importing" group))
11226 (or (file-readable-p file)
11227 (not (file-regular-p file))
11228 (error "Can't read %s" file))
11230 (set-buffer (get-buffer-create " *import file*"))
11231 (buffer-disable-undo (current-buffer))
11233 (insert-file-contents file)
11234 (goto-char (point-min))
11235 (unless (nnheader-article-p)
11236 ;; This doesn't look like an article, so we fudge some headers.
11237 (setq atts (file-attributes file)
11238 lines (count-lines (point-min) (point-max)))
11239 (insert "From: " (read-string "From: ") "\n"
11240 "Subject: " (read-string "Subject: ") "\n"
11241 "Date: " (timezone-make-date-arpa-standard
11242 (current-time-string (nth 5 atts))
11243 (current-time-zone now)
11244 (current-time-zone now)) "\n"
11245 "Message-ID: " (gnus-inews-message-id) "\n"
11246 "Lines: " (int-to-string lines) "\n"
11247 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11248 (gnus-request-accept-article group t)
11249 (kill-buffer (current-buffer)))))
11251 (defun gnus-summary-expire-articles ()
11252 "Expire all articles that are marked as expirable in the current group."
11254 (gnus-set-global-variables)
11255 (when (gnus-check-backend-function
11256 'request-expire-articles gnus-newsgroup-name)
11257 ;; This backend supports expiry.
11258 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11259 (expirable (if total
11260 (gnus-list-of-read-articles gnus-newsgroup-name)
11261 (setq gnus-newsgroup-expirable
11262 (sort gnus-newsgroup-expirable '<))))
11263 (expiry-wait (gnus-group-get-parameter
11264 gnus-newsgroup-name 'expiry-wait))
11267 ;; There are expirable articles in this group, so we run them
11268 ;; through the expiry process.
11269 (gnus-message 6 "Expiring articles...")
11270 ;; The list of articles that weren't expired is returned.
11272 (let ((nnmail-expiry-wait-function nil)
11273 (nnmail-expiry-wait expiry-wait))
11274 (setq es (gnus-request-expire-articles
11275 expirable gnus-newsgroup-name)))
11276 (setq es (gnus-request-expire-articles
11277 expirable gnus-newsgroup-name)))
11278 (or total (setq gnus-newsgroup-expirable es))
11279 ;; We go through the old list of expirable, and mark all
11280 ;; really expired articles as nonexistent.
11281 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11282 (let ((gnus-use-cache nil))
11284 (unless (memq (car expirable) es)
11285 (when (gnus-data-find (car expirable))
11286 (gnus-summary-mark-article
11287 (car expirable) gnus-canceled-mark)))
11288 (setq expirable (cdr expirable)))))
11289 (gnus-message 6 "Expiring articles...done")))))
11291 (defun gnus-summary-expire-articles-now ()
11292 "Expunge all expirable articles in the current group.
11293 This means that *all* articles that are marked as expirable will be
11294 deleted forever, right now."
11296 (gnus-set-global-variables)
11297 (or gnus-expert-user
11299 "Are you really, really, really sure you want to expunge? ")
11301 (let ((nnmail-expiry-wait 'immediate)
11302 (nnmail-expiry-wait-function nil))
11303 (gnus-summary-expire-articles)))
11305 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11306 (defun gnus-summary-delete-article (&optional n)
11307 "Delete the N next (mail) articles.
11308 This command actually deletes articles. This is not a marking
11309 command. The article will disappear forever from your life, never to
11311 If N is negative, delete backwards.
11312 If N is nil and articles have been marked with the process mark,
11313 delete these instead."
11315 (gnus-set-global-variables)
11316 (or (gnus-check-backend-function 'request-expire-articles
11317 gnus-newsgroup-name)
11318 (error "The current newsgroup does not support article deletion."))
11319 ;; Compute the list of articles to delete.
11320 (let ((articles (gnus-summary-work-articles n))
11322 (if (and gnus-novice-user
11323 (not (gnus-y-or-n-p
11324 (format "Do you really want to delete %s forever? "
11325 (if (> (length articles) 1) "these articles"
11326 "this article")))))
11328 ;; Delete the articles.
11329 (setq not-deleted (gnus-request-expire-articles
11330 articles gnus-newsgroup-name 'force))
11332 (gnus-summary-remove-process-mark (car articles))
11333 ;; The backend might not have been able to delete the article
11335 (or (memq (car articles) not-deleted)
11336 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11337 (setq articles (cdr articles))))
11338 (gnus-summary-position-point)
11339 (gnus-set-mode-line 'summary)
11342 (defun gnus-summary-edit-article (&optional force)
11343 "Enter into a buffer and edit the current article.
11344 This will have permanent effect only in mail groups.
11345 If FORCE is non-nil, allow editing of articles even in read-only
11349 (set-buffer gnus-summary-buffer)
11350 (gnus-set-global-variables)
11351 (when (and (not force)
11352 (gnus-group-read-only-p))
11353 (error "The current newsgroup does not support article editing."))
11354 (gnus-summary-select-article t nil t)
11355 (gnus-configure-windows 'article)
11356 (select-window (get-buffer-window gnus-article-buffer))
11357 (gnus-message 6 "C-c C-c to end edits")
11358 (setq buffer-read-only nil)
11360 (use-local-map (copy-keymap (current-local-map)))
11361 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11362 (buffer-enable-undo)
11364 (goto-char (point-min))
11365 (search-forward "\n\n" nil t)))
11367 (defun gnus-summary-edit-article-done ()
11368 "Make edits to the current article permanent."
11370 (if (gnus-group-read-only-p)
11372 (gnus-summary-edit-article-postpone)
11374 1 "The current newsgroup does not support article editing.")
11376 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11379 (if (not (gnus-request-replace-article
11380 (cdr gnus-article-current) (car gnus-article-current)
11382 (error "Couldn't replace article.")
11383 (gnus-article-mode)
11384 (use-local-map gnus-article-mode-map)
11385 (setq buffer-read-only t)
11386 (buffer-disable-undo (current-buffer))
11387 (gnus-configure-windows 'summary)
11388 (gnus-summary-update-article (cdr gnus-article-current)))
11389 (run-hooks 'gnus-article-display-hook)
11390 (and (gnus-visual-p 'summary-highlight 'highlight)
11391 (run-hooks 'gnus-visual-mark-article-hook)))))
11393 (defun gnus-summary-edit-article-postpone ()
11394 "Postpone changes to the current article."
11396 (gnus-article-mode)
11397 (use-local-map gnus-article-mode-map)
11398 (setq buffer-read-only t)
11399 (buffer-disable-undo (current-buffer))
11400 (gnus-configure-windows 'summary)
11401 (and (gnus-visual-p 'summary-highlight 'highlight)
11402 (run-hooks 'gnus-visual-mark-article-hook)))
11404 (defun gnus-summary-respool-query ()
11405 "Query where the respool algorithm would put this article."
11407 (gnus-set-global-variables)
11408 (gnus-summary-select-article)
11410 (set-buffer gnus-article-buffer)
11412 (goto-char (point-min))
11413 (search-forward "\n\n")
11414 (narrow-to-region (point-min) (point))
11415 (pp-eval-expression
11416 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11418 ;; Summary score commands.
11420 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11422 (defun gnus-summary-raise-score (n)
11423 "Raise the score of the current article by N."
11425 (gnus-set-global-variables)
11426 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11428 (defun gnus-summary-set-score (n)
11429 "Set the score of the current article to N."
11431 (gnus-set-global-variables)
11433 (gnus-summary-show-thread)
11434 (let ((buffer-read-only nil))
11436 (gnus-summary-update-mark
11437 (if (= n (or gnus-summary-default-score 0)) ?
11438 (if (< n (or gnus-summary-default-score 0))
11439 gnus-score-below-mark gnus-score-over-mark)) 'score))
11440 (let* ((article (gnus-summary-article-number))
11441 (score (assq article gnus-newsgroup-scored)))
11442 (if score (setcdr score n)
11443 (setq gnus-newsgroup-scored
11444 (cons (cons article n) gnus-newsgroup-scored))))
11445 (gnus-summary-update-line)))
11447 (defun gnus-summary-current-score ()
11448 "Return the score of the current article."
11450 (gnus-set-global-variables)
11451 (message "%s" (gnus-summary-article-score)))
11453 ;; Summary marking commands.
11455 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11456 "Mark articles which has the same subject as read, and then select the next.
11457 If UNMARK is positive, remove any kind of mark.
11458 If UNMARK is negative, tick articles."
11460 (gnus-set-global-variables)
11462 (setq unmark (prefix-numeric-value unmark)))
11464 (gnus-summary-mark-same-subject
11465 (gnus-summary-article-subject) unmark)))
11466 ;; Select next unread article. If auto-select-same mode, should
11467 ;; select the first unread article.
11468 (gnus-summary-next-article t (and gnus-auto-select-same
11469 (gnus-summary-article-subject)))
11470 (gnus-message 7 "%d article%s marked as %s"
11471 count (if (= count 1) " is" "s are")
11472 (if unmark "unread" "read"))))
11474 (defun gnus-summary-kill-same-subject (&optional unmark)
11475 "Mark articles which has the same subject as read.
11476 If UNMARK is positive, remove any kind of mark.
11477 If UNMARK is negative, tick articles."
11479 (gnus-set-global-variables)
11481 (setq unmark (prefix-numeric-value unmark)))
11483 (gnus-summary-mark-same-subject
11484 (gnus-summary-article-subject) unmark)))
11485 ;; If marked as read, go to next unread subject.
11487 ;; Go to next unread subject.
11488 (gnus-summary-next-subject 1 t))
11489 (gnus-message 7 "%d articles are marked as %s"
11490 count (if unmark "unread" "read"))))
11492 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11493 "Mark articles with same SUBJECT as read, and return marked number.
11494 If optional argument UNMARK is positive, remove any kinds of marks.
11495 If optional argument UNMARK is negative, mark articles as unread instead."
11499 ((null unmark) ; Mark as read.
11502 (gnus-summary-mark-article-as-read gnus-killed-mark)
11503 (gnus-summary-show-thread) t)
11504 (gnus-summary-find-subject subject))
11505 (setq count (1+ count))))
11506 ((> unmark 0) ; Tick.
11509 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11510 (gnus-summary-show-thread) t)
11511 (gnus-summary-find-subject subject))
11512 (setq count (1+ count))))
11513 (t ; Mark as unread.
11516 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11517 (gnus-summary-show-thread) t)
11518 (gnus-summary-find-subject subject))
11519 (setq count (1+ count)))))
11520 (gnus-set-mode-line 'summary)
11521 ;; Return the number of marked articles.
11524 (defun gnus-summary-mark-as-processable (n &optional unmark)
11525 "Set the process mark on the next N articles.
11526 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11527 the process mark instead. The difference between N and the actual
11528 number of articles marked is returned."
11530 (gnus-set-global-variables)
11531 (let ((backward (< n 0))
11536 (gnus-summary-remove-process-mark
11537 (gnus-summary-article-number))
11538 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11539 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11541 (if (/= 0 n) (gnus-message 7 "No more articles"))
11542 (gnus-summary-recenter)
11543 (gnus-summary-position-point)
11546 (defun gnus-summary-unmark-as-processable (n)
11547 "Remove the process mark from the next N articles.
11548 If N is negative, mark backward instead. The difference between N and
11549 the actual number of articles marked is returned."
11551 (gnus-set-global-variables)
11552 (gnus-summary-mark-as-processable n t))
11554 (defun gnus-summary-unmark-all-processable ()
11555 "Remove the process mark from all articles."
11557 (gnus-set-global-variables)
11559 (while gnus-newsgroup-processable
11560 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11561 (gnus-summary-position-point))
11563 (defun gnus-summary-mark-as-expirable (n)
11564 "Mark N articles forward as expirable.
11565 If N is negative, mark backward instead. The difference between N and
11566 the actual number of articles marked is returned."
11568 (gnus-set-global-variables)
11569 (gnus-summary-mark-forward n gnus-expirable-mark))
11571 (defun gnus-summary-mark-article-as-replied (article)
11572 "Mark ARTICLE replied and update the summary line."
11573 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11574 (let ((buffer-read-only nil))
11575 (when (gnus-summary-goto-subject article)
11576 (gnus-summary-update-secondary-mark article))))
11578 (defun gnus-summary-set-bookmark (article)
11579 "Set a bookmark in current article."
11580 (interactive (list (gnus-summary-article-number)))
11581 (gnus-set-global-variables)
11582 (if (or (not (get-buffer gnus-article-buffer))
11583 (not gnus-current-article)
11584 (not gnus-article-current)
11585 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11586 (error "No current article selected"))
11587 ;; Remove old bookmark, if one exists.
11588 (let ((old (assq article gnus-newsgroup-bookmarks)))
11589 (if old (setq gnus-newsgroup-bookmarks
11590 (delq old gnus-newsgroup-bookmarks))))
11591 ;; Set the new bookmark, which is on the form
11592 ;; (article-number . line-number-in-body).
11593 (setq gnus-newsgroup-bookmarks
11597 (set-buffer gnus-article-buffer)
11601 (goto-char (point-min))
11602 (search-forward "\n\n" nil t)
11605 gnus-newsgroup-bookmarks))
11606 (gnus-message 6 "A bookmark has been added to the current article."))
11608 (defun gnus-summary-remove-bookmark (article)
11609 "Remove the bookmark from the current article."
11610 (interactive (list (gnus-summary-article-number)))
11611 (gnus-set-global-variables)
11612 ;; Remove old bookmark, if one exists.
11613 (let ((old (assq article gnus-newsgroup-bookmarks)))
11616 (setq gnus-newsgroup-bookmarks
11617 (delq old gnus-newsgroup-bookmarks))
11618 (gnus-message 6 "Removed bookmark."))
11619 (gnus-message 6 "No bookmark in current article."))))
11621 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11622 (defun gnus-summary-mark-as-dormant (n)
11623 "Mark N articles forward as dormant.
11624 If N is negative, mark backward instead. The difference between N and
11625 the actual number of articles marked is returned."
11627 (gnus-set-global-variables)
11628 (gnus-summary-mark-forward n gnus-dormant-mark))
11630 (defun gnus-summary-set-process-mark (article)
11631 "Set the process mark on ARTICLE and update the summary line."
11632 (setq gnus-newsgroup-processable
11634 (delq article gnus-newsgroup-processable)))
11635 (when (gnus-summary-goto-subject article)
11636 (gnus-summary-show-thread)
11637 (gnus-summary-update-secondary-mark article)))
11639 (defun gnus-summary-remove-process-mark (article)
11640 "Remove the process mark from ARTICLE and update the summary line."
11641 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11642 (when (gnus-summary-goto-subject article)
11643 (gnus-summary-show-thread)
11644 (gnus-summary-update-secondary-mark article)))
11646 (defun gnus-summary-set-saved-mark (article)
11647 "Set the process mark on ARTICLE and update the summary line."
11648 (push article gnus-newsgroup-saved)
11649 (when (gnus-summary-goto-subject article)
11650 (gnus-summary-update-secondary-mark article)))
11652 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11653 "Mark N articles as read forwards.
11654 If N is negative, mark backwards instead.
11655 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11657 The difference between N and the actual number of articles marked is
11660 (gnus-set-global-variables)
11661 (let ((backward (< n 0))
11662 (gnus-summary-goto-unread
11663 (and gnus-summary-goto-unread
11664 (not (eq gnus-summary-goto-unread 'never))
11665 (not (memq mark (list gnus-unread-mark
11666 gnus-ticked-mark gnus-dormant-mark)))))
11668 (mark (or mark gnus-del-mark)))
11669 (while (and (> n 0)
11670 (gnus-summary-mark-article nil mark no-expire)
11671 (zerop (gnus-summary-next-subject
11673 (and gnus-summary-goto-unread
11674 (not (eq gnus-summary-goto-unread 'never)))
11677 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11678 (gnus-summary-recenter)
11679 (gnus-summary-position-point)
11680 (gnus-set-mode-line 'summary)
11683 (defun gnus-summary-mark-article-as-read (mark)
11684 "Mark the current article quickly as read with MARK."
11685 (let ((article (gnus-summary-article-number)))
11686 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11687 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11688 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11689 (setq gnus-newsgroup-reads
11690 (cons (cons article mark) gnus-newsgroup-reads))
11691 ;; Possibly remove from cache, if that is used.
11692 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11693 ;; Allow the backend to change the mark.
11694 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11695 ;; Check for auto-expiry.
11696 (when (and gnus-newsgroup-auto-expire
11697 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11698 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11699 (= mark gnus-ancient-mark)
11700 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11701 (setq mark gnus-expirable-mark)
11702 (push article gnus-newsgroup-expirable))
11703 ;; Set the mark in the buffer.
11704 (gnus-summary-update-mark mark 'unread)
11707 (defun gnus-summary-mark-article-as-unread (mark)
11708 "Mark the current article quickly as unread with MARK."
11709 (let ((article (gnus-summary-article-number)))
11710 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11711 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11712 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11713 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11714 (cond ((= mark gnus-ticked-mark)
11715 (push article gnus-newsgroup-marked))
11716 ((= mark gnus-dormant-mark)
11717 (push article gnus-newsgroup-dormant))
11719 (push article gnus-newsgroup-unreads)))
11720 (setq gnus-newsgroup-reads
11721 (delq (assq article gnus-newsgroup-reads)
11722 gnus-newsgroup-reads))
11724 ;; See whether the article is to be put in the cache.
11725 (and gnus-use-cache
11726 (vectorp (gnus-summary-article-header article))
11728 (gnus-cache-possibly-enter-article
11729 gnus-newsgroup-name article
11730 (gnus-summary-article-header article)
11731 (= mark gnus-ticked-mark)
11732 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11735 (gnus-summary-update-mark mark 'unread)
11738 (defun gnus-summary-mark-article (&optional article mark no-expire)
11739 "Mark ARTICLE with MARK. MARK can be any character.
11740 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11741 `??' (dormant) and `?E' (expirable).
11742 If MARK is nil, then the default character `?D' is used.
11743 If ARTICLE is nil, then the article on the current line will be
11745 ;; The mark might be a string.
11746 (and (stringp mark)
11747 (setq mark (aref mark 0)))
11748 ;; If no mark is given, then we check auto-expiring.
11749 (and (not no-expire)
11750 gnus-newsgroup-auto-expire
11752 (and (numberp mark)
11753 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11754 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11755 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11756 (setq mark gnus-expirable-mark))
11757 (let* ((mark (or mark gnus-del-mark))
11758 (article (or article (gnus-summary-article-number))))
11759 (or article (error "No article on current line"))
11760 (if (or (= mark gnus-unread-mark)
11761 (= mark gnus-ticked-mark)
11762 (= mark gnus-dormant-mark))
11763 (gnus-mark-article-as-unread article mark)
11764 (gnus-mark-article-as-read article mark))
11766 ;; See whether the article is to be put in the cache.
11767 (and gnus-use-cache
11768 (not (= mark gnus-canceled-mark))
11769 (vectorp (gnus-summary-article-header article))
11771 (gnus-cache-possibly-enter-article
11772 gnus-newsgroup-name article
11773 (gnus-summary-article-header article)
11774 (= mark gnus-ticked-mark)
11775 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11777 (if (gnus-summary-goto-subject article nil t)
11778 (let ((buffer-read-only nil))
11779 (gnus-summary-show-thread)
11781 (gnus-summary-update-mark mark 'unread)
11784 (defun gnus-summary-update-secondary-mark (article)
11785 "Update the secondary (read, process, cache) mark."
11786 (gnus-summary-update-mark
11787 (cond ((memq article gnus-newsgroup-processable)
11789 ((memq article gnus-newsgroup-cached)
11791 ((memq article gnus-newsgroup-replied)
11793 ((memq article gnus-newsgroup-saved)
11795 (t gnus-unread-mark))
11797 (when (gnus-visual-p 'summary-highlight 'highlight)
11798 (run-hooks 'gnus-summary-update-hook))
11801 (defun gnus-summary-update-mark (mark type)
11802 (beginning-of-line)
11803 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11804 (buffer-read-only nil))
11806 ;; Go to the right position on the line.
11807 (forward-char forward)
11808 ;; Replace the old mark with the new mark.
11809 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11810 ;; Optionally update the marks by some user rule.
11811 (when (eq type 'unread)
11812 (gnus-data-set-mark
11813 (gnus-data-find (gnus-summary-article-number)) mark)
11814 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11816 (defun gnus-mark-article-as-read (article &optional mark)
11817 "Enter ARTICLE in the pertinent lists and remove it from others."
11818 ;; Make the article expirable.
11819 (let ((mark (or mark gnus-del-mark)))
11820 (if (= mark gnus-expirable-mark)
11821 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11822 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11823 ;; Remove from unread and marked lists.
11824 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11825 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11826 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11827 (push (cons article mark) gnus-newsgroup-reads)
11828 ;; Possibly remove from cache, if that is used.
11829 (when gnus-use-cache
11830 (gnus-cache-enter-remove-article article))))
11832 (defun gnus-mark-article-as-unread (article &optional mark)
11833 "Enter ARTICLE in the pertinent lists and remove it from others."
11834 (let ((mark (or mark gnus-ticked-mark)))
11835 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11836 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11837 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11838 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11839 (cond ((= mark gnus-ticked-mark)
11840 (push article gnus-newsgroup-marked))
11841 ((= mark gnus-dormant-mark)
11842 (push article gnus-newsgroup-dormant))
11844 (push article gnus-newsgroup-unreads)))
11845 (setq gnus-newsgroup-reads
11846 (delq (assq article gnus-newsgroup-reads)
11847 gnus-newsgroup-reads))))
11849 (defalias 'gnus-summary-mark-as-unread-forward
11850 'gnus-summary-tick-article-forward)
11851 (make-obsolete 'gnus-summary-mark-as-unread-forward
11852 'gnus-summary-tick-article-forward)
11853 (defun gnus-summary-tick-article-forward (n)
11854 "Tick N articles forwards.
11855 If N is negative, tick backwards instead.
11856 The difference between N and the number of articles ticked is returned."
11858 (gnus-summary-mark-forward n gnus-ticked-mark))
11860 (defalias 'gnus-summary-mark-as-unread-backward
11861 'gnus-summary-tick-article-backward)
11862 (make-obsolete 'gnus-summary-mark-as-unread-backward
11863 'gnus-summary-tick-article-backward)
11864 (defun gnus-summary-tick-article-backward (n)
11865 "Tick N articles backwards.
11866 The difference between N and the number of articles ticked is returned."
11868 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11870 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11871 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11872 (defun gnus-summary-tick-article (&optional article clear-mark)
11873 "Mark current article as unread.
11874 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11875 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11877 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11878 gnus-ticked-mark)))
11880 (defun gnus-summary-mark-as-read-forward (n)
11881 "Mark N articles as read forwards.
11882 If N is negative, mark backwards instead.
11883 The difference between N and the actual number of articles marked is
11886 (gnus-summary-mark-forward n gnus-del-mark t))
11888 (defun gnus-summary-mark-as-read-backward (n)
11889 "Mark the N articles as read backwards.
11890 The difference between N and the actual number of articles marked is
11893 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11895 (defun gnus-summary-mark-as-read (&optional article mark)
11896 "Mark current article as read.
11897 ARTICLE specifies the article to be marked as read.
11898 MARK specifies a string to be inserted at the beginning of the line."
11899 (gnus-summary-mark-article article mark))
11901 (defun gnus-summary-clear-mark-forward (n)
11902 "Clear marks from N articles forward.
11903 If N is negative, clear backward instead.
11904 The difference between N and the number of marks cleared is returned."
11906 (gnus-summary-mark-forward n gnus-unread-mark))
11908 (defun gnus-summary-clear-mark-backward (n)
11909 "Clear marks from N articles backward.
11910 The difference between N and the number of marks cleared is returned."
11912 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11914 (defun gnus-summary-mark-unread-as-read ()
11915 "Intended to be used by `gnus-summary-mark-article-hook'."
11916 (when (memq gnus-current-article gnus-newsgroup-unreads)
11917 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11919 (defun gnus-summary-mark-unread-and-read-as-read ()
11920 "Intended to be used by `gnus-summary-mark-article-hook'."
11921 (let ((mark (gnus-summary-article-mark)))
11922 (when (or (gnus-unread-mark-p mark)
11923 (gnus-read-mark-p mark))
11924 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11926 (defun gnus-summary-mark-region-as-read (point mark all)
11927 "Mark all unread articles between point and mark as read.
11928 If given a prefix, mark all articles between point and mark as read,
11929 even ticked and dormant ones."
11930 (interactive "r\nP")
11934 (beginning-of-line)
11939 (memq (setq article (gnus-summary-article-number))
11940 gnus-newsgroup-unreads))
11941 (gnus-summary-mark-article article gnus-del-mark))
11943 (gnus-summary-find-next))))))
11945 (defun gnus-summary-mark-below (score mark)
11946 "Mark articles with score less than SCORE with MARK."
11947 (interactive "P\ncMark: ")
11948 (gnus-set-global-variables)
11949 (setq score (if score
11950 (prefix-numeric-value score)
11951 (or gnus-summary-default-score 0)))
11953 (set-buffer gnus-summary-buffer)
11954 (goto-char (point-min))
11957 (and (< (gnus-summary-article-score) score)
11958 (gnus-summary-mark-article nil mark))
11959 (gnus-summary-find-next)))))
11961 (defun gnus-summary-kill-below (&optional score)
11962 "Mark articles with score below SCORE as read."
11964 (gnus-set-global-variables)
11965 (gnus-summary-mark-below score gnus-killed-mark))
11967 (defun gnus-summary-clear-above (&optional score)
11968 "Clear all marks from articles with score above SCORE."
11970 (gnus-set-global-variables)
11971 (gnus-summary-mark-above score gnus-unread-mark))
11973 (defun gnus-summary-tick-above (&optional score)
11974 "Tick all articles with score above SCORE."
11976 (gnus-set-global-variables)
11977 (gnus-summary-mark-above score gnus-ticked-mark))
11979 (defun gnus-summary-mark-above (score mark)
11980 "Mark articles with score over SCORE with MARK."
11981 (interactive "P\ncMark: ")
11982 (gnus-set-global-variables)
11983 (setq score (if score
11984 (prefix-numeric-value score)
11985 (or gnus-summary-default-score 0)))
11987 (set-buffer gnus-summary-buffer)
11988 (goto-char (point-min))
11990 (if (> (gnus-summary-article-score) score)
11991 (gnus-summary-mark-article nil mark))
11993 (gnus-summary-find-next)))))
11995 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11996 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11997 (defun gnus-summary-limit-include-expunged ()
11998 "Display all the hidden articles that were expunged for low scores."
12000 (gnus-set-global-variables)
12001 (let ((buffer-read-only nil))
12002 (let ((scored gnus-newsgroup-scored)
12005 (or (gnus-summary-goto-subject (car (car scored)))
12006 (and (setq h (gnus-summary-article-header (car (car scored))))
12007 (< (cdr (car scored)) gnus-summary-expunge-below)
12008 (setq headers (cons h headers))))
12009 (setq scored (cdr scored)))
12010 (or headers (error "No expunged articles hidden."))
12011 (goto-char (point-min))
12012 (gnus-summary-prepare-unthreaded (nreverse headers)))
12013 (goto-char (point-min))
12014 (gnus-summary-position-point)))
12016 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12017 "Mark all articles not marked as unread in this newsgroup as read.
12018 If prefix argument ALL is non-nil, all articles are marked as read.
12019 If QUIETLY is non-nil, no questions will be asked.
12020 If TO-HERE is non-nil, it should be a point in the buffer. All
12021 articles before this point will be marked as read.
12022 The number of articles marked as read is returned."
12024 (gnus-set-global-variables)
12027 (not gnus-interactive-catchup) ;Without confirmation?
12031 "Mark absolutely all articles as read? "
12032 "Mark all unread articles as read? ")))
12034 (not gnus-newsgroup-adaptive)
12035 (not gnus-newsgroup-auto-expire))
12038 (setq gnus-newsgroup-marked nil
12039 gnus-newsgroup-dormant nil))
12040 (setq gnus-newsgroup-unreads nil))
12041 ;; We actually mark all articles as canceled, which we
12042 ;; have to do when using auto-expiry or adaptive scoring.
12043 (gnus-summary-show-all-threads)
12044 (if (gnus-summary-first-subject (not all))
12046 (if to-here (< (point) to-here) t)
12047 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12048 (gnus-summary-find-next (not all)))))
12050 (setq gnus-newsgroup-unreads nil))
12051 (gnus-set-mode-line 'summary)))
12052 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12053 (if (and (not to-here) (eq 'nnvirtual (car method)))
12054 (nnvirtual-catchup-group
12055 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12056 (gnus-summary-position-point)))
12058 (defun gnus-summary-catchup-to-here (&optional all)
12059 "Mark all unticked articles before the current one as read.
12060 If ALL is non-nil, also mark ticked and dormant articles as read."
12062 (gnus-set-global-variables)
12064 (let ((beg (point)))
12065 ;; We check that there are unread articles.
12066 (when (or all (gnus-summary-find-prev))
12067 (gnus-summary-catchup all t beg))))
12068 (gnus-summary-position-point))
12070 (defun gnus-summary-catchup-all (&optional quietly)
12071 "Mark all articles in this newsgroup as read."
12073 (gnus-set-global-variables)
12074 (gnus-summary-catchup t quietly))
12076 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12077 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12078 If prefix argument ALL is non-nil, all articles are marked as read."
12080 (gnus-set-global-variables)
12081 (gnus-summary-catchup all quietly nil 'fast)
12082 ;; Select next newsgroup or exit.
12083 (if (eq gnus-auto-select-next 'quietly)
12084 (gnus-summary-next-group nil)
12085 (gnus-summary-exit)))
12087 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12088 "Mark all articles in this newsgroup as read, and then exit."
12090 (gnus-set-global-variables)
12091 (gnus-summary-catchup-and-exit t quietly))
12093 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12094 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12095 "Mark all articles in this group as read and select the next group.
12096 If given a prefix, mark all articles, unread as well as ticked, as
12099 (gnus-set-global-variables)
12101 (gnus-summary-catchup all))
12102 (gnus-summary-next-article t nil nil t))
12104 ;; Thread-based commands.
12106 (defun gnus-summary-articles-in-thread (&optional article)
12107 "Return a list of all articles in the current thread.
12108 If ARTICLE is non-nil, return all articles in the thread that starts
12109 with that article."
12110 (let* ((article (or article (gnus-summary-article-number)))
12111 (data (gnus-data-find-list article))
12112 (top-level (gnus-data-level (car data)))
12114 (cond ((null gnus-thread-operation-ignore-subject)
12115 (gnus-simplify-subject-re
12116 (mail-header-subject (gnus-data-header (car data)))))
12117 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12118 (gnus-simplify-subject-fuzzy
12119 (mail-header-subject (gnus-data-header (car data)))))
12123 () ; This article doesn't exist.
12125 (and (or (not top-subject)
12126 (string= top-subject
12127 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12128 (gnus-simplify-subject-fuzzy
12129 (mail-header-subject
12130 (gnus-data-header (car data))))
12131 (gnus-simplify-subject-re
12132 (mail-header-subject
12133 (gnus-data-header (car data)))))))
12134 (setq articles (cons (gnus-data-number (car data)) articles)))
12135 (if (and (setq data (cdr data))
12136 (> (gnus-data-level (car data)) top-level))
12139 ;; Return the list of articles.
12140 (nreverse articles))))
12142 (defun gnus-summary-rethread-current ()
12143 "Rethread the thread the current article is part of."
12145 (gnus-set-global-variables)
12146 (let* ((gnus-show-threads t)
12147 (article (gnus-summary-article-number))
12148 (id (mail-header-id (gnus-summary-article-header)))
12149 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12151 (error "No article on the current line"))
12152 (gnus-rebuild-thread id)
12153 (gnus-summary-goto-subject article)))
12155 (defun gnus-summary-reparent-thread ()
12156 "Make current article child of the marked (or previous) article.
12158 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12159 is non-nil or the Subject: of both articles are the same."
12161 (or (not (gnus-group-read-only-p))
12162 (error "The current newsgroup does not support article editing."))
12163 (or (<= (length gnus-newsgroup-processable) 1)
12164 (error "No more than one article may be marked."))
12165 (save-window-excursion
12166 (let ((gnus-article-buffer " *reparent*")
12167 (current-article (gnus-summary-article-number))
12168 ; first grab the marked article, otherwise one line up.
12169 (parent-article (if (not (null gnus-newsgroup-processable))
12170 (car gnus-newsgroup-processable)
12172 (if (eq (forward-line -1) 0)
12173 (gnus-summary-article-number)
12174 (error "Beginning of summary buffer."))))))
12175 (or (not (eq current-article parent-article))
12176 (error "An article may not be self-referential."))
12177 (let ((message-id (mail-header-id
12178 (gnus-summary-article-header parent-article))))
12179 (or (and message-id (not (equal message-id "")))
12180 (error "No message-id in desired parent."))
12181 (gnus-summary-select-article t t nil current-article)
12182 (set-buffer gnus-article-buffer)
12183 (setq buffer-read-only nil)
12184 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
12187 (goto-char (point-min))
12188 (if (search-forward-regexp "^References: " nil t)
12189 (insert message-id " " )
12190 (insert "References: " message-id "\n"))
12191 (or (gnus-request-replace-article current-article
12192 (car gnus-article-current)
12193 gnus-article-buffer)
12194 (error "Couldn't replace article."))
12195 (set-buffer gnus-summary-buffer)
12196 (gnus-summary-unmark-all-processable)
12197 (gnus-summary-rethread-current)
12198 (message "Article %d is now the child of article %d."
12199 current-article parent-article)))))
12201 (defun gnus-summary-toggle-threads (&optional arg)
12202 "Toggle showing conversation threads.
12203 If ARG is positive number, turn showing conversation threads on."
12205 (gnus-set-global-variables)
12206 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12207 (setq gnus-show-threads
12208 (if (null arg) (not gnus-show-threads)
12209 (> (prefix-numeric-value arg) 0)))
12210 (gnus-summary-prepare)
12211 (gnus-summary-goto-subject current)
12212 (gnus-summary-position-point)))
12214 (defun gnus-summary-show-all-threads ()
12215 "Show all threads."
12217 (gnus-set-global-variables)
12219 (let ((buffer-read-only nil))
12220 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12221 (gnus-summary-position-point))
12223 (defun gnus-summary-show-thread ()
12224 "Show thread subtrees.
12225 Returns nil if no thread was there to be shown."
12227 (gnus-set-global-variables)
12228 (let ((buffer-read-only nil)
12230 ;; first goto end then to beg, to have point at beg after let
12231 (end (progn (end-of-line) (point)))
12232 (beg (progn (beginning-of-line) (point))))
12234 ;; Any hidden lines here?
12235 (search-forward "\r" end t)
12236 (subst-char-in-region beg end ?\^M ?\n t)
12238 (gnus-summary-position-point))))
12240 (defun gnus-summary-hide-all-threads ()
12241 "Hide all thread subtrees."
12243 (gnus-set-global-variables)
12245 (goto-char (point-min))
12246 (gnus-summary-hide-thread)
12247 (while (zerop (gnus-summary-next-thread 1 t))
12248 (gnus-summary-hide-thread)))
12249 (gnus-summary-position-point))
12251 (defun gnus-summary-hide-thread ()
12252 "Hide thread subtrees.
12253 Returns nil if no threads were there to be hidden."
12255 (gnus-set-global-variables)
12256 (let ((buffer-read-only nil)
12258 (article (gnus-summary-article-number))
12261 ;; Go forward until either the buffer ends or the subthread
12263 (when (and (not (eobp))
12264 (or (zerop (gnus-summary-next-thread 1 t))
12265 (goto-char (point-max))))
12268 (if (and (> (point) start)
12269 (search-backward "\n" start t))
12271 (subst-char-in-region start (point) ?\n ?\^M)
12272 (gnus-summary-goto-subject article))
12275 (gnus-summary-position-point)))))
12277 (defun gnus-summary-go-to-next-thread (&optional previous)
12278 "Go to the same level (or less) next thread.
12279 If PREVIOUS is non-nil, go to previous thread instead.
12280 Return the article number moved to, or nil if moving was impossible."
12281 (let* ((level (gnus-summary-thread-level))
12282 (article (gnus-summary-article-number))
12283 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12286 (if (<= (gnus-data-level (car data)) level)
12287 (setq oart (gnus-data-number (car data))
12289 (setq data (cdr data))))
12291 (gnus-summary-goto-subject oart))))
12293 (defun gnus-summary-next-thread (n &optional silent)
12294 "Go to the same level next N'th thread.
12295 If N is negative, search backward instead.
12296 Returns the difference between N and the number of skips actually
12299 If SILENT, don't output messages."
12301 (gnus-set-global-variables)
12302 (let ((backward (< n 0))
12305 (while (and (> n 0)
12306 (setq old (save-excursion (forward-line 1) (point)))
12307 (gnus-summary-go-to-next-thread backward))
12308 (when (and (eq gnus-summary-make-false-root 'dummy)
12309 (setq dum (text-property-not-all
12310 old (point) 'gnus-intangible nil)))
12313 (gnus-summary-position-point)
12314 (when (and (not silent) (/= 0 n))
12315 (gnus-message 7 "No more threads"))
12318 (defun gnus-summary-prev-thread (n)
12319 "Go to the same level previous N'th thread.
12320 Returns the difference between N and the number of skips actually
12323 (gnus-set-global-variables)
12324 (gnus-summary-next-thread (- n)))
12326 (defun gnus-summary-go-down-thread ()
12327 "Go down one level in the current thread."
12328 (let ((children (gnus-summary-article-children)))
12330 (gnus-summary-goto-subject (car children)))))
12332 (defun gnus-summary-go-up-thread ()
12333 "Go up one level in the current thread."
12334 (let ((parent (gnus-summary-article-parent)))
12336 (gnus-summary-goto-subject parent))))
12338 (defun gnus-summary-down-thread (n)
12339 "Go down thread N steps.
12340 If N is negative, go up instead.
12341 Returns the difference between N and how many steps down that were
12344 (gnus-set-global-variables)
12347 (while (and (> n 0)
12348 (if up (gnus-summary-go-up-thread)
12349 (gnus-summary-go-down-thread)))
12351 (gnus-summary-position-point)
12352 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12355 (defun gnus-summary-up-thread (n)
12356 "Go up thread N steps.
12357 If N is negative, go up instead.
12358 Returns the difference between N and how many steps down that were
12361 (gnus-set-global-variables)
12362 (gnus-summary-down-thread (- n)))
12364 (defun gnus-summary-top-thread ()
12365 "Go to the top of the thread."
12367 (gnus-set-global-variables)
12368 (while (gnus-summary-go-up-thread))
12369 (gnus-summary-article-number))
12371 (defun gnus-summary-kill-thread (&optional unmark)
12372 "Mark articles under current thread as read.
12373 If the prefix argument is positive, remove any kinds of marks.
12374 If the prefix argument is negative, tick articles instead."
12376 (gnus-set-global-variables)
12378 (setq unmark (prefix-numeric-value unmark)))
12379 (let ((articles (gnus-summary-articles-in-thread)))
12381 ;; Expand the thread.
12382 (gnus-summary-show-thread)
12383 ;; Mark all the articles.
12385 (gnus-summary-goto-subject (car articles))
12386 (cond ((null unmark)
12387 (gnus-summary-mark-article-as-read gnus-killed-mark))
12389 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12391 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12392 (setq articles (cdr articles))))
12393 ;; Hide killed subtrees.
12395 gnus-thread-hide-killed
12396 (gnus-summary-hide-thread))
12397 ;; If marked as read, go to next unread subject.
12399 ;; Go to next unread subject.
12400 (gnus-summary-next-subject 1 t)))
12401 (gnus-set-mode-line 'summary))
12403 ;; Summary sorting commands
12405 (defun gnus-summary-sort-by-number (&optional reverse)
12406 "Sort summary buffer by article number.
12407 Argument REVERSE means reverse order."
12409 (gnus-summary-sort 'number reverse))
12411 (defun gnus-summary-sort-by-author (&optional reverse)
12412 "Sort summary buffer by author name alphabetically.
12413 If case-fold-search is non-nil, case of letters is ignored.
12414 Argument REVERSE means reverse order."
12416 (gnus-summary-sort 'author reverse))
12418 (defun gnus-summary-sort-by-subject (&optional reverse)
12419 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12420 If case-fold-search is non-nil, case of letters is ignored.
12421 Argument REVERSE means reverse order."
12423 (gnus-summary-sort 'subject reverse))
12425 (defun gnus-summary-sort-by-date (&optional reverse)
12426 "Sort summary buffer by date.
12427 Argument REVERSE means reverse order."
12429 (gnus-summary-sort 'date reverse))
12431 (defun gnus-summary-sort-by-score (&optional reverse)
12432 "Sort summary buffer by score.
12433 Argument REVERSE means reverse order."
12435 (gnus-summary-sort 'score reverse))
12437 (defun gnus-summary-sort (predicate reverse)
12438 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12439 (gnus-set-global-variables)
12440 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12441 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12442 (gnus-thread-sort-functions
12447 (,thread t2 t1)))))
12448 (gnus-article-sort-functions
12453 (,article t2 t1)))))
12455 (gnus-summary-prepare-hook nil))
12456 ;; We do the sorting by regenerating the threads.
12457 (gnus-summary-prepare)
12458 ;; Hide subthreads if needed.
12459 (when (and gnus-show-threads gnus-thread-hide-subtree)
12460 (gnus-summary-hide-all-threads)))
12461 ;; If in async mode, we send some info to the backend.
12462 (when gnus-newsgroup-async
12463 (gnus-request-asynchronous
12464 gnus-newsgroup-name gnus-newsgroup-data)))
12466 (defun gnus-sortable-date (date)
12467 "Make sortable string by string-lessp from DATE.
12468 Timezone package is used."
12469 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12470 (year (aref date 0))
12471 (month (aref date 1))
12472 (day (aref date 2)))
12473 (timezone-make-sortable-date
12475 (timezone-make-time-string
12476 (aref date 3) (aref date 4) (aref date 5)))))
12478 ;; Summary saving commands.
12480 (defun gnus-summary-save-article (&optional n not-saved)
12481 "Save the current article using the default saver function.
12482 If N is a positive number, save the N next articles.
12483 If N is a negative number, save the N previous articles.
12484 If N is nil and any articles have been marked with the process mark,
12485 save those articles instead.
12486 The variable `gnus-default-article-saver' specifies the saver function."
12488 (gnus-set-global-variables)
12489 (let ((articles (gnus-summary-work-articles n))
12490 file header article)
12492 (setq header (gnus-summary-article-header
12493 (setq article (pop articles))))
12494 (if (not (vectorp header))
12495 ;; This is a pseudo-article.
12496 (if (assq 'name header)
12497 (gnus-copy-file (cdr (assq 'name header)))
12498 (gnus-message 1 "Article %d is unsaveable" article))
12499 ;; This is a real article.
12500 (save-window-excursion
12501 (gnus-summary-select-article t nil nil article))
12502 (unless gnus-save-all-headers
12503 ;; Remove headers accoring to `gnus-saved-headers'.
12504 (let ((gnus-visible-headers
12505 (or gnus-saved-headers gnus-visible-headers)))
12506 (gnus-article-hide-headers nil t)))
12507 ;; Remove any X-Gnus lines.
12509 (set-buffer gnus-article-buffer)
12511 (let ((buffer-read-only nil))
12512 (nnheader-narrow-to-headers)
12513 (while (re-search-forward "^X-Gnus" nil t)
12514 (gnus-delete-line)))))
12515 (save-window-excursion
12516 (if (not gnus-default-article-saver)
12517 (error "No default saver is defined.")
12518 (setq file (funcall
12519 gnus-default-article-saver
12521 ((not gnus-prompt-before-saving)
12523 ((eq gnus-prompt-before-saving 'always)
12526 (gnus-summary-remove-process-mark article)
12528 (gnus-summary-set-saved-mark article))))
12529 (gnus-summary-position-point)
12532 (defun gnus-summary-pipe-output (&optional arg)
12533 "Pipe the current article to a subprocess.
12534 If N is a positive number, pipe the N next articles.
12535 If N is a negative number, pipe the N previous articles.
12536 If N is nil and any articles have been marked with the process mark,
12537 pipe those articles instead."
12539 (gnus-set-global-variables)
12540 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12541 (gnus-summary-save-article arg t))
12542 (gnus-configure-windows 'pipe))
12544 (defun gnus-summary-save-article-mail (&optional arg)
12545 "Append the current article to an mail file.
12546 If N is a positive number, save the N next articles.
12547 If N is a negative number, save the N previous articles.
12548 If N is nil and any articles have been marked with the process mark,
12549 save those articles instead."
12551 (gnus-set-global-variables)
12552 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12553 (gnus-summary-save-article arg)))
12555 (defun gnus-summary-save-article-rmail (&optional arg)
12556 "Append the current article to an rmail file.
12557 If N is a positive number, save the N next articles.
12558 If N is a negative number, save the N previous articles.
12559 If N is nil and any articles have been marked with the process mark,
12560 save those articles instead."
12562 (gnus-set-global-variables)
12563 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12564 (gnus-summary-save-article arg)))
12566 (defun gnus-summary-save-article-file (&optional arg)
12567 "Append the current article to a file.
12568 If N is a positive number, save the N next articles.
12569 If N is a negative number, save the N previous articles.
12570 If N is nil and any articles have been marked with the process mark,
12571 save those articles instead."
12573 (gnus-set-global-variables)
12574 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12575 (gnus-summary-save-article arg)))
12577 (defun gnus-summary-save-article-body-file (&optional arg)
12578 "Append the current article body to a file.
12579 If N is a positive number, save the N next articles.
12580 If N is a negative number, save the N previous articles.
12581 If N is nil and any articles have been marked with the process mark,
12582 save those articles instead."
12584 (gnus-set-global-variables)
12585 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12586 (gnus-summary-save-article arg)))
12588 (defun gnus-get-split-value (methods)
12589 "Return a value based on the split METHODS."
12590 (let (split-name method result match)
12593 (set-buffer gnus-original-article-buffer)
12595 (nnheader-narrow-to-headers)
12597 (goto-char (point-min))
12598 (setq method (pop methods))
12599 (setq match (pop method))
12602 ;; Regular expression.
12604 (re-search-forward match nil t)
12606 ((gnus-functionp match)
12610 (setq result (funcall match gnus-newsgroup-name))))
12615 (setq result (eval match)))))
12616 (setq split-name (append (cdr methods) split-name))
12617 (cond ((stringp result)
12618 (push result split-name))
12620 (setq split-name (append result split-name)))))))))
12623 (defun gnus-read-move-group-name (prompt default articles prefix)
12624 "Read a group name."
12625 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12627 (format "Where do you want to %s %s? "
12629 (if (> (length articles) 1)
12630 (format "these %d articles" (length articles))
12638 (format "(default %s) " default)
12640 gnus-active-hashtb nil nil prefix))
12641 ((= 1 (length split-name))
12642 (completing-read prom gnus-active-hashtb
12643 nil nil (cons (car split-name) 0)))
12646 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12649 (if (or (string= to-newsgroup "")
12650 (string= to-newsgroup prefix))
12651 (setq to-newsgroup (or default "")))
12652 (or (gnus-active to-newsgroup)
12653 (gnus-activate-group to-newsgroup)
12654 (error "No such group: %s" to-newsgroup)))
12657 (defun gnus-read-save-file-name (prompt default-name)
12658 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12660 ;; Let the split methods have their say.
12662 ;; No split name was found.
12665 (concat prompt " (default "
12666 (file-name-nondirectory default-name) ") ")
12667 (file-name-directory default-name)
12669 ;; A single split name was found
12670 ((= 1 (length split-name))
12672 (concat prompt " (default " (car split-name) ") ")
12673 gnus-article-save-directory
12674 (concat gnus-article-save-directory (car split-name))))
12675 ;; A list of splits was found.
12677 (setq split-name (mapcar (lambda (el) (list el))
12678 (nreverse split-name)))
12679 (let ((result (completing-read
12680 (concat prompt " ") split-name nil nil)))
12681 (concat gnus-article-save-directory
12682 (if (string= result "")
12683 (car (car split-name))
12685 ;; If we have read a directory, we append the default file name.
12686 (when (file-directory-p file)
12687 (setq file (concat (file-name-as-directory file)
12688 (file-name-nondirectory default-name))))
12689 ;; Possibly translate some charaters.
12690 (nnheader-translate-file-chars file)))
12692 (defun gnus-article-archive-name (group)
12693 "Return the first instance of an \"Archive-name\" in the current buffer."
12694 (let ((case-fold-search t))
12695 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12696 (match-string 1))))
12698 (defun gnus-summary-save-in-rmail (&optional filename)
12699 "Append this article to Rmail file.
12700 Optional argument FILENAME specifies file name.
12701 Directory to save to is default to `gnus-article-save-directory' which
12702 is initialized from the SAVEDIR environment variable."
12704 (gnus-set-global-variables)
12705 (let ((default-name
12706 (funcall gnus-rmail-save-name gnus-newsgroup-name
12707 gnus-current-headers gnus-newsgroup-last-rmail)))
12709 (cond ((eq filename 'default)
12711 (filename filename)
12712 (t (gnus-read-save-file-name
12713 "Save in rmail file:" default-name))))
12714 (gnus-make-directory (file-name-directory filename))
12715 (gnus-eval-in-buffer-window
12716 gnus-original-article-buffer
12720 (gnus-output-to-rmail filename))))
12721 ;; Remember the directory name to save articles
12722 (setq gnus-newsgroup-last-rmail filename)))
12724 (defun gnus-summary-save-in-mail (&optional filename)
12725 "Append this article to Unix mail file.
12726 Optional argument FILENAME specifies file name.
12727 Directory to save to is default to `gnus-article-save-directory' which
12728 is initialized from the SAVEDIR environment variable."
12730 (gnus-set-global-variables)
12731 (let ((default-name
12732 (funcall gnus-mail-save-name gnus-newsgroup-name
12733 gnus-current-headers gnus-newsgroup-last-mail)))
12735 (cond ((eq filename 'default)
12737 (filename filename)
12738 (t (gnus-read-save-file-name
12739 "Save in Unix mail file:" default-name))))
12741 (expand-file-name filename
12743 (file-name-directory default-name))))
12744 (gnus-make-directory (file-name-directory filename))
12745 (gnus-eval-in-buffer-window
12746 gnus-original-article-buffer
12750 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12751 (gnus-output-to-rmail filename)
12752 (let ((mail-use-rfc822 t))
12753 (rmail-output filename 1 t t))))))
12754 ;; Remember the directory name to save articles.
12755 (setq gnus-newsgroup-last-mail filename)))
12757 (defun gnus-summary-save-in-file (&optional filename)
12758 "Append this article to file.
12759 Optional argument FILENAME specifies file name.
12760 Directory to save to is default to `gnus-article-save-directory' which
12761 is initialized from the SAVEDIR environment variable."
12763 (gnus-set-global-variables)
12764 (let ((default-name
12765 (funcall gnus-file-save-name gnus-newsgroup-name
12766 gnus-current-headers gnus-newsgroup-last-file)))
12768 (cond ((eq filename 'default)
12770 (filename filename)
12771 (t (gnus-read-save-file-name
12772 "Save in file:" default-name))))
12773 (gnus-make-directory (file-name-directory filename))
12774 (gnus-eval-in-buffer-window
12775 gnus-original-article-buffer
12779 (gnus-output-to-file filename))))
12780 ;; Remember the directory name to save articles.
12781 (setq gnus-newsgroup-last-file filename)))
12783 (defun gnus-summary-save-body-in-file (&optional filename)
12784 "Append this article body to a file.
12785 Optional argument FILENAME specifies file name.
12786 The directory to save in defaults to `gnus-article-save-directory' which
12787 is initialized from the SAVEDIR environment variable."
12789 (gnus-set-global-variables)
12790 (let ((default-name
12791 (funcall gnus-file-save-name gnus-newsgroup-name
12792 gnus-current-headers gnus-newsgroup-last-file)))
12794 (cond ((eq filename 'default)
12796 (filename filename)
12797 (t (gnus-read-save-file-name
12798 "Save body in file:" default-name))))
12799 (gnus-make-directory (file-name-directory filename))
12800 (gnus-eval-in-buffer-window
12801 gnus-article-buffer
12805 (goto-char (point-min))
12806 (and (search-forward "\n\n" nil t)
12807 (narrow-to-region (point) (point-max)))
12808 (gnus-output-to-file filename))))
12809 ;; Remember the directory name to save articles.
12810 (setq gnus-newsgroup-last-file filename)))
12812 (defun gnus-summary-save-in-pipe (&optional command)
12813 "Pipe this article to subprocess."
12815 (gnus-set-global-variables)
12817 (cond ((eq command 'default)
12818 gnus-last-shell-command)
12820 (t (read-string "Shell command on article: "
12821 gnus-last-shell-command))))
12822 (if (string-equal command "")
12823 (setq command gnus-last-shell-command))
12824 (gnus-eval-in-buffer-window
12825 gnus-article-buffer
12828 (shell-command-on-region (point-min) (point-max) command nil)))
12829 (setq gnus-last-shell-command command))
12831 ;; Summary extract commands
12833 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12834 (let ((buffer-read-only nil)
12835 (article (gnus-summary-article-number))
12837 (or (gnus-summary-goto-subject article)
12838 (error (format "No such article: %d" article)))
12839 (gnus-summary-position-point)
12840 ;; If all commands are to be bunched up on one line, we collect
12842 (if gnus-view-pseudos-separately
12844 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12847 (setq action (cdr (assq 'action (car ps))))
12848 (setq files (list (cdr (assq 'name (car ps)))))
12849 (while (and ps (cdr ps)
12850 (string= (or action "1")
12851 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12852 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12853 (setcdr ps (cdr (cdr ps))))
12856 (if (not (string-match "%s" action))
12857 (setq files (cons " " files)))
12858 (setq files (cons " " files))
12859 (and (assq 'execute (car ps))
12860 (setcdr (assq 'execute (car ps))
12861 (funcall (if (string-match "%s" action)
12864 (mapconcat (lambda (f) f) files " ")))))
12865 (setq ps (cdr ps)))))
12866 (if (and gnus-view-pseudos (not not-view))
12868 (and (assq 'execute (car pslist))
12869 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12870 (eq gnus-view-pseudos 'not-confirm)))
12871 (setq pslist (cdr pslist)))
12874 (setq after-article (or (cdr (assq 'article (car pslist)))
12875 (gnus-summary-article-number)))
12876 (gnus-summary-goto-subject after-article)
12879 (insert " " (file-name-nondirectory
12880 (cdr (assq 'name (car pslist))))
12881 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12883 (forward-line -1) ; back to `b'
12884 (add-text-properties
12885 b e (list 'gnus-number gnus-reffed-article-number
12886 gnus-mouse-face-prop gnus-mouse-face))
12888 after-article gnus-reffed-article-number
12889 gnus-unread-mark b (car pslist) 0 (- e b))
12890 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12891 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12892 (setq pslist (cdr pslist)))))))
12894 (defun gnus-pseudos< (p1 p2)
12895 (let ((c1 (cdr (assq 'action p1)))
12896 (c2 (cdr (assq 'action p2))))
12897 (and c1 c2 (string< c1 c2))))
12899 (defun gnus-request-pseudo-article (props)
12900 (cond ((assq 'execute props)
12901 (gnus-execute-command (cdr (assq 'execute props)))))
12902 (let ((gnus-current-article (gnus-summary-article-number)))
12903 (run-hooks 'gnus-mark-article-hook)))
12905 (defun gnus-execute-command (command &optional automatic)
12907 (gnus-article-setup-buffer)
12908 (set-buffer gnus-article-buffer)
12909 (let ((command (if automatic command (read-string "Command: " command)))
12910 (buffer-read-only nil))
12912 (insert "$ " command "\n\n")
12913 (if gnus-view-pseudo-asynchronously
12914 (start-process "gnus-execute" nil "sh" "-c" command)
12915 (call-process "sh" nil t nil "-c" command)))))
12917 (defun gnus-copy-file (file &optional to)
12920 (list (read-file-name "Copy file: " default-directory)
12921 (read-file-name "Copy file to: " default-directory)))
12922 (gnus-set-global-variables)
12923 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12924 (and (file-directory-p to)
12925 (setq to (concat (file-name-as-directory to)
12926 (file-name-nondirectory file))))
12927 (copy-file file to))
12929 ;; Summary kill commands.
12931 (defun gnus-summary-edit-global-kill (article)
12932 "Edit the \"global\" kill file."
12933 (interactive (list (gnus-summary-article-number)))
12934 (gnus-set-global-variables)
12935 (gnus-group-edit-global-kill article))
12937 (defun gnus-summary-edit-local-kill ()
12938 "Edit a local kill file applied to the current newsgroup."
12940 (gnus-set-global-variables)
12941 (setq gnus-current-headers (gnus-summary-article-header))
12942 (gnus-set-global-variables)
12943 (gnus-group-edit-local-kill
12944 (gnus-summary-article-number) gnus-newsgroup-name))
12948 ;;; Gnus article mode
12951 (put 'gnus-article-mode 'mode-class 'special)
12953 (if gnus-article-mode-map
12955 (setq gnus-article-mode-map (make-keymap))
12956 (suppress-keymap gnus-article-mode-map)
12959 gnus-article-mode-map
12960 " " gnus-article-goto-next-page
12961 "\177" gnus-article-goto-prev-page
12962 [delete] gnus-article-goto-prev-page
12963 "\C-c^" gnus-article-refer-article
12964 "h" gnus-article-show-summary
12965 "s" gnus-article-show-summary
12966 "\C-c\C-m" gnus-article-mail
12967 "?" gnus-article-describe-briefly
12968 gnus-mouse-2 gnus-article-push-button
12969 "\r" gnus-article-press-button
12970 "\t" gnus-article-next-button
12971 "\M-\t" gnus-article-prev-button
12972 "\C-c\C-b" gnus-bug)
12974 (substitute-key-definition
12975 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
12977 (defun gnus-article-mode ()
12978 "Major mode for displaying an article.
12980 All normal editing commands are switched off.
12982 The following commands are available:
12984 \\<gnus-article-mode-map>
12985 \\[gnus-article-next-page]\t Scroll the article one page forwards
12986 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12987 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12988 \\[gnus-article-show-summary]\t Display the summary buffer
12989 \\[gnus-article-mail]\t Send a reply to the address near point
12990 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
12991 \\[gnus-info-find-node]\t Go to the Gnus info node"
12993 (when (and menu-bar-mode
12994 (gnus-visual-p 'article-menu 'menu))
12995 (gnus-article-make-menu-bar))
12996 (kill-all-local-variables)
12997 (gnus-simplify-mode-line)
12998 (setq mode-name "Article")
12999 (setq major-mode 'gnus-article-mode)
13000 (make-local-variable 'minor-mode-alist)
13001 (or (assq 'gnus-show-mime minor-mode-alist)
13002 (setq minor-mode-alist
13003 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13004 (use-local-map gnus-article-mode-map)
13005 (make-local-variable 'page-delimiter)
13006 (setq page-delimiter gnus-page-delimiter)
13007 (buffer-disable-undo (current-buffer))
13008 (setq buffer-read-only t) ;Disable modification
13009 (run-hooks 'gnus-article-mode-hook))
13011 (defun gnus-article-setup-buffer ()
13012 "Initialize the article buffer."
13013 (let* ((name (if gnus-single-article-buffer "*Article*"
13014 (concat "*Article " gnus-newsgroup-name "*")))
13016 (progn (string-match "\\*Article" name)
13017 (concat " *Original Article"
13018 (substring name (match-end 0))))))
13019 (setq gnus-article-buffer name)
13020 (setq gnus-original-article-buffer original)
13021 ;; This might be a variable local to the summary buffer.
13022 (unless gnus-single-article-buffer
13024 (set-buffer gnus-summary-buffer)
13025 (setq gnus-article-buffer name)
13026 (setq gnus-original-article-buffer original)
13027 (gnus-set-global-variables))
13028 (make-local-variable 'gnus-summary-buffer))
13029 (if (get-buffer name)
13032 (buffer-disable-undo (current-buffer))
13033 (setq buffer-read-only t)
13034 (gnus-add-current-to-buffer-list)
13035 (or (eq major-mode 'gnus-article-mode)
13036 (gnus-article-mode))
13039 (set-buffer (get-buffer-create name))
13040 (gnus-add-current-to-buffer-list)
13041 (gnus-article-mode)
13042 (current-buffer)))))
13044 ;; Set article window start at LINE, where LINE is the number of lines
13045 ;; from the head of the article.
13046 (defun gnus-article-set-window-start (&optional line)
13048 (get-buffer-window gnus-article-buffer)
13050 (set-buffer gnus-article-buffer)
13051 (goto-char (point-min))
13054 (gnus-message 6 "Moved to bookmark")
13055 (search-forward "\n\n" nil t)
13056 (forward-line line)
13059 (defun gnus-kill-all-overlays ()
13060 "Delete all overlays in the current buffer."
13061 (when (fboundp 'overlay-lists)
13062 (let* ((overlayss (overlay-lists))
13063 (buffer-read-only nil)
13064 (overlays (nconc (car overlayss) (cdr overlayss))))
13066 (delete-overlay (pop overlays))))))
13068 (defun gnus-request-article-this-buffer (article group)
13069 "Get an article and insert it into this buffer."
13073 (gnus-kill-all-overlays)
13074 (setq group (or group gnus-newsgroup-name))
13076 ;; Open server if it has closed.
13077 (gnus-check-server (gnus-find-method-for-group group))
13079 ;; Using `gnus-request-article' directly will insert the article into
13080 ;; `nntp-server-buffer' - so we'll save some time by not having to
13081 ;; copy it from the server buffer into the article buffer.
13083 ;; We only request an article by message-id when we do not have the
13084 ;; headers for it, so we'll have to get those.
13085 (when (stringp article)
13086 (let ((gnus-override-method gnus-refer-article-method))
13087 (gnus-read-header article)))
13089 ;; If the article number is negative, that means that this article
13090 ;; doesn't belong in this newsgroup (possibly), so we find its
13091 ;; message-id and request it by id instead of number.
13092 (when (numberp article)
13094 (set-buffer gnus-summary-buffer)
13095 (let ((header (gnus-summary-article-header article)))
13098 ((memq article gnus-newsgroup-sparse)
13099 ;; This is a sparse gap article.
13100 (setq article (mail-header-id header)))
13102 ;; It's a real article.
13103 (setq article (mail-header-id header)))
13105 ;; It is an extracted pseudo-article.
13106 (setq article 'pseudo)
13107 (gnus-request-pseudo-article header))))
13109 (let ((method (gnus-find-method-for-group
13110 gnus-newsgroup-name)))
13111 (if (not (eq (car method) 'nneething))
13113 (let ((dir (concat (file-name-as-directory (nth 1 method))
13114 (mail-header-subject header))))
13115 (if (file-directory-p dir)
13117 (setq article 'nneething)
13118 (gnus-group-enter-directory dir)))))))))
13121 ;; We first check `gnus-original-article-buffer'.
13122 ((and (equal (car gnus-original-article) group)
13123 (eq (cdr gnus-original-article) article)
13124 (get-buffer gnus-original-article-buffer))
13125 (insert-buffer-substring gnus-original-article-buffer)
13127 ;; Check the backlog.
13128 ((and gnus-keep-backlog
13129 (gnus-backlog-request-article group article (current-buffer)))
13131 ;; Check the cache.
13132 ((and gnus-use-cache
13134 (gnus-cache-request-article article group))
13136 ;; Get the article and put into the article buffer.
13137 ((or (stringp article) (numberp article))
13138 (let ((gnus-override-method
13139 (and (stringp article) gnus-refer-article-method))
13140 (buffer-read-only nil))
13142 (gnus-kill-all-overlays)
13143 (if (gnus-request-article article group (current-buffer))
13145 (and gnus-keep-backlog
13146 (gnus-backlog-enter-article
13147 group article (current-buffer)))
13149 ;; It was a pseudo.
13152 ;; Take the article from the original article buffer
13153 ;; and place it in the buffer it's supposed to be in.
13154 (setq gnus-original-article (cons group article))
13155 (when (and (get-buffer gnus-article-buffer)
13156 (equal (buffer-name (current-buffer))
13157 (buffer-name (get-buffer gnus-article-buffer))))
13159 (if (get-buffer gnus-original-article-buffer)
13160 (set-buffer (get-buffer gnus-original-article-buffer))
13161 (set-buffer (get-buffer-create gnus-original-article-buffer))
13162 (buffer-disable-undo (current-buffer))
13163 (setq major-mode 'gnus-original-article-mode)
13164 (setq buffer-read-only t)
13165 (gnus-add-current-to-buffer-list))
13166 (let (buffer-read-only)
13168 (insert-buffer-substring gnus-article-buffer))))
13170 ;; Update sparse articles.
13171 (when (memq article gnus-newsgroup-sparse)
13172 (gnus-summary-update-article article))))
13174 (defun gnus-read-header (id)
13175 "Read the headers of article ID and enter them into the Gnus system."
13176 (let ((group gnus-newsgroup-name)
13177 (headers gnus-newsgroup-headers)
13179 ;; First we check to see whether the header in question is already
13182 ;; This is a Message-ID.
13183 (setq header (gnus-id-to-header id))
13184 ;; This is an article number.
13185 (setq header (gnus-summary-article-header id)))
13187 ;; We have found the header.
13189 ;; We have to really fetch the header to this article.
13191 (if (gnus-check-backend-function 'request-head group)
13192 (gnus-request-head id group)
13193 (gnus-request-article id group)))
13195 (set-buffer nntp-server-buffer)
13196 (and (search-forward "\n\n" nil t)
13197 (delete-region (1- (point)) (point-max)))
13198 (goto-char (point-max))
13200 (goto-char (point-min))
13209 gnus-reffed-article-number)))
13210 " Article retrieved.\n"))
13211 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13212 () ; Malformed head.
13213 (if (and (stringp id)
13214 (not (string= (gnus-group-real-name group)
13216 ;; If we fetched by Message-ID and the article came
13217 ;; from a different group, we fudge some bogus article
13218 ;; numbers for this article.
13219 (mail-header-set-number header gnus-reffed-article-number))
13220 (decf gnus-reffed-article-number)
13221 (push header gnus-newsgroup-headers)
13222 (setq gnus-current-headers header)
13223 (push (mail-header-number header) gnus-newsgroup-limit)
13226 (defun gnus-article-prepare (article &optional all-headers header)
13227 "Prepare ARTICLE in article mode buffer.
13228 ARTICLE should either be an article number or a Message-ID.
13229 If ARTICLE is an id, HEADER should be the article headers.
13230 If ALL-HEADERS is non-nil, no headers are hidden."
13232 ;; Make sure we start in a summary buffer.
13233 (unless (eq major-mode 'gnus-summary-mode)
13234 (set-buffer gnus-summary-buffer))
13235 (setq gnus-summary-buffer (current-buffer))
13236 ;; Make sure the connection to the server is alive.
13237 (unless (gnus-server-opened
13238 (gnus-find-method-for-group gnus-newsgroup-name))
13239 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13240 (gnus-request-group gnus-newsgroup-name t))
13241 (let* ((article (if header (mail-header-number header) article))
13242 (summary-buffer (current-buffer))
13243 (internal-hook gnus-article-internal-prepare-hook)
13244 (group gnus-newsgroup-name)
13247 (gnus-article-setup-buffer)
13248 (set-buffer gnus-article-buffer)
13249 ;; Deactivate active regions.
13250 (when (and (boundp 'transient-mark-mode)
13251 transient-mark-mode)
13252 (setq mark-active nil))
13253 (if (not (setq result (let ((buffer-read-only nil))
13254 (gnus-request-article-this-buffer
13256 ;; There is no such article.
13258 (when (and (numberp article)
13259 (not (memq article gnus-newsgroup-sparse)))
13260 (setq gnus-article-current
13261 (cons gnus-newsgroup-name article))
13262 (set-buffer gnus-summary-buffer)
13263 (setq gnus-current-article article)
13264 (gnus-summary-mark-article article gnus-canceled-mark))
13265 (unless (memq article gnus-newsgroup-sparse)
13267 1 "No such article (may have expired or been canceled)")
13270 (if (or (eq result 'pseudo) (eq result 'nneething))
13273 (set-buffer summary-buffer)
13274 (setq gnus-last-article gnus-current-article
13275 gnus-newsgroup-history (cons gnus-current-article
13276 gnus-newsgroup-history)
13277 gnus-current-article 0
13278 gnus-current-headers nil
13279 gnus-article-current nil)
13280 (if (eq result 'nneething)
13281 (gnus-configure-windows 'summary)
13282 (gnus-configure-windows 'article))
13283 (gnus-set-global-variables))
13284 (gnus-set-mode-line 'article))
13285 ;; The result from the `request' was an actual article -
13286 ;; or at least some text that is now displayed in the
13288 (if (and (numberp article)
13289 (not (eq article gnus-current-article)))
13290 ;; Seems like a new article has been selected.
13291 ;; `gnus-current-article' must be an article number.
13293 (set-buffer summary-buffer)
13294 (setq gnus-last-article gnus-current-article
13295 gnus-newsgroup-history (cons gnus-current-article
13296 gnus-newsgroup-history)
13297 gnus-current-article article
13298 gnus-current-headers
13299 (gnus-summary-article-header gnus-current-article)
13300 gnus-article-current
13301 (cons gnus-newsgroup-name gnus-current-article))
13302 (unless (vectorp gnus-current-headers)
13303 (setq gnus-current-headers nil))
13304 (gnus-summary-show-thread)
13305 (run-hooks 'gnus-mark-article-hook)
13306 (gnus-set-mode-line 'summary)
13307 (and (gnus-visual-p 'article-highlight 'highlight)
13308 (run-hooks 'gnus-visual-mark-article-hook))
13309 ;; Set the global newsgroup variables here.
13310 ;; Suggested by Jim Sisolak
13311 ;; <sisolak@trans4.neep.wisc.edu>.
13312 (gnus-set-global-variables)
13313 (setq gnus-have-all-headers
13314 (or all-headers gnus-show-all-headers))
13315 (and gnus-use-cache
13316 (vectorp (gnus-summary-article-header article))
13317 (gnus-cache-possibly-enter-article
13319 (gnus-summary-article-header article)
13320 (memq article gnus-newsgroup-marked)
13321 (memq article gnus-newsgroup-dormant)
13322 (memq article gnus-newsgroup-unreads)))))
13323 ;; Hooks for getting information from the article.
13324 ;; This hook must be called before being narrowed.
13325 (let (buffer-read-only)
13326 (run-hooks 'internal-hook)
13327 (run-hooks 'gnus-article-prepare-hook)
13328 ;; Decode MIME message.
13330 (if (or (not gnus-strict-mime)
13331 (gnus-fetch-field "Mime-Version"))
13332 (funcall gnus-show-mime-method)
13333 (funcall gnus-decode-encoded-word-method)))
13334 ;; Perform the article display hooks.
13335 (run-hooks 'gnus-article-display-hook))
13337 (goto-char (point-min))
13338 (and gnus-break-pages (gnus-narrow-to-page))
13339 (gnus-set-mode-line 'article)
13340 (gnus-configure-windows 'article)
13341 (goto-char (point-min))
13344 (defun gnus-article-show-all-headers ()
13345 "Show all article headers in article mode buffer."
13347 (gnus-article-setup-buffer)
13348 (set-buffer gnus-article-buffer)
13349 (let ((buffer-read-only nil))
13350 (remove-text-properties (point-min) (point-max)
13351 gnus-hidden-properties))))
13353 (defun gnus-article-hide-headers-if-wanted ()
13354 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13355 Provided for backwards compatibility."
13356 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13357 gnus-inhibit-hiding
13358 (gnus-article-hide-headers)))
13360 (defun gnus-article-hide-headers (&optional arg delete)
13361 "Toggle whether to hide unwanted headers and possibly sort them as well.
13362 If given a negative prefix, always show; if given a positive prefix,
13365 (unless (gnus-article-check-hidden-text 'headers arg)
13366 ;; This function might be inhibited.
13367 (unless gnus-inhibit-hiding
13369 (set-buffer gnus-article-buffer)
13371 (let ((buffer-read-only nil)
13372 (ignored (when (not (stringp gnus-visible-headers))
13373 (cond ((stringp gnus-ignored-headers)
13374 gnus-ignored-headers)
13375 ((listp gnus-ignored-headers)
13376 (mapconcat 'identity gnus-ignored-headers
13379 (cond ((stringp gnus-visible-headers)
13380 gnus-visible-headers)
13381 ((and gnus-visible-headers
13382 (listp gnus-visible-headers))
13383 (mapconcat 'identity gnus-visible-headers "\\|"))))
13384 want-list beg want-l)
13385 ;; First we narrow to just the headers.
13387 (goto-char (point-min))
13388 ;; Hide any "From " lines at the beginning of (mail) articles.
13389 (while (looking-at "From ")
13392 (add-text-properties
13393 (point-min) (point)
13394 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13395 ;; Then treat the rest of the header lines.
13398 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13399 ;; Then we use the two regular expressions
13400 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13401 ;; select which header lines is to remain visible in the
13403 (goto-char (point-min))
13404 (while (re-search-forward "^[^ \t]*:" nil t)
13405 (beginning-of-line)
13406 ;; We add the headers we want to keep to a list and delete
13407 ;; them from the buffer.
13408 (if (or (and visible (looking-at visible))
13409 (and ignored (not (looking-at ignored))))
13411 (push (buffer-substring
13415 ;; Be sure to get multi-line headers...
13416 (re-search-forward "^[^ \t]*:" nil t)
13417 (beginning-of-line)
13420 (delete-region beg (point)))
13422 ;; Sort the headers that we want to display.
13423 (setq want-list (sort want-list 'gnus-article-header-less))
13424 (goto-char (point-min))
13426 (insert (pop want-list)))
13427 ;; We make the unwanted headers invisible.
13429 (delete-region (point-min) (point-max))
13430 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13431 (add-text-properties
13432 (point) (point-max)
13433 (nconc (list 'gnus-type 'headers)
13434 gnus-hidden-properties)))))))))
13436 (defsubst gnus-article-header-rank (header)
13437 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13438 (let ((list gnus-sorted-header-list)
13441 (when (string-match (car list) header)
13443 (setq list (cdr list))
13447 (defun gnus-article-header-less (h1 h2)
13448 "Say whether string H1 is \"less\" than string H2."
13449 (< (gnus-article-header-rank h1)
13450 (gnus-article-header-rank h2)))
13452 (defun gnus-article-hide-boring-headers (&optional arg)
13453 "Toggle hiding of headers that aren't very interesting.
13454 If given a negative prefix, always show; if given a positive prefix,
13457 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13459 (set-buffer gnus-article-buffer)
13461 (let ((buffer-read-only nil)
13462 (list gnus-boring-article-headers)
13463 (inhibit-point-motion-hooks t)
13465 (nnheader-narrow-to-headers)
13467 (setq elem (pop list))
13468 (goto-char (point-min))
13470 ;; Hide empty headers.
13472 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13474 (add-text-properties
13475 (progn (beginning-of-line) (point))
13478 (if (re-search-forward "^[^ \t]" nil t)
13479 (match-beginning 0)
13481 (nconc (list 'gnus-type 'boring-headers)
13482 gnus-hidden-properties))))
13483 ;; Hide boring Newsgroups header.
13484 ((eq elem 'newsgroups)
13485 (when (equal (mail-fetch-field "newsgroups")
13486 (gnus-group-real-name gnus-newsgroup-name))
13487 (gnus-article-hide-header "newsgroups")))
13488 ((eq elem 'followup-to)
13489 (when (equal (mail-fetch-field "followup-to")
13490 (mail-fetch-field "newsgroups"))
13491 (gnus-article-hide-header "followup-to")))
13492 ((eq elem 'reply-to)
13493 (let ((from (mail-fetch-field "from"))
13494 (reply-to (mail-fetch-field "reply-to")))
13498 (nth 1 (mail-extract-address-components from))
13499 (nth 1 (mail-extract-address-components reply-to))))
13500 (gnus-article-hide-header "reply-to"))))
13502 (let ((date (mail-fetch-field "date")))
13504 (< (gnus-days-between date (current-time-string))
13506 (gnus-article-hide-header "date")))))))))))
13508 (defun gnus-article-hide-header (header)
13510 (goto-char (point-min))
13511 (when (re-search-forward (concat "^" header ":") nil t)
13512 (add-text-properties
13513 (progn (beginning-of-line) (point))
13516 (if (re-search-forward "^[^ \t]" nil t)
13517 (match-beginning 0)
13519 (nconc (list 'gnus-type 'boring-headers)
13520 gnus-hidden-properties)))))
13522 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13523 (defun gnus-article-treat-overstrike ()
13524 "Translate overstrikes into bold text."
13527 (set-buffer gnus-article-buffer)
13528 (let ((buffer-read-only nil))
13529 (while (search-forward "\b" nil t)
13530 (let ((next (following-char))
13531 (previous (char-after (- (point) 2))))
13532 (cond ((eq next previous)
13533 (put-text-property (- (point) 2) (point) 'invisible t)
13534 (put-text-property (point) (1+ (point)) 'face 'bold))
13536 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13538 (- (point) 2) (1- (point)) 'face 'underline))
13540 (put-text-property (- (point) 2) (point) 'invisible t)
13542 (point) (1+ (point)) 'face 'underline))))))))
13544 (defun gnus-article-word-wrap ()
13545 "Format too long lines."
13548 (set-buffer gnus-article-buffer)
13549 (let ((buffer-read-only nil)
13552 (goto-char (point-min))
13553 (search-forward "\n\n" nil t)
13555 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13556 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13557 (adaptive-fill-mode t))
13558 (while (not (eobp))
13559 (and (>= (current-column) (min fill-column (window-width)))
13560 (/= (preceding-char) ?:)
13561 (fill-paragraph nil))
13562 (end-of-line 2))))))
13564 (defun gnus-article-remove-cr ()
13565 "Remove carriage returns from an article."
13568 (set-buffer gnus-article-buffer)
13569 (let ((buffer-read-only nil))
13570 (goto-char (point-min))
13571 (while (search-forward "\r" nil t)
13572 (replace-match "" t t)))))
13574 (defun gnus-article-remove-trailing-blank-lines ()
13575 "Remove all trailing blank lines from the article."
13578 (set-buffer gnus-article-buffer)
13579 (let ((buffer-read-only nil))
13580 (goto-char (point-max))
13584 (while (looking-at "^[ \t]*$")
13589 (defun gnus-article-display-x-face (&optional force)
13590 "Look for an X-Face header and display it if present."
13591 (interactive (list 'force))
13593 (set-buffer gnus-article-buffer)
13594 ;; Delete the old process, if any.
13595 (when (process-status "gnus-x-face")
13596 (delete-process "gnus-x-face"))
13597 (let ((inhibit-point-motion-hooks t)
13598 (case-fold-search nil)
13601 (nnheader-narrow-to-headers)
13602 (setq from (mail-fetch-field "from"))
13603 (goto-char (point-min))
13604 (when (and gnus-article-x-face-command
13606 ;; Check whether this face is censored.
13607 (not gnus-article-x-face-too-ugly)
13608 (and gnus-article-x-face-too-ugly from
13609 (not (string-match gnus-article-x-face-too-ugly
13611 ;; Has to be present.
13612 (re-search-forward "^X-Face: " nil t))
13613 ;; We now have the area of the buffer where the X-Face is stored.
13614 (let ((beg (point))
13615 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13616 ;; We display the face.
13617 (if (symbolp gnus-article-x-face-command)
13618 ;; The command is a lisp function, so we call it.
13619 (if (gnus-functionp gnus-article-x-face-command)
13620 (funcall gnus-article-x-face-command beg end)
13621 (error "%s is not a function" gnus-article-x-face-command))
13622 ;; The command is a string, so we interpret the command
13623 ;; as a, well, command, and fork it off.
13624 (let ((process-connection-type nil))
13625 (process-kill-without-query
13627 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13628 (process-send-region "gnus-x-face" beg end)
13629 (process-send-eof "gnus-x-face")))))))))
13631 (defun gnus-headers-decode-quoted-printable ()
13632 "Hack to remove QP encoding from headers."
13633 (let ((case-fold-search t)
13634 (inhibit-point-motion-hooks t)
13636 (goto-char (point-min))
13637 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13638 (setq string (match-string 1))
13639 (narrow-to-region (match-beginning 0) (match-end 0))
13640 (delete-region (point-min) (point-max))
13642 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13643 (subst-char-in-region (point-min) (point-max) ?_ ? )
13645 (goto-char (point-min)))))
13647 (defun gnus-article-de-quoted-unreadable (&optional force)
13648 "Do a naive translation of a quoted-printable-encoded article.
13649 This is in no way, shape or form meant as a replacement for real MIME
13650 processing, but is simply a stop-gap measure until MIME support is
13652 If FORCE, decode the article whether it is marked as quoted-printable
13654 (interactive (list 'force))
13656 (set-buffer gnus-article-buffer)
13657 (let ((case-fold-search t)
13658 (buffer-read-only nil)
13659 (type (gnus-fetch-field "content-transfer-encoding")))
13661 (and type (string-match "quoted-printable" type)))
13662 (gnus-headers-decode-quoted-printable)
13663 (goto-char (point-min))
13664 (search-forward "\n\n" nil 'move)
13665 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13667 (defun gnus-mime-decode-quoted-printable (from to)
13668 "Decode Quoted-Printable in the region between FROM and TO."
13670 (while (search-forward "=" to t)
13671 (cond ((eq (following-char) ?\n)
13674 ((looking-at "[0-9A-F][0-9A-F]")
13676 (insert (hexl-hex-string-to-integer
13677 (buffer-substring (point) (+ 2 (point)))))
13681 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13683 (defun gnus-article-hide-pgp (&optional arg)
13684 "Toggle hiding of any PGP headers and signatures in the current article.
13685 If given a negative prefix, always show; if given a positive prefix,
13688 (unless (gnus-article-check-hidden-text 'pgp arg)
13690 (set-buffer gnus-article-buffer)
13691 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13692 buffer-read-only beg end)
13694 (goto-char (point-min))
13695 ;; Hide the "header".
13696 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13697 (add-text-properties (match-beginning 0) (match-end 0) props))
13699 ;; Hide the actual signature.
13700 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13701 (setq end (match-beginning 0))
13702 (add-text-properties
13703 (match-beginning 0)
13704 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13706 ;; Perhaps we shouldn't hide to the end of the buffer
13707 ;; if there is no end to the signature?
13710 ;; Hide "- " PGP quotation markers.
13711 (when (and beg end)
13712 (narrow-to-region beg end)
13713 (goto-char (point-min))
13714 (while (re-search-forward "^- " nil t)
13715 (add-text-properties (match-beginning 0) (match-end 0) props))
13718 (defun gnus-article-hide-signature (&optional arg)
13719 "Hide the signature in the current article.
13720 If given a negative prefix, always show; if given a positive prefix,
13723 (unless (gnus-article-check-hidden-text 'signature arg)
13725 (set-buffer gnus-article-buffer)
13727 (let ((buffer-read-only nil))
13728 (when (gnus-narrow-to-signature)
13729 (add-text-properties
13730 (point-min) (point-max)
13731 (nconc (list 'gnus-type 'signature)
13732 gnus-hidden-properties))))))))
13734 (defvar gnus-signature-limit nil
13735 "Provide a limit to what is considered a signature.
13736 If it is a number, no signature may not be longer (in characters) than
13737 that number. If it is a function, the function will be called without
13738 any parameters, and if it returns nil, there is no signature in the
13739 buffer. If it is a string, it will be used as a regexp. If it
13740 matches, the text in question is not a signature.")
13742 (defun gnus-narrow-to-signature ()
13743 "Narrow to the signature."
13745 (goto-char (point-max))
13746 (when (re-search-backward gnus-signature-separator nil t)
13748 (when (or (null gnus-signature-limit)
13749 (and (numberp gnus-signature-limit)
13750 (< (- (point-max) (point)) gnus-signature-limit))
13751 (and (gnus-functionp gnus-signature-limit)
13752 (funcall gnus-signature-limit))
13753 (and (stringp gnus-signature-limit)
13754 (not (re-search-forward gnus-signature-limit nil t))))
13755 (narrow-to-region (point) (point-max))
13758 (defun gnus-article-check-hidden-text (type arg)
13759 "Return nil if hiding is necessary."
13761 (set-buffer gnus-article-buffer)
13762 (let ((hide (gnus-article-hidden-text-p type)))
13763 (cond ((or (and (null arg) (eq hide 'hidden))
13764 (and arg (< 0 (prefix-numeric-value arg))))
13765 (gnus-article-show-hidden-text type))
13767 (gnus-article-show-hidden-text type t))
13770 (defun gnus-article-hidden-text-p (type)
13771 "Say whether the current buffer contains hidden text of type TYPE."
13772 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13775 (if (get-text-property pos 'invisible)
13779 (defun gnus-article-hide (&optional arg force)
13780 "Hide all the gruft in the current article.
13781 This means that PGP stuff, signatures, cited text and (some)
13782 headers will be hidden.
13783 If given a prefix, show the hidden text instead."
13784 (interactive (list current-prefix-arg 'force))
13785 (gnus-article-hide-headers arg)
13786 (gnus-article-hide-pgp arg)
13787 (gnus-article-hide-citation-maybe arg force)
13788 (gnus-article-hide-signature arg))
13790 (defun gnus-article-show-hidden-text (type &optional hide)
13791 "Show all hidden text of type TYPE.
13792 If HIDE, hide the text instead."
13794 (set-buffer gnus-article-buffer)
13795 (let ((buffer-read-only nil)
13796 (inhibit-point-motion-hooks t)
13798 (while (gnus-goto-char (text-property-any
13799 beg (point-max) 'gnus-type type))
13803 (add-text-properties beg (point) gnus-hidden-properties)
13804 (remove-text-properties beg (point) gnus-hidden-properties))
13805 (setq beg (point)))
13808 (defvar gnus-article-time-units
13809 `((year . ,(* 365.25 24 60 60))
13810 (week . ,(* 7 24 60 60))
13811 (day . ,(* 24 60 60))
13812 (hour . ,(* 60 60))
13815 "Mapping from time units to seconds.")
13817 (defun gnus-article-date-ut (&optional type highlight)
13818 "Convert DATE date to universal time in the current article.
13819 If TYPE is `local', convert to local time; if it is `lapsed', output
13820 how much time has lapsed since DATE."
13821 (interactive (list 'ut t))
13822 (let* ((header (or gnus-current-headers
13823 (gnus-summary-article-header) ""))
13824 (date (and (vectorp header) (mail-header-date header)))
13825 (date-regexp "^Date: \\|^X-Sent: ")
13826 (now (current-time))
13827 (inhibit-point-motion-hooks t))
13828 (when (and date (not (string= date "")))
13830 (set-buffer gnus-article-buffer)
13832 (nnheader-narrow-to-headers)
13833 (let ((buffer-read-only nil))
13834 ;; Delete any old Date headers.
13835 (if (zerop (nnheader-remove-header date-regexp t))
13836 (beginning-of-line)
13837 (goto-char (point-max)))
13840 ;; Convert to the local timezone. We have to slap a
13841 ;; `condition-case' round the calls to the timezone
13842 ;; functions since they aren't particularly resistant to
13845 (concat "Date: " (condition-case ()
13846 (timezone-make-date-arpa-standard date)
13849 ;; Convert to Universal Time.
13853 (timezone-make-date-arpa-standard date nil "UT")
13856 ;; Get the original date from the article.
13857 ((eq type 'original)
13858 (concat "Date: " date "\n"))
13859 ;; Do an X-Sent lapsed format.
13861 ;; If the date is seriously mangled, the timezone
13862 ;; functions are liable to bug out, so we condition-case
13863 ;; the entire thing.
13868 (timezone-make-date-arpa-standard
13869 (current-time-string now)
13870 (current-time-zone now) "UT"))
13872 (timezone-make-date-arpa-standard
13875 (real-sec (+ (* (float (car real-time)) 65536)
13877 (sec (abs real-sec))
13883 ;; This is a bit convoluted, but basically we go
13884 ;; through the time units for years, weeks, etc,
13885 ;; and divide things to see whether that results
13886 ;; in positive answers.
13889 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13890 ;; The (remaining) seconds are too few to
13891 ;; be divided into this time unit.
13893 ;; It's big enough, so we output it.
13894 (setq sec (- sec (* num (cdr unit))))
13896 (concat (if prev ", " "") (int-to-string
13898 " " (symbol-name (car unit))
13899 (if (> num 1) "s" ""))
13901 gnus-article-time-units "")
13902 ;; If dates are odd, then it might appear like the
13903 ;; article was sent in the future.
13906 " in the future\n")))))
13908 (error "Unknown conversion type: %s" type)))))
13909 ;; Do highlighting.
13910 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13911 (gnus-article-highlight-headers)))))))
13913 (defun gnus-article-date-local (&optional highlight)
13914 "Convert the current article date to the local timezone."
13915 (interactive (list t))
13916 (gnus-article-date-ut 'local highlight))
13918 (defun gnus-article-date-original (&optional highlight)
13919 "Convert the current article date to what it was originally.
13920 This is only useful if you have used some other date conversion
13921 function and want to see what the date was before converting."
13922 (interactive (list t))
13923 (gnus-article-date-ut 'original highlight))
13925 (defun gnus-article-date-lapsed (&optional highlight)
13926 "Convert the current article date to time lapsed since it was sent."
13927 (interactive (list t))
13928 (gnus-article-date-ut 'lapsed highlight))
13930 (defun gnus-article-maybe-highlight ()
13931 "Do some article highlighting if `gnus-visual' is non-nil."
13932 (if (gnus-visual-p 'article-highlight 'highlight)
13933 (gnus-article-highlight-some)))
13937 (defun gnus-output-to-rmail (file-name)
13938 "Append the current article to an Rmail file named FILE-NAME."
13940 ;; Most of these codes are borrowed from rmailout.el.
13941 (setq file-name (expand-file-name file-name))
13942 (setq rmail-default-rmail-file file-name)
13943 (let ((artbuf (current-buffer))
13944 (tmpbuf (get-buffer-create " *Gnus-output*")))
13946 (or (get-file-buffer file-name)
13947 (file-exists-p file-name)
13948 (if (gnus-yes-or-no-p
13949 (concat "\"" file-name "\" does not exist, create it? "))
13950 (let ((file-buffer (create-file-buffer file-name)))
13952 (set-buffer file-buffer)
13953 (rmail-insert-rmail-file-header)
13954 (let ((require-final-newline nil))
13955 (write-region (point-min) (point-max) file-name t 1)))
13956 (kill-buffer file-buffer))
13957 (error "Output file does not exist")))
13958 (set-buffer tmpbuf)
13959 (buffer-disable-undo (current-buffer))
13961 (insert-buffer-substring artbuf)
13962 (gnus-convert-article-to-rmail)
13963 ;; Decide whether to append to a file or to an Emacs buffer.
13964 (let ((outbuf (get-file-buffer file-name)))
13966 (append-to-file (point-min) (point-max) file-name)
13967 ;; File has been visited, in buffer OUTBUF.
13968 (set-buffer outbuf)
13969 (let ((buffer-read-only nil)
13970 (msg (and (boundp 'rmail-current-message)
13971 (symbol-value 'rmail-current-message))))
13972 ;; If MSG is non-nil, buffer is in RMAIL mode.
13975 (narrow-to-region (point-max) (point-max))))
13976 (insert-buffer-substring tmpbuf)
13979 (goto-char (point-min))
13981 (search-backward "\^_")
13982 (narrow-to-region (point) (point-max))
13983 (goto-char (1+ (point-min)))
13984 (rmail-count-new-messages t)
13985 (rmail-show-message msg)))))))
13986 (kill-buffer tmpbuf)))
13988 (defun gnus-output-to-file (file-name)
13989 "Append the current article to a file named FILE-NAME."
13990 (setq file-name (expand-file-name file-name))
13991 (let ((artbuf (current-buffer))
13992 (tmpbuf (get-buffer-create " *Gnus-output*")))
13994 (set-buffer tmpbuf)
13995 (buffer-disable-undo (current-buffer))
13997 (insert-buffer-substring artbuf)
13998 ;; Append newline at end of the buffer as separator, and then
13999 ;; save it to file.
14000 (goto-char (point-max))
14002 (append-to-file (point-min) (point-max) file-name))
14003 (kill-buffer tmpbuf)))
14005 (defun gnus-convert-article-to-rmail ()
14006 "Convert article in current buffer to Rmail message format."
14007 (let ((buffer-read-only nil))
14008 ;; Convert article directly into Babyl format.
14009 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14010 (goto-char (point-min))
14011 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14012 (while (search-forward "\n\^_" nil t) ;single char
14013 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14014 (goto-char (point-max))
14017 (defun gnus-narrow-to-page (&optional arg)
14018 "Narrow the article buffer to a page.
14019 If given a numerical ARG, move forward ARG pages."
14021 (setq arg (if arg (prefix-numeric-value arg) 0))
14023 (set-buffer gnus-article-buffer)
14024 (goto-char (point-min))
14026 (when (gnus-visual-p 'page-marker)
14027 (let ((buffer-read-only nil))
14028 (gnus-remove-text-with-property 'gnus-prev)
14029 (gnus-remove-text-with-property 'gnus-next)))
14032 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14034 (re-search-forward page-delimiter nil 'move arg)))
14035 (goto-char (match-end 0)))
14038 (if (re-search-forward page-delimiter nil 'move)
14039 (match-beginning 0)
14041 (when (and (gnus-visual-p 'page-marker)
14042 (not (= (point-min) 1)))
14044 (goto-char (point-min))
14045 (gnus-insert-prev-page-button)))
14046 (when (and (gnus-visual-p 'page-marker)
14047 (not (= (1- (point-max)) (buffer-size))))
14049 (goto-char (point-max))
14050 (gnus-insert-next-page-button)))))
14052 ;; Article mode commands
14054 (defun gnus-article-goto-next-page ()
14055 "Show the next page of the article."
14057 (when (gnus-article-next-page)
14058 (gnus-article-read-summary-keys nil ?n)))
14060 (defun gnus-article-goto-prev-page ()
14061 "Show the next page of the article."
14063 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14064 (gnus-article-prev-page nil)))
14066 (defun gnus-article-next-page (&optional lines)
14067 "Show the next page of the current article.
14068 If end of article, return non-nil. Otherwise return nil.
14069 Argument LINES specifies lines to be scrolled up."
14071 (move-to-window-line -1)
14072 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14073 (if (save-excursion
14075 (and (pos-visible-in-window-p) ;Not continuation line.
14077 ;; Nothing in this page.
14078 (if (or (not gnus-break-pages)
14081 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14083 (gnus-narrow-to-page 1) ;Go to next page.
14085 ;; More in this page.
14089 ;; Long lines may cause an end-of-buffer error.
14090 (goto-char (point-max))))
14093 (defun gnus-article-prev-page (&optional lines)
14094 "Show previous page of current article.
14095 Argument LINES specifies lines to be scrolled down."
14097 (move-to-window-line 0)
14098 (if (and gnus-break-pages
14100 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14102 (gnus-narrow-to-page -1) ;Go to previous page.
14103 (goto-char (point-max))
14106 (scroll-down lines)
14109 (defun gnus-article-refer-article ()
14110 "Read article specified by message-id around point."
14112 (let ((point (point)))
14113 (search-forward ">" nil t) ;Move point to end of "<....>".
14114 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14115 (let ((message-id (match-string 1)))
14117 (set-buffer gnus-summary-buffer)
14118 (gnus-summary-refer-article message-id))
14119 (goto-char (point))
14120 (error "No references around point"))))
14122 (defun gnus-article-show-summary ()
14123 "Reconfigure windows to show summary buffer."
14125 (gnus-configure-windows 'article)
14126 (gnus-summary-goto-subject gnus-current-article))
14128 (defun gnus-article-describe-briefly ()
14129 "Describe article mode commands briefly."
14132 (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")))
14134 (defun gnus-article-summary-command ()
14135 "Execute the last keystroke in the summary buffer."
14137 (let ((obuf (current-buffer))
14138 (owin (current-window-configuration))
14140 (switch-to-buffer gnus-summary-buffer 'norecord)
14141 (setq func (lookup-key (current-local-map) (this-command-keys)))
14142 (call-interactively func)
14144 (set-window-configuration owin)
14145 (set-window-point (get-buffer-window (current-buffer)) (point))))
14147 (defun gnus-article-summary-command-nosave ()
14148 "Execute the last keystroke in the summary buffer."
14151 (pop-to-buffer gnus-summary-buffer 'norecord)
14152 (setq func (lookup-key (current-local-map) (this-command-keys)))
14153 (call-interactively func)))
14155 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14156 "Read a summary buffer key sequence and execute it from the article buffer."
14159 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14160 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14164 (set-buffer gnus-summary-buffer)
14165 (push (or key last-command-event) unread-command-events)
14166 (setq keys (read-key-sequence nil)))
14169 (if (member keys nosaves)
14171 (pop-to-buffer gnus-summary-buffer 'norecord)
14172 (if (setq func (lookup-key (current-local-map) keys))
14173 (call-interactively func)
14175 (let ((obuf (current-buffer))
14176 (owin (current-window-configuration))
14179 (if not-restore-window
14180 (pop-to-buffer gnus-summary-buffer 'norecord)
14181 (switch-to-buffer gnus-summary-buffer 'norecord))
14182 (setq in-buffer (current-buffer))
14183 (if (setq func (lookup-key (current-local-map) keys))
14184 (call-interactively func)
14186 (when (eq in-buffer (current-buffer))
14188 (unless not-restore-window
14189 (set-window-configuration owin))
14190 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14194 ;;; Kill file handling.
14198 (defalias 'gnus-batch-kill 'gnus-batch-score)
14200 (defun gnus-batch-score ()
14201 "Run batched scoring.
14202 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14203 Newsgroups is a list of strings in Bnews format. If you want to score
14204 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14205 score the alt hierarchy, you'd say \"!alt.all\"."
14208 (gnus-newsrc-parse-options
14209 (apply (function concat)
14210 (mapcar (lambda (g) (concat g " "))
14211 command-line-args-left))))
14212 (gnus-expert-user t)
14213 (nnmail-spool-file nil)
14214 (gnus-use-dribble-file nil)
14215 (yes (car yes-and-no))
14216 (no (cdr yes-and-no))
14218 ;; Disable verbose message.
14219 gnus-novice-user gnus-large-newsgroup)
14220 ;; Eat all arguments.
14221 (setq command-line-args-left nil)
14224 ;; Apply kills to specified newsgroups in command line arguments.
14225 (setq newsrc (cdr gnus-newsrc-alist))
14227 (setq group (car (car newsrc)))
14228 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14229 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14231 (or (eq (car entry) t)
14232 (not (zerop (car entry)))))
14233 (if yes (string-match yes group) t)
14234 (or (null no) (not (string-match no group))))
14236 (gnus-summary-read-group group nil t nil t)
14237 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14238 (gnus-summary-exit))))
14239 (setq newsrc (cdr newsrc)))
14241 (switch-to-buffer gnus-group-buffer)
14242 (gnus-group-save-newsrc)))
14244 (defun gnus-apply-kill-file ()
14245 "Apply a kill file to the current newsgroup.
14246 Returns the number of articles marked as read."
14247 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14248 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14249 (gnus-apply-kill-file-internal)
14252 (defun gnus-kill-save-kill-buffer ()
14253 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14254 (when (get-file-buffer file)
14256 (set-buffer (get-file-buffer file))
14257 (and (buffer-modified-p) (save-buffer))
14258 (kill-buffer (current-buffer))))))
14260 (defvar gnus-kill-file-name "KILL"
14261 "Suffix of the kill files.")
14263 (defun gnus-newsgroup-kill-file (newsgroup)
14264 "Return the name of a kill file name for NEWSGROUP.
14265 If NEWSGROUP is nil, return the global kill file name instead."
14267 ;; The global KILL file is placed at top of the directory.
14268 ((or (null newsgroup)
14269 (string-equal newsgroup ""))
14270 (expand-file-name gnus-kill-file-name
14271 (or gnus-kill-files-directory "~/News")))
14272 ;; Append ".KILL" to newsgroup name.
14273 ((gnus-use-long-file-name 'not-kill)
14274 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14275 "." gnus-kill-file-name)
14276 (or gnus-kill-files-directory "~/News")))
14277 ;; Place "KILL" under the hierarchical directory.
14279 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14280 "/" gnus-kill-file-name)
14281 (or gnus-kill-files-directory "~/News")))))
14288 (defvar gnus-dribble-ignore nil)
14289 (defvar gnus-dribble-eval-file nil)
14291 (defun gnus-dribble-file-name ()
14292 "Return the dribble file for the current .newsrc."
14294 (if gnus-dribble-directory
14295 (concat (file-name-as-directory gnus-dribble-directory)
14296 (file-name-nondirectory gnus-current-startup-file))
14297 gnus-current-startup-file)
14300 (defun gnus-dribble-enter (string)
14301 "Enter STRING into the dribble buffer."
14302 (if (and (not gnus-dribble-ignore)
14303 gnus-dribble-buffer
14304 (buffer-name gnus-dribble-buffer))
14305 (let ((obuf (current-buffer)))
14306 (set-buffer gnus-dribble-buffer)
14307 (insert string "\n")
14308 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14309 (set-buffer obuf))))
14311 (defun gnus-dribble-read-file ()
14312 "Read the dribble file from disk."
14313 (let ((dribble-file (gnus-dribble-file-name)))
14315 (set-buffer (setq gnus-dribble-buffer
14317 (file-name-nondirectory dribble-file))))
14318 (gnus-add-current-to-buffer-list)
14320 (setq buffer-file-name dribble-file)
14322 (buffer-disable-undo (current-buffer))
14323 (bury-buffer (current-buffer))
14324 (set-buffer-modified-p nil)
14325 (let ((auto (make-auto-save-file-name))
14326 (gnus-dribble-ignore t))
14327 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14328 ;; Load whichever file is newest -- the auto save file
14329 ;; or the "real" file.
14330 (if (file-newer-than-file-p auto dribble-file)
14331 (insert-file-contents auto)
14332 (insert-file-contents dribble-file))
14333 (unless (zerop (buffer-size))
14334 (set-buffer-modified-p t))
14335 ;; Set the file modes to reflect the .newsrc file modes.
14337 (when (file-exists-p gnus-current-startup-file)
14338 (set-file-modes dribble-file
14339 (file-modes gnus-current-startup-file)))
14340 ;; Possibly eval the file later.
14341 (when (gnus-y-or-n-p
14342 "Auto-save file exists. Do you want to read it? ")
14343 (setq gnus-dribble-eval-file t)))))))
14345 (defun gnus-dribble-eval-file ()
14346 (if (not gnus-dribble-eval-file)
14348 (setq gnus-dribble-eval-file nil)
14350 (let ((gnus-dribble-ignore t))
14351 (set-buffer gnus-dribble-buffer)
14352 (eval-buffer (current-buffer))))))
14354 (defun gnus-dribble-delete-file ()
14355 (if (file-exists-p (gnus-dribble-file-name))
14356 (delete-file (gnus-dribble-file-name)))
14357 (if gnus-dribble-buffer
14359 (set-buffer gnus-dribble-buffer)
14360 (let ((auto (make-auto-save-file-name)))
14361 (if (file-exists-p auto)
14362 (delete-file auto))
14364 (set-buffer-modified-p nil)))))
14366 (defun gnus-dribble-save ()
14367 (if (and gnus-dribble-buffer
14368 (buffer-name gnus-dribble-buffer))
14370 (set-buffer gnus-dribble-buffer)
14373 (defun gnus-dribble-clear ()
14375 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14377 (set-buffer gnus-dribble-buffer)
14379 (set-buffer-modified-p nil)
14380 (setq buffer-saved-size (buffer-size))))))
14384 ;;; Server Communication
14387 (defun gnus-start-news-server (&optional confirm)
14388 "Open a method for getting news.
14389 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14391 (if gnus-current-select-method
14392 ;; Stream is already opened.
14394 ;; Open NNTP server.
14395 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14398 ;; Read server name with completion.
14399 (setq gnus-nntp-server
14400 (completing-read "NNTP server: "
14401 (mapcar (lambda (server) (list server))
14402 (cons (list gnus-nntp-server)
14403 gnus-secondary-servers))
14404 nil nil gnus-nntp-server))))
14406 (if (and gnus-nntp-server
14407 (stringp gnus-nntp-server)
14408 (not (string= gnus-nntp-server "")))
14409 (setq gnus-select-method
14410 (cond ((or (string= gnus-nntp-server "")
14411 (string= gnus-nntp-server "::"))
14412 (list 'nnspool (system-name)))
14413 ((string-match "^:" gnus-nntp-server)
14414 (list 'nnmh gnus-nntp-server
14415 (list 'nnmh-directory
14416 (file-name-as-directory
14418 (concat "~/" (substring
14419 gnus-nntp-server 1)))))
14420 (list 'nnmh-get-new-mail nil)))
14422 (list 'nntp gnus-nntp-server)))))
14424 (setq how (car gnus-select-method))
14425 (cond ((eq how 'nnspool)
14427 (gnus-message 5 "Looking up local news spool..."))
14430 (gnus-message 5 "Looking up mh spool..."))
14433 (setq gnus-current-select-method gnus-select-method)
14434 (run-hooks 'gnus-open-server-hook)
14436 ;; gnus-open-server-hook might have opened it
14437 (gnus-server-opened gnus-select-method)
14438 (gnus-open-server gnus-select-method)
14441 "%s (%s) open error: '%s'. Continue? "
14442 (car gnus-select-method) (cadr gnus-select-method)
14443 (gnus-status-message gnus-select-method)))
14445 (gnus-message 1 "Couldn't open server on %s"
14446 (nth 1 gnus-select-method))
14450 (defun gnus-check-group (group)
14451 "Try to make sure that the server where GROUP exists is alive."
14452 (let ((method (gnus-find-method-for-group group)))
14453 (or (gnus-server-opened method)
14454 (gnus-open-server method))))
14456 (defun gnus-check-server (&optional method)
14457 "Check whether the connection to METHOD is down.
14458 If METHOD is nil, use `gnus-select-method'.
14459 If it is down, start it up (again)."
14460 (let ((method (or method gnus-select-method)))
14461 ;; Transform virtual server names into select methods.
14462 (when (stringp method)
14463 (setq method (gnus-server-to-method method)))
14464 (if (gnus-server-opened method)
14465 ;; The stream is already opened.
14467 ;; Open the server.
14468 (gnus-message 5 "Opening %s server%s..." (car method)
14469 (if (equal (nth 1 method) "") ""
14470 (format " on %s" (nth 1 method))))
14471 (run-hooks 'gnus-open-server-hook)
14473 (gnus-open-server method)
14476 (defun gnus-get-function (method function)
14477 "Return a function symbol based on METHOD and FUNCTION."
14478 ;; Translate server names into methods.
14480 (error "Attempted use of a nil select method"))
14481 (when (stringp method)
14482 (setq method (gnus-server-to-method method)))
14483 (let ((func (intern (format "%s-%s" (car method) function))))
14484 ;; If the functions isn't bound, we require the backend in
14486 (unless (fboundp func)
14487 (require (car method))
14488 (unless (fboundp func)
14489 ;; This backend doesn't implement this function.
14490 (error "No such function: %s" func)))
14495 ;;; Interface functions to the backends.
14498 (defun gnus-open-server (method)
14499 "Open a connection to METHOD."
14500 (let ((elem (assoc method gnus-opened-servers)))
14501 ;; If this method was previously denied, we just return nil.
14502 (if (eq (nth 1 elem) 'denied)
14504 (gnus-message 1 "Denied server")
14506 ;; Open the server.
14508 (funcall (gnus-get-function method 'open-server)
14509 (nth 1 method) (nthcdr 2 method))))
14510 ;; If this hasn't been opened before, we add it to the list.
14512 (setq elem (list method nil)
14513 gnus-opened-servers (cons elem gnus-opened-servers)))
14514 ;; Set the status of this server.
14515 (setcar (cdr elem) (if result 'ok 'denied))
14516 ;; Return the result from the "open" call.
14519 (defun gnus-close-server (method)
14520 "Close the connection to METHOD."
14521 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14523 (defun gnus-request-list (method)
14524 "Request the active file from METHOD."
14525 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14527 (defun gnus-request-list-newsgroups (method)
14528 "Request the newsgroups file from METHOD."
14529 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14531 (defun gnus-request-newgroups (date method)
14532 "Request all new groups since DATE from METHOD."
14533 (funcall (gnus-get-function method 'request-newgroups)
14534 date (nth 1 method)))
14536 (defun gnus-server-opened (method)
14537 "Check whether a connection to METHOD has been opened."
14538 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14540 (defun gnus-status-message (method)
14541 "Return the status message from METHOD.
14542 If METHOD is a string, it is interpreted as a group name. The method
14543 this group uses will be queried."
14544 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14546 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14548 (defun gnus-request-group (group &optional dont-check method)
14549 "Request GROUP. If DONT-CHECK, no information is required."
14550 (let ((method (or method (gnus-find-method-for-group group))))
14551 (funcall (gnus-get-function method 'request-group)
14552 (gnus-group-real-name group) (nth 1 method) dont-check)))
14554 (defun gnus-request-asynchronous (group &optional articles)
14555 "Request that GROUP behave asynchronously.
14556 ARTICLES is the `data' of the group."
14557 (let ((method (gnus-find-method-for-group group)))
14558 (funcall (gnus-get-function method 'request-asynchronous)
14559 (gnus-group-real-name group) (nth 1 method) articles)))
14561 (defun gnus-list-active-group (group)
14562 "Request active information on GROUP."
14563 (let ((method (gnus-find-method-for-group group))
14564 (func 'list-active-group))
14565 (when (gnus-check-backend-function func group)
14566 (funcall (gnus-get-function method func)
14567 (gnus-group-real-name group) (nth 1 method)))))
14569 (defun gnus-request-group-description (group)
14570 "Request a description of GROUP."
14571 (let ((method (gnus-find-method-for-group group))
14572 (func 'request-group-description))
14573 (when (gnus-check-backend-function func group)
14574 (funcall (gnus-get-function method func)
14575 (gnus-group-real-name group) (nth 1 method)))))
14577 (defun gnus-close-group (group)
14578 "Request the GROUP be closed."
14579 (let ((method (gnus-find-method-for-group group)))
14580 (funcall (gnus-get-function method 'close-group)
14581 (gnus-group-real-name group) (nth 1 method))))
14583 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14584 "Request headers for ARTICLES in GROUP.
14585 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14586 (let ((method (gnus-find-method-for-group group)))
14587 (if (and gnus-use-cache (numberp (car articles)))
14588 (gnus-cache-retrieve-headers articles group fetch-old)
14589 (funcall (gnus-get-function method 'retrieve-headers)
14590 articles (gnus-group-real-name group) (nth 1 method)
14593 (defun gnus-retrieve-groups (groups method)
14594 "Request active information on GROUPS from METHOD."
14595 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14597 (defun gnus-request-type (group &optional article)
14598 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14599 (let ((method (gnus-find-method-for-group group)))
14600 (if (not (gnus-check-backend-function 'request-type (car method)))
14602 (funcall (gnus-get-function method 'request-type)
14603 (gnus-group-real-name group) article))))
14605 (defun gnus-request-update-mark (group article mark)
14606 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14607 (let ((method (gnus-find-method-for-group group)))
14608 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14610 (funcall (gnus-get-function method 'request-update-mark)
14611 (gnus-group-real-name group) article mark))))
14613 (defun gnus-request-article (article group &optional buffer)
14614 "Request the ARTICLE in GROUP.
14615 ARTICLE can either be an article number or an article Message-ID.
14616 If BUFFER, insert the article in that group."
14617 (let ((method (gnus-find-method-for-group group)))
14618 (funcall (gnus-get-function method 'request-article)
14619 article (gnus-group-real-name group) (nth 1 method) buffer)))
14621 (defun gnus-request-head (article group)
14622 "Request the head of ARTICLE in GROUP."
14623 (let ((method (gnus-find-method-for-group group)))
14624 (funcall (gnus-get-function method 'request-head)
14625 article (gnus-group-real-name group) (nth 1 method))))
14627 (defun gnus-request-body (article group)
14628 "Request the body of ARTICLE in GROUP."
14629 (let ((method (gnus-find-method-for-group group)))
14630 (funcall (gnus-get-function method 'request-body)
14631 article (gnus-group-real-name group) (nth 1 method))))
14633 (defun gnus-request-post (method)
14634 "Post the current buffer using METHOD."
14635 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14637 (defun gnus-request-scan (group method)
14638 "Request a SCAN being performed in GROUP from METHOD.
14639 If GROUP is nil, all groups on METHOD are scanned."
14640 (let ((method (if group (gnus-find-method-for-group group) method)))
14641 (funcall (gnus-get-function method 'request-scan)
14642 (and group (gnus-group-real-name group)) (nth 1 method))))
14644 (defsubst gnus-request-update-info (info method)
14645 "Request that METHOD update INFO."
14646 (when (gnus-check-backend-function 'request-update-info (car method))
14647 (funcall (gnus-get-function method 'request-update-info)
14648 (gnus-group-real-name (gnus-info-group info))
14649 info (nth 1 method))))
14651 (defun gnus-request-expire-articles (articles group &optional force)
14652 (let ((method (gnus-find-method-for-group group)))
14653 (funcall (gnus-get-function method 'request-expire-articles)
14654 articles (gnus-group-real-name group) (nth 1 method)
14657 (defun gnus-request-move-article
14658 (article group server accept-function &optional last)
14659 (let ((method (gnus-find-method-for-group group)))
14660 (funcall (gnus-get-function method 'request-move-article)
14661 article (gnus-group-real-name group)
14662 (nth 1 method) accept-function last)))
14664 (defun gnus-request-accept-article (group &optional last method)
14665 ;; Make sure there's a newline at the end of the article.
14666 (goto-char (point-max))
14669 (let ((func (if (symbolp group) group
14670 (car (or method (gnus-find-method-for-group group))))))
14671 (funcall (intern (format "%s-request-accept-article" func))
14672 (if (stringp group) (gnus-group-real-name group) group)
14675 (defun gnus-request-replace-article (article group buffer)
14676 (let ((func (car (gnus-find-method-for-group group))))
14677 (funcall (intern (format "%s-request-replace-article" func))
14678 article (gnus-group-real-name group) buffer)))
14680 (defun gnus-request-associate-buffer (group)
14681 (let ((method (gnus-find-method-for-group group)))
14682 (funcall (gnus-get-function method 'request-associate-buffer)
14683 (gnus-group-real-name group))))
14685 (defun gnus-request-restore-buffer (article group)
14686 "Request a new buffer restored to the state of ARTICLE."
14687 (let ((method (gnus-find-method-for-group group)))
14688 (funcall (gnus-get-function method 'request-restore-buffer)
14689 article (gnus-group-real-name group) (nth 1 method))))
14691 (defun gnus-request-create-group (group &optional method)
14692 (let ((method (or method (gnus-find-method-for-group group))))
14693 (funcall (gnus-get-function method 'request-create-group)
14694 (gnus-group-real-name group) (nth 1 method))))
14696 (defun gnus-request-delete-group (group &optional force)
14697 (let ((method (gnus-find-method-for-group group)))
14698 (funcall (gnus-get-function method 'request-delete-group)
14699 (gnus-group-real-name group) force (nth 1 method))))
14701 (defun gnus-request-rename-group (group new-name)
14702 (let ((method (gnus-find-method-for-group group)))
14703 (funcall (gnus-get-function method 'request-rename-group)
14704 (gnus-group-real-name group)
14705 (gnus-group-real-name new-name) (nth 1 method))))
14707 (defun gnus-member-of-valid (symbol group)
14708 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14709 (memq symbol (assoc
14710 (symbol-name (car (gnus-find-method-for-group group)))
14711 gnus-valid-select-methods)))
14713 (defun gnus-method-option-p (method option)
14714 "Return non-nil if select METHOD has OPTION as a parameter."
14715 (memq option (assoc (format "%s" (car method))
14716 gnus-valid-select-methods)))
14718 (defun gnus-server-extend-method (group method)
14719 ;; This function "extends" a virtual server. If the server is
14720 ;; "hello", and the select method is ("hello" (my-var "something"))
14721 ;; in the group "alt.alt", this will result in a new virtual server
14722 ;; called "hello+alt.alt".
14724 (gnus-copy-sequence
14725 (if (equal (car method) "native") gnus-select-method
14726 (cdr (assoc (car method) gnus-server-alist))))))
14727 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14728 (nconc entry (cdr method))))
14730 (defun gnus-find-method-for-group (group &optional info)
14731 "Find the select method that GROUP uses."
14732 (or gnus-override-method
14734 gnus-select-method)
14735 (let ((info (or info (gnus-get-info group)))
14738 (not (setq method (gnus-info-method info))))
14739 (setq method gnus-select-method)
14741 (cond ((stringp method)
14742 (gnus-server-to-method method))
14743 ((stringp (car method))
14744 (gnus-server-extend-method group method))
14747 (gnus-server-add-address method)))))
14749 (defun gnus-check-backend-function (func group)
14750 "Check whether GROUP supports function FUNC."
14751 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14753 (fboundp (intern (format "%s-%s" method func)))))
14755 (defun gnus-methods-using (feature)
14756 "Find all methods that have FEATURE."
14757 (let ((valids gnus-valid-select-methods)
14760 (if (memq feature (car valids))
14761 (setq outs (cons (car valids) outs)))
14762 (setq valids (cdr valids)))
14767 ;;; Active & Newsrc File Handling
14770 (defun gnus-setup-news (&optional rawfile level)
14771 "Setup news information.
14772 If RAWFILE is non-nil, the .newsrc file will also be read.
14773 If LEVEL is non-nil, the news will be set up at level LEVEL."
14774 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14775 ;; Clear some variables to re-initialize news information.
14776 (if init (setq gnus-newsrc-alist nil
14777 gnus-active-hashtb nil))
14779 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14780 (if init (gnus-read-newsrc-file rawfile))
14782 (unless (assoc "archive" gnus-server-alist)
14783 (push (cons "archive" gnus-message-archive-method)
14784 gnus-server-alist))
14786 ;; If we don't read the complete active file, we fill in the
14788 (if (or (null gnus-read-active-file)
14789 (eq gnus-read-active-file 'some))
14790 (gnus-update-active-hashtb-from-killed))
14792 ;; Read the active file and create `gnus-active-hashtb'.
14793 ;; If `gnus-read-active-file' is nil, then we just create an empty
14794 ;; hash table. The partial filling out of the hash table will be
14795 ;; done in `gnus-get-unread-articles'.
14796 (and gnus-read-active-file
14798 (gnus-read-active-file))
14800 (or gnus-active-hashtb
14801 (setq gnus-active-hashtb (make-vector 4095 0)))
14803 ;; Initialize the cache.
14804 (when gnus-use-cache
14807 ;; Possibly eval the dribble file.
14808 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14810 (gnus-update-format-specifications)
14812 ;; Find new newsgroups and treat them.
14813 (if (and init gnus-check-new-newsgroups (not level)
14814 (gnus-check-server gnus-select-method))
14815 (gnus-find-new-newsgroups))
14817 ;; Find the number of unread articles in each non-dead group.
14818 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14819 (gnus-get-unread-articles level))
14821 (if (and init gnus-check-bogus-newsgroups
14822 gnus-read-active-file (not level)
14823 (gnus-server-opened gnus-select-method))
14824 (gnus-check-bogus-newsgroups))))
14826 (defun gnus-find-new-newsgroups (&optional arg)
14827 "Search for new newsgroups and add them.
14828 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14829 The `-n' option line from .newsrc is respected.
14830 If ARG (the prefix), use the `ask-server' method to query
14831 the server for new groups."
14833 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14834 (null gnus-read-active-file)
14835 (eq gnus-read-active-file 'some))
14836 'ask-server gnus-check-new-newsgroups)))
14837 (unless (gnus-check-first-time-used)
14838 (if (or (consp check)
14839 (eq check 'ask-server))
14840 ;; Ask the server for new groups.
14841 (gnus-ask-server-for-new-groups)
14842 ;; Go through the active hashtb and look for new groups.
14844 group new-newsgroups)
14845 (gnus-message 5 "Looking for new newsgroups...")
14846 (unless gnus-have-read-active-file
14847 (gnus-read-active-file))
14848 (setq gnus-newsrc-last-checked-date (current-time-string))
14849 (unless gnus-killed-hashtb
14850 (gnus-make-hashtable-from-killed))
14851 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14852 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14855 (if (or (null (setq group (symbol-name sym)))
14857 (null (symbol-value sym))
14858 (gnus-gethash group gnus-killed-hashtb)
14859 (gnus-gethash group gnus-newsrc-hashtb))
14861 (let ((do-sub (gnus-matches-options-n group)))
14863 ((eq do-sub 'subscribe)
14864 (setq groups (1+ groups))
14865 (gnus-sethash group group gnus-killed-hashtb)
14866 (funcall gnus-subscribe-options-newsgroup-method group))
14867 ((eq do-sub 'ignore)
14870 (setq groups (1+ groups))
14871 (gnus-sethash group group gnus-killed-hashtb)
14872 (if gnus-subscribe-hierarchical-interactive
14873 (setq new-newsgroups (cons group new-newsgroups))
14874 (funcall gnus-subscribe-newsgroup-method group)))))))
14875 gnus-active-hashtb)
14876 (when new-newsgroups
14877 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14878 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14880 (gnus-message 6 "%d new newsgroup%s arrived."
14881 groups (if (> groups 1) "s have" " has"))
14882 (gnus-message 6 "No new newsgroups.")))))))
14884 (defun gnus-matches-options-n (group)
14885 ;; Returns `subscribe' if the group is to be unconditionally
14886 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14887 ;; no match for the group.
14889 ;; First we check the two user variables.
14891 ((and gnus-options-subscribe
14892 (string-match gnus-options-subscribe group))
14894 ((and gnus-auto-subscribed-groups
14895 (string-match gnus-auto-subscribed-groups group))
14897 ((and gnus-options-not-subscribe
14898 (string-match gnus-options-not-subscribe group))
14900 ;; Then we go through the list that was retrieved from the .newsrc
14901 ;; file. This list has elements on the form
14902 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14903 ;; is in the reverse order of the options line) is returned.
14905 (let ((regs gnus-newsrc-options-n))
14907 (not (string-match (car (car regs)) group)))
14908 (setq regs (cdr regs)))
14909 (and regs (cdr (car regs)))))))
14911 (defun gnus-ask-server-for-new-groups ()
14912 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14913 (methods (cons gnus-select-method
14917 (and (consp gnus-check-new-newsgroups)
14918 gnus-check-new-newsgroups)
14919 gnus-secondary-select-methods))))
14921 (new-date (current-time-string))
14922 group new-newsgroups got-new method hashtb
14923 gnus-override-subscribe-method)
14924 ;; Go through both primary and secondary select methods and
14925 ;; request new newsgroups.
14926 (while (setq method (gnus-server-get-method nil (pop methods)))
14927 (setq new-newsgroups nil)
14928 (setq gnus-override-subscribe-method method)
14929 (when (and (gnus-check-server method)
14930 (gnus-request-newgroups date method))
14933 (setq hashtb (gnus-make-hashtable 100))
14934 (set-buffer nntp-server-buffer)
14935 ;; Enter all the new groups into a hashtable.
14936 (gnus-active-to-gnus-format method hashtb 'ignore)))
14937 ;; Now all new groups from `method' are in `hashtb'.
14939 (lambda (group-sym)
14940 (if (or (null (setq group (symbol-name group-sym)))
14941 (null (symbol-value group-sym))
14942 (gnus-gethash group gnus-newsrc-hashtb)
14943 (member group gnus-zombie-list)
14944 (member group gnus-killed-list))
14945 ;; The group is already known.
14947 ;; Make this group active.
14948 (when (symbol-value group-sym)
14949 (gnus-set-active group (symbol-value group-sym)))
14950 ;; Check whether we want it or not.
14951 (let ((do-sub (gnus-matches-options-n group)))
14953 ((eq do-sub 'subscribe)
14955 (gnus-sethash group group gnus-killed-hashtb)
14956 (funcall gnus-subscribe-options-newsgroup-method group))
14957 ((eq do-sub 'ignore)
14961 (gnus-sethash group group gnus-killed-hashtb)
14962 (if gnus-subscribe-hierarchical-interactive
14963 (push group new-newsgroups)
14964 (funcall gnus-subscribe-newsgroup-method group)))))))
14966 (when new-newsgroups
14967 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
14968 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14970 (gnus-message 6 "%d new newsgroup%s arrived."
14971 groups (if (> groups 1) "s have" " has")))
14972 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14975 (defun gnus-check-first-time-used ()
14976 (if (or (> (length gnus-newsrc-alist) 1)
14977 (file-exists-p gnus-startup-file)
14978 (file-exists-p (concat gnus-startup-file ".el"))
14979 (file-exists-p (concat gnus-startup-file ".eld")))
14981 (gnus-message 6 "First time user; subscribing you to default groups")
14982 (unless gnus-have-read-active-file
14983 (gnus-read-active-file))
14984 (setq gnus-newsrc-last-checked-date (current-time-string))
14985 (let ((groups gnus-default-subscribed-newsgroups)
14989 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
14992 (if (null (setq group (symbol-name sym)))
14994 (let ((do-sub (gnus-matches-options-n group)))
14996 ((eq do-sub 'subscribe)
14997 (gnus-sethash group group gnus-killed-hashtb)
14998 (funcall gnus-subscribe-options-newsgroup-method group))
14999 ((eq do-sub 'ignore)
15002 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15003 gnus-active-hashtb)
15005 (if (gnus-active (car groups))
15006 (gnus-group-change-level
15007 (car groups) gnus-level-default-subscribed gnus-level-killed))
15008 (setq groups (cdr groups)))
15009 (gnus-group-make-help-group)
15010 (and gnus-novice-user
15011 (gnus-message 7 "`A k' to list killed groups"))))))
15013 (defun gnus-subscribe-group (group previous &optional method)
15014 (gnus-group-change-level
15016 (list t group gnus-level-default-subscribed nil nil method)
15018 gnus-level-default-subscribed gnus-level-killed previous t))
15020 ;; `gnus-group-change-level' is the fundamental function for changing
15021 ;; subscription levels of newsgroups. This might mean just changing
15022 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15023 ;; again, which subscribes/unsubscribes a group, which is equally
15024 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15025 ;; from 8-9 to 1-7 means that you remove the group from the list of
15026 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15027 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15028 ;; which is trivial.
15029 ;; ENTRY can either be a string (newsgroup name) or a list (if
15030 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15031 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15033 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15034 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15036 (defun gnus-group-change-level (entry level &optional oldlevel
15037 previous fromkilled)
15038 (let (group info active num)
15039 ;; Glean what info we can from the arguments
15041 (if fromkilled (setq group (nth 1 entry))
15042 (setq group (car (nth 2 entry))))
15043 (setq group entry))
15044 (if (and (stringp entry)
15046 (< oldlevel gnus-level-zombie))
15047 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15048 (if (and (not oldlevel)
15050 (setq oldlevel (car (cdr (nth 2 entry)))))
15051 (if (stringp previous)
15052 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15054 (if (and (>= oldlevel gnus-level-zombie)
15055 (gnus-gethash group gnus-newsrc-hashtb))
15056 ;; We are trying to subscribe a group that is already
15060 (or (gnus-ephemeral-group-p group)
15061 (gnus-dribble-enter
15062 (format "(gnus-group-change-level %S %S %S %S %S)"
15063 group level oldlevel (car (nth 2 previous)) fromkilled)))
15065 ;; Then we remove the newgroup from any old structures, if needed.
15066 ;; If the group was killed, we remove it from the killed or zombie
15067 ;; list. If not, and it is in fact going to be killed, we remove
15068 ;; it from the newsrc hash table and assoc.
15070 ((>= oldlevel gnus-level-zombie)
15071 (if (= oldlevel gnus-level-zombie)
15072 (setq gnus-zombie-list (delete group gnus-zombie-list))
15073 (setq gnus-killed-list (delete group gnus-killed-list))))
15075 (if (and (>= level gnus-level-zombie)
15078 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15080 (setcdr (gnus-gethash (car (nth 3 entry))
15081 gnus-newsrc-hashtb)
15083 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
15085 ;; Finally we enter (if needed) the list where it is supposed to
15086 ;; go, and change the subscription level. If it is to be killed,
15087 ;; we enter it into the killed or zombie list.
15089 ((>= level gnus-level-zombie)
15090 ;; Remove from the hash table.
15091 (gnus-sethash group nil gnus-newsrc-hashtb)
15092 ;; We do not enter foreign groups into the list of dead
15094 (unless (gnus-group-foreign-p group)
15095 (if (= level gnus-level-zombie)
15096 (setq gnus-zombie-list (cons group gnus-zombie-list))
15097 (setq gnus-killed-list (cons group gnus-killed-list)))))
15099 ;; If the list is to be entered into the newsrc assoc, and
15100 ;; it was killed, we have to create an entry in the newsrc
15101 ;; hashtb format and fix the pointers in the newsrc assoc.
15102 (if (< oldlevel gnus-level-zombie)
15103 ;; It was alive, and it is going to stay alive, so we
15104 ;; just change the level and don't change any pointers or
15105 ;; hash table entries.
15106 (setcar (cdr (car (cdr (cdr entry)))) level)
15108 (setq info (cdr entry)
15110 (setq active (gnus-active group))
15112 (if active (- (1+ (cdr active)) (car active)) t))
15113 ;; Check whether the group is foreign. If so, the
15114 ;; foreign select method has to be entered into the
15116 (let ((method (or gnus-override-subscribe-method
15117 (gnus-group-method group))))
15118 (if (eq method gnus-select-method)
15119 (setq info (list group level nil))
15120 (setq info (list group level nil nil method)))))
15123 (let ((p gnus-newsrc-alist))
15124 (while (cdr (cdr p))
15127 (setq entry (cons info (cdr (cdr previous))))
15130 (setcdr (cdr previous) entry)
15131 (gnus-sethash group (cons num (cdr previous))
15132 gnus-newsrc-hashtb))
15133 (setcdr previous entry)
15134 (gnus-sethash group (cons num previous)
15135 gnus-newsrc-hashtb))
15137 (setcdr (gnus-gethash (car (car (cdr entry))) gnus-newsrc-hashtb)
15139 (when gnus-group-change-level-function
15140 (funcall gnus-group-change-level-function group level oldlevel)))))
15142 (defun gnus-kill-newsgroup (newsgroup)
15143 "Obsolete function. Kills a newsgroup."
15144 (gnus-group-change-level
15145 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15147 (defun gnus-check-bogus-newsgroups (&optional confirm)
15148 "Remove bogus newsgroups.
15149 If CONFIRM is non-nil, the user has to confirm the deletion of every
15151 (let ((newsrc (cdr gnus-newsrc-alist))
15152 bogus group entry info)
15153 (gnus-message 5 "Checking bogus newsgroups...")
15154 (unless gnus-have-read-active-file
15155 (gnus-read-active-file))
15156 (when (member gnus-select-method gnus-have-read-active-file)
15157 ;; Find all bogus newsgroup that are subscribed.
15159 (setq info (pop newsrc)
15160 group (gnus-info-group info))
15161 (unless (or (gnus-active group) ; Active
15162 (gnus-info-method info) ; Foreign
15164 (not (gnus-y-or-n-p
15165 (format "Remove bogus newsgroup: %s " group)))))
15166 ;; Found a bogus newsgroup.
15167 (push group bogus)))
15168 ;; Remove all bogus subscribed groups by first killing them, and
15169 ;; then removing them from the list of killed groups.
15171 (when (setq entry (gnus-gethash (setq group (pop bogus))
15172 gnus-newsrc-hashtb))
15173 (gnus-group-change-level entry gnus-level-killed)
15174 (setq gnus-killed-list (delete group gnus-killed-list))))
15175 ;; Then we remove all bogus groups from the list of killed and
15176 ;; zombie groups. They are are removed without confirmation.
15177 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15180 (setq killed (symbol-value (car dead-lists)))
15182 (unless (gnus-active (setq group (pop killed)))
15183 ;; The group is bogus.
15184 ;; !!!Slow as hell.
15185 (set (car dead-lists)
15186 (delete group (symbol-value (car dead-lists))))))
15187 (setq dead-lists (cdr dead-lists))))
15188 (gnus-message 5 "Checking bogus newsgroups...done"))))
15190 (defun gnus-check-duplicate-killed-groups ()
15191 "Remove duplicates from the list of killed groups."
15193 (let ((killed gnus-killed-list))
15195 (gnus-message 9 "%d" (length killed))
15196 (setcdr killed (delete (car killed) (cdr killed)))
15197 (setq killed (cdr killed)))))
15199 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15200 ;; and compute how many unread articles there are in each group.
15201 (defun gnus-get-unread-articles (&optional level)
15202 (let* ((newsrc (cdr gnus-newsrc-alist))
15203 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15206 (cond ((and gnus-activate-foreign-newsgroups
15207 (not (numberp gnus-activate-foreign-newsgroups)))
15208 (1+ gnus-level-subscribed))
15209 ((numberp gnus-activate-foreign-newsgroups)
15210 gnus-activate-foreign-newsgroups)
15213 info group active virtuals method)
15214 (gnus-message 5 "Checking new news...")
15217 (setq info (car newsrc)
15218 group (gnus-info-group info)
15219 active (gnus-active group))
15221 ;; Check newsgroups. If the user doesn't want to check them, or
15222 ;; they can't be checked (for instance, if the news server can't
15223 ;; be reached) we just set the number of unread articles in this
15224 ;; newsgroup to t. This means that Gnus thinks that there are
15225 ;; unread articles, but it has no idea how many.
15226 (if (and (setq method (gnus-info-method info))
15227 (not (gnus-server-equal
15229 (gnus-server-get-method nil method)))
15230 (not (gnus-secondary-method-p method)))
15231 ;; These groups are foreign. Check the level.
15232 (when (<= (gnus-info-level info) foreign-level)
15233 (setq active (gnus-activate-group group 'scan))
15234 (gnus-close-group group))
15236 ;; These groups are native or secondary.
15237 (when (and (<= (gnus-info-level info) level)
15238 (not gnus-read-active-file))
15239 (setq active (gnus-activate-group group 'scan))
15240 (gnus-close-group group)))
15243 (gnus-get-unread-articles-in-group info active t)
15244 ;; The group couldn't be reached, so we nix out the number of
15245 ;; unread articles and stuff.
15246 (gnus-set-active group nil)
15247 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
15249 (setq newsrc (cdr newsrc)))
15251 (gnus-message 5 "Checking new news...done")))
15253 ;; Create a hash table out of the newsrc alist. The `car's of the
15254 ;; alist elements are used as keys.
15255 (defun gnus-make-hashtable-from-newsrc-alist ()
15256 (let ((alist gnus-newsrc-alist)
15257 (ohashtb gnus-newsrc-hashtb)
15259 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15261 (setq prev (setq gnus-newsrc-alist
15262 (if (equal (car (car gnus-newsrc-alist))
15265 (cons (list "dummy.group" 0 nil) alist)))))
15269 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
15271 gnus-newsrc-hashtb)
15273 alist (cdr alist)))))
15275 (defun gnus-make-hashtable-from-killed ()
15276 "Create a hash table from the killed and zombie lists."
15277 (let ((lists '(gnus-killed-list gnus-zombie-list))
15279 (setq gnus-killed-hashtb
15280 (gnus-make-hashtable
15281 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15283 (setq list (symbol-value (car lists)))
15284 (setq lists (cdr lists))
15286 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15287 (setq list (cdr list))))))
15289 (defun gnus-get-unread-articles-in-group (info active &optional update)
15291 ;; Allow the backend to update the info in the group.
15293 (gnus-request-update-info
15294 info (gnus-find-method-for-group (gnus-info-group info))))
15295 (let* ((range (gnus-info-read info))
15297 (marked (gnus-info-marks info)))
15298 ;; If a cache is present, we may have to alter the active info.
15299 (and gnus-use-cache
15300 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15301 ;; Modify the list of read articles according to what articles
15302 ;; are available; then tally the unread articles and add the
15303 ;; number to the group hash table entry.
15305 ((zerop (cdr active))
15308 (setq num (- (1+ (cdr active)) (car active))))
15309 ((not (listp (cdr range)))
15310 ;; Fix a single (num . num) range according to the
15311 ;; active hash table.
15312 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15313 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15314 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15315 ;; Compute number of unread articles.
15316 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15318 ;; The read list is a list of ranges. Fix them according to
15319 ;; the active hash table.
15320 ;; First peel off any elements that are below the lower
15322 (while (and (cdr range)
15324 (or (and (atom (car (cdr range))) (car (cdr range)))
15325 (car (car (cdr range))))))
15326 (if (numberp (car range))
15329 (or (and (numberp (car (cdr range)))
15331 (cdr (car (cdr range))))))
15332 (setcdr (car range)
15333 (or (and (numberp (nth 1 range)) (nth 1 range))
15334 (cdr (car (cdr range))))))
15335 (setcdr range (cdr (cdr range))))
15336 ;; Adjust the first element to be the same as the lower limit.
15337 (if (and (not (atom (car range)))
15338 (< (cdr (car range)) (car active)))
15339 (setcdr (car range) (1- (car active))))
15340 ;; Then we want to peel off any elements that are higher
15341 ;; than the upper active limit.
15342 (let ((srange range))
15343 ;; Go past all legal elements.
15344 (while (and (cdr srange)
15345 (<= (or (and (atom (car (cdr srange)))
15346 (car (cdr srange)))
15347 (car (car (cdr srange)))) (cdr active)))
15348 (setq srange (cdr srange)))
15350 ;; Nuke all remaining illegal elements.
15351 (setcdr srange nil))
15353 ;; Adjust the final element.
15354 (if (and (not (atom (car srange)))
15355 (> (cdr (car srange)) (cdr active)))
15356 (setcdr (car srange) (cdr active))))
15357 ;; Compute the number of unread articles.
15359 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15360 (cdr (car range))))
15361 (or (and (atom (car range)) (car range))
15362 (car (car range))))))
15363 (setq range (cdr range)))
15364 (setq num (max 0 (- (cdr active) num)))))
15365 ;; Set the number of unread articles.
15366 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
15369 (defun gnus-activate-group (group &optional scan)
15370 ;; Check whether a group has been activated or not.
15371 ;; If SCAN, request a scan of that group as well.
15372 (let ((method (gnus-find-method-for-group group))
15374 (and (gnus-check-server method)
15375 ;; We escape all bugs and quit here to make it possible to
15376 ;; continue if a group is so out-there that it reports bugs
15380 (gnus-check-backend-function 'request-scan (car method))
15381 (gnus-request-scan group method))
15384 (gnus-request-group group)
15388 (set-buffer nntp-server-buffer)
15389 (goto-char (point-min))
15390 ;; Parse the result we got from `gnus-request-group'.
15391 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15393 (goto-char (match-beginning 1))
15395 group (setq active (cons (read (current-buffer))
15396 (read (current-buffer)))))
15397 ;; Return the new active info.
15400 (defun gnus-update-read-articles (group unread)
15401 "Update the list of read and ticked articles in GROUP using the
15402 UNREAD and TICKED lists.
15403 Note: UNSELECTED has to be sorted over `<'.
15404 Returns whether the updating was successful."
15405 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15406 (entry (gnus-gethash group gnus-newsrc-hashtb))
15407 (info (nth 2 entry))
15408 (marked (gnus-info-marks info))
15410 (unread (sort (copy-sequence unread) '<))
15412 (if (or (not info) (not active))
15413 ;; There is no info on this group if it was, in fact,
15414 ;; killed. Gnus stores no information on killed groups, so
15415 ;; there's nothing to be done.
15416 ;; One could store the information somewhere temporarily,
15417 ;; perhaps... Hmmm...
15419 ;; Remove any negative articles numbers.
15420 (while (and unread (< (car unread) 0))
15421 (setq unread (cdr unread)))
15422 ;; Remove any expired article numbers
15423 (while (and unread (< (car unread) (car active)))
15424 (setq unread (cdr unread)))
15425 ;; Compute the ranges of read articles by looking at the list of
15426 ;; unread articles.
15428 (if (/= (car unread) prev)
15429 (setq read (cons (if (= prev (1- (car unread))) prev
15430 (cons prev (1- (car unread)))) read)))
15431 (setq prev (1+ (car unread)))
15432 (setq unread (cdr unread)))
15433 (when (<= prev (cdr active))
15434 (setq read (cons (cons prev (cdr active)) read)))
15435 ;; Enter this list into the group info.
15436 (gnus-info-set-read
15437 info (if (> (length read) 1) (nreverse read) read))
15438 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15439 (gnus-get-unread-articles-in-group info (gnus-active group))
15442 (defun gnus-make-articles-unread (group articles)
15443 "Mark ARTICLES in GROUP as unread."
15444 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15445 (gnus-gethash (gnus-group-real-name group)
15446 gnus-newsrc-hashtb))))
15447 (ranges (gnus-info-read info))
15450 (when (gnus-member-of-range
15451 (setq article (pop articles)) ranges)
15452 (setq news (cons article news))))
15454 (gnus-info-set-read
15455 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15456 (gnus-group-update-group group t))))
15458 ;; Enter all dead groups into the hashtb.
15459 (defun gnus-update-active-hashtb-from-killed ()
15460 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15461 (lists (list gnus-killed-list gnus-zombie-list))
15464 (setq killed (car lists))
15466 (gnus-sethash (car killed) nil hashtb)
15467 (setq killed (cdr killed)))
15468 (setq lists (cdr lists)))))
15470 ;; Get the active file(s) from the backend(s).
15471 (defun gnus-read-active-file ()
15472 (gnus-group-set-mode-line)
15475 (if (gnus-check-server gnus-select-method)
15476 ;; The native server is available.
15477 (cons gnus-select-method gnus-secondary-select-methods)
15478 ;; The native server is down, so we just do the
15480 gnus-secondary-select-methods)
15481 ;; Also read from the archive server.
15484 (setq gnus-have-read-active-file nil)
15486 (set-buffer nntp-server-buffer)
15488 (let* ((method (if (stringp (car methods))
15489 (gnus-server-get-method nil (car methods))
15491 (where (nth 1 method))
15492 (mesg (format "Reading active file%s via %s..."
15493 (if (and where (not (zerop (length where))))
15494 (concat " from " where) "")
15496 (gnus-message 5 mesg)
15497 (if (not (gnus-check-server method))
15499 ;; Request that the backend scan its incoming messages.
15500 (and (gnus-check-backend-function 'request-scan (car method))
15501 (gnus-request-scan nil method))
15503 ((and (eq gnus-read-active-file 'some)
15504 (gnus-check-backend-function 'retrieve-groups (car method)))
15505 (let ((newsrc (cdr gnus-newsrc-alist))
15506 (gmethod (gnus-server-get-method nil method))
15509 (and (gnus-server-equal
15510 (gnus-find-method-for-group
15511 (car (car newsrc)) (car newsrc))
15513 (setq groups (cons (gnus-group-real-name
15514 (car (car newsrc))) groups)))
15515 (setq newsrc (cdr newsrc)))
15516 (gnus-check-server method)
15517 (setq list-type (gnus-retrieve-groups groups method))
15521 1 "Cannot read partial active file from %s server."
15525 ((eq list-type 'active)
15526 (gnus-active-to-gnus-format method gnus-active-hashtb))
15528 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
15530 (if (not (gnus-request-list method))
15532 (unless (equal method gnus-message-archive-method)
15533 (gnus-message 1 "Cannot read active file from %s server."
15536 (gnus-active-to-gnus-format method)
15537 ;; We mark this active file as read.
15538 (push method gnus-have-read-active-file)
15539 (gnus-message 5 "%sdone" mesg))))))
15540 (setq methods (cdr methods))))))
15542 ;; Read an active file and place the results in `gnus-active-hashtb'.
15543 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15545 (setq method gnus-select-method))
15546 (let ((cur (current-buffer))
15548 (if (and gnus-active-hashtb
15549 (not (equal method gnus-select-method)))
15551 (setq gnus-active-hashtb
15552 (if (equal method gnus-select-method)
15553 (gnus-make-hashtable
15554 (count-lines (point-min) (point-max)))
15555 (gnus-make-hashtable 4096))))))
15556 (flag-hashtb (gnus-make-hashtable 60)))
15557 ;; Delete unnecessary lines.
15558 (goto-char (point-min))
15559 (while (search-forward "\nto." nil t)
15560 (delete-region (1+ (match-beginning 0))
15561 (progn (forward-line 1) (point))))
15562 (or (string= gnus-ignored-newsgroups "")
15564 (goto-char (point-min))
15565 (delete-matching-lines gnus-ignored-newsgroups)))
15566 ;; Make the group names readable as a lisp expression even if they
15567 ;; contain special characters.
15568 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15569 (goto-char (point-max))
15570 (while (re-search-backward "[][';?()#]" nil t)
15572 ;; If these are groups from a foreign select method, we insert the
15573 ;; group prefix in front of the group names.
15574 (and method (not (gnus-server-equal
15575 (gnus-server-get-method nil method)
15576 (gnus-server-get-method nil gnus-select-method)))
15577 (let ((prefix (gnus-group-prefixed-name "" method)))
15578 (goto-char (point-min))
15579 (while (and (not (eobp))
15580 (progn (insert prefix)
15581 (zerop (forward-line 1)))))))
15582 ;; Store the active file in a hash table.
15583 (goto-char (point-min))
15584 (if (string-match "%[oO]" gnus-group-line-format)
15585 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15586 ;; If we want information on moderated groups, we use this
15588 (let* ((mod-hashtb (make-vector 7 0))
15589 (m (intern "m" mod-hashtb))
15591 (while (not (eobp))
15592 (condition-case nil
15594 (narrow-to-region (point) (gnus-point-at-eol))
15595 (setq group (let ((obarray hashtb)) (read cur)))
15596 (if (and (numberp (setq max (read cur)))
15597 (numberp (setq min (read cur)))
15599 (skip-chars-forward " \t")
15601 (or (= (following-char) ?=)
15602 (= (following-char) ?x)
15603 (= (following-char) ?j)))))
15604 (set group (cons min max))
15606 ;; Enter moderated groups into a list.
15607 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15608 (setq gnus-moderated-list
15609 (cons (symbol-name group) gnus-moderated-list))))
15616 ;; And if we do not care about moderation, we use this loop,
15617 ;; which is faster.
15618 (let (group max min)
15619 (while (not (eobp))
15622 (narrow-to-region (point) (gnus-point-at-eol))
15623 ;; group gets set to a symbol interned in the hash table
15624 ;; (what a hack!!) - jwz
15625 (setq group (let ((obarray hashtb)) (read cur)))
15626 (if (and (numberp (setq max (read cur)))
15627 (numberp (setq min (read cur)))
15629 (skip-chars-forward " \t")
15631 (or (= (following-char) ?=)
15632 (= (following-char) ?x)
15633 (= (following-char) ?j)))))
15634 (set group (cons min max))
15642 (gnus-message 3 "Warning - illegal active: %s"
15644 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15646 (forward-line 1))))))
15648 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15649 ;; Parse a "groups" active file.
15650 (let ((cur (current-buffer))
15652 (if (and method gnus-active-hashtb)
15654 (setq gnus-active-hashtb
15655 (gnus-make-hashtable
15656 (count-lines (point-min) (point-max)))))))
15657 (prefix (and method
15658 (not (gnus-server-equal
15659 (gnus-server-get-method nil method)
15660 (gnus-server-get-method nil gnus-select-method)))
15661 (gnus-group-prefixed-name "" method))))
15663 (goto-char (point-min))
15664 ;; We split this into to separate loops, one with the prefix
15665 ;; and one without to speed the reading up somewhat.
15667 (let (min max opoint group)
15668 (while (not (eobp))
15671 (read cur) (read cur)
15672 (setq min (read cur)
15675 (skip-chars-forward " \t")
15678 (set (let ((obarray hashtb)) (read cur))
15680 (error (and group (symbolp group) (set group nil))))
15682 (let (min max group)
15683 (while (not (eobp))
15685 (if (= (following-char) ?2)
15687 (read cur) (read cur)
15688 (setq min (read cur)
15690 (set (setq group (let ((obarray hashtb)) (read cur)))
15692 (error (and group (symbolp group) (set group nil))))
15693 (forward-line 1))))))
15695 (defun gnus-read-newsrc-file (&optional force)
15696 "Read startup file.
15697 If FORCE is non-nil, the .newsrc file is read."
15698 ;; Reset variables that might be defined in the .newsrc.eld file.
15699 (let ((variables gnus-variable-list))
15701 (set (car variables) nil)
15702 (setq variables (cdr variables))))
15703 (let* ((newsrc-file gnus-current-startup-file)
15704 (quick-file (concat newsrc-file ".el")))
15706 ;; We always load the .newsrc.eld file. If always contains
15707 ;; much information that can not be gotten from the .newsrc
15708 ;; file (ticked articles, killed groups, foreign methods, etc.)
15709 (gnus-read-newsrc-el-file quick-file)
15712 (and (file-newer-than-file-p newsrc-file quick-file)
15713 (file-newer-than-file-p newsrc-file
15714 (concat quick-file "d")))
15715 (not gnus-newsrc-alist))
15716 ;; We read the .newsrc file. Note that if there if a
15717 ;; .newsrc.eld file exists, it has already been read, and
15718 ;; the `gnus-newsrc-hashtb' has been created. While reading
15719 ;; the .newsrc file, Gnus will only use the information it
15720 ;; can find there for changing the data already read -
15721 ;; ie. reading the .newsrc file will not trash the data
15722 ;; already read (except for read articles).
15724 (gnus-message 5 "Reading %s..." newsrc-file)
15725 (set-buffer (find-file-noselect newsrc-file))
15726 (buffer-disable-undo (current-buffer))
15727 (gnus-newsrc-to-gnus-format)
15728 (kill-buffer (current-buffer))
15729 (gnus-message 5 "Reading %s...done" newsrc-file)))
15731 ;; Read any slave files.
15733 (gnus-master-read-slave-newsrc)))))
15735 (defun gnus-read-newsrc-el-file (file)
15736 (let ((ding-file (concat file "d")))
15737 ;; We always, always read the .eld file.
15738 (gnus-message 5 "Reading %s..." ding-file)
15739 (let (gnus-newsrc-assoc)
15740 (condition-case nil
15741 (load ding-file t t t)
15743 (gnus-message 1 "Error in %s" ding-file)
15745 (when gnus-newsrc-assoc
15746 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15747 (gnus-make-hashtable-from-newsrc-alist)
15748 (when (file-newer-than-file-p file ding-file)
15749 ;; Old format quick file
15750 (gnus-message 5 "Reading %s..." file)
15751 ;; The .el file is newer than the .eld file, so we read that one
15753 (gnus-read-old-newsrc-el-file file))))
15755 ;; Parse the old-style quick startup file
15756 (defun gnus-read-old-newsrc-el-file (file)
15757 (let (newsrc killed marked group m)
15759 (let ((gnus-killed-assoc nil)
15760 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15762 (condition-case nil
15765 (setq newsrc gnus-newsrc-assoc
15766 killed gnus-killed-assoc
15767 marked gnus-marked-assoc)))
15768 (setq gnus-newsrc-alist nil)
15770 (setq group (car newsrc))
15771 (let ((info (gnus-get-info (car group))))
15774 (gnus-info-set-read info (cdr (cdr group)))
15775 (gnus-info-set-level
15776 info (if (nth 1 group) gnus-level-default-subscribed
15777 gnus-level-default-unsubscribed))
15778 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15779 (setq gnus-newsrc-alist
15783 (if (nth 1 group) gnus-level-default-subscribed
15784 gnus-level-default-unsubscribed)
15785 (cdr (cdr group))))
15786 gnus-newsrc-alist)))
15787 (if (setq m (assoc (car group) marked))
15788 (gnus-info-set-marks
15789 info (cons (list (cons 'tick (gnus-compress-sequence
15790 (sort (cdr m) '<) t)))
15792 (setq newsrc (cdr newsrc)))
15793 (setq newsrc killed)
15795 (setcar newsrc (car (car newsrc)))
15796 (setq newsrc (cdr newsrc)))
15797 (setq gnus-killed-list killed))
15798 ;; The .el file version of this variable does not begin with
15799 ;; "options", while the .eld version does, so we just add it if it
15802 gnus-newsrc-options
15804 (and (not (string-match "^ *options" gnus-newsrc-options))
15805 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15806 (and (not (string-match "\n$" gnus-newsrc-options))
15807 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15808 ;; Finally, if we read some options lines, we parse them.
15809 (or (string= gnus-newsrc-options "")
15810 (gnus-newsrc-parse-options gnus-newsrc-options))))
15812 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15813 (gnus-make-hashtable-from-newsrc-alist)))
15815 (defun gnus-make-newsrc-file (file)
15816 "Make server dependent file name by catenating FILE and server host name."
15817 (let* ((file (expand-file-name file nil))
15818 (real-file (concat file "-" (nth 1 gnus-select-method))))
15819 (if (or (file-exists-p real-file)
15820 (file-exists-p (concat real-file ".el"))
15821 (file-exists-p (concat real-file ".eld")))
15824 (defun gnus-newsrc-to-gnus-format ()
15825 (setq gnus-newsrc-options "")
15826 (setq gnus-newsrc-options-n nil)
15828 (or gnus-active-hashtb
15829 (setq gnus-active-hashtb (make-vector 4095 0)))
15830 (let ((buf (current-buffer))
15831 (already-read (> (length gnus-newsrc-alist) 1))
15832 group subscribed options-symbol newsrc Options-symbol
15834 (goto-char (point-min))
15835 ;; We intern the symbol `options' in the active hashtb so that we
15836 ;; can `eq' against it later.
15837 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15838 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15840 (while (not (eobp))
15841 ;; We first read the first word on the line by narrowing and
15842 ;; then reading into `gnus-active-hashtb'. Most groups will
15843 ;; already exist in that hashtb, so this will save some string
15847 (progn (skip-chars-forward "^ \t!:\n") (point)))
15848 (goto-char (point-min))
15850 (and (/= (point-min) (point-max))
15851 (let ((obarray gnus-active-hashtb)) (read buf))))
15853 ;; Now, the symbol we have read is either `options' or a group
15854 ;; name. If it is an options line, we just add it to a string.
15856 ((or (eq symbol options-symbol)
15857 (eq symbol Options-symbol))
15858 (setq gnus-newsrc-options
15859 ;; This concating is quite inefficient, but since our
15860 ;; thorough studies show that approx 99.37% of all
15861 ;; .newsrc files only contain a single options line, we
15862 ;; don't give a damn, frankly, my dear.
15863 (concat gnus-newsrc-options
15865 (gnus-point-at-bol)
15866 ;; Options may continue on the next line.
15867 (or (and (re-search-forward "^[^ \t]" nil 'move)
15868 (progn (beginning-of-line) (point)))
15872 ;; Group names can be just numbers.
15873 (when (numberp symbol)
15874 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15875 (or (boundp symbol) (set symbol nil))
15876 ;; It was a group name.
15877 (setq subscribed (= (following-char) ?:)
15878 group (symbol-name symbol)
15881 ;; If the line ends here, this is clearly a buggy line, so
15882 ;; we put point a the beginning of line and let the cond
15883 ;; below do the error handling.
15884 (beginning-of-line)
15885 ;; We skip to the beginning of the ranges.
15886 (skip-chars-forward "!: \t"))
15887 ;; We are now at the beginning of the list of read articles.
15888 ;; We read them range by range.
15891 ((looking-at "[0-9]+")
15892 ;; We narrow and read a number instead of buffer-substring/
15893 ;; string-to-int because it's faster. narrow/widen is
15894 ;; faster than save-restriction/narrow, and save-restriction
15895 ;; produces a garbage object.
15897 (narrow-to-region (match-beginning 0) (match-end 0))
15900 ;; If the next character is a dash, then this is a range.
15901 (if (= (following-char) ?-)
15903 ;; We read the upper bound of the range.
15905 (if (not (looking-at "[0-9]+"))
15906 ;; This is a buggy line, by we pretend that
15907 ;; it's kinda OK. Perhaps the user should be
15909 (setq reads (cons num1 reads))
15914 (narrow-to-region (match-beginning 0)
15919 ;; It was just a simple number, so we add it to the
15921 (setq reads (cons num1 reads)))
15922 ;; If the next char in ?\n, then we have reached the end
15923 ;; of the line and return nil.
15924 (/= (following-char) ?\n))
15925 ((= (following-char) ?\n)
15926 ;; End of line, so we end.
15929 ;; Not numbers and not eol, so this might be a buggy
15932 ;; If it was eob instead of ?\n, we allow it.
15934 ;; The line was buggy.
15936 (gnus-message 3 "Mangled line: %s"
15937 (buffer-substring (gnus-point-at-bol)
15938 (gnus-point-at-eol)))
15942 ;; Skip past ", ". Spaces are illegal in these ranges, but
15943 ;; we allow them, because it's a common mistake to put a
15944 ;; space after the comma.
15945 (skip-chars-forward ", "))
15947 ;; We have already read .newsrc.eld, so we gently update the
15948 ;; data in the hash table with the information we have just
15951 (let ((info (gnus-get-info group))
15954 ;; There is an entry for this file in the alist.
15956 (gnus-info-set-read info (nreverse reads))
15957 ;; We update the level very gently. In fact, we
15958 ;; only change it if there's been a status change
15959 ;; from subscribed to unsubscribed, or vice versa.
15960 (setq level (gnus-info-level info))
15961 (cond ((and (<= level gnus-level-subscribed)
15963 (setq level (if reads
15964 gnus-level-default-unsubscribed
15965 (1+ gnus-level-default-unsubscribed))))
15966 ((and (> level gnus-level-subscribed) subscribed)
15967 (setq level gnus-level-default-subscribed)))
15968 (gnus-info-set-level info level))
15969 ;; This is a new group.
15970 (setq info (list group
15972 gnus-level-default-subscribed
15974 (1+ gnus-level-subscribed)
15975 gnus-level-default-unsubscribed))
15976 (nreverse reads))))
15977 (setq newsrc (cons info newsrc))))))
15980 (setq newsrc (nreverse newsrc))
15982 (if (not already-read)
15984 ;; We now have two newsrc lists - `newsrc', which is what we
15985 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
15986 ;; what we've read from .newsrc.eld. We have to merge these
15987 ;; lists. We do this by "attaching" any (foreign) groups in the
15988 ;; gnus-newsrc-alist to the (native) group that precedes them.
15989 (let ((rc (cdr gnus-newsrc-alist))
15990 (prev gnus-newsrc-alist)
15993 (or (null (nth 4 (car rc))) ; It's a native group.
15994 (assoc (car (car rc)) newsrc) ; It's already in the alist.
15995 (if (setq entry (assoc (car (car prev)) newsrc))
15996 (setcdr (setq mentry (memq entry newsrc))
15997 (cons (car rc) (cdr mentry)))
15998 (setq newsrc (cons (car rc) newsrc))))
16002 (setq gnus-newsrc-alist newsrc)
16003 ;; We make the newsrc hashtb.
16004 (gnus-make-hashtable-from-newsrc-alist)
16006 ;; Finally, if we read some options lines, we parse them.
16007 (or (string= gnus-newsrc-options "")
16008 (gnus-newsrc-parse-options gnus-newsrc-options))))
16010 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16011 ;; The return value will be a list on the form
16012 ;; ((regexp1 . ignore)
16013 ;; (regexp2 . subscribe)...)
16014 ;; When handling new newsgroups, groups that match a `ignore' regexp
16015 ;; will be ignored, and groups that match a `subscribe' regexp will be
16016 ;; subscribed. A line like
16017 ;; options -n !all rec.all
16018 ;; will lead to a list that looks like
16019 ;; (("^rec\\..+" . subscribe)
16020 ;; ("^.+" . ignore))
16021 ;; So all "rec.*" groups will be subscribed, while all the other
16022 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16023 ;; different from "options -n rec.all !all".
16024 (defun gnus-newsrc-parse-options (options)
16027 (gnus-set-work-buffer)
16028 (insert (regexp-quote options))
16029 ;; First we treat all continuation lines.
16030 (goto-char (point-min))
16031 (while (re-search-forward "\n[ \t]+" nil t)
16032 (replace-match " " t t))
16033 ;; Then we transform all "all"s into ".+"s.
16034 (goto-char (point-min))
16035 (while (re-search-forward "\\ball\\b" nil t)
16036 (replace-match ".+" t t))
16037 (goto-char (point-min))
16038 ;; We remove all other options than the "-n" ones.
16039 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16040 (replace-match " ")
16042 (goto-char (point-min))
16044 ;; We are only interested in "options -n" lines - we
16045 ;; ignore the other option lines.
16046 (while (re-search-forward "[ \t]-n" nil t)
16048 (or (save-excursion
16049 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16051 (gnus-point-at-eol)))
16052 ;; Search for all "words"...
16053 (while (re-search-forward "[^ \t,\n]+" eol t)
16054 (if (= (char-after (match-beginning 0)) ?!)
16055 ;; If the word begins with a bang (!), this is a "not"
16056 ;; spec. We put this spec (minus the bang) and the
16057 ;; symbol `ignore' into the list.
16058 (setq out (cons (cons (concat
16059 "^" (buffer-substring
16060 (1+ (match-beginning 0))
16063 ;; There was no bang, so this is a "yes" spec.
16064 (setq out (cons (cons (concat "^" (match-string 0))
16065 'subscribe) out)))))
16067 (setq gnus-newsrc-options-n out))))
16069 (defun gnus-save-newsrc-file (&optional force)
16070 "Save .newsrc file."
16071 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16072 ;; from the variable gnus-newsrc-alist.
16073 (when (and (or gnus-newsrc-alist gnus-killed-list)
16074 gnus-current-startup-file)
16076 (if (and (or gnus-use-dribble-file gnus-slave)
16078 (or (not gnus-dribble-buffer)
16079 (not (buffer-name gnus-dribble-buffer))
16080 (zerop (save-excursion
16081 (set-buffer gnus-dribble-buffer)
16083 (gnus-message 4 "(No changes need to be saved)")
16084 (run-hooks 'gnus-save-newsrc-hook)
16086 (gnus-slave-save-newsrc)
16088 (when gnus-save-newsrc-file
16089 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16090 (gnus-gnus-to-newsrc-format)
16091 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16092 ;; Save .newsrc.eld.
16093 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16094 (make-local-variable 'version-control)
16095 (setq version-control 'never)
16096 (setq buffer-file-name
16097 (concat gnus-current-startup-file ".eld"))
16098 (gnus-add-current-to-buffer-list)
16099 (buffer-disable-undo (current-buffer))
16101 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16102 (gnus-gnus-to-quick-newsrc-format)
16103 (run-hooks 'gnus-save-quick-newsrc-hook)
16105 (kill-buffer (current-buffer))
16107 5 "Saving %s.eld...done" gnus-current-startup-file))
16108 (gnus-dribble-delete-file)))))
16110 (defun gnus-gnus-to-quick-newsrc-format ()
16111 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16112 (insert ";; Gnus startup file.\n")
16113 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16114 (insert ";; to read .newsrc.\n")
16115 (insert "(setq gnus-newsrc-file-version "
16116 (prin1-to-string gnus-version) ")\n")
16118 (if gnus-save-killed-list gnus-variable-list
16119 ;; Remove the `gnus-killed-list' from the list of variables
16120 ;; to be saved, if required.
16121 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16122 ;; Peel off the "dummy" group.
16123 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16125 ;; Insert the variables into the file.
16127 (when (and (boundp (setq variable (pop variables)))
16128 (symbol-value variable))
16129 (insert "(setq " (symbol-name variable) " '"
16130 (prin1-to-string (symbol-value variable)) ")\n")))))
16132 (defun gnus-gnus-to-newsrc-format ()
16133 ;; Generate and save the .newsrc file.
16134 (let ((newsrc (cdr gnus-newsrc-alist))
16137 (set-buffer (create-file-buffer gnus-current-startup-file))
16138 (setq buffer-file-name gnus-current-startup-file)
16139 (buffer-disable-undo (current-buffer))
16142 (if gnus-newsrc-options (insert gnus-newsrc-options))
16143 ;; Write subscribed and unsubscribed.
16145 (setq info (car newsrc))
16146 (if (not (gnus-info-method info))
16147 ;; Don't write foreign groups to .newsrc.
16149 (insert (gnus-info-group info)
16150 (if (> (gnus-info-level info) gnus-level-subscribed)
16152 (if (setq ranges (gnus-info-read info))
16155 (if (not (listp (cdr ranges)))
16156 (if (= (car ranges) (cdr ranges))
16157 (insert (int-to-string (car ranges)))
16158 (insert (int-to-string (car ranges)) "-"
16159 (int-to-string (cdr ranges))))
16161 (setq range (car ranges)
16162 ranges (cdr ranges))
16163 (if (or (atom range) (= (car range) (cdr range)))
16164 (insert (int-to-string
16165 (or (and (atom range) range)
16167 (insert (int-to-string (car range)) "-"
16168 (int-to-string (cdr range))))
16169 (if ranges (insert ","))))))
16171 (setq newsrc (cdr newsrc)))
16172 (make-local-variable 'version-control)
16173 (setq version-control 'never)
16174 ;; It has been reported that sometime the modtime on the .newsrc
16175 ;; file seems to be off. We really do want to overwrite it, so
16176 ;; we clear the modtime here before saving. It's a bit odd,
16178 ;; sometimes the modtime clear isn't sufficient. most brute force:
16179 ;; delete the silly thing entirely first. but this fails to provide
16180 ;; such niceties as .newsrc~ creation.
16181 (if gnus-modtime-botch
16182 (delete-file gnus-startup-file)
16183 (clear-visited-file-modtime))
16184 (run-hooks 'gnus-save-standard-newsrc-hook)
16186 (kill-buffer (current-buffer)))))
16190 ;;; Slave functions.
16193 (defun gnus-slave-save-newsrc ()
16195 (set-buffer gnus-dribble-buffer)
16197 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16198 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16200 (defun gnus-master-read-slave-newsrc ()
16203 (file-name-directory gnus-current-startup-file)
16207 (file-name-nondirectory gnus-current-startup-file)
16211 (if (not slave-files)
16212 () ; There are no slave files to read.
16213 (gnus-message 7 "Reading slave newsrcs...")
16215 (set-buffer (get-buffer-create " *gnus slave*"))
16216 (buffer-disable-undo (current-buffer))
16218 (sort (mapcar (lambda (file)
16219 (list (nth 5 (file-attributes file)) file))
16222 (or (< (car (car f1)) (car (car f2)))
16223 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16226 (setq file (nth 1 (car slave-files)))
16227 (insert-file-contents file)
16228 (if (condition-case ()
16230 (eval-buffer (current-buffer))
16233 (gnus-message 3 "Possible error in %s" file)
16237 (or gnus-slave ; Slaves shouldn't delete these files.
16241 (setq slave-files (cdr slave-files))))
16242 (gnus-message 7 "Reading slave newsrcs...done"))))
16246 ;;; Group description.
16249 (defun gnus-read-all-descriptions-files ()
16250 (let ((methods (cons gnus-select-method
16252 gnus-secondary-select-methods))))
16254 (gnus-read-descriptions-file (car methods))
16255 (setq methods (cdr methods)))
16258 (defun gnus-read-descriptions-file (&optional method)
16259 (let ((method (or method gnus-select-method)))
16260 (when (stringp method)
16261 (setq method (gnus-server-to-method method)))
16262 ;; We create the hashtable whether we manage to read the desc file
16263 ;; to avoid trying to re-read after a failed read.
16264 (or gnus-description-hashtb
16265 (setq gnus-description-hashtb
16266 (gnus-make-hashtable (length gnus-active-hashtb))))
16267 ;; Mark this method's desc file as read.
16268 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16269 gnus-description-hashtb)
16271 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16273 ((not (gnus-check-server method))
16274 (gnus-message 1 "Couldn't open server")
16276 ((not (gnus-request-list-newsgroups method))
16277 (gnus-message 1 "Couldn't read newsgroups descriptions")
16283 (set-buffer nntp-server-buffer)
16284 (goto-char (point-min))
16285 (if (or (search-forward "\n.\n" nil t)
16286 (goto-char (point-max)))
16288 (beginning-of-line)
16289 (narrow-to-region (point-min) (point))))
16290 (goto-char (point-min))
16291 (while (not (eobp))
16292 ;; If we get an error, we set group to 0, which is not a
16296 (let ((obarray gnus-description-hashtb))
16297 ;; Group is set to a symbol interned in this
16299 (read nntp-server-buffer))
16301 (skip-chars-forward " \t")
16302 ;; ... which leads to this line being effectively ignored.
16303 (and (symbolp group)
16304 (set group (buffer-substring
16305 (point) (progn (end-of-line) (point)))))
16306 (forward-line 1))))
16307 (gnus-message 5 "Reading descriptions file...done")
16310 (defun gnus-group-get-description (group)
16311 "Get the description of a group by sending XGTITLE to the server."
16312 (when (gnus-request-group-description group)
16314 (set-buffer nntp-server-buffer)
16315 (goto-char (point-min))
16316 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16317 (match-string 1)))))
16321 ;;; Buffering of read articles.
16324 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16325 (defvar gnus-backlog-articles nil)
16326 (defvar gnus-backlog-hashtb nil)
16328 (defun gnus-backlog-buffer ()
16329 "Return the backlog buffer."
16330 (or (get-buffer gnus-backlog-buffer)
16332 (set-buffer (get-buffer-create gnus-backlog-buffer))
16333 (buffer-disable-undo (current-buffer))
16334 (setq buffer-read-only t)
16335 (gnus-add-current-to-buffer-list)
16336 (get-buffer gnus-backlog-buffer))))
16338 (defun gnus-backlog-setup ()
16339 "Initialize backlog variables."
16340 (unless gnus-backlog-hashtb
16341 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16343 (defun gnus-backlog-shutdown ()
16344 "Clear all backlog variables and buffers."
16345 (when (get-buffer gnus-backlog-buffer)
16346 (kill-buffer gnus-backlog-buffer))
16347 (setq gnus-backlog-hashtb nil
16348 gnus-backlog-articles nil))
16350 (defun gnus-backlog-enter-article (group number buffer)
16351 (gnus-backlog-setup)
16352 (let ((ident (intern (concat group ":" (int-to-string number))
16353 gnus-backlog-hashtb))
16355 (if (memq ident gnus-backlog-articles)
16356 () ; It's already kept.
16357 ;; Remove the oldest article, if necessary.
16358 (and (numberp gnus-keep-backlog)
16359 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16360 (gnus-backlog-remove-oldest-article))
16361 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16362 ;; Insert the new article.
16364 (set-buffer (gnus-backlog-buffer))
16365 (let (buffer-read-only)
16366 (goto-char (point-max))
16367 (or (bolp) (insert "\n"))
16369 (insert-buffer-substring buffer)
16370 ;; Tag the beginning of the article with the ident.
16371 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16373 (defun gnus-backlog-remove-oldest-article ()
16375 (set-buffer (gnus-backlog-buffer))
16376 (goto-char (point-min))
16377 (if (zerop (buffer-size))
16378 () ; The buffer is empty.
16379 (let ((ident (get-text-property (point) 'gnus-backlog))
16381 ;; Remove the ident from the list of articles.
16383 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16384 ;; Delete the article itself.
16386 (point) (next-single-property-change
16387 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16389 (defun gnus-backlog-request-article (group number buffer)
16390 (gnus-backlog-setup)
16391 (let ((ident (intern (concat group ":" (int-to-string number))
16392 gnus-backlog-hashtb))
16394 (when (memq ident gnus-backlog-articles)
16395 ;; It was in the backlog.
16397 (set-buffer (gnus-backlog-buffer))
16398 (if (not (setq beg (text-property-any
16399 (point-min) (point-max) 'gnus-backlog
16401 ;; It wasn't in the backlog after all.
16403 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16404 ;; Find the end (i. e., the beginning of the next article).
16406 (next-single-property-change
16407 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16408 (let ((buffer-read-only nil))
16410 (insert-buffer-substring gnus-backlog-buffer beg end)
16413 ;; Allow redefinition of Gnus functions.
16415 (gnus-ems-redefine)
16419 ;;; gnus.el ends here