1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
38 (eval-when-compile (require 'cl))
40 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
41 "*Directory variable from which all other Gnus file variables are derived.")
43 ;; Site dependent variables. These variables should be defined in
46 (defvar gnus-default-nntp-server nil
47 "Specify a default NNTP server.
48 This variable should be defined in paths.el, and should never be set
50 If you want to change servers, you should use `gnus-select-method'.
51 See the documentation to that variable.")
53 (defvar gnus-backup-default-subscribed-newsgroups
54 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
55 "Default default new newsgroups the first time Gnus is run.
56 Should be set in paths.el, and shouldn't be touched by the user.")
58 (defvar gnus-local-domain nil
59 "Local domain name without a host name.
60 The DOMAINNAME environment variable is used instead if it is defined.
61 If the `system-name' function returns the full Internet name, there is
62 no need to set this variable.")
64 (defvar gnus-local-organization nil
65 "String with a description of what organization (if any) the user belongs to.
66 The ORGANIZATION environment variable is used instead if it is defined.
67 If this variable contains a function, this function will be called
68 with the current newsgroup name as the argument. The function should
71 In any case, if the string (either in the variable, in the environment
72 variable, or returned by the function) is a file name, the contents of
73 this file will be used as the organization.")
75 ;; Customization variables
77 ;; Don't touch this variable.
78 (defvar gnus-nntp-service "nntp"
79 "*NNTP service name (\"nntp\" or 119).
80 This is an obsolete variable, which is scarcely used. If you use an
81 nntp server for your newsgroup and want to change the port number
82 used to 899, you would say something along these lines:
84 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
86 (defvar gnus-nntpserver-file "/etc/nntpserver"
87 "*A file with only the name of the nntp server in it.")
89 ;; This function is used to check both the environment variable
90 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
91 ;; an nntp server name default.
92 (defun gnus-getenv-nntpserver ()
93 (or (getenv "NNTPSERVER")
94 (and (file-readable-p gnus-nntpserver-file)
96 (set-buffer (get-buffer-create " *gnus nntp*"))
97 (buffer-disable-undo (current-buffer))
98 (insert-file-contents gnus-nntpserver-file)
99 (let ((name (buffer-string)))
101 (if (string-match "^[ \t\n]*$" name)
104 (kill-buffer (current-buffer))))))))
106 (defvar gnus-select-method
108 (list 'nntp (or (condition-case ()
109 (gnus-getenv-nntpserver)
111 (if (and gnus-default-nntp-server
112 (not (string= gnus-default-nntp-server "")))
113 gnus-default-nntp-server)
115 (if (or (null gnus-nntp-service)
116 (equal gnus-nntp-service "nntp"))
118 (list gnus-nntp-service)))
119 "*Default method for selecting a newsgroup.
120 This variable should be a list, where the first element is how the
121 news is to be fetched, the second is the address.
123 For instance, if you want to get your news via NNTP from
124 \"flab.flab.edu\", you could say:
126 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
128 If you want to use your local spool, say:
130 (setq gnus-select-method (list 'nnspool (system-name)))
132 If you use this variable, you must set `gnus-nntp-server' to nil.
134 There is a lot more to know about select methods and virtual servers -
135 see the manual for details.")
137 (defvar gnus-message-archive-method
140 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
141 (nnfolder-active-file
142 ,(nnheader-concat message-directory "archive/active"))
143 (nnfolder-get-new-mail nil)
144 (nnfolder-inhibit-expiry t))
145 "*Method used for archiving messages you've sent.
146 This should be a mail method.
148 It's probably not a very effective to change this variable once you've
149 run Gnus once. After doing that, you must edit this server from the
152 (defvar gnus-message-archive-group nil
153 "*Name of the group in which to save the messages you've written.
154 This can either be a string, a list of strings; or an alist
155 of regexps/functions/forms to be evaluated to return a string (or a list
156 of strings). The functions are called with the name of the current
157 group (or nil) as a parameter.
159 If you want to save your mail in one group and the news articles you
160 write in another group, you could say something like:
162 \(setq gnus-message-archive-group
163 '((if (message-news-p)
167 Normally the group names returned by this variable should be
168 unprefixed -- which implictly means \"store on the archive server\".
169 However, you may wish to store the message on some other server. In
170 that case, just return a fully prefixed name of the group --
171 \"nnml+private:mail.misc\", for instance.")
173 (defvar gnus-refer-article-method nil
174 "*Preferred method for fetching an article by Message-ID.
175 If you are reading news from the local spool (with nnspool), fetching
176 articles by Message-ID is painfully slow. By setting this method to an
177 nntp method, you might get acceptable results.
179 The value of this variable must be a valid select method as discussed
180 in the documentation of `gnus-select-method'.")
182 (defvar gnus-secondary-select-methods nil
183 "*A list of secondary methods that will be used for reading news.
184 This is a list where each element is a complete select method (see
185 `gnus-select-method').
187 If, for instance, you want to read your mail with the nnml backend,
188 you could set this variable:
190 (setq gnus-secondary-select-methods '((nnml \"\")))")
192 (defvar gnus-secondary-servers nil
193 "*List of NNTP servers that the user can choose between interactively.
194 To make Gnus query you for a server, you have to give `gnus' a
195 non-numeric prefix - `C-u M-x gnus', in short.")
197 (defvar gnus-nntp-server nil
198 "*The name of the host running the NNTP server.
199 This variable is semi-obsolete. Use the `gnus-select-method'
202 (defvar gnus-startup-file "~/.newsrc"
203 "*Your `.newsrc' file.
204 `.newsrc-SERVER' will be used instead if that exists.")
206 (defvar gnus-init-file "~/.gnus"
207 "*Your Gnus elisp startup file.
208 If a file with the .el or .elc suffixes exist, it will be read
211 (defvar gnus-group-faq-directory
212 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
213 "/ftp@sunsite.auc.dk:/pub/usenet/"
214 "/ftp@sunsite.doc.ic.ac.uk:/pub/usenet/news-faqs/"
215 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
216 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
217 "/ftp@rtfm.mit.edu:/pub/usenet/"
218 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
219 "/ftp@ftp.sunet.se:/pub/usenet/"
220 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
221 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
222 "/ftp@ftp.hk.super.net:/mirror/faqs/")
223 "*Directory where the group FAQs are stored.
224 This will most commonly be on a remote machine, and the file will be
227 This variable can also be a list of directories. In that case, the
228 first element in the list will be used by default. The others can
229 be used when being prompted for a site.
231 Note that Gnus uses an aol machine as the default directory. If this
232 feels fundamentally unclean, just think of it as a way to finally get
233 something of value back from them.
235 If the default site is too slow, try one of these:
237 North America: mirrors.aol.com /pub/rtfm/usenet
238 ftp.seas.gwu.edu /pub/rtfm
239 rtfm.mit.edu /pub/usenet
240 Europe: ftp.uni-paderborn.de /pub/FAQ
241 src.doc.ic.ac.uk /usenet/news-FAQS
242 ftp.sunet.se /pub/usenet
243 sunsite.auc.dk /pub/usenet
244 Asia: nctuccca.edu.tw /USENET/FAQ
245 hwarang.postech.ac.kr /pub/usenet
246 ftp.hk.super.net /mirror/faqs")
248 (defvar gnus-group-archive-directory
249 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
250 "*The address of the (ding) archives.")
252 (defvar gnus-group-recent-archive-directory
253 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
254 "*The address of the most recent (ding) articles.")
256 (defvar gnus-default-subscribed-newsgroups nil
257 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
258 It should be a list of strings.
259 If it is `t', Gnus will not do anything special the first time it is
260 started; it'll just use the normal newsgroups subscription methods.")
262 (defvar gnus-use-cross-reference t
263 "*Non-nil means that cross referenced articles will be marked as read.
264 If nil, ignore cross references. If t, mark articles as read in
265 subscribed newsgroups. If neither t nor nil, mark as read in all
268 (defvar gnus-single-article-buffer t
269 "*If non-nil, display all articles in the same buffer.
270 If nil, each group will get its own article buffer.")
272 (defvar gnus-use-dribble-file t
273 "*Non-nil means that Gnus will use a dribble file to store user updates.
274 If Emacs should crash without saving the .newsrc files, complete
275 information can be restored from the dribble file.")
277 (defvar gnus-dribble-directory nil
278 "*The directory where dribble files will be saved.
279 If this variable is nil, the directory where the .newsrc files are
280 saved will be used.")
282 (defvar gnus-asynchronous nil
283 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
285 (defvar gnus-kill-summary-on-exit t
286 "*If non-nil, kill the summary buffer when you exit from it.
287 If nil, the summary will become a \"*Dead Summary*\" buffer, and
288 it will be killed sometime later.")
290 (defvar gnus-large-newsgroup 200
291 "*The number of articles which indicates a large newsgroup.
292 If the number of articles in a newsgroup is greater than this value,
293 confirmation is required for selecting the newsgroup.")
295 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
296 (defvar gnus-no-groups-message "No news is horrible news"
297 "*Message displayed by Gnus when no groups are available.")
299 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
300 "*Non-nil means that the default name of a file to save articles in is the group name.
301 If it's nil, the directory form of the group name is used instead.
303 If this variable is a list, and the list contains the element
304 `not-score', long file names will not be used for score files; if it
305 contains the element `not-save', long file names will not be used for
306 saving; and if it contains the element `not-kill', long file names
307 will not be used for kill files.
309 Note that the default for this variable varies according to what system
310 type you're using. On `usg-unix-v' and `xenix' this variable defaults
311 to nil while on all other systems it defaults to t.")
313 (defvar gnus-article-save-directory gnus-directory
314 "*Name of the directory articles will be saved in (default \"~/News\").")
316 (defvar gnus-kill-files-directory gnus-directory
317 "*Name of the directory where kill files will be stored (default \"~/News\").")
319 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
320 "*A function to save articles in your favorite format.
321 The function must be interactively callable (in other words, it must
322 be an Emacs command).
324 Gnus provides the following functions:
326 * gnus-summary-save-in-rmail (Rmail format)
327 * gnus-summary-save-in-mail (Unix mail format)
328 * gnus-summary-save-in-folder (MH folder)
329 * gnus-summary-save-in-file (article format).
330 * gnus-summary-save-in-vm (use VM's folder format).")
332 (defvar gnus-prompt-before-saving 'always
333 "*This variable says how much prompting is to be done when saving articles.
334 If it is nil, no prompting will be done, and the articles will be
335 saved to the default files. If this variable is `always', each and
336 every article that is saved will be preceded by a prompt, even when
337 saving large batches of articles. If this variable is neither nil not
338 `always', there the user will be prompted once for a file name for
339 each invocation of the saving commands.")
341 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
342 "*A function generating a file name to save articles in Rmail format.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
345 (defvar gnus-mail-save-name (function gnus-plain-save-name)
346 "*A function generating a file name to save articles in Unix mail format.
347 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
349 (defvar gnus-folder-save-name (function gnus-folder-save-name)
350 "*A function generating a file name to save articles in MH folder.
351 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
353 (defvar gnus-file-save-name (function gnus-numeric-save-name)
354 "*A function generating a file name to save articles in article format.
355 The function is called with NEWSGROUP, HEADERS, and optional
358 (defvar gnus-split-methods
359 '((gnus-article-archive-name))
360 "*Variable used to suggest where articles are to be saved.
361 For instance, if you would like to save articles related to Gnus in
362 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
363 you could set this variable to something like:
365 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
366 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
368 This variable is an alist where the where the key is the match and the
369 value is a list of possible files to save in if the match is non-nil.
371 If the match is a string, it is used as a regexp match on the
372 article. If the match is a symbol, that symbol will be funcalled
373 from the buffer of the article to be saved with the newsgroup as the
374 parameter. If it is a list, it will be evaled in the same buffer.
376 If this form or function returns a string, this string will be used as
377 a possible file name; and if it returns a non-nil list, that list will
378 be used as possible file names.")
380 (defvar gnus-move-split-methods nil
381 "*Variable used to suggest where articles are to be moved to.
382 It uses the same syntax as the `gnus-split-methods' variable.")
384 (defvar gnus-save-score nil
385 "*If non-nil, save group scoring info.")
387 (defvar gnus-use-adaptive-scoring nil
388 "*If non-nil, use some adaptive scoring scheme.")
390 (defvar gnus-use-cache 'passive
391 "*If nil, Gnus will ignore the article cache.
392 If `passive', it will allow entering (and reading) articles
393 explicitly entered into the cache. If anything else, use the
394 cache to the full extent of the law.")
396 (defvar gnus-use-trees nil
397 "*If non-nil, display a thread tree buffer.")
399 (defvar gnus-use-grouplens nil
400 "*If non-nil, use GroupLens ratings.")
402 (defvar gnus-keep-backlog nil
403 "*If non-nil, Gnus will keep read articles for later re-retrieval.
404 If it is a number N, then Gnus will only keep the last N articles
405 read. If it is neither nil nor a number, Gnus will keep all read
406 articles. This is not a good idea.")
408 (defvar gnus-use-nocem nil
409 "*If non-nil, Gnus will read NoCeM cancel messages.")
411 (defvar gnus-use-demon nil
412 "If non-nil, Gnus might use some demons.")
414 (defvar gnus-use-scoring t
415 "*If non-nil, enable scoring.")
417 (defvar gnus-use-picons nil
418 "*If non-nil, display picons.")
420 (defvar gnus-fetch-old-headers nil
421 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
422 If an unread article in the group refers to an older, already read (or
423 just marked as read) article, the old article will not normally be
424 displayed in the Summary buffer. If this variable is non-nil, Gnus
425 will attempt to grab the headers to the old articles, and thereby
426 build complete threads. If it has the value `some', only enough
427 headers to connect otherwise loose threads will be displayed.
428 This variable can also be a number. In that case, no more than that
429 number of old headers will be fetched.
431 The server has to support NOV for any of this to work.")
434 ;(defvar gnus-visual t
435 ; "*If non-nil, will do various highlighting.
436 ;If nil, no mouse highlights (or any other highlights) will be
437 ;performed. This might speed up Gnus some when generating large group
438 ;and summary buffers.")
440 (defvar gnus-novice-user t
441 "*Non-nil means that you are a usenet novice.
442 If non-nil, verbose messages may be displayed and confirmations may be
445 (defvar gnus-expert-user nil
446 "*Non-nil means that you will never be asked for confirmation about anything.
447 And that means *anything*.")
449 (defvar gnus-verbose 7
450 "*Integer that says how verbose Gnus should be.
451 The higher the number, the more messages Gnus will flash to say what
452 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
453 display most important messages; and at ten, Gnus will keep on
454 jabbering all the time.")
456 (defvar gnus-keep-same-level nil
457 "*Non-nil means that the next newsgroup after the current will be on the same level.
458 When you type, for instance, `n' after reading the last article in the
459 current newsgroup, you will go to the next newsgroup. If this variable
460 is nil, the next newsgroup will be the next from the group
462 If this variable is non-nil, Gnus will either put you in the
463 next newsgroup with the same level, or, if no such newsgroup is
464 available, the next newsgroup with the lowest possible level higher
465 than the current level.
466 If this variable is `best', Gnus will make the next newsgroup the one
467 with the best level.")
469 (defvar gnus-summary-make-false-root 'adopt
470 "*nil means that Gnus won't gather loose threads.
471 If the root of a thread has expired or been read in a previous
472 session, the information necessary to build a complete thread has been
473 lost. Instead of having many small sub-threads from this original thread
474 scattered all over the summary buffer, Gnus can gather them.
476 If non-nil, Gnus will try to gather all loose sub-threads from an
477 original thread into one large thread.
479 If this variable is non-nil, it should be one of `none', `adopt',
482 If this variable is `none', Gnus will not make a false root, but just
483 present the sub-threads after another.
484 If this variable is `dummy', Gnus will create a dummy root that will
485 have all the sub-threads as children.
486 If this variable is `adopt', Gnus will make one of the \"children\"
487 the parent and mark all the step-children as such.
488 If this variable is `empty', the \"children\" are printed with empty
489 subject fields. (Or rather, they will be printed with a string
490 given by the `gnus-summary-same-subject' variable.)")
492 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
493 "*A regexp to match subjects to be excluded from loose thread gathering.
494 As loose thread gathering is done on subjects only, that means that
495 there can be many false gatherings performed. By rooting out certain
496 common subjects, gathering might become saner.")
498 (defvar gnus-summary-gather-subject-limit nil
499 "*Maximum length of subject comparisons when gathering loose threads.
500 Use nil to compare full subjects. Setting this variable to a low
501 number will help gather threads that have been corrupted by
502 newsreaders chopping off subject lines, but it might also mean that
503 unrelated articles that have subject that happen to begin with the
504 same few characters will be incorrectly gathered.
506 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
507 comparing subjects.")
509 (defvar gnus-simplify-ignored-prefixes nil
510 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily.")
512 (defvar gnus-build-sparse-threads nil
513 "*If non-nil, fill in the gaps in threads.
514 If `some', only fill in the gaps that are needed to tie loose threads
515 together. If `more', fill in all leaf nodes that Gnus can find. If
516 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
518 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
519 "Function used for gathering loose threads.
520 There are two pre-defined functions: `gnus-gather-threads-by-subject',
521 which only takes Subjects into consideration; and
522 `gnus-gather-threads-by-references', which compared the References
523 headers of the articles to find matches.")
525 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
526 (defvar gnus-summary-same-subject ""
527 "*String indicating that the current article has the same subject as the previous.
528 This variable will only be used if the value of
529 `gnus-summary-make-false-root' is `empty'.")
531 (defvar gnus-summary-goto-unread t
532 "*If non-nil, marking commands will go to the next unread article.
533 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
534 whether it is read or not.")
536 (defvar gnus-group-goto-unread t
537 "*If non-nil, movement commands will go to the next unread and subscribed group.")
539 (defvar gnus-goto-next-group-when-activating t
540 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
542 (defvar gnus-check-new-newsgroups t
543 "*Non-nil means that Gnus will run gnus-find-new-newsgroups at startup.
544 This normally finds new newsgroups by comparing the active groups the
545 servers have already reported with those Gnus already knows, either alive
548 When any of the following are true, gnus-find-new-newsgroups will instead
549 ask the servers (primary, secondary, and archive servers) to list new
550 groups since the last time it checked:
551 1. This variable is `ask-server'.
552 2. This variable is a list of select methods (see below).
553 3. `gnus-read-active-file' is nil or `some'.
554 4. A prefix argument is given to gnus-find-new-newsgroups interactively.
556 Thus, if this variable is `ask-server' or a list of select methods or
557 `gnus-read-active-file' is nil or `some', then the killed list is no
558 longer necessary, so you could safely set `gnus-save-killed-list' to nil.
560 This variable can be a list of select methods which Gnus will query with
561 the `ask-server' method in addition to the primary, secondary, and archive
565 (setq gnus-check-new-newsgroups
566 '((nntp \"some.server\") (nntp \"other.server\")))
568 If this variable is nil, then you have to tell Gnus explicitly to
569 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
571 (defvar gnus-check-bogus-newsgroups nil
572 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
573 If this variable is nil, then you have to tell Gnus explicitly to
574 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
576 (defvar gnus-read-active-file t
577 "*Non-nil means that Gnus will read the entire active file at startup.
578 If this variable is nil, Gnus will only know about the groups in your
581 If this variable is `some', Gnus will try to only read the relevant
582 parts of the active file from the server. Not all servers support
583 this, and it might be quite slow with other servers, but this should
584 generally be faster than both the t and nil value.
586 If you set this variable to nil or `some', you probably still want to
587 be told about new newsgroups that arrive. To do that, set
588 `gnus-check-new-newsgroups' to `ask-server'. This may not work
589 properly with all servers.")
591 (defvar gnus-level-subscribed 5
592 "*Groups with levels less than or equal to this variable are subscribed.")
594 (defvar gnus-level-unsubscribed 7
595 "*Groups with levels less than or equal to this variable are unsubscribed.
596 Groups with levels less than `gnus-level-subscribed', which should be
597 less than this variable, are subscribed.")
599 (defvar gnus-level-zombie 8
600 "*Groups with this level are zombie groups.")
602 (defvar gnus-level-killed 9
603 "*Groups with this level are killed.")
605 (defvar gnus-level-default-subscribed 3
606 "*New subscribed groups will be subscribed at this level.")
608 (defvar gnus-level-default-unsubscribed 6
609 "*New unsubscribed groups will be unsubscribed at this level.")
611 (defvar gnus-activate-level (1+ gnus-level-subscribed)
612 "*Groups higher than this level won't be activated on startup.
613 Setting this variable to something log might save lots of time when
614 you have many groups that you aren't interested in.")
616 (defvar gnus-activate-foreign-newsgroups 4
617 "*If nil, Gnus will not check foreign newsgroups at startup.
618 If it is non-nil, it should be a number between one and nine. Foreign
619 newsgroups that have a level lower or equal to this number will be
620 activated on startup. For instance, if you want to active all
621 subscribed newsgroups, but not the rest, you'd set this variable to
622 `gnus-level-subscribed'.
624 If you subscribe to lots of newsgroups from different servers, startup
625 might take a while. By setting this variable to nil, you'll save time,
626 but you won't be told how many unread articles there are in the
629 (defvar gnus-save-newsrc-file t
630 "*Non-nil means that Gnus will save the `.newsrc' file.
631 Gnus always saves its own startup file, which is called
632 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
633 be readily understood by other newsreaders. If you don't plan on
634 using other newsreaders, set this variable to nil to save some time on
637 (defvar gnus-save-killed-list t
638 "*If non-nil, save the list of killed groups to the startup file.
639 If you set this variable to nil, you'll save both time (when starting
640 and quitting) and space (both memory and disk), but it will also mean
641 that Gnus has no record of which groups are new and which are old, so
642 the automatic new newsgroups subscription methods become meaningless.
644 You should always set `gnus-check-new-newsgroups' to `ask-server' or
645 nil if you set this variable to nil.")
647 (defvar gnus-interactive-catchup t
648 "*If non-nil, require your confirmation when catching up a group.")
650 (defvar gnus-interactive-exit t
651 "*If non-nil, require your confirmation when exiting Gnus.")
653 (defvar gnus-kill-killed t
654 "*If non-nil, Gnus will apply kill files to already killed articles.
655 If it is nil, Gnus will never apply kill files to articles that have
656 already been through the scoring process, which might very well save lots
659 (defvar gnus-extract-address-components 'gnus-extract-address-components
660 "*Function for extracting address components from a From header.
661 Two pre-defined function exist: `gnus-extract-address-components',
662 which is the default, quite fast, and too simplistic solution, and
663 `mail-extract-address-components', which works much better, but is
666 (defvar gnus-summary-default-score 0
667 "*Default article score level.
668 If this variable is nil, scoring will be disabled.")
670 (defvar gnus-summary-zcore-fuzz 0
671 "*Fuzziness factor for the zcore in the summary buffer.
672 Articles with scores closer than this to `gnus-summary-default-score'
673 will not be marked.")
675 (defvar gnus-simplify-subject-fuzzy-regexp nil
676 "*Strings to be removed when doing fuzzy matches.
677 This can either be a regular expression or list of regular expressions
678 that will be removed from subject strings if fuzzy subject
679 simplification is selected.")
681 (defvar gnus-permanently-visible-groups nil
682 "*Regexp to match groups that should always be listed in the group buffer.
683 This means that they will still be listed when there are no unread
684 articles in the groups.")
686 (defvar gnus-list-groups-with-ticked-articles t
687 "*If non-nil, list groups that have only ticked articles.
688 If nil, only list groups that have unread articles.")
690 (defvar gnus-group-default-list-level gnus-level-subscribed
691 "*Default listing level.
692 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
694 (defvar gnus-group-use-permanent-levels nil
695 "*If non-nil, once you set a level, Gnus will use this level.")
697 (defvar gnus-group-list-inactive-groups t
698 "*If non-nil, inactive groups will be listed.")
700 (defvar gnus-show-mime nil
701 "*If non-nil, do mime processing of articles.
702 The articles will simply be fed to the function given by
703 `gnus-show-mime-method'.")
705 (defvar gnus-strict-mime t
706 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
708 (defvar gnus-show-mime-method 'metamail-buffer
709 "*Function to process a MIME message.
710 The function is called from the article buffer.")
712 (defvar gnus-decode-encoded-word-method (lambda ())
713 "*Function to decode a MIME encoded-words.
714 The function is called from the article buffer.")
716 (defvar gnus-show-threads t
717 "*If non-nil, display threads in summary mode.")
719 (defvar gnus-thread-hide-subtree nil
720 "*If non-nil, hide all threads initially.
721 If threads are hidden, you have to run the command
722 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
723 to expose hidden threads.")
725 (defvar gnus-thread-hide-killed t
726 "*If non-nil, hide killed threads automatically.")
728 (defvar gnus-thread-ignore-subject nil
729 "*If non-nil, ignore subjects and do all threading based on the Reference header.
730 If nil, which is the default, articles that have different subjects
731 from their parents will start separate threads.")
733 (defvar gnus-thread-operation-ignore-subject t
734 "*If non-nil, subjects will be ignored when doing thread commands.
735 This affects commands like `gnus-summary-kill-thread' and
736 `gnus-summary-lower-thread'.
738 If this variable is nil, articles in the same thread with different
739 subjects will not be included in the operation in question. If this
740 variable is `fuzzy', only articles that have subjects that are fuzzily
741 equal will be included.")
743 (defvar gnus-thread-indent-level 4
744 "*Number that says how much each sub-thread should be indented.")
746 (defvar gnus-ignored-newsgroups
747 (purecopy (mapconcat 'identity
748 '("^to\\." ; not "real" groups
749 "^[0-9. \t]+ " ; all digits in name
750 "[][\"#'()]" ; bogus characters
753 "*A regexp to match uninteresting newsgroups in the active file.
754 Any lines in the active file matching this regular expression are
755 removed from the newsgroup list before anything else is done to it,
756 thus making them effectively non-existent.")
758 (defvar gnus-ignored-headers
759 "^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:"
760 "*All headers that match this regexp will be hidden.
761 This variable can also be a list of regexps of headers to be ignored.
762 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
764 (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-"
765 "*All headers that do not match this regexp will be hidden.
766 This variable can also be a list of regexp of headers to remain visible.
767 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
769 (defvar gnus-sorted-header-list
770 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
771 "^Cc:" "^Date:" "^Organization:")
772 "*This variable is a list of regular expressions.
773 If it is non-nil, headers that match the regular expressions will
774 be placed first in the article buffer in the sequence specified by
777 (defvar gnus-boring-article-headers
778 '(empty followup-to reply-to)
779 "*Headers that are only to be displayed if they have interesting data.
780 Possible values in this list are `empty', `newsgroups', `followup-to',
781 `reply-to', and `date'.")
783 (defvar gnus-show-all-headers nil
784 "*If non-nil, don't hide any headers.")
786 (defvar gnus-save-all-headers t
787 "*If non-nil, don't remove any headers before saving.")
789 (defvar gnus-saved-headers gnus-visible-headers
790 "*Headers to keep if `gnus-save-all-headers' is nil.
791 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
792 If that variable is nil, however, all headers that match this regexp
793 will be kept while the rest will be deleted before saving.")
795 (defvar gnus-inhibit-startup-message nil
796 "*If non-nil, the startup message will not be displayed.")
798 (defvar gnus-signature-separator "^-- *$"
799 "Regexp matching signature separator.")
801 (defvar gnus-signature-limit nil
802 "Provide a limit to what is considered a signature.
803 If it is a number, no signature may not be longer (in characters) than
804 that number. If it is a function, the function will be called without
805 any parameters, and if it returns nil, there is no signature in the
806 buffer. If it is a string, it will be used as a regexp. If it
807 matches, the text in question is not a signature.")
809 (defvar gnus-auto-extend-newsgroup t
810 "*If non-nil, extend newsgroup forward and backward when requested.")
812 (defvar gnus-auto-select-first t
813 "*If nil, don't select the first unread article when entering a group.
814 If this variable is `best', select the highest-scored unread article
815 in the group. If neither nil nor `best', select the first unread
818 If you want to prevent automatic selection of the first unread article
819 in some newsgroups, set the variable to nil in
820 `gnus-select-group-hook'.")
822 (defvar gnus-auto-select-next t
823 "*If non-nil, offer to go to the next group from the end of the previous.
824 If the value is t and the next newsgroup is empty, Gnus will exit
825 summary mode and go back to group mode. If the value is neither nil
826 nor t, Gnus will select the following unread newsgroup. In
827 particular, if the value is the symbol `quietly', the next unread
828 newsgroup will be selected without any confirmation, and if it is
829 `almost-quietly', the next group will be selected without any
830 confirmation if you are located on the last article in the group.
831 Finally, if this variable is `slightly-quietly', the `Z n' command
832 will go to the next group without confirmation.")
834 (defvar gnus-auto-select-same nil
835 "*If non-nil, select the next article with the same subject.")
837 (defvar gnus-summary-check-current nil
838 "*If non-nil, consider the current article when moving.
839 The \"unread\" movement commands will stay on the same line if the
840 current article is unread.")
842 (defvar gnus-auto-center-summary t
843 "*If non-nil, always center the current summary buffer.
844 In particular, if `vertical' do only vertical recentering. If non-nil
845 and non-`vertical', do both horizontal and vertical recentering.")
847 (defvar gnus-break-pages t
848 "*If non-nil, do page breaking on articles.
849 The page delimiter is specified by the `gnus-page-delimiter'
852 (defvar gnus-page-delimiter "^\^L"
853 "*Regexp describing what to use as article page delimiters.
854 The default value is \"^\^L\", which is a form linefeed at the
855 beginning of a line.")
857 (defvar gnus-use-full-window t
858 "*If non-nil, use the entire Emacs screen.")
860 (defvar gnus-window-configuration nil
861 "Obsolete variable. See `gnus-buffer-configuration'.")
863 (defvar gnus-window-min-width 2
864 "*Minimum width of Gnus buffers.")
866 (defvar gnus-window-min-height 1
867 "*Minimum height of Gnus buffers.")
869 (defvar gnus-buffer-configuration
873 (if gnus-carpal '(group-carpal 4))))
877 (if gnus-carpal '(summary-carpal 4))))
884 (if gnus-carpal '(summary-carpal 4))
886 (vertical ((height . 5) (width . 15)
888 (left . -1) (top . 1))
898 (if gnus-carpal '(summary-carpal 4))
903 (if gnus-carpal '(server-carpal 2))))
907 (if gnus-carpal '(browse-carpal 2))))
910 (message 1.0 point)))
913 (article 1.0 point)))
924 (edit-group 1.0 point)))
928 (edit-server 1.0 point)))
932 (edit-score 1.0 point)))
939 (message 1.0 point)))
942 (message 1.0 point)))
945 (message 1.0 point)))
949 (message 1.0 point)))
956 (if gnus-carpal '(summary-carpal 4))
957 ("*Shell Command Output*" 1.0)))
960 ("*Gnus Help Bug*" 0.5)
961 ("*Gnus Bug*" 1.0 point)))
965 (message 1.0 point))))
966 "Window configuration for all possible Gnus buffers.
967 This variable is a list of lists. Each of these lists has a NAME and
968 a RULE. The NAMEs are commonsense names like `group', which names a
969 rule used when displaying the group buffer; `summary', which names a
970 rule for what happens when you enter a group and do not display an
971 article buffer; and so on. See the value of this variable for a
972 complete list of NAMEs.
974 Each RULE is a list of vectors. The first element in this vector is
975 the name of the buffer to be displayed; the second element is the
976 percentage of the screen this buffer is to occupy (a number in the
977 0.0-0.99 range); the optional third element is `point', which should
978 be present to denote which buffer point is to go to after making this
979 buffer configuration.")
981 (defvar gnus-window-to-buffer
982 '((group . gnus-group-buffer)
983 (summary . gnus-summary-buffer)
984 (article . gnus-article-buffer)
985 (server . gnus-server-buffer)
986 (browse . "*Gnus Browse Server*")
987 (edit-group . gnus-group-edit-buffer)
988 (edit-server . gnus-server-edit-buffer)
989 (group-carpal . gnus-carpal-group-buffer)
990 (summary-carpal . gnus-carpal-summary-buffer)
991 (server-carpal . gnus-carpal-server-buffer)
992 (browse-carpal . gnus-carpal-browse-buffer)
993 (edit-score . gnus-score-edit-buffer)
994 (message . gnus-message-buffer)
995 (mail . gnus-message-buffer)
996 (post-news . gnus-message-buffer)
997 (faq . gnus-faq-buffer)
998 (picons . "*Picons*")
999 (tree . gnus-tree-buffer)
1000 (info . gnus-info-buffer)
1001 (article-copy . gnus-article-copy)
1002 (draft . gnus-draft-buffer))
1003 "Mapping from short symbols to buffer names or buffer variables.")
1005 (defvar gnus-carpal nil
1006 "*If non-nil, display clickable icons.")
1008 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
1009 "*Function called with a group name when new group is detected.
1010 A few pre-made functions are supplied: `gnus-subscribe-randomly'
1011 inserts new groups at the beginning of the list of groups;
1012 `gnus-subscribe-alphabetically' inserts new groups in strict
1013 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
1014 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
1015 for your decision; `gnus-subscribe-killed' kills all new groups;
1016 `gnus-subscribe-zombies' will make all new groups into zombies.")
1018 ;; Suggested by a bug report by Hallvard B Furuseth.
1019 ;; <h.b.furuseth@usit.uio.no>.
1020 (defvar gnus-subscribe-options-newsgroup-method
1021 (function gnus-subscribe-alphabetically)
1022 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
1023 If, for instance, you want to subscribe to all newsgroups in the
1024 \"no\" and \"alt\" hierarchies, you'd put the following in your
1027 options -n no.all alt.all
1029 Gnus will the subscribe all new newsgroups in these hierarchies with
1030 the subscription method in this variable.")
1032 (defvar gnus-subscribe-hierarchical-interactive nil
1033 "*If non-nil, Gnus will offer to subscribe hierarchically.
1034 When a new hierarchy appears, Gnus will ask the user:
1036 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1038 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1039 subscribe to all newsgroups in the hierarchy and `s' will skip this
1040 hierarchy in its entirety.")
1042 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1043 "*Function used for sorting the group buffer.
1044 This function will be called with group info entries as the arguments
1045 for the groups to be sorted. Pre-made functions include
1046 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1047 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1048 `gnus-group-sort-by-rank'.
1050 This variable can also be a list of sorting functions. In that case,
1051 the most significant sort function should be the last function in the
1054 ;; Mark variables suggested by Thomas Michanek
1055 ;; <Thomas.Michanek@telelogic.se>.
1056 (defvar gnus-unread-mark ?
1057 "*Mark used for unread articles.")
1058 (defvar gnus-ticked-mark ?!
1059 "*Mark used for ticked articles.")
1060 (defvar gnus-dormant-mark ??
1061 "*Mark used for dormant articles.")
1062 (defvar gnus-del-mark ?r
1063 "*Mark used for del'd articles.")
1064 (defvar gnus-read-mark ?R
1065 "*Mark used for read articles.")
1066 (defvar gnus-expirable-mark ?E
1067 "*Mark used for expirable articles.")
1068 (defvar gnus-killed-mark ?K
1069 "*Mark used for killed articles.")
1070 (defvar gnus-souped-mark ?F
1071 "*Mark used for killed articles.")
1072 (defvar gnus-kill-file-mark ?X
1073 "*Mark used for articles killed by kill files.")
1074 (defvar gnus-low-score-mark ?Y
1075 "*Mark used for articles with a low score.")
1076 (defvar gnus-catchup-mark ?C
1077 "*Mark used for articles that are caught up.")
1078 (defvar gnus-replied-mark ?A
1079 "*Mark used for articles that have been replied to.")
1080 (defvar gnus-cached-mark ?*
1081 "*Mark used for articles that are in the cache.")
1082 (defvar gnus-saved-mark ?S
1083 "*Mark used for articles that have been saved to.")
1084 (defvar gnus-process-mark ?#
1086 (defvar gnus-ancient-mark ?O
1087 "*Mark used for ancient articles.")
1088 (defvar gnus-sparse-mark ?Q
1089 "*Mark used for sparsely reffed articles.")
1090 (defvar gnus-canceled-mark ?G
1091 "*Mark used for canceled articles.")
1092 (defvar gnus-score-over-mark ?+
1093 "*Score mark used for articles with high scores.")
1094 (defvar gnus-score-below-mark ?-
1095 "*Score mark used for articles with low scores.")
1096 (defvar gnus-empty-thread-mark ?
1097 "*There is no thread under the article.")
1098 (defvar gnus-not-empty-thread-mark ?=
1099 "*There is a thread under the article.")
1101 (defvar gnus-view-pseudo-asynchronously nil
1102 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1104 (defvar gnus-view-pseudos nil
1105 "*If `automatic', pseudo-articles will be viewed automatically.
1106 If `not-confirm', pseudos will be viewed automatically, and the user
1107 will not be asked to confirm the command.")
1109 (defvar gnus-view-pseudos-separately t
1110 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1111 If nil, all files that use the same viewing command will be given as a
1112 list of parameters to that command.")
1114 (defvar gnus-insert-pseudo-articles t
1115 "*If non-nil, insert pseudo-articles when decoding articles.")
1117 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1118 "*Format of group lines.
1119 It works along the same lines as a normal formatting string,
1120 with some simple extensions.
1122 %M Only marked articles (character, \"*\" or \" \")
1123 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1124 %L Level of subscribedness (integer)
1125 %N Number of unread articles (integer)
1126 %I Number of dormant articles (integer)
1127 %i Number of ticked and dormant (integer)
1128 %T Number of ticked articles (integer)
1129 %R Number of read articles (integer)
1130 %t Total number of articles (integer)
1131 %y Number of unread, unticked articles (integer)
1132 %G Group name (string)
1133 %g Qualified group name (string)
1134 %D Group description (string)
1135 %s Select method (string)
1136 %o Moderated group (char, \"m\")
1137 %p Process mark (char)
1138 %O Moderated group (string, \"(m)\" or \"\")
1139 %P Topic indentation (string)
1140 %l Whether there are GroupLens predictions for this group (string)
1141 %n Select from where (string)
1142 %z A string that look like `<%s:%n>' if a foreign select method is used
1143 %u User defined specifier. The next character in the format string should
1144 be a letter. Gnus will call the function gnus-user-format-function-X,
1145 where X is the letter following %u. The function will be passed the
1146 current header as argument. The function should return a string, which
1147 will be inserted into the buffer just like information from any other
1150 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1151 the mouse point move inside the area. There can only be one such area.
1153 Note that this format specification is not always respected. For
1154 reasons of efficiency, when listing killed groups, this specification
1155 is ignored altogether. If the spec is changed considerably, your
1156 output may end up looking strange when listing both alive and killed
1159 If you use %o or %O, reading the active file will be slower and quite
1160 a bit of extra memory will be used. %D will also worsen performance.
1161 Also note that if you change the format specification to include any
1162 of these specs, you must probably re-start Gnus to see them go into
1165 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1166 "*The format specification of the lines in the summary buffer.
1168 It works along the same lines as a normal formatting string,
1169 with some simple extensions.
1171 %N Article number, left padded with spaces (string)
1173 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1174 %n Name of the poster (string)
1175 %a Extracted name of the poster (string)
1176 %A Extracted address of the poster (string)
1177 %F Contents of the From: header (string)
1178 %x Contents of the Xref: header (string)
1179 %D Date of the article (string)
1180 %d Date of the article (string) in DD-MMM format
1181 %M Message-id of the article (string)
1182 %r References of the article (string)
1183 %c Number of characters in the article (integer)
1184 %L Number of lines in the article (integer)
1185 %I Indentation based on thread level (a string of spaces)
1186 %T A string with two possible values: 80 spaces if the article
1187 is on thread level two or larger and 0 spaces on level one
1188 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1189 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1190 %[ Opening bracket (character, \"[\" or \"<\")
1191 %] Closing bracket (character, \"]\" or \">\")
1192 %> Spaces of length thread-level (string)
1193 %< Spaces of length (- 20 thread-level) (string)
1194 %i Article score (number)
1195 %z Article zcore (character)
1196 %t Number of articles under the current thread (number).
1197 %e Whether the thread is empty or not (character).
1198 %l GroupLens score (string).
1199 %u User defined specifier. The next character in the format string should
1200 be a letter. Gnus will call the function gnus-user-format-function-X,
1201 where X is the letter following %u. The function will be passed the
1202 current header as argument. The function should return a string, which
1203 will be inserted into the summary just like information from any other
1206 Text between %( and %) will be highlighted with `gnus-mouse-face'
1207 when the mouse point is placed inside the area. There can only be one
1210 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1211 with care. For reasons of efficiency, Gnus will compute what column
1212 these characters will end up in, and \"hard-code\" that. This means that
1213 it is illegal to have these specs after a variable-length spec. Well,
1214 you might not be arrested, but your summary buffer will look strange,
1215 which is bad enough.
1217 The smart choice is to have these specs as for to the left as
1220 This restriction may disappear in later versions of Gnus.")
1222 (defvar gnus-summary-dummy-line-format
1224 "*The format specification for the dummy roots in the summary buffer.
1225 It works along the same lines as a normal formatting string,
1226 with some simple extensions.
1230 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1231 "*The format specification for the summary mode line.
1232 It works along the same lines as a normal formatting string,
1233 with some simple extensions:
1236 %p Unprefixed group name
1237 %A Current article number
1239 %U Number of unread articles in the group
1240 %e Number of unselected articles in the group
1241 %Z A string with unread/unselected article counts
1242 %g Shortish group name
1243 %S Subject of the current article
1244 %u User-defined spec
1245 %s Current score file name
1246 %d Number of dormant articles
1247 %r Number of articles that have been marked as read in this session
1248 %E Number of articles expunged by the score files")
1250 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1251 "*The format specification for the article mode line.
1252 See `gnus-summary-mode-line-format' for a closer description.")
1254 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1255 "*The format specification for the group mode line.
1256 It works along the same lines as a normal formatting string,
1257 with some simple extensions:
1259 %S The native news server.
1260 %M The native select method.
1261 %: \":\" if %S isn't \"\".")
1263 (defvar gnus-valid-select-methods
1264 '(("nntp" post address prompt-address)
1265 ("nnspool" post address)
1266 ("nnvirtual" post-mail virtual prompt-address)
1267 ("nnmbox" mail respool address)
1268 ("nnml" mail respool address)
1269 ("nnmh" mail respool address)
1270 ("nndir" post-mail prompt-address address)
1271 ("nneething" none address prompt-address)
1272 ("nndoc" none address prompt-address)
1273 ("nnbabyl" mail address respool)
1274 ("nnkiboze" post virtual)
1275 ("nnsoup" post-mail address)
1276 ("nndraft" post-mail)
1277 ("nnfolder" mail respool address))
1278 "An alist of valid select methods.
1279 The first element of each list lists should be a string with the name
1280 of the select method. The other elements may be be the category of
1281 this method (ie. `post', `mail', `none' or whatever) or other
1282 properties that this method has (like being respoolable).
1283 If you implement a new select method, all you should have to change is
1284 this variable. I think.")
1286 (defvar gnus-updated-mode-lines '(group article summary tree)
1287 "*List of buffers that should update their mode lines.
1288 The list may contain the symbols `group', `article' and `summary'. If
1289 the corresponding symbol is present, Gnus will keep that mode line
1290 updated with information that may be pertinent.
1291 If this variable is nil, screen refresh may be quicker.")
1293 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1294 (defvar gnus-mode-non-string-length nil
1295 "*Max length of mode-line non-string contents.
1296 If this is nil, Gnus will take space as is needed, leaving the rest
1297 of the modeline intact.")
1300 ;(defvar gnus-mouse-face 'highlight
1301 ; "*Face used for mouse highlighting in Gnus.
1302 ;No mouse highlights will be done if `gnus-visual' is nil.")
1304 (defvar gnus-summary-mark-below 0
1305 "*Mark all articles with a score below this variable as read.
1306 This variable is local to each summary buffer and usually set by the
1309 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1310 "*List of functions used for sorting articles in the summary buffer.
1311 This variable is only used when not using a threaded display.")
1313 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1314 "*List of functions used for sorting threads in the summary buffer.
1315 By default, threads are sorted by article number.
1317 Each function takes two threads and return non-nil if the first thread
1318 should be sorted before the other. If you use more than one function,
1319 the primary sort function should be the last. You should probably
1320 always include `gnus-thread-sort-by-number' in the list of sorting
1321 functions -- preferably first.
1323 Ready-mady functions include `gnus-thread-sort-by-number',
1324 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1325 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1326 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1328 (defvar gnus-thread-score-function '+
1329 "*Function used for calculating the total score of a thread.
1331 The function is called with the scores of the article and each
1332 subthread and should then return the score of the thread.
1334 Some functions you can use are `+', `max', or `min'.")
1336 (defvar gnus-summary-expunge-below nil
1337 "All articles that have a score less than this variable will be expunged.")
1339 (defvar gnus-thread-expunge-below nil
1340 "All threads that have a total score less than this variable will be expunged.
1341 See `gnus-thread-score-function' for en explanation of what a
1342 \"thread score\" is.")
1344 (defvar gnus-auto-subscribed-groups
1345 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1346 "*All new groups that match this regexp will be subscribed automatically.
1347 Note that this variable only deals with new groups. It has no effect
1348 whatsoever on old groups.
1350 New groups that match this regexp will not be handled by
1351 `gnus-subscribe-newsgroup-method'. Instead, they will
1352 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1354 (defvar gnus-options-subscribe nil
1355 "*All new groups matching this regexp will be subscribed unconditionally.
1356 Note that this variable deals only with new newsgroups. This variable
1357 does not affect old newsgroups.
1359 New groups that match this regexp will not be handled by
1360 `gnus-subscribe-newsgroup-method'. Instead, they will
1361 be subscribed using `gnus-subscribe-options-newsgroup-method'.")
1363 (defvar gnus-options-not-subscribe nil
1364 "*All new groups matching this regexp will be ignored.
1365 Note that this variable deals only with new newsgroups. This variable
1366 does not affect old (already subscribed) newsgroups.")
1368 (defvar gnus-auto-expirable-newsgroups nil
1369 "*Groups in which to automatically mark read articles as expirable.
1370 If non-nil, this should be a regexp that should match all groups in
1371 which to perform auto-expiry. This only makes sense for mail groups.")
1373 (defvar gnus-total-expirable-newsgroups nil
1374 "*Groups in which to perform expiry of all read articles.
1375 Use with extreme caution. All groups that match this regexp will be
1376 expiring - which means that all read articles will be deleted after
1377 (say) one week. (This only goes for mail groups and the like, of
1380 (defvar gnus-group-uncollapsed-levels 1
1381 "Number of group name elements to leave alone when making a short group name.")
1383 (defvar gnus-hidden-properties '(invisible t intangible t)
1384 "Property list to use for hiding text.")
1386 (defvar gnus-modtime-botch nil
1387 "*Non-nil means .newsrc should be deleted prior to save.
1388 Its use is due to the bogus appearance that .newsrc was modified on
1393 (defvar gnus-group-mode-hook nil
1394 "*A hook for Gnus group mode.")
1396 (defvar gnus-summary-mode-hook nil
1397 "*A hook for Gnus summary mode.
1398 This hook is run before any variables are set in the summary buffer.")
1400 (defvar gnus-article-mode-hook nil
1401 "*A hook for Gnus article mode.")
1403 (defvar gnus-summary-prepare-exit-hook nil
1404 "*A hook called when preparing to exit from the summary buffer.
1405 It calls `gnus-summary-expire-articles' by default.")
1406 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1408 (defvar gnus-summary-exit-hook nil
1409 "*A hook called on exit from the summary buffer.")
1411 (defvar gnus-check-bogus-groups-hook nil
1412 "A hook run after removing bogus groups.")
1414 (defvar gnus-group-catchup-group-hook nil
1415 "*A hook run when catching up a group from the group buffer.")
1417 (defvar gnus-group-update-group-hook nil
1418 "*A hook called when updating group lines.")
1420 (defvar gnus-open-server-hook nil
1421 "*A hook called just before opening connection to the news server.")
1423 (defvar gnus-load-hook nil
1424 "*A hook run while Gnus is loaded.")
1426 (defvar gnus-startup-hook nil
1427 "*A hook called at startup.
1428 This hook is called after Gnus is connected to the NNTP server.")
1430 (defvar gnus-get-new-news-hook nil
1431 "*A hook run just before Gnus checks for new news.")
1433 (defvar gnus-after-getting-new-news-hook nil
1434 "*A hook run after Gnus checks for new news.")
1436 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1437 "*A function that is called to generate the group buffer.
1438 The function is called with three arguments: The first is a number;
1439 all group with a level less or equal to that number should be listed,
1440 if the second is non-nil, empty groups should also be displayed. If
1441 the third is non-nil, it is a number. No groups with a level lower
1442 than this number should be displayed.
1444 The only current function implemented is `gnus-group-prepare-flat'.")
1446 (defvar gnus-group-prepare-hook nil
1447 "*A hook called after the group buffer has been generated.
1448 If you want to modify the group buffer, you can use this hook.")
1450 (defvar gnus-summary-prepare-hook nil
1451 "*A hook called after the summary buffer has been generated.
1452 If you want to modify the summary buffer, you can use this hook.")
1454 (defvar gnus-summary-generate-hook nil
1455 "*A hook run just before generating the summary buffer.
1456 This hook is commonly used to customize threading variables and the
1459 (defvar gnus-article-prepare-hook nil
1460 "*A hook called after an article has been prepared in the article buffer.
1461 If you want to run a special decoding program like nkf, use this hook.")
1463 ;(defvar gnus-article-display-hook nil
1464 ; "*A hook called after the article is displayed in the article buffer.
1465 ;The hook is designed to change the contents of the article
1466 ;buffer. Typical functions that this hook may contain are
1467 ;`gnus-article-hide-headers' (hide selected headers),
1468 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1469 ;`gnus-article-hide-signature' (hide signature) and
1470 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1471 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1472 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1473 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1475 (defvar gnus-article-x-face-too-ugly nil
1476 "Regexp matching posters whose face shouldn't be shown automatically.")
1478 (defvar gnus-select-group-hook nil
1479 "*A hook called when a newsgroup is selected.
1481 If you'd like to simplify subjects like the
1482 `gnus-summary-next-same-subject' command does, you can use the
1485 (setq gnus-select-group-hook
1488 (mapcar (lambda (header)
1489 (mail-header-set-subject
1491 (gnus-simplify-subject
1492 (mail-header-subject header) 're-only)))
1493 gnus-newsgroup-headers))))")
1495 (defvar gnus-select-article-hook nil
1496 "*A hook called when an article is selected.")
1498 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1499 "*A hook called to apply kill files to a group.
1500 This hook is intended to apply a kill file to the selected newsgroup.
1501 The function `gnus-apply-kill-file' is called by default.
1503 Since a general kill file is too heavy to use only for a few
1504 newsgroups, I recommend you to use a lighter hook function. For
1505 example, if you'd like to apply a kill file to articles which contains
1506 a string `rmgroup' in subject in newsgroup `control', you can use the
1509 (setq gnus-apply-kill-hook
1512 (cond ((string-match \"control\" gnus-newsgroup-name)
1513 (gnus-kill \"Subject\" \"rmgroup\")
1514 (gnus-expunge \"X\"))))))")
1516 (defvar gnus-visual-mark-article-hook
1517 (list 'gnus-highlight-selected-summary)
1518 "*Hook run after selecting an article in the summary buffer.
1519 It is meant to be used for highlighting the article in some way. It
1520 is not run if `gnus-visual' is nil.")
1522 (defvar gnus-parse-headers-hook nil
1523 "*A hook called before parsing the headers.")
1524 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1526 (defvar gnus-exit-group-hook nil
1527 "*A hook called when exiting (not quitting) summary mode.")
1529 (defvar gnus-suspend-gnus-hook nil
1530 "*A hook called when suspending (not exiting) Gnus.")
1532 (defvar gnus-exit-gnus-hook nil
1533 "*A hook called when exiting Gnus.")
1535 (defvar gnus-after-exiting-gnus-hook nil
1536 "*A hook called after exiting Gnus.")
1538 (defvar gnus-save-newsrc-hook nil
1539 "*A hook called before saving any of the newsrc files.")
1541 (defvar gnus-save-quick-newsrc-hook nil
1542 "*A hook called just before saving the quick newsrc file.
1543 Can be used to turn version control on or off.")
1545 (defvar gnus-save-standard-newsrc-hook nil
1546 "*A hook called just before saving the standard newsrc file.
1547 Can be used to turn version control on or off.")
1549 (defvar gnus-summary-update-hook
1550 (list 'gnus-summary-highlight-line)
1551 "*A hook called when a summary line is changed.
1552 The hook will not be called if `gnus-visual' is nil.
1554 The default function `gnus-summary-highlight-line' will
1555 highlight the line according to the `gnus-summary-highlight'
1558 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1559 "*A hook called when a group line is changed.
1560 The hook will not be called if `gnus-visual' is nil.
1562 The default function `gnus-group-highlight-line' will
1563 highlight the line according to the `gnus-group-highlight'
1566 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1567 "*A hook called when an article is selected for the first time.
1568 The hook is intended to mark an article as read (or unread)
1569 automatically when it is selected.")
1571 (defvar gnus-group-change-level-function nil
1572 "Function run when a group level is changed.
1573 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1575 ;; Remove any hilit infestation.
1576 (add-hook 'gnus-startup-hook
1578 (remove-hook 'gnus-summary-prepare-hook
1579 'hilit-rehighlight-buffer-quietly)
1580 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1581 (setq gnus-mark-article-hook
1582 '(gnus-summary-mark-read-and-unread-as-read))
1583 (remove-hook 'gnus-article-prepare-hook
1584 'hilit-rehighlight-buffer-quietly)))
1587 ;; Internal variables
1589 (defvar gnus-tree-buffer "*Tree*"
1590 "Buffer where Gnus thread trees are displayed.")
1593 (defvar gnus-use-generic-from nil)
1595 (defvar gnus-thread-indent-array nil)
1596 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1598 (defvar gnus-newsrc-file-version nil)
1600 (defvar gnus-method-history nil)
1601 ;; Variable holding the user answers to all method prompts.
1603 (defvar gnus-group-history nil)
1604 ;; Variable holding the user answers to all group prompts.
1606 (defvar gnus-server-alist nil
1607 "List of available servers.")
1609 (defvar gnus-group-indentation-function nil)
1611 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1613 (defvar gnus-goto-missing-group-function nil)
1615 (defvar gnus-override-subscribe-method nil)
1617 (defvar gnus-group-goto-next-group-function nil
1618 "Function to override finding the next group after listing groups.")
1620 (defconst gnus-article-mark-lists
1621 '((marked . tick) (replied . reply)
1622 (expirable . expire) (killed . killed)
1623 (bookmarks . bookmark) (dormant . dormant)
1624 (scored . score) (saved . save)
1628 ;; Avoid highlighting in kill files.
1629 (defvar gnus-summary-inhibit-highlight nil)
1630 (defvar gnus-newsgroup-selected-overlay nil)
1632 (defvar gnus-inhibit-hiding nil)
1633 (defvar gnus-group-indentation "")
1634 (defvar gnus-inhibit-limiting nil)
1635 (defvar gnus-created-frames nil)
1637 (defvar gnus-article-mode-map nil)
1638 (defvar gnus-dribble-buffer nil)
1639 (defvar gnus-headers-retrieved-by nil)
1640 (defvar gnus-article-reply nil)
1641 (defvar gnus-override-method nil)
1642 (defvar gnus-article-check-size nil)
1644 (defvar gnus-current-score-file nil)
1645 (defvar gnus-newsgroup-adaptive-score-file nil)
1646 (defvar gnus-scores-exclude-files nil)
1648 (defvar gnus-opened-servers nil)
1650 (defvar gnus-current-move-group nil)
1651 (defvar gnus-current-copy-group nil)
1652 (defvar gnus-current-crosspost-group nil)
1654 (defvar gnus-newsgroup-dependencies nil)
1655 (defvar gnus-newsgroup-async nil)
1656 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1658 (defvar gnus-newsgroup-adaptive nil)
1660 (defvar gnus-summary-display-table nil)
1661 (defvar gnus-summary-display-article-function nil)
1663 (defvar gnus-summary-highlight-line-function nil
1664 "Function called after highlighting a summary line.")
1666 (defvar gnus-group-line-format-alist
1667 `((?M gnus-tmp-marked-mark ?c)
1668 (?S gnus-tmp-subscribed ?c)
1669 (?L gnus-tmp-level ?d)
1670 (?N (cond ((eq number t) "*" )
1674 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1675 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1677 (?R gnus-tmp-number-of-read ?s)
1678 (?t gnus-tmp-number-total ?d)
1679 (?y gnus-tmp-number-of-unread ?s)
1680 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1681 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1682 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1683 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1684 (?g gnus-tmp-group ?s)
1685 (?G gnus-tmp-qualified-group ?s)
1686 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1687 (?D gnus-tmp-newsgroup-description ?s)
1688 (?o gnus-tmp-moderated ?c)
1689 (?O gnus-tmp-moderated-string ?s)
1690 (?p gnus-tmp-process-marked ?c)
1691 (?s gnus-tmp-news-server ?s)
1692 (?n gnus-tmp-news-method ?s)
1693 (?P gnus-group-indentation ?s)
1694 (?l gnus-tmp-grouplens ?s)
1695 (?z gnus-tmp-news-method-string ?s)
1696 (?u gnus-tmp-user-defined ?s)))
1698 (defvar gnus-summary-line-format-alist
1699 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1700 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1701 (?s gnus-tmp-subject-or-nil ?s)
1702 (?n gnus-tmp-name ?s)
1703 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1705 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1707 (?F gnus-tmp-from ?s)
1708 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1709 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1710 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1711 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1712 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1713 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1714 (?L gnus-tmp-lines ?d)
1715 (?I gnus-tmp-indentation ?s)
1716 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1717 (?R gnus-tmp-replied ?c)
1718 (?\[ gnus-tmp-opening-bracket ?c)
1719 (?\] gnus-tmp-closing-bracket ?c)
1720 (?\> (make-string gnus-tmp-level ? ) ?s)
1721 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1722 (?i gnus-tmp-score ?d)
1723 (?z gnus-tmp-score-char ?c)
1724 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1725 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1726 (?U gnus-tmp-unread ?c)
1727 (?t (gnus-summary-number-of-articles-in-thread
1728 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1730 (?e (gnus-summary-number-of-articles-in-thread
1731 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1733 (?u gnus-tmp-user-defined ?s))
1734 "An alist of format specifications that can appear in summary lines,
1735 and what variables they correspond with, along with the type of the
1736 variable (string, integer, character, etc).")
1738 (defvar gnus-summary-dummy-line-format-alist
1739 `((?S gnus-tmp-subject ?s)
1740 (?N gnus-tmp-number ?d)
1741 (?u gnus-tmp-user-defined ?s)))
1743 (defvar gnus-summary-mode-line-format-alist
1744 `((?G gnus-tmp-group-name ?s)
1745 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1746 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1747 (?A gnus-tmp-article-number ?d)
1748 (?Z gnus-tmp-unread-and-unselected ?s)
1749 (?V gnus-version ?s)
1750 (?U gnus-tmp-unread-and-unticked ?d)
1751 (?S gnus-tmp-subject ?s)
1752 (?e gnus-tmp-unselected ?d)
1753 (?u gnus-tmp-user-defined ?s)
1754 (?d (length gnus-newsgroup-dormant) ?d)
1755 (?t (length gnus-newsgroup-marked) ?d)
1756 (?r (length gnus-newsgroup-reads) ?d)
1757 (?E gnus-newsgroup-expunged-tally ?d)
1758 (?s (gnus-current-score-file-nondirectory) ?s)))
1760 (defvar gnus-article-mode-line-format-alist
1761 gnus-summary-mode-line-format-alist)
1763 (defvar gnus-group-mode-line-format-alist
1764 `((?S gnus-tmp-news-server ?s)
1765 (?M gnus-tmp-news-method ?s)
1766 (?u gnus-tmp-user-defined ?s)
1767 (?: gnus-tmp-colon ?s)))
1769 (defvar gnus-have-read-active-file nil)
1771 (defconst gnus-maintainer
1772 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1773 "The mail address of the Gnus maintainers.")
1775 (defconst gnus-version-number "5.2.33"
1776 "Version number for this version of Gnus.")
1778 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1779 "Version string for this version of Gnus.")
1781 (defvar gnus-info-nodes
1782 '((gnus-group-mode "(gnus)The Group Buffer")
1783 (gnus-summary-mode "(gnus)The Summary Buffer")
1784 (gnus-article-mode "(gnus)The Article Buffer")
1785 (gnus-server-mode "(gnus)The Server Buffer")
1786 (gnus-browse-mode "(gnus)Browse Foreign Server")
1787 (gnus-tree-mode "(gnus)Tree Display")
1789 "Alist of major modes and related Info nodes.")
1791 (defvar gnus-group-buffer "*Group*")
1792 (defvar gnus-summary-buffer "*Summary*")
1793 (defvar gnus-article-buffer "*Article*")
1794 (defvar gnus-server-buffer "*Server*")
1796 (defvar gnus-work-buffer " *gnus work*")
1798 (defvar gnus-original-article-buffer " *Original Article*")
1799 (defvar gnus-original-article nil)
1801 (defvar gnus-buffer-list nil
1802 "Gnus buffers that should be killed on exit.")
1804 (defvar gnus-slave nil
1805 "Whether this Gnus is a slave or not.")
1807 (defvar gnus-variable-list
1808 '(gnus-newsrc-options gnus-newsrc-options-n
1809 gnus-newsrc-last-checked-date
1810 gnus-newsrc-alist gnus-server-alist
1811 gnus-killed-list gnus-zombie-list
1812 gnus-topic-topology gnus-topic-alist
1814 "Gnus variables saved in the quick startup file.")
1816 (defvar gnus-newsrc-options nil
1817 "Options line in the .newsrc file.")
1819 (defvar gnus-newsrc-options-n nil
1820 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1822 (defvar gnus-newsrc-last-checked-date nil
1823 "Date Gnus last asked server for new newsgroups.")
1825 (defvar gnus-topic-topology nil
1826 "The complete topic hierarchy.")
1828 (defvar gnus-topic-alist nil
1829 "The complete topic-group alist.")
1831 (defvar gnus-newsrc-alist nil
1832 "Assoc list of read articles.
1833 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1835 (defvar gnus-newsrc-hashtb nil
1836 "Hashtable of gnus-newsrc-alist.")
1838 (defvar gnus-killed-list nil
1839 "List of killed newsgroups.")
1841 (defvar gnus-killed-hashtb nil
1842 "Hash table equivalent of gnus-killed-list.")
1844 (defvar gnus-zombie-list nil
1845 "List of almost dead newsgroups.")
1847 (defvar gnus-description-hashtb nil
1848 "Descriptions of newsgroups.")
1850 (defvar gnus-list-of-killed-groups nil
1851 "List of newsgroups that have recently been killed by the user.")
1853 (defvar gnus-active-hashtb nil
1854 "Hashtable of active articles.")
1856 (defvar gnus-moderated-list nil
1857 "List of moderated newsgroups.")
1859 (defvar gnus-group-marked nil)
1861 (defvar gnus-current-startup-file nil
1862 "Startup file for the current host.")
1864 (defvar gnus-last-search-regexp nil
1865 "Default regexp for article search command.")
1867 (defvar gnus-last-shell-command nil
1868 "Default shell command on article.")
1870 (defvar gnus-current-select-method nil
1871 "The current method for selecting a newsgroup.")
1873 (defvar gnus-group-list-mode nil)
1875 (defvar gnus-article-internal-prepare-hook nil)
1877 (defvar gnus-newsgroup-name nil)
1878 (defvar gnus-newsgroup-begin nil)
1879 (defvar gnus-newsgroup-end nil)
1880 (defvar gnus-newsgroup-last-rmail nil)
1881 (defvar gnus-newsgroup-last-mail nil)
1882 (defvar gnus-newsgroup-last-folder nil)
1883 (defvar gnus-newsgroup-last-file nil)
1884 (defvar gnus-newsgroup-auto-expire nil)
1885 (defvar gnus-newsgroup-active nil)
1887 (defvar gnus-newsgroup-data nil)
1888 (defvar gnus-newsgroup-data-reverse nil)
1889 (defvar gnus-newsgroup-limit nil)
1890 (defvar gnus-newsgroup-limits nil)
1892 (defvar gnus-newsgroup-unreads nil
1893 "List of unread articles in the current newsgroup.")
1895 (defvar gnus-newsgroup-unselected nil
1896 "List of unselected unread articles in the current newsgroup.")
1898 (defvar gnus-newsgroup-reads nil
1899 "Alist of read articles and article marks in the current newsgroup.")
1901 (defvar gnus-newsgroup-expunged-tally nil)
1903 (defvar gnus-newsgroup-marked nil
1904 "List of ticked articles in the current newsgroup (a subset of unread art).")
1906 (defvar gnus-newsgroup-killed nil
1907 "List of ranges of articles that have been through the scoring process.")
1909 (defvar gnus-newsgroup-cached nil
1910 "List of articles that come from the article cache.")
1912 (defvar gnus-newsgroup-saved nil
1913 "List of articles that have been saved.")
1915 (defvar gnus-newsgroup-kill-headers nil)
1917 (defvar gnus-newsgroup-replied nil
1918 "List of articles that have been replied to in the current newsgroup.")
1920 (defvar gnus-newsgroup-expirable nil
1921 "List of articles in the current newsgroup that can be expired.")
1923 (defvar gnus-newsgroup-processable nil
1924 "List of articles in the current newsgroup that can be processed.")
1926 (defvar gnus-newsgroup-bookmarks nil
1927 "List of articles in the current newsgroup that have bookmarks.")
1929 (defvar gnus-newsgroup-dormant nil
1930 "List of dormant articles in the current newsgroup.")
1932 (defvar gnus-newsgroup-scored nil
1933 "List of scored articles in the current newsgroup.")
1935 (defvar gnus-newsgroup-headers nil
1936 "List of article headers in the current newsgroup.")
1938 (defvar gnus-newsgroup-threads nil)
1940 (defvar gnus-newsgroup-prepared nil
1941 "Whether the current group has been prepared properly.")
1943 (defvar gnus-newsgroup-ancient nil
1944 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1946 (defvar gnus-newsgroup-sparse nil)
1948 (defvar gnus-current-article nil)
1949 (defvar gnus-article-current nil)
1950 (defvar gnus-current-headers nil)
1951 (defvar gnus-have-all-headers nil)
1952 (defvar gnus-last-article nil)
1953 (defvar gnus-newsgroup-history nil)
1954 (defvar gnus-current-kill-article nil)
1956 ;; Save window configuration.
1957 (defvar gnus-prev-winconf nil)
1959 (defvar gnus-summary-mark-positions nil)
1960 (defvar gnus-group-mark-positions nil)
1962 (defvar gnus-reffed-article-number nil)
1964 ;;; Let the byte-compiler know that we know about this variable.
1965 (defvar rmail-default-rmail-file)
1967 (defvar gnus-cache-removable-articles nil)
1969 (defvar gnus-dead-summary nil)
1971 (defconst gnus-summary-local-variables
1972 '(gnus-newsgroup-name
1973 gnus-newsgroup-begin gnus-newsgroup-end
1974 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1975 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1976 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1977 gnus-newsgroup-unselected gnus-newsgroup-marked
1978 gnus-newsgroup-reads gnus-newsgroup-saved
1979 gnus-newsgroup-replied gnus-newsgroup-expirable
1980 gnus-newsgroup-processable gnus-newsgroup-killed
1981 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1982 gnus-newsgroup-headers gnus-newsgroup-threads
1983 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1984 gnus-current-article gnus-current-headers gnus-have-all-headers
1985 gnus-last-article gnus-article-internal-prepare-hook
1986 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1987 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1988 gnus-newsgroup-async gnus-thread-expunge-below
1989 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1990 (gnus-summary-mark-below . global)
1991 gnus-newsgroup-active gnus-scores-exclude-files
1992 gnus-newsgroup-history gnus-newsgroup-ancient
1993 gnus-newsgroup-sparse
1994 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1995 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1996 (gnus-newsgroup-expunged-tally . 0)
1997 gnus-cache-removable-articles gnus-newsgroup-cached
1998 gnus-newsgroup-data gnus-newsgroup-data-reverse
1999 gnus-newsgroup-limit gnus-newsgroup-limits)
2000 "Variables that are buffer-local to the summary buffers.")
2002 (defconst gnus-bug-message
2003 "Sending a bug report to the Gnus Towers.
2004 ========================================
2006 The buffer below is a mail buffer. When you press `C-c C-c', it will
2007 be sent to the Gnus Bug Exterminators.
2009 At the bottom of the buffer you'll see lots of variable settings.
2010 Please do not delete those. They will tell the Bug People what your
2011 environment is, so that it will be easier to locate the bugs.
2013 If you have found a bug that makes Emacs go \"beep\", set
2014 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
2015 and include the backtrace in your bug report.
2017 Please describe the bug in annoying, painstaking detail.
2019 Thank you for your help in stamping out bugs.
2022 ;;; End of variables.
2024 ;; Define some autoload functions Gnus might use.
2027 ;; This little mapcar goes through the list below and marks the
2028 ;; symbols in question as autoloaded functions.
2031 (let ((interactive (nth 1 (memq ':interactive package))))
2035 (when (consp function)
2036 (setq keymap (car (memq 'keymap function)))
2037 (setq function (car function)))
2038 (autoload function (car package) nil interactive keymap)))
2039 (if (eq (nth 1 package) ':interactive)
2042 '(("metamail" metamail-buffer)
2043 ("info" Info-goto-node)
2044 ("hexl" hexl-hex-string-to-integer)
2045 ("pp" pp pp-to-string pp-eval-expression)
2046 ("mail-extr" mail-extract-address-components)
2047 ("nnmail" nnmail-split-fancy nnmail-article-group)
2048 ("nnvirtual" nnvirtual-catchup-group)
2049 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2050 timezone-make-sortable-date timezone-make-time-string)
2051 ("rmailout" rmail-output)
2052 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2054 ("gnus-soup" :interactive t
2055 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2056 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2057 ("nnsoup" nnsoup-pack-replies)
2058 ("score-mode" :interactive t gnus-score-mode)
2059 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2060 gnus-Folder-save-name gnus-folder-save-name)
2061 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2062 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2063 gnus-server-make-menu-bar gnus-article-make-menu-bar
2064 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2065 gnus-summary-highlight-line gnus-carpal-setup-buffer
2066 gnus-group-highlight-line
2067 gnus-article-add-button gnus-insert-next-page-button
2068 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2069 ("gnus-vis" :interactive t
2070 gnus-article-push-button gnus-article-press-button
2071 gnus-article-highlight gnus-article-highlight-some
2072 gnus-article-highlight-headers gnus-article-highlight-signature
2073 gnus-article-add-buttons gnus-article-add-buttons-to-head
2074 gnus-article-next-button gnus-article-prev-button)
2075 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2076 gnus-demon-add-disconnection gnus-demon-add-handler
2077 gnus-demon-remove-handler)
2078 ("gnus-demon" :interactive t
2079 gnus-demon-init gnus-demon-cancel)
2080 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2081 gnus-tree-open gnus-tree-close)
2082 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2083 gnus-nocem-unwanted-article-p)
2084 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2085 ("gnus-srvr" gnus-browse-foreign-server)
2086 ("gnus-cite" :interactive t
2087 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2088 gnus-article-hide-citation gnus-article-fill-cited-article
2089 gnus-article-hide-citation-in-followups)
2090 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2091 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2092 gnus-execute gnus-expunge)
2093 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2094 gnus-cache-possibly-remove-articles gnus-cache-request-article
2095 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2096 gnus-cache-enter-remove-article gnus-cached-article-p
2097 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2098 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2099 gnus-cache-remove-article)
2100 ("gnus-score" :interactive t
2101 gnus-summary-increase-score gnus-summary-lower-score
2102 gnus-score-flush-cache gnus-score-close
2103 gnus-score-raise-same-subject-and-select
2104 gnus-score-raise-same-subject gnus-score-default
2105 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2106 gnus-score-lower-same-subject gnus-score-lower-thread
2107 gnus-possibly-score-headers gnus-summary-raise-score
2108 gnus-summary-set-score gnus-summary-current-score)
2110 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2111 gnus-current-score-file-nondirectory gnus-score-adaptive
2112 gnus-score-find-trace gnus-score-file-name)
2113 ("gnus-edit" :interactive t gnus-score-customize)
2114 ("gnus-topic" :interactive t gnus-topic-mode)
2115 ("gnus-topic" gnus-topic-remove-group)
2116 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2117 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2118 ("gnus-uu" :interactive t
2119 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2120 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2121 gnus-uu-mark-by-regexp gnus-uu-mark-all
2122 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2123 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2124 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2125 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2126 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2127 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2128 gnus-uu-decode-binhex-view)
2129 ("gnus-msg" (gnus-summary-send-map keymap)
2130 gnus-mail-yank-original gnus-mail-send-and-exit
2131 gnus-article-mail gnus-new-mail gnus-mail-reply)
2132 ("gnus-msg" :interactive t
2133 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2134 gnus-summary-followup gnus-summary-followup-with-original
2135 gnus-summary-cancel-article gnus-summary-supersede-article
2136 gnus-post-news gnus-inews-news
2137 gnus-summary-reply gnus-summary-reply-with-original
2138 gnus-summary-mail-forward gnus-summary-mail-other-window
2140 ("gnus-picon" :interactive t gnus-article-display-picons
2141 gnus-group-display-picons gnus-picons-article-display-x-face
2142 gnus-picons-display-x-face)
2143 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2144 gnus-grouplens-mode)
2145 ("smiley" :interactive t gnus-smiley-display)
2146 ("gnus-vm" gnus-vm-mail-setup)
2147 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2148 gnus-summary-save-article-vm))))
2152 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2153 ;; If you want the cursor to go somewhere else, set these two
2154 ;; functions in some startup hook to whatever you want.
2155 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2156 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2158 ;;; Various macros and substs.
2160 (defun gnus-header-from (header)
2161 (mail-header-from header))
2163 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2164 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2165 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2166 (w (make-symbol "w"))
2167 (buf (make-symbol "buf")))
2168 `(let* ((,tempvar (selected-window))
2170 (,w (get-buffer-window ,buf 'visible)))
2175 (pop-to-buffer ,buf))
2177 (select-window ,tempvar)))))
2179 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2180 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2181 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2183 (defmacro gnus-gethash (string hashtable)
2184 "Get hash value of STRING in HASHTABLE."
2185 `(symbol-value (intern-soft ,string ,hashtable)))
2187 (defmacro gnus-sethash (string value hashtable)
2188 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2189 `(set (intern ,string ,hashtable) ,value))
2191 (defmacro gnus-intern-safe (string hashtable)
2192 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2193 `(let ((symbol (intern ,string ,hashtable)))
2198 (defmacro gnus-group-unread (group)
2199 "Get the currently computed number of unread articles in GROUP."
2200 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2202 (defmacro gnus-group-entry (group)
2203 "Get the newsrc entry for GROUP."
2204 `(gnus-gethash ,group gnus-newsrc-hashtb))
2206 (defmacro gnus-active (group)
2207 "Get active info on GROUP."
2208 `(gnus-gethash ,group gnus-active-hashtb))
2210 (defmacro gnus-set-active (group active)
2211 "Set GROUP's active info."
2212 `(gnus-sethash ,group ,active gnus-active-hashtb))
2214 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2215 ;; function `substring' might cut on a middle of multi-octet
2217 (defun gnus-truncate-string (str width)
2218 (substring str 0 width))
2220 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2221 ;; to limit the length of a string. This function is necessary since
2222 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2223 (defsubst gnus-limit-string (str width)
2224 (if (> (length str) width)
2225 (substring str 0 width)
2228 (defsubst gnus-simplify-subject-re (subject)
2229 "Remove \"Re:\" from subject lines."
2230 (if (string-match "^[Rr][Ee]: *" subject)
2231 (substring subject (match-end 0))
2234 (defsubst gnus-functionp (form)
2235 "Return non-nil if FORM is funcallable."
2236 (or (and (symbolp form) (fboundp form))
2237 (and (listp form) (eq (car form) 'lambda))))
2239 (defsubst gnus-goto-char (point)
2240 (and point (goto-char point)))
2242 (defmacro gnus-buffer-exists-p (buffer)
2243 `(let ((buffer ,buffer))
2245 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2248 (defmacro gnus-kill-buffer (buffer)
2249 `(let ((buf ,buffer))
2250 (if (gnus-buffer-exists-p buf)
2251 (kill-buffer buf))))
2253 (defsubst gnus-point-at-bol ()
2254 "Return point at the beginning of the line."
2261 (defsubst gnus-point-at-eol ()
2262 "Return point at the end of the line."
2269 (defun gnus-alive-p ()
2270 "Say whether Gnus is running or not."
2271 (and gnus-group-buffer
2272 (get-buffer gnus-group-buffer)))
2274 (defun gnus-delete-first (elt list)
2275 "Delete by side effect the first occurrence of ELT as a member of LIST."
2276 (if (equal (car list) elt)
2279 (while (and (cdr list)
2280 (not (equal (cadr list) elt)))
2281 (setq list (cdr list)))
2283 (setcdr list (cddr list)))
2286 ;; Delete the current line (and the next N lines.);
2287 (defmacro gnus-delete-line (&optional n)
2288 `(delete-region (progn (beginning-of-line) (point))
2289 (progn (forward-line ,(or n 1)) (point))))
2291 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2292 (defvar gnus-init-inhibit nil)
2293 (defun gnus-read-init-file (&optional inhibit-next)
2294 (if gnus-init-inhibit
2295 (setq gnus-init-inhibit nil)
2296 (setq gnus-init-inhibit inhibit-next)
2298 (or (and (file-exists-p gnus-init-file)
2299 ;; Don't try to load a directory.
2300 (not (file-directory-p gnus-init-file)))
2301 (file-exists-p (concat gnus-init-file ".el"))
2302 (file-exists-p (concat gnus-init-file ".elc")))
2304 (load gnus-init-file nil t)
2306 (error "Error in %s: %s" gnus-init-file var))))))
2308 ;; Info access macros.
2310 (defmacro gnus-info-group (info)
2312 (defmacro gnus-info-rank (info)
2314 (defmacro gnus-info-read (info)
2316 (defmacro gnus-info-marks (info)
2318 (defmacro gnus-info-method (info)
2320 (defmacro gnus-info-params (info)
2323 (defmacro gnus-info-level (info)
2324 `(let ((rank (gnus-info-rank ,info)))
2328 (defmacro gnus-info-score (info)
2329 `(let ((rank (gnus-info-rank ,info)))
2330 (or (and (consp rank) (cdr rank)) 0)))
2332 (defmacro gnus-info-set-group (info group)
2333 `(setcar ,info ,group))
2334 (defmacro gnus-info-set-rank (info rank)
2335 `(setcar (nthcdr 1 ,info) ,rank))
2336 (defmacro gnus-info-set-read (info read)
2337 `(setcar (nthcdr 2 ,info) ,read))
2338 (defmacro gnus-info-set-marks (info marks)
2339 `(setcar (nthcdr 3 ,info) ,marks))
2340 (defmacro gnus-info-set-method (info method)
2341 `(setcar (nthcdr 4 ,info) ,method))
2342 (defmacro gnus-info-set-params (info params)
2343 `(setcar (nthcdr 5 ,info) ,params))
2345 (defmacro gnus-info-set-level (info level)
2346 `(let ((rank (cdr ,info)))
2347 (if (consp (car rank))
2348 (setcar (car rank) ,level)
2349 (setcar rank ,level))))
2350 (defmacro gnus-info-set-score (info score)
2351 `(let ((rank (cdr ,info)))
2352 (if (consp (car rank))
2353 (setcdr (car rank) ,score)
2354 (setcar rank (cons (car rank) ,score)))))
2356 (defmacro gnus-get-info (group)
2357 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2359 (defun gnus-byte-code (func)
2360 "Return a form that can be `eval'ed based on FUNC."
2361 (let ((fval (symbol-function func)))
2362 (if (byte-code-function-p fval)
2363 (let ((flist (append fval nil)))
2364 (setcar flist 'byte-code)
2366 (cons 'progn (cddr fval)))))
2368 ;; Find out whether the gnus-visual TYPE is wanted.
2369 (defun gnus-visual-p (&optional type class)
2370 (and gnus-visual ; Has to be non-nil, at least.
2371 (if (not type) ; We don't care about type.
2373 (if (listp gnus-visual) ; It's a list, so we check it.
2374 (or (memq type gnus-visual)
2375 (memq class gnus-visual))
2378 ;;; Load the compatability functions.
2388 (defvar gnus-shutdown-alist nil)
2390 (defun gnus-add-shutdown (function &rest symbols)
2391 "Run FUNCTION whenever one of SYMBOLS is shut down."
2392 (push (cons function symbols) gnus-shutdown-alist))
2394 (defun gnus-shutdown (symbol)
2395 "Shut down everything that waits for SYMBOL."
2396 (let ((alist gnus-shutdown-alist)
2398 (while (setq entry (pop alist))
2399 (when (memq symbol (cdr entry))
2400 (funcall (car entry))))))
2404 ;; Format specs. The chunks below are the machine-generated forms
2405 ;; that are to be evaled as the result of the default format strings.
2406 ;; We write them in here to get them byte-compiled. That way the
2407 ;; default actions will be quite fast, while still retaining the full
2408 ;; flexibility of the user-defined format specs.
2410 ;; First we have lots of dummy defvars to let the compiler know these
2411 ;; are really dynamic variables.
2413 (defvar gnus-tmp-unread)
2414 (defvar gnus-tmp-replied)
2415 (defvar gnus-tmp-score-char)
2416 (defvar gnus-tmp-indentation)
2417 (defvar gnus-tmp-opening-bracket)
2418 (defvar gnus-tmp-lines)
2419 (defvar gnus-tmp-name)
2420 (defvar gnus-tmp-closing-bracket)
2421 (defvar gnus-tmp-subject-or-nil)
2422 (defvar gnus-tmp-subject)
2423 (defvar gnus-tmp-marked)
2424 (defvar gnus-tmp-marked-mark)
2425 (defvar gnus-tmp-subscribed)
2426 (defvar gnus-tmp-process-marked)
2427 (defvar gnus-tmp-number-of-unread)
2428 (defvar gnus-tmp-group-name)
2429 (defvar gnus-tmp-group)
2430 (defvar gnus-tmp-article-number)
2431 (defvar gnus-tmp-unread-and-unselected)
2432 (defvar gnus-tmp-news-method)
2433 (defvar gnus-tmp-news-server)
2434 (defvar gnus-tmp-article-number)
2435 (defvar gnus-mouse-face)
2436 (defvar gnus-mouse-face-prop)
2438 (defun gnus-summary-line-format-spec ()
2439 (insert gnus-tmp-unread gnus-tmp-replied
2440 gnus-tmp-score-char gnus-tmp-indentation)
2441 (gnus-put-text-property
2445 gnus-tmp-opening-bracket
2446 (format "%4d: %-20s"
2448 (if (> (length gnus-tmp-name) 20)
2449 (substring gnus-tmp-name 0 20)
2451 gnus-tmp-closing-bracket)
2453 gnus-mouse-face-prop gnus-mouse-face)
2454 (insert " " gnus-tmp-subject-or-nil "\n"))
2456 (defvar gnus-summary-line-format-spec
2457 (gnus-byte-code 'gnus-summary-line-format-spec))
2459 (defun gnus-summary-dummy-line-format-spec ()
2461 (gnus-put-text-property
2466 gnus-mouse-face-prop gnus-mouse-face)
2467 (insert " " gnus-tmp-subject "\n"))
2469 (defvar gnus-summary-dummy-line-format-spec
2470 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2472 (defun gnus-group-line-format-spec ()
2473 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2474 gnus-tmp-process-marked
2475 gnus-group-indentation
2476 (format "%5s: " gnus-tmp-number-of-unread))
2477 (gnus-put-text-property
2480 (insert gnus-tmp-group "\n")
2482 gnus-mouse-face-prop gnus-mouse-face))
2483 (defvar gnus-group-line-format-spec
2484 (gnus-byte-code 'gnus-group-line-format-spec))
2486 (defvar gnus-format-specs
2487 `((version . ,emacs-version)
2488 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2489 (summary-dummy ,gnus-summary-dummy-line-format
2490 ,gnus-summary-dummy-line-format-spec)
2491 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2493 (defvar gnus-article-mode-line-format-spec nil)
2494 (defvar gnus-summary-mode-line-format-spec nil)
2495 (defvar gnus-group-mode-line-format-spec nil)
2497 ;;; Phew. All that gruft is over, fortunately.
2501 ;;; Gnus Utility Functions
2504 (defun gnus-extract-address-components (from)
2506 ;; First find the address - the thing with the @ in it. This may
2507 ;; not be accurate in mail addresses, but does the trick most of
2508 ;; the time in news messages.
2509 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2510 (setq address (substring from (match-beginning 0) (match-end 0))))
2511 ;; Then we check whether the "name <address>" format is used.
2513 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2514 ;; Linear white space is not required.
2515 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2516 (and (setq name (substring from 0 (match-beginning 0)))
2517 ;; Strip any quotes from the name.
2518 (string-match "\".*\"" name)
2519 (setq name (substring name 1 (1- (match-end 0))))))
2520 ;; If not, then "address (name)" is used.
2522 (and (string-match "(.+)" from)
2523 (setq name (substring from (1+ (match-beginning 0))
2524 (1- (match-end 0)))))
2525 (and (string-match "()" from)
2526 (setq name address))
2527 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2528 ;; XOVER might not support folded From headers.
2529 (and (string-match "(.*" from)
2530 (setq name (substring from (1+ (match-beginning 0))
2532 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2533 (list (or name from) (or address from))))
2535 (defun gnus-fetch-field (field)
2536 "Return the value of the header FIELD of current article."
2539 (let ((case-fold-search t)
2540 (inhibit-point-motion-hooks t))
2541 (nnheader-narrow-to-headers)
2542 (message-fetch-field field)))))
2544 (defun gnus-goto-colon ()
2546 (search-forward ":" (gnus-point-at-eol) t))
2549 (defun gnus-update-format (var)
2550 "Update the format specification near point."
2555 ;; Find the end of the current word.
2556 (re-search-forward "[ \t\n]" nil t)
2558 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2559 (match-string 1)))))
2560 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2561 (match-string 1 var))))
2562 (entry (assq type gnus-format-specs))
2565 (setq gnus-format-specs (delq entry gnus-format-specs)))
2567 (intern (format "%s-spec" var))
2568 (gnus-parse-format (setq value (symbol-value (intern var)))
2569 (symbol-value (intern (format "%s-alist" var)))
2570 (not (string-match "mode" var))))
2571 (setq spec (symbol-value (intern (format "%s-spec" var))))
2572 (push (list type value spec) gnus-format-specs)
2574 (pop-to-buffer "*Gnus Format*")
2576 (lisp-interaction-mode)
2577 (insert (pp-to-string spec))))
2579 (defun gnus-update-format-specifications (&optional force)
2580 "Update all (necessary) format specifications."
2581 ;; Make the indentation array.
2582 (gnus-make-thread-indent-array)
2584 ;; See whether all the stored info needs to be flushed.
2586 (not (equal emacs-version
2587 (cdr (assq 'version gnus-format-specs)))))
2588 (setq gnus-format-specs nil))
2590 ;; Go through all the formats and see whether they need updating.
2591 (let ((types '(summary summary-dummy group
2592 summary-mode group-mode article-mode))
2593 new-format entry type val)
2594 (while (setq type (pop types))
2595 ;; Jump to the proper buffer to find out the value of
2596 ;; the variable, if possible. (It may be buffer-local.)
2598 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2600 (when (and (boundp buffer)
2601 (setq val (symbol-value buffer))
2603 (buffer-name (get-buffer val)))
2604 (set-buffer (get-buffer val)))
2605 (setq new-format (symbol-value
2606 (intern (format "gnus-%s-line-format" type))))))
2607 (setq entry (cdr (assq type gnus-format-specs)))
2609 (equal (car entry) new-format))
2610 ;; Use the old format.
2611 (set (intern (format "gnus-%s-line-format-spec" type))
2613 ;; This is a new format.
2615 (if (not (stringp new-format))
2616 ;; This is a function call or something.
2618 ;; This is a "real" format.
2622 (intern (format "gnus-%s-line-format-alist"
2623 (if (eq type 'article-mode)
2624 'summary-mode type))))
2625 (not (string-match "mode$" (symbol-name type))))))
2626 ;; Enter the new format spec into the list.
2629 (setcar (cdr entry) val)
2630 (setcar entry new-format))
2631 (push (list type new-format val) gnus-format-specs))
2632 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2634 (unless (assq 'version gnus-format-specs)
2635 (push (cons 'version emacs-version) gnus-format-specs))
2637 (gnus-update-group-mark-positions)
2638 (gnus-update-summary-mark-positions))
2640 (defun gnus-update-summary-mark-positions ()
2641 "Compute where the summary marks are to go."
2643 (when (and gnus-summary-buffer
2644 (get-buffer gnus-summary-buffer)
2645 (buffer-name (get-buffer gnus-summary-buffer)))
2646 (set-buffer gnus-summary-buffer))
2647 (let ((gnus-replied-mark 129)
2648 (gnus-score-below-mark 130)
2649 (gnus-score-over-mark 130)
2652 (spec gnus-summary-line-format-spec)
2655 (gnus-set-work-buffer)
2656 (let ((gnus-summary-line-format-spec spec))
2657 (gnus-summary-insert-line
2658 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2659 (goto-char (point-min))
2660 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2662 (goto-char (point-min))
2663 (push (cons 'replied (and (search-forward "\201" nil t)
2666 (goto-char (point-min))
2667 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2669 (setq gnus-summary-mark-positions pos))))
2671 (defun gnus-update-group-mark-positions ()
2673 (let ((gnus-process-mark 128)
2674 (gnus-group-marked '("dummy.group"))
2675 (gnus-active-hashtb (make-vector 10 0)))
2676 (gnus-set-active "dummy.group" '(0 . 0))
2677 (gnus-set-work-buffer)
2678 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2679 (goto-char (point-min))
2680 (setq gnus-group-mark-positions
2681 (list (cons 'process (and (search-forward "\200" nil t)
2682 (- (point) 2))))))))
2684 (defvar gnus-mouse-face-0 'highlight)
2685 (defvar gnus-mouse-face-1 'highlight)
2686 (defvar gnus-mouse-face-2 'highlight)
2687 (defvar gnus-mouse-face-3 'highlight)
2688 (defvar gnus-mouse-face-4 'highlight)
2690 (defun gnus-mouse-face-function (form type)
2691 `(gnus-put-text-property
2692 (point) (progn ,@form (point))
2693 gnus-mouse-face-prop
2696 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2698 (defvar gnus-face-0 'bold)
2699 (defvar gnus-face-1 'italic)
2700 (defvar gnus-face-2 'bold-italic)
2701 (defvar gnus-face-3 'bold)
2702 (defvar gnus-face-4 'bold)
2704 (defun gnus-face-face-function (form type)
2705 `(gnus-put-text-property
2706 (point) (progn ,@form (point))
2707 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2709 (defun gnus-max-width-function (el max-width)
2710 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2712 `(if (> (length ,el) ,max-width)
2713 (substring ,el 0 ,max-width)
2715 `(let ((val (eval ,el)))
2717 (setq val (int-to-string val)))
2718 (if (> (length val) ,max-width)
2719 (substring val 0 ,max-width)
2722 (defun gnus-parse-format (format spec-alist &optional insert)
2723 ;; This function parses the FORMAT string with the help of the
2724 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2725 ;; string. If the FORMAT string contains the specifiers %( and %)
2726 ;; the text between them will have the mouse-face text property.
2728 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2730 (gnus-parse-complex-format format spec-alist)
2731 ;; This is a simple format.
2732 (gnus-parse-simple-format format spec-alist insert)))
2734 (defun gnus-parse-complex-format (format spec-alist)
2736 (gnus-set-work-buffer)
2738 (goto-char (point-min))
2739 (while (re-search-forward "\"" nil t)
2740 (replace-match "\\\"" nil t))
2741 (goto-char (point-min))
2743 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2744 (let ((number (if (match-beginning 1)
2745 (match-string 1) "0"))
2746 (delim (aref (match-string 2) 0)))
2747 (if (or (= delim ?\() (= delim ?\{))
2748 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2750 (replace-match "\")\""))))
2751 (goto-char (point-max))
2753 (goto-char (point-min))
2754 (let ((form (read (current-buffer))))
2755 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2757 (defun gnus-complex-form-to-spec (form spec-alist)
2762 (gnus-parse-simple-format sform spec-alist t)
2763 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2764 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2768 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2769 ;; This function parses the FORMAT string with the help of the
2770 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2773 spec flist fstring newspec elem beg result dontinsert)
2775 (gnus-set-work-buffer)
2777 (goto-char (point-min))
2778 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2780 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2782 beg (1+ (match-beginning 0)))
2783 ;; First check if there are any specs that look anything like
2784 ;; "%12,12A", ie. with a "max width specification". These have
2785 ;; to be treated specially.
2786 (if (setq beg (match-beginning 1))
2790 (1+ (match-beginning 1)) (match-end 1))))
2792 (setq beg (match-beginning 2)))
2793 ;; Find the specification from `spec-alist'.
2794 (unless (setq elem (cdr (assq spec spec-alist)))
2795 (setq elem '("*" ?s)))
2796 ;; Treat user defined format specifiers specially.
2797 (when (eq (car elem) 'gnus-tmp-user-defined)
2800 (list (intern (concat "gnus-user-format-function-"
2802 'gnus-tmp-header) ?s))
2803 (delete-region (match-beginning 3) (match-end 3)))
2804 (if (not (zerop max-width))
2805 (let ((el (car elem)))
2806 (cond ((= (cadr elem) ?c)
2807 (setq el (list 'char-to-string el)))
2809 (setq el (list 'int-to-string el))))
2810 (setq flist (cons (gnus-max-width-function el max-width)
2814 (setq flist (cons (car elem) flist))
2815 (setq newspec (cadr elem)))))
2816 ;; Remove the old specification (and possibly a ",12" string).
2817 (delete-region beg (match-end 2))
2818 ;; Insert the new specification.
2821 (setq fstring (buffer-substring 1 (point-max))))
2822 ;; Do some postprocessing to increase efficiency.
2827 ((string= fstring "")
2829 ;; Not a format string.
2830 ((not (string-match "%" fstring))
2832 ;; A format string with just a single string spec.
2833 ((string= fstring "%s")
2835 ;; A single character.
2836 ((string= fstring "%c")
2839 ((string= fstring "%d")
2842 (list `(princ ,(car flist)))
2843 (list `(int-to-string ,(car flist)))))
2844 ;; Just lots of chars and strings.
2845 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2847 ;; A single string spec at the beginning of the spec.
2848 ((string-match "\\`%[sc][^%]+\\'" fstring)
2849 (list (car flist) (substring fstring 2)))
2850 ;; A single string spec in the middle of the spec.
2851 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2852 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2853 ;; A single string spec in the end of the spec.
2854 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2855 (list (match-string 1 fstring) (car flist)))
2856 ;; A more complex spec.
2858 (list (cons 'format (cons fstring (nreverse flist)))))))
2864 (cons 'insert result)))
2865 (cond ((stringp result)
2868 (cons 'concat result))
2871 (defun gnus-eval-format (format &optional alist props)
2872 "Eval the format variable FORMAT, using ALIST.
2873 If PROPS, insert the result."
2874 (let ((form (gnus-parse-format format alist props)))
2876 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2879 (defun gnus-remove-text-with-property (prop)
2880 "Delete all text in the current buffer with text property PROP."
2882 (goto-char (point-min))
2884 (while (get-text-property (point) prop)
2886 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2888 (defun gnus-set-work-buffer ()
2889 (if (get-buffer gnus-work-buffer)
2891 (set-buffer gnus-work-buffer)
2893 (set-buffer (get-buffer-create gnus-work-buffer))
2894 (kill-all-local-variables)
2895 (buffer-disable-undo (current-buffer))
2896 (gnus-add-current-to-buffer-list)))
2898 ;; Article file names when saving.
2900 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2901 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2902 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2903 Otherwise, it is like ~/News/news/group/num."
2906 (concat (if (gnus-use-long-file-name 'not-save)
2907 (gnus-capitalize-newsgroup newsgroup)
2908 (gnus-newsgroup-directory-form newsgroup))
2909 "/" (int-to-string (mail-header-number headers)))
2910 gnus-article-save-directory)))
2912 (string-equal (file-name-directory default)
2913 (file-name-directory last-file))
2914 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2916 (or last-file default))))
2918 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2919 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2920 If variable `gnus-use-long-file-name' is non-nil, it is
2921 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2924 (concat (if (gnus-use-long-file-name 'not-save)
2926 (gnus-newsgroup-directory-form newsgroup))
2927 "/" (int-to-string (mail-header-number headers)))
2928 gnus-article-save-directory)))
2930 (string-equal (file-name-directory default)
2931 (file-name-directory last-file))
2932 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2934 (or last-file default))))
2936 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2937 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2938 If variable `gnus-use-long-file-name' is non-nil, it is
2939 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2942 (if (gnus-use-long-file-name 'not-save)
2943 (gnus-capitalize-newsgroup newsgroup)
2944 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2945 gnus-article-save-directory)))
2947 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2948 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2949 If variable `gnus-use-long-file-name' is non-nil, it is
2950 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2953 (if (gnus-use-long-file-name 'not-save)
2955 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2956 gnus-article-save-directory)))
2958 ;; For subscribing new newsgroup
2960 (defun gnus-subscribe-hierarchical-interactive (groups)
2961 (let ((groups (sort groups 'string<))
2962 prefixes prefix start ans group starts)
2964 (setq prefixes (list "^"))
2965 (while (and groups prefixes)
2966 (while (not (string-match (car prefixes) (car groups)))
2967 (setq prefixes (cdr prefixes)))
2968 (setq prefix (car prefixes))
2969 (setq start (1- (length prefix)))
2970 (if (and (string-match "[^\\.]\\." (car groups) start)
2973 (concat "^" (substring (car groups) 0 (match-end 0))))
2974 (string-match prefix (cadr groups)))
2976 (setq prefixes (cons prefix prefixes))
2977 (message "Descend hierarchy %s? ([y]nsq): "
2978 (substring prefix 1 (1- (length prefix))))
2979 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2981 (message "Descend hierarchy %s? ([y]nsq): "
2982 (substring prefix 1 (1- (length prefix)))))
2985 (string-match prefix
2986 (setq group (car groups))))
2987 (setq gnus-killed-list
2988 (cons group gnus-killed-list))
2989 (gnus-sethash group group gnus-killed-hashtb)
2990 (setq groups (cdr groups)))
2991 (setq starts (cdr starts)))
2994 (string-match prefix
2995 (setq group (car groups))))
2996 (gnus-sethash group group gnus-killed-hashtb)
2997 (gnus-subscribe-alphabetically (car groups))
2998 (setq groups (cdr groups)))
2999 (setq starts (cdr starts)))
3002 (setq group (car groups))
3003 (setq gnus-killed-list (cons group gnus-killed-list))
3004 (gnus-sethash group group gnus-killed-hashtb)
3005 (setq groups (cdr groups))))
3007 (message "Subscribe %s? ([n]yq)" (car groups))
3008 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
3010 (message "Subscribe %s? ([n]yq)" (car groups)))
3011 (setq group (car groups))
3013 (gnus-subscribe-alphabetically (car groups))
3014 (gnus-sethash group group gnus-killed-hashtb))
3017 (setq group (car groups))
3018 (setq gnus-killed-list (cons group gnus-killed-list))
3019 (gnus-sethash group group gnus-killed-hashtb)
3020 (setq groups (cdr groups))))
3022 (setq gnus-killed-list (cons group gnus-killed-list))
3023 (gnus-sethash group group gnus-killed-hashtb)))
3024 (setq groups (cdr groups)))))))
3026 (defun gnus-subscribe-randomly (newsgroup)
3027 "Subscribe new NEWSGROUP by making it the first newsgroup."
3028 (gnus-subscribe-newsgroup newsgroup))
3030 (defun gnus-subscribe-alphabetically (newgroup)
3031 "Subscribe new NEWSGROUP and insert it in alphabetical order."
3032 (let ((groups (cdr gnus-newsrc-alist))
3034 (while (and (not before) groups)
3035 (if (string< newgroup (caar groups))
3036 (setq before (caar groups))
3037 (setq groups (cdr groups))))
3038 (gnus-subscribe-newsgroup newgroup before)))
3040 (defun gnus-subscribe-hierarchically (newgroup)
3041 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
3042 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
3044 (set-buffer (find-file-noselect gnus-current-startup-file))
3045 (let ((groupkey newgroup)
3047 (while (and (not before) groupkey)
3048 (goto-char (point-min))
3050 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3051 (while (and (re-search-forward groupkey-re nil t)
3053 (setq before (match-string 1))
3054 (string< before newgroup)))))
3055 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3057 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3058 (substring groupkey (match-beginning 1) (match-end 1)))))
3059 (gnus-subscribe-newsgroup newgroup before))
3060 (kill-buffer (current-buffer))))
3062 (defun gnus-subscribe-interactively (group)
3063 "Subscribe the new GROUP interactively.
3064 It is inserted in hierarchical newsgroup order if subscribed. If not,
3066 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3067 (gnus-subscribe-hierarchically group)
3068 (push group gnus-killed-list)))
3070 (defun gnus-subscribe-zombies (group)
3071 "Make the new GROUP into a zombie group."
3072 (push group gnus-zombie-list))
3074 (defun gnus-subscribe-killed (group)
3075 "Make the new GROUP a killed group."
3076 (push group gnus-killed-list))
3078 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3079 "Subscribe new NEWSGROUP.
3080 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3081 the first newsgroup."
3082 ;; We subscribe the group by changing its level to `subscribed'.
3083 (gnus-group-change-level
3084 newsgroup gnus-level-default-subscribed
3085 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3086 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3090 (defun gnus-newsgroup-directory-form (newsgroup)
3091 "Make hierarchical directory name from NEWSGROUP name."
3092 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3093 (len (length newsgroup))
3095 ;; If this is a foreign group, we don't want to translate the
3097 (if (setq idx (string-match ":" newsgroup))
3098 (aset newsgroup idx ?/)
3100 ;; Replace all occurrences of `.' with `/'.
3102 (if (= (aref newsgroup idx) ?.)
3103 (aset newsgroup idx ?/))
3104 (setq idx (1+ idx)))
3107 (defun gnus-newsgroup-savable-name (group)
3108 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3110 (nnheader-replace-chars-in-string group ?/ ?.))
3112 (defun gnus-make-directory (dir)
3113 "Make DIRECTORY recursively."
3114 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3115 ;; of the many mysteries of the universe.
3116 (let* ((dir (expand-file-name dir default-directory))
3118 (if (string-match "/$" dir)
3119 (setq dir (substring dir 0 (match-beginning 0))))
3120 ;; First go down the path until we find a directory that exists.
3121 (while (not (file-exists-p dir))
3122 (setq dirs (cons dir dirs))
3123 (string-match "/[^/]+$" dir)
3124 (setq dir (substring dir 0 (match-beginning 0))))
3125 ;; Then create all the subdirs.
3126 (while (and dirs (not err))
3128 (make-directory (car dirs))
3129 (error (setq err t)))
3130 (setq dirs (cdr dirs)))
3131 ;; We return whether we were successful or not.
3134 (defun gnus-capitalize-newsgroup (newsgroup)
3135 "Capitalize NEWSGROUP name."
3136 (and (not (zerop (length newsgroup)))
3137 (concat (char-to-string (upcase (aref newsgroup 0)))
3138 (substring newsgroup 1))))
3140 ;; Various... things.
3142 (defun gnus-simplify-subject (subject &optional re-only)
3143 "Remove `Re:' and words in parentheses.
3144 If RE-ONLY is non-nil, strip leading `Re:'s only."
3145 (let ((case-fold-search t)) ;Ignore case.
3146 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3147 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3148 (setq subject (substring subject (match-end 0))))
3149 ;; Remove uninteresting prefixes.
3150 (if (and (not re-only)
3151 gnus-simplify-ignored-prefixes
3152 (string-match gnus-simplify-ignored-prefixes subject))
3153 (setq subject (substring subject (match-end 0))))
3154 ;; Remove words in parentheses from end.
3156 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3157 (setq subject (substring subject 0 (match-beginning 0)))))
3158 ;; Return subject string.
3161 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3163 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3164 (defun gnus-simplify-buffer-fuzzy ()
3165 (let ((case-fold-search t))
3166 (goto-char (point-min))
3167 (while (search-forward "\t" nil t)
3168 (replace-match " " t t))
3169 (goto-char (point-min))
3170 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3171 (goto-char (match-beginning 0))
3173 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3174 (looking-at "^[[].*: .*[]]$"))
3175 (goto-char (point-min))
3176 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3178 (replace-match "" t t))
3179 (goto-char (point-min))
3180 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3181 (goto-char (match-end 0))
3184 (progn (goto-char (match-beginning 0)))
3185 (re-search-forward ":"))))
3186 (goto-char (point-min))
3187 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3188 (replace-match "" t t))
3189 (goto-char (point-min))
3190 (while (re-search-forward " +" nil t)
3191 (replace-match " " t t))
3192 (goto-char (point-min))
3193 (while (re-search-forward " $" nil t)
3194 (replace-match "" t t))
3195 (goto-char (point-min))
3196 (while (re-search-forward "^ +" nil t)
3197 (replace-match "" t t))
3198 (goto-char (point-min))
3199 (when gnus-simplify-subject-fuzzy-regexp
3200 (if (listp gnus-simplify-subject-fuzzy-regexp)
3201 (let ((list gnus-simplify-subject-fuzzy-regexp))
3203 (goto-char (point-min))
3204 (while (re-search-forward (car list) nil t)
3205 (replace-match "" t t))
3206 (setq list (cdr list))))
3207 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3208 (replace-match "" t t))))))
3210 (defun gnus-simplify-subject-fuzzy (subject)
3211 "Siplify a subject string fuzzily."
3213 (gnus-set-work-buffer)
3214 (let ((case-fold-search t))
3216 (inline (gnus-simplify-buffer-fuzzy))
3219 ;; Add the current buffer to the list of buffers to be killed on exit.
3220 (defun gnus-add-current-to-buffer-list ()
3221 (or (memq (current-buffer) gnus-buffer-list)
3222 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3224 (defun gnus-string> (s1 s2)
3225 (not (or (string< s1 s2)
3228 (defun gnus-read-active-file-p ()
3229 "Say whether the active file has been read from `gnus-select-method'."
3230 (memq gnus-select-method gnus-have-read-active-file))
3232 ;;; General various misc type functions.
3234 (defun gnus-clear-system ()
3235 "Clear all variables and buffers."
3236 ;; Clear Gnus variables.
3237 (let ((variables gnus-variable-list))
3239 (set (car variables) nil)
3240 (setq variables (cdr variables))))
3241 ;; Clear other internal variables.
3242 (setq gnus-list-of-killed-groups nil
3243 gnus-have-read-active-file nil
3244 gnus-newsrc-alist nil
3245 gnus-newsrc-hashtb nil
3246 gnus-killed-list nil
3247 gnus-zombie-list nil
3248 gnus-killed-hashtb nil
3249 gnus-active-hashtb nil
3250 gnus-moderated-list nil
3251 gnus-description-hashtb nil
3252 gnus-current-headers nil
3253 gnus-thread-indent-array nil
3254 gnus-newsgroup-headers nil
3255 gnus-newsgroup-name nil
3256 gnus-server-alist nil
3257 gnus-group-list-mode nil
3258 gnus-opened-servers nil
3259 gnus-group-mark-positions nil
3260 gnus-newsgroup-data nil
3261 gnus-newsgroup-unreads nil
3262 nnoo-state-alist nil
3263 gnus-current-select-method nil)
3264 (gnus-shutdown 'gnus)
3265 ;; Kill the startup file.
3266 (and gnus-current-startup-file
3267 (get-file-buffer gnus-current-startup-file)
3268 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3269 ;; Clear the dribble buffer.
3270 (gnus-dribble-clear)
3271 ;; Kill global KILL file buffer.
3272 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3273 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3274 (gnus-kill-buffer nntp-server-buffer)
3275 ;; Kill Gnus buffers.
3276 (while gnus-buffer-list
3277 (gnus-kill-buffer (pop gnus-buffer-list)))
3278 ;; Remove Gnus frames.
3279 (gnus-kill-gnus-frames))
3281 (defun gnus-kill-gnus-frames ()
3282 "Kill all frames Gnus has created."
3283 (while gnus-created-frames
3284 (when (frame-live-p (car gnus-created-frames))
3285 ;; We slap a condition-case around this `delete-frame' to ensure
3286 ;; against errors if we try do delete the single frame that's left.
3288 (delete-frame (car gnus-created-frames))
3290 (pop gnus-created-frames)))
3292 (defun gnus-windows-old-to-new (setting)
3293 ;; First we take care of the really, really old Gnus 3 actions.
3294 (when (symbolp setting)
3296 ;; Take care of ooold GNUS 3.x values.
3297 (cond ((eq setting 'SelectArticle) 'article)
3298 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3299 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3301 (if (or (listp setting)
3302 (not (and gnus-window-configuration
3303 (memq setting '(group summary article)))))
3305 (let* ((setting (if (eq setting 'group)
3306 (if (assq 'newsgroup gnus-window-configuration)
3308 'newsgroups) setting))
3309 (elem (cadr (assq setting gnus-window-configuration)))
3310 (total (apply '+ elem))
3311 (types '(group summary article))
3312 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3317 (or (not (numberp (nth i elem)))
3318 (zerop (nth i elem))
3320 (setq perc (if (= i 2)
3322 (/ (float (nth 0 elem)) total)))
3323 (setq out (cons (if (eq pbuf (nth i types))
3324 (list (nth i types) perc 'point)
3325 (list (nth i types) perc))
3328 `(vertical 1.0 ,@(nreverse out)))))
3331 (defun gnus-add-configuration (conf)
3332 "Add the window configuration CONF to `gnus-buffer-configuration'."
3333 (setq gnus-buffer-configuration
3334 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3335 gnus-buffer-configuration))))
3337 (defvar gnus-frame-list nil)
3339 (defun gnus-configure-frame (split &optional window)
3340 "Split WINDOW according to SPLIT."
3342 (setq window (get-buffer-window (current-buffer))))
3343 (select-window window)
3344 ;; This might be an old-stylee buffer config.
3345 (when (vectorp split)
3346 (setq split (append split nil)))
3347 (when (or (consp (car split))
3348 (vectorp (car split)))
3350 (push 'vertical split))
3351 ;; The SPLIT might be something that is to be evaled to
3352 ;; return a new SPLIT.
3353 (while (and (not (assq (car split) gnus-window-to-buffer))
3354 (gnus-functionp (car split)))
3355 (setq split (eval split)))
3356 (let* ((type (car split))
3358 (len (if (eq type 'horizontal) (window-width) (window-height)))
3360 (window-min-width (or gnus-window-min-width window-min-width))
3361 (window-min-height (or gnus-window-min-height window-min-height))
3362 s result new-win rest comp-subs size sub)
3364 ;; Nothing to do here.
3366 ;; Don't switch buffers.
3368 (and (memq 'point split) window))
3369 ;; This is a buffer to be selected.
3370 ((not (memq type '(frame horizontal vertical)))
3371 (let ((buffer (cond ((stringp type) type)
3372 (t (cdr (assq type gnus-window-to-buffer)))))
3375 (error "Illegal buffer type: %s" type))
3376 (unless (setq buf (get-buffer (if (symbolp buffer)
3377 (symbol-value buffer) buffer)))
3378 (setq buf (get-buffer-create (if (symbolp buffer)
3379 (symbol-value buffer) buffer))))
3380 (switch-to-buffer buf)
3381 ;; We return the window if it has the `point' spec.
3382 (and (memq 'point split) window)))
3383 ;; This is a frame split.
3385 (unless gnus-frame-list
3386 (setq gnus-frame-list (list (window-frame
3387 (get-buffer-window (current-buffer))))))
3389 params frame fresult)
3390 (while (< i (length subs))
3391 ;; Frame parameter is gotten from the sub-split.
3392 (setq params (cadr (elt subs i)))
3393 ;; It should be a list.
3394 (unless (listp params)
3396 ;; Create a new frame?
3397 (unless (setq frame (elt gnus-frame-list i))
3398 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3399 (push frame gnus-created-frames))
3400 ;; Is the old frame still alive?
3401 (unless (frame-live-p frame)
3402 (setcar (nthcdr i gnus-frame-list)
3403 (setq frame (make-frame params))))
3404 ;; Select the frame in question and do more splits there.
3405 (select-frame frame)
3406 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3408 ;; Select the frame that has the selected buffer.
3410 (select-frame (window-frame fresult)))))
3411 ;; This is a normal split.
3413 (when (> (length subs) 0)
3414 ;; First we have to compute the sizes of all new windows.
3416 (setq sub (append (pop subs) nil))
3417 (while (and (not (assq (car sub) gnus-window-to-buffer))
3418 (gnus-functionp (car sub)))
3419 (setq sub (eval sub)))
3421 (push sub comp-subs)
3422 (setq size (cadar comp-subs))
3423 (cond ((equal size 1.0)
3424 (setq rest (car comp-subs))
3427 (setq s (floor (* size len))))
3431 (error "Illegal size: %s" size)))
3432 ;; Try to make sure that we are inside the safe limits.
3434 ((eq type 'horizontal)
3435 (setq s (max s window-min-width)))
3436 ((eq type 'vertical)
3437 (setq s (max s window-min-height))))
3438 (setcar (cdar comp-subs) s)
3440 ;; Take care of the "1.0" spec.
3442 (setcar (cdr rest) (- len total))
3443 (error "No 1.0 specs in %s" split))
3444 ;; The we do the actual splitting in a nice recursive
3446 (setq comp-subs (nreverse comp-subs))
3448 (if (null (cdr comp-subs))
3449 (setq new-win window)
3451 (split-window window (cadar comp-subs)
3452 (eq type 'horizontal))))
3453 (setq result (or (gnus-configure-frame
3454 (car comp-subs) window) result))
3455 (select-window new-win)
3456 (setq window new-win)
3457 (setq comp-subs (cdr comp-subs))))
3458 ;; Return the proper window, if any.
3460 (select-window result))))))
3462 (defvar gnus-frame-split-p nil)
3464 (defun gnus-configure-windows (setting &optional force)
3465 (setq setting (gnus-windows-old-to-new setting))
3466 (let ((split (if (symbolp setting)
3467 (cadr (assq setting gnus-buffer-configuration))
3471 (setq gnus-frame-split-p nil)
3474 (error "No such setting: %s" setting))
3476 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3478 ;; All the windows mentioned are already visible, so we just
3479 ;; put point in the assigned buffer, and do not touch the
3481 (select-window all-visible)
3483 ;; Either remove all windows or just remove all Gnus windows.
3484 (let ((frame (selected-frame)))
3486 (if gnus-use-full-window
3487 ;; We want to remove all other windows.
3488 (if (not gnus-frame-split-p)
3489 ;; This is not a `frame' split, so we ignore the
3491 (delete-other-windows)
3492 ;; This is a `frame' split, so we delete all windows
3496 (unless (eq (cdr (assq 'minibuffer
3497 (frame-parameters frame)))
3499 (select-frame frame)
3500 (delete-other-windows)))
3502 ;; Just remove some windows.
3503 (gnus-remove-some-windows)
3504 (switch-to-buffer nntp-server-buffer))
3505 (select-frame frame)))
3507 (switch-to-buffer nntp-server-buffer)
3508 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3510 (defun gnus-all-windows-visible-p (split)
3511 "Say whether all buffers in SPLIT are currently visible.
3512 In particular, the value returned will be the window that
3514 (let ((stack (list split))
3516 type buffer win buf)
3517 (while (and (setq split (pop stack))
3519 ;; Be backwards compatible.
3520 (when (vectorp split)
3521 (setq split (append split nil)))
3522 (when (or (consp (car split))
3523 (vectorp (car split)))
3525 (push 'vertical split))
3526 ;; The SPLIT might be something that is to be evaled to
3527 ;; return a new SPLIT.
3528 (while (and (not (assq (car split) gnus-window-to-buffer))
3529 (gnus-functionp (car split)))
3530 (setq split (eval split)))
3532 (setq type (elt split 0))
3537 ((not (memq type '(horizontal vertical frame)))
3538 (setq buffer (cond ((stringp type) type)
3539 (t (cdr (assq type gnus-window-to-buffer)))))
3541 (error "Illegal buffer type: %s" type))
3542 (when (setq buf (get-buffer (if (symbolp buffer)
3543 (symbol-value buffer)
3545 (setq win (get-buffer-window buf t)))
3547 (when (memq 'point split)
3548 (setq all-visible win))
3549 (setq all-visible nil)))
3551 (when (eq type 'frame)
3552 (setq gnus-frame-split-p t))
3553 (setq stack (append (cddr split) stack)))))
3554 (unless (eq all-visible t)
3557 (defun gnus-window-top-edge (&optional window)
3558 (nth 1 (window-edges window)))
3560 (defun gnus-remove-some-windows ()
3561 (let ((buffers gnus-window-to-buffer)
3562 buf bufs lowest-buf lowest)
3564 ;; Remove windows on all known Gnus buffers.
3566 (setq buf (cdar buffers))
3568 (setq buf (and (boundp buf) (symbol-value buf))))
3570 (get-buffer-window buf)
3572 (setq bufs (cons buf bufs))
3574 (if (or (not lowest)
3575 (< (gnus-window-top-edge) lowest))
3577 (setq lowest (gnus-window-top-edge))
3578 (setq lowest-buf buf)))))
3579 (setq buffers (cdr buffers)))
3580 ;; Remove windows on *all* summary buffers.
3583 (let ((buf (window-buffer win)))
3584 (if (string-match "^\\*Summary" (buffer-name buf))
3586 (setq bufs (cons buf bufs))
3588 (if (or (not lowest)
3589 (< (gnus-window-top-edge) lowest))
3591 (setq lowest-buf buf)
3592 (setq lowest (gnus-window-top-edge)))))))))
3595 (pop-to-buffer lowest-buf)
3596 (switch-to-buffer nntp-server-buffer)))
3598 (and (not (eq (car bufs) lowest-buf))
3599 (delete-windows-on (car bufs)))
3600 (setq bufs (cdr bufs))))))
3602 (defun gnus-version (&optional arg)
3603 "Version number of this version of Gnus.
3604 If ARG, insert string at point."
3606 (let ((methods gnus-valid-select-methods)
3609 ;; Go through all the legal select methods and add their version
3610 ;; numbers to the total version string. Only the backends that are
3611 ;; currently in use will have their message numbers taken into
3614 (setq meth (intern (concat (caar methods) "-version")))
3616 (stringp (symbol-value meth))
3617 (setq mess (concat mess "; " (symbol-value meth))))
3618 (setq methods (cdr methods)))
3620 (insert (message mess))
3623 (defun gnus-info-find-node ()
3624 "Find Info documentation of Gnus."
3626 ;; Enlarge info window if needed.
3627 (let ((mode major-mode)
3629 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3630 (setq gnus-info-buffer (current-buffer))
3631 (gnus-configure-windows 'info)))
3633 (defun gnus-days-between (date1 date2)
3634 ;; Return the number of days between date1 and date2.
3635 (- (gnus-day-number date1) (gnus-day-number date2)))
3637 (defun gnus-day-number (date)
3638 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3639 (timezone-parse-date date))))
3640 (timezone-absolute-from-gregorian
3641 (nth 1 dat) (nth 2 dat) (car dat))))
3643 (defun gnus-encode-date (date)
3644 "Convert DATE to internal time."
3645 (let* ((parse (timezone-parse-date date))
3646 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3647 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3648 (encode-time (caddr time) (cadr time) (car time)
3649 (caddr date) (cadr date) (car date) (nth 4 date))))
3651 (defun gnus-time-minus (t1 t2)
3652 "Subtract two internal times."
3653 (let ((borrow (< (cadr t1) (cadr t2))))
3654 (list (- (car t1) (car t2) (if borrow 1 0))
3655 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3657 (defun gnus-file-newer-than (file date)
3658 (let ((fdate (nth 5 (file-attributes file))))
3659 (or (> (car fdate) (car date))
3660 (and (= (car fdate) (car date))
3661 (> (nth 1 fdate) (nth 1 date))))))
3663 (defmacro gnus-local-set-keys (&rest plist)
3664 "Set the keys in PLIST in the current keymap."
3665 `(gnus-define-keys-1 (current-local-map) ',plist))
3667 (defmacro gnus-define-keys (keymap &rest plist)
3668 "Define all keys in PLIST in KEYMAP."
3669 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3671 (put 'gnus-define-keys 'lisp-indent-function 1)
3672 (put 'gnus-define-keys 'lisp-indent-hook 1)
3673 (put 'gnus-define-keymap 'lisp-indent-function 1)
3674 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3676 (defmacro gnus-define-keymap (keymap &rest plist)
3677 "Define all keys in PLIST in KEYMAP."
3678 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3680 (defun gnus-define-keys-1 (keymap plist)
3682 (error "Can't set keys in a null keymap"))
3683 (cond ((symbolp keymap)
3684 (setq keymap (symbol-value keymap)))
3687 (set (car keymap) nil)
3688 (define-prefix-command (car keymap))
3689 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3690 (setq keymap (symbol-value (car keymap)))))
3693 (when (symbolp (setq key (pop plist)))
3694 (setq key (symbol-value key)))
3695 (define-key keymap key (pop plist)))))
3697 (defun gnus-group-read-only-p (&optional group)
3698 "Check whether GROUP supports editing or not.
3699 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3700 that that variable is buffer-local to the summary buffers."
3701 (let ((group (or group gnus-newsgroup-name)))
3702 (not (gnus-check-backend-function 'request-replace-article group))))
3704 (defun gnus-group-total-expirable-p (group)
3705 "Check whether GROUP is total-expirable or not."
3706 (let ((params (gnus-info-params (gnus-get-info group))))
3707 (or (memq 'total-expire params)
3708 (cdr (assq 'total-expire params)) ; (total-expire . t)
3709 (and gnus-total-expirable-newsgroups ; Check var.
3710 (string-match gnus-total-expirable-newsgroups group)))))
3712 (defun gnus-group-auto-expirable-p (group)
3713 "Check whether GROUP is total-expirable or not."
3714 (let ((params (gnus-info-params (gnus-get-info group))))
3715 (or (memq 'auto-expire params)
3716 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3717 (and gnus-auto-expirable-newsgroups ; Check var.
3718 (string-match gnus-auto-expirable-newsgroups group)))))
3720 (defun gnus-virtual-group-p (group)
3721 "Say whether GROUP is virtual or not."
3722 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3723 gnus-valid-select-methods)))
3725 (defun gnus-news-group-p (group &optional article)
3726 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3727 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3728 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3729 (eq (gnus-request-type group article) 'news))))
3731 (defsubst gnus-simplify-subject-fully (subject)
3732 "Simplify a subject string according to the user's wishes."
3734 ((null gnus-summary-gather-subject-limit)
3735 (gnus-simplify-subject-re subject))
3736 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3737 (gnus-simplify-subject-fuzzy subject))
3738 ((numberp gnus-summary-gather-subject-limit)
3739 (gnus-limit-string (gnus-simplify-subject-re subject)
3740 gnus-summary-gather-subject-limit))
3744 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3745 "Check whether two subjects are equal. If optional argument
3746 simple-first is t, first argument is already simplified."
3748 ((null simple-first)
3749 (equal (gnus-simplify-subject-fully s1)
3750 (gnus-simplify-subject-fully s2)))
3753 (gnus-simplify-subject-fully s2)))))
3755 ;; Returns a list of writable groups.
3756 (defun gnus-writable-groups ()
3757 (let ((alist gnus-newsrc-alist)
3759 (while (setq group (car (pop alist)))
3760 (unless (gnus-group-read-only-p group)
3761 (push group groups)))
3764 (defun gnus-completing-read (default prompt &rest args)
3765 ;; Like `completing-read', except that DEFAULT is the default argument.
3766 (let* ((prompt (if default
3767 (concat prompt " (default " default ") ")
3768 (concat prompt " ")))
3769 (answer (apply 'completing-read prompt args)))
3770 (if (or (null answer) (zerop (length answer)))
3774 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3776 (defun gnus-y-or-n-p (prompt)
3781 (defun gnus-yes-or-no-p (prompt)
3783 (yes-or-no-p prompt)
3786 ;; Check whether to use long file names.
3787 (defun gnus-use-long-file-name (symbol)
3788 ;; The variable has to be set...
3789 (and gnus-use-long-file-name
3790 ;; If it isn't a list, then we return t.
3791 (or (not (listp gnus-use-long-file-name))
3792 ;; If it is a list, and the list contains `symbol', we
3794 (not (memq symbol gnus-use-long-file-name)))))
3796 ;; I suspect there's a better way, but I haven't taken the time to do
3797 ;; it yet. -erik selberg@cs.washington.edu
3798 (defun gnus-dd-mmm (messy-date)
3799 "Return a string like DD-MMM from a big messy string"
3800 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3806 ;; Make sure leading zeroes are stripped.
3807 (number-to-string (string-to-number (aref datevec 2)))
3811 (nth (1- (string-to-number (aref datevec 1)))
3812 timezone-months-assoc))
3815 (defun gnus-mode-string-quote (string)
3816 "Quote all \"%\" in STRING."
3818 (gnus-set-work-buffer)
3820 (goto-char (point-min))
3821 (while (search-forward "%" nil t)
3825 ;; Make a hash table (default and minimum size is 255).
3826 ;; Optional argument HASHSIZE specifies the table size.
3827 (defun gnus-make-hashtable (&optional hashsize)
3828 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3830 ;; Make a number that is suitable for hashing; bigger than MIN and one
3832 (defun gnus-create-hash-size (min)
3838 ;; Show message if message has a lower level than `gnus-verbose'.
3839 ;; Guideline for numbers:
3840 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3841 ;; for things that take a long time, 7 - not very important messages
3842 ;; on stuff, 9 - messages inside loops.
3843 (defun gnus-message (level &rest args)
3844 (if (<= level gnus-verbose)
3845 (apply 'message args)
3846 ;; We have to do this format thingy here even if the result isn't
3847 ;; shown - the return value has to be the same as the return value
3849 (apply 'format args)))
3851 (defun gnus-error (level &rest args)
3852 "Beep an error if LEVEL is equal to or less than `gnus-verbose'."
3853 (when (<= (floor level) gnus-verbose)
3854 (apply 'message args)
3857 (when (and (floatp level)
3858 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3859 (sit-for duration))))
3862 ;; Generate a unique new group name.
3863 (defun gnus-generate-new-group-name (leaf)
3866 (while (gnus-gethash name gnus-newsrc-hashtb)
3867 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3870 (defsubst gnus-hide-text (b e props)
3871 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3872 (gnus-add-text-properties b e props)
3873 (when (memq 'intangible props)
3874 (gnus-put-text-property (max (1- b) (point-min))
3875 b 'intangible (cddr (memq 'intangible props)))))
3877 (defsubst gnus-unhide-text (b e)
3878 "Remove hidden text properties from region between B and E."
3879 (remove-text-properties b e gnus-hidden-properties)
3880 (when (memq 'intangible gnus-hidden-properties)
3881 (gnus-put-text-property (max (1- b) (point-min))
3882 b 'intangible nil)))
3884 (defun gnus-hide-text-type (b e type)
3885 "Hide text of TYPE between B and E."
3886 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3888 (defun gnus-parent-headers (headers &optional generation)
3889 "Return the headers of the GENERATIONeth parent of HEADERS."
3891 (setq generation 1))
3892 (let (references parent)
3893 (while (and headers (not (zerop generation)))
3894 (setq references (mail-header-references headers))
3895 (when (and references
3896 (setq parent (gnus-parent-id references))
3897 (setq headers (car (gnus-id-to-thread parent))))
3901 (defun gnus-parent-id (references)
3902 "Return the last Message-ID in REFERENCES."
3903 (when (and references
3904 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3905 (substring references (match-beginning 1) (match-end 1))))
3907 (defun gnus-split-references (references)
3908 "Return a list of Message-IDs in REFERENCES."
3911 (while (string-match "<[^>]+>" references beg)
3912 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3916 (defun gnus-buffer-live-p (buffer)
3917 "Say whether BUFFER is alive or not."
3920 (buffer-name (get-buffer buffer))))
3922 (defun gnus-ephemeral-group-p (group)
3923 "Say whether GROUP is ephemeral or not."
3924 (gnus-group-get-parameter group 'quit-config))
3926 (defun gnus-group-quit-config (group)
3927 "Return the quit-config of GROUP."
3928 (gnus-group-get-parameter group 'quit-config))
3930 (defun gnus-simplify-mode-line ()
3931 "Make mode lines a bit simpler."
3932 (setq mode-line-modified "-- ")
3933 (when (listp mode-line-format)
3934 (make-local-variable 'mode-line-format)
3935 (setq mode-line-format (copy-sequence mode-line-format))
3936 (when (equal (nth 3 mode-line-format) " ")
3937 (setcar (nthcdr 3 mode-line-format) " "))))
3939 ;;; List and range functions
3941 (defun gnus-last-element (list)
3942 "Return last element of LIST."
3944 (setq list (cdr list)))
3947 (defun gnus-copy-sequence (list)
3948 "Do a complete, total copy of a list."
3949 (if (and (consp list) (not (consp (cdr list))))
3950 (cons (car list) (cdr list))
3951 (mapcar (lambda (elem) (if (consp elem)
3952 (if (consp (cdr elem))
3953 (gnus-copy-sequence elem)
3954 (cons (car elem) (cdr elem)))
3958 (defun gnus-set-difference (list1 list2)
3959 "Return a list of elements of LIST1 that do not appear in LIST2."
3960 (let ((list1 (copy-sequence list1)))
3962 (setq list1 (delq (car list2) list1))
3963 (setq list2 (cdr list2)))
3966 (defun gnus-sorted-complement (list1 list2)
3967 "Return a list of elements of LIST1 that do not appear in LIST2.
3968 Both lists have to be sorted over <."
3970 (if (or (null list1) (null list2))
3972 (while (and list1 list2)
3973 (cond ((= (car list1) (car list2))
3974 (setq list1 (cdr list1)
3976 ((< (car list1) (car list2))
3977 (setq out (cons (car list1) out))
3978 (setq list1 (cdr list1)))
3980 (setq out (cons (car list2) out))
3981 (setq list2 (cdr list2)))))
3982 (nconc (nreverse out) (or list1 list2)))))
3984 (defun gnus-intersection (list1 list2)
3987 (if (memq (car list2) list1)
3988 (setq result (cons (car list2) result)))
3989 (setq list2 (cdr list2)))
3992 (defun gnus-sorted-intersection (list1 list2)
3993 ;; LIST1 and LIST2 have to be sorted over <.
3995 (while (and list1 list2)
3996 (cond ((= (car list1) (car list2))
3997 (setq out (cons (car list1) out)
4000 ((< (car list1) (car list2))
4001 (setq list1 (cdr list1)))
4003 (setq list2 (cdr list2)))))
4006 (defun gnus-set-sorted-intersection (list1 list2)
4007 ;; LIST1 and LIST2 have to be sorted over <.
4008 ;; This function modifies LIST1.
4009 (let* ((top (cons nil list1))
4011 (while (and list1 list2)
4012 (cond ((= (car list1) (car list2))
4016 ((< (car list1) (car list2))
4017 (setcdr prev (cdr list1))
4018 (setq list1 (cdr list1)))
4020 (setq list2 (cdr list2)))))
4024 (defun gnus-compress-sequence (numbers &optional always-list)
4025 "Convert list of numbers to a list of ranges or a single range.
4026 If ALWAYS-LIST is non-nil, this function will always release a list of
4028 (let* ((first (car numbers))
4029 (last (car numbers))
4033 (if (not (listp (cdr numbers)))
4036 (cond ((= last (car numbers)) nil) ;Omit duplicated number
4037 ((= (1+ last) (car numbers)) ;Still in sequence
4038 (setq last (car numbers)))
4039 (t ;End of one sequence
4041 (cons (if (= first last) first
4042 (cons first last)) result))
4043 (setq first (car numbers))
4044 (setq last (car numbers))))
4045 (setq numbers (cdr numbers)))
4046 (if (and (not always-list) (null result))
4047 (if (= first last) (list first) (cons first last))
4048 (nreverse (cons (if (= first last) first (cons first last))
4051 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
4052 (defun gnus-uncompress-range (ranges)
4053 "Expand a list of ranges into a list of numbers.
4054 RANGES is either a single range on the form `(num . num)' or a list of
4056 (let (first last result)
4060 ((not (listp (cdr ranges)))
4061 (setq first (car ranges))
4062 (setq last (cdr ranges))
4063 (while (<= first last)
4064 (setq result (cons first result))
4065 (setq first (1+ first)))
4069 (if (atom (car ranges))
4070 (if (numberp (car ranges))
4071 (setq result (cons (car ranges) result)))
4072 (setq first (caar ranges))
4073 (setq last (cdar ranges))
4074 (while (<= first last)
4075 (setq result (cons first result))
4076 (setq first (1+ first))))
4077 (setq ranges (cdr ranges)))
4078 (nreverse result)))))
4080 (defun gnus-add-to-range (ranges list)
4081 "Return a list of ranges that has all articles from both RANGES and LIST.
4082 Note: LIST has to be sorted over `<'."
4084 (gnus-compress-sequence list t)
4085 (setq list (copy-sequence list))
4086 (or (listp (cdr ranges))
4087 (setq ranges (list ranges)))
4089 ilist lowest highest temp)
4090 (while (and ranges list)
4092 (setq lowest (or (and (atom (car ranges)) (car ranges))
4094 (while (and list (cdr list) (< (cadr list) lowest))
4095 (setq list (cdr list)))
4096 (if (< (car ilist) lowest)
4099 (setq list (cdr list))
4101 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4102 (setq highest (or (and (atom (car ranges)) (car ranges))
4104 (while (and list (<= (car list) highest))
4105 (setq list (cdr list)))
4106 (setq ranges (cdr ranges)))
4108 (setq out (nconc (gnus-compress-sequence list t) out)))
4109 (setq out (sort out (lambda (r1 r2)
4110 (< (or (and (atom r1) r1) (car r1))
4111 (or (and (atom r2) r2) (car r2))))))
4114 (if (atom (car ranges))
4116 (if (atom (cadr ranges))
4117 (if (= (1+ (car ranges)) (cadr ranges))
4119 (setcar ranges (cons (car ranges)
4121 (setcdr ranges (cddr ranges))))
4122 (if (= (1+ (car ranges)) (caadr ranges))
4124 (setcar (cadr ranges) (car ranges))
4125 (setcar ranges (cadr ranges))
4126 (setcdr ranges (cddr ranges))))))
4128 (if (atom (cadr ranges))
4129 (if (= (1+ (cdar ranges)) (cadr ranges))
4131 (setcdr (car ranges) (cadr ranges))
4132 (setcdr ranges (cddr ranges))))
4133 (if (= (1+ (cdar ranges)) (caadr ranges))
4135 (setcdr (car ranges) (cdadr ranges))
4136 (setcdr ranges (cddr ranges)))))))
4137 (setq ranges (cdr ranges)))
4140 (defun gnus-remove-from-range (ranges list)
4141 "Return a list of ranges that has all articles from LIST removed from RANGES.
4142 Note: LIST has to be sorted over `<'."
4143 ;; !!! This function shouldn't look like this, but I've got a headache.
4144 (gnus-compress-sequence
4145 (gnus-sorted-complement
4146 (gnus-uncompress-range ranges) list)))
4148 (defun gnus-member-of-range (number ranges)
4149 (if (not (listp (cdr ranges)))
4150 (and (>= number (car ranges))
4151 (<= number (cdr ranges)))
4154 (if (numberp (car ranges))
4155 (>= number (car ranges))
4156 (>= number (caar ranges)))
4158 (if (if (numberp (car ranges))
4159 (= number (car ranges))
4160 (and (>= number (caar ranges))
4161 (<= number (cdar ranges))))
4162 (setq not-stop nil))
4163 (setq ranges (cdr ranges)))
4166 (defun gnus-range-length (range)
4167 "Return the length RANGE would have if uncompressed."
4168 (length (gnus-uncompress-range range)))
4170 (defun gnus-sublist-p (list sublist)
4171 "Test whether all elements in SUBLIST are members of LIST."
4174 (unless (memq (pop sublist) list)
4184 (defvar gnus-group-mode-map nil)
4185 (put 'gnus-group-mode 'mode-class 'special)
4187 (unless gnus-group-mode-map
4188 (setq gnus-group-mode-map (make-keymap))
4189 (suppress-keymap gnus-group-mode-map)
4191 (gnus-define-keys gnus-group-mode-map
4192 " " gnus-group-read-group
4193 "=" gnus-group-select-group
4194 "\r" gnus-group-select-group
4195 "\M-\r" gnus-group-quick-select-group
4196 "j" gnus-group-jump-to-group
4197 "n" gnus-group-next-unread-group
4198 "p" gnus-group-prev-unread-group
4199 "\177" gnus-group-prev-unread-group
4200 [delete] gnus-group-prev-unread-group
4201 "N" gnus-group-next-group
4202 "P" gnus-group-prev-group
4203 "\M-n" gnus-group-next-unread-group-same-level
4204 "\M-p" gnus-group-prev-unread-group-same-level
4205 "," gnus-group-best-unread-group
4206 "." gnus-group-first-unread-group
4207 "u" gnus-group-unsubscribe-current-group
4208 "U" gnus-group-unsubscribe-group
4209 "c" gnus-group-catchup-current
4210 "C" gnus-group-catchup-current-all
4211 "l" gnus-group-list-groups
4212 "L" gnus-group-list-all-groups
4214 "g" gnus-group-get-new-news
4215 "\M-g" gnus-group-get-new-news-this-group
4216 "R" gnus-group-restart
4217 "r" gnus-group-read-init-file
4218 "B" gnus-group-browse-foreign-server
4219 "b" gnus-group-check-bogus-groups
4220 "F" gnus-find-new-newsgroups
4221 "\C-c\C-d" gnus-group-describe-group
4222 "\M-d" gnus-group-describe-all-groups
4223 "\C-c\C-a" gnus-group-apropos
4224 "\C-c\M-\C-a" gnus-group-description-apropos
4225 "a" gnus-group-post-news
4226 "\ek" gnus-group-edit-local-kill
4227 "\eK" gnus-group-edit-global-kill
4228 "\C-k" gnus-group-kill-group
4229 "\C-y" gnus-group-yank-group
4230 "\C-w" gnus-group-kill-region
4231 "\C-x\C-t" gnus-group-transpose-groups
4232 "\C-c\C-l" gnus-group-list-killed
4233 "\C-c\C-x" gnus-group-expire-articles
4234 "\C-c\M-\C-x" gnus-group-expire-all-groups
4236 "s" gnus-group-save-newsrc
4237 "z" gnus-group-suspend
4238 ; "Z" gnus-group-clear-dribble
4241 "?" gnus-group-describe-briefly
4242 "\C-c\C-i" gnus-info-find-node
4243 "\M-e" gnus-group-edit-group-method
4244 "^" gnus-group-enter-server-mode
4245 gnus-mouse-2 gnus-mouse-pick-group
4246 "<" beginning-of-buffer
4249 "\C-c\C-s" gnus-group-sort-groups
4251 "\C-c\M-g" gnus-activate-all-groups
4252 "\M-&" gnus-group-universal-argument
4253 "#" gnus-group-mark-group
4254 "\M-#" gnus-group-unmark-group)
4256 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4257 "m" gnus-group-mark-group
4258 "u" gnus-group-unmark-group
4259 "w" gnus-group-mark-region
4260 "m" gnus-group-mark-buffer
4261 "r" gnus-group-mark-regexp
4262 "U" gnus-group-unmark-all-groups)
4264 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4265 "d" gnus-group-make-directory-group
4266 "h" gnus-group-make-help-group
4267 "a" gnus-group-make-archive-group
4268 "k" gnus-group-make-kiboze-group
4269 "m" gnus-group-make-group
4270 "E" gnus-group-edit-group
4271 "e" gnus-group-edit-group-method
4272 "p" gnus-group-edit-group-parameters
4273 "v" gnus-group-add-to-virtual
4274 "V" gnus-group-make-empty-virtual
4275 "D" gnus-group-enter-directory
4276 "f" gnus-group-make-doc-group
4277 "r" gnus-group-rename-group
4278 "\177" gnus-group-delete-group
4279 [delete] gnus-group-delete-group)
4281 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4282 "b" gnus-group-brew-soup
4283 "w" gnus-soup-save-areas
4284 "s" gnus-soup-send-replies
4285 "p" gnus-soup-pack-packet
4286 "r" nnsoup-pack-replies)
4288 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4289 "s" gnus-group-sort-groups
4290 "a" gnus-group-sort-groups-by-alphabet
4291 "u" gnus-group-sort-groups-by-unread
4292 "l" gnus-group-sort-groups-by-level
4293 "v" gnus-group-sort-groups-by-score
4294 "r" gnus-group-sort-groups-by-rank
4295 "m" gnus-group-sort-groups-by-method)
4297 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4298 "k" gnus-group-list-killed
4299 "z" gnus-group-list-zombies
4300 "s" gnus-group-list-groups
4301 "u" gnus-group-list-all-groups
4302 "A" gnus-group-list-active
4303 "a" gnus-group-apropos
4304 "d" gnus-group-description-apropos
4305 "m" gnus-group-list-matching
4306 "M" gnus-group-list-all-matching
4307 "l" gnus-group-list-level)
4309 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4310 "f" gnus-score-flush-cache)
4312 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4313 "f" gnus-group-fetch-faq)
4315 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4316 "l" gnus-group-set-current-level
4317 "t" gnus-group-unsubscribe-current-group
4318 "s" gnus-group-unsubscribe-group
4319 "k" gnus-group-kill-group
4320 "y" gnus-group-yank-group
4321 "w" gnus-group-kill-region
4322 "\C-k" gnus-group-kill-level
4323 "z" gnus-group-kill-all-zombies))
4325 (defun gnus-group-mode ()
4326 "Major mode for reading news.
4328 All normal editing commands are switched off.
4329 \\<gnus-group-mode-map>
4330 The group buffer lists (some of) the groups available. For instance,
4331 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4332 lists all zombie groups.
4334 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4335 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4337 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4339 The following commands are available:
4341 \\{gnus-group-mode-map}"
4343 (when (and menu-bar-mode
4344 (gnus-visual-p 'group-menu 'menu))
4345 (gnus-group-make-menu-bar))
4346 (kill-all-local-variables)
4347 (gnus-simplify-mode-line)
4348 (setq major-mode 'gnus-group-mode)
4349 (setq mode-name "Group")
4350 (gnus-group-set-mode-line)
4351 (setq mode-line-process nil)
4352 (use-local-map gnus-group-mode-map)
4353 (buffer-disable-undo (current-buffer))
4354 (setq truncate-lines t)
4355 (setq buffer-read-only t)
4356 (gnus-make-local-hook 'post-command-hook)
4357 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4358 (run-hooks 'gnus-group-mode-hook))
4360 (defun gnus-clear-inboxes-moved ()
4361 (setq nnmail-moved-inboxes nil))
4363 (defun gnus-mouse-pick-group (e)
4364 "Enter the group under the mouse pointer."
4367 (gnus-group-read-group nil))
4369 ;; Look at LEVEL and find out what the level is really supposed to be.
4370 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4371 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4372 (defun gnus-group-default-level (&optional level number-or-nil)
4374 (gnus-group-use-permanent-levels
4375 (or (setq gnus-group-use-permanent-levels
4376 (or level (if (numberp gnus-group-use-permanent-levels)
4377 gnus-group-use-permanent-levels
4378 (or gnus-group-default-list-level
4379 gnus-level-subscribed))))
4380 gnus-group-default-list-level gnus-level-subscribed))
4384 (or level gnus-group-default-list-level gnus-level-subscribed))))
4387 (defun gnus-slave-no-server (&optional arg)
4388 "Read network news as a slave, without connecting to local server"
4390 (gnus-no-server arg t))
4393 (defun gnus-no-server (&optional arg slave)
4395 If ARG is a positive number, Gnus will use that as the
4396 startup level. If ARG is nil, Gnus will be started at level 2.
4397 If ARG is non-nil and not a positive number, Gnus will
4398 prompt the user for the name of an NNTP server to use.
4399 As opposed to `gnus', this command will not connect to the local server."
4401 (let ((val (or arg (1- gnus-level-default-subscribed))))
4403 (make-local-variable 'gnus-group-use-permanent-levels)
4404 (setq gnus-group-use-permanent-levels val)))
4407 (defun gnus-slave (&optional arg)
4408 "Read news as a slave."
4410 (gnus arg nil 'slave))
4413 (defun gnus-other-frame (&optional arg)
4414 "Pop up a frame to read news."
4416 (if (get-buffer gnus-group-buffer)
4417 (let ((pop-up-frames t))
4419 (select-frame (make-frame))
4423 (defun gnus (&optional arg dont-connect slave)
4425 If ARG is non-nil and a positive number, Gnus will use that as the
4426 startup level. If ARG is non-nil and not a positive number, Gnus will
4427 prompt the user for the name of an NNTP server to use."
4430 (if (get-buffer gnus-group-buffer)
4432 (switch-to-buffer gnus-group-buffer)
4433 (gnus-group-get-new-news))
4436 (nnheader-init-server-buffer)
4437 (gnus-read-init-file)
4438 (setq gnus-slave slave)
4440 (gnus-group-setup-buffer)
4441 (let ((buffer-read-only nil))
4443 (if (not gnus-inhibit-startup-message)
4445 (gnus-group-startup-message)
4448 (let ((level (and (numberp arg) (> arg 0) arg))
4454 (gnus-start-news-server (and arg (not level))))))
4455 (if (and (not dont-connect)
4458 (run-hooks 'gnus-startup-hook)
4459 ;; NNTP server is successfully open.
4461 ;; Find the current startup file name.
4462 (setq gnus-current-startup-file
4463 (gnus-make-newsrc-file gnus-startup-file))
4465 ;; Read the dribble file.
4466 (when (or gnus-slave gnus-use-dribble-file)
4467 (gnus-dribble-read-file))
4469 ;; Allow using GroupLens predictions.
4470 (when gnus-use-grouplens
4472 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4474 (gnus-summary-make-display-table)
4475 ;; Do the actual startup.
4476 (gnus-setup-news nil level dont-connect)
4477 ;; Generate the group buffer.
4478 (gnus-group-list-groups level)
4479 (gnus-group-first-unread-group)
4480 (gnus-configure-windows 'group)
4481 (gnus-group-set-mode-line))))))
4483 (defun gnus-unload ()
4484 "Unload all Gnus features."
4486 (or (boundp 'load-history)
4487 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4488 (let ((history load-history)
4491 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4492 (setq feature (cdr (assq 'provide (car history))))
4493 (unload-feature feature 'force))
4494 (setq history (cdr history)))))
4496 (defun gnus-compile ()
4497 "Byte-compile the user-defined format specs."
4499 (let ((entries gnus-format-specs)
4500 entry gnus-tmp-func)
4502 (gnus-message 7 "Compiling format specs...")
4505 (setq entry (pop entries))
4506 (if (eq (car entry) 'version)
4507 (setq gnus-format-specs (delq entry gnus-format-specs))
4508 (when (and (listp (caddr entry))
4509 (not (eq 'byte-code (caaddr entry))))
4510 (fset 'gnus-tmp-func
4511 `(lambda () ,(caddr entry)))
4512 (byte-compile 'gnus-tmp-func)
4513 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4515 (push (cons 'version emacs-version) gnus-format-specs)
4516 ;; Mark the .newsrc.eld file as "dirty".
4517 (gnus-dribble-enter " ")
4518 (gnus-message 7 "Compiling user specs...done"))))
4520 (defun gnus-indent-rigidly (start end arg)
4521 "Indent rigidly using only spaces and no tabs."
4524 (narrow-to-region start end)
4525 (indent-rigidly start end arg)
4526 (goto-char (point-min))
4527 (while (search-forward "\t" nil t)
4528 (replace-match " " t t)))))
4530 (defun gnus-group-startup-message (&optional x y)
4531 "Insert startup message in current buffer."
4532 ;; Insert the message.
4537 _ ___ __ ___ __ _ ___
4556 ;; And then hack it.
4557 (gnus-indent-rigidly (point-min) (point-max)
4558 (/ (max (- (window-width) (or x 46)) 0) 2))
4559 (goto-char (point-min))
4561 (let* ((pheight (count-lines (point-min) (point-max)))
4562 (wheight (window-height))
4563 (rest (- wheight pheight)))
4564 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4566 (goto-char (point-min))
4567 (and (search-forward "Praxis" nil t)
4568 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4569 (goto-char (point-min))
4570 (let* ((mode-string (gnus-group-set-mode-line)))
4571 (setq mode-line-buffer-identification
4572 (list (concat gnus-version (substring (car mode-string) 4))))
4573 (set-buffer-modified-p t)))
4575 (defun gnus-group-setup-buffer ()
4576 (or (get-buffer gnus-group-buffer)
4578 (switch-to-buffer gnus-group-buffer)
4579 (gnus-add-current-to-buffer-list)
4581 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4583 (defun gnus-group-list-groups (&optional level unread lowest)
4584 "List newsgroups with level LEVEL or lower that have unread articles.
4585 Default is all subscribed groups.
4586 If argument UNREAD is non-nil, groups with no unread articles are also
4588 (interactive (list (if current-prefix-arg
4589 (prefix-numeric-value current-prefix-arg)
4591 (gnus-group-default-level nil t)
4592 gnus-group-default-list-level
4593 gnus-level-subscribed))))
4595 (setq level (car gnus-group-list-mode)
4596 unread (cdr gnus-group-list-mode)))
4597 (setq level (gnus-group-default-level level))
4598 (gnus-group-setup-buffer) ;May call from out of group buffer
4599 (gnus-update-format-specifications)
4600 (let ((case-fold-search nil)
4601 (props (text-properties-at (gnus-point-at-bol)))
4602 (group (gnus-group-group-name)))
4603 (set-buffer gnus-group-buffer)
4604 (funcall gnus-group-prepare-function level unread lowest)
4605 (if (zerop (buffer-size))
4606 (gnus-message 5 gnus-no-groups-message)
4607 (goto-char (point-max))
4608 (when (or (not gnus-group-goto-next-group-function)
4609 (not (funcall gnus-group-goto-next-group-function
4612 ;; Go to the first group with unread articles.
4613 (gnus-group-search-forward t)
4614 ;; Find the right group to put point on. If the current group
4615 ;; has disappeared in the new listing, try to find the next
4616 ;; one. If no next one can be found, just leave point at the
4617 ;; first newsgroup in the buffer.
4618 (if (not (gnus-goto-char
4620 (point-min) (point-max)
4621 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4622 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4624 (not (gnus-goto-char
4626 (point-min) (point-max) 'gnus-group
4628 (caar newsrc) gnus-active-hashtb)))))
4629 (setq newsrc (cdr newsrc)))
4630 (or newsrc (progn (goto-char (point-max))
4631 (forward-line -1)))))))
4632 ;; Adjust cursor point.
4633 (gnus-group-position-point))))
4635 (defun gnus-group-list-level (level &optional all)
4636 "List groups on LEVEL.
4637 If ALL (the prefix), also list groups that have no unread articles."
4638 (interactive "nList groups on level: \nP")
4639 (gnus-group-list-groups level all level))
4641 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4642 "List all newsgroups with unread articles of level LEVEL or lower.
4643 If ALL is non-nil, list groups that have no unread articles.
4644 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4645 If REGEXP, only list groups matching REGEXP."
4646 (set-buffer gnus-group-buffer)
4647 (let ((buffer-read-only nil)
4648 (newsrc (cdr gnus-newsrc-alist))
4649 (lowest (or lowest 1))
4650 info clevel unread group params)
4652 (if (< lowest gnus-level-zombie)
4653 ;; List living groups.
4655 (setq info (car newsrc)
4656 group (gnus-info-group info)
4657 params (gnus-info-params info)
4659 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4660 (and unread ; This group might be bogus
4662 (string-match regexp group))
4663 (<= (setq clevel (gnus-info-level info)) level)
4665 (or all ; We list all groups?
4666 (if (eq unread t) ; Unactivated?
4667 gnus-group-list-inactive-groups ; We list unactivated
4668 (> unread 0)) ; We list groups with unread articles
4669 (and gnus-list-groups-with-ticked-articles
4670 (cdr (assq 'tick (gnus-info-marks info))))
4671 ; And groups with tickeds
4672 ;; Check for permanent visibility.
4673 (and gnus-permanently-visible-groups
4674 (string-match gnus-permanently-visible-groups
4676 (memq 'visible params)
4677 (cdr (assq 'visible params)))
4678 (gnus-group-insert-group-line
4679 group (gnus-info-level info)
4680 (gnus-info-marks info) unread (gnus-info-method info)))))
4682 ;; List dead groups.
4683 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4684 (gnus-group-prepare-flat-list-dead
4685 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4686 gnus-level-zombie ?Z
4688 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4689 (gnus-group-prepare-flat-list-dead
4690 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4691 gnus-level-killed ?K regexp))
4693 (gnus-group-set-mode-line)
4694 (setq gnus-group-list-mode (cons level all))
4695 (run-hooks 'gnus-group-prepare-hook)))
4697 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4698 ;; List zombies and killed lists somewhat faster, which was
4699 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4700 ;; this by ignoring the group format specification altogether.
4703 ;; This loop is used when listing groups that match some
4706 (setq group (pop groups))
4707 (when (string-match regexp group)
4708 (gnus-add-text-properties
4709 (point) (prog1 (1+ (point))
4710 (insert " " mark " *: " group "\n"))
4711 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4713 'gnus-level level))))
4714 ;; This loop is used when listing all groups.
4716 (gnus-add-text-properties
4717 (point) (prog1 (1+ (point))
4718 (insert " " mark " *: "
4719 (setq group (pop groups)) "\n"))
4720 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4722 'gnus-level level))))))
4724 (defmacro gnus-group-real-name (group)
4725 "Find the real name of a foreign newsgroup."
4726 `(let ((gname ,group))
4727 (if (string-match ":[^:]+$" gname)
4728 (substring gname (1+ (match-beginning 0)))
4731 (defsubst gnus-server-add-address (method)
4732 (let ((method-name (symbol-name (car method))))
4733 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4734 (not (assq (intern (concat method-name "-address")) method)))
4735 (append method (list (list (intern (concat method-name "-address"))
4739 (defsubst gnus-server-get-method (group method)
4740 ;; Input either a server name, and extended server name, or a
4741 ;; select method, and return a select method.
4742 (cond ((stringp method)
4743 (gnus-server-to-method method))
4744 ((equal method gnus-select-method)
4746 ((and (stringp (car method)) group)
4747 (gnus-server-extend-method group method))
4748 ((and method (not group)
4749 (equal (cadr method) ""))
4752 (gnus-server-add-address method))))
4754 (defun gnus-server-to-method (server)
4755 "Map virtual server names to select methods."
4757 ;; Is this a method, perhaps?
4758 (and server (listp server) server)
4759 ;; Perhaps this is the native server?
4760 (and (equal server "native") gnus-select-method)
4761 ;; It should be in the server alist.
4762 (cdr (assoc server gnus-server-alist))
4763 ;; If not, we look through all the opened server
4764 ;; to see whether we can find it there.
4765 (let ((opened gnus-opened-servers))
4767 (not (equal server (format "%s:%s" (caaar opened)
4772 (defmacro gnus-method-equal (ss1 ss2)
4773 "Say whether two servers are equal."
4777 (and (= (length s1) (length s2))
4779 (while (and s1 (member (car s1) s2))
4783 (defun gnus-server-equal (m1 m2)
4784 "Say whether two methods are equal."
4785 (let ((m1 (cond ((null m1) gnus-select-method)
4786 ((stringp m1) (gnus-server-to-method m1))
4788 (m2 (cond ((null m2) gnus-select-method)
4789 ((stringp m2) (gnus-server-to-method m2))
4791 (gnus-method-equal m1 m2)))
4793 (defun gnus-servers-using-backend (backend)
4794 "Return a list of known servers using BACKEND."
4795 (let ((opened gnus-opened-servers)
4798 (when (eq backend (caaar opened))
4799 (push (caar opened) out))
4803 (defun gnus-archive-server-wanted-p ()
4804 "Say whether the user wants to use the archive server."
4806 ((or (not gnus-message-archive-method)
4807 (not gnus-message-archive-group))
4809 ((and gnus-message-archive-method gnus-message-archive-group)
4812 (let ((active (cadr (assq 'nnfolder-active-file
4813 gnus-message-archive-method))))
4815 (file-exists-p active))))))
4817 (defun gnus-group-prefixed-name (group method)
4818 "Return the whole name from GROUP and METHOD."
4819 (and (stringp method) (setq method (gnus-server-to-method method)))
4820 (concat (format "%s" (car method))
4822 (or (assoc (format "%s" (car method))
4823 (gnus-methods-using 'address))
4824 (gnus-server-equal method gnus-message-archive-method))
4826 (not (string= (nth 1 method) "")))
4827 (concat "+" (nth 1 method)))
4830 (defun gnus-group-real-prefix (group)
4831 "Return the prefix of the current group name."
4832 (if (string-match "^[^:]+:" group)
4833 (substring group 0 (match-end 0))
4836 (defun gnus-group-method (group)
4837 "Return the server or method used for selecting GROUP."
4838 (let ((prefix (gnus-group-real-prefix group)))
4839 (if (equal prefix "")
4841 (let ((servers gnus-opened-servers)
4843 backend possible found)
4844 (if (string-match "^[^\\+]+\\+" prefix)
4845 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4846 server (substring prefix (match-end 0) (1- (length prefix))))
4847 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4849 (when (eq (caaar servers) backend)
4850 (setq possible (caar servers))
4851 (when (equal (cadaar servers) server)
4852 (setq found (caar servers))))
4854 (or (car (rassoc found gnus-server-alist))
4856 (car (rassoc possible gnus-server-alist))
4858 (list backend server))))))
4860 (defsubst gnus-secondary-method-p (method)
4861 "Return whether METHOD is a secondary select method."
4862 (let ((methods gnus-secondary-select-methods)
4863 (gmethod (gnus-server-get-method nil method)))
4865 (not (equal (gnus-server-get-method nil (car methods))
4867 (setq methods (cdr methods)))
4870 (defun gnus-group-foreign-p (group)
4871 "Say whether a group is foreign or not."
4872 (and (not (gnus-group-native-p group))
4873 (not (gnus-group-secondary-p group))))
4875 (defun gnus-group-native-p (group)
4876 "Say whether the group is native or not."
4877 (not (string-match ":" group)))
4879 (defun gnus-group-secondary-p (group)
4880 "Say whether the group is secondary or not."
4881 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4883 (defun gnus-group-get-parameter (group &optional symbol)
4884 "Returns the group parameters for GROUP.
4885 If SYMBOL, return the value of that symbol in the group parameters."
4886 (let ((params (gnus-info-params (gnus-get-info group))))
4888 (gnus-group-parameter-value params symbol)
4891 (defun gnus-group-parameter-value (params symbol)
4892 "Return the value of SYMBOL in group PARAMS."
4893 (or (car (memq symbol params)) ; It's either a simple symbol
4894 (cdr (assq symbol params)))) ; or a cons.
4896 (defun gnus-group-add-parameter (group param)
4897 "Add parameter PARAM to GROUP."
4898 (let ((info (gnus-get-info group)))
4900 () ; This is a dead group. We just ignore it.
4901 ;; Cons the new param to the old one and update.
4902 (gnus-group-set-info (cons param (gnus-info-params info))
4905 (defun gnus-group-set-parameter (group name value)
4906 "Set parameter NAME to VALUE in GROUP."
4907 (let ((info (gnus-get-info group)))
4909 () ; This is a dead group. We just ignore it.
4910 (let ((old-params (gnus-info-params info))
4911 (new-params (list (cons name value))))
4913 (if (or (not (listp (car old-params)))
4914 (not (eq (caar old-params) name)))
4915 (setq new-params (append new-params (list (car old-params)))))
4916 (setq old-params (cdr old-params)))
4917 (gnus-group-set-info new-params group 'params)))))
4919 (defun gnus-group-add-score (group &optional score)
4920 "Add SCORE to the GROUP score.
4921 If SCORE is nil, add 1 to the score of GROUP."
4922 (let ((info (gnus-get-info group)))
4924 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4926 (defun gnus-summary-bubble-group ()
4927 "Increase the score of the current group.
4928 This is a handy function to add to `gnus-summary-exit-hook' to
4929 increase the score of each group you read."
4930 (gnus-group-add-score gnus-newsgroup-name))
4932 (defun gnus-group-set-info (info &optional method-only-group part)
4933 (let* ((entry (gnus-gethash
4934 (or method-only-group (gnus-info-group info))
4935 gnus-newsrc-hashtb))
4937 (info (if method-only-group (nth 2 entry) info))
4939 (when method-only-group
4941 (error "Trying to change non-existent group %s" method-only-group))
4942 ;; We have received parts of the actual group info - either the
4943 ;; select method or the group parameters. We first check
4944 ;; whether we have to extend the info, and if so, do that.
4945 (let ((len (length info))
4946 (total (if (eq part 'method) 5 6)))
4948 (setcdr (nthcdr (1- len) info)
4949 (make-list (- total len) nil)))
4950 ;; Then we enter the new info.
4951 (setcar (nthcdr (1- total) info) part-info)))
4953 ;; This is a new group, so we just create it.
4955 (set-buffer gnus-group-buffer)
4956 (setq method (gnus-info-method info))
4957 (when (gnus-server-equal method "native")
4960 (set-buffer gnus-group-buffer)
4962 ;; It's a foreign group...
4963 (gnus-group-make-group
4964 (gnus-group-real-name (gnus-info-group info))
4965 (if (stringp method) method
4966 (prin1-to-string (car method)))
4968 (nth 1 (gnus-info-method info))))
4969 ;; It's a native group.
4970 (gnus-group-make-group (gnus-info-group info))))
4971 (gnus-message 6 "Note: New group created")
4973 (gnus-gethash (gnus-group-prefixed-name
4974 (gnus-group-real-name (gnus-info-group info))
4975 (or (gnus-info-method info) gnus-select-method))
4976 gnus-newsrc-hashtb))))
4977 ;; Whether it was a new group or not, we now have the entry, so we
4978 ;; can do the update.
4981 (setcar (nthcdr 2 entry) info)
4982 (when (and (not (eq (car entry) t))
4983 (gnus-active (gnus-info-group info)))
4984 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4985 (error "No such group: %s" (gnus-info-group info)))))
4987 (defun gnus-group-set-method-info (group select-method)
4988 (gnus-group-set-info select-method group 'method))
4990 (defun gnus-group-set-params-info (group params)
4991 (gnus-group-set-info params group 'params))
4993 (defun gnus-group-update-group-line ()
4994 "Update the current line in the group buffer."
4995 (let* ((buffer-read-only nil)
4996 (group (gnus-group-group-name))
4997 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4998 gnus-group-indentation)
5001 (not (gnus-ephemeral-group-p group))
5003 (concat "(gnus-group-set-info '"
5004 (prin1-to-string (nth 2 entry)) ")")))
5005 (setq gnus-group-indentation (gnus-group-group-indentation))
5007 (gnus-group-insert-group-line-info group)
5009 (gnus-group-position-point))))
5011 (defun gnus-group-insert-group-line-info (group)
5012 "Insert GROUP on the current line."
5013 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
5017 ;; (Un)subscribed group.
5018 (setq info (nth 2 entry))
5019 (gnus-group-insert-group-line
5020 group (gnus-info-level info) (gnus-info-marks info)
5021 (or (car entry) t) (gnus-info-method info)))
5022 ;; This group is dead.
5023 (gnus-group-insert-group-line
5025 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
5027 (if (setq active (gnus-active group))
5028 (- (1+ (cdr active)) (car active)) 0)
5031 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
5032 gnus-tmp-marked number
5034 "Insert a group line in the group buffer."
5035 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
5036 (gnus-tmp-number-total
5038 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
5040 (gnus-tmp-number-of-unread
5041 (if (numberp number) (int-to-string (max 0 number))
5043 (gnus-tmp-number-of-read
5044 (if (numberp number)
5045 (int-to-string (max 0 (- gnus-tmp-number-total number)))
5047 (gnus-tmp-subscribed
5048 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
5049 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
5050 ((= gnus-tmp-level gnus-level-zombie) ?Z)
5052 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
5053 (gnus-tmp-newsgroup-description
5054 (if gnus-description-hashtb
5055 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
5058 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
5059 (gnus-tmp-moderated-string
5060 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
5062 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
5063 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
5064 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
5065 (gnus-tmp-news-method-string
5067 (format "(%s:%s)" (car gnus-tmp-method)
5068 (cadr gnus-tmp-method)) ""))
5069 (gnus-tmp-marked-mark
5070 (if (and (numberp number)
5072 (cdr (assq 'tick gnus-tmp-marked)))
5074 (gnus-tmp-process-marked
5075 (if (member gnus-tmp-group gnus-group-marked)
5076 gnus-process-mark ? ))
5078 (or (and gnus-use-grouplens
5079 (bbb-grouplens-group-p gnus-tmp-group))
5081 (buffer-read-only nil)
5082 header gnus-tmp-header) ; passed as parameter to user-funcs.
5084 (gnus-add-text-properties
5088 (eval gnus-group-line-format-spec))
5089 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5090 gnus-unread ,(if (numberp number)
5091 (string-to-int gnus-tmp-number-of-unread)
5093 gnus-marked ,gnus-tmp-marked-mark
5094 gnus-indentation ,gnus-group-indentation
5095 gnus-level ,gnus-tmp-level))
5096 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5098 (run-hooks 'gnus-group-update-hook)
5100 ;; Allow XEmacs to remove front-sticky text properties.
5101 (gnus-group-remove-excess-properties)))
5103 (defun gnus-group-update-group (group &optional visible-only)
5104 "Update all lines where GROUP appear.
5105 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5108 (set-buffer gnus-group-buffer)
5109 ;; The buffer may be narrowed.
5112 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5114 found buffer-read-only)
5115 ;; Enter the current status into the dribble buffer.
5116 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5117 (if (and entry (not (gnus-ephemeral-group-p group)))
5119 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5121 ;; Find all group instances. If topics are in use, each group
5122 ;; may be listed in more than once.
5123 (while (setq loc (text-property-any
5124 loc (point-max) 'gnus-group ident))
5127 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5129 (gnus-group-insert-group-line-info group)
5132 (run-hooks 'gnus-group-update-group-hook)))
5133 (setq loc (1+ loc)))
5134 (unless (or found visible-only)
5135 ;; No such line in the buffer, find out where it's supposed to
5136 ;; go, and insert it there (or at the end of the buffer).
5137 (if gnus-goto-missing-group-function
5138 (funcall gnus-goto-missing-group-function group)
5139 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5140 (while (and entry (car entry)
5144 (point-min) (point-max)
5145 'gnus-group (gnus-intern-safe
5146 (caar entry) gnus-active-hashtb)))))
5147 (setq entry (cdr entry)))
5148 (or entry (goto-char (point-max)))))
5149 ;; Finally insert the line.
5150 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5151 (gnus-group-insert-group-line-info group)
5154 (run-hooks 'gnus-group-update-group-hook))))
5155 (gnus-group-set-mode-line)))))
5157 (defun gnus-group-set-mode-line ()
5158 "Update the mode line in the group buffer."
5159 (when (memq 'group gnus-updated-mode-lines)
5160 ;; Yes, we want to keep this mode line updated.
5162 (set-buffer gnus-group-buffer)
5163 (let* ((gformat (or gnus-group-mode-line-format-spec
5164 (setq gnus-group-mode-line-format-spec
5166 gnus-group-mode-line-format
5167 gnus-group-mode-line-format-alist))))
5168 (gnus-tmp-news-server (cadr gnus-select-method))
5169 (gnus-tmp-news-method (car gnus-select-method))
5170 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5172 gnus-tmp-header ;Dummy binding for user-defined formats
5173 ;; Get the resulting string.
5175 (and gnus-dribble-buffer
5176 (buffer-name gnus-dribble-buffer)
5177 (buffer-modified-p gnus-dribble-buffer)
5179 (set-buffer gnus-dribble-buffer)
5180 (not (zerop (buffer-size))))))
5181 (mode-string (eval gformat)))
5182 ;; Say whether the dribble buffer has been modified.
5183 (setq mode-line-modified
5184 (if modified "---*- " "----- "))
5185 ;; If the line is too long, we chop it off.
5186 (when (> (length mode-string) max-len)
5187 (setq mode-string (substring mode-string 0 (- max-len 4))))
5189 (setq mode-line-buffer-identification
5190 (gnus-mode-line-buffer-identification
5191 (list mode-string)))
5192 (set-buffer-modified-p modified))))))
5194 (defun gnus-group-group-name ()
5195 "Get the name of the newsgroup on the current line."
5196 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5197 (and group (symbol-name group))))
5199 (defun gnus-group-group-level ()
5200 "Get the level of the newsgroup on the current line."
5201 (get-text-property (gnus-point-at-bol) 'gnus-level))
5203 (defun gnus-group-group-indentation ()
5204 "Get the indentation of the newsgroup on the current line."
5205 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5206 (and gnus-group-indentation-function
5207 (funcall gnus-group-indentation-function))
5210 (defun gnus-group-group-unread ()
5211 "Get the number of unread articles of the newsgroup on the current line."
5212 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5214 (defun gnus-group-search-forward (&optional backward all level first-too)
5215 "Find the next newsgroup with unread articles.
5216 If BACKWARD is non-nil, find the previous newsgroup instead.
5217 If ALL is non-nil, just find any newsgroup.
5218 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5220 If FIRST-TOO, the current line is also eligible as a target."
5221 (let ((way (if backward -1 1))
5222 (low gnus-level-killed)
5225 (if (and backward (progn (beginning-of-line)) (bobp))
5227 (or first-too (forward-line way))
5235 (get-text-property (point) 'gnus-unread)))
5236 (and (numberp unread) (> unread 0)))
5237 (setq lev (get-text-property (point)
5239 (<= lev gnus-level-subscribed)))
5241 (and (setq lev (get-text-property (point)
5250 (zerop (forward-line way)))))
5252 (progn (gnus-group-position-point) t)
5253 (goto-char (or pos beg))
5256 ;;; Gnus group mode commands
5260 (defun gnus-group-mark-group (n &optional unmark no-advance)
5261 "Mark the current group."
5263 (let ((buffer-read-only nil)
5267 (when (setq group (gnus-group-group-name))
5271 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5276 (setq gnus-group-marked (delete group gnus-group-marked)))
5278 (setq gnus-group-marked
5279 (cons group (delete group gnus-group-marked)))))
5280 (or no-advance (gnus-group-next-group 1))
5282 (gnus-summary-position-point)
5285 (defun gnus-group-unmark-group (n)
5286 "Remove the mark from the current group."
5288 (gnus-group-mark-group n 'unmark)
5289 (gnus-group-position-point))
5291 (defun gnus-group-unmark-all-groups ()
5292 "Unmark all groups."
5294 (let ((groups gnus-group-marked))
5297 (gnus-group-remove-mark (pop groups)))))
5298 (gnus-group-position-point))
5300 (defun gnus-group-mark-region (unmark beg end)
5301 "Mark all groups between point and mark.
5302 If UNMARK, remove the mark instead."
5303 (interactive "P\nr")
5304 (let ((num (count-lines beg end)))
5307 (- num (gnus-group-mark-group num unmark)))))
5309 (defun gnus-group-mark-buffer (&optional unmark)
5310 "Mark all groups in the buffer.
5311 If UNMARK, remove the mark instead."
5313 (gnus-group-mark-region unmark (point-min) (point-max)))
5315 (defun gnus-group-mark-regexp (regexp)
5316 "Mark all groups that match some regexp."
5317 (interactive "sMark (regexp): ")
5318 (let ((alist (cdr gnus-newsrc-alist))
5321 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5322 (gnus-group-set-mark group))))
5323 (gnus-group-position-point))
5325 (defun gnus-group-remove-mark (group)
5326 "Remove the process mark from GROUP and move point there.
5327 Return nil if the group isn't displayed."
5328 (if (gnus-group-goto-group group)
5330 (gnus-group-mark-group 1 'unmark t)
5332 (setq gnus-group-marked
5333 (delete group gnus-group-marked))
5336 (defun gnus-group-set-mark (group)
5337 "Set the process mark on GROUP."
5338 (if (gnus-group-goto-group group)
5340 (gnus-group-mark-group 1 nil t))
5341 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5343 (defun gnus-group-universal-argument (arg &optional groups func)
5344 "Perform any command on all groups accoring to the process/prefix convention."
5346 (let ((groups (or groups (gnus-group-process-prefix arg)))
5348 (if (eq (setq func (or func
5351 (substitute-command-keys
5352 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5354 (gnus-error 1 "Undefined key")
5356 (gnus-group-remove-mark (setq group (pop groups)))
5357 (command-execute func))))
5358 (gnus-group-position-point))
5360 (defun gnus-group-process-prefix (n)
5361 "Return a list of groups to work on.
5362 Take into consideration N (the prefix) and the list of marked groups."
5365 (setq n (prefix-numeric-value n))
5366 ;; There is a prefix, so we return a list of the N next
5368 (let ((way (if (< n 0) -1 1))
5373 (setq group (gnus-group-group-name)))
5374 (setq groups (cons group groups))
5376 (gnus-group-next-group way)))
5378 ((and (boundp 'transient-mark-mode)
5380 (boundp 'mark-active)
5382 ;; Work on the region between point and mark.
5383 (let ((max (max (point) (mark)))
5386 (goto-char (min (point) (mark)))
5389 (push (gnus-group-group-name) groups)
5390 (zerop (gnus-group-next-group 1))
5392 (nreverse groups))))
5394 ;; No prefix, but a list of marked articles.
5395 (reverse gnus-group-marked))
5397 ;; Neither marked articles or a prefix, so we return the
5399 (let ((group (gnus-group-group-name)))
5400 (and group (list group))))))
5402 ;; Selecting groups.
5404 (defun gnus-group-read-group (&optional all no-article group)
5405 "Read news in this newsgroup.
5406 If the prefix argument ALL is non-nil, already read articles become
5407 readable. IF ALL is a number, fetch this number of articles. If the
5408 optional argument NO-ARTICLE is non-nil, no article will be
5409 auto-selected upon group entry. If GROUP is non-nil, fetch that
5412 (let ((group (or group (gnus-group-group-name)))
5413 number active marked entry)
5414 (or group (error "No group on current line"))
5415 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5416 group gnus-newsrc-hashtb)))))
5417 ;; This group might be a dead group. In that case we have to get
5418 ;; the number of unread articles from `gnus-active-hashtb'.
5420 (cond ((numberp all) all)
5422 ((setq active (gnus-active group))
5423 (- (1+ (cdr active)) (car active)))))
5424 (gnus-summary-read-group
5425 group (or all (and (numberp number)
5426 (zerop (+ number (length (cdr (assq 'tick marked)))
5427 (length (cdr (assq 'dormant marked)))))))
5430 (defun gnus-group-select-group (&optional all)
5431 "Select this newsgroup.
5432 No article is selected automatically.
5433 If ALL is non-nil, already read articles become readable.
5434 If ALL is a number, fetch this number of articles."
5436 (gnus-group-read-group all t))
5438 (defun gnus-group-quick-select-group (&optional all)
5439 "Select the current group \"quickly\".
5440 This means that no highlighting or scoring will be performed."
5443 gnus-score-find-score-files-function
5444 gnus-apply-kill-hook
5445 gnus-summary-expunge-below)
5446 (gnus-group-read-group all t)))
5448 (defun gnus-group-visible-select-group (&optional all)
5449 "Select the current group without hiding any articles."
5451 (let ((gnus-inhibit-limiting t))
5452 (gnus-group-read-group all t)))
5455 (defun gnus-fetch-group (group)
5456 "Start Gnus if necessary and enter GROUP.
5457 Returns whether the fetching was successful or not."
5458 (interactive "sGroup name: ")
5459 (or (get-buffer gnus-group-buffer)
5461 (gnus-group-read-group nil nil group))
5463 ;; Enter a group that is not in the group buffer. Non-nil is returned
5464 ;; if selection was successful.
5465 (defun gnus-group-read-ephemeral-group
5466 (group method &optional activate quit-config)
5467 (let ((group (if (gnus-group-foreign-p group) group
5468 (gnus-group-prefixed-name group method))))
5471 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5472 ((quit-config . ,(if quit-config quit-config
5473 (cons (current-buffer) 'summary))))))
5475 (set-buffer gnus-group-buffer)
5476 (or (gnus-check-server method)
5477 (error "Unable to contact server: %s" (gnus-status-message method)))
5478 (if activate (or (gnus-request-group group)
5479 (error "Couldn't request group")))
5481 (gnus-group-read-group t t group)
5485 (defun gnus-group-jump-to-group (group)
5486 "Jump to newsgroup GROUP."
5488 (list (completing-read
5489 "Group: " gnus-active-hashtb nil
5490 (gnus-read-active-file-p)
5492 'gnus-group-history)))
5494 (when (equal group "")
5495 (error "Empty group name"))
5497 (when (string-match "[\000-\032]" group)
5498 (error "Control characters in group: %s" group))
5500 (let ((b (text-property-any
5501 (point-min) (point-max)
5502 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5503 (unless (gnus-ephemeral-group-p group)
5505 ;; Either go to the line in the group buffer...
5507 ;; ... or insert the line.
5510 (gnus-activate-group group)
5511 (error "%s error: %s" group (gnus-status-message group)))
5513 (gnus-group-update-group group)
5514 (goto-char (text-property-any
5515 (point-min) (point-max)
5516 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5517 ;; Adjust cursor point.
5518 (gnus-group-position-point)))
5520 (defun gnus-group-goto-group (group)
5521 "Goto to newsgroup GROUP."
5523 (let ((b (text-property-any (point-min) (point-max)
5524 'gnus-group (gnus-intern-safe
5525 group gnus-active-hashtb))))
5526 (and b (goto-char b)))))
5528 (defun gnus-group-next-group (n &optional silent)
5529 "Go to next N'th newsgroup.
5530 If N is negative, search backward instead.
5531 Returns the difference between N and the number of skips actually
5534 (gnus-group-next-unread-group n t nil silent))
5536 (defun gnus-group-next-unread-group (n &optional all level silent)
5537 "Go to next N'th unread newsgroup.
5538 If N is negative, search backward instead.
5539 If ALL is non-nil, choose any newsgroup, unread or not.
5540 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5541 such group can be found, the next group with a level higher than
5543 Returns the difference between N and the number of skips actually
5546 (let ((backward (< n 0))
5549 (gnus-group-search-forward
5550 backward (or (not gnus-group-goto-unread) all) level))
5554 (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5555 (if level " on this level or higher" "")))
5558 (defun gnus-group-prev-group (n)
5559 "Go to previous N'th newsgroup.
5560 Returns the difference between N and the number of skips actually
5563 (gnus-group-next-unread-group (- n) t))
5565 (defun gnus-group-prev-unread-group (n)
5566 "Go to previous N'th unread newsgroup.
5567 Returns the difference between N and the number of skips actually
5570 (gnus-group-next-unread-group (- n)))
5572 (defun gnus-group-next-unread-group-same-level (n)
5573 "Go to next N'th unread newsgroup on the same level.
5574 If N is negative, search backward instead.
5575 Returns the difference between N and the number of skips actually
5578 (gnus-group-next-unread-group n t (gnus-group-group-level))
5579 (gnus-group-position-point))
5581 (defun gnus-group-prev-unread-group-same-level (n)
5582 "Go to next N'th unread newsgroup on the same level.
5583 Returns the difference between N and the number of skips actually
5586 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5587 (gnus-group-position-point))
5589 (defun gnus-group-best-unread-group (&optional exclude-group)
5590 "Go to the group with the highest level.
5591 If EXCLUDE-GROUP, do not go to that group."
5593 (goto-char (point-min))
5597 (setq unread (get-text-property (point) 'gnus-unread))
5598 (if (and (numberp unread) (> unread 0))
5600 (if (and (get-text-property (point) 'gnus-level)
5601 (< (get-text-property (point) 'gnus-level) best)
5602 (or (not exclude-group)
5603 (not (equal exclude-group (gnus-group-group-name)))))
5605 (setq best (get-text-property (point) 'gnus-level))
5606 (setq best-point (point))))))
5608 (if best-point (goto-char best-point))
5609 (gnus-summary-position-point)
5610 (and best-point (gnus-group-group-name))))
5612 (defun gnus-group-first-unread-group ()
5613 "Go to the first group with unread articles."
5616 (let ((opoint (point))
5618 (goto-char (point-min))
5619 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5620 (and (numberp unread) ; Not a topic.
5621 (not (zerop unread))) ; Has unread articles.
5622 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5625 nil)) ; Not success.
5626 (gnus-group-position-point)))
5628 (defun gnus-group-enter-server-mode ()
5629 "Jump to the server buffer."
5631 (gnus-enter-server-buffer))
5633 (defun gnus-group-make-group (name &optional method address)
5634 "Add a new newsgroup.
5635 The user will be prompted for a NAME, for a select METHOD, and an
5639 (read-string "Group name: ")
5642 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5643 nil t nil 'gnus-method-history)))
5644 (cond ((assoc method gnus-valid-select-methods)
5646 (if (memq 'prompt-address
5647 (assoc method gnus-valid-select-methods))
5648 (read-string "Address: ")
5650 ((assoc method gnus-server-alist)
5653 (list method ""))))))
5655 (let* ((meth (and method (if address (list (intern method) address)
5657 (nname (if method (gnus-group-prefixed-name name meth) name))
5659 (when (gnus-gethash nname gnus-newsrc-hashtb)
5660 (error "Group %s already exists" nname))
5661 ;; Subscribe to the new group.
5662 (gnus-group-change-level
5663 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5664 gnus-level-default-subscribed gnus-level-killed
5665 (and (gnus-group-group-name)
5666 (gnus-gethash (gnus-group-group-name)
5667 gnus-newsrc-hashtb))
5670 (gnus-set-active nname (cons 1 0))
5671 (or (gnus-ephemeral-group-p name)
5673 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5675 (gnus-group-insert-group-line-info nname)
5677 (gnus-group-position-point)
5679 ;; Load the backend and try to make the backend create
5680 ;; the group as well.
5681 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5683 gnus-valid-select-methods)
5685 (gnus-check-server meth)
5686 (and (gnus-check-backend-function 'request-create-group nname)
5687 (gnus-request-create-group nname))
5690 (defun gnus-group-delete-group (group &optional force)
5691 "Delete the current group. Only meaningful with mail groups.
5692 If FORCE (the prefix) is non-nil, all the articles in the group will
5693 be deleted. This is \"deleted\" as in \"removed forever from the face
5694 of the Earth\". There is no undo. The user will be prompted before
5695 doing the deletion."
5697 (list (gnus-group-group-name)
5698 current-prefix-arg))
5699 (or group (error "No group to rename"))
5700 (or (gnus-check-backend-function 'request-delete-group group)
5701 (error "This backend does not support group deletion"))
5703 (if (not (gnus-yes-or-no-p
5705 "Do you really want to delete %s%s? "
5706 group (if force " and all its contents" ""))))
5708 (gnus-message 6 "Deleting group %s..." group)
5709 (if (not (gnus-request-delete-group group force))
5710 (gnus-error 3 "Couldn't delete group %s" group)
5711 (gnus-message 6 "Deleting group %s...done" group)
5712 (gnus-group-goto-group group)
5713 (gnus-group-kill-group 1 t)
5714 (gnus-sethash group nil gnus-active-hashtb)
5716 (gnus-group-position-point)))
5718 (defun gnus-group-rename-group (group new-name)
5721 (gnus-group-group-name)
5723 (or (gnus-check-backend-function
5724 'request-rename-group (gnus-group-group-name))
5725 (error "This backend does not support renaming groups"))
5726 (read-string "New group name: "))))
5728 (or (gnus-check-backend-function 'request-rename-group group)
5729 (error "This backend does not support renaming groups"))
5731 (or group (error "No group to rename"))
5732 (and (string-match "^[ \t]*$" new-name)
5733 (error "Not a valid group name"))
5735 ;; We find the proper prefixed name.
5737 (gnus-group-prefixed-name
5738 (gnus-group-real-name new-name)
5739 (gnus-info-method (gnus-get-info group))))
5741 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5743 (if (not (gnus-request-rename-group group new-name))
5744 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5745 ;; We rename the group internally by killing it...
5746 (gnus-group-goto-group group)
5747 (gnus-group-kill-group)
5748 ;; ... changing its name ...
5749 (setcar (cdar gnus-list-of-killed-groups) new-name)
5750 ;; ... and then yanking it. Magic!
5751 (gnus-group-yank-group)
5752 (gnus-set-active new-name (gnus-active group))
5753 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5755 (gnus-group-position-point)))
5757 (defun gnus-group-edit-group (group &optional part)
5758 "Edit the group on the current line."
5759 (interactive (list (gnus-group-group-name)))
5760 (let* ((part (or part 'info))
5761 (done-func `(lambda ()
5762 "Exit editing mode and update the information."
5764 (gnus-group-edit-group-done ',part ,group)))
5765 (winconf (current-window-configuration))
5767 (or group (error "No group on current line"))
5768 (or (setq info (gnus-get-info group))
5769 (error "Killed group; can't be edited"))
5770 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5771 (gnus-configure-windows 'edit-group)
5772 (gnus-add-current-to-buffer-list)
5774 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5775 (use-local-map (copy-keymap emacs-lisp-mode-map))
5776 (local-set-key "\C-c\C-c" done-func)
5777 (make-local-variable 'gnus-prev-winconf)
5778 (setq gnus-prev-winconf winconf)
5783 ";; Type `C-c C-c' after editing the select method.\n\n")
5785 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5787 ";; Type `C-c C-c' after editing the group info.\n\n")))
5790 (cond ((eq part 'method)
5791 (or (gnus-info-method info) "native"))
5793 (gnus-info-params info))
5797 (defun gnus-group-edit-group-method (group)
5798 "Edit the select method of GROUP."
5799 (interactive (list (gnus-group-group-name)))
5800 (gnus-group-edit-group group 'method))
5802 (defun gnus-group-edit-group-parameters (group)
5803 "Edit the group parameters of GROUP."
5804 (interactive (list (gnus-group-group-name)))
5805 (gnus-group-edit-group group 'params))
5807 (defun gnus-group-edit-group-done (part group)
5808 "Get info from buffer, update variables and jump to the group buffer."
5809 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5810 (goto-char (point-min))
5811 (let* ((form (read (current-buffer)))
5812 (winconf gnus-prev-winconf)
5813 (method (cond ((eq part 'info) (nth 4 form))
5814 ((eq part 'method) form)
5816 (info (cond ((eq part 'info) form)
5817 ((eq part 'method) (gnus-get-info group))
5820 (if (or (not method)
5822 gnus-select-method method))
5823 (gnus-group-real-name (car info))
5824 (gnus-group-prefixed-name
5825 (gnus-group-real-name (car info)) method))
5827 (when (and new-group
5828 (not (equal new-group group)))
5829 (when (gnus-group-goto-group group)
5830 (gnus-group-kill-group 1))
5831 (gnus-activate-group new-group))
5833 (if (and info new-group)
5835 (setq info (gnus-copy-sequence info))
5836 (setcar info new-group)
5837 (unless (gnus-server-equal method "native")
5838 (unless (nthcdr 3 info)
5839 (nconc info (list nil nil)))
5840 (unless (nthcdr 4 info)
5841 (nconc info (list nil)))
5842 (gnus-info-set-method info method))
5843 (gnus-group-set-info info))
5844 (gnus-group-set-info form (or new-group group) part))
5845 (kill-buffer (current-buffer))
5846 (and winconf (set-window-configuration winconf))
5847 (set-buffer gnus-group-buffer)
5848 (gnus-group-update-group (or new-group group))
5849 (gnus-group-position-point)))
5851 (defun gnus-group-make-help-group ()
5852 "Create the Gnus documentation group."
5854 (let ((path load-path)
5855 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5857 (and (gnus-gethash name gnus-newsrc-hashtb)
5858 (error "Documentation group already exists"))
5860 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5862 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5864 (setq file (concat (file-name-directory
5865 (directory-file-name dir))
5866 "etc/gnus-tut.txt"))))
5869 (gnus-message 1 "Couldn't find doc group")
5870 (gnus-group-make-group
5871 (gnus-group-real-name name)
5872 (list 'nndoc "gnus-help"
5873 (list 'nndoc-address file)
5874 (list 'nndoc-article-type 'mbox)))))
5875 (gnus-group-position-point))
5877 (defun gnus-group-make-doc-group (file type)
5878 "Create a group that uses a single file as the source."
5880 (list (read-file-name "File name: ")
5881 (and current-prefix-arg 'ask)))
5882 (when (eq type 'ask)
5887 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5889 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5890 ((= char ?b) 'babyl)
5891 ((= char ?d) 'digest)
5892 ((= char ?f) 'forward)
5894 (t (setq err (format "%c unknown. " char))
5897 (let* ((file (expand-file-name file))
5898 (name (gnus-generate-new-group-name
5899 (gnus-group-prefixed-name
5900 (file-name-nondirectory file) '(nndoc "")))))
5901 (gnus-group-make-group
5902 (gnus-group-real-name name)
5903 (list 'nndoc (file-name-nondirectory file)
5904 (list 'nndoc-address file)
5905 (list 'nndoc-article-type (or type 'guess))))))
5907 (defun gnus-group-make-archive-group (&optional all)
5908 "Create the (ding) Gnus archive group of the most recent articles.
5909 Given a prefix, create a full group."
5911 (let ((group (gnus-group-prefixed-name
5912 (if all "ding.archives" "ding.recent") '(nndir ""))))
5913 (and (gnus-gethash group gnus-newsrc-hashtb)
5914 (error "Archive group already exists"))
5915 (gnus-group-make-group
5916 (gnus-group-real-name group)
5917 (list 'nndir (if all "hpc" "edu")
5918 (list 'nndir-directory
5919 (if all gnus-group-archive-directory
5920 gnus-group-recent-archive-directory))))))
5922 (defun gnus-group-make-directory-group (dir)
5923 "Create an nndir group.
5924 The user will be prompted for a directory. The contents of this
5925 directory will be used as a newsgroup. The directory should contain
5926 mail messages or news articles in files that have numeric names."
5928 (list (read-file-name "Create group from directory: ")))
5929 (or (file-exists-p dir) (error "No such directory"))
5930 (or (file-directory-p dir) (error "Not a directory"))
5934 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5936 (gnus-group-prefixed-name
5937 (concat (file-name-as-directory (directory-file-name dir))
5940 (setq ext (format "<%d>" (setq i (1+ i)))))
5941 (gnus-group-make-group
5942 (gnus-group-real-name group)
5943 (list 'nndir group (list 'nndir-directory dir)))))
5945 (defun gnus-group-make-kiboze-group (group address scores)
5946 "Create an nnkiboze group.
5947 The user will be prompted for a name, a regexp to match groups, and
5948 score file entries for articles to include in the group."
5951 (read-string "nnkiboze group name: ")
5952 (read-string "Source groups (regexp): ")
5953 (let ((headers (mapcar (lambda (group) (list group))
5954 '("subject" "from" "number" "date" "message-id"
5955 "references" "chars" "lines" "xref"
5956 "followup" "all" "body" "head")))
5957 scores header regexp regexps)
5958 (while (not (equal "" (setq header (completing-read
5959 "Match on header: " headers nil t))))
5961 (while (not (equal "" (setq regexp (read-string
5962 (format "Match on %s (string): "
5964 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5965 (setq scores (cons (cons header regexps) scores)))
5967 (gnus-group-make-group group "nnkiboze" address)
5968 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5969 (let (emacs-lisp-mode-hook)
5970 (pp scores (current-buffer)))))
5972 (defun gnus-group-add-to-virtual (n vgroup)
5973 "Add the current group to a virtual group."
5975 (list current-prefix-arg
5976 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5978 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5979 (error "%s is not an nnvirtual group" vgroup))
5980 (let* ((groups (gnus-group-process-prefix n))
5981 (method (gnus-info-method (gnus-get-info vgroup))))
5982 (setcar (cdr method)
5984 (nth 1 method) "\\|"
5987 (gnus-group-remove-mark s)
5988 (concat "\\(^" (regexp-quote s) "$\\)"))
5990 (gnus-group-position-point))
5992 (defun gnus-group-make-empty-virtual (group)
5993 "Create a new, fresh, empty virtual group."
5994 (interactive "sCreate new, empty virtual group: ")
5995 (let* ((method (list 'nnvirtual "^$"))
5996 (pgroup (gnus-group-prefixed-name group method)))
5997 ;; Check whether it exists already.
5998 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5999 (error "Group %s already exists." pgroup))
6000 ;; Subscribe the new group after the group on the current line.
6001 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
6002 (gnus-group-update-group pgroup)
6004 (gnus-group-position-point)))
6006 (defun gnus-group-enter-directory (dir)
6007 "Enter an ephemeral nneething group."
6008 (interactive "DDirectory to read: ")
6009 (let* ((method (list 'nneething dir))
6010 (leaf (gnus-group-prefixed-name
6011 (file-name-nondirectory (directory-file-name dir))
6013 (name (gnus-generate-new-group-name leaf)))
6014 (let ((nneething-read-only t))
6015 (or (gnus-group-read-ephemeral-group
6017 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
6019 (error "Couldn't enter %s" dir)))))
6021 ;; Group sorting commands
6022 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
6024 (defun gnus-group-sort-groups (func &optional reverse)
6025 "Sort the group buffer according to FUNC.
6026 If REVERSE, reverse the sorting order."
6027 (interactive (list gnus-group-sort-function
6028 current-prefix-arg))
6030 ((not (listp func)) func)
6032 ((= 1 (length func)) (car func))
6034 ,(gnus-make-sort-function
6035 (reverse func)))))))
6036 ;; We peel off the dummy group from the alist.
6038 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
6039 (pop gnus-newsrc-alist))
6041 (setq gnus-newsrc-alist
6042 (sort gnus-newsrc-alist func))
6044 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
6045 ;; Regenerate the hash table.
6046 (gnus-make-hashtable-from-newsrc-alist)
6047 (gnus-group-list-groups))))
6049 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
6050 "Sort the group buffer alphabetically by group name.
6051 If REVERSE, sort in reverse order."
6053 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
6055 (defun gnus-group-sort-groups-by-unread (&optional reverse)
6056 "Sort the group buffer by number of unread articles.
6057 If REVERSE, sort in reverse order."
6059 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
6061 (defun gnus-group-sort-groups-by-level (&optional reverse)
6062 "Sort the group buffer by group level.
6063 If REVERSE, sort in reverse order."
6065 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
6067 (defun gnus-group-sort-groups-by-score (&optional reverse)
6068 "Sort the group buffer by group score.
6069 If REVERSE, sort in reverse order."
6071 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
6073 (defun gnus-group-sort-groups-by-rank (&optional reverse)
6074 "Sort the group buffer by group rank.
6075 If REVERSE, sort in reverse order."
6077 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6079 (defun gnus-group-sort-groups-by-method (&optional reverse)
6080 "Sort the group buffer alphabetically by backend name.
6081 If REVERSE, sort in reverse order."
6083 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6085 (defun gnus-group-sort-by-alphabet (info1 info2)
6086 "Sort alphabetically."
6087 (string< (gnus-info-group info1) (gnus-info-group info2)))
6089 (defun gnus-group-sort-by-unread (info1 info2)
6090 "Sort by number of unread articles."
6091 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6092 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6093 (< (or (and (numberp n1) n1) 0)
6094 (or (and (numberp n2) n2) 0))))
6096 (defun gnus-group-sort-by-level (info1 info2)
6098 (< (gnus-info-level info1) (gnus-info-level info2)))
6100 (defun gnus-group-sort-by-method (info1 info2)
6101 "Sort alphabetically by backend name."
6102 (string< (symbol-name (car (gnus-find-method-for-group
6103 (gnus-info-group info1) info1)))
6104 (symbol-name (car (gnus-find-method-for-group
6105 (gnus-info-group info2) info2)))))
6107 (defun gnus-group-sort-by-score (info1 info2)
6108 "Sort by group score."
6109 (< (gnus-info-score info1) (gnus-info-score info2)))
6111 (defun gnus-group-sort-by-rank (info1 info2)
6112 "Sort by level and score."
6113 (let ((level1 (gnus-info-level info1))
6114 (level2 (gnus-info-level info2)))
6115 (or (< level1 level2)
6116 (and (= level1 level2)
6117 (> (gnus-info-score info1) (gnus-info-score info2))))))
6119 ;; Group catching up.
6121 (defun gnus-group-clear-data (n)
6122 "Clear all marks and read ranges from the current group."
6124 (let ((groups (gnus-group-process-prefix n))
6126 (while (setq group (pop groups))
6127 (setq info (gnus-get-info group))
6128 (gnus-info-set-read info nil)
6129 (when (gnus-info-marks info)
6130 (gnus-info-set-marks info nil))
6131 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6132 (when (gnus-group-goto-group group)
6133 (gnus-group-remove-mark group)
6134 (gnus-group-update-group-line)))))
6136 (defun gnus-group-catchup-current (&optional n all)
6137 "Mark all articles not marked as unread in current newsgroup as read.
6138 If prefix argument N is numeric, the ARG next newsgroups will be
6139 caught up. If ALL is non-nil, marked articles will also be marked as
6140 read. Cross references (Xref: header) of articles are ignored.
6141 The difference between N and actual number of newsgroups that were
6142 caught up is returned."
6144 (unless (gnus-group-group-name)
6145 (error "No group on the current line"))
6146 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6150 "Do you really want to mark all articles as read? "
6151 "Mark all unread articles as read? "))))
6153 (let ((groups (gnus-group-process-prefix n))
6156 ;; Virtual groups have to be given special treatment.
6157 (let ((method (gnus-find-method-for-group (car groups))))
6158 (if (eq 'nnvirtual (car method))
6159 (nnvirtual-catchup-group
6160 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6161 (gnus-group-remove-mark (car groups))
6162 (if (>= (gnus-group-group-level) gnus-level-zombie)
6163 (gnus-message 2 "Dead groups can't be caught up")
6165 (gnus-group-goto-group (car groups))
6166 (gnus-group-catchup (car groups) all))
6167 (gnus-group-update-group-line)
6168 (setq ret (1+ ret))))
6169 (setq groups (cdr groups)))
6170 (gnus-group-next-unread-group 1)
6173 (defun gnus-group-catchup-current-all (&optional n)
6174 "Mark all articles in current newsgroup as read.
6175 Cross references (Xref: header) of articles are ignored."
6177 (gnus-group-catchup-current n 'all))
6179 (defun gnus-group-catchup (group &optional all)
6180 "Mark all articles in GROUP as read.
6181 If ALL is non-nil, all articles are marked as read.
6182 The return value is the number of articles that were marked as read,
6183 or nil if no action could be taken."
6184 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6186 ;; Do the updating only if the newsgroup isn't killed.
6187 (if (not (numberp (car entry)))
6188 (gnus-message 1 "Can't catch up; non-active group")
6189 ;; Do auto-expirable marks if that's required.
6190 (when (gnus-group-auto-expirable-p group)
6191 (gnus-add-marked-articles
6192 group 'expire (gnus-list-of-unread-articles group))
6194 (let ((marks (nth 3 (nth 2 entry))))
6195 (gnus-add-marked-articles
6196 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6197 (gnus-add-marked-articles
6198 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6200 (gnus-update-read-articles group nil)
6201 ;; Also nix out the lists of marks and dormants.
6203 (gnus-add-marked-articles group 'tick nil nil 'force)
6204 (gnus-add-marked-articles group 'dormant nil nil 'force))
6205 (run-hooks 'gnus-group-catchup-group-hook)
6208 (defun gnus-group-expire-articles (&optional n)
6209 "Expire all expirable articles in the current newsgroup."
6211 (let ((groups (gnus-group-process-prefix n))
6214 (error "No groups to expire"))
6215 (while (setq group (pop groups))
6216 (gnus-group-remove-mark group)
6217 (when (gnus-check-backend-function 'request-expire-articles group)
6218 (gnus-message 6 "Expiring articles in %s..." group)
6219 (let* ((info (gnus-get-info group))
6220 (expirable (if (gnus-group-total-expirable-p group)
6221 (cons nil (gnus-list-of-read-articles group))
6222 (assq 'expire (gnus-info-marks info))))
6223 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6227 (gnus-compress-sequence
6229 ;; We set the expiry variables to the groupp
6231 (let ((nnmail-expiry-wait-function nil)
6232 (nnmail-expiry-wait expiry-wait))
6233 (gnus-request-expire-articles
6234 (gnus-uncompress-sequence (cdr expirable)) group))
6235 ;; Just expire using the normal expiry values.
6236 (gnus-request-expire-articles
6237 (gnus-uncompress-sequence (cdr expirable)) group))))
6238 (gnus-close-group group))
6239 (gnus-message 6 "Expiring articles in %s...done" group)))
6240 (gnus-group-position-point))))
6242 (defun gnus-group-expire-all-groups ()
6243 "Expire all expirable articles in all newsgroups."
6246 (gnus-message 5 "Expiring...")
6247 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6248 (cdr gnus-newsrc-alist))))
6249 (gnus-group-expire-articles nil)))
6250 (gnus-group-position-point)
6251 (gnus-message 5 "Expiring...done"))
6253 (defun gnus-group-set-current-level (n level)
6254 "Set the level of the next N groups to LEVEL."
6259 (let ((s (read-string
6260 (format "Level (default %s): "
6261 (or (gnus-group-group-level)
6262 gnus-level-default-subscribed)))))
6263 (if (string-match "^\\s-*$" s)
6264 (int-to-string (or (gnus-group-group-level)
6265 gnus-level-default-subscribed))
6267 (or (and (>= level 1) (<= level gnus-level-killed))
6268 (error "Illegal level: %d" level))
6269 (let ((groups (gnus-group-process-prefix n))
6271 (while (setq group (pop groups))
6272 (gnus-group-remove-mark group)
6273 (gnus-message 6 "Changed level of %s from %d to %d"
6274 group (or (gnus-group-group-level) gnus-level-killed)
6276 (gnus-group-change-level
6277 group level (or (gnus-group-group-level) gnus-level-killed))
6278 (gnus-group-update-group-line)))
6279 (gnus-group-position-point))
6281 (defun gnus-group-unsubscribe-current-group (&optional n)
6282 "Toggle subscription of the current group.
6283 If given numerical prefix, toggle the N next groups."
6285 (let ((groups (gnus-group-process-prefix n))
6288 (setq group (car groups)
6289 groups (cdr groups))
6290 (gnus-group-remove-mark group)
6291 (gnus-group-unsubscribe-group
6292 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6293 gnus-level-default-unsubscribed
6294 gnus-level-default-subscribed) t)
6295 (gnus-group-update-group-line))
6296 (gnus-group-next-group 1)))
6298 (defun gnus-group-unsubscribe-group (group &optional level silent)
6299 "Toggle subscription to GROUP.
6300 Killed newsgroups are subscribed. If SILENT, don't try to update the
6303 (list (completing-read
6304 "Group: " gnus-active-hashtb nil
6305 (gnus-read-active-file-p)
6307 'gnus-group-history)))
6308 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6310 ((string-match "^[ \t]$" group)
6311 (error "Empty group name"))
6313 ;; Toggle subscription flag.
6314 (gnus-group-change-level
6315 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6316 gnus-level-subscribed)
6317 (1+ gnus-level-subscribed)
6318 gnus-level-default-subscribed)))
6320 (gnus-group-update-group group)))
6321 ((and (stringp group)
6322 (or (not (gnus-read-active-file-p))
6323 (gnus-active group)))
6324 ;; Add new newsgroup.
6325 (gnus-group-change-level
6327 (if level level gnus-level-default-subscribed)
6328 (or (and (member group gnus-zombie-list)
6331 (and (gnus-group-group-name)
6332 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6334 (gnus-group-update-group group)))
6335 (t (error "No such newsgroup: %s" group)))
6336 (gnus-group-position-point)))
6338 (defun gnus-group-transpose-groups (n)
6339 "Move the current newsgroup up N places.
6340 If given a negative prefix, move down instead. The difference between
6341 N and the number of steps taken is returned."
6343 (or (gnus-group-group-name)
6344 (error "No group on current line"))
6345 (gnus-group-kill-group 1)
6347 (forward-line (- n))
6348 (gnus-group-yank-group)
6349 (gnus-group-position-point)))
6351 (defun gnus-group-kill-all-zombies ()
6352 "Kill all zombie newsgroups."
6354 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6355 (setq gnus-zombie-list nil)
6356 (gnus-group-list-groups))
6358 (defun gnus-group-kill-region (begin end)
6359 "Kill newsgroups in current region (excluding current point).
6360 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6375 (beginning-of-line) ;Important when LINES < 1
6376 (gnus-group-kill-group lines)))
6378 (defun gnus-group-kill-group (&optional n discard)
6379 "Kill the next N groups.
6380 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6381 However, only groups that were alive can be yanked; already killed
6382 groups or zombie groups can't be yanked.
6383 The return value is the name of the group that was killed, or a list
6386 (let ((buffer-read-only nil)
6387 (groups (gnus-group-process-prefix n))
6388 group entry level out)
6389 (if (< (length groups) 10)
6390 ;; This is faster when there are few groups.
6392 (push (setq group (pop groups)) out)
6393 (gnus-group-remove-mark group)
6394 (setq level (gnus-group-group-level))
6396 (when (and (not discard)
6397 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6398 (push (cons (car entry) (nth 2 entry))
6399 gnus-list-of-killed-groups))
6400 (gnus-group-change-level
6401 (if entry entry group) gnus-level-killed (if entry nil level)))
6402 ;; If there are lots and lots of groups to be killed, we use
6403 ;; this thing instead.
6405 (setq groups (nreverse groups))
6407 (gnus-group-remove-mark (setq group (pop groups)))
6409 (push group gnus-killed-list)
6410 (setq gnus-newsrc-alist
6411 (delq (assoc group gnus-newsrc-alist)
6413 (when gnus-group-change-level-function
6414 (funcall gnus-group-change-level-function group 9 3))
6416 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6417 (push (cons (car entry) (nth 2 entry))
6418 gnus-list-of-killed-groups)
6419 (setcdr (cdr entry) (cdddr entry)))
6420 ((member group gnus-zombie-list)
6421 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6422 (gnus-make-hashtable-from-newsrc-alist)))
6424 (gnus-group-position-point)
6425 (if (< (length out) 2) (car out) (nreverse out))))
6427 (defun gnus-group-yank-group (&optional arg)
6428 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6429 inserting it before the current newsgroup. The numeric ARG specifies
6430 how many newsgroups are to be yanked. The name of the newsgroup yanked
6431 is returned, or (if several groups are yanked) a list of yanked groups
6434 (setq arg (or arg 1))
6435 (let (info group prev out)
6436 (while (>= (decf arg) 0)
6437 (if (not (setq info (pop gnus-list-of-killed-groups)))
6438 (error "No more newsgroups to yank"))
6439 (push (setq group (nth 1 info)) out)
6440 ;; Find which newsgroup to insert this one before - search
6441 ;; backward until something suitable is found. If there are no
6442 ;; other newsgroups in this buffer, just make this newsgroup the
6444 (setq prev (gnus-group-group-name))
6445 (gnus-group-change-level
6446 info (gnus-info-level (cdr info)) gnus-level-killed
6447 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6449 (gnus-group-insert-group-line-info group))
6451 (gnus-group-position-point)
6452 (if (< (length out) 2) (car out) (nreverse out))))
6454 (defun gnus-group-kill-level (level)
6455 "Kill all groups that is on a certain LEVEL."
6456 (interactive "nKill all groups on level: ")
6458 ((= level gnus-level-zombie)
6459 (setq gnus-killed-list
6460 (nconc gnus-zombie-list gnus-killed-list))
6461 (setq gnus-zombie-list nil))
6462 ((and (< level gnus-level-zombie)
6464 (or gnus-expert-user
6467 "Do you really want to kill all groups on level %d? "
6469 (let* ((prev gnus-newsrc-alist)
6472 (if (= (gnus-info-level (car alist)) level)
6474 (push (gnus-info-group (car alist)) gnus-killed-list)
6475 (setcdr prev (cdr alist)))
6477 (setq alist (cdr alist)))
6478 (gnus-make-hashtable-from-newsrc-alist)
6479 (gnus-group-list-groups)))
6481 (error "Can't kill; illegal level: %d" level))))
6483 (defun gnus-group-list-all-groups (&optional arg)
6484 "List all newsgroups with level ARG or lower.
6485 Default is gnus-level-unsubscribed, which lists all subscribed and most
6486 unsubscribed groups."
6488 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6490 ;; Redefine this to list ALL killed groups if prefix arg used.
6491 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6492 (defun gnus-group-list-killed (&optional arg)
6493 "List all killed newsgroups in the group buffer.
6494 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6495 entail asking the server for the groups."
6497 ;; Find all possible killed newsgroups if arg.
6499 (gnus-get-killed-groups))
6500 (if (not gnus-killed-list)
6501 (gnus-message 6 "No killed groups")
6502 (let (gnus-group-list-mode)
6503 (funcall gnus-group-prepare-function
6504 gnus-level-killed t gnus-level-killed))
6505 (goto-char (point-min)))
6506 (gnus-group-position-point))
6508 (defun gnus-group-list-zombies ()
6509 "List all zombie newsgroups in the group buffer."
6511 (if (not gnus-zombie-list)
6512 (gnus-message 6 "No zombie groups")
6513 (let (gnus-group-list-mode)
6514 (funcall gnus-group-prepare-function
6515 gnus-level-zombie t gnus-level-zombie))
6516 (goto-char (point-min)))
6517 (gnus-group-position-point))
6519 (defun gnus-group-list-active ()
6520 "List all groups that are available from the server(s)."
6522 ;; First we make sure that we have really read the active file.
6523 (unless (gnus-read-active-file-p)
6524 (let ((gnus-read-active-file t))
6525 (gnus-read-active-file)))
6526 ;; Find all groups and sort them.
6534 (setq list (cons (symbol-name sym) list))))
6538 (buffer-read-only nil))
6541 (gnus-group-insert-group-line-info (pop groups)))
6542 (goto-char (point-min))))
6544 (defun gnus-activate-all-groups (level)
6545 "Activate absolutely all groups."
6546 (interactive (list 7))
6547 (let ((gnus-activate-level level)
6548 (gnus-activate-foreign-newsgroups level))
6549 (gnus-group-get-new-news)))
6551 (defun gnus-group-get-new-news (&optional arg)
6552 "Get newly arrived articles.
6553 If ARG is a number, it specifies which levels you are interested in
6554 re-scanning. If ARG is non-nil and not a number, this will force
6555 \"hard\" re-reading of the active files from all servers."
6557 (run-hooks 'gnus-get-new-news-hook)
6558 ;; We might read in new NoCeM messages here.
6559 (when (and gnus-use-nocem
6561 (gnus-nocem-scan-groups))
6562 ;; If ARG is not a number, then we read the active file.
6563 (when (and arg (not (numberp arg)))
6564 (let ((gnus-read-active-file t))
6565 (gnus-read-active-file))
6568 (setq arg (gnus-group-default-level arg t))
6569 (if (and gnus-read-active-file (not arg))
6571 (gnus-read-active-file)
6572 (gnus-get-unread-articles arg))
6573 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6574 (gnus-get-unread-articles arg)))
6575 (run-hooks 'gnus-after-getting-new-news-hook)
6576 (gnus-group-list-groups))
6578 (defun gnus-group-get-new-news-this-group (&optional n)
6579 "Check for newly arrived news in the current group (and the N-1 next groups).
6580 The difference between N and the number of newsgroup checked is returned.
6581 If N is negative, this group and the N-1 previous groups will be checked."
6583 (let* ((groups (gnus-group-process-prefix n))
6584 (ret (if (numberp n) (- n (length groups)) 0))
6585 (beg (unless n (point)))
6587 (while (setq group (pop groups))
6588 (gnus-group-remove-mark group)
6589 (if (gnus-activate-group group 'scan)
6591 (gnus-get-unread-articles-in-group
6592 (gnus-get-info group) (gnus-active group) t)
6593 (unless (gnus-virtual-group-p group)
6594 (gnus-close-group group))
6595 (gnus-group-update-group group))
6596 (if (eq (gnus-server-status (gnus-find-method-for-group group))
6598 (gnus-error "Server denied access")
6599 (gnus-error 3 "%s error: %s" group (gnus-status-message group)))))
6600 (when beg (goto-char beg))
6601 (when gnus-goto-next-group-when-activating
6602 (gnus-group-next-unread-group 1 t))
6603 (gnus-summary-position-point)
6606 (defun gnus-group-fetch-faq (group &optional faq-dir)
6607 "Fetch the FAQ for the current group."
6610 (and (gnus-group-group-name)
6611 (gnus-group-real-name (gnus-group-group-name)))
6612 (cond (current-prefix-arg
6614 "Faq dir: " (and (listp gnus-group-faq-directory)
6615 (mapcar (lambda (file) (list file))
6616 gnus-group-faq-directory)))))))
6618 (setq faq-dir (if (listp gnus-group-faq-directory)
6619 (car gnus-group-faq-directory)
6620 gnus-group-faq-directory)))
6621 (or group (error "No group name given"))
6622 (let ((file (concat (file-name-as-directory faq-dir)
6623 (gnus-group-real-name group))))
6624 (if (not (file-exists-p file))
6625 (error "No such file: %s" file)
6628 (defun gnus-group-describe-group (force &optional group)
6629 "Display a description of the current newsgroup."
6630 (interactive (list current-prefix-arg (gnus-group-group-name)))
6631 (let* ((method (gnus-find-method-for-group group))
6632 (mname (gnus-group-prefixed-name "" method))
6635 gnus-description-hashtb)
6636 (gnus-sethash mname nil gnus-description-hashtb))
6637 (or group (error "No group name given"))
6638 (and (or (and gnus-description-hashtb
6639 ;; We check whether this group's method has been
6640 ;; queried for a description file.
6641 (gnus-gethash mname gnus-description-hashtb))
6642 (setq desc (gnus-group-get-description group))
6643 (gnus-read-descriptions-file method))
6645 (or desc (gnus-gethash group gnus-description-hashtb)
6646 "No description available")))))
6648 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6649 (defun gnus-group-describe-all-groups (&optional force)
6650 "Pop up a buffer with descriptions of all newsgroups."
6652 (and force (setq gnus-description-hashtb nil))
6653 (if (not (or gnus-description-hashtb
6654 (gnus-read-all-descriptions-files)))
6655 (error "Couldn't request descriptions file"))
6656 (let ((buffer-read-only nil)
6662 (insert (format " *: %-20s %s\n" (symbol-name group)
6663 (symbol-value group)))
6664 (gnus-add-text-properties
6665 b (1+ b) (list 'gnus-group group
6666 'gnus-unread t 'gnus-marked nil
6667 'gnus-level (1+ gnus-level-subscribed))))
6668 gnus-description-hashtb)
6669 (goto-char (point-min))
6670 (gnus-group-position-point)))
6672 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6673 (defun gnus-group-apropos (regexp &optional search-description)
6674 "List all newsgroups that have names that match a regexp."
6675 (interactive "sGnus apropos (regexp): ")
6677 (obuf (current-buffer))
6679 ;; Go through all newsgroups that are known to Gnus.
6682 (and (symbol-name group)
6683 (string-match regexp (symbol-name group))
6684 (setq groups (cons (symbol-name group) groups))))
6686 ;; Also go through all descriptions that are known to Gnus.
6687 (when search-description
6690 (and (string-match regexp (symbol-value group))
6691 (gnus-active (symbol-name group))
6692 (setq groups (cons (symbol-name group) groups))))
6693 gnus-description-hashtb))
6695 (gnus-message 3 "No groups matched \"%s\"." regexp)
6696 ;; Print out all the groups.
6698 (pop-to-buffer "*Gnus Help*")
6699 (buffer-disable-undo (current-buffer))
6701 (setq groups (sort groups 'string<))
6703 ;; Groups may be entered twice into the list of groups.
6704 (if (not (string= (car groups) prev))
6706 (insert (setq prev (car groups)) "\n")
6707 (if (and gnus-description-hashtb
6708 (setq des (gnus-gethash (car groups)
6709 gnus-description-hashtb)))
6710 (insert " " des "\n"))))
6711 (setq groups (cdr groups)))
6712 (goto-char (point-min))))
6713 (pop-to-buffer obuf)))
6715 (defun gnus-group-description-apropos (regexp)
6716 "List all newsgroups that have names or descriptions that match a regexp."
6717 (interactive "sGnus description apropos (regexp): ")
6718 (if (not (or gnus-description-hashtb
6719 (gnus-read-all-descriptions-files)))
6720 (error "Couldn't request descriptions file"))
6721 (gnus-group-apropos regexp t))
6723 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6724 (defun gnus-group-list-matching (level regexp &optional all lowest)
6725 "List all groups with unread articles that match REGEXP.
6726 If the prefix LEVEL is non-nil, it should be a number that says which
6727 level to cut off listing groups.
6728 If ALL, also list groups with no unread articles.
6729 If LOWEST, don't list groups with level lower than LOWEST.
6731 This command may read the active file."
6732 (interactive "P\nsList newsgroups matching: ")
6733 ;; First make sure active file has been read.
6735 (> (prefix-numeric-value level) gnus-level-killed))
6736 (gnus-get-killed-groups))
6737 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6738 all (or lowest 1) regexp)
6739 (goto-char (point-min))
6740 (gnus-group-position-point))
6742 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6743 "List all groups that match REGEXP.
6744 If the prefix LEVEL is non-nil, it should be a number that says which
6745 level to cut off listing groups.
6746 If LOWEST, don't list groups with level lower than LOWEST."
6747 (interactive "P\nsList newsgroups matching: ")
6748 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6750 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6751 (defun gnus-group-save-newsrc (&optional force)
6752 "Save the Gnus startup files.
6753 If FORCE, force saving whether it is necessary or not."
6755 (gnus-save-newsrc-file force))
6757 (defun gnus-group-restart (&optional arg)
6758 "Force Gnus to read the .newsrc file."
6760 (when (gnus-yes-or-no-p
6761 (format "Are you sure you want to read %s? "
6762 gnus-current-startup-file))
6763 (gnus-save-newsrc-file)
6764 (gnus-setup-news 'force)
6765 (gnus-group-list-groups arg)))
6767 (defun gnus-group-read-init-file ()
6768 "Read the Gnus elisp init file."
6770 (gnus-read-init-file))
6772 (defun gnus-group-check-bogus-groups (&optional silent)
6773 "Check bogus newsgroups.
6774 If given a prefix, don't ask for confirmation before removing a bogus
6777 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6778 (gnus-group-list-groups))
6780 (defun gnus-group-edit-global-kill (&optional article group)
6781 "Edit the global kill file.
6782 If GROUP, edit that local kill file instead."
6784 (setq gnus-current-kill-article article)
6785 (gnus-kill-file-edit-file group)
6788 (substitute-command-keys
6789 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6790 (if group "local" "global")))))
6792 (defun gnus-group-edit-local-kill (article group)
6793 "Edit a local kill file."
6794 (interactive (list nil (gnus-group-group-name)))
6795 (gnus-group-edit-global-kill article group))
6797 (defun gnus-group-force-update ()
6798 "Update `.newsrc' file."
6800 (gnus-save-newsrc-file))
6802 (defun gnus-group-suspend ()
6803 "Suspend the current Gnus session.
6804 In fact, cleanup buffers except for group mode buffer.
6805 The hook gnus-suspend-gnus-hook is called before actually suspending."
6807 (run-hooks 'gnus-suspend-gnus-hook)
6808 ;; Kill Gnus buffers except for group mode buffer.
6809 (let* ((group-buf (get-buffer gnus-group-buffer))
6810 ;; Do this on a separate list in case the user does a ^G before we finish
6812 (delete group-buf (delete gnus-dribble-buffer
6813 (append gnus-buffer-list nil)))))
6814 (while gnus-buffer-list
6815 (gnus-kill-buffer (pop gnus-buffer-list)))
6816 (gnus-kill-gnus-frames)
6818 (setq gnus-buffer-list (list group-buf))
6819 (bury-buffer group-buf)
6820 (delete-windows-on group-buf t))))
6822 (defun gnus-group-clear-dribble ()
6823 "Clear all information from the dribble buffer."
6825 (gnus-dribble-clear)
6826 (gnus-message 7 "Cleared dribble buffer"))
6828 (defun gnus-group-exit ()
6829 "Quit reading news after updating .newsrc.eld and .newsrc.
6830 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6833 (or noninteractive ;For gnus-batch-kill
6834 (not gnus-interactive-exit) ;Without confirmation
6836 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6837 (run-hooks 'gnus-exit-gnus-hook)
6838 ;; Offer to save data from non-quitted summary buffers.
6839 (gnus-offer-save-summaries)
6840 ;; Save the newsrc file(s).
6841 (gnus-save-newsrc-file)
6843 (gnus-close-backends)
6844 ;; Reset everything.
6846 ;; Allow the user to do things after cleaning up.
6847 (run-hooks 'gnus-after-exiting-gnus-hook)))
6849 (defun gnus-close-backends ()
6850 ;; Send a close request to all backends that support such a request.
6851 (let ((methods gnus-valid-select-methods)
6854 (if (fboundp (setq func (intern (concat (caar methods)
6855 "-request-close"))))
6857 (setq methods (cdr methods)))))
6859 (defun gnus-group-quit ()
6860 "Quit reading news without updating .newsrc.eld or .newsrc.
6861 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6863 (when (or noninteractive ;For gnus-batch-kill
6864 (zerop (buffer-size))
6865 (not (gnus-server-opened gnus-select-method))
6867 (not gnus-current-startup-file)
6869 (format "Quit reading news without saving %s? "
6870 (file-name-nondirectory gnus-current-startup-file))))
6871 (run-hooks 'gnus-exit-gnus-hook)
6872 (if gnus-use-full-window
6873 (delete-other-windows)
6874 (gnus-remove-some-windows))
6876 (gnus-close-backends)
6878 ;; Allow the user to do things after cleaning up.
6879 (run-hooks 'gnus-after-exiting-gnus-hook)))
6881 (defun gnus-offer-save-summaries ()
6882 "Offer to save all active summary buffers."
6884 (let ((buflist (buffer-list))
6886 ;; Go through all buffers and find all summaries.
6888 (and (setq bufname (buffer-name (car buflist)))
6889 (string-match "Summary" bufname)
6891 (set-buffer bufname)
6892 ;; We check that this is, indeed, a summary buffer.
6893 (and (eq major-mode 'gnus-summary-mode)
6894 ;; Also make sure this isn't bogus.
6895 gnus-newsgroup-prepared))
6896 (push bufname buffers))
6897 (setq buflist (cdr buflist)))
6898 ;; Go through all these summary buffers and offer to save them.
6901 "Update summary buffer %s? "
6902 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6905 (defun gnus-group-describe-briefly ()
6906 "Give a one line description of the group mode commands."
6908 (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")))
6910 (defun gnus-group-browse-foreign-server (method)
6911 "Browse a foreign news server.
6912 If called interactively, this function will ask for a select method
6913 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6914 If not, METHOD should be a list where the first element is the method
6915 and the second element is the address."
6917 (list (let ((how (completing-read
6919 (append gnus-valid-select-methods gnus-server-alist)
6920 nil t (cons "nntp" 0) 'gnus-method-history)))
6921 ;; We either got a backend name or a virtual server name.
6922 ;; If the first, we also need an address.
6923 (if (assoc how gnus-valid-select-methods)
6925 ;; Suggested by mapjph@bath.ac.uk.
6928 (mapcar (lambda (server) (list server))
6929 gnus-secondary-servers)))
6930 ;; We got a server name, so we find the method.
6931 (gnus-server-to-method how)))))
6932 (gnus-browse-foreign-server method))
6936 ;;; Gnus summary mode
6939 (defvar gnus-summary-mode-map nil)
6941 (put 'gnus-summary-mode 'mode-class 'special)
6943 (unless gnus-summary-mode-map
6944 (setq gnus-summary-mode-map (make-keymap))
6945 (suppress-keymap gnus-summary-mode-map)
6947 ;; Non-orthogonal keys
6949 (gnus-define-keys gnus-summary-mode-map
6950 " " gnus-summary-next-page
6951 "\177" gnus-summary-prev-page
6952 [delete] gnus-summary-prev-page
6953 "\r" gnus-summary-scroll-up
6954 "n" gnus-summary-next-unread-article
6955 "p" gnus-summary-prev-unread-article
6956 "N" gnus-summary-next-article
6957 "P" gnus-summary-prev-article
6958 "\M-\C-n" gnus-summary-next-same-subject
6959 "\M-\C-p" gnus-summary-prev-same-subject
6960 "\M-n" gnus-summary-next-unread-subject
6961 "\M-p" gnus-summary-prev-unread-subject
6962 "." gnus-summary-first-unread-article
6963 "," gnus-summary-best-unread-article
6964 "\M-s" gnus-summary-search-article-forward
6965 "\M-r" gnus-summary-search-article-backward
6966 "<" gnus-summary-beginning-of-article
6967 ">" gnus-summary-end-of-article
6968 "j" gnus-summary-goto-article
6969 "^" gnus-summary-refer-parent-article
6970 "\M-^" gnus-summary-refer-article
6971 "u" gnus-summary-tick-article-forward
6972 "!" gnus-summary-tick-article-forward
6973 "U" gnus-summary-tick-article-backward
6974 "d" gnus-summary-mark-as-read-forward
6975 "D" gnus-summary-mark-as-read-backward
6976 "E" gnus-summary-mark-as-expirable
6977 "\M-u" gnus-summary-clear-mark-forward
6978 "\M-U" gnus-summary-clear-mark-backward
6979 "k" gnus-summary-kill-same-subject-and-select
6980 "\C-k" gnus-summary-kill-same-subject
6981 "\M-\C-k" gnus-summary-kill-thread
6982 "\M-\C-l" gnus-summary-lower-thread
6983 "e" gnus-summary-edit-article
6984 "#" gnus-summary-mark-as-processable
6985 "\M-#" gnus-summary-unmark-as-processable
6986 "\M-\C-t" gnus-summary-toggle-threads
6987 "\M-\C-s" gnus-summary-show-thread
6988 "\M-\C-h" gnus-summary-hide-thread
6989 "\M-\C-f" gnus-summary-next-thread
6990 "\M-\C-b" gnus-summary-prev-thread
6991 "\M-\C-u" gnus-summary-up-thread
6992 "\M-\C-d" gnus-summary-down-thread
6993 "&" gnus-summary-execute-command
6994 "c" gnus-summary-catchup-and-exit
6995 "\C-w" gnus-summary-mark-region-as-read
6996 "\C-t" gnus-summary-toggle-truncation
6997 "?" gnus-summary-mark-as-dormant
6998 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6999 "\C-c\C-s\C-n" gnus-summary-sort-by-number
7000 "\C-c\C-s\C-a" gnus-summary-sort-by-author
7001 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
7002 "\C-c\C-s\C-d" gnus-summary-sort-by-date
7003 "\C-c\C-s\C-i" gnus-summary-sort-by-score
7004 "=" gnus-summary-expand-window
7005 "\C-x\C-s" gnus-summary-reselect-current-group
7006 "\M-g" gnus-summary-rescan-group
7007 "w" gnus-summary-stop-page-breaking
7008 "\C-c\C-r" gnus-summary-caesar-message
7009 "\M-t" gnus-summary-toggle-mime
7010 "f" gnus-summary-followup
7011 "F" gnus-summary-followup-with-original
7012 "C" gnus-summary-cancel-article
7013 "r" gnus-summary-reply
7014 "R" gnus-summary-reply-with-original
7015 "\C-c\C-f" gnus-summary-mail-forward
7016 "o" gnus-summary-save-article
7017 "\C-o" gnus-summary-save-article-mail
7018 "|" gnus-summary-pipe-output
7019 "\M-k" gnus-summary-edit-local-kill
7020 "\M-K" gnus-summary-edit-global-kill
7022 "\C-c\C-d" gnus-summary-describe-group
7023 "q" gnus-summary-exit
7024 "Q" gnus-summary-exit-no-update
7025 "\C-c\C-i" gnus-info-find-node
7026 gnus-mouse-2 gnus-mouse-pick-article
7027 "m" gnus-summary-mail-other-window
7028 "a" gnus-summary-post-news
7029 "x" gnus-summary-limit-to-unread
7030 "s" gnus-summary-isearch-article
7031 "t" gnus-article-hide-headers
7032 "g" gnus-summary-show-article
7033 "l" gnus-summary-goto-last-article
7034 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
7035 "\C-d" gnus-summary-enter-digest-group
7037 "*" gnus-cache-enter-article
7038 "\M-*" gnus-cache-remove-article
7039 "\M-&" gnus-summary-universal-argument
7040 "\C-l" gnus-recenter
7041 "I" gnus-summary-increase-score
7042 "L" gnus-summary-lower-score
7044 "V" gnus-summary-score-map
7045 "X" gnus-uu-extract-map
7046 "S" gnus-summary-send-map)
7048 ;; Sort of orthogonal keymap
7049 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
7050 "t" gnus-summary-tick-article-forward
7051 "!" gnus-summary-tick-article-forward
7052 "d" gnus-summary-mark-as-read-forward
7053 "r" gnus-summary-mark-as-read-forward
7054 "c" gnus-summary-clear-mark-forward
7055 " " gnus-summary-clear-mark-forward
7056 "e" gnus-summary-mark-as-expirable
7057 "x" gnus-summary-mark-as-expirable
7058 "?" gnus-summary-mark-as-dormant
7059 "b" gnus-summary-set-bookmark
7060 "B" gnus-summary-remove-bookmark
7061 "#" gnus-summary-mark-as-processable
7062 "\M-#" gnus-summary-unmark-as-processable
7063 "S" gnus-summary-limit-include-expunged
7064 "C" gnus-summary-catchup
7065 "H" gnus-summary-catchup-to-here
7066 "\C-c" gnus-summary-catchup-all
7067 "k" gnus-summary-kill-same-subject-and-select
7068 "K" gnus-summary-kill-same-subject
7069 "P" gnus-uu-mark-map)
7071 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
7072 "c" gnus-summary-clear-above
7073 "u" gnus-summary-tick-above
7074 "m" gnus-summary-mark-above
7075 "k" gnus-summary-kill-below)
7077 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
7078 "/" gnus-summary-limit-to-subject
7079 "n" gnus-summary-limit-to-articles
7080 "w" gnus-summary-pop-limit
7081 "s" gnus-summary-limit-to-subject
7082 "a" gnus-summary-limit-to-author
7083 "u" gnus-summary-limit-to-unread
7084 "m" gnus-summary-limit-to-marks
7085 "v" gnus-summary-limit-to-score
7086 "D" gnus-summary-limit-include-dormant
7087 "d" gnus-summary-limit-exclude-dormant
7088 ;; "t" gnus-summary-limit-exclude-thread
7089 "E" gnus-summary-limit-include-expunged
7090 "c" gnus-summary-limit-exclude-childless-dormant
7091 "C" gnus-summary-limit-mark-excluded-as-read)
7093 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7094 "n" gnus-summary-next-unread-article
7095 "p" gnus-summary-prev-unread-article
7096 "N" gnus-summary-next-article
7097 "P" gnus-summary-prev-article
7098 "\C-n" gnus-summary-next-same-subject
7099 "\C-p" gnus-summary-prev-same-subject
7100 "\M-n" gnus-summary-next-unread-subject
7101 "\M-p" gnus-summary-prev-unread-subject
7102 "f" gnus-summary-first-unread-article
7103 "b" gnus-summary-best-unread-article
7104 "j" gnus-summary-goto-article
7105 "g" gnus-summary-goto-subject
7106 "l" gnus-summary-goto-last-article
7107 "p" gnus-summary-pop-article)
7109 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7110 "k" gnus-summary-kill-thread
7111 "l" gnus-summary-lower-thread
7112 "i" gnus-summary-raise-thread
7113 "T" gnus-summary-toggle-threads
7114 "t" gnus-summary-rethread-current
7115 "^" gnus-summary-reparent-thread
7116 "s" gnus-summary-show-thread
7117 "S" gnus-summary-show-all-threads
7118 "h" gnus-summary-hide-thread
7119 "H" gnus-summary-hide-all-threads
7120 "n" gnus-summary-next-thread
7121 "p" gnus-summary-prev-thread
7122 "u" gnus-summary-up-thread
7123 "o" gnus-summary-top-thread
7124 "d" gnus-summary-down-thread
7125 "#" gnus-uu-mark-thread
7126 "\M-#" gnus-uu-unmark-thread)
7128 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7129 "c" gnus-summary-catchup-and-exit
7130 "C" gnus-summary-catchup-all-and-exit
7131 "E" gnus-summary-exit-no-update
7132 "Q" gnus-summary-exit
7133 "Z" gnus-summary-exit
7134 "n" gnus-summary-catchup-and-goto-next-group
7135 "R" gnus-summary-reselect-current-group
7136 "G" gnus-summary-rescan-group
7137 "N" gnus-summary-next-group
7138 "P" gnus-summary-prev-group)
7140 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7141 " " gnus-summary-next-page
7142 "n" gnus-summary-next-page
7143 "\177" gnus-summary-prev-page
7144 [delete] gnus-summary-prev-page
7145 "p" gnus-summary-prev-page
7146 "\r" gnus-summary-scroll-up
7147 "<" gnus-summary-beginning-of-article
7148 ">" gnus-summary-end-of-article
7149 "b" gnus-summary-beginning-of-article
7150 "e" gnus-summary-end-of-article
7151 "^" gnus-summary-refer-parent-article
7152 "r" gnus-summary-refer-parent-article
7153 "R" gnus-summary-refer-references
7154 "g" gnus-summary-show-article
7155 "s" gnus-summary-isearch-article)
7157 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7158 "b" gnus-article-add-buttons
7159 "B" gnus-article-add-buttons-to-head
7160 "o" gnus-article-treat-overstrike
7161 ;; "w" gnus-article-word-wrap
7162 "w" gnus-article-fill-cited-article
7163 "c" gnus-article-remove-cr
7164 "L" gnus-article-remove-trailing-blank-lines
7165 "q" gnus-article-de-quoted-unreadable
7166 "f" gnus-article-display-x-face
7167 "l" gnus-summary-stop-page-breaking
7168 "r" gnus-summary-caesar-message
7169 "t" gnus-article-hide-headers
7170 "v" gnus-summary-verbose-headers
7171 "m" gnus-summary-toggle-mime)
7173 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7174 "a" gnus-article-hide
7175 "h" gnus-article-hide-headers
7176 "b" gnus-article-hide-boring-headers
7177 "s" gnus-article-hide-signature
7178 "c" gnus-article-hide-citation
7179 "p" gnus-article-hide-pgp
7180 "P" gnus-article-hide-pem
7181 "\C-c" gnus-article-hide-citation-maybe)
7183 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7184 "a" gnus-article-highlight
7185 "h" gnus-article-highlight-headers
7186 "c" gnus-article-highlight-citation
7187 "s" gnus-article-highlight-signature)
7189 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7190 "z" gnus-article-date-ut
7191 "u" gnus-article-date-ut
7192 "l" gnus-article-date-local
7193 "e" gnus-article-date-lapsed
7194 "o" gnus-article-date-original)
7196 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7198 "f" gnus-summary-fetch-faq
7199 "d" gnus-summary-describe-group
7200 "h" gnus-summary-describe-briefly
7201 "i" gnus-info-find-node)
7203 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7204 "e" gnus-summary-expire-articles
7205 "\M-\C-e" gnus-summary-expire-articles-now
7206 "\177" gnus-summary-delete-article
7207 [delete] gnus-summary-delete-article
7208 "m" gnus-summary-move-article
7209 "r" gnus-summary-respool-article
7210 "w" gnus-summary-edit-article
7211 "c" gnus-summary-copy-article
7212 "B" gnus-summary-crosspost-article
7213 "q" gnus-summary-respool-query
7214 "i" gnus-summary-import-article)
7216 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7217 "o" gnus-summary-save-article
7218 "m" gnus-summary-save-article-mail
7219 "r" gnus-summary-save-article-rmail
7220 "f" gnus-summary-save-article-file
7221 "b" gnus-summary-save-article-body-file
7222 "h" gnus-summary-save-article-folder
7223 "v" gnus-summary-save-article-vm
7224 "p" gnus-summary-pipe-output
7225 "s" gnus-soup-add-article)
7230 (defun gnus-summary-mode (&optional group)
7231 "Major mode for reading articles.
7233 All normal editing commands are switched off.
7234 \\<gnus-summary-mode-map>
7235 Each line in this buffer represents one article. To read an
7236 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7237 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7240 You can also post articles and send mail from this buffer. To
7241 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7242 of an article, type `\\[gnus-summary-reply]'.
7244 There are approx. one gazillion commands you can execute in this
7245 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7247 The following commands are available:
7249 \\{gnus-summary-mode-map}"
7251 (when (and menu-bar-mode
7252 (gnus-visual-p 'summary-menu 'menu))
7253 (gnus-summary-make-menu-bar))
7254 (kill-all-local-variables)
7255 (gnus-summary-make-local-variables)
7256 (gnus-make-thread-indent-array)
7257 (gnus-simplify-mode-line)
7258 (setq major-mode 'gnus-summary-mode)
7259 (setq mode-name "Summary")
7260 (make-local-variable 'minor-mode-alist)
7261 (use-local-map gnus-summary-mode-map)
7262 (buffer-disable-undo (current-buffer))
7263 (setq buffer-read-only t) ;Disable modification
7264 (setq truncate-lines t)
7265 (setq selective-display t)
7266 (setq selective-display-ellipses t) ;Display `...'
7267 (setq buffer-display-table gnus-summary-display-table)
7268 (setq gnus-newsgroup-name group)
7269 (make-local-variable 'gnus-summary-line-format)
7270 (make-local-variable 'gnus-summary-line-format-spec)
7271 (make-local-variable 'gnus-summary-mark-positions)
7272 (gnus-make-local-hook 'post-command-hook)
7273 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
7274 (run-hooks 'gnus-summary-mode-hook))
7276 (defun gnus-summary-make-local-variables ()
7277 "Make all the local summary buffer variables."
7278 (let ((locals gnus-summary-local-variables)
7280 (while (setq local (pop locals))
7283 (if (eq (cdr local) 'global)
7284 ;; Copy the global value of the variable.
7285 (setq global (symbol-value (car local)))
7286 ;; Use the value from the list.
7287 (setq global (eval (cdr local))))
7288 (make-local-variable (car local))
7289 (set (car local) global))
7290 ;; Simple nil-valued local variable.
7291 (make-local-variable local)
7294 (defun gnus-summary-make-display-table ()
7295 ;; Change the display table. Odd characters have a tendency to mess
7296 ;; up nicely formatted displays - we make all possible glyphs
7297 ;; display only a single character.
7299 ;; We start from the standard display table, if any.
7300 (setq gnus-summary-display-table
7301 (or (copy-sequence standard-display-table)
7302 (make-display-table)))
7303 ;; Nix out all the control chars...
7305 (while (>= (setq i (1- i)) 0)
7306 (aset gnus-summary-display-table i [??])))
7307 ;; ... but not newline and cr, of course. (cr is necessary for the
7308 ;; selective display).
7309 (aset gnus-summary-display-table ?\n nil)
7310 (aset gnus-summary-display-table ?\r nil)
7311 ;; We nix out any glyphs over 126 that are not set already.
7313 (while (>= (setq i (1- i)) 127)
7314 ;; Only modify if the entry is nil.
7315 (or (aref gnus-summary-display-table i)
7316 (aset gnus-summary-display-table i [??])))))
7318 (defun gnus-summary-clear-local-variables ()
7319 (let ((locals gnus-summary-local-variables))
7321 (if (consp (car locals))
7322 (and (vectorp (caar locals))
7323 (set (caar locals) nil))
7324 (and (vectorp (car locals))
7325 (set (car locals) nil)))
7326 (setq locals (cdr locals)))))
7328 ;; Summary data functions.
7330 (defmacro gnus-data-number (data)
7333 (defmacro gnus-data-set-number (data number)
7334 `(setcar ,data ,number))
7336 (defmacro gnus-data-mark (data)
7339 (defmacro gnus-data-set-mark (data mark)
7340 `(setcar (nthcdr 1 ,data) ,mark))
7342 (defmacro gnus-data-pos (data)
7345 (defmacro gnus-data-set-pos (data pos)
7346 `(setcar (nthcdr 2 ,data) ,pos))
7348 (defmacro gnus-data-header (data)
7351 (defmacro gnus-data-level (data)
7354 (defmacro gnus-data-unread-p (data)
7355 `(= (nth 1 ,data) gnus-unread-mark))
7357 (defmacro gnus-data-pseudo-p (data)
7358 `(consp (nth 3 ,data)))
7360 (defmacro gnus-data-find (number)
7361 `(assq ,number gnus-newsgroup-data))
7363 (defmacro gnus-data-find-list (number &optional data)
7364 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7365 (memq (assq ,number bdata)
7368 (defmacro gnus-data-make (number mark pos header level)
7369 `(list ,number ,mark ,pos ,header ,level))
7371 (defun gnus-data-enter (after-article number mark pos header level offset)
7372 (let ((data (gnus-data-find-list after-article)))
7373 (or data (error "No such article: %d" after-article))
7374 (setcdr data (cons (gnus-data-make number mark pos header level)
7376 (setq gnus-newsgroup-data-reverse nil)
7377 (gnus-data-update-list (cddr data) offset)))
7379 (defun gnus-data-enter-list (after-article list &optional offset)
7381 (let ((data (and after-article (gnus-data-find-list after-article)))
7383 (or data (not after-article) (error "No such article: %d" after-article))
7384 ;; Find the last element in the list to be spliced into the main
7387 (setq list (cdr list)))
7390 (setcdr list gnus-newsgroup-data)
7391 (setq gnus-newsgroup-data ilist)
7392 (and offset (gnus-data-update-list (cdr list) offset)))
7393 (setcdr list (cdr data))
7395 (and offset (gnus-data-update-list (cdr data) offset)))
7396 (setq gnus-newsgroup-data-reverse nil))))
7398 (defun gnus-data-remove (article &optional offset)
7399 (let ((data gnus-newsgroup-data))
7400 (if (= (gnus-data-number (car data)) article)
7401 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7402 gnus-newsgroup-data-reverse nil)
7404 (and (= (gnus-data-number (cadr data)) article)
7406 (setcdr data (cddr data))
7407 (and offset (gnus-data-update-list (cdr data) offset))
7409 gnus-newsgroup-data-reverse nil)))
7410 (setq data (cdr data))))))
7412 (defmacro gnus-data-list (backward)
7414 (or gnus-newsgroup-data-reverse
7415 (setq gnus-newsgroup-data-reverse
7416 (reverse gnus-newsgroup-data)))
7417 gnus-newsgroup-data))
7419 (defun gnus-data-update-list (data offset)
7420 "Add OFFSET to the POS of all data entries in DATA."
7422 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7423 (setq data (cdr data))))
7425 (defun gnus-data-compute-positions ()
7426 "Compute the positions of all articles."
7427 (let ((data gnus-newsgroup-data)
7430 (when (setq pos (text-property-any
7431 (point-min) (point-max)
7432 'gnus-number (gnus-data-number (car data))))
7433 (gnus-data-set-pos (car data) (+ pos 3)))
7434 (setq data (cdr data)))))
7436 (defun gnus-summary-article-pseudo-p (article)
7437 "Say whether this article is a pseudo article or not."
7438 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7440 (defun gnus-article-parent-p (number)
7441 "Say whether this article is a parent or not."
7442 (let ((data (gnus-data-find-list number)))
7443 (and (cdr data) ; There has to be an article after...
7444 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7445 (gnus-data-level (nth 1 data))))))
7447 (defun gnus-article-children (number)
7448 "Return a list of all children to NUMBER."
7449 (let* ((data (gnus-data-find-list number))
7450 (level (gnus-data-level (car data)))
7452 (setq data (cdr data))
7454 (= (gnus-data-level (car data)) (1+ level)))
7455 (push (gnus-data-number (car data)) children)
7456 (setq data (cdr data)))
7459 (defmacro gnus-summary-skip-intangible ()
7460 "If the current article is intangible, then jump to a different article."
7461 '(let ((to (get-text-property (point) 'gnus-intangible)))
7462 (and to (gnus-summary-goto-subject to))))
7464 (defmacro gnus-summary-article-intangible-p ()
7465 "Say whether this article is intangible or not."
7466 '(get-text-property (point) 'gnus-intangible))
7468 ;; Some summary mode macros.
7470 (defmacro gnus-summary-article-number ()
7471 "The article number of the article on the current line.
7472 If there isn's an article number here, then we return the current
7475 (gnus-summary-skip-intangible)
7476 (or (get-text-property (point) 'gnus-number)
7477 (gnus-summary-last-subject))))
7479 (defmacro gnus-summary-article-header (&optional number)
7480 `(gnus-data-header (gnus-data-find
7481 ,(or number '(gnus-summary-article-number)))))
7483 (defmacro gnus-summary-thread-level (&optional number)
7484 `(if (and (eq gnus-summary-make-false-root 'dummy)
7485 (get-text-property (point) 'gnus-intangible))
7487 (gnus-data-level (gnus-data-find
7488 ,(or number '(gnus-summary-article-number))))))
7490 (defmacro gnus-summary-article-mark (&optional number)
7491 `(gnus-data-mark (gnus-data-find
7492 ,(or number '(gnus-summary-article-number)))))
7494 (defmacro gnus-summary-article-pos (&optional number)
7495 `(gnus-data-pos (gnus-data-find
7496 ,(or number '(gnus-summary-article-number)))))
7498 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7499 (defmacro gnus-summary-article-subject (&optional number)
7500 "Return current subject string or nil if nothing."
7503 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7504 '(gnus-data-header (assq (gnus-summary-article-number)
7505 gnus-newsgroup-data)))))
7508 (mail-header-subject headers))))
7510 (defmacro gnus-summary-article-score (&optional number)
7511 "Return current article score."
7512 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7513 gnus-newsgroup-scored))
7514 gnus-summary-default-score 0))
7516 (defun gnus-summary-article-children (&optional number)
7517 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7518 (level (gnus-data-level (car data)))
7520 (while (and (setq data (cdr data))
7521 (> (setq l (gnus-data-level (car data))) level))
7522 (and (= (1+ level) l)
7523 (setq children (cons (gnus-data-number (car data))
7525 (nreverse children)))
7527 (defun gnus-summary-article-parent (&optional number)
7528 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7529 (gnus-data-list t)))
7530 (level (gnus-data-level (car data))))
7532 () ; This is a root.
7533 ;; We search until we find an article with a level less than
7534 ;; this one. That function has to be the parent.
7535 (while (and (setq data (cdr data))
7536 (not (< (gnus-data-level (car data)) level))))
7537 (and data (gnus-data-number (car data))))))
7539 (defun gnus-unread-mark-p (mark)
7540 "Say whether MARK is the unread mark."
7541 (= mark gnus-unread-mark))
7543 (defun gnus-read-mark-p (mark)
7544 "Say whether MARK is one of the marks that mark as read.
7545 This is all marks except unread, ticked, dormant, and expirable."
7546 (not (or (= mark gnus-unread-mark)
7547 (= mark gnus-ticked-mark)
7548 (= mark gnus-dormant-mark)
7549 (= mark gnus-expirable-mark))))
7551 ;; Saving hidden threads.
7553 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7554 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7555 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7557 (defmacro gnus-save-hidden-threads (&rest forms)
7558 "Save hidden threads, eval FORMS, and restore the hidden threads."
7559 (let ((config (make-symbol "config")))
7560 `(let ((,config (gnus-hidden-threads-configuration)))
7564 (gnus-restore-hidden-threads-configuration ,config)))))
7566 (defun gnus-hidden-threads-configuration ()
7567 "Return the current hidden threads configuration."
7570 (goto-char (point-min))
7571 (while (search-forward "\r" nil t)
7572 (push (1- (point)) config))
7575 (defun gnus-restore-hidden-threads-configuration (config)
7576 "Restore hidden threads configuration from CONFIG."
7577 (let (point buffer-read-only)
7578 (while (setq point (pop config))
7579 (when (and (< point (point-max))
7581 (= (following-char) ?\n))
7582 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7584 ;; Various summary mode internalish functions.
7586 (defun gnus-mouse-pick-article (e)
7589 (gnus-summary-next-page nil t))
7591 (defun gnus-summary-setup-buffer (group)
7592 "Initialize summary buffer."
7593 (let ((buffer (concat "*Summary " group "*")))
7594 (if (get-buffer buffer)
7597 (setq gnus-summary-buffer (current-buffer))
7598 (not gnus-newsgroup-prepared))
7599 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7600 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7601 (gnus-add-current-to-buffer-list)
7602 (gnus-summary-mode group)
7604 (gnus-carpal-setup-buffer 'summary))
7605 (unless gnus-single-article-buffer
7606 (make-local-variable 'gnus-article-buffer)
7607 (make-local-variable 'gnus-article-current)
7608 (make-local-variable 'gnus-original-article-buffer))
7609 (setq gnus-newsgroup-name group)
7612 (defun gnus-set-global-variables ()
7613 ;; Set the global equivalents of the summary buffer-local variables
7614 ;; to the latest values they had. These reflect the summary buffer
7615 ;; that was in action when the last article was fetched.
7616 (when (eq major-mode 'gnus-summary-mode)
7617 (setq gnus-summary-buffer (current-buffer))
7618 (let ((name gnus-newsgroup-name)
7619 (marked gnus-newsgroup-marked)
7620 (unread gnus-newsgroup-unreads)
7621 (headers gnus-current-headers)
7622 (data gnus-newsgroup-data)
7623 (summary gnus-summary-buffer)
7624 (article-buffer gnus-article-buffer)
7625 (original gnus-original-article-buffer)
7626 (gac gnus-article-current)
7627 (reffed gnus-reffed-article-number)
7628 (score-file gnus-current-score-file))
7630 (set-buffer gnus-group-buffer)
7631 (setq gnus-newsgroup-name name)
7632 (setq gnus-newsgroup-marked marked)
7633 (setq gnus-newsgroup-unreads unread)
7634 (setq gnus-current-headers headers)
7635 (setq gnus-newsgroup-data data)
7636 (setq gnus-article-current gac)
7637 (setq gnus-summary-buffer summary)
7638 (setq gnus-article-buffer article-buffer)
7639 (setq gnus-original-article-buffer original)
7640 (setq gnus-reffed-article-number reffed)
7641 (setq gnus-current-score-file score-file)))))
7643 (defun gnus-summary-last-article-p (&optional article)
7644 "Return whether ARTICLE is the last article in the buffer."
7645 (if (not (setq article (or article (gnus-summary-article-number))))
7646 t ; All non-existant numbers are the last article. :-)
7647 (not (cdr (gnus-data-find-list article)))))
7649 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7650 "Insert a dummy root in the summary buffer."
7652 (gnus-add-text-properties
7653 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7654 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7656 (defun gnus-make-thread-indent-array ()
7658 (unless (and gnus-thread-indent-array
7659 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7660 (setq gnus-thread-indent-array (make-vector 201 "")
7661 gnus-thread-indent-array-level gnus-thread-indent-level)
7663 (aset gnus-thread-indent-array n
7664 (make-string (* n gnus-thread-indent-level) ? ))
7667 (defun gnus-summary-insert-line
7668 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7669 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7670 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7671 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7672 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7673 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7674 (gnus-tmp-score-char
7675 (if (or (null gnus-summary-default-score)
7676 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7677 gnus-summary-zcore-fuzz)) ?
7678 (if (< gnus-tmp-score gnus-summary-default-score)
7679 gnus-score-below-mark gnus-score-over-mark)))
7680 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7681 ((memq gnus-tmp-current gnus-newsgroup-cached)
7683 (gnus-tmp-replied gnus-replied-mark)
7684 ((memq gnus-tmp-current gnus-newsgroup-saved)
7686 (t gnus-unread-mark)))
7687 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7690 ((string-match "(.+)" gnus-tmp-from)
7691 (substring gnus-tmp-from
7692 (1+ (match-beginning 0)) (1- (match-end 0))))
7693 ((string-match "<[^>]+> *$" gnus-tmp-from)
7694 (let ((beg (match-beginning 0)))
7695 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7696 (substring gnus-tmp-from (1+ (match-beginning 0))
7697 (1- (match-end 0))))
7698 (substring gnus-tmp-from 0 beg))))
7700 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7701 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7702 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7703 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7704 (buffer-read-only nil))
7705 (when (string= gnus-tmp-name "")
7706 (setq gnus-tmp-name gnus-tmp-from))
7707 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7708 (gnus-put-text-property
7710 (progn (eval gnus-summary-line-format-spec) (point))
7711 'gnus-number gnus-tmp-number)
7712 (when (gnus-visual-p 'summary-highlight 'highlight)
7714 (run-hooks 'gnus-summary-update-hook)
7717 (defun gnus-summary-update-line (&optional dont-update)
7718 ;; Update summary line after change.
7719 (when (and gnus-summary-default-score
7720 (not gnus-summary-inhibit-highlight))
7721 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7722 (article (gnus-summary-article-number))
7723 (score (gnus-summary-article-score article)))
7725 (if (and gnus-summary-mark-below
7726 (< (gnus-summary-article-score)
7727 gnus-summary-mark-below))
7728 ;; This article has a low score, so we mark it as read.
7729 (when (memq article gnus-newsgroup-unreads)
7730 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7731 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7732 ;; This article was previously marked as read on account
7733 ;; of a low score, but now it has risen, so we mark it as
7735 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7736 (gnus-summary-update-mark
7737 (if (or (null gnus-summary-default-score)
7738 (<= (abs (- score gnus-summary-default-score))
7739 gnus-summary-zcore-fuzz)) ?
7740 (if (< score gnus-summary-default-score)
7741 gnus-score-below-mark gnus-score-over-mark)) 'score))
7742 ;; Do visual highlighting.
7743 (when (gnus-visual-p 'summary-highlight 'highlight)
7744 (run-hooks 'gnus-summary-update-hook)))))
7746 (defvar gnus-tmp-new-adopts nil)
7748 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7749 ;; Sum up all elements (and sub-elements) in a list.
7751 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7753 ((and (consp thread) (cdr thread))
7756 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7759 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7762 (when (and level (zerop level) gnus-tmp-new-adopts)
7765 'gnus-summary-number-of-articles-in-thread
7766 gnus-tmp-new-adopts))))
7768 (if (> number 1) gnus-not-empty-thread-mark
7769 gnus-empty-thread-mark)
7772 (defun gnus-summary-set-local-parameters (group)
7773 "Go through the local params of GROUP and set all variable specs in that list."
7774 (let ((params (gnus-info-params (gnus-get-info group)))
7777 (setq elem (car params)
7778 params (cdr params))
7779 (and (consp elem) ; Has to be a cons.
7780 (consp (cdr elem)) ; The cdr has to be a list.
7781 (symbolp (car elem)) ; Has to be a symbol in there.
7782 (not (memq (car elem)
7783 '(quit-config to-address to-list to-group)))
7784 (progn ; So we set it.
7785 (make-local-variable (car elem))
7786 (set (car elem) (eval (nth 1 elem))))))))
7788 (defun gnus-summary-read-group (group &optional show-all no-article
7789 kill-buffer no-display)
7790 "Start reading news in newsgroup GROUP.
7791 If SHOW-ALL is non-nil, already read articles are also listed.
7792 If NO-ARTICLE is non-nil, no article is selected initially.
7793 If NO-DISPLAY, don't generate a summary buffer."
7794 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7795 (let* ((new-group (gnus-summary-setup-buffer group))
7796 (quit-config (gnus-group-quit-config group))
7797 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7799 ;; This summary buffer exists already, so we just select it.
7801 (gnus-set-global-variables)
7803 (gnus-kill-or-deaden-summary kill-buffer))
7804 (gnus-configure-windows 'summary 'force)
7805 (gnus-set-mode-line 'summary)
7806 (gnus-summary-position-point)
7809 ;; We couldn't select this group.
7811 (when (and (eq major-mode 'gnus-summary-mode)
7812 (not (equal (current-buffer) kill-buffer)))
7813 (kill-buffer (current-buffer))
7814 (if (not quit-config)
7816 (set-buffer gnus-group-buffer)
7817 (gnus-group-jump-to-group group)
7818 (gnus-group-next-unread-group 1))
7819 (if (not (buffer-name (car quit-config)))
7820 (gnus-configure-windows 'group 'force)
7821 (set-buffer (car quit-config))
7822 (and (eq major-mode 'gnus-summary-mode)
7823 (gnus-set-global-variables))
7824 (gnus-configure-windows (cdr quit-config)))))
7825 (gnus-message 3 "Can't select group")
7827 ;; The user did a `C-g' while prompting for number of articles,
7828 ;; so we exit this group.
7829 ((eq did-select 'quit)
7830 (and (eq major-mode 'gnus-summary-mode)
7831 (not (equal (current-buffer) kill-buffer))
7832 (kill-buffer (current-buffer)))
7834 (gnus-kill-or-deaden-summary kill-buffer))
7835 (if (not quit-config)
7837 (set-buffer gnus-group-buffer)
7838 (gnus-group-jump-to-group group)
7839 (gnus-group-next-unread-group 1)
7840 (gnus-configure-windows 'group 'force))
7841 (if (not (buffer-name (car quit-config)))
7842 (gnus-configure-windows 'group 'force)
7843 (set-buffer (car quit-config))
7844 (and (eq major-mode 'gnus-summary-mode)
7845 (gnus-set-global-variables))
7846 (gnus-configure-windows (cdr quit-config))))
7847 ;; Finally signal the quit.
7849 ;; The group was successfully selected.
7851 (gnus-set-global-variables)
7852 ;; Save the active value in effect when the group was entered.
7853 (setq gnus-newsgroup-active
7855 (gnus-active gnus-newsgroup-name)))
7856 ;; You can change the summary buffer in some way with this hook.
7857 (run-hooks 'gnus-select-group-hook)
7858 ;; Set any local variables in the group parameters.
7859 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7860 (gnus-update-format-specifications)
7861 ;; Do score processing.
7862 (when gnus-use-scoring
7863 (gnus-possibly-score-headers))
7864 ;; Check whether to fill in the gaps in the threads.
7865 (when gnus-build-sparse-threads
7866 (gnus-build-sparse-threads))
7867 ;; Find the initial limit.
7868 (if gnus-show-threads
7870 (let ((gnus-newsgroup-dormant nil))
7871 (gnus-summary-initial-limit show-all))
7872 (gnus-summary-initial-limit show-all))
7873 (setq gnus-newsgroup-limit
7875 (lambda (header) (mail-header-number header))
7876 gnus-newsgroup-headers)))
7877 ;; Generate the summary buffer.
7879 (gnus-summary-prepare))
7880 (when gnus-use-trees
7881 (gnus-tree-open group)
7882 (setq gnus-summary-highlight-line-function
7883 'gnus-tree-highlight-article))
7884 ;; If the summary buffer is empty, but there are some low-scored
7885 ;; articles or some excluded dormants, we include these in the
7887 (when (and (zerop (buffer-size))
7889 (cond (gnus-newsgroup-dormant
7890 (gnus-summary-limit-include-dormant))
7891 ((and gnus-newsgroup-scored show-all)
7892 (gnus-summary-limit-include-expunged t))))
7893 ;; Function `gnus-apply-kill-file' must be called in this hook.
7894 (run-hooks 'gnus-apply-kill-hook)
7895 (if (and (zerop (buffer-size))
7898 ;; This newsgroup is empty.
7899 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7900 (gnus-message 6 "No unread news")
7902 (gnus-kill-or-deaden-summary kill-buffer))
7903 ;; Return nil from this function.
7905 ;; Hide conversation thread subtrees. We cannot do this in
7906 ;; gnus-summary-prepare-hook since kill processing may not
7907 ;; work with hidden articles.
7908 (and gnus-show-threads
7909 gnus-thread-hide-subtree
7910 (gnus-summary-hide-all-threads))
7911 ;; Show first unread article if requested.
7912 (if (and (not no-article)
7914 gnus-newsgroup-unreads
7915 gnus-auto-select-first)
7916 (unless (if (eq gnus-auto-select-first 'best)
7917 (gnus-summary-best-unread-article)
7918 (gnus-summary-first-unread-article))
7919 (gnus-configure-windows 'summary))
7920 ;; Don't select any articles, just move point to the first
7921 ;; article in the group.
7922 (goto-char (point-min))
7923 (gnus-summary-position-point)
7924 (gnus-set-mode-line 'summary)
7925 (gnus-configure-windows 'summary 'force))
7926 ;; If we are in async mode, we send some info to the backend.
7927 (when gnus-newsgroup-async
7928 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7930 (gnus-kill-or-deaden-summary kill-buffer))
7931 (when (get-buffer-window gnus-group-buffer t)
7932 ;; Gotta use windows, because recenter does wierd stuff if
7933 ;; the current buffer ain't the displayed window.
7934 (let ((owin (selected-window)))
7935 (select-window (get-buffer-window gnus-group-buffer t))
7936 (when (gnus-group-goto-group group)
7938 (select-window owin))))
7939 ;; Mark this buffer as "prepared".
7940 (setq gnus-newsgroup-prepared t)
7943 (defun gnus-summary-prepare ()
7944 "Generate the summary buffer."
7945 (let ((buffer-read-only nil))
7947 (setq gnus-newsgroup-data nil
7948 gnus-newsgroup-data-reverse nil)
7949 (run-hooks 'gnus-summary-generate-hook)
7950 ;; Generate the buffer, either with threads or without.
7951 (when gnus-newsgroup-headers
7952 (gnus-summary-prepare-threads
7953 (if gnus-show-threads
7954 (gnus-sort-gathered-threads
7955 (funcall gnus-summary-thread-gathering-function
7957 (gnus-cut-threads (gnus-make-threads)))))
7958 ;; Unthreaded display.
7959 (gnus-sort-articles gnus-newsgroup-headers))))
7960 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7961 ;; Call hooks for modifying summary buffer.
7962 (goto-char (point-min))
7963 (run-hooks 'gnus-summary-prepare-hook)))
7965 (defun gnus-gather-threads-by-subject (threads)
7966 "Gather threads by looking at Subject headers."
7967 (if (not gnus-summary-make-false-root)
7969 (let ((hashtb (gnus-make-hashtable 1023))
7972 subject hthread whole-subject)
7974 (setq whole-subject (mail-header-subject (caar threads)))
7977 ;; Truncate the subject.
7978 ((numberp gnus-summary-gather-subject-limit)
7979 (setq subject (gnus-simplify-subject-re whole-subject))
7980 (if (> (length subject) gnus-summary-gather-subject-limit)
7981 (substring subject 0 gnus-summary-gather-subject-limit)
7983 ;; Fuzzily simplify it.
7984 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7985 (gnus-simplify-subject-fuzzy whole-subject))
7986 ;; Just remove the leading "Re:".
7988 (gnus-simplify-subject-re whole-subject))))
7990 (if (and gnus-summary-gather-exclude-subject
7991 (string-match gnus-summary-gather-exclude-subject
7993 () ; We don't want to do anything with this article.
7994 ;; We simplify the subject before looking it up in the
7997 (if (setq hthread (gnus-gethash subject hashtb))
7999 ;; We enter a dummy root into the thread, if we
8000 ;; haven't done that already.
8001 (unless (stringp (caar hthread))
8002 (setcar hthread (list whole-subject (car hthread))))
8003 ;; We add this new gathered thread to this gathered
8005 (setcdr (car hthread)
8006 (nconc (cdar hthread) (list (car threads))))
8007 ;; Remove it from the list of threads.
8008 (setcdr prev (cdr threads))
8009 (setq threads prev))
8010 ;; Enter this thread into the hash table.
8011 (gnus-sethash subject threads hashtb)))
8013 (setq threads (cdr threads)))
8016 (defun gnus-gather-threads-by-references (threads)
8017 "Gather threads by looking at References headers."
8018 (let ((idhashtb (gnus-make-hashtable 1023))
8019 (thhashtb (gnus-make-hashtable 1023))
8022 ids references id gthread gid entered)
8024 (when (setq references (mail-header-references (caar threads)))
8025 (setq id (mail-header-id (caar threads)))
8026 (setq ids (gnus-split-references references))
8029 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
8031 (gnus-sethash (car ids) id idhashtb)
8032 (gnus-sethash id threads thhashtb))
8033 (setq gthread (gnus-gethash gid thhashtb))
8035 ;; We enter a dummy root into the thread, if we
8036 ;; haven't done that already.
8037 (unless (stringp (caar gthread))
8038 (setcar gthread (list (mail-header-subject (caar gthread))
8040 ;; We add this new gathered thread to this gathered
8042 (setcdr (car gthread)
8043 (nconc (cdar gthread) (list (car threads)))))
8044 ;; Add it into the thread hash table.
8045 (gnus-sethash id gthread thhashtb)
8047 ;; Remove it from the list of threads.
8048 (setcdr prev (cdr threads))
8049 (setq threads prev))
8050 (setq ids (cdr ids))))
8052 (setq threads (cdr threads)))
8055 (defun gnus-sort-gathered-threads (threads)
8056 "Sort subtreads inside each gathered thread by article number."
8057 (let ((result threads))
8059 (when (stringp (caar threads))
8060 (setcdr (car threads)
8061 (sort (cdar threads) 'gnus-thread-sort-by-number)))
8062 (setq threads (cdr threads)))
8065 (defun gnus-make-threads ()
8066 "Go through the dependency hashtb and find the roots. Return all threads."
8070 (unless (car (symbol-value refs))
8071 ;; These threads do not refer back to any other articles,
8072 ;; so they're roots.
8073 (setq threads (append (cdr (symbol-value refs)) threads))))
8074 gnus-newsgroup-dependencies)
8077 (defun gnus-build-sparse-threads ()
8078 (let ((headers gnus-newsgroup-headers)
8079 (deps gnus-newsgroup-dependencies)
8080 header references generation relations
8081 cthread subject child end pthread relation)
8082 ;; First we create an alist of generations/relations, where
8083 ;; generations is how much we trust the ralation, and the relation
8085 (gnus-message 7 "Making sparse threads...")
8087 (nnheader-set-temp-buffer " *gnus sparse threads*")
8088 (while (setq header (pop headers))
8089 (when (and (setq references (mail-header-references header))
8090 (not (string= references "")))
8092 (setq child (mail-header-id header)
8093 subject (mail-header-subject header))
8095 (while (search-backward ">" nil t)
8096 (setq end (1+ (point)))
8097 (when (search-backward "<" nil t)
8098 (push (list (incf generation)
8099 child (setq child (buffer-substring (point) end))
8102 (push (list (1+ generation) child nil subject) relations)
8104 (kill-buffer (current-buffer)))
8105 ;; Sort over trustworthiness.
8106 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8107 (while (setq relation (pop relations))
8108 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8109 (unless (car (symbol-value cthread))
8110 ;; Make this article the parent of these threads.
8111 (setcar (symbol-value cthread)
8112 (vector gnus-reffed-article-number
8116 (or (caddr relation) "") 0 0 "")))
8117 (set cthread (list (vector gnus-reffed-article-number
8119 "" "" (cadr relation)
8120 (or (caddr relation) "") 0 0 ""))))
8121 (push gnus-reffed-article-number gnus-newsgroup-limit)
8122 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8123 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8124 gnus-newsgroup-reads)
8125 (decf gnus-reffed-article-number)
8126 ;; Make this new thread the child of its parent.
8127 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8128 (setcdr (symbol-value pthread)
8129 (nconc (cdr (symbol-value pthread))
8130 (list (symbol-value cthread))))
8131 (set pthread (list nil (symbol-value cthread))))))
8132 (gnus-message 7 "Making sparse threads...done")))
8134 (defun gnus-build-old-threads ()
8135 ;; Look at all the articles that refer back to old articles, and
8136 ;; fetch the headers for the articles that aren't there. This will
8137 ;; build complete threads - if the roots haven't been expired by the
8142 (when (not (car (symbol-value refs)))
8143 (setq heads (cdr (symbol-value refs)))
8145 (if (memq (mail-header-number (caar heads))
8146 gnus-newsgroup-dormant)
8147 (setq heads (cdr heads))
8148 (setq id (symbol-name refs))
8149 (while (and (setq id (gnus-build-get-header id))
8150 (not (car (gnus-gethash
8151 id gnus-newsgroup-dependencies)))))
8152 (setq heads nil)))))
8153 gnus-newsgroup-dependencies)))
8155 (defun gnus-build-get-header (id)
8156 ;; Look through the buffer of NOV lines and find the header to
8157 ;; ID. Enter this line into the dependencies hash table, and return
8158 ;; the id of the parent article (if any).
8159 (let ((deps gnus-newsgroup-dependencies)
8163 (set-buffer nntp-server-buffer)
8164 (goto-char (point-min))
8165 (while (and (not found) (search-forward id nil t))
8167 (setq found (looking-at
8168 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8169 (regexp-quote id))))
8170 (or found (beginning-of-line 2)))
8174 (setq header (gnus-nov-parse-line
8175 (read (current-buffer)) deps))
8176 (gnus-parent-id (mail-header-references header)))))
8178 (let ((number (mail-header-number header)))
8179 (push number gnus-newsgroup-limit)
8180 (push header gnus-newsgroup-headers)
8181 (if (memq number gnus-newsgroup-unselected)
8183 (push number gnus-newsgroup-unreads)
8184 (setq gnus-newsgroup-unselected
8185 (delq number gnus-newsgroup-unselected)))
8186 (push number gnus-newsgroup-ancient)))))))
8188 (defun gnus-summary-update-article (article &optional iheader)
8189 "Update ARTICLE in the summary buffer."
8190 (set-buffer gnus-summary-buffer)
8191 (let* ((header (or iheader (gnus-summary-article-header article)))
8192 (id (mail-header-id header))
8193 (data (gnus-data-find article))
8194 (thread (gnus-id-to-thread id))
8195 (references (mail-header-references header))
8200 (not (equal "" references)))
8203 (buffer-read-only nil)
8205 (number (mail-header-number header))
8208 ;; !!! Should this be in or not?
8210 (setcar thread nil))
8212 (delq thread parent))
8213 (if (gnus-summary-insert-subject id header iheader)
8214 ;; Set the (possibly) new article number in the data structure.
8215 (gnus-data-set-number data (gnus-id-to-article id))
8219 (defun gnus-rebuild-thread (id)
8220 "Rebuild the thread containing ID."
8221 (let ((buffer-read-only nil)
8222 current thread data)
8223 (if (not gnus-show-threads)
8224 (setq thread (list (car (gnus-id-to-thread id))))
8225 ;; Get the thread this article is part of.
8226 (setq thread (gnus-remove-thread id)))
8227 (setq current (save-excursion
8228 (and (zerop (forward-line -1))
8229 (gnus-summary-article-number))))
8230 ;; If this is a gathered thread, we have to go some re-gathering.
8231 (when (stringp (car thread))
8232 (let ((subject (car thread))
8234 (setq thread (cdr thread))
8236 (unless (memq (setq thr (gnus-id-to-thread
8238 (mail-header-id (caar thread)))))
8241 (setq thread (cdr thread)))
8242 ;; We now have all (unique) roots.
8243 (if (= (length roots) 1)
8244 ;; All the loose roots are now one solid root.
8245 (setq thread (car roots))
8246 (setq thread (cons subject (gnus-sort-threads roots))))))
8248 ;; We then insert this thread into the summary buffer.
8249 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8250 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8251 (setq data (nreverse gnus-newsgroup-data))
8252 (setq threads gnus-newsgroup-threads))
8253 ;; We splice the new data into the data structure.
8254 (gnus-data-enter-list current data)
8255 (gnus-data-compute-positions)
8256 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8258 (defun gnus-number-to-header (number)
8259 "Return the header for article NUMBER."
8260 (let ((headers gnus-newsgroup-headers))
8262 (not (= number (mail-header-number (car headers)))))
8267 (defun gnus-id-to-thread (id)
8268 "Return the (sub-)thread where ID appears."
8269 (gnus-gethash id gnus-newsgroup-dependencies))
8271 (defun gnus-id-to-article (id)
8272 "Return the article number of ID."
8273 (let ((thread (gnus-id-to-thread id)))
8276 (mail-header-number (car thread)))))
8278 (defun gnus-id-to-header (id)
8279 "Return the article headers of ID."
8280 (car (gnus-id-to-thread id)))
8282 (defun gnus-article-displayed-root-p (article)
8283 "Say whether ARTICLE is a root(ish) article."
8284 (let ((level (gnus-summary-thread-level article))
8285 (refs (mail-header-references (gnus-summary-article-header article)))
8291 ((null (gnus-parent-id refs)) t)
8293 (null (setq particle (gnus-id-to-article
8294 (gnus-parent-id refs))))
8295 (null (gnus-summary-thread-level particle)))))))
8297 (defun gnus-root-id (id)
8298 "Return the id of the root of the thread where ID appears."
8300 (while (and id (setq prev (car (gnus-gethash
8301 id gnus-newsgroup-dependencies))))
8303 id (gnus-parent-id (mail-header-references prev))))
8306 (defun gnus-remove-thread (id &optional dont-remove)
8307 "Remove the thread that has ID in it."
8308 (let ((dep gnus-newsgroup-dependencies)
8309 headers thread last-id)
8310 ;; First go up in this thread until we find the root.
8311 (setq last-id (gnus-root-id id))
8312 (setq headers (list (car (gnus-id-to-thread last-id))
8313 (caadr (gnus-id-to-thread last-id))))
8314 ;; We have now found the real root of this thread. It might have
8315 ;; been gathered into some loose thread, so we have to search
8316 ;; through the threads to find the thread we wanted.
8317 (let ((threads gnus-newsgroup-threads)
8320 (setq sub (car threads))
8321 (if (stringp (car sub))
8322 ;; This is a gathered threads, so we look at the roots
8323 ;; below it to find whether this article in in this
8326 (setq sub (cdr sub))
8328 (when (member (caar sub) headers)
8329 (setq thread (car threads)
8332 (setq sub (cdr sub))))
8333 ;; It's an ordinary thread, so we check it.
8334 (when (eq (car sub) (car headers))
8337 (setq threads (cdr threads)))
8338 ;; If this article is in no thread, then it's a root.
8341 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8342 (setq thread (gnus-gethash last-id dep)))
8345 thread ; We return this thread.
8347 (if (stringp (car thread))
8349 ;; If we use dummy roots, then we have to remove the
8350 ;; dummy root as well.
8351 (when (eq gnus-summary-make-false-root 'dummy)
8354 (setq thread (cdr thread))
8356 (gnus-remove-thread-1 (car thread))
8357 (setq thread (cdr thread))))
8358 (gnus-remove-thread-1 thread))))))))
8360 (defun gnus-remove-thread-1 (thread)
8361 "Remove the thread THREAD recursively."
8362 (let ((number (mail-header-number (car thread)))
8364 (when (setq pos (text-property-any
8365 (point-min) (point-max) 'gnus-number number))
8368 (gnus-data-remove number))
8369 (setq thread (cdr thread))
8371 (gnus-remove-thread-1 (pop thread)))))
8373 (defun gnus-sort-threads (threads)
8375 (if (not gnus-thread-sort-functions)
8377 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8378 (car gnus-thread-sort-functions)
8380 ,(gnus-make-sort-function
8381 (reverse gnus-thread-sort-functions))))))
8382 (gnus-message 7 "Sorting threads...")
8385 (gnus-message 7 "Sorting threads...done")))))
8387 (defun gnus-sort-articles (articles)
8389 (when gnus-article-sort-functions
8390 (let ((func (if (= 1 (length gnus-article-sort-functions))
8391 (car gnus-article-sort-functions)
8393 ,(gnus-make-sort-function
8394 (reverse gnus-article-sort-functions))))))
8395 (gnus-message 7 "Sorting articles...")
8397 (setq gnus-newsgroup-headers (sort articles func))
8398 (gnus-message 7 "Sorting articles...done")))))
8400 (defun gnus-make-sort-function (funs)
8401 "Return a composite sort condition based on the functions in FUNC."
8403 `(or (,(car funs) t1 t2)
8404 (and (not (,(car funs) t2 t1))
8405 ,(gnus-make-sort-function (cdr funs))))
8406 `(,(car funs) t1 t2)))
8408 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8409 (defmacro gnus-thread-header (thread)
8410 ;; Return header of first article in THREAD.
8411 ;; Note that THREAD must never, ever be anything else than a variable -
8412 ;; using some other form will lead to serious barfage.
8413 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8414 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8415 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8418 (defsubst gnus-article-sort-by-number (h1 h2)
8419 "Sort articles by article number."
8420 (< (mail-header-number h1)
8421 (mail-header-number h2)))
8423 (defun gnus-thread-sort-by-number (h1 h2)
8424 "Sort threads by root article number."
8425 (gnus-article-sort-by-number
8426 (gnus-thread-header h1) (gnus-thread-header h2)))
8428 (defsubst gnus-article-sort-by-author (h1 h2)
8429 "Sort articles by root author."
8431 (let ((extract (funcall
8432 gnus-extract-address-components
8433 (mail-header-from h1))))
8434 (or (car extract) (cdr extract)))
8435 (let ((extract (funcall
8436 gnus-extract-address-components
8437 (mail-header-from h2))))
8438 (or (car extract) (cdr extract)))))
8440 (defun gnus-thread-sort-by-author (h1 h2)
8441 "Sort threads by root author."
8442 (gnus-article-sort-by-author
8443 (gnus-thread-header h1) (gnus-thread-header h2)))
8445 (defsubst gnus-article-sort-by-subject (h1 h2)
8446 "Sort articles by root subject."
8448 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8449 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8451 (defun gnus-thread-sort-by-subject (h1 h2)
8452 "Sort threads by root subject."
8453 (gnus-article-sort-by-subject
8454 (gnus-thread-header h1) (gnus-thread-header h2)))
8456 (defsubst gnus-article-sort-by-date (h1 h2)
8457 "Sort articles by root article date."
8459 (inline (gnus-sortable-date (mail-header-date h1)))
8460 (inline (gnus-sortable-date (mail-header-date h2)))))
8462 (defun gnus-thread-sort-by-date (h1 h2)
8463 "Sort threads by root article date."
8464 (gnus-article-sort-by-date
8465 (gnus-thread-header h1) (gnus-thread-header h2)))
8467 (defsubst gnus-article-sort-by-score (h1 h2)
8468 "Sort articles by root article score.
8469 Unscored articles will be counted as having a score of zero."
8470 (> (or (cdr (assq (mail-header-number h1)
8471 gnus-newsgroup-scored))
8472 gnus-summary-default-score 0)
8473 (or (cdr (assq (mail-header-number h2)
8474 gnus-newsgroup-scored))
8475 gnus-summary-default-score 0)))
8477 (defun gnus-thread-sort-by-score (h1 h2)
8478 "Sort threads by root article score."
8479 (gnus-article-sort-by-score
8480 (gnus-thread-header h1) (gnus-thread-header h2)))
8482 (defun gnus-thread-sort-by-total-score (h1 h2)
8483 "Sort threads by the sum of all scores in the thread.
8484 Unscored articles will be counted as having a score of zero."
8485 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8487 (defun gnus-thread-total-score (thread)
8488 ;; This function find the total score of THREAD.
8489 (cond ((null thread)
8492 (if (stringp (car thread))
8493 (apply gnus-thread-score-function 0
8494 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8495 (gnus-thread-total-score-1 thread)))
8497 (gnus-thread-total-score-1 (list thread)))))
8499 (defun gnus-thread-total-score-1 (root)
8500 ;; This function find the total score of the thread below ROOT.
8501 (setq root (car root))
8502 (apply gnus-thread-score-function
8504 (mapcar 'gnus-thread-total-score
8505 (cdr (gnus-gethash (mail-header-id root)
8506 gnus-newsgroup-dependencies)))
8507 (if (> (mail-header-number root) 0)
8508 (list (or (cdr (assq (mail-header-number root)
8509 gnus-newsgroup-scored))
8510 gnus-summary-default-score 0))))
8511 (list gnus-summary-default-score)
8514 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8515 (defvar gnus-tmp-prev-subject nil)
8516 (defvar gnus-tmp-false-parent nil)
8517 (defvar gnus-tmp-root-expunged nil)
8518 (defvar gnus-tmp-dummy-line nil)
8520 (defun gnus-summary-prepare-threads (threads)
8521 "Prepare summary buffer from THREADS and indentation LEVEL.
8522 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8523 or a straight list of headers."
8524 (gnus-message 7 "Generating summary...")
8526 (setq gnus-newsgroup-threads threads)
8529 (let ((gnus-tmp-level 0)
8530 (default-score (or gnus-summary-default-score 0))
8531 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8532 thread number subject stack state gnus-tmp-gathered beg-match
8533 new-roots gnus-tmp-new-adopts thread-end
8534 gnus-tmp-header gnus-tmp-unread
8535 gnus-tmp-replied gnus-tmp-subject-or-nil
8536 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8537 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8538 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8540 (setq gnus-tmp-prev-subject nil)
8542 (if (vectorp (car threads))
8543 ;; If this is a straight (sic) list of headers, then a
8544 ;; threaded summary display isn't required, so we just create
8545 ;; an unthreaded one.
8546 (gnus-summary-prepare-unthreaded threads)
8548 ;; Do the threaded display.
8550 (while (or threads stack gnus-tmp-new-adopts new-roots)
8552 (if (and (= gnus-tmp-level 0)
8553 (not (setq gnus-tmp-dummy-line nil))
8556 (not gnus-tmp-false-parent)
8557 (or gnus-tmp-new-adopts new-roots))
8558 (if gnus-tmp-new-adopts
8559 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8560 thread (list (car gnus-tmp-new-adopts))
8561 gnus-tmp-header (caar thread)
8562 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8564 (setq thread (list (car new-roots))
8565 gnus-tmp-header (caar thread)
8566 new-roots (cdr new-roots))))
8569 ;; If there are some threads, we do them before the
8570 ;; threads on the stack.
8571 (setq thread threads
8572 gnus-tmp-header (caar thread))
8573 ;; There were no current threads, so we pop something off
8575 (setq state (car stack)
8576 gnus-tmp-level (car state)
8579 gnus-tmp-header (caar thread))))
8581 (setq gnus-tmp-false-parent nil)
8582 (setq gnus-tmp-root-expunged nil)
8583 (setq thread-end nil)
8585 (if (stringp gnus-tmp-header)
8586 ;; The header is a dummy root.
8588 ((eq gnus-summary-make-false-root 'adopt)
8589 ;; We let the first article adopt the rest.
8590 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8592 (setq gnus-tmp-gathered
8594 (lambda (h) (mail-header-number (car h)))
8597 (setq thread (cons (list (caar thread)
8600 (setq gnus-tmp-level -1
8601 gnus-tmp-false-parent t))
8602 ((eq gnus-summary-make-false-root 'empty)
8603 ;; We print adopted articles with empty subject fields.
8604 (setq gnus-tmp-gathered
8606 (lambda (h) (mail-header-number (car h)))
8609 (setq gnus-tmp-level -1))
8610 ((eq gnus-summary-make-false-root 'dummy)
8611 ;; We remember that we probably want to output a dummy
8613 (setq gnus-tmp-dummy-line gnus-tmp-header)
8614 (setq gnus-tmp-prev-subject gnus-tmp-header))
8616 ;; We do not make a root for the gathered
8617 ;; sub-threads at all.
8618 (setq gnus-tmp-level -1)))
8620 (setq number (mail-header-number gnus-tmp-header)
8621 subject (mail-header-subject gnus-tmp-header))
8624 ;; If the thread has changed subject, we might want to make
8625 ;; this subthread into a root.
8626 ((and (null gnus-thread-ignore-subject)
8627 (not (zerop gnus-tmp-level))
8628 gnus-tmp-prev-subject
8630 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8631 (setq new-roots (nconc new-roots (list (car thread)))
8633 gnus-tmp-header nil))
8634 ;; If the article lies outside the current limit,
8635 ;; then we do not display it.
8636 ((and (not (memq number gnus-newsgroup-limit))
8637 (not gnus-tmp-dummy-line))
8638 (setq gnus-tmp-gathered
8640 (lambda (h) (mail-header-number (car h)))
8643 (setq gnus-tmp-new-adopts (if (cdar thread)
8644 (append gnus-tmp-new-adopts
8646 gnus-tmp-new-adopts)
8648 gnus-tmp-header nil)
8649 (when (zerop gnus-tmp-level)
8650 (setq gnus-tmp-root-expunged t)))
8651 ;; Perhaps this article is to be marked as read?
8652 ((and gnus-summary-mark-below
8653 (< (or (cdr (assq number gnus-newsgroup-scored))
8655 gnus-summary-mark-below)
8656 ;; Don't touch sparse articles.
8657 (not (memq number gnus-newsgroup-sparse))
8658 (not (memq number gnus-newsgroup-ancient)))
8659 (setq gnus-newsgroup-unreads
8660 (delq number gnus-newsgroup-unreads))
8661 (if gnus-newsgroup-auto-expire
8662 (push number gnus-newsgroup-expirable)
8663 (push (cons number gnus-low-score-mark)
8664 gnus-newsgroup-reads))))
8666 (when gnus-tmp-header
8667 ;; We may have an old dummy line to output before this
8669 (when gnus-tmp-dummy-line
8670 (gnus-summary-insert-dummy-line
8671 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8672 (setq gnus-tmp-dummy-line nil))
8674 ;; Compute the mark.
8678 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8679 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8680 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8681 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8682 (t (or (cdr (assq number gnus-newsgroup-reads))
8683 gnus-ancient-mark))))
8685 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8686 gnus-tmp-header gnus-tmp-level)
8687 gnus-newsgroup-data)
8689 ;; Actually insert the line.
8691 gnus-tmp-subject-or-nil
8693 ((and gnus-thread-ignore-subject
8694 gnus-tmp-prev-subject
8695 (not (inline (gnus-subject-equal
8696 gnus-tmp-prev-subject subject))))
8698 ((zerop gnus-tmp-level)
8699 (if (and (eq gnus-summary-make-false-root 'empty)
8700 (memq number gnus-tmp-gathered)
8701 gnus-tmp-prev-subject
8702 (inline (gnus-subject-equal
8703 gnus-tmp-prev-subject subject)))
8704 gnus-summary-same-subject
8706 (t gnus-summary-same-subject)))
8707 (if (and (eq gnus-summary-make-false-root 'adopt)
8708 (= gnus-tmp-level 1)
8709 (memq number gnus-tmp-gathered))
8710 (setq gnus-tmp-opening-bracket ?\<
8711 gnus-tmp-closing-bracket ?\>)
8712 (setq gnus-tmp-opening-bracket ?\[
8713 gnus-tmp-closing-bracket ?\]))
8715 gnus-tmp-indentation
8716 (aref gnus-thread-indent-array gnus-tmp-level)
8717 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8718 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8719 gnus-summary-default-score 0)
8721 (if (or (null gnus-summary-default-score)
8722 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8723 gnus-summary-zcore-fuzz)) ?
8724 (if (< gnus-tmp-score gnus-summary-default-score)
8725 gnus-score-below-mark gnus-score-over-mark))
8727 (cond ((memq number gnus-newsgroup-processable)
8729 ((memq number gnus-newsgroup-cached)
8731 ((memq number gnus-newsgroup-replied)
8733 ((memq number gnus-newsgroup-saved)
8735 (t gnus-unread-mark))
8736 gnus-tmp-from (mail-header-from gnus-tmp-header)
8739 ((string-match "(.+)" gnus-tmp-from)
8740 (substring gnus-tmp-from
8741 (1+ (match-beginning 0)) (1- (match-end 0))))
8742 ((string-match "<[^>]+> *$" gnus-tmp-from)
8743 (setq beg-match (match-beginning 0))
8744 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8745 (substring gnus-tmp-from (1+ (match-beginning 0))
8746 (1- (match-end 0))))
8747 (substring gnus-tmp-from 0 beg-match)))
8749 (when (string= gnus-tmp-name "")
8750 (setq gnus-tmp-name gnus-tmp-from))
8751 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8752 (gnus-put-text-property
8754 (progn (eval gnus-summary-line-format-spec) (point))
8755 'gnus-number number)
8758 (run-hooks 'gnus-summary-update-hook)
8761 (setq gnus-tmp-prev-subject subject)))
8763 (when (nth 1 thread)
8764 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8765 (incf gnus-tmp-level)
8766 (setq threads (if thread-end nil (cdar thread)))
8768 (setq gnus-tmp-level 0)))))
8769 (gnus-message 7 "Generating summary...done"))
8771 (defun gnus-summary-prepare-unthreaded (headers)
8772 "Generate an unthreaded summary buffer based on HEADERS."
8773 (let (header number mark)
8776 ;; We may have to root out some bad articles...
8777 (when (memq (setq number (mail-header-number
8778 (setq header (pop headers))))
8779 gnus-newsgroup-limit)
8780 ;; Mark article as read when it has a low score.
8781 (when (and gnus-summary-mark-below
8782 (< (or (cdr (assq number gnus-newsgroup-scored))
8783 gnus-summary-default-score 0)
8784 gnus-summary-mark-below)
8785 (not (memq number gnus-newsgroup-ancient)))
8786 (setq gnus-newsgroup-unreads
8787 (delq number gnus-newsgroup-unreads))
8788 (if gnus-newsgroup-auto-expire
8789 (push number gnus-newsgroup-expirable)
8790 (push (cons number gnus-low-score-mark)
8791 gnus-newsgroup-reads)))
8795 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8796 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8797 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8798 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8799 (t (or (cdr (assq number gnus-newsgroup-reads))
8800 gnus-ancient-mark))))
8801 (setq gnus-newsgroup-data
8802 (cons (gnus-data-make number mark (1+ (point)) header 0)
8803 gnus-newsgroup-data))
8804 (gnus-summary-insert-line
8805 header 0 nil mark (memq number gnus-newsgroup-replied)
8806 (memq number gnus-newsgroup-expirable)
8807 (mail-header-subject header) nil
8808 (cdr (assq number gnus-newsgroup-scored))
8809 (memq number gnus-newsgroup-processable))))))
8811 (defun gnus-select-newsgroup (group &optional read-all)
8812 "Select newsgroup GROUP.
8813 If READ-ALL is non-nil, all articles in the group are selected."
8814 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8815 (info (nth 2 entry))
8816 articles fetched-articles cached)
8818 (or (gnus-check-server
8819 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8820 (error "Couldn't open server"))
8822 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8823 (gnus-activate-group group) ; Or we can activate it...
8824 (progn ; Or we bug out.
8825 (when (equal major-mode 'gnus-summary-mode)
8826 (kill-buffer (current-buffer)))
8827 (error "Couldn't request group %s: %s"
8828 group (gnus-status-message group))))
8830 (unless (gnus-request-group group t)
8831 (when (equal major-mode 'gnus-summary-mode)
8832 (kill-buffer (current-buffer)))
8833 (error "Couldn't request group %s: %s"
8834 group (gnus-status-message group)))
8836 (setq gnus-newsgroup-name group)
8837 (setq gnus-newsgroup-unselected nil)
8838 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8840 (and gnus-asynchronous
8841 (gnus-check-backend-function
8842 'request-asynchronous gnus-newsgroup-name)
8843 (setq gnus-newsgroup-async
8844 (gnus-request-asynchronous gnus-newsgroup-name)))
8846 ;; Adjust and set lists of article marks.
8848 (gnus-adjust-marked-articles info))
8850 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8851 (when (gnus-virtual-group-p group)
8852 (setq cached gnus-newsgroup-cached))
8854 (setq gnus-newsgroup-unreads
8855 (gnus-set-difference
8856 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8857 gnus-newsgroup-dormant))
8859 (setq gnus-newsgroup-processable nil)
8861 (setq articles (gnus-articles-to-read group read-all))
8865 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8867 ((eq articles 0) nil)
8869 ;; Init the dependencies hash table.
8870 (setq gnus-newsgroup-dependencies
8871 (gnus-make-hashtable (length articles)))
8872 ;; Retrieve the headers and read them in.
8873 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8874 (setq gnus-newsgroup-headers
8876 (setq gnus-headers-retrieved-by
8877 (gnus-retrieve-headers
8878 articles gnus-newsgroup-name
8879 ;; We might want to fetch old headers, but
8880 ;; not if there is only 1 article.
8881 (and gnus-fetch-old-headers
8883 (not (eq gnus-fetch-old-headers 'some))
8884 (not (numberp gnus-fetch-old-headers)))
8885 (> (length articles) 1))))))
8886 (gnus-get-newsgroup-headers-xover articles)
8887 (gnus-get-newsgroup-headers)))
8888 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8890 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8892 (setq gnus-newsgroup-cached cached))
8894 ;; Set the initial limit.
8895 (setq gnus-newsgroup-limit (copy-sequence articles))
8896 ;; Remove canceled articles from the list of unread articles.
8897 (setq gnus-newsgroup-unreads
8898 (gnus-set-sorted-intersection
8899 gnus-newsgroup-unreads
8900 (setq fetched-articles
8901 (mapcar (lambda (headers) (mail-header-number headers))
8902 gnus-newsgroup-headers))))
8903 ;; Removed marked articles that do not exist.
8904 (gnus-update-missing-marks
8905 (gnus-sorted-complement fetched-articles articles))
8906 ;; We might want to build some more threads first.
8907 (and gnus-fetch-old-headers
8908 (eq gnus-headers-retrieved-by 'nov)
8909 (gnus-build-old-threads))
8910 ;; Check whether auto-expire is to be done in this group.
8911 (setq gnus-newsgroup-auto-expire
8912 (gnus-group-auto-expirable-p group))
8913 ;; Set up the article buffer now, if necessary.
8914 (unless gnus-single-article-buffer
8915 (gnus-article-setup-buffer))
8916 ;; First and last article in this newsgroup.
8917 (when gnus-newsgroup-headers
8918 (setq gnus-newsgroup-begin
8919 (mail-header-number (car gnus-newsgroup-headers))
8922 (gnus-last-element gnus-newsgroup-headers))))
8923 ;; GROUP is successfully selected.
8924 (or gnus-newsgroup-headers t)))))
8926 (defun gnus-articles-to-read (group read-all)
8927 ;; Find out what articles the user wants to read.
8929 ;; Select all articles if `read-all' is non-nil, or if there
8930 ;; are no unread articles.
8932 (and (zerop (length gnus-newsgroup-marked))
8933 (zerop (length gnus-newsgroup-unreads))))
8934 (gnus-uncompress-range (gnus-active group))
8935 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8936 (copy-sequence gnus-newsgroup-unreads))
8938 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8939 (scored (length scored-list))
8940 (number (length articles))
8941 (marked (+ (length gnus-newsgroup-marked)
8942 (length gnus-newsgroup-dormant)))
8950 ((and (or (<= scored marked) (= scored number))
8951 (numberp gnus-large-newsgroup)
8952 (> number gnus-large-newsgroup))
8956 "How many articles from %s (default %d): "
8957 gnus-newsgroup-name number))))
8958 (if (string-match "^[ \t]*$" input) number input)))
8959 ((and (> scored marked) (< scored number)
8960 (> (- scored number) 20))
8963 (format "%s %s (%d scored, %d total): "
8964 "How many articles from"
8965 group scored number))))
8966 (if (string-match "^[ \t]*$" input)
8970 (setq select (if (stringp select) (string-to-number select) select))
8971 (if (or (null select) (zerop select))
8973 (if (and (not (zerop scored)) (<= (abs select) scored))
8975 (setq articles (sort scored-list '<))
8976 (setq number (length articles)))
8977 (setq articles (copy-sequence articles)))
8979 (if (< (abs select) number)
8981 ;; Select the N oldest articles.
8982 (setcdr (nthcdr (1- (abs select)) articles) nil)
8983 ;; Select the N most recent articles.
8984 (setq articles (nthcdr (- number select) articles))))
8985 (setq gnus-newsgroup-unselected
8986 (gnus-sorted-intersection
8987 gnus-newsgroup-unreads
8988 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8991 (defun gnus-killed-articles (killed articles)
8994 (if (inline (gnus-member-of-range (car articles) killed))
8995 (setq out (cons (car articles) out)))
8996 (setq articles (cdr articles)))
8999 (defun gnus-uncompress-marks (marks)
9000 "Uncompress the mark ranges in MARKS."
9001 (let ((uncompressed '(score bookmark))
9004 (if (memq (caar marks) uncompressed)
9005 (push (car marks) out)
9006 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
9007 (setq marks (cdr marks)))
9010 (defun gnus-adjust-marked-articles (info)
9011 "Set all article lists and remove all marks that are no longer legal."
9012 (let* ((marked-lists (gnus-info-marks info))
9013 (active (gnus-active (gnus-info-group info)))
9016 (types gnus-article-mark-lists)
9017 (uncompressed '(score bookmark killed))
9018 marks var articles article mark)
9021 (setq marks (pop marked-lists))
9022 (set (setq var (intern (format "gnus-newsgroup-%s"
9023 (car (rassq (setq mark (car marks))
9025 (if (memq (car marks) uncompressed) (cdr marks)
9026 (gnus-uncompress-range (cdr marks))))
9028 (setq articles (symbol-value var))
9030 ;; All articles have to be subsets of the active articles.
9032 ;; Adjust "simple" lists.
9033 ((memq mark '(tick dormant expirable reply save))
9035 (when (or (< (setq article (pop articles)) min) (> article max))
9036 (set var (delq article (symbol-value var))))))
9038 ((memq mark uncompressed)
9040 (when (or (not (consp (setq article (pop articles))))
9041 (< (car article) min)
9042 (> (car article) max))
9043 (set var (delq article (symbol-value var))))))))))
9045 (defun gnus-update-missing-marks (missing)
9046 "Go through the list of MISSING articles and remove them mark lists."
9048 (let ((types gnus-article-mark-lists)
9050 ;; Go through all types.
9052 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
9053 (when (symbol-value var)
9054 ;; This list has articles. So we delete all missing articles
9058 (set var (delq (pop m) (symbol-value var)))))))))
9060 (defun gnus-update-marks ()
9061 "Enter the various lists of marked articles into the newsgroup info list."
9062 (let ((types gnus-article-mark-lists)
9063 (info (gnus-get-info gnus-newsgroup-name))
9064 (uncompressed '(score bookmark killed))
9065 type list newmarked symbol)
9067 ;; Add all marks lists that are non-nil to the list of marks lists.
9069 (setq type (pop types))
9070 (when (setq list (symbol-value
9072 (intern (format "gnus-newsgroup-%s"
9074 (push (cons (cdr type)
9075 (if (memq (cdr type) uncompressed) list
9076 (gnus-compress-sequence
9077 (set symbol (sort list '<)) t)))
9080 ;; Enter these new marks into the info of the group.
9082 (setcar (nthcdr 3 info) newmarked)
9083 ;; Add the marks lists to the end of the info.
9085 (setcdr (nthcdr 2 info) (list newmarked))))
9087 ;; Cut off the end of the info if there's nothing else there.
9091 (when (nthcdr (decf i) info)
9092 (setcdr (nthcdr i info) nil)))))))
9094 (defun gnus-add-marked-articles (group type articles &optional info force)
9095 ;; Add ARTICLES of TYPE to the info of GROUP.
9096 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9097 ;; add, but replace marked articles of TYPE with ARTICLES.
9098 (let ((info (or info (gnus-get-info group)))
9099 (uncompressed '(score bookmark killed))
9102 (and (not (setq marked (nthcdr 3 info)))
9104 (setcdr (nthcdr 2 info)
9105 (list (list (cons type (gnus-compress-sequence
9107 (and (not (setq m (assq type (car marked))))
9110 (cons (cons type (gnus-compress-sequence articles t) )
9114 (setcar (nthcdr 3 info)
9115 (delq (assq type (car marked)) (car marked)))
9116 (setcdr m (gnus-compress-sequence articles t)))
9117 (setcdr m (gnus-compress-sequence
9118 (sort (nconc (gnus-uncompress-range (cdr m))
9119 (copy-sequence articles)) '<) t))))))
9121 (defun gnus-set-mode-line (where)
9122 "This function sets the mode line of the article or summary buffers.
9123 If WHERE is `summary', the summary mode line format will be used."
9124 ;; Is this mode line one we keep updated?
9125 (when (memq where gnus-updated-mode-lines)
9128 ;; We evaluate this in the summary buffer since these
9129 ;; variables are buffer-local to that buffer.
9130 (set-buffer gnus-summary-buffer)
9131 ;; We bind all these variables that are used in the `eval' form
9133 (let* ((mformat (symbol-value
9135 (format "gnus-%s-mode-line-format-spec" where))))
9136 (gnus-tmp-group-name gnus-newsgroup-name)
9137 (gnus-tmp-article-number (or gnus-current-article 0))
9138 (gnus-tmp-unread gnus-newsgroup-unreads)
9139 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9140 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9141 (gnus-tmp-unread-and-unselected
9142 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9143 (zerop gnus-tmp-unselected)) "")
9144 ((zerop gnus-tmp-unselected)
9145 (format "{%d more}" gnus-tmp-unread-and-unticked))
9146 (t (format "{%d(+%d) more}"
9147 gnus-tmp-unread-and-unticked
9148 gnus-tmp-unselected))))
9150 (if (and gnus-current-headers
9151 (vectorp gnus-current-headers))
9152 (gnus-mode-string-quote
9153 (mail-header-subject gnus-current-headers)) ""))
9155 gnus-tmp-header);; passed as argument to any user-format-funcs
9156 (setq mode-string (eval mformat))
9157 (setq max-len (max 4 (if gnus-mode-non-string-length
9159 gnus-mode-non-string-length)
9160 (length mode-string))))
9161 ;; We might have to chop a bit of the string off...
9162 (when (> (length mode-string) max-len)
9164 (concat (gnus-truncate-string mode-string (- max-len 3))
9166 ;; Pad the mode string a bit.
9167 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9168 ;; Update the mode line.
9169 (setq mode-line-buffer-identification
9170 (gnus-mode-line-buffer-identification
9171 (list mode-string)))
9172 (set-buffer-modified-p t))))
9174 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9175 "Go through the HEADERS list and add all Xrefs to a hash table.
9176 The resulting hash table is returned, or nil if no Xrefs were found."
9177 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9178 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9179 (xref-hashtb (make-vector 63 0))
9180 start group entry number xrefs header)
9182 (setq header (pop headers))
9183 (when (and (setq xrefs (mail-header-xref header))
9184 (not (memq (setq number (mail-header-number header))
9187 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9188 (setq start (match-end 0))
9189 (setq group (if prefix
9190 (concat prefix (substring xrefs (match-beginning 1)
9192 (substring xrefs (match-beginning 1) (match-end 1))))
9194 (string-to-int (substring xrefs (match-beginning 2)
9196 (if (setq entry (gnus-gethash group xref-hashtb))
9197 (setcdr entry (cons number (cdr entry)))
9198 (gnus-sethash group (cons number nil) xref-hashtb)))))
9199 (and start xref-hashtb)))
9201 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9202 "Look through all the headers and mark the Xrefs as read."
9203 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9204 name entry info xref-hashtb idlist method nth4)
9206 (set-buffer gnus-group-buffer)
9207 (when (setq xref-hashtb
9208 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9211 (unless (string= from-newsgroup (setq name (symbol-name group)))
9212 (setq idlist (symbol-value group))
9213 ;; Dead groups are not updated.
9215 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9217 (if (stringp (setq nth4 (gnus-info-method info)))
9218 (setq nth4 (gnus-server-to-method nth4))))
9219 ;; Only do the xrefs if the group has the same
9220 ;; select method as the group we have just read.
9221 (or (gnus-methods-equal-p
9222 nth4 (gnus-find-method-for-group from-newsgroup))
9224 (equal nth4 (setq method (gnus-find-method-for-group
9226 (and (equal (car nth4) (car method))
9227 (equal (nth 1 nth4) (nth 1 method))))
9228 gnus-use-cross-reference
9229 (or (not (eq gnus-use-cross-reference t))
9231 ;; Only do cross-references on subscribed
9232 ;; groups, if that is what is wanted.
9233 (<= (gnus-info-level info) gnus-level-subscribed))
9234 (gnus-group-make-articles-read name idlist))))
9237 (defun gnus-group-make-articles-read (group articles)
9239 (entry (gnus-gethash group gnus-newsrc-hashtb))
9240 (info (nth 2 entry))
9241 (active (gnus-active group))
9243 ;; First peel off all illegal article numbers.
9245 (let ((ids articles)
9249 (if (and first (> id (cdr active)))
9251 ;; We'll end up in this situation in one particular
9252 ;; obscure situation. If you re-scan a group and get
9253 ;; a new article that is cross-posted to a different
9254 ;; group that has not been re-scanned, you might get
9255 ;; crossposted article that has a higher number than
9256 ;; Gnus believes possible. So we re-activate this
9257 ;; group as well. This might mean doing the
9258 ;; crossposting thingy will *increase* the number
9259 ;; of articles in some groups. Tsk, tsk.
9260 (setq active (or (gnus-activate-group group) active))))
9261 (if (or (> id (cdr active))
9262 (< id (car active)))
9263 (setq articles (delq id articles)))
9264 (setq ids (cdr ids)))))
9265 ;; If the read list is nil, we init it.
9267 (null (gnus-info-read info))
9269 (gnus-info-set-read info (cons 1 (1- (car active)))))
9270 ;; Then we add the read articles to the range.
9275 (gnus-info-read info) (setq articles (sort articles '<)))))
9276 ;; Then we have to re-compute how many unread
9277 ;; articles there are in this group.
9282 (setq num (- (1+ (cdr active)) (car active))))
9283 ((not (listp (cdr range)))
9284 (setq num (- (cdr active) (- (1+ (cdr range))
9288 (if (numberp (car range))
9290 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9291 (setq range (cdr range)))
9292 (setq num (- (cdr active) num))))
9293 ;; Update the number of unread articles.
9295 ;; Update the group buffer.
9296 (gnus-group-update-group group t)))))
9298 (defun gnus-methods-equal-p (m1 m2)
9299 (let ((m1 (or m1 gnus-select-method))
9300 (m2 (or m2 gnus-select-method)))
9302 (and (eq (car m1) (car m2))
9303 (or (not (memq 'address (assoc (symbol-name (car m1))
9304 gnus-valid-select-methods)))
9305 (equal (nth 1 m1) (nth 1 m2)))))))
9307 (defsubst gnus-header-value ()
9308 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9310 (defvar gnus-newsgroup-none-id 0)
9312 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9313 (let ((cur nntp-server-buffer)
9316 (save-excursion (set-buffer gnus-summary-buffer)
9317 gnus-newsgroup-dependencies)))
9318 headers id id-dep ref-dep end ref)
9320 (set-buffer nntp-server-buffer)
9321 (run-hooks 'gnus-parse-headers-hook)
9322 (let ((case-fold-search t)
9323 in-reply-to header p lines)
9324 (goto-char (point-min))
9325 ;; Search to the beginning of the next header. Error messages
9326 ;; do not begin with 2 or 3.
9327 (while (re-search-forward "^[23][0-9]+ " nil t)
9330 ;; This implementation of this function, with nine
9331 ;; search-forwards instead of the one re-search-forward and
9332 ;; a case (which basically was the old function) is actually
9333 ;; about twice as fast, even though it looks messier. You
9334 ;; can't have everything, I guess. Speed and elegance
9335 ;; doesn't always go hand in hand.
9344 (narrow-to-region (point)
9345 (or (and (search-forward "\n.\n" nil t)
9351 (if (search-forward "\nsubject: " nil t)
9352 (gnus-header-value) "(none)"))
9356 (if (search-forward "\nfrom: " nil t)
9357 (gnus-header-value) "(nobody)"))
9361 (if (search-forward "\ndate: " nil t)
9362 (gnus-header-value) ""))
9366 (if (search-forward "\nmessage-id: " nil t)
9367 (setq id (gnus-header-value))
9368 ;; If there was no message-id, we just fake one to make
9369 ;; subsequent routines simpler.
9370 (setq id (concat "none+"
9372 (setq gnus-newsgroup-none-id
9373 (1+ gnus-newsgroup-none-id)))))))
9377 (if (search-forward "\nreferences: " nil t)
9386 (search-backward ">" end t)
9389 (search-backward "<" end t)
9391 ;; Get the references from the in-reply-to header if there
9392 ;; were no references and the in-reply-to header looks
9394 (if (and (search-forward "\nin-reply-to: " nil t)
9395 (setq in-reply-to (gnus-header-value))
9396 (string-match "<[^>]+>" in-reply-to))
9397 (setq ref (substring in-reply-to (match-beginning 0)
9405 (if (search-forward "\nlines: " nil t)
9406 (if (numberp (setq lines (read cur)))
9412 (and (search-forward "\nxref: " nil t)
9413 (gnus-header-value)))))
9414 ;; We do the threading while we read the headers. The
9415 ;; message-id and the last reference are both entered into
9416 ;; the same hash table. Some tippy-toeing around has to be
9417 ;; done in case an article has arrived before the article
9418 ;; which it refers to.
9419 (if (boundp (setq id-dep (intern id dependencies)))
9420 (if (and (car (symbol-value id-dep))
9422 ;; An article with this Message-ID has already
9423 ;; been seen, so we ignore this one, except we add
9424 ;; any additional Xrefs (in case the two articles
9425 ;; came from different servers).
9427 (mail-header-set-xref
9428 (car (symbol-value id-dep))
9429 (concat (or (mail-header-xref
9430 (car (symbol-value id-dep))) "")
9431 (or (mail-header-xref header) "")))
9433 (setcar (symbol-value id-dep) header))
9434 (set id-dep (list header)))
9436 (if (boundp (setq ref-dep (intern ref dependencies)))
9437 (setcdr (symbol-value ref-dep)
9438 (nconc (cdr (symbol-value ref-dep))
9439 (list (symbol-value id-dep))))
9440 (set ref-dep (list nil (symbol-value id-dep))))
9441 (setq headers (cons header headers)))
9442 (goto-char (point-max))
9444 (nreverse headers)))))
9446 ;; The following macros and functions were written by Felix Lee
9447 ;; <flee@cse.psu.edu>.
9449 (defmacro gnus-nov-read-integer ()
9451 (if (= (following-char) ?\t)
9453 (let ((num (condition-case nil (read buffer) (error nil))))
9454 (if (numberp num) num 0)))
9455 (or (eobp) (forward-char 1))))
9457 (defmacro gnus-nov-skip-field ()
9458 '(search-forward "\t" eol 'move))
9460 (defmacro gnus-nov-field ()
9461 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9463 ;; Goes through the xover lines and returns a list of vectors
9464 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9465 force-new dependencies)
9466 "Parse the news overview data in the server buffer, and return a
9467 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9468 ;; Get the Xref when the users reads the articles since most/some
9469 ;; NNTP servers do not include Xrefs when using XOVER.
9470 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9471 (let ((cur nntp-server-buffer)
9472 (dependencies (or dependencies gnus-newsgroup-dependencies))
9473 number headers header)
9475 (set-buffer nntp-server-buffer)
9476 ;; Allow the user to mangle the headers before parsing them.
9477 (run-hooks 'gnus-parse-headers-hook)
9478 (goto-char (point-min))
9479 (while (and sequence (not (eobp)))
9480 (setq number (read cur))
9481 (while (and sequence (< (car sequence) number))
9482 (setq sequence (cdr sequence)))
9484 (eq number (car sequence))
9486 (setq sequence (cdr sequence))
9488 (inline (gnus-nov-parse-line
9489 number dependencies force-new)))
9490 (setq headers (cons header headers)))))
9492 (setq headers (nreverse headers)))
9495 ;; This function has to be called with point after the article number
9496 ;; on the beginning of the line.
9497 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9499 (eol (gnus-point-at-eol))
9500 (buffer (current-buffer))
9501 header ref id id-dep ref-dep)
9503 ;; overview: [num subject from date id refs chars lines misc]
9504 (narrow-to-region (point) eol)
9505 (or (eobp) (forward-char))
9511 (gnus-nov-field) ; subject
9512 (gnus-nov-field) ; from
9513 (gnus-nov-field) ; date
9514 (setq id (or (gnus-nov-field)
9517 (setq none (1+ none)))))) ; id
9520 (let ((beg (point)))
9521 (search-forward "\t" eol)
9522 (if (search-backward ">" beg t)
9526 (search-backward "<" beg t)))
9528 (gnus-nov-field)) ; refs
9529 (gnus-nov-read-integer) ; chars
9530 (gnus-nov-read-integer) ; lines
9531 (if (= (following-char) ?\n)
9533 (gnus-nov-field)) ; misc
9536 (gnus-error 4 "Strange nov line")
9542 ;; We build the thread tree.
9544 (if (boundp (setq id-dep (intern id dependencies)))
9545 (if (and (car (symbol-value id-dep))
9547 ;; An article with this Message-ID has already been seen,
9548 ;; so we ignore this one, except we add any additional
9549 ;; Xrefs (in case the two articles came from different
9552 (mail-header-set-xref
9553 (car (symbol-value id-dep))
9554 (concat (or (mail-header-xref
9555 (car (symbol-value id-dep))) "")
9556 (or (mail-header-xref header) "")))
9558 (setcar (symbol-value id-dep) header))
9559 (set id-dep (list header))))
9561 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9562 (setcdr (symbol-value ref-dep)
9563 (nconc (cdr (symbol-value ref-dep))
9564 (list (symbol-value id-dep))))
9565 (set ref-dep (list nil (symbol-value id-dep)))))
9568 (defun gnus-article-get-xrefs ()
9569 "Fill in the Xref value in `gnus-current-headers', if necessary.
9570 This is meant to be called in `gnus-article-internal-prepare-hook'."
9571 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9572 gnus-current-headers)))
9573 (or (not gnus-use-cross-reference)
9575 (and (mail-header-xref headers)
9576 (not (string= (mail-header-xref headers) "")))
9577 (let ((case-fold-search t)
9580 (nnheader-narrow-to-headers)
9581 (goto-char (point-min))
9582 (if (or (and (eq (downcase (following-char)) ?x)
9583 (looking-at "Xref:"))
9584 (search-forward "\nXref:" nil t))
9586 (goto-char (1+ (match-end 0)))
9587 (setq xref (buffer-substring (point)
9588 (progn (end-of-line) (point))))
9589 (mail-header-set-xref headers xref))))))))
9591 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9592 "Find article ID and insert the summary line for that article."
9593 (let ((header (if (and old-header use-old-header)
9594 old-header (gnus-read-header id)))
9595 (number (and (numberp id) id))
9598 ;; Rebuild the thread that this article is part of and go to the
9599 ;; article we have fetched.
9600 (when (and (not gnus-show-threads)
9602 (when (setq pos (text-property-any
9603 (point-min) (point-max) 'gnus-number
9604 (mail-header-number old-header)))
9607 (gnus-data-remove (mail-header-number old-header))))
9609 (mail-header-set-number header (mail-header-number old-header)))
9610 (setq gnus-newsgroup-sparse
9611 (delq (setq number (mail-header-number header))
9612 gnus-newsgroup-sparse))
9613 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9614 (gnus-rebuild-thread (mail-header-id header))
9615 (gnus-summary-goto-subject number nil t))
9616 (when (and (numberp number)
9618 ;; We have to update the boundaries even if we can't fetch the
9619 ;; article if ID is a number -- so that the next `P' or `N'
9620 ;; command will fetch the previous (or next) article even
9621 ;; if the one we tried to fetch this time has been canceled.
9622 (and (> number gnus-newsgroup-end)
9623 (setq gnus-newsgroup-end number))
9624 (and (< number gnus-newsgroup-begin)
9625 (setq gnus-newsgroup-begin number))
9626 (setq gnus-newsgroup-unselected
9627 (delq number gnus-newsgroup-unselected)))
9628 ;; Report back a success?
9629 (and header (mail-header-number header))))
9631 (defun gnus-summary-work-articles (n)
9632 "Return a list of articles to be worked upon. The prefix argument,
9633 the list of process marked articles, and the current article will be
9634 taken into consideration."
9637 ;; A numerical prefix has been given.
9638 (let ((backward (< n 0))
9639 (n (abs (prefix-numeric-value n)))
9644 (push (setq article (gnus-summary-article-number))
9647 (gnus-summary-find-prev nil article)
9648 (gnus-summary-find-next nil article)))
9650 (nreverse articles)))
9651 ((and (boundp 'transient-mark-mode)
9654 ;; Work on the region between point and mark.
9655 (let ((max (max (point) (mark)))
9658 (goto-char (min (point) (mark)))
9661 (push (setq article (gnus-summary-article-number)) articles)
9662 (gnus-summary-find-next nil article)
9664 (nreverse articles))))
9665 (gnus-newsgroup-processable
9666 ;; There are process-marked articles present.
9667 (reverse gnus-newsgroup-processable))
9669 ;; Just return the current article.
9670 (list (gnus-summary-article-number)))))
9672 (defun gnus-summary-search-group (&optional backward use-level)
9673 "Search for next unread newsgroup.
9674 If optional argument BACKWARD is non-nil, search backward instead."
9676 (set-buffer gnus-group-buffer)
9677 (if (gnus-group-search-forward
9678 backward nil (if use-level (gnus-group-group-level) nil))
9679 (gnus-group-group-name))))
9681 (defun gnus-summary-best-group (&optional exclude-group)
9682 "Find the name of the best unread group.
9683 If EXCLUDE-GROUP, do not go to this group."
9685 (set-buffer gnus-group-buffer)
9687 (gnus-group-best-unread-group exclude-group))))
9689 (defun gnus-summary-find-next (&optional unread article backward)
9690 (if backward (gnus-summary-find-prev)
9691 (let* ((dummy (gnus-summary-article-intangible-p))
9692 (article (or article (gnus-summary-article-number)))
9693 (arts (gnus-data-find-list article))
9695 (when (and (not dummy)
9696 (or (not gnus-summary-check-current)
9698 (not (gnus-data-unread-p (car arts)))))
9699 (setq arts (cdr arts)))
9704 (when (gnus-data-unread-p (car arts))
9705 (setq result (car arts)
9707 (setq arts (cdr arts)))
9710 (goto-char (gnus-data-pos result))
9711 (gnus-data-number result)))))
9713 (defun gnus-summary-find-prev (&optional unread article)
9714 (let* ((eobp (eobp))
9715 (article (or article (gnus-summary-article-number)))
9716 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9718 (when (and (not eobp)
9719 (or (not gnus-summary-check-current)
9721 (not (gnus-data-unread-p (car arts)))))
9722 (setq arts (cdr arts)))
9727 (and (gnus-data-unread-p (car arts))
9728 (setq result (car arts)
9730 (setq arts (cdr arts)))
9734 (goto-char (gnus-data-pos result))
9735 (gnus-data-number result)))))
9737 (defun gnus-summary-find-subject (subject &optional unread backward article)
9738 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9739 (article (or article (gnus-summary-article-number)))
9740 (articles (gnus-data-list backward))
9741 (arts (gnus-data-find-list article articles))
9743 (when (or (not gnus-summary-check-current)
9745 (not (gnus-data-unread-p (car arts))))
9746 (setq arts (cdr arts)))
9748 (and (or (not unread)
9749 (gnus-data-unread-p (car arts)))
9750 (vectorp (gnus-data-header (car arts)))
9752 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9753 (setq result (car arts)
9755 (setq arts (cdr arts)))
9757 (goto-char (gnus-data-pos result))
9758 (gnus-data-number result))))
9760 (defun gnus-summary-search-forward (&optional unread subject backward)
9761 "Search forward for an article.
9762 If UNREAD, look for unread articles. If SUBJECT, look for
9763 articles with that subject. If BACKWARD, search backward instead."
9764 (cond (subject (gnus-summary-find-subject subject unread backward))
9765 (backward (gnus-summary-find-prev unread))
9766 (t (gnus-summary-find-next unread))))
9768 (defun gnus-recenter (&optional n)
9769 "Center point in window and redisplay frame.
9770 Also do horizontal recentering."
9772 (when (and gnus-auto-center-summary
9773 (not (eq gnus-auto-center-summary 'vertical)))
9774 (gnus-horizontal-recenter))
9777 (defun gnus-summary-recenter ()
9778 "Center point in the summary window.
9779 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9780 displayed, no centering will be performed."
9781 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9782 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9783 (let* ((top (cond ((< (window-height) 4) 0)
9784 ((< (window-height) 7) 1)
9786 (height (1- (window-height)))
9787 (bottom (save-excursion (goto-char (point-max))
9788 (forward-line (- height))
9790 (window (get-buffer-window (current-buffer))))
9791 ;; The user has to want it.
9792 (when gnus-auto-center-summary
9793 (when (get-buffer-window gnus-article-buffer)
9794 ;; Only do recentering when the article buffer is displayed,
9795 ;; Set the window start to either `bottom', which is the biggest
9796 ;; possible valid number, or the second line from the top,
9797 ;; whichever is the least.
9799 window (min bottom (save-excursion
9800 (forward-line (- top)) (point)))))
9801 ;; Do horizontal recentering while we're at it.
9802 (when (and (get-buffer-window (current-buffer) t)
9803 (not (eq gnus-auto-center-summary 'vertical)))
9804 (let ((selected (selected-window)))
9805 (select-window (get-buffer-window (current-buffer) t))
9806 (gnus-summary-position-point)
9807 (gnus-horizontal-recenter)
9808 (select-window selected))))))
9810 (defun gnus-horizontal-recenter ()
9811 "Recenter the current buffer horizontally."
9812 (if (< (current-column) (/ (window-width) 2))
9813 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9814 (let* ((orig (point))
9815 (end (window-end (get-buffer-window (current-buffer) t)))
9817 ;; Find the longest line currently displayed in the window.
9818 (goto-char (window-start))
9819 (while (and (not (eobp))
9822 (setq max (max max (current-column)))
9825 ;; Scroll horizontally to center (sort of) the point.
9826 (if (> max (window-width))
9828 (get-buffer-window (current-buffer) t)
9829 (min (- (current-column) (/ (window-width) 3))
9830 (+ 2 (- max (window-width)))))
9831 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9834 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9835 (defun gnus-short-group-name (group &optional levels)
9836 "Collapse GROUP name LEVELS."
9843 (while (string-match "\\." group skip)
9844 (setq skip (match-end 0)
9847 (if (string-match ":" group)
9848 (setq foreign (substring group 0 (match-end 0))
9849 group (substring group (match-end 0))))
9851 (if (and (string-match "\\." group)
9852 (> levels (- gnus-group-uncollapsed-levels 1)))
9853 (setq name (concat name (substring group 0 1))
9854 group (substring group (match-end 0))
9856 name (concat name "."))
9857 (setq name (concat foreign name group)
9861 (defun gnus-summary-jump-to-group (newsgroup)
9862 "Move point to NEWSGROUP in group mode buffer."
9863 ;; Keep update point of group mode buffer if visible.
9864 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9865 (save-window-excursion
9866 ;; Take care of tree window mode.
9867 (if (get-buffer-window gnus-group-buffer)
9868 (pop-to-buffer gnus-group-buffer))
9869 (gnus-group-jump-to-group newsgroup))
9871 ;; Take care of tree window mode.
9872 (if (get-buffer-window gnus-group-buffer)
9873 (pop-to-buffer gnus-group-buffer)
9874 (set-buffer gnus-group-buffer))
9875 (gnus-group-jump-to-group newsgroup))))
9877 ;; This function returns a list of article numbers based on the
9878 ;; difference between the ranges of read articles in this group and
9879 ;; the range of active articles.
9880 (defun gnus-list-of-unread-articles (group)
9881 (let* ((read (gnus-info-read (gnus-get-info group)))
9882 (active (gnus-active group))
9885 ;; If none are read, then all are unread.
9887 (setq first (car active))
9888 ;; If the range of read articles is a single range, then the
9889 ;; first unread article is the article after the last read
9890 ;; article. Sounds logical, doesn't it?
9891 (if (not (listp (cdr read)))
9892 (setq first (1+ (cdr read)))
9893 ;; `read' is a list of ranges.
9894 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9899 (while (< first nlast)
9900 (setq unread (cons first unread))
9901 (setq first (1+ first))))
9902 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9903 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9904 (setq read (cdr read)))))
9905 ;; And add the last unread articles.
9906 (while (<= first last)
9907 (setq unread (cons first unread))
9908 (setq first (1+ first)))
9909 ;; Return the list of unread articles.
9912 (defun gnus-list-of-read-articles (group)
9913 "Return a list of unread, unticked and non-dormant articles."
9914 (let* ((info (gnus-get-info group))
9915 (marked (gnus-info-marks info))
9916 (active (gnus-active group)))
9918 (gnus-set-difference
9919 (gnus-sorted-complement
9920 (gnus-uncompress-range active)
9921 (gnus-list-of-unread-articles group))
9923 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9924 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9926 ;; Various summary commands
9928 (defun gnus-summary-universal-argument (arg)
9929 "Perform any operation on all articles that are process/prefixed."
9931 (gnus-set-global-variables)
9932 (let ((articles (gnus-summary-work-articles arg))
9939 (substitute-command-keys
9940 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9943 (gnus-error 1 "Undefined key")
9946 (gnus-summary-goto-subject (setq article (pop articles)))
9947 (command-execute func)
9948 (gnus-summary-remove-process-mark article)))))
9949 (gnus-summary-position-point))
9951 (defun gnus-summary-toggle-truncation (&optional arg)
9952 "Toggle truncation of summary lines.
9953 With arg, turn line truncation on iff arg is positive."
9955 (setq truncate-lines
9956 (if (null arg) (not truncate-lines)
9957 (> (prefix-numeric-value arg) 0)))
9960 (defun gnus-summary-reselect-current-group (&optional all rescan)
9961 "Exit and then reselect the current newsgroup.
9962 The prefix argument ALL means to select all articles."
9964 (gnus-set-global-variables)
9965 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
9966 (error "Ephemeral groups can't be reselected"))
9967 (let ((current-subject (gnus-summary-article-number))
9968 (group gnus-newsgroup-name))
9969 (setq gnus-newsgroup-begin nil)
9971 ;; We have to adjust the point of group mode buffer because the
9972 ;; current point was moved to the next unread newsgroup by
9974 (gnus-summary-jump-to-group group)
9977 (gnus-group-get-new-news-this-group 1)))
9978 (gnus-group-read-group all t)
9979 (gnus-summary-goto-subject current-subject nil t)))
9981 (defun gnus-summary-rescan-group (&optional all)
9982 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9984 (gnus-summary-reselect-current-group all t))
9986 (defun gnus-summary-update-info ()
9987 (let* ((group gnus-newsgroup-name))
9988 (when gnus-newsgroup-kill-headers
9989 (setq gnus-newsgroup-killed
9990 (gnus-compress-sequence
9992 (gnus-set-sorted-intersection
9993 (gnus-uncompress-range gnus-newsgroup-killed)
9994 (setq gnus-newsgroup-unselected
9995 (sort gnus-newsgroup-unselected '<)))
9996 (setq gnus-newsgroup-unreads
9997 (sort gnus-newsgroup-unreads '<))) t)))
9998 (unless (listp (cdr gnus-newsgroup-killed))
9999 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
10000 (let ((headers gnus-newsgroup-headers))
10001 (run-hooks 'gnus-exit-group-hook)
10002 (unless gnus-save-score
10003 (setq gnus-newsgroup-scored nil))
10004 ;; Set the new ranges of read articles.
10005 (gnus-update-read-articles
10006 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
10007 ;; Set the current article marks.
10008 (gnus-update-marks)
10009 ;; Do the cross-ref thing.
10010 (when gnus-use-cross-reference
10011 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
10012 ;; Do adaptive scoring, and possibly save score files.
10013 (when gnus-newsgroup-adaptive
10014 (gnus-score-adaptive))
10015 (when gnus-use-scoring
10017 ;; Do not switch windows but change the buffer to work.
10018 (set-buffer gnus-group-buffer)
10019 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10020 (gnus-group-update-group group)))))
10022 (defun gnus-summary-exit (&optional temporary)
10023 "Exit reading current newsgroup, and then return to group selection mode.
10024 gnus-exit-group-hook is called with no arguments if that value is non-nil."
10026 (gnus-set-global-variables)
10027 (gnus-kill-save-kill-buffer)
10028 (let* ((group gnus-newsgroup-name)
10029 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
10031 (buf (current-buffer)))
10032 (run-hooks 'gnus-summary-prepare-exit-hook)
10033 ;; If we have several article buffers, we kill them at exit.
10034 (unless gnus-single-article-buffer
10035 (gnus-kill-buffer gnus-original-article-buffer)
10036 (setq gnus-article-current nil))
10037 (when gnus-use-cache
10038 (gnus-cache-possibly-remove-articles)
10039 (gnus-cache-save-buffers))
10040 (when gnus-use-trees
10041 (gnus-tree-close group))
10042 ;; Make all changes in this group permanent.
10043 (unless quit-config
10044 (gnus-summary-update-info))
10045 (gnus-close-group group)
10046 ;; Make sure where I was, and go to next newsgroup.
10047 (set-buffer gnus-group-buffer)
10048 (unless quit-config
10049 (gnus-group-jump-to-group group))
10050 (run-hooks 'gnus-summary-exit-hook)
10051 (unless quit-config
10052 (gnus-group-next-unread-group 1))
10054 nil ;Nothing to do.
10055 ;; If we have several article buffers, we kill them at exit.
10056 (unless gnus-single-article-buffer
10057 (gnus-kill-buffer gnus-article-buffer)
10058 (gnus-kill-buffer gnus-original-article-buffer)
10059 (setq gnus-article-current nil))
10061 (if (not gnus-kill-summary-on-exit)
10062 (gnus-deaden-summary)
10063 ;; We set all buffer-local variables to nil. It is unclear why
10064 ;; this is needed, but if we don't, buffer-local variables are
10065 ;; not garbage-collected, it seems. This would the lead to en
10066 ;; ever-growing Emacs.
10067 (gnus-summary-clear-local-variables)
10068 (when (get-buffer gnus-article-buffer)
10069 (bury-buffer gnus-article-buffer))
10070 ;; We clear the global counterparts of the buffer-local
10071 ;; variables as well, just to be on the safe side.
10072 (gnus-configure-windows 'group 'force)
10073 (gnus-summary-clear-local-variables)
10074 ;; Return to group mode buffer.
10075 (if (eq mode 'gnus-summary-mode)
10076 (gnus-kill-buffer buf)))
10077 (setq gnus-current-select-method gnus-select-method)
10078 (pop-to-buffer gnus-group-buffer)
10079 ;; Clear the current group name.
10080 (if (not quit-config)
10082 (gnus-group-jump-to-group group)
10083 (gnus-group-next-unread-group 1)
10084 (gnus-configure-windows 'group 'force))
10085 (if (not (buffer-name (car quit-config)))
10086 (gnus-configure-windows 'group 'force)
10087 (set-buffer (car quit-config))
10088 (and (eq major-mode 'gnus-summary-mode)
10089 (gnus-set-global-variables))
10090 (gnus-configure-windows (cdr quit-config))))
10091 (unless quit-config
10092 (setq gnus-newsgroup-name nil)))))
10094 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10095 (defun gnus-summary-exit-no-update (&optional no-questions)
10096 "Quit reading current newsgroup without updating read article info."
10098 (gnus-set-global-variables)
10099 (let* ((group gnus-newsgroup-name)
10100 (quit-config (gnus-group-quit-config group)))
10101 (when (or no-questions
10103 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10104 ;; If we have several article buffers, we kill them at exit.
10105 (unless gnus-single-article-buffer
10106 (gnus-kill-buffer gnus-article-buffer)
10107 (gnus-kill-buffer gnus-original-article-buffer)
10108 (setq gnus-article-current nil))
10109 (if (not gnus-kill-summary-on-exit)
10110 (gnus-deaden-summary)
10111 (gnus-close-group group)
10112 (gnus-summary-clear-local-variables)
10113 (set-buffer gnus-group-buffer)
10114 (gnus-summary-clear-local-variables)
10115 (when (get-buffer gnus-summary-buffer)
10116 (kill-buffer gnus-summary-buffer)))
10117 (unless gnus-single-article-buffer
10118 (setq gnus-article-current nil))
10119 (when gnus-use-trees
10120 (gnus-tree-close group))
10121 (when (get-buffer gnus-article-buffer)
10122 (bury-buffer gnus-article-buffer))
10123 ;; Return to the group buffer.
10124 (gnus-configure-windows 'group 'force)
10125 ;; Clear the current group name.
10126 (setq gnus-newsgroup-name nil)
10127 (when (equal (gnus-group-group-name) group)
10128 (gnus-group-next-unread-group 1))
10130 (if (not (buffer-name (car quit-config)))
10131 (gnus-configure-windows 'group 'force)
10132 (set-buffer (car quit-config))
10133 (when (eq major-mode 'gnus-summary-mode)
10134 (gnus-set-global-variables))
10135 (gnus-configure-windows (cdr quit-config)))))))
10137 ;;; Dead summaries.
10139 (defvar gnus-dead-summary-mode-map nil)
10141 (if gnus-dead-summary-mode-map
10143 (setq gnus-dead-summary-mode-map (make-keymap))
10144 (suppress-keymap gnus-dead-summary-mode-map)
10145 (substitute-key-definition
10146 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10147 (let ((keys '("\C-d" "\r" "\177")))
10149 (define-key gnus-dead-summary-mode-map
10150 (pop keys) 'gnus-summary-wake-up-the-dead))))
10152 (defvar gnus-dead-summary-mode nil
10153 "Minor mode for Gnus summary buffers.")
10155 (defun gnus-dead-summary-mode (&optional arg)
10156 "Minor mode for Gnus summary buffers."
10158 (when (eq major-mode 'gnus-summary-mode)
10159 (make-local-variable 'gnus-dead-summary-mode)
10160 (setq gnus-dead-summary-mode
10161 (if (null arg) (not gnus-dead-summary-mode)
10162 (> (prefix-numeric-value arg) 0)))
10163 (when gnus-dead-summary-mode
10164 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10165 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10166 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10167 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10168 minor-mode-map-alist)))))
10170 (defun gnus-deaden-summary ()
10171 "Make the current summary buffer into a dead summary buffer."
10172 ;; Kill any previous dead summary buffer.
10173 (when (and gnus-dead-summary
10174 (buffer-name gnus-dead-summary))
10176 (set-buffer gnus-dead-summary)
10177 (when gnus-dead-summary-mode
10178 (kill-buffer (current-buffer)))))
10179 ;; Make this the current dead summary.
10180 (setq gnus-dead-summary (current-buffer))
10181 (gnus-dead-summary-mode 1)
10182 (let ((name (buffer-name)))
10183 (when (string-match "Summary" name)
10185 (concat (substring name 0 (match-beginning 0)) "Dead "
10186 (substring name (match-beginning 0))) t))))
10188 (defun gnus-kill-or-deaden-summary (buffer)
10189 "Kill or deaden the summary BUFFER."
10190 (when (and (buffer-name buffer)
10191 (not gnus-single-article-buffer))
10193 (set-buffer buffer)
10194 (gnus-kill-buffer gnus-article-buffer)
10195 (gnus-kill-buffer gnus-original-article-buffer)))
10196 (cond (gnus-kill-summary-on-exit
10197 (when (and gnus-use-trees
10198 (and (get-buffer buffer)
10199 (buffer-name (get-buffer buffer))))
10201 (set-buffer (get-buffer buffer))
10202 (gnus-tree-close gnus-newsgroup-name)))
10203 (gnus-kill-buffer buffer))
10204 ((and (get-buffer buffer)
10205 (buffer-name (get-buffer buffer)))
10207 (set-buffer buffer)
10208 (gnus-deaden-summary)))))
10210 (defun gnus-summary-wake-up-the-dead (&rest args)
10211 "Wake up the dead summary buffer."
10213 (gnus-dead-summary-mode -1)
10214 (let ((name (buffer-name)))
10215 (when (string-match "Dead " name)
10217 (concat (substring name 0 (match-beginning 0))
10218 (substring name (match-end 0))) t)))
10219 (gnus-message 3 "This dead summary is now alive again"))
10221 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10222 (defun gnus-summary-fetch-faq (&optional faq-dir)
10223 "Fetch the FAQ for the current group.
10224 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10228 (if current-prefix-arg
10230 "Faq dir: " (and (listp gnus-group-faq-directory)
10231 gnus-group-faq-directory)))))
10232 (let (gnus-faq-buffer)
10233 (and (setq gnus-faq-buffer
10234 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10235 (gnus-configure-windows 'summary-faq))))
10237 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10238 (defun gnus-summary-describe-group (&optional force)
10239 "Describe the current newsgroup."
10241 (gnus-group-describe-group force gnus-newsgroup-name))
10243 (defun gnus-summary-describe-briefly ()
10244 "Describe summary mode commands briefly."
10247 (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")))
10249 ;; Walking around group mode buffer from summary mode.
10251 (defun gnus-summary-next-group (&optional no-article target-group backward)
10252 "Exit current newsgroup and then select next unread newsgroup.
10253 If prefix argument NO-ARTICLE is non-nil, no article is selected
10254 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10255 previous group instead."
10257 (gnus-set-global-variables)
10258 (let ((current-group gnus-newsgroup-name)
10259 (current-buffer (current-buffer))
10261 ;; First we semi-exit this group to update Xrefs and all variables.
10262 ;; We can't do a real exit, because the window conf must remain
10263 ;; the same in case the user is prompted for info, and we don't
10264 ;; want the window conf to change before that...
10265 (gnus-summary-exit t)
10266 (while (not entered)
10267 ;; Then we find what group we are supposed to enter.
10268 (set-buffer gnus-group-buffer)
10269 (gnus-group-jump-to-group current-group)
10272 (if (eq gnus-keep-same-level 'best)
10273 (gnus-summary-best-group gnus-newsgroup-name)
10274 (gnus-summary-search-group backward gnus-keep-same-level))))
10275 (if (not target-group)
10276 ;; There are no further groups, so we return to the group
10279 (gnus-message 5 "Returning to the group buffer")
10281 (set-buffer current-buffer)
10282 (gnus-summary-exit))
10283 ;; We try to enter the target group.
10284 (gnus-group-jump-to-group target-group)
10285 (let ((unreads (gnus-group-group-unread)))
10286 (if (and (or (eq t unreads)
10287 (and unreads (not (zerop unreads))))
10288 (gnus-summary-read-group
10289 target-group nil no-article current-buffer))
10291 (setq current-group target-group
10292 target-group nil)))))))
10294 (defun gnus-summary-prev-group (&optional no-article)
10295 "Exit current newsgroup and then select previous unread newsgroup.
10296 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10298 (gnus-summary-next-group no-article nil t))
10300 ;; Walking around summary lines.
10302 (defun gnus-summary-first-subject (&optional unread)
10303 "Go to the first unread subject.
10304 If UNREAD is non-nil, go to the first unread article.
10305 Returns the article selected or nil if there are no unread articles."
10310 ((null gnus-newsgroup-data)
10311 (gnus-message 3 "No articles in the group")
10313 ;; Pick the first article.
10315 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10316 (gnus-data-number (car gnus-newsgroup-data)))
10317 ;; No unread articles.
10318 ((null gnus-newsgroup-unreads)
10319 (gnus-message 3 "No more unread articles")
10321 ;; Find the first unread article.
10323 (let ((data gnus-newsgroup-data))
10325 (not (gnus-data-unread-p (car data))))
10326 (setq data (cdr data)))
10329 (goto-char (gnus-data-pos (car data)))
10330 (gnus-data-number (car data)))))))
10331 (gnus-summary-position-point)))
10333 (defun gnus-summary-next-subject (n &optional unread dont-display)
10334 "Go to next N'th summary line.
10335 If N is negative, go to the previous N'th subject line.
10336 If UNREAD is non-nil, only unread articles are selected.
10337 The difference between N and the actual number of steps taken is
10340 (let ((backward (< n 0))
10342 (while (and (> n 0)
10344 (gnus-summary-find-prev unread)
10345 (gnus-summary-find-next unread)))
10347 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10348 (if unread " unread" "")))
10349 (unless dont-display
10350 (gnus-summary-recenter)
10351 (gnus-summary-position-point))
10354 (defun gnus-summary-next-unread-subject (n)
10355 "Go to next N'th unread summary line."
10357 (gnus-summary-next-subject n t))
10359 (defun gnus-summary-prev-subject (n &optional unread)
10360 "Go to previous N'th summary line.
10361 If optional argument UNREAD is non-nil, only unread article is selected."
10363 (gnus-summary-next-subject (- n) unread))
10365 (defun gnus-summary-prev-unread-subject (n)
10366 "Go to previous N'th unread summary line."
10368 (gnus-summary-next-subject (- n) t))
10370 (defun gnus-summary-goto-subject (article &optional force silent)
10371 "Go the subject line of ARTICLE.
10372 If FORCE, also allow jumping to articles not currently shown."
10374 (data (gnus-data-find article)))
10375 ;; We read in the article if we have to.
10378 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10379 (setq data (gnus-data-find article)))
10384 (gnus-message 3 "Can't find article %d" article))
10386 (goto-char (gnus-data-pos data))
10389 ;; Walking around summary lines with displaying articles.
10391 (defun gnus-summary-expand-window (&optional arg)
10392 "Make the summary buffer take up the entire Emacs frame.
10393 Given a prefix, will force an `article' buffer configuration."
10395 (gnus-set-global-variables)
10397 (gnus-configure-windows 'article 'force)
10398 (gnus-configure-windows 'summary 'force)))
10400 (defun gnus-summary-display-article (article &optional all-header)
10401 "Display ARTICLE in article buffer."
10402 (gnus-set-global-variables)
10406 (if gnus-summary-display-article-function
10407 (funcall gnus-summary-display-article-function article all-header)
10408 (gnus-article-prepare article all-header))
10409 (run-hooks 'gnus-select-article-hook)
10410 (unless (zerop gnus-current-article)
10411 (gnus-summary-goto-subject gnus-current-article))
10412 (gnus-summary-recenter)
10413 (when gnus-use-trees
10414 (gnus-possibly-generate-tree article)
10415 (gnus-highlight-selected-tree article))
10416 ;; Successfully display article.
10417 (gnus-article-set-window-start
10418 (cdr (assq article gnus-newsgroup-bookmarks))))))
10420 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10421 "Select the current article.
10422 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10423 non-nil, the article will be re-fetched even if it already present in
10424 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10426 ;; Make sure we are in the summary buffer to work around bbdb bug.
10427 (unless (eq major-mode 'gnus-summary-mode)
10428 (set-buffer gnus-summary-buffer))
10429 (let ((article (or article (gnus-summary-article-number)))
10430 (all-headers (not (not all-headers))) ;Must be T or NIL.
10431 gnus-summary-display-article-function
10434 (gnus-summary-article-pseudo-p article)
10435 (error "This is a pseudo-article."))
10438 (set-buffer gnus-summary-buffer)
10439 (if (or (and gnus-single-article-buffer
10440 (or (null gnus-current-article)
10441 (null gnus-article-current)
10442 (null (get-buffer gnus-article-buffer))
10443 (not (eq article (cdr gnus-article-current)))
10444 (not (equal (car gnus-article-current)
10445 gnus-newsgroup-name))))
10446 (and (not gnus-single-article-buffer)
10447 (or (null gnus-current-article)
10448 (not (eq gnus-current-article article))))
10450 ;; The requested article is different from the current article.
10452 (gnus-summary-display-article article all-headers)
10453 (setq did article))
10454 (if (or all-headers gnus-show-all-headers)
10455 (gnus-article-show-all-headers))
10458 (gnus-article-set-window-start
10459 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10461 (defun gnus-summary-set-current-mark (&optional current-mark)
10462 "Obsolete function."
10465 (defun gnus-summary-next-article (&optional unread subject backward push)
10466 "Select the next article.
10467 If UNREAD, only unread articles are selected.
10468 If SUBJECT, only articles with SUBJECT are selected.
10469 If BACKWARD, the previous article is selected instead of the next."
10471 (gnus-set-global-variables)
10473 ;; Is there such an article?
10474 ((and (gnus-summary-search-forward unread subject backward)
10475 (or (gnus-summary-display-article (gnus-summary-article-number))
10476 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10477 (gnus-summary-position-point))
10478 ;; If not, we try the first unread, if that is wanted.
10480 gnus-auto-select-same
10481 (gnus-summary-first-unread-article))
10482 (gnus-summary-position-point)
10483 (gnus-message 6 "Wrapped"))
10484 ;; Try to get next/previous article not displayed in this group.
10485 ((and gnus-auto-extend-newsgroup
10486 (not unread) (not subject))
10487 (gnus-summary-goto-article
10488 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10490 ;; Go to next/previous group.
10492 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10493 (gnus-summary-jump-to-group gnus-newsgroup-name))
10494 (let ((cmd last-command-char)
10496 (if (eq gnus-keep-same-level 'best)
10497 (gnus-summary-best-group gnus-newsgroup-name)
10498 (gnus-summary-search-group backward gnus-keep-same-level))))
10499 ;; For some reason, the group window gets selected. We change
10501 (select-window (get-buffer-window (current-buffer)))
10502 ;; Select next unread newsgroup automagically.
10504 ((or (not gnus-auto-select-next)
10506 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10507 ((or (eq gnus-auto-select-next 'quietly)
10508 (and (eq gnus-auto-select-next 'slightly-quietly)
10510 (and (eq gnus-auto-select-next 'almost-quietly)
10511 (gnus-summary-last-article-p)))
10513 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10514 (gnus-summary-exit)
10515 (gnus-message 7 "No more%s articles (%s)..."
10516 (if unread " unread" "")
10517 (if group (concat "selecting " group)
10519 (gnus-summary-next-group nil group backward)))
10521 (gnus-summary-walk-group-buffer
10522 gnus-newsgroup-name cmd unread backward)))))))
10524 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10525 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10526 (?\C-p (gnus-group-prev-unread-group 1))))
10527 keve key group ended)
10529 (set-buffer gnus-group-buffer)
10530 (gnus-summary-jump-to-group from-group)
10532 (if (eq gnus-keep-same-level 'best)
10533 (gnus-summary-best-group gnus-newsgroup-name)
10534 (gnus-summary-search-group backward gnus-keep-same-level))))
10537 5 "No more%s articles%s" (if unread " unread" "")
10539 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10540 (format " (Type %s for %s [%s])"
10541 (single-key-description cmd) group
10542 (car (gnus-gethash group gnus-newsrc-hashtb)))
10543 (format " (Type %s to exit %s)"
10544 (single-key-description cmd)
10545 gnus-newsgroup-name)))
10546 ;; Confirm auto selection.
10547 (setq key (car (setq keve (gnus-read-event-char))))
10550 ((assq key keystrokes)
10551 (let ((obuf (current-buffer)))
10552 (switch-to-buffer gnus-group-buffer)
10554 (gnus-group-jump-to-group group))
10555 (eval (cadr (assq key keystrokes)))
10556 (setq group (gnus-group-group-name))
10557 (switch-to-buffer obuf))
10560 (if (or (not group)
10561 (gnus-ephemeral-group-p gnus-newsgroup-name))
10562 (gnus-summary-exit)
10563 (gnus-summary-next-group nil group backward)))
10565 (push (cdr keve) unread-command-events))))))
10567 (defun gnus-read-event-char ()
10568 "Get the next event."
10569 (let ((event (read-event)))
10570 (cons (and (numberp event) event) event)))
10572 (defun gnus-summary-next-unread-article ()
10573 "Select unread article after current one."
10575 (gnus-summary-next-article t (and gnus-auto-select-same
10576 (gnus-summary-article-subject))))
10578 (defun gnus-summary-prev-article (&optional unread subject)
10579 "Select the article after the current one.
10580 If UNREAD is non-nil, only unread articles are selected."
10582 (gnus-summary-next-article unread subject t))
10584 (defun gnus-summary-prev-unread-article ()
10585 "Select unred article before current one."
10587 (gnus-summary-prev-article t (and gnus-auto-select-same
10588 (gnus-summary-article-subject))))
10590 (defun gnus-summary-next-page (&optional lines circular)
10591 "Show next page of the selected article.
10592 If at the end of the current article, select the next article.
10593 LINES says how many lines should be scrolled up.
10595 If CIRCULAR is non-nil, go to the start of the article instead of
10596 selecting the next article when reaching the end of the current
10599 (setq gnus-summary-buffer (current-buffer))
10600 (gnus-set-global-variables)
10601 (let ((article (gnus-summary-article-number))
10603 (gnus-configure-windows 'article)
10604 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10605 (if (and (eq gnus-summary-goto-unread 'never)
10606 (not (gnus-summary-last-article-p article)))
10607 (gnus-summary-next-article)
10608 (gnus-summary-next-unread-article))
10609 (if (or (null gnus-current-article)
10610 (null gnus-article-current)
10611 (/= article (cdr gnus-article-current))
10612 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10613 ;; Selected subject is different from current article's.
10614 (gnus-summary-display-article article)
10615 (gnus-eval-in-buffer-window gnus-article-buffer
10616 (setq endp (gnus-article-next-page lines)))
10619 (gnus-summary-beginning-of-article))
10621 (gnus-message 3 "End of message"))
10623 (if (and (eq gnus-summary-goto-unread 'never)
10624 (not (gnus-summary-last-article-p article)))
10625 (gnus-summary-next-article)
10626 (gnus-summary-next-unread-article)))))))
10627 (gnus-summary-recenter)
10628 (gnus-summary-position-point)))
10630 (defun gnus-summary-prev-page (&optional lines)
10631 "Show previous page of selected article.
10632 Argument LINES specifies lines to be scrolled down."
10634 (gnus-set-global-variables)
10635 (let ((article (gnus-summary-article-number)))
10636 (gnus-configure-windows 'article)
10637 (if (or (null gnus-current-article)
10638 (null gnus-article-current)
10639 (/= article (cdr gnus-article-current))
10640 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10641 ;; Selected subject is different from current article's.
10642 (gnus-summary-display-article article)
10643 (gnus-summary-recenter)
10644 (gnus-eval-in-buffer-window gnus-article-buffer
10645 (gnus-article-prev-page lines))))
10646 (gnus-summary-position-point))
10648 (defun gnus-summary-scroll-up (lines)
10649 "Scroll up (or down) one line current article.
10650 Argument LINES specifies lines to be scrolled up (or down if negative)."
10652 (gnus-set-global-variables)
10653 (gnus-configure-windows 'article)
10654 (gnus-summary-show-thread)
10655 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10656 (gnus-eval-in-buffer-window gnus-article-buffer
10658 (if (gnus-article-next-page lines)
10659 (gnus-message 3 "End of message")))
10661 (gnus-article-prev-page (- lines))))))
10662 (gnus-summary-recenter)
10663 (gnus-summary-position-point))
10665 (defun gnus-summary-next-same-subject ()
10666 "Select next article which has the same subject as current one."
10668 (gnus-set-global-variables)
10669 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10671 (defun gnus-summary-prev-same-subject ()
10672 "Select previous article which has the same subject as current one."
10674 (gnus-set-global-variables)
10675 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10677 (defun gnus-summary-next-unread-same-subject ()
10678 "Select next unread article which has the same subject as current one."
10680 (gnus-set-global-variables)
10681 (gnus-summary-next-article t (gnus-summary-article-subject)))
10683 (defun gnus-summary-prev-unread-same-subject ()
10684 "Select previous unread article which has the same subject as current one."
10686 (gnus-set-global-variables)
10687 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10689 (defun gnus-summary-first-unread-article ()
10690 "Select the first unread article.
10691 Return nil if there are no unread articles."
10693 (gnus-set-global-variables)
10695 (if (gnus-summary-first-subject t)
10697 (gnus-summary-show-thread)
10698 (gnus-summary-first-subject t)
10699 (gnus-summary-display-article (gnus-summary-article-number))))
10700 (gnus-summary-position-point)))
10702 (defun gnus-summary-best-unread-article ()
10703 "Select the unread article with the highest score."
10705 (gnus-set-global-variables)
10706 (let ((best -1000000)
10707 (data gnus-newsgroup-data)
10710 (and (gnus-data-unread-p (car data))
10712 (gnus-summary-article-score (gnus-data-number (car data))))
10715 article (gnus-data-number (car data))))
10716 (setq data (cdr data)))
10719 (gnus-summary-goto-article article)
10720 (error "No unread articles"))
10721 (gnus-summary-position-point))))
10723 (defun gnus-summary-last-subject ()
10724 "Go to the last displayed subject line in the group."
10725 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10727 (gnus-summary-goto-subject article))))
10729 (defun gnus-summary-goto-article (article &optional all-headers force)
10730 "Fetch ARTICLE and display it if it exists.
10731 If ALL-HEADERS is non-nil, no header lines are hidden."
10737 (mapcar (lambda (number) (list (int-to-string number)))
10738 gnus-newsgroup-limit)))
10742 (if (gnus-summary-goto-subject article force)
10743 (gnus-summary-display-article article all-headers)
10744 (gnus-message 4 "Couldn't go to article %s" article) nil)
10745 (gnus-summary-position-point)))
10747 (defun gnus-summary-goto-last-article ()
10748 "Go to the previously read article."
10751 (and gnus-last-article
10752 (gnus-summary-goto-article gnus-last-article))
10753 (gnus-summary-position-point)))
10755 (defun gnus-summary-pop-article (number)
10756 "Pop one article off the history and go to the previous.
10757 NUMBER articles will be popped off."
10760 (setq gnus-newsgroup-history
10761 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10763 (gnus-summary-goto-article (car to))
10764 (error "Article history empty")))
10765 (gnus-summary-position-point))
10767 ;; Summary commands and functions for limiting the summary buffer.
10769 (defun gnus-summary-limit-to-articles (n)
10770 "Limit the summary buffer to the next N articles.
10771 If not given a prefix, use the process marked articles instead."
10773 (gnus-set-global-variables)
10775 (let ((articles (gnus-summary-work-articles n)))
10776 (setq gnus-newsgroup-processable nil)
10777 (gnus-summary-limit articles))
10778 (gnus-summary-position-point)))
10780 (defun gnus-summary-pop-limit (&optional total)
10781 "Restore the previous limit.
10782 If given a prefix, remove all limits."
10784 (gnus-set-global-variables)
10786 (setq gnus-newsgroup-limits
10787 (list (mapcar (lambda (h) (mail-header-number h))
10788 gnus-newsgroup-headers))))
10789 (unless gnus-newsgroup-limits
10790 (error "No limit to pop"))
10792 (gnus-summary-limit nil 'pop)
10793 (gnus-summary-position-point)))
10795 (defun gnus-summary-limit-to-subject (subject &optional header)
10796 "Limit the summary buffer to articles that have subjects that match a regexp."
10797 (interactive "sRegexp: ")
10799 (setq header "subject"))
10800 (when (not (equal "" subject))
10802 (let ((articles (gnus-summary-find-matching
10803 (or header "subject") subject 'all)))
10804 (or articles (error "Found no matches for \"%s\"" subject))
10805 (gnus-summary-limit articles))
10806 (gnus-summary-position-point))))
10808 (defun gnus-summary-limit-to-author (from)
10809 "Limit the summary buffer to articles that have authors that match a regexp."
10810 (interactive "sRegexp: ")
10811 (gnus-summary-limit-to-subject from "from"))
10813 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10815 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10817 (defun gnus-summary-limit-to-unread (&optional all)
10818 "Limit the summary buffer to articles that are not marked as read.
10819 If ALL is non-nil, limit strictly to unread articles."
10822 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10823 (gnus-summary-limit-to-marks
10824 ;; Concat all the marks that say that an article is read and have
10826 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10827 gnus-killed-mark gnus-kill-file-mark
10828 gnus-low-score-mark gnus-expirable-mark
10829 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10832 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10833 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10835 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10836 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10837 If REVERSE, limit the summary buffer to articles that are not marked
10838 with MARKS. MARKS can either be a string of marks or a list of marks.
10839 Returns how many articles were removed."
10840 (interactive "sMarks: ")
10841 (gnus-set-global-variables)
10843 (let ((data gnus-newsgroup-data)
10844 (marks (if (listp marks) marks
10845 (append marks nil))) ; Transform to list.
10848 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10849 (memq (gnus-data-mark (car data)) marks))
10850 (setq articles (cons (gnus-data-number (car data)) articles)))
10851 (setq data (cdr data)))
10852 (gnus-summary-limit articles))
10853 (gnus-summary-position-point)))
10855 (defun gnus-summary-limit-to-score (&optional score)
10856 "Limit to articles with score at or above SCORE."
10858 (gnus-set-global-variables)
10859 (setq score (if score
10860 (prefix-numeric-value score)
10861 (or gnus-summary-default-score 0)))
10862 (let ((data gnus-newsgroup-data)
10865 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10867 (push (gnus-data-number (car data)) articles))
10868 (setq data (cdr data)))
10870 (gnus-summary-limit articles)
10871 (gnus-summary-position-point))))
10873 (defun gnus-summary-limit-include-dormant ()
10874 "Display all the hidden articles that are marked as dormant."
10876 (gnus-set-global-variables)
10877 (or gnus-newsgroup-dormant
10878 (error "There are no dormant articles in this group"))
10880 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10881 (gnus-summary-position-point)))
10883 (defun gnus-summary-limit-exclude-dormant ()
10884 "Hide all dormant articles."
10886 (gnus-set-global-variables)
10888 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10889 (gnus-summary-position-point)))
10891 (defun gnus-summary-limit-exclude-childless-dormant ()
10892 "Hide all dormant articles that have no children."
10894 (gnus-set-global-variables)
10895 (let ((data (gnus-data-list t))
10896 articles d children)
10897 ;; Find all articles that are either not dormant or have
10899 (while (setq d (pop data))
10900 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10901 (and (setq children
10902 (gnus-article-children (gnus-data-number d)))
10905 (when (memq (car children) articles)
10910 (push (gnus-data-number d) articles)))
10911 ;; Do the limiting.
10913 (gnus-summary-limit articles)
10914 (gnus-summary-position-point))))
10916 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10917 "Mark all unread excluded articles as read.
10918 If ALL, mark even excluded ticked and dormants as read."
10920 (let ((articles (gnus-sorted-complement
10922 (mapcar (lambda (h) (mail-header-number h))
10923 gnus-newsgroup-headers)
10925 (sort gnus-newsgroup-limit '<)))
10927 (setq gnus-newsgroup-unreads nil)
10929 (setq gnus-newsgroup-dormant nil
10930 gnus-newsgroup-marked nil
10931 gnus-newsgroup-reads
10933 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10934 gnus-newsgroup-reads))
10935 (while (setq article (pop articles))
10936 (unless (or (memq article gnus-newsgroup-dormant)
10937 (memq article gnus-newsgroup-marked))
10938 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10940 (defun gnus-summary-limit (articles &optional pop)
10942 ;; We pop the previous limit off the stack and use that.
10943 (setq articles (car gnus-newsgroup-limits)
10944 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10945 ;; We use the new limit, so we push the old limit on the stack.
10946 (setq gnus-newsgroup-limits
10947 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10949 (setq gnus-newsgroup-limit articles)
10950 (let ((total (length gnus-newsgroup-data))
10951 (data (gnus-data-find-list (gnus-summary-article-number)))
10952 (gnus-summary-mark-below nil) ; Inhibit this.
10954 ;; This will do all the work of generating the new summary buffer
10955 ;; according to the new limit.
10956 (gnus-summary-prepare)
10957 ;; Hide any threads, possibly.
10958 (and gnus-show-threads
10959 gnus-thread-hide-subtree
10960 (gnus-summary-hide-all-threads))
10961 ;; Try to return to the article you were at, or one in the
10964 ;; We try to find some article after the current one.
10966 (and (gnus-summary-goto-subject
10967 (gnus-data-number (car data)) nil t)
10970 (setq data (cdr data))))
10972 ;; If there is no data, that means that we were after the last
10973 ;; article. The same goes when we can't find any articles
10974 ;; after the current one.
10976 (goto-char (point-max))
10977 (gnus-summary-find-prev)))
10978 ;; We return how many articles were removed from the summary
10979 ;; buffer as a result of the new limit.
10980 (- total (length gnus-newsgroup-data))))
10982 (defsubst gnus-invisible-cut-children (threads)
10985 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10990 (defsubst gnus-cut-thread (thread)
10991 "Go forwards in the thread until we find an article that we want to display."
10992 (when (or (eq gnus-fetch-old-headers 'some)
10993 (eq gnus-build-sparse-threads 'some)
10994 (eq gnus-build-sparse-threads 'more))
10995 ;; Deal with old-fetched headers and sparse threads.
10999 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
11000 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
11001 (or (<= (length (cdr thread)) 1)
11002 (gnus-invisible-cut-children (cdr thread))))
11003 (setq thread (cadr thread))))
11006 (defun gnus-cut-threads (threads)
11007 "Cut off all uninteresting articles from the beginning of threads."
11008 (when (or (eq gnus-fetch-old-headers 'some)
11009 (eq gnus-build-sparse-threads 'some)
11010 (eq gnus-build-sparse-threads 'more))
11011 (let ((th threads))
11013 (setcar th (gnus-cut-thread (car th)))
11014 (setq th (cdr th)))))
11015 ;; Remove nixed out threads.
11016 (delq nil threads))
11018 (defun gnus-summary-initial-limit (&optional show-if-empty)
11019 "Figure out what the initial limit is supposed to be on group entry.
11020 This entails weeding out unwanted dormants, low-scored articles,
11021 fetch-old-headers verbiage, and so on."
11022 ;; Most groups have nothing to remove.
11023 (if (or gnus-inhibit-limiting
11024 (and (null gnus-newsgroup-dormant)
11025 (not (eq gnus-fetch-old-headers 'some))
11026 (null gnus-summary-expunge-below)
11027 (not (eq gnus-build-sparse-threads 'some))
11028 (not (eq gnus-build-sparse-threads 'more))
11029 (null gnus-thread-expunge-below)
11030 (not gnus-use-nocem)))
11032 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11033 (setq gnus-newsgroup-limit nil)
11036 (unless (car (symbol-value node))
11037 ;; These threads have no parents -- they are roots.
11038 (let ((nodes (cdr (symbol-value node)))
11041 (if (and gnus-thread-expunge-below
11042 (< (gnus-thread-total-score (car nodes))
11043 gnus-thread-expunge-below))
11044 (gnus-expunge-thread (pop nodes))
11045 (setq thread (pop nodes))
11046 (gnus-summary-limit-children thread))))))
11047 gnus-newsgroup-dependencies)
11048 ;; If this limitation resulted in an empty group, we might
11049 ;; pop the previous limit and use it instead.
11050 (when (and (not gnus-newsgroup-limit)
11052 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
11053 gnus-newsgroup-limit))
11055 (defun gnus-summary-limit-children (thread)
11056 "Return 1 if this subthread is visible and 0 if it is not."
11057 ;; First we get the number of visible children to this thread. This
11058 ;; is done by recursing down the thread using this function, so this
11059 ;; will really go down to a leaf article first, before slowly
11060 ;; working its way up towards the root.
11064 (apply '+ (mapcar 'gnus-summary-limit-children
11067 (number (mail-header-number (car thread)))
11070 ;; If this article is dormant and has absolutely no visible
11071 ;; children, then this article isn't visible.
11072 (and (memq number gnus-newsgroup-dormant)
11074 ;; If this is "fetch-old-headered" and there is only one
11075 ;; visible child (or less), then we don't want this article.
11076 (and (eq gnus-fetch-old-headers 'some)
11077 (memq number gnus-newsgroup-ancient)
11079 ;; If this is a sparsely inserted article with no children,
11080 ;; we don't want it.
11081 (and (eq gnus-build-sparse-threads 'some)
11082 (memq number gnus-newsgroup-sparse)
11084 ;; If we use expunging, and this article is really
11085 ;; low-scored, then we don't want this article.
11086 (when (and gnus-summary-expunge-below
11088 (or (cdr (assq number gnus-newsgroup-scored))
11089 gnus-summary-default-score))
11090 gnus-summary-expunge-below))
11091 ;; We increase the expunge-tally here, but that has
11092 ;; nothing to do with the limits, really.
11093 (incf gnus-newsgroup-expunged-tally)
11094 ;; We also mark as read here, if that's wanted.
11095 (when (and gnus-summary-mark-below
11096 (< score gnus-summary-mark-below))
11097 (setq gnus-newsgroup-unreads
11098 (delq number gnus-newsgroup-unreads))
11099 (if gnus-newsgroup-auto-expire
11100 (push number gnus-newsgroup-expirable)
11101 (push (cons number gnus-low-score-mark)
11102 gnus-newsgroup-reads)))
11104 (and gnus-use-nocem
11105 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11106 ;; Nope, invisible article.
11108 ;; Ok, this article is to be visible, so we add it to the limit
11110 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11113 (defun gnus-expunge-thread (thread)
11114 "Mark all articles in THREAD as read."
11115 (let* ((number (mail-header-number (car thread))))
11116 (incf gnus-newsgroup-expunged-tally)
11117 ;; We also mark as read here, if that's wanted.
11118 (setq gnus-newsgroup-unreads
11119 (delq number gnus-newsgroup-unreads))
11120 (if gnus-newsgroup-auto-expire
11121 (push number gnus-newsgroup-expirable)
11122 (push (cons number gnus-low-score-mark)
11123 gnus-newsgroup-reads)))
11124 ;; Go recursively through all subthreads.
11125 (mapcar 'gnus-expunge-thread (cdr thread)))
11127 ;; Summary article oriented commands
11129 (defun gnus-summary-refer-parent-article (n)
11130 "Refer parent article N times.
11131 The difference between N and the number of articles fetched is returned."
11133 (gnus-set-global-variables)
11137 (let* ((header (gnus-summary-article-header))
11139 ;; If we try to find the parent of the currently
11140 ;; displayed article, then we take a look at the actual
11141 ;; References header, since this is slightly more
11142 ;; reliable than the References field we got from the
11144 (if (and (eq (mail-header-number header)
11145 (cdr gnus-article-current))
11146 (equal gnus-newsgroup-name
11147 (car gnus-article-current)))
11149 (set-buffer gnus-original-article-buffer)
11150 (nnheader-narrow-to-headers)
11152 (message-fetch-field "references")
11154 ;; It's not the current article, so we take a bet on
11155 ;; the value we got from the server.
11156 (mail-header-references header))))
11157 (if (setq ref (or ref (mail-header-references header)))
11158 (or (gnus-summary-refer-article (gnus-parent-id ref))
11159 (gnus-message 1 "Couldn't find parent"))
11160 (gnus-message 1 "No references in article %d"
11161 (gnus-summary-article-number))
11164 (gnus-summary-position-point)
11167 (defun gnus-summary-refer-references ()
11168 "Fetch all articles mentioned in the References header.
11169 Return how many articles were fetched."
11171 (gnus-set-global-variables)
11172 (let ((ref (mail-header-references (gnus-summary-article-header)))
11173 (current (gnus-summary-article-number))
11175 ;; For each Message-ID in the References header...
11176 (while (string-match "<[^>]*>" ref)
11178 ;; ... fetch that article.
11179 (gnus-summary-refer-article
11180 (prog1 (match-string 0 ref)
11181 (setq ref (substring ref (match-end 0))))))
11182 (gnus-summary-goto-subject current)
11183 (gnus-summary-position-point)
11186 (defun gnus-summary-refer-article (message-id)
11187 "Fetch an article specified by MESSAGE-ID."
11188 (interactive "sMessage-ID: ")
11189 (when (and (stringp message-id)
11190 (not (zerop (length message-id))))
11191 ;; Construct the correct Message-ID if necessary.
11192 ;; Suggested by tale@pawl.rpi.edu.
11193 (unless (string-match "^<" message-id)
11194 (setq message-id (concat "<" message-id)))
11195 (unless (string-match ">$" message-id)
11196 (setq message-id (concat message-id ">")))
11197 (let* ((header (gnus-id-to-header message-id))
11198 (sparse (and header
11199 (memq (mail-header-number header)
11200 gnus-newsgroup-sparse))))
11203 ;; The article is present in the buffer, to we just go to it.
11204 (gnus-summary-goto-article
11205 (mail-header-number header) nil header)
11207 (gnus-summary-update-article (mail-header-number header))))
11208 ;; We fetch the article
11209 (let ((gnus-override-method
11210 (and (gnus-news-group-p gnus-newsgroup-name)
11211 gnus-refer-article-method))
11213 ;; Start the special refer-article method, if necessary.
11214 (when (and gnus-refer-article-method
11215 (gnus-news-group-p gnus-newsgroup-name))
11216 (gnus-check-server gnus-refer-article-method))
11217 ;; Fetch the header, and display the article.
11218 (if (setq number (gnus-summary-insert-subject message-id))
11219 (gnus-summary-select-article nil nil nil number)
11220 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11222 (defun gnus-summary-enter-digest-group (&optional force)
11223 "Enter a digest group based on the current article."
11225 (gnus-set-global-variables)
11226 (gnus-summary-select-article)
11227 (let ((name (format "%s-%d"
11228 (gnus-group-prefixed-name
11229 gnus-newsgroup-name (list 'nndoc ""))
11230 gnus-current-article))
11231 (ogroup gnus-newsgroup-name)
11232 (case-fold-search t)
11233 (buf (current-buffer))
11236 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11237 (insert-buffer-substring gnus-original-article-buffer)
11239 (goto-char (point-min))
11240 (or (search-forward "\n\n" nil t) (point)))
11241 (goto-char (point-min))
11242 (delete-matching-lines "^\\(Path\\):\\|^From ")
11245 (if (gnus-group-read-ephemeral-group
11246 name `(nndoc ,name (nndoc-address
11248 (nndoc-article-type ,(if force 'digest 'guess))) t)
11249 ;; Make all postings to this group go to the parent group.
11250 (nconc (gnus-info-params (gnus-get-info name))
11251 (list (cons 'to-group ogroup)))
11252 ;; Couldn't select this doc group.
11253 (switch-to-buffer buf)
11254 (gnus-set-global-variables)
11255 (gnus-configure-windows 'summary)
11256 (gnus-message 3 "Article couldn't be entered?"))
11257 (kill-buffer dig))))
11259 (defun gnus-summary-isearch-article (&optional regexp-p)
11260 "Do incremental search forward on the current article.
11261 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11263 (gnus-set-global-variables)
11264 (gnus-summary-select-article)
11265 (gnus-configure-windows 'article)
11266 (gnus-eval-in-buffer-window gnus-article-buffer
11267 ;;(goto-char (point-min))
11268 (isearch-forward regexp-p)))
11270 (defun gnus-summary-search-article-forward (regexp &optional backward)
11271 "Search for an article containing REGEXP forward.
11272 If BACKWARD, search backward instead."
11275 (format "Search article %s (regexp%s): "
11276 (if current-prefix-arg "backward" "forward")
11277 (if gnus-last-search-regexp
11278 (concat ", default " gnus-last-search-regexp)
11280 current-prefix-arg))
11281 (gnus-set-global-variables)
11282 (if (string-equal regexp "")
11283 (setq regexp (or gnus-last-search-regexp ""))
11284 (setq gnus-last-search-regexp regexp))
11285 (unless (gnus-summary-search-article regexp backward)
11286 (error "Search failed: \"%s\"" regexp)))
11288 (defun gnus-summary-search-article-backward (regexp)
11289 "Search for an article containing REGEXP backward."
11292 (format "Search article backward (regexp%s): "
11293 (if gnus-last-search-regexp
11294 (concat ", default " gnus-last-search-regexp)
11296 (gnus-summary-search-article-forward regexp 'backward))
11298 (defun gnus-summary-search-article (regexp &optional backward)
11299 "Search for an article containing REGEXP.
11300 Optional argument BACKWARD means do search for backward.
11301 `gnus-select-article-hook' is not called during the search."
11302 (let ((gnus-select-article-hook nil) ;Disable hook.
11303 (gnus-article-display-hook nil)
11304 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11307 're-search-backward 're-search-forward))
11308 (sum (current-buffer))
11310 (gnus-save-hidden-threads
11311 (gnus-summary-select-article)
11312 (set-buffer gnus-article-buffer)
11316 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11318 (re-search-backward regexp nil t)
11319 (re-search-forward regexp nil t))
11320 ;; We found the regexp.
11322 (setq found 'found)
11323 (beginning-of-line)
11325 (get-buffer-window (current-buffer))
11329 ;; We didn't find it, so we go to the next article.
11331 (if (not (if backward (gnus-summary-find-prev)
11332 (gnus-summary-find-next)))
11333 ;; No more articles.
11335 ;; Select the next article and adjust point.
11336 (gnus-summary-select-article)
11337 (set-buffer gnus-article-buffer)
11339 (goto-char (if backward (point-max) (point-min))))))
11340 (gnus-message 7 ""))
11341 ;; Return whether we found the regexp.
11342 (when (eq found 'found)
11343 (gnus-summary-show-thread)
11344 (gnus-summary-goto-subject gnus-current-article)
11345 (gnus-summary-position-point)
11348 (defun gnus-summary-find-matching (header regexp &optional backward unread
11350 "Return a list of all articles that match REGEXP on HEADER.
11351 The search stars on the current article and goes forwards unless
11352 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11353 If UNREAD is non-nil, only unread articles will
11354 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11355 in the comparisons."
11356 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11357 (gnus-data-find-list
11358 (gnus-summary-article-number) (gnus-data-list backward))))
11359 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11360 (case-fold-search (not not-case-fold))
11362 (or (fboundp (intern (concat "mail-header-" header)))
11363 (error "%s is not a valid header" header))
11365 (setq d (car data))
11366 (and (or (not unread) ; We want all articles...
11367 (gnus-data-unread-p d)) ; Or just unreads.
11368 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11369 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11370 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11371 (setq data (cdr data)))
11372 (nreverse articles)))
11374 (defun gnus-summary-execute-command (header regexp command &optional backward)
11375 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11376 If HEADER is an empty string (or nil), the match is done on the entire
11377 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11379 (list (let ((completion-ignore-case t))
11382 (mapcar (lambda (string) (list string))
11383 '("Number" "Subject" "From" "Lines" "Date"
11384 "Message-ID" "Xref" "References" "Body"))
11385 nil 'require-match))
11386 (read-string "Regexp: ")
11387 (read-key-sequence "Command: ")
11388 current-prefix-arg))
11389 (when (equal header "Body")
11391 (gnus-set-global-variables)
11392 ;; Hidden thread subtrees must be searched as well.
11393 (gnus-summary-show-all-threads)
11394 ;; We don't want to change current point nor window configuration.
11396 (save-window-excursion
11397 (gnus-message 6 "Executing %s..." (key-description command))
11398 ;; We'd like to execute COMMAND interactively so as to give arguments.
11399 (gnus-execute header regexp
11400 `(lambda () (call-interactively ',(key-binding command)))
11402 (gnus-message 6 "Executing %s...done" (key-description command)))))
11404 (defun gnus-summary-beginning-of-article ()
11405 "Scroll the article back to the beginning."
11407 (gnus-set-global-variables)
11408 (gnus-summary-select-article)
11409 (gnus-configure-windows 'article)
11410 (gnus-eval-in-buffer-window gnus-article-buffer
11412 (goto-char (point-min))
11413 (and gnus-break-pages (gnus-narrow-to-page))))
11415 (defun gnus-summary-end-of-article ()
11416 "Scroll to the end of the article."
11418 (gnus-set-global-variables)
11419 (gnus-summary-select-article)
11420 (gnus-configure-windows 'article)
11421 (gnus-eval-in-buffer-window gnus-article-buffer
11423 (goto-char (point-max))
11425 (and gnus-break-pages (gnus-narrow-to-page))))
11427 (defun gnus-summary-show-article (&optional arg)
11428 "Force re-fetching of the current article.
11429 If ARG (the prefix) is non-nil, show the raw article without any
11430 article massaging functions being run."
11432 (gnus-set-global-variables)
11434 ;; Select the article the normal way.
11435 (gnus-summary-select-article nil 'force)
11436 ;; Bind the article treatment functions to nil.
11437 (let ((gnus-have-all-headers t)
11438 gnus-article-display-hook
11439 gnus-article-prepare-hook
11442 (gnus-summary-select-article nil 'force)))
11443 (gnus-summary-goto-subject gnus-current-article)
11444 ; (gnus-configure-windows 'article)
11445 (gnus-summary-position-point))
11447 (defun gnus-summary-verbose-headers (&optional arg)
11448 "Toggle permanent full header display.
11449 If ARG is a positive number, turn header display on.
11450 If ARG is a negative number, turn header display off."
11452 (gnus-set-global-variables)
11453 (gnus-summary-toggle-header arg)
11454 (setq gnus-show-all-headers
11455 (cond ((or (not (numberp arg))
11457 (not gnus-show-all-headers))
11461 (defun gnus-summary-toggle-header (&optional arg)
11462 "Show the headers if they are hidden, or hide them if they are shown.
11463 If ARG is a positive number, show the entire header.
11464 If ARG is a negative number, hide the unwanted header lines."
11466 (gnus-set-global-variables)
11468 (set-buffer gnus-article-buffer)
11469 (let* ((buffer-read-only nil)
11470 (inhibit-point-motion-hooks t)
11471 (hidden (text-property-any
11472 (goto-char (point-min)) (search-forward "\n\n")
11475 (goto-char (point-min))
11476 (when (search-forward "\n\n" nil t)
11477 (delete-region (point-min) (1- (point))))
11478 (goto-char (point-min))
11480 (set-buffer gnus-original-article-buffer)
11481 (goto-char (point-min))
11482 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11483 (insert-buffer-substring gnus-original-article-buffer 1 e)
11484 (let ((gnus-inhibit-hiding t))
11485 (run-hooks 'gnus-article-display-hook))
11486 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11487 (gnus-article-hide-headers)))))
11489 (defun gnus-summary-show-all-headers ()
11490 "Make all header lines visible."
11492 (gnus-set-global-variables)
11493 (gnus-article-show-all-headers))
11495 (defun gnus-summary-toggle-mime (&optional arg)
11496 "Toggle MIME processing.
11497 If ARG is a positive number, turn MIME processing on."
11499 (gnus-set-global-variables)
11500 (setq gnus-show-mime
11501 (if (null arg) (not gnus-show-mime)
11502 (> (prefix-numeric-value arg) 0)))
11503 (gnus-summary-select-article t 'force))
11505 (defun gnus-summary-caesar-message (&optional arg)
11506 "Caesar rotate the current article by 13.
11507 The numerical prefix specifies how manu places to rotate each letter
11510 (gnus-set-global-variables)
11511 (gnus-summary-select-article)
11512 (let ((mail-header-separator ""))
11513 (gnus-eval-in-buffer-window gnus-article-buffer
11516 (let ((start (window-start))
11518 (message-caesar-buffer-body arg)
11519 (set-window-start (get-buffer-window (current-buffer)) start))))))
11521 (defun gnus-summary-stop-page-breaking ()
11522 "Stop page breaking in the current article."
11524 (gnus-set-global-variables)
11525 (gnus-summary-select-article)
11526 (gnus-eval-in-buffer-window gnus-article-buffer
11529 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11530 "Move the current article to a different newsgroup.
11531 If N is a positive number, move the N next articles.
11532 If N is a negative number, move the N previous articles.
11533 If N is nil and any articles have been marked with the process mark,
11534 move those articles instead.
11535 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11536 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11537 re-spool using this method.
11539 For this function to work, both the current newsgroup and the
11540 newsgroup that you want to move to have to support the `request-move'
11541 and `request-accept' functions."
11543 (unless action (setq action 'move))
11544 (gnus-set-global-variables)
11545 ;; Check whether the source group supports the required functions.
11546 (cond ((and (eq action 'move)
11547 (not (gnus-check-backend-function
11548 'request-move-article gnus-newsgroup-name)))
11549 (error "The current group does not support article moving"))
11550 ((and (eq action 'crosspost)
11551 (not (gnus-check-backend-function
11552 'request-replace-article gnus-newsgroup-name)))
11553 (error "The current group does not support article editing")))
11554 (let ((articles (gnus-summary-work-articles n))
11555 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11556 (names '((move "Move" "Moving")
11557 (copy "Copy" "Copying")
11558 (crosspost "Crosspost" "Crossposting")))
11559 (copy-buf (save-excursion
11560 (nnheader-set-temp-buffer " *copy article*")))
11561 art-group to-method new-xref article to-groups)
11562 (unless (assq action names)
11563 (error "Unknown action %s" action))
11564 ;; Read the newsgroup name.
11565 (when (and (not to-newsgroup)
11566 (not select-method))
11568 (gnus-read-move-group-name
11569 (cadr (assq action names))
11570 (symbol-value (intern (format "gnus-current-%s-group" action)))
11572 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11573 (setq to-method (or select-method
11574 (gnus-group-name-to-method to-newsgroup)))
11575 ;; Check the method we are to move this article to...
11576 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11577 (error "%s does not support article copying" (car to-method)))
11578 (or (gnus-check-server to-method)
11579 (error "Can't open server %s" (car to-method)))
11580 (gnus-message 6 "%s to %s: %s..."
11581 (caddr (assq action names))
11582 (or (car select-method) to-newsgroup) articles)
11584 (setq article (pop articles))
11588 ;; Move the article.
11590 (gnus-request-move-article
11591 article ; Article to move
11592 gnus-newsgroup-name ; From newsgrouo
11593 (nth 1 (gnus-find-method-for-group
11594 gnus-newsgroup-name)) ; Server
11595 (list 'gnus-request-accept-article
11596 to-newsgroup (list 'quote select-method)
11597 (not articles)) ; Accept form
11598 (not articles))) ; Only save nov last time
11599 ;; Copy the article.
11602 (set-buffer copy-buf)
11603 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11604 (gnus-request-accept-article
11605 to-newsgroup select-method (not articles))))
11606 ;; Crosspost the article.
11607 ((eq action 'crosspost)
11608 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11609 (setq new-xref (concat gnus-newsgroup-name ":" article))
11610 (if (and xref (not (string= xref "")))
11612 (when (string-match "^Xref: " xref)
11613 (setq xref (substring xref (match-end 0))))
11614 (setq new-xref (concat xref " " new-xref)))
11615 (setq new-xref (concat (system-name) " " new-xref)))
11617 (set-buffer copy-buf)
11618 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11619 (nnheader-replace-header "xref" new-xref)
11620 (gnus-request-accept-article
11621 to-newsgroup select-method (not articles)))))))
11622 (if (not art-group)
11623 (gnus-message 1 "Couldn't %s article %s"
11624 (cadr (assq action names)) article)
11627 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11629 (gnus-group-prefixed-name
11632 (gnus-find-method-for-group to-newsgroup)))
11633 gnus-newsrc-hashtb)))
11634 (info (nth 2 entry))
11635 (to-group (gnus-info-group info)))
11636 ;; Update the group that has been moved to.
11638 (memq action '(move copy)))
11639 (unless (member to-group to-groups)
11640 (push to-group to-groups))
11642 (unless (memq article gnus-newsgroup-unreads)
11643 (gnus-info-set-read
11644 info (gnus-add-to-range (gnus-info-read info)
11645 (list (cdr art-group)))))
11647 ;; Copy any marks over to the new group.
11648 (let ((marks gnus-article-mark-lists)
11649 (to-article (cdr art-group)))
11651 ;; See whether the article is to be put in the cache.
11652 (when gnus-use-cache
11653 (gnus-cache-possibly-enter-article
11654 to-group to-article
11655 (let ((header (copy-sequence
11656 (gnus-summary-article-header article))))
11657 (mail-header-set-number header to-article)
11659 (memq article gnus-newsgroup-marked)
11660 (memq article gnus-newsgroup-dormant)
11661 (memq article gnus-newsgroup-unreads)))
11664 (when (memq article (symbol-value
11665 (intern (format "gnus-newsgroup-%s"
11667 ;; If the other group is the same as this group,
11668 ;; then we have to add the mark to the list.
11669 (when (equal to-group gnus-newsgroup-name)
11670 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11673 (intern (format "gnus-newsgroup-%s"
11675 ;; Copy mark to other group.
11676 (gnus-add-marked-articles
11677 to-group (cdar marks) (list to-article) info))
11678 (setq marks (cdr marks)))))
11680 ;; Update the Xref header in this article to point to
11681 ;; the new crossposted article we have just created.
11682 (when (eq action 'crosspost)
11684 (set-buffer copy-buf)
11685 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11686 (nnheader-replace-header
11687 "xref" (concat new-xref " " (gnus-group-prefixed-name
11688 (car art-group) to-method)
11689 ":" (cdr art-group)))
11690 (gnus-request-replace-article
11691 article gnus-newsgroup-name (current-buffer)))))
11693 (gnus-summary-goto-subject article)
11694 (when (eq action 'move)
11695 (gnus-summary-mark-article article gnus-canceled-mark)))
11696 (gnus-summary-remove-process-mark article))
11697 ;; Re-activate all groups that have been moved to.
11699 (gnus-activate-group (pop to-groups)))
11701 (gnus-kill-buffer copy-buf)
11702 (gnus-summary-position-point)
11703 (gnus-set-mode-line 'summary)))
11705 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11706 "Move the current article to a different newsgroup.
11707 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11708 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11709 re-spool using this method."
11711 (gnus-summary-move-article n nil select-method 'copy))
11713 (defun gnus-summary-crosspost-article (&optional n)
11714 "Crosspost the current article to some other group."
11716 (gnus-summary-move-article n nil nil 'crosspost))
11718 (defvar gnus-summary-respool-default-method nil
11719 "Default method for respooling an article.
11720 If nil, use to the current newsgroup method.")
11722 (defun gnus-summary-respool-article (&optional n method)
11723 "Respool the current article.
11724 The article will be squeezed through the mail spooling process again,
11725 which means that it will be put in some mail newsgroup or other
11726 depending on `nnmail-split-methods'.
11727 If N is a positive number, respool the N next articles.
11728 If N is a negative number, respool the N previous articles.
11729 If N is nil and any articles have been marked with the process mark,
11730 respool those articles instead.
11732 Respooling can be done both from mail groups and \"real\" newsgroups.
11733 In the former case, the articles in question will be moved from the
11734 current group into whatever groups they are destined to. In the
11735 latter case, they will be copied into the relevant groups."
11737 (list current-prefix-arg
11738 (let* ((methods (gnus-methods-using 'respool))
11740 (symbol-name (or gnus-summary-respool-default-method
11741 (car (gnus-find-method-for-group
11742 gnus-newsgroup-name)))))
11744 (gnus-completing-read
11745 methname "What backend do you want to use when respooling?"
11746 methods nil t nil 'gnus-method-history))
11749 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11750 (list (intern method) ""))
11754 (cdr (completing-read
11756 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11757 (gnus-set-global-variables)
11759 (error "No method given for respooling"))
11760 (if (assoc (symbol-name
11761 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11762 (gnus-methods-using 'respool))
11763 (gnus-summary-move-article n nil method)
11764 (gnus-summary-copy-article n nil method)))
11766 (defun gnus-summary-import-article (file)
11767 "Import a random file into a mail newsgroup."
11768 (interactive "fImport file: ")
11769 (gnus-set-global-variables)
11770 (let ((group gnus-newsgroup-name)
11771 (now (current-time))
11773 (or (gnus-check-backend-function 'request-accept-article group)
11774 (error "%s does not support article importing" group))
11775 (or (file-readable-p file)
11776 (not (file-regular-p file))
11777 (error "Can't read %s" file))
11779 (set-buffer (get-buffer-create " *import file*"))
11780 (buffer-disable-undo (current-buffer))
11782 (insert-file-contents file)
11783 (goto-char (point-min))
11784 (unless (nnheader-article-p)
11785 ;; This doesn't look like an article, so we fudge some headers.
11786 (setq atts (file-attributes file)
11787 lines (count-lines (point-min) (point-max)))
11788 (insert "From: " (read-string "From: ") "\n"
11789 "Subject: " (read-string "Subject: ") "\n"
11790 "Date: " (timezone-make-date-arpa-standard
11791 (current-time-string (nth 5 atts))
11792 (current-time-zone now)
11793 (current-time-zone now)) "\n"
11794 "Message-ID: " (message-make-message-id) "\n"
11795 "Lines: " (int-to-string lines) "\n"
11796 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11797 (gnus-request-accept-article group nil t)
11798 (kill-buffer (current-buffer)))))
11800 (defun gnus-summary-expire-articles (&optional now)
11801 "Expire all articles that are marked as expirable in the current group."
11803 (gnus-set-global-variables)
11804 (when (gnus-check-backend-function
11805 'request-expire-articles gnus-newsgroup-name)
11806 ;; This backend supports expiry.
11807 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11808 (expirable (if total
11809 (gnus-list-of-read-articles gnus-newsgroup-name)
11810 (setq gnus-newsgroup-expirable
11811 (sort gnus-newsgroup-expirable '<))))
11812 (expiry-wait (if now 'immediate
11813 (gnus-group-get-parameter
11814 gnus-newsgroup-name 'expiry-wait)))
11817 ;; There are expirable articles in this group, so we run them
11818 ;; through the expiry process.
11819 (gnus-message 6 "Expiring articles...")
11820 ;; The list of articles that weren't expired is returned.
11822 (let ((nnmail-expiry-wait-function nil)
11823 (nnmail-expiry-wait expiry-wait))
11824 (setq es (gnus-request-expire-articles
11825 expirable gnus-newsgroup-name)))
11826 (setq es (gnus-request-expire-articles
11827 expirable gnus-newsgroup-name)))
11828 (or total (setq gnus-newsgroup-expirable es))
11829 ;; We go through the old list of expirable, and mark all
11830 ;; really expired articles as nonexistent.
11831 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11832 (let ((gnus-use-cache nil))
11834 (unless (memq (car expirable) es)
11835 (when (gnus-data-find (car expirable))
11836 (gnus-summary-mark-article
11837 (car expirable) gnus-canceled-mark)))
11838 (setq expirable (cdr expirable)))))
11839 (gnus-message 6 "Expiring articles...done")))))
11841 (defun gnus-summary-expire-articles-now ()
11842 "Expunge all expirable articles in the current group.
11843 This means that *all* articles that are marked as expirable will be
11844 deleted forever, right now."
11846 (gnus-set-global-variables)
11847 (or gnus-expert-user
11849 "Are you really, really, really sure you want to delete all these messages? ")
11851 (gnus-summary-expire-articles t))
11853 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11854 (defun gnus-summary-delete-article (&optional n)
11855 "Delete the N next (mail) articles.
11856 This command actually deletes articles. This is not a marking
11857 command. The article will disappear forever from your life, never to
11859 If N is negative, delete backwards.
11860 If N is nil and articles have been marked with the process mark,
11861 delete these instead."
11863 (gnus-set-global-variables)
11864 (or (gnus-check-backend-function 'request-expire-articles
11865 gnus-newsgroup-name)
11866 (error "The current newsgroup does not support article deletion."))
11867 ;; Compute the list of articles to delete.
11868 (let ((articles (gnus-summary-work-articles n))
11870 (if (and gnus-novice-user
11871 (not (gnus-y-or-n-p
11872 (format "Do you really want to delete %s forever? "
11873 (if (> (length articles) 1)
11874 (format "these %s articles" (length articles))
11875 "this article")))))
11877 ;; Delete the articles.
11878 (setq not-deleted (gnus-request-expire-articles
11879 articles gnus-newsgroup-name 'force))
11881 (gnus-summary-remove-process-mark (car articles))
11882 ;; The backend might not have been able to delete the article
11884 (or (memq (car articles) not-deleted)
11885 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11886 (setq articles (cdr articles))))
11887 (gnus-summary-position-point)
11888 (gnus-set-mode-line 'summary)
11891 (defun gnus-summary-edit-article (&optional force)
11892 "Enter into a buffer and edit the current article.
11893 This will have permanent effect only in mail groups.
11894 If FORCE is non-nil, allow editing of articles even in read-only
11898 (set-buffer gnus-summary-buffer)
11899 (gnus-set-global-variables)
11900 (when (and (not force)
11901 (gnus-group-read-only-p))
11902 (error "The current newsgroup does not support article editing."))
11903 (gnus-summary-select-article t nil t)
11904 (gnus-configure-windows 'article)
11905 (select-window (get-buffer-window gnus-article-buffer))
11906 (gnus-message 6 "C-c C-c to end edits")
11907 (setq buffer-read-only nil)
11909 (use-local-map (copy-keymap (current-local-map)))
11910 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11911 (buffer-enable-undo)
11913 (goto-char (point-min))
11914 (search-forward "\n\n" nil t)))
11916 (defun gnus-summary-edit-article-done ()
11917 "Make edits to the current article permanent."
11919 (if (gnus-group-read-only-p)
11921 (let ((beep (not (eq major-mode 'text-mode))))
11922 (gnus-summary-edit-article-postpone)
11925 3 "The current newsgroup does not support article editing."))))
11926 (let ((buf (format "%s" (buffer-string))))
11929 (if (not (gnus-request-replace-article
11930 (cdr gnus-article-current) (car gnus-article-current)
11932 (error "Couldn't replace article.")
11933 (gnus-article-mode)
11934 (use-local-map gnus-article-mode-map)
11935 (setq buffer-read-only t)
11936 (buffer-disable-undo (current-buffer))
11937 (gnus-configure-windows 'summary)
11938 (gnus-summary-update-article (cdr gnus-article-current))
11939 (when gnus-use-cache
11940 (gnus-cache-update-article
11941 (car gnus-article-current) (cdr gnus-article-current)))
11942 (when gnus-keep-backlog
11943 (gnus-backlog-remove-article
11944 (car gnus-article-current) (cdr gnus-article-current))))
11946 (when (get-buffer gnus-original-article-buffer)
11947 (set-buffer gnus-original-article-buffer)
11948 (setq gnus-original-article nil)))
11949 (setq gnus-article-current nil
11950 gnus-current-article nil)
11951 (run-hooks 'gnus-article-display-hook)
11952 (and (gnus-visual-p 'summary-highlight 'highlight)
11953 (run-hooks 'gnus-visual-mark-article-hook)))))
11955 (defun gnus-summary-edit-article-postpone ()
11956 "Postpone changes to the current article."
11958 (gnus-article-mode)
11959 (use-local-map gnus-article-mode-map)
11960 (setq buffer-read-only t)
11961 (buffer-disable-undo (current-buffer))
11962 (gnus-configure-windows 'summary)
11963 (and (gnus-visual-p 'summary-highlight 'highlight)
11964 (run-hooks 'gnus-visual-mark-article-hook)))
11966 (defun gnus-summary-respool-query ()
11967 "Query where the respool algorithm would put this article."
11969 (gnus-set-global-variables)
11970 (gnus-summary-select-article)
11972 (set-buffer gnus-article-buffer)
11974 (goto-char (point-min))
11975 (search-forward "\n\n")
11976 (narrow-to-region (point-min) (point))
11977 (pp-eval-expression
11978 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11980 ;; Summary marking commands.
11982 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11983 "Mark articles which has the same subject as read, and then select the next.
11984 If UNMARK is positive, remove any kind of mark.
11985 If UNMARK is negative, tick articles."
11987 (gnus-set-global-variables)
11989 (setq unmark (prefix-numeric-value unmark)))
11991 (gnus-summary-mark-same-subject
11992 (gnus-summary-article-subject) unmark)))
11993 ;; Select next unread article. If auto-select-same mode, should
11994 ;; select the first unread article.
11995 (gnus-summary-next-article t (and gnus-auto-select-same
11996 (gnus-summary-article-subject)))
11997 (gnus-message 7 "%d article%s marked as %s"
11998 count (if (= count 1) " is" "s are")
11999 (if unmark "unread" "read"))))
12001 (defun gnus-summary-kill-same-subject (&optional unmark)
12002 "Mark articles which has the same subject as read.
12003 If UNMARK is positive, remove any kind of mark.
12004 If UNMARK is negative, tick articles."
12006 (gnus-set-global-variables)
12008 (setq unmark (prefix-numeric-value unmark)))
12010 (gnus-summary-mark-same-subject
12011 (gnus-summary-article-subject) unmark)))
12012 ;; If marked as read, go to next unread subject.
12014 ;; Go to next unread subject.
12015 (gnus-summary-next-subject 1 t))
12016 (gnus-message 7 "%d articles are marked as %s"
12017 count (if unmark "unread" "read"))))
12019 (defun gnus-summary-mark-same-subject (subject &optional unmark)
12020 "Mark articles with same SUBJECT as read, and return marked number.
12021 If optional argument UNMARK is positive, remove any kinds of marks.
12022 If optional argument UNMARK is negative, mark articles as unread instead."
12026 ((null unmark) ; Mark as read.
12029 (gnus-summary-mark-article-as-read gnus-killed-mark)
12030 (gnus-summary-show-thread) t)
12031 (gnus-summary-find-subject subject))
12032 (setq count (1+ count))))
12033 ((> unmark 0) ; Tick.
12036 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
12037 (gnus-summary-show-thread) t)
12038 (gnus-summary-find-subject subject))
12039 (setq count (1+ count))))
12040 (t ; Mark as unread.
12043 (gnus-summary-mark-article-as-unread gnus-unread-mark)
12044 (gnus-summary-show-thread) t)
12045 (gnus-summary-find-subject subject))
12046 (setq count (1+ count)))))
12047 (gnus-set-mode-line 'summary)
12048 ;; Return the number of marked articles.
12051 (defun gnus-summary-mark-as-processable (n &optional unmark)
12052 "Set the process mark on the next N articles.
12053 If N is negative, mark backward instead. If UNMARK is non-nil, remove
12054 the process mark instead. The difference between N and the actual
12055 number of articles marked is returned."
12057 (gnus-set-global-variables)
12058 (let ((backward (< n 0))
12063 (gnus-summary-remove-process-mark
12064 (gnus-summary-article-number))
12065 (gnus-summary-set-process-mark (gnus-summary-article-number)))
12066 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
12068 (if (/= 0 n) (gnus-message 7 "No more articles"))
12069 (gnus-summary-recenter)
12070 (gnus-summary-position-point)
12073 (defun gnus-summary-unmark-as-processable (n)
12074 "Remove the process mark from the next N articles.
12075 If N is negative, mark backward instead. The difference between N and
12076 the actual number of articles marked is returned."
12078 (gnus-set-global-variables)
12079 (gnus-summary-mark-as-processable n t))
12081 (defun gnus-summary-unmark-all-processable ()
12082 "Remove the process mark from all articles."
12084 (gnus-set-global-variables)
12086 (while gnus-newsgroup-processable
12087 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
12088 (gnus-summary-position-point))
12090 (defun gnus-summary-mark-as-expirable (n)
12091 "Mark N articles forward as expirable.
12092 If N is negative, mark backward instead. The difference between N and
12093 the actual number of articles marked is returned."
12095 (gnus-set-global-variables)
12096 (gnus-summary-mark-forward n gnus-expirable-mark))
12098 (defun gnus-summary-mark-article-as-replied (article)
12099 "Mark ARTICLE replied and update the summary line."
12100 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12101 (let ((buffer-read-only nil))
12102 (when (gnus-summary-goto-subject article)
12103 (gnus-summary-update-secondary-mark article))))
12105 (defun gnus-summary-set-bookmark (article)
12106 "Set a bookmark in current article."
12107 (interactive (list (gnus-summary-article-number)))
12108 (gnus-set-global-variables)
12109 (if (or (not (get-buffer gnus-article-buffer))
12110 (not gnus-current-article)
12111 (not gnus-article-current)
12112 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12113 (error "No current article selected"))
12114 ;; Remove old bookmark, if one exists.
12115 (let ((old (assq article gnus-newsgroup-bookmarks)))
12116 (if old (setq gnus-newsgroup-bookmarks
12117 (delq old gnus-newsgroup-bookmarks))))
12118 ;; Set the new bookmark, which is on the form
12119 ;; (article-number . line-number-in-body).
12120 (setq gnus-newsgroup-bookmarks
12124 (set-buffer gnus-article-buffer)
12128 (goto-char (point-min))
12129 (search-forward "\n\n" nil t)
12132 gnus-newsgroup-bookmarks))
12133 (gnus-message 6 "A bookmark has been added to the current article."))
12135 (defun gnus-summary-remove-bookmark (article)
12136 "Remove the bookmark from the current article."
12137 (interactive (list (gnus-summary-article-number)))
12138 (gnus-set-global-variables)
12139 ;; Remove old bookmark, if one exists.
12140 (let ((old (assq article gnus-newsgroup-bookmarks)))
12143 (setq gnus-newsgroup-bookmarks
12144 (delq old gnus-newsgroup-bookmarks))
12145 (gnus-message 6 "Removed bookmark."))
12146 (gnus-message 6 "No bookmark in current article."))))
12148 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12149 (defun gnus-summary-mark-as-dormant (n)
12150 "Mark N articles forward as dormant.
12151 If N is negative, mark backward instead. The difference between N and
12152 the actual number of articles marked is returned."
12154 (gnus-set-global-variables)
12155 (gnus-summary-mark-forward n gnus-dormant-mark))
12157 (defun gnus-summary-set-process-mark (article)
12158 "Set the process mark on ARTICLE and update the summary line."
12159 (setq gnus-newsgroup-processable
12161 (delq article gnus-newsgroup-processable)))
12162 (when (gnus-summary-goto-subject article)
12163 (gnus-summary-show-thread)
12164 (gnus-summary-update-secondary-mark article)))
12166 (defun gnus-summary-remove-process-mark (article)
12167 "Remove the process mark from ARTICLE and update the summary line."
12168 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12169 (when (gnus-summary-goto-subject article)
12170 (gnus-summary-show-thread)
12171 (gnus-summary-update-secondary-mark article)))
12173 (defun gnus-summary-set-saved-mark (article)
12174 "Set the process mark on ARTICLE and update the summary line."
12175 (push article gnus-newsgroup-saved)
12176 (when (gnus-summary-goto-subject article)
12177 (gnus-summary-update-secondary-mark article)))
12179 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12180 "Mark N articles as read forwards.
12181 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
12182 The difference between N and the actual number of articles marked is
12185 (gnus-set-global-variables)
12186 (let ((backward (< n 0))
12187 (gnus-summary-goto-unread
12188 (and gnus-summary-goto-unread
12189 (not (eq gnus-summary-goto-unread 'never))
12190 (not (memq mark (list gnus-unread-mark
12191 gnus-ticked-mark gnus-dormant-mark)))))
12193 (mark (or mark gnus-del-mark)))
12194 (while (and (> n 0)
12195 (gnus-summary-mark-article nil mark no-expire)
12196 (zerop (gnus-summary-next-subject
12198 (and gnus-summary-goto-unread
12199 (not (eq gnus-summary-goto-unread 'never)))
12202 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12203 (gnus-summary-recenter)
12204 (gnus-summary-position-point)
12205 (gnus-set-mode-line 'summary)
12208 (defun gnus-summary-mark-article-as-read (mark)
12209 "Mark the current article quickly as read with MARK."
12210 (let ((article (gnus-summary-article-number)))
12211 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12212 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12213 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12214 (setq gnus-newsgroup-reads
12215 (cons (cons article mark) gnus-newsgroup-reads))
12216 ;; Possibly remove from cache, if that is used.
12217 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12218 ;; Allow the backend to change the mark.
12219 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12220 ;; Check for auto-expiry.
12221 (when (and gnus-newsgroup-auto-expire
12222 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12223 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12224 (= mark gnus-ancient-mark)
12225 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12226 (setq mark gnus-expirable-mark)
12227 (push article gnus-newsgroup-expirable))
12228 ;; Set the mark in the buffer.
12229 (gnus-summary-update-mark mark 'unread)
12232 (defun gnus-summary-mark-article-as-unread (mark)
12233 "Mark the current article quickly as unread with MARK."
12234 (let ((article (gnus-summary-article-number)))
12236 (gnus-error 1 "Unmarkable article")
12237 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12238 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12239 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12240 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12241 (cond ((= mark gnus-ticked-mark)
12242 (push article gnus-newsgroup-marked))
12243 ((= mark gnus-dormant-mark)
12244 (push article gnus-newsgroup-dormant))
12246 (push article gnus-newsgroup-unreads)))
12247 (setq gnus-newsgroup-reads
12248 (delq (assq article gnus-newsgroup-reads)
12249 gnus-newsgroup-reads))
12251 ;; See whether the article is to be put in the cache.
12252 (and gnus-use-cache
12253 (vectorp (gnus-summary-article-header article))
12255 (gnus-cache-possibly-enter-article
12256 gnus-newsgroup-name article
12257 (gnus-summary-article-header article)
12258 (= mark gnus-ticked-mark)
12259 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12262 (gnus-summary-update-mark mark 'unread))
12265 (defun gnus-summary-mark-article (&optional article mark no-expire)
12266 "Mark ARTICLE with MARK. MARK can be any character.
12267 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12268 `??' (dormant) and `?E' (expirable).
12269 If MARK is nil, then the default character `?D' is used.
12270 If ARTICLE is nil, then the article on the current line will be
12272 ;; The mark might be a string.
12273 (and (stringp mark)
12274 (setq mark (aref mark 0)))
12275 ;; If no mark is given, then we check auto-expiring.
12276 (and (not no-expire)
12277 gnus-newsgroup-auto-expire
12279 (and (numberp mark)
12280 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12281 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12282 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12283 (setq mark gnus-expirable-mark))
12284 (let* ((mark (or mark gnus-del-mark))
12285 (article (or article (gnus-summary-article-number))))
12286 (or article (error "No article on current line"))
12287 (if (or (= mark gnus-unread-mark)
12288 (= mark gnus-ticked-mark)
12289 (= mark gnus-dormant-mark))
12290 (gnus-mark-article-as-unread article mark)
12291 (gnus-mark-article-as-read article mark))
12293 ;; See whether the article is to be put in the cache.
12294 (and gnus-use-cache
12295 (not (= mark gnus-canceled-mark))
12296 (vectorp (gnus-summary-article-header article))
12298 (gnus-cache-possibly-enter-article
12299 gnus-newsgroup-name article
12300 (gnus-summary-article-header article)
12301 (= mark gnus-ticked-mark)
12302 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12304 (if (gnus-summary-goto-subject article nil t)
12305 (let ((buffer-read-only nil))
12306 (gnus-summary-show-thread)
12308 (gnus-summary-update-mark mark 'unread)
12311 (defun gnus-summary-update-secondary-mark (article)
12312 "Update the secondary (read, process, cache) mark."
12313 (gnus-summary-update-mark
12314 (cond ((memq article gnus-newsgroup-processable)
12316 ((memq article gnus-newsgroup-cached)
12318 ((memq article gnus-newsgroup-replied)
12320 ((memq article gnus-newsgroup-saved)
12322 (t gnus-unread-mark))
12324 (when (gnus-visual-p 'summary-highlight 'highlight)
12325 (run-hooks 'gnus-summary-update-hook))
12328 (defun gnus-summary-update-mark (mark type)
12329 (beginning-of-line)
12330 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12331 (buffer-read-only nil))
12333 (<= (+ forward (point)) (point-max)))
12334 ;; Go to the right position on the line.
12335 (goto-char (+ forward (point)))
12336 ;; Replace the old mark with the new mark.
12337 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12338 ;; Optionally update the marks by some user rule.
12339 (when (eq type 'unread)
12340 (gnus-data-set-mark
12341 (gnus-data-find (gnus-summary-article-number)) mark)
12342 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12344 (defun gnus-mark-article-as-read (article &optional mark)
12345 "Enter ARTICLE in the pertinent lists and remove it from others."
12346 ;; Make the article expirable.
12347 (let ((mark (or mark gnus-del-mark)))
12348 (if (= mark gnus-expirable-mark)
12349 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12350 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12351 ;; Remove from unread and marked lists.
12352 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12353 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12354 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12355 (push (cons article mark) gnus-newsgroup-reads)
12356 ;; Possibly remove from cache, if that is used.
12357 (when gnus-use-cache
12358 (gnus-cache-enter-remove-article article))))
12360 (defun gnus-mark-article-as-unread (article &optional mark)
12361 "Enter ARTICLE in the pertinent lists and remove it from others."
12362 (let ((mark (or mark gnus-ticked-mark)))
12363 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12364 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12365 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12366 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12367 (cond ((= mark gnus-ticked-mark)
12368 (push article gnus-newsgroup-marked))
12369 ((= mark gnus-dormant-mark)
12370 (push article gnus-newsgroup-dormant))
12372 (push article gnus-newsgroup-unreads)))
12373 (setq gnus-newsgroup-reads
12374 (delq (assq article gnus-newsgroup-reads)
12375 gnus-newsgroup-reads))))
12377 (defalias 'gnus-summary-mark-as-unread-forward
12378 'gnus-summary-tick-article-forward)
12379 (make-obsolete 'gnus-summary-mark-as-unread-forward
12380 'gnus-summary-tick-article-forward)
12381 (defun gnus-summary-tick-article-forward (n)
12382 "Tick N articles forwards.
12383 If N is negative, tick backwards instead.
12384 The difference between N and the number of articles ticked is returned."
12386 (gnus-summary-mark-forward n gnus-ticked-mark))
12388 (defalias 'gnus-summary-mark-as-unread-backward
12389 'gnus-summary-tick-article-backward)
12390 (make-obsolete 'gnus-summary-mark-as-unread-backward
12391 'gnus-summary-tick-article-backward)
12392 (defun gnus-summary-tick-article-backward (n)
12393 "Tick N articles backwards.
12394 The difference between N and the number of articles ticked is returned."
12396 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12398 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12399 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12400 (defun gnus-summary-tick-article (&optional article clear-mark)
12401 "Mark current article as unread.
12402 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12403 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12405 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12406 gnus-ticked-mark)))
12408 (defun gnus-summary-mark-as-read-forward (n)
12409 "Mark N articles as read forwards.
12410 If N is negative, mark backwards instead.
12411 The difference between N and the actual number of articles marked is
12414 (gnus-summary-mark-forward n gnus-del-mark t))
12416 (defun gnus-summary-mark-as-read-backward (n)
12417 "Mark the N articles as read backwards.
12418 The difference between N and the actual number of articles marked is
12421 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12423 (defun gnus-summary-mark-as-read (&optional article mark)
12424 "Mark current article as read.
12425 ARTICLE specifies the article to be marked as read.
12426 MARK specifies a string to be inserted at the beginning of the line."
12427 (gnus-summary-mark-article article mark))
12429 (defun gnus-summary-clear-mark-forward (n)
12430 "Clear marks from N articles forward.
12431 If N is negative, clear backward instead.
12432 The difference between N and the number of marks cleared is returned."
12434 (gnus-summary-mark-forward n gnus-unread-mark))
12436 (defun gnus-summary-clear-mark-backward (n)
12437 "Clear marks from N articles backward.
12438 The difference between N and the number of marks cleared is returned."
12440 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12442 (defun gnus-summary-mark-unread-as-read ()
12443 "Intended to be used by `gnus-summary-mark-article-hook'."
12444 (when (memq gnus-current-article gnus-newsgroup-unreads)
12445 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12447 (defun gnus-summary-mark-read-and-unread-as-read ()
12448 "Intended to be used by `gnus-summary-mark-article-hook'."
12449 (let ((mark (gnus-summary-article-mark)))
12450 (when (or (gnus-unread-mark-p mark)
12451 (gnus-read-mark-p mark))
12452 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12454 (defun gnus-summary-mark-region-as-read (point mark all)
12455 "Mark all unread articles between point and mark as read.
12456 If given a prefix, mark all articles between point and mark as read,
12457 even ticked and dormant ones."
12458 (interactive "r\nP")
12462 (beginning-of-line)
12467 (memq (setq article (gnus-summary-article-number))
12468 gnus-newsgroup-unreads))
12469 (gnus-summary-mark-article article gnus-del-mark))
12471 (gnus-summary-find-next))))))
12473 (defun gnus-summary-mark-below (score mark)
12474 "Mark articles with score less than SCORE with MARK."
12475 (interactive "P\ncMark: ")
12476 (gnus-set-global-variables)
12477 (setq score (if score
12478 (prefix-numeric-value score)
12479 (or gnus-summary-default-score 0)))
12481 (set-buffer gnus-summary-buffer)
12482 (goto-char (point-min))
12485 (and (< (gnus-summary-article-score) score)
12486 (gnus-summary-mark-article nil mark))
12487 (gnus-summary-find-next)))))
12489 (defun gnus-summary-kill-below (&optional score)
12490 "Mark articles with score below SCORE as read."
12492 (gnus-set-global-variables)
12493 (gnus-summary-mark-below score gnus-killed-mark))
12495 (defun gnus-summary-clear-above (&optional score)
12496 "Clear all marks from articles with score above SCORE."
12498 (gnus-set-global-variables)
12499 (gnus-summary-mark-above score gnus-unread-mark))
12501 (defun gnus-summary-tick-above (&optional score)
12502 "Tick all articles with score above SCORE."
12504 (gnus-set-global-variables)
12505 (gnus-summary-mark-above score gnus-ticked-mark))
12507 (defun gnus-summary-mark-above (score mark)
12508 "Mark articles with score over SCORE with MARK."
12509 (interactive "P\ncMark: ")
12510 (gnus-set-global-variables)
12511 (setq score (if score
12512 (prefix-numeric-value score)
12513 (or gnus-summary-default-score 0)))
12515 (set-buffer gnus-summary-buffer)
12516 (goto-char (point-min))
12518 (if (> (gnus-summary-article-score) score)
12519 (gnus-summary-mark-article nil mark))
12521 (gnus-summary-find-next)))))
12523 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12524 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12525 (defun gnus-summary-limit-include-expunged (&optional no-error)
12526 "Display all the hidden articles that were expunged for low scores."
12528 (gnus-set-global-variables)
12529 (let ((buffer-read-only nil))
12530 (let ((scored gnus-newsgroup-scored)
12533 (or (gnus-summary-goto-subject (caar scored))
12534 (and (setq h (gnus-summary-article-header (caar scored)))
12535 (< (cdar scored) gnus-summary-expunge-below)
12536 (setq headers (cons h headers))))
12537 (setq scored (cdr scored)))
12539 (when (not no-error)
12540 (error "No expunged articles hidden."))
12541 (goto-char (point-min))
12542 (gnus-summary-prepare-unthreaded (nreverse headers))
12543 (goto-char (point-min))
12544 (gnus-summary-position-point)
12547 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12548 "Mark all articles not marked as unread in this newsgroup as read.
12549 If prefix argument ALL is non-nil, all articles are marked as read.
12550 If QUIETLY is non-nil, no questions will be asked.
12551 If TO-HERE is non-nil, it should be a point in the buffer. All
12552 articles before this point will be marked as read.
12553 The number of articles marked as read is returned."
12555 (gnus-set-global-variables)
12558 (not gnus-interactive-catchup) ;Without confirmation?
12562 "Mark absolutely all articles as read? "
12563 "Mark all unread articles as read? ")))
12565 (not gnus-newsgroup-adaptive)
12566 (not gnus-newsgroup-auto-expire))
12569 (setq gnus-newsgroup-marked nil
12570 gnus-newsgroup-dormant nil))
12571 (setq gnus-newsgroup-unreads nil))
12572 ;; We actually mark all articles as canceled, which we
12573 ;; have to do when using auto-expiry or adaptive scoring.
12574 (gnus-summary-show-all-threads)
12575 (if (gnus-summary-first-subject (not all))
12577 (if to-here (< (point) to-here) t)
12578 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12579 (gnus-summary-find-next (not all)))))
12581 (setq gnus-newsgroup-unreads nil))
12582 (gnus-set-mode-line 'summary)))
12583 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12584 (if (and (not to-here) (eq 'nnvirtual (car method)))
12585 (nnvirtual-catchup-group
12586 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12587 (gnus-summary-position-point)))
12589 (defun gnus-summary-catchup-to-here (&optional all)
12590 "Mark all unticked articles before the current one as read.
12591 If ALL is non-nil, also mark ticked and dormant articles as read."
12593 (gnus-set-global-variables)
12595 (gnus-save-hidden-threads
12596 (let ((beg (point)))
12597 ;; We check that there are unread articles.
12598 (when (or all (gnus-summary-find-prev))
12599 (gnus-summary-catchup all t beg)))))
12600 (gnus-summary-position-point))
12602 (defun gnus-summary-catchup-all (&optional quietly)
12603 "Mark all articles in this newsgroup as read."
12605 (gnus-set-global-variables)
12606 (gnus-summary-catchup t quietly))
12608 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12609 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12610 If prefix argument ALL is non-nil, all articles are marked as read."
12612 (gnus-set-global-variables)
12613 (gnus-summary-catchup all quietly nil 'fast)
12614 ;; Select next newsgroup or exit.
12615 (if (eq gnus-auto-select-next 'quietly)
12616 (gnus-summary-next-group nil)
12617 (gnus-summary-exit)))
12619 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12620 "Mark all articles in this newsgroup as read, and then exit."
12622 (gnus-set-global-variables)
12623 (gnus-summary-catchup-and-exit t quietly))
12625 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12626 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12627 "Mark all articles in this group as read and select the next group.
12628 If given a prefix, mark all articles, unread as well as ticked, as
12631 (gnus-set-global-variables)
12633 (gnus-summary-catchup all))
12634 (gnus-summary-next-article t nil nil t))
12636 ;; Thread-based commands.
12638 (defun gnus-summary-articles-in-thread (&optional article)
12639 "Return a list of all articles in the current thread.
12640 If ARTICLE is non-nil, return all articles in the thread that starts
12641 with that article."
12642 (let* ((article (or article (gnus-summary-article-number)))
12643 (data (gnus-data-find-list article))
12644 (top-level (gnus-data-level (car data)))
12646 (cond ((null gnus-thread-operation-ignore-subject)
12647 (gnus-simplify-subject-re
12648 (mail-header-subject (gnus-data-header (car data)))))
12649 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12650 (gnus-simplify-subject-fuzzy
12651 (mail-header-subject (gnus-data-header (car data)))))
12653 (end-point (save-excursion
12654 (if (gnus-summary-go-to-next-thread)
12655 (point) (point-max))))
12658 (< (gnus-data-pos (car data)) end-point))
12659 (when (or (not top-subject)
12660 (string= top-subject
12661 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12662 (gnus-simplify-subject-fuzzy
12663 (mail-header-subject
12664 (gnus-data-header (car data))))
12665 (gnus-simplify-subject-re
12666 (mail-header-subject
12667 (gnus-data-header (car data)))))))
12668 (push (gnus-data-number (car data)) articles))
12669 (unless (and (setq data (cdr data))
12670 (> (gnus-data-level (car data)) top-level))
12672 ;; Return the list of articles.
12673 (nreverse articles)))
12675 (defun gnus-summary-rethread-current ()
12676 "Rethread the thread the current article is part of."
12678 (gnus-set-global-variables)
12679 (let* ((gnus-show-threads t)
12680 (article (gnus-summary-article-number))
12681 (id (mail-header-id (gnus-summary-article-header)))
12682 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12684 (error "No article on the current line"))
12685 (gnus-rebuild-thread id)
12686 (gnus-summary-goto-subject article)))
12688 (defun gnus-summary-reparent-thread ()
12689 "Make current article child of the marked (or previous) article.
12691 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12692 is non-nil or the Subject: of both articles are the same."
12694 (or (not (gnus-group-read-only-p))
12695 (error "The current newsgroup does not support article editing."))
12696 (or (<= (length gnus-newsgroup-processable) 1)
12697 (error "No more than one article may be marked."))
12698 (save-window-excursion
12699 (let ((gnus-article-buffer " *reparent*")
12700 (current-article (gnus-summary-article-number))
12701 ; first grab the marked article, otherwise one line up.
12702 (parent-article (if (not (null gnus-newsgroup-processable))
12703 (car gnus-newsgroup-processable)
12705 (if (eq (forward-line -1) 0)
12706 (gnus-summary-article-number)
12707 (error "Beginning of summary buffer."))))))
12708 (or (not (eq current-article parent-article))
12709 (error "An article may not be self-referential."))
12710 (let ((message-id (mail-header-id
12711 (gnus-summary-article-header parent-article))))
12712 (or (and message-id (not (equal message-id "")))
12713 (error "No message-id in desired parent."))
12714 (gnus-summary-select-article t t nil current-article)
12715 (set-buffer gnus-article-buffer)
12716 (setq buffer-read-only nil)
12717 (let ((buf (format "%s" (buffer-string))))
12720 (goto-char (point-min))
12721 (if (search-forward-regexp "^References: " nil t)
12722 (insert message-id " " )
12723 (insert "References: " message-id "\n"))
12724 (or (gnus-request-replace-article current-article
12725 (car gnus-article-current)
12726 gnus-article-buffer)
12727 (error "Couldn't replace article."))
12728 (set-buffer gnus-summary-buffer)
12729 (gnus-summary-unmark-all-processable)
12730 (gnus-summary-rethread-current)
12731 (gnus-message 3 "Article %d is now the child of article %d."
12732 current-article parent-article)))))
12734 (defun gnus-summary-toggle-threads (&optional arg)
12735 "Toggle showing conversation threads.
12736 If ARG is positive number, turn showing conversation threads on."
12738 (gnus-set-global-variables)
12739 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12740 (setq gnus-show-threads
12741 (if (null arg) (not gnus-show-threads)
12742 (> (prefix-numeric-value arg) 0)))
12743 (gnus-summary-prepare)
12744 (gnus-summary-goto-subject current)
12745 (gnus-summary-position-point)))
12747 (defun gnus-summary-show-all-threads ()
12748 "Show all threads."
12750 (gnus-set-global-variables)
12752 (let ((buffer-read-only nil))
12753 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12754 (gnus-summary-position-point))
12756 (defun gnus-summary-show-thread ()
12757 "Show thread subtrees.
12758 Returns nil if no thread was there to be shown."
12760 (gnus-set-global-variables)
12761 (let ((buffer-read-only nil)
12763 ;; first goto end then to beg, to have point at beg after let
12764 (end (progn (end-of-line) (point)))
12765 (beg (progn (beginning-of-line) (point))))
12767 ;; Any hidden lines here?
12768 (search-forward "\r" end t)
12769 (subst-char-in-region beg end ?\^M ?\n t)
12771 (gnus-summary-position-point))))
12773 (defun gnus-summary-hide-all-threads ()
12774 "Hide all thread subtrees."
12776 (gnus-set-global-variables)
12778 (goto-char (point-min))
12779 (gnus-summary-hide-thread)
12780 (while (zerop (gnus-summary-next-thread 1 t))
12781 (gnus-summary-hide-thread)))
12782 (gnus-summary-position-point))
12784 (defun gnus-summary-hide-thread ()
12785 "Hide thread subtrees.
12786 Returns nil if no threads were there to be hidden."
12788 (gnus-set-global-variables)
12789 (let ((buffer-read-only nil)
12791 (article (gnus-summary-article-number)))
12793 ;; Go forward until either the buffer ends or the subthread
12795 (when (and (not (eobp))
12796 (or (zerop (gnus-summary-next-thread 1 t))
12797 (goto-char (point-max))))
12799 (if (and (> (point) start)
12800 (search-backward "\n" start t))
12802 (subst-char-in-region start (point) ?\n ?\^M)
12803 (gnus-summary-goto-subject article))
12806 ;;(gnus-summary-position-point)
12809 (defun gnus-summary-go-to-next-thread (&optional previous)
12810 "Go to the same level (or less) next thread.
12811 If PREVIOUS is non-nil, go to previous thread instead.
12812 Return the article number moved to, or nil if moving was impossible."
12813 (let ((level (gnus-summary-thread-level))
12814 (way (if previous -1 1))
12817 (while (and (not (eobp))
12818 (< level (gnus-summary-thread-level)))
12819 (forward-line way))
12826 (gnus-summary-article-number)
12827 (goto-char beg)))))
12829 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12830 "Go to the same level (or less) next thread.
12831 If PREVIOUS is non-nil, go to previous thread instead.
12832 Return the article number moved to, or nil if moving was impossible."
12833 (if (and (eq gnus-summary-make-false-root 'dummy)
12834 (gnus-summary-article-intangible-p))
12835 (let ((beg (point)))
12836 (while (and (zerop (forward-line 1))
12837 (not (gnus-summary-article-intangible-p))
12838 (not (zerop (save-excursion
12839 (gnus-summary-thread-level))))))
12845 (let* ((level (gnus-summary-thread-level))
12846 (article (gnus-summary-article-number))
12847 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12850 (if (<= (gnus-data-level (car data)) level)
12851 (setq oart (gnus-data-number (car data))
12853 (setq data (cdr data))))
12855 (gnus-summary-goto-subject oart)))))
12857 (defun gnus-summary-next-thread (n &optional silent)
12858 "Go to the same level next N'th thread.
12859 If N is negative, search backward instead.
12860 Returns the difference between N and the number of skips actually
12863 If SILENT, don't output messages."
12865 (gnus-set-global-variables)
12866 (let ((backward (< n 0))
12869 (while (and (> n 0)
12870 (gnus-summary-go-to-next-thread backward))
12873 (gnus-summary-position-point))
12874 (when (and (not silent) (/= 0 n))
12875 (gnus-message 7 "No more threads"))
12878 (defun gnus-summary-prev-thread (n)
12879 "Go to the same level previous N'th thread.
12880 Returns the difference between N and the number of skips actually
12883 (gnus-set-global-variables)
12884 (gnus-summary-next-thread (- n)))
12886 (defun gnus-summary-go-down-thread ()
12887 "Go down one level in the current thread."
12888 (let ((children (gnus-summary-article-children)))
12890 (gnus-summary-goto-subject (car children)))))
12892 (defun gnus-summary-go-up-thread ()
12893 "Go up one level in the current thread."
12894 (let ((parent (gnus-summary-article-parent)))
12896 (gnus-summary-goto-subject parent))))
12898 (defun gnus-summary-down-thread (n)
12899 "Go down thread N steps.
12900 If N is negative, go up instead.
12901 Returns the difference between N and how many steps down that were
12904 (gnus-set-global-variables)
12907 (while (and (> n 0)
12908 (if up (gnus-summary-go-up-thread)
12909 (gnus-summary-go-down-thread)))
12911 (gnus-summary-position-point)
12912 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12915 (defun gnus-summary-up-thread (n)
12916 "Go up thread N steps.
12917 If N is negative, go up instead.
12918 Returns the difference between N and how many steps down that were
12921 (gnus-set-global-variables)
12922 (gnus-summary-down-thread (- n)))
12924 (defun gnus-summary-top-thread ()
12925 "Go to the top of the thread."
12927 (gnus-set-global-variables)
12928 (while (gnus-summary-go-up-thread))
12929 (gnus-summary-article-number))
12931 (defun gnus-summary-kill-thread (&optional unmark)
12932 "Mark articles under current thread as read.
12933 If the prefix argument is positive, remove any kinds of marks.
12934 If the prefix argument is negative, tick articles instead."
12936 (gnus-set-global-variables)
12938 (setq unmark (prefix-numeric-value unmark)))
12939 (let ((articles (gnus-summary-articles-in-thread)))
12941 ;; Expand the thread.
12942 (gnus-summary-show-thread)
12943 ;; Mark all the articles.
12945 (gnus-summary-goto-subject (car articles))
12946 (cond ((null unmark)
12947 (gnus-summary-mark-article-as-read gnus-killed-mark))
12949 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12951 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12952 (setq articles (cdr articles))))
12953 ;; Hide killed subtrees.
12955 gnus-thread-hide-killed
12956 (gnus-summary-hide-thread))
12957 ;; If marked as read, go to next unread subject.
12959 ;; Go to next unread subject.
12960 (gnus-summary-next-subject 1 t)))
12961 (gnus-set-mode-line 'summary))
12963 ;; Summary sorting commands
12965 (defun gnus-summary-sort-by-number (&optional reverse)
12966 "Sort summary buffer by article number.
12967 Argument REVERSE means reverse order."
12969 (gnus-summary-sort 'number reverse))
12971 (defun gnus-summary-sort-by-author (&optional reverse)
12972 "Sort summary buffer by author name alphabetically.
12973 If case-fold-search is non-nil, case of letters is ignored.
12974 Argument REVERSE means reverse order."
12976 (gnus-summary-sort 'author reverse))
12978 (defun gnus-summary-sort-by-subject (&optional reverse)
12979 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12980 If case-fold-search is non-nil, case of letters is ignored.
12981 Argument REVERSE means reverse order."
12983 (gnus-summary-sort 'subject reverse))
12985 (defun gnus-summary-sort-by-date (&optional reverse)
12986 "Sort summary buffer by date.
12987 Argument REVERSE means reverse order."
12989 (gnus-summary-sort 'date reverse))
12991 (defun gnus-summary-sort-by-score (&optional reverse)
12992 "Sort summary buffer by score.
12993 Argument REVERSE means reverse order."
12995 (gnus-summary-sort 'score reverse))
12997 (defun gnus-summary-sort (predicate reverse)
12998 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12999 (gnus-set-global-variables)
13000 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
13001 (article (intern (format "gnus-article-sort-by-%s" predicate)))
13002 (gnus-thread-sort-functions
13007 (,thread t2 t1)))))
13008 (gnus-article-sort-functions
13013 (,article t2 t1)))))
13015 (gnus-summary-prepare-hook nil))
13016 ;; We do the sorting by regenerating the threads.
13017 (gnus-summary-prepare)
13018 ;; Hide subthreads if needed.
13019 (when (and gnus-show-threads gnus-thread-hide-subtree)
13020 (gnus-summary-hide-all-threads)))
13021 ;; If in async mode, we send some info to the backend.
13022 (when gnus-newsgroup-async
13023 (gnus-request-asynchronous
13024 gnus-newsgroup-name gnus-newsgroup-data)))
13026 (defun gnus-sortable-date (date)
13027 "Make sortable string by string-lessp from DATE.
13028 Timezone package is used."
13031 (setq date (inline (timezone-fix-time
13033 (aref (inline (timezone-parse-date date)) 4))))
13035 (timezone-make-sortable-date
13036 (aref date 0) (aref date 1) (aref date 2)
13038 (timezone-make-time-string
13039 (aref date 3) (aref date 4) (aref date 5))))))
13042 ;; Summary saving commands.
13044 (defun gnus-summary-save-article (&optional n not-saved)
13045 "Save the current article using the default saver function.
13046 If N is a positive number, save the N next articles.
13047 If N is a negative number, save the N previous articles.
13048 If N is nil and any articles have been marked with the process mark,
13049 save those articles instead.
13050 The variable `gnus-default-article-saver' specifies the saver function."
13052 (gnus-set-global-variables)
13053 (let ((articles (gnus-summary-work-articles n))
13054 (save-buffer (save-excursion
13055 (nnheader-set-temp-buffer " *Gnus Save*")))
13056 file header article)
13058 (setq header (gnus-summary-article-header
13059 (setq article (pop articles))))
13060 (if (not (vectorp header))
13061 ;; This is a pseudo-article.
13062 (if (assq 'name header)
13063 (gnus-copy-file (cdr (assq 'name header)))
13064 (gnus-message 1 "Article %d is unsaveable" article))
13065 ;; This is a real article.
13066 (save-window-excursion
13067 (gnus-summary-select-article t nil nil article))
13069 (set-buffer save-buffer)
13071 (insert-buffer-substring gnus-original-article-buffer))
13072 (unless gnus-save-all-headers
13073 ;; Remove headers accoring to `gnus-saved-headers'.
13074 (let ((gnus-visible-headers
13075 (or gnus-saved-headers gnus-visible-headers))
13076 (gnus-article-buffer save-buffer))
13077 (gnus-article-hide-headers 1 t)))
13078 (save-window-excursion
13079 (if (not gnus-default-article-saver)
13080 (error "No default saver is defined.")
13081 ;; !!! Magic! The saving functions all save
13082 ;; `gnus-original-article-buffer' (or so they think),
13083 ;; but we bind that variable to our save-buffer.
13084 (set-buffer gnus-article-buffer)
13085 (let ((gnus-original-article-buffer save-buffer))
13086 (set-buffer gnus-summary-buffer)
13087 (setq file (funcall
13088 gnus-default-article-saver
13090 ((not gnus-prompt-before-saving)
13092 ((eq gnus-prompt-before-saving 'always)
13095 (gnus-summary-remove-process-mark article)
13097 (gnus-summary-set-saved-mark article))))
13098 (gnus-kill-buffer save-buffer)
13099 (gnus-summary-position-point)
13102 (defun gnus-summary-pipe-output (&optional arg)
13103 "Pipe the current article to a subprocess.
13104 If N is a positive number, pipe the N next articles.
13105 If N is a negative number, pipe the N previous articles.
13106 If N is nil and any articles have been marked with the process mark,
13107 pipe those articles instead."
13109 (gnus-set-global-variables)
13110 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13111 (gnus-summary-save-article arg t))
13112 (gnus-configure-windows 'pipe))
13114 (defun gnus-summary-save-article-mail (&optional arg)
13115 "Append the current article to an mail file.
13116 If N is a positive number, save the N next articles.
13117 If N is a negative number, save the N previous articles.
13118 If N is nil and any articles have been marked with the process mark,
13119 save those articles instead."
13121 (gnus-set-global-variables)
13122 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13123 (gnus-summary-save-article arg)))
13125 (defun gnus-summary-save-article-rmail (&optional arg)
13126 "Append the current article to an rmail file.
13127 If N is a positive number, save the N next articles.
13128 If N is a negative number, save the N previous articles.
13129 If N is nil and any articles have been marked with the process mark,
13130 save those articles instead."
13132 (gnus-set-global-variables)
13133 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13134 (gnus-summary-save-article arg)))
13136 (defun gnus-summary-save-article-file (&optional arg)
13137 "Append the current article to a file.
13138 If N is a positive number, save the N next articles.
13139 If N is a negative number, save the N previous articles.
13140 If N is nil and any articles have been marked with the process mark,
13141 save those articles instead."
13143 (gnus-set-global-variables)
13144 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13145 (gnus-summary-save-article arg)))
13147 (defun gnus-summary-save-article-body-file (&optional arg)
13148 "Append the current article body to a file.
13149 If N is a positive number, save the N next articles.
13150 If N is a negative number, save the N previous articles.
13151 If N is nil and any articles have been marked with the process mark,
13152 save those articles instead."
13154 (gnus-set-global-variables)
13155 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13156 (gnus-summary-save-article arg)))
13158 (defun gnus-get-split-value (methods)
13159 "Return a value based on the split METHODS."
13160 (let (split-name method result match)
13163 (set-buffer gnus-original-article-buffer)
13165 (nnheader-narrow-to-headers)
13167 (goto-char (point-min))
13168 (setq method (pop methods))
13169 (setq match (car method))
13172 ;; Regular expression.
13174 (re-search-forward match nil t)
13176 ((gnus-functionp match)
13180 (setq result (funcall match gnus-newsgroup-name))))
13185 (setq result (eval match)))))
13186 (setq split-name (append (cdr method) split-name))
13187 (cond ((stringp result)
13188 (push result split-name))
13190 (setq split-name (append result split-name)))))))))
13193 (defun gnus-read-move-group-name (prompt default articles prefix)
13194 "Read a group name."
13195 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13196 (minibuffer-confirm-incomplete nil) ; XEmacs
13203 (assoc (symbol-name
13204 (car (gnus-find-method-for-group
13206 gnus-valid-select-methods))
13207 (push (list (symbol-name g)) group-map)))
13208 gnus-active-hashtb))
13210 (format "%s %s to:"
13212 (if (> (length articles) 1)
13213 (format "these %d articles" (length articles))
13218 (gnus-completing-read default prom
13219 group-map nil nil prefix
13220 'gnus-group-history))
13221 ((= 1 (length split-name))
13222 (gnus-completing-read (car split-name) prom group-map
13224 'gnus-group-history))
13226 (gnus-completing-read nil prom
13227 (mapcar (lambda (el) (list el))
13228 (nreverse split-name))
13230 'gnus-group-history)))))
13232 (if (or (string= to-newsgroup "")
13233 (string= to-newsgroup prefix))
13234 (setq to-newsgroup (or default "")))
13235 (or (gnus-active to-newsgroup)
13236 (gnus-activate-group to-newsgroup)
13237 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13239 (or (and (gnus-request-create-group
13240 to-newsgroup (gnus-group-name-to-method to-newsgroup))
13241 (gnus-activate-group to-newsgroup nil nil
13242 (gnus-group-name-to-method
13244 (error "Couldn't create group %s" to-newsgroup)))
13245 (error "No such group: %s" to-newsgroup)))
13248 (defun gnus-read-save-file-name (prompt default-name)
13249 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13251 ;; Let the split methods have their say.
13253 ;; No split name was found.
13256 (concat prompt " (default "
13257 (file-name-nondirectory default-name) ") ")
13258 (file-name-directory default-name)
13260 ;; A single split name was found
13261 ((= 1 (length split-name))
13262 (let* ((name (car split-name))
13263 (dir (cond ((file-directory-p name)
13264 (file-name-as-directory name))
13265 ((file-exists-p name) name)
13266 (t gnus-article-save-directory))))
13268 (concat prompt " (default " name ") ")
13270 ;; A list of splits was found.
13272 (setq split-name (nreverse split-name))
13274 (let ((file-name-history (nconc split-name file-name-history)))
13277 (concat prompt " (`M-p' for defaults) ")
13278 gnus-article-save-directory
13279 (car split-name))))
13280 (car (push result file-name-history)))))))
13281 ;; If we have read a directory, we append the default file name.
13282 (when (file-directory-p file)
13283 (setq file (concat (file-name-as-directory file)
13284 (file-name-nondirectory default-name))))
13285 ;; Possibly translate some charaters.
13286 (nnheader-translate-file-chars file)))
13288 (defun gnus-article-archive-name (group)
13289 "Return the first instance of an \"Archive-name\" in the current buffer."
13290 (let ((case-fold-search t))
13291 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13292 (match-string 1))))
13294 (defun gnus-summary-save-in-rmail (&optional filename)
13295 "Append this article to Rmail file.
13296 Optional argument FILENAME specifies file name.
13297 Directory to save to is default to `gnus-article-save-directory'."
13299 (gnus-set-global-variables)
13300 (let ((default-name
13301 (funcall gnus-rmail-save-name gnus-newsgroup-name
13302 gnus-current-headers gnus-newsgroup-last-rmail)))
13304 (cond ((eq filename 'default)
13306 (filename filename)
13307 (t (gnus-read-save-file-name
13308 "Save in rmail file:" default-name))))
13309 (gnus-make-directory (file-name-directory filename))
13310 (gnus-eval-in-buffer-window gnus-original-article-buffer
13314 (gnus-output-to-rmail filename))))
13315 ;; Remember the directory name to save articles
13316 (setq gnus-newsgroup-last-rmail filename)))
13318 (defun gnus-summary-save-in-mail (&optional filename)
13319 "Append this article to Unix mail file.
13320 Optional argument FILENAME specifies file name.
13321 Directory to save to is default to `gnus-article-save-directory'."
13323 (gnus-set-global-variables)
13324 (let ((default-name
13325 (funcall gnus-mail-save-name gnus-newsgroup-name
13326 gnus-current-headers gnus-newsgroup-last-mail)))
13328 (cond ((eq filename 'default)
13330 (filename filename)
13331 (t (gnus-read-save-file-name
13332 "Save in Unix mail file:" default-name))))
13334 (expand-file-name filename
13336 (file-name-directory default-name))))
13337 (gnus-make-directory (file-name-directory filename))
13338 (gnus-eval-in-buffer-window gnus-original-article-buffer
13342 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13343 (gnus-output-to-rmail filename)
13344 (let ((mail-use-rfc822 t))
13345 (rmail-output filename 1 t t))))))
13346 ;; Remember the directory name to save articles.
13347 (setq gnus-newsgroup-last-mail filename)))
13349 (defun gnus-summary-save-in-file (&optional filename)
13350 "Append this article to file.
13351 Optional argument FILENAME specifies file name.
13352 Directory to save to is default to `gnus-article-save-directory'."
13354 (gnus-set-global-variables)
13355 (let ((default-name
13356 (funcall gnus-file-save-name gnus-newsgroup-name
13357 gnus-current-headers gnus-newsgroup-last-file)))
13359 (cond ((eq filename 'default)
13361 (filename filename)
13362 (t (gnus-read-save-file-name
13363 "Save in file:" default-name))))
13364 (gnus-make-directory (file-name-directory filename))
13365 (gnus-eval-in-buffer-window gnus-original-article-buffer
13369 (gnus-output-to-file filename))))
13370 ;; Remember the directory name to save articles.
13371 (setq gnus-newsgroup-last-file filename)))
13373 (defun gnus-summary-save-body-in-file (&optional filename)
13374 "Append this article body to a file.
13375 Optional argument FILENAME specifies file name.
13376 The directory to save in defaults to `gnus-article-save-directory'."
13378 (gnus-set-global-variables)
13379 (let ((default-name
13380 (funcall gnus-file-save-name gnus-newsgroup-name
13381 gnus-current-headers gnus-newsgroup-last-file)))
13383 (cond ((eq filename 'default)
13385 (filename filename)
13386 (t (gnus-read-save-file-name
13387 "Save body in file:" default-name))))
13388 (gnus-make-directory (file-name-directory filename))
13389 (gnus-eval-in-buffer-window gnus-original-article-buffer
13393 (goto-char (point-min))
13394 (and (search-forward "\n\n" nil t)
13395 (narrow-to-region (point) (point-max)))
13396 (gnus-output-to-file filename))))
13397 ;; Remember the directory name to save articles.
13398 (setq gnus-newsgroup-last-file filename)))
13400 (defun gnus-summary-save-in-pipe (&optional command)
13401 "Pipe this article to subprocess."
13403 (gnus-set-global-variables)
13405 (cond ((eq command 'default)
13406 gnus-last-shell-command)
13408 (t (read-string "Shell command on article: "
13409 gnus-last-shell-command))))
13410 (if (string-equal command "")
13411 (setq command gnus-last-shell-command))
13412 (gnus-eval-in-buffer-window gnus-article-buffer
13415 (shell-command-on-region (point-min) (point-max) command nil)))
13416 (setq gnus-last-shell-command command))
13418 ;; Summary extract commands
13420 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13421 (let ((buffer-read-only nil)
13422 (article (gnus-summary-article-number))
13424 (or (gnus-summary-goto-subject article)
13425 (error (format "No such article: %d" article)))
13426 (gnus-summary-position-point)
13427 ;; If all commands are to be bunched up on one line, we collect
13429 (if gnus-view-pseudos-separately
13431 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13434 (setq action (cdr (assq 'action (car ps))))
13435 (setq files (list (cdr (assq 'name (car ps)))))
13436 (while (and ps (cdr ps)
13437 (string= (or action "1")
13438 (or (cdr (assq 'action (cadr ps))) "2")))
13439 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13440 (setcdr ps (cddr ps)))
13443 (if (not (string-match "%s" action))
13444 (setq files (cons " " files)))
13445 (setq files (cons " " files))
13446 (and (assq 'execute (car ps))
13447 (setcdr (assq 'execute (car ps))
13448 (funcall (if (string-match "%s" action)
13451 (mapconcat (lambda (f) f) files " ")))))
13452 (setq ps (cdr ps)))))
13453 (if (and gnus-view-pseudos (not not-view))
13455 (and (assq 'execute (car pslist))
13456 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13457 (eq gnus-view-pseudos 'not-confirm)))
13458 (setq pslist (cdr pslist)))
13461 (setq after-article (or (cdr (assq 'article (car pslist)))
13462 (gnus-summary-article-number)))
13463 (gnus-summary-goto-subject after-article)
13466 (insert " " (file-name-nondirectory
13467 (cdr (assq 'name (car pslist))))
13468 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13470 (forward-line -1) ; back to `b'
13471 (gnus-add-text-properties
13472 b (1- e) (list 'gnus-number gnus-reffed-article-number
13473 gnus-mouse-face-prop gnus-mouse-face))
13475 after-article gnus-reffed-article-number
13476 gnus-unread-mark b (car pslist) 0 (- e b))
13477 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13478 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13479 (setq pslist (cdr pslist)))))))
13481 (defun gnus-pseudos< (p1 p2)
13482 (let ((c1 (cdr (assq 'action p1)))
13483 (c2 (cdr (assq 'action p2))))
13484 (and c1 c2 (string< c1 c2))))
13486 (defun gnus-request-pseudo-article (props)
13487 (cond ((assq 'execute props)
13488 (gnus-execute-command (cdr (assq 'execute props)))))
13489 (let ((gnus-current-article (gnus-summary-article-number)))
13490 (run-hooks 'gnus-mark-article-hook)))
13492 (defun gnus-execute-command (command &optional automatic)
13494 (gnus-article-setup-buffer)
13495 (set-buffer gnus-article-buffer)
13496 (setq buffer-read-only nil)
13497 (let ((command (if automatic command (read-string "Command: " command)))
13498 ;; Just binding this here doesn't help, because there might
13499 ;; be output from the process after exiting the scope of
13501 ;; (buffer-read-only nil)
13504 (insert "$ " command "\n\n")
13505 (if gnus-view-pseudo-asynchronously
13506 (start-process "gnus-execute" nil shell-file-name
13507 shell-command-switch command)
13508 (call-process shell-file-name nil t nil
13509 shell-command-switch command)))))
13511 (defun gnus-copy-file (file &optional to)
13514 (list (read-file-name "Copy file: " default-directory)
13515 (read-file-name "Copy file to: " default-directory)))
13516 (gnus-set-global-variables)
13517 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13518 (and (file-directory-p to)
13519 (setq to (concat (file-name-as-directory to)
13520 (file-name-nondirectory file))))
13521 (copy-file file to))
13523 ;; Summary kill commands.
13525 (defun gnus-summary-edit-global-kill (article)
13526 "Edit the \"global\" kill file."
13527 (interactive (list (gnus-summary-article-number)))
13528 (gnus-set-global-variables)
13529 (gnus-group-edit-global-kill article))
13531 (defun gnus-summary-edit-local-kill ()
13532 "Edit a local kill file applied to the current newsgroup."
13534 (gnus-set-global-variables)
13535 (setq gnus-current-headers (gnus-summary-article-header))
13536 (gnus-set-global-variables)
13537 (gnus-group-edit-local-kill
13538 (gnus-summary-article-number) gnus-newsgroup-name))
13542 ;;; Gnus article mode
13545 (put 'gnus-article-mode 'mode-class 'special)
13547 (if gnus-article-mode-map
13549 (setq gnus-article-mode-map (make-keymap))
13550 (suppress-keymap gnus-article-mode-map)
13552 (gnus-define-keys gnus-article-mode-map
13553 " " gnus-article-goto-next-page
13554 "\177" gnus-article-goto-prev-page
13555 [delete] gnus-article-goto-prev-page
13556 "\C-c^" gnus-article-refer-article
13557 "h" gnus-article-show-summary
13558 "s" gnus-article-show-summary
13559 "\C-c\C-m" gnus-article-mail
13560 "?" gnus-article-describe-briefly
13561 gnus-mouse-2 gnus-article-push-button
13562 "\r" gnus-article-press-button
13563 "\t" gnus-article-next-button
13564 "\M-\t" gnus-article-prev-button
13565 "<" beginning-of-buffer
13567 "\C-c\C-i" gnus-info-find-node
13568 "\C-c\C-b" gnus-bug)
13570 (substitute-key-definition
13571 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13573 (defun gnus-article-mode ()
13574 "Major mode for displaying an article.
13576 All normal editing commands are switched off.
13578 The following commands are available:
13580 \\<gnus-article-mode-map>
13581 \\[gnus-article-next-page]\t Scroll the article one page forwards
13582 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13583 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13584 \\[gnus-article-show-summary]\t Display the summary buffer
13585 \\[gnus-article-mail]\t Send a reply to the address near point
13586 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13587 \\[gnus-info-find-node]\t Go to the Gnus info node"
13589 (when (and menu-bar-mode
13590 (gnus-visual-p 'article-menu 'menu))
13591 (gnus-article-make-menu-bar))
13592 (kill-all-local-variables)
13593 (gnus-simplify-mode-line)
13594 (setq mode-name "Article")
13595 (setq major-mode 'gnus-article-mode)
13596 (make-local-variable 'minor-mode-alist)
13597 (or (assq 'gnus-show-mime minor-mode-alist)
13598 (setq minor-mode-alist
13599 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13600 (use-local-map gnus-article-mode-map)
13601 (make-local-variable 'page-delimiter)
13602 (setq page-delimiter gnus-page-delimiter)
13603 (buffer-disable-undo (current-buffer))
13604 (setq buffer-read-only t) ;Disable modification
13605 (run-hooks 'gnus-article-mode-hook))
13607 (defun gnus-article-setup-buffer ()
13608 "Initialize the article buffer."
13609 (let* ((name (if gnus-single-article-buffer "*Article*"
13610 (concat "*Article " gnus-newsgroup-name "*")))
13612 (progn (string-match "\\*Article" name)
13613 (concat " *Original Article"
13614 (substring name (match-end 0))))))
13615 (setq gnus-article-buffer name)
13616 (setq gnus-original-article-buffer original)
13617 ;; This might be a variable local to the summary buffer.
13618 (unless gnus-single-article-buffer
13620 (set-buffer gnus-summary-buffer)
13621 (setq gnus-article-buffer name)
13622 (setq gnus-original-article-buffer original)
13623 (gnus-set-global-variables))
13624 (make-local-variable 'gnus-summary-buffer))
13625 ;; Init original article buffer.
13627 (set-buffer (get-buffer-create gnus-original-article-buffer))
13628 (buffer-disable-undo (current-buffer))
13629 (setq major-mode 'gnus-original-article-mode)
13630 (gnus-add-current-to-buffer-list)
13631 (make-local-variable 'gnus-original-article))
13632 (if (get-buffer name)
13635 (buffer-disable-undo (current-buffer))
13636 (setq buffer-read-only t)
13637 (gnus-add-current-to-buffer-list)
13638 (or (eq major-mode 'gnus-article-mode)
13639 (gnus-article-mode))
13642 (set-buffer (get-buffer-create name))
13643 (gnus-add-current-to-buffer-list)
13644 (gnus-article-mode)
13645 (current-buffer)))))
13647 ;; Set article window start at LINE, where LINE is the number of lines
13648 ;; from the head of the article.
13649 (defun gnus-article-set-window-start (&optional line)
13651 (get-buffer-window gnus-article-buffer t)
13653 (set-buffer gnus-article-buffer)
13654 (goto-char (point-min))
13657 (gnus-message 6 "Moved to bookmark")
13658 (search-forward "\n\n" nil t)
13659 (forward-line line)
13662 (defun gnus-kill-all-overlays ()
13663 "Delete all overlays in the current buffer."
13664 (when (fboundp 'overlay-lists)
13665 (let* ((overlayss (overlay-lists))
13666 (buffer-read-only nil)
13667 (overlays (nconc (car overlayss) (cdr overlayss))))
13669 (delete-overlay (pop overlays))))))
13671 (defun gnus-request-article-this-buffer (article group)
13672 "Get an article and insert it into this buffer."
13673 (let (do-update-line)
13677 (gnus-kill-all-overlays)
13678 (setq group (or group gnus-newsgroup-name))
13680 ;; Open server if it has closed.
13681 (gnus-check-server (gnus-find-method-for-group group))
13683 ;; Using `gnus-request-article' directly will insert the article into
13684 ;; `nntp-server-buffer' - so we'll save some time by not having to
13685 ;; copy it from the server buffer into the article buffer.
13687 ;; We only request an article by message-id when we do not have the
13688 ;; headers for it, so we'll have to get those.
13689 (when (stringp article)
13690 (let ((gnus-override-method gnus-refer-article-method))
13691 (gnus-read-header article)))
13693 ;; If the article number is negative, that means that this article
13694 ;; doesn't belong in this newsgroup (possibly), so we find its
13695 ;; message-id and request it by id instead of number.
13696 (when (and (numberp article)
13697 gnus-summary-buffer
13698 (get-buffer gnus-summary-buffer)
13699 (buffer-name (get-buffer gnus-summary-buffer)))
13701 (set-buffer gnus-summary-buffer)
13702 (let ((header (gnus-summary-article-header article)))
13705 ((memq article gnus-newsgroup-sparse)
13706 ;; This is a sparse gap article.
13707 (setq do-update-line article)
13708 (setq article (mail-header-id header))
13709 (let ((gnus-override-method gnus-refer-article-method))
13710 (gnus-read-header article))
13711 (setq gnus-newsgroup-sparse
13712 (delq article gnus-newsgroup-sparse)))
13714 ;; It's a real article.
13715 (setq article (mail-header-id header)))
13717 ;; It is an extracted pseudo-article.
13718 (setq article 'pseudo)
13719 (gnus-request-pseudo-article header))))
13721 (let ((method (gnus-find-method-for-group
13722 gnus-newsgroup-name)))
13723 (if (not (eq (car method) 'nneething))
13725 (let ((dir (concat (file-name-as-directory (nth 1 method))
13726 (mail-header-subject header))))
13727 (if (file-directory-p dir)
13729 (setq article 'nneething)
13730 (gnus-group-enter-directory dir)))))))))
13733 ;; Refuse to select canceled articles.
13734 ((and (numberp article)
13735 gnus-summary-buffer
13736 (get-buffer gnus-summary-buffer)
13737 (buffer-name (get-buffer gnus-summary-buffer))
13738 (eq (cdr (save-excursion
13739 (set-buffer gnus-summary-buffer)
13740 (assq article gnus-newsgroup-reads)))
13741 gnus-canceled-mark))
13743 ;; We first check `gnus-original-article-buffer'.
13744 ((and (get-buffer gnus-original-article-buffer)
13747 (set-buffer gnus-original-article-buffer)
13748 (and (equal (car gnus-original-article) group)
13749 (eq (cdr gnus-original-article) article))))
13750 (insert-buffer-substring gnus-original-article-buffer)
13752 ;; Check the backlog.
13753 ((and gnus-keep-backlog
13754 (gnus-backlog-request-article group article (current-buffer)))
13756 ;; Check the cache.
13757 ((and gnus-use-cache
13759 (gnus-cache-request-article article group))
13761 ;; Get the article and put into the article buffer.
13762 ((or (stringp article) (numberp article))
13763 (let ((gnus-override-method
13764 (and (stringp article) gnus-refer-article-method))
13765 (buffer-read-only nil))
13767 (gnus-kill-all-overlays)
13768 (if (gnus-request-article article group (current-buffer))
13770 (and gnus-keep-backlog
13772 (gnus-backlog-enter-article
13773 group article (current-buffer)))
13775 ;; It was a pseudo.
13778 ;; Take the article from the original article buffer
13779 ;; and place it in the buffer it's supposed to be in.
13780 (when (and (get-buffer gnus-article-buffer)
13781 ;;(numberp article)
13782 (equal (buffer-name (current-buffer))
13783 (buffer-name (get-buffer gnus-article-buffer))))
13785 (if (get-buffer gnus-original-article-buffer)
13786 (set-buffer (get-buffer gnus-original-article-buffer))
13787 (set-buffer (get-buffer-create gnus-original-article-buffer))
13788 (buffer-disable-undo (current-buffer))
13789 (setq major-mode 'gnus-original-article-mode)
13790 (setq buffer-read-only t)
13791 (gnus-add-current-to-buffer-list))
13792 (let (buffer-read-only)
13794 (insert-buffer-substring gnus-article-buffer))
13795 (setq gnus-original-article (cons group article))))
13797 ;; Update sparse articles.
13798 (when (and do-update-line
13799 (or (numberp article)
13800 (stringp article)))
13801 (let ((buf (current-buffer)))
13802 (set-buffer gnus-summary-buffer)
13803 (gnus-summary-update-article do-update-line)
13804 (gnus-summary-goto-subject do-update-line nil t)
13805 (set-window-point (get-buffer-window (current-buffer) t)
13807 (set-buffer buf))))))
13809 (defun gnus-read-header (id &optional header)
13810 "Read the headers of article ID and enter them into the Gnus system."
13811 (let ((group gnus-newsgroup-name)
13812 (gnus-override-method
13813 (and (gnus-news-group-p gnus-newsgroup-name)
13814 gnus-refer-article-method))
13816 ;; First we check to see whether the header in question is already
13819 ;; This is a Message-ID.
13820 (setq header (or header (gnus-id-to-header id)))
13821 ;; This is an article number.
13822 (setq header (or header (gnus-summary-article-header id))))
13824 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13825 ;; We have found the header.
13827 ;; We have to really fetch the header to this article.
13828 (when (setq where (gnus-request-head id group))
13830 (set-buffer nntp-server-buffer)
13831 (goto-char (point-max))
13833 (goto-char (point-min))
13837 ((cdr where) (cdr where))
13838 (header (mail-header-number header))
13839 (t gnus-reffed-article-number))
13841 (insert " Article retrieved.\n"))
13843 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13844 ; (setcar (gnus-id-to-thread id) nil))
13845 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13846 () ; Malformed head.
13847 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13848 (if (and (stringp id)
13849 (not (string= (gnus-group-real-name group)
13851 ;; If we fetched by Message-ID and the article came
13852 ;; from a different group, we fudge some bogus article
13853 ;; numbers for this article.
13854 (mail-header-set-number header gnus-reffed-article-number))
13855 (decf gnus-reffed-article-number)
13856 (gnus-remove-header (mail-header-number header))
13857 (push header gnus-newsgroup-headers)
13858 (setq gnus-current-headers header)
13859 (push (mail-header-number header) gnus-newsgroup-limit))
13862 (defun gnus-remove-header (number)
13863 "Remove header NUMBER from `gnus-newsgroup-headers'."
13864 (if (and gnus-newsgroup-headers
13865 (= number (mail-header-number (car gnus-newsgroup-headers))))
13866 (pop gnus-newsgroup-headers)
13867 (let ((headers gnus-newsgroup-headers))
13868 (while (and (cdr headers)
13869 (not (= number (mail-header-number (cadr headers)))))
13871 (when (cdr headers)
13872 (setcdr headers (cddr headers))))))
13874 (defun gnus-article-prepare (article &optional all-headers header)
13875 "Prepare ARTICLE in article mode buffer.
13876 ARTICLE should either be an article number or a Message-ID.
13877 If ARTICLE is an id, HEADER should be the article headers.
13878 If ALL-HEADERS is non-nil, no headers are hidden."
13880 ;; Make sure we start in a summary buffer.
13881 (unless (eq major-mode 'gnus-summary-mode)
13882 (set-buffer gnus-summary-buffer))
13883 (setq gnus-summary-buffer (current-buffer))
13884 ;; Make sure the connection to the server is alive.
13885 (unless (gnus-server-opened
13886 (gnus-find-method-for-group gnus-newsgroup-name))
13887 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13888 (gnus-request-group gnus-newsgroup-name t))
13889 (let* ((article (if header (mail-header-number header) article))
13890 (summary-buffer (current-buffer))
13891 (internal-hook gnus-article-internal-prepare-hook)
13892 (group gnus-newsgroup-name)
13895 (gnus-article-setup-buffer)
13896 (set-buffer gnus-article-buffer)
13897 ;; Deactivate active regions.
13898 (when (and (boundp 'transient-mark-mode)
13899 transient-mark-mode)
13900 (setq mark-active nil))
13901 (if (not (setq result (let ((buffer-read-only nil))
13902 (gnus-request-article-this-buffer
13904 ;; There is no such article.
13906 (when (and (numberp article)
13907 (not (memq article gnus-newsgroup-sparse)))
13908 (setq gnus-article-current
13909 (cons gnus-newsgroup-name article))
13910 (set-buffer gnus-summary-buffer)
13911 (setq gnus-current-article article)
13912 (gnus-summary-mark-article article gnus-canceled-mark))
13913 (unless (memq article gnus-newsgroup-sparse)
13915 1 "No such article (may have expired or been canceled)")))
13916 (if (or (eq result 'pseudo) (eq result 'nneething))
13919 (set-buffer summary-buffer)
13920 (setq gnus-last-article gnus-current-article
13921 gnus-newsgroup-history (cons gnus-current-article
13922 gnus-newsgroup-history)
13923 gnus-current-article 0
13924 gnus-current-headers nil
13925 gnus-article-current nil)
13926 (if (eq result 'nneething)
13927 (gnus-configure-windows 'summary)
13928 (gnus-configure-windows 'article))
13929 (gnus-set-global-variables))
13930 (gnus-set-mode-line 'article))
13931 ;; The result from the `request' was an actual article -
13932 ;; or at least some text that is now displayed in the
13934 (if (and (numberp article)
13935 (not (eq article gnus-current-article)))
13936 ;; Seems like a new article has been selected.
13937 ;; `gnus-current-article' must be an article number.
13939 (set-buffer summary-buffer)
13940 (setq gnus-last-article gnus-current-article
13941 gnus-newsgroup-history (cons gnus-current-article
13942 gnus-newsgroup-history)
13943 gnus-current-article article
13944 gnus-current-headers
13945 (gnus-summary-article-header gnus-current-article)
13946 gnus-article-current
13947 (cons gnus-newsgroup-name gnus-current-article))
13948 (unless (vectorp gnus-current-headers)
13949 (setq gnus-current-headers nil))
13950 (gnus-summary-show-thread)
13951 (run-hooks 'gnus-mark-article-hook)
13952 (gnus-set-mode-line 'summary)
13953 (and (gnus-visual-p 'article-highlight 'highlight)
13954 (run-hooks 'gnus-visual-mark-article-hook))
13955 ;; Set the global newsgroup variables here.
13956 ;; Suggested by Jim Sisolak
13957 ;; <sisolak@trans4.neep.wisc.edu>.
13958 (gnus-set-global-variables)
13959 (setq gnus-have-all-headers
13960 (or all-headers gnus-show-all-headers))
13961 (and gnus-use-cache
13962 (vectorp (gnus-summary-article-header article))
13963 (gnus-cache-possibly-enter-article
13965 (gnus-summary-article-header article)
13966 (memq article gnus-newsgroup-marked)
13967 (memq article gnus-newsgroup-dormant)
13968 (memq article gnus-newsgroup-unreads)))))
13969 (when (or (numberp article)
13971 ;; Hooks for getting information from the article.
13972 ;; This hook must be called before being narrowed.
13973 (let (buffer-read-only)
13974 (run-hooks 'internal-hook)
13975 (run-hooks 'gnus-article-prepare-hook)
13976 ;; Decode MIME message.
13978 (if (or (not gnus-strict-mime)
13979 (gnus-fetch-field "Mime-Version"))
13980 (funcall gnus-show-mime-method)
13981 (funcall gnus-decode-encoded-word-method)))
13982 ;; Perform the article display hooks.
13983 (run-hooks 'gnus-article-display-hook))
13985 (goto-char (point-min))
13986 (and gnus-break-pages (gnus-narrow-to-page)))
13987 (gnus-set-mode-line 'article)
13988 (gnus-configure-windows 'article)
13989 (goto-char (point-min))
13992 (defun gnus-article-show-all-headers ()
13993 "Show all article headers in article mode buffer."
13995 (gnus-article-setup-buffer)
13996 (set-buffer gnus-article-buffer)
13997 (let ((buffer-read-only nil))
13998 (gnus-unhide-text (point-min) (point-max)))))
14000 (defun gnus-article-hide-headers-if-wanted ()
14001 "Hide unwanted headers if `gnus-have-all-headers' is nil.
14002 Provided for backwards compatibility."
14003 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
14004 gnus-inhibit-hiding
14005 (gnus-article-hide-headers)))
14007 (defsubst gnus-article-header-rank ()
14008 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
14009 (let ((list gnus-sorted-header-list)
14012 (when (looking-at (car list))
14014 (setq list (cdr list))
14018 (defun gnus-article-hide-headers (&optional arg delete)
14019 "Toggle whether to hide unwanted headers and possibly sort them as well.
14020 If given a negative prefix, always show; if given a positive prefix,
14022 (interactive (gnus-hidden-arg))
14023 (if (gnus-article-check-hidden-text 'headers arg)
14024 ;; Show boring headers as well.
14025 (gnus-article-show-hidden-text 'boring-headers)
14026 ;; This function might be inhibited.
14027 (unless gnus-inhibit-hiding
14029 (set-buffer gnus-article-buffer)
14031 (let ((buffer-read-only nil)
14032 (props (nconc (list 'gnus-type 'headers)
14033 gnus-hidden-properties))
14034 (max (1+ (length gnus-sorted-header-list)))
14035 (ignored (when (not (stringp gnus-visible-headers))
14036 (cond ((stringp gnus-ignored-headers)
14037 gnus-ignored-headers)
14038 ((listp gnus-ignored-headers)
14039 (mapconcat 'identity gnus-ignored-headers
14042 (cond ((stringp gnus-visible-headers)
14043 gnus-visible-headers)
14044 ((and gnus-visible-headers
14045 (listp gnus-visible-headers))
14046 (mapconcat 'identity gnus-visible-headers "\\|"))))
14047 (inhibit-point-motion-hooks t)
14049 ;; First we narrow to just the headers.
14051 (goto-char (point-min))
14052 ;; Hide any "From " lines at the beginning of (mail) articles.
14053 (while (looking-at "From ")
14057 (delete-region (point-min) (point))
14058 (gnus-hide-text (point-min) (point) props)))
14059 ;; Then treat the rest of the header lines.
14062 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
14063 ;; Then we use the two regular expressions
14064 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
14065 ;; select which header lines is to remain visible in the
14067 (goto-char (point-min))
14068 (while (re-search-forward "^[^ \t]*:" nil t)
14069 (beginning-of-line)
14070 ;; We add the headers we want to keep to a list and delete
14071 ;; them from the buffer.
14072 (gnus-put-text-property
14073 (point) (1+ (point)) 'message-rank
14074 (if (or (and visible (looking-at visible))
14076 (not (looking-at ignored))))
14077 (gnus-article-header-rank)
14080 (message-sort-headers-1)
14081 (when (setq beg (text-property-any
14082 (point-min) (point-max) 'message-rank (+ 2 max)))
14083 ;; We make the unwanted headers invisible.
14085 (delete-region beg (point-max))
14086 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
14087 (gnus-hide-text-type beg (point-max) 'headers))
14088 ;; Work around XEmacs lossage.
14089 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
14091 (defun gnus-article-hide-boring-headers (&optional arg)
14092 "Toggle hiding of headers that aren't very interesting.
14093 If given a negative prefix, always show; if given a positive prefix,
14095 (interactive (gnus-hidden-arg))
14096 (unless (gnus-article-check-hidden-text 'boring-headers arg)
14098 (set-buffer gnus-article-buffer)
14100 (let ((buffer-read-only nil)
14101 (list gnus-boring-article-headers)
14102 (inhibit-point-motion-hooks t)
14104 (nnheader-narrow-to-headers)
14106 (setq elem (pop list))
14107 (goto-char (point-min))
14109 ;; Hide empty headers.
14111 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14113 (gnus-hide-text-type
14114 (progn (beginning-of-line) (point))
14117 (if (re-search-forward "^[^ \t]" nil t)
14118 (match-beginning 0)
14121 ;; Hide boring Newsgroups header.
14122 ((eq elem 'newsgroups)
14123 (when (equal (message-fetch-field "newsgroups")
14124 (gnus-group-real-name gnus-newsgroup-name))
14125 (gnus-article-hide-header "newsgroups")))
14126 ((eq elem 'followup-to)
14127 (when (equal (message-fetch-field "followup-to")
14128 (message-fetch-field "newsgroups"))
14129 (gnus-article-hide-header "followup-to")))
14130 ((eq elem 'reply-to)
14131 (let ((from (message-fetch-field "from"))
14132 (reply-to (message-fetch-field "reply-to")))
14136 (nth 1 (funcall gnus-extract-address-components from))
14137 (nth 1 (funcall gnus-extract-address-components
14139 (gnus-article-hide-header "reply-to"))))
14141 (let ((date (message-fetch-field "date")))
14143 (< (gnus-days-between date (current-time-string))
14145 (gnus-article-hide-header "date")))))))))))
14147 (defun gnus-article-hide-header (header)
14149 (goto-char (point-min))
14150 (when (re-search-forward (concat "^" header ":") nil t)
14151 (gnus-hide-text-type
14152 (progn (beginning-of-line) (point))
14155 (if (re-search-forward "^[^ \t]" nil t)
14156 (match-beginning 0)
14158 'boring-headers))))
14160 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14161 (defun gnus-article-treat-overstrike ()
14162 "Translate overstrikes into bold text."
14165 (set-buffer gnus-article-buffer)
14166 (let ((buffer-read-only nil))
14167 (while (search-forward "\b" nil t)
14168 (let ((next (following-char))
14169 (previous (char-after (- (point) 2))))
14171 ((eq next previous)
14172 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14173 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14175 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14176 (gnus-put-text-property
14177 (- (point) 2) (1- (point)) 'face 'underline))
14179 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14180 (gnus-put-text-property
14181 (point) (1+ (point)) 'face 'underline))))))))
14183 (defun gnus-article-word-wrap ()
14184 "Format too long lines."
14187 (set-buffer gnus-article-buffer)
14188 (let ((buffer-read-only nil))
14190 (goto-char (point-min))
14191 (search-forward "\n\n" nil t)
14193 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14194 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14195 (adaptive-fill-mode t))
14196 (while (not (eobp))
14197 (and (>= (current-column) (min fill-column (window-width)))
14198 (/= (preceding-char) ?:)
14199 (fill-paragraph nil))
14200 (end-of-line 2))))))
14202 (defun gnus-article-remove-cr ()
14203 "Remove carriage returns from an article."
14206 (set-buffer gnus-article-buffer)
14207 (let ((buffer-read-only nil))
14208 (goto-char (point-min))
14209 (while (search-forward "\r" nil t)
14210 (replace-match "" t t)))))
14212 (defun gnus-article-remove-trailing-blank-lines ()
14213 "Remove all trailing blank lines from the article."
14216 (set-buffer gnus-article-buffer)
14217 (let ((buffer-read-only nil))
14218 (goto-char (point-max))
14222 (while (looking-at "^[ \t]*$")
14227 (defun gnus-article-display-x-face (&optional force)
14228 "Look for an X-Face header and display it if present."
14229 (interactive (list 'force))
14231 (set-buffer gnus-article-buffer)
14232 ;; Delete the old process, if any.
14233 (when (process-status "gnus-x-face")
14234 (delete-process "gnus-x-face"))
14235 (let ((inhibit-point-motion-hooks t)
14236 (case-fold-search nil)
14239 (nnheader-narrow-to-headers)
14240 (setq from (message-fetch-field "from"))
14241 (goto-char (point-min))
14242 (when (and gnus-article-x-face-command
14244 ;; Check whether this face is censored.
14245 (not gnus-article-x-face-too-ugly)
14246 (and gnus-article-x-face-too-ugly from
14247 (not (string-match gnus-article-x-face-too-ugly
14249 ;; Has to be present.
14250 (re-search-forward "^X-Face: " nil t))
14251 ;; We now have the area of the buffer where the X-Face is stored.
14252 (let ((beg (point))
14253 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14254 ;; We display the face.
14255 (if (symbolp gnus-article-x-face-command)
14256 ;; The command is a lisp function, so we call it.
14257 (if (gnus-functionp gnus-article-x-face-command)
14258 (funcall gnus-article-x-face-command beg end)
14259 (error "%s is not a function" gnus-article-x-face-command))
14260 ;; The command is a string, so we interpret the command
14261 ;; as a, well, command, and fork it off.
14262 (let ((process-connection-type nil))
14263 (process-kill-without-query
14265 "gnus-x-face" nil shell-file-name shell-command-switch
14266 gnus-article-x-face-command))
14267 (process-send-region "gnus-x-face" beg end)
14268 (process-send-eof "gnus-x-face")))))))))
14270 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14271 (defun gnus-decode-rfc1522 ()
14272 "Hack to remove QP encoding from headers."
14273 (let ((case-fold-search t)
14274 (inhibit-point-motion-hooks t)
14275 (buffer-read-only nil)
14279 (goto-char (point-min))
14280 (or (search-forward "\n\n" nil t) (point-max)))
14282 (while (re-search-forward
14283 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14284 (setq string (match-string 1))
14285 (narrow-to-region (match-beginning 0) (match-end 0))
14286 (delete-region (point-min) (point-max))
14288 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14289 (subst-char-in-region (point-min) (point-max) ?_ ? )
14291 (goto-char (point-min))))))
14293 (defun gnus-article-de-quoted-unreadable (&optional force)
14294 "Do a naive translation of a quoted-printable-encoded article.
14295 This is in no way, shape or form meant as a replacement for real MIME
14296 processing, but is simply a stop-gap measure until MIME support is
14298 If FORCE, decode the article whether it is marked as quoted-printable
14300 (interactive (list 'force))
14302 (set-buffer gnus-article-buffer)
14303 (let ((case-fold-search t)
14304 (buffer-read-only nil)
14305 (type (gnus-fetch-field "content-transfer-encoding")))
14306 (gnus-decode-rfc1522)
14308 (and type (string-match "quoted-printable" (downcase type))))
14309 (goto-char (point-min))
14310 (search-forward "\n\n" nil 'move)
14311 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14313 (defun gnus-mime-decode-quoted-printable (from to)
14314 "Decode Quoted-Printable in the region between FROM and TO."
14317 (while (search-forward "=" to t)
14318 (cond ((eq (following-char) ?\n)
14321 ((looking-at "[0-9A-F][0-9A-F]")
14322 (subst-char-in-region
14323 (1- (point)) (point) ?=
14324 (hexl-hex-string-to-integer
14325 (buffer-substring (point) (+ 2 (point)))))
14329 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14331 (defun gnus-article-hide-pgp (&optional arg)
14332 "Toggle hiding of any PGP headers and signatures in the current article.
14333 If given a negative prefix, always show; if given a positive prefix,
14335 (interactive (gnus-hidden-arg))
14336 (unless (gnus-article-check-hidden-text 'pgp arg)
14338 (set-buffer gnus-article-buffer)
14339 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14340 buffer-read-only beg end)
14342 (goto-char (point-min))
14343 ;; Hide the "header".
14344 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14345 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14347 ;; Hide the actual signature.
14348 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14349 (setq end (1+ (match-beginning 0)))
14352 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14354 ;; Perhaps we shouldn't hide to the end of the buffer
14355 ;; if there is no end to the signature?
14358 ;; Hide "- " PGP quotation markers.
14359 (when (and beg end)
14360 (narrow-to-region beg end)
14361 (goto-char (point-min))
14362 (while (re-search-forward "^- " nil t)
14363 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14366 (defun gnus-article-hide-pem (&optional arg)
14367 "Toggle hiding of any PEM headers and signatures in the current article.
14368 If given a negative prefix, always show; if given a positive prefix,
14370 (interactive (gnus-hidden-arg))
14371 (unless (gnus-article-check-hidden-text 'pem arg)
14373 (set-buffer gnus-article-buffer)
14374 (let ((props (nconc (list 'gnus-type 'pem) gnus-hidden-properties))
14375 buffer-read-only end)
14377 (goto-char (point-min))
14378 ;; hide the horrendously ugly "header".
14379 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
14382 (setq end (1+ (match-beginning 0)))
14385 (if (search-forward "\n\n" nil t)
14389 ;; hide the trailer as well
14390 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
14393 (gnus-hide-text (match-beginning 0) (match-end 0) props))))))
14395 (defun gnus-article-hide-signature (&optional arg)
14396 "Hide the signature in the current article.
14397 If given a negative prefix, always show; if given a positive prefix,
14399 (interactive (gnus-hidden-arg))
14400 (unless (gnus-article-check-hidden-text 'signature arg)
14402 (set-buffer gnus-article-buffer)
14404 (let ((buffer-read-only nil))
14405 (when (gnus-narrow-to-signature)
14406 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14408 (defun gnus-article-strip-leading-blank-lines ()
14409 "Remove all blank lines from the beginning of the article."
14412 (set-buffer gnus-article-buffer)
14413 (let (buffer-read-only)
14414 (goto-char (point-min))
14415 (when (search-forward "\n\n" nil t)
14416 (while (looking-at "[ \t]$")
14417 (gnus-delete-line))))))
14419 (defvar mime::preview/content-list)
14420 (defvar mime::preview-content-info/point-min)
14421 (defun gnus-narrow-to-signature ()
14422 "Narrow to the signature."
14424 (if (and (boundp 'mime::preview/content-list)
14425 mime::preview/content-list)
14426 (let ((pcinfo (car (last mime::preview/content-list))))
14429 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14432 (goto-char (point-max))
14433 (when (re-search-backward gnus-signature-separator nil t)
14435 (when (or (null gnus-signature-limit)
14436 (and (numberp gnus-signature-limit)
14437 (< (- (point-max) (point)) gnus-signature-limit))
14438 (and (gnus-functionp gnus-signature-limit)
14439 (funcall gnus-signature-limit))
14440 (and (stringp gnus-signature-limit)
14441 (not (re-search-forward gnus-signature-limit nil t))))
14442 (narrow-to-region (point) (point-max))
14445 (defun gnus-hidden-arg ()
14446 "Return the current prefix arg as a number, or 0 if no prefix."
14447 (list (if current-prefix-arg
14448 (prefix-numeric-value current-prefix-arg)
14451 (defun gnus-article-check-hidden-text (type arg)
14452 "Return nil if hiding is necessary.
14453 Arg can be nil or a number. Nil and positive means hide, negative
14454 means show, 0 means toggle."
14456 (set-buffer gnus-article-buffer)
14457 (let ((hide (gnus-article-hidden-text-p type)))
14463 (gnus-article-show-hidden-text type))
14465 (if (eq hide 'hidden)
14466 (gnus-article-show-hidden-text type)
14469 (defun gnus-article-hidden-text-p (type)
14470 "Say whether the current buffer contains hidden text of type TYPE."
14471 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14473 (if (get-text-property pos 'invisible)
14477 (defun gnus-article-hide (&optional arg force)
14478 "Hide all the gruft in the current article.
14479 This means that PGP stuff, signatures, cited text and (some)
14480 headers will be hidden.
14481 If given a prefix, show the hidden text instead."
14482 (interactive (list current-prefix-arg 'force))
14483 (gnus-article-hide-headers arg)
14484 (gnus-article-hide-pgp arg)
14485 (gnus-article-hide-citation-maybe arg force)
14486 (gnus-article-hide-signature arg))
14488 (defun gnus-article-show-hidden-text (type &optional hide)
14489 "Show all hidden text of type TYPE.
14490 If HIDE, hide the text instead."
14492 (set-buffer gnus-article-buffer)
14493 (let ((buffer-read-only nil)
14494 (inhibit-point-motion-hooks t)
14496 (while (gnus-goto-char (text-property-any
14497 beg (point-max) 'gnus-type type))
14501 (gnus-hide-text beg (point) gnus-hidden-properties)
14502 (gnus-unhide-text beg (point)))
14503 (setq beg (point)))
14506 (defvar gnus-article-time-units
14507 `((year . ,(* 365.25 24 60 60))
14508 (week . ,(* 7 24 60 60))
14509 (day . ,(* 24 60 60))
14510 (hour . ,(* 60 60))
14513 "Mapping from time units to seconds.")
14515 (defun gnus-article-date-ut (&optional type highlight)
14516 "Convert DATE date to universal time in the current article.
14517 If TYPE is `local', convert to local time; if it is `lapsed', output
14518 how much time has lapsed since DATE."
14519 (interactive (list 'ut t))
14520 (let* ((header (or gnus-current-headers
14521 (gnus-summary-article-header) ""))
14522 (date (and (vectorp header) (mail-header-date header)))
14523 (date-regexp "^Date: \\|^X-Sent: ")
14524 (now (current-time))
14525 (inhibit-point-motion-hooks t)
14527 (when (and date (not (string= date "")))
14529 (set-buffer gnus-article-buffer)
14531 (nnheader-narrow-to-headers)
14532 (let ((buffer-read-only nil))
14533 ;; Delete any old Date headers.
14534 (if (re-search-forward date-regexp nil t)
14536 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14537 eface (get-text-property (1- (gnus-point-at-eol))
14539 (message-remove-header date-regexp t)
14540 (beginning-of-line))
14541 (goto-char (point-max)))
14542 (insert (gnus-make-date-line date type))
14543 ;; Do highlighting.
14545 (when (and (gnus-visual-p 'article-highlight 'highlight)
14546 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14547 (gnus-put-text-property (match-beginning 1) (match-end 1)
14549 (gnus-put-text-property (match-beginning 2) (match-end 2)
14550 'face eface))))))))
14552 (defun gnus-make-date-line (date type)
14553 "Return a DATE line of TYPE."
14555 ;; Convert to the local timezone. We have to slap a
14556 ;; `condition-case' round the calls to the timezone
14557 ;; functions since they aren't particularly resistant to
14560 (concat "Date: " (condition-case ()
14561 (timezone-make-date-arpa-standard date)
14564 ;; Convert to Universal Time.
14568 (timezone-make-date-arpa-standard date nil "UT")
14571 ;; Get the original date from the article.
14572 ((eq type 'original)
14573 (concat "Date: " date "\n"))
14574 ;; Do an X-Sent lapsed format.
14576 ;; If the date is seriously mangled, the timezone
14577 ;; functions are liable to bug out, so we condition-case
14578 ;; the entire thing.
14579 (let* ((now (current-time))
14584 (timezone-make-date-arpa-standard
14585 (current-time-string now)
14586 (current-time-zone now) "UT"))
14588 (timezone-make-date-arpa-standard
14591 (real-sec (+ (* (float (car real-time)) 65536)
14593 (sec (abs real-sec))
14596 ((equal real-time '(0 0))
14597 "X-Sent: Unknown\n")
14603 ;; This is a bit convoluted, but basically we go
14604 ;; through the time units for years, weeks, etc,
14605 ;; and divide things to see whether that results
14606 ;; in positive answers.
14609 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14610 ;; The (remaining) seconds are too few to
14611 ;; be divided into this time unit.
14613 ;; It's big enough, so we output it.
14614 (setq sec (- sec (* num (cdr unit))))
14616 (concat (if prev ", " "") (int-to-string
14618 " " (symbol-name (car unit))
14619 (if (> num 1) "s" ""))
14621 gnus-article-time-units "")