1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is t, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
75 The server has to support NOV for any of this to work."
77 :type '(choice (const :tag "off" nil)
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-refer-thread-limit 200
85 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
86 If t, fetch all the available old headers."
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-summary-make-false-root 'adopt
92 "*nil means that Gnus won't gather loose threads.
93 If the root of a thread has expired or been read in a previous
94 session, the information necessary to build a complete thread has been
95 lost. Instead of having many small sub-threads from this original thread
96 scattered all over the summary buffer, Gnus can gather them.
98 If non-nil, Gnus will try to gather all loose sub-threads from an
99 original thread into one large thread.
101 If this variable is non-nil, it should be one of `none', `adopt',
104 If this variable is `none', Gnus will not make a false root, but just
105 present the sub-threads after another.
106 If this variable is `dummy', Gnus will create a dummy root that will
107 have all the sub-threads as children.
108 If this variable is `adopt', Gnus will make one of the \"children\"
109 the parent and mark all the step-children as such.
110 If this variable is `empty', the \"children\" are printed with empty
111 subject fields. (Or rather, they will be printed with a string
112 given by the `gnus-summary-same-subject' variable.)"
114 :type '(choice (const :tag "off" nil)
120 (defcustom gnus-summary-make-false-root-always nil
121 "Always make a false dummy root."
126 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
127 "*A regexp to match subjects to be excluded from loose thread gathering.
128 As loose thread gathering is done on subjects only, that means that
129 there can be many false gatherings performed. By rooting out certain
130 common subjects, gathering might become saner."
134 (defcustom gnus-summary-gather-subject-limit nil
135 "*Maximum length of subject comparisons when gathering loose threads.
136 Use nil to compare full subjects. Setting this variable to a low
137 number will help gather threads that have been corrupted by
138 newsreaders chopping off subject lines, but it might also mean that
139 unrelated articles that have subject that happen to begin with the
140 same few characters will be incorrectly gathered.
142 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
145 :type '(choice (const :tag "off" nil)
147 (sexp :menu-tag "on" t)))
149 (defcustom gnus-simplify-subject-functions nil
150 "List of functions taking a string argument that simplify subjects.
151 The functions are applied recursively.
153 Useful functions to put in this list include:
154 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
155 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
157 :type '(repeat function))
159 (defcustom gnus-simplify-ignored-prefixes nil
160 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
162 :type '(choice (const :tag "off" nil)
165 (defcustom gnus-build-sparse-threads nil
166 "*If non-nil, fill in the gaps in threads.
167 If `some', only fill in the gaps that are needed to tie loose threads
168 together. If `more', fill in all leaf nodes that Gnus can find. If
169 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
171 :type '(choice (const :tag "off" nil)
174 (sexp :menu-tag "all" t)))
176 (defcustom gnus-summary-thread-gathering-function
177 'gnus-gather-threads-by-subject
178 "*Function used for gathering loose threads.
179 There are two pre-defined functions: `gnus-gather-threads-by-subject',
180 which only takes Subjects into consideration; and
181 `gnus-gather-threads-by-references', which compared the References
182 headers of the articles to find matches."
184 :type '(radio (function-item gnus-gather-threads-by-subject)
185 (function-item gnus-gather-threads-by-references)
186 (function :tag "other")))
188 (defcustom gnus-summary-same-subject ""
189 "*String indicating that the current article has the same subject as the previous.
190 This variable will only be used if the value of
191 `gnus-summary-make-false-root' is `empty'."
192 :group 'gnus-summary-format
195 (defcustom gnus-summary-goto-unread t
196 "*If t, many commands will go to the next unread article.
197 This applies to marking commands as well as other commands that
198 \"naturally\" select the next article, like, for instance, `SPC' at
199 the end of an article.
201 If nil, the marking commands do NOT go to the next unread article
202 \(they go to the next article instead). If `never', commands that
203 usually go to the next unread article, will go to the next article,
204 whether it is read or not."
205 :group 'gnus-summary-marks
206 :link '(custom-manual "(gnus)Setting Marks")
207 :type '(choice (const :tag "off" nil)
209 (sexp :menu-tag "on" t)))
211 (defcustom gnus-summary-default-score 0
212 "*Default article score level.
213 All scores generated by the score files will be added to this score.
214 If this variable is nil, scoring will be disabled."
215 :group 'gnus-score-default
216 :type '(choice (const :tag "disable")
219 (defcustom gnus-summary-default-high-score 0
220 "*Default threshold for a high scored article.
221 An article will be highlighted as high scored if its score is greater
224 :group 'gnus-score-default
227 (defcustom gnus-summary-default-low-score 0
228 "*Default threshold for a low scored article.
229 An article will be highlighted as low scored if its score is smaller
232 :group 'gnus-score-default
235 (defcustom gnus-summary-zcore-fuzz 0
236 "*Fuzziness factor for the zcore in the summary buffer.
237 Articles with scores closer than this to `gnus-summary-default-score'
239 :group 'gnus-summary-format
242 (defcustom gnus-simplify-subject-fuzzy-regexp nil
243 "*Strings to be removed when doing fuzzy matches.
244 This can either be a regular expression or list of regular expressions
245 that will be removed from subject strings if fuzzy subject
246 simplification is selected."
248 :type '(repeat regexp))
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
255 (defcustom gnus-thread-hide-subtree nil
256 "*If non-nil, hide all threads initially.
257 This can be a predicate specifier which says which threads to hide.
258 If threads are hidden, you have to run the command
259 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
260 to expose hidden threads."
262 :type '(radio (sexp :format "Non-nil\n"
263 :match (lambda (widget value)
264 (not (or (consp value) (functionp value))))
267 (sexp :tag "Predicate specifier")))
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
291 :type '(choice (const :tag "off" nil)
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), 'unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
328 :group 'gnus-group-select
329 :type '(choice (const best)
333 (const unseen-or-unread)))
335 (defcustom gnus-auto-select-next t
336 "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode. If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup. In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346 :group 'gnus-summary-maneuvering
347 :type '(choice (const :tag "off" nil)
349 (const almost-quietly)
350 (const slightly-quietly)
351 (sexp :menu-tag "on" t)))
353 (defcustom gnus-auto-select-same nil
354 "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357 :group 'gnus-summary-maneuvering
360 (defcustom gnus-auto-goto-ignores 'unfetched
361 "*Says how to handle unfetched articles when maneuvering.
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "None" nil)
374 (const :tag "Undownloaded when unplugged" undownloaded)
375 (const :tag "Undownloaded" always-undownloaded)
376 (const :tag "Unfetched" unfetched)))
378 (defcustom gnus-summary-check-current nil
379 "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382 :group 'gnus-summary-maneuvering
385 (defcustom gnus-auto-center-summary 2
386 "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering. If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "none" nil)
392 (integer :tag "height")
393 (sexp :menu-tag "both" t)))
395 (defvar gnus-auto-center-group t
396 "*If non-nil, always center the group buffer.")
398 (defcustom gnus-show-all-headers nil
399 "*If non-nil, don't hide any headers."
400 :group 'gnus-article-hiding
401 :group 'gnus-article-headers
404 (defcustom gnus-summary-ignore-duplicates nil
405 "*If non-nil, ignore articles with identical Message-ID headers."
409 (defcustom gnus-single-article-buffer t
410 "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412 :group 'gnus-article-various
415 (defcustom gnus-break-pages t
416 "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
419 :group 'gnus-article-various
422 (defcustom gnus-move-split-methods nil
423 "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427 :group 'gnus-summary-mail
428 :type '(repeat (choice (list :value (fun) function)
429 (cons :value ("" "") regexp (repeat string))
432 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
433 "Function used to compute default prefix for article move/copy/etc prompts.
434 The function should take one argument, a group name, and return a
435 string with the suggested prefix."
436 :group 'gnus-summary-mail
439 ;; FIXME: Although the custom type is `character' for the following variables,
440 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
442 (defcustom gnus-unread-mark ? ;Whitespace
443 "*Mark used for unread articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-ticked-mark ?!
448 "*Mark used for ticked articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-dormant-mark ??
453 "*Mark used for dormant articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-del-mark ?r
458 "*Mark used for del'd articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-read-mark ?R
463 "*Mark used for read articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-expirable-mark ?E
468 "*Mark used for expirable articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-killed-mark ?K
473 "*Mark used for killed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-spam-mark ?$
478 "*Mark used for spam articles."
480 :group 'gnus-summary-marks
483 (defcustom gnus-souped-mark ?F
484 "*Mark used for souped articles."
485 :group 'gnus-summary-marks
488 (defcustom gnus-kill-file-mark ?X
489 "*Mark used for articles killed by kill files."
490 :group 'gnus-summary-marks
493 (defcustom gnus-low-score-mark ?Y
494 "*Mark used for articles with a low score."
495 :group 'gnus-summary-marks
498 (defcustom gnus-catchup-mark ?C
499 "*Mark used for articles that are caught up."
500 :group 'gnus-summary-marks
503 (defcustom gnus-replied-mark ?A
504 "*Mark used for articles that have been replied to."
505 :group 'gnus-summary-marks
508 (defcustom gnus-forwarded-mark ?F
509 "*Mark used for articles that have been forwarded."
511 :group 'gnus-summary-marks
514 (defcustom gnus-recent-mark ?N
515 "*Mark used for articles that are recent."
517 :group 'gnus-summary-marks
520 (defcustom gnus-cached-mark ?*
521 "*Mark used for articles that are in the cache."
522 :group 'gnus-summary-marks
525 (defcustom gnus-saved-mark ?S
526 "*Mark used for articles that have been saved."
527 :group 'gnus-summary-marks
530 (defcustom gnus-unseen-mark ?.
531 "*Mark used for articles that haven't been seen."
533 :group 'gnus-summary-marks
536 (defcustom gnus-no-mark ? ;Whitespace
537 "*Mark used for articles that have no other secondary mark."
539 :group 'gnus-summary-marks
542 (defcustom gnus-ancient-mark ?O
543 "*Mark used for ancient articles."
544 :group 'gnus-summary-marks
547 (defcustom gnus-sparse-mark ?Q
548 "*Mark used for sparsely reffed articles."
549 :group 'gnus-summary-marks
552 (defcustom gnus-canceled-mark ?G
553 "*Mark used for canceled articles."
554 :group 'gnus-summary-marks
557 (defcustom gnus-duplicate-mark ?M
558 "*Mark used for duplicate articles."
559 :group 'gnus-summary-marks
562 (defcustom gnus-undownloaded-mark ?-
563 "*Mark used for articles that weren't downloaded."
565 :group 'gnus-summary-marks
568 (defcustom gnus-downloaded-mark ?+
569 "*Mark used for articles that were downloaded."
570 :group 'gnus-summary-marks
573 (defcustom gnus-downloadable-mark ?%
574 "*Mark used for articles that are to be downloaded."
575 :group 'gnus-summary-marks
578 (defcustom gnus-unsendable-mark ?=
579 "*Mark used for articles that won't be sent."
580 :group 'gnus-summary-marks
583 (defcustom gnus-score-over-mark ?+
584 "*Score mark used for articles with high scores."
585 :group 'gnus-summary-marks
588 (defcustom gnus-score-below-mark ?-
589 "*Score mark used for articles with low scores."
590 :group 'gnus-summary-marks
593 (defcustom gnus-empty-thread-mark ? ;Whitespace
594 "*There is no thread under the article."
595 :group 'gnus-summary-marks
598 (defcustom gnus-not-empty-thread-mark ?=
599 "*There is a thread under the article."
600 :group 'gnus-summary-marks
603 (defcustom gnus-view-pseudo-asynchronously nil
604 "*If non-nil, Gnus will view pseudo-articles asynchronously."
605 :group 'gnus-extract-view
608 (defcustom gnus-auto-expirable-marks
609 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
610 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
611 gnus-souped-mark gnus-duplicate-mark)
612 "*The list of marks converted into expiration if a group is auto-expirable."
615 :type '(repeat character))
617 (defcustom gnus-inhibit-user-auto-expire t
618 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
623 (defcustom gnus-view-pseudos nil
624 "*If `automatic', pseudo-articles will be viewed automatically.
625 If `not-confirm', pseudos will be viewed automatically, and the user
626 will not be asked to confirm the command."
627 :group 'gnus-extract-view
628 :type '(choice (const :tag "off" nil)
630 (const not-confirm)))
632 (defcustom gnus-view-pseudos-separately t
633 "*If non-nil, one pseudo-article will be created for each file to be viewed.
634 If nil, all files that use the same viewing command will be given as a
635 list of parameters to that command."
636 :group 'gnus-extract-view
639 (defcustom gnus-insert-pseudo-articles t
640 "*If non-nil, insert pseudo-articles when decoding articles."
641 :group 'gnus-extract-view
644 (defcustom gnus-summary-dummy-line-format
646 "*The format specification for the dummy roots in the summary buffer.
647 It works along the same lines as a normal formatting string,
648 with some simple extensions.
652 General format specifiers can also be used.
653 See `(gnus)Formatting Variables'."
654 :link '(custom-manual "(gnus)Formatting Variables")
655 :group 'gnus-threading
658 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
659 "*The format specification for the summary mode line.
660 It works along the same lines as a normal formatting string,
661 with some simple extensions:
664 %p Unprefixed group name
665 %A Current article number
666 %z Current article score
668 %U Number of unread articles in the group
669 %e Number of unselected articles in the group
670 %Z A string with unread/unselected article counts
671 %g Shortish group name
672 %S Subject of the current article
674 %s Current score file name
675 %d Number of dormant articles
676 %r Number of articles that have been marked as read in this session
677 %E Number of articles expunged by the score files"
678 :group 'gnus-summary-format
681 (defcustom gnus-list-identifiers nil
682 "Regexp that matches list identifiers to be removed from subject.
683 This can also be a list of regexps."
685 :group 'gnus-summary-format
686 :group 'gnus-article-hiding
687 :type '(choice (const :tag "none" nil)
689 (repeat :value (".*") regexp)))
691 (defcustom gnus-summary-mark-below 0
692 "*Mark all articles with a score below this variable as read.
693 This variable is local to each summary buffer and usually set by the
695 :group 'gnus-score-default
698 (defun gnus-widget-reversible-match (widget value)
699 "Ignoring WIDGET, convert VALUE to internal form.
700 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
704 (eq (length value) 2)
705 (eq (nth 0 value) 'not)
706 (symbolp (nth 1 value)))))
708 (defun gnus-widget-reversible-to-internal (widget value)
709 "Ignoring WIDGET, convert VALUE to internal form.
710 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
711 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
715 (list (nth 1 value) t)))
717 (defun gnus-widget-reversible-to-external (widget value)
718 "Ignoring WIDGET, convert VALUE to external form.
719 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
720 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
723 (list 'not (nth 0 value))
726 (define-widget 'gnus-widget-reversible 'group
727 "A `group' that convert values."
728 :match 'gnus-widget-reversible-match
729 :value-to-internal 'gnus-widget-reversible-to-internal
730 :value-to-external 'gnus-widget-reversible-to-external)
732 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
733 "*List of functions used for sorting articles in the summary buffer.
735 Each function takes two articles and returns non-nil if the first
736 article should be sorted before the other. If you use more than one
737 function, the primary sort function should be the last. You should
738 probably always include `gnus-article-sort-by-number' in the list of
739 sorting functions -- preferably first. Also note that sorting by date
740 is often much slower than sorting by number, and the sorting order is
741 very similar. (Sorting by date means sorting by the time the message
742 was sent, sorting by number means sorting by arrival time.)
744 Each item can also be a list `(not F)' where F is a function;
745 this reverses the sort order.
747 Ready-made functions include `gnus-article-sort-by-number',
748 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
749 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
750 and `gnus-article-sort-by-score'.
752 When threading is turned on, the variable `gnus-thread-sort-functions'
753 controls how articles are sorted."
754 :group 'gnus-summary-sort
755 :type '(repeat (gnus-widget-reversible
756 (choice (function-item gnus-article-sort-by-number)
757 (function-item gnus-article-sort-by-author)
758 (function-item gnus-article-sort-by-subject)
759 (function-item gnus-article-sort-by-date)
760 (function-item gnus-article-sort-by-score)
761 (function-item gnus-article-sort-by-random)
762 (function :tag "other"))
763 (boolean :tag "Reverse order"))))
766 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
767 "*List of functions used for sorting threads in the summary buffer.
768 By default, threads are sorted by article number.
770 Each function takes two threads and returns non-nil if the first
771 thread should be sorted before the other. If you use more than one
772 function, the primary sort function should be the last. You should
773 probably always include `gnus-thread-sort-by-number' in the list of
774 sorting functions -- preferably first. Also note that sorting by date
775 is often much slower than sorting by number, and the sorting order is
776 very similar. (Sorting by date means sorting by the time the message
777 was sent, sorting by number means sorting by arrival time.)
779 Each list item can also be a list `(not F)' where F is a
780 function; this specifies reversed sort order.
782 Ready-made functions include `gnus-thread-sort-by-number',
783 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
784 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
785 `gnus-thread-sort-by-most-recent-number',
786 `gnus-thread-sort-by-most-recent-date',
787 `gnus-thread-sort-by-random', and
788 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
790 When threading is turned off, the variable
791 `gnus-article-sort-functions' controls how articles are sorted."
792 :group 'gnus-summary-sort
794 (gnus-widget-reversible
795 (choice (function-item gnus-thread-sort-by-number)
796 (function-item gnus-thread-sort-by-author)
797 (function-item gnus-thread-sort-by-subject)
798 (function-item gnus-thread-sort-by-date)
799 (function-item gnus-thread-sort-by-score)
800 (function-item gnus-thread-sort-by-most-recent-number)
801 (function-item gnus-thread-sort-by-most-recent-date)
802 (function-item gnus-thread-sort-by-random)
803 (function-item gnus-thread-sort-by-total-score)
804 (function :tag "other"))
805 (boolean :tag "Reverse order"))))
807 (defcustom gnus-thread-score-function '+
808 "*Function used for calculating the total score of a thread.
810 The function is called with the scores of the article and each
811 subthread and should then return the score of the thread.
813 Some functions you can use are `+', `max', or `min'."
814 :group 'gnus-summary-sort
817 (defcustom gnus-summary-expunge-below nil
818 "All articles that have a score less than this variable will be expunged.
819 This variable is local to the summary buffers."
820 :group 'gnus-score-default
821 :type '(choice (const :tag "off" nil)
824 (defcustom gnus-thread-expunge-below nil
825 "All threads that have a total score less than this variable will be expunged.
826 See `gnus-thread-score-function' for en explanation of what a
829 This variable is local to the summary buffers."
830 :group 'gnus-threading
831 :group 'gnus-score-default
832 :type '(choice (const :tag "off" nil)
835 (defcustom gnus-summary-mode-hook nil
836 "*A hook for Gnus summary mode.
837 This hook is run before any variables are set in the summary buffer."
838 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
839 :group 'gnus-summary-various
842 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
843 (when (featurep 'xemacs)
844 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
845 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
846 (add-hook 'gnus-summary-mode-hook
847 'gnus-xmas-switch-horizontal-scrollbar-off))
849 (defcustom gnus-summary-menu-hook nil
850 "*Hook run after the creation of the summary mode menu."
851 :group 'gnus-summary-visual
854 (defcustom gnus-summary-exit-hook nil
855 "*A hook called on exit from the summary buffer.
856 It will be called with point in the group buffer."
857 :group 'gnus-summary-exit
860 (defcustom gnus-summary-prepare-hook nil
861 "*A hook called after the summary buffer has been generated.
862 If you want to modify the summary buffer, you can use this hook."
863 :group 'gnus-summary-various
866 (defcustom gnus-summary-prepared-hook nil
867 "*A hook called as the last thing after the summary buffer has been generated."
868 :group 'gnus-summary-various
871 (defcustom gnus-summary-generate-hook nil
872 "*A hook run just before generating the summary buffer.
873 This hook is commonly used to customize threading variables and the
875 :group 'gnus-summary-various
878 (defcustom gnus-select-group-hook nil
879 "*A hook called when a newsgroup is selected.
881 If you'd like to simplify subjects like the
882 `gnus-summary-next-same-subject' command does, you can use the
885 (add-hook gnus-select-group-hook
887 (mapcar (lambda (header)
888 (mail-header-set-subject
890 (gnus-simplify-subject
891 (mail-header-subject header) 're-only)))
892 gnus-newsgroup-headers)))"
893 :group 'gnus-group-select
896 (defcustom gnus-select-article-hook nil
897 "*A hook called when an article is selected."
898 :group 'gnus-summary-choose
899 :options '(gnus-agent-fetch-selected-article)
902 (defcustom gnus-visual-mark-article-hook
903 (list 'gnus-highlight-selected-summary)
904 "*Hook run after selecting an article in the summary buffer.
905 It is meant to be used for highlighting the article in some way. It
906 is not run if `gnus-visual' is nil."
907 :group 'gnus-summary-visual
910 (defcustom gnus-parse-headers-hook nil
911 "*A hook called before parsing the headers."
915 (defcustom gnus-exit-group-hook nil
916 "*A hook called when exiting summary mode.
917 This hook is not called from the non-updating exit commands like `Q'."
921 (defcustom gnus-summary-update-hook
922 (list 'gnus-summary-highlight-line)
923 "*A hook called when a summary line is changed.
924 The hook will not be called if `gnus-visual' is nil.
926 The default function `gnus-summary-highlight-line' will
927 highlight the line according to the `gnus-summary-highlight'
929 :group 'gnus-summary-visual
932 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
933 "*A hook called when an article is selected for the first time.
934 The hook is intended to mark an article as read (or unread)
935 automatically when it is selected."
936 :group 'gnus-summary-choose
939 (defcustom gnus-group-no-more-groups-hook nil
940 "*A hook run when returning to group mode having no more (unread) groups."
941 :group 'gnus-group-select
944 (defcustom gnus-ps-print-hook nil
945 "*A hook run before ps-printing something from Gnus."
949 (defcustom gnus-summary-article-move-hook nil
950 "*A hook called after an article is moved, copied, respooled, or crossposted."
955 (defcustom gnus-summary-article-delete-hook nil
956 "*A hook called after an article is deleted."
961 (defcustom gnus-summary-article-expire-hook nil
962 "*A hook called after an article is expired."
967 (defcustom gnus-summary-display-arrow
968 (and (fboundp 'display-graphic-p)
970 "*If non-nil, display an arrow highlighting the current article."
975 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
976 "Face used for highlighting the current article in the summary buffer."
977 :group 'gnus-summary-visual
980 (defvar gnus-tmp-downloaded nil)
982 (defcustom gnus-summary-highlight
983 '(((eq mark gnus-canceled-mark)
984 . gnus-summary-cancelled-face)
985 ((and uncached (> score default-high))
986 . gnus-summary-high-undownloaded-face)
987 ((and uncached (< score default-low))
988 . gnus-summary-low-undownloaded-face)
990 . gnus-summary-normal-undownloaded-face)
991 ((and (> score default-high)
992 (or (eq mark gnus-dormant-mark)
993 (eq mark gnus-ticked-mark)))
994 . gnus-summary-high-ticked-face)
995 ((and (< score default-low)
996 (or (eq mark gnus-dormant-mark)
997 (eq mark gnus-ticked-mark)))
998 . gnus-summary-low-ticked-face)
999 ((or (eq mark gnus-dormant-mark)
1000 (eq mark gnus-ticked-mark))
1001 . gnus-summary-normal-ticked-face)
1002 ((and (> score default-high) (eq mark gnus-ancient-mark))
1003 . gnus-summary-high-ancient-face)
1004 ((and (< score default-low) (eq mark gnus-ancient-mark))
1005 . gnus-summary-low-ancient-face)
1006 ((eq mark gnus-ancient-mark)
1007 . gnus-summary-normal-ancient-face)
1008 ((and (> score default-high) (eq mark gnus-unread-mark))
1009 . gnus-summary-high-unread-face)
1010 ((and (< score default-low) (eq mark gnus-unread-mark))
1011 . gnus-summary-low-unread-face)
1012 ((eq mark gnus-unread-mark)
1013 . gnus-summary-normal-unread-face)
1014 ((> score default-high)
1015 . gnus-summary-high-read-face)
1016 ((< score default-low)
1017 . gnus-summary-low-read-face)
1019 . gnus-summary-normal-read-face))
1020 "*Controls the highlighting of summary buffer lines.
1022 A list of (FORM . FACE) pairs. When deciding how a a particular
1023 summary line should be displayed, each form is evaluated. The content
1024 of the face field after the first true form is used. You can change
1025 how those summary lines are displayed, by editing the face field.
1027 You can use the following variables in the FORM field.
1029 score: The article's score
1030 default: The default article score.
1031 default-high: The default score for high scored articles.
1032 default-low: The default score for low scored articles.
1033 below: The score below which articles are automatically marked as read.
1034 mark: The article's mark.
1035 uncached: Non-nil if the article is uncached."
1036 :group 'gnus-summary-visual
1037 :type '(repeat (cons (sexp :tag "Form" nil)
1040 (defcustom gnus-alter-header-function nil
1041 "Function called to allow alteration of article header structures.
1042 The function is called with one parameter, the article header vector,
1043 which it may alter in any way."
1044 :type '(choice (const :tag "None" nil)
1046 :group 'gnus-summary)
1048 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1049 "Variable that says which function should be used to decode a string with encoded words.")
1051 (defcustom gnus-extra-headers '(To Newsgroups)
1052 "*Extra headers to parse."
1054 :group 'gnus-summary
1055 :type '(repeat symbol))
1057 (defcustom gnus-ignored-from-addresses
1058 (and user-mail-address (regexp-quote user-mail-address))
1059 "*Regexp of From headers that may be suppressed in favor of To headers."
1061 :group 'gnus-summary
1064 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1065 "List of charsets that should be ignored.
1066 When these charsets are used in the \"charset\" parameter, the
1067 default charset will be used instead."
1069 :type '(repeat symbol)
1070 :group 'gnus-charset)
1072 (gnus-define-group-parameter
1076 "Return the ignored charsets of GROUP."
1077 :variable gnus-group-ignored-charsets-alist
1079 '(("alt\\.chinese\\.text" iso-8859-1))
1081 "Alist of regexps (to match group names) and charsets that should be ignored.
1082 When these charsets are used in the \"charset\" parameter, the
1083 default charset will be used instead."
1084 :variable-group gnus-charset
1085 :variable-type '(repeat (cons (regexp :tag "Group")
1087 :parameter-type '(choice :tag "Ignored charsets"
1090 :parameter-document "\
1091 List of charsets that should be ignored.
1093 When these charsets are used in the \"charset\" parameter, the
1094 default charset will be used instead.")
1096 (defcustom gnus-group-highlight-words-alist nil
1097 "Alist of group regexps and highlight regexps.
1098 This variable uses the same syntax as `gnus-emphasis-alist'."
1100 :type '(repeat (cons (regexp :tag "Group")
1101 (repeat (list (regexp :tag "Highlight regexp")
1102 (number :tag "Group for entire word" 0)
1103 (number :tag "Group for displayed part" 0)
1105 gnus-emphasis-highlight-words)))))
1106 :group 'gnus-summary-visual)
1108 (defcustom gnus-summary-show-article-charset-alist
1110 "Alist of number and charset.
1111 The article will be shown with the charset corresponding to the
1113 For example: ((1 . cn-gb-2312) (2 . big5))."
1115 :type '(repeat (cons (number :tag "Argument" 1)
1116 (symbol :tag "Charset")))
1117 :group 'gnus-charset)
1119 (defcustom gnus-preserve-marks t
1120 "Whether marks are preserved when moving, copying and respooling messages."
1123 :group 'gnus-summary-marks)
1125 (defcustom gnus-alter-articles-to-read-function nil
1126 "Function to be called to alter the list of articles to be selected."
1127 :type '(choice (const nil) function)
1128 :group 'gnus-summary)
1130 (defcustom gnus-orphan-score nil
1131 "*All orphans get this score added. Set in the score file."
1132 :group 'gnus-score-default
1133 :type '(choice (const nil)
1136 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1137 "*A regexp to match MIME parts when saving multiple parts of a
1138 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1139 This regexp will be used by default when prompting the user for which
1140 type of files to save."
1141 :group 'gnus-summary
1144 (defcustom gnus-read-all-available-headers nil
1145 "Whether Gnus should parse all headers made available to it.
1146 This is mostly relevant for slow back ends where the user may
1147 wish to widen the summary buffer to include all headers
1148 that were fetched. Say, for nnultimate groups."
1150 :group 'gnus-summary
1151 :type '(choice boolean regexp))
1153 (defcustom gnus-summary-muttprint-program "muttprint"
1154 "Command (and optional arguments) used to run Muttprint."
1156 :group 'gnus-summary
1159 (defcustom gnus-article-loose-mime t
1160 "If non-nil, don't require MIME-Version header.
1161 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1162 supply the MIME-Version header or deliberately strip it from the mail.
1163 If non-nil (the default), Gnus will treat some articles as MIME
1164 even if the MIME-Version header is missing."
1167 :group 'gnus-article-mime)
1169 (defcustom gnus-article-emulate-mime t
1170 "If non-nil, use MIME emulation for uuencode and the like.
1171 This means that Gnus will search message bodies for text that look
1172 like uuencoded bits, yEncoded bits, and so on, and present that using
1173 the normal Gnus MIME machinery."
1176 :group 'gnus-article-mime)
1178 ;;; Internal variables
1180 (defvar gnus-summary-display-cache nil)
1181 (defvar gnus-article-mime-handles nil)
1182 (defvar gnus-article-decoded-p nil)
1183 (defvar gnus-article-charset nil)
1184 (defvar gnus-article-ignored-charsets nil)
1185 (defvar gnus-scores-exclude-files nil)
1186 (defvar gnus-page-broken nil)
1188 (defvar gnus-original-article nil)
1189 (defvar gnus-article-internal-prepare-hook nil)
1190 (defvar gnus-newsgroup-process-stack nil)
1192 (defvar gnus-thread-indent-array nil)
1193 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1194 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1195 "Function called to sort the articles within a thread after it has been gathered together.")
1197 (defvar gnus-summary-save-parts-type-history nil)
1198 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1200 ;; Avoid highlighting in kill files.
1201 (defvar gnus-summary-inhibit-highlight nil)
1202 (defvar gnus-newsgroup-selected-overlay nil)
1203 (defvar gnus-inhibit-limiting nil)
1204 (defvar gnus-newsgroup-adaptive-score-file nil)
1205 (defvar gnus-current-score-file nil)
1206 (defvar gnus-current-move-group nil)
1207 (defvar gnus-current-copy-group nil)
1208 (defvar gnus-current-crosspost-group nil)
1209 (defvar gnus-newsgroup-display nil)
1211 (defvar gnus-newsgroup-dependencies nil)
1212 (defvar gnus-newsgroup-adaptive nil)
1213 (defvar gnus-summary-display-article-function nil)
1214 (defvar gnus-summary-highlight-line-function nil
1215 "Function called after highlighting a summary line.")
1217 (defvar gnus-summary-line-format-alist
1218 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1219 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1220 (?s gnus-tmp-subject-or-nil ?s)
1221 (?n gnus-tmp-name ?s)
1222 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1224 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1226 (?F gnus-tmp-from ?s)
1227 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1228 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1229 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1230 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1231 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1232 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1233 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1234 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1235 (?L gnus-tmp-lines ?s)
1236 (?O gnus-tmp-downloaded ?c)
1237 (?I gnus-tmp-indentation ?s)
1238 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1239 (?R gnus-tmp-replied ?c)
1240 (?\[ gnus-tmp-opening-bracket ?c)
1241 (?\] gnus-tmp-closing-bracket ?c)
1242 (?\> (make-string gnus-tmp-level ? ) ?s)
1243 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1244 (?i gnus-tmp-score ?d)
1245 (?z gnus-tmp-score-char ?c)
1246 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1247 (?U gnus-tmp-unread ?c)
1248 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1250 (?t (gnus-summary-number-of-articles-in-thread
1251 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1253 (?e (gnus-summary-number-of-articles-in-thread
1254 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1256 (?u gnus-tmp-user-defined ?s)
1257 (?P (gnus-pick-line-number) ?d)
1258 (?B gnus-tmp-thread-tree-header-string ?s)
1259 (user-date (gnus-user-date
1260 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1261 "An alist of format specifications that can appear in summary lines.
1262 These are paired with what variables they correspond with, along with
1263 the type of the variable (string, integer, character, etc).")
1265 (defvar gnus-summary-dummy-line-format-alist
1266 `((?S gnus-tmp-subject ?s)
1267 (?N gnus-tmp-number ?d)
1268 (?u gnus-tmp-user-defined ?s)))
1270 (defvar gnus-summary-mode-line-format-alist
1271 `((?G gnus-tmp-group-name ?s)
1272 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1273 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1274 (?A gnus-tmp-article-number ?d)
1275 (?Z gnus-tmp-unread-and-unselected ?s)
1276 (?V gnus-version ?s)
1277 (?U gnus-tmp-unread-and-unticked ?d)
1278 (?S gnus-tmp-subject ?s)
1279 (?e gnus-tmp-unselected ?d)
1280 (?u gnus-tmp-user-defined ?s)
1281 (?d (length gnus-newsgroup-dormant) ?d)
1282 (?t (length gnus-newsgroup-marked) ?d)
1283 (?h (length gnus-newsgroup-spam-marked) ?d)
1284 (?r (length gnus-newsgroup-reads) ?d)
1285 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1286 (?E gnus-newsgroup-expunged-tally ?d)
1287 (?s (gnus-current-score-file-nondirectory) ?s)))
1289 (defvar gnus-last-search-regexp nil
1290 "Default regexp for article search command.")
1292 (defvar gnus-last-shell-command nil
1293 "Default shell command on article.")
1295 (defvar gnus-newsgroup-agentized nil
1296 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1297 (defvar gnus-newsgroup-begin nil)
1298 (defvar gnus-newsgroup-end nil)
1299 (defvar gnus-newsgroup-last-rmail nil)
1300 (defvar gnus-newsgroup-last-mail nil)
1301 (defvar gnus-newsgroup-last-folder nil)
1302 (defvar gnus-newsgroup-last-file nil)
1303 (defvar gnus-newsgroup-auto-expire nil)
1304 (defvar gnus-newsgroup-active nil)
1306 (defvar gnus-newsgroup-data nil)
1307 (defvar gnus-newsgroup-data-reverse nil)
1308 (defvar gnus-newsgroup-limit nil)
1309 (defvar gnus-newsgroup-limits nil)
1310 (defvar gnus-summary-use-undownloaded-faces nil)
1312 (defvar gnus-newsgroup-unreads nil
1313 "Sorted list of unread articles in the current newsgroup.")
1315 (defvar gnus-newsgroup-unselected nil
1316 "Sorted list of unselected unread articles in the current newsgroup.")
1318 (defvar gnus-newsgroup-reads nil
1319 "Alist of read articles and article marks in the current newsgroup.")
1321 (defvar gnus-newsgroup-expunged-tally nil)
1323 (defvar gnus-newsgroup-marked nil
1324 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1326 (defvar gnus-newsgroup-spam-marked nil
1327 "List of ranges of articles that have been marked as spam.")
1329 (defvar gnus-newsgroup-killed nil
1330 "List of ranges of articles that have been through the scoring process.")
1332 (defvar gnus-newsgroup-cached nil
1333 "Sorted list of articles that come from the article cache.")
1335 (defvar gnus-newsgroup-saved nil
1336 "List of articles that have been saved.")
1338 (defvar gnus-newsgroup-kill-headers nil)
1340 (defvar gnus-newsgroup-replied nil
1341 "List of articles that have been replied to in the current newsgroup.")
1343 (defvar gnus-newsgroup-forwarded nil
1344 "List of articles that have been forwarded in the current newsgroup.")
1346 (defvar gnus-newsgroup-recent nil
1347 "List of articles that have are recent in the current newsgroup.")
1349 (defvar gnus-newsgroup-expirable nil
1350 "Sorted list of articles in the current newsgroup that can be expired.")
1352 (defvar gnus-newsgroup-processable nil
1353 "List of articles in the current newsgroup that can be processed.")
1355 (defvar gnus-newsgroup-downloadable nil
1356 "Sorted list of articles in the current newsgroup that can be processed.")
1358 (defvar gnus-newsgroup-unfetched nil
1359 "Sorted list of articles in the current newsgroup whose headers have
1360 not been fetched into the agent.
1362 This list will always be a subset of gnus-newsgroup-undownloaded.")
1364 (defvar gnus-newsgroup-undownloaded nil
1365 "List of articles in the current newsgroup that haven't been downloaded.")
1367 (defvar gnus-newsgroup-unsendable nil
1368 "List of articles in the current newsgroup that won't be sent.")
1370 (defvar gnus-newsgroup-bookmarks nil
1371 "List of articles in the current newsgroup that have bookmarks.")
1373 (defvar gnus-newsgroup-dormant nil
1374 "Sorted list of dormant articles in the current newsgroup.")
1376 (defvar gnus-newsgroup-unseen nil
1377 "List of unseen articles in the current newsgroup.")
1379 (defvar gnus-newsgroup-seen nil
1380 "Range of seen articles in the current newsgroup.")
1382 (defvar gnus-newsgroup-articles nil
1383 "List of articles in the current newsgroup.")
1385 (defvar gnus-newsgroup-scored nil
1386 "List of scored articles in the current newsgroup.")
1388 (defvar gnus-newsgroup-headers nil
1389 "List of article headers in the current newsgroup.")
1391 (defvar gnus-newsgroup-threads nil)
1393 (defvar gnus-newsgroup-prepared nil
1394 "Whether the current group has been prepared properly.")
1396 (defvar gnus-newsgroup-ancient nil
1397 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1399 (defvar gnus-newsgroup-sparse nil)
1401 (defvar gnus-current-article nil)
1402 (defvar gnus-article-current nil)
1403 (defvar gnus-current-headers nil)
1404 (defvar gnus-have-all-headers nil)
1405 (defvar gnus-last-article nil)
1406 (defvar gnus-newsgroup-history nil)
1407 (defvar gnus-newsgroup-charset nil)
1408 (defvar gnus-newsgroup-ephemeral-charset nil)
1409 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1411 (defvar gnus-article-before-search nil)
1413 (defvar gnus-summary-local-variables
1414 '(gnus-newsgroup-name
1415 gnus-newsgroup-begin gnus-newsgroup-end
1416 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1417 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1418 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1419 gnus-newsgroup-unselected gnus-newsgroup-marked
1420 gnus-newsgroup-spam-marked
1421 gnus-newsgroup-reads gnus-newsgroup-saved
1422 gnus-newsgroup-replied gnus-newsgroup-forwarded
1423 gnus-newsgroup-recent
1424 gnus-newsgroup-expirable
1425 gnus-newsgroup-processable gnus-newsgroup-killed
1426 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1427 gnus-newsgroup-unfetched
1428 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1429 gnus-newsgroup-seen gnus-newsgroup-articles
1430 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1431 gnus-newsgroup-headers gnus-newsgroup-threads
1432 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1433 gnus-current-article gnus-current-headers gnus-have-all-headers
1434 gnus-last-article gnus-article-internal-prepare-hook
1435 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1436 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1437 gnus-thread-expunge-below
1438 gnus-score-alist gnus-current-score-file
1439 (gnus-summary-expunge-below . global)
1440 (gnus-summary-mark-below . global)
1441 (gnus-orphan-score . global)
1442 gnus-newsgroup-active gnus-scores-exclude-files
1443 gnus-newsgroup-history gnus-newsgroup-ancient
1444 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1445 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1446 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1447 (gnus-newsgroup-expunged-tally . 0)
1448 gnus-cache-removable-articles gnus-newsgroup-cached
1449 gnus-newsgroup-data gnus-newsgroup-data-reverse
1450 gnus-newsgroup-limit gnus-newsgroup-limits
1451 gnus-newsgroup-charset gnus-newsgroup-display
1452 gnus-summary-use-undownloaded-faces)
1453 "Variables that are buffer-local to the summary buffers.")
1455 (defvar gnus-newsgroup-variables nil
1456 "A list of variables that have separate values in different newsgroups.
1457 A list of newsgroup (summary buffer) local variables, or cons of
1458 variables and their default expressions to be evalled (when the default
1459 values are not nil), that should be made global while the summary buffer
1462 Note: The default expressions will be evaluated (using function `eval')
1463 before assignment to the local variable rather than just assigned to it.
1464 If the default expression is the symbol `global', that symbol will not
1465 be evaluated but the global value of the local variable will be used
1468 These variables can be used to set variables in the group parameters
1469 while still allowing them to affect operations done in other buffers.
1472 \(setq gnus-newsgroup-variables
1473 '(message-use-followup-to
1474 (gnus-visible-headers .
1475 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1478 ;; Byte-compiler warning.
1480 ;; Bind features so that require will believe that gnus-sum has
1481 ;; already been loaded (avoids infinite recursion)
1482 (let ((features (cons 'gnus-sum features)))
1483 ;; Several of the declarations in gnus-sum are needed to load the
1484 ;; following files. Right now, these definitions have been
1485 ;; compiled but not defined (evaluated). We could either do a
1486 ;; eval-and-compile about all of the declarations or evaluate the
1488 (if (boundp 'gnus-newsgroup-variables)
1490 (load "gnus-sum.el" t t t))
1492 (require 'gnus-art)))
1496 (defvar gnus-decode-encoded-word-methods
1497 '(mail-decode-encoded-word-string)
1498 "List of methods used to decode encoded words.
1500 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1501 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1502 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1503 whose names match REGEXP.
1506 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1507 mail-decode-encoded-word-string
1508 (\"chinese\" . rfc1843-decode-string))")
1510 (defvar gnus-decode-encoded-word-methods-cache nil)
1512 (defun gnus-multi-decode-encoded-word-string (string)
1513 "Apply the functions from `gnus-encoded-word-methods' that match."
1514 (unless (and gnus-decode-encoded-word-methods-cache
1515 (eq gnus-newsgroup-name
1516 (car gnus-decode-encoded-word-methods-cache)))
1517 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1520 (nconc gnus-decode-encoded-word-methods-cache (list x))
1521 (if (and gnus-newsgroup-name
1522 (string-match (car x) gnus-newsgroup-name))
1523 (nconc gnus-decode-encoded-word-methods-cache
1525 gnus-decode-encoded-word-methods))
1526 (let ((xlist gnus-decode-encoded-word-methods-cache))
1529 (setq string (funcall (pop xlist) string))))
1532 ;; Subject simplification.
1534 (defun gnus-simplify-whitespace (str)
1535 "Remove excessive whitespace from STR."
1537 (while (string-match "[ \t][ \t]+" str)
1538 (setq str (concat (substring str 0 (match-beginning 0))
1540 (substring str (match-end 0)))))
1542 (when (string-match "^[ \t]+" str)
1543 (setq str (substring str (match-end 0))))
1545 (when (string-match "[ \t]+$" str)
1546 (setq str (substring str 0 (match-beginning 0))))
1549 (defun gnus-simplify-all-whitespace (str)
1550 "Remove all whitespace from STR."
1551 (while (string-match "[ \t\n]+" str)
1552 (setq str (replace-match "" nil nil str)))
1555 (defsubst gnus-simplify-subject-re (subject)
1556 "Remove \"Re:\" from subject lines."
1557 (if (string-match message-subject-re-regexp subject)
1558 (substring subject (match-end 0))
1561 (defun gnus-simplify-subject (subject &optional re-only)
1562 "Remove `Re:' and words in parentheses.
1563 If RE-ONLY is non-nil, strip leading `Re:'s only."
1564 (let ((case-fold-search t)) ;Ignore case.
1565 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1566 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1567 (setq subject (substring subject (match-end 0))))
1568 ;; Remove uninteresting prefixes.
1569 (when (and (not re-only)
1570 gnus-simplify-ignored-prefixes
1571 (string-match gnus-simplify-ignored-prefixes subject))
1572 (setq subject (substring subject (match-end 0))))
1573 ;; Remove words in parentheses from end.
1575 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1576 (setq subject (substring subject 0 (match-beginning 0)))))
1577 ;; Return subject string.
1580 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1582 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1583 (goto-char (point-min))
1584 (while (re-search-forward regexp nil t)
1585 (replace-match (or newtext ""))))
1587 (defun gnus-simplify-buffer-fuzzy ()
1588 "Simplify string in the buffer fuzzily.
1589 The string in the accessible portion of the current buffer is simplified.
1590 It is assumed to be a single-line subject.
1591 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1592 matter is removed. Additional things can be deleted by setting
1593 `gnus-simplify-subject-fuzzy-regexp'."
1594 (let ((case-fold-search t)
1596 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1598 (while (not (eq modified-tick (buffer-modified-tick)))
1599 (setq modified-tick (buffer-modified-tick))
1601 ((listp gnus-simplify-subject-fuzzy-regexp)
1602 (mapcar 'gnus-simplify-buffer-fuzzy-step
1603 gnus-simplify-subject-fuzzy-regexp))
1604 (gnus-simplify-subject-fuzzy-regexp
1605 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1606 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1607 (gnus-simplify-buffer-fuzzy-step
1608 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1609 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1611 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1612 (gnus-simplify-buffer-fuzzy-step " +" " ")
1613 (gnus-simplify-buffer-fuzzy-step " $")
1614 (gnus-simplify-buffer-fuzzy-step "^ +")))
1616 (defun gnus-simplify-subject-fuzzy (subject)
1617 "Simplify a subject string fuzzily.
1618 See `gnus-simplify-buffer-fuzzy' for details."
1620 (gnus-set-work-buffer)
1621 (let ((case-fold-search t))
1622 ;; Remove uninteresting prefixes.
1623 (when (and gnus-simplify-ignored-prefixes
1624 (string-match gnus-simplify-ignored-prefixes subject))
1625 (setq subject (substring subject (match-end 0))))
1627 (inline (gnus-simplify-buffer-fuzzy))
1630 (defsubst gnus-simplify-subject-fully (subject)
1631 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1633 (gnus-simplify-subject-functions
1634 (gnus-map-function gnus-simplify-subject-functions subject))
1635 ((null gnus-summary-gather-subject-limit)
1636 (gnus-simplify-subject-re subject))
1637 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1638 (gnus-simplify-subject-fuzzy subject))
1639 ((numberp gnus-summary-gather-subject-limit)
1640 (gnus-limit-string (gnus-simplify-subject-re subject)
1641 gnus-summary-gather-subject-limit))
1645 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1646 "Check whether two subjects are equal.
1647 If optional argument SIMPLE-FIRST is t, first argument is already
1650 ((null simple-first)
1651 (equal (gnus-simplify-subject-fully s1)
1652 (gnus-simplify-subject-fully s2)))
1655 (gnus-simplify-subject-fully s2)))))
1657 (defun gnus-summary-bubble-group ()
1658 "Increase the score of the current group.
1659 This is a handy function to add to `gnus-summary-exit-hook' to
1660 increase the score of each group you read."
1661 (gnus-group-add-score gnus-newsgroup-name))
1665 ;;; Gnus summary mode
1668 (put 'gnus-summary-mode 'mode-class 'special)
1670 (defvar gnus-article-commands-menu)
1672 ;; Non-orthogonal keys
1674 (gnus-define-keys gnus-summary-mode-map
1675 " " gnus-summary-next-page
1676 "\177" gnus-summary-prev-page
1677 [delete] gnus-summary-prev-page
1678 [backspace] gnus-summary-prev-page
1679 "\r" gnus-summary-scroll-up
1680 "\M-\r" gnus-summary-scroll-down
1681 "n" gnus-summary-next-unread-article
1682 "p" gnus-summary-prev-unread-article
1683 "N" gnus-summary-next-article
1684 "P" gnus-summary-prev-article
1685 "\M-\C-n" gnus-summary-next-same-subject
1686 "\M-\C-p" gnus-summary-prev-same-subject
1687 "\M-n" gnus-summary-next-unread-subject
1688 "\M-p" gnus-summary-prev-unread-subject
1689 "." gnus-summary-first-unread-article
1690 "," gnus-summary-best-unread-article
1691 "\M-s" gnus-summary-search-article-forward
1692 "\M-r" gnus-summary-search-article-backward
1693 "<" gnus-summary-beginning-of-article
1694 ">" gnus-summary-end-of-article
1695 "j" gnus-summary-goto-article
1696 "^" gnus-summary-refer-parent-article
1697 "\M-^" gnus-summary-refer-article
1698 "u" gnus-summary-tick-article-forward
1699 "!" gnus-summary-tick-article-forward
1700 "U" gnus-summary-tick-article-backward
1701 "d" gnus-summary-mark-as-read-forward
1702 "D" gnus-summary-mark-as-read-backward
1703 "E" gnus-summary-mark-as-expirable
1704 "\M-u" gnus-summary-clear-mark-forward
1705 "\M-U" gnus-summary-clear-mark-backward
1706 "k" gnus-summary-kill-same-subject-and-select
1707 "\C-k" gnus-summary-kill-same-subject
1708 "\M-\C-k" gnus-summary-kill-thread
1709 "\M-\C-l" gnus-summary-lower-thread
1710 "e" gnus-summary-edit-article
1711 "#" gnus-summary-mark-as-processable
1712 "\M-#" gnus-summary-unmark-as-processable
1713 "\M-\C-t" gnus-summary-toggle-threads
1714 "\M-\C-s" gnus-summary-show-thread
1715 "\M-\C-h" gnus-summary-hide-thread
1716 "\M-\C-f" gnus-summary-next-thread
1717 "\M-\C-b" gnus-summary-prev-thread
1718 [(meta down)] gnus-summary-next-thread
1719 [(meta up)] gnus-summary-prev-thread
1720 "\M-\C-u" gnus-summary-up-thread
1721 "\M-\C-d" gnus-summary-down-thread
1722 "&" gnus-summary-execute-command
1723 "c" gnus-summary-catchup-and-exit
1724 "\C-w" gnus-summary-mark-region-as-read
1725 "\C-t" gnus-summary-toggle-truncation
1726 "?" gnus-summary-mark-as-dormant
1727 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1728 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1729 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1730 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1731 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1732 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1733 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1734 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1735 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1736 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1737 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1738 "=" gnus-summary-expand-window
1739 "\C-x\C-s" gnus-summary-reselect-current-group
1740 "\M-g" gnus-summary-rescan-group
1741 "w" gnus-summary-stop-page-breaking
1742 "\C-c\C-r" gnus-summary-caesar-message
1743 "f" gnus-summary-followup
1744 "F" gnus-summary-followup-with-original
1745 "C" gnus-summary-cancel-article
1746 "r" gnus-summary-reply
1747 "R" gnus-summary-reply-with-original
1748 "\C-c\C-f" gnus-summary-mail-forward
1749 "o" gnus-summary-save-article
1750 "\C-o" gnus-summary-save-article-mail
1751 "|" gnus-summary-pipe-output
1752 "\M-k" gnus-summary-edit-local-kill
1753 "\M-K" gnus-summary-edit-global-kill
1755 "\C-c\C-d" gnus-summary-describe-group
1756 "q" gnus-summary-exit
1757 "Q" gnus-summary-exit-no-update
1758 "\C-c\C-i" gnus-info-find-node
1759 gnus-mouse-2 gnus-mouse-pick-article
1760 [follow-link] mouse-face
1761 "m" gnus-summary-mail-other-window
1762 "a" gnus-summary-post-news
1763 "i" gnus-summary-news-other-window
1764 "x" gnus-summary-limit-to-unread
1765 "s" gnus-summary-isearch-article
1766 "t" gnus-summary-toggle-header
1767 "g" gnus-summary-show-article
1768 "l" gnus-summary-goto-last-article
1769 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1770 "\C-d" gnus-summary-enter-digest-group
1771 "\M-\C-d" gnus-summary-read-document
1772 "\M-\C-e" gnus-summary-edit-parameters
1773 "\M-\C-a" gnus-summary-customize-parameters
1775 "*" gnus-cache-enter-article
1776 "\M-*" gnus-cache-remove-article
1777 "\M-&" gnus-summary-universal-argument
1778 "\C-l" gnus-recenter
1779 "I" gnus-summary-increase-score
1780 "L" gnus-summary-lower-score
1781 "\M-i" gnus-symbolic-argument
1782 "h" gnus-summary-select-article-buffer
1784 "b" gnus-article-view-part
1785 "\M-t" gnus-summary-toggle-display-buttonized
1787 "V" gnus-summary-score-map
1788 "X" gnus-uu-extract-map
1789 "S" gnus-summary-send-map)
1791 ;; Sort of orthogonal keymap
1792 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1793 "t" gnus-summary-tick-article-forward
1794 "!" gnus-summary-tick-article-forward
1795 "d" gnus-summary-mark-as-read-forward
1796 "r" gnus-summary-mark-as-read-forward
1797 "c" gnus-summary-clear-mark-forward
1798 " " gnus-summary-clear-mark-forward
1799 "e" gnus-summary-mark-as-expirable
1800 "x" gnus-summary-mark-as-expirable
1801 "?" gnus-summary-mark-as-dormant
1802 "b" gnus-summary-set-bookmark
1803 "B" gnus-summary-remove-bookmark
1804 "#" gnus-summary-mark-as-processable
1805 "\M-#" gnus-summary-unmark-as-processable
1806 "S" gnus-summary-limit-include-expunged
1807 "C" gnus-summary-catchup
1808 "H" gnus-summary-catchup-to-here
1809 "h" gnus-summary-catchup-from-here
1810 "\C-c" gnus-summary-catchup-all
1811 "k" gnus-summary-kill-same-subject-and-select
1812 "K" gnus-summary-kill-same-subject
1813 "P" gnus-uu-mark-map)
1815 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1816 "c" gnus-summary-clear-above
1817 "u" gnus-summary-tick-above
1818 "m" gnus-summary-mark-above
1819 "k" gnus-summary-kill-below)
1821 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1822 "/" gnus-summary-limit-to-subject
1823 "n" gnus-summary-limit-to-articles
1824 "w" gnus-summary-pop-limit
1825 "s" gnus-summary-limit-to-subject
1826 "a" gnus-summary-limit-to-author
1827 "u" gnus-summary-limit-to-unread
1828 "m" gnus-summary-limit-to-marks
1829 "M" gnus-summary-limit-exclude-marks
1830 "v" gnus-summary-limit-to-score
1831 "*" gnus-summary-limit-include-cached
1832 "D" gnus-summary-limit-include-dormant
1833 "T" gnus-summary-limit-include-thread
1834 "d" gnus-summary-limit-exclude-dormant
1835 "t" gnus-summary-limit-to-age
1836 "." gnus-summary-limit-to-unseen
1837 "x" gnus-summary-limit-to-extra
1838 "p" gnus-summary-limit-to-display-predicate
1839 "E" gnus-summary-limit-include-expunged
1840 "c" gnus-summary-limit-exclude-childless-dormant
1841 "C" gnus-summary-limit-mark-excluded-as-read
1842 "o" gnus-summary-insert-old-articles
1843 "N" gnus-summary-insert-new-articles
1844 "r" gnus-summary-limit-to-replied
1845 "R" gnus-summary-limit-to-recipient)
1847 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1848 "n" gnus-summary-next-unread-article
1849 "p" gnus-summary-prev-unread-article
1850 "N" gnus-summary-next-article
1851 "P" gnus-summary-prev-article
1852 "\C-n" gnus-summary-next-same-subject
1853 "\C-p" gnus-summary-prev-same-subject
1854 "\M-n" gnus-summary-next-unread-subject
1855 "\M-p" gnus-summary-prev-unread-subject
1856 "f" gnus-summary-first-unread-article
1857 "b" gnus-summary-best-unread-article
1858 "j" gnus-summary-goto-article
1859 "g" gnus-summary-goto-subject
1860 "l" gnus-summary-goto-last-article
1861 "o" gnus-summary-pop-article)
1863 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1864 "k" gnus-summary-kill-thread
1865 "l" gnus-summary-lower-thread
1866 "i" gnus-summary-raise-thread
1867 "T" gnus-summary-toggle-threads
1868 "t" gnus-summary-rethread-current
1869 "^" gnus-summary-reparent-thread
1870 "s" gnus-summary-show-thread
1871 "S" gnus-summary-show-all-threads
1872 "h" gnus-summary-hide-thread
1873 "H" gnus-summary-hide-all-threads
1874 "n" gnus-summary-next-thread
1875 "p" gnus-summary-prev-thread
1876 "u" gnus-summary-up-thread
1877 "o" gnus-summary-top-thread
1878 "d" gnus-summary-down-thread
1879 "#" gnus-uu-mark-thread
1880 "\M-#" gnus-uu-unmark-thread)
1882 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1883 "g" gnus-summary-prepare
1884 "c" gnus-summary-insert-cached-articles
1885 "d" gnus-summary-insert-dormant-articles)
1887 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1888 "c" gnus-summary-catchup-and-exit
1889 "C" gnus-summary-catchup-all-and-exit
1890 "E" gnus-summary-exit-no-update
1891 "Q" gnus-summary-exit
1892 "Z" gnus-summary-exit
1893 "n" gnus-summary-catchup-and-goto-next-group
1894 "R" gnus-summary-reselect-current-group
1895 "G" gnus-summary-rescan-group
1896 "N" gnus-summary-next-group
1897 "s" gnus-summary-save-newsrc
1898 "P" gnus-summary-prev-group)
1900 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1901 " " gnus-summary-next-page
1902 "n" gnus-summary-next-page
1903 "\177" gnus-summary-prev-page
1904 [delete] gnus-summary-prev-page
1905 "p" gnus-summary-prev-page
1906 "\r" gnus-summary-scroll-up
1907 "\M-\r" gnus-summary-scroll-down
1908 "<" gnus-summary-beginning-of-article
1909 ">" gnus-summary-end-of-article
1910 "b" gnus-summary-beginning-of-article
1911 "e" gnus-summary-end-of-article
1912 "^" gnus-summary-refer-parent-article
1913 "r" gnus-summary-refer-parent-article
1914 "D" gnus-summary-enter-digest-group
1915 "R" gnus-summary-refer-references
1916 "T" gnus-summary-refer-thread
1917 "g" gnus-summary-show-article
1918 "s" gnus-summary-isearch-article
1919 "P" gnus-summary-print-article
1920 "M" gnus-mailing-list-insinuate
1921 "t" gnus-article-babel)
1923 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1924 "b" gnus-article-add-buttons
1925 "B" gnus-article-add-buttons-to-head
1926 "o" gnus-article-treat-overstrike
1927 "e" gnus-article-emphasize
1928 "w" gnus-article-fill-cited-article
1929 "Q" gnus-article-fill-long-lines
1930 "C" gnus-article-capitalize-sentences
1931 "c" gnus-article-remove-cr
1932 "q" gnus-article-de-quoted-unreadable
1933 "6" gnus-article-de-base64-unreadable
1934 "Z" gnus-article-decode-HZ
1935 "A" gnus-article-treat-ansi-sequences
1936 "h" gnus-article-wash-html
1937 "u" gnus-article-unsplit-urls
1938 "s" gnus-summary-force-verify-and-decrypt
1939 "f" gnus-article-display-x-face
1940 "l" gnus-summary-stop-page-breaking
1941 "r" gnus-summary-caesar-message
1942 "m" gnus-summary-morse-message
1943 "t" gnus-summary-toggle-header
1944 "g" gnus-treat-smiley
1945 "v" gnus-summary-verbose-headers
1946 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1947 "p" gnus-article-verify-x-pgp-sig
1948 "d" gnus-article-treat-dumbquotes
1949 "i" gnus-summary-idna-message)
1951 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1952 ;; mnemonic: deuglif*Y*
1953 "u" gnus-article-outlook-unwrap-lines
1954 "a" gnus-article-outlook-repair-attribution
1955 "c" gnus-article-outlook-rearrange-citation
1956 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1958 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1959 "a" gnus-article-hide
1960 "h" gnus-article-hide-headers
1961 "b" gnus-article-hide-boring-headers
1962 "s" gnus-article-hide-signature
1963 "c" gnus-article-hide-citation
1964 "C" gnus-article-hide-citation-in-followups
1965 "l" gnus-article-hide-list-identifiers
1966 "B" gnus-article-strip-banner
1967 "P" gnus-article-hide-pem
1968 "\C-c" gnus-article-hide-citation-maybe)
1970 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1971 "a" gnus-article-highlight
1972 "h" gnus-article-highlight-headers
1973 "c" gnus-article-highlight-citation
1974 "s" gnus-article-highlight-signature)
1976 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1977 "f" gnus-article-treat-fold-headers
1978 "u" gnus-article-treat-unfold-headers
1979 "n" gnus-article-treat-fold-newsgroups)
1981 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1982 "x" gnus-article-display-x-face
1983 "d" gnus-article-display-face
1984 "s" gnus-treat-smiley
1985 "D" gnus-article-remove-images
1986 "f" gnus-treat-from-picon
1987 "m" gnus-treat-mail-picon
1988 "n" gnus-treat-newsgroups-picon)
1990 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1991 "w" gnus-article-decode-mime-words
1992 "c" gnus-article-decode-charset
1993 "v" gnus-mime-view-all-parts
1994 "b" gnus-article-view-part)
1996 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1997 "z" gnus-article-date-ut
1998 "u" gnus-article-date-ut
1999 "l" gnus-article-date-local
2000 "p" gnus-article-date-english
2001 "e" gnus-article-date-lapsed
2002 "o" gnus-article-date-original
2003 "i" gnus-article-date-iso8601
2004 "s" gnus-article-date-user)
2006 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2007 "t" gnus-article-remove-trailing-blank-lines
2008 "l" gnus-article-strip-leading-blank-lines
2009 "m" gnus-article-strip-multiple-blank-lines
2010 "a" gnus-article-strip-blank-lines
2011 "A" gnus-article-strip-all-blank-lines
2012 "s" gnus-article-strip-leading-space
2013 "e" gnus-article-strip-trailing-space
2014 "w" gnus-article-remove-leading-whitespace)
2016 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2018 "f" gnus-summary-fetch-faq
2019 "d" gnus-summary-describe-group
2020 "h" gnus-summary-describe-briefly
2021 "i" gnus-info-find-node
2022 "c" gnus-group-fetch-charter
2023 "C" gnus-group-fetch-control)
2025 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2026 "e" gnus-summary-expire-articles
2027 "\M-\C-e" gnus-summary-expire-articles-now
2028 "\177" gnus-summary-delete-article
2029 [delete] gnus-summary-delete-article
2030 [backspace] gnus-summary-delete-article
2031 "m" gnus-summary-move-article
2032 "r" gnus-summary-respool-article
2033 "w" gnus-summary-edit-article
2034 "c" gnus-summary-copy-article
2035 "B" gnus-summary-crosspost-article
2036 "q" gnus-summary-respool-query
2037 "t" gnus-summary-respool-trace
2038 "i" gnus-summary-import-article
2039 "I" gnus-summary-create-article
2040 "p" gnus-summary-article-posted-p)
2042 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2043 "o" gnus-summary-save-article
2044 "m" gnus-summary-save-article-mail
2045 "F" gnus-summary-write-article-file
2046 "r" gnus-summary-save-article-rmail
2047 "f" gnus-summary-save-article-file
2048 "b" gnus-summary-save-article-body-file
2049 "h" gnus-summary-save-article-folder
2050 "v" gnus-summary-save-article-vm
2051 "p" gnus-summary-pipe-output
2052 "P" gnus-summary-muttprint
2053 "s" gnus-soup-add-article)
2055 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2056 "b" gnus-summary-display-buttonized
2057 "m" gnus-summary-repair-multipart
2058 "v" gnus-article-view-part
2059 "o" gnus-article-save-part
2060 "c" gnus-article-copy-part
2061 "C" gnus-article-view-part-as-charset
2062 "e" gnus-article-view-part-externally
2063 "E" gnus-article-encrypt-body
2064 "i" gnus-article-inline-part
2065 "|" gnus-article-pipe-part)
2067 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2068 "p" gnus-summary-mark-as-processable
2069 "u" gnus-summary-unmark-as-processable
2070 "U" gnus-summary-unmark-all-processable
2071 "v" gnus-uu-mark-over
2072 "s" gnus-uu-mark-series
2073 "r" gnus-uu-mark-region
2074 "g" gnus-uu-unmark-region
2075 "R" gnus-uu-mark-by-regexp
2076 "G" gnus-uu-unmark-by-regexp
2077 "t" gnus-uu-mark-thread
2078 "T" gnus-uu-unmark-thread
2079 "a" gnus-uu-mark-all
2080 "b" gnus-uu-mark-buffer
2081 "S" gnus-uu-mark-sparse
2082 "k" gnus-summary-kill-process-mark
2083 "y" gnus-summary-yank-process-mark
2084 "w" gnus-summary-save-process-mark
2085 "i" gnus-uu-invert-processable)
2087 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2088 ;;"x" gnus-uu-extract-any
2089 "m" gnus-summary-save-parts
2090 "u" gnus-uu-decode-uu
2091 "U" gnus-uu-decode-uu-and-save
2092 "s" gnus-uu-decode-unshar
2093 "S" gnus-uu-decode-unshar-and-save
2094 "o" gnus-uu-decode-save
2095 "O" gnus-uu-decode-save
2096 "b" gnus-uu-decode-binhex
2097 "B" gnus-uu-decode-binhex
2098 "p" gnus-uu-decode-postscript
2099 "P" gnus-uu-decode-postscript-and-save)
2102 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2103 "u" gnus-uu-decode-uu-view
2104 "U" gnus-uu-decode-uu-and-save-view
2105 "s" gnus-uu-decode-unshar-view
2106 "S" gnus-uu-decode-unshar-and-save-view
2107 "o" gnus-uu-decode-save-view
2108 "O" gnus-uu-decode-save-view
2109 "b" gnus-uu-decode-binhex-view
2110 "B" gnus-uu-decode-binhex-view
2111 "p" gnus-uu-decode-postscript-view
2112 "P" gnus-uu-decode-postscript-and-save-view)
2114 (defvar gnus-article-post-menu nil)
2116 (defconst gnus-summary-menu-maxlen 20)
2118 (defun gnus-summary-menu-split (menu)
2119 ;; If we have lots of elements, divide them into groups of 20
2120 ;; and make a pane (or submenu) for each one.
2121 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2122 (let ((menu menu) sublists next
2125 ;; Pull off the next gnus-summary-menu-maxlen elements
2126 ;; and make them the next element of sublist.
2127 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2129 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2131 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2132 (aref (car (last menu)) 0)) menu)
2136 (nreverse sublists))
2137 ;; Few elements--put them all in one pane.
2140 (defun gnus-summary-make-menu-bar ()
2141 (gnus-turn-off-edit-menu 'summary)
2143 (unless (boundp 'gnus-summary-misc-menu)
2146 gnus-summary-kill-menu gnus-summary-mode-map ""
2151 ["Customize" gnus-score-customize t])
2152 (gnus-make-score-map 'increase)
2153 (gnus-make-score-map 'lower)
2155 ["Kill below" gnus-summary-kill-below t]
2156 ["Mark above" gnus-summary-mark-above t]
2157 ["Tick above" gnus-summary-tick-above t]
2158 ["Clear above" gnus-summary-clear-above t])
2159 ["Current score" gnus-summary-current-score t]
2160 ["Set score" gnus-summary-set-score t]
2161 ["Switch current score file..." gnus-score-change-score-file t]
2162 ["Set mark below..." gnus-score-set-mark-below t]
2163 ["Set expunge below..." gnus-score-set-expunge-below t]
2164 ["Edit current score file" gnus-score-edit-current-scores t]
2165 ["Edit score file" gnus-score-edit-file t]
2166 ["Trace score" gnus-score-find-trace t]
2167 ["Find words" gnus-score-find-favourite-words t]
2168 ["Rescore buffer" gnus-summary-rescore t]
2169 ["Increase score..." gnus-summary-increase-score t]
2170 ["Lower score..." gnus-summary-lower-score t]))))
2172 ;; Define both the Article menu in the summary buffer and the
2173 ;; equivalent Commands menu in the article buffer here for
2177 ["All" gnus-article-hide t]
2178 ["Headers" gnus-article-hide-headers t]
2179 ["Signature" gnus-article-hide-signature t]
2180 ["Citation" gnus-article-hide-citation t]
2181 ["List identifiers" gnus-article-hide-list-identifiers t]
2182 ["Banner" gnus-article-strip-banner t]
2183 ["Boring headers" gnus-article-hide-boring-headers t])
2185 ["All" gnus-article-highlight t]
2186 ["Headers" gnus-article-highlight-headers t]
2187 ["Signature" gnus-article-highlight-signature t]
2188 ["Citation" gnus-article-highlight-citation t])
2190 ["Words" gnus-article-decode-mime-words t]
2191 ["Charset" gnus-article-decode-charset t]
2192 ["QP" gnus-article-de-quoted-unreadable t]
2193 ["Base64" gnus-article-de-base64-unreadable t]
2194 ["View MIME buttons" gnus-summary-display-buttonized t]
2195 ["View all" gnus-mime-view-all-parts t]
2196 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2197 ["Encrypt body" gnus-article-encrypt-body
2198 :active (not (gnus-group-read-only-p))
2199 ,@(if (featurep 'xemacs) nil
2200 '(:help "Encrypt the message body on disk"))]
2201 ["Extract all parts..." gnus-summary-save-parts t]
2203 ["Repair multipart" gnus-summary-repair-multipart t]
2204 ["Pipe part..." gnus-article-pipe-part t]
2205 ["Inline part" gnus-article-inline-part t]
2206 ["Encrypt body" gnus-article-encrypt-body
2207 :active (not (gnus-group-read-only-p))
2208 ,@(if (featurep 'xemacs) nil
2209 '(:help "Encrypt the message body on disk"))]
2210 ["View part externally" gnus-article-view-part-externally t]
2211 ["View part with charset..." gnus-article-view-part-as-charset t]
2212 ["Copy part" gnus-article-copy-part t]
2213 ["Save part..." gnus-article-save-part t]
2214 ["View part" gnus-article-view-part t]))
2216 ["Local" gnus-article-date-local t]
2217 ["ISO8601" gnus-article-date-iso8601 t]
2218 ["UT" gnus-article-date-ut t]
2219 ["Original" gnus-article-date-original t]
2220 ["Lapsed" gnus-article-date-lapsed t]
2221 ["User-defined" gnus-article-date-user t])
2223 ["Remove images" gnus-article-remove-images t]
2224 ["Toggle smiley" gnus-treat-smiley t]
2225 ["Show X-Face" gnus-article-display-x-face t]
2226 ["Show picons in From" gnus-treat-from-picon t]
2227 ["Show picons in mail headers" gnus-treat-mail-picon t]
2228 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2229 ("View as different encoding"
2230 ,@(gnus-summary-menu-split
2233 ;; Since easymenu under Emacs doesn't allow
2234 ;; lambda forms for menu commands, we should
2235 ;; provide intern'ed function symbols.
2236 (let ((command (intern (format "\
2237 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2241 (let ((gnus-summary-show-article-charset-alist
2243 (gnus-summary-show-article 1))))
2244 `[,(symbol-name cs) ,command t]))
2245 (sort (if (fboundp 'coding-system-list)
2246 (coding-system-list)
2247 (mapcar 'car mm-mime-mule-charset-alist))
2251 ["Leading" gnus-article-strip-leading-blank-lines t]
2252 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2253 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2254 ["All of the above" gnus-article-strip-blank-lines t]
2255 ["All" gnus-article-strip-all-blank-lines t]
2256 ["Leading space" gnus-article-strip-leading-space t]
2257 ["Trailing space" gnus-article-strip-trailing-space t]
2258 ["Leading space in headers"
2259 gnus-article-remove-leading-whitespace t])
2260 ["Overstrike" gnus-article-treat-overstrike t]
2261 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2262 ["Emphasis" gnus-article-emphasize t]
2263 ["Word wrap" gnus-article-fill-cited-article t]
2264 ["Fill long lines" gnus-article-fill-long-lines t]
2265 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2266 ["Remove CR" gnus-article-remove-cr t]
2267 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2268 ["Base64" gnus-article-de-base64-unreadable t]
2269 ["Rot 13" gnus-summary-caesar-message
2270 ,@(if (featurep 'xemacs) '(t)
2271 '(:help "\"Caesar rotate\" article by 13"))]
2272 ["De-IDNA" gnus-summary-idna-message t]
2273 ["Morse decode" gnus-summary-morse-message t]
2274 ["Unix pipe..." gnus-summary-pipe-message t]
2275 ["Add buttons" gnus-article-add-buttons t]
2276 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2277 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2278 ["Verbose header" gnus-summary-verbose-headers t]
2279 ["Toggle header" gnus-summary-toggle-header t]
2280 ["Unfold headers" gnus-article-treat-unfold-headers t]
2281 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2282 ["Html" gnus-article-wash-html t]
2283 ["Unsplit URLs" gnus-article-unsplit-urls t]
2284 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2285 ["Decode HZ" gnus-article-decode-HZ t]
2286 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2287 ("(Outlook) Deuglify"
2288 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2289 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2290 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2291 ["Full (Outlook) deuglify"
2292 gnus-article-outlook-deuglify-article t])
2295 ["Save in default format..." gnus-summary-save-article
2296 ,@(if (featurep 'xemacs) '(t)
2297 '(:help "Save article using default method"))]
2298 ["Save in file..." gnus-summary-save-article-file
2299 ,@(if (featurep 'xemacs) '(t)
2300 '(:help "Save article in file"))]
2301 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2302 ["Save in MH folder..." gnus-summary-save-article-folder t]
2303 ["Save in VM folder..." gnus-summary-save-article-vm t]
2304 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2305 ["Save body in file..." gnus-summary-save-article-body-file t]
2306 ["Pipe through a filter..." gnus-summary-pipe-output t]
2307 ["Add to SOUP packet" gnus-soup-add-article t]
2308 ["Print with Muttprint..." gnus-summary-muttprint t]
2309 ["Print" gnus-summary-print-article
2310 ,@(if (featurep 'xemacs) '(t)
2311 '(:help "Generate and print a PostScript image"))])
2312 ("Copy, move,... (Backend)"
2313 ,@(if (featurep 'xemacs) nil
2314 '(:help "Copying, moving, expiring articles..."))
2315 ["Respool article..." gnus-summary-respool-article t]
2316 ["Move article..." gnus-summary-move-article
2317 (gnus-check-backend-function
2318 'request-move-article gnus-newsgroup-name)]
2319 ["Copy article..." gnus-summary-copy-article t]
2320 ["Crosspost article..." gnus-summary-crosspost-article
2321 (gnus-check-backend-function
2322 'request-replace-article gnus-newsgroup-name)]
2323 ["Import file..." gnus-summary-import-article
2324 (gnus-check-backend-function
2325 'request-accept-article gnus-newsgroup-name)]
2326 ["Create article..." gnus-summary-create-article
2327 (gnus-check-backend-function
2328 'request-accept-article gnus-newsgroup-name)]
2329 ["Check if posted" gnus-summary-article-posted-p t]
2330 ["Edit article" gnus-summary-edit-article
2331 (not (gnus-group-read-only-p))]
2332 ["Delete article" gnus-summary-delete-article
2333 (gnus-check-backend-function
2334 'request-expire-articles gnus-newsgroup-name)]
2335 ["Query respool" gnus-summary-respool-query t]
2336 ["Trace respool" gnus-summary-respool-trace t]
2337 ["Delete expirable articles" gnus-summary-expire-articles-now
2338 (gnus-check-backend-function
2339 'request-expire-articles gnus-newsgroup-name)])
2341 ["Uudecode" gnus-uu-decode-uu
2342 ,@(if (featurep 'xemacs) '(t)
2343 '(:help "Decode uuencoded article(s)"))]
2344 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2345 ["Unshar" gnus-uu-decode-unshar t]
2346 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2347 ["Save" gnus-uu-decode-save t]
2348 ["Binhex" gnus-uu-decode-binhex t]
2349 ["Postscript" gnus-uu-decode-postscript t]
2350 ["All MIME parts" gnus-summary-save-parts t])
2352 ["Enter article" gnus-cache-enter-article t]
2353 ["Remove article" gnus-cache-remove-article t])
2354 ["Translate" gnus-article-babel t]
2355 ["Select article buffer" gnus-summary-select-article-buffer t]
2356 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2357 ["Isearch article..." gnus-summary-isearch-article t]
2358 ["Beginning of the article" gnus-summary-beginning-of-article t]
2359 ["End of the article" gnus-summary-end-of-article t]
2360 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2361 ["Fetch referenced articles" gnus-summary-refer-references t]
2362 ["Fetch current thread" gnus-summary-refer-thread t]
2363 ["Fetch article with id..." gnus-summary-refer-article t]
2364 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2365 ["Redisplay" gnus-summary-show-article t]
2366 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2368 gnus-summary-article-menu gnus-summary-mode-map ""
2369 (cons "Article" innards))
2371 (if (not (keymapp gnus-summary-article-menu))
2373 gnus-article-commands-menu gnus-article-mode-map ""
2374 (cons "Commands" innards))
2375 ;; in Emacs, don't share menu.
2376 (setq gnus-article-commands-menu
2377 (copy-keymap gnus-summary-article-menu))
2378 (define-key gnus-article-mode-map [menu-bar commands]
2379 (cons "Commands" gnus-article-commands-menu))))
2382 gnus-summary-thread-menu gnus-summary-mode-map ""
2384 ["Find all messages in thread" gnus-summary-refer-thread t]
2385 ["Toggle threading" gnus-summary-toggle-threads t]
2386 ["Hide threads" gnus-summary-hide-all-threads t]
2387 ["Show threads" gnus-summary-show-all-threads t]
2388 ["Hide thread" gnus-summary-hide-thread t]
2389 ["Show thread" gnus-summary-show-thread t]
2390 ["Go to next thread" gnus-summary-next-thread t]
2391 ["Go to previous thread" gnus-summary-prev-thread t]
2392 ["Go down thread" gnus-summary-down-thread t]
2393 ["Go up thread" gnus-summary-up-thread t]
2394 ["Top of thread" gnus-summary-top-thread t]
2395 ["Mark thread as read" gnus-summary-kill-thread t]
2396 ["Lower thread score" gnus-summary-lower-thread t]
2397 ["Raise thread score" gnus-summary-raise-thread t]
2398 ["Rethread current" gnus-summary-rethread-current t]))
2401 gnus-summary-post-menu gnus-summary-mode-map ""
2403 ["Send a message (mail or news)" gnus-summary-post-news
2404 ,@(if (featurep 'xemacs) '(t)
2405 '(:help "Compose a new message (mail or news)"))]
2406 ["Followup" gnus-summary-followup
2407 ,@(if (featurep 'xemacs) '(t)
2408 '(:help "Post followup to this article"))]
2409 ["Followup and yank" gnus-summary-followup-with-original
2410 ,@(if (featurep 'xemacs) '(t)
2411 '(:help "Post followup to this article, quoting its contents"))]
2412 ["Supersede article" gnus-summary-supersede-article t]
2413 ["Cancel article" gnus-summary-cancel-article
2414 ,@(if (featurep 'xemacs) '(t)
2415 '(:help "Cancel an article you posted"))]
2416 ["Reply" gnus-summary-reply t]
2417 ["Reply and yank" gnus-summary-reply-with-original t]
2418 ["Wide reply" gnus-summary-wide-reply t]
2419 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2420 ,@(if (featurep 'xemacs) '(t)
2421 '(:help "Mail a reply, quoting this article"))]
2422 ["Very wide reply" gnus-summary-very-wide-reply t]
2423 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2424 ,@(if (featurep 'xemacs) '(t)
2425 '(:help "Mail a very wide reply, quoting this article"))]
2426 ["Mail forward" gnus-summary-mail-forward t]
2427 ["Post forward" gnus-summary-post-forward t]
2428 ["Digest and mail" gnus-uu-digest-mail-forward t]
2429 ["Digest and post" gnus-uu-digest-post-forward t]
2430 ["Resend message" gnus-summary-resend-message t]
2431 ["Resend message edit" gnus-summary-resend-message-edit t]
2432 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2433 ["Send a mail" gnus-summary-mail-other-window t]
2434 ["Create a local message" gnus-summary-news-other-window t]
2435 ["Uuencode and post" gnus-uu-post-news
2436 ,@(if (featurep 'xemacs) '(t)
2437 '(:help "Post a uuencoded article"))]
2438 ["Followup via news" gnus-summary-followup-to-mail t]
2439 ["Followup via news and yank"
2440 gnus-summary-followup-to-mail-with-original t]
2442 ;;["Send" gnus-summary-send-draft t]
2443 ;;["Send bounced" gnus-resend-bounced-mail t])
2447 ((not (keymapp gnus-summary-post-menu))
2448 (setq gnus-article-post-menu gnus-summary-post-menu))
2449 ((not gnus-article-post-menu)
2450 ;; Don't share post menu.
2451 (setq gnus-article-post-menu
2452 (copy-keymap gnus-summary-post-menu))))
2453 (define-key gnus-article-mode-map [menu-bar post]
2454 (cons "Post" gnus-article-post-menu))
2457 gnus-summary-misc-menu gnus-summary-mode-map ""
2460 ["Mark as read" gnus-summary-mark-as-read-forward t]
2461 ["Mark same subject and select"
2462 gnus-summary-kill-same-subject-and-select t]
2463 ["Mark same subject" gnus-summary-kill-same-subject t]
2464 ["Catchup" gnus-summary-catchup
2465 ,@(if (featurep 'xemacs) '(t)
2466 '(:help "Mark unread articles in this group as read"))]
2467 ["Catchup all" gnus-summary-catchup-all t]
2468 ["Catchup to here" gnus-summary-catchup-to-here t]
2469 ["Catchup from here" gnus-summary-catchup-from-here t]
2470 ["Catchup region" gnus-summary-mark-region-as-read
2471 (gnus-mark-active-p)]
2472 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2474 ["Tick" gnus-summary-tick-article-forward t]
2475 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2476 ["Remove marks" gnus-summary-clear-mark-forward t]
2477 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2478 ["Set bookmark" gnus-summary-set-bookmark t]
2479 ["Remove bookmark" gnus-summary-remove-bookmark t])
2481 ["Marks..." gnus-summary-limit-to-marks t]
2482 ["Subject..." gnus-summary-limit-to-subject t]
2483 ["Author..." gnus-summary-limit-to-author t]
2484 ["Recipient..." gnus-summary-limit-to-recipient t]
2485 ["Age..." gnus-summary-limit-to-age t]
2486 ["Extra..." gnus-summary-limit-to-extra t]
2487 ["Score..." gnus-summary-limit-to-score t]
2488 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2489 ["Unread" gnus-summary-limit-to-unread t]
2490 ["Unseen" gnus-summary-limit-to-unseen t]
2491 ["Replied" gnus-summary-limit-to-replied t]
2492 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2493 ["Next articles" gnus-summary-limit-to-articles t]
2494 ["Pop limit" gnus-summary-pop-limit t]
2495 ["Show dormant" gnus-summary-limit-include-dormant t]
2496 ["Hide childless dormant"
2497 gnus-summary-limit-exclude-childless-dormant t]
2498 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2499 ["Hide marked" gnus-summary-limit-exclude-marks t]
2500 ["Show expunged" gnus-summary-limit-include-expunged t])
2502 ["Set mark" gnus-summary-mark-as-processable t]
2503 ["Remove mark" gnus-summary-unmark-as-processable t]
2504 ["Remove all marks" gnus-summary-unmark-all-processable t]
2505 ["Invert marks" gnus-uu-invert-processable t]
2506 ["Mark above" gnus-uu-mark-over t]
2507 ["Mark series" gnus-uu-mark-series t]
2508 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2509 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2510 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2511 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2512 ["Mark all" gnus-uu-mark-all t]
2513 ["Mark buffer" gnus-uu-mark-buffer t]
2514 ["Mark sparse" gnus-uu-mark-sparse t]
2515 ["Mark thread" gnus-uu-mark-thread t]
2516 ["Unmark thread" gnus-uu-unmark-thread t]
2517 ("Process Mark Sets"
2518 ["Kill" gnus-summary-kill-process-mark t]
2519 ["Yank" gnus-summary-yank-process-mark
2520 gnus-newsgroup-process-stack]
2521 ["Save" gnus-summary-save-process-mark t]
2522 ["Run command on marked..." gnus-summary-universal-argument t]))
2524 ["Page forward" gnus-summary-next-page
2525 ,@(if (featurep 'xemacs) '(t)
2526 '(:help "Show next page of article"))]
2527 ["Page backward" gnus-summary-prev-page
2528 ,@(if (featurep 'xemacs) '(t)
2529 '(:help "Show previous page of article"))]
2530 ["Line forward" gnus-summary-scroll-up t])
2532 ["Next unread article" gnus-summary-next-unread-article t]
2533 ["Previous unread article" gnus-summary-prev-unread-article t]
2534 ["Next article" gnus-summary-next-article t]
2535 ["Previous article" gnus-summary-prev-article t]
2536 ["Next unread subject" gnus-summary-next-unread-subject t]
2537 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2538 ["Next article same subject" gnus-summary-next-same-subject t]
2539 ["Previous article same subject" gnus-summary-prev-same-subject t]
2540 ["First unread article" gnus-summary-first-unread-article t]
2541 ["Best unread article" gnus-summary-best-unread-article t]
2542 ["Go to subject number..." gnus-summary-goto-subject t]
2543 ["Go to article number..." gnus-summary-goto-article t]
2544 ["Go to the last article" gnus-summary-goto-last-article t]
2545 ["Pop article off history" gnus-summary-pop-article t])
2547 ["Sort by number" gnus-summary-sort-by-number t]
2548 ["Sort by author" gnus-summary-sort-by-author t]
2549 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2550 ["Sort by subject" gnus-summary-sort-by-subject t]
2551 ["Sort by date" gnus-summary-sort-by-date t]
2552 ["Sort by score" gnus-summary-sort-by-score t]
2553 ["Sort by lines" gnus-summary-sort-by-lines t]
2554 ["Sort by characters" gnus-summary-sort-by-chars t]
2555 ["Randomize" gnus-summary-sort-by-random t]
2556 ["Original sort" gnus-summary-sort-by-original t])
2558 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2559 ["Describe group" gnus-summary-describe-group t]
2560 ["Fetch charter" gnus-group-fetch-charter
2561 ,@(if (featurep 'xemacs) nil
2562 '(:help "Display the charter of the current group"))]
2563 ["Fetch control message" gnus-group-fetch-control
2564 ,@(if (featurep 'xemacs) nil
2565 '(:help "Display the archived control message for the current group"))]
2566 ["Read manual" gnus-info-find-node t])
2568 ["Pick and read" gnus-pick-mode t]
2569 ["Binary" gnus-binary-mode t])
2571 ["Regenerate" gnus-summary-prepare t]
2572 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2573 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2574 ["Toggle threading" gnus-summary-toggle-threads t])
2575 ["See old articles" gnus-summary-insert-old-articles t]
2576 ["See new articles" gnus-summary-insert-new-articles t]
2577 ["Filter articles..." gnus-summary-execute-command t]
2578 ["Run command on articles..." gnus-summary-universal-argument t]
2579 ["Search articles forward..." gnus-summary-search-article-forward t]
2580 ["Search articles backward..." gnus-summary-search-article-backward t]
2581 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2582 ["Expand window" gnus-summary-expand-window t]
2583 ["Expire expirable articles" gnus-summary-expire-articles
2584 (gnus-check-backend-function
2585 'request-expire-articles gnus-newsgroup-name)]
2586 ["Edit local kill file" gnus-summary-edit-local-kill t]
2587 ["Edit main kill file" gnus-summary-edit-global-kill t]
2588 ["Edit group parameters" gnus-summary-edit-parameters t]
2589 ["Customize group parameters" gnus-summary-customize-parameters t]
2590 ["Send a bug report" gnus-bug t]
2592 ["Catchup and exit" gnus-summary-catchup-and-exit
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Mark unread articles in this group as read, then exit"))]
2595 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2596 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2597 ["Exit group" gnus-summary-exit
2598 ,@(if (featurep 'xemacs) '(t)
2599 '(:help "Exit current group, return to group selection mode"))]
2600 ["Exit group without updating" gnus-summary-exit-no-update t]
2601 ["Exit and goto next group" gnus-summary-next-group t]
2602 ["Exit and goto prev group" gnus-summary-prev-group t]
2603 ["Reselect group" gnus-summary-reselect-current-group t]
2604 ["Rescan group" gnus-summary-rescan-group t]
2605 ["Update dribble" gnus-summary-save-newsrc t])))
2607 (gnus-run-hooks 'gnus-summary-menu-hook)))
2609 (defvar gnus-summary-tool-bar-map nil)
2611 ;; Emacs 21 tool bar. Should be no-op otherwise.
2612 (defun gnus-summary-make-tool-bar ()
2613 (if (and (fboundp 'tool-bar-add-item-from-menu)
2614 (default-value 'tool-bar-mode)
2615 (not gnus-summary-tool-bar-map))
2616 (setq gnus-summary-tool-bar-map
2617 (let ((tool-bar-map (make-sparse-keymap))
2618 (load-path (mm-image-load-path)))
2619 (tool-bar-add-item-from-menu
2620 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2621 (tool-bar-add-item-from-menu
2622 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2623 (tool-bar-add-item-from-menu
2624 'gnus-summary-post-news "post" gnus-summary-mode-map)
2625 (tool-bar-add-item-from-menu
2626 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2627 (tool-bar-add-item-from-menu
2628 'gnus-summary-followup "followup" gnus-summary-mode-map)
2629 (tool-bar-add-item-from-menu
2630 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2631 (tool-bar-add-item-from-menu
2632 'gnus-summary-reply "reply" gnus-summary-mode-map)
2633 (tool-bar-add-item-from-menu
2634 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2635 (tool-bar-add-item-from-menu
2636 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2637 (tool-bar-add-item-from-menu
2638 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2639 (tool-bar-add-item-from-menu
2640 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2641 (tool-bar-add-item-from-menu
2642 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2643 (tool-bar-add-item-from-menu
2644 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2645 (tool-bar-add-item-from-menu
2646 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2647 (tool-bar-add-item-from-menu
2648 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2649 (tool-bar-add-item-from-menu
2650 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2652 (if gnus-summary-tool-bar-map
2653 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2655 (defun gnus-score-set-default (var value)
2656 "A version of set that updates the GNU Emacs menu-bar."
2658 ;; It is the message that forces the active status to be updated.
2661 (defun gnus-make-score-map (type)
2662 "Make a summary score map of type TYPE."
2665 (let ((headers '(("author" "from" string)
2666 ("subject" "subject" string)
2667 ("article body" "body" string)
2668 ("article head" "head" string)
2669 ("xref" "xref" string)
2670 ("extra header" "extra" string)
2671 ("lines" "lines" number)
2672 ("followups to author" "followup" string)))
2673 (types '((number ("less than" <)
2676 (string ("substring" s)
2680 (perms '(("temporary" (current-time-string))
2688 (if (eq type 'lower)
2693 (setq header (car headers))
2699 (let ((ts (cdr (assoc (nth 2 header) types)))
2715 'gnus-summary-score-entry
2717 (if (or (string= (nth 1 header)
2719 (string= (nth 1 header)
2722 (list 'gnus-summary-header
2724 (list 'quote (nth 1 (car ts)))
2725 (list 'gnus-score-delta-default
2732 (list (nreverse outp))))
2735 (list (nreverse outt))))
2737 (setq headers (cdr headers)))
2738 (list (nreverse outh))))))))
2742 (defun gnus-summary-mode (&optional group)
2743 "Major mode for reading articles.
2745 All normal editing commands are switched off.
2746 \\<gnus-summary-mode-map>
2747 Each line in this buffer represents one article. To read an
2748 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2749 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2752 You can also post articles and send mail from this buffer. To
2753 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2754 of an article, type `\\[gnus-summary-reply]'.
2756 There are approx. one gazillion commands you can execute in this
2757 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2759 The following commands are available:
2761 \\{gnus-summary-mode-map}"
2763 (kill-all-local-variables)
2764 (when (gnus-visual-p 'summary-menu 'menu)
2765 (gnus-summary-make-menu-bar)
2766 (gnus-summary-make-tool-bar))
2767 (gnus-summary-make-local-variables)
2768 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2769 (gnus-summary-make-local-variables))
2770 (gnus-make-thread-indent-array)
2771 (gnus-simplify-mode-line)
2772 (setq major-mode 'gnus-summary-mode)
2773 (setq mode-name "Summary")
2774 (make-local-variable 'minor-mode-alist)
2775 (use-local-map gnus-summary-mode-map)
2776 (buffer-disable-undo)
2777 (setq buffer-read-only t ;Disable modification
2778 show-trailing-whitespace nil)
2779 (setq truncate-lines t)
2780 (setq selective-display t)
2781 (setq selective-display-ellipses t) ;Display `...'
2782 (gnus-summary-set-display-table)
2783 (gnus-set-default-directory)
2784 (setq gnus-newsgroup-name group)
2785 (make-local-variable 'gnus-summary-line-format)
2786 (make-local-variable 'gnus-summary-line-format-spec)
2787 (make-local-variable 'gnus-summary-dummy-line-format)
2788 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2789 (make-local-variable 'gnus-summary-mark-positions)
2790 (gnus-make-local-hook 'pre-command-hook)
2791 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2792 (gnus-run-hooks 'gnus-summary-mode-hook)
2793 (turn-on-gnus-mailing-list-mode)
2794 (mm-enable-multibyte)
2795 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2796 (gnus-update-summary-mark-positions))
2798 (defun gnus-summary-make-local-variables ()
2799 "Make all the local summary buffer variables."
2801 (dolist (local gnus-summary-local-variables)
2804 (if (eq (cdr local) 'global)
2805 ;; Copy the global value of the variable.
2806 (setq global (symbol-value (car local)))
2807 ;; Use the value from the list.
2808 (setq global (eval (cdr local))))
2809 (set (make-local-variable (car local)) global))
2810 ;; Simple nil-valued local variable.
2811 (set (make-local-variable local) nil)))))
2813 (defun gnus-summary-clear-local-variables ()
2814 (let ((locals gnus-summary-local-variables))
2816 (if (consp (car locals))
2817 (and (symbolp (caar locals))
2818 (set (caar locals) nil))
2819 (and (symbolp (car locals))
2820 (set (car locals) nil)))
2821 (setq locals (cdr locals)))))
2823 ;; Summary data functions.
2825 (defmacro gnus-data-number (data)
2828 (defmacro gnus-data-set-number (data number)
2829 `(setcar ,data ,number))
2831 (defmacro gnus-data-mark (data)
2834 (defmacro gnus-data-set-mark (data mark)
2835 `(setcar (nthcdr 1 ,data) ,mark))
2837 (defmacro gnus-data-pos (data)
2840 (defmacro gnus-data-set-pos (data pos)
2841 `(setcar (nthcdr 2 ,data) ,pos))
2843 (defmacro gnus-data-header (data)
2846 (defmacro gnus-data-set-header (data header)
2847 `(setf (nth 3 ,data) ,header))
2849 (defmacro gnus-data-level (data)
2852 (defmacro gnus-data-unread-p (data)
2853 `(= (nth 1 ,data) gnus-unread-mark))
2855 (defmacro gnus-data-read-p (data)
2856 `(/= (nth 1 ,data) gnus-unread-mark))
2858 (defmacro gnus-data-pseudo-p (data)
2859 `(consp (nth 3 ,data)))
2861 (defmacro gnus-data-find (number)
2862 `(assq ,number gnus-newsgroup-data))
2864 (defmacro gnus-data-find-list (number &optional data)
2865 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2866 (memq (assq ,number bdata)
2869 (defmacro gnus-data-make (number mark pos header level)
2870 `(list ,number ,mark ,pos ,header ,level))
2872 (defun gnus-data-enter (after-article number mark pos header level offset)
2873 (let ((data (gnus-data-find-list after-article)))
2875 (error "No such article: %d" after-article))
2876 (setcdr data (cons (gnus-data-make number mark pos header level)
2878 (setq gnus-newsgroup-data-reverse nil)
2879 (gnus-data-update-list (cddr data) offset)))
2881 (defun gnus-data-enter-list (after-article list &optional offset)
2883 (let ((data (and after-article (gnus-data-find-list after-article)))
2887 (let ((odata gnus-newsgroup-data))
2888 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2890 (gnus-data-update-list odata offset)))
2891 ;; Find the last element in the list to be spliced into the main
2893 (setq list (last list))
2896 (setcdr list gnus-newsgroup-data)
2897 (setq gnus-newsgroup-data ilist)
2899 (gnus-data-update-list (cdr list) offset)))
2900 (setcdr list (cdr data))
2903 (gnus-data-update-list (cdr list) offset))))
2904 (setq gnus-newsgroup-data-reverse nil))))
2906 (defun gnus-data-remove (article &optional offset)
2907 (let ((data gnus-newsgroup-data))
2908 (if (= (gnus-data-number (car data)) article)
2910 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2911 gnus-newsgroup-data-reverse nil)
2913 (gnus-data-update-list gnus-newsgroup-data offset)))
2915 (when (= (gnus-data-number (cadr data)) article)
2916 (setcdr data (cddr data))
2918 (gnus-data-update-list (cdr data) offset))
2920 gnus-newsgroup-data-reverse nil))
2921 (setq data (cdr data))))))
2923 (defmacro gnus-data-list (backward)
2925 (or gnus-newsgroup-data-reverse
2926 (setq gnus-newsgroup-data-reverse
2927 (reverse gnus-newsgroup-data)))
2928 gnus-newsgroup-data))
2930 (defun gnus-data-update-list (data offset)
2931 "Add OFFSET to the POS of all data entries in DATA."
2932 (setq gnus-newsgroup-data-reverse nil)
2934 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2935 (setq data (cdr data))))
2937 (defun gnus-summary-article-pseudo-p (article)
2938 "Say whether this article is a pseudo article or not."
2939 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2941 (defmacro gnus-summary-article-sparse-p (article)
2942 "Say whether this article is a sparse article or not."
2943 `(memq ,article gnus-newsgroup-sparse))
2945 (defmacro gnus-summary-article-ancient-p (article)
2946 "Say whether this article is a sparse article or not."
2947 `(memq ,article gnus-newsgroup-ancient))
2949 (defun gnus-article-parent-p (number)
2950 "Say whether this article is a parent or not."
2951 (let ((data (gnus-data-find-list number)))
2952 (and (cdr data) ; There has to be an article after...
2953 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2954 (gnus-data-level (nth 1 data))))))
2956 (defun gnus-article-children (number)
2957 "Return a list of all children to NUMBER."
2958 (let* ((data (gnus-data-find-list number))
2959 (level (gnus-data-level (car data)))
2961 (setq data (cdr data))
2963 (= (gnus-data-level (car data)) (1+ level)))
2964 (push (gnus-data-number (car data)) children)
2965 (setq data (cdr data)))
2968 (defmacro gnus-summary-skip-intangible ()
2969 "If the current article is intangible, then jump to a different article."
2970 '(let ((to (get-text-property (point) 'gnus-intangible)))
2971 (and to (gnus-summary-goto-subject to))))
2973 (defmacro gnus-summary-article-intangible-p ()
2974 "Say whether this article is intangible or not."
2975 '(get-text-property (point) 'gnus-intangible))
2977 (defun gnus-article-read-p (article)
2978 "Say whether ARTICLE is read or not."
2979 (not (or (memq article gnus-newsgroup-marked)
2980 (memq article gnus-newsgroup-spam-marked)
2981 (memq article gnus-newsgroup-unreads)
2982 (memq article gnus-newsgroup-unselected)
2983 (memq article gnus-newsgroup-dormant))))
2985 ;; Some summary mode macros.
2987 (defmacro gnus-summary-article-number ()
2988 "The article number of the article on the current line.
2989 If there isn't an article number here, then we return the current
2992 (gnus-summary-skip-intangible)
2993 (or (get-text-property (point) 'gnus-number)
2994 (gnus-summary-last-subject))))
2996 (defmacro gnus-summary-article-header (&optional number)
2997 "Return the header of article NUMBER."
2998 `(gnus-data-header (gnus-data-find
2999 ,(or number '(gnus-summary-article-number)))))
3001 (defmacro gnus-summary-thread-level (&optional number)
3002 "Return the level of thread that starts with article NUMBER."
3003 `(if (and (eq gnus-summary-make-false-root 'dummy)
3004 (get-text-property (point) 'gnus-intangible))
3006 (gnus-data-level (gnus-data-find
3007 ,(or number '(gnus-summary-article-number))))))
3009 (defmacro gnus-summary-article-mark (&optional number)
3010 "Return the mark of article NUMBER."
3011 `(gnus-data-mark (gnus-data-find
3012 ,(or number '(gnus-summary-article-number)))))
3014 (defmacro gnus-summary-article-pos (&optional number)
3015 "Return the position of the line of article NUMBER."
3016 `(gnus-data-pos (gnus-data-find
3017 ,(or number '(gnus-summary-article-number)))))
3019 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3020 (defmacro gnus-summary-article-subject (&optional number)
3021 "Return current subject string or nil if nothing."
3024 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3025 '(gnus-data-header (assq (gnus-summary-article-number)
3026 gnus-newsgroup-data)))))
3029 (mail-header-subject headers))))
3031 (defmacro gnus-summary-article-score (&optional number)
3032 "Return current article score."
3033 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3034 gnus-newsgroup-scored))
3035 gnus-summary-default-score 0))
3037 (defun gnus-summary-article-children (&optional number)
3038 "Return a list of article numbers that are children of article NUMBER."
3039 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3040 (level (gnus-data-level (car data)))
3042 (while (and (setq data (cdr data))
3043 (> (setq l (gnus-data-level (car data))) level))
3044 (and (= (1+ level) l)
3045 (push (gnus-data-number (car data))
3047 (nreverse children)))
3049 (defun gnus-summary-article-parent (&optional number)
3050 "Return the article number of the parent of article NUMBER."
3051 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3052 (gnus-data-list t)))
3053 (level (gnus-data-level (car data))))
3055 () ; This is a root.
3056 ;; We search until we find an article with a level less than
3057 ;; this one. That function has to be the parent.
3058 (while (and (setq data (cdr data))
3059 (not (< (gnus-data-level (car data)) level))))
3060 (and data (gnus-data-number (car data))))))
3062 (defun gnus-unread-mark-p (mark)
3063 "Say whether MARK is the unread mark."
3064 (= mark gnus-unread-mark))
3066 (defun gnus-read-mark-p (mark)
3067 "Say whether MARK is one of the marks that mark as read.
3068 This is all marks except unread, ticked, dormant, and expirable."
3069 (not (or (= mark gnus-unread-mark)
3070 (= mark gnus-ticked-mark)
3071 (= mark gnus-spam-mark)
3072 (= mark gnus-dormant-mark)
3073 (= mark gnus-expirable-mark))))
3075 (defmacro gnus-article-mark (number)
3076 "Return the MARK of article NUMBER.
3077 This macro should only be used when computing the mark the \"first\"
3078 time; i.e., when generating the summary lines. After that,
3079 `gnus-summary-article-mark' should be used to examine the
3082 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3083 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3084 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3085 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3086 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3087 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3088 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3089 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3090 gnus-ancient-mark))))
3092 ;; Saving hidden threads.
3094 (defmacro gnus-save-hidden-threads (&rest forms)
3095 "Save hidden threads, eval FORMS, and restore the hidden threads."
3096 (let ((config (make-symbol "config")))
3097 `(let ((,config (gnus-hidden-threads-configuration)))
3101 (gnus-restore-hidden-threads-configuration ,config)))))
3102 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3103 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3105 (defun gnus-data-compute-positions ()
3106 "Compute the positions of all articles."
3107 (setq gnus-newsgroup-data-reverse nil)
3108 (let ((data gnus-newsgroup-data))
3110 (gnus-save-hidden-threads
3111 (gnus-summary-show-all-threads)
3112 (goto-char (point-min))
3114 (while (get-text-property (point) 'gnus-intangible)
3116 (gnus-data-set-pos (car data) (+ (point) 3))
3117 (setq data (cdr data))
3118 (forward-line 1))))))
3120 (defun gnus-hidden-threads-configuration ()
3121 "Return the current hidden threads configuration."
3124 (goto-char (point-min))
3125 (while (search-forward "\r" nil t)
3126 (push (1- (point)) config))
3129 (defun gnus-restore-hidden-threads-configuration (config)
3130 "Restore hidden threads configuration from CONFIG."
3132 (let (point buffer-read-only)
3133 (while (setq point (pop config))
3134 (when (and (< point (point-max))
3136 (eq (char-after) ?\n))
3137 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3139 ;; Various summary mode internalish functions.
3141 (defun gnus-mouse-pick-article (e)
3144 (gnus-summary-next-page nil t))
3146 (defun gnus-summary-set-display-table ()
3147 "Change the display table.
3148 Odd characters have a tendency to mess
3149 up nicely formatted displays - we make all possible glyphs
3150 display only a single character."
3152 ;; We start from the standard display table, if any.
3153 (let ((table (or (copy-sequence standard-display-table)
3154 (make-display-table)))
3156 ;; Nix out all the control chars...
3157 (while (>= (setq i (1- i)) 0)
3158 (aset table i [??]))
3159 ;; ... but not newline and cr, of course. (cr is necessary for the
3160 ;; selective display).
3161 (aset table ?\n nil)
3162 (aset table ?\r nil)
3163 ;; We keep TAB as well.
3164 (aset table ?\t nil)
3165 ;; We nix out any glyphs over 126 that are not set already.
3167 (while (>= (setq i (1- i)) 127)
3168 ;; Only modify if the entry is nil.
3169 (unless (aref table i)
3170 (aset table i [??]))))
3171 (setq buffer-display-table table)))
3173 (defun gnus-summary-set-article-display-arrow (pos)
3174 "Update the overlay arrow to point to line at position POS."
3175 (when (and gnus-summary-display-arrow
3176 (boundp 'overlay-arrow-position)
3177 (boundp 'overlay-arrow-string))
3181 (unless overlay-arrow-position
3182 (setq overlay-arrow-position (make-marker)))
3183 (setq overlay-arrow-string "=>"
3184 overlay-arrow-position (set-marker overlay-arrow-position
3186 (current-buffer))))))
3188 (defun gnus-summary-setup-buffer (group)
3189 "Initialize summary buffer."
3190 (let ((buffer (gnus-summary-buffer-name group))
3191 (dead-name (concat "*Dead Summary "
3192 (gnus-group-decoded-name group) "*")))
3193 ;; If a dead summary buffer exists, we kill it.
3194 (when (gnus-buffer-live-p dead-name)
3195 (gnus-kill-buffer dead-name))
3196 (if (get-buffer buffer)
3199 (setq gnus-summary-buffer (current-buffer))
3200 (not gnus-newsgroup-prepared))
3201 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3202 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3203 (gnus-summary-mode group)
3205 (gnus-carpal-setup-buffer 'summary))
3206 (unless gnus-single-article-buffer
3207 (make-local-variable 'gnus-article-buffer)
3208 (make-local-variable 'gnus-article-current)
3209 (make-local-variable 'gnus-original-article-buffer))
3210 (setq gnus-newsgroup-name group)
3211 ;; Set any local variables in the group parameters.
3212 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3215 (defun gnus-set-global-variables ()
3216 "Set the global equivalents of the buffer-local variables.
3217 They are set to the latest values they had. These reflect the summary
3218 buffer that was in action when the last article was fetched."
3219 (when (eq major-mode 'gnus-summary-mode)
3220 (setq gnus-summary-buffer (current-buffer))
3221 (let ((name gnus-newsgroup-name)
3222 (marked gnus-newsgroup-marked)
3223 (spam gnus-newsgroup-spam-marked)
3224 (unread gnus-newsgroup-unreads)
3225 (headers gnus-current-headers)
3226 (data gnus-newsgroup-data)
3227 (summary gnus-summary-buffer)
3228 (article-buffer gnus-article-buffer)
3229 (original gnus-original-article-buffer)
3230 (gac gnus-article-current)
3231 (reffed gnus-reffed-article-number)
3232 (score-file gnus-current-score-file)
3233 (default-charset gnus-newsgroup-charset)
3235 (let ((locals gnus-newsgroup-variables))
3237 (if (consp (car locals))
3238 (push (eval (caar locals)) vlist)
3239 (push (eval (car locals)) vlist))
3240 (setq locals (cdr locals)))
3241 (setq vlist (nreverse vlist)))
3242 (with-current-buffer gnus-group-buffer
3243 (setq gnus-newsgroup-name name
3244 gnus-newsgroup-marked marked
3245 gnus-newsgroup-spam-marked spam
3246 gnus-newsgroup-unreads unread
3247 gnus-current-headers headers
3248 gnus-newsgroup-data data
3249 gnus-article-current gac
3250 gnus-summary-buffer summary
3251 gnus-article-buffer article-buffer
3252 gnus-original-article-buffer original
3253 gnus-reffed-article-number reffed
3254 gnus-current-score-file score-file
3255 gnus-newsgroup-charset default-charset)
3256 (let ((locals gnus-newsgroup-variables))
3258 (if (consp (car locals))
3259 (set (caar locals) (pop vlist))
3260 (set (car locals) (pop vlist)))
3261 (setq locals (cdr locals))))
3262 ;; The article buffer also has local variables.
3263 (when (gnus-buffer-live-p gnus-article-buffer)
3264 (set-buffer gnus-article-buffer)
3265 (setq gnus-summary-buffer summary))))))
3267 (defun gnus-summary-article-unread-p (article)
3268 "Say whether ARTICLE is unread or not."
3269 (memq article gnus-newsgroup-unreads))
3271 (defun gnus-summary-first-article-p (&optional article)
3272 "Return whether ARTICLE is the first article in the buffer."
3273 (if (not (setq article (or article (gnus-summary-article-number))))
3275 (eq article (caar gnus-newsgroup-data))))
3277 (defun gnus-summary-last-article-p (&optional article)
3278 "Return whether ARTICLE is the last article in the buffer."
3279 (if (not (setq article (or article (gnus-summary-article-number))))
3280 ;; All non-existent numbers are the last article. :-)
3282 (not (cdr (gnus-data-find-list article)))))
3284 (defun gnus-make-thread-indent-array ()
3286 (unless (and gnus-thread-indent-array
3287 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3288 (setq gnus-thread-indent-array (make-vector 201 "")
3289 gnus-thread-indent-array-level gnus-thread-indent-level)
3291 (aset gnus-thread-indent-array n
3292 (make-string (* n gnus-thread-indent-level) ? ))
3295 (defun gnus-update-summary-mark-positions ()
3296 "Compute where the summary marks are to go."
3298 (when (gnus-buffer-exists-p gnus-summary-buffer)
3299 (set-buffer gnus-summary-buffer))
3300 (let ((spec gnus-summary-line-format-spec)
3303 (gnus-set-work-buffer)
3304 (let ((gnus-tmp-unread ?Z)
3305 (gnus-replied-mark ?Z)
3306 (gnus-score-below-mark ?Z)
3307 (gnus-score-over-mark ?Z)
3308 (gnus-undownloaded-mark ?Z)
3309 (gnus-summary-line-format-spec spec)
3310 (gnus-newsgroup-downloadable '(0))
3311 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3312 case-fold-search ignores)
3313 ;; Here, all marks are bound to Z.
3314 (gnus-summary-insert-line header
3315 0 nil t gnus-tmp-unread t nil "" nil 1)
3316 (goto-char (point-min))
3317 ;; Memorize the positions of the same characters as dummy marks.
3318 (while (re-search-forward "[A-D]" nil t)
3319 (push (point) ignores))
3321 ;; We use A-D as dummy marks in order to know column positions
3322 ;; where marks should be inserted.
3323 (setq gnus-tmp-unread ?A
3324 gnus-replied-mark ?B
3325 gnus-score-below-mark ?C
3326 gnus-score-over-mark ?C
3327 gnus-undownloaded-mark ?D)
3328 (gnus-summary-insert-line header
3329 0 nil t gnus-tmp-unread t nil "" nil 1)
3330 ;; Ignore characters which aren't dummy marks.
3332 (delete-region (goto-char (1- p)) p)
3334 (goto-char (point-min))
3335 (setq pos (list (cons 'unread
3336 (and (search-forward "A" nil t)
3337 (- (point) (point-min) 1)))))
3338 (goto-char (point-min))
3339 (push (cons 'replied (and (search-forward "B" nil t)
3340 (- (point) (point-min) 1)))
3342 (goto-char (point-min))
3343 (push (cons 'score (and (search-forward "C" nil t)
3344 (- (point) (point-min) 1)))
3346 (goto-char (point-min))
3347 (push (cons 'download (and (search-forward "D" nil t)
3348 (- (point) (point-min) 1)))
3350 (setq gnus-summary-mark-positions pos))))
3352 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3353 "Insert a dummy root in the summary buffer."
3355 (gnus-add-text-properties
3356 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3357 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3359 (defun gnus-summary-extract-address-component (from)
3360 (or (car (funcall gnus-extract-address-components from))
3363 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3364 (let ((mail-parse-charset gnus-newsgroup-charset)
3365 ; Is it really necessary to do this next part for each summary line?
3366 ; Luckily, doesn't seem to slow things down much.
3367 (mail-parse-ignored-charsets
3368 (with-current-buffer gnus-summary-buffer
3369 gnus-newsgroup-ignored-charsets)))
3371 (and gnus-ignored-from-addresses
3372 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3373 (let ((extra-headers (mail-header-extra header))
3377 ((setq to (cdr (assq 'To extra-headers)))
3380 (gnus-summary-extract-address-component
3381 (funcall gnus-decode-encoded-word-function to)))))
3382 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3383 (concat "=> " newsgroups)))))
3384 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3386 (defun gnus-summary-insert-line (gnus-tmp-header
3387 gnus-tmp-level gnus-tmp-current
3388 undownloaded gnus-tmp-unread gnus-tmp-replied
3389 gnus-tmp-expirable gnus-tmp-subject-or-nil
3390 &optional gnus-tmp-dummy gnus-tmp-score
3392 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3393 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3394 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3395 (gnus-tmp-score-char
3396 (if (or (null gnus-summary-default-score)
3397 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3398 gnus-summary-zcore-fuzz))
3400 (if (< gnus-tmp-score gnus-summary-default-score)
3401 gnus-score-below-mark gnus-score-over-mark)))
3402 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3404 (cond (gnus-tmp-process gnus-process-mark)
3405 ((memq gnus-tmp-current gnus-newsgroup-cached)
3407 (gnus-tmp-replied gnus-replied-mark)
3408 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3409 gnus-forwarded-mark)
3410 ((memq gnus-tmp-current gnus-newsgroup-saved)
3412 ((memq gnus-tmp-number gnus-newsgroup-recent)
3414 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3417 (gnus-tmp-downloaded
3419 gnus-undownloaded-mark)
3420 (gnus-newsgroup-agentized
3421 gnus-downloaded-mark)
3424 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3427 ((string-match "<[^>]+> *$" gnus-tmp-from)
3428 (let ((beg (match-beginning 0)))
3429 (or (and (string-match "^\".+\"" gnus-tmp-from)
3430 (substring gnus-tmp-from 1 (1- (match-end 0))))
3431 (substring gnus-tmp-from 0 beg))))
3432 ((string-match "(.+)" gnus-tmp-from)
3433 (substring gnus-tmp-from
3434 (1+ (match-beginning 0)) (1- (match-end 0))))
3436 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3437 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3438 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3439 (buffer-read-only nil))
3440 (when (string= gnus-tmp-name "")
3441 (setq gnus-tmp-name gnus-tmp-from))
3442 (unless (numberp gnus-tmp-lines)
3443 (setq gnus-tmp-lines -1))
3444 (if (= gnus-tmp-lines -1)
3445 (setq gnus-tmp-lines "?")
3446 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3447 (gnus-put-text-property
3449 (progn (eval gnus-summary-line-format-spec) (point))
3450 'gnus-number gnus-tmp-number)
3451 (when (gnus-visual-p 'summary-highlight 'highlight)
3453 (gnus-run-hooks 'gnus-summary-update-hook)
3456 (defun gnus-summary-update-line (&optional dont-update)
3457 "Update summary line after change."
3458 (when (and gnus-summary-default-score
3459 (not gnus-summary-inhibit-highlight))
3460 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3461 (article (gnus-summary-article-number))
3462 (score (gnus-summary-article-score article)))
3464 (if (and gnus-summary-mark-below
3465 (< (gnus-summary-article-score)
3466 gnus-summary-mark-below))
3467 ;; This article has a low score, so we mark it as read.
3468 (when (memq article gnus-newsgroup-unreads)
3469 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3470 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3471 ;; This article was previously marked as read on account
3472 ;; of a low score, but now it has risen, so we mark it as
3474 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3475 (gnus-summary-update-mark
3476 (if (or (null gnus-summary-default-score)
3477 (<= (abs (- score gnus-summary-default-score))
3478 gnus-summary-zcore-fuzz))
3480 (if (< score gnus-summary-default-score)
3481 gnus-score-below-mark gnus-score-over-mark))
3483 ;; Do visual highlighting.
3484 (when (gnus-visual-p 'summary-highlight 'highlight)
3485 (gnus-run-hooks 'gnus-summary-update-hook)))))
3487 (defvar gnus-tmp-new-adopts nil)
3489 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3490 "Return the number of articles in THREAD.
3491 This may be 0 in some cases -- if none of the articles in
3492 the thread are to be displayed."
3494 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3496 ((not (listp thread))
3498 ((and (consp thread) (cdr thread))
3501 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3504 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3507 (when (and level (zerop level) gnus-tmp-new-adopts)
3510 'gnus-summary-number-of-articles-in-thread
3511 gnus-tmp-new-adopts))))
3513 (if (> number 1) gnus-not-empty-thread-mark
3514 gnus-empty-thread-mark)
3517 (defsubst gnus-summary-line-message-size (head)
3518 "Return pretty-printed version of message size.
3519 This function is intended to be used in
3520 `gnus-summary-line-format-alist'."
3521 (let ((c (or (mail-header-chars head) -1)))
3522 (cond ((< c 0) "n/a") ; chars not available
3523 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3524 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3525 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3526 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3529 (defun gnus-summary-set-local-parameters (group)
3530 "Go through the local params of GROUP and set all variable specs in that list."
3531 (let ((vars '(quit-config))) ; Ignore quit-config.
3532 (dolist (elem (gnus-group-find-parameter group))
3533 (and (consp elem) ; Has to be a cons.
3534 (consp (cdr elem)) ; The cdr has to be a list.
3535 (symbolp (car elem)) ; Has to be a symbol in there.
3536 (not (memq (car elem) vars))
3537 (ignore-errors ; So we set it.
3538 (push (car elem) vars)
3539 (make-local-variable (car elem))
3540 (set (car elem) (eval (nth 1 elem))))))))
3542 (defun gnus-summary-read-group (group &optional show-all no-article
3543 kill-buffer no-display backward
3545 "Start reading news in newsgroup GROUP.
3546 If SHOW-ALL is non-nil, already read articles are also listed.
3547 If NO-ARTICLE is non-nil, no article is selected initially.
3548 If NO-DISPLAY, don't generate a summary buffer."
3552 (let ((gnus-auto-select-next nil))
3553 (or (gnus-summary-read-group-1
3554 group show-all no-article
3555 kill-buffer no-display
3558 select-articles nil)))))
3559 (eq gnus-auto-select-next 'quietly))
3560 (set-buffer gnus-group-buffer)
3561 ;; The entry function called above goes to the next
3562 ;; group automatically, so we go two groups back
3563 ;; if we are searching for the previous group.
3565 (gnus-group-prev-unread-group 2))
3566 (if (not (equal group (gnus-group-group-name)))
3567 (setq group (gnus-group-group-name))
3571 (defun gnus-summary-read-group-1 (group show-all no-article
3572 kill-buffer no-display
3573 &optional select-articles)
3574 ;; Killed foreign groups can't be entered.
3575 ;; (when (and (not (gnus-group-native-p group))
3576 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3577 ;; (error "Dead non-native groups can't be entered"))
3578 (gnus-message 5 "Retrieving newsgroup: %s..."
3579 (gnus-group-decoded-name group))
3580 (let* ((new-group (gnus-summary-setup-buffer group))
3581 (quit-config (gnus-group-quit-config group))
3582 (did-select (and new-group (gnus-select-newsgroup
3583 group show-all select-articles))))
3585 ;; This summary buffer exists already, so we just select it.
3587 (gnus-set-global-variables)
3589 (gnus-kill-or-deaden-summary kill-buffer))
3590 (gnus-configure-windows 'summary 'force)
3591 (gnus-set-mode-line 'summary)
3592 (gnus-summary-position-point)
3595 ;; We couldn't select this group.
3597 (when (and (eq major-mode 'gnus-summary-mode)
3598 (not (equal (current-buffer) kill-buffer)))
3599 (kill-buffer (current-buffer))
3600 (if (not quit-config)
3602 ;; Update the info -- marks might need to be removed,
3604 (gnus-summary-update-info)
3605 (set-buffer gnus-group-buffer)
3606 (gnus-group-jump-to-group group)
3607 (gnus-group-next-unread-group 1))
3608 (gnus-handle-ephemeral-exit quit-config)))
3609 (let ((grpinfo (gnus-get-info group)))
3610 (if (null (gnus-info-read grpinfo))
3611 (gnus-message 3 "Group %s contains no messages"
3612 (gnus-group-decoded-name group))
3613 (gnus-message 3 "Can't select group")))
3615 ;; The user did a `C-g' while prompting for number of articles,
3616 ;; so we exit this group.
3617 ((eq did-select 'quit)
3618 (and (eq major-mode 'gnus-summary-mode)
3619 (not (equal (current-buffer) kill-buffer))
3620 (kill-buffer (current-buffer)))
3622 (gnus-kill-or-deaden-summary kill-buffer))
3623 (if (not quit-config)
3625 (set-buffer gnus-group-buffer)
3626 (gnus-group-jump-to-group group)
3627 (gnus-group-next-unread-group 1)
3628 (gnus-configure-windows 'group 'force))
3629 (gnus-handle-ephemeral-exit quit-config))
3630 ;; Finally signal the quit.
3632 ;; The group was successfully selected.
3634 (gnus-set-global-variables)
3635 ;; Save the active value in effect when the group was entered.
3636 (setq gnus-newsgroup-active
3638 (gnus-active gnus-newsgroup-name)))
3639 ;; You can change the summary buffer in some way with this hook.
3640 (gnus-run-hooks 'gnus-select-group-hook)
3641 (when (memq 'summary (gnus-update-format-specifications
3642 nil 'summary 'summary-mode 'summary-dummy))
3643 ;; The format specification for the summary line was updated,
3644 ;; so we need to update the mark positions as well.
3645 (gnus-update-summary-mark-positions))
3646 ;; Do score processing.
3647 (when gnus-use-scoring
3648 (gnus-possibly-score-headers))
3649 ;; Check whether to fill in the gaps in the threads.
3650 (when gnus-build-sparse-threads
3651 (gnus-build-sparse-threads))
3652 ;; Find the initial limit.
3654 (let ((gnus-newsgroup-dormant nil))
3655 (gnus-summary-initial-limit show-all))
3656 (gnus-summary-initial-limit show-all))
3657 ;; Generate the summary buffer.
3659 (gnus-summary-prepare))
3660 (when gnus-use-trees
3661 (gnus-tree-open group)
3662 (setq gnus-summary-highlight-line-function
3663 'gnus-tree-highlight-article))
3664 ;; If the summary buffer is empty, but there are some low-scored
3665 ;; articles or some excluded dormants, we include these in the
3667 (when (and (zerop (buffer-size))
3669 (cond (gnus-newsgroup-dormant
3670 (gnus-summary-limit-include-dormant))
3671 ((and gnus-newsgroup-scored show-all)
3672 (gnus-summary-limit-include-expunged t))))
3673 ;; Function `gnus-apply-kill-file' must be called in this hook.
3674 (gnus-run-hooks 'gnus-apply-kill-hook)
3675 (if (and (zerop (buffer-size))
3678 ;; This newsgroup is empty.
3679 (gnus-summary-catchup-and-exit nil t)
3680 (gnus-message 6 "No unread news")
3682 (gnus-kill-or-deaden-summary kill-buffer))
3683 ;; Return nil from this function.
3685 ;; Hide conversation thread subtrees. We cannot do this in
3686 ;; gnus-summary-prepare-hook since kill processing may not
3687 ;; work with hidden articles.
3688 (gnus-summary-maybe-hide-threads)
3690 (gnus-kill-or-deaden-summary kill-buffer))
3691 (gnus-summary-auto-select-subject)
3692 ;; Show first unread article if requested.
3693 (if (and (not no-article)
3695 gnus-newsgroup-unreads
3696 gnus-auto-select-first)
3698 (gnus-configure-windows 'summary)
3699 (let ((art (gnus-summary-article-number)))
3700 (unless (and (not gnus-plugged)
3701 (or (memq art gnus-newsgroup-undownloaded)
3702 (memq art gnus-newsgroup-downloadable)))
3703 (gnus-summary-goto-article art))))
3704 ;; Don't select any articles.
3705 (gnus-summary-position-point)
3706 (gnus-configure-windows 'summary 'force)
3707 (gnus-set-mode-line 'summary))
3708 (when (and gnus-auto-center-group
3709 (get-buffer-window gnus-group-buffer t))
3710 ;; Gotta use windows, because recenter does weird stuff if
3711 ;; the current buffer ain't the displayed window.
3712 (let ((owin (selected-window)))
3713 (select-window (get-buffer-window gnus-group-buffer t))
3714 (when (gnus-group-goto-group group)
3716 (select-window owin)))
3717 ;; Mark this buffer as "prepared".
3718 (setq gnus-newsgroup-prepared t)
3719 (gnus-run-hooks 'gnus-summary-prepared-hook)
3720 (unless (gnus-ephemeral-group-p group)
3721 (gnus-group-update-group group))
3724 (defun gnus-summary-auto-select-subject ()
3725 "Select the subject line on initial group entry."
3726 (goto-char (point-min))
3728 ((eq gnus-auto-select-subject 'best)
3729 (gnus-summary-best-unread-subject))
3730 ((eq gnus-auto-select-subject 'unread)
3731 (gnus-summary-first-unread-subject))
3732 ((eq gnus-auto-select-subject 'unseen)
3733 (gnus-summary-first-unseen-subject))
3734 ((eq gnus-auto-select-subject 'unseen-or-unread)
3735 (gnus-summary-first-unseen-or-unread-subject))
3736 ((eq gnus-auto-select-subject 'first)
3739 ((functionp gnus-auto-select-subject)
3740 (funcall gnus-auto-select-subject))))
3742 (defun gnus-summary-prepare ()
3743 "Generate the summary buffer."
3745 (let ((buffer-read-only nil))
3747 (setq gnus-newsgroup-data nil
3748 gnus-newsgroup-data-reverse nil)
3749 (gnus-run-hooks 'gnus-summary-generate-hook)
3750 ;; Generate the buffer, either with threads or without.
3751 (when gnus-newsgroup-headers
3752 (gnus-summary-prepare-threads
3753 (if gnus-show-threads
3754 (gnus-sort-gathered-threads
3755 (funcall gnus-summary-thread-gathering-function
3757 (gnus-cut-threads (gnus-make-threads)))))
3758 ;; Unthreaded display.
3759 (gnus-sort-articles gnus-newsgroup-headers))))
3760 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3761 ;; Call hooks for modifying summary buffer.
3762 (goto-char (point-min))
3763 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3765 (defsubst gnus-general-simplify-subject (subject)
3766 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3769 ;; Truncate the subject.
3770 (gnus-simplify-subject-functions
3771 (gnus-map-function gnus-simplify-subject-functions subject))
3772 ((numberp gnus-summary-gather-subject-limit)
3773 (setq subject (gnus-simplify-subject-re subject))
3774 (if (> (length subject) gnus-summary-gather-subject-limit)
3775 (substring subject 0 gnus-summary-gather-subject-limit)
3777 ;; Fuzzily simplify it.
3778 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3779 (gnus-simplify-subject-fuzzy subject))
3780 ;; Just remove the leading "Re:".
3782 (gnus-simplify-subject-re subject))))
3784 (if (and gnus-summary-gather-exclude-subject
3785 (string-match gnus-summary-gather-exclude-subject subject))
3786 nil ; This article shouldn't be gathered
3789 (defun gnus-summary-simplify-subject-query ()
3790 "Query where the respool algorithm would put this article."
3792 (gnus-summary-select-article)
3793 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3795 (defun gnus-gather-threads-by-subject (threads)
3796 "Gather threads by looking at Subject headers."
3797 (if (not gnus-summary-make-false-root)
3799 (let ((hashtb (gnus-make-hashtable 1024))
3802 subject hthread whole-subject)
3804 (setq subject (gnus-general-simplify-subject
3805 (setq whole-subject (mail-header-subject
3808 (if (setq hthread (gnus-gethash subject hashtb))
3810 ;; We enter a dummy root into the thread, if we
3811 ;; haven't done that already.
3812 (unless (stringp (caar hthread))
3813 (setcar hthread (list whole-subject (car hthread))))
3814 ;; We add this new gathered thread to this gathered
3816 (setcdr (car hthread)
3817 (nconc (cdar hthread) (list (car threads))))
3818 ;; Remove it from the list of threads.
3819 (setcdr prev (cdr threads))
3820 (setq threads prev))
3821 ;; Enter this thread into the hash table.
3822 (gnus-sethash subject
3823 (if gnus-summary-make-false-root-always
3825 ;; If you want a dummy root above all
3827 (setcar threads (list whole-subject
3833 (setq threads (cdr threads)))
3836 (defun gnus-gather-threads-by-references (threads)
3837 "Gather threads by looking at References headers."
3838 (let ((idhashtb (gnus-make-hashtable 1024))
3839 (thhashtb (gnus-make-hashtable 1024))
3842 ids references id gthread gid entered ref)
3844 (when (setq references (mail-header-references (caar threads)))
3845 (setq id (mail-header-id (caar threads))
3846 ids (inline (gnus-split-references references))
3848 (while (setq ref (pop ids))
3849 (setq ids (delete ref ids))
3850 (if (not (setq gid (gnus-gethash ref idhashtb)))
3852 (gnus-sethash ref id idhashtb)
3853 (gnus-sethash id threads thhashtb))
3854 (setq gthread (gnus-gethash gid thhashtb))
3856 ;; We enter a dummy root into the thread, if we
3857 ;; haven't done that already.
3858 (unless (stringp (caar gthread))
3859 (setcar gthread (list (mail-header-subject (caar gthread))
3861 ;; We add this new gathered thread to this gathered
3863 (setcdr (car gthread)
3864 (nconc (cdar gthread) (list (car threads)))))
3865 ;; Add it into the thread hash table.
3866 (gnus-sethash id gthread thhashtb)
3868 ;; Remove it from the list of threads.
3869 (setcdr prev (cdr threads))
3870 (setq threads prev))))
3872 (setq threads (cdr threads)))
3875 (defun gnus-sort-gathered-threads (threads)
3876 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3877 (let ((result threads))
3879 (when (stringp (caar threads))
3880 (setcdr (car threads)
3881 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3882 (setq threads (cdr threads)))
3885 (defun gnus-thread-loop-p (root thread)
3886 "Say whether ROOT is in THREAD."
3887 (let ((stack (list thread))
3890 (while (setq thread (pop stack))
3891 (setq th (cdr thread))
3893 (not (eq (caar th) root)))
3896 ;; We have found a loop.
3898 (setcdr thread (delq (car th) (cdr thread)))
3899 (if (boundp (setq ref-dep (intern "none"
3900 gnus-newsgroup-dependencies)))
3901 (setcdr (symbol-value ref-dep)
3902 (nconc (cdr (symbol-value ref-dep))
3904 (set ref-dep (list nil (car th))))
3907 ;; Push all the subthreads onto the stack.
3908 (push (cdr thread) stack)))
3911 (defun gnus-make-threads ()
3912 "Go through the dependency hashtb and find the roots. Return all threads."
3914 (while (catch 'infloop
3917 ;; Deal with self-referencing References loops.
3918 (when (and (car (symbol-value refs))
3925 (car (symbol-value refs)) thread))
3926 (cdr (symbol-value refs)))))))
3929 (unless (car (symbol-value refs))
3930 ;; These threads do not refer back to any other
3931 ;; articles, so they're roots.
3932 (setq threads (append (cdr (symbol-value refs)) threads))))
3933 gnus-newsgroup-dependencies)))
3936 ;; Build the thread tree.
3937 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3938 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3940 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3941 if it was already present.
3943 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3944 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3945 Message-IDs will be renamed to a unique Message-ID before being
3948 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3949 (let* ((id (mail-header-id header))
3950 (id-dep (and id (intern id dependencies)))
3951 parent-id ref ref-dep ref-header replaced)
3952 ;; Enter this `header' in the `dependencies' table.
3956 ;; The first two cases do the normal part: enter a new `header'
3957 ;; in the `dependencies' table.
3958 ((not (boundp id-dep))
3959 (set id-dep (list header)))
3960 ((null (car (symbol-value id-dep)))
3961 (setcar (symbol-value id-dep) header))
3963 ;; From here the `header' was already present in the
3964 ;; `dependencies' table.
3966 ;; Overrides an existing entry;
3967 ;; just set the header part of the entry.
3968 (setcar (symbol-value id-dep) header)
3971 ;; Renames the existing `header' to a unique Message-ID.
3972 ((not gnus-summary-ignore-duplicates)
3973 ;; An article with this Message-ID has already been seen.
3974 ;; We rename the Message-ID.
3975 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3977 (mail-header-set-id header id))
3979 ;; The last case ignores an existing entry, except it adds any
3980 ;; additional Xrefs (in case the two articles came from different
3982 ;; Also sets `header' to `nil' meaning that the `dependencies'
3983 ;; table was *not* modified.
3985 (mail-header-set-xref
3986 (car (symbol-value id-dep))
3987 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3989 (or (mail-header-xref header) "")))
3992 (when (and header (not replaced))
3993 ;; First check that we are not creating a References loop.
3994 (setq parent-id (gnus-parent-id (mail-header-references header)))
3995 (setq ref parent-id)
3997 (setq ref-dep (intern-soft ref dependencies))
3999 (setq ref-header (car (symbol-value ref-dep))))
4000 (if (string= id ref)
4001 ;; Yuk! This is a reference loop. Make the article be a
4004 (mail-header-set-references (car (symbol-value id-dep)) "none")
4006 (setq parent-id nil))
4007 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4008 (setq ref-dep (intern (or parent-id "none") dependencies))
4009 (if (boundp ref-dep)
4010 (setcdr (symbol-value ref-dep)
4011 (nconc (cdr (symbol-value ref-dep))
4012 (list (symbol-value id-dep))))
4013 (set ref-dep (list nil (symbol-value id-dep)))))
4016 (defun gnus-extract-message-id-from-in-reply-to (string)
4017 (if (string-match "<[^>]+>" string)
4018 (substring string (match-beginning 0) (match-end 0))
4021 (defun gnus-build-sparse-threads ()
4022 (let ((headers gnus-newsgroup-headers)
4023 (mail-parse-charset gnus-newsgroup-charset)
4024 (gnus-summary-ignore-duplicates t)
4025 header references generation relations
4026 subject child end new-child date)
4027 ;; First we create an alist of generations/relations, where
4028 ;; generations is how much we trust the relation, and the relation
4030 (gnus-message 7 "Making sparse threads...")
4032 (nnheader-set-temp-buffer " *gnus sparse threads*")
4033 (while (setq header (pop headers))
4034 (when (and (setq references (mail-header-references header))
4035 (not (string= references "")))
4037 (setq child (mail-header-id header)
4038 subject (mail-header-subject header)
4039 date (mail-header-date header)
4041 (while (search-backward ">" nil t)
4042 (setq end (1+ (point)))
4043 (when (search-backward "<" nil t)
4044 (setq new-child (buffer-substring (point) end))
4045 (push (list (incf generation)
4046 child (setq child new-child)
4050 (push (list (1+ generation) child nil subject) relations))
4052 (kill-buffer (current-buffer)))
4053 ;; Sort over trustworthiness.
4056 (when (gnus-dependencies-add-header
4057 (make-full-mail-header
4058 gnus-reffed-article-number
4059 (nth 3 relation) "" (or (nth 4 relation) "")
4061 (or (nth 2 relation) "") 0 0 "")
4062 gnus-newsgroup-dependencies nil)
4063 (push gnus-reffed-article-number gnus-newsgroup-limit)
4064 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4065 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4066 gnus-newsgroup-reads)
4067 (decf gnus-reffed-article-number)))
4068 (sort relations 'car-less-than-car))
4069 (gnus-message 7 "Making sparse threads...done")))
4071 (defun gnus-build-old-threads ()
4072 ;; Look at all the articles that refer back to old articles, and
4073 ;; fetch the headers for the articles that aren't there. This will
4074 ;; build complete threads - if the roots haven't been expired by the
4076 (let ((mail-parse-charset gnus-newsgroup-charset)
4080 (when (not (car (symbol-value refs)))
4081 (setq heads (cdr (symbol-value refs)))
4083 (if (memq (mail-header-number (caar heads))
4084 gnus-newsgroup-dormant)
4085 (setq heads (cdr heads))
4086 (setq id (symbol-name refs))
4087 (while (and (setq id (gnus-build-get-header id))
4088 (not (car (gnus-id-to-thread id)))))
4089 (setq heads nil)))))
4090 gnus-newsgroup-dependencies)))
4092 (defsubst gnus-remove-odd-characters (string)
4093 "Translate STRING into something that doesn't contain weird characters."
4094 (mm-subst-char-in-string
4096 (mm-subst-char-in-string ?\n ?\- string t) t))
4098 ;; This function has to be called with point after the article number
4099 ;; on the beginning of the line.
4100 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4101 (let ((eol (point-at-eol))
4102 (buffer (current-buffer))
4103 header references in-reply-to)
4105 ;; overview: [num subject from date id refs chars lines misc]
4108 (narrow-to-region (point) eol)
4113 (make-full-mail-header
4115 (condition-case () ; subject
4116 (gnus-remove-odd-characters
4117 (funcall gnus-decode-encoded-word-function
4118 (setq x (nnheader-nov-field))))
4120 (condition-case () ; from
4121 (gnus-remove-odd-characters
4122 (funcall gnus-decode-encoded-word-function
4123 (setq x (nnheader-nov-field))))
4125 (nnheader-nov-field) ; date
4126 (nnheader-nov-read-message-id number) ; id
4127 (setq references (nnheader-nov-field)) ; refs
4128 (nnheader-nov-read-integer) ; chars
4129 (nnheader-nov-read-integer) ; lines
4131 (if (looking-at "Xref: ")
4132 (goto-char (match-end 0)))
4133 (nnheader-nov-field)) ; Xref
4134 (nnheader-nov-parse-extra)))) ; extra
4138 (when (and (string= references "")
4139 (setq in-reply-to (mail-header-extra header))
4140 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4141 (mail-header-set-references
4142 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4144 (when gnus-alter-header-function
4145 (funcall gnus-alter-header-function header))
4146 (gnus-dependencies-add-header header dependencies force-new)))
4148 (defun gnus-build-get-header (id)
4149 "Look through the buffer of NOV lines and find the header to ID.
4150 Enter this line into the dependencies hash table, and return
4151 the id of the parent article (if any)."
4152 (let ((deps gnus-newsgroup-dependencies)
4156 (set-buffer nntp-server-buffer)
4157 (let ((case-fold-search nil))
4158 (goto-char (point-min))
4159 (while (and (not found)
4160 (search-forward id nil t))
4162 (setq found (looking-at
4163 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4164 (regexp-quote id))))
4165 (or found (beginning-of-line 2)))
4169 (setq header (gnus-nov-parse-line
4170 (read (current-buffer)) deps))
4171 (gnus-parent-id (mail-header-references header))))))
4173 (let ((number (mail-header-number header)))
4174 (push number gnus-newsgroup-limit)
4175 (push header gnus-newsgroup-headers)
4176 (if (memq number gnus-newsgroup-unselected)
4178 (setq gnus-newsgroup-unreads
4179 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4181 (setq gnus-newsgroup-unselected
4182 (delq number gnus-newsgroup-unselected)))
4183 (push number gnus-newsgroup-ancient)))))))
4185 (defun gnus-build-all-threads ()
4186 "Read all the headers."
4187 (let ((gnus-summary-ignore-duplicates t)
4188 (mail-parse-charset gnus-newsgroup-charset)
4189 (dependencies gnus-newsgroup-dependencies)
4192 (set-buffer nntp-server-buffer)
4193 (let ((case-fold-search nil))
4194 (goto-char (point-min))
4197 (setq article (read (current-buffer))
4198 header (gnus-nov-parse-line article dependencies)))
4200 (with-current-buffer gnus-summary-buffer
4201 (push header gnus-newsgroup-headers)
4202 (if (memq (setq article (mail-header-number header))
4203 gnus-newsgroup-unselected)
4205 (setq gnus-newsgroup-unreads
4206 (gnus-add-to-sorted-list
4207 gnus-newsgroup-unreads article))
4208 (setq gnus-newsgroup-unselected
4209 (delq article gnus-newsgroup-unselected)))
4210 (push article gnus-newsgroup-ancient)))
4211 (forward-line 1)))))))
4213 (defun gnus-summary-update-article-line (article header)
4214 "Update the line for ARTICLE using HEADER."
4215 (let* ((id (mail-header-id header))
4216 (thread (gnus-id-to-thread id)))
4218 (error "Article in no thread"))
4219 ;; Update the thread.
4220 (setcar thread header)
4221 (gnus-summary-goto-subject article)
4222 (let* ((datal (gnus-data-find-list article))
4224 (buffer-read-only nil)
4225 (level (gnus-summary-thread-level)))
4227 (let ((inserted (- (point)
4229 (gnus-summary-insert-line
4231 (memq article gnus-newsgroup-undownloaded)
4232 (gnus-article-mark article)
4233 (memq article gnus-newsgroup-replied)
4234 (memq article gnus-newsgroup-expirable)
4235 ;; Only insert the Subject string when it's different
4236 ;; from the previous Subject string.
4241 (mail-header-subject
4244 (gnus-data-find-list
4246 (gnus-data-list t)))))
4247 ;; Error on the side of excessive subjects.
4249 (mail-header-subject header)))
4251 (mail-header-subject header))
4252 nil (cdr (assq article gnus-newsgroup-scored))
4253 (memq article gnus-newsgroup-processable))
4256 (gnus-data-update-list
4258 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4260 (defun gnus-summary-update-article (article &optional iheader)
4261 "Update ARTICLE in the summary buffer."
4262 (set-buffer gnus-summary-buffer)
4263 (let* ((header (gnus-summary-article-header article))
4264 (id (mail-header-id header))
4265 (data (gnus-data-find article))
4266 (thread (gnus-id-to-thread id))
4267 (references (mail-header-references header))
4271 (when (and references
4272 (not (equal "" references)))
4275 (buffer-read-only nil)
4281 (delq thread parent)))
4282 (if (gnus-summary-insert-subject id header)
4283 ;; Set the (possibly) new article number in the data structure.
4284 (gnus-data-set-number data (gnus-id-to-article id))
4288 (defun gnus-rebuild-thread (id &optional line)
4289 "Rebuild the thread containing ID.
4290 If LINE, insert the rebuilt thread starting on line LINE."
4291 (let ((buffer-read-only nil)
4292 old-pos current thread data)
4293 (if (not gnus-show-threads)
4294 (setq thread (list (car (gnus-id-to-thread id))))
4295 ;; Get the thread this article is part of.
4296 (setq thread (gnus-remove-thread id)))
4297 (setq old-pos (point-at-bol))
4298 (setq current (save-excursion
4299 (and (re-search-backward "[\r\n]" nil t)
4300 (gnus-summary-article-number))))
4301 ;; If this is a gathered thread, we have to go some re-gathering.
4302 (when (stringp (car thread))
4303 (let ((subject (car thread))
4305 (setq thread (cdr thread))
4307 (unless (memq (setq thr (gnus-id-to-thread
4309 (mail-header-id (caar thread)))))
4312 (setq thread (cdr thread)))
4313 ;; We now have all (unique) roots.
4314 (if (= (length roots) 1)
4315 ;; All the loose roots are now one solid root.
4316 (setq thread (car roots))
4317 (setq thread (cons subject (gnus-sort-threads roots))))))
4319 ;; We then insert this thread into the summary buffer.
4321 (goto-char (point-min))
4322 (forward-line (1- line)))
4323 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4324 (if gnus-show-threads
4325 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4326 (gnus-summary-prepare-unthreaded thread))
4327 (setq data (nreverse gnus-newsgroup-data))
4328 (setq threads gnus-newsgroup-threads))
4329 ;; We splice the new data into the data structure.
4330 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4331 ;;!!! then we want to insert at the beginning of the buffer.
4332 ;;!!! That happens to be true with Gnus now, but that may
4333 ;;!!! change in the future. Perhaps.
4334 (gnus-data-enter-list
4335 (if line nil current) data (- (point) old-pos))
4336 (setq gnus-newsgroup-threads
4337 (nconc threads gnus-newsgroup-threads))
4338 (gnus-data-compute-positions))))
4340 (defun gnus-number-to-header (number)
4341 "Return the header for article NUMBER."
4342 (let ((headers gnus-newsgroup-headers))
4344 (not (= number (mail-header-number (car headers)))))
4349 (defun gnus-parent-headers (in-headers &optional generation)
4350 "Return the headers of the GENERATIONeth parent of HEADERS."
4352 (setq generation 1))
4354 (headers in-headers)
4357 (not (zerop generation))
4358 (setq references (mail-header-references headers)))
4359 (setq headers (if (and references
4360 (setq parent (gnus-parent-id references)))
4361 (car (gnus-id-to-thread parent))
4364 (and (not (eq headers in-headers))
4367 (defun gnus-id-to-thread (id)
4368 "Return the (sub-)thread where ID appears."
4369 (gnus-gethash id gnus-newsgroup-dependencies))
4371 (defun gnus-id-to-article (id)
4372 "Return the article number of ID."
4373 (let ((thread (gnus-id-to-thread id)))
4376 (mail-header-number (car thread)))))
4378 (defun gnus-id-to-header (id)
4379 "Return the article headers of ID."
4380 (car (gnus-id-to-thread id)))
4382 (defun gnus-article-displayed-root-p (article)
4383 "Say whether ARTICLE is a root(ish) article."
4384 (let ((level (gnus-summary-thread-level article))
4385 (refs (mail-header-references (gnus-summary-article-header article)))
4391 ((null (gnus-parent-id refs)) t)
4393 (null (setq particle (gnus-id-to-article
4394 (gnus-parent-id refs))))
4395 (null (gnus-summary-thread-level particle)))))))
4397 (defun gnus-root-id (id)
4398 "Return the id of the root of the thread where ID appears."
4400 (while (and id (setq prev (car (gnus-id-to-thread id))))
4402 id (gnus-parent-id (mail-header-references prev))))
4405 (defun gnus-articles-in-thread (thread)
4406 "Return the list of articles in THREAD."
4407 (cons (mail-header-number (car thread))
4408 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4410 (defun gnus-remove-thread (id &optional dont-remove)
4411 "Remove the thread that has ID in it."
4412 (let (headers thread last-id)
4413 ;; First go up in this thread until we find the root.
4414 (setq last-id (gnus-root-id id)
4415 headers (message-flatten-list (gnus-id-to-thread last-id)))
4416 ;; We have now found the real root of this thread. It might have
4417 ;; been gathered into some loose thread, so we have to search
4418 ;; through the threads to find the thread we wanted.
4419 (let ((threads gnus-newsgroup-threads)
4422 (setq sub (car threads))
4423 (if (stringp (car sub))
4424 ;; This is a gathered thread, so we look at the roots
4425 ;; below it to find whether this article is in this
4428 (setq sub (cdr sub))
4430 (when (member (caar sub) headers)
4431 (setq thread (car threads)
4434 (setq sub (cdr sub))))
4435 ;; It's an ordinary thread, so we check it.
4436 (when (eq (car sub) (car headers))
4439 (setq threads (cdr threads)))
4440 ;; If this article is in no thread, then it's a root.
4443 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4444 (setq thread (gnus-id-to-thread last-id)))
4447 thread ; We return this thread.
4449 (if (stringp (car thread))
4451 ;; If we use dummy roots, then we have to remove the
4452 ;; dummy root as well.
4453 (when (eq gnus-summary-make-false-root 'dummy)
4454 ;; We go to the dummy root by going to
4455 ;; the first sub-"thread", and then one line up.
4456 (gnus-summary-goto-article
4457 (mail-header-number (caadr thread)))
4460 (gnus-data-compute-positions))
4461 (setq thread (cdr thread))
4463 (gnus-remove-thread-1 (car thread))
4464 (setq thread (cdr thread))))
4465 (gnus-remove-thread-1 thread))))))))
4467 (defun gnus-remove-thread-1 (thread)
4468 "Remove the thread THREAD recursively."
4469 (let ((number (mail-header-number (pop thread)))
4471 (setq thread (reverse thread))
4473 (gnus-remove-thread-1 (pop thread)))
4474 (when (setq d (gnus-data-find number))
4475 (goto-char (gnus-data-pos d))
4476 (gnus-summary-show-thread)
4482 (gnus-delete-line)))))))
4484 (defun gnus-sort-threads-1 (threads func)
4485 (sort (mapcar (lambda (thread)
4488 (gnus-sort-threads-1 (cdr thread) func))))
4491 (defun gnus-sort-threads (threads)
4493 (if (not gnus-thread-sort-functions)
4495 (gnus-message 8 "Sorting threads...")
4496 (let ((max-lisp-eval-depth 5000))
4497 (prog1 (gnus-sort-threads-1
4499 (gnus-make-sort-function gnus-thread-sort-functions))
4500 (gnus-message 8 "Sorting threads...done")))))
4502 (defun gnus-sort-articles (articles)
4504 (when gnus-article-sort-functions
4505 (gnus-message 7 "Sorting articles...")
4507 (setq gnus-newsgroup-headers
4508 (sort articles (gnus-make-sort-function
4509 gnus-article-sort-functions)))
4510 (gnus-message 7 "Sorting articles...done"))))
4512 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4513 (defmacro gnus-thread-header (thread)
4514 "Return header of first article in THREAD.
4515 Note that THREAD must never, ever be anything else than a variable -
4516 using some other form will lead to serious barfage."
4517 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4518 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4519 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4522 (defsubst gnus-article-sort-by-number (h1 h2)
4523 "Sort articles by article number."
4524 (< (mail-header-number h1)
4525 (mail-header-number h2)))
4527 (defun gnus-thread-sort-by-number (h1 h2)
4528 "Sort threads by root article number."
4529 (gnus-article-sort-by-number
4530 (gnus-thread-header h1) (gnus-thread-header h2)))
4532 (defsubst gnus-article-sort-by-random (h1 h2)
4533 "Sort articles by article number."
4536 (defun gnus-thread-sort-by-random (h1 h2)
4537 "Sort threads by root article number."
4538 (gnus-article-sort-by-random
4539 (gnus-thread-header h1) (gnus-thread-header h2)))
4541 (defsubst gnus-article-sort-by-lines (h1 h2)
4542 "Sort articles by article Lines header."
4543 (< (mail-header-lines h1)
4544 (mail-header-lines h2)))
4546 (defun gnus-thread-sort-by-lines (h1 h2)
4547 "Sort threads by root article Lines header."
4548 (gnus-article-sort-by-lines
4549 (gnus-thread-header h1) (gnus-thread-header h2)))
4551 (defsubst gnus-article-sort-by-chars (h1 h2)
4552 "Sort articles by octet length."
4553 (< (mail-header-chars h1)
4554 (mail-header-chars h2)))
4556 (defun gnus-thread-sort-by-chars (h1 h2)
4557 "Sort threads by root article octet length."
4558 (gnus-article-sort-by-chars
4559 (gnus-thread-header h1) (gnus-thread-header h2)))
4561 (defsubst gnus-article-sort-by-author (h1 h2)
4562 "Sort articles by root author."
4564 (let ((extract (funcall
4565 gnus-extract-address-components
4566 (mail-header-from h1))))
4567 (or (car extract) (cadr extract) ""))
4568 (let ((extract (funcall
4569 gnus-extract-address-components
4570 (mail-header-from h2))))
4571 (or (car extract) (cadr extract) ""))))
4573 (defun gnus-thread-sort-by-author (h1 h2)
4574 "Sort threads by root author."
4575 (gnus-article-sort-by-author
4576 (gnus-thread-header h1) (gnus-thread-header h2)))
4578 (defsubst gnus-article-sort-by-recipient (h1 h2)
4579 "Sort articles by recipient."
4581 (let ((extract (funcall
4582 gnus-extract-address-components
4583 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4584 (or (car extract) (cadr extract)))
4585 (let ((extract (funcall
4586 gnus-extract-address-components
4587 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4588 (or (car extract) (cadr extract)))))
4590 (defsubst gnus-article-sort-by-subject (h1 h2)
4591 "Sort articles by root subject."
4593 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4594 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4596 (defun gnus-thread-sort-by-subject (h1 h2)
4597 "Sort threads by root subject."
4598 (gnus-article-sort-by-subject
4599 (gnus-thread-header h1) (gnus-thread-header h2)))
4601 (defsubst gnus-article-sort-by-date (h1 h2)
4602 "Sort articles by root article date."
4604 (gnus-date-get-time (mail-header-date h1))
4605 (gnus-date-get-time (mail-header-date h2))))
4607 (defun gnus-thread-sort-by-date (h1 h2)
4608 "Sort threads by root article date."
4609 (gnus-article-sort-by-date
4610 (gnus-thread-header h1) (gnus-thread-header h2)))
4612 (defsubst gnus-article-sort-by-score (h1 h2)
4613 "Sort articles by root article score.
4614 Unscored articles will be counted as having a score of zero."
4615 (> (or (cdr (assq (mail-header-number h1)
4616 gnus-newsgroup-scored))
4617 gnus-summary-default-score 0)
4618 (or (cdr (assq (mail-header-number h2)
4619 gnus-newsgroup-scored))
4620 gnus-summary-default-score 0)))
4622 (defun gnus-thread-sort-by-score (h1 h2)
4623 "Sort threads by root article score."
4624 (gnus-article-sort-by-score
4625 (gnus-thread-header h1) (gnus-thread-header h2)))
4627 (defun gnus-thread-sort-by-total-score (h1 h2)
4628 "Sort threads by the sum of all scores in the thread.
4629 Unscored articles will be counted as having a score of zero."
4630 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4632 (defun gnus-thread-total-score (thread)
4633 ;; This function find the total score of THREAD.
4638 (if (stringp (car thread))
4639 (apply gnus-thread-score-function 0
4640 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4641 (gnus-thread-total-score-1 thread)))
4643 (gnus-thread-total-score-1 (list thread)))))
4645 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4646 "Sort threads such that the thread with the most recently arrived article comes first."
4647 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4649 (defun gnus-thread-highest-number (thread)
4650 "Return the highest article number in THREAD."
4651 (apply 'max (mapcar (lambda (header)
4652 (mail-header-number header))
4653 (message-flatten-list thread))))
4655 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4656 "Sort threads such that the thread with the most recently dated article comes first."
4657 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4659 (defun gnus-thread-latest-date (thread)
4660 "Return the highest article date in THREAD."
4661 (let ((previous-time 0))
4667 (time-to-seconds (mail-header-parse-date
4668 (mail-header-date header)))
4669 (error previous-time))))
4671 (message-flatten-list thread)
4673 (< (mail-header-number h1)
4674 (mail-header-number h2))))))))
4676 (defun gnus-thread-total-score-1 (root)
4677 ;; This function find the total score of the thread below ROOT.
4678 (setq root (car root))
4679 (apply gnus-thread-score-function
4681 (mapcar 'gnus-thread-total-score
4682 (cdr (gnus-id-to-thread (mail-header-id root))))
4683 (when (> (mail-header-number root) 0)
4684 (list (or (cdr (assq (mail-header-number root)
4685 gnus-newsgroup-scored))
4686 gnus-summary-default-score 0))))
4687 (list gnus-summary-default-score)
4690 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4691 (defvar gnus-tmp-prev-subject nil)
4692 (defvar gnus-tmp-false-parent nil)
4693 (defvar gnus-tmp-root-expunged nil)
4694 (defvar gnus-tmp-dummy-line nil)
4696 (eval-when-compile (defvar gnus-tmp-header))
4697 (defun gnus-extra-header (type &optional header)
4698 "Return the extra header of TYPE."
4699 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4702 (defvar gnus-tmp-thread-tree-header-string "")
4704 (defcustom gnus-sum-thread-tree-root "> "
4705 "With %B spec, used for the root of a thread.
4706 If nil, use subject instead."
4708 :type '(radio (const :format "%v " nil) string)
4709 :group 'gnus-thread)
4710 (defcustom gnus-sum-thread-tree-false-root "> "
4711 "With %B spec, used for a false root of a thread.
4712 If nil, use subject instead."
4714 :type '(radio (const :format "%v " nil) string)
4715 :group 'gnus-thread)
4716 (defcustom gnus-sum-thread-tree-single-indent ""
4717 "With %B spec, used for a thread with just one message.
4718 If nil, use subject instead."
4720 :type '(radio (const :format "%v " nil) string)
4721 :group 'gnus-thread)
4722 (defcustom gnus-sum-thread-tree-vertical "| "
4723 "With %B spec, used for drawing a vertical line."
4726 :group 'gnus-thread)
4727 (defcustom gnus-sum-thread-tree-indent " "
4728 "With %B spec, used for indenting."
4731 :group 'gnus-thread)
4732 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4733 "With %B spec, used for a leaf with brothers."
4736 :group 'gnus-thread)
4737 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4738 "With %B spec, used for a leaf without brothers."
4741 :group 'gnus-thread)
4743 (defun gnus-summary-prepare-threads (threads)
4744 "Prepare summary buffer from THREADS and indentation LEVEL.
4745 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4746 or a straight list of headers."
4747 (gnus-message 7 "Generating summary...")
4749 (setq gnus-newsgroup-threads threads)
4752 (let ((gnus-tmp-level 0)
4753 (default-score (or gnus-summary-default-score 0))
4754 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4755 (building-line-count gnus-summary-display-while-building)
4756 (building-count (integerp gnus-summary-display-while-building))
4757 thread number subject stack state gnus-tmp-gathered beg-match
4758 new-roots gnus-tmp-new-adopts thread-end simp-subject
4759 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4760 gnus-tmp-replied gnus-tmp-subject-or-nil
4761 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4762 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4763 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4766 (setq gnus-tmp-prev-subject nil
4767 gnus-tmp-thread-tree-header-string "")
4769 (if (vectorp (car threads))
4770 ;; If this is a straight (sic) list of headers, then a
4771 ;; threaded summary display isn't required, so we just create
4772 ;; an unthreaded one.
4773 (gnus-summary-prepare-unthreaded threads)
4775 ;; Do the threaded display.
4777 (if gnus-summary-display-while-building
4778 (switch-to-buffer (buffer-name)))
4779 (while (or threads stack gnus-tmp-new-adopts new-roots)
4781 (if (and (= gnus-tmp-level 0)
4784 (not gnus-tmp-false-parent)
4785 (or gnus-tmp-new-adopts new-roots))
4786 (if gnus-tmp-new-adopts
4787 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4788 thread (list (car gnus-tmp-new-adopts))
4789 gnus-tmp-header (caar thread)
4790 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4792 (setq thread (list (car new-roots))
4793 gnus-tmp-header (caar thread)
4794 new-roots (cdr new-roots))))
4797 ;; If there are some threads, we do them before the
4798 ;; threads on the stack.
4799 (setq thread threads
4800 gnus-tmp-header (caar thread))
4801 ;; There were no current threads, so we pop something off
4803 (setq state (car stack)
4804 gnus-tmp-level (car state)
4805 tree-stack (cadr state)
4806 thread (caddr state)
4808 gnus-tmp-header (caar thread))))
4810 (setq gnus-tmp-false-parent nil)
4811 (setq gnus-tmp-root-expunged nil)
4812 (setq thread-end nil)
4814 (if (stringp gnus-tmp-header)
4815 ;; The header is a dummy root.
4817 ((eq gnus-summary-make-false-root 'adopt)
4818 ;; We let the first article adopt the rest.
4819 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4821 (setq gnus-tmp-gathered
4823 (lambda (h) (mail-header-number (car h)))
4826 (setq thread (cons (list (caar thread)
4829 (setq gnus-tmp-level -1
4830 gnus-tmp-false-parent t))
4831 ((eq gnus-summary-make-false-root 'empty)
4832 ;; We print adopted articles with empty subject fields.
4833 (setq gnus-tmp-gathered
4835 (lambda (h) (mail-header-number (car h)))
4838 (setq gnus-tmp-level -1))
4839 ((eq gnus-summary-make-false-root 'dummy)
4840 ;; We remember that we probably want to output a dummy
4842 (setq gnus-tmp-dummy-line gnus-tmp-header)
4843 (setq gnus-tmp-prev-subject gnus-tmp-header))
4845 ;; We do not make a root for the gathered
4846 ;; sub-threads at all.
4847 (setq gnus-tmp-level -1)))
4849 (setq number (mail-header-number gnus-tmp-header)
4850 subject (mail-header-subject gnus-tmp-header)
4851 simp-subject (gnus-simplify-subject-fully subject))
4854 ;; If the thread has changed subject, we might want to make
4855 ;; this subthread into a root.
4856 ((and (null gnus-thread-ignore-subject)
4857 (not (zerop gnus-tmp-level))
4858 gnus-tmp-prev-subject
4859 (not (string= gnus-tmp-prev-subject simp-subject)))
4860 (setq new-roots (nconc new-roots (list (car thread)))
4862 gnus-tmp-header nil))
4863 ;; If the article lies outside the current limit,
4864 ;; then we do not display it.
4865 ((not (memq number gnus-newsgroup-limit))
4866 (setq gnus-tmp-gathered
4868 (lambda (h) (mail-header-number (car h)))
4871 (setq gnus-tmp-new-adopts (if (cdar thread)
4872 (append gnus-tmp-new-adopts
4874 gnus-tmp-new-adopts)
4876 gnus-tmp-header nil)
4877 (when (zerop gnus-tmp-level)
4878 (setq gnus-tmp-root-expunged t)))
4879 ;; Perhaps this article is to be marked as read?
4880 ((and gnus-summary-mark-below
4881 (< (or (cdr (assq number gnus-newsgroup-scored))
4883 gnus-summary-mark-below)
4884 ;; Don't touch sparse articles.
4885 (not (gnus-summary-article-sparse-p number))
4886 (not (gnus-summary-article-ancient-p number)))
4887 (setq gnus-newsgroup-unreads
4888 (delq number gnus-newsgroup-unreads))
4889 (if gnus-newsgroup-auto-expire
4890 (setq gnus-newsgroup-expirable
4891 (gnus-add-to-sorted-list
4892 gnus-newsgroup-expirable number))
4893 (push (cons number gnus-low-score-mark)
4894 gnus-newsgroup-reads))))
4896 (when gnus-tmp-header
4897 ;; We may have an old dummy line to output before this
4899 (when (and gnus-tmp-dummy-line
4902 (mail-header-subject gnus-tmp-header)))
4903 (gnus-summary-insert-dummy-line
4904 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4905 (setq gnus-tmp-dummy-line nil))
4907 ;; Compute the mark.
4908 (setq gnus-tmp-unread (gnus-article-mark number))
4910 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4911 gnus-tmp-header gnus-tmp-level)
4912 gnus-newsgroup-data)
4914 ;; Actually insert the line.
4916 gnus-tmp-subject-or-nil
4918 ((and gnus-thread-ignore-subject
4919 gnus-tmp-prev-subject
4920 (not (string= gnus-tmp-prev-subject simp-subject)))
4922 ((zerop gnus-tmp-level)
4923 (if (and (eq gnus-summary-make-false-root 'empty)
4924 (memq number gnus-tmp-gathered)
4925 gnus-tmp-prev-subject
4926 (string= gnus-tmp-prev-subject simp-subject))
4927 gnus-summary-same-subject
4929 (t gnus-summary-same-subject)))
4930 (if (and (eq gnus-summary-make-false-root 'adopt)
4931 (= gnus-tmp-level 1)
4932 (memq number gnus-tmp-gathered))
4933 (setq gnus-tmp-opening-bracket ?\<
4934 gnus-tmp-closing-bracket ?\>)
4935 (setq gnus-tmp-opening-bracket ?\[
4936 gnus-tmp-closing-bracket ?\]))
4938 gnus-tmp-indentation
4939 (aref gnus-thread-indent-array gnus-tmp-level)
4940 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4941 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4942 gnus-summary-default-score 0)
4944 (if (or (null gnus-summary-default-score)
4945 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4946 gnus-summary-zcore-fuzz))
4948 (if (< gnus-tmp-score gnus-summary-default-score)
4949 gnus-score-below-mark gnus-score-over-mark))
4951 (cond ((memq number gnus-newsgroup-processable)
4953 ((memq number gnus-newsgroup-cached)
4955 ((memq number gnus-newsgroup-replied)
4957 ((memq number gnus-newsgroup-forwarded)
4958 gnus-forwarded-mark)
4959 ((memq number gnus-newsgroup-saved)
4961 ((memq number gnus-newsgroup-recent)
4963 ((memq number gnus-newsgroup-unseen)
4967 (cond ((memq number gnus-newsgroup-undownloaded)
4968 gnus-undownloaded-mark)
4969 (gnus-newsgroup-agentized
4970 gnus-downloaded-mark)
4973 gnus-tmp-from (mail-header-from gnus-tmp-header)
4976 ((string-match "<[^>]+> *$" gnus-tmp-from)
4977 (setq beg-match (match-beginning 0))
4978 (or (and (string-match "^\".+\"" gnus-tmp-from)
4979 (substring gnus-tmp-from 1 (1- (match-end 0))))
4980 (substring gnus-tmp-from 0 beg-match)))
4981 ((string-match "(.+)" gnus-tmp-from)
4982 (substring gnus-tmp-from
4983 (1+ (match-beginning 0)) (1- (match-end 0))))
4987 gnus-tmp-thread-tree-header-string
4989 ((not gnus-show-threads) "")
4990 ((zerop gnus-tmp-level)
4991 (cond ((cdar thread)
4992 (or gnus-sum-thread-tree-root subject))
4993 (gnus-tmp-new-adopts
4994 (or gnus-sum-thread-tree-false-root subject))
4996 (or gnus-sum-thread-tree-single-indent subject))))
4998 (concat (apply 'concat
4999 (mapcar (lambda (item)
5001 gnus-sum-thread-tree-vertical
5002 gnus-sum-thread-tree-indent))
5003 (cdr (reverse tree-stack))))
5005 gnus-sum-thread-tree-leaf-with-other
5006 gnus-sum-thread-tree-single-leaf)))))
5007 (when (string= gnus-tmp-name "")
5008 (setq gnus-tmp-name gnus-tmp-from))
5009 (unless (numberp gnus-tmp-lines)
5010 (setq gnus-tmp-lines -1))
5011 (if (= gnus-tmp-lines -1)
5012 (setq gnus-tmp-lines "?")
5013 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5014 (gnus-put-text-property
5016 (progn (eval gnus-summary-line-format-spec) (point))
5017 'gnus-number number)
5020 (gnus-run-hooks 'gnus-summary-update-hook)
5023 (setq gnus-tmp-prev-subject simp-subject)))
5025 (when (nth 1 thread)
5026 (push (list (max 0 gnus-tmp-level)
5027 (copy-sequence tree-stack)
5030 (push (if (nth 1 thread) 1 0) tree-stack)
5031 (incf gnus-tmp-level)
5032 (setq threads (if thread-end nil (cdar thread)))
5033 (if gnus-summary-display-while-building
5036 ;; use a set frequency
5037 (setq building-line-count (1- building-line-count))
5038 (when (= building-line-count 0)
5040 (setq building-line-count
5041 gnus-summary-display-while-building)))
5045 (setq gnus-tmp-level 0)))))
5046 (gnus-message 7 "Generating summary...done"))
5048 (defun gnus-summary-prepare-unthreaded (headers)
5049 "Generate an unthreaded summary buffer based on HEADERS."
5050 (let (header number mark)
5055 ;; We may have to root out some bad articles...
5056 (when (memq (setq number (mail-header-number
5057 (setq header (pop headers))))
5058 gnus-newsgroup-limit)
5059 ;; Mark article as read when it has a low score.
5060 (when (and gnus-summary-mark-below
5061 (< (or (cdr (assq number gnus-newsgroup-scored))
5062 gnus-summary-default-score 0)
5063 gnus-summary-mark-below)
5064 (not (gnus-summary-article-ancient-p number)))
5065 (setq gnus-newsgroup-unreads
5066 (delq number gnus-newsgroup-unreads))
5067 (if gnus-newsgroup-auto-expire
5068 (push number gnus-newsgroup-expirable)
5069 (push (cons number gnus-low-score-mark)
5070 gnus-newsgroup-reads)))
5072 (setq mark (gnus-article-mark number))
5073 (push (gnus-data-make number mark (1+ (point)) header 0)
5074 gnus-newsgroup-data)
5075 (gnus-summary-insert-line
5077 (memq number gnus-newsgroup-undownloaded)
5078 mark (memq number gnus-newsgroup-replied)
5079 (memq number gnus-newsgroup-expirable)
5080 (mail-header-subject header) nil
5081 (cdr (assq number gnus-newsgroup-scored))
5082 (memq number gnus-newsgroup-processable))))))
5084 (defun gnus-summary-remove-list-identifiers ()
5085 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5086 (let ((regexp (if (consp gnus-list-identifiers)
5087 (mapconcat 'identity gnus-list-identifiers " *\\|")
5088 gnus-list-identifiers))
5091 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5092 (dolist (header gnus-newsgroup-headers)
5093 (setq subject (mail-header-subject header)
5095 (while (string-match regexp subject)
5097 (concat (substring subject 0 (match-beginning 1))
5098 (substring subject (match-end 0)))
5101 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5103 (concat (substring subject 0 (match-beginning 1))
5104 (substring subject (match-end 1)))))
5105 (mail-header-set-subject header subject))))))
5107 (defun gnus-fetch-headers (articles)
5108 "Fetch headers of ARTICLES."
5109 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5110 (gnus-message 5 "Fetching headers for %s..." name)
5113 (setq gnus-headers-retrieved-by
5114 (gnus-retrieve-headers
5115 articles gnus-newsgroup-name
5116 ;; We might want to fetch old headers, but
5117 ;; not if there is only 1 article.
5119 (not (eq gnus-fetch-old-headers 'some))
5120 (not (numberp gnus-fetch-old-headers)))
5121 (> (length articles) 1))
5122 gnus-fetch-old-headers))))
5123 (gnus-get-newsgroup-headers-xover
5124 articles nil nil gnus-newsgroup-name t)
5125 (gnus-get-newsgroup-headers))
5126 (gnus-message 5 "Fetching headers for %s...done" name))))
5128 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5129 "Select newsgroup GROUP.
5130 If READ-ALL is non-nil, all articles in the group are selected.
5131 If SELECT-ARTICLES, only select those articles from GROUP."
5132 (let* ((entry (gnus-group-entry group))
5133 ;;!!! Dirty hack; should be removed.
5134 (gnus-summary-ignore-duplicates
5135 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5137 gnus-summary-ignore-duplicates))
5138 (info (nth 2 entry))
5139 articles fetched-articles cached)
5141 (unless (gnus-check-server
5142 (set (make-local-variable 'gnus-current-select-method)
5143 (gnus-find-method-for-group group)))
5144 (error "Couldn't open server"))
5146 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5147 (gnus-activate-group group) ; Or we can activate it...
5148 (progn ; Or we bug out.
5149 (when (equal major-mode 'gnus-summary-mode)
5150 (gnus-kill-buffer (current-buffer)))
5151 (error "Couldn't activate group %s: %s"
5152 group (gnus-status-message group))))
5154 (unless (gnus-request-group group t)
5155 (when (equal major-mode 'gnus-summary-mode)
5156 (gnus-kill-buffer (current-buffer)))
5157 (error "Couldn't request group %s: %s"
5158 group (gnus-status-message group)))
5161 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5163 (setq gnus-summary-use-undownloaded-faces
5164 (gnus-agent-find-parameter
5166 'agent-enable-undownloaded-faces)))
5168 (setq gnus-newsgroup-name group
5169 gnus-newsgroup-unselected nil
5170 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5172 (let ((display (gnus-group-find-parameter group 'display)))
5173 (setq gnus-newsgroup-display
5175 ((not (zerop (or (car-safe read-all) 0)))
5176 ;; The user entered the group with C-u SPC/RET, let's show
5182 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5184 ;; The following is probably the "correct" solution, but
5185 ;; it makes Gnus fetch all headers and then limit the
5186 ;; articles (which is slow), so instead we hack the
5187 ;; select-articles parameter instead. -- Simon Josefsson
5190 ;; (gnus-byte-compile
5191 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5193 (setq select-articles
5194 (gnus-uncompress-range
5195 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5199 (cdr (gnus-active group)))))
5204 (gnus-summary-setup-default-charset)
5206 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5207 (when (gnus-virtual-group-p group)
5208 (setq cached gnus-newsgroup-cached))
5210 (setq gnus-newsgroup-unreads
5211 (gnus-sorted-ndifference
5212 (gnus-sorted-ndifference gnus-newsgroup-unreads
5213 gnus-newsgroup-marked)
5214 gnus-newsgroup-dormant))
5216 (setq gnus-newsgroup-processable nil)
5218 (gnus-update-read-articles group gnus-newsgroup-unreads)
5220 ;; Adjust and set lists of article marks.
5222 (gnus-adjust-marked-articles info))
5223 (if (setq articles select-articles)
5224 (setq gnus-newsgroup-unselected
5225 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5226 (setq articles (gnus-articles-to-read group read-all)))
5230 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5232 ((eq articles 0) nil)
5234 ;; Init the dependencies hash table.
5235 (setq gnus-newsgroup-dependencies
5236 (gnus-make-hashtable (length articles)))
5237 (gnus-set-global-variables)
5238 ;; Retrieve the headers and read them in.
5240 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5242 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5244 (setq gnus-newsgroup-cached cached))
5246 ;; Suppress duplicates?
5247 (when gnus-suppress-duplicates
5248 (gnus-dup-suppress-articles))
5250 ;; Set the initial limit.
5251 (setq gnus-newsgroup-limit (copy-sequence articles))
5252 ;; Remove canceled articles from the list of unread articles.
5253 (setq fetched-articles
5254 (mapcar (lambda (headers) (mail-header-number headers))
5255 gnus-newsgroup-headers))
5256 (setq gnus-newsgroup-articles fetched-articles)
5257 (setq gnus-newsgroup-unreads
5258 (gnus-sorted-nintersection
5259 gnus-newsgroup-unreads fetched-articles))
5260 (gnus-compute-unseen-list)
5262 ;; Removed marked articles that do not exist.
5263 (gnus-update-missing-marks
5264 (gnus-sorted-difference articles fetched-articles))
5265 ;; We might want to build some more threads first.
5266 (when (and gnus-fetch-old-headers
5267 (eq gnus-headers-retrieved-by 'nov))
5268 (if (eq gnus-fetch-old-headers 'invisible)
5269 (gnus-build-all-threads)
5270 (gnus-build-old-threads)))
5271 ;; Let the Gnus agent mark articles as read.
5273 (gnus-agent-get-undownloaded-list))
5274 ;; Remove list identifiers from subject
5275 (when gnus-list-identifiers
5276 (gnus-summary-remove-list-identifiers))
5277 ;; Check whether auto-expire is to be done in this group.
5278 (setq gnus-newsgroup-auto-expire
5279 (gnus-group-auto-expirable-p group))
5280 ;; Set up the article buffer now, if necessary.
5281 (unless gnus-single-article-buffer
5282 (gnus-article-setup-buffer))
5283 ;; First and last article in this newsgroup.
5284 (when gnus-newsgroup-headers
5285 (setq gnus-newsgroup-begin
5286 (mail-header-number (car gnus-newsgroup-headers))
5289 (gnus-last-element gnus-newsgroup-headers))))
5290 ;; GROUP is successfully selected.
5291 (or gnus-newsgroup-headers t)))))
5293 (defun gnus-compute-unseen-list ()
5294 ;; The `seen' marks are treated specially.
5295 (if (not gnus-newsgroup-seen)
5296 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5297 (setq gnus-newsgroup-unseen
5298 (gnus-inverse-list-range-intersection
5299 gnus-newsgroup-articles gnus-newsgroup-seen))))
5301 (defun gnus-summary-display-make-predicate (display)
5302 (require 'gnus-agent)
5303 (when (= (length display) 1)
5304 (setq display (car display)))
5305 (unless gnus-summary-display-cache
5306 (dolist (elem (append '((unread . unread)
5309 gnus-article-mark-lists))
5310 (push (cons (cdr elem)
5312 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5313 gnus-summary-display-cache)))
5314 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5315 (gnus-category-predicate-cache gnus-summary-display-cache))
5316 (gnus-get-predicate display)))
5318 ;; Uses the dynamically bound `number' variable.
5321 (defun gnus-article-marked-p (type &optional article)
5322 (let ((article (or article number)))
5325 (memq article gnus-newsgroup-marked))
5327 (memq article gnus-newsgroup-spam-marked))
5329 (memq article gnus-newsgroup-unsendable))
5330 ((eq type 'undownload)
5331 (memq article gnus-newsgroup-undownloaded))
5332 ((eq type 'download)
5333 (memq article gnus-newsgroup-downloadable))
5335 (memq article gnus-newsgroup-unreads))
5337 (memq article gnus-newsgroup-reads))
5339 (memq article gnus-newsgroup-dormant) )
5341 (memq article gnus-newsgroup-expirable))
5343 (memq article gnus-newsgroup-replied))
5345 (memq article gnus-newsgroup-killed))
5346 ((eq type 'bookmark)
5347 (assq article gnus-newsgroup-bookmarks))
5349 (assq article gnus-newsgroup-scored))
5351 (memq article gnus-newsgroup-saved))
5353 (memq article gnus-newsgroup-cached))
5355 (memq article gnus-newsgroup-forwarded))
5357 (not (memq article gnus-newsgroup-unseen)))
5359 (memq article gnus-newsgroup-recent))
5362 (defun gnus-articles-to-read (group &optional read-all)
5363 "Find out what articles the user wants to read."
5365 ;; Select all articles if `read-all' is non-nil, or if there
5366 ;; are no unread articles.
5368 (and (zerop (length gnus-newsgroup-marked))
5369 (zerop (length gnus-newsgroup-unreads)))
5370 ;; Fetch all if the predicate is non-nil.
5371 gnus-newsgroup-display)
5372 ;; We want to select the headers for all the articles in
5373 ;; the group, so we select either all the active
5374 ;; articles in the group, or (if that's nil), the
5375 ;; articles in the cache.
5377 (gnus-uncompress-range (gnus-active group))
5378 (gnus-cache-articles-in-group group))
5379 ;; Select only the "normal" subset of articles.
5381 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5382 gnus-newsgroup-unreads)))
5383 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5384 (scored (length scored-list))
5385 (number (length articles))
5386 (marked (+ (length gnus-newsgroup-marked)
5387 (length gnus-newsgroup-dormant)))
5392 ((numberp gnus-newsgroup-display)
5393 gnus-newsgroup-display)
5397 ((and (or (<= scored marked) (= scored number))
5398 (numberp gnus-large-newsgroup)
5399 (> number gnus-large-newsgroup))
5400 (let* ((cursor-in-echo-area nil)
5401 (initial (gnus-parameter-large-newsgroup-initial
5402 gnus-newsgroup-name))
5406 "How many articles from %s (%s %d): "
5408 (gnus-group-decoded-name gnus-newsgroup-name)
5410 (if initial "max" "default")
5413 (cons (number-to-string initial)
5415 (if (string-match "^[ \t]*$" input) number input)))
5416 ((and (> scored marked) (< scored number)
5417 (> (- scored number) 20))
5420 (format "%s %s (%d scored, %d total): "
5421 "How many articles from"
5422 (gnus-group-decoded-name group)
5424 (if (string-match "^[ \t]*$" input)
5428 (message "Quit getting the articles to read")
5430 (setq select (if (stringp select) (string-to-number select) select))
5431 (if (or (null select) (zerop select))
5433 (if (and (not (zerop scored)) (<= (abs select) scored))
5435 (setq articles (sort scored-list '<))
5436 (setq number (length articles)))
5437 (setq articles (copy-sequence articles)))
5439 (when (< (abs select) number)
5441 ;; Select the N oldest articles.
5442 (setcdr (nthcdr (1- (abs select)) articles) nil)
5443 ;; Select the N most recent articles.
5444 (setq articles (nthcdr (- number select) articles))))
5445 (setq gnus-newsgroup-unselected
5446 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5447 (when gnus-alter-articles-to-read-function
5450 (funcall gnus-alter-articles-to-read-function
5451 gnus-newsgroup-name articles)
5455 (defun gnus-killed-articles (killed articles)
5458 (when (inline (gnus-member-of-range (car articles) killed))
5459 (push (car articles) out))
5460 (setq articles (cdr articles)))
5463 (defun gnus-uncompress-marks (marks)
5464 "Uncompress the mark ranges in MARKS."
5465 (let ((uncompressed '(score bookmark))
5468 (if (memq (caar marks) uncompressed)
5469 (push (car marks) out)
5470 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5471 (setq marks (cdr marks)))
5474 (defun gnus-article-mark-to-type (mark)
5475 "Return the type of MARK."
5476 (or (cadr (assq mark gnus-article-special-mark-lists))
5479 (defun gnus-article-unpropagatable-p (mark)
5480 "Return whether MARK should be propagated to back end."
5481 (memq mark gnus-article-unpropagated-mark-lists))
5483 (defun gnus-adjust-marked-articles (info)
5484 "Set all article lists and remove all marks that are no longer valid."
5485 (let* ((marked-lists (gnus-info-marks info))
5486 (active (gnus-active (gnus-info-group info)))
5489 (types gnus-article-mark-lists)
5490 marks var articles article mark mark-type
5493 (dolist (marks marked-lists)
5494 (setq mark (car marks)
5495 mark-type (gnus-article-mark-to-type mark)
5496 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5498 ;; We set the variable according to the type of the marks list,
5499 ;; and then adjust the marks to a subset of the active articles.
5501 ;; Adjust "simple" lists - compressed yet unsorted
5502 ((eq mark-type 'list)
5503 ;; Simultaneously uncompress and clip to active range
5504 ;; See gnus-uncompress-range for a description of possible marks
5506 (if (not (cadr marks))
5508 (setq articles (if (numberp (cddr marks))
5514 (while (setq article (pop articles))
5515 (cond ((consp article)
5516 (setq bgn (max (car article) min)
5517 end (min (cdr article) max))
5519 (setq l (setcdr l (cons bgn nil))
5521 ((and (<= min article)
5523 (setq l (setcdr l (cons article nil))))))
5524 (set var (cdr lh)))))
5526 ((eq mark-type 'tuple)
5527 (set var (setq articles (cdr marks)))
5528 (when (not (listp (cdr (symbol-value var))))
5529 (set var (list (symbol-value var))))
5530 (when (not (listp (cdr articles)))
5531 (setq articles (list articles)))
5533 (when (or (not (consp (setq article (pop articles))))
5534 (< (car article) min)
5535 (> (car article) max))
5536 (set var (delq article (symbol-value var))))))
5537 ;; Adjust ranges (sloppily).
5538 ((eq mark-type 'range)
5541 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5542 ;; It should be (seen (NUM1 . NUM2)).
5543 (when (numberp (cddr marks))
5544 (setcdr marks (list (cdr marks))))
5545 (setq articles (cdr marks))
5546 (while (and articles
5547 (or (and (consp (car articles))
5548 (> min (cdar articles)))
5549 (and (numberp (car articles))
5550 (> min (car articles)))))
5552 (set var articles))))))))
5554 (defun gnus-update-missing-marks (missing)
5555 "Go through the list of MISSING articles and remove them from the mark lists."
5558 ;; Go through all types.
5559 (dolist (elem gnus-article-mark-lists)
5560 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5561 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5562 (when (symbol-value var)
5563 ;; This list has articles. So we delete all missing
5564 ;; articles from it.
5567 (set var (delq (pop m) (symbol-value var))))))))))
5569 (defun gnus-update-marks ()
5570 "Enter the various lists of marked articles into the newsgroup info list."
5571 (let ((types gnus-article-mark-lists)
5572 (info (gnus-get-info gnus-newsgroup-name))
5573 type list newmarked symbol delta-marks)
5575 ;; Add all marks lists to the list of marks lists.
5576 (while (setq type (pop types))
5577 (setq list (symbol-value
5579 (intern (format "gnus-newsgroup-%s" (car type))))))
5582 ;; Get rid of the entries of the articles that have the
5584 (when (and (eq (cdr type) 'score)
5588 (prev (cons nil list))
5591 (if (or (not (consp (car arts)))
5592 (= (cdar arts) gnus-summary-default-score))
5593 (setcdr prev (cdr arts))
5595 (setq arts (cdr arts)))
5596 (setq list (cdr all)))))
5598 (when (eq (cdr type) 'seen)
5599 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5601 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5602 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5604 (when (and (gnus-check-backend-function
5605 'request-set-mark gnus-newsgroup-name)
5606 (not (gnus-article-unpropagatable-p (cdr type))))
5607 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5608 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5609 (add (gnus-remove-from-range
5610 (gnus-copy-sequence list) old)))
5612 (push (list add 'add (list (cdr type))) delta-marks))
5614 (push (list del 'del (list (cdr type))) delta-marks))))
5617 (push (cons (cdr type) list) newmarked)))
5620 (unless (gnus-check-group gnus-newsgroup-name)
5621 (error "Can't open server for %s" gnus-newsgroup-name))
5622 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5624 ;; Enter these new marks into the info of the group.
5626 (setcar (nthcdr 3 info) newmarked)
5627 ;; Add the marks lists to the end of the info.
5629 (setcdr (nthcdr 2 info) (list newmarked))))
5631 ;; Cut off the end of the info if there's nothing else there.
5635 (when (nthcdr (decf i) info)
5636 (setcdr (nthcdr i info) nil)))))))
5638 (defun gnus-set-mode-line (where)
5639 "Set the mode line of the article or summary buffers.
5640 If WHERE is `summary', the summary mode line format will be used."
5641 ;; Is this mode line one we keep updated?
5642 (when (and (memq where gnus-updated-mode-lines)
5644 (intern (format "gnus-%s-mode-line-format-spec" where))))
5647 ;; We evaluate this in the summary buffer since these
5648 ;; variables are buffer-local to that buffer.
5649 (set-buffer gnus-summary-buffer)
5650 ;; We bind all these variables that are used in the `eval' form
5652 (let* ((mformat (symbol-value
5654 (format "gnus-%s-mode-line-format-spec" where))))
5655 (gnus-tmp-group-name (gnus-group-decoded-name
5656 gnus-newsgroup-name))
5657 (gnus-tmp-article-number (or gnus-current-article 0))
5658 (gnus-tmp-unread gnus-newsgroup-unreads)
5659 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5660 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5661 (gnus-tmp-unread-and-unselected
5662 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5663 (zerop gnus-tmp-unselected))
5665 ((zerop gnus-tmp-unselected)
5666 (format "{%d more}" gnus-tmp-unread-and-unticked))
5667 (t (format "{%d(+%d) more}"
5668 gnus-tmp-unread-and-unticked
5669 gnus-tmp-unselected))))
5671 (if (and gnus-current-headers
5672 (vectorp gnus-current-headers))
5673 (gnus-mode-string-quote
5674 (mail-header-subject gnus-current-headers))
5676 bufname-length max-len
5677 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5678 (setq mode-string (eval mformat))
5679 (setq bufname-length (if (string-match "%b" mode-string)
5682 (if (eq where 'summary)
5684 (get-buffer gnus-article-buffer))))
5687 (setq max-len (max 4 (if gnus-mode-non-string-length
5689 gnus-mode-non-string-length
5691 (length mode-string))))
5692 ;; We might have to chop a bit of the string off...
5693 (when (> (length mode-string) max-len)
5695 (concat (truncate-string-to-width mode-string (- max-len 3))
5697 ;; Pad the mode string a bit.
5698 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5699 ;; Update the mode line.
5700 (setq mode-line-buffer-identification
5701 (gnus-mode-line-buffer-identification (list mode-string)))
5702 (set-buffer-modified-p t))))
5704 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5705 "Go through the HEADERS list and add all Xrefs to a hash table.
5706 The resulting hash table is returned, or nil if no Xrefs were found."
5707 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5708 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5709 (xref-hashtb (gnus-make-hashtable))
5710 start group entry number xrefs header)
5712 (setq header (pop headers))
5713 (when (and (setq xrefs (mail-header-xref header))
5714 (not (memq (setq number (mail-header-number header))
5717 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5718 (setq start (match-end 0))
5719 (setq group (if prefix
5720 (concat prefix (substring xrefs (match-beginning 1)
5722 (substring xrefs (match-beginning 1) (match-end 1))))
5724 (string-to-int (substring xrefs (match-beginning 2)
5726 (if (setq entry (gnus-gethash group xref-hashtb))
5727 (setcdr entry (cons number (cdr entry)))
5728 (gnus-sethash group (cons number nil) xref-hashtb)))))
5729 (and start xref-hashtb)))
5731 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5732 "Look through all the headers and mark the Xrefs as read."
5733 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5734 name info xref-hashtb idlist method nth4)
5736 (set-buffer gnus-group-buffer)
5737 (when (setq xref-hashtb
5738 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5741 (unless (string= from-newsgroup (setq name (symbol-name group)))
5742 (setq idlist (symbol-value group))
5743 ;; Dead groups are not updated.
5745 (setq info (gnus-get-info name))
5746 (when (stringp (setq nth4 (gnus-info-method info)))
5747 (setq nth4 (gnus-server-to-method nth4))))
5748 ;; Only do the xrefs if the group has the same
5749 ;; select method as the group we have just read.
5750 (or (gnus-methods-equal-p
5751 nth4 (gnus-find-method-for-group from-newsgroup))
5753 (equal nth4 (setq method (gnus-find-method-for-group
5755 (and (equal (car nth4) (car method))
5756 (equal (nth 1 nth4) (nth 1 method))))
5757 gnus-use-cross-reference
5758 (or (not (eq gnus-use-cross-reference t))
5760 ;; Only do cross-references on subscribed
5761 ;; groups, if that is what is wanted.
5762 (<= (gnus-info-level info) gnus-level-subscribed))
5763 (gnus-group-make-articles-read name idlist))))
5766 (defun gnus-compute-read-articles (group articles)
5767 (let* ((entry (gnus-group-entry group))
5768 (info (nth 2 entry))
5769 (active (gnus-active group))
5772 ;; First peel off all invalid article numbers.
5774 (let ((ids articles)
5776 (while (setq id (pop ids))
5777 (when (and first (> id (cdr active)))
5778 ;; We'll end up in this situation in one particular
5779 ;; obscure situation. If you re-scan a group and get
5780 ;; a new article that is cross-posted to a different
5781 ;; group that has not been re-scanned, you might get
5782 ;; crossposted article that has a higher number than
5783 ;; Gnus believes possible. So we re-activate this
5784 ;; group as well. This might mean doing the
5785 ;; crossposting thingy will *increase* the number
5786 ;; of articles in some groups. Tsk, tsk.
5787 (setq active (or (gnus-activate-group group) active)))
5788 (when (or (> id (cdr active))
5789 (< id (car active)))
5790 (setq articles (delq id articles))))))
5791 ;; If the read list is nil, we init it.
5793 (null (gnus-info-read info))
5795 (setq ninfo (cons 1 (1- (car active))))
5796 (setq ninfo (gnus-info-read info)))
5797 ;; Then we add the read articles to the range.
5799 ninfo (setq articles (sort articles '<))))))
5801 (defun gnus-group-make-articles-read (group articles)
5802 "Update the info of GROUP to say that ARTICLES are read."
5804 (entry (gnus-group-entry group))
5805 (info (nth 2 entry))
5806 (active (gnus-active group))
5809 (setq range (gnus-compute-read-articles group articles))
5810 (with-current-buffer gnus-group-buffer
5813 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5814 (gnus-info-set-read ',info ',(gnus-info-read info))
5815 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5816 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5817 (gnus-group-update-group ,group t))))
5818 ;; Add the read articles to the range.
5819 (gnus-info-set-read info range)
5820 (gnus-request-set-mark group (list (list range 'add '(read))))
5821 ;; Then we have to re-compute how many unread
5822 ;; articles there are in this group.
5826 (setq num (- (1+ (cdr active)) (car active))))
5827 ((not (listp (cdr range)))
5828 (setq num (- (cdr active) (- (1+ (cdr range))
5832 (if (numberp (car range))
5834 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5835 (setq range (cdr range)))
5836 (setq num (- (cdr active) num))))
5837 ;; Update the number of unread articles.
5839 ;; Update the group buffer.
5840 (unless (gnus-ephemeral-group-p group)
5841 (gnus-group-update-group group t))))))
5843 (defvar gnus-newsgroup-none-id 0)
5845 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5846 (let ((cur nntp-server-buffer)
5849 (with-current-buffer gnus-summary-buffer
5850 gnus-newsgroup-dependencies)))
5851 headers id end ref number
5852 (mail-parse-charset gnus-newsgroup-charset)
5853 (mail-parse-ignored-charsets
5854 (save-excursion (condition-case nil
5855 (set-buffer gnus-summary-buffer)
5857 gnus-newsgroup-ignored-charsets)))
5859 (set-buffer nntp-server-buffer)
5860 ;; Translate all TAB characters into SPACE characters.
5861 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5862 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5863 (ietf-drums-unfold-fws)
5864 (gnus-run-hooks 'gnus-parse-headers-hook)
5865 (let ((case-fold-search t)
5866 in-reply-to header p lines chars)
5867 (goto-char (point-min))
5868 ;; Search to the beginning of the next header. Error messages
5869 ;; do not begin with 2 or 3.
5870 (while (re-search-forward "^[23][0-9]+ " nil t)
5873 ;; This implementation of this function, with nine
5874 ;; search-forwards instead of the one re-search-forward and
5875 ;; a case (which basically was the old function) is actually
5876 ;; about twice as fast, even though it looks messier. You
5877 ;; can't have everything, I guess. Speed and elegance
5878 ;; doesn't always go hand in hand.
5884 (setq number (read cur))
5887 (narrow-to-region (point)
5888 (or (and (search-forward "\n.\n" nil t)
5894 (if (search-forward "\nsubject:" nil t)
5895 (funcall gnus-decode-encoded-word-function
5896 (nnheader-header-value))
5901 (if (search-forward "\nfrom:" nil t)
5902 (funcall gnus-decode-encoded-word-function
5903 (nnheader-header-value))
5908 (if (search-forward "\ndate:" nil t)
5909 (nnheader-header-value) ""))
5913 (setq id (if (re-search-forward
5914 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5915 ;; We do it this way to make sure the Message-ID
5916 ;; is (somewhat) syntactically valid.
5917 (buffer-substring (match-beginning 1)
5919 ;; If there was no message-id, we just fake one
5920 ;; to make subsequent routines simpler.
5921 (nnheader-generate-fake-message-id number))))
5925 (if (search-forward "\nreferences:" nil t)
5929 (nnheader-header-value)
5934 (search-backward ">" end t)
5937 (search-backward "<" end t)
5939 ;; Get the references from the in-reply-to header if there
5940 ;; were no references and the in-reply-to header looks
5942 (if (and (search-forward "\nin-reply-to:" nil t)
5943 (setq in-reply-to (nnheader-header-value))
5944 (string-match "<[^>]+>" in-reply-to))
5946 (setq ref (substring in-reply-to (match-beginning 0)
5948 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5949 (setq ref2 (substring in-reply-to (match-beginning 0)
5951 (when (> (length ref2) (length ref))
5958 (if (search-forward "\nchars: " nil t)
5959 (if (numberp (setq chars (ignore-errors (read cur))))
5965 (if (search-forward "\nlines: " nil t)
5966 (if (numberp (setq lines (ignore-errors (read cur))))
5972 (and (search-forward "\nxref:" nil t)
5973 (nnheader-header-value)))
5975 (when gnus-extra-headers
5976 (let ((extra gnus-extra-headers)
5980 (when (search-forward
5981 (concat "\n" (symbol-name (car extra)) ":") nil t)
5982 (push (cons (car extra) (nnheader-header-value))
5986 (when (equal id ref)
5989 (when gnus-alter-header-function
5990 (funcall gnus-alter-header-function header)
5991 (setq id (mail-header-id header)
5992 ref (gnus-parent-id (mail-header-references header))))
5995 (gnus-dependencies-add-header
5996 header dependencies force-new))
5997 (push header headers))
5998 (goto-char (point-max))
6000 (nreverse headers)))))
6002 ;; Goes through the xover lines and returns a list of vectors
6003 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6004 force-new dependencies
6005 group also-fetch-heads)
6006 "Parse the news overview data in the server buffer.
6007 Return a list of headers that match SEQUENCE (see
6008 `nntp-retrieve-headers')."
6009 ;; Get the Xref when the users reads the articles since most/some
6010 ;; NNTP servers do not include Xrefs when using XOVER.
6011 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6012 (let ((mail-parse-charset gnus-newsgroup-charset)
6013 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6014 (cur nntp-server-buffer)
6015 (dependencies (or dependencies gnus-newsgroup-dependencies))
6017 ((eq gnus-read-all-available-headers t)
6019 ((stringp gnus-read-all-available-headers)
6020 (string-match gnus-read-all-available-headers group))
6023 number headers header)
6025 (set-buffer nntp-server-buffer)
6026 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6027 ;; Allow the user to mangle the headers before parsing them.
6028 (gnus-run-hooks 'gnus-parse-headers-hook)
6029 (goto-char (point-min))
6030 (gnus-parse-without-error
6031 (while (and (or sequence allp)
6033 (setq number (read cur))
6035 (while (and sequence
6036 (< (car sequence) number))
6037 (setq sequence (cdr sequence))))
6040 (eq number (car sequence))))
6042 (setq sequence (cdr sequence))
6043 (setq header (inline
6044 (gnus-nov-parse-line
6045 number dependencies force-new)))))
6046 (push header headers))
6048 ;; A common bug in inn is that if you have posted an article and
6049 ;; then retrieves the active file, it will answer correctly --
6050 ;; the new article is included. However, a NOV entry for the
6051 ;; article may not have been generated yet, so this may fail.
6052 ;; We work around this problem by retrieving the last few
6053 ;; headers using HEAD.
6054 (if (or (not also-fetch-heads)
6056 ;; We (probably) got all the headers.
6058 (let ((gnus-nov-is-evil t))
6061 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6062 (gnus-get-newsgroup-headers))))))))
6064 (defun gnus-article-get-xrefs ()
6065 "Fill in the Xref value in `gnus-current-headers', if necessary.
6066 This is meant to be called in `gnus-article-internal-prepare-hook'."
6067 (let ((headers (with-current-buffer gnus-summary-buffer
6068 gnus-current-headers)))
6069 (or (not gnus-use-cross-reference)
6071 (and (mail-header-xref headers)
6072 (not (string= (mail-header-xref headers) "")))
6073 (let ((case-fold-search t)
6076 (nnheader-narrow-to-headers)
6077 (goto-char (point-min))
6078 (when (or (and (not (eobp))
6079 (eq (downcase (char-after)) ?x)
6080 (looking-at "Xref:"))
6081 (search-forward "\nXref:" nil t))
6082 (goto-char (1+ (match-end 0)))
6083 (setq xref (buffer-substring (point) (point-at-eol)))
6084 (mail-header-set-xref headers xref)))))))
6086 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6087 "Find article ID and insert the summary line for that article.
6088 OLD-HEADER can either be a header or a line number to insert
6089 the subject line on."
6090 (let* ((line (and (numberp old-header) old-header))
6091 (old-header (and (vectorp old-header) old-header))
6092 (header (cond ((and old-header use-old-header)
6095 (gnus-number-to-header id))
6096 (gnus-number-to-header id))
6098 (gnus-read-header id))))
6099 (number (and (numberp id) id))
6102 ;; Rebuild the thread that this article is part of and go to the
6103 ;; article we have fetched.
6104 (when (and (not gnus-show-threads)
6107 (setq d (gnus-data-find (mail-header-number old-header))))
6108 (goto-char (gnus-data-pos d))
6114 (gnus-delete-line))))))
6115 ;; Remove list identifiers from subject.
6116 (when gnus-list-identifiers
6117 (let ((gnus-newsgroup-headers (list header)))
6118 (gnus-summary-remove-list-identifiers)))
6120 (mail-header-set-number header (mail-header-number old-header)))
6121 (setq gnus-newsgroup-sparse
6122 (delq (setq number (mail-header-number header))
6123 gnus-newsgroup-sparse))
6124 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6125 (push number gnus-newsgroup-limit)
6126 (gnus-rebuild-thread (mail-header-id header) line)
6127 (gnus-summary-goto-subject number nil t))
6128 (when (and (numberp number)
6130 ;; We have to update the boundaries even if we can't fetch the
6131 ;; article if ID is a number -- so that the next `P' or `N'
6132 ;; command will fetch the previous (or next) article even
6133 ;; if the one we tried to fetch this time has been canceled.
6134 (when (> number gnus-newsgroup-end)
6135 (setq gnus-newsgroup-end number))
6136 (when (< number gnus-newsgroup-begin)
6137 (setq gnus-newsgroup-begin number))
6138 (setq gnus-newsgroup-unselected
6139 (delq number gnus-newsgroup-unselected)))
6140 ;; Report back a success?
6141 (and header (mail-header-number header))))
6143 ;;; Process/prefix in the summary buffer
6145 (defun gnus-summary-work-articles (n)
6146 "Return a list of articles to be worked upon.
6147 The prefix argument, the list of process marked articles, and the
6148 current article will be taken into consideration."
6150 (set-buffer gnus-summary-buffer)
6153 ;; A numerical prefix has been given.
6154 (setq n (prefix-numeric-value n))
6155 (let ((backward (< n 0))
6156 (n (abs (prefix-numeric-value n)))
6161 (push (setq article (gnus-summary-article-number))
6164 (gnus-summary-find-prev nil article)
6165 (gnus-summary-find-next nil article)))
6167 (nreverse articles)))
6168 ((and (gnus-region-active-p) (mark))
6169 (message "region active")
6170 ;; Work on the region between point and mark.
6171 (let ((max (max (point) (mark)))
6174 (goto-char (min (min (point) (mark))))
6177 (push (setq article (gnus-summary-article-number)) articles)
6178 (gnus-summary-find-next nil article)
6180 (nreverse articles))))
6181 (gnus-newsgroup-processable
6182 ;; There are process-marked articles present.
6183 ;; Save current state.
6184 (gnus-summary-save-process-mark)
6186 (reverse gnus-newsgroup-processable))
6188 ;; Just return the current article.
6189 (list (gnus-summary-article-number))))))
6191 (defmacro gnus-summary-iterate (arg &rest forms)
6192 "Iterate over the process/prefixed articles and do FORMS.
6193 ARG is the interactive prefix given to the command. FORMS will be
6194 executed with point over the summary line of the articles."
6195 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6196 `(let ((,articles (gnus-summary-work-articles ,arg)))
6198 (gnus-summary-goto-subject (car ,articles))
6202 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6203 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6205 (defun gnus-summary-save-process-mark ()
6206 "Push the current set of process marked articles on the stack."
6208 (push (copy-sequence gnus-newsgroup-processable)
6209 gnus-newsgroup-process-stack))
6211 (defun gnus-summary-kill-process-mark ()
6212 "Push the current set of process marked articles on the stack and unmark."
6214 (gnus-summary-save-process-mark)
6215 (gnus-summary-unmark-all-processable))
6217 (defun gnus-summary-yank-process-mark ()
6218 "Pop the last process mark state off the stack and restore it."
6220 (unless gnus-newsgroup-process-stack
6221 (error "Empty mark stack"))
6222 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6224 (defun gnus-summary-process-mark-set (set)
6225 "Make SET into the current process marked articles."
6226 (gnus-summary-unmark-all-processable)
6227 (mapc 'gnus-summary-set-process-mark set))
6229 ;;; Searching and stuff
6231 (defun gnus-summary-search-group (&optional backward use-level)
6232 "Search for next unread newsgroup.
6233 If optional argument BACKWARD is non-nil, search backward instead."
6235 (set-buffer gnus-group-buffer)
6236 (when (gnus-group-search-forward
6237 backward nil (if use-level (gnus-group-group-level) nil))
6238 (gnus-group-group-name))))
6240 (defun gnus-summary-best-group (&optional exclude-group)
6241 "Find the name of the best unread group.
6242 If EXCLUDE-GROUP, do not go to this group."
6243 (with-current-buffer gnus-group-buffer
6245 (gnus-group-best-unread-group exclude-group))))
6247 (defun gnus-summary-find-next (&optional unread article backward)
6249 (gnus-summary-find-prev unread article)
6250 (let* ((dummy (gnus-summary-article-intangible-p))
6251 (article (or article (gnus-summary-article-number)))
6252 (data (gnus-data-find-list article))
6254 (when (and (not dummy)
6255 (or (not gnus-summary-check-current)
6257 (not (gnus-data-unread-p (car data)))))
6258 (setq data (cdr data)))
6263 (unless (memq (gnus-data-number (car data))
6265 ((eq gnus-auto-goto-ignores
6266 'always-undownloaded)
6267 gnus-newsgroup-undownloaded)
6270 ((eq gnus-auto-goto-ignores
6272 gnus-newsgroup-unfetched)
6273 ((eq gnus-auto-goto-ignores
6275 gnus-newsgroup-undownloaded)))
6276 (when (gnus-data-unread-p (car data))
6277 (setq result (car data)
6279 (setq data (cdr data)))
6282 (goto-char (gnus-data-pos result))
6283 (gnus-data-number result)))))
6285 (defun gnus-summary-find-prev (&optional unread article)
6286 (let* ((eobp (eobp))
6287 (article (or article (gnus-summary-article-number)))
6288 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6290 (when (and (not eobp)
6291 (or (not gnus-summary-check-current)
6293 (not (gnus-data-unread-p (car data)))))
6294 (setq data (cdr data)))
6299 (unless (memq (gnus-data-number (car data))
6301 ((eq gnus-auto-goto-ignores
6302 'always-undownloaded)
6303 gnus-newsgroup-undownloaded)
6306 ((eq gnus-auto-goto-ignores
6308 gnus-newsgroup-unfetched)
6309 ((eq gnus-auto-goto-ignores
6311 gnus-newsgroup-undownloaded)))
6312 (when (gnus-data-unread-p (car data))
6313 (setq result (car data)
6315 (setq data (cdr data)))
6318 (goto-char (gnus-data-pos result))
6319 (gnus-data-number result))))
6321 (defun gnus-summary-find-subject (subject &optional unread backward article)
6322 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6323 (article (or article (gnus-summary-article-number)))
6324 (articles (gnus-data-list backward))
6325 (arts (gnus-data-find-list article articles))
6327 (when (or (not gnus-summary-check-current)
6329 (not (gnus-data-unread-p (car arts))))
6330 (setq arts (cdr arts)))
6332 (and (or (not unread)
6333 (gnus-data-unread-p (car arts)))
6334 (vectorp (gnus-data-header (car arts)))
6336 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6337 (setq result (car arts)
6339 (setq arts (cdr arts)))
6341 (goto-char (gnus-data-pos result))
6342 (gnus-data-number result))))
6344 (defun gnus-summary-search-forward (&optional unread subject backward)
6345 "Search forward for an article.
6346 If UNREAD, look for unread articles. If SUBJECT, look for
6347 articles with that subject. If BACKWARD, search backward instead."
6348 (cond (subject (gnus-summary-find-subject subject unread backward))
6349 (backward (gnus-summary-find-prev unread))
6350 (t (gnus-summary-find-next unread))))
6352 (defun gnus-recenter (&optional n)
6353 "Center point in window and redisplay frame.
6354 Also do horizontal recentering."
6356 (when (and gnus-auto-center-summary
6357 (not (eq gnus-auto-center-summary 'vertical)))
6358 (gnus-horizontal-recenter))
6361 (defun gnus-summary-recenter ()
6362 "Center point in the summary window.
6363 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6364 displayed, no centering will be performed."
6365 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6366 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6368 ;; The user has to want it.
6369 (when gnus-auto-center-summary
6370 (let* ((top (cond ((< (window-height) 4) 0)
6371 ((< (window-height) 7) 1)
6372 (t (if (numberp gnus-auto-center-summary)
6373 gnus-auto-center-summary
6374 (/ (1- (window-height)) 2)))))
6375 (height (1- (window-height)))
6376 (bottom (save-excursion (goto-char (point-max))
6377 (forward-line (- height))
6379 (window (get-buffer-window (current-buffer))))
6380 (when (get-buffer-window gnus-article-buffer)
6381 ;; Only do recentering when the article buffer is displayed,
6382 ;; Set the window start to either `bottom', which is the biggest
6383 ;; possible valid number, or the second line from the top,
6384 ;; whichever is the least.
6385 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6386 (if (> bottom top-pos)
6387 ;; Keep the second line from the top visible
6388 (set-window-start window top-pos t)
6389 ;; Try to keep the bottom line visible; if it's partially
6390 ;; obscured, either scroll one more line to make it fully
6391 ;; visible, or revert to using TOP-POS.
6393 (goto-char (point-max))
6395 (let ((last-line-start (point)))
6397 (set-window-start window (point) t)
6398 (when (not (pos-visible-in-window-p last-line-start window))
6400 (set-window-start window (min (point) top-pos) t)))))))
6401 ;; Do horizontal recentering while we're at it.
6402 (when (and (get-buffer-window (current-buffer) t)
6403 (not (eq gnus-auto-center-summary 'vertical)))
6404 (let ((selected (selected-window)))
6405 (select-window (get-buffer-window (current-buffer) t))
6406 (gnus-summary-position-point)
6407 (gnus-horizontal-recenter)
6408 (select-window selected))))))
6410 (defun gnus-summary-jump-to-group (newsgroup)
6411 "Move point to NEWSGROUP in group mode buffer."
6412 ;; Keep update point of group mode buffer if visible.
6413 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6414 (save-window-excursion
6415 ;; Take care of tree window mode.
6416 (when (get-buffer-window gnus-group-buffer)
6417 (pop-to-buffer gnus-group-buffer))
6418 (gnus-group-jump-to-group newsgroup))
6420 ;; Take care of tree window mode.
6421 (if (get-buffer-window gnus-group-buffer)
6422 (pop-to-buffer gnus-group-buffer)
6423 (set-buffer gnus-group-buffer))
6424 (gnus-group-jump-to-group newsgroup))))
6426 ;; This function returns a list of article numbers based on the
6427 ;; difference between the ranges of read articles in this group and
6428 ;; the range of active articles.
6429 (defun gnus-list-of-unread-articles (group)
6430 (let* ((read (gnus-info-read (gnus-get-info group)))
6431 (active (or (gnus-active group) (gnus-activate-group group)))
6432 (last (or (cdr active)
6433 (error "Group %s couldn't be activated " group)))
6435 ;; If none are read, then all are unread.
6437 (setq first (car active))
6438 ;; If the range of read articles is a single range, then the
6439 ;; first unread article is the article after the last read
6440 ;; article. Sounds logical, doesn't it?
6441 (if (and (not (listp (cdr read)))
6442 (or (< (car read) (car active))
6443 (progn (setq read (list read))
6445 (setq first (max (car active) (1+ (cdr read))))
6446 ;; `read' is a list of ranges.
6447 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6450 (setq first (car active)))
6453 (while (< first nlast)
6454 (setq unread (cons first unread)
6456 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6457 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6458 (setq read (cdr read)))))
6459 ;; And add the last unread articles.
6460 (while (<= first last)
6461 (setq unread (cons first unread)
6463 ;; Return the list of unread articles.
6464 (delq 0 (nreverse unread))))
6466 (defun gnus-list-of-read-articles (group)
6467 "Return a list of unread, unticked and non-dormant articles."
6468 (let* ((info (gnus-get-info group))
6469 (marked (gnus-info-marks info))
6470 (active (gnus-active group)))
6472 (gnus-list-range-difference
6473 (gnus-list-range-difference
6474 (gnus-sorted-complement
6475 (gnus-uncompress-range active)
6476 (gnus-list-of-unread-articles group))
6477 (cdr (assq 'dormant marked)))
6478 (cdr (assq 'tick marked))))))
6480 ;; This function returns a sequence of article numbers based on the
6481 ;; difference between the ranges of read articles in this group and
6482 ;; the range of active articles.
6483 (defun gnus-sequence-of-unread-articles (group)
6484 (let* ((read (gnus-info-read (gnus-get-info group)))
6485 (active (or (gnus-active group) (gnus-activate-group group)))
6488 ;; If none are read, then all are unread.
6490 (setq first (car active))
6491 ;; If the range of read articles is a single range, then the
6492 ;; first unread article is the article after the last read
6493 ;; article. Sounds logical, doesn't it?
6494 (if (and (not (listp (cdr read)))
6495 (or (< (car read) (car active))
6496 (progn (setq read (list read))
6498 (setq first (max (car active) (1+ (cdr read))))
6499 ;; `read' is a list of ranges.
6500 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6503 (setq first (car active)))
6506 (push (cons first nlast) unread))
6507 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6508 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6509 (setq read (cdr read)))))
6510 ;; And add the last unread articles.
6511 (cond ((< first last)
6512 (push (cons first last) unread))
6514 (push first unread)))
6515 ;; Return the sequence of unread articles.
6516 (delq 0 (nreverse unread))))
6518 ;; Various summary commands
6520 (defun gnus-summary-select-article-buffer ()
6521 "Reconfigure windows to show article buffer."
6523 (if (not (gnus-buffer-live-p gnus-article-buffer))
6524 (error "There is no article buffer for this summary buffer")
6525 (gnus-configure-windows 'article)
6526 (select-window (get-buffer-window gnus-article-buffer))))
6528 (defun gnus-summary-universal-argument (arg)
6529 "Perform any operation on all articles that are process/prefixed."
6531 (let ((articles (gnus-summary-work-articles arg))
6538 (substitute-command-keys
6539 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6541 (gnus-error 1 "Undefined key")
6544 (gnus-summary-goto-subject (setq article (pop articles)))
6545 (let (gnus-newsgroup-processable)
6546 (command-execute func))
6547 (gnus-summary-remove-process-mark article)))))
6548 (gnus-summary-position-point))
6550 (defun gnus-summary-toggle-truncation (&optional arg)
6551 "Toggle truncation of summary lines.
6552 With ARG, turn line truncation on if ARG is positive."
6554 (setq truncate-lines
6555 (if (null arg) (not truncate-lines)
6556 (> (prefix-numeric-value arg) 0)))
6559 (defun gnus-summary-find-for-reselect ()
6560 "Return the number of an article to stay on across a reselect.
6561 The current article is considered, then following articles, then previous
6562 articles. An article is sought which is not cancelled and isn't a temporary
6563 insertion from another group. If there's no such then return a dummy 0."
6565 (dolist (rev '(nil t))
6566 (unless found ; don't demand the reverse list if we don't need it
6567 (let ((data (gnus-data-find-list
6568 (gnus-summary-article-number) (gnus-data-list rev))))
6569 (while (and data (not found))
6570 (if (and (< 0 (gnus-data-number (car data)))
6571 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6572 (setq found (gnus-data-number (car data))))
6573 (setq data (cdr data))))))
6576 (defun gnus-summary-reselect-current-group (&optional all rescan)
6577 "Exit and then reselect the current newsgroup.
6578 The prefix argument ALL means to select all articles."
6580 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6581 (error "Ephemeral groups can't be reselected"))
6582 (let ((current-subject (gnus-summary-find-for-reselect))
6583 (group gnus-newsgroup-name))
6584 (setq gnus-newsgroup-begin nil)
6585 (gnus-summary-exit nil 'leave-hidden)
6586 ;; We have to adjust the point of group mode buffer because
6587 ;; point was moved to the next unread newsgroup by exiting.
6588 (gnus-summary-jump-to-group group)
6591 (gnus-group-get-new-news-this-group 1)))
6592 (gnus-group-read-group all t)
6593 (gnus-summary-goto-subject current-subject nil t)))
6595 (defun gnus-summary-rescan-group (&optional all)
6596 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6598 (gnus-summary-reselect-current-group all t))
6600 (defun gnus-summary-update-info (&optional non-destructive)
6602 (let ((group gnus-newsgroup-name))
6604 (when gnus-newsgroup-kill-headers
6605 (setq gnus-newsgroup-killed
6606 (gnus-compress-sequence
6608 (gnus-list-range-intersection
6609 gnus-newsgroup-unselected gnus-newsgroup-killed)
6610 gnus-newsgroup-unreads)
6612 (unless (listp (cdr gnus-newsgroup-killed))
6613 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6614 (let ((headers gnus-newsgroup-headers))
6615 ;; Set the new ranges of read articles.
6616 (with-current-buffer gnus-group-buffer
6617 (gnus-undo-force-boundary))
6618 (gnus-update-read-articles
6619 group (gnus-sorted-union
6620 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6621 ;; Set the current article marks.
6622 (let ((gnus-newsgroup-scored
6623 (if (and (not gnus-save-score)
6624 (not non-destructive))
6626 gnus-newsgroup-scored)))
6628 (gnus-update-marks)))
6629 ;; Do the cross-ref thing.
6630 (when gnus-use-cross-reference
6631 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6632 ;; Do not switch windows but change the buffer to work.
6633 (set-buffer gnus-group-buffer)
6634 (unless (gnus-ephemeral-group-p group)
6635 (gnus-group-update-group group)))))))
6637 (defun gnus-summary-save-newsrc (&optional force)
6638 "Save the current number of read/marked articles in the dribble buffer.
6639 The dribble buffer will then be saved.
6640 If FORCE (the prefix), also save the .newsrc file(s)."
6642 (gnus-summary-update-info t)
6644 (gnus-save-newsrc-file)
6645 (gnus-dribble-save)))
6647 (defun gnus-summary-exit (&optional temporary leave-hidden)
6648 "Exit reading current newsgroup, and then return to group selection mode.
6649 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6651 (gnus-set-global-variables)
6652 (when (gnus-buffer-live-p gnus-article-buffer)
6654 (set-buffer gnus-article-buffer)
6655 (mm-destroy-parts gnus-article-mime-handles)
6656 ;; Set it to nil for safety reason.
6657 (setq gnus-article-mime-handle-alist nil)
6658 (setq gnus-article-mime-handles nil)))
6659 (gnus-kill-save-kill-buffer)
6660 (gnus-async-halt-prefetch)
6661 (let* ((group gnus-newsgroup-name)
6662 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6663 (gnus-group-is-exiting-p t)
6666 (buf (current-buffer)))
6668 ;; Do adaptive scoring, and possibly save score files.
6669 (when gnus-newsgroup-adaptive
6670 (gnus-score-adaptive))
6671 (when gnus-use-scoring
6673 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6674 ;; If we have several article buffers, we kill them at exit.
6675 (unless gnus-single-article-buffer
6676 (gnus-kill-buffer gnus-original-article-buffer)
6677 (setq gnus-article-current nil))
6678 (when gnus-use-cache
6679 (gnus-cache-possibly-remove-articles)
6680 (gnus-cache-save-buffers))
6681 (gnus-async-prefetch-remove-group group)
6682 (when gnus-suppress-duplicates
6683 (gnus-dup-enter-articles))
6684 (when gnus-use-trees
6685 (gnus-tree-close group))
6686 (when gnus-use-cache
6687 (gnus-cache-write-active))
6688 ;; Remove entries for this group.
6689 (nnmail-purge-split-history (gnus-group-real-name group))
6690 ;; Make all changes in this group permanent.
6692 (gnus-run-hooks 'gnus-exit-group-hook)
6693 (gnus-summary-update-info))
6694 (gnus-close-group group)
6695 ;; Make sure where we were, and go to next newsgroup.
6696 (set-buffer gnus-group-buffer)
6698 (gnus-group-jump-to-group group))
6699 (gnus-run-hooks 'gnus-summary-exit-hook)
6700 (unless (or quit-config
6701 ;; If this group has disappeared from the summary
6702 ;; buffer, don't skip forwards.
6703 (not (string= group (gnus-group-group-name))))
6704 (gnus-group-next-unread-group 1))
6705 (setq group-point (point))
6708 ;; If we have several article buffers, we kill them at exit.
6709 (unless gnus-single-article-buffer
6710 (gnus-kill-buffer gnus-article-buffer)
6711 (gnus-kill-buffer gnus-original-article-buffer)
6712 (setq gnus-article-current nil))
6714 (if (not gnus-kill-summary-on-exit)
6716 (gnus-deaden-summary)
6718 ;; We set all buffer-local variables to nil. It is unclear why
6719 ;; this is needed, but if we don't, buffer-local variables are
6720 ;; not garbage-collected, it seems. This would the lead to en
6721 ;; ever-growing Emacs.
6722 (gnus-summary-clear-local-variables)
6723 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6724 (gnus-summary-clear-local-variables))
6725 (when (get-buffer gnus-article-buffer)
6726 (bury-buffer gnus-article-buffer))
6727 ;; Return to group mode buffer.
6728 (when (eq mode 'gnus-summary-mode)
6729 (gnus-kill-buffer buf)))
6730 (setq gnus-current-select-method gnus-select-method)
6731 (set-buffer gnus-group-buffer)
6733 (gnus-handle-ephemeral-exit quit-config)
6734 (goto-char group-point)
6735 ;; If gnus-group-buffer is already displayed, make sure we also move
6736 ;; the cursor in the window that displays it.
6737 (let ((win (get-buffer-window (current-buffer) 0)))
6738 (if win (set-window-point win (point))))
6739 (unless leave-hidden
6740 (gnus-configure-windows 'group 'force)))
6741 ;; Clear the current group name.
6743 (setq gnus-newsgroup-name nil)))))
6745 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6746 (defun gnus-summary-exit-no-update (&optional no-questions)
6747 "Quit reading current newsgroup without updating read article info."
6749 (let* ((group gnus-newsgroup-name)
6750 (gnus-group-is-exiting-p t)
6751 (gnus-group-is-exiting-without-update-p t)
6752 (quit-config (gnus-group-quit-config group)))
6753 (when (or no-questions
6755 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6756 (gnus-async-halt-prefetch)
6757 (run-hooks 'gnus-summary-prepare-exit-hook)
6758 (when (gnus-buffer-live-p gnus-article-buffer)
6760 (set-buffer gnus-article-buffer)
6761 (mm-destroy-parts gnus-article-mime-handles)
6762 ;; Set it to nil for safety reason.
6763 (setq gnus-article-mime-handle-alist nil)
6764 (setq gnus-article-mime-handles nil)))
6765 ;; If we have several article buffers, we kill them at exit.
6766 (unless gnus-single-article-buffer
6767 (gnus-kill-buffer gnus-article-buffer)
6768 (gnus-kill-buffer gnus-original-article-buffer)
6769 (setq gnus-article-current nil))
6770 (if (not gnus-kill-summary-on-exit)
6771 (gnus-deaden-summary)
6772 (gnus-close-group group)
6773 (gnus-summary-clear-local-variables)
6774 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6775 (gnus-summary-clear-local-variables))
6776 (gnus-kill-buffer gnus-summary-buffer))
6777 (unless gnus-single-article-buffer
6778 (setq gnus-article-current nil))
6779 (when gnus-use-trees
6780 (gnus-tree-close group))
6781 (gnus-async-prefetch-remove-group group)
6782 (when (get-buffer gnus-article-buffer)
6783 (bury-buffer gnus-article-buffer))
6784 ;; Return to the group buffer.
6785 (gnus-configure-windows 'group 'force)
6786 ;; Clear the current group name.
6787 (setq gnus-newsgroup-name nil)
6788 (unless (gnus-ephemeral-group-p group)
6789 (gnus-group-update-group group))
6790 (when (equal (gnus-group-group-name) group)
6791 (gnus-group-next-unread-group 1))
6793 (gnus-handle-ephemeral-exit quit-config)))))
6795 (defun gnus-handle-ephemeral-exit (quit-config)
6796 "Handle movement when leaving an ephemeral group.
6797 The state which existed when entering the ephemeral is reset."
6798 (if (not (buffer-name (car quit-config)))
6799 (gnus-configure-windows 'group 'force)
6800 (set-buffer (car quit-config))
6801 (cond ((eq major-mode 'gnus-summary-mode)
6802 (gnus-set-global-variables))
6803 ((eq major-mode 'gnus-article-mode)
6805 ;; The `gnus-summary-buffer' variable may point
6806 ;; to the old summary buffer when using a single
6808 (unless (gnus-buffer-live-p gnus-summary-buffer)
6809 (set-buffer gnus-group-buffer))
6810 (set-buffer gnus-summary-buffer)
6811 (gnus-set-global-variables))))
6812 (if (or (eq (cdr quit-config) 'article)
6813 (eq (cdr quit-config) 'pick))
6815 ;; The current article may be from the ephemeral group
6816 ;; thus it is best that we reload this article
6818 ;; If we're exiting from a large digest, this can be
6819 ;; extremely slow. So, it's better not to reload it. -- jh.
6820 ;;(gnus-summary-show-article)
6821 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6822 (gnus-configure-windows 'pick 'force)
6823 (gnus-configure-windows (cdr quit-config) 'force)))
6824 (gnus-configure-windows (cdr quit-config) 'force))
6825 (when (eq major-mode 'gnus-summary-mode)
6826 (gnus-summary-next-subject 1 nil t)
6827 (gnus-summary-recenter)
6828 (gnus-summary-position-point))))
6832 (defvar gnus-dead-summary-mode-map nil)
6834 (unless gnus-dead-summary-mode-map
6835 (setq gnus-dead-summary-mode-map (make-keymap))
6836 (suppress-keymap gnus-dead-summary-mode-map)
6837 (substitute-key-definition
6838 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6839 (dolist (key '("\C-d" "\r" "\177" [delete]))
6840 (define-key gnus-dead-summary-mode-map
6841 key 'gnus-summary-wake-up-the-dead))
6842 (dolist (key '("q" "Q"))
6843 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6845 (defvar gnus-dead-summary-mode nil
6846 "Minor mode for Gnus summary buffers.")
6848 (defun gnus-dead-summary-mode (&optional arg)
6849 "Minor mode for Gnus summary buffers."
6851 (when (eq major-mode 'gnus-summary-mode)
6852 (make-local-variable 'gnus-dead-summary-mode)
6853 (setq gnus-dead-summary-mode
6854 (if (null arg) (not gnus-dead-summary-mode)
6855 (> (prefix-numeric-value arg) 0)))
6856 (when gnus-dead-summary-mode
6858 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6860 (defun gnus-deaden-summary ()
6861 "Make the current summary buffer into a dead summary buffer."
6862 ;; Kill any previous dead summary buffer.
6863 (when (and gnus-dead-summary
6864 (buffer-name gnus-dead-summary))
6865 (with-current-buffer gnus-dead-summary
6866 (when gnus-dead-summary-mode
6867 (kill-buffer (current-buffer)))))
6868 ;; Make this the current dead summary.
6869 (setq gnus-dead-summary (current-buffer))
6870 (gnus-dead-summary-mode 1)
6871 (let ((name (buffer-name)))
6872 (when (string-match "Summary" name)
6874 (concat (substring name 0 (match-beginning 0)) "Dead "
6875 (substring name (match-beginning 0)))
6879 (defun gnus-kill-or-deaden-summary (buffer)
6880 "Kill or deaden the summary BUFFER."
6882 (when (and (buffer-name buffer)
6883 (not gnus-single-article-buffer))
6884 (with-current-buffer buffer
6885 (gnus-kill-buffer gnus-article-buffer)
6886 (gnus-kill-buffer gnus-original-article-buffer)))
6889 (gnus-kill-summary-on-exit
6890 (when (and gnus-use-trees
6891 (gnus-buffer-exists-p buffer))
6894 (gnus-tree-close gnus-newsgroup-name)))
6895 (gnus-kill-buffer buffer))
6896 ;; Deaden the buffer.
6897 ((gnus-buffer-exists-p buffer)
6900 (gnus-deaden-summary))))))
6902 (defun gnus-summary-wake-up-the-dead (&rest args)
6903 "Wake up the dead summary buffer."
6905 (gnus-dead-summary-mode -1)
6906 (let ((name (buffer-name)))
6907 (when (string-match "Dead " name)
6909 (concat (substring name 0 (match-beginning 0))
6910 (substring name (match-end 0)))
6912 (gnus-message 3 "This dead summary is now alive again"))
6914 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6915 (defun gnus-summary-fetch-faq (&optional faq-dir)
6916 "Fetch the FAQ for the current group.
6917 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6921 (when current-prefix-arg
6923 "FAQ dir: " (and (listp gnus-group-faq-directory)
6925 gnus-group-faq-directory))))))
6926 (let (gnus-faq-buffer)
6927 (when (setq gnus-faq-buffer
6928 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6929 (gnus-configure-windows 'summary-faq))))
6931 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6932 (defun gnus-summary-describe-group (&optional force)
6933 "Describe the current newsgroup."
6935 (gnus-group-describe-group force gnus-newsgroup-name))
6937 (defun gnus-summary-describe-briefly ()
6938 "Describe summary mode commands briefly."
6940 (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")))
6942 ;; Walking around group mode buffer from summary mode.
6944 (defun gnus-summary-next-group (&optional no-article target-group backward)
6945 "Exit current newsgroup and then select next unread newsgroup.
6946 If prefix argument NO-ARTICLE is non-nil, no article is selected
6947 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6948 previous group instead."
6950 ;; Stop pre-fetching.
6951 (gnus-async-halt-prefetch)
6952 (let ((current-group gnus-newsgroup-name)
6953 (current-buffer (current-buffer))
6955 ;; First we semi-exit this group to update Xrefs and all variables.
6956 ;; We can't do a real exit, because the window conf must remain
6957 ;; the same in case the user is prompted for info, and we don't
6958 ;; want the window conf to change before that...
6959 (gnus-summary-exit t)
6960 (while (not entered)
6961 ;; Then we find what group we are supposed to enter.
6962 (set-buffer gnus-group-buffer)
6963 (gnus-group-jump-to-group current-group)
6966 (if (eq gnus-keep-same-level 'best)
6967 (gnus-summary-best-group gnus-newsgroup-name)
6968 (gnus-summary-search-group backward gnus-keep-same-level))))
6969 (if (not target-group)
6970 ;; There are no further groups, so we return to the group
6973 (gnus-message 5 "Returning to the group buffer")
6975 (when (gnus-buffer-live-p current-buffer)
6976 (set-buffer current-buffer)
6977 (gnus-summary-exit))
6978 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6979 ;; We try to enter the target group.
6980 (gnus-group-jump-to-group target-group)
6981 (let ((unreads (gnus-group-group-unread)))
6982 (if (and (or (eq t unreads)
6983 (and unreads (not (zerop unreads))))
6984 (gnus-summary-read-group
6985 target-group nil no-article
6986 (and (buffer-name current-buffer) current-buffer)
6989 (setq current-group target-group
6990 target-group nil)))))))
6992 (defun gnus-summary-prev-group (&optional no-article)
6993 "Exit current newsgroup and then select previous unread newsgroup.
6994 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6996 (gnus-summary-next-group no-article nil t))
6998 ;; Walking around summary lines.
7000 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7001 "Go to the first subject satisfying any non-nil constraint.
7002 If UNREAD is non-nil, the article should be unread.
7003 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7004 If UNSEEN is non-nil, the article should be unseen.
7005 Returns the article selected or nil if there are no matching articles."
7009 ((null gnus-newsgroup-data)
7010 (gnus-message 3 "No articles in the group")
7012 ;; Pick the first article.
7013 ((not (or unread undownloaded unseen))
7014 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7015 (gnus-data-number (car gnus-newsgroup-data)))
7016 ;; Find the first unread article.
7018 (let ((data gnus-newsgroup-data))
7020 (let ((num (gnus-data-number (car data))))
7021 (or (memq num gnus-newsgroup-unfetched)
7022 (not (or (and unread
7023 (memq num gnus-newsgroup-unreads))
7025 (memq num gnus-newsgroup-undownloaded))
7027 (memq num gnus-newsgroup-unseen)))))))
7028 (setq data (cdr data)))
7032 (goto-char (gnus-data-pos (car data)))
7033 (gnus-data-number (car data)))
7034 (gnus-message 3 "No more%s articles"
7035 (let* ((r (when unread " unread"))
7036 (d (when undownloaded " undownloaded"))
7037 (s (when unseen " unseen"))
7038 (l (delq nil (list r d s))))
7039 (cond ((= 3 (length l))
7040 (concat r "," d ", or" s))
7042 (concat (car l) ", or" (cadr l)))
7049 (gnus-summary-position-point))))))
7051 (defun gnus-summary-next-subject (n &optional unread dont-display)
7052 "Go to next N'th summary line.
7053 If N is negative, go to the previous N'th subject line.
7054 If UNREAD is non-nil, only unread articles are selected.
7055 The difference between N and the actual number of steps taken is
7058 (let ((backward (< n 0))
7062 (gnus-summary-find-prev unread)
7063 (gnus-summary-find-next unread)))
7064 (unless (zerop (setq n (1- n)))
7065 (gnus-summary-show-thread)))
7067 (gnus-message 7 "No more%s articles"
7068 (if unread " unread" "")))
7069 (unless dont-display
7070 (gnus-summary-recenter)
7071 (gnus-summary-position-point))
7074 (defun gnus-summary-next-unread-subject (n)
7075 "Go to next N'th unread summary line."
7077 (gnus-summary-next-subject n t))
7079 (defun gnus-summary-prev-subject (n &optional unread)
7080 "Go to previous N'th summary line.
7081 If optional argument UNREAD is non-nil, only unread article is selected."
7083 (gnus-summary-next-subject (- n) unread))
7085 (defun gnus-summary-prev-unread-subject (n)
7086 "Go to previous N'th unread summary line."
7088 (gnus-summary-next-subject (- n) t))
7090 (defun gnus-summary-goto-subjects (articles)
7091 "Insert the subject header for ARTICLES in the current buffer."
7093 (dolist (article articles)
7094 (gnus-summary-goto-subject article t)))
7095 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7096 (gnus-summary-position-point))
7098 (defun gnus-summary-goto-subject (article &optional force silent)
7099 "Go the subject line of ARTICLE.
7100 If FORCE, also allow jumping to articles not currently shown."
7101 (interactive "nArticle number: ")
7102 (unless (numberp article)
7103 (error "Article %s is not a number" article))
7105 (data (gnus-data-find article)))
7106 ;; We read in the article if we have to.
7109 (gnus-summary-insert-subject
7111 (if (or (numberp force) (vectorp force)) force)
7113 (setq data (gnus-data-find article)))
7118 (gnus-message 3 "Can't find article %d" article))
7120 (let ((pt (gnus-data-pos data)))
7122 (gnus-summary-set-article-display-arrow pt))
7123 (gnus-summary-position-point)
7126 ;; Walking around summary lines with displaying articles.
7128 (defun gnus-summary-expand-window (&optional arg)
7129 "Make the summary buffer take up the entire Emacs frame.
7130 Given a prefix, will force an `article' buffer configuration."
7133 (gnus-configure-windows 'article 'force)
7134 (gnus-configure-windows 'summary 'force)))
7136 (defun gnus-summary-display-article (article &optional all-header)
7137 "Display ARTICLE in article buffer."
7138 (when (gnus-buffer-live-p gnus-article-buffer)
7139 (with-current-buffer gnus-article-buffer
7140 (mm-enable-multibyte)))
7141 (gnus-set-global-variables)
7142 (when (gnus-buffer-live-p gnus-article-buffer)
7143 (with-current-buffer gnus-article-buffer
7144 (setq gnus-article-charset gnus-newsgroup-charset)
7145 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7146 (mm-enable-multibyte)))
7150 (if gnus-summary-display-article-function
7151 (funcall gnus-summary-display-article-function article all-header)
7152 (gnus-article-prepare article all-header))
7153 (gnus-run-hooks 'gnus-select-article-hook)
7154 (when (and gnus-current-article
7155 (not (zerop gnus-current-article)))
7156 (gnus-summary-goto-subject gnus-current-article))
7157 (gnus-summary-recenter)
7158 (when (and gnus-use-trees gnus-show-threads)
7159 (gnus-possibly-generate-tree article)
7160 (gnus-highlight-selected-tree article))
7161 ;; Successfully display article.
7162 (gnus-article-set-window-start
7163 (cdr (assq article gnus-newsgroup-bookmarks))))))
7165 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7166 "Select the current article.
7167 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7168 non-nil, the article will be re-fetched even if it already present in
7169 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7171 ;; Make sure we are in the summary buffer to work around bbdb bug.
7172 (unless (eq major-mode 'gnus-summary-mode)
7173 (set-buffer gnus-summary-buffer))
7174 (let ((article (or article (gnus-summary-article-number)))
7175 (all-headers (not (not all-headers))) ;Must be t or nil.
7176 gnus-summary-display-article-function)
7178 (gnus-summary-article-pseudo-p article)
7179 (error "This is a pseudo-article"))
7181 (set-buffer gnus-summary-buffer)
7182 (if (or (and gnus-single-article-buffer
7183 (or (null gnus-current-article)
7184 (null gnus-article-current)
7185 (null (get-buffer gnus-article-buffer))
7186 (not (eq article (cdr gnus-article-current)))
7187 (not (equal (car gnus-article-current)
7188 gnus-newsgroup-name))))
7189 (and (not gnus-single-article-buffer)
7190 (or (null gnus-current-article)
7191 (not (eq gnus-current-article article))))
7193 ;; The requested article is different from the current article.
7195 (gnus-summary-display-article article all-headers)
7196 (when (gnus-buffer-live-p gnus-article-buffer)
7197 (with-current-buffer gnus-article-buffer
7198 (if (not gnus-article-decoded-p) ;; a local variable
7199 (mm-disable-multibyte))))
7200 (gnus-article-set-window-start
7201 (cdr (assq article gnus-newsgroup-bookmarks)))
7205 (defun gnus-summary-force-verify-and-decrypt ()
7206 "Display buttons for signed/encrypted parts and verify/decrypt them."
7208 (let ((mm-verify-option 'known)
7209 (mm-decrypt-option 'known)
7210 (gnus-article-emulate-mime t)
7211 (gnus-buttonized-mime-types (append (list "multipart/signed"
7212 "multipart/encrypted")
7213 gnus-buttonized-mime-types)))
7214 (gnus-summary-select-article nil 'force)))
7216 (defun gnus-summary-set-current-mark (&optional current-mark)
7217 "Obsolete function."
7220 (defun gnus-summary-next-article (&optional unread subject backward push)
7221 "Select the next article.
7222 If UNREAD, only unread articles are selected.
7223 If SUBJECT, only articles with SUBJECT are selected.
7224 If BACKWARD, the previous article is selected instead of the next."
7227 ;; Is there such an article?
7228 ((and (gnus-summary-search-forward unread subject backward)
7229 (or (gnus-summary-display-article (gnus-summary-article-number))
7230 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7231 (gnus-summary-position-point))
7232 ;; If not, we try the first unread, if that is wanted.
7234 gnus-auto-select-same
7235 (gnus-summary-first-unread-article))
7236 (gnus-summary-position-point)
7237 (gnus-message 6 "Wrapped"))
7238 ;; Try to get next/previous article not displayed in this group.
7239 ((and gnus-auto-extend-newsgroup
7240 (not unread) (not subject))
7241 (gnus-summary-goto-article
7242 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7243 nil (count-lines (point-min) (point))))
7244 ;; Go to next/previous group.
7246 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7247 (gnus-summary-jump-to-group gnus-newsgroup-name))
7248 (let ((cmd last-command-char)
7250 (with-current-buffer gnus-group-buffer
7253 (if (eq gnus-keep-same-level 'best)
7254 (gnus-summary-best-group gnus-newsgroup-name)
7255 (gnus-summary-search-group backward gnus-keep-same-level))))
7256 ;; For some reason, the group window gets selected. We change
7258 (select-window (get-buffer-window (current-buffer)))
7259 ;; Select next unread newsgroup automagically.
7261 ((or (not gnus-auto-select-next)
7263 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7264 ((or (eq gnus-auto-select-next 'quietly)
7265 (and (eq gnus-auto-select-next 'slightly-quietly)
7267 (and (eq gnus-auto-select-next 'almost-quietly)
7268 (gnus-summary-last-article-p)))
7270 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7272 (gnus-message 7 "No more%s articles (%s)..."
7273 (if unread " unread" "")
7274 (if group (concat "selecting " group)
7276 (gnus-summary-next-group nil group backward)))
7278 (when (gnus-key-press-event-p last-input-event)
7279 (gnus-summary-walk-group-buffer
7280 gnus-newsgroup-name cmd unread backward point))))))))
7282 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7283 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7284 (?\C-p (gnus-group-prev-unread-group 1))))
7285 (cursor-in-echo-area t)
7286 keve key group ended prompt)
7288 (set-buffer gnus-group-buffer)
7291 (if (eq gnus-keep-same-level 'best)
7292 (gnus-summary-best-group gnus-newsgroup-name)
7293 (gnus-summary-search-group backward gnus-keep-same-level))))
7297 "No more%s articles%s " (if unread " unread" "")
7299 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7300 (format " (Type %s for %s [%s])"
7301 (single-key-description cmd)
7302 (gnus-group-decoded-name group)
7303 (gnus-group-unread group))
7304 (format " (Type %s to exit %s)"
7305 (single-key-description cmd)
7306 (gnus-group-decoded-name gnus-newsgroup-name)))))
7307 ;; Confirm auto selection.
7308 (setq key (car (setq keve (gnus-read-event-char prompt)))
7311 ((assq key keystrokes)
7312 (let ((obuf (current-buffer)))
7313 (switch-to-buffer gnus-group-buffer)
7315 (gnus-group-jump-to-group group))
7316 (eval (cadr (assq key keystrokes)))
7317 (setq group (gnus-group-group-name))
7318 (switch-to-buffer obuf))
7322 (gnus-ephemeral-group-p gnus-newsgroup-name))
7324 (gnus-summary-next-group nil group backward)))
7326 (push (cdr keve) unread-command-events))))))
7328 (defun gnus-summary-next-unread-article ()
7329 "Select unread article after current one."
7331 (gnus-summary-next-article
7332 (or (not (eq gnus-summary-goto-unread 'never))
7333 (gnus-summary-last-article-p (gnus-summary-article-number)))
7334 (and gnus-auto-select-same
7335 (gnus-summary-article-subject))))
7337 (defun gnus-summary-prev-article (&optional unread subject)
7338 "Select the article after the current one.
7339 If UNREAD is non-nil, only unread articles are selected."
7341 (gnus-summary-next-article unread subject t))
7343 (defun gnus-summary-prev-unread-article ()
7344 "Select unread article before current one."
7346 (gnus-summary-prev-article
7347 (or (not (eq gnus-summary-goto-unread 'never))
7348 (gnus-summary-first-article-p (gnus-summary-article-number)))
7349 (and gnus-auto-select-same
7350 (gnus-summary-article-subject))))
7352 (defun gnus-summary-next-page (&optional lines circular stop)
7353 "Show next page of the selected article.
7354 If at the end of the current article, select the next article.
7355 LINES says how many lines should be scrolled up.
7357 If CIRCULAR is non-nil, go to the start of the article instead of
7358 selecting the next article when reaching the end of the current
7361 If STOP is non-nil, just stop when reaching the end of the message.
7363 Also see the variable `gnus-article-skip-boring'."
7365 (setq gnus-summary-buffer (current-buffer))
7366 (gnus-set-global-variables)
7367 (let ((article (gnus-summary-article-number))
7368 (article-window (get-buffer-window gnus-article-buffer t))
7370 ;; If the buffer is empty, we have no article.
7372 (error "No article to select"))
7373 (gnus-configure-windows 'article)
7374 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7375 (if (and (eq gnus-summary-goto-unread 'never)
7376 (not (gnus-summary-last-article-p article)))
7377 (gnus-summary-next-article)
7378 (gnus-summary-next-unread-article))
7379 (if (or (null gnus-current-article)
7380 (null gnus-article-current)
7381 (/= article (cdr gnus-article-current))
7382 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7383 ;; Selected subject is different from current article's.
7384 (gnus-summary-display-article article)
7385 (when article-window
7386 (gnus-eval-in-buffer-window gnus-article-buffer
7387 (setq endp (or (gnus-article-next-page lines)
7388 (gnus-article-only-boring-p))))
7391 (gnus-message 3 "End of message"))
7393 (gnus-summary-beginning-of-article))
7395 (gnus-message 3 "End of message"))
7397 (if (and (eq gnus-summary-goto-unread 'never)
7398 (not (gnus-summary-last-article-p article)))
7399 (gnus-summary-next-article)
7400 (gnus-summary-next-unread-article))))))))
7401 (gnus-summary-recenter)
7402 (gnus-summary-position-point)))
7404 (defun gnus-summary-prev-page (&optional lines move)
7405 "Show previous page of selected article.
7406 Argument LINES specifies lines to be scrolled down.
7407 If MOVE, move to the previous unread article if point is at
7408 the beginning of the buffer."
7410 (let ((article (gnus-summary-article-number))
7411 (article-window (get-buffer-window gnus-article-buffer t))
7413 (gnus-configure-windows 'article)
7414 (if (or (null gnus-current-article)
7415 (null gnus-article-current)
7416 (/= article (cdr gnus-article-current))
7417 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7418 ;; Selected subject is different from current article's.
7419 (gnus-summary-display-article article)
7420 (gnus-summary-recenter)
7421 (when article-window
7422 (gnus-eval-in-buffer-window gnus-article-buffer
7423 (setq endp (gnus-article-prev-page lines)))
7424 (when (and move endp)
7426 (gnus-message 3 "Beginning of message"))
7428 (if (and (eq gnus-summary-goto-unread 'never)
7429 (not (gnus-summary-first-article-p article)))
7430 (gnus-summary-prev-article)
7431 (gnus-summary-prev-unread-article))))))))
7432 (gnus-summary-position-point))
7434 (defun gnus-summary-prev-page-or-article (&optional lines)
7435 "Show previous page of selected article.
7436 Argument LINES specifies lines to be scrolled down.
7437 If at the beginning of the article, go to the next article."
7439 (gnus-summary-prev-page lines t))
7441 (defun gnus-summary-scroll-up (lines)
7442 "Scroll up (or down) one line current article.
7443 Argument LINES specifies lines to be scrolled up (or down if negative)."
7445 (gnus-configure-windows 'article)
7446 (gnus-summary-show-thread)
7447 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7448 (gnus-eval-in-buffer-window gnus-article-buffer
7450 (when (gnus-article-next-page lines)
7451 (gnus-message 3 "End of message")))
7453 (gnus-article-prev-page (- lines))))))
7454 (gnus-summary-recenter)
7455 (gnus-summary-position-point))
7457 (defun gnus-summary-scroll-down (lines)
7458 "Scroll down (or up) one line current article.
7459 Argument LINES specifies lines to be scrolled down (or up if negative)."
7461 (gnus-summary-scroll-up (- lines)))
7463 (defun gnus-summary-next-same-subject ()
7464 "Select next article which has the same subject as current one."
7466 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7468 (defun gnus-summary-prev-same-subject ()
7469 "Select previous article which has the same subject as current one."
7471 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7473 (defun gnus-summary-next-unread-same-subject ()
7474 "Select next unread article which has the same subject as current one."
7476 (gnus-summary-next-article t (gnus-summary-article-subject)))
7478 (defun gnus-summary-prev-unread-same-subject ()
7479 "Select previous unread article which has the same subject as current one."
7481 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7483 (defun gnus-summary-first-unread-article ()
7484 "Select the first unread article.
7485 Return nil if there are no unread articles."
7488 (when (gnus-summary-first-subject t)
7489 (gnus-summary-show-thread)
7490 (gnus-summary-first-subject t)
7491 (gnus-summary-display-article (gnus-summary-article-number)))
7492 (gnus-summary-position-point)))
7494 (defun gnus-summary-first-unread-subject ()
7495 "Place the point on the subject line of the first unread article.
7496 Return nil if there are no unread articles."
7499 (when (gnus-summary-first-subject t)
7500 (gnus-summary-show-thread)
7501 (gnus-summary-first-subject t))
7502 (gnus-summary-position-point)))
7504 (defun gnus-summary-first-unseen-subject ()
7505 "Place the point on the subject line of the first unseen article.
7506 Return nil if there are no unseen articles."
7509 (when (gnus-summary-first-subject nil nil t)
7510 (gnus-summary-show-thread)
7511 (gnus-summary-first-subject nil nil t))
7512 (gnus-summary-position-point)))
7514 (defun gnus-summary-first-unseen-or-unread-subject ()
7515 "Place the point on the subject line of the first unseen article or,
7516 if all article have been seen, on the subject line of the first unread
7520 (unless (when (gnus-summary-first-subject nil nil t)
7521 (gnus-summary-show-thread)
7522 (gnus-summary-first-subject nil nil t))
7523 (when (gnus-summary-first-subject t)
7524 (gnus-summary-show-thread)
7525 (gnus-summary-first-subject t)))
7526 (gnus-summary-position-point)))
7528 (defun gnus-summary-first-article ()
7529 "Select the first article.
7530 Return nil if there are no articles."
7533 (when (gnus-summary-first-subject)
7534 (gnus-summary-show-thread)
7535 (gnus-summary-first-subject)
7536 (gnus-summary-display-article (gnus-summary-article-number)))
7537 (gnus-summary-position-point)))
7539 (defun gnus-summary-best-unread-article (&optional arg)
7540 "Select the unread article with the highest score.
7541 If given a prefix argument, select the next unread article that has a
7542 score higher than the default score."
7544 (let ((article (if arg
7545 (gnus-summary-better-unread-subject)
7546 (gnus-summary-best-unread-subject))))
7548 (gnus-summary-goto-article article)
7549 (error "No unread articles"))))
7551 (defun gnus-summary-best-unread-subject ()
7552 "Select the unread subject with the highest score."
7554 (let ((best -1000000)
7555 (data gnus-newsgroup-data)
7558 (and (gnus-data-unread-p (car data))
7560 (gnus-summary-article-score (gnus-data-number (car data))))
7563 article (gnus-data-number (car data))))
7564 (setq data (cdr data)))
7566 (gnus-summary-goto-subject article))
7567 (gnus-summary-position-point)
7570 (defun gnus-summary-better-unread-subject ()
7571 "Select the first unread subject that has a score over the default score."
7573 (let ((data gnus-newsgroup-data)
7575 (while (and (setq article (gnus-data-number (car data)))
7576 (or (gnus-data-read-p (car data))
7577 (not (> (gnus-summary-article-score article)
7578 gnus-summary-default-score))))
7579 (setq data (cdr data)))
7581 (gnus-summary-goto-subject article))
7582 (gnus-summary-position-point)
7585 (defun gnus-summary-last-subject ()
7586 "Go to the last displayed subject line in the group."
7587 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7589 (gnus-summary-goto-subject article))))
7591 (defun gnus-summary-goto-article (article &optional all-headers force)
7592 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7593 If ALL-HEADERS is non-nil, no header lines are hidden.
7594 If FORCE, go to the article even if it isn't displayed. If FORCE
7595 is a number, it is the line the article is to be displayed on."
7599 "Article number or Message-ID: "
7600 (mapcar (lambda (number) (list (int-to-string number)))
7601 gnus-newsgroup-limit))
7605 (if (and (stringp article)
7606 (string-match "@\\|%40" article))
7607 (gnus-summary-refer-article article)
7608 (when (stringp article)
7609 (setq article (string-to-number article)))
7610 (if (gnus-summary-goto-subject article force)
7611 (gnus-summary-display-article article all-headers)
7612 (gnus-message 4 "Couldn't go to article %s" article) nil))
7613 (gnus-summary-position-point)))
7615 (defun gnus-summary-goto-last-article ()
7616 "Go to the previously read article."
7619 (when gnus-last-article
7620 (gnus-summary-goto-article gnus-last-article nil t))
7621 (gnus-summary-position-point)))
7623 (defun gnus-summary-pop-article (number)
7624 "Pop one article off the history and go to the previous.
7625 NUMBER articles will be popped off."
7628 (setq gnus-newsgroup-history
7629 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7631 (gnus-summary-goto-article (car to) nil t)
7632 (error "Article history empty")))
7633 (gnus-summary-position-point))
7635 ;; Summary commands and functions for limiting the summary buffer.
7637 (defun gnus-summary-limit-to-articles (n)
7638 "Limit the summary buffer to the next N articles.
7639 If not given a prefix, use the process marked articles instead."
7642 (let ((articles (gnus-summary-work-articles n)))
7643 (setq gnus-newsgroup-processable nil)
7644 (gnus-summary-limit articles))
7645 (gnus-summary-position-point)))
7647 (defun gnus-summary-pop-limit (&optional total)
7648 "Restore the previous limit.
7649 If given a prefix, remove all limits."
7652 (setq gnus-newsgroup-limits
7653 (list (mapcar (lambda (h) (mail-header-number h))
7654 gnus-newsgroup-headers))))
7655 (unless gnus-newsgroup-limits
7656 (error "No limit to pop"))
7658 (gnus-summary-limit nil 'pop)
7659 (gnus-summary-position-point)))
7661 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7662 "Limit the summary buffer to articles that have subjects that match a regexp.
7663 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7665 (list (read-string (if current-prefix-arg
7666 "Exclude subject (regexp): "
7667 "Limit to subject (regexp): "))
7668 nil current-prefix-arg))
7670 (setq header "subject"))
7671 (when (not (equal "" subject))
7673 (let ((articles (gnus-summary-find-matching
7674 (or header "subject") subject 'all nil nil
7677 (error "Found no matches for \"%s\"" subject))
7678 (gnus-summary-limit articles))
7679 (gnus-summary-position-point))))
7681 (defun gnus-summary-limit-to-author (from &optional not-matching)
7682 "Limit the summary buffer to articles that have authors that match a regexp.
7683 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7685 (list (read-string (if current-prefix-arg
7686 "Exclude author (regexp): "
7687 "Limit to author (regexp): "))
7688 current-prefix-arg))
7689 (gnus-summary-limit-to-subject from "from" not-matching))
7691 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7692 "Limit the summary buffer to articles with the given RECIPIENT.
7694 If NOT-MATCHING, exclude RECIPIENT.
7696 To and Cc headers are checked. You need to include them in
7697 `nnmail-extra-headers'."
7698 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7700 (list (read-string (format "%s recipient (regexp): "
7701 (if current-prefix-arg "Exclude" "Limit to")))
7702 current-prefix-arg))
7703 (when (not (equal "" recipient))
7705 (if (memq 'To nnmail-extra-headers)
7706 (gnus-summary-find-matching
7707 (cons 'extra 'To) recipient 'all nil nil
7710 1 "`To' isn't present in `nnmail-extra-headers'")
7714 (if (memq 'Cc nnmail-extra-headers)
7715 (gnus-summary-find-matching
7716 (cons 'extra 'Cc) recipient 'all nil nil
7719 1 "`Cc' isn't present in `nnmail-extra-headers'")
7724 ;; We need the numbers that are in both lists:
7726 (and (memq a to) a))
7730 (error "Found no matches for \"%s\"" recipient))
7731 (gnus-summary-limit articles))
7732 (gnus-summary-position-point))))
7734 (defun gnus-summary-limit-to-age (age &optional younger-p)
7735 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7736 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7737 articles that are younger than AGE days."
7739 (let ((younger current-prefix-arg)
7742 (while (not days-got)
7743 (setq days (if younger
7744 (read-string "Limit to articles younger than (in days, older when negative): ")
7746 "Limit to articles older than (in days, younger when negative): ")))
7747 (when (> (length days) 0)
7748 (setq days (read days)))
7753 (setq younger (not younger))
7754 (setq days (* days -1))))
7755 (message "Please enter a number.")
7757 (list days younger)))
7759 (let ((data gnus-newsgroup-data)
7760 (cutoff (days-to-time age))
7761 articles d date is-younger)
7762 (while (setq d (pop data))
7763 (when (and (vectorp (gnus-data-header d))
7764 (setq date (mail-header-date (gnus-data-header d))))
7765 (setq is-younger (time-less-p
7766 (time-since (condition-case ()
7773 (push (gnus-data-number d) articles))))
7774 (gnus-summary-limit (nreverse articles)))
7775 (gnus-summary-position-point)))
7777 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7778 "Limit the summary buffer to articles that match an 'extra' header."
7782 (gnus-completing-read-with-default
7783 (symbol-name (car gnus-extra-headers))
7784 (if current-prefix-arg
7785 "Exclude extra header:"
7786 "Limit extra header:")
7788 (cons (symbol-name x) x))
7793 (read-string (format "%s header %s (regexp): "
7794 (if current-prefix-arg "Exclude" "Limit to")
7796 current-prefix-arg)))
7797 (when (not (equal "" regexp))
7799 (let ((articles (gnus-summary-find-matching
7800 (cons 'extra header) regexp 'all nil nil
7803 (error "Found no matches for \"%s\"" regexp))
7804 (gnus-summary-limit articles))
7805 (gnus-summary-position-point))))
7807 (defun gnus-summary-limit-to-display-predicate ()
7808 "Limit the summary buffer to the predicated in the `display' group parameter."
7810 (unless gnus-newsgroup-display
7811 (error "There is no `display' group parameter"))
7813 (dolist (number gnus-newsgroup-articles)
7814 (when (funcall gnus-newsgroup-display)
7815 (push number articles)))
7816 (gnus-summary-limit articles))
7817 (gnus-summary-position-point))
7819 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7821 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7823 (defun gnus-summary-limit-to-unread (&optional all)
7824 "Limit the summary buffer to articles that are not marked as read.
7825 If ALL is non-nil, limit strictly to unread articles."
7828 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7829 (gnus-summary-limit-to-marks
7830 ;; Concat all the marks that say that an article is read and have
7832 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7833 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7834 gnus-low-score-mark gnus-expirable-mark
7835 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7836 gnus-duplicate-mark gnus-souped-mark)
7839 (defun gnus-summary-limit-to-replied (&optional unreplied)
7840 "Limit the summary buffer to replied articles.
7841 If UNREPLIED (the prefix), limit to unreplied articles."
7845 (gnus-set-difference gnus-newsgroup-articles
7846 gnus-newsgroup-replied))
7847 (gnus-summary-limit gnus-newsgroup-replied))
7848 (gnus-summary-position-point))
7850 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7851 (make-obsolete 'gnus-summary-delete-marked-with
7852 'gnus-summary-limit-exclude-marks)
7854 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7855 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7856 If REVERSE, limit the summary buffer to articles that are marked
7857 with MARKS. MARKS can either be a string of marks or a list of marks.
7858 Returns how many articles were removed."
7859 (interactive "sMarks: ")
7860 (gnus-summary-limit-to-marks marks t))
7862 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7863 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7864 If REVERSE (the prefix), limit the summary buffer to articles that are
7865 not marked with MARKS. MARKS can either be a string of marks or a
7867 Returns how many articles were removed."
7868 (interactive "sMarks: \nP")
7870 (let ((data gnus-newsgroup-data)
7871 (marks (if (listp marks) marks
7872 (append marks nil))) ; Transform to list.
7875 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7876 (memq (gnus-data-mark (car data)) marks))
7877 (push (gnus-data-number (car data)) articles))
7878 (setq data (cdr data)))
7879 (gnus-summary-limit articles))
7880 (gnus-summary-position-point)))
7882 (defun gnus-summary-limit-to-score (score)
7883 "Limit to articles with score at or above SCORE."
7884 (interactive "NLimit to articles with score of at least: ")
7885 (let ((data gnus-newsgroup-data)
7888 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7890 (push (gnus-data-number (car data)) articles))
7891 (setq data (cdr data)))
7893 (gnus-summary-limit articles)
7894 (gnus-summary-position-point))))
7896 (defun gnus-summary-limit-to-unseen ()
7897 "Limit to unseen articles."
7900 (gnus-summary-limit gnus-newsgroup-unseen)
7901 (gnus-summary-position-point)))
7903 (defun gnus-summary-limit-include-thread (id)
7904 "Display all the hidden articles that is in the thread with ID in it.
7905 When called interactively, ID is the Message-ID of the current
7907 (interactive (list (mail-header-id (gnus-summary-article-header))))
7908 (let ((articles (gnus-articles-in-thread
7909 (gnus-id-to-thread (gnus-root-id id)))))
7911 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7912 (gnus-summary-limit-include-matching-articles
7914 (regexp-quote (gnus-simplify-subject-re
7915 (mail-header-subject (gnus-id-to-header id)))))
7916 (gnus-summary-position-point))))
7918 (defun gnus-summary-limit-include-matching-articles (header regexp)
7919 "Display all the hidden articles that have HEADERs that match REGEXP."
7920 (interactive (list (read-string "Match on header: ")
7921 (read-string "Regexp: ")))
7922 (let ((articles (gnus-find-matching-articles header regexp)))
7924 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7925 (gnus-summary-position-point))))
7927 (defun gnus-summary-insert-dormant-articles ()
7928 "Insert all the dormant articles for this group into the current buffer."
7930 (let ((gnus-verbose (max 6 gnus-verbose)))
7931 (if (not gnus-newsgroup-dormant)
7932 (gnus-message 3 "No cached articles for this group")
7933 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7935 (defun gnus-summary-limit-include-dormant ()
7936 "Display all the hidden articles that are marked as dormant.
7937 Note that this command only works on a subset of the articles currently
7938 fetched for this group."
7940 (unless gnus-newsgroup-dormant
7941 (error "There are no dormant articles in this group"))
7943 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7944 (gnus-summary-position-point)))
7946 (defun gnus-summary-limit-exclude-dormant ()
7947 "Hide all dormant articles."
7950 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7951 (gnus-summary-position-point)))
7953 (defun gnus-summary-limit-exclude-childless-dormant ()
7954 "Hide all dormant articles that have no children."
7956 (let ((data (gnus-data-list t))
7957 articles d children)
7958 ;; Find all articles that are either not dormant or have
7960 (while (setq d (pop data))
7961 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7963 (gnus-article-children (gnus-data-number d)))
7966 (when (memq (car children) articles)
7971 (push (gnus-data-number d) articles)))
7974 (gnus-summary-limit articles)
7975 (gnus-summary-position-point))))
7977 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7978 "Mark all unread excluded articles as read.
7979 If ALL, mark even excluded ticked and dormants as read."
7981 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7982 (let ((articles (gnus-sorted-ndifference
7984 (mapcar (lambda (h) (mail-header-number h))
7985 gnus-newsgroup-headers)
7987 gnus-newsgroup-limit))
7989 (setq gnus-newsgroup-unreads
7990 (gnus-sorted-intersection gnus-newsgroup-unreads
7991 gnus-newsgroup-limit))
7993 (setq gnus-newsgroup-dormant nil
7994 gnus-newsgroup-marked nil
7995 gnus-newsgroup-reads
7997 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7998 gnus-newsgroup-reads))
7999 (while (setq article (pop articles))
8000 (unless (or (memq article gnus-newsgroup-dormant)
8001 (memq article gnus-newsgroup-marked))
8002 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8004 (defun gnus-summary-limit (articles &optional pop)
8006 ;; We pop the previous limit off the stack and use that.
8007 (setq articles (car gnus-newsgroup-limits)
8008 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8009 ;; We use the new limit, so we push the old limit on the stack.
8010 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8012 (setq gnus-newsgroup-limit articles)
8013 (let ((total (length gnus-newsgroup-data))
8014 (data (gnus-data-find-list (gnus-summary-article-number)))
8015 (gnus-summary-mark-below nil) ; Inhibit this.
8017 ;; This will do all the work of generating the new summary buffer
8018 ;; according to the new limit.
8019 (gnus-summary-prepare)
8020 ;; Hide any threads, possibly.
8021 (gnus-summary-maybe-hide-threads)
8022 ;; Try to return to the article you were at, or one in the
8025 ;; We try to find some article after the current one.
8027 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8030 (setq data (cdr data))))
8032 ;; If there is no data, that means that we were after the last
8033 ;; article. The same goes when we can't find any articles
8034 ;; after the current one.
8035 (goto-char (point-max))
8036 (gnus-summary-find-prev))
8037 (gnus-set-mode-line 'summary)
8038 ;; We return how many articles were removed from the summary
8039 ;; buffer as a result of the new limit.
8040 (- total (length gnus-newsgroup-data))))
8042 (defsubst gnus-invisible-cut-children (threads)
8045 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8050 (defsubst gnus-cut-thread (thread)
8051 "Go forwards in the thread until we find an article that we want to display."
8052 (when (or (eq gnus-fetch-old-headers 'some)
8053 (eq gnus-fetch-old-headers 'invisible)
8054 (numberp gnus-fetch-old-headers)
8055 (eq gnus-build-sparse-threads 'some)
8056 (eq gnus-build-sparse-threads 'more))
8057 ;; Deal with old-fetched headers and sparse threads.
8061 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8062 (gnus-summary-article-ancient-p
8063 (mail-header-number (car thread))))
8064 (if (or (<= (length (cdr thread)) 1)
8065 (eq gnus-fetch-old-headers 'invisible))
8066 (setq gnus-newsgroup-limit
8067 (delq (mail-header-number (car thread))
8068 gnus-newsgroup-limit)
8069 thread (cadr thread))
8070 (when (gnus-invisible-cut-children (cdr thread))
8071 (let ((th (cdr thread)))
8073 (if (memq (mail-header-number (caar th))
8074 gnus-newsgroup-limit)
8075 (setq thread (car th)
8077 (setq th (cdr th))))))))))
8080 (defun gnus-cut-threads (threads)
8081 "Cut off all uninteresting articles from the beginning of THREADS."
8082 (when (or (eq gnus-fetch-old-headers 'some)
8083 (eq gnus-fetch-old-headers 'invisible)
8084 (numberp gnus-fetch-old-headers)
8085 (eq gnus-build-sparse-threads 'some)
8086 (eq gnus-build-sparse-threads 'more))
8089 (setcar th (gnus-cut-thread (car th)))
8090 (setq th (cdr th)))))
8091 ;; Remove nixed out threads.
8094 (defun gnus-summary-initial-limit (&optional show-if-empty)
8095 "Figure out what the initial limit is supposed to be on group entry.
8096 This entails weeding out unwanted dormants, low-scored articles,
8097 fetch-old-headers verbiage, and so on."
8098 ;; Most groups have nothing to remove.
8099 (if (or gnus-inhibit-limiting
8100 (and (null gnus-newsgroup-dormant)
8101 (eq gnus-newsgroup-display 'gnus-not-ignore)
8102 (not (eq gnus-fetch-old-headers 'some))
8103 (not (numberp gnus-fetch-old-headers))
8104 (not (eq gnus-fetch-old-headers 'invisible))
8105 (null gnus-summary-expunge-below)
8106 (not (eq gnus-build-sparse-threads 'some))
8107 (not (eq gnus-build-sparse-threads 'more))
8108 (null gnus-thread-expunge-below)
8109 (not gnus-use-nocem)))
8111 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8112 (setq gnus-newsgroup-limit nil)
8115 (unless (car (symbol-value node))
8116 ;; These threads have no parents -- they are roots.
8117 (let ((nodes (cdr (symbol-value node)))
8120 (if (and gnus-thread-expunge-below
8121 (< (gnus-thread-total-score (car nodes))
8122 gnus-thread-expunge-below))
8123 (gnus-expunge-thread (pop nodes))
8124 (setq thread (pop nodes))
8125 (gnus-summary-limit-children thread))))))
8126 gnus-newsgroup-dependencies)
8127 ;; If this limitation resulted in an empty group, we might
8128 ;; pop the previous limit and use it instead.
8129 (when (and (not gnus-newsgroup-limit)
8131 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8132 gnus-newsgroup-limit))
8134 (defun gnus-summary-limit-children (thread)
8135 "Return 1 if this subthread is visible and 0 if it is not."
8136 ;; First we get the number of visible children to this thread. This
8137 ;; is done by recursing down the thread using this function, so this
8138 ;; will really go down to a leaf article first, before slowly
8139 ;; working its way up towards the root.
8141 (let* ((max-lisp-eval-depth 5000)
8144 (apply '+ (mapcar 'gnus-summary-limit-children
8147 (number (mail-header-number (car thread)))
8150 (not (memq number gnus-newsgroup-marked))
8152 ;; If this article is dormant and has absolutely no visible
8153 ;; children, then this article isn't visible.
8154 (and (memq number gnus-newsgroup-dormant)
8156 ;; If this is "fetch-old-headered" and there is no
8157 ;; visible children, then we don't want this article.
8158 (and (or (eq gnus-fetch-old-headers 'some)
8159 (numberp gnus-fetch-old-headers))
8160 (gnus-summary-article-ancient-p number)
8162 ;; If this is "fetch-old-headered" and `invisible', then
8163 ;; we don't want this article.
8164 (and (eq gnus-fetch-old-headers 'invisible)
8165 (gnus-summary-article-ancient-p number))
8166 ;; If this is a sparsely inserted article with no children,
8167 ;; we don't want it.
8168 (and (eq gnus-build-sparse-threads 'some)
8169 (gnus-summary-article-sparse-p number)
8171 ;; If we use expunging, and this article is really
8172 ;; low-scored, then we don't want this article.
8173 (when (and gnus-summary-expunge-below
8175 (or (cdr (assq number gnus-newsgroup-scored))
8176 gnus-summary-default-score))
8177 gnus-summary-expunge-below))
8178 ;; We increase the expunge-tally here, but that has
8179 ;; nothing to do with the limits, really.
8180 (incf gnus-newsgroup-expunged-tally)
8181 ;; We also mark as read here, if that's wanted.
8182 (when (and gnus-summary-mark-below
8183 (< score gnus-summary-mark-below))
8184 (setq gnus-newsgroup-unreads
8185 (delq number gnus-newsgroup-unreads))
8186 (if gnus-newsgroup-auto-expire
8187 (push number gnus-newsgroup-expirable)
8188 (push (cons number gnus-low-score-mark)
8189 gnus-newsgroup-reads)))
8191 ;; Do the `display' group parameter.
8192 (and gnus-newsgroup-display
8193 (not (funcall gnus-newsgroup-display)))
8194 ;; Check NoCeM things.
8195 (when (and gnus-use-nocem
8196 (gnus-nocem-unwanted-article-p
8197 (mail-header-id (car thread))))
8198 (setq gnus-newsgroup-unreads
8199 (delq number gnus-newsgroup-unreads))
8201 ;; Nope, invisible article.
8203 ;; Ok, this article is to be visible, so we add it to the limit
8205 (push number gnus-newsgroup-limit)
8208 (defun gnus-expunge-thread (thread)
8209 "Mark all articles in THREAD as read."
8210 (let* ((number (mail-header-number (car thread))))
8211 (incf gnus-newsgroup-expunged-tally)
8212 ;; We also mark as read here, if that's wanted.
8213 (setq gnus-newsgroup-unreads
8214 (delq number gnus-newsgroup-unreads))
8215 (if gnus-newsgroup-auto-expire
8216 (push number gnus-newsgroup-expirable)
8217 (push (cons number gnus-low-score-mark)
8218 gnus-newsgroup-reads)))
8219 ;; Go recursively through all subthreads.
8220 (mapcar 'gnus-expunge-thread (cdr thread)))
8222 ;; Summary article oriented commands
8224 (defun gnus-summary-refer-parent-article (n)
8225 "Refer parent article N times.
8226 If N is negative, go to ancestor -N instead.
8227 The difference between N and the number of articles fetched is returned."
8231 (when (not (natnump n))
8236 (setq header (gnus-summary-article-header))
8237 (if (and (eq (mail-header-number header)
8238 (cdr gnus-article-current))
8239 (equal gnus-newsgroup-name
8240 (car gnus-article-current)))
8241 ;; If we try to find the parent of the currently
8242 ;; displayed article, then we take a look at the actual
8243 ;; References header, since this is slightly more
8244 ;; reliable than the References field we got from the
8247 (set-buffer gnus-original-article-buffer)
8248 (nnheader-narrow-to-headers)
8249 (unless (setq ref (message-fetch-field "references"))
8250 (when (setq ref (message-fetch-field "in-reply-to"))
8251 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8254 ;; It's not the current article, so we take a bet on
8255 ;; the value we got from the server.
8256 (mail-header-references header)))
8258 (not (equal ref "")))
8259 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8260 (gnus-message 1 "Couldn't find parent"))
8261 (gnus-message 1 "No references in article %d"
8262 (gnus-summary-article-number))
8265 (gnus-summary-position-point)
8268 (defun gnus-summary-refer-references ()
8269 "Fetch all articles mentioned in the References header.
8270 Return the number of articles fetched."
8272 (let ((ref (mail-header-references (gnus-summary-article-header)))
8273 (current (gnus-summary-article-number))
8277 (error "No References in the current article")
8278 ;; For each Message-ID in the References header...
8279 (while (string-match "<[^>]*>" ref)
8281 ;; ... fetch that article.
8282 (gnus-summary-refer-article
8283 (prog1 (match-string 0 ref)
8284 (setq ref (substring ref (match-end 0))))))
8285 (gnus-summary-goto-subject current)
8286 (gnus-summary-position-point)
8289 (defun gnus-summary-refer-thread (&optional limit)
8290 "Fetch all articles in the current thread.
8291 If LIMIT (the numerical prefix), fetch that many old headers instead
8292 of what's specified by the `gnus-refer-thread-limit' variable."
8294 (let ((id (mail-header-id (gnus-summary-article-header)))
8295 (limit (if limit (prefix-numeric-value limit)
8296 gnus-refer-thread-limit)))
8297 (unless (eq gnus-fetch-old-headers 'invisible)
8298 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8299 ;; Retrieve the headers and read them in.
8300 (if (eq (if (numberp limit)
8301 (gnus-retrieve-headers
8303 (+ (mail-header-number
8304 (gnus-summary-article-header))
8306 gnus-newsgroup-end))
8307 gnus-newsgroup-name (* limit 2))
8308 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8310 (gnus-retrieve-headers (list gnus-newsgroup-end)
8311 gnus-newsgroup-name limit))
8313 (gnus-build-all-threads)
8314 (error "Can't fetch thread from back ends that don't support NOV"))
8315 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8316 (gnus-summary-limit-include-thread id)))
8318 (defun gnus-summary-refer-article (message-id)
8319 "Fetch an article specified by MESSAGE-ID."
8320 (interactive "sMessage-ID: ")
8321 (when (and (stringp message-id)
8322 (not (zerop (length message-id))))
8323 (setq message-id (gnus-replace-in-string message-id " " ""))
8324 ;; Construct the correct Message-ID if necessary.
8325 ;; Suggested by tale@pawl.rpi.edu.
8326 (unless (string-match "^<" message-id)
8327 (setq message-id (concat "<" message-id)))
8328 (unless (string-match ">$" message-id)
8329 (setq message-id (concat message-id ">")))
8330 ;; People often post MIDs from URLs, so unhex it:
8331 (unless (string-match "@" message-id)
8332 (setq message-id (gnus-url-unhex-string message-id)))
8333 (let* ((header (gnus-id-to-header message-id))
8335 (gnus-summary-article-sparse-p
8336 (mail-header-number header))
8337 (memq (mail-header-number header)
8338 gnus-newsgroup-limit)))
8341 ;; If the article is present in the buffer we just go to it.
8343 (or (not (gnus-summary-article-sparse-p
8344 (mail-header-number header)))
8347 (gnus-summary-goto-article
8348 (mail-header-number header) nil t)
8350 (gnus-summary-update-article (mail-header-number header)))))
8352 ;; We fetch the article.
8354 (dolist (gnus-override-method (gnus-refer-article-methods))
8355 (when (and (gnus-check-server gnus-override-method)
8356 ;; Fetch the header,
8357 (setq number (gnus-summary-insert-subject message-id)))
8358 ;; and display the article.
8359 (gnus-summary-select-article nil nil nil number)
8361 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8363 (defun gnus-refer-article-methods ()
8364 "Return a list of referable methods."
8366 ;; No method, so we default to current and native.
8367 ((null gnus-refer-article-method)
8368 (list gnus-current-select-method gnus-select-method))
8370 ((eq 'current gnus-refer-article-method)
8371 (list gnus-current-select-method))
8372 ;; List of select methods.
8373 ((not (and (symbolp (car gnus-refer-article-method))
8374 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8376 (dolist (method gnus-refer-article-method)
8377 (push (if (eq 'current method)
8378 gnus-current-select-method
8382 ;; One single select method.
8384 (list gnus-refer-article-method))))
8386 (defun gnus-summary-edit-parameters ()
8387 "Edit the group parameters of the current group."
8389 (gnus-group-edit-group gnus-newsgroup-name 'params))
8391 (defun gnus-summary-customize-parameters ()
8392 "Customize the group parameters of the current group."
8394 (gnus-group-customize gnus-newsgroup-name))
8396 (defun gnus-summary-enter-digest-group (&optional force)
8397 "Enter an nndoc group based on the current article.
8398 If FORCE, force a digest interpretation. If not, try
8399 to guess what the document format is."
8401 (let ((conf gnus-current-window-configuration))
8402 (save-window-excursion
8404 (let (gnus-article-prepare-hook
8405 gnus-display-mime-function
8407 (gnus-summary-select-article))))
8408 (setq gnus-current-window-configuration conf)
8409 (let* ((name (format "%s-%d"
8410 (gnus-group-prefixed-name
8411 gnus-newsgroup-name (list 'nndoc ""))
8412 (with-current-buffer gnus-summary-buffer
8413 gnus-current-article)))
8414 (ogroup gnus-newsgroup-name)
8415 (params (append (gnus-info-params (gnus-get-info ogroup))
8416 (list (cons 'to-group ogroup))
8417 (list (cons 'parent-group ogroup))
8418 (list (cons 'save-article-group ogroup))))
8419 (case-fold-search t)
8420 (buf (current-buffer))
8423 (set-buffer gnus-original-article-buffer)
8424 ;; Have the digest group inherit the main mail address of
8425 ;; the parent article.
8426 (when (setq to-address (or (gnus-fetch-field "reply-to")
8427 (gnus-fetch-field "from")))
8428 (setq params (append
8429 (list (cons 'to-address
8430 (funcall gnus-decode-encoded-word-function
8432 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8433 (insert-buffer-substring gnus-original-article-buffer)
8434 ;; Remove lines that may lead nndoc to misinterpret the
8437 (goto-char (point-min))
8438 (or (search-forward "\n\n" nil t) (point)))
8439 (goto-char (point-min))
8440 (delete-matching-lines "^Path:\\|^From ")
8443 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8444 (gnus-newsgroup-ephemeral-ignored-charsets
8445 gnus-newsgroup-ignored-charsets))
8446 (gnus-group-read-ephemeral-group
8447 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8449 ,(if force 'mbox 'guess)))
8451 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8453 ;; Make all postings to this group go to the parent group.
8454 (nconc (gnus-info-params (gnus-get-info name))
8456 ;; Couldn't select this doc group.
8457 (switch-to-buffer buf)
8458 (gnus-set-global-variables)
8459 (gnus-configure-windows 'summary)
8460 (gnus-message 3 "Article couldn't be entered?"))
8461 (kill-buffer dig)))))
8463 (defun gnus-summary-read-document (n)
8464 "Open a new group based on the current article(s).
8465 This will allow you to read digests and other similar
8466 documents as newsgroups.
8467 Obeys the standard process/prefix convention."
8469 (let* ((ogroup gnus-newsgroup-name)
8470 (params (append (gnus-info-params (gnus-get-info ogroup))
8471 (list (cons 'to-group ogroup))))
8472 group egroup groups vgroup)
8473 (dolist (article (gnus-summary-work-articles n))
8474 (setq group (format "%s-%d" gnus-newsgroup-name article))
8475 (gnus-summary-remove-process-mark article)
8476 (when (gnus-summary-display-article article)
8479 (insert-buffer-substring gnus-original-article-buffer)
8480 ;; Remove some headers that may lead nndoc to make
8482 (message-narrow-to-head)
8483 (goto-char (point-min))
8484 (delete-matching-lines "^Path:\\|^From ")
8487 (gnus-group-read-ephemeral-group
8488 group `(nndoc ,group (nndoc-address ,(current-buffer))
8489 (nndoc-article-type guess))
8492 ;; Make all postings to this group go to the parent group.
8493 (nconc (gnus-info-params (gnus-get-info egroup))
8495 (push egroup groups))
8496 ;; Couldn't select this doc group.
8497 (gnus-error 3 "Article couldn't be entered"))))))
8498 ;; Now we have selected all the documents.
8501 (error "None of the articles could be interpreted as documents"))
8502 ((gnus-group-read-ephemeral-group
8503 (setq vgroup (format
8504 "nnvirtual:%s-%s" gnus-newsgroup-name
8505 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8506 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8508 (cons (current-buffer) 'summary)))
8510 (error "Couldn't select virtual nndoc group")))))
8512 (defun gnus-summary-isearch-article (&optional regexp-p)
8513 "Do incremental search forward on the current article.
8514 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8516 (gnus-summary-select-article)
8517 (gnus-configure-windows 'article)
8518 (gnus-eval-in-buffer-window gnus-article-buffer
8521 (isearch-forward regexp-p))))
8523 (defun gnus-summary-search-article-forward (regexp &optional backward)
8524 "Search for an article containing REGEXP forward.
8525 If BACKWARD, search backward instead."
8528 (format "Search article %s (regexp%s): "
8529 (if current-prefix-arg "backward" "forward")
8530 (if gnus-last-search-regexp
8531 (concat ", default " gnus-last-search-regexp)
8533 current-prefix-arg))
8534 (if (string-equal regexp "")
8535 (setq regexp (or gnus-last-search-regexp ""))
8536 (setq gnus-last-search-regexp regexp)
8537 (setq gnus-article-before-search gnus-current-article))
8538 ;; Intentionally set gnus-last-article.
8539 (setq gnus-last-article gnus-article-before-search)
8540 (let ((gnus-last-article gnus-last-article))
8541 (if (gnus-summary-search-article regexp backward)
8542 (gnus-summary-show-thread)
8543 (signal 'search-failed (list regexp)))))
8545 (defun gnus-summary-search-article-backward (regexp)
8546 "Search for an article containing REGEXP backward."
8549 (format "Search article backward (regexp%s): "
8550 (if gnus-last-search-regexp
8551 (concat ", default " gnus-last-search-regexp)
8553 (gnus-summary-search-article-forward regexp 'backward))
8555 (defun gnus-summary-search-article (regexp &optional backward)
8556 "Search for an article containing REGEXP.
8557 Optional argument BACKWARD means do search for backward.
8558 `gnus-select-article-hook' is not called during the search."
8559 ;; We have to require this here to make sure that the following
8560 ;; dynamic binding isn't shadowed by autoloading.
8561 (require 'gnus-async)
8563 (let ((gnus-select-article-hook nil) ;Disable hook.
8564 (gnus-article-prepare-hook nil)
8565 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8566 (gnus-use-article-prefetch nil)
8567 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8568 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8570 (gnus-keep-backlog nil)
8571 (gnus-break-pages nil)
8572 (gnus-summary-display-arrow nil)
8573 (gnus-updated-mode-lines nil)
8574 (gnus-auto-center-summary nil)
8575 (sum (current-buffer))
8576 (gnus-display-mime-function nil)
8579 (gnus-save-hidden-threads
8580 (gnus-summary-select-article)
8581 (set-buffer gnus-article-buffer)
8582 (goto-char (window-point (get-buffer-window (current-buffer))))
8586 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8588 (re-search-backward regexp nil t)
8589 (re-search-forward regexp nil t))
8590 ;; We found the regexp.
8595 (get-buffer-window (current-buffer))
8599 (get-buffer-window (current-buffer))
8602 (setq point (point)))
8603 ;; We didn't find it, so we go to the next article.
8606 (while (eq found 'not)
8607 (if (not (if backward (gnus-summary-find-prev)
8608 (gnus-summary-find-next)))
8609 ;; No more articles.
8611 ;; Select the next article and adjust point.
8612 (unless (gnus-summary-article-sparse-p
8613 (gnus-summary-article-number))
8615 (gnus-summary-select-article)
8616 (set-buffer gnus-article-buffer)
8618 (goto-char (if backward (point-max) (point-min))))))))
8619 (gnus-message 7 ""))
8620 ;; Return whether we found the regexp.
8621 (when (eq found 'found)
8623 (gnus-summary-show-thread)
8624 (gnus-summary-goto-subject gnus-current-article)
8625 (gnus-summary-position-point)
8628 (defun gnus-find-matching-articles (header regexp)
8629 "Return a list of all articles that match REGEXP on HEADER.
8630 This search includes all articles in the current group that Gnus has
8631 fetched headers for, whether they are displayed or not."
8632 (let ((articles nil)
8633 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8634 (case-fold-search t))
8635 (dolist (header gnus-newsgroup-headers)
8636 (when (string-match regexp (funcall func header))
8637 (push (mail-header-number header) articles)))
8638 (nreverse articles)))
8640 (defun gnus-summary-find-matching (header regexp &optional backward unread
8641 not-case-fold not-matching)
8642 "Return a list of all articles that match REGEXP on HEADER.
8643 The search stars on the current article and goes forwards unless
8644 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8645 If UNREAD is non-nil, only unread articles will
8646 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8647 in the comparisons. If NOT-MATCHING, return a list of all articles that
8648 not match REGEXP on HEADER."
8649 (let ((case-fold-search (not not-case-fold))
8652 (if (eq (car header) 'extra)
8655 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8657 (error "%s is an invalid header" header))
8658 (unless (fboundp (intern (concat "mail-header-" header)))
8659 (error "%s is not a valid header" header))
8660 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8661 (dolist (d (if (eq backward 'all)
8663 (gnus-data-find-list
8664 (gnus-summary-article-number)
8665 (gnus-data-list backward))))
8666 (when (and (or (not unread) ; We want all articles...
8667 (gnus-data-unread-p d)) ; Or just unreads.
8668 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8672 (funcall func (gnus-data-header d))))
8673 (string-match regexp
8674 (funcall func (gnus-data-header d)))))
8675 (push (gnus-data-number d) articles))) ; Success!
8676 (nreverse articles)))
8678 (defun gnus-summary-execute-command (header regexp command &optional backward)
8679 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8680 If HEADER is an empty string (or nil), the match is done on the entire
8681 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8683 (list (let ((completion-ignore-case t))
8686 (mapcar (lambda (header) (list (format "%s" header)))
8688 '("Number" "Subject" "From" "Lines" "Date"
8689 "Message-ID" "Xref" "References" "Body")
8690 gnus-extra-headers))
8691 nil 'require-match))
8692 (read-string "Regexp: ")
8693 (read-key-sequence "Command: ")
8694 current-prefix-arg))
8695 (when (equal header "Body")
8697 ;; Hidden thread subtrees must be searched as well.
8698 (gnus-summary-show-all-threads)
8699 ;; We don't want to change current point nor window configuration.
8701 (save-window-excursion
8703 gnus-treat-strip-trailing-blank-lines
8704 gnus-treat-strip-leading-blank-lines
8705 gnus-treat-strip-multiple-blank-lines
8706 gnus-treat-hide-boring-headers
8707 gnus-treat-fold-newsgroups
8708 gnus-article-prepare-hook)
8709 (gnus-message 6 "Executing %s..." (key-description command))
8710 ;; We'd like to execute COMMAND interactively so as to give arguments.
8711 (gnus-execute header regexp
8712 `(call-interactively ',(key-binding command))
8714 (gnus-message 6 "Executing %s...done" (key-description command))))))
8716 (defun gnus-summary-beginning-of-article ()
8717 "Scroll the article back to the beginning."
8719 (gnus-summary-select-article)
8720 (gnus-configure-windows 'article)
8721 (gnus-eval-in-buffer-window gnus-article-buffer
8723 (goto-char (point-min))
8724 (when gnus-break-pages
8725 (gnus-narrow-to-page))))
8727 (defun gnus-summary-end-of-article ()
8728 "Scroll to the end of the article."
8730 (gnus-summary-select-article)
8731 (gnus-configure-windows 'article)
8732 (gnus-eval-in-buffer-window gnus-article-buffer
8734 (goto-char (point-max))
8736 (when gnus-break-pages
8737 (when (re-search-backward page-delimiter nil t)
8738 (narrow-to-region (match-end 0) (point-max)))
8739 (gnus-narrow-to-page))))
8741 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8742 "Truncate to LEN and quote all \"(\"'s in STRING."
8743 (gnus-replace-in-string (if (and len (> (length string) len))
8744 (substring string 0 len)
8748 (defun gnus-summary-print-article (&optional filename n)
8749 "Generate and print a PostScript image of the process-marked (mail) articles.
8751 If used interactively, print the current article if none are
8752 process-marked. With prefix arg, prompt the user for the name of the
8755 When used from Lisp, accept two optional args FILENAME and N. N means
8756 to print the next N articles. If N is negative, print the N previous
8757 articles. If N is nil and articles have been marked with the process
8758 mark, print these instead.
8760 If the optional first argument FILENAME is nil, send the image to the
8761 printer. If FILENAME is a string, save the PostScript image in a file with
8762 that name. If FILENAME is a number, prompt the user for the name of the file
8764 (interactive (list (ps-print-preprint current-prefix-arg)))
8765 (dolist (article (gnus-summary-work-articles n))
8766 (gnus-summary-select-article nil nil 'pseudo article)
8767 (gnus-eval-in-buffer-window gnus-article-buffer
8768 (gnus-print-buffer))
8769 (gnus-summary-remove-process-mark article))
8770 (ps-despool filename))
8772 (defun gnus-print-buffer ()
8773 (let ((buffer (generate-new-buffer " *print*")))
8776 (copy-to-buffer buffer (point-min) (point-max))
8778 (gnus-remove-text-with-property 'gnus-decoration)
8779 (when (gnus-visual-p 'article-highlight 'highlight)
8780 ;; Copy-to-buffer doesn't copy overlay. So redo
8782 (let ((gnus-article-buffer buffer))
8783 (gnus-article-highlight-citation t)
8784 (gnus-article-highlight-signature)
8785 (gnus-article-emphasize)
8786 (gnus-article-delete-invisible-text)))
8787 (let ((ps-left-header
8790 (gnus-summary-print-truncate-and-quote
8791 (mail-header-subject gnus-current-headers)
8794 (gnus-summary-print-truncate-and-quote
8795 (mail-header-from gnus-current-headers)
8799 "/pagenumberstring load"
8801 (mail-header-date gnus-current-headers) ")"))))
8802 (gnus-run-hooks 'gnus-ps-print-hook)
8805 (ps-spool-buffer-with-faces)
8806 (ps-spool-buffer)))))
8807 (kill-buffer buffer))))
8809 (defun gnus-summary-show-article (&optional arg)
8810 "Force redisplaying of the current article.
8811 If ARG (the prefix) is a number, show the article with the charset
8812 defined in `gnus-summary-show-article-charset-alist', or the charset
8814 If ARG (the prefix) is non-nil and not a number, show the raw article
8815 without any article massaging functions being run. Normally, the key
8816 strokes are `C-u g'."
8820 (gnus-summary-show-article t)
8821 (let ((gnus-newsgroup-charset
8822 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8823 (mm-read-coding-system
8824 "View as charset: " ;; actually it is coding system.
8825 (with-current-buffer gnus-article-buffer
8826 (mm-detect-coding-region (point) (point-max))))))
8827 (gnus-newsgroup-ignored-charsets 'gnus-all))
8828 (gnus-summary-select-article nil 'force)
8829 (let ((deps gnus-newsgroup-dependencies)
8832 (set-buffer gnus-original-article-buffer)
8834 (message-narrow-to-head)
8835 (setq head (buffer-string))
8836 (goto-char (point-min))
8837 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8838 (goto-char (point-max))
8840 (setq lines (1- (count-lines (point) (point-max))))))
8842 (insert (format "211 %d Article retrieved.\n"
8843 (cdr gnus-article-current)))
8845 (if lines (insert (format "Lines: %d\n" lines)))
8847 (let ((nntp-server-buffer (current-buffer)))
8848 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8849 (gnus-data-set-header
8850 (gnus-data-find (cdr gnus-article-current))
8852 (gnus-summary-update-article-line
8853 (cdr gnus-article-current) header)
8854 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8855 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8857 ;; Select the article the normal way.
8858 (gnus-summary-select-article nil 'force))
8860 ;; We have to require this here to make sure that the following
8861 ;; dynamic binding isn't shadowed by autoloading.
8862 (require 'gnus-async)
8864 ;; Bind the article treatment functions to nil.
8865 (let ((gnus-have-all-headers t)
8866 gnus-article-prepare-hook
8867 gnus-article-decode-hook
8868 gnus-display-mime-function
8870 ;; Destroy any MIME parts.
8871 (when (gnus-buffer-live-p gnus-article-buffer)
8873 (set-buffer gnus-article-buffer)
8874 (mm-destroy-parts gnus-article-mime-handles)
8875 ;; Set it to nil for safety reason.
8876 (setq gnus-article-mime-handle-alist nil)
8877 (setq gnus-article-mime-handles nil)))
8878 (gnus-summary-select-article nil 'force))))
8879 (gnus-summary-goto-subject gnus-current-article)
8880 (gnus-summary-position-point))
8882 (defun gnus-summary-show-raw-article ()
8883 "Show the raw article without any article massaging functions being run."
8885 (gnus-summary-show-article t))
8887 (defun gnus-summary-verbose-headers (&optional arg)
8888 "Toggle permanent full header display.
8889 If ARG is a positive number, turn header display on.
8890 If ARG is a negative number, turn header display off."
8892 (setq gnus-show-all-headers
8893 (cond ((or (not (numberp arg))
8895 (not gnus-show-all-headers))
8898 (gnus-summary-show-article))
8900 (defun gnus-summary-toggle-header (&optional arg)
8901 "Show the headers if they are hidden, or hide them if they are shown.
8902 If ARG is a positive number, show the entire header.
8903 If ARG is a negative number, hide the unwanted header lines."
8905 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8906 (get-buffer-window gnus-article-buffer t))))
8907 (with-current-buffer gnus-article-buffer
8909 (article-narrow-to-head)
8910 (let* ((buffer-read-only nil)
8911 (inhibit-point-motion-hooks t)
8912 (hidden (if (numberp arg)
8914 (or (not (looking-at "[^ \t\n]+:"))
8915 (gnus-article-hidden-text-p 'headers))))
8917 (delete-region (point-min) (point-max))
8918 (with-current-buffer gnus-original-article-buffer
8919 (goto-char (setq s (point-min)))
8920 (setq e (if (search-forward "\n\n" nil t)
8923 (insert-buffer-substring gnus-original-article-buffer s e)
8924 (run-hooks 'gnus-article-decode-hook)
8926 (let ((gnus-treat-hide-headers nil)
8927 (gnus-treat-hide-boring-headers nil))
8928 (gnus-delete-wash-type 'headers)
8929 (gnus-treat-article 'head))
8930 (gnus-treat-article 'head))
8933 (set-window-start window (goto-char (point-min))))
8934 (if gnus-break-pages
8935 (gnus-narrow-to-page)
8936 (when (gnus-visual-p 'page-marker)
8937 (let ((buffer-read-only nil))
8938 (gnus-remove-text-with-property 'gnus-prev)
8939 (gnus-remove-text-with-property 'gnus-next))))
8940 (gnus-set-mode-line 'article)))))
8942 (defun gnus-summary-show-all-headers ()
8943 "Make all header lines visible."
8945 (gnus-summary-toggle-header 1))
8947 (defun gnus-summary-caesar-message (&optional arg)
8948 "Caesar rotate the current article by 13.
8949 The numerical prefix specifies how many places to rotate each letter
8952 (gnus-summary-select-article)
8953 (let ((mail-header-separator ""))
8954 (gnus-eval-in-buffer-window gnus-article-buffer
8957 (let ((start (window-start))
8959 (message-caesar-buffer-body arg)
8960 (set-window-start (get-buffer-window (current-buffer)) start)))))
8961 ;; Create buttons and stuff...
8962 (gnus-treat-article nil))
8964 (defun gnus-summary-idna-message (&optional arg)
8965 "Decode IDNA encoded domain names in the current articles.
8966 IDNA encoded domain names looks like `xn--bar'. If a string
8967 remain unencoded after running this function, it is likely an
8968 invalid IDNA string (`xn--bar' is invalid).
8970 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
8971 installed for this command to work."
8973 (if (not (and (condition-case nil (require 'idna)
8975 (mm-coding-system-p 'utf-8)
8976 (executable-find (symbol-value 'idna-program))))
8978 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
8979 (gnus-summary-select-article)
8980 (let ((mail-header-separator ""))
8981 (gnus-eval-in-buffer-window gnus-article-buffer
8984 (let ((start (window-start))
8986 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
8987 (replace-match (idna-to-unicode (match-string 1))))
8988 (set-window-start (get-buffer-window (current-buffer)) start)))))))
8990 (autoload 'unmorse-region "morse"
8991 "Convert morse coded text in region to ordinary ASCII text."
8994 (defun gnus-summary-morse-message (&optional arg)
8995 "Morse decode the current article."
8997 (gnus-summary-select-article)
8998 (let ((mail-header-separator ""))
8999 (gnus-eval-in-buffer-window gnus-article-buffer
9003 (let ((pos (window-start))
9005 (goto-char (point-min))
9006 (when (message-goto-body)
9007 (gnus-narrow-to-body))
9008 (goto-char (point-min))
9009 (while (search-forward "·" (point-max) t)
9010 (replace-match "."))
9011 (unmorse-region (point-min) (point-max))
9013 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9015 (defun gnus-summary-stop-page-breaking ()
9016 "Stop page breaking in the current article."
9018 (gnus-summary-select-article)
9019 (gnus-eval-in-buffer-window gnus-article-buffer
9021 (when (gnus-visual-p 'page-marker)
9022 (let ((buffer-read-only nil))
9023 (gnus-remove-text-with-property 'gnus-prev)
9024 (gnus-remove-text-with-property 'gnus-next))
9025 (setq gnus-page-broken nil))))
9027 (defun gnus-summary-move-article (&optional n to-newsgroup
9028 select-method action)
9029 "Move the current article to a different newsgroup.
9030 If N is a positive number, move the N next articles.
9031 If N is a negative number, move the N previous articles.
9032 If N is nil and any articles have been marked with the process mark,
9033 move those articles instead.
9034 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9035 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9036 re-spool using this method.
9038 When called interactively with TO-NEWSGROUP being nil, the value of
9039 the variable `gnus-move-split-methods' is used for finding a default
9040 for the target newsgroup.
9042 For this function to work, both the current newsgroup and the
9043 newsgroup that you want to move to have to support the `request-move'
9044 and `request-accept' functions.
9046 ACTION can be either `move' (the default), `crosspost' or `copy'."
9049 (setq action 'move))
9050 ;; Check whether the source group supports the required functions.
9051 (cond ((and (eq action 'move)
9052 (not (gnus-check-backend-function
9053 'request-move-article gnus-newsgroup-name)))
9054 (error "The current group does not support article moving"))
9055 ((and (eq action 'crosspost)
9056 (not (gnus-check-backend-function
9057 'request-replace-article gnus-newsgroup-name)))
9058 (error "The current group does not support article editing")))
9059 (let ((articles (gnus-summary-work-articles n))
9060 (prefix (if (gnus-check-backend-function
9061 'request-move-article gnus-newsgroup-name)
9062 (funcall gnus-move-group-prefix-function
9063 gnus-newsgroup-name)
9065 (names '((move "Move" "Moving")
9066 (copy "Copy" "Copying")
9067 (crosspost "Crosspost" "Crossposting")))
9068 (copy-buf (save-excursion
9069 (nnheader-set-temp-buffer " *copy article*")))
9070 art-group to-method new-xref article to-groups articles-to-update-marks)
9071 (unless (assq action names)
9072 (error "Unknown action %s" action))
9073 ;; Read the newsgroup name.
9074 (when (and (not to-newsgroup)
9075 (not select-method))
9076 (if (and gnus-move-split-methods
9078 (and (memq gnus-current-article articles)
9079 (gnus-buffer-live-p gnus-original-article-buffer))))
9080 ;; When `gnus-move-split-methods' is non-nil, we have to
9081 ;; select an article to give `gnus-read-move-group-name' an
9082 ;; opportunity to suggest an appropriate default. However,
9083 ;; we needn't render or mark the article.
9084 (let ((gnus-display-mime-function nil)
9085 (gnus-article-prepare-hook nil)
9086 (gnus-mark-article-hook nil))
9087 (gnus-summary-select-article nil nil nil (car articles))))
9089 (gnus-read-move-group-name
9090 (cadr (assq action names))
9091 (symbol-value (intern (format "gnus-current-%s-group" action)))
9093 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9094 (setq to-method (or select-method
9095 (gnus-server-to-method
9096 (gnus-group-method to-newsgroup))))
9097 ;; Check the method we are to move this article to...
9098 (unless (gnus-check-backend-function
9099 'request-accept-article (car to-method))
9100 (error "%s does not support article copying" (car to-method)))
9101 (unless (gnus-check-server to-method)
9102 (error "Can't open server %s" (car to-method)))
9103 (gnus-message 6 "%s to %s: %s..."
9104 (caddr (assq action names))
9105 (or (car select-method) to-newsgroup) articles)
9107 (setq article (pop articles))
9111 ;; Move the article.
9113 ;; Remove this article from future suppression.
9114 (gnus-dup-unsuppress-article article)
9115 (let* ((from-method (gnus-find-method-for-group
9116 gnus-newsgroup-name))
9117 (to-method (gnus-find-method-for-group
9119 (move-is-internal (gnus-method-equal from-method to-method)))
9120 (gnus-request-move-article
9121 article ; Article to move
9122 gnus-newsgroup-name ; From newsgroup
9123 (nth 1 (gnus-find-method-for-group
9124 gnus-newsgroup-name)) ; Server
9125 (list 'gnus-request-accept-article
9126 to-newsgroup (list 'quote select-method)
9127 (not articles) t) ; Accept form
9128 (not articles) ; Only save nov last time
9129 move-is-internal))) ; is this move internal?
9130 ;; Copy the article.
9133 (set-buffer copy-buf)
9134 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9136 (nnheader-narrow-to-headers)
9137 (dolist (hdr gnus-copy-article-ignored-headers)
9138 (message-remove-header hdr t)))
9139 (gnus-request-accept-article
9140 to-newsgroup select-method (not articles) t))))
9141 ;; Crosspost the article.
9142 ((eq action 'crosspost)
9143 (let ((xref (message-tokenize-header
9144 (mail-header-xref (gnus-summary-article-header article))
9146 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9147 ":" (number-to-string article)))
9149 (setq xref (list (system-name))))
9152 (mapconcat 'identity
9153 (delete "Xref:" (delete new-xref xref))
9157 (set-buffer copy-buf)
9158 ;; First put the article in the destination group.
9159 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9160 (when (consp (setq art-group
9161 (gnus-request-accept-article
9162 to-newsgroup select-method (not articles))))
9163 (setq new-xref (concat new-xref " " (car art-group)
9165 (number-to-string (cdr art-group))))
9166 ;; Now we have the new Xrefs header, so we insert
9167 ;; it and replace the new article.
9168 (nnheader-replace-header "Xref" new-xref)
9169 (gnus-request-replace-article
9170 (cdr art-group) to-newsgroup (current-buffer))
9174 (gnus-message 1 "Couldn't %s article %s: %s"
9175 (cadr (assq action names)) article
9176 (nnheader-get-report (car to-method))))
9177 ((eq art-group 'junk)
9178 (when (eq action 'move)
9179 (gnus-summary-mark-article article gnus-canceled-mark)
9180 (gnus-message 4 "Deleted article %s" article)
9181 ;; run the delete hook
9182 (run-hook-with-args 'gnus-summary-article-delete-hook
9185 (assoc article (gnus-data-list nil)))
9186 gnus-newsgroup-name nil
9189 (let* ((pto-group (gnus-group-prefixed-name
9190 (car art-group) to-method))
9191 (info (gnus-get-info pto-group))
9192 (to-group (gnus-info-group info))
9194 ;; Update the group that has been moved to.
9196 (memq action '(move copy)))
9197 (unless (member to-group to-groups)
9198 (push to-group to-groups))
9200 (unless (memq article gnus-newsgroup-unreads)
9201 (push 'read to-marks)
9203 info (gnus-add-to-range (gnus-info-read info)
9204 (list (cdr art-group)))))
9206 ;; See whether the article is to be put in the cache.
9207 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9208 gnus-article-mark-lists
9209 (delete '(expirable . expire)
9210 (copy-sequence gnus-article-mark-lists))))
9211 (to-article (cdr art-group)))
9213 ;; Enter the article into the cache in the new group,
9214 ;; if that is required.
9215 (when gnus-use-cache
9216 (gnus-cache-possibly-enter-article
9218 (memq article gnus-newsgroup-marked)
9219 (memq article gnus-newsgroup-dormant)
9220 (memq article gnus-newsgroup-unreads)))
9222 (when gnus-preserve-marks
9223 ;; Copy any marks over to the new group.
9224 (when (and (equal to-group gnus-newsgroup-name)
9225 (not (memq article gnus-newsgroup-unreads)))
9226 ;; Mark this article as read in this group.
9227 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9228 (setcdr (gnus-active to-group) to-article)
9229 (setcdr gnus-newsgroup-active to-article))
9232 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9233 (when (memq article (symbol-value
9234 (intern (format "gnus-newsgroup-%s"
9236 (push (cdar marks) to-marks)
9237 ;; If the other group is the same as this group,
9238 ;; then we have to add the mark to the list.
9239 (when (equal to-group gnus-newsgroup-name)
9240 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9243 (intern (format "gnus-newsgroup-%s"
9245 ;; Copy the marks to other group.
9246 (gnus-add-marked-articles
9247 to-group (cdar marks) (list to-article) info)))
9248 (setq marks (cdr marks)))
9250 (gnus-request-set-mark
9251 to-group (list (list (list to-article) 'add to-marks))))
9254 (concat "(gnus-group-set-info '"
9255 (gnus-prin1-to-string (gnus-get-info to-group))
9258 ;; Update the Xref header in this article to point to
9259 ;; the new crossposted article we have just created.
9260 (when (eq action 'crosspost)
9262 (set-buffer copy-buf)
9263 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9264 (nnheader-replace-header "Xref" new-xref)
9265 (gnus-request-replace-article
9266 article gnus-newsgroup-name (current-buffer))))
9268 ;; run the move/copy/crosspost/respool hook
9269 (run-hook-with-args 'gnus-summary-article-move-hook
9272 (assoc article (gnus-data-list nil)))
9277 ;;;!!!Why is this necessary?
9278 (set-buffer gnus-summary-buffer)
9280 (gnus-summary-goto-subject article)
9281 (when (eq action 'move)
9282 (gnus-summary-mark-article article gnus-canceled-mark))))
9283 (push article articles-to-update-marks))
9285 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9286 ;; Re-activate all groups that have been moved to.
9288 (set-buffer gnus-group-buffer)
9289 (let ((gnus-group-marked to-groups))
9290 (gnus-group-get-new-news-this-group nil t)))
9292 (gnus-kill-buffer copy-buf)
9293 (gnus-summary-position-point)
9294 (gnus-set-mode-line 'summary)))
9296 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9297 "Copy the current article to some other group.
9298 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9299 When called interactively, if TO-NEWSGROUP is nil, use the value of
9300 the variable `gnus-move-split-methods' for finding a default target
9302 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9303 re-spool using this method."
9305 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9307 (defun gnus-summary-crosspost-article (&optional n)
9308 "Crosspost the current article to some other group."
9310 (gnus-summary-move-article n nil nil 'crosspost))
9312 (defcustom gnus-summary-respool-default-method nil
9313 "Default method type for respooling an article.
9314 If nil, use to the current newsgroup method."
9316 :group 'gnus-summary-mail)
9318 (defcustom gnus-summary-display-while-building nil
9319 "If non-nil, show and update the summary buffer as it's being built.
9320 If the value is t, update the buffer after every line is inserted. If
9321 the value is an integer (N), update the display every N lines."
9324 :type '(choice (const :tag "off" nil)
9326 (const :tag "frequently" t)))
9328 (defun gnus-summary-respool-article (&optional n method)
9329 "Respool the current article.
9330 The article will be squeezed through the mail spooling process again,
9331 which means that it will be put in some mail newsgroup or other
9332 depending on `nnmail-split-methods'.
9333 If N is a positive number, respool the N next articles.
9334 If N is a negative number, respool the N previous articles.
9335 If N is nil and any articles have been marked with the process mark,
9336 respool those articles instead.
9338 Respooling can be done both from mail groups and \"real\" newsgroups.
9339 In the former case, the articles in question will be moved from the
9340 current group into whatever groups they are destined to. In the
9341 latter case, they will be copied into the relevant groups."
9343 (list current-prefix-arg
9344 (let* ((methods (gnus-methods-using 'respool))
9346 (symbol-name (or gnus-summary-respool-default-method
9347 (car (gnus-find-method-for-group
9348 gnus-newsgroup-name)))))
9350 (gnus-completing-read-with-default
9351 methname "What backend do you want to use when respooling?"
9352 methods nil t nil 'gnus-mail-method-history))
9355 ((zerop (length (setq ms (gnus-servers-using-backend
9357 (list (intern method) ""))
9361 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9362 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9365 (error "No method given for respooling"))
9366 (if (assoc (symbol-name
9367 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9368 (gnus-methods-using 'respool))
9369 (gnus-summary-move-article n nil method)
9370 (gnus-summary-copy-article n nil method)))
9372 (defun gnus-summary-import-article (file &optional edit)
9373 "Import an arbitrary file into a mail newsgroup."
9374 (interactive "fImport file: \nP")
9375 (let ((group gnus-newsgroup-name)
9376 (now (current-time))
9377 atts lines group-art)
9378 (unless (gnus-check-backend-function 'request-accept-article group)
9379 (error "%s does not support article importing" group))
9380 (or (file-readable-p file)
9381 (not (file-regular-p file))
9382 (error "Can't read %s" file))
9384 (set-buffer (gnus-get-buffer-create " *import file*"))
9386 (nnheader-insert-file-contents file)
9387 (goto-char (point-min))
9388 (if (nnheader-article-p)
9390 (goto-char (point-min))
9391 (search-forward "\n\n" nil t)
9392 (narrow-to-region (point-min) (1- (point)))
9393 (goto-char (point-min))
9394 (unless (re-search-forward "^date:" nil t)
9395 (goto-char (point-max))
9396 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9397 ;; This doesn't look like an article, so we fudge some headers.
9398 (setq atts (file-attributes file)
9399 lines (count-lines (point-min) (point-max)))
9400 (insert "From: " (read-string "From: ") "\n"
9401 "Subject: " (read-string "Subject: ") "\n"
9402 "Date: " (message-make-date (nth 5 atts)) "\n"
9403 "Message-ID: " (message-make-message-id) "\n"
9404 "Lines: " (int-to-string lines) "\n"
9405 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9406 (setq group-art (gnus-request-accept-article group nil t))
9407 (kill-buffer (current-buffer)))
9408 (setq gnus-newsgroup-active (gnus-activate-group group))
9410 (gnus-summary-goto-article (cdr group-art) nil t)
9412 (gnus-summary-edit-article))))
9414 (defun gnus-summary-create-article ()
9415 "Create an article in a mail newsgroup."
9417 (let ((group gnus-newsgroup-name)
9418 (now (current-time))
9420 (unless (gnus-check-backend-function 'request-accept-article group)
9421 (error "%s does not support article importing" group))
9423 (set-buffer (gnus-get-buffer-create " *import file*"))
9425 (goto-char (point-min))
9426 ;; This doesn't look like an article, so we fudge some headers.
9427 (insert "From: " (read-string "From: ") "\n"
9428 "Subject: " (read-string "Subject: ") "\n"
9429 "Date: " (message-make-date now) "\n"
9430 "Message-ID: " (message-make-message-id) "\n")
9431 (setq group-art (gnus-request-accept-article group nil t))
9432 (kill-buffer (current-buffer)))
9433 (setq gnus-newsgroup-active (gnus-activate-group group))
9435 (gnus-summary-goto-article (cdr group-art) nil t)
9436 (gnus-summary-edit-article)))
9438 (defun gnus-summary-article-posted-p ()
9439 "Say whether the current (mail) article is available from news as well.
9440 This will be the case if the article has both been mailed and posted."
9442 (let ((id (mail-header-references (gnus-summary-article-header)))
9443 (gnus-override-method (car (gnus-refer-article-methods))))
9444 (if (gnus-request-head id "")
9445 (gnus-message 2 "The current message was found on %s"
9446 gnus-override-method)
9447 (gnus-message 2 "The current message couldn't be found on %s"
9448 gnus-override-method)
9451 (defun gnus-summary-expire-articles (&optional now)
9452 "Expire all articles that are marked as expirable in the current group."
9454 (when (and (not gnus-group-is-exiting-without-update-p)
9455 (gnus-check-backend-function
9456 'request-expire-articles gnus-newsgroup-name))
9457 ;; This backend supports expiry.
9458 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9459 (expirable (if total
9461 ;; We need to update the info for
9462 ;; this group for `gnus-list-of-read-articles'
9463 ;; to give us the right answer.
9464 (gnus-run-hooks 'gnus-exit-group-hook)
9465 (gnus-summary-update-info)
9466 (gnus-list-of-read-articles gnus-newsgroup-name))
9467 (setq gnus-newsgroup-expirable
9468 (sort gnus-newsgroup-expirable '<))))
9469 (expiry-wait (if now 'immediate
9470 (gnus-group-find-parameter
9471 gnus-newsgroup-name 'expiry-wait)))
9472 (nnmail-expiry-target
9473 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9474 nnmail-expiry-target))
9477 ;; There are expirable articles in this group, so we run them
9478 ;; through the expiry process.
9479 (gnus-message 6 "Expiring articles...")
9480 (unless (gnus-check-group gnus-newsgroup-name)
9481 (error "Can't open server for %s" gnus-newsgroup-name))
9482 ;; The list of articles that weren't expired is returned.
9485 (let ((nnmail-expiry-wait-function nil)
9486 (nnmail-expiry-wait expiry-wait))
9487 (setq es (gnus-request-expire-articles
9488 expirable gnus-newsgroup-name)))
9489 (setq es (gnus-request-expire-articles
9490 expirable gnus-newsgroup-name)))
9492 (setq gnus-newsgroup-expirable es))
9493 ;; We go through the old list of expirable, and mark all
9494 ;; really expired articles as nonexistent.
9495 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9496 (let ((gnus-use-cache nil))
9497 (dolist (article expirable)
9498 (when (and (not (memq article es))
9499 (gnus-data-find article))
9500 (gnus-summary-mark-article article gnus-canceled-mark)
9501 (run-hook-with-args 'gnus-summary-article-expire-hook
9504 (assoc article (gnus-data-list nil)))
9508 (gnus-message 6 "Expiring articles...done")))))
9510 (defun gnus-summary-expire-articles-now ()
9511 "Expunge all expirable articles in the current group.
9512 This means that *all* articles that are marked as expirable will be
9513 deleted forever, right now."
9515 (or gnus-expert-user
9517 "Are you really, really, really sure you want to delete all these messages? ")
9519 (gnus-summary-expire-articles t))
9521 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9522 (defun gnus-summary-delete-article (&optional n)
9523 "Delete the N next (mail) articles.
9524 This command actually deletes articles. This is not a marking
9525 command. The article will disappear forever from your life, never to
9528 If N is negative, delete backwards.
9529 If N is nil and articles have been marked with the process mark,
9530 delete these instead.
9532 If `gnus-novice-user' is non-nil you will be asked for
9533 confirmation before the articles are deleted."
9535 (unless (gnus-check-backend-function 'request-expire-articles
9536 gnus-newsgroup-name)
9537 (error "The current newsgroup does not support article deletion"))
9538 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9539 (error "Couldn't open server"))
9540 ;; Compute the list of articles to delete.
9541 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9542 (nnmail-expiry-target 'delete)
9544 (if (and gnus-novice-user
9545 (not (gnus-yes-or-no-p
9546 (format "Do you really want to delete %s forever? "
9547 (if (> (length articles) 1)
9548 (format "these %s articles" (length articles))
9551 ;; Delete the articles.
9552 (setq not-deleted (gnus-request-expire-articles
9553 articles gnus-newsgroup-name 'force))
9555 (gnus-summary-remove-process-mark (car articles))
9556 ;; The backend might not have been able to delete the article
9558 (unless (memq (car articles) not-deleted)
9559 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9560 (let* ((article (car articles))
9561 (ghead (gnus-data-header
9562 (assoc article (gnus-data-list nil)))))
9563 (run-hook-with-args 'gnus-summary-article-delete-hook
9564 'delete ghead gnus-newsgroup-name nil
9566 (setq articles (cdr articles)))
9568 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9569 (gnus-summary-position-point)
9570 (gnus-set-mode-line 'summary)
9573 (defun gnus-summary-edit-article (&optional arg)
9574 "Edit the current article.
9575 This will have permanent effect only in mail groups.
9576 If ARG is nil, edit the decoded articles.
9577 If ARG is 1, edit the raw articles.
9578 If ARG is 2, edit the raw articles even in read-only groups.
9579 If ARG is 3, edit the articles with the current handles.
9580 Otherwise, allow editing of articles even in read-only
9583 (let (force raw current-handles)
9592 (setq current-handles
9593 (and (gnus-buffer-live-p gnus-article-buffer)
9594 (with-current-buffer gnus-article-buffer
9596 gnus-article-mime-handles
9597 (setq gnus-article-mime-handles nil))))))
9600 (when (and raw (not force)
9601 (member gnus-newsgroup-name '("nndraft:delayed"
9604 (error "Can't edit the raw article in group %s"
9605 gnus-newsgroup-name))
9607 (set-buffer gnus-summary-buffer)
9608 (let ((mail-parse-charset gnus-newsgroup-charset)
9609 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9610 (gnus-set-global-variables)
9611 (when (and (not force)
9612 (gnus-group-read-only-p))
9613 (error "The current newsgroup does not support article editing"))
9614 (gnus-summary-show-article t)
9615 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9616 (with-current-buffer gnus-article-buffer
9617 (mm-enable-multibyte)))
9618 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9620 (gnus-article-edit-article
9623 (let ((mbl mml-buffer-list))
9624 (setq mml-buffer-list nil)
9625 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9626 (mime-to-mml ,'current-handles))
9627 (let ((mbl1 mml-buffer-list))
9628 (setq mml-buffer-list mbl)
9629 (set (make-local-variable 'mml-buffer-list) mbl1))
9630 (gnus-make-local-hook 'kill-buffer-hook)
9631 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9632 `(lambda (no-highlight)
9633 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9634 (message-options message-options)
9635 (message-options-set-recipient)
9636 (mail-parse-ignored-charsets
9637 ',gnus-newsgroup-ignored-charsets))
9638 ,(if (not raw) '(progn
9640 (mml-destroy-buffers)
9641 (remove-hook 'kill-buffer-hook
9642 'mml-destroy-buffers t)
9643 (kill-local-variable 'mml-buffer-list)))
9644 (gnus-summary-edit-article-done
9645 ,(or (mail-header-references gnus-current-headers) "")
9646 ,(gnus-group-read-only-p)
9647 ,gnus-summary-buffer no-highlight))))))))
9649 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9651 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9653 "Make edits to the current article permanent."
9656 ;; The buffer restriction contains the entire article if it exists.
9657 (when (article-goto-body)
9658 (let ((lines (count-lines (point) (point-max)))
9659 (length (- (point-max) (point)))
9660 (case-fold-search t)
9661 (body (copy-marker (point))))
9662 (goto-char (point-min))
9663 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9664 (delete-region (match-beginning 1) (match-end 1))
9665 (insert (number-to-string length)))
9666 (goto-char (point-min))
9667 (when (re-search-forward
9668 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9669 (delete-region (match-beginning 1) (match-end 1))
9670 (insert (number-to-string length)))
9671 (goto-char (point-min))
9672 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9673 (delete-region (match-beginning 1) (match-end 1))
9674 (insert (number-to-string lines))))))
9675 ;; Replace the article.
9676 (let ((buf (current-buffer)))
9678 (insert-buffer-substring buf)
9680 (if (and (not read-only)
9681 (not (gnus-request-replace-article
9682 (cdr gnus-article-current) (car gnus-article-current)
9683 (current-buffer) t)))
9684 (error "Couldn't replace article")
9685 ;; Update the summary buffer.
9687 (equal (message-tokenize-header references " ")
9688 (message-tokenize-header
9689 (or (message-fetch-field "references") "") " ")))
9690 ;; We only have to update this line.
9693 (message-narrow-to-head)
9694 (let ((head (buffer-string))
9697 (insert (format "211 %d Article retrieved.\n"
9698 (cdr gnus-article-current)))
9701 (let ((nntp-server-buffer (current-buffer)))
9702 (setq header (car (gnus-get-newsgroup-headers
9705 (set-buffer gnus-summary-buffer)
9706 (gnus-data-set-header
9707 (gnus-data-find (cdr gnus-article-current))
9709 (gnus-summary-update-article-line
9710 (cdr gnus-article-current) header)
9711 (if (gnus-summary-goto-subject
9712 (cdr gnus-article-current) nil t)
9713 (gnus-summary-update-secondary-mark
9714 (cdr gnus-article-current))))))))
9716 (set-buffer (or buffer gnus-summary-buffer))
9717 (gnus-summary-update-article (cdr gnus-article-current))
9718 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9719 (gnus-summary-update-secondary-mark
9720 (cdr gnus-article-current))))
9721 ;; Prettify the article buffer again.
9722 (unless no-highlight
9724 (set-buffer gnus-article-buffer)
9725 ;;;!!! Fix this -- article should be rehighlighted.
9726 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9727 (set-buffer gnus-original-article-buffer)
9728 (gnus-request-article
9729 (cdr gnus-article-current)
9730 (car gnus-article-current) (current-buffer))))
9731 ;; Prettify the summary buffer line.
9732 (when (gnus-visual-p 'summary-highlight 'highlight)
9733 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9735 (defun gnus-summary-edit-wash (key)
9736 "Perform editing command KEY in the article buffer."
9740 (message "%s" (concat (this-command-keys) "- "))
9743 (gnus-summary-edit-article)
9744 (execute-kbd-macro (concat (this-command-keys) key))
9745 (gnus-article-edit-done))
9749 (defun gnus-summary-respool-query (&optional silent trace)
9750 "Query where the respool algorithm would put this article."
9752 (let (gnus-mark-article-hook)
9753 (gnus-summary-select-article)
9755 (set-buffer gnus-original-article-buffer)
9756 (let ((groups (nnmail-article-group 'identity trace)))
9759 (message "This message would go to %s"
9760 (mapconcat 'car groups ", "))
9761 (message "This message would go to no groups"))
9764 (defun gnus-summary-respool-trace ()
9765 "Trace where the respool algorithm would put this article.
9766 Display a buffer showing all fancy splitting patterns which matched."
9768 (gnus-summary-respool-query nil t))
9770 ;; Summary marking commands.
9772 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9773 "Mark articles which has the same subject as read, and then select the next.
9774 If UNMARK is positive, remove any kind of mark.
9775 If UNMARK is negative, tick articles."
9778 (setq unmark (prefix-numeric-value unmark)))
9780 (gnus-summary-mark-same-subject
9781 (gnus-summary-article-subject) unmark)))
9782 ;; Select next unread article. If auto-select-same mode, should
9783 ;; select the first unread article.
9784 (gnus-summary-next-article t (and gnus-auto-select-same
9785 (gnus-summary-article-subject)))
9786 (gnus-message 7 "%d article%s marked as %s"
9787 count (if (= count 1) " is" "s are")
9788 (if unmark "unread" "read"))))
9790 (defun gnus-summary-kill-same-subject (&optional unmark)
9791 "Mark articles which has the same subject as read.
9792 If UNMARK is positive, remove any kind of mark.
9793 If UNMARK is negative, tick articles."
9796 (setq unmark (prefix-numeric-value unmark)))
9798 (gnus-summary-mark-same-subject
9799 (gnus-summary-article-subject) unmark)))
9800 ;; If marked as read, go to next unread subject.
9802 ;; Go to next unread subject.
9803 (gnus-summary-next-subject 1 t))
9804 (gnus-message 7 "%d articles are marked as %s"
9805 count (if unmark "unread" "read"))))
9807 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9808 "Mark articles with same SUBJECT as read, and return marked number.
9809 If optional argument UNMARK is positive, remove any kinds of marks.
9810 If optional argument UNMARK is negative, mark articles as unread instead."
9814 ((null unmark) ; Mark as read.
9817 (gnus-summary-mark-article-as-read gnus-killed-mark)
9818 (gnus-summary-show-thread) t)
9819 (gnus-summary-find-subject subject))
9820 (setq count (1+ count))))
9821 ((> unmark 0) ; Tick.
9824 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9825 (gnus-summary-show-thread) t)
9826 (gnus-summary-find-subject subject))
9827 (setq count (1+ count))))
9828 (t ; Mark as unread.
9831 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9832 (gnus-summary-show-thread) t)
9833 (gnus-summary-find-subject subject))
9834 (setq count (1+ count)))))
9835 (gnus-set-mode-line 'summary)
9836 ;; Return the number of marked articles.
9839 (defun gnus-summary-mark-as-processable (n &optional unmark)
9840 "Set the process mark on the next N articles.
9841 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9842 the process mark instead. The difference between N and the actual
9843 number of articles marked is returned."
9845 (if (and (null n) (gnus-region-active-p))
9846 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9847 (setq n (prefix-numeric-value n))
9848 (let ((backward (< n 0))
9853 (gnus-summary-remove-process-mark
9854 (gnus-summary-article-number))
9855 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9856 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9859 (gnus-message 7 "No more articles"))
9860 (gnus-summary-recenter)
9861 (gnus-summary-position-point)
9864 (defun gnus-summary-unmark-as-processable (n)
9865 "Remove the process mark from the next N articles.
9866 If N is negative, unmark backward instead. The difference between N and
9867 the actual number of articles unmarked is returned."
9869 (gnus-summary-mark-as-processable n t))
9871 (defun gnus-summary-unmark-all-processable ()
9872 "Remove the process mark from all articles."
9875 (while gnus-newsgroup-processable
9876 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9877 (gnus-summary-position-point))
9879 (defun gnus-summary-add-mark (article type)
9880 "Mark ARTICLE with a mark of TYPE."
9881 (let ((vtype (car (assq type gnus-article-mark-lists)))
9884 (error "No such mark type: %s" type)
9885 (setq var (intern (format "gnus-newsgroup-%s" type)))
9886 (set var (cons article (symbol-value var)))
9887 (if (memq type '(processable cached replied forwarded recent saved))
9888 (gnus-summary-update-secondary-mark article)
9889 ;;; !!! This is bogus. We should find out what primary
9890 ;;; !!! mark we want to set.
9891 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9893 (defun gnus-summary-mark-as-expirable (n)
9894 "Mark N articles forward as expirable.
9895 If N is negative, mark backward instead. The difference between N and
9896 the actual number of articles marked is returned."
9898 (gnus-summary-mark-forward n gnus-expirable-mark))
9900 (defun gnus-summary-mark-as-spam (n)
9901 "Mark N articles forward as spam.
9902 If N is negative, mark backward instead. The difference between N and
9903 the actual number of articles marked is returned."
9905 (gnus-summary-mark-forward n gnus-spam-mark))
9907 (defun gnus-summary-mark-article-as-replied (article)
9908 "Mark ARTICLE as replied to and update the summary line.
9909 ARTICLE can also be a list of articles."
9910 (interactive (list (gnus-summary-article-number)))
9911 (let ((articles (if (listp article) article (list article))))
9912 (dolist (article articles)
9913 (unless (numberp article)
9914 (error "%s is not a number" article))
9915 (push article gnus-newsgroup-replied)
9916 (let ((buffer-read-only nil))
9917 (when (gnus-summary-goto-subject article nil t)
9918 (gnus-summary-update-secondary-mark article))))))
9920 (defun gnus-summary-mark-article-as-forwarded (article)
9921 "Mark ARTICLE as forwarded and update the summary line.
9922 ARTICLE can also be a list of articles."
9923 (let ((articles (if (listp article) article (list article))))
9924 (dolist (article articles)
9925 (push article gnus-newsgroup-forwarded)
9926 (let ((buffer-read-only nil))
9927 (when (gnus-summary-goto-subject article nil t)
9928 (gnus-summary-update-secondary-mark article))))))
9930 (defun gnus-summary-set-bookmark (article)
9931 "Set a bookmark in current article."
9932 (interactive (list (gnus-summary-article-number)))
9933 (when (or (not (get-buffer gnus-article-buffer))
9934 (not gnus-current-article)
9935 (not gnus-article-current)
9936 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9937 (error "No current article selected"))
9938 ;; Remove old bookmark, if one exists.
9939 (gnus-pull article gnus-newsgroup-bookmarks)
9940 ;; Set the new bookmark, which is on the form
9941 ;; (article-number . line-number-in-body).
9944 (with-current-buffer gnus-article-buffer
9951 gnus-newsgroup-bookmarks)
9952 (gnus-message 6 "A bookmark has been added to the current article."))
9954 (defun gnus-summary-remove-bookmark (article)
9955 "Remove the bookmark from the current article."
9956 (interactive (list (gnus-summary-article-number)))
9957 ;; Remove old bookmark, if one exists.
9958 (if (not (assq article gnus-newsgroup-bookmarks))
9959 (gnus-message 6 "No bookmark in current article.")
9960 (gnus-pull article gnus-newsgroup-bookmarks)
9961 (gnus-message 6 "Removed bookmark.")))
9963 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9964 (defun gnus-summary-mark-as-dormant (n)
9965 "Mark N articles forward as dormant.
9966 If N is negative, mark backward instead. The difference between N and
9967 the actual number of articles marked is returned."
9969 (gnus-summary-mark-forward n gnus-dormant-mark))
9971 (defun gnus-summary-set-process-mark (article)
9972 "Set the process mark on ARTICLE and update the summary line."
9973 (setq gnus-newsgroup-processable
9975 (delq article gnus-newsgroup-processable)))
9976 (when (gnus-summary-goto-subject article)
9977 (gnus-summary-show-thread)
9978 (gnus-summary-goto-subject article)
9979 (gnus-summary-update-secondary-mark article)))
9981 (defun gnus-summary-remove-process-mark (&rest articles)
9982 "Remove the process mark from ARTICLES and update the summary line."
9983 (dolist (article articles)
9984 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9985 (when (gnus-summary-goto-subject article)
9986 (gnus-summary-show-thread)
9987 (gnus-summary-goto-subject article)
9988 (gnus-summary-update-secondary-mark article))))
9990 (defun gnus-summary-set-saved-mark (article)
9991 "Set the process mark on ARTICLE and update the summary line."
9992 (push article gnus-newsgroup-saved)
9993 (when (gnus-summary-goto-subject article)
9994 (gnus-summary-update-secondary-mark article)))
9996 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9997 "Mark N articles as read forwards.
9998 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9999 The difference between N and the actual number of articles marked is
10001 If NO-EXPIRE, auto-expiry will be inhibited."
10003 (gnus-summary-show-thread)
10004 (let ((backward (< n 0))
10005 (gnus-summary-goto-unread
10006 (and gnus-summary-goto-unread
10007 (not (eq gnus-summary-goto-unread 'never))
10008 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10009 gnus-ticked-mark gnus-dormant-mark)))))
10011 (mark (or mark gnus-del-mark)))
10012 (while (and (> n 0)
10013 (gnus-summary-mark-article nil mark no-expire)
10014 (zerop (gnus-summary-next-subject
10016 (and gnus-summary-goto-unread
10017 (not (eq gnus-summary-goto-unread 'never)))
10021 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10022 (gnus-summary-recenter)
10023 (gnus-summary-position-point)
10024 (gnus-set-mode-line 'summary)
10027 (defun gnus-summary-mark-article-as-read (mark)
10028 "Mark the current article quickly as read with MARK."
10029 (let ((article (gnus-summary-article-number)))
10030 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10031 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10032 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10033 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10034 (push (cons article mark) gnus-newsgroup-reads)
10035 ;; Possibly remove from cache, if that is used.
10036 (when gnus-use-cache
10037 (gnus-cache-enter-remove-article article))
10038 ;; Allow the backend to change the mark.
10039 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10040 ;; Check for auto-expiry.
10041 (when (and gnus-newsgroup-auto-expire
10042 (memq mark gnus-auto-expirable-marks))
10043 (setq mark gnus-expirable-mark)
10044 ;; Let the backend know about the mark change.
10045 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10046 (push article gnus-newsgroup-expirable))
10047 ;; Set the mark in the buffer.
10048 (gnus-summary-update-mark mark 'unread)
10051 (defun gnus-summary-mark-article-as-unread (mark)
10052 "Mark the current article quickly as unread with MARK."
10053 (let* ((article (gnus-summary-article-number))
10054 (old-mark (gnus-summary-article-mark article)))
10055 ;; Allow the backend to change the mark.
10056 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10057 (if (eq mark old-mark)
10061 (gnus-error 1 "Can't mark negative article numbers")
10063 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10064 (setq gnus-newsgroup-spam-marked
10065 (delq article gnus-newsgroup-spam-marked))
10066 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10067 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10068 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10069 (cond ((= mark gnus-ticked-mark)
10070 (setq gnus-newsgroup-marked
10071 (gnus-add-to-sorted-list gnus-newsgroup-marked
10073 ((= mark gnus-spam-mark)
10074 (setq gnus-newsgroup-spam-marked
10075 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10077 ((= mark gnus-dormant-mark)
10078 (setq gnus-newsgroup-dormant
10079 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10082 (setq gnus-newsgroup-unreads
10083 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10085 (gnus-pull article gnus-newsgroup-reads)
10087 ;; See whether the article is to be put in the cache.
10088 (and gnus-use-cache
10089 (vectorp (gnus-summary-article-header article))
10091 (gnus-cache-possibly-enter-article
10092 gnus-newsgroup-name article
10093 (= mark gnus-ticked-mark)
10094 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10097 (gnus-summary-update-mark mark 'unread)
10100 (defun gnus-summary-mark-article (&optional article mark no-expire)
10101 "Mark ARTICLE with MARK. MARK can be any character.
10102 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10103 `??' (dormant) and `?E' (expirable).
10104 If MARK is nil, then the default character `?r' is used.
10105 If ARTICLE is nil, then the article on the current line will be
10107 If NO-EXPIRE, auto-expiry will be inhibited."
10108 ;; The mark might be a string.
10109 (when (stringp mark)
10110 (setq mark (aref mark 0)))
10111 ;; If no mark is given, then we check auto-expiring.
10113 (setq mark gnus-del-mark))
10114 (when (and (not no-expire)
10115 gnus-newsgroup-auto-expire
10116 (memq mark gnus-auto-expirable-marks))
10117 (setq mark gnus-expirable-mark))
10118 (let ((article (or article (gnus-summary-article-number)))
10119 (old-mark (gnus-summary-article-mark article)))
10120 ;; Allow the backend to change the mark.
10121 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10122 (if (eq mark old-mark)
10125 (error "No article on current line"))
10126 (if (not (if (or (= mark gnus-unread-mark)
10127 (= mark gnus-ticked-mark)
10128 (= mark gnus-spam-mark)
10129 (= mark gnus-dormant-mark))
10130 (gnus-mark-article-as-unread article mark)
10131 (gnus-mark-article-as-read article mark)))
10133 ;; See whether the article is to be put in the cache.
10134 (and gnus-use-cache
10135 (not (= mark gnus-canceled-mark))
10136 (vectorp (gnus-summary-article-header article))
10138 (gnus-cache-possibly-enter-article
10139 gnus-newsgroup-name article
10140 (= mark gnus-ticked-mark)
10141 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10143 (when (gnus-summary-goto-subject article nil t)
10144 (let ((buffer-read-only nil))
10145 (gnus-summary-show-thread)
10147 (gnus-summary-update-mark mark 'unread)
10150 (defun gnus-summary-update-secondary-mark (article)
10151 "Update the secondary (read, process, cache) mark."
10152 (gnus-summary-update-mark
10153 (cond ((memq article gnus-newsgroup-processable)
10155 ((memq article gnus-newsgroup-cached)
10157 ((memq article gnus-newsgroup-replied)
10159 ((memq article gnus-newsgroup-forwarded)
10160 gnus-forwarded-mark)
10161 ((memq article gnus-newsgroup-saved)
10163 ((memq article gnus-newsgroup-recent)
10165 ((memq article gnus-newsgroup-unseen)
10169 (when (gnus-visual-p 'summary-highlight 'highlight)
10170 (gnus-run-hooks 'gnus-summary-update-hook))
10173 (defun gnus-summary-update-download-mark (article)
10174 "Update the download mark."
10175 (gnus-summary-update-mark
10176 (cond ((memq article gnus-newsgroup-undownloaded)
10177 gnus-undownloaded-mark)
10178 (gnus-newsgroup-agentized
10179 gnus-downloaded-mark)
10183 (gnus-summary-update-line t)
10186 (defun gnus-summary-update-mark (mark type)
10187 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10188 (buffer-read-only nil))
10189 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10191 (when (looking-at "\r")
10193 (when (<= (+ forward (point)) (point-max))
10194 ;; Go to the right position on the line.
10195 (goto-char (+ forward (point)))
10196 ;; Replace the old mark with the new mark.
10197 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10198 ;; Optionally update the marks by some user rule.
10199 (when (eq type 'unread)
10200 (gnus-data-set-mark
10201 (gnus-data-find (gnus-summary-article-number)) mark)
10202 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10204 (defun gnus-mark-article-as-read (article &optional mark)
10205 "Enter ARTICLE in the pertinent lists and remove it from others."
10206 ;; Make the article expirable.
10207 (let ((mark (or mark gnus-del-mark)))
10208 (setq gnus-newsgroup-expirable
10209 (if (= mark gnus-expirable-mark)
10210 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10211 (delq article gnus-newsgroup-expirable)))
10212 ;; Remove from unread and marked lists.
10213 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10214 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10215 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10216 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10217 (push (cons article mark) gnus-newsgroup-reads)
10218 ;; Possibly remove from cache, if that is used.
10219 (when gnus-use-cache
10220 (gnus-cache-enter-remove-article article))
10223 (defun gnus-mark-article-as-unread (article &optional mark)
10224 "Enter ARTICLE in the pertinent lists and remove it from others."
10225 (let ((mark (or mark gnus-ticked-mark)))
10228 (gnus-error 1 "Can't mark negative article numbers")
10230 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10231 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10232 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10233 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10234 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10236 ;; Unsuppress duplicates?
10237 (when gnus-suppress-duplicates
10238 (gnus-dup-unsuppress-article article))
10240 (cond ((= mark gnus-ticked-mark)
10241 (setq gnus-newsgroup-marked
10242 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10243 ((= mark gnus-spam-mark)
10244 (setq gnus-newsgroup-spam-marked
10245 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10247 ((= mark gnus-dormant-mark)
10248 (setq gnus-newsgroup-dormant
10249 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10251 (setq gnus-newsgroup-unreads
10252 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10253 (gnus-pull article gnus-newsgroup-reads)
10256 (defalias 'gnus-summary-mark-as-unread-forward
10257 'gnus-summary-tick-article-forward)
10258 (make-obsolete 'gnus-summary-mark-as-unread-forward
10259 'gnus-summary-tick-article-forward)
10260 (defun gnus-summary-tick-article-forward (n)
10261 "Tick N articles forwards.
10262 If N is negative, tick backwards instead.
10263 The difference between N and the number of articles ticked is returned."
10265 (gnus-summary-mark-forward n gnus-ticked-mark))
10267 (defalias 'gnus-summary-mark-as-unread-backward
10268 'gnus-summary-tick-article-backward)
10269 (make-obsolete 'gnus-summary-mark-as-unread-backward
10270 'gnus-summary-tick-article-backward)
10271 (defun gnus-summary-tick-article-backward (n)
10272 "Tick N articles backwards.
10273 The difference between N and the number of articles ticked is returned."
10275 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10277 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10278 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10279 (defun gnus-summary-tick-article (&optional article clear-mark)
10280 "Mark current article as unread.
10281 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10282 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10284 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10285 gnus-ticked-mark)))
10287 (defun gnus-summary-mark-as-read-forward (n)
10288 "Mark N articles as read forwards.
10289 If N is negative, mark backwards instead.
10290 The difference between N and the actual number of articles marked is
10293 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10295 (defun gnus-summary-mark-as-read-backward (n)
10296 "Mark the N articles as read backwards.
10297 The difference between N and the actual number of articles marked is
10300 (gnus-summary-mark-forward
10301 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10303 (defun gnus-summary-mark-as-read (&optional article mark)
10304 "Mark current article as read.
10305 ARTICLE specifies the article to be marked as read.
10306 MARK specifies a string to be inserted at the beginning of the line."
10307 (gnus-summary-mark-article article mark))
10309 (defun gnus-summary-clear-mark-forward (n)
10310 "Clear marks from N articles forward.
10311 If N is negative, clear backward instead.
10312 The difference between N and the number of marks cleared is returned."
10314 (gnus-summary-mark-forward n gnus-unread-mark))
10316 (defun gnus-summary-clear-mark-backward (n)
10317 "Clear marks from N articles backward.
10318 The difference between N and the number of marks cleared is returned."
10320 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10322 (defun gnus-summary-mark-unread-as-read ()
10323 "Intended to be used by `gnus-summary-mark-article-hook'."
10324 (when (memq gnus-current-article gnus-newsgroup-unreads)
10325 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10327 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10328 "Intended to be used by `gnus-summary-mark-article-hook'."
10329 (let ((mark (gnus-summary-article-mark)))
10330 (when (or (gnus-unread-mark-p mark)
10331 (gnus-read-mark-p mark))
10332 (gnus-summary-mark-article gnus-current-article
10333 (or new-mark gnus-read-mark)))))
10335 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10336 "Intended to be used by `gnus-summary-mark-article-hook'."
10337 (let ((mark (gnus-summary-article-mark)))
10338 (when (or (gnus-unread-mark-p mark)
10339 (gnus-read-mark-p mark))
10340 (gnus-summary-mark-article (gnus-summary-article-number)
10341 (or new-mark gnus-read-mark)))))
10343 (defun gnus-summary-mark-unread-as-ticked ()
10344 "Intended to be used by `gnus-summary-mark-article-hook'."
10345 (when (memq gnus-current-article gnus-newsgroup-unreads)
10346 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10348 (defun gnus-summary-mark-region-as-read (point mark all)
10349 "Mark all unread articles between point and mark as read.
10350 If given a prefix, mark all articles between point and mark as read,
10351 even ticked and dormant ones."
10352 (interactive "r\nP")
10356 (beginning-of-line)
10361 (memq (setq article (gnus-summary-article-number))
10362 gnus-newsgroup-unreads))
10363 (gnus-summary-mark-article article gnus-del-mark))
10365 (gnus-summary-find-next))))))
10367 (defun gnus-summary-mark-below (score mark)
10368 "Mark articles with score less than SCORE with MARK."
10369 (interactive "P\ncMark: ")
10370 (setq score (if score
10371 (prefix-numeric-value score)
10372 (or gnus-summary-default-score 0)))
10374 (set-buffer gnus-summary-buffer)
10375 (goto-char (point-min))
10378 (and (< (gnus-summary-article-score) score)
10379 (gnus-summary-mark-article nil mark))
10380 (gnus-summary-find-next)))))
10382 (defun gnus-summary-kill-below (&optional score)
10383 "Mark articles with score below SCORE as read."
10385 (gnus-summary-mark-below score gnus-killed-mark))
10387 (defun gnus-summary-clear-above (&optional score)
10388 "Clear all marks from articles with score above SCORE."
10390 (gnus-summary-mark-above score gnus-unread-mark))
10392 (defun gnus-summary-tick-above (&optional score)
10393 "Tick all articles with score above SCORE."
10395 (gnus-summary-mark-above score gnus-ticked-mark))
10397 (defun gnus-summary-mark-above (score mark)
10398 "Mark articles with score over SCORE with MARK."
10399 (interactive "P\ncMark: ")
10400 (setq score (if score
10401 (prefix-numeric-value score)
10402 (or gnus-summary-default-score 0)))
10404 (set-buffer gnus-summary-buffer)
10405 (goto-char (point-min))
10407 (when (> (gnus-summary-article-score) score)
10408 (gnus-summary-mark-article nil mark))
10410 (gnus-summary-find-next)))))
10412 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10413 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10414 (defun gnus-summary-limit-include-expunged (&optional no-error)
10415 "Display all the hidden articles that were expunged for low scores."
10417 (let ((buffer-read-only nil))
10418 (let ((scored gnus-newsgroup-scored)
10421 (unless (gnus-summary-article-header (caar scored))
10422 (and (setq h (gnus-number-to-header (caar scored)))
10423 (< (cdar scored) gnus-summary-expunge-below)
10425 (setq scored (cdr scored)))
10427 (when (not no-error)
10428 (error "No expunged articles hidden"))
10429 (goto-char (point-min))
10430 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10431 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10432 (mapcar (lambda (x) (push (mail-header-number x)
10433 gnus-newsgroup-limit))
10435 (gnus-summary-prepare-unthreaded (nreverse headers))
10436 (goto-char (point-min))
10437 (gnus-summary-position-point)
10440 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10441 "Mark all unread articles in this newsgroup as read.
10442 If prefix argument ALL is non-nil, ticked and dormant articles will
10443 also be marked as read.
10444 If QUIETLY is non-nil, no questions will be asked.
10446 If TO-HERE is non-nil, it should be a point in the buffer. All
10447 articles before (after, if REVERSE is set) this point will be marked
10450 Note that this function will only catch up the unread article
10451 in the current summary buffer limitation.
10453 The number of articles marked as read is returned."
10458 (not gnus-interactive-catchup) ;Without confirmation?
10462 "Mark absolutely all articles as read? "
10463 "Mark all unread articles as read? ")))
10465 (not gnus-newsgroup-adaptive)
10466 (not gnus-newsgroup-auto-expire)
10467 (not gnus-suppress-duplicates)
10468 (or (not gnus-use-cache)
10469 (eq gnus-use-cache 'passive)))
10472 (setq gnus-newsgroup-marked nil
10473 gnus-newsgroup-spam-marked nil
10474 gnus-newsgroup-dormant nil))
10475 (setq gnus-newsgroup-unreads
10476 (gnus-sorted-nunion
10477 (gnus-intersection gnus-newsgroup-unreads
10478 gnus-newsgroup-downloadable)
10479 gnus-newsgroup-unfetched)))
10480 ;; We actually mark all articles as canceled, which we
10481 ;; have to do when using auto-expiry or adaptive scoring.
10482 (gnus-summary-show-all-threads)
10483 (if (and to-here reverse)
10485 (goto-char to-here)
10486 (gnus-summary-mark-current-read-and-unread-as-read
10488 (while (gnus-summary-find-next (not all))
10489 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10490 (when (gnus-summary-first-subject (not all))
10492 (if to-here (< (point) to-here) t)
10493 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10494 (gnus-summary-find-next (not all))))))
10495 (gnus-set-mode-line 'summary))
10497 (gnus-summary-position-point)))
10499 (defun gnus-summary-catchup-to-here (&optional all)
10500 "Mark all unticked articles before the current one as read.
10501 If ALL is non-nil, also mark ticked and dormant articles as read."
10504 (gnus-save-hidden-threads
10505 (let ((beg (point)))
10506 ;; We check that there are unread articles.
10507 (when (or all (gnus-summary-find-prev))
10508 (gnus-summary-catchup all t beg)))))
10509 (gnus-summary-position-point))
10511 (defun gnus-summary-catchup-from-here (&optional all)
10512 "Mark all unticked articles after (and including) the current one as read.
10513 If ALL is non-nil, also mark ticked and dormant articles as read."
10516 (gnus-save-hidden-threads
10517 (let ((beg (point)))
10518 ;; We check that there are unread articles.
10519 (when (or all (gnus-summary-find-next))
10520 (gnus-summary-catchup all t beg nil t)))))
10521 (gnus-summary-position-point))
10523 (defun gnus-summary-catchup-all (&optional quietly)
10524 "Mark all articles in this newsgroup as read.
10525 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10526 instead, which marks only unread articles as read."
10528 (gnus-summary-catchup t quietly))
10530 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10531 "Mark all unread articles in this group as read, then exit.
10532 If prefix argument ALL is non-nil, all articles are marked as read.
10533 If QUIETLY is non-nil, no questions will be asked."
10535 (when (gnus-summary-catchup all quietly nil 'fast)
10536 ;; Select next newsgroup or exit.
10537 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10538 (eq gnus-auto-select-next 'quietly))
10539 (gnus-summary-next-group nil)
10540 (gnus-summary-exit))))
10542 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10543 "Mark all articles in this newsgroup as read, and then exit.
10544 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10545 instead, which marks only unread articles as read."
10547 (gnus-summary-catchup-and-exit t quietly))
10549 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10550 "Mark all articles in this group as read and select the next group.
10551 If given a prefix, mark all articles, unread as well as ticked, as
10555 (gnus-summary-catchup all))
10556 (gnus-summary-next-group))
10562 (defmacro gnus-with-article (article &rest forms)
10563 "Select ARTICLE and perform FORMS in the original article buffer.
10564 Then replace the article with the result."
10566 ;; We don't want the article to be marked as read.
10567 (let (gnus-mark-article-hook)
10568 (gnus-summary-select-article t t nil ,article))
10569 (set-buffer gnus-original-article-buffer)
10571 (if (not (gnus-check-backend-function
10572 'request-replace-article (car gnus-article-current)))
10573 (gnus-message 5 "Read-only group; not replacing")
10574 (unless (gnus-request-replace-article
10575 ,article (car gnus-article-current)
10576 (current-buffer) t)
10577 (error "Couldn't replace article")))
10578 ;; The cache and backlog have to be flushed somewhat.
10579 (when gnus-keep-backlog
10580 (gnus-backlog-remove-article
10581 (car gnus-article-current) (cdr gnus-article-current)))
10582 (when gnus-use-cache
10583 (gnus-cache-update-article
10584 (car gnus-article-current) (cdr gnus-article-current)))))
10586 (put 'gnus-with-article 'lisp-indent-function 1)
10587 (put 'gnus-with-article 'edebug-form-spec '(form body))
10589 ;; Thread-based commands.
10591 (defun gnus-summary-articles-in-thread (&optional article)
10592 "Return a list of all articles in the current thread.
10593 If ARTICLE is non-nil, return all articles in the thread that starts
10594 with that article."
10595 (let* ((article (or article (gnus-summary-article-number)))
10596 (data (gnus-data-find-list article))
10597 (top-level (gnus-data-level (car data)))
10599 (cond ((null gnus-thread-operation-ignore-subject)
10600 (gnus-simplify-subject-re
10601 (mail-header-subject (gnus-data-header (car data)))))
10602 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10603 (gnus-simplify-subject-fuzzy
10604 (mail-header-subject (gnus-data-header (car data)))))
10606 (end-point (save-excursion
10607 (if (gnus-summary-go-to-next-thread)
10608 (point) (point-max))))
10611 (< (gnus-data-pos (car data)) end-point))
10612 (when (or (not top-subject)
10613 (string= top-subject
10614 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10615 (gnus-simplify-subject-fuzzy
10616 (mail-header-subject
10617 (gnus-data-header (car data))))
10618 (gnus-simplify-subject-re
10619 (mail-header-subject
10620 (gnus-data-header (car data)))))))
10621 (push (gnus-data-number (car data)) articles))
10622 (unless (and (setq data (cdr data))
10623 (> (gnus-data-level (car data)) top-level))
10625 ;; Return the list of articles.
10626 (nreverse articles)))
10628 (defun gnus-summary-rethread-current ()
10629 "Rethread the thread the current article is part of."
10631 (let* ((gnus-show-threads t)
10632 (article (gnus-summary-article-number))
10633 (id (mail-header-id (gnus-summary-article-header)))
10634 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10636 (error "No article on the current line"))
10637 (gnus-rebuild-thread id)
10638 (gnus-summary-goto-subject article)))
10640 (defun gnus-summary-reparent-thread ()
10641 "Make the current article child of the marked (or previous) article.
10643 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10644 is non-nil or the Subject: of both articles are the same."
10646 (unless (not (gnus-group-read-only-p))
10647 (error "The current newsgroup does not support article editing"))
10648 (unless (<= (length gnus-newsgroup-processable) 1)
10649 (error "No more than one article may be marked"))
10650 (save-window-excursion
10651 (let ((gnus-article-buffer " *reparent*")
10652 (current-article (gnus-summary-article-number))
10653 ;; First grab the marked article, otherwise one line up.
10654 (parent-article (if (not (null gnus-newsgroup-processable))
10655 (car gnus-newsgroup-processable)
10657 (if (eq (forward-line -1) 0)
10658 (gnus-summary-article-number)
10659 (error "Beginning of summary buffer"))))))
10660 (unless (not (eq current-article parent-article))
10661 (error "An article may not be self-referential"))
10662 (let ((message-id (mail-header-id
10663 (gnus-summary-article-header parent-article))))
10664 (unless (and message-id (not (equal message-id "")))
10665 (error "No message-id in desired parent"))
10666 (gnus-with-article current-article
10668 (goto-char (point-min))
10669 (message-narrow-to-head)
10670 (if (re-search-forward "^References: " nil t)
10672 (re-search-forward "^[^ \t]" nil t)
10675 (insert " " message-id))
10676 (insert "References: " message-id "\n"))))
10677 (set-buffer gnus-summary-buffer)
10678 (gnus-summary-unmark-all-processable)
10679 (gnus-summary-update-article current-article)
10680 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10681 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10682 (gnus-summary-rethread-current)
10683 (gnus-message 3 "Article %d is now the child of article %d"
10684 current-article parent-article)))))
10686 (defun gnus-summary-toggle-threads (&optional arg)
10687 "Toggle showing conversation threads.
10688 If ARG is positive number, turn showing conversation threads on."
10690 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10691 (setq gnus-show-threads
10692 (if (null arg) (not gnus-show-threads)
10693 (> (prefix-numeric-value arg) 0)))
10694 (gnus-summary-prepare)
10695 (gnus-summary-goto-subject current)
10696 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10697 (gnus-summary-position-point)))
10699 (defun gnus-summary-show-all-threads ()
10700 "Show all threads."
10703 (let ((buffer-read-only nil))
10704 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10705 (gnus-summary-position-point))
10707 (defun gnus-summary-show-thread ()
10708 "Show thread subtrees.
10709 Returns nil if no thread was there to be shown."
10711 (let ((buffer-read-only nil)
10713 (end (point-at-eol))
10714 ;; Leave point at bol
10715 (beg (progn (beginning-of-line) (point))))
10717 ;; Any hidden lines here?
10718 (search-forward "\r" end t)
10719 (subst-char-in-region beg end ?\^M ?\n t)
10721 (gnus-summary-position-point))))
10723 (defun gnus-summary-maybe-hide-threads ()
10724 "If requested, hide the threads that should be hidden."
10725 (when (and gnus-show-threads
10726 gnus-thread-hide-subtree)
10727 (gnus-summary-hide-all-threads
10728 (if (or (consp gnus-thread-hide-subtree)
10729 (functionp gnus-thread-hide-subtree))
10730 (gnus-make-predicate gnus-thread-hide-subtree)
10733 ;;; Hiding predicates.
10735 (defun gnus-article-unread-p (header)
10736 (memq (mail-header-number header) gnus-newsgroup-unreads))
10738 (defun gnus-article-unseen-p (header)
10739 (memq (mail-header-number header) gnus-newsgroup-unseen))
10741 (defun gnus-map-articles (predicate articles)
10742 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10743 (apply 'gnus-or (mapcar predicate
10744 (mapcar 'gnus-summary-article-header articles))))
10746 (defun gnus-summary-hide-all-threads (&optional predicate)
10747 "Hide all thread subtrees.
10748 If PREDICATE is supplied, threads that satisfy this predicate
10749 will not be hidden."
10752 (goto-char (point-min))
10755 (when (or (not predicate)
10757 predicate (gnus-summary-article-children)))
10758 (gnus-summary-hide-thread))
10759 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10760 (gnus-summary-position-point))
10762 (defun gnus-summary-hide-thread ()
10763 "Hide thread subtrees.
10764 If PREDICATE is supplied, threads that satisfy this predicate
10765 will not be hidden.
10766 Returns nil if no threads were there to be hidden."
10768 (let ((buffer-read-only nil)
10770 (article (gnus-summary-article-number)))
10772 ;; Go forward until either the buffer ends or the subthread
10774 (when (and (not (eobp))
10775 (or (zerop (gnus-summary-next-thread 1 t))
10776 (goto-char (point-max))))
10778 (if (and (> (point) start)
10779 (search-backward "\n" start t))
10781 (subst-char-in-region start (point) ?\n ?\^M)
10782 (gnus-summary-goto-subject article))
10786 (defun gnus-summary-go-to-next-thread (&optional previous)
10787 "Go to the same level (or less) next thread.
10788 If PREVIOUS is non-nil, go to previous thread instead.
10789 Return the article number moved to, or nil if moving was impossible."
10790 (let ((level (gnus-summary-thread-level))
10791 (way (if previous -1 1))
10794 (while (and (not (eobp))
10795 (< level (gnus-summary-thread-level)))
10796 (forward-line way))
10803 (gnus-summary-article-number)
10804 (goto-char beg)))))
10806 (defun gnus-summary-next-thread (n &optional silent)
10807 "Go to the same level next N'th thread.
10808 If N is negative, search backward instead.
10809 Returns the difference between N and the number of skips actually
10812 If SILENT, don't output messages."
10814 (let ((backward (< n 0))
10816 (while (and (> n 0)
10817 (gnus-summary-go-to-next-thread backward))
10820 (gnus-summary-position-point))
10821 (when (and (not silent) (/= 0 n))
10822 (gnus-message 7 "No more threads"))
10825 (defun gnus-summary-prev-thread (n)
10826 "Go to the same level previous N'th thread.
10827 Returns the difference between N and the number of skips actually
10830 (gnus-summary-next-thread (- n)))
10832 (defun gnus-summary-go-down-thread ()
10833 "Go down one level in the current thread."
10834 (let ((children (gnus-summary-article-children)))
10836 (gnus-summary-goto-subject (car children)))))
10838 (defun gnus-summary-go-up-thread ()
10839 "Go up one level in the current thread."
10840 (let ((parent (gnus-summary-article-parent)))
10842 (gnus-summary-goto-subject parent))))
10844 (defun gnus-summary-down-thread (n)
10845 "Go down thread N steps.
10846 If N is negative, go up instead.
10847 Returns the difference between N and how many steps down that were
10852 (while (and (> n 0)
10853 (if up (gnus-summary-go-up-thread)
10854 (gnus-summary-go-down-thread)))
10856 (gnus-summary-position-point)
10858 (gnus-message 7 "Can't go further"))
10861 (defun gnus-summary-up-thread (n)
10862 "Go up thread N steps.
10863 If N is negative, go down instead.
10864 Returns the difference between N and how many steps down that were
10867 (gnus-summary-down-thread (- n)))
10869 (defun gnus-summary-top-thread ()
10870 "Go to the top of the thread."
10872 (while (gnus-summary-go-up-thread))
10873 (gnus-summary-article-number))
10875 (defun gnus-summary-kill-thread (&optional unmark)
10876 "Mark articles under current thread as read.
10877 If the prefix argument is positive, remove any kinds of marks.
10878 If the prefix argument is negative, tick articles instead."
10881 (setq unmark (prefix-numeric-value unmark)))
10882 (let ((articles (gnus-summary-articles-in-thread)))
10884 ;; Expand the thread.
10885 (gnus-summary-show-thread)
10886 ;; Mark all the articles.
10888 (gnus-summary-goto-subject (car articles))
10889 (cond ((null unmark)
10890 (gnus-summary-mark-article-as-read gnus-killed-mark))
10892 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10894 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10895 (setq articles (cdr articles))))
10896 ;; Hide killed subtrees.
10898 gnus-thread-hide-killed
10899 (gnus-summary-hide-thread))
10900 ;; If marked as read, go to next unread subject.
10901 (when (null unmark)
10902 ;; Go to next unread subject.
10903 (gnus-summary-next-subject 1 t)))
10904 (gnus-set-mode-line 'summary))
10906 ;; Summary sorting commands
10908 (defun gnus-summary-sort-by-number (&optional reverse)
10909 "Sort the summary buffer by article number.
10910 Argument REVERSE means reverse order."
10912 (gnus-summary-sort 'number reverse))
10914 (defun gnus-summary-sort-by-random (&optional reverse)
10915 "Randomize the order in the summary buffer.
10916 Argument REVERSE means to randomize in reverse order."
10918 (gnus-summary-sort 'random reverse))
10920 (defun gnus-summary-sort-by-author (&optional reverse)
10921 "Sort the summary buffer by author name alphabetically.
10922 If `case-fold-search' is non-nil, case of letters is ignored.
10923 Argument REVERSE means reverse order."
10925 (gnus-summary-sort 'author reverse))
10927 (defun gnus-summary-sort-by-recipient (&optional reverse)
10928 "Sort the summary buffer by recipient name alphabetically.
10929 If `case-fold-search' is non-nil, case of letters is ignored.
10930 Argument REVERSE means reverse order."
10932 (gnus-summary-sort 'recipient reverse))
10934 (defun gnus-summary-sort-by-subject (&optional reverse)
10935 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10936 If `case-fold-search' is non-nil, case of letters is ignored.
10937 Argument REVERSE means reverse order."
10939 (gnus-summary-sort 'subject reverse))
10941 (defun gnus-summary-sort-by-date (&optional reverse)
10942 "Sort the summary buffer by date.
10943 Argument REVERSE means reverse order."
10945 (gnus-summary-sort 'date reverse))
10947 (defun gnus-summary-sort-by-score (&optional reverse)
10948 "Sort the summary buffer by score.
10949 Argument REVERSE means reverse order."
10951 (gnus-summary-sort 'score reverse))
10953 (defun gnus-summary-sort-by-lines (&optional reverse)
10954 "Sort the summary buffer by the number of lines.
10955 Argument REVERSE means reverse order."
10957 (gnus-summary-sort 'lines reverse))
10959 (defun gnus-summary-sort-by-chars (&optional reverse)
10960 "Sort the summary buffer by article length.
10961 Argument REVERSE means reverse order."
10963 (gnus-summary-sort 'chars reverse))
10965 (defun gnus-summary-sort-by-original (&optional reverse)
10966 "Sort the summary buffer using the default sorting method.
10967 Argument REVERSE means reverse order."
10969 (let* ((buffer-read-only)
10970 (gnus-summary-prepare-hook nil))
10971 ;; We do the sorting by regenerating the threads.
10972 (gnus-summary-prepare)
10973 ;; Hide subthreads if needed.
10974 (gnus-summary-maybe-hide-threads)))
10976 (defun gnus-summary-sort (predicate reverse)
10977 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10978 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10979 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10980 (gnus-thread-sort-functions
10985 (gnus-sort-gathered-threads-function
10986 gnus-thread-sort-functions)
10987 (gnus-article-sort-functions
10991 (,article t2 t1))))
10993 (gnus-summary-prepare-hook nil))
10994 ;; We do the sorting by regenerating the threads.
10995 (gnus-summary-prepare)
10996 ;; Hide subthreads if needed.
10997 (gnus-summary-maybe-hide-threads)))
10999 ;; Summary saving commands.
11001 (defun gnus-summary-save-article (&optional n not-saved)
11002 "Save the current article using the default saver function.
11003 If N is a positive number, save the N next articles.
11004 If N is a negative number, save the N previous articles.
11005 If N is nil and any articles have been marked with the process mark,
11006 save those articles instead.
11007 The variable `gnus-default-article-saver' specifies the saver function."
11009 (let* ((articles (gnus-summary-work-articles n))
11010 (save-buffer (save-excursion
11011 (nnheader-set-temp-buffer " *Gnus Save*")))
11012 (num (length articles))
11014 (dolist (article articles)
11015 (setq header (gnus-summary-article-header article))
11016 (if (not (vectorp header))
11017 ;; This is a pseudo-article.
11018 (if (assq 'name header)
11019 (gnus-copy-file (cdr (assq 'name header)))
11020 (gnus-message 1 "Article %d is unsaveable" article))
11021 ;; This is a real article.
11022 (save-window-excursion
11023 (let ((gnus-display-mime-function nil)
11024 (gnus-article-prepare-hook nil))
11025 (gnus-summary-select-article t nil nil article)))
11027 (set-buffer save-buffer)
11029 (insert-buffer-substring gnus-original-article-buffer))
11030 (setq file (gnus-article-save save-buffer file num))
11031 (gnus-summary-remove-process-mark article)
11033 (gnus-summary-set-saved-mark article))))
11034 (gnus-kill-buffer save-buffer)
11035 (gnus-summary-position-point)
11036 (gnus-set-mode-line 'summary)
11039 (defun gnus-summary-pipe-output (&optional arg headers)
11040 "Pipe the current article to a subprocess.
11041 If N is a positive number, pipe the N next articles.
11042 If N is a negative number, pipe the N previous articles.
11043 If N is nil and any articles have been marked with the process mark,
11044 pipe those articles instead.
11045 If HEADERS (the symbolic prefix), include the headers, too."
11046 (interactive (gnus-interactive "P\ny"))
11047 (require 'gnus-art)
11048 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11049 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11050 (gnus-summary-save-article arg t))
11051 (let ((buffer (get-buffer "*Shell Command Output*")))
11053 (not (zerop (buffer-size buffer))))
11054 (gnus-configure-windows 'pipe))))
11056 (defun gnus-summary-save-article-mail (&optional arg)
11057 "Append the current article to an mail file.
11058 If N is a positive number, save the N next articles.
11059 If N is a negative number, save the N previous articles.
11060 If N is nil and any articles have been marked with the process mark,
11061 save those articles instead."
11063 (require 'gnus-art)
11064 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11065 (gnus-summary-save-article arg)))
11067 (defun gnus-summary-save-article-rmail (&optional arg)
11068 "Append the current article to an rmail file.
11069 If N is a positive number, save the N next articles.
11070 If N is a negative number, save the N previous articles.
11071 If N is nil and any articles have been marked with the process mark,
11072 save those articles instead."
11074 (require 'gnus-art)
11075 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11076 (gnus-summary-save-article arg)))
11078 (defun gnus-summary-save-article-file (&optional arg)
11079 "Append the current article to a file.
11080 If N is a positive number, save the N next articles.
11081 If N is a negative number, save the N previous articles.
11082 If N is nil and any articles have been marked with the process mark,
11083 save those articles instead."
11085 (require 'gnus-art)
11086 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11087 (gnus-summary-save-article arg)))
11089 (defun gnus-summary-write-article-file (&optional arg)
11090 "Write the current article to a file, deleting the previous file.
11091 If N is a positive number, save the N next articles.
11092 If N is a negative number, save the N previous articles.
11093 If N is nil and any articles have been marked with the process mark,
11094 save those articles instead."
11096 (require 'gnus-art)
11097 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11098 (gnus-summary-save-article arg)))
11100 (defun gnus-summary-save-article-body-file (&optional arg)
11101 "Append the current article body to a file.
11102 If N is a positive number, save the N next articles.
11103 If N is a negative number, save the N previous articles.
11104 If N is nil and any articles have been marked with the process mark,
11105 save those articles instead."
11107 (require 'gnus-art)
11108 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11109 (gnus-summary-save-article arg)))
11111 (defun gnus-summary-muttprint (&optional arg)
11112 "Print the current article using Muttprint.
11113 If N is a positive number, save the N next articles.
11114 If N is a negative number, save the N previous articles.
11115 If N is nil and any articles have been marked with the process mark,
11116 save those articles instead."
11118 (require 'gnus-art)
11119 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11120 (gnus-summary-save-article arg t)))
11122 (defun gnus-summary-pipe-message (program)
11123 "Pipe the current article through PROGRAM."
11124 (interactive "sProgram: ")
11125 (gnus-summary-select-article)
11126 (let ((mail-header-separator ""))
11127 (gnus-eval-in-buffer-window gnus-article-buffer
11130 (let ((start (window-start))
11132 (message-pipe-buffer-body program)
11133 (set-window-start (get-buffer-window (current-buffer)) start))))))
11135 (defun gnus-get-split-value (methods)
11136 "Return a value based on the split METHODS."
11137 (let (split-name method result match)
11140 (set-buffer gnus-original-article-buffer)
11142 (nnheader-narrow-to-headers)
11143 (while (and methods (not split-name))
11144 (goto-char (point-min))
11145 (setq method (pop methods))
11146 (setq match (car method))
11149 ;; Regular expression.
11151 (re-search-forward match nil t)))
11156 (setq result (funcall match gnus-newsgroup-name))))
11161 (setq result (eval match)))))
11162 (setq split-name (cdr method))
11163 (cond ((stringp result)
11164 (push (expand-file-name
11165 result gnus-article-save-directory)
11168 (setq split-name (append result split-name)))))))))
11169 (nreverse split-name)))
11171 (defun gnus-valid-move-group-p (group)
11172 (and (boundp group)
11173 (symbol-name group)
11174 (symbol-value group)
11175 (gnus-get-function (gnus-find-method-for-group
11176 (symbol-name group)) 'request-accept-article t)))
11178 (defun gnus-read-move-group-name (prompt default articles prefix)
11179 "Read a group name."
11180 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11181 (minibuffer-confirm-incomplete nil) ; XEmacs
11183 (format "%s %s to:"
11185 (if (> (length articles) 1)
11186 (format "these %d articles" (length articles))
11191 (gnus-completing-read-with-default
11194 'gnus-valid-move-group-p
11196 'gnus-group-history))
11197 ((= 1 (length split-name))
11198 (gnus-completing-read-with-default
11199 (car split-name) prom
11201 'gnus-valid-move-group-p
11203 'gnus-group-history))
11205 (gnus-completing-read-with-default
11207 (mapcar 'list (nreverse split-name))
11209 'gnus-group-history))))
11210 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11212 (if (or (string= to-newsgroup "")
11213 (string= to-newsgroup prefix))
11214 (setq to-newsgroup default))
11215 (unless to-newsgroup
11216 (error "No group name entered"))
11217 (or (gnus-active to-newsgroup)
11218 (gnus-activate-group to-newsgroup nil nil to-method)
11219 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11221 (or (and (gnus-request-create-group to-newsgroup to-method)
11222 (gnus-activate-group
11223 to-newsgroup nil nil to-method)
11224 (gnus-subscribe-group to-newsgroup))
11225 (error "Couldn't create group %s" to-newsgroup)))
11226 (error "No such group: %s" to-newsgroup)))
11229 (defun gnus-summary-save-parts (type dir n &optional reverse)
11230 "Save parts matching TYPE to DIR.
11231 If REVERSE, save parts that do not match TYPE."
11233 (list (read-string "Save parts of type: "
11234 (or (car gnus-summary-save-parts-type-history)
11235 gnus-summary-save-parts-default-mime)
11236 'gnus-summary-save-parts-type-history)
11237 (setq gnus-summary-save-parts-last-directory
11238 (read-file-name "Save to directory: "
11239 gnus-summary-save-parts-last-directory
11241 current-prefix-arg))
11242 (gnus-summary-iterate n
11243 (let ((gnus-display-mime-function nil)
11244 (gnus-inhibit-treatment t))
11245 (gnus-summary-select-article))
11247 (set-buffer gnus-article-buffer)
11248 (let ((handles (or gnus-article-mime-handles
11249 (mm-dissect-buffer nil gnus-article-loose-mime)
11250 (and gnus-article-emulate-mime
11251 (mm-uu-dissect)))))
11253 (gnus-summary-save-parts-1 type dir handles reverse)
11254 (unless gnus-article-mime-handles ;; Don't destroy this case.
11255 (mm-destroy-parts handles)))))))
11257 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11258 (if (stringp (car handle))
11259 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11262 (not (string-match type (mm-handle-media-type handle)))
11263 (string-match type (mm-handle-media-type handle)))
11264 (let ((file (expand-file-name
11266 mm-file-name-rewrite-functions
11267 (file-name-nondirectory
11269 (mail-content-type-get
11270 (mm-handle-disposition handle) 'filename)
11271 (mail-content-type-get
11272 (mm-handle-type handle) 'name)
11273 (concat gnus-newsgroup-name
11274 "." (number-to-string
11275 (cdr gnus-article-current))))))
11277 (unless (file-exists-p file)
11278 (mm-save-part-to-file handle file))))))
11280 ;; Summary extract commands
11282 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11283 (let ((buffer-read-only nil)
11284 (article (gnus-summary-article-number))
11286 (unless (gnus-summary-goto-subject article)
11287 (error "No such article: %d" article))
11288 (gnus-summary-position-point)
11289 ;; If all commands are to be bunched up on one line, we collect
11291 (unless gnus-view-pseudos-separately
11292 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11295 (setq action (cdr (assq 'action (car ps))))
11296 (setq files (list (cdr (assq 'name (car ps)))))
11297 (while (and ps (cdr ps)
11298 (string= (or action "1")
11299 (or (cdr (assq 'action (cadr ps))) "2")))
11300 (push (cdr (assq 'name (cadr ps))) files)
11301 (setcdr ps (cddr ps)))
11303 (when (not (string-match "%s" action))
11306 (when (assq 'execute (car ps))
11307 (setcdr (assq 'execute (car ps))
11308 (funcall (if (string-match "%s" action)
11315 (shell-quote-argument f)))
11317 (setq ps (cdr ps)))))
11318 (if (and gnus-view-pseudos (not not-view))
11320 (when (assq 'execute (car pslist))
11321 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11322 (eq gnus-view-pseudos 'not-confirm)))
11323 (setq pslist (cdr pslist)))
11326 (setq after-article (or (cdr (assq 'article (car pslist)))
11327 (gnus-summary-article-number)))
11328 (gnus-summary-goto-subject after-article)
11331 (insert " " (file-name-nondirectory
11332 (cdr (assq 'name (car pslist))))
11333 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11335 (forward-line -1) ; back to `b'
11336 (gnus-add-text-properties
11337 b (1- e) (list 'gnus-number gnus-reffed-article-number
11338 gnus-mouse-face-prop gnus-mouse-face))
11340 after-article gnus-reffed-article-number
11341 gnus-unread-mark b (car pslist) 0 (- e b))
11342 (setq gnus-newsgroup-unreads
11343 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11344 gnus-reffed-article-number))
11345 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11346 (setq pslist (cdr pslist)))))))
11348 (defun gnus-pseudos< (p1 p2)
11349 (let ((c1 (cdr (assq 'action p1)))
11350 (c2 (cdr (assq 'action p2))))
11351 (and c1 c2 (string< c1 c2))))
11353 (defun gnus-request-pseudo-article (props)
11354 (cond ((assq 'execute props)
11355 (gnus-execute-command (cdr (assq 'execute props)))))
11356 (let ((gnus-current-article (gnus-summary-article-number)))
11357 (gnus-run-hooks 'gnus-mark-article-hook)))
11359 (defun gnus-execute-command (command &optional automatic)
11361 (gnus-article-setup-buffer)
11362 (set-buffer gnus-article-buffer)
11363 (setq buffer-read-only nil)
11364 (let ((command (if automatic command
11365 (read-string "Command: " (cons command 0)))))
11367 (insert "$ " command "\n\n")
11368 (if gnus-view-pseudo-asynchronously
11369 (start-process "gnus-execute" (current-buffer) shell-file-name
11370 shell-command-switch command)
11371 (call-process shell-file-name nil t nil
11372 shell-command-switch command)))))
11374 ;; Summary kill commands.
11376 (defun gnus-summary-edit-global-kill (article)
11377 "Edit the \"global\" kill file."
11378 (interactive (list (gnus-summary-article-number)))
11379 (gnus-group-edit-global-kill article))
11381 (defun gnus-summary-edit-local-kill ()
11382 "Edit a local kill file applied to the current newsgroup."
11384 (setq gnus-current-headers (gnus-summary-article-header))
11385 (gnus-group-edit-local-kill
11386 (gnus-summary-article-number) gnus-newsgroup-name))
11388 ;;; Header reading.
11390 (defun gnus-read-header (id &optional header)
11391 "Read the headers of article ID and enter them into the Gnus system."
11392 (let ((group gnus-newsgroup-name)
11393 (gnus-override-method
11395 gnus-override-method
11396 (and (gnus-news-group-p gnus-newsgroup-name)
11397 (car (gnus-refer-article-methods)))))
11399 ;; First we check to see whether the header in question is already
11402 ;; This is a Message-ID.
11403 (setq header (or header (gnus-id-to-header id)))
11404 ;; This is an article number.
11405 (setq header (or header (gnus-summary-article-header id))))
11407 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11408 ;; We have found the header.
11410 ;; We have to really fetch the header to this article.
11412 (set-buffer nntp-server-buffer)
11413 (when (setq where (gnus-request-head id group))
11414 (nnheader-fold-continuation-lines)
11415 (goto-char (point-max))
11417 (goto-char (point-min))
11421 ((cdr where) (cdr where))
11422 (header (mail-header-number header))
11423 (t gnus-reffed-article-number))
11425 (insert " Article retrieved.\n"))
11426 (if (or (not where)
11427 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11428 () ; Malformed head.
11429 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11430 (when (and (stringp id)
11431 (not (string= (gnus-group-real-name group)
11433 ;; If we fetched by Message-ID and the article came
11434 ;; from a different group, we fudge some bogus article
11435 ;; numbers for this article.
11436 (mail-header-set-number header gnus-reffed-article-number))
11438 (set-buffer gnus-summary-buffer)
11439 (decf gnus-reffed-article-number)
11440 (gnus-remove-header (mail-header-number header))
11441 (push header gnus-newsgroup-headers)
11442 (setq gnus-current-headers header)
11443 (push (mail-header-number header) gnus-newsgroup-limit)))
11446 (defun gnus-remove-header (number)
11447 "Remove header NUMBER from `gnus-newsgroup-headers'."
11448 (if (and gnus-newsgroup-headers
11449 (= number (mail-header-number (car gnus-newsgroup-headers))))
11450 (pop gnus-newsgroup-headers)
11451 (let ((headers gnus-newsgroup-headers))
11452 (while (and (cdr headers)
11453 (not (= number (mail-header-number (cadr headers)))))
11455 (when (cdr headers)
11456 (setcdr headers (cddr headers))))))
11459 ;;; summary highlights
11462 (defun gnus-highlight-selected-summary ()
11463 "Highlight selected article in summary buffer."
11464 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11465 (when gnus-summary-selected-face
11467 (let* ((beg (point-at-bol))
11468 (end (point-at-eol))
11469 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11470 (from (if (get-text-property beg gnus-mouse-face-prop)
11472 (or (next-single-property-change
11473 beg gnus-mouse-face-prop nil end)
11478 (or (next-single-property-change
11479 from gnus-mouse-face-prop nil end)
11481 ;; If no mouse-face prop on line we will have to = from = end,
11482 ;; so we highlight the entire line instead.
11483 (when (= (+ to 2) from)
11486 (if gnus-newsgroup-selected-overlay
11487 ;; Move old overlay.
11489 gnus-newsgroup-selected-overlay from to (current-buffer))
11490 ;; Create new overlay.
11492 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11493 'face gnus-summary-selected-face))))))
11495 (defvar gnus-summary-highlight-line-cached nil)
11496 (defvar gnus-summary-highlight-line-trigger nil)
11498 (defun gnus-summary-highlight-line-0 ()
11499 (if (and (eq gnus-summary-highlight-line-trigger
11500 gnus-summary-highlight)
11501 gnus-summary-highlight-line-cached)
11502 gnus-summary-highlight-line-cached
11503 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11504 gnus-summary-highlight-line-cached
11505 (let* ((cond (list 'cond))
11507 (list gnus-summary-highlight))
11509 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11513 (gnus-byte-compile (list 'lambda nil cond))))))
11515 (defun gnus-summary-highlight-line ()
11516 "Highlight current line according to `gnus-summary-highlight'."
11517 (let* ((beg (point-at-bol))
11518 (article (or (gnus-summary-article-number) gnus-current-article))
11519 (score (or (cdr (assq article
11520 gnus-newsgroup-scored))
11521 gnus-summary-default-score 0))
11522 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11523 (inhibit-read-only t)
11524 (default gnus-summary-default-score)
11525 (default-high gnus-summary-default-high-score)
11526 (default-low gnus-summary-default-low-score)
11527 (uncached (and gnus-summary-use-undownloaded-faces
11528 (memq article gnus-newsgroup-undownloaded)
11529 (not (memq article gnus-newsgroup-cached)))))
11530 (let ((face (funcall (gnus-summary-highlight-line-0))))
11531 (unless (eq face (get-text-property beg 'face))
11532 (gnus-put-text-property-excluding-characters-with-faces
11533 beg (point-at-eol) 'face
11534 (setq face (if (boundp face) (symbol-value face) face)))
11535 (when gnus-summary-highlight-line-function
11536 (funcall gnus-summary-highlight-line-function article face))))))
11538 (defun gnus-update-read-articles (group unread &optional compute)
11539 "Update the list of read articles in GROUP.
11540 UNREAD is a sorted list."
11541 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11542 (info (gnus-get-info group))
11545 (if (or (not info) (not active))
11546 ;; There is no info on this group if it was, in fact,
11547 ;; killed. Gnus stores no information on killed groups, so
11548 ;; there's nothing to be done.
11549 ;; One could store the information somewhere temporarily,
11550 ;; perhaps... Hmmm...
11552 ;; Remove any negative articles numbers.
11553 (while (and unread (< (car unread) 0))
11554 (setq unread (cdr unread)))
11555 ;; Remove any expired article numbers
11556 (while (and unread (< (car unread) (car active)))
11557 (setq unread (cdr unread)))
11558 ;; Compute the ranges of read articles by looking at the list of
11559 ;; unread articles.
11561 (when (/= (car unread) prev)
11562 (push (if (= prev (1- (car unread))) prev
11563 (cons prev (1- (car unread))))
11565 (setq prev (1+ (car unread)))
11566 (setq unread (cdr unread)))
11567 (when (<= prev (cdr active))
11568 (push (cons prev (cdr active)) read))
11569 (setq read (if (> (length read) 1) (nreverse read) read))
11574 ;; Propagate the read marks to the backend.
11575 (when (gnus-check-backend-function 'request-set-mark group)
11576 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11577 (add (gnus-remove-from-range read (gnus-info-read info))))
11579 (unless (gnus-check-group group)
11580 (error "Can't open server for %s" group))
11581 (gnus-request-set-mark
11582 group (delq nil (list (if add (list add 'add '(read)))
11583 (if del (list del 'del '(read))))))
11585 `(gnus-request-set-mark
11588 (if del (list del 'add '(read)))
11589 (if add (list add 'del '(read))))))))))
11590 (set-buffer gnus-group-buffer)
11591 (gnus-undo-register
11593 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11594 (gnus-info-set-read ',info ',(gnus-info-read info))
11595 (gnus-get-unread-articles-in-group ',info
11596 (gnus-active ,group))
11597 (gnus-group-update-group ,group t)
11599 ;; Enter this list into the group info.
11600 (gnus-info-set-read info read)
11601 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11602 (gnus-get-unread-articles-in-group info (gnus-active group))
11605 (defun gnus-offer-save-summaries ()
11606 "Offer to save all active summary buffers."
11608 ;; Go through all buffers and find all summaries.
11609 (dolist (buffer (buffer-list))
11610 (when (and (setq buffer (buffer-name buffer))
11611 (string-match "Summary" buffer)
11612 (with-current-buffer buffer
11613 ;; We check that this is, indeed, a summary buffer.
11614 (and (eq major-mode 'gnus-summary-mode)
11615 ;; Also make sure this isn't bogus.
11616 gnus-newsgroup-prepared
11617 ;; Also make sure that this isn't a
11618 ;; dead summary buffer.
11619 (not gnus-dead-summary-mode))))
11620 (push buffer buffers)))
11621 ;; Go through all these summary buffers and offer to save them.
11625 "Update summary buffer %s? "
11627 (switch-to-buffer buf)
11628 (gnus-summary-exit))
11631 (defun gnus-summary-setup-default-charset ()
11632 "Setup newsgroup default charset."
11633 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11634 (setq gnus-newsgroup-charset nil)
11635 (let* ((ignored-charsets
11636 (or gnus-newsgroup-ephemeral-ignored-charsets
11638 (and gnus-newsgroup-name
11639 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11640 gnus-newsgroup-ignored-charsets))))
11641 (setq gnus-newsgroup-charset
11642 (or gnus-newsgroup-ephemeral-charset
11643 (and gnus-newsgroup-name
11644 (gnus-parameter-charset gnus-newsgroup-name))
11645 gnus-default-charset))
11646 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11647 ignored-charsets))))
11653 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11654 "Display the current article buffer fully MIME-buttonized.
11655 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11656 treated as multipart/mixed."
11658 (require 'gnus-art)
11659 (let ((gnus-unbuttonized-mime-types nil)
11660 (gnus-mime-display-multipart-as-mixed show-all-parts))
11661 (gnus-summary-show-article)))
11663 (defun gnus-summary-repair-multipart (article)
11664 "Add a Content-Type header to a multipart article without one."
11665 (interactive (list (gnus-summary-article-number)))
11666 (gnus-with-article article
11667 (message-narrow-to-head)
11668 (message-remove-header "Mime-Version")
11669 (goto-char (point-max))
11670 (insert "Mime-Version: 1.0\n")
11672 (when (search-forward "\n--" nil t)
11673 (let ((separator (buffer-substring (point) (point-at-eol))))
11674 (message-narrow-to-head)
11675 (message-remove-header "Content-Type")
11676 (goto-char (point-max))
11677 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11680 (let (gnus-mark-article-hook)
11681 (gnus-summary-select-article t t nil article)))
11683 (defun gnus-summary-toggle-display-buttonized ()
11684 "Toggle the buttonizing of the article buffer."
11686 (require 'gnus-art)
11687 (if (setq gnus-inhibit-mime-unbuttonizing
11688 (not gnus-inhibit-mime-unbuttonizing))
11689 (let ((gnus-unbuttonized-mime-types nil))
11690 (gnus-summary-show-article))
11691 (gnus-summary-show-article)))
11694 ;;; Generic summary marking commands
11697 (defvar gnus-summary-marking-alist
11698 '((read gnus-del-mark "d")
11699 (unread gnus-unread-mark "u")
11700 (ticked gnus-ticked-mark "!")
11701 (dormant gnus-dormant-mark "?")
11702 (expirable gnus-expirable-mark "e"))
11703 "An alist of names/marks/keystrokes.")
11705 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11706 (defvar gnus-summary-mark-map)
11708 (defun gnus-summary-make-all-marking-commands ()
11709 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11710 (dolist (elem gnus-summary-marking-alist)
11711 (apply 'gnus-summary-make-marking-command elem)))
11713 (defun gnus-summary-make-marking-command (name mark keystroke)
11714 (let ((map (make-sparse-keymap)))
11715 (define-key gnus-summary-generic-mark-map keystroke map)
11716 (dolist (lway `((next "next" next nil "n")
11717 (next-unread "next unread" next t "N")
11718 (prev "previous" prev nil "p")
11719 (prev-unread "previous unread" prev t "P")
11720 (nomove "" nil nil ,keystroke)))
11721 (let ((func (gnus-summary-make-marking-command-1
11722 mark (car lway) lway name)))
11723 (setq func (eval func))
11724 (define-key map (nth 4 lway) func)))))
11726 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11728 (format "gnus-summary-put-mark-as-%s%s"
11729 name (if (eq way 'nomove)
11731 (concat "-" (symbol-name way)))))
11734 "Mark the current article as %s%s.
11735 If N, the prefix, then repeat N times.
11736 If N is negative, move in reverse order.
11737 The difference between N and the actual number of articles marked is
11741 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11743 (defun gnus-summary-generic-mark (n mark move unread)
11744 "Mark N articles with MARK."
11745 (unless (eq major-mode 'gnus-summary-mode)
11746 (error "This command can only be used in the summary buffer"))
11747 (gnus-summary-show-thread)
11750 ((eq move 'next) 1)
11751 ((eq move 'prev) -1)
11753 (if (zerop nummove)
11757 nummove (* -1 nummove))))
11758 (while (and (> n 0)
11759 (gnus-summary-mark-article nil mark)
11760 (zerop (gnus-summary-next-subject nummove unread t)))
11763 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11764 (gnus-summary-recenter)
11765 (gnus-summary-position-point)
11766 (gnus-set-mode-line 'summary)
11769 (defun gnus-summary-insert-articles (articles)
11770 (when (setq articles
11771 (gnus-sorted-difference articles
11772 (mapcar (lambda (h)
11773 (mail-header-number h))
11774 gnus-newsgroup-headers)))
11775 (setq gnus-newsgroup-headers
11777 gnus-newsgroup-headers
11778 (gnus-fetch-headers articles)
11779 'gnus-article-sort-by-number))
11780 ;; Suppress duplicates?
11781 (when gnus-suppress-duplicates
11782 (gnus-dup-suppress-articles))
11784 ;; We might want to build some more threads first.
11785 (when (and gnus-fetch-old-headers
11786 (eq gnus-headers-retrieved-by 'nov))
11787 (if (eq gnus-fetch-old-headers 'invisible)
11788 (gnus-build-all-threads)
11789 (gnus-build-old-threads)))
11790 ;; Let the Gnus agent mark articles as read.
11792 (gnus-agent-get-undownloaded-list))
11793 ;; Remove list identifiers from subject
11794 (when gnus-list-identifiers
11795 (gnus-summary-remove-list-identifiers))
11796 ;; First and last article in this newsgroup.
11797 (when gnus-newsgroup-headers
11798 (setq gnus-newsgroup-begin
11799 (mail-header-number (car gnus-newsgroup-headers))
11801 (mail-header-number
11802 (gnus-last-element gnus-newsgroup-headers))))
11803 (when gnus-use-scoring
11804 (gnus-possibly-score-headers))))
11806 (defun gnus-summary-insert-old-articles (&optional all)
11807 "Insert all old articles in this group.
11808 If ALL is non-nil, already read articles become readable.
11809 If ALL is a number, fetch this number of articles."
11812 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11815 ;; Some nntp servers lie about their active range. When
11816 ;; this happens, the active range can be in the millions.
11817 ;; Use a compressed range to avoid creating a huge list.
11818 (gnus-range-difference (list gnus-newsgroup-active) old))
11819 (setq len (gnus-range-length older))
11824 (let ((older-range (nreverse older)))
11828 (let* ((r (pop older-range))
11829 (min (if (numberp r) r (car r)))
11830 (max (if (numberp r) r (cdr r))))
11831 (while (and (<= min max)
11836 (setq older (gnus-uncompress-range older))))
11838 (setq older (gnus-uncompress-range older)))
11840 (when (and (numberp gnus-large-newsgroup)
11841 (> len gnus-large-newsgroup))
11842 (let* ((cursor-in-echo-area nil)
11843 (initial (gnus-parameter-large-newsgroup-initial
11844 gnus-newsgroup-name))
11848 "How many articles from %s (%s %d): "
11850 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11851 (if initial "max" "default")
11854 (cons (number-to-string initial)
11856 (unless (string-match "^[ \t]*$" input)
11857 (setq all (string-to-number input))
11859 (let ((older-range (nreverse older)))
11863 (let* ((r (pop older-range))
11864 (min (if (numberp r) r (car r)))
11865 (max (if (numberp r) r (cdr r))))
11866 (while (and (<= min max)
11870 max (1- max))))))))))
11871 (setq older (gnus-uncompress-range older))))
11873 (message "No old news.")
11874 (gnus-summary-insert-articles older)
11875 (gnus-summary-limit (gnus-sorted-nunion old older))))
11876 (gnus-summary-position-point)))
11878 (defun gnus-summary-insert-new-articles ()
11879 "Insert all new articles in this group."
11882 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11883 (old-active gnus-newsgroup-active)
11884 (nnmail-fetched-sources (list t))
11886 (setq gnus-newsgroup-active
11887 (gnus-activate-group gnus-newsgroup-name 'scan))
11888 (setq i (cdr gnus-newsgroup-active))
11889 (while (> i (cdr old-active))
11893 (message "No gnus is bad news")
11894 (gnus-summary-insert-articles new)
11895 (setq gnus-newsgroup-unreads
11896 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11897 (gnus-summary-limit (gnus-sorted-nunion old new))))
11898 (gnus-summary-position-point)))
11900 (gnus-summary-make-all-marking-commands)
11902 (gnus-ems-redefine)
11904 (provide 'gnus-sum)
11906 (run-hooks 'gnus-sum-load-hook)
11908 ;; Local Variables:
11909 ;; coding: iso-8859-1
11912 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11913 ;;; gnus-sum.el ends here