1 ;;; gnus-sum.el --- summary mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
32 (defvar tool-bar-map))
45 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
46 (autoload 'gnus-cache-write-active "gnus-cache")
47 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
48 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
49 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
50 (autoload 'mm-uu-dissect "mm-uu")
51 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
52 "Deuglify broken Outlook (Express) articles and redisplay."
54 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
55 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
56 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
58 (defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
65 (defcustom gnus-fetch-old-headers nil
66 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
67 If an unread article in the group refers to an older, already read (or
68 just marked as read) article, the old article will not normally be
69 displayed in the Summary buffer. If this variable is t, Gnus
70 will attempt to grab the headers to the old articles, and thereby
71 build complete threads. If it has the value `some', only enough
72 headers to connect otherwise loose threads will be displayed. This
73 variable can also be a number. In that case, no more than that number
74 of old headers will be fetched. If it has the value `invisible', all
75 old headers will be fetched, but none will be displayed.
77 The server has to support NOV for any of this to work."
79 :type '(choice (const :tag "off" nil)
84 (sexp :menu-tag "other" t)))
86 (defcustom gnus-refer-thread-limit 200
87 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
88 If t, fetch all the available old headers."
91 (sexp :menu-tag "other" t)))
93 (defcustom gnus-summary-make-false-root 'adopt
94 "*nil means that Gnus won't gather loose threads.
95 If the root of a thread has expired or been read in a previous
96 session, the information necessary to build a complete thread has been
97 lost. Instead of having many small sub-threads from this original thread
98 scattered all over the summary buffer, Gnus can gather them.
100 If non-nil, Gnus will try to gather all loose sub-threads from an
101 original thread into one large thread.
103 If this variable is non-nil, it should be one of `none', `adopt',
106 If this variable is `none', Gnus will not make a false root, but just
107 present the sub-threads after another.
108 If this variable is `dummy', Gnus will create a dummy root that will
109 have all the sub-threads as children.
110 If this variable is `adopt', Gnus will make one of the \"children\"
111 the parent and mark all the step-children as such.
112 If this variable is `empty', the \"children\" are printed with empty
113 subject fields. (Or rather, they will be printed with a string
114 given by the `gnus-summary-same-subject' variable.)"
116 :type '(choice (const :tag "off" nil)
122 (defcustom gnus-summary-make-false-root-always nil
123 "Always make a false dummy root."
128 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130 As loose thread gathering is done on subjects only, that means that
131 there can be many false gatherings performed. By rooting out certain
132 common subjects, gathering might become saner."
136 (defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138 Use nil to compare full subjects. Setting this variable to a low
139 number will help gather threads that have been corrupted by
140 newsreaders chopping off subject lines, but it might also mean that
141 unrelated articles that have subject that happen to begin with the
142 same few characters will be incorrectly gathered.
144 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
147 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "on" t)))
151 (defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153 The functions are applied recursively.
155 Useful functions to put in this list include:
156 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
159 :type '(repeat function))
161 (defcustom gnus-simplify-ignored-prefixes nil
162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
164 :type '(choice (const :tag "off" nil)
167 (defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169 If `some', only fill in the gaps that are needed to tie loose threads
170 together. If `more', fill in all leaf nodes that Gnus can find. If
171 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
173 :type '(choice (const :tag "off" nil)
176 (sexp :menu-tag "all" t)))
178 (defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
180 "*Function used for gathering loose threads.
181 There are two pre-defined functions: `gnus-gather-threads-by-subject',
182 which only takes Subjects into consideration; and
183 `gnus-gather-threads-by-references', which compared the References
184 headers of the articles to find matches."
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
190 (defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192 This variable will only be used if the value of
193 `gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
197 (defcustom gnus-summary-goto-unread t
198 "*If t, many commands will go to the next unread article.
199 This applies to marking commands as well as other commands that
200 \"naturally\" select the next article, like, for instance, `SPC' at
201 the end of an article.
203 If nil, the marking commands do NOT go to the next unread article
204 \(they go to the next article instead). If `never', commands that
205 usually go to the next unread article, will go to the next article,
206 whether it is read or not."
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
211 (sexp :menu-tag "on" t)))
213 (defcustom gnus-summary-default-score 0
214 "*Default article score level.
215 All scores generated by the score files will be added to this score.
216 If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
221 (defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223 An article will be highlighted as high scored if its score is greater
226 :group 'gnus-score-default
229 (defcustom gnus-summary-default-low-score 0
230 "*Default threshold for a low scored article.
231 An article will be highlighted as low scored if its score is smaller
234 :group 'gnus-score-default
237 (defcustom gnus-summary-zcore-fuzz 0
238 "*Fuzziness factor for the zcore in the summary buffer.
239 Articles with scores closer than this to `gnus-summary-default-score'
241 :group 'gnus-summary-format
244 (defcustom gnus-simplify-subject-fuzzy-regexp nil
245 "*Strings to be removed when doing fuzzy matches.
246 This can either be a regular expression or list of regular expressions
247 that will be removed from subject strings if fuzzy subject
248 simplification is selected."
250 :type '(repeat regexp))
252 (defcustom gnus-show-threads t
253 "*If non-nil, display threads in summary mode."
257 (defcustom gnus-thread-hide-subtree nil
258 "*If non-nil, hide all threads initially.
259 This can be a predicate specifier which says which threads to hide.
260 If threads are hidden, you have to run the command
261 `gnus-summary-show-thread' by hand or select an article."
263 :type '(radio (sexp :format "Non-nil\n"
264 :match (lambda (widget value)
265 (not (or (consp value) (functionp value))))
268 (sexp :tag "Predicate specifier")))
270 (defcustom gnus-thread-hide-killed t
271 "*If non-nil, hide killed threads automatically."
275 (defcustom gnus-thread-ignore-subject t
276 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
277 If nil, articles that have different subjects from their parents will
278 start separate threads."
282 (defcustom gnus-thread-operation-ignore-subject t
283 "*If non-nil, subjects will be ignored when doing thread commands.
284 This affects commands like `gnus-summary-kill-thread' and
285 `gnus-summary-lower-thread'.
287 If this variable is nil, articles in the same thread with different
288 subjects will not be included in the operation in question. If this
289 variable is `fuzzy', only articles that have subjects that are fuzzily
290 equal will be included."
292 :type '(choice (const :tag "off" nil)
296 (defcustom gnus-thread-indent-level 4
297 "*Number that says how much each sub-thread should be indented."
301 (defcustom gnus-auto-extend-newsgroup t
302 "*If non-nil, extend newsgroup forward and backward when requested."
303 :group 'gnus-summary-choose
306 (defcustom gnus-auto-select-first t
307 "*If non-nil, select the article under point.
308 Which article this is is controlled by the `gnus-auto-select-subject'
311 If you want to prevent automatic selection of articles in some
312 newsgroups, set the variable to nil in `gnus-select-group-hook'."
313 :group 'gnus-group-select
314 :type '(choice (const :tag "none" nil)
315 (sexp :menu-tag "first" t)))
317 (defcustom gnus-auto-select-subject 'unread
318 "*Says what subject to place under point when entering a group.
320 This variable can either be the symbols `first' (place point on the
321 first subject), `unread' (place point on the subject line of the first
322 unread article), `best' (place point on the subject line of the
323 higest-scored article), `unseen' (place point on the subject line of
324 the first unseen article), `unseen-or-unread' (place point on the subject
325 line of the first unseen article or, if all article have been seen, on the
326 subject line of the first unread article), or a function to be called to
327 place point on some subject line."
329 :group 'gnus-group-select
330 :type '(choice (const best)
334 (const unseen-or-unread)))
336 (defcustom gnus-auto-select-next t
337 "*If non-nil, offer to go to the next group from the end of the previous.
338 If the value is t and the next newsgroup is empty, Gnus will exit
339 summary mode and go back to group mode. If the value is neither nil
340 nor t, Gnus will select the following unread newsgroup. In
341 particular, if the value is the symbol `quietly', the next unread
342 newsgroup will be selected without any confirmation, and if it is
343 `almost-quietly', the next group will be selected without any
344 confirmation if you are located on the last article in the group.
345 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
346 will go to the next group without confirmation."
347 :group 'gnus-summary-maneuvering
348 :type '(choice (const :tag "off" nil)
350 (const almost-quietly)
351 (const slightly-quietly)
352 (sexp :menu-tag "on" t)))
354 (defcustom gnus-auto-select-same nil
355 "*If non-nil, select the next article with the same subject.
356 If there are no more articles with the same subject, go to
357 the first unread article."
358 :group 'gnus-summary-maneuvering
361 (defcustom gnus-auto-goto-ignores 'unfetched
362 "*Says how to handle unfetched articles when maneuvering.
364 This variable can either be the symbols nil (maneuver to any
365 article), `undownloaded' (maneuvering while unplugged ignores articles
366 that have not been fetched), `always-undownloaded' (maneuvering always
367 ignores articles that have not been fetched), `unfetched' (maneuvering
368 ignores articles whose headers have not been fetched).
370 NOTE: The list of unfetched articles will always be nil when plugged
371 and, when unplugged, a subset of the undownloaded article list."
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "None" nil)
375 (const :tag "Undownloaded when unplugged" undownloaded)
376 (const :tag "Undownloaded" always-undownloaded)
377 (const :tag "Unfetched" unfetched)))
379 (defcustom gnus-summary-check-current nil
380 "*If non-nil, consider the current article when moving.
381 The \"unread\" movement commands will stay on the same line if the
382 current article is unread."
383 :group 'gnus-summary-maneuvering
386 (defcustom gnus-auto-center-summary t
387 "*If non-nil, always center the current summary buffer.
388 In particular, if `vertical' do only vertical recentering. If non-nil
389 and non-`vertical', do both horizontal and vertical recentering."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "none" nil)
393 (integer :tag "height")
394 (sexp :menu-tag "both" t)))
396 (defvar gnus-auto-center-group t
397 "*If non-nil, always center the group buffer.")
399 (defcustom gnus-show-all-headers nil
400 "*If non-nil, don't hide any headers."
401 :group 'gnus-article-hiding
402 :group 'gnus-article-headers
405 (defcustom gnus-summary-ignore-duplicates nil
406 "*If non-nil, ignore articles with identical Message-ID headers."
410 (defcustom gnus-single-article-buffer t
411 "*If non-nil, display all articles in the same buffer.
412 If nil, each group will get its own article buffer."
413 :group 'gnus-article-various
416 (defcustom gnus-break-pages t
417 "*If non-nil, do page breaking on articles.
418 The page delimiter is specified by the `gnus-page-delimiter'
420 :group 'gnus-article-various
423 (defcustom gnus-move-split-methods nil
424 "*Variable used to suggest where articles are to be moved to.
425 It uses the same syntax as the `gnus-split-methods' variable.
426 However, whereas `gnus-split-methods' specifies file names as targets,
427 this variable specifies group names."
428 :group 'gnus-summary-mail
429 :type '(repeat (choice (list :value (fun) function)
430 (cons :value ("" "") regexp (repeat string))
433 ;; FIXME: Although the custom type is `character' for the following variables,
434 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
436 (defcustom gnus-unread-mark ? ;Whitespace
437 "*Mark used for unread articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-ticked-mark ?!
442 "*Mark used for ticked articles."
443 :group 'gnus-summary-marks
446 (defcustom gnus-dormant-mark ??
447 "*Mark used for dormant articles."
448 :group 'gnus-summary-marks
451 (defcustom gnus-del-mark ?r
452 "*Mark used for del'd articles."
453 :group 'gnus-summary-marks
456 (defcustom gnus-read-mark ?R
457 "*Mark used for read articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-expirable-mark ?E
462 "*Mark used for expirable articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-killed-mark ?K
467 "*Mark used for killed articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-spam-mark ?$
472 "*Mark used for spam articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-souped-mark ?F
478 "*Mark used for souped articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-kill-file-mark ?X
483 "*Mark used for articles killed by kill files."
484 :group 'gnus-summary-marks
487 (defcustom gnus-low-score-mark ?Y
488 "*Mark used for articles with a low score."
489 :group 'gnus-summary-marks
492 (defcustom gnus-catchup-mark ?C
493 "*Mark used for articles that are caught up."
494 :group 'gnus-summary-marks
497 (defcustom gnus-replied-mark ?A
498 "*Mark used for articles that have been replied to."
499 :group 'gnus-summary-marks
502 (defcustom gnus-forwarded-mark ?F
503 "*Mark used for articles that have been forwarded."
505 :group 'gnus-summary-marks
508 (defcustom gnus-recent-mark ?N
509 "*Mark used for articles that are recent."
511 :group 'gnus-summary-marks
514 (defcustom gnus-cached-mark ?*
515 "*Mark used for articles that are in the cache."
516 :group 'gnus-summary-marks
519 (defcustom gnus-saved-mark ?S
520 "*Mark used for articles that have been saved."
521 :group 'gnus-summary-marks
524 (defcustom gnus-unseen-mark ?.
525 "*Mark used for articles that haven't been seen."
527 :group 'gnus-summary-marks
530 (defcustom gnus-no-mark ? ;Whitespace
531 "*Mark used for articles that have no other secondary mark."
533 :group 'gnus-summary-marks
536 (defcustom gnus-ancient-mark ?O
537 "*Mark used for ancient articles."
538 :group 'gnus-summary-marks
541 (defcustom gnus-sparse-mark ?Q
542 "*Mark used for sparsely reffed articles."
543 :group 'gnus-summary-marks
546 (defcustom gnus-canceled-mark ?G
547 "*Mark used for canceled articles."
548 :group 'gnus-summary-marks
551 (defcustom gnus-duplicate-mark ?M
552 "*Mark used for duplicate articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-undownloaded-mark ?-
557 "*Mark used for articles that weren't downloaded."
559 :group 'gnus-summary-marks
562 (defcustom gnus-downloaded-mark ?+
563 "*Mark used for articles that were downloaded."
564 :group 'gnus-summary-marks
567 (defcustom gnus-downloadable-mark ?%
568 "*Mark used for articles that are to be downloaded."
569 :group 'gnus-summary-marks
572 (defcustom gnus-unsendable-mark ?=
573 "*Mark used for articles that won't be sent."
574 :group 'gnus-summary-marks
577 (defcustom gnus-score-over-mark ?+
578 "*Score mark used for articles with high scores."
579 :group 'gnus-summary-marks
582 (defcustom gnus-score-below-mark ?-
583 "*Score mark used for articles with low scores."
584 :group 'gnus-summary-marks
587 (defcustom gnus-empty-thread-mark ? ;Whitespace
588 "*There is no thread under the article."
589 :group 'gnus-summary-marks
592 (defcustom gnus-not-empty-thread-mark ?=
593 "*There is a thread under the article."
594 :group 'gnus-summary-marks
597 (defcustom gnus-view-pseudo-asynchronously nil
598 "*If non-nil, Gnus will view pseudo-articles asynchronously."
599 :group 'gnus-extract-view
602 (defcustom gnus-auto-expirable-marks
603 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
604 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
605 gnus-souped-mark gnus-duplicate-mark)
606 "*The list of marks converted into expiration if a group is auto-expirable."
609 :type '(repeat character))
611 (defcustom gnus-inhibit-user-auto-expire t
612 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
617 (defcustom gnus-view-pseudos nil
618 "*If `automatic', pseudo-articles will be viewed automatically.
619 If `not-confirm', pseudos will be viewed automatically, and the user
620 will not be asked to confirm the command."
621 :group 'gnus-extract-view
622 :type '(choice (const :tag "off" nil)
624 (const not-confirm)))
626 (defcustom gnus-view-pseudos-separately t
627 "*If non-nil, one pseudo-article will be created for each file to be viewed.
628 If nil, all files that use the same viewing command will be given as a
629 list of parameters to that command."
630 :group 'gnus-extract-view
633 (defcustom gnus-insert-pseudo-articles t
634 "*If non-nil, insert pseudo-articles when decoding articles."
635 :group 'gnus-extract-view
638 (defcustom gnus-summary-dummy-line-format
640 "*The format specification for the dummy roots in the summary buffer.
641 It works along the same lines as a normal formatting string,
642 with some simple extensions.
646 General format specifiers can also be used.
647 See `(gnus)Formatting Variables'."
648 :link '(custom-manual "(gnus)Formatting Variables")
649 :group 'gnus-threading
652 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
653 "*The format specification for the summary mode line.
654 It works along the same lines as a normal formatting string,
655 with some simple extensions:
658 %p Unprefixed group name
659 %A Current article number
660 %z Current article score
662 %U Number of unread articles in the group
663 %e Number of unselected articles in the group
664 %Z A string with unread/unselected article counts
665 %g Shortish group name
666 %S Subject of the current article
668 %s Current score file name
669 %d Number of dormant articles
670 %r Number of articles that have been marked as read in this session
671 %E Number of articles expunged by the score files"
672 :group 'gnus-summary-format
675 (defcustom gnus-list-identifiers nil
676 "Regexp that matches list identifiers to be removed from subject.
677 This can also be a list of regexps."
679 :group 'gnus-summary-format
680 :group 'gnus-article-hiding
681 :type '(choice (const :tag "none" nil)
683 (repeat :value (".*") regexp)))
685 (defcustom gnus-summary-mark-below 0
686 "*Mark all articles with a score below this variable as read.
687 This variable is local to each summary buffer and usually set by the
689 :group 'gnus-score-default
692 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
693 "*List of functions used for sorting articles in the summary buffer.
695 Each function takes two articles and returns non-nil if the first
696 article should be sorted before the other. If you use more than one
697 function, the primary sort function should be the last. You should
698 probably always include `gnus-article-sort-by-number' in the list of
699 sorting functions -- preferably first. Also note that sorting by date
700 is often much slower than sorting by number, and the sorting order is
701 very similar. (Sorting by date means sorting by the time the message
702 was sent, sorting by number means sorting by arrival time.)
704 Ready-made functions include `gnus-article-sort-by-number',
705 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
706 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
707 and `gnus-article-sort-by-score'.
709 When threading is turned on, the variable `gnus-thread-sort-functions'
710 controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-article-sort-by-number)
713 (function-item gnus-article-sort-by-author)
714 (function-item gnus-article-sort-by-subject)
715 (function-item gnus-article-sort-by-date)
716 (function-item gnus-article-sort-by-score)
717 (function-item gnus-article-sort-by-random)
718 (function :tag "other"))))
720 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
721 "*List of functions used for sorting threads in the summary buffer.
722 By default, threads are sorted by article number.
724 Each function takes two threads and returns non-nil if the first
725 thread should be sorted before the other. If you use more than one
726 function, the primary sort function should be the last. You should
727 probably always include `gnus-thread-sort-by-number' in the list of
728 sorting functions -- preferably first. Also note that sorting by date
729 is often much slower than sorting by number, and the sorting order is
730 very similar. (Sorting by date means sorting by the time the message
731 was sent, sorting by number means sorting by arrival time.)
733 Ready-made functions include `gnus-thread-sort-by-number',
734 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
735 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
736 `gnus-thread-sort-by-most-recent-number',
737 `gnus-thread-sort-by-most-recent-date',
738 `gnus-thread-sort-by-random', and
739 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
741 When threading is turned off, the variable
742 `gnus-article-sort-functions' controls how articles are sorted."
743 :group 'gnus-summary-sort
744 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
745 (function-item gnus-thread-sort-by-author)
746 (function-item gnus-thread-sort-by-subject)
747 (function-item gnus-thread-sort-by-date)
748 (function-item gnus-thread-sort-by-score)
749 (function-item gnus-thread-sort-by-total-score)
750 (function-item gnus-thread-sort-by-random)
751 (function :tag "other"))))
753 (defcustom gnus-thread-score-function '+
754 "*Function used for calculating the total score of a thread.
756 The function is called with the scores of the article and each
757 subthread and should then return the score of the thread.
759 Some functions you can use are `+', `max', or `min'."
760 :group 'gnus-summary-sort
763 (defcustom gnus-summary-expunge-below nil
764 "All articles that have a score less than this variable will be expunged.
765 This variable is local to the summary buffers."
766 :group 'gnus-score-default
767 :type '(choice (const :tag "off" nil)
770 (defcustom gnus-thread-expunge-below nil
771 "All threads that have a total score less than this variable will be expunged.
772 See `gnus-thread-score-function' for en explanation of what a
775 This variable is local to the summary buffers."
776 :group 'gnus-threading
777 :group 'gnus-score-default
778 :type '(choice (const :tag "off" nil)
781 (defcustom gnus-summary-mode-hook nil
782 "*A hook for Gnus summary mode.
783 This hook is run before any variables are set in the summary buffer."
784 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
785 :group 'gnus-summary-various
788 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
789 (when (featurep 'xemacs)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
791 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
792 (add-hook 'gnus-summary-mode-hook
793 'gnus-xmas-switch-horizontal-scrollbar-off))
795 (defcustom gnus-summary-menu-hook nil
796 "*Hook run after the creation of the summary mode menu."
797 :group 'gnus-summary-visual
800 (defcustom gnus-summary-exit-hook nil
801 "*A hook called on exit from the summary buffer.
802 It will be called with point in the group buffer."
803 :group 'gnus-summary-exit
806 (defcustom gnus-summary-prepare-hook nil
807 "*A hook called after the summary buffer has been generated.
808 If you want to modify the summary buffer, you can use this hook."
809 :group 'gnus-summary-various
812 (defcustom gnus-summary-prepared-hook nil
813 "*A hook called as the last thing after the summary buffer has been generated."
814 :group 'gnus-summary-various
817 (defcustom gnus-summary-generate-hook nil
818 "*A hook run just before generating the summary buffer.
819 This hook is commonly used to customize threading variables and the
821 :group 'gnus-summary-various
824 (defcustom gnus-select-group-hook nil
825 "*A hook called when a newsgroup is selected.
827 If you'd like to simplify subjects like the
828 `gnus-summary-next-same-subject' command does, you can use the
831 (add-hook gnus-select-group-hook
833 (mapcar (lambda (header)
834 (mail-header-set-subject
836 (gnus-simplify-subject
837 (mail-header-subject header) 're-only)))
838 gnus-newsgroup-headers)))"
839 :group 'gnus-group-select
842 (defcustom gnus-select-article-hook nil
843 "*A hook called when an article is selected."
844 :group 'gnus-summary-choose
845 :options '(gnus-agent-fetch-selected-article)
848 (defcustom gnus-visual-mark-article-hook
849 (list 'gnus-highlight-selected-summary)
850 "*Hook run after selecting an article in the summary buffer.
851 It is meant to be used for highlighting the article in some way. It
852 is not run if `gnus-visual' is nil."
853 :group 'gnus-summary-visual
856 (defcustom gnus-parse-headers-hook nil
857 "*A hook called before parsing the headers."
861 (defcustom gnus-exit-group-hook nil
862 "*A hook called when exiting summary mode.
863 This hook is not called from the non-updating exit commands like `Q'."
867 (defcustom gnus-summary-update-hook
868 (list 'gnus-summary-highlight-line)
869 "*A hook called when a summary line is changed.
870 The hook will not be called if `gnus-visual' is nil.
872 The default function `gnus-summary-highlight-line' will
873 highlight the line according to the `gnus-summary-highlight'
875 :group 'gnus-summary-visual
878 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
879 "*A hook called when an article is selected for the first time.
880 The hook is intended to mark an article as read (or unread)
881 automatically when it is selected."
882 :group 'gnus-summary-choose
885 (defcustom gnus-group-no-more-groups-hook nil
886 "*A hook run when returning to group mode having no more (unread) groups."
887 :group 'gnus-group-select
890 (defcustom gnus-ps-print-hook nil
891 "*A hook run before ps-printing something from Gnus."
895 (defcustom gnus-summary-article-move-hook nil
896 "*A hook called after an article is moved, copied, respooled, or crossposted."
901 (defcustom gnus-summary-article-delete-hook nil
902 "*A hook called after an article is deleted."
907 (defcustom gnus-summary-article-expire-hook nil
908 "*A hook called after an article is expired."
913 (defcustom gnus-summary-display-arrow
914 (and (fboundp 'display-graphic-p)
916 "*If non-nil, display an arrow highlighting the current article."
921 (defcustom gnus-summary-selected-face 'gnus-summary-selected
922 "Face used for highlighting the current article in the summary buffer."
923 :group 'gnus-summary-visual
926 (defvar gnus-tmp-downloaded nil)
928 (defcustom gnus-summary-highlight
929 '(((eq mark gnus-canceled-mark)
930 . gnus-summary-cancelled)
931 ((and uncached (> score default-high))
932 . gnus-summary-high-undownloaded)
933 ((and uncached (< score default-low))
934 . gnus-summary-low-undownloaded)
936 . gnus-summary-normal-undownloaded)
937 ((and (> score default-high)
938 (or (eq mark gnus-dormant-mark)
939 (eq mark gnus-ticked-mark)))
940 . gnus-summary-high-ticked)
941 ((and (< score default-low)
942 (or (eq mark gnus-dormant-mark)
943 (eq mark gnus-ticked-mark)))
944 . gnus-summary-low-ticked)
945 ((or (eq mark gnus-dormant-mark)
946 (eq mark gnus-ticked-mark))
947 . gnus-summary-normal-ticked)
948 ((and (> score default-high) (eq mark gnus-ancient-mark))
949 . gnus-summary-high-ancient)
950 ((and (< score default-low) (eq mark gnus-ancient-mark))
951 . gnus-summary-low-ancient)
952 ((eq mark gnus-ancient-mark)
953 . gnus-summary-normal-ancient)
954 ((and (> score default-high) (eq mark gnus-unread-mark))
955 . gnus-summary-high-unread)
956 ((and (< score default-low) (eq mark gnus-unread-mark))
957 . gnus-summary-low-unread)
958 ((eq mark gnus-unread-mark)
959 . gnus-summary-normal-unread)
960 ((> score default-high)
961 . gnus-summary-high-read)
962 ((< score default-low)
963 . gnus-summary-low-read)
965 . gnus-summary-normal-read))
966 "*Controls the highlighting of summary buffer lines.
968 A list of (FORM . FACE) pairs. When deciding how a a particular
969 summary line should be displayed, each form is evaluated. The content
970 of the face field after the first true form is used. You can change
971 how those summary lines are displayed, by editing the face field.
973 You can use the following variables in the FORM field.
975 score: The article's score
976 default: The default article score.
977 default-high: The default score for high scored articles.
978 default-low: The default score for low scored articles.
979 below: The score below which articles are automatically marked as read.
980 mark: The article's mark.
981 uncached: Non-nil if the article is uncached."
982 :group 'gnus-summary-visual
983 :type '(repeat (cons (sexp :tag "Form" nil)
986 (defcustom gnus-alter-header-function nil
987 "Function called to allow alteration of article header structures.
988 The function is called with one parameter, the article header vector,
989 which it may alter in any way."
990 :type '(choice (const :tag "None" nil)
992 :group 'gnus-summary)
994 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
995 "Variable that says which function should be used to decode a string with encoded words.")
997 (defcustom gnus-extra-headers '(To Newsgroups)
998 "*Extra headers to parse."
1000 :group 'gnus-summary
1001 :type '(repeat symbol))
1003 (defcustom gnus-ignored-from-addresses
1004 (and user-mail-address
1005 (not (string= user-mail-address ""))
1006 (regexp-quote user-mail-address))
1007 "*Regexp of From headers that may be suppressed in favor of To headers."
1009 :group 'gnus-summary
1012 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1013 "List of charsets that should be ignored.
1014 When these charsets are used in the \"charset\" parameter, the
1015 default charset will be used instead."
1017 :type '(repeat symbol)
1018 :group 'gnus-charset)
1020 (gnus-define-group-parameter
1024 "Return the ignored charsets of GROUP."
1025 :variable gnus-group-ignored-charsets-alist
1027 '(("alt\\.chinese\\.text" iso-8859-1))
1029 "Alist of regexps (to match group names) and charsets that should be ignored.
1030 When these charsets are used in the \"charset\" parameter, the
1031 default charset will be used instead."
1032 :variable-group gnus-charset
1033 :variable-type '(repeat (cons (regexp :tag "Group")
1035 :parameter-type '(choice :tag "Ignored charsets"
1038 :parameter-document "\
1039 List of charsets that should be ignored.
1041 When these charsets are used in the \"charset\" parameter, the
1042 default charset will be used instead.")
1044 (defcustom gnus-group-highlight-words-alist nil
1045 "Alist of group regexps and highlight regexps.
1046 This variable uses the same syntax as `gnus-emphasis-alist'."
1048 :type '(repeat (cons (regexp :tag "Group")
1049 (repeat (list (regexp :tag "Highlight regexp")
1050 (number :tag "Group for entire word" 0)
1051 (number :tag "Group for displayed part" 0)
1053 gnus-emphasis-highlight-words)))))
1054 :group 'gnus-summary-visual)
1056 (defcustom gnus-summary-show-article-charset-alist
1058 "Alist of number and charset.
1059 The article will be shown with the charset corresponding to the
1061 For example: ((1 . cn-gb-2312) (2 . big5))."
1063 :type '(repeat (cons (number :tag "Argument" 1)
1064 (symbol :tag "Charset")))
1065 :group 'gnus-charset)
1067 (defcustom gnus-preserve-marks t
1068 "Whether marks are preserved when moving, copying and respooling messages."
1071 :group 'gnus-summary-marks)
1073 (defcustom gnus-alter-articles-to-read-function nil
1074 "Function to be called to alter the list of articles to be selected."
1075 :type '(choice (const nil) function)
1076 :group 'gnus-summary)
1078 (defcustom gnus-orphan-score nil
1079 "*All orphans get this score added. Set in the score file."
1080 :group 'gnus-score-default
1081 :type '(choice (const nil)
1084 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1085 "*A regexp to match MIME parts when saving multiple parts of a
1086 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1087 This regexp will be used by default when prompting the user for which
1088 type of files to save."
1089 :group 'gnus-summary
1092 (defcustom gnus-read-all-available-headers nil
1093 "Whether Gnus should parse all headers made available to it.
1094 This is mostly relevant for slow back ends where the user may
1095 wish to widen the summary buffer to include all headers
1096 that were fetched. Say, for nnultimate groups."
1098 :group 'gnus-summary
1099 :type '(choice boolean regexp))
1101 (defcustom gnus-summary-muttprint-program "muttprint"
1102 "Command (and optional arguments) used to run Muttprint."
1104 :group 'gnus-summary
1107 (defcustom gnus-article-loose-mime nil
1108 "If non-nil, don't require MIME-Version header.
1109 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1110 supply the MIME-Version header or deliberately strip it from the mail.
1111 Set it to non-nil, Gnus will treat some articles as MIME even if
1112 the MIME-Version header is missed."
1115 :group 'gnus-article-mime)
1117 (defcustom gnus-article-emulate-mime t
1118 "If non-nil, use MIME emulation for uuencode and the like.
1119 This means that Gnus will search message bodies for text that look
1120 like uuencoded bits, yEncoded bits, and so on, and present that using
1121 the normal Gnus MIME machinery."
1124 :group 'gnus-article-mime)
1126 ;;; Internal variables
1128 (defvar gnus-summary-display-cache nil)
1129 (defvar gnus-article-mime-handles nil)
1130 (defvar gnus-article-decoded-p nil)
1131 (defvar gnus-article-charset nil)
1132 (defvar gnus-article-ignored-charsets nil)
1133 (defvar gnus-scores-exclude-files nil)
1134 (defvar gnus-page-broken nil)
1136 (defvar gnus-original-article nil)
1137 (defvar gnus-article-internal-prepare-hook nil)
1138 (defvar gnus-newsgroup-process-stack nil)
1140 (defvar gnus-thread-indent-array nil)
1141 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1142 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1143 "Function called to sort the articles within a thread after it has been gathered together.")
1145 (defvar gnus-summary-save-parts-type-history nil)
1146 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1148 ;; Avoid highlighting in kill files.
1149 (defvar gnus-summary-inhibit-highlight nil)
1150 (defvar gnus-newsgroup-selected-overlay nil)
1151 (defvar gnus-inhibit-limiting nil)
1152 (defvar gnus-newsgroup-adaptive-score-file nil)
1153 (defvar gnus-current-score-file nil)
1154 (defvar gnus-current-move-group nil)
1155 (defvar gnus-current-copy-group nil)
1156 (defvar gnus-current-crosspost-group nil)
1157 (defvar gnus-newsgroup-display nil)
1159 (defvar gnus-newsgroup-dependencies nil)
1160 (defvar gnus-newsgroup-adaptive nil)
1161 (defvar gnus-summary-display-article-function nil)
1162 (defvar gnus-summary-highlight-line-function nil
1163 "Function called after highlighting a summary line.")
1165 (defvar gnus-summary-line-format-alist
1166 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1167 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1168 (?s gnus-tmp-subject-or-nil ?s)
1169 (?n gnus-tmp-name ?s)
1170 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1172 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1174 (?F gnus-tmp-from ?s)
1175 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1176 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1177 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1178 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1179 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1180 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1181 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1182 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1183 (?L gnus-tmp-lines ?s)
1184 (?O gnus-tmp-downloaded ?c)
1185 (?I gnus-tmp-indentation ?s)
1186 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1187 (?R gnus-tmp-replied ?c)
1188 (?\[ gnus-tmp-opening-bracket ?c)
1189 (?\] gnus-tmp-closing-bracket ?c)
1190 (?\> (make-string gnus-tmp-level ? ) ?s)
1191 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1192 (?i gnus-tmp-score ?d)
1193 (?z gnus-tmp-score-char ?c)
1194 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1195 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1196 (?U gnus-tmp-unread ?c)
1197 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1199 (?t (gnus-summary-number-of-articles-in-thread
1200 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1202 (?e (gnus-summary-number-of-articles-in-thread
1203 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1205 (?u gnus-tmp-user-defined ?s)
1206 (?P (gnus-pick-line-number) ?d)
1207 (?B gnus-tmp-thread-tree-header-string ?s)
1208 (user-date (gnus-user-date
1209 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1210 "An alist of format specifications that can appear in summary lines.
1211 These are paired with what variables they correspond with, along with
1212 the type of the variable (string, integer, character, etc).")
1214 (defvar gnus-summary-dummy-line-format-alist
1215 `((?S gnus-tmp-subject ?s)
1216 (?N gnus-tmp-number ?d)
1217 (?u gnus-tmp-user-defined ?s)))
1219 (defvar gnus-summary-mode-line-format-alist
1220 `((?G gnus-tmp-group-name ?s)
1221 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1222 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1223 (?A gnus-tmp-article-number ?d)
1224 (?Z gnus-tmp-unread-and-unselected ?s)
1225 (?V gnus-version ?s)
1226 (?U gnus-tmp-unread-and-unticked ?d)
1227 (?S gnus-tmp-subject ?s)
1228 (?e gnus-tmp-unselected ?d)
1229 (?u gnus-tmp-user-defined ?s)
1230 (?d (length gnus-newsgroup-dormant) ?d)
1231 (?t (length gnus-newsgroup-marked) ?d)
1232 (?h (length gnus-newsgroup-spam-marked) ?d)
1233 (?r (length gnus-newsgroup-reads) ?d)
1234 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1235 (?E gnus-newsgroup-expunged-tally ?d)
1236 (?s (gnus-current-score-file-nondirectory) ?s)))
1238 (defvar gnus-last-search-regexp nil
1239 "Default regexp for article search command.")
1241 (defvar gnus-last-shell-command nil
1242 "Default shell command on article.")
1244 (defvar gnus-newsgroup-agentized nil
1245 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1246 (defvar gnus-newsgroup-begin nil)
1247 (defvar gnus-newsgroup-end nil)
1248 (defvar gnus-newsgroup-last-rmail nil)
1249 (defvar gnus-newsgroup-last-mail nil)
1250 (defvar gnus-newsgroup-last-folder nil)
1251 (defvar gnus-newsgroup-last-file nil)
1252 (defvar gnus-newsgroup-auto-expire nil)
1253 (defvar gnus-newsgroup-active nil)
1255 (defvar gnus-newsgroup-data nil)
1256 (defvar gnus-newsgroup-data-reverse nil)
1257 (defvar gnus-newsgroup-limit nil)
1258 (defvar gnus-newsgroup-limits nil)
1259 (defvar gnus-summary-use-undownloaded-faces nil)
1261 (defvar gnus-newsgroup-unreads nil
1262 "Sorted list of unread articles in the current newsgroup.")
1264 (defvar gnus-newsgroup-unselected nil
1265 "Sorted list of unselected unread articles in the current newsgroup.")
1267 (defvar gnus-newsgroup-reads nil
1268 "Alist of read articles and article marks in the current newsgroup.")
1270 (defvar gnus-newsgroup-expunged-tally nil)
1272 (defvar gnus-newsgroup-marked nil
1273 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1275 (defvar gnus-newsgroup-spam-marked nil
1276 "List of ranges of articles that have been marked as spam.")
1278 (defvar gnus-newsgroup-killed nil
1279 "List of ranges of articles that have been through the scoring process.")
1281 (defvar gnus-newsgroup-cached nil
1282 "Sorted list of articles that come from the article cache.")
1284 (defvar gnus-newsgroup-saved nil
1285 "List of articles that have been saved.")
1287 (defvar gnus-newsgroup-kill-headers nil)
1289 (defvar gnus-newsgroup-replied nil
1290 "List of articles that have been replied to in the current newsgroup.")
1292 (defvar gnus-newsgroup-forwarded nil
1293 "List of articles that have been forwarded in the current newsgroup.")
1295 (defvar gnus-newsgroup-recent nil
1296 "List of articles that have are recent in the current newsgroup.")
1298 (defvar gnus-newsgroup-expirable nil
1299 "Sorted list of articles in the current newsgroup that can be expired.")
1301 (defvar gnus-newsgroup-processable nil
1302 "List of articles in the current newsgroup that can be processed.")
1304 (defvar gnus-newsgroup-downloadable nil
1305 "Sorted list of articles in the current newsgroup that can be processed.")
1307 (defvar gnus-newsgroup-unfetched nil
1308 "Sorted list of articles in the current newsgroup whose headers have
1309 not been fetched into the agent.
1311 This list will always be a subset of gnus-newsgroup-undownloaded.")
1313 (defvar gnus-newsgroup-undownloaded nil
1314 "List of articles in the current newsgroup that haven't been downloaded.")
1316 (defvar gnus-newsgroup-unsendable nil
1317 "List of articles in the current newsgroup that won't be sent.")
1319 (defvar gnus-newsgroup-bookmarks nil
1320 "List of articles in the current newsgroup that have bookmarks.")
1322 (defvar gnus-newsgroup-dormant nil
1323 "Sorted list of dormant articles in the current newsgroup.")
1325 (defvar gnus-newsgroup-unseen nil
1326 "List of unseen articles in the current newsgroup.")
1328 (defvar gnus-newsgroup-seen nil
1329 "Range of seen articles in the current newsgroup.")
1331 (defvar gnus-newsgroup-articles nil
1332 "List of articles in the current newsgroup.")
1334 (defvar gnus-newsgroup-scored nil
1335 "List of scored articles in the current newsgroup.")
1337 (defvar gnus-newsgroup-headers nil
1338 "List of article headers in the current newsgroup.")
1340 (defvar gnus-newsgroup-threads nil)
1342 (defvar gnus-newsgroup-prepared nil
1343 "Whether the current group has been prepared properly.")
1345 (defvar gnus-newsgroup-ancient nil
1346 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1348 (defvar gnus-newsgroup-sparse nil)
1350 (defvar gnus-current-article nil)
1351 (defvar gnus-article-current nil)
1352 (defvar gnus-current-headers nil)
1353 (defvar gnus-have-all-headers nil)
1354 (defvar gnus-last-article nil)
1355 (defvar gnus-newsgroup-history nil)
1356 (defvar gnus-newsgroup-charset nil)
1357 (defvar gnus-newsgroup-ephemeral-charset nil)
1358 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1360 (defvar gnus-article-before-search nil)
1362 (defvar gnus-summary-local-variables
1363 '(gnus-newsgroup-name
1364 gnus-newsgroup-begin gnus-newsgroup-end
1365 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1366 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1367 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1368 gnus-newsgroup-unselected gnus-newsgroup-marked
1369 gnus-newsgroup-spam-marked
1370 gnus-newsgroup-reads gnus-newsgroup-saved
1371 gnus-newsgroup-replied gnus-newsgroup-forwarded
1372 gnus-newsgroup-recent
1373 gnus-newsgroup-expirable
1374 gnus-newsgroup-processable gnus-newsgroup-killed
1375 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1376 gnus-newsgroup-unfetched
1377 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1378 gnus-newsgroup-seen gnus-newsgroup-articles
1379 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1380 gnus-newsgroup-headers gnus-newsgroup-threads
1381 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1382 gnus-current-article gnus-current-headers gnus-have-all-headers
1383 gnus-last-article gnus-article-internal-prepare-hook
1384 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1385 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1386 gnus-thread-expunge-below
1387 gnus-score-alist gnus-current-score-file
1388 (gnus-summary-expunge-below . global)
1389 (gnus-summary-mark-below . global)
1390 (gnus-orphan-score . global)
1391 gnus-newsgroup-active gnus-scores-exclude-files
1392 gnus-newsgroup-history gnus-newsgroup-ancient
1393 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1394 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1395 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1396 (gnus-newsgroup-expunged-tally . 0)
1397 gnus-cache-removable-articles gnus-newsgroup-cached
1398 gnus-newsgroup-data gnus-newsgroup-data-reverse
1399 gnus-newsgroup-limit gnus-newsgroup-limits
1400 gnus-newsgroup-charset gnus-newsgroup-display
1401 gnus-summary-use-undownloaded-faces)
1402 "Variables that are buffer-local to the summary buffers.")
1404 (defvar gnus-newsgroup-variables nil
1405 "A list of variables that have separate values in different newsgroups.
1406 A list of newsgroup (summary buffer) local variables, or cons of
1407 variables and their default expressions to be evalled (when the default
1408 values are not nil), that should be made global while the summary buffer
1411 Note: The default expressions will be evaluated (using function `eval')
1412 before assignment to the local variable rather than just assigned to it.
1413 If the default expression is the symbol `global', that symbol will not
1414 be evaluated but the global value of the local variable will be used
1417 These variables can be used to set variables in the group parameters
1418 while still allowing them to affect operations done in other buffers.
1421 \(setq gnus-newsgroup-variables
1422 '(message-use-followup-to
1423 (gnus-visible-headers .
1424 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1427 ;; Byte-compiler warning.
1429 ;; Bind features so that require will believe that gnus-sum has
1430 ;; already been loaded (avoids infinite recursion)
1431 (let ((features (cons 'gnus-sum features)))
1432 ;; Several of the declarations in gnus-sum are needed to load the
1433 ;; following files. Right now, these definitions have been
1434 ;; compiled but not defined (evaluated). We could either do a
1435 ;; eval-and-compile about all of the declarations or evaluate the
1437 (if (boundp 'gnus-newsgroup-variables)
1439 (load "gnus-sum.el" t t t))
1441 (require 'gnus-agent)
1442 (require 'gnus-art)))
1446 (defvar gnus-decode-encoded-word-methods
1447 '(mail-decode-encoded-word-string)
1448 "List of methods used to decode encoded words.
1450 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1451 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1452 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1453 whose names match REGEXP.
1456 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1457 mail-decode-encoded-word-string
1458 (\"chinese\" . rfc1843-decode-string))")
1460 (defvar gnus-decode-encoded-word-methods-cache nil)
1462 (defun gnus-multi-decode-encoded-word-string (string)
1463 "Apply the functions from `gnus-encoded-word-methods' that match."
1464 (unless (and gnus-decode-encoded-word-methods-cache
1465 (eq gnus-newsgroup-name
1466 (car gnus-decode-encoded-word-methods-cache)))
1467 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1470 (nconc gnus-decode-encoded-word-methods-cache (list x))
1471 (if (and gnus-newsgroup-name
1472 (string-match (car x) gnus-newsgroup-name))
1473 (nconc gnus-decode-encoded-word-methods-cache
1475 gnus-decode-encoded-word-methods))
1476 (let ((xlist gnus-decode-encoded-word-methods-cache))
1479 (setq string (funcall (pop xlist) string))))
1482 ;; Subject simplification.
1484 (defun gnus-simplify-whitespace (str)
1485 "Remove excessive whitespace from STR."
1487 (while (string-match "[ \t][ \t]+" str)
1488 (setq str (concat (substring str 0 (match-beginning 0))
1490 (substring str (match-end 0)))))
1492 (when (string-match "^[ \t]+" str)
1493 (setq str (substring str (match-end 0))))
1495 (when (string-match "[ \t]+$" str)
1496 (setq str (substring str 0 (match-beginning 0))))
1499 (defun gnus-simplify-all-whitespace (str)
1500 "Remove all whitespace from STR."
1501 (while (string-match "[ \t\n]+" str)
1502 (setq str (replace-match "" nil nil str)))
1505 (defsubst gnus-simplify-subject-re (subject)
1506 "Remove \"Re:\" from subject lines."
1507 (if (string-match message-subject-re-regexp subject)
1508 (substring subject (match-end 0))
1511 (defun gnus-simplify-subject (subject &optional re-only)
1512 "Remove `Re:' and words in parentheses.
1513 If RE-ONLY is non-nil, strip leading `Re:'s only."
1514 (let ((case-fold-search t)) ;Ignore case.
1515 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1516 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1517 (setq subject (substring subject (match-end 0))))
1518 ;; Remove uninteresting prefixes.
1519 (when (and (not re-only)
1520 gnus-simplify-ignored-prefixes
1521 (string-match gnus-simplify-ignored-prefixes subject))
1522 (setq subject (substring subject (match-end 0))))
1523 ;; Remove words in parentheses from end.
1525 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1526 (setq subject (substring subject 0 (match-beginning 0)))))
1527 ;; Return subject string.
1530 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1532 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1533 (goto-char (point-min))
1534 (while (re-search-forward regexp nil t)
1535 (replace-match (or newtext ""))))
1537 (defun gnus-simplify-buffer-fuzzy ()
1538 "Simplify string in the buffer fuzzily.
1539 The string in the accessible portion of the current buffer is simplified.
1540 It is assumed to be a single-line subject.
1541 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1542 matter is removed. Additional things can be deleted by setting
1543 `gnus-simplify-subject-fuzzy-regexp'."
1544 (let ((case-fold-search t)
1546 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1548 (while (not (eq modified-tick (buffer-modified-tick)))
1549 (setq modified-tick (buffer-modified-tick))
1551 ((listp gnus-simplify-subject-fuzzy-regexp)
1552 (mapcar 'gnus-simplify-buffer-fuzzy-step
1553 gnus-simplify-subject-fuzzy-regexp))
1554 (gnus-simplify-subject-fuzzy-regexp
1555 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1556 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1557 (gnus-simplify-buffer-fuzzy-step
1558 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1559 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1561 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1562 (gnus-simplify-buffer-fuzzy-step " +" " ")
1563 (gnus-simplify-buffer-fuzzy-step " $")
1564 (gnus-simplify-buffer-fuzzy-step "^ +")))
1566 (defun gnus-simplify-subject-fuzzy (subject)
1567 "Simplify a subject string fuzzily.
1568 See `gnus-simplify-buffer-fuzzy' for details."
1570 (gnus-set-work-buffer)
1571 (let ((case-fold-search t))
1572 ;; Remove uninteresting prefixes.
1573 (when (and gnus-simplify-ignored-prefixes
1574 (string-match gnus-simplify-ignored-prefixes subject))
1575 (setq subject (substring subject (match-end 0))))
1577 (inline (gnus-simplify-buffer-fuzzy))
1580 (defsubst gnus-simplify-subject-fully (subject)
1581 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1583 (gnus-simplify-subject-functions
1584 (gnus-map-function gnus-simplify-subject-functions subject))
1585 ((null gnus-summary-gather-subject-limit)
1586 (gnus-simplify-subject-re subject))
1587 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1588 (gnus-simplify-subject-fuzzy subject))
1589 ((numberp gnus-summary-gather-subject-limit)
1590 (gnus-limit-string (gnus-simplify-subject-re subject)
1591 gnus-summary-gather-subject-limit))
1595 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1596 "Check whether two subjects are equal.
1597 If optional argument SIMPLE-FIRST is t, first argument is already
1600 ((null simple-first)
1601 (equal (gnus-simplify-subject-fully s1)
1602 (gnus-simplify-subject-fully s2)))
1605 (gnus-simplify-subject-fully s2)))))
1607 (defun gnus-summary-bubble-group ()
1608 "Increase the score of the current group.
1609 This is a handy function to add to `gnus-summary-exit-hook' to
1610 increase the score of each group you read."
1611 (gnus-group-add-score gnus-newsgroup-name))
1615 ;;; Gnus summary mode
1618 (put 'gnus-summary-mode 'mode-class 'special)
1620 (defvar gnus-article-commands-menu)
1622 ;; Non-orthogonal keys
1624 (gnus-define-keys gnus-summary-mode-map
1625 " " gnus-summary-next-page
1626 "\177" gnus-summary-prev-page
1627 [delete] gnus-summary-prev-page
1628 [backspace] gnus-summary-prev-page
1629 "\r" gnus-summary-scroll-up
1630 "\M-\r" gnus-summary-scroll-down
1631 "n" gnus-summary-next-unread-article
1632 "p" gnus-summary-prev-unread-article
1633 "N" gnus-summary-next-article
1634 "P" gnus-summary-prev-article
1635 "\M-\C-n" gnus-summary-next-same-subject
1636 "\M-\C-p" gnus-summary-prev-same-subject
1637 "\M-n" gnus-summary-next-unread-subject
1638 "\M-p" gnus-summary-prev-unread-subject
1639 "." gnus-summary-first-unread-article
1640 "," gnus-summary-best-unread-article
1641 "\M-s" gnus-summary-search-article-forward
1642 "\M-r" gnus-summary-search-article-backward
1643 "<" gnus-summary-beginning-of-article
1644 ">" gnus-summary-end-of-article
1645 "j" gnus-summary-goto-article
1646 "^" gnus-summary-refer-parent-article
1647 "\M-^" gnus-summary-refer-article
1648 "u" gnus-summary-tick-article-forward
1649 "!" gnus-summary-tick-article-forward
1650 "U" gnus-summary-tick-article-backward
1651 "d" gnus-summary-mark-as-read-forward
1652 "D" gnus-summary-mark-as-read-backward
1653 "E" gnus-summary-mark-as-expirable
1654 "\M-u" gnus-summary-clear-mark-forward
1655 "\M-U" gnus-summary-clear-mark-backward
1656 "k" gnus-summary-kill-same-subject-and-select
1657 "\C-k" gnus-summary-kill-same-subject
1658 "\M-\C-k" gnus-summary-kill-thread
1659 "\M-\C-l" gnus-summary-lower-thread
1660 "e" gnus-summary-edit-article
1661 "#" gnus-summary-mark-as-processable
1662 "\M-#" gnus-summary-unmark-as-processable
1663 "\M-\C-t" gnus-summary-toggle-threads
1664 "\M-\C-s" gnus-summary-show-thread
1665 "\M-\C-h" gnus-summary-hide-thread
1666 "\M-\C-f" gnus-summary-next-thread
1667 "\M-\C-b" gnus-summary-prev-thread
1668 [(meta down)] gnus-summary-next-thread
1669 [(meta up)] gnus-summary-prev-thread
1670 "\M-\C-u" gnus-summary-up-thread
1671 "\M-\C-d" gnus-summary-down-thread
1672 "&" gnus-summary-execute-command
1673 "c" gnus-summary-catchup-and-exit
1674 "\C-w" gnus-summary-mark-region-as-read
1675 "\C-t" gnus-summary-toggle-truncation
1676 "?" gnus-summary-mark-as-dormant
1677 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1678 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1679 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1680 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1681 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1682 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1683 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1684 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1685 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1686 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1687 "=" gnus-summary-expand-window
1688 "\C-x\C-s" gnus-summary-reselect-current-group
1689 "\M-g" gnus-summary-rescan-group
1690 "w" gnus-summary-stop-page-breaking
1691 "\C-c\C-r" gnus-summary-caesar-message
1692 "f" gnus-summary-followup
1693 "F" gnus-summary-followup-with-original
1694 "C" gnus-summary-cancel-article
1695 "r" gnus-summary-reply
1696 "R" gnus-summary-reply-with-original
1697 "\C-c\C-f" gnus-summary-mail-forward
1698 "o" gnus-summary-save-article
1699 "\C-o" gnus-summary-save-article-mail
1700 "|" gnus-summary-pipe-output
1701 "\M-k" gnus-summary-edit-local-kill
1702 "\M-K" gnus-summary-edit-global-kill
1704 "\C-c\C-d" gnus-summary-describe-group
1705 "q" gnus-summary-exit
1706 "Q" gnus-summary-exit-no-update
1707 "\C-c\C-i" gnus-info-find-node
1708 gnus-mouse-2 gnus-mouse-pick-article
1709 [follow-link] mouse-face
1710 "m" gnus-summary-mail-other-window
1711 "a" gnus-summary-post-news
1712 "i" gnus-summary-news-other-window
1713 "x" gnus-summary-limit-to-unread
1714 "s" gnus-summary-isearch-article
1715 "t" gnus-summary-toggle-header
1716 "g" gnus-summary-show-article
1717 "l" gnus-summary-goto-last-article
1718 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1719 "\C-d" gnus-summary-enter-digest-group
1720 "\M-\C-d" gnus-summary-read-document
1721 "\M-\C-e" gnus-summary-edit-parameters
1722 "\M-\C-a" gnus-summary-customize-parameters
1724 "*" gnus-cache-enter-article
1725 "\M-*" gnus-cache-remove-article
1726 "\M-&" gnus-summary-universal-argument
1727 "\C-l" gnus-recenter
1728 "I" gnus-summary-increase-score
1729 "L" gnus-summary-lower-score
1730 "\M-i" gnus-symbolic-argument
1731 "h" gnus-summary-select-article-buffer
1733 "b" gnus-article-view-part
1734 "\M-t" gnus-summary-toggle-display-buttonized
1736 "V" gnus-summary-score-map
1737 "X" gnus-uu-extract-map
1738 "S" gnus-summary-send-map)
1740 ;; Sort of orthogonal keymap
1741 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1742 "t" gnus-summary-tick-article-forward
1743 "!" gnus-summary-tick-article-forward
1744 "d" gnus-summary-mark-as-read-forward
1745 "r" gnus-summary-mark-as-read-forward
1746 "c" gnus-summary-clear-mark-forward
1747 " " gnus-summary-clear-mark-forward
1748 "e" gnus-summary-mark-as-expirable
1749 "x" gnus-summary-mark-as-expirable
1750 "?" gnus-summary-mark-as-dormant
1751 "b" gnus-summary-set-bookmark
1752 "B" gnus-summary-remove-bookmark
1753 "#" gnus-summary-mark-as-processable
1754 "\M-#" gnus-summary-unmark-as-processable
1755 "S" gnus-summary-limit-include-expunged
1756 "C" gnus-summary-catchup
1757 "H" gnus-summary-catchup-to-here
1758 "h" gnus-summary-catchup-from-here
1759 "\C-c" gnus-summary-catchup-all
1760 "k" gnus-summary-kill-same-subject-and-select
1761 "K" gnus-summary-kill-same-subject
1762 "P" gnus-uu-mark-map)
1764 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1765 "c" gnus-summary-clear-above
1766 "u" gnus-summary-tick-above
1767 "m" gnus-summary-mark-above
1768 "k" gnus-summary-kill-below)
1770 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1771 "/" gnus-summary-limit-to-subject
1772 "n" gnus-summary-limit-to-articles
1773 "w" gnus-summary-pop-limit
1774 "s" gnus-summary-limit-to-subject
1775 "a" gnus-summary-limit-to-author
1776 "u" gnus-summary-limit-to-unread
1777 "m" gnus-summary-limit-to-marks
1778 "M" gnus-summary-limit-exclude-marks
1779 "v" gnus-summary-limit-to-score
1780 "*" gnus-summary-limit-include-cached
1781 "D" gnus-summary-limit-include-dormant
1782 "T" gnus-summary-limit-include-thread
1783 "d" gnus-summary-limit-exclude-dormant
1784 "t" gnus-summary-limit-to-age
1785 "." gnus-summary-limit-to-unseen
1786 "x" gnus-summary-limit-to-extra
1787 "p" gnus-summary-limit-to-display-predicate
1788 "E" gnus-summary-limit-include-expunged
1789 "c" gnus-summary-limit-exclude-childless-dormant
1790 "C" gnus-summary-limit-mark-excluded-as-read
1791 "o" gnus-summary-insert-old-articles
1792 "N" gnus-summary-insert-new-articles)
1794 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1795 "n" gnus-summary-next-unread-article
1796 "p" gnus-summary-prev-unread-article
1797 "N" gnus-summary-next-article
1798 "P" gnus-summary-prev-article
1799 "\C-n" gnus-summary-next-same-subject
1800 "\C-p" gnus-summary-prev-same-subject
1801 "\M-n" gnus-summary-next-unread-subject
1802 "\M-p" gnus-summary-prev-unread-subject
1803 "f" gnus-summary-first-unread-article
1804 "b" gnus-summary-best-unread-article
1805 "j" gnus-summary-goto-article
1806 "g" gnus-summary-goto-subject
1807 "l" gnus-summary-goto-last-article
1808 "o" gnus-summary-pop-article)
1810 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1811 "k" gnus-summary-kill-thread
1812 "l" gnus-summary-lower-thread
1813 "i" gnus-summary-raise-thread
1814 "T" gnus-summary-toggle-threads
1815 "t" gnus-summary-rethread-current
1816 "^" gnus-summary-reparent-thread
1817 "s" gnus-summary-show-thread
1818 "S" gnus-summary-show-all-threads
1819 "h" gnus-summary-hide-thread
1820 "H" gnus-summary-hide-all-threads
1821 "n" gnus-summary-next-thread
1822 "p" gnus-summary-prev-thread
1823 "u" gnus-summary-up-thread
1824 "o" gnus-summary-top-thread
1825 "d" gnus-summary-down-thread
1826 "#" gnus-uu-mark-thread
1827 "\M-#" gnus-uu-unmark-thread)
1829 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1830 "g" gnus-summary-prepare
1831 "c" gnus-summary-insert-cached-articles
1832 "d" gnus-summary-insert-dormant-articles)
1834 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1835 "c" gnus-summary-catchup-and-exit
1836 "C" gnus-summary-catchup-all-and-exit
1837 "E" gnus-summary-exit-no-update
1838 "Q" gnus-summary-exit
1839 "Z" gnus-summary-exit
1840 "n" gnus-summary-catchup-and-goto-next-group
1841 "R" gnus-summary-reselect-current-group
1842 "G" gnus-summary-rescan-group
1843 "N" gnus-summary-next-group
1844 "s" gnus-summary-save-newsrc
1845 "P" gnus-summary-prev-group)
1847 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1848 " " gnus-summary-next-page
1849 "n" gnus-summary-next-page
1850 "\177" gnus-summary-prev-page
1851 [delete] gnus-summary-prev-page
1852 "p" gnus-summary-prev-page
1853 "\r" gnus-summary-scroll-up
1854 "\M-\r" gnus-summary-scroll-down
1855 "<" gnus-summary-beginning-of-article
1856 ">" gnus-summary-end-of-article
1857 "b" gnus-summary-beginning-of-article
1858 "e" gnus-summary-end-of-article
1859 "^" gnus-summary-refer-parent-article
1860 "r" gnus-summary-refer-parent-article
1861 "D" gnus-summary-enter-digest-group
1862 "R" gnus-summary-refer-references
1863 "T" gnus-summary-refer-thread
1864 "g" gnus-summary-show-article
1865 "s" gnus-summary-isearch-article
1866 "P" gnus-summary-print-article
1867 "M" gnus-mailing-list-insinuate
1868 "t" gnus-article-babel)
1870 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1871 "b" gnus-article-add-buttons
1872 "B" gnus-article-add-buttons-to-head
1873 "o" gnus-article-treat-overstrike
1874 "e" gnus-article-emphasize
1875 "w" gnus-article-fill-cited-article
1876 "Q" gnus-article-fill-long-lines
1877 "C" gnus-article-capitalize-sentences
1878 "c" gnus-article-remove-cr
1879 "q" gnus-article-de-quoted-unreadable
1880 "6" gnus-article-de-base64-unreadable
1881 "Z" gnus-article-decode-HZ
1882 "h" gnus-article-wash-html
1883 "u" gnus-article-unsplit-urls
1884 "s" gnus-summary-force-verify-and-decrypt
1885 "f" gnus-article-display-x-face
1886 "l" gnus-summary-stop-page-breaking
1887 "r" gnus-summary-caesar-message
1888 "m" gnus-summary-morse-message
1889 "t" gnus-summary-toggle-header
1890 "g" gnus-treat-smiley
1891 "v" gnus-summary-verbose-headers
1892 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1893 "p" gnus-article-verify-x-pgp-sig
1894 "d" gnus-article-treat-dumbquotes)
1896 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1897 ;; mnemonic: deuglif*Y*
1898 "u" gnus-article-outlook-unwrap-lines
1899 "a" gnus-article-outlook-repair-attribution
1900 "c" gnus-article-outlook-rearrange-citation
1901 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1903 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1904 "a" gnus-article-hide
1905 "h" gnus-article-hide-headers
1906 "b" gnus-article-hide-boring-headers
1907 "s" gnus-article-hide-signature
1908 "c" gnus-article-hide-citation
1909 "C" gnus-article-hide-citation-in-followups
1910 "l" gnus-article-hide-list-identifiers
1911 "B" gnus-article-strip-banner
1912 "P" gnus-article-hide-pem
1913 "\C-c" gnus-article-hide-citation-maybe)
1915 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1916 "a" gnus-article-highlight
1917 "h" gnus-article-highlight-headers
1918 "c" gnus-article-highlight-citation
1919 "s" gnus-article-highlight-signature)
1921 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1922 "f" gnus-article-treat-fold-headers
1923 "u" gnus-article-treat-unfold-headers
1924 "n" gnus-article-treat-fold-newsgroups)
1926 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1927 "x" gnus-article-display-x-face
1928 "d" gnus-article-display-face
1929 "s" gnus-treat-smiley
1930 "D" gnus-article-remove-images
1931 "f" gnus-treat-from-picon
1932 "m" gnus-treat-mail-picon
1933 "n" gnus-treat-newsgroups-picon)
1935 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1936 "w" gnus-article-decode-mime-words
1937 "c" gnus-article-decode-charset
1938 "v" gnus-mime-view-all-parts
1939 "b" gnus-article-view-part)
1941 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1942 "z" gnus-article-date-ut
1943 "u" gnus-article-date-ut
1944 "l" gnus-article-date-local
1945 "p" gnus-article-date-english
1946 "e" gnus-article-date-lapsed
1947 "o" gnus-article-date-original
1948 "i" gnus-article-date-iso8601
1949 "s" gnus-article-date-user)
1951 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1952 "t" gnus-article-remove-trailing-blank-lines
1953 "l" gnus-article-strip-leading-blank-lines
1954 "m" gnus-article-strip-multiple-blank-lines
1955 "a" gnus-article-strip-blank-lines
1956 "A" gnus-article-strip-all-blank-lines
1957 "s" gnus-article-strip-leading-space
1958 "e" gnus-article-strip-trailing-space
1959 "w" gnus-article-remove-leading-whitespace)
1961 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1963 "f" gnus-summary-fetch-faq
1964 "d" gnus-summary-describe-group
1965 "h" gnus-summary-describe-briefly
1966 "i" gnus-info-find-node
1967 "c" gnus-group-fetch-charter
1968 "C" gnus-group-fetch-control)
1970 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1971 "e" gnus-summary-expire-articles
1972 "\M-\C-e" gnus-summary-expire-articles-now
1973 "\177" gnus-summary-delete-article
1974 [delete] gnus-summary-delete-article
1975 [backspace] gnus-summary-delete-article
1976 "m" gnus-summary-move-article
1977 "r" gnus-summary-respool-article
1978 "w" gnus-summary-edit-article
1979 "c" gnus-summary-copy-article
1980 "B" gnus-summary-crosspost-article
1981 "q" gnus-summary-respool-query
1982 "t" gnus-summary-respool-trace
1983 "i" gnus-summary-import-article
1984 "I" gnus-summary-create-article
1985 "p" gnus-summary-article-posted-p)
1987 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1988 "o" gnus-summary-save-article
1989 "m" gnus-summary-save-article-mail
1990 "F" gnus-summary-write-article-file
1991 "r" gnus-summary-save-article-rmail
1992 "f" gnus-summary-save-article-file
1993 "b" gnus-summary-save-article-body-file
1994 "h" gnus-summary-save-article-folder
1995 "v" gnus-summary-save-article-vm
1996 "p" gnus-summary-pipe-output
1997 "P" gnus-summary-muttprint
1998 "s" gnus-soup-add-article)
2000 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2001 "b" gnus-summary-display-buttonized
2002 "m" gnus-summary-repair-multipart
2003 "v" gnus-article-view-part
2004 "o" gnus-article-save-part
2005 "c" gnus-article-copy-part
2006 "C" gnus-article-view-part-as-charset
2007 "e" gnus-article-view-part-externally
2008 "E" gnus-article-encrypt-body
2009 "i" gnus-article-inline-part
2010 "|" gnus-article-pipe-part)
2012 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2013 "p" gnus-summary-mark-as-processable
2014 "u" gnus-summary-unmark-as-processable
2015 "U" gnus-summary-unmark-all-processable
2016 "v" gnus-uu-mark-over
2017 "s" gnus-uu-mark-series
2018 "r" gnus-uu-mark-region
2019 "g" gnus-uu-unmark-region
2020 "R" gnus-uu-mark-by-regexp
2021 "G" gnus-uu-unmark-by-regexp
2022 "t" gnus-uu-mark-thread
2023 "T" gnus-uu-unmark-thread
2024 "a" gnus-uu-mark-all
2025 "b" gnus-uu-mark-buffer
2026 "S" gnus-uu-mark-sparse
2027 "k" gnus-summary-kill-process-mark
2028 "y" gnus-summary-yank-process-mark
2029 "w" gnus-summary-save-process-mark
2030 "i" gnus-uu-invert-processable)
2032 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2033 ;;"x" gnus-uu-extract-any
2034 "m" gnus-summary-save-parts
2035 "u" gnus-uu-decode-uu
2036 "U" gnus-uu-decode-uu-and-save
2037 "s" gnus-uu-decode-unshar
2038 "S" gnus-uu-decode-unshar-and-save
2039 "o" gnus-uu-decode-save
2040 "O" gnus-uu-decode-save
2041 "b" gnus-uu-decode-binhex
2042 "B" gnus-uu-decode-binhex
2043 "p" gnus-uu-decode-postscript
2044 "P" gnus-uu-decode-postscript-and-save)
2047 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2048 "u" gnus-uu-decode-uu-view
2049 "U" gnus-uu-decode-uu-and-save-view
2050 "s" gnus-uu-decode-unshar-view
2051 "S" gnus-uu-decode-unshar-and-save-view
2052 "o" gnus-uu-decode-save-view
2053 "O" gnus-uu-decode-save-view
2054 "b" gnus-uu-decode-binhex-view
2055 "B" gnus-uu-decode-binhex-view
2056 "p" gnus-uu-decode-postscript-view
2057 "P" gnus-uu-decode-postscript-and-save-view)
2059 (defvar gnus-article-post-menu nil)
2061 (defconst gnus-summary-menu-maxlen 20)
2063 (defun gnus-summary-menu-split (menu)
2064 ;; If we have lots of elements, divide them into groups of 20
2065 ;; and make a pane (or submenu) for each one.
2066 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2067 (let ((menu menu) sublists next
2070 ;; Pull off the next gnus-summary-menu-maxlen elements
2071 ;; and make them the next element of sublist.
2072 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2074 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2076 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2077 (aref (car (last menu)) 0)) menu)
2081 (nreverse sublists))
2082 ;; Few elements--put them all in one pane.
2085 (defun gnus-summary-make-menu-bar ()
2086 (gnus-turn-off-edit-menu 'summary)
2088 (unless (boundp 'gnus-summary-misc-menu)
2091 gnus-summary-kill-menu gnus-summary-mode-map ""
2096 ["Customize" gnus-score-customize t])
2097 (gnus-make-score-map 'increase)
2098 (gnus-make-score-map 'lower)
2100 ["Kill below" gnus-summary-kill-below t]
2101 ["Mark above" gnus-summary-mark-above t]
2102 ["Tick above" gnus-summary-tick-above t]
2103 ["Clear above" gnus-summary-clear-above t])
2104 ["Current score" gnus-summary-current-score t]
2105 ["Set score" gnus-summary-set-score t]
2106 ["Switch current score file..." gnus-score-change-score-file t]
2107 ["Set mark below..." gnus-score-set-mark-below t]
2108 ["Set expunge below..." gnus-score-set-expunge-below t]
2109 ["Edit current score file" gnus-score-edit-current-scores t]
2110 ["Edit score file" gnus-score-edit-file t]
2111 ["Trace score" gnus-score-find-trace t]
2112 ["Find words" gnus-score-find-favourite-words t]
2113 ["Rescore buffer" gnus-summary-rescore t]
2114 ["Increase score..." gnus-summary-increase-score t]
2115 ["Lower score..." gnus-summary-lower-score t]))))
2117 ;; Define both the Article menu in the summary buffer and the
2118 ;; equivalent Commands menu in the article buffer here for
2122 ["All" gnus-article-hide t]
2123 ["Headers" gnus-article-hide-headers t]
2124 ["Signature" gnus-article-hide-signature t]
2125 ["Citation" gnus-article-hide-citation t]
2126 ["List identifiers" gnus-article-hide-list-identifiers t]
2127 ["Banner" gnus-article-strip-banner t]
2128 ["Boring headers" gnus-article-hide-boring-headers t])
2130 ["All" gnus-article-highlight t]
2131 ["Headers" gnus-article-highlight-headers t]
2132 ["Signature" gnus-article-highlight-signature t]
2133 ["Citation" gnus-article-highlight-citation t])
2135 ["Words" gnus-article-decode-mime-words t]
2136 ["Charset" gnus-article-decode-charset t]
2137 ["QP" gnus-article-de-quoted-unreadable t]
2138 ["Base64" gnus-article-de-base64-unreadable t]
2139 ["View MIME buttons" gnus-summary-display-buttonized t]
2140 ["View all" gnus-mime-view-all-parts t]
2141 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2142 ["Encrypt body" gnus-article-encrypt-body
2143 :active (not (gnus-group-read-only-p))
2144 ,@(if (featurep 'xemacs) nil
2145 '(:help "Encrypt the message body on disk"))]
2146 ["Extract all parts..." gnus-summary-save-parts t]
2148 ["Repair multipart" gnus-summary-repair-multipart t]
2149 ["Pipe part..." gnus-article-pipe-part t]
2150 ["Inline part" gnus-article-inline-part t]
2151 ["Encrypt body" gnus-article-encrypt-body
2152 :active (not (gnus-group-read-only-p))
2153 ,@(if (featurep 'xemacs) nil
2154 '(:help "Encrypt the message body on disk"))]
2155 ["View part externally" gnus-article-view-part-externally t]
2156 ["View part with charset..." gnus-article-view-part-as-charset t]
2157 ["Copy part" gnus-article-copy-part t]
2158 ["Save part..." gnus-article-save-part t]
2159 ["View part" gnus-article-view-part t]))
2161 ["Local" gnus-article-date-local t]
2162 ["ISO8601" gnus-article-date-iso8601 t]
2163 ["UT" gnus-article-date-ut t]
2164 ["Original" gnus-article-date-original t]
2165 ["Lapsed" gnus-article-date-lapsed t]
2166 ["User-defined" gnus-article-date-user t])
2168 ["Remove images" gnus-article-remove-images t]
2169 ["Toggle smiley" gnus-treat-smiley t]
2170 ["Show X-Face" gnus-article-display-x-face t]
2171 ["Show picons in From" gnus-treat-from-picon t]
2172 ["Show picons in mail headers" gnus-treat-mail-picon t]
2173 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2174 ("View as different encoding"
2175 ,@(gnus-summary-menu-split
2178 ;; Since easymenu under Emacs doesn't allow
2179 ;; lambda forms for menu commands, we should
2180 ;; provide intern'ed function symbols.
2181 (let ((command (intern (format "\
2182 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2186 (let ((gnus-summary-show-article-charset-alist
2188 (gnus-summary-show-article 1))))
2189 `[,(symbol-name cs) ,command t]))
2190 (sort (if (fboundp 'coding-system-list)
2191 (coding-system-list)
2192 (mapcar 'car mm-mime-mule-charset-alist))
2196 ["Leading" gnus-article-strip-leading-blank-lines t]
2197 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2198 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2199 ["All of the above" gnus-article-strip-blank-lines t]
2200 ["All" gnus-article-strip-all-blank-lines t]
2201 ["Leading space" gnus-article-strip-leading-space t]
2202 ["Trailing space" gnus-article-strip-trailing-space t]
2203 ["Leading space in headers"
2204 gnus-article-remove-leading-whitespace t])
2205 ["Overstrike" gnus-article-treat-overstrike t]
2206 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2207 ["Emphasis" gnus-article-emphasize t]
2208 ["Word wrap" gnus-article-fill-cited-article t]
2209 ["Fill long lines" gnus-article-fill-long-lines t]
2210 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2211 ["Remove CR" gnus-article-remove-cr t]
2212 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2213 ["Base64" gnus-article-de-base64-unreadable t]
2214 ["Rot 13" gnus-summary-caesar-message
2215 ,@(if (featurep 'xemacs) '(t)
2216 '(:help "\"Caesar rotate\" article by 13"))]
2217 ["Morse decode" gnus-summary-morse-message t]
2218 ["Unix pipe..." gnus-summary-pipe-message t]
2219 ["Add buttons" gnus-article-add-buttons t]
2220 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2221 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2222 ["Verbose header" gnus-summary-verbose-headers t]
2223 ["Toggle header" gnus-summary-toggle-header t]
2224 ["Unfold headers" gnus-article-treat-unfold-headers t]
2225 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2226 ["Html" gnus-article-wash-html t]
2227 ["Unsplit URLs" gnus-article-unsplit-urls t]
2228 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2229 ["Decode HZ" gnus-article-decode-HZ t]
2230 ("(Outlook) Deuglify"
2231 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2232 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2233 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2234 ["Full (Outlook) deuglify"
2235 gnus-article-outlook-deuglify-article t])
2238 ["Save in default format..." gnus-summary-save-article
2239 ,@(if (featurep 'xemacs) '(t)
2240 '(:help "Save article using default method"))]
2241 ["Save in file..." gnus-summary-save-article-file
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "Save article in file"))]
2244 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2245 ["Save in MH folder..." gnus-summary-save-article-folder t]
2246 ["Save in VM folder..." gnus-summary-save-article-vm t]
2247 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2248 ["Save body in file..." gnus-summary-save-article-body-file t]
2249 ["Pipe through a filter..." gnus-summary-pipe-output t]
2250 ["Add to SOUP packet" gnus-soup-add-article t]
2251 ["Print with Muttprint..." gnus-summary-muttprint t]
2252 ["Print" gnus-summary-print-article
2253 ,@(if (featurep 'xemacs) '(t)
2254 '(:help "Generate and print a PostScript image"))])
2255 ("Copy, move,... (Backend)"
2256 ,@(if (featurep 'xemacs) nil
2257 '(:help "Copying, moving, expiring articles..."))
2258 ["Respool article..." gnus-summary-respool-article t]
2259 ["Move article..." gnus-summary-move-article
2260 (gnus-check-backend-function
2261 'request-move-article gnus-newsgroup-name)]
2262 ["Copy article..." gnus-summary-copy-article t]
2263 ["Crosspost article..." gnus-summary-crosspost-article
2264 (gnus-check-backend-function
2265 'request-replace-article gnus-newsgroup-name)]
2266 ["Import file..." gnus-summary-import-article
2267 (gnus-check-backend-function
2268 'request-accept-article gnus-newsgroup-name)]
2269 ["Create article..." gnus-summary-create-article
2270 (gnus-check-backend-function
2271 'request-accept-article gnus-newsgroup-name)]
2272 ["Check if posted" gnus-summary-article-posted-p t]
2273 ["Edit article" gnus-summary-edit-article
2274 (not (gnus-group-read-only-p))]
2275 ["Delete article" gnus-summary-delete-article
2276 (gnus-check-backend-function
2277 'request-expire-articles gnus-newsgroup-name)]
2278 ["Query respool" gnus-summary-respool-query t]
2279 ["Trace respool" gnus-summary-respool-trace t]
2280 ["Delete expirable articles" gnus-summary-expire-articles-now
2281 (gnus-check-backend-function
2282 'request-expire-articles gnus-newsgroup-name)])
2284 ["Uudecode" gnus-uu-decode-uu
2285 ,@(if (featurep 'xemacs) '(t)
2286 '(:help "Decode uuencoded article(s)"))]
2287 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2288 ["Unshar" gnus-uu-decode-unshar t]
2289 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2290 ["Save" gnus-uu-decode-save t]
2291 ["Binhex" gnus-uu-decode-binhex t]
2292 ["Postscript" gnus-uu-decode-postscript t]
2293 ["All MIME parts" gnus-summary-save-parts t])
2295 ["Enter article" gnus-cache-enter-article t]
2296 ["Remove article" gnus-cache-remove-article t])
2297 ["Translate" gnus-article-babel t]
2298 ["Select article buffer" gnus-summary-select-article-buffer t]
2299 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2300 ["Isearch article..." gnus-summary-isearch-article t]
2301 ["Beginning of the article" gnus-summary-beginning-of-article t]
2302 ["End of the article" gnus-summary-end-of-article t]
2303 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2304 ["Fetch referenced articles" gnus-summary-refer-references t]
2305 ["Fetch current thread" gnus-summary-refer-thread t]
2306 ["Fetch article with id..." gnus-summary-refer-article t]
2307 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2308 ["Redisplay" gnus-summary-show-article t]
2309 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2311 gnus-summary-article-menu gnus-summary-mode-map ""
2312 (cons "Article" innards))
2314 (if (not (keymapp gnus-summary-article-menu))
2316 gnus-article-commands-menu gnus-article-mode-map ""
2317 (cons "Commands" innards))
2318 ;; in Emacs, don't share menu.
2319 (setq gnus-article-commands-menu
2320 (copy-keymap gnus-summary-article-menu))
2321 (define-key gnus-article-mode-map [menu-bar commands]
2322 (cons "Commands" gnus-article-commands-menu))))
2325 gnus-summary-thread-menu gnus-summary-mode-map ""
2327 ["Find all messages in thread" gnus-summary-refer-thread t]
2328 ["Toggle threading" gnus-summary-toggle-threads t]
2329 ["Hide threads" gnus-summary-hide-all-threads t]
2330 ["Show threads" gnus-summary-show-all-threads t]
2331 ["Hide thread" gnus-summary-hide-thread t]
2332 ["Show thread" gnus-summary-show-thread t]
2333 ["Go to next thread" gnus-summary-next-thread t]
2334 ["Go to previous thread" gnus-summary-prev-thread t]
2335 ["Go down thread" gnus-summary-down-thread t]
2336 ["Go up thread" gnus-summary-up-thread t]
2337 ["Top of thread" gnus-summary-top-thread t]
2338 ["Mark thread as read" gnus-summary-kill-thread t]
2339 ["Lower thread score" gnus-summary-lower-thread t]
2340 ["Raise thread score" gnus-summary-raise-thread t]
2341 ["Rethread current" gnus-summary-rethread-current t]))
2344 gnus-summary-post-menu gnus-summary-mode-map ""
2346 ["Send a message (mail or news)" gnus-summary-post-news
2347 ,@(if (featurep 'xemacs) '(t)
2348 '(:help "Compose a new message (mail or news)"))]
2349 ["Followup" gnus-summary-followup
2350 ,@(if (featurep 'xemacs) '(t)
2351 '(:help "Post followup to this article"))]
2352 ["Followup and yank" gnus-summary-followup-with-original
2353 ,@(if (featurep 'xemacs) '(t)
2354 '(:help "Post followup to this article, quoting its contents"))]
2355 ["Supersede article" gnus-summary-supersede-article t]
2356 ["Cancel article" gnus-summary-cancel-article
2357 ,@(if (featurep 'xemacs) '(t)
2358 '(:help "Cancel an article you posted"))]
2359 ["Reply" gnus-summary-reply t]
2360 ["Reply and yank" gnus-summary-reply-with-original t]
2361 ["Wide reply" gnus-summary-wide-reply t]
2362 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Mail a reply, quoting this article"))]
2365 ["Very wide reply" gnus-summary-very-wide-reply t]
2366 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2367 ,@(if (featurep 'xemacs) '(t)
2368 '(:help "Mail a very wide reply, quoting this article"))]
2369 ["Mail forward" gnus-summary-mail-forward t]
2370 ["Post forward" gnus-summary-post-forward t]
2371 ["Digest and mail" gnus-uu-digest-mail-forward t]
2372 ["Digest and post" gnus-uu-digest-post-forward t]
2373 ["Resend message" gnus-summary-resend-message t]
2374 ["Resend message edit" gnus-summary-resend-message-edit t]
2375 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2376 ["Send a mail" gnus-summary-mail-other-window t]
2377 ["Create a local message" gnus-summary-news-other-window t]
2378 ["Uuencode and post" gnus-uu-post-news
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Post a uuencoded article"))]
2381 ["Followup via news" gnus-summary-followup-to-mail t]
2382 ["Followup via news and yank"
2383 gnus-summary-followup-to-mail-with-original t]
2385 ;;["Send" gnus-summary-send-draft t]
2386 ;;["Send bounced" gnus-resend-bounced-mail t])
2390 ((not (keymapp gnus-summary-post-menu))
2391 (setq gnus-article-post-menu gnus-summary-post-menu))
2392 ((not gnus-article-post-menu)
2393 ;; Don't share post menu.
2394 (setq gnus-article-post-menu
2395 (copy-keymap gnus-summary-post-menu))))
2396 (define-key gnus-article-mode-map [menu-bar post]
2397 (cons "Post" gnus-article-post-menu))
2400 gnus-summary-misc-menu gnus-summary-mode-map ""
2403 ["Mark as read" gnus-summary-mark-as-read-forward t]
2404 ["Mark same subject and select"
2405 gnus-summary-kill-same-subject-and-select t]
2406 ["Mark same subject" gnus-summary-kill-same-subject t]
2407 ["Catchup" gnus-summary-catchup
2408 ,@(if (featurep 'xemacs) '(t)
2409 '(:help "Mark unread articles in this group as read"))]
2410 ["Catchup all" gnus-summary-catchup-all t]
2411 ["Catchup to here" gnus-summary-catchup-to-here t]
2412 ["Catchup from here" gnus-summary-catchup-from-here t]
2413 ["Catchup region" gnus-summary-mark-region-as-read
2414 (gnus-mark-active-p)]
2415 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2417 ["Tick" gnus-summary-tick-article-forward t]
2418 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2419 ["Remove marks" gnus-summary-clear-mark-forward t]
2420 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2421 ["Set bookmark" gnus-summary-set-bookmark t]
2422 ["Remove bookmark" gnus-summary-remove-bookmark t])
2424 ["Marks..." gnus-summary-limit-to-marks t]
2425 ["Subject..." gnus-summary-limit-to-subject t]
2426 ["Author..." gnus-summary-limit-to-author t]
2427 ["Age..." gnus-summary-limit-to-age t]
2428 ["Extra..." gnus-summary-limit-to-extra t]
2429 ["Score..." gnus-summary-limit-to-score t]
2430 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2431 ["Unread" gnus-summary-limit-to-unread t]
2432 ["Unseen" gnus-summary-limit-to-unseen t]
2433 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2434 ["Next articles" gnus-summary-limit-to-articles t]
2435 ["Pop limit" gnus-summary-pop-limit t]
2436 ["Show dormant" gnus-summary-limit-include-dormant t]
2437 ["Hide childless dormant"
2438 gnus-summary-limit-exclude-childless-dormant t]
2439 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2440 ["Hide marked" gnus-summary-limit-exclude-marks t]
2441 ["Show expunged" gnus-summary-limit-include-expunged t])
2443 ["Set mark" gnus-summary-mark-as-processable t]
2444 ["Remove mark" gnus-summary-unmark-as-processable t]
2445 ["Remove all marks" gnus-summary-unmark-all-processable t]
2446 ["Mark above" gnus-uu-mark-over t]
2447 ["Mark series" gnus-uu-mark-series t]
2448 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2449 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2450 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2451 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2452 ["Mark all" gnus-uu-mark-all t]
2453 ["Mark buffer" gnus-uu-mark-buffer t]
2454 ["Mark sparse" gnus-uu-mark-sparse t]
2455 ["Mark thread" gnus-uu-mark-thread t]
2456 ["Unmark thread" gnus-uu-unmark-thread t]
2457 ("Process Mark Sets"
2458 ["Kill" gnus-summary-kill-process-mark t]
2459 ["Yank" gnus-summary-yank-process-mark
2460 gnus-newsgroup-process-stack]
2461 ["Save" gnus-summary-save-process-mark t]
2462 ["Run command on marked..." gnus-summary-universal-argument t]))
2464 ["Page forward" gnus-summary-next-page
2465 ,@(if (featurep 'xemacs) '(t)
2466 '(:help "Show next page of article"))]
2467 ["Page backward" gnus-summary-prev-page
2468 ,@(if (featurep 'xemacs) '(t)
2469 '(:help "Show previous page of article"))]
2470 ["Line forward" gnus-summary-scroll-up t])
2472 ["Next unread article" gnus-summary-next-unread-article t]
2473 ["Previous unread article" gnus-summary-prev-unread-article t]
2474 ["Next article" gnus-summary-next-article t]
2475 ["Previous article" gnus-summary-prev-article t]
2476 ["Next unread subject" gnus-summary-next-unread-subject t]
2477 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2478 ["Next article same subject" gnus-summary-next-same-subject t]
2479 ["Previous article same subject" gnus-summary-prev-same-subject t]
2480 ["First unread article" gnus-summary-first-unread-article t]
2481 ["Best unread article" gnus-summary-best-unread-article t]
2482 ["Go to subject number..." gnus-summary-goto-subject t]
2483 ["Go to article number..." gnus-summary-goto-article t]
2484 ["Go to the last article" gnus-summary-goto-last-article t]
2485 ["Pop article off history" gnus-summary-pop-article t])
2487 ["Sort by number" gnus-summary-sort-by-number t]
2488 ["Sort by author" gnus-summary-sort-by-author t]
2489 ["Sort by subject" gnus-summary-sort-by-subject t]
2490 ["Sort by date" gnus-summary-sort-by-date t]
2491 ["Sort by score" gnus-summary-sort-by-score t]
2492 ["Sort by lines" gnus-summary-sort-by-lines t]
2493 ["Sort by characters" gnus-summary-sort-by-chars t]
2494 ["Randomize" gnus-summary-sort-by-random t]
2495 ["Original sort" gnus-summary-sort-by-original t])
2497 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2498 ["Describe group" gnus-summary-describe-group t]
2499 ["Fetch charter" gnus-group-fetch-charter
2500 ,@(if (featurep 'xemacs) nil
2501 '(:help "Display the charter of the current group"))]
2502 ["Fetch control message" gnus-group-fetch-control
2503 ,@(if (featurep 'xemacs) nil
2504 '(:help "Display the archived control message for the current group"))]
2505 ["Read manual" gnus-info-find-node t])
2507 ["Pick and read" gnus-pick-mode t]
2508 ["Binary" gnus-binary-mode t])
2510 ["Regenerate" gnus-summary-prepare t]
2511 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2512 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2513 ["Toggle threading" gnus-summary-toggle-threads t])
2514 ["See old articles" gnus-summary-insert-old-articles t]
2515 ["See new articles" gnus-summary-insert-new-articles t]
2516 ["Filter articles..." gnus-summary-execute-command t]
2517 ["Run command on articles..." gnus-summary-universal-argument t]
2518 ["Search articles forward..." gnus-summary-search-article-forward t]
2519 ["Search articles backward..." gnus-summary-search-article-backward t]
2520 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2521 ["Expand window" gnus-summary-expand-window t]
2522 ["Expire expirable articles" gnus-summary-expire-articles
2523 (gnus-check-backend-function
2524 'request-expire-articles gnus-newsgroup-name)]
2525 ["Edit local kill file" gnus-summary-edit-local-kill t]
2526 ["Edit main kill file" gnus-summary-edit-global-kill t]
2527 ["Edit group parameters" gnus-summary-edit-parameters t]
2528 ["Customize group parameters" gnus-summary-customize-parameters t]
2529 ["Send a bug report" gnus-bug t]
2531 ["Catchup and exit" gnus-summary-catchup-and-exit
2532 ,@(if (featurep 'xemacs) '(t)
2533 '(:help "Mark unread articles in this group as read, then exit"))]
2534 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2535 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2536 ["Exit group" gnus-summary-exit
2537 ,@(if (featurep 'xemacs) '(t)
2538 '(:help "Exit current group, return to group selection mode"))]
2539 ["Exit group without updating" gnus-summary-exit-no-update t]
2540 ["Exit and goto next group" gnus-summary-next-group t]
2541 ["Exit and goto prev group" gnus-summary-prev-group t]
2542 ["Reselect group" gnus-summary-reselect-current-group t]
2543 ["Rescan group" gnus-summary-rescan-group t]
2544 ["Update dribble" gnus-summary-save-newsrc t])))
2546 (gnus-run-hooks 'gnus-summary-menu-hook)))
2548 (defvar gnus-summary-tool-bar-map nil)
2550 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2551 ;; affect _new_ message buffers. We might add a function that walks thru all
2552 ;; summary-mode buffers and force the update.
2553 (defun gnus-summary-tool-bar-update (&optional symbol value)
2554 "Update summary mode toolbar.
2555 Setter function for custom variables."
2556 (setq-default gnus-summary-tool-bar-map nil)
2558 ;; When used as ":set" function:
2559 (set-default symbol value))
2560 (when (gnus-buffer-live-p gnus-summary-buffer)
2561 (with-current-buffer gnus-summary-buffer
2562 (gnus-summary-make-tool-bar))))
2564 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2565 'gnus-summary-tool-bar-gnome
2566 'gnus-summary-tool-bar-retro)
2567 "Specifies the Gnus summary tool bar.
2569 It can be either a list or a symbol refering to a list. See
2570 `gmm-tool-bar-from-list' for the format of the list. The
2571 default key map is `gnus-summary-mode-map'.
2573 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2574 `gnus-summary-tool-bar-retro'."
2575 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2576 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2577 (repeat :tag "User defined list" gmm-tool-bar-item)
2579 :version "22.1" ;; Gnus 5.10.9
2580 :initialize 'custom-initialize-default
2581 :set 'gnus-summary-tool-bar-update
2582 :group 'gnus-summary)
2584 (defcustom gnus-summary-tool-bar-gnome
2585 '((gnus-summary-post-news "mail/compose" nil)
2586 (gnus-summary-insert-new-articles "mail/inbox" nil
2587 :visible (or (not gnus-agent)
2589 (gnus-summary-reply-with-original "mail/reply")
2590 (gnus-summary-reply "mail/reply" nil :visible nil)
2591 (gnus-summary-followup-with-original "mail/reply-all")
2592 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2593 (gnus-summary-mail-forward "mail/forward")
2594 (gnus-summary-save-article "mail/save")
2595 (gnus-summary-search-article-forward "search" nil :visible nil)
2596 (gnus-summary-print-article "print")
2597 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2598 ;; Some new commands that may need more suitable icons:
2599 (gnus-summary-save-newsrc "save" nil :visible nil)
2600 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2601 (gnus-summary-prev-article "left-arrow")
2602 (gnus-summary-next-article "right-arrow")
2603 (gnus-summary-next-page "next-page")
2604 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2606 ;; Maybe some sort-by-... could be added:
2607 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2608 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2609 (gnus-summary-mark-as-expirable
2611 :visible (gnus-check-backend-function 'request-expire-articles
2612 gnus-newsgroup-name))
2613 (gnus-summary-mark-as-spam
2615 :visible (and (fboundp 'spam-group-ham-contents-p)
2616 (spam-group-ham-contents-p gnus-newsgroup-name))
2617 :help "Mark as spam")
2618 (gnus-summary-mark-as-read-forward
2620 :visible (and (fboundp 'spam-group-spam-contents-p)
2621 (spam-group-spam-contents-p gnus-newsgroup-name)))
2623 (gnus-summary-exit "exit")
2624 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2625 (gnus-info-find-node "help"))
2626 "List of functions for the summary tool bar (GNOME style).
2628 See `gmm-tool-bar-from-list' for the format of the list."
2629 :type '(repeat gmm-tool-bar-item)
2630 :version "22.1" ;; Gnus 5.10.9
2631 :initialize 'custom-initialize-default
2632 :set 'gnus-summary-tool-bar-update
2633 :group 'gnus-summary)
2635 (defcustom gnus-summary-tool-bar-retro
2636 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2637 (gnus-summary-next-unread-article "gnus/next-ur")
2638 (gnus-summary-post-news "gnus/post")
2639 (gnus-summary-followup-with-original "gnus/fuwo")
2640 (gnus-summary-followup "gnus/followup")
2641 (gnus-summary-reply-with-original "gnus/reply-wo")
2642 (gnus-summary-reply "gnus/reply")
2643 (gnus-summary-caesar-message "gnus/rot13")
2644 (gnus-uu-decode-uu "gnus/uu-decode")
2645 (gnus-summary-save-article-file "gnus/save-aif")
2646 (gnus-summary-save-article "gnus/save-art")
2647 (gnus-uu-post-news "gnus/uu-post")
2648 (gnus-summary-catchup "gnus/catchup")
2649 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2650 (gnus-summary-exit "gnus/exit-summ")
2651 ;; Some new command that may need more suitable icons:
2652 (gnus-summary-print-article "gnus/print" nil :visible nil)
2653 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2654 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2655 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2656 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2657 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2658 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2660 (gnus-info-find-node "gnus/help" nil :visible nil))
2661 "List of functions for the summary tool bar (retro look).
2663 See `gmm-tool-bar-from-list' for the format of the list."
2664 :type '(repeat gmm-tool-bar-item)
2665 :version "22.1" ;; Gnus 5.10.9
2666 :initialize 'custom-initialize-default
2667 :set 'gnus-summary-tool-bar-update
2668 :group 'gnus-summary)
2670 (defcustom gnus-summary-tool-bar-zap-list t
2671 "List of icon items from the global tool bar.
2672 These items are not displayed in the Gnus summary mode tool bar.
2674 See `gmm-tool-bar-from-list' for the format of the list."
2675 :type 'gmm-tool-bar-zap-list
2676 :version "22.1" ;; Gnus 5.10.9
2677 :initialize 'custom-initialize-default
2678 :set 'gnus-summary-tool-bar-update
2679 :group 'gnus-summary)
2681 (defvar image-load-path)
2683 (defun gnus-summary-make-tool-bar (&optional force)
2684 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2685 When FORCE, rebuild the tool bar."
2686 (when (and (not (featurep 'xemacs))
2687 (boundp 'tool-bar-mode)
2689 (or (not gnus-summary-tool-bar-map) force))
2691 (gmm-image-load-path-for-library "gnus"
2694 (image-load-path (cons (car load-path)
2695 (when (boundp 'image-load-path)
2697 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2698 gnus-summary-tool-bar-zap-list
2699 'gnus-summary-mode-map)))
2701 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2703 (setq gnus-summary-tool-bar-map map))))
2704 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2706 (defun gnus-score-set-default (var value)
2707 "A version of set that updates the GNU Emacs menu-bar."
2709 ;; It is the message that forces the active status to be updated.
2712 (defun gnus-make-score-map (type)
2713 "Make a summary score map of type TYPE."
2716 (let ((headers '(("author" "from" string)
2717 ("subject" "subject" string)
2718 ("article body" "body" string)
2719 ("article head" "head" string)
2720 ("xref" "xref" string)
2721 ("extra header" "extra" string)
2722 ("lines" "lines" number)
2723 ("followups to author" "followup" string)))
2724 (types '((number ("less than" <)
2727 (string ("substring" s)
2731 (perms '(("temporary" (current-time-string))
2739 (if (eq type 'lower)
2744 (setq header (car headers))
2750 (let ((ts (cdr (assoc (nth 2 header) types)))
2766 'gnus-summary-score-entry
2768 (if (or (string= (nth 1 header)
2770 (string= (nth 1 header)
2773 (list 'gnus-summary-header
2775 (list 'quote (nth 1 (car ts)))
2776 (list 'gnus-score-delta-default
2783 (list (nreverse outp))))
2786 (list (nreverse outt))))
2788 (setq headers (cdr headers)))
2789 (list (nreverse outh))))))))
2793 (defun gnus-summary-mode (&optional group)
2794 "Major mode for reading articles.
2796 All normal editing commands are switched off.
2797 \\<gnus-summary-mode-map>
2798 Each line in this buffer represents one article. To read an
2799 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2800 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2803 You can also post articles and send mail from this buffer. To
2804 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2805 of an article, type `\\[gnus-summary-reply]'.
2807 There are approx. one gazillion commands you can execute in this
2808 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2810 The following commands are available:
2812 \\{gnus-summary-mode-map}"
2814 (kill-all-local-variables)
2815 (when (gnus-visual-p 'summary-menu 'menu)
2816 (gnus-summary-make-menu-bar)
2817 (gnus-summary-make-tool-bar))
2818 (gnus-summary-make-local-variables)
2819 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2820 (gnus-summary-make-local-variables))
2821 (gnus-make-thread-indent-array)
2822 (gnus-simplify-mode-line)
2823 (setq major-mode 'gnus-summary-mode)
2824 (setq mode-name "Summary")
2825 (make-local-variable 'minor-mode-alist)
2826 (use-local-map gnus-summary-mode-map)
2827 (buffer-disable-undo)
2828 (setq buffer-read-only t) ;Disable modification
2829 (setq truncate-lines t)
2830 (setq selective-display t)
2831 (setq selective-display-ellipses t) ;Display `...'
2832 (gnus-summary-set-display-table)
2833 (gnus-set-default-directory)
2834 (setq gnus-newsgroup-name group)
2835 (make-local-variable 'gnus-summary-line-format)
2836 (make-local-variable 'gnus-summary-line-format-spec)
2837 (make-local-variable 'gnus-summary-dummy-line-format)
2838 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2839 (make-local-variable 'gnus-summary-mark-positions)
2840 (gnus-make-local-hook 'pre-command-hook)
2841 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2842 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2843 (turn-on-gnus-mailing-list-mode)
2844 (mm-enable-multibyte)
2845 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2846 (gnus-update-summary-mark-positions))
2848 (defun gnus-summary-make-local-variables ()
2849 "Make all the local summary buffer variables."
2851 (dolist (local gnus-summary-local-variables)
2854 (if (eq (cdr local) 'global)
2855 ;; Copy the global value of the variable.
2856 (setq global (symbol-value (car local)))
2857 ;; Use the value from the list.
2858 (setq global (eval (cdr local))))
2859 (set (make-local-variable (car local)) global))
2860 ;; Simple nil-valued local variable.
2861 (set (make-local-variable local) nil)))))
2863 (defun gnus-summary-clear-local-variables ()
2864 (let ((locals gnus-summary-local-variables))
2866 (if (consp (car locals))
2867 (and (vectorp (caar locals))
2868 (set (caar locals) nil))
2869 (and (vectorp (car locals))
2870 (set (car locals) nil)))
2871 (setq locals (cdr locals)))))
2873 ;; Summary data functions.
2875 (defmacro gnus-data-number (data)
2878 (defmacro gnus-data-set-number (data number)
2879 `(setcar ,data ,number))
2881 (defmacro gnus-data-mark (data)
2884 (defmacro gnus-data-set-mark (data mark)
2885 `(setcar (nthcdr 1 ,data) ,mark))
2887 (defmacro gnus-data-pos (data)
2890 (defmacro gnus-data-set-pos (data pos)
2891 `(setcar (nthcdr 2 ,data) ,pos))
2893 (defmacro gnus-data-header (data)
2896 (defmacro gnus-data-set-header (data header)
2897 `(setf (nth 3 ,data) ,header))
2899 (defmacro gnus-data-level (data)
2902 (defmacro gnus-data-unread-p (data)
2903 `(= (nth 1 ,data) gnus-unread-mark))
2905 (defmacro gnus-data-read-p (data)
2906 `(/= (nth 1 ,data) gnus-unread-mark))
2908 (defmacro gnus-data-pseudo-p (data)
2909 `(consp (nth 3 ,data)))
2911 (defmacro gnus-data-find (number)
2912 `(assq ,number gnus-newsgroup-data))
2914 (defmacro gnus-data-find-list (number &optional data)
2915 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2916 (memq (assq ,number bdata)
2919 (defmacro gnus-data-make (number mark pos header level)
2920 `(list ,number ,mark ,pos ,header ,level))
2922 (defun gnus-data-enter (after-article number mark pos header level offset)
2923 (let ((data (gnus-data-find-list after-article)))
2925 (error "No such article: %d" after-article))
2926 (setcdr data (cons (gnus-data-make number mark pos header level)
2928 (setq gnus-newsgroup-data-reverse nil)
2929 (gnus-data-update-list (cddr data) offset)))
2931 (defun gnus-data-enter-list (after-article list &optional offset)
2933 (let ((data (and after-article (gnus-data-find-list after-article)))
2937 (let ((odata gnus-newsgroup-data))
2938 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2940 (gnus-data-update-list odata offset)))
2941 ;; Find the last element in the list to be spliced into the main
2944 (setq list (cdr list)))
2947 (setcdr list gnus-newsgroup-data)
2948 (setq gnus-newsgroup-data ilist)
2950 (gnus-data-update-list (cdr list) offset)))
2951 (setcdr list (cdr data))
2954 (gnus-data-update-list (cdr list) offset))))
2955 (setq gnus-newsgroup-data-reverse nil))))
2957 (defun gnus-data-remove (article &optional offset)
2958 (let ((data gnus-newsgroup-data))
2959 (if (= (gnus-data-number (car data)) article)
2961 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2962 gnus-newsgroup-data-reverse nil)
2964 (gnus-data-update-list gnus-newsgroup-data offset)))
2966 (when (= (gnus-data-number (cadr data)) article)
2967 (setcdr data (cddr data))
2969 (gnus-data-update-list (cdr data) offset))
2971 gnus-newsgroup-data-reverse nil))
2972 (setq data (cdr data))))))
2974 (defmacro gnus-data-list (backward)
2976 (or gnus-newsgroup-data-reverse
2977 (setq gnus-newsgroup-data-reverse
2978 (reverse gnus-newsgroup-data)))
2979 gnus-newsgroup-data))
2981 (defun gnus-data-update-list (data offset)
2982 "Add OFFSET to the POS of all data entries in DATA."
2983 (setq gnus-newsgroup-data-reverse nil)
2985 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2986 (setq data (cdr data))))
2988 (defun gnus-summary-article-pseudo-p (article)
2989 "Say whether this article is a pseudo article or not."
2990 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2992 (defmacro gnus-summary-article-sparse-p (article)
2993 "Say whether this article is a sparse article or not."
2994 `(memq ,article gnus-newsgroup-sparse))
2996 (defmacro gnus-summary-article-ancient-p (article)
2997 "Say whether this article is a sparse article or not."
2998 `(memq ,article gnus-newsgroup-ancient))
3000 (defun gnus-article-parent-p (number)
3001 "Say whether this article is a parent or not."
3002 (let ((data (gnus-data-find-list number)))
3003 (and (cdr data) ; There has to be an article after...
3004 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3005 (gnus-data-level (nth 1 data))))))
3007 (defun gnus-article-children (number)
3008 "Return a list of all children to NUMBER."
3009 (let* ((data (gnus-data-find-list number))
3010 (level (gnus-data-level (car data)))
3012 (setq data (cdr data))
3014 (= (gnus-data-level (car data)) (1+ level)))
3015 (push (gnus-data-number (car data)) children)
3016 (setq data (cdr data)))
3019 (defmacro gnus-summary-skip-intangible ()
3020 "If the current article is intangible, then jump to a different article."
3021 '(let ((to (get-text-property (point) 'gnus-intangible)))
3022 (and to (gnus-summary-goto-subject to))))
3024 (defmacro gnus-summary-article-intangible-p ()
3025 "Say whether this article is intangible or not."
3026 '(get-text-property (point) 'gnus-intangible))
3028 (defun gnus-article-read-p (article)
3029 "Say whether ARTICLE is read or not."
3030 (not (or (memq article gnus-newsgroup-marked)
3031 (memq article gnus-newsgroup-spam-marked)
3032 (memq article gnus-newsgroup-unreads)
3033 (memq article gnus-newsgroup-unselected)
3034 (memq article gnus-newsgroup-dormant))))
3036 ;; Some summary mode macros.
3038 (defmacro gnus-summary-article-number ()
3039 "The article number of the article on the current line.
3040 If there isn't an article number here, then we return the current
3043 (gnus-summary-skip-intangible)
3044 (or (get-text-property (point) 'gnus-number)
3045 (gnus-summary-last-subject))))
3047 (defmacro gnus-summary-article-header (&optional number)
3048 "Return the header of article NUMBER."
3049 `(gnus-data-header (gnus-data-find
3050 ,(or number '(gnus-summary-article-number)))))
3052 (defmacro gnus-summary-thread-level (&optional number)
3053 "Return the level of thread that starts with article NUMBER."
3054 `(if (and (eq gnus-summary-make-false-root 'dummy)
3055 (get-text-property (point) 'gnus-intangible))
3057 (gnus-data-level (gnus-data-find
3058 ,(or number '(gnus-summary-article-number))))))
3060 (defmacro gnus-summary-article-mark (&optional number)
3061 "Return the mark of article NUMBER."
3062 `(gnus-data-mark (gnus-data-find
3063 ,(or number '(gnus-summary-article-number)))))
3065 (defmacro gnus-summary-article-pos (&optional number)
3066 "Return the position of the line of article NUMBER."
3067 `(gnus-data-pos (gnus-data-find
3068 ,(or number '(gnus-summary-article-number)))))
3070 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3071 (defmacro gnus-summary-article-subject (&optional number)
3072 "Return current subject string or nil if nothing."
3075 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3076 '(gnus-data-header (assq (gnus-summary-article-number)
3077 gnus-newsgroup-data)))))
3080 (mail-header-subject headers))))
3082 (defmacro gnus-summary-article-score (&optional number)
3083 "Return current article score."
3084 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3085 gnus-newsgroup-scored))
3086 gnus-summary-default-score 0))
3088 (defun gnus-summary-article-children (&optional number)
3089 "Return a list of article numbers that are children of article NUMBER."
3090 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3091 (level (gnus-data-level (car data)))
3093 (while (and (setq data (cdr data))
3094 (> (setq l (gnus-data-level (car data))) level))
3095 (and (= (1+ level) l)
3096 (push (gnus-data-number (car data))
3098 (nreverse children)))
3100 (defun gnus-summary-article-parent (&optional number)
3101 "Return the article number of the parent of article NUMBER."
3102 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3103 (gnus-data-list t)))
3104 (level (gnus-data-level (car data))))
3106 () ; This is a root.
3107 ;; We search until we find an article with a level less than
3108 ;; this one. That function has to be the parent.
3109 (while (and (setq data (cdr data))
3110 (not (< (gnus-data-level (car data)) level))))
3111 (and data (gnus-data-number (car data))))))
3113 (defun gnus-unread-mark-p (mark)
3114 "Say whether MARK is the unread mark."
3115 (= mark gnus-unread-mark))
3117 (defun gnus-read-mark-p (mark)
3118 "Say whether MARK is one of the marks that mark as read.
3119 This is all marks except unread, ticked, dormant, and expirable."
3120 (not (or (= mark gnus-unread-mark)
3121 (= mark gnus-ticked-mark)
3122 (= mark gnus-spam-mark)
3123 (= mark gnus-dormant-mark)
3124 (= mark gnus-expirable-mark))))
3126 (defmacro gnus-article-mark (number)
3127 "Return the MARK of article NUMBER.
3128 This macro should only be used when computing the mark the \"first\"
3129 time; i.e., when generating the summary lines. After that,
3130 `gnus-summary-article-mark' should be used to examine the
3133 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3134 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3135 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3136 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3137 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3138 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3139 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3140 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3141 gnus-ancient-mark))))
3143 ;; Saving hidden threads.
3145 (defmacro gnus-save-hidden-threads (&rest forms)
3146 "Save hidden threads, eval FORMS, and restore the hidden threads."
3147 (let ((config (make-symbol "config")))
3148 `(let ((,config (gnus-hidden-threads-configuration)))
3152 (gnus-restore-hidden-threads-configuration ,config)))))
3153 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3154 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3156 (defun gnus-data-compute-positions ()
3157 "Compute the positions of all articles."
3158 (setq gnus-newsgroup-data-reverse nil)
3159 (let ((data gnus-newsgroup-data))
3161 (gnus-save-hidden-threads
3162 (gnus-summary-show-all-threads)
3163 (goto-char (point-min))
3165 (while (get-text-property (point) 'gnus-intangible)
3167 (gnus-data-set-pos (car data) (+ (point) 3))
3168 (setq data (cdr data))
3169 (forward-line 1))))))
3171 (defun gnus-hidden-threads-configuration ()
3172 "Return the current hidden threads configuration."
3175 (goto-char (point-min))
3176 (while (search-forward "\r" nil t)
3177 (push (1- (point)) config))
3180 (defun gnus-restore-hidden-threads-configuration (config)
3181 "Restore hidden threads configuration from CONFIG."
3183 (let (point buffer-read-only)
3184 (while (setq point (pop config))
3185 (when (and (< point (point-max))
3187 (eq (char-after) ?\n))
3188 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3190 ;; Various summary mode internalish functions.
3192 (defun gnus-mouse-pick-article (e)
3195 (gnus-summary-next-page nil t))
3197 (defun gnus-summary-set-display-table ()
3198 "Change the display table.
3199 Odd characters have a tendency to mess
3200 up nicely formatted displays - we make all possible glyphs
3201 display only a single character."
3203 ;; We start from the standard display table, if any.
3204 (let ((table (or (copy-sequence standard-display-table)
3205 (make-display-table)))
3207 ;; Nix out all the control chars...
3208 (while (>= (setq i (1- i)) 0)
3209 (aset table i [??]))
3210 ;; ... but not newline and cr, of course. (cr is necessary for the
3211 ;; selective display).
3212 (aset table ?\n nil)
3213 (aset table ?\r nil)
3214 ;; We keep TAB as well.
3215 (aset table ?\t nil)
3216 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3217 ;; Emacs 23 (unicode), that are not set already.
3218 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3221 (while (>= (setq i (1- i)) 127)
3222 ;; Only modify if the entry is nil.
3223 (unless (aref table i)
3224 (aset table i [??]))))
3225 (setq buffer-display-table table)))
3227 (defun gnus-summary-set-article-display-arrow (pos)
3228 "Update the overlay arrow to point to line at position POS."
3229 (when (and gnus-summary-display-arrow
3230 (boundp 'overlay-arrow-position)
3231 (boundp 'overlay-arrow-string))
3235 (unless overlay-arrow-position
3236 (setq overlay-arrow-position (make-marker)))
3237 (setq overlay-arrow-string "=>"
3238 overlay-arrow-position (set-marker overlay-arrow-position
3240 (current-buffer))))))
3242 (defun gnus-summary-setup-buffer (group)
3243 "Initialize summary buffer."
3244 (let ((buffer (gnus-summary-buffer-name group))
3245 (dead-name (concat "*Dead Summary "
3246 (gnus-group-decoded-name group) "*")))
3247 ;; If a dead summary buffer exists, we kill it.
3248 (when (gnus-buffer-live-p dead-name)
3249 (gnus-kill-buffer dead-name))
3250 (if (get-buffer buffer)
3253 (setq gnus-summary-buffer (current-buffer))
3254 (not gnus-newsgroup-prepared))
3255 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3256 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3257 (gnus-summary-mode group)
3259 (gnus-carpal-setup-buffer 'summary))
3260 (unless gnus-single-article-buffer
3261 (make-local-variable 'gnus-article-buffer)
3262 (make-local-variable 'gnus-article-current)
3263 (make-local-variable 'gnus-original-article-buffer))
3264 (setq gnus-newsgroup-name group)
3265 ;; Set any local variables in the group parameters.
3266 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3269 (defun gnus-set-global-variables ()
3270 "Set the global equivalents of the buffer-local variables.
3271 They are set to the latest values they had. These reflect the summary
3272 buffer that was in action when the last article was fetched."
3273 (when (eq major-mode 'gnus-summary-mode)
3274 (setq gnus-summary-buffer (current-buffer))
3275 (let ((name gnus-newsgroup-name)
3276 (marked gnus-newsgroup-marked)
3277 (spam gnus-newsgroup-spam-marked)
3278 (unread gnus-newsgroup-unreads)
3279 (headers gnus-current-headers)
3280 (data gnus-newsgroup-data)
3281 (summary gnus-summary-buffer)
3282 (article-buffer gnus-article-buffer)
3283 (original gnus-original-article-buffer)
3284 (gac gnus-article-current)
3285 (reffed gnus-reffed-article-number)
3286 (score-file gnus-current-score-file)
3287 (default-charset gnus-newsgroup-charset)
3289 (let ((locals gnus-newsgroup-variables))
3291 (if (consp (car locals))
3292 (push (eval (caar locals)) vlist)
3293 (push (eval (car locals)) vlist))
3294 (setq locals (cdr locals)))
3295 (setq vlist (nreverse vlist)))
3297 (set-buffer gnus-group-buffer)
3298 (setq gnus-newsgroup-name name
3299 gnus-newsgroup-marked marked
3300 gnus-newsgroup-spam-marked spam
3301 gnus-newsgroup-unreads unread
3302 gnus-current-headers headers
3303 gnus-newsgroup-data data
3304 gnus-article-current gac
3305 gnus-summary-buffer summary
3306 gnus-article-buffer article-buffer
3307 gnus-original-article-buffer original
3308 gnus-reffed-article-number reffed
3309 gnus-current-score-file score-file
3310 gnus-newsgroup-charset default-charset)
3311 (let ((locals gnus-newsgroup-variables))
3313 (if (consp (car locals))
3314 (set (caar locals) (pop vlist))
3315 (set (car locals) (pop vlist)))
3316 (setq locals (cdr locals))))
3317 ;; The article buffer also has local variables.
3318 (when (gnus-buffer-live-p gnus-article-buffer)
3319 (set-buffer gnus-article-buffer)
3320 (setq gnus-summary-buffer summary))))))
3322 (defun gnus-summary-article-unread-p (article)
3323 "Say whether ARTICLE is unread or not."
3324 (memq article gnus-newsgroup-unreads))
3326 (defun gnus-summary-first-article-p (&optional article)
3327 "Return whether ARTICLE is the first article in the buffer."
3328 (if (not (setq article (or article (gnus-summary-article-number))))
3330 (eq article (caar gnus-newsgroup-data))))
3332 (defun gnus-summary-last-article-p (&optional article)
3333 "Return whether ARTICLE is the last article in the buffer."
3334 (if (not (setq article (or article (gnus-summary-article-number))))
3335 ;; All non-existent numbers are the last article. :-)
3337 (not (cdr (gnus-data-find-list article)))))
3339 (defun gnus-make-thread-indent-array ()
3341 (unless (and gnus-thread-indent-array
3342 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3343 (setq gnus-thread-indent-array (make-vector 201 "")
3344 gnus-thread-indent-array-level gnus-thread-indent-level)
3346 (aset gnus-thread-indent-array n
3347 (make-string (* n gnus-thread-indent-level) ? ))
3350 (defun gnus-update-summary-mark-positions ()
3351 "Compute where the summary marks are to go."
3353 (when (gnus-buffer-exists-p gnus-summary-buffer)
3354 (set-buffer gnus-summary-buffer))
3355 (let ((spec gnus-summary-line-format-spec)
3358 (gnus-set-work-buffer)
3359 (let ((gnus-tmp-unread ?Z)
3360 (gnus-replied-mark ?Z)
3361 (gnus-score-below-mark ?Z)
3362 (gnus-score-over-mark ?Z)
3363 (gnus-undownloaded-mark ?Z)
3364 (gnus-summary-line-format-spec spec)
3365 (gnus-newsgroup-downloadable '(0))
3366 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3367 case-fold-search ignores)
3368 ;; Here, all marks are bound to Z.
3369 (gnus-summary-insert-line header
3370 0 nil t gnus-tmp-unread t nil "" nil 1)
3371 (goto-char (point-min))
3372 ;; Memorize the positions of the same characters as dummy marks.
3373 (while (re-search-forward "[A-D]" nil t)
3374 (push (point) ignores))
3376 ;; We use A-D as dummy marks in order to know column positions
3377 ;; where marks should be inserted.
3378 (setq gnus-tmp-unread ?A
3379 gnus-replied-mark ?B
3380 gnus-score-below-mark ?C
3381 gnus-score-over-mark ?C
3382 gnus-undownloaded-mark ?D)
3383 (gnus-summary-insert-line header
3384 0 nil t gnus-tmp-unread t nil "" nil 1)
3385 ;; Ignore characters which aren't dummy marks.
3387 (delete-region (goto-char (1- p)) p)
3389 (goto-char (point-min))
3390 (setq pos (list (cons 'unread
3391 (and (search-forward "A" nil t)
3392 (- (point) (point-min) 1)))))
3393 (goto-char (point-min))
3394 (push (cons 'replied (and (search-forward "B" nil t)
3395 (- (point) (point-min) 1)))
3397 (goto-char (point-min))
3398 (push (cons 'score (and (search-forward "C" nil t)
3399 (- (point) (point-min) 1)))
3401 (goto-char (point-min))
3402 (push (cons 'download (and (search-forward "D" nil t)
3403 (- (point) (point-min) 1)))
3405 (setq gnus-summary-mark-positions pos))))
3407 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3408 "Insert a dummy root in the summary buffer."
3410 (gnus-add-text-properties
3411 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3412 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3414 (defun gnus-summary-extract-address-component (from)
3415 (or (car (funcall gnus-extract-address-components from))
3418 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3419 (let ((mail-parse-charset gnus-newsgroup-charset)
3420 ; Is it really necessary to do this next part for each summary line?
3421 ; Luckily, doesn't seem to slow things down much.
3422 (mail-parse-ignored-charsets
3423 (save-excursion (set-buffer gnus-summary-buffer)
3424 gnus-newsgroup-ignored-charsets)))
3426 (and gnus-ignored-from-addresses
3427 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3428 (let ((extra-headers (mail-header-extra header))
3432 ((setq to (cdr (assq 'To extra-headers)))
3435 (gnus-summary-extract-address-component
3436 (funcall gnus-decode-encoded-word-function to)))))
3437 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3438 (concat "=> " newsgroups)))))
3439 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3441 (defun gnus-summary-insert-line (gnus-tmp-header
3442 gnus-tmp-level gnus-tmp-current
3443 undownloaded gnus-tmp-unread gnus-tmp-replied
3444 gnus-tmp-expirable gnus-tmp-subject-or-nil
3445 &optional gnus-tmp-dummy gnus-tmp-score
3447 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3448 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3449 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3450 (gnus-tmp-score-char
3451 (if (or (null gnus-summary-default-score)
3452 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3453 gnus-summary-zcore-fuzz))
3455 (if (< gnus-tmp-score gnus-summary-default-score)
3456 gnus-score-below-mark gnus-score-over-mark)))
3457 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3459 (cond (gnus-tmp-process gnus-process-mark)
3460 ((memq gnus-tmp-current gnus-newsgroup-cached)
3462 (gnus-tmp-replied gnus-replied-mark)
3463 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3464 gnus-forwarded-mark)
3465 ((memq gnus-tmp-current gnus-newsgroup-saved)
3467 ((memq gnus-tmp-number gnus-newsgroup-recent)
3469 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3472 (gnus-tmp-downloaded
3474 gnus-undownloaded-mark)
3475 (gnus-newsgroup-agentized
3476 gnus-downloaded-mark)
3479 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3482 ((string-match "<[^>]+> *$" gnus-tmp-from)
3483 (let ((beg (match-beginning 0)))
3484 (or (and (string-match "^\".+\"" gnus-tmp-from)
3485 (substring gnus-tmp-from 1 (1- (match-end 0))))
3486 (substring gnus-tmp-from 0 beg))))
3487 ((string-match "(.+)" gnus-tmp-from)
3488 (substring gnus-tmp-from
3489 (1+ (match-beginning 0)) (1- (match-end 0))))
3491 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3492 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3493 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3494 (buffer-read-only nil))
3495 (when (string= gnus-tmp-name "")
3496 (setq gnus-tmp-name gnus-tmp-from))
3497 (unless (numberp gnus-tmp-lines)
3498 (setq gnus-tmp-lines -1))
3499 (if (= gnus-tmp-lines -1)
3500 (setq gnus-tmp-lines "?")
3501 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3502 (gnus-put-text-property
3504 (progn (eval gnus-summary-line-format-spec) (point))
3505 'gnus-number gnus-tmp-number)
3506 (when (gnus-visual-p 'summary-highlight 'highlight)
3508 (gnus-run-hooks 'gnus-summary-update-hook)
3511 (defun gnus-summary-update-line (&optional dont-update)
3512 "Update summary line after change."
3513 (when (and gnus-summary-default-score
3514 (not gnus-summary-inhibit-highlight))
3515 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3516 (article (gnus-summary-article-number))
3517 (score (gnus-summary-article-score article)))
3519 (if (and gnus-summary-mark-below
3520 (< (gnus-summary-article-score)
3521 gnus-summary-mark-below))
3522 ;; This article has a low score, so we mark it as read.
3523 (when (memq article gnus-newsgroup-unreads)
3524 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3525 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3526 ;; This article was previously marked as read on account
3527 ;; of a low score, but now it has risen, so we mark it as
3529 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3530 (gnus-summary-update-mark
3531 (if (or (null gnus-summary-default-score)
3532 (<= (abs (- score gnus-summary-default-score))
3533 gnus-summary-zcore-fuzz))
3535 (if (< score gnus-summary-default-score)
3536 gnus-score-below-mark gnus-score-over-mark))
3538 ;; Do visual highlighting.
3539 (when (gnus-visual-p 'summary-highlight 'highlight)
3540 (gnus-run-hooks 'gnus-summary-update-hook)))))
3542 (defvar gnus-tmp-new-adopts nil)
3544 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3545 "Return the number of articles in THREAD.
3546 This may be 0 in some cases -- if none of the articles in
3547 the thread are to be displayed."
3549 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3551 ((not (listp thread))
3553 ((and (consp thread) (cdr thread))
3556 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3559 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3562 (when (and level (zerop level) gnus-tmp-new-adopts)
3565 'gnus-summary-number-of-articles-in-thread
3566 gnus-tmp-new-adopts))))
3568 (if (> number 1) gnus-not-empty-thread-mark
3569 gnus-empty-thread-mark)
3572 (defsubst gnus-summary-line-message-size (head)
3573 "Return pretty-printed version of message size.
3574 This function is intended to be used in
3575 `gnus-summary-line-format-alist'."
3576 (let ((c (or (mail-header-chars head) -1)))
3577 (cond ((< c 0) "n/a") ; chars not available
3578 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3579 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3580 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3581 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3584 (defun gnus-summary-set-local-parameters (group)
3585 "Go through the local params of GROUP and set all variable specs in that list."
3586 (let ((params (gnus-group-find-parameter group))
3587 (vars '(quit-config)) ; Ignore quit-config.
3590 (setq elem (car params)
3591 params (cdr params))
3592 (and (consp elem) ; Has to be a cons.
3593 (consp (cdr elem)) ; The cdr has to be a list.
3594 (symbolp (car elem)) ; Has to be a symbol in there.
3595 (not (memq (car elem) vars))
3596 (ignore-errors ; So we set it.
3597 (push (car elem) vars)
3598 (make-local-variable (car elem))
3599 (set (car elem) (eval (nth 1 elem))))))))
3601 (defun gnus-summary-read-group (group &optional show-all no-article
3602 kill-buffer no-display backward
3604 "Start reading news in newsgroup GROUP.
3605 If SHOW-ALL is non-nil, already read articles are also listed.
3606 If NO-ARTICLE is non-nil, no article is selected initially.
3607 If NO-DISPLAY, don't generate a summary buffer."
3611 (let ((gnus-auto-select-next nil))
3612 (or (gnus-summary-read-group-1
3613 group show-all no-article
3614 kill-buffer no-display
3617 select-articles nil)))))
3618 (eq gnus-auto-select-next 'quietly))
3619 (set-buffer gnus-group-buffer)
3620 ;; The entry function called above goes to the next
3621 ;; group automatically, so we go two groups back
3622 ;; if we are searching for the previous group.
3624 (gnus-group-prev-unread-group 2))
3625 (if (not (equal group (gnus-group-group-name)))
3626 (setq group (gnus-group-group-name))
3630 (defun gnus-summary-read-group-1 (group show-all no-article
3631 kill-buffer no-display
3632 &optional select-articles)
3633 ;; Killed foreign groups can't be entered.
3634 ;; (when (and (not (gnus-group-native-p group))
3635 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3636 ;; (error "Dead non-native groups can't be entered"))
3637 (gnus-message 5 "Retrieving newsgroup: %s..."
3638 (gnus-group-decoded-name group))
3639 (let* ((new-group (gnus-summary-setup-buffer group))
3640 (quit-config (gnus-group-quit-config group))
3641 (did-select (and new-group (gnus-select-newsgroup
3642 group show-all select-articles))))
3644 ;; This summary buffer exists already, so we just select it.
3646 (gnus-set-global-variables)
3648 (gnus-kill-or-deaden-summary kill-buffer))
3649 (gnus-configure-windows 'summary 'force)
3650 (gnus-set-mode-line 'summary)
3651 (gnus-summary-position-point)
3654 ;; We couldn't select this group.
3656 (when (and (eq major-mode 'gnus-summary-mode)
3657 (not (equal (current-buffer) kill-buffer)))
3658 (kill-buffer (current-buffer))
3659 (if (not quit-config)
3661 ;; Update the info -- marks might need to be removed,
3663 (gnus-summary-update-info)
3664 (set-buffer gnus-group-buffer)
3665 (gnus-group-jump-to-group group)
3666 (gnus-group-next-unread-group 1))
3667 (gnus-handle-ephemeral-exit quit-config)))
3668 (let ((grpinfo (gnus-get-info group)))
3669 (if (null (gnus-info-read grpinfo))
3670 (gnus-message 3 "Group %s contains no messages"
3671 (gnus-group-decoded-name group))
3672 (gnus-message 3 "Can't select group")))
3674 ;; The user did a `C-g' while prompting for number of articles,
3675 ;; so we exit this group.
3676 ((eq did-select 'quit)
3677 (and (eq major-mode 'gnus-summary-mode)
3678 (not (equal (current-buffer) kill-buffer))
3679 (kill-buffer (current-buffer)))
3681 (gnus-kill-or-deaden-summary kill-buffer))
3682 (if (not quit-config)
3684 (set-buffer gnus-group-buffer)
3685 (gnus-group-jump-to-group group)
3686 (gnus-group-next-unread-group 1)
3687 (gnus-configure-windows 'group 'force))
3688 (gnus-handle-ephemeral-exit quit-config))
3689 ;; Finally signal the quit.
3691 ;; The group was successfully selected.
3693 (gnus-set-global-variables)
3694 ;; Save the active value in effect when the group was entered.
3695 (setq gnus-newsgroup-active
3697 (gnus-active gnus-newsgroup-name)))
3698 ;; You can change the summary buffer in some way with this hook.
3699 (gnus-run-hooks 'gnus-select-group-hook)
3700 (when (memq 'summary (gnus-update-format-specifications
3701 nil 'summary 'summary-mode 'summary-dummy))
3702 ;; The format specification for the summary line was updated,
3703 ;; so we need to update the mark positions as well.
3704 (gnus-update-summary-mark-positions))
3705 ;; Do score processing.
3706 (when gnus-use-scoring
3707 (gnus-possibly-score-headers))
3708 ;; Check whether to fill in the gaps in the threads.
3709 (when gnus-build-sparse-threads
3710 (gnus-build-sparse-threads))
3711 ;; Find the initial limit.
3712 (if gnus-show-threads
3714 (let ((gnus-newsgroup-dormant nil))
3715 (gnus-summary-initial-limit show-all))
3716 (gnus-summary-initial-limit show-all))
3717 ;; When unthreaded, all articles are always shown.
3718 (setq gnus-newsgroup-limit
3720 (lambda (header) (mail-header-number header))
3721 gnus-newsgroup-headers)))
3722 ;; Generate the summary buffer.
3724 (gnus-summary-prepare))
3725 (when gnus-use-trees
3726 (gnus-tree-open group)
3727 (setq gnus-summary-highlight-line-function
3728 'gnus-tree-highlight-article))
3729 ;; If the summary buffer is empty, but there are some low-scored
3730 ;; articles or some excluded dormants, we include these in the
3732 (when (and (zerop (buffer-size))
3734 (cond (gnus-newsgroup-dormant
3735 (gnus-summary-limit-include-dormant))
3736 ((and gnus-newsgroup-scored show-all)
3737 (gnus-summary-limit-include-expunged t))))
3738 ;; Function `gnus-apply-kill-file' must be called in this hook.
3739 (gnus-run-hooks 'gnus-apply-kill-hook)
3740 (if (and (zerop (buffer-size))
3743 ;; This newsgroup is empty.
3744 (gnus-summary-catchup-and-exit nil t)
3745 (gnus-message 6 "No unread news")
3747 (gnus-kill-or-deaden-summary kill-buffer))
3748 ;; Return nil from this function.
3750 ;; Hide conversation thread subtrees. We cannot do this in
3751 ;; gnus-summary-prepare-hook since kill processing may not
3752 ;; work with hidden articles.
3753 (gnus-summary-maybe-hide-threads)
3755 (gnus-kill-or-deaden-summary kill-buffer))
3756 (gnus-summary-auto-select-subject)
3757 ;; Show first unread article if requested.
3758 (if (and (not no-article)
3760 gnus-newsgroup-unreads
3761 gnus-auto-select-first)
3763 (gnus-configure-windows 'summary)
3764 (let ((art (gnus-summary-article-number)))
3765 (unless (and (not gnus-plugged)
3766 (or (memq art gnus-newsgroup-undownloaded)
3767 (memq art gnus-newsgroup-downloadable)))
3768 (gnus-summary-goto-article art))))
3769 ;; Don't select any articles.
3770 (gnus-summary-position-point)
3771 (gnus-configure-windows 'summary 'force)
3772 (gnus-set-mode-line 'summary))
3773 (when (and gnus-auto-center-group
3774 (get-buffer-window gnus-group-buffer t))
3775 ;; Gotta use windows, because recenter does weird stuff if
3776 ;; the current buffer ain't the displayed window.
3777 (let ((owin (selected-window)))
3778 (select-window (get-buffer-window gnus-group-buffer t))
3779 (when (gnus-group-goto-group group)
3781 (select-window owin)))
3782 ;; Mark this buffer as "prepared".
3783 (setq gnus-newsgroup-prepared t)
3784 (gnus-run-hooks 'gnus-summary-prepared-hook)
3785 (unless (gnus-ephemeral-group-p group)
3786 (gnus-group-update-group group))
3789 (defun gnus-summary-auto-select-subject ()
3790 "Select the subject line on initial group entry."
3791 (goto-char (point-min))
3793 ((eq gnus-auto-select-subject 'best)
3794 (gnus-summary-best-unread-subject))
3795 ((eq gnus-auto-select-subject 'unread)
3796 (gnus-summary-first-unread-subject))
3797 ((eq gnus-auto-select-subject 'unseen)
3798 (gnus-summary-first-unseen-subject))
3799 ((eq gnus-auto-select-subject 'unseen-or-unread)
3800 (gnus-summary-first-unseen-or-unread-subject))
3801 ((eq gnus-auto-select-subject 'first)
3804 ((functionp gnus-auto-select-subject)
3805 (funcall gnus-auto-select-subject))))
3807 (defun gnus-summary-prepare ()
3808 "Generate the summary buffer."
3810 (let ((buffer-read-only nil))
3812 (setq gnus-newsgroup-data nil
3813 gnus-newsgroup-data-reverse nil)
3814 (gnus-run-hooks 'gnus-summary-generate-hook)
3815 ;; Generate the buffer, either with threads or without.
3816 (when gnus-newsgroup-headers
3817 (gnus-summary-prepare-threads
3818 (if gnus-show-threads
3819 (gnus-sort-gathered-threads
3820 (funcall gnus-summary-thread-gathering-function
3822 (gnus-cut-threads (gnus-make-threads)))))
3823 ;; Unthreaded display.
3824 (gnus-sort-articles gnus-newsgroup-headers))))
3825 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3826 ;; Call hooks for modifying summary buffer.
3827 (goto-char (point-min))
3828 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3830 (defsubst gnus-general-simplify-subject (subject)
3831 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3834 ;; Truncate the subject.
3835 (gnus-simplify-subject-functions
3836 (gnus-map-function gnus-simplify-subject-functions subject))
3837 ((numberp gnus-summary-gather-subject-limit)
3838 (setq subject (gnus-simplify-subject-re subject))
3839 (if (> (length subject) gnus-summary-gather-subject-limit)
3840 (substring subject 0 gnus-summary-gather-subject-limit)
3842 ;; Fuzzily simplify it.
3843 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3844 (gnus-simplify-subject-fuzzy subject))
3845 ;; Just remove the leading "Re:".
3847 (gnus-simplify-subject-re subject))))
3849 (if (and gnus-summary-gather-exclude-subject
3850 (string-match gnus-summary-gather-exclude-subject subject))
3851 nil ; This article shouldn't be gathered
3854 (defun gnus-summary-simplify-subject-query ()
3855 "Query where the respool algorithm would put this article."
3857 (gnus-summary-select-article)
3858 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3860 (defun gnus-gather-threads-by-subject (threads)
3861 "Gather threads by looking at Subject headers."
3862 (if (not gnus-summary-make-false-root)
3864 (let ((hashtb (gnus-make-hashtable 1024))
3867 subject hthread whole-subject)
3869 (setq subject (gnus-general-simplify-subject
3870 (setq whole-subject (mail-header-subject
3873 (if (setq hthread (gnus-gethash subject hashtb))
3875 ;; We enter a dummy root into the thread, if we
3876 ;; haven't done that already.
3877 (unless (stringp (caar hthread))
3878 (setcar hthread (list whole-subject (car hthread))))
3879 ;; We add this new gathered thread to this gathered
3881 (setcdr (car hthread)
3882 (nconc (cdar hthread) (list (car threads))))
3883 ;; Remove it from the list of threads.
3884 (setcdr prev (cdr threads))
3885 (setq threads prev))
3886 ;; Enter this thread into the hash table.
3887 (gnus-sethash subject
3888 (if gnus-summary-make-false-root-always
3890 ;; If you want a dummy root above all
3892 (setcar threads (list whole-subject
3898 (setq threads (cdr threads)))
3901 (defun gnus-gather-threads-by-references (threads)
3902 "Gather threads by looking at References headers."
3903 (let ((idhashtb (gnus-make-hashtable 1024))
3904 (thhashtb (gnus-make-hashtable 1024))
3907 ids references id gthread gid entered ref)
3909 (when (setq references (mail-header-references (caar threads)))
3910 (setq id (mail-header-id (caar threads))
3911 ids (inline (gnus-split-references references))
3913 (while (setq ref (pop ids))
3914 (setq ids (delete ref ids))
3915 (if (not (setq gid (gnus-gethash ref idhashtb)))
3917 (gnus-sethash ref id idhashtb)
3918 (gnus-sethash id threads thhashtb))
3919 (setq gthread (gnus-gethash gid thhashtb))
3921 ;; We enter a dummy root into the thread, if we
3922 ;; haven't done that already.
3923 (unless (stringp (caar gthread))
3924 (setcar gthread (list (mail-header-subject (caar gthread))
3926 ;; We add this new gathered thread to this gathered
3928 (setcdr (car gthread)
3929 (nconc (cdar gthread) (list (car threads)))))
3930 ;; Add it into the thread hash table.
3931 (gnus-sethash id gthread thhashtb)
3933 ;; Remove it from the list of threads.
3934 (setcdr prev (cdr threads))
3935 (setq threads prev))))
3937 (setq threads (cdr threads)))
3940 (defun gnus-sort-gathered-threads (threads)
3941 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3942 (let ((result threads))
3944 (when (stringp (caar threads))
3945 (setcdr (car threads)
3946 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3947 (setq threads (cdr threads)))
3950 (defun gnus-thread-loop-p (root thread)
3951 "Say whether ROOT is in THREAD."
3952 (let ((stack (list thread))
3955 (while (setq thread (pop stack))
3956 (setq th (cdr thread))
3958 (not (eq (caar th) root)))
3961 ;; We have found a loop.
3963 (setcdr thread (delq (car th) (cdr thread)))
3964 (if (boundp (setq ref-dep (intern "none"
3965 gnus-newsgroup-dependencies)))
3966 (setcdr (symbol-value ref-dep)
3967 (nconc (cdr (symbol-value ref-dep))
3969 (set ref-dep (list nil (car th))))
3972 ;; Push all the subthreads onto the stack.
3973 (push (cdr thread) stack)))
3976 (defun gnus-make-threads ()
3977 "Go through the dependency hashtb and find the roots. Return all threads."
3979 (while (catch 'infloop
3982 ;; Deal with self-referencing References loops.
3983 (when (and (car (symbol-value refs))
3990 (car (symbol-value refs)) thread))
3991 (cdr (symbol-value refs)))))))
3994 (unless (car (symbol-value refs))
3995 ;; These threads do not refer back to any other
3996 ;; articles, so they're roots.
3997 (setq threads (append (cdr (symbol-value refs)) threads))))
3998 gnus-newsgroup-dependencies)))
4001 ;; Build the thread tree.
4002 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4003 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4005 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4006 if it was already present.
4008 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4009 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4010 Message-IDs will be renamed to a unique Message-ID before being
4013 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4014 (let* ((id (mail-header-id header))
4015 (id-dep (and id (intern id dependencies)))
4016 parent-id ref ref-dep ref-header replaced)
4017 ;; Enter this `header' in the `dependencies' table.
4021 ;; The first two cases do the normal part: enter a new `header'
4022 ;; in the `dependencies' table.
4023 ((not (boundp id-dep))
4024 (set id-dep (list header)))
4025 ((null (car (symbol-value id-dep)))
4026 (setcar (symbol-value id-dep) header))
4028 ;; From here the `header' was already present in the
4029 ;; `dependencies' table.
4031 ;; Overrides an existing entry;
4032 ;; just set the header part of the entry.
4033 (setcar (symbol-value id-dep) header)
4036 ;; Renames the existing `header' to a unique Message-ID.
4037 ((not gnus-summary-ignore-duplicates)
4038 ;; An article with this Message-ID has already been seen.
4039 ;; We rename the Message-ID.
4040 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4042 (mail-header-set-id header id))
4044 ;; The last case ignores an existing entry, except it adds any
4045 ;; additional Xrefs (in case the two articles came from different
4047 ;; Also sets `header' to `nil' meaning that the `dependencies'
4048 ;; table was *not* modified.
4050 (mail-header-set-xref
4051 (car (symbol-value id-dep))
4052 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4054 (or (mail-header-xref header) "")))
4057 (when (and header (not replaced))
4058 ;; First check that we are not creating a References loop.
4059 (setq parent-id (gnus-parent-id (mail-header-references header)))
4060 (setq ref parent-id)
4062 (setq ref-dep (intern-soft ref dependencies))
4064 (setq ref-header (car (symbol-value ref-dep))))
4065 (if (string= id ref)
4066 ;; Yuk! This is a reference loop. Make the article be a
4069 (mail-header-set-references (car (symbol-value id-dep)) "none")
4071 (setq parent-id nil))
4072 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4073 (setq ref-dep (intern (or parent-id "none") dependencies))
4074 (if (boundp ref-dep)
4075 (setcdr (symbol-value ref-dep)
4076 (nconc (cdr (symbol-value ref-dep))
4077 (list (symbol-value id-dep))))
4078 (set ref-dep (list nil (symbol-value id-dep)))))
4081 (defun gnus-extract-message-id-from-in-reply-to (string)
4082 (if (string-match "<[^>]+>" string)
4083 (substring string (match-beginning 0) (match-end 0))
4086 (defun gnus-build-sparse-threads ()
4087 (let ((headers gnus-newsgroup-headers)
4088 (mail-parse-charset gnus-newsgroup-charset)
4089 (gnus-summary-ignore-duplicates t)
4090 header references generation relations
4091 subject child end new-child date)
4092 ;; First we create an alist of generations/relations, where
4093 ;; generations is how much we trust the relation, and the relation
4095 (gnus-message 7 "Making sparse threads...")
4097 (nnheader-set-temp-buffer " *gnus sparse threads*")
4098 (while (setq header (pop headers))
4099 (when (and (setq references (mail-header-references header))
4100 (not (string= references "")))
4102 (setq child (mail-header-id header)
4103 subject (mail-header-subject header)
4104 date (mail-header-date header)
4106 (while (search-backward ">" nil t)
4107 (setq end (1+ (point)))
4108 (when (search-backward "<" nil t)
4109 (setq new-child (buffer-substring (point) end))
4110 (push (list (incf generation)
4111 child (setq child new-child)
4115 (push (list (1+ generation) child nil subject) relations))
4117 (kill-buffer (current-buffer)))
4118 ;; Sort over trustworthiness.
4121 (when (gnus-dependencies-add-header
4122 (make-full-mail-header
4123 gnus-reffed-article-number
4124 (nth 3 relation) "" (or (nth 4 relation) "")
4126 (or (nth 2 relation) "") 0 0 "")
4127 gnus-newsgroup-dependencies nil)
4128 (push gnus-reffed-article-number gnus-newsgroup-limit)
4129 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4130 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4131 gnus-newsgroup-reads)
4132 (decf gnus-reffed-article-number)))
4133 (sort relations 'car-less-than-car))
4134 (gnus-message 7 "Making sparse threads...done")))
4136 (defun gnus-build-old-threads ()
4137 ;; Look at all the articles that refer back to old articles, and
4138 ;; fetch the headers for the articles that aren't there. This will
4139 ;; build complete threads - if the roots haven't been expired by the
4141 (let ((mail-parse-charset gnus-newsgroup-charset)
4145 (when (not (car (symbol-value refs)))
4146 (setq heads (cdr (symbol-value refs)))
4148 (if (memq (mail-header-number (caar heads))
4149 gnus-newsgroup-dormant)
4150 (setq heads (cdr heads))
4151 (setq id (symbol-name refs))
4152 (while (and (setq id (gnus-build-get-header id))
4153 (not (car (gnus-id-to-thread id)))))
4154 (setq heads nil)))))
4155 gnus-newsgroup-dependencies)))
4157 (defsubst gnus-remove-odd-characters (string)
4158 "Translate STRING into something that doesn't contain weird characters."
4159 (mm-subst-char-in-string
4161 (mm-subst-char-in-string
4164 ;; This function has to be called with point after the article number
4165 ;; on the beginning of the line.
4166 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4167 (let ((eol (gnus-point-at-eol))
4168 (buffer (current-buffer))
4169 header references in-reply-to)
4171 ;; overview: [num subject from date id refs chars lines misc]
4174 (narrow-to-region (point) eol)
4179 (make-full-mail-header
4181 (condition-case () ; subject
4182 (gnus-remove-odd-characters
4183 (funcall gnus-decode-encoded-word-function
4184 (setq x (nnheader-nov-field))))
4186 (condition-case () ; from
4187 (gnus-remove-odd-characters
4188 (funcall gnus-decode-encoded-word-function
4189 (setq x (nnheader-nov-field))))
4191 (nnheader-nov-field) ; date
4192 (nnheader-nov-read-message-id) ; id
4193 (setq references (nnheader-nov-field)) ; refs
4194 (nnheader-nov-read-integer) ; chars
4195 (nnheader-nov-read-integer) ; lines
4197 (if (looking-at "Xref: ")
4198 (goto-char (match-end 0)))
4199 (nnheader-nov-field)) ; Xref
4200 (nnheader-nov-parse-extra)))) ; extra
4204 (when (and (string= references "")
4205 (setq in-reply-to (mail-header-extra header))
4206 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4207 (mail-header-set-references
4208 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4210 (when gnus-alter-header-function
4211 (funcall gnus-alter-header-function header))
4212 (gnus-dependencies-add-header header dependencies force-new)))
4214 (defun gnus-build-get-header (id)
4215 "Look through the buffer of NOV lines and find the header to ID.
4216 Enter this line into the dependencies hash table, and return
4217 the id of the parent article (if any)."
4218 (let ((deps gnus-newsgroup-dependencies)
4222 (set-buffer nntp-server-buffer)
4223 (let ((case-fold-search nil))
4224 (goto-char (point-min))
4225 (while (and (not found)
4226 (search-forward id nil t))
4228 (setq found (looking-at
4229 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4230 (regexp-quote id))))
4231 (or found (beginning-of-line 2)))
4235 (setq header (gnus-nov-parse-line
4236 (read (current-buffer)) deps))
4237 (gnus-parent-id (mail-header-references header))))))
4239 (let ((number (mail-header-number header)))
4240 (push number gnus-newsgroup-limit)
4241 (push header gnus-newsgroup-headers)
4242 (if (memq number gnus-newsgroup-unselected)
4244 (setq gnus-newsgroup-unreads
4245 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4247 (setq gnus-newsgroup-unselected
4248 (delq number gnus-newsgroup-unselected)))
4249 (push number gnus-newsgroup-ancient)))))))
4251 (defun gnus-build-all-threads ()
4252 "Read all the headers."
4253 (let ((gnus-summary-ignore-duplicates t)
4254 (mail-parse-charset gnus-newsgroup-charset)
4255 (dependencies gnus-newsgroup-dependencies)
4258 (set-buffer nntp-server-buffer)
4259 (let ((case-fold-search nil))
4260 (goto-char (point-min))
4263 (setq article (read (current-buffer))
4264 header (gnus-nov-parse-line article dependencies)))
4267 (set-buffer gnus-summary-buffer)
4268 (push header gnus-newsgroup-headers)
4269 (if (memq (setq article (mail-header-number header))
4270 gnus-newsgroup-unselected)
4272 (setq gnus-newsgroup-unreads
4273 (gnus-add-to-sorted-list
4274 gnus-newsgroup-unreads article))
4275 (setq gnus-newsgroup-unselected
4276 (delq article gnus-newsgroup-unselected)))
4277 (push article gnus-newsgroup-ancient)))
4278 (forward-line 1)))))))
4280 (defun gnus-summary-update-article-line (article header)
4281 "Update the line for ARTICLE using HEADER."
4282 (let* ((id (mail-header-id header))
4283 (thread (gnus-id-to-thread id)))
4285 (error "Article in no thread"))
4286 ;; Update the thread.
4287 (setcar thread header)
4288 (gnus-summary-goto-subject article)
4289 (let* ((datal (gnus-data-find-list article))
4291 (buffer-read-only nil)
4292 (level (gnus-summary-thread-level)))
4294 (let ((inserted (- (point)
4296 (gnus-summary-insert-line
4298 (memq article gnus-newsgroup-undownloaded)
4299 (gnus-article-mark article)
4300 (memq article gnus-newsgroup-replied)
4301 (memq article gnus-newsgroup-expirable)
4302 ;; Only insert the Subject string when it's different
4303 ;; from the previous Subject string.
4308 (mail-header-subject
4311 (gnus-data-find-list
4313 (gnus-data-list t)))))
4314 ;; Error on the side of excessive subjects.
4316 (mail-header-subject header)))
4318 (mail-header-subject header))
4319 nil (cdr (assq article gnus-newsgroup-scored))
4320 (memq article gnus-newsgroup-processable))
4323 (gnus-data-update-list
4325 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4327 (defun gnus-summary-update-article (article &optional iheader)
4328 "Update ARTICLE in the summary buffer."
4329 (set-buffer gnus-summary-buffer)
4330 (let* ((header (gnus-summary-article-header article))
4331 (id (mail-header-id header))
4332 (data (gnus-data-find article))
4333 (thread (gnus-id-to-thread id))
4334 (references (mail-header-references header))
4338 (when (and references
4339 (not (equal "" references)))
4342 (buffer-read-only nil)
4348 (delq thread parent)))
4349 (if (gnus-summary-insert-subject id header)
4350 ;; Set the (possibly) new article number in the data structure.
4351 (gnus-data-set-number data (gnus-id-to-article id))
4355 (defun gnus-rebuild-thread (id &optional line)
4356 "Rebuild the thread containing ID.
4357 If LINE, insert the rebuilt thread starting on line LINE."
4358 (let ((buffer-read-only nil)
4359 old-pos current thread data)
4360 (if (not gnus-show-threads)
4361 (setq thread (list (car (gnus-id-to-thread id))))
4362 ;; Get the thread this article is part of.
4363 (setq thread (gnus-remove-thread id)))
4364 (setq old-pos (gnus-point-at-bol))
4365 (setq current (save-excursion
4366 (and (re-search-backward "[\r\n]" nil t)
4367 (gnus-summary-article-number))))
4368 ;; If this is a gathered thread, we have to go some re-gathering.
4369 (when (stringp (car thread))
4370 (let ((subject (car thread))
4372 (setq thread (cdr thread))
4374 (unless (memq (setq thr (gnus-id-to-thread
4376 (mail-header-id (caar thread)))))
4379 (setq thread (cdr thread)))
4380 ;; We now have all (unique) roots.
4381 (if (= (length roots) 1)
4382 ;; All the loose roots are now one solid root.
4383 (setq thread (car roots))
4384 (setq thread (cons subject (gnus-sort-threads roots))))))
4386 ;; We then insert this thread into the summary buffer.
4388 (goto-char (point-min))
4389 (forward-line (1- line)))
4390 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4391 (if gnus-show-threads
4392 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4393 (gnus-summary-prepare-unthreaded thread))
4394 (setq data (nreverse gnus-newsgroup-data))
4395 (setq threads gnus-newsgroup-threads))
4396 ;; We splice the new data into the data structure.
4397 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4398 ;;!!! then we want to insert at the beginning of the buffer.
4399 ;;!!! That happens to be true with Gnus now, but that may
4400 ;;!!! change in the future. Perhaps.
4401 (gnus-data-enter-list
4402 (if line nil current) data (- (point) old-pos))
4403 (setq gnus-newsgroup-threads
4404 (nconc threads gnus-newsgroup-threads))
4405 (gnus-data-compute-positions))))
4407 (defun gnus-number-to-header (number)
4408 "Return the header for article NUMBER."
4409 (let ((headers gnus-newsgroup-headers))
4411 (not (= number (mail-header-number (car headers)))))
4416 (defun gnus-parent-headers (in-headers &optional generation)
4417 "Return the headers of the GENERATIONeth parent of HEADERS."
4419 (setq generation 1))
4421 (headers in-headers)
4424 (not (zerop generation))
4425 (setq references (mail-header-references headers)))
4426 (setq headers (if (and references
4427 (setq parent (gnus-parent-id references)))
4428 (car (gnus-id-to-thread parent))
4431 (and (not (eq headers in-headers))
4434 (defun gnus-id-to-thread (id)
4435 "Return the (sub-)thread where ID appears."
4436 (gnus-gethash id gnus-newsgroup-dependencies))
4438 (defun gnus-id-to-article (id)
4439 "Return the article number of ID."
4440 (let ((thread (gnus-id-to-thread id)))
4443 (mail-header-number (car thread)))))
4445 (defun gnus-id-to-header (id)
4446 "Return the article headers of ID."
4447 (car (gnus-id-to-thread id)))
4449 (defun gnus-article-displayed-root-p (article)
4450 "Say whether ARTICLE is a root(ish) article."
4451 (let ((level (gnus-summary-thread-level article))
4452 (refs (mail-header-references (gnus-summary-article-header article)))
4458 ((null (gnus-parent-id refs)) t)
4460 (null (setq particle (gnus-id-to-article
4461 (gnus-parent-id refs))))
4462 (null (gnus-summary-thread-level particle)))))))
4464 (defun gnus-root-id (id)
4465 "Return the id of the root of the thread where ID appears."
4467 (while (and id (setq prev (car (gnus-id-to-thread id))))
4469 id (gnus-parent-id (mail-header-references prev))))
4472 (defun gnus-articles-in-thread (thread)
4473 "Return the list of articles in THREAD."
4474 (cons (mail-header-number (car thread))
4475 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4477 (defun gnus-remove-thread (id &optional dont-remove)
4478 "Remove the thread that has ID in it."
4479 (let (headers thread last-id)
4480 ;; First go up in this thread until we find the root.
4481 (setq last-id (gnus-root-id id)
4482 headers (message-flatten-list (gnus-id-to-thread last-id)))
4483 ;; We have now found the real root of this thread. It might have
4484 ;; been gathered into some loose thread, so we have to search
4485 ;; through the threads to find the thread we wanted.
4486 (let ((threads gnus-newsgroup-threads)
4489 (setq sub (car threads))
4490 (if (stringp (car sub))
4491 ;; This is a gathered thread, so we look at the roots
4492 ;; below it to find whether this article is in this
4495 (setq sub (cdr sub))
4497 (when (member (caar sub) headers)
4498 (setq thread (car threads)
4501 (setq sub (cdr sub))))
4502 ;; It's an ordinary thread, so we check it.
4503 (when (eq (car sub) (car headers))
4506 (setq threads (cdr threads)))
4507 ;; If this article is in no thread, then it's a root.
4510 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4511 (setq thread (gnus-id-to-thread last-id)))
4514 thread ; We return this thread.
4516 (if (stringp (car thread))
4518 ;; If we use dummy roots, then we have to remove the
4519 ;; dummy root as well.
4520 (when (eq gnus-summary-make-false-root 'dummy)
4521 ;; We go to the dummy root by going to
4522 ;; the first sub-"thread", and then one line up.
4523 (gnus-summary-goto-article
4524 (mail-header-number (caadr thread)))
4527 (gnus-data-compute-positions))
4528 (setq thread (cdr thread))
4530 (gnus-remove-thread-1 (car thread))
4531 (setq thread (cdr thread))))
4532 (gnus-remove-thread-1 thread))))))))
4534 (defun gnus-remove-thread-1 (thread)
4535 "Remove the thread THREAD recursively."
4536 (let ((number (mail-header-number (pop thread)))
4538 (setq thread (reverse thread))
4540 (gnus-remove-thread-1 (pop thread)))
4541 (when (setq d (gnus-data-find number))
4542 (goto-char (gnus-data-pos d))
4543 (gnus-summary-show-thread)
4546 (- (gnus-point-at-bol)
4548 (1+ (gnus-point-at-eol))
4549 (gnus-delete-line)))))))
4551 (defun gnus-sort-threads-1 (threads func)
4552 (sort (mapcar (lambda (thread)
4555 (gnus-sort-threads-1 (cdr thread) func))))
4558 (defun gnus-sort-threads (threads)
4560 (if (not gnus-thread-sort-functions)
4562 (gnus-message 8 "Sorting threads...")
4563 (let ((max-lisp-eval-depth 5000))
4564 (prog1 (gnus-sort-threads-1
4566 (gnus-make-sort-function gnus-thread-sort-functions))
4567 (gnus-message 8 "Sorting threads...done")))))
4569 (defun gnus-sort-articles (articles)
4571 (when gnus-article-sort-functions
4572 (gnus-message 7 "Sorting articles...")
4574 (setq gnus-newsgroup-headers
4575 (sort articles (gnus-make-sort-function
4576 gnus-article-sort-functions)))
4577 (gnus-message 7 "Sorting articles...done"))))
4579 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4580 (defmacro gnus-thread-header (thread)
4581 "Return header of first article in THREAD.
4582 Note that THREAD must never, ever be anything else than a variable -
4583 using some other form will lead to serious barfage."
4584 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4585 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4586 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4589 (defsubst gnus-article-sort-by-number (h1 h2)
4590 "Sort articles by article number."
4591 (< (mail-header-number h1)
4592 (mail-header-number h2)))
4594 (defun gnus-thread-sort-by-number (h1 h2)
4595 "Sort threads by root article number."
4596 (gnus-article-sort-by-number
4597 (gnus-thread-header h1) (gnus-thread-header h2)))
4599 (defsubst gnus-article-sort-by-random (h1 h2)
4600 "Sort articles by article number."
4603 (defun gnus-thread-sort-by-random (h1 h2)
4604 "Sort threads by root article number."
4605 (gnus-article-sort-by-random
4606 (gnus-thread-header h1) (gnus-thread-header h2)))
4608 (defsubst gnus-article-sort-by-lines (h1 h2)
4609 "Sort articles by article Lines header."
4610 (< (mail-header-lines h1)
4611 (mail-header-lines h2)))
4613 (defun gnus-thread-sort-by-lines (h1 h2)
4614 "Sort threads by root article Lines header."
4615 (gnus-article-sort-by-lines
4616 (gnus-thread-header h1) (gnus-thread-header h2)))
4618 (defsubst gnus-article-sort-by-chars (h1 h2)
4619 "Sort articles by octet length."
4620 (< (mail-header-chars h1)
4621 (mail-header-chars h2)))
4623 (defun gnus-thread-sort-by-chars (h1 h2)
4624 "Sort threads by root article octet length."
4625 (gnus-article-sort-by-chars
4626 (gnus-thread-header h1) (gnus-thread-header h2)))
4628 (defsubst gnus-article-sort-by-author (h1 h2)
4629 "Sort articles by root author."
4631 (let ((extract (funcall
4632 gnus-extract-address-components
4633 (mail-header-from h1))))
4634 (or (car extract) (cadr extract) ""))
4635 (let ((extract (funcall
4636 gnus-extract-address-components
4637 (mail-header-from h2))))
4638 (or (car extract) (cadr extract) ""))))
4640 (defun gnus-thread-sort-by-author (h1 h2)
4641 "Sort threads by root author."
4642 (gnus-article-sort-by-author
4643 (gnus-thread-header h1) (gnus-thread-header h2)))
4645 (defsubst gnus-article-sort-by-subject (h1 h2)
4646 "Sort articles by root subject."
4648 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4649 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4651 (defun gnus-thread-sort-by-subject (h1 h2)
4652 "Sort threads by root subject."
4653 (gnus-article-sort-by-subject
4654 (gnus-thread-header h1) (gnus-thread-header h2)))
4656 (defsubst gnus-article-sort-by-date (h1 h2)
4657 "Sort articles by root article date."
4659 (gnus-date-get-time (mail-header-date h1))
4660 (gnus-date-get-time (mail-header-date h2))))
4662 (defun gnus-thread-sort-by-date (h1 h2)
4663 "Sort threads by root article date."
4664 (gnus-article-sort-by-date
4665 (gnus-thread-header h1) (gnus-thread-header h2)))
4667 (defsubst gnus-article-sort-by-score (h1 h2)
4668 "Sort articles by root article score.
4669 Unscored articles will be counted as having a score of zero."
4670 (> (or (cdr (assq (mail-header-number h1)
4671 gnus-newsgroup-scored))
4672 gnus-summary-default-score 0)
4673 (or (cdr (assq (mail-header-number h2)
4674 gnus-newsgroup-scored))
4675 gnus-summary-default-score 0)))
4677 (defun gnus-thread-sort-by-score (h1 h2)
4678 "Sort threads by root article score."
4679 (gnus-article-sort-by-score
4680 (gnus-thread-header h1) (gnus-thread-header h2)))
4682 (defun gnus-thread-sort-by-total-score (h1 h2)
4683 "Sort threads by the sum of all scores in the thread.
4684 Unscored articles will be counted as having a score of zero."
4685 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4687 (defun gnus-thread-total-score (thread)
4688 ;; This function find the total score of THREAD.
4693 (if (stringp (car thread))
4694 (apply gnus-thread-score-function 0
4695 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4696 (gnus-thread-total-score-1 thread)))
4698 (gnus-thread-total-score-1 (list thread)))))
4700 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4701 "Sort threads such that the thread with the most recently arrived article comes first."
4702 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4704 (defun gnus-thread-highest-number (thread)
4705 "Return the highest article number in THREAD."
4706 (apply 'max (mapcar (lambda (header)
4707 (mail-header-number header))
4708 (message-flatten-list thread))))
4710 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4711 "Sort threads such that the thread with the most recently dated article comes first."
4712 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4714 (defun gnus-thread-latest-date (thread)
4715 "Return the highest article date in THREAD."
4716 (let ((previous-time 0))
4722 (time-to-seconds (mail-header-parse-date
4723 (mail-header-date header)))
4724 (error previous-time))))
4726 (message-flatten-list thread)
4728 (< (mail-header-number h1)
4729 (mail-header-number h2))))))))
4731 (defun gnus-thread-total-score-1 (root)
4732 ;; This function find the total score of the thread below ROOT.
4733 (setq root (car root))
4734 (apply gnus-thread-score-function
4736 (mapcar 'gnus-thread-total-score
4737 (cdr (gnus-id-to-thread (mail-header-id root))))
4738 (when (> (mail-header-number root) 0)
4739 (list (or (cdr (assq (mail-header-number root)
4740 gnus-newsgroup-scored))
4741 gnus-summary-default-score 0))))
4742 (list gnus-summary-default-score)
4745 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4746 (defvar gnus-tmp-prev-subject nil)
4747 (defvar gnus-tmp-false-parent nil)
4748 (defvar gnus-tmp-root-expunged nil)
4749 (defvar gnus-tmp-dummy-line nil)
4751 (eval-when-compile (defvar gnus-tmp-header))
4752 (defun gnus-extra-header (type &optional header)
4753 "Return the extra header of TYPE."
4754 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4757 (defvar gnus-tmp-thread-tree-header-string "")
4759 (defcustom gnus-sum-thread-tree-root "> "
4760 "With %B spec, used for the root of a thread.
4761 If nil, use subject instead."
4763 :type '(radio (const :format "%v " nil) string)
4764 :group 'gnus-thread)
4765 (defcustom gnus-sum-thread-tree-false-root "> "
4766 "With %B spec, used for a false root of a thread.
4767 If nil, use subject instead."
4769 :type '(radio (const :format "%v " nil) string)
4770 :group 'gnus-thread)
4771 (defcustom gnus-sum-thread-tree-single-indent ""
4772 "With %B spec, used for a thread with just one message.
4773 If nil, use subject instead."
4775 :type '(radio (const :format "%v " nil) string)
4776 :group 'gnus-thread)
4777 (defcustom gnus-sum-thread-tree-vertical "| "
4778 "With %B spec, used for drawing a vertical line."
4781 :group 'gnus-thread)
4782 (defcustom gnus-sum-thread-tree-indent " "
4783 "With %B spec, used for indenting."
4786 :group 'gnus-thread)
4787 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4788 "With %B spec, used for a leaf with brothers."
4791 :group 'gnus-thread)
4792 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4793 "With %B spec, used for a leaf without brothers."
4796 :group 'gnus-thread)
4798 (defun gnus-summary-prepare-threads (threads)
4799 "Prepare summary buffer from THREADS and indentation LEVEL.
4800 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4801 or a straight list of headers."
4802 (gnus-message 7 "Generating summary...")
4804 (setq gnus-newsgroup-threads threads)
4807 (let ((gnus-tmp-level 0)
4808 (default-score (or gnus-summary-default-score 0))
4809 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4810 (building-line-count gnus-summary-display-while-building)
4811 (building-count (integerp gnus-summary-display-while-building))
4812 thread number subject stack state gnus-tmp-gathered beg-match
4813 new-roots gnus-tmp-new-adopts thread-end simp-subject
4814 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4815 gnus-tmp-replied gnus-tmp-subject-or-nil
4816 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4817 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4818 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4821 (setq gnus-tmp-prev-subject nil
4822 gnus-tmp-thread-tree-header-string "")
4824 (if (vectorp (car threads))
4825 ;; If this is a straight (sic) list of headers, then a
4826 ;; threaded summary display isn't required, so we just create
4827 ;; an unthreaded one.
4828 (gnus-summary-prepare-unthreaded threads)
4830 ;; Do the threaded display.
4832 (if gnus-summary-display-while-building
4833 (switch-to-buffer (buffer-name)))
4834 (while (or threads stack gnus-tmp-new-adopts new-roots)
4836 (if (and (= gnus-tmp-level 0)
4839 (not gnus-tmp-false-parent)
4840 (or gnus-tmp-new-adopts new-roots))
4841 (if gnus-tmp-new-adopts
4842 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4843 thread (list (car gnus-tmp-new-adopts))
4844 gnus-tmp-header (caar thread)
4845 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4847 (setq thread (list (car new-roots))
4848 gnus-tmp-header (caar thread)
4849 new-roots (cdr new-roots))))
4852 ;; If there are some threads, we do them before the
4853 ;; threads on the stack.
4854 (setq thread threads
4855 gnus-tmp-header (caar thread))
4856 ;; There were no current threads, so we pop something off
4858 (setq state (car stack)
4859 gnus-tmp-level (car state)
4860 tree-stack (cadr state)
4861 thread (caddr state)
4863 gnus-tmp-header (caar thread))))
4865 (setq gnus-tmp-false-parent nil)
4866 (setq gnus-tmp-root-expunged nil)
4867 (setq thread-end nil)
4869 (if (stringp gnus-tmp-header)
4870 ;; The header is a dummy root.
4872 ((eq gnus-summary-make-false-root 'adopt)
4873 ;; We let the first article adopt the rest.
4874 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4876 (setq gnus-tmp-gathered
4878 (lambda (h) (mail-header-number (car h)))
4881 (setq thread (cons (list (caar thread)
4884 (setq gnus-tmp-level -1
4885 gnus-tmp-false-parent t))
4886 ((eq gnus-summary-make-false-root 'empty)
4887 ;; We print adopted articles with empty subject fields.
4888 (setq gnus-tmp-gathered
4890 (lambda (h) (mail-header-number (car h)))
4893 (setq gnus-tmp-level -1))
4894 ((eq gnus-summary-make-false-root 'dummy)
4895 ;; We remember that we probably want to output a dummy
4897 (setq gnus-tmp-dummy-line gnus-tmp-header)
4898 (setq gnus-tmp-prev-subject gnus-tmp-header))
4900 ;; We do not make a root for the gathered
4901 ;; sub-threads at all.
4902 (setq gnus-tmp-level -1)))
4904 (setq number (mail-header-number gnus-tmp-header)
4905 subject (mail-header-subject gnus-tmp-header)
4906 simp-subject (gnus-simplify-subject-fully subject))
4909 ;; If the thread has changed subject, we might want to make
4910 ;; this subthread into a root.
4911 ((and (null gnus-thread-ignore-subject)
4912 (not (zerop gnus-tmp-level))
4913 gnus-tmp-prev-subject
4914 (not (string= gnus-tmp-prev-subject simp-subject)))
4915 (setq new-roots (nconc new-roots (list (car thread)))
4917 gnus-tmp-header nil))
4918 ;; If the article lies outside the current limit,
4919 ;; then we do not display it.
4920 ((not (memq number gnus-newsgroup-limit))
4921 (setq gnus-tmp-gathered
4923 (lambda (h) (mail-header-number (car h)))
4926 (setq gnus-tmp-new-adopts (if (cdar thread)
4927 (append gnus-tmp-new-adopts
4929 gnus-tmp-new-adopts)
4931 gnus-tmp-header nil)
4932 (when (zerop gnus-tmp-level)
4933 (setq gnus-tmp-root-expunged t)))
4934 ;; Perhaps this article is to be marked as read?
4935 ((and gnus-summary-mark-below
4936 (< (or (cdr (assq number gnus-newsgroup-scored))
4938 gnus-summary-mark-below)
4939 ;; Don't touch sparse articles.
4940 (not (gnus-summary-article-sparse-p number))
4941 (not (gnus-summary-article-ancient-p number)))
4942 (setq gnus-newsgroup-unreads
4943 (delq number gnus-newsgroup-unreads))
4944 (if gnus-newsgroup-auto-expire
4945 (setq gnus-newsgroup-expirable
4946 (gnus-add-to-sorted-list
4947 gnus-newsgroup-expirable number))
4948 (push (cons number gnus-low-score-mark)
4949 gnus-newsgroup-reads))))
4951 (when gnus-tmp-header
4952 ;; We may have an old dummy line to output before this
4954 (when (and gnus-tmp-dummy-line
4957 (mail-header-subject gnus-tmp-header)))
4958 (gnus-summary-insert-dummy-line
4959 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4960 (setq gnus-tmp-dummy-line nil))
4962 ;; Compute the mark.
4963 (setq gnus-tmp-unread (gnus-article-mark number))
4965 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4966 gnus-tmp-header gnus-tmp-level)
4967 gnus-newsgroup-data)
4969 ;; Actually insert the line.
4971 gnus-tmp-subject-or-nil
4973 ((and gnus-thread-ignore-subject
4974 gnus-tmp-prev-subject
4975 (not (string= gnus-tmp-prev-subject simp-subject)))
4977 ((zerop gnus-tmp-level)
4978 (if (and (eq gnus-summary-make-false-root 'empty)
4979 (memq number gnus-tmp-gathered)
4980 gnus-tmp-prev-subject
4981 (string= gnus-tmp-prev-subject simp-subject))
4982 gnus-summary-same-subject
4984 (t gnus-summary-same-subject)))
4985 (if (and (eq gnus-summary-make-false-root 'adopt)
4986 (= gnus-tmp-level 1)
4987 (memq number gnus-tmp-gathered))
4988 (setq gnus-tmp-opening-bracket ?\<
4989 gnus-tmp-closing-bracket ?\>)
4990 (setq gnus-tmp-opening-bracket ?\[
4991 gnus-tmp-closing-bracket ?\]))
4993 gnus-tmp-indentation
4994 (aref gnus-thread-indent-array gnus-tmp-level)
4995 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4996 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4997 gnus-summary-default-score 0)
4999 (if (or (null gnus-summary-default-score)
5000 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5001 gnus-summary-zcore-fuzz))
5003 (if (< gnus-tmp-score gnus-summary-default-score)
5004 gnus-score-below-mark gnus-score-over-mark))
5006 (cond ((memq number gnus-newsgroup-processable)
5008 ((memq number gnus-newsgroup-cached)
5010 ((memq number gnus-newsgroup-replied)
5012 ((memq number gnus-newsgroup-forwarded)
5013 gnus-forwarded-mark)
5014 ((memq number gnus-newsgroup-saved)
5016 ((memq number gnus-newsgroup-recent)
5018 ((memq number gnus-newsgroup-unseen)
5022 (cond ((memq number gnus-newsgroup-undownloaded)
5023 gnus-undownloaded-mark)
5024 (gnus-newsgroup-agentized
5025 gnus-downloaded-mark)
5028 gnus-tmp-from (mail-header-from gnus-tmp-header)
5031 ((string-match "<[^>]+> *$" gnus-tmp-from)
5032 (setq beg-match (match-beginning 0))
5033 (or (and (string-match "^\".+\"" gnus-tmp-from)
5034 (substring gnus-tmp-from 1 (1- (match-end 0))))
5035 (substring gnus-tmp-from 0 beg-match)))
5036 ((string-match "(.+)" gnus-tmp-from)
5037 (substring gnus-tmp-from
5038 (1+ (match-beginning 0)) (1- (match-end 0))))
5042 gnus-tmp-thread-tree-header-string
5044 ((not gnus-show-threads) "")
5045 ((zerop gnus-tmp-level)
5046 (cond ((cdar thread)
5047 (or gnus-sum-thread-tree-root subject))
5048 (gnus-tmp-new-adopts
5049 (or gnus-sum-thread-tree-false-root subject))
5051 (or gnus-sum-thread-tree-single-indent subject))))
5053 (concat (apply 'concat
5054 (mapcar (lambda (item)
5056 gnus-sum-thread-tree-vertical
5057 gnus-sum-thread-tree-indent))
5058 (cdr (reverse tree-stack))))
5060 gnus-sum-thread-tree-leaf-with-other
5061 gnus-sum-thread-tree-single-leaf)))))
5062 (when (string= gnus-tmp-name "")
5063 (setq gnus-tmp-name gnus-tmp-from))
5064 (unless (numberp gnus-tmp-lines)
5065 (setq gnus-tmp-lines -1))
5066 (if (= gnus-tmp-lines -1)
5067 (setq gnus-tmp-lines "?")
5068 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5069 (gnus-put-text-property
5071 (progn (eval gnus-summary-line-format-spec) (point))
5072 'gnus-number number)
5075 (gnus-run-hooks 'gnus-summary-update-hook)
5078 (setq gnus-tmp-prev-subject simp-subject)))
5080 (when (nth 1 thread)
5081 (push (list (max 0 gnus-tmp-level)
5082 (copy-sequence tree-stack)
5085 (push (if (nth 1 thread) 1 0) tree-stack)
5086 (incf gnus-tmp-level)
5087 (setq threads (if thread-end nil (cdar thread)))
5088 (if gnus-summary-display-while-building
5091 ;; use a set frequency
5092 (setq building-line-count (1- building-line-count))
5093 (when (= building-line-count 0)
5095 (setq building-line-count
5096 gnus-summary-display-while-building)))
5100 (setq gnus-tmp-level 0)))))
5101 (gnus-message 7 "Generating summary...done"))
5103 (defun gnus-summary-prepare-unthreaded (headers)
5104 "Generate an unthreaded summary buffer based on HEADERS."
5105 (let (header number mark)
5110 ;; We may have to root out some bad articles...
5111 (when (memq (setq number (mail-header-number
5112 (setq header (pop headers))))
5113 gnus-newsgroup-limit)
5114 ;; Mark article as read when it has a low score.
5115 (when (and gnus-summary-mark-below
5116 (< (or (cdr (assq number gnus-newsgroup-scored))
5117 gnus-summary-default-score 0)
5118 gnus-summary-mark-below)
5119 (not (gnus-summary-article-ancient-p number)))
5120 (setq gnus-newsgroup-unreads
5121 (delq number gnus-newsgroup-unreads))
5122 (if gnus-newsgroup-auto-expire
5123 (push number gnus-newsgroup-expirable)
5124 (push (cons number gnus-low-score-mark)
5125 gnus-newsgroup-reads)))
5127 (setq mark (gnus-article-mark number))
5128 (push (gnus-data-make number mark (1+ (point)) header 0)
5129 gnus-newsgroup-data)
5130 (gnus-summary-insert-line
5132 (memq number gnus-newsgroup-undownloaded)
5133 mark (memq number gnus-newsgroup-replied)
5134 (memq number gnus-newsgroup-expirable)
5135 (mail-header-subject header) nil
5136 (cdr (assq number gnus-newsgroup-scored))
5137 (memq number gnus-newsgroup-processable))))))
5139 (defun gnus-summary-remove-list-identifiers ()
5140 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5141 (let ((regexp (if (consp gnus-list-identifiers)
5142 (mapconcat 'identity gnus-list-identifiers " *\\|")
5143 gnus-list-identifiers))
5146 (dolist (header gnus-newsgroup-headers)
5147 (setq subject (mail-header-subject header)
5149 (while (string-match
5150 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5153 (concat (substring subject 0 (match-beginning 2))
5154 (substring subject (match-end 0)))
5158 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5160 (concat (substring subject 0 (match-beginning 1))
5161 (substring subject (match-end 1)))))
5163 (mail-header-set-subject header subject))))))
5165 (defun gnus-fetch-headers (articles)
5166 "Fetch headers of ARTICLES."
5167 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5168 (gnus-message 5 "Fetching headers for %s..." name)
5171 (setq gnus-headers-retrieved-by
5172 (gnus-retrieve-headers
5173 articles gnus-newsgroup-name
5174 ;; We might want to fetch old headers, but
5175 ;; not if there is only 1 article.
5177 (not (eq gnus-fetch-old-headers 'some))
5178 (not (numberp gnus-fetch-old-headers)))
5179 (> (length articles) 1))
5180 gnus-fetch-old-headers))))
5181 (gnus-get-newsgroup-headers-xover
5182 articles nil nil gnus-newsgroup-name t)
5183 (gnus-get-newsgroup-headers))
5184 (gnus-message 5 "Fetching headers for %s...done" name))))
5186 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5187 "Select newsgroup GROUP.
5188 If READ-ALL is non-nil, all articles in the group are selected.
5189 If SELECT-ARTICLES, only select those articles from GROUP."
5190 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5191 ;;!!! Dirty hack; should be removed.
5192 (gnus-summary-ignore-duplicates
5193 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5195 gnus-summary-ignore-duplicates))
5196 (info (nth 2 entry))
5197 articles fetched-articles cached)
5199 (unless (gnus-check-server
5200 (set (make-local-variable 'gnus-current-select-method)
5201 (gnus-find-method-for-group group)))
5202 (error "Couldn't open server"))
5204 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5205 (gnus-activate-group group) ; Or we can activate it...
5206 (progn ; Or we bug out.
5207 (when (equal major-mode 'gnus-summary-mode)
5208 (gnus-kill-buffer (current-buffer)))
5209 (error "Couldn't activate group %s: %s"
5210 group (gnus-status-message group))))
5212 (unless (gnus-request-group group t)
5213 (when (equal major-mode 'gnus-summary-mode)
5214 (gnus-kill-buffer (current-buffer)))
5215 (error "Couldn't request group %s: %s"
5216 group (gnus-status-message group)))
5219 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5221 (setq gnus-summary-use-undownloaded-faces
5222 (gnus-agent-find-parameter
5224 'agent-enable-undownloaded-faces)))
5226 (setq gnus-newsgroup-name group
5227 gnus-newsgroup-unselected nil
5228 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5230 (let ((display (gnus-group-find-parameter group 'display)))
5231 (setq gnus-newsgroup-display
5233 ((not (zerop (or (car-safe read-all) 0)))
5234 ;; The user entered the group with C-u SPC/RET, let's show
5240 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5242 ;; The following is probably the "correct" solution, but
5243 ;; it makes Gnus fetch all headers and then limit the
5244 ;; articles (which is slow), so instead we hack the
5245 ;; select-articles parameter instead. -- Simon Josefsson
5248 ;; (gnus-byte-compile
5249 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5251 (setq select-articles
5252 (gnus-uncompress-range
5253 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5257 (cdr (gnus-active group)))))
5262 (gnus-summary-setup-default-charset)
5264 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5265 (when (gnus-virtual-group-p group)
5266 (setq cached gnus-newsgroup-cached))
5268 (setq gnus-newsgroup-unreads
5269 (gnus-sorted-ndifference
5270 (gnus-sorted-ndifference gnus-newsgroup-unreads
5271 gnus-newsgroup-marked)
5272 gnus-newsgroup-dormant))
5274 (setq gnus-newsgroup-processable nil)
5276 (gnus-update-read-articles group gnus-newsgroup-unreads)
5278 ;; Adjust and set lists of article marks.
5280 (gnus-adjust-marked-articles info))
5281 (if (setq articles select-articles)
5282 (setq gnus-newsgroup-unselected
5283 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5284 (setq articles (gnus-articles-to-read group read-all)))
5288 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5290 ((eq articles 0) nil)
5292 ;; Init the dependencies hash table.
5293 (setq gnus-newsgroup-dependencies
5294 (gnus-make-hashtable (length articles)))
5295 (gnus-set-global-variables)
5296 ;; Retrieve the headers and read them in.
5298 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5300 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5302 (setq gnus-newsgroup-cached cached))
5304 ;; Suppress duplicates?
5305 (when gnus-suppress-duplicates
5306 (gnus-dup-suppress-articles))
5308 ;; Set the initial limit.
5309 (setq gnus-newsgroup-limit (copy-sequence articles))
5310 ;; Remove canceled articles from the list of unread articles.
5311 (setq fetched-articles
5312 (mapcar (lambda (headers) (mail-header-number headers))
5313 gnus-newsgroup-headers))
5314 (setq gnus-newsgroup-articles fetched-articles)
5315 (setq gnus-newsgroup-unreads
5316 (gnus-sorted-nintersection
5317 gnus-newsgroup-unreads fetched-articles))
5318 (gnus-compute-unseen-list)
5320 ;; Removed marked articles that do not exist.
5321 (gnus-update-missing-marks
5322 (gnus-sorted-difference articles fetched-articles))
5323 ;; We might want to build some more threads first.
5324 (when (and gnus-fetch-old-headers
5325 (eq gnus-headers-retrieved-by 'nov))
5326 (if (eq gnus-fetch-old-headers 'invisible)
5327 (gnus-build-all-threads)
5328 (gnus-build-old-threads)))
5329 ;; Let the Gnus agent mark articles as read.
5331 (gnus-agent-get-undownloaded-list))
5332 ;; Remove list identifiers from subject
5333 (when gnus-list-identifiers
5334 (gnus-summary-remove-list-identifiers))
5335 ;; Check whether auto-expire is to be done in this group.
5336 (setq gnus-newsgroup-auto-expire
5337 (gnus-group-auto-expirable-p group))
5338 ;; Set up the article buffer now, if necessary.
5339 (unless gnus-single-article-buffer
5340 (gnus-article-setup-buffer))
5341 ;; First and last article in this newsgroup.
5342 (when gnus-newsgroup-headers
5343 (setq gnus-newsgroup-begin
5344 (mail-header-number (car gnus-newsgroup-headers))
5347 (gnus-last-element gnus-newsgroup-headers))))
5348 ;; GROUP is successfully selected.
5349 (or gnus-newsgroup-headers t)))))
5351 (defun gnus-compute-unseen-list ()
5352 ;; The `seen' marks are treated specially.
5353 (if (not gnus-newsgroup-seen)
5354 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5355 (setq gnus-newsgroup-unseen
5356 (gnus-inverse-list-range-intersection
5357 gnus-newsgroup-articles gnus-newsgroup-seen))))
5359 (defun gnus-summary-display-make-predicate (display)
5360 (require 'gnus-agent)
5361 (when (= (length display) 1)
5362 (setq display (car display)))
5363 (unless gnus-summary-display-cache
5364 (dolist (elem (append '((unread . unread)
5367 gnus-article-mark-lists))
5368 (push (cons (cdr elem)
5370 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5371 gnus-summary-display-cache)))
5372 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5373 (gnus-category-predicate-cache gnus-summary-display-cache))
5374 (gnus-get-predicate display)))
5376 ;; Uses the dynamically bound `number' variable.
5379 (defun gnus-article-marked-p (type &optional article)
5380 (let ((article (or article number)))
5383 (memq article gnus-newsgroup-marked))
5385 (memq article gnus-newsgroup-spam-marked))
5387 (memq article gnus-newsgroup-unsendable))
5388 ((eq type 'undownload)
5389 (memq article gnus-newsgroup-undownloaded))
5390 ((eq type 'download)
5391 (memq article gnus-newsgroup-downloadable))
5393 (memq article gnus-newsgroup-unreads))
5395 (memq article gnus-newsgroup-reads))
5397 (memq article gnus-newsgroup-dormant) )
5399 (memq article gnus-newsgroup-expirable))
5401 (memq article gnus-newsgroup-replied))
5403 (memq article gnus-newsgroup-killed))
5404 ((eq type 'bookmark)
5405 (assq article gnus-newsgroup-bookmarks))
5407 (assq article gnus-newsgroup-scored))
5409 (memq article gnus-newsgroup-saved))
5411 (memq article gnus-newsgroup-cached))
5413 (memq article gnus-newsgroup-forwarded))
5415 (not (memq article gnus-newsgroup-unseen)))
5417 (memq article gnus-newsgroup-recent))
5420 (defun gnus-articles-to-read (group &optional read-all)
5421 "Find out what articles the user wants to read."
5422 (let* ((display (gnus-group-find-parameter group 'display))
5424 ;; Select all articles if `read-all' is non-nil, or if there
5425 ;; are no unread articles.
5427 (and (zerop (length gnus-newsgroup-marked))
5428 (zerop (length gnus-newsgroup-unreads)))
5429 ;; Fetch all if the predicate is non-nil.
5430 gnus-newsgroup-display)
5431 ;; We want to select the headers for all the articles in
5432 ;; the group, so we select either all the active
5433 ;; articles in the group, or (if that's nil), the
5434 ;; articles in the cache.
5436 (gnus-uncompress-range (gnus-active group))
5437 (gnus-cache-articles-in-group group))
5438 ;; Select only the "normal" subset of articles.
5440 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5441 gnus-newsgroup-unreads)))
5442 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5443 (scored (length scored-list))
5444 (number (length articles))
5445 (marked (+ (length gnus-newsgroup-marked)
5446 (length gnus-newsgroup-dormant)))
5451 ((numberp gnus-newsgroup-display)
5452 gnus-newsgroup-display)
5456 ((and (or (<= scored marked) (= scored number))
5457 (numberp gnus-large-newsgroup)
5458 (> number gnus-large-newsgroup))
5459 (let* ((cursor-in-echo-area nil)
5460 (initial (gnus-parameter-large-newsgroup-initial
5461 gnus-newsgroup-name))
5465 "How many articles from %s (%s %d): "
5467 (gnus-group-decoded-name gnus-newsgroup-name)
5469 (if initial "max" "default")
5472 (cons (number-to-string initial)
5474 (if (string-match "^[ \t]*$" input) number input)))
5475 ((and (> scored marked) (< scored number)
5476 (> (- scored number) 20))
5479 (format "%s %s (%d scored, %d total): "
5480 "How many articles from"
5481 (gnus-group-decoded-name group)
5483 (if (string-match "^[ \t]*$" input)
5487 (message "Quit getting the articles to read")
5489 (setq select (if (stringp select) (string-to-number select) select))
5490 (if (or (null select) (zerop select))
5492 (if (and (not (zerop scored)) (<= (abs select) scored))
5494 (setq articles (sort scored-list '<))
5495 (setq number (length articles)))
5496 (setq articles (copy-sequence articles)))
5498 (when (< (abs select) number)
5500 ;; Select the N oldest articles.
5501 (setcdr (nthcdr (1- (abs select)) articles) nil)
5502 ;; Select the N most recent articles.
5503 (setq articles (nthcdr (- number select) articles))))
5504 (setq gnus-newsgroup-unselected
5505 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5506 (when gnus-alter-articles-to-read-function
5509 (funcall gnus-alter-articles-to-read-function
5510 gnus-newsgroup-name articles)
5514 (defun gnus-killed-articles (killed articles)
5517 (when (inline (gnus-member-of-range (car articles) killed))
5518 (push (car articles) out))
5519 (setq articles (cdr articles)))
5522 (defun gnus-uncompress-marks (marks)
5523 "Uncompress the mark ranges in MARKS."
5524 (let ((uncompressed '(score bookmark))
5527 (if (memq (caar marks) uncompressed)
5528 (push (car marks) out)
5529 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5530 (setq marks (cdr marks)))
5533 (defun gnus-article-mark-to-type (mark)
5534 "Return the type of MARK."
5535 (or (cadr (assq mark gnus-article-special-mark-lists))
5538 (defun gnus-article-unpropagatable-p (mark)
5539 "Return whether MARK should be propagated to back end."
5540 (memq mark gnus-article-unpropagated-mark-lists))
5542 (defun gnus-adjust-marked-articles (info)
5543 "Set all article lists and remove all marks that are no longer valid."
5544 (let* ((marked-lists (gnus-info-marks info))
5545 (active (gnus-active (gnus-info-group info)))
5548 (types gnus-article-mark-lists)
5549 marks var articles article mark mark-type
5552 (dolist (marks marked-lists)
5553 (setq mark (car marks)
5554 mark-type (gnus-article-mark-to-type mark)
5555 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5557 ;; We set the variable according to the type of the marks list,
5558 ;; and then adjust the marks to a subset of the active articles.
5560 ;; Adjust "simple" lists - compressed yet unsorted
5561 ((eq mark-type 'list)
5562 ;; Simultaneously uncompress and clip to active range
5563 ;; See gnus-uncompress-range for a description of possible marks
5565 (if (not (cadr marks))
5567 (setq articles (if (numberp (cddr marks))
5573 (while (setq article (pop articles))
5574 (cond ((consp article)
5575 (setq bgn (max (car article) min)
5576 end (min (cdr article) max))
5578 (setq l (setcdr l (cons bgn nil))
5580 ((and (<= min article)
5582 (setq l (setcdr l (cons article nil))))))
5583 (set var (cdr lh)))))
5585 ((eq mark-type 'tuple)
5586 (set var (setq articles (cdr marks)))
5587 (when (not (listp (cdr (symbol-value var))))
5588 (set var (list (symbol-value var))))
5589 (when (not (listp (cdr articles)))
5590 (setq articles (list articles)))
5592 (when (or (not (consp (setq article (pop articles))))
5593 (< (car article) min)
5594 (> (car article) max))
5595 (set var (delq article (symbol-value var))))))
5596 ;; Adjust ranges (sloppily).
5597 ((eq mark-type 'range)
5600 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5601 ;; It should be (seen (NUM1 . NUM2)).
5602 (when (numberp (cddr marks))
5603 (setcdr marks (list (cdr marks))))
5604 (setq articles (cdr marks))
5605 (while (and articles
5606 (or (and (consp (car articles))
5607 (> min (cdar articles)))
5608 (and (numberp (car articles))
5609 (> min (car articles)))))
5611 (set var articles))))))))
5613 (defun gnus-update-missing-marks (missing)
5614 "Go through the list of MISSING articles and remove them from the mark lists."
5617 ;; Go through all types.
5618 (dolist (elem gnus-article-mark-lists)
5619 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5620 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5621 (when (symbol-value var)
5622 ;; This list has articles. So we delete all missing
5623 ;; articles from it.
5626 (set var (delq (pop m) (symbol-value var))))))))))
5628 (defun gnus-update-marks ()
5629 "Enter the various lists of marked articles into the newsgroup info list."
5630 (let ((types gnus-article-mark-lists)
5631 (info (gnus-get-info gnus-newsgroup-name))
5632 type list newmarked symbol delta-marks)
5634 ;; Add all marks lists to the list of marks lists.
5635 (while (setq type (pop types))
5636 (setq list (symbol-value
5638 (intern (format "gnus-newsgroup-%s" (car type))))))
5641 ;; Get rid of the entries of the articles that have the
5643 (when (and (eq (cdr type) 'score)
5647 (prev (cons nil list))
5650 (if (or (not (consp (car arts)))
5651 (= (cdar arts) gnus-summary-default-score))
5652 (setcdr prev (cdr arts))
5654 (setq arts (cdr arts)))
5655 (setq list (cdr all)))))
5657 (when (eq (cdr type) 'seen)
5658 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5660 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5661 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5663 (when (and (gnus-check-backend-function
5664 'request-set-mark gnus-newsgroup-name)
5665 (not (gnus-article-unpropagatable-p (cdr type))))
5666 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5667 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5668 (add (gnus-remove-from-range
5669 (gnus-copy-sequence list) old)))
5671 (push (list add 'add (list (cdr type))) delta-marks))
5673 (push (list del 'del (list (cdr type))) delta-marks))))
5676 (push (cons (cdr type) list) newmarked)))
5679 (unless (gnus-check-group gnus-newsgroup-name)
5680 (error "Can't open server for %s" gnus-newsgroup-name))
5681 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5683 ;; Enter these new marks into the info of the group.
5685 (setcar (nthcdr 3 info) newmarked)
5686 ;; Add the marks lists to the end of the info.
5688 (setcdr (nthcdr 2 info) (list newmarked))))
5690 ;; Cut off the end of the info if there's nothing else there.
5694 (when (nthcdr (decf i) info)
5695 (setcdr (nthcdr i info) nil)))))))
5697 (defun gnus-set-mode-line (where)
5698 "Set the mode line of the article or summary buffers.
5699 If WHERE is `summary', the summary mode line format will be used."
5700 ;; Is this mode line one we keep updated?
5701 (when (and (memq where gnus-updated-mode-lines)
5703 (intern (format "gnus-%s-mode-line-format-spec" where))))
5706 ;; We evaluate this in the summary buffer since these
5707 ;; variables are buffer-local to that buffer.
5708 (set-buffer gnus-summary-buffer)
5709 ;; We bind all these variables that are used in the `eval' form
5711 (let* ((mformat (symbol-value
5713 (format "gnus-%s-mode-line-format-spec" where))))
5714 (gnus-tmp-group-name (gnus-group-decoded-name
5715 gnus-newsgroup-name))
5716 (gnus-tmp-article-number (or gnus-current-article 0))
5717 (gnus-tmp-unread gnus-newsgroup-unreads)
5718 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5719 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5720 (gnus-tmp-unread-and-unselected
5721 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5722 (zerop gnus-tmp-unselected))
5724 ((zerop gnus-tmp-unselected)
5725 (format "{%d more}" gnus-tmp-unread-and-unticked))
5726 (t (format "{%d(+%d) more}"
5727 gnus-tmp-unread-and-unticked
5728 gnus-tmp-unselected))))
5730 (if (and gnus-current-headers
5731 (vectorp gnus-current-headers))
5732 (gnus-mode-string-quote
5733 (mail-header-subject gnus-current-headers))
5735 bufname-length max-len
5736 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5737 (setq mode-string (eval mformat))
5738 (setq bufname-length (if (string-match "%b" mode-string)
5741 (if (eq where 'summary)
5743 (get-buffer gnus-article-buffer))))
5746 (setq max-len (max 4 (if gnus-mode-non-string-length
5748 gnus-mode-non-string-length
5750 (length mode-string))))
5751 ;; We might have to chop a bit of the string off...
5752 (when (> (length mode-string) max-len)
5754 (concat (truncate-string-to-width mode-string (- max-len 3))
5756 ;; Pad the mode string a bit.
5757 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5758 ;; Update the mode line.
5759 (setq mode-line-buffer-identification
5760 (gnus-mode-line-buffer-identification (list mode-string)))
5761 (set-buffer-modified-p t))))
5763 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5764 "Go through the HEADERS list and add all Xrefs to a hash table.
5765 The resulting hash table is returned, or nil if no Xrefs were found."
5766 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5767 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5768 (xref-hashtb (gnus-make-hashtable))
5769 start group entry number xrefs header)
5771 (setq header (pop headers))
5772 (when (and (setq xrefs (mail-header-xref header))
5773 (not (memq (setq number (mail-header-number header))
5776 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5777 (setq start (match-end 0))
5778 (setq group (if prefix
5779 (concat prefix (substring xrefs (match-beginning 1)
5781 (substring xrefs (match-beginning 1) (match-end 1))))
5783 (string-to-number (substring xrefs (match-beginning 2)
5785 (if (setq entry (gnus-gethash group xref-hashtb))
5786 (setcdr entry (cons number (cdr entry)))
5787 (gnus-sethash group (cons number nil) xref-hashtb)))))
5788 (and start xref-hashtb)))
5790 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5791 "Look through all the headers and mark the Xrefs as read."
5792 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5793 name entry info xref-hashtb idlist method nth4)
5795 (set-buffer gnus-group-buffer)
5796 (when (setq xref-hashtb
5797 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5800 (unless (string= from-newsgroup (setq name (symbol-name group)))
5801 (setq idlist (symbol-value group))
5802 ;; Dead groups are not updated.
5804 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5806 (when (stringp (setq nth4 (gnus-info-method info)))
5807 (setq nth4 (gnus-server-to-method nth4))))
5808 ;; Only do the xrefs if the group has the same
5809 ;; select method as the group we have just read.
5810 (or (gnus-methods-equal-p
5811 nth4 (gnus-find-method-for-group from-newsgroup))
5813 (equal nth4 (setq method (gnus-find-method-for-group
5815 (and (equal (car nth4) (car method))
5816 (equal (nth 1 nth4) (nth 1 method))))
5817 gnus-use-cross-reference
5818 (or (not (eq gnus-use-cross-reference t))
5820 ;; Only do cross-references on subscribed
5821 ;; groups, if that is what is wanted.
5822 (<= (gnus-info-level info) gnus-level-subscribed))
5823 (gnus-group-make-articles-read name idlist))))
5826 (defun gnus-compute-read-articles (group articles)
5827 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5828 (info (nth 2 entry))
5829 (active (gnus-active group))
5832 ;; First peel off all invalid article numbers.
5834 (let ((ids articles)
5836 (while (setq id (pop ids))
5837 (when (and first (> id (cdr active)))
5838 ;; We'll end up in this situation in one particular
5839 ;; obscure situation. If you re-scan a group and get
5840 ;; a new article that is cross-posted to a different
5841 ;; group that has not been re-scanned, you might get
5842 ;; crossposted article that has a higher number than
5843 ;; Gnus believes possible. So we re-activate this
5844 ;; group as well. This might mean doing the
5845 ;; crossposting thingy will *increase* the number
5846 ;; of articles in some groups. Tsk, tsk.
5847 (setq active (or (gnus-activate-group group) active)))
5848 (when (or (> id (cdr active))
5849 (< id (car active)))
5850 (setq articles (delq id articles))))))
5851 ;; If the read list is nil, we init it.
5853 (null (gnus-info-read info))
5855 (setq ninfo (cons 1 (1- (car active))))
5856 (setq ninfo (gnus-info-read info)))
5857 ;; Then we add the read articles to the range.
5859 ninfo (setq articles (sort articles '<))))))
5861 (defun gnus-group-make-articles-read (group articles)
5862 "Update the info of GROUP to say that ARTICLES are read."
5864 (entry (gnus-gethash group gnus-newsrc-hashtb))
5865 (info (nth 2 entry))
5866 (active (gnus-active group))
5869 (setq range (gnus-compute-read-articles group articles))
5871 (set-buffer gnus-group-buffer)
5874 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5875 (gnus-info-set-read ',info ',(gnus-info-read info))
5876 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5877 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5878 (gnus-group-update-group ,group t))))
5879 ;; Add the read articles to the range.
5880 (gnus-info-set-read info range)
5881 (gnus-request-set-mark group (list (list range 'add '(read))))
5882 ;; Then we have to re-compute how many unread
5883 ;; articles there are in this group.
5887 (setq num (- (1+ (cdr active)) (car active))))
5888 ((not (listp (cdr range)))
5889 (setq num (- (cdr active) (- (1+ (cdr range))
5893 (if (numberp (car range))
5895 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5896 (setq range (cdr range)))
5897 (setq num (- (cdr active) num))))
5898 ;; Update the number of unread articles.
5900 ;; Update the group buffer.
5901 (unless (gnus-ephemeral-group-p group)
5902 (gnus-group-update-group group t))))))
5904 (defvar gnus-newsgroup-none-id 0)
5906 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5907 (let ((cur nntp-server-buffer)
5910 (save-excursion (set-buffer gnus-summary-buffer)
5911 gnus-newsgroup-dependencies)))
5913 (mail-parse-charset gnus-newsgroup-charset)
5914 (mail-parse-ignored-charsets
5915 (save-excursion (condition-case nil
5916 (set-buffer gnus-summary-buffer)
5918 gnus-newsgroup-ignored-charsets)))
5920 (set-buffer nntp-server-buffer)
5921 ;; Translate all TAB characters into SPACE characters.
5922 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5923 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5924 (ietf-drums-unfold-fws)
5925 (gnus-run-hooks 'gnus-parse-headers-hook)
5926 (let ((case-fold-search t)
5927 in-reply-to header p lines chars)
5928 (goto-char (point-min))
5929 ;; Search to the beginning of the next header. Error messages
5930 ;; do not begin with 2 or 3.
5931 (while (re-search-forward "^[23][0-9]+ " nil t)
5934 ;; This implementation of this function, with nine
5935 ;; search-forwards instead of the one re-search-forward and
5936 ;; a case (which basically was the old function) is actually
5937 ;; about twice as fast, even though it looks messier. You
5938 ;; can't have everything, I guess. Speed and elegance
5939 ;; doesn't always go hand in hand.
5948 (narrow-to-region (point)
5949 (or (and (search-forward "\n.\n" nil t)
5955 (if (search-forward "\nsubject:" nil t)
5956 (funcall gnus-decode-encoded-word-function
5957 (nnheader-header-value))
5962 (if (search-forward "\nfrom:" nil t)
5963 (funcall gnus-decode-encoded-word-function
5964 (nnheader-header-value))
5969 (if (search-forward "\ndate:" nil t)
5970 (nnheader-header-value) ""))
5974 (setq id (if (re-search-forward
5975 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5976 ;; We do it this way to make sure the Message-ID
5977 ;; is (somewhat) syntactically valid.
5978 (buffer-substring (match-beginning 1)
5980 ;; If there was no message-id, we just fake one
5981 ;; to make subsequent routines simpler.
5982 (nnheader-generate-fake-message-id))))
5986 (if (search-forward "\nreferences:" nil t)
5990 (nnheader-header-value)
5995 (search-backward ">" end t)
5998 (search-backward "<" end t)
6000 ;; Get the references from the in-reply-to header if there
6001 ;; were no references and the in-reply-to header looks
6003 (if (and (search-forward "\nin-reply-to:" nil t)
6004 (setq in-reply-to (nnheader-header-value))
6005 (string-match "<[^>]+>" in-reply-to))
6007 (setq ref (substring in-reply-to (match-beginning 0)
6009 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6010 (setq ref2 (substring in-reply-to (match-beginning 0)
6012 (when (> (length ref2) (length ref))
6019 (if (search-forward "\nchars: " nil t)
6020 (if (numberp (setq chars (ignore-errors (read cur))))
6026 (if (search-forward "\nlines: " nil t)
6027 (if (numberp (setq lines (ignore-errors (read cur))))
6033 (and (search-forward "\nxref:" nil t)
6034 (nnheader-header-value)))
6036 (when gnus-extra-headers
6037 (let ((extra gnus-extra-headers)
6041 (when (search-forward
6042 (concat "\n" (symbol-name (car extra)) ":") nil t)
6043 (push (cons (car extra) (nnheader-header-value))
6047 (when (equal id ref)
6050 (when gnus-alter-header-function
6051 (funcall gnus-alter-header-function header)
6052 (setq id (mail-header-id header)
6053 ref (gnus-parent-id (mail-header-references header))))
6056 (gnus-dependencies-add-header
6057 header dependencies force-new))
6058 (push header headers))
6059 (goto-char (point-max))
6061 (nreverse headers)))))
6063 ;; Goes through the xover lines and returns a list of vectors
6064 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6065 force-new dependencies
6066 group also-fetch-heads)
6067 "Parse the news overview data in the server buffer.
6068 Return a list of headers that match SEQUENCE (see
6069 `nntp-retrieve-headers')."
6070 ;; Get the Xref when the users reads the articles since most/some
6071 ;; NNTP servers do not include Xrefs when using XOVER.
6072 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6073 (let ((mail-parse-charset gnus-newsgroup-charset)
6074 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6075 (cur nntp-server-buffer)
6076 (dependencies (or dependencies gnus-newsgroup-dependencies))
6078 ((eq gnus-read-all-available-headers t)
6080 ((and (stringp gnus-read-all-available-headers)
6082 (string-match gnus-read-all-available-headers group))
6085 number headers header)
6087 (set-buffer nntp-server-buffer)
6088 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6089 ;; Allow the user to mangle the headers before parsing them.
6090 (gnus-run-hooks 'gnus-parse-headers-hook)
6091 (goto-char (point-min))
6092 (gnus-parse-without-error
6093 (while (and (or sequence allp)
6095 (setq number (read cur))
6097 (while (and sequence
6098 (< (car sequence) number))
6099 (setq sequence (cdr sequence))))
6102 (eq number (car sequence))))
6104 (setq sequence (cdr sequence))
6105 (setq header (inline
6106 (gnus-nov-parse-line
6107 number dependencies force-new)))))
6108 (push header headers))
6110 ;; A common bug in inn is that if you have posted an article and
6111 ;; then retrieves the active file, it will answer correctly --
6112 ;; the new article is included. However, a NOV entry for the
6113 ;; article may not have been generated yet, so this may fail.
6114 ;; We work around this problem by retrieving the last few
6115 ;; headers using HEAD.
6116 (if (or (not also-fetch-heads)
6118 ;; We (probably) got all the headers.
6120 (let ((gnus-nov-is-evil t))
6123 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6124 (gnus-get-newsgroup-headers))))))))
6126 (defun gnus-article-get-xrefs ()
6127 "Fill in the Xref value in `gnus-current-headers', if necessary.
6128 This is meant to be called in `gnus-article-internal-prepare-hook'."
6129 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6130 gnus-current-headers)))
6131 (or (not gnus-use-cross-reference)
6133 (and (mail-header-xref headers)
6134 (not (string= (mail-header-xref headers) "")))
6135 (let ((case-fold-search t)
6138 (nnheader-narrow-to-headers)
6139 (goto-char (point-min))
6140 (when (or (and (not (eobp))
6141 (eq (downcase (char-after)) ?x)
6142 (looking-at "Xref:"))
6143 (search-forward "\nXref:" nil t))
6144 (goto-char (1+ (match-end 0)))
6145 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6146 (mail-header-set-xref headers xref)))))))
6148 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6149 "Find article ID and insert the summary line for that article.
6150 OLD-HEADER can either be a header or a line number to insert
6151 the subject line on."
6152 (let* ((line (and (numberp old-header) old-header))
6153 (old-header (and (vectorp old-header) old-header))
6154 (header (cond ((and old-header use-old-header)
6157 (gnus-number-to-header id))
6158 (gnus-number-to-header id))
6160 (gnus-read-header id))))
6161 (number (and (numberp id) id))
6164 ;; Rebuild the thread that this article is part of and go to the
6165 ;; article we have fetched.
6166 (when (and (not gnus-show-threads)
6169 (setq d (gnus-data-find (mail-header-number old-header))))
6170 (goto-char (gnus-data-pos d))
6173 (- (gnus-point-at-bol)
6175 (1+ (gnus-point-at-eol))
6176 (gnus-delete-line))))))
6177 ;; Remove list identifiers from subject.
6178 (when gnus-list-identifiers
6179 (let ((gnus-newsgroup-headers (list header)))
6180 (gnus-summary-remove-list-identifiers)))
6182 (mail-header-set-number header (mail-header-number old-header)))
6183 (setq gnus-newsgroup-sparse
6184 (delq (setq number (mail-header-number header))
6185 gnus-newsgroup-sparse))
6186 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6187 (push number gnus-newsgroup-limit)
6188 (gnus-rebuild-thread (mail-header-id header) line)
6189 (gnus-summary-goto-subject number nil t))
6190 (when (and (numberp number)
6192 ;; We have to update the boundaries even if we can't fetch the
6193 ;; article if ID is a number -- so that the next `P' or `N'
6194 ;; command will fetch the previous (or next) article even
6195 ;; if the one we tried to fetch this time has been canceled.
6196 (when (> number gnus-newsgroup-end)
6197 (setq gnus-newsgroup-end number))
6198 (when (< number gnus-newsgroup-begin)
6199 (setq gnus-newsgroup-begin number))
6200 (setq gnus-newsgroup-unselected
6201 (delq number gnus-newsgroup-unselected)))
6202 ;; Report back a success?
6203 (and header (mail-header-number header))))
6205 ;;; Process/prefix in the summary buffer
6207 (defun gnus-summary-work-articles (n)
6208 "Return a list of articles to be worked upon.
6209 The prefix argument, the list of process marked articles, and the
6210 current article will be taken into consideration."
6212 (set-buffer gnus-summary-buffer)
6215 ;; A numerical prefix has been given.
6216 (setq n (prefix-numeric-value n))
6217 (let ((backward (< n 0))
6218 (n (abs (prefix-numeric-value n)))
6223 (push (setq article (gnus-summary-article-number))
6226 (gnus-summary-find-prev nil article)
6227 (gnus-summary-find-next nil article)))
6229 (nreverse articles)))
6230 ((and (gnus-region-active-p) (mark))
6231 (message "region active")
6232 ;; Work on the region between point and mark.
6233 (let ((max (max (point) (mark)))
6236 (goto-char (min (point) (mark)))
6239 (push (setq article (gnus-summary-article-number)) articles)
6240 (gnus-summary-find-next nil article)
6242 (nreverse articles))))
6243 (gnus-newsgroup-processable
6244 ;; There are process-marked articles present.
6245 ;; Save current state.
6246 (gnus-summary-save-process-mark)
6248 (reverse gnus-newsgroup-processable))
6250 ;; Just return the current article.
6251 (list (gnus-summary-article-number))))))
6253 (defmacro gnus-summary-iterate (arg &rest forms)
6254 "Iterate over the process/prefixed articles and do FORMS.
6255 ARG is the interactive prefix given to the command. FORMS will be
6256 executed with point over the summary line of the articles."
6257 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6258 `(let ((,articles (gnus-summary-work-articles ,arg)))
6260 (gnus-summary-goto-subject (car ,articles))
6264 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6265 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6267 (defun gnus-summary-save-process-mark ()
6268 "Push the current set of process marked articles on the stack."
6270 (push (copy-sequence gnus-newsgroup-processable)
6271 gnus-newsgroup-process-stack))
6273 (defun gnus-summary-kill-process-mark ()
6274 "Push the current set of process marked articles on the stack and unmark."
6276 (gnus-summary-save-process-mark)
6277 (gnus-summary-unmark-all-processable))
6279 (defun gnus-summary-yank-process-mark ()
6280 "Pop the last process mark state off the stack and restore it."
6282 (unless gnus-newsgroup-process-stack
6283 (error "Empty mark stack"))
6284 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6286 (defun gnus-summary-process-mark-set (set)
6287 "Make SET into the current process marked articles."
6288 (gnus-summary-unmark-all-processable)
6290 (gnus-summary-set-process-mark (pop set))))
6292 ;;; Searching and stuff
6294 (defun gnus-summary-search-group (&optional backward use-level)
6295 "Search for next unread newsgroup.
6296 If optional argument BACKWARD is non-nil, search backward instead."
6298 (set-buffer gnus-group-buffer)
6299 (when (gnus-group-search-forward
6300 backward nil (if use-level (gnus-group-group-level) nil))
6301 (gnus-group-group-name))))
6303 (defun gnus-summary-best-group (&optional exclude-group)
6304 "Find the name of the best unread group.
6305 If EXCLUDE-GROUP, do not go to this group."
6307 (set-buffer gnus-group-buffer)
6309 (gnus-group-best-unread-group exclude-group))))
6311 (defun gnus-summary-find-next (&optional unread article backward)
6313 (gnus-summary-find-prev unread article)
6314 (let* ((dummy (gnus-summary-article-intangible-p))
6315 (article (or article (gnus-summary-article-number)))
6316 (data (gnus-data-find-list article))
6318 (when (and (not dummy)
6319 (or (not gnus-summary-check-current)
6321 (not (gnus-data-unread-p (car data)))))
6322 (setq data (cdr data)))
6327 (unless (memq (gnus-data-number (car data))
6329 ((eq gnus-auto-goto-ignores
6330 'always-undownloaded)
6331 gnus-newsgroup-undownloaded)
6334 ((eq gnus-auto-goto-ignores
6336 gnus-newsgroup-unfetched)
6337 ((eq gnus-auto-goto-ignores
6339 gnus-newsgroup-undownloaded)))
6340 (when (gnus-data-unread-p (car data))
6341 (setq result (car data)
6343 (setq data (cdr data)))
6346 (goto-char (gnus-data-pos result))
6347 (gnus-data-number result)))))
6349 (defun gnus-summary-find-prev (&optional unread article)
6350 (let* ((eobp (eobp))
6351 (article (or article (gnus-summary-article-number)))
6352 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6354 (when (and (not eobp)
6355 (or (not gnus-summary-check-current)
6357 (not (gnus-data-unread-p (car data)))))
6358 (setq data (cdr data)))
6363 (unless (memq (gnus-data-number (car data))
6365 ((eq gnus-auto-goto-ignores
6366 'always-undownloaded)
6367 gnus-newsgroup-undownloaded)
6370 ((eq gnus-auto-goto-ignores
6372 gnus-newsgroup-unfetched)
6373 ((eq gnus-auto-goto-ignores
6375 gnus-newsgroup-undownloaded)))
6376 (when (gnus-data-unread-p (car data))
6377 (setq result (car data)
6379 (setq data (cdr data)))
6382 (goto-char (gnus-data-pos result))
6383 (gnus-data-number result))))
6385 (defun gnus-summary-find-subject (subject &optional unread backward article)
6386 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6387 (article (or article (gnus-summary-article-number)))
6388 (articles (gnus-data-list backward))
6389 (arts (gnus-data-find-list article articles))
6391 (when (or (not gnus-summary-check-current)
6393 (not (gnus-data-unread-p (car arts))))
6394 (setq arts (cdr arts)))
6396 (and (or (not unread)
6397 (gnus-data-unread-p (car arts)))
6398 (vectorp (gnus-data-header (car arts)))
6400 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6401 (setq result (car arts)
6403 (setq arts (cdr arts)))
6405 (goto-char (gnus-data-pos result))
6406 (gnus-data-number result))))
6408 (defun gnus-summary-search-forward (&optional unread subject backward)
6409 "Search forward for an article.
6410 If UNREAD, look for unread articles. If SUBJECT, look for
6411 articles with that subject. If BACKWARD, search backward instead."
6412 (cond (subject (gnus-summary-find-subject subject unread backward))
6413 (backward (gnus-summary-find-prev unread))
6414 (t (gnus-summary-find-next unread))))
6416 (defun gnus-recenter (&optional n)
6417 "Center point in window and redisplay frame.
6418 Also do horizontal recentering."
6420 (when (and gnus-auto-center-summary
6421 (not (eq gnus-auto-center-summary 'vertical)))
6422 (gnus-horizontal-recenter))
6425 (defun gnus-summary-recenter ()
6426 "Center point in the summary window.
6427 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6428 displayed, no centering will be performed."
6429 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6430 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6432 ;; The user has to want it.
6433 (when gnus-auto-center-summary
6434 (let* ((top (cond ((< (window-height) 4) 0)
6435 ((< (window-height) 7) 1)
6436 (t (if (numberp gnus-auto-center-summary)
6437 gnus-auto-center-summary
6439 (height (1- (window-height)))
6440 (bottom (save-excursion (goto-char (point-max))
6441 (forward-line (- height))
6443 (window (get-buffer-window (current-buffer))))
6444 (when (get-buffer-window gnus-article-buffer)
6445 ;; Only do recentering when the article buffer is displayed,
6446 ;; Set the window start to either `bottom', which is the biggest
6447 ;; possible valid number, or the second line from the top,
6448 ;; whichever is the least.
6449 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6450 (if (> bottom top-pos)
6451 ;; Keep the second line from the top visible
6452 (set-window-start window top-pos t)
6453 ;; Try to keep the bottom line visible; if it's partially
6454 ;; obscured, either scroll one more line to make it fully
6455 ;; visible, or revert to using TOP-POS.
6457 (goto-char (point-max))
6459 (let ((last-line-start (point)))
6461 (set-window-start window (point) t)
6462 (when (not (pos-visible-in-window-p last-line-start window))
6464 (set-window-start window (min (point) top-pos) t)))))))
6465 ;; Do horizontal recentering while we're at it.
6466 (when (and (get-buffer-window (current-buffer) t)
6467 (not (eq gnus-auto-center-summary 'vertical)))
6468 (let ((selected (selected-window)))
6469 (select-window (get-buffer-window (current-buffer) t))
6470 (gnus-summary-position-point)
6471 (gnus-horizontal-recenter)
6472 (select-window selected))))))
6474 (defun gnus-summary-jump-to-group (newsgroup)
6475 "Move point to NEWSGROUP in group mode buffer."
6476 ;; Keep update point of group mode buffer if visible.
6477 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6478 (save-window-excursion
6479 ;; Take care of tree window mode.
6480 (when (get-buffer-window gnus-group-buffer)
6481 (pop-to-buffer gnus-group-buffer))
6482 (gnus-group-jump-to-group newsgroup))
6484 ;; Take care of tree window mode.
6485 (if (get-buffer-window gnus-group-buffer)
6486 (pop-to-buffer gnus-group-buffer)
6487 (set-buffer gnus-group-buffer))
6488 (gnus-group-jump-to-group newsgroup))))
6490 ;; This function returns a list of article numbers based on the
6491 ;; difference between the ranges of read articles in this group and
6492 ;; the range of active articles.
6493 (defun gnus-list-of-unread-articles (group)
6494 (let* ((read (gnus-info-read (gnus-get-info group)))
6495 (active (or (gnus-active group) (gnus-activate-group group)))
6498 ;; If none are read, then all are unread.
6500 (setq first (car active))
6501 ;; If the range of read articles is a single range, then the
6502 ;; first unread article is the article after the last read
6503 ;; article. Sounds logical, doesn't it?
6504 (if (and (not (listp (cdr read)))
6505 (or (< (car read) (car active))
6506 (progn (setq read (list read))
6508 (setq first (max (car active) (1+ (cdr read))))
6509 ;; `read' is a list of ranges.
6510 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6513 (setq first (car active)))
6516 (while (< first nlast)
6517 (setq unread (cons first unread)
6519 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6520 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6521 (setq read (cdr read)))))
6522 ;; And add the last unread articles.
6523 (while (<= first last)
6524 (setq unread (cons first unread)
6526 ;; Return the list of unread articles.
6527 (delq 0 (nreverse unread))))
6529 (defun gnus-list-of-read-articles (group)
6530 "Return a list of unread, unticked and non-dormant articles."
6531 (let* ((info (gnus-get-info group))
6532 (marked (gnus-info-marks info))
6533 (active (gnus-active group)))
6535 (gnus-list-range-difference
6536 (gnus-list-range-difference
6537 (gnus-sorted-complement
6538 (gnus-uncompress-range active)
6539 (gnus-list-of-unread-articles group))
6540 (cdr (assq 'dormant marked)))
6541 (cdr (assq 'tick marked))))))
6543 ;; This function returns a sequence of article numbers based on the
6544 ;; difference between the ranges of read articles in this group and
6545 ;; the range of active articles.
6546 (defun gnus-sequence-of-unread-articles (group)
6547 (let* ((read (gnus-info-read (gnus-get-info group)))
6548 (active (or (gnus-active group) (gnus-activate-group group)))
6551 ;; If none are read, then all are unread.
6553 (setq first (car active))
6554 ;; If the range of read articles is a single range, then the
6555 ;; first unread article is the article after the last read
6556 ;; article. Sounds logical, doesn't it?
6557 (if (and (not (listp (cdr read)))
6558 (or (< (car read) (car active))
6559 (progn (setq read (list read))
6561 (setq first (max (car active) (1+ (cdr read))))
6562 ;; `read' is a list of ranges.
6563 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6566 (setq first (car active)))
6569 (push (cons first nlast) unread))
6570 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6571 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6572 (setq read (cdr read)))))
6573 ;; And add the last unread articles.
6574 (cond ((not (and first last))
6577 (push (cons first last) unread))
6579 (push first unread)))
6580 ;; Return the sequence of unread articles.
6581 (delq 0 (nreverse unread))))
6583 ;; Various summary commands
6585 (defun gnus-summary-select-article-buffer ()
6586 "Reconfigure windows to show article buffer."
6588 (if (not (gnus-buffer-live-p gnus-article-buffer))
6589 (error "There is no article buffer for this summary buffer")
6590 (gnus-configure-windows 'article)
6591 (select-window (get-buffer-window gnus-article-buffer))))
6593 (defun gnus-summary-universal-argument (arg)
6594 "Perform any operation on all articles that are process/prefixed."
6596 (let ((articles (gnus-summary-work-articles arg))
6603 (substitute-command-keys
6604 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6606 (gnus-error 1 "Undefined key")
6609 (gnus-summary-goto-subject (setq article (pop articles)))
6610 (let (gnus-newsgroup-processable)
6611 (command-execute func))
6612 (gnus-summary-remove-process-mark article)))))
6613 (gnus-summary-position-point))
6615 (defun gnus-summary-toggle-truncation (&optional arg)
6616 "Toggle truncation of summary lines.
6617 With ARG, turn line truncation on if ARG is positive."
6619 (setq truncate-lines
6620 (if (null arg) (not truncate-lines)
6621 (> (prefix-numeric-value arg) 0)))
6624 (defun gnus-summary-find-for-reselect ()
6625 "Return the number of an article to stay on across a reselect.
6626 The current article is considered, then following articles, then previous
6627 articles. An article is sought which is not cancelled and isn't a temporary
6628 insertion from another group. If there's no such then return a dummy 0."
6630 (dolist (rev '(nil t))
6631 (unless found ; don't demand the reverse list if we don't need it
6632 (let ((data (gnus-data-find-list
6633 (gnus-summary-article-number) (gnus-data-list rev))))
6634 (while (and data (not found))
6635 (if (and (< 0 (gnus-data-number (car data)))
6636 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6637 (setq found (gnus-data-number (car data))))
6638 (setq data (cdr data))))))
6641 (defun gnus-summary-reselect-current-group (&optional all rescan)
6642 "Exit and then reselect the current newsgroup.
6643 The prefix argument ALL means to select all articles."
6645 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6646 (error "Ephemeral groups can't be reselected"))
6647 (let ((current-subject (gnus-summary-find-for-reselect))
6648 (group gnus-newsgroup-name))
6649 (setq gnus-newsgroup-begin nil)
6650 (gnus-summary-exit nil 'leave-hidden)
6651 ;; We have to adjust the point of group mode buffer because
6652 ;; point was moved to the next unread newsgroup by exiting.
6653 (gnus-summary-jump-to-group group)
6656 (gnus-group-get-new-news-this-group 1)))
6657 (gnus-group-read-group all t)
6658 (gnus-summary-goto-subject current-subject nil t)))
6660 (defun gnus-summary-rescan-group (&optional all)
6661 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6663 (gnus-summary-reselect-current-group all t))
6665 (defun gnus-summary-update-info (&optional non-destructive)
6667 (let ((group gnus-newsgroup-name))
6669 (when gnus-newsgroup-kill-headers
6670 (setq gnus-newsgroup-killed
6671 (gnus-compress-sequence
6673 (gnus-list-range-intersection
6674 gnus-newsgroup-unselected gnus-newsgroup-killed)
6675 gnus-newsgroup-unreads)
6677 (unless (listp (cdr gnus-newsgroup-killed))
6678 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6679 (let ((headers gnus-newsgroup-headers))
6680 ;; Set the new ranges of read articles.
6682 (set-buffer gnus-group-buffer)
6683 (gnus-undo-force-boundary))
6684 (gnus-update-read-articles
6685 group (gnus-sorted-union
6686 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6687 ;; Set the current article marks.
6688 (let ((gnus-newsgroup-scored
6689 (if (and (not gnus-save-score)
6690 (not non-destructive))
6692 gnus-newsgroup-scored)))
6694 (gnus-update-marks)))
6695 ;; Do the cross-ref thing.
6696 (when gnus-use-cross-reference
6697 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6698 ;; Do not switch windows but change the buffer to work.
6699 (set-buffer gnus-group-buffer)
6700 (unless (gnus-ephemeral-group-p group)
6701 (gnus-group-update-group group)))))))
6703 (defun gnus-summary-save-newsrc (&optional force)
6704 "Save the current number of read/marked articles in the dribble buffer.
6705 The dribble buffer will then be saved.
6706 If FORCE (the prefix), also save the .newsrc file(s)."
6708 (gnus-summary-update-info t)
6710 (gnus-save-newsrc-file)
6711 (gnus-dribble-save)))
6713 (defun gnus-summary-exit (&optional temporary leave-hidden)
6714 "Exit reading current newsgroup, and then return to group selection mode.
6715 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6717 (gnus-set-global-variables)
6718 (when (gnus-buffer-live-p gnus-article-buffer)
6720 (set-buffer gnus-article-buffer)
6721 (mm-destroy-parts gnus-article-mime-handles)
6722 ;; Set it to nil for safety reason.
6723 (setq gnus-article-mime-handle-alist nil)
6724 (setq gnus-article-mime-handles nil)))
6725 (gnus-kill-save-kill-buffer)
6726 (gnus-async-halt-prefetch)
6727 (let* ((group gnus-newsgroup-name)
6728 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6729 (gnus-group-is-exiting-p t)
6732 (buf (current-buffer)))
6734 ;; Do adaptive scoring, and possibly save score files.
6735 (when gnus-newsgroup-adaptive
6736 (gnus-score-adaptive))
6737 (when gnus-use-scoring
6739 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6740 ;; If we have several article buffers, we kill them at exit.
6741 (unless gnus-single-article-buffer
6742 (gnus-kill-buffer gnus-original-article-buffer)
6743 (setq gnus-article-current nil))
6744 (when gnus-use-cache
6745 (gnus-cache-possibly-remove-articles)
6746 (gnus-cache-save-buffers))
6747 (gnus-async-prefetch-remove-group group)
6748 (when gnus-suppress-duplicates
6749 (gnus-dup-enter-articles))
6750 (when gnus-use-trees
6751 (gnus-tree-close group))
6752 (when gnus-use-cache
6753 (gnus-cache-write-active))
6754 ;; Remove entries for this group.
6755 (nnmail-purge-split-history (gnus-group-real-name group))
6756 ;; Make all changes in this group permanent.
6758 (gnus-run-hooks 'gnus-exit-group-hook)
6759 (gnus-summary-update-info))
6760 (gnus-close-group group)
6761 ;; Make sure where we were, and go to next newsgroup.
6762 (set-buffer gnus-group-buffer)
6764 (gnus-group-jump-to-group group))
6765 (gnus-run-hooks 'gnus-summary-exit-hook)
6766 (unless (or quit-config
6767 ;; If this group has disappeared from the summary
6768 ;; buffer, don't skip forwards.
6769 (not (string= group (gnus-group-group-name))))
6770 (gnus-group-next-unread-group 1))
6771 (setq group-point (point))
6774 ;; If we have several article buffers, we kill them at exit.
6775 (unless gnus-single-article-buffer
6776 (gnus-kill-buffer gnus-article-buffer)
6777 (gnus-kill-buffer gnus-original-article-buffer)
6778 (setq gnus-article-current nil))
6780 (if (not gnus-kill-summary-on-exit)
6782 (gnus-deaden-summary)
6784 ;; We set all buffer-local variables to nil. It is unclear why
6785 ;; this is needed, but if we don't, buffer-local variables are
6786 ;; not garbage-collected, it seems. This would the lead to en
6787 ;; ever-growing Emacs.
6788 (gnus-summary-clear-local-variables)
6789 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6790 (gnus-summary-clear-local-variables))
6791 (when (get-buffer gnus-article-buffer)
6792 (bury-buffer gnus-article-buffer))
6793 ;; We clear the global counterparts of the buffer-local
6794 ;; variables as well, just to be on the safe side.
6795 (set-buffer gnus-group-buffer)
6796 (gnus-summary-clear-local-variables)
6797 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6798 (gnus-summary-clear-local-variables))
6799 ;; Return to group mode buffer.
6800 (when (eq mode 'gnus-summary-mode)
6801 (gnus-kill-buffer buf)))
6802 (setq gnus-current-select-method gnus-select-method)
6803 (set-buffer gnus-group-buffer)
6805 (gnus-handle-ephemeral-exit quit-config)
6806 (goto-char group-point)
6807 ;; If gnus-group-buffer is already displayed, make sure we also move
6808 ;; the cursor in the window that displays it.
6809 (let ((win (get-buffer-window (current-buffer) 0)))
6810 (if win (set-window-point win (point))))
6811 (unless leave-hidden
6812 (gnus-configure-windows 'group 'force)))
6813 ;; Clear the current group name.
6815 (setq gnus-newsgroup-name nil)))))
6817 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6818 (defun gnus-summary-exit-no-update (&optional no-questions)
6819 "Quit reading current newsgroup without updating read article info."
6821 (let* ((group gnus-newsgroup-name)
6822 (gnus-group-is-exiting-p t)
6823 (gnus-group-is-exiting-without-update-p t)
6824 (quit-config (gnus-group-quit-config group)))
6825 (when (or no-questions
6827 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6828 (gnus-async-halt-prefetch)
6829 (run-hooks 'gnus-summary-prepare-exit-hook)
6830 (when (gnus-buffer-live-p gnus-article-buffer)
6832 (set-buffer gnus-article-buffer)
6833 (mm-destroy-parts gnus-article-mime-handles)
6834 ;; Set it to nil for safety reason.
6835 (setq gnus-article-mime-handle-alist nil)
6836 (setq gnus-article-mime-handles nil)))
6837 ;; If we have several article buffers, we kill them at exit.
6838 (unless gnus-single-article-buffer
6839 (gnus-kill-buffer gnus-article-buffer)
6840 (gnus-kill-buffer gnus-original-article-buffer)
6841 (setq gnus-article-current nil))
6842 (if (not gnus-kill-summary-on-exit)
6843 (gnus-deaden-summary)
6844 (gnus-close-group group)
6845 (gnus-summary-clear-local-variables)
6846 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6847 (gnus-summary-clear-local-variables))
6848 (set-buffer gnus-group-buffer)
6849 (gnus-summary-clear-local-variables)
6850 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6851 (gnus-summary-clear-local-variables))
6852 (gnus-kill-buffer gnus-summary-buffer))
6853 (unless gnus-single-article-buffer
6854 (setq gnus-article-current nil))
6855 (when gnus-use-trees
6856 (gnus-tree-close group))
6857 (gnus-async-prefetch-remove-group group)
6858 (when (get-buffer gnus-article-buffer)
6859 (bury-buffer gnus-article-buffer))
6860 ;; Return to the group buffer.
6861 (gnus-configure-windows 'group 'force)
6862 ;; Clear the current group name.
6863 (setq gnus-newsgroup-name nil)
6864 (unless (gnus-ephemeral-group-p group)
6865 (gnus-group-update-group group))
6866 (when (equal (gnus-group-group-name) group)
6867 (gnus-group-next-unread-group 1))
6869 (gnus-handle-ephemeral-exit quit-config)))))
6871 (defun gnus-handle-ephemeral-exit (quit-config)
6872 "Handle movement when leaving an ephemeral group.
6873 The state which existed when entering the ephemeral is reset."
6874 (if (not (buffer-name (car quit-config)))
6875 (gnus-configure-windows 'group 'force)
6876 (set-buffer (car quit-config))
6877 (cond ((eq major-mode 'gnus-summary-mode)
6878 (gnus-set-global-variables))
6879 ((eq major-mode 'gnus-article-mode)
6881 ;; The `gnus-summary-buffer' variable may point
6882 ;; to the old summary buffer when using a single
6884 (unless (gnus-buffer-live-p gnus-summary-buffer)
6885 (set-buffer gnus-group-buffer))
6886 (set-buffer gnus-summary-buffer)
6887 (gnus-set-global-variables))))
6888 (if (or (eq (cdr quit-config) 'article)
6889 (eq (cdr quit-config) 'pick))
6891 ;; The current article may be from the ephemeral group
6892 ;; thus it is best that we reload this article
6894 ;; If we're exiting from a large digest, this can be
6895 ;; extremely slow. So, it's better not to reload it. -- jh.
6896 ;;(gnus-summary-show-article)
6897 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6898 (gnus-configure-windows 'pick 'force)
6899 (gnus-configure-windows (cdr quit-config) 'force)))
6900 (gnus-configure-windows (cdr quit-config) 'force))
6901 (when (eq major-mode 'gnus-summary-mode)
6902 (gnus-summary-next-subject 1 nil t)
6903 (gnus-summary-recenter)
6904 (gnus-summary-position-point))))
6908 (defvar gnus-dead-summary-mode-map nil)
6910 (unless gnus-dead-summary-mode-map
6911 (setq gnus-dead-summary-mode-map (make-keymap))
6912 (suppress-keymap gnus-dead-summary-mode-map)
6913 (substitute-key-definition
6914 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6915 (dolist (key '("\C-d" "\r" "\177" [delete]))
6916 (define-key gnus-dead-summary-mode-map
6917 key 'gnus-summary-wake-up-the-dead))
6918 (dolist (key '("q" "Q"))
6919 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6921 (defvar gnus-dead-summary-mode nil
6922 "Minor mode for Gnus summary buffers.")
6924 (defun gnus-dead-summary-mode (&optional arg)
6925 "Minor mode for Gnus summary buffers."
6927 (when (eq major-mode 'gnus-summary-mode)
6928 (make-local-variable 'gnus-dead-summary-mode)
6929 (setq gnus-dead-summary-mode
6930 (if (null arg) (not gnus-dead-summary-mode)
6931 (> (prefix-numeric-value arg) 0)))
6932 (when gnus-dead-summary-mode
6933 (gnus-add-minor-mode
6934 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6936 (defun gnus-deaden-summary ()
6937 "Make the current summary buffer into a dead summary buffer."
6938 ;; Kill any previous dead summary buffer.
6939 (when (and gnus-dead-summary
6940 (buffer-name gnus-dead-summary))
6942 (set-buffer gnus-dead-summary)
6943 (when gnus-dead-summary-mode
6944 (kill-buffer (current-buffer)))))
6945 ;; Make this the current dead summary.
6946 (setq gnus-dead-summary (current-buffer))
6947 (gnus-dead-summary-mode 1)
6948 (let ((name (buffer-name)))
6949 (when (string-match "Summary" name)
6951 (concat (substring name 0 (match-beginning 0)) "Dead "
6952 (substring name (match-beginning 0)))
6956 (defun gnus-kill-or-deaden-summary (buffer)
6957 "Kill or deaden the summary BUFFER."
6959 (when (and (buffer-name buffer)
6960 (not gnus-single-article-buffer))
6963 (gnus-kill-buffer gnus-article-buffer)
6964 (gnus-kill-buffer gnus-original-article-buffer)))
6967 (gnus-kill-summary-on-exit
6968 (when (and gnus-use-trees
6969 (gnus-buffer-exists-p buffer))
6972 (gnus-tree-close gnus-newsgroup-name)))
6973 (gnus-kill-buffer buffer))
6974 ;; Deaden the buffer.
6975 ((gnus-buffer-exists-p buffer)
6978 (gnus-deaden-summary))))))
6980 (defun gnus-summary-wake-up-the-dead (&rest args)
6981 "Wake up the dead summary buffer."
6983 (gnus-dead-summary-mode -1)
6984 (let ((name (buffer-name)))
6985 (when (string-match "Dead " name)
6987 (concat (substring name 0 (match-beginning 0))
6988 (substring name (match-end 0)))
6990 (gnus-message 3 "This dead summary is now alive again"))
6992 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6993 (defun gnus-summary-fetch-faq (&optional faq-dir)
6994 "Fetch the FAQ for the current group.
6995 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6999 (when current-prefix-arg
7001 "FAQ dir: " (and (listp gnus-group-faq-directory)
7002 (mapcar (lambda (file) (list file))
7003 gnus-group-faq-directory))))))
7004 (let (gnus-faq-buffer)
7005 (when (setq gnus-faq-buffer
7006 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7007 (gnus-configure-windows 'summary-faq))))
7009 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7010 (defun gnus-summary-describe-group (&optional force)
7011 "Describe the current newsgroup."
7013 (gnus-group-describe-group force gnus-newsgroup-name))
7015 (defun gnus-summary-describe-briefly ()
7016 "Describe summary mode commands briefly."
7018 (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")))
7020 ;; Walking around group mode buffer from summary mode.
7022 (defun gnus-summary-next-group (&optional no-article target-group backward)
7023 "Exit current newsgroup and then select next unread newsgroup.
7024 If prefix argument NO-ARTICLE is non-nil, no article is selected
7025 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7026 previous group instead."
7028 ;; Stop pre-fetching.
7029 (gnus-async-halt-prefetch)
7030 (let ((current-group gnus-newsgroup-name)
7031 (current-buffer (current-buffer))
7033 ;; First we semi-exit this group to update Xrefs and all variables.
7034 ;; We can't do a real exit, because the window conf must remain
7035 ;; the same in case the user is prompted for info, and we don't
7036 ;; want the window conf to change before that...
7037 (gnus-summary-exit t)
7038 (while (not entered)
7039 ;; Then we find what group we are supposed to enter.
7040 (set-buffer gnus-group-buffer)
7041 (gnus-group-jump-to-group current-group)
7044 (if (eq gnus-keep-same-level 'best)
7045 (gnus-summary-best-group gnus-newsgroup-name)
7046 (gnus-summary-search-group backward gnus-keep-same-level))))
7047 (if (not target-group)
7048 ;; There are no further groups, so we return to the group
7051 (gnus-message 5 "Returning to the group buffer")
7053 (when (gnus-buffer-live-p current-buffer)
7054 (set-buffer current-buffer)
7055 (gnus-summary-exit))
7056 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7057 ;; We try to enter the target group.
7058 (gnus-group-jump-to-group target-group)
7059 (let ((unreads (gnus-group-group-unread)))
7060 (if (and (or (eq t unreads)
7061 (and unreads (not (zerop unreads))))
7062 (gnus-summary-read-group
7063 target-group nil no-article
7064 (and (buffer-name current-buffer) current-buffer)
7067 (setq current-group target-group
7068 target-group nil)))))))
7070 (defun gnus-summary-prev-group (&optional no-article)
7071 "Exit current newsgroup and then select previous unread newsgroup.
7072 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7074 (gnus-summary-next-group no-article nil t))
7076 ;; Walking around summary lines.
7078 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7079 "Go to the first subject satisfying any non-nil constraint.
7080 If UNREAD is non-nil, the article should be unread.
7081 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7082 If UNSEEN is non-nil, the article should be unseen.
7083 Returns the article selected or nil if there are no matching articles."
7087 ((null gnus-newsgroup-data)
7088 (gnus-message 3 "No articles in the group")
7090 ;; Pick the first article.
7091 ((not (or unread undownloaded unseen))
7092 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7093 (gnus-data-number (car gnus-newsgroup-data)))
7094 ;; Find the first unread article.
7096 (let ((data gnus-newsgroup-data))
7098 (let ((num (gnus-data-number (car data))))
7099 (or (memq num gnus-newsgroup-unfetched)
7100 (not (or (and unread
7101 (memq num gnus-newsgroup-unreads))
7103 (memq num gnus-newsgroup-undownloaded))
7105 (memq num gnus-newsgroup-unseen)))))))
7106 (setq data (cdr data)))
7110 (goto-char (gnus-data-pos (car data)))
7111 (gnus-data-number (car data)))
7112 (gnus-message 3 "No more%s articles"
7113 (let* ((r (when unread " unread"))
7114 (d (when undownloaded " undownloaded"))
7115 (s (when unseen " unseen"))
7116 (l (delq nil (list r d s))))
7117 (cond ((= 3 (length l))
7118 (concat r "," d ", or" s))
7120 (concat (car l) ", or" (cadr l)))
7127 (gnus-summary-position-point))))))
7129 (defun gnus-summary-next-subject (n &optional unread dont-display)
7130 "Go to next N'th summary line.
7131 If N is negative, go to the previous N'th subject line.
7132 If UNREAD is non-nil, only unread articles are selected.
7133 The difference between N and the actual number of steps taken is
7136 (let ((backward (< n 0))
7140 (gnus-summary-find-prev unread)
7141 (gnus-summary-find-next unread)))
7142 (unless (zerop (setq n (1- n)))
7143 (gnus-summary-show-thread)))
7145 (gnus-message 7 "No more%s articles"
7146 (if unread " unread" "")))
7147 (unless dont-display
7148 (gnus-summary-recenter)
7149 (gnus-summary-position-point))
7152 (defun gnus-summary-next-unread-subject (n)
7153 "Go to next N'th unread summary line."
7155 (gnus-summary-next-subject n t))
7157 (defun gnus-summary-prev-subject (n &optional unread)
7158 "Go to previous N'th summary line.
7159 If optional argument UNREAD is non-nil, only unread article is selected."
7161 (gnus-summary-next-subject (- n) unread))
7163 (defun gnus-summary-prev-unread-subject (n)
7164 "Go to previous N'th unread summary line."
7166 (gnus-summary-next-subject (- n) t))
7168 (defun gnus-summary-goto-subjects (articles)
7169 "Insert the subject header for ARTICLES in the current buffer."
7171 (dolist (article articles)
7172 (gnus-summary-goto-subject article t)))
7173 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7174 (gnus-summary-position-point))
7176 (defun gnus-summary-goto-subject (article &optional force silent)
7177 "Go the subject line of ARTICLE.
7178 If FORCE, also allow jumping to articles not currently shown."
7179 (interactive "nArticle number: ")
7180 (unless (numberp article)
7181 (error "Article %s is not a number" article))
7183 (data (gnus-data-find article)))
7184 ;; We read in the article if we have to.
7187 (gnus-summary-insert-subject
7189 (if (or (numberp force) (vectorp force)) force)
7191 (setq data (gnus-data-find article)))
7196 (gnus-message 3 "Can't find article %d" article))
7198 (let ((pt (gnus-data-pos data)))
7200 (gnus-summary-set-article-display-arrow pt))
7201 (gnus-summary-position-point)
7204 ;; Walking around summary lines with displaying articles.
7206 (defun gnus-summary-expand-window (&optional arg)
7207 "Make the summary buffer take up the entire Emacs frame.
7208 Given a prefix, will force an `article' buffer configuration."
7211 (gnus-configure-windows 'article 'force)
7212 (gnus-configure-windows 'summary 'force)))
7214 (defun gnus-summary-display-article (article &optional all-header)
7215 "Display ARTICLE in article buffer."
7216 (when (gnus-buffer-live-p gnus-article-buffer)
7217 (with-current-buffer gnus-article-buffer
7218 (mm-enable-multibyte)))
7219 (gnus-set-global-variables)
7220 (when (gnus-buffer-live-p gnus-article-buffer)
7221 (with-current-buffer gnus-article-buffer
7222 (setq gnus-article-charset gnus-newsgroup-charset)
7223 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7224 (mm-enable-multibyte)))
7228 (if gnus-summary-display-article-function
7229 (funcall gnus-summary-display-article-function article all-header)
7230 (gnus-article-prepare article all-header))
7231 (gnus-run-hooks 'gnus-select-article-hook)
7232 (when (and gnus-current-article
7233 (not (zerop gnus-current-article)))
7234 (gnus-summary-goto-subject gnus-current-article))
7235 (gnus-summary-recenter)
7236 (when (and gnus-use-trees gnus-show-threads)
7237 (gnus-possibly-generate-tree article)
7238 (gnus-highlight-selected-tree article))
7239 ;; Successfully display article.
7240 (gnus-article-set-window-start
7241 (cdr (assq article gnus-newsgroup-bookmarks))))))
7243 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7244 "Select the current article.
7245 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7246 non-nil, the article will be re-fetched even if it already present in
7247 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7249 ;; Make sure we are in the summary buffer to work around bbdb bug.
7250 (unless (eq major-mode 'gnus-summary-mode)
7251 (set-buffer gnus-summary-buffer))
7252 (let ((article (or article (gnus-summary-article-number)))
7253 (all-headers (not (not all-headers))) ;Must be t or nil.
7254 gnus-summary-display-article-function)
7256 (gnus-summary-article-pseudo-p article)
7257 (error "This is a pseudo-article"))
7259 (set-buffer gnus-summary-buffer)
7260 (if (or (and gnus-single-article-buffer
7261 (or (null gnus-current-article)
7262 (null gnus-article-current)
7263 (null (get-buffer gnus-article-buffer))
7264 (not (eq article (cdr gnus-article-current)))
7265 (not (equal (car gnus-article-current)
7266 gnus-newsgroup-name))))
7267 (and (not gnus-single-article-buffer)
7268 (or (null gnus-current-article)
7269 (not (eq gnus-current-article article))))
7271 ;; The requested article is different from the current article.
7273 (gnus-summary-display-article article all-headers)
7274 (when (gnus-buffer-live-p gnus-article-buffer)
7275 (with-current-buffer gnus-article-buffer
7276 (if (not gnus-article-decoded-p) ;; a local variable
7277 (mm-disable-multibyte))))
7278 (gnus-article-set-window-start
7279 (cdr (assq article gnus-newsgroup-bookmarks)))
7283 (defun gnus-summary-force-verify-and-decrypt ()
7284 "Display buttons for signed/encrypted parts and verify/decrypt them."
7286 (let ((mm-verify-option 'known)
7287 (mm-decrypt-option 'known)
7288 (gnus-article-emulate-mime t)
7289 (gnus-buttonized-mime-types (append (list "multipart/signed"
7290 "multipart/encrypted")
7291 gnus-buttonized-mime-types)))
7292 (gnus-summary-select-article nil 'force)))
7294 (defun gnus-summary-set-current-mark (&optional current-mark)
7295 "Obsolete function."
7298 (defun gnus-summary-next-article (&optional unread subject backward push)
7299 "Select the next article.
7300 If UNREAD, only unread articles are selected.
7301 If SUBJECT, only articles with SUBJECT are selected.
7302 If BACKWARD, the previous article is selected instead of the next."
7305 ;; Is there such an article?
7306 ((and (gnus-summary-search-forward unread subject backward)
7307 (or (gnus-summary-display-article (gnus-summary-article-number))
7308 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7309 (gnus-summary-position-point))
7310 ;; If not, we try the first unread, if that is wanted.
7312 gnus-auto-select-same
7313 (gnus-summary-first-unread-article))
7314 (gnus-summary-position-point)
7315 (gnus-message 6 "Wrapped"))
7316 ;; Try to get next/previous article not displayed in this group.
7317 ((and gnus-auto-extend-newsgroup
7318 (not unread) (not subject))
7319 (gnus-summary-goto-article
7320 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7321 nil (count-lines (point-min) (point))))
7322 ;; Go to next/previous group.
7324 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7325 (gnus-summary-jump-to-group gnus-newsgroup-name))
7326 (let ((cmd last-command-char)
7329 (set-buffer gnus-group-buffer)
7332 (if (eq gnus-keep-same-level 'best)
7333 (gnus-summary-best-group gnus-newsgroup-name)
7334 (gnus-summary-search-group backward gnus-keep-same-level))))
7335 ;; For some reason, the group window gets selected. We change
7337 (select-window (get-buffer-window (current-buffer)))
7338 ;; Select next unread newsgroup automagically.
7340 ((or (not gnus-auto-select-next)
7342 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7343 ((or (eq gnus-auto-select-next 'quietly)
7344 (and (eq gnus-auto-select-next 'slightly-quietly)
7346 (and (eq gnus-auto-select-next 'almost-quietly)
7347 (gnus-summary-last-article-p)))
7349 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7351 (gnus-message 7 "No more%s articles (%s)..."
7352 (if unread " unread" "")
7353 (if group (concat "selecting " group)
7355 (gnus-summary-next-group nil group backward)))
7357 (when (gnus-key-press-event-p last-input-event)
7358 (gnus-summary-walk-group-buffer
7359 gnus-newsgroup-name cmd unread backward point))))))))
7361 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7362 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7363 (?\C-p (gnus-group-prev-unread-group 1))))
7364 (cursor-in-echo-area t)
7365 keve key group ended prompt)
7367 (set-buffer gnus-group-buffer)
7370 (if (eq gnus-keep-same-level 'best)
7371 (gnus-summary-best-group gnus-newsgroup-name)
7372 (gnus-summary-search-group backward gnus-keep-same-level))))
7376 "No more%s articles%s " (if unread " unread" "")
7378 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7379 (format " (Type %s for %s [%s])"
7380 (single-key-description cmd)
7381 (gnus-group-decoded-name group)
7382 (car (gnus-gethash group gnus-newsrc-hashtb)))
7383 (format " (Type %s to exit %s)"
7384 (single-key-description cmd)
7385 (gnus-group-decoded-name gnus-newsgroup-name)))))
7386 ;; Confirm auto selection.
7387 (setq key (car (setq keve (gnus-read-event-char prompt)))
7390 ((assq key keystrokes)
7391 (let ((obuf (current-buffer)))
7392 (switch-to-buffer gnus-group-buffer)
7394 (gnus-group-jump-to-group group))
7395 (eval (cadr (assq key keystrokes)))
7396 (setq group (gnus-group-group-name))
7397 (switch-to-buffer obuf))
7401 (gnus-ephemeral-group-p gnus-newsgroup-name))
7403 (gnus-summary-next-group nil group backward)))
7405 (push (cdr keve) unread-command-events))))))
7407 (defun gnus-summary-next-unread-article ()
7408 "Select unread article after current one."
7410 (gnus-summary-next-article
7411 (or (not (eq gnus-summary-goto-unread 'never))
7412 (gnus-summary-last-article-p (gnus-summary-article-number)))
7413 (and gnus-auto-select-same
7414 (gnus-summary-article-subject))))
7416 (defun gnus-summary-prev-article (&optional unread subject)
7417 "Select the article after the current one.
7418 If UNREAD is non-nil, only unread articles are selected."
7420 (gnus-summary-next-article unread subject t))
7422 (defun gnus-summary-prev-unread-article ()
7423 "Select unread article before current one."
7425 (gnus-summary-prev-article
7426 (or (not (eq gnus-summary-goto-unread 'never))
7427 (gnus-summary-first-article-p (gnus-summary-article-number)))
7428 (and gnus-auto-select-same
7429 (gnus-summary-article-subject))))
7431 (defun gnus-summary-next-page (&optional lines circular stop)
7432 "Show next page of the selected article.
7433 If at the end of the current article, select the next article.
7434 LINES says how many lines should be scrolled up.
7436 If CIRCULAR is non-nil, go to the start of the article instead of
7437 selecting the next article when reaching the end of the current
7440 If STOP is non-nil, just stop when reaching the end of the message.
7442 Also see the variable `gnus-article-skip-boring'."
7444 (setq gnus-summary-buffer (current-buffer))
7445 (gnus-set-global-variables)
7446 (let ((article (gnus-summary-article-number))
7447 (article-window (get-buffer-window gnus-article-buffer t))
7449 ;; If the buffer is empty, we have no article.
7451 (error "No article to select"))
7452 (gnus-configure-windows 'article)
7453 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7454 (if (and (eq gnus-summary-goto-unread 'never)
7455 (not (gnus-summary-last-article-p article)))
7456 (gnus-summary-next-article)
7457 (gnus-summary-next-unread-article))
7458 (if (or (null gnus-current-article)
7459 (null gnus-article-current)
7460 (/= article (cdr gnus-article-current))
7461 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7462 ;; Selected subject is different from current article's.
7463 (gnus-summary-display-article article)
7464 (when article-window
7465 (gnus-eval-in-buffer-window gnus-article-buffer
7466 (setq endp (or (gnus-article-next-page lines)
7467 (gnus-article-only-boring-p))))
7470 (gnus-message 3 "End of message"))
7472 (gnus-summary-beginning-of-article))
7474 (gnus-message 3 "End of message"))
7476 (if (and (eq gnus-summary-goto-unread 'never)
7477 (not (gnus-summary-last-article-p article)))
7478 (gnus-summary-next-article)
7479 (gnus-summary-next-unread-article))))))))
7480 (gnus-summary-recenter)
7481 (gnus-summary-position-point)))
7483 (defun gnus-summary-prev-page (&optional lines move)
7484 "Show previous page of selected article.
7485 Argument LINES specifies lines to be scrolled down.
7486 If MOVE, move to the previous unread article if point is at
7487 the beginning of the buffer."
7489 (let ((article (gnus-summary-article-number))
7490 (article-window (get-buffer-window gnus-article-buffer t))
7492 (gnus-configure-windows 'article)
7493 (if (or (null gnus-current-article)
7494 (null gnus-article-current)
7495 (/= article (cdr gnus-article-current))
7496 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7497 ;; Selected subject is different from current article's.
7498 (gnus-summary-display-article article)
7499 (gnus-summary-recenter)
7500 (when article-window
7501 (gnus-eval-in-buffer-window gnus-article-buffer
7502 (setq endp (gnus-article-prev-page lines)))
7503 (when (and move endp)
7505 (gnus-message 3 "Beginning of message"))
7507 (if (and (eq gnus-summary-goto-unread 'never)
7508 (not (gnus-summary-first-article-p article)))
7509 (gnus-summary-prev-article)
7510 (gnus-summary-prev-unread-article))))))))
7511 (gnus-summary-position-point))
7513 (defun gnus-summary-prev-page-or-article (&optional lines)
7514 "Show previous page of selected article.
7515 Argument LINES specifies lines to be scrolled down.
7516 If at the beginning of the article, go to the next article."
7518 (gnus-summary-prev-page lines t))
7520 (defun gnus-summary-scroll-up (lines)
7521 "Scroll up (or down) one line current article.
7522 Argument LINES specifies lines to be scrolled up (or down if negative)."
7524 (gnus-configure-windows 'article)
7525 (gnus-summary-show-thread)
7526 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7527 (gnus-eval-in-buffer-window gnus-article-buffer
7529 (when (gnus-article-next-page lines)
7530 (gnus-message 3 "End of message")))
7532 (gnus-article-prev-page (- lines))))))
7533 (gnus-summary-recenter)
7534 (gnus-summary-position-point))
7536 (defun gnus-summary-scroll-down (lines)
7537 "Scroll down (or up) one line current article.
7538 Argument LINES specifies lines to be scrolled down (or up if negative)."
7540 (gnus-summary-scroll-up (- lines)))
7542 (defun gnus-summary-next-same-subject ()
7543 "Select next article which has the same subject as current one."
7545 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7547 (defun gnus-summary-prev-same-subject ()
7548 "Select previous article which has the same subject as current one."
7550 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7552 (defun gnus-summary-next-unread-same-subject ()
7553 "Select next unread article which has the same subject as current one."
7555 (gnus-summary-next-article t (gnus-summary-article-subject)))
7557 (defun gnus-summary-prev-unread-same-subject ()
7558 "Select previous unread article which has the same subject as current one."
7560 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7562 (defun gnus-summary-first-unread-article ()
7563 "Select the first unread article.
7564 Return nil if there are no unread articles."
7567 (when (gnus-summary-first-subject t)
7568 (gnus-summary-show-thread)
7569 (gnus-summary-first-subject t)
7570 (gnus-summary-display-article (gnus-summary-article-number)))
7571 (gnus-summary-position-point)))
7573 (defun gnus-summary-first-unread-subject ()
7574 "Place the point on the subject line of the first unread article.
7575 Return nil if there are no unread articles."
7578 (when (gnus-summary-first-subject t)
7579 (gnus-summary-show-thread)
7580 (gnus-summary-first-subject t))
7581 (gnus-summary-position-point)))
7583 (defun gnus-summary-first-unseen-subject ()
7584 "Place the point on the subject line of the first unseen article.
7585 Return nil if there are no unseen articles."
7588 (when (gnus-summary-first-subject nil nil t)
7589 (gnus-summary-show-thread)
7590 (gnus-summary-first-subject nil nil t))
7591 (gnus-summary-position-point)))
7593 (defun gnus-summary-first-unseen-or-unread-subject ()
7594 "Place the point on the subject line of the first unseen article or,
7595 if all article have been seen, on the subject line of the first unread
7599 (unless (when (gnus-summary-first-subject nil nil t)
7600 (gnus-summary-show-thread)
7601 (gnus-summary-first-subject nil nil t))
7602 (when (gnus-summary-first-subject t)
7603 (gnus-summary-show-thread)
7604 (gnus-summary-first-subject t)))
7605 (gnus-summary-position-point)))
7607 (defun gnus-summary-first-article ()
7608 "Select the first article.
7609 Return nil if there are no articles."
7612 (when (gnus-summary-first-subject)
7613 (gnus-summary-show-thread)
7614 (gnus-summary-first-subject)
7615 (gnus-summary-display-article (gnus-summary-article-number)))
7616 (gnus-summary-position-point)))
7618 (defun gnus-summary-best-unread-article (&optional arg)
7619 "Select the unread article with the highest score.
7620 If given a prefix argument, select the next unread article that has a
7621 score higher than the default score."
7623 (let ((article (if arg
7624 (gnus-summary-better-unread-subject)
7625 (gnus-summary-best-unread-subject))))
7627 (gnus-summary-goto-article article)
7628 (error "No unread articles"))))
7630 (defun gnus-summary-best-unread-subject ()
7631 "Select the unread subject with the highest score."
7633 (let ((best -1000000)
7634 (data gnus-newsgroup-data)
7637 (and (gnus-data-unread-p (car data))
7639 (gnus-summary-article-score (gnus-data-number (car data))))
7642 article (gnus-data-number (car data))))
7643 (setq data (cdr data)))
7645 (gnus-summary-goto-subject article))
7646 (gnus-summary-position-point)
7649 (defun gnus-summary-better-unread-subject ()
7650 "Select the first unread subject that has a score over the default score."
7652 (let ((data gnus-newsgroup-data)
7654 (while (and (setq article (gnus-data-number (car data)))
7655 (or (gnus-data-read-p (car data))
7656 (not (> (gnus-summary-article-score article)
7657 gnus-summary-default-score))))
7658 (setq data (cdr data)))
7660 (gnus-summary-goto-subject article))
7661 (gnus-summary-position-point)
7664 (defun gnus-summary-last-subject ()
7665 "Go to the last displayed subject line in the group."
7666 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7668 (gnus-summary-goto-subject article))))
7670 (defun gnus-summary-goto-article (article &optional all-headers force)
7671 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7672 If ALL-HEADERS is non-nil, no header lines are hidden.
7673 If FORCE, go to the article even if it isn't displayed. If FORCE
7674 is a number, it is the line the article is to be displayed on."
7678 "Article number or Message-ID: "
7679 (mapcar (lambda (number) (list (int-to-string number)))
7680 gnus-newsgroup-limit))
7684 (if (and (stringp article)
7685 (string-match "@\\|%40" article))
7686 (gnus-summary-refer-article article)
7687 (when (stringp article)
7688 (setq article (string-to-number article)))
7689 (if (gnus-summary-goto-subject article force)
7690 (gnus-summary-display-article article all-headers)
7691 (gnus-message 4 "Couldn't go to article %s" article) nil))
7692 (gnus-summary-position-point)))
7694 (defun gnus-summary-goto-last-article ()
7695 "Go to the previously read article."
7698 (when gnus-last-article
7699 (gnus-summary-goto-article gnus-last-article nil t))
7700 (gnus-summary-position-point)))
7702 (defun gnus-summary-pop-article (number)
7703 "Pop one article off the history and go to the previous.
7704 NUMBER articles will be popped off."
7707 (setq gnus-newsgroup-history
7708 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7710 (gnus-summary-goto-article (car to) nil t)
7711 (error "Article history empty")))
7712 (gnus-summary-position-point))
7714 ;; Summary commands and functions for limiting the summary buffer.
7716 (defun gnus-summary-limit-to-articles (n)
7717 "Limit the summary buffer to the next N articles.
7718 If not given a prefix, use the process marked articles instead."
7721 (let ((articles (gnus-summary-work-articles n)))
7722 (setq gnus-newsgroup-processable nil)
7723 (gnus-summary-limit articles))
7724 (gnus-summary-position-point)))
7726 (defun gnus-summary-pop-limit (&optional total)
7727 "Restore the previous limit.
7728 If given a prefix, remove all limits."
7731 (setq gnus-newsgroup-limits
7732 (list (mapcar (lambda (h) (mail-header-number h))
7733 gnus-newsgroup-headers))))
7734 (unless gnus-newsgroup-limits
7735 (error "No limit to pop"))
7737 (gnus-summary-limit nil 'pop)
7738 (gnus-summary-position-point)))
7740 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7741 "Limit the summary buffer to articles that have subjects that match a regexp.
7742 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7744 (list (read-string (if current-prefix-arg
7745 "Exclude subject (regexp): "
7746 "Limit to subject (regexp): "))
7747 nil current-prefix-arg))
7749 (setq header "subject"))
7750 (when (not (equal "" subject))
7752 (let ((articles (gnus-summary-find-matching
7753 (or header "subject") subject 'all nil nil
7756 (error "Found no matches for \"%s\"" subject))
7757 (gnus-summary-limit articles))
7758 (gnus-summary-position-point))))
7760 (defun gnus-summary-limit-to-author (from &optional not-matching)
7761 "Limit the summary buffer to articles that have authors that match a regexp.
7762 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7764 (list (read-string (if current-prefix-arg
7765 "Exclude author (regexp): "
7766 "Limit to author (regexp): "))
7767 current-prefix-arg))
7768 (gnus-summary-limit-to-subject from "from" not-matching))
7770 (defun gnus-summary-limit-to-age (age &optional younger-p)
7771 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7772 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7773 articles that are younger than AGE days."
7775 (let ((younger current-prefix-arg)
7778 (while (not days-got)
7779 (setq days (if younger
7780 (read-string "Limit to articles younger than (in days, older when negative): ")
7782 "Limit to articles older than (in days, younger when negative): ")))
7783 (when (> (length days) 0)
7784 (setq days (read days)))
7790 (setq younger (not younger))
7791 (setq days (* days -1)))))
7792 (message "Please enter a number.")
7794 (list days younger)))
7796 (let ((data gnus-newsgroup-data)
7797 (cutoff (days-to-time age))
7798 articles d date is-younger)
7799 (while (setq d (pop data))
7800 (when (and (vectorp (gnus-data-header d))
7801 (setq date (mail-header-date (gnus-data-header d))))
7802 (setq is-younger (time-less-p
7803 (time-since (condition-case ()
7810 (push (gnus-data-number d) articles))))
7811 (gnus-summary-limit (nreverse articles)))
7812 (gnus-summary-position-point)))
7814 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7815 "Limit the summary buffer to articles that match an 'extra' header."
7819 (gnus-completing-read-with-default
7820 (symbol-name (car gnus-extra-headers))
7821 (if current-prefix-arg
7822 "Exclude extra header"
7823 "Limit extra header")
7825 (cons (symbol-name x) x))
7830 (read-string (format "%s header %s (regexp): "
7831 (if current-prefix-arg "Exclude" "Limit to")
7833 current-prefix-arg)))
7834 (when (not (equal "" regexp))
7836 (let ((articles (gnus-summary-find-matching
7837 (cons 'extra header) regexp 'all nil nil
7840 (error "Found no matches for \"%s\"" regexp))
7841 (gnus-summary-limit articles))
7842 (gnus-summary-position-point))))
7844 (defun gnus-summary-limit-to-display-predicate ()
7845 "Limit the summary buffer to the predicated in the `display' group parameter."
7847 (unless gnus-newsgroup-display
7848 (error "There is no `display' group parameter"))
7850 (dolist (number gnus-newsgroup-articles)
7851 (when (funcall gnus-newsgroup-display)
7852 (push number articles)))
7853 (gnus-summary-limit articles))
7854 (gnus-summary-position-point))
7856 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7858 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7860 (defun gnus-summary-limit-to-unread (&optional all)
7861 "Limit the summary buffer to articles that are not marked as read.
7862 If ALL is non-nil, limit strictly to unread articles."
7865 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7866 (gnus-summary-limit-to-marks
7867 ;; Concat all the marks that say that an article is read and have
7869 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7870 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7871 gnus-low-score-mark gnus-expirable-mark
7872 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7873 gnus-duplicate-mark gnus-souped-mark)
7876 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7877 (make-obsolete 'gnus-summary-delete-marked-with
7878 'gnus-summary-limit-exclude-marks)
7880 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7881 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7882 If REVERSE, limit the summary buffer to articles that are marked
7883 with MARKS. MARKS can either be a string of marks or a list of marks.
7884 Returns how many articles were removed."
7885 (interactive "sMarks: ")
7886 (gnus-summary-limit-to-marks marks t))
7888 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7889 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7890 If REVERSE (the prefix), limit the summary buffer to articles that are
7891 not marked with MARKS. MARKS can either be a string of marks or a
7893 Returns how many articles were removed."
7894 (interactive "sMarks: \nP")
7896 (let ((data gnus-newsgroup-data)
7897 (marks (if (listp marks) marks
7898 (append marks nil))) ; Transform to list.
7901 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7902 (memq (gnus-data-mark (car data)) marks))
7903 (push (gnus-data-number (car data)) articles))
7904 (setq data (cdr data)))
7905 (gnus-summary-limit articles))
7906 (gnus-summary-position-point)))
7908 (defun gnus-summary-limit-to-score (score)
7909 "Limit to articles with score at or above SCORE."
7910 (interactive "NLimit to articles with score of at least: ")
7911 (let ((data gnus-newsgroup-data)
7914 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7916 (push (gnus-data-number (car data)) articles))
7917 (setq data (cdr data)))
7919 (gnus-summary-limit articles)
7920 (gnus-summary-position-point))))
7922 (defun gnus-summary-limit-to-unseen ()
7923 "Limit to unseen articles."
7926 (gnus-summary-limit gnus-newsgroup-unseen)
7927 (gnus-summary-position-point)))
7929 (defun gnus-summary-limit-include-thread (id)
7930 "Display all the hidden articles that is in the thread with ID in it.
7931 When called interactively, ID is the Message-ID of the current
7933 (interactive (list (mail-header-id (gnus-summary-article-header))))
7934 (let ((articles (gnus-articles-in-thread
7935 (gnus-id-to-thread (gnus-root-id id)))))
7937 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7938 (gnus-summary-limit-include-matching-articles
7940 (regexp-quote (gnus-simplify-subject-re
7941 (mail-header-subject (gnus-id-to-header id)))))
7942 (gnus-summary-position-point))))
7944 (defun gnus-summary-limit-include-matching-articles (header regexp)
7945 "Display all the hidden articles that have HEADERs that match REGEXP."
7946 (interactive (list (read-string "Match on header: ")
7947 (read-string "Regexp: ")))
7948 (let ((articles (gnus-find-matching-articles header regexp)))
7950 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7951 (gnus-summary-position-point))))
7953 (defun gnus-summary-insert-dormant-articles ()
7954 "Insert all the dormant articles for this group into the current buffer."
7956 (let ((gnus-verbose (max 6 gnus-verbose)))
7957 (if (not gnus-newsgroup-dormant)
7958 (gnus-message 3 "No cached articles for this group")
7959 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7961 (defun gnus-summary-limit-include-dormant ()
7962 "Display all the hidden articles that are marked as dormant.
7963 Note that this command only works on a subset of the articles currently
7964 fetched for this group."
7966 (unless gnus-newsgroup-dormant
7967 (error "There are no dormant articles in this group"))
7969 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7970 (gnus-summary-position-point)))
7972 (defun gnus-summary-limit-exclude-dormant ()
7973 "Hide all dormant articles."
7976 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7977 (gnus-summary-position-point)))
7979 (defun gnus-summary-limit-exclude-childless-dormant ()
7980 "Hide all dormant articles that have no children."
7982 (let ((data (gnus-data-list t))
7983 articles d children)
7984 ;; Find all articles that are either not dormant or have
7986 (while (setq d (pop data))
7987 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7989 (gnus-article-children (gnus-data-number d)))
7992 (when (memq (car children) articles)
7997 (push (gnus-data-number d) articles)))
8000 (gnus-summary-limit articles)
8001 (gnus-summary-position-point))))
8003 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8004 "Mark all unread excluded articles as read.
8005 If ALL, mark even excluded ticked and dormants as read."
8007 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8008 (let ((articles (gnus-sorted-ndifference
8010 (mapcar (lambda (h) (mail-header-number h))
8011 gnus-newsgroup-headers)
8013 gnus-newsgroup-limit))
8015 (setq gnus-newsgroup-unreads
8016 (gnus-sorted-intersection gnus-newsgroup-unreads
8017 gnus-newsgroup-limit))
8019 (setq gnus-newsgroup-dormant nil
8020 gnus-newsgroup-marked nil
8021 gnus-newsgroup-reads
8023 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8024 gnus-newsgroup-reads))
8025 (while (setq article (pop articles))
8026 (unless (or (memq article gnus-newsgroup-dormant)
8027 (memq article gnus-newsgroup-marked))
8028 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8030 (defun gnus-summary-limit (articles &optional pop)
8032 ;; We pop the previous limit off the stack and use that.
8033 (setq articles (car gnus-newsgroup-limits)
8034 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8035 ;; We use the new limit, so we push the old limit on the stack.
8036 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8038 (setq gnus-newsgroup-limit articles)
8039 (let ((total (length gnus-newsgroup-data))
8040 (data (gnus-data-find-list (gnus-summary-article-number)))
8041 (gnus-summary-mark-below nil) ; Inhibit this.
8043 ;; This will do all the work of generating the new summary buffer
8044 ;; according to the new limit.
8045 (gnus-summary-prepare)
8046 ;; Hide any threads, possibly.
8047 (gnus-summary-maybe-hide-threads)
8048 ;; Try to return to the article you were at, or one in the
8051 ;; We try to find some article after the current one.
8053 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8056 (setq data (cdr data))))
8058 ;; If there is no data, that means that we were after the last
8059 ;; article. The same goes when we can't find any articles
8060 ;; after the current one.
8061 (goto-char (point-max))
8062 (gnus-summary-find-prev))
8063 (gnus-set-mode-line 'summary)
8064 ;; We return how many articles were removed from the summary
8065 ;; buffer as a result of the new limit.
8066 (- total (length gnus-newsgroup-data))))
8068 (defsubst gnus-invisible-cut-children (threads)
8071 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8076 (defsubst gnus-cut-thread (thread)
8077 "Go forwards in the thread until we find an article that we want to display."
8078 (when (or (eq gnus-fetch-old-headers 'some)
8079 (eq gnus-fetch-old-headers 'invisible)
8080 (numberp gnus-fetch-old-headers)
8081 (eq gnus-build-sparse-threads 'some)
8082 (eq gnus-build-sparse-threads 'more))
8083 ;; Deal with old-fetched headers and sparse threads.
8087 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8088 (gnus-summary-article-ancient-p
8089 (mail-header-number (car thread))))
8090 (if (or (<= (length (cdr thread)) 1)
8091 (eq gnus-fetch-old-headers 'invisible))
8092 (setq gnus-newsgroup-limit
8093 (delq (mail-header-number (car thread))
8094 gnus-newsgroup-limit)
8095 thread (cadr thread))
8096 (when (gnus-invisible-cut-children (cdr thread))
8097 (let ((th (cdr thread)))
8099 (if (memq (mail-header-number (caar th))
8100 gnus-newsgroup-limit)
8101 (setq thread (car th)
8103 (setq th (cdr th))))))))))
8106 (defun gnus-cut-threads (threads)
8107 "Cut off all uninteresting articles from the beginning of THREADS."
8108 (when (or (eq gnus-fetch-old-headers 'some)
8109 (eq gnus-fetch-old-headers 'invisible)
8110 (numberp gnus-fetch-old-headers)
8111 (eq gnus-build-sparse-threads 'some)
8112 (eq gnus-build-sparse-threads 'more))
8115 (setcar th (gnus-cut-thread (car th)))
8116 (setq th (cdr th)))))
8117 ;; Remove nixed out threads.
8120 (defun gnus-summary-initial-limit (&optional show-if-empty)
8121 "Figure out what the initial limit is supposed to be on group entry.
8122 This entails weeding out unwanted dormants, low-scored articles,
8123 fetch-old-headers verbiage, and so on."
8124 ;; Most groups have nothing to remove.
8125 (if (or gnus-inhibit-limiting
8126 (and (null gnus-newsgroup-dormant)
8127 (eq gnus-newsgroup-display 'gnus-not-ignore)
8128 (not (eq gnus-fetch-old-headers 'some))
8129 (not (numberp gnus-fetch-old-headers))
8130 (not (eq gnus-fetch-old-headers 'invisible))
8131 (null gnus-summary-expunge-below)
8132 (not (eq gnus-build-sparse-threads 'some))
8133 (not (eq gnus-build-sparse-threads 'more))
8134 (null gnus-thread-expunge-below)
8135 (not gnus-use-nocem)))
8137 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8138 (setq gnus-newsgroup-limit nil)
8141 (unless (car (symbol-value node))
8142 ;; These threads have no parents -- they are roots.
8143 (let ((nodes (cdr (symbol-value node)))
8146 (if (and gnus-thread-expunge-below
8147 (< (gnus-thread-total-score (car nodes))
8148 gnus-thread-expunge-below))
8149 (gnus-expunge-thread (pop nodes))
8150 (setq thread (pop nodes))
8151 (gnus-summary-limit-children thread))))))
8152 gnus-newsgroup-dependencies)
8153 ;; If this limitation resulted in an empty group, we might
8154 ;; pop the previous limit and use it instead.
8155 (when (and (not gnus-newsgroup-limit)
8157 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8158 gnus-newsgroup-limit))
8160 (defun gnus-summary-limit-children (thread)
8161 "Return 1 if this subthread is visible and 0 if it is not."
8162 ;; First we get the number of visible children to this thread. This
8163 ;; is done by recursing down the thread using this function, so this
8164 ;; will really go down to a leaf article first, before slowly
8165 ;; working its way up towards the root.
8167 (let* ((max-lisp-eval-depth 5000)
8170 (apply '+ (mapcar 'gnus-summary-limit-children
8173 (number (mail-header-number (car thread)))
8176 (not (memq number gnus-newsgroup-marked))
8178 ;; If this article is dormant and has absolutely no visible
8179 ;; children, then this article isn't visible.
8180 (and (memq number gnus-newsgroup-dormant)
8182 ;; If this is "fetch-old-headered" and there is no
8183 ;; visible children, then we don't want this article.
8184 (and (or (eq gnus-fetch-old-headers 'some)
8185 (numberp gnus-fetch-old-headers))
8186 (gnus-summary-article-ancient-p number)
8188 ;; If this is "fetch-old-headered" and `invisible', then
8189 ;; we don't want this article.
8190 (and (eq gnus-fetch-old-headers 'invisible)
8191 (gnus-summary-article-ancient-p number))
8192 ;; If this is a sparsely inserted article with no children,
8193 ;; we don't want it.
8194 (and (eq gnus-build-sparse-threads 'some)
8195 (gnus-summary-article-sparse-p number)
8197 ;; If we use expunging, and this article is really
8198 ;; low-scored, then we don't want this article.
8199 (when (and gnus-summary-expunge-below
8201 (or (cdr (assq number gnus-newsgroup-scored))
8202 gnus-summary-default-score))
8203 gnus-summary-expunge-below))
8204 ;; We increase the expunge-tally here, but that has
8205 ;; nothing to do with the limits, really.
8206 (incf gnus-newsgroup-expunged-tally)
8207 ;; We also mark as read here, if that's wanted.
8208 (when (and gnus-summary-mark-below
8209 (< score gnus-summary-mark-below))
8210 (setq gnus-newsgroup-unreads
8211 (delq number gnus-newsgroup-unreads))
8212 (if gnus-newsgroup-auto-expire
8213 (push number gnus-newsgroup-expirable)
8214 (push (cons number gnus-low-score-mark)
8215 gnus-newsgroup-reads)))
8217 ;; Do the `display' group parameter.
8218 (and gnus-newsgroup-display
8219 (not (funcall gnus-newsgroup-display)))
8220 ;; Check NoCeM things.
8221 (if (and gnus-use-nocem
8222 (gnus-nocem-unwanted-article-p
8223 (mail-header-id (car thread))))
8225 (setq gnus-newsgroup-unreads
8226 (delq number gnus-newsgroup-unreads))
8228 ;; Nope, invisible article.
8230 ;; Ok, this article is to be visible, so we add it to the limit
8232 (push number gnus-newsgroup-limit)
8235 (defun gnus-expunge-thread (thread)
8236 "Mark all articles in THREAD as read."
8237 (let* ((number (mail-header-number (car thread))))
8238 (incf gnus-newsgroup-expunged-tally)
8239 ;; We also mark as read here, if that's wanted.
8240 (setq gnus-newsgroup-unreads
8241 (delq number gnus-newsgroup-unreads))
8242 (if gnus-newsgroup-auto-expire
8243 (push number gnus-newsgroup-expirable)
8244 (push (cons number gnus-low-score-mark)
8245 gnus-newsgroup-reads)))
8246 ;; Go recursively through all subthreads.
8247 (mapcar 'gnus-expunge-thread (cdr thread)))
8249 ;; Summary article oriented commands
8251 (defun gnus-summary-refer-parent-article (n)
8252 "Refer parent article N times.
8253 If N is negative, go to ancestor -N instead.
8254 The difference between N and the number of articles fetched is returned."
8258 (when (not (natnump n))
8263 (setq header (gnus-summary-article-header))
8264 (if (and (eq (mail-header-number header)
8265 (cdr gnus-article-current))
8266 (equal gnus-newsgroup-name
8267 (car gnus-article-current)))
8268 ;; If we try to find the parent of the currently
8269 ;; displayed article, then we take a look at the actual
8270 ;; References header, since this is slightly more
8271 ;; reliable than the References field we got from the
8274 (set-buffer gnus-original-article-buffer)
8275 (nnheader-narrow-to-headers)
8276 (unless (setq ref (message-fetch-field "references"))
8277 (when (setq ref (message-fetch-field "in-reply-to"))
8278 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8281 ;; It's not the current article, so we take a bet on
8282 ;; the value we got from the server.
8283 (mail-header-references header)))
8285 (not (equal ref "")))
8286 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8287 (gnus-message 1 "Couldn't find parent"))
8288 (gnus-message 1 "No references in article %d"
8289 (gnus-summary-article-number))
8292 (gnus-summary-position-point)
8295 (defun gnus-summary-refer-references ()
8296 "Fetch all articles mentioned in the References header.
8297 Return the number of articles fetched."
8299 (let ((ref (mail-header-references (gnus-summary-article-header)))
8300 (current (gnus-summary-article-number))
8304 (error "No References in the current article")
8305 ;; For each Message-ID in the References header...
8306 (while (string-match "<[^>]*>" ref)
8308 ;; ... fetch that article.
8309 (gnus-summary-refer-article
8310 (prog1 (match-string 0 ref)
8311 (setq ref (substring ref (match-end 0))))))
8312 (gnus-summary-goto-subject current)
8313 (gnus-summary-position-point)
8316 (defun gnus-summary-refer-thread (&optional limit)
8317 "Fetch all articles in the current thread.
8318 If LIMIT (the numerical prefix), fetch that many old headers instead
8319 of what's specified by the `gnus-refer-thread-limit' variable."
8321 (let ((id (mail-header-id (gnus-summary-article-header)))
8322 (limit (if limit (prefix-numeric-value limit)
8323 gnus-refer-thread-limit)))
8324 (unless (eq gnus-fetch-old-headers 'invisible)
8325 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8326 ;; Retrieve the headers and read them in.
8327 (if (eq (if (numberp limit)
8328 (gnus-retrieve-headers
8330 (+ (mail-header-number
8331 (gnus-summary-article-header))
8333 gnus-newsgroup-end))
8334 gnus-newsgroup-name (* limit 2))
8335 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8337 (gnus-retrieve-headers (list gnus-newsgroup-end)
8338 gnus-newsgroup-name limit))
8340 (gnus-build-all-threads)
8341 (error "Can't fetch thread from back ends that don't support NOV"))
8342 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8343 (gnus-summary-limit-include-thread id)))
8345 (defun gnus-summary-refer-article (message-id)
8346 "Fetch an article specified by MESSAGE-ID."
8347 (interactive "sMessage-ID: ")
8348 (when (and (stringp message-id)
8349 (not (zerop (length message-id))))
8350 (setq message-id (gnus-replace-in-string message-id " " ""))
8351 ;; Construct the correct Message-ID if necessary.
8352 ;; Suggested by tale@pawl.rpi.edu.
8353 (unless (string-match "^<" message-id)
8354 (setq message-id (concat "<" message-id)))
8355 (unless (string-match ">$" message-id)
8356 (setq message-id (concat message-id ">")))
8357 ;; People often post MIDs from URLs, so unhex it:
8358 (unless (string-match "@" message-id)
8359 (setq message-id (gnus-url-unhex-string message-id)))
8360 (let* ((header (gnus-id-to-header message-id))
8362 (gnus-summary-article-sparse-p
8363 (mail-header-number header))
8364 (memq (mail-header-number header)
8365 gnus-newsgroup-limit)))
8368 ;; If the article is present in the buffer we just go to it.
8370 (or (not (gnus-summary-article-sparse-p
8371 (mail-header-number header)))
8374 (gnus-summary-goto-article
8375 (mail-header-number header) nil t)
8377 (gnus-summary-update-article (mail-header-number header)))))
8379 ;; We fetch the article.
8381 (dolist (gnus-override-method (gnus-refer-article-methods))
8382 (when (and (gnus-check-server gnus-override-method)
8383 ;; Fetch the header,
8384 (setq number (gnus-summary-insert-subject message-id)))
8385 ;; and display the article.
8386 (gnus-summary-select-article nil nil nil number)
8388 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8390 (defun gnus-refer-article-methods ()
8391 "Return a list of referable methods."
8393 ;; No method, so we default to current and native.
8394 ((null gnus-refer-article-method)
8395 (list gnus-current-select-method gnus-select-method))
8397 ((eq 'current gnus-refer-article-method)
8398 (list gnus-current-select-method))
8399 ;; List of select methods.
8400 ((not (and (symbolp (car gnus-refer-article-method))
8401 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8403 (dolist (method gnus-refer-article-method)
8404 (push (if (eq 'current method)
8405 gnus-current-select-method
8409 ;; One single select method.
8411 (list gnus-refer-article-method))))
8413 (defun gnus-summary-edit-parameters ()
8414 "Edit the group parameters of the current group."
8416 (gnus-group-edit-group gnus-newsgroup-name 'params))
8418 (defun gnus-summary-customize-parameters ()
8419 "Customize the group parameters of the current group."
8421 (gnus-group-customize gnus-newsgroup-name))
8423 (defun gnus-summary-enter-digest-group (&optional force)
8424 "Enter an nndoc group based on the current article.
8425 If FORCE, force a digest interpretation. If not, try
8426 to guess what the document format is."
8428 (let ((conf gnus-current-window-configuration))
8429 (save-window-excursion
8431 (let (gnus-article-prepare-hook
8432 gnus-display-mime-function
8434 (gnus-summary-select-article))))
8435 (setq gnus-current-window-configuration conf)
8436 (let* ((name (format "%s-%d"
8437 (gnus-group-prefixed-name
8438 gnus-newsgroup-name (list 'nndoc ""))
8440 (set-buffer gnus-summary-buffer)
8441 gnus-current-article)))
8442 (ogroup gnus-newsgroup-name)
8443 (params (append (gnus-info-params (gnus-get-info ogroup))
8444 (list (cons 'to-group ogroup))
8445 (list (cons 'parent-group ogroup))
8446 (list (cons 'save-article-group ogroup))))
8447 (case-fold-search t)
8448 (buf (current-buffer))
8451 (set-buffer gnus-original-article-buffer)
8452 ;; Have the digest group inherit the main mail address of
8453 ;; the parent article.
8454 (when (setq to-address (or (gnus-fetch-field "reply-to")
8455 (gnus-fetch-field "from")))
8456 (setq params (append
8457 (list (cons 'to-address
8458 (funcall gnus-decode-encoded-word-function
8460 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8461 (insert-buffer-substring gnus-original-article-buffer)
8462 ;; Remove lines that may lead nndoc to misinterpret the
8465 (goto-char (point-min))
8466 (or (search-forward "\n\n" nil t) (point)))
8467 (goto-char (point-min))
8468 (delete-matching-lines "^Path:\\|^From ")
8471 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8472 (gnus-newsgroup-ephemeral-ignored-charsets
8473 gnus-newsgroup-ignored-charsets))
8474 (gnus-group-read-ephemeral-group
8475 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8477 ,(if force 'mbox 'guess)))
8479 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8481 ;; Make all postings to this group go to the parent group.
8482 (nconc (gnus-info-params (gnus-get-info name))
8484 ;; Couldn't select this doc group.
8485 (switch-to-buffer buf)
8486 (gnus-set-global-variables)
8487 (gnus-configure-windows 'summary)
8488 (gnus-message 3 "Article couldn't be entered?"))
8489 (kill-buffer dig)))))
8491 (defun gnus-summary-read-document (n)
8492 "Open a new group based on the current article(s).
8493 This will allow you to read digests and other similar
8494 documents as newsgroups.
8495 Obeys the standard process/prefix convention."
8497 (let* ((articles (gnus-summary-work-articles n))
8498 (ogroup gnus-newsgroup-name)
8499 (params (append (gnus-info-params (gnus-get-info ogroup))
8500 (list (cons 'to-group ogroup))))
8501 article group egroup groups vgroup)
8502 (while (setq article (pop articles))
8503 (setq group (format "%s-%d" gnus-newsgroup-name article))
8504 (gnus-summary-remove-process-mark article)
8505 (when (gnus-summary-display-article article)
8508 (insert-buffer-substring gnus-original-article-buffer)
8509 ;; Remove some headers that may lead nndoc to make
8511 (message-narrow-to-head)
8512 (goto-char (point-min))
8513 (delete-matching-lines "^\\(Path\\):\\|^From ")
8516 (gnus-group-read-ephemeral-group
8517 group `(nndoc ,group (nndoc-address ,(current-buffer))
8518 (nndoc-article-type guess))
8521 ;; Make all postings to this group go to the parent group.
8522 (nconc (gnus-info-params (gnus-get-info egroup))
8524 (push egroup groups))
8525 ;; Couldn't select this doc group.
8526 (gnus-error 3 "Article couldn't be entered"))))))
8527 ;; Now we have selected all the documents.
8530 (error "None of the articles could be interpreted as documents"))
8531 ((gnus-group-read-ephemeral-group
8532 (setq vgroup (format
8533 "nnvirtual:%s-%s" gnus-newsgroup-name
8534 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8535 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8537 (cons (current-buffer) 'summary)))
8539 (error "Couldn't select virtual nndoc group")))))
8541 (defun gnus-summary-isearch-article (&optional regexp-p)
8542 "Do incremental search forward on the current article.
8543 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8545 (gnus-summary-select-article)
8546 (gnus-configure-windows 'article)
8547 (gnus-eval-in-buffer-window gnus-article-buffer
8550 (isearch-forward regexp-p))))
8552 (defun gnus-summary-search-article-forward (regexp &optional backward)
8553 "Search for an article containing REGEXP forward.
8554 If BACKWARD, search backward instead."
8557 (format "Search article %s (regexp%s): "
8558 (if current-prefix-arg "backward" "forward")
8559 (if gnus-last-search-regexp
8560 (concat ", default " gnus-last-search-regexp)
8562 current-prefix-arg))
8563 (if (string-equal regexp "")
8564 (setq regexp (or gnus-last-search-regexp ""))
8565 (setq gnus-last-search-regexp regexp)
8566 (setq gnus-article-before-search gnus-current-article))
8567 ;; Intentionally set gnus-last-article.
8568 (setq gnus-last-article gnus-article-before-search)
8569 (let ((gnus-last-article gnus-last-article))
8570 (if (gnus-summary-search-article regexp backward)
8571 (gnus-summary-show-thread)
8572 (signal 'search-failed (list regexp)))))
8574 (defun gnus-summary-search-article-backward (regexp)
8575 "Search for an article containing REGEXP backward."
8578 (format "Search article backward (regexp%s): "
8579 (if gnus-last-search-regexp
8580 (concat ", default " gnus-last-search-regexp)
8582 (gnus-summary-search-article-forward regexp 'backward))
8584 (defun gnus-summary-search-article (regexp &optional backward)
8585 "Search for an article containing REGEXP.
8586 Optional argument BACKWARD means do search for backward.
8587 `gnus-select-article-hook' is not called during the search."
8588 ;; We have to require this here to make sure that the following
8589 ;; dynamic binding isn't shadowed by autoloading.
8590 (require 'gnus-async)
8592 (let ((gnus-select-article-hook nil) ;Disable hook.
8593 (gnus-article-prepare-hook nil)
8594 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8595 (gnus-use-article-prefetch nil)
8596 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8597 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8599 (gnus-keep-backlog nil)
8600 (gnus-break-pages nil)
8601 (gnus-summary-display-arrow nil)
8602 (gnus-updated-mode-lines nil)
8603 (gnus-auto-center-summary nil)
8604 (sum (current-buffer))
8605 (gnus-display-mime-function nil)
8608 (gnus-save-hidden-threads
8609 (gnus-summary-select-article)
8610 (set-buffer gnus-article-buffer)
8611 (goto-char (window-point (get-buffer-window (current-buffer))))
8615 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8617 (re-search-backward regexp nil t)
8618 (re-search-forward regexp nil t))
8619 ;; We found the regexp.
8624 (get-buffer-window (current-buffer))
8628 (get-buffer-window (current-buffer))
8631 (setq point (point)))
8632 ;; We didn't find it, so we go to the next article.
8635 (while (eq found 'not)
8636 (if (not (if backward (gnus-summary-find-prev)
8637 (gnus-summary-find-next)))
8638 ;; No more articles.
8640 ;; Select the next article and adjust point.
8641 (unless (gnus-summary-article-sparse-p
8642 (gnus-summary-article-number))
8644 (gnus-summary-select-article)
8645 (set-buffer gnus-article-buffer)
8647 (goto-char (if backward (point-max) (point-min))))))))
8648 (gnus-message 7 ""))
8649 ;; Return whether we found the regexp.
8650 (when (eq found 'found)
8652 (gnus-summary-show-thread)
8653 (gnus-summary-goto-subject gnus-current-article)
8654 (gnus-summary-position-point)
8657 (defun gnus-find-matching-articles (header regexp)
8658 "Return a list of all articles that match REGEXP on HEADER.
8659 This search includes all articles in the current group that Gnus has
8660 fetched headers for, whether they are displayed or not."
8661 (let ((articles nil)
8662 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8663 (case-fold-search t))
8664 (dolist (header gnus-newsgroup-headers)
8665 (when (string-match regexp (funcall func header))
8666 (push (mail-header-number header) articles)))
8667 (nreverse articles)))
8669 (defun gnus-summary-find-matching (header regexp &optional backward unread
8670 not-case-fold not-matching)
8671 "Return a list of all articles that match REGEXP on HEADER.
8672 The search stars on the current article and goes forwards unless
8673 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8674 If UNREAD is non-nil, only unread articles will
8675 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8676 in the comparisons. If NOT-MATCHING, return a list of all articles that
8677 not match REGEXP on HEADER."
8678 (let ((case-fold-search (not not-case-fold))
8681 (if (eq (car header) 'extra)
8684 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8686 (error "%s is an invalid header" header))
8687 (unless (fboundp (intern (concat "mail-header-" header)))
8688 (error "%s is not a valid header" header))
8689 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8690 (dolist (d (if (eq backward 'all)
8692 (gnus-data-find-list
8693 (gnus-summary-article-number)
8694 (gnus-data-list backward))))
8695 (when (and (or (not unread) ; We want all articles...
8696 (gnus-data-unread-p d)) ; Or just unreads.
8697 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8701 (funcall func (gnus-data-header d))))
8702 (string-match regexp
8703 (funcall func (gnus-data-header d)))))
8704 (push (gnus-data-number d) articles))) ; Success!
8705 (nreverse articles)))
8707 (defun gnus-summary-execute-command (header regexp command &optional backward)
8708 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8709 If HEADER is an empty string (or nil), the match is done on the entire
8710 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8712 (list (let ((completion-ignore-case t))
8715 (mapcar (lambda (header) (list (format "%s" header)))
8717 '("Number" "Subject" "From" "Lines" "Date"
8718 "Message-ID" "Xref" "References" "Body")
8719 gnus-extra-headers))
8720 nil 'require-match))
8721 (read-string "Regexp: ")
8722 (read-key-sequence "Command: ")
8723 current-prefix-arg))
8724 (when (equal header "Body")
8726 ;; Hidden thread subtrees must be searched as well.
8727 (gnus-summary-show-all-threads)
8728 ;; We don't want to change current point nor window configuration.
8730 (save-window-excursion
8732 gnus-treat-strip-trailing-blank-lines
8733 gnus-treat-strip-leading-blank-lines
8734 gnus-treat-strip-multiple-blank-lines
8735 gnus-treat-hide-boring-headers
8736 gnus-treat-fold-newsgroups
8737 gnus-article-prepare-hook)
8738 (gnus-message 6 "Executing %s..." (key-description command))
8739 ;; We'd like to execute COMMAND interactively so as to give arguments.
8740 (gnus-execute header regexp
8741 `(call-interactively ',(key-binding command))
8743 (gnus-message 6 "Executing %s...done" (key-description command))))))
8745 (defun gnus-summary-beginning-of-article ()
8746 "Scroll the article back to the beginning."
8748 (gnus-summary-select-article)
8749 (gnus-configure-windows 'article)
8750 (gnus-eval-in-buffer-window gnus-article-buffer
8752 (goto-char (point-min))
8753 (when gnus-break-pages
8754 (gnus-narrow-to-page))))
8756 (defun gnus-summary-end-of-article ()
8757 "Scroll to the end of the article."
8759 (gnus-summary-select-article)
8760 (gnus-configure-windows 'article)
8761 (gnus-eval-in-buffer-window gnus-article-buffer
8763 (goto-char (point-max))
8765 (when gnus-break-pages
8766 (when (re-search-backward page-delimiter nil t)
8767 (narrow-to-region (match-end 0) (point-max)))
8768 (gnus-narrow-to-page))))
8770 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8771 "Truncate to LEN and quote all \"(\"'s in STRING."
8772 (gnus-replace-in-string (if (and len (> (length string) len))
8773 (substring string 0 len)
8777 (defun gnus-summary-print-article (&optional filename n)
8778 "Generate and print a PostScript image of the process-marked (mail) articles.
8780 If used interactively, print the current article if none are
8781 process-marked. With prefix arg, prompt the user for the name of the
8784 When used from Lisp, accept two optional args FILENAME and N. N means
8785 to print the next N articles. If N is negative, print the N previous
8786 articles. If N is nil and articles have been marked with the process
8787 mark, print these instead.
8789 If the optional first argument FILENAME is nil, send the image to the
8790 printer. If FILENAME is a string, save the PostScript image in a file with
8791 that name. If FILENAME is a number, prompt the user for the name of the file
8793 (interactive (list (ps-print-preprint current-prefix-arg)))
8794 (dolist (article (gnus-summary-work-articles n))
8795 (gnus-summary-select-article nil nil 'pseudo article)
8796 (gnus-eval-in-buffer-window gnus-article-buffer
8797 (gnus-print-buffer))
8798 (gnus-summary-remove-process-mark article))
8799 (ps-despool filename))
8801 (defun gnus-print-buffer ()
8802 (let ((buffer (generate-new-buffer " *print*")))
8805 (copy-to-buffer buffer (point-min) (point-max))
8807 (gnus-remove-text-with-property 'gnus-decoration)
8808 (when (gnus-visual-p 'article-highlight 'highlight)
8809 ;; Copy-to-buffer doesn't copy overlay. So redo
8811 (let ((gnus-article-buffer buffer))
8812 (gnus-article-highlight-citation t)
8813 (gnus-article-highlight-signature)
8814 (gnus-article-emphasize)
8815 (gnus-article-delete-invisible-text)))
8816 (let ((ps-left-header
8819 (gnus-summary-print-truncate-and-quote
8820 (mail-header-subject gnus-current-headers)
8823 (gnus-summary-print-truncate-and-quote
8824 (mail-header-from gnus-current-headers)
8828 "/pagenumberstring load"
8830 (mail-header-date gnus-current-headers) ")"))))
8831 (gnus-run-hooks 'gnus-ps-print-hook)
8834 (ps-spool-buffer-with-faces)
8835 (ps-spool-buffer)))))
8836 (kill-buffer buffer))))
8838 (defun gnus-summary-show-article (&optional arg)
8839 "Force redisplaying of the current article.
8840 If ARG (the prefix) is a number, show the article with the charset
8841 defined in `gnus-summary-show-article-charset-alist', or the charset
8843 If ARG (the prefix) is non-nil and not a number, show the raw article
8844 without any article massaging functions being run. Normally, the key
8845 strokes are `C-u g'."
8849 (gnus-summary-show-article t)
8850 (let ((gnus-newsgroup-charset
8851 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8852 (mm-read-coding-system
8853 "View as charset: " ;; actually it is coding system.
8855 (set-buffer gnus-article-buffer)
8856 (mm-detect-coding-region (point) (point-max))))))
8857 (gnus-newsgroup-ignored-charsets 'gnus-all))
8858 (gnus-summary-select-article nil 'force)
8859 (let ((deps gnus-newsgroup-dependencies)
8862 (set-buffer gnus-original-article-buffer)
8864 (message-narrow-to-head)
8865 (setq head (buffer-string))
8866 (goto-char (point-min))
8867 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8868 (goto-char (point-max))
8870 (setq lines (1- (count-lines (point) (point-max))))))
8872 (insert (format "211 %d Article retrieved.\n"
8873 (cdr gnus-article-current)))
8875 (if lines (insert (format "Lines: %d\n" lines)))
8877 (let ((nntp-server-buffer (current-buffer)))
8878 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8879 (gnus-data-set-header
8880 (gnus-data-find (cdr gnus-article-current))
8882 (gnus-summary-update-article-line
8883 (cdr gnus-article-current) header)
8884 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8885 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8887 ;; Select the article the normal way.
8888 (gnus-summary-select-article nil 'force))
8890 ;; We have to require this here to make sure that the following
8891 ;; dynamic binding isn't shadowed by autoloading.
8892 (require 'gnus-async)
8894 ;; Bind the article treatment functions to nil.
8895 (let ((gnus-have-all-headers t)
8896 gnus-article-prepare-hook
8897 gnus-article-decode-hook
8898 gnus-display-mime-function
8900 ;; Destroy any MIME parts.
8901 (when (gnus-buffer-live-p gnus-article-buffer)
8903 (set-buffer gnus-article-buffer)
8904 (mm-destroy-parts gnus-article-mime-handles)
8905 ;; Set it to nil for safety reason.
8906 (setq gnus-article-mime-handle-alist nil)
8907 (setq gnus-article-mime-handles nil)))
8908 (gnus-summary-select-article nil 'force))))
8909 (gnus-summary-goto-subject gnus-current-article)
8910 (gnus-summary-position-point))
8912 (defun gnus-summary-show-raw-article ()
8913 "Show the raw article without any article massaging functions being run."
8915 (gnus-summary-show-article t))
8917 (defun gnus-summary-verbose-headers (&optional arg)
8918 "Toggle permanent full header display.
8919 If ARG is a positive number, turn header display on.
8920 If ARG is a negative number, turn header display off."
8922 (setq gnus-show-all-headers
8923 (cond ((or (not (numberp arg))
8925 (not gnus-show-all-headers))
8928 (gnus-summary-show-article))
8930 (defun gnus-summary-toggle-header (&optional arg)
8931 "Show the headers if they are hidden, or hide them if they are shown.
8932 If ARG is a positive number, show the entire header.
8933 If ARG is a negative number, hide the unwanted header lines."
8935 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8936 (get-buffer-window gnus-article-buffer t))))
8937 (with-current-buffer gnus-article-buffer
8939 (article-narrow-to-head)
8940 (let* ((buffer-read-only nil)
8941 (inhibit-point-motion-hooks t)
8942 (hidden (if (numberp arg)
8944 (or (not (looking-at "[^ \t\n]+:"))
8945 (gnus-article-hidden-text-p 'headers))))
8947 (delete-region (point-min) (point-max))
8948 (with-current-buffer gnus-original-article-buffer
8949 (goto-char (setq s (point-min)))
8950 (setq e (if (search-forward "\n\n" nil t)
8953 (insert-buffer-substring gnus-original-article-buffer s e)
8954 (run-hooks 'gnus-article-decode-hook)
8956 (let ((gnus-treat-hide-headers nil)
8957 (gnus-treat-hide-boring-headers nil))
8958 (gnus-delete-wash-type 'headers)
8959 (gnus-treat-article 'head))
8960 (gnus-treat-article 'head))
8963 (set-window-start window (goto-char (point-min))))
8964 (if gnus-break-pages
8965 (gnus-narrow-to-page)
8966 (when (gnus-visual-p 'page-marker)
8967 (let ((buffer-read-only nil))
8968 (gnus-remove-text-with-property 'gnus-prev)
8969 (gnus-remove-text-with-property 'gnus-next))))
8970 (gnus-set-mode-line 'article)))))
8972 (defun gnus-summary-show-all-headers ()
8973 "Make all header lines visible."
8975 (gnus-summary-toggle-header 1))
8977 (defun gnus-summary-caesar-message (&optional arg)
8978 "Caesar rotate the current article by 13.
8979 The numerical prefix specifies how many places to rotate each letter
8982 (gnus-summary-select-article)
8983 (let ((mail-header-separator ""))
8984 (gnus-eval-in-buffer-window gnus-article-buffer
8987 (let ((start (window-start))
8989 (message-caesar-buffer-body arg)
8990 (set-window-start (get-buffer-window (current-buffer)) start)))))
8991 ;; Create buttons and stuff...
8992 (gnus-treat-article nil))
8994 (autoload 'unmorse-region "morse"
8995 "Convert morse coded text in region to ordinary ASCII text."
8998 (defun gnus-summary-morse-message (&optional arg)
8999 "Morse decode the current article."
9001 (gnus-summary-select-article)
9002 (let ((mail-header-separator ""))
9003 (gnus-eval-in-buffer-window gnus-article-buffer
9007 (let ((pos (window-start))
9009 (goto-char (point-min))
9010 (when (message-goto-body)
9011 (gnus-narrow-to-body))
9012 (goto-char (point-min))
9013 (while (re-search-forward "·" (point-max) t)
9014 (replace-match "."))
9015 (unmorse-region (point-min) (point-max))
9017 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9019 (defun gnus-summary-stop-page-breaking ()
9020 "Stop page breaking in the current article."
9022 (gnus-summary-select-article)
9023 (gnus-eval-in-buffer-window gnus-article-buffer
9025 (when (gnus-visual-p 'page-marker)
9026 (let ((buffer-read-only nil))
9027 (gnus-remove-text-with-property 'gnus-prev)
9028 (gnus-remove-text-with-property 'gnus-next))
9029 (setq gnus-page-broken nil))))
9031 (defun gnus-summary-move-article (&optional n to-newsgroup
9032 select-method action)
9033 "Move the current article to a different newsgroup.
9034 If N is a positive number, move the N next articles.
9035 If N is a negative number, move the N previous articles.
9036 If N is nil and any articles have been marked with the process mark,
9037 move those articles instead.
9038 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9039 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9040 re-spool using this method.
9042 When called interactively with TO-NEWSGROUP being nil, the value of
9043 the variable `gnus-move-split-methods' is used for finding a default
9044 for the target newsgroup.
9046 For this function to work, both the current newsgroup and the
9047 newsgroup that you want to move to have to support the `request-move'
9048 and `request-accept' functions.
9050 ACTION can be either `move' (the default), `crosspost' or `copy'."
9053 (setq action 'move))
9054 ;; Check whether the source group supports the required functions.
9055 (cond ((and (eq action 'move)
9056 (not (gnus-check-backend-function
9057 'request-move-article gnus-newsgroup-name)))
9058 (error "The current group does not support article moving"))
9059 ((and (eq action 'crosspost)
9060 (not (gnus-check-backend-function
9061 'request-replace-article gnus-newsgroup-name)))
9062 (error "The current group does not support article editing")))
9063 (let ((articles (gnus-summary-work-articles n))
9064 (prefix (if (gnus-check-backend-function
9065 'request-move-article gnus-newsgroup-name)
9066 (gnus-group-real-prefix gnus-newsgroup-name)
9068 (names '((move "Move" "Moving")
9069 (copy "Copy" "Copying")
9070 (crosspost "Crosspost" "Crossposting")))
9071 (copy-buf (save-excursion
9072 (nnheader-set-temp-buffer " *copy article*")))
9073 art-group to-method new-xref article to-groups)
9074 (unless (assq action names)
9075 (error "Unknown action %s" action))
9076 ;; Read the newsgroup name.
9077 (when (and (not to-newsgroup)
9078 (not select-method))
9079 (if (and gnus-move-split-methods
9081 (and (memq gnus-current-article articles)
9082 (gnus-buffer-live-p gnus-original-article-buffer))))
9083 ;; When `gnus-move-split-methods' is non-nil, we have to
9084 ;; select an article to give `gnus-read-move-group-name' an
9085 ;; opportunity to suggest an appropriate default. However,
9086 ;; we needn't render or mark the article.
9087 (let ((gnus-display-mime-function nil)
9088 (gnus-article-prepare-hook nil)
9089 (gnus-mark-article-hook nil))
9090 (gnus-summary-select-article nil nil nil (car articles))))
9092 (gnus-read-move-group-name
9093 (cadr (assq action names))
9094 (symbol-value (intern (format "gnus-current-%s-group" action)))
9096 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9097 (setq to-method (or select-method
9098 (gnus-server-to-method
9099 (gnus-group-method to-newsgroup))))
9100 ;; Check the method we are to move this article to...
9101 (unless (gnus-check-backend-function
9102 'request-accept-article (car to-method))
9103 (error "%s does not support article copying" (car to-method)))
9104 (unless (gnus-check-server to-method)
9105 (error "Can't open server %s" (car to-method)))
9106 (gnus-message 6 "%s to %s: %s..."
9107 (caddr (assq action names))
9108 (or (car select-method) to-newsgroup) articles)
9110 (setq article (pop articles))
9114 ;; Move the article.
9116 ;; Remove this article from future suppression.
9117 (gnus-dup-unsuppress-article article)
9118 (gnus-request-move-article
9119 article ; Article to move
9120 gnus-newsgroup-name ; From newsgroup
9121 (nth 1 (gnus-find-method-for-group
9122 gnus-newsgroup-name)) ; Server
9123 (list 'gnus-request-accept-article
9124 to-newsgroup (list 'quote select-method)
9125 (not articles) t) ; Accept form
9126 (not articles))) ; Only save nov last time
9127 ;; Copy the article.
9130 (set-buffer copy-buf)
9131 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9132 (gnus-request-accept-article
9133 to-newsgroup select-method (not articles) t))))
9134 ;; Crosspost the article.
9135 ((eq action 'crosspost)
9136 (let ((xref (message-tokenize-header
9137 (mail-header-xref (gnus-summary-article-header article))
9139 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9140 ":" (number-to-string article)))
9142 (setq xref (list (system-name))))
9145 (mapconcat 'identity
9146 (delete "Xref:" (delete new-xref xref))
9150 (set-buffer copy-buf)
9151 ;; First put the article in the destination group.
9152 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9153 (when (consp (setq art-group
9154 (gnus-request-accept-article
9155 to-newsgroup select-method (not articles))))
9156 (setq new-xref (concat new-xref " " (car art-group)
9158 (number-to-string (cdr art-group))))
9159 ;; Now we have the new Xrefs header, so we insert
9160 ;; it and replace the new article.
9161 (nnheader-replace-header "Xref" new-xref)
9162 (gnus-request-replace-article
9163 (cdr art-group) to-newsgroup (current-buffer))
9167 (gnus-message 1 "Couldn't %s article %s: %s"
9168 (cadr (assq action names)) article
9169 (nnheader-get-report (car to-method))))
9170 ((eq art-group 'junk)
9171 (when (eq action 'move)
9172 (gnus-summary-mark-article article gnus-canceled-mark)
9173 (gnus-message 4 "Deleted article %s" article)
9174 ;; run the delete hook
9175 (run-hook-with-args 'gnus-summary-article-delete-hook
9178 (assoc article (gnus-data-list nil)))
9179 gnus-newsgroup-name nil
9182 (let* ((pto-group (gnus-group-prefixed-name
9183 (car art-group) to-method))
9185 (gnus-gethash pto-group gnus-newsrc-hashtb))
9186 (info (nth 2 entry))
9187 (to-group (gnus-info-group info))
9189 ;; Update the group that has been moved to.
9191 (memq action '(move copy)))
9192 (unless (member to-group to-groups)
9193 (push to-group to-groups))
9195 (unless (memq article gnus-newsgroup-unreads)
9196 (push 'read to-marks)
9198 info (gnus-add-to-range (gnus-info-read info)
9199 (list (cdr art-group)))))
9201 ;; See whether the article is to be put in the cache.
9202 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9203 gnus-article-mark-lists
9204 (delete '(expirable . expire)
9205 (copy-sequence gnus-article-mark-lists))))
9206 (to-article (cdr art-group)))
9208 ;; Enter the article into the cache in the new group,
9209 ;; if that is required.
9210 (when gnus-use-cache
9211 (gnus-cache-possibly-enter-article
9213 (memq article gnus-newsgroup-marked)
9214 (memq article gnus-newsgroup-dormant)
9215 (memq article gnus-newsgroup-unreads)))
9217 (when gnus-preserve-marks
9218 ;; Copy any marks over to the new group.
9219 (when (and (equal to-group gnus-newsgroup-name)
9220 (not (memq article gnus-newsgroup-unreads)))
9221 ;; Mark this article as read in this group.
9222 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9223 (setcdr (gnus-active to-group) to-article)
9224 (setcdr gnus-newsgroup-active to-article))
9227 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9228 (when (memq article (symbol-value
9229 (intern (format "gnus-newsgroup-%s"
9231 (push (cdar marks) to-marks)
9232 ;; If the other group is the same as this group,
9233 ;; then we have to add the mark to the list.
9234 (when (equal to-group gnus-newsgroup-name)
9235 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9238 (intern (format "gnus-newsgroup-%s"
9240 ;; Copy the marks to other group.
9241 (gnus-add-marked-articles
9242 to-group (cdar marks) (list to-article) info)))
9243 (setq marks (cdr marks)))
9245 (gnus-request-set-mark
9246 to-group (list (list (list to-article) 'add to-marks))))
9249 (concat "(gnus-group-set-info '"
9250 (gnus-prin1-to-string (gnus-get-info to-group))
9253 ;; Update the Xref header in this article to point to
9254 ;; the new crossposted article we have just created.
9255 (when (eq action 'crosspost)
9257 (set-buffer copy-buf)
9258 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9259 (nnheader-replace-header "Xref" new-xref)
9260 (gnus-request-replace-article
9261 article gnus-newsgroup-name (current-buffer))))
9263 ;; run the move/copy/crosspost/respool hook
9264 (run-hook-with-args 'gnus-summary-article-move-hook
9267 (assoc article (gnus-data-list nil)))
9272 ;;;!!!Why is this necessary?
9273 (set-buffer gnus-summary-buffer)
9275 (gnus-summary-goto-subject article)
9276 (when (eq action 'move)
9277 (gnus-summary-mark-article article gnus-canceled-mark))))
9278 (gnus-summary-remove-process-mark article))
9279 ;; Re-activate all groups that have been moved to.
9281 (set-buffer gnus-group-buffer)
9282 (let ((gnus-group-marked to-groups))
9283 (gnus-group-get-new-news-this-group nil t)))
9285 (gnus-kill-buffer copy-buf)
9286 (gnus-summary-position-point)
9287 (gnus-set-mode-line 'summary)))
9289 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9290 "Copy the current article to some other group.
9291 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9292 When called interactively, if TO-NEWSGROUP is nil, use the value of
9293 the variable `gnus-move-split-methods' for finding a default target
9295 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9296 re-spool using this method."
9298 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9300 (defun gnus-summary-crosspost-article (&optional n)
9301 "Crosspost the current article to some other group."
9303 (gnus-summary-move-article n nil nil 'crosspost))
9305 (defcustom gnus-summary-respool-default-method nil
9306 "Default method type for respooling an article.
9307 If nil, use to the current newsgroup method."
9309 :group 'gnus-summary-mail)
9311 (defcustom gnus-summary-display-while-building nil
9312 "If non-nil, show and update the summary buffer as it's being built.
9313 If the value is t, update the buffer after every line is inserted. If
9314 the value is an integer (N), update the display every N lines."
9317 :type '(choice (const :tag "off" nil)
9319 (const :tag "frequently" t)))
9321 (defun gnus-summary-respool-article (&optional n method)
9322 "Respool the current article.
9323 The article will be squeezed through the mail spooling process again,
9324 which means that it will be put in some mail newsgroup or other
9325 depending on `nnmail-split-methods'.
9326 If N is a positive number, respool the N next articles.
9327 If N is a negative number, respool the N previous articles.
9328 If N is nil and any articles have been marked with the process mark,
9329 respool those articles instead.
9331 Respooling can be done both from mail groups and \"real\" newsgroups.
9332 In the former case, the articles in question will be moved from the
9333 current group into whatever groups they are destined to. In the
9334 latter case, they will be copied into the relevant groups."
9336 (list current-prefix-arg
9337 (let* ((methods (gnus-methods-using 'respool))
9339 (symbol-name (or gnus-summary-respool-default-method
9340 (car (gnus-find-method-for-group
9341 gnus-newsgroup-name)))))
9343 (gnus-completing-read-with-default
9344 methname "Backend to use when respooling"
9345 methods nil t nil 'gnus-mail-method-history))
9348 ((zerop (length (setq ms (gnus-servers-using-backend
9350 (list (intern method) ""))
9354 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9355 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9358 (error "No method given for respooling"))
9359 (if (assoc (symbol-name
9360 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9361 (gnus-methods-using 'respool))
9362 (gnus-summary-move-article n nil method)
9363 (gnus-summary-copy-article n nil method)))
9365 (defun gnus-summary-import-article (file &optional edit)
9366 "Import an arbitrary file into a mail newsgroup."
9367 (interactive "fImport file: \nP")
9368 (let ((group gnus-newsgroup-name)
9369 (now (current-time))
9370 atts lines group-art)
9371 (unless (gnus-check-backend-function 'request-accept-article group)
9372 (error "%s does not support article importing" group))
9373 (or (file-readable-p file)
9374 (not (file-regular-p file))
9375 (error "Can't read %s" file))
9377 (set-buffer (gnus-get-buffer-create " *import file*"))
9379 (nnheader-insert-file-contents file)
9380 (goto-char (point-min))
9381 (if (nnheader-article-p)
9383 (goto-char (point-min))
9384 (search-forward "\n\n" nil t)
9385 (narrow-to-region (point-min) (1- (point)))
9386 (goto-char (point-min))
9387 (unless (re-search-forward "^date:" nil t)
9388 (goto-char (point-max))
9389 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9390 ;; This doesn't look like an article, so we fudge some headers.
9391 (setq atts (file-attributes file)
9392 lines (count-lines (point-min) (point-max)))
9393 (insert "From: " (read-string "From: ") "\n"
9394 "Subject: " (read-string "Subject: ") "\n"
9395 "Date: " (message-make-date (nth 5 atts)) "\n"
9396 "Message-ID: " (message-make-message-id) "\n"
9397 "Lines: " (int-to-string lines) "\n"
9398 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9399 (setq group-art (gnus-request-accept-article group nil t))
9400 (kill-buffer (current-buffer)))
9401 (setq gnus-newsgroup-active (gnus-activate-group group))
9403 (gnus-summary-goto-article (cdr group-art) nil t)
9405 (gnus-summary-edit-article))))
9407 (defun gnus-summary-create-article ()
9408 "Create an article in a mail newsgroup."
9410 (let ((group gnus-newsgroup-name)
9411 (now (current-time))
9413 (unless (gnus-check-backend-function 'request-accept-article group)
9414 (error "%s does not support article importing" group))
9416 (set-buffer (gnus-get-buffer-create " *import file*"))
9418 (goto-char (point-min))
9419 ;; This doesn't look like an article, so we fudge some headers.
9420 (insert "From: " (read-string "From: ") "\n"
9421 "Subject: " (read-string "Subject: ") "\n"
9422 "Date: " (message-make-date now) "\n"
9423 "Message-ID: " (message-make-message-id) "\n")
9424 (setq group-art (gnus-request-accept-article group nil t))
9425 (kill-buffer (current-buffer)))
9426 (setq gnus-newsgroup-active (gnus-activate-group group))
9428 (gnus-summary-goto-article (cdr group-art) nil t)
9429 (gnus-summary-edit-article)))
9431 (defun gnus-summary-article-posted-p ()
9432 "Say whether the current (mail) article is available from news as well.
9433 This will be the case if the article has both been mailed and posted."
9435 (let ((id (mail-header-references (gnus-summary-article-header)))
9436 (gnus-override-method (car (gnus-refer-article-methods))))
9437 (if (gnus-request-head id "")
9438 (gnus-message 2 "The current message was found on %s"
9439 gnus-override-method)
9440 (gnus-message 2 "The current message couldn't be found on %s"
9441 gnus-override-method)
9444 (defun gnus-summary-expire-articles (&optional now)
9445 "Expire all articles that are marked as expirable in the current group."
9447 (when (and (not gnus-group-is-exiting-without-update-p)
9448 (gnus-check-backend-function
9449 'request-expire-articles gnus-newsgroup-name))
9450 ;; This backend supports expiry.
9451 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9452 (expirable (if total
9454 ;; We need to update the info for
9455 ;; this group for `gnus-list-of-read-articles'
9456 ;; to give us the right answer.
9457 (gnus-run-hooks 'gnus-exit-group-hook)
9458 (gnus-summary-update-info)
9459 (gnus-list-of-read-articles gnus-newsgroup-name))
9460 (setq gnus-newsgroup-expirable
9461 (sort gnus-newsgroup-expirable '<))))
9462 (expiry-wait (if now 'immediate
9463 (gnus-group-find-parameter
9464 gnus-newsgroup-name 'expiry-wait)))
9465 (nnmail-expiry-target
9466 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9467 nnmail-expiry-target))
9470 ;; There are expirable articles in this group, so we run them
9471 ;; through the expiry process.
9472 (gnus-message 6 "Expiring articles...")
9473 (unless (gnus-check-group gnus-newsgroup-name)
9474 (error "Can't open server for %s" gnus-newsgroup-name))
9475 ;; The list of articles that weren't expired is returned.
9478 (let ((nnmail-expiry-wait-function nil)
9479 (nnmail-expiry-wait expiry-wait))
9480 (setq es (gnus-request-expire-articles
9481 expirable gnus-newsgroup-name)))
9482 (setq es (gnus-request-expire-articles
9483 expirable gnus-newsgroup-name)))
9485 (setq gnus-newsgroup-expirable es))
9486 ;; We go through the old list of expirable, and mark all
9487 ;; really expired articles as nonexistent.
9488 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9489 (let ((gnus-use-cache nil))
9490 (dolist (article expirable)
9491 (when (and (not (memq article es))
9492 (gnus-data-find article))
9493 (gnus-summary-mark-article article gnus-canceled-mark)
9494 (run-hook-with-args 'gnus-summary-article-expire-hook
9497 (assoc article (gnus-data-list nil)))
9501 (gnus-message 6 "Expiring articles...done")))))
9503 (defun gnus-summary-expire-articles-now ()
9504 "Expunge all expirable articles in the current group.
9505 This means that *all* articles that are marked as expirable will be
9506 deleted forever, right now."
9508 (or gnus-expert-user
9510 "Are you really, really, really sure you want to delete all these messages? ")
9512 (gnus-summary-expire-articles t))
9514 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9515 (defun gnus-summary-delete-article (&optional n)
9516 "Delete the N next (mail) articles.
9517 This command actually deletes articles. This is not a marking
9518 command. The article will disappear forever from your life, never to
9521 If N is negative, delete backwards.
9522 If N is nil and articles have been marked with the process mark,
9523 delete these instead.
9525 If `gnus-novice-user' is non-nil you will be asked for
9526 confirmation before the articles are deleted."
9528 (unless (gnus-check-backend-function 'request-expire-articles
9529 gnus-newsgroup-name)
9530 (error "The current newsgroup does not support article deletion"))
9531 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9532 (error "Couldn't open server"))
9533 ;; Compute the list of articles to delete.
9534 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9535 (nnmail-expiry-target 'delete)
9537 (if (and gnus-novice-user
9538 (not (gnus-yes-or-no-p
9539 (format "Do you really want to delete %s forever? "
9540 (if (> (length articles) 1)
9541 (format "these %s articles" (length articles))
9544 ;; Delete the articles.
9545 (setq not-deleted (gnus-request-expire-articles
9546 articles gnus-newsgroup-name 'force))
9548 (gnus-summary-remove-process-mark (car articles))
9549 ;; The backend might not have been able to delete the article
9551 (unless (memq (car articles) not-deleted)
9552 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9553 (let* ((article (car articles))
9554 (id (mail-header-id (gnus-data-header
9555 (assoc article (gnus-data-list nil))))))
9556 (run-hook-with-args 'gnus-summary-article-delete-hook
9557 'delete id gnus-newsgroup-name nil
9559 (setq articles (cdr articles)))
9561 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9562 (gnus-summary-position-point)
9563 (gnus-set-mode-line 'summary)
9566 (defun gnus-summary-edit-article (&optional arg)
9567 "Edit the current article.
9568 This will have permanent effect only in mail groups.
9569 If ARG is nil, edit the decoded articles.
9570 If ARG is 1, edit the raw articles.
9571 If ARG is 2, edit the raw articles even in read-only groups.
9572 If ARG is 3, edit the articles with the current handles.
9573 Otherwise, allow editing of articles even in read-only
9576 (let (force raw current-handles)
9585 (setq current-handles
9586 (and (gnus-buffer-live-p gnus-article-buffer)
9587 (with-current-buffer gnus-article-buffer
9589 gnus-article-mime-handles
9590 (setq gnus-article-mime-handles nil))))))
9593 (when (and raw (not force)
9594 (member gnus-newsgroup-name '("nndraft:delayed"
9597 (error "Can't edit the raw article in group %s"
9598 gnus-newsgroup-name))
9600 (set-buffer gnus-summary-buffer)
9601 (let ((mail-parse-charset gnus-newsgroup-charset)
9602 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9603 (gnus-set-global-variables)
9604 (when (and (not force)
9605 (gnus-group-read-only-p))
9606 (error "The current newsgroup does not support article editing"))
9607 (gnus-summary-show-article t)
9608 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9609 (with-current-buffer gnus-article-buffer
9610 (mm-enable-multibyte)))
9611 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9613 (gnus-article-edit-article
9616 (let ((mbl mml-buffer-list))
9617 (setq mml-buffer-list nil)
9618 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9619 (mime-to-mml ,'current-handles))
9620 (let ((mbl1 mml-buffer-list))
9621 (setq mml-buffer-list mbl)
9622 (set (make-local-variable 'mml-buffer-list) mbl1))
9623 (gnus-make-local-hook 'kill-buffer-hook)
9624 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9625 `(lambda (no-highlight)
9626 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9627 (message-options message-options)
9628 (message-options-set-recipient)
9629 (mail-parse-ignored-charsets
9630 ',gnus-newsgroup-ignored-charsets))
9631 ,(if (not raw) '(progn
9633 (mml-destroy-buffers)
9634 (remove-hook 'kill-buffer-hook
9635 'mml-destroy-buffers t)
9636 (kill-local-variable 'mml-buffer-list)))
9637 (gnus-summary-edit-article-done
9638 ,(or (mail-header-references gnus-current-headers) "")
9639 ,(gnus-group-read-only-p)
9640 ,gnus-summary-buffer no-highlight))))))))
9642 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9644 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9646 "Make edits to the current article permanent."
9649 ;; The buffer restriction contains the entire article if it exists.
9650 (when (article-goto-body)
9651 (let ((lines (count-lines (point) (point-max)))
9652 (length (- (point-max) (point)))
9653 (case-fold-search t)
9654 (body (copy-marker (point))))
9655 (goto-char (point-min))
9656 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9657 (delete-region (match-beginning 1) (match-end 1))
9658 (insert (number-to-string length)))
9659 (goto-char (point-min))
9660 (when (re-search-forward
9661 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9662 (delete-region (match-beginning 1) (match-end 1))
9663 (insert (number-to-string length)))
9664 (goto-char (point-min))
9665 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9666 (delete-region (match-beginning 1) (match-end 1))
9667 (insert (number-to-string lines))))))
9668 ;; Replace the article.
9669 (let ((buf (current-buffer)))
9671 (insert-buffer-substring buf)
9673 (if (and (not read-only)
9674 (not (gnus-request-replace-article
9675 (cdr gnus-article-current) (car gnus-article-current)
9676 (current-buffer) t)))
9677 (error "Couldn't replace article")
9678 ;; Update the summary buffer.
9680 (equal (message-tokenize-header references " ")
9681 (message-tokenize-header
9682 (or (message-fetch-field "references") "") " ")))
9683 ;; We only have to update this line.
9686 (message-narrow-to-head)
9687 (let ((head (buffer-substring-no-properties
9688 (point-min) (point-max)))
9691 (insert (format "211 %d Article retrieved.\n"
9692 (cdr gnus-article-current)))
9695 (let ((nntp-server-buffer (current-buffer)))
9696 (setq header (car (gnus-get-newsgroup-headers
9699 (set-buffer gnus-summary-buffer)
9700 (gnus-data-set-header
9701 (gnus-data-find (cdr gnus-article-current))
9703 (gnus-summary-update-article-line
9704 (cdr gnus-article-current) header)
9705 (if (gnus-summary-goto-subject
9706 (cdr gnus-article-current) nil t)
9707 (gnus-summary-update-secondary-mark
9708 (cdr gnus-article-current))))))))
9710 (set-buffer (or buffer gnus-summary-buffer))
9711 (gnus-summary-update-article (cdr gnus-article-current))
9712 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9713 (gnus-summary-update-secondary-mark
9714 (cdr gnus-article-current))))
9715 ;; Prettify the article buffer again.
9716 (unless no-highlight
9718 (set-buffer gnus-article-buffer)
9719 ;;;!!! Fix this -- article should be rehighlighted.
9720 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9721 (set-buffer gnus-original-article-buffer)
9722 (gnus-request-article
9723 (cdr gnus-article-current)
9724 (car gnus-article-current) (current-buffer))))
9725 ;; Prettify the summary buffer line.
9726 (when (gnus-visual-p 'summary-highlight 'highlight)
9727 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9729 (defun gnus-summary-edit-wash (key)
9730 "Perform editing command KEY in the article buffer."
9734 (message "%s" (concat (this-command-keys) "- "))
9737 (gnus-summary-edit-article)
9738 (execute-kbd-macro (concat (this-command-keys) key))
9739 (gnus-article-edit-done))
9743 (defun gnus-summary-respool-query (&optional silent trace)
9744 "Query where the respool algorithm would put this article."
9746 (let (gnus-mark-article-hook)
9747 (gnus-summary-select-article)
9749 (set-buffer gnus-original-article-buffer)
9750 (let ((groups (nnmail-article-group 'identity trace)))
9753 (message "This message would go to %s"
9754 (mapconcat 'car groups ", "))
9755 (message "This message would go to no groups"))
9758 (defun gnus-summary-respool-trace ()
9759 "Trace where the respool algorithm would put this article.
9760 Display a buffer showing all fancy splitting patterns which matched."
9762 (gnus-summary-respool-query nil t))
9764 ;; Summary marking commands.
9766 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9767 "Mark articles which has the same subject as read, and then select the next.
9768 If UNMARK is positive, remove any kind of mark.
9769 If UNMARK is negative, tick articles."
9772 (setq unmark (prefix-numeric-value unmark)))
9774 (gnus-summary-mark-same-subject
9775 (gnus-summary-article-subject) unmark)))
9776 ;; Select next unread article. If auto-select-same mode, should
9777 ;; select the first unread article.
9778 (gnus-summary-next-article t (and gnus-auto-select-same
9779 (gnus-summary-article-subject)))
9780 (gnus-message 7 "%d article%s marked as %s"
9781 count (if (= count 1) " is" "s are")
9782 (if unmark "unread" "read"))))
9784 (defun gnus-summary-kill-same-subject (&optional unmark)
9785 "Mark articles which has the same subject as read.
9786 If UNMARK is positive, remove any kind of mark.
9787 If UNMARK is negative, tick articles."
9790 (setq unmark (prefix-numeric-value unmark)))
9792 (gnus-summary-mark-same-subject
9793 (gnus-summary-article-subject) unmark)))
9794 ;; If marked as read, go to next unread subject.
9796 ;; Go to next unread subject.
9797 (gnus-summary-next-subject 1 t))
9798 (gnus-message 7 "%d articles are marked as %s"
9799 count (if unmark "unread" "read"))))
9801 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9802 "Mark articles with same SUBJECT as read, and return marked number.
9803 If optional argument UNMARK is positive, remove any kinds of marks.
9804 If optional argument UNMARK is negative, mark articles as unread instead."
9808 ((null unmark) ; Mark as read.
9811 (gnus-summary-mark-article-as-read gnus-killed-mark)
9812 (gnus-summary-show-thread) t)
9813 (gnus-summary-find-subject subject))
9814 (setq count (1+ count))))
9815 ((> unmark 0) ; Tick.
9818 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9819 (gnus-summary-show-thread) t)
9820 (gnus-summary-find-subject subject))
9821 (setq count (1+ count))))
9822 (t ; Mark as unread.
9825 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9826 (gnus-summary-show-thread) t)
9827 (gnus-summary-find-subject subject))
9828 (setq count (1+ count)))))
9829 (gnus-set-mode-line 'summary)
9830 ;; Return the number of marked articles.
9833 (defun gnus-summary-mark-as-processable (n &optional unmark)
9834 "Set the process mark on the next N articles.
9835 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9836 the process mark instead. The difference between N and the actual
9837 number of articles marked is returned."
9839 (if (and (null n) (gnus-region-active-p))
9840 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9841 (setq n (prefix-numeric-value n))
9842 (let ((backward (< n 0))
9847 (gnus-summary-remove-process-mark
9848 (gnus-summary-article-number))
9849 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9850 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9853 (gnus-message 7 "No more articles"))
9854 (gnus-summary-recenter)
9855 (gnus-summary-position-point)
9858 (defun gnus-summary-unmark-as-processable (n)
9859 "Remove the process mark from the next N articles.
9860 If N is negative, unmark backward instead. The difference between N and
9861 the actual number of articles unmarked is returned."
9863 (gnus-summary-mark-as-processable n t))
9865 (defun gnus-summary-unmark-all-processable ()
9866 "Remove the process mark from all articles."
9869 (while gnus-newsgroup-processable
9870 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9871 (gnus-summary-position-point))
9873 (defun gnus-summary-add-mark (article type)
9874 "Mark ARTICLE with a mark of TYPE."
9875 (let ((vtype (car (assq type gnus-article-mark-lists)))
9878 (error "No such mark type: %s" type)
9879 (setq var (intern (format "gnus-newsgroup-%s" type)))
9880 (set var (cons article (symbol-value var)))
9881 (if (memq type '(processable cached replied forwarded recent saved))
9882 (gnus-summary-update-secondary-mark article)
9883 ;;; !!! This is bogus. We should find out what primary
9884 ;;; !!! mark we want to set.
9885 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9887 (defun gnus-summary-mark-as-expirable (n)
9888 "Mark N articles forward as expirable.
9889 If N is negative, mark backward instead. The difference between N and
9890 the actual number of articles marked is returned."
9892 (gnus-summary-mark-forward n gnus-expirable-mark))
9894 (defun gnus-summary-mark-as-spam (n)
9895 "Mark N articles forward as spam.
9896 If N is negative, mark backward instead. The difference between N and
9897 the actual number of articles marked is returned."
9899 (gnus-summary-mark-forward n gnus-spam-mark))
9901 (defun gnus-summary-mark-article-as-replied (article)
9902 "Mark ARTICLE as replied to and update the summary line.
9903 ARTICLE can also be a list of articles."
9904 (interactive (list (gnus-summary-article-number)))
9905 (let ((articles (if (listp article) article (list article))))
9906 (dolist (article articles)
9907 (unless (numberp article)
9908 (error "%s is not a number" article))
9909 (push article gnus-newsgroup-replied)
9910 (let ((buffer-read-only nil))
9911 (when (gnus-summary-goto-subject article nil t)
9912 (gnus-summary-update-secondary-mark article))))))
9914 (defun gnus-summary-mark-article-as-forwarded (article)
9915 "Mark ARTICLE as forwarded and update the summary line.
9916 ARTICLE can also be a list of articles."
9917 (let ((articles (if (listp article) article (list article))))
9918 (dolist (article articles)
9919 (push article gnus-newsgroup-forwarded)
9920 (let ((buffer-read-only nil))
9921 (when (gnus-summary-goto-subject article nil t)
9922 (gnus-summary-update-secondary-mark article))))))
9924 (defun gnus-summary-set-bookmark (article)
9925 "Set a bookmark in current article."
9926 (interactive (list (gnus-summary-article-number)))
9927 (when (or (not (get-buffer gnus-article-buffer))
9928 (not gnus-current-article)
9929 (not gnus-article-current)
9930 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9931 (error "No current article selected"))
9932 ;; Remove old bookmark, if one exists.
9933 (gnus-pull article gnus-newsgroup-bookmarks)
9934 ;; Set the new bookmark, which is on the form
9935 ;; (article-number . line-number-in-body).
9939 (set-buffer gnus-article-buffer)
9946 gnus-newsgroup-bookmarks)
9947 (gnus-message 6 "A bookmark has been added to the current article."))
9949 (defun gnus-summary-remove-bookmark (article)
9950 "Remove the bookmark from the current article."
9951 (interactive (list (gnus-summary-article-number)))
9952 ;; Remove old bookmark, if one exists.
9953 (if (not (assq article gnus-newsgroup-bookmarks))
9954 (gnus-message 6 "No bookmark in current article.")
9955 (gnus-pull article gnus-newsgroup-bookmarks)
9956 (gnus-message 6 "Removed bookmark.")))
9958 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9959 (defun gnus-summary-mark-as-dormant (n)
9960 "Mark N articles forward as dormant.
9961 If N is negative, mark backward instead. The difference between N and
9962 the actual number of articles marked is returned."
9964 (gnus-summary-mark-forward n gnus-dormant-mark))
9966 (defun gnus-summary-set-process-mark (article)
9967 "Set the process mark on ARTICLE and update the summary line."
9968 (setq gnus-newsgroup-processable
9970 (delq article gnus-newsgroup-processable)))
9971 (when (gnus-summary-goto-subject article)
9972 (gnus-summary-show-thread)
9973 (gnus-summary-goto-subject article)
9974 (gnus-summary-update-secondary-mark article)))
9976 (defun gnus-summary-remove-process-mark (article)
9977 "Remove the process mark from ARTICLE and update the summary line."
9978 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9979 (when (gnus-summary-goto-subject article)
9980 (gnus-summary-show-thread)
9981 (gnus-summary-goto-subject article)
9982 (gnus-summary-update-secondary-mark article)))
9984 (defun gnus-summary-set-saved-mark (article)
9985 "Set the process mark on ARTICLE and update the summary line."
9986 (push article gnus-newsgroup-saved)
9987 (when (gnus-summary-goto-subject article)
9988 (gnus-summary-update-secondary-mark article)))
9990 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9991 "Mark N articles as read forwards.
9992 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9993 The difference between N and the actual number of articles marked is
9995 If NO-EXPIRE, auto-expiry will be inhibited."
9997 (gnus-summary-show-thread)
9998 (let ((backward (< n 0))
9999 (gnus-summary-goto-unread
10000 (and gnus-summary-goto-unread
10001 (not (eq gnus-summary-goto-unread 'never))
10002 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10003 gnus-ticked-mark gnus-dormant-mark)))))
10005 (mark (or mark gnus-del-mark)))
10006 (while (and (> n 0)
10007 (gnus-summary-mark-article nil mark no-expire)
10008 (zerop (gnus-summary-next-subject
10010 (and gnus-summary-goto-unread
10011 (not (eq gnus-summary-goto-unread 'never)))
10015 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10016 (gnus-summary-recenter)
10017 (gnus-summary-position-point)
10018 (gnus-set-mode-line 'summary)
10021 (defun gnus-summary-mark-article-as-read (mark)
10022 "Mark the current article quickly as read with MARK."
10023 (let ((article (gnus-summary-article-number)))
10024 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10025 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10026 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10027 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10028 (push (cons article mark) gnus-newsgroup-reads)
10029 ;; Possibly remove from cache, if that is used.
10030 (when gnus-use-cache
10031 (gnus-cache-enter-remove-article article))
10032 ;; Allow the backend to change the mark.
10033 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10034 ;; Check for auto-expiry.
10035 (when (and gnus-newsgroup-auto-expire
10036 (memq mark gnus-auto-expirable-marks))
10037 (setq mark gnus-expirable-mark)
10038 ;; Let the backend know about the mark change.
10039 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10040 (push article gnus-newsgroup-expirable))
10041 ;; Set the mark in the buffer.
10042 (gnus-summary-update-mark mark 'unread)
10045 (defun gnus-summary-mark-article-as-unread (mark)
10046 "Mark the current article quickly as unread with MARK."
10047 (let* ((article (gnus-summary-article-number))
10048 (old-mark (gnus-summary-article-mark article)))
10049 ;; Allow the backend to change the mark.
10050 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10051 (if (eq mark old-mark)
10055 (gnus-error 1 "Can't mark negative article numbers")
10057 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10058 (setq gnus-newsgroup-spam-marked
10059 (delq article gnus-newsgroup-spam-marked))
10060 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10061 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10062 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10063 (cond ((= mark gnus-ticked-mark)
10064 (setq gnus-newsgroup-marked
10065 (gnus-add-to-sorted-list gnus-newsgroup-marked
10067 ((= mark gnus-spam-mark)
10068 (setq gnus-newsgroup-spam-marked
10069 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10071 ((= mark gnus-dormant-mark)
10072 (setq gnus-newsgroup-dormant
10073 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10076 (setq gnus-newsgroup-unreads
10077 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10079 (gnus-pull article gnus-newsgroup-reads)
10081 ;; See whether the article is to be put in the cache.
10082 (and gnus-use-cache
10083 (vectorp (gnus-summary-article-header article))
10085 (gnus-cache-possibly-enter-article
10086 gnus-newsgroup-name article
10087 (= mark gnus-ticked-mark)
10088 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10091 (gnus-summary-update-mark mark 'unread)
10094 (defun gnus-summary-mark-article (&optional article mark no-expire)
10095 "Mark ARTICLE with MARK. MARK can be any character.
10096 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10097 `??' (dormant) and `?E' (expirable).
10098 If MARK is nil, then the default character `?r' is used.
10099 If ARTICLE is nil, then the article on the current line will be
10101 If NO-EXPIRE, auto-expiry will be inhibited."
10102 ;; The mark might be a string.
10103 (when (stringp mark)
10104 (setq mark (aref mark 0)))
10105 ;; If no mark is given, then we check auto-expiring.
10107 (setq mark gnus-del-mark))
10108 (when (and (not no-expire)
10109 gnus-newsgroup-auto-expire
10110 (memq mark gnus-auto-expirable-marks))
10111 (setq mark gnus-expirable-mark))
10112 (let ((article (or article (gnus-summary-article-number)))
10113 (old-mark (gnus-summary-article-mark article)))
10114 ;; Allow the backend to change the mark.
10115 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10116 (if (eq mark old-mark)
10119 (error "No article on current line"))
10120 (if (not (if (or (= mark gnus-unread-mark)
10121 (= mark gnus-ticked-mark)
10122 (= mark gnus-spam-mark)
10123 (= mark gnus-dormant-mark))
10124 (gnus-mark-article-as-unread article mark)
10125 (gnus-mark-article-as-read article mark)))
10127 ;; See whether the article is to be put in the cache.
10128 (and gnus-use-cache
10129 (not (= mark gnus-canceled-mark))
10130 (vectorp (gnus-summary-article-header article))
10132 (gnus-cache-possibly-enter-article
10133 gnus-newsgroup-name article
10134 (= mark gnus-ticked-mark)
10135 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10137 (when (gnus-summary-goto-subject article nil t)
10138 (let ((buffer-read-only nil))
10139 (gnus-summary-show-thread)
10141 (gnus-summary-update-mark mark 'unread)
10144 (defun gnus-summary-update-secondary-mark (article)
10145 "Update the secondary (read, process, cache) mark."
10146 (gnus-summary-update-mark
10147 (cond ((memq article gnus-newsgroup-processable)
10149 ((memq article gnus-newsgroup-cached)
10151 ((memq article gnus-newsgroup-replied)
10153 ((memq article gnus-newsgroup-forwarded)
10154 gnus-forwarded-mark)
10155 ((memq article gnus-newsgroup-saved)
10157 ((memq article gnus-newsgroup-recent)
10159 ((memq article gnus-newsgroup-unseen)
10163 (when (gnus-visual-p 'summary-highlight 'highlight)
10164 (gnus-run-hooks 'gnus-summary-update-hook))
10167 (defun gnus-summary-update-download-mark (article)
10168 "Update the download mark."
10169 (gnus-summary-update-mark
10170 (cond ((memq article gnus-newsgroup-undownloaded)
10171 gnus-undownloaded-mark)
10172 (gnus-newsgroup-agentized
10173 gnus-downloaded-mark)
10177 (gnus-summary-update-line t)
10180 (defun gnus-summary-update-mark (mark type)
10181 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10182 (buffer-read-only nil))
10183 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10185 (when (looking-at "\r")
10187 (when (<= (+ forward (point)) (point-max))
10188 ;; Go to the right position on the line.
10189 (goto-char (+ forward (point)))
10190 ;; Replace the old mark with the new mark.
10191 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10192 ;; Optionally update the marks by some user rule.
10193 (when (eq type 'unread)
10194 (gnus-data-set-mark
10195 (gnus-data-find (gnus-summary-article-number)) mark)
10196 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10198 (defun gnus-mark-article-as-read (article &optional mark)
10199 "Enter ARTICLE in the pertinent lists and remove it from others."
10200 ;; Make the article expirable.
10201 (let ((mark (or mark gnus-del-mark)))
10202 (setq gnus-newsgroup-expirable
10203 (if (= mark gnus-expirable-mark)
10204 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10205 (delq article gnus-newsgroup-expirable)))
10206 ;; Remove from unread and marked lists.
10207 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10208 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10209 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10210 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10211 (push (cons article mark) gnus-newsgroup-reads)
10212 ;; Possibly remove from cache, if that is used.
10213 (when gnus-use-cache
10214 (gnus-cache-enter-remove-article article))
10217 (defun gnus-mark-article-as-unread (article &optional mark)
10218 "Enter ARTICLE in the pertinent lists and remove it from others."
10219 (let ((mark (or mark gnus-ticked-mark)))
10222 (gnus-error 1 "Can't mark negative article numbers")
10224 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10225 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10226 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10227 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10228 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10230 ;; Unsuppress duplicates?
10231 (when gnus-suppress-duplicates
10232 (gnus-dup-unsuppress-article article))
10234 (cond ((= mark gnus-ticked-mark)
10235 (setq gnus-newsgroup-marked
10236 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10237 ((= mark gnus-spam-mark)
10238 (setq gnus-newsgroup-spam-marked
10239 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10241 ((= mark gnus-dormant-mark)
10242 (setq gnus-newsgroup-dormant
10243 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10245 (setq gnus-newsgroup-unreads
10246 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10247 (gnus-pull article gnus-newsgroup-reads)
10250 (defalias 'gnus-summary-mark-as-unread-forward
10251 'gnus-summary-tick-article-forward)
10252 (make-obsolete 'gnus-summary-mark-as-unread-forward
10253 'gnus-summary-tick-article-forward)
10254 (defun gnus-summary-tick-article-forward (n)
10255 "Tick N articles forwards.
10256 If N is negative, tick backwards instead.
10257 The difference between N and the number of articles ticked is returned."
10259 (gnus-summary-mark-forward n gnus-ticked-mark))
10261 (defalias 'gnus-summary-mark-as-unread-backward
10262 'gnus-summary-tick-article-backward)
10263 (make-obsolete 'gnus-summary-mark-as-unread-backward
10264 'gnus-summary-tick-article-backward)
10265 (defun gnus-summary-tick-article-backward (n)
10266 "Tick N articles backwards.
10267 The difference between N and the number of articles ticked is returned."
10269 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10271 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10272 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10273 (defun gnus-summary-tick-article (&optional article clear-mark)
10274 "Mark current article as unread.
10275 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10276 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10278 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10279 gnus-ticked-mark)))
10281 (defun gnus-summary-mark-as-read-forward (n)
10282 "Mark N articles as read forwards.
10283 If N is negative, mark backwards instead.
10284 The difference between N and the actual number of articles marked is
10287 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10289 (defun gnus-summary-mark-as-read-backward (n)
10290 "Mark the N articles as read backwards.
10291 The difference between N and the actual number of articles marked is
10294 (gnus-summary-mark-forward
10295 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10297 (defun gnus-summary-mark-as-read (&optional article mark)
10298 "Mark current article as read.
10299 ARTICLE specifies the article to be marked as read.
10300 MARK specifies a string to be inserted at the beginning of the line."
10301 (gnus-summary-mark-article article mark))
10303 (defun gnus-summary-clear-mark-forward (n)
10304 "Clear marks from N articles forward.
10305 If N is negative, clear backward instead.
10306 The difference between N and the number of marks cleared is returned."
10308 (gnus-summary-mark-forward n gnus-unread-mark))
10310 (defun gnus-summary-clear-mark-backward (n)
10311 "Clear marks from N articles backward.
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-mark-unread-as-read ()
10317 "Intended to be used by `gnus-summary-mark-article-hook'."
10318 (when (memq gnus-current-article gnus-newsgroup-unreads)
10319 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10321 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10322 "Intended to be used by `gnus-summary-mark-article-hook'."
10323 (let ((mark (gnus-summary-article-mark)))
10324 (when (or (gnus-unread-mark-p mark)
10325 (gnus-read-mark-p mark))
10326 (gnus-summary-mark-article gnus-current-article
10327 (or new-mark gnus-read-mark)))))
10329 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10330 "Intended to be used by `gnus-summary-mark-article-hook'."
10331 (let ((mark (gnus-summary-article-mark)))
10332 (when (or (gnus-unread-mark-p mark)
10333 (gnus-read-mark-p mark))
10334 (gnus-summary-mark-article (gnus-summary-article-number)
10335 (or new-mark gnus-read-mark)))))
10337 (defun gnus-summary-mark-unread-as-ticked ()
10338 "Intended to be used by `gnus-summary-mark-article-hook'."
10339 (when (memq gnus-current-article gnus-newsgroup-unreads)
10340 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10342 (defun gnus-summary-mark-region-as-read (point mark all)
10343 "Mark all unread articles between point and mark as read.
10344 If given a prefix, mark all articles between point and mark as read,
10345 even ticked and dormant ones."
10346 (interactive "r\nP")
10350 (beginning-of-line)
10355 (memq (setq article (gnus-summary-article-number))
10356 gnus-newsgroup-unreads))
10357 (gnus-summary-mark-article article gnus-del-mark))
10359 (gnus-summary-find-next))))))
10361 (defun gnus-summary-mark-below (score mark)
10362 "Mark articles with score less than SCORE with MARK."
10363 (interactive "P\ncMark: ")
10364 (setq score (if score
10365 (prefix-numeric-value score)
10366 (or gnus-summary-default-score 0)))
10368 (set-buffer gnus-summary-buffer)
10369 (goto-char (point-min))
10372 (and (< (gnus-summary-article-score) score)
10373 (gnus-summary-mark-article nil mark))
10374 (gnus-summary-find-next)))))
10376 (defun gnus-summary-kill-below (&optional score)
10377 "Mark articles with score below SCORE as read."
10379 (gnus-summary-mark-below score gnus-killed-mark))
10381 (defun gnus-summary-clear-above (&optional score)
10382 "Clear all marks from articles with score above SCORE."
10384 (gnus-summary-mark-above score gnus-unread-mark))
10386 (defun gnus-summary-tick-above (&optional score)
10387 "Tick all articles with score above SCORE."
10389 (gnus-summary-mark-above score gnus-ticked-mark))
10391 (defun gnus-summary-mark-above (score mark)
10392 "Mark articles with score over SCORE with MARK."
10393 (interactive "P\ncMark: ")
10394 (setq score (if score
10395 (prefix-numeric-value score)
10396 (or gnus-summary-default-score 0)))
10398 (set-buffer gnus-summary-buffer)
10399 (goto-char (point-min))
10401 (when (> (gnus-summary-article-score) score)
10402 (gnus-summary-mark-article nil mark))
10404 (gnus-summary-find-next)))))
10406 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10407 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10408 (defun gnus-summary-limit-include-expunged (&optional no-error)
10409 "Display all the hidden articles that were expunged for low scores."
10411 (let ((buffer-read-only nil))
10412 (let ((scored gnus-newsgroup-scored)
10415 (unless (gnus-summary-article-header (caar scored))
10416 (and (setq h (gnus-number-to-header (caar scored)))
10417 (< (cdar scored) gnus-summary-expunge-below)
10419 (setq scored (cdr scored)))
10421 (when (not no-error)
10422 (error "No expunged articles hidden"))
10423 (goto-char (point-min))
10424 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10425 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10426 (mapcar (lambda (x) (push (mail-header-number x)
10427 gnus-newsgroup-limit))
10429 (gnus-summary-prepare-unthreaded (nreverse headers))
10430 (goto-char (point-min))
10431 (gnus-summary-position-point)
10434 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10435 "Mark all unread articles in this newsgroup as read.
10436 If prefix argument ALL is non-nil, ticked and dormant articles will
10437 also be marked as read.
10438 If QUIETLY is non-nil, no questions will be asked.
10440 If TO-HERE is non-nil, it should be a point in the buffer. All
10441 articles before (after, if REVERSE is set) this point will be marked
10444 Note that this function will only catch up the unread article
10445 in the current summary buffer limitation.
10447 The number of articles marked as read is returned."
10452 (not gnus-interactive-catchup) ;Without confirmation?
10456 "Mark absolutely all articles as read? "
10457 "Mark all unread articles as read? ")))
10459 (not gnus-newsgroup-adaptive)
10460 (not gnus-newsgroup-auto-expire)
10461 (not gnus-suppress-duplicates)
10462 (or (not gnus-use-cache)
10463 (eq gnus-use-cache 'passive)))
10466 (setq gnus-newsgroup-marked nil
10467 gnus-newsgroup-spam-marked nil
10468 gnus-newsgroup-dormant nil))
10469 (setq gnus-newsgroup-unreads
10470 (gnus-sorted-nunion
10471 (gnus-intersection gnus-newsgroup-unreads
10472 gnus-newsgroup-downloadable)
10473 gnus-newsgroup-unfetched)))
10474 ;; We actually mark all articles as canceled, which we
10475 ;; have to do when using auto-expiry or adaptive scoring.
10476 (gnus-summary-show-all-threads)
10477 (if (and to-here reverse)
10479 (goto-char to-here)
10480 (gnus-summary-mark-current-read-and-unread-as-read
10482 (while (gnus-summary-find-next (not all))
10483 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10484 (when (gnus-summary-first-subject (not all))
10486 (if to-here (< (point) to-here) t)
10487 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10488 (gnus-summary-find-next (not all))))))
10489 (gnus-set-mode-line 'summary))
10491 (gnus-summary-position-point)))
10493 (defun gnus-summary-catchup-to-here (&optional all)
10494 "Mark all unticked articles before the current one as read.
10495 If ALL is non-nil, also mark ticked and dormant articles as read."
10498 (gnus-save-hidden-threads
10499 (let ((beg (point)))
10500 ;; We check that there are unread articles.
10501 (when (or all (gnus-summary-find-prev))
10502 (gnus-summary-catchup all t beg)))))
10503 (gnus-summary-position-point))
10505 (defun gnus-summary-catchup-from-here (&optional all)
10506 "Mark all unticked articles after (and including) the current one as read.
10507 If ALL is non-nil, also mark ticked and dormant articles as read."
10510 (gnus-save-hidden-threads
10511 (let ((beg (point)))
10512 ;; We check that there are unread articles.
10513 (when (or all (gnus-summary-find-next))
10514 (gnus-summary-catchup all t beg nil t)))))
10515 (gnus-summary-position-point))
10517 (defun gnus-summary-catchup-all (&optional quietly)
10518 "Mark all articles in this newsgroup as read.
10519 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10520 instead, which marks only unread articles as read."
10522 (gnus-summary-catchup t quietly))
10524 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10525 "Mark all unread articles in this group as read, then exit.
10526 If prefix argument ALL is non-nil, all articles are marked as read.
10527 If QUIETLY is non-nil, no questions will be asked."
10529 (when (gnus-summary-catchup all quietly nil 'fast)
10530 ;; Select next newsgroup or exit.
10531 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10532 (eq gnus-auto-select-next 'quietly))
10533 (gnus-summary-next-group nil)
10534 (gnus-summary-exit))))
10536 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10537 "Mark all articles in this newsgroup as read, and then exit.
10538 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10539 instead, which marks only unread articles as read."
10541 (gnus-summary-catchup-and-exit t quietly))
10543 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10544 "Mark all articles in this group as read and select the next group.
10545 If given a prefix, mark all articles, unread as well as ticked, as
10549 (gnus-summary-catchup all))
10550 (gnus-summary-next-group))
10556 (defmacro gnus-with-article (article &rest forms)
10557 "Select ARTICLE and perform FORMS in the original article buffer.
10558 Then replace the article with the result."
10560 ;; We don't want the article to be marked as read.
10561 (let (gnus-mark-article-hook)
10562 (gnus-summary-select-article t t nil ,article))
10563 (set-buffer gnus-original-article-buffer)
10565 (if (not (gnus-check-backend-function
10566 'request-replace-article (car gnus-article-current)))
10567 (gnus-message 5 "Read-only group; not replacing")
10568 (unless (gnus-request-replace-article
10569 ,article (car gnus-article-current)
10570 (current-buffer) t)
10571 (error "Couldn't replace article")))
10572 ;; The cache and backlog have to be flushed somewhat.
10573 (when gnus-keep-backlog
10574 (gnus-backlog-remove-article
10575 (car gnus-article-current) (cdr gnus-article-current)))
10576 (when gnus-use-cache
10577 (gnus-cache-update-article
10578 (car gnus-article-current) (cdr gnus-article-current)))))
10580 (put 'gnus-with-article 'lisp-indent-function 1)
10581 (put 'gnus-with-article 'edebug-form-spec '(form body))
10583 ;; Thread-based commands.
10585 (defun gnus-summary-articles-in-thread (&optional article)
10586 "Return a list of all articles in the current thread.
10587 If ARTICLE is non-nil, return all articles in the thread that starts
10588 with that article."
10589 (let* ((article (or article (gnus-summary-article-number)))
10590 (data (gnus-data-find-list article))
10591 (top-level (gnus-data-level (car data)))
10593 (cond ((null gnus-thread-operation-ignore-subject)
10594 (gnus-simplify-subject-re
10595 (mail-header-subject (gnus-data-header (car data)))))
10596 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10597 (gnus-simplify-subject-fuzzy
10598 (mail-header-subject (gnus-data-header (car data)))))
10600 (end-point (save-excursion
10601 (if (gnus-summary-go-to-next-thread)
10602 (point) (point-max))))
10605 (< (gnus-data-pos (car data)) end-point))
10606 (when (or (not top-subject)
10607 (string= top-subject
10608 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10609 (gnus-simplify-subject-fuzzy
10610 (mail-header-subject
10611 (gnus-data-header (car data))))
10612 (gnus-simplify-subject-re
10613 (mail-header-subject
10614 (gnus-data-header (car data)))))))
10615 (push (gnus-data-number (car data)) articles))
10616 (unless (and (setq data (cdr data))
10617 (> (gnus-data-level (car data)) top-level))
10619 ;; Return the list of articles.
10620 (nreverse articles)))
10622 (defun gnus-summary-rethread-current ()
10623 "Rethread the thread the current article is part of."
10625 (let* ((gnus-show-threads t)
10626 (article (gnus-summary-article-number))
10627 (id (mail-header-id (gnus-summary-article-header)))
10628 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10630 (error "No article on the current line"))
10631 (gnus-rebuild-thread id)
10632 (gnus-summary-goto-subject article)))
10634 (defun gnus-summary-reparent-thread ()
10635 "Make the current article child of the marked (or previous) article.
10637 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10638 is non-nil or the Subject: of both articles are the same."
10640 (unless (not (gnus-group-read-only-p))
10641 (error "The current newsgroup does not support article editing"))
10642 (unless (<= (length gnus-newsgroup-processable) 1)
10643 (error "No more than one article may be marked"))
10644 (save-window-excursion
10645 (let ((gnus-article-buffer " *reparent*")
10646 (current-article (gnus-summary-article-number))
10647 ;; First grab the marked article, otherwise one line up.
10648 (parent-article (if (not (null gnus-newsgroup-processable))
10649 (car gnus-newsgroup-processable)
10651 (if (eq (forward-line -1) 0)
10652 (gnus-summary-article-number)
10653 (error "Beginning of summary buffer"))))))
10654 (unless (not (eq current-article parent-article))
10655 (error "An article may not be self-referential"))
10656 (let ((message-id (mail-header-id
10657 (gnus-summary-article-header parent-article))))
10658 (unless (and message-id (not (equal message-id "")))
10659 (error "No message-id in desired parent"))
10660 (gnus-with-article current-article
10662 (goto-char (point-min))
10663 (message-narrow-to-head)
10664 (if (re-search-forward "^References: " nil t)
10666 (re-search-forward "^[^ \t]" nil t)
10669 (insert " " message-id))
10670 (insert "References: " message-id "\n"))))
10671 (set-buffer gnus-summary-buffer)
10672 (gnus-summary-unmark-all-processable)
10673 (gnus-summary-update-article current-article)
10674 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10675 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10676 (gnus-summary-rethread-current)
10677 (gnus-message 3 "Article %d is now the child of article %d"
10678 current-article parent-article)))))
10680 (defun gnus-summary-toggle-threads (&optional arg)
10681 "Toggle showing conversation threads.
10682 If ARG is positive number, turn showing conversation threads on."
10684 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10685 (setq gnus-show-threads
10686 (if (null arg) (not gnus-show-threads)
10687 (> (prefix-numeric-value arg) 0)))
10688 (gnus-summary-prepare)
10689 (gnus-summary-goto-subject current)
10690 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10691 (gnus-summary-position-point)))
10693 (defun gnus-summary-show-all-threads ()
10694 "Show all threads."
10697 (let ((buffer-read-only nil))
10698 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10699 (gnus-summary-position-point))
10701 (defun gnus-summary-show-thread ()
10702 "Show thread subtrees.
10703 Returns nil if no thread was there to be shown."
10705 (let ((buffer-read-only nil)
10707 (end (gnus-point-at-eol))
10708 ;; Leave point at bol
10709 (beg (progn (beginning-of-line) (point))))
10711 ;; Any hidden lines here?
10712 (search-forward "\r" end t)
10713 (subst-char-in-region beg end ?\^M ?\n t)
10715 (gnus-summary-position-point))))
10717 (defun gnus-summary-maybe-hide-threads ()
10718 "If requested, hide the threads that should be hidden."
10719 (when (and gnus-show-threads
10720 gnus-thread-hide-subtree)
10721 (gnus-summary-hide-all-threads
10722 (if (or (consp gnus-thread-hide-subtree)
10723 (functionp gnus-thread-hide-subtree))
10724 (gnus-make-predicate gnus-thread-hide-subtree)
10727 ;;; Hiding predicates.
10729 (defun gnus-article-unread-p (header)
10730 (memq (mail-header-number header) gnus-newsgroup-unreads))
10732 (defun gnus-article-unseen-p (header)
10733 (memq (mail-header-number header) gnus-newsgroup-unseen))
10735 (defun gnus-map-articles (predicate articles)
10736 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10737 (apply 'gnus-or (mapcar predicate
10738 (mapcar (lambda (number)
10739 (gnus-summary-article-header number))
10742 (defun gnus-summary-hide-all-threads (&optional predicate)
10743 "Hide all thread subtrees.
10744 If PREDICATE is supplied, threads that satisfy this predicate
10745 will not be hidden."
10748 (goto-char (point-min))
10751 (when (or (not predicate)
10753 predicate (gnus-summary-article-children)))
10754 (gnus-summary-hide-thread))
10755 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10756 (gnus-summary-position-point))
10758 (defun gnus-summary-hide-thread ()
10759 "Hide thread subtrees.
10760 If PREDICATE is supplied, threads that satisfy this predicate
10761 will not be hidden.
10762 Returns nil if no threads were there to be hidden."
10764 (let ((buffer-read-only nil)
10766 (article (gnus-summary-article-number)))
10768 ;; Go forward until either the buffer ends or the subthread
10770 (when (and (not (eobp))
10771 (or (zerop (gnus-summary-next-thread 1 t))
10772 (goto-char (point-max))))
10774 (if (and (> (point) start)
10775 (search-backward "\n" start t))
10777 (subst-char-in-region start (point) ?\n ?\^M)
10778 (gnus-summary-goto-subject article))
10782 (defun gnus-summary-go-to-next-thread (&optional previous)
10783 "Go to the same level (or less) next thread.
10784 If PREVIOUS is non-nil, go to previous thread instead.
10785 Return the article number moved to, or nil if moving was impossible."
10786 (let ((level (gnus-summary-thread-level))
10787 (way (if previous -1 1))
10790 (while (and (not (eobp))
10791 (< level (gnus-summary-thread-level)))
10792 (forward-line way))
10799 (gnus-summary-article-number)
10800 (goto-char beg)))))
10802 (defun gnus-summary-next-thread (n &optional silent)
10803 "Go to the same level next N'th thread.
10804 If N is negative, search backward instead.
10805 Returns the difference between N and the number of skips actually
10808 If SILENT, don't output messages."
10810 (let ((backward (< n 0))
10812 (while (and (> n 0)
10813 (gnus-summary-go-to-next-thread backward))
10816 (gnus-summary-position-point))
10817 (when (and (not silent) (/= 0 n))
10818 (gnus-message 7 "No more threads"))
10821 (defun gnus-summary-prev-thread (n)
10822 "Go to the same level previous N'th thread.
10823 Returns the difference between N and the number of skips actually
10826 (gnus-summary-next-thread (- n)))
10828 (defun gnus-summary-go-down-thread ()
10829 "Go down one level in the current thread."
10830 (let ((children (gnus-summary-article-children)))
10832 (gnus-summary-goto-subject (car children)))))
10834 (defun gnus-summary-go-up-thread ()
10835 "Go up one level in the current thread."
10836 (let ((parent (gnus-summary-article-parent)))
10838 (gnus-summary-goto-subject parent))))
10840 (defun gnus-summary-down-thread (n)
10841 "Go down thread N steps.
10842 If N is negative, go up instead.
10843 Returns the difference between N and how many steps down that were
10848 (while (and (> n 0)
10849 (if up (gnus-summary-go-up-thread)
10850 (gnus-summary-go-down-thread)))
10852 (gnus-summary-position-point)
10854 (gnus-message 7 "Can't go further"))
10857 (defun gnus-summary-up-thread (n)
10858 "Go up thread N steps.
10859 If N is negative, go down instead.
10860 Returns the difference between N and how many steps down that were
10863 (gnus-summary-down-thread (- n)))
10865 (defun gnus-summary-top-thread ()
10866 "Go to the top of the thread."
10868 (while (gnus-summary-go-up-thread))
10869 (gnus-summary-article-number))
10871 (defun gnus-summary-kill-thread (&optional unmark)
10872 "Mark articles under current thread as read.
10873 If the prefix argument is positive, remove any kinds of marks.
10874 If the prefix argument is negative, tick articles instead."
10877 (setq unmark (prefix-numeric-value unmark)))
10878 (let ((articles (gnus-summary-articles-in-thread)))
10880 ;; Expand the thread.
10881 (gnus-summary-show-thread)
10882 ;; Mark all the articles.
10884 (gnus-summary-goto-subject (car articles))
10885 (cond ((null unmark)
10886 (gnus-summary-mark-article-as-read gnus-killed-mark))
10888 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10890 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10891 (setq articles (cdr articles))))
10892 ;; Hide killed subtrees.
10894 gnus-thread-hide-killed
10895 (gnus-summary-hide-thread))
10896 ;; If marked as read, go to next unread subject.
10897 (when (null unmark)
10898 ;; Go to next unread subject.
10899 (gnus-summary-next-subject 1 t)))
10900 (gnus-set-mode-line 'summary))
10902 ;; Summary sorting commands
10904 (defun gnus-summary-sort-by-number (&optional reverse)
10905 "Sort the summary buffer by article number.
10906 Argument REVERSE means reverse order."
10908 (gnus-summary-sort 'number reverse))
10910 (defun gnus-summary-sort-by-random (&optional reverse)
10911 "Randomize the order in the summary buffer.
10912 Argument REVERSE means to randomize in reverse order."
10914 (gnus-summary-sort 'random reverse))
10916 (defun gnus-summary-sort-by-author (&optional reverse)
10917 "Sort the summary buffer by author name alphabetically.
10918 If `case-fold-search' is non-nil, case of letters is ignored.
10919 Argument REVERSE means reverse order."
10921 (gnus-summary-sort 'author reverse))
10923 (defun gnus-summary-sort-by-subject (&optional reverse)
10924 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10925 If `case-fold-search' is non-nil, case of letters is ignored.
10926 Argument REVERSE means reverse order."
10928 (gnus-summary-sort 'subject reverse))
10930 (defun gnus-summary-sort-by-date (&optional reverse)
10931 "Sort the summary buffer by date.
10932 Argument REVERSE means reverse order."
10934 (gnus-summary-sort 'date reverse))
10936 (defun gnus-summary-sort-by-score (&optional reverse)
10937 "Sort the summary buffer by score.
10938 Argument REVERSE means reverse order."
10940 (gnus-summary-sort 'score reverse))
10942 (defun gnus-summary-sort-by-lines (&optional reverse)
10943 "Sort the summary buffer by the number of lines.
10944 Argument REVERSE means reverse order."
10946 (gnus-summary-sort 'lines reverse))
10948 (defun gnus-summary-sort-by-chars (&optional reverse)
10949 "Sort the summary buffer by article length.
10950 Argument REVERSE means reverse order."
10952 (gnus-summary-sort 'chars reverse))
10954 (defun gnus-summary-sort-by-original (&optional reverse)
10955 "Sort the summary buffer using the default sorting method.
10956 Argument REVERSE means reverse order."
10958 (let* ((buffer-read-only)
10959 (gnus-summary-prepare-hook nil))
10960 ;; We do the sorting by regenerating the threads.
10961 (gnus-summary-prepare)
10962 ;; Hide subthreads if needed.
10963 (gnus-summary-maybe-hide-threads)))
10965 (defun gnus-summary-sort (predicate reverse)
10966 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10967 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10968 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10969 (gnus-thread-sort-functions
10974 (gnus-sort-gathered-threads-function
10975 gnus-thread-sort-functions)
10976 (gnus-article-sort-functions
10980 (,article t2 t1))))
10982 (gnus-summary-prepare-hook nil))
10983 ;; We do the sorting by regenerating the threads.
10984 (gnus-summary-prepare)
10985 ;; Hide subthreads if needed.
10986 (gnus-summary-maybe-hide-threads)))
10988 ;; Summary saving commands.
10990 (defun gnus-summary-save-article (&optional n not-saved)
10991 "Save the current article using the default saver function.
10992 If N is a positive number, save the N next articles.
10993 If N is a negative number, save the N previous articles.
10994 If N is nil and any articles have been marked with the process mark,
10995 save those articles instead.
10996 The variable `gnus-default-article-saver' specifies the saver function."
10998 (let* ((articles (gnus-summary-work-articles n))
10999 (save-buffer (save-excursion
11000 (nnheader-set-temp-buffer " *Gnus Save*")))
11001 (num (length articles))
11003 (dolist (article articles)
11004 (setq header (gnus-summary-article-header article))
11005 (if (not (vectorp header))
11006 ;; This is a pseudo-article.
11007 (if (assq 'name header)
11008 (gnus-copy-file (cdr (assq 'name header)))
11009 (gnus-message 1 "Article %d is unsaveable" article))
11010 ;; This is a real article.
11011 (save-window-excursion
11012 (let ((gnus-display-mime-function nil)
11013 (gnus-article-prepare-hook nil))
11014 (gnus-summary-select-article t nil nil article)))
11016 (set-buffer save-buffer)
11018 (insert-buffer-substring gnus-original-article-buffer))
11019 (setq file (gnus-article-save save-buffer file num))
11020 (gnus-summary-remove-process-mark article)
11022 (gnus-summary-set-saved-mark article))))
11023 (gnus-kill-buffer save-buffer)
11024 (gnus-summary-position-point)
11025 (gnus-set-mode-line 'summary)
11028 (defun gnus-summary-pipe-output (&optional arg headers)
11029 "Pipe the current article to a subprocess.
11030 If N is a positive number, pipe the N next articles.
11031 If N is a negative number, pipe the N previous articles.
11032 If N is nil and any articles have been marked with the process mark,
11033 pipe those articles instead.
11034 If HEADERS (the symbolic prefix), include the headers, too."
11035 (interactive (gnus-interactive "P\ny"))
11036 (require 'gnus-art)
11037 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11038 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11039 (gnus-summary-save-article arg t))
11040 (let ((buffer (get-buffer "*Shell Command Output*")))
11042 (not (zerop (buffer-size buffer))))
11043 (gnus-configure-windows 'pipe))))
11045 (defun gnus-summary-save-article-mail (&optional arg)
11046 "Append the current article to an mail file.
11047 If N is a positive number, save the N next articles.
11048 If N is a negative number, save the N previous articles.
11049 If N is nil and any articles have been marked with the process mark,
11050 save those articles instead."
11052 (require 'gnus-art)
11053 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11054 (gnus-summary-save-article arg)))
11056 (defun gnus-summary-save-article-rmail (&optional arg)
11057 "Append the current article to an rmail 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-rmail))
11065 (gnus-summary-save-article arg)))
11067 (defun gnus-summary-save-article-file (&optional arg)
11068 "Append the current article to a 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-file))
11076 (gnus-summary-save-article arg)))
11078 (defun gnus-summary-write-article-file (&optional arg)
11079 "Write the current article to a file, deleting the previous 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-write-to-file))
11087 (gnus-summary-save-article arg)))
11089 (defun gnus-summary-save-article-body-file (&optional arg)
11090 "Append the current article body to a 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-save-body-in-file))
11098 (gnus-summary-save-article arg)))
11100 (defun gnus-summary-muttprint (&optional arg)
11101 "Print the current article using Muttprint.
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-pipe-to-muttprint))
11109 (gnus-summary-save-article arg t)))
11111 (defun gnus-summary-pipe-message (program)
11112 "Pipe the current article through PROGRAM."
11113 (interactive "sProgram: ")
11114 (gnus-summary-select-article)
11115 (let ((mail-header-separator ""))
11116 (gnus-eval-in-buffer-window gnus-article-buffer
11119 (let ((start (window-start))
11121 (message-pipe-buffer-body program)
11122 (set-window-start (get-buffer-window (current-buffer)) start))))))
11124 (defun gnus-get-split-value (methods)
11125 "Return a value based on the split METHODS."
11126 (let (split-name method result match)
11129 (set-buffer gnus-original-article-buffer)
11131 (nnheader-narrow-to-headers)
11132 (while (and methods (not split-name))
11133 (goto-char (point-min))
11134 (setq method (pop methods))
11135 (setq match (car method))
11138 ;; Regular expression.
11140 (re-search-forward match nil t)))
11145 (setq result (funcall match gnus-newsgroup-name))))
11150 (setq result (eval match)))))
11151 (setq split-name (cdr method))
11152 (cond ((stringp result)
11153 (push (expand-file-name
11154 result gnus-article-save-directory)
11157 (setq split-name (append result split-name)))))))))
11158 (nreverse split-name)))
11160 (defun gnus-valid-move-group-p (group)
11161 (and (boundp group)
11162 (symbol-name group)
11163 (symbol-value group)
11164 (gnus-get-function (gnus-find-method-for-group
11165 (symbol-name group)) 'request-accept-article t)))
11167 (defun gnus-read-move-group-name (prompt default articles prefix)
11168 "Read a group name."
11169 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11170 (minibuffer-confirm-incomplete nil) ; XEmacs
11174 (if (> (length articles) 1)
11175 (format "these %d articles" (length articles))
11180 (gnus-completing-read-with-default
11183 'gnus-valid-move-group-p
11185 'gnus-group-history))
11186 ((= 1 (length split-name))
11187 (gnus-completing-read-with-default
11188 (car split-name) prom
11190 'gnus-valid-move-group-p
11192 'gnus-group-history))
11194 (gnus-completing-read-with-default
11196 (mapcar (lambda (el) (list el))
11197 (nreverse split-name))
11199 'gnus-group-history))))
11200 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11202 (if (or (string= to-newsgroup "")
11203 (string= to-newsgroup prefix))
11204 (setq to-newsgroup default))
11205 (unless to-newsgroup
11206 (error "No group name entered"))
11207 (or (gnus-active to-newsgroup)
11208 (gnus-activate-group to-newsgroup nil nil to-method)
11209 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11211 (or (and (gnus-request-create-group to-newsgroup to-method)
11212 (gnus-activate-group
11213 to-newsgroup nil nil to-method)
11214 (gnus-subscribe-group to-newsgroup))
11215 (error "Couldn't create group %s" to-newsgroup)))
11216 (error "No such group: %s" to-newsgroup)))
11219 (defun gnus-summary-save-parts (type dir n &optional reverse)
11220 "Save parts matching TYPE to DIR.
11221 If REVERSE, save parts that do not match TYPE."
11223 (list (read-string "Save parts of type: "
11224 (or (car gnus-summary-save-parts-type-history)
11225 gnus-summary-save-parts-default-mime)
11226 'gnus-summary-save-parts-type-history)
11227 (setq gnus-summary-save-parts-last-directory
11228 (read-file-name "Save to directory: "
11229 gnus-summary-save-parts-last-directory
11231 current-prefix-arg))
11232 (gnus-summary-iterate n
11233 (let ((gnus-display-mime-function nil)
11234 (gnus-inhibit-treatment t))
11235 (gnus-summary-select-article))
11237 (set-buffer gnus-article-buffer)
11238 (let ((handles (or gnus-article-mime-handles
11239 (mm-dissect-buffer nil gnus-article-loose-mime)
11240 (and gnus-article-emulate-mime
11241 (mm-uu-dissect)))))
11243 (gnus-summary-save-parts-1 type dir handles reverse)
11244 (unless gnus-article-mime-handles ;; Don't destroy this case.
11245 (mm-destroy-parts handles)))))))
11247 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11248 (if (stringp (car handle))
11249 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11252 (not (string-match type (mm-handle-media-type handle)))
11253 (string-match type (mm-handle-media-type handle)))
11254 (let ((file (expand-file-name
11256 mm-file-name-rewrite-functions
11257 (file-name-nondirectory
11259 (mail-content-type-get
11260 (mm-handle-disposition handle) 'filename)
11261 (mail-content-type-get
11262 (mm-handle-type handle) 'name)
11263 (concat gnus-newsgroup-name
11264 "." (number-to-string
11265 (cdr gnus-article-current))))))
11267 (unless (file-exists-p file)
11268 (mm-save-part-to-file handle file))))))
11270 ;; Summary extract commands
11272 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11273 (let ((buffer-read-only nil)
11274 (article (gnus-summary-article-number))
11276 (unless (gnus-summary-goto-subject article)
11277 (error "No such article: %d" article))
11278 (gnus-summary-position-point)
11279 ;; If all commands are to be bunched up on one line, we collect
11281 (unless gnus-view-pseudos-separately
11282 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11285 (setq action (cdr (assq 'action (car ps))))
11286 (setq files (list (cdr (assq 'name (car ps)))))
11287 (while (and ps (cdr ps)
11288 (string= (or action "1")
11289 (or (cdr (assq 'action (cadr ps))) "2")))
11290 (push (cdr (assq 'name (cadr ps))) files)
11291 (setcdr ps (cddr ps)))
11293 (when (not (string-match "%s" action))
11296 (when (assq 'execute (car ps))
11297 (setcdr (assq 'execute (car ps))
11298 (funcall (if (string-match "%s" action)
11307 (setq ps (cdr ps)))))
11308 (if (and gnus-view-pseudos (not not-view))
11310 (when (assq 'execute (car pslist))
11311 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11312 (eq gnus-view-pseudos 'not-confirm)))
11313 (setq pslist (cdr pslist)))
11316 (setq after-article (or (cdr (assq 'article (car pslist)))
11317 (gnus-summary-article-number)))
11318 (gnus-summary-goto-subject after-article)
11321 (insert " " (file-name-nondirectory
11322 (cdr (assq 'name (car pslist))))
11323 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11325 (forward-line -1) ; back to `b'
11326 (gnus-add-text-properties
11327 b (1- e) (list 'gnus-number gnus-reffed-article-number
11328 gnus-mouse-face-prop gnus-mouse-face))
11330 after-article gnus-reffed-article-number
11331 gnus-unread-mark b (car pslist) 0 (- e b))
11332 (setq gnus-newsgroup-unreads
11333 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11334 gnus-reffed-article-number))
11335 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11336 (setq pslist (cdr pslist)))))))
11338 (defun gnus-pseudos< (p1 p2)
11339 (let ((c1 (cdr (assq 'action p1)))
11340 (c2 (cdr (assq 'action p2))))
11341 (and c1 c2 (string< c1 c2))))
11343 (defun gnus-request-pseudo-article (props)
11344 (cond ((assq 'execute props)
11345 (gnus-execute-command (cdr (assq 'execute props)))))
11346 (let ((gnus-current-article (gnus-summary-article-number)))
11347 (gnus-run-hooks 'gnus-mark-article-hook)))
11349 (defun gnus-execute-command (command &optional automatic)
11351 (gnus-article-setup-buffer)
11352 (set-buffer gnus-article-buffer)
11353 (setq buffer-read-only nil)
11354 (let ((command (if automatic command
11355 (read-string "Command: " (cons command 0)))))
11357 (insert "$ " command "\n\n")
11358 (if gnus-view-pseudo-asynchronously
11359 (start-process "gnus-execute" (current-buffer) shell-file-name
11360 shell-command-switch command)
11361 (call-process shell-file-name nil t nil
11362 shell-command-switch command)))))
11364 ;; Summary kill commands.
11366 (defun gnus-summary-edit-global-kill (article)
11367 "Edit the \"global\" kill file."
11368 (interactive (list (gnus-summary-article-number)))
11369 (gnus-group-edit-global-kill article))
11371 (defun gnus-summary-edit-local-kill ()
11372 "Edit a local kill file applied to the current newsgroup."
11374 (setq gnus-current-headers (gnus-summary-article-header))
11375 (gnus-group-edit-local-kill
11376 (gnus-summary-article-number) gnus-newsgroup-name))
11378 ;;; Header reading.
11380 (defun gnus-read-header (id &optional header)
11381 "Read the headers of article ID and enter them into the Gnus system."
11382 (let ((group gnus-newsgroup-name)
11383 (gnus-override-method
11385 gnus-override-method
11386 (and (gnus-news-group-p gnus-newsgroup-name)
11387 (car (gnus-refer-article-methods)))))
11389 ;; First we check to see whether the header in question is already
11392 ;; This is a Message-ID.
11393 (setq header (or header (gnus-id-to-header id)))
11394 ;; This is an article number.
11395 (setq header (or header (gnus-summary-article-header id))))
11397 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11398 ;; We have found the header.
11400 ;; We have to really fetch the header to this article.
11402 (set-buffer nntp-server-buffer)
11403 (when (setq where (gnus-request-head id group))
11404 (nnheader-fold-continuation-lines)
11405 (goto-char (point-max))
11407 (goto-char (point-min))
11411 ((cdr where) (cdr where))
11412 (header (mail-header-number header))
11413 (t gnus-reffed-article-number))
11415 (insert " Article retrieved.\n"))
11416 (if (or (not where)
11417 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11418 () ; Malformed head.
11419 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11420 (when (and (stringp id)
11421 (not (string= (gnus-group-real-name group)
11423 ;; If we fetched by Message-ID and the article came
11424 ;; from a different group, we fudge some bogus article
11425 ;; numbers for this article.
11426 (mail-header-set-number header gnus-reffed-article-number))
11428 (set-buffer gnus-summary-buffer)
11429 (decf gnus-reffed-article-number)
11430 (gnus-remove-header (mail-header-number header))
11431 (push header gnus-newsgroup-headers)
11432 (setq gnus-current-headers header)
11433 (push (mail-header-number header) gnus-newsgroup-limit)))
11436 (defun gnus-remove-header (number)
11437 "Remove header NUMBER from `gnus-newsgroup-headers'."
11438 (if (and gnus-newsgroup-headers
11439 (= number (mail-header-number (car gnus-newsgroup-headers))))
11440 (pop gnus-newsgroup-headers)
11441 (let ((headers gnus-newsgroup-headers))
11442 (while (and (cdr headers)
11443 (not (= number (mail-header-number (cadr headers)))))
11445 (when (cdr headers)
11446 (setcdr headers (cddr headers))))))
11449 ;;; summary highlights
11452 (defun gnus-highlight-selected-summary ()
11453 "Highlight selected article in summary buffer."
11454 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11455 (when gnus-summary-selected-face
11457 (let* ((beg (gnus-point-at-bol))
11458 (end (gnus-point-at-eol))
11459 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11460 (from (if (get-text-property beg gnus-mouse-face-prop)
11462 (or (next-single-property-change
11463 beg gnus-mouse-face-prop nil end)
11468 (or (next-single-property-change
11469 from gnus-mouse-face-prop nil end)
11471 ;; If no mouse-face prop on line we will have to = from = end,
11472 ;; so we highlight the entire line instead.
11473 (when (= (+ to 2) from)
11476 (if gnus-newsgroup-selected-overlay
11477 ;; Move old overlay.
11479 gnus-newsgroup-selected-overlay from to (current-buffer))
11480 ;; Create new overlay.
11482 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11483 'face gnus-summary-selected-face))))))
11485 (defvar gnus-summary-highlight-line-cached nil)
11486 (defvar gnus-summary-highlight-line-trigger nil)
11488 (defun gnus-summary-highlight-line-0 ()
11489 (if (and (eq gnus-summary-highlight-line-trigger
11490 gnus-summary-highlight)
11491 gnus-summary-highlight-line-cached)
11492 gnus-summary-highlight-line-cached
11493 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11494 gnus-summary-highlight-line-cached
11495 (let* ((cond (list 'cond))
11497 (list gnus-summary-highlight))
11499 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11503 (gnus-byte-compile (list 'lambda nil cond))))))
11505 (defun gnus-summary-highlight-line ()
11506 "Highlight current line according to `gnus-summary-highlight'."
11507 (let* ((beg (gnus-point-at-bol))
11508 (article (or (gnus-summary-article-number) gnus-current-article))
11509 (score (or (cdr (assq article
11510 gnus-newsgroup-scored))
11511 gnus-summary-default-score 0))
11512 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11513 (inhibit-read-only t)
11514 (default gnus-summary-default-score)
11515 (default-high gnus-summary-default-high-score)
11516 (default-low gnus-summary-default-low-score)
11517 (uncached (and gnus-summary-use-undownloaded-faces
11518 (memq article gnus-newsgroup-undownloaded)
11519 (not (memq article gnus-newsgroup-cached)))))
11520 (let ((face (funcall (gnus-summary-highlight-line-0))))
11521 (unless (eq face (get-text-property beg 'face))
11522 (gnus-put-text-property-excluding-characters-with-faces
11523 beg (gnus-point-at-eol) 'face
11524 (setq face (if (boundp face) (symbol-value face) face)))
11525 (when gnus-summary-highlight-line-function
11526 (funcall gnus-summary-highlight-line-function article face))))))
11528 (defun gnus-update-read-articles (group unread &optional compute)
11529 "Update the list of read articles in GROUP.
11530 UNREAD is a sorted list."
11531 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11532 (entry (gnus-gethash group gnus-newsrc-hashtb))
11533 (info (nth 2 entry))
11536 (if (or (not info) (not active))
11537 ;; There is no info on this group if it was, in fact,
11538 ;; killed. Gnus stores no information on killed groups, so
11539 ;; there's nothing to be done.
11540 ;; One could store the information somewhere temporarily,
11541 ;; perhaps... Hmmm...
11543 ;; Remove any negative articles numbers.
11544 (while (and unread (< (car unread) 0))
11545 (setq unread (cdr unread)))
11546 ;; Remove any expired article numbers
11547 (while (and unread (< (car unread) (car active)))
11548 (setq unread (cdr unread)))
11549 ;; Compute the ranges of read articles by looking at the list of
11550 ;; unread articles.
11552 (when (/= (car unread) prev)
11553 (push (if (= prev (1- (car unread))) prev
11554 (cons prev (1- (car unread))))
11556 (setq prev (1+ (car unread)))
11557 (setq unread (cdr unread)))
11558 (when (<= prev (cdr active))
11559 (push (cons prev (cdr active)) read))
11560 (setq read (if (> (length read) 1) (nreverse read) read))
11565 ;; Propagate the read marks to the backend.
11566 (when (gnus-check-backend-function 'request-set-mark group)
11567 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11568 (add (gnus-remove-from-range read (gnus-info-read info))))
11570 (unless (gnus-check-group group)
11571 (error "Can't open server for %s" group))
11572 (gnus-request-set-mark
11573 group (delq nil (list (if add (list add 'add '(read)))
11574 (if del (list del 'del '(read))))))
11576 `(gnus-request-set-mark
11579 (if del (list del 'add '(read)))
11580 (if add (list add 'del '(read))))))))))
11581 (set-buffer gnus-group-buffer)
11582 (gnus-undo-register
11584 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11585 (gnus-info-set-read ',info ',(gnus-info-read info))
11586 (gnus-get-unread-articles-in-group ',info
11587 (gnus-active ,group))
11588 (gnus-group-update-group ,group t)
11590 ;; Enter this list into the group info.
11591 (gnus-info-set-read info read)
11592 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11593 (gnus-get-unread-articles-in-group info (gnus-active group))
11596 (defun gnus-offer-save-summaries ()
11597 "Offer to save all active summary buffers."
11599 ;; Go through all buffers and find all summaries.
11600 (dolist (buffer (buffer-list))
11601 (when (and (setq buffer (buffer-name buffer))
11602 (string-match "Summary" buffer)
11604 (set-buffer buffer)
11605 ;; We check that this is, indeed, a summary buffer.
11606 (and (eq major-mode 'gnus-summary-mode)
11607 ;; Also make sure this isn't bogus.
11608 gnus-newsgroup-prepared
11609 ;; Also make sure that this isn't a
11610 ;; dead summary buffer.
11611 (not gnus-dead-summary-mode))))
11612 (push buffer buffers)))
11613 ;; Go through all these summary buffers and offer to save them.
11617 "Update summary buffer %s? "
11619 (switch-to-buffer buf)
11620 (gnus-summary-exit))
11623 (defun gnus-summary-setup-default-charset ()
11624 "Setup newsgroup default charset."
11625 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11626 (setq gnus-newsgroup-charset nil)
11627 (let* ((ignored-charsets
11628 (or gnus-newsgroup-ephemeral-ignored-charsets
11630 (and gnus-newsgroup-name
11631 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11632 gnus-newsgroup-ignored-charsets))))
11633 (setq gnus-newsgroup-charset
11634 (or gnus-newsgroup-ephemeral-charset
11635 (and gnus-newsgroup-name
11636 (gnus-parameter-charset gnus-newsgroup-name))
11637 gnus-default-charset))
11638 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11639 ignored-charsets))))
11645 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11646 "Display the current article buffer fully MIME-buttonized.
11647 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11648 treated as multipart/mixed."
11650 (require 'gnus-art)
11651 (let ((gnus-unbuttonized-mime-types nil)
11652 (gnus-mime-display-multipart-as-mixed show-all-parts))
11653 (gnus-summary-show-article)))
11655 (defun gnus-summary-repair-multipart (article)
11656 "Add a Content-Type header to a multipart article without one."
11657 (interactive (list (gnus-summary-article-number)))
11658 (gnus-with-article article
11659 (message-narrow-to-head)
11660 (message-remove-header "Mime-Version")
11661 (goto-char (point-max))
11662 (insert "Mime-Version: 1.0\n")
11664 (when (search-forward "\n--" nil t)
11665 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11666 (message-narrow-to-head)
11667 (message-remove-header "Content-Type")
11668 (goto-char (point-max))
11669 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11672 (let (gnus-mark-article-hook)
11673 (gnus-summary-select-article t t nil article)))
11675 (defun gnus-summary-toggle-display-buttonized ()
11676 "Toggle the buttonizing of the article buffer."
11678 (require 'gnus-art)
11679 (if (setq gnus-inhibit-mime-unbuttonizing
11680 (not gnus-inhibit-mime-unbuttonizing))
11681 (let ((gnus-unbuttonized-mime-types nil))
11682 (gnus-summary-show-article))
11683 (gnus-summary-show-article)))
11686 ;;; Generic summary marking commands
11689 (defvar gnus-summary-marking-alist
11690 '((read gnus-del-mark "d")
11691 (unread gnus-unread-mark "u")
11692 (ticked gnus-ticked-mark "!")
11693 (dormant gnus-dormant-mark "?")
11694 (expirable gnus-expirable-mark "e"))
11695 "An alist of names/marks/keystrokes.")
11697 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11698 (defvar gnus-summary-mark-map)
11700 (defun gnus-summary-make-all-marking-commands ()
11701 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11702 (dolist (elem gnus-summary-marking-alist)
11703 (apply 'gnus-summary-make-marking-command elem)))
11705 (defun gnus-summary-make-marking-command (name mark keystroke)
11706 (let ((map (make-sparse-keymap)))
11707 (define-key gnus-summary-generic-mark-map keystroke map)
11708 (dolist (lway `((next "next" next nil "n")
11709 (next-unread "next unread" next t "N")
11710 (prev "previous" prev nil "p")
11711 (prev-unread "previous unread" prev t "P")
11712 (nomove "" nil nil ,keystroke)))
11713 (let ((func (gnus-summary-make-marking-command-1
11714 mark (car lway) lway name)))
11715 (setq func (eval func))
11716 (define-key map (nth 4 lway) func)))))
11718 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11720 (format "gnus-summary-put-mark-as-%s%s"
11721 name (if (eq way 'nomove)
11723 (concat "-" (symbol-name way)))))
11726 "Mark the current article as %s%s.
11727 If N, the prefix, then repeat N times.
11728 If N is negative, move in reverse order.
11729 The difference between N and the actual number of articles marked is
11733 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11735 (defun gnus-summary-generic-mark (n mark move unread)
11736 "Mark N articles with MARK."
11737 (unless (eq major-mode 'gnus-summary-mode)
11738 (error "This command can only be used in the summary buffer"))
11739 (gnus-summary-show-thread)
11742 ((eq move 'next) 1)
11743 ((eq move 'prev) -1)
11745 (if (zerop nummove)
11749 nummove (* -1 nummove))))
11750 (while (and (> n 0)
11751 (gnus-summary-mark-article nil mark)
11752 (zerop (gnus-summary-next-subject nummove unread t)))
11755 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11756 (gnus-summary-recenter)
11757 (gnus-summary-position-point)
11758 (gnus-set-mode-line 'summary)
11761 (defun gnus-summary-insert-articles (articles)
11762 (when (setq articles
11763 (gnus-sorted-difference articles
11764 (mapcar (lambda (h)
11765 (mail-header-number h))
11766 gnus-newsgroup-headers)))
11767 (setq gnus-newsgroup-headers
11769 gnus-newsgroup-headers
11770 (gnus-fetch-headers articles)
11771 'gnus-article-sort-by-number))
11772 ;; Suppress duplicates?
11773 (when gnus-suppress-duplicates
11774 (gnus-dup-suppress-articles))
11776 ;; We might want to build some more threads first.
11777 (when (and gnus-fetch-old-headers
11778 (eq gnus-headers-retrieved-by 'nov))
11779 (if (eq gnus-fetch-old-headers 'invisible)
11780 (gnus-build-all-threads)
11781 (gnus-build-old-threads)))
11782 ;; Let the Gnus agent mark articles as read.
11784 (gnus-agent-get-undownloaded-list))
11785 ;; Remove list identifiers from subject
11786 (when gnus-list-identifiers
11787 (gnus-summary-remove-list-identifiers))
11788 ;; First and last article in this newsgroup.
11789 (when gnus-newsgroup-headers
11790 (setq gnus-newsgroup-begin
11791 (mail-header-number (car gnus-newsgroup-headers))
11793 (mail-header-number
11794 (gnus-last-element gnus-newsgroup-headers))))
11795 (when gnus-use-scoring
11796 (gnus-possibly-score-headers))))
11798 (defun gnus-summary-insert-old-articles (&optional all)
11799 "Insert all old articles in this group.
11800 If ALL is non-nil, already read articles become readable.
11801 If ALL is a number, fetch this number of articles."
11804 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11807 ;; Some nntp servers lie about their active range. When
11808 ;; this happens, the active range can be in the millions.
11809 ;; Use a compressed range to avoid creating a huge list.
11810 (gnus-range-difference (list gnus-newsgroup-active) old))
11811 (setq len (gnus-range-length older))
11816 (let ((older-range (nreverse older)))
11820 (let* ((r (pop older-range))
11821 (min (if (numberp r) r (car r)))
11822 (max (if (numberp r) r (cdr r))))
11823 (while (and (<= min max)
11828 (setq older (gnus-uncompress-range older))))
11830 (setq older (gnus-uncompress-range older)))
11832 (when (and (numberp gnus-large-newsgroup)
11833 (> len gnus-large-newsgroup))
11834 (let* ((cursor-in-echo-area nil)
11835 (initial (gnus-parameter-large-newsgroup-initial
11836 gnus-newsgroup-name))
11840 "How many articles from %s (%s %d): "
11842 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11843 (if initial "max" "default")
11846 (cons (number-to-string initial)
11848 (unless (string-match "^[ \t]*$" input)
11849 (setq all (string-to-number input))
11851 (let ((older-range (nreverse older)))
11855 (let* ((r (pop older-range))
11856 (min (if (numberp r) r (car r)))
11857 (max (if (numberp r) r (cdr r))))
11858 (while (and (<= min max)
11862 max (1- max))))))))))
11863 (setq older (gnus-uncompress-range older))))
11865 (message "No old news.")
11866 (gnus-summary-insert-articles older)
11867 (gnus-summary-limit (gnus-sorted-nunion old older))))
11868 (gnus-summary-position-point)))
11870 (defun gnus-summary-insert-new-articles ()
11871 "Insert all new articles in this group."
11874 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11875 (old-active gnus-newsgroup-active)
11876 (nnmail-fetched-sources (list t))
11878 (setq gnus-newsgroup-active
11879 (gnus-activate-group gnus-newsgroup-name 'scan))
11880 (setq i (cdr gnus-newsgroup-active))
11881 (while (> i (cdr old-active))
11885 (message "No gnus is bad news.")
11886 (gnus-summary-insert-articles new)
11887 (setq gnus-newsgroup-unreads
11888 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11889 (gnus-summary-limit (gnus-sorted-nunion old new))))
11890 (gnus-summary-position-point)))
11892 (gnus-summary-make-all-marking-commands)
11894 (gnus-ems-redefine)
11896 (provide 'gnus-sum)
11898 (run-hooks 'gnus-sum-load-hook)
11900 ;; Local Variables:
11901 ;; coding: iso-8859-1
11904 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11905 ;;; gnus-sum.el ends here