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-read-and-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)
1560 (defvar gnus-created-frames nil)
1562 (defvar gnus-article-mode-map nil)
1563 (defvar gnus-dribble-buffer nil)
1564 (defvar gnus-headers-retrieved-by nil)
1565 (defvar gnus-article-reply nil)
1566 (defvar gnus-override-method nil)
1567 (defvar gnus-article-check-size nil)
1569 (defvar gnus-current-score-file nil)
1570 (defvar gnus-newsgroup-adaptive-score-file nil)
1571 (defvar gnus-scores-exclude-files nil)
1573 (defvar gnus-opened-servers nil)
1575 (defvar gnus-current-move-group nil)
1577 (defvar gnus-newsgroup-dependencies nil)
1578 (defvar gnus-newsgroup-async nil)
1579 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1581 (defvar gnus-newsgroup-adaptive nil)
1583 (defvar gnus-summary-display-table nil)
1584 (defvar gnus-summary-display-article-function nil)
1586 (defvar gnus-summary-highlight-line-function nil
1587 "Function called after highlighting a summary line.")
1589 (defvar gnus-group-line-format-alist
1590 `((?M gnus-tmp-marked-mark ?c)
1591 (?S gnus-tmp-subscribed ?c)
1592 (?L gnus-tmp-level ?d)
1593 (?N (cond ((eq number t) "*" )
1597 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1598 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1600 (?R gnus-tmp-number-of-read ?s)
1601 (?t gnus-tmp-number-total ?d)
1602 (?y gnus-tmp-number-of-unread ?s)
1603 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1604 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1605 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1606 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1607 (?g gnus-tmp-group ?s)
1608 (?G gnus-tmp-qualified-group ?s)
1609 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1610 (?D gnus-tmp-newsgroup-description ?s)
1611 (?o gnus-tmp-moderated ?c)
1612 (?O gnus-tmp-moderated-string ?s)
1613 (?p gnus-tmp-process-marked ?c)
1614 (?s gnus-tmp-news-server ?s)
1615 (?n gnus-tmp-news-method ?s)
1616 (?P gnus-group-indentation ?s)
1617 (?l gnus-tmp-grouplens ?s)
1618 (?z gnus-tmp-news-method-string ?s)
1619 (?u gnus-tmp-user-defined ?s)))
1621 (defvar gnus-summary-line-format-alist
1622 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1623 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1624 (?s gnus-tmp-subject-or-nil ?s)
1625 (?n gnus-tmp-name ?s)
1626 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1628 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1630 (?F gnus-tmp-from ?s)
1631 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1632 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1633 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1634 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1635 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1636 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1637 (?L gnus-tmp-lines ?d)
1638 (?I gnus-tmp-indentation ?s)
1639 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1640 (?R gnus-tmp-replied ?c)
1641 (?\[ gnus-tmp-opening-bracket ?c)
1642 (?\] gnus-tmp-closing-bracket ?c)
1643 (?\> (make-string gnus-tmp-level ? ) ?s)
1644 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1645 (?i gnus-tmp-score ?d)
1646 (?z gnus-tmp-score-char ?c)
1647 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1648 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1649 (?U gnus-tmp-unread ?c)
1650 (?t (gnus-summary-number-of-articles-in-thread
1651 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1653 (?e (gnus-summary-number-of-articles-in-thread
1654 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1656 (?u gnus-tmp-user-defined ?s))
1657 "An alist of format specifications that can appear in summary lines,
1658 and what variables they correspond with, along with the type of the
1659 variable (string, integer, character, etc).")
1661 (defvar gnus-summary-dummy-line-format-alist
1662 `((?S gnus-tmp-subject ?s)
1663 (?N gnus-tmp-number ?d)
1664 (?u gnus-tmp-user-defined ?s)))
1666 (defvar gnus-summary-mode-line-format-alist
1667 `((?G gnus-tmp-group-name ?s)
1668 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1669 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1670 (?A gnus-tmp-article-number ?d)
1671 (?Z gnus-tmp-unread-and-unselected ?s)
1672 (?V gnus-version ?s)
1673 (?U gnus-tmp-unread ?d)
1674 (?S gnus-tmp-subject ?s)
1675 (?e gnus-tmp-unselected ?d)
1676 (?u gnus-tmp-user-defined ?s)
1677 (?d (length gnus-newsgroup-dormant) ?d)
1678 (?t (length gnus-newsgroup-marked) ?d)
1679 (?r (length gnus-newsgroup-reads) ?d)
1680 (?E gnus-newsgroup-expunged-tally ?d)
1681 (?s (gnus-current-score-file-nondirectory) ?s)))
1683 (defvar gnus-article-mode-line-format-alist
1684 gnus-summary-mode-line-format-alist)
1686 (defvar gnus-group-mode-line-format-alist
1687 `((?S gnus-tmp-news-server ?s)
1688 (?M gnus-tmp-news-method ?s)
1689 (?u gnus-tmp-user-defined ?s)))
1691 (defvar gnus-have-read-active-file nil)
1693 (defconst gnus-maintainer
1694 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1695 "The mail address of the Gnus maintainers.")
1697 (defconst gnus-version "September Gnus v0.45"
1698 "Version number for this version of Gnus.")
1700 (defvar gnus-info-nodes
1701 '((gnus-group-mode "(gnus)The Group Buffer")
1702 (gnus-summary-mode "(gnus)The Summary Buffer")
1703 (gnus-article-mode "(gnus)The Article Buffer"))
1704 "Assoc list of major modes and related Info nodes.")
1706 (defvar gnus-group-buffer "*Group*")
1707 (defvar gnus-summary-buffer "*Summary*")
1708 (defvar gnus-article-buffer "*Article*")
1709 (defvar gnus-server-buffer "*Server*")
1711 (defvar gnus-work-buffer " *gnus work*")
1713 (defvar gnus-original-article-buffer " *Original Article*")
1714 (defvar gnus-original-article nil)
1716 (defvar gnus-buffer-list nil
1717 "Gnus buffers that should be killed on exit.")
1719 (defvar gnus-slave nil
1720 "Whether this Gnus is a slave or not.")
1722 (defvar gnus-variable-list
1723 '(gnus-newsrc-options gnus-newsrc-options-n
1724 gnus-newsrc-last-checked-date
1725 gnus-newsrc-alist gnus-server-alist
1726 gnus-killed-list gnus-zombie-list
1727 gnus-topic-topology gnus-topic-alist
1729 "Gnus variables saved in the quick startup file.")
1731 (defvar gnus-newsrc-options nil
1732 "Options line in the .newsrc file.")
1734 (defvar gnus-newsrc-options-n nil
1735 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1737 (defvar gnus-newsrc-last-checked-date nil
1738 "Date Gnus last asked server for new newsgroups.")
1740 (defvar gnus-topic-topology nil
1741 "The complete topic hierarchy.")
1743 (defvar gnus-topic-alist nil
1744 "The complete topic-group alist.")
1746 (defvar gnus-newsrc-alist nil
1747 "Assoc list of read articles.
1748 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1750 (defvar gnus-newsrc-hashtb nil
1751 "Hashtable of gnus-newsrc-alist.")
1753 (defvar gnus-killed-list nil
1754 "List of killed newsgroups.")
1756 (defvar gnus-killed-hashtb nil
1757 "Hash table equivalent of gnus-killed-list.")
1759 (defvar gnus-zombie-list nil
1760 "List of almost dead newsgroups.")
1762 (defvar gnus-description-hashtb nil
1763 "Descriptions of newsgroups.")
1765 (defvar gnus-list-of-killed-groups nil
1766 "List of newsgroups that have recently been killed by the user.")
1768 (defvar gnus-active-hashtb nil
1769 "Hashtable of active articles.")
1771 (defvar gnus-moderated-list nil
1772 "List of moderated newsgroups.")
1774 (defvar gnus-group-marked nil)
1776 (defvar gnus-current-startup-file nil
1777 "Startup file for the current host.")
1779 (defvar gnus-last-search-regexp nil
1780 "Default regexp for article search command.")
1782 (defvar gnus-last-shell-command nil
1783 "Default shell command on article.")
1785 (defvar gnus-current-select-method nil
1786 "The current method for selecting a newsgroup.")
1788 (defvar gnus-group-list-mode nil)
1790 (defvar gnus-article-internal-prepare-hook nil)
1792 (defvar gnus-newsgroup-name nil)
1793 (defvar gnus-newsgroup-begin nil)
1794 (defvar gnus-newsgroup-end nil)
1795 (defvar gnus-newsgroup-last-rmail nil)
1796 (defvar gnus-newsgroup-last-mail nil)
1797 (defvar gnus-newsgroup-last-folder nil)
1798 (defvar gnus-newsgroup-last-file nil)
1799 (defvar gnus-newsgroup-auto-expire nil)
1800 (defvar gnus-newsgroup-active nil)
1802 (defvar gnus-newsgroup-data nil)
1803 (defvar gnus-newsgroup-data-reverse nil)
1804 (defvar gnus-newsgroup-limit nil)
1805 (defvar gnus-newsgroup-limits nil)
1807 (defvar gnus-newsgroup-unreads nil
1808 "List of unread articles in the current newsgroup.")
1810 (defvar gnus-newsgroup-unselected nil
1811 "List of unselected unread articles in the current newsgroup.")
1813 (defvar gnus-newsgroup-reads nil
1814 "Alist of read articles and article marks in the current newsgroup.")
1816 (defvar gnus-newsgroup-expunged-tally nil)
1818 (defvar gnus-newsgroup-marked nil
1819 "List of ticked articles in the current newsgroup (a subset of unread art).")
1821 (defvar gnus-newsgroup-killed nil
1822 "List of ranges of articles that have been through the scoring process.")
1824 (defvar gnus-newsgroup-cached nil
1825 "List of articles that come from the article cache.")
1827 (defvar gnus-newsgroup-saved nil
1828 "List of articles that have been saved.")
1830 (defvar gnus-newsgroup-kill-headers nil)
1832 (defvar gnus-newsgroup-replied nil
1833 "List of articles that have been replied to in the current newsgroup.")
1835 (defvar gnus-newsgroup-expirable nil
1836 "List of articles in the current newsgroup that can be expired.")
1838 (defvar gnus-newsgroup-processable nil
1839 "List of articles in the current newsgroup that can be processed.")
1841 (defvar gnus-newsgroup-bookmarks nil
1842 "List of articles in the current newsgroup that have bookmarks.")
1844 (defvar gnus-newsgroup-dormant nil
1845 "List of dormant articles in the current newsgroup.")
1847 (defvar gnus-newsgroup-scored nil
1848 "List of scored articles in the current newsgroup.")
1850 (defvar gnus-newsgroup-headers nil
1851 "List of article headers in the current newsgroup.")
1853 (defvar gnus-newsgroup-threads nil)
1855 (defvar gnus-newsgroup-prepared nil
1856 "Whether the current group has been prepared properly.")
1858 (defvar gnus-newsgroup-ancient nil
1859 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1861 (defvar gnus-newsgroup-sparse nil)
1863 (defvar gnus-current-article nil)
1864 (defvar gnus-article-current nil)
1865 (defvar gnus-current-headers nil)
1866 (defvar gnus-have-all-headers nil)
1867 (defvar gnus-last-article nil)
1868 (defvar gnus-newsgroup-history nil)
1869 (defvar gnus-current-kill-article nil)
1871 ;; Save window configuration.
1872 (defvar gnus-prev-winconf nil)
1874 (defvar gnus-summary-mark-positions nil)
1875 (defvar gnus-group-mark-positions nil)
1877 (defvar gnus-reffed-article-number nil)
1879 ;;; Let the byte-compiler know that we know about this variable.
1880 (defvar rmail-default-rmail-file)
1882 (defvar gnus-cache-removable-articles nil)
1884 (defvar gnus-dead-summary nil)
1886 (defconst gnus-summary-local-variables
1887 '(gnus-newsgroup-name
1888 gnus-newsgroup-begin gnus-newsgroup-end
1889 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1890 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1891 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1892 gnus-newsgroup-unselected gnus-newsgroup-marked
1893 gnus-newsgroup-reads gnus-newsgroup-saved
1894 gnus-newsgroup-replied gnus-newsgroup-expirable
1895 gnus-newsgroup-processable gnus-newsgroup-killed
1896 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1897 gnus-newsgroup-headers gnus-newsgroup-threads
1898 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1899 gnus-current-article gnus-current-headers gnus-have-all-headers
1900 gnus-last-article gnus-article-internal-prepare-hook
1901 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1902 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1903 gnus-newsgroup-async
1904 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1905 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1906 gnus-newsgroup-history gnus-newsgroup-ancient
1907 gnus-newsgroup-sparse
1908 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1909 gnus-newsgroup-adaptive-score-file
1910 (gnus-newsgroup-expunged-tally . 0)
1911 gnus-cache-removeable-articles gnus-newsgroup-cached
1912 gnus-newsgroup-data gnus-newsgroup-data-reverse
1913 gnus-newsgroup-limit gnus-newsgroup-limits)
1914 "Variables that are buffer-local to the summary buffers.")
1916 (defconst gnus-bug-message
1917 "Sending a bug report to the Gnus Towers.
1918 ========================================
1920 The buffer below is a mail buffer. When you press `C-c C-c', it will
1921 be sent to the Gnus Bug Exterminators.
1923 At the bottom of the buffer you'll see lots of variable settings.
1924 Please do not delete those. They will tell the Bug People what your
1925 environment is, so that it will be easier to locate the bugs.
1927 If you have found a bug that makes Emacs go \"beep\", set
1928 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1929 and include the backtrace in your bug report.
1931 Please describe the bug in annoying, painstaking detail.
1933 Thank you for your help in stamping out bugs.
1936 ;;; End of variables.
1938 ;; Define some autoload functions Gnus might use.
1941 ;; This little mapcar goes through the list below and marks the
1942 ;; symbols in question as autoloaded functions.
1945 (let ((interactive (nth 1 (memq ':interactive package))))
1949 (when (consp function)
1950 (setq keymap (car (memq 'keymap function)))
1951 (setq function (car function)))
1952 (autoload function (car package) nil interactive keymap)))
1953 (if (eq (nth 1 package) ':interactive)
1956 '(("metamail" metamail-buffer)
1957 ("info" Info-goto-node)
1958 ("hexl" hexl-hex-string-to-integer)
1959 ("pp" pp pp-to-string pp-eval-expression)
1960 ("mail-extr" mail-extract-address-components)
1961 ("nnmail" nnmail-split-fancy nnmail-article-group)
1962 ("nnvirtual" nnvirtual-catchup-group)
1963 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1964 timezone-make-sortable-date timezone-make-time-string)
1965 ("sendmail" mail-position-on-field mail-setup)
1966 ("rmailout" rmail-output)
1967 ("rnewspost" news-mail-other-window news-reply-yank-original
1968 news-caesar-buffer-body)
1969 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1971 ("gnus-soup" :interactive t
1972 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1973 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1974 ("nnsoup" nnsoup-pack-replies)
1975 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1976 gnus-Folder-save-name gnus-folder-save-name)
1977 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1978 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1979 gnus-server-make-menu-bar gnus-article-make-menu-bar
1980 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1981 gnus-summary-highlight-line gnus-carpal-setup-buffer
1982 gnus-group-highlight-line
1983 gnus-article-add-button gnus-insert-next-page-button
1984 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1985 ("gnus-vis" :interactive t
1986 gnus-article-push-button gnus-article-press-button
1987 gnus-article-highlight gnus-article-highlight-some
1988 gnus-article-highlight-headers gnus-article-highlight-signature
1989 gnus-article-add-buttons gnus-article-add-buttons-to-head
1990 gnus-article-next-button gnus-article-prev-button)
1991 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1992 gnus-demon-add-disconnection gnus-demon-add-handler
1993 gnus-demon-remove-handler)
1994 ("gnus-demon" :interactive t
1995 gnus-demon-init gnus-demon-cancel)
1996 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1997 gnus-tree-open gnus-tree-close)
1998 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
1999 gnus-nocem-unwanted-article-p)
2000 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2001 ("gnus-srvr" gnus-browse-foreign-server)
2002 ("gnus-cite" :interactive t
2003 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2004 gnus-article-hide-citation gnus-article-fill-cited-article)
2005 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2006 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2007 gnus-execute gnus-expunge)
2008 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2009 gnus-cache-possibly-remove-articles gnus-cache-request-article
2010 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2011 gnus-cache-enter-remove-article gnus-cached-article-p
2012 gnus-cache-open gnus-cache-close)
2013 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2014 gnus-cache-remove-article)
2015 ("gnus-score" :interactive t
2016 gnus-summary-increase-score gnus-summary-lower-score
2017 gnus-score-flush-cache gnus-score-close
2018 gnus-score-raise-same-subject-and-select
2019 gnus-score-raise-same-subject gnus-score-default
2020 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2021 gnus-score-lower-same-subject gnus-score-lower-thread
2022 gnus-possibly-score-headers)
2024 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2025 gnus-current-score-file-nondirectory gnus-score-adaptive
2026 gnus-score-find-trace gnus-score-file-name)
2027 ("gnus-edit" :interactive t gnus-score-customize)
2028 ("gnus-topic" :interactive t gnus-topic-mode)
2029 ("gnus-topic" gnus-topic-remove-group)
2030 ("gnus-salt" :interactive t gnus-pick-mode)
2031 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2032 ("gnus-uu" :interactive t
2033 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2034 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2035 gnus-uu-mark-by-regexp gnus-uu-mark-all
2036 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2037 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2038 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2039 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2040 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2041 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2042 gnus-uu-decode-binhex-view)
2043 ("gnus-msg" (gnus-summary-send-map keymap)
2044 gnus-mail-yank-original gnus-mail-send-and-exit
2045 gnus-sendmail-setup-mail gnus-article-mail
2046 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2047 ("gnus-msg" :interactive t
2048 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2049 gnus-summary-followup gnus-summary-followup-with-original
2050 gnus-summary-followup-and-reply
2051 gnus-summary-followup-and-reply-with-original
2052 gnus-summary-cancel-article gnus-summary-supersede-article
2053 gnus-post-news gnus-inews-news gnus-cancel-news
2054 gnus-summary-reply gnus-summary-reply-with-original
2055 gnus-summary-mail-forward gnus-summary-mail-other-window
2057 ("gnus-picon" :interactive t gnus-article-display-picons
2058 gnus-group-display-picons gnus-picons-article-display-x-face)
2059 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2060 gnus-grouplens-mode)
2061 ("gnus-vm" gnus-vm-mail-setup)
2062 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2063 gnus-summary-save-article-vm gnus-yank-article))))
2067 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2068 ;; If you want the cursor to go somewhere else, set these two
2069 ;; functions in some startup hook to whatever you want.
2070 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2071 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2073 ;;; Various macros and substs.
2075 (defun gnus-header-from (header)
2076 (mail-header-from header))
2078 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2079 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2080 `(let ((GnusStartBufferWindow (selected-window)))
2083 (pop-to-buffer ,buffer)
2085 (select-window GnusStartBufferWindow))))
2087 (defmacro gnus-gethash (string hashtable)
2088 "Get hash value of STRING in HASHTABLE."
2089 `(symbol-value (intern-soft ,string ,hashtable)))
2091 (defmacro gnus-sethash (string value hashtable)
2092 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2093 `(set (intern ,string ,hashtable) ,value))
2095 (defmacro gnus-intern-safe (string hashtable)
2096 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2097 `(let ((symbol (intern ,string ,hashtable)))
2102 (defmacro gnus-group-unread (group)
2103 "Get the currently computed number of unread articles in GROUP."
2104 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2106 (defmacro gnus-group-entry (group)
2107 "Get the newsrc entry for GROUP."
2108 `(gnus-gethash ,group gnus-newsrc-hashtb))
2110 (defmacro gnus-active (group)
2111 "Get active info on GROUP."
2112 `(gnus-gethash ,group gnus-active-hashtb))
2114 (defmacro gnus-set-active (group active)
2115 "Set GROUP's active info."
2116 `(gnus-sethash ,group ,active gnus-active-hashtb))
2118 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2119 ;; function `substring' might cut on a middle of multi-octet
2121 (defun gnus-truncate-string (str width)
2122 (substring str 0 width))
2124 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2125 ;; to limit the length of a string. This function is necessary since
2126 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2127 (defsubst gnus-limit-string (str width)
2128 (if (> (length str) width)
2129 (substring str 0 width)
2132 (defsubst gnus-simplify-subject-re (subject)
2133 "Remove \"Re:\" from subject lines."
2134 (if (string-match "^[Rr][Ee]: *" subject)
2135 (substring subject (match-end 0))
2138 (defsubst gnus-goto-char (point)
2139 (and point (goto-char point)))
2141 (defmacro gnus-buffer-exists-p (buffer)
2143 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2146 (defmacro gnus-kill-buffer (buffer)
2147 `(let ((buf ,buffer))
2148 (if (gnus-buffer-exists-p buf)
2149 (kill-buffer buf))))
2151 (defsubst gnus-point-at-bol ()
2152 "Return point at the beginning of the line."
2159 (defsubst gnus-point-at-eol ()
2160 "Return point at the end of the line."
2167 (defun gnus-alive-p ()
2168 "Say whether Gnus is running or not."
2169 (and gnus-group-buffer
2170 (get-buffer gnus-group-buffer)))
2172 ;; Delete the current line (and the next N lines.);
2173 (defmacro gnus-delete-line (&optional n)
2174 `(delete-region (progn (beginning-of-line) (point))
2175 (progn (forward-line ,(or n 1)) (point))))
2177 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2178 (defvar gnus-init-inhibit nil)
2179 (defun gnus-read-init-file (&optional inhibit-next)
2180 (if gnus-init-inhibit
2181 (setq gnus-init-inhibit nil)
2182 (setq gnus-init-inhibit inhibit-next)
2184 (or (and (file-exists-p gnus-init-file)
2185 ;; Don't try to load a directory.
2186 (not (file-directory-p gnus-init-file)))
2187 (file-exists-p (concat gnus-init-file ".el"))
2188 (file-exists-p (concat gnus-init-file ".elc")))
2190 (load gnus-init-file nil t)
2192 (error "Error in %s: %s" gnus-init-file var))))))
2194 ;; Info access macros.
2196 (defmacro gnus-info-group (info)
2198 (defmacro gnus-info-rank (info)
2200 (defmacro gnus-info-read (info)
2202 (defmacro gnus-info-marks (info)
2204 (defmacro gnus-info-method (info)
2206 (defmacro gnus-info-params (info)
2209 (defmacro gnus-info-level (info)
2210 `(let ((rank (gnus-info-rank ,info)))
2214 (defmacro gnus-info-score (info)
2215 `(let ((rank (gnus-info-rank ,info)))
2216 (or (and (consp rank) (cdr rank)) 0)))
2218 (defmacro gnus-info-set-group (info group)
2219 `(setcar ,info ,group))
2220 (defmacro gnus-info-set-rank (info rank)
2221 `(setcar (nthcdr 1 ,info) ,rank))
2222 (defmacro gnus-info-set-read (info read)
2223 `(setcar (nthcdr 2 ,info) ,read))
2224 (defmacro gnus-info-set-marks (info marks)
2225 `(setcar (nthcdr 3 ,info) ,marks))
2226 (defmacro gnus-info-set-method (info method)
2227 `(setcar (nthcdr 4 ,info) ,method))
2228 (defmacro gnus-info-set-params (info params)
2229 `(setcar (nthcdr 5 ,info) ,params))
2231 (defmacro gnus-info-set-level (info level)
2232 `(let ((rank (cdr ,info)))
2233 (if (consp (car rank))
2234 (setcar (car rank) ,level)
2235 (setcar rank ,level))))
2236 (defmacro gnus-info-set-score (info score)
2237 `(let ((rank (cdr ,info)))
2238 (if (consp (car rank))
2239 (setcdr (car rank) ,score)
2240 (setcar rank (cons (car rank) ,score)))))
2242 (defmacro gnus-get-info (group)
2243 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2245 (defun gnus-byte-code (func)
2246 "Return a form that can be `eval'ed based on FUNC."
2247 (let ((fval (symbol-function func)))
2248 (if (byte-code-function-p fval)
2249 (let ((flist (append fval nil)))
2250 (setcar flist 'byte-code)
2252 (cons 'progn (cddr fval)))))
2254 ;;; Load the compatability functions.
2261 ;; Format specs. The chunks below are the machine-generated forms
2262 ;; that are to be evaled as the result of the default format strings.
2263 ;; We write them in here to get them byte-compiled. That way the
2264 ;; default actions will be quite fast, while still retaining the full
2265 ;; flexibility of the user-defined format specs.
2267 ;; First we have lots of dummy defvars to let the compiler know these
2268 ;; are really dynamic variables.
2270 (defvar gnus-tmp-unread)
2271 (defvar gnus-tmp-replied)
2272 (defvar gnus-tmp-score-char)
2273 (defvar gnus-tmp-indentation)
2274 (defvar gnus-tmp-opening-bracket)
2275 (defvar gnus-tmp-lines)
2276 (defvar gnus-tmp-name)
2277 (defvar gnus-tmp-closing-bracket)
2278 (defvar gnus-tmp-subject-or-nil)
2279 (defvar gnus-tmp-subject)
2280 (defvar gnus-tmp-marked)
2281 (defvar gnus-tmp-marked-mark)
2282 (defvar gnus-tmp-subscribed)
2283 (defvar gnus-tmp-process-marked)
2284 (defvar gnus-tmp-number-of-unread)
2285 (defvar gnus-tmp-group-name)
2286 (defvar gnus-tmp-group)
2287 (defvar gnus-tmp-article-number)
2288 (defvar gnus-tmp-unread-and-unselected)
2289 (defvar gnus-tmp-news-method)
2290 (defvar gnus-tmp-news-server)
2291 (defvar gnus-tmp-article-number)
2292 (defvar gnus-mouse-face)
2293 (defvar gnus-mouse-face-prop)
2295 (defun gnus-summary-line-format-spec ()
2296 (insert gnus-tmp-unread gnus-tmp-replied
2297 gnus-tmp-score-char gnus-tmp-indentation)
2302 gnus-tmp-opening-bracket
2303 (format "%4d: %-20s"
2305 (if (> (length gnus-tmp-name) 20)
2306 (substring gnus-tmp-name 0 20)
2308 gnus-tmp-closing-bracket)
2310 gnus-mouse-face-prop gnus-mouse-face)
2311 (insert " " gnus-tmp-subject-or-nil "\n"))
2313 (defvar gnus-summary-line-format-spec
2314 (gnus-byte-code 'gnus-summary-line-format-spec))
2316 (defun gnus-summary-dummy-line-format-spec ()
2323 gnus-mouse-face-prop gnus-mouse-face)
2324 (insert " " gnus-tmp-subject "\n"))
2326 (defvar gnus-summary-dummy-line-format-spec
2327 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2329 (defun gnus-group-line-format-spec ()
2330 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2331 gnus-tmp-process-marked
2332 gnus-group-indentation
2333 (format "%5s: " gnus-tmp-number-of-unread))
2337 (insert gnus-tmp-group "\n")
2339 gnus-mouse-face-prop gnus-mouse-face))
2340 (defvar gnus-group-line-format-spec
2341 (gnus-byte-code 'gnus-group-line-format-spec))
2343 (defvar gnus-format-specs
2344 `((version . ,emacs-version)
2345 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2346 (summary-dummy ,gnus-summary-dummy-line-format
2347 ,gnus-summary-dummy-line-format-spec)
2348 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2350 (defvar gnus-article-mode-line-format-spec nil)
2351 (defvar gnus-summary-mode-line-format-spec nil)
2352 (defvar gnus-group-mode-line-format-spec nil)
2354 ;;; Phew. All that gruft is over, fortunately.
2358 ;;; Gnus Utility Functions
2361 (defun gnus-extract-address-components (from)
2363 ;; First find the address - the thing with the @ in it. This may
2364 ;; not be accurate in mail addresses, but does the trick most of
2365 ;; the time in news messages.
2366 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2367 (setq address (substring from (match-beginning 0) (match-end 0))))
2368 ;; Then we check whether the "name <address>" format is used.
2370 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2371 ;; Linear white space is not required.
2372 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2373 (and (setq name (substring from 0 (match-beginning 0)))
2374 ;; Strip any quotes from the name.
2375 (string-match "\".*\"" name)
2376 (setq name (substring name 1 (1- (match-end 0))))))
2377 ;; If not, then "address (name)" is used.
2379 (and (string-match "(.+)" from)
2380 (setq name (substring from (1+ (match-beginning 0))
2381 (1- (match-end 0)))))
2382 (and (string-match "()" from)
2383 (setq name address))
2384 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2385 ;; XOVER might not support folded From headers.
2386 (and (string-match "(.*" from)
2387 (setq name (substring from (1+ (match-beginning 0))
2389 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2390 (list (or name from) (or address from))))
2392 (defun gnus-fetch-field (field)
2393 "Return the value of the header FIELD of current article."
2396 (let ((case-fold-search t))
2397 (nnheader-narrow-to-headers)
2398 (mail-fetch-field field)))))
2400 (defun gnus-goto-colon ()
2402 (search-forward ":" (gnus-point-at-eol) t))
2405 (defun gnus-update-format (var)
2406 "Update the format specification near point."
2411 ;; Find the end of the current word.
2412 (re-search-forward "[ \t\n]" nil t)
2414 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2415 (match-string 1)))))
2416 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2417 (match-string 1 var))))
2418 (entry (assq type gnus-format-specs))
2421 (setq gnus-format-specs (delq entry gnus-format-specs)))
2423 (intern (format "%s-spec" var))
2424 (gnus-parse-format (setq value (symbol-value (intern var)))
2425 (symbol-value (intern (format "%s-alist" var)))
2426 (not (string-match "mode" var))))
2427 (setq spec (symbol-value (intern (format "%s-spec" var))))
2428 (push (list type value spec) gnus-format-specs)
2430 (pop-to-buffer "*Gnus Format*")
2432 (lisp-interaction-mode)
2433 (insert (pp-to-string spec))))
2435 (defun gnus-update-format-specifications (&optional force)
2436 "Update all (necessary) format specifications."
2437 ;; Make the indentation array.
2438 (gnus-make-thread-indent-array)
2440 ;; See whether all the stored info needs to be flushed.
2442 (not (equal emacs-version
2443 (cdr (assq 'version gnus-format-specs)))))
2444 (setq gnus-format-specs nil))
2446 ;; Go through all the formats and see whether they need updating.
2447 (let ((types '(summary summary-dummy group
2448 summary-mode group-mode article-mode))
2449 new-format entry type val)
2450 (while (setq type (pop types))
2451 ;; Jump to the proper buffer to find out the value of
2452 ;; the variable, if possible. (It may be buffer-local.)
2454 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2456 (when (and (boundp buffer)
2457 (setq val (symbol-value buffer))
2459 (buffer-name (get-buffer val)))
2460 (set-buffer (get-buffer val)))
2461 (setq new-format (symbol-value
2462 (intern (format "gnus-%s-line-format" type))))))
2463 (setq entry (cdr (assq type gnus-format-specs)))
2465 (equal (car entry) new-format))
2466 ;; Use the old format.
2467 (set (intern (format "gnus-%s-line-format-spec" type))
2469 ;; This is a new format.
2471 (if (not (stringp new-format))
2472 ;; This is a function call or something.
2474 ;; This is a "real" format.
2478 (intern (format "gnus-%s-line-format-alist"
2479 (if (eq type 'article-mode)
2480 'summary-mode type))))
2481 (not (string-match "mode$" (symbol-name type))))))
2482 ;; Enter the new format spec into the list.
2485 (setcar (cdr entry) val)
2486 (setcar entry new-format))
2487 (push (list type new-format val) gnus-format-specs))
2488 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2490 (gnus-update-group-mark-positions)
2491 (gnus-update-summary-mark-positions)
2493 ;; See whether we need to read the description file.
2494 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2495 (not gnus-description-hashtb)
2496 gnus-read-active-file)
2497 (gnus-read-all-descriptions-files)))
2499 (defun gnus-update-summary-mark-positions ()
2500 "Compute where the summary marks are to go."
2502 (let ((gnus-replied-mark 129)
2503 (gnus-score-below-mark 130)
2504 (gnus-score-over-mark 130)
2508 (gnus-set-work-buffer)
2509 (gnus-summary-insert-line
2510 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2511 (goto-char (point-min))
2512 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2514 (goto-char (point-min))
2515 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2517 (goto-char (point-min))
2518 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2520 (setq gnus-summary-mark-positions pos))))
2522 (defun gnus-update-group-mark-positions ()
2524 (let ((gnus-process-mark 128)
2525 (gnus-group-marked '("dummy.group")))
2526 (gnus-set-active "dummy.group" '(0 . 0))
2527 (gnus-set-work-buffer)
2528 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2529 (goto-char (point-min))
2530 (setq gnus-group-mark-positions
2531 (list (cons 'process (and (search-forward "\200" nil t)
2532 (- (point) 2))))))))
2534 (defvar gnus-mouse-face-0 'highlight)
2535 (defvar gnus-mouse-face-1 'highlight)
2536 (defvar gnus-mouse-face-2 'highlight)
2537 (defvar gnus-mouse-face-3 'highlight)
2538 (defvar gnus-mouse-face-4 'highlight)
2540 (defun gnus-mouse-face-function (form type)
2542 (point) (progn ,@form (point))
2543 gnus-mouse-face-prop
2546 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2548 (defvar gnus-face-0 'bold)
2549 (defvar gnus-face-1 'italic)
2550 (defvar gnus-face-2 'bold-italic)
2551 (defvar gnus-face-3 'bold)
2552 (defvar gnus-face-4 'bold)
2554 (defun gnus-face-face-function (form type)
2556 (point) (progn ,@form (point))
2557 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2559 (defun gnus-max-width-function (el max-width)
2560 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2562 `(if (> (length ,el) ,max-width)
2563 (substring ,el 0 ,max-width)
2565 `(let ((val (eval ,el)))
2567 (setq val (int-to-string val)))
2568 (if (> (length val) ,max-width)
2569 (substring val 0 ,max-width)
2572 (defun gnus-parse-format (format spec-alist &optional insert)
2573 ;; This function parses the FORMAT string with the help of the
2574 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2575 ;; string. If the FORMAT string contains the specifiers %( and %)
2576 ;; the text between them will have the mouse-face text property.
2578 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2580 (gnus-parse-complex-format format spec-alist)
2581 ;; This is a simple format.
2582 (gnus-parse-simple-format format spec-alist insert)))
2584 (defun gnus-parse-complex-format (format spec-alist)
2586 (gnus-set-work-buffer)
2588 (goto-char (point-min))
2589 (while (re-search-forward "\"" nil t)
2590 (replace-match "\\\"" nil t))
2591 (goto-char (point-min))
2593 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2594 (let ((number (if (match-beginning 1)
2595 (match-string 1) "0"))
2596 (delim (aref (match-string 2) 0)))
2597 (if (or (= delim ?\() (= delim ?\{))
2598 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2600 (replace-match "\")\""))))
2601 (goto-char (point-max))
2603 (goto-char (point-min))
2604 (let ((form (read (current-buffer))))
2605 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2607 (defun gnus-complex-form-to-spec (form spec-alist)
2612 (gnus-parse-simple-format sform spec-alist t)
2613 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2614 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2618 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2619 ;; This function parses the FORMAT string with the help of the
2620 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2623 spec flist fstring newspec elem beg result dontinsert)
2625 (gnus-set-work-buffer)
2627 (goto-char (point-min))
2628 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2630 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2632 beg (1+ (match-beginning 0)))
2633 ;; First check if there are any specs that look anything like
2634 ;; "%12,12A", ie. with a "max width specification". These have
2635 ;; to be treated specially.
2636 (if (setq beg (match-beginning 1))
2640 (1+ (match-beginning 1)) (match-end 1))))
2642 (setq beg (match-beginning 2)))
2643 ;; Find the specification from `spec-alist'.
2644 (unless (setq elem (cdr (assq spec spec-alist)))
2645 (setq elem '("*" ?s)))
2646 ;; Treat user defined format specifiers specially.
2647 (when (eq (car elem) 'gnus-tmp-user-defined)
2650 (list (intern (concat "gnus-user-format-function-"
2652 'gnus-tmp-header) ?s))
2653 (delete-region (match-beginning 3) (match-end 3)))
2654 (if (not (zerop max-width))
2655 (let ((el (car elem)))
2656 (cond ((= (cadr elem) ?c)
2657 (setq el (list 'char-to-string el)))
2659 (setq el (list 'int-to-string el))))
2660 (setq flist (cons (gnus-max-width-function el max-width)
2664 (setq flist (cons (car elem) flist))
2665 (setq newspec (cadr elem)))))
2666 ;; Remove the old specification (and possibly a ",12" string).
2667 (delete-region beg (match-end 2))
2668 ;; Insert the new specification.
2671 (setq fstring (buffer-substring 1 (point-max))))
2672 ;; Do some postprocessing to increase efficiency.
2677 ((string= fstring "")
2679 ;; Not a format string.
2680 ((not (string-match "%" fstring))
2682 ;; A format string with just a single string spec.
2683 ((string= fstring "%s")
2685 ;; A single character.
2686 ((string= fstring "%c")
2689 ((string= fstring "%d")
2692 (list `(princ ,(car flist)))
2693 (list `(int-to-string ,(car flist)))))
2694 ;; Just lots of chars and strings.
2695 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2697 ;; A single string spec at the beginning of the spec.
2698 ((string-match "\\`%[sc][^%]+\\'" fstring)
2699 (list (car flist) (substring fstring 2)))
2700 ;; A single string spec in the middle of the spec.
2701 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2702 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2703 ;; A single string spec in the end of the spec.
2704 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2705 (list (match-string 1 fstring) (car flist)))
2706 ;; A more complex spec.
2708 (list (cons 'format (cons fstring (nreverse flist)))))))
2714 (cons 'insert result)))
2715 (cond ((stringp result)
2718 (cons 'concat result))
2721 (defun gnus-eval-format (format &optional alist props)
2722 "Eval the format variable FORMAT, using ALIST.
2723 If PROPS, insert the result."
2724 (let ((form (gnus-parse-format format alist props)))
2726 (add-text-properties (point) (progn (eval form) (point)) props)
2729 (defun gnus-remove-text-with-property (prop)
2730 "Delete all text in the current buffer with text property PROP."
2732 (goto-char (point-min))
2734 (while (get-text-property (point) prop)
2736 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2738 (defun gnus-set-work-buffer ()
2739 (if (get-buffer gnus-work-buffer)
2741 (set-buffer gnus-work-buffer)
2743 (set-buffer (get-buffer-create gnus-work-buffer))
2744 (kill-all-local-variables)
2745 (buffer-disable-undo (current-buffer))
2746 (gnus-add-current-to-buffer-list)))
2748 ;; Article file names when saving.
2750 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2751 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2752 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2753 Otherwise, it is like ~/News/news/group/num."
2756 (concat (if (gnus-use-long-file-name 'not-save)
2757 (gnus-capitalize-newsgroup newsgroup)
2758 (gnus-newsgroup-directory-form newsgroup))
2759 "/" (int-to-string (mail-header-number headers)))
2760 (or gnus-article-save-directory "~/News"))))
2762 (string-equal (file-name-directory default)
2763 (file-name-directory last-file))
2764 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2766 (or last-file default))))
2768 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2769 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2770 If variable `gnus-use-long-file-name' is non-nil, it is
2771 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2774 (concat (if (gnus-use-long-file-name 'not-save)
2776 (gnus-newsgroup-directory-form newsgroup))
2777 "/" (int-to-string (mail-header-number headers)))
2778 (or gnus-article-save-directory "~/News"))))
2780 (string-equal (file-name-directory default)
2781 (file-name-directory last-file))
2782 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2784 (or last-file default))))
2786 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2787 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2788 If variable `gnus-use-long-file-name' is non-nil, it is
2789 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2792 (if (gnus-use-long-file-name 'not-save)
2793 (gnus-capitalize-newsgroup newsgroup)
2794 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2795 (or gnus-article-save-directory "~/News"))))
2797 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2798 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2799 If variable `gnus-use-long-file-name' is non-nil, it is
2800 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2803 (if (gnus-use-long-file-name 'not-save)
2805 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2806 (or gnus-article-save-directory "~/News"))))
2808 ;; For subscribing new newsgroup
2810 (defun gnus-subscribe-hierarchical-interactive (groups)
2811 (let ((groups (sort groups 'string<))
2812 prefixes prefix start ans group starts)
2814 (setq prefixes (list "^"))
2815 (while (and groups prefixes)
2816 (while (not (string-match (car prefixes) (car groups)))
2817 (setq prefixes (cdr prefixes)))
2818 (setq prefix (car prefixes))
2819 (setq start (1- (length prefix)))
2820 (if (and (string-match "[^\\.]\\." (car groups) start)
2823 (concat "^" (substring (car groups) 0 (match-end 0))))
2824 (string-match prefix (cadr groups)))
2826 (setq prefixes (cons prefix prefixes))
2827 (message "Descend hierarchy %s? ([y]nsq): "
2828 (substring prefix 1 (1- (length prefix))))
2829 (setq ans (read-char))
2832 (string-match prefix
2833 (setq group (car groups))))
2834 (setq gnus-killed-list
2835 (cons group gnus-killed-list))
2836 (gnus-sethash group group gnus-killed-hashtb)
2837 (setq groups (cdr groups)))
2838 (setq starts (cdr starts)))
2841 (string-match prefix
2842 (setq group (car groups))))
2843 (gnus-sethash group group gnus-killed-hashtb)
2844 (gnus-subscribe-alphabetically (car groups))
2845 (setq groups (cdr groups)))
2846 (setq starts (cdr starts)))
2849 (setq group (car groups))
2850 (setq gnus-killed-list (cons group gnus-killed-list))
2851 (gnus-sethash group group gnus-killed-hashtb)
2852 (setq groups (cdr groups))))
2854 (message "Subscribe %s? ([n]yq)" (car groups))
2855 (setq ans (read-char))
2856 (setq group (car groups))
2858 (gnus-subscribe-alphabetically (car groups))
2859 (gnus-sethash group group gnus-killed-hashtb))
2862 (setq group (car groups))
2863 (setq gnus-killed-list (cons group gnus-killed-list))
2864 (gnus-sethash group group gnus-killed-hashtb)
2865 (setq groups (cdr groups))))
2867 (setq gnus-killed-list (cons group gnus-killed-list))
2868 (gnus-sethash group group gnus-killed-hashtb)))
2869 (setq groups (cdr groups)))))))
2871 (defun gnus-subscribe-randomly (newsgroup)
2872 "Subscribe new NEWSGROUP by making it the first newsgroup."
2873 (gnus-subscribe-newsgroup newsgroup))
2875 (defun gnus-subscribe-alphabetically (newgroup)
2876 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2877 (let ((groups (cdr gnus-newsrc-alist))
2879 (while (and (not before) groups)
2880 (if (string< newgroup (caar groups))
2881 (setq before (caar groups))
2882 (setq groups (cdr groups))))
2883 (gnus-subscribe-newsgroup newgroup before)))
2885 (defun gnus-subscribe-hierarchically (newgroup)
2886 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2887 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2889 (set-buffer (find-file-noselect gnus-current-startup-file))
2890 (let ((groupkey newgroup)
2892 (while (and (not before) groupkey)
2893 (goto-char (point-min))
2895 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2896 (while (and (re-search-forward groupkey-re nil t)
2898 (setq before (match-string 1))
2899 (string< before newgroup)))))
2900 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2902 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2903 (substring groupkey (match-beginning 1) (match-end 1)))))
2904 (gnus-subscribe-newsgroup newgroup before))))
2906 (defun gnus-subscribe-interactively (group)
2907 "Subscribe the new GROUP interactively.
2908 It is inserted in hierarchical newsgroup order if subscribed. If not,
2910 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2911 (gnus-subscribe-hierarchically group)
2912 (push group gnus-killed-list)))
2914 (defun gnus-subscribe-zombies (group)
2915 "Make the new GROUP into a zombie group."
2916 (push group gnus-zombie-list))
2918 (defun gnus-subscribe-killed (group)
2919 "Make the new GROUP a killed group."
2920 (push group gnus-killed-list))
2922 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2923 "Subscribe new NEWSGROUP.
2924 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2925 the first newsgroup."
2926 ;; We subscribe the group by changing its level to `subscribed'.
2927 (gnus-group-change-level
2928 newsgroup gnus-level-default-subscribed
2929 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2930 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2934 (defun gnus-newsgroup-directory-form (newsgroup)
2935 "Make hierarchical directory name from NEWSGROUP name."
2936 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2937 (len (length newsgroup))
2939 ;; If this is a foreign group, we don't want to translate the
2941 (if (setq idx (string-match ":" newsgroup))
2942 (aset newsgroup idx ?/)
2944 ;; Replace all occurrences of `.' with `/'.
2946 (if (= (aref newsgroup idx) ?.)
2947 (aset newsgroup idx ?/))
2948 (setq idx (1+ idx)))
2951 (defun gnus-newsgroup-savable-name (group)
2952 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2954 (nnheader-replace-chars-in-string group ?/ ?.))
2956 (defun gnus-make-directory (dir)
2957 "Make DIRECTORY recursively."
2958 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2959 ;; of the many mysteries of the universe.
2960 (let* ((dir (expand-file-name dir default-directory))
2962 (if (string-match "/$" dir)
2963 (setq dir (substring dir 0 (match-beginning 0))))
2964 ;; First go down the path until we find a directory that exists.
2965 (while (not (file-exists-p dir))
2966 (setq dirs (cons dir dirs))
2967 (string-match "/[^/]+$" dir)
2968 (setq dir (substring dir 0 (match-beginning 0))))
2969 ;; Then create all the subdirs.
2970 (while (and dirs (not err))
2972 (make-directory (car dirs))
2973 (error (setq err t)))
2974 (setq dirs (cdr dirs)))
2975 ;; We return whether we were successful or not.
2978 (defun gnus-capitalize-newsgroup (newsgroup)
2979 "Capitalize NEWSGROUP name."
2980 (and (not (zerop (length newsgroup)))
2981 (concat (char-to-string (upcase (aref newsgroup 0)))
2982 (substring newsgroup 1))))
2984 ;; Various... things.
2986 (defun gnus-simplify-subject (subject &optional re-only)
2987 "Remove `Re:' and words in parentheses.
2988 If RE-ONLY is non-nil, strip leading `Re:'s only."
2989 (let ((case-fold-search t)) ;Ignore case.
2990 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
2991 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
2992 (setq subject (substring subject (match-end 0))))
2993 ;; Remove uninteresting prefixes.
2994 (if (and (not re-only)
2995 gnus-simplify-ignored-prefixes
2996 (string-match gnus-simplify-ignored-prefixes subject))
2997 (setq subject (substring subject (match-end 0))))
2998 ;; Remove words in parentheses from end.
3000 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3001 (setq subject (substring subject 0 (match-beginning 0)))))
3002 ;; Return subject string.
3005 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3007 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3008 (defun gnus-simplify-buffer-fuzzy ()
3009 (goto-char (point-min))
3010 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3011 (goto-char (match-beginning 0))
3013 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3014 (looking-at "^[[].*:[ \t].*[]]$"))
3015 (goto-char (point-min))
3016 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3018 (replace-match "" t t))
3019 (goto-char (point-min))
3020 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3021 (goto-char (match-end 0))
3024 (progn (goto-char (match-beginning 0)))
3025 (re-search-forward ":"))))
3026 (goto-char (point-min))
3027 (while (re-search-forward "[ \t\n]*[[{(][^()]*[]})][ \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 (while (re-search-forward "[ \t]+$" nil t)
3034 (replace-match "" t t))
3035 (goto-char (point-min))
3036 (while (re-search-forward "^[ \t]+" nil t)
3037 (replace-match "" t t))
3038 (goto-char (point-min))
3039 (if gnus-simplify-subject-fuzzy-regexp
3040 (if (listp gnus-simplify-subject-fuzzy-regexp)
3041 (let ((list gnus-simplify-subject-fuzzy-regexp))
3043 (goto-char (point-min))
3044 (while (re-search-forward (car list) nil t)
3045 (replace-match "" t t))
3046 (setq list (cdr list))))
3047 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3048 (replace-match "" t t)))))
3050 (defun gnus-simplify-subject-fuzzy (subject)
3051 "Siplify a subject string fuzzily."
3053 (gnus-set-work-buffer)
3054 (let ((case-fold-search t))
3056 (inline (gnus-simplify-buffer-fuzzy))
3059 ;; Add the current buffer to the list of buffers to be killed on exit.
3060 (defun gnus-add-current-to-buffer-list ()
3061 (or (memq (current-buffer) gnus-buffer-list)
3062 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3064 (defun gnus-string> (s1 s2)
3065 (not (or (string< s1 s2)
3068 ;;; General various misc type functions.
3070 (defun gnus-clear-system ()
3071 "Clear all variables and buffers."
3072 ;; Clear Gnus variables.
3073 (let ((variables gnus-variable-list))
3075 (set (car variables) nil)
3076 (setq variables (cdr variables))))
3077 ;; Clear other internal variables.
3078 (setq gnus-list-of-killed-groups nil
3079 gnus-have-read-active-file nil
3080 gnus-newsrc-alist nil
3081 gnus-newsrc-hashtb nil
3082 gnus-killed-list nil
3083 gnus-zombie-list nil
3084 gnus-killed-hashtb nil
3085 gnus-active-hashtb nil
3086 gnus-moderated-list nil
3087 gnus-description-hashtb nil
3088 gnus-newsgroup-headers nil
3089 gnus-newsgroup-name nil
3090 gnus-server-alist nil
3091 gnus-opened-servers nil
3092 gnus-current-select-method nil)
3093 ;; Reset any score variables.
3094 (when gnus-use-scoring
3096 ;; Kill the startup file.
3097 (and gnus-current-startup-file
3098 (get-file-buffer gnus-current-startup-file)
3099 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3100 ;; Save any cache buffers.
3101 (when gnus-use-cache
3102 (gnus-cache-save-buffers))
3103 ;; Clear the dribble buffer.
3104 (gnus-dribble-clear)
3105 ;; Close down NoCeM.
3106 (when gnus-use-nocem
3108 ;; Shut down the demons.
3109 (when gnus-use-demon
3110 (gnus-demon-cancel))
3111 ;; Kill global KILL file buffer.
3112 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3113 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3114 (gnus-kill-buffer nntp-server-buffer)
3116 (when gnus-keep-backlog
3117 (gnus-backlog-shutdown))
3118 ;; Kill Gnus buffers.
3119 (while gnus-buffer-list
3120 (gnus-kill-buffer (pop gnus-buffer-list)))
3121 ;; Remove Gnus frames.
3122 (while gnus-created-frames
3123 (when (frame-live-p (car gnus-created-frames))
3124 ;; We slap a condition-case around this `delete-frame' to ensure
3125 ;; agains errors if we try do delete the single frame that's left.
3127 (delete-frame (car gnus-created-frames))
3129 (pop gnus-created-frames)))
3131 (defun gnus-windows-old-to-new (setting)
3132 ;; First we take care of the really, really old Gnus 3 actions.
3133 (when (symbolp setting)
3135 ;; Take care of ooold GNUS 3.x values.
3136 (cond ((eq setting 'SelectArticle) 'article)
3137 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3138 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3140 (if (or (listp setting)
3141 (not (and gnus-window-configuration
3142 (memq setting '(group summary article)))))
3144 (let* ((setting (if (eq setting 'group)
3145 (if (assq 'newsgroup gnus-window-configuration)
3147 'newsgroups) setting))
3148 (elem (cadr (assq setting gnus-window-configuration)))
3149 (total (apply '+ elem))
3150 (types '(group summary article))
3151 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3156 (or (not (numberp (nth i elem)))
3157 (zerop (nth i elem))
3159 (setq perc (/ (float (nth 0 elem)) total))
3160 (setq out (cons (if (eq pbuf (nth i types))
3161 (vector (nth i types) perc 'point)
3162 (vector (nth i types) perc))
3165 (list (nreverse out)))))
3168 (defun gnus-add-configuration (conf)
3169 "Add the window configuration CONF to `gnus-buffer-configuration'."
3170 (setq gnus-buffer-configuration
3171 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3172 gnus-buffer-configuration))))
3174 (defvar gnus-frame-list nil)
3176 (defun gnus-configure-frame (split &optional window)
3177 "Split WINDOW according to SPLIT."
3179 (setq window (get-buffer-window (current-buffer))))
3180 (select-window window)
3181 ;; This might be an old-stylee buffer config.
3182 (when (vectorp split)
3183 (setq split (append split nil)))
3184 (when (or (consp (car split))
3185 (vectorp (car split)))
3187 (push 'vertical split))
3188 ;; The SPLIT might be something that is to be evaled to
3189 ;; return a new SPLIT.
3190 (while (and (not (assq (car split) gnus-window-to-buffer))
3191 (gnus-functionp (car split)))
3192 (setq split (eval split)))
3193 (let* ((type (car split))
3195 (len (if (eq type 'horizontal) (window-width) (window-height)))
3197 (window-min-width (or gnus-window-min-width window-min-width))
3198 (window-min-height (or gnus-window-min-height window-min-height))
3199 s result new-win rest comp-subs size sub)
3201 ;; Nothing to do here.
3203 ;; Don't switch buffers.
3205 (and (memq 'point split) window))
3206 ;; This is a buffer to be selected.
3207 ((not (memq type '(frame horizontal vertical)))
3208 (let ((buffer (cond ((stringp type) type)
3209 (t (cdr (assq type gnus-window-to-buffer)))))
3212 (error "Illegal buffer type: %s" type))
3213 (unless (setq buf (get-buffer (if (symbolp buffer)
3214 (symbol-value buffer) buffer)))
3215 (setq buf (get-buffer-create (if (symbolp buffer)
3216 (symbol-value buffer) buffer))))
3217 (switch-to-buffer buf)
3218 ;; We return the window if it has the `point' spec.
3219 (and (memq 'point split) window)))
3220 ;; This is a frame split.
3222 (unless gnus-frame-list
3223 (setq gnus-frame-list (list (window-frame
3224 (get-buffer-window (current-buffer))))))
3226 params frame fresult)
3227 (while (< i (length subs))
3228 ;; Frame parameter is gotten from the sub-split.
3229 (setq params (cadr (elt subs i)))
3230 ;; It should be a list.
3231 (unless (listp params)
3233 ;; Create a new frame?
3234 (unless (setq frame (elt gnus-frame-list i))
3235 (nconc gnus-frame-list (list (setq frame (make-frame params)))))
3236 (push frame gnus-created-frames)
3237 ;; Is the old frame still alive?
3238 (unless (frame-live-p frame)
3239 (setcar (nthcdr i gnus-frame-list)
3240 (setq frame (make-frame params))))
3241 ;; Select the frame in question and do more splits there.
3242 (select-frame frame)
3243 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3245 ;; Select the frame that has the selected buffer.
3247 (select-frame (window-frame fresult)))))
3248 ;; This is a normal split.
3250 (when (> (length subs) 0)
3251 ;; First we have to compute the sizes of all new windows.
3253 (setq sub (append (pop subs) nil))
3254 (while (and (not (assq (car sub) gnus-window-to-buffer))
3255 (gnus-functionp (car sub)))
3256 (setq sub (eval sub)))
3258 (push sub comp-subs)
3259 (setq size (cadar comp-subs))
3260 (cond ((equal size 1.0)
3261 (setq rest (car comp-subs))
3264 (setq s (floor (* size len))))
3268 (error "Illegal size: %s" size)))
3269 ;; Try to make sure that we are inside the safe limits.
3271 ((eq type 'horizontal)
3272 (setq s (max s window-min-width)))
3273 ((eq type 'vertical)
3274 (setq s (max s window-min-height))))
3275 (setcar (cdar comp-subs) s)
3277 ;; Take care of the "1.0" spec.
3279 (setcar (cdr rest) (- len total))
3280 (error "No 1.0 specs in %s" split))
3281 ;; The we do the actual splitting in a nice recursive
3283 (setq comp-subs (nreverse comp-subs))
3285 (if (null (cdr comp-subs))
3286 (setq new-win window)
3288 (split-window window (cadar comp-subs)
3289 (eq type 'horizontal))))
3290 (setq result (or (gnus-configure-frame
3291 (car comp-subs) window) result))
3292 (select-window new-win)
3293 (setq window new-win)
3294 (setq comp-subs (cdr comp-subs))))
3295 ;; Return the proper window, if any.
3297 (select-window result))))))
3299 (defvar gnus-frame-split-p nil)
3301 (defun gnus-configure-windows (setting &optional force)
3302 (setq setting (gnus-windows-old-to-new setting))
3303 (let ((split (if (symbolp setting)
3304 (cadr (assq setting gnus-buffer-configuration))
3306 (in-buf (current-buffer))
3307 rule val w height hor ohor heights sub jump-buffer
3308 rel total to-buf all-visible)
3310 (setq gnus-frame-split-p nil)
3313 (error "No such setting: %s" setting))
3315 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3317 ;; All the windows mentioned are already visible, so we just
3318 ;; put point in the assigned buffer, and do not touch the
3320 (select-window all-visible)
3322 ;; Either remove all windows or just remove all Gnus windows.
3323 (let ((frame (selected-frame)))
3325 (if gnus-use-full-window
3326 ;; We want to remove all other windows.
3327 (if (not gnus-frame-split-p)
3328 ;; This is not a `frame' split, so we ignore the
3330 (delete-other-windows)
3331 ;; This is a `frame' split, so we delete all windows
3335 (unless (eq (cdr (assq 'minibuffer
3336 (frame-parameters frame)))
3338 (select-frame frame)
3339 (delete-other-windows)))
3341 ;; Just remove some windows.
3342 (gnus-remove-some-windows)
3343 (switch-to-buffer nntp-server-buffer))
3344 (select-frame frame)))
3346 (switch-to-buffer nntp-server-buffer)
3347 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3349 (defun gnus-all-windows-visible-p (split)
3350 (when (vectorp split)
3351 (setq split (append split nil)))
3352 (when (or (consp (car split))
3353 (vectorp (car split)))
3355 (push 'vertical split))
3356 ;; The SPLIT might be something that is to be evaled to
3357 ;; return a new SPLIT.
3358 (while (and (not (assq (car split) gnus-window-to-buffer))
3359 (gnus-functionp (car split)))
3360 (setq split (eval split)))
3361 (let* ((type (elt split 0)))
3365 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3366 (let ((buffer (cond ((stringp type) type)
3367 (t (cdr (assq type gnus-window-to-buffer)))))
3370 (error "Illegal buffer type: %s" type))
3371 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3373 (setq win (get-buffer-window buf t)))
3375 (if (memq 'point split)
3379 (when (eq type 'frame)
3380 (setq gnus-frame-split-p t))
3381 (let ((n (mapcar 'gnus-all-windows-visible-p
3385 (cond ((windowp (car n))
3392 (defun gnus-window-top-edge (&optional window)
3393 (nth 1 (window-edges window)))
3395 (defun gnus-remove-some-windows ()
3396 (let ((buffers gnus-window-to-buffer)
3397 buf bufs lowest-buf lowest)
3399 ;; Remove windows on all known Gnus buffers.
3401 (setq buf (cdar buffers))
3403 (setq buf (and (boundp buf) (symbol-value buf))))
3405 (get-buffer-window buf)
3407 (setq bufs (cons buf bufs))
3409 (if (or (not lowest)
3410 (< (gnus-window-top-edge) lowest))
3412 (setq lowest (gnus-window-top-edge))
3413 (setq lowest-buf buf)))))
3414 (setq buffers (cdr buffers)))
3415 ;; Remove windows on *all* summary buffers.
3419 (let ((buf (window-buffer win)))
3420 (if (string-match "^\\*Summary" (buffer-name buf))
3422 (setq bufs (cons buf bufs))
3424 (if (or (not lowest)
3425 (< (gnus-window-top-edge) lowest))
3427 (setq lowest-buf buf)
3428 (setq lowest (gnus-window-top-edge))))))))))
3431 (pop-to-buffer lowest-buf)
3432 (switch-to-buffer nntp-server-buffer)))
3434 (and (not (eq (car bufs) lowest-buf))
3435 (delete-windows-on (car bufs)))
3436 (setq bufs (cdr bufs))))))
3438 (defun gnus-version ()
3439 "Version numbers of this version of Gnus."
3441 (let ((methods gnus-valid-select-methods)
3444 ;; Go through all the legal select methods and add their version
3445 ;; numbers to the total version string. Only the backends that are
3446 ;; currently in use will have their message numbers taken into
3449 (setq meth (intern (concat (caar methods) "-version")))
3451 (stringp (symbol-value meth))
3452 (setq mess (concat mess "; " (symbol-value meth))))
3453 (setq methods (cdr methods)))
3454 (gnus-message 2 mess)))
3456 (defun gnus-info-find-node ()
3457 "Find Info documentation of Gnus."
3459 ;; Enlarge info window if needed.
3460 (let ((mode major-mode)
3462 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3463 (setq gnus-info-buffer (current-buffer))
3464 (gnus-configure-windows 'info)))
3466 (defun gnus-days-between (date1 date2)
3467 ;; Return the number of days between date1 and date2.
3468 (- (gnus-day-number date1) (gnus-day-number date2)))
3470 (defun gnus-day-number (date)
3471 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3472 (timezone-parse-date date))))
3473 (timezone-absolute-from-gregorian
3474 (nth 1 dat) (nth 2 dat) (car dat))))
3476 (defun gnus-encode-date (date)
3477 "Convert DATE to internal time."
3478 (let* ((parse (timezone-parse-date date))
3479 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3480 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3481 (encode-time (caddr time) (cadr time) (car time)
3482 (caddr date) (cadr date) (car date) (nth 4 date))))
3484 (defun gnus-time-minus (t1 t2)
3485 "Subtract two internal times."
3486 (let ((borrow (< (cadr t1) (cadr t2))))
3487 (list (- (car t1) (car t2) (if borrow 1 0))
3488 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3490 (defun gnus-file-newer-than (file date)
3491 (let ((fdate (nth 5 (file-attributes file))))
3492 (or (> (car fdate) (car date))
3493 (and (= (car fdate) (car date))
3494 (> (nth 1 fdate) (nth 1 date))))))
3496 (defmacro gnus-local-set-keys (&rest plist)
3497 "Set the keys in PLIST in the current keymap."
3498 `(gnus-define-keys-1 (current-local-map) ',plist))
3500 (defmacro gnus-define-keys (keymap &rest plist)
3501 "Define all keys in PLIST in KEYMAP."
3502 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3504 (put 'gnus-define-keys 'lisp-indent-function 1)
3505 (put 'gnus-define-keys 'lisp-indent-hook 1)
3506 (put 'gnus-define-keymap 'lisp-indent-function 1)
3507 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3509 (defmacro gnus-define-keymap (keymap &rest plist)
3510 "Define all keys in PLIST in KEYMAP."
3511 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3513 (defun gnus-define-keys-1 (keymap plist)
3515 (error "Can't set keys in a null keymap"))
3516 (cond ((symbolp keymap)
3517 (setq keymap (symbol-value keymap)))
3520 (set (car keymap) nil)
3521 (define-prefix-command (car keymap))
3522 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3523 (setq keymap (symbol-value (car keymap)))))
3526 (when (symbolp (setq key (pop plist)))
3527 (setq key (symbol-value key)))
3528 (define-key keymap key (pop plist)))))
3530 (defun gnus-group-read-only-p (&optional group)
3531 "Check whether GROUP supports editing or not.
3532 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3533 that that variable is buffer-local to the summary buffers."
3534 (let ((group (or group gnus-newsgroup-name)))
3535 (not (gnus-check-backend-function 'request-replace-article group))))
3537 (defun gnus-group-total-expirable-p (group)
3538 "Check whether GROUP is total-expirable or not."
3539 (let ((params (gnus-info-params (gnus-get-info group))))
3540 (or (memq 'total-expire params)
3541 (cdr (assq 'total-expire params)) ; (total-expire . t)
3542 (and gnus-total-expirable-newsgroups ; Check var.
3543 (string-match gnus-total-expirable-newsgroups group)))))
3545 (defun gnus-group-auto-expirable-p (group)
3546 "Check whether GROUP is total-expirable or not."
3547 (let ((params (gnus-info-params (gnus-get-info group))))
3548 (or (memq 'auto-expire params)
3549 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3550 (and gnus-auto-expirable-newsgroups ; Check var.
3551 (string-match gnus-auto-expirable-newsgroups group)))))
3553 (defun gnus-virtual-group-p (group)
3554 "Say whether GROUP is virtual or not."
3555 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3556 gnus-valid-select-methods)))
3558 (defsubst gnus-simplify-subject-fully (subject)
3559 "Simplify a subject string according to the user's wishes."
3561 ((null gnus-summary-gather-subject-limit)
3562 (gnus-simplify-subject-re subject))
3563 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3564 (gnus-simplify-subject-fuzzy subject))
3565 ((numberp gnus-summary-gather-subject-limit)
3566 (gnus-limit-string (gnus-simplify-subject-re subject)
3567 gnus-summary-gather-subject-limit))
3571 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3572 "Check whether two subjects are equal. If optional argument
3573 simple-first is t, first argument is already simplified."
3575 ((null simple-first)
3576 (equal (gnus-simplify-subject-fully s1)
3577 (gnus-simplify-subject-fully s2)))
3580 (gnus-simplify-subject-fully s2)))))
3582 ;; Returns a list of writable groups.
3583 (defun gnus-writable-groups ()
3584 (let ((alist gnus-newsrc-alist)
3586 (while (setq group (car (pop alist)))
3587 (unless (gnus-group-read-only-p group)
3588 (push group groups)))
3591 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3593 (defun gnus-y-or-n-p (prompt)
3598 (defun gnus-yes-or-no-p (prompt)
3600 (yes-or-no-p prompt)
3603 ;; Check whether to use long file names.
3604 (defun gnus-use-long-file-name (symbol)
3605 ;; The variable has to be set...
3606 (and gnus-use-long-file-name
3607 ;; If it isn't a list, then we return t.
3608 (or (not (listp gnus-use-long-file-name))
3609 ;; If it is a list, and the list contains `symbol', we
3611 (not (memq symbol gnus-use-long-file-name)))))
3613 ;; I suspect there's a better way, but I haven't taken the time to do
3614 ;; it yet. -erik selberg@cs.washington.edu
3615 (defun gnus-dd-mmm (messy-date)
3616 "Return a string like DD-MMM from a big messy string"
3617 (let ((datevec (timezone-parse-date messy-date)))
3619 (or (aref datevec 2) "??")
3622 (nth (1- (string-to-number (aref datevec 1)))
3623 timezone-months-assoc))
3626 ;; Make a hash table (default and minimum size is 255).
3627 ;; Optional argument HASHSIZE specifies the table size.
3628 (defun gnus-make-hashtable (&optional hashsize)
3629 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3631 ;; Make a number that is suitable for hashing; bigger than MIN and one
3633 (defun gnus-create-hash-size (min)
3639 ;; Show message if message has a lower level than `gnus-verbose'.
3640 ;; Guideline for numbers:
3641 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3642 ;; for things that take a long time, 7 - not very important messages
3643 ;; on stuff, 9 - messages inside loops.
3644 (defun gnus-message (level &rest args)
3645 (if (<= level gnus-verbose)
3646 (apply 'message args)
3647 ;; We have to do this format thingy here even if the result isn't
3648 ;; shown - the return value has to be the same as the return value
3650 (apply 'format args)))
3652 (defun gnus-functionp (form)
3653 "Return non-nil if FORM is funcallable."
3654 (or (and (symbolp form) (fboundp form))
3655 (and (listp form) (eq (car form) 'lambda))))
3657 ;; Generate a unique new group name.
3658 (defun gnus-generate-new-group-name (leaf)
3661 (while (gnus-gethash name gnus-newsrc-hashtb)
3662 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3665 ;; Find out whether the gnus-visual TYPE is wanted.
3666 (defun gnus-visual-p (&optional type class)
3667 (and gnus-visual ; Has to be non-nil, at least.
3668 (if (not type) ; We don't care about type.
3670 (if (listp gnus-visual) ; It's a list, so we check it.
3671 (or (memq type gnus-visual)
3672 (memq class gnus-visual))
3675 (defun gnus-parent-id (references)
3676 "Return the last Message-ID in REFERENCES."
3677 (when (and references
3678 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3679 (substring references (match-beginning 1) (match-end 1))))
3681 (defun gnus-split-references (references)
3682 "Return a list of Message-IDs in REFERENCES."
3685 (while (string-match "<[^>]+>" references beg)
3686 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3690 (defun gnus-ephemeral-group-p (group)
3691 "Say whether GROUP is ephemeral or not."
3692 (gnus-group-get-parameter group 'quit-config))
3694 (defun gnus-group-quit-config (group)
3695 "Return the quit-config of GROUP."
3696 (gnus-group-get-parameter group 'quit-config))
3698 (defun gnus-simplify-mode-line ()
3699 "Make mode lines a bit simpler."
3700 (setq mode-line-modified "-- ")
3701 (when (listp mode-line-format)
3702 (make-local-variable 'mode-line-format)
3703 (setq mode-line-format (copy-sequence mode-line-format))
3704 (when (equal (nth 3 mode-line-format) " ")
3705 (setcar (nthcdr 3 mode-line-format) " "))))
3707 ;;; List and range functions
3709 (defun gnus-last-element (list)
3710 "Return last element of LIST."
3712 (setq list (cdr list)))
3715 (defun gnus-copy-sequence (list)
3716 "Do a complete, total copy of a list."
3717 (if (and (consp list) (not (consp (cdr list))))
3718 (cons (car list) (cdr list))
3719 (mapcar (lambda (elem) (if (consp elem)
3720 (if (consp (cdr elem))
3721 (gnus-copy-sequence elem)
3722 (cons (car elem) (cdr elem)))
3726 (defun gnus-set-difference (list1 list2)
3727 "Return a list of elements of LIST1 that do not appear in LIST2."
3728 (let ((list1 (copy-sequence list1)))
3730 (setq list1 (delq (car list2) list1))
3731 (setq list2 (cdr list2)))
3734 (defun gnus-sorted-complement (list1 list2)
3735 "Return a list of elements of LIST1 that do not appear in LIST2.
3736 Both lists have to be sorted over <."
3738 (if (or (null list1) (null list2))
3740 (while (and list1 list2)
3741 (cond ((= (car list1) (car list2))
3742 (setq list1 (cdr list1)
3744 ((< (car list1) (car list2))
3745 (setq out (cons (car list1) out))
3746 (setq list1 (cdr list1)))
3748 (setq out (cons (car list2) out))
3749 (setq list2 (cdr list2)))))
3750 (nconc (nreverse out) (or list1 list2)))))
3752 (defun gnus-intersection (list1 list2)
3755 (if (memq (car list2) list1)
3756 (setq result (cons (car list2) result)))
3757 (setq list2 (cdr list2)))
3760 (defun gnus-sorted-intersection (list1 list2)
3761 ;; LIST1 and LIST2 have to be sorted over <.
3763 (while (and list1 list2)
3764 (cond ((= (car list1) (car list2))
3765 (setq out (cons (car list1) out)
3768 ((< (car list1) (car list2))
3769 (setq list1 (cdr list1)))
3771 (setq list2 (cdr list2)))))
3774 (defun gnus-set-sorted-intersection (list1 list2)
3775 ;; LIST1 and LIST2 have to be sorted over <.
3776 ;; This function modifies LIST1.
3777 (let* ((top (cons nil list1))
3779 (while (and list1 list2)
3780 (cond ((= (car list1) (car list2))
3784 ((< (car list1) (car list2))
3785 (setcdr prev (cdr list1))
3786 (setq list1 (cdr list1)))
3788 (setq list2 (cdr list2)))))
3792 (defun gnus-compress-sequence (numbers &optional always-list)
3793 "Convert list of numbers to a list of ranges or a single range.
3794 If ALWAYS-LIST is non-nil, this function will always release a list of
3796 (let* ((first (car numbers))
3797 (last (car numbers))
3801 (if (not (listp (cdr numbers)))
3804 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3805 ((= (1+ last) (car numbers)) ;Still in sequence
3806 (setq last (car numbers)))
3807 (t ;End of one sequence
3809 (cons (if (= first last) first
3810 (cons first last)) result))
3811 (setq first (car numbers))
3812 (setq last (car numbers))))
3813 (setq numbers (cdr numbers)))
3814 (if (and (not always-list) (null result))
3815 (if (= first last) (list first) (cons first last))
3816 (nreverse (cons (if (= first last) first (cons first last))
3819 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3820 (defun gnus-uncompress-range (ranges)
3821 "Expand a list of ranges into a list of numbers.
3822 RANGES is either a single range on the form `(num . num)' or a list of
3824 (let (first last result)
3828 ((not (listp (cdr ranges)))
3829 (setq first (car ranges))
3830 (setq last (cdr ranges))
3831 (while (<= first last)
3832 (setq result (cons first result))
3833 (setq first (1+ first)))
3837 (if (atom (car ranges))
3838 (if (numberp (car ranges))
3839 (setq result (cons (car ranges) result)))
3840 (setq first (caar ranges))
3841 (setq last (cdar ranges))
3842 (while (<= first last)
3843 (setq result (cons first result))
3844 (setq first (1+ first))))
3845 (setq ranges (cdr ranges)))
3846 (nreverse result)))))
3848 (defun gnus-add-to-range (ranges list)
3849 "Return a list of ranges that has all articles from both RANGES and LIST.
3850 Note: LIST has to be sorted over `<'."
3852 (gnus-compress-sequence list t)
3853 (setq list (copy-sequence list))
3854 (or (listp (cdr ranges))
3855 (setq ranges (list ranges)))
3857 ilist lowest highest temp)
3858 (while (and ranges list)
3860 (setq lowest (or (and (atom (car ranges)) (car ranges))
3862 (while (and list (cdr list) (< (cadr list) lowest))
3863 (setq list (cdr list)))
3864 (if (< (car ilist) lowest)
3867 (setq list (cdr list))
3869 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3870 (setq highest (or (and (atom (car ranges)) (car ranges))
3872 (while (and list (<= (car list) highest))
3873 (setq list (cdr list)))
3874 (setq ranges (cdr ranges)))
3876 (setq out (nconc (gnus-compress-sequence list t) out)))
3877 (setq out (sort out (lambda (r1 r2)
3878 (< (or (and (atom r1) r1) (car r1))
3879 (or (and (atom r2) r2) (car r2))))))
3882 (if (atom (car ranges))
3884 (if (atom (cadr ranges))
3885 (if (= (1+ (car ranges)) (cadr ranges))
3887 (setcar ranges (cons (car ranges)
3889 (setcdr ranges (cddr ranges))))
3890 (if (= (1+ (car ranges)) (caadr ranges))
3892 (setcar (cadr ranges) (car ranges))
3893 (setcar ranges (cadr ranges))
3894 (setcdr ranges (cddr ranges))))))
3896 (if (atom (cadr ranges))
3897 (if (= (1+ (cdar ranges)) (cadr ranges))
3899 (setcdr (car ranges) (cadr ranges))
3900 (setcdr ranges (cddr ranges))))
3901 (if (= (1+ (cdar ranges)) (caadr ranges))
3903 (setcdr (car ranges) (cdadr ranges))
3904 (setcdr ranges (cddr ranges)))))))
3905 (setq ranges (cdr ranges)))
3908 (defun gnus-remove-from-range (ranges list)
3909 "Return a list of ranges that has all articles from LIST removed from RANGES.
3910 Note: LIST has to be sorted over `<'."
3911 ;; !!! This function shouldn't look like this, but I've got a headache.
3912 (gnus-compress-sequence
3913 (gnus-sorted-complement
3914 (gnus-uncompress-range ranges) list)))
3916 (defun gnus-member-of-range (number ranges)
3917 (if (not (listp (cdr ranges)))
3918 (and (>= number (car ranges))
3919 (<= number (cdr ranges)))
3922 (if (numberp (car ranges))
3923 (>= number (car ranges))
3924 (>= number (caar ranges)))
3926 (if (if (numberp (car ranges))
3927 (= number (car ranges))
3928 (and (>= number (caar ranges))
3929 (<= number (cdar ranges))))
3930 (setq not-stop nil))
3931 (setq ranges (cdr ranges)))
3934 (defun gnus-range-length (range)
3935 "Return the length RANGE would have if uncompressed."
3936 (length (gnus-uncompress-range range)))
3938 (defun gnus-sublist-p (list sublist)
3939 "Test whether all elements in SUBLIST are members of LIST."
3942 (unless (memq (pop sublist) list)
3952 (defvar gnus-group-mode-map nil)
3953 (put 'gnus-group-mode 'mode-class 'special)
3955 (unless gnus-group-mode-map
3956 (setq gnus-group-mode-map (make-keymap))
3957 (suppress-keymap gnus-group-mode-map)
3959 (gnus-define-keys gnus-group-mode-map
3960 " " gnus-group-read-group
3961 "=" gnus-group-select-group
3962 "\M- " gnus-group-unhidden-select-group
3963 "\r" gnus-group-select-group
3964 "\M-\r" gnus-group-quick-select-group
3965 "j" gnus-group-jump-to-group
3966 "n" gnus-group-next-unread-group
3967 "p" gnus-group-prev-unread-group
3968 "\177" gnus-group-prev-unread-group
3969 [delete] gnus-group-prev-unread-group
3970 "N" gnus-group-next-group
3971 "P" gnus-group-prev-group
3972 "\M-n" gnus-group-next-unread-group-same-level
3973 "\M-p" gnus-group-prev-unread-group-same-level
3974 "," gnus-group-best-unread-group
3975 "." gnus-group-first-unread-group
3976 "u" gnus-group-unsubscribe-current-group
3977 "U" gnus-group-unsubscribe-group
3978 "c" gnus-group-catchup-current
3979 "C" gnus-group-catchup-current-all
3980 "l" gnus-group-list-groups
3981 "L" gnus-group-list-all-groups
3983 "g" gnus-group-get-new-news
3984 "\M-g" gnus-group-get-new-news-this-group
3985 "R" gnus-group-restart
3986 "r" gnus-group-read-init-file
3987 "B" gnus-group-browse-foreign-server
3988 "b" gnus-group-check-bogus-groups
3989 "F" gnus-find-new-newsgroups
3990 "\C-c\C-d" gnus-group-describe-group
3991 "\M-d" gnus-group-describe-all-groups
3992 "\C-c\C-a" gnus-group-apropos
3993 "\C-c\M-\C-a" gnus-group-description-apropos
3994 "a" gnus-group-post-news
3995 "\ek" gnus-group-edit-local-kill
3996 "\eK" gnus-group-edit-global-kill
3997 "\C-k" gnus-group-kill-group
3998 "\C-y" gnus-group-yank-group
3999 "\C-w" gnus-group-kill-region
4000 "\C-x\C-t" gnus-group-transpose-groups
4001 "\C-c\C-l" gnus-group-list-killed
4002 "\C-c\C-x" gnus-group-expire-articles
4003 "\C-c\M-\C-x" gnus-group-expire-all-groups
4005 "s" gnus-group-save-newsrc
4006 "z" gnus-group-suspend
4007 "Z" gnus-group-clear-dribble
4010 "?" gnus-group-describe-briefly
4011 "\C-c\C-i" gnus-info-find-node
4012 "\M-e" gnus-group-edit-group-method
4013 "^" gnus-group-enter-server-mode
4014 gnus-mouse-2 gnus-mouse-pick-group
4015 "<" beginning-of-buffer
4018 "\C-c\C-s" gnus-group-sort-groups
4020 "\C-c\M-g" gnus-activate-all-groups
4021 "\M-&" gnus-group-universal-argument
4022 "#" gnus-group-mark-group
4023 "\M-#" gnus-group-unmark-group)
4025 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4026 "m" gnus-group-mark-group
4027 "u" gnus-group-unmark-group
4028 "w" gnus-group-mark-region
4029 "m" gnus-group-mark-buffer
4030 "r" gnus-group-mark-regexp
4031 "U" gnus-group-unmark-all-groups)
4033 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4034 "d" gnus-group-make-directory-group
4035 "h" gnus-group-make-help-group
4036 "a" gnus-group-make-archive-group
4037 "k" gnus-group-make-kiboze-group
4038 "m" gnus-group-make-group
4039 "E" gnus-group-edit-group
4040 "e" gnus-group-edit-group-method
4041 "p" gnus-group-edit-group-parameters
4042 "v" gnus-group-add-to-virtual
4043 "V" gnus-group-make-empty-virtual
4044 "D" gnus-group-enter-directory
4045 "f" gnus-group-make-doc-group
4046 "r" gnus-group-rename-group
4047 "\177" gnus-group-delete-group
4048 [delete] gnus-group-delete-group)
4050 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4051 "b" gnus-group-brew-soup
4052 "w" gnus-soup-save-areas
4053 "s" gnus-soup-send-replies
4054 "p" gnus-soup-pack-packet
4055 "r" nnsoup-pack-replies)
4057 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4058 "s" gnus-group-sort-groups
4059 "a" gnus-group-sort-groups-by-alphabet
4060 "u" gnus-group-sort-groups-by-unread
4061 "l" gnus-group-sort-groups-by-level
4062 "v" gnus-group-sort-groups-by-score
4063 "r" gnus-group-sort-groups-by-rank
4064 "m" gnus-group-sort-groups-by-method)
4066 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4067 "k" gnus-group-list-killed
4068 "z" gnus-group-list-zombies
4069 "s" gnus-group-list-groups
4070 "u" gnus-group-list-all-groups
4071 "A" gnus-group-list-active
4072 "a" gnus-group-apropos
4073 "d" gnus-group-description-apropos
4074 "m" gnus-group-list-matching
4075 "M" gnus-group-list-all-matching
4076 "l" gnus-group-list-level)
4078 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4079 "f" gnus-score-flush-cache)
4081 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4082 "f" gnus-group-fetch-faq)
4084 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4085 "l" gnus-group-set-current-level
4086 "t" gnus-group-unsubscribe-current-group
4087 "s" gnus-group-unsubscribe-group
4088 "k" gnus-group-kill-group
4089 "y" gnus-group-yank-group
4090 "w" gnus-group-kill-region
4091 "\C-k" gnus-group-kill-level
4092 "z" gnus-group-kill-all-zombies))
4094 (defun gnus-group-mode ()
4095 "Major mode for reading news.
4097 All normal editing commands are switched off.
4098 \\<gnus-group-mode-map>
4099 The group buffer lists (some of) the groups available. For instance,
4100 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4101 lists all zombie groups.
4103 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4104 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4106 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4108 The following commands are available:
4110 \\{gnus-group-mode-map}"
4112 (when (and menu-bar-mode
4113 (gnus-visual-p 'group-menu 'menu))
4114 (gnus-group-make-menu-bar))
4115 (kill-all-local-variables)
4116 (gnus-simplify-mode-line)
4117 (setq major-mode 'gnus-group-mode)
4118 (setq mode-name "Group")
4119 (gnus-group-set-mode-line)
4120 (setq mode-line-process nil)
4121 (use-local-map gnus-group-mode-map)
4122 (buffer-disable-undo (current-buffer))
4123 (setq truncate-lines t)
4124 (setq buffer-read-only t)
4125 (run-hooks 'gnus-group-mode-hook))
4127 (defun gnus-mouse-pick-group (e)
4128 "Enter the group under the mouse pointer."
4131 (gnus-group-read-group nil))
4133 ;; Look at LEVEL and find out what the level is really supposed to be.
4134 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4135 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4136 (defun gnus-group-default-level (&optional level number-or-nil)
4138 (gnus-group-use-permanent-levels
4139 (setq gnus-group-default-list-level
4140 (or level gnus-group-default-list-level))
4141 (or gnus-group-default-list-level gnus-level-subscribed))
4145 (or level gnus-group-default-list-level gnus-level-subscribed))))
4148 (defun gnus-slave-no-server (&optional arg)
4149 "Read network news as a slave, without connecting to local server"
4151 (gnus-no-server arg t))
4154 (defun gnus-no-server (&optional arg slave)
4156 If ARG is a positive number, Gnus will use that as the
4157 startup level. If ARG is nil, Gnus will be started at level 2.
4158 If ARG is non-nil and not a positive number, Gnus will
4159 prompt the user for the name of an NNTP server to use.
4160 As opposed to `gnus', this command will not connect to the local server."
4162 (make-local-variable 'gnus-group-use-permanent-levels)
4163 (setq gnus-group-use-permanent-levels t)
4164 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4167 (defun gnus-slave (&optional arg)
4168 "Read news as a slave."
4170 (gnus arg nil 'slave))
4173 (defun gnus-other-frame (&optional arg)
4174 "Pop up a frame to read news."
4176 (if (get-buffer gnus-group-buffer)
4177 (let ((pop-up-frames t))
4179 (select-frame (make-frame))
4183 (defun gnus (&optional arg dont-connect slave)
4185 If ARG is non-nil and a positive number, Gnus will use that as the
4186 startup level. If ARG is non-nil and not a positive number, Gnus will
4187 prompt the user for the name of an NNTP server to use."
4190 (if (get-buffer gnus-group-buffer)
4192 (switch-to-buffer gnus-group-buffer)
4193 (gnus-group-get-new-news))
4196 (nnheader-init-server-buffer)
4197 (gnus-read-init-file)
4198 (setq gnus-slave slave)
4200 (gnus-group-setup-buffer)
4201 (let ((buffer-read-only nil))
4203 (if (not gnus-inhibit-startup-message)
4205 (gnus-group-startup-message)
4208 (let ((level (and (numberp arg) (> arg 0) arg))
4214 (gnus-start-news-server (and arg (not level))))))
4215 (if (and (not dont-connect)
4218 (run-hooks 'gnus-startup-hook)
4219 ;; NNTP server is successfully open.
4221 ;; Find the current startup file name.
4222 (setq gnus-current-startup-file
4223 (gnus-make-newsrc-file gnus-startup-file))
4225 ;; Read the dribble file.
4226 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4228 ;; Allow using GroupLens predictions.
4229 (when gnus-use-grouplens
4231 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4233 (gnus-summary-make-display-table)
4234 ;; Do the actual startup.
4235 (gnus-setup-news nil level)
4236 ;; Generate the group buffer.
4237 (gnus-group-list-groups level)
4238 (gnus-group-first-unread-group)
4239 (gnus-configure-windows 'group)
4240 (gnus-group-set-mode-line))))))
4242 (defun gnus-unload ()
4243 "Unload all Gnus features."
4245 (or (boundp 'load-history)
4246 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4247 (let ((history load-history)
4250 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4251 (setq feature (cdr (assq 'provide (car history))))
4252 (unload-feature feature 'force))
4253 (setq history (cdr history)))))
4255 (defun gnus-compile ()
4256 "Byte-compile the user-defined format specs."
4258 (let ((entries gnus-format-specs)
4259 entry gnus-tmp-func)
4261 (gnus-message 7 "Compiling format specs...")
4264 (setq entry (pop entries))
4265 (if (eq (car entry) 'version)
4266 (setq gnus-format-specs (delq entry gnus-format-specs))
4267 (when (and (listp (caddr entry))
4268 (not (eq 'byte-code (caaddr entry))))
4269 (fset 'gnus-tmp-func
4270 `(lambda () ,(caddr entry)))
4271 (byte-compile 'gnus-tmp-func)
4272 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4274 (push (cons 'version emacs-version) gnus-format-specs)
4276 (gnus-message 7 "Compiling user specs...done"))))
4278 (defun gnus-indent-rigidly (start end arg)
4279 "Indent rigidly using only spaces and no tabs."
4282 (narrow-to-region start end)
4283 (indent-rigidly start end arg)
4284 (goto-char (point-min))
4285 (while (search-forward "\t" nil t)
4286 (replace-match " " t t)))))
4288 (defun gnus-group-startup-message (&optional x y)
4289 "Insert startup message in current buffer."
4290 ;; Insert the message.
4295 _ ___ __ ___ __ _ ___
4314 ;; And then hack it.
4315 (gnus-indent-rigidly (point-min) (point-max)
4316 (/ (max (- (window-width) (or x 46)) 0) 2))
4317 (goto-char (point-min))
4319 (let* ((pheight (count-lines (point-min) (point-max)))
4320 (wheight (window-height))
4321 (rest (- wheight pheight)))
4322 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4324 (goto-char (point-min))
4325 (and (search-forward "Praxis" nil t)
4326 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4327 (goto-char (point-min))
4328 (let* ((mode-string (gnus-group-set-mode-line)))
4329 (setq mode-line-buffer-identification
4330 (list (concat gnus-version (substring (car mode-string) 4))))
4331 (set-buffer-modified-p t)))
4333 (defun gnus-group-setup-buffer ()
4334 (or (get-buffer gnus-group-buffer)
4336 (switch-to-buffer gnus-group-buffer)
4337 (gnus-add-current-to-buffer-list)
4339 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4341 (defun gnus-group-list-groups (&optional level unread lowest)
4342 "List newsgroups with level LEVEL or lower that have unread articles.
4343 Default is all subscribed groups.
4344 If argument UNREAD is non-nil, groups with no unread articles are also
4346 (interactive (list (if current-prefix-arg
4347 (prefix-numeric-value current-prefix-arg)
4349 (gnus-group-default-level nil t)
4350 gnus-group-default-list-level
4351 gnus-level-subscribed))))
4353 (setq level (car gnus-group-list-mode)
4354 unread (cdr gnus-group-list-mode)))
4355 (setq level (gnus-group-default-level level))
4356 (gnus-group-setup-buffer) ;May call from out of group buffer
4357 (gnus-update-format-specifications)
4358 (let ((case-fold-search nil)
4359 (props (text-properties-at (gnus-point-at-bol)))
4360 (group (gnus-group-group-name)))
4361 (funcall gnus-group-prepare-function level unread lowest)
4362 (if (zerop (buffer-size))
4363 (gnus-message 5 gnus-no-groups-message)
4364 (goto-char (point-max))
4365 (when (or (not gnus-group-goto-next-group-function)
4366 (not (funcall gnus-group-goto-next-group-function
4369 ;; Go to the first group with unread articles.
4370 (gnus-group-search-forward t)
4371 ;; Find the right group to put point on. If the current group
4372 ;; has disappeared in the new listing, try to find the next
4373 ;; one. If no next one can be found, just leave point at the
4374 ;; first newsgroup in the buffer.
4375 (if (not (gnus-goto-char
4377 (point-min) (point-max)
4378 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4379 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4381 (not (gnus-goto-char
4383 (point-min) (point-max) 'gnus-group
4385 (caar newsrc) gnus-active-hashtb)))))
4386 (setq newsrc (cdr newsrc)))
4387 (or newsrc (progn (goto-char (point-max))
4388 (forward-line -1)))))))
4389 ;; Adjust cursor point.
4390 (gnus-group-position-point))))
4392 (defun gnus-group-list-level (level &optional all)
4393 "List groups on LEVEL.
4394 If ALL (the prefix), also list groups that have no unread articles."
4395 (interactive "nList groups on level: \nP")
4396 (gnus-group-list-groups level all level))
4398 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4399 "List all newsgroups with unread articles of level LEVEL or lower.
4400 If ALL is non-nil, list groups that have no unread articles.
4401 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4402 If REGEXP, only list groups matching REGEXP."
4403 (set-buffer gnus-group-buffer)
4404 (let ((buffer-read-only nil)
4405 (newsrc (cdr gnus-newsrc-alist))
4406 (lowest (or lowest 1))
4407 info clevel unread group params)
4409 (if (< lowest gnus-level-zombie)
4410 ;; List living groups.
4412 (setq info (car newsrc)
4413 group (gnus-info-group info)
4414 params (gnus-info-params info)
4416 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4417 (and unread ; This group might be bogus
4419 (string-match regexp group))
4420 (<= (setq clevel (gnus-info-level info)) level)
4422 (or all ; We list all groups?
4423 (and gnus-group-list-inactive-groups
4424 (eq unread t)) ; We list unactivated groups
4425 (> unread 0) ; We list groups with unread articles
4426 (and gnus-list-groups-with-ticked-articles
4427 (cdr (assq 'tick (gnus-info-marks info))))
4428 ; And groups with tickeds
4429 ;; Check for permanent visibility.
4430 (and gnus-permanently-visible-groups
4431 (string-match gnus-permanently-visible-groups
4433 (memq 'visible params)
4434 (cdr (assq 'visible params)))
4435 (gnus-group-insert-group-line
4436 group (gnus-info-level info)
4437 (gnus-info-marks info) unread (gnus-info-method info)))))
4439 ;; List dead groups.
4440 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4441 (gnus-group-prepare-flat-list-dead
4442 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4443 gnus-level-zombie ?Z
4445 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4446 (gnus-group-prepare-flat-list-dead
4447 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4448 gnus-level-killed ?K regexp))
4450 (gnus-group-set-mode-line)
4451 (setq gnus-group-list-mode (cons level all))
4452 (run-hooks 'gnus-group-prepare-hook)))
4454 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4455 ;; List zombies and killed lists somewhat faster, which was
4456 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4457 ;; this by ignoring the group format specification altogether.
4460 ;; This loop is used when listing groups that match some
4463 (setq group (pop groups))
4464 (when (string-match regexp group)
4465 (add-text-properties
4466 (point) (prog1 (1+ (point))
4467 (insert " " mark " *: " group "\n"))
4468 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4470 'gnus-level level))))
4471 ;; This loop is used when listing all groups.
4473 (add-text-properties
4474 (point) (prog1 (1+ (point))
4475 (insert " " mark " *: "
4476 (setq group (pop groups)) "\n"))
4477 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4479 'gnus-level level))))))
4481 (defmacro gnus-group-real-name (group)
4482 "Find the real name of a foreign newsgroup."
4483 `(let ((gname ,group))
4484 (if (string-match ":[^:]+$" gname)
4485 (substring gname (1+ (match-beginning 0)))
4488 (defsubst gnus-server-add-address (method)
4489 (let ((method-name (symbol-name (car method))))
4490 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4491 (not (assq (intern (concat method-name "-address")) method)))
4492 (append method (list (list (intern (concat method-name "-address"))
4496 (defsubst gnus-server-get-method (group method)
4497 ;; Input either a server name, and extended server name, or a
4498 ;; select method, and return a select method.
4499 (cond ((stringp method)
4500 (gnus-server-to-method method))
4501 ((and (stringp (car method)) group)
4502 (gnus-server-extend-method group method))
4504 (gnus-server-add-address method))))
4506 (defun gnus-server-to-method (server)
4507 "Map virtual server names to select methods."
4509 ;; Perhaps this is the native server?
4510 (and (equal server "native") gnus-select-method)
4511 ;; It should be in the server alist.
4512 (cdr (assoc server gnus-server-alist))
4513 ;; If not, we look through all the opened server
4514 ;; to see whether we can find it there.
4515 (let ((opened gnus-opened-servers))
4517 (not (equal server (format "%s:%s" (caaar opened)
4522 (defmacro gnus-server-equal (ss1 ss2)
4523 "Say whether two servers are equal."
4527 (and (= (length s1) (length s2))
4529 (while (and s1 (member (car s1) s2))
4533 (defun gnus-group-prefixed-name (group method)
4534 "Return the whole name from GROUP and METHOD."
4535 (and (stringp method) (setq method (gnus-server-to-method method)))
4536 (concat (format "%s" (car method))
4538 (or (assoc (format "%s" (car method))
4539 (gnus-methods-using 'address))
4540 (equal method gnus-message-archive-method))
4541 (not (string= (nth 1 method) "")))
4542 (concat "+" (nth 1 method)))
4545 (defun gnus-group-real-prefix (group)
4546 "Return the prefix of the current group name."
4547 (if (string-match "^[^:]+:" group)
4548 (substring group 0 (match-end 0))
4551 (defun gnus-group-method (group)
4552 "Return the server or method used for selecting GROUP."
4553 (let ((prefix (gnus-group-real-prefix group)))
4554 (if (equal prefix "")
4556 (let ((servers gnus-opened-servers)
4558 backend possible found)
4559 (if (string-match "^[^\\+]+\\+" prefix)
4560 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4561 server (substring prefix (match-end 0) (1- (length prefix))))
4562 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4564 (when (eq (caaar servers) backend)
4565 (setq possible (caar servers))
4566 (when (equal (cadaar servers) server)
4567 (setq found (caar servers))))
4569 (or (car (rassoc found gnus-server-alist))
4571 (car (rassoc possible gnus-server-alist))
4573 (list backend server))))))
4575 (defsubst gnus-secondary-method-p (method)
4576 "Return whether METHOD is a secondary select method."
4577 (let ((methods gnus-secondary-select-methods)
4578 (gmethod (gnus-server-get-method nil method)))
4580 (not (equal (gnus-server-get-method nil (car methods))
4582 (setq methods (cdr methods)))
4585 (defun gnus-group-foreign-p (group)
4586 "Say whether a group is foreign or not."
4587 (and (not (gnus-group-native-p group))
4588 (not (gnus-group-secondary-p group))))
4590 (defun gnus-group-native-p (group)
4591 "Say whether the group is native or not."
4592 (not (string-match ":" group)))
4594 (defun gnus-group-secondary-p (group)
4595 "Say whether the group is secondary or not."
4596 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4598 (defun gnus-group-get-parameter (group &optional symbol)
4599 "Returns the group parameters for GROUP.
4600 If SYMBOL, return the value of that symbol in the group parameters."
4601 (let ((params (gnus-info-params (gnus-get-info group))))
4603 (gnus-group-parameter-value params symbol)
4606 (defun gnus-group-parameter-value (params symbol)
4607 "Return the value of SYMBOL in group PARAMS."
4608 (or (car (memq symbol params)) ; It's either a simple symbol
4609 (cdr (assq symbol params)))) ; or a cons.
4611 (defun gnus-group-add-parameter (group param)
4612 "Add parameter PARAM to GROUP."
4613 (let ((info (gnus-get-info group)))
4615 () ; This is a dead group. We just ignore it.
4616 ;; Cons the new param to the old one and update.
4617 (gnus-group-set-info (cons param (gnus-info-params info))
4620 (defun gnus-group-set-parameter (group name value)
4621 "Set parameter NAME to VALUE in GROUP."
4622 (let ((info (gnus-get-info group)))
4624 () ; This is a dead group. We just ignore it.
4625 (let ((old-params (gnus-info-params info))
4626 (new-params (list (cons name value))))
4628 (if (or (not (listp (car old-params)))
4629 (not (eq (caar old-params) name)))
4630 (setq new-params (append new-params (list (car old-params)))))
4631 (setq old-params (cdr old-params)))
4632 (gnus-group-set-info new-params group 'params)))))
4634 (defun gnus-group-add-score (group &optional score)
4635 "Add SCORE to the GROUP score.
4636 If SCORE is nil, add 1 to the score of GROUP."
4637 (let ((info (gnus-get-info group)))
4638 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4640 (defun gnus-summary-bubble-group ()
4641 "Increase the score of the current group.
4642 This is a handy function to add to `gnus-summary-exit-hook' to
4643 increase the score of each group you read."
4644 (gnus-group-add-score gnus-newsgroup-name))
4646 (defun gnus-group-set-info (info &optional method-only-group part)
4647 (let* ((entry (gnus-gethash
4648 (or method-only-group (gnus-info-group info))
4649 gnus-newsrc-hashtb))
4651 (info (if method-only-group (nth 2 entry) info)))
4652 (when method-only-group
4654 (error "Trying to change non-existent group %s" method-only-group))
4655 ;; We have received parts of the actual group info - either the
4656 ;; select method or the group parameters. We first check
4657 ;; whether we have to extend the info, and if so, do that.
4658 (let ((len (length info))
4659 (total (if (eq part 'method) 5 6)))
4661 (setcdr (nthcdr (1- len) info)
4662 (make-list (- total len) nil)))
4663 ;; Then we enter the new info.
4664 (setcar (nthcdr (1- total) info) part-info)))
4666 ;; This is a new group, so we just create it.
4668 (set-buffer gnus-group-buffer)
4669 (if (gnus-info-method info)
4670 ;; It's a foreign group...
4671 (gnus-group-make-group
4672 (gnus-group-real-name (gnus-info-group info))
4673 (prin1-to-string (car (gnus-info-method info)))
4674 (nth 1 (gnus-info-method info)))
4675 ;; It's a native group.
4676 (gnus-group-make-group (gnus-info-group info)))
4677 (gnus-message 6 "Note: New group created")
4679 (gnus-gethash (gnus-group-prefixed-name
4680 (gnus-group-real-name (gnus-info-group info))
4681 (or (gnus-info-method info) gnus-select-method))
4682 gnus-newsrc-hashtb))))
4683 ;; Whether it was a new group or not, we now have the entry, so we
4684 ;; can do the update.
4687 (setcar (nthcdr 2 entry) info)
4688 (when (and (not (eq (car entry) t))
4689 (gnus-active (gnus-info-group info)))
4690 (let ((marked (gnus-info-marks info)))
4691 (setcar entry (length (gnus-list-of-unread-articles
4693 (error "No such group: %s" (gnus-info-group info)))))
4695 (defun gnus-group-set-method-info (group select-method)
4696 (gnus-group-set-info select-method group 'method))
4698 (defun gnus-group-set-params-info (group params)
4699 (gnus-group-set-info params group 'params))
4701 (defun gnus-group-update-group-line ()
4702 "Update the current line in the group buffer."
4703 (let* ((buffer-read-only nil)
4704 (group (gnus-group-group-name))
4705 (gnus-group-indentation (gnus-group-group-indentation))
4706 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4708 (not (gnus-ephemeral-group-p group))
4710 (concat "(gnus-group-set-info '"
4711 (prin1-to-string (nth 2 entry)) ")")))
4713 (gnus-group-insert-group-line-info group)
4715 (gnus-group-position-point)))
4717 (defun gnus-group-insert-group-line-info (group)
4718 "Insert GROUP on the current line."
4719 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4723 ;; (Un)subscribed group.
4724 (setq info (nth 2 entry))
4725 (gnus-group-insert-group-line
4726 group (gnus-info-level info) (gnus-info-marks info)
4727 (or (car entry) t) (gnus-info-method info)))
4728 ;; This group is dead.
4729 (gnus-group-insert-group-line
4731 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4733 (if (setq active (gnus-active group))
4734 (- (1+ (cdr active)) (car active)) 0)
4737 (defun gnus-group-insert-group-line
4738 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4740 "Insert a group line in the group buffer."
4741 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4742 (gnus-tmp-number-total
4744 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4746 (gnus-tmp-number-of-unread
4747 (if (numberp number) (int-to-string (max 0 number))
4749 (gnus-tmp-number-of-read
4750 (if (numberp number)
4751 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4753 (gnus-tmp-subscribed
4754 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4755 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4756 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4758 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4759 (gnus-tmp-newsgroup-description
4760 (if gnus-description-hashtb
4761 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4764 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4765 (gnus-tmp-moderated-string
4766 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4768 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4769 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4770 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4771 (gnus-tmp-news-method-string
4773 (format "(%s:%s)" (car gnus-tmp-method)
4774 (cadr gnus-tmp-method)) ""))
4775 (gnus-tmp-marked-mark
4776 (if (and (numberp number)
4778 (cdr (assq 'tick gnus-tmp-marked)))
4780 (gnus-tmp-process-marked
4781 (if (member gnus-tmp-group gnus-group-marked)
4782 gnus-process-mark ? ))
4784 (or (and gnus-use-grouplens
4785 (bbb-grouplens-group-p gnus-tmp-group))
4787 (buffer-read-only nil)
4788 header gnus-tmp-header) ; passed as parameter to user-funcs.
4790 (add-text-properties
4794 (eval gnus-group-line-format-spec))
4795 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4796 gnus-unread ,(if (numberp number)
4797 (string-to-int gnus-tmp-number-of-unread)
4799 gnus-marked ,gnus-tmp-marked-mark
4800 gnus-indentation ,gnus-group-indentation
4801 gnus-level ,gnus-tmp-level))
4802 (when (gnus-visual-p 'group-highlight 'highlight)
4804 (run-hooks 'gnus-group-update-hook)
4806 ;; Allow XEmacs to remove front-sticky text properties.
4807 (gnus-group-remove-excess-properties)))
4809 (defun gnus-group-update-group (group &optional visible-only)
4810 "Update all lines where GROUP appear.
4811 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4814 (set-buffer gnus-group-buffer)
4815 ;; The buffer may be narrowed.
4818 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4820 found buffer-read-only visible)
4821 ;; Enter the current status into the dribble buffer.
4822 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4823 (if (and entry (not (gnus-ephemeral-group-p group)))
4825 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4827 ;; Find all group instances. If topics are in use, each group
4828 ;; may be listed in more than once.
4829 (while (setq loc (text-property-any
4830 loc (point-max) 'gnus-group ident))
4833 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4835 (gnus-group-insert-group-line-info group))
4836 (setq loc (1+ loc)))
4837 (unless (or found visible-only)
4838 ;; No such line in the buffer, find out where it's supposed to
4839 ;; go, and insert it there (or at the end of the buffer).
4840 (if gnus-goto-missing-group-function
4841 (funcall gnus-goto-missing-group-function group)
4842 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4843 (while (and entry (car entry)
4847 (point-min) (point-max)
4848 'gnus-group (gnus-intern-safe
4849 (caar entry) gnus-active-hashtb)))))
4850 (setq entry (cdr entry)))
4851 (or entry (goto-char (point-max)))))
4852 ;; Finally insert the line.
4853 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4854 (gnus-group-insert-group-line-info group)))
4855 (gnus-group-set-mode-line)))))
4857 (defun gnus-group-set-mode-line ()
4858 (when (memq 'group gnus-updated-mode-lines)
4859 (let* ((gformat (or gnus-group-mode-line-format-spec
4860 (setq gnus-group-mode-line-format-spec
4862 gnus-group-mode-line-format
4863 gnus-group-mode-line-format-alist))))
4864 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4865 (gnus-tmp-news-method (car gnus-select-method))
4867 gnus-tmp-header ;Dummy binding for user-defined formats
4868 ;; Get the resulting string.
4869 (mode-string (eval gformat)))
4870 ;; If the line is too long, we chop it off.
4871 (when (> (length mode-string) max-len)
4872 (setq mode-string (substring mode-string 0 (- max-len 4))))
4874 (setq mode-line-buffer-identification (list mode-string))
4875 (set-buffer-modified-p t)))))
4877 (defun gnus-group-group-name ()
4878 "Get the name of the newsgroup on the current line."
4879 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4880 (and group (symbol-name group))))
4882 (defun gnus-group-group-level ()
4883 "Get the level of the newsgroup on the current line."
4884 (get-text-property (gnus-point-at-bol) 'gnus-level))
4886 (defun gnus-group-group-indentation ()
4887 "Get the indentation of the newsgroup on the current line."
4888 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4890 (defun gnus-group-group-unread ()
4891 "Get the number of unread articles of the newsgroup on the current line."
4892 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4894 (defun gnus-group-search-forward (&optional backward all level first-too)
4895 "Find the next newsgroup with unread articles.
4896 If BACKWARD is non-nil, find the previous newsgroup instead.
4897 If ALL is non-nil, just find any newsgroup.
4898 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4900 If FIRST-TOO, the current line is also eligible as a target."
4901 (let ((way (if backward -1 1))
4902 (low gnus-level-killed)
4905 (if (and backward (progn (beginning-of-line)) (bobp))
4907 (or first-too (forward-line way))
4915 (get-text-property (point) 'gnus-unread)))
4916 (and (numberp unread) (> unread 0)))
4917 (setq lev (get-text-property (point)
4919 (<= lev gnus-level-subscribed)))
4921 (and (setq lev (get-text-property (point)
4930 (zerop (forward-line way)))))
4932 (progn (gnus-group-position-point) t)
4933 (goto-char (or pos beg))
4936 ;;; Gnus group mode commands
4940 (defun gnus-group-mark-group (n &optional unmark no-advance)
4941 "Mark the current group."
4943 (let ((buffer-read-only nil)
4947 (setq group (gnus-group-group-name))
4951 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4956 (setq gnus-group-marked (delete group gnus-group-marked)))
4958 (setq gnus-group-marked
4959 (cons group (delete group gnus-group-marked))))
4961 (or no-advance (zerop (gnus-group-next-group 1))))
4963 (gnus-summary-position-point)
4966 (defun gnus-group-unmark-group (n)
4967 "Remove the mark from the current group."
4969 (gnus-group-mark-group n 'unmark)
4970 (gnus-group-position-point))
4972 (defun gnus-group-unmark-all-groups ()
4973 "Unmark all groups."
4974 (let ((groups gnus-group-marked))
4977 (gnus-group-remove-mark (pop groups)))))
4978 (gnus-group-position-point))
4980 (defun gnus-group-mark-region (unmark beg end)
4981 "Mark all groups between point and mark.
4982 If UNMARK, remove the mark instead."
4983 (interactive "P\nr")
4984 (let ((num (count-lines beg end)))
4987 (- num (gnus-group-mark-group num unmark)))))
4989 (defun gnus-group-mark-buffer (&optional unmark)
4990 "Mark all groups in the buffer.
4991 If UNMARK, remove the mark instead."
4993 (gnus-group-mark-region unmark (point-min) (point-max)))
4995 (defun gnus-group-mark-regexp (regexp)
4996 "Mark all groups that match some regexp."
4997 (interactive "sMark (regexp): ")
4998 (let ((alist (cdr gnus-newsrc-alist))
5001 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5002 (gnus-group-set-mark group))))
5003 (gnus-group-position-point))
5005 (defun gnus-group-remove-mark (group)
5006 "Remove the process mark from GROUP and move point there.
5007 Return nil if the group isn't displayed."
5008 (if (gnus-group-goto-group group)
5010 (gnus-group-mark-group 1 'unmark t)
5012 (setq gnus-group-marked
5013 (delete group gnus-group-marked))
5016 (defun gnus-group-set-mark (group)
5017 "Set the process mark on GROUP."
5018 (if (gnus-group-goto-group group)
5020 (gnus-group-mark-group 1 nil t))
5021 (setq gnus-group-marked
5022 (cons group (delete group gnus-group-marked)))))
5024 (defun gnus-group-universal-argument (arg &optional groups func)
5025 "Perform any command on all groups accoring to the process/prefix convention."
5027 (let ((groups (or groups (gnus-group-process-prefix arg)))
5029 (if (eq (setq func (or func
5032 (substitute-command-keys
5033 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5036 (message "Undefined key")
5039 (gnus-group-remove-mark (setq group (pop groups)))
5040 (command-execute func))))
5041 (gnus-group-position-point))
5043 (defun gnus-group-process-prefix (n)
5044 "Return a list of groups to work on.
5045 Take into consideration N (the prefix) and the list of marked groups."
5048 (setq n (prefix-numeric-value n))
5049 ;; There is a prefix, so we return a list of the N next
5051 (let ((way (if (< n 0) -1 1))
5056 (setq group (gnus-group-group-name)))
5057 (setq groups (cons group groups))
5059 (gnus-group-next-group way)))
5061 ((and (boundp 'transient-mark-mode)
5064 ;; Work on the region between point and mark.
5065 (let ((max (max (point) (mark)))
5068 (goto-char (min (point) (mark)))
5071 (push (gnus-group-group-name) groups)
5072 (zerop (gnus-group-next-group 1))
5074 (nreverse groups))))
5076 ;; No prefix, but a list of marked articles.
5077 (reverse gnus-group-marked))
5079 ;; Neither marked articles or a prefix, so we return the
5081 (let ((group (gnus-group-group-name)))
5082 (and group (list group))))))
5084 ;; Selecting groups.
5086 (defun gnus-group-read-group (&optional all no-article group)
5087 "Read news in this newsgroup.
5088 If the prefix argument ALL is non-nil, already read articles become
5089 readable. IF ALL is a number, fetch this number of articles. If the
5090 optional argument NO-ARTICLE is non-nil, no article will be
5091 auto-selected upon group entry. If GROUP is non-nil, fetch that
5094 (let ((group (or group (gnus-group-group-name)))
5095 number active marked entry)
5096 (or group (error "No group on current line"))
5097 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5098 group gnus-newsrc-hashtb)))))
5099 ;; This group might be a dead group. In that case we have to get
5100 ;; the number of unread articles from `gnus-active-hashtb'.
5102 (cond ((numberp all) all)
5104 ((setq active (gnus-active group))
5105 (- (1+ (cdr active)) (car active)))))
5106 (gnus-summary-read-group
5107 group (or all (and (numberp number)
5108 (zerop (+ number (length (cdr (assq 'tick marked)))
5109 (length (cdr (assq 'dormant marked)))))))
5112 (defun gnus-group-select-group (&optional all)
5113 "Select this newsgroup.
5114 No article is selected automatically.
5115 If ALL is non-nil, already read articles become readable.
5116 If ALL is a number, fetch this number of articles."
5118 (gnus-group-read-group all t))
5120 (defun gnus-group-quick-select-group (&optional all)
5121 "Select the current group \"quickly\".
5122 This means that no highlighting or scoring will be performed."
5125 gnus-score-find-score-files-function
5126 gnus-apply-kill-hook
5127 gnus-summary-expunge-below)
5128 (gnus-group-read-group all t)))
5130 (defun gnus-group-visible-select-group (&optional all)
5131 "Select the current group without hiding any articles."
5133 (let ((gnus-inhibit-limiting t))
5134 (gnus-group-read-group all t)))
5137 (defun gnus-fetch-group (group)
5138 "Start Gnus if necessary and enter GROUP.
5139 Returns whether the fetching was successful or not."
5140 (interactive "sGroup name: ")
5141 (or (get-buffer gnus-group-buffer)
5143 (gnus-group-select-group))
5145 ;; Enter a group that is not in the group buffer. Non-nil is returned
5146 ;; if selection was successful.
5147 (defun gnus-group-read-ephemeral-group
5148 (group method &optional activate quit-config)
5149 (let ((group (if (gnus-group-foreign-p group) group
5150 (gnus-group-prefixed-name group method))))
5153 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5154 ((quit-config . ,(if quit-config quit-config
5155 (cons (current-buffer) 'summary))))))
5157 (set-buffer gnus-group-buffer)
5158 (or (gnus-check-server method)
5159 (error "Unable to contact server: %s" (gnus-status-message method)))
5160 (if activate (or (gnus-request-group group)
5161 (error "Couldn't request group")))
5163 (gnus-group-read-group t t group)
5167 (defun gnus-group-jump-to-group (group)
5168 "Jump to newsgroup GROUP."
5170 (list (completing-read
5171 "Group: " gnus-active-hashtb nil
5172 (memq gnus-select-method gnus-have-read-active-file))))
5174 (if (equal group "")
5175 (error "Empty group name"))
5177 (let ((b (text-property-any
5178 (point-min) (point-max)
5179 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5180 (unless (gnus-ephemeral-group-p group)
5182 ;; Either go to the line in the group buffer...
5184 ;; ... or insert the line.
5187 (gnus-activate-group group)
5188 (error "%s error: %s" group (gnus-status-message group)))
5190 (gnus-group-update-group group)
5191 (goto-char (text-property-any
5192 (point-min) (point-max)
5193 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5194 ;; Adjust cursor point.
5195 (gnus-group-position-point)))
5197 (defun gnus-group-goto-group (group)
5198 "Goto to newsgroup GROUP."
5200 (let ((b (text-property-any (point-min) (point-max)
5201 'gnus-group (gnus-intern-safe
5202 group gnus-active-hashtb))))
5203 (and b (goto-char b)))))
5205 (defun gnus-group-next-group (n)
5206 "Go to next N'th newsgroup.
5207 If N is negative, search backward instead.
5208 Returns the difference between N and the number of skips actually
5211 (gnus-group-next-unread-group n t))
5213 (defun gnus-group-next-unread-group (n &optional all level)
5214 "Go to next N'th unread newsgroup.
5215 If N is negative, search backward instead.
5216 If ALL is non-nil, choose any newsgroup, unread or not.
5217 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5218 such group can be found, the next group with a level higher than
5220 Returns the difference between N and the number of skips actually
5223 (let ((backward (< n 0))
5226 (gnus-group-search-forward
5227 backward (or (not gnus-group-goto-unread) all) level))
5229 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5230 (if level " on this level or higher" "")))
5233 (defun gnus-group-prev-group (n)
5234 "Go to previous N'th newsgroup.
5235 Returns the difference between N and the number of skips actually
5238 (gnus-group-next-unread-group (- n) t))
5240 (defun gnus-group-prev-unread-group (n)
5241 "Go to previous N'th unread newsgroup.
5242 Returns the difference between N and the number of skips actually
5245 (gnus-group-next-unread-group (- n)))
5247 (defun gnus-group-next-unread-group-same-level (n)
5248 "Go to next N'th unread newsgroup on the same level.
5249 If N is negative, search backward instead.
5250 Returns the difference between N and the number of skips actually
5253 (gnus-group-next-unread-group n t (gnus-group-group-level))
5254 (gnus-group-position-point))
5256 (defun gnus-group-prev-unread-group-same-level (n)
5257 "Go to next N'th unread newsgroup on the same level.
5258 Returns the difference between N and the number of skips actually
5261 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5262 (gnus-group-position-point))
5264 (defun gnus-group-best-unread-group (&optional exclude-group)
5265 "Go to the group with the highest level.
5266 If EXCLUDE-GROUP, do not go to that group."
5268 (goto-char (point-min))
5271 (while (setq unread (get-text-property (point) 'gnus-unread))
5272 (if (and (numberp unread) (> unread 0))
5274 (if (and (< (get-text-property (point) 'gnus-level) best)
5275 (or (not exclude-group)
5276 (not (equal exclude-group (gnus-group-group-name)))))
5278 (setq best (get-text-property (point) 'gnus-level))
5279 (setq best-point (point))))))
5281 (if best-point (goto-char best-point))
5282 (gnus-summary-position-point)
5283 (and best-point (gnus-group-group-name))))
5285 (defun gnus-group-first-unread-group ()
5286 "Go to the first group with unread articles."
5289 (let ((opoint (point))
5291 (goto-char (point-min))
5292 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5293 (and (numberp unread) ; Not a topic.
5294 (not (zerop unread))) ; Has unread articles.
5295 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5298 nil)) ; Not success.
5299 (gnus-group-position-point)))
5301 (defun gnus-group-enter-server-mode ()
5302 "Jump to the server buffer."
5304 (gnus-enter-server-buffer))
5306 (defun gnus-group-make-group (name &optional method address)
5307 "Add a new newsgroup.
5308 The user will be prompted for a NAME, for a select METHOD, and an
5312 (read-string "Group name: ")
5315 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5317 (if (assoc method gnus-valid-select-methods)
5319 (if (memq 'prompt-address
5320 (assoc method gnus-valid-select-methods))
5321 (read-string "Address: ")
5323 (list method "")))))
5326 (set-buffer gnus-group-buffer)
5327 (let* ((meth (and method (if address (list (intern method) address)
5329 (nname (if method (gnus-group-prefixed-name name meth) name))
5331 (and (gnus-gethash nname gnus-newsrc-hashtb)
5332 (error "Group %s already exists" nname))
5333 (gnus-group-change-level
5334 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5335 gnus-level-default-subscribed gnus-level-killed
5336 (and (gnus-group-group-name)
5337 (gnus-gethash (gnus-group-group-name)
5338 gnus-newsrc-hashtb))
5340 (gnus-set-active nname (cons 1 0))
5341 (or (gnus-ephemeral-group-p name)
5343 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5344 (gnus-group-insert-group-line-info nname)
5346 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5347 (require (car meth)))
5348 (gnus-check-server meth)
5349 (and (gnus-check-backend-function 'request-create-group nname)
5350 (gnus-request-create-group nname))
5353 (defun gnus-group-delete-group (group &optional force)
5354 "Delete the current group.
5355 If FORCE (the prefix) is non-nil, all the articles in the group will
5356 be deleted. This is \"deleted\" as in \"removed forever from the face
5357 of the Earth\". There is no undo."
5359 (list (gnus-group-group-name)
5360 current-prefix-arg))
5361 (or group (error "No group to rename"))
5362 (or (gnus-check-backend-function 'request-delete-group group)
5363 (error "This backend does not support group deletion"))
5365 (if (not (gnus-yes-or-no-p
5367 "Do you really want to delete %s%s? "
5368 group (if force " and all its contents" ""))))
5370 (gnus-message 6 "Deleting group %s..." group)
5371 (if (not (gnus-request-delete-group group force))
5373 (gnus-message 3 "Couldn't delete group %s" group)
5375 (gnus-message 6 "Deleting group %s...done" group)
5376 (gnus-group-goto-group group)
5377 (gnus-group-kill-group 1 t)
5379 (gnus-group-position-point)))
5381 (defun gnus-group-rename-group (group new-name)
5384 (gnus-group-group-name)
5386 (or (gnus-check-backend-function
5387 'request-rename-group (gnus-group-group-name))
5388 (error "This backend does not support renaming groups"))
5389 (read-string "New group name: "))))
5391 (or (gnus-check-backend-function 'request-rename-group group)
5392 (error "This backend does not support renaming groups"))
5394 (or group (error "No group to rename"))
5395 (and (string-match "^[ \t]*$" new-name)
5396 (error "Not a valid group name"))
5398 ;; We find the proper prefixed name.
5400 (gnus-group-prefixed-name
5401 (gnus-group-real-name new-name)
5402 (gnus-info-method (gnus-get-info group))))
5404 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5406 (if (not (gnus-request-rename-group group new-name))
5408 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5410 ;; We rename the group internally by killing it...
5411 (gnus-group-goto-group group)
5412 (gnus-group-kill-group)
5413 ;; ... changing its name ...
5414 (setcar (cdr (car gnus-list-of-killed-groups))
5416 ;; ... and then yanking it. Magic!
5417 (gnus-group-yank-group)
5418 (gnus-set-active new-name (gnus-active group))
5419 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5421 (gnus-group-position-point)))
5423 (defun gnus-group-edit-group (group &optional part)
5424 "Edit the group on the current line."
5425 (interactive (list (gnus-group-group-name)))
5426 (let* ((part (or part 'info))
5427 (done-func `(lambda ()
5428 "Exit editing mode and update the information."
5430 (gnus-group-edit-group-done ',part ,group)))
5431 (winconf (current-window-configuration))
5433 (or group (error "No group on current line"))
5434 (or (setq info (gnus-get-info group))
5435 (error "Killed group; can't be edited"))
5436 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5437 (gnus-configure-windows 'edit-group)
5438 (gnus-add-current-to-buffer-list)
5440 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5441 (use-local-map (copy-keymap emacs-lisp-mode-map))
5442 (local-set-key "\C-c\C-c" done-func)
5443 (make-local-variable 'gnus-prev-winconf)
5444 (setq gnus-prev-winconf winconf)
5449 ";; Type `C-c C-c' after editing the select method.\n\n")
5451 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5453 ";; Type `C-c C-c' after editing the group info.\n\n")))
5456 (cond ((eq part 'method)
5457 (or (gnus-info-method info) "native"))
5459 (gnus-info-params info))
5463 (defun gnus-group-edit-group-method (group)
5464 "Edit the select method of GROUP."
5465 (interactive (list (gnus-group-group-name)))
5466 (gnus-group-edit-group group 'method))
5468 (defun gnus-group-edit-group-parameters (group)
5469 "Edit the group parameters of GROUP."
5470 (interactive (list (gnus-group-group-name)))
5471 (gnus-group-edit-group group 'params))
5473 (defun gnus-group-edit-group-done (part group)
5474 "Get info from buffer, update variables and jump to the group buffer."
5475 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5476 (goto-char (point-min))
5477 (let* ((form (read (current-buffer)))
5478 (winconf gnus-prev-winconf)
5479 (method (cond ((eq part 'info) (nth 4 form))
5480 ((eq part 'method) form)
5482 (info (cond ((eq part 'info) form)
5483 ((eq part 'method) (gnus-get-info group))
5486 (if (or (not method)
5488 gnus-select-method method))
5489 (gnus-group-real-name (car info))
5490 (gnus-group-prefixed-name
5491 (gnus-group-real-name (car info)) method))
5493 (when (and new-group
5494 (not (equal new-group group)))
5495 (when (gnus-group-goto-group group)
5496 (gnus-group-kill-group 1))
5497 (gnus-activate-group new-group))
5499 (if (and info new-group)
5501 (setq info (gnus-copy-sequence info))
5502 (setcar info new-group)
5503 (setcar (cddddr info) method)
5504 (gnus-group-set-info info))
5505 (gnus-group-set-info form (or new-group group) part))
5506 (kill-buffer (current-buffer))
5507 (and winconf (set-window-configuration winconf))
5508 (set-buffer gnus-group-buffer)
5509 (gnus-group-update-group (or new-group group))
5510 (gnus-group-position-point)))
5512 (defun gnus-group-make-help-group ()
5513 "Create the Gnus documentation group."
5515 (let ((path load-path)
5516 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5518 (and (gnus-gethash name gnus-newsrc-hashtb)
5519 (error "Documentation group already exists"))
5521 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5523 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5525 (setq file (concat (file-name-directory
5526 (directory-file-name dir))
5527 "etc/gnus-tut.txt"))))
5530 (message "Couldn't find doc group")
5531 (gnus-group-make-group
5532 (gnus-group-real-name name)
5534 (list 'nndoc-address file)
5535 (list 'nndoc-article-type 'mbox)))))
5536 (gnus-group-position-point))
5538 (defun gnus-group-make-doc-group (file type)
5539 "Create a group that uses a single file as the source."
5541 (list (read-file-name "File name: ")
5542 (and current-prefix-arg 'ask)))
5543 (when (eq type 'ask)
5548 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5550 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5551 ((= char ?b) 'babyl)
5552 ((= char ?d) 'digest)
5553 ((= char ?f) 'forward)
5555 (t (setq err (format "%c unknown. " char))
5558 (let* ((file (expand-file-name file))
5559 (name (gnus-generate-new-group-name
5560 (gnus-group-prefixed-name
5561 (file-name-nondirectory file) '(nndoc "")))))
5562 (gnus-group-make-group
5563 (gnus-group-real-name name)
5565 (list 'nndoc-address file)
5566 (list 'nndoc-article-type (or type 'guess))))
5568 (gnus-group-position-point)))
5570 (defun gnus-group-make-archive-group (&optional all)
5571 "Create the (ding) Gnus archive group of the most recent articles.
5572 Given a prefix, create a full group."
5574 (let ((group (gnus-group-prefixed-name
5575 (if all "ding.archives" "ding.recent") '(nndir ""))))
5576 (and (gnus-gethash group gnus-newsrc-hashtb)
5577 (error "Archive group already exists"))
5578 (gnus-group-make-group
5579 (gnus-group-real-name group)
5580 (list 'nndir (if all "hpc" "edu")
5581 (list 'nndir-directory
5582 (if all gnus-group-archive-directory
5583 gnus-group-recent-archive-directory)))))
5585 (gnus-group-position-point))
5587 (defun gnus-group-make-directory-group (dir)
5588 "Create an nndir group.
5589 The user will be prompted for a directory. The contents of this
5590 directory will be used as a newsgroup. The directory should contain
5591 mail messages or news articles in files that have numeric names."
5593 (list (read-file-name "Create group from directory: ")))
5594 (or (file-exists-p dir) (error "No such directory"))
5595 (or (file-directory-p dir) (error "Not a directory"))
5599 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5601 (gnus-group-prefixed-name
5602 (concat (file-name-as-directory (directory-file-name dir))
5605 (setq ext (format "<%d>" (setq i (1+ i)))))
5606 (gnus-group-make-group
5607 (gnus-group-real-name group)
5608 (list 'nndir group (list 'nndir-directory dir))))
5610 (gnus-group-position-point))
5612 (defun gnus-group-make-kiboze-group (group address scores)
5613 "Create an nnkiboze group.
5614 The user will be prompted for a name, a regexp to match groups, and
5615 score file entries for articles to include in the group."
5618 (read-string "nnkiboze group name: ")
5619 (read-string "Source groups (regexp): ")
5620 (let ((headers (mapcar (lambda (group) (list group))
5621 '("subject" "from" "number" "date" "message-id"
5622 "references" "chars" "lines" "xref"
5623 "followup" "all" "body" "head")))
5624 scores header regexp regexps)
5625 (while (not (equal "" (setq header (completing-read
5626 "Match on header: " headers nil t))))
5628 (while (not (equal "" (setq regexp (read-string
5629 (format "Match on %s (string): "
5631 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5632 (setq scores (cons (cons header regexps) scores)))
5634 (gnus-group-make-group group "nnkiboze" address)
5636 (gnus-set-work-buffer)
5637 (let (emacs-lisp-mode-hook)
5638 (pp scores (current-buffer)))
5639 (write-region (point-min) (point-max)
5640 (gnus-score-file-name (concat "nnkiboze:" group))))
5642 (gnus-group-position-point))
5644 (defun gnus-group-add-to-virtual (n vgroup)
5645 "Add the current group to a virtual group."
5647 (list current-prefix-arg
5648 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5650 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5651 (error "%s is not an nnvirtual group" vgroup))
5652 (let* ((groups (gnus-group-process-prefix n))
5653 (method (gnus-info-method (gnus-get-info vgroup))))
5654 (setcar (cdr method)
5656 (nth 1 method) "\\|"
5659 (gnus-group-remove-mark s)
5660 (concat "\\(^" (regexp-quote s) "$\\)"))
5662 (gnus-group-position-point))
5664 (defun gnus-group-make-empty-virtual (group)
5665 "Create a new, fresh, empty virtual group."
5666 (interactive "sCreate new, empty virtual group: ")
5667 (let* ((method (list 'nnvirtual "^$"))
5668 (pgroup (gnus-group-prefixed-name group method)))
5669 ;; Check whether it exists already.
5670 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5671 (error "Group %s already exists." pgroup))
5672 ;; Subscribe the new group after the group on the current line.
5673 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5674 (gnus-group-update-group pgroup)
5676 (gnus-group-position-point)))
5678 (defun gnus-group-enter-directory (dir)
5679 "Enter an ephemeral nneething group."
5680 (interactive "DDirectory to read: ")
5681 (let* ((method (list 'nneething dir))
5682 (leaf (gnus-group-prefixed-name
5683 (file-name-nondirectory (directory-file-name dir))
5685 (name (gnus-generate-new-group-name leaf)))
5686 (let ((nneething-read-only t))
5687 (or (gnus-group-read-ephemeral-group
5689 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5691 (error "Couldn't enter %s" dir)))))
5693 ;; Group sorting commands
5694 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5696 (defun gnus-group-sort-groups (func &optional reverse)
5697 "Sort the group buffer according to FUNC.
5698 If REVERSE, reverse the sorting order."
5699 (interactive (list gnus-group-sort-function
5700 current-prefix-arg))
5702 ((not (listp func)) func)
5704 ((= 1 (length func)) (car func))
5706 ,(gnus-make-sort-function
5707 (reverse func)))))))
5708 ;; We peel off the dummy group from the alist.
5710 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5711 (pop gnus-newsrc-alist))
5713 (setq gnus-newsrc-alist
5714 (sort gnus-newsrc-alist func))
5716 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5717 ;; Regenerate the hash table.
5718 (gnus-make-hashtable-from-newsrc-alist)
5719 (gnus-group-list-groups))))
5721 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5722 "Sort the group buffer alphabetically by group name.
5723 If REVERSE, sort in reverse order."
5725 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5727 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5728 "Sort the group buffer by number of unread articles.
5729 If REVERSE, sort in reverse order."
5731 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5733 (defun gnus-group-sort-groups-by-level (&optional reverse)
5734 "Sort the group buffer by group level.
5735 If REVERSE, sort in reverse order."
5737 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5739 (defun gnus-group-sort-groups-by-score (&optional reverse)
5740 "Sort the group buffer by group score.
5741 If REVERSE, sort in reverse order."
5743 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5745 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5746 "Sort the group buffer by group rank.
5747 If REVERSE, sort in reverse order."
5749 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5751 (defun gnus-group-sort-groups-by-method (&optional reverse)
5752 "Sort the group buffer alphabetically by backend name.
5753 If REVERSE, sort in reverse order."
5755 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5757 (defun gnus-group-sort-by-alphabet (info1 info2)
5758 "Sort alphabetically."
5759 (string< (gnus-info-group info1) (gnus-info-group info2)))
5761 (defun gnus-group-sort-by-unread (info1 info2)
5762 "Sort by number of unread articles."
5763 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5764 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5765 (< (or (and (numberp n1) n1) 0)
5766 (or (and (numberp n2) n2) 0))))
5768 (defun gnus-group-sort-by-level (info1 info2)
5770 (< (gnus-info-level info1) (gnus-info-level info2)))
5772 (defun gnus-group-sort-by-method (info1 info2)
5773 "Sort alphabetically by backend name."
5774 (string< (symbol-name (car (gnus-find-method-for-group
5775 (gnus-info-group info1) info1)))
5776 (symbol-name (car (gnus-find-method-for-group
5777 (gnus-info-group info2) info2)))))
5779 (defun gnus-group-sort-by-score (info1 info2)
5780 "Sort by group score."
5781 (< (gnus-info-score info1) (gnus-info-score info2)))
5783 (defun gnus-group-sort-by-rank (info1 info2)
5784 "Sort by level and score."
5785 (let ((level1 (gnus-info-level info1))
5786 (level2 (gnus-info-level info2)))
5787 (or (< level1 level2)
5788 (and (= level1 level2)
5789 (< (gnus-info-score info1) (gnus-info-score info2))))))
5791 ;; Group catching up.
5793 (defun gnus-group-catchup-current (&optional n all)
5794 "Mark all articles not marked as unread in current newsgroup as read.
5795 If prefix argument N is numeric, the ARG next newsgroups will be
5796 caught up. If ALL is non-nil, marked articles will also be marked as
5797 read. Cross references (Xref: header) of articles are ignored.
5798 The difference between N and actual number of newsgroups that were
5799 caught up is returned."
5801 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5805 "Do you really want to mark all articles as read? "
5806 "Mark all unread articles as read? "))))
5808 (let ((groups (gnus-group-process-prefix n))
5811 ;; Virtual groups have to be given special treatment.
5812 (let ((method (gnus-find-method-for-group (car groups))))
5813 (if (eq 'nnvirtual (car method))
5814 (nnvirtual-catchup-group
5815 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5816 (gnus-group-remove-mark (car groups))
5818 (gnus-group-goto-group (car groups))
5819 (gnus-group-catchup (car groups) all))
5820 (gnus-group-update-group-line)
5821 (setq ret (1+ ret)))
5822 (setq groups (cdr groups)))
5823 (gnus-group-next-unread-group 1)
5826 (defun gnus-group-catchup-current-all (&optional n)
5827 "Mark all articles in current newsgroup as read.
5828 Cross references (Xref: header) of articles are ignored."
5830 (gnus-group-catchup-current n 'all))
5832 (defun gnus-group-catchup (group &optional all)
5833 "Mark all articles in GROUP as read.
5834 If ALL is non-nil, all articles are marked as read.
5835 The return value is the number of articles that were marked as read,
5836 or nil if no action could be taken."
5837 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5839 ;; Do the updating only if the newsgroup isn't killed.
5840 (if (not (numberp (car entry)))
5841 (gnus-message 1 "Can't catch up; non-active group")
5842 ;; Do auto-expirable marks if that's required.
5843 (when (gnus-group-auto-expirable-p group)
5844 (gnus-add-marked-articles
5845 group 'expire (gnus-list-of-unread-articles group))
5847 (let ((marks (nth 3 (nth 2 entry))))
5848 (gnus-add-marked-articles
5849 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5850 (gnus-add-marked-articles
5851 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5853 (gnus-update-read-articles group nil)
5854 ;; Also nix out the lists of marks and dormants.
5856 (gnus-add-marked-articles group 'tick nil nil 'force)
5857 (gnus-add-marked-articles group 'dormant nil nil 'force))
5858 (run-hooks 'gnus-group-catchup-group-hook)
5861 (defun gnus-group-expire-articles (&optional n)
5862 "Expire all expirable articles in the current newsgroup."
5864 (let ((groups (gnus-group-process-prefix n))
5867 (error "No groups to expire"))
5868 (while (setq group (pop groups))
5869 (gnus-group-remove-mark group)
5870 (when (gnus-check-backend-function 'request-expire-articles group)
5871 (gnus-message 6 "Expiring articles in %s..." group)
5872 (let* ((info (gnus-get-info group))
5873 (expirable (if (gnus-group-total-expirable-p group)
5874 (cons nil (gnus-list-of-read-articles group))
5875 (assq 'expire (gnus-info-marks info))))
5876 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5880 (gnus-compress-sequence
5882 ;; We set the expiry variables to the groupp
5884 (let ((nnmail-expiry-wait-function nil)
5885 (nnmail-expiry-wait expiry-wait))
5886 (gnus-request-expire-articles
5887 (gnus-uncompress-sequence (cdr expirable)) group))
5888 ;; Just expire using the normal expiry values.
5889 (gnus-request-expire-articles
5890 (gnus-uncompress-sequence (cdr expirable)) group)))))
5891 (gnus-message 6 "Expiring articles in %s...done" group)))
5892 (gnus-group-position-point))))
5894 (defun gnus-group-expire-all-groups ()
5895 "Expire all expirable articles in all newsgroups."
5898 (gnus-message 5 "Expiring...")
5899 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5900 (cdr gnus-newsrc-alist))))
5901 (gnus-group-expire-articles nil)))
5902 (gnus-group-position-point)
5903 (gnus-message 5 "Expiring...done"))
5905 (defun gnus-group-set-current-level (n level)
5906 "Set the level of the next N groups to LEVEL."
5910 (if (not (gnus-group-group-name))
5911 (error "No group on the current line")
5913 (let ((s (read-string
5914 (format "Level (default %s): " (gnus-group-group-level)))))
5915 (if (string-match "^\\s-*$" s)
5916 (int-to-string (gnus-group-group-level))
5918 (or (and (>= level 1) (<= level gnus-level-killed))
5919 (error "Illegal level: %d" level))
5920 (let ((groups (gnus-group-process-prefix n))
5922 (while (setq group (pop groups))
5923 (gnus-group-remove-mark group)
5924 (gnus-message 6 "Changed level of %s from %d to %d"
5925 group (or (gnus-group-group-level) gnus-level-killed)
5927 (gnus-group-change-level
5928 group level (or (gnus-group-group-level) gnus-level-killed))
5929 (gnus-group-update-group-line)))
5930 (gnus-group-position-point))
5932 (defun gnus-group-unsubscribe-current-group (&optional n)
5933 "Toggle subscription of the current group.
5934 If given numerical prefix, toggle the N next groups."
5936 (let ((groups (gnus-group-process-prefix n))
5939 (setq group (car groups)
5940 groups (cdr groups))
5941 (gnus-group-remove-mark group)
5942 (gnus-group-unsubscribe-group
5943 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5944 gnus-level-default-unsubscribed
5945 gnus-level-default-subscribed) t)
5946 (gnus-group-update-group-line))
5947 (gnus-group-next-group 1)))
5949 (defun gnus-group-unsubscribe-group (group &optional level silent)
5950 "Toggle subscription to GROUP.
5951 Killed newsgroups are subscribed. If SILENT, don't try to update the
5954 (list (completing-read
5955 "Group: " gnus-active-hashtb nil
5956 (memq gnus-select-method gnus-have-read-active-file))))
5957 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5959 ((string-match "^[ \t]$" group)
5960 (error "Empty group name"))
5962 ;; Toggle subscription flag.
5963 (gnus-group-change-level
5964 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5965 gnus-level-subscribed)
5966 (1+ gnus-level-subscribed)
5967 gnus-level-default-subscribed)))
5969 (gnus-group-update-group group)))
5970 ((and (stringp group)
5971 (or (not (memq gnus-select-method gnus-have-read-active-file))
5972 (gnus-active group)))
5973 ;; Add new newsgroup.
5974 (gnus-group-change-level
5976 (if level level gnus-level-default-subscribed)
5977 (or (and (member group gnus-zombie-list)
5980 (and (gnus-group-group-name)
5981 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5983 (gnus-group-update-group group)))
5984 (t (error "No such newsgroup: %s" group)))
5985 (gnus-group-position-point)))
5987 (defun gnus-group-transpose-groups (n)
5988 "Move the current newsgroup up N places.
5989 If given a negative prefix, move down instead. The difference between
5990 N and the number of steps taken is returned."
5992 (or (gnus-group-group-name)
5993 (error "No group on current line"))
5994 (gnus-group-kill-group 1)
5996 (forward-line (- n))
5997 (gnus-group-yank-group)
5998 (gnus-group-position-point)))
6000 (defun gnus-group-kill-all-zombies ()
6001 "Kill all zombie newsgroups."
6003 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6004 (setq gnus-zombie-list nil)
6005 (gnus-group-list-groups))
6007 (defun gnus-group-kill-region (begin end)
6008 "Kill newsgroups in current region (excluding current point).
6009 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6024 (beginning-of-line) ;Important when LINES < 1
6025 (gnus-group-kill-group lines)))
6027 (defun gnus-group-kill-group (&optional n discard)
6028 "Kill the next N groups.
6029 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6030 However, only groups that were alive can be yanked; already killed
6031 groups or zombie groups can't be yanked.
6032 The return value is the name of the group that was killed, or a list
6035 (let ((buffer-read-only nil)
6036 (groups (gnus-group-process-prefix n))
6037 group entry level out)
6038 (if (< (length groups) 10)
6039 ;; This is faster when there are few groups.
6041 (push (setq group (pop groups)) out)
6042 (gnus-group-remove-mark group)
6043 (setq level (gnus-group-group-level))
6045 (if (and (not discard)
6046 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6047 (setq gnus-list-of-killed-groups
6048 (cons (cons (car entry) (nth 2 entry))
6049 gnus-list-of-killed-groups)))
6050 (gnus-group-change-level
6051 (if entry entry group) gnus-level-killed (if entry nil level)))
6052 ;; If there are lots and lots of groups to be killed, we use
6053 ;; this thing instead.
6055 (setq groups (nreverse groups))
6057 (gnus-group-remove-mark (setq group (pop groups)))
6060 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6061 (push (cons (car entry) (nth 2 entry))
6062 gnus-list-of-killed-groups)
6063 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))
6064 ((member group gnus-zombie-list)
6065 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6066 (gnus-make-hashtable-from-newsrc-alist)))
6068 (gnus-group-position-point)
6069 (if (< (length out) 2) (car out) (nreverse out))))
6071 (defun gnus-group-yank-group (&optional arg)
6072 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6073 inserting it before the current newsgroup. The numeric ARG specifies
6074 how many newsgroups are to be yanked. The name of the newsgroup yanked
6075 is returned, or (if several groups are yanked) a list of yanked groups
6078 (setq arg (or arg 1))
6079 (let (info group prev out)
6080 (while (>= (decf arg) 0)
6081 (if (not (setq info (pop gnus-list-of-killed-groups)))
6082 (error "No more newsgroups to yank"))
6083 (push (setq group (nth 1 info)) out)
6084 ;; Find which newsgroup to insert this one before - search
6085 ;; backward until something suitable is found. If there are no
6086 ;; other newsgroups in this buffer, just make this newsgroup the
6088 (setq prev (gnus-group-group-name))
6089 (gnus-group-change-level
6090 info (nth 2 info) gnus-level-killed
6091 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6093 (gnus-group-insert-group-line-info group))
6095 (gnus-group-position-point)
6096 (if (< (length out) 2) (car out) (nreverse out))))
6098 (defun gnus-group-kill-level (level)
6099 "Kill all groups that is on a certain LEVEL."
6100 (interactive "nKill all groups on level: ")
6102 ((= level gnus-level-zombie)
6103 (setq gnus-killed-list
6104 (nconc gnus-zombie-list gnus-killed-list))
6105 (setq gnus-zombie-list nil))
6106 ((and (< level gnus-level-zombie)
6108 (or gnus-expert-user
6111 "Do you really want to kill all groups on level %d? "
6113 (let* ((prev gnus-newsrc-alist)
6116 (if (= (gnus-info-level level) level)
6117 (setcdr prev (cdr alist))
6119 (setq alist (cdr alist)))
6120 (gnus-make-hashtable-from-newsrc-alist)
6121 (gnus-group-list-groups)))
6123 (error "Can't kill; illegal level: %d" level))))
6125 (defun gnus-group-list-all-groups (&optional arg)
6126 "List all newsgroups with level ARG or lower.
6127 Default is gnus-level-unsubscribed, which lists all subscribed and most
6128 unsubscribed groups."
6130 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6132 ;; Redefine this to list ALL killed groups if prefix arg used.
6133 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6134 (defun gnus-group-list-killed (&optional arg)
6135 "List all killed newsgroups in the group buffer.
6136 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6137 entail asking the server for the groups."
6139 ;; Find all possible killed newsgroups if arg.
6141 ;; First make sure active file has been read.
6142 (unless gnus-have-read-active-file
6143 (let ((gnus-read-active-file t))
6144 (gnus-read-active-file)))
6145 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6146 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6150 (group (symbol-name sym)))
6151 (if (or (null group)
6152 (gnus-gethash group gnus-killed-hashtb)
6153 (gnus-gethash group gnus-newsrc-hashtb))
6155 (let ((do-sub (gnus-matches-options-n group)))
6156 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6158 (setq groups (1+ groups))
6159 (setq gnus-killed-list
6160 (cons group gnus-killed-list))
6161 (gnus-sethash group group gnus-killed-hashtb))))))
6162 gnus-active-hashtb))
6163 (if (not gnus-killed-list)
6164 (gnus-message 6 "No killed groups")
6165 (let (gnus-group-list-mode)
6166 (funcall gnus-group-prepare-function
6167 gnus-level-killed t gnus-level-killed))
6168 (goto-char (point-min)))
6169 (gnus-group-position-point))
6171 (defun gnus-group-list-zombies ()
6172 "List all zombie newsgroups in the group buffer."
6174 (if (not gnus-zombie-list)
6175 (gnus-message 6 "No zombie groups")
6176 (let (gnus-group-list-mode)
6177 (funcall gnus-group-prepare-function
6178 gnus-level-zombie t gnus-level-zombie))
6179 (goto-char (point-min)))
6180 (gnus-group-position-point))
6182 (defun gnus-group-list-active ()
6183 "List all groups that are available from the server(s)."
6185 ;; First we make sure that we have really read the active file.
6186 (unless gnus-have-read-active-file
6187 (let ((gnus-read-active-file t))
6188 (gnus-read-active-file)))
6189 ;; Find all groups and sort them.
6195 (and (symbol-value sym)
6196 (setq list (cons (symbol-name sym) list))))
6200 (buffer-read-only nil))
6203 (gnus-group-insert-group-line-info (car groups))
6204 (setq groups (cdr groups)))
6205 (goto-char (point-min))))
6207 (defun gnus-activate-all-groups (level)
6208 "Activate absolutely all groups."
6209 (interactive (list 7))
6210 (let ((gnus-activate-level level)
6211 (gnus-activate-foreign-newsgroups level))
6212 (gnus-group-get-new-news)))
6214 (defun gnus-group-get-new-news (&optional arg)
6215 "Get newly arrived articles.
6216 If ARG is a number, it specifies which levels you are interested in
6217 re-scanning. If ARG is non-nil and not a number, this will force
6218 \"hard\" re-reading of the active files from all servers."
6220 (run-hooks 'gnus-get-new-news-hook)
6221 ;; We might read in new NoCeM messages here.
6222 (when (and gnus-use-nocem
6224 (gnus-nocem-scan-groups))
6225 ;; If ARG is not a number, then we read the active file.
6226 (when (and arg (not (numberp arg)))
6227 (let ((gnus-read-active-file t))
6228 (gnus-read-active-file))
6231 (setq arg (gnus-group-default-level arg t))
6232 (if (and gnus-read-active-file (not arg))
6234 (gnus-read-active-file)
6235 (gnus-get-unread-articles arg))
6236 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6237 (gnus-get-unread-articles arg)))
6238 (gnus-group-list-groups))
6240 (defun gnus-group-get-new-news-this-group (&optional n)
6241 "Check for newly arrived news in the current group (and the N-1 next groups).
6242 The difference between N and the number of newsgroup checked is returned.
6243 If N is negative, this group and the N-1 previous groups will be checked."
6245 (let* ((groups (gnus-group-process-prefix n))
6246 (ret (if (numberp n) (- n (length groups)) 0))
6249 (setq group (car groups)
6250 groups (cdr groups))
6251 (gnus-group-remove-mark group)
6252 (unless (gnus-get-new-news-in-group group)
6254 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6255 (when gnus-goto-next-group-when-activating
6256 (gnus-group-next-unread-group 1 t))
6257 (gnus-summary-position-point)
6260 (defun gnus-get-new-news-in-group (group)
6261 (when (and group (gnus-activate-group group 'scan))
6262 (gnus-get-unread-articles-in-group
6263 (gnus-get-info group) (gnus-active group) t)
6264 (when (gnus-group-goto-group group)
6265 (gnus-group-update-group-line))
6268 (defun gnus-group-fetch-faq (group &optional faq-dir)
6269 "Fetch the FAQ for the current group."
6272 (gnus-group-real-name (gnus-group-group-name))
6273 (cond (current-prefix-arg
6275 "Faq dir: " (and (listp gnus-group-faq-directory)
6276 gnus-group-faq-directory))))))
6278 (setq faq-dir (if (listp gnus-group-faq-directory)
6279 (car gnus-group-faq-directory)
6280 gnus-group-faq-directory)))
6281 (or group (error "No group name given"))
6282 (let ((file (concat (file-name-as-directory faq-dir)
6283 (gnus-group-real-name group))))
6284 (if (not (file-exists-p file))
6285 (error "No such file: %s" file)
6288 (defun gnus-group-describe-group (force &optional group)
6289 "Display a description of the current newsgroup."
6290 (interactive (list current-prefix-arg (gnus-group-group-name)))
6291 (and force (setq gnus-description-hashtb nil))
6292 (let ((method (gnus-find-method-for-group group))
6294 (or group (error "No group name given"))
6295 (and (or (and gnus-description-hashtb
6296 ;; We check whether this group's method has been
6297 ;; queried for a description file.
6299 (gnus-group-prefixed-name "" method)
6300 gnus-description-hashtb))
6301 (setq desc (gnus-group-get-description group))
6302 (gnus-read-descriptions-file method))
6304 (or desc (gnus-gethash group gnus-description-hashtb)
6305 "No description available")))))
6307 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6308 (defun gnus-group-describe-all-groups (&optional force)
6309 "Pop up a buffer with descriptions of all newsgroups."
6311 (and force (setq gnus-description-hashtb nil))
6312 (if (not (or gnus-description-hashtb
6313 (gnus-read-all-descriptions-files)))
6314 (error "Couldn't request descriptions file"))
6315 (let ((buffer-read-only nil)
6321 (insert (format " *: %-20s %s\n" (symbol-name group)
6322 (symbol-value group)))
6323 (add-text-properties
6324 b (1+ b) (list 'gnus-group group
6325 'gnus-unread t 'gnus-marked nil
6326 'gnus-level (1+ gnus-level-subscribed))))
6327 gnus-description-hashtb)
6328 (goto-char (point-min))
6329 (gnus-group-position-point)))
6331 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6332 (defun gnus-group-apropos (regexp &optional search-description)
6333 "List all newsgroups that have names that match a regexp."
6334 (interactive "sGnus apropos (regexp): ")
6336 (obuf (current-buffer))
6338 ;; Go through all newsgroups that are known to Gnus.
6341 (and (symbol-name group)
6342 (string-match regexp (symbol-name group))
6343 (setq groups (cons (symbol-name group) groups))))
6345 ;; Go through all descriptions that are known to Gnus.
6346 (if search-description
6349 (and (string-match regexp (symbol-value group))
6350 (gnus-active (symbol-name group))
6351 (setq groups (cons (symbol-name group) groups))))
6352 gnus-description-hashtb))
6354 (gnus-message 3 "No groups matched \"%s\"." regexp)
6355 ;; Print out all the groups.
6357 (pop-to-buffer "*Gnus Help*")
6358 (buffer-disable-undo (current-buffer))
6360 (setq groups (sort groups 'string<))
6362 ;; Groups may be entered twice into the list of groups.
6363 (if (not (string= (car groups) prev))
6365 (insert (setq prev (car groups)) "\n")
6366 (if (and gnus-description-hashtb
6367 (setq des (gnus-gethash (car groups)
6368 gnus-description-hashtb)))
6369 (insert " " des "\n"))))
6370 (setq groups (cdr groups)))
6371 (goto-char (point-min))))
6372 (pop-to-buffer obuf)))
6374 (defun gnus-group-description-apropos (regexp)
6375 "List all newsgroups that have names or descriptions that match a regexp."
6376 (interactive "sGnus description apropos (regexp): ")
6377 (if (not (or gnus-description-hashtb
6378 (gnus-read-all-descriptions-files)))
6379 (error "Couldn't request descriptions file"))
6380 (gnus-group-apropos regexp t))
6382 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6383 (defun gnus-group-list-matching (level regexp &optional all lowest)
6384 "List all groups with unread articles that match REGEXP.
6385 If the prefix LEVEL is non-nil, it should be a number that says which
6386 level to cut off listing groups.
6387 If ALL, also list groups with no unread articles.
6388 If LOWEST, don't list groups with level lower than LOWEST."
6389 (interactive "P\nsList newsgroups matching: ")
6390 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6391 all (or lowest 1) regexp)
6392 (goto-char (point-min))
6393 (gnus-group-position-point))
6395 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6396 "List all groups that match REGEXP.
6397 If the prefix LEVEL is non-nil, it should be a number that says which
6398 level to cut off listing groups.
6399 If LOWEST, don't list groups with level lower than LOWEST."
6400 (interactive "P\nsList newsgroups matching: ")
6401 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6403 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6404 (defun gnus-group-save-newsrc (&optional force)
6405 "Save the Gnus startup files.
6406 If FORCE, force saving whether it is necessary or not."
6408 (gnus-save-newsrc-file force))
6410 (defun gnus-group-restart (&optional arg)
6411 "Force Gnus to read the .newsrc file."
6413 (gnus-save-newsrc-file)
6414 (gnus-setup-news 'force)
6415 (gnus-group-list-groups arg))
6417 (defun gnus-group-read-init-file ()
6418 "Read the Gnus elisp init file."
6420 (gnus-read-init-file))
6422 (defun gnus-group-check-bogus-groups (&optional silent)
6423 "Check bogus newsgroups.
6424 If given a prefix, don't ask for confirmation before removing a bogus
6427 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6428 (gnus-group-list-groups))
6430 (defun gnus-group-edit-global-kill (&optional article group)
6431 "Edit the global kill file.
6432 If GROUP, edit that local kill file instead."
6434 (setq gnus-current-kill-article article)
6435 (gnus-kill-file-edit-file group)
6438 (substitute-command-keys
6439 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6440 (if group "local" "global")))))
6442 (defun gnus-group-edit-local-kill (article group)
6443 "Edit a local kill file."
6444 (interactive (list nil (gnus-group-group-name)))
6445 (gnus-group-edit-global-kill article group))
6447 (defun gnus-group-force-update ()
6448 "Update `.newsrc' file."
6450 (gnus-save-newsrc-file))
6452 (defun gnus-group-suspend ()
6453 "Suspend the current Gnus session.
6454 In fact, cleanup buffers except for group mode buffer.
6455 The hook gnus-suspend-gnus-hook is called before actually suspending."
6457 (run-hooks 'gnus-suspend-gnus-hook)
6458 ;; Kill Gnus buffers except for group mode buffer.
6459 (let ((group-buf (get-buffer gnus-group-buffer)))
6460 ;; Do this on a separate list in case the user does a ^G before we finish
6461 (let ((gnus-buffer-list
6462 (delq group-buf (delq gnus-dribble-buffer
6463 (append gnus-buffer-list nil)))))
6464 (while gnus-buffer-list
6465 (gnus-kill-buffer (car gnus-buffer-list))
6466 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6469 (setq gnus-buffer-list (list group-buf))
6470 (bury-buffer group-buf)
6471 (delete-windows-on group-buf t)))))
6473 (defun gnus-group-clear-dribble ()
6474 "Clear all information from the dribble buffer."
6476 (gnus-dribble-clear)
6477 (gnus-message 7 "Cleared dribble buffer"))
6479 (defun gnus-group-exit ()
6480 "Quit reading news after updating .newsrc.eld and .newsrc.
6481 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6484 (or noninteractive ;For gnus-batch-kill
6485 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6486 (not gnus-interactive-exit) ;Without confirmation
6488 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6489 (run-hooks 'gnus-exit-gnus-hook)
6490 ;; Close down GroupLens.
6491 (when gnus-use-grouplens
6493 ;; Offer to save data from non-quitted summary buffers.
6494 (gnus-offer-save-summaries)
6495 ;; Save the newsrc file(s).
6496 (gnus-save-newsrc-file)
6498 (gnus-close-backends)
6499 ;; Shut down the cache.
6500 (when gnus-use-cache
6502 ;; Reset everything.
6504 ;; Allow the user to do things after cleaning up.
6505 (run-hooks 'gnus-after-exiting-gnus-hook)))
6507 (defun gnus-close-backends ()
6508 ;; Send a close request to all backends that support such a request.
6509 (let ((methods gnus-valid-select-methods)
6512 (if (fboundp (setq func (intern (concat (car (car methods))
6513 "-request-close"))))
6515 (setq methods (cdr methods)))))
6517 (defun gnus-group-quit ()
6518 "Quit reading news without updating .newsrc.eld or .newsrc.
6519 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6521 (when (or noninteractive ;For gnus-batch-kill
6522 (zerop (buffer-size))
6523 (not (gnus-server-opened gnus-select-method))
6525 (not gnus-current-startup-file)
6527 (format "Quit reading news without saving %s? "
6528 (file-name-nondirectory gnus-current-startup-file))))
6529 (run-hooks 'gnus-exit-gnus-hook)
6530 (if gnus-use-full-window
6531 (delete-other-windows)
6532 (gnus-remove-some-windows))
6534 (gnus-close-backends)
6535 ;; Shut down the cache.
6536 (when gnus-use-cache
6539 ;; Allow the user to do things after cleaning up.
6540 (run-hooks 'gnus-after-exiting-gnus-hook)))
6542 (defun gnus-offer-save-summaries ()
6543 "Offer to save all active summary buffers."
6545 (let ((buflist (buffer-list))
6547 ;; Go through all buffers and find all summaries.
6549 (and (setq bufname (buffer-name (car buflist)))
6550 (string-match "Summary" bufname)
6552 (set-buffer bufname)
6553 ;; We check that this is, indeed, a summary buffer.
6554 (and (eq major-mode 'gnus-summary-mode)
6555 ;; Also make sure this isn't bogus.
6556 gnus-newsgroup-prepared))
6557 (push bufname buffers))
6558 (setq buflist (cdr buflist)))
6559 ;; Go through all these summary buffers and offer to save them.
6562 "Update summary buffer %s? "
6563 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6566 (defun gnus-group-describe-briefly ()
6567 "Give a one line description of the group mode commands."
6569 (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")))
6571 (defun gnus-group-browse-foreign-server (method)
6572 "Browse a foreign news server.
6573 If called interactively, this function will ask for a select method
6574 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6575 If not, METHOD should be a list where the first element is the method
6576 and the second element is the address."
6578 (list (let ((how (completing-read
6580 (append gnus-valid-select-methods gnus-server-alist)
6581 nil t (cons "nntp" 0))))
6582 ;; We either got a backend name or a virtual server name.
6583 ;; If the first, we also need an address.
6584 (if (assoc how gnus-valid-select-methods)
6586 ;; Suggested by mapjph@bath.ac.uk.
6589 (mapcar (lambda (server) (list server))
6590 gnus-secondary-servers)))
6591 ;; We got a server name, so we find the method.
6592 (gnus-server-to-method how)))))
6593 (gnus-browse-foreign-server method))
6597 ;;; Gnus summary mode
6600 (defvar gnus-summary-mode-map nil)
6602 (put 'gnus-summary-mode 'mode-class 'special)
6604 (unless gnus-summary-mode-map
6605 (setq gnus-summary-mode-map (make-keymap))
6606 (suppress-keymap gnus-summary-mode-map)
6608 ;; Non-orthogonal keys
6610 (gnus-define-keys gnus-summary-mode-map
6611 " " gnus-summary-next-page
6612 "\177" gnus-summary-prev-page
6613 [delete] gnus-summary-prev-page
6614 "\r" gnus-summary-scroll-up
6615 "n" gnus-summary-next-unread-article
6616 "p" gnus-summary-prev-unread-article
6617 "N" gnus-summary-next-article
6618 "P" gnus-summary-prev-article
6619 "\M-\C-n" gnus-summary-next-same-subject
6620 "\M-\C-p" gnus-summary-prev-same-subject
6621 "\M-n" gnus-summary-next-unread-subject
6622 "\M-p" gnus-summary-prev-unread-subject
6623 "." gnus-summary-first-unread-article
6624 "," gnus-summary-best-unread-article
6625 "\M-s" gnus-summary-search-article-forward
6626 "\M-r" gnus-summary-search-article-backward
6627 "<" gnus-summary-beginning-of-article
6628 ">" gnus-summary-end-of-article
6629 "j" gnus-summary-goto-article
6630 "^" gnus-summary-refer-parent-article
6631 "\M-^" gnus-summary-refer-article
6632 "u" gnus-summary-tick-article-forward
6633 "!" gnus-summary-tick-article-forward
6634 "U" gnus-summary-tick-article-backward
6635 "d" gnus-summary-mark-as-read-forward
6636 "D" gnus-summary-mark-as-read-backward
6637 "E" gnus-summary-mark-as-expirable
6638 "\M-u" gnus-summary-clear-mark-forward
6639 "\M-U" gnus-summary-clear-mark-backward
6640 "k" gnus-summary-kill-same-subject-and-select
6641 "\C-k" gnus-summary-kill-same-subject
6642 "\M-\C-k" gnus-summary-kill-thread
6643 "\M-\C-l" gnus-summary-lower-thread
6644 "e" gnus-summary-edit-article
6645 "#" gnus-summary-mark-as-processable
6646 "\M-#" gnus-summary-unmark-as-processable
6647 "\M-\C-t" gnus-summary-toggle-threads
6648 "\M-\C-s" gnus-summary-show-thread
6649 "\M-\C-h" gnus-summary-hide-thread
6650 "\M-\C-f" gnus-summary-next-thread
6651 "\M-\C-b" gnus-summary-prev-thread
6652 "\M-\C-u" gnus-summary-up-thread
6653 "\M-\C-d" gnus-summary-down-thread
6654 "&" gnus-summary-execute-command
6655 "c" gnus-summary-catchup-and-exit
6656 "\C-w" gnus-summary-mark-region-as-read
6657 "\C-t" gnus-summary-toggle-truncation
6658 "?" gnus-summary-mark-as-dormant
6659 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6660 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6661 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6662 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6663 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6664 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6665 "=" gnus-summary-expand-window
6666 "\C-x\C-s" gnus-summary-reselect-current-group
6667 "\M-g" gnus-summary-rescan-group
6668 "w" gnus-summary-stop-page-breaking
6669 "\C-c\C-r" gnus-summary-caesar-message
6670 "\M-t" gnus-summary-toggle-mime
6671 "f" gnus-summary-followup
6672 "F" gnus-summary-followup-with-original
6673 "C" gnus-summary-cancel-article
6674 "r" gnus-summary-reply
6675 "R" gnus-summary-reply-with-original
6676 "\C-c\C-f" gnus-summary-mail-forward
6677 "o" gnus-summary-save-article
6678 "\C-o" gnus-summary-save-article-mail
6679 "|" gnus-summary-pipe-output
6680 "\M-k" gnus-summary-edit-local-kill
6681 "\M-K" gnus-summary-edit-global-kill
6683 "\C-c\C-d" gnus-summary-describe-group
6684 "q" gnus-summary-exit
6685 "Q" gnus-summary-exit-no-update
6686 "\C-c\C-i" gnus-info-find-node
6687 gnus-mouse-2 gnus-mouse-pick-article
6688 "m" gnus-summary-mail-other-window
6689 "a" gnus-summary-post-news
6690 "x" gnus-summary-limit-to-unread
6691 "s" gnus-summary-isearch-article
6692 "t" gnus-article-hide-headers
6693 "g" gnus-summary-show-article
6694 "l" gnus-summary-goto-last-article
6695 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6696 "\C-d" gnus-summary-enter-digest-group
6698 "*" gnus-cache-enter-article
6699 "\M-*" gnus-cache-remove-article
6700 "\M-&" gnus-summary-universal-argument
6701 "\C-l" gnus-recenter
6702 "I" gnus-summary-increase-score
6703 "L" gnus-summary-lower-score
6705 "V" gnus-summary-score-map
6706 "X" gnus-uu-extract-map
6707 "S" gnus-summary-send-map)
6709 ;; Sort of orthogonal keymap
6710 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6711 "t" gnus-summary-tick-article-forward
6712 "!" gnus-summary-tick-article-forward
6713 "d" gnus-summary-mark-as-read-forward
6714 "r" gnus-summary-mark-as-read-forward
6715 "c" gnus-summary-clear-mark-forward
6716 " " gnus-summary-clear-mark-forward
6717 "e" gnus-summary-mark-as-expirable
6718 "x" gnus-summary-mark-as-expirable
6719 "?" gnus-summary-mark-as-dormant
6720 "b" gnus-summary-set-bookmark
6721 "B" gnus-summary-remove-bookmark
6722 "#" gnus-summary-mark-as-processable
6723 "\M-#" gnus-summary-unmark-as-processable
6724 "S" gnus-summary-limit-include-expunged
6725 "C" gnus-summary-catchup
6726 "H" gnus-summary-catchup-to-here
6727 "\C-c" gnus-summary-catchup-all
6728 "k" gnus-summary-kill-same-subject-and-select
6729 "K" gnus-summary-kill-same-subject
6730 "P" gnus-uu-mark-map)
6732 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6733 "c" gnus-summary-clear-above
6734 "u" gnus-summary-tick-above
6735 "m" gnus-summary-mark-above
6736 "k" gnus-summary-kill-below)
6738 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6739 "/" gnus-summary-limit-to-subject
6740 "n" gnus-summary-limit-to-articles
6741 "w" gnus-summary-pop-limit
6742 "s" gnus-summary-limit-to-subject
6743 "a" gnus-summary-limit-to-author
6744 "u" gnus-summary-limit-to-unread
6745 "m" gnus-summary-limit-to-marks
6746 "v" gnus-summary-limit-to-score
6747 "D" gnus-summary-limit-include-dormant
6748 "d" gnus-summary-limit-exclude-dormant
6749 ;; "t" gnus-summary-limit-exclude-thread
6750 "E" gnus-summary-limit-include-expunged
6751 "c" gnus-summary-limit-exclude-childless-dormant
6752 "C" gnus-summary-limit-mark-excluded-as-read)
6754 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6755 "n" gnus-summary-next-unread-article
6756 "p" gnus-summary-prev-unread-article
6757 "N" gnus-summary-next-article
6758 "P" gnus-summary-prev-article
6759 "\C-n" gnus-summary-next-same-subject
6760 "\C-p" gnus-summary-prev-same-subject
6761 "\M-n" gnus-summary-next-unread-subject
6762 "\M-p" gnus-summary-prev-unread-subject
6763 "f" gnus-summary-first-unread-article
6764 "b" gnus-summary-best-unread-article
6765 "g" gnus-summary-goto-subject
6766 "l" gnus-summary-goto-last-article
6767 "p" gnus-summary-pop-article)
6769 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6770 "k" gnus-summary-kill-thread
6771 "l" gnus-summary-lower-thread
6772 "i" gnus-summary-raise-thread
6773 "T" gnus-summary-toggle-threads
6774 "t" gnus-summary-rethread-current
6775 "^" gnus-summary-reparent-thread
6776 "s" gnus-summary-show-thread
6777 "S" gnus-summary-show-all-threads
6778 "h" gnus-summary-hide-thread
6779 "H" gnus-summary-hide-all-threads
6780 "n" gnus-summary-next-thread
6781 "p" gnus-summary-prev-thread
6782 "u" gnus-summary-up-thread
6783 "o" gnus-summary-top-thread
6784 "d" gnus-summary-down-thread
6785 "#" gnus-uu-mark-thread
6786 "\M-#" gnus-uu-unmark-thread)
6788 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6789 "c" gnus-summary-catchup-and-exit
6790 "C" gnus-summary-catchup-all-and-exit
6791 "E" gnus-summary-exit-no-update
6792 "Q" gnus-summary-exit
6793 "Z" gnus-summary-exit
6794 "n" gnus-summary-catchup-and-goto-next-group
6795 "R" gnus-summary-reselect-current-group
6796 "G" gnus-summary-rescan-group
6797 "N" gnus-summary-next-group
6798 "P" gnus-summary-prev-group)
6800 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6801 " " gnus-summary-next-page
6802 "n" gnus-summary-next-page
6803 "\177" gnus-summary-prev-page
6804 [delete] gnus-summary-prev-page
6805 "p" gnus-summary-prev-page
6806 "\r" gnus-summary-scroll-up
6807 "<" gnus-summary-beginning-of-article
6808 ">" gnus-summary-end-of-article
6809 "b" gnus-summary-beginning-of-article
6810 "e" gnus-summary-end-of-article
6811 "^" gnus-summary-refer-parent-article
6812 "r" gnus-summary-refer-parent-article
6813 "R" gnus-summary-refer-references
6814 "g" gnus-summary-show-article
6815 "s" gnus-summary-isearch-article)
6817 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6818 "b" gnus-article-add-buttons
6819 "B" gnus-article-add-buttons-to-head
6820 "o" gnus-article-treat-overstrike
6821 ;; "w" gnus-article-word-wrap
6822 "w" gnus-article-fill-cited-article
6823 "c" gnus-article-remove-cr
6824 "L" gnus-article-remove-trailing-blank-lines
6825 "q" gnus-article-de-quoted-unreadable
6826 "f" gnus-article-display-x-face
6827 "l" gnus-summary-stop-page-breaking
6828 "r" gnus-summary-caesar-message
6829 "t" gnus-article-hide-headers
6830 "v" gnus-summary-verbose-headers
6831 "m" gnus-summary-toggle-mime)
6833 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6834 "a" gnus-article-hide
6835 "h" gnus-article-hide-headers
6836 "b" gnus-article-hide-boring-headers
6837 "s" gnus-article-hide-signature
6838 "c" gnus-article-hide-citation
6839 "p" gnus-article-hide-pgp
6840 "\C-c" gnus-article-hide-citation-maybe)
6842 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6843 "a" gnus-article-highlight
6844 "h" gnus-article-highlight-headers
6845 "c" gnus-article-highlight-citation
6846 "s" gnus-article-highlight-signature)
6848 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6849 "z" gnus-article-date-ut
6850 "u" gnus-article-date-ut
6851 "l" gnus-article-date-local
6852 "e" gnus-article-date-lapsed
6853 "o" gnus-article-date-original)
6855 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6857 "f" gnus-summary-fetch-faq
6858 "d" gnus-summary-describe-group
6859 "h" gnus-summary-describe-briefly
6860 "i" gnus-info-find-node)
6862 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6863 "e" gnus-summary-expire-articles
6864 "\M-\C-e" gnus-summary-expire-articles-now
6865 "\177" gnus-summary-delete-article
6866 [delete] gnus-summary-delete-article
6867 "m" gnus-summary-move-article
6868 "r" gnus-summary-respool-article
6869 "w" gnus-summary-edit-article
6870 "c" gnus-summary-copy-article
6871 "B" gnus-summary-crosspost-article
6872 "q" gnus-summary-respool-query
6873 "i" gnus-summary-import-article)
6875 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6876 "o" gnus-summary-save-article
6877 "m" gnus-summary-save-article-mail
6878 "r" gnus-summary-save-article-rmail
6879 "f" gnus-summary-save-article-file
6880 "b" gnus-summary-save-article-body-file
6881 "h" gnus-summary-save-article-folder
6882 "v" gnus-summary-save-article-vm
6883 "p" gnus-summary-pipe-output
6884 "s" gnus-soup-add-article)
6889 (defun gnus-summary-mode (&optional group)
6890 "Major mode for reading articles.
6892 All normal editing commands are switched off.
6893 \\<gnus-summary-mode-map>
6894 Each line in this buffer represents one article. To read an
6895 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6896 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6899 You can also post articles and send mail from this buffer. To
6900 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6901 of an article, type `\\[gnus-summary-reply]'.
6903 There are approx. one gazillion commands you can execute in this
6904 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6906 The following commands are available:
6908 \\{gnus-summary-mode-map}"
6910 (when (and menu-bar-mode
6911 (gnus-visual-p 'summary-menu 'menu))
6912 (gnus-summary-make-menu-bar))
6913 (kill-all-local-variables)
6914 (let ((locals gnus-summary-local-variables))
6916 (if (consp (car locals))
6918 (make-local-variable (car (car locals)))
6919 (set (car (car locals)) (eval (cdr (car locals)))))
6920 (make-local-variable (car locals))
6921 (set (car locals) nil))
6922 (setq locals (cdr locals))))
6923 (gnus-make-thread-indent-array)
6924 (gnus-simplify-mode-line)
6925 (setq major-mode 'gnus-summary-mode)
6926 (setq mode-name "Summary")
6927 (make-local-variable 'minor-mode-alist)
6928 (use-local-map gnus-summary-mode-map)
6929 (buffer-disable-undo (current-buffer))
6930 (setq buffer-read-only t) ;Disable modification
6931 (setq truncate-lines t)
6932 (setq selective-display t)
6933 (setq selective-display-ellipses t) ;Display `...'
6934 (setq buffer-display-table gnus-summary-display-table)
6935 (setq gnus-newsgroup-name group)
6936 (run-hooks 'gnus-summary-mode-hook))
6938 (defun gnus-summary-make-display-table ()
6939 ;; Change the display table. Odd characters have a tendency to mess
6940 ;; up nicely formatted displays - we make all possible glyphs
6941 ;; display only a single character.
6943 ;; We start from the standard display table, if any.
6944 (setq gnus-summary-display-table
6945 (or (copy-sequence standard-display-table)
6946 (make-display-table)))
6947 ;; Nix out all the control chars...
6949 (while (>= (setq i (1- i)) 0)
6950 (aset gnus-summary-display-table i [??])))
6951 ;; ... but not newline and cr, of course. (cr is necessary for the
6952 ;; selective display).
6953 (aset gnus-summary-display-table ?\n nil)
6954 (aset gnus-summary-display-table ?\r nil)
6955 ;; We nix out any glyphs over 126 that are not set already.
6957 (while (>= (setq i (1- i)) 127)
6958 ;; Only modify if the entry is nil.
6959 (or (aref gnus-summary-display-table i)
6960 (aset gnus-summary-display-table i [??])))))
6962 (defun gnus-summary-clear-local-variables ()
6963 (let ((locals gnus-summary-local-variables))
6965 (if (consp (car locals))
6966 (and (vectorp (car (car locals)))
6967 (set (car (car locals)) nil))
6968 (and (vectorp (car locals))
6969 (set (car locals) nil)))
6970 (setq locals (cdr locals)))))
6972 ;; Summary data functions.
6974 (defmacro gnus-data-number (data)
6977 (defmacro gnus-data-set-number (data number)
6978 `(setcar ,data ,number))
6980 (defmacro gnus-data-mark (data)
6983 (defmacro gnus-data-set-mark (data mark)
6984 `(setcar (nthcdr 1 ,data) ,mark))
6986 (defmacro gnus-data-pos (data)
6989 (defmacro gnus-data-set-pos (data pos)
6990 `(setcar (nthcdr 2 ,data) ,pos))
6992 (defmacro gnus-data-header (data)
6995 (defmacro gnus-data-level (data)
6998 (defmacro gnus-data-unread-p (data)
6999 `(= (nth 1 ,data) gnus-unread-mark))
7001 (defmacro gnus-data-pseudo-p (data)
7002 `(consp (nth 3 ,data)))
7004 (defmacro gnus-data-find (number)
7005 `(assq ,number gnus-newsgroup-data))
7007 (defmacro gnus-data-find-list (number &optional data)
7008 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7009 (memq (assq ,number bdata)
7012 (defmacro gnus-data-make (number mark pos header level)
7013 `(list ,number ,mark ,pos ,header ,level))
7015 (defun gnus-data-enter (after-article number mark pos header level offset)
7016 (let ((data (gnus-data-find-list after-article)))
7017 (or data (error "No such article: %d" after-article))
7018 (setcdr data (cons (gnus-data-make number mark pos header level)
7020 (setq gnus-newsgroup-data-reverse nil)
7021 (gnus-data-update-list (cdr (cdr data)) offset)))
7023 (defun gnus-data-enter-list (after-article list &optional offset)
7025 (let ((data (and after-article (gnus-data-find-list after-article)))
7027 (or data (not after-article) (error "No such article: %d" after-article))
7028 ;; Find the last element in the list to be spliced into the main
7031 (setq list (cdr list)))
7034 (setcdr list gnus-newsgroup-data)
7035 (setq gnus-newsgroup-data ilist)
7036 (and offset (gnus-data-update-list (cdr list) offset)))
7037 (setcdr list (cdr data))
7039 (and offset (gnus-data-update-list (cdr data) offset)))
7040 (setq gnus-newsgroup-data-reverse nil))))
7042 (defun gnus-data-remove (article &optional offset)
7043 (let ((data gnus-newsgroup-data))
7044 (if (= (gnus-data-number (car data)) article)
7045 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7046 gnus-newsgroup-data-reverse nil)
7048 (and (= (gnus-data-number (car (cdr data))) article)
7050 (setcdr data (cdr (cdr data)))
7051 (and offset (gnus-data-update-list (cdr data) offset))
7053 gnus-newsgroup-data-reverse nil)))
7054 (setq data (cdr data))))))
7056 (defmacro gnus-data-list (backward)
7058 (or gnus-newsgroup-data-reverse
7059 (setq gnus-newsgroup-data-reverse
7060 (reverse gnus-newsgroup-data)))
7061 gnus-newsgroup-data))
7063 (defun gnus-data-update-list (data offset)
7064 "Add OFFSET to the POS of all data entries in DATA."
7066 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7067 (setq data (cdr data))))
7069 (defun gnus-data-compute-positions ()
7070 "Compute the positions of all articles."
7071 (let ((data gnus-newsgroup-data)
7074 (when (setq pos (text-property-any
7075 (point-min) (point-max)
7076 'gnus-number (gnus-data-number (car data))))
7077 (gnus-data-set-pos (car data) (+ pos 3)))
7078 (setq data (cdr data)))))
7080 (defun gnus-summary-article-pseudo-p (article)
7081 "Say whether this article is a pseudo article or not."
7082 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7084 (defun gnus-article-parent-p (number)
7085 "Say whether this article is a parent or not."
7086 (let ((data (gnus-data-find-list number)))
7087 (and (cdr data) ; There has to be an article after...
7088 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7089 (gnus-data-level (nth 1 data))))))
7091 (defun gnus-article-children (number)
7092 "Return a list of all children to NUMBER."
7093 (let* ((data (gnus-data-find-list number))
7094 (level (gnus-data-level (car data)))
7096 (setq data (cdr data))
7098 (= (gnus-data-level (car data)) (1+ level)))
7099 (push (gnus-data-number (car data)) children)
7100 (setq data (cdr data)))
7103 (defmacro gnus-summary-skip-intangible ()
7104 "If the current article is intangible, then jump to a different article."
7105 '(let ((to (get-text-property (point) 'gnus-intangible)))
7106 (and to (gnus-summary-goto-subject to))))
7108 (defmacro gnus-summary-article-intangible-p ()
7109 "Say whether this article is intangible or not."
7110 '(get-text-property (point) 'gnus-intangible))
7112 ;; Some summary mode macros.
7114 (defmacro gnus-summary-article-number ()
7115 "The article number of the article on the current line.
7116 If there isn's an article number here, then we return the current
7119 (gnus-summary-skip-intangible)
7120 (or (get-text-property (point) 'gnus-number)
7121 (gnus-summary-last-subject))))
7123 (defmacro gnus-summary-article-header (&optional number)
7124 `(gnus-data-header (gnus-data-find
7125 ,(or number '(gnus-summary-article-number)))))
7127 (defmacro gnus-summary-thread-level (&optional number)
7128 `(if (and (eq gnus-summary-make-false-root 'dummy)
7129 (get-text-property (point) 'gnus-intangible))
7131 (gnus-data-level (gnus-data-find
7132 ,(or number '(gnus-summary-article-number))))))
7134 (defmacro gnus-summary-article-mark (&optional number)
7135 `(gnus-data-mark (gnus-data-find
7136 ,(or number '(gnus-summary-article-number)))))
7138 (defmacro gnus-summary-article-pos (&optional number)
7139 `(gnus-data-pos (gnus-data-find
7140 ,(or number '(gnus-summary-article-number)))))
7142 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7143 (defmacro gnus-summary-article-subject (&optional number)
7144 "Return current subject string or nil if nothing."
7147 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7148 '(gnus-data-header (assq (gnus-summary-article-number)
7149 gnus-newsgroup-data)))))
7152 (mail-header-subject headers))))
7154 (defmacro gnus-summary-article-score (&optional number)
7155 "Return current article score."
7156 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7157 gnus-newsgroup-scored))
7158 gnus-summary-default-score 0))
7160 (defun gnus-summary-article-children (&optional number)
7161 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7162 (level (gnus-data-level (car data)))
7164 (while (and (setq data (cdr data))
7165 (> (setq l (gnus-data-level (car data))) level))
7166 (and (= (1+ level) l)
7167 (setq children (cons (gnus-data-number (car data))
7169 (nreverse children)))
7171 (defun gnus-summary-article-parent (&optional number)
7172 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7173 (gnus-data-list t)))
7174 (level (gnus-data-level (car data)))
7177 () ; This is a root.
7178 ;; We search until we find an article with a level less than
7179 ;; this one. That function has to be the parent.
7180 (while (and (setq data (cdr data))
7181 (not (< (gnus-data-level (car data)) level))))
7182 (and data (gnus-data-number (car data))))))
7184 (defun gnus-unread-mark-p (mark)
7185 "Say whether MARK is the unread mark."
7186 (= mark gnus-unread-mark))
7188 (defun gnus-read-mark-p (mark)
7189 "Say whether MARK is one of the marks that mark as read.
7190 This is all marks except unread, ticked, dormant, and expirable."
7191 (not (or (= mark gnus-unread-mark)
7192 (= mark gnus-ticked-mark)
7193 (= mark gnus-dormant-mark)
7194 (= mark gnus-expirable-mark))))
7196 ;; Various summary mode internalish functions.
7198 (defun gnus-mouse-pick-article (e)
7201 (gnus-summary-next-page nil t))
7203 (defun gnus-summary-setup-buffer (group)
7204 "Initialize summary buffer."
7205 (let ((buffer (concat "*Summary " group "*")))
7206 (if (get-buffer buffer)
7209 (setq gnus-summary-buffer (current-buffer))
7210 (not gnus-newsgroup-prepared))
7211 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7212 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7213 (gnus-add-current-to-buffer-list)
7214 (gnus-summary-mode group)
7216 (gnus-carpal-setup-buffer 'summary))
7217 (unless gnus-single-article-buffer
7218 (make-local-variable 'gnus-article-buffer)
7219 (make-local-variable 'gnus-original-article-buffer))
7220 (setq gnus-newsgroup-name group)
7223 (defun gnus-set-global-variables ()
7224 ;; Set the global equivalents of the summary buffer-local variables
7225 ;; to the latest values they had. These reflect the summary buffer
7226 ;; that was in action when the last article was fetched.
7227 (when (eq major-mode 'gnus-summary-mode)
7228 (setq gnus-summary-buffer (current-buffer))
7229 (let ((name gnus-newsgroup-name)
7230 (marked gnus-newsgroup-marked)
7231 (unread gnus-newsgroup-unreads)
7232 (headers gnus-current-headers)
7233 (data gnus-newsgroup-data)
7234 (article-buffer gnus-article-buffer)
7235 (original gnus-original-article-buffer)
7236 (score-file gnus-current-score-file))
7238 (set-buffer gnus-group-buffer)
7239 (setq gnus-newsgroup-name name)
7240 (setq gnus-newsgroup-marked marked)
7241 (setq gnus-newsgroup-unreads unread)
7242 (setq gnus-current-headers headers)
7243 (setq gnus-newsgroup-data data)
7244 (setq gnus-article-buffer article-buffer)
7245 (setq gnus-original-article-buffer original)
7246 (setq gnus-current-score-file score-file)))))
7248 (defun gnus-summary-last-article-p (&optional article)
7249 "Return whether ARTICLE is the last article in the buffer."
7250 (if (not (setq article (or article (gnus-summary-article-number))))
7251 t ; All non-existant numbers are the last article. :-)
7252 (cdr (gnus-data-find-list article))))
7254 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7255 "Insert a dummy root in the summary buffer."
7257 (add-text-properties
7258 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7259 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7261 (defvar gnus-thread-indent-array nil)
7262 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7263 (defun gnus-make-thread-indent-array ()
7265 (if (and gnus-thread-indent-array
7266 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7268 (setq gnus-thread-indent-array (make-vector 201 "")
7269 gnus-thread-indent-array-level gnus-thread-indent-level)
7271 (aset gnus-thread-indent-array n
7272 (make-string (* n gnus-thread-indent-level) ? ))
7275 (defun gnus-summary-insert-line
7276 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7277 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7278 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7279 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7280 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7281 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7282 (gnus-tmp-score-char
7283 (if (or (null gnus-summary-default-score)
7284 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7285 gnus-summary-zcore-fuzz)) ?
7286 (if (< gnus-tmp-score gnus-summary-default-score)
7287 gnus-score-below-mark gnus-score-over-mark)))
7288 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7289 ((memq gnus-tmp-current gnus-newsgroup-cached)
7291 (gnus-tmp-replied gnus-replied-mark)
7292 ((memq gnus-tmp-current gnus-newsgroup-saved)
7294 (t gnus-unread-mark)))
7295 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7298 ((string-match "(.+)" gnus-tmp-from)
7299 (substring gnus-tmp-from
7300 (1+ (match-beginning 0)) (1- (match-end 0))))
7301 ((string-match "<[^>]+> *$" gnus-tmp-from)
7302 (let ((beg (match-beginning 0)))
7303 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7304 (substring gnus-tmp-from (1+ (match-beginning 0))
7305 (1- (match-end 0))))
7306 (substring gnus-tmp-from 0 beg))))
7308 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7309 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7310 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7311 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7312 (buffer-read-only nil))
7313 (when (string= gnus-tmp-name "")
7314 (setq gnus-tmp-name gnus-tmp-from))
7315 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7318 (progn (eval gnus-summary-line-format-spec) (point))
7319 'gnus-number gnus-tmp-number)
7320 (when (gnus-visual-p 'summary-highlight 'highlight)
7322 (run-hooks 'gnus-summary-update-hook)
7325 (defun gnus-summary-update-line (&optional dont-update)
7326 ;; Update summary line after change.
7327 (when (and gnus-summary-default-score
7328 (not gnus-summary-inhibit-highlight))
7329 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7330 (article (gnus-summary-article-number))
7331 (score (gnus-summary-article-score article)))
7333 (if (and gnus-summary-mark-below
7334 (< (gnus-summary-article-score)
7335 gnus-summary-mark-below))
7336 ;; This article has a low score, so we mark it as read.
7337 (when (memq article gnus-newsgroup-unreads)
7338 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7339 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7340 ;; This article was previously marked as read on account
7341 ;; of a low score, but now it has risen, so we mark it as
7343 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7344 (gnus-summary-update-mark
7345 (if (or (null gnus-summary-default-score)
7346 (<= (abs (- score gnus-summary-default-score))
7347 gnus-summary-zcore-fuzz)) ?
7348 (if (< score gnus-summary-default-score)
7349 gnus-score-below-mark gnus-score-over-mark)) 'score))
7350 ;; Do visual highlighting.
7351 (when (gnus-visual-p 'summary-highlight 'highlight)
7352 (run-hooks 'gnus-summary-update-hook)))))
7354 (defvar gnus-tmp-new-adopts nil)
7356 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7357 ;; Sum up all elements (and sub-elements) in a list.
7359 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7361 ((and (consp thread) (cdr thread))
7364 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7367 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7370 (when (and level (zerop level) gnus-tmp-new-adopts)
7373 'gnus-summary-number-of-articles-in-thread
7374 gnus-tmp-new-adopts))))
7376 (if (> number 1) gnus-not-empty-thread-mark
7377 gnus-empty-thread-mark)
7380 (defun gnus-summary-set-local-parameters (group)
7381 "Go through the local params of GROUP and set all variable specs in that list."
7382 (let ((params (gnus-info-params (gnus-get-info group)))
7385 (setq elem (car params)
7386 params (cdr params))
7387 (and (consp elem) ; Has to be a cons.
7388 (consp (cdr elem)) ; The cdr has to be a list.
7389 (symbolp (car elem)) ; Has to be a symbol in there.
7390 (not (memq (car elem)
7391 '(quit-config to-address to-list to-group)))
7392 (progn ; So we set it.
7393 (make-local-variable (car elem))
7394 (set (car elem) (eval (nth 1 elem))))))))
7396 (defun gnus-summary-read-group
7397 (group &optional show-all no-article kill-buffer no-display)
7398 "Start reading news in newsgroup GROUP.
7399 If SHOW-ALL is non-nil, already read articles are also listed.
7400 If NO-ARTICLE is non-nil, no article is selected initially.
7401 If NO-DISPLAY, don't generate a summary buffer."
7402 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7403 (let* ((new-group (gnus-summary-setup-buffer group))
7404 (quit-config (gnus-group-quit-config group))
7405 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7407 ;; This summary buffer exists already, so we just select it.
7409 (gnus-set-global-variables)
7411 (gnus-kill-or-deaden-summary kill-buffer))
7412 (gnus-configure-windows 'summary 'force)
7413 (gnus-set-mode-line 'summary)
7414 (gnus-summary-position-point)
7417 ;; We couldn't select this group.
7419 (when (and (eq major-mode 'gnus-summary-mode)
7420 (not (equal (current-buffer) kill-buffer)))
7421 (kill-buffer (current-buffer))
7422 (if (not quit-config)
7424 (set-buffer gnus-group-buffer)
7425 (gnus-group-jump-to-group group)
7426 (gnus-group-next-unread-group 1))
7427 (if (not (buffer-name (car quit-config)))
7428 (gnus-configure-windows 'group 'force)
7429 (set-buffer (car quit-config))
7430 (and (eq major-mode 'gnus-summary-mode)
7431 (gnus-set-global-variables))
7432 (gnus-configure-windows (cdr quit-config)))))
7433 (gnus-message 3 "Can't select group")
7435 ;; The user did a `C-g' while prompting for number of articles,
7436 ;; so we exit this group.
7437 ((eq did-select 'quit)
7438 (and (eq major-mode 'gnus-summary-mode)
7439 (not (equal (current-buffer) kill-buffer))
7440 (kill-buffer (current-buffer)))
7442 (gnus-kill-or-deaden-summary kill-buffer))
7443 (if (not quit-config)
7445 (set-buffer gnus-group-buffer)
7446 (gnus-group-jump-to-group group)
7447 (gnus-group-next-unread-group 1)
7448 (gnus-configure-windows 'group 'force))
7449 (if (not (buffer-name (car quit-config)))
7450 (gnus-configure-windows 'group 'force)
7451 (set-buffer (car quit-config))
7452 (and (eq major-mode 'gnus-summary-mode)
7453 (gnus-set-global-variables))
7454 (gnus-configure-windows (cdr quit-config))))
7455 ;; Finally signal the quit.
7457 ;; The group was successfully selected.
7459 (gnus-set-global-variables)
7460 ;; Save the active value in effect when the group was entered.
7461 (setq gnus-newsgroup-active
7463 (gnus-active gnus-newsgroup-name)))
7464 ;; You can change the summary buffer in some way with this hook.
7465 (run-hooks 'gnus-select-group-hook)
7466 ;; Set any local variables in the group parameters.
7467 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7468 (gnus-update-format-specifications)
7469 ;; Do score processing.
7470 (when gnus-use-scoring
7471 (gnus-possibly-score-headers))
7472 ;; Check whether to fill in the gaps in the threads.
7473 (when gnus-build-sparse-threads
7474 (gnus-build-sparse-threads))
7475 ;; Find the initial limit.
7477 (let ((gnus-newsgroup-dormant nil))
7478 (gnus-summary-initial-limit show-all))
7479 (gnus-summary-initial-limit show-all))
7480 ;; Generate the summary buffer.
7482 (gnus-summary-prepare))
7483 (when gnus-use-trees
7484 (gnus-tree-open group)
7485 (setq gnus-summary-highlight-line-function
7486 'gnus-tree-highlight-article))
7487 ;; If the summary buffer is empty, but there are some low-scored
7488 ;; articles or some excluded dormants, we include these in the
7490 (when (and (zerop (buffer-size))
7492 (cond (gnus-newsgroup-dormant
7493 (gnus-summary-limit-include-dormant))
7494 ((and gnus-newsgroup-scored show-all)
7495 (gnus-summary-limit-include-expunged))))
7496 ;; Function `gnus-apply-kill-file' must be called in this hook.
7497 (run-hooks 'gnus-apply-kill-hook)
7498 (if (and (zerop (buffer-size))
7501 ;; This newsgroup is empty.
7502 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7503 (gnus-message 6 "No unread news")
7505 (gnus-kill-or-deaden-summary kill-buffer))
7506 ;; Return nil from this function.
7508 ;; Hide conversation thread subtrees. We cannot do this in
7509 ;; gnus-summary-prepare-hook since kill processing may not
7510 ;; work with hidden articles.
7511 (and gnus-show-threads
7512 gnus-thread-hide-subtree
7513 (gnus-summary-hide-all-threads))
7514 ;; Show first unread article if requested.
7515 (if (and (not no-article)
7517 gnus-newsgroup-unreads
7518 gnus-auto-select-first)
7519 (if (eq gnus-auto-select-first 'best)
7520 (gnus-summary-best-unread-article)
7521 (gnus-summary-first-unread-article))
7522 ;; Don't select any articles, just move point to the first
7523 ;; article in the group.
7524 (goto-char (point-min))
7525 (gnus-summary-position-point)
7526 (gnus-set-mode-line 'summary)
7527 (gnus-configure-windows 'summary 'force))
7528 ;; If we are in async mode, we send some info to the backend.
7529 (when gnus-newsgroup-async
7530 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7532 (gnus-kill-or-deaden-summary kill-buffer))
7533 (when (get-buffer-window gnus-group-buffer t)
7534 ;; Gotta use windows, because recenter does wierd stuff if
7535 ;; the current buffer ain't the displayed window.
7536 (let ((owin (selected-window)))
7537 (select-window (get-buffer-window gnus-group-buffer t))
7538 (when (gnus-group-goto-group group)
7540 (select-window owin))))
7541 ;; Mark this buffer as "prepared".
7542 (setq gnus-newsgroup-prepared t)
7545 (defun gnus-summary-prepare ()
7546 "Generate the summary buffer."
7547 (let ((buffer-read-only nil))
7549 (setq gnus-newsgroup-data nil
7550 gnus-newsgroup-data-reverse nil)
7551 (run-hooks 'gnus-summary-generate-hook)
7552 ;; Generate the buffer, either with threads or without.
7553 (when gnus-newsgroup-headers
7554 (gnus-summary-prepare-threads
7555 (if gnus-show-threads
7556 (gnus-sort-gathered-threads
7557 (funcall gnus-summary-thread-gathering-function
7559 (gnus-cut-threads (gnus-make-threads)))))
7560 ;; Unthreaded display.
7561 (gnus-sort-articles gnus-newsgroup-headers))))
7562 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7563 ;; Call hooks for modifying summary buffer.
7564 (goto-char (point-min))
7565 (run-hooks 'gnus-summary-prepare-hook)))
7567 (defun gnus-gather-threads-by-subject (threads)
7568 "Gather threads by looking at Subject headers."
7569 (if (not gnus-summary-make-false-root)
7571 (let ((hashtb (gnus-make-hashtable 1023))
7574 subject hthread whole-subject)
7576 (setq whole-subject (mail-header-subject (car (car threads))))
7577 (if (and gnus-summary-gather-exclude-subject
7578 (string-match gnus-summary-gather-exclude-subject
7580 () ; We don't want to do anything with this article.
7581 ;; We simplify the subject before looking it up in the
7585 ;; Truncate the subject.
7586 ((numberp gnus-summary-gather-subject-limit)
7587 (setq subject (gnus-simplify-subject-re whole-subject))
7588 (if (> (length subject) gnus-summary-gather-subject-limit)
7589 (substring subject 0 gnus-summary-gather-subject-limit)
7591 ;; Fuzzily simplify it.
7592 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7593 (gnus-simplify-subject-fuzzy whole-subject))
7594 ;; Just remove the leading "Re:".
7596 (gnus-simplify-subject-re whole-subject))))
7598 (if (setq hthread (gnus-gethash subject hashtb))
7600 ;; We enter a dummy root into the thread, if we
7601 ;; haven't done that already.
7602 (unless (stringp (car (car hthread)))
7603 (setcar hthread (list whole-subject (car hthread))))
7604 ;; We add this new gathered thread to this gathered
7606 (setcdr (car hthread)
7607 (nconc (cdr (car hthread)) (list (car threads))))
7608 ;; Remove it from the list of threads.
7609 (setcdr prev (cdr threads))
7610 (setq threads prev))
7611 ;; Enter this thread into the hash table.
7612 (gnus-sethash subject threads hashtb)))
7614 (setq threads (cdr threads)))
7617 (defun gnus-summary-gather-threads-by-references (threads)
7618 "Gather threads by looking at References headers."
7619 (let ((idhashtb (gnus-make-hashtable 1023))
7620 (thhashtb (gnus-make-hashtable 1023))
7623 ids references id gthread gid entered)
7625 (when (setq references (mail-header-references (caar threads)))
7626 (setq id (mail-header-id (caar threads)))
7627 (setq ids (gnus-split-references references))
7630 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7632 (gnus-sethash (car ids) id idhashtb)
7633 (gnus-sethash id threads thhashtb))
7634 (setq gthread (gnus-gethash gid thhashtb))
7636 ;; We enter a dummy root into the thread, if we
7637 ;; haven't done that already.
7638 (unless (stringp (caar gthread))
7639 (setcar gthread (list (mail-header-subject (caar gthread))
7641 ;; We add this new gathered thread to this gathered
7643 (setcdr (car gthread)
7644 (nconc (cdar gthread) (list (car threads)))))
7645 ;; Add it into the thread hash table.
7646 (gnus-sethash id gthread thhashtb)
7648 ;; Remove it from the list of threads.
7649 (setcdr prev (cdr threads))
7650 (setq threads prev))
7651 (setq ids (cdr ids))))
7653 (setq threads (cdr threads)))
7656 (defun gnus-sort-gathered-threads (threads)
7657 "Sort subtreads inside each gathered thread by article number."
7658 (let ((result threads))
7660 (when (stringp (car (car threads)))
7661 (setcdr (car threads)
7662 (sort (cdr (car threads)) 'gnus-thread-sort-by-number)))
7663 (setq threads (cdr threads)))
7666 (defun gnus-make-threads ()
7667 "Go through the dependency hashtb and find the roots. Return all threads."
7671 (unless (car (symbol-value refs))
7672 ;; These threads do not refer back to any other articles,
7673 ;; so they're roots.
7674 (setq threads (append (cdr (symbol-value refs)) threads))))
7675 gnus-newsgroup-dependencies)
7678 (defun gnus-build-sparse-threads ()
7679 (let ((headers gnus-newsgroup-headers)
7680 (deps gnus-newsgroup-dependencies)
7681 header references generation relations
7682 cthread subject child end pthread relation)
7683 ;; First we create an alist of generations/relations, where
7684 ;; generations is how much we trust the ralation, and the relation
7686 (gnus-message 7 "Making sparse threads...")
7688 (nnheader-set-temp-buffer " *gnus sparse threads*")
7689 (while (setq header (pop headers))
7690 (when (and (setq references (mail-header-references header))
7691 (not (string= references "")))
7693 (setq child (downcase (mail-header-id header))
7694 subject (mail-header-subject header))
7696 (while (search-backward ">" nil t)
7697 (setq end (1+ (point)))
7698 (when (search-backward "<" nil t)
7699 (push (list (incf generation)
7700 child (setq child (downcase
7701 (buffer-substring (point) end)))
7704 (push (list (1+ generation) child nil subject) relations)
7706 (kill-buffer (current-buffer)))
7707 ;; Sort over trustworthiness.
7708 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7709 (while (setq relation (pop relations))
7710 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7711 (unless (car (symbol-value cthread))
7712 ;; Make this article the parent of these threads.
7713 (setcar (symbol-value cthread)
7714 (vector gnus-reffed-article-number
7718 (or (caddr relation) "") 0 0 "")))
7719 (set cthread (list (vector gnus-reffed-article-number
7721 "" "" (cadr relation)
7722 (or (caddr relation) "") 0 0 ""))))
7723 (push gnus-reffed-article-number gnus-newsgroup-limit)
7724 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7725 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7726 gnus-newsgroup-reads)
7727 (decf gnus-reffed-article-number)
7728 ;; Make this new thread the child of its parent.
7729 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7730 (setcdr (symbol-value pthread)
7731 (nconc (cdr (symbol-value pthread))
7732 (list (symbol-value cthread))))
7733 (set pthread (list nil (symbol-value cthread))))))
7734 (gnus-message 7 "Making sparse threads...done")))
7736 (defun gnus-build-old-threads ()
7737 ;; Look at all the articles that refer back to old articles, and
7738 ;; fetch the headers for the articles that aren't there. This will
7739 ;; build complete threads - if the roots haven't been expired by the
7744 (when (not (car (symbol-value refs)))
7745 (setq heads (cdr (symbol-value refs)))
7747 (if (memq (mail-header-number (car (car heads)))
7748 gnus-newsgroup-dormant)
7749 (setq heads (cdr heads))
7750 (setq id (symbol-name refs))
7751 (while (and (setq id (gnus-build-get-header id))
7752 (not (car (gnus-gethash
7753 id gnus-newsgroup-dependencies)))))
7754 (setq heads nil)))))
7755 gnus-newsgroup-dependencies)))
7757 (defun gnus-build-get-header (id)
7758 ;; Look through the buffer of NOV lines and find the header to
7759 ;; ID. Enter this line into the dependencies hash table, and return
7760 ;; the id of the parent article (if any).
7761 (let ((deps gnus-newsgroup-dependencies)
7765 (set-buffer nntp-server-buffer)
7766 (goto-char (point-min))
7767 (while (and (not found) (search-forward id nil t))
7769 (setq found (looking-at
7770 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7771 (regexp-quote id))))
7772 (or found (beginning-of-line 2)))
7777 (setq header (gnus-nov-parse-line
7778 (read (current-buffer)) deps))
7779 (gnus-parent-id (mail-header-references header))))))
7781 (let ((number (mail-header-number header)))
7782 (push number gnus-newsgroup-limit)
7783 (push header gnus-newsgroup-headers)
7784 (if (memq number gnus-newsgroup-unselected)
7786 (push number gnus-newsgroup-unreads)
7787 (setq gnus-newsgroup-unselected
7788 (delq number gnus-newsgroup-unselected)))
7789 (push number gnus-newsgroup-ancient)))))))
7791 (defun gnus-summary-update-article (article &optional header)
7792 "Update ARTICLE in the summary buffer."
7793 (let ((id (mail-header-id (gnus-summary-article-header article)))
7794 (data (gnus-data-find article)))
7795 (setcar (gnus-id-to-thread id) nil)
7796 (gnus-summary-insert-subject id)
7797 ;; Set the (possibly) new article number in the data structure.
7798 (gnus-data-set-number data (gnus-id-to-article id))))
7800 (defun gnus-rebuild-thread (id)
7801 "Rebuild the thread containing ID."
7802 (let ((dep gnus-newsgroup-dependencies)
7803 (buffer-read-only nil)
7804 current headers refs thread art data)
7805 (if (not gnus-show-threads)
7806 (setq thread (list (car (gnus-id-to-thread id))))
7807 ;; Get the thread this article is part of.
7808 (setq thread (gnus-remove-thread id)))
7809 (setq current (save-excursion
7810 (and (zerop (forward-line -1))
7811 (gnus-summary-article-number))))
7812 ;; If this is a gathered thread, we have to go some re-gathering.
7813 (when (stringp (car thread))
7814 (let ((subject (car thread))
7816 (setq thread (cdr thread))
7818 (unless (memq (setq thr (gnus-id-to-thread
7820 (mail-header-id (car (car thread))))))
7823 (setq thread (cdr thread)))
7824 ;; We now have all (unique) roots.
7825 (if (= (length roots) 1)
7826 ;; All the loose roots are now one solid root.
7827 (setq thread (car roots))
7828 (setq thread (cons subject (gnus-sort-threads roots))))))
7831 ;; We then insert this thread into the summary buffer.
7832 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7833 (gnus-summary-prepare-threads (list thread))
7834 (setq data (nreverse gnus-newsgroup-data))
7835 (setq threads gnus-newsgroup-threads))
7836 ;; We splice the new data into the data structure.
7837 (gnus-data-enter-list current data)
7838 (gnus-data-compute-positions)
7839 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7841 (defun gnus-id-to-thread (id)
7842 "Return the (sub-)thread where ID appears."
7843 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7845 (defun gnus-id-to-article (id)
7846 "Return the article number of ID."
7847 (let ((thread (gnus-id-to-thread id)))
7849 (mail-header-number (car thread)))))
7851 (defun gnus-id-to-header (id)
7852 "Return the article headers of ID."
7853 (car (gnus-id-to-thread id)))
7855 (defun gnus-article-displayed-root-p (article)
7856 "Say whether ARTICLE is a root(ish) article."
7857 (let ((level (gnus-summary-thread-level article))
7863 (null (setq particle (gnus-id-to-article
7865 (mail-header-references
7866 (gnus-summary-article-header article))))))
7867 (null (gnus-summary-thread-level particle)))))))
7869 (defun gnus-root-id (id)
7870 "Return the id of the root of the thread where ID appears."
7872 (while (and id (setq prev (car (gnus-gethash
7874 gnus-newsgroup-dependencies))))
7876 id (gnus-parent-id (mail-header-references prev))))
7879 (defun gnus-remove-thread (id &optional dont-remove)
7880 "Remove the thread that has ID in it."
7881 (let ((dep gnus-newsgroup-dependencies)
7882 headers thread prev last-id)
7883 ;; First go up in this thread until we find the root.
7884 (setq last-id (gnus-root-id id))
7885 (setq headers (list (car (gnus-id-to-thread last-id))
7886 (car (car (cdr (gnus-id-to-thread last-id))))))
7887 ;; We have now found the real root of this thread. It might have
7888 ;; been gathered into some loose thread, so we have to search
7889 ;; through the threads to find the thread we wanted.
7890 (let ((threads gnus-newsgroup-threads)
7893 (setq sub (car threads))
7894 (if (stringp (car sub))
7895 ;; This is a gathered threads, so we look at the roots
7896 ;; below it to find whether this article in in this
7899 (setq sub (cdr sub))
7901 (when (member (car (car sub)) headers)
7902 (setq thread (car threads)
7905 (setq sub (cdr sub))))
7906 ;; It's an ordinary thread, so we check it.
7907 (when (eq (car sub) (car headers))
7910 (setq threads (cdr threads)))
7911 ;; If this article is in no thread, then it's a root.
7914 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7915 (setq thread (gnus-gethash (downcase last-id) dep)))
7918 thread ; We return this thread.
7920 (if (stringp (car thread))
7922 ;; If we use dummy roots, then we have to remove the
7923 ;; dummy root as well.
7924 (when (eq gnus-summary-make-false-root 'dummy)
7927 (setq thread (cdr thread))
7929 (gnus-remove-thread-1 (car thread))
7930 (setq thread (cdr thread))))
7931 (gnus-remove-thread-1 thread))))))))
7933 (defun gnus-remove-thread-1 (thread)
7934 "Remove the thread THREAD recursively."
7935 (let ((number (mail-header-number (car thread)))
7937 (when (setq pos (text-property-any
7938 (point-min) (point-max) 'gnus-number number))
7941 (gnus-data-remove number))
7942 (setq thread (cdr thread))
7944 (gnus-remove-thread-1 (car thread))
7945 (setq thread (cdr thread)))))
7947 (defun gnus-sort-threads (threads)
7949 (if (not gnus-thread-sort-functions)
7951 (let ((func (if (= 1 (length gnus-thread-sort-functions))
7952 (car gnus-thread-sort-functions)
7954 ,(gnus-make-sort-function
7955 (reverse gnus-thread-sort-functions))))))
7956 (gnus-message 7 "Sorting threads...")
7959 (gnus-message 7 "Sorting threads...done")))))
7961 (defun gnus-sort-articles (articles)
7963 (when gnus-article-sort-functions
7964 (let ((func (if (= 1 (length gnus-article-sort-functions))
7965 (car gnus-article-sort-functions)
7967 ,(gnus-make-sort-function
7968 (reverse gnus-article-sort-functions))))))
7969 (gnus-message 7 "Sorting articles...")
7971 (setq gnus-newsgroup-headers (sort articles func))
7972 (gnus-message 7 "Sorting articles...done")))))
7974 (defun gnus-make-sort-function (funs)
7975 "Return a composite sort condition based on the functions in FUNC."
7977 `(or (,(car funs) t1 t2)
7978 (and (not (,(car funs) t2 t1))
7979 ,(gnus-make-sort-function (cdr funs))))
7980 `(,(car funs) t1 t2)))
7982 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7983 (defmacro gnus-thread-header (thread)
7984 ;; Return header of first article in THREAD.
7985 ;; Note that THREAD must never, ever be anything else than a variable -
7986 ;; using some other form will lead to serious barfage.
7987 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7988 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7989 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7992 (defsubst gnus-article-sort-by-number (h1 h2)
7993 "Sort articles by article number."
7994 (< (mail-header-number h1)
7995 (mail-header-number h2)))
7997 (defun gnus-thread-sort-by-number (h1 h2)
7998 "Sort threads by root article number."
7999 (gnus-article-sort-by-number
8000 (gnus-thread-header h1) (gnus-thread-header h2)))
8002 (defsubst gnus-article-sort-by-author (h1 h2)
8003 "Sort articles by root author."
8005 (let ((extract (funcall
8006 gnus-extract-address-components
8007 (mail-header-from h1))))
8008 (or (car extract) (cdr extract)))
8009 (let ((extract (funcall
8010 gnus-extract-address-components
8011 (mail-header-from h2))))
8012 (or (car extract) (cdr extract)))))
8014 (defun gnus-thread-sort-by-author (h1 h2)
8015 "Sort threads by root author."
8016 (gnus-article-sort-by-author
8017 (gnus-thread-header h1) (gnus-thread-header h2)))
8019 (defsubst gnus-article-sort-by-subject (h1 h2)
8020 "Sort articles by root subject."
8022 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8023 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8025 (defun gnus-thread-sort-by-subject (h1 h2)
8026 "Sort threads by root subject."
8027 (gnus-article-sort-by-subject
8028 (gnus-thread-header h1) (gnus-thread-header h2)))
8030 (defsubst gnus-article-sort-by-date (h1 h2)
8031 "Sort articles by root article date."
8033 (gnus-sortable-date (mail-header-date h1))
8034 (gnus-sortable-date (mail-header-date h2))))
8036 (defun gnus-thread-sort-by-date (h1 h2)
8037 "Sort threads by root article date."
8038 (gnus-article-sort-by-date
8039 (gnus-thread-header h1) (gnus-thread-header h2)))
8041 (defsubst gnus-article-sort-by-score (h1 h2)
8042 "Sort articles by root article score.
8043 Unscored articles will be counted as having a score of zero."
8044 (> (or (cdr (assq (mail-header-number h1)
8045 gnus-newsgroup-scored))
8046 gnus-summary-default-score 0)
8047 (or (cdr (assq (mail-header-number h2)
8048 gnus-newsgroup-scored))
8049 gnus-summary-default-score 0)))
8051 (defun gnus-thread-sort-by-score (h1 h2)
8052 "Sort threads by root article score."
8053 (gnus-article-sort-by-score
8054 (gnus-thread-header h1) (gnus-thread-header h2)))
8056 (defun gnus-thread-sort-by-total-score (h1 h2)
8057 "Sort threads by the sum of all scores in the thread.
8058 Unscored articles will be counted as having a score of zero."
8059 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8061 (defun gnus-thread-total-score (thread)
8062 ;; This function find the total score of THREAD.
8064 (if (stringp (car thread))
8065 (apply gnus-thread-score-function 0
8066 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8067 (gnus-thread-total-score-1 thread))
8068 (gnus-thread-total-score-1 (list thread))))
8070 (defun gnus-thread-total-score-1 (root)
8071 ;; This function find the total score of the thread below ROOT.
8072 (setq root (car root))
8073 (apply gnus-thread-score-function
8074 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8075 gnus-summary-default-score 0)
8076 (mapcar 'gnus-thread-total-score
8077 (cdr (gnus-gethash (downcase (mail-header-id root))
8078 gnus-newsgroup-dependencies)))))
8080 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8081 (defvar gnus-tmp-prev-subject nil)
8082 (defvar gnus-tmp-false-parent nil)
8083 (defvar gnus-tmp-root-expunged nil)
8084 (defvar gnus-tmp-dummy-line nil)
8086 (defun gnus-summary-prepare-threads (threads)
8087 "Prepare summary buffer from THREADS and indentation LEVEL.
8088 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8089 or a straight list of headers."
8090 (gnus-message 7 "Generating summary...")
8092 (setq gnus-newsgroup-threads threads)
8095 (let ((gnus-tmp-level 0)
8096 (default-score (or gnus-summary-default-score 0))
8097 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8098 thread number subject stack state gnus-tmp-gathered beg-match
8099 new-roots gnus-tmp-new-adopts thread-end
8100 gnus-tmp-header gnus-tmp-unread
8101 gnus-tmp-replied gnus-tmp-subject-or-nil
8102 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8103 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8104 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8106 (setq gnus-tmp-prev-subject nil)
8108 (if (vectorp (car threads))
8109 ;; If this is a straight (sic) list of headers, then a
8110 ;; threaded summary display isn't required, so we just create
8111 ;; an unthreaded one.
8112 (gnus-summary-prepare-unthreaded threads)
8114 ;; Do the threaded display.
8116 (while (or threads stack gnus-tmp-new-adopts new-roots)
8118 (if (and (= gnus-tmp-level 0)
8119 (not (setq gnus-tmp-dummy-line nil))
8121 (= (car (car stack)) 0))
8122 (not gnus-tmp-false-parent)
8123 (or gnus-tmp-new-adopts new-roots))
8124 (if gnus-tmp-new-adopts
8125 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8126 thread (list (car gnus-tmp-new-adopts))
8127 gnus-tmp-header (car (car thread))
8128 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8130 (setq thread (list (car new-roots))
8131 gnus-tmp-header (car (car thread))
8132 new-roots (cdr new-roots))))
8135 ;; If there are some threads, we do them before the
8136 ;; threads on the stack.
8137 (setq thread threads
8138 gnus-tmp-header (car (car thread)))
8139 ;; There were no current threads, so we pop something off
8141 (setq state (car stack)
8142 gnus-tmp-level (car state)
8145 gnus-tmp-header (car (car thread)))))
8147 (setq gnus-tmp-false-parent nil)
8148 (setq gnus-tmp-root-expunged nil)
8149 (setq thread-end nil)
8151 (if (stringp gnus-tmp-header)
8152 ;; The header is a dummy root.
8154 ((eq gnus-summary-make-false-root 'adopt)
8155 ;; We let the first article adopt the rest.
8156 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8157 (cdr (cdr (car thread)))))
8158 (setq gnus-tmp-gathered
8160 (lambda (h) (mail-header-number (car h)))
8161 (cdr (cdr (car thread))))
8163 (setq thread (cons (list (car (car thread))
8164 (car (cdr (car thread))))
8166 (setq gnus-tmp-level -1
8167 gnus-tmp-false-parent t))
8168 ((eq gnus-summary-make-false-root 'empty)
8169 ;; We print adopted articles with empty subject fields.
8170 (setq gnus-tmp-gathered
8172 (lambda (h) (mail-header-number (car h)))
8173 (cdr (cdr (car thread))))
8175 (setq gnus-tmp-level -1))
8176 ((eq gnus-summary-make-false-root 'dummy)
8177 ;; We remember that we probably want to output a dummy
8179 (setq gnus-tmp-dummy-line gnus-tmp-header)
8180 (setq gnus-tmp-prev-subject gnus-tmp-header))
8182 ;; We do not make a root for the gathered
8183 ;; sub-threads at all.
8184 (setq gnus-tmp-level -1)))
8186 (setq number (mail-header-number gnus-tmp-header)
8187 subject (mail-header-subject gnus-tmp-header))
8190 ;; If the thread has changed subject, we might want to make
8191 ;; this subthread into a root.
8192 ((and (null gnus-thread-ignore-subject)
8193 (not (zerop gnus-tmp-level))
8194 gnus-tmp-prev-subject
8196 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8197 (setq new-roots (nconc new-roots (list (car thread)))
8199 gnus-tmp-header nil))
8200 ;; If the article lies outside the current limit,
8201 ;; then we do not display it.
8202 ((and (not (memq number gnus-newsgroup-limit))
8203 (not gnus-tmp-dummy-line))
8204 (setq gnus-tmp-gathered
8206 (lambda (h) (mail-header-number (car h)))
8209 (setq gnus-tmp-new-adopts (if (cdr (car thread))
8210 (append gnus-tmp-new-adopts
8212 gnus-tmp-new-adopts)
8214 gnus-tmp-header nil)
8215 (when (zerop gnus-tmp-level)
8216 (setq gnus-tmp-root-expunged t)))
8217 ;; Perhaps this article is to be marked as read?
8218 ((and gnus-summary-mark-below
8219 (< (or (cdr (assq number gnus-newsgroup-scored))
8221 gnus-summary-mark-below)
8222 ;; Don't touch sparse articles.
8223 (not (memq number gnus-newsgroup-sparse)))
8224 (setq gnus-newsgroup-unreads
8225 (delq number gnus-newsgroup-unreads))
8226 (if gnus-newsgroup-auto-expire
8227 (push number gnus-newsgroup-expirable)
8228 (push (cons number gnus-low-score-mark)
8229 gnus-newsgroup-reads))))
8231 (when gnus-tmp-header
8232 ;; We may have an old dummy line to output before this
8234 (when gnus-tmp-dummy-line
8235 (gnus-summary-insert-dummy-line
8236 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8237 (setq gnus-tmp-dummy-line nil))
8239 ;; Compute the mark.
8243 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8244 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8245 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8246 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8247 (t (or (cdr (assq number gnus-newsgroup-reads))
8248 gnus-ancient-mark))))
8250 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8251 gnus-tmp-header gnus-tmp-level)
8252 gnus-newsgroup-data)
8254 ;; Actually insert the line.
8256 gnus-tmp-subject-or-nil
8258 ((and gnus-thread-ignore-subject
8259 gnus-tmp-prev-subject
8260 (not (inline (gnus-subject-equal
8261 gnus-tmp-prev-subject subject))))
8263 ((zerop gnus-tmp-level)
8264 (if (and (eq gnus-summary-make-false-root 'empty)
8265 (memq number gnus-tmp-gathered)
8266 gnus-tmp-prev-subject
8267 (inline (gnus-subject-equal
8268 gnus-tmp-prev-subject subject)))
8269 gnus-summary-same-subject
8271 (t gnus-summary-same-subject)))
8272 (if (and (eq gnus-summary-make-false-root 'adopt)
8273 (= gnus-tmp-level 1)
8274 (memq number gnus-tmp-gathered))
8275 (setq gnus-tmp-opening-bracket ?\<
8276 gnus-tmp-closing-bracket ?\>)
8277 (setq gnus-tmp-opening-bracket ?\[
8278 gnus-tmp-closing-bracket ?\]))
8280 gnus-tmp-indentation
8281 (aref gnus-thread-indent-array gnus-tmp-level)
8282 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8283 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8284 gnus-summary-default-score 0)
8286 (if (or (null gnus-summary-default-score)
8287 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8288 gnus-summary-zcore-fuzz)) ?
8289 (if (< gnus-tmp-score gnus-summary-default-score)
8290 gnus-score-below-mark gnus-score-over-mark))
8292 (cond ((memq number gnus-newsgroup-processable)
8294 ((memq number gnus-newsgroup-cached)
8296 ((memq number gnus-newsgroup-replied)
8298 (t gnus-unread-mark))
8299 gnus-tmp-from (mail-header-from gnus-tmp-header)
8302 ((string-match "(.+)" gnus-tmp-from)
8303 (substring gnus-tmp-from
8304 (1+ (match-beginning 0)) (1- (match-end 0))))
8305 ((string-match "<[^>]+> *$" gnus-tmp-from)
8306 (setq beg-match (match-beginning 0))
8307 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8308 (substring gnus-tmp-from (1+ (match-beginning 0))
8309 (1- (match-end 0))))
8310 (substring gnus-tmp-from 0 beg-match)))
8312 (when (string= gnus-tmp-name "")
8313 (setq gnus-tmp-name gnus-tmp-from))
8314 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8317 (progn (eval gnus-summary-line-format-spec) (point))
8318 'gnus-number number)
8321 (run-hooks 'gnus-summary-update-hook)
8324 (setq gnus-tmp-prev-subject subject)))
8326 (when (nth 1 thread)
8327 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8328 (incf gnus-tmp-level)
8329 (setq threads (if thread-end nil (cdr (car thread))))
8331 (setq gnus-tmp-level 0)))))
8332 (gnus-message 7 "Generating summary...done"))
8334 (defun gnus-summary-prepare-unthreaded (headers)
8335 "Generate an unthreaded summary buffer based on HEADERS."
8336 (let (header number mark)
8339 (setq header (car headers)
8340 headers (cdr headers)
8341 number (mail-header-number header))
8343 ;; We may have to root out some bad articles...
8344 (when (memq number gnus-newsgroup-limit)
8345 (when (and gnus-summary-mark-below
8346 (< (or (cdr (assq number gnus-newsgroup-scored))
8347 gnus-summary-default-score 0)
8348 gnus-summary-mark-below))
8349 (setq gnus-newsgroup-unreads
8350 (delq number gnus-newsgroup-unreads))
8351 (if gnus-newsgroup-auto-expire
8352 (push number gnus-newsgroup-expirable)
8353 (push (cons number gnus-low-score-mark)
8354 gnus-newsgroup-reads)))
8358 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8359 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8360 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8361 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8362 (t (or (cdr (assq number gnus-newsgroup-reads))
8363 gnus-ancient-mark))))
8364 (setq gnus-newsgroup-data
8365 (cons (gnus-data-make number mark (1+ (point)) header 0)
8366 gnus-newsgroup-data))
8367 (gnus-summary-insert-line
8368 header 0 nil mark (memq number gnus-newsgroup-replied)
8369 (memq number gnus-newsgroup-expirable)
8370 (mail-header-subject header) nil
8371 (cdr (assq number gnus-newsgroup-scored))
8372 (memq number gnus-newsgroup-processable))))))
8374 (defun gnus-select-newsgroup (group &optional read-all)
8375 "Select newsgroup GROUP.
8376 If READ-ALL is non-nil, all articles in the group are selected."
8377 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8378 (info (nth 2 entry))
8379 articles fetched-articles cached)
8381 (or (gnus-check-server
8382 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8383 (error "Couldn't open server"))
8385 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8386 (gnus-activate-group group) ; Or we can activate it...
8387 (progn ; Or we bug out.
8388 (kill-buffer (current-buffer))
8389 (error "Couldn't request group %s: %s"
8390 group (gnus-status-message group))))
8392 (setq gnus-newsgroup-name group)
8393 (setq gnus-newsgroup-unselected nil)
8394 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8396 (and gnus-asynchronous
8397 (gnus-check-backend-function
8398 'request-asynchronous gnus-newsgroup-name)
8399 (setq gnus-newsgroup-async
8400 (gnus-request-asynchronous gnus-newsgroup-name)))
8402 ;; Adjust and set lists of article marks.
8404 (gnus-adjust-marked-articles info))
8406 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8407 (when (gnus-virtual-group-p group)
8408 (setq cached gnus-newsgroup-cached))
8410 (setq gnus-newsgroup-unreads
8411 (gnus-set-difference
8412 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8413 gnus-newsgroup-dormant))
8415 (setq gnus-newsgroup-processable nil)
8417 (setq articles (gnus-articles-to-read group read-all))
8421 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8423 ((eq articles 0) nil)
8425 ;; Init the dependencies hash table.
8426 (setq gnus-newsgroup-dependencies
8427 (gnus-make-hashtable (length articles)))
8428 ;; Retrieve the headers and read them in.
8429 (gnus-message 5 "Fetching headers...")
8430 (setq gnus-newsgroup-headers
8432 (setq gnus-headers-retrieved-by
8433 (gnus-retrieve-headers
8434 articles gnus-newsgroup-name
8435 ;; We might want to fetch old headers, but
8436 ;; not if there is only 1 article.
8437 (and gnus-fetch-old-headers
8439 (not (eq gnus-fetch-old-headers 'some))
8440 (not (numberp gnus-fetch-old-headers)))
8441 (> (length articles) 1))))))
8442 (gnus-get-newsgroup-headers-xover articles)
8443 (gnus-get-newsgroup-headers)))
8444 (gnus-message 5 "Fetching headers...done")
8446 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8448 (setq gnus-newsgroup-cached cached))
8450 ;; Set the initial limit.
8451 (setq gnus-newsgroup-limit (copy-sequence articles))
8452 ;; Remove canceled articles from the list of unread articles.
8453 (setq gnus-newsgroup-unreads
8454 (gnus-set-sorted-intersection
8455 gnus-newsgroup-unreads
8456 (setq fetched-articles
8457 (mapcar (lambda (headers) (mail-header-number headers))
8458 gnus-newsgroup-headers))))
8459 ;; Removed marked articles that do not exist.
8460 (gnus-update-missing-marks
8461 (gnus-sorted-complement fetched-articles articles))
8462 ;; We might want to build some more threads first.
8463 (and gnus-fetch-old-headers
8464 (eq gnus-headers-retrieved-by 'nov)
8465 (gnus-build-old-threads))
8466 ;; Check whether auto-expire is to be done in this group.
8467 (setq gnus-newsgroup-auto-expire
8468 (gnus-group-auto-expirable-p group))
8469 ;; First and last article in this newsgroup.
8470 (and gnus-newsgroup-headers
8471 (setq gnus-newsgroup-begin
8472 (mail-header-number (car gnus-newsgroup-headers)))
8473 (setq gnus-newsgroup-end
8475 (gnus-last-element gnus-newsgroup-headers))))
8476 (setq gnus-reffed-article-number -1)
8477 ;; GROUP is successfully selected.
8478 (or gnus-newsgroup-headers t)))))
8480 (defun gnus-articles-to-read (group read-all)
8481 ;; Find out what articles the user wants to read.
8483 ;; Select all articles if `read-all' is non-nil, or if there
8484 ;; are no unread articles.
8486 (and (zerop (length gnus-newsgroup-marked))
8487 (zerop (length gnus-newsgroup-unreads))))
8488 (gnus-uncompress-range (gnus-active group))
8489 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8490 (copy-sequence gnus-newsgroup-unreads))
8492 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8493 (scored (length scored-list))
8494 (number (length articles))
8495 (marked (+ (length gnus-newsgroup-marked)
8496 (length gnus-newsgroup-dormant)))
8504 ((and (or (<= scored marked) (= scored number))
8505 (numberp gnus-large-newsgroup)
8506 (> number gnus-large-newsgroup))
8510 "How many articles from %s (default %d): "
8511 gnus-newsgroup-name number))))
8512 (if (string-match "^[ \t]*$" input) number input)))
8513 ((and (> scored marked) (< scored number))
8516 (format "%s %s (%d scored, %d total): "
8517 "How many articles from"
8518 group scored number))))
8519 (if (string-match "^[ \t]*$" input)
8523 (setq select (if (stringp select) (string-to-number select) select))
8524 (if (or (null select) (zerop select))
8526 (if (and (not (zerop scored)) (<= (abs select) scored))
8528 (setq articles (sort scored-list '<))
8529 (setq number (length articles)))
8530 (setq articles (copy-sequence articles)))
8532 (if (< (abs select) number)
8534 ;; Select the N oldest articles.
8535 (setcdr (nthcdr (1- (abs select)) articles) nil)
8536 ;; Select the N most recent articles.
8537 (setq articles (nthcdr (- number select) articles))))
8538 (setq gnus-newsgroup-unselected
8539 (gnus-sorted-intersection
8540 gnus-newsgroup-unreads
8541 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8544 (defun gnus-killed-articles (killed articles)
8547 (if (inline (gnus-member-of-range (car articles) killed))
8548 (setq out (cons (car articles) out)))
8549 (setq articles (cdr articles)))
8552 (defun gnus-uncompress-marks (marks)
8553 "Uncompress the mark ranges in MARKS."
8554 (let ((uncompressed '(score bookmark))
8557 (if (memq (caar marks) uncompressed)
8558 (push (car marks) out)
8559 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8560 (setq marks (cdr marks)))
8563 (defun gnus-adjust-marked-articles (info)
8564 "Set all article lists and remove all marks that are no longer legal."
8565 (let* ((marked-lists (gnus-info-marks info))
8566 (active (gnus-active (gnus-info-group info)))
8569 (types gnus-article-mark-lists)
8570 (uncompressed '(score bookmark))
8571 marks var articles article mark)
8574 (setq marks (pop marked-lists))
8575 (set (setq var (intern (format "gnus-newsgroup-%s"
8576 (car (rassq (setq mark (car marks))
8578 (if (memq (car marks) uncompressed) (cdr marks)
8579 (gnus-uncompress-range (cdr marks))))
8581 (setq articles (symbol-value var))
8583 ;; All articles have to be subsets of the active articles.
8585 ;; Adjust "simple" lists.
8586 ((memq mark '(tick dormant expirable reply killed save))
8588 (when (or (< (setq article (pop articles)) min) (> article max))
8589 (set var (delq article (symbol-value var))))))
8591 ((memq mark '(score bookmark))
8593 (when (or (< (car (setq article (pop articles))) min)
8594 (> (car article) max))
8595 (set var (delq article (symbol-value var))))))))))
8597 (defun gnus-update-missing-marks (missing)
8598 "Go through the list of MISSING articles and remove them mark lists."
8600 (let ((types gnus-article-mark-lists)
8602 ;; Go through all types.
8604 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8605 (when (symbol-value var)
8606 ;; This list has articles. So we delete all missing articles
8610 (set var (delq (pop m) (symbol-value var)))))))))
8612 (defun gnus-update-marks ()
8613 "Enter the various lists of marked articles into the newsgroup info list."
8614 (let ((types gnus-article-mark-lists)
8615 (info (gnus-get-info gnus-newsgroup-name))
8616 (uncompressed '(score bookmark killed))
8617 var type list newmarked symbol)
8619 ;; Add all marks lists that are non-nil to the list of marks lists.
8621 (setq type (pop types))
8622 (when (setq list (symbol-value
8624 (intern (format "gnus-newsgroup-%s"
8626 (push (cons (cdr type)
8627 (if (memq (cdr type) uncompressed) list
8628 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8631 ;; Enter these new marks into the info of the group.
8633 (setcar (nthcdr 3 info) newmarked)
8634 ;; Add the marks lists to the end of the info.
8636 (setcdr (nthcdr 2 info) (list newmarked))))
8638 ;; Cut off the end of the info if there's nothing else there.
8642 (when (nthcdr (decf i) info)
8643 (setcdr (nthcdr i info) nil)))))))
8645 (defun gnus-add-marked-articles (group type articles &optional info force)
8646 ;; Add ARTICLES of TYPE to the info of GROUP.
8647 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8648 ;; add, but replace marked articles of TYPE with ARTICLES.
8649 (let ((info (or info (gnus-get-info group)))
8650 (uncompressed '(score bookmark killed))
8653 (and (not (setq marked (nthcdr 3 info)))
8654 (setcdr (nthcdr 2 info)
8655 (list (list (cons type (gnus-compress-sequence
8657 (and (not (setq m (assq type (car marked))))
8659 (cons (cons type (gnus-compress-sequence articles t) )
8662 (setcdr m (gnus-compress-sequence articles t))
8663 (setcdr m (gnus-compress-sequence
8664 (sort (nconc (gnus-uncompress-range m)
8665 (copy-sequence articles)) '<) t))))))
8667 (defun gnus-set-mode-line (where)
8668 "This function sets the mode line of the article or summary buffers.
8669 If WHERE is `summary', the summary mode line format will be used."
8670 ;; Is this mode line one we keep updated?
8671 (when (memq where gnus-updated-mode-lines)
8674 ;; We evaluate this in the summary buffer since these
8675 ;; variables are buffer-local to that buffer.
8676 (set-buffer gnus-summary-buffer)
8677 ;; We bind all these variables that are used in the `eval' form
8679 (let* ((mformat (symbol-value
8681 (format "gnus-%s-mode-line-format-spec" where))))
8682 (gnus-tmp-group-name gnus-newsgroup-name)
8683 (gnus-tmp-article-number (or gnus-current-article 0))
8684 (gnus-tmp-unread gnus-newsgroup-unreads)
8685 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8686 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8687 (gnus-tmp-unread-and-unselected
8688 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8689 (zerop gnus-tmp-unselected)) "")
8690 ((zerop gnus-tmp-unselected)
8691 (format "{%d more}" gnus-tmp-unread-and-unticked))
8692 (t (format "{%d(+%d) more}"
8693 gnus-tmp-unread-and-unticked
8694 gnus-tmp-unselected))))
8696 (if (and gnus-current-headers
8697 (vectorp gnus-current-headers))
8698 (mail-header-subject gnus-current-headers) ""))
8700 gnus-tmp-header);; passed as argument to any user-format-funcs
8701 (setq mode-string (eval mformat))
8702 (setq max-len (max 4 (if gnus-mode-non-string-length
8704 gnus-mode-non-string-length)
8705 (length mode-string))))
8706 ;; We might have to chop a bit of the string off...
8707 (when (> (length mode-string) max-len)
8709 (concat (gnus-truncate-string mode-string (- max-len 3))
8711 ;; Pad the mode string a bit.
8712 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8713 ;; Update the mode line.
8714 (setq mode-line-buffer-identification (list mode-string))
8715 (set-buffer-modified-p t))))
8717 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8718 "Go through the HEADERS list and add all Xrefs to a hash table.
8719 The resulting hash table is returned, or nil if no Xrefs were found."
8720 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8721 (virtual (gnus-virtual-group-p from-newsgroup))
8722 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8723 (xref-hashtb (make-vector 63 0))
8724 start group entry number xrefs header)
8726 (setq header (pop headers))
8727 (when (and (setq xrefs (mail-header-xref header))
8728 (not (memq (setq number (mail-header-number header))
8731 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8732 (setq start (match-end 0))
8733 (setq group (concat prefix (substring xrefs (match-beginning 1)
8736 (string-to-int (substring xrefs (match-beginning 2)
8738 (if (setq entry (gnus-gethash group xref-hashtb))
8739 (setcdr entry (cons number (cdr entry)))
8740 (gnus-sethash group (cons number nil) xref-hashtb)))))
8741 (and start xref-hashtb)))
8743 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8744 "Look through all the headers and mark the Xrefs as read."
8745 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8746 name entry info xref-hashtb idlist method nth4)
8748 (set-buffer gnus-group-buffer)
8749 (when (setq xref-hashtb
8750 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8753 (unless (string= from-newsgroup (setq name (symbol-name group)))
8754 (setq idlist (symbol-value group))
8755 ;; Dead groups are not updated.
8757 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8759 (if (stringp (setq nth4 (gnus-info-method info)))
8760 (setq nth4 (gnus-server-to-method nth4))))
8761 ;; Only do the xrefs if the group has the same
8762 ;; select method as the group we have just read.
8763 (or (gnus-methods-equal-p
8764 nth4 (gnus-find-method-for-group from-newsgroup))
8766 (equal nth4 (setq method (gnus-find-method-for-group
8768 (and (equal (car nth4) (car method))
8769 (equal (nth 1 nth4) (nth 1 method))))
8770 gnus-use-cross-reference
8771 (or (not (eq gnus-use-cross-reference t))
8773 ;; Only do cross-references on subscribed
8774 ;; groups, if that is what is wanted.
8775 (<= (gnus-info-level info) gnus-level-subscribed))
8776 (gnus-group-make-articles-read name idlist))))
8779 (defun gnus-group-make-articles-read (group articles)
8781 (entry (gnus-gethash group gnus-newsrc-hashtb))
8782 (info (nth 2 entry))
8783 (active (gnus-active group))
8785 ;; First peel off all illegal article numbers.
8787 (let ((ids articles)
8791 (if (and first (> id (cdr active)))
8793 ;; We'll end up in this situation in one particular
8794 ;; obscure situation. If you re-scan a group and get
8795 ;; a new article that is cross-posted to a different
8796 ;; group that has not been re-scanned, you might get
8797 ;; crossposted article that has a higher number than
8798 ;; Gnus believes possible. So we re-activate this
8799 ;; group as well. This might mean doing the
8800 ;; crossposting thingy will *increase* the number
8801 ;; of articles in some groups. Tsk, tsk.
8802 (setq active (or (gnus-activate-group group) active))))
8803 (if (or (> id (cdr active))
8804 (< id (car active)))
8805 (setq articles (delq id articles)))
8806 (setq ids (cdr ids)))))
8807 ;; If the read list is nil, we init it.
8809 (null (gnus-info-read info))
8811 (gnus-info-set-read info (cons 1 (1- (car active)))))
8812 ;; Then we add the read articles to the range.
8817 (gnus-info-read info) (setq articles (sort articles '<)))))
8818 ;; Then we have to re-compute how many unread
8819 ;; articles there are in this group.
8824 (setq num (- (1+ (cdr active)) (car active))))
8825 ((not (listp (cdr range)))
8826 (setq num (- (cdr active) (- (1+ (cdr range))
8830 (if (numberp (car range))
8832 (setq num (+ num (- (1+ (cdr (car range)))
8833 (car (car range))))))
8834 (setq range (cdr range)))
8835 (setq num (- (cdr active) num))))
8836 ;; Update the number of unread articles.
8838 ;; Update the group buffer.
8839 (gnus-group-update-group group t)))))
8841 (defun gnus-methods-equal-p (m1 m2)
8842 (let ((m1 (or m1 gnus-select-method))
8843 (m2 (or m2 gnus-select-method)))
8845 (and (eq (car m1) (car m2))
8846 (or (not (memq 'address (assoc (symbol-name (car m1))
8847 gnus-valid-select-methods)))
8848 (equal (nth 1 m1) (nth 1 m2)))))))
8850 (defsubst gnus-header-value ()
8851 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8853 (defvar gnus-newsgroup-none-id 0)
8855 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8856 (let ((cur nntp-server-buffer)
8859 (save-excursion (set-buffer gnus-summary-buffer)
8860 gnus-newsgroup-dependencies)))
8861 headers id id-dep ref-dep end ref)
8863 (set-buffer nntp-server-buffer)
8864 (let ((case-fold-search t)
8865 in-reply-to header number p lines)
8866 (goto-char (point-min))
8867 ;; Search to the beginning of the next header. Error messages
8868 ;; do not begin with 2 or 3.
8869 (while (re-search-forward "^[23][0-9]+ " nil t)
8872 ;; This implementation of this function, with nine
8873 ;; search-forwards instead of the one re-search-forward and
8874 ;; a case (which basically was the old function) is actually
8875 ;; about twice as fast, even though it looks messier. You
8876 ;; can't have everything, I guess. Speed and elegance
8877 ;; doesn't always go hand in hand.
8886 (narrow-to-region (point)
8887 (or (and (search-forward "\n.\n" nil t)
8893 (if (search-forward "\nsubject: " nil t)
8894 (gnus-header-value) "(none)"))
8898 (if (search-forward "\nfrom: " nil t)
8899 (gnus-header-value) "(nobody)"))
8903 (if (search-forward "\ndate: " nil t)
8904 (gnus-header-value) ""))
8908 (if (search-forward "\nmessage-id: " nil t)
8909 (setq id (gnus-header-value))
8910 ;; If there was no message-id, we just fake one to make
8911 ;; subsequent routines simpler.
8912 (setq id (concat "none+"
8914 (setq gnus-newsgroup-none-id
8915 (1+ gnus-newsgroup-none-id)))))))
8919 (if (search-forward "\nreferences: " nil t)
8922 (setq end (match-end 0))
8929 (search-backward ">" end t)
8932 (search-backward "<" end t)
8934 ;; Get the references from the in-reply-to header if there
8935 ;; were no references and the in-reply-to header looks
8937 (if (and (search-forward "\nin-reply-to: " nil t)
8938 (setq in-reply-to (gnus-header-value))
8939 (string-match "<[^>]+>" in-reply-to))
8941 (setq ref (substring in-reply-to (match-beginning 0)
8943 (setq ref (downcase ref))))
8950 (if (search-forward "\nlines: " nil t)
8951 (if (numberp (setq lines (read cur)))
8957 (and (search-forward "\nxref: " nil t)
8958 (gnus-header-value)))))
8959 ;; We do the threading while we read the headers. The
8960 ;; message-id and the last reference are both entered into
8961 ;; the same hash table. Some tippy-toeing around has to be
8962 ;; done in case an article has arrived before the article
8963 ;; which it refers to.
8964 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8965 (if (and (car (symbol-value id-dep))
8967 ;; An article with this Message-ID has already
8968 ;; been seen, so we ignore this one, except we add
8969 ;; any additional Xrefs (in case the two articles
8970 ;; came from different servers).
8972 (mail-header-set-xref
8973 (car (symbol-value id-dep))
8974 (concat (or (mail-header-xref
8975 (car (symbol-value id-dep))) "")
8976 (or (mail-header-xref header) "")))
8978 (setcar (symbol-value id-dep) header))
8979 (set id-dep (list header)))
8981 (if (boundp (setq ref-dep (intern ref dependencies)))
8982 (setcdr (symbol-value ref-dep)
8983 (nconc (cdr (symbol-value ref-dep))
8984 (list (symbol-value id-dep))))
8985 (set ref-dep (list nil (symbol-value id-dep))))
8986 (setq headers (cons header headers)))
8987 (goto-char (point-max))
8989 (nreverse headers)))))
8991 ;; The following macros and functions were written by Felix Lee
8992 ;; <flee@cse.psu.edu>.
8994 (defmacro gnus-nov-read-integer ()
8996 (if (= (following-char) ?\t)
8998 (let ((num (condition-case nil (read buffer) (error nil))))
8999 (if (numberp num) num 0)))
9000 (or (eobp) (forward-char 1))))
9002 (defmacro gnus-nov-skip-field ()
9003 '(search-forward "\t" eol 'move))
9005 (defmacro gnus-nov-field ()
9006 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9008 ;; Goes through the xover lines and returns a list of vectors
9009 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9010 "Parse the news overview data in the server buffer, and return a
9011 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9012 ;; Get the Xref when the users reads the articles since most/some
9013 ;; NNTP servers do not include Xrefs when using XOVER.
9014 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9015 (let ((cur nntp-server-buffer)
9016 (dependencies gnus-newsgroup-dependencies)
9017 number headers header)
9019 (set-buffer nntp-server-buffer)
9020 ;; Allow the user to mangle the headers before parsing them.
9021 (run-hooks 'gnus-parse-headers-hook)
9022 ;; Allow the user to mangle the headers before parsing them.
9023 (run-hooks 'gnus-parse-headers-hook)
9024 (goto-char (point-min))
9025 (while (and sequence (not (eobp)))
9026 (setq number (read cur))
9027 (while (and sequence (< (car sequence) number))
9028 (setq sequence (cdr sequence)))
9030 (eq number (car sequence))
9032 (setq sequence (cdr sequence))
9034 (inline (gnus-nov-parse-line
9035 number dependencies force-new)))
9036 (setq headers (cons header headers)))))
9038 (setq headers (nreverse headers)))
9041 ;; This function has to be called with point after the article number
9042 ;; on the beginning of the line.
9043 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9045 (eol (gnus-point-at-eol))
9046 (buffer (current-buffer))
9047 header ref id id-dep ref-dep)
9049 ;; overview: [num subject from date id refs chars lines misc]
9050 (narrow-to-region (point) eol)
9051 (or (eobp) (forward-char))
9057 (gnus-nov-field) ; subject
9058 (gnus-nov-field) ; from
9059 (gnus-nov-field) ; date
9060 (setq id (or (gnus-nov-field)
9063 (setq none (1+ none)))))) ; id
9066 (let ((beg (point)))
9067 (search-forward "\t" eol)
9068 (if (search-backward ">" beg t)
9074 (search-backward "<" beg t)
9077 (gnus-nov-field)) ; refs
9078 (gnus-nov-read-integer) ; chars
9079 (gnus-nov-read-integer) ; lines
9080 (if (= (following-char) ?\n)
9082 (gnus-nov-field)) ; misc
9086 (gnus-message 4 "Strange nov line")
9092 ;; We build the thread tree.
9094 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9095 (if (and (car (symbol-value id-dep))
9097 ;; An article with this Message-ID has already been seen,
9098 ;; so we ignore this one, except we add any additional
9099 ;; Xrefs (in case the two articles came from different
9102 (mail-header-set-xref
9103 (car (symbol-value id-dep))
9104 (concat (or (mail-header-xref
9105 (car (symbol-value id-dep))) "")
9106 (or (mail-header-xref header) "")))
9108 (setcar (symbol-value id-dep) header))
9109 (set id-dep (list header))))
9112 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9113 (setcdr (symbol-value ref-dep)
9114 (nconc (cdr (symbol-value ref-dep))
9115 (list (symbol-value id-dep))))
9116 (set ref-dep (list nil (symbol-value id-dep))))))
9119 (defun gnus-article-get-xrefs ()
9120 "Fill in the Xref value in `gnus-current-headers', if necessary.
9121 This is meant to be called in `gnus-article-internal-prepare-hook'."
9122 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9123 gnus-current-headers)))
9124 (or (not gnus-use-cross-reference)
9126 (and (mail-header-xref headers)
9127 (not (string= (mail-header-xref headers) "")))
9128 (let ((case-fold-search t)
9131 (nnheader-narrow-to-headers)
9132 (goto-char (point-min))
9133 (if (or (and (eq (downcase (following-char)) ?x)
9134 (looking-at "Xref:"))
9135 (search-forward "\nXref:" nil t))
9137 (goto-char (1+ (match-end 0)))
9138 (setq xref (buffer-substring (point)
9139 (progn (end-of-line) (point))))
9140 (mail-header-set-xref headers xref))))))))
9142 (defun gnus-summary-insert-subject (id)
9143 "Find article ID and insert the summary line for that article."
9144 (let ((header (gnus-read-header id))
9145 (number (and (numberp id) id)))
9147 ;; Rebuild the thread that this article is part of and go to the
9148 ;; article we have fetched.
9149 (gnus-rebuild-thread (mail-header-id header))
9150 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9151 (when (and (numberp number)
9153 ;; We have to update the boundaries even if we can't fetch the
9154 ;; article if ID is a number -- so that the next `P' or `N'
9155 ;; command will fetch the previous (or next) article even
9156 ;; if the one we tried to fetch this time has been canceled.
9157 (and (> number gnus-newsgroup-end)
9158 (setq gnus-newsgroup-end number))
9159 (and (< number gnus-newsgroup-begin)
9160 (setq gnus-newsgroup-begin number))
9161 (setq gnus-newsgroup-unselected
9162 (delq number gnus-newsgroup-unselected)))
9163 ;; Report back a success?
9164 (and header number)))
9166 (defun gnus-summary-work-articles (n)
9167 "Return a list of articles to be worked upon. The prefix argument,
9168 the list of process marked articles, and the current article will be
9169 taken into consideration."
9171 ((and n (numberp n))
9172 ;; A numerical prefix has been given.
9173 (let ((backward (< n 0))
9179 (push (setq article (gnus-summary-article-number))
9182 (gnus-summary-find-prev nil article)
9183 (gnus-summary-find-next nil article)))
9185 (nreverse articles)))
9186 ((and (boundp 'transient-mark-mode)
9189 ;; Work on the region between point and mark.
9190 (let ((max (max (point) (mark)))
9193 (goto-char (min (point) (mark)))
9196 (push (setq article (gnus-summary-article-number)) articles)
9197 (gnus-summary-find-next nil article)
9199 (nreverse articles))))
9200 (gnus-newsgroup-processable
9201 ;; There are process-marked articles present.
9202 (reverse gnus-newsgroup-processable))
9204 ;; Just return the current article.
9205 (list (gnus-summary-article-number)))))
9207 (defun gnus-summary-search-group (&optional backward use-level)
9208 "Search for next unread newsgroup.
9209 If optional argument BACKWARD is non-nil, search backward instead."
9211 (set-buffer gnus-group-buffer)
9212 (if (gnus-group-search-forward
9213 backward nil (if use-level (gnus-group-group-level) nil))
9214 (gnus-group-group-name))))
9216 (defun gnus-summary-best-group (&optional exclude-group)
9217 "Find the name of the best unread group.
9218 If EXCLUDE-GROUP, do not go to this group."
9220 (set-buffer gnus-group-buffer)
9222 (gnus-group-best-unread-group exclude-group))))
9224 (defun gnus-summary-find-next (&optional unread article backward)
9225 (if backward (gnus-summary-find-prev)
9226 (let* ((article (or article (gnus-summary-article-number)))
9227 (arts (gnus-data-find-list article))
9229 (when (or (not gnus-summary-check-current)
9231 (not (gnus-data-unread-p (car arts))))
9232 (setq arts (cdr arts)))
9237 (when (gnus-data-unread-p (car arts))
9238 (setq result (car arts)
9240 (setq arts (cdr arts)))
9243 (goto-char (gnus-data-pos result))
9244 (gnus-data-number result)))))
9246 (defun gnus-summary-find-prev (&optional unread article)
9247 (let* ((article (or article (gnus-summary-article-number)))
9248 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9250 (when (or (not gnus-summary-check-current)
9252 (not (gnus-data-unread-p (car arts))))
9253 (setq arts (cdr arts)))
9258 (and (gnus-data-unread-p (car arts))
9259 (setq result (car arts)
9261 (setq arts (cdr arts)))
9265 (goto-char (gnus-data-pos result))
9266 (gnus-data-number result)))))
9268 (defun gnus-summary-find-subject (subject &optional unread backward article)
9269 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9270 (article (or article (gnus-summary-article-number)))
9271 (articles (gnus-data-list backward))
9272 (arts (gnus-data-find-list article articles))
9274 (when (or (not gnus-summary-check-current)
9276 (not (gnus-data-unread-p (car arts))))
9277 (setq arts (cdr arts)))
9279 (and (or (not unread)
9280 (gnus-data-unread-p (car arts)))
9281 (vectorp (gnus-data-header (car arts)))
9283 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9284 (setq result (car arts)
9286 (setq arts (cdr arts)))
9288 (goto-char (gnus-data-pos result))
9289 (gnus-data-number result))))
9291 (defun gnus-summary-search-forward (&optional unread subject backward)
9292 "Search forward for an article.
9293 If UNREAD, look for unread articles. If SUBJECT, look for
9294 articles with that subject. If BACKWARD, search backward instead."
9295 (cond (subject (gnus-summary-find-subject subject unread backward))
9296 (backward (gnus-summary-find-prev unread))
9297 (t (gnus-summary-find-next unread))))
9299 (defun gnus-recenter (&optional n)
9300 "Center point in window and redisplay frame.
9301 Also do horizontal recentering."
9303 (gnus-horizontal-recenter)
9306 (defun gnus-summary-recenter ()
9307 "Center point in the summary window.
9308 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9309 displayed, no centering will be performed."
9310 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9311 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9312 (let* ((top (cond ((< (window-height) 4) 0)
9313 ((< (window-height) 7) 1)
9315 (height (1- (window-height)))
9316 (bottom (save-excursion (goto-char (point-max))
9317 (forward-line (- height))
9319 (window (get-buffer-window (current-buffer))))
9320 ;; The user has to want it.
9321 (when gnus-auto-center-summary
9322 (when (get-buffer-window gnus-article-buffer)
9323 ;; Only do recentering when the article buffer is displayed,
9324 ;; Set the window start to either `bottom', which is the biggest
9325 ;; possible valid number, or the second line from the top,
9326 ;; whichever is the least.
9328 window (min bottom (save-excursion
9329 (forward-line (- top)) (point)))))
9330 ;; Do horizontal recentering while we're at it.
9331 (when (get-buffer-window (current-buffer) t)
9332 (let ((selected (selected-window)))
9333 (select-window (get-buffer-window (current-buffer) t))
9334 (gnus-summary-position-point)
9335 (gnus-horizontal-recenter)
9336 (select-window selected))))))
9338 (defun gnus-horizontal-recenter ()
9339 "Recenter the current buffer horizontally."
9340 (if (< (current-column) (/ (window-width) 2))
9341 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9342 (let* ((orig (point))
9343 (end (window-end (get-buffer-window (current-buffer) t)))
9345 ;; Find the longest line currently displayed in the window.
9346 (goto-char (window-start))
9347 (while (and (not (eobp))
9350 (setq max (max max (current-column)))
9353 ;; Scroll horizontally to center (sort of) the point.
9354 (if (> max (window-width))
9356 (get-buffer-window (current-buffer) t)
9357 (min (- (current-column) (/ (window-width) 3))
9358 (+ 2 (- max (window-width)))))
9359 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9362 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9363 (defun gnus-short-group-name (group &optional levels)
9364 "Collapse GROUP name LEVELS."
9371 (while (string-match "\\." group skip)
9372 (setq skip (match-end 0)
9375 (if (string-match ":" group)
9376 (setq foreign (substring group 0 (match-end 0))
9377 group (substring group (match-end 0))))
9379 (if (and (string-match "\\." group)
9380 (> levels (- gnus-group-uncollapsed-levels 1)))
9381 (setq name (concat name (substring group 0 1))
9382 group (substring group (match-end 0))
9384 name (concat name "."))
9385 (setq name (concat foreign name group)
9389 (defun gnus-summary-jump-to-group (newsgroup)
9390 "Move point to NEWSGROUP in group mode buffer."
9391 ;; Keep update point of group mode buffer if visible.
9392 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9393 (save-window-excursion
9394 ;; Take care of tree window mode.
9395 (if (get-buffer-window gnus-group-buffer)
9396 (pop-to-buffer gnus-group-buffer))
9397 (gnus-group-jump-to-group newsgroup))
9399 ;; Take care of tree window mode.
9400 (if (get-buffer-window gnus-group-buffer)
9401 (pop-to-buffer gnus-group-buffer)
9402 (set-buffer gnus-group-buffer))
9403 (gnus-group-jump-to-group newsgroup))))
9405 ;; This function returns a list of article numbers based on the
9406 ;; difference between the ranges of read articles in this group and
9407 ;; the range of active articles.
9408 (defun gnus-list-of-unread-articles (group)
9409 (let* ((read (gnus-info-read (gnus-get-info group)))
9410 (active (gnus-active group))
9413 ;; If none are read, then all are unread.
9415 (setq first (car active))
9416 ;; If the range of read articles is a single range, then the
9417 ;; first unread article is the article after the last read
9418 ;; article. Sounds logical, doesn't it?
9419 (if (not (listp (cdr read)))
9420 (setq first (1+ (cdr read)))
9421 ;; `read' is a list of ranges.
9422 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9423 (car (car read)))) 1)
9427 (while (< first nlast)
9428 (setq unread (cons first unread))
9429 (setq first (1+ first))))
9430 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9431 (setq nlast (if (atom (car (cdr read)))
9433 (car (car (cdr read)))))
9434 (setq read (cdr read)))))
9435 ;; And add the last unread articles.
9436 (while (<= first last)
9437 (setq unread (cons first unread))
9438 (setq first (1+ first)))
9439 ;; Return the list of unread articles.
9442 (defun gnus-list-of-read-articles (group)
9443 "Return a list of unread, unticked and non-dormant articles."
9444 (let* ((info (gnus-get-info group))
9445 (marked (gnus-info-marks info))
9446 (active (gnus-active group)))
9448 (gnus-set-difference
9449 (gnus-sorted-complement
9450 (gnus-uncompress-range active)
9451 (gnus-list-of-unread-articles group))
9453 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9454 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9456 ;; Various summary commands
9458 (defun gnus-summary-universal-argument (arg)
9459 "Perform any operation on all articles that are process/prefixed."
9461 (gnus-set-global-variables)
9462 (let ((articles (gnus-summary-work-articles arg))
9469 (substitute-command-keys
9470 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9474 (message "Undefined key")
9478 (gnus-summary-goto-subject (setq article (pop articles)))
9479 (command-execute func)
9480 (gnus-summary-remove-process-mark article)))))
9481 (gnus-summary-position-point))
9483 (defun gnus-summary-toggle-truncation (&optional arg)
9484 "Toggle truncation of summary lines.
9485 With arg, turn line truncation on iff arg is positive."
9487 (setq truncate-lines
9488 (if (null arg) (not truncate-lines)
9489 (> (prefix-numeric-value arg) 0)))
9492 (defun gnus-summary-reselect-current-group (&optional all rescan)
9493 "Exit and then reselect the current newsgroup.
9494 The prefix argument ALL means to select all articles."
9496 (gnus-set-global-variables)
9497 (let ((current-subject (gnus-summary-article-number))
9498 (group gnus-newsgroup-name))
9499 (setq gnus-newsgroup-begin nil)
9501 ;; We have to adjust the point of group mode buffer because the
9502 ;; current point was moved to the next unread newsgroup by
9504 (gnus-summary-jump-to-group group)
9507 (gnus-group-get-new-news-this-group 1)))
9508 (gnus-group-read-group all t)
9509 (gnus-summary-goto-subject current-subject)))
9511 (defun gnus-summary-rescan-group (&optional all)
9512 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9514 (gnus-summary-reselect-current-group all t))
9516 (defun gnus-summary-update-info ()
9517 (let* ((group gnus-newsgroup-name))
9518 (when gnus-newsgroup-kill-headers
9519 (setq gnus-newsgroup-killed
9520 (gnus-compress-sequence
9522 (gnus-set-sorted-intersection
9523 (gnus-uncompress-range gnus-newsgroup-killed)
9524 (setq gnus-newsgroup-unselected
9525 (sort gnus-newsgroup-unselected '<)))
9526 (setq gnus-newsgroup-unreads
9527 (sort gnus-newsgroup-unreads '<))) t)))
9528 (unless (listp (cdr gnus-newsgroup-killed))
9529 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9530 (let ((headers gnus-newsgroup-headers))
9531 (gnus-close-group group)
9532 (run-hooks 'gnus-exit-group-hook)
9533 (unless gnus-save-score
9534 (setq gnus-newsgroup-scored nil))
9535 ;; Set the new ranges of read articles.
9536 (gnus-update-read-articles
9537 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9538 ;; Set the current article marks.
9540 ;; Do the cross-ref thing.
9541 (when gnus-use-cross-reference
9542 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9543 ;; Do adaptive scoring, and possibly save score files.
9544 (when gnus-newsgroup-adaptive
9545 (gnus-score-adaptive))
9546 (when gnus-use-scoring
9548 ;; Do not switch windows but change the buffer to work.
9549 (set-buffer gnus-group-buffer)
9550 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9551 (gnus-group-update-group group)))))
9553 (defun gnus-summary-exit (&optional temporary)
9554 "Exit reading current newsgroup, and then return to group selection mode.
9555 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9557 (gnus-set-global-variables)
9558 (gnus-kill-save-kill-buffer)
9559 (let* ((group gnus-newsgroup-name)
9560 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9562 (buf (current-buffer)))
9563 (run-hooks 'gnus-summary-prepare-exit-hook)
9564 ;; If we have several article buffers, we kill them at exit.
9565 (unless gnus-single-article-buffer
9566 (gnus-kill-buffer gnus-article-buffer)
9567 (gnus-kill-buffer gnus-original-article-buffer))
9568 (when gnus-use-cache
9569 (gnus-cache-possibly-remove-articles)
9570 (gnus-cache-save-buffers))
9571 (when gnus-use-trees
9572 (gnus-tree-close group))
9573 ;; Make all changes in this group permanent.
9575 (gnus-summary-update-info))
9576 ;; Make sure where I was, and go to next newsgroup.
9577 (set-buffer gnus-group-buffer)
9579 (gnus-group-jump-to-group group)
9580 (gnus-group-next-unread-group 1))
9581 (run-hooks 'gnus-summary-exit-hook)
9584 ;; If we have several article buffers, we kill them at exit.
9585 (unless gnus-single-article-buffer
9586 (gnus-kill-buffer gnus-article-buffer)
9587 (gnus-kill-buffer gnus-original-article-buffer))
9589 (if (not gnus-kill-summary-on-exit)
9590 (gnus-deaden-summary)
9591 ;; We set all buffer-local variables to nil. It is unclear why
9592 ;; this is needed, but if we don't, buffer-local variables are
9593 ;; not garbage-collected, it seems. This would the lead to en
9594 ;; ever-growing Emacs.
9595 (gnus-summary-clear-local-variables)
9596 (when (get-buffer gnus-article-buffer)
9597 (bury-buffer gnus-article-buffer))
9598 ;; We clear the global counterparts of the buffer-local
9599 ;; variables as well, just to be on the safe side.
9600 (gnus-configure-windows 'group 'force)
9601 (gnus-summary-clear-local-variables)
9602 ;; Return to group mode buffer.
9603 (if (eq mode 'gnus-summary-mode)
9604 (gnus-kill-buffer buf)))
9605 (setq gnus-current-select-method gnus-select-method)
9606 (pop-to-buffer gnus-group-buffer)
9607 ;; Clear the current group name.
9608 (if (not quit-config)
9610 (gnus-group-jump-to-group group)
9611 (gnus-group-next-unread-group 1)
9612 (gnus-configure-windows 'group 'force))
9613 (if (not (buffer-name (car quit-config)))
9614 (gnus-configure-windows 'group 'force)
9615 (set-buffer (car quit-config))
9616 (and (eq major-mode 'gnus-summary-mode)
9617 (gnus-set-global-variables))
9618 (gnus-configure-windows (cdr quit-config))))
9620 (setq gnus-newsgroup-name nil)))))
9622 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9623 (defun gnus-summary-exit-no-update (&optional no-questions)
9624 "Quit reading current newsgroup without updating read article info."
9626 (gnus-set-global-variables)
9627 (let* ((group gnus-newsgroup-name)
9628 (quit-config (gnus-group-quit-config group)))
9629 (when (or no-questions
9631 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9632 ;; If we have several article buffers, we kill them at exit.
9633 (unless gnus-single-article-buffer
9634 (gnus-kill-buffer gnus-article-buffer)
9635 (gnus-kill-buffer gnus-original-article-buffer))
9636 (if (not gnus-kill-summary-on-exit)
9637 (gnus-deaden-summary)
9638 (gnus-close-group group)
9639 (gnus-summary-clear-local-variables)
9640 (set-buffer gnus-group-buffer)
9641 (gnus-summary-clear-local-variables)
9642 (when (get-buffer gnus-summary-buffer)
9643 (kill-buffer gnus-summary-buffer)))
9644 (when gnus-use-trees
9645 (gnus-tree-close group))
9646 (when (get-buffer gnus-article-buffer)
9647 (bury-buffer gnus-article-buffer))
9648 ;; Return to the group buffer.
9649 (gnus-configure-windows 'group 'force)
9650 ;; Clear the current group name.
9651 (setq gnus-newsgroup-name nil)
9652 (when (equal (gnus-group-group-name) group)
9653 (gnus-group-next-unread-group 1))
9655 (if (not (buffer-name (car quit-config)))
9656 (gnus-configure-windows 'group 'force)
9657 (set-buffer (car quit-config))
9658 (when (eq major-mode 'gnus-summary-mode)
9659 (gnus-set-global-variables))
9660 (gnus-configure-windows (cdr quit-config)))))))
9664 (defvar gnus-dead-summary-mode-map nil)
9666 (if gnus-dead-summary-mode-map
9668 (setq gnus-dead-summary-mode-map (make-keymap))
9669 (suppress-keymap gnus-dead-summary-mode-map)
9670 (substitute-key-definition
9671 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9672 (let ((keys '("\C-d" "\r" "\177")))
9674 (define-key gnus-dead-summary-mode-map
9675 (pop keys) 'gnus-summary-wake-up-the-dead))))
9677 (defvar gnus-dead-summary-mode nil
9678 "Minor mode for Gnus summary buffers.")
9680 (defun gnus-dead-summary-mode (&optional arg)
9681 "Minor mode for Gnus summary buffers."
9683 (when (eq major-mode 'gnus-summary-mode)
9684 (make-local-variable 'gnus-dead-summary-mode)
9685 (setq gnus-dead-summary-mode
9686 (if (null arg) (not gnus-dead-summary-mode)
9687 (> (prefix-numeric-value arg) 0)))
9688 (when gnus-dead-summary-mode
9689 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9690 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9691 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9692 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9693 minor-mode-map-alist)))))
9695 (defun gnus-deaden-summary ()
9696 "Make the current summary buffer into a dead summary buffer."
9697 ;; Kill any previous dead summary buffer.
9698 (when (and gnus-dead-summary
9699 (buffer-name gnus-dead-summary))
9701 (set-buffer gnus-dead-summary)
9702 (when gnus-dead-summary-mode
9703 (kill-buffer (current-buffer)))))
9704 ;; Make this the current dead summary.
9705 (setq gnus-dead-summary (current-buffer))
9706 (gnus-dead-summary-mode 1)
9707 (let ((name (buffer-name)))
9708 (when (string-match "Summary" name)
9710 (concat (substring name 0 (match-beginning 0)) "Dead "
9711 (substring name (match-beginning 0))) t))))
9713 (defun gnus-kill-or-deaden-summary (buffer)
9714 "Kill or deaden the summary BUFFER."
9715 (cond (gnus-kill-summary-on-exit
9716 (when (and gnus-use-trees
9717 (and (get-buffer buffer)
9718 (buffer-name (get-buffer buffer))))
9720 (set-buffer (get-buffer buffer))
9721 (gnus-tree-close gnus-newsgroup-name)))
9722 (gnus-kill-buffer buffer))
9723 ((and (get-buffer buffer)
9724 (buffer-name (get-buffer buffer)))
9727 (gnus-deaden-summary)))))
9729 (defun gnus-summary-wake-up-the-dead (&rest args)
9730 "Wake up the dead summary buffer."
9732 (gnus-dead-summary-mode -1)
9733 (let ((name (buffer-name)))
9734 (when (string-match "Dead " name)
9736 (concat (substring name 0 (match-beginning 0))
9737 (substring name (match-end 0))) t)))
9738 (gnus-message 3 "This dead summary is now alive again"))
9740 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9741 (defun gnus-summary-fetch-faq (&optional faq-dir)
9742 "Fetch the FAQ for the current group.
9743 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9747 (if current-prefix-arg
9749 "Faq dir: " (and (listp gnus-group-faq-directory)
9750 gnus-group-faq-directory)))))
9751 (let (gnus-faq-buffer)
9752 (and (setq gnus-faq-buffer
9753 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9754 (gnus-configure-windows 'summary-faq))))
9756 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9757 (defun gnus-summary-describe-group (&optional force)
9758 "Describe the current newsgroup."
9760 (gnus-group-describe-group force gnus-newsgroup-name))
9762 (defun gnus-summary-describe-briefly ()
9763 "Describe summary mode commands briefly."
9766 (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")))
9768 ;; Walking around group mode buffer from summary mode.
9770 (defun gnus-summary-next-group (&optional no-article target-group backward)
9771 "Exit current newsgroup and then select next unread newsgroup.
9772 If prefix argument NO-ARTICLE is non-nil, no article is selected
9773 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9774 previous group instead."
9776 (gnus-set-global-variables)
9777 (let ((current-group gnus-newsgroup-name)
9778 (current-buffer (current-buffer))
9780 ;; First we semi-exit this group to update Xrefs and all variables.
9781 ;; We can't do a real exit, because the window conf must remain
9782 ;; the same in case the user is prompted for info, and we don't
9783 ;; want the window conf to change before that...
9784 (gnus-summary-exit t)
9785 (while (not entered)
9786 ;; Then we find what group we are supposed to enter.
9787 (set-buffer gnus-group-buffer)
9788 (gnus-group-jump-to-group current-group)
9791 (if (eq gnus-keep-same-level 'best)
9792 (gnus-summary-best-group gnus-newsgroup-name)
9793 (gnus-summary-search-group backward gnus-keep-same-level))))
9794 (if (not target-group)
9795 ;; There are no further groups, so we return to the group
9798 (gnus-message 5 "Returning to the group buffer")
9800 (set-buffer current-buffer)
9801 (gnus-summary-exit))
9802 ;; We try to enter the target group.
9803 (gnus-group-jump-to-group target-group)
9804 (let ((unreads (gnus-group-group-unread)))
9805 (if (and (or (eq t unreads)
9806 (and unreads (not (zerop unreads))))
9807 (gnus-summary-read-group
9808 target-group nil no-article current-buffer))
9810 (setq current-group target-group
9811 target-group nil)))))))
9813 (defun gnus-summary-prev-group (&optional no-article)
9814 "Exit current newsgroup and then select previous unread newsgroup.
9815 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9817 (gnus-summary-next-group no-article nil t))
9819 ;; Walking around summary lines.
9821 (defun gnus-summary-first-subject (&optional unread)
9822 "Go to the first unread subject.
9823 If UNREAD is non-nil, go to the first unread article.
9824 Returns the article selected or nil if there are no unread articles."
9829 ((null gnus-newsgroup-data)
9830 (gnus-message 3 "No articles in the group")
9832 ;; Pick the first article.
9834 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9835 (gnus-data-number (car gnus-newsgroup-data)))
9836 ;; No unread articles.
9837 ((null gnus-newsgroup-unreads)
9838 (gnus-message 3 "No more unread articles")
9840 ;; Find the first unread article.
9842 (let ((data gnus-newsgroup-data))
9844 (not (gnus-data-unread-p (car data))))
9845 (setq data (cdr data)))
9848 (goto-char (gnus-data-pos (car data)))
9849 (gnus-data-number (car data)))))))
9850 (gnus-summary-position-point)))
9852 (defun gnus-summary-next-subject (n &optional unread dont-display)
9853 "Go to next N'th summary line.
9854 If N is negative, go to the previous N'th subject line.
9855 If UNREAD is non-nil, only unread articles are selected.
9856 The difference between N and the actual number of steps taken is
9859 (let ((backward (< n 0))
9863 (gnus-summary-find-prev unread)
9864 (gnus-summary-find-next unread)))
9866 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9867 (if unread " unread" "")))
9870 (gnus-summary-recenter)
9871 (gnus-summary-position-point)))
9874 (defun gnus-summary-next-unread-subject (n)
9875 "Go to next N'th unread summary line."
9877 (gnus-summary-next-subject n t))
9879 (defun gnus-summary-prev-subject (n &optional unread)
9880 "Go to previous N'th summary line.
9881 If optional argument UNREAD is non-nil, only unread article is selected."
9883 (gnus-summary-next-subject (- n) unread))
9885 (defun gnus-summary-prev-unread-subject (n)
9886 "Go to previous N'th unread summary line."
9888 (gnus-summary-next-subject (- n) t))
9890 (defun gnus-summary-goto-subject (article &optional force silent)
9891 "Go the subject line of ARTICLE.
9892 If FORCE, also allow jumping to articles not currently shown."
9894 (data (gnus-data-find article)))
9895 ;; We read in the article if we have to.
9898 (gnus-summary-insert-subject article)
9899 (setq data (gnus-data-find article)))
9904 (gnus-message 3 "Can't find article %d" article))
9906 (goto-char (gnus-data-pos data))
9909 ;; Walking around summary lines with displaying articles.
9911 (defun gnus-summary-expand-window (&optional arg)
9912 "Make the summary buffer take up the entire Emacs frame.
9913 Given a prefix, will force an `article' buffer configuration."
9915 (gnus-set-global-variables)
9917 (gnus-configure-windows 'article 'force)
9918 (gnus-configure-windows 'summary 'force)))
9920 (defun gnus-summary-display-article (article &optional all-header)
9921 "Display ARTICLE in article buffer."
9922 (gnus-set-global-variables)
9926 (if gnus-summary-display-article-function
9927 (funcall gnus-summary-display-article-function article all-header)
9928 (gnus-article-prepare article all-header))
9929 (run-hooks 'gnus-select-article-hook)
9930 (gnus-summary-recenter)
9931 (gnus-summary-goto-subject article)
9932 (when gnus-use-trees
9933 (gnus-possibly-generate-tree article)
9934 (gnus-highlight-selected-tree article))
9935 ;; Successfully display article.
9936 (gnus-article-set-window-start
9937 (cdr (assq article gnus-newsgroup-bookmarks)))
9940 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9941 "Select the current article.
9942 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9943 non-nil, the article will be re-fetched even if it already present in
9944 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9946 (let ((article (or article (gnus-summary-article-number)))
9947 (all-headers (not (not all-headers))) ;Must be T or NIL.
9948 gnus-summary-display-article-function
9951 (gnus-summary-article-pseudo-p article)
9952 (error "This is a pseudo-article."))
9955 (set-buffer gnus-summary-buffer)
9956 (if (or (and gnus-single-article-buffer
9957 (or (null gnus-current-article)
9958 (null gnus-article-current)
9959 (null (get-buffer gnus-article-buffer))
9960 (not (eq article (cdr gnus-article-current)))
9961 (not (equal (car gnus-article-current)
9962 gnus-newsgroup-name))))
9963 (and (not gnus-single-article-buffer)
9964 (null gnus-current-article))
9966 ;; The requested article is different from the current article.
9968 (gnus-summary-display-article article all-headers)
9970 (if (or all-headers gnus-show-all-headers)
9971 (gnus-article-show-all-headers))
9974 (gnus-article-set-window-start
9975 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9977 (defun gnus-summary-set-current-mark (&optional current-mark)
9978 "Obsolete function."
9981 (defun gnus-summary-next-article (&optional unread subject backward push)
9982 "Select the next article.
9983 If UNREAD, only unread articles are selected.
9984 If SUBJECT, only articles with SUBJECT are selected.
9985 If BACKWARD, the previous article is selected instead of the next."
9987 (gnus-set-global-variables)
9990 ;; Is there such an article?
9991 ((and (gnus-summary-search-forward unread subject backward)
9992 (or (gnus-summary-display-article (gnus-summary-article-number))
9993 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9994 (gnus-summary-position-point))
9995 ;; If not, we try the first unread, if that is wanted.
9997 gnus-auto-select-same
9998 (or (gnus-summary-first-unread-article)
9999 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10000 (gnus-summary-position-point)
10001 (gnus-message 6 "Wrapped"))
10002 ;; Try to get next/previous article not displayed in this group.
10003 ((and gnus-auto-extend-newsgroup
10004 (not unread) (not subject))
10005 (gnus-summary-goto-article
10006 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10008 ;; Go to next/previous group.
10010 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10011 (gnus-summary-jump-to-group gnus-newsgroup-name))
10012 (let ((cmd last-command-char)
10014 (if (eq gnus-keep-same-level 'best)
10015 (gnus-summary-best-group gnus-newsgroup-name)
10016 (gnus-summary-search-group backward gnus-keep-same-level))))
10017 ;; For some reason, the group window gets selected. We change
10019 (select-window (get-buffer-window (current-buffer)))
10020 ;; Select next unread newsgroup automagically.
10022 ((not gnus-auto-select-next)
10023 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10024 ((or (eq gnus-auto-select-next 'quietly)
10025 (and (eq gnus-auto-select-next 'slightly-quietly)
10027 (and (eq gnus-auto-select-next 'almost-quietly)
10028 (gnus-summary-last-article-p)))
10030 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10031 (gnus-summary-exit)
10032 (gnus-message 7 "No more%s articles (%s)..."
10033 (if unread " unread" "")
10034 (if group (concat "selecting " group)
10036 (gnus-summary-next-group nil group backward)))
10038 (gnus-summary-walk-group-buffer
10039 gnus-newsgroup-name cmd unread backward))))))))
10041 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10042 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10043 (?\C-p (gnus-group-prev-unread-group 1))))
10044 keve key group ended)
10046 (set-buffer gnus-group-buffer)
10047 (gnus-summary-jump-to-group from-group)
10049 (if (eq gnus-keep-same-level 'best)
10050 (gnus-summary-best-group gnus-newsgroup-name)
10051 (gnus-summary-search-group backward gnus-keep-same-level))))
10054 5 "No more%s articles%s" (if unread " unread" "")
10056 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10057 (format " (Type %s for %s [%s])"
10058 (single-key-description cmd) group
10059 (car (gnus-gethash group gnus-newsrc-hashtb)))
10060 (format " (Type %s to exit %s)"
10061 (single-key-description cmd)
10062 gnus-newsgroup-name)))
10063 ;; Confirm auto selection.
10064 (setq key (car (setq keve (gnus-read-event-char))))
10067 ((assq key keystrokes)
10068 (let ((obuf (current-buffer)))
10069 (switch-to-buffer gnus-group-buffer)
10071 (gnus-group-jump-to-group group))
10072 (eval (car (cdr (assq key keystrokes))))
10073 (setq group (gnus-group-group-name))
10074 (switch-to-buffer obuf))
10077 (if (or (not group)
10078 (gnus-ephemeral-group-p gnus-newsgroup-name))
10079 (gnus-summary-exit)
10080 (gnus-summary-next-group nil group backward)))
10082 (push (cdr keve) unread-command-events))))))
10084 (defun gnus-read-event-char ()
10085 "Get the next event."
10086 (let ((event (read-event)))
10087 (cons (and (numberp event) event) event)))
10089 (defun gnus-summary-next-unread-article ()
10090 "Select unread article after current one."
10092 (gnus-summary-next-article t (and gnus-auto-select-same
10093 (gnus-summary-article-subject))))
10095 (defun gnus-summary-prev-article (&optional unread subject)
10096 "Select the article after the current one.
10097 If UNREAD is non-nil, only unread articles are selected."
10099 (gnus-summary-next-article unread subject t))
10101 (defun gnus-summary-prev-unread-article ()
10102 "Select unred article before current one."
10104 (gnus-summary-prev-article t (and gnus-auto-select-same
10105 (gnus-summary-article-subject))))
10107 (defun gnus-summary-next-page (&optional lines circular)
10108 "Show next page of the selected article.
10109 If at the end of the current article, select the next article.
10110 LINES says how many lines should be scrolled up.
10112 If CIRCULAR is non-nil, go to the start of the article instead of
10113 selecting the next article when reaching the end of the current
10116 (setq gnus-summary-buffer (current-buffer))
10117 (gnus-set-global-variables)
10118 (let ((article (gnus-summary-article-number))
10120 (gnus-configure-windows 'article)
10121 (if (or (null gnus-current-article)
10122 (null gnus-article-current)
10123 (/= article (cdr gnus-article-current))
10124 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10125 ;; Selected subject is different from current article's.
10126 (gnus-summary-display-article article)
10127 (gnus-eval-in-buffer-window
10128 gnus-article-buffer
10129 (setq endp (gnus-article-next-page lines)))
10132 (gnus-summary-beginning-of-article))
10134 (gnus-message 3 "End of message"))
10136 (if (and (eq gnus-summary-goto-unread 'never)
10137 (not (eq article gnus-newsgroup-end)))
10138 (gnus-summary-next-article)
10139 (gnus-summary-next-unread-article))))))
10140 (gnus-summary-recenter)
10141 (gnus-summary-position-point)))
10143 (defun gnus-summary-prev-page (&optional lines)
10144 "Show previous page of selected article.
10145 Argument LINES specifies lines to be scrolled down."
10147 (gnus-set-global-variables)
10148 (let ((article (gnus-summary-article-number)))
10149 (gnus-configure-windows 'article)
10150 (if (or (null gnus-current-article)
10151 (null gnus-article-current)
10152 (/= article (cdr gnus-article-current))
10153 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10154 ;; Selected subject is different from current article's.
10155 (gnus-summary-display-article article)
10156 (gnus-summary-recenter)
10157 (gnus-eval-in-buffer-window gnus-article-buffer
10158 (gnus-article-prev-page lines))))
10159 (gnus-summary-position-point))
10161 (defun gnus-summary-scroll-up (lines)
10162 "Scroll up (or down) one line current article.
10163 Argument LINES specifies lines to be scrolled up (or down if negative)."
10165 (gnus-set-global-variables)
10166 (gnus-configure-windows 'article)
10167 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10168 (gnus-eval-in-buffer-window
10169 gnus-article-buffer
10171 (if (gnus-article-next-page lines)
10172 (gnus-message 3 "End of message")))
10174 (gnus-article-prev-page (- lines))))))
10175 (gnus-summary-recenter)
10176 (gnus-summary-position-point))
10178 (defun gnus-summary-next-same-subject ()
10179 "Select next article which has the same subject as current one."
10181 (gnus-set-global-variables)
10182 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10184 (defun gnus-summary-prev-same-subject ()
10185 "Select previous article which has the same subject as current one."
10187 (gnus-set-global-variables)
10188 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10190 (defun gnus-summary-next-unread-same-subject ()
10191 "Select next unread article which has the same subject as current one."
10193 (gnus-set-global-variables)
10194 (gnus-summary-next-article t (gnus-summary-article-subject)))
10196 (defun gnus-summary-prev-unread-same-subject ()
10197 "Select previous unread article which has the same subject as current one."
10199 (gnus-set-global-variables)
10200 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10202 (defun gnus-summary-first-unread-article ()
10203 "Select the first unread article.
10204 Return nil if there are no unread articles."
10206 (gnus-set-global-variables)
10208 (if (gnus-summary-first-subject t)
10210 (gnus-summary-show-thread)
10211 (gnus-summary-first-subject t)
10212 (gnus-summary-display-article (gnus-summary-article-number))))
10213 (gnus-summary-position-point)))
10215 (defun gnus-summary-best-unread-article ()
10216 "Select the unread article with the highest score."
10218 (gnus-set-global-variables)
10219 (let ((best -1000000)
10220 (data gnus-newsgroup-data)
10223 (and (gnus-data-unread-p (car data))
10225 (gnus-summary-article-score (gnus-data-number (car data))))
10228 article (gnus-data-number (car data))))
10229 (setq data (cdr data)))
10231 (gnus-summary-goto-article article)
10232 (error "No unread articles"))
10233 (gnus-summary-position-point)))
10235 (defun gnus-summary-last-subject ()
10236 "Go to the last displayed subject line in the group."
10237 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10239 (gnus-summary-goto-subject article))))
10241 (defun gnus-summary-goto-article (article &optional all-headers force)
10242 "Fetch ARTICLE and display it if it exists.
10243 If ALL-HEADERS is non-nil, no header lines are hidden."
10249 (mapcar (lambda (number) (list (int-to-string number)))
10250 gnus-newsgroup-limit)))
10254 (if (gnus-summary-goto-subject article force)
10255 (gnus-summary-display-article article all-headers)
10256 (gnus-message 4 "Couldn't go to article %s" article) nil)
10257 (gnus-summary-position-point)))
10259 (defun gnus-summary-goto-last-article ()
10260 "Go to the previously read article."
10263 (and gnus-last-article
10264 (gnus-summary-goto-article gnus-last-article))
10265 (gnus-summary-position-point)))
10267 (defun gnus-summary-pop-article (number)
10268 "Pop one article off the history and go to the previous.
10269 NUMBER articles will be popped off."
10272 (setq gnus-newsgroup-history
10273 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10275 (gnus-summary-goto-article (car to))
10276 (error "Article history empty")))
10277 (gnus-summary-position-point))
10279 ;; Summary commands and functions for limiting the summary buffer.
10281 (defun gnus-summary-limit-to-articles (n)
10282 "Limit the summary buffer to the next N articles.
10283 If not given a prefix, use the process marked articles instead."
10285 (gnus-set-global-variables)
10287 (let ((articles (gnus-summary-work-articles n)))
10288 (setq gnus-newsgroup-processable nil)
10289 (gnus-summary-limit articles))
10290 (gnus-summary-position-point)))
10292 (defun gnus-summary-pop-limit (&optional total)
10293 "Restore the previous limit.
10294 If given a prefix, remove all limits."
10296 (gnus-set-global-variables)
10298 (setq gnus-newsgroup-limits
10299 (list (mapcar (lambda (h) (mail-header-number h))
10300 gnus-newsgroup-headers))))
10301 (unless gnus-newsgroup-limits
10302 (error "No limit to pop"))
10304 (gnus-summary-limit nil 'pop)
10305 (gnus-summary-position-point)))
10307 (defun gnus-summary-limit-to-subject (subject &optional header)
10308 "Limit the summary buffer to articles that have subjects that match a regexp."
10309 (interactive "sRegexp: ")
10311 (setq header "subject"))
10312 (when (not (equal "" subject))
10314 (let ((articles (gnus-summary-find-matching
10315 (or header "subject") subject 'all)))
10316 (or articles (error "Found no matches for \"%s\"" subject))
10317 (gnus-summary-limit articles))
10318 (gnus-summary-position-point))))
10320 (defun gnus-summary-limit-to-author (from)
10321 "Limit the summary buffer to articles that have authors that match a regexp."
10322 (interactive "sRegexp: ")
10323 (gnus-summary-limit-to-subject from "from"))
10325 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10327 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10329 (defun gnus-summary-limit-to-unread (&optional all)
10330 "Limit the summary buffer to articles that are not marked as read.
10331 If ALL is non-nil, limit strictly to unread articles."
10334 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10335 (gnus-summary-limit-to-marks
10336 ;; Concat all the marks that say that an article is read and have
10338 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10339 gnus-killed-mark gnus-kill-file-mark
10340 gnus-low-score-mark gnus-expirable-mark
10341 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10344 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10345 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10347 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10348 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10349 If REVERSE, limit the summary buffer to articles that are not marked
10350 with MARKS. MARKS can either be a string of marks or a list of marks.
10351 Returns how many articles were removed."
10352 (interactive "sMarks: ")
10353 (gnus-set-global-variables)
10355 (let ((data gnus-newsgroup-data)
10356 (marks (if (listp marks) marks
10357 (append marks nil))) ; Transform to list.
10360 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10361 (memq (gnus-data-mark (car data)) marks))
10362 (setq articles (cons (gnus-data-number (car data)) articles)))
10363 (setq data (cdr data)))
10364 (gnus-summary-limit articles))
10365 (gnus-summary-position-point)))
10367 (defun gnus-summary-limit-to-score (&optional score)
10368 "Limit to articles with score at or above SCORE."
10370 (gnus-set-global-variables)
10371 (setq score (if score
10372 (prefix-numeric-value score)
10373 (or gnus-summary-default-score 0)))
10374 (let ((data gnus-newsgroup-data)
10377 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10379 (push (gnus-data-number (car data)) articles))
10380 (setq data (cdr data)))
10382 (gnus-summary-limit articles)
10383 (gnus-summary-position-point))))
10385 (defun gnus-summary-limit-include-dormant ()
10386 "Display all the hidden articles that are marked as dormant."
10388 (gnus-set-global-variables)
10389 (or gnus-newsgroup-dormant
10390 (error "There are no dormant articles in this group"))
10392 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10393 (gnus-summary-position-point)))
10395 (defun gnus-summary-limit-exclude-dormant ()
10396 "Hide all dormant articles."
10398 (gnus-set-global-variables)
10400 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10401 (gnus-summary-position-point)))
10403 (defun gnus-summary-limit-exclude-childless-dormant ()
10404 "Hide all dormant articles that have no children."
10406 (gnus-set-global-variables)
10407 (let ((data (gnus-data-list t))
10408 articles d children)
10409 ;; Find all articles that are either not dormant or have
10411 (while (setq d (pop data))
10412 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10413 (and (setq children
10414 (gnus-article-children (gnus-data-number d)))
10417 (when (memq (car children) articles)
10422 (push (gnus-data-number d) articles)))
10423 ;; Do the limiting.
10425 (gnus-summary-limit articles)
10426 (gnus-summary-position-point))))
10428 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10429 "Mark all unread excluded articles as read.
10430 If ALL, mark even excluded ticked and dormants as read."
10432 (let ((articles (gnus-sorted-complement
10434 (mapcar (lambda (h) (mail-header-number h))
10435 gnus-newsgroup-headers)
10437 (sort gnus-newsgroup-limit '<)))
10439 (setq gnus-newsgroup-unreads nil)
10441 (setq gnus-newsgroup-dormant nil
10442 gnus-newsgroup-marked nil
10443 gnus-newsgroup-reads
10445 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10446 gnus-newsgroup-reads))
10447 (while (setq article (pop articles))
10448 (unless (or (memq article gnus-newsgroup-dormant)
10449 (memq article gnus-newsgroup-marked))
10450 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10452 (defun gnus-summary-limit (articles &optional pop)
10454 ;; We pop the previous limit off the stack and use that.
10455 (setq articles (car gnus-newsgroup-limits)
10456 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10457 ;; We use the new limit, so we push the old limit on the stack.
10458 (setq gnus-newsgroup-limits
10459 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10461 (setq gnus-newsgroup-limit articles)
10462 (let ((total (length gnus-newsgroup-data))
10463 (data (gnus-data-find-list (gnus-summary-article-number)))
10465 ;; This will do all the work of generating the new summary buffer
10466 ;; according to the new limit.
10467 (gnus-summary-prepare)
10468 ;; Hide any threads, possibly.
10469 (and gnus-show-threads
10470 gnus-thread-hide-subtree
10471 (gnus-summary-hide-all-threads))
10472 ;; Try to return to the article you were at, or one in the
10475 ;; We try to find some article after the current one.
10477 (and (gnus-summary-goto-subject
10478 (gnus-data-number (car data)) nil t)
10481 (setq data (cdr data))))
10483 ;; If there is no data, that means that we were after the last
10484 ;; article. The same goes when we can't find any articles
10485 ;; after the current one.
10487 (goto-char (point-max))
10488 (gnus-summary-find-prev)))
10489 ;; We return how many articles were removed from the summary
10490 ;; buffer as a result of the new limit.
10491 (- total (length gnus-newsgroup-data))))
10493 (defsubst gnus-cut-thread (thread)
10494 "Go forwards in the thread until we find an article that we want to display."
10495 (if (eq gnus-fetch-old-headers 'some)
10497 (memq (mail-header-number (car thread))
10498 gnus-newsgroup-ancient)
10499 (<= (length (cdr thread)) 1))
10500 (setq thread (cadr thread)))
10502 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10503 (= (length (cdr thread)) 1))
10504 (setq thread (cadr thread))))
10507 (defun gnus-cut-threads (threads)
10508 "Cut off all uninteresting articles from the beginning of threads."
10509 (when (or (eq gnus-fetch-old-headers 'some)
10510 (eq gnus-build-sparse-threads 'some)
10511 (eq gnus-build-sparse-threads 'more))
10512 (let ((th threads))
10514 (setcar th (gnus-cut-thread (car th)))
10515 (setq th (cdr th)))))
10518 (defun gnus-summary-initial-limit (&optional show-if-empty)
10519 "Figure out what the initial limit is supposed to be on group entry.
10520 This entails weeding out unwanted dormants, low-scored articles,
10521 fetch-old-headers verbiage, and so on."
10522 ;; Most groups have nothing to remove.
10523 (if (or gnus-inhibit-limiting
10524 (and (null gnus-newsgroup-dormant)
10525 (not (eq gnus-fetch-old-headers 'some))
10526 (null gnus-summary-expunge-below)
10527 (not (eq gnus-build-sparse-threads 'some))
10528 (not (eq gnus-build-sparse-threads 'more))
10529 (null gnus-thread-expunge-below)
10530 (not gnus-use-nocem)))
10532 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10533 (setq gnus-newsgroup-limit nil)
10536 (unless (car (symbol-value node))
10537 ;; These threads have no parents -- they are roots.
10538 (let ((nodes (cdr (symbol-value node)))
10541 (if (and gnus-thread-expunge-below
10542 (< (gnus-thread-total-score (car nodes))
10543 gnus-thread-expunge-below))
10544 (gnus-expunge-thread (pop nodes))
10545 (setq thread (pop nodes))
10546 (gnus-summary-limit-children thread))))))
10547 gnus-newsgroup-dependencies)
10548 ;; If this limitation resulted in an empty group, we might
10549 ;; pop the previous limit and use it instead.
10550 (when (and (not gnus-newsgroup-limit)
10552 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10553 gnus-newsgroup-limit))
10555 (defun gnus-summary-limit-children (thread)
10556 "Return 1 if this subthread is visible and 0 if it is not."
10557 ;; First we get the number of visible children to this thread. This
10558 ;; is done by recursing down the thread using this function, so this
10559 ;; will really go down to a leaf article first, before slowly
10560 ;; working its way up towards the root.
10564 (apply '+ (mapcar 'gnus-summary-limit-children
10567 (number (mail-header-number (car thread)))
10570 ;; If this article is dormant and has absolutely no visible
10571 ;; children, then this article isn't visible.
10572 (and (memq number gnus-newsgroup-dormant)
10574 ;; If this is a "fetch-old-headered" and there is only one
10575 ;; visible child (or less), then we don't want this article.
10576 (and (eq gnus-fetch-old-headers 'some)
10577 (memq number gnus-newsgroup-ancient)
10579 ;; If this is a sparsely inserted article with no children,
10580 ;; we don't want it.
10581 (and (eq gnus-build-sparse-threads 'some)
10582 (memq number gnus-newsgroup-sparse)
10584 ;; If we use expunging, and this article is really
10585 ;; low-scored, then we don't want this article.
10586 (when (and gnus-summary-expunge-below
10588 (or (cdr (assq number gnus-newsgroup-scored))
10589 gnus-summary-default-score))
10590 gnus-summary-expunge-below))
10591 ;; We increase the expunge-tally here, but that has
10592 ;; nothing to do with the limits, really.
10593 (incf gnus-newsgroup-expunged-tally)
10594 ;; We also mark as read here, if that's wanted.
10595 (when (and gnus-summary-mark-below
10596 (< score gnus-summary-mark-below))
10597 (setq gnus-newsgroup-unreads
10598 (delq number gnus-newsgroup-unreads))
10599 (if gnus-newsgroup-auto-expire
10600 (push number gnus-newsgroup-expirable)
10601 (push (cons number gnus-low-score-mark)
10602 gnus-newsgroup-reads)))
10604 (and gnus-use-nocem
10605 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10606 ;; Nope, invisible article.
10608 ;; Ok, this article is to be visible, so we add it to the limit
10610 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10613 (defun gnus-expunge-thread (thread)
10614 "Mark all articles in THREAD as read."
10615 (let* ((number (mail-header-number (car thread))))
10616 (incf gnus-newsgroup-expunged-tally)
10617 ;; We also mark as read here, if that's wanted.
10618 (setq gnus-newsgroup-unreads
10619 (delq number gnus-newsgroup-unreads))
10620 (if gnus-newsgroup-auto-expire
10621 (push number gnus-newsgroup-expirable)
10622 (push (cons number gnus-low-score-mark)
10623 gnus-newsgroup-reads)))
10624 ;; Go recursively through all subthreads.
10625 (mapcar 'gnus-expunge-thread (cdr thread)))
10627 ;; Summary article oriented commands
10629 (defun gnus-summary-refer-parent-article (n)
10630 "Refer parent article N times.
10631 The difference between N and the number of articles fetched is returned."
10633 (gnus-set-global-variables)
10637 (let* ((header (gnus-summary-article-header))
10639 ;; If we try to find the parent of the currently
10640 ;; displayed article, then we take a look at the actual
10641 ;; References header, since this is slightly more
10642 ;; reliable than the References field we got from the
10644 (if (and (eq (mail-header-number header)
10645 (cdr gnus-article-current))
10646 (equal gnus-newsgroup-name
10647 (car gnus-article-current)))
10649 (set-buffer gnus-original-article-buffer)
10650 (nnheader-narrow-to-headers)
10652 (mail-fetch-field "references")
10654 ;; It's not the current article, so we take a bet on
10655 ;; the value we got from the server.
10656 (mail-header-references header))))
10657 (if (setq ref (or ref (mail-header-references header)))
10658 (or (gnus-summary-refer-article (gnus-parent-id ref))
10659 (gnus-message 1 "Couldn't find parent"))
10660 (gnus-message 1 "No references in article %d"
10661 (gnus-summary-article-number))
10664 (gnus-summary-position-point)
10667 (defun gnus-summary-refer-references ()
10668 "Fetch all articles mentioned in the References header.
10669 Return how many articles were fetched."
10671 (gnus-set-global-variables)
10672 (let ((ref (mail-header-references (gnus-summary-article-header)))
10673 (current (gnus-summary-article-number))
10675 ;; For each Message-ID in the References header...
10676 (while (string-match "<[^>]*>" ref)
10678 ;; ... fetch that article.
10679 (gnus-summary-refer-article
10680 (prog1 (match-string 0 ref)
10681 (setq ref (substring ref (match-end 0))))))
10682 (gnus-summary-goto-subject current)
10683 (gnus-summary-position-point)
10686 (defun gnus-summary-refer-article (message-id)
10687 "Fetch an article specified by MESSAGE-ID."
10688 (interactive "sMessage-ID: ")
10689 (when (and (stringp message-id)
10690 (not (zerop (length message-id))))
10691 ;; Construct the correct Message-ID if necessary.
10692 ;; Suggested by tale@pawl.rpi.edu.
10693 (unless (string-match "^<" message-id)
10694 (setq message-id (concat "<" message-id)))
10695 (unless (string-match ">$" message-id)
10696 (setq message-id (concat message-id ">")))
10697 (let ((header (car (gnus-gethash (downcase message-id)
10698 gnus-newsgroup-dependencies))))
10700 ;; The article is present in the buffer, to we just go to it.
10701 (gnus-summary-goto-article (mail-header-number header) nil t)
10702 ;; We fetch the article
10703 (let ((gnus-override-method gnus-refer-article-method)
10705 ;; Start the special refer-article method, if necessary.
10706 (when gnus-refer-article-method
10707 (gnus-check-server gnus-refer-article-method))
10708 ;; Fetch the header, and display the article.
10709 (if (setq number (gnus-summary-insert-subject message-id))
10710 (gnus-summary-select-article nil nil nil number)
10711 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10713 (defun gnus-summary-enter-digest-group (&optional force)
10714 "Enter a digest group based on the current article."
10716 (gnus-set-global-variables)
10717 (gnus-summary-select-article)
10718 (let ((name (format "%s-%d"
10719 (gnus-group-prefixed-name
10720 gnus-newsgroup-name (list 'nndoc ""))
10721 gnus-current-article))
10722 (ogroup gnus-newsgroup-name)
10723 (case-fold-search t)
10724 (buf (current-buffer))
10727 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10728 (insert-buffer-substring gnus-original-article-buffer)
10730 (goto-char (point-min))
10731 (or (search-forward "\n\n" nil t) (point)))
10732 (goto-char (point-min))
10733 (delete-matching-lines "^\\(Path\\):\\|^From ")
10736 (if (gnus-group-read-ephemeral-group
10737 name `(nndoc ,name (nndoc-address
10739 (nndoc-article-type ,(if force 'digest 'guess))) t)
10740 ;; Make all postings to this group go to the parent group.
10741 (nconc (gnus-info-params (gnus-get-info name))
10742 (list (cons 'to-group ogroup)))
10743 ;; Couldn't select this doc group.
10744 (switch-to-buffer buf)
10745 (gnus-set-global-variables)
10746 (gnus-configure-windows 'summary)
10747 (gnus-message 3 "Article couldn't be entered?"))
10748 (kill-buffer dig))))
10750 (defun gnus-summary-isearch-article (&optional regexp-p)
10751 "Do incremental search forward on the current article.
10752 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10754 (gnus-set-global-variables)
10755 (gnus-summary-select-article)
10756 (gnus-configure-windows 'article)
10757 (gnus-eval-in-buffer-window
10758 gnus-article-buffer
10759 (goto-char (point-min))
10760 (isearch-forward regexp-p)))
10762 (defun gnus-summary-search-article-forward (regexp &optional backward)
10763 "Search for an article containing REGEXP forward.
10764 If BACKWARD, search backward instead."
10767 (format "Search article %s (regexp%s): "
10768 (if current-prefix-arg "backward" "forward")
10769 (if gnus-last-search-regexp
10770 (concat ", default " gnus-last-search-regexp)
10772 current-prefix-arg))
10773 (gnus-set-global-variables)
10774 (if (string-equal regexp "")
10775 (setq regexp (or gnus-last-search-regexp ""))
10776 (setq gnus-last-search-regexp regexp))
10777 (if (gnus-summary-search-article regexp backward)
10778 (gnus-article-set-window-start
10779 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10780 (error "Search failed: \"%s\"" regexp)))
10782 (defun gnus-summary-search-article-backward (regexp)
10783 "Search for an article containing REGEXP backward."
10786 (format "Search article backward (regexp%s): "
10787 (if gnus-last-search-regexp
10788 (concat ", default " gnus-last-search-regexp)
10790 (gnus-summary-search-article-forward regexp 'backward))
10792 (defun gnus-summary-search-article (regexp &optional backward)
10793 "Search for an article containing REGEXP.
10794 Optional argument BACKWARD means do search for backward.
10795 gnus-select-article-hook is not called during the search."
10796 (let ((gnus-select-article-hook nil) ;Disable hook.
10797 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10800 (function re-search-backward) (function re-search-forward)))
10803 ;; Hidden thread subtrees must be searched for ,too.
10804 (gnus-summary-show-all-threads)
10805 ;; First of all, search current article.
10806 ;; We don't want to read article again from NNTP server nor reset
10808 (gnus-summary-select-article)
10809 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10810 (setq last gnus-current-article)
10811 (gnus-eval-in-buffer-window
10812 gnus-article-buffer
10815 ;; Begin search from current point.
10816 (setq found (funcall re-search regexp nil t))))
10817 ;; Then search next articles.
10818 (while (and (not found)
10819 (gnus-summary-display-article
10820 (if backward (gnus-summary-find-prev)
10821 (gnus-summary-find-next))))
10822 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10823 (gnus-eval-in-buffer-window
10824 gnus-article-buffer
10827 (goto-char (if backward (point-max) (point-min)))
10828 (setq found (funcall re-search regexp nil t)))))
10830 ;; Adjust article pointer.
10831 (or (eq last gnus-current-article)
10832 (setq gnus-last-article last))
10833 ;; Return T if found such article.
10836 (defun gnus-summary-find-matching (header regexp &optional backward unread
10838 "Return a list of all articles that match REGEXP on HEADER.
10839 The search stars on the current article and goes forwards unless
10840 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10841 If UNREAD is non-nil, only unread articles will
10842 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10843 in the comparisons."
10844 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10845 (gnus-data-find-list
10846 (gnus-summary-article-number) (gnus-data-list backward))))
10847 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10848 (case-fold-search (not not-case-fold))
10850 (or (fboundp (intern (concat "mail-header-" header)))
10851 (error "%s is not a valid header" header))
10853 (setq d (car data))
10854 (and (or (not unread) ; We want all articles...
10855 (gnus-data-unread-p d)) ; Or just unreads.
10856 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10857 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10858 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10859 (setq data (cdr data)))
10860 (nreverse articles)))
10862 (defun gnus-summary-execute-command (header regexp command &optional backward)
10863 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10864 If HEADER is an empty string (or nil), the match is done on the entire
10865 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10867 (list (let ((completion-ignore-case t))
10870 (mapcar (lambda (string) (list string))
10871 '("Number" "Subject" "From" "Lines" "Date"
10872 "Message-ID" "Xref" "References" "Body"))
10873 nil 'require-match))
10874 (read-string "Regexp: ")
10875 (read-key-sequence "Command: ")
10876 current-prefix-arg))
10877 (when (equal header "Body")
10879 (gnus-set-global-variables)
10880 ;; Hidden thread subtrees must be searched as well.
10881 (gnus-summary-show-all-threads)
10882 ;; We don't want to change current point nor window configuration.
10884 (save-window-excursion
10885 (gnus-message 6 "Executing %s..." (key-description command))
10886 ;; We'd like to execute COMMAND interactively so as to give arguments.
10887 (gnus-execute header regexp
10888 `(lambda () (call-interactively ',(key-binding command)))
10890 (gnus-message 6 "Executing %s...done" (key-description command)))))
10892 (defun gnus-summary-beginning-of-article ()
10893 "Scroll the article back to the beginning."
10895 (gnus-set-global-variables)
10896 (gnus-summary-select-article)
10897 (gnus-configure-windows 'article)
10898 (gnus-eval-in-buffer-window
10899 gnus-article-buffer
10901 (goto-char (point-min))
10902 (and gnus-break-pages (gnus-narrow-to-page))))
10904 (defun gnus-summary-end-of-article ()
10905 "Scroll to the end of the article."
10907 (gnus-set-global-variables)
10908 (gnus-summary-select-article)
10909 (gnus-configure-windows 'article)
10910 (gnus-eval-in-buffer-window
10911 gnus-article-buffer
10913 (goto-char (point-max))
10915 (and gnus-break-pages (gnus-narrow-to-page))))
10917 (defun gnus-summary-show-article (&optional arg)
10918 "Force re-fetching of the current article.
10919 If ARG (the prefix) is non-nil, show the raw article without any
10920 article massaging functions being run."
10922 (gnus-set-global-variables)
10924 ;; Select the article the normal way.
10925 (gnus-summary-select-article nil 'force)
10926 ;; Bind the article treatment functions to nil.
10927 (let ((gnus-have-all-headers t)
10928 gnus-article-display-hook
10929 gnus-article-prepare-hook
10931 (gnus-summary-select-article nil 'force)))
10932 ; (gnus-configure-windows 'article)
10933 (gnus-summary-position-point))
10935 (defun gnus-summary-verbose-headers (&optional arg)
10936 "Toggle permanent full header display.
10937 If ARG is a positive number, turn header display on.
10938 If ARG is a negative number, turn header display off."
10940 (gnus-set-global-variables)
10941 (gnus-summary-toggle-header arg)
10942 (setq gnus-show-all-headers
10943 (cond ((or (not (numberp arg))
10945 (not gnus-show-all-headers))
10949 (defun gnus-summary-toggle-header (&optional arg)
10950 "Show the headers if they are hidden, or hide them if they are shown.
10951 If ARG is a positive number, show the entire header.
10952 If ARG is a negative number, hide the unwanted header lines."
10954 (gnus-set-global-variables)
10956 (set-buffer gnus-article-buffer)
10957 (let* ((buffer-read-only nil)
10958 (inhibit-point-motion-hooks t)
10959 (hidden (text-property-any
10960 (goto-char (point-min)) (search-forward "\n\n")
10963 (goto-char (point-min))
10964 (when (search-forward "\n\n" nil t)
10965 (delete-region (point-min) (1- (point))))
10966 (goto-char (point-min))
10968 (set-buffer gnus-original-article-buffer)
10969 (goto-char (point-min))
10970 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10971 (insert-buffer-substring gnus-original-article-buffer 1 e)
10972 (let ((gnus-inhibit-hiding t))
10973 (run-hooks 'gnus-article-display-hook))
10974 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10975 (gnus-article-hide-headers)))))
10977 (defun gnus-summary-show-all-headers ()
10978 "Make all header lines visible."
10980 (gnus-set-global-variables)
10981 (gnus-article-show-all-headers))
10983 (defun gnus-summary-toggle-mime (&optional arg)
10984 "Toggle MIME processing.
10985 If ARG is a positive number, turn MIME processing on."
10987 (gnus-set-global-variables)
10988 (setq gnus-show-mime
10989 (if (null arg) (not gnus-show-mime)
10990 (> (prefix-numeric-value arg) 0)))
10991 (gnus-summary-select-article t 'force))
10993 (defun gnus-summary-caesar-message (&optional arg)
10994 "Caesar rotate the current article by 13.
10995 The numerical prefix specifies how manu places to rotate each letter
10998 (gnus-set-global-variables)
10999 (gnus-summary-select-article)
11000 (let ((mail-header-separator ""))
11001 (gnus-eval-in-buffer-window
11002 gnus-article-buffer
11005 (let ((start (window-start)))
11006 (news-caesar-buffer-body arg)
11007 (set-window-start (get-buffer-window (current-buffer)) start))))))
11009 (defun gnus-summary-stop-page-breaking ()
11010 "Stop page breaking in the current article."
11012 (gnus-set-global-variables)
11013 (gnus-summary-select-article)
11014 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11016 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11017 "Move the current article to a different newsgroup.
11018 If N is a positive number, move the N next articles.
11019 If N is a negative number, move the N previous articles.
11020 If N is nil and any articles have been marked with the process mark,
11021 move those articles instead.
11022 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11023 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11024 re-spool using this method.
11026 For this function to work, both the current newsgroup and the
11027 newsgroup that you want to move to have to support the `request-move'
11028 and `request-accept' functions."
11030 (unless action (setq action 'move))
11031 (gnus-set-global-variables)
11032 ;; Check whether the source group supports the required functions.
11033 (cond ((and (eq action 'move)
11034 (not (gnus-check-backend-function
11035 'request-move-article gnus-newsgroup-name)))
11036 (error "The current group does not support article moving"))
11037 ((and (eq action 'crosspost)
11038 (not (gnus-check-backend-function
11039 'request-replace-article gnus-newsgroup-name)))
11040 (error "The current group does not support article editing")))
11041 (let ((articles (gnus-summary-work-articles n))
11042 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11043 (names '((move "move" "Moving")
11044 (copy "copy" "Copying")
11045 (crosspost "crosspost" "Crossposting")))
11046 (copy-buf (save-excursion
11047 (nnheader-set-temp-buffer " *copy article*")))
11048 art-group to-method new-xref article)
11049 (unless (assq action names)
11050 (error "Unknown action %s" action))
11051 ;; Read the newsgroup name.
11052 (when (and (not to-newsgroup)
11053 (not select-method))
11055 (gnus-read-move-group-name
11056 (cadr (assq action names))
11057 gnus-current-move-group articles prefix))
11058 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11059 (setq to-method (if select-method (list select-method "")
11060 (gnus-find-method-for-group to-newsgroup)))
11061 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11062 ;;(error "Can't %s to the same group you're already in" action))
11063 ;; Check the method we are to move this article to...
11064 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11065 (error "%s does not support article copying" (car to-method)))
11066 (or (gnus-check-server to-method)
11067 (error "Can't open server %s" (car to-method)))
11068 (gnus-message 6 "%s to %s: %s..."
11069 (caddr (assq action names))
11070 (or select-method to-newsgroup) articles)
11072 (setq article (pop articles))
11076 ;; Move the article.
11078 (gnus-request-move-article
11079 article ; Article to move
11080 gnus-newsgroup-name ; From newsgrouo
11081 (nth 1 (gnus-find-method-for-group
11082 gnus-newsgroup-name)) ; Server
11083 (list 'gnus-request-accept-article
11085 (list 'quote select-method)
11087 (not articles)) ; Accept form
11088 (not articles))) ; Only save nov last time
11089 ;; Copy the article.
11092 (set-buffer copy-buf)
11093 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11094 (gnus-request-accept-article
11095 (if select-method select-method to-newsgroup)
11097 ;; Crosspost the article.
11098 ((eq action 'crosspost)
11099 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11100 (setq new-xref (concat gnus-newsgroup-name ":" article))
11101 (if (and xref (not (string= xref "")))
11103 (when (string-match "^Xref: " xref)
11104 (setq xref (substring xref (match-end 0))))
11105 (setq new-xref (concat xref " " new-xref)))
11106 (setq new-xref (concat (system-name) " " new-xref)))
11108 (set-buffer copy-buf)
11109 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11110 (nnheader-replace-header "xref" new-xref)
11111 (gnus-request-accept-article
11112 (if select-method select-method to-newsgroup)
11113 (not articles)))))))
11114 (if (not art-group)
11115 (gnus-message 1 "Couldn't %s article %s"
11116 (cadr (assq action names)) article)
11119 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11121 (gnus-group-prefixed-name
11123 (if select-method (list select-method "")
11124 (gnus-find-method-for-group to-newsgroup)))
11125 gnus-newsrc-hashtb)))
11126 (info (nth 2 entry)))
11127 ;; Update the group that has been moved to.
11129 (memq action '(move copy)))
11130 (unless (memq article gnus-newsgroup-unreads)
11131 (gnus-info-set-read
11132 info (gnus-add-to-range (gnus-info-read info)
11133 (list (cdr art-group)))))
11135 ;; Copy any marks over to the new group.
11136 (let ((marks gnus-article-mark-lists)
11137 (to-article (cdr art-group)))
11139 ;; See whether the article is to be put in the cache.
11140 (when gnus-use-cache
11141 (gnus-cache-possibly-enter-article
11142 (gnus-info-group info) to-article
11143 (let ((header (copy-sequence
11144 (gnus-summary-article-header article))))
11145 (mail-header-set-number header to-article)
11147 (memq article gnus-newsgroup-marked)
11148 (memq article gnus-newsgroup-dormant)
11149 (memq article gnus-newsgroup-unreads)))
11152 (when (memq article (symbol-value
11153 (intern (format "gnus-newsgroup-%s"
11155 (gnus-add-marked-articles
11156 (gnus-info-group info) (cdar marks)
11157 (list to-article) info))
11158 (setq marks (cdr marks)))))
11160 ;; Update the Xref header in this article to point to
11161 ;; the new crossposted article we have just created.
11162 (when (eq action 'crosspost)
11164 (set-buffer copy-buf)
11165 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11166 (nnheader-replace-header
11167 "xref" (concat new-xref " " (gnus-group-prefixed-name
11168 (car art-group) to-method)
11169 ":" (cdr art-group)))
11170 (gnus-request-replace-article
11171 article gnus-newsgroup-name (current-buffer)))))
11173 (gnus-summary-goto-subject article)
11174 (when (eq action 'move)
11175 (gnus-summary-mark-article article gnus-canceled-mark)))
11176 (gnus-summary-remove-process-mark article))
11177 (gnus-kill-buffer copy-buf)
11178 (gnus-summary-position-point)
11179 (gnus-set-mode-line 'summary)))
11181 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11182 "Move the current article to a different newsgroup.
11183 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11184 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11185 re-spool using this method."
11187 (gnus-summary-move-article n nil nil 'copy))
11189 (defun gnus-summary-crosspost-article (&optional n)
11190 "Crosspost the current article to some other group."
11192 (gnus-summary-move-article n nil nil 'crosspost))
11194 (defun gnus-summary-respool-article (&optional n respool-method)
11195 "Respool the current article.
11196 The article will be squeezed through the mail spooling process again,
11197 which means that it will be put in some mail newsgroup or other
11198 depending on `nnmail-split-methods'.
11199 If N is a positive number, respool the N next articles.
11200 If N is a negative number, respool the N previous articles.
11201 If N is nil and any articles have been marked with the process mark,
11202 respool those articles instead.
11204 Respooling can be done both from mail groups and \"real\" newsgroups.
11205 In the former case, the articles in question will be moved from the
11206 current group into whatever groups they are destined to. In the
11207 latter case, they will be copied into the relevant groups."
11209 (gnus-set-global-variables)
11210 (let ((respool-methods (gnus-methods-using 'respool))
11212 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11214 (setq respool-method
11216 "What method do you want to use when respooling? "
11217 respool-methods nil t methname)))
11218 (or (string= respool-method "")
11219 (if (assoc (symbol-name
11220 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11222 (gnus-summary-move-article n nil (intern respool-method))
11223 (gnus-summary-copy-article n nil (intern respool-method))))))
11225 (defun gnus-summary-import-article (file)
11226 "Import a random file into a mail newsgroup."
11227 (interactive "fImport file: ")
11228 (gnus-set-global-variables)
11229 (let ((group gnus-newsgroup-name)
11230 (now (current-time))
11232 (or (gnus-check-backend-function 'request-accept-article group)
11233 (error "%s does not support article importing" group))
11234 (or (file-readable-p file)
11235 (not (file-regular-p file))
11236 (error "Can't read %s" file))
11238 (set-buffer (get-buffer-create " *import file*"))
11239 (buffer-disable-undo (current-buffer))
11241 (insert-file-contents file)
11242 (goto-char (point-min))
11243 (unless (nnheader-article-p)
11244 ;; This doesn't look like an article, so we fudge some headers.
11245 (setq atts (file-attributes file)
11246 lines (count-lines (point-min) (point-max)))
11247 (insert "From: " (read-string "From: ") "\n"
11248 "Subject: " (read-string "Subject: ") "\n"
11249 "Date: " (timezone-make-date-arpa-standard
11250 (current-time-string (nth 5 atts))
11251 (current-time-zone now)
11252 (current-time-zone now)) "\n"
11253 "Message-ID: " (gnus-inews-message-id) "\n"
11254 "Lines: " (int-to-string lines) "\n"
11255 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11256 (gnus-request-accept-article group t)
11257 (kill-buffer (current-buffer)))))
11259 (defun gnus-summary-expire-articles ()
11260 "Expire all articles that are marked as expirable in the current group."
11262 (gnus-set-global-variables)
11263 (when (gnus-check-backend-function
11264 'request-expire-articles gnus-newsgroup-name)
11265 ;; This backend supports expiry.
11266 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11267 (expirable (if total
11268 (gnus-list-of-read-articles gnus-newsgroup-name)
11269 (setq gnus-newsgroup-expirable
11270 (sort gnus-newsgroup-expirable '<))))
11271 (expiry-wait (gnus-group-get-parameter
11272 gnus-newsgroup-name 'expiry-wait))
11275 ;; There are expirable articles in this group, so we run them
11276 ;; through the expiry process.
11277 (gnus-message 6 "Expiring articles...")
11278 ;; The list of articles that weren't expired is returned.
11280 (let ((nnmail-expiry-wait-function nil)
11281 (nnmail-expiry-wait expiry-wait))
11282 (setq es (gnus-request-expire-articles
11283 expirable gnus-newsgroup-name)))
11284 (setq es (gnus-request-expire-articles
11285 expirable gnus-newsgroup-name)))
11286 (or total (setq gnus-newsgroup-expirable es))
11287 ;; We go through the old list of expirable, and mark all
11288 ;; really expired articles as nonexistent.
11289 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11290 (let ((gnus-use-cache nil))
11292 (unless (memq (car expirable) es)
11293 (when (gnus-data-find (car expirable))
11294 (gnus-summary-mark-article
11295 (car expirable) gnus-canceled-mark)))
11296 (setq expirable (cdr expirable)))))
11297 (gnus-message 6 "Expiring articles...done")))))
11299 (defun gnus-summary-expire-articles-now ()
11300 "Expunge all expirable articles in the current group.
11301 This means that *all* articles that are marked as expirable will be
11302 deleted forever, right now."
11304 (gnus-set-global-variables)
11305 (or gnus-expert-user
11307 "Are you really, really, really sure you want to expunge? ")
11309 (let ((nnmail-expiry-wait 'immediate)
11310 (nnmail-expiry-wait-function nil))
11311 (gnus-summary-expire-articles)))
11313 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11314 (defun gnus-summary-delete-article (&optional n)
11315 "Delete the N next (mail) articles.
11316 This command actually deletes articles. This is not a marking
11317 command. The article will disappear forever from your life, never to
11319 If N is negative, delete backwards.
11320 If N is nil and articles have been marked with the process mark,
11321 delete these instead."
11323 (gnus-set-global-variables)
11324 (or (gnus-check-backend-function 'request-expire-articles
11325 gnus-newsgroup-name)
11326 (error "The current newsgroup does not support article deletion."))
11327 ;; Compute the list of articles to delete.
11328 (let ((articles (gnus-summary-work-articles n))
11330 (if (and gnus-novice-user
11331 (not (gnus-y-or-n-p
11332 (format "Do you really want to delete %s forever? "
11333 (if (> (length articles) 1) "these articles"
11334 "this article")))))
11336 ;; Delete the articles.
11337 (setq not-deleted (gnus-request-expire-articles
11338 articles gnus-newsgroup-name 'force))
11340 (gnus-summary-remove-process-mark (car articles))
11341 ;; The backend might not have been able to delete the article
11343 (or (memq (car articles) not-deleted)
11344 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11345 (setq articles (cdr articles))))
11346 (gnus-summary-position-point)
11347 (gnus-set-mode-line 'summary)
11350 (defun gnus-summary-edit-article (&optional force)
11351 "Enter into a buffer and edit the current article.
11352 This will have permanent effect only in mail groups.
11353 If FORCE is non-nil, allow editing of articles even in read-only
11357 (set-buffer gnus-summary-buffer)
11358 (gnus-set-global-variables)
11359 (when (and (not force)
11360 (gnus-group-read-only-p))
11361 (error "The current newsgroup does not support article editing."))
11362 (gnus-summary-select-article t nil t)
11363 (gnus-configure-windows 'article)
11364 (select-window (get-buffer-window gnus-article-buffer))
11365 (gnus-message 6 "C-c C-c to end edits")
11366 (setq buffer-read-only nil)
11368 (use-local-map (copy-keymap (current-local-map)))
11369 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11370 (buffer-enable-undo)
11372 (goto-char (point-min))
11373 (search-forward "\n\n" nil t)))
11375 (defun gnus-summary-edit-article-done ()
11376 "Make edits to the current article permanent."
11378 (if (gnus-group-read-only-p)
11380 (gnus-summary-edit-article-postpone)
11382 1 "The current newsgroup does not support article editing.")
11384 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
11387 (if (not (gnus-request-replace-article
11388 (cdr gnus-article-current) (car gnus-article-current)
11390 (error "Couldn't replace article.")
11391 (gnus-article-mode)
11392 (use-local-map gnus-article-mode-map)
11393 (setq buffer-read-only t)
11394 (buffer-disable-undo (current-buffer))
11395 (gnus-configure-windows 'summary)
11396 (gnus-summary-update-article (cdr gnus-article-current)))
11397 (run-hooks 'gnus-article-display-hook)
11398 (and (gnus-visual-p 'summary-highlight 'highlight)
11399 (run-hooks 'gnus-visual-mark-article-hook)))))
11401 (defun gnus-summary-edit-article-postpone ()
11402 "Postpone changes to the current article."
11404 (gnus-article-mode)
11405 (use-local-map gnus-article-mode-map)
11406 (setq buffer-read-only t)
11407 (buffer-disable-undo (current-buffer))
11408 (gnus-configure-windows 'summary)
11409 (and (gnus-visual-p 'summary-highlight 'highlight)
11410 (run-hooks 'gnus-visual-mark-article-hook)))
11412 (defun gnus-summary-respool-query ()
11413 "Query where the respool algorithm would put this article."
11415 (gnus-set-global-variables)
11416 (gnus-summary-select-article)
11418 (set-buffer gnus-article-buffer)
11420 (goto-char (point-min))
11421 (search-forward "\n\n")
11422 (narrow-to-region (point-min) (point))
11423 (pp-eval-expression
11424 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11426 ;; Summary score commands.
11428 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11430 (defun gnus-summary-raise-score (n)
11431 "Raise the score of the current article by N."
11433 (gnus-set-global-variables)
11434 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11436 (defun gnus-summary-set-score (n)
11437 "Set the score of the current article to N."
11439 (gnus-set-global-variables)
11441 (gnus-summary-show-thread)
11442 (let ((buffer-read-only nil))
11444 (gnus-summary-update-mark
11445 (if (= n (or gnus-summary-default-score 0)) ?
11446 (if (< n (or gnus-summary-default-score 0))
11447 gnus-score-below-mark gnus-score-over-mark)) 'score))
11448 (let* ((article (gnus-summary-article-number))
11449 (score (assq article gnus-newsgroup-scored)))
11450 (if score (setcdr score n)
11451 (setq gnus-newsgroup-scored
11452 (cons (cons article n) gnus-newsgroup-scored))))
11453 (gnus-summary-update-line)))
11455 (defun gnus-summary-current-score ()
11456 "Return the score of the current article."
11458 (gnus-set-global-variables)
11459 (message "%s" (gnus-summary-article-score)))
11461 ;; Summary marking commands.
11463 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11464 "Mark articles which has the same subject as read, and then select the next.
11465 If UNMARK is positive, remove any kind of mark.
11466 If UNMARK is negative, tick articles."
11468 (gnus-set-global-variables)
11470 (setq unmark (prefix-numeric-value unmark)))
11472 (gnus-summary-mark-same-subject
11473 (gnus-summary-article-subject) unmark)))
11474 ;; Select next unread article. If auto-select-same mode, should
11475 ;; select the first unread article.
11476 (gnus-summary-next-article t (and gnus-auto-select-same
11477 (gnus-summary-article-subject)))
11478 (gnus-message 7 "%d article%s marked as %s"
11479 count (if (= count 1) " is" "s are")
11480 (if unmark "unread" "read"))))
11482 (defun gnus-summary-kill-same-subject (&optional unmark)
11483 "Mark articles which has the same subject as read.
11484 If UNMARK is positive, remove any kind of mark.
11485 If UNMARK is negative, tick articles."
11487 (gnus-set-global-variables)
11489 (setq unmark (prefix-numeric-value unmark)))
11491 (gnus-summary-mark-same-subject
11492 (gnus-summary-article-subject) unmark)))
11493 ;; If marked as read, go to next unread subject.
11495 ;; Go to next unread subject.
11496 (gnus-summary-next-subject 1 t))
11497 (gnus-message 7 "%d articles are marked as %s"
11498 count (if unmark "unread" "read"))))
11500 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11501 "Mark articles with same SUBJECT as read, and return marked number.
11502 If optional argument UNMARK is positive, remove any kinds of marks.
11503 If optional argument UNMARK is negative, mark articles as unread instead."
11507 ((null unmark) ; Mark as read.
11510 (gnus-summary-mark-article-as-read gnus-killed-mark)
11511 (gnus-summary-show-thread) t)
11512 (gnus-summary-find-subject subject))
11513 (setq count (1+ count))))
11514 ((> unmark 0) ; Tick.
11517 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11518 (gnus-summary-show-thread) t)
11519 (gnus-summary-find-subject subject))
11520 (setq count (1+ count))))
11521 (t ; Mark as unread.
11524 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11525 (gnus-summary-show-thread) t)
11526 (gnus-summary-find-subject subject))
11527 (setq count (1+ count)))))
11528 (gnus-set-mode-line 'summary)
11529 ;; Return the number of marked articles.
11532 (defun gnus-summary-mark-as-processable (n &optional unmark)
11533 "Set the process mark on the next N articles.
11534 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11535 the process mark instead. The difference between N and the actual
11536 number of articles marked is returned."
11538 (gnus-set-global-variables)
11539 (let ((backward (< n 0))
11544 (gnus-summary-remove-process-mark
11545 (gnus-summary-article-number))
11546 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11547 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11549 (if (/= 0 n) (gnus-message 7 "No more articles"))
11550 (gnus-summary-recenter)
11551 (gnus-summary-position-point)
11554 (defun gnus-summary-unmark-as-processable (n)
11555 "Remove the process mark from the next N articles.
11556 If N is negative, mark backward instead. The difference between N and
11557 the actual number of articles marked is returned."
11559 (gnus-set-global-variables)
11560 (gnus-summary-mark-as-processable n t))
11562 (defun gnus-summary-unmark-all-processable ()
11563 "Remove the process mark from all articles."
11565 (gnus-set-global-variables)
11567 (while gnus-newsgroup-processable
11568 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11569 (gnus-summary-position-point))
11571 (defun gnus-summary-mark-as-expirable (n)
11572 "Mark N articles forward as expirable.
11573 If N is negative, mark backward instead. The difference between N and
11574 the actual number of articles marked is returned."
11576 (gnus-set-global-variables)
11577 (gnus-summary-mark-forward n gnus-expirable-mark))
11579 (defun gnus-summary-mark-article-as-replied (article)
11580 "Mark ARTICLE replied and update the summary line."
11581 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11582 (let ((buffer-read-only nil))
11583 (when (gnus-summary-goto-subject article)
11584 (gnus-summary-update-secondary-mark article))))
11586 (defun gnus-summary-set-bookmark (article)
11587 "Set a bookmark in current article."
11588 (interactive (list (gnus-summary-article-number)))
11589 (gnus-set-global-variables)
11590 (if (or (not (get-buffer gnus-article-buffer))
11591 (not gnus-current-article)
11592 (not gnus-article-current)
11593 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11594 (error "No current article selected"))
11595 ;; Remove old bookmark, if one exists.
11596 (let ((old (assq article gnus-newsgroup-bookmarks)))
11597 (if old (setq gnus-newsgroup-bookmarks
11598 (delq old gnus-newsgroup-bookmarks))))
11599 ;; Set the new bookmark, which is on the form
11600 ;; (article-number . line-number-in-body).
11601 (setq gnus-newsgroup-bookmarks
11605 (set-buffer gnus-article-buffer)
11609 (goto-char (point-min))
11610 (search-forward "\n\n" nil t)
11613 gnus-newsgroup-bookmarks))
11614 (gnus-message 6 "A bookmark has been added to the current article."))
11616 (defun gnus-summary-remove-bookmark (article)
11617 "Remove the bookmark from the current article."
11618 (interactive (list (gnus-summary-article-number)))
11619 (gnus-set-global-variables)
11620 ;; Remove old bookmark, if one exists.
11621 (let ((old (assq article gnus-newsgroup-bookmarks)))
11624 (setq gnus-newsgroup-bookmarks
11625 (delq old gnus-newsgroup-bookmarks))
11626 (gnus-message 6 "Removed bookmark."))
11627 (gnus-message 6 "No bookmark in current article."))))
11629 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11630 (defun gnus-summary-mark-as-dormant (n)
11631 "Mark N articles forward as dormant.
11632 If N is negative, mark backward instead. The difference between N and
11633 the actual number of articles marked is returned."
11635 (gnus-set-global-variables)
11636 (gnus-summary-mark-forward n gnus-dormant-mark))
11638 (defun gnus-summary-set-process-mark (article)
11639 "Set the process mark on ARTICLE and update the summary line."
11640 (setq gnus-newsgroup-processable
11642 (delq article gnus-newsgroup-processable)))
11643 (when (gnus-summary-goto-subject article)
11644 (gnus-summary-show-thread)
11645 (gnus-summary-update-secondary-mark article)))
11647 (defun gnus-summary-remove-process-mark (article)
11648 "Remove the process mark from ARTICLE and update the summary line."
11649 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11650 (when (gnus-summary-goto-subject article)
11651 (gnus-summary-show-thread)
11652 (gnus-summary-update-secondary-mark article)))
11654 (defun gnus-summary-set-saved-mark (article)
11655 "Set the process mark on ARTICLE and update the summary line."
11656 (push article gnus-newsgroup-saved)
11657 (when (gnus-summary-goto-subject article)
11658 (gnus-summary-update-secondary-mark article)))
11660 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11661 "Mark N articles as read forwards.
11662 If N is negative, mark backwards instead.
11663 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11665 The difference between N and the actual number of articles marked is
11668 (gnus-set-global-variables)
11669 (let ((backward (< n 0))
11670 (gnus-summary-goto-unread
11671 (and gnus-summary-goto-unread
11672 (not (eq gnus-summary-goto-unread 'never))
11673 (not (memq mark (list gnus-unread-mark
11674 gnus-ticked-mark gnus-dormant-mark)))))
11676 (mark (or mark gnus-del-mark)))
11677 (while (and (> n 0)
11678 (gnus-summary-mark-article nil mark no-expire)
11679 (zerop (gnus-summary-next-subject
11681 (and gnus-summary-goto-unread
11682 (not (eq gnus-summary-goto-unread 'never)))
11685 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11686 (gnus-summary-recenter)
11687 (gnus-summary-position-point)
11688 (gnus-set-mode-line 'summary)
11691 (defun gnus-summary-mark-article-as-read (mark)
11692 "Mark the current article quickly as read with MARK."
11693 (let ((article (gnus-summary-article-number)))
11694 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11695 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11696 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11697 (setq gnus-newsgroup-reads
11698 (cons (cons article mark) gnus-newsgroup-reads))
11699 ;; Possibly remove from cache, if that is used.
11700 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11701 ;; Allow the backend to change the mark.
11702 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11703 ;; Check for auto-expiry.
11704 (when (and gnus-newsgroup-auto-expire
11705 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11706 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11707 (= mark gnus-ancient-mark)
11708 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11709 (setq mark gnus-expirable-mark)
11710 (push article gnus-newsgroup-expirable))
11711 ;; Set the mark in the buffer.
11712 (gnus-summary-update-mark mark 'unread)
11715 (defun gnus-summary-mark-article-as-unread (mark)
11716 "Mark the current article quickly as unread with MARK."
11717 (let ((article (gnus-summary-article-number)))
11718 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11719 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11720 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11721 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11722 (cond ((= mark gnus-ticked-mark)
11723 (push article gnus-newsgroup-marked))
11724 ((= mark gnus-dormant-mark)
11725 (push article gnus-newsgroup-dormant))
11727 (push article gnus-newsgroup-unreads)))
11728 (setq gnus-newsgroup-reads
11729 (delq (assq article gnus-newsgroup-reads)
11730 gnus-newsgroup-reads))
11732 ;; See whether the article is to be put in the cache.
11733 (and gnus-use-cache
11734 (vectorp (gnus-summary-article-header article))
11736 (gnus-cache-possibly-enter-article
11737 gnus-newsgroup-name article
11738 (gnus-summary-article-header article)
11739 (= mark gnus-ticked-mark)
11740 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11743 (gnus-summary-update-mark mark 'unread)
11746 (defun gnus-summary-mark-article (&optional article mark no-expire)
11747 "Mark ARTICLE with MARK. MARK can be any character.
11748 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11749 `??' (dormant) and `?E' (expirable).
11750 If MARK is nil, then the default character `?D' is used.
11751 If ARTICLE is nil, then the article on the current line will be
11753 ;; The mark might be a string.
11754 (and (stringp mark)
11755 (setq mark (aref mark 0)))
11756 ;; If no mark is given, then we check auto-expiring.
11757 (and (not no-expire)
11758 gnus-newsgroup-auto-expire
11760 (and (numberp mark)
11761 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11762 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11763 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11764 (setq mark gnus-expirable-mark))
11765 (let* ((mark (or mark gnus-del-mark))
11766 (article (or article (gnus-summary-article-number))))
11767 (or article (error "No article on current line"))
11768 (if (or (= mark gnus-unread-mark)
11769 (= mark gnus-ticked-mark)
11770 (= mark gnus-dormant-mark))
11771 (gnus-mark-article-as-unread article mark)
11772 (gnus-mark-article-as-read article mark))
11774 ;; See whether the article is to be put in the cache.
11775 (and gnus-use-cache
11776 (not (= mark gnus-canceled-mark))
11777 (vectorp (gnus-summary-article-header article))
11779 (gnus-cache-possibly-enter-article
11780 gnus-newsgroup-name article
11781 (gnus-summary-article-header article)
11782 (= mark gnus-ticked-mark)
11783 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11785 (if (gnus-summary-goto-subject article nil t)
11786 (let ((buffer-read-only nil))
11787 (gnus-summary-show-thread)
11789 (gnus-summary-update-mark mark 'unread)
11792 (defun gnus-summary-update-secondary-mark (article)
11793 "Update the secondary (read, process, cache) mark."
11794 (gnus-summary-update-mark
11795 (cond ((memq article gnus-newsgroup-processable)
11797 ((memq article gnus-newsgroup-cached)
11799 ((memq article gnus-newsgroup-replied)
11801 ((memq article gnus-newsgroup-saved)
11803 (t gnus-unread-mark))
11805 (when (gnus-visual-p 'summary-highlight 'highlight)
11806 (run-hooks 'gnus-summary-update-hook))
11809 (defun gnus-summary-update-mark (mark type)
11810 (beginning-of-line)
11811 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11812 (buffer-read-only nil))
11814 ;; Go to the right position on the line.
11815 (forward-char forward)
11816 ;; Replace the old mark with the new mark.
11817 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11818 ;; Optionally update the marks by some user rule.
11819 (when (eq type 'unread)
11820 (gnus-data-set-mark
11821 (gnus-data-find (gnus-summary-article-number)) mark)
11822 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11824 (defun gnus-mark-article-as-read (article &optional mark)
11825 "Enter ARTICLE in the pertinent lists and remove it from others."
11826 ;; Make the article expirable.
11827 (let ((mark (or mark gnus-del-mark)))
11828 (if (= mark gnus-expirable-mark)
11829 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11830 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11831 ;; Remove from unread and marked lists.
11832 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11833 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11834 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11835 (push (cons article mark) gnus-newsgroup-reads)
11836 ;; Possibly remove from cache, if that is used.
11837 (when gnus-use-cache
11838 (gnus-cache-enter-remove-article article))))
11840 (defun gnus-mark-article-as-unread (article &optional mark)
11841 "Enter ARTICLE in the pertinent lists and remove it from others."
11842 (let ((mark (or mark gnus-ticked-mark)))
11843 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11844 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11845 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11846 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11847 (cond ((= mark gnus-ticked-mark)
11848 (push article gnus-newsgroup-marked))
11849 ((= mark gnus-dormant-mark)
11850 (push article gnus-newsgroup-dormant))
11852 (push article gnus-newsgroup-unreads)))
11853 (setq gnus-newsgroup-reads
11854 (delq (assq article gnus-newsgroup-reads)
11855 gnus-newsgroup-reads))))
11857 (defalias 'gnus-summary-mark-as-unread-forward
11858 'gnus-summary-tick-article-forward)
11859 (make-obsolete 'gnus-summary-mark-as-unread-forward
11860 'gnus-summary-tick-article-forward)
11861 (defun gnus-summary-tick-article-forward (n)
11862 "Tick N articles forwards.
11863 If N is negative, tick backwards instead.
11864 The difference between N and the number of articles ticked is returned."
11866 (gnus-summary-mark-forward n gnus-ticked-mark))
11868 (defalias 'gnus-summary-mark-as-unread-backward
11869 'gnus-summary-tick-article-backward)
11870 (make-obsolete 'gnus-summary-mark-as-unread-backward
11871 'gnus-summary-tick-article-backward)
11872 (defun gnus-summary-tick-article-backward (n)
11873 "Tick N articles backwards.
11874 The difference between N and the number of articles ticked is returned."
11876 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11878 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11879 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11880 (defun gnus-summary-tick-article (&optional article clear-mark)
11881 "Mark current article as unread.
11882 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11883 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11885 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11886 gnus-ticked-mark)))
11888 (defun gnus-summary-mark-as-read-forward (n)
11889 "Mark N articles as read forwards.
11890 If N is negative, mark backwards instead.
11891 The difference between N and the actual number of articles marked is
11894 (gnus-summary-mark-forward n gnus-del-mark t))
11896 (defun gnus-summary-mark-as-read-backward (n)
11897 "Mark the N articles as read backwards.
11898 The difference between N and the actual number of articles marked is
11901 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11903 (defun gnus-summary-mark-as-read (&optional article mark)
11904 "Mark current article as read.
11905 ARTICLE specifies the article to be marked as read.
11906 MARK specifies a string to be inserted at the beginning of the line."
11907 (gnus-summary-mark-article article mark))
11909 (defun gnus-summary-clear-mark-forward (n)
11910 "Clear marks from N articles forward.
11911 If N is negative, clear backward instead.
11912 The difference between N and the number of marks cleared is returned."
11914 (gnus-summary-mark-forward n gnus-unread-mark))
11916 (defun gnus-summary-clear-mark-backward (n)
11917 "Clear marks from N articles backward.
11918 The difference between N and the number of marks cleared is returned."
11920 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11922 (defun gnus-summary-mark-unread-as-read ()
11923 "Intended to be used by `gnus-summary-mark-article-hook'."
11924 (when (memq gnus-current-article gnus-newsgroup-unreads)
11925 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11927 (defun gnus-summary-mark-read-and-unread-as-read ()
11928 "Intended to be used by `gnus-summary-mark-article-hook'."
11929 (let ((mark (gnus-summary-article-mark)))
11930 (when (or (gnus-unread-mark-p mark)
11931 (gnus-read-mark-p mark))
11932 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11934 (defun gnus-summary-mark-region-as-read (point mark all)
11935 "Mark all unread articles between point and mark as read.
11936 If given a prefix, mark all articles between point and mark as read,
11937 even ticked and dormant ones."
11938 (interactive "r\nP")
11942 (beginning-of-line)
11947 (memq (setq article (gnus-summary-article-number))
11948 gnus-newsgroup-unreads))
11949 (gnus-summary-mark-article article gnus-del-mark))
11951 (gnus-summary-find-next))))))
11953 (defun gnus-summary-mark-below (score mark)
11954 "Mark articles with score less than SCORE with MARK."
11955 (interactive "P\ncMark: ")
11956 (gnus-set-global-variables)
11957 (setq score (if score
11958 (prefix-numeric-value score)
11959 (or gnus-summary-default-score 0)))
11961 (set-buffer gnus-summary-buffer)
11962 (goto-char (point-min))
11965 (and (< (gnus-summary-article-score) score)
11966 (gnus-summary-mark-article nil mark))
11967 (gnus-summary-find-next)))))
11969 (defun gnus-summary-kill-below (&optional score)
11970 "Mark articles with score below SCORE as read."
11972 (gnus-set-global-variables)
11973 (gnus-summary-mark-below score gnus-killed-mark))
11975 (defun gnus-summary-clear-above (&optional score)
11976 "Clear all marks from articles with score above SCORE."
11978 (gnus-set-global-variables)
11979 (gnus-summary-mark-above score gnus-unread-mark))
11981 (defun gnus-summary-tick-above (&optional score)
11982 "Tick all articles with score above SCORE."
11984 (gnus-set-global-variables)
11985 (gnus-summary-mark-above score gnus-ticked-mark))
11987 (defun gnus-summary-mark-above (score mark)
11988 "Mark articles with score over SCORE with MARK."
11989 (interactive "P\ncMark: ")
11990 (gnus-set-global-variables)
11991 (setq score (if score
11992 (prefix-numeric-value score)
11993 (or gnus-summary-default-score 0)))
11995 (set-buffer gnus-summary-buffer)
11996 (goto-char (point-min))
11998 (if (> (gnus-summary-article-score) score)
11999 (gnus-summary-mark-article nil mark))
12001 (gnus-summary-find-next)))))
12003 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12004 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12005 (defun gnus-summary-limit-include-expunged ()
12006 "Display all the hidden articles that were expunged for low scores."
12008 (gnus-set-global-variables)
12009 (let ((buffer-read-only nil))
12010 (let ((scored gnus-newsgroup-scored)
12013 (or (gnus-summary-goto-subject (car (car scored)))
12014 (and (setq h (gnus-summary-article-header (car (car scored))))
12015 (< (cdr (car scored)) gnus-summary-expunge-below)
12016 (setq headers (cons h headers))))
12017 (setq scored (cdr scored)))
12018 (or headers (error "No expunged articles hidden."))
12019 (goto-char (point-min))
12020 (gnus-summary-prepare-unthreaded (nreverse headers)))
12021 (goto-char (point-min))
12022 (gnus-summary-position-point)))
12024 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12025 "Mark all articles not marked as unread in this newsgroup as read.
12026 If prefix argument ALL is non-nil, all articles are marked as read.
12027 If QUIETLY is non-nil, no questions will be asked.
12028 If TO-HERE is non-nil, it should be a point in the buffer. All
12029 articles before this point will be marked as read.
12030 The number of articles marked as read is returned."
12032 (gnus-set-global-variables)
12035 (not gnus-interactive-catchup) ;Without confirmation?
12039 "Mark absolutely all articles as read? "
12040 "Mark all unread articles as read? ")))
12042 (not gnus-newsgroup-adaptive)
12043 (not gnus-newsgroup-auto-expire))
12046 (setq gnus-newsgroup-marked nil
12047 gnus-newsgroup-dormant nil))
12048 (setq gnus-newsgroup-unreads nil))
12049 ;; We actually mark all articles as canceled, which we
12050 ;; have to do when using auto-expiry or adaptive scoring.
12051 (gnus-summary-show-all-threads)
12052 (if (gnus-summary-first-subject (not all))
12054 (if to-here (< (point) to-here) t)
12055 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12056 (gnus-summary-find-next (not all)))))
12058 (setq gnus-newsgroup-unreads nil))
12059 (gnus-set-mode-line 'summary)))
12060 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12061 (if (and (not to-here) (eq 'nnvirtual (car method)))
12062 (nnvirtual-catchup-group
12063 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12064 (gnus-summary-position-point)))
12066 (defun gnus-summary-catchup-to-here (&optional all)
12067 "Mark all unticked articles before the current one as read.
12068 If ALL is non-nil, also mark ticked and dormant articles as read."
12070 (gnus-set-global-variables)
12072 (let ((beg (point)))
12073 ;; We check that there are unread articles.
12074 (when (or all (gnus-summary-find-prev))
12075 (gnus-summary-catchup all t beg))))
12076 (gnus-summary-position-point))
12078 (defun gnus-summary-catchup-all (&optional quietly)
12079 "Mark all articles in this newsgroup as read."
12081 (gnus-set-global-variables)
12082 (gnus-summary-catchup t quietly))
12084 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12085 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12086 If prefix argument ALL is non-nil, all articles are marked as read."
12088 (gnus-set-global-variables)
12089 (gnus-summary-catchup all quietly nil 'fast)
12090 ;; Select next newsgroup or exit.
12091 (if (eq gnus-auto-select-next 'quietly)
12092 (gnus-summary-next-group nil)
12093 (gnus-summary-exit)))
12095 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12096 "Mark all articles in this newsgroup as read, and then exit."
12098 (gnus-set-global-variables)
12099 (gnus-summary-catchup-and-exit t quietly))
12101 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12102 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12103 "Mark all articles in this group as read and select the next group.
12104 If given a prefix, mark all articles, unread as well as ticked, as
12107 (gnus-set-global-variables)
12109 (gnus-summary-catchup all))
12110 (gnus-summary-next-article t nil nil t))
12112 ;; Thread-based commands.
12114 (defun gnus-summary-articles-in-thread (&optional article)
12115 "Return a list of all articles in the current thread.
12116 If ARTICLE is non-nil, return all articles in the thread that starts
12117 with that article."
12118 (let* ((article (or article (gnus-summary-article-number)))
12119 (data (gnus-data-find-list article))
12120 (top-level (gnus-data-level (car data)))
12122 (cond ((null gnus-thread-operation-ignore-subject)
12123 (gnus-simplify-subject-re
12124 (mail-header-subject (gnus-data-header (car data)))))
12125 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12126 (gnus-simplify-subject-fuzzy
12127 (mail-header-subject (gnus-data-header (car data)))))
12131 () ; This article doesn't exist.
12133 (and (or (not top-subject)
12134 (string= top-subject
12135 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12136 (gnus-simplify-subject-fuzzy
12137 (mail-header-subject
12138 (gnus-data-header (car data))))
12139 (gnus-simplify-subject-re
12140 (mail-header-subject
12141 (gnus-data-header (car data)))))))
12142 (setq articles (cons (gnus-data-number (car data)) articles)))
12143 (if (and (setq data (cdr data))
12144 (> (gnus-data-level (car data)) top-level))
12147 ;; Return the list of articles.
12148 (nreverse articles))))
12150 (defun gnus-summary-rethread-current ()
12151 "Rethread the thread the current article is part of."
12153 (gnus-set-global-variables)
12154 (let* ((gnus-show-threads t)
12155 (article (gnus-summary-article-number))
12156 (id (mail-header-id (gnus-summary-article-header)))
12157 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12159 (error "No article on the current line"))
12160 (gnus-rebuild-thread id)
12161 (gnus-summary-goto-subject article)))
12163 (defun gnus-summary-reparent-thread ()
12164 "Make current article child of the marked (or previous) article.
12166 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12167 is non-nil or the Subject: of both articles are the same."
12169 (or (not (gnus-group-read-only-p))
12170 (error "The current newsgroup does not support article editing."))
12171 (or (<= (length gnus-newsgroup-processable) 1)
12172 (error "No more than one article may be marked."))
12173 (save-window-excursion
12174 (let ((gnus-article-buffer " *reparent*")
12175 (current-article (gnus-summary-article-number))
12176 ; first grab the marked article, otherwise one line up.
12177 (parent-article (if (not (null gnus-newsgroup-processable))
12178 (car gnus-newsgroup-processable)
12180 (if (eq (forward-line -1) 0)
12181 (gnus-summary-article-number)
12182 (error "Beginning of summary buffer."))))))
12183 (or (not (eq current-article parent-article))
12184 (error "An article may not be self-referential."))
12185 (let ((message-id (mail-header-id
12186 (gnus-summary-article-header parent-article))))
12187 (or (and message-id (not (equal message-id "")))
12188 (error "No message-id in desired parent."))
12189 (gnus-summary-select-article t t nil current-article)
12190 (set-buffer gnus-article-buffer)
12191 (setq buffer-read-only nil)
12192 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
12195 (goto-char (point-min))
12196 (if (search-forward-regexp "^References: " nil t)
12197 (insert message-id " " )
12198 (insert "References: " message-id "\n"))
12199 (or (gnus-request-replace-article current-article
12200 (car gnus-article-current)
12201 gnus-article-buffer)
12202 (error "Couldn't replace article."))
12203 (set-buffer gnus-summary-buffer)
12204 (gnus-summary-unmark-all-processable)
12205 (gnus-summary-rethread-current)
12206 (message "Article %d is now the child of article %d."
12207 current-article parent-article)))))
12209 (defun gnus-summary-toggle-threads (&optional arg)
12210 "Toggle showing conversation threads.
12211 If ARG is positive number, turn showing conversation threads on."
12213 (gnus-set-global-variables)
12214 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12215 (setq gnus-show-threads
12216 (if (null arg) (not gnus-show-threads)
12217 (> (prefix-numeric-value arg) 0)))
12218 (gnus-summary-prepare)
12219 (gnus-summary-goto-subject current)
12220 (gnus-summary-position-point)))
12222 (defun gnus-summary-show-all-threads ()
12223 "Show all threads."
12225 (gnus-set-global-variables)
12227 (let ((buffer-read-only nil))
12228 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12229 (gnus-summary-position-point))
12231 (defun gnus-summary-show-thread ()
12232 "Show thread subtrees.
12233 Returns nil if no thread was there to be shown."
12235 (gnus-set-global-variables)
12236 (let ((buffer-read-only nil)
12238 ;; first goto end then to beg, to have point at beg after let
12239 (end (progn (end-of-line) (point)))
12240 (beg (progn (beginning-of-line) (point))))
12242 ;; Any hidden lines here?
12243 (search-forward "\r" end t)
12244 (subst-char-in-region beg end ?\^M ?\n t)
12246 (gnus-summary-position-point))))
12248 (defun gnus-summary-hide-all-threads ()
12249 "Hide all thread subtrees."
12251 (gnus-set-global-variables)
12253 (goto-char (point-min))
12254 (gnus-summary-hide-thread)
12255 (while (zerop (gnus-summary-next-thread 1 t))
12256 (gnus-summary-hide-thread)))
12257 (gnus-summary-position-point))
12259 (defun gnus-summary-hide-thread ()
12260 "Hide thread subtrees.
12261 Returns nil if no threads were there to be hidden."
12263 (gnus-set-global-variables)
12264 (let ((buffer-read-only nil)
12266 (article (gnus-summary-article-number))
12269 ;; Go forward until either the buffer ends or the subthread
12271 (when (and (not (eobp))
12272 (or (zerop (gnus-summary-next-thread 1 t))
12273 (goto-char (point-max))))
12276 (if (and (> (point) start)
12277 (search-backward "\n" start t))
12279 (subst-char-in-region start (point) ?\n ?\^M)
12280 (gnus-summary-goto-subject article))
12283 ;;(gnus-summary-position-point)
12286 (defun gnus-summary-go-to-next-thread (&optional previous)
12287 "Go to the same level (or less) next thread.
12288 If PREVIOUS is non-nil, go to previous thread instead.
12289 Return the article number moved to, or nil if moving was impossible."
12290 (let* ((level (gnus-summary-thread-level))
12291 (article (gnus-summary-article-number))
12292 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12295 (if (<= (gnus-data-level (car data)) level)
12296 (setq oart (gnus-data-number (car data))
12298 (setq data (cdr data))))
12300 (gnus-summary-goto-subject oart))))
12302 (defun gnus-summary-next-thread (n &optional silent)
12303 "Go to the same level next N'th thread.
12304 If N is negative, search backward instead.
12305 Returns the difference between N and the number of skips actually
12308 If SILENT, don't output messages."
12310 (gnus-set-global-variables)
12311 (let ((backward (< n 0))
12314 (while (and (> n 0)
12315 (setq old (save-excursion (forward-line 1) (point)))
12316 (gnus-summary-go-to-next-thread backward))
12317 (when (and (eq gnus-summary-make-false-root 'dummy)
12318 (setq dum (text-property-not-all
12319 old (point) 'gnus-intangible nil)))
12323 (gnus-summary-position-point))
12324 (when (and (not silent) (/= 0 n))
12325 (gnus-message 7 "No more threads"))
12328 (defun gnus-summary-prev-thread (n)
12329 "Go to the same level previous N'th thread.
12330 Returns the difference between N and the number of skips actually
12333 (gnus-set-global-variables)
12334 (gnus-summary-next-thread (- n)))
12336 (defun gnus-summary-go-down-thread ()
12337 "Go down one level in the current thread."
12338 (let ((children (gnus-summary-article-children)))
12340 (gnus-summary-goto-subject (car children)))))
12342 (defun gnus-summary-go-up-thread ()
12343 "Go up one level in the current thread."
12344 (let ((parent (gnus-summary-article-parent)))
12346 (gnus-summary-goto-subject parent))))
12348 (defun gnus-summary-down-thread (n)
12349 "Go down thread N steps.
12350 If N is negative, go up instead.
12351 Returns the difference between N and how many steps down that were
12354 (gnus-set-global-variables)
12357 (while (and (> n 0)
12358 (if up (gnus-summary-go-up-thread)
12359 (gnus-summary-go-down-thread)))
12361 (gnus-summary-position-point)
12362 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12365 (defun gnus-summary-up-thread (n)
12366 "Go up thread N steps.
12367 If N is negative, go up instead.
12368 Returns the difference between N and how many steps down that were
12371 (gnus-set-global-variables)
12372 (gnus-summary-down-thread (- n)))
12374 (defun gnus-summary-top-thread ()
12375 "Go to the top of the thread."
12377 (gnus-set-global-variables)
12378 (while (gnus-summary-go-up-thread))
12379 (gnus-summary-article-number))
12381 (defun gnus-summary-kill-thread (&optional unmark)
12382 "Mark articles under current thread as read.
12383 If the prefix argument is positive, remove any kinds of marks.
12384 If the prefix argument is negative, tick articles instead."
12386 (gnus-set-global-variables)
12388 (setq unmark (prefix-numeric-value unmark)))
12389 (let ((articles (gnus-summary-articles-in-thread)))
12391 ;; Expand the thread.
12392 (gnus-summary-show-thread)
12393 ;; Mark all the articles.
12395 (gnus-summary-goto-subject (car articles))
12396 (cond ((null unmark)
12397 (gnus-summary-mark-article-as-read gnus-killed-mark))
12399 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12401 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12402 (setq articles (cdr articles))))
12403 ;; Hide killed subtrees.
12405 gnus-thread-hide-killed
12406 (gnus-summary-hide-thread))
12407 ;; If marked as read, go to next unread subject.
12409 ;; Go to next unread subject.
12410 (gnus-summary-next-subject 1 t)))
12411 (gnus-set-mode-line 'summary))
12413 ;; Summary sorting commands
12415 (defun gnus-summary-sort-by-number (&optional reverse)
12416 "Sort summary buffer by article number.
12417 Argument REVERSE means reverse order."
12419 (gnus-summary-sort 'number reverse))
12421 (defun gnus-summary-sort-by-author (&optional reverse)
12422 "Sort summary buffer by author name alphabetically.
12423 If case-fold-search is non-nil, case of letters is ignored.
12424 Argument REVERSE means reverse order."
12426 (gnus-summary-sort 'author reverse))
12428 (defun gnus-summary-sort-by-subject (&optional reverse)
12429 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12430 If case-fold-search is non-nil, case of letters is ignored.
12431 Argument REVERSE means reverse order."
12433 (gnus-summary-sort 'subject reverse))
12435 (defun gnus-summary-sort-by-date (&optional reverse)
12436 "Sort summary buffer by date.
12437 Argument REVERSE means reverse order."
12439 (gnus-summary-sort 'date reverse))
12441 (defun gnus-summary-sort-by-score (&optional reverse)
12442 "Sort summary buffer by score.
12443 Argument REVERSE means reverse order."
12445 (gnus-summary-sort 'score reverse))
12447 (defun gnus-summary-sort (predicate reverse)
12448 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12449 (gnus-set-global-variables)
12450 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12451 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12452 (gnus-thread-sort-functions
12457 (,thread t2 t1)))))
12458 (gnus-article-sort-functions
12463 (,article t2 t1)))))
12465 (gnus-summary-prepare-hook nil))
12466 ;; We do the sorting by regenerating the threads.
12467 (gnus-summary-prepare)
12468 ;; Hide subthreads if needed.
12469 (when (and gnus-show-threads gnus-thread-hide-subtree)
12470 (gnus-summary-hide-all-threads)))
12471 ;; If in async mode, we send some info to the backend.
12472 (when gnus-newsgroup-async
12473 (gnus-request-asynchronous
12474 gnus-newsgroup-name gnus-newsgroup-data)))
12476 (defun gnus-sortable-date (date)
12477 "Make sortable string by string-lessp from DATE.
12478 Timezone package is used."
12479 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12480 (year (aref date 0))
12481 (month (aref date 1))
12482 (day (aref date 2)))
12483 (timezone-make-sortable-date
12485 (timezone-make-time-string
12486 (aref date 3) (aref date 4) (aref date 5)))))
12488 ;; Summary saving commands.
12490 (defun gnus-summary-save-article (&optional n not-saved)
12491 "Save the current article using the default saver function.
12492 If N is a positive number, save the N next articles.
12493 If N is a negative number, save the N previous articles.
12494 If N is nil and any articles have been marked with the process mark,
12495 save those articles instead.
12496 The variable `gnus-default-article-saver' specifies the saver function."
12498 (gnus-set-global-variables)
12499 (let ((articles (gnus-summary-work-articles n))
12500 file header article)
12502 (setq header (gnus-summary-article-header
12503 (setq article (pop articles))))
12504 (if (not (vectorp header))
12505 ;; This is a pseudo-article.
12506 (if (assq 'name header)
12507 (gnus-copy-file (cdr (assq 'name header)))
12508 (gnus-message 1 "Article %d is unsaveable" article))
12509 ;; This is a real article.
12510 (save-window-excursion
12511 (gnus-summary-select-article t nil nil article))
12512 (unless gnus-save-all-headers
12513 ;; Remove headers accoring to `gnus-saved-headers'.
12514 (let ((gnus-visible-headers
12515 (or gnus-saved-headers gnus-visible-headers)))
12516 (gnus-article-hide-headers nil t)))
12517 ;; Remove any X-Gnus lines.
12519 (set-buffer gnus-article-buffer)
12521 (let ((buffer-read-only nil))
12522 (nnheader-narrow-to-headers)
12523 (while (re-search-forward "^X-Gnus" nil t)
12524 (gnus-delete-line)))))
12525 (save-window-excursion
12526 (if (not gnus-default-article-saver)
12527 (error "No default saver is defined.")
12528 (setq file (funcall
12529 gnus-default-article-saver
12531 ((not gnus-prompt-before-saving)
12533 ((eq gnus-prompt-before-saving 'always)
12536 (gnus-summary-remove-process-mark article)
12538 (gnus-summary-set-saved-mark article))))
12539 (gnus-summary-position-point)
12542 (defun gnus-summary-pipe-output (&optional arg)
12543 "Pipe the current article to a subprocess.
12544 If N is a positive number, pipe the N next articles.
12545 If N is a negative number, pipe the N previous articles.
12546 If N is nil and any articles have been marked with the process mark,
12547 pipe those articles instead."
12549 (gnus-set-global-variables)
12550 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12551 (gnus-summary-save-article arg t))
12552 (gnus-configure-windows 'pipe))
12554 (defun gnus-summary-save-article-mail (&optional arg)
12555 "Append the current article to an mail file.
12556 If N is a positive number, save the N next articles.
12557 If N is a negative number, save the N previous articles.
12558 If N is nil and any articles have been marked with the process mark,
12559 save those articles instead."
12561 (gnus-set-global-variables)
12562 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12563 (gnus-summary-save-article arg)))
12565 (defun gnus-summary-save-article-rmail (&optional arg)
12566 "Append the current article to an rmail file.
12567 If N is a positive number, save the N next articles.
12568 If N is a negative number, save the N previous articles.
12569 If N is nil and any articles have been marked with the process mark,
12570 save those articles instead."
12572 (gnus-set-global-variables)
12573 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12574 (gnus-summary-save-article arg)))
12576 (defun gnus-summary-save-article-file (&optional arg)
12577 "Append the current article to a file.
12578 If N is a positive number, save the N next articles.
12579 If N is a negative number, save the N previous articles.
12580 If N is nil and any articles have been marked with the process mark,
12581 save those articles instead."
12583 (gnus-set-global-variables)
12584 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12585 (gnus-summary-save-article arg)))
12587 (defun gnus-summary-save-article-body-file (&optional arg)
12588 "Append the current article body to a file.
12589 If N is a positive number, save the N next articles.
12590 If N is a negative number, save the N previous articles.
12591 If N is nil and any articles have been marked with the process mark,
12592 save those articles instead."
12594 (gnus-set-global-variables)
12595 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12596 (gnus-summary-save-article arg)))
12598 (defun gnus-get-split-value (methods)
12599 "Return a value based on the split METHODS."
12600 (let (split-name method result match)
12603 (set-buffer gnus-original-article-buffer)
12605 (nnheader-narrow-to-headers)
12607 (goto-char (point-min))
12608 (setq method (pop methods))
12609 (setq match (pop method))
12612 ;; Regular expression.
12614 (re-search-forward match nil t)
12616 ((gnus-functionp match)
12620 (setq result (funcall match gnus-newsgroup-name))))
12625 (setq result (eval match)))))
12626 (setq split-name (append (cdr methods) split-name))
12627 (cond ((stringp result)
12628 (push result split-name))
12630 (setq split-name (append result split-name)))))))))
12633 (defun gnus-read-move-group-name (prompt default articles prefix)
12634 "Read a group name."
12635 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12637 (format "Where do you want to %s %s? "
12639 (if (> (length articles) 1)
12640 (format "these %d articles" (length articles))
12648 (format "(default %s) " default)
12650 gnus-active-hashtb nil nil prefix))
12651 ((= 1 (length split-name))
12652 (completing-read prom gnus-active-hashtb
12653 nil nil (cons (car split-name) 0)))
12656 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12659 (if (or (string= to-newsgroup "")
12660 (string= to-newsgroup prefix))
12661 (setq to-newsgroup (or default "")))
12662 (or (gnus-active to-newsgroup)
12663 (gnus-activate-group to-newsgroup)
12664 (error "No such group: %s" to-newsgroup)))
12667 (defun gnus-read-save-file-name (prompt default-name)
12668 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12670 ;; Let the split methods have their say.
12672 ;; No split name was found.
12675 (concat prompt " (default "
12676 (file-name-nondirectory default-name) ") ")
12677 (file-name-directory default-name)
12679 ;; A single split name was found
12680 ((= 1 (length split-name))
12682 (concat prompt " (default " (car split-name) ") ")
12683 gnus-article-save-directory
12684 (concat gnus-article-save-directory (car split-name))))
12685 ;; A list of splits was found.
12687 (setq split-name (mapcar (lambda (el) (list el))
12688 (nreverse split-name)))
12689 (let ((result (completing-read
12690 (concat prompt " ") split-name nil nil)))
12691 (concat gnus-article-save-directory
12692 (if (string= result "")
12693 (car (car split-name))
12695 ;; If we have read a directory, we append the default file name.
12696 (when (file-directory-p file)
12697 (setq file (concat (file-name-as-directory file)
12698 (file-name-nondirectory default-name))))
12699 ;; Possibly translate some charaters.
12700 (nnheader-translate-file-chars file)))
12702 (defun gnus-article-archive-name (group)
12703 "Return the first instance of an \"Archive-name\" in the current buffer."
12704 (let ((case-fold-search t))
12705 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12706 (match-string 1))))
12708 (defun gnus-summary-save-in-rmail (&optional filename)
12709 "Append this article to Rmail file.
12710 Optional argument FILENAME specifies file name.
12711 Directory to save to is default to `gnus-article-save-directory' which
12712 is initialized from the SAVEDIR environment variable."
12714 (gnus-set-global-variables)
12715 (let ((default-name
12716 (funcall gnus-rmail-save-name gnus-newsgroup-name
12717 gnus-current-headers gnus-newsgroup-last-rmail)))
12719 (cond ((eq filename 'default)
12721 (filename filename)
12722 (t (gnus-read-save-file-name
12723 "Save in rmail file:" default-name))))
12724 (gnus-make-directory (file-name-directory filename))
12725 (gnus-eval-in-buffer-window
12726 gnus-original-article-buffer
12730 (gnus-output-to-rmail filename))))
12731 ;; Remember the directory name to save articles
12732 (setq gnus-newsgroup-last-rmail filename)))
12734 (defun gnus-summary-save-in-mail (&optional filename)
12735 "Append this article to Unix mail file.
12736 Optional argument FILENAME specifies file name.
12737 Directory to save to is default to `gnus-article-save-directory' which
12738 is initialized from the SAVEDIR environment variable."
12740 (gnus-set-global-variables)
12741 (let ((default-name
12742 (funcall gnus-mail-save-name gnus-newsgroup-name
12743 gnus-current-headers gnus-newsgroup-last-mail)))
12745 (cond ((eq filename 'default)
12747 (filename filename)
12748 (t (gnus-read-save-file-name
12749 "Save in Unix mail file:" default-name))))
12751 (expand-file-name filename
12753 (file-name-directory default-name))))
12754 (gnus-make-directory (file-name-directory filename))
12755 (gnus-eval-in-buffer-window
12756 gnus-original-article-buffer
12760 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12761 (gnus-output-to-rmail filename)
12762 (let ((mail-use-rfc822 t))
12763 (rmail-output filename 1 t t))))))
12764 ;; Remember the directory name to save articles.
12765 (setq gnus-newsgroup-last-mail filename)))
12767 (defun gnus-summary-save-in-file (&optional filename)
12768 "Append this article to file.
12769 Optional argument FILENAME specifies file name.
12770 Directory to save to is default to `gnus-article-save-directory' which
12771 is initialized from the SAVEDIR environment variable."
12773 (gnus-set-global-variables)
12774 (let ((default-name
12775 (funcall gnus-file-save-name gnus-newsgroup-name
12776 gnus-current-headers gnus-newsgroup-last-file)))
12778 (cond ((eq filename 'default)
12780 (filename filename)
12781 (t (gnus-read-save-file-name
12782 "Save in file:" default-name))))
12783 (gnus-make-directory (file-name-directory filename))
12784 (gnus-eval-in-buffer-window
12785 gnus-original-article-buffer
12789 (gnus-output-to-file filename))))
12790 ;; Remember the directory name to save articles.
12791 (setq gnus-newsgroup-last-file filename)))
12793 (defun gnus-summary-save-body-in-file (&optional filename)
12794 "Append this article body to a file.
12795 Optional argument FILENAME specifies file name.
12796 The directory to save in defaults to `gnus-article-save-directory' which
12797 is initialized from the SAVEDIR environment variable."
12799 (gnus-set-global-variables)
12800 (let ((default-name
12801 (funcall gnus-file-save-name gnus-newsgroup-name
12802 gnus-current-headers gnus-newsgroup-last-file)))
12804 (cond ((eq filename 'default)
12806 (filename filename)
12807 (t (gnus-read-save-file-name
12808 "Save body in file:" default-name))))
12809 (gnus-make-directory (file-name-directory filename))
12810 (gnus-eval-in-buffer-window
12811 gnus-article-buffer
12815 (goto-char (point-min))
12816 (and (search-forward "\n\n" nil t)
12817 (narrow-to-region (point) (point-max)))
12818 (gnus-output-to-file filename))))
12819 ;; Remember the directory name to save articles.
12820 (setq gnus-newsgroup-last-file filename)))
12822 (defun gnus-summary-save-in-pipe (&optional command)
12823 "Pipe this article to subprocess."
12825 (gnus-set-global-variables)
12827 (cond ((eq command 'default)
12828 gnus-last-shell-command)
12830 (t (read-string "Shell command on article: "
12831 gnus-last-shell-command))))
12832 (if (string-equal command "")
12833 (setq command gnus-last-shell-command))
12834 (gnus-eval-in-buffer-window
12835 gnus-article-buffer
12838 (shell-command-on-region (point-min) (point-max) command nil)))
12839 (setq gnus-last-shell-command command))
12841 ;; Summary extract commands
12843 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12844 (let ((buffer-read-only nil)
12845 (article (gnus-summary-article-number))
12847 (or (gnus-summary-goto-subject article)
12848 (error (format "No such article: %d" article)))
12849 (gnus-summary-position-point)
12850 ;; If all commands are to be bunched up on one line, we collect
12852 (if gnus-view-pseudos-separately
12854 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12857 (setq action (cdr (assq 'action (car ps))))
12858 (setq files (list (cdr (assq 'name (car ps)))))
12859 (while (and ps (cdr ps)
12860 (string= (or action "1")
12861 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12862 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12863 (setcdr ps (cdr (cdr ps))))
12866 (if (not (string-match "%s" action))
12867 (setq files (cons " " files)))
12868 (setq files (cons " " files))
12869 (and (assq 'execute (car ps))
12870 (setcdr (assq 'execute (car ps))
12871 (funcall (if (string-match "%s" action)
12874 (mapconcat (lambda (f) f) files " ")))))
12875 (setq ps (cdr ps)))))
12876 (if (and gnus-view-pseudos (not not-view))
12878 (and (assq 'execute (car pslist))
12879 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12880 (eq gnus-view-pseudos 'not-confirm)))
12881 (setq pslist (cdr pslist)))
12884 (setq after-article (or (cdr (assq 'article (car pslist)))
12885 (gnus-summary-article-number)))
12886 (gnus-summary-goto-subject after-article)
12889 (insert " " (file-name-nondirectory
12890 (cdr (assq 'name (car pslist))))
12891 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12893 (forward-line -1) ; back to `b'
12894 (add-text-properties
12895 b e (list 'gnus-number gnus-reffed-article-number
12896 gnus-mouse-face-prop gnus-mouse-face))
12898 after-article gnus-reffed-article-number
12899 gnus-unread-mark b (car pslist) 0 (- e b))
12900 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12901 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12902 (setq pslist (cdr pslist)))))))
12904 (defun gnus-pseudos< (p1 p2)
12905 (let ((c1 (cdr (assq 'action p1)))
12906 (c2 (cdr (assq 'action p2))))
12907 (and c1 c2 (string< c1 c2))))
12909 (defun gnus-request-pseudo-article (props)
12910 (cond ((assq 'execute props)
12911 (gnus-execute-command (cdr (assq 'execute props)))))
12912 (let ((gnus-current-article (gnus-summary-article-number)))
12913 (run-hooks 'gnus-mark-article-hook)))
12915 (defun gnus-execute-command (command &optional automatic)
12917 (gnus-article-setup-buffer)
12918 (set-buffer gnus-article-buffer)
12919 (let ((command (if automatic command (read-string "Command: " command)))
12920 (buffer-read-only nil))
12922 (insert "$ " command "\n\n")
12923 (if gnus-view-pseudo-asynchronously
12924 (start-process "gnus-execute" nil "sh" "-c" command)
12925 (call-process "sh" nil t nil "-c" command)))))
12927 (defun gnus-copy-file (file &optional to)
12930 (list (read-file-name "Copy file: " default-directory)
12931 (read-file-name "Copy file to: " default-directory)))
12932 (gnus-set-global-variables)
12933 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12934 (and (file-directory-p to)
12935 (setq to (concat (file-name-as-directory to)
12936 (file-name-nondirectory file))))
12937 (copy-file file to))
12939 ;; Summary kill commands.
12941 (defun gnus-summary-edit-global-kill (article)
12942 "Edit the \"global\" kill file."
12943 (interactive (list (gnus-summary-article-number)))
12944 (gnus-set-global-variables)
12945 (gnus-group-edit-global-kill article))
12947 (defun gnus-summary-edit-local-kill ()
12948 "Edit a local kill file applied to the current newsgroup."
12950 (gnus-set-global-variables)
12951 (setq gnus-current-headers (gnus-summary-article-header))
12952 (gnus-set-global-variables)
12953 (gnus-group-edit-local-kill
12954 (gnus-summary-article-number) gnus-newsgroup-name))
12958 ;;; Gnus article mode
12961 (put 'gnus-article-mode 'mode-class 'special)
12963 (if gnus-article-mode-map
12965 (setq gnus-article-mode-map (make-keymap))
12966 (suppress-keymap gnus-article-mode-map)
12968 (gnus-define-keys gnus-article-mode-map
12969 " " gnus-article-goto-next-page
12970 "\177" gnus-article-goto-prev-page
12971 [delete] gnus-article-goto-prev-page
12972 "\C-c^" gnus-article-refer-article
12973 "h" gnus-article-show-summary
12974 "s" gnus-article-show-summary
12975 "\C-c\C-m" gnus-article-mail
12976 "?" gnus-article-describe-briefly
12977 gnus-mouse-2 gnus-article-push-button
12978 "\r" gnus-article-press-button
12979 "\t" gnus-article-next-button
12980 "\M-\t" gnus-article-prev-button
12981 "\C-c\C-b" gnus-bug)
12983 (substitute-key-definition
12984 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
12986 (defun gnus-article-mode ()
12987 "Major mode for displaying an article.
12989 All normal editing commands are switched off.
12991 The following commands are available:
12993 \\<gnus-article-mode-map>
12994 \\[gnus-article-next-page]\t Scroll the article one page forwards
12995 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12996 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12997 \\[gnus-article-show-summary]\t Display the summary buffer
12998 \\[gnus-article-mail]\t Send a reply to the address near point
12999 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13000 \\[gnus-info-find-node]\t Go to the Gnus info node"
13002 (when (and menu-bar-mode
13003 (gnus-visual-p 'article-menu 'menu))
13004 (gnus-article-make-menu-bar))
13005 (kill-all-local-variables)
13006 (gnus-simplify-mode-line)
13007 (setq mode-name "Article")
13008 (setq major-mode 'gnus-article-mode)
13009 (make-local-variable 'minor-mode-alist)
13010 (or (assq 'gnus-show-mime minor-mode-alist)
13011 (setq minor-mode-alist
13012 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13013 (use-local-map gnus-article-mode-map)
13014 (make-local-variable 'page-delimiter)
13015 (setq page-delimiter gnus-page-delimiter)
13016 (buffer-disable-undo (current-buffer))
13017 (setq buffer-read-only t) ;Disable modification
13018 (run-hooks 'gnus-article-mode-hook))
13020 (defun gnus-article-setup-buffer ()
13021 "Initialize the article buffer."
13022 (let* ((name (if gnus-single-article-buffer "*Article*"
13023 (concat "*Article " gnus-newsgroup-name "*")))
13025 (progn (string-match "\\*Article" name)
13026 (concat " *Original Article"
13027 (substring name (match-end 0))))))
13028 (setq gnus-article-buffer name)
13029 (setq gnus-original-article-buffer original)
13030 ;; This might be a variable local to the summary buffer.
13031 (unless gnus-single-article-buffer
13033 (set-buffer gnus-summary-buffer)
13034 (setq gnus-article-buffer name)
13035 (setq gnus-original-article-buffer original)
13036 (gnus-set-global-variables))
13037 (make-local-variable 'gnus-summary-buffer))
13038 (if (get-buffer name)
13041 (buffer-disable-undo (current-buffer))
13042 (setq buffer-read-only t)
13043 (gnus-add-current-to-buffer-list)
13044 (or (eq major-mode 'gnus-article-mode)
13045 (gnus-article-mode))
13048 (set-buffer (get-buffer-create name))
13049 (gnus-add-current-to-buffer-list)
13050 (gnus-article-mode)
13051 (current-buffer)))))
13053 ;; Set article window start at LINE, where LINE is the number of lines
13054 ;; from the head of the article.
13055 (defun gnus-article-set-window-start (&optional line)
13057 (get-buffer-window gnus-article-buffer)
13059 (set-buffer gnus-article-buffer)
13060 (goto-char (point-min))
13063 (gnus-message 6 "Moved to bookmark")
13064 (search-forward "\n\n" nil t)
13065 (forward-line line)
13068 (defun gnus-kill-all-overlays ()
13069 "Delete all overlays in the current buffer."
13070 (when (fboundp 'overlay-lists)
13071 (let* ((overlayss (overlay-lists))
13072 (buffer-read-only nil)
13073 (overlays (nconc (car overlayss) (cdr overlayss))))
13075 (delete-overlay (pop overlays))))))
13077 (defun gnus-request-article-this-buffer (article group)
13078 "Get an article and insert it into this buffer."
13082 (gnus-kill-all-overlays)
13083 (setq group (or group gnus-newsgroup-name))
13085 ;; Open server if it has closed.
13086 (gnus-check-server (gnus-find-method-for-group group))
13088 ;; Using `gnus-request-article' directly will insert the article into
13089 ;; `nntp-server-buffer' - so we'll save some time by not having to
13090 ;; copy it from the server buffer into the article buffer.
13092 ;; We only request an article by message-id when we do not have the
13093 ;; headers for it, so we'll have to get those.
13094 (when (stringp article)
13095 (let ((gnus-override-method gnus-refer-article-method))
13096 (gnus-read-header article)))
13098 ;; If the article number is negative, that means that this article
13099 ;; doesn't belong in this newsgroup (possibly), so we find its
13100 ;; message-id and request it by id instead of number.
13101 (when (and (numberp article)
13102 gnus-summary-buffer
13103 (buffer-name gnus-summary-buffer))
13105 (set-buffer gnus-summary-buffer)
13106 (let ((header (gnus-summary-article-header article)))
13109 ((memq article gnus-newsgroup-sparse)
13110 ;; This is a sparse gap article.
13111 (setq article (mail-header-id header)))
13113 ;; It's a real article.
13114 (setq article (mail-header-id header)))
13116 ;; It is an extracted pseudo-article.
13117 (setq article 'pseudo)
13118 (gnus-request-pseudo-article header))))
13120 (let ((method (gnus-find-method-for-group
13121 gnus-newsgroup-name)))
13122 (if (not (eq (car method) 'nneething))
13124 (let ((dir (concat (file-name-as-directory (nth 1 method))
13125 (mail-header-subject header))))
13126 (if (file-directory-p dir)
13128 (setq article 'nneething)
13129 (gnus-group-enter-directory dir)))))))))
13132 ;; We first check `gnus-original-article-buffer'.
13133 ((and (equal (car gnus-original-article) group)
13134 (eq (cdr gnus-original-article) article)
13135 (get-buffer gnus-original-article-buffer))
13136 (insert-buffer-substring gnus-original-article-buffer)
13138 ;; Check the backlog.
13139 ((and gnus-keep-backlog
13140 (gnus-backlog-request-article group article (current-buffer)))
13142 ;; Check the cache.
13143 ((and gnus-use-cache
13145 (gnus-cache-request-article article group))
13147 ;; Get the article and put into the article buffer.
13148 ((or (stringp article) (numberp article))
13149 (let ((gnus-override-method
13150 (and (stringp article) gnus-refer-article-method))
13151 (buffer-read-only nil))
13153 (gnus-kill-all-overlays)
13154 (if (gnus-request-article article group (current-buffer))
13156 (and gnus-keep-backlog
13157 (gnus-backlog-enter-article
13158 group article (current-buffer)))
13160 ;; It was a pseudo.
13163 ;; Take the article from the original article buffer
13164 ;; and place it in the buffer it's supposed to be in.
13165 (setq gnus-original-article (cons group article))
13166 (when (and (get-buffer gnus-article-buffer)
13167 (equal (buffer-name (current-buffer))
13168 (buffer-name (get-buffer gnus-article-buffer))))
13170 (if (get-buffer gnus-original-article-buffer)
13171 (set-buffer (get-buffer gnus-original-article-buffer))
13172 (set-buffer (get-buffer-create gnus-original-article-buffer))
13173 (buffer-disable-undo (current-buffer))
13174 (setq major-mode 'gnus-original-article-mode)
13175 (setq buffer-read-only t)
13176 (gnus-add-current-to-buffer-list))
13177 (let (buffer-read-only)
13179 (insert-buffer-substring gnus-article-buffer))))
13181 ;; Update sparse articles.
13182 (when (memq article gnus-newsgroup-sparse)
13183 (gnus-summary-update-article article))))
13185 (defun gnus-read-header (id)
13186 "Read the headers of article ID and enter them into the Gnus system."
13187 (let ((group gnus-newsgroup-name)
13188 (headers gnus-newsgroup-headers)
13190 ;; First we check to see whether the header in question is already
13193 ;; This is a Message-ID.
13194 (setq header (gnus-id-to-header id))
13195 ;; This is an article number.
13196 (setq header (gnus-summary-article-header id)))
13198 ;; We have found the header.
13200 ;; We have to really fetch the header to this article.
13202 (if (gnus-check-backend-function 'request-head group)
13203 (gnus-request-head id group)
13204 (gnus-request-article id group)))
13206 (set-buffer nntp-server-buffer)
13207 (and (search-forward "\n\n" nil t)
13208 (delete-region (1- (point)) (point-max)))
13209 (goto-char (point-max))
13211 (goto-char (point-min))
13220 gnus-reffed-article-number)))
13221 " Article retrieved.\n"))
13222 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13223 () ; Malformed head.
13224 (if (and (stringp id)
13225 (not (string= (gnus-group-real-name group)
13227 ;; If we fetched by Message-ID and the article came
13228 ;; from a different group, we fudge some bogus article
13229 ;; numbers for this article.
13230 (mail-header-set-number header gnus-reffed-article-number))
13231 (decf gnus-reffed-article-number)
13232 (push header gnus-newsgroup-headers)
13233 (setq gnus-current-headers header)
13234 (push (mail-header-number header) gnus-newsgroup-limit)
13237 (defun gnus-article-prepare (article &optional all-headers header)
13238 "Prepare ARTICLE in article mode buffer.
13239 ARTICLE should either be an article number or a Message-ID.
13240 If ARTICLE is an id, HEADER should be the article headers.
13241 If ALL-HEADERS is non-nil, no headers are hidden."
13243 ;; Make sure we start in a summary buffer.
13244 (unless (eq major-mode 'gnus-summary-mode)
13245 (set-buffer gnus-summary-buffer))
13246 (setq gnus-summary-buffer (current-buffer))
13247 ;; Make sure the connection to the server is alive.
13248 (unless (gnus-server-opened
13249 (gnus-find-method-for-group gnus-newsgroup-name))
13250 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13251 (gnus-request-group gnus-newsgroup-name t))
13252 (let* ((article (if header (mail-header-number header) article))
13253 (summary-buffer (current-buffer))
13254 (internal-hook gnus-article-internal-prepare-hook)
13255 (group gnus-newsgroup-name)
13258 (gnus-article-setup-buffer)
13259 (set-buffer gnus-article-buffer)
13260 ;; Deactivate active regions.
13261 (when (and (boundp 'transient-mark-mode)
13262 transient-mark-mode)
13263 (setq mark-active nil))
13264 (if (not (setq result (let ((buffer-read-only nil))
13265 (gnus-request-article-this-buffer
13267 ;; There is no such article.
13269 (when (and (numberp article)
13270 (not (memq article gnus-newsgroup-sparse)))
13271 (setq gnus-article-current
13272 (cons gnus-newsgroup-name article))
13273 (set-buffer gnus-summary-buffer)
13274 (setq gnus-current-article article)
13275 (gnus-summary-mark-article article gnus-canceled-mark))
13276 (unless (memq article gnus-newsgroup-sparse)
13278 1 "No such article (may have expired or been canceled)")
13281 (if (or (eq result 'pseudo) (eq result 'nneething))
13284 (set-buffer summary-buffer)
13285 (setq gnus-last-article gnus-current-article
13286 gnus-newsgroup-history (cons gnus-current-article
13287 gnus-newsgroup-history)
13288 gnus-current-article 0
13289 gnus-current-headers nil
13290 gnus-article-current nil)
13291 (if (eq result 'nneething)
13292 (gnus-configure-windows 'summary)
13293 (gnus-configure-windows 'article))
13294 (gnus-set-global-variables))
13295 (gnus-set-mode-line 'article))
13296 ;; The result from the `request' was an actual article -
13297 ;; or at least some text that is now displayed in the
13299 (if (and (numberp article)
13300 (not (eq article gnus-current-article)))
13301 ;; Seems like a new article has been selected.
13302 ;; `gnus-current-article' must be an article number.
13304 (set-buffer summary-buffer)
13305 (setq gnus-last-article gnus-current-article
13306 gnus-newsgroup-history (cons gnus-current-article
13307 gnus-newsgroup-history)
13308 gnus-current-article article
13309 gnus-current-headers
13310 (gnus-summary-article-header gnus-current-article)
13311 gnus-article-current
13312 (cons gnus-newsgroup-name gnus-current-article))
13313 (unless (vectorp gnus-current-headers)
13314 (setq gnus-current-headers nil))
13315 (gnus-summary-show-thread)
13316 (run-hooks 'gnus-mark-article-hook)
13317 (gnus-set-mode-line 'summary)
13318 (and (gnus-visual-p 'article-highlight 'highlight)
13319 (run-hooks 'gnus-visual-mark-article-hook))
13320 ;; Set the global newsgroup variables here.
13321 ;; Suggested by Jim Sisolak
13322 ;; <sisolak@trans4.neep.wisc.edu>.
13323 (gnus-set-global-variables)
13324 (setq gnus-have-all-headers
13325 (or all-headers gnus-show-all-headers))
13326 (and gnus-use-cache
13327 (vectorp (gnus-summary-article-header article))
13328 (gnus-cache-possibly-enter-article
13330 (gnus-summary-article-header article)
13331 (memq article gnus-newsgroup-marked)
13332 (memq article gnus-newsgroup-dormant)
13333 (memq article gnus-newsgroup-unreads)))))
13334 ;; Hooks for getting information from the article.
13335 ;; This hook must be called before being narrowed.
13336 (let (buffer-read-only)
13337 (run-hooks 'internal-hook)
13338 (run-hooks 'gnus-article-prepare-hook)
13339 ;; Decode MIME message.
13341 (if (or (not gnus-strict-mime)
13342 (gnus-fetch-field "Mime-Version"))
13343 (funcall gnus-show-mime-method)
13344 (funcall gnus-decode-encoded-word-method)))
13345 ;; Perform the article display hooks.
13346 (run-hooks 'gnus-article-display-hook))
13348 (goto-char (point-min))
13349 (and gnus-break-pages (gnus-narrow-to-page))
13350 (gnus-set-mode-line 'article)
13351 (gnus-configure-windows 'article)
13352 (goto-char (point-min))
13355 (defun gnus-article-show-all-headers ()
13356 "Show all article headers in article mode buffer."
13358 (gnus-article-setup-buffer)
13359 (set-buffer gnus-article-buffer)
13360 (let ((buffer-read-only nil))
13361 (remove-text-properties (point-min) (point-max)
13362 gnus-hidden-properties))))
13364 (defun gnus-article-hide-headers-if-wanted ()
13365 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13366 Provided for backwards compatibility."
13367 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13368 gnus-inhibit-hiding
13369 (gnus-article-hide-headers)))
13371 (defun gnus-article-hide-headers (&optional arg delete)
13372 "Toggle whether to hide unwanted headers and possibly sort them as well.
13373 If given a negative prefix, always show; if given a positive prefix,
13376 (unless (gnus-article-check-hidden-text 'headers arg)
13377 ;; This function might be inhibited.
13378 (unless gnus-inhibit-hiding
13380 (set-buffer gnus-article-buffer)
13382 (let ((buffer-read-only nil)
13383 (ignored (when (not (stringp gnus-visible-headers))
13384 (cond ((stringp gnus-ignored-headers)
13385 gnus-ignored-headers)
13386 ((listp gnus-ignored-headers)
13387 (mapconcat 'identity gnus-ignored-headers
13390 (cond ((stringp gnus-visible-headers)
13391 gnus-visible-headers)
13392 ((and gnus-visible-headers
13393 (listp gnus-visible-headers))
13394 (mapconcat 'identity gnus-visible-headers "\\|"))))
13395 want-list beg want-l)
13396 ;; First we narrow to just the headers.
13398 (goto-char (point-min))
13399 ;; Hide any "From " lines at the beginning of (mail) articles.
13400 (while (looking-at "From ")
13403 (add-text-properties
13404 (point-min) (point)
13405 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13406 ;; Then treat the rest of the header lines.
13409 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13410 ;; Then we use the two regular expressions
13411 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13412 ;; select which header lines is to remain visible in the
13414 (goto-char (point-min))
13415 (while (re-search-forward "^[^ \t]*:" nil t)
13416 (beginning-of-line)
13417 ;; We add the headers we want to keep to a list and delete
13418 ;; them from the buffer.
13419 (if (or (and visible (looking-at visible))
13420 (and ignored (not (looking-at ignored))))
13422 (push (buffer-substring
13426 ;; Be sure to get multi-line headers...
13427 (re-search-forward "^[^ \t]*:" nil t)
13428 (beginning-of-line)
13431 (delete-region beg (point)))
13433 ;; Sort the headers that we want to display.
13434 (setq want-list (sort want-list 'gnus-article-header-less))
13435 (goto-char (point-min))
13437 (insert (pop want-list)))
13438 ;; We make the unwanted headers invisible.
13440 (delete-region (point-min) (point-max))
13441 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13442 (add-text-properties
13443 (point) (point-max)
13444 (nconc (list 'gnus-type 'headers)
13445 gnus-hidden-properties)))))))))
13447 (defsubst gnus-article-header-rank (header)
13448 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13449 (let ((list gnus-sorted-header-list)
13452 (when (string-match (car list) header)
13454 (setq list (cdr list))
13458 (defun gnus-article-header-less (h1 h2)
13459 "Say whether string H1 is \"less\" than string H2."
13460 (< (gnus-article-header-rank h1)
13461 (gnus-article-header-rank h2)))
13463 (defun gnus-article-hide-boring-headers (&optional arg)
13464 "Toggle hiding of headers that aren't very interesting.
13465 If given a negative prefix, always show; if given a positive prefix,
13468 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13470 (set-buffer gnus-article-buffer)
13472 (let ((buffer-read-only nil)
13473 (list gnus-boring-article-headers)
13474 (inhibit-point-motion-hooks t)
13476 (nnheader-narrow-to-headers)
13478 (setq elem (pop list))
13479 (goto-char (point-min))
13481 ;; Hide empty headers.
13483 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13485 (add-text-properties
13486 (progn (beginning-of-line) (point))
13489 (if (re-search-forward "^[^ \t]" nil t)
13490 (match-beginning 0)
13492 (nconc (list 'gnus-type 'boring-headers)
13493 gnus-hidden-properties))))
13494 ;; Hide boring Newsgroups header.
13495 ((eq elem 'newsgroups)
13496 (when (equal (mail-fetch-field "newsgroups")
13497 (gnus-group-real-name gnus-newsgroup-name))
13498 (gnus-article-hide-header "newsgroups")))
13499 ((eq elem 'followup-to)
13500 (when (equal (mail-fetch-field "followup-to")
13501 (mail-fetch-field "newsgroups"))
13502 (gnus-article-hide-header "followup-to")))
13503 ((eq elem 'reply-to)
13504 (let ((from (mail-fetch-field "from"))
13505 (reply-to (mail-fetch-field "reply-to")))
13509 (nth 1 (mail-extract-address-components from))
13510 (nth 1 (mail-extract-address-components reply-to))))
13511 (gnus-article-hide-header "reply-to"))))
13513 (let ((date (mail-fetch-field "date")))
13515 (< (gnus-days-between date (current-time-string))
13517 (gnus-article-hide-header "date")))))))))))
13519 (defun gnus-article-hide-header (header)
13521 (goto-char (point-min))
13522 (when (re-search-forward (concat "^" header ":") nil t)
13523 (add-text-properties
13524 (progn (beginning-of-line) (point))
13527 (if (re-search-forward "^[^ \t]" nil t)
13528 (match-beginning 0)
13530 (nconc (list 'gnus-type 'boring-headers)
13531 gnus-hidden-properties)))))
13533 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13534 (defun gnus-article-treat-overstrike ()
13535 "Translate overstrikes into bold text."
13538 (set-buffer gnus-article-buffer)
13539 (let ((buffer-read-only nil))
13540 (while (search-forward "\b" nil t)
13541 (let ((next (following-char))
13542 (previous (char-after (- (point) 2))))
13543 (cond ((eq next previous)
13544 (put-text-property (- (point) 2) (point) 'invisible t)
13545 (put-text-property (point) (1+ (point)) 'face 'bold))
13547 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13549 (- (point) 2) (1- (point)) 'face 'underline))
13551 (put-text-property (- (point) 2) (point) 'invisible t)
13553 (point) (1+ (point)) 'face 'underline))))))))
13555 (defun gnus-article-word-wrap ()
13556 "Format too long lines."
13559 (set-buffer gnus-article-buffer)
13560 (let ((buffer-read-only nil)
13563 (goto-char (point-min))
13564 (search-forward "\n\n" nil t)
13566 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13567 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13568 (adaptive-fill-mode t))
13569 (while (not (eobp))
13570 (and (>= (current-column) (min fill-column (window-width)))
13571 (/= (preceding-char) ?:)
13572 (fill-paragraph nil))
13573 (end-of-line 2))))))
13575 (defun gnus-article-remove-cr ()
13576 "Remove carriage returns from an article."
13579 (set-buffer gnus-article-buffer)
13580 (let ((buffer-read-only nil))
13581 (goto-char (point-min))
13582 (while (search-forward "\r" nil t)
13583 (replace-match "" t t)))))
13585 (defun gnus-article-remove-trailing-blank-lines ()
13586 "Remove all trailing blank lines from the article."
13589 (set-buffer gnus-article-buffer)
13590 (let ((buffer-read-only nil))
13591 (goto-char (point-max))
13595 (while (looking-at "^[ \t]*$")
13600 (defun gnus-article-display-x-face (&optional force)
13601 "Look for an X-Face header and display it if present."
13602 (interactive (list 'force))
13604 (set-buffer gnus-article-buffer)
13605 ;; Delete the old process, if any.
13606 (when (process-status "gnus-x-face")
13607 (delete-process "gnus-x-face"))
13608 (let ((inhibit-point-motion-hooks t)
13609 (case-fold-search nil)
13612 (nnheader-narrow-to-headers)
13613 (setq from (mail-fetch-field "from"))
13614 (goto-char (point-min))
13615 (when (and gnus-article-x-face-command
13617 ;; Check whether this face is censored.
13618 (not gnus-article-x-face-too-ugly)
13619 (and gnus-article-x-face-too-ugly from
13620 (not (string-match gnus-article-x-face-too-ugly
13622 ;; Has to be present.
13623 (re-search-forward "^X-Face: " nil t))
13624 ;; We now have the area of the buffer where the X-Face is stored.
13625 (let ((beg (point))
13626 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13627 ;; We display the face.
13628 (if (symbolp gnus-article-x-face-command)
13629 ;; The command is a lisp function, so we call it.
13630 (if (gnus-functionp gnus-article-x-face-command)
13631 (funcall gnus-article-x-face-command beg end)
13632 (error "%s is not a function" gnus-article-x-face-command))
13633 ;; The command is a string, so we interpret the command
13634 ;; as a, well, command, and fork it off.
13635 (let ((process-connection-type nil))
13636 (process-kill-without-query
13638 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13639 (process-send-region "gnus-x-face" beg end)
13640 (process-send-eof "gnus-x-face")))))))))
13642 (defun gnus-headers-decode-quoted-printable ()
13643 "Hack to remove QP encoding from headers."
13644 (let ((case-fold-search t)
13645 (inhibit-point-motion-hooks t)
13647 (goto-char (point-min))
13648 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13649 (setq string (match-string 1))
13650 (narrow-to-region (match-beginning 0) (match-end 0))
13651 (delete-region (point-min) (point-max))
13653 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13654 (subst-char-in-region (point-min) (point-max) ?_ ? )
13656 (goto-char (point-min)))))
13658 (defun gnus-article-de-quoted-unreadable (&optional force)
13659 "Do a naive translation of a quoted-printable-encoded article.
13660 This is in no way, shape or form meant as a replacement for real MIME
13661 processing, but is simply a stop-gap measure until MIME support is
13663 If FORCE, decode the article whether it is marked as quoted-printable
13665 (interactive (list 'force))
13667 (set-buffer gnus-article-buffer)
13668 (let ((case-fold-search t)
13669 (buffer-read-only nil)
13670 (type (gnus-fetch-field "content-transfer-encoding")))
13672 (and type (string-match "quoted-printable" type)))
13673 (gnus-headers-decode-quoted-printable)
13674 (goto-char (point-min))
13675 (search-forward "\n\n" nil 'move)
13676 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13678 (defun gnus-mime-decode-quoted-printable (from to)
13679 "Decode Quoted-Printable in the region between FROM and TO."
13681 (while (search-forward "=" to t)
13682 (cond ((eq (following-char) ?\n)
13685 ((looking-at "[0-9A-F][0-9A-F]")
13687 (insert (hexl-hex-string-to-integer
13688 (buffer-substring (point) (+ 2 (point)))))
13692 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13694 (defun gnus-article-hide-pgp (&optional arg)
13695 "Toggle hiding of any PGP headers and signatures in the current article.
13696 If given a negative prefix, always show; if given a positive prefix,
13699 (unless (gnus-article-check-hidden-text 'pgp arg)
13701 (set-buffer gnus-article-buffer)
13702 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13703 buffer-read-only beg end)
13705 (goto-char (point-min))
13706 ;; Hide the "header".
13707 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13708 (add-text-properties (match-beginning 0) (match-end 0) props))
13710 ;; Hide the actual signature.
13711 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13712 (setq end (match-beginning 0))
13713 (add-text-properties
13714 (match-beginning 0)
13715 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13717 ;; Perhaps we shouldn't hide to the end of the buffer
13718 ;; if there is no end to the signature?
13721 ;; Hide "- " PGP quotation markers.
13722 (when (and beg end)
13723 (narrow-to-region beg end)
13724 (goto-char (point-min))
13725 (while (re-search-forward "^- " nil t)
13726 (add-text-properties (match-beginning 0) (match-end 0) props))
13729 (defun gnus-article-hide-signature (&optional arg)
13730 "Hide the signature in the current article.
13731 If given a negative prefix, always show; if given a positive prefix,
13734 (unless (gnus-article-check-hidden-text 'signature arg)
13736 (set-buffer gnus-article-buffer)
13738 (let ((buffer-read-only nil))
13739 (when (gnus-narrow-to-signature)
13740 (add-text-properties
13741 (point-min) (point-max)
13742 (nconc (list 'gnus-type 'signature)
13743 gnus-hidden-properties))))))))
13745 (defvar gnus-signature-limit nil
13746 "Provide a limit to what is considered a signature.
13747 If it is a number, no signature may not be longer (in characters) than
13748 that number. If it is a function, the function will be called without
13749 any parameters, and if it returns nil, there is no signature in the
13750 buffer. If it is a string, it will be used as a regexp. If it
13751 matches, the text in question is not a signature.")
13753 (defun gnus-narrow-to-signature ()
13754 "Narrow to the signature."
13756 (goto-char (point-max))
13757 (when (re-search-backward gnus-signature-separator nil t)
13759 (when (or (null gnus-signature-limit)
13760 (and (numberp gnus-signature-limit)
13761 (< (- (point-max) (point)) gnus-signature-limit))
13762 (and (gnus-functionp gnus-signature-limit)
13763 (funcall gnus-signature-limit))
13764 (and (stringp gnus-signature-limit)
13765 (not (re-search-forward gnus-signature-limit nil t))))
13766 (narrow-to-region (point) (point-max))
13769 (defun gnus-article-check-hidden-text (type arg)
13770 "Return nil if hiding is necessary."
13772 (set-buffer gnus-article-buffer)
13773 (let ((hide (gnus-article-hidden-text-p type)))
13774 (cond ((or (and (null arg) (eq hide 'hidden))
13775 (and arg (< 0 (prefix-numeric-value arg))))
13776 (gnus-article-show-hidden-text type))
13778 (gnus-article-show-hidden-text type t))
13781 (defun gnus-article-hidden-text-p (type)
13782 "Say whether the current buffer contains hidden text of type TYPE."
13783 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13786 (if (get-text-property pos 'invisible)
13790 (defun gnus-article-hide (&optional arg force)
13791 "Hide all the gruft in the current article.
13792 This means that PGP stuff, signatures, cited text and (some)
13793 headers will be hidden.
13794 If given a prefix, show the hidden text instead."
13795 (interactive (list current-prefix-arg 'force))
13796 (gnus-article-hide-headers arg)
13797 (gnus-article-hide-pgp arg)
13798 (gnus-article-hide-citation-maybe arg force)
13799 (gnus-article-hide-signature arg))
13801 (defun gnus-article-show-hidden-text (type &optional hide)
13802 "Show all hidden text of type TYPE.
13803 If HIDE, hide the text instead."
13805 (set-buffer gnus-article-buffer)
13806 (let ((buffer-read-only nil)
13807 (inhibit-point-motion-hooks t)
13809 (while (gnus-goto-char (text-property-any
13810 beg (point-max) 'gnus-type type))
13814 (add-text-properties beg (point) gnus-hidden-properties)
13815 (remove-text-properties beg (point) gnus-hidden-properties))
13816 (setq beg (point)))
13819 (defvar gnus-article-time-units
13820 `((year . ,(* 365.25 24 60 60))
13821 (week . ,(* 7 24 60 60))
13822 (day . ,(* 24 60 60))
13823 (hour . ,(* 60 60))
13826 "Mapping from time units to seconds.")
13828 (defun gnus-article-date-ut (&optional type highlight)
13829 "Convert DATE date to universal time in the current article.
13830 If TYPE is `local', convert to local time; if it is `lapsed', output
13831 how much time has lapsed since DATE."
13832 (interactive (list 'ut t))
13833 (let* ((header (or gnus-current-headers
13834 (gnus-summary-article-header) ""))
13835 (date (and (vectorp header) (mail-header-date header)))
13836 (date-regexp "^Date: \\|^X-Sent: ")
13837 (now (current-time))
13838 (inhibit-point-motion-hooks t))
13839 (when (and date (not (string= date "")))
13841 (set-buffer gnus-article-buffer)
13843 (nnheader-narrow-to-headers)
13844 (let ((buffer-read-only nil))
13845 ;; Delete any old Date headers.
13846 (if (zerop (nnheader-remove-header date-regexp t))
13847 (beginning-of-line)
13848 (goto-char (point-max)))
13851 ;; Convert to the local timezone. We have to slap a
13852 ;; `condition-case' round the calls to the timezone
13853 ;; functions since they aren't particularly resistant to
13856 (concat "Date: " (condition-case ()
13857 (timezone-make-date-arpa-standard date)
13860 ;; Convert to Universal Time.
13864 (timezone-make-date-arpa-standard date nil "UT")
13867 ;; Get the original date from the article.
13868 ((eq type 'original)
13869 (concat "Date: " date "\n"))
13870 ;; Do an X-Sent lapsed format.
13872 ;; If the date is seriously mangled, the timezone
13873 ;; functions are liable to bug out, so we condition-case
13874 ;; the entire thing.
13879 (timezone-make-date-arpa-standard
13880 (current-time-string now)
13881 (current-time-zone now) "UT"))
13883 (timezone-make-date-arpa-standard
13886 (real-sec (+ (* (float (car real-time)) 65536)
13888 (sec (abs real-sec))
13894 ;; This is a bit convoluted, but basically we go
13895 ;; through the time units for years, weeks, etc,
13896 ;; and divide things to see whether that results
13897 ;; in positive answers.
13900 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13901 ;; The (remaining) seconds are too few to
13902 ;; be divided into this time unit.
13904 ;; It's big enough, so we output it.
13905 (setq sec (- sec (* num (cdr unit))))
13907 (concat (if prev ", " "") (int-to-string
13909 " " (symbol-name (car unit))
13910 (if (> num 1) "s" ""))
13912 gnus-article-time-units "")
13913 ;; If dates are odd, then it might appear like the
13914 ;; article was sent in the future.
13917 " in the future\n")))))
13919 (error "Unknown conversion type: %s" type)))))
13920 ;; Do highlighting.
13921 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13922 (gnus-article-highlight-headers)))))))
13924 (defun gnus-article-date-local (&optional highlight)
13925 "Convert the current article date to the local timezone."
13926 (interactive (list t))
13927 (gnus-article-date-ut 'local highlight))
13929 (defun gnus-article-date-original (&optional highlight)
13930 "Convert the current article date to what it was originally.
13931 This is only useful if you have used some other date conversion
13932 function and want to see what the date was before converting."
13933 (interactive (list t))
13934 (gnus-article-date-ut 'original highlight))
13936 (defun gnus-article-date-lapsed (&optional highlight)
13937 "Convert the current article date to time lapsed since it was sent."
13938 (interactive (list t))
13939 (gnus-article-date-ut 'lapsed highlight))
13941 (defun gnus-article-maybe-highlight ()
13942 "Do some article highlighting if `gnus-visual' is non-nil."
13943 (if (gnus-visual-p 'article-highlight 'highlight)
13944 (gnus-article-highlight-some)))
13948 (defun gnus-output-to-rmail (file-name)
13949 "Append the current article to an Rmail file named FILE-NAME."
13951 ;; Most of these codes are borrowed from rmailout.el.
13952 (setq file-name (expand-file-name file-name))
13953 (setq rmail-default-rmail-file file-name)
13954 (let ((artbuf (current-buffer))
13955 (tmpbuf (get-buffer-create " *Gnus-output*")))
13957 (or (get-file-buffer file-name)
13958 (file-exists-p file-name)
13959 (if (gnus-yes-or-no-p
13960 (concat "\"" file-name "\" does not exist, create it? "))
13961 (let ((file-buffer (create-file-buffer file-name)))
13963 (set-buffer file-buffer)
13964 (rmail-insert-rmail-file-header)
13965 (let ((require-final-newline nil))
13966 (write-region (point-min) (point-max) file-name t 1)))
13967 (kill-buffer file-buffer))
13968 (error "Output file does not exist")))
13969 (set-buffer tmpbuf)
13970 (buffer-disable-undo (current-buffer))
13972 (insert-buffer-substring artbuf)
13973 (gnus-convert-article-to-rmail)
13974 ;; Decide whether to append to a file or to an Emacs buffer.
13975 (let ((outbuf (get-file-buffer file-name)))
13977 (append-to-file (point-min) (point-max) file-name)
13978 ;; File has been visited, in buffer OUTBUF.
13979 (set-buffer outbuf)
13980 (let ((buffer-read-only nil)
13981 (msg (and (boundp 'rmail-current-message)
13982 (symbol-value 'rmail-current-message))))
13983 ;; If MSG is non-nil, buffer is in RMAIL mode.
13986 (narrow-to-region (point-max) (point-max))))
13987 (insert-buffer-substring tmpbuf)
13990 (goto-char (point-min))
13992 (search-backward "\^_")
13993 (narrow-to-region (point) (point-max))
13994 (goto-char (1+ (point-min)))
13995 (rmail-count-new-messages t)
13996 (rmail-show-message msg)))))))
13997 (kill-buffer tmpbuf)))
13999 (defun gnus-output-to-file (file-name)
14000 "Append the current article to a file named FILE-NAME."
14001 (setq file-name (expand-file-name file-name))
14002 (let ((artbuf (current-buffer))
14003 (tmpbuf (get-buffer-create " *Gnus-output*")))
14005 (set-buffer tmpbuf)
14006 (buffer-disable-undo (current-buffer))
14008 (insert-buffer-substring artbuf)
14009 ;; Append newline at end of the buffer as separator, and then
14010 ;; save it to file.
14011 (goto-char (point-max))
14013 (append-to-file (point-min) (point-max) file-name))
14014 (kill-buffer tmpbuf)))
14016 (defun gnus-convert-article-to-rmail ()
14017 "Convert article in current buffer to Rmail message format."
14018 (let ((buffer-read-only nil))
14019 ;; Convert article directly into Babyl format.
14020 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14021 (goto-char (point-min))
14022 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14023 (while (search-forward "\n\^_" nil t) ;single char
14024 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14025 (goto-char (point-max))
14028 (defun gnus-narrow-to-page (&optional arg)
14029 "Narrow the article buffer to a page.
14030 If given a numerical ARG, move forward ARG pages."
14032 (setq arg (if arg (prefix-numeric-value arg) 0))
14034 (set-buffer gnus-article-buffer)
14035 (goto-char (point-min))
14037 (when (gnus-visual-p 'page-marker)
14038 (let ((buffer-read-only nil))
14039 (gnus-remove-text-with-property 'gnus-prev)
14040 (gnus-remove-text-with-property 'gnus-next)))
14043 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14045 (re-search-forward page-delimiter nil 'move arg)))
14046 (goto-char (match-end 0)))
14049 (if (re-search-forward page-delimiter nil 'move)
14050 (match-beginning 0)
14052 (when (and (gnus-visual-p 'page-marker)
14053 (not (= (point-min) 1)))
14055 (goto-char (point-min))
14056 (gnus-insert-prev-page-button)))
14057 (when (and (gnus-visual-p 'page-marker)
14058 (not (= (1- (point-max)) (buffer-size))))
14060 (goto-char (point-max))
14061 (gnus-insert-next-page-button)))))
14063 ;; Article mode commands
14065 (defun gnus-article-goto-next-page ()
14066 "Show the next page of the article."
14068 (when (gnus-article-next-page)
14069 (gnus-article-read-summary-keys nil ?n)))
14071 (defun gnus-article-goto-prev-page ()
14072 "Show the next page of the article."
14074 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14075 (gnus-article-prev-page nil)))
14077 (defun gnus-article-next-page (&optional lines)
14078 "Show the next page of the current article.
14079 If end of article, return non-nil. Otherwise return nil.
14080 Argument LINES specifies lines to be scrolled up."
14082 (move-to-window-line -1)
14083 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14084 (if (save-excursion
14086 (and (pos-visible-in-window-p) ;Not continuation line.
14088 ;; Nothing in this page.
14089 (if (or (not gnus-break-pages)
14092 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14094 (gnus-narrow-to-page 1) ;Go to next page.
14096 ;; More in this page.
14100 ;; Long lines may cause an end-of-buffer error.
14101 (goto-char (point-max))))
14104 (defun gnus-article-prev-page (&optional lines)
14105 "Show previous page of current article.
14106 Argument LINES specifies lines to be scrolled down."
14108 (move-to-window-line 0)
14109 (if (and gnus-break-pages
14111 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14113 (gnus-narrow-to-page -1) ;Go to previous page.
14114 (goto-char (point-max))
14117 (scroll-down lines)
14120 (defun gnus-article-refer-article ()
14121 "Read article specified by message-id around point."
14123 (let ((point (point)))
14124 (search-forward ">" nil t) ;Move point to end of "<....>".
14125 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14126 (let ((message-id (match-string 1)))
14128 (set-buffer gnus-summary-buffer)
14129 (gnus-summary-refer-article message-id))
14130 (goto-char (point))
14131 (error "No references around point"))))
14133 (defun gnus-article-show-summary ()
14134 "Reconfigure windows to show summary buffer."
14136 (gnus-configure-windows 'article)
14137 (gnus-summary-goto-subject gnus-current-article))
14139 (defun gnus-article-describe-briefly ()
14140 "Describe article mode commands briefly."
14143 (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")))
14145 (defun gnus-article-summary-command ()
14146 "Execute the last keystroke in the summary buffer."
14148 (let ((obuf (current-buffer))
14149 (owin (current-window-configuration))
14151 (switch-to-buffer gnus-summary-buffer 'norecord)
14152 (setq func (lookup-key (current-local-map) (this-command-keys)))
14153 (call-interactively func)
14155 (set-window-configuration owin)
14156 (set-window-point (get-buffer-window (current-buffer)) (point))))
14158 (defun gnus-article-summary-command-nosave ()
14159 "Execute the last keystroke in the summary buffer."
14162 (pop-to-buffer gnus-summary-buffer 'norecord)
14163 (setq func (lookup-key (current-local-map) (this-command-keys)))
14164 (call-interactively func)))
14166 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14167 "Read a summary buffer key sequence and execute it from the article buffer."
14170 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14171 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14175 (set-buffer gnus-summary-buffer)
14176 (push (or key last-command-event) unread-command-events)
14177 (setq keys (read-key-sequence nil)))
14180 (if (member keys nosaves)
14182 (pop-to-buffer gnus-summary-buffer 'norecord)
14183 (if (setq func (lookup-key (current-local-map) keys))
14184 (call-interactively func)
14186 (let ((obuf (current-buffer))
14187 (owin (current-window-configuration))
14190 (if not-restore-window
14191 (pop-to-buffer gnus-summary-buffer 'norecord)
14192 (switch-to-buffer gnus-summary-buffer 'norecord))
14193 (setq in-buffer (current-buffer))
14194 (if (setq func (lookup-key (current-local-map) keys))
14195 (call-interactively func)
14197 (when (eq in-buffer (current-buffer))
14199 (unless not-restore-window
14200 (set-window-configuration owin))
14201 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14205 ;;; Kill file handling.
14209 (defalias 'gnus-batch-kill 'gnus-batch-score)
14211 (defun gnus-batch-score ()
14212 "Run batched scoring.
14213 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14214 Newsgroups is a list of strings in Bnews format. If you want to score
14215 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14216 score the alt hierarchy, you'd say \"!alt.all\"."
14219 (gnus-newsrc-parse-options
14220 (apply (function concat)
14221 (mapcar (lambda (g) (concat g " "))
14222 command-line-args-left))))
14223 (gnus-expert-user t)
14224 (nnmail-spool-file nil)
14225 (gnus-use-dribble-file nil)
14226 (yes (car yes-and-no))
14227 (no (cdr yes-and-no))
14229 ;; Disable verbose message.
14230 gnus-novice-user gnus-large-newsgroup)
14231 ;; Eat all arguments.
14232 (setq command-line-args-left nil)
14235 ;; Apply kills to specified newsgroups in command line arguments.
14236 (setq newsrc (cdr gnus-newsrc-alist))
14238 (setq group (car (car newsrc)))
14239 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14240 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14242 (or (eq (car entry) t)
14243 (not (zerop (car entry)))))
14244 (if yes (string-match yes group) t)
14245 (or (null no) (not (string-match no group))))
14247 (gnus-summary-read-group group nil t nil t)
14248 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14249 (gnus-summary-exit))))
14250 (setq newsrc (cdr newsrc)))
14252 (switch-to-buffer gnus-group-buffer)
14253 (gnus-group-save-newsrc)))
14255 (defun gnus-apply-kill-file ()
14256 "Apply a kill file to the current newsgroup.
14257 Returns the number of articles marked as read."
14258 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14259 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14260 (gnus-apply-kill-file-internal)
14263 (defun gnus-kill-save-kill-buffer ()
14264 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14265 (when (get-file-buffer file)
14267 (set-buffer (get-file-buffer file))
14268 (and (buffer-modified-p) (save-buffer))
14269 (kill-buffer (current-buffer))))))
14271 (defvar gnus-kill-file-name "KILL"
14272 "Suffix of the kill files.")
14274 (defun gnus-newsgroup-kill-file (newsgroup)
14275 "Return the name of a kill file name for NEWSGROUP.
14276 If NEWSGROUP is nil, return the global kill file name instead."
14278 ;; The global KILL file is placed at top of the directory.
14279 ((or (null newsgroup)
14280 (string-equal newsgroup ""))
14281 (expand-file-name gnus-kill-file-name
14282 (or gnus-kill-files-directory "~/News")))
14283 ;; Append ".KILL" to newsgroup name.
14284 ((gnus-use-long-file-name 'not-kill)
14285 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14286 "." gnus-kill-file-name)
14287 (or gnus-kill-files-directory "~/News")))
14288 ;; Place "KILL" under the hierarchical directory.
14290 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14291 "/" gnus-kill-file-name)
14292 (or gnus-kill-files-directory "~/News")))))
14299 (defvar gnus-dribble-ignore nil)
14300 (defvar gnus-dribble-eval-file nil)
14302 (defun gnus-dribble-file-name ()
14303 "Return the dribble file for the current .newsrc."
14305 (if gnus-dribble-directory
14306 (concat (file-name-as-directory gnus-dribble-directory)
14307 (file-name-nondirectory gnus-current-startup-file))
14308 gnus-current-startup-file)
14311 (defun gnus-dribble-enter (string)
14312 "Enter STRING into the dribble buffer."
14313 (if (and (not gnus-dribble-ignore)
14314 gnus-dribble-buffer
14315 (buffer-name gnus-dribble-buffer))
14316 (let ((obuf (current-buffer)))
14317 (set-buffer gnus-dribble-buffer)
14318 (insert string "\n")
14319 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14320 (set-buffer obuf))))
14322 (defun gnus-dribble-read-file ()
14323 "Read the dribble file from disk."
14324 (let ((dribble-file (gnus-dribble-file-name)))
14326 (set-buffer (setq gnus-dribble-buffer
14328 (file-name-nondirectory dribble-file))))
14329 (gnus-add-current-to-buffer-list)
14331 (setq buffer-file-name dribble-file)
14333 (buffer-disable-undo (current-buffer))
14334 (bury-buffer (current-buffer))
14335 (set-buffer-modified-p nil)
14336 (let ((auto (make-auto-save-file-name))
14337 (gnus-dribble-ignore t))
14338 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14339 ;; Load whichever file is newest -- the auto save file
14340 ;; or the "real" file.
14341 (if (file-newer-than-file-p auto dribble-file)
14342 (insert-file-contents auto)
14343 (insert-file-contents dribble-file))
14344 (unless (zerop (buffer-size))
14345 (set-buffer-modified-p t))
14346 ;; Set the file modes to reflect the .newsrc file modes.
14348 (when (file-exists-p gnus-current-startup-file)
14349 (set-file-modes dribble-file
14350 (file-modes gnus-current-startup-file)))
14351 ;; Possibly eval the file later.
14352 (when (gnus-y-or-n-p
14353 "Auto-save file exists. Do you want to read it? ")
14354 (setq gnus-dribble-eval-file t)))))))
14356 (defun gnus-dribble-eval-file ()
14357 (if (not gnus-dribble-eval-file)
14359 (setq gnus-dribble-eval-file nil)
14361 (let ((gnus-dribble-ignore t))
14362 (set-buffer gnus-dribble-buffer)
14363 (eval-buffer (current-buffer))))))
14365 (defun gnus-dribble-delete-file ()
14366 (if (file-exists-p (gnus-dribble-file-name))
14367 (delete-file (gnus-dribble-file-name)))
14368 (if gnus-dribble-buffer
14370 (set-buffer gnus-dribble-buffer)
14371 (let ((auto (make-auto-save-file-name)))
14372 (if (file-exists-p auto)
14373 (delete-file auto))
14375 (set-buffer-modified-p nil)))))
14377 (defun gnus-dribble-save ()
14378 (if (and gnus-dribble-buffer
14379 (buffer-name gnus-dribble-buffer))
14381 (set-buffer gnus-dribble-buffer)
14384 (defun gnus-dribble-clear ()
14386 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14388 (set-buffer gnus-dribble-buffer)
14390 (set-buffer-modified-p nil)
14391 (setq buffer-saved-size (buffer-size))))))
14395 ;;; Server Communication
14398 (defun gnus-start-news-server (&optional confirm)
14399 "Open a method for getting news.
14400 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14402 (if gnus-current-select-method
14403 ;; Stream is already opened.
14405 ;; Open NNTP server.
14406 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14409 ;; Read server name with completion.
14410 (setq gnus-nntp-server
14411 (completing-read "NNTP server: "
14412 (mapcar (lambda (server) (list server))
14413 (cons (list gnus-nntp-server)
14414 gnus-secondary-servers))
14415 nil nil gnus-nntp-server))))
14417 (if (and gnus-nntp-server
14418 (stringp gnus-nntp-server)
14419 (not (string= gnus-nntp-server "")))
14420 (setq gnus-select-method
14421 (cond ((or (string= gnus-nntp-server "")
14422 (string= gnus-nntp-server "::"))
14423 (list 'nnspool (system-name)))
14424 ((string-match "^:" gnus-nntp-server)
14425 (list 'nnmh gnus-nntp-server
14426 (list 'nnmh-directory
14427 (file-name-as-directory
14429 (concat "~/" (substring
14430 gnus-nntp-server 1)))))
14431 (list 'nnmh-get-new-mail nil)))
14433 (list 'nntp gnus-nntp-server)))))
14435 (setq how (car gnus-select-method))
14436 (cond ((eq how 'nnspool)
14438 (gnus-message 5 "Looking up local news spool..."))
14441 (gnus-message 5 "Looking up mh spool..."))
14444 (setq gnus-current-select-method gnus-select-method)
14445 (run-hooks 'gnus-open-server-hook)
14447 ;; gnus-open-server-hook might have opened it
14448 (gnus-server-opened gnus-select-method)
14449 (gnus-open-server gnus-select-method)
14452 "%s (%s) open error: '%s'. Continue? "
14453 (car gnus-select-method) (cadr gnus-select-method)
14454 (gnus-status-message gnus-select-method)))
14456 (gnus-message 1 "Couldn't open server on %s"
14457 (nth 1 gnus-select-method))
14461 (defun gnus-check-group (group)
14462 "Try to make sure that the server where GROUP exists is alive."
14463 (let ((method (gnus-find-method-for-group group)))
14464 (or (gnus-server-opened method)
14465 (gnus-open-server method))))
14467 (defun gnus-check-server (&optional method)
14468 "Check whether the connection to METHOD is down.
14469 If METHOD is nil, use `gnus-select-method'.
14470 If it is down, start it up (again)."
14471 (let ((method (or method gnus-select-method)))
14472 ;; Transform virtual server names into select methods.
14473 (when (stringp method)
14474 (setq method (gnus-server-to-method method)))
14475 (if (gnus-server-opened method)
14476 ;; The stream is already opened.
14478 ;; Open the server.
14479 (gnus-message 5 "Opening %s server%s..." (car method)
14480 (if (equal (nth 1 method) "") ""
14481 (format " on %s" (nth 1 method))))
14482 (run-hooks 'gnus-open-server-hook)
14484 (gnus-open-server method)
14487 (defun gnus-get-function (method function)
14488 "Return a function symbol based on METHOD and FUNCTION."
14489 ;; Translate server names into methods.
14491 (error "Attempted use of a nil select method"))
14492 (when (stringp method)
14493 (setq method (gnus-server-to-method method)))
14494 (let ((func (intern (format "%s-%s" (car method) function))))
14495 ;; If the functions isn't bound, we require the backend in
14497 (unless (fboundp func)
14498 (require (car method))
14499 (unless (fboundp func)
14500 ;; This backend doesn't implement this function.
14501 (error "No such function: %s" func)))
14506 ;;; Interface functions to the backends.
14509 (defun gnus-open-server (method)
14510 "Open a connection to METHOD."
14511 (let ((elem (assoc method gnus-opened-servers)))
14512 ;; If this method was previously denied, we just return nil.
14513 (if (eq (nth 1 elem) 'denied)
14515 (gnus-message 1 "Denied server")
14517 ;; Open the server.
14519 (funcall (gnus-get-function method 'open-server)
14520 (nth 1 method) (nthcdr 2 method))))
14521 ;; If this hasn't been opened before, we add it to the list.
14523 (setq elem (list method nil)
14524 gnus-opened-servers (cons elem gnus-opened-servers)))
14525 ;; Set the status of this server.
14526 (setcar (cdr elem) (if result 'ok 'denied))
14527 ;; Return the result from the "open" call.
14530 (defun gnus-close-server (method)
14531 "Close the connection to METHOD."
14532 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14534 (defun gnus-request-list (method)
14535 "Request the active file from METHOD."
14536 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14538 (defun gnus-request-list-newsgroups (method)
14539 "Request the newsgroups file from METHOD."
14540 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14542 (defun gnus-request-newgroups (date method)
14543 "Request all new groups since DATE from METHOD."
14544 (funcall (gnus-get-function method 'request-newgroups)
14545 date (nth 1 method)))
14547 (defun gnus-server-opened (method)
14548 "Check whether a connection to METHOD has been opened."
14549 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14551 (defun gnus-status-message (method)
14552 "Return the status message from METHOD.
14553 If METHOD is a string, it is interpreted as a group name. The method
14554 this group uses will be queried."
14555 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14557 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14559 (defun gnus-request-group (group &optional dont-check method)
14560 "Request GROUP. If DONT-CHECK, no information is required."
14561 (let ((method (or method (gnus-find-method-for-group group))))
14562 (funcall (gnus-get-function method 'request-group)
14563 (gnus-group-real-name group) (nth 1 method) dont-check)))
14565 (defun gnus-request-asynchronous (group &optional articles)
14566 "Request that GROUP behave asynchronously.
14567 ARTICLES is the `data' of the group."
14568 (let ((method (gnus-find-method-for-group group)))
14569 (funcall (gnus-get-function method 'request-asynchronous)
14570 (gnus-group-real-name group) (nth 1 method) articles)))
14572 (defun gnus-list-active-group (group)
14573 "Request active information on GROUP."
14574 (let ((method (gnus-find-method-for-group group))
14575 (func 'list-active-group))
14576 (when (gnus-check-backend-function func group)
14577 (funcall (gnus-get-function method func)
14578 (gnus-group-real-name group) (nth 1 method)))))
14580 (defun gnus-request-group-description (group)
14581 "Request a description of GROUP."
14582 (let ((method (gnus-find-method-for-group group))
14583 (func 'request-group-description))
14584 (when (gnus-check-backend-function func group)
14585 (funcall (gnus-get-function method func)
14586 (gnus-group-real-name group) (nth 1 method)))))
14588 (defun gnus-close-group (group)
14589 "Request the GROUP be closed."
14590 (let ((method (gnus-find-method-for-group group)))
14591 (funcall (gnus-get-function method 'close-group)
14592 (gnus-group-real-name group) (nth 1 method))))
14594 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14595 "Request headers for ARTICLES in GROUP.
14596 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14597 (let ((method (gnus-find-method-for-group group)))
14598 (if (and gnus-use-cache (numberp (car articles)))
14599 (gnus-cache-retrieve-headers articles group fetch-old)
14600 (funcall (gnus-get-function method 'retrieve-headers)
14601 articles (gnus-group-real-name group) (nth 1 method)
14604 (defun gnus-retrieve-groups (groups method)
14605 "Request active information on GROUPS from METHOD."
14606 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14608 (defun gnus-request-type (group &optional article)
14609 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14610 (let ((method (gnus-find-method-for-group group)))
14611 (if (not (gnus-check-backend-function 'request-type (car method)))
14613 (funcall (gnus-get-function method 'request-type)
14614 (gnus-group-real-name group) article))))
14616 (defun gnus-request-update-mark (group article mark)
14617 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14618 (let ((method (gnus-find-method-for-group group)))
14619 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14621 (funcall (gnus-get-function method 'request-update-mark)
14622 (gnus-group-real-name group) article mark))))
14624 (defun gnus-request-article (article group &optional buffer)
14625 "Request the ARTICLE in GROUP.
14626 ARTICLE can either be an article number or an article Message-ID.
14627 If BUFFER, insert the article in that group."
14628 (let ((method (gnus-find-method-for-group group)))
14629 (funcall (gnus-get-function method 'request-article)
14630 article (gnus-group-real-name group) (nth 1 method) buffer)))
14632 (defun gnus-request-head (article group)
14633 "Request the head of ARTICLE in GROUP."
14634 (let ((method (gnus-find-method-for-group group)))
14635 (funcall (gnus-get-function method 'request-head)
14636 article (gnus-group-real-name group) (nth 1 method))))
14638 (defun gnus-request-body (article group)
14639 "Request the body of ARTICLE in GROUP."
14640 (let ((method (gnus-find-method-for-group group)))
14641 (funcall (gnus-get-function method 'request-body)
14642 article (gnus-group-real-name group) (nth 1 method))))
14644 (defun gnus-request-post (method)
14645 "Post the current buffer using METHOD."
14646 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14648 (defun gnus-request-scan (group method)
14649 "Request a SCAN being performed in GROUP from METHOD.
14650 If GROUP is nil, all groups on METHOD are scanned."
14651 (let ((method (if group (gnus-find-method-for-group group) method)))
14652 (funcall (gnus-get-function method 'request-scan)
14653 (and group (gnus-group-real-name group)) (nth 1 method))))
14655 (defsubst gnus-request-update-info (info method)
14656 "Request that METHOD update INFO."
14657 (when (gnus-check-backend-function 'request-update-info (car method))
14658 (funcall (gnus-get-function method 'request-update-info)
14659 (gnus-group-real-name (gnus-info-group info))
14660 info (nth 1 method))))
14662 (defun gnus-request-expire-articles (articles group &optional force)
14663 (let ((method (gnus-find-method-for-group group)))
14664 (funcall (gnus-get-function method 'request-expire-articles)
14665 articles (gnus-group-real-name group) (nth 1 method)
14668 (defun gnus-request-move-article
14669 (article group server accept-function &optional last)
14670 (let ((method (gnus-find-method-for-group group)))
14671 (funcall (gnus-get-function method 'request-move-article)
14672 article (gnus-group-real-name group)
14673 (nth 1 method) accept-function last)))
14675 (defun gnus-request-accept-article (group &optional last method)
14676 ;; Make sure there's a newline at the end of the article.
14677 (goto-char (point-max))
14680 (let ((func (if (symbolp group) group
14681 (car (or method (gnus-find-method-for-group group))))))
14682 (funcall (intern (format "%s-request-accept-article" func))
14683 (if (stringp group) (gnus-group-real-name group) group)
14686 (defun gnus-request-replace-article (article group buffer)
14687 (let ((func (car (gnus-find-method-for-group group))))
14688 (funcall (intern (format "%s-request-replace-article" func))
14689 article (gnus-group-real-name group) buffer)))
14691 (defun gnus-request-associate-buffer (group)
14692 (let ((method (gnus-find-method-for-group group)))
14693 (funcall (gnus-get-function method 'request-associate-buffer)
14694 (gnus-group-real-name group))))
14696 (defun gnus-request-restore-buffer (article group)
14697 "Request a new buffer restored to the state of ARTICLE."
14698 (let ((method (gnus-find-method-for-group group)))
14699 (funcall (gnus-get-function method 'request-restore-buffer)
14700 article (gnus-group-real-name group) (nth 1 method))))
14702 (defun gnus-request-create-group (group &optional method)
14703 (let ((method (or method (gnus-find-method-for-group group))))
14704 (funcall (gnus-get-function method 'request-create-group)
14705 (gnus-group-real-name group) (nth 1 method))))
14707 (defun gnus-request-delete-group (group &optional force)
14708 (let ((method (gnus-find-method-for-group group)))
14709 (funcall (gnus-get-function method 'request-delete-group)
14710 (gnus-group-real-name group) force (nth 1 method))))
14712 (defun gnus-request-rename-group (group new-name)
14713 (let ((method (gnus-find-method-for-group group)))
14714 (funcall (gnus-get-function method 'request-rename-group)
14715 (gnus-group-real-name group)
14716 (gnus-group-real-name new-name) (nth 1 method))))
14718 (defun gnus-member-of-valid (symbol group)
14719 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14720 (memq symbol (assoc
14721 (symbol-name (car (gnus-find-method-for-group group)))
14722 gnus-valid-select-methods)))
14724 (defun gnus-method-option-p (method option)
14725 "Return non-nil if select METHOD has OPTION as a parameter."
14726 (memq option (assoc (format "%s" (car method))
14727 gnus-valid-select-methods)))
14729 (defun gnus-server-extend-method (group method)
14730 ;; This function "extends" a virtual server. If the server is
14731 ;; "hello", and the select method is ("hello" (my-var "something"))
14732 ;; in the group "alt.alt", this will result in a new virtual server
14733 ;; called "hello+alt.alt".
14735 (gnus-copy-sequence
14736 (if (equal (car method) "native") gnus-select-method
14737 (cdr (assoc (car method) gnus-server-alist))))))
14738 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14739 (nconc entry (cdr method))))
14741 (defun gnus-find-method-for-group (group &optional info)
14742 "Find the select method that GROUP uses."
14743 (or gnus-override-method
14745 gnus-select-method)
14746 (let ((info (or info (gnus-get-info group)))
14749 (not (setq method (gnus-info-method info))))
14750 (setq method gnus-select-method)
14752 (cond ((stringp method)
14753 (gnus-server-to-method method))
14754 ((stringp (car method))
14755 (gnus-server-extend-method group method))
14758 (gnus-server-add-address method)))))
14760 (defun gnus-check-backend-function (func group)
14761 "Check whether GROUP supports function FUNC."
14762 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14764 (fboundp (intern (format "%s-%s" method func)))))
14766 (defun gnus-methods-using (feature)
14767 "Find all methods that have FEATURE."
14768 (let ((valids gnus-valid-select-methods)
14771 (if (memq feature (car valids))
14772 (setq outs (cons (car valids) outs)))
14773 (setq valids (cdr valids)))
14778 ;;; Active & Newsrc File Handling
14781 (defun gnus-setup-news (&optional rawfile level)
14782 "Setup news information.
14783 If RAWFILE is non-nil, the .newsrc file will also be read.
14784 If LEVEL is non-nil, the news will be set up at level LEVEL."
14785 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14786 ;; Clear some variables to re-initialize news information.
14787 (if init (setq gnus-newsrc-alist nil
14788 gnus-active-hashtb nil))
14790 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14791 (if init (gnus-read-newsrc-file rawfile))
14793 (when (and (not (assoc "archive" gnus-server-alist))
14794 gnus-message-archive-method)
14795 (push (cons "archive" gnus-message-archive-method)
14796 gnus-server-alist))
14798 ;; If we don't read the complete active file, we fill in the
14800 (if (or (null gnus-read-active-file)
14801 (eq gnus-read-active-file 'some))
14802 (gnus-update-active-hashtb-from-killed))
14804 ;; Read the active file and create `gnus-active-hashtb'.
14805 ;; If `gnus-read-active-file' is nil, then we just create an empty
14806 ;; hash table. The partial filling out of the hash table will be
14807 ;; done in `gnus-get-unread-articles'.
14808 (and gnus-read-active-file
14810 (gnus-read-active-file))
14812 (or gnus-active-hashtb
14813 (setq gnus-active-hashtb (make-vector 4095 0)))
14815 ;; Initialize the cache.
14816 (when gnus-use-cache
14819 ;; Possibly eval the dribble file.
14820 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14822 (gnus-update-format-specifications)
14824 ;; Find new newsgroups and treat them.
14825 (if (and init gnus-check-new-newsgroups (not level)
14826 (gnus-check-server gnus-select-method))
14827 (gnus-find-new-newsgroups))
14829 ;; Find the number of unread articles in each non-dead group.
14830 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14831 (gnus-get-unread-articles level))
14833 (if (and init gnus-check-bogus-newsgroups
14834 gnus-read-active-file (not level)
14835 (gnus-server-opened gnus-select-method))
14836 (gnus-check-bogus-newsgroups))))
14838 (defun gnus-find-new-newsgroups (&optional arg)
14839 "Search for new newsgroups and add them.
14840 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14841 The `-n' option line from .newsrc is respected.
14842 If ARG (the prefix), use the `ask-server' method to query
14843 the server for new groups."
14845 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14846 (null gnus-read-active-file)
14847 (eq gnus-read-active-file 'some))
14848 'ask-server gnus-check-new-newsgroups)))
14849 (unless (gnus-check-first-time-used)
14850 (if (or (consp check)
14851 (eq check 'ask-server))
14852 ;; Ask the server for new groups.
14853 (gnus-ask-server-for-new-groups)
14854 ;; Go through the active hashtb and look for new groups.
14856 group new-newsgroups)
14857 (gnus-message 5 "Looking for new newsgroups...")
14858 (unless gnus-have-read-active-file
14859 (gnus-read-active-file))
14860 (setq gnus-newsrc-last-checked-date (current-time-string))
14861 (unless gnus-killed-hashtb
14862 (gnus-make-hashtable-from-killed))
14863 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14864 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14867 (if (or (null (setq group (symbol-name sym)))
14869 (null (symbol-value sym))
14870 (gnus-gethash group gnus-killed-hashtb)
14871 (gnus-gethash group gnus-newsrc-hashtb))
14873 (let ((do-sub (gnus-matches-options-n group)))
14875 ((eq do-sub 'subscribe)
14876 (setq groups (1+ groups))
14877 (gnus-sethash group group gnus-killed-hashtb)
14878 (funcall gnus-subscribe-options-newsgroup-method group))
14879 ((eq do-sub 'ignore)
14882 (setq groups (1+ groups))
14883 (gnus-sethash group group gnus-killed-hashtb)
14884 (if gnus-subscribe-hierarchical-interactive
14885 (setq new-newsgroups (cons group new-newsgroups))
14886 (funcall gnus-subscribe-newsgroup-method group)))))))
14887 gnus-active-hashtb)
14888 (when new-newsgroups
14889 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14890 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14892 (gnus-message 6 "%d new newsgroup%s arrived."
14893 groups (if (> groups 1) "s have" " has"))
14894 (gnus-message 6 "No new newsgroups.")))))))
14896 (defun gnus-matches-options-n (group)
14897 ;; Returns `subscribe' if the group is to be unconditionally
14898 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14899 ;; no match for the group.
14901 ;; First we check the two user variables.
14903 ((and gnus-options-subscribe
14904 (string-match gnus-options-subscribe group))
14906 ((and gnus-auto-subscribed-groups
14907 (string-match gnus-auto-subscribed-groups group))
14909 ((and gnus-options-not-subscribe
14910 (string-match gnus-options-not-subscribe group))
14912 ;; Then we go through the list that was retrieved from the .newsrc
14913 ;; file. This list has elements on the form
14914 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14915 ;; is in the reverse order of the options line) is returned.
14917 (let ((regs gnus-newsrc-options-n))
14919 (not (string-match (car (car regs)) group)))
14920 (setq regs (cdr regs)))
14921 (and regs (cdr (car regs)))))))
14923 (defun gnus-ask-server-for-new-groups ()
14924 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14925 (methods (cons gnus-select-method
14927 (when gnus-message-archive-method
14930 (and (consp gnus-check-new-newsgroups)
14931 gnus-check-new-newsgroups)
14932 gnus-secondary-select-methods))))
14934 (new-date (current-time-string))
14935 group new-newsgroups got-new method hashtb
14936 gnus-override-subscribe-method)
14937 ;; Go through both primary and secondary select methods and
14938 ;; request new newsgroups.
14939 (while (setq method (gnus-server-get-method nil (pop methods)))
14940 (setq new-newsgroups nil)
14941 (setq gnus-override-subscribe-method method)
14942 (when (and (gnus-check-server method)
14943 (gnus-request-newgroups date method))
14946 (setq hashtb (gnus-make-hashtable 100))
14947 (set-buffer nntp-server-buffer)
14948 ;; Enter all the new groups into a hashtable.
14949 (gnus-active-to-gnus-format method hashtb 'ignore)))
14950 ;; Now all new groups from `method' are in `hashtb'.
14952 (lambda (group-sym)
14953 (if (or (null (setq group (symbol-name group-sym)))
14954 (null (symbol-value group-sym))
14955 (gnus-gethash group gnus-newsrc-hashtb)
14956 (member group gnus-zombie-list)
14957 (member group gnus-killed-list))
14958 ;; The group is already known.
14960 ;; Make this group active.
14961 (when (symbol-value group-sym)
14962 (gnus-set-active group (symbol-value group-sym)))
14963 ;; Check whether we want it or not.
14964 (let ((do-sub (gnus-matches-options-n group)))
14966 ((eq do-sub 'subscribe)
14968 (gnus-sethash group group gnus-killed-hashtb)
14969 (funcall gnus-subscribe-options-newsgroup-method group))
14970 ((eq do-sub 'ignore)
14974 (gnus-sethash group group gnus-killed-hashtb)
14975 (if gnus-subscribe-hierarchical-interactive
14976 (push group new-newsgroups)
14977 (funcall gnus-subscribe-newsgroup-method group)))))))
14979 (when new-newsgroups
14980 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
14981 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14983 (gnus-message 6 "%d new newsgroup%s arrived."
14984 groups (if (> groups 1) "s have" " has")))
14985 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14988 (defun gnus-check-first-time-used ()
14989 (if (or (> (length gnus-newsrc-alist) 1)
14990 (file-exists-p gnus-startup-file)
14991 (file-exists-p (concat gnus-startup-file ".el"))
14992 (file-exists-p (concat gnus-startup-file ".eld")))
14994 (gnus-message 6 "First time user; subscribing you to default groups")
14995 (unless gnus-have-read-active-file
14996 (gnus-read-active-file))
14997 (setq gnus-newsrc-last-checked-date (current-time-string))
14998 (let ((groups gnus-default-subscribed-newsgroups)
15002 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15005 (if (null (setq group (symbol-name sym)))
15007 (let ((do-sub (gnus-matches-options-n group)))
15009 ((eq do-sub 'subscribe)
15010 (gnus-sethash group group gnus-killed-hashtb)
15011 (funcall gnus-subscribe-options-newsgroup-method group))
15012 ((eq do-sub 'ignore)
15015 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15016 gnus-active-hashtb)
15018 (if (gnus-active (car groups))
15019 (gnus-group-change-level
15020 (car groups) gnus-level-default-subscribed gnus-level-killed))
15021 (setq groups (cdr groups)))
15022 (gnus-group-make-help-group)
15023 (and gnus-novice-user
15024 (gnus-message 7 "`A k' to list killed groups"))))))
15026 (defun gnus-subscribe-group (group previous &optional method)
15027 (gnus-group-change-level
15029 (list t group gnus-level-default-subscribed nil nil method)
15031 gnus-level-default-subscribed gnus-level-killed previous t))
15033 ;; `gnus-group-change-level' is the fundamental function for changing
15034 ;; subscription levels of newsgroups. This might mean just changing
15035 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15036 ;; again, which subscribes/unsubscribes a group, which is equally
15037 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15038 ;; from 8-9 to 1-7 means that you remove the group from the list of
15039 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15040 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15041 ;; which is trivial.
15042 ;; ENTRY can either be a string (newsgroup name) or a list (if
15043 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15044 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15046 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15047 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15049 (defun gnus-group-change-level (entry level &optional oldlevel
15050 previous fromkilled)
15051 (let (group info active num)
15052 ;; Glean what info we can from the arguments
15054 (if fromkilled (setq group (nth 1 entry))
15055 (setq group (car (nth 2 entry))))
15056 (setq group entry))
15057 (if (and (stringp entry)
15059 (< oldlevel gnus-level-zombie))
15060 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15061 (if (and (not oldlevel)
15063 (setq oldlevel (car (cdr (nth 2 entry)))))
15064 (if (stringp previous)
15065 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15067 (if (and (>= oldlevel gnus-level-zombie)
15068 (gnus-gethash group gnus-newsrc-hashtb))
15069 ;; We are trying to subscribe a group that is already
15073 (or (gnus-ephemeral-group-p group)
15074 (gnus-dribble-enter
15075 (format "(gnus-group-change-level %S %S %S %S %S)"
15076 group level oldlevel (car (nth 2 previous)) fromkilled)))
15078 ;; Then we remove the newgroup from any old structures, if needed.
15079 ;; If the group was killed, we remove it from the killed or zombie
15080 ;; list. If not, and it is in fact going to be killed, we remove
15081 ;; it from the newsrc hash table and assoc.
15083 ((>= oldlevel gnus-level-zombie)
15084 (if (= oldlevel gnus-level-zombie)
15085 (setq gnus-zombie-list (delete group gnus-zombie-list))
15086 (setq gnus-killed-list (delete group gnus-killed-list))))
15088 (if (and (>= level gnus-level-zombie)
15091 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15093 (setcdr (gnus-gethash (car (nth 3 entry))
15094 gnus-newsrc-hashtb)
15096 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
15098 ;; Finally we enter (if needed) the list where it is supposed to
15099 ;; go, and change the subscription level. If it is to be killed,
15100 ;; we enter it into the killed or zombie list.
15102 ((>= level gnus-level-zombie)
15103 ;; Remove from the hash table.
15104 (gnus-sethash group nil gnus-newsrc-hashtb)
15105 ;; We do not enter foreign groups into the list of dead
15107 (unless (gnus-group-foreign-p group)
15108 (if (= level gnus-level-zombie)
15109 (setq gnus-zombie-list (cons group gnus-zombie-list))
15110 (setq gnus-killed-list (cons group gnus-killed-list)))))
15112 ;; If the list is to be entered into the newsrc assoc, and
15113 ;; it was killed, we have to create an entry in the newsrc
15114 ;; hashtb format and fix the pointers in the newsrc assoc.
15115 (if (< oldlevel gnus-level-zombie)
15116 ;; It was alive, and it is going to stay alive, so we
15117 ;; just change the level and don't change any pointers or
15118 ;; hash table entries.
15119 (setcar (cdr (car (cdr (cdr entry)))) level)
15121 (setq info (cdr entry)
15123 (setq active (gnus-active group))
15125 (if active (- (1+ (cdr active)) (car active)) t))
15126 ;; Check whether the group is foreign. If so, the
15127 ;; foreign select method has to be entered into the
15129 (let ((method (or gnus-override-subscribe-method
15130 (gnus-group-method group))))
15131 (if (eq method gnus-select-method)
15132 (setq info (list group level nil))
15133 (setq info (list group level nil nil method)))))
15136 (let ((p gnus-newsrc-alist))
15137 (while (cdr (cdr p))
15140 (setq entry (cons info (cdr (cdr previous))))
15143 (setcdr (cdr previous) entry)
15144 (gnus-sethash group (cons num (cdr previous))
15145 gnus-newsrc-hashtb))
15146 (setcdr previous entry)
15147 (gnus-sethash group (cons num previous)
15148 gnus-newsrc-hashtb))
15150 (setcdr (gnus-gethash (car (car (cdr entry))) gnus-newsrc-hashtb)
15152 (when gnus-group-change-level-function
15153 (funcall gnus-group-change-level-function group level oldlevel)))))
15155 (defun gnus-kill-newsgroup (newsgroup)
15156 "Obsolete function. Kills a newsgroup."
15157 (gnus-group-change-level
15158 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15160 (defun gnus-check-bogus-newsgroups (&optional confirm)
15161 "Remove bogus newsgroups.
15162 If CONFIRM is non-nil, the user has to confirm the deletion of every
15164 (let ((newsrc (cdr gnus-newsrc-alist))
15165 bogus group entry info)
15166 (gnus-message 5 "Checking bogus newsgroups...")
15167 (unless gnus-have-read-active-file
15168 (gnus-read-active-file))
15169 (when (member gnus-select-method gnus-have-read-active-file)
15170 ;; Find all bogus newsgroup that are subscribed.
15172 (setq info (pop newsrc)
15173 group (gnus-info-group info))
15174 (unless (or (gnus-active group) ; Active
15175 (gnus-info-method info) ; Foreign
15177 (not (gnus-y-or-n-p
15178 (format "Remove bogus newsgroup: %s " group)))))
15179 ;; Found a bogus newsgroup.
15180 (push group bogus)))
15181 ;; Remove all bogus subscribed groups by first killing them, and
15182 ;; then removing them from the list of killed groups.
15184 (when (setq entry (gnus-gethash (setq group (pop bogus))
15185 gnus-newsrc-hashtb))
15186 (gnus-group-change-level entry gnus-level-killed)
15187 (setq gnus-killed-list (delete group gnus-killed-list))))
15188 ;; Then we remove all bogus groups from the list of killed and
15189 ;; zombie groups. They are are removed without confirmation.
15190 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15193 (setq killed (symbol-value (car dead-lists)))
15195 (unless (gnus-active (setq group (pop killed)))
15196 ;; The group is bogus.
15197 ;; !!!Slow as hell.
15198 (set (car dead-lists)
15199 (delete group (symbol-value (car dead-lists))))))
15200 (setq dead-lists (cdr dead-lists))))
15201 (gnus-message 5 "Checking bogus newsgroups...done"))))
15203 (defun gnus-check-duplicate-killed-groups ()
15204 "Remove duplicates from the list of killed groups."
15206 (let ((killed gnus-killed-list))
15208 (gnus-message 9 "%d" (length killed))
15209 (setcdr killed (delete (car killed) (cdr killed)))
15210 (setq killed (cdr killed)))))
15212 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15213 ;; and compute how many unread articles there are in each group.
15214 (defun gnus-get-unread-articles (&optional level)
15215 (let* ((newsrc (cdr gnus-newsrc-alist))
15216 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15219 (cond ((and gnus-activate-foreign-newsgroups
15220 (not (numberp gnus-activate-foreign-newsgroups)))
15221 (1+ gnus-level-subscribed))
15222 ((numberp gnus-activate-foreign-newsgroups)
15223 gnus-activate-foreign-newsgroups)
15226 info group active virtuals method)
15227 (gnus-message 5 "Checking new news...")
15230 (setq info (car newsrc)
15231 group (gnus-info-group info)
15232 active (gnus-active group))
15234 ;; Check newsgroups. If the user doesn't want to check them, or
15235 ;; they can't be checked (for instance, if the news server can't
15236 ;; be reached) we just set the number of unread articles in this
15237 ;; newsgroup to t. This means that Gnus thinks that there are
15238 ;; unread articles, but it has no idea how many.
15239 (if (and (setq method (gnus-info-method info))
15240 (not (gnus-server-equal
15242 (gnus-server-get-method nil method)))
15243 (not (gnus-secondary-method-p method)))
15244 ;; These groups are foreign. Check the level.
15245 (when (<= (gnus-info-level info) foreign-level)
15246 (setq active (gnus-activate-group group 'scan))
15247 (gnus-close-group group))
15249 ;; These groups are native or secondary.
15250 (when (and (<= (gnus-info-level info) level)
15251 (not gnus-read-active-file))
15252 (setq active (gnus-activate-group group 'scan))
15253 (gnus-close-group group)))
15256 (gnus-get-unread-articles-in-group info active t)
15257 ;; The group couldn't be reached, so we nix out the number of
15258 ;; unread articles and stuff.
15259 (gnus-set-active group nil)
15260 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
15262 (setq newsrc (cdr newsrc)))
15264 (gnus-message 5 "Checking new news...done")))
15266 ;; Create a hash table out of the newsrc alist. The `car's of the
15267 ;; alist elements are used as keys.
15268 (defun gnus-make-hashtable-from-newsrc-alist ()
15269 (let ((alist gnus-newsrc-alist)
15270 (ohashtb gnus-newsrc-hashtb)
15272 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15274 (setq prev (setq gnus-newsrc-alist
15275 (if (equal (car (car gnus-newsrc-alist))
15278 (cons (list "dummy.group" 0 nil) alist)))))
15282 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
15284 gnus-newsrc-hashtb)
15286 alist (cdr alist)))))
15288 (defun gnus-make-hashtable-from-killed ()
15289 "Create a hash table from the killed and zombie lists."
15290 (let ((lists '(gnus-killed-list gnus-zombie-list))
15292 (setq gnus-killed-hashtb
15293 (gnus-make-hashtable
15294 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15296 (setq list (symbol-value (car lists)))
15297 (setq lists (cdr lists))
15299 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15300 (setq list (cdr list))))))
15302 (defun gnus-get-unread-articles-in-group (info active &optional update)
15304 ;; Allow the backend to update the info in the group.
15306 (gnus-request-update-info
15307 info (gnus-find-method-for-group (gnus-info-group info))))
15308 (let* ((range (gnus-info-read info))
15310 (marked (gnus-info-marks info)))
15311 ;; If a cache is present, we may have to alter the active info.
15312 (and gnus-use-cache
15313 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15314 ;; Modify the list of read articles according to what articles
15315 ;; are available; then tally the unread articles and add the
15316 ;; number to the group hash table entry.
15318 ((zerop (cdr active))
15321 (setq num (- (1+ (cdr active)) (car active))))
15322 ((not (listp (cdr range)))
15323 ;; Fix a single (num . num) range according to the
15324 ;; active hash table.
15325 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15326 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15327 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15328 ;; Compute number of unread articles.
15329 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15331 ;; The read list is a list of ranges. Fix them according to
15332 ;; the active hash table.
15333 ;; First peel off any elements that are below the lower
15335 (while (and (cdr range)
15337 (or (and (atom (car (cdr range))) (car (cdr range)))
15338 (car (car (cdr range))))))
15339 (if (numberp (car range))
15342 (or (and (numberp (car (cdr range)))
15344 (cdr (car (cdr range))))))
15345 (setcdr (car range)
15346 (or (and (numberp (nth 1 range)) (nth 1 range))
15347 (cdr (car (cdr range))))))
15348 (setcdr range (cdr (cdr range))))
15349 ;; Adjust the first element to be the same as the lower limit.
15350 (if (and (not (atom (car range)))
15351 (< (cdr (car range)) (car active)))
15352 (setcdr (car range) (1- (car active))))
15353 ;; Then we want to peel off any elements that are higher
15354 ;; than the upper active limit.
15355 (let ((srange range))
15356 ;; Go past all legal elements.
15357 (while (and (cdr srange)
15358 (<= (or (and (atom (car (cdr srange)))
15359 (car (cdr srange)))
15360 (car (car (cdr srange)))) (cdr active)))
15361 (setq srange (cdr srange)))
15363 ;; Nuke all remaining illegal elements.
15364 (setcdr srange nil))
15366 ;; Adjust the final element.
15367 (if (and (not (atom (car srange)))
15368 (> (cdr (car srange)) (cdr active)))
15369 (setcdr (car srange) (cdr active))))
15370 ;; Compute the number of unread articles.
15372 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15373 (cdr (car range))))
15374 (or (and (atom (car range)) (car range))
15375 (car (car range))))))
15376 (setq range (cdr range)))
15377 (setq num (max 0 (- (cdr active) num)))))
15378 ;; Set the number of unread articles.
15379 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
15382 (defun gnus-activate-group (group &optional scan)
15383 ;; Check whether a group has been activated or not.
15384 ;; If SCAN, request a scan of that group as well.
15385 (let ((method (gnus-find-method-for-group group))
15387 (and (gnus-check-server method)
15388 ;; We escape all bugs and quit here to make it possible to
15389 ;; continue if a group is so out-there that it reports bugs
15393 (gnus-check-backend-function 'request-scan (car method))
15394 (gnus-request-scan group method))
15397 (gnus-request-group group)
15401 (set-buffer nntp-server-buffer)
15402 (goto-char (point-min))
15403 ;; Parse the result we got from `gnus-request-group'.
15404 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15406 (goto-char (match-beginning 1))
15408 group (setq active (cons (read (current-buffer))
15409 (read (current-buffer)))))
15410 ;; Return the new active info.
15413 (defun gnus-update-read-articles (group unread)
15414 "Update the list of read and ticked articles in GROUP using the
15415 UNREAD and TICKED lists.
15416 Note: UNSELECTED has to be sorted over `<'.
15417 Returns whether the updating was successful."
15418 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15419 (entry (gnus-gethash group gnus-newsrc-hashtb))
15420 (info (nth 2 entry))
15421 (marked (gnus-info-marks info))
15423 (unread (sort (copy-sequence unread) '<))
15425 (if (or (not info) (not active))
15426 ;; There is no info on this group if it was, in fact,
15427 ;; killed. Gnus stores no information on killed groups, so
15428 ;; there's nothing to be done.
15429 ;; One could store the information somewhere temporarily,
15430 ;; perhaps... Hmmm...
15432 ;; Remove any negative articles numbers.
15433 (while (and unread (< (car unread) 0))
15434 (setq unread (cdr unread)))
15435 ;; Remove any expired article numbers
15436 (while (and unread (< (car unread) (car active)))
15437 (setq unread (cdr unread)))
15438 ;; Compute the ranges of read articles by looking at the list of
15439 ;; unread articles.
15441 (if (/= (car unread) prev)
15442 (setq read (cons (if (= prev (1- (car unread))) prev
15443 (cons prev (1- (car unread)))) read)))
15444 (setq prev (1+ (car unread)))
15445 (setq unread (cdr unread)))
15446 (when (<= prev (cdr active))
15447 (setq read (cons (cons prev (cdr active)) read)))
15448 ;; Enter this list into the group info.
15449 (gnus-info-set-read
15450 info (if (> (length read) 1) (nreverse read) read))
15451 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15452 (gnus-get-unread-articles-in-group info (gnus-active group))
15455 (defun gnus-make-articles-unread (group articles)
15456 "Mark ARTICLES in GROUP as unread."
15457 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15458 (gnus-gethash (gnus-group-real-name group)
15459 gnus-newsrc-hashtb))))
15460 (ranges (gnus-info-read info))
15463 (when (gnus-member-of-range
15464 (setq article (pop articles)) ranges)
15465 (setq news (cons article news))))
15467 (gnus-info-set-read
15468 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15469 (gnus-group-update-group group t))))
15471 ;; Enter all dead groups into the hashtb.
15472 (defun gnus-update-active-hashtb-from-killed ()
15473 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15474 (lists (list gnus-killed-list gnus-zombie-list))
15477 (setq killed (car lists))
15479 (gnus-sethash (car killed) nil hashtb)
15480 (setq killed (cdr killed)))
15481 (setq lists (cdr lists)))))
15483 ;; Get the active file(s) from the backend(s).
15484 (defun gnus-read-active-file ()
15485 (gnus-group-set-mode-line)
15488 (if (gnus-check-server gnus-select-method)
15489 ;; The native server is available.
15490 (cons gnus-select-method gnus-secondary-select-methods)
15491 ;; The native server is down, so we just do the
15493 gnus-secondary-select-methods)
15494 ;; Also read from the archive server.
15495 (when gnus-message-archive-method
15496 (list "archive"))))
15498 (setq gnus-have-read-active-file nil)
15500 (set-buffer nntp-server-buffer)
15502 (let* ((method (if (stringp (car methods))
15503 (gnus-server-get-method nil (car methods))
15505 (where (nth 1 method))
15506 (mesg (format "Reading active file%s via %s..."
15507 (if (and where (not (zerop (length where))))
15508 (concat " from " where) "")
15510 (gnus-message 5 mesg)
15511 (if (not (gnus-check-server method))
15513 ;; Request that the backend scan its incoming messages.
15514 (and (gnus-check-backend-function 'request-scan (car method))
15515 (gnus-request-scan nil method))
15517 ((and (eq gnus-read-active-file 'some)
15518 (gnus-check-backend-function 'retrieve-groups (car method)))
15519 (let ((newsrc (cdr gnus-newsrc-alist))
15520 (gmethod (gnus-server-get-method nil method))
15523 (and (gnus-server-equal
15524 (gnus-find-method-for-group
15525 (car (car newsrc)) (car newsrc))
15527 (setq groups (cons (gnus-group-real-name
15528 (car (car newsrc))) groups)))
15529 (setq newsrc (cdr newsrc)))
15530 (gnus-check-server method)
15531 (setq list-type (gnus-retrieve-groups groups method))
15535 1 "Cannot read partial active file from %s server."
15539 ((eq list-type 'active)
15540 (gnus-active-to-gnus-format method gnus-active-hashtb))
15542 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
15544 (if (not (gnus-request-list method))
15546 (unless (equal method gnus-message-archive-method)
15547 (gnus-message 1 "Cannot read active file from %s server."
15550 (gnus-active-to-gnus-format method)
15551 ;; We mark this active file as read.
15552 (push method gnus-have-read-active-file)
15553 (gnus-message 5 "%sdone" mesg))))))
15554 (setq methods (cdr methods))))))
15556 ;; Read an active file and place the results in `gnus-active-hashtb'.
15557 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15559 (setq method gnus-select-method))
15560 (let ((cur (current-buffer))
15562 (if (and gnus-active-hashtb
15563 (not (equal method gnus-select-method)))
15565 (setq gnus-active-hashtb
15566 (if (equal method gnus-select-method)
15567 (gnus-make-hashtable
15568 (count-lines (point-min) (point-max)))
15569 (gnus-make-hashtable 4096))))))
15570 (flag-hashtb (gnus-make-hashtable 60)))
15571 ;; Delete unnecessary lines.
15572 (goto-char (point-min))
15573 (while (search-forward "\nto." nil t)
15574 (delete-region (1+ (match-beginning 0))
15575 (progn (forward-line 1) (point))))
15576 (or (string= gnus-ignored-newsgroups "")
15578 (goto-char (point-min))
15579 (delete-matching-lines gnus-ignored-newsgroups)))
15580 ;; Make the group names readable as a lisp expression even if they
15581 ;; contain special characters.
15582 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15583 (goto-char (point-max))
15584 (while (re-search-backward "[][';?()#]" nil t)
15586 ;; If these are groups from a foreign select method, we insert the
15587 ;; group prefix in front of the group names.
15588 (and method (not (gnus-server-equal
15589 (gnus-server-get-method nil method)
15590 (gnus-server-get-method nil gnus-select-method)))
15591 (let ((prefix (gnus-group-prefixed-name "" method)))
15592 (goto-char (point-min))
15593 (while (and (not (eobp))
15594 (progn (insert prefix)
15595 (zerop (forward-line 1)))))))
15596 ;; Store the active file in a hash table.
15597 (goto-char (point-min))
15598 (if (string-match "%[oO]" gnus-group-line-format)
15599 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15600 ;; If we want information on moderated groups, we use this
15602 (let* ((mod-hashtb (make-vector 7 0))
15603 (m (intern "m" mod-hashtb))
15605 (while (not (eobp))
15606 (condition-case nil
15608 (narrow-to-region (point) (gnus-point-at-eol))
15609 (setq group (let ((obarray hashtb)) (read cur)))
15610 (if (and (numberp (setq max (read cur)))
15611 (numberp (setq min (read cur)))
15613 (skip-chars-forward " \t")
15615 (or (= (following-char) ?=)
15616 (= (following-char) ?x)
15617 (= (following-char) ?j)))))
15618 (set group (cons min max))
15620 ;; Enter moderated groups into a list.
15621 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15622 (setq gnus-moderated-list
15623 (cons (symbol-name group) gnus-moderated-list))))
15630 ;; And if we do not care about moderation, we use this loop,
15631 ;; which is faster.
15632 (let (group max min)
15633 (while (not (eobp))
15636 (narrow-to-region (point) (gnus-point-at-eol))
15637 ;; group gets set to a symbol interned in the hash table
15638 ;; (what a hack!!) - jwz
15639 (setq group (let ((obarray hashtb)) (read cur)))
15640 (if (and (numberp (setq max (read cur)))
15641 (numberp (setq min (read cur)))
15643 (skip-chars-forward " \t")
15645 (or (= (following-char) ?=)
15646 (= (following-char) ?x)
15647 (= (following-char) ?j)))))
15648 (set group (cons min max))
15656 (gnus-message 3 "Warning - illegal active: %s"
15658 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15660 (forward-line 1))))))
15662 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15663 ;; Parse a "groups" active file.
15664 (let ((cur (current-buffer))
15666 (if (and method gnus-active-hashtb)
15668 (setq gnus-active-hashtb
15669 (gnus-make-hashtable
15670 (count-lines (point-min) (point-max)))))))
15671 (prefix (and method
15672 (not (gnus-server-equal
15673 (gnus-server-get-method nil method)
15674 (gnus-server-get-method nil gnus-select-method)))
15675 (gnus-group-prefixed-name "" method))))
15677 (goto-char (point-min))
15678 ;; We split this into to separate loops, one with the prefix
15679 ;; and one without to speed the reading up somewhat.
15681 (let (min max opoint group)
15682 (while (not (eobp))
15685 (read cur) (read cur)
15686 (setq min (read cur)
15689 (skip-chars-forward " \t")
15692 (set (let ((obarray hashtb)) (read cur))
15694 (error (and group (symbolp group) (set group nil))))
15696 (let (min max group)
15697 (while (not (eobp))
15699 (if (= (following-char) ?2)
15701 (read cur) (read cur)
15702 (setq min (read cur)
15704 (set (setq group (let ((obarray hashtb)) (read cur)))
15706 (error (and group (symbolp group) (set group nil))))
15707 (forward-line 1))))))
15709 (defun gnus-read-newsrc-file (&optional force)
15710 "Read startup file.
15711 If FORCE is non-nil, the .newsrc file is read."
15712 ;; Reset variables that might be defined in the .newsrc.eld file.
15713 (let ((variables gnus-variable-list))
15715 (set (car variables) nil)
15716 (setq variables (cdr variables))))
15717 (let* ((newsrc-file gnus-current-startup-file)
15718 (quick-file (concat newsrc-file ".el")))
15720 ;; We always load the .newsrc.eld file. If always contains
15721 ;; much information that can not be gotten from the .newsrc
15722 ;; file (ticked articles, killed groups, foreign methods, etc.)
15723 (gnus-read-newsrc-el-file quick-file)
15726 (and (file-newer-than-file-p newsrc-file quick-file)
15727 (file-newer-than-file-p newsrc-file
15728 (concat quick-file "d")))
15729 (not gnus-newsrc-alist))
15730 ;; We read the .newsrc file. Note that if there if a
15731 ;; .newsrc.eld file exists, it has already been read, and
15732 ;; the `gnus-newsrc-hashtb' has been created. While reading
15733 ;; the .newsrc file, Gnus will only use the information it
15734 ;; can find there for changing the data already read -
15735 ;; ie. reading the .newsrc file will not trash the data
15736 ;; already read (except for read articles).
15738 (gnus-message 5 "Reading %s..." newsrc-file)
15739 (set-buffer (find-file-noselect newsrc-file))
15740 (buffer-disable-undo (current-buffer))
15741 (gnus-newsrc-to-gnus-format)
15742 (kill-buffer (current-buffer))
15743 (gnus-message 5 "Reading %s...done" newsrc-file)))
15745 ;; Read any slave files.
15747 (gnus-master-read-slave-newsrc)))))
15749 (defun gnus-read-newsrc-el-file (file)
15750 (let ((ding-file (concat file "d")))
15751 ;; We always, always read the .eld file.
15752 (gnus-message 5 "Reading %s..." ding-file)
15753 (let (gnus-newsrc-assoc)
15754 (condition-case nil
15755 (load ding-file t t t)
15757 (gnus-message 1 "Error in %s" ding-file)
15759 (when gnus-newsrc-assoc
15760 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15761 (gnus-make-hashtable-from-newsrc-alist)
15762 (when (file-newer-than-file-p file ding-file)
15763 ;; Old format quick file
15764 (gnus-message 5 "Reading %s..." file)
15765 ;; The .el file is newer than the .eld file, so we read that one
15767 (gnus-read-old-newsrc-el-file file))))
15769 ;; Parse the old-style quick startup file
15770 (defun gnus-read-old-newsrc-el-file (file)
15771 (let (newsrc killed marked group m)
15773 (let ((gnus-killed-assoc nil)
15774 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15776 (condition-case nil
15779 (setq newsrc gnus-newsrc-assoc
15780 killed gnus-killed-assoc
15781 marked gnus-marked-assoc)))
15782 (setq gnus-newsrc-alist nil)
15784 (setq group (car newsrc))
15785 (let ((info (gnus-get-info (car group))))
15788 (gnus-info-set-read info (cdr (cdr group)))
15789 (gnus-info-set-level
15790 info (if (nth 1 group) gnus-level-default-subscribed
15791 gnus-level-default-unsubscribed))
15792 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15793 (setq gnus-newsrc-alist
15797 (if (nth 1 group) gnus-level-default-subscribed
15798 gnus-level-default-unsubscribed)
15799 (cdr (cdr group))))
15800 gnus-newsrc-alist)))
15801 (if (setq m (assoc (car group) marked))
15802 (gnus-info-set-marks
15803 info (cons (list (cons 'tick (gnus-compress-sequence
15804 (sort (cdr m) '<) t)))
15806 (setq newsrc (cdr newsrc)))
15807 (setq newsrc killed)
15809 (setcar newsrc (car (car newsrc)))
15810 (setq newsrc (cdr newsrc)))
15811 (setq gnus-killed-list killed))
15812 ;; The .el file version of this variable does not begin with
15813 ;; "options", while the .eld version does, so we just add it if it
15816 gnus-newsrc-options
15818 (and (not (string-match "^ *options" gnus-newsrc-options))
15819 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15820 (and (not (string-match "\n$" gnus-newsrc-options))
15821 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15822 ;; Finally, if we read some options lines, we parse them.
15823 (or (string= gnus-newsrc-options "")
15824 (gnus-newsrc-parse-options gnus-newsrc-options))))
15826 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15827 (gnus-make-hashtable-from-newsrc-alist)))
15829 (defun gnus-make-newsrc-file (file)
15830 "Make server dependent file name by catenating FILE and server host name."
15831 (let* ((file (expand-file-name file nil))
15832 (real-file (concat file "-" (nth 1 gnus-select-method))))
15833 (if (or (file-exists-p real-file)
15834 (file-exists-p (concat real-file ".el"))
15835 (file-exists-p (concat real-file ".eld")))
15838 (defun gnus-newsrc-to-gnus-format ()
15839 (setq gnus-newsrc-options "")
15840 (setq gnus-newsrc-options-n nil)
15842 (or gnus-active-hashtb
15843 (setq gnus-active-hashtb (make-vector 4095 0)))
15844 (let ((buf (current-buffer))
15845 (already-read (> (length gnus-newsrc-alist) 1))
15846 group subscribed options-symbol newsrc Options-symbol
15848 (goto-char (point-min))
15849 ;; We intern the symbol `options' in the active hashtb so that we
15850 ;; can `eq' against it later.
15851 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15852 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15854 (while (not (eobp))
15855 ;; We first read the first word on the line by narrowing and
15856 ;; then reading into `gnus-active-hashtb'. Most groups will
15857 ;; already exist in that hashtb, so this will save some string
15861 (progn (skip-chars-forward "^ \t!:\n") (point)))
15862 (goto-char (point-min))
15864 (and (/= (point-min) (point-max))
15865 (let ((obarray gnus-active-hashtb)) (read buf))))
15867 ;; Now, the symbol we have read is either `options' or a group
15868 ;; name. If it is an options line, we just add it to a string.
15870 ((or (eq symbol options-symbol)
15871 (eq symbol Options-symbol))
15872 (setq gnus-newsrc-options
15873 ;; This concating is quite inefficient, but since our
15874 ;; thorough studies show that approx 99.37% of all
15875 ;; .newsrc files only contain a single options line, we
15876 ;; don't give a damn, frankly, my dear.
15877 (concat gnus-newsrc-options
15879 (gnus-point-at-bol)
15880 ;; Options may continue on the next line.
15881 (or (and (re-search-forward "^[^ \t]" nil 'move)
15882 (progn (beginning-of-line) (point)))
15886 ;; Group names can be just numbers.
15887 (when (numberp symbol)
15888 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15889 (or (boundp symbol) (set symbol nil))
15890 ;; It was a group name.
15891 (setq subscribed (= (following-char) ?:)
15892 group (symbol-name symbol)
15895 ;; If the line ends here, this is clearly a buggy line, so
15896 ;; we put point a the beginning of line and let the cond
15897 ;; below do the error handling.
15898 (beginning-of-line)
15899 ;; We skip to the beginning of the ranges.
15900 (skip-chars-forward "!: \t"))
15901 ;; We are now at the beginning of the list of read articles.
15902 ;; We read them range by range.
15905 ((looking-at "[0-9]+")
15906 ;; We narrow and read a number instead of buffer-substring/
15907 ;; string-to-int because it's faster. narrow/widen is
15908 ;; faster than save-restriction/narrow, and save-restriction
15909 ;; produces a garbage object.
15911 (narrow-to-region (match-beginning 0) (match-end 0))
15914 ;; If the next character is a dash, then this is a range.
15915 (if (= (following-char) ?-)
15917 ;; We read the upper bound of the range.
15919 (if (not (looking-at "[0-9]+"))
15920 ;; This is a buggy line, by we pretend that
15921 ;; it's kinda OK. Perhaps the user should be
15923 (setq reads (cons num1 reads))
15928 (narrow-to-region (match-beginning 0)
15933 ;; It was just a simple number, so we add it to the
15935 (setq reads (cons num1 reads)))
15936 ;; If the next char in ?\n, then we have reached the end
15937 ;; of the line and return nil.
15938 (/= (following-char) ?\n))
15939 ((= (following-char) ?\n)
15940 ;; End of line, so we end.
15943 ;; Not numbers and not eol, so this might be a buggy
15946 ;; If it was eob instead of ?\n, we allow it.
15948 ;; The line was buggy.
15950 (gnus-message 3 "Mangled line: %s"
15951 (buffer-substring (gnus-point-at-bol)
15952 (gnus-point-at-eol)))
15956 ;; Skip past ", ". Spaces are illegal in these ranges, but
15957 ;; we allow them, because it's a common mistake to put a
15958 ;; space after the comma.
15959 (skip-chars-forward ", "))
15961 ;; We have already read .newsrc.eld, so we gently update the
15962 ;; data in the hash table with the information we have just
15965 (let ((info (gnus-get-info group))
15968 ;; There is an entry for this file in the alist.
15970 (gnus-info-set-read info (nreverse reads))
15971 ;; We update the level very gently. In fact, we
15972 ;; only change it if there's been a status change
15973 ;; from subscribed to unsubscribed, or vice versa.
15974 (setq level (gnus-info-level info))
15975 (cond ((and (<= level gnus-level-subscribed)
15977 (setq level (if reads
15978 gnus-level-default-unsubscribed
15979 (1+ gnus-level-default-unsubscribed))))
15980 ((and (> level gnus-level-subscribed) subscribed)
15981 (setq level gnus-level-default-subscribed)))
15982 (gnus-info-set-level info level))
15983 ;; This is a new group.
15984 (setq info (list group
15986 gnus-level-default-subscribed
15988 (1+ gnus-level-subscribed)
15989 gnus-level-default-unsubscribed))
15990 (nreverse reads))))
15991 (setq newsrc (cons info newsrc))))))
15994 (setq newsrc (nreverse newsrc))
15996 (if (not already-read)
15998 ;; We now have two newsrc lists - `newsrc', which is what we
15999 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16000 ;; what we've read from .newsrc.eld. We have to merge these
16001 ;; lists. We do this by "attaching" any (foreign) groups in the
16002 ;; gnus-newsrc-alist to the (native) group that precedes them.
16003 (let ((rc (cdr gnus-newsrc-alist))
16004 (prev gnus-newsrc-alist)
16007 (or (null (nth 4 (car rc))) ; It's a native group.
16008 (assoc (car (car rc)) newsrc) ; It's already in the alist.
16009 (if (setq entry (assoc (car (car prev)) newsrc))
16010 (setcdr (setq mentry (memq entry newsrc))
16011 (cons (car rc) (cdr mentry)))
16012 (setq newsrc (cons (car rc) newsrc))))
16016 (setq gnus-newsrc-alist newsrc)
16017 ;; We make the newsrc hashtb.
16018 (gnus-make-hashtable-from-newsrc-alist)
16020 ;; Finally, if we read some options lines, we parse them.
16021 (or (string= gnus-newsrc-options "")
16022 (gnus-newsrc-parse-options gnus-newsrc-options))))
16024 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16025 ;; The return value will be a list on the form
16026 ;; ((regexp1 . ignore)
16027 ;; (regexp2 . subscribe)...)
16028 ;; When handling new newsgroups, groups that match a `ignore' regexp
16029 ;; will be ignored, and groups that match a `subscribe' regexp will be
16030 ;; subscribed. A line like
16031 ;; options -n !all rec.all
16032 ;; will lead to a list that looks like
16033 ;; (("^rec\\..+" . subscribe)
16034 ;; ("^.+" . ignore))
16035 ;; So all "rec.*" groups will be subscribed, while all the other
16036 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16037 ;; different from "options -n rec.all !all".
16038 (defun gnus-newsrc-parse-options (options)
16041 (gnus-set-work-buffer)
16042 (insert (regexp-quote options))
16043 ;; First we treat all continuation lines.
16044 (goto-char (point-min))
16045 (while (re-search-forward "\n[ \t]+" nil t)
16046 (replace-match " " t t))
16047 ;; Then we transform all "all"s into ".+"s.
16048 (goto-char (point-min))
16049 (while (re-search-forward "\\ball\\b" nil t)
16050 (replace-match ".+" t t))
16051 (goto-char (point-min))
16052 ;; We remove all other options than the "-n" ones.
16053 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16054 (replace-match " ")
16056 (goto-char (point-min))
16058 ;; We are only interested in "options -n" lines - we
16059 ;; ignore the other option lines.
16060 (while (re-search-forward "[ \t]-n" nil t)
16062 (or (save-excursion
16063 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16065 (gnus-point-at-eol)))
16066 ;; Search for all "words"...
16067 (while (re-search-forward "[^ \t,\n]+" eol t)
16068 (if (= (char-after (match-beginning 0)) ?!)
16069 ;; If the word begins with a bang (!), this is a "not"
16070 ;; spec. We put this spec (minus the bang) and the
16071 ;; symbol `ignore' into the list.
16072 (setq out (cons (cons (concat
16073 "^" (buffer-substring
16074 (1+ (match-beginning 0))
16077 ;; There was no bang, so this is a "yes" spec.
16078 (setq out (cons (cons (concat "^" (match-string 0))
16079 'subscribe) out)))))
16081 (setq gnus-newsrc-options-n out))))
16083 (defun gnus-save-newsrc-file (&optional force)
16084 "Save .newsrc file."
16085 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16086 ;; from the variable gnus-newsrc-alist.
16087 (when (and (or gnus-newsrc-alist gnus-killed-list)
16088 gnus-current-startup-file)
16090 (if (and (or gnus-use-dribble-file gnus-slave)
16092 (or (not gnus-dribble-buffer)
16093 (not (buffer-name gnus-dribble-buffer))
16094 (zerop (save-excursion
16095 (set-buffer gnus-dribble-buffer)
16097 (gnus-message 4 "(No changes need to be saved)")
16098 (run-hooks 'gnus-save-newsrc-hook)
16100 (gnus-slave-save-newsrc)
16102 (when gnus-save-newsrc-file
16103 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16104 (gnus-gnus-to-newsrc-format)
16105 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16106 ;; Save .newsrc.eld.
16107 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16108 (make-local-variable 'version-control)
16109 (setq version-control 'never)
16110 (setq buffer-file-name
16111 (concat gnus-current-startup-file ".eld"))
16112 (gnus-add-current-to-buffer-list)
16113 (buffer-disable-undo (current-buffer))
16115 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16116 (gnus-gnus-to-quick-newsrc-format)
16117 (run-hooks 'gnus-save-quick-newsrc-hook)
16119 (kill-buffer (current-buffer))
16121 5 "Saving %s.eld...done" gnus-current-startup-file))
16122 (gnus-dribble-delete-file)))))
16124 (defun gnus-gnus-to-quick-newsrc-format ()
16125 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16126 (insert ";; Gnus startup file.\n")
16127 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16128 (insert ";; to read .newsrc.\n")
16129 (insert "(setq gnus-newsrc-file-version "
16130 (prin1-to-string gnus-version) ")\n")
16132 (if gnus-save-killed-list gnus-variable-list
16133 ;; Remove the `gnus-killed-list' from the list of variables
16134 ;; to be saved, if required.
16135 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16136 ;; Peel off the "dummy" group.
16137 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16139 ;; Insert the variables into the file.
16141 (when (and (boundp (setq variable (pop variables)))
16142 (symbol-value variable))
16143 (insert "(setq " (symbol-name variable) " '"
16144 (prin1-to-string (symbol-value variable)) ")\n")))))
16146 (defun gnus-gnus-to-newsrc-format ()
16147 ;; Generate and save the .newsrc file.
16148 (let ((newsrc (cdr gnus-newsrc-alist))
16151 (set-buffer (create-file-buffer gnus-current-startup-file))
16152 (setq buffer-file-name gnus-current-startup-file)
16153 (buffer-disable-undo (current-buffer))
16156 (if gnus-newsrc-options (insert gnus-newsrc-options))
16157 ;; Write subscribed and unsubscribed.
16159 (setq info (car newsrc))
16160 (if (not (gnus-info-method info))
16161 ;; Don't write foreign groups to .newsrc.
16163 (insert (gnus-info-group info)
16164 (if (> (gnus-info-level info) gnus-level-subscribed)
16166 (if (setq ranges (gnus-info-read info))
16169 (if (not (listp (cdr ranges)))
16170 (if (= (car ranges) (cdr ranges))
16171 (insert (int-to-string (car ranges)))
16172 (insert (int-to-string (car ranges)) "-"
16173 (int-to-string (cdr ranges))))
16175 (setq range (car ranges)
16176 ranges (cdr ranges))
16177 (if (or (atom range) (= (car range) (cdr range)))
16178 (insert (int-to-string
16179 (or (and (atom range) range)
16181 (insert (int-to-string (car range)) "-"
16182 (int-to-string (cdr range))))
16183 (if ranges (insert ","))))))
16185 (setq newsrc (cdr newsrc)))
16186 (make-local-variable 'version-control)
16187 (setq version-control 'never)
16188 ;; It has been reported that sometime the modtime on the .newsrc
16189 ;; file seems to be off. We really do want to overwrite it, so
16190 ;; we clear the modtime here before saving. It's a bit odd,
16192 ;; sometimes the modtime clear isn't sufficient. most brute force:
16193 ;; delete the silly thing entirely first. but this fails to provide
16194 ;; such niceties as .newsrc~ creation.
16195 (if gnus-modtime-botch
16196 (delete-file gnus-startup-file)
16197 (clear-visited-file-modtime))
16198 (run-hooks 'gnus-save-standard-newsrc-hook)
16200 (kill-buffer (current-buffer)))))
16204 ;;; Slave functions.
16207 (defun gnus-slave-save-newsrc ()
16209 (set-buffer gnus-dribble-buffer)
16211 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16212 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16214 (defun gnus-master-read-slave-newsrc ()
16217 (file-name-directory gnus-current-startup-file)
16221 (file-name-nondirectory gnus-current-startup-file)
16225 (if (not slave-files)
16226 () ; There are no slave files to read.
16227 (gnus-message 7 "Reading slave newsrcs...")
16229 (set-buffer (get-buffer-create " *gnus slave*"))
16230 (buffer-disable-undo (current-buffer))
16232 (sort (mapcar (lambda (file)
16233 (list (nth 5 (file-attributes file)) file))
16236 (or (< (car (car f1)) (car (car f2)))
16237 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16240 (setq file (nth 1 (car slave-files)))
16241 (insert-file-contents file)
16242 (if (condition-case ()
16244 (eval-buffer (current-buffer))
16247 (gnus-message 3 "Possible error in %s" file)
16251 (or gnus-slave ; Slaves shouldn't delete these files.
16255 (setq slave-files (cdr slave-files))))
16256 (gnus-message 7 "Reading slave newsrcs...done"))))
16260 ;;; Group description.
16263 (defun gnus-read-all-descriptions-files ()
16264 (let ((methods (cons gnus-select-method
16266 (when gnus-message-archive-method
16268 gnus-secondary-select-methods))))
16270 (gnus-read-descriptions-file (car methods))
16271 (setq methods (cdr methods)))
16274 (defun gnus-read-descriptions-file (&optional method)
16275 (let ((method (or method gnus-select-method)))
16276 (when (stringp method)
16277 (setq method (gnus-server-to-method method)))
16278 ;; We create the hashtable whether we manage to read the desc file
16279 ;; to avoid trying to re-read after a failed read.
16280 (or gnus-description-hashtb
16281 (setq gnus-description-hashtb
16282 (gnus-make-hashtable (length gnus-active-hashtb))))
16283 ;; Mark this method's desc file as read.
16284 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16285 gnus-description-hashtb)
16287 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16289 ((not (gnus-check-server method))
16290 (gnus-message 1 "Couldn't open server")
16292 ((not (gnus-request-list-newsgroups method))
16293 (gnus-message 1 "Couldn't read newsgroups descriptions")
16299 (set-buffer nntp-server-buffer)
16300 (goto-char (point-min))
16301 (if (or (search-forward "\n.\n" nil t)
16302 (goto-char (point-max)))
16304 (beginning-of-line)
16305 (narrow-to-region (point-min) (point))))
16306 (goto-char (point-min))
16307 (while (not (eobp))
16308 ;; If we get an error, we set group to 0, which is not a
16312 (let ((obarray gnus-description-hashtb))
16313 ;; Group is set to a symbol interned in this
16315 (read nntp-server-buffer))
16317 (skip-chars-forward " \t")
16318 ;; ... which leads to this line being effectively ignored.
16319 (and (symbolp group)
16320 (set group (buffer-substring
16321 (point) (progn (end-of-line) (point)))))
16322 (forward-line 1))))
16323 (gnus-message 5 "Reading descriptions file...done")
16326 (defun gnus-group-get-description (group)
16327 "Get the description of a group by sending XGTITLE to the server."
16328 (when (gnus-request-group-description group)
16330 (set-buffer nntp-server-buffer)
16331 (goto-char (point-min))
16332 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16333 (match-string 1)))))
16337 ;;; Buffering of read articles.
16340 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16341 (defvar gnus-backlog-articles nil)
16342 (defvar gnus-backlog-hashtb nil)
16344 (defun gnus-backlog-buffer ()
16345 "Return the backlog buffer."
16346 (or (get-buffer gnus-backlog-buffer)
16348 (set-buffer (get-buffer-create gnus-backlog-buffer))
16349 (buffer-disable-undo (current-buffer))
16350 (setq buffer-read-only t)
16351 (gnus-add-current-to-buffer-list)
16352 (get-buffer gnus-backlog-buffer))))
16354 (defun gnus-backlog-setup ()
16355 "Initialize backlog variables."
16356 (unless gnus-backlog-hashtb
16357 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16359 (defun gnus-backlog-shutdown ()
16360 "Clear all backlog variables and buffers."
16361 (when (get-buffer gnus-backlog-buffer)
16362 (kill-buffer gnus-backlog-buffer))
16363 (setq gnus-backlog-hashtb nil
16364 gnus-backlog-articles nil))
16366 (defun gnus-backlog-enter-article (group number buffer)
16367 (gnus-backlog-setup)
16368 (let ((ident (intern (concat group ":" (int-to-string number))
16369 gnus-backlog-hashtb))
16371 (if (memq ident gnus-backlog-articles)
16372 () ; It's already kept.
16373 ;; Remove the oldest article, if necessary.
16374 (and (numberp gnus-keep-backlog)
16375 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16376 (gnus-backlog-remove-oldest-article))
16377 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16378 ;; Insert the new article.
16380 (set-buffer (gnus-backlog-buffer))
16381 (let (buffer-read-only)
16382 (goto-char (point-max))
16383 (or (bolp) (insert "\n"))
16385 (insert-buffer-substring buffer)
16386 ;; Tag the beginning of the article with the ident.
16387 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16389 (defun gnus-backlog-remove-oldest-article ()
16391 (set-buffer (gnus-backlog-buffer))
16392 (goto-char (point-min))
16393 (if (zerop (buffer-size))
16394 () ; The buffer is empty.
16395 (let ((ident (get-text-property (point) 'gnus-backlog))
16397 ;; Remove the ident from the list of articles.
16399 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16400 ;; Delete the article itself.
16402 (point) (next-single-property-change
16403 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16405 (defun gnus-backlog-request-article (group number buffer)
16406 (gnus-backlog-setup)
16407 (let ((ident (intern (concat group ":" (int-to-string number))
16408 gnus-backlog-hashtb))
16410 (when (memq ident gnus-backlog-articles)
16411 ;; It was in the backlog.
16413 (set-buffer (gnus-backlog-buffer))
16414 (if (not (setq beg (text-property-any
16415 (point-min) (point-max) 'gnus-backlog
16417 ;; It wasn't in the backlog after all.
16419 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16420 ;; Find the end (i. e., the beginning of the next article).
16422 (next-single-property-change
16423 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16424 (let ((buffer-read-only nil))
16426 (insert-buffer-substring gnus-backlog-buffer beg end)
16429 ;; Allow redefinition of Gnus functions.
16431 (gnus-ems-redefine)
16435 ;;; gnus.el ends here