1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
34 (defvar tool-bar-mode)
35 (defvar gnus-tmp-header)
48 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
49 (autoload 'gnus-cache-write-active "gnus-cache")
50 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
51 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
52 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
53 (autoload 'mm-uu-dissect "mm-uu")
54 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
55 "Deuglify broken Outlook (Express) articles and redisplay."
57 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
58 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
59 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-summary-next-group-on-exit t
69 "If non-nil, go to the next unread newsgroup on summary exit.
70 See `gnus-group-goto-unread'."
71 :link '(custom-manual "(gnus)Group Maneuvering")
72 :group 'gnus-summary-exit
73 :version "23.1" ;; No Gnus
76 (defcustom gnus-fetch-old-headers nil
77 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
78 If an unread article in the group refers to an older, already
79 read (or just marked as read) article, the old article will not
80 normally be displayed in the Summary buffer. If this variable is
81 t, Gnus will attempt to grab the headers to the old articles, and
82 thereby build complete threads. If it has the value `some', all
83 old headers will be fetched but only enough headers to connect
84 otherwise loose threads will be displayed. This variable can
85 also be a number. In that case, no more than that number of old
86 headers will be fetched. If it has the value `invisible', all
87 old headers will be fetched, but none will be displayed.
89 The server has to support NOV for any of this to work.
91 This feature can seriously impact performance it ignores all
92 locally cached header entries. Setting it to t for groups for a
93 server that doesn't expire articles (such as news.gmane.org),
94 leads to very slow summary generation."
96 :type '(choice (const :tag "off" nil)
101 (sexp :menu-tag "other" t)))
103 (defcustom gnus-refer-thread-limit 500
104 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
105 If t, fetch all the available old headers."
107 :type '(choice number
108 (sexp :menu-tag "other" t)))
110 (defcustom gnus-summary-make-false-root 'adopt
111 "*nil means that Gnus won't gather loose threads.
112 If the root of a thread has expired or been read in a previous
113 session, the information necessary to build a complete thread has been
114 lost. Instead of having many small sub-threads from this original thread
115 scattered all over the summary buffer, Gnus can gather them.
117 If non-nil, Gnus will try to gather all loose sub-threads from an
118 original thread into one large thread.
120 If this variable is non-nil, it should be one of `none', `adopt',
123 If this variable is `none', Gnus will not make a false root, but just
124 present the sub-threads after another.
125 If this variable is `dummy', Gnus will create a dummy root that will
126 have all the sub-threads as children.
127 If this variable is `adopt', Gnus will make one of the \"children\"
128 the parent and mark all the step-children as such.
129 If this variable is `empty', the \"children\" are printed with empty
130 subject fields. (Or rather, they will be printed with a string
131 given by the `gnus-summary-same-subject' variable.)"
133 :type '(choice (const :tag "off" nil)
139 (defcustom gnus-summary-make-false-root-always nil
140 "Always make a false dummy root."
145 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
146 "*A regexp to match subjects to be excluded from loose thread gathering.
147 As loose thread gathering is done on subjects only, that means that
148 there can be many false gatherings performed. By rooting out certain
149 common subjects, gathering might become saner."
153 (defcustom gnus-summary-gather-subject-limit nil
154 "*Maximum length of subject comparisons when gathering loose threads.
155 Use nil to compare full subjects. Setting this variable to a low
156 number will help gather threads that have been corrupted by
157 newsreaders chopping off subject lines, but it might also mean that
158 unrelated articles that have subject that happen to begin with the
159 same few characters will be incorrectly gathered.
161 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
164 :type '(choice (const :tag "off" nil)
166 (sexp :menu-tag "on" t)))
168 (defcustom gnus-simplify-subject-functions nil
169 "List of functions taking a string argument that simplify subjects.
170 The functions are applied recursively.
172 Useful functions to put in this list include:
173 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
174 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
176 :type '(repeat function))
178 (defcustom gnus-simplify-ignored-prefixes nil
179 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
181 :type '(choice (const :tag "off" nil)
184 (defcustom gnus-build-sparse-threads nil
185 "*If non-nil, fill in the gaps in threads.
186 If `some', only fill in the gaps that are needed to tie loose threads
187 together. If `more', fill in all leaf nodes that Gnus can find. If
188 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
190 :type '(choice (const :tag "off" nil)
193 (sexp :menu-tag "all" t)))
195 (defcustom gnus-summary-thread-gathering-function
196 'gnus-gather-threads-by-subject
197 "*Function used for gathering loose threads.
198 There are two pre-defined functions: `gnus-gather-threads-by-subject',
199 which only takes Subjects into consideration; and
200 `gnus-gather-threads-by-references', which compared the References
201 headers of the articles to find matches."
203 :type '(radio (function-item gnus-gather-threads-by-subject)
204 (function-item gnus-gather-threads-by-references)
205 (function :tag "other")))
207 (defcustom gnus-summary-same-subject ""
208 "*String indicating that the current article has the same subject as the previous.
209 This variable will only be used if the value of
210 `gnus-summary-make-false-root' is `empty'."
211 :group 'gnus-summary-format
214 (defcustom gnus-summary-goto-unread t
215 "*If t, many commands will go to the next unread article.
216 This applies to marking commands as well as other commands that
217 \"naturally\" select the next article, like, for instance, `SPC' at
218 the end of an article.
220 If nil, the marking commands do NOT go to the next unread article
221 \(they go to the next article instead). If `never', commands that
222 usually go to the next unread article, will go to the next article,
223 whether it is read or not."
224 :group 'gnus-summary-marks
225 :link '(custom-manual "(gnus)Setting Marks")
226 :type '(choice (const :tag "off" nil)
228 (sexp :menu-tag "on" t)))
230 (defcustom gnus-summary-default-score 0
231 "*Default article score level.
232 All scores generated by the score files will be added to this score.
233 If this variable is nil, scoring will be disabled."
234 :group 'gnus-score-default
235 :type '(choice (const :tag "disable")
238 (defcustom gnus-summary-default-high-score 0
239 "*Default threshold for a high scored article.
240 An article will be highlighted as high scored if its score is greater
243 :group 'gnus-score-default
246 (defcustom gnus-summary-default-low-score 0
247 "*Default threshold for a low scored article.
248 An article will be highlighted as low scored if its score is smaller
251 :group 'gnus-score-default
254 (defcustom gnus-summary-zcore-fuzz 0
255 "*Fuzziness factor for the zcore in the summary buffer.
256 Articles with scores closer than this to `gnus-summary-default-score'
258 :group 'gnus-summary-format
261 (defcustom gnus-simplify-subject-fuzzy-regexp nil
262 "*Strings to be removed when doing fuzzy matches.
263 This can either be a regular expression or list of regular expressions
264 that will be removed from subject strings if fuzzy subject
265 simplification is selected."
267 :type '(repeat regexp))
269 (defcustom gnus-show-threads t
270 "*If non-nil, display threads in summary mode."
274 (defcustom gnus-thread-hide-subtree nil
275 "*If non-nil, hide all threads initially.
276 This can be a predicate specifier which says which threads to hide.
277 If threads are hidden, you have to run the command
278 `gnus-summary-show-thread' by hand or select an article."
280 :type '(radio (sexp :format "Non-nil\n"
281 :match (lambda (widget value)
282 (not (or (consp value) (functionp value))))
285 (sexp :tag "Predicate specifier")))
287 (defcustom gnus-thread-hide-killed t
288 "*If non-nil, hide killed threads automatically."
292 (defcustom gnus-thread-ignore-subject t
293 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
294 If nil, articles that have different subjects from their parents will
295 start separate threads."
299 (defcustom gnus-thread-operation-ignore-subject t
300 "*If non-nil, subjects will be ignored when doing thread commands.
301 This affects commands like `gnus-summary-kill-thread' and
302 `gnus-summary-lower-thread'.
304 If this variable is nil, articles in the same thread with different
305 subjects will not be included in the operation in question. If this
306 variable is `fuzzy', only articles that have subjects that are fuzzily
307 equal will be included."
309 :type '(choice (const :tag "off" nil)
313 (defcustom gnus-thread-indent-level 4
314 "*Number that says how much each sub-thread should be indented."
318 (defcustom gnus-auto-extend-newsgroup t
319 "*If non-nil, extend newsgroup forward and backward when requested."
320 :group 'gnus-summary-choose
323 (defcustom gnus-auto-select-first t
324 "If non-nil, select an article on group entry.
325 An article is selected automatically when entering a group
326 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
327 `gnus-summary-catchup-and-goto-next-group'.
329 Which article is selected is controlled by the variable
330 `gnus-auto-select-subject'.
332 If you want to prevent automatic selection of articles in some
333 newsgroups, set the variable to nil in `gnus-select-group-hook'."
334 ;; Commands include...
335 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
336 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
337 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
338 :group 'gnus-group-select
339 :type '(choice (const :tag "none" nil)
340 (sexp :menu-tag "first" t)))
342 (defcustom gnus-auto-select-subject 'unread
343 "*Says what subject to place under point when entering a group.
345 This variable can either be the symbols `first' (place point on the
346 first subject), `unread' (place point on the subject line of the first
347 unread article), `best' (place point on the subject line of the
348 higest-scored article), `unseen' (place point on the subject line of
349 the first unseen article), `unseen-or-unread' (place point on the subject
350 line of the first unseen article or, if all article have been seen, on the
351 subject line of the first unread article), or a function to be called to
352 place point on some subject line."
354 :group 'gnus-group-select
355 :type '(choice (const best)
359 (const unseen-or-unread)))
361 (defcustom gnus-auto-select-next t
362 "*If non-nil, offer to go to the next group from the end of the previous.
363 If the value is t and the next newsgroup is empty, Gnus will exit
364 summary mode and go back to group mode. If the value is neither nil
365 nor t, Gnus will select the following unread newsgroup. In
366 particular, if the value is the symbol `quietly', the next unread
367 newsgroup will be selected without any confirmation, and if it is
368 `almost-quietly', the next group will be selected without any
369 confirmation if you are located on the last article in the group.
370 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
371 will go to the next group without confirmation."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "off" nil)
375 (const almost-quietly)
376 (const slightly-quietly)
377 (sexp :menu-tag "on" t)))
379 (defcustom gnus-auto-select-same nil
380 "*If non-nil, select the next article with the same subject.
381 If there are no more articles with the same subject, go to
382 the first unread article."
383 :group 'gnus-summary-maneuvering
386 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
387 "What article should be selected after exiting an ephemeral group.
388 Valid values include:
391 Select the next article.
393 Select the next unread article.
395 Move the cursor to the next article. This is the default.
396 `next-unread-noselect'
397 Move the cursor to the next unread article.
399 If it has any other value or there is no next (unread) article, the
400 article selected before entering to the ephemeral group will appear."
401 :version "23.1" ;; No Gnus
402 :group 'gnus-summary-maneuvering
403 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
404 (const next) (const next-unread)
405 (const next-noselect) (const next-unread-noselect)
406 (sexp :tag "other" :value nil)))
408 (defcustom gnus-auto-goto-ignores 'unfetched
409 "*Says how to handle unfetched articles when maneuvering.
411 This variable can either be the symbols nil (maneuver to any
412 article), `undownloaded' (maneuvering while unplugged ignores articles
413 that have not been fetched), `always-undownloaded' (maneuvering always
414 ignores articles that have not been fetched), `unfetched' (maneuvering
415 ignores articles whose headers have not been fetched).
417 NOTE: The list of unfetched articles will always be nil when plugged
418 and, when unplugged, a subset of the undownloaded article list."
420 :group 'gnus-summary-maneuvering
421 :type '(choice (const :tag "None" nil)
422 (const :tag "Undownloaded when unplugged" undownloaded)
423 (const :tag "Undownloaded" always-undownloaded)
424 (const :tag "Unfetched" unfetched)))
426 (defcustom gnus-summary-check-current nil
427 "*If non-nil, consider the current article when moving.
428 The \"unread\" movement commands will stay on the same line if the
429 current article is unread."
430 :group 'gnus-summary-maneuvering
433 (defcustom gnus-auto-center-summary 2
434 "*If non-nil, always center the current summary buffer.
435 In particular, if `vertical' do only vertical recentering. If non-nil
436 and non-`vertical', do both horizontal and vertical recentering."
437 :group 'gnus-summary-maneuvering
438 :type '(choice (const :tag "none" nil)
440 (integer :tag "height")
441 (sexp :menu-tag "both" t)))
443 (defvar gnus-auto-center-group t
444 "*If non-nil, always center the group buffer.")
446 (defcustom gnus-show-all-headers nil
447 "*If non-nil, don't hide any headers."
448 :group 'gnus-article-hiding
449 :group 'gnus-article-headers
452 (defcustom gnus-summary-ignore-duplicates nil
453 "*If non-nil, ignore articles with identical Message-ID headers."
457 (defcustom gnus-single-article-buffer t
458 "*If non-nil, display all articles in the same buffer.
459 If nil, each group will get its own article buffer."
460 :group 'gnus-article-various
463 (defcustom gnus-break-pages t
464 "*If non-nil, do page breaking on articles.
465 The page delimiter is specified by the `gnus-page-delimiter'
467 :group 'gnus-article-various
470 (defcustom gnus-move-split-methods nil
471 "*Variable used to suggest where articles are to be moved to.
472 It uses the same syntax as the `gnus-split-methods' variable.
473 However, whereas `gnus-split-methods' specifies file names as targets,
474 this variable specifies group names."
475 :group 'gnus-summary-mail
476 :type '(repeat (choice (list :value (fun) function)
477 (cons :value ("" "") regexp (repeat string))
480 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
481 "Function used to compute default prefix for article move/copy/etc prompts.
482 The function should take one argument, a group name, and return a
483 string with the suggested prefix."
484 :group 'gnus-summary-mail
487 ;; FIXME: Although the custom type is `character' for the following variables,
488 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
490 (defcustom gnus-unread-mark ? ;Whitespace
491 "*Mark used for unread articles."
492 :group 'gnus-summary-marks
495 (defcustom gnus-ticked-mark ?!
496 "*Mark used for ticked articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-dormant-mark ??
501 "*Mark used for dormant articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-del-mark ?r
506 "*Mark used for del'd articles."
507 :group 'gnus-summary-marks
510 (defcustom gnus-read-mark ?R
511 "*Mark used for read articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-expirable-mark ?E
516 "*Mark used for expirable articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-killed-mark ?K
521 "*Mark used for killed articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-spam-mark ?$
526 "*Mark used for spam articles."
528 :group 'gnus-summary-marks
531 (defcustom gnus-souped-mark ?F
532 "*Mark used for souped articles."
533 :group 'gnus-summary-marks
536 (defcustom gnus-kill-file-mark ?X
537 "*Mark used for articles killed by kill files."
538 :group 'gnus-summary-marks
541 (defcustom gnus-low-score-mark ?Y
542 "*Mark used for articles with a low score."
543 :group 'gnus-summary-marks
546 (defcustom gnus-catchup-mark ?C
547 "*Mark used for articles that are caught up."
548 :group 'gnus-summary-marks
551 (defcustom gnus-replied-mark ?A
552 "*Mark used for articles that have been replied to."
553 :group 'gnus-summary-marks
556 (defcustom gnus-forwarded-mark ?F
557 "*Mark used for articles that have been forwarded."
559 :group 'gnus-summary-marks
562 (defcustom gnus-recent-mark ?N
563 "*Mark used for articles that are recent."
565 :group 'gnus-summary-marks
568 (defcustom gnus-cached-mark ?*
569 "*Mark used for articles that are in the cache."
570 :group 'gnus-summary-marks
573 (defcustom gnus-saved-mark ?S
574 "*Mark used for articles that have been saved."
575 :group 'gnus-summary-marks
578 (defcustom gnus-unseen-mark ?.
579 "*Mark used for articles that haven't been seen."
581 :group 'gnus-summary-marks
584 (defcustom gnus-no-mark ? ;Whitespace
585 "*Mark used for articles that have no other secondary mark."
587 :group 'gnus-summary-marks
590 (defcustom gnus-ancient-mark ?O
591 "*Mark used for ancient articles."
592 :group 'gnus-summary-marks
595 (defcustom gnus-sparse-mark ?Q
596 "*Mark used for sparsely reffed articles."
597 :group 'gnus-summary-marks
600 (defcustom gnus-canceled-mark ?G
601 "*Mark used for canceled articles."
602 :group 'gnus-summary-marks
605 (defcustom gnus-duplicate-mark ?M
606 "*Mark used for duplicate articles."
607 :group 'gnus-summary-marks
610 (defcustom gnus-undownloaded-mark ?-
611 "*Mark used for articles that weren't downloaded."
613 :group 'gnus-summary-marks
616 (defcustom gnus-downloaded-mark ?+
617 "*Mark used for articles that were downloaded."
618 :group 'gnus-summary-marks
621 (defcustom gnus-downloadable-mark ?%
622 "*Mark used for articles that are to be downloaded."
623 :group 'gnus-summary-marks
626 (defcustom gnus-unsendable-mark ?=
627 "*Mark used for articles that won't be sent."
628 :group 'gnus-summary-marks
631 (defcustom gnus-score-over-mark ?+
632 "*Score mark used for articles with high scores."
633 :group 'gnus-summary-marks
636 (defcustom gnus-score-below-mark ?-
637 "*Score mark used for articles with low scores."
638 :group 'gnus-summary-marks
641 (defcustom gnus-empty-thread-mark ? ;Whitespace
642 "*There is no thread under the article."
643 :group 'gnus-summary-marks
646 (defcustom gnus-not-empty-thread-mark ?=
647 "*There is a thread under the article."
648 :group 'gnus-summary-marks
651 (defcustom gnus-view-pseudo-asynchronously nil
652 "*If non-nil, Gnus will view pseudo-articles asynchronously."
653 :group 'gnus-extract-view
656 (defcustom gnus-auto-expirable-marks
657 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
658 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
659 gnus-souped-mark gnus-duplicate-mark)
660 "*The list of marks converted into expiration if a group is auto-expirable."
663 :type '(repeat character))
665 (defcustom gnus-inhibit-user-auto-expire t
666 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
671 (defcustom gnus-view-pseudos nil
672 "*If `automatic', pseudo-articles will be viewed automatically.
673 If `not-confirm', pseudos will be viewed automatically, and the user
674 will not be asked to confirm the command."
675 :group 'gnus-extract-view
676 :type '(choice (const :tag "off" nil)
678 (const not-confirm)))
680 (defcustom gnus-view-pseudos-separately t
681 "*If non-nil, one pseudo-article will be created for each file to be viewed.
682 If nil, all files that use the same viewing command will be given as a
683 list of parameters to that command."
684 :group 'gnus-extract-view
687 (defcustom gnus-insert-pseudo-articles t
688 "*If non-nil, insert pseudo-articles when decoding articles."
689 :group 'gnus-extract-view
692 (defcustom gnus-summary-dummy-line-format
694 "*The format specification for the dummy roots in the summary buffer.
695 It works along the same lines as a normal formatting string,
696 with some simple extensions.
700 General format specifiers can also be used.
701 See `(gnus)Formatting Variables'."
702 :link '(custom-manual "(gnus)Formatting Variables")
703 :group 'gnus-threading
706 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
707 "*The format specification for the summary mode line.
708 It works along the same lines as a normal formatting string,
709 with some simple extensions:
712 %p Unprefixed group name
713 %A Current article number
714 %z Current article score
716 %U Number of unread articles in the group
717 %e Number of unselected articles in the group
718 %Z A string with unread/unselected article counts
719 %g Shortish group name
720 %S Subject of the current article
722 %s Current score file name
723 %d Number of dormant articles
724 %r Number of articles that have been marked as read in this session
725 %E Number of articles expunged by the score files"
726 :group 'gnus-summary-format
729 (defcustom gnus-list-identifiers nil
730 "Regexp that matches list identifiers to be removed from subject.
731 This can also be a list of regexps."
733 :group 'gnus-summary-format
734 :group 'gnus-article-hiding
735 :type '(choice (const :tag "none" nil)
737 (repeat :value (".*") regexp)))
739 (defcustom gnus-summary-mark-below 0
740 "*Mark all articles with a score below this variable as read.
741 This variable is local to each summary buffer and usually set by the
743 :group 'gnus-score-default
746 (defun gnus-widget-reversible-match (widget value)
747 "Ignoring WIDGET, convert VALUE to internal form.
748 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
752 (eq (length value) 2)
753 (eq (nth 0 value) 'not)
754 (symbolp (nth 1 value)))))
756 (defun gnus-widget-reversible-to-internal (widget value)
757 "Ignoring WIDGET, convert VALUE to internal form.
758 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
759 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
763 (list (nth 1 value) t)))
765 (defun gnus-widget-reversible-to-external (widget value)
766 "Ignoring WIDGET, convert VALUE to external form.
767 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
768 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
771 (list 'not (nth 0 value))
774 (define-widget 'gnus-widget-reversible 'group
775 "A `group' that convert values."
776 :match 'gnus-widget-reversible-match
777 :value-to-internal 'gnus-widget-reversible-to-internal
778 :value-to-external 'gnus-widget-reversible-to-external)
780 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
781 "*List of functions used for sorting articles in the summary buffer.
783 Each function takes two articles and returns non-nil if the first
784 article should be sorted before the other. If you use more than one
785 function, the primary sort function should be the last. You should
786 probably always include `gnus-article-sort-by-number' in the list of
787 sorting functions -- preferably first. Also note that sorting by date
788 is often much slower than sorting by number, and the sorting order is
789 very similar. (Sorting by date means sorting by the time the message
790 was sent, sorting by number means sorting by arrival time.)
792 Each item can also be a list `(not F)' where F is a function;
793 this reverses the sort order.
795 Ready-made functions include `gnus-article-sort-by-number',
796 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
797 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
798 and `gnus-article-sort-by-score'.
800 When threading is turned on, the variable `gnus-thread-sort-functions'
801 controls how articles are sorted."
802 :group 'gnus-summary-sort
803 :type '(repeat (gnus-widget-reversible
804 (choice (function-item gnus-article-sort-by-number)
805 (function-item gnus-article-sort-by-author)
806 (function-item gnus-article-sort-by-subject)
807 (function-item gnus-article-sort-by-date)
808 (function-item gnus-article-sort-by-score)
809 (function-item gnus-article-sort-by-random)
810 (function :tag "other"))
811 (boolean :tag "Reverse order"))))
814 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
815 "*List of functions used for sorting threads in the summary buffer.
816 By default, threads are sorted by article number.
818 Each function takes two threads and returns non-nil if the first
819 thread should be sorted before the other. If you use more than one
820 function, the primary sort function should be the last. You should
821 probably always include `gnus-thread-sort-by-number' in the list of
822 sorting functions -- preferably first. Also note that sorting by date
823 is often much slower than sorting by number, and the sorting order is
824 very similar. (Sorting by date means sorting by the time the message
825 was sent, sorting by number means sorting by arrival time.)
827 Each list item can also be a list `(not F)' where F is a
828 function; this specifies reversed sort order.
830 Ready-made functions include `gnus-thread-sort-by-number',
831 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
832 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
833 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
834 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
835 and `gnus-thread-sort-by-total-score' (see
836 `gnus-thread-score-function').
838 When threading is turned off, the variable
839 `gnus-article-sort-functions' controls how articles are sorted."
840 :group 'gnus-summary-sort
842 (gnus-widget-reversible
843 (choice (function-item gnus-thread-sort-by-number)
844 (function-item gnus-thread-sort-by-author)
845 (function-item gnus-thread-sort-by-recipient)
846 (function-item gnus-thread-sort-by-subject)
847 (function-item gnus-thread-sort-by-date)
848 (function-item gnus-thread-sort-by-score)
849 (function-item gnus-thread-sort-by-most-recent-number)
850 (function-item gnus-thread-sort-by-most-recent-date)
851 (function-item gnus-thread-sort-by-random)
852 (function-item gnus-thread-sort-by-total-score)
853 (function :tag "other"))
854 (boolean :tag "Reverse order"))))
856 (defcustom gnus-thread-score-function '+
857 "*Function used for calculating the total score of a thread.
859 The function is called with the scores of the article and each
860 subthread and should then return the score of the thread.
862 Some functions you can use are `+', `max', or `min'."
863 :group 'gnus-summary-sort
866 (defcustom gnus-summary-expunge-below nil
867 "All articles that have a score less than this variable will be expunged.
868 This variable is local to the summary buffers."
869 :group 'gnus-score-default
870 :type '(choice (const :tag "off" nil)
873 (defcustom gnus-thread-expunge-below nil
874 "All threads that have a total score less than this variable will be expunged.
875 See `gnus-thread-score-function' for en explanation of what a
878 This variable is local to the summary buffers."
879 :group 'gnus-threading
880 :group 'gnus-score-default
881 :type '(choice (const :tag "off" nil)
884 (defcustom gnus-summary-mode-hook nil
885 "*A hook for Gnus summary mode.
886 This hook is run before any variables are set in the summary buffer."
887 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
888 :group 'gnus-summary-various
891 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
892 (when (featurep 'xemacs)
893 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
894 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
895 (add-hook 'gnus-summary-mode-hook
896 'gnus-xmas-switch-horizontal-scrollbar-off))
898 (defcustom gnus-summary-menu-hook nil
899 "*Hook run after the creation of the summary mode menu."
900 :group 'gnus-summary-visual
903 (defcustom gnus-summary-exit-hook nil
904 "*A hook called on exit from the summary buffer.
905 It will be called with point in the group buffer."
906 :group 'gnus-summary-exit
909 (defcustom gnus-summary-prepare-hook nil
910 "*A hook called after the summary buffer has been generated.
911 If you want to modify the summary buffer, you can use this hook."
912 :group 'gnus-summary-various
915 (defcustom gnus-summary-prepared-hook nil
916 "*A hook called as the last thing after the summary buffer has been generated."
917 :group 'gnus-summary-various
920 (defcustom gnus-summary-generate-hook nil
921 "*A hook run just before generating the summary buffer.
922 This hook is commonly used to customize threading variables and the
924 :group 'gnus-summary-various
927 (defcustom gnus-select-group-hook nil
928 "*A hook called when a newsgroup is selected.
930 If you'd like to simplify subjects like the
931 `gnus-summary-next-same-subject' command does, you can use the
934 (add-hook gnus-select-group-hook
936 (mapcar (lambda (header)
937 (mail-header-set-subject
939 (gnus-simplify-subject
940 (mail-header-subject header) 're-only)))
941 gnus-newsgroup-headers)))"
942 :group 'gnus-group-select
945 (defcustom gnus-select-article-hook nil
946 "*A hook called when an article is selected."
947 :group 'gnus-summary-choose
948 :options '(gnus-agent-fetch-selected-article)
951 (defcustom gnus-visual-mark-article-hook
952 (list 'gnus-highlight-selected-summary)
953 "*Hook run after selecting an article in the summary buffer.
954 It is meant to be used for highlighting the article in some way. It
955 is not run if `gnus-visual' is nil."
956 :group 'gnus-summary-visual
959 (defcustom gnus-parse-headers-hook nil
960 "*A hook called before parsing the headers."
964 (defcustom gnus-exit-group-hook nil
965 "*A hook called when exiting summary mode.
966 This hook is not called from the non-updating exit commands like `Q'."
970 (defcustom gnus-summary-update-hook
971 (list 'gnus-summary-highlight-line)
972 "*A hook called when a summary line is changed.
973 The hook will not be called if `gnus-visual' is nil.
975 The default function `gnus-summary-highlight-line' will
976 highlight the line according to the `gnus-summary-highlight'
978 :group 'gnus-summary-visual
981 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
982 "*A hook called when an article is selected for the first time.
983 The hook is intended to mark an article as read (or unread)
984 automatically when it is selected."
985 :group 'gnus-summary-choose
988 (defcustom gnus-group-no-more-groups-hook nil
989 "*A hook run when returning to group mode having no more (unread) groups."
990 :group 'gnus-group-select
993 (defcustom gnus-ps-print-hook nil
994 "*A hook run before ps-printing something from Gnus."
998 (defcustom gnus-summary-article-move-hook nil
999 "*A hook called after an article is moved, copied, respooled, or crossposted."
1001 :group 'gnus-summary
1004 (defcustom gnus-summary-article-delete-hook nil
1005 "*A hook called after an article is deleted."
1007 :group 'gnus-summary
1010 (defcustom gnus-summary-article-expire-hook nil
1011 "*A hook called after an article is expired."
1013 :group 'gnus-summary
1016 (defcustom gnus-summary-display-arrow
1017 (and (fboundp 'display-graphic-p)
1018 (display-graphic-p))
1019 "*If non-nil, display an arrow highlighting the current article."
1021 :group 'gnus-summary
1024 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1025 "Face used for highlighting the current article in the summary buffer."
1026 :group 'gnus-summary-visual
1029 (defvar gnus-tmp-downloaded nil)
1031 (defcustom gnus-summary-highlight
1032 '(((eq mark gnus-canceled-mark)
1033 . gnus-summary-cancelled)
1034 ((and uncached (> score default-high))
1035 . gnus-summary-high-undownloaded)
1036 ((and uncached (< score default-low))
1037 . gnus-summary-low-undownloaded)
1039 . gnus-summary-normal-undownloaded)
1040 ((and (> score default-high)
1041 (or (eq mark gnus-dormant-mark)
1042 (eq mark gnus-ticked-mark)))
1043 . gnus-summary-high-ticked)
1044 ((and (< score default-low)
1045 (or (eq mark gnus-dormant-mark)
1046 (eq mark gnus-ticked-mark)))
1047 . gnus-summary-low-ticked)
1048 ((or (eq mark gnus-dormant-mark)
1049 (eq mark gnus-ticked-mark))
1050 . gnus-summary-normal-ticked)
1051 ((and (> score default-high) (eq mark gnus-ancient-mark))
1052 . gnus-summary-high-ancient)
1053 ((and (< score default-low) (eq mark gnus-ancient-mark))
1054 . gnus-summary-low-ancient)
1055 ((eq mark gnus-ancient-mark)
1056 . gnus-summary-normal-ancient)
1057 ((and (> score default-high) (eq mark gnus-unread-mark))
1058 . gnus-summary-high-unread)
1059 ((and (< score default-low) (eq mark gnus-unread-mark))
1060 . gnus-summary-low-unread)
1061 ((eq mark gnus-unread-mark)
1062 . gnus-summary-normal-unread)
1063 ((> score default-high)
1064 . gnus-summary-high-read)
1065 ((< score default-low)
1066 . gnus-summary-low-read)
1068 . gnus-summary-normal-read))
1069 "*Controls the highlighting of summary buffer lines.
1071 A list of (FORM . FACE) pairs. When deciding how a particular
1072 summary line should be displayed, each form is evaluated. The content
1073 of the face field after the first true form is used. You can change
1074 how those summary lines are displayed, by editing the face field.
1076 You can use the following variables in the FORM field.
1078 score: The article's score.
1079 default: The default article score.
1080 default-high: The default score for high scored articles.
1081 default-low: The default score for low scored articles.
1082 below: The score below which articles are automatically marked as read.
1083 mark: The article's mark.
1084 uncached: Non-nil if the article is uncached."
1085 :group 'gnus-summary-visual
1086 :type '(repeat (cons (sexp :tag "Form" nil)
1088 (put 'gnus-summary-highlight 'risky-local-variable t)
1090 (defcustom gnus-alter-header-function nil
1091 "Function called to allow alteration of article header structures.
1092 The function is called with one parameter, the article header vector,
1093 which it may alter in any way."
1094 :type '(choice (const :tag "None" nil)
1096 :group 'gnus-summary)
1098 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1099 "Function used to decode a string with encoded words.")
1101 (defvar gnus-decode-encoded-address-function
1102 'mail-decode-encoded-address-string
1103 "Function used to decode addresses with encoded words.")
1105 (defcustom gnus-extra-headers '(To Newsgroups)
1106 "*Extra headers to parse."
1108 :group 'gnus-summary
1109 :type '(repeat symbol))
1111 (defcustom gnus-ignored-from-addresses
1112 (and user-mail-address
1113 (not (string= user-mail-address ""))
1114 (regexp-quote user-mail-address))
1115 "*From headers that may be suppressed in favor of To headers.
1116 This can be a regexp or a list of regexps."
1118 :group 'gnus-summary
1119 :type '(choice regexp
1120 (repeat :tag "Regexp List" regexp)))
1122 (defsubst gnus-ignored-from-addresses ()
1123 (gmm-regexp-concat gnus-ignored-from-addresses))
1125 (defcustom gnus-summary-to-prefix "-> "
1126 "*String prefixed to the To field in the summary line when
1127 using `gnus-ignored-from-addresses'."
1129 :group 'gnus-summary
1132 (defcustom gnus-summary-newsgroup-prefix "=> "
1133 "*String prefixed to the Newsgroup field in the summary
1134 line when using `gnus-ignored-from-addresses'."
1136 :group 'gnus-summary
1139 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1140 "List of charsets that should be ignored.
1141 When these charsets are used in the \"charset\" parameter, the
1142 default charset will be used instead."
1144 :type '(repeat symbol)
1145 :group 'gnus-charset)
1147 (defcustom gnus-newsgroup-maximum-articles nil
1148 "The maximum number of articles a newsgroup.
1149 If this is a number, old articles in a newsgroup exceeding this number
1150 are silently ignored. If it is nil, no article is ignored. Note that
1151 setting this variable to a number might prevent you from reading very
1153 :group 'gnus-group-select
1155 :type '(choice (const :tag "No limit" nil)
1158 (gnus-define-group-parameter
1162 "Return the ignored charsets of GROUP."
1163 :variable gnus-group-ignored-charsets-alist
1165 '(("alt\\.chinese\\.text" iso-8859-1))
1167 "Alist of regexps (to match group names) and charsets that should be ignored.
1168 When these charsets are used in the \"charset\" parameter, the
1169 default charset will be used instead."
1170 :variable-group gnus-charset
1171 :variable-type '(repeat (cons (regexp :tag "Group")
1173 :parameter-type '(choice :tag "Ignored charsets"
1176 :parameter-document "\
1177 List of charsets that should be ignored.
1179 When these charsets are used in the \"charset\" parameter, the
1180 default charset will be used instead.")
1182 (defcustom gnus-group-highlight-words-alist nil
1183 "Alist of group regexps and highlight regexps.
1184 This variable uses the same syntax as `gnus-emphasis-alist'."
1186 :type '(repeat (cons (regexp :tag "Group")
1187 (repeat (list (regexp :tag "Highlight regexp")
1188 (number :tag "Group for entire word" 0)
1189 (number :tag "Group for displayed part" 0)
1191 gnus-emphasis-highlight-words)))))
1192 :group 'gnus-summary-visual)
1194 (defcustom gnus-summary-show-article-charset-alist
1196 "Alist of number and charset.
1197 The article will be shown with the charset corresponding to the
1199 For example: ((1 . cn-gb-2312) (2 . big5))."
1201 :type '(repeat (cons (number :tag "Argument" 1)
1202 (symbol :tag "Charset")))
1203 :group 'gnus-charset)
1205 (defcustom gnus-preserve-marks t
1206 "Whether marks are preserved when moving, copying and respooling messages."
1209 :group 'gnus-summary-marks)
1211 (defcustom gnus-propagate-marks t
1212 "If non-nil, do not propagate marks to the backends."
1213 :version "23.1" ;; No Gnus
1215 :group 'gnus-summary-marks)
1217 (defcustom gnus-alter-articles-to-read-function nil
1218 "Function to be called to alter the list of articles to be selected."
1219 :type '(choice (const nil) function)
1220 :group 'gnus-summary)
1222 (defcustom gnus-orphan-score nil
1223 "*All orphans get this score added. Set in the score file."
1224 :group 'gnus-score-default
1225 :type '(choice (const nil)
1228 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1229 "*A regexp to match MIME parts when saving multiple parts of a
1230 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1231 This regexp will be used by default when prompting the user for which
1232 type of files to save."
1233 :group 'gnus-summary
1236 (defcustom gnus-read-all-available-headers nil
1237 "Whether Gnus should parse all headers made available to it.
1238 This is mostly relevant for slow back ends where the user may
1239 wish to widen the summary buffer to include all headers
1240 that were fetched. Say, for nnultimate groups."
1242 :group 'gnus-summary
1243 :type '(choice boolean regexp))
1245 (defcustom gnus-summary-pipe-output-default-command nil
1246 "Command (and optional arguments) used to pipe article to subprocess.
1247 This will be used as the default command if it is non-nil. The value
1248 will be updated if you modify it when executing the command
1249 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1250 :version "23.1" ;; No Gnus
1251 :group 'gnus-summary
1252 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1254 (defcustom gnus-summary-muttprint-program "muttprint"
1255 "Command (and optional arguments) used to run Muttprint.
1256 The value will be updated if you modify it when executing the command
1257 `gnus-summary-muttprint'."
1259 :group 'gnus-summary
1262 (defcustom gnus-article-loose-mime t
1263 "If non-nil, don't require MIME-Version header.
1264 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1265 supply the MIME-Version header or deliberately strip it from the mail.
1266 If non-nil (the default), Gnus will treat some articles as MIME
1267 even if the MIME-Version header is missing."
1270 :group 'gnus-article-mime)
1272 (defcustom gnus-article-emulate-mime t
1273 "If non-nil, use MIME emulation for uuencode and the like.
1274 This means that Gnus will search message bodies for text that look
1275 like uuencoded bits, yEncoded bits, and so on, and present that using
1276 the normal Gnus MIME machinery."
1279 :group 'gnus-article-mime)
1281 ;;; Internal variables
1283 (defvar gnus-summary-display-cache nil)
1284 (defvar gnus-article-mime-handles nil)
1285 (defvar gnus-article-decoded-p nil)
1286 (defvar gnus-article-charset nil)
1287 (defvar gnus-article-ignored-charsets nil)
1288 (defvar gnus-scores-exclude-files nil)
1289 (defvar gnus-page-broken nil)
1291 (defvar gnus-original-article nil)
1292 (defvar gnus-article-internal-prepare-hook nil)
1293 (defvar gnus-newsgroup-process-stack nil)
1295 (defvar gnus-thread-indent-array nil)
1296 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1297 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1298 "Function called to sort the articles within a thread after it has been gathered together.")
1300 (defvar gnus-summary-save-parts-type-history nil)
1301 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1303 ;; Avoid highlighting in kill files.
1304 (defvar gnus-summary-inhibit-highlight nil)
1305 (defvar gnus-newsgroup-selected-overlay nil)
1306 (defvar gnus-inhibit-limiting nil)
1307 (defvar gnus-newsgroup-adaptive-score-file nil)
1308 (defvar gnus-current-score-file nil)
1309 (defvar gnus-current-move-group nil)
1310 (defvar gnus-current-copy-group nil)
1311 (defvar gnus-current-crosspost-group nil)
1312 (defvar gnus-newsgroup-display nil)
1314 (defvar gnus-newsgroup-dependencies nil)
1315 (defvar gnus-newsgroup-adaptive nil)
1316 (defvar gnus-summary-display-article-function nil)
1317 (defvar gnus-summary-highlight-line-function nil
1318 "Function called after highlighting a summary line.")
1320 (defvar gnus-summary-line-format-alist
1321 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1322 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1323 (?s gnus-tmp-subject-or-nil ?s)
1324 (?n gnus-tmp-name ?s)
1325 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1327 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1329 (?F gnus-tmp-from ?s)
1330 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1331 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1332 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1333 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1334 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1335 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1336 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1337 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1338 (?L gnus-tmp-lines ?s)
1339 (?O gnus-tmp-downloaded ?c)
1340 (?I gnus-tmp-indentation ?s)
1341 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1342 (?R gnus-tmp-replied ?c)
1343 (?\[ gnus-tmp-opening-bracket ?c)
1344 (?\] gnus-tmp-closing-bracket ?c)
1345 (?\> (make-string gnus-tmp-level ? ) ?s)
1346 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1347 (?i gnus-tmp-score ?d)
1348 (?z gnus-tmp-score-char ?c)
1349 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1350 (?U gnus-tmp-unread ?c)
1351 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1353 (?t (gnus-summary-number-of-articles-in-thread
1354 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1356 (?e (gnus-summary-number-of-articles-in-thread
1357 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1359 (?u gnus-tmp-user-defined ?s)
1360 (?P (gnus-pick-line-number) ?d)
1361 (?B gnus-tmp-thread-tree-header-string ?s)
1362 (user-date (gnus-user-date
1363 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1364 "An alist of format specifications that can appear in summary lines.
1365 These are paired with what variables they correspond with, along with
1366 the type of the variable (string, integer, character, etc).")
1368 (defvar gnus-summary-dummy-line-format-alist
1369 `((?S gnus-tmp-subject ?s)
1370 (?N gnus-tmp-number ?d)
1371 (?u gnus-tmp-user-defined ?s)))
1373 (defvar gnus-summary-mode-line-format-alist
1374 `((?G gnus-tmp-group-name ?s)
1375 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1376 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1377 (?A gnus-tmp-article-number ?d)
1378 (?Z gnus-tmp-unread-and-unselected ?s)
1379 (?V gnus-version ?s)
1380 (?U gnus-tmp-unread-and-unticked ?d)
1381 (?S gnus-tmp-subject ?s)
1382 (?e gnus-tmp-unselected ?d)
1383 (?u gnus-tmp-user-defined ?s)
1384 (?d (length gnus-newsgroup-dormant) ?d)
1385 (?t (length gnus-newsgroup-marked) ?d)
1386 (?h (length gnus-newsgroup-spam-marked) ?d)
1387 (?r (length gnus-newsgroup-reads) ?d)
1388 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1389 (?E gnus-newsgroup-expunged-tally ?d)
1390 (?s (gnus-current-score-file-nondirectory) ?s)))
1392 ;; This is here rather than in gnus-art for compilation reasons.
1393 (defvar gnus-article-mode-line-format-alist
1394 (nconc '((?w (gnus-article-wash-status) ?s)
1395 (?m (gnus-article-mime-part-status) ?s))
1396 gnus-summary-mode-line-format-alist))
1398 (defvar gnus-last-search-regexp nil
1399 "Default regexp for article search command.")
1401 (defvar gnus-last-shell-command nil
1402 "Default shell command on article.")
1404 (defvar gnus-newsgroup-agentized nil
1405 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1406 (defvar gnus-newsgroup-begin nil)
1407 (defvar gnus-newsgroup-end nil)
1408 (defvar gnus-newsgroup-last-rmail nil)
1409 (defvar gnus-newsgroup-last-mail nil)
1410 (defvar gnus-newsgroup-last-folder nil)
1411 (defvar gnus-newsgroup-last-file nil)
1412 (defvar gnus-newsgroup-last-directory nil)
1413 (defvar gnus-newsgroup-auto-expire nil)
1414 (defvar gnus-newsgroup-active nil)
1416 (defvar gnus-newsgroup-data nil)
1417 (defvar gnus-newsgroup-data-reverse nil)
1418 (defvar gnus-newsgroup-limit nil)
1419 (defvar gnus-newsgroup-limits nil)
1420 (defvar gnus-summary-use-undownloaded-faces nil)
1422 (defvar gnus-newsgroup-unreads nil
1423 "Sorted list of unread articles in the current newsgroup.")
1425 (defvar gnus-newsgroup-unselected nil
1426 "Sorted list of unselected unread articles in the current newsgroup.")
1428 (defvar gnus-newsgroup-reads nil
1429 "Alist of read articles and article marks in the current newsgroup.")
1431 (defvar gnus-newsgroup-expunged-tally nil)
1433 (defvar gnus-newsgroup-marked nil
1434 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1436 (defvar gnus-newsgroup-spam-marked nil
1437 "List of ranges of articles that have been marked as spam.")
1439 (defvar gnus-newsgroup-killed nil
1440 "List of ranges of articles that have been through the scoring process.")
1442 (defvar gnus-newsgroup-cached nil
1443 "Sorted list of articles that come from the article cache.")
1445 (defvar gnus-newsgroup-saved nil
1446 "List of articles that have been saved.")
1448 (defvar gnus-newsgroup-kill-headers nil)
1450 (defvar gnus-newsgroup-replied nil
1451 "List of articles that have been replied to in the current newsgroup.")
1453 (defvar gnus-newsgroup-forwarded nil
1454 "List of articles that have been forwarded in the current newsgroup.")
1456 (defvar gnus-newsgroup-recent nil
1457 "List of articles that have are recent in the current newsgroup.")
1459 (defvar gnus-newsgroup-expirable nil
1460 "Sorted list of articles in the current newsgroup that can be expired.")
1462 (defvar gnus-newsgroup-processable nil
1463 "List of articles in the current newsgroup that can be processed.")
1465 (defvar gnus-newsgroup-downloadable nil
1466 "Sorted list of articles in the current newsgroup that can be processed.")
1468 (defvar gnus-newsgroup-unfetched nil
1469 "Sorted list of articles in the current newsgroup whose headers have
1470 not been fetched into the agent.
1472 This list will always be a subset of gnus-newsgroup-undownloaded.")
1474 (defvar gnus-newsgroup-undownloaded nil
1475 "List of articles in the current newsgroup that haven't been downloaded.")
1477 (defvar gnus-newsgroup-unsendable nil
1478 "List of articles in the current newsgroup that won't be sent.")
1480 (defvar gnus-newsgroup-bookmarks nil
1481 "List of articles in the current newsgroup that have bookmarks.")
1483 (defvar gnus-newsgroup-dormant nil
1484 "Sorted list of dormant articles in the current newsgroup.")
1486 (defvar gnus-newsgroup-unseen nil
1487 "List of unseen articles in the current newsgroup.")
1489 (defvar gnus-newsgroup-seen nil
1490 "Range of seen articles in the current newsgroup.")
1492 (defvar gnus-newsgroup-articles nil
1493 "List of articles in the current newsgroup.")
1495 (defvar gnus-newsgroup-scored nil
1496 "List of scored articles in the current newsgroup.")
1498 (defvar gnus-newsgroup-headers nil
1499 "List of article headers in the current newsgroup.")
1501 (defvar gnus-newsgroup-threads nil)
1503 (defvar gnus-newsgroup-prepared nil
1504 "Whether the current group has been prepared properly.")
1506 (defvar gnus-newsgroup-ancient nil
1507 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1509 (defvar gnus-newsgroup-sparse nil)
1511 (defvar gnus-current-article nil)
1512 (defvar gnus-article-current nil)
1513 (defvar gnus-current-headers nil)
1514 (defvar gnus-have-all-headers nil)
1515 (defvar gnus-last-article nil)
1516 (defvar gnus-newsgroup-history nil)
1517 (defvar gnus-newsgroup-charset nil)
1518 (defvar gnus-newsgroup-ephemeral-charset nil)
1519 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1521 (defvar gnus-article-before-search nil)
1523 (defvar gnus-summary-local-variables
1524 '(gnus-newsgroup-name
1525 gnus-newsgroup-begin gnus-newsgroup-end
1526 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1527 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1528 gnus-newsgroup-last-directory
1529 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1530 gnus-newsgroup-unselected gnus-newsgroup-marked
1531 gnus-newsgroup-spam-marked
1532 gnus-newsgroup-reads gnus-newsgroup-saved
1533 gnus-newsgroup-replied gnus-newsgroup-forwarded
1534 gnus-newsgroup-recent
1535 gnus-newsgroup-expirable
1536 gnus-newsgroup-processable gnus-newsgroup-killed
1537 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1538 gnus-newsgroup-unfetched
1539 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1540 gnus-newsgroup-seen gnus-newsgroup-articles
1541 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1542 gnus-newsgroup-headers gnus-newsgroup-threads
1543 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1544 gnus-current-article gnus-current-headers gnus-have-all-headers
1545 gnus-last-article gnus-article-internal-prepare-hook
1546 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1547 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1548 gnus-thread-expunge-below
1549 gnus-score-alist gnus-current-score-file
1550 (gnus-summary-expunge-below . global)
1551 (gnus-summary-mark-below . global)
1552 (gnus-orphan-score . global)
1553 gnus-newsgroup-active gnus-scores-exclude-files
1554 gnus-newsgroup-history gnus-newsgroup-ancient
1555 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1556 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1557 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1558 (gnus-newsgroup-expunged-tally . 0)
1559 gnus-cache-removable-articles gnus-newsgroup-cached
1560 gnus-newsgroup-data gnus-newsgroup-data-reverse
1561 gnus-newsgroup-limit gnus-newsgroup-limits
1562 gnus-newsgroup-charset gnus-newsgroup-display
1563 gnus-summary-use-undownloaded-faces)
1564 "Variables that are buffer-local to the summary buffers.")
1566 (defvar gnus-newsgroup-variables nil
1567 "A list of variables that have separate values in different newsgroups.
1568 A list of newsgroup (summary buffer) local variables, or cons of
1569 variables and their default expressions to be evalled (when the default
1570 values are not nil), that should be made global while the summary buffer
1573 Note: The default expressions will be evaluated (using function `eval')
1574 before assignment to the local variable rather than just assigned to it.
1575 If the default expression is the symbol `global', that symbol will not
1576 be evaluated but the global value of the local variable will be used
1579 These variables can be used to set variables in the group parameters
1580 while still allowing them to affect operations done in other buffers.
1583 \(setq gnus-newsgroup-variables
1584 '(message-use-followup-to
1585 (gnus-visible-headers .
1586 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1590 ;; Bind features so that require will believe that gnus-sum has
1591 ;; already been loaded (avoids infinite recursion)
1592 (let ((features (cons 'gnus-sum features)))
1593 (require 'gnus-art)))
1597 (defvar gnus-decode-encoded-word-methods
1598 '(mail-decode-encoded-word-string)
1599 "List of methods used to decode encoded words.
1601 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1602 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1603 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1604 whose names match REGEXP.
1607 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1608 mail-decode-encoded-word-string
1609 (\"chinese\" . rfc1843-decode-string))")
1611 (defvar gnus-decode-encoded-word-methods-cache nil)
1613 (defun gnus-multi-decode-encoded-word-string (string)
1614 "Apply the functions from `gnus-encoded-word-methods' that match."
1615 (unless (and gnus-decode-encoded-word-methods-cache
1616 (eq gnus-newsgroup-name
1617 (car gnus-decode-encoded-word-methods-cache)))
1618 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1619 (dolist (method gnus-decode-encoded-word-methods)
1620 (if (symbolp method)
1621 (nconc gnus-decode-encoded-word-methods-cache (list method))
1622 (if (and gnus-newsgroup-name
1623 (string-match (car method) gnus-newsgroup-name))
1624 (nconc gnus-decode-encoded-word-methods-cache
1625 (list (cdr method)))))))
1626 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1627 (setq string (funcall method string))))
1629 ;; Subject simplification.
1631 (defun gnus-simplify-whitespace (str)
1632 "Remove excessive whitespace from STR."
1634 (while (string-match "[ \t][ \t]+" str)
1635 (setq str (concat (substring str 0 (match-beginning 0))
1637 (substring str (match-end 0)))))
1639 (when (string-match "^[ \t]+" str)
1640 (setq str (substring str (match-end 0))))
1642 (when (string-match "[ \t]+$" str)
1643 (setq str (substring str 0 (match-beginning 0))))
1646 (defun gnus-simplify-all-whitespace (str)
1647 "Remove all whitespace from STR."
1648 (while (string-match "[ \t\n]+" str)
1649 (setq str (replace-match "" nil nil str)))
1652 (defsubst gnus-simplify-subject-re (subject)
1653 "Remove \"Re:\" from subject lines."
1654 (if (string-match message-subject-re-regexp subject)
1655 (substring subject (match-end 0))
1658 (defun gnus-simplify-subject (subject &optional re-only)
1659 "Remove `Re:' and words in parentheses.
1660 If RE-ONLY is non-nil, strip leading `Re:'s only."
1661 (let ((case-fold-search t)) ;Ignore case.
1662 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1663 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1664 (setq subject (substring subject (match-end 0))))
1665 ;; Remove uninteresting prefixes.
1666 (when (and (not re-only)
1667 gnus-simplify-ignored-prefixes
1668 (string-match gnus-simplify-ignored-prefixes subject))
1669 (setq subject (substring subject (match-end 0))))
1670 ;; Remove words in parentheses from end.
1672 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1673 (setq subject (substring subject 0 (match-beginning 0)))))
1674 ;; Return subject string.
1677 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1679 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1680 (goto-char (point-min))
1681 (while (re-search-forward regexp nil t)
1682 (replace-match (or newtext ""))))
1684 (defun gnus-simplify-buffer-fuzzy ()
1685 "Simplify string in the buffer fuzzily.
1686 The string in the accessible portion of the current buffer is simplified.
1687 It is assumed to be a single-line subject.
1688 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1689 matter is removed. Additional things can be deleted by setting
1690 `gnus-simplify-subject-fuzzy-regexp'."
1691 (let ((case-fold-search t)
1693 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1695 (while (not (eq modified-tick (buffer-modified-tick)))
1696 (setq modified-tick (buffer-modified-tick))
1698 ((listp gnus-simplify-subject-fuzzy-regexp)
1699 (mapc 'gnus-simplify-buffer-fuzzy-step
1700 gnus-simplify-subject-fuzzy-regexp))
1701 (gnus-simplify-subject-fuzzy-regexp
1702 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1703 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1704 (gnus-simplify-buffer-fuzzy-step
1705 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1706 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1708 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1709 (gnus-simplify-buffer-fuzzy-step " +" " ")
1710 (gnus-simplify-buffer-fuzzy-step " $")
1711 (gnus-simplify-buffer-fuzzy-step "^ +")))
1713 (defun gnus-simplify-subject-fuzzy (subject)
1714 "Simplify a subject string fuzzily.
1715 See `gnus-simplify-buffer-fuzzy' for details."
1717 (gnus-set-work-buffer)
1718 (let ((case-fold-search t))
1719 ;; Remove uninteresting prefixes.
1720 (when (and gnus-simplify-ignored-prefixes
1721 (string-match gnus-simplify-ignored-prefixes subject))
1722 (setq subject (substring subject (match-end 0))))
1724 (inline (gnus-simplify-buffer-fuzzy))
1727 (defsubst gnus-simplify-subject-fully (subject)
1728 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1730 (gnus-simplify-subject-functions
1731 (gnus-map-function gnus-simplify-subject-functions subject))
1732 ((null gnus-summary-gather-subject-limit)
1733 (gnus-simplify-subject-re subject))
1734 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1735 (gnus-simplify-subject-fuzzy subject))
1736 ((numberp gnus-summary-gather-subject-limit)
1737 (truncate-string-to-width (gnus-simplify-subject-re subject)
1738 gnus-summary-gather-subject-limit))
1742 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1743 "Check whether two subjects are equal.
1744 If optional argument SIMPLE-FIRST is t, first argument is already
1747 ((null simple-first)
1748 (equal (gnus-simplify-subject-fully s1)
1749 (gnus-simplify-subject-fully s2)))
1752 (gnus-simplify-subject-fully s2)))))
1754 (defun gnus-summary-bubble-group ()
1755 "Increase the score of the current group.
1756 This is a handy function to add to `gnus-summary-exit-hook' to
1757 increase the score of each group you read."
1758 (gnus-group-add-score gnus-newsgroup-name))
1762 ;;; Gnus summary mode
1765 (put 'gnus-summary-mode 'mode-class 'special)
1767 (defvar gnus-article-commands-menu)
1769 ;; Non-orthogonal keys
1771 (gnus-define-keys gnus-summary-mode-map
1772 " " gnus-summary-next-page
1773 "\177" gnus-summary-prev-page
1774 [delete] gnus-summary-prev-page
1775 [backspace] gnus-summary-prev-page
1776 "\r" gnus-summary-scroll-up
1777 "\M-\r" gnus-summary-scroll-down
1778 "n" gnus-summary-next-unread-article
1779 "p" gnus-summary-prev-unread-article
1780 "N" gnus-summary-next-article
1781 "P" gnus-summary-prev-article
1782 "\M-\C-n" gnus-summary-next-same-subject
1783 "\M-\C-p" gnus-summary-prev-same-subject
1784 "\M-n" gnus-summary-next-unread-subject
1785 "\M-p" gnus-summary-prev-unread-subject
1786 "." gnus-summary-first-unread-article
1787 "," gnus-summary-best-unread-article
1788 "\M-s" gnus-summary-search-article-forward
1789 "\M-r" gnus-summary-search-article-backward
1790 "\M-S" gnus-summary-repeat-search-article-forward
1791 "\M-R" gnus-summary-repeat-search-article-backward
1792 "<" gnus-summary-beginning-of-article
1793 ">" gnus-summary-end-of-article
1794 "j" gnus-summary-goto-article
1795 "^" gnus-summary-refer-parent-article
1796 "\M-^" gnus-summary-refer-article
1797 "u" gnus-summary-tick-article-forward
1798 "!" gnus-summary-tick-article-forward
1799 "U" gnus-summary-tick-article-backward
1800 "d" gnus-summary-mark-as-read-forward
1801 "D" gnus-summary-mark-as-read-backward
1802 "E" gnus-summary-mark-as-expirable
1803 "\M-u" gnus-summary-clear-mark-forward
1804 "\M-U" gnus-summary-clear-mark-backward
1805 "k" gnus-summary-kill-same-subject-and-select
1806 "\C-k" gnus-summary-kill-same-subject
1807 "\M-\C-k" gnus-summary-kill-thread
1808 "\M-\C-l" gnus-summary-lower-thread
1809 "e" gnus-summary-edit-article
1810 "#" gnus-summary-mark-as-processable
1811 "\M-#" gnus-summary-unmark-as-processable
1812 "\M-\C-t" gnus-summary-toggle-threads
1813 "\M-\C-s" gnus-summary-show-thread
1814 "\M-\C-h" gnus-summary-hide-thread
1815 "\M-\C-f" gnus-summary-next-thread
1816 "\M-\C-b" gnus-summary-prev-thread
1817 [(meta down)] gnus-summary-next-thread
1818 [(meta up)] gnus-summary-prev-thread
1819 "\M-\C-u" gnus-summary-up-thread
1820 "\M-\C-d" gnus-summary-down-thread
1821 "&" gnus-summary-execute-command
1822 "c" gnus-summary-catchup-and-exit
1823 "\C-w" gnus-summary-mark-region-as-read
1824 "\C-t" gnus-summary-toggle-truncation
1825 "?" gnus-summary-mark-as-dormant
1826 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1827 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1828 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1829 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1830 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1831 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1832 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1833 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1834 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1835 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1836 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1837 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1838 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1839 "=" gnus-summary-expand-window
1840 "\C-x\C-s" gnus-summary-reselect-current-group
1841 "\M-g" gnus-summary-rescan-group
1842 "w" gnus-summary-stop-page-breaking
1843 "\C-c\C-r" gnus-summary-caesar-message
1844 "f" gnus-summary-followup
1845 "F" gnus-summary-followup-with-original
1846 "C" gnus-summary-cancel-article
1847 "r" gnus-summary-reply
1848 "R" gnus-summary-reply-with-original
1849 "\C-c\C-f" gnus-summary-mail-forward
1850 "o" gnus-summary-save-article
1851 "\C-o" gnus-summary-save-article-mail
1852 "|" gnus-summary-pipe-output
1853 "\M-k" gnus-summary-edit-local-kill
1854 "\M-K" gnus-summary-edit-global-kill
1856 "\C-c\C-d" gnus-summary-describe-group
1857 "q" gnus-summary-exit
1858 "Q" gnus-summary-exit-no-update
1859 "\C-c\C-i" gnus-info-find-node
1860 gnus-mouse-2 gnus-mouse-pick-article
1861 [follow-link] mouse-face
1862 "m" gnus-summary-mail-other-window
1863 "a" gnus-summary-post-news
1864 "i" gnus-summary-news-other-window
1865 "x" gnus-summary-limit-to-unread
1866 "s" gnus-summary-isearch-article
1867 "t" gnus-summary-toggle-header
1868 "g" gnus-summary-show-article
1869 "l" gnus-summary-goto-last-article
1870 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1871 "\C-d" gnus-summary-enter-digest-group
1872 "\M-\C-d" gnus-summary-read-document
1873 "\M-\C-e" gnus-summary-edit-parameters
1874 "\M-\C-a" gnus-summary-customize-parameters
1876 "*" gnus-cache-enter-article
1877 "\M-*" gnus-cache-remove-article
1878 "\M-&" gnus-summary-universal-argument
1879 "\C-l" gnus-recenter
1880 "I" gnus-summary-increase-score
1881 "L" gnus-summary-lower-score
1882 "\M-i" gnus-symbolic-argument
1883 "h" gnus-summary-select-article-buffer
1885 "b" gnus-article-view-part
1886 "\M-t" gnus-summary-toggle-display-buttonized
1888 "V" gnus-summary-score-map
1889 "X" gnus-uu-extract-map
1890 "S" gnus-summary-send-map)
1892 ;; Sort of orthogonal keymap
1893 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1894 "t" gnus-summary-tick-article-forward
1895 "!" gnus-summary-tick-article-forward
1896 "d" gnus-summary-mark-as-read-forward
1897 "r" gnus-summary-mark-as-read-forward
1898 "c" gnus-summary-clear-mark-forward
1899 " " gnus-summary-clear-mark-forward
1900 "e" gnus-summary-mark-as-expirable
1901 "x" gnus-summary-mark-as-expirable
1902 "?" gnus-summary-mark-as-dormant
1903 "b" gnus-summary-set-bookmark
1904 "B" gnus-summary-remove-bookmark
1905 "#" gnus-summary-mark-as-processable
1906 "\M-#" gnus-summary-unmark-as-processable
1907 "S" gnus-summary-limit-include-expunged
1908 "C" gnus-summary-catchup
1909 "H" gnus-summary-catchup-to-here
1910 "h" gnus-summary-catchup-from-here
1911 "\C-c" gnus-summary-catchup-all
1912 "k" gnus-summary-kill-same-subject-and-select
1913 "K" gnus-summary-kill-same-subject
1914 "P" gnus-uu-mark-map)
1916 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1917 "c" gnus-summary-clear-above
1918 "u" gnus-summary-tick-above
1919 "m" gnus-summary-mark-above
1920 "k" gnus-summary-kill-below)
1922 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1923 "/" gnus-summary-limit-to-subject
1924 "n" gnus-summary-limit-to-articles
1925 "b" gnus-summary-limit-to-bodies
1926 "h" gnus-summary-limit-to-headers
1927 "w" gnus-summary-pop-limit
1928 "s" gnus-summary-limit-to-subject
1929 "a" gnus-summary-limit-to-author
1930 "u" gnus-summary-limit-to-unread
1931 "m" gnus-summary-limit-to-marks
1932 "M" gnus-summary-limit-exclude-marks
1933 "v" gnus-summary-limit-to-score
1934 "*" gnus-summary-limit-include-cached
1935 "D" gnus-summary-limit-include-dormant
1936 "T" gnus-summary-limit-include-thread
1937 "d" gnus-summary-limit-exclude-dormant
1938 "t" gnus-summary-limit-to-age
1939 "." gnus-summary-limit-to-unseen
1940 "x" gnus-summary-limit-to-extra
1941 "p" gnus-summary-limit-to-display-predicate
1942 "E" gnus-summary-limit-include-expunged
1943 "c" gnus-summary-limit-exclude-childless-dormant
1944 "C" gnus-summary-limit-mark-excluded-as-read
1945 "o" gnus-summary-insert-old-articles
1946 "N" gnus-summary-insert-new-articles
1947 "S" gnus-summary-limit-to-singletons
1948 "r" gnus-summary-limit-to-replied
1949 "R" gnus-summary-limit-to-recipient
1950 "A" gnus-summary-limit-to-address)
1952 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1953 "n" gnus-summary-next-unread-article
1954 "p" gnus-summary-prev-unread-article
1955 "N" gnus-summary-next-article
1956 "P" gnus-summary-prev-article
1957 "\C-n" gnus-summary-next-same-subject
1958 "\C-p" gnus-summary-prev-same-subject
1959 "\M-n" gnus-summary-next-unread-subject
1960 "\M-p" gnus-summary-prev-unread-subject
1961 "f" gnus-summary-first-unread-article
1962 "b" gnus-summary-best-unread-article
1963 "j" gnus-summary-goto-article
1964 "g" gnus-summary-goto-subject
1965 "l" gnus-summary-goto-last-article
1966 "o" gnus-summary-pop-article)
1968 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1969 "k" gnus-summary-kill-thread
1970 "E" gnus-summary-expire-thread
1971 "l" gnus-summary-lower-thread
1972 "i" gnus-summary-raise-thread
1973 "T" gnus-summary-toggle-threads
1974 "t" gnus-summary-rethread-current
1975 "^" gnus-summary-reparent-thread
1976 "\M-^" gnus-summary-reparent-children
1977 "s" gnus-summary-show-thread
1978 "S" gnus-summary-show-all-threads
1979 "h" gnus-summary-hide-thread
1980 "H" gnus-summary-hide-all-threads
1981 "n" gnus-summary-next-thread
1982 "p" gnus-summary-prev-thread
1983 "u" gnus-summary-up-thread
1984 "o" gnus-summary-top-thread
1985 "d" gnus-summary-down-thread
1986 "#" gnus-uu-mark-thread
1987 "\M-#" gnus-uu-unmark-thread)
1989 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1990 "g" gnus-summary-prepare
1991 "c" gnus-summary-insert-cached-articles
1992 "d" gnus-summary-insert-dormant-articles
1993 "t" gnus-summary-insert-ticked-articles)
1995 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1996 "c" gnus-summary-catchup-and-exit
1997 "C" gnus-summary-catchup-all-and-exit
1998 "E" gnus-summary-exit-no-update
1999 "Q" gnus-summary-exit
2000 "Z" gnus-summary-exit
2001 "n" gnus-summary-catchup-and-goto-next-group
2002 "p" gnus-summary-catchup-and-goto-prev-group
2003 "R" gnus-summary-reselect-current-group
2004 "G" gnus-summary-rescan-group
2005 "N" gnus-summary-next-group
2006 "s" gnus-summary-save-newsrc
2007 "P" gnus-summary-prev-group)
2009 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2010 " " gnus-summary-next-page
2011 "n" gnus-summary-next-page
2012 "\177" gnus-summary-prev-page
2013 [delete] gnus-summary-prev-page
2014 "p" gnus-summary-prev-page
2015 "\r" gnus-summary-scroll-up
2016 "\M-\r" gnus-summary-scroll-down
2017 "<" gnus-summary-beginning-of-article
2018 ">" gnus-summary-end-of-article
2019 "b" gnus-summary-beginning-of-article
2020 "e" gnus-summary-end-of-article
2021 "^" gnus-summary-refer-parent-article
2022 "r" gnus-summary-refer-parent-article
2023 "D" gnus-summary-enter-digest-group
2024 "R" gnus-summary-refer-references
2025 "T" gnus-summary-refer-thread
2026 "g" gnus-summary-show-article
2027 "s" gnus-summary-isearch-article
2028 "P" gnus-summary-print-article
2029 "S" gnus-sticky-article
2030 "M" gnus-mailing-list-insinuate
2031 "t" gnus-article-babel)
2033 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2034 "b" gnus-article-add-buttons
2035 "B" gnus-article-add-buttons-to-head
2036 "o" gnus-article-treat-overstrike
2037 "e" gnus-article-emphasize
2038 "w" gnus-article-fill-cited-article
2039 "Q" gnus-article-fill-long-lines
2040 "L" gnus-article-toggle-truncate-lines
2041 "C" gnus-article-capitalize-sentences
2042 "c" gnus-article-remove-cr
2043 "q" gnus-article-de-quoted-unreadable
2044 "6" gnus-article-de-base64-unreadable
2045 "Z" gnus-article-decode-HZ
2046 "A" gnus-article-treat-ansi-sequences
2047 "h" gnus-article-wash-html
2048 "u" gnus-article-unsplit-urls
2049 "s" gnus-summary-force-verify-and-decrypt
2050 "f" gnus-article-display-x-face
2051 "l" gnus-summary-stop-page-breaking
2052 "r" gnus-summary-caesar-message
2053 "m" gnus-summary-morse-message
2054 "t" gnus-summary-toggle-header
2055 "g" gnus-treat-smiley
2056 "v" gnus-summary-verbose-headers
2057 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2058 "p" gnus-article-verify-x-pgp-sig
2059 "d" gnus-article-treat-dumbquotes
2060 "i" gnus-summary-idna-message)
2062 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2063 ;; mnemonic: deuglif*Y*
2064 "u" gnus-article-outlook-unwrap-lines
2065 "a" gnus-article-outlook-repair-attribution
2066 "c" gnus-article-outlook-rearrange-citation
2067 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2069 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2070 "a" gnus-article-hide
2071 "h" gnus-article-hide-headers
2072 "b" gnus-article-hide-boring-headers
2073 "s" gnus-article-hide-signature
2074 "c" gnus-article-hide-citation
2075 "C" gnus-article-hide-citation-in-followups
2076 "l" gnus-article-hide-list-identifiers
2077 "B" gnus-article-strip-banner
2078 "P" gnus-article-hide-pem
2079 "\C-c" gnus-article-hide-citation-maybe)
2081 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2082 "a" gnus-article-highlight
2083 "h" gnus-article-highlight-headers
2084 "c" gnus-article-highlight-citation
2085 "s" gnus-article-highlight-signature)
2087 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2088 "f" gnus-article-treat-fold-headers
2089 "u" gnus-article-treat-unfold-headers
2090 "n" gnus-article-treat-fold-newsgroups)
2092 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2093 "x" gnus-article-display-x-face
2094 "d" gnus-article-display-face
2095 "s" gnus-treat-smiley
2096 "D" gnus-article-remove-images
2097 "f" gnus-treat-from-picon
2098 "m" gnus-treat-mail-picon
2099 "n" gnus-treat-newsgroups-picon)
2101 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2102 "w" gnus-article-decode-mime-words
2103 "c" gnus-article-decode-charset
2104 "v" gnus-mime-view-all-parts
2105 "b" gnus-article-view-part)
2107 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2108 "z" gnus-article-date-ut
2109 "u" gnus-article-date-ut
2110 "l" gnus-article-date-local
2111 "p" gnus-article-date-english
2112 "e" gnus-article-date-lapsed
2113 "o" gnus-article-date-original
2114 "i" gnus-article-date-iso8601
2115 "s" gnus-article-date-user)
2117 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2118 "t" gnus-article-remove-trailing-blank-lines
2119 "l" gnus-article-strip-leading-blank-lines
2120 "m" gnus-article-strip-multiple-blank-lines
2121 "a" gnus-article-strip-blank-lines
2122 "A" gnus-article-strip-all-blank-lines
2123 "s" gnus-article-strip-leading-space
2124 "e" gnus-article-strip-trailing-space
2125 "w" gnus-article-remove-leading-whitespace)
2127 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2129 "f" gnus-summary-fetch-faq
2130 "d" gnus-summary-describe-group
2131 "h" gnus-summary-describe-briefly
2132 "i" gnus-info-find-node
2133 "c" gnus-group-fetch-charter
2134 "C" gnus-group-fetch-control)
2136 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2137 "e" gnus-summary-expire-articles
2138 "\M-\C-e" gnus-summary-expire-articles-now
2139 "\177" gnus-summary-delete-article
2140 [delete] gnus-summary-delete-article
2141 [backspace] gnus-summary-delete-article
2142 "m" gnus-summary-move-article
2143 "r" gnus-summary-respool-article
2144 "w" gnus-summary-edit-article
2145 "c" gnus-summary-copy-article
2146 "B" gnus-summary-crosspost-article
2147 "q" gnus-summary-respool-query
2148 "t" gnus-summary-respool-trace
2149 "i" gnus-summary-import-article
2150 "I" gnus-summary-create-article
2151 "p" gnus-summary-article-posted-p)
2153 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2154 "o" gnus-summary-save-article
2155 "m" gnus-summary-save-article-mail
2156 "F" gnus-summary-write-article-file
2157 "r" gnus-summary-save-article-rmail
2158 "f" gnus-summary-save-article-file
2159 "b" gnus-summary-save-article-body-file
2160 "B" gnus-summary-write-article-body-file
2161 "h" gnus-summary-save-article-folder
2162 "v" gnus-summary-save-article-vm
2163 "p" gnus-summary-pipe-output
2164 "P" gnus-summary-muttprint
2165 "s" gnus-soup-add-article)
2167 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2168 "b" gnus-summary-display-buttonized
2169 "m" gnus-summary-repair-multipart
2170 "v" gnus-article-view-part
2171 "o" gnus-article-save-part
2172 "O" gnus-article-save-part-and-strip
2173 "r" gnus-article-replace-part
2174 "d" gnus-article-delete-part
2175 "t" gnus-article-view-part-as-type
2176 "j" gnus-article-jump-to-part
2177 "c" gnus-article-copy-part
2178 "C" gnus-article-view-part-as-charset
2179 "e" gnus-article-view-part-externally
2180 "H" gnus-article-browse-html-article
2181 "E" gnus-article-encrypt-body
2182 "i" gnus-article-inline-part
2183 "|" gnus-article-pipe-part)
2185 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2186 "p" gnus-summary-mark-as-processable
2187 "u" gnus-summary-unmark-as-processable
2188 "U" gnus-summary-unmark-all-processable
2189 "v" gnus-uu-mark-over
2190 "s" gnus-uu-mark-series
2191 "r" gnus-uu-mark-region
2192 "g" gnus-uu-unmark-region
2193 "R" gnus-uu-mark-by-regexp
2194 "G" gnus-uu-unmark-by-regexp
2195 "t" gnus-uu-mark-thread
2196 "T" gnus-uu-unmark-thread
2197 "a" gnus-uu-mark-all
2198 "b" gnus-uu-mark-buffer
2199 "S" gnus-uu-mark-sparse
2200 "k" gnus-summary-kill-process-mark
2201 "y" gnus-summary-yank-process-mark
2202 "w" gnus-summary-save-process-mark
2203 "i" gnus-uu-invert-processable)
2205 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2206 ;;"x" gnus-uu-extract-any
2207 "m" gnus-summary-save-parts
2208 "u" gnus-uu-decode-uu
2209 "U" gnus-uu-decode-uu-and-save
2210 "s" gnus-uu-decode-unshar
2211 "S" gnus-uu-decode-unshar-and-save
2212 "o" gnus-uu-decode-save
2213 "O" gnus-uu-decode-save
2214 "b" gnus-uu-decode-binhex
2215 "B" gnus-uu-decode-binhex
2216 "Y" gnus-uu-decode-yenc
2217 "p" gnus-uu-decode-postscript
2218 "P" gnus-uu-decode-postscript-and-save)
2221 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2222 "u" gnus-uu-decode-uu-view
2223 "U" gnus-uu-decode-uu-and-save-view
2224 "s" gnus-uu-decode-unshar-view
2225 "S" gnus-uu-decode-unshar-and-save-view
2226 "o" gnus-uu-decode-save-view
2227 "O" gnus-uu-decode-save-view
2228 "b" gnus-uu-decode-binhex-view
2229 "B" gnus-uu-decode-binhex-view
2230 "p" gnus-uu-decode-postscript-view
2231 "P" gnus-uu-decode-postscript-and-save-view)
2233 (defvar gnus-article-post-menu nil)
2235 (defconst gnus-summary-menu-maxlen 20)
2237 (defun gnus-summary-menu-split (menu)
2238 ;; If we have lots of elements, divide them into groups of 20
2239 ;; and make a pane (or submenu) for each one.
2240 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2241 (let ((menu menu) sublists next
2244 ;; Pull off the next gnus-summary-menu-maxlen elements
2245 ;; and make them the next element of sublist.
2246 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2248 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2250 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2251 (aref (car (last menu)) 0)) menu)
2255 (nreverse sublists))
2256 ;; Few elements--put them all in one pane.
2259 (defun gnus-summary-make-menu-bar ()
2260 (gnus-turn-off-edit-menu 'summary)
2262 (unless (boundp 'gnus-summary-misc-menu)
2265 gnus-summary-kill-menu gnus-summary-mode-map ""
2270 ["Customize" gnus-score-customize t])
2271 (gnus-make-score-map 'increase)
2272 (gnus-make-score-map 'lower)
2274 ["Kill below" gnus-summary-kill-below t]
2275 ["Mark above" gnus-summary-mark-above t]
2276 ["Tick above" gnus-summary-tick-above t]
2277 ["Clear above" gnus-summary-clear-above t])
2278 ["Current score" gnus-summary-current-score t]
2279 ["Set score" gnus-summary-set-score t]
2280 ["Switch current score file..." gnus-score-change-score-file t]
2281 ["Set mark below..." gnus-score-set-mark-below t]
2282 ["Set expunge below..." gnus-score-set-expunge-below t]
2283 ["Edit current score file" gnus-score-edit-current-scores t]
2284 ["Edit score file..." gnus-score-edit-file t]
2285 ["Trace score" gnus-score-find-trace t]
2286 ["Find words" gnus-score-find-favourite-words t]
2287 ["Rescore buffer" gnus-summary-rescore t]
2288 ["Increase score..." gnus-summary-increase-score t]
2289 ["Lower score..." gnus-summary-lower-score t]))))
2291 ;; Define both the Article menu in the summary buffer and the
2292 ;; equivalent Commands menu in the article buffer here for
2296 ["All" gnus-article-hide t]
2297 ["Headers" gnus-article-hide-headers t]
2298 ["Signature" gnus-article-hide-signature t]
2299 ["Citation" gnus-article-hide-citation t]
2300 ["List identifiers" gnus-article-hide-list-identifiers t]
2301 ["Banner" gnus-article-strip-banner t]
2302 ["Boring headers" gnus-article-hide-boring-headers t])
2304 ["All" gnus-article-highlight t]
2305 ["Headers" gnus-article-highlight-headers t]
2306 ["Signature" gnus-article-highlight-signature t]
2307 ["Citation" gnus-article-highlight-citation t])
2309 ["Words" gnus-article-decode-mime-words t]
2310 ["Charset" gnus-article-decode-charset t]
2311 ["QP" gnus-article-de-quoted-unreadable t]
2312 ["Base64" gnus-article-de-base64-unreadable t]
2313 ["View MIME buttons" gnus-summary-display-buttonized t]
2314 ["View all" gnus-mime-view-all-parts t]
2315 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2316 ["Encrypt body" gnus-article-encrypt-body
2317 :active (not (gnus-group-read-only-p))
2318 ,@(if (featurep 'xemacs) nil
2319 '(:help "Encrypt the message body on disk"))]
2320 ["Extract all parts..." gnus-summary-save-parts t]
2322 ["Repair multipart" gnus-summary-repair-multipart t]
2323 ["Pipe part..." gnus-article-pipe-part t]
2324 ["Inline part" gnus-article-inline-part t]
2325 ["View part as type..." gnus-article-view-part-as-type t]
2326 ["Encrypt body" gnus-article-encrypt-body
2327 :active (not (gnus-group-read-only-p))
2328 ,@(if (featurep 'xemacs) nil
2329 '(:help "Encrypt the message body on disk"))]
2330 ["View part externally" gnus-article-view-part-externally t]
2331 ["View HTML parts in browser" gnus-article-browse-html-article t]
2332 ["View part with charset..." gnus-article-view-part-as-charset t]
2333 ["Copy part" gnus-article-copy-part t]
2334 ["Save part..." gnus-article-save-part t]
2335 ["View part" gnus-article-view-part t]))
2337 ["Local" gnus-article-date-local t]
2338 ["ISO8601" gnus-article-date-iso8601 t]
2339 ["UT" gnus-article-date-ut t]
2340 ["Original" gnus-article-date-original t]
2341 ["Lapsed" gnus-article-date-lapsed t]
2342 ["User-defined" gnus-article-date-user t])
2344 ["Remove images" gnus-article-remove-images t]
2345 ["Toggle smiley" gnus-treat-smiley t]
2346 ["Show X-Face" gnus-article-display-x-face t]
2347 ["Show picons in From" gnus-treat-from-picon t]
2348 ["Show picons in mail headers" gnus-treat-mail-picon t]
2349 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2350 ("View as different encoding"
2351 ,@(gnus-summary-menu-split
2354 ;; Since easymenu under Emacs doesn't allow
2355 ;; lambda forms for menu commands, we should
2356 ;; provide intern'ed function symbols.
2357 (let ((command (intern (format "\
2358 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2362 (let ((gnus-summary-show-article-charset-alist
2364 (gnus-summary-show-article 1))))
2365 `[,(symbol-name cs) ,command t]))
2366 (sort (if (fboundp 'coding-system-list)
2367 (coding-system-list)
2368 (mapcar 'car mm-mime-mule-charset-alist))
2372 ["Leading" gnus-article-strip-leading-blank-lines t]
2373 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2374 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2375 ["All of the above" gnus-article-strip-blank-lines t]
2376 ["All" gnus-article-strip-all-blank-lines t]
2377 ["Leading space" gnus-article-strip-leading-space t]
2378 ["Trailing space" gnus-article-strip-trailing-space t]
2379 ["Leading space in headers"
2380 gnus-article-remove-leading-whitespace t])
2381 ["Overstrike" gnus-article-treat-overstrike t]
2382 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2383 ["Emphasis" gnus-article-emphasize t]
2384 ["Word wrap" gnus-article-fill-cited-article t]
2385 ["Fill long lines" gnus-article-fill-long-lines t]
2386 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2387 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2388 ["Remove CR" gnus-article-remove-cr t]
2389 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2390 ["Base64" gnus-article-de-base64-unreadable t]
2391 ["Rot 13" gnus-summary-caesar-message
2392 ,@(if (featurep 'xemacs) '(t)
2393 '(:help "\"Caesar rotate\" article by 13"))]
2394 ["De-IDNA" gnus-summary-idna-message t]
2395 ["Morse decode" gnus-summary-morse-message t]
2396 ["Unix pipe..." gnus-summary-pipe-message t]
2397 ["Add buttons" gnus-article-add-buttons t]
2398 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2399 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2400 ["Verbose header" gnus-summary-verbose-headers t]
2401 ["Toggle header" gnus-summary-toggle-header t]
2402 ["Unfold headers" gnus-article-treat-unfold-headers t]
2403 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2404 ["Html" gnus-article-wash-html t]
2405 ["Unsplit URLs" gnus-article-unsplit-urls t]
2406 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2407 ["Decode HZ" gnus-article-decode-HZ t]
2408 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2409 ("(Outlook) Deuglify"
2410 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2411 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2412 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2413 ["Full (Outlook) deuglify"
2414 gnus-article-outlook-deuglify-article t])
2417 ["Save in default format..." gnus-summary-save-article
2418 ,@(if (featurep 'xemacs) '(t)
2419 '(:help "Save article using default method"))]
2420 ["Save in file..." gnus-summary-save-article-file
2421 ,@(if (featurep 'xemacs) '(t)
2422 '(:help "Save article in file"))]
2423 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2424 ["Save in MH folder..." gnus-summary-save-article-folder t]
2425 ["Save in VM folder..." gnus-summary-save-article-vm t]
2426 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2427 ["Save body in file..." gnus-summary-save-article-body-file t]
2428 ["Pipe through a filter..." gnus-summary-pipe-output t]
2429 ["Add to SOUP packet" gnus-soup-add-article t]
2430 ["Print with Muttprint..." gnus-summary-muttprint t]
2431 ["Print" gnus-summary-print-article
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Generate and print a PostScript image"))])
2434 ("Copy, move,... (Backend)"
2435 ,@(if (featurep 'xemacs) nil
2436 '(:help "Copying, moving, expiring articles..."))
2437 ["Respool article..." gnus-summary-respool-article t]
2438 ["Move article..." gnus-summary-move-article
2439 (gnus-check-backend-function
2440 'request-move-article gnus-newsgroup-name)]
2441 ["Copy article..." gnus-summary-copy-article t]
2442 ["Crosspost article..." gnus-summary-crosspost-article
2443 (gnus-check-backend-function
2444 'request-replace-article gnus-newsgroup-name)]
2445 ["Import file..." gnus-summary-import-article
2446 (gnus-check-backend-function
2447 'request-accept-article gnus-newsgroup-name)]
2448 ["Create article..." gnus-summary-create-article
2449 (gnus-check-backend-function
2450 'request-accept-article gnus-newsgroup-name)]
2451 ["Check if posted" gnus-summary-article-posted-p t]
2452 ["Edit article" gnus-summary-edit-article
2453 (not (gnus-group-read-only-p))]
2454 ["Delete article" gnus-summary-delete-article
2455 (gnus-check-backend-function
2456 'request-expire-articles gnus-newsgroup-name)]
2457 ["Query respool" gnus-summary-respool-query t]
2458 ["Trace respool" gnus-summary-respool-trace t]
2459 ["Delete expirable articles" gnus-summary-expire-articles-now
2460 (gnus-check-backend-function
2461 'request-expire-articles gnus-newsgroup-name)])
2463 ["Uudecode" gnus-uu-decode-uu
2464 ,@(if (featurep 'xemacs) '(t)
2465 '(:help "Decode uuencoded article(s)"))]
2466 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2467 ["Unshar" gnus-uu-decode-unshar t]
2468 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2469 ["Save" gnus-uu-decode-save t]
2470 ["Binhex" gnus-uu-decode-binhex t]
2471 ["Postscript" gnus-uu-decode-postscript t]
2472 ["All MIME parts" gnus-summary-save-parts t])
2474 ["Enter article" gnus-cache-enter-article t]
2475 ["Remove article" gnus-cache-remove-article t])
2476 ["Translate" gnus-article-babel t]
2477 ["Select article buffer" gnus-summary-select-article-buffer t]
2478 ["Make article buffer sticky" gnus-sticky-article t]
2479 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2480 ["Isearch article..." gnus-summary-isearch-article t]
2481 ["Beginning of the article" gnus-summary-beginning-of-article t]
2482 ["End of the article" gnus-summary-end-of-article t]
2483 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2484 ["Fetch referenced articles" gnus-summary-refer-references t]
2485 ["Fetch current thread" gnus-summary-refer-thread t]
2486 ["Fetch article with id..." gnus-summary-refer-article t]
2487 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2488 ["Redisplay" gnus-summary-show-article t]
2489 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2491 gnus-summary-article-menu gnus-summary-mode-map ""
2492 (cons "Article" innards))
2494 (if (not (keymapp gnus-summary-article-menu))
2496 gnus-article-commands-menu gnus-article-mode-map ""
2497 (cons "Commands" innards))
2498 ;; in Emacs, don't share menu.
2499 (setq gnus-article-commands-menu
2500 (copy-keymap gnus-summary-article-menu))
2501 (define-key gnus-article-mode-map [menu-bar commands]
2502 (cons "Commands" gnus-article-commands-menu))))
2505 gnus-summary-thread-menu gnus-summary-mode-map ""
2507 ["Find all messages in thread" gnus-summary-refer-thread t]
2508 ["Toggle threading" gnus-summary-toggle-threads t]
2509 ["Hide threads" gnus-summary-hide-all-threads t]
2510 ["Show threads" gnus-summary-show-all-threads t]
2511 ["Hide thread" gnus-summary-hide-thread t]
2512 ["Show thread" gnus-summary-show-thread t]
2513 ["Go to next thread" gnus-summary-next-thread t]
2514 ["Go to previous thread" gnus-summary-prev-thread t]
2515 ["Go down thread" gnus-summary-down-thread t]
2516 ["Go up thread" gnus-summary-up-thread t]
2517 ["Top of thread" gnus-summary-top-thread t]
2518 ["Mark thread as read" gnus-summary-kill-thread t]
2519 ["Mark thread as expired" gnus-summary-expire-thread t]
2520 ["Lower thread score" gnus-summary-lower-thread t]
2521 ["Raise thread score" gnus-summary-raise-thread t]
2522 ["Rethread current" gnus-summary-rethread-current t]))
2525 gnus-summary-post-menu gnus-summary-mode-map ""
2527 ["Send a message (mail or news)" gnus-summary-post-news
2528 ,@(if (featurep 'xemacs) '(t)
2529 '(:help "Compose a new message (mail or news)"))]
2530 ["Followup" gnus-summary-followup
2531 ,@(if (featurep 'xemacs) '(t)
2532 '(:help "Post followup to this article"))]
2533 ["Followup and yank" gnus-summary-followup-with-original
2534 ,@(if (featurep 'xemacs) '(t)
2535 '(:help "Post followup to this article, quoting its contents"))]
2536 ["Supersede article" gnus-summary-supersede-article t]
2537 ["Cancel article" gnus-summary-cancel-article
2538 ,@(if (featurep 'xemacs) '(t)
2539 '(:help "Cancel an article you posted"))]
2540 ["Reply" gnus-summary-reply t]
2541 ["Reply and yank" gnus-summary-reply-with-original t]
2542 ["Wide reply" gnus-summary-wide-reply t]
2543 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2544 ,@(if (featurep 'xemacs) '(t)
2545 '(:help "Mail a reply, quoting this article"))]
2546 ["Very wide reply" gnus-summary-very-wide-reply t]
2547 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2548 ,@(if (featurep 'xemacs) '(t)
2549 '(:help "Mail a very wide reply, quoting this article"))]
2550 ["Mail forward" gnus-summary-mail-forward t]
2551 ["Post forward" gnus-summary-post-forward t]
2552 ["Digest and mail" gnus-uu-digest-mail-forward t]
2553 ["Digest and post" gnus-uu-digest-post-forward t]
2554 ["Resend message" gnus-summary-resend-message t]
2555 ["Resend message edit" gnus-summary-resend-message-edit t]
2556 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2557 ["Send a mail" gnus-summary-mail-other-window t]
2558 ["Create a local message" gnus-summary-news-other-window t]
2559 ["Uuencode and post" gnus-uu-post-news
2560 ,@(if (featurep 'xemacs) '(t)
2561 '(:help "Post a uuencoded article"))]
2562 ["Followup via news" gnus-summary-followup-to-mail t]
2563 ["Followup via news and yank"
2564 gnus-summary-followup-to-mail-with-original t]
2565 ["Strip signature on reply"
2568 (if (not (memq message-cite-function
2569 '(message-cite-original-without-signature
2570 message-cite-original)))
2571 ;; Stupid workaround for XEmacs not honoring :visible.
2572 (message "Can't toggle this value of `message-cite-function'")
2573 (setq message-cite-function
2574 (if (eq message-cite-function
2575 'message-cite-original-without-signature)
2576 'message-cite-original
2577 'message-cite-original-without-signature))))
2578 ;; XEmacs barfs on :visible.
2579 ,@(if (featurep 'xemacs) nil
2580 '(:visible (memq message-cite-function
2581 '(message-cite-original-without-signature
2582 message-cite-original))))
2584 :selected (eq message-cite-function
2585 'message-cite-original-without-signature)
2586 ,@(if (featurep 'xemacs) nil
2587 '(:help "Strip signature from cited article when replying."))]
2589 ;;["Send" gnus-summary-send-draft t]
2590 ;;["Send bounced" gnus-resend-bounced-mail t])
2594 ((not (keymapp gnus-summary-post-menu))
2595 (setq gnus-article-post-menu gnus-summary-post-menu))
2596 ((not gnus-article-post-menu)
2597 ;; Don't share post menu.
2598 (setq gnus-article-post-menu
2599 (copy-keymap gnus-summary-post-menu))))
2600 (define-key gnus-article-mode-map [menu-bar post]
2601 (cons "Post" gnus-article-post-menu))
2604 gnus-summary-misc-menu gnus-summary-mode-map ""
2607 ["Mark as read" gnus-summary-mark-as-read-forward t]
2608 ["Mark same subject and select"
2609 gnus-summary-kill-same-subject-and-select t]
2610 ["Mark same subject" gnus-summary-kill-same-subject t]
2611 ["Catchup" gnus-summary-catchup
2612 ,@(if (featurep 'xemacs) '(t)
2613 '(:help "Mark unread articles in this group as read"))]
2614 ["Catchup all" gnus-summary-catchup-all t]
2615 ["Catchup to here" gnus-summary-catchup-to-here t]
2616 ["Catchup from here" gnus-summary-catchup-from-here t]
2617 ["Catchup region" gnus-summary-mark-region-as-read
2618 (gnus-mark-active-p)]
2619 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2621 ["Tick" gnus-summary-tick-article-forward t]
2622 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2623 ["Remove marks" gnus-summary-clear-mark-forward t]
2624 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2625 ["Set bookmark" gnus-summary-set-bookmark t]
2626 ["Remove bookmark" gnus-summary-remove-bookmark t])
2628 ["Important" gnus-registry-set-article-Important-mark t]
2629 ["Not Important" gnus-registry-remove-article-Important-mark t]
2630 ["Work" gnus-registry-set-article-Work-mark t]
2631 ["Not Work" gnus-registry-remove-article-Work-mark t]
2632 ["Later" gnus-registry-set-article-Later-mark t]
2633 ["Not Later" gnus-registry-remove-article-Later-mark t]
2634 ["Personal" gnus-registry-set-article-Personal-mark t]
2635 ["Not Personal" gnus-registry-remove-article-Personal-mark t]
2636 ["To Do" gnus-registry-set-article-To-Do-mark t]
2637 ["Not To Do" gnus-registry-remove-article-To-Do-mark t])
2639 ["Marks..." gnus-summary-limit-to-marks t]
2640 ["Subject..." gnus-summary-limit-to-subject t]
2641 ["Author..." gnus-summary-limit-to-author t]
2642 ["Recipient..." gnus-summary-limit-to-recipient t]
2643 ["Address..." gnus-summary-limit-to-address t]
2644 ["Age..." gnus-summary-limit-to-age t]
2645 ["Extra..." gnus-summary-limit-to-extra t]
2646 ["Score..." gnus-summary-limit-to-score t]
2647 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2648 ["Unread" gnus-summary-limit-to-unread t]
2649 ["Unseen" gnus-summary-limit-to-unseen t]
2650 ["Singletons" gnus-summary-limit-to-singletons t]
2651 ["Replied" gnus-summary-limit-to-replied t]
2652 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2653 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2654 ["Pop limit" gnus-summary-pop-limit t]
2655 ["Show dormant" gnus-summary-limit-include-dormant t]
2656 ["Hide childless dormant"
2657 gnus-summary-limit-exclude-childless-dormant t]
2658 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2659 ["Hide marked" gnus-summary-limit-exclude-marks t]
2660 ["Show expunged" gnus-summary-limit-include-expunged t])
2662 ["Set mark" gnus-summary-mark-as-processable t]
2663 ["Remove mark" gnus-summary-unmark-as-processable t]
2664 ["Remove all marks" gnus-summary-unmark-all-processable t]
2665 ["Invert marks" gnus-uu-invert-processable t]
2666 ["Mark above" gnus-uu-mark-over t]
2667 ["Mark series" gnus-uu-mark-series t]
2668 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2669 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2670 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2671 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2672 ["Mark all" gnus-uu-mark-all t]
2673 ["Mark buffer" gnus-uu-mark-buffer t]
2674 ["Mark sparse" gnus-uu-mark-sparse t]
2675 ["Mark thread" gnus-uu-mark-thread t]
2676 ["Unmark thread" gnus-uu-unmark-thread t]
2677 ("Process Mark Sets"
2678 ["Kill" gnus-summary-kill-process-mark t]
2679 ["Yank" gnus-summary-yank-process-mark
2680 gnus-newsgroup-process-stack]
2681 ["Save" gnus-summary-save-process-mark t]
2682 ["Run command on marked..." gnus-summary-universal-argument t]))
2684 ["Page forward" gnus-summary-next-page
2685 ,@(if (featurep 'xemacs) '(t)
2686 '(:help "Show next page of article"))]
2687 ["Page backward" gnus-summary-prev-page
2688 ,@(if (featurep 'xemacs) '(t)
2689 '(:help "Show previous page of article"))]
2690 ["Line forward" gnus-summary-scroll-up t])
2692 ["Next unread article" gnus-summary-next-unread-article t]
2693 ["Previous unread article" gnus-summary-prev-unread-article t]
2694 ["Next article" gnus-summary-next-article t]
2695 ["Previous article" gnus-summary-prev-article t]
2696 ["Next unread subject" gnus-summary-next-unread-subject t]
2697 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2698 ["Next article same subject" gnus-summary-next-same-subject t]
2699 ["Previous article same subject" gnus-summary-prev-same-subject t]
2700 ["First unread article" gnus-summary-first-unread-article t]
2701 ["Best unread article" gnus-summary-best-unread-article t]
2702 ["Go to subject number..." gnus-summary-goto-subject t]
2703 ["Go to article number..." gnus-summary-goto-article t]
2704 ["Go to the last article" gnus-summary-goto-last-article t]
2705 ["Pop article off history" gnus-summary-pop-article t])
2707 ["Sort by number" gnus-summary-sort-by-number t]
2708 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2709 ["Sort by author" gnus-summary-sort-by-author t]
2710 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2711 ["Sort by subject" gnus-summary-sort-by-subject t]
2712 ["Sort by date" gnus-summary-sort-by-date t]
2713 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2714 ["Sort by score" gnus-summary-sort-by-score t]
2715 ["Sort by lines" gnus-summary-sort-by-lines t]
2716 ["Sort by characters" gnus-summary-sort-by-chars t]
2717 ["Randomize" gnus-summary-sort-by-random t]
2718 ["Original sort" gnus-summary-sort-by-original t])
2720 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2721 ["Describe group" gnus-summary-describe-group t]
2722 ["Fetch charter" gnus-group-fetch-charter
2723 ,@(if (featurep 'xemacs) nil
2724 '(:help "Display the charter of the current group"))]
2725 ["Fetch control message" gnus-group-fetch-control
2726 ,@(if (featurep 'xemacs) nil
2727 '(:help "Display the archived control message for the current group"))]
2728 ["Read manual" gnus-info-find-node t])
2730 ["Pick and read" gnus-pick-mode t]
2731 ["Binary" gnus-binary-mode t])
2733 ["Regenerate" gnus-summary-prepare t]
2734 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2735 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2736 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2737 ["Toggle threading" gnus-summary-toggle-threads t])
2738 ["See old articles" gnus-summary-insert-old-articles t]
2739 ["See new articles" gnus-summary-insert-new-articles t]
2740 ["Filter articles..." gnus-summary-execute-command t]
2741 ["Run command on articles..." gnus-summary-universal-argument t]
2742 ["Search articles forward..." gnus-summary-search-article-forward t]
2743 ["Search articles backward..." gnus-summary-search-article-backward t]
2744 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2745 ["Expand window" gnus-summary-expand-window t]
2746 ["Expire expirable articles" gnus-summary-expire-articles
2747 (gnus-check-backend-function
2748 'request-expire-articles gnus-newsgroup-name)]
2749 ["Edit local kill file" gnus-summary-edit-local-kill t]
2750 ["Edit main kill file" gnus-summary-edit-global-kill t]
2751 ["Edit group parameters" gnus-summary-edit-parameters t]
2752 ["Customize group parameters" gnus-summary-customize-parameters t]
2753 ["Send a bug report" gnus-bug t]
2755 ["Catchup and exit" gnus-summary-catchup-and-exit
2756 ,@(if (featurep 'xemacs) '(t)
2757 '(:help "Mark unread articles in this group as read, then exit"))]
2758 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2759 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2760 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2761 ["Exit group" gnus-summary-exit
2762 ,@(if (featurep 'xemacs) '(t)
2763 '(:help "Exit current group, return to group selection mode"))]
2764 ["Exit group without updating" gnus-summary-exit-no-update t]
2765 ["Exit and goto next group" gnus-summary-next-group t]
2766 ["Exit and goto prev group" gnus-summary-prev-group t]
2767 ["Reselect group" gnus-summary-reselect-current-group t]
2768 ["Rescan group" gnus-summary-rescan-group t]
2769 ["Update dribble" gnus-summary-save-newsrc t])))
2771 (gnus-run-hooks 'gnus-summary-menu-hook)))
2773 (defvar gnus-summary-tool-bar-map nil)
2775 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2776 ;; affect _new_ message buffers. We might add a function that walks thru all
2777 ;; summary-mode buffers and force the update.
2778 (defun gnus-summary-tool-bar-update (&optional symbol value)
2779 "Update summary mode toolbar.
2780 Setter function for custom variables."
2781 (setq-default gnus-summary-tool-bar-map nil)
2783 ;; When used as ":set" function:
2784 (set-default symbol value))
2785 (when (gnus-buffer-live-p gnus-summary-buffer)
2786 (with-current-buffer gnus-summary-buffer
2787 (gnus-summary-make-tool-bar))))
2789 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2790 'gnus-summary-tool-bar-gnome
2791 'gnus-summary-tool-bar-retro)
2792 "Specifies the Gnus summary tool bar.
2794 It can be either a list or a symbol refering to a list. See
2795 `gmm-tool-bar-from-list' for the format of the list. The
2796 default key map is `gnus-summary-mode-map'.
2798 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2799 `gnus-summary-tool-bar-retro'."
2800 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2801 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2802 (repeat :tag "User defined list" gmm-tool-bar-item)
2804 :version "23.1" ;; No Gnus
2805 :initialize 'custom-initialize-default
2806 :set 'gnus-summary-tool-bar-update
2807 :group 'gnus-summary)
2809 (defcustom gnus-summary-tool-bar-gnome
2810 '((gnus-summary-post-news "mail/compose" nil)
2811 (gnus-summary-insert-new-articles "mail/inbox" nil
2812 :visible (or (not gnus-agent)
2814 (gnus-summary-reply-with-original "mail/reply")
2815 (gnus-summary-reply "mail/reply" nil :visible nil)
2816 (gnus-summary-followup-with-original "mail/reply-all")
2817 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2818 (gnus-summary-mail-forward "mail/forward")
2819 (gnus-summary-save-article "mail/save")
2820 (gnus-summary-search-article-forward "search" nil :visible nil)
2821 (gnus-summary-print-article "print")
2822 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2823 ;; Some new commands that may need more suitable icons:
2824 (gnus-summary-save-newsrc "save" nil :visible nil)
2825 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2826 (gnus-summary-prev-article "left-arrow")
2827 (gnus-summary-next-article "right-arrow")
2828 (gnus-summary-next-page "next-page")
2829 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2831 ;; Maybe some sort-by-... could be added:
2832 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2833 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2834 (gnus-summary-mark-as-expirable
2836 :visible (gnus-check-backend-function 'request-expire-articles
2837 gnus-newsgroup-name))
2838 (gnus-summary-mark-as-spam
2840 :visible (and (fboundp 'spam-group-ham-contents-p)
2841 (spam-group-ham-contents-p gnus-newsgroup-name))
2842 :help "Mark as spam")
2843 (gnus-summary-mark-as-read-forward
2845 :visible (and (fboundp 'spam-group-spam-contents-p)
2846 (spam-group-spam-contents-p gnus-newsgroup-name)))
2848 (gnus-summary-exit "exit")
2849 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2850 (gnus-info-find-node "help"))
2851 "List of functions for the summary tool bar (GNOME style).
2853 See `gmm-tool-bar-from-list' for the format of the list."
2854 :type '(repeat gmm-tool-bar-item)
2855 :version "23.1" ;; No Gnus
2856 :initialize 'custom-initialize-default
2857 :set 'gnus-summary-tool-bar-update
2858 :group 'gnus-summary)
2860 (defcustom gnus-summary-tool-bar-retro
2861 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2862 (gnus-summary-next-unread-article "gnus/next-ur")
2863 (gnus-summary-post-news "gnus/post")
2864 (gnus-summary-followup-with-original "gnus/fuwo")
2865 (gnus-summary-followup "gnus/followup")
2866 (gnus-summary-reply-with-original "gnus/reply-wo")
2867 (gnus-summary-reply "gnus/reply")
2868 (gnus-summary-caesar-message "gnus/rot13")
2869 (gnus-uu-decode-uu "gnus/uu-decode")
2870 (gnus-summary-save-article-file "gnus/save-aif")
2871 (gnus-summary-save-article "gnus/save-art")
2872 (gnus-uu-post-news "gnus/uu-post")
2873 (gnus-summary-catchup "gnus/catchup")
2874 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2875 (gnus-summary-exit "gnus/exit-summ")
2876 ;; Some new command that may need more suitable icons:
2877 (gnus-summary-print-article "gnus/print" nil :visible nil)
2878 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2879 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2880 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2881 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2882 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2883 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2885 (gnus-info-find-node "gnus/help" nil :visible nil))
2886 "List of functions for the summary tool bar (retro look).
2888 See `gmm-tool-bar-from-list' for the format of the list."
2889 :type '(repeat gmm-tool-bar-item)
2890 :version "23.1" ;; No Gnus
2891 :initialize 'custom-initialize-default
2892 :set 'gnus-summary-tool-bar-update
2893 :group 'gnus-summary)
2895 (defcustom gnus-summary-tool-bar-zap-list t
2896 "List of icon items from the global tool bar.
2897 These items are not displayed in the Gnus summary mode tool bar.
2899 See `gmm-tool-bar-from-list' for the format of the list."
2900 :type 'gmm-tool-bar-zap-list
2901 :version "23.1" ;; No Gnus
2902 :initialize 'custom-initialize-default
2903 :set 'gnus-summary-tool-bar-update
2904 :group 'gnus-summary)
2906 (defvar image-load-path)
2907 (defvar tool-bar-map)
2909 (defun gnus-summary-make-tool-bar (&optional force)
2910 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2911 When FORCE, rebuild the tool bar."
2912 (when (and (not (featurep 'xemacs))
2913 (boundp 'tool-bar-mode)
2915 (or (not gnus-summary-tool-bar-map) force))
2917 (gmm-image-load-path-for-library "gnus"
2920 (image-load-path (cons (car load-path)
2921 (when (boundp 'image-load-path)
2923 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2924 gnus-summary-tool-bar-zap-list
2925 'gnus-summary-mode-map)))
2927 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2929 (setq gnus-summary-tool-bar-map map))))
2930 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2932 (defun gnus-score-set-default (var value)
2933 "A version of set that updates the GNU Emacs menu-bar."
2935 ;; It is the message that forces the active status to be updated.
2938 (defun gnus-make-score-map (type)
2939 "Make a summary score map of type TYPE."
2942 (let ((headers '(("author" "from" string)
2943 ("subject" "subject" string)
2944 ("article body" "body" string)
2945 ("article head" "head" string)
2946 ("xref" "xref" string)
2947 ("extra header" "extra" string)
2948 ("lines" "lines" number)
2949 ("followups to author" "followup" string)))
2950 (types '((number ("less than" <)
2953 (string ("substring" s)
2957 (perms '(("temporary" (current-time-string))
2965 (if (eq type 'lower)
2970 (setq header (car headers))
2976 (let ((ts (cdr (assoc (nth 2 header) types)))
2992 'gnus-summary-score-entry
2994 (if (or (string= (nth 1 header)
2996 (string= (nth 1 header)
2999 (list 'gnus-summary-header
3001 (list 'quote (nth 1 (car ts)))
3002 (list 'gnus-score-delta-default
3009 (list (nreverse outp))))
3012 (list (nreverse outt))))
3014 (setq headers (cdr headers)))
3015 (list (nreverse outh))))))))
3018 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3022 (defun gnus-summary-mode (&optional group)
3023 "Major mode for reading articles.
3025 All normal editing commands are switched off.
3026 \\<gnus-summary-mode-map>
3027 Each line in this buffer represents one article. To read an
3028 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3029 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3032 You can also post articles and send mail from this buffer. To
3033 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3034 of an article, type `\\[gnus-summary-reply]'.
3036 There are approx. one gazillion commands you can execute in this
3037 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3039 The following commands are available:
3041 \\{gnus-summary-mode-map}"
3043 (kill-all-local-variables)
3044 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3045 (gnus-summary-make-local-variables))
3046 (gnus-summary-make-local-variables)
3047 (setq gnus-newsgroup-name group)
3048 (when (gnus-visual-p 'summary-menu 'menu)
3049 (gnus-summary-make-menu-bar)
3050 (gnus-summary-make-tool-bar))
3051 (gnus-make-thread-indent-array)
3052 (gnus-simplify-mode-line)
3053 (setq major-mode 'gnus-summary-mode)
3054 (setq mode-name "Summary")
3055 (make-local-variable 'minor-mode-alist)
3056 (use-local-map gnus-summary-mode-map)
3057 (buffer-disable-undo)
3058 (setq buffer-read-only t ;Disable modification
3059 show-trailing-whitespace nil)
3060 (setq truncate-lines t)
3061 (setq selective-display t)
3062 (setq selective-display-ellipses t) ;Display `...'
3063 (gnus-summary-set-display-table)
3064 (gnus-set-default-directory)
3065 (make-local-variable 'gnus-summary-line-format)
3066 (make-local-variable 'gnus-summary-line-format-spec)
3067 (make-local-variable 'gnus-summary-dummy-line-format)
3068 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3069 (make-local-variable 'gnus-summary-mark-positions)
3070 (gnus-make-local-hook 'pre-command-hook)
3071 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3072 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3073 (turn-on-gnus-mailing-list-mode)
3074 (mm-enable-multibyte)
3075 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3076 (gnus-update-summary-mark-positions))
3078 (defun gnus-summary-make-local-variables ()
3079 "Make all the local summary buffer variables."
3081 (dolist (local gnus-summary-local-variables)
3084 (if (eq (cdr local) 'global)
3085 ;; Copy the global value of the variable.
3086 (setq global (symbol-value (car local)))
3087 ;; Use the value from the list.
3088 (setq global (eval (cdr local))))
3089 (set (make-local-variable (car local)) global))
3090 ;; Simple nil-valued local variable.
3091 (set (make-local-variable local) nil)))))
3093 (defun gnus-summary-clear-local-variables ()
3094 (let ((locals gnus-summary-local-variables))
3096 (if (consp (car locals))
3097 (and (symbolp (caar locals))
3098 (set (caar locals) nil))
3099 (and (symbolp (car locals))
3100 (set (car locals) nil)))
3101 (setq locals (cdr locals)))))
3103 ;; Summary data functions.
3105 (defmacro gnus-data-number (data)
3108 (defmacro gnus-data-set-number (data number)
3109 `(setcar ,data ,number))
3111 (defmacro gnus-data-mark (data)
3114 (defmacro gnus-data-set-mark (data mark)
3115 `(setcar (nthcdr 1 ,data) ,mark))
3117 (defmacro gnus-data-pos (data)
3120 (defmacro gnus-data-set-pos (data pos)
3121 `(setcar (nthcdr 2 ,data) ,pos))
3123 (defmacro gnus-data-header (data)
3126 (defmacro gnus-data-set-header (data header)
3127 `(setf (nth 3 ,data) ,header))
3129 (defmacro gnus-data-level (data)
3132 (defmacro gnus-data-unread-p (data)
3133 `(= (nth 1 ,data) gnus-unread-mark))
3135 (defmacro gnus-data-read-p (data)
3136 `(/= (nth 1 ,data) gnus-unread-mark))
3138 (defmacro gnus-data-pseudo-p (data)
3139 `(consp (nth 3 ,data)))
3141 (defmacro gnus-data-find (number)
3142 `(assq ,number gnus-newsgroup-data))
3144 (defmacro gnus-data-find-list (number &optional data)
3145 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3146 (memq (assq ,number bdata)
3149 (defmacro gnus-data-make (number mark pos header level)
3150 `(list ,number ,mark ,pos ,header ,level))
3152 (defun gnus-data-enter (after-article number mark pos header level offset)
3153 (let ((data (gnus-data-find-list after-article)))
3155 (error "No such article: %d" after-article))
3156 (setcdr data (cons (gnus-data-make number mark pos header level)
3158 (setq gnus-newsgroup-data-reverse nil)
3159 (gnus-data-update-list (cddr data) offset)))
3161 (defun gnus-data-enter-list (after-article list &optional offset)
3163 (let ((data (and after-article (gnus-data-find-list after-article)))
3167 (let ((odata gnus-newsgroup-data))
3168 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3170 (gnus-data-update-list odata offset)))
3171 ;; Find the last element in the list to be spliced into the main
3173 (setq list (last list))
3176 (setcdr list gnus-newsgroup-data)
3177 (setq gnus-newsgroup-data ilist)
3179 (gnus-data-update-list (cdr list) offset)))
3180 (setcdr list (cdr data))
3183 (gnus-data-update-list (cdr list) offset))))
3184 (setq gnus-newsgroup-data-reverse nil))))
3186 (defun gnus-data-remove (article &optional offset)
3187 (let ((data gnus-newsgroup-data))
3188 (if (= (gnus-data-number (car data)) article)
3190 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3191 gnus-newsgroup-data-reverse nil)
3193 (gnus-data-update-list gnus-newsgroup-data offset)))
3195 (when (= (gnus-data-number (cadr data)) article)
3196 (setcdr data (cddr data))
3198 (gnus-data-update-list (cdr data) offset))
3200 gnus-newsgroup-data-reverse nil))
3201 (setq data (cdr data))))))
3203 (defmacro gnus-data-list (backward)
3205 (or gnus-newsgroup-data-reverse
3206 (setq gnus-newsgroup-data-reverse
3207 (reverse gnus-newsgroup-data)))
3208 gnus-newsgroup-data))
3210 (defun gnus-data-update-list (data offset)
3211 "Add OFFSET to the POS of all data entries in DATA."
3212 (setq gnus-newsgroup-data-reverse nil)
3214 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3215 (setq data (cdr data))))
3217 (defun gnus-summary-article-pseudo-p (article)
3218 "Say whether this article is a pseudo article or not."
3219 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3221 (defmacro gnus-summary-article-sparse-p (article)
3222 "Say whether this article is a sparse article or not."
3223 `(memq ,article gnus-newsgroup-sparse))
3225 (defmacro gnus-summary-article-ancient-p (article)
3226 "Say whether this article is a sparse article or not."
3227 `(memq ,article gnus-newsgroup-ancient))
3229 (defun gnus-article-parent-p (number)
3230 "Say whether this article is a parent or not."
3231 (let ((data (gnus-data-find-list number)))
3232 (and (cdr data) ; There has to be an article after...
3233 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3234 (gnus-data-level (nth 1 data))))))
3236 (defun gnus-article-children (number)
3237 "Return a list of all children to NUMBER."
3238 (let* ((data (gnus-data-find-list number))
3239 (level (gnus-data-level (car data)))
3241 (setq data (cdr data))
3243 (= (gnus-data-level (car data)) (1+ level)))
3244 (push (gnus-data-number (car data)) children)
3245 (setq data (cdr data)))
3248 (defmacro gnus-summary-skip-intangible ()
3249 "If the current article is intangible, then jump to a different article."
3250 '(let ((to (get-text-property (point) 'gnus-intangible)))
3251 (and to (gnus-summary-goto-subject to))))
3253 (defmacro gnus-summary-article-intangible-p ()
3254 "Say whether this article is intangible or not."
3255 '(get-text-property (point) 'gnus-intangible))
3257 (defun gnus-article-read-p (article)
3258 "Say whether ARTICLE is read or not."
3259 (not (or (memq article gnus-newsgroup-marked)
3260 (memq article gnus-newsgroup-spam-marked)
3261 (memq article gnus-newsgroup-unreads)
3262 (memq article gnus-newsgroup-unselected)
3263 (memq article gnus-newsgroup-dormant))))
3265 ;; Some summary mode macros.
3267 (defmacro gnus-summary-article-number ()
3268 "The article number of the article on the current line.
3269 If there isn't an article number here, then we return the current
3272 (gnus-summary-skip-intangible)
3273 (or (get-text-property (point) 'gnus-number)
3274 (gnus-summary-last-subject))))
3276 (defmacro gnus-summary-article-header (&optional number)
3277 "Return the header of article NUMBER."
3278 `(gnus-data-header (gnus-data-find
3279 ,(or number '(gnus-summary-article-number)))))
3281 (defmacro gnus-summary-thread-level (&optional number)
3282 "Return the level of thread that starts with article NUMBER."
3283 `(if (and (eq gnus-summary-make-false-root 'dummy)
3284 (get-text-property (point) 'gnus-intangible))
3286 (gnus-data-level (gnus-data-find
3287 ,(or number '(gnus-summary-article-number))))))
3289 (defmacro gnus-summary-article-mark (&optional number)
3290 "Return the mark of article NUMBER."
3291 `(gnus-data-mark (gnus-data-find
3292 ,(or number '(gnus-summary-article-number)))))
3294 (defmacro gnus-summary-article-pos (&optional number)
3295 "Return the position of the line of article NUMBER."
3296 `(gnus-data-pos (gnus-data-find
3297 ,(or number '(gnus-summary-article-number)))))
3299 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3300 (defmacro gnus-summary-article-subject (&optional number)
3301 "Return current subject string or nil if nothing."
3304 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3305 '(gnus-data-header (assq (gnus-summary-article-number)
3306 gnus-newsgroup-data)))))
3309 (mail-header-subject headers))))
3311 (defmacro gnus-summary-article-score (&optional number)
3312 "Return current article score."
3313 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3314 gnus-newsgroup-scored))
3315 gnus-summary-default-score 0))
3317 (defun gnus-summary-article-children (&optional number)
3318 "Return a list of article numbers that are children of article NUMBER."
3319 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3320 (level (gnus-data-level (car data)))
3322 (while (and (setq data (cdr data))
3323 (> (setq l (gnus-data-level (car data))) level))
3324 (and (= (1+ level) l)
3325 (push (gnus-data-number (car data))
3327 (nreverse children)))
3329 (defun gnus-summary-article-parent (&optional number)
3330 "Return the article number of the parent of article NUMBER."
3331 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3332 (gnus-data-list t)))
3333 (level (gnus-data-level (car data))))
3335 () ; This is a root.
3336 ;; We search until we find an article with a level less than
3337 ;; this one. That function has to be the parent.
3338 (while (and (setq data (cdr data))
3339 (not (< (gnus-data-level (car data)) level))))
3340 (and data (gnus-data-number (car data))))))
3342 (defun gnus-unread-mark-p (mark)
3343 "Say whether MARK is the unread mark."
3344 (= mark gnus-unread-mark))
3346 (defun gnus-read-mark-p (mark)
3347 "Say whether MARK is one of the marks that mark as read.
3348 This is all marks except unread, ticked, dormant, and expirable."
3349 (not (or (= mark gnus-unread-mark)
3350 (= mark gnus-ticked-mark)
3351 (= mark gnus-spam-mark)
3352 (= mark gnus-dormant-mark)
3353 (= mark gnus-expirable-mark))))
3355 (defmacro gnus-article-mark (number)
3356 "Return the MARK of article NUMBER.
3357 This macro should only be used when computing the mark the \"first\"
3358 time; i.e., when generating the summary lines. After that,
3359 `gnus-summary-article-mark' should be used to examine the
3362 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3363 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3364 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3365 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3366 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3367 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3368 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3369 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3370 gnus-ancient-mark))))
3372 ;; Saving hidden threads.
3374 (defmacro gnus-save-hidden-threads (&rest forms)
3375 "Save hidden threads, eval FORMS, and restore the hidden threads."
3376 (let ((config (make-symbol "config")))
3377 `(let ((,config (gnus-hidden-threads-configuration)))
3381 (gnus-restore-hidden-threads-configuration ,config)))))
3382 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3383 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3385 (defun gnus-data-compute-positions ()
3386 "Compute the positions of all articles."
3387 (setq gnus-newsgroup-data-reverse nil)
3388 (let ((data gnus-newsgroup-data))
3390 (gnus-save-hidden-threads
3391 (gnus-summary-show-all-threads)
3392 (goto-char (point-min))
3394 (while (get-text-property (point) 'gnus-intangible)
3396 (gnus-data-set-pos (car data) (+ (point) 3))
3397 (setq data (cdr data))
3398 (forward-line 1))))))
3400 (defun gnus-hidden-threads-configuration ()
3401 "Return the current hidden threads configuration."
3404 (goto-char (point-min))
3405 (while (search-forward "\r" nil t)
3406 (push (1- (point)) config))
3409 (defun gnus-restore-hidden-threads-configuration (config)
3410 "Restore hidden threads configuration from CONFIG."
3412 (let (point (inhibit-read-only t))
3413 (while (setq point (pop config))
3414 (when (and (< point (point-max))
3416 (eq (char-after) ?\n))
3417 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3419 ;; Various summary mode internalish functions.
3421 (defun gnus-mouse-pick-article (e)
3424 (gnus-summary-next-page nil t))
3426 (defun gnus-summary-set-display-table ()
3427 "Change the display table.
3428 Odd characters have a tendency to mess
3429 up nicely formatted displays - we make all possible glyphs
3430 display only a single character."
3432 ;; We start from the standard display table, if any.
3433 (let ((table (or (copy-sequence standard-display-table)
3434 (make-display-table)))
3436 ;; Nix out all the control chars...
3437 (while (>= (setq i (1- i)) 0)
3438 (gnus-put-display-table i [??] table))
3439 ;; ... but not newline and cr, of course. (cr is necessary for the
3440 ;; selective display).
3441 (gnus-put-display-table ?\n nil table)
3442 (gnus-put-display-table ?\r nil table)
3443 ;; We keep TAB as well.
3444 (gnus-put-display-table ?\t nil table)
3445 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3446 ;; Emacs 23 (unicode), that are not set already.
3447 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3450 (while (>= (setq i (1- i)) 127)
3451 ;; Only modify if the entry is nil.
3452 (unless (gnus-get-display-table i table)
3453 (gnus-put-display-table i [??] table))))
3454 (setq buffer-display-table table)))
3456 (defun gnus-summary-set-article-display-arrow (pos)
3457 "Update the overlay arrow to point to line at position POS."
3458 (when (and gnus-summary-display-arrow
3459 (boundp 'overlay-arrow-position)
3460 (boundp 'overlay-arrow-string))
3464 (unless overlay-arrow-position
3465 (setq overlay-arrow-position (make-marker)))
3466 (setq overlay-arrow-string "=>"
3467 overlay-arrow-position (set-marker overlay-arrow-position
3469 (current-buffer))))))
3471 (defun gnus-summary-setup-buffer (group)
3472 "Initialize summary buffer."
3473 (let ((buffer (gnus-summary-buffer-name group))
3474 (dead-name (concat "*Dead Summary "
3475 (gnus-group-decoded-name group) "*")))
3476 ;; If a dead summary buffer exists, we kill it.
3477 (when (gnus-buffer-live-p dead-name)
3478 (gnus-kill-buffer dead-name))
3479 (if (get-buffer buffer)
3482 (setq gnus-summary-buffer (current-buffer))
3483 (not gnus-newsgroup-prepared))
3484 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3485 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3486 (gnus-summary-mode group)
3488 (gnus-carpal-setup-buffer 'summary))
3489 (when (gnus-group-quit-config group)
3490 (set (make-local-variable 'gnus-single-article-buffer) nil))
3491 (make-local-variable 'gnus-article-buffer)
3492 (make-local-variable 'gnus-article-current)
3493 (make-local-variable 'gnus-original-article-buffer)
3494 (setq gnus-newsgroup-name group)
3495 ;; Set any local variables in the group parameters.
3496 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3499 (defun gnus-set-global-variables ()
3500 "Set the global equivalents of the buffer-local variables.
3501 They are set to the latest values they had. These reflect the summary
3502 buffer that was in action when the last article was fetched."
3503 (when (eq major-mode 'gnus-summary-mode)
3504 (setq gnus-summary-buffer (current-buffer))
3505 (let ((name gnus-newsgroup-name)
3506 (marked gnus-newsgroup-marked)
3507 (spam gnus-newsgroup-spam-marked)
3508 (unread gnus-newsgroup-unreads)
3509 (headers gnus-current-headers)
3510 (data gnus-newsgroup-data)
3511 (summary gnus-summary-buffer)
3512 (article-buffer gnus-article-buffer)
3513 (original gnus-original-article-buffer)
3514 (gac gnus-article-current)
3515 (reffed gnus-reffed-article-number)
3516 (score-file gnus-current-score-file)
3517 (default-charset gnus-newsgroup-charset)
3519 (let ((locals gnus-newsgroup-variables))
3521 (if (consp (car locals))
3522 (push (eval (caar locals)) vlist)
3523 (push (eval (car locals)) vlist))
3524 (setq locals (cdr locals)))
3525 (setq vlist (nreverse vlist)))
3526 (with-current-buffer gnus-group-buffer
3527 (setq gnus-newsgroup-name name
3528 gnus-newsgroup-marked marked
3529 gnus-newsgroup-spam-marked spam
3530 gnus-newsgroup-unreads unread
3531 gnus-current-headers headers
3532 gnus-newsgroup-data data
3533 gnus-article-current gac
3534 gnus-summary-buffer summary
3535 gnus-article-buffer article-buffer
3536 gnus-original-article-buffer original
3537 gnus-reffed-article-number reffed
3538 gnus-current-score-file score-file
3539 gnus-newsgroup-charset default-charset)
3540 (let ((locals gnus-newsgroup-variables))
3542 (if (consp (car locals))
3543 (set (caar locals) (pop vlist))
3544 (set (car locals) (pop vlist)))
3545 (setq locals (cdr locals))))
3546 ;; The article buffer also has local variables.
3547 (when (gnus-buffer-live-p gnus-article-buffer)
3548 (set-buffer gnus-article-buffer)
3549 (setq gnus-summary-buffer summary))))))
3551 (defun gnus-summary-article-unread-p (article)
3552 "Say whether ARTICLE is unread or not."
3553 (memq article gnus-newsgroup-unreads))
3555 (defun gnus-summary-first-article-p (&optional article)
3556 "Return whether ARTICLE is the first article in the buffer."
3557 (if (not (setq article (or article (gnus-summary-article-number))))
3559 (eq article (caar gnus-newsgroup-data))))
3561 (defun gnus-summary-last-article-p (&optional article)
3562 "Return whether ARTICLE is the last article in the buffer."
3563 (if (not (setq article (or article (gnus-summary-article-number))))
3564 ;; All non-existent numbers are the last article. :-)
3566 (not (cdr (gnus-data-find-list article)))))
3568 (defun gnus-make-thread-indent-array (&optional n)
3570 (progn (setq n 200) nil)
3571 (null gnus-thread-indent-array)
3572 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3573 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3574 gnus-thread-indent-array-level gnus-thread-indent-level)
3576 (aset gnus-thread-indent-array n
3577 (make-string (* n gnus-thread-indent-level) ? ))
3580 (defun gnus-update-summary-mark-positions ()
3581 "Compute where the summary marks are to go."
3583 (when (gnus-buffer-exists-p gnus-summary-buffer)
3584 (set-buffer gnus-summary-buffer))
3585 (let ((spec gnus-summary-line-format-spec)
3588 (gnus-set-work-buffer)
3589 (let ((gnus-tmp-unread ?Z)
3590 (gnus-replied-mark ?Z)
3591 (gnus-score-below-mark ?Z)
3592 (gnus-score-over-mark ?Z)
3593 (gnus-undownloaded-mark ?Z)
3594 (gnus-summary-line-format-spec spec)
3595 (gnus-newsgroup-downloadable '(0))
3596 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3597 case-fold-search ignores)
3598 ;; Here, all marks are bound to Z.
3599 (gnus-summary-insert-line header
3600 0 nil t gnus-tmp-unread t nil "" nil 1)
3601 (goto-char (point-min))
3602 ;; Memorize the positions of the same characters as dummy marks.
3603 (while (re-search-forward "[A-D]" nil t)
3604 (push (point) ignores))
3606 ;; We use A-D as dummy marks in order to know column positions
3607 ;; where marks should be inserted.
3608 (setq gnus-tmp-unread ?A
3609 gnus-replied-mark ?B
3610 gnus-score-below-mark ?C
3611 gnus-score-over-mark ?C
3612 gnus-undownloaded-mark ?D)
3613 (gnus-summary-insert-line header
3614 0 nil t gnus-tmp-unread t nil "" nil 1)
3615 ;; Ignore characters which aren't dummy marks.
3617 (delete-region (goto-char (1- p)) p)
3619 (goto-char (point-min))
3620 (setq pos (list (cons 'unread
3621 (and (search-forward "A" nil t)
3622 (- (point) (point-min) 1)))))
3623 (goto-char (point-min))
3624 (push (cons 'replied (and (search-forward "B" nil t)
3625 (- (point) (point-min) 1)))
3627 (goto-char (point-min))
3628 (push (cons 'score (and (search-forward "C" nil t)
3629 (- (point) (point-min) 1)))
3631 (goto-char (point-min))
3632 (push (cons 'download (and (search-forward "D" nil t)
3633 (- (point) (point-min) 1)))
3635 (setq gnus-summary-mark-positions pos))))
3637 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3638 "Insert a dummy root in the summary buffer."
3640 (gnus-add-text-properties
3641 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3642 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3644 (defun gnus-summary-extract-address-component (from)
3645 (or (car (funcall gnus-extract-address-components from))
3648 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3649 (let ((mail-parse-charset gnus-newsgroup-charset)
3650 (ignored-from-addresses (gnus-ignored-from-addresses))
3651 ; Is it really necessary to do this next part for each summary line?
3652 ; Luckily, doesn't seem to slow things down much.
3653 (mail-parse-ignored-charsets
3654 (with-current-buffer gnus-summary-buffer
3655 gnus-newsgroup-ignored-charsets)))
3657 (and ignored-from-addresses
3658 (string-match ignored-from-addresses gnus-tmp-from)
3659 (let ((extra-headers (mail-header-extra header))
3663 ((setq to (cdr (assq 'To extra-headers)))
3664 (concat gnus-summary-to-prefix
3666 (gnus-summary-extract-address-component
3667 (funcall gnus-decode-encoded-address-function to)))))
3670 (cdr (assq 'Newsgroups extra-headers))
3672 (memq 'Newsgroups gnus-extra-headers)
3673 (eq (car (gnus-find-method-for-group
3674 gnus-newsgroup-name)) 'nntp)
3675 (gnus-group-real-name gnus-newsgroup-name))))
3676 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3677 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3679 (defun gnus-summary-insert-line (gnus-tmp-header
3680 gnus-tmp-level gnus-tmp-current
3681 undownloaded gnus-tmp-unread gnus-tmp-replied
3682 gnus-tmp-expirable gnus-tmp-subject-or-nil
3683 &optional gnus-tmp-dummy gnus-tmp-score
3685 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3686 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3688 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3689 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3690 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3691 (gnus-tmp-score-char
3692 (if (or (null gnus-summary-default-score)
3693 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3694 gnus-summary-zcore-fuzz))
3696 (if (< gnus-tmp-score gnus-summary-default-score)
3697 gnus-score-below-mark gnus-score-over-mark)))
3698 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3700 (cond (gnus-tmp-process gnus-process-mark)
3701 ((memq gnus-tmp-current gnus-newsgroup-cached)
3703 (gnus-tmp-replied gnus-replied-mark)
3704 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3705 gnus-forwarded-mark)
3706 ((memq gnus-tmp-current gnus-newsgroup-saved)
3708 ((memq gnus-tmp-number gnus-newsgroup-recent)
3710 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3713 (gnus-tmp-downloaded
3715 gnus-undownloaded-mark)
3716 (gnus-newsgroup-agentized
3717 gnus-downloaded-mark)
3720 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3723 ((string-match "<[^>]+> *$" gnus-tmp-from)
3724 (let ((beg (match-beginning 0)))
3725 (or (and (string-match "^\".+\"" gnus-tmp-from)
3726 (substring gnus-tmp-from 1 (1- (match-end 0))))
3727 (substring gnus-tmp-from 0 beg))))
3728 ((string-match "(.+)" gnus-tmp-from)
3729 (substring gnus-tmp-from
3730 (1+ (match-beginning 0)) (1- (match-end 0))))
3732 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3733 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3734 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3735 (inhibit-read-only t))
3736 (when (string= gnus-tmp-name "")
3737 (setq gnus-tmp-name gnus-tmp-from))
3738 (unless (numberp gnus-tmp-lines)
3739 (setq gnus-tmp-lines -1))
3740 (if (= gnus-tmp-lines -1)
3741 (setq gnus-tmp-lines "?")
3742 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3744 (gnus-put-text-property
3746 (progn (eval gnus-summary-line-format-spec) (point))
3747 'gnus-number gnus-tmp-number)
3748 (error (gnus-message 5 "Error updating the summary line")))
3749 (when (gnus-visual-p 'summary-highlight 'highlight)
3751 (gnus-run-hooks 'gnus-summary-update-hook)
3754 (defun gnus-summary-update-line (&optional dont-update)
3755 "Update summary line after change."
3756 (when (and gnus-summary-default-score
3757 (not gnus-summary-inhibit-highlight))
3758 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3759 (article (gnus-summary-article-number))
3760 (score (gnus-summary-article-score article)))
3762 (if (and gnus-summary-mark-below
3763 (< (gnus-summary-article-score)
3764 gnus-summary-mark-below))
3765 ;; This article has a low score, so we mark it as read.
3766 (when (memq article gnus-newsgroup-unreads)
3767 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3768 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3769 ;; This article was previously marked as read on account
3770 ;; of a low score, but now it has risen, so we mark it as
3772 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3773 (gnus-summary-update-mark
3774 (if (or (null gnus-summary-default-score)
3775 (<= (abs (- score gnus-summary-default-score))
3776 gnus-summary-zcore-fuzz))
3778 (if (< score gnus-summary-default-score)
3779 gnus-score-below-mark gnus-score-over-mark))
3781 ;; Do visual highlighting.
3782 (when (gnus-visual-p 'summary-highlight 'highlight)
3783 (gnus-run-hooks 'gnus-summary-update-hook)))))
3785 (defvar gnus-tmp-new-adopts nil)
3787 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3788 "Return the number of articles in THREAD.
3789 This may be 0 in some cases -- if none of the articles in
3790 the thread are to be displayed."
3792 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3794 ((not (listp thread))
3796 ((and (consp thread) (cdr thread))
3799 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3802 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3805 (when (and level (zerop level) gnus-tmp-new-adopts)
3808 'gnus-summary-number-of-articles-in-thread
3809 gnus-tmp-new-adopts))))
3811 (if (> number 1) gnus-not-empty-thread-mark
3812 gnus-empty-thread-mark)
3815 (defsubst gnus-summary-line-message-size (head)
3816 "Return pretty-printed version of message size.
3817 This function is intended to be used in
3818 `gnus-summary-line-format-alist'."
3819 (let ((c (or (mail-header-chars head) -1)))
3820 (cond ((< c 0) "n/a") ; chars not available
3821 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3822 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3823 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3824 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3827 (defun gnus-summary-set-local-parameters (group)
3828 "Go through the local params of GROUP and set all variable specs in that list."
3829 (let ((vars '(quit-config))) ; Ignore quit-config.
3830 (dolist (elem (gnus-group-find-parameter group))
3831 (and (consp elem) ; Has to be a cons.
3832 (consp (cdr elem)) ; The cdr has to be a list.
3833 (symbolp (car elem)) ; Has to be a symbol in there.
3834 (not (memq (car elem) vars))
3835 (ignore-errors ; So we set it.
3836 (push (car elem) vars)
3837 (make-local-variable (car elem))
3838 (set (car elem) (eval (nth 1 elem))))))))
3840 (defun gnus-summary-read-group (group &optional show-all no-article
3841 kill-buffer no-display backward
3843 "Start reading news in newsgroup GROUP.
3844 If SHOW-ALL is non-nil, already read articles are also listed.
3845 If NO-ARTICLE is non-nil, no article is selected initially.
3846 If NO-DISPLAY, don't generate a summary buffer."
3850 (let ((gnus-auto-select-next nil))
3851 (or (gnus-summary-read-group-1
3852 group show-all no-article
3853 kill-buffer no-display
3856 select-articles nil)))))
3857 (eq gnus-auto-select-next 'quietly))
3858 (set-buffer gnus-group-buffer)
3859 ;; The entry function called above goes to the next
3860 ;; group automatically, so we go two groups back
3861 ;; if we are searching for the previous group.
3863 (gnus-group-prev-unread-group 2))
3864 (if (not (equal group (gnus-group-group-name)))
3865 (setq group (gnus-group-group-name))
3869 (defun gnus-summary-read-group-1 (group show-all no-article
3870 kill-buffer no-display
3871 &optional select-articles)
3872 ;; Killed foreign groups can't be entered.
3873 ;; (when (and (not (gnus-group-native-p group))
3874 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3875 ;; (error "Dead non-native groups can't be entered"))
3876 (gnus-message 5 "Retrieving newsgroup: %s..."
3877 (gnus-group-decoded-name group))
3878 (let* ((new-group (gnus-summary-setup-buffer group))
3879 (quit-config (gnus-group-quit-config group))
3880 (did-select (and new-group (gnus-select-newsgroup
3881 group show-all select-articles))))
3883 ;; This summary buffer exists already, so we just select it.
3885 (gnus-set-global-variables)
3887 (gnus-kill-or-deaden-summary kill-buffer))
3888 (gnus-configure-windows 'summary 'force)
3889 (gnus-set-mode-line 'summary)
3890 (gnus-summary-position-point)
3893 ;; We couldn't select this group.
3895 (when (and (eq major-mode 'gnus-summary-mode)
3896 (not (equal (current-buffer) kill-buffer)))
3897 (kill-buffer (current-buffer))
3898 (if (not quit-config)
3900 ;; Update the info -- marks might need to be removed,
3902 (gnus-summary-update-info)
3903 (set-buffer gnus-group-buffer)
3904 (gnus-group-jump-to-group group)
3905 (gnus-group-next-unread-group 1))
3906 (gnus-handle-ephemeral-exit quit-config)))
3907 (let ((grpinfo (gnus-get-info group)))
3908 (if (null (gnus-info-read grpinfo))
3909 (gnus-message 3 "Group %s contains no messages"
3910 (gnus-group-decoded-name group))
3911 (gnus-message 3 "Can't select group")))
3913 ;; The user did a `C-g' while prompting for number of articles,
3914 ;; so we exit this group.
3915 ((eq did-select 'quit)
3916 (and (eq major-mode 'gnus-summary-mode)
3917 (not (equal (current-buffer) kill-buffer))
3918 (kill-buffer (current-buffer)))
3920 (gnus-kill-or-deaden-summary kill-buffer))
3921 (if (not quit-config)
3923 (set-buffer gnus-group-buffer)
3924 (gnus-group-jump-to-group group)
3925 (gnus-group-next-unread-group 1)
3926 (gnus-configure-windows 'group 'force))
3927 (gnus-handle-ephemeral-exit quit-config))
3928 ;; Finally signal the quit.
3930 ;; The group was successfully selected.
3932 (gnus-set-global-variables)
3933 ;; Save the active value in effect when the group was entered.
3934 (setq gnus-newsgroup-active
3936 (gnus-active gnus-newsgroup-name)))
3937 ;; You can change the summary buffer in some way with this hook.
3938 (gnus-run-hooks 'gnus-select-group-hook)
3939 (when (memq 'summary (gnus-update-format-specifications
3940 nil 'summary 'summary-mode 'summary-dummy))
3941 ;; The format specification for the summary line was updated,
3942 ;; so we need to update the mark positions as well.
3943 (gnus-update-summary-mark-positions))
3944 ;; Do score processing.
3945 (when gnus-use-scoring
3946 (gnus-possibly-score-headers))
3947 ;; Check whether to fill in the gaps in the threads.
3948 (when gnus-build-sparse-threads
3949 (gnus-build-sparse-threads))
3950 ;; Find the initial limit.
3952 (let ((gnus-newsgroup-dormant nil))
3953 (gnus-summary-initial-limit show-all))
3954 (gnus-summary-initial-limit show-all))
3955 ;; Generate the summary buffer.
3957 (gnus-summary-prepare))
3958 (when gnus-use-trees
3959 (gnus-tree-open group)
3960 (setq gnus-summary-highlight-line-function
3961 'gnus-tree-highlight-article))
3962 ;; If the summary buffer is empty, but there are some low-scored
3963 ;; articles or some excluded dormants, we include these in the
3965 (when (and (zerop (buffer-size))
3967 (cond (gnus-newsgroup-dormant
3968 (gnus-summary-limit-include-dormant))
3969 ((and gnus-newsgroup-scored show-all)
3970 (gnus-summary-limit-include-expunged t))))
3971 ;; Function `gnus-apply-kill-file' must be called in this hook.
3972 (gnus-run-hooks 'gnus-apply-kill-hook)
3973 (if (and (zerop (buffer-size))
3976 ;; This newsgroup is empty.
3977 (gnus-summary-catchup-and-exit nil t)
3978 (gnus-message 6 "No unread news")
3980 (gnus-kill-or-deaden-summary kill-buffer))
3981 ;; Return nil from this function.
3983 ;; Hide conversation thread subtrees. We cannot do this in
3984 ;; gnus-summary-prepare-hook since kill processing may not
3985 ;; work with hidden articles.
3986 (gnus-summary-maybe-hide-threads)
3988 (gnus-kill-or-deaden-summary kill-buffer))
3989 (gnus-summary-auto-select-subject)
3990 ;; Show first unread article if requested.
3991 (if (and (not no-article)
3993 gnus-newsgroup-unreads
3994 gnus-auto-select-first)
3996 (gnus-configure-windows 'summary)
3997 (let ((art (gnus-summary-article-number)))
3998 (unless (and (not gnus-plugged)
3999 (or (memq art gnus-newsgroup-undownloaded)
4000 (memq art gnus-newsgroup-downloadable)))
4001 (gnus-summary-goto-article art))))
4002 ;; Don't select any articles.
4003 (gnus-summary-position-point)
4004 (gnus-configure-windows 'summary 'force)
4005 (gnus-set-mode-line 'summary))
4006 (when (and gnus-auto-center-group
4007 (get-buffer-window gnus-group-buffer t))
4008 ;; Gotta use windows, because recenter does weird stuff if
4009 ;; the current buffer ain't the displayed window.
4010 (let ((owin (selected-window)))
4011 (select-window (get-buffer-window gnus-group-buffer t))
4012 (when (gnus-group-goto-group group)
4014 (select-window owin)))
4015 ;; Mark this buffer as "prepared".
4016 (setq gnus-newsgroup-prepared t)
4017 (gnus-run-hooks 'gnus-summary-prepared-hook)
4018 (unless (gnus-ephemeral-group-p group)
4019 (gnus-group-update-group group))
4022 (defun gnus-summary-auto-select-subject ()
4023 "Select the subject line on initial group entry."
4024 (goto-char (point-min))
4026 ((eq gnus-auto-select-subject 'best)
4027 (gnus-summary-best-unread-subject))
4028 ((eq gnus-auto-select-subject 'unread)
4029 (gnus-summary-first-unread-subject))
4030 ((eq gnus-auto-select-subject 'unseen)
4031 (gnus-summary-first-unseen-subject))
4032 ((eq gnus-auto-select-subject 'unseen-or-unread)
4033 (gnus-summary-first-unseen-or-unread-subject))
4034 ((eq gnus-auto-select-subject 'first)
4037 ((functionp gnus-auto-select-subject)
4038 (funcall gnus-auto-select-subject))))
4040 (defun gnus-summary-prepare ()
4041 "Generate the summary buffer."
4043 (let ((inhibit-read-only t))
4045 (setq gnus-newsgroup-data nil
4046 gnus-newsgroup-data-reverse nil)
4047 (gnus-run-hooks 'gnus-summary-generate-hook)
4048 ;; Generate the buffer, either with threads or without.
4049 (when gnus-newsgroup-headers
4050 (gnus-summary-prepare-threads
4051 (if gnus-show-threads
4052 (gnus-sort-gathered-threads
4053 (funcall gnus-summary-thread-gathering-function
4055 (gnus-cut-threads (gnus-make-threads)))))
4056 ;; Unthreaded display.
4057 (gnus-sort-articles gnus-newsgroup-headers))))
4058 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4059 ;; Call hooks for modifying summary buffer.
4060 (goto-char (point-min))
4061 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4063 (defsubst gnus-general-simplify-subject (subject)
4064 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4067 ;; Truncate the subject.
4068 (gnus-simplify-subject-functions
4069 (gnus-map-function gnus-simplify-subject-functions subject))
4070 ((numberp gnus-summary-gather-subject-limit)
4071 (setq subject (gnus-simplify-subject-re subject))
4072 (if (> (length subject) gnus-summary-gather-subject-limit)
4073 (substring subject 0 gnus-summary-gather-subject-limit)
4075 ;; Fuzzily simplify it.
4076 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4077 (gnus-simplify-subject-fuzzy subject))
4078 ;; Just remove the leading "Re:".
4080 (gnus-simplify-subject-re subject))))
4082 (if (and gnus-summary-gather-exclude-subject
4083 (string-match gnus-summary-gather-exclude-subject subject))
4084 nil ; This article shouldn't be gathered
4087 (defun gnus-summary-simplify-subject-query ()
4088 "Query where the respool algorithm would put this article."
4090 (gnus-summary-select-article)
4091 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4093 (defun gnus-gather-threads-by-subject (threads)
4094 "Gather threads by looking at Subject headers."
4095 (if (not gnus-summary-make-false-root)
4097 (let ((hashtb (gnus-make-hashtable 1024))
4100 subject hthread whole-subject)
4102 (setq subject (gnus-general-simplify-subject
4103 (setq whole-subject (mail-header-subject
4106 (if (setq hthread (gnus-gethash subject hashtb))
4108 ;; We enter a dummy root into the thread, if we
4109 ;; haven't done that already.
4110 (unless (stringp (caar hthread))
4111 (setcar hthread (list whole-subject (car hthread))))
4112 ;; We add this new gathered thread to this gathered
4114 (setcdr (car hthread)
4115 (nconc (cdar hthread) (list (car threads))))
4116 ;; Remove it from the list of threads.
4117 (setcdr prev (cdr threads))
4118 (setq threads prev))
4119 ;; Enter this thread into the hash table.
4120 (gnus-sethash subject
4121 (if gnus-summary-make-false-root-always
4123 ;; If you want a dummy root above all
4125 (setcar threads (list whole-subject
4131 (setq threads (cdr threads)))
4134 (defun gnus-gather-threads-by-references (threads)
4135 "Gather threads by looking at References headers."
4136 (let ((idhashtb (gnus-make-hashtable 1024))
4137 (thhashtb (gnus-make-hashtable 1024))
4140 ids references id gthread gid entered ref)
4142 (when (setq references (mail-header-references (caar threads)))
4143 (setq id (mail-header-id (caar threads))
4144 ids (inline (gnus-split-references references))
4146 (while (setq ref (pop ids))
4147 (setq ids (delete ref ids))
4148 (if (not (setq gid (gnus-gethash ref idhashtb)))
4150 (gnus-sethash ref id idhashtb)
4151 (gnus-sethash id threads thhashtb))
4152 (setq gthread (gnus-gethash gid thhashtb))
4154 ;; We enter a dummy root into the thread, if we
4155 ;; haven't done that already.
4156 (unless (stringp (caar gthread))
4157 (setcar gthread (list (mail-header-subject (caar gthread))
4159 ;; We add this new gathered thread to this gathered
4161 (setcdr (car gthread)
4162 (nconc (cdar gthread) (list (car threads)))))
4163 ;; Add it into the thread hash table.
4164 (gnus-sethash id gthread thhashtb)
4166 ;; Remove it from the list of threads.
4167 (setcdr prev (cdr threads))
4168 (setq threads prev))))
4170 (setq threads (cdr threads)))
4173 (defun gnus-sort-gathered-threads (threads)
4174 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4175 (let ((result threads))
4177 (when (stringp (caar threads))
4178 (setcdr (car threads)
4179 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4180 (setq threads (cdr threads)))
4183 (defun gnus-thread-loop-p (root thread)
4184 "Say whether ROOT is in THREAD."
4185 (let ((stack (list thread))
4188 (while (setq thread (pop stack))
4189 (setq th (cdr thread))
4191 (not (eq (caar th) root)))
4194 ;; We have found a loop.
4196 (setcdr thread (delq (car th) (cdr thread)))
4197 (if (boundp (setq ref-dep (intern "none"
4198 gnus-newsgroup-dependencies)))
4199 (setcdr (symbol-value ref-dep)
4200 (nconc (cdr (symbol-value ref-dep))
4202 (set ref-dep (list nil (car th))))
4205 ;; Push all the subthreads onto the stack.
4206 (push (cdr thread) stack)))
4209 (defun gnus-make-threads ()
4210 "Go through the dependency hashtb and find the roots. Return all threads."
4212 (while (catch 'infloop
4215 ;; Deal with self-referencing References loops.
4216 (when (and (car (symbol-value refs))
4223 (car (symbol-value refs)) thread))
4224 (cdr (symbol-value refs)))))))
4227 (unless (car (symbol-value refs))
4228 ;; These threads do not refer back to any other
4229 ;; articles, so they're roots.
4230 (setq threads (append (cdr (symbol-value refs)) threads))))
4231 gnus-newsgroup-dependencies)))
4234 ;; Build the thread tree.
4235 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4236 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4238 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4239 if it was already present.
4241 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4242 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4243 Message-IDs will be renamed to a unique Message-ID before being
4246 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4247 (let* ((id (mail-header-id header))
4248 (id-dep (and id (intern id dependencies)))
4249 parent-id ref ref-dep ref-header replaced)
4250 ;; Enter this `header' in the `dependencies' table.
4254 ;; The first two cases do the normal part: enter a new `header'
4255 ;; in the `dependencies' table.
4256 ((not (boundp id-dep))
4257 (set id-dep (list header)))
4258 ((null (car (symbol-value id-dep)))
4259 (setcar (symbol-value id-dep) header))
4261 ;; From here the `header' was already present in the
4262 ;; `dependencies' table.
4264 ;; Overrides an existing entry;
4265 ;; just set the header part of the entry.
4266 (setcar (symbol-value id-dep) header)
4269 ;; Renames the existing `header' to a unique Message-ID.
4270 ((not gnus-summary-ignore-duplicates)
4271 ;; An article with this Message-ID has already been seen.
4272 ;; We rename the Message-ID.
4273 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4275 (mail-header-set-id header id))
4277 ;; The last case ignores an existing entry, except it adds any
4278 ;; additional Xrefs (in case the two articles came from different
4280 ;; Also sets `header' to `nil' meaning that the `dependencies'
4281 ;; table was *not* modified.
4283 (mail-header-set-xref
4284 (car (symbol-value id-dep))
4285 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4287 (or (mail-header-xref header) "")))
4290 (when (and header (not replaced))
4291 ;; First check that we are not creating a References loop.
4292 (setq parent-id (gnus-parent-id (mail-header-references header)))
4293 (setq ref parent-id)
4295 (setq ref-dep (intern-soft ref dependencies))
4297 (setq ref-header (car (symbol-value ref-dep))))
4298 (if (string= id ref)
4299 ;; Yuk! This is a reference loop. Make the article be a
4302 (mail-header-set-references (car (symbol-value id-dep)) "none")
4304 (setq parent-id nil))
4305 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4306 (setq ref-dep (intern (or parent-id "none") dependencies))
4307 (if (boundp ref-dep)
4308 (setcdr (symbol-value ref-dep)
4309 (nconc (cdr (symbol-value ref-dep))
4310 (list (symbol-value id-dep))))
4311 (set ref-dep (list nil (symbol-value id-dep)))))
4314 (defun gnus-extract-message-id-from-in-reply-to (string)
4315 (if (string-match "<[^>]+>" string)
4316 (substring string (match-beginning 0) (match-end 0))
4319 (defun gnus-build-sparse-threads ()
4320 (let ((headers gnus-newsgroup-headers)
4321 (mail-parse-charset gnus-newsgroup-charset)
4322 (gnus-summary-ignore-duplicates t)
4323 header references generation relations
4324 subject child end new-child date)
4325 ;; First we create an alist of generations/relations, where
4326 ;; generations is how much we trust the relation, and the relation
4328 (gnus-message 7 "Making sparse threads...")
4330 (nnheader-set-temp-buffer " *gnus sparse threads*")
4331 (while (setq header (pop headers))
4332 (when (and (setq references (mail-header-references header))
4333 (not (string= references "")))
4335 (setq child (mail-header-id header)
4336 subject (mail-header-subject header)
4337 date (mail-header-date header)
4339 (while (search-backward ">" nil t)
4340 (setq end (1+ (point)))
4341 (when (search-backward "<" nil t)
4342 (setq new-child (buffer-substring (point) end))
4343 (push (list (incf generation)
4344 child (setq child new-child)
4348 (push (list (1+ generation) child nil subject) relations))
4350 (kill-buffer (current-buffer)))
4351 ;; Sort over trustworthiness.
4352 (dolist (relation (sort relations 'car-less-than-car))
4353 (when (gnus-dependencies-add-header
4354 (make-full-mail-header
4355 gnus-reffed-article-number
4356 (nth 3 relation) "" (or (nth 4 relation) "")
4358 (or (nth 2 relation) "") 0 0 "")
4359 gnus-newsgroup-dependencies nil)
4360 (push gnus-reffed-article-number gnus-newsgroup-limit)
4361 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4362 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4363 gnus-newsgroup-reads)
4364 (decf gnus-reffed-article-number)))
4365 (gnus-message 7 "Making sparse threads...done")))
4367 (defun gnus-build-old-threads ()
4368 ;; Look at all the articles that refer back to old articles, and
4369 ;; fetch the headers for the articles that aren't there. This will
4370 ;; build complete threads - if the roots haven't been expired by the
4372 (let ((mail-parse-charset gnus-newsgroup-charset)
4376 (when (not (car (symbol-value refs)))
4377 (setq heads (cdr (symbol-value refs)))
4379 (if (memq (mail-header-number (caar heads))
4380 gnus-newsgroup-dormant)
4381 (setq heads (cdr heads))
4382 (setq id (symbol-name refs))
4383 (while (and (setq id (gnus-build-get-header id))
4384 (not (car (gnus-id-to-thread id)))))
4385 (setq heads nil)))))
4386 gnus-newsgroup-dependencies)))
4388 (defsubst gnus-remove-odd-characters (string)
4389 "Translate STRING into something that doesn't contain weird characters."
4390 (mm-subst-char-in-string
4392 (mm-subst-char-in-string ?\n ?\- string t) t))
4394 ;; This function has to be called with point after the article number
4395 ;; on the beginning of the line.
4396 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4397 (let ((eol (point-at-eol))
4398 (buffer (current-buffer))
4399 header references in-reply-to)
4401 ;; overview: [num subject from date id refs chars lines misc]
4404 (narrow-to-region (point) eol)
4409 (make-full-mail-header
4411 (condition-case () ; subject
4412 (gnus-remove-odd-characters
4413 (funcall gnus-decode-encoded-word-function
4414 (setq x (nnheader-nov-field))))
4416 (condition-case () ; from
4417 (gnus-remove-odd-characters
4418 (funcall gnus-decode-encoded-address-function
4419 (setq x (nnheader-nov-field))))
4421 (nnheader-nov-field) ; date
4422 (nnheader-nov-read-message-id number) ; id
4423 (setq references (nnheader-nov-field)) ; refs
4424 (nnheader-nov-read-integer) ; chars
4425 (nnheader-nov-read-integer) ; lines
4427 (if (looking-at "Xref: ")
4428 (goto-char (match-end 0)))
4429 (nnheader-nov-field)) ; Xref
4430 (nnheader-nov-parse-extra)))) ; extra
4434 (when (and (string= references "")
4435 (setq in-reply-to (mail-header-extra header))
4436 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4437 (mail-header-set-references
4438 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4440 (when gnus-alter-header-function
4441 (funcall gnus-alter-header-function header))
4442 (gnus-dependencies-add-header header dependencies force-new)))
4444 (defun gnus-build-get-header (id)
4445 "Look through the buffer of NOV lines and find the header to ID.
4446 Enter this line into the dependencies hash table, and return
4447 the id of the parent article (if any)."
4448 (let ((deps gnus-newsgroup-dependencies)
4451 (with-current-buffer nntp-server-buffer
4452 (let ((case-fold-search nil))
4453 (goto-char (point-min))
4454 (while (and (not found)
4455 (search-forward id nil t))
4457 (setq found (looking-at
4458 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4459 (regexp-quote id))))
4460 (or found (beginning-of-line 2)))
4464 (setq header (gnus-nov-parse-line
4465 (read (current-buffer)) deps))
4466 (gnus-parent-id (mail-header-references header))))))
4468 (let ((number (mail-header-number header)))
4469 (push number gnus-newsgroup-limit)
4470 (push header gnus-newsgroup-headers)
4471 (if (memq number gnus-newsgroup-unselected)
4473 (setq gnus-newsgroup-unreads
4474 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4476 (setq gnus-newsgroup-unselected
4477 (delq number gnus-newsgroup-unselected)))
4478 (push number gnus-newsgroup-ancient)))))))
4480 (defun gnus-build-all-threads ()
4481 "Read all the headers."
4482 (let ((gnus-summary-ignore-duplicates t)
4483 (mail-parse-charset gnus-newsgroup-charset)
4484 (dependencies gnus-newsgroup-dependencies)
4486 (with-current-buffer nntp-server-buffer
4487 (let ((case-fold-search nil))
4488 (goto-char (point-min))
4491 (setq article (read (current-buffer))
4492 header (gnus-nov-parse-line article dependencies)))
4494 (with-current-buffer gnus-summary-buffer
4495 (push header gnus-newsgroup-headers)
4496 (if (memq (setq article (mail-header-number header))
4497 gnus-newsgroup-unselected)
4499 (setq gnus-newsgroup-unreads
4500 (gnus-add-to-sorted-list
4501 gnus-newsgroup-unreads article))
4502 (setq gnus-newsgroup-unselected
4503 (delq article gnus-newsgroup-unselected)))
4504 (push article gnus-newsgroup-ancient)))
4505 (forward-line 1)))))))
4507 (defun gnus-summary-update-article-line (article header)
4508 "Update the line for ARTICLE using HEADER."
4509 (let* ((id (mail-header-id header))
4510 (thread (gnus-id-to-thread id)))
4512 (error "Article in no thread"))
4513 ;; Update the thread.
4514 (setcar thread header)
4515 (gnus-summary-goto-subject article)
4516 (let* ((datal (gnus-data-find-list article))
4518 (inhibit-read-only t)
4519 (level (gnus-summary-thread-level)))
4521 (let ((inserted (- (point)
4523 (gnus-summary-insert-line
4525 (memq article gnus-newsgroup-undownloaded)
4526 (gnus-article-mark article)
4527 (memq article gnus-newsgroup-replied)
4528 (memq article gnus-newsgroup-expirable)
4529 ;; Only insert the Subject string when it's different
4530 ;; from the previous Subject string.
4535 (mail-header-subject
4538 (gnus-data-find-list
4540 (gnus-data-list t)))))
4541 ;; Error on the side of excessive subjects.
4543 (mail-header-subject header)))
4545 (mail-header-subject header))
4546 nil (cdr (assq article gnus-newsgroup-scored))
4547 (memq article gnus-newsgroup-processable))
4550 (gnus-data-update-list
4552 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4554 (defun gnus-summary-update-article (article &optional iheader)
4555 "Update ARTICLE in the summary buffer."
4556 (set-buffer gnus-summary-buffer)
4557 (let* ((header (gnus-summary-article-header article))
4558 (id (mail-header-id header))
4559 (data (gnus-data-find article))
4560 (thread (gnus-id-to-thread id))
4561 (references (mail-header-references header))
4565 (when (and references
4566 (not (equal "" references)))
4569 (inhibit-read-only t)
4575 (delq thread parent)))
4576 (if (gnus-summary-insert-subject id header)
4577 ;; Set the (possibly) new article number in the data structure.
4578 (gnus-data-set-number data (gnus-id-to-article id))
4582 (defun gnus-rebuild-thread (id &optional line)
4583 "Rebuild the thread containing ID.
4584 If LINE, insert the rebuilt thread starting on line LINE."
4585 (let ((inhibit-read-only t)
4586 old-pos current thread data)
4587 (if (not gnus-show-threads)
4588 (setq thread (list (car (gnus-id-to-thread id))))
4589 ;; Get the thread this article is part of.
4590 (setq thread (gnus-remove-thread id)))
4591 (setq old-pos (point-at-bol))
4592 (setq current (save-excursion
4593 (and (re-search-backward "[\r\n]" nil t)
4594 (gnus-summary-article-number))))
4595 ;; If this is a gathered thread, we have to go some re-gathering.
4596 (when (stringp (car thread))
4597 (let ((subject (car thread))
4599 (setq thread (cdr thread))
4601 (unless (memq (setq thr (gnus-id-to-thread
4603 (mail-header-id (caar thread)))))
4606 (setq thread (cdr thread)))
4607 ;; We now have all (unique) roots.
4608 (if (= (length roots) 1)
4609 ;; All the loose roots are now one solid root.
4610 (setq thread (car roots))
4611 (setq thread (cons subject (gnus-sort-threads roots))))))
4613 ;; We then insert this thread into the summary buffer.
4615 (goto-char (point-min))
4616 (forward-line (1- line)))
4617 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4618 (if gnus-show-threads
4619 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4620 (gnus-summary-prepare-unthreaded thread))
4621 (setq data (nreverse gnus-newsgroup-data))
4622 (setq threads gnus-newsgroup-threads))
4623 ;; We splice the new data into the data structure.
4624 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4625 ;;!!! then we want to insert at the beginning of the buffer.
4626 ;;!!! That happens to be true with Gnus now, but that may
4627 ;;!!! change in the future. Perhaps.
4628 (gnus-data-enter-list
4629 (if line nil current) data (- (point) old-pos))
4630 (setq gnus-newsgroup-threads
4631 (nconc threads gnus-newsgroup-threads))
4632 (gnus-data-compute-positions))))
4634 (defun gnus-number-to-header (number)
4635 "Return the header for article NUMBER."
4636 (let ((headers gnus-newsgroup-headers))
4638 (not (= number (mail-header-number (car headers)))))
4643 (defun gnus-parent-headers (in-headers &optional generation)
4644 "Return the headers of the GENERATIONeth parent of HEADERS."
4646 (setq generation 1))
4648 (headers in-headers)
4651 (not (zerop generation))
4652 (setq references (mail-header-references headers)))
4653 (setq headers (if (and references
4654 (setq parent (gnus-parent-id references)))
4655 (car (gnus-id-to-thread parent))
4658 (and (not (eq headers in-headers))
4661 (defun gnus-id-to-thread (id)
4662 "Return the (sub-)thread where ID appears."
4663 (gnus-gethash id gnus-newsgroup-dependencies))
4665 (defun gnus-id-to-article (id)
4666 "Return the article number of ID."
4667 (let ((thread (gnus-id-to-thread id)))
4670 (mail-header-number (car thread)))))
4672 (defun gnus-id-to-header (id)
4673 "Return the article headers of ID."
4674 (car (gnus-id-to-thread id)))
4676 (defun gnus-article-displayed-root-p (article)
4677 "Say whether ARTICLE is a root(ish) article."
4678 (let ((level (gnus-summary-thread-level article))
4679 (refs (mail-header-references (gnus-summary-article-header article)))
4685 ((null (gnus-parent-id refs)) t)
4687 (null (setq particle (gnus-id-to-article
4688 (gnus-parent-id refs))))
4689 (null (gnus-summary-thread-level particle)))))))
4691 (defun gnus-root-id (id)
4692 "Return the id of the root of the thread where ID appears."
4694 (while (and id (setq prev (car (gnus-id-to-thread id))))
4696 id (gnus-parent-id (mail-header-references prev))))
4699 (defun gnus-articles-in-thread (thread)
4700 "Return the list of articles in THREAD."
4701 (cons (mail-header-number (car thread))
4702 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4704 (defun gnus-remove-thread (id &optional dont-remove)
4705 "Remove the thread that has ID in it."
4706 (let (headers thread last-id)
4707 ;; First go up in this thread until we find the root.
4708 (setq last-id (gnus-root-id id)
4709 headers (message-flatten-list (gnus-id-to-thread last-id)))
4710 ;; We have now found the real root of this thread. It might have
4711 ;; been gathered into some loose thread, so we have to search
4712 ;; through the threads to find the thread we wanted.
4713 (let ((threads gnus-newsgroup-threads)
4716 (setq sub (car threads))
4717 (if (stringp (car sub))
4718 ;; This is a gathered thread, so we look at the roots
4719 ;; below it to find whether this article is in this
4722 (setq sub (cdr sub))
4724 (when (member (caar sub) headers)
4725 (setq thread (car threads)
4728 (setq sub (cdr sub))))
4729 ;; It's an ordinary thread, so we check it.
4730 (when (eq (car sub) (car headers))
4733 (setq threads (cdr threads)))
4734 ;; If this article is in no thread, then it's a root.
4737 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4738 (setq thread (gnus-id-to-thread last-id)))
4741 thread ; We return this thread.
4743 (if (stringp (car thread))
4745 ;; If we use dummy roots, then we have to remove the
4746 ;; dummy root as well.
4747 (when (eq gnus-summary-make-false-root 'dummy)
4748 ;; We go to the dummy root by going to
4749 ;; the first sub-"thread", and then one line up.
4750 (gnus-summary-goto-article
4751 (mail-header-number (caadr thread)))
4754 (gnus-data-compute-positions))
4755 (setq thread (cdr thread))
4757 (gnus-remove-thread-1 (car thread))
4758 (setq thread (cdr thread))))
4759 (gnus-remove-thread-1 thread))))))))
4761 (defun gnus-remove-thread-1 (thread)
4762 "Remove the thread THREAD recursively."
4763 (let ((number (mail-header-number (pop thread)))
4765 (setq thread (reverse thread))
4767 (gnus-remove-thread-1 (pop thread)))
4768 (when (setq d (gnus-data-find number))
4769 (goto-char (gnus-data-pos d))
4770 (gnus-summary-show-thread)
4776 (gnus-delete-line)))))))
4778 (defun gnus-sort-threads-recursive (threads func)
4779 (sort (mapcar (lambda (thread)
4782 (gnus-sort-threads-recursive (cdr thread) func))))
4785 (defun gnus-sort-threads-loop (threads func)
4786 (let* ((superthread (cons nil threads))
4787 (stack (list (cons superthread threads)))
4788 remaining-threads thread)
4790 (setq remaining-threads (cdr (car stack)))
4791 (if remaining-threads
4792 (progn (setq thread (car remaining-threads))
4793 (setcdr (car stack) (cdr remaining-threads))
4795 (push (cons thread (cdr thread)) stack)))
4796 (setq thread (caar stack))
4797 (setcdr thread (sort (cdr thread) func))
4801 (defun gnus-sort-threads (threads)
4803 (if (not gnus-thread-sort-functions)
4805 (gnus-message 8 "Sorting threads...")
4808 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4809 (gnus-sort-threads-recursive
4810 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4811 ;; Even after binding max-lisp-eval-depth, the recursive
4812 ;; sorter might fail for very long threads. In that case,
4813 ;; try using a (less well-tested) non-recursive sorter.
4814 (error (gnus-sort-threads-loop
4815 threads (gnus-make-sort-function
4816 gnus-thread-sort-functions))))
4817 (gnus-message 8 "Sorting threads...done"))))
4819 (defun gnus-sort-articles (articles)
4821 (when gnus-article-sort-functions
4822 (gnus-message 7 "Sorting articles...")
4824 (setq gnus-newsgroup-headers
4825 (sort articles (gnus-make-sort-function
4826 gnus-article-sort-functions)))
4827 (gnus-message 7 "Sorting articles...done"))))
4829 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4830 (defmacro gnus-thread-header (thread)
4831 "Return header of first article in THREAD.
4832 Note that THREAD must never, ever be anything else than a variable -
4833 using some other form will lead to serious barfage."
4834 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4835 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4836 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4839 (defsubst gnus-article-sort-by-number (h1 h2)
4840 "Sort articles by article number."
4841 (< (mail-header-number h1)
4842 (mail-header-number h2)))
4844 (defun gnus-thread-sort-by-number (h1 h2)
4845 "Sort threads by root article number."
4846 (gnus-article-sort-by-number
4847 (gnus-thread-header h1) (gnus-thread-header h2)))
4849 (defsubst gnus-article-sort-by-random (h1 h2)
4850 "Sort articles randomly."
4853 (defun gnus-thread-sort-by-random (h1 h2)
4854 "Sort threads randomly."
4855 (gnus-article-sort-by-random
4856 (gnus-thread-header h1) (gnus-thread-header h2)))
4858 (defsubst gnus-article-sort-by-lines (h1 h2)
4859 "Sort articles by article Lines header."
4860 (< (mail-header-lines h1)
4861 (mail-header-lines h2)))
4863 (defun gnus-thread-sort-by-lines (h1 h2)
4864 "Sort threads by root article Lines header."
4865 (gnus-article-sort-by-lines
4866 (gnus-thread-header h1) (gnus-thread-header h2)))
4868 (defsubst gnus-article-sort-by-chars (h1 h2)
4869 "Sort articles by octet length."
4870 (< (mail-header-chars h1)
4871 (mail-header-chars h2)))
4873 (defun gnus-thread-sort-by-chars (h1 h2)
4874 "Sort threads by root article octet length."
4875 (gnus-article-sort-by-chars
4876 (gnus-thread-header h1) (gnus-thread-header h2)))
4878 (defsubst gnus-article-sort-by-author (h1 h2)
4879 "Sort articles by root author."
4881 (let ((extract (funcall
4882 gnus-extract-address-components
4883 (mail-header-from h1))))
4884 (or (car extract) (cadr extract) ""))
4885 (let ((extract (funcall
4886 gnus-extract-address-components
4887 (mail-header-from h2))))
4888 (or (car extract) (cadr extract) ""))))
4890 (defun gnus-thread-sort-by-author (h1 h2)
4891 "Sort threads by root author."
4892 (gnus-article-sort-by-author
4893 (gnus-thread-header h1) (gnus-thread-header h2)))
4895 (defsubst gnus-article-sort-by-recipient (h1 h2)
4896 "Sort articles by recipient."
4898 (let ((extract (funcall
4899 gnus-extract-address-components
4900 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4901 (or (car extract) (cadr extract)))
4902 (let ((extract (funcall
4903 gnus-extract-address-components
4904 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4905 (or (car extract) (cadr extract)))))
4907 (defun gnus-thread-sort-by-recipient (h1 h2)
4908 "Sort threads by root recipient."
4909 (gnus-article-sort-by-recipient
4910 (gnus-thread-header h1) (gnus-thread-header h2)))
4912 (defsubst gnus-article-sort-by-subject (h1 h2)
4913 "Sort articles by root subject."
4915 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4916 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4918 (defun gnus-thread-sort-by-subject (h1 h2)
4919 "Sort threads by root subject."
4920 (gnus-article-sort-by-subject
4921 (gnus-thread-header h1) (gnus-thread-header h2)))
4923 (defsubst gnus-article-sort-by-date (h1 h2)
4924 "Sort articles by root article date."
4926 (gnus-date-get-time (mail-header-date h1))
4927 (gnus-date-get-time (mail-header-date h2))))
4929 (defun gnus-thread-sort-by-date (h1 h2)
4930 "Sort threads by root article date."
4931 (gnus-article-sort-by-date
4932 (gnus-thread-header h1) (gnus-thread-header h2)))
4934 (defsubst gnus-article-sort-by-score (h1 h2)
4935 "Sort articles by root article score.
4936 Unscored articles will be counted as having a score of zero."
4937 (> (or (cdr (assq (mail-header-number h1)
4938 gnus-newsgroup-scored))
4939 gnus-summary-default-score 0)
4940 (or (cdr (assq (mail-header-number h2)
4941 gnus-newsgroup-scored))
4942 gnus-summary-default-score 0)))
4944 (defun gnus-thread-sort-by-score (h1 h2)
4945 "Sort threads by root article score."
4946 (gnus-article-sort-by-score
4947 (gnus-thread-header h1) (gnus-thread-header h2)))
4949 (defun gnus-thread-sort-by-total-score (h1 h2)
4950 "Sort threads by the sum of all scores in the thread.
4951 Unscored articles will be counted as having a score of zero."
4952 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4954 (defun gnus-thread-total-score (thread)
4955 ;; This function find the total score of THREAD.
4960 (if (stringp (car thread))
4961 (apply gnus-thread-score-function 0
4962 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4963 (gnus-thread-total-score-1 thread)))
4965 (gnus-thread-total-score-1 (list thread)))))
4967 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4968 "Sort threads such that the thread with the most recently arrived article comes first."
4969 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4971 (defun gnus-thread-highest-number (thread)
4972 "Return the highest article number in THREAD."
4973 (apply 'max (mapcar (lambda (header)
4974 (mail-header-number header))
4975 (message-flatten-list thread))))
4977 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4978 "Sort threads such that the thread with the most recently dated article comes first."
4979 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4981 (defun gnus-thread-latest-date (thread)
4982 "Return the highest article date in THREAD."
4983 (let ((previous-time 0))
4989 (time-to-seconds (mail-header-parse-date
4990 (mail-header-date header)))
4991 (error previous-time))))
4993 (message-flatten-list thread)
4995 (< (mail-header-number h1)
4996 (mail-header-number h2))))))))
4998 (defun gnus-thread-total-score-1 (root)
4999 ;; This function find the total score of the thread below ROOT.
5000 (setq root (car root))
5001 (apply gnus-thread-score-function
5003 (mapcar 'gnus-thread-total-score
5004 (cdr (gnus-id-to-thread (mail-header-id root))))
5005 (when (> (mail-header-number root) 0)
5006 (list (or (cdr (assq (mail-header-number root)
5007 gnus-newsgroup-scored))
5008 gnus-summary-default-score 0))))
5009 (list gnus-summary-default-score)
5012 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5013 (defvar gnus-tmp-prev-subject nil)
5014 (defvar gnus-tmp-false-parent nil)
5015 (defvar gnus-tmp-root-expunged nil)
5016 (defvar gnus-tmp-dummy-line nil)
5018 (defun gnus-extra-header (type &optional header)
5019 "Return the extra header of TYPE."
5020 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5023 (defvar gnus-tmp-thread-tree-header-string "")
5025 (defcustom gnus-sum-thread-tree-root "> "
5026 "With %B spec, used for the root of a thread.
5027 If nil, use subject instead."
5029 :type '(radio (const :format "%v " nil) string)
5030 :group 'gnus-thread)
5032 (defcustom gnus-sum-thread-tree-false-root "> "
5033 "With %B spec, used for a false root of a thread.
5034 If nil, use subject instead."
5036 :type '(radio (const :format "%v " nil) string)
5037 :group 'gnus-thread)
5039 (defcustom gnus-sum-thread-tree-single-indent ""
5040 "With %B spec, used for a thread with just one message.
5041 If nil, use subject instead."
5043 :type '(radio (const :format "%v " nil) string)
5044 :group 'gnus-thread)
5046 (defcustom gnus-sum-thread-tree-vertical "| "
5047 "With %B spec, used for drawing a vertical line."
5050 :group 'gnus-thread)
5052 (defcustom gnus-sum-thread-tree-indent " "
5053 "With %B spec, used for indenting."
5056 :group 'gnus-thread)
5058 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5059 "With %B spec, used for a leaf with brothers."
5062 :group 'gnus-thread)
5064 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5065 "With %B spec, used for a leaf without brothers."
5068 :group 'gnus-thread)
5070 (defcustom gnus-summary-display-while-building nil
5071 "If non-nil, show and update the summary buffer as it's being built.
5072 If the value is t, update the buffer after every line is inserted. If
5073 the value is an integer (N), update the display every N lines."
5076 :type '(choice (const :tag "off" nil)
5078 (const :tag "frequently" t)))
5080 (defun gnus-summary-prepare-threads (threads)
5081 "Prepare summary buffer from THREADS and indentation LEVEL.
5082 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5083 or a straight list of headers."
5084 (gnus-message 7 "Generating summary...")
5086 (setq gnus-newsgroup-threads threads)
5089 (let ((gnus-tmp-level 0)
5090 (default-score (or gnus-summary-default-score 0))
5091 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5092 (building-line-count gnus-summary-display-while-building)
5093 (building-count (integerp gnus-summary-display-while-building))
5094 thread number subject stack state gnus-tmp-gathered beg-match
5095 new-roots gnus-tmp-new-adopts thread-end simp-subject
5096 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5097 gnus-tmp-replied gnus-tmp-subject-or-nil
5098 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5099 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5100 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5103 (setq gnus-tmp-prev-subject nil
5104 gnus-tmp-thread-tree-header-string "")
5106 (if (vectorp (car threads))
5107 ;; If this is a straight (sic) list of headers, then a
5108 ;; threaded summary display isn't required, so we just create
5109 ;; an unthreaded one.
5110 (gnus-summary-prepare-unthreaded threads)
5112 ;; Do the threaded display.
5114 (if gnus-summary-display-while-building
5115 (switch-to-buffer (buffer-name)))
5116 (while (or threads stack gnus-tmp-new-adopts new-roots)
5118 (if (and (= gnus-tmp-level 0)
5121 (not gnus-tmp-false-parent)
5122 (or gnus-tmp-new-adopts new-roots))
5123 (if gnus-tmp-new-adopts
5124 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5125 thread (list (car gnus-tmp-new-adopts))
5126 gnus-tmp-header (caar thread)
5127 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5129 (setq thread (list (car new-roots))
5130 gnus-tmp-header (caar thread)
5131 new-roots (cdr new-roots))))
5134 ;; If there are some threads, we do them before the
5135 ;; threads on the stack.
5136 (setq thread threads
5137 gnus-tmp-header (caar thread))
5138 ;; There were no current threads, so we pop something off
5140 (setq state (car stack)
5141 gnus-tmp-level (car state)
5142 tree-stack (cadr state)
5143 thread (caddr state)
5145 gnus-tmp-header (caar thread))))
5147 (setq gnus-tmp-false-parent nil)
5148 (setq gnus-tmp-root-expunged nil)
5149 (setq thread-end nil)
5151 (if (stringp gnus-tmp-header)
5152 ;; The header is a dummy root.
5154 ((eq gnus-summary-make-false-root 'adopt)
5155 ;; We let the first article adopt the rest.
5156 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5158 (setq gnus-tmp-gathered
5160 (lambda (h) (mail-header-number (car h)))
5163 (setq thread (cons (list (caar thread)
5166 (setq gnus-tmp-level -1
5167 gnus-tmp-false-parent t))
5168 ((eq gnus-summary-make-false-root 'empty)
5169 ;; We print adopted articles with empty subject fields.
5170 (setq gnus-tmp-gathered
5172 (lambda (h) (mail-header-number (car h)))
5175 (setq gnus-tmp-level -1))
5176 ((eq gnus-summary-make-false-root 'dummy)
5177 ;; We remember that we probably want to output a dummy
5179 (setq gnus-tmp-dummy-line gnus-tmp-header)
5180 (setq gnus-tmp-prev-subject gnus-tmp-header))
5182 ;; We do not make a root for the gathered
5183 ;; sub-threads at all.
5184 (setq gnus-tmp-level -1)))
5186 (setq number (mail-header-number gnus-tmp-header)
5187 subject (mail-header-subject gnus-tmp-header)
5188 simp-subject (gnus-simplify-subject-fully subject))
5191 ;; If the thread has changed subject, we might want to make
5192 ;; this subthread into a root.
5193 ((and (null gnus-thread-ignore-subject)
5194 (not (zerop gnus-tmp-level))
5195 gnus-tmp-prev-subject
5196 (not (string= gnus-tmp-prev-subject simp-subject)))
5197 (setq new-roots (nconc new-roots (list (car thread)))
5199 gnus-tmp-header nil))
5200 ;; If the article lies outside the current limit,
5201 ;; then we do not display it.
5202 ((not (memq number gnus-newsgroup-limit))
5203 (setq gnus-tmp-gathered
5205 (lambda (h) (mail-header-number (car h)))
5208 (setq gnus-tmp-new-adopts (if (cdar thread)
5209 (append gnus-tmp-new-adopts
5211 gnus-tmp-new-adopts)
5213 gnus-tmp-header nil)
5214 (when (zerop gnus-tmp-level)
5215 (setq gnus-tmp-root-expunged t)))
5216 ;; Perhaps this article is to be marked as read?
5217 ((and gnus-summary-mark-below
5218 (< (or (cdr (assq number gnus-newsgroup-scored))
5220 gnus-summary-mark-below)
5221 ;; Don't touch sparse articles.
5222 (not (gnus-summary-article-sparse-p number))
5223 (not (gnus-summary-article-ancient-p number)))
5224 (setq gnus-newsgroup-unreads
5225 (delq number gnus-newsgroup-unreads))
5226 (if gnus-newsgroup-auto-expire
5227 (setq gnus-newsgroup-expirable
5228 (gnus-add-to-sorted-list
5229 gnus-newsgroup-expirable number))
5230 (push (cons number gnus-low-score-mark)
5231 gnus-newsgroup-reads))))
5233 (when gnus-tmp-header
5234 ;; We may have an old dummy line to output before this
5236 (when (and gnus-tmp-dummy-line
5239 (mail-header-subject gnus-tmp-header)))
5240 (gnus-summary-insert-dummy-line
5241 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5242 (setq gnus-tmp-dummy-line nil))
5244 ;; Compute the mark.
5245 (setq gnus-tmp-unread (gnus-article-mark number))
5247 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5248 gnus-tmp-header gnus-tmp-level)
5249 gnus-newsgroup-data)
5251 ;; Actually insert the line.
5253 gnus-tmp-subject-or-nil
5255 ((and gnus-thread-ignore-subject
5256 gnus-tmp-prev-subject
5257 (not (string= gnus-tmp-prev-subject simp-subject)))
5259 ((zerop gnus-tmp-level)
5260 (if (and (eq gnus-summary-make-false-root 'empty)
5261 (memq number gnus-tmp-gathered)
5262 gnus-tmp-prev-subject
5263 (string= gnus-tmp-prev-subject simp-subject))
5264 gnus-summary-same-subject
5266 (t gnus-summary-same-subject)))
5267 (if (and (eq gnus-summary-make-false-root 'adopt)
5268 (= gnus-tmp-level 1)
5269 (memq number gnus-tmp-gathered))
5270 (setq gnus-tmp-opening-bracket ?\<
5271 gnus-tmp-closing-bracket ?\>)
5272 (setq gnus-tmp-opening-bracket ?\[
5273 gnus-tmp-closing-bracket ?\]))
5274 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5275 (gnus-make-thread-indent-array
5276 (max (* 2 (length gnus-thread-indent-array))
5279 gnus-tmp-indentation
5280 (aref gnus-thread-indent-array gnus-tmp-level)
5281 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5282 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5283 gnus-summary-default-score 0)
5285 (if (or (null gnus-summary-default-score)
5286 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5287 gnus-summary-zcore-fuzz))
5289 (if (< gnus-tmp-score gnus-summary-default-score)
5290 gnus-score-below-mark gnus-score-over-mark))
5292 (cond ((memq number gnus-newsgroup-processable)
5294 ((memq number gnus-newsgroup-cached)
5296 ((memq number gnus-newsgroup-replied)
5298 ((memq number gnus-newsgroup-forwarded)
5299 gnus-forwarded-mark)
5300 ((memq number gnus-newsgroup-saved)
5302 ((memq number gnus-newsgroup-recent)
5304 ((memq number gnus-newsgroup-unseen)
5308 (cond ((memq number gnus-newsgroup-undownloaded)
5309 gnus-undownloaded-mark)
5310 (gnus-newsgroup-agentized
5311 gnus-downloaded-mark)
5314 gnus-tmp-from (mail-header-from gnus-tmp-header)
5317 ((string-match "<[^>]+> *$" gnus-tmp-from)
5318 (setq beg-match (match-beginning 0))
5319 (or (and (string-match "^\".+\"" gnus-tmp-from)
5320 (substring gnus-tmp-from 1 (1- (match-end 0))))
5321 (substring gnus-tmp-from 0 beg-match)))
5322 ((string-match "(.+)" gnus-tmp-from)
5323 (substring gnus-tmp-from
5324 (1+ (match-beginning 0)) (1- (match-end 0))))
5328 gnus-tmp-thread-tree-header-string
5330 ((not gnus-show-threads) "")
5331 ((zerop gnus-tmp-level)
5332 (cond ((cdar thread)
5333 (or gnus-sum-thread-tree-root subject))
5334 (gnus-tmp-new-adopts
5335 (or gnus-sum-thread-tree-false-root subject))
5337 (or gnus-sum-thread-tree-single-indent subject))))
5339 (concat (apply 'concat
5340 (mapcar (lambda (item)
5342 gnus-sum-thread-tree-vertical
5343 gnus-sum-thread-tree-indent))
5344 (cdr (reverse tree-stack))))
5346 gnus-sum-thread-tree-leaf-with-other
5347 gnus-sum-thread-tree-single-leaf)))))
5348 (when (string= gnus-tmp-name "")
5349 (setq gnus-tmp-name gnus-tmp-from))
5350 (unless (numberp gnus-tmp-lines)
5351 (setq gnus-tmp-lines -1))
5352 (if (= gnus-tmp-lines -1)
5353 (setq gnus-tmp-lines "?")
5354 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5355 (gnus-put-text-property
5357 (progn (eval gnus-summary-line-format-spec) (point))
5358 'gnus-number number)
5361 (gnus-run-hooks 'gnus-summary-update-hook)
5364 (setq gnus-tmp-prev-subject simp-subject)))
5366 (when (nth 1 thread)
5367 (push (list (max 0 gnus-tmp-level)
5368 (copy-sequence tree-stack)
5371 (push (if (nth 1 thread) 1 0) tree-stack)
5372 (incf gnus-tmp-level)
5373 (setq threads (if thread-end nil (cdar thread)))
5374 (if gnus-summary-display-while-building
5377 ;; use a set frequency
5378 (setq building-line-count (1- building-line-count))
5379 (when (= building-line-count 0)
5381 (setq building-line-count
5382 gnus-summary-display-while-building)))
5386 (setq gnus-tmp-level 0)))))
5387 (gnus-message 7 "Generating summary...done"))
5389 (defun gnus-summary-prepare-unthreaded (headers)
5390 "Generate an unthreaded summary buffer based on HEADERS."
5391 (let (header number mark)
5396 ;; We may have to root out some bad articles...
5397 (when (memq (setq number (mail-header-number
5398 (setq header (pop headers))))
5399 gnus-newsgroup-limit)
5400 ;; Mark article as read when it has a low score.
5401 (when (and gnus-summary-mark-below
5402 (< (or (cdr (assq number gnus-newsgroup-scored))
5403 gnus-summary-default-score 0)
5404 gnus-summary-mark-below)
5405 (not (gnus-summary-article-ancient-p number)))
5406 (setq gnus-newsgroup-unreads
5407 (delq number gnus-newsgroup-unreads))
5408 (if gnus-newsgroup-auto-expire
5409 (push number gnus-newsgroup-expirable)
5410 (push (cons number gnus-low-score-mark)
5411 gnus-newsgroup-reads)))
5413 (setq mark (gnus-article-mark number))
5414 (push (gnus-data-make number mark (1+ (point)) header 0)
5415 gnus-newsgroup-data)
5416 (gnus-summary-insert-line
5418 (memq number gnus-newsgroup-undownloaded)
5419 mark (memq number gnus-newsgroup-replied)
5420 (memq number gnus-newsgroup-expirable)
5421 (mail-header-subject header) nil
5422 (cdr (assq number gnus-newsgroup-scored))
5423 (memq number gnus-newsgroup-processable))))))
5425 (defun gnus-summary-remove-list-identifiers ()
5426 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5427 (let ((regexp (if (consp gnus-list-identifiers)
5428 (mapconcat 'identity gnus-list-identifiers " *\\|")
5429 gnus-list-identifiers))
5432 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5433 (dolist (header gnus-newsgroup-headers)
5434 (setq subject (mail-header-subject header)
5436 (while (string-match regexp subject)
5438 (concat (substring subject 0 (match-beginning 1))
5439 (substring subject (match-end 0)))
5442 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5444 (concat (substring subject 0 (match-beginning 1))
5445 (substring subject (match-end 1)))))
5446 (mail-header-set-subject header subject))))))
5448 (defun gnus-fetch-headers (articles)
5449 "Fetch headers of ARTICLES."
5450 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5451 (gnus-message 5 "Fetching headers for %s..." name)
5454 (setq gnus-headers-retrieved-by
5455 (gnus-retrieve-headers
5456 articles gnus-newsgroup-name
5457 ;; We might want to fetch old headers, but
5458 ;; not if there is only 1 article.
5460 (not (eq gnus-fetch-old-headers 'some))
5461 (not (numberp gnus-fetch-old-headers)))
5462 (> (length articles) 1))
5463 gnus-fetch-old-headers))))
5464 (gnus-get-newsgroup-headers-xover
5465 articles nil nil gnus-newsgroup-name t)
5466 (gnus-get-newsgroup-headers))
5467 (gnus-message 5 "Fetching headers for %s...done" name))))
5469 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5470 "Select newsgroup GROUP.
5471 If READ-ALL is non-nil, all articles in the group are selected.
5472 If SELECT-ARTICLES, only select those articles from GROUP."
5473 (let* ((entry (gnus-group-entry group))
5474 ;;!!! Dirty hack; should be removed.
5475 (gnus-summary-ignore-duplicates
5476 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5478 gnus-summary-ignore-duplicates))
5479 (info (nth 2 entry))
5480 charset articles fetched-articles cached)
5482 (unless (gnus-check-server
5483 (set (make-local-variable 'gnus-current-select-method)
5484 (gnus-find-method-for-group group)))
5485 (error "Couldn't open server"))
5486 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5488 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5489 (gnus-activate-group group) ; Or we can activate it...
5490 (progn ; Or we bug out.
5491 (when (equal major-mode 'gnus-summary-mode)
5492 (gnus-kill-buffer (current-buffer)))
5494 "Couldn't activate group %s: %s"
5495 (mm-decode-coding-string group charset)
5496 (mm-decode-coding-string (gnus-status-message group) charset))))
5498 (unless (gnus-request-group group t)
5499 (when (equal major-mode 'gnus-summary-mode)
5500 (gnus-kill-buffer (current-buffer)))
5501 (error "Couldn't request group %s: %s"
5502 (mm-decode-coding-string group charset)
5503 (mm-decode-coding-string (gnus-status-message group) charset)))
5506 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5508 (setq gnus-summary-use-undownloaded-faces
5509 (gnus-agent-find-parameter
5511 'agent-enable-undownloaded-faces)))
5513 (setq gnus-newsgroup-name group
5514 gnus-newsgroup-unselected nil
5515 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5517 (let ((display (gnus-group-find-parameter group 'display)))
5518 (setq gnus-newsgroup-display
5520 ((not (zerop (or (car-safe read-all) 0)))
5521 ;; The user entered the group with C-u SPC/RET, let's show
5527 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5529 ;; The following is probably the "correct" solution, but
5530 ;; it makes Gnus fetch all headers and then limit the
5531 ;; articles (which is slow), so instead we hack the
5532 ;; select-articles parameter instead. -- Simon Josefsson
5535 ;; (gnus-byte-compile
5536 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5538 (setq select-articles
5539 (gnus-uncompress-range
5540 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5544 (cdr (gnus-active group)))))
5549 (gnus-summary-setup-default-charset)
5551 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5552 (when (gnus-virtual-group-p group)
5553 (setq cached gnus-newsgroup-cached))
5555 (setq gnus-newsgroup-unreads
5556 (gnus-sorted-ndifference
5557 (gnus-sorted-ndifference gnus-newsgroup-unreads
5558 gnus-newsgroup-marked)
5559 gnus-newsgroup-dormant))
5561 (setq gnus-newsgroup-processable nil)
5563 (gnus-update-read-articles group gnus-newsgroup-unreads)
5565 ;; Adjust and set lists of article marks.
5567 (gnus-adjust-marked-articles info))
5568 (if (setq articles select-articles)
5569 (setq gnus-newsgroup-unselected
5570 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5571 (setq articles (gnus-articles-to-read group read-all)))
5575 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5577 ((eq articles 0) nil)
5579 ;; Init the dependencies hash table.
5580 (setq gnus-newsgroup-dependencies
5581 (gnus-make-hashtable (length articles)))
5582 (gnus-set-global-variables)
5583 ;; Retrieve the headers and read them in.
5585 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5587 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5589 (setq gnus-newsgroup-cached cached))
5591 ;; Suppress duplicates?
5592 (when gnus-suppress-duplicates
5593 (gnus-dup-suppress-articles))
5595 ;; Set the initial limit.
5596 (setq gnus-newsgroup-limit (copy-sequence articles))
5597 ;; Remove canceled articles from the list of unread articles.
5598 (setq fetched-articles
5599 (mapcar (lambda (headers) (mail-header-number headers))
5600 gnus-newsgroup-headers))
5601 (setq gnus-newsgroup-articles fetched-articles)
5602 (setq gnus-newsgroup-unreads
5603 (gnus-sorted-nintersection
5604 gnus-newsgroup-unreads fetched-articles))
5605 (gnus-compute-unseen-list)
5607 ;; Removed marked articles that do not exist.
5608 (gnus-update-missing-marks
5609 (gnus-sorted-difference articles fetched-articles))
5610 ;; We might want to build some more threads first.
5611 (when (and gnus-fetch-old-headers
5612 (eq gnus-headers-retrieved-by 'nov))
5613 (if (eq gnus-fetch-old-headers 'invisible)
5614 (gnus-build-all-threads)
5615 (gnus-build-old-threads)))
5616 ;; Let the Gnus agent mark articles as read.
5618 (gnus-agent-get-undownloaded-list))
5619 ;; Remove list identifiers from subject
5620 (when gnus-list-identifiers
5621 (gnus-summary-remove-list-identifiers))
5622 ;; Check whether auto-expire is to be done in this group.
5623 (setq gnus-newsgroup-auto-expire
5624 (gnus-group-auto-expirable-p group))
5625 ;; Set up the article buffer now, if necessary.
5626 (unless (and gnus-single-article-buffer
5627 (equal gnus-article-buffer "*Article*"))
5628 (gnus-article-setup-buffer))
5629 ;; First and last article in this newsgroup.
5630 (when gnus-newsgroup-headers
5631 (setq gnus-newsgroup-begin
5632 (mail-header-number (car gnus-newsgroup-headers))
5635 (gnus-last-element gnus-newsgroup-headers))))
5636 ;; GROUP is successfully selected.
5637 (or gnus-newsgroup-headers t)))))
5639 (defun gnus-compute-unseen-list ()
5640 ;; The `seen' marks are treated specially.
5641 (if (not gnus-newsgroup-seen)
5642 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5643 (setq gnus-newsgroup-unseen
5644 (gnus-inverse-list-range-intersection
5645 gnus-newsgroup-articles gnus-newsgroup-seen))))
5647 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5649 (defun gnus-summary-display-make-predicate (display)
5650 (require 'gnus-agent)
5651 (when (= (length display) 1)
5652 (setq display (car display)))
5653 (unless gnus-summary-display-cache
5654 (dolist (elem (append '((unread . unread)
5657 gnus-article-mark-lists))
5658 (push (cons (cdr elem)
5660 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5661 gnus-summary-display-cache)))
5662 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5663 (gnus-category-predicate-cache gnus-summary-display-cache))
5664 (gnus-get-predicate display)))
5666 ;; Uses the dynamically bound `number' variable.
5668 (defun gnus-article-marked-p (type &optional article)
5669 (let ((article (or article number)))
5672 (memq article gnus-newsgroup-marked))
5674 (memq article gnus-newsgroup-spam-marked))
5676 (memq article gnus-newsgroup-unsendable))
5677 ((eq type 'undownload)
5678 (memq article gnus-newsgroup-undownloaded))
5679 ((eq type 'download)
5680 (memq article gnus-newsgroup-downloadable))
5682 (memq article gnus-newsgroup-unreads))
5684 (memq article gnus-newsgroup-reads))
5686 (memq article gnus-newsgroup-dormant) )
5688 (memq article gnus-newsgroup-expirable))
5690 (memq article gnus-newsgroup-replied))
5692 (memq article gnus-newsgroup-killed))
5693 ((eq type 'bookmark)
5694 (assq article gnus-newsgroup-bookmarks))
5696 (assq article gnus-newsgroup-scored))
5698 (memq article gnus-newsgroup-saved))
5700 (memq article gnus-newsgroup-cached))
5702 (memq article gnus-newsgroup-forwarded))
5704 (not (memq article gnus-newsgroup-unseen)))
5706 (memq article gnus-newsgroup-recent))
5709 (defun gnus-articles-to-read (group &optional read-all)
5710 "Find out what articles the user wants to read."
5712 ;; Select all articles if `read-all' is non-nil, or if there
5713 ;; are no unread articles.
5715 (and (zerop (length gnus-newsgroup-marked))
5716 (zerop (length gnus-newsgroup-unreads)))
5717 ;; Fetch all if the predicate is non-nil.
5718 gnus-newsgroup-display)
5719 ;; We want to select the headers for all the articles in
5720 ;; the group, so we select either all the active
5721 ;; articles in the group, or (if that's nil), the
5722 ;; articles in the cache.
5724 (if gnus-newsgroup-maximum-articles
5725 (let ((active (gnus-active group)))
5726 (gnus-uncompress-range
5727 (cons (max (car active)
5729 gnus-newsgroup-maximum-articles
5732 (gnus-uncompress-range (gnus-active group)))
5733 (gnus-cache-articles-in-group group))
5734 ;; Select only the "normal" subset of articles.
5736 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5737 gnus-newsgroup-unreads)))
5738 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5739 (scored (length scored-list))
5740 (number (length articles))
5741 (marked (+ (length gnus-newsgroup-marked)
5742 (length gnus-newsgroup-dormant)))
5747 ((numberp gnus-newsgroup-display)
5748 gnus-newsgroup-display)
5752 ((and (or (<= scored marked) (= scored number))
5753 (numberp gnus-large-newsgroup)
5754 (> number gnus-large-newsgroup))
5755 (let* ((cursor-in-echo-area nil)
5756 (initial (gnus-parameter-large-newsgroup-initial
5757 gnus-newsgroup-name))
5761 "How many articles from %s (%s %d): "
5762 (gnus-group-decoded-name gnus-newsgroup-name)
5763 (if initial "max" "default")
5766 (cons (number-to-string initial)
5768 (if (string-match "^[ \t]*$" input) number input)))
5769 ((and (> scored marked) (< scored number)
5770 (> (- scored number) 20))
5773 (format "%s %s (%d scored, %d total): "
5774 "How many articles from"
5775 (gnus-group-decoded-name group)
5777 (if (string-match "^[ \t]*$" input)
5781 (message "Quit getting the articles to read")
5783 (setq select (if (stringp select) (string-to-number select) select))
5784 (if (or (null select) (zerop select))
5786 (if (and (not (zerop scored)) (<= (abs select) scored))
5788 (setq articles (sort scored-list '<))
5789 (setq number (length articles)))
5790 (setq articles (copy-sequence articles)))
5792 (when (< (abs select) number)
5794 ;; Select the N oldest articles.
5795 (setcdr (nthcdr (1- (abs select)) articles) nil)
5796 ;; Select the N most recent articles.
5797 (setq articles (nthcdr (- number select) articles))))
5798 (setq gnus-newsgroup-unselected
5799 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5800 (when gnus-alter-articles-to-read-function
5803 (funcall gnus-alter-articles-to-read-function
5804 gnus-newsgroup-name articles)
5808 (defun gnus-killed-articles (killed articles)
5811 (when (inline (gnus-member-of-range (car articles) killed))
5812 (push (car articles) out))
5813 (setq articles (cdr articles)))
5816 (defun gnus-uncompress-marks (marks)
5817 "Uncompress the mark ranges in MARKS."
5818 (let ((uncompressed '(score bookmark))
5821 (if (memq (caar marks) uncompressed)
5822 (push (car marks) out)
5823 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5824 (setq marks (cdr marks)))
5827 (defun gnus-article-mark-to-type (mark)
5828 "Return the type of MARK."
5829 (or (cadr (assq mark gnus-article-special-mark-lists))
5832 (defun gnus-article-unpropagatable-p (mark)
5833 "Return whether MARK should be propagated to back end."
5834 (memq mark gnus-article-unpropagated-mark-lists))
5836 (defun gnus-adjust-marked-articles (info)
5837 "Set all article lists and remove all marks that are no longer valid."
5838 (let* ((marked-lists (gnus-info-marks info))
5839 (active (gnus-active (gnus-info-group info)))
5842 (types gnus-article-mark-lists)
5843 marks var articles article mark mark-type
5846 (dolist (marks marked-lists)
5847 (setq mark (car marks)
5848 mark-type (gnus-article-mark-to-type mark)
5849 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5851 ;; We set the variable according to the type of the marks list,
5852 ;; and then adjust the marks to a subset of the active articles.
5854 ;; Adjust "simple" lists - compressed yet unsorted
5855 ((eq mark-type 'list)
5856 ;; Simultaneously uncompress and clip to active range
5857 ;; See gnus-uncompress-range for a description of possible marks
5859 (if (not (cadr marks))
5861 (setq articles (if (numberp (cddr marks))
5867 (while (setq article (pop articles))
5868 (cond ((consp article)
5869 (setq bgn (max (car article) min)
5870 end (min (cdr article) max))
5872 (setq l (setcdr l (cons bgn nil))
5874 ((and (<= min article)
5876 (setq l (setcdr l (cons article nil))))))
5877 (set var (cdr lh)))))
5879 ((eq mark-type 'tuple)
5880 (set var (setq articles (cdr marks)))
5881 (when (not (listp (cdr (symbol-value var))))
5882 (set var (list (symbol-value var))))
5883 (when (not (listp (cdr articles)))
5884 (setq articles (list articles)))
5886 (when (or (not (consp (setq article (pop articles))))
5887 (< (car article) min)
5888 (> (car article) max))
5889 (set var (delq article (symbol-value var))))))
5890 ;; Adjust ranges (sloppily).
5891 ((eq mark-type 'range)
5894 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5895 ;; It should be (seen (NUM1 . NUM2)).
5896 (when (numberp (cddr marks))
5897 (setcdr marks (list (cdr marks))))
5898 (setq articles (cdr marks))
5899 (while (and articles
5900 (or (and (consp (car articles))
5901 (> min (cdar articles)))
5902 (and (numberp (car articles))
5903 (> min (car articles)))))
5905 (set var articles))))))))
5907 (defun gnus-update-missing-marks (missing)
5908 "Go through the list of MISSING articles and remove them from the mark lists."
5911 ;; Go through all types.
5912 (dolist (elem gnus-article-mark-lists)
5913 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5914 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5915 (when (symbol-value var)
5916 ;; This list has articles. So we delete all missing
5917 ;; articles from it.
5920 (set var (delq (pop m) (symbol-value var))))))))))
5922 (defun gnus-update-marks ()
5923 "Enter the various lists of marked articles into the newsgroup info list."
5924 (let ((types gnus-article-mark-lists)
5925 (info (gnus-get-info gnus-newsgroup-name))
5926 type list newmarked symbol delta-marks)
5928 ;; Add all marks lists to the list of marks lists.
5929 (while (setq type (pop types))
5930 (setq list (symbol-value
5932 (intern (format "gnus-newsgroup-%s" (car type))))))
5935 ;; Get rid of the entries of the articles that have the
5937 (when (and (eq (cdr type) 'score)
5941 (prev (cons nil list))
5944 (if (or (not (consp (car arts)))
5945 (= (cdar arts) gnus-summary-default-score))
5946 (setcdr prev (cdr arts))
5948 (setq arts (cdr arts)))
5949 (setq list (cdr all)))))
5951 (when (eq (cdr type) 'seen)
5952 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5954 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5955 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5957 (when (and (gnus-check-backend-function
5958 'request-set-mark gnus-newsgroup-name)
5959 (not (gnus-article-unpropagatable-p (cdr type))))
5960 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5961 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5962 (add (gnus-remove-from-range
5963 (gnus-copy-sequence list) old)))
5965 (push (list add 'add (list (cdr type))) delta-marks))
5967 (push (list del 'del (list (cdr type))) delta-marks))))
5970 (push (cons (cdr type) list) newmarked)))
5973 (unless (gnus-check-group gnus-newsgroup-name)
5974 (error "Can't open server for %s" gnus-newsgroup-name))
5975 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5977 ;; Enter these new marks into the info of the group.
5979 (setcar (nthcdr 3 info) newmarked)
5980 ;; Add the marks lists to the end of the info.
5982 (setcdr (nthcdr 2 info) (list newmarked))))
5984 ;; Cut off the end of the info if there's nothing else there.
5988 (when (nthcdr (decf i) info)
5989 (setcdr (nthcdr i info) nil)))))))
5991 (defun gnus-set-mode-line (where)
5992 "Set the mode line of the article or summary buffers.
5993 If WHERE is `summary', the summary mode line format will be used."
5994 ;; Is this mode line one we keep updated?
5995 (when (and (memq where gnus-updated-mode-lines)
5997 (intern (format "gnus-%s-mode-line-format-spec" where))))
5999 ;; We evaluate this in the summary buffer since these
6000 ;; variables are buffer-local to that buffer.
6001 (with-current-buffer gnus-summary-buffer
6002 ;; We bind all these variables that are used in the `eval' form
6004 (let* ((mformat (symbol-value
6006 (format "gnus-%s-mode-line-format-spec" where))))
6007 (gnus-tmp-group-name (gnus-mode-string-quote
6008 (gnus-group-decoded-name
6009 gnus-newsgroup-name)))
6010 (gnus-tmp-article-number (or gnus-current-article 0))
6011 (gnus-tmp-unread gnus-newsgroup-unreads)
6012 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6013 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6014 (gnus-tmp-unread-and-unselected
6015 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6016 (zerop gnus-tmp-unselected))
6018 ((zerop gnus-tmp-unselected)
6019 (format "{%d more}" gnus-tmp-unread-and-unticked))
6020 (t (format "{%d(+%d) more}"
6021 gnus-tmp-unread-and-unticked
6022 gnus-tmp-unselected))))
6024 (if (and gnus-current-headers
6025 (vectorp gnus-current-headers))
6026 (gnus-mode-string-quote
6027 (mail-header-subject gnus-current-headers))
6029 bufname-length max-len
6030 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6031 (setq mode-string (eval mformat))
6032 (setq bufname-length (if (string-match "%b" mode-string)
6035 (if (eq where 'summary)
6037 (get-buffer gnus-article-buffer))))
6040 (setq max-len (max 4 (if gnus-mode-non-string-length
6042 gnus-mode-non-string-length
6044 (length mode-string))))
6045 ;; We might have to chop a bit of the string off...
6046 (when (> (length mode-string) max-len)
6048 (concat (truncate-string-to-width mode-string (- max-len 3))
6050 ;; Pad the mode string a bit.
6051 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
6052 ;; Update the mode line.
6053 (setq mode-line-buffer-identification
6054 (gnus-mode-line-buffer-identification (list mode-string)))
6055 (set-buffer-modified-p t))))
6057 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6058 "Go through the HEADERS list and add all Xrefs to a hash table.
6059 The resulting hash table is returned, or nil if no Xrefs were found."
6060 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6061 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6062 (xref-hashtb (gnus-make-hashtable))
6063 start group entry number xrefs header)
6065 (setq header (pop headers))
6066 (when (and (setq xrefs (mail-header-xref header))
6067 (not (memq (setq number (mail-header-number header))
6070 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6071 (setq start (match-end 0))
6072 (setq group (if prefix
6073 (concat prefix (substring xrefs (match-beginning 1)
6075 (substring xrefs (match-beginning 1) (match-end 1))))
6077 (string-to-number (substring xrefs (match-beginning 2)
6079 (if (setq entry (gnus-gethash group xref-hashtb))
6080 (setcdr entry (cons number (cdr entry)))
6081 (gnus-sethash group (cons number nil) xref-hashtb)))))
6082 (and start xref-hashtb)))
6084 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6085 "Look through all the headers and mark the Xrefs as read."
6086 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6087 name info xref-hashtb idlist method nth4)
6089 (set-buffer gnus-group-buffer)
6090 (when (setq xref-hashtb
6091 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6094 (unless (string= from-newsgroup (setq name (symbol-name group)))
6095 (setq idlist (symbol-value group))
6096 ;; Dead groups are not updated.
6098 (setq info (gnus-get-info name))
6099 (when (stringp (setq nth4 (gnus-info-method info)))
6100 (setq nth4 (gnus-server-to-method nth4))))
6101 ;; Only do the xrefs if the group has the same
6102 ;; select method as the group we have just read.
6103 (or (gnus-methods-equal-p
6104 nth4 (gnus-find-method-for-group from-newsgroup))
6106 (equal nth4 (setq method (gnus-find-method-for-group
6108 (and (equal (car nth4) (car method))
6109 (equal (nth 1 nth4) (nth 1 method))))
6110 gnus-use-cross-reference
6111 (or (not (eq gnus-use-cross-reference t))
6113 ;; Only do cross-references on subscribed
6114 ;; groups, if that is what is wanted.
6115 (<= (gnus-info-level info) gnus-level-subscribed))
6116 (gnus-group-make-articles-read name idlist))))
6119 (defun gnus-compute-read-articles (group articles)
6120 (let* ((entry (gnus-group-entry group))
6121 (info (nth 2 entry))
6122 (active (gnus-active group))
6125 ;; First peel off all invalid article numbers.
6127 (let ((ids articles)
6129 (while (setq id (pop ids))
6130 (when (and first (> id (cdr active)))
6131 ;; We'll end up in this situation in one particular
6132 ;; obscure situation. If you re-scan a group and get
6133 ;; a new article that is cross-posted to a different
6134 ;; group that has not been re-scanned, you might get
6135 ;; crossposted article that has a higher number than
6136 ;; Gnus believes possible. So we re-activate this
6137 ;; group as well. This might mean doing the
6138 ;; crossposting thingy will *increase* the number
6139 ;; of articles in some groups. Tsk, tsk.
6140 (setq active (or (gnus-activate-group group) active)))
6141 (when (or (> id (cdr active))
6142 (< id (car active)))
6143 (setq articles (delq id articles))))))
6144 ;; If the read list is nil, we init it.
6146 (null (gnus-info-read info))
6148 (setq ninfo (cons 1 (1- (car active))))
6149 (setq ninfo (gnus-info-read info)))
6150 ;; Then we add the read articles to the range.
6152 ninfo (setq articles (sort articles '<))))))
6154 (defun gnus-group-make-articles-read (group articles)
6155 "Update the info of GROUP to say that ARTICLES are read."
6157 (entry (gnus-group-entry group))
6158 (info (nth 2 entry))
6159 (active (gnus-active group))
6162 (setq range (gnus-compute-read-articles group articles))
6163 (with-current-buffer gnus-group-buffer
6166 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6167 (gnus-info-set-read ',info ',(gnus-info-read info))
6168 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6169 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6170 (gnus-group-update-group ,group t))))
6171 ;; Add the read articles to the range.
6172 (gnus-info-set-read info range)
6173 (gnus-request-set-mark group (list (list range 'add '(read))))
6174 ;; Then we have to re-compute how many unread
6175 ;; articles there are in this group.
6179 (setq num (- (1+ (cdr active)) (car active))))
6180 ((not (listp (cdr range)))
6181 (setq num (- (cdr active) (- (1+ (cdr range))
6185 (if (numberp (car range))
6187 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6188 (setq range (cdr range)))
6189 (setq num (- (cdr active) num))))
6190 ;; Update the number of unread articles.
6192 ;; Update the group buffer.
6193 (unless (gnus-ephemeral-group-p group)
6194 (gnus-group-update-group group t))))))
6196 (defvar gnus-newsgroup-none-id 0)
6198 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6199 (let ((cur nntp-server-buffer)
6202 (with-current-buffer gnus-summary-buffer
6203 gnus-newsgroup-dependencies)))
6204 headers id end ref number
6205 (mail-parse-charset gnus-newsgroup-charset)
6206 (mail-parse-ignored-charsets
6207 (save-current-buffer (condition-case nil
6208 (set-buffer gnus-summary-buffer)
6210 gnus-newsgroup-ignored-charsets)))
6211 (with-current-buffer nntp-server-buffer
6212 ;; Translate all TAB characters into SPACE characters.
6213 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6214 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6215 (ietf-drums-unfold-fws)
6216 (gnus-run-hooks 'gnus-parse-headers-hook)
6217 (let ((case-fold-search t)
6218 in-reply-to header p lines chars)
6219 (goto-char (point-min))
6220 ;; Search to the beginning of the next header. Error messages
6221 ;; do not begin with 2 or 3.
6222 (while (re-search-forward "^[23][0-9]+ " nil t)
6225 ;; This implementation of this function, with nine
6226 ;; search-forwards instead of the one re-search-forward and
6227 ;; a case (which basically was the old function) is actually
6228 ;; about twice as fast, even though it looks messier. You
6229 ;; can't have everything, I guess. Speed and elegance
6230 ;; doesn't always go hand in hand.
6236 (setq number (read cur))
6239 (narrow-to-region (point)
6240 (or (and (search-forward "\n.\n" nil t)
6246 (if (search-forward "\nsubject:" nil t)
6247 (funcall gnus-decode-encoded-word-function
6248 (nnheader-header-value))
6253 (if (search-forward "\nfrom:" nil t)
6254 (funcall gnus-decode-encoded-address-function
6255 (nnheader-header-value))
6260 (if (search-forward "\ndate:" nil t)
6261 (nnheader-header-value) ""))
6265 (setq id (if (re-search-forward
6266 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6267 ;; We do it this way to make sure the Message-ID
6268 ;; is (somewhat) syntactically valid.
6269 (buffer-substring (match-beginning 1)
6271 ;; If there was no message-id, we just fake one
6272 ;; to make subsequent routines simpler.
6273 (nnheader-generate-fake-message-id number))))
6277 (if (search-forward "\nreferences:" nil t)
6281 (nnheader-header-value)
6286 (search-backward ">" end t)
6289 (search-backward "<" end t)
6291 ;; Get the references from the in-reply-to header if there
6292 ;; were no references and the in-reply-to header looks
6294 (if (and (search-forward "\nin-reply-to:" nil t)
6295 (setq in-reply-to (nnheader-header-value))
6296 (string-match "<[^>]+>" in-reply-to))
6298 (setq ref (substring in-reply-to (match-beginning 0)
6300 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6301 (setq ref2 (substring in-reply-to (match-beginning 0)
6303 (when (> (length ref2) (length ref))
6310 (if (search-forward "\nchars: " nil t)
6311 (if (numberp (setq chars (ignore-errors (read cur))))
6317 (if (search-forward "\nlines: " nil t)
6318 (if (numberp (setq lines (ignore-errors (read cur))))
6324 (and (search-forward "\nxref:" nil t)
6325 (nnheader-header-value)))
6327 (when gnus-extra-headers
6328 (let ((extra gnus-extra-headers)
6332 (when (search-forward
6333 (concat "\n" (symbol-name (car extra)) ":") nil t)
6334 (push (cons (car extra) (nnheader-header-value))
6338 (when (equal id ref)
6341 (when gnus-alter-header-function
6342 (funcall gnus-alter-header-function header)
6343 (setq id (mail-header-id header)
6344 ref (gnus-parent-id (mail-header-references header))))
6347 (gnus-dependencies-add-header
6348 header dependencies force-new))
6349 (push header headers))
6350 (goto-char (point-max))
6352 (nreverse headers)))))
6354 ;; Goes through the xover lines and returns a list of vectors
6355 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6356 force-new dependencies
6357 group also-fetch-heads)
6358 "Parse the news overview data in the server buffer.
6359 Return a list of headers that match SEQUENCE (see
6360 `nntp-retrieve-headers')."
6361 ;; Get the Xref when the users reads the articles since most/some
6362 ;; NNTP servers do not include Xrefs when using XOVER.
6363 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6364 (let ((mail-parse-charset gnus-newsgroup-charset)
6365 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6366 (cur nntp-server-buffer)
6367 (dependencies (or dependencies gnus-newsgroup-dependencies))
6369 ((eq gnus-read-all-available-headers t)
6371 ((and (stringp gnus-read-all-available-headers)
6373 (string-match gnus-read-all-available-headers group))
6376 number headers header)
6377 (with-current-buffer nntp-server-buffer
6378 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6379 ;; Allow the user to mangle the headers before parsing them.
6380 (gnus-run-hooks 'gnus-parse-headers-hook)
6381 (goto-char (point-min))
6382 (gnus-parse-without-error
6383 (while (and (or sequence allp)
6385 (setq number (read cur))
6387 (while (and sequence
6388 (< (car sequence) number))
6389 (setq sequence (cdr sequence))))
6392 (eq number (car sequence))))
6394 (setq sequence (cdr sequence))
6395 (setq header (inline
6396 (gnus-nov-parse-line
6397 number dependencies force-new)))))
6398 (push header headers))
6400 ;; A common bug in inn is that if you have posted an article and
6401 ;; then retrieves the active file, it will answer correctly --
6402 ;; the new article is included. However, a NOV entry for the
6403 ;; article may not have been generated yet, so this may fail.
6404 ;; We work around this problem by retrieving the last few
6405 ;; headers using HEAD.
6406 (if (or (not also-fetch-heads)
6408 ;; We (probably) got all the headers.
6410 (let ((gnus-nov-is-evil t))
6413 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6414 (gnus-get-newsgroup-headers))))))))
6416 (defun gnus-article-get-xrefs ()
6417 "Fill in the Xref value in `gnus-current-headers', if necessary.
6418 This is meant to be called in `gnus-article-internal-prepare-hook'."
6419 (let ((headers (with-current-buffer gnus-summary-buffer
6420 gnus-current-headers)))
6421 (or (not gnus-use-cross-reference)
6423 (and (mail-header-xref headers)
6424 (not (string= (mail-header-xref headers) "")))
6425 (let ((case-fold-search t)
6428 (nnheader-narrow-to-headers)
6429 (goto-char (point-min))
6430 (when (or (and (not (eobp))
6431 (eq (downcase (char-after)) ?x)
6432 (looking-at "Xref:"))
6433 (search-forward "\nXref:" nil t))
6434 (goto-char (1+ (match-end 0)))
6435 (setq xref (buffer-substring (point) (point-at-eol)))
6436 (mail-header-set-xref headers xref)))))))
6438 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6439 "Find article ID and insert the summary line for that article.
6440 OLD-HEADER can either be a header or a line number to insert
6441 the subject line on."
6442 (let* ((line (and (numberp old-header) old-header))
6443 (old-header (and (vectorp old-header) old-header))
6444 (header (cond ((and old-header use-old-header)
6447 (gnus-number-to-header id))
6448 (gnus-number-to-header id))
6450 (gnus-read-header id))))
6451 (number (and (numberp id) id))
6454 ;; Rebuild the thread that this article is part of and go to the
6455 ;; article we have fetched.
6456 (when (and (not gnus-show-threads)
6459 (setq d (gnus-data-find (mail-header-number old-header))))
6460 (goto-char (gnus-data-pos d))
6466 (gnus-delete-line))))))
6467 ;; Remove list identifiers from subject.
6468 (when gnus-list-identifiers
6469 (let ((gnus-newsgroup-headers (list header)))
6470 (gnus-summary-remove-list-identifiers)))
6472 (mail-header-set-number header (mail-header-number old-header)))
6473 (setq gnus-newsgroup-sparse
6474 (delq (setq number (mail-header-number header))
6475 gnus-newsgroup-sparse))
6476 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6477 (push number gnus-newsgroup-limit)
6478 (gnus-rebuild-thread (mail-header-id header) line)
6479 (gnus-summary-goto-subject number nil t))
6480 (when (and (numberp number)
6482 ;; We have to update the boundaries even if we can't fetch the
6483 ;; article if ID is a number -- so that the next `P' or `N'
6484 ;; command will fetch the previous (or next) article even
6485 ;; if the one we tried to fetch this time has been canceled.
6486 (when (> number gnus-newsgroup-end)
6487 (setq gnus-newsgroup-end number))
6488 (when (< number gnus-newsgroup-begin)
6489 (setq gnus-newsgroup-begin number))
6490 (setq gnus-newsgroup-unselected
6491 (delq number gnus-newsgroup-unselected)))
6492 ;; Report back a success?
6493 (and header (mail-header-number header))))
6495 ;;; Process/prefix in the summary buffer
6497 (defun gnus-summary-work-articles (n)
6498 "Return a list of articles to be worked upon.
6499 The prefix argument, the list of process marked articles, and the
6500 current article will be taken into consideration."
6501 (with-current-buffer gnus-summary-buffer
6504 ;; A numerical prefix has been given.
6505 (setq n (prefix-numeric-value n))
6506 (let ((backward (< n 0))
6507 (n (abs (prefix-numeric-value n)))
6512 (push (setq article (gnus-summary-article-number))
6515 (gnus-summary-find-prev nil article)
6516 (gnus-summary-find-next nil article)))
6518 (nreverse articles)))
6519 ((and (gnus-region-active-p) (mark))
6520 (message "region active")
6521 ;; Work on the region between point and mark.
6522 (let ((max (max (point) (mark)))
6525 (goto-char (min (point) (mark)))
6528 (push (setq article (gnus-summary-article-number)) articles)
6529 (gnus-summary-find-next nil article)
6531 (nreverse articles))))
6532 (gnus-newsgroup-processable
6533 ;; There are process-marked articles present.
6534 ;; Save current state.
6535 (gnus-summary-save-process-mark)
6537 (reverse gnus-newsgroup-processable))
6539 ;; Just return the current article.
6540 (list (gnus-summary-article-number))))))
6542 (defmacro gnus-summary-iterate (arg &rest forms)
6543 "Iterate over the process/prefixed articles and do FORMS.
6544 ARG is the interactive prefix given to the command. FORMS will be
6545 executed with point over the summary line of the articles."
6546 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6547 `(let ((,articles (gnus-summary-work-articles ,arg)))
6549 (gnus-summary-goto-subject (car ,articles))
6553 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6554 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6556 (defun gnus-summary-save-process-mark ()
6557 "Push the current set of process marked articles on the stack."
6559 (push (copy-sequence gnus-newsgroup-processable)
6560 gnus-newsgroup-process-stack))
6562 (defun gnus-summary-kill-process-mark ()
6563 "Push the current set of process marked articles on the stack and unmark."
6565 (gnus-summary-save-process-mark)
6566 (gnus-summary-unmark-all-processable))
6568 (defun gnus-summary-yank-process-mark ()
6569 "Pop the last process mark state off the stack and restore it."
6571 (unless gnus-newsgroup-process-stack
6572 (error "Empty mark stack"))
6573 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6575 (defun gnus-summary-process-mark-set (set)
6576 "Make SET into the current process marked articles."
6577 (gnus-summary-unmark-all-processable)
6578 (mapc 'gnus-summary-set-process-mark set))
6580 ;;; Searching and stuff
6582 (defun gnus-summary-search-group (&optional backward use-level)
6583 "Search for next unread newsgroup.
6584 If optional argument BACKWARD is non-nil, search backward instead."
6585 (with-current-buffer gnus-group-buffer
6586 (when (gnus-group-search-forward
6587 backward nil (if use-level (gnus-group-group-level) nil))
6588 (gnus-group-group-name))))
6590 (defun gnus-summary-best-group (&optional exclude-group)
6591 "Find the name of the best unread group.
6592 If EXCLUDE-GROUP, do not go to this group."
6593 (with-current-buffer gnus-group-buffer
6595 (gnus-group-best-unread-group exclude-group))))
6597 (defun gnus-summary-find-next (&optional unread article backward)
6599 (gnus-summary-find-prev unread article)
6600 (let* ((dummy (gnus-summary-article-intangible-p))
6601 (article (or article (gnus-summary-article-number)))
6602 (data (gnus-data-find-list article))
6604 (when (and (not dummy)
6605 (or (not gnus-summary-check-current)
6607 (not (gnus-data-unread-p (car data)))))
6608 (setq data (cdr data)))
6613 (unless (memq (gnus-data-number (car data))
6615 ((eq gnus-auto-goto-ignores
6616 'always-undownloaded)
6617 gnus-newsgroup-undownloaded)
6620 ((eq gnus-auto-goto-ignores
6622 gnus-newsgroup-unfetched)
6623 ((eq gnus-auto-goto-ignores
6625 gnus-newsgroup-undownloaded)))
6626 (when (gnus-data-unread-p (car data))
6627 (setq result (car data)
6629 (setq data (cdr data)))
6632 (goto-char (gnus-data-pos result))
6633 (gnus-data-number result)))))
6635 (defun gnus-summary-find-prev (&optional unread article)
6636 (let* ((eobp (eobp))
6637 (article (or article (gnus-summary-article-number)))
6638 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6640 (when (and (not eobp)
6641 (or (not gnus-summary-check-current)
6643 (not (gnus-data-unread-p (car data)))))
6644 (setq data (cdr data)))
6649 (unless (memq (gnus-data-number (car data))
6651 ((eq gnus-auto-goto-ignores
6652 'always-undownloaded)
6653 gnus-newsgroup-undownloaded)
6656 ((eq gnus-auto-goto-ignores
6658 gnus-newsgroup-unfetched)
6659 ((eq gnus-auto-goto-ignores
6661 gnus-newsgroup-undownloaded)))
6662 (when (gnus-data-unread-p (car data))
6663 (setq result (car data)
6665 (setq data (cdr data)))
6668 (goto-char (gnus-data-pos result))
6669 (gnus-data-number result))))
6671 (defun gnus-summary-find-subject (subject &optional unread backward article)
6672 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6673 (article (or article (gnus-summary-article-number)))
6674 (articles (gnus-data-list backward))
6675 (arts (gnus-data-find-list article articles))
6677 (when (or (not gnus-summary-check-current)
6679 (not (gnus-data-unread-p (car arts))))
6680 (setq arts (cdr arts)))
6682 (and (or (not unread)
6683 (gnus-data-unread-p (car arts)))
6684 (vectorp (gnus-data-header (car arts)))
6686 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6687 (setq result (car arts)
6689 (setq arts (cdr arts)))
6691 (goto-char (gnus-data-pos result))
6692 (gnus-data-number result))))
6694 (defun gnus-summary-search-forward (&optional unread subject backward)
6695 "Search forward for an article.
6696 If UNREAD, look for unread articles. If SUBJECT, look for
6697 articles with that subject. If BACKWARD, search backward instead."
6698 (cond (subject (gnus-summary-find-subject subject unread backward))
6699 (backward (gnus-summary-find-prev unread))
6700 (t (gnus-summary-find-next unread))))
6702 (defun gnus-recenter (&optional n)
6703 "Center point in window and redisplay frame.
6704 Also do horizontal recentering."
6706 (when (and gnus-auto-center-summary
6707 (not (eq gnus-auto-center-summary 'vertical)))
6708 (gnus-horizontal-recenter))
6711 (defun gnus-summary-recenter ()
6712 "Center point in the summary window.
6713 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6714 displayed, no centering will be performed."
6715 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6716 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6718 ;; The user has to want it.
6719 (when gnus-auto-center-summary
6720 (let* ((top (cond ((< (window-height) 4) 0)
6721 ((< (window-height) 7) 1)
6722 (t (if (numberp gnus-auto-center-summary)
6723 gnus-auto-center-summary
6724 (/ (1- (window-height)) 2)))))
6725 (height (1- (window-height)))
6726 (bottom (save-excursion (goto-char (point-max))
6727 (forward-line (- height))
6729 (window (get-buffer-window (current-buffer))))
6730 (when (get-buffer-window gnus-article-buffer)
6731 ;; Only do recentering when the article buffer is displayed,
6732 ;; Set the window start to either `bottom', which is the biggest
6733 ;; possible valid number, or the second line from the top,
6734 ;; whichever is the least.
6735 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6736 (if (> bottom top-pos)
6737 ;; Keep the second line from the top visible
6738 (set-window-start window top-pos)
6739 ;; Try to keep the bottom line visible; if it's partially
6740 ;; obscured, either scroll one more line to make it fully
6741 ;; visible, or revert to using TOP-POS.
6743 (goto-char (point-max))
6745 (let ((last-line-start (point)))
6747 (set-window-start window (point) t)
6748 (when (not (pos-visible-in-window-p last-line-start window))
6750 (set-window-start window (min (point) top-pos) t)))))))
6751 ;; Do horizontal recentering while we're at it.
6752 (when (and (get-buffer-window (current-buffer) t)
6753 (not (eq gnus-auto-center-summary 'vertical)))
6754 (let ((selected (selected-window)))
6755 (select-window (get-buffer-window (current-buffer) t))
6756 (gnus-summary-position-point)
6757 (gnus-horizontal-recenter)
6758 (select-window selected))))))
6760 (defun gnus-summary-jump-to-group (newsgroup)
6761 "Move point to NEWSGROUP in group mode buffer."
6762 ;; Keep update point of group mode buffer if visible.
6763 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6764 (save-window-excursion
6765 ;; Take care of tree window mode.
6766 (when (get-buffer-window gnus-group-buffer)
6767 (pop-to-buffer gnus-group-buffer))
6768 (gnus-group-jump-to-group newsgroup))
6770 ;; Take care of tree window mode.
6771 (if (get-buffer-window gnus-group-buffer 0)
6772 (pop-to-buffer gnus-group-buffer)
6773 (set-buffer gnus-group-buffer))
6774 (gnus-group-jump-to-group newsgroup))))
6776 ;; This function returns a list of article numbers based on the
6777 ;; difference between the ranges of read articles in this group and
6778 ;; the range of active articles.
6779 (defun gnus-list-of-unread-articles (group)
6780 (let* ((read (gnus-info-read (gnus-get-info group)))
6781 (active (or (gnus-active group) (gnus-activate-group group)))
6782 (last (or (cdr active)
6783 (error "Group %s couldn't be activated " group)))
6784 (bottom (if gnus-newsgroup-maximum-articles
6786 (- last gnus-newsgroup-maximum-articles -1))
6789 ;; If none are read, then all are unread.
6792 ;; If the range of read articles is a single range, then the
6793 ;; first unread article is the article after the last read
6794 ;; article. Sounds logical, doesn't it?
6795 (if (and (not (listp (cdr read)))
6796 (or (< (car read) bottom)
6797 (progn (setq read (list read))
6799 (setq first (max bottom (1+ (cdr read))))
6800 ;; `read' is a list of ranges.
6801 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6804 (setq first bottom))
6807 (while (< first nlast)
6808 (setq unread (cons first unread)
6810 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6811 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6812 (setq read (cdr read)))))
6813 ;; And add the last unread articles.
6814 (while (<= first last)
6815 (setq unread (cons first unread)
6817 ;; Return the list of unread articles.
6818 (delq 0 (nreverse unread))))
6820 (defun gnus-list-of-read-articles (group)
6821 "Return a list of unread, unticked and non-dormant articles."
6822 (let* ((info (gnus-get-info group))
6823 (marked (gnus-info-marks info))
6824 (active (gnus-active group)))
6826 (gnus-list-range-difference
6827 (gnus-list-range-difference
6828 (gnus-sorted-complement
6829 (gnus-uncompress-range
6830 (if gnus-newsgroup-maximum-articles
6831 (cons (max (car active)
6833 gnus-newsgroup-maximum-articles
6837 (gnus-list-of-unread-articles group))
6838 (cdr (assq 'dormant marked)))
6839 (cdr (assq 'tick marked))))))
6841 ;; This function returns a sequence of article numbers based on the
6842 ;; difference between the ranges of read articles in this group and
6843 ;; the range of active articles.
6844 (defun gnus-sequence-of-unread-articles (group)
6845 (let* ((read (gnus-info-read (gnus-get-info group)))
6846 (active (or (gnus-active group) (gnus-activate-group group)))
6848 (bottom (if gnus-newsgroup-maximum-articles
6850 (- last gnus-newsgroup-maximum-articles -1))
6853 ;; If none are read, then all are unread.
6856 ;; If the range of read articles is a single range, then the
6857 ;; first unread article is the article after the last read
6858 ;; article. Sounds logical, doesn't it?
6859 (if (and (not (listp (cdr read)))
6860 (or (< (car read) bottom)
6861 (progn (setq read (list read))
6863 (setq first (max bottom (1+ (cdr read))))
6864 ;; `read' is a list of ranges.
6865 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6868 (setq first bottom))
6871 (push (cons first nlast) unread))
6872 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6873 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6874 (setq read (cdr read)))))
6875 ;; And add the last unread articles.
6876 (cond ((not (and first last))
6879 (push (cons first last) unread))
6881 (push first unread)))
6882 ;; Return the sequence of unread articles.
6883 (delq 0 (nreverse unread))))
6885 ;; Various summary commands
6887 (defun gnus-summary-select-article-buffer ()
6888 "Reconfigure windows to show article buffer."
6890 (if (not (gnus-buffer-live-p gnus-article-buffer))
6891 (error "There is no article buffer for this summary buffer")
6892 (gnus-configure-windows 'article)
6893 (select-window (get-buffer-window gnus-article-buffer))))
6895 (defun gnus-summary-universal-argument (arg)
6896 "Perform any operation on all articles that are process/prefixed."
6898 (let ((articles (gnus-summary-work-articles arg))
6905 (substitute-command-keys
6906 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6908 (gnus-error 1 "Undefined key")
6911 (gnus-summary-goto-subject (setq article (pop articles)))
6912 (let (gnus-newsgroup-processable)
6913 (command-execute func))
6914 (gnus-summary-remove-process-mark article)))))
6915 (gnus-summary-position-point))
6917 (defun gnus-summary-toggle-truncation (&optional arg)
6918 "Toggle truncation of summary lines.
6919 With ARG, turn line truncation on if ARG is positive."
6921 (setq truncate-lines
6922 (if (null arg) (not truncate-lines)
6923 (> (prefix-numeric-value arg) 0)))
6926 (defun gnus-summary-find-for-reselect ()
6927 "Return the number of an article to stay on across a reselect.
6928 The current article is considered, then following articles, then previous
6929 articles. An article is sought which is not cancelled and isn't a temporary
6930 insertion from another group. If there's no such then return a dummy 0."
6932 (dolist (rev '(nil t))
6933 (unless found ; don't demand the reverse list if we don't need it
6934 (let ((data (gnus-data-find-list
6935 (gnus-summary-article-number) (gnus-data-list rev))))
6936 (while (and data (not found))
6937 (if (and (< 0 (gnus-data-number (car data)))
6938 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6939 (setq found (gnus-data-number (car data))))
6940 (setq data (cdr data))))))
6943 (defun gnus-summary-reselect-current-group (&optional all rescan)
6944 "Exit and then reselect the current newsgroup.
6945 The prefix argument ALL means to select all articles."
6947 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6948 (error "Ephemeral groups can't be reselected"))
6949 (let ((current-subject (gnus-summary-find-for-reselect))
6950 (group gnus-newsgroup-name))
6951 (setq gnus-newsgroup-begin nil)
6952 (gnus-summary-exit nil 'leave-hidden)
6953 ;; We have to adjust the point of group mode buffer because
6954 ;; point was moved to the next unread newsgroup by exiting.
6955 (gnus-summary-jump-to-group group)
6958 (gnus-group-get-new-news-this-group 1)))
6959 (gnus-group-read-group all t)
6960 (gnus-summary-goto-subject current-subject nil t)))
6962 (defun gnus-summary-rescan-group (&optional all)
6963 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6965 (gnus-summary-reselect-current-group all t))
6967 (defun gnus-summary-update-info (&optional non-destructive)
6969 (let ((group gnus-newsgroup-name))
6971 (when gnus-newsgroup-kill-headers
6972 (setq gnus-newsgroup-killed
6973 (gnus-compress-sequence
6975 (gnus-list-range-intersection
6976 gnus-newsgroup-unselected gnus-newsgroup-killed)
6977 gnus-newsgroup-unreads)
6979 (unless (listp (cdr gnus-newsgroup-killed))
6980 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6981 (let ((headers gnus-newsgroup-headers))
6982 ;; Set the new ranges of read articles.
6983 (with-current-buffer gnus-group-buffer
6984 (gnus-undo-force-boundary))
6985 (gnus-update-read-articles
6986 group (gnus-sorted-union
6987 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6988 ;; Set the current article marks.
6989 (let ((gnus-newsgroup-scored
6990 (if (and (not gnus-save-score)
6991 (not non-destructive))
6993 gnus-newsgroup-scored)))
6995 (gnus-update-marks)))
6996 ;; Do the cross-ref thing.
6997 (when gnus-use-cross-reference
6998 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6999 ;; Do not switch windows but change the buffer to work.
7000 (set-buffer gnus-group-buffer)
7001 (unless (gnus-ephemeral-group-p group)
7002 (gnus-group-update-group group)))))))
7004 (defun gnus-summary-save-newsrc (&optional force)
7005 "Save the current number of read/marked articles in the dribble buffer.
7006 The dribble buffer will then be saved.
7007 If FORCE (the prefix), also save the .newsrc file(s)."
7009 (gnus-summary-update-info t)
7011 (gnus-save-newsrc-file)
7012 (gnus-dribble-save)))
7014 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7016 (defun gnus-summary-exit (&optional temporary leave-hidden)
7017 "Exit reading current newsgroup, and then return to group selection mode.
7018 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7020 (gnus-set-global-variables)
7021 (when (gnus-buffer-live-p gnus-article-buffer)
7022 (with-current-buffer gnus-article-buffer
7023 (mm-destroy-parts gnus-article-mime-handles)
7024 ;; Set it to nil for safety reason.
7025 (setq gnus-article-mime-handle-alist nil)
7026 (setq gnus-article-mime-handles nil)))
7027 (gnus-kill-save-kill-buffer)
7028 (gnus-async-halt-prefetch)
7029 (let* ((group gnus-newsgroup-name)
7030 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7031 (gnus-group-is-exiting-p t)
7034 (buf (current-buffer)))
7036 ;; Do adaptive scoring, and possibly save score files.
7037 (when gnus-newsgroup-adaptive
7038 (gnus-score-adaptive))
7039 (when gnus-use-scoring
7041 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7042 ;; If we have several article buffers, we kill them at exit.
7043 (unless gnus-single-article-buffer
7044 (when (gnus-buffer-live-p gnus-article-buffer)
7045 (with-current-buffer gnus-article-buffer
7046 ;; Don't kill sticky article buffers
7047 (unless (eq major-mode 'gnus-sticky-article-mode)
7048 (gnus-kill-buffer gnus-article-buffer)
7049 (setq gnus-article-current nil))))
7050 (gnus-kill-buffer gnus-original-article-buffer))
7051 (when gnus-use-cache
7052 (gnus-cache-possibly-remove-articles)
7053 (gnus-cache-save-buffers))
7054 (gnus-async-prefetch-remove-group group)
7055 (when gnus-suppress-duplicates
7056 (gnus-dup-enter-articles))
7057 (when gnus-use-trees
7058 (gnus-tree-close group))
7059 (when gnus-use-cache
7060 (gnus-cache-write-active))
7061 ;; Remove entries for this group.
7062 (nnmail-purge-split-history (gnus-group-real-name group))
7063 ;; Make all changes in this group permanent.
7065 (gnus-run-hooks 'gnus-exit-group-hook)
7066 (gnus-summary-update-info))
7067 (gnus-close-group group)
7068 ;; Make sure where we were, and go to next newsgroup.
7069 (set-buffer gnus-group-buffer)
7071 (gnus-group-jump-to-group group))
7072 (gnus-run-hooks 'gnus-summary-exit-hook)
7073 (unless (or quit-config
7074 (not gnus-summary-next-group-on-exit)
7075 ;; If this group has disappeared from the summary
7076 ;; buffer, don't skip forwards.
7077 (not (string= group (gnus-group-group-name))))
7078 (gnus-group-next-unread-group 1))
7079 (setq group-point (point))
7083 (if (not gnus-kill-summary-on-exit)
7085 (gnus-deaden-summary)
7087 ;; We set all buffer-local variables to nil. It is unclear why
7088 ;; this is needed, but if we don't, buffer-local variables are
7089 ;; not garbage-collected, it seems. This would the lead to en
7090 ;; ever-growing Emacs.
7091 (gnus-summary-clear-local-variables)
7092 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7093 (gnus-summary-clear-local-variables))
7094 (when (get-buffer gnus-article-buffer)
7095 (bury-buffer gnus-article-buffer))
7096 ;; Return to group mode buffer.
7097 (when (eq mode 'gnus-summary-mode)
7098 (gnus-kill-buffer buf)))
7099 (setq gnus-current-select-method gnus-select-method)
7100 (set-buffer gnus-group-buffer)
7102 (gnus-handle-ephemeral-exit quit-config)
7103 (goto-char group-point)
7104 ;; If gnus-group-buffer is already displayed, make sure we also move
7105 ;; the cursor in the window that displays it.
7106 (let ((win (get-buffer-window (current-buffer) 0)))
7107 (if win (set-window-point win (point))))
7108 (unless leave-hidden
7109 (gnus-configure-windows 'group 'force)))
7110 ;; Clear the current group name.
7112 (setq gnus-newsgroup-name nil)))))
7114 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7115 (defun gnus-summary-exit-no-update (&optional no-questions)
7116 "Quit reading current newsgroup without updating read article info."
7118 (let* ((group gnus-newsgroup-name)
7119 (gnus-group-is-exiting-p t)
7120 (gnus-group-is-exiting-without-update-p t)
7121 (quit-config (gnus-group-quit-config group)))
7122 (when (or no-questions
7124 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7125 (gnus-async-halt-prefetch)
7126 (run-hooks 'gnus-summary-prepare-exit-hook)
7127 (when (gnus-buffer-live-p gnus-article-buffer)
7128 (with-current-buffer gnus-article-buffer
7129 (mm-destroy-parts gnus-article-mime-handles)
7130 ;; Set it to nil for safety reason.
7131 (setq gnus-article-mime-handle-alist nil)
7132 (setq gnus-article-mime-handles nil)))
7133 ;; If we have several article buffers, we kill them at exit.
7134 (unless gnus-single-article-buffer
7135 (gnus-kill-buffer gnus-article-buffer)
7136 (gnus-kill-buffer gnus-original-article-buffer)
7137 (setq gnus-article-current nil))
7138 (if (not gnus-kill-summary-on-exit)
7139 (gnus-deaden-summary)
7140 (gnus-close-group group)
7141 (gnus-summary-clear-local-variables)
7142 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7143 (gnus-summary-clear-local-variables))
7144 (gnus-kill-buffer gnus-summary-buffer))
7145 (unless gnus-single-article-buffer
7146 (setq gnus-article-current nil))
7147 (when gnus-use-trees
7148 (gnus-tree-close group))
7149 (gnus-async-prefetch-remove-group group)
7150 (when (get-buffer gnus-article-buffer)
7151 (bury-buffer gnus-article-buffer))
7152 ;; Return to the group buffer.
7153 (gnus-configure-windows 'group 'force)
7154 ;; Clear the current group name.
7155 (setq gnus-newsgroup-name nil)
7156 (unless (gnus-ephemeral-group-p group)
7157 (gnus-group-update-group group))
7158 (when (equal (gnus-group-group-name) group)
7159 (gnus-group-next-unread-group 1))
7161 (gnus-handle-ephemeral-exit quit-config)))))
7163 (defun gnus-handle-ephemeral-exit (quit-config)
7164 "Handle movement when leaving an ephemeral group.
7165 The state which existed when entering the ephemeral is reset."
7166 (if (not (buffer-name (car quit-config)))
7167 (gnus-configure-windows 'group 'force)
7168 (set-buffer (car quit-config))
7169 (cond ((eq major-mode 'gnus-summary-mode)
7170 (gnus-set-global-variables))
7171 ((eq major-mode 'gnus-article-mode)
7172 (save-current-buffer
7173 ;; The `gnus-summary-buffer' variable may point
7174 ;; to the old summary buffer when using a single
7176 (unless (gnus-buffer-live-p gnus-summary-buffer)
7177 (set-buffer gnus-group-buffer))
7178 (set-buffer gnus-summary-buffer)
7179 (gnus-set-global-variables))))
7180 (if (or (eq (cdr quit-config) 'article)
7181 (eq (cdr quit-config) 'pick))
7182 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7183 (gnus-configure-windows 'pick 'force)
7184 (gnus-configure-windows (cdr quit-config) 'force))
7185 (gnus-configure-windows (cdr quit-config) 'force))
7186 (when (eq major-mode 'gnus-summary-mode)
7187 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7188 next-unread-noselect))
7189 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7191 (gnus-summary-next-subject 1 nil t))
7192 ((eq gnus-auto-select-on-ephemeral-exit
7193 'next-unread-noselect)
7194 (gnus-summary-next-subject 1 t t))))
7195 ;; Hide the article buffer which displays the article different
7196 ;; from the one that the cursor points to in the summary buffer.
7197 (gnus-configure-windows 'summary 'force))
7198 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7199 (gnus-summary-next-subject 1))
7200 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7201 (gnus-summary-next-subject 1 t))))
7202 (gnus-summary-recenter)
7203 (gnus-summary-position-point))))
7207 (defvar gnus-dead-summary-mode-map nil)
7209 (unless gnus-dead-summary-mode-map
7210 (setq gnus-dead-summary-mode-map (make-keymap))
7211 (suppress-keymap gnus-dead-summary-mode-map)
7212 (substitute-key-definition
7213 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
7214 (dolist (key '("\C-d" "\r" "\177" [delete]))
7215 (define-key gnus-dead-summary-mode-map
7216 key 'gnus-summary-wake-up-the-dead))
7217 (dolist (key '("q" "Q"))
7218 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
7220 (defvar gnus-dead-summary-mode nil
7221 "Minor mode for Gnus summary buffers.")
7223 (defun gnus-dead-summary-mode (&optional arg)
7224 "Minor mode for Gnus summary buffers."
7226 (when (eq major-mode 'gnus-summary-mode)
7227 (make-local-variable 'gnus-dead-summary-mode)
7228 (setq gnus-dead-summary-mode
7229 (if (null arg) (not gnus-dead-summary-mode)
7230 (> (prefix-numeric-value arg) 0)))
7231 (when gnus-dead-summary-mode
7233 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
7235 (defun gnus-deaden-summary ()
7236 "Make the current summary buffer into a dead summary buffer."
7237 ;; Kill any previous dead summary buffer.
7238 (when (and gnus-dead-summary
7239 (buffer-name gnus-dead-summary))
7240 (with-current-buffer gnus-dead-summary
7241 (when gnus-dead-summary-mode
7242 (kill-buffer (current-buffer)))))
7243 ;; Make this the current dead summary.
7244 (setq gnus-dead-summary (current-buffer))
7245 (gnus-dead-summary-mode 1)
7246 (let ((name (buffer-name)))
7247 (when (string-match "Summary" name)
7249 (concat (substring name 0 (match-beginning 0)) "Dead "
7250 (substring name (match-beginning 0)))
7254 (defun gnus-kill-or-deaden-summary (buffer)
7255 "Kill or deaden the summary BUFFER."
7257 (when (and (buffer-name buffer)
7258 (not gnus-single-article-buffer))
7259 (with-current-buffer buffer
7260 (gnus-kill-buffer gnus-article-buffer)
7261 (gnus-kill-buffer gnus-original-article-buffer)))
7264 (gnus-kill-summary-on-exit
7265 (when (and gnus-use-trees
7266 (gnus-buffer-exists-p buffer))
7267 (with-current-buffer buffer
7268 (gnus-tree-close gnus-newsgroup-name)))
7269 (gnus-kill-buffer buffer))
7270 ;; Deaden the buffer.
7271 ((gnus-buffer-exists-p buffer)
7272 (with-current-buffer buffer
7273 (gnus-deaden-summary))))))
7275 (defun gnus-summary-wake-up-the-dead (&rest args)
7276 "Wake up the dead summary buffer."
7278 (gnus-dead-summary-mode -1)
7279 (let ((name (buffer-name)))
7280 (when (string-match "Dead " name)
7282 (concat (substring name 0 (match-beginning 0))
7283 (substring name (match-end 0)))
7285 (gnus-message 3 "This dead summary is now alive again"))
7287 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7288 (defun gnus-summary-fetch-faq (&optional faq-dir)
7289 "Fetch the FAQ for the current group.
7290 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7294 (when current-prefix-arg
7296 "FAQ dir: " (and (listp gnus-group-faq-directory)
7298 gnus-group-faq-directory))))))
7299 (let (gnus-faq-buffer)
7300 (when (setq gnus-faq-buffer
7301 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7302 (gnus-configure-windows 'summary-faq))))
7304 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7305 (defun gnus-summary-describe-group (&optional force)
7306 "Describe the current newsgroup."
7308 (gnus-group-describe-group force gnus-newsgroup-name))
7310 (defun gnus-summary-describe-briefly ()
7311 "Describe summary mode commands briefly."
7313 (gnus-message 6 (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")))
7315 ;; Walking around group mode buffer from summary mode.
7317 (defun gnus-summary-next-group (&optional no-article target-group backward)
7318 "Exit current newsgroup and then select next unread newsgroup.
7319 If prefix argument NO-ARTICLE is non-nil, no article is selected
7320 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7321 previous group instead."
7323 ;; Stop pre-fetching.
7324 (gnus-async-halt-prefetch)
7325 (let ((current-group gnus-newsgroup-name)
7326 (current-buffer (current-buffer))
7328 ;; First we semi-exit this group to update Xrefs and all variables.
7329 ;; We can't do a real exit, because the window conf must remain
7330 ;; the same in case the user is prompted for info, and we don't
7331 ;; want the window conf to change before that...
7332 (gnus-summary-exit t)
7333 (while (not entered)
7334 ;; Then we find what group we are supposed to enter.
7335 (set-buffer gnus-group-buffer)
7336 (gnus-group-jump-to-group current-group)
7339 (if (eq gnus-keep-same-level 'best)
7340 (gnus-summary-best-group gnus-newsgroup-name)
7341 (gnus-summary-search-group backward gnus-keep-same-level))))
7342 (if (not target-group)
7343 ;; There are no further groups, so we return to the group
7346 (gnus-message 5 "Returning to the group buffer")
7348 (when (gnus-buffer-live-p current-buffer)
7349 (set-buffer current-buffer)
7350 (gnus-summary-exit))
7351 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7352 ;; We try to enter the target group.
7353 (gnus-group-jump-to-group target-group)
7354 (let ((unreads (gnus-group-group-unread)))
7355 (if (and (or (eq t unreads)
7356 (and unreads (not (zerop unreads))))
7357 (gnus-summary-read-group
7358 target-group nil no-article
7359 (and (buffer-name current-buffer) current-buffer)
7362 (setq current-group target-group
7363 target-group nil)))))))
7365 (defun gnus-summary-prev-group (&optional no-article)
7366 "Exit current newsgroup and then select previous unread newsgroup.
7367 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7369 (gnus-summary-next-group no-article nil t))
7371 ;; Walking around summary lines.
7373 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7374 "Go to the first subject satisfying any non-nil constraint.
7375 If UNREAD is non-nil, the article should be unread.
7376 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7377 If UNSEEN is non-nil, the article should be unseen.
7378 Returns the article selected or nil if there are no matching articles."
7382 ((null gnus-newsgroup-data)
7383 (gnus-message 3 "No articles in the group")
7385 ;; Pick the first article.
7386 ((not (or unread undownloaded unseen))
7387 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7388 (gnus-data-number (car gnus-newsgroup-data)))
7389 ;; Find the first unread article.
7391 (let ((data gnus-newsgroup-data))
7393 (let ((num (gnus-data-number (car data))))
7394 (or (memq num gnus-newsgroup-unfetched)
7395 (not (or (and unread
7396 (memq num gnus-newsgroup-unreads))
7398 (memq num gnus-newsgroup-undownloaded))
7400 (memq num gnus-newsgroup-unseen)))))))
7401 (setq data (cdr data)))
7405 (goto-char (gnus-data-pos (car data)))
7406 (gnus-data-number (car data)))
7407 (gnus-message 3 "No more%s articles"
7408 (let* ((r (when unread " unread"))
7409 (d (when undownloaded " undownloaded"))
7410 (s (when unseen " unseen"))
7411 (l (delq nil (list r d s))))
7412 (cond ((= 3 (length l))
7413 (concat r "," d ", or" s))
7415 (concat (car l) ", or" (cadr l)))
7422 (gnus-summary-position-point))))))
7424 (defun gnus-summary-next-subject (n &optional unread dont-display)
7425 "Go to next N'th summary line.
7426 If N is negative, go to the previous N'th subject line.
7427 If UNREAD is non-nil, only unread articles are selected.
7428 The difference between N and the actual number of steps taken is
7431 (let ((backward (< n 0))
7435 (gnus-summary-find-prev unread)
7436 (gnus-summary-find-next unread)))
7437 (unless (zerop (setq n (1- n)))
7438 (gnus-summary-show-thread)))
7440 (gnus-message 7 "No more%s articles"
7441 (if unread " unread" "")))
7442 (unless dont-display
7443 (gnus-summary-recenter)
7444 (gnus-summary-position-point))
7447 (defun gnus-summary-next-unread-subject (n)
7448 "Go to next N'th unread summary line."
7450 (gnus-summary-next-subject n t))
7452 (defun gnus-summary-prev-subject (n &optional unread)
7453 "Go to previous N'th summary line.
7454 If optional argument UNREAD is non-nil, only unread article is selected."
7456 (gnus-summary-next-subject (- n) unread))
7458 (defun gnus-summary-prev-unread-subject (n)
7459 "Go to previous N'th unread summary line."
7461 (gnus-summary-next-subject (- n) t))
7463 (defun gnus-summary-goto-subjects (articles)
7464 "Insert the subject header for ARTICLES in the current buffer."
7466 (dolist (article articles)
7467 (gnus-summary-goto-subject article t)))
7468 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7469 (gnus-summary-position-point))
7471 (defun gnus-summary-goto-subject (article &optional force silent)
7472 "Go to the subject line of ARTICLE.
7473 If FORCE, also allow jumping to articles not currently shown."
7474 (interactive "nArticle number: ")
7475 (unless (numberp article)
7476 (error "Article %s is not a number" article))
7478 (data (gnus-data-find article)))
7479 ;; We read in the article if we have to.
7482 (gnus-summary-insert-subject
7484 (if (or (numberp force) (vectorp force)) force)
7486 (setq data (gnus-data-find article)))
7491 (gnus-message 3 "Can't find article %d" article))
7493 (let ((pt (gnus-data-pos data)))
7495 (gnus-summary-set-article-display-arrow pt))
7496 (gnus-summary-position-point)
7499 ;; Walking around summary lines with displaying articles.
7501 (defun gnus-summary-expand-window (&optional arg)
7502 "Make the summary buffer take up the entire Emacs frame.
7503 Given a prefix, will force an `article' buffer configuration."
7506 (gnus-configure-windows 'article 'force)
7507 (gnus-configure-windows 'summary 'force)))
7509 (defun gnus-summary-display-article (article &optional all-header)
7510 "Display ARTICLE in article buffer."
7511 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7512 (with-current-buffer gnus-article-buffer
7513 (eq major-mode 'gnus-article-mode)))
7514 (gnus-article-setup-buffer))
7515 (gnus-set-global-variables)
7516 (with-current-buffer gnus-article-buffer
7517 (setq gnus-article-charset gnus-newsgroup-charset)
7518 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7519 (mm-enable-multibyte))
7523 (if gnus-summary-display-article-function
7524 (funcall gnus-summary-display-article-function article all-header)
7525 (gnus-article-prepare article all-header))
7526 (gnus-run-hooks 'gnus-select-article-hook)
7527 (when (and gnus-current-article
7528 (not (zerop gnus-current-article)))
7529 (gnus-summary-goto-subject gnus-current-article))
7530 (gnus-summary-recenter)
7531 (when (and gnus-use-trees gnus-show-threads)
7532 (gnus-possibly-generate-tree article)
7533 (gnus-highlight-selected-tree article))
7534 ;; Successfully display article.
7535 (gnus-article-set-window-start
7536 (cdr (assq article gnus-newsgroup-bookmarks))))))
7538 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7539 "Select the current article.
7540 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7541 non-nil, the article will be re-fetched even if it already present in
7542 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7544 ;; Make sure we are in the summary buffer to work around bbdb bug.
7545 (unless (eq major-mode 'gnus-summary-mode)
7546 (set-buffer gnus-summary-buffer))
7547 (let ((article (or article (gnus-summary-article-number)))
7548 (all-headers (not (not all-headers))) ;Must be t or nil.
7549 gnus-summary-display-article-function)
7551 (gnus-summary-article-pseudo-p article)
7552 (error "This is a pseudo-article"))
7553 (with-current-buffer gnus-summary-buffer
7554 (if (or (and gnus-single-article-buffer
7555 (or (null gnus-current-article)
7556 (null gnus-article-current)
7557 (null (get-buffer gnus-article-buffer))
7558 (not (eq article (cdr gnus-article-current)))
7559 (not (equal (car gnus-article-current)
7560 gnus-newsgroup-name))))
7561 (and (not gnus-single-article-buffer)
7562 (or (null gnus-current-article)
7563 (not (eq gnus-current-article article))))
7565 ;; The requested article is different from the current article.
7567 (gnus-summary-display-article article all-headers)
7568 (when (gnus-buffer-live-p gnus-article-buffer)
7569 (with-current-buffer gnus-article-buffer
7570 (if (not gnus-article-decoded-p) ;; a local variable
7571 (mm-disable-multibyte))))
7572 (gnus-article-set-window-start
7573 (cdr (assq article gnus-newsgroup-bookmarks)))
7577 (defun gnus-summary-force-verify-and-decrypt ()
7578 "Display buttons for signed/encrypted parts and verify/decrypt them."
7580 (let ((mm-verify-option 'known)
7581 (mm-decrypt-option 'known)
7582 (gnus-article-emulate-mime t)
7583 (gnus-buttonized-mime-types (append (list "multipart/signed"
7584 "multipart/encrypted")
7585 gnus-buttonized-mime-types)))
7586 (gnus-summary-select-article nil 'force)))
7588 (defun gnus-summary-set-current-mark (&optional current-mark)
7589 "Obsolete function."
7592 (defun gnus-summary-next-article (&optional unread subject backward push)
7593 "Select the next article.
7594 If UNREAD, only unread articles are selected.
7595 If SUBJECT, only articles with SUBJECT are selected.
7596 If BACKWARD, the previous article is selected instead of the next."
7598 ;; Make sure we are in the summary buffer.
7599 (unless (eq major-mode 'gnus-summary-mode)
7600 (set-buffer gnus-summary-buffer))
7602 ;; Is there such an article?
7603 ((and (gnus-summary-search-forward unread subject backward)
7604 (or (gnus-summary-display-article (gnus-summary-article-number))
7605 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7606 (gnus-summary-position-point))
7607 ;; If not, we try the first unread, if that is wanted.
7609 gnus-auto-select-same
7610 (gnus-summary-first-unread-article))
7611 (gnus-summary-position-point)
7612 (gnus-message 6 "Wrapped"))
7613 ;; Try to get next/previous article not displayed in this group.
7614 ((and gnus-auto-extend-newsgroup
7615 (not unread) (not subject))
7616 (gnus-summary-goto-article
7617 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7618 nil (count-lines (point-min) (point))))
7619 ;; Go to next/previous group.
7621 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7622 (gnus-summary-jump-to-group gnus-newsgroup-name))
7623 (let ((cmd last-command-char)
7625 (with-current-buffer gnus-group-buffer
7628 (if (eq gnus-keep-same-level 'best)
7629 (gnus-summary-best-group gnus-newsgroup-name)
7630 (gnus-summary-search-group backward gnus-keep-same-level))))
7631 ;; For some reason, the group window gets selected. We change
7633 (select-window (get-buffer-window (current-buffer)))
7634 ;; Select next unread newsgroup automagically.
7636 ((or (not gnus-auto-select-next)
7638 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7639 ((or (eq gnus-auto-select-next 'quietly)
7640 (and (eq gnus-auto-select-next 'slightly-quietly)
7642 (and (eq gnus-auto-select-next 'almost-quietly)
7643 (gnus-summary-last-article-p)))
7645 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7647 (gnus-message 7 "No more%s articles (%s)..."
7648 (if unread " unread" "")
7649 (if group (concat "selecting " group)
7651 (gnus-summary-next-group nil group backward)))
7653 (when (gnus-key-press-event-p last-input-event)
7654 (gnus-summary-walk-group-buffer
7655 gnus-newsgroup-name cmd unread backward point))))))))
7657 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7658 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7659 (?\C-p (gnus-group-prev-unread-group 1))))
7660 (cursor-in-echo-area t)
7661 keve key group ended prompt)
7662 (with-current-buffer gnus-group-buffer
7665 (if (eq gnus-keep-same-level 'best)
7666 (gnus-summary-best-group gnus-newsgroup-name)
7667 (gnus-summary-search-group backward gnus-keep-same-level))))
7671 "No more%s articles%s " (if unread " unread" "")
7673 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7674 (format " (Type %s for %s [%s])"
7675 (single-key-description cmd)
7676 (gnus-group-decoded-name group)
7677 (gnus-group-unread group))
7678 (format " (Type %s to exit %s)"
7679 (single-key-description cmd)
7680 (gnus-group-decoded-name gnus-newsgroup-name)))))
7681 ;; Confirm auto selection.
7682 (setq key (car (setq keve (gnus-read-event-char prompt)))
7685 ((assq key keystrokes)
7686 (let ((obuf (current-buffer)))
7687 (switch-to-buffer gnus-group-buffer)
7689 (gnus-group-jump-to-group group))
7690 (eval (cadr (assq key keystrokes)))
7691 (setq group (gnus-group-group-name))
7692 (switch-to-buffer obuf))
7696 (gnus-ephemeral-group-p gnus-newsgroup-name))
7698 (gnus-summary-next-group nil group backward)))
7700 (push (cdr keve) unread-command-events))))))
7702 (defun gnus-summary-next-unread-article ()
7703 "Select unread article after current one."
7705 (gnus-summary-next-article
7706 (or (not (eq gnus-summary-goto-unread 'never))
7707 (gnus-summary-last-article-p (gnus-summary-article-number)))
7708 (and gnus-auto-select-same
7709 (gnus-summary-article-subject))))
7711 (defun gnus-summary-prev-article (&optional unread subject)
7712 "Select the article before the current one.
7713 If UNREAD is non-nil, only unread articles are selected."
7715 (gnus-summary-next-article unread subject t))
7717 (defun gnus-summary-prev-unread-article ()
7718 "Select unread article before current one."
7720 (gnus-summary-prev-article
7721 (or (not (eq gnus-summary-goto-unread 'never))
7722 (gnus-summary-first-article-p (gnus-summary-article-number)))
7723 (and gnus-auto-select-same
7724 (gnus-summary-article-subject))))
7726 (defun gnus-summary-next-page (&optional lines circular stop)
7727 "Show next page of the selected article.
7728 If at the end of the current article, select the next article.
7729 LINES says how many lines should be scrolled up.
7731 If CIRCULAR is non-nil, go to the start of the article instead of
7732 selecting the next article when reaching the end of the current
7735 If STOP is non-nil, just stop when reaching the end of the message.
7737 Also see the variable `gnus-article-skip-boring'."
7739 (setq gnus-summary-buffer (current-buffer))
7740 (gnus-set-global-variables)
7741 (let ((article (gnus-summary-article-number))
7742 (article-window (get-buffer-window gnus-article-buffer t))
7744 ;; If the buffer is empty, we have no article.
7746 (error "No article to select"))
7747 (gnus-configure-windows 'article)
7748 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7749 (if (and (eq gnus-summary-goto-unread 'never)
7750 (not (gnus-summary-last-article-p article)))
7751 (gnus-summary-next-article)
7752 (gnus-summary-next-unread-article))
7753 (if (or (null gnus-current-article)
7754 (null gnus-article-current)
7755 (/= article (cdr gnus-article-current))
7756 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7757 ;; Selected subject is different from current article's.
7758 (gnus-summary-display-article article)
7759 (when article-window
7760 (gnus-eval-in-buffer-window gnus-article-buffer
7761 (setq endp (or (gnus-article-next-page lines)
7762 (gnus-article-only-boring-p))))
7765 (gnus-message 3 "End of message"))
7767 (gnus-summary-beginning-of-article))
7769 (gnus-message 3 "End of message"))
7771 (if (and (eq gnus-summary-goto-unread 'never)
7772 (not (gnus-summary-last-article-p article)))
7773 (gnus-summary-next-article)
7774 (gnus-summary-next-unread-article))))))))
7775 (gnus-summary-recenter)
7776 (gnus-summary-position-point)))
7778 (defun gnus-summary-prev-page (&optional lines move)
7779 "Show previous page of selected article.
7780 Argument LINES specifies lines to be scrolled down.
7781 If MOVE, move to the previous unread article if point is at
7782 the beginning of the buffer."
7784 (let ((article (gnus-summary-article-number))
7785 (article-window (get-buffer-window gnus-article-buffer t))
7787 (gnus-configure-windows 'article)
7788 (if (or (null gnus-current-article)
7789 (null gnus-article-current)
7790 (/= article (cdr gnus-article-current))
7791 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7792 ;; Selected subject is different from current article's.
7793 (gnus-summary-display-article article)
7794 (gnus-summary-recenter)
7795 (when article-window
7796 (gnus-eval-in-buffer-window gnus-article-buffer
7797 (setq endp (gnus-article-prev-page lines)))
7798 (when (and move endp)
7800 (gnus-message 3 "Beginning of message"))
7802 (if (and (eq gnus-summary-goto-unread 'never)
7803 (not (gnus-summary-first-article-p article)))
7804 (gnus-summary-prev-article)
7805 (gnus-summary-prev-unread-article))))))))
7806 (gnus-summary-position-point))
7808 (defun gnus-summary-prev-page-or-article (&optional lines)
7809 "Show previous page of selected article.
7810 Argument LINES specifies lines to be scrolled down.
7811 If at the beginning of the article, go to the next article."
7813 (gnus-summary-prev-page lines t))
7815 (defun gnus-summary-scroll-up (lines)
7816 "Scroll up (or down) one line current article.
7817 Argument LINES specifies lines to be scrolled up (or down if negative)."
7819 (gnus-configure-windows 'article)
7820 (gnus-summary-show-thread)
7821 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7822 (gnus-eval-in-buffer-window gnus-article-buffer
7824 (when (gnus-article-next-page lines)
7825 (gnus-message 3 "End of message")))
7827 (gnus-article-prev-page (- lines))))))
7828 (gnus-summary-recenter)
7829 (gnus-summary-position-point))
7831 (defun gnus-summary-scroll-down (lines)
7832 "Scroll down (or up) one line current article.
7833 Argument LINES specifies lines to be scrolled down (or up if negative)."
7835 (gnus-summary-scroll-up (- lines)))
7837 (defun gnus-summary-next-same-subject ()
7838 "Select next article which has the same subject as current one."
7840 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7842 (defun gnus-summary-prev-same-subject ()
7843 "Select previous article which has the same subject as current one."
7845 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7847 (defun gnus-summary-next-unread-same-subject ()
7848 "Select next unread article which has the same subject as current one."
7850 (gnus-summary-next-article t (gnus-summary-article-subject)))
7852 (defun gnus-summary-prev-unread-same-subject ()
7853 "Select previous unread article which has the same subject as current one."
7855 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7857 (defun gnus-summary-first-unread-article ()
7858 "Select the first unread article.
7859 Return nil if there are no unread articles."
7862 (when (gnus-summary-first-subject t)
7863 (gnus-summary-show-thread)
7864 (gnus-summary-first-subject t)
7865 (gnus-summary-display-article (gnus-summary-article-number)))
7866 (gnus-summary-position-point)))
7868 (defun gnus-summary-first-unread-subject ()
7869 "Place the point on the subject line of the first unread article.
7870 Return nil if there are no unread articles."
7873 (when (gnus-summary-first-subject t)
7874 (gnus-summary-show-thread)
7875 (gnus-summary-first-subject t))
7876 (gnus-summary-position-point)))
7878 (defun gnus-summary-first-unseen-subject ()
7879 "Place the point on the subject line of the first unseen article.
7880 Return nil if there are no unseen articles."
7883 (when (gnus-summary-first-subject nil nil t)
7884 (gnus-summary-show-thread)
7885 (gnus-summary-first-subject nil nil t))
7886 (gnus-summary-position-point)))
7888 (defun gnus-summary-first-unseen-or-unread-subject ()
7889 "Place the point on the subject line of the first unseen article or,
7890 if all article have been seen, on the subject line of the first unread
7894 (unless (when (gnus-summary-first-subject nil nil t)
7895 (gnus-summary-show-thread)
7896 (gnus-summary-first-subject nil nil t))
7897 (when (gnus-summary-first-subject t)
7898 (gnus-summary-show-thread)
7899 (gnus-summary-first-subject t)))
7900 (gnus-summary-position-point)))
7902 (defun gnus-summary-first-article ()
7903 "Select the first article.
7904 Return nil if there are no articles."
7907 (when (gnus-summary-first-subject)
7908 (gnus-summary-show-thread)
7909 (gnus-summary-first-subject)
7910 (gnus-summary-display-article (gnus-summary-article-number)))
7911 (gnus-summary-position-point)))
7913 (defun gnus-summary-best-unread-article (&optional arg)
7914 "Select the unread article with the highest score.
7915 If given a prefix argument, select the next unread article that has a
7916 score higher than the default score."
7918 (let ((article (if arg
7919 (gnus-summary-better-unread-subject)
7920 (gnus-summary-best-unread-subject))))
7922 (gnus-summary-goto-article article)
7923 (error "No unread articles"))))
7925 (defun gnus-summary-best-unread-subject ()
7926 "Select the unread subject with the highest score."
7928 (let ((best -1000000)
7929 (data gnus-newsgroup-data)
7932 (and (gnus-data-unread-p (car data))
7934 (gnus-summary-article-score (gnus-data-number (car data))))
7937 article (gnus-data-number (car data))))
7938 (setq data (cdr data)))
7940 (gnus-summary-goto-subject article))
7941 (gnus-summary-position-point)
7944 (defun gnus-summary-better-unread-subject ()
7945 "Select the first unread subject that has a score over the default score."
7947 (let ((data gnus-newsgroup-data)
7949 (while (and (setq article (gnus-data-number (car data)))
7950 (or (gnus-data-read-p (car data))
7951 (not (> (gnus-summary-article-score article)
7952 gnus-summary-default-score))))
7953 (setq data (cdr data)))
7955 (gnus-summary-goto-subject article))
7956 (gnus-summary-position-point)
7959 (defun gnus-summary-last-subject ()
7960 "Go to the last displayed subject line in the group."
7961 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7963 (gnus-summary-goto-subject article))))
7965 (defun gnus-summary-goto-article (article &optional all-headers force)
7966 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7967 If ALL-HEADERS is non-nil, no header lines are hidden.
7968 If FORCE, go to the article even if it isn't displayed. If FORCE
7969 is a number, it is the line the article is to be displayed on."
7973 "Article number or Message-ID: "
7974 (mapcar (lambda (number) (list (int-to-string number)))
7975 gnus-newsgroup-limit))
7979 (if (and (stringp article)
7980 (string-match "@\\|%40" article))
7981 (gnus-summary-refer-article article)
7982 (when (stringp article)
7983 (setq article (string-to-number article)))
7984 (if (gnus-summary-goto-subject article force)
7985 (gnus-summary-display-article article all-headers)
7986 (gnus-message 4 "Couldn't go to article %s" article) nil))
7987 (gnus-summary-position-point)))
7989 (defun gnus-summary-goto-last-article ()
7990 "Go to the previously read article."
7993 (when gnus-last-article
7994 (gnus-summary-goto-article gnus-last-article nil t))
7995 (gnus-summary-position-point)))
7997 (defun gnus-summary-pop-article (number)
7998 "Pop one article off the history and go to the previous.
7999 NUMBER articles will be popped off."
8002 (setq gnus-newsgroup-history
8003 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8005 (gnus-summary-goto-article (car to) nil t)
8006 (error "Article history empty")))
8007 (gnus-summary-position-point))
8009 ;; Summary commands and functions for limiting the summary buffer.
8011 (defun gnus-summary-limit-to-articles (n)
8012 "Limit the summary buffer to the next N articles.
8013 If not given a prefix, use the process marked articles instead."
8016 (let ((articles (gnus-summary-work-articles n)))
8017 (setq gnus-newsgroup-processable nil)
8018 (gnus-summary-limit articles))
8019 (gnus-summary-position-point)))
8021 (defun gnus-summary-pop-limit (&optional total)
8022 "Restore the previous limit.
8023 If given a prefix, remove all limits."
8026 (setq gnus-newsgroup-limits
8027 (list (mapcar (lambda (h) (mail-header-number h))
8028 gnus-newsgroup-headers))))
8029 (unless gnus-newsgroup-limits
8030 (error "No limit to pop"))
8032 (gnus-summary-limit nil 'pop)
8033 (gnus-summary-position-point)))
8035 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8036 "Limit the summary buffer to articles that have subjects that match a regexp.
8037 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8039 (list (read-string (if current-prefix-arg
8040 "Exclude subject (regexp): "
8041 "Limit to subject (regexp): "))
8042 nil current-prefix-arg))
8044 (setq header "subject"))
8045 (when (not (equal "" subject))
8047 (let ((articles (gnus-summary-find-matching
8048 (or header "subject") subject 'all nil nil
8051 (error "Found no matches for \"%s\"" subject))
8052 (gnus-summary-limit articles))
8053 (gnus-summary-position-point))))
8055 (defun gnus-summary-limit-to-author (from &optional not-matching)
8056 "Limit the summary buffer to articles that have authors that match a regexp.
8057 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8059 (list (read-string (if current-prefix-arg
8060 "Exclude author (regexp): "
8061 "Limit to author (regexp): "))
8062 current-prefix-arg))
8063 (gnus-summary-limit-to-subject from "from" not-matching))
8065 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8066 "Limit the summary buffer to articles with the given RECIPIENT.
8068 If NOT-MATCHING, exclude RECIPIENT.
8070 To and Cc headers are checked. You need to include them in
8071 `nnmail-extra-headers'."
8072 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8074 (list (read-string (format "%s recipient (regexp): "
8075 (if current-prefix-arg "Exclude" "Limit to")))
8076 current-prefix-arg))
8077 (when (not (equal "" recipient))
8079 (if (memq 'To nnmail-extra-headers)
8080 (gnus-summary-find-matching
8081 (cons 'extra 'To) recipient 'all nil nil
8084 1 "`To' isn't present in `nnmail-extra-headers'")
8088 (if (memq 'Cc nnmail-extra-headers)
8089 (gnus-summary-find-matching
8090 (cons 'extra 'Cc) recipient 'all nil nil
8093 1 "`Cc' isn't present in `nnmail-extra-headers'")
8098 ;; We need the numbers that are in both lists:
8100 (and (memq a to) a))
8104 (error "Found no matches for \"%s\"" recipient))
8105 (gnus-summary-limit articles))
8106 (gnus-summary-position-point))))
8108 (defun gnus-summary-limit-to-address (address &optional not-matching)
8109 "Limit the summary buffer to articles with the given ADDRESS.
8111 If NOT-MATCHING, exclude ADDRESS.
8113 To, Cc and From headers are checked. You need to include `To' and `Cc'
8114 in `nnmail-extra-headers'."
8116 (list (read-string (format "%s address (regexp): "
8117 (if current-prefix-arg "Exclude" "Limit to")))
8118 current-prefix-arg))
8119 (when (not (equal "" address))
8121 (if (memq 'To nnmail-extra-headers)
8122 (gnus-summary-find-matching
8123 (cons 'extra 'To) address 'all nil nil
8126 1 "`To' isn't present in `nnmail-extra-headers'")
8130 (if (memq 'Cc nnmail-extra-headers)
8131 (gnus-summary-find-matching
8132 (cons 'extra 'Cc) address 'all nil nil
8135 1 "`Cc' isn't present in `nnmail-extra-headers'")
8139 (gnus-summary-find-matching "from" address
8140 'all nil nil not-matching))
8143 ;; We need the numbers that are in all lists:
8147 (mapcar (lambda (a) (car (memq a from))) to))
8149 (mapcar (lambda (a) (car (memq a from))) cc)
8150 (mapcar (lambda (a) (car (memq a from)))
8151 (mapcar (lambda (a) (car (memq a to)))
8153 (nconc (if (eq to t) nil to)
8154 (if (eq cc t) nil cc)
8157 (error "Found no matches for \"%s\"" address))
8158 (gnus-summary-limit articles))
8159 (gnus-summary-position-point))))
8161 (defun gnus-summary-limit-strange-charsets-predicate (header)
8162 (let ((string (concat (mail-header-subject header)
8163 (mail-header-from header)))
8165 (dotimes (i (1- (length string)))
8166 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8167 (when (string-match "unicode\\|big\\|japanese" charset)
8171 (defun gnus-summary-limit-to-predicate (predicate)
8172 "Limit to articles where PREDICATE returns non-nil.
8173 PREDICATE will be called with the header structures of the
8175 (let ((articles nil)
8176 (case-fold-search t))
8177 (dolist (header gnus-newsgroup-headers)
8178 (when (funcall predicate header)
8179 (push (mail-header-number header) articles)))
8180 (gnus-summary-limit (nreverse articles))))
8182 (defun gnus-summary-limit-to-age (age &optional younger-p)
8183 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8184 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8185 articles that are younger than AGE days."
8187 (let ((younger current-prefix-arg)
8190 (while (not days-got)
8191 (setq days (if younger
8192 (read-string "Limit to articles younger than (in days, older when negative): ")
8194 "Limit to articles older than (in days, younger when negative): ")))
8195 (when (> (length days) 0)
8196 (setq days (read days)))
8201 (setq younger (not younger))
8202 (setq days (* days -1))))
8203 (message "Please enter a number.")
8205 (list days younger)))
8207 (let ((data gnus-newsgroup-data)
8208 (cutoff (days-to-time age))
8209 articles d date is-younger)
8210 (while (setq d (pop data))
8211 (when (and (vectorp (gnus-data-header d))
8212 (setq date (mail-header-date (gnus-data-header d))))
8213 (setq is-younger (time-less-p
8214 (time-since (condition-case ()
8221 (push (gnus-data-number d) articles))))
8222 (gnus-summary-limit (nreverse articles)))
8223 (gnus-summary-position-point)))
8225 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8226 "Limit the summary buffer to articles that match an 'extra' header."
8230 (gnus-completing-read-with-default
8231 (symbol-name (car gnus-extra-headers))
8232 (if current-prefix-arg
8233 "Exclude extra header"
8234 "Limit extra header")
8236 (cons (symbol-name x) x))
8241 (read-string (format "%s header %s (regexp): "
8242 (if current-prefix-arg "Exclude" "Limit to")
8244 current-prefix-arg)))
8245 (when (not (equal "" regexp))
8247 (let ((articles (gnus-summary-find-matching
8248 (cons 'extra header) regexp 'all nil nil
8251 (error "Found no matches for \"%s\"" regexp))
8252 (gnus-summary-limit articles))
8253 (gnus-summary-position-point))))
8255 (defun gnus-summary-limit-to-display-predicate ()
8256 "Limit the summary buffer to the predicated in the `display' group parameter."
8258 (unless gnus-newsgroup-display
8259 (error "There is no `display' group parameter"))
8261 (dolist (number gnus-newsgroup-articles)
8262 (when (funcall gnus-newsgroup-display)
8263 (push number articles)))
8264 (gnus-summary-limit articles))
8265 (gnus-summary-position-point))
8267 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8269 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8271 (defun gnus-summary-limit-to-unread (&optional all)
8272 "Limit the summary buffer to articles that are not marked as read.
8273 If ALL is non-nil, limit strictly to unread articles."
8276 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8277 (gnus-summary-limit-to-marks
8278 ;; Concat all the marks that say that an article is read and have
8280 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8281 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8282 gnus-low-score-mark gnus-expirable-mark
8283 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8284 gnus-duplicate-mark gnus-souped-mark)
8287 (defun gnus-summary-limit-to-headers (match &optional reverse)
8288 "Limit the summary buffer to articles that have headers that match MATCH.
8289 If REVERSE (the prefix), limit to articles that don't match."
8290 (interactive "sMatch headers (regexp): \nP")
8291 (gnus-summary-limit-to-bodies match reverse t))
8293 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8294 "Limit the summary buffer to articles that have bodies that match MATCH.
8295 If REVERSE (the prefix), limit to articles that don't match."
8296 (interactive "sMatch body (regexp): \nP")
8297 (let ((articles nil)
8298 (gnus-select-article-hook nil) ;Disable hook.
8299 (gnus-article-prepare-hook nil)
8300 (gnus-use-article-prefetch nil)
8301 (gnus-keep-backlog nil)
8302 (gnus-break-pages nil)
8303 (gnus-summary-display-arrow nil)
8304 (gnus-updated-mode-lines nil)
8305 (gnus-auto-center-summary nil)
8306 (gnus-display-mime-function nil))
8307 (dolist (data gnus-newsgroup-data)
8308 (let (gnus-mark-article-hook)
8309 (gnus-summary-select-article t t nil (gnus-data-number data)))
8311 (set-buffer gnus-article-buffer)
8313 (let* ((case-fold-search t)
8315 (re-search-backward match nil t)
8316 (re-search-forward match nil t))))
8317 (when (or (and found
8321 (push (gnus-data-number data) articles)))))
8323 (message "No messages matched")
8324 (gnus-summary-limit articles)))
8325 (gnus-summary-position-point))
8327 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8328 "Limit the summary buffer to articles that aren't part on any thread.
8329 If THREADSP (the prefix), limit to articles that are in threads."
8331 (let ((articles nil)
8334 (dolist (thread gnus-newsgroup-threads)
8335 (if (stringp (car thread))
8336 (dolist (thread (cdr thread))
8337 (push thread threads))
8338 (push thread threads)))
8339 (dolist (thread threads)
8340 (setq thread-articles (gnus-articles-in-thread thread))
8341 (when (or (and threadsp
8342 (> (length thread-articles) 1))
8344 (= (length thread-articles) 1)))
8345 (setq articles (nconc thread-articles articles))))
8347 (message "No messages matched")
8348 (gnus-summary-limit articles))
8349 (gnus-summary-position-point)))
8351 (defun gnus-summary-limit-to-replied (&optional unreplied)
8352 "Limit the summary buffer to replied articles.
8353 If UNREPLIED (the prefix), limit to unreplied articles."
8357 (gnus-set-difference gnus-newsgroup-articles
8358 gnus-newsgroup-replied))
8359 (gnus-summary-limit gnus-newsgroup-replied))
8360 (gnus-summary-position-point))
8362 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8363 (make-obsolete 'gnus-summary-delete-marked-with
8364 'gnus-summary-limit-exclude-marks)
8366 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8367 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8368 If REVERSE, limit the summary buffer to articles that are marked
8369 with MARKS. MARKS can either be a string of marks or a list of marks.
8370 Returns how many articles were removed."
8371 (interactive "sMarks: ")
8372 (gnus-summary-limit-to-marks marks t))
8374 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8375 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8376 If REVERSE (the prefix), limit the summary buffer to articles that are
8377 not marked with MARKS. MARKS can either be a string of marks or a
8379 Returns how many articles were removed."
8380 (interactive "sMarks: \nP")
8382 (let ((data gnus-newsgroup-data)
8383 (marks (if (listp marks) marks
8384 (append marks nil))) ; Transform to list.
8387 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8388 (memq (gnus-data-mark (car data)) marks))
8389 (push (gnus-data-number (car data)) articles))
8390 (setq data (cdr data)))
8391 (gnus-summary-limit articles))
8392 (gnus-summary-position-point)))
8394 (defun gnus-summary-limit-to-score (score)
8395 "Limit to articles with score at or above SCORE."
8396 (interactive "NLimit to articles with score of at least: ")
8397 (let ((data gnus-newsgroup-data)
8400 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8402 (push (gnus-data-number (car data)) articles))
8403 (setq data (cdr data)))
8405 (gnus-summary-limit articles)
8406 (gnus-summary-position-point))))
8408 (defun gnus-summary-limit-to-unseen ()
8409 "Limit to unseen articles."
8412 (gnus-summary-limit gnus-newsgroup-unseen)
8413 (gnus-summary-position-point)))
8415 (defun gnus-summary-limit-include-thread (id)
8416 "Display all the hidden articles that is in the thread with ID in it.
8417 When called interactively, ID is the Message-ID of the current
8419 (interactive (list (mail-header-id (gnus-summary-article-header))))
8420 (let ((articles (gnus-articles-in-thread
8421 (gnus-id-to-thread (gnus-root-id id)))))
8423 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8424 (gnus-summary-limit-include-matching-articles
8426 (regexp-quote (gnus-simplify-subject-re
8427 (mail-header-subject (gnus-id-to-header id)))))
8428 (gnus-summary-position-point))))
8430 (defun gnus-summary-limit-include-matching-articles (header regexp)
8431 "Display all the hidden articles that have HEADERs that match REGEXP."
8432 (interactive (list (read-string "Match on header: ")
8433 (read-string "Regexp: ")))
8434 (let ((articles (gnus-find-matching-articles header regexp)))
8436 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8437 (gnus-summary-position-point))))
8439 (defun gnus-summary-insert-dormant-articles ()
8440 "Insert all the dormant articles for this group into the current buffer."
8442 (let ((gnus-verbose (max 6 gnus-verbose)))
8443 (if (not gnus-newsgroup-dormant)
8444 (gnus-message 3 "No dormant articles for this group")
8445 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8447 (defun gnus-summary-insert-ticked-articles ()
8448 "Insert ticked articles for this group into the current buffer."
8450 (let ((gnus-verbose (max 6 gnus-verbose)))
8451 (if (not gnus-newsgroup-marked)
8452 (gnus-message 3 "No ticked articles for this group")
8453 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8455 (defun gnus-summary-limit-include-dormant ()
8456 "Display all the hidden articles that are marked as dormant.
8457 Note that this command only works on a subset of the articles currently
8458 fetched for this group."
8460 (unless gnus-newsgroup-dormant
8461 (error "There are no dormant articles in this group"))
8463 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8464 (gnus-summary-position-point)))
8466 (defun gnus-summary-limit-exclude-dormant ()
8467 "Hide all dormant articles."
8470 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8471 (gnus-summary-position-point)))
8473 (defun gnus-summary-limit-exclude-childless-dormant ()
8474 "Hide all dormant articles that have no children."
8476 (let ((data (gnus-data-list t))
8477 articles d children)
8478 ;; Find all articles that are either not dormant or have
8480 (while (setq d (pop data))
8481 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8483 (gnus-article-children (gnus-data-number d)))
8486 (when (memq (car children) articles)
8491 (push (gnus-data-number d) articles)))
8494 (gnus-summary-limit articles)
8495 (gnus-summary-position-point))))
8497 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8498 "Mark all unread excluded articles as read.
8499 If ALL, mark even excluded ticked and dormants as read."
8501 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8502 (let ((articles (gnus-sorted-ndifference
8504 (mapcar (lambda (h) (mail-header-number h))
8505 gnus-newsgroup-headers)
8507 gnus-newsgroup-limit))
8509 (setq gnus-newsgroup-unreads
8510 (gnus-sorted-intersection gnus-newsgroup-unreads
8511 gnus-newsgroup-limit))
8513 (setq gnus-newsgroup-dormant nil
8514 gnus-newsgroup-marked nil
8515 gnus-newsgroup-reads
8517 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8518 gnus-newsgroup-reads))
8519 (while (setq article (pop articles))
8520 (unless (or (memq article gnus-newsgroup-dormant)
8521 (memq article gnus-newsgroup-marked))
8522 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8524 (defun gnus-summary-limit (articles &optional pop)
8526 ;; We pop the previous limit off the stack and use that.
8527 (setq articles (car gnus-newsgroup-limits)
8528 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8529 ;; We use the new limit, so we push the old limit on the stack.
8530 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8532 (setq gnus-newsgroup-limit articles)
8533 (let ((total (length gnus-newsgroup-data))
8534 (data (gnus-data-find-list (gnus-summary-article-number)))
8535 (gnus-summary-mark-below nil) ; Inhibit this.
8537 ;; This will do all the work of generating the new summary buffer
8538 ;; according to the new limit.
8539 (gnus-summary-prepare)
8540 ;; Hide any threads, possibly.
8541 (gnus-summary-maybe-hide-threads)
8542 ;; Try to return to the article you were at, or one in the
8545 ;; We try to find some article after the current one.
8547 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8550 (setq data (cdr data))))
8552 ;; If there is no data, that means that we were after the last
8553 ;; article. The same goes when we can't find any articles
8554 ;; after the current one.
8555 (goto-char (point-max))
8556 (gnus-summary-find-prev))
8557 (gnus-set-mode-line 'summary)
8558 ;; We return how many articles were removed from the summary
8559 ;; buffer as a result of the new limit.
8560 (- total (length gnus-newsgroup-data))))
8562 (defsubst gnus-invisible-cut-children (threads)
8565 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8570 (defsubst gnus-cut-thread (thread)
8571 "Go forwards in the thread until we find an article that we want to display."
8572 (when (or (eq gnus-fetch-old-headers 'some)
8573 (eq gnus-fetch-old-headers 'invisible)
8574 (numberp gnus-fetch-old-headers)
8575 (eq gnus-build-sparse-threads 'some)
8576 (eq gnus-build-sparse-threads 'more))
8577 ;; Deal with old-fetched headers and sparse threads.
8581 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8582 (gnus-summary-article-ancient-p
8583 (mail-header-number (car thread))))
8584 (if (or (<= (length (cdr thread)) 1)
8585 (eq gnus-fetch-old-headers 'invisible))
8586 (setq gnus-newsgroup-limit
8587 (delq (mail-header-number (car thread))
8588 gnus-newsgroup-limit)
8589 thread (cadr thread))
8590 (when (gnus-invisible-cut-children (cdr thread))
8591 (let ((th (cdr thread)))
8593 (if (memq (mail-header-number (caar th))
8594 gnus-newsgroup-limit)
8595 (setq thread (car th)
8597 (setq th (cdr th))))))))))
8600 (defun gnus-cut-threads (threads)
8601 "Cut off all uninteresting articles from the beginning of THREADS."
8602 (when (or (eq gnus-fetch-old-headers 'some)
8603 (eq gnus-fetch-old-headers 'invisible)
8604 (numberp gnus-fetch-old-headers)
8605 (eq gnus-build-sparse-threads 'some)
8606 (eq gnus-build-sparse-threads 'more))
8609 (setcar th (gnus-cut-thread (car th)))
8610 (setq th (cdr th)))))
8611 ;; Remove nixed out threads.
8614 (defun gnus-summary-initial-limit (&optional show-if-empty)
8615 "Figure out what the initial limit is supposed to be on group entry.
8616 This entails weeding out unwanted dormants, low-scored articles,
8617 fetch-old-headers verbiage, and so on."
8618 ;; Most groups have nothing to remove.
8619 (unless (or gnus-inhibit-limiting
8620 (and (null gnus-newsgroup-dormant)
8621 (eq gnus-newsgroup-display 'gnus-not-ignore)
8622 (not (eq gnus-fetch-old-headers 'some))
8623 (not (numberp gnus-fetch-old-headers))
8624 (not (eq gnus-fetch-old-headers 'invisible))
8625 (null gnus-summary-expunge-below)
8626 (not (eq gnus-build-sparse-threads 'some))
8627 (not (eq gnus-build-sparse-threads 'more))
8628 (null gnus-thread-expunge-below)
8629 (not gnus-use-nocem)))
8630 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8631 (setq gnus-newsgroup-limit nil)
8634 (unless (car (symbol-value node))
8635 ;; These threads have no parents -- they are roots.
8636 (let ((nodes (cdr (symbol-value node)))
8639 (if (and gnus-thread-expunge-below
8640 (< (gnus-thread-total-score (car nodes))
8641 gnus-thread-expunge-below))
8642 (gnus-expunge-thread (pop nodes))
8643 (setq thread (pop nodes))
8644 (gnus-summary-limit-children thread))))))
8645 gnus-newsgroup-dependencies)
8646 ;; If this limitation resulted in an empty group, we might
8647 ;; pop the previous limit and use it instead.
8648 (when (and (not gnus-newsgroup-limit)
8650 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8651 gnus-newsgroup-limit))
8653 (defun gnus-summary-limit-children (thread)
8654 "Return 1 if this subthread is visible and 0 if it is not."
8655 ;; First we get the number of visible children to this thread. This
8656 ;; is done by recursing down the thread using this function, so this
8657 ;; will really go down to a leaf article first, before slowly
8658 ;; working its way up towards the root.
8660 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8663 (apply '+ (mapcar 'gnus-summary-limit-children
8666 (number (mail-header-number (car thread)))
8669 (not (memq number gnus-newsgroup-marked))
8671 ;; If this article is dormant and has absolutely no visible
8672 ;; children, then this article isn't visible.
8673 (and (memq number gnus-newsgroup-dormant)
8675 ;; If this is "fetch-old-headered" and there is no
8676 ;; visible children, then we don't want this article.
8677 (and (or (eq gnus-fetch-old-headers 'some)
8678 (numberp gnus-fetch-old-headers))
8679 (gnus-summary-article-ancient-p number)
8681 ;; If this is "fetch-old-headered" and `invisible', then
8682 ;; we don't want this article.
8683 (and (eq gnus-fetch-old-headers 'invisible)
8684 (gnus-summary-article-ancient-p number))
8685 ;; If this is a sparsely inserted article with no children,
8686 ;; we don't want it.
8687 (and (eq gnus-build-sparse-threads 'some)
8688 (gnus-summary-article-sparse-p number)
8690 ;; If we use expunging, and this article is really
8691 ;; low-scored, then we don't want this article.
8692 (when (and gnus-summary-expunge-below
8694 (or (cdr (assq number gnus-newsgroup-scored))
8695 gnus-summary-default-score))
8696 gnus-summary-expunge-below))
8697 ;; We increase the expunge-tally here, but that has
8698 ;; nothing to do with the limits, really.
8699 (incf gnus-newsgroup-expunged-tally)
8700 ;; We also mark as read here, if that's wanted.
8701 (when (and gnus-summary-mark-below
8702 (< score gnus-summary-mark-below))
8703 (setq gnus-newsgroup-unreads
8704 (delq number gnus-newsgroup-unreads))
8705 (if gnus-newsgroup-auto-expire
8706 (push number gnus-newsgroup-expirable)
8707 (push (cons number gnus-low-score-mark)
8708 gnus-newsgroup-reads)))
8710 ;; Do the `display' group parameter.
8711 (and gnus-newsgroup-display
8712 (not (funcall gnus-newsgroup-display)))
8713 ;; Check NoCeM things.
8714 (when (and gnus-use-nocem
8715 (gnus-nocem-unwanted-article-p
8716 (mail-header-id (car thread))))
8717 (setq gnus-newsgroup-unreads
8718 (delq number gnus-newsgroup-unreads))
8720 ;; Nope, invisible article.
8722 ;; Ok, this article is to be visible, so we add it to the limit
8724 (push number gnus-newsgroup-limit)
8727 (defun gnus-expunge-thread (thread)
8728 "Mark all articles in THREAD as read."
8729 (let* ((number (mail-header-number (car thread))))
8730 (incf gnus-newsgroup-expunged-tally)
8731 ;; We also mark as read here, if that's wanted.
8732 (setq gnus-newsgroup-unreads
8733 (delq number gnus-newsgroup-unreads))
8734 (if gnus-newsgroup-auto-expire
8735 (push number gnus-newsgroup-expirable)
8736 (push (cons number gnus-low-score-mark)
8737 gnus-newsgroup-reads)))
8738 ;; Go recursively through all subthreads.
8739 (mapcar 'gnus-expunge-thread (cdr thread)))
8741 ;; Summary article oriented commands
8743 (defun gnus-summary-refer-parent-article (n)
8744 "Refer parent article N times.
8745 If N is negative, go to ancestor -N instead.
8746 The difference between N and the number of articles fetched is returned."
8750 (when (not (natnump n))
8755 (setq header (gnus-summary-article-header))
8756 (if (and (eq (mail-header-number header)
8757 (cdr gnus-article-current))
8758 (equal gnus-newsgroup-name
8759 (car gnus-article-current)))
8760 ;; If we try to find the parent of the currently
8761 ;; displayed article, then we take a look at the actual
8762 ;; References header, since this is slightly more
8763 ;; reliable than the References field we got from the
8765 (with-current-buffer gnus-original-article-buffer
8766 (nnheader-narrow-to-headers)
8767 (unless (setq ref (message-fetch-field "references"))
8768 (when (setq ref (message-fetch-field "in-reply-to"))
8769 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8772 ;; It's not the current article, so we take a bet on
8773 ;; the value we got from the server.
8774 (mail-header-references header)))
8776 (not (equal ref "")))
8777 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8778 (gnus-message 1 "Couldn't find parent"))
8779 (gnus-message 1 "No references in article %d"
8780 (gnus-summary-article-number))
8783 (gnus-summary-position-point)
8786 (defun gnus-summary-refer-references ()
8787 "Fetch all articles mentioned in the References header.
8788 Return the number of articles fetched."
8790 (let ((ref (mail-header-references (gnus-summary-article-header)))
8791 (current (gnus-summary-article-number))
8795 (error "No References in the current article")
8796 ;; For each Message-ID in the References header...
8797 (while (string-match "<[^>]*>" ref)
8799 ;; ... fetch that article.
8800 (gnus-summary-refer-article
8801 (prog1 (match-string 0 ref)
8802 (setq ref (substring ref (match-end 0))))))
8803 (gnus-summary-goto-subject current)
8804 (gnus-summary-position-point)
8807 (defun gnus-summary-refer-thread (&optional limit)
8808 "Fetch all articles in the current thread.
8809 If LIMIT (the numerical prefix), fetch that many old headers instead
8810 of what's specified by the `gnus-refer-thread-limit' variable."
8812 (let ((id (mail-header-id (gnus-summary-article-header)))
8813 (limit (if limit (prefix-numeric-value limit)
8814 gnus-refer-thread-limit)))
8815 (unless (eq gnus-fetch-old-headers 'invisible)
8816 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8817 ;; Retrieve the headers and read them in.
8818 (if (eq (if (numberp limit)
8819 (gnus-retrieve-headers
8821 (+ (mail-header-number
8822 (gnus-summary-article-header))
8824 gnus-newsgroup-end))
8825 gnus-newsgroup-name (* limit 2))
8826 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8828 (gnus-retrieve-headers (list gnus-newsgroup-end)
8829 gnus-newsgroup-name limit))
8831 (gnus-build-all-threads)
8832 (error "Can't fetch thread from back ends that don't support NOV"))
8833 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8834 (gnus-summary-limit-include-thread id)))
8836 (defun gnus-summary-refer-article (message-id)
8837 "Fetch an article specified by MESSAGE-ID."
8838 (interactive "sMessage-ID: ")
8839 (when (and (stringp message-id)
8840 (not (zerop (length message-id))))
8841 (setq message-id (gnus-replace-in-string message-id " " ""))
8842 ;; Construct the correct Message-ID if necessary.
8843 ;; Suggested by tale@pawl.rpi.edu.
8844 (unless (string-match "^<" message-id)
8845 (setq message-id (concat "<" message-id)))
8846 (unless (string-match ">$" message-id)
8847 (setq message-id (concat message-id ">")))
8848 ;; People often post MIDs from URLs, so unhex it:
8849 (unless (string-match "@" message-id)
8850 (setq message-id (gnus-url-unhex-string message-id)))
8851 (let* ((header (gnus-id-to-header message-id))
8853 (gnus-summary-article-sparse-p
8854 (mail-header-number header))
8855 (memq (mail-header-number header)
8856 gnus-newsgroup-limit)))
8859 ;; If the article is present in the buffer we just go to it.
8861 (or (not (gnus-summary-article-sparse-p
8862 (mail-header-number header)))
8865 (gnus-summary-goto-article
8866 (mail-header-number header) nil t)
8868 (gnus-summary-update-article (mail-header-number header)))))
8870 ;; We fetch the article.
8872 (dolist (gnus-override-method (gnus-refer-article-methods))
8873 (when (and (gnus-check-server gnus-override-method)
8874 ;; Fetch the header,
8875 (setq number (gnus-summary-insert-subject message-id)))
8876 ;; and display the article.
8877 (gnus-summary-select-article nil nil nil number)
8879 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8881 (defun gnus-refer-article-methods ()
8882 "Return a list of referable methods."
8884 ;; No method, so we default to current and native.
8885 ((null gnus-refer-article-method)
8886 (list gnus-current-select-method gnus-select-method))
8888 ((eq 'current gnus-refer-article-method)
8889 (list gnus-current-select-method))
8890 ;; List of select methods.
8891 ((not (and (symbolp (car gnus-refer-article-method))
8892 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8894 (dolist (method gnus-refer-article-method)
8895 (push (if (eq 'current method)
8896 gnus-current-select-method
8900 ;; One single select method.
8902 (list gnus-refer-article-method))))
8904 (defun gnus-summary-edit-parameters ()
8905 "Edit the group parameters of the current group."
8907 (gnus-group-edit-group gnus-newsgroup-name 'params))
8909 (defun gnus-summary-customize-parameters ()
8910 "Customize the group parameters of the current group."
8912 (gnus-group-customize gnus-newsgroup-name))
8914 (defun gnus-summary-enter-digest-group (&optional force)
8915 "Enter an nndoc group based on the current article.
8916 If FORCE, force a digest interpretation. If not, try
8917 to guess what the document format is."
8919 (let ((conf gnus-current-window-configuration))
8920 (save-window-excursion
8922 (let (gnus-article-prepare-hook
8923 gnus-display-mime-function
8925 (gnus-summary-select-article))))
8926 (setq gnus-current-window-configuration conf)
8927 (let* ((name (format "%s-%d"
8928 (gnus-group-prefixed-name
8929 gnus-newsgroup-name (list 'nndoc ""))
8930 (with-current-buffer gnus-summary-buffer
8931 gnus-current-article)))
8932 (ogroup gnus-newsgroup-name)
8933 (params (append (gnus-info-params (gnus-get-info ogroup))
8934 (list (cons 'to-group ogroup))
8935 (list (cons 'parent-group ogroup))
8936 (list (cons 'save-article-group ogroup))))
8937 (case-fold-search t)
8938 (buf (current-buffer))
8940 (with-current-buffer gnus-original-article-buffer
8941 ;; Have the digest group inherit the main mail address of
8942 ;; the parent article.
8943 (when (setq to-address (or (gnus-fetch-field "reply-to")
8944 (gnus-fetch-field "from")))
8947 (list (cons 'to-address
8948 (funcall gnus-decode-encoded-address-function
8950 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8951 (insert-buffer-substring gnus-original-article-buffer)
8952 ;; Remove lines that may lead nndoc to misinterpret the
8955 (goto-char (point-min))
8956 (or (search-forward "\n\n" nil t) (point)))
8957 (goto-char (point-min))
8958 (delete-matching-lines "^Path:\\|^From ")
8961 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8962 (gnus-newsgroup-ephemeral-ignored-charsets
8963 gnus-newsgroup-ignored-charsets))
8964 (gnus-group-read-ephemeral-group
8965 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8967 ,(if force 'mbox 'guess)))
8969 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8971 ;; Make all postings to this group go to the parent group.
8972 (nconc (gnus-info-params (gnus-get-info name))
8974 ;; Couldn't select this doc group.
8975 (switch-to-buffer buf)
8976 (gnus-set-global-variables)
8977 (gnus-configure-windows 'summary)
8978 (gnus-message 3 "Article couldn't be entered?"))
8979 (kill-buffer dig)))))
8981 (defun gnus-summary-read-document (n)
8982 "Open a new group based on the current article(s).
8983 This will allow you to read digests and other similar
8984 documents as newsgroups.
8985 Obeys the standard process/prefix convention."
8987 (let* ((ogroup gnus-newsgroup-name)
8988 (params (append (gnus-info-params (gnus-get-info ogroup))
8989 (list (cons 'to-group ogroup))))
8990 group egroup groups vgroup)
8991 (dolist (article (gnus-summary-work-articles n))
8992 (setq group (format "%s-%d" gnus-newsgroup-name article))
8993 (gnus-summary-remove-process-mark article)
8994 (when (gnus-summary-display-article article)
8997 (insert-buffer-substring gnus-original-article-buffer)
8998 ;; Remove some headers that may lead nndoc to make
9000 (message-narrow-to-head)
9001 (goto-char (point-min))
9002 (delete-matching-lines "^Path:\\|^From ")
9005 (gnus-group-read-ephemeral-group
9006 group `(nndoc ,group (nndoc-address ,(current-buffer))
9007 (nndoc-article-type guess))
9010 ;; Make all postings to this group go to the parent group.
9011 (nconc (gnus-info-params (gnus-get-info egroup))
9013 (push egroup groups))
9014 ;; Couldn't select this doc group.
9015 (gnus-error 3 "Article couldn't be entered"))))))
9016 ;; Now we have selected all the documents.
9019 (error "None of the articles could be interpreted as documents"))
9020 ((gnus-group-read-ephemeral-group
9021 (setq vgroup (format
9022 "nnvirtual:%s-%s" gnus-newsgroup-name
9023 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9024 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9026 (cons (current-buffer) 'summary)))
9028 (error "Couldn't select virtual nndoc group")))))
9030 (defun gnus-summary-isearch-article (&optional regexp-p)
9031 "Do incremental search forward on the current article.
9032 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9034 (gnus-summary-select-article)
9035 (gnus-configure-windows 'article)
9036 (gnus-eval-in-buffer-window gnus-article-buffer
9039 (isearch-forward regexp-p))))
9041 (defun gnus-summary-repeat-search-article-forward ()
9042 "Repeat the previous search forwards."
9044 (unless gnus-last-search-regexp
9045 (error "No previous search"))
9046 (gnus-summary-search-article-forward gnus-last-search-regexp))
9048 (defun gnus-summary-repeat-search-article-backward ()
9049 "Repeat the previous search backwards."
9051 (unless gnus-last-search-regexp
9052 (error "No previous search"))
9053 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9055 (defun gnus-summary-search-article-forward (regexp &optional backward)
9056 "Search for an article containing REGEXP forward.
9057 If BACKWARD, search backward instead."
9060 (format "Search article %s (regexp%s): "
9061 (if current-prefix-arg "backward" "forward")
9062 (if gnus-last-search-regexp
9063 (concat ", default " gnus-last-search-regexp)
9065 current-prefix-arg))
9066 (if (string-equal regexp "")
9067 (setq regexp (or gnus-last-search-regexp ""))
9068 (setq gnus-last-search-regexp regexp)
9069 (setq gnus-article-before-search gnus-current-article))
9070 ;; Intentionally set gnus-last-article.
9071 (setq gnus-last-article gnus-article-before-search)
9072 (let ((gnus-last-article gnus-last-article))
9073 (if (gnus-summary-search-article regexp backward)
9074 (gnus-summary-show-thread)
9075 (signal 'search-failed (list regexp)))))
9077 (defun gnus-summary-search-article-backward (regexp)
9078 "Search for an article containing REGEXP backward."
9081 (format "Search article backward (regexp%s): "
9082 (if gnus-last-search-regexp
9083 (concat ", default " gnus-last-search-regexp)
9085 (gnus-summary-search-article-forward regexp 'backward))
9087 (defun gnus-summary-search-article (regexp &optional backward)
9088 "Search for an article containing REGEXP.
9089 Optional argument BACKWARD means do search for backward.
9090 `gnus-select-article-hook' is not called during the search."
9091 ;; We have to require this here to make sure that the following
9092 ;; dynamic binding isn't shadowed by autoloading.
9093 (require 'gnus-async)
9095 (let ((gnus-select-article-hook nil) ;Disable hook.
9096 (gnus-article-prepare-hook nil)
9097 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9098 (gnus-use-article-prefetch nil)
9099 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9100 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9102 (gnus-keep-backlog nil)
9103 (gnus-break-pages nil)
9104 (gnus-summary-display-arrow nil)
9105 (gnus-updated-mode-lines nil)
9106 (gnus-auto-center-summary nil)
9107 (sum (current-buffer))
9108 (gnus-display-mime-function nil)
9111 (gnus-save-hidden-threads
9112 (gnus-summary-select-article)
9113 (set-buffer gnus-article-buffer)
9114 (goto-char (window-point (get-buffer-window (current-buffer))))
9118 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9120 (re-search-backward regexp nil t)
9121 (re-search-forward regexp nil t))
9122 ;; We found the regexp.
9127 (get-buffer-window (current-buffer))
9131 (get-buffer-window (current-buffer))
9134 (setq point (point)))
9135 ;; We didn't find it, so we go to the next article.
9138 (while (eq found 'not)
9139 (if (not (if backward (gnus-summary-find-prev)
9140 (gnus-summary-find-next)))
9141 ;; No more articles.
9143 ;; Select the next article and adjust point.
9144 (unless (gnus-summary-article-sparse-p
9145 (gnus-summary-article-number))
9147 (gnus-summary-select-article)
9148 (set-buffer gnus-article-buffer)
9150 (goto-char (if backward (point-max) (point-min))))))))
9151 (gnus-message 7 ""))
9152 ;; Return whether we found the regexp.
9153 (when (eq found 'found)
9155 (gnus-summary-show-thread)
9156 (gnus-summary-goto-subject gnus-current-article)
9157 (gnus-summary-position-point)
9160 (defun gnus-find-matching-articles (header regexp)
9161 "Return a list of all articles that match REGEXP on HEADER.
9162 This search includes all articles in the current group that Gnus has
9163 fetched headers for, whether they are displayed or not."
9164 (let ((articles nil)
9165 ;; Can't eta-reduce because it's a macro.
9166 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9167 (case-fold-search t))
9168 (dolist (header gnus-newsgroup-headers)
9169 (when (string-match regexp (funcall func header))
9170 (push (mail-header-number header) articles)))
9171 (nreverse articles)))
9173 (defun gnus-summary-find-matching (header regexp &optional backward unread
9174 not-case-fold not-matching)
9175 "Return a list of all articles that match REGEXP on HEADER.
9176 The search stars on the current article and goes forwards unless
9177 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9178 If UNREAD is non-nil, only unread articles will
9179 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9180 in the comparisons. If NOT-MATCHING, return a list of all articles that
9181 not match REGEXP on HEADER."
9182 (let ((case-fold-search (not not-case-fold))
9185 (if (eq (car header) 'extra)
9188 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9190 (error "%s is an invalid header" header))
9191 (unless (fboundp (intern (concat "mail-header-" header)))
9192 (error "%s is not a valid header" header))
9193 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9194 (dolist (d (if (eq backward 'all)
9196 (gnus-data-find-list
9197 (gnus-summary-article-number)
9198 (gnus-data-list backward))))
9199 (when (and (or (not unread) ; We want all articles...
9200 (gnus-data-unread-p d)) ; Or just unreads.
9201 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9205 (funcall func (gnus-data-header d))))
9206 (string-match regexp
9207 (funcall func (gnus-data-header d)))))
9208 (push (gnus-data-number d) articles))) ; Success!
9209 (nreverse articles)))
9211 (defun gnus-summary-execute-command (header regexp command &optional backward)
9212 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9213 If HEADER is an empty string (or nil), the match is done on the entire
9214 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9216 (list (let ((completion-ignore-case t))
9219 (mapcar (lambda (header) (list (format "%s" header)))
9221 '("Number" "Subject" "From" "Lines" "Date"
9222 "Message-ID" "Xref" "References" "Body")
9223 gnus-extra-headers))
9224 nil 'require-match))
9225 (read-string "Regexp: ")
9226 (read-key-sequence "Command: ")
9227 current-prefix-arg))
9228 (when (equal header "Body")
9230 ;; Hidden thread subtrees must be searched as well.
9231 (gnus-summary-show-all-threads)
9232 ;; We don't want to change current point nor window configuration.
9234 (save-window-excursion
9236 gnus-treat-strip-trailing-blank-lines
9237 gnus-treat-strip-leading-blank-lines
9238 gnus-treat-strip-multiple-blank-lines
9239 gnus-treat-hide-boring-headers
9240 gnus-treat-fold-newsgroups
9241 gnus-article-prepare-hook)
9242 (gnus-message 6 "Executing %s..." (key-description command))
9243 ;; We'd like to execute COMMAND interactively so as to give arguments.
9244 (gnus-execute header regexp
9245 `(call-interactively ',(key-binding command))
9247 (gnus-message 6 "Executing %s...done" (key-description command))))))
9249 (defun gnus-summary-beginning-of-article ()
9250 "Scroll the article back to the beginning."
9252 (gnus-summary-select-article)
9253 (gnus-configure-windows 'article)
9254 (gnus-eval-in-buffer-window gnus-article-buffer
9256 (goto-char (point-min))
9257 (when gnus-break-pages
9258 (gnus-narrow-to-page))))
9260 (defun gnus-summary-end-of-article ()
9261 "Scroll to the end of the article."
9263 (gnus-summary-select-article)
9264 (gnus-configure-windows 'article)
9265 (gnus-eval-in-buffer-window gnus-article-buffer
9267 (goto-char (point-max))
9269 (when gnus-break-pages
9270 (gnus-narrow-to-page))))
9272 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9273 "Truncate to LEN and quote all \"(\"'s in STRING."
9274 (gnus-replace-in-string (if (and len (> (length string) len))
9275 (substring string 0 len)
9279 (defun gnus-summary-print-article (&optional filename n)
9280 "Generate and print a PostScript image of the process-marked (mail) articles.
9282 If used interactively, print the current article if none are
9283 process-marked. With prefix arg, prompt the user for the name of the
9286 When used from Lisp, accept two optional args FILENAME and N. N means
9287 to print the next N articles. If N is negative, print the N previous
9288 articles. If N is nil and articles have been marked with the process
9289 mark, print these instead.
9291 If the optional first argument FILENAME is nil, send the image to the
9292 printer. If FILENAME is a string, save the PostScript image in a file with
9293 that name. If FILENAME is a number, prompt the user for the name of the file
9295 (interactive (list (ps-print-preprint current-prefix-arg)))
9296 (dolist (article (gnus-summary-work-articles n))
9297 (gnus-summary-select-article nil nil 'pseudo article)
9298 (gnus-eval-in-buffer-window gnus-article-buffer
9299 (gnus-print-buffer))
9300 (gnus-summary-remove-process-mark article))
9301 (ps-despool filename))
9303 (defun gnus-print-buffer ()
9304 (let ((buffer (generate-new-buffer " *print*")))
9307 (copy-to-buffer buffer (point-min) (point-max))
9309 (gnus-remove-text-with-property 'gnus-decoration)
9310 (when (gnus-visual-p 'article-highlight 'highlight)
9311 ;; Copy-to-buffer doesn't copy overlay. So redo
9313 (let ((gnus-article-buffer buffer))
9314 (gnus-article-highlight-citation t)
9315 (gnus-article-highlight-signature)
9316 (gnus-article-emphasize)
9317 (gnus-article-delete-invisible-text)))
9318 (let ((ps-left-header
9321 (gnus-summary-print-truncate-and-quote
9322 (mail-header-subject gnus-current-headers)
9325 (gnus-summary-print-truncate-and-quote
9326 (mail-header-from gnus-current-headers)
9330 "/pagenumberstring load"
9332 (mail-header-date gnus-current-headers) ")"))))
9333 (gnus-run-hooks 'gnus-ps-print-hook)
9335 (if ps-print-color-p
9336 (ps-spool-buffer-with-faces)
9337 (ps-spool-buffer)))))
9338 (kill-buffer buffer))))
9340 (defun gnus-summary-show-article (&optional arg)
9341 "Force redisplaying of the current article.
9342 If ARG (the prefix) is a number, show the article with the charset
9343 defined in `gnus-summary-show-article-charset-alist', or the charset
9345 If ARG (the prefix) is non-nil and not a number, show the raw article
9346 without any article massaging functions being run. Normally, the key
9347 strokes are `C-u g'."
9351 (gnus-summary-show-article t)
9352 (let ((gnus-newsgroup-charset
9353 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9354 (mm-read-coding-system
9355 "View as charset: " ;; actually it is coding system.
9356 (with-current-buffer gnus-article-buffer
9357 (mm-detect-coding-region (point) (point-max))))))
9358 (gnus-newsgroup-ignored-charsets 'gnus-all))
9359 (gnus-summary-select-article nil 'force)
9360 (let ((deps gnus-newsgroup-dependencies)
9362 (with-current-buffer gnus-original-article-buffer
9364 (message-narrow-to-head)
9365 (setq head (buffer-string))
9366 (goto-char (point-min))
9367 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9368 (goto-char (point-max))
9370 (setq lines (1- (count-lines (point) (point-max))))))
9372 (insert (format "211 %d Article retrieved.\n"
9373 (cdr gnus-article-current)))
9375 (if lines (insert (format "Lines: %d\n" lines)))
9377 (let ((nntp-server-buffer (current-buffer)))
9378 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9379 (gnus-data-set-header
9380 (gnus-data-find (cdr gnus-article-current))
9382 (gnus-summary-update-article-line
9383 (cdr gnus-article-current) header)
9384 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9385 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9387 ;; Select the article the normal way.
9388 (gnus-summary-select-article nil 'force))
9390 ;; We have to require this here to make sure that the following
9391 ;; dynamic binding isn't shadowed by autoloading.
9392 (require 'gnus-async)
9394 ;; Bind the article treatment functions to nil.
9395 (let ((gnus-have-all-headers t)
9396 gnus-article-prepare-hook
9397 gnus-article-decode-hook
9398 gnus-display-mime-function
9400 ;; Destroy any MIME parts.
9401 (when (gnus-buffer-live-p gnus-article-buffer)
9402 (with-current-buffer gnus-article-buffer
9403 (mm-destroy-parts gnus-article-mime-handles)
9404 ;; Set it to nil for safety reason.
9405 (setq gnus-article-mime-handle-alist nil)
9406 (setq gnus-article-mime-handles nil)))
9407 (gnus-summary-select-article nil 'force))))
9408 (gnus-summary-goto-subject gnus-current-article)
9409 (gnus-summary-position-point))
9411 (defun gnus-summary-show-raw-article ()
9412 "Show the raw article without any article massaging functions being run."
9414 (gnus-summary-show-article t))
9416 (defun gnus-summary-verbose-headers (&optional arg)
9417 "Toggle permanent full header display.
9418 If ARG is a positive number, turn header display on.
9419 If ARG is a negative number, turn header display off."
9421 (setq gnus-show-all-headers
9422 (cond ((or (not (numberp arg))
9424 (not gnus-show-all-headers))
9427 (gnus-summary-show-article))
9429 (defun gnus-summary-toggle-header (&optional arg)
9430 "Show the headers if they are hidden, or hide them if they are shown.
9431 If ARG is a positive number, show the entire header.
9432 If ARG is a negative number, hide the unwanted header lines."
9434 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9435 (get-buffer-window gnus-article-buffer t))))
9436 (with-current-buffer gnus-article-buffer
9438 (article-narrow-to-head)
9439 (let* ((inhibit-read-only t)
9440 (inhibit-point-motion-hooks t)
9441 (hidden (if (numberp arg)
9443 (or (not (looking-at "[^ \t\n]+:"))
9444 (gnus-article-hidden-text-p 'headers))))
9446 (delete-region (point-min) (point-max))
9447 (with-current-buffer gnus-original-article-buffer
9448 (goto-char (setq s (point-min)))
9449 (setq e (if (search-forward "\n\n" nil t)
9452 (insert-buffer-substring gnus-original-article-buffer s e)
9453 (run-hooks 'gnus-article-decode-hook)
9455 (let ((gnus-treat-hide-headers nil)
9456 (gnus-treat-hide-boring-headers nil))
9457 (gnus-delete-wash-type 'headers)
9458 (gnus-treat-article 'head))
9459 (gnus-treat-article 'head))
9462 (set-window-start window (goto-char (point-min))))
9463 (if gnus-break-pages
9464 (gnus-narrow-to-page)
9465 (when (gnus-visual-p 'page-marker)
9466 (let ((inhibit-read-only t))
9467 (gnus-remove-text-with-property 'gnus-prev)
9468 (gnus-remove-text-with-property 'gnus-next))))
9469 (gnus-set-mode-line 'article)))))
9471 (defun gnus-summary-show-all-headers ()
9472 "Make all header lines visible."
9474 (gnus-summary-toggle-header 1))
9476 (defun gnus-summary-caesar-message (&optional arg)
9477 "Caesar rotate the current article by 13.
9478 With a non-numerical prefix, also rotate headers. A numerical
9479 prefix specifies how many places to rotate each letter forward."
9481 (gnus-summary-select-article)
9482 (let ((mail-header-separator ""))
9483 (gnus-eval-in-buffer-window gnus-article-buffer
9486 (let ((start (window-start))
9487 (inhibit-read-only t))
9488 (if (equal arg '(4))
9489 (message-caesar-buffer-body nil t)
9490 (message-caesar-buffer-body arg))
9491 (set-window-start (get-buffer-window (current-buffer)) start)))))
9492 ;; Create buttons and stuff...
9493 (gnus-treat-article nil))
9495 (declare-function idna-to-unicode "ext:idna" (str))
9497 (defun gnus-summary-idna-message (&optional arg)
9498 "Decode IDNA encoded domain names in the current articles.
9499 IDNA encoded domain names looks like `xn--bar'. If a string
9500 remain unencoded after running this function, it is likely an
9501 invalid IDNA string (`xn--bar' is invalid).
9503 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9504 installed for this command to work."
9506 (if (not (and (condition-case nil (require 'idna)
9508 (mm-coding-system-p 'utf-8)
9509 (executable-find (symbol-value 'idna-program))))
9511 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9512 (gnus-summary-select-article)
9513 (let ((mail-header-separator ""))
9514 (gnus-eval-in-buffer-window gnus-article-buffer
9517 (let ((start (window-start))
9519 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9520 (replace-match (idna-to-unicode (match-string 1))))
9521 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9523 (defun gnus-summary-morse-message (&optional arg)
9524 "Morse decode the current article."
9526 (gnus-summary-select-article)
9527 (let ((mail-header-separator ""))
9528 (gnus-eval-in-buffer-window gnus-article-buffer
9532 (let ((pos (window-start))
9533 (inhibit-read-only t))
9534 (goto-char (point-min))
9535 (when (message-goto-body)
9536 (gnus-narrow-to-body))
9537 (goto-char (point-min))
9538 (while (search-forward "·" (point-max) t)
9539 (replace-match "."))
9540 (unmorse-region (point-min) (point-max))
9542 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9544 (defun gnus-summary-stop-page-breaking ()
9545 "Stop page breaking in the current article."
9547 (gnus-summary-select-article)
9548 (gnus-eval-in-buffer-window gnus-article-buffer
9550 (when (gnus-visual-p 'page-marker)
9551 (let ((inhibit-read-only t))
9552 (gnus-remove-text-with-property 'gnus-prev)
9553 (gnus-remove-text-with-property 'gnus-next))
9554 (setq gnus-page-broken nil))))
9556 (defun gnus-summary-move-article (&optional n to-newsgroup
9557 select-method action)
9558 "Move the current article to a different newsgroup.
9559 If N is a positive number, move the N next articles.
9560 If N is a negative number, move the N previous articles.
9561 If N is nil and any articles have been marked with the process mark,
9562 move those articles instead.
9563 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9564 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9565 re-spool using this method.
9567 When called interactively with TO-NEWSGROUP being nil, the value of
9568 the variable `gnus-move-split-methods' is used for finding a default
9569 for the target newsgroup.
9571 For this function to work, both the current newsgroup and the
9572 newsgroup that you want to move to have to support the `request-move'
9573 and `request-accept' functions.
9575 ACTION can be either `move' (the default), `crosspost' or `copy'."
9578 (setq action 'move))
9579 ;; Check whether the source group supports the required functions.
9580 (cond ((and (eq action 'move)
9581 (not (gnus-check-backend-function
9582 'request-move-article gnus-newsgroup-name)))
9583 (error "The current group does not support article moving"))
9584 ((and (eq action 'crosspost)
9585 (not (gnus-check-backend-function
9586 'request-replace-article gnus-newsgroup-name)))
9587 (error "The current group does not support article editing")))
9588 (let ((articles (gnus-summary-work-articles n))
9589 (prefix (if (gnus-check-backend-function
9590 'request-move-article gnus-newsgroup-name)
9591 (funcall gnus-move-group-prefix-function
9592 gnus-newsgroup-name)
9594 (names '((move "Move" "Moving")
9595 (copy "Copy" "Copying")
9596 (crosspost "Crosspost" "Crossposting")))
9597 (copy-buf (save-excursion
9598 (nnheader-set-temp-buffer " *copy article*")))
9599 art-group to-method new-xref article to-groups
9600 articles-to-update-marks encoded)
9601 (unless (assq action names)
9602 (error "Unknown action %s" action))
9603 ;; Read the newsgroup name.
9604 (when (and (not to-newsgroup)
9605 (not select-method))
9606 (if (and gnus-move-split-methods
9608 (and (memq gnus-current-article articles)
9609 (gnus-buffer-live-p gnus-original-article-buffer))))
9610 ;; When `gnus-move-split-methods' is non-nil, we have to
9611 ;; select an article to give `gnus-read-move-group-name' an
9612 ;; opportunity to suggest an appropriate default. However,
9613 ;; we needn't render or mark the article.
9614 (let ((gnus-display-mime-function nil)
9615 (gnus-article-prepare-hook nil)
9616 (gnus-mark-article-hook nil))
9617 (gnus-summary-select-article nil nil nil (car articles))))
9618 (setq to-newsgroup (gnus-read-move-group-name
9619 (cadr (assq action names))
9621 (intern (format "gnus-current-%s-group" action)))
9623 encoded to-newsgroup
9624 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9625 (set (intern (format "gnus-current-%s-group" action))
9626 (mm-decode-coding-string
9628 (gnus-group-name-charset to-method to-newsgroup))))
9630 (setq to-method (or select-method
9631 (gnus-server-to-method
9632 (gnus-group-method to-newsgroup)))))
9636 (mm-encode-coding-string
9638 (gnus-group-name-charset to-method to-newsgroup)))))
9639 ;; Check the method we are to move this article to...
9640 (unless (gnus-check-backend-function
9641 'request-accept-article (car to-method))
9642 (error "%s does not support article copying" (car to-method)))
9643 (unless (gnus-check-server to-method)
9644 (error "Can't open server %s" (car to-method)))
9645 (gnus-message 6 "%s to %s: %s..."
9646 (caddr (assq action names))
9647 (or (car select-method)
9648 (gnus-group-decoded-name to-newsgroup))
9651 (setq article (pop articles))
9655 ;; Move the article.
9657 ;; Remove this article from future suppression.
9658 (gnus-dup-unsuppress-article article)
9659 (let* ((from-method (gnus-find-method-for-group
9660 gnus-newsgroup-name))
9661 (to-method (or select-method
9662 (gnus-find-method-for-group to-newsgroup)))
9663 (move-is-internal (gnus-method-equal from-method to-method)))
9664 (gnus-request-move-article
9665 article ; Article to move
9666 gnus-newsgroup-name ; From newsgroup
9667 (nth 1 (gnus-find-method-for-group
9668 gnus-newsgroup-name)) ; Server
9669 (list 'gnus-request-accept-article
9670 to-newsgroup (list 'quote select-method)
9671 (not articles) t) ; Accept form
9672 (not articles) ; Only save nov last time
9673 move-is-internal))) ; is this move internal?
9674 ;; Copy the article.
9676 (with-current-buffer copy-buf
9677 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9679 (nnheader-narrow-to-headers)
9680 (dolist (hdr gnus-copy-article-ignored-headers)
9681 (message-remove-header hdr t)))
9682 (gnus-request-accept-article
9683 to-newsgroup select-method (not articles) t))))
9684 ;; Crosspost the article.
9685 ((eq action 'crosspost)
9686 (let ((xref (message-tokenize-header
9687 (mail-header-xref (gnus-summary-article-header article))
9689 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9690 ":" (number-to-string article)))
9692 (setq xref (list (system-name))))
9695 (mapconcat 'identity
9696 (delete "Xref:" (delete new-xref xref))
9699 (with-current-buffer copy-buf
9700 ;; First put the article in the destination group.
9701 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9702 (when (consp (setq art-group
9703 (gnus-request-accept-article
9704 to-newsgroup select-method (not articles) t)))
9705 (setq new-xref (concat new-xref " " (car art-group)
9707 (number-to-string (cdr art-group))))
9708 ;; Now we have the new Xrefs header, so we insert
9709 ;; it and replace the new article.
9710 (nnheader-replace-header "Xref" new-xref)
9711 (gnus-request-replace-article
9712 (cdr art-group) to-newsgroup (current-buffer) t)
9716 (gnus-message 1 "Couldn't %s article %s: %s"
9717 (cadr (assq action names)) article
9718 (nnheader-get-report (car to-method))))
9719 ((eq art-group 'junk)
9720 (when (eq action 'move)
9721 (gnus-summary-mark-article article gnus-canceled-mark)
9722 (gnus-message 4 "Deleted article %s" article)
9723 ;; run the delete hook
9724 (run-hook-with-args 'gnus-summary-article-delete-hook
9727 (assoc article (gnus-data-list nil)))
9728 gnus-newsgroup-name nil
9731 (let* ((pto-group (gnus-group-prefixed-name
9732 (car art-group) to-method))
9733 (info (gnus-get-info pto-group))
9734 (to-group (gnus-info-group info))
9736 ;; Update the group that has been moved to.
9738 (memq action '(move copy)))
9739 (unless (member to-group to-groups)
9740 (push to-group to-groups))
9742 (unless (memq article gnus-newsgroup-unreads)
9743 (push 'read to-marks)
9745 info (gnus-add-to-range (gnus-info-read info)
9746 (list (cdr art-group)))))
9748 ;; See whether the article is to be put in the cache.
9749 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9750 gnus-article-mark-lists
9751 (delete '(expirable . expire)
9752 (copy-sequence gnus-article-mark-lists))))
9753 (to-article (cdr art-group)))
9755 ;; Enter the article into the cache in the new group,
9756 ;; if that is required.
9757 (when gnus-use-cache
9758 (gnus-cache-possibly-enter-article
9760 (memq article gnus-newsgroup-marked)
9761 (memq article gnus-newsgroup-dormant)
9762 (memq article gnus-newsgroup-unreads)))
9764 (when gnus-preserve-marks
9765 ;; Copy any marks over to the new group.
9766 (when (and (equal to-group gnus-newsgroup-name)
9767 (not (memq article gnus-newsgroup-unreads)))
9768 ;; Mark this article as read in this group.
9769 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9770 (setcdr (gnus-active to-group) to-article)
9771 (setcdr gnus-newsgroup-active to-article))
9774 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9775 (when (memq article (symbol-value
9776 (intern (format "gnus-newsgroup-%s"
9778 (push (cdar marks) to-marks)
9779 ;; If the other group is the same as this group,
9780 ;; then we have to add the mark to the list.
9781 (when (equal to-group gnus-newsgroup-name)
9782 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9785 (intern (format "gnus-newsgroup-%s"
9787 ;; Copy the marks to other group.
9788 (gnus-add-marked-articles
9789 to-group (cdar marks) (list to-article) info)))
9790 (setq marks (cdr marks)))
9792 (gnus-request-set-mark
9793 to-group (list (list (list to-article) 'add to-marks))))
9796 (concat "(gnus-group-set-info '"
9797 (gnus-prin1-to-string (gnus-get-info to-group))
9800 ;; Update the Xref header in this article to point to
9801 ;; the new crossposted article we have just created.
9802 (when (eq action 'crosspost)
9803 (with-current-buffer copy-buf
9804 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9805 (nnheader-replace-header "Xref" new-xref)
9806 (gnus-request-replace-article
9807 article gnus-newsgroup-name (current-buffer) t)))
9809 ;; run the move/copy/crosspost/respool hook
9810 (run-hook-with-args 'gnus-summary-article-move-hook
9813 (assoc article (gnus-data-list nil)))
9818 ;;;!!!Why is this necessary?
9819 (set-buffer gnus-summary-buffer)
9821 (gnus-summary-goto-subject article)
9822 (when (eq action 'move)
9823 (gnus-summary-mark-article article gnus-canceled-mark))))
9824 (push article articles-to-update-marks))
9826 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9827 ;; Re-activate all groups that have been moved to.
9828 (with-current-buffer gnus-group-buffer
9829 (let ((gnus-group-marked to-groups))
9830 (gnus-group-get-new-news-this-group nil t)))
9832 (gnus-kill-buffer copy-buf)
9833 (gnus-summary-position-point)
9834 (gnus-set-mode-line 'summary)))
9836 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9837 "Copy the current article to some other group.
9838 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9839 When called interactively, if TO-NEWSGROUP is nil, use the value of
9840 the variable `gnus-move-split-methods' for finding a default target
9842 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9843 re-spool using this method."
9845 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9847 (defun gnus-summary-crosspost-article (&optional n)
9848 "Crosspost the current article to some other group."
9850 (gnus-summary-move-article n nil nil 'crosspost))
9852 (defcustom gnus-summary-respool-default-method nil
9853 "Default method type for respooling an article.
9854 If nil, use to the current newsgroup method."
9856 :group 'gnus-summary-mail)
9858 (defun gnus-summary-respool-article (&optional n method)
9859 "Respool the current article.
9860 The article will be squeezed through the mail spooling process again,
9861 which means that it will be put in some mail newsgroup or other
9862 depending on `nnmail-split-methods'.
9863 If N is a positive number, respool the N next articles.
9864 If N is a negative number, respool the N previous articles.
9865 If N is nil and any articles have been marked with the process mark,
9866 respool those articles instead.
9868 Respooling can be done both from mail groups and \"real\" newsgroups.
9869 In the former case, the articles in question will be moved from the
9870 current group into whatever groups they are destined to. In the
9871 latter case, they will be copied into the relevant groups."
9873 (list current-prefix-arg
9874 (let* ((methods (gnus-methods-using 'respool))
9876 (symbol-name (or gnus-summary-respool-default-method
9877 (car (gnus-find-method-for-group
9878 gnus-newsgroup-name)))))
9880 (gnus-completing-read-with-default
9881 methname "Backend to use when respooling"
9882 methods nil t nil 'gnus-mail-method-history))
9885 ((zerop (length (setq ms (gnus-servers-using-backend
9887 (list (intern method) ""))
9891 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9892 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9895 (error "No method given for respooling"))
9896 (if (assoc (symbol-name
9897 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9898 (gnus-methods-using 'respool))
9899 (gnus-summary-move-article n nil method)
9900 (gnus-summary-copy-article n nil method)))
9902 (defun gnus-summary-import-article (file &optional edit)
9903 "Import an arbitrary file into a mail newsgroup."
9904 (interactive "fImport file: \nP")
9905 (let ((group gnus-newsgroup-name)
9906 (now (current-time))
9907 atts lines group-art)
9908 (unless (gnus-check-backend-function 'request-accept-article group)
9909 (error "%s does not support article importing" group))
9910 (or (file-readable-p file)
9911 (not (file-regular-p file))
9912 (error "Can't read %s" file))
9913 (with-current-buffer (gnus-get-buffer-create " *import file*")
9915 (nnheader-insert-file-contents file)
9916 (goto-char (point-min))
9917 (if (nnheader-article-p)
9919 (goto-char (point-min))
9920 (search-forward "\n\n" nil t)
9921 (narrow-to-region (point-min) (1- (point)))
9922 (goto-char (point-min))
9923 (unless (re-search-forward "^date:" nil t)
9924 (goto-char (point-max))
9925 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9926 ;; This doesn't look like an article, so we fudge some headers.
9927 (setq atts (file-attributes file)
9928 lines (count-lines (point-min) (point-max)))
9929 (insert "From: " (read-string "From: ") "\n"
9930 "Subject: " (read-string "Subject: ") "\n"
9931 "Date: " (message-make-date (nth 5 atts)) "\n"
9932 "Message-ID: " (message-make-message-id) "\n"
9933 "Lines: " (int-to-string lines) "\n"
9934 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9935 (setq group-art (gnus-request-accept-article group nil t))
9936 (kill-buffer (current-buffer)))
9937 (setq gnus-newsgroup-active (gnus-activate-group group))
9939 (gnus-summary-goto-article (cdr group-art) nil t)
9941 (gnus-summary-edit-article))))
9943 (defun gnus-summary-create-article ()
9944 "Create an article in a mail newsgroup."
9946 (let ((group gnus-newsgroup-name)
9947 (now (current-time))
9949 (unless (gnus-check-backend-function 'request-accept-article group)
9950 (error "%s does not support article importing" group))
9951 (with-current-buffer (gnus-get-buffer-create " *import file*")
9953 (goto-char (point-min))
9954 ;; This doesn't look like an article, so we fudge some headers.
9955 (insert "From: " (read-string "From: ") "\n"
9956 "Subject: " (read-string "Subject: ") "\n"
9957 "Date: " (message-make-date now) "\n"
9958 "Message-ID: " (message-make-message-id) "\n")
9959 (setq group-art (gnus-request-accept-article group nil t))
9960 (kill-buffer (current-buffer)))
9961 (setq gnus-newsgroup-active (gnus-activate-group group))
9963 (gnus-summary-goto-article (cdr group-art) nil t)
9964 (gnus-summary-edit-article)))
9966 (defun gnus-summary-article-posted-p ()
9967 "Say whether the current (mail) article is available from news as well.
9968 This will be the case if the article has both been mailed and posted."
9970 (let ((id (mail-header-references (gnus-summary-article-header)))
9971 (gnus-override-method (car (gnus-refer-article-methods))))
9972 (if (gnus-request-head id "")
9973 (gnus-message 2 "The current message was found on %s"
9974 gnus-override-method)
9975 (gnus-message 2 "The current message couldn't be found on %s"
9976 gnus-override-method)
9979 (defun gnus-summary-expire-articles (&optional now)
9980 "Expire all articles that are marked as expirable in the current group."
9982 (when (and (not gnus-group-is-exiting-without-update-p)
9983 (gnus-check-backend-function
9984 'request-expire-articles gnus-newsgroup-name))
9985 ;; This backend supports expiry.
9986 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9987 (expirable (if total
9989 ;; We need to update the info for
9990 ;; this group for `gnus-list-of-read-articles'
9991 ;; to give us the right answer.
9992 (gnus-run-hooks 'gnus-exit-group-hook)
9993 (gnus-summary-update-info)
9994 (gnus-list-of-read-articles gnus-newsgroup-name))
9995 (setq gnus-newsgroup-expirable
9996 (sort gnus-newsgroup-expirable '<))))
9997 (expiry-wait (if now 'immediate
9998 (gnus-group-find-parameter
9999 gnus-newsgroup-name 'expiry-wait)))
10000 (nnmail-expiry-target
10001 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10002 nnmail-expiry-target))
10005 ;; There are expirable articles in this group, so we run them
10006 ;; through the expiry process.
10007 (gnus-message 6 "Expiring articles...")
10008 (unless (gnus-check-group gnus-newsgroup-name)
10009 (error "Can't open server for %s" gnus-newsgroup-name))
10010 ;; The list of articles that weren't expired is returned.
10013 (let ((nnmail-expiry-wait-function nil)
10014 (nnmail-expiry-wait expiry-wait))
10015 (setq es (gnus-request-expire-articles
10016 expirable gnus-newsgroup-name)))
10017 (setq es (gnus-request-expire-articles
10018 expirable gnus-newsgroup-name)))
10020 (setq gnus-newsgroup-expirable es))
10021 ;; We go through the old list of expirable, and mark all
10022 ;; really expired articles as nonexistent.
10023 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10024 (let ((gnus-use-cache nil))
10025 (dolist (article expirable)
10026 (when (and (not (memq article es))
10027 (gnus-data-find article))
10028 (gnus-summary-mark-article article gnus-canceled-mark)
10029 (run-hook-with-args 'gnus-summary-article-expire-hook
10032 (assoc article (gnus-data-list nil)))
10033 gnus-newsgroup-name
10036 (gnus-message 6 "Expiring articles...done")))))
10038 (defun gnus-summary-expire-articles-now ()
10039 "Expunge all expirable articles in the current group.
10040 This means that *all* articles that are marked as expirable will be
10041 deleted forever, right now."
10043 (or gnus-expert-user
10045 "Are you really, really sure you want to delete all expirable messages? ")
10047 (gnus-summary-expire-articles t))
10049 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10050 (defun gnus-summary-delete-article (&optional n)
10051 "Delete the N next (mail) articles.
10052 This command actually deletes articles. This is not a marking
10053 command. The article will disappear forever from your life, never to
10056 If N is negative, delete backwards.
10057 If N is nil and articles have been marked with the process mark,
10058 delete these instead.
10060 If `gnus-novice-user' is non-nil you will be asked for
10061 confirmation before the articles are deleted."
10063 (unless (gnus-check-backend-function 'request-expire-articles
10064 gnus-newsgroup-name)
10065 (error "The current newsgroup does not support article deletion"))
10066 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10067 (error "Couldn't open server"))
10068 ;; Compute the list of articles to delete.
10069 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10070 (nnmail-expiry-target 'delete)
10072 (if (and gnus-novice-user
10073 (not (gnus-yes-or-no-p
10074 (format "Do you really want to delete %s forever? "
10075 (if (> (length articles) 1)
10076 (format "these %s articles" (length articles))
10077 "this article")))))
10079 ;; Delete the articles.
10080 (setq not-deleted (gnus-request-expire-articles
10081 articles gnus-newsgroup-name 'force))
10083 (gnus-summary-remove-process-mark (car articles))
10084 ;; The backend might not have been able to delete the article
10086 (unless (memq (car articles) not-deleted)
10087 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
10088 (let* ((article (car articles))
10089 (ghead (gnus-data-header
10090 (assoc article (gnus-data-list nil)))))
10091 (run-hook-with-args 'gnus-summary-article-delete-hook
10092 'delete ghead gnus-newsgroup-name nil
10094 (setq articles (cdr articles)))
10096 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10097 (gnus-summary-position-point)
10098 (gnus-set-mode-line 'summary)
10101 (defun gnus-summary-edit-article (&optional arg)
10102 "Edit the current article.
10103 This will have permanent effect only in mail groups.
10104 If ARG is nil, edit the decoded articles.
10105 If ARG is 1, edit the raw articles.
10106 If ARG is 2, edit the raw articles even in read-only groups.
10107 If ARG is 3, edit the articles with the current handles.
10108 Otherwise, allow editing of articles even in read-only
10111 (let (force raw current-handles)
10120 (setq current-handles
10121 (and (gnus-buffer-live-p gnus-article-buffer)
10122 (with-current-buffer gnus-article-buffer
10124 gnus-article-mime-handles
10125 (setq gnus-article-mime-handles nil))))))
10128 (when (and raw (not force)
10129 (member gnus-newsgroup-name '("nndraft:delayed"
10132 (error "Can't edit the raw article in group %s"
10133 gnus-newsgroup-name))
10134 (with-current-buffer gnus-summary-buffer
10135 (let ((mail-parse-charset gnus-newsgroup-charset)
10136 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10137 (gnus-set-global-variables)
10138 (when (and (not force)
10139 (gnus-group-read-only-p))
10140 (error "The current newsgroup does not support article editing"))
10141 (gnus-summary-show-article t)
10142 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10143 (with-current-buffer gnus-article-buffer
10144 (mm-enable-multibyte)))
10145 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10147 (gnus-article-edit-article
10150 (let ((mbl mml-buffer-list))
10151 (setq mml-buffer-list nil)
10152 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10153 (mime-to-mml ,'current-handles))
10154 (let ((mbl1 mml-buffer-list))
10155 (setq mml-buffer-list mbl)
10156 (set (make-local-variable 'mml-buffer-list) mbl1))
10157 (gnus-make-local-hook 'kill-buffer-hook)
10158 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10159 `(lambda (no-highlight)
10160 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10161 (message-options message-options)
10162 (message-options-set-recipient)
10163 (mail-parse-ignored-charsets
10164 ',gnus-newsgroup-ignored-charsets)
10165 (rfc2047-header-encoding-alist
10166 ',(let ((charset (gnus-group-name-charset
10167 (gnus-find-method-for-group
10168 gnus-newsgroup-name)
10169 gnus-newsgroup-name)))
10170 (append (list (cons "Newsgroups" charset)
10171 (cons "Followup-To" charset)
10172 (cons "Xref" charset))
10173 rfc2047-header-encoding-alist))))
10174 ,(if (not raw) '(progn
10176 (mml-destroy-buffers)
10177 (remove-hook 'kill-buffer-hook
10178 'mml-destroy-buffers t)
10179 (kill-local-variable 'mml-buffer-list)))
10180 (gnus-summary-edit-article-done
10181 ,(or (mail-header-references gnus-current-headers) "")
10182 ,(gnus-group-read-only-p)
10183 ,gnus-summary-buffer no-highlight))))))))
10185 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10187 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10189 "Make edits to the current article permanent."
10192 ;; The buffer restriction contains the entire article if it exists.
10193 (when (article-goto-body)
10194 (let ((lines (count-lines (point) (point-max)))
10195 (length (- (point-max) (point)))
10196 (case-fold-search t)
10197 (body (copy-marker (point))))
10198 (goto-char (point-min))
10199 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10200 (delete-region (match-beginning 1) (match-end 1))
10201 (insert (number-to-string length)))
10202 (goto-char (point-min))
10203 (when (re-search-forward
10204 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10205 (delete-region (match-beginning 1) (match-end 1))
10206 (insert (number-to-string length)))
10207 (goto-char (point-min))
10208 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10209 (delete-region (match-beginning 1) (match-end 1))
10210 (insert (number-to-string lines))))))
10211 ;; Replace the article.
10212 (let ((buf (current-buffer)))
10214 (insert-buffer-substring buf)
10216 (if (and (not read-only)
10217 (not (gnus-request-replace-article
10218 (cdr gnus-article-current) (car gnus-article-current)
10219 (current-buffer) t)))
10220 (error "Couldn't replace article")
10221 ;; Update the summary buffer.
10222 (if (and references
10223 (equal (message-tokenize-header references " ")
10224 (message-tokenize-header
10225 (or (message-fetch-field "references") "") " ")))
10226 ;; We only have to update this line.
10229 (message-narrow-to-head)
10230 (let ((head (buffer-substring-no-properties
10231 (point-min) (point-max)))
10234 (insert (format "211 %d Article retrieved.\n"
10235 (cdr gnus-article-current)))
10238 (let ((nntp-server-buffer (current-buffer)))
10239 (setq header (car (gnus-get-newsgroup-headers
10241 (with-current-buffer gnus-summary-buffer
10242 (gnus-data-set-header
10243 (gnus-data-find (cdr gnus-article-current))
10245 (gnus-summary-update-article-line
10246 (cdr gnus-article-current) header)
10247 (if (gnus-summary-goto-subject
10248 (cdr gnus-article-current) nil t)
10249 (gnus-summary-update-secondary-mark
10250 (cdr gnus-article-current))))))))
10252 (set-buffer (or buffer gnus-summary-buffer))
10253 (gnus-summary-update-article (cdr gnus-article-current))
10254 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10255 (gnus-summary-update-secondary-mark
10256 (cdr gnus-article-current))))
10257 ;; Prettify the article buffer again.
10258 (unless no-highlight
10259 (with-current-buffer gnus-article-buffer
10260 ;;;!!! Fix this -- article should be rehighlighted.
10261 ;;;(gnus-run-hooks 'gnus-article-display-hook)
10262 (set-buffer gnus-original-article-buffer)
10263 (gnus-request-article
10264 (cdr gnus-article-current)
10265 (car gnus-article-current) (current-buffer))))
10266 ;; Prettify the summary buffer line.
10267 (when (gnus-visual-p 'summary-highlight 'highlight)
10268 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10270 (defun gnus-summary-edit-wash (key)
10271 "Perform editing command KEY in the article buffer."
10275 (message "%s" (concat (this-command-keys) "- "))
10278 (gnus-summary-edit-article)
10279 (execute-kbd-macro (concat (this-command-keys) key))
10280 (gnus-article-edit-done))
10284 (defun gnus-summary-respool-query (&optional silent trace)
10285 "Query where the respool algorithm would put this article."
10287 (let (gnus-mark-article-hook)
10288 (gnus-summary-select-article)
10289 (with-current-buffer gnus-original-article-buffer
10290 (let ((groups (nnmail-article-group 'identity trace)))
10293 (message "This message would go to %s"
10294 (mapconcat 'car groups ", "))
10295 (message "This message would go to no groups"))
10298 (defun gnus-summary-respool-trace ()
10299 "Trace where the respool algorithm would put this article.
10300 Display a buffer showing all fancy splitting patterns which matched."
10302 (gnus-summary-respool-query nil t))
10304 ;; Summary marking commands.
10306 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10307 "Mark articles which has the same subject as read, and then select the next.
10308 If UNMARK is positive, remove any kind of mark.
10309 If UNMARK is negative, tick articles."
10312 (setq unmark (prefix-numeric-value unmark)))
10314 (gnus-summary-mark-same-subject
10315 (gnus-summary-article-subject) unmark)))
10316 ;; Select next unread article. If auto-select-same mode, should
10317 ;; select the first unread article.
10318 (gnus-summary-next-article t (and gnus-auto-select-same
10319 (gnus-summary-article-subject)))
10320 (gnus-message 7 "%d article%s marked as %s"
10321 count (if (= count 1) " is" "s are")
10322 (if unmark "unread" "read"))))
10324 (defun gnus-summary-kill-same-subject (&optional unmark)
10325 "Mark articles which has the same subject as read.
10326 If UNMARK is positive, remove any kind of mark.
10327 If UNMARK is negative, tick articles."
10330 (setq unmark (prefix-numeric-value unmark)))
10332 (gnus-summary-mark-same-subject
10333 (gnus-summary-article-subject) unmark)))
10334 ;; If marked as read, go to next unread subject.
10335 (when (null unmark)
10336 ;; Go to next unread subject.
10337 (gnus-summary-next-subject 1 t))
10338 (gnus-message 7 "%d articles are marked as %s"
10339 count (if unmark "unread" "read"))))
10341 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10342 "Mark articles with same SUBJECT as read, and return marked number.
10343 If optional argument UNMARK is positive, remove any kinds of marks.
10344 If optional argument UNMARK is negative, mark articles as unread instead."
10348 ((null unmark) ; Mark as read.
10351 (gnus-summary-mark-article-as-read gnus-killed-mark)
10352 (gnus-summary-show-thread) t)
10353 (gnus-summary-find-subject subject))
10354 (setq count (1+ count))))
10355 ((> unmark 0) ; Tick.
10358 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10359 (gnus-summary-show-thread) t)
10360 (gnus-summary-find-subject subject))
10361 (setq count (1+ count))))
10362 (t ; Mark as unread.
10365 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10366 (gnus-summary-show-thread) t)
10367 (gnus-summary-find-subject subject))
10368 (setq count (1+ count)))))
10369 (gnus-set-mode-line 'summary)
10370 ;; Return the number of marked articles.
10373 (defun gnus-summary-mark-as-processable (n &optional unmark)
10374 "Set the process mark on the next N articles.
10375 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10376 the process mark instead. The difference between N and the actual
10377 number of articles marked is returned."
10379 (if (and (null n) (gnus-region-active-p))
10380 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10381 (setq n (prefix-numeric-value n))
10382 (let ((backward (< n 0))
10387 (gnus-summary-remove-process-mark
10388 (gnus-summary-article-number))
10389 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10390 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10393 (gnus-message 7 "No more articles"))
10394 (gnus-summary-recenter)
10395 (gnus-summary-position-point)
10398 (defun gnus-summary-unmark-as-processable (n)
10399 "Remove the process mark from the next N articles.
10400 If N is negative, unmark backward instead. The difference between N and
10401 the actual number of articles unmarked is returned."
10403 (gnus-summary-mark-as-processable n t))
10405 (defun gnus-summary-unmark-all-processable ()
10406 "Remove the process mark from all articles."
10409 (while gnus-newsgroup-processable
10410 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10411 (gnus-summary-position-point))
10413 (defun gnus-summary-add-mark (article type)
10414 "Mark ARTICLE with a mark of TYPE."
10415 (let ((vtype (car (assq type gnus-article-mark-lists)))
10418 (error "No such mark type: %s" type)
10419 (setq var (intern (format "gnus-newsgroup-%s" type)))
10420 (set var (cons article (symbol-value var)))
10421 (if (memq type '(processable cached replied forwarded recent saved))
10422 (gnus-summary-update-secondary-mark article)
10423 ;;; !!! This is bogus. We should find out what primary
10424 ;;; !!! mark we want to set.
10425 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10427 (defun gnus-summary-mark-as-expirable (n)
10428 "Mark N articles forward as expirable.
10429 If N is negative, mark backward instead. The difference between N and
10430 the actual number of articles marked is returned."
10432 (gnus-summary-mark-forward n gnus-expirable-mark))
10434 (defun gnus-summary-mark-as-spam (n)
10435 "Mark N articles forward as spam.
10436 If N is negative, mark backward instead. The difference between N and
10437 the actual number of articles marked is returned."
10439 (gnus-summary-mark-forward n gnus-spam-mark))
10441 (defun gnus-summary-mark-article-as-replied (article)
10442 "Mark ARTICLE as replied to and update the summary line.
10443 ARTICLE can also be a list of articles."
10444 (interactive (list (gnus-summary-article-number)))
10445 (let ((articles (if (listp article) article (list article))))
10446 (dolist (article articles)
10447 (unless (numberp article)
10448 (error "%s is not a number" article))
10449 (push article gnus-newsgroup-replied)
10450 (let ((inhibit-read-only t))
10451 (when (gnus-summary-goto-subject article nil t)
10452 (gnus-summary-update-secondary-mark article))))))
10454 (defun gnus-summary-mark-article-as-forwarded (article)
10455 "Mark ARTICLE as forwarded and update the summary line.
10456 ARTICLE can also be a list of articles."
10457 (let ((articles (if (listp article) article (list article))))
10458 (dolist (article articles)
10459 (push article gnus-newsgroup-forwarded)
10460 (let ((inhibit-read-only t))
10461 (when (gnus-summary-goto-subject article nil t)
10462 (gnus-summary-update-secondary-mark article))))))
10464 (defun gnus-summary-set-bookmark (article)
10465 "Set a bookmark in current article."
10466 (interactive (list (gnus-summary-article-number)))
10467 (when (or (not (get-buffer gnus-article-buffer))
10468 (not gnus-current-article)
10469 (not gnus-article-current)
10470 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10471 (error "No current article selected"))
10472 ;; Remove old bookmark, if one exists.
10473 (gnus-pull article gnus-newsgroup-bookmarks)
10474 ;; Set the new bookmark, which is on the form
10475 ;; (article-number . line-number-in-body).
10478 (with-current-buffer gnus-article-buffer
10482 (article-goto-body)
10485 gnus-newsgroup-bookmarks)
10486 (gnus-message 6 "A bookmark has been added to the current article."))
10488 (defun gnus-summary-remove-bookmark (article)
10489 "Remove the bookmark from the current article."
10490 (interactive (list (gnus-summary-article-number)))
10491 ;; Remove old bookmark, if one exists.
10492 (if (not (assq article gnus-newsgroup-bookmarks))
10493 (gnus-message 6 "No bookmark in current article.")
10494 (gnus-pull article gnus-newsgroup-bookmarks)
10495 (gnus-message 6 "Removed bookmark.")))
10497 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10498 (defun gnus-summary-mark-as-dormant (n)
10499 "Mark N articles forward as dormant.
10500 If N is negative, mark backward instead. The difference between N and
10501 the actual number of articles marked is returned."
10503 (gnus-summary-mark-forward n gnus-dormant-mark))
10505 (defun gnus-summary-set-process-mark (article)
10506 "Set the process mark on ARTICLE and update the summary line."
10507 (setq gnus-newsgroup-processable
10509 (delq article gnus-newsgroup-processable)))
10510 (when (gnus-summary-goto-subject article)
10511 (gnus-summary-show-thread)
10512 (gnus-summary-goto-subject article)
10513 (gnus-summary-update-secondary-mark article)))
10515 (defun gnus-summary-remove-process-mark (&rest articles)
10516 "Remove the process mark from ARTICLES and update the summary line."
10517 (dolist (article articles)
10518 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10519 (when (gnus-summary-goto-subject article)
10520 (gnus-summary-show-thread)
10521 (gnus-summary-goto-subject article)
10522 (gnus-summary-update-secondary-mark article)))
10525 (defun gnus-summary-set-saved-mark (article)
10526 "Set the process mark on ARTICLE and update the summary line."
10527 (push article gnus-newsgroup-saved)
10528 (when (gnus-summary-goto-subject article)
10529 (gnus-summary-update-secondary-mark article)))
10531 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10532 "Mark N articles as read forwards.
10533 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10534 The difference between N and the actual number of articles marked is
10536 If NO-EXPIRE, auto-expiry will be inhibited."
10538 (gnus-summary-show-thread)
10539 (let ((backward (< n 0))
10540 (gnus-summary-goto-unread
10541 (and gnus-summary-goto-unread
10542 (not (eq gnus-summary-goto-unread 'never))
10543 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10544 gnus-ticked-mark gnus-dormant-mark)))))
10546 (mark (or mark gnus-del-mark)))
10547 (while (and (> n 0)
10548 (gnus-summary-mark-article nil mark no-expire)
10549 (zerop (gnus-summary-next-subject
10551 (and gnus-summary-goto-unread
10552 (not (eq gnus-summary-goto-unread 'never)))
10556 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10557 (gnus-summary-recenter)
10558 (gnus-summary-position-point)
10559 (gnus-set-mode-line 'summary)
10562 (defun gnus-summary-mark-article-as-read (mark)
10563 "Mark the current article quickly as read with MARK."
10564 (let ((article (gnus-summary-article-number)))
10565 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10566 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10567 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10568 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10569 (push (cons article mark) gnus-newsgroup-reads)
10570 ;; Possibly remove from cache, if that is used.
10571 (when gnus-use-cache
10572 (gnus-cache-enter-remove-article article))
10573 ;; Allow the backend to change the mark.
10574 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10575 ;; Check for auto-expiry.
10576 (when (and gnus-newsgroup-auto-expire
10577 (memq mark gnus-auto-expirable-marks))
10578 (setq mark gnus-expirable-mark)
10579 ;; Let the backend know about the mark change.
10580 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10581 (push article gnus-newsgroup-expirable))
10582 ;; Set the mark in the buffer.
10583 (gnus-summary-update-mark mark 'unread)
10586 (defun gnus-summary-mark-article-as-unread (mark)
10587 "Mark the current article quickly as unread with MARK."
10588 (let* ((article (gnus-summary-article-number))
10589 (old-mark (gnus-summary-article-mark article)))
10590 ;; Allow the backend to change the mark.
10591 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10592 (if (eq mark old-mark)
10596 (gnus-error 1 "Can't mark negative article numbers")
10598 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10599 (setq gnus-newsgroup-spam-marked
10600 (delq article gnus-newsgroup-spam-marked))
10601 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10602 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10603 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10604 (cond ((= mark gnus-ticked-mark)
10605 (setq gnus-newsgroup-marked
10606 (gnus-add-to-sorted-list gnus-newsgroup-marked
10608 ((= mark gnus-spam-mark)
10609 (setq gnus-newsgroup-spam-marked
10610 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10612 ((= mark gnus-dormant-mark)
10613 (setq gnus-newsgroup-dormant
10614 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10617 (setq gnus-newsgroup-unreads
10618 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10620 (gnus-pull article gnus-newsgroup-reads)
10622 ;; See whether the article is to be put in the cache.
10623 (and gnus-use-cache
10624 (vectorp (gnus-summary-article-header article))
10626 (gnus-cache-possibly-enter-article
10627 gnus-newsgroup-name article
10628 (= mark gnus-ticked-mark)
10629 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10632 (gnus-summary-update-mark mark 'unread)
10635 (defun gnus-summary-mark-article (&optional article mark no-expire)
10636 "Mark ARTICLE with MARK. MARK can be any character.
10637 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10638 `??' (dormant) and `?E' (expirable).
10639 If MARK is nil, then the default character `?r' is used.
10640 If ARTICLE is nil, then the article on the current line will be
10642 If NO-EXPIRE, auto-expiry will be inhibited."
10643 ;; The mark might be a string.
10644 (when (stringp mark)
10645 (setq mark (aref mark 0)))
10646 ;; If no mark is given, then we check auto-expiring.
10648 (setq mark gnus-del-mark))
10649 (when (and (not no-expire)
10650 gnus-newsgroup-auto-expire
10651 (memq mark gnus-auto-expirable-marks))
10652 (setq mark gnus-expirable-mark))
10653 (let ((article (or article (gnus-summary-article-number)))
10654 (old-mark (gnus-summary-article-mark article)))
10655 ;; Allow the backend to change the mark.
10656 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10657 (if (eq mark old-mark)
10660 (error "No article on current line"))
10661 (if (not (if (or (= mark gnus-unread-mark)
10662 (= mark gnus-ticked-mark)
10663 (= mark gnus-spam-mark)
10664 (= mark gnus-dormant-mark))
10665 (gnus-mark-article-as-unread article mark)
10666 (gnus-mark-article-as-read article mark)))
10668 ;; See whether the article is to be put in the cache.
10669 (and gnus-use-cache
10670 (not (= mark gnus-canceled-mark))
10671 (vectorp (gnus-summary-article-header article))
10673 (gnus-cache-possibly-enter-article
10674 gnus-newsgroup-name article
10675 (= mark gnus-ticked-mark)
10676 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10678 (when (gnus-summary-goto-subject article nil t)
10679 (let ((inhibit-read-only t))
10680 (gnus-summary-show-thread)
10682 (gnus-summary-update-mark mark 'unread)
10685 (defun gnus-summary-update-secondary-mark (article)
10686 "Update the secondary (read, process, cache) mark."
10687 (gnus-summary-update-mark
10688 (cond ((memq article gnus-newsgroup-processable)
10690 ((memq article gnus-newsgroup-cached)
10692 ((memq article gnus-newsgroup-replied)
10694 ((memq article gnus-newsgroup-forwarded)
10695 gnus-forwarded-mark)
10696 ((memq article gnus-newsgroup-saved)
10698 ((memq article gnus-newsgroup-recent)
10700 ((memq article gnus-newsgroup-unseen)
10704 (when (gnus-visual-p 'summary-highlight 'highlight)
10705 (gnus-run-hooks 'gnus-summary-update-hook))
10708 (defun gnus-summary-update-download-mark (article)
10709 "Update the download mark."
10710 (gnus-summary-update-mark
10711 (cond ((memq article gnus-newsgroup-undownloaded)
10712 gnus-undownloaded-mark)
10713 (gnus-newsgroup-agentized
10714 gnus-downloaded-mark)
10718 (gnus-summary-update-line t)
10721 (defun gnus-summary-update-mark (mark type)
10722 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10723 (inhibit-read-only t))
10724 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10726 (when (looking-at "\r")
10728 (when (<= (+ forward (point)) (point-max))
10729 ;; Go to the right position on the line.
10730 (goto-char (+ forward (point)))
10731 ;; Replace the old mark with the new mark.
10732 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10733 ;; Optionally update the marks by some user rule.
10734 (when (eq type 'unread)
10735 (gnus-data-set-mark
10736 (gnus-data-find (gnus-summary-article-number)) mark)
10737 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10739 (defun gnus-mark-article-as-read (article &optional mark)
10740 "Enter ARTICLE in the pertinent lists and remove it from others."
10741 ;; Make the article expirable.
10742 (let ((mark (or mark gnus-del-mark)))
10743 (setq gnus-newsgroup-expirable
10744 (if (= mark gnus-expirable-mark)
10745 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10746 (delq article gnus-newsgroup-expirable)))
10747 ;; Remove from unread and marked lists.
10748 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10749 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10750 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10751 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10752 (push (cons article mark) gnus-newsgroup-reads)
10753 ;; Possibly remove from cache, if that is used.
10754 (when gnus-use-cache
10755 (gnus-cache-enter-remove-article article))
10758 (defun gnus-mark-article-as-unread (article &optional mark)
10759 "Enter ARTICLE in the pertinent lists and remove it from others."
10760 (let ((mark (or mark gnus-ticked-mark)))
10763 (gnus-error 1 "Can't mark negative article numbers")
10765 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10766 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10767 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10768 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10769 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10771 ;; Unsuppress duplicates?
10772 (when gnus-suppress-duplicates
10773 (gnus-dup-unsuppress-article article))
10775 (cond ((= mark gnus-ticked-mark)
10776 (setq gnus-newsgroup-marked
10777 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10778 ((= mark gnus-spam-mark)
10779 (setq gnus-newsgroup-spam-marked
10780 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10782 ((= mark gnus-dormant-mark)
10783 (setq gnus-newsgroup-dormant
10784 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10786 (setq gnus-newsgroup-unreads
10787 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10788 (gnus-pull article gnus-newsgroup-reads)
10791 (defalias 'gnus-summary-mark-as-unread-forward
10792 'gnus-summary-tick-article-forward)
10793 (make-obsolete 'gnus-summary-mark-as-unread-forward
10794 'gnus-summary-tick-article-forward)
10795 (defun gnus-summary-tick-article-forward (n)
10796 "Tick N articles forwards.
10797 If N is negative, tick backwards instead.
10798 The difference between N and the number of articles ticked is returned."
10800 (gnus-summary-mark-forward n gnus-ticked-mark))
10802 (defalias 'gnus-summary-mark-as-unread-backward
10803 'gnus-summary-tick-article-backward)
10804 (make-obsolete 'gnus-summary-mark-as-unread-backward
10805 'gnus-summary-tick-article-backward)
10806 (defun gnus-summary-tick-article-backward (n)
10807 "Tick N articles backwards.
10808 The difference between N and the number of articles ticked is returned."
10810 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10812 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10813 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10814 (defun gnus-summary-tick-article (&optional article clear-mark)
10815 "Mark current article as unread.
10816 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10817 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10819 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10820 gnus-ticked-mark)))
10822 (defun gnus-summary-mark-as-read-forward (n)
10823 "Mark N articles as read forwards.
10824 If N is negative, mark backwards instead.
10825 The difference between N and the actual number of articles marked is
10828 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10830 (defun gnus-summary-mark-as-read-backward (n)
10831 "Mark the N articles as read backwards.
10832 The difference between N and the actual number of articles marked is
10835 (gnus-summary-mark-forward
10836 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10838 (defun gnus-summary-mark-as-read (&optional article mark)
10839 "Mark current article as read.
10840 ARTICLE specifies the article to be marked as read.
10841 MARK specifies a string to be inserted at the beginning of the line."
10842 (gnus-summary-mark-article article mark))
10844 (defun gnus-summary-clear-mark-forward (n)
10845 "Clear marks from N articles forward.
10846 If N is negative, clear backward instead.
10847 The difference between N and the number of marks cleared is returned."
10849 (gnus-summary-mark-forward n gnus-unread-mark))
10851 (defun gnus-summary-clear-mark-backward (n)
10852 "Clear marks from N articles backward.
10853 The difference between N and the number of marks cleared is returned."
10855 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10857 (defun gnus-summary-mark-unread-as-read ()
10858 "Intended to be used by `gnus-mark-article-hook'."
10859 (when (memq gnus-current-article gnus-newsgroup-unreads)
10860 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10862 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10863 "Intended to be used by `gnus-mark-article-hook'."
10864 (let ((mark (gnus-summary-article-mark)))
10865 (when (or (gnus-unread-mark-p mark)
10866 (gnus-read-mark-p mark))
10867 (gnus-summary-mark-article gnus-current-article
10868 (or new-mark gnus-read-mark)))))
10870 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10871 "Intended to be used by `gnus-mark-article-hook'."
10872 (let ((mark (gnus-summary-article-mark)))
10873 (when (or (gnus-unread-mark-p mark)
10874 (gnus-read-mark-p mark))
10875 (gnus-summary-mark-article (gnus-summary-article-number)
10876 (or new-mark gnus-read-mark)))))
10878 (defun gnus-summary-mark-unread-as-ticked ()
10879 "Intended to be used by `gnus-mark-article-hook'."
10880 (when (memq gnus-current-article gnus-newsgroup-unreads)
10881 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10883 (defun gnus-summary-mark-region-as-read (point mark all)
10884 "Mark all unread articles between point and mark as read.
10885 If given a prefix, mark all articles between point and mark as read,
10886 even ticked and dormant ones."
10887 (interactive "r\nP")
10891 (beginning-of-line)
10896 (memq (setq article (gnus-summary-article-number))
10897 gnus-newsgroup-unreads))
10898 (gnus-summary-mark-article article gnus-del-mark))
10900 (gnus-summary-find-next))))))
10902 (defun gnus-summary-mark-below (score mark)
10903 "Mark articles with score less than SCORE with MARK."
10904 (interactive "P\ncMark: ")
10905 (setq score (if score
10906 (prefix-numeric-value score)
10907 (or gnus-summary-default-score 0)))
10908 (with-current-buffer gnus-summary-buffer
10909 (goto-char (point-min))
10912 (and (< (gnus-summary-article-score) score)
10913 (gnus-summary-mark-article nil mark))
10914 (gnus-summary-find-next)))))
10916 (defun gnus-summary-kill-below (&optional score)
10917 "Mark articles with score below SCORE as read."
10919 (gnus-summary-mark-below score gnus-killed-mark))
10921 (defun gnus-summary-clear-above (&optional score)
10922 "Clear all marks from articles with score above SCORE."
10924 (gnus-summary-mark-above score gnus-unread-mark))
10926 (defun gnus-summary-tick-above (&optional score)
10927 "Tick all articles with score above SCORE."
10929 (gnus-summary-mark-above score gnus-ticked-mark))
10931 (defun gnus-summary-mark-above (score mark)
10932 "Mark articles with score over SCORE with MARK."
10933 (interactive "P\ncMark: ")
10934 (setq score (if score
10935 (prefix-numeric-value score)
10936 (or gnus-summary-default-score 0)))
10937 (with-current-buffer gnus-summary-buffer
10938 (goto-char (point-min))
10940 (when (> (gnus-summary-article-score) score)
10941 (gnus-summary-mark-article nil mark))
10943 (gnus-summary-find-next)))))
10945 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10946 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10947 (defun gnus-summary-limit-include-expunged (&optional no-error)
10948 "Display all the hidden articles that were expunged for low scores."
10950 (let ((inhibit-read-only t))
10951 (let ((scored gnus-newsgroup-scored)
10954 (unless (gnus-summary-article-header (caar scored))
10955 (and (setq h (gnus-number-to-header (caar scored)))
10956 (< (cdar scored) gnus-summary-expunge-below)
10958 (setq scored (cdr scored)))
10960 (when (not no-error)
10961 (error "No expunged articles hidden"))
10962 (goto-char (point-min))
10963 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10964 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10965 (dolist (x headers)
10966 (push (mail-header-number x) gnus-newsgroup-limit))
10967 (gnus-summary-prepare-unthreaded (nreverse headers))
10968 (goto-char (point-min))
10969 (gnus-summary-position-point)
10972 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10973 "Mark all unread articles in this newsgroup as read.
10974 If prefix argument ALL is non-nil, ticked and dormant articles will
10975 also be marked as read.
10976 If QUIETLY is non-nil, no questions will be asked.
10978 If TO-HERE is non-nil, it should be a point in the buffer. All
10979 articles before (after, if REVERSE is set) this point will be marked
10982 Note that this function will only catch up the unread article
10983 in the current summary buffer limitation.
10985 The number of articles marked as read is returned."
10990 (not gnus-interactive-catchup) ;Without confirmation?
10994 "Mark absolutely all articles as read? "
10995 "Mark all unread articles as read? ")))
10997 (not gnus-newsgroup-adaptive)
10998 (not gnus-newsgroup-auto-expire)
10999 (not gnus-suppress-duplicates)
11000 (or (not gnus-use-cache)
11001 (eq gnus-use-cache 'passive)))
11004 (setq gnus-newsgroup-marked nil
11005 gnus-newsgroup-spam-marked nil
11006 gnus-newsgroup-dormant nil))
11007 (setq gnus-newsgroup-unreads
11008 (gnus-sorted-nunion
11009 (gnus-sorted-intersection gnus-newsgroup-unreads
11010 gnus-newsgroup-downloadable)
11011 (gnus-sorted-difference gnus-newsgroup-unfetched
11012 gnus-newsgroup-cached))))
11013 ;; We actually mark all articles as canceled, which we
11014 ;; have to do when using auto-expiry or adaptive scoring.
11015 (gnus-summary-show-all-threads)
11016 (if (and to-here reverse)
11018 (goto-char to-here)
11019 (gnus-summary-mark-current-read-and-unread-as-read
11021 (while (gnus-summary-find-next (not all))
11022 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11023 (when (gnus-summary-first-subject (not all))
11025 (if to-here (< (point) to-here) t)
11026 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11027 (gnus-summary-find-next (not all))))))
11028 (gnus-set-mode-line 'summary))
11030 (gnus-summary-position-point)))
11032 (defun gnus-summary-catchup-to-here (&optional all)
11033 "Mark all unticked articles before the current one as read.
11034 If ALL is non-nil, also mark ticked and dormant articles as read."
11037 (gnus-save-hidden-threads
11038 (let ((beg (point)))
11039 ;; We check that there are unread articles.
11040 (when (or all (gnus-summary-find-prev))
11041 (gnus-summary-catchup all t beg)))))
11042 (gnus-summary-position-point))
11044 (defun gnus-summary-catchup-from-here (&optional all)
11045 "Mark all unticked articles after (and including) the current one as read.
11046 If ALL is non-nil, also mark ticked and dormant articles as read."
11049 (gnus-save-hidden-threads
11050 (let ((beg (point)))
11051 ;; We check that there are unread articles.
11052 (when (or all (gnus-summary-find-next))
11053 (gnus-summary-catchup all t beg nil t)))))
11054 (gnus-summary-position-point))
11056 (defun gnus-summary-catchup-all (&optional quietly)
11057 "Mark all articles in this newsgroup as read.
11058 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11059 instead, which marks only unread articles as read."
11061 (gnus-summary-catchup t quietly))
11063 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11064 "Mark all unread articles in this group as read, then exit.
11065 If prefix argument ALL is non-nil, all articles are marked as read.
11066 If QUIETLY is non-nil, no questions will be asked."
11068 (when (gnus-summary-catchup all quietly nil 'fast)
11069 ;; Select next newsgroup or exit.
11070 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11071 (eq gnus-auto-select-next 'quietly))
11072 (gnus-summary-next-group nil)
11073 (gnus-summary-exit))))
11075 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11076 "Mark all articles in this newsgroup as read, and then exit.
11077 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11078 instead, which marks only unread articles as read."
11080 (gnus-summary-catchup-and-exit t quietly))
11082 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11083 "Mark all articles in this group as read and select the next group.
11084 If given a prefix, mark all articles, unread as well as ticked, as
11088 (gnus-summary-catchup all))
11089 (gnus-summary-next-group))
11091 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11092 "Mark all articles in this group as read and select the previous group.
11093 If given a prefix, mark all articles, unread as well as ticked, as
11097 (gnus-summary-catchup all))
11098 (gnus-summary-next-group nil nil t))
11104 (defmacro gnus-with-article (article &rest forms)
11105 "Select ARTICLE and perform FORMS in the original article buffer.
11106 Then replace the article with the result."
11108 ;; We don't want the article to be marked as read.
11109 (let (gnus-mark-article-hook)
11110 (gnus-summary-select-article t t nil ,article))
11111 (set-buffer gnus-original-article-buffer)
11113 (if (not (gnus-check-backend-function
11114 'request-replace-article (car gnus-article-current)))
11115 (gnus-message 5 "Read-only group; not replacing")
11116 (unless (gnus-request-replace-article
11117 ,article (car gnus-article-current)
11118 (current-buffer) t)
11119 (error "Couldn't replace article")))
11120 ;; The cache and backlog have to be flushed somewhat.
11121 (when gnus-keep-backlog
11122 (gnus-backlog-remove-article
11123 (car gnus-article-current) (cdr gnus-article-current)))
11124 (when gnus-use-cache
11125 (gnus-cache-update-article
11126 (car gnus-article-current) (cdr gnus-article-current)))))
11128 (put 'gnus-with-article 'lisp-indent-function 1)
11129 (put 'gnus-with-article 'edebug-form-spec '(form body))
11131 ;; Thread-based commands.
11133 (defun gnus-summary-articles-in-thread (&optional article)
11134 "Return a list of all articles in the current thread.
11135 If ARTICLE is non-nil, return all articles in the thread that starts
11136 with that article."
11137 (let* ((article (or article (gnus-summary-article-number)))
11138 (data (gnus-data-find-list article))
11139 (top-level (gnus-data-level (car data)))
11141 (cond ((null gnus-thread-operation-ignore-subject)
11142 (gnus-simplify-subject-re
11143 (mail-header-subject (gnus-data-header (car data)))))
11144 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11145 (gnus-simplify-subject-fuzzy
11146 (mail-header-subject (gnus-data-header (car data)))))
11148 (end-point (save-excursion
11149 (if (gnus-summary-go-to-next-thread)
11150 (point) (point-max))))
11153 (< (gnus-data-pos (car data)) end-point))
11154 (when (or (not top-subject)
11155 (string= top-subject
11156 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11157 (gnus-simplify-subject-fuzzy
11158 (mail-header-subject
11159 (gnus-data-header (car data))))
11160 (gnus-simplify-subject-re
11161 (mail-header-subject
11162 (gnus-data-header (car data)))))))
11163 (push (gnus-data-number (car data)) articles))
11164 (unless (and (setq data (cdr data))
11165 (> (gnus-data-level (car data)) top-level))
11167 ;; Return the list of articles.
11168 (nreverse articles)))
11170 (defun gnus-summary-rethread-current ()
11171 "Rethread the thread the current article is part of."
11173 (let* ((gnus-show-threads t)
11174 (article (gnus-summary-article-number))
11175 (id (mail-header-id (gnus-summary-article-header)))
11176 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11178 (error "No article on the current line"))
11179 (gnus-rebuild-thread id)
11180 (gnus-summary-goto-subject article)))
11182 (defun gnus-summary-reparent-thread ()
11183 "Make the current article child of the marked (or previous) article.
11185 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11186 is non-nil or the Subject: of both articles are the same."
11188 (unless (not (gnus-group-read-only-p))
11189 (error "The current newsgroup does not support article editing"))
11190 (unless (<= (length gnus-newsgroup-processable) 1)
11191 (error "No more than one article may be marked"))
11192 (let ((child (gnus-summary-article-number))
11193 ;; First grab the marked article, otherwise one line up.
11194 (parent (if (not (null gnus-newsgroup-processable))
11195 (car gnus-newsgroup-processable)
11197 (if (eq (forward-line -1) 0)
11198 (gnus-summary-article-number)
11199 (error "Beginning of summary buffer"))))))
11200 (gnus-summary-reparent-children parent (list child))))
11202 (defun gnus-summary-reparent-children (parent children)
11203 "Make PARENT the parent of CHILDREN.
11204 When called interactively, PARENT is the current article and CHILDREN
11205 are the process-marked articles."
11207 (list (gnus-summary-article-number)
11208 (gnus-summary-work-articles nil)))
11209 (dolist (child children)
11210 (save-window-excursion
11211 (let ((gnus-article-buffer " *reparent*"))
11212 (unless (not (eq parent child))
11213 (error "An article may not be self-referential"))
11214 (let ((message-id (mail-header-id
11215 (gnus-summary-article-header parent))))
11216 (unless (and message-id (not (equal message-id "")))
11217 (error "No message-id in desired parent"))
11218 (gnus-with-article child
11220 (goto-char (point-min))
11221 (message-narrow-to-head)
11222 (if (re-search-forward "^References: " nil t)
11224 (re-search-forward "^[^ \t]" nil t)
11227 (insert " " message-id))
11228 (insert "References: " message-id "\n"))))
11229 (set-buffer gnus-summary-buffer)
11230 (gnus-summary-unmark-all-processable)
11231 (gnus-summary-update-article child)
11232 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11233 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11234 (gnus-summary-rethread-current)
11235 (gnus-message 3 "Article %d is now the child of article %d"
11238 (defun gnus-summary-toggle-threads (&optional arg)
11239 "Toggle showing conversation threads.
11240 If ARG is positive number, turn showing conversation threads on."
11242 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11243 (setq gnus-show-threads
11244 (if (null arg) (not gnus-show-threads)
11245 (> (prefix-numeric-value arg) 0)))
11246 (gnus-summary-prepare)
11247 (gnus-summary-goto-subject current)
11248 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11249 (gnus-summary-position-point)))
11251 (defun gnus-summary-show-all-threads ()
11252 "Show all threads."
11255 (let ((buffer-read-only nil))
11256 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
11257 (gnus-summary-position-point))
11259 (defun gnus-summary-show-thread ()
11260 "Show thread subtrees.
11261 Returns nil if no thread was there to be shown."
11263 (let ((buffer-read-only nil)
11265 (end (point-at-eol))
11266 ;; Leave point at bol
11267 (beg (progn (beginning-of-line) (point))))
11269 ;; Any hidden lines here?
11270 (search-forward "\r" end t)
11271 (subst-char-in-region beg end ?\^M ?\n t)
11273 (gnus-summary-position-point))))
11275 (defun gnus-summary-maybe-hide-threads ()
11276 "If requested, hide the threads that should be hidden."
11277 (when (and gnus-show-threads
11278 gnus-thread-hide-subtree)
11279 (gnus-summary-hide-all-threads
11280 (if (or (consp gnus-thread-hide-subtree)
11281 (functionp gnus-thread-hide-subtree))
11282 (gnus-make-predicate gnus-thread-hide-subtree)
11285 ;;; Hiding predicates.
11287 (defun gnus-article-unread-p (header)
11288 (memq (mail-header-number header) gnus-newsgroup-unreads))
11290 (defun gnus-article-unseen-p (header)
11291 (memq (mail-header-number header) gnus-newsgroup-unseen))
11293 (defun gnus-map-articles (predicate articles)
11294 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11295 (apply 'gnus-or (mapcar predicate
11296 (mapcar (lambda (number)
11297 (gnus-summary-article-header number))
11300 (defun gnus-summary-hide-all-threads (&optional predicate)
11301 "Hide all thread subtrees.
11302 If PREDICATE is supplied, threads that satisfy this predicate
11303 will not be hidden."
11306 (goto-char (point-min))
11309 (when (or (not predicate)
11311 predicate (gnus-summary-article-children)))
11312 (gnus-summary-hide-thread))
11313 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11314 (gnus-summary-position-point))
11316 (defun gnus-summary-hide-thread ()
11317 "Hide thread subtrees.
11318 If PREDICATE is supplied, threads that satisfy this predicate
11319 will not be hidden.
11320 Returns nil if no threads were there to be hidden."
11322 (let ((buffer-read-only nil)
11324 (article (gnus-summary-article-number)))
11326 ;; Go forward until either the buffer ends or the subthread ends.
11327 (when (and (not (eobp))
11328 (or (zerop (gnus-summary-next-thread 1 t))
11329 (goto-char (point-max))))
11331 (if (and (> (point) start)
11332 (search-backward "\n" start t))
11334 (subst-char-in-region start (point) ?\n ?\^M)
11335 (gnus-summary-goto-subject article))
11339 (defun gnus-summary-go-to-next-thread (&optional previous)
11340 "Go to the same level (or less) next thread.
11341 If PREVIOUS is non-nil, go to previous thread instead.
11342 Return the article number moved to, or nil if moving was impossible."
11343 (let ((level (gnus-summary-thread-level))
11344 (way (if previous -1 1))
11347 (while (and (not (eobp))
11348 (< level (gnus-summary-thread-level)))
11349 (forward-line way))
11356 (gnus-summary-article-number)
11357 (goto-char beg)))))
11359 (defun gnus-summary-next-thread (n &optional silent)
11360 "Go to the same level next N'th thread.
11361 If N is negative, search backward instead.
11362 Returns the difference between N and the number of skips actually
11365 If SILENT, don't output messages."
11367 (let ((backward (< n 0))
11369 (while (and (> n 0)
11370 (gnus-summary-go-to-next-thread backward))
11373 (gnus-summary-position-point))
11374 (when (and (not silent) (/= 0 n))
11375 (gnus-message 7 "No more threads"))
11378 (defun gnus-summary-prev-thread (n)
11379 "Go to the same level previous N'th thread.
11380 Returns the difference between N and the number of skips actually
11383 (gnus-summary-next-thread (- n)))
11385 (defun gnus-summary-go-down-thread ()
11386 "Go down one level in the current thread."
11387 (let ((children (gnus-summary-article-children)))
11389 (gnus-summary-goto-subject (car children)))))
11391 (defun gnus-summary-go-up-thread ()
11392 "Go up one level in the current thread."
11393 (let ((parent (gnus-summary-article-parent)))
11395 (gnus-summary-goto-subject parent))))
11397 (defun gnus-summary-down-thread (n)
11398 "Go down thread N steps.
11399 If N is negative, go up instead.
11400 Returns the difference between N and how many steps down that were
11405 (while (and (> n 0)
11406 (if up (gnus-summary-go-up-thread)
11407 (gnus-summary-go-down-thread)))
11409 (gnus-summary-position-point)
11411 (gnus-message 7 "Can't go further"))
11414 (defun gnus-summary-up-thread (n)
11415 "Go up thread N steps.
11416 If N is negative, go down instead.
11417 Returns the difference between N and how many steps down that were
11420 (gnus-summary-down-thread (- n)))
11422 (defun gnus-summary-top-thread ()
11423 "Go to the top of the thread."
11425 (while (gnus-summary-go-up-thread))
11426 (gnus-summary-article-number))
11428 (defun gnus-summary-expire-thread ()
11429 "Mark articles under current thread as expired."
11431 (gnus-summary-kill-thread 0))
11433 (defun gnus-summary-kill-thread (&optional unmark)
11434 "Mark articles under current thread as read.
11435 If the prefix argument is positive, remove any kinds of marks.
11436 If the prefix argument is zero, mark thread as expired.
11437 If the prefix argument is negative, tick articles instead."
11440 (setq unmark (prefix-numeric-value unmark)))
11441 (let ((articles (gnus-summary-articles-in-thread))
11442 (hide (or (null unmark) (= unmark 0))))
11444 ;; Expand the thread.
11445 (gnus-summary-show-thread)
11446 ;; Mark all the articles.
11448 (gnus-summary-goto-subject (car articles))
11449 (cond ((null unmark)
11450 (gnus-summary-mark-article-as-read gnus-killed-mark))
11452 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11454 (gnus-summary-mark-article-as-unread gnus-expirable-mark))
11456 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11457 (setq articles (cdr articles))))
11458 ;; Hide killed subtrees when hide is true.
11460 gnus-thread-hide-killed
11461 (gnus-summary-hide-thread))
11462 ;; If hide is t, go to next unread subject.
11464 ;; Go to next unread subject.
11465 (gnus-summary-next-subject 1 t)))
11466 (gnus-set-mode-line 'summary))
11468 ;; Summary sorting commands
11470 (defun gnus-summary-sort-by-number (&optional reverse)
11471 "Sort the summary buffer by article number.
11472 Argument REVERSE means reverse order."
11474 (gnus-summary-sort 'number reverse))
11476 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11477 "Sort the summary buffer by most recent article number.
11478 Argument REVERSE means reverse order."
11480 (gnus-summary-sort 'most-recent-number reverse))
11482 (defun gnus-summary-sort-by-random (&optional reverse)
11483 "Randomize the order in the summary buffer.
11484 Argument REVERSE means to randomize in reverse order."
11486 (gnus-summary-sort 'random reverse))
11488 (defun gnus-summary-sort-by-author (&optional reverse)
11489 "Sort the summary buffer by author name alphabetically.
11490 If `case-fold-search' is non-nil, case of letters is ignored.
11491 Argument REVERSE means reverse order."
11493 (gnus-summary-sort 'author reverse))
11495 (defun gnus-summary-sort-by-recipient (&optional reverse)
11496 "Sort the summary buffer by recipient name alphabetically.
11497 If `case-fold-search' is non-nil, case of letters is ignored.
11498 Argument REVERSE means reverse order."
11500 (gnus-summary-sort 'recipient reverse))
11502 (defun gnus-summary-sort-by-subject (&optional reverse)
11503 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11504 If `case-fold-search' is non-nil, case of letters is ignored.
11505 Argument REVERSE means reverse order."
11507 (gnus-summary-sort 'subject reverse))
11509 (defun gnus-summary-sort-by-date (&optional reverse)
11510 "Sort the summary buffer by date.
11511 Argument REVERSE means reverse order."
11513 (gnus-summary-sort 'date reverse))
11515 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11516 "Sort the summary buffer by most recent date.
11517 Argument REVERSE means reverse order."
11519 (gnus-summary-sort 'most-recent-date reverse))
11521 (defun gnus-summary-sort-by-score (&optional reverse)
11522 "Sort the summary buffer by score.
11523 Argument REVERSE means reverse order."
11525 (gnus-summary-sort 'score reverse))
11527 (defun gnus-summary-sort-by-lines (&optional reverse)
11528 "Sort the summary buffer by the number of lines.
11529 Argument REVERSE means reverse order."
11531 (gnus-summary-sort 'lines reverse))
11533 (defun gnus-summary-sort-by-chars (&optional reverse)
11534 "Sort the summary buffer by article length.
11535 Argument REVERSE means reverse order."
11537 (gnus-summary-sort 'chars reverse))
11539 (defun gnus-summary-sort-by-original (&optional reverse)
11540 "Sort the summary buffer using the default sorting method.
11541 Argument REVERSE means reverse order."
11543 (let* ((inhibit-read-only t)
11544 (gnus-summary-prepare-hook nil))
11545 ;; We do the sorting by regenerating the threads.
11546 (gnus-summary-prepare)
11547 ;; Hide subthreads if needed.
11548 (gnus-summary-maybe-hide-threads)))
11550 (defun gnus-summary-sort (predicate reverse)
11551 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11552 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11553 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11554 (gnus-thread-sort-functions
11559 (gnus-sort-gathered-threads-function
11560 gnus-thread-sort-functions)
11561 (gnus-article-sort-functions
11565 (,article t2 t1))))
11566 (inhibit-read-only t)
11567 (gnus-summary-prepare-hook nil))
11568 ;; We do the sorting by regenerating the threads.
11569 (gnus-summary-prepare)
11570 ;; Hide subthreads if needed.
11571 (gnus-summary-maybe-hide-threads)))
11573 ;; Summary saving commands.
11575 (defun gnus-summary-save-article (&optional n not-saved)
11576 "Save the current article using the default saver function.
11577 If N is a positive number, save the N next articles.
11578 If N is a negative number, save the N previous articles.
11579 If N is nil and any articles have been marked with the process mark,
11580 save those articles instead.
11581 The variable `gnus-default-article-saver' specifies the saver function.
11583 If the optional second argument NOT-SAVED is non-nil, articles saved
11584 will not be marked as saved."
11586 (require 'gnus-art)
11587 (let* ((articles (gnus-summary-work-articles n))
11588 (save-buffer (save-excursion
11589 (nnheader-set-temp-buffer " *Gnus Save*")))
11590 (num (length articles))
11591 ;; Whether to save decoded articles or raw articles.
11592 (decode (when gnus-article-save-coding-system
11593 (get gnus-default-article-saver :decode)))
11594 ;; When saving many articles in a single file, use the other
11595 ;; function to save articles other than the first one.
11596 (saver2 (get gnus-default-article-saver :function))
11597 (gnus-prompt-before-saving (if saver2
11599 gnus-prompt-before-saving))
11600 (gnus-default-article-saver gnus-default-article-saver)
11602 (dolist (article articles)
11603 (setq header (gnus-summary-article-header article))
11604 (if (not (vectorp header))
11605 ;; This is a pseudo-article.
11606 (if (assq 'name header)
11607 (gnus-copy-file (cdr (assq 'name header)))
11608 (gnus-message 1 "Article %d is unsaveable" article))
11609 ;; This is a real article.
11610 (save-window-excursion
11611 (let ((gnus-display-mime-function (when decode
11612 gnus-display-mime-function))
11613 (gnus-article-prepare-hook (when decode
11614 gnus-article-prepare-hook)))
11615 (gnus-summary-select-article t t nil article)
11616 (gnus-summary-goto-subject article)))
11617 (with-current-buffer save-buffer
11619 (insert-buffer-substring (if decode
11620 gnus-article-buffer
11621 gnus-original-article-buffer)))
11622 (setq file (gnus-article-save save-buffer file num))
11623 (gnus-summary-remove-process-mark article)
11625 (gnus-summary-set-saved-mark article)))
11627 (setq gnus-default-article-saver saver2
11629 (gnus-kill-buffer save-buffer)
11630 (gnus-summary-position-point)
11631 (gnus-set-mode-line 'summary)
11634 (defun gnus-summary-pipe-output (&optional n sym)
11635 "Pipe the current article to a subprocess.
11636 If N is a positive number, pipe the N next articles.
11637 If N is a negative number, pipe the N previous articles.
11638 If N is nil and any articles have been marked with the process mark,
11639 pipe those articles instead.
11640 The default command to which articles are piped is specified by the
11641 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11642 will be prompted for the command.
11644 The properties `:decode' and `:headers' that are put to the function
11645 symbol `gnus-summary-save-in-pipe' control whether this function
11646 decodes articles and what headers to keep (see the doc string for the
11647 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11648 is neither omitted nor the symbol `r', force including all headers
11649 regardless of the `:headers' property. If it is the symbol `r',
11650 articles that are not decoded and include all headers will be piped
11651 no matter what the properties `:decode' and `:headers' are."
11652 (interactive (gnus-interactive "P\ny"))
11653 (require 'gnus-art)
11654 (let* ((articles (gnus-summary-work-articles n))
11655 (result-buffer "*Shell Command Output*")
11656 (all-headers (not (memq sym '(nil r))))
11657 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11659 (headers (get 'gnus-summary-save-in-pipe :headers))
11661 (unless (numberp (car articles))
11662 (error "No article to pipe"))
11663 (setq command (gnus-read-shell-command
11664 (concat "Shell command on "
11666 (format "these %d articles" (length articles))
11669 gnus-summary-pipe-output-default-command))
11670 (when (string-equal command "")
11671 (error "A command is required"))
11673 (put 'gnus-summary-save-in-pipe :headers nil))
11676 (gnus-summary-goto-subject (pop articles))
11677 (save-window-excursion (gnus-summary-save-in-pipe command raw))
11678 (when (and (get-buffer result-buffer)
11679 (not (zerop (buffer-size (get-buffer result-buffer)))))
11680 (setq result (concat result (with-current-buffer result-buffer
11681 (buffer-string))))))
11682 (put 'gnus-summary-save-in-pipe :headers headers))
11683 (unless (zerop (length result))
11684 (if (with-current-buffer (get-buffer-create result-buffer)
11688 (and (= (count-lines (point-min) (point)) 1)
11691 (<= (current-column)
11692 (window-width (minibuffer-window)))))
11693 (goto-char (point-min))))
11694 (message "%s" (substring result 0 -1))
11696 (gnus-configure-windows 'pipe)))))
11698 (defun gnus-summary-save-article-mail (&optional arg)
11699 "Append the current article to a Unix mail box file.
11700 If N is a positive number, save the N next articles.
11701 If N is a negative number, save the N previous articles.
11702 If N is nil and any articles have been marked with the process mark,
11703 save those articles instead."
11705 (require 'gnus-art)
11706 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11707 (gnus-summary-save-article arg)))
11709 (defun gnus-summary-save-article-rmail (&optional arg)
11710 "Append the current article to an rmail file.
11711 If N is a positive number, save the N next articles.
11712 If N is a negative number, save the N previous articles.
11713 If N is nil and any articles have been marked with the process mark,
11714 save those articles instead."
11716 (require 'gnus-art)
11717 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11718 (gnus-summary-save-article arg)))
11720 (defun gnus-summary-save-article-file (&optional arg)
11721 "Append the current article to a file.
11722 If N is a positive number, save the N next articles.
11723 If N is a negative number, save the N previous articles.
11724 If N is nil and any articles have been marked with the process mark,
11725 save those articles instead."
11727 (require 'gnus-art)
11728 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11729 (gnus-summary-save-article arg)))
11731 (defun gnus-summary-write-article-file (&optional arg)
11732 "Write the current article to a file, deleting the previous file.
11733 If N is a positive number, save the N next articles.
11734 If N is a negative number, save the N previous articles.
11735 If N is nil and any articles have been marked with the process mark,
11736 save those articles instead."
11738 (require 'gnus-art)
11739 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11740 (gnus-summary-save-article arg)))
11742 (defun gnus-summary-save-article-body-file (&optional arg)
11743 "Append the current article body to a file.
11744 If N is a positive number, save the N next articles.
11745 If N is a negative number, save the N previous articles.
11746 If N is nil and any articles have been marked with the process mark,
11747 save those articles instead."
11749 (require 'gnus-art)
11750 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11751 (gnus-summary-save-article arg)))
11753 (defun gnus-summary-write-article-body-file (&optional arg)
11754 "Write the current article body to a file, deleting the previous file.
11755 If N is a positive number, save the N next articles.
11756 If N is a negative number, save the N previous articles.
11757 If N is nil and any articles have been marked with the process mark,
11758 save those articles instead."
11760 (require 'gnus-art)
11761 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11762 (gnus-summary-save-article arg)))
11764 (defun gnus-summary-muttprint (&optional arg)
11765 "Print the current article using Muttprint.
11766 If N is a positive number, save the N next articles.
11767 If N is a negative number, save the N previous articles.
11768 If N is nil and any articles have been marked with the process mark,
11769 save those articles instead."
11771 (require 'gnus-art)
11772 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11773 (gnus-summary-save-article arg t)))
11775 (defun gnus-summary-pipe-message (program)
11776 "Pipe the current article through PROGRAM."
11777 (interactive "sProgram: ")
11778 (gnus-summary-select-article)
11779 (let ((mail-header-separator ""))
11780 (gnus-eval-in-buffer-window gnus-article-buffer
11783 (let ((start (window-start))
11784 (inhibit-read-only t))
11785 (message-pipe-buffer-body program)
11786 (set-window-start (get-buffer-window (current-buffer)) start))))))
11788 (defun gnus-get-split-value (methods)
11789 "Return a value based on the split METHODS."
11790 (let (split-name method result match)
11792 (with-current-buffer gnus-original-article-buffer
11794 (nnheader-narrow-to-headers)
11795 (while (and methods (not split-name))
11796 (goto-char (point-min))
11797 (setq method (pop methods))
11798 (setq match (car method))
11801 ;; Regular expression.
11803 (re-search-forward match nil t)))
11808 (setq result (funcall match gnus-newsgroup-name))))
11813 (setq result (eval match)))))
11814 (setq split-name (cdr method))
11815 (cond ((stringp result)
11816 (push (expand-file-name
11817 result gnus-article-save-directory)
11820 (setq split-name (append result split-name)))))))))
11821 (nreverse split-name)))
11823 (defun gnus-valid-move-group-p (group)
11824 (and (boundp group)
11825 (symbol-name group)
11826 (symbol-value group)
11827 (gnus-get-function (gnus-find-method-for-group
11828 (symbol-name group)) 'request-accept-article t)))
11830 (defun gnus-read-move-group-name (prompt default articles prefix)
11831 "Read a group name."
11832 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11833 (minibuffer-confirm-incomplete nil) ; XEmacs
11837 (if (> (length articles) 1)
11838 (format "these %d articles" (length articles))
11841 (let (active group)
11842 (when (or (null split-name) (= 1 (length split-name)))
11843 (setq active (gnus-make-hashtable (length gnus-active-hashtb)))
11844 (mapatoms (lambda (symbol)
11845 (setq group (symbol-name symbol))
11846 (when (string-match "[^\000-\177]" group)
11847 (setq group (gnus-group-decoded-name group)))
11848 (set (intern group active) group))
11849 gnus-active-hashtb))
11852 (gnus-completing-read-with-default
11853 default prom active 'gnus-valid-move-group-p nil prefix
11854 'gnus-group-history))
11855 ((= 1 (length split-name))
11856 (gnus-completing-read-with-default
11857 (car split-name) prom active 'gnus-valid-move-group-p nil nil
11858 'gnus-group-history))
11860 (gnus-completing-read-with-default
11861 nil prom (mapcar 'list (nreverse split-name)) nil nil nil
11862 'gnus-group-history)))))
11863 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
11866 (if (or (string= to-newsgroup "")
11867 (string= to-newsgroup prefix))
11868 (setq to-newsgroup default))
11869 (unless to-newsgroup
11870 (error "No group name entered"))
11871 (setq encoded (mm-encode-coding-string
11873 (gnus-group-name-charset to-method to-newsgroup)))
11874 (or (gnus-active encoded)
11875 (gnus-activate-group encoded nil nil to-method)
11876 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11878 (or (and (gnus-request-create-group encoded to-method)
11879 (gnus-activate-group encoded nil nil to-method)
11880 (gnus-subscribe-group encoded))
11881 (error "Couldn't create group %s" to-newsgroup)))
11882 (error "No such group: %s" to-newsgroup))
11885 (defvar gnus-summary-save-parts-counter)
11886 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
11888 (defun gnus-summary-save-parts (type dir n &optional reverse)
11889 "Save parts matching TYPE to DIR.
11890 If REVERSE, save parts that do not match TYPE."
11892 (list (read-string "Save parts of type: "
11893 (or (car gnus-summary-save-parts-type-history)
11894 gnus-summary-save-parts-default-mime)
11895 'gnus-summary-save-parts-type-history)
11896 (setq gnus-summary-save-parts-last-directory
11897 (read-file-name "Save to directory: "
11898 gnus-summary-save-parts-last-directory
11900 current-prefix-arg))
11901 (gnus-summary-iterate n
11902 (let ((gnus-display-mime-function nil)
11903 gnus-article-prepare-hook
11904 gnus-article-decode-hook
11905 gnus-display-mime-function
11907 (gnus-inhibit-treatment t))
11908 (gnus-summary-select-article))
11909 (with-current-buffer gnus-article-buffer
11910 (let ((handles (or gnus-article-mime-handles
11911 (mm-dissect-buffer nil gnus-article-loose-mime)
11912 (and gnus-article-emulate-mime
11914 (gnus-summary-save-parts-counter 1))
11916 (gnus-summary-save-parts-1 type dir handles reverse)
11917 (unless gnus-article-mime-handles ;; Don't destroy this case.
11918 (mm-destroy-parts handles)))))))
11920 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11921 (if (stringp (car handle))
11922 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11925 (not (string-match type (mm-handle-media-type handle)))
11926 (string-match type (mm-handle-media-type handle)))
11927 (let ((file (expand-file-name
11929 mm-file-name-rewrite-functions
11930 (file-name-nondirectory
11932 (mail-content-type-get
11933 (mm-handle-disposition handle) 'filename)
11934 (mail-content-type-get
11935 (mm-handle-type handle) 'name)
11936 (format "%s.%d.%d" gnus-newsgroup-name
11937 (cdr gnus-article-current)
11938 gnus-summary-save-parts-counter))))
11940 (incf gnus-summary-save-parts-counter)
11941 (unless (file-exists-p file)
11942 (mm-save-part-to-file handle file))))))
11944 ;; Summary extract commands
11946 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11947 (let ((inhibit-read-only t)
11948 (article (gnus-summary-article-number))
11950 (unless (gnus-summary-goto-subject article)
11951 (error "No such article: %d" article))
11952 (gnus-summary-position-point)
11953 ;; If all commands are to be bunched up on one line, we collect
11955 (unless gnus-view-pseudos-separately
11956 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11959 (setq action (cdr (assq 'action (car ps))))
11960 (setq files (list (cdr (assq 'name (car ps)))))
11961 (while (and ps (cdr ps)
11962 (string= (or action "1")
11963 (or (cdr (assq 'action (cadr ps))) "2")))
11964 (push (cdr (assq 'name (cadr ps))) files)
11965 (setcdr ps (cddr ps)))
11967 (when (not (string-match "%s" action))
11970 (when (assq 'execute (car ps))
11971 (setcdr (assq 'execute (car ps))
11972 (funcall (if (string-match "%s" action)
11979 (shell-quote-argument f)))
11981 (setq ps (cdr ps)))))
11982 (if (and gnus-view-pseudos (not not-view))
11984 (when (assq 'execute (car pslist))
11985 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11986 (eq gnus-view-pseudos 'not-confirm)))
11987 (setq pslist (cdr pslist)))
11990 (setq after-article (or (cdr (assq 'article (car pslist)))
11991 (gnus-summary-article-number)))
11992 (gnus-summary-goto-subject after-article)
11995 (insert " " (file-name-nondirectory
11996 (cdr (assq 'name (car pslist))))
11997 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11999 (forward-line -1) ; back to `b'
12000 (gnus-add-text-properties
12001 b (1- e) (list 'gnus-number gnus-reffed-article-number
12002 gnus-mouse-face-prop gnus-mouse-face))
12004 after-article gnus-reffed-article-number
12005 gnus-unread-mark b (car pslist) 0 (- e b))
12006 (setq gnus-newsgroup-unreads
12007 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12008 gnus-reffed-article-number))
12009 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12010 (setq pslist (cdr pslist)))))))
12012 (defun gnus-pseudos< (p1 p2)
12013 (let ((c1 (cdr (assq 'action p1)))
12014 (c2 (cdr (assq 'action p2))))
12015 (and c1 c2 (string< c1 c2))))
12017 (defun gnus-request-pseudo-article (props)
12018 (cond ((assq 'execute props)
12019 (gnus-execute-command (cdr (assq 'execute props)))))
12020 (let ((gnus-current-article (gnus-summary-article-number)))
12021 (gnus-run-hooks 'gnus-mark-article-hook)))
12023 (defun gnus-execute-command (command &optional automatic)
12025 (gnus-article-setup-buffer)
12026 (set-buffer gnus-article-buffer)
12027 (setq buffer-read-only nil)
12028 (let ((command (if automatic command
12029 (read-string "Command: " (cons command 0)))))
12031 (insert "$ " command "\n\n")
12032 (if gnus-view-pseudo-asynchronously
12033 (start-process "gnus-execute" (current-buffer) shell-file-name
12034 shell-command-switch command)
12035 (call-process shell-file-name nil t nil
12036 shell-command-switch command)))))
12038 ;; Summary kill commands.
12040 (defun gnus-summary-edit-global-kill (article)
12041 "Edit the \"global\" kill file."
12042 (interactive (list (gnus-summary-article-number)))
12043 (gnus-group-edit-global-kill article))
12045 (defun gnus-summary-edit-local-kill ()
12046 "Edit a local kill file applied to the current newsgroup."
12048 (setq gnus-current-headers (gnus-summary-article-header))
12049 (gnus-group-edit-local-kill
12050 (gnus-summary-article-number) gnus-newsgroup-name))
12052 ;;; Header reading.
12054 (defun gnus-read-header (id &optional header)
12055 "Read the headers of article ID and enter them into the Gnus system."
12056 (let ((group gnus-newsgroup-name)
12057 (gnus-override-method
12059 gnus-override-method
12060 (and (gnus-news-group-p gnus-newsgroup-name)
12061 (car (gnus-refer-article-methods)))))
12063 ;; First we check to see whether the header in question is already
12066 ;; This is a Message-ID.
12067 (setq header (or header (gnus-id-to-header id)))
12068 ;; This is an article number.
12069 (setq header (or header (gnus-summary-article-header id))))
12071 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12072 ;; We have found the header.
12074 ;; We have to really fetch the header to this article.
12075 (with-current-buffer nntp-server-buffer
12076 (when (setq where (gnus-request-head id group))
12077 (nnheader-fold-continuation-lines)
12078 (goto-char (point-max))
12080 (goto-char (point-min))
12084 ((cdr where) (cdr where))
12085 (header (mail-header-number header))
12086 (t gnus-reffed-article-number))
12088 (insert " Article retrieved.\n"))
12089 (if (or (not where)
12090 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12091 () ; Malformed head.
12092 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12093 (when (and (stringp id)
12095 (not (string= (gnus-group-real-name group)
12097 (not (gnus-server-equal gnus-override-method
12098 (gnus-group-method group)))))
12099 ;; If we fetched by Message-ID and the article came from
12100 ;; a different group (or server), we fudge some bogus
12101 ;; article numbers for this article.
12102 (mail-header-set-number header gnus-reffed-article-number))
12103 (with-current-buffer gnus-summary-buffer
12104 (decf gnus-reffed-article-number)
12105 (gnus-remove-header (mail-header-number header))
12106 (push header gnus-newsgroup-headers)
12107 (setq gnus-current-headers header)
12108 (push (mail-header-number header) gnus-newsgroup-limit)))
12111 (defun gnus-remove-header (number)
12112 "Remove header NUMBER from `gnus-newsgroup-headers'."
12113 (if (and gnus-newsgroup-headers
12114 (= number (mail-header-number (car gnus-newsgroup-headers))))
12115 (pop gnus-newsgroup-headers)
12116 (let ((headers gnus-newsgroup-headers))
12117 (while (and (cdr headers)
12118 (not (= number (mail-header-number (cadr headers)))))
12120 (when (cdr headers)
12121 (setcdr headers (cddr headers))))))
12124 ;;; summary highlights
12127 (defun gnus-highlight-selected-summary ()
12128 "Highlight selected article in summary buffer."
12129 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12130 (when gnus-summary-selected-face
12132 (let* ((beg (point-at-bol))
12133 (end (point-at-eol))
12134 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12135 (from (if (get-text-property beg gnus-mouse-face-prop)
12137 (or (next-single-property-change
12138 beg gnus-mouse-face-prop nil end)
12143 (or (next-single-property-change
12144 from gnus-mouse-face-prop nil end)
12146 ;; If no mouse-face prop on line we will have to = from = end,
12147 ;; so we highlight the entire line instead.
12148 (when (= (+ to 2) from)
12151 (if gnus-newsgroup-selected-overlay
12152 ;; Move old overlay.
12154 gnus-newsgroup-selected-overlay from to (current-buffer))
12155 ;; Create new overlay.
12157 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12158 'face gnus-summary-selected-face))))))
12160 (defvar gnus-summary-highlight-line-cached nil)
12161 (defvar gnus-summary-highlight-line-trigger nil)
12163 (defun gnus-summary-highlight-line-0 ()
12164 (if (and (eq gnus-summary-highlight-line-trigger
12165 gnus-summary-highlight)
12166 gnus-summary-highlight-line-cached)
12167 gnus-summary-highlight-line-cached
12168 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12169 gnus-summary-highlight-line-cached
12170 (let* ((cond (list 'cond))
12172 (list gnus-summary-highlight))
12174 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12178 (gnus-byte-compile (list 'lambda nil cond))))))
12180 (defun gnus-summary-highlight-line ()
12181 "Highlight current line according to `gnus-summary-highlight'."
12182 (let* ((beg (point-at-bol))
12183 (article (or (gnus-summary-article-number) gnus-current-article))
12184 (score (or (cdr (assq article
12185 gnus-newsgroup-scored))
12186 gnus-summary-default-score 0))
12187 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12188 (inhibit-read-only t)
12189 (default gnus-summary-default-score)
12190 (default-high gnus-summary-default-high-score)
12191 (default-low gnus-summary-default-low-score)
12192 (uncached (and gnus-summary-use-undownloaded-faces
12193 (memq article gnus-newsgroup-undownloaded)
12194 (not (memq article gnus-newsgroup-cached)))))
12195 (let ((face (funcall (gnus-summary-highlight-line-0))))
12196 (unless (eq face (get-text-property beg 'face))
12197 (gnus-put-text-property-excluding-characters-with-faces
12198 beg (point-at-eol) 'face
12199 (setq face (if (boundp face) (symbol-value face) face)))
12200 (when gnus-summary-highlight-line-function
12201 (funcall gnus-summary-highlight-line-function article face))))))
12203 (defun gnus-update-read-articles (group unread &optional compute)
12204 "Update the list of read articles in GROUP.
12205 UNREAD is a sorted list."
12206 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12207 (info (gnus-get-info group))
12210 (if (or (not info) (not active))
12211 ;; There is no info on this group if it was, in fact,
12212 ;; killed. Gnus stores no information on killed groups, so
12213 ;; there's nothing to be done.
12214 ;; One could store the information somewhere temporarily,
12215 ;; perhaps... Hmmm...
12217 ;; Remove any negative articles numbers.
12218 (while (and unread (< (car unread) 0))
12219 (setq unread (cdr unread)))
12220 ;; Remove any expired article numbers
12221 (while (and unread (< (car unread) (car active)))
12222 (setq unread (cdr unread)))
12223 ;; Compute the ranges of read articles by looking at the list of
12224 ;; unread articles.
12226 (when (/= (car unread) prev)
12227 (push (if (= prev (1- (car unread))) prev
12228 (cons prev (1- (car unread))))
12230 (setq prev (1+ (car unread)))
12231 (setq unread (cdr unread)))
12232 (when (<= prev (cdr active))
12233 (push (cons prev (cdr active)) read))
12234 (setq read (if (> (length read) 1) (nreverse read) read))
12239 ;; Propagate the read marks to the backend.
12240 (when (and gnus-propagate-marks
12241 (gnus-check-backend-function 'request-set-mark group))
12242 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12243 (add (gnus-remove-from-range read (gnus-info-read info))))
12245 (unless (gnus-check-group group)
12246 (error "Can't open server for %s" group))
12247 (gnus-request-set-mark
12248 group (delq nil (list (if add (list add 'add '(read)))
12249 (if del (list del 'del '(read))))))
12251 `(gnus-request-set-mark
12254 (if del (list del 'add '(read)))
12255 (if add (list add 'del '(read))))))))))
12256 (set-buffer gnus-group-buffer)
12257 (gnus-undo-register
12259 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12260 (gnus-info-set-read ',info ',(gnus-info-read info))
12261 (gnus-get-unread-articles-in-group ',info
12262 (gnus-active ,group))
12263 (gnus-group-update-group ,group t)
12265 ;; Enter this list into the group info.
12266 (gnus-info-set-read info read)
12267 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12268 (gnus-get-unread-articles-in-group info (gnus-active group))
12271 (defun gnus-offer-save-summaries ()
12272 "Offer to save all active summary buffers."
12274 ;; Go through all buffers and find all summaries.
12275 (dolist (buffer (buffer-list))
12276 (when (and (setq buffer (buffer-name buffer))
12277 (string-match "Summary" buffer)
12278 (with-current-buffer buffer
12279 ;; We check that this is, indeed, a summary buffer.
12280 (and (eq major-mode 'gnus-summary-mode)
12281 ;; Also make sure this isn't bogus.
12282 gnus-newsgroup-prepared
12283 ;; Also make sure that this isn't a
12284 ;; dead summary buffer.
12285 (not gnus-dead-summary-mode))))
12286 (push buffer buffers)))
12287 ;; Go through all these summary buffers and offer to save them.
12291 "Update summary buffer %s? "
12293 (switch-to-buffer buf)
12294 (gnus-summary-exit))
12297 (defun gnus-summary-setup-default-charset ()
12298 "Setup newsgroup default charset."
12299 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12300 (setq gnus-newsgroup-charset nil)
12301 (let* ((ignored-charsets
12302 (or gnus-newsgroup-ephemeral-ignored-charsets
12304 (and gnus-newsgroup-name
12305 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12306 gnus-newsgroup-ignored-charsets))))
12307 (setq gnus-newsgroup-charset
12308 (or gnus-newsgroup-ephemeral-charset
12309 (and gnus-newsgroup-name
12310 (gnus-parameter-charset gnus-newsgroup-name))
12311 gnus-default-charset))
12312 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12313 ignored-charsets))))
12319 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12320 "Display the current article buffer fully MIME-buttonized.
12321 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12322 treated as multipart/mixed."
12324 (require 'gnus-art)
12325 (let ((gnus-unbuttonized-mime-types nil)
12326 (gnus-mime-display-multipart-as-mixed show-all-parts))
12327 (gnus-summary-show-article)))
12329 (defun gnus-summary-repair-multipart (article)
12330 "Add a Content-Type header to a multipart article without one."
12331 (interactive (list (gnus-summary-article-number)))
12332 (gnus-with-article article
12333 (message-narrow-to-head)
12334 (message-remove-header "Mime-Version")
12335 (goto-char (point-max))
12336 (insert "Mime-Version: 1.0\n")
12338 (when (search-forward "\n--" nil t)
12339 (let ((separator (buffer-substring (point) (point-at-eol))))
12340 (message-narrow-to-head)
12341 (message-remove-header "Content-Type")
12342 (goto-char (point-max))
12343 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12346 (let (gnus-mark-article-hook)
12347 (gnus-summary-select-article t t nil article)))
12349 (defun gnus-summary-toggle-display-buttonized ()
12350 "Toggle the buttonizing of the article buffer."
12352 (require 'gnus-art)
12353 (if (setq gnus-inhibit-mime-unbuttonizing
12354 (not gnus-inhibit-mime-unbuttonizing))
12355 (let ((gnus-unbuttonized-mime-types nil))
12356 (gnus-summary-show-article))
12357 (gnus-summary-show-article)))
12360 ;;; Generic summary marking commands
12363 (defvar gnus-summary-marking-alist
12364 '((read gnus-del-mark "d")
12365 (unread gnus-unread-mark "u")
12366 (ticked gnus-ticked-mark "!")
12367 (dormant gnus-dormant-mark "?")
12368 (expirable gnus-expirable-mark "e"))
12369 "An alist of names/marks/keystrokes.")
12371 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12372 (defvar gnus-summary-mark-map)
12374 (defun gnus-summary-make-all-marking-commands ()
12375 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12376 (dolist (elem gnus-summary-marking-alist)
12377 (apply 'gnus-summary-make-marking-command elem)))
12379 (defun gnus-summary-make-marking-command (name mark keystroke)
12380 (let ((map (make-sparse-keymap)))
12381 (define-key gnus-summary-generic-mark-map keystroke map)
12382 (dolist (lway `((next "next" next nil "n")
12383 (next-unread "next unread" next t "N")
12384 (prev "previous" prev nil "p")
12385 (prev-unread "previous unread" prev t "P")
12386 (nomove "" nil nil ,keystroke)))
12387 (let ((func (gnus-summary-make-marking-command-1
12388 mark (car lway) lway name)))
12389 (setq func (eval func))
12390 (define-key map (nth 4 lway) func)))))
12392 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12394 (format "gnus-summary-put-mark-as-%s%s"
12395 name (if (eq way 'nomove)
12397 (concat "-" (symbol-name way)))))
12400 "Mark the current article as %s%s.
12401 If N, the prefix, then repeat N times.
12402 If N is negative, move in reverse order.
12403 The difference between N and the actual number of articles marked is
12407 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12409 (defun gnus-summary-generic-mark (n mark move unread)
12410 "Mark N articles with MARK."
12411 (unless (eq major-mode 'gnus-summary-mode)
12412 (error "This command can only be used in the summary buffer"))
12413 (gnus-summary-show-thread)
12416 ((eq move 'next) 1)
12417 ((eq move 'prev) -1)
12419 (if (zerop nummove)
12423 nummove (* -1 nummove))))
12424 (while (and (> n 0)
12425 (gnus-summary-mark-article nil mark)
12426 (zerop (gnus-summary-next-subject nummove unread t)))
12429 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12430 (gnus-summary-recenter)
12431 (gnus-summary-position-point)
12432 (gnus-set-mode-line 'summary)
12435 (defun gnus-summary-insert-articles (articles)
12436 (when (setq articles
12437 (gnus-sorted-difference articles
12438 (mapcar (lambda (h)
12439 (mail-header-number h))
12440 gnus-newsgroup-headers)))
12441 (setq gnus-newsgroup-headers
12443 gnus-newsgroup-headers
12444 (gnus-fetch-headers articles)
12445 'gnus-article-sort-by-number))
12446 ;; Suppress duplicates?
12447 (when gnus-suppress-duplicates
12448 (gnus-dup-suppress-articles))
12450 (if (and gnus-fetch-old-headers
12451 (eq gnus-headers-retrieved-by 'nov))
12452 ;; We might want to build some more threads first.
12453 (if (eq gnus-fetch-old-headers 'invisible)
12454 (gnus-build-all-threads)
12455 (gnus-build-old-threads))
12456 ;; Mark the inserted articles that are unread as unread.
12457 (setq gnus-newsgroup-unreads
12458 (gnus-sorted-nunion
12459 gnus-newsgroup-unreads
12460 (gnus-sorted-nintersection
12461 (gnus-list-of-unread-articles gnus-newsgroup-name)
12463 ;; Mark the inserted articles as selected so that the information
12464 ;; of the marks having been changed by a user may be updated when
12465 ;; exiting this group. See `gnus-summary-update-info'.
12466 (dolist (art articles)
12467 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12468 ;; Let the Gnus agent mark articles as read.
12470 (gnus-agent-get-undownloaded-list))
12471 ;; Remove list identifiers from subject
12472 (when gnus-list-identifiers
12473 (gnus-summary-remove-list-identifiers))
12474 ;; First and last article in this newsgroup.
12475 (when gnus-newsgroup-headers
12476 (setq gnus-newsgroup-begin
12477 (mail-header-number (car gnus-newsgroup-headers))
12479 (mail-header-number
12480 (gnus-last-element gnus-newsgroup-headers))))
12481 (when gnus-use-scoring
12482 (gnus-possibly-score-headers))))
12484 (defun gnus-summary-insert-old-articles (&optional all)
12485 "Insert all old articles in this group.
12486 If ALL is non-nil, already read articles become readable.
12487 If ALL is a number, fetch this number of articles."
12490 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12493 ;; Some nntp servers lie about their active range. When
12494 ;; this happens, the active range can be in the millions.
12495 ;; Use a compressed range to avoid creating a huge list.
12496 (gnus-range-difference (list gnus-newsgroup-active) old))
12497 (setq len (gnus-range-length older))
12502 (let ((older-range (nreverse older)))
12506 (let* ((r (pop older-range))
12507 (min (if (numberp r) r (car r)))
12508 (max (if (numberp r) r (cdr r))))
12509 (while (and (<= min max)
12514 (setq older (gnus-uncompress-range older))))
12516 (setq older (gnus-uncompress-range older)))
12518 (when (and (numberp gnus-large-newsgroup)
12519 (> len gnus-large-newsgroup))
12520 (let* ((cursor-in-echo-area nil)
12521 (initial (gnus-parameter-large-newsgroup-initial
12522 gnus-newsgroup-name))
12526 "How many articles from %s (%s %d): "
12527 (gnus-group-decoded-name gnus-newsgroup-name)
12528 (if initial "max" "default")
12531 (cons (number-to-string initial)
12533 (unless (string-match "^[ \t]*$" input)
12534 (setq all (string-to-number input))
12536 (let ((older-range (nreverse older)))
12540 (let* ((r (pop older-range))
12541 (min (if (numberp r) r (car r)))
12542 (max (if (numberp r) r (cdr r))))
12543 (while (and (<= min max)
12547 max (1- max))))))))))
12548 (setq older (gnus-uncompress-range older))))
12550 (message "No old news.")
12551 (gnus-summary-insert-articles older)
12552 (gnus-summary-limit (gnus-sorted-nunion old older))))
12553 (gnus-summary-position-point)))
12555 (defun gnus-summary-insert-new-articles ()
12556 "Insert all new articles in this group."
12559 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12560 (old-active gnus-newsgroup-active)
12561 (nnmail-fetched-sources (list t))
12563 (setq gnus-newsgroup-active
12564 (gnus-activate-group gnus-newsgroup-name 'scan))
12565 (setq i (cdr gnus-newsgroup-active))
12566 (while (> i (cdr old-active))
12570 (message "No gnus is bad news")
12571 (gnus-summary-insert-articles new)
12572 (setq gnus-newsgroup-unreads
12573 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12574 (gnus-summary-limit (gnus-sorted-nunion old new))))
12575 (gnus-summary-position-point)))
12577 (gnus-summary-make-all-marking-commands)
12579 (gnus-ems-redefine)
12581 (provide 'gnus-sum)
12583 (run-hooks 'gnus-sum-load-hook)
12585 ;; Local Variables:
12586 ;; coding: iso-8859-1
12589 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
12590 ;;; gnus-sum.el ends here