1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
41 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
42 (autoload 'gnus-cache-write-active "gnus-cache")
43 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
44 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
47 (defcustom gnus-kill-summary-on-exit t
48 "*If non-nil, kill the summary buffer when you exit from it.
49 If nil, the summary will become a \"*Dead Summary*\" buffer, and
50 it will be killed sometime later."
51 :group 'gnus-summary-exit
54 (defcustom gnus-fetch-old-headers nil
55 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
56 If an unread article in the group refers to an older, already read (or
57 just marked as read) article, the old article will not normally be
58 displayed in the Summary buffer. If this variable is non-nil, Gnus
59 will attempt to grab the headers to the old articles, and thereby
60 build complete threads. If it has the value `some', only enough
61 headers to connect otherwise loose threads will be displayed. This
62 variable can also be a number. In that case, no more than that number
63 of old headers will be fetched. If it has the value `invisible', all
64 old headers will be fetched, but none will be displayed.
66 The server has to support NOV for any of this to work."
68 :type '(choice (const :tag "off" nil)
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-refer-thread-limit 200
74 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
75 If t, fetch all the available old headers."
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-summary-make-false-root 'adopt
81 "*nil means that Gnus won't gather loose threads.
82 If the root of a thread has expired or been read in a previous
83 session, the information necessary to build a complete thread has been
84 lost. Instead of having many small sub-threads from this original thread
85 scattered all over the summary buffer, Gnus can gather them.
87 If non-nil, Gnus will try to gather all loose sub-threads from an
88 original thread into one large thread.
90 If this variable is non-nil, it should be one of `none', `adopt',
93 If this variable is `none', Gnus will not make a false root, but just
94 present the sub-threads after another.
95 If this variable is `dummy', Gnus will create a dummy root that will
96 have all the sub-threads as children.
97 If this variable is `adopt', Gnus will make one of the \"children\"
98 the parent and mark all the step-children as such.
99 If this variable is `empty', the \"children\" are printed with empty
100 subject fields. (Or rather, they will be printed with a string
101 given by the `gnus-summary-same-subject' variable.)"
103 :type '(choice (const :tag "off" nil)
109 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
110 "*A regexp to match subjects to be excluded from loose thread gathering.
111 As loose thread gathering is done on subjects only, that means that
112 there can be many false gatherings performed. By rooting out certain
113 common subjects, gathering might become saner."
117 (defcustom gnus-summary-gather-subject-limit nil
118 "*Maximum length of subject comparisons when gathering loose threads.
119 Use nil to compare full subjects. Setting this variable to a low
120 number will help gather threads that have been corrupted by
121 newsreaders chopping off subject lines, but it might also mean that
122 unrelated articles that have subject that happen to begin with the
123 same few characters will be incorrectly gathered.
125 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
128 :type '(choice (const :tag "off" nil)
130 (sexp :menu-tag "on" t)))
132 (defcustom gnus-simplify-subject-functions nil
133 "List of functions taking a string argument that simplify subjects.
134 The functions are applied recursively.
136 Useful functions to put in this list include: `gnus-simplify-subject-re',
137 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
139 :type '(repeat function))
141 (defcustom gnus-simplify-ignored-prefixes nil
142 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
144 :type '(choice (const :tag "off" nil)
147 (defcustom gnus-build-sparse-threads nil
148 "*If non-nil, fill in the gaps in threads.
149 If `some', only fill in the gaps that are needed to tie loose threads
150 together. If `more', fill in all leaf nodes that Gnus can find. If
151 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
153 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "all" t)))
158 (defcustom gnus-summary-thread-gathering-function
159 'gnus-gather-threads-by-subject
160 "*Function used for gathering loose threads.
161 There are two pre-defined functions: `gnus-gather-threads-by-subject',
162 which only takes Subjects into consideration; and
163 `gnus-gather-threads-by-references', which compared the References
164 headers of the articles to find matches."
166 :type '(radio (function-item gnus-gather-threads-by-subject)
167 (function-item gnus-gather-threads-by-references)
168 (function :tag "other")))
170 (defcustom gnus-summary-same-subject ""
171 "*String indicating that the current article has the same subject as the previous.
172 This variable will only be used if the value of
173 `gnus-summary-make-false-root' is `empty'."
174 :group 'gnus-summary-format
177 (defcustom gnus-summary-goto-unread t
178 "*If t, many commands will go to the next unread article.
179 This applies to marking commands as well as other commands that
180 \"naturally\" select the next article, like, for instance, `SPC' at
181 the end of an article.
183 If nil, the marking commands do NOT go to the next unread article
184 (they go to the next article instead). If `never', commands that
185 usually go to the next unread article, will go to the next article,
186 whether it is read or not."
187 :group 'gnus-summary-marks
188 :link '(custom-manual "(gnus)Setting Marks")
189 :type '(choice (const :tag "off" nil)
191 (sexp :menu-tag "on" t)))
193 (defcustom gnus-summary-default-score 0
194 "*Default article score level.
195 All scores generated by the score files will be added to this score.
196 If this variable is nil, scoring will be disabled."
197 :group 'gnus-score-default
198 :type '(choice (const :tag "disable")
201 (defcustom gnus-summary-default-high-score 0
202 "*Default threshold for a high scored article.
203 An article will be highlighted as high scored if its score is greater
205 :group 'gnus-score-default
208 (defcustom gnus-summary-default-low-score 0
209 "*Default threshold for a low scored article.
210 An article will be highlighted as low scored if its score is smaller
212 :group 'gnus-score-default
215 (defcustom gnus-summary-zcore-fuzz 0
216 "*Fuzziness factor for the zcore in the summary buffer.
217 Articles with scores closer than this to `gnus-summary-default-score'
219 :group 'gnus-summary-format
222 (defcustom gnus-simplify-subject-fuzzy-regexp nil
223 "*Strings to be removed when doing fuzzy matches.
224 This can either be a regular expression or list of regular expressions
225 that will be removed from subject strings if fuzzy subject
226 simplification is selected."
228 :type '(repeat regexp))
230 (defcustom gnus-show-threads t
231 "*If non-nil, display threads in summary mode."
235 (defcustom gnus-thread-hide-subtree nil
236 "*If non-nil, hide all threads initially.
237 This can be a predicate specifier which says which threads to hide.
238 If threads are hidden, you have to run the command
239 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
240 to expose hidden threads."
244 (defcustom gnus-thread-hide-killed t
245 "*If non-nil, hide killed threads automatically."
249 (defcustom gnus-thread-ignore-subject t
250 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
251 If nil, articles that have different subjects from their parents will
252 start separate threads."
256 (defcustom gnus-thread-operation-ignore-subject t
257 "*If non-nil, subjects will be ignored when doing thread commands.
258 This affects commands like `gnus-summary-kill-thread' and
259 `gnus-summary-lower-thread'.
261 If this variable is nil, articles in the same thread with different
262 subjects will not be included in the operation in question. If this
263 variable is `fuzzy', only articles that have subjects that are fuzzily
264 equal will be included."
266 :type '(choice (const :tag "off" nil)
270 (defcustom gnus-thread-indent-level 4
271 "*Number that says how much each sub-thread should be indented."
275 (defcustom gnus-auto-extend-newsgroup t
276 "*If non-nil, extend newsgroup forward and backward when requested."
277 :group 'gnus-summary-choose
280 (defcustom gnus-auto-select-first t
281 "*If non-nil, select the article under point.
282 Which article this is is controlled by the `gnus-auto-select-subject'
285 If you want to prevent automatic selection of articles in some
286 newsgroups, set the variable to nil in `gnus-select-group-hook'."
287 :group 'gnus-group-select
288 :type '(choice (const :tag "none" nil)
289 (sexp :menu-tag "first" t)))
291 (defcustom gnus-auto-select-subject 'unread
292 "*Says what subject to place under point when entering a group.
294 This variable can either be the symbols `first' (place point on the
295 first subject), `unread' (place point on the subject line of the first
296 unread article), `best' (place point on the subject line of the
297 higest-scored article), `unseen' (place point on the subject line of
298 the first unseen article), 'unseen-or-unread' (place point on the subject
299 line of the first unseen article or, if all article have been seen, on the
300 subject line of the first unread article), or a function to be called to
301 place point on some subject line.."
302 :group 'gnus-group-select
303 :type '(choice (const best)
307 (const unseen-or-unread)))
309 (defcustom gnus-auto-select-next t
310 "*If non-nil, offer to go to the next group from the end of the previous.
311 If the value is t and the next newsgroup is empty, Gnus will exit
312 summary mode and go back to group mode. If the value is neither nil
313 nor t, Gnus will select the following unread newsgroup. In
314 particular, if the value is the symbol `quietly', the next unread
315 newsgroup will be selected without any confirmation, and if it is
316 `almost-quietly', the next group will be selected without any
317 confirmation if you are located on the last article in the group.
318 Finally, if this variable is `slightly-quietly', the `Z n' command
319 will go to the next group without confirmation."
320 :group 'gnus-summary-maneuvering
321 :type '(choice (const :tag "off" nil)
323 (const almost-quietly)
324 (const slightly-quietly)
325 (sexp :menu-tag "on" t)))
327 (defcustom gnus-auto-select-same nil
328 "*If non-nil, select the next article with the same subject.
329 If there are no more articles with the same subject, go to
330 the first unread article."
331 :group 'gnus-summary-maneuvering
334 (defcustom gnus-summary-check-current nil
335 "*If non-nil, consider the current article when moving.
336 The \"unread\" movement commands will stay on the same line if the
337 current article is unread."
338 :group 'gnus-summary-maneuvering
341 (defcustom gnus-auto-center-summary t
342 "*If non-nil, always center the current summary buffer.
343 In particular, if `vertical' do only vertical recentering. If non-nil
344 and non-`vertical', do both horizontal and vertical recentering."
345 :group 'gnus-summary-maneuvering
346 :type '(choice (const :tag "none" nil)
348 (integer :tag "height")
349 (sexp :menu-tag "both" t)))
351 (defcustom gnus-show-all-headers nil
352 "*If non-nil, don't hide any headers."
353 :group 'gnus-article-hiding
354 :group 'gnus-article-headers
357 (defcustom gnus-summary-ignore-duplicates nil
358 "*If non-nil, ignore articles with identical Message-ID headers."
362 (defcustom gnus-single-article-buffer t
363 "*If non-nil, display all articles in the same buffer.
364 If nil, each group will get its own article buffer."
365 :group 'gnus-article-various
368 (defcustom gnus-break-pages t
369 "*If non-nil, do page breaking on articles.
370 The page delimiter is specified by the `gnus-page-delimiter'
372 :group 'gnus-article-various
375 (defcustom gnus-move-split-methods nil
376 "*Variable used to suggest where articles are to be moved to.
377 It uses the same syntax as the `gnus-split-methods' variable.
378 However, whereas `gnus-split-methods' specifies file names as targets,
379 this variable specifies group names."
380 :group 'gnus-summary-mail
381 :type '(repeat (choice (list :value (fun) function)
382 (cons :value ("" "") regexp (repeat string))
385 (defcustom gnus-unread-mark ? ;Whitespace
386 "*Mark used for unread articles."
387 :group 'gnus-summary-marks
390 (defcustom gnus-ticked-mark ?!
391 "*Mark used for ticked articles."
392 :group 'gnus-summary-marks
395 (defcustom gnus-dormant-mark ??
396 "*Mark used for dormant articles."
397 :group 'gnus-summary-marks
400 (defcustom gnus-del-mark ?r
401 "*Mark used for del'd articles."
402 :group 'gnus-summary-marks
405 (defcustom gnus-read-mark ?R
406 "*Mark used for read articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-expirable-mark ?E
411 "*Mark used for expirable articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-killed-mark ?K
416 "*Mark used for killed articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-souped-mark ?F
421 "*Mark used for souped articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-kill-file-mark ?X
426 "*Mark used for articles killed by kill files."
427 :group 'gnus-summary-marks
430 (defcustom gnus-low-score-mark ?Y
431 "*Mark used for articles with a low score."
432 :group 'gnus-summary-marks
435 (defcustom gnus-catchup-mark ?C
436 "*Mark used for articles that are caught up."
437 :group 'gnus-summary-marks
440 (defcustom gnus-replied-mark ?A
441 "*Mark used for articles that have been replied to."
442 :group 'gnus-summary-marks
445 (defcustom gnus-forwarded-mark ?F
446 "*Mark used for articles that have been forwarded."
447 :group 'gnus-summary-marks
450 (defcustom gnus-recent-mark ?N
451 "*Mark used for articles that are recent."
452 :group 'gnus-summary-marks
455 (defcustom gnus-cached-mark ?*
456 "*Mark used for articles that are in the cache."
457 :group 'gnus-summary-marks
460 (defcustom gnus-saved-mark ?S
461 "*Mark used for articles that have been saved."
462 :group 'gnus-summary-marks
465 (defcustom gnus-unseen-mark ?.
466 "*Mark used for articles that haven't been seen."
467 :group 'gnus-summary-marks
470 (defcustom gnus-no-mark ? ;Whitespace
471 "*Mark used for articles that have no other secondary mark."
472 :group 'gnus-summary-marks
475 (defcustom gnus-ancient-mark ?O
476 "*Mark used for ancient articles."
477 :group 'gnus-summary-marks
480 (defcustom gnus-sparse-mark ?Q
481 "*Mark used for sparsely reffed articles."
482 :group 'gnus-summary-marks
485 (defcustom gnus-canceled-mark ?G
486 "*Mark used for canceled articles."
487 :group 'gnus-summary-marks
490 (defcustom gnus-duplicate-mark ?M
491 "*Mark used for duplicate articles."
492 :group 'gnus-summary-marks
495 (defcustom gnus-undownloaded-mark ?@
496 "*Mark used for articles that weren't downloaded."
497 :group 'gnus-summary-marks
500 (defcustom gnus-downloadable-mark ?%
501 "*Mark used for articles that are to be downloaded."
502 :group 'gnus-summary-marks
505 (defcustom gnus-unsendable-mark ?=
506 "*Mark used for articles that won't be sent."
507 :group 'gnus-summary-marks
510 (defcustom gnus-score-over-mark ?+
511 "*Score mark used for articles with high scores."
512 :group 'gnus-summary-marks
515 (defcustom gnus-score-below-mark ?-
516 "*Score mark used for articles with low scores."
517 :group 'gnus-summary-marks
520 (defcustom gnus-empty-thread-mark ? ;Whitespace
521 "*There is no thread under the article."
522 :group 'gnus-summary-marks
525 (defcustom gnus-not-empty-thread-mark ?=
526 "*There is a thread under the article."
527 :group 'gnus-summary-marks
530 (defcustom gnus-view-pseudo-asynchronously nil
531 "*If non-nil, Gnus will view pseudo-articles asynchronously."
532 :group 'gnus-extract-view
535 (defcustom gnus-auto-expirable-marks
536 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
537 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
538 gnus-souped-mark gnus-duplicate-mark)
539 "*The list of marks converted into expiration if a group is auto-expirable."
542 :type '(repeat character))
544 (defcustom gnus-inhibit-user-auto-expire t
545 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
550 (defcustom gnus-view-pseudos nil
551 "*If `automatic', pseudo-articles will be viewed automatically.
552 If `not-confirm', pseudos will be viewed automatically, and the user
553 will not be asked to confirm the command."
554 :group 'gnus-extract-view
555 :type '(choice (const :tag "off" nil)
557 (const not-confirm)))
559 (defcustom gnus-view-pseudos-separately t
560 "*If non-nil, one pseudo-article will be created for each file to be viewed.
561 If nil, all files that use the same viewing command will be given as a
562 list of parameters to that command."
563 :group 'gnus-extract-view
566 (defcustom gnus-insert-pseudo-articles t
567 "*If non-nil, insert pseudo-articles when decoding articles."
568 :group 'gnus-extract-view
571 (defcustom gnus-summary-dummy-line-format
573 "*The format specification for the dummy roots in the summary buffer.
574 It works along the same lines as a normal formatting string,
575 with some simple extensions.
579 General format specifiers can also be used.
580 See (gnus)Formatting Variables."
581 :link '(custom-manual "(gnus)Formatting Variables")
582 :group 'gnus-threading
585 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
586 "*The format specification for the summary mode line.
587 It works along the same lines as a normal formatting string,
588 with some simple extensions:
591 %p Unprefixed group name
592 %A Current article number
593 %z Current article score
595 %U Number of unread articles in the group
596 %e Number of unselected articles in the group
597 %Z A string with unread/unselected article counts
598 %g Shortish group name
599 %S Subject of the current article
601 %s Current score file name
602 %d Number of dormant articles
603 %r Number of articles that have been marked as read in this session
604 %E Number of articles expunged by the score files"
605 :group 'gnus-summary-format
608 (defcustom gnus-list-identifiers nil
609 "Regexp that matches list identifiers to be removed from subject.
610 This can also be a list of regexps."
612 :group 'gnus-summary-format
613 :group 'gnus-article-hiding
614 :type '(choice (const :tag "none" nil)
616 (repeat :value (".*") regexp)))
618 (defcustom gnus-summary-mark-below 0
619 "*Mark all articles with a score below this variable as read.
620 This variable is local to each summary buffer and usually set by the
622 :group 'gnus-score-default
625 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
626 "*List of functions used for sorting articles in the summary buffer.
628 Each function takes two articles and returns non-nil if the first
629 article should be sorted before the other. If you use more than one
630 function, the primary sort function should be the last. You should
631 probably always include `gnus-article-sort-by-number' in the list of
632 sorting functions -- preferably first. Also note that sorting by date
633 is often much slower than sorting by number, and the sorting order is
634 very similar. (Sorting by date means sorting by the time the message
635 was sent, sorting by number means sorting by arrival time.)
637 Ready-made functions include `gnus-article-sort-by-number',
638 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
639 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
641 When threading is turned on, the variable `gnus-thread-sort-functions'
642 controls how articles are sorted."
643 :group 'gnus-summary-sort
644 :type '(repeat (choice (function-item gnus-article-sort-by-number)
645 (function-item gnus-article-sort-by-author)
646 (function-item gnus-article-sort-by-subject)
647 (function-item gnus-article-sort-by-date)
648 (function-item gnus-article-sort-by-score)
649 (function :tag "other"))))
651 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
652 "*List of functions used for sorting threads in the summary buffer.
653 By default, threads are sorted by article number.
655 Each function takes two threads and returns non-nil if the first
656 thread should be sorted before the other. If you use more than one
657 function, the primary sort function should be the last. You should
658 probably always include `gnus-thread-sort-by-number' in the list of
659 sorting functions -- preferably first. Also note that sorting by date
660 is often much slower than sorting by number, and the sorting order is
661 very similar. (Sorting by date means sorting by the time the message
662 was sent, sorting by number means sorting by arrival time.)
664 Ready-made functions include `gnus-thread-sort-by-number',
665 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
666 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
667 `gnus-thread-sort-by-most-recent-number',
668 `gnus-thread-sort-by-most-recent-date', and
669 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
671 When threading is turned off, the variable
672 `gnus-article-sort-functions' controls how articles are sorted."
673 :group 'gnus-summary-sort
674 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
675 (function-item gnus-thread-sort-by-author)
676 (function-item gnus-thread-sort-by-subject)
677 (function-item gnus-thread-sort-by-date)
678 (function-item gnus-thread-sort-by-score)
679 (function-item gnus-thread-sort-by-total-score)
680 (function :tag "other"))))
682 (defcustom gnus-thread-score-function '+
683 "*Function used for calculating the total score of a thread.
685 The function is called with the scores of the article and each
686 subthread and should then return the score of the thread.
688 Some functions you can use are `+', `max', or `min'."
689 :group 'gnus-summary-sort
692 (defcustom gnus-summary-expunge-below nil
693 "All articles that have a score less than this variable will be expunged.
694 This variable is local to the summary buffers."
695 :group 'gnus-score-default
696 :type '(choice (const :tag "off" nil)
699 (defcustom gnus-thread-expunge-below nil
700 "All threads that have a total score less than this variable will be expunged.
701 See `gnus-thread-score-function' for en explanation of what a
704 This variable is local to the summary buffers."
705 :group 'gnus-threading
706 :group 'gnus-score-default
707 :type '(choice (const :tag "off" nil)
710 (defcustom gnus-summary-mode-hook nil
711 "*A hook for Gnus summary mode.
712 This hook is run before any variables are set in the summary buffer."
713 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
714 :group 'gnus-summary-various
717 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
718 (when (featurep 'xemacs)
719 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
720 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
721 (add-hook 'gnus-summary-mode-hook
722 'gnus-xmas-switch-horizontal-scrollbar-off))
724 (defcustom gnus-summary-menu-hook nil
725 "*Hook run after the creation of the summary mode menu."
726 :group 'gnus-summary-visual
729 (defcustom gnus-summary-exit-hook nil
730 "*A hook called on exit from the summary buffer.
731 It will be called with point in the group buffer."
732 :group 'gnus-summary-exit
735 (defcustom gnus-summary-prepare-hook nil
736 "*A hook called after the summary buffer has been generated.
737 If you want to modify the summary buffer, you can use this hook."
738 :group 'gnus-summary-various
741 (defcustom gnus-summary-prepared-hook nil
742 "*A hook called as the last thing after the summary buffer has been generated."
743 :group 'gnus-summary-various
746 (defcustom gnus-summary-generate-hook nil
747 "*A hook run just before generating the summary buffer.
748 This hook is commonly used to customize threading variables and the
750 :group 'gnus-summary-various
753 (defcustom gnus-select-group-hook nil
754 "*A hook called when a newsgroup is selected.
756 If you'd like to simplify subjects like the
757 `gnus-summary-next-same-subject' command does, you can use the
760 (add-hook gnus-select-group-hook
762 (mapcar (lambda (header)
763 (mail-header-set-subject
765 (gnus-simplify-subject
766 (mail-header-subject header) 're-only)))
767 gnus-newsgroup-headers)))"
768 :group 'gnus-group-select
771 (defcustom gnus-select-article-hook nil
772 "*A hook called when an article is selected."
773 :group 'gnus-summary-choose
776 (defcustom gnus-visual-mark-article-hook
777 (list 'gnus-highlight-selected-summary)
778 "*Hook run after selecting an article in the summary buffer.
779 It is meant to be used for highlighting the article in some way. It
780 is not run if `gnus-visual' is nil."
781 :group 'gnus-summary-visual
784 (defcustom gnus-parse-headers-hook nil
785 "*A hook called before parsing the headers."
789 (defcustom gnus-exit-group-hook nil
790 "*A hook called when exiting summary mode.
791 This hook is not called from the non-updating exit commands like `Q'."
795 (defcustom gnus-summary-update-hook
796 (list 'gnus-summary-highlight-line)
797 "*A hook called when a summary line is changed.
798 The hook will not be called if `gnus-visual' is nil.
800 The default function `gnus-summary-highlight-line' will
801 highlight the line according to the `gnus-summary-highlight'
803 :group 'gnus-summary-visual
806 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
807 "*A hook called when an article is selected for the first time.
808 The hook is intended to mark an article as read (or unread)
809 automatically when it is selected."
810 :group 'gnus-summary-choose
813 (defcustom gnus-group-no-more-groups-hook nil
814 "*A hook run when returning to group mode having no more (unread) groups."
815 :group 'gnus-group-select
818 (defcustom gnus-ps-print-hook nil
819 "*A hook run before ps-printing something from Gnus."
823 (defcustom gnus-summary-display-arrow
824 (and (fboundp 'display-graphic-p)
826 "*If non-nil, display an arrow highlighting the current article."
831 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
832 "Face used for highlighting the current article in the summary buffer."
833 :group 'gnus-summary-visual
836 (defcustom gnus-summary-highlight
837 '(((= mark gnus-canceled-mark)
838 . gnus-summary-cancelled-face)
839 ((and (> score default-high)
840 (or (= mark gnus-dormant-mark)
841 (= mark gnus-ticked-mark)))
842 . gnus-summary-high-ticked-face)
843 ((and (< score default-low)
844 (or (= mark gnus-dormant-mark)
845 (= mark gnus-ticked-mark)))
846 . gnus-summary-low-ticked-face)
847 ((or (= mark gnus-dormant-mark)
848 (= mark gnus-ticked-mark))
849 . gnus-summary-normal-ticked-face)
850 ((and (> score default-high) (= mark gnus-ancient-mark))
851 . gnus-summary-high-ancient-face)
852 ((and (< score default-low) (= mark gnus-ancient-mark))
853 . gnus-summary-low-ancient-face)
854 ((= mark gnus-ancient-mark)
855 . gnus-summary-normal-ancient-face)
856 ((and (> score default-high) (= mark gnus-unread-mark))
857 . gnus-summary-high-unread-face)
858 ((and (< score default-low) (= mark gnus-unread-mark))
859 . gnus-summary-low-unread-face)
860 ((= mark gnus-unread-mark)
861 . gnus-summary-normal-unread-face)
862 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
863 gnus-undownloaded-mark)))
864 . gnus-summary-high-unread-face)
865 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
866 gnus-undownloaded-mark)))
867 . gnus-summary-low-unread-face)
868 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
869 (memq article gnus-newsgroup-unreads))
870 . gnus-summary-normal-unread-face)
871 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
872 . gnus-summary-normal-read-face)
873 ((> score default-high)
874 . gnus-summary-high-read-face)
875 ((< score default-low)
876 . gnus-summary-low-read-face)
878 . gnus-summary-normal-read-face))
879 "*Controls the highlighting of summary buffer lines.
881 A list of (FORM . FACE) pairs. When deciding how a a particular
882 summary line should be displayed, each form is evaluated. The content
883 of the face field after the first true form is used. You can change
884 how those summary lines are displayed, by editing the face field.
886 You can use the following variables in the FORM field.
888 score: The article's score
889 default: The default article score.
890 default-high: The default score for high scored articles.
891 default-low: The default score for low scored articles.
892 below: The score below which articles are automatically marked as read.
893 mark: The articles mark."
894 :group 'gnus-summary-visual
895 :type '(repeat (cons (sexp :tag "Form" nil)
898 (defcustom gnus-alter-header-function nil
899 "Function called to allow alteration of article header structures.
900 The function is called with one parameter, the article header vector,
901 which it may alter in any way.")
903 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
904 "Variable that says which function should be used to decode a string with encoded words.")
906 (defcustom gnus-extra-headers '(To Newsgroups)
907 "*Extra headers to parse."
910 :type '(repeat symbol))
912 (defcustom gnus-ignored-from-addresses
913 (and user-mail-address (regexp-quote user-mail-address))
914 "*Regexp of From headers that may be suppressed in favor of To headers."
919 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
920 "List of charsets that should be ignored.
921 When these charsets are used in the \"charset\" parameter, the
922 default charset will be used instead."
924 :type '(repeat symbol)
925 :group 'gnus-charset)
927 (gnus-define-group-parameter
931 "Return the ignored charsets of GROUP."
932 :variable gnus-group-ignored-charsets-alist
934 '(("alt\\.chinese\\.text" iso-8859-1))
936 "Alist of regexps (to match group names) and charsets that should be ignored.
937 When these charsets are used in the \"charset\" parameter, the
938 default charset will be used instead."
939 :variable-group gnus-charset
940 :variable-type '(repeat (cons (regexp :tag "Group")
942 :parameter-type '(choice :tag "Ignored charsets"
945 :parameter-document "\
946 List of charsets that should be ignored.
948 When these charsets are used in the \"charset\" parameter, the
949 default charset will be used instead.")
951 (defcustom gnus-group-highlight-words-alist nil
952 "Alist of group regexps and highlight regexps.
953 This variable uses the same syntax as `gnus-emphasis-alist'."
955 :type '(repeat (cons (regexp :tag "Group")
956 (repeat (list (regexp :tag "Highlight regexp")
957 (number :tag "Group for entire word" 0)
958 (number :tag "Group for displayed part" 0)
960 gnus-emphasis-highlight-words)))))
961 :group 'gnus-summary-visual)
963 (defcustom gnus-summary-show-article-charset-alist
965 "Alist of number and charset.
966 The article will be shown with the charset corresponding to the
968 For example: ((1 . cn-gb-2312) (2 . big5))."
970 :type '(repeat (cons (number :tag "Argument" 1)
971 (symbol :tag "Charset")))
972 :group 'gnus-charset)
974 (defcustom gnus-preserve-marks t
975 "Whether marks are preserved when moving, copying and respooling messages."
978 :group 'gnus-summary-marks)
980 (defcustom gnus-alter-articles-to-read-function nil
981 "Function to be called to alter the list of articles to be selected."
982 :type '(choice (const nil) function)
983 :group 'gnus-summary)
985 (defcustom gnus-orphan-score nil
986 "*All orphans get this score added. Set in the score file."
987 :group 'gnus-score-default
988 :type '(choice (const nil)
991 (defcustom gnus-summary-save-parts-default-mime "image/.*"
992 "*A regexp to match MIME parts when saving multiple parts of a message
993 with gnus-summary-save-parts (X m). This regexp will be used by default
994 when prompting the user for which type of files to save."
999 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1000 "*A regexp to match MIME parts when saving multiple parts of a message
1001 with gnus-summary-save-parts (X m). This regexp will be used by default
1002 when prompting the user for which type of files to save."
1003 :group 'gnus-summary
1006 (defcustom gnus-read-all-available-headers nil
1007 "Whether Gnus should parse all headers made available to it.
1008 This is mostly relevant for slow backends where the user may
1009 wish to widen the summary buffer to include all headers
1010 that were fetched. Say, for nnultimate groups."
1011 :group 'gnus-summary
1012 :type '(choice boolean regexp))
1014 (defcustom gnus-summary-muttprint-program "muttprint"
1015 "Command (and optional arguments) used to run Muttprint."
1017 :group 'gnus-summary
1020 (defcustom gnus-article-no-strict-mime nil
1021 "If non-nil, don't require strict MIME.
1022 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1023 supply the MIME-Version header or deliberately strip it From the mail.
1024 Set it to non-nil, Gnus will treat some articles as MIME even if
1025 the MIME-Version header is missed."
1028 :group 'gnus-article)
1030 ;;; Internal variables
1032 (defvar gnus-summary-display-cache nil)
1033 (defvar gnus-article-mime-handles nil)
1034 (defvar gnus-article-decoded-p nil)
1035 (defvar gnus-article-charset nil)
1036 (defvar gnus-article-ignored-charsets nil)
1037 (defvar gnus-scores-exclude-files nil)
1038 (defvar gnus-page-broken nil)
1039 (defvar gnus-inhibit-mime-unbuttonizing nil)
1041 (defvar gnus-original-article nil)
1042 (defvar gnus-article-internal-prepare-hook nil)
1043 (defvar gnus-newsgroup-process-stack nil)
1045 (defvar gnus-thread-indent-array nil)
1046 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1047 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1048 "Function called to sort the articles within a thread after it has been gathered together.")
1050 (defvar gnus-summary-save-parts-type-history nil)
1051 (defvar gnus-summary-save-parts-last-directory nil)
1053 (defvar gnus-summary-save-parts-type-history nil)
1054 (defvar gnus-summary-save-parts-last-directory nil)
1056 ;; Avoid highlighting in kill files.
1057 (defvar gnus-summary-inhibit-highlight nil)
1058 (defvar gnus-newsgroup-selected-overlay nil)
1059 (defvar gnus-inhibit-limiting nil)
1060 (defvar gnus-newsgroup-adaptive-score-file nil)
1061 (defvar gnus-current-score-file nil)
1062 (defvar gnus-current-move-group nil)
1063 (defvar gnus-current-copy-group nil)
1064 (defvar gnus-current-crosspost-group nil)
1065 (defvar gnus-newsgroup-display nil)
1067 (defvar gnus-newsgroup-dependencies nil)
1068 (defvar gnus-newsgroup-adaptive nil)
1069 (defvar gnus-summary-display-article-function nil)
1070 (defvar gnus-summary-highlight-line-function nil
1071 "Function called after highlighting a summary line.")
1073 (defvar gnus-summary-line-format-alist
1074 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1075 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1076 (?s gnus-tmp-subject-or-nil ?s)
1077 (?n gnus-tmp-name ?s)
1078 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1080 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1082 (?F gnus-tmp-from ?s)
1083 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1084 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1085 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1086 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1087 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1088 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1089 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1090 (?L gnus-tmp-lines ?s)
1091 (?I gnus-tmp-indentation ?s)
1092 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1093 (?R gnus-tmp-replied ?c)
1094 (?\[ gnus-tmp-opening-bracket ?c)
1095 (?\] gnus-tmp-closing-bracket ?c)
1096 (?\> (make-string gnus-tmp-level ? ) ?s)
1097 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1098 (?i gnus-tmp-score ?d)
1099 (?z gnus-tmp-score-char ?c)
1100 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1101 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1102 (?U gnus-tmp-unread ?c)
1103 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1105 (?t (gnus-summary-number-of-articles-in-thread
1106 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1108 (?e (gnus-summary-number-of-articles-in-thread
1109 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1111 (?u gnus-tmp-user-defined ?s)
1112 (?P (gnus-pick-line-number) ?d)
1113 (?B gnus-tmp-thread-tree-header-string ?s)
1114 (user-date (gnus-user-date
1115 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1116 "An alist of format specifications that can appear in summary lines.
1117 These are paired with what variables they correspond with, along with
1118 the type of the variable (string, integer, character, etc).")
1120 (defvar gnus-summary-dummy-line-format-alist
1121 `((?S gnus-tmp-subject ?s)
1122 (?N gnus-tmp-number ?d)
1123 (?u gnus-tmp-user-defined ?s)))
1125 (defvar gnus-summary-mode-line-format-alist
1126 `((?G gnus-tmp-group-name ?s)
1127 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1128 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1129 (?A gnus-tmp-article-number ?d)
1130 (?Z gnus-tmp-unread-and-unselected ?s)
1131 (?V gnus-version ?s)
1132 (?U gnus-tmp-unread-and-unticked ?d)
1133 (?S gnus-tmp-subject ?s)
1134 (?e gnus-tmp-unselected ?d)
1135 (?u gnus-tmp-user-defined ?s)
1136 (?d (length gnus-newsgroup-dormant) ?d)
1137 (?t (length gnus-newsgroup-marked) ?d)
1138 (?r (length gnus-newsgroup-reads) ?d)
1139 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1140 (?E gnus-newsgroup-expunged-tally ?d)
1141 (?s (gnus-current-score-file-nondirectory) ?s)))
1143 (defvar gnus-last-search-regexp nil
1144 "Default regexp for article search command.")
1146 (defvar gnus-last-shell-command nil
1147 "Default shell command on article.")
1149 (defvar gnus-newsgroup-begin nil)
1150 (defvar gnus-newsgroup-end nil)
1151 (defvar gnus-newsgroup-last-rmail nil)
1152 (defvar gnus-newsgroup-last-mail nil)
1153 (defvar gnus-newsgroup-last-folder nil)
1154 (defvar gnus-newsgroup-last-file nil)
1155 (defvar gnus-newsgroup-auto-expire nil)
1156 (defvar gnus-newsgroup-active nil)
1158 (defvar gnus-newsgroup-data nil)
1159 (defvar gnus-newsgroup-data-reverse nil)
1160 (defvar gnus-newsgroup-limit nil)
1161 (defvar gnus-newsgroup-limits nil)
1163 (defvar gnus-newsgroup-unreads nil
1164 "Sorted list of unread articles in the current newsgroup.")
1166 (defvar gnus-newsgroup-unselected nil
1167 "Sorted list of unselected unread articles in the current newsgroup.")
1169 (defvar gnus-newsgroup-reads nil
1170 "Alist of read articles and article marks in the current newsgroup.")
1172 (defvar gnus-newsgroup-expunged-tally nil)
1174 (defvar gnus-newsgroup-marked nil
1175 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1177 (defvar gnus-newsgroup-killed nil
1178 "List of ranges of articles that have been through the scoring process.")
1180 (defvar gnus-newsgroup-cached nil
1181 "Sorted list of articles that come from the article cache.")
1183 (defvar gnus-newsgroup-saved nil
1184 "List of articles that have been saved.")
1186 (defvar gnus-newsgroup-kill-headers nil)
1188 (defvar gnus-newsgroup-replied nil
1189 "List of articles that have been replied to in the current newsgroup.")
1191 (defvar gnus-newsgroup-forwarded nil
1192 "List of articles that have been forwarded in the current newsgroup.")
1194 (defvar gnus-newsgroup-recent nil
1195 "List of articles that have are recent in the current newsgroup.")
1197 (defvar gnus-newsgroup-expirable nil
1198 "Sorted list of articles in the current newsgroup that can be expired.")
1200 (defvar gnus-newsgroup-processable nil
1201 "List of articles in the current newsgroup that can be processed.")
1203 (defvar gnus-newsgroup-downloadable nil
1204 "Sorted list of articles in the current newsgroup that can be processed.")
1206 (defvar gnus-newsgroup-undownloaded nil
1207 "List of articles in the current newsgroup that haven't been downloaded..")
1209 (defvar gnus-newsgroup-unsendable nil
1210 "List of articles in the current newsgroup that won't be sent.")
1212 (defvar gnus-newsgroup-bookmarks nil
1213 "List of articles in the current newsgroup that have bookmarks.")
1215 (defvar gnus-newsgroup-dormant nil
1216 "Sorted list of dormant articles in the current newsgroup.")
1218 (defvar gnus-newsgroup-unseen nil
1219 "List of unseen articles in the current newsgroup.")
1221 (defvar gnus-newsgroup-seen nil
1222 "Range of seen articles in the current newsgroup.")
1224 (defvar gnus-newsgroup-articles nil
1225 "List of articles in the current newsgroup.")
1227 (defvar gnus-newsgroup-scored nil
1228 "List of scored articles in the current newsgroup.")
1230 (defvar gnus-newsgroup-headers nil
1231 "List of article headers in the current newsgroup.")
1233 (defvar gnus-newsgroup-threads nil)
1235 (defvar gnus-newsgroup-prepared nil
1236 "Whether the current group has been prepared properly.")
1238 (defvar gnus-newsgroup-ancient nil
1239 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1241 (defvar gnus-newsgroup-sparse nil)
1243 (defvar gnus-current-article nil)
1244 (defvar gnus-article-current nil)
1245 (defvar gnus-current-headers nil)
1246 (defvar gnus-have-all-headers nil)
1247 (defvar gnus-last-article nil)
1248 (defvar gnus-newsgroup-history nil)
1249 (defvar gnus-newsgroup-charset nil)
1250 (defvar gnus-newsgroup-ephemeral-charset nil)
1251 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1253 (defvar gnus-article-before-search nil)
1255 (defconst gnus-summary-local-variables
1256 '(gnus-newsgroup-name
1257 gnus-newsgroup-begin gnus-newsgroup-end
1258 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1259 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1260 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1261 gnus-newsgroup-unselected gnus-newsgroup-marked
1262 gnus-newsgroup-reads gnus-newsgroup-saved
1263 gnus-newsgroup-replied gnus-newsgroup-forwarded
1264 gnus-newsgroup-recent
1265 gnus-newsgroup-expirable
1266 gnus-newsgroup-processable gnus-newsgroup-killed
1267 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1268 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1269 gnus-newsgroup-seen gnus-newsgroup-articles
1270 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1271 gnus-newsgroup-headers gnus-newsgroup-threads
1272 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1273 gnus-current-article gnus-current-headers gnus-have-all-headers
1274 gnus-last-article gnus-article-internal-prepare-hook
1275 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1276 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1277 gnus-thread-expunge-below
1278 gnus-score-alist gnus-current-score-file
1279 (gnus-summary-expunge-below . global)
1280 (gnus-summary-mark-below . global)
1281 (gnus-orphan-score . global)
1282 gnus-newsgroup-active gnus-scores-exclude-files
1283 gnus-newsgroup-history gnus-newsgroup-ancient
1284 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1285 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1286 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1287 (gnus-newsgroup-expunged-tally . 0)
1288 gnus-cache-removable-articles gnus-newsgroup-cached
1289 gnus-newsgroup-data gnus-newsgroup-data-reverse
1290 gnus-newsgroup-limit gnus-newsgroup-limits
1291 gnus-newsgroup-charset gnus-newsgroup-display)
1292 "Variables that are buffer-local to the summary buffers.")
1294 (defvar gnus-newsgroup-variables nil
1295 "A list of variables that have separate values in different newsgroups.
1296 A list of newsgroup (summary buffer) local variables, or cons of
1297 variables and their default values (when the default values are not
1298 nil), that should be made global while the summary buffer is active.
1299 These variables can be used to set variables in the group parameters
1300 while still allowing them to affect operations done in other
1301 buffers. For example:
1303 \(setq gnus-newsgroup-variables
1304 '(message-use-followup-to
1305 (gnus-visible-headers .
1306 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1309 ;; Byte-compiler warning.
1310 (eval-when-compile (defvar gnus-article-mode-map))
1314 (defvar gnus-decode-encoded-word-methods
1315 '(mail-decode-encoded-word-string)
1316 "List of methods used to decode encoded words.
1318 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1319 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1320 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1321 whose names match REGEXP.
1324 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1325 mail-decode-encoded-word-string
1326 (\"chinese\" . rfc1843-decode-string))")
1328 (defvar gnus-decode-encoded-word-methods-cache nil)
1330 (defun gnus-multi-decode-encoded-word-string (string)
1331 "Apply the functions from `gnus-encoded-word-methods' that match."
1332 (unless (and gnus-decode-encoded-word-methods-cache
1333 (eq gnus-newsgroup-name
1334 (car gnus-decode-encoded-word-methods-cache)))
1335 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1338 (nconc gnus-decode-encoded-word-methods-cache (list x))
1339 (if (and gnus-newsgroup-name
1340 (string-match (car x) gnus-newsgroup-name))
1341 (nconc gnus-decode-encoded-word-methods-cache
1343 gnus-decode-encoded-word-methods))
1344 (let ((xlist gnus-decode-encoded-word-methods-cache))
1347 (setq string (funcall (pop xlist) string))))
1350 ;; Subject simplification.
1352 (defun gnus-simplify-whitespace (str)
1353 "Remove excessive whitespace from STR."
1356 (while (string-match "[ \t][ \t]+" mystr)
1357 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1359 (substring mystr (match-end 0)))))
1361 (when (string-match "^[ \t]+" mystr)
1362 (setq mystr (substring mystr (match-end 0))))
1364 (when (string-match "[ \t]+$" mystr)
1365 (setq mystr (substring mystr 0 (match-beginning 0))))
1368 (defsubst gnus-simplify-subject-re (subject)
1369 "Remove \"Re:\" from subject lines."
1370 (if (string-match message-subject-re-regexp subject)
1371 (substring subject (match-end 0))
1374 (defun gnus-simplify-subject (subject &optional re-only)
1375 "Remove `Re:' and words in parentheses.
1376 If RE-ONLY is non-nil, strip leading `Re:'s only."
1377 (let ((case-fold-search t)) ;Ignore case.
1378 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1379 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1380 (setq subject (substring subject (match-end 0))))
1381 ;; Remove uninteresting prefixes.
1382 (when (and (not re-only)
1383 gnus-simplify-ignored-prefixes
1384 (string-match gnus-simplify-ignored-prefixes subject))
1385 (setq subject (substring subject (match-end 0))))
1386 ;; Remove words in parentheses from end.
1388 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1389 (setq subject (substring subject 0 (match-beginning 0)))))
1390 ;; Return subject string.
1393 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1395 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1396 (goto-char (point-min))
1397 (while (re-search-forward regexp nil t)
1398 (replace-match (or newtext ""))))
1400 (defun gnus-simplify-buffer-fuzzy ()
1401 "Simplify string in the buffer fuzzily.
1402 The string in the accessible portion of the current buffer is simplified.
1403 It is assumed to be a single-line subject.
1404 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1405 matter is removed. Additional things can be deleted by setting
1406 `gnus-simplify-subject-fuzzy-regexp'."
1407 (let ((case-fold-search t)
1409 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1411 (while (not (eq modified-tick (buffer-modified-tick)))
1412 (setq modified-tick (buffer-modified-tick))
1414 ((listp gnus-simplify-subject-fuzzy-regexp)
1415 (mapcar 'gnus-simplify-buffer-fuzzy-step
1416 gnus-simplify-subject-fuzzy-regexp))
1417 (gnus-simplify-subject-fuzzy-regexp
1418 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1419 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1420 (gnus-simplify-buffer-fuzzy-step
1421 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1422 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1424 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1425 (gnus-simplify-buffer-fuzzy-step " +" " ")
1426 (gnus-simplify-buffer-fuzzy-step " $")
1427 (gnus-simplify-buffer-fuzzy-step "^ +")))
1429 (defun gnus-simplify-subject-fuzzy (subject)
1430 "Simplify a subject string fuzzily.
1431 See `gnus-simplify-buffer-fuzzy' for details."
1433 (gnus-set-work-buffer)
1434 (let ((case-fold-search t))
1435 ;; Remove uninteresting prefixes.
1436 (when (and gnus-simplify-ignored-prefixes
1437 (string-match gnus-simplify-ignored-prefixes subject))
1438 (setq subject (substring subject (match-end 0))))
1440 (inline (gnus-simplify-buffer-fuzzy))
1443 (defsubst gnus-simplify-subject-fully (subject)
1444 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1446 (gnus-simplify-subject-functions
1447 (gnus-map-function gnus-simplify-subject-functions subject))
1448 ((null gnus-summary-gather-subject-limit)
1449 (gnus-simplify-subject-re subject))
1450 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1451 (gnus-simplify-subject-fuzzy subject))
1452 ((numberp gnus-summary-gather-subject-limit)
1453 (gnus-limit-string (gnus-simplify-subject-re subject)
1454 gnus-summary-gather-subject-limit))
1458 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1459 "Check whether two subjects are equal.
1460 If optional argument simple-first is t, first argument is already
1463 ((null simple-first)
1464 (equal (gnus-simplify-subject-fully s1)
1465 (gnus-simplify-subject-fully s2)))
1468 (gnus-simplify-subject-fully s2)))))
1470 (defun gnus-summary-bubble-group ()
1471 "Increase the score of the current group.
1472 This is a handy function to add to `gnus-summary-exit-hook' to
1473 increase the score of each group you read."
1474 (gnus-group-add-score gnus-newsgroup-name))
1478 ;;; Gnus summary mode
1481 (put 'gnus-summary-mode 'mode-class 'special)
1483 (defvar gnus-article-commands-menu)
1486 ;; Non-orthogonal keys
1488 (gnus-define-keys gnus-summary-mode-map
1489 " " gnus-summary-next-page
1490 "\177" gnus-summary-prev-page
1491 [delete] gnus-summary-prev-page
1492 [backspace] gnus-summary-prev-page
1493 "\r" gnus-summary-scroll-up
1494 "\M-\r" gnus-summary-scroll-down
1495 "n" gnus-summary-next-unread-article
1496 "p" gnus-summary-prev-unread-article
1497 "N" gnus-summary-next-article
1498 "P" gnus-summary-prev-article
1499 "\M-\C-n" gnus-summary-next-same-subject
1500 "\M-\C-p" gnus-summary-prev-same-subject
1501 "\M-n" gnus-summary-next-unread-subject
1502 "\M-p" gnus-summary-prev-unread-subject
1503 "." gnus-summary-first-unread-article
1504 "," gnus-summary-best-unread-article
1505 "\M-s" gnus-summary-search-article-forward
1506 "\M-r" gnus-summary-search-article-backward
1507 "<" gnus-summary-beginning-of-article
1508 ">" gnus-summary-end-of-article
1509 "j" gnus-summary-goto-article
1510 "^" gnus-summary-refer-parent-article
1511 "\M-^" gnus-summary-refer-article
1512 "u" gnus-summary-tick-article-forward
1513 "!" gnus-summary-tick-article-forward
1514 "U" gnus-summary-tick-article-backward
1515 "d" gnus-summary-mark-as-read-forward
1516 "D" gnus-summary-mark-as-read-backward
1517 "E" gnus-summary-mark-as-expirable
1518 "\M-u" gnus-summary-clear-mark-forward
1519 "\M-U" gnus-summary-clear-mark-backward
1520 "k" gnus-summary-kill-same-subject-and-select
1521 "\C-k" gnus-summary-kill-same-subject
1522 "\M-\C-k" gnus-summary-kill-thread
1523 "\M-\C-l" gnus-summary-lower-thread
1524 "e" gnus-summary-edit-article
1525 "#" gnus-summary-mark-as-processable
1526 "\M-#" gnus-summary-unmark-as-processable
1527 "\M-\C-t" gnus-summary-toggle-threads
1528 "\M-\C-s" gnus-summary-show-thread
1529 "\M-\C-h" gnus-summary-hide-thread
1530 "\M-\C-f" gnus-summary-next-thread
1531 "\M-\C-b" gnus-summary-prev-thread
1532 [(meta down)] gnus-summary-next-thread
1533 [(meta up)] gnus-summary-prev-thread
1534 "\M-\C-u" gnus-summary-up-thread
1535 "\M-\C-d" gnus-summary-down-thread
1536 "&" gnus-summary-execute-command
1537 "c" gnus-summary-catchup-and-exit
1538 "\C-w" gnus-summary-mark-region-as-read
1539 "\C-t" gnus-summary-toggle-truncation
1540 "?" gnus-summary-mark-as-dormant
1541 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1542 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1543 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1544 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1545 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1546 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1547 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1548 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1549 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1550 "=" gnus-summary-expand-window
1551 "\C-x\C-s" gnus-summary-reselect-current-group
1552 "\M-g" gnus-summary-rescan-group
1553 "w" gnus-summary-stop-page-breaking
1554 "\C-c\C-r" gnus-summary-caesar-message
1555 "f" gnus-summary-followup
1556 "F" gnus-summary-followup-with-original
1557 "C" gnus-summary-cancel-article
1558 "r" gnus-summary-reply
1559 "R" gnus-summary-reply-with-original
1560 "\C-c\C-f" gnus-summary-mail-forward
1561 "o" gnus-summary-save-article
1562 "\C-o" gnus-summary-save-article-mail
1563 "|" gnus-summary-pipe-output
1564 "\M-k" gnus-summary-edit-local-kill
1565 "\M-K" gnus-summary-edit-global-kill
1567 "\C-c\C-d" gnus-summary-describe-group
1568 "q" gnus-summary-exit
1569 "Q" gnus-summary-exit-no-update
1570 "\C-c\C-i" gnus-info-find-node
1571 gnus-mouse-2 gnus-mouse-pick-article
1572 "m" gnus-summary-mail-other-window
1573 "a" gnus-summary-post-news
1574 "i" gnus-summary-news-other-window
1575 "x" gnus-summary-limit-to-unread
1576 "s" gnus-summary-isearch-article
1577 "t" gnus-summary-toggle-header
1578 "g" gnus-summary-show-article
1579 "l" gnus-summary-goto-last-article
1580 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1581 "\C-d" gnus-summary-enter-digest-group
1582 "\M-\C-d" gnus-summary-read-document
1583 "\M-\C-e" gnus-summary-edit-parameters
1584 "\M-\C-a" gnus-summary-customize-parameters
1586 "*" gnus-cache-enter-article
1587 "\M-*" gnus-cache-remove-article
1588 "\M-&" gnus-summary-universal-argument
1589 "\C-l" gnus-recenter
1590 "I" gnus-summary-increase-score
1591 "L" gnus-summary-lower-score
1592 "\M-i" gnus-symbolic-argument
1593 "h" gnus-summary-select-article-buffer
1595 "b" gnus-article-view-part
1596 "\M-t" gnus-summary-toggle-display-buttonized
1598 "V" gnus-summary-score-map
1599 "X" gnus-uu-extract-map
1600 "S" gnus-summary-send-map)
1602 ;; Sort of orthogonal keymap
1603 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1604 "t" gnus-summary-tick-article-forward
1605 "!" gnus-summary-tick-article-forward
1606 "d" gnus-summary-mark-as-read-forward
1607 "r" gnus-summary-mark-as-read-forward
1608 "c" gnus-summary-clear-mark-forward
1609 " " gnus-summary-clear-mark-forward
1610 "e" gnus-summary-mark-as-expirable
1611 "x" gnus-summary-mark-as-expirable
1612 "?" gnus-summary-mark-as-dormant
1613 "b" gnus-summary-set-bookmark
1614 "B" gnus-summary-remove-bookmark
1615 "#" gnus-summary-mark-as-processable
1616 "\M-#" gnus-summary-unmark-as-processable
1617 "S" gnus-summary-limit-include-expunged
1618 "C" gnus-summary-catchup
1619 "H" gnus-summary-catchup-to-here
1620 "h" gnus-summary-catchup-from-here
1621 "\C-c" gnus-summary-catchup-all
1622 "k" gnus-summary-kill-same-subject-and-select
1623 "K" gnus-summary-kill-same-subject
1624 "P" gnus-uu-mark-map)
1626 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1627 "c" gnus-summary-clear-above
1628 "u" gnus-summary-tick-above
1629 "m" gnus-summary-mark-above
1630 "k" gnus-summary-kill-below)
1632 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1633 "/" gnus-summary-limit-to-subject
1634 "n" gnus-summary-limit-to-articles
1635 "w" gnus-summary-pop-limit
1636 "s" gnus-summary-limit-to-subject
1637 "a" gnus-summary-limit-to-author
1638 "u" gnus-summary-limit-to-unread
1639 "m" gnus-summary-limit-to-marks
1640 "M" gnus-summary-limit-exclude-marks
1641 "v" gnus-summary-limit-to-score
1642 "*" gnus-summary-limit-include-cached
1643 "D" gnus-summary-limit-include-dormant
1644 "T" gnus-summary-limit-include-thread
1645 "d" gnus-summary-limit-exclude-dormant
1646 "t" gnus-summary-limit-to-age
1647 "x" gnus-summary-limit-to-extra
1648 "p" gnus-summary-limit-to-display-predicate
1649 "E" gnus-summary-limit-include-expunged
1650 "c" gnus-summary-limit-exclude-childless-dormant
1651 "C" gnus-summary-limit-mark-excluded-as-read
1652 "o" gnus-summary-insert-old-articles
1653 "N" gnus-summary-insert-new-articles)
1655 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1656 "n" gnus-summary-next-unread-article
1657 "p" gnus-summary-prev-unread-article
1658 "N" gnus-summary-next-article
1659 "P" gnus-summary-prev-article
1660 "\C-n" gnus-summary-next-same-subject
1661 "\C-p" gnus-summary-prev-same-subject
1662 "\M-n" gnus-summary-next-unread-subject
1663 "\M-p" gnus-summary-prev-unread-subject
1664 "f" gnus-summary-first-unread-article
1665 "b" gnus-summary-best-unread-article
1666 "j" gnus-summary-goto-article
1667 "g" gnus-summary-goto-subject
1668 "l" gnus-summary-goto-last-article
1669 "o" gnus-summary-pop-article)
1671 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1672 "k" gnus-summary-kill-thread
1673 "l" gnus-summary-lower-thread
1674 "i" gnus-summary-raise-thread
1675 "T" gnus-summary-toggle-threads
1676 "t" gnus-summary-rethread-current
1677 "^" gnus-summary-reparent-thread
1678 "s" gnus-summary-show-thread
1679 "S" gnus-summary-show-all-threads
1680 "h" gnus-summary-hide-thread
1681 "H" gnus-summary-hide-all-threads
1682 "n" gnus-summary-next-thread
1683 "p" gnus-summary-prev-thread
1684 "u" gnus-summary-up-thread
1685 "o" gnus-summary-top-thread
1686 "d" gnus-summary-down-thread
1687 "#" gnus-uu-mark-thread
1688 "\M-#" gnus-uu-unmark-thread)
1690 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1691 "g" gnus-summary-prepare
1692 "c" gnus-summary-insert-cached-articles)
1694 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1695 "c" gnus-summary-catchup-and-exit
1696 "C" gnus-summary-catchup-all-and-exit
1697 "E" gnus-summary-exit-no-update
1698 "Q" gnus-summary-exit
1699 "Z" gnus-summary-exit
1700 "n" gnus-summary-catchup-and-goto-next-group
1701 "R" gnus-summary-reselect-current-group
1702 "G" gnus-summary-rescan-group
1703 "N" gnus-summary-next-group
1704 "s" gnus-summary-save-newsrc
1705 "P" gnus-summary-prev-group)
1707 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1708 " " gnus-summary-next-page
1709 "n" gnus-summary-next-page
1710 "\177" gnus-summary-prev-page
1711 [delete] gnus-summary-prev-page
1712 "p" gnus-summary-prev-page
1713 "\r" gnus-summary-scroll-up
1714 "\M-\r" gnus-summary-scroll-down
1715 "<" gnus-summary-beginning-of-article
1716 ">" gnus-summary-end-of-article
1717 "b" gnus-summary-beginning-of-article
1718 "e" gnus-summary-end-of-article
1719 "^" gnus-summary-refer-parent-article
1720 "r" gnus-summary-refer-parent-article
1721 "D" gnus-summary-enter-digest-group
1722 "R" gnus-summary-refer-references
1723 "T" gnus-summary-refer-thread
1724 "g" gnus-summary-show-article
1725 "s" gnus-summary-isearch-article
1726 "P" gnus-summary-print-article
1727 "M" gnus-mailing-list-insinuate
1728 "t" gnus-article-babel)
1730 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1731 "b" gnus-article-add-buttons
1732 "B" gnus-article-add-buttons-to-head
1733 "o" gnus-article-treat-overstrike
1734 "e" gnus-article-emphasize
1735 "w" gnus-article-fill-cited-article
1736 "Q" gnus-article-fill-long-lines
1737 "C" gnus-article-capitalize-sentences
1738 "c" gnus-article-remove-cr
1739 "q" gnus-article-de-quoted-unreadable
1740 "6" gnus-article-de-base64-unreadable
1741 "Z" gnus-article-decode-HZ
1742 "h" gnus-article-wash-html
1743 "s" gnus-summary-force-verify-and-decrypt
1744 "f" gnus-article-display-x-face
1745 "l" gnus-summary-stop-page-breaking
1746 "r" gnus-summary-caesar-message
1747 "t" gnus-summary-toggle-header
1748 "g" gnus-treat-smiley
1749 "v" gnus-summary-verbose-headers
1750 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1751 "p" gnus-article-verify-x-pgp-sig
1752 "d" gnus-article-treat-dumbquotes)
1754 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1755 "a" gnus-article-hide
1756 "h" gnus-article-hide-headers
1757 "b" gnus-article-hide-boring-headers
1758 "s" gnus-article-hide-signature
1759 "c" gnus-article-hide-citation
1760 "C" gnus-article-hide-citation-in-followups
1761 "l" gnus-article-hide-list-identifiers
1762 "p" gnus-article-hide-pgp
1763 "B" gnus-article-strip-banner
1764 "P" gnus-article-hide-pem
1765 "\C-c" gnus-article-hide-citation-maybe)
1767 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1768 "a" gnus-article-highlight
1769 "h" gnus-article-highlight-headers
1770 "c" gnus-article-highlight-citation
1771 "s" gnus-article-highlight-signature)
1773 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1774 "f" gnus-article-treat-fold-headers
1775 "u" gnus-article-treat-unfold-headers
1776 "n" gnus-article-treat-fold-newsgroups)
1778 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1779 "x" gnus-article-display-x-face
1780 "s" gnus-treat-smiley
1781 "D" gnus-article-remove-images
1782 "f" gnus-treat-from-picon
1783 "m" gnus-treat-mail-picon
1784 "n" gnus-treat-newsgroups-picon)
1786 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1787 "w" gnus-article-decode-mime-words
1788 "c" gnus-article-decode-charset
1789 "v" gnus-mime-view-all-parts
1790 "b" gnus-article-view-part)
1792 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1793 "z" gnus-article-date-ut
1794 "u" gnus-article-date-ut
1795 "l" gnus-article-date-local
1796 "p" gnus-article-date-english
1797 "e" gnus-article-date-lapsed
1798 "o" gnus-article-date-original
1799 "i" gnus-article-date-iso8601
1800 "s" gnus-article-date-user)
1802 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1803 "t" gnus-article-remove-trailing-blank-lines
1804 "l" gnus-article-strip-leading-blank-lines
1805 "m" gnus-article-strip-multiple-blank-lines
1806 "a" gnus-article-strip-blank-lines
1807 "A" gnus-article-strip-all-blank-lines
1808 "s" gnus-article-strip-leading-space
1809 "e" gnus-article-strip-trailing-space
1810 "w" gnus-article-remove-leading-whitespace)
1812 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1814 "f" gnus-summary-fetch-faq
1815 "d" gnus-summary-describe-group
1816 "h" gnus-summary-describe-briefly
1817 "i" gnus-info-find-node)
1819 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1820 "e" gnus-summary-expire-articles
1821 "\M-\C-e" gnus-summary-expire-articles-now
1822 "\177" gnus-summary-delete-article
1823 [delete] gnus-summary-delete-article
1824 [backspace] gnus-summary-delete-article
1825 "m" gnus-summary-move-article
1826 "r" gnus-summary-respool-article
1827 "w" gnus-summary-edit-article
1828 "c" gnus-summary-copy-article
1829 "B" gnus-summary-crosspost-article
1830 "q" gnus-summary-respool-query
1831 "t" gnus-summary-respool-trace
1832 "i" gnus-summary-import-article
1833 "I" gnus-summary-create-article
1834 "p" gnus-summary-article-posted-p)
1836 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1837 "o" gnus-summary-save-article
1838 "m" gnus-summary-save-article-mail
1839 "F" gnus-summary-write-article-file
1840 "r" gnus-summary-save-article-rmail
1841 "f" gnus-summary-save-article-file
1842 "b" gnus-summary-save-article-body-file
1843 "h" gnus-summary-save-article-folder
1844 "v" gnus-summary-save-article-vm
1845 "p" gnus-summary-pipe-output
1846 "P" gnus-summary-muttprint
1847 "s" gnus-soup-add-article)
1849 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1850 "b" gnus-summary-display-buttonized
1851 "m" gnus-summary-repair-multipart
1852 "v" gnus-article-view-part
1853 "o" gnus-article-save-part
1854 "c" gnus-article-copy-part
1855 "C" gnus-article-view-part-as-charset
1856 "e" gnus-article-externalize-part
1857 "E" gnus-article-encrypt-body
1858 "i" gnus-article-inline-part
1859 "|" gnus-article-pipe-part))
1861 (defvar gnus-article-post-menu nil)
1863 (defun gnus-summary-make-menu-bar ()
1864 (gnus-turn-off-edit-menu 'summary)
1866 (unless (boundp 'gnus-summary-misc-menu)
1869 gnus-summary-kill-menu gnus-summary-mode-map ""
1874 ["Customize" gnus-score-customize t])
1875 (gnus-make-score-map 'increase)
1876 (gnus-make-score-map 'lower)
1878 ["Kill below" gnus-summary-kill-below t]
1879 ["Mark above" gnus-summary-mark-above t]
1880 ["Tick above" gnus-summary-tick-above t]
1881 ["Clear above" gnus-summary-clear-above t])
1882 ["Current score" gnus-summary-current-score t]
1883 ["Set score" gnus-summary-set-score t]
1884 ["Switch current score file..." gnus-score-change-score-file t]
1885 ["Set mark below..." gnus-score-set-mark-below t]
1886 ["Set expunge below..." gnus-score-set-expunge-below t]
1887 ["Edit current score file" gnus-score-edit-current-scores t]
1888 ["Edit score file" gnus-score-edit-file t]
1889 ["Trace score" gnus-score-find-trace t]
1890 ["Find words" gnus-score-find-favourite-words t]
1891 ["Rescore buffer" gnus-summary-rescore t]
1892 ["Increase score..." gnus-summary-increase-score t]
1893 ["Lower score..." gnus-summary-lower-score t]))))
1895 ;; Define both the Article menu in the summary buffer and the
1896 ;; equivalent Commands menu in the article buffer here for
1900 ["All" gnus-article-hide t]
1901 ["Headers" gnus-article-hide-headers t]
1902 ["Signature" gnus-article-hide-signature t]
1903 ["Citation" gnus-article-hide-citation t]
1904 ["List identifiers" gnus-article-hide-list-identifiers t]
1905 ["PGP" gnus-article-hide-pgp t]
1906 ["Banner" gnus-article-strip-banner t]
1907 ["Boring headers" gnus-article-hide-boring-headers t])
1909 ["All" gnus-article-highlight t]
1910 ["Headers" gnus-article-highlight-headers t]
1911 ["Signature" gnus-article-highlight-signature t]
1912 ["Citation" gnus-article-highlight-citation t])
1914 ["Words" gnus-article-decode-mime-words t]
1915 ["Charset" gnus-article-decode-charset t]
1916 ["QP" gnus-article-de-quoted-unreadable t]
1917 ["Base64" gnus-article-de-base64-unreadable t]
1918 ["View all" gnus-mime-view-all-parts t]
1919 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1920 ["Encrypt body" gnus-article-encrypt-body t])
1922 ["Local" gnus-article-date-local t]
1923 ["ISO8601" gnus-article-date-iso8601 t]
1924 ["UT" gnus-article-date-ut t]
1925 ["Original" gnus-article-date-original t]
1926 ["Lapsed" gnus-article-date-lapsed t]
1927 ["User-defined" gnus-article-date-user t])
1929 ["Remove images" gnus-article-remove-images t]
1930 ["Toggle smiley" gnus-treat-smiley t]
1931 ["Show X-Face" gnus-article-display-x-face t]
1932 ["Show picons in From" gnus-treat-from-picon t]
1933 ["Show picons in mail headers" gnus-treat-mail-picon t]
1934 ["Show picons in news headers" gnus-treat-newsgroups-picon t])
1937 ["Leading" gnus-article-strip-leading-blank-lines t]
1938 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1939 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1940 ["All of the above" gnus-article-strip-blank-lines t]
1941 ["All" gnus-article-strip-all-blank-lines t]
1942 ["Leading space" gnus-article-strip-leading-space t]
1943 ["Trailing space" gnus-article-strip-trailing-space t]
1944 ["Leading space in headers"
1945 gnus-article-remove-leading-whitespace t])
1946 ["Overstrike" gnus-article-treat-overstrike t]
1947 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1948 ["Emphasis" gnus-article-emphasize t]
1949 ["Word wrap" gnus-article-fill-cited-article t]
1950 ["Fill long lines" gnus-article-fill-long-lines t]
1951 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1952 ["CR" gnus-article-remove-cr t]
1953 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1954 ["Base64" gnus-article-de-base64-unreadable t]
1955 ["Rot 13" gnus-summary-caesar-message
1956 ,@(if (featurep 'xemacs) '(t)
1957 '(:help "\"Caesar rotate\" article by 13"))]
1958 ["Unix pipe" gnus-summary-pipe-message t]
1959 ["Add buttons" gnus-article-add-buttons t]
1960 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1961 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1962 ["Verbose header" gnus-summary-verbose-headers t]
1963 ["Toggle header" gnus-summary-toggle-header t]
1964 ["Unfold headers" gnus-article-treat-unfold-headers t]
1965 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
1966 ["Html" gnus-article-wash-html t]
1967 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1968 ["HZ" gnus-article-decode-HZ t])
1970 ["Save in default format" gnus-summary-save-article
1971 ,@(if (featurep 'xemacs) '(t)
1972 '(:help "Save article using default method"))]
1973 ["Save in file" gnus-summary-save-article-file
1974 ,@(if (featurep 'xemacs) '(t)
1975 '(:help "Save article in file"))]
1976 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1977 ["Save in MH folder" gnus-summary-save-article-folder t]
1978 ["Save in VM folder" gnus-summary-save-article-vm t]
1979 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1980 ["Save body in file" gnus-summary-save-article-body-file t]
1981 ["Pipe through a filter" gnus-summary-pipe-output t]
1982 ["Add to SOUP packet" gnus-soup-add-article t]
1983 ["Print with Muttprint" gnus-summary-muttprint t]
1984 ["Print" gnus-summary-print-article t])
1986 ["Respool article..." gnus-summary-respool-article t]
1987 ["Move article..." gnus-summary-move-article
1988 (gnus-check-backend-function
1989 'request-move-article gnus-newsgroup-name)]
1990 ["Copy article..." gnus-summary-copy-article t]
1991 ["Crosspost article..." gnus-summary-crosspost-article
1992 (gnus-check-backend-function
1993 'request-replace-article gnus-newsgroup-name)]
1994 ["Import file..." gnus-summary-import-article t]
1995 ["Create article..." gnus-summary-create-article t]
1996 ["Check if posted" gnus-summary-article-posted-p t]
1997 ["Edit article" gnus-summary-edit-article
1998 (not (gnus-group-read-only-p))]
1999 ["Delete article" gnus-summary-delete-article
2000 (gnus-check-backend-function
2001 'request-expire-articles gnus-newsgroup-name)]
2002 ["Query respool" gnus-summary-respool-query t]
2003 ["Trace respool" gnus-summary-respool-trace t]
2004 ["Delete expirable articles" gnus-summary-expire-articles-now
2005 (gnus-check-backend-function
2006 'request-expire-articles gnus-newsgroup-name)])
2008 ["Uudecode" gnus-uu-decode-uu
2009 ,@(if (featurep 'xemacs) '(t)
2010 '(:help "Decode uuencoded article(s)"))]
2011 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2012 ["Unshar" gnus-uu-decode-unshar t]
2013 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2014 ["Save" gnus-uu-decode-save t]
2015 ["Binhex" gnus-uu-decode-binhex t]
2016 ["Postscript" gnus-uu-decode-postscript t])
2018 ["Enter article" gnus-cache-enter-article t]
2019 ["Remove article" gnus-cache-remove-article t])
2020 ["Translate" gnus-article-babel t]
2021 ["Select article buffer" gnus-summary-select-article-buffer t]
2022 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2023 ["Isearch article..." gnus-summary-isearch-article t]
2024 ["Beginning of the article" gnus-summary-beginning-of-article t]
2025 ["End of the article" gnus-summary-end-of-article t]
2026 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2027 ["Fetch referenced articles" gnus-summary-refer-references t]
2028 ["Fetch current thread" gnus-summary-refer-thread t]
2029 ["Fetch article with id..." gnus-summary-refer-article t]
2030 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2031 ["Redisplay" gnus-summary-show-article t]
2032 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2034 gnus-summary-article-menu gnus-summary-mode-map ""
2035 (cons "Article" innards))
2037 (if (not (keymapp gnus-summary-article-menu))
2039 gnus-article-commands-menu gnus-article-mode-map ""
2040 (cons "Commands" innards))
2041 ;; in Emacs, don't share menu.
2042 (setq gnus-article-commands-menu
2043 (copy-keymap gnus-summary-article-menu))
2044 (define-key gnus-article-mode-map [menu-bar commands]
2045 (cons "Commands" gnus-article-commands-menu))))
2048 gnus-summary-thread-menu gnus-summary-mode-map ""
2050 ["Toggle threading" gnus-summary-toggle-threads t]
2051 ["Hide threads" gnus-summary-hide-all-threads t]
2052 ["Show threads" gnus-summary-show-all-threads t]
2053 ["Hide thread" gnus-summary-hide-thread t]
2054 ["Show thread" gnus-summary-show-thread t]
2055 ["Go to next thread" gnus-summary-next-thread t]
2056 ["Go to previous thread" gnus-summary-prev-thread t]
2057 ["Go down thread" gnus-summary-down-thread t]
2058 ["Go up thread" gnus-summary-up-thread t]
2059 ["Top of thread" gnus-summary-top-thread t]
2060 ["Mark thread as read" gnus-summary-kill-thread t]
2061 ["Lower thread score" gnus-summary-lower-thread t]
2062 ["Raise thread score" gnus-summary-raise-thread t]
2063 ["Rethread current" gnus-summary-rethread-current t]))
2066 gnus-summary-post-menu gnus-summary-mode-map ""
2068 ["Send a message (mail or news)" gnus-summary-post-news
2069 ,@(if (featurep 'xemacs) '(t)
2070 '(:help "Post an article"))]
2071 ["Followup" gnus-summary-followup
2072 ,@(if (featurep 'xemacs) '(t)
2073 '(:help "Post followup to this article"))]
2074 ["Followup and yank" gnus-summary-followup-with-original
2075 ,@(if (featurep 'xemacs) '(t)
2076 '(:help "Post followup to this article, quoting its contents"))]
2077 ["Supersede article" gnus-summary-supersede-article t]
2078 ["Cancel article" gnus-summary-cancel-article
2079 ,@(if (featurep 'xemacs) '(t)
2080 '(:help "Cancel an article you posted"))]
2081 ["Reply" gnus-summary-reply t]
2082 ["Reply and yank" gnus-summary-reply-with-original t]
2083 ["Wide reply" gnus-summary-wide-reply t]
2084 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2085 ,@(if (featurep 'xemacs) '(t)
2086 '(:help "Mail a reply, quoting this article"))]
2087 ["Very wide reply" gnus-summary-very-wide-reply t]
2088 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2089 ,@(if (featurep 'xemacs) '(t)
2090 '(:help "Mail a very wide reply, quoting this article"))]
2091 ["Mail forward" gnus-summary-mail-forward t]
2092 ["Post forward" gnus-summary-post-forward t]
2093 ["Digest and mail" gnus-uu-digest-mail-forward t]
2094 ["Digest and post" gnus-uu-digest-post-forward t]
2095 ["Resend message" gnus-summary-resend-message t]
2096 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2097 ["Send a mail" gnus-summary-mail-other-window t]
2098 ["Create a local message" gnus-summary-news-other-window t]
2099 ["Uuencode and post" gnus-uu-post-news
2100 ,@(if (featurep 'xemacs) '(t)
2101 '(:help "Post a uuencoded article"))]
2102 ["Followup via news" gnus-summary-followup-to-mail t]
2103 ["Followup via news and yank"
2104 gnus-summary-followup-to-mail-with-original t]
2106 ;;["Send" gnus-summary-send-draft t]
2107 ;;["Send bounced" gnus-resend-bounced-mail t])
2111 ((not (keymapp gnus-summary-post-menu))
2112 (setq gnus-article-post-menu gnus-summary-post-menu))
2113 ((not gnus-article-post-menu)
2114 ;; Don't share post menu.
2115 (setq gnus-article-post-menu
2116 (copy-keymap gnus-summary-post-menu))))
2117 (define-key gnus-article-mode-map [menu-bar post]
2118 (cons "Post" gnus-article-post-menu))
2121 gnus-summary-misc-menu gnus-summary-mode-map ""
2124 ["Mark as read" gnus-summary-mark-as-read-forward t]
2125 ["Mark same subject and select"
2126 gnus-summary-kill-same-subject-and-select t]
2127 ["Mark same subject" gnus-summary-kill-same-subject t]
2128 ["Catchup" gnus-summary-catchup
2129 ,@(if (featurep 'xemacs) '(t)
2130 '(:help "Mark unread articles in this group as read"))]
2131 ["Catchup all" gnus-summary-catchup-all t]
2132 ["Catchup to here" gnus-summary-catchup-to-here t]
2133 ["Catchup from here" gnus-summary-catchup-from-here t]
2134 ["Catchup region" gnus-summary-mark-region-as-read t]
2135 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2137 ["Tick" gnus-summary-tick-article-forward t]
2138 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2139 ["Remove marks" gnus-summary-clear-mark-forward t]
2140 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2141 ["Set bookmark" gnus-summary-set-bookmark t]
2142 ["Remove bookmark" gnus-summary-remove-bookmark t])
2144 ["Marks..." gnus-summary-limit-to-marks t]
2145 ["Subject..." gnus-summary-limit-to-subject t]
2146 ["Author..." gnus-summary-limit-to-author t]
2147 ["Age..." gnus-summary-limit-to-age t]
2148 ["Extra..." gnus-summary-limit-to-extra t]
2149 ["Score" gnus-summary-limit-to-score t]
2150 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2151 ["Unread" gnus-summary-limit-to-unread t]
2152 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2153 ["Articles" gnus-summary-limit-to-articles t]
2154 ["Pop limit" gnus-summary-pop-limit t]
2155 ["Show dormant" gnus-summary-limit-include-dormant t]
2156 ["Hide childless dormant"
2157 gnus-summary-limit-exclude-childless-dormant t]
2158 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2159 ["Hide marked" gnus-summary-limit-exclude-marks t]
2160 ["Show expunged" gnus-summary-limit-include-expunged t])
2162 ["Set mark" gnus-summary-mark-as-processable t]
2163 ["Remove mark" gnus-summary-unmark-as-processable t]
2164 ["Remove all marks" gnus-summary-unmark-all-processable t]
2165 ["Mark above" gnus-uu-mark-over t]
2166 ["Mark series" gnus-uu-mark-series t]
2167 ["Mark region" gnus-uu-mark-region t]
2168 ["Unmark region" gnus-uu-unmark-region t]
2169 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2170 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2171 ["Mark all" gnus-uu-mark-all t]
2172 ["Mark buffer" gnus-uu-mark-buffer t]
2173 ["Mark sparse" gnus-uu-mark-sparse t]
2174 ["Mark thread" gnus-uu-mark-thread t]
2175 ["Unmark thread" gnus-uu-unmark-thread t]
2176 ("Process Mark Sets"
2177 ["Kill" gnus-summary-kill-process-mark t]
2178 ["Yank" gnus-summary-yank-process-mark
2179 gnus-newsgroup-process-stack]
2180 ["Save" gnus-summary-save-process-mark t]))
2182 ["Page forward" gnus-summary-next-page
2183 ,@(if (featurep 'xemacs) '(t)
2184 '(:help "Show next page of article"))]
2185 ["Page backward" gnus-summary-prev-page
2186 ,@(if (featurep 'xemacs) '(t)
2187 '(:help "Show previous page of article"))]
2188 ["Line forward" gnus-summary-scroll-up t])
2190 ["Next unread article" gnus-summary-next-unread-article t]
2191 ["Previous unread article" gnus-summary-prev-unread-article t]
2192 ["Next article" gnus-summary-next-article t]
2193 ["Previous article" gnus-summary-prev-article t]
2194 ["Next unread subject" gnus-summary-next-unread-subject t]
2195 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2196 ["Next article same subject" gnus-summary-next-same-subject t]
2197 ["Previous article same subject" gnus-summary-prev-same-subject t]
2198 ["First unread article" gnus-summary-first-unread-article t]
2199 ["Best unread article" gnus-summary-best-unread-article t]
2200 ["Go to subject number..." gnus-summary-goto-subject t]
2201 ["Go to article number..." gnus-summary-goto-article t]
2202 ["Go to the last article" gnus-summary-goto-last-article t]
2203 ["Pop article off history" gnus-summary-pop-article t])
2205 ["Sort by number" gnus-summary-sort-by-number t]
2206 ["Sort by author" gnus-summary-sort-by-author t]
2207 ["Sort by subject" gnus-summary-sort-by-subject t]
2208 ["Sort by date" gnus-summary-sort-by-date t]
2209 ["Sort by score" gnus-summary-sort-by-score t]
2210 ["Sort by lines" gnus-summary-sort-by-lines t]
2211 ["Sort by characters" gnus-summary-sort-by-chars t]
2212 ["Original sort" gnus-summary-sort-by-original t])
2214 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2215 ["Describe group" gnus-summary-describe-group t]
2216 ["Read manual" gnus-info-find-node t])
2218 ["Pick and read" gnus-pick-mode t]
2219 ["Binary" gnus-binary-mode t])
2221 ["Regenerate" gnus-summary-prepare t]
2222 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2223 ["Toggle threading" gnus-summary-toggle-threads t])
2224 ["See old articles" gnus-summary-insert-old-articles t]
2225 ["See new articles" gnus-summary-insert-new-articles t]
2226 ["Filter articles..." gnus-summary-execute-command t]
2227 ["Run command on subjects..." gnus-summary-universal-argument t]
2228 ["Search articles forward..." gnus-summary-search-article-forward t]
2229 ["Search articles backward..." gnus-summary-search-article-backward t]
2230 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2231 ["Expand window" gnus-summary-expand-window t]
2232 ["Expire expirable articles" gnus-summary-expire-articles
2233 (gnus-check-backend-function
2234 'request-expire-articles gnus-newsgroup-name)]
2235 ["Edit local kill file" gnus-summary-edit-local-kill t]
2236 ["Edit main kill file" gnus-summary-edit-global-kill t]
2237 ["Edit group parameters" gnus-summary-edit-parameters t]
2238 ["Customize group parameters" gnus-summary-customize-parameters t]
2239 ["Send a bug report" gnus-bug t]
2241 ["Catchup and exit" gnus-summary-catchup-and-exit
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "Mark unread articles in this group as read, then exit"))]
2244 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2245 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2246 ["Exit group" gnus-summary-exit
2247 ,@(if (featurep 'xemacs) '(t)
2248 '(:help "Exit current group, return to group selection mode"))]
2249 ["Exit group without updating" gnus-summary-exit-no-update t]
2250 ["Exit and goto next group" gnus-summary-next-group t]
2251 ["Exit and goto prev group" gnus-summary-prev-group t]
2252 ["Reselect group" gnus-summary-reselect-current-group t]
2253 ["Rescan group" gnus-summary-rescan-group t]
2254 ["Update dribble" gnus-summary-save-newsrc t])))
2256 (gnus-run-hooks 'gnus-summary-menu-hook)))
2258 (defvar gnus-summary-tool-bar-map nil)
2260 ;; Emacs 21 tool bar. Should be no-op otherwise.
2261 (defun gnus-summary-make-tool-bar ()
2262 (if (and (fboundp 'tool-bar-add-item-from-menu)
2263 (default-value 'tool-bar-mode)
2264 (not gnus-summary-tool-bar-map))
2265 (setq gnus-summary-tool-bar-map
2266 (let ((tool-bar-map (make-sparse-keymap))
2267 (load-path (mm-image-load-path)))
2268 (tool-bar-add-item-from-menu
2269 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2270 (tool-bar-add-item-from-menu
2271 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2272 (tool-bar-add-item-from-menu
2273 'gnus-summary-post-news "post" gnus-summary-mode-map)
2274 (tool-bar-add-item-from-menu
2275 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2276 (tool-bar-add-item-from-menu
2277 'gnus-summary-followup "followup" gnus-summary-mode-map)
2278 (tool-bar-add-item-from-menu
2279 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2280 (tool-bar-add-item-from-menu
2281 'gnus-summary-reply "reply" gnus-summary-mode-map)
2282 (tool-bar-add-item-from-menu
2283 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2284 (tool-bar-add-item-from-menu
2285 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2286 (tool-bar-add-item-from-menu
2287 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2288 (tool-bar-add-item-from-menu
2289 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2290 (tool-bar-add-item-from-menu
2291 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2292 (tool-bar-add-item-from-menu
2293 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2294 (tool-bar-add-item-from-menu
2295 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2296 (tool-bar-add-item-from-menu
2297 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2299 (if gnus-summary-tool-bar-map
2300 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2302 (defun gnus-score-set-default (var value)
2303 "A version of set that updates the GNU Emacs menu-bar."
2305 ;; It is the message that forces the active status to be updated.
2308 (defun gnus-make-score-map (type)
2309 "Make a summary score map of type TYPE."
2312 (let ((headers '(("author" "from" string)
2313 ("subject" "subject" string)
2314 ("article body" "body" string)
2315 ("article head" "head" string)
2316 ("xref" "xref" string)
2317 ("extra header" "extra" string)
2318 ("lines" "lines" number)
2319 ("followups to author" "followup" string)))
2320 (types '((number ("less than" <)
2323 (string ("substring" s)
2327 (perms '(("temporary" (current-time-string))
2335 (if (eq type 'lower)
2340 (setq header (car headers))
2346 (let ((ts (cdr (assoc (nth 2 header) types)))
2362 'gnus-summary-score-entry
2364 (if (or (string= (nth 1 header)
2366 (string= (nth 1 header)
2369 (list 'gnus-summary-header
2371 (list 'quote (nth 1 (car ts)))
2372 (list 'gnus-score-delta-default
2379 (list (nreverse outp))))
2382 (list (nreverse outt))))
2384 (setq headers (cdr headers)))
2385 (list (nreverse outh))))))))
2389 (defun gnus-summary-mode (&optional group)
2390 "Major mode for reading articles.
2392 All normal editing commands are switched off.
2393 \\<gnus-summary-mode-map>
2394 Each line in this buffer represents one article. To read an
2395 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2396 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2399 You can also post articles and send mail from this buffer. To
2400 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2401 of an article, type `\\[gnus-summary-reply]'.
2403 There are approx. one gazillion commands you can execute in this
2404 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2406 The following commands are available:
2408 \\{gnus-summary-mode-map}"
2410 (kill-all-local-variables)
2411 (when (gnus-visual-p 'summary-menu 'menu)
2412 (gnus-summary-make-menu-bar)
2413 (gnus-summary-make-tool-bar))
2414 (gnus-summary-make-local-variables)
2415 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2416 (gnus-summary-make-local-variables))
2417 (gnus-make-thread-indent-array)
2418 (gnus-simplify-mode-line)
2419 (setq major-mode 'gnus-summary-mode)
2420 (setq mode-name "Summary")
2421 (make-local-variable 'minor-mode-alist)
2422 (use-local-map gnus-summary-mode-map)
2423 (buffer-disable-undo)
2424 (setq buffer-read-only t) ;Disable modification
2425 (setq truncate-lines t)
2426 (setq selective-display t)
2427 (setq selective-display-ellipses t) ;Display `...'
2428 (gnus-summary-set-display-table)
2429 (gnus-set-default-directory)
2430 (setq gnus-newsgroup-name group)
2431 (make-local-variable 'gnus-summary-line-format)
2432 (make-local-variable 'gnus-summary-line-format-spec)
2433 (make-local-variable 'gnus-summary-dummy-line-format)
2434 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2435 (make-local-variable 'gnus-summary-mark-positions)
2436 (make-local-hook 'pre-command-hook)
2437 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2438 (gnus-run-hooks 'gnus-summary-mode-hook)
2439 (turn-on-gnus-mailing-list-mode)
2440 (mm-enable-multibyte)
2441 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2442 (gnus-update-summary-mark-positions))
2444 (defun gnus-summary-make-local-variables ()
2445 "Make all the local summary buffer variables."
2447 (dolist (local gnus-summary-local-variables)
2450 (if (eq (cdr local) 'global)
2451 ;; Copy the global value of the variable.
2452 (setq global (symbol-value (car local)))
2453 ;; Use the value from the list.
2454 (setq global (eval (cdr local))))
2455 (set (make-local-variable (car local)) global))
2456 ;; Simple nil-valued local variable.
2457 (set (make-local-variable local) nil)))))
2459 (defun gnus-summary-clear-local-variables ()
2460 (let ((locals gnus-summary-local-variables))
2462 (if (consp (car locals))
2463 (and (vectorp (caar locals))
2464 (set (caar locals) nil))
2465 (and (vectorp (car locals))
2466 (set (car locals) nil)))
2467 (setq locals (cdr locals)))))
2469 ;; Summary data functions.
2471 (defmacro gnus-data-number (data)
2474 (defmacro gnus-data-set-number (data number)
2475 `(setcar ,data ,number))
2477 (defmacro gnus-data-mark (data)
2480 (defmacro gnus-data-set-mark (data mark)
2481 `(setcar (nthcdr 1 ,data) ,mark))
2483 (defmacro gnus-data-pos (data)
2486 (defmacro gnus-data-set-pos (data pos)
2487 `(setcar (nthcdr 2 ,data) ,pos))
2489 (defmacro gnus-data-header (data)
2492 (defmacro gnus-data-set-header (data header)
2493 `(setf (nth 3 ,data) ,header))
2495 (defmacro gnus-data-level (data)
2498 (defmacro gnus-data-unread-p (data)
2499 `(= (nth 1 ,data) gnus-unread-mark))
2501 (defmacro gnus-data-read-p (data)
2502 `(/= (nth 1 ,data) gnus-unread-mark))
2504 (defmacro gnus-data-pseudo-p (data)
2505 `(consp (nth 3 ,data)))
2507 (defmacro gnus-data-find (number)
2508 `(assq ,number gnus-newsgroup-data))
2510 (defmacro gnus-data-find-list (number &optional data)
2511 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2512 (memq (assq ,number bdata)
2515 (defmacro gnus-data-make (number mark pos header level)
2516 `(list ,number ,mark ,pos ,header ,level))
2518 (defun gnus-data-enter (after-article number mark pos header level offset)
2519 (let ((data (gnus-data-find-list after-article)))
2521 (error "No such article: %d" after-article))
2522 (setcdr data (cons (gnus-data-make number mark pos header level)
2524 (setq gnus-newsgroup-data-reverse nil)
2525 (gnus-data-update-list (cddr data) offset)))
2527 (defun gnus-data-enter-list (after-article list &optional offset)
2529 (let ((data (and after-article (gnus-data-find-list after-article)))
2533 (let ((odata gnus-newsgroup-data))
2534 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2536 (gnus-data-update-list odata offset)))
2537 ;; Find the last element in the list to be spliced into the main
2540 (setq list (cdr list)))
2543 (setcdr list gnus-newsgroup-data)
2544 (setq gnus-newsgroup-data ilist)
2546 (gnus-data-update-list (cdr list) offset)))
2547 (setcdr list (cdr data))
2550 (gnus-data-update-list (cdr list) offset))))
2551 (setq gnus-newsgroup-data-reverse nil))))
2553 (defun gnus-data-remove (article &optional offset)
2554 (let ((data gnus-newsgroup-data))
2555 (if (= (gnus-data-number (car data)) article)
2557 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2558 gnus-newsgroup-data-reverse nil)
2560 (gnus-data-update-list gnus-newsgroup-data offset)))
2562 (when (= (gnus-data-number (cadr data)) article)
2563 (setcdr data (cddr data))
2565 (gnus-data-update-list (cdr data) offset))
2567 gnus-newsgroup-data-reverse nil))
2568 (setq data (cdr data))))))
2570 (defmacro gnus-data-list (backward)
2572 (or gnus-newsgroup-data-reverse
2573 (setq gnus-newsgroup-data-reverse
2574 (reverse gnus-newsgroup-data)))
2575 gnus-newsgroup-data))
2577 (defun gnus-data-update-list (data offset)
2578 "Add OFFSET to the POS of all data entries in DATA."
2579 (setq gnus-newsgroup-data-reverse nil)
2581 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2582 (setq data (cdr data))))
2584 (defun gnus-summary-article-pseudo-p (article)
2585 "Say whether this article is a pseudo article or not."
2586 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2588 (defmacro gnus-summary-article-sparse-p (article)
2589 "Say whether this article is a sparse article or not."
2590 `(memq ,article gnus-newsgroup-sparse))
2592 (defmacro gnus-summary-article-ancient-p (article)
2593 "Say whether this article is a sparse article or not."
2594 `(memq ,article gnus-newsgroup-ancient))
2596 (defun gnus-article-parent-p (number)
2597 "Say whether this article is a parent or not."
2598 (let ((data (gnus-data-find-list number)))
2599 (and (cdr data) ; There has to be an article after...
2600 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2601 (gnus-data-level (nth 1 data))))))
2603 (defun gnus-article-children (number)
2604 "Return a list of all children to NUMBER."
2605 (let* ((data (gnus-data-find-list number))
2606 (level (gnus-data-level (car data)))
2608 (setq data (cdr data))
2610 (= (gnus-data-level (car data)) (1+ level)))
2611 (push (gnus-data-number (car data)) children)
2612 (setq data (cdr data)))
2615 (defmacro gnus-summary-skip-intangible ()
2616 "If the current article is intangible, then jump to a different article."
2617 '(let ((to (get-text-property (point) 'gnus-intangible)))
2618 (and to (gnus-summary-goto-subject to))))
2620 (defmacro gnus-summary-article-intangible-p ()
2621 "Say whether this article is intangible or not."
2622 '(get-text-property (point) 'gnus-intangible))
2624 (defun gnus-article-read-p (article)
2625 "Say whether ARTICLE is read or not."
2626 (not (or (memq article gnus-newsgroup-marked)
2627 (memq article gnus-newsgroup-unreads)
2628 (memq article gnus-newsgroup-unselected)
2629 (memq article gnus-newsgroup-dormant))))
2631 ;; Some summary mode macros.
2633 (defmacro gnus-summary-article-number ()
2634 "The article number of the article on the current line.
2635 If there isn's an article number here, then we return the current
2638 (gnus-summary-skip-intangible)
2639 (or (get-text-property (point) 'gnus-number)
2640 (gnus-summary-last-subject))))
2642 (defmacro gnus-summary-article-header (&optional number)
2643 "Return the header of article NUMBER."
2644 `(gnus-data-header (gnus-data-find
2645 ,(or number '(gnus-summary-article-number)))))
2647 (defmacro gnus-summary-thread-level (&optional number)
2648 "Return the level of thread that starts with article NUMBER."
2649 `(if (and (eq gnus-summary-make-false-root 'dummy)
2650 (get-text-property (point) 'gnus-intangible))
2652 (gnus-data-level (gnus-data-find
2653 ,(or number '(gnus-summary-article-number))))))
2655 (defmacro gnus-summary-article-mark (&optional number)
2656 "Return the mark of article NUMBER."
2657 `(gnus-data-mark (gnus-data-find
2658 ,(or number '(gnus-summary-article-number)))))
2660 (defmacro gnus-summary-article-pos (&optional number)
2661 "Return the position of the line of article NUMBER."
2662 `(gnus-data-pos (gnus-data-find
2663 ,(or number '(gnus-summary-article-number)))))
2665 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2666 (defmacro gnus-summary-article-subject (&optional number)
2667 "Return current subject string or nil if nothing."
2670 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2671 '(gnus-data-header (assq (gnus-summary-article-number)
2672 gnus-newsgroup-data)))))
2675 (mail-header-subject headers))))
2677 (defmacro gnus-summary-article-score (&optional number)
2678 "Return current article score."
2679 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2680 gnus-newsgroup-scored))
2681 gnus-summary-default-score 0))
2683 (defun gnus-summary-article-children (&optional number)
2684 "Return a list of article numbers that are children of article NUMBER."
2685 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2686 (level (gnus-data-level (car data)))
2688 (while (and (setq data (cdr data))
2689 (> (setq l (gnus-data-level (car data))) level))
2690 (and (= (1+ level) l)
2691 (push (gnus-data-number (car data))
2693 (nreverse children)))
2695 (defun gnus-summary-article-parent (&optional number)
2696 "Return the article number of the parent of article NUMBER."
2697 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2698 (gnus-data-list t)))
2699 (level (gnus-data-level (car data))))
2701 () ; This is a root.
2702 ;; We search until we find an article with a level less than
2703 ;; this one. That function has to be the parent.
2704 (while (and (setq data (cdr data))
2705 (not (< (gnus-data-level (car data)) level))))
2706 (and data (gnus-data-number (car data))))))
2708 (defun gnus-unread-mark-p (mark)
2709 "Say whether MARK is the unread mark."
2710 (= mark gnus-unread-mark))
2712 (defun gnus-read-mark-p (mark)
2713 "Say whether MARK is one of the marks that mark as read.
2714 This is all marks except unread, ticked, dormant, and expirable."
2715 (not (or (= mark gnus-unread-mark)
2716 (= mark gnus-ticked-mark)
2717 (= mark gnus-dormant-mark)
2718 (= mark gnus-expirable-mark))))
2720 (defmacro gnus-article-mark (number)
2721 "Return the MARK of article NUMBER.
2722 This macro should only be used when computing the mark the \"first\"
2723 time; i.e., when generating the summary lines. After that,
2724 `gnus-summary-article-mark' should be used to examine the
2727 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2728 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2729 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2730 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2731 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2732 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2733 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2734 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2735 gnus-ancient-mark))))
2737 ;; Saving hidden threads.
2739 (defmacro gnus-save-hidden-threads (&rest forms)
2740 "Save hidden threads, eval FORMS, and restore the hidden threads."
2741 (let ((config (make-symbol "config")))
2742 `(let ((,config (gnus-hidden-threads-configuration)))
2746 (gnus-restore-hidden-threads-configuration ,config)))))
2747 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2748 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2750 (defun gnus-data-compute-positions ()
2751 "Compute the positions of all articles."
2752 (setq gnus-newsgroup-data-reverse nil)
2753 (let ((data gnus-newsgroup-data))
2755 (gnus-save-hidden-threads
2756 (gnus-summary-show-all-threads)
2757 (goto-char (point-min))
2759 (while (get-text-property (point) 'gnus-intangible)
2761 (gnus-data-set-pos (car data) (+ (point) 3))
2762 (setq data (cdr data))
2763 (forward-line 1))))))
2765 (defun gnus-hidden-threads-configuration ()
2766 "Return the current hidden threads configuration."
2769 (goto-char (point-min))
2770 (while (search-forward "\r" nil t)
2771 (push (1- (point)) config))
2774 (defun gnus-restore-hidden-threads-configuration (config)
2775 "Restore hidden threads configuration from CONFIG."
2777 (let (point buffer-read-only)
2778 (while (setq point (pop config))
2779 (when (and (< point (point-max))
2781 (eq (char-after) ?\n))
2782 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2784 ;; Various summary mode internalish functions.
2786 (defun gnus-mouse-pick-article (e)
2789 (gnus-summary-next-page nil t))
2791 (defun gnus-summary-set-display-table ()
2792 "Change the display table.
2793 Odd characters have a tendency to mess
2794 up nicely formatted displays - we make all possible glyphs
2795 display only a single character."
2797 ;; We start from the standard display table, if any.
2798 (let ((table (or (copy-sequence standard-display-table)
2799 (make-display-table)))
2801 ;; Nix out all the control chars...
2802 (while (>= (setq i (1- i)) 0)
2803 (aset table i [??]))
2804 ;; ... but not newline and cr, of course. (cr is necessary for the
2805 ;; selective display).
2806 (aset table ?\n nil)
2807 (aset table ?\r nil)
2808 ;; We keep TAB as well.
2809 (aset table ?\t nil)
2810 ;; We nix out any glyphs over 126 that are not set already.
2812 (while (>= (setq i (1- i)) 127)
2813 ;; Only modify if the entry is nil.
2814 (unless (aref table i)
2815 (aset table i [??]))))
2816 (setq buffer-display-table table)))
2818 (defun gnus-summary-set-article-display-arrow (pos)
2819 "Update the overlay arrow to point to line at position POS."
2820 (when (and gnus-summary-display-arrow
2821 (boundp 'overlay-arrow-position)
2822 (boundp 'overlay-arrow-string))
2826 (unless overlay-arrow-position
2827 (setq overlay-arrow-position (make-marker)))
2828 (setq overlay-arrow-string "=>"
2829 overlay-arrow-position (set-marker overlay-arrow-position
2831 (current-buffer))))))
2833 (defun gnus-summary-buffer-name (group)
2834 "Return the summary buffer name of GROUP."
2835 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2837 (defun gnus-summary-setup-buffer (group)
2838 "Initialize summary buffer."
2839 (let ((buffer (gnus-summary-buffer-name group))
2840 (dead-name (concat "*Dead Summary "
2841 (gnus-group-decoded-name group) "*")))
2842 ;; If a dead summary buffer exists, we kill it.
2843 (when (gnus-buffer-live-p dead-name)
2844 (gnus-kill-buffer dead-name))
2845 (if (get-buffer buffer)
2848 (setq gnus-summary-buffer (current-buffer))
2849 (not gnus-newsgroup-prepared))
2850 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2851 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2852 (gnus-summary-mode group)
2854 (gnus-carpal-setup-buffer 'summary))
2855 (unless gnus-single-article-buffer
2856 (make-local-variable 'gnus-article-buffer)
2857 (make-local-variable 'gnus-article-current)
2858 (make-local-variable 'gnus-original-article-buffer))
2859 (setq gnus-newsgroup-name group)
2860 ;; Set any local variables in the group parameters.
2861 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2864 (defun gnus-set-global-variables ()
2865 "Set the global equivalents of the buffer-local variables.
2866 They are set to the latest values they had. These reflect the summary
2867 buffer that was in action when the last article was fetched."
2868 (when (eq major-mode 'gnus-summary-mode)
2869 (setq gnus-summary-buffer (current-buffer))
2870 (let ((name gnus-newsgroup-name)
2871 (marked gnus-newsgroup-marked)
2872 (unread gnus-newsgroup-unreads)
2873 (headers gnus-current-headers)
2874 (data gnus-newsgroup-data)
2875 (summary gnus-summary-buffer)
2876 (article-buffer gnus-article-buffer)
2877 (original gnus-original-article-buffer)
2878 (gac gnus-article-current)
2879 (reffed gnus-reffed-article-number)
2880 (score-file gnus-current-score-file)
2881 (default-charset gnus-newsgroup-charset)
2883 (let ((locals gnus-newsgroup-variables))
2885 (if (consp (car locals))
2886 (push (eval (caar locals)) vlist)
2887 (push (eval (car locals)) vlist))
2888 (setq locals (cdr locals)))
2889 (setq vlist (nreverse vlist)))
2891 (set-buffer gnus-group-buffer)
2892 (setq gnus-newsgroup-name name
2893 gnus-newsgroup-marked marked
2894 gnus-newsgroup-unreads unread
2895 gnus-current-headers headers
2896 gnus-newsgroup-data data
2897 gnus-article-current gac
2898 gnus-summary-buffer summary
2899 gnus-article-buffer article-buffer
2900 gnus-original-article-buffer original
2901 gnus-reffed-article-number reffed
2902 gnus-current-score-file score-file
2903 gnus-newsgroup-charset default-charset)
2904 (let ((locals gnus-newsgroup-variables))
2906 (if (consp (car locals))
2907 (set (caar locals) (pop vlist))
2908 (set (car locals) (pop vlist)))
2909 (setq locals (cdr locals))))
2910 ;; The article buffer also has local variables.
2911 (when (gnus-buffer-live-p gnus-article-buffer)
2912 (set-buffer gnus-article-buffer)
2913 (setq gnus-summary-buffer summary))))))
2915 (defun gnus-summary-article-unread-p (article)
2916 "Say whether ARTICLE is unread or not."
2917 (memq article gnus-newsgroup-unreads))
2919 (defun gnus-summary-first-article-p (&optional article)
2920 "Return whether ARTICLE is the first article in the buffer."
2921 (if (not (setq article (or article (gnus-summary-article-number))))
2923 (eq article (caar gnus-newsgroup-data))))
2925 (defun gnus-summary-last-article-p (&optional article)
2926 "Return whether ARTICLE is the last article in the buffer."
2927 (if (not (setq article (or article (gnus-summary-article-number))))
2928 ;; All non-existent numbers are the last article. :-)
2930 (not (cdr (gnus-data-find-list article)))))
2932 (defun gnus-make-thread-indent-array ()
2934 (unless (and gnus-thread-indent-array
2935 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2936 (setq gnus-thread-indent-array (make-vector 201 "")
2937 gnus-thread-indent-array-level gnus-thread-indent-level)
2939 (aset gnus-thread-indent-array n
2940 (make-string (* n gnus-thread-indent-level) ? ))
2943 (defun gnus-update-summary-mark-positions ()
2944 "Compute where the summary marks are to go."
2946 (when (gnus-buffer-exists-p gnus-summary-buffer)
2947 (set-buffer gnus-summary-buffer))
2948 (let ((gnus-replied-mark 129)
2949 (gnus-score-below-mark 130)
2950 (gnus-score-over-mark 130)
2951 (gnus-download-mark 131)
2952 (spec gnus-summary-line-format-spec)
2955 (gnus-set-work-buffer)
2956 (let ((gnus-summary-line-format-spec spec)
2957 (gnus-newsgroup-downloadable '((0 . t))))
2958 (gnus-summary-insert-line
2959 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
2960 0 nil 128 t nil "" nil 1)
2961 (goto-char (point-min))
2962 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2964 (goto-char (point-min))
2965 (push (cons 'replied (and (search-forward "\201" nil t)
2968 (goto-char (point-min))
2969 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2971 (goto-char (point-min))
2972 (push (cons 'download
2973 (and (search-forward "\203" nil t) (- (point) 2)))
2975 (setq gnus-summary-mark-positions pos))))
2977 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2978 "Insert a dummy root in the summary buffer."
2980 (gnus-add-text-properties
2981 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2982 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2984 (defun gnus-summary-extract-address-component (from)
2985 (or (car (funcall gnus-extract-address-components from))
2988 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2989 (let ((mail-parse-charset gnus-newsgroup-charset)
2990 ; Is it really necessary to do this next part for each summary line?
2991 ; Luckily, doesn't seem to slow things down much.
2992 (mail-parse-ignored-charsets
2993 (save-excursion (set-buffer gnus-summary-buffer)
2994 gnus-newsgroup-ignored-charsets)))
2996 (and gnus-ignored-from-addresses
2997 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2998 (let ((extra-headers (mail-header-extra header))
3002 ((setq to (cdr (assq 'To extra-headers)))
3005 (gnus-summary-extract-address-component
3006 (funcall gnus-decode-encoded-word-function to)))))
3007 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3008 (concat "=> " newsgroups)))))
3009 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3011 (defun gnus-summary-insert-line (gnus-tmp-header
3012 gnus-tmp-level gnus-tmp-current
3013 gnus-tmp-unread gnus-tmp-replied
3014 gnus-tmp-expirable gnus-tmp-subject-or-nil
3015 &optional gnus-tmp-dummy gnus-tmp-score
3017 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3018 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3019 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3020 (gnus-tmp-score-char
3021 (if (or (null gnus-summary-default-score)
3022 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3023 gnus-summary-zcore-fuzz))
3025 (if (< gnus-tmp-score gnus-summary-default-score)
3026 gnus-score-below-mark gnus-score-over-mark)))
3027 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3029 (cond (gnus-tmp-process gnus-process-mark)
3030 ((memq gnus-tmp-current gnus-newsgroup-cached)
3032 (gnus-tmp-replied gnus-replied-mark)
3033 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3034 gnus-forwarded-mark)
3035 ((memq gnus-tmp-current gnus-newsgroup-saved)
3037 ((memq gnus-tmp-number gnus-newsgroup-recent)
3039 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3042 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3045 ((string-match "<[^>]+> *$" gnus-tmp-from)
3046 (let ((beg (match-beginning 0)))
3047 (or (and (string-match "^\".+\"" gnus-tmp-from)
3048 (substring gnus-tmp-from 1 (1- (match-end 0))))
3049 (substring gnus-tmp-from 0 beg))))
3050 ((string-match "(.+)" gnus-tmp-from)
3051 (substring gnus-tmp-from
3052 (1+ (match-beginning 0)) (1- (match-end 0))))
3054 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3055 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3056 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3057 (buffer-read-only nil))
3058 (when (string= gnus-tmp-name "")
3059 (setq gnus-tmp-name gnus-tmp-from))
3060 (unless (numberp gnus-tmp-lines)
3061 (setq gnus-tmp-lines -1))
3062 (if (= gnus-tmp-lines -1)
3063 (setq gnus-tmp-lines "?")
3064 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3065 (gnus-put-text-property
3067 (progn (eval gnus-summary-line-format-spec) (point))
3068 'gnus-number gnus-tmp-number)
3069 (when (gnus-visual-p 'summary-highlight 'highlight)
3071 (gnus-run-hooks 'gnus-summary-update-hook)
3074 (defun gnus-summary-update-line (&optional dont-update)
3075 "Update summary line after change."
3076 (when (and gnus-summary-default-score
3077 (not gnus-summary-inhibit-highlight))
3078 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3079 (article (gnus-summary-article-number))
3080 (score (gnus-summary-article-score article)))
3082 (if (and gnus-summary-mark-below
3083 (< (gnus-summary-article-score)
3084 gnus-summary-mark-below))
3085 ;; This article has a low score, so we mark it as read.
3086 (when (memq article gnus-newsgroup-unreads)
3087 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3088 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3089 ;; This article was previously marked as read on account
3090 ;; of a low score, but now it has risen, so we mark it as
3092 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3093 (gnus-summary-update-mark
3094 (if (or (null gnus-summary-default-score)
3095 (<= (abs (- score gnus-summary-default-score))
3096 gnus-summary-zcore-fuzz))
3098 (if (< score gnus-summary-default-score)
3099 gnus-score-below-mark gnus-score-over-mark))
3101 ;; Do visual highlighting.
3102 (when (gnus-visual-p 'summary-highlight 'highlight)
3103 (gnus-run-hooks 'gnus-summary-update-hook)))))
3105 (defvar gnus-tmp-new-adopts nil)
3107 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3108 "Return the number of articles in THREAD.
3109 This may be 0 in some cases -- if none of the articles in
3110 the thread are to be displayed."
3112 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3114 ((not (listp thread))
3116 ((and (consp thread) (cdr thread))
3119 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3122 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3125 (when (and level (zerop level) gnus-tmp-new-adopts)
3128 'gnus-summary-number-of-articles-in-thread
3129 gnus-tmp-new-adopts))))
3131 (if (> number 1) gnus-not-empty-thread-mark
3132 gnus-empty-thread-mark)
3135 (defun gnus-summary-set-local-parameters (group)
3136 "Go through the local params of GROUP and set all variable specs in that list."
3137 (let ((params (gnus-group-find-parameter group))
3138 (vars '(quit-config)) ; Ignore quit-config.
3141 (setq elem (car params)
3142 params (cdr params))
3143 (and (consp elem) ; Has to be a cons.
3144 (consp (cdr elem)) ; The cdr has to be a list.
3145 (symbolp (car elem)) ; Has to be a symbol in there.
3146 (not (memq (car elem) vars))
3147 (ignore-errors ; So we set it.
3148 (push (car elem) vars)
3149 (make-local-variable (car elem))
3150 (set (car elem) (eval (nth 1 elem))))))))
3152 (defun gnus-summary-read-group (group &optional show-all no-article
3153 kill-buffer no-display backward
3155 "Start reading news in newsgroup GROUP.
3156 If SHOW-ALL is non-nil, already read articles are also listed.
3157 If NO-ARTICLE is non-nil, no article is selected initially.
3158 If NO-DISPLAY, don't generate a summary buffer."
3162 (let ((gnus-auto-select-next nil))
3163 (or (gnus-summary-read-group-1
3164 group show-all no-article
3165 kill-buffer no-display
3168 select-articles nil)))))
3169 (eq gnus-auto-select-next 'quietly))
3170 (set-buffer gnus-group-buffer)
3171 ;; The entry function called above goes to the next
3172 ;; group automatically, so we go two groups back
3173 ;; if we are searching for the previous group.
3175 (gnus-group-prev-unread-group 2))
3176 (if (not (equal group (gnus-group-group-name)))
3177 (setq group (gnus-group-group-name))
3181 (defun gnus-summary-read-group-1 (group show-all no-article
3182 kill-buffer no-display
3183 &optional select-articles)
3184 ;; Killed foreign groups can't be entered.
3185 ;; (when (and (not (gnus-group-native-p group))
3186 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3187 ;; (error "Dead non-native groups can't be entered"))
3188 (gnus-message 5 "Retrieving newsgroup: %s..."
3189 (gnus-group-decoded-name group))
3190 (let* ((new-group (gnus-summary-setup-buffer group))
3191 (quit-config (gnus-group-quit-config group))
3192 (did-select (and new-group (gnus-select-newsgroup
3193 group show-all select-articles))))
3195 ;; This summary buffer exists already, so we just select it.
3197 (gnus-set-global-variables)
3199 (gnus-kill-or-deaden-summary kill-buffer))
3200 (gnus-configure-windows 'summary 'force)
3201 (gnus-set-mode-line 'summary)
3202 (gnus-summary-position-point)
3205 ;; We couldn't select this group.
3207 (when (and (eq major-mode 'gnus-summary-mode)
3208 (not (equal (current-buffer) kill-buffer)))
3209 (kill-buffer (current-buffer))
3210 (if (not quit-config)
3212 ;; Update the info -- marks might need to be removed,
3214 (gnus-summary-update-info)
3215 (set-buffer gnus-group-buffer)
3216 (gnus-group-jump-to-group group)
3217 (gnus-group-next-unread-group 1))
3218 (gnus-handle-ephemeral-exit quit-config)))
3219 (let ((grpinfo (gnus-get-info group)))
3220 (if (null (gnus-info-read grpinfo))
3221 (gnus-message 3 "Group %s contains no messages"
3222 (gnus-group-decoded-name group))
3223 (gnus-message 3 "Can't select group")))
3225 ;; The user did a `C-g' while prompting for number of articles,
3226 ;; so we exit this group.
3227 ((eq did-select 'quit)
3228 (and (eq major-mode 'gnus-summary-mode)
3229 (not (equal (current-buffer) kill-buffer))
3230 (kill-buffer (current-buffer)))
3232 (gnus-kill-or-deaden-summary kill-buffer))
3233 (if (not quit-config)
3235 (set-buffer gnus-group-buffer)
3236 (gnus-group-jump-to-group group)
3237 (gnus-group-next-unread-group 1)
3238 (gnus-configure-windows 'group 'force))
3239 (gnus-handle-ephemeral-exit quit-config))
3240 ;; Finally signal the quit.
3242 ;; The group was successfully selected.
3244 (gnus-set-global-variables)
3245 ;; Save the active value in effect when the group was entered.
3246 (setq gnus-newsgroup-active
3248 (gnus-active gnus-newsgroup-name)))
3249 ;; You can change the summary buffer in some way with this hook.
3250 (gnus-run-hooks 'gnus-select-group-hook)
3251 (gnus-update-format-specifications
3252 nil 'summary 'summary-mode 'summary-dummy)
3253 (gnus-update-summary-mark-positions)
3254 ;; Do score processing.
3255 (when gnus-use-scoring
3256 (gnus-possibly-score-headers))
3257 ;; Check whether to fill in the gaps in the threads.
3258 (when gnus-build-sparse-threads
3259 (gnus-build-sparse-threads))
3260 ;; Find the initial limit.
3261 (if gnus-show-threads
3263 (let ((gnus-newsgroup-dormant nil))
3264 (gnus-summary-initial-limit show-all))
3265 (gnus-summary-initial-limit show-all))
3266 ;; When untreaded, all articles are always shown.
3267 (setq gnus-newsgroup-limit
3269 (lambda (header) (mail-header-number header))
3270 gnus-newsgroup-headers)))
3271 ;; Generate the summary buffer.
3273 (gnus-summary-prepare))
3274 (when gnus-use-trees
3275 (gnus-tree-open group)
3276 (setq gnus-summary-highlight-line-function
3277 'gnus-tree-highlight-article))
3278 ;; If the summary buffer is empty, but there are some low-scored
3279 ;; articles or some excluded dormants, we include these in the
3281 (when (and (zerop (buffer-size))
3283 (cond (gnus-newsgroup-dormant
3284 (gnus-summary-limit-include-dormant))
3285 ((and gnus-newsgroup-scored show-all)
3286 (gnus-summary-limit-include-expunged t))))
3287 ;; Function `gnus-apply-kill-file' must be called in this hook.
3288 (gnus-run-hooks 'gnus-apply-kill-hook)
3289 (if (and (zerop (buffer-size))
3292 ;; This newsgroup is empty.
3293 (gnus-summary-catchup-and-exit nil t)
3294 (gnus-message 6 "No unread news")
3296 (gnus-kill-or-deaden-summary kill-buffer))
3297 ;; Return nil from this function.
3299 ;; Hide conversation thread subtrees. We cannot do this in
3300 ;; gnus-summary-prepare-hook since kill processing may not
3301 ;; work with hidden articles.
3302 (gnus-summary-maybe-hide-threads)
3304 (gnus-kill-or-deaden-summary kill-buffer))
3305 (gnus-summary-auto-select-subject)
3306 ;; Show first unread article if requested.
3307 (if (and (not no-article)
3309 gnus-newsgroup-unreads
3310 gnus-auto-select-first)
3312 (gnus-configure-windows 'summary)
3313 (let ((art (gnus-summary-article-number)))
3314 (unless (or (memq art gnus-newsgroup-undownloaded)
3315 (memq art gnus-newsgroup-downloadable))
3316 (gnus-summary-goto-article art))))
3317 ;; Don't select any articles.
3318 (gnus-summary-position-point)
3319 (gnus-configure-windows 'summary 'force)
3320 (gnus-set-mode-line 'summary))
3321 (when (get-buffer-window gnus-group-buffer t)
3322 ;; Gotta use windows, because recenter does weird stuff if
3323 ;; the current buffer ain't the displayed window.
3324 (let ((owin (selected-window)))
3325 (select-window (get-buffer-window gnus-group-buffer t))
3326 (when (gnus-group-goto-group group)
3328 (select-window owin)))
3329 ;; Mark this buffer as "prepared".
3330 (setq gnus-newsgroup-prepared t)
3331 (gnus-run-hooks 'gnus-summary-prepared-hook)
3334 (defun gnus-summary-auto-select-subject ()
3335 "Select the subject line on initial group entry."
3336 (goto-char (point-min))
3338 ((eq gnus-auto-select-subject 'best)
3339 (gnus-summary-best-unread-subject))
3340 ((eq gnus-auto-select-subject 'unread)
3341 (gnus-summary-first-unread-subject))
3342 ((eq gnus-auto-select-subject 'unseen)
3343 (gnus-summary-first-unseen-subject))
3344 ((eq gnus-auto-select-subject 'unseen-or-unread)
3345 (gnus-summary-first-unseen-or-unread-subject))
3346 ((eq gnus-auto-select-subject 'first)
3349 ((gnus-functionp gnus-auto-select-subject)
3350 (funcall gnus-auto-select-subject))))
3352 (defun gnus-summary-prepare ()
3353 "Generate the summary buffer."
3355 (let ((buffer-read-only nil))
3357 (setq gnus-newsgroup-data nil
3358 gnus-newsgroup-data-reverse nil)
3359 (gnus-run-hooks 'gnus-summary-generate-hook)
3360 ;; Generate the buffer, either with threads or without.
3361 (when gnus-newsgroup-headers
3362 (gnus-summary-prepare-threads
3363 (if gnus-show-threads
3364 (gnus-sort-gathered-threads
3365 (funcall gnus-summary-thread-gathering-function
3367 (gnus-cut-threads (gnus-make-threads)))))
3368 ;; Unthreaded display.
3369 (gnus-sort-articles gnus-newsgroup-headers))))
3370 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3371 ;; Call hooks for modifying summary buffer.
3372 (goto-char (point-min))
3373 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3375 (defsubst gnus-general-simplify-subject (subject)
3376 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3379 ;; Truncate the subject.
3380 (gnus-simplify-subject-functions
3381 (gnus-map-function gnus-simplify-subject-functions subject))
3382 ((numberp gnus-summary-gather-subject-limit)
3383 (setq subject (gnus-simplify-subject-re subject))
3384 (if (> (length subject) gnus-summary-gather-subject-limit)
3385 (substring subject 0 gnus-summary-gather-subject-limit)
3387 ;; Fuzzily simplify it.
3388 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3389 (gnus-simplify-subject-fuzzy subject))
3390 ;; Just remove the leading "Re:".
3392 (gnus-simplify-subject-re subject))))
3394 (if (and gnus-summary-gather-exclude-subject
3395 (string-match gnus-summary-gather-exclude-subject subject))
3396 nil ; This article shouldn't be gathered
3399 (defun gnus-summary-simplify-subject-query ()
3400 "Query where the respool algorithm would put this article."
3402 (gnus-summary-select-article)
3403 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3405 (defun gnus-gather-threads-by-subject (threads)
3406 "Gather threads by looking at Subject headers."
3407 (if (not gnus-summary-make-false-root)
3409 (let ((hashtb (gnus-make-hashtable 1024))
3412 subject hthread whole-subject)
3414 (setq subject (gnus-general-simplify-subject
3415 (setq whole-subject (mail-header-subject
3418 (if (setq hthread (gnus-gethash subject hashtb))
3420 ;; We enter a dummy root into the thread, if we
3421 ;; haven't done that already.
3422 (unless (stringp (caar hthread))
3423 (setcar hthread (list whole-subject (car hthread))))
3424 ;; We add this new gathered thread to this gathered
3426 (setcdr (car hthread)
3427 (nconc (cdar hthread) (list (car threads))))
3428 ;; Remove it from the list of threads.
3429 (setcdr prev (cdr threads))
3430 (setq threads prev))
3431 ;; Enter this thread into the hash table.
3432 (gnus-sethash subject threads hashtb)))
3434 (setq threads (cdr threads)))
3437 (defun gnus-gather-threads-by-references (threads)
3438 "Gather threads by looking at References headers."
3439 (let ((idhashtb (gnus-make-hashtable 1024))
3440 (thhashtb (gnus-make-hashtable 1024))
3443 ids references id gthread gid entered ref)
3445 (when (setq references (mail-header-references (caar threads)))
3446 (setq id (mail-header-id (caar threads))
3447 ids (inline (gnus-split-references references))
3449 (while (setq ref (pop ids))
3450 (setq ids (delete ref ids))
3451 (if (not (setq gid (gnus-gethash ref idhashtb)))
3453 (gnus-sethash ref id idhashtb)
3454 (gnus-sethash id threads thhashtb))
3455 (setq gthread (gnus-gethash gid thhashtb))
3457 ;; We enter a dummy root into the thread, if we
3458 ;; haven't done that already.
3459 (unless (stringp (caar gthread))
3460 (setcar gthread (list (mail-header-subject (caar gthread))
3462 ;; We add this new gathered thread to this gathered
3464 (setcdr (car gthread)
3465 (nconc (cdar gthread) (list (car threads)))))
3466 ;; Add it into the thread hash table.
3467 (gnus-sethash id gthread thhashtb)
3469 ;; Remove it from the list of threads.
3470 (setcdr prev (cdr threads))
3471 (setq threads prev))))
3473 (setq threads (cdr threads)))
3476 (defun gnus-sort-gathered-threads (threads)
3477 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3478 (let ((result threads))
3480 (when (stringp (caar threads))
3481 (setcdr (car threads)
3482 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3483 (setq threads (cdr threads)))
3486 (defun gnus-thread-loop-p (root thread)
3487 "Say whether ROOT is in THREAD."
3488 (let ((stack (list thread))
3491 (while (setq thread (pop stack))
3492 (setq th (cdr thread))
3494 (not (eq (caar th) root)))
3497 ;; We have found a loop.
3499 (setcdr thread (delq (car th) (cdr thread)))
3500 (if (boundp (setq ref-dep (intern "none"
3501 gnus-newsgroup-dependencies)))
3502 (setcdr (symbol-value ref-dep)
3503 (nconc (cdr (symbol-value ref-dep))
3505 (set ref-dep (list nil (car th))))
3508 ;; Push all the subthreads onto the stack.
3509 (push (cdr thread) stack)))
3512 (defun gnus-make-threads ()
3513 "Go through the dependency hashtb and find the roots. Return all threads."
3515 (while (catch 'infloop
3518 ;; Deal with self-referencing References loops.
3519 (when (and (car (symbol-value refs))
3526 (car (symbol-value refs)) thread))
3527 (cdr (symbol-value refs)))))))
3530 (unless (car (symbol-value refs))
3531 ;; These threads do not refer back to any other articles,
3532 ;; so they're roots.
3533 (setq threads (append (cdr (symbol-value refs)) threads))))
3534 gnus-newsgroup-dependencies)))
3537 ;; Build the thread tree.
3538 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3539 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3541 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3542 if it was already present.
3544 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3545 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3546 Message-IDs will be renamed to a unique Message-ID before being
3549 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3550 (let* ((id (mail-header-id header))
3551 (id-dep (and id (intern id dependencies)))
3552 ref ref-dep ref-header)
3553 ;; Enter this `header' in the `dependencies' table.
3557 ;; The first two cases do the normal part: enter a new `header'
3558 ;; in the `dependencies' table.
3559 ((not (boundp id-dep))
3560 (set id-dep (list header)))
3561 ((null (car (symbol-value id-dep)))
3562 (setcar (symbol-value id-dep) header))
3564 ;; From here the `header' was already present in the
3565 ;; `dependencies' table.
3567 ;; Overrides an existing entry;
3568 ;; just set the header part of the entry.
3569 (setcar (symbol-value id-dep) header))
3571 ;; Renames the existing `header' to a unique Message-ID.
3572 ((not gnus-summary-ignore-duplicates)
3573 ;; An article with this Message-ID has already been seen.
3574 ;; We rename the Message-ID.
3575 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3577 (mail-header-set-id header id))
3579 ;; The last case ignores an existing entry, except it adds any
3580 ;; additional Xrefs (in case the two articles came from different
3582 ;; Also sets `header' to `nil' meaning that the `dependencies'
3583 ;; table was *not* modified.
3585 (mail-header-set-xref
3586 (car (symbol-value id-dep))
3587 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3589 (or (mail-header-xref header) "")))
3593 ;; First check that we are not creating a References loop.
3594 (setq ref (gnus-parent-id (mail-header-references header)))
3596 (setq ref-dep (intern-soft ref dependencies))
3598 (setq ref-header (car (symbol-value ref-dep))))
3599 (if (string= id ref)
3600 ;; Yuk! This is a reference loop. Make the article be a
3603 (mail-header-set-references (car (symbol-value id-dep)) "none")
3605 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3606 (setq ref (gnus-parent-id (mail-header-references header)))
3607 (setq ref-dep (intern (or ref "none") dependencies))
3608 (if (boundp ref-dep)
3609 (setcdr (symbol-value ref-dep)
3610 (nconc (cdr (symbol-value ref-dep))
3611 (list (symbol-value id-dep))))
3612 (set ref-dep (list nil (symbol-value id-dep)))))
3615 (defun gnus-extract-message-id-from-in-reply-to (string)
3616 (if (string-match "<[^>]+>" string)
3617 (substring string (match-beginning 0) (match-end 0))
3620 (defun gnus-build-sparse-threads ()
3621 (let ((headers gnus-newsgroup-headers)
3622 (mail-parse-charset gnus-newsgroup-charset)
3623 (gnus-summary-ignore-duplicates t)
3624 header references generation relations
3625 subject child end new-child date)
3626 ;; First we create an alist of generations/relations, where
3627 ;; generations is how much we trust the relation, and the relation
3629 (gnus-message 7 "Making sparse threads...")
3631 (nnheader-set-temp-buffer " *gnus sparse threads*")
3632 (while (setq header (pop headers))
3633 (when (and (setq references (mail-header-references header))
3634 (not (string= references "")))
3636 (setq child (mail-header-id header)
3637 subject (mail-header-subject header)
3638 date (mail-header-date header)
3640 (while (search-backward ">" nil t)
3641 (setq end (1+ (point)))
3642 (when (search-backward "<" nil t)
3643 (setq new-child (buffer-substring (point) end))
3644 (push (list (incf generation)
3645 child (setq child new-child)
3649 (push (list (1+ generation) child nil subject) relations))
3651 (kill-buffer (current-buffer)))
3652 ;; Sort over trustworthiness.
3655 (when (gnus-dependencies-add-header
3656 (make-full-mail-header
3657 gnus-reffed-article-number
3658 (nth 3 relation) "" (or (nth 4 relation) "")
3660 (or (nth 2 relation) "") 0 0 "")
3661 gnus-newsgroup-dependencies nil)
3662 (push gnus-reffed-article-number gnus-newsgroup-limit)
3663 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3664 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3665 gnus-newsgroup-reads)
3666 (decf gnus-reffed-article-number)))
3667 (sort relations 'car-less-than-car))
3668 (gnus-message 7 "Making sparse threads...done")))
3670 (defun gnus-build-old-threads ()
3671 ;; Look at all the articles that refer back to old articles, and
3672 ;; fetch the headers for the articles that aren't there. This will
3673 ;; build complete threads - if the roots haven't been expired by the
3675 (let ((mail-parse-charset gnus-newsgroup-charset)
3679 (when (not (car (symbol-value refs)))
3680 (setq heads (cdr (symbol-value refs)))
3682 (if (memq (mail-header-number (caar heads))
3683 gnus-newsgroup-dormant)
3684 (setq heads (cdr heads))
3685 (setq id (symbol-name refs))
3686 (while (and (setq id (gnus-build-get-header id))
3687 (not (car (gnus-id-to-thread id)))))
3688 (setq heads nil)))))
3689 gnus-newsgroup-dependencies)))
3691 ;; This function has to be called with point after the article number
3692 ;; on the beginning of the line.
3693 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3694 (let ((eol (gnus-point-at-eol))
3695 (buffer (current-buffer))
3696 header references in-reply-to)
3698 ;; overview: [num subject from date id refs chars lines misc]
3701 (narrow-to-region (point) eol)
3706 (make-full-mail-header
3708 (funcall gnus-decode-encoded-word-function
3709 (nnheader-nov-field)) ; subject
3710 (funcall gnus-decode-encoded-word-function
3711 (nnheader-nov-field)) ; from
3712 (nnheader-nov-field) ; date
3713 (nnheader-nov-read-message-id) ; id
3714 (setq references (nnheader-nov-field)) ; refs
3715 (nnheader-nov-read-integer) ; chars
3716 (nnheader-nov-read-integer) ; lines
3718 (if (looking-at "Xref: ")
3719 (goto-char (match-end 0)))
3720 (nnheader-nov-field)) ; Xref
3721 (nnheader-nov-parse-extra)))) ; extra
3725 (when (and (string= references "")
3726 (setq in-reply-to (mail-header-extra header))
3727 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3728 (mail-header-set-references
3729 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3731 (when gnus-alter-header-function
3732 (funcall gnus-alter-header-function header))
3733 (gnus-dependencies-add-header header dependencies force-new)))
3735 (defun gnus-build-get-header (id)
3736 "Look through the buffer of NOV lines and find the header to ID.
3737 Enter this line into the dependencies hash table, and return
3738 the id of the parent article (if any)."
3739 (let ((deps gnus-newsgroup-dependencies)
3743 (set-buffer nntp-server-buffer)
3744 (let ((case-fold-search nil))
3745 (goto-char (point-min))
3746 (while (and (not found)
3747 (search-forward id nil t))
3749 (setq found (looking-at
3750 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3751 (regexp-quote id))))
3752 (or found (beginning-of-line 2)))
3756 (setq header (gnus-nov-parse-line
3757 (read (current-buffer)) deps))
3758 (gnus-parent-id (mail-header-references header))))))
3760 (let ((number (mail-header-number header)))
3761 (push number gnus-newsgroup-limit)
3762 (push header gnus-newsgroup-headers)
3763 (if (memq number gnus-newsgroup-unselected)
3765 (setq gnus-newsgroup-unreads
3766 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3768 (setq gnus-newsgroup-unselected
3769 (delq number gnus-newsgroup-unselected)))
3770 (push number gnus-newsgroup-ancient)))))))
3772 (defun gnus-build-all-threads ()
3773 "Read all the headers."
3774 (let ((gnus-summary-ignore-duplicates t)
3775 (mail-parse-charset gnus-newsgroup-charset)
3776 (dependencies gnus-newsgroup-dependencies)
3779 (set-buffer nntp-server-buffer)
3780 (let ((case-fold-search nil))
3781 (goto-char (point-min))
3784 (setq article (read (current-buffer))
3785 header (gnus-nov-parse-line article dependencies)))
3788 (set-buffer gnus-summary-buffer)
3789 (push header gnus-newsgroup-headers)
3790 (if (memq (setq article (mail-header-number header))
3791 gnus-newsgroup-unselected)
3793 (setq gnus-newsgroup-unreads
3794 (gnus-add-to-sorted-list
3795 gnus-newsgroup-unreads article))
3796 (setq gnus-newsgroup-unselected
3797 (delq article gnus-newsgroup-unselected)))
3798 (push article gnus-newsgroup-ancient)))
3799 (forward-line 1)))))))
3801 (defun gnus-summary-update-article-line (article header)
3802 "Update the line for ARTICLE using HEADERS."
3803 (let* ((id (mail-header-id header))
3804 (thread (gnus-id-to-thread id)))
3806 (error "Article in no thread"))
3807 ;; Update the thread.
3808 (setcar thread header)
3809 (gnus-summary-goto-subject article)
3810 (let* ((datal (gnus-data-find-list article))
3812 (length (when (cdr datal)
3813 (- (gnus-data-pos data)
3814 (gnus-data-pos (cadr datal)))))
3815 (buffer-read-only nil)
3816 (level (gnus-summary-thread-level)))
3818 (gnus-summary-insert-line
3819 header level nil (gnus-article-mark article)
3820 (memq article gnus-newsgroup-replied)
3821 (memq article gnus-newsgroup-expirable)
3822 ;; Only insert the Subject string when it's different
3823 ;; from the previous Subject string.
3828 (mail-header-subject
3831 (gnus-data-find-list
3833 (gnus-data-list t)))))
3834 ;; Error on the side of excessive subjects.
3836 (mail-header-subject header)))
3838 (mail-header-subject header))
3839 nil (cdr (assq article gnus-newsgroup-scored))
3840 (memq article gnus-newsgroup-processable))
3842 (gnus-data-update-list
3843 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3845 (defun gnus-summary-update-article (article &optional iheader)
3846 "Update ARTICLE in the summary buffer."
3847 (set-buffer gnus-summary-buffer)
3848 (let* ((header (gnus-summary-article-header article))
3849 (id (mail-header-id header))
3850 (data (gnus-data-find article))
3851 (thread (gnus-id-to-thread id))
3852 (references (mail-header-references header))
3856 (when (and references
3857 (not (equal "" references)))
3860 (buffer-read-only nil)
3866 (delq thread parent)))
3867 (if (gnus-summary-insert-subject id header)
3868 ;; Set the (possibly) new article number in the data structure.
3869 (gnus-data-set-number data (gnus-id-to-article id))
3873 (defun gnus-rebuild-thread (id &optional line)
3874 "Rebuild the thread containing ID.
3875 If LINE, insert the rebuilt thread starting on line LINE."
3876 (let ((buffer-read-only nil)
3877 old-pos current thread data)
3878 (if (not gnus-show-threads)
3879 (setq thread (list (car (gnus-id-to-thread id))))
3880 ;; Get the thread this article is part of.
3881 (setq thread (gnus-remove-thread id)))
3882 (setq old-pos (gnus-point-at-bol))
3883 (setq current (save-excursion
3884 (and (re-search-backward "[\r\n]" nil t)
3885 (gnus-summary-article-number))))
3886 ;; If this is a gathered thread, we have to go some re-gathering.
3887 (when (stringp (car thread))
3888 (let ((subject (car thread))
3890 (setq thread (cdr thread))
3892 (unless (memq (setq thr (gnus-id-to-thread
3894 (mail-header-id (caar thread)))))
3897 (setq thread (cdr thread)))
3898 ;; We now have all (unique) roots.
3899 (if (= (length roots) 1)
3900 ;; All the loose roots are now one solid root.
3901 (setq thread (car roots))
3902 (setq thread (cons subject (gnus-sort-threads roots))))))
3904 ;; We then insert this thread into the summary buffer.
3906 (goto-char (point-min))
3907 (forward-line (1- line)))
3908 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3909 (if gnus-show-threads
3910 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3911 (gnus-summary-prepare-unthreaded thread))
3912 (setq data (nreverse gnus-newsgroup-data))
3913 (setq threads gnus-newsgroup-threads))
3914 ;; We splice the new data into the data structure.
3915 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3916 ;;!!! then we want to insert at the beginning of the buffer.
3917 ;;!!! That happens to be true with Gnus now, but that may
3918 ;;!!! change in the future. Perhaps.
3919 (gnus-data-enter-list
3920 (if line nil current) data (- (point) old-pos))
3921 (setq gnus-newsgroup-threads
3922 (nconc threads gnus-newsgroup-threads))
3923 (gnus-data-compute-positions))))
3925 (defun gnus-number-to-header (number)
3926 "Return the header for article NUMBER."
3927 (let ((headers gnus-newsgroup-headers))
3929 (not (= number (mail-header-number (car headers)))))
3934 (defun gnus-parent-headers (in-headers &optional generation)
3935 "Return the headers of the GENERATIONeth parent of HEADERS."
3937 (setq generation 1))
3939 (headers in-headers)
3942 (not (zerop generation))
3943 (setq references (mail-header-references headers)))
3944 (setq headers (if (and references
3945 (setq parent (gnus-parent-id references)))
3946 (car (gnus-id-to-thread parent))
3949 (and (not (eq headers in-headers))
3952 (defun gnus-id-to-thread (id)
3953 "Return the (sub-)thread where ID appears."
3954 (gnus-gethash id gnus-newsgroup-dependencies))
3956 (defun gnus-id-to-article (id)
3957 "Return the article number of ID."
3958 (let ((thread (gnus-id-to-thread id)))
3961 (mail-header-number (car thread)))))
3963 (defun gnus-id-to-header (id)
3964 "Return the article headers of ID."
3965 (car (gnus-id-to-thread id)))
3967 (defun gnus-article-displayed-root-p (article)
3968 "Say whether ARTICLE is a root(ish) article."
3969 (let ((level (gnus-summary-thread-level article))
3970 (refs (mail-header-references (gnus-summary-article-header article)))
3976 ((null (gnus-parent-id refs)) t)
3978 (null (setq particle (gnus-id-to-article
3979 (gnus-parent-id refs))))
3980 (null (gnus-summary-thread-level particle)))))))
3982 (defun gnus-root-id (id)
3983 "Return the id of the root of the thread where ID appears."
3985 (while (and id (setq prev (car (gnus-id-to-thread id))))
3987 id (gnus-parent-id (mail-header-references prev))))
3990 (defun gnus-articles-in-thread (thread)
3991 "Return the list of articles in THREAD."
3992 (cons (mail-header-number (car thread))
3993 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3995 (defun gnus-remove-thread (id &optional dont-remove)
3996 "Remove the thread that has ID in it."
3997 (let (headers thread last-id)
3998 ;; First go up in this thread until we find the root.
3999 (setq last-id (gnus-root-id id)
4000 headers (message-flatten-list (gnus-id-to-thread last-id)))
4001 ;; We have now found the real root of this thread. It might have
4002 ;; been gathered into some loose thread, so we have to search
4003 ;; through the threads to find the thread we wanted.
4004 (let ((threads gnus-newsgroup-threads)
4007 (setq sub (car threads))
4008 (if (stringp (car sub))
4009 ;; This is a gathered thread, so we look at the roots
4010 ;; below it to find whether this article is in this
4013 (setq sub (cdr sub))
4015 (when (member (caar sub) headers)
4016 (setq thread (car threads)
4019 (setq sub (cdr sub))))
4020 ;; It's an ordinary thread, so we check it.
4021 (when (eq (car sub) (car headers))
4024 (setq threads (cdr threads)))
4025 ;; If this article is in no thread, then it's a root.
4028 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4029 (setq thread (gnus-id-to-thread last-id)))
4032 thread ; We return this thread.
4034 (if (stringp (car thread))
4036 ;; If we use dummy roots, then we have to remove the
4037 ;; dummy root as well.
4038 (when (eq gnus-summary-make-false-root 'dummy)
4039 ;; We go to the dummy root by going to
4040 ;; the first sub-"thread", and then one line up.
4041 (gnus-summary-goto-article
4042 (mail-header-number (caadr thread)))
4045 (gnus-data-compute-positions))
4046 (setq thread (cdr thread))
4048 (gnus-remove-thread-1 (car thread))
4049 (setq thread (cdr thread))))
4050 (gnus-remove-thread-1 thread))))))))
4052 (defun gnus-remove-thread-1 (thread)
4053 "Remove the thread THREAD recursively."
4054 (let ((number (mail-header-number (pop thread)))
4056 (setq thread (reverse thread))
4058 (gnus-remove-thread-1 (pop thread)))
4059 (when (setq d (gnus-data-find number))
4060 (goto-char (gnus-data-pos d))
4061 (gnus-summary-show-thread)
4064 (- (gnus-point-at-bol)
4066 (1+ (gnus-point-at-eol))
4067 (gnus-delete-line)))))))
4069 (defun gnus-sort-threads-1 (threads func)
4070 (sort (mapcar (lambda (thread)
4073 (gnus-sort-threads-1 (cdr thread) func))))
4076 (defun gnus-sort-threads (threads)
4078 (if (not gnus-thread-sort-functions)
4080 (gnus-message 8 "Sorting threads...")
4082 (gnus-sort-threads-1
4084 (gnus-make-sort-function gnus-thread-sort-functions))
4085 (gnus-message 8 "Sorting threads...done"))))
4087 (defun gnus-sort-articles (articles)
4089 (when gnus-article-sort-functions
4090 (gnus-message 7 "Sorting articles...")
4092 (setq gnus-newsgroup-headers
4093 (sort articles (gnus-make-sort-function
4094 gnus-article-sort-functions)))
4095 (gnus-message 7 "Sorting articles...done"))))
4097 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4098 (defmacro gnus-thread-header (thread)
4099 "Return header of first article in THREAD.
4100 Note that THREAD must never, ever be anything else than a variable -
4101 using some other form will lead to serious barfage."
4102 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4103 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4104 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4107 (defsubst gnus-article-sort-by-number (h1 h2)
4108 "Sort articles by article number."
4109 (< (mail-header-number h1)
4110 (mail-header-number h2)))
4112 (defun gnus-thread-sort-by-number (h1 h2)
4113 "Sort threads by root article number."
4114 (gnus-article-sort-by-number
4115 (gnus-thread-header h1) (gnus-thread-header h2)))
4117 (defsubst gnus-article-sort-by-lines (h1 h2)
4118 "Sort articles by article Lines header."
4119 (< (mail-header-lines h1)
4120 (mail-header-lines h2)))
4122 (defun gnus-thread-sort-by-lines (h1 h2)
4123 "Sort threads by root article Lines header."
4124 (gnus-article-sort-by-lines
4125 (gnus-thread-header h1) (gnus-thread-header h2)))
4127 (defsubst gnus-article-sort-by-chars (h1 h2)
4128 "Sort articles by octet length."
4129 (< (mail-header-chars h1)
4130 (mail-header-chars h2)))
4132 (defun gnus-thread-sort-by-chars (h1 h2)
4133 "Sort threads by root article octet length."
4134 (gnus-article-sort-by-chars
4135 (gnus-thread-header h1) (gnus-thread-header h2)))
4137 (defsubst gnus-article-sort-by-author (h1 h2)
4138 "Sort articles by root author."
4140 (let ((extract (funcall
4141 gnus-extract-address-components
4142 (mail-header-from h1))))
4143 (or (car extract) (cadr extract) ""))
4144 (let ((extract (funcall
4145 gnus-extract-address-components
4146 (mail-header-from h2))))
4147 (or (car extract) (cadr extract) ""))))
4149 (defun gnus-thread-sort-by-author (h1 h2)
4150 "Sort threads by root author."
4151 (gnus-article-sort-by-author
4152 (gnus-thread-header h1) (gnus-thread-header h2)))
4154 (defsubst gnus-article-sort-by-subject (h1 h2)
4155 "Sort articles by root subject."
4157 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4158 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4160 (defun gnus-thread-sort-by-subject (h1 h2)
4161 "Sort threads by root subject."
4162 (gnus-article-sort-by-subject
4163 (gnus-thread-header h1) (gnus-thread-header h2)))
4165 (defsubst gnus-article-sort-by-date (h1 h2)
4166 "Sort articles by root article date."
4168 (gnus-date-get-time (mail-header-date h1))
4169 (gnus-date-get-time (mail-header-date h2))))
4171 (defun gnus-thread-sort-by-date (h1 h2)
4172 "Sort threads by root article date."
4173 (gnus-article-sort-by-date
4174 (gnus-thread-header h1) (gnus-thread-header h2)))
4176 (defsubst gnus-article-sort-by-score (h1 h2)
4177 "Sort articles by root article score.
4178 Unscored articles will be counted as having a score of zero."
4179 (> (or (cdr (assq (mail-header-number h1)
4180 gnus-newsgroup-scored))
4181 gnus-summary-default-score 0)
4182 (or (cdr (assq (mail-header-number h2)
4183 gnus-newsgroup-scored))
4184 gnus-summary-default-score 0)))
4186 (defun gnus-thread-sort-by-score (h1 h2)
4187 "Sort threads by root article score."
4188 (gnus-article-sort-by-score
4189 (gnus-thread-header h1) (gnus-thread-header h2)))
4191 (defun gnus-thread-sort-by-total-score (h1 h2)
4192 "Sort threads by the sum of all scores in the thread.
4193 Unscored articles will be counted as having a score of zero."
4194 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4196 (defun gnus-thread-total-score (thread)
4197 ;; This function find the total score of THREAD.
4202 (if (stringp (car thread))
4203 (apply gnus-thread-score-function 0
4204 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4205 (gnus-thread-total-score-1 thread)))
4207 (gnus-thread-total-score-1 (list thread)))))
4209 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4210 "Sort threads such that the thread with the most recently arrived article comes first."
4211 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4213 (defun gnus-thread-highest-number (thread)
4214 "Return the highest article number in THREAD."
4215 (apply 'max (mapcar (lambda (header)
4216 (mail-header-number header))
4217 (message-flatten-list thread))))
4219 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4220 "Sort threads such that the thread with the most recently dated article comes first."
4221 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4223 (defun gnus-thread-latest-date (thread)
4224 "Return the highest article date in THREAD."
4225 (let ((previous-time 0))
4230 (mail-header-parse-date
4232 (mail-header-date header)
4233 (error previous-time))))))
4235 (message-flatten-list thread)
4237 (< (mail-header-number h1)
4238 (mail-header-number h2))))))))
4240 (defun gnus-thread-total-score-1 (root)
4241 ;; This function find the total score of the thread below ROOT.
4242 (setq root (car root))
4243 (apply gnus-thread-score-function
4245 (mapcar 'gnus-thread-total-score
4246 (cdr (gnus-id-to-thread (mail-header-id root))))
4247 (when (> (mail-header-number root) 0)
4248 (list (or (cdr (assq (mail-header-number root)
4249 gnus-newsgroup-scored))
4250 gnus-summary-default-score 0))))
4251 (list gnus-summary-default-score)
4254 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4255 (defvar gnus-tmp-prev-subject nil)
4256 (defvar gnus-tmp-false-parent nil)
4257 (defvar gnus-tmp-root-expunged nil)
4258 (defvar gnus-tmp-dummy-line nil)
4260 (eval-when-compile (defvar gnus-tmp-header))
4261 (defun gnus-extra-header (type &optional header)
4262 "Return the extra header of TYPE."
4263 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4266 (defvar gnus-tmp-thread-tree-header-string "")
4268 (defvar gnus-sum-thread-tree-root "> "
4269 "With %B spec, used for the root of a thread.
4270 If nil, use subject instead.")
4271 (defvar gnus-sum-thread-tree-single-indent ""
4272 "With %B spec, used for a thread with just one message.
4273 If nil, use subject instead.")
4274 (defvar gnus-sum-thread-tree-vertical "| "
4275 "With %B spec, used for drawing a vertical line.")
4276 (defvar gnus-sum-thread-tree-indent " "
4277 "With %B spec, used for indenting.")
4278 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4279 "With %B spec, used for a leaf with brothers.")
4280 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4281 "With %B spec, used for a leaf without brothers.")
4283 (defun gnus-summary-prepare-threads (threads)
4284 "Prepare summary buffer from THREADS and indentation LEVEL.
4285 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4286 or a straight list of headers."
4287 (gnus-message 7 "Generating summary...")
4289 (setq gnus-newsgroup-threads threads)
4292 (let ((gnus-tmp-level 0)
4293 (default-score (or gnus-summary-default-score 0))
4294 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4295 thread number subject stack state gnus-tmp-gathered beg-match
4296 new-roots gnus-tmp-new-adopts thread-end
4297 gnus-tmp-header gnus-tmp-unread
4298 gnus-tmp-replied gnus-tmp-subject-or-nil
4299 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4300 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4301 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4304 (setq gnus-tmp-prev-subject nil)
4306 (if (vectorp (car threads))
4307 ;; If this is a straight (sic) list of headers, then a
4308 ;; threaded summary display isn't required, so we just create
4309 ;; an unthreaded one.
4310 (gnus-summary-prepare-unthreaded threads)
4312 ;; Do the threaded display.
4314 (while (or threads stack gnus-tmp-new-adopts new-roots)
4316 (if (and (= gnus-tmp-level 0)
4319 (not gnus-tmp-false-parent)
4320 (or gnus-tmp-new-adopts new-roots))
4321 (if gnus-tmp-new-adopts
4322 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4323 thread (list (car gnus-tmp-new-adopts))
4324 gnus-tmp-header (caar thread)
4325 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4327 (setq thread (list (car new-roots))
4328 gnus-tmp-header (caar thread)
4329 new-roots (cdr new-roots))))
4332 ;; If there are some threads, we do them before the
4333 ;; threads on the stack.
4334 (setq thread threads
4335 gnus-tmp-header (caar thread))
4336 ;; There were no current threads, so we pop something off
4338 (setq state (car stack)
4339 gnus-tmp-level (car state)
4340 tree-stack (cadr state)
4341 thread (caddr state)
4343 gnus-tmp-header (caar thread))))
4345 (setq gnus-tmp-false-parent nil)
4346 (setq gnus-tmp-root-expunged nil)
4347 (setq thread-end nil)
4349 (if (stringp gnus-tmp-header)
4350 ;; The header is a dummy root.
4352 ((eq gnus-summary-make-false-root 'adopt)
4353 ;; We let the first article adopt the rest.
4354 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4356 (setq gnus-tmp-gathered
4358 (lambda (h) (mail-header-number (car h)))
4361 (setq thread (cons (list (caar thread)
4364 (setq gnus-tmp-level -1
4365 gnus-tmp-false-parent t))
4366 ((eq gnus-summary-make-false-root 'empty)
4367 ;; We print adopted articles with empty subject fields.
4368 (setq gnus-tmp-gathered
4370 (lambda (h) (mail-header-number (car h)))
4373 (setq gnus-tmp-level -1))
4374 ((eq gnus-summary-make-false-root 'dummy)
4375 ;; We remember that we probably want to output a dummy
4377 (setq gnus-tmp-dummy-line gnus-tmp-header)
4378 (setq gnus-tmp-prev-subject gnus-tmp-header))
4380 ;; We do not make a root for the gathered
4381 ;; sub-threads at all.
4382 (setq gnus-tmp-level -1)))
4384 (setq number (mail-header-number gnus-tmp-header)
4385 subject (mail-header-subject gnus-tmp-header))
4388 ;; If the thread has changed subject, we might want to make
4389 ;; this subthread into a root.
4390 ((and (null gnus-thread-ignore-subject)
4391 (not (zerop gnus-tmp-level))
4392 gnus-tmp-prev-subject
4394 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4395 (setq new-roots (nconc new-roots (list (car thread)))
4397 gnus-tmp-header nil))
4398 ;; If the article lies outside the current limit,
4399 ;; then we do not display it.
4400 ((not (memq number gnus-newsgroup-limit))
4401 (setq gnus-tmp-gathered
4403 (lambda (h) (mail-header-number (car h)))
4406 (setq gnus-tmp-new-adopts (if (cdar thread)
4407 (append gnus-tmp-new-adopts
4409 gnus-tmp-new-adopts)
4411 gnus-tmp-header nil)
4412 (when (zerop gnus-tmp-level)
4413 (setq gnus-tmp-root-expunged t)))
4414 ;; Perhaps this article is to be marked as read?
4415 ((and gnus-summary-mark-below
4416 (< (or (cdr (assq number gnus-newsgroup-scored))
4418 gnus-summary-mark-below)
4419 ;; Don't touch sparse articles.
4420 (not (gnus-summary-article-sparse-p number))
4421 (not (gnus-summary-article-ancient-p number)))
4422 (setq gnus-newsgroup-unreads
4423 (delq number gnus-newsgroup-unreads))
4424 (if gnus-newsgroup-auto-expire
4425 (setq gnus-newsgroup-expirable
4426 (gnus-add-to-sorted-list
4427 gnus-newsgroup-expirable number))
4428 (push (cons number gnus-low-score-mark)
4429 gnus-newsgroup-reads))))
4431 (when gnus-tmp-header
4432 ;; We may have an old dummy line to output before this
4434 (when (and gnus-tmp-dummy-line
4437 (mail-header-subject gnus-tmp-header)))
4438 (gnus-summary-insert-dummy-line
4439 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4440 (setq gnus-tmp-dummy-line nil))
4442 ;; Compute the mark.
4443 (setq gnus-tmp-unread (gnus-article-mark number))
4445 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4446 gnus-tmp-header gnus-tmp-level)
4447 gnus-newsgroup-data)
4449 ;; Actually insert the line.
4451 gnus-tmp-subject-or-nil
4453 ((and gnus-thread-ignore-subject
4454 gnus-tmp-prev-subject
4455 (not (inline (gnus-subject-equal
4456 gnus-tmp-prev-subject subject))))
4458 ((zerop gnus-tmp-level)
4459 (if (and (eq gnus-summary-make-false-root 'empty)
4460 (memq number gnus-tmp-gathered)
4461 gnus-tmp-prev-subject
4462 (inline (gnus-subject-equal
4463 gnus-tmp-prev-subject subject)))
4464 gnus-summary-same-subject
4466 (t gnus-summary-same-subject)))
4467 (if (and (eq gnus-summary-make-false-root 'adopt)
4468 (= gnus-tmp-level 1)
4469 (memq number gnus-tmp-gathered))
4470 (setq gnus-tmp-opening-bracket ?\<
4471 gnus-tmp-closing-bracket ?\>)
4472 (setq gnus-tmp-opening-bracket ?\[
4473 gnus-tmp-closing-bracket ?\]))
4475 gnus-tmp-indentation
4476 (aref gnus-thread-indent-array gnus-tmp-level)
4477 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4478 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4479 gnus-summary-default-score 0)
4481 (if (or (null gnus-summary-default-score)
4482 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4483 gnus-summary-zcore-fuzz))
4485 (if (< gnus-tmp-score gnus-summary-default-score)
4486 gnus-score-below-mark gnus-score-over-mark))
4488 (cond ((memq number gnus-newsgroup-processable)
4490 ((memq number gnus-newsgroup-cached)
4492 ((memq number gnus-newsgroup-replied)
4494 ((memq number gnus-newsgroup-forwarded)
4495 gnus-forwarded-mark)
4496 ((memq number gnus-newsgroup-saved)
4498 ((memq number gnus-newsgroup-recent)
4500 ((memq number gnus-newsgroup-unseen)
4503 gnus-tmp-from (mail-header-from gnus-tmp-header)
4506 ((string-match "<[^>]+> *$" gnus-tmp-from)
4507 (setq beg-match (match-beginning 0))
4508 (or (and (string-match "^\".+\"" gnus-tmp-from)
4509 (substring gnus-tmp-from 1 (1- (match-end 0))))
4510 (substring gnus-tmp-from 0 beg-match)))
4511 ((string-match "(.+)" gnus-tmp-from)
4512 (substring gnus-tmp-from
4513 (1+ (match-beginning 0)) (1- (match-end 0))))
4515 gnus-tmp-thread-tree-header-string
4517 ((not gnus-show-threads) "")
4518 ((zerop gnus-tmp-level)
4520 (or gnus-sum-thread-tree-root subject)
4521 (or gnus-sum-thread-tree-single-indent subject)))
4523 (concat (apply 'concat
4524 (mapcar (lambda (item)
4526 gnus-sum-thread-tree-vertical
4527 gnus-sum-thread-tree-indent))
4528 (cdr (reverse tree-stack))))
4530 gnus-sum-thread-tree-leaf-with-other
4531 gnus-sum-thread-tree-single-leaf)))))
4532 (when (string= gnus-tmp-name "")
4533 (setq gnus-tmp-name gnus-tmp-from))
4534 (unless (numberp gnus-tmp-lines)
4535 (setq gnus-tmp-lines -1))
4536 (if (= gnus-tmp-lines -1)
4537 (setq gnus-tmp-lines "?")
4538 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4539 (gnus-put-text-property
4541 (progn (eval gnus-summary-line-format-spec) (point))
4542 'gnus-number number)
4545 (gnus-run-hooks 'gnus-summary-update-hook)
4548 (setq gnus-tmp-prev-subject subject)))
4550 (when (nth 1 thread)
4551 (push (list (max 0 gnus-tmp-level)
4552 (copy-list tree-stack)
4555 (push (if (nth 1 thread) 1 0) tree-stack)
4556 (incf gnus-tmp-level)
4557 (setq threads (if thread-end nil (cdar thread)))
4559 (setq gnus-tmp-level 0)))))
4560 (gnus-message 7 "Generating summary...done"))
4562 (defun gnus-summary-prepare-unthreaded (headers)
4563 "Generate an unthreaded summary buffer based on HEADERS."
4564 (let (header number mark)
4569 ;; We may have to root out some bad articles...
4570 (when (memq (setq number (mail-header-number
4571 (setq header (pop headers))))
4572 gnus-newsgroup-limit)
4573 ;; Mark article as read when it has a low score.
4574 (when (and gnus-summary-mark-below
4575 (< (or (cdr (assq number gnus-newsgroup-scored))
4576 gnus-summary-default-score 0)
4577 gnus-summary-mark-below)
4578 (not (gnus-summary-article-ancient-p number)))
4579 (setq gnus-newsgroup-unreads
4580 (delq number gnus-newsgroup-unreads))
4581 (if gnus-newsgroup-auto-expire
4582 (push number gnus-newsgroup-expirable)
4583 (push (cons number gnus-low-score-mark)
4584 gnus-newsgroup-reads)))
4586 (setq mark (gnus-article-mark number))
4587 (push (gnus-data-make number mark (1+ (point)) header 0)
4588 gnus-newsgroup-data)
4589 (gnus-summary-insert-line
4591 mark (memq number gnus-newsgroup-replied)
4592 (memq number gnus-newsgroup-expirable)
4593 (mail-header-subject header) nil
4594 (cdr (assq number gnus-newsgroup-scored))
4595 (memq number gnus-newsgroup-processable))))))
4597 (defun gnus-summary-remove-list-identifiers ()
4598 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4599 (let ((regexp (if (consp gnus-list-identifiers)
4600 (mapconcat 'identity gnus-list-identifiers " *\\|")
4601 gnus-list-identifiers))
4604 (dolist (header gnus-newsgroup-headers)
4605 (setq subject (mail-header-subject header)
4607 (while (string-match
4608 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4611 (concat (substring subject 0 (match-beginning 2))
4612 (substring subject (match-end 0)))
4616 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4618 (concat (substring subject 0 (match-beginning 1))
4619 (substring subject (match-end 1)))))
4621 (mail-header-set-subject header subject))))))
4623 (defun gnus-fetch-headers (articles)
4624 "Fetch headers of ARTICLES."
4625 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4626 (gnus-message 5 "Fetching headers for %s..." name)
4629 (setq gnus-headers-retrieved-by
4630 (gnus-retrieve-headers
4631 articles gnus-newsgroup-name
4632 ;; We might want to fetch old headers, but
4633 ;; not if there is only 1 article.
4635 (not (eq gnus-fetch-old-headers 'some))
4636 (not (numberp gnus-fetch-old-headers)))
4637 (> (length articles) 1))
4638 gnus-fetch-old-headers))))
4639 (gnus-get-newsgroup-headers-xover
4640 articles nil nil gnus-newsgroup-name t)
4641 (gnus-get-newsgroup-headers))
4642 (gnus-message 5 "Fetching headers for %s...done" name))))
4644 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4645 "Select newsgroup GROUP.
4646 If READ-ALL is non-nil, all articles in the group are selected.
4647 If SELECT-ARTICLES, only select those articles from GROUP."
4648 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4649 ;;!!! Dirty hack; should be removed.
4650 (gnus-summary-ignore-duplicates
4651 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4653 gnus-summary-ignore-duplicates))
4654 (info (nth 2 entry))
4655 articles fetched-articles cached)
4657 (unless (gnus-check-server
4658 (set (make-local-variable 'gnus-current-select-method)
4659 (gnus-find-method-for-group group)))
4660 (error "Couldn't open server"))
4662 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4663 (gnus-activate-group group) ; Or we can activate it...
4664 (progn ; Or we bug out.
4665 (when (equal major-mode 'gnus-summary-mode)
4666 (kill-buffer (current-buffer)))
4667 (error "Couldn't activate group %s: %s"
4668 group (gnus-status-message group))))
4670 (unless (gnus-request-group group t)
4671 (when (equal major-mode 'gnus-summary-mode)
4672 (kill-buffer (current-buffer)))
4673 (error "Couldn't request group %s: %s"
4674 group (gnus-status-message group)))
4676 (setq gnus-newsgroup-name group
4677 gnus-newsgroup-unselected nil
4678 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4680 (let ((display (gnus-group-find-parameter group 'display)))
4681 (setq gnus-newsgroup-display
4683 ((not (zerop (or (car-safe read-all) 0)))
4684 ;; The user entered the group with C-u SPC/RET, let's show
4690 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4692 ;; The following is probably the "correct" solution, but
4693 ;; it makes Gnus fetch all headers and then limit the
4694 ;; articles (which is slow), so instead we hack the
4695 ;; select-articles parameter instead. -- Simon Josefsson
4698 ;; (gnus-byte-compile
4699 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4701 (setq select-articles
4702 (gnus-uncompress-range
4703 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4707 (cdr (gnus-active group)))))
4712 (gnus-summary-setup-default-charset)
4714 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4715 (when (gnus-virtual-group-p group)
4716 (setq cached gnus-newsgroup-cached))
4718 (setq gnus-newsgroup-unreads
4719 (gnus-sorted-ndifference
4720 (gnus-sorted-ndifference gnus-newsgroup-unreads
4721 gnus-newsgroup-marked)
4722 gnus-newsgroup-dormant))
4724 (setq gnus-newsgroup-processable nil)
4726 (gnus-update-read-articles group gnus-newsgroup-unreads)
4728 ;; Adjust and set lists of article marks.
4730 (gnus-adjust-marked-articles info))
4732 (if (setq articles select-articles)
4733 (setq gnus-newsgroup-unselected
4734 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4735 (setq articles (gnus-articles-to-read group read-all)))
4739 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4741 ((eq articles 0) nil)
4743 ;; Init the dependencies hash table.
4744 (setq gnus-newsgroup-dependencies
4745 (gnus-make-hashtable (length articles)))
4746 (gnus-set-global-variables)
4747 ;; Retrieve the headers and read them in.
4748 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4750 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4752 (setq gnus-newsgroup-cached cached))
4754 ;; Suppress duplicates?
4755 (when gnus-suppress-duplicates
4756 (gnus-dup-suppress-articles))
4758 ;; Set the initial limit.
4759 (setq gnus-newsgroup-limit (copy-sequence articles))
4760 ;; Remove canceled articles from the list of unread articles.
4761 (setq fetched-articles
4762 (mapcar (lambda (headers) (mail-header-number headers))
4763 gnus-newsgroup-headers))
4764 (setq gnus-newsgroup-articles fetched-articles)
4765 (setq gnus-newsgroup-unreads
4766 (gnus-sorted-nintersection
4767 gnus-newsgroup-unreads fetched-articles))
4768 (gnus-compute-unseen-list)
4770 ;; Removed marked articles that do not exist.
4771 (gnus-update-missing-marks
4772 (gnus-sorted-difference articles fetched-articles))
4773 ;; We might want to build some more threads first.
4774 (when (and gnus-fetch-old-headers
4775 (eq gnus-headers-retrieved-by 'nov))
4776 (if (eq gnus-fetch-old-headers 'invisible)
4777 (gnus-build-all-threads)
4778 (gnus-build-old-threads)))
4779 ;; Let the Gnus agent mark articles as read.
4781 (gnus-agent-get-undownloaded-list))
4782 ;; Remove list identifiers from subject
4783 (when gnus-list-identifiers
4784 (gnus-summary-remove-list-identifiers))
4785 ;; Check whether auto-expire is to be done in this group.
4786 (setq gnus-newsgroup-auto-expire
4787 (gnus-group-auto-expirable-p group))
4788 ;; Set up the article buffer now, if necessary.
4789 (unless gnus-single-article-buffer
4790 (gnus-article-setup-buffer))
4791 ;; First and last article in this newsgroup.
4792 (when gnus-newsgroup-headers
4793 (setq gnus-newsgroup-begin
4794 (mail-header-number (car gnus-newsgroup-headers))
4797 (gnus-last-element gnus-newsgroup-headers))))
4798 ;; GROUP is successfully selected.
4799 (or gnus-newsgroup-headers t)))))
4801 (defun gnus-compute-unseen-list ()
4802 ;; The `seen' marks are treated specially.
4803 (if (not gnus-newsgroup-seen)
4804 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4805 (setq gnus-newsgroup-unseen
4806 (gnus-inverse-list-range-intersection
4807 gnus-newsgroup-articles gnus-newsgroup-seen))))
4809 (defun gnus-summary-display-make-predicate (display)
4810 (require 'gnus-agent)
4811 (when (= (length display) 1)
4812 (setq display (car display)))
4813 (unless gnus-summary-display-cache
4814 (dolist (elem (append (list (cons 'read 'read)
4815 (cons 'unseen 'unseen))
4816 gnus-article-mark-lists))
4817 (push (cons (cdr elem)
4819 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4820 gnus-summary-display-cache)))
4821 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4822 (gnus-get-predicate display)))
4824 ;; Uses the dynamically bound `number' variable.
4826 (defun gnus-article-marked-p (type &optional article)
4827 (let ((article (or article number)))
4830 (memq article gnus-newsgroup-marked))
4832 (memq article gnus-newsgroup-unsendable))
4833 ((eq type 'undownload)
4834 (memq article gnus-newsgroup-undownloaded))
4835 ((eq type 'download)
4836 (memq article gnus-newsgroup-downloadable))
4838 (memq article gnus-newsgroup-unreads))
4840 (memq article gnus-newsgroup-reads))
4842 (memq article gnus-newsgroup-dormant) )
4844 (memq article gnus-newsgroup-expirable))
4846 (memq article gnus-newsgroup-replied))
4848 (memq article gnus-newsgroup-killed))
4849 ((eq type 'bookmark)
4850 (assq article gnus-newsgroup-bookmarks))
4852 (assq article gnus-newsgroup-scored))
4854 (memq article gnus-newsgroup-saved))
4856 (memq article gnus-newsgroup-cached))
4858 (memq article gnus-newsgroup-forwarded))
4860 (not (memq article gnus-newsgroup-unseen)))
4862 (memq article gnus-newsgroup-recent))
4865 (defun gnus-articles-to-read (group &optional read-all)
4866 "Find out what articles the user wants to read."
4868 ;; Select all articles if `read-all' is non-nil, or if there
4869 ;; are no unread articles.
4871 (and (zerop (length gnus-newsgroup-marked))
4872 (zerop (length gnus-newsgroup-unreads)))
4873 ;; Fetch all if the predicate is non-nil.
4874 gnus-newsgroup-display)
4875 ;; We want to select the headers for all the articles in
4876 ;; the group, so we select either all the active
4877 ;; articles in the group, or (if that's nil), the
4878 ;; articles in the cache.
4880 (gnus-uncompress-range (gnus-active group))
4881 (gnus-cache-articles-in-group group))
4882 ;; Select only the "normal" subset of articles.
4884 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
4885 gnus-newsgroup-unreads)))
4886 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4887 (scored (length scored-list))
4888 (number (length articles))
4889 (marked (+ (length gnus-newsgroup-marked)
4890 (length gnus-newsgroup-dormant)))
4895 ((numberp gnus-newsgroup-display)
4896 gnus-newsgroup-display)
4900 ((and (or (<= scored marked) (= scored number))
4901 (numberp gnus-large-newsgroup)
4902 (> number gnus-large-newsgroup))
4906 "How many articles from %s (default %d): "
4908 (gnus-group-decoded-name gnus-newsgroup-name)
4911 (if (string-match "^[ \t]*$" input) number input)))
4912 ((and (> scored marked) (< scored number)
4913 (> (- scored number) 20))
4916 (format "%s %s (%d scored, %d total): "
4917 "How many articles from"
4918 (gnus-group-decoded-name group)
4920 (if (string-match "^[ \t]*$" input)
4924 (message "Quit getting the articles to read")
4926 (setq select (if (stringp select) (string-to-number select) select))
4927 (if (or (null select) (zerop select))
4929 (if (and (not (zerop scored)) (<= (abs select) scored))
4931 (setq articles (sort scored-list '<))
4932 (setq number (length articles)))
4933 (setq articles (copy-sequence articles)))
4935 (when (< (abs select) number)
4937 ;; Select the N oldest articles.
4938 (setcdr (nthcdr (1- (abs select)) articles) nil)
4939 ;; Select the N most recent articles.
4940 (setq articles (nthcdr (- number select) articles))))
4941 (setq gnus-newsgroup-unselected
4942 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4943 (when gnus-alter-articles-to-read-function
4944 (setq gnus-newsgroup-unreads
4946 (funcall gnus-alter-articles-to-read-function
4947 gnus-newsgroup-name gnus-newsgroup-unreads)
4951 (defun gnus-killed-articles (killed articles)
4954 (when (inline (gnus-member-of-range (car articles) killed))
4955 (push (car articles) out))
4956 (setq articles (cdr articles)))
4959 (defun gnus-uncompress-marks (marks)
4960 "Uncompress the mark ranges in MARKS."
4961 (let ((uncompressed '(score bookmark))
4964 (if (memq (caar marks) uncompressed)
4965 (push (car marks) out)
4966 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4967 (setq marks (cdr marks)))
4970 (defun gnus-article-mark-to-type (mark)
4971 "Return the type of MARK."
4972 (or (cadr (assq mark gnus-article-special-mark-lists))
4975 (defun gnus-article-unpropagatable-p (mark)
4976 "Return whether MARK should be propagated to backend."
4977 (memq mark gnus-article-unpropagated-mark-lists))
4979 (defun gnus-adjust-marked-articles (info)
4980 "Set all article lists and remove all marks that are no longer valid."
4981 (let* ((marked-lists (gnus-info-marks info))
4982 (active (gnus-active (gnus-info-group info)))
4985 (types gnus-article-mark-lists)
4986 marks var articles article mark mark-type)
4988 (dolist (marks marked-lists)
4989 (setq mark (car marks)
4990 mark-type (gnus-article-mark-to-type mark)
4991 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4993 ;; We set the variable according to the type of the marks list,
4994 ;; and then adjust the marks to a subset of the active articles.
4996 ;; Adjust "simple" lists.
4997 ((eq mark-type 'list)
4998 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4999 (when (memq mark '(tick dormant expire reply save))
5001 (when (or (< (setq article (pop articles)) min) (> article max))
5002 (set var (delq article (symbol-value var)))))))
5004 ((eq mark-type 'tuple)
5005 (set var (setq articles (cdr marks)))
5006 (when (not (listp (cdr (symbol-value var))))
5007 (set var (list (symbol-value var))))
5008 (when (not (listp (cdr articles)))
5009 (setq articles (list articles)))
5011 (when (or (not (consp (setq article (pop articles))))
5012 (< (car article) min)
5013 (> (car article) max))
5014 (set var (delq article (symbol-value var))))))
5015 ;; Adjust ranges (sloppily).
5016 ((eq mark-type 'range)
5019 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5020 ;; It should be (seen (NUM1 . NUM2)).
5021 (when (numberp (cddr marks))
5022 (setcdr marks (list (cdr marks))))
5023 (setq articles (cdr marks))
5024 (while (and articles
5025 (or (and (consp (car articles))
5026 (> min (cdar articles)))
5027 (and (numberp (car articles))
5028 (> min (car articles)))))
5030 (set var articles))))))))
5032 (defun gnus-update-missing-marks (missing)
5033 "Go through the list of MISSING articles and remove them from the mark lists."
5036 ;; Go through all types.
5037 (dolist (elem gnus-article-mark-lists)
5038 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5039 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5040 (when (symbol-value var)
5041 ;; This list has articles. So we delete all missing
5042 ;; articles from it.
5045 (set var (delq (pop m) (symbol-value var))))))))))
5047 (defun gnus-update-marks ()
5048 "Enter the various lists of marked articles into the newsgroup info list."
5049 (let ((types gnus-article-mark-lists)
5050 (info (gnus-get-info gnus-newsgroup-name))
5051 type list newmarked symbol delta-marks)
5053 ;; Add all marks lists to the list of marks lists.
5054 (while (setq type (pop types))
5055 (setq list (symbol-value
5057 (intern (format "gnus-newsgroup-%s" (car type))))))
5060 ;; Get rid of the entries of the articles that have the
5062 (when (and (eq (cdr type) 'score)
5066 (prev (cons nil list))
5069 (if (or (not (consp (car arts)))
5070 (= (cdar arts) gnus-summary-default-score))
5071 (setcdr prev (cdr arts))
5073 (setq arts (cdr arts)))
5074 (setq list (cdr all)))))
5076 (when (eq (cdr type) 'seen)
5077 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5079 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5080 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5082 (when (and (gnus-check-backend-function
5083 'request-set-mark gnus-newsgroup-name)
5084 (not (gnus-article-unpropagatable-p (cdr type))))
5085 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5086 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5087 (add (gnus-remove-from-range
5088 (gnus-copy-sequence list) old)))
5090 (push (list add 'add (list (cdr type))) delta-marks))
5092 (push (list del 'del (list (cdr type))) delta-marks))))
5095 (push (cons (cdr type) list) newmarked)))
5098 (unless (gnus-check-group gnus-newsgroup-name)
5099 (error "Can't open server for %s" gnus-newsgroup-name))
5100 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5102 ;; Enter these new marks into the info of the group.
5104 (setcar (nthcdr 3 info) newmarked)
5105 ;; Add the marks lists to the end of the info.
5107 (setcdr (nthcdr 2 info) (list newmarked))))
5109 ;; Cut off the end of the info if there's nothing else there.
5113 (when (nthcdr (decf i) info)
5114 (setcdr (nthcdr i info) nil)))))))
5116 (defun gnus-set-mode-line (where)
5117 "Set the mode line of the article or summary buffers.
5118 If WHERE is `summary', the summary mode line format will be used."
5119 ;; Is this mode line one we keep updated?
5120 (when (and (memq where gnus-updated-mode-lines)
5122 (intern (format "gnus-%s-mode-line-format-spec" where))))
5125 ;; We evaluate this in the summary buffer since these
5126 ;; variables are buffer-local to that buffer.
5127 (set-buffer gnus-summary-buffer)
5128 ;; We bind all these variables that are used in the `eval' form
5130 (let* ((mformat (symbol-value
5132 (format "gnus-%s-mode-line-format-spec" where))))
5133 (gnus-tmp-group-name (gnus-group-decoded-name
5134 gnus-newsgroup-name))
5135 (gnus-tmp-article-number (or gnus-current-article 0))
5136 (gnus-tmp-unread gnus-newsgroup-unreads)
5137 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5138 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5139 (gnus-tmp-unread-and-unselected
5140 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5141 (zerop gnus-tmp-unselected))
5143 ((zerop gnus-tmp-unselected)
5144 (format "{%d more}" gnus-tmp-unread-and-unticked))
5145 (t (format "{%d(+%d) more}"
5146 gnus-tmp-unread-and-unticked
5147 gnus-tmp-unselected))))
5149 (if (and gnus-current-headers
5150 (vectorp gnus-current-headers))
5151 (gnus-mode-string-quote
5152 (mail-header-subject gnus-current-headers))
5154 bufname-length max-len
5155 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5156 (setq mode-string (eval mformat))
5157 (setq bufname-length (if (string-match "%b" mode-string)
5160 (if (eq where 'summary)
5162 (get-buffer gnus-article-buffer))))
5165 (setq max-len (max 4 (if gnus-mode-non-string-length
5167 gnus-mode-non-string-length
5169 (length mode-string))))
5170 ;; We might have to chop a bit of the string off...
5171 (when (> (length mode-string) max-len)
5173 (concat (truncate-string-to-width mode-string (- max-len 3))
5175 ;; Pad the mode string a bit.
5176 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5177 ;; Update the mode line.
5178 (setq mode-line-buffer-identification
5179 (gnus-mode-line-buffer-identification (list mode-string)))
5180 (set-buffer-modified-p t))))
5182 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5183 "Go through the HEADERS list and add all Xrefs to a hash table.
5184 The resulting hash table is returned, or nil if no Xrefs were found."
5185 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5186 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5187 (xref-hashtb (gnus-make-hashtable))
5188 start group entry number xrefs header)
5190 (setq header (pop headers))
5191 (when (and (setq xrefs (mail-header-xref header))
5192 (not (memq (setq number (mail-header-number header))
5195 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5196 (setq start (match-end 0))
5197 (setq group (if prefix
5198 (concat prefix (substring xrefs (match-beginning 1)
5200 (substring xrefs (match-beginning 1) (match-end 1))))
5202 (string-to-int (substring xrefs (match-beginning 2)
5204 (if (setq entry (gnus-gethash group xref-hashtb))
5205 (setcdr entry (cons number (cdr entry)))
5206 (gnus-sethash group (cons number nil) xref-hashtb)))))
5207 (and start xref-hashtb)))
5209 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5210 "Look through all the headers and mark the Xrefs as read."
5211 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5212 name entry info xref-hashtb idlist method nth4)
5214 (set-buffer gnus-group-buffer)
5215 (when (setq xref-hashtb
5216 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5219 (unless (string= from-newsgroup (setq name (symbol-name group)))
5220 (setq idlist (symbol-value group))
5221 ;; Dead groups are not updated.
5223 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5225 (when (stringp (setq nth4 (gnus-info-method info)))
5226 (setq nth4 (gnus-server-to-method nth4))))
5227 ;; Only do the xrefs if the group has the same
5228 ;; select method as the group we have just read.
5229 (or (gnus-methods-equal-p
5230 nth4 (gnus-find-method-for-group from-newsgroup))
5232 (equal nth4 (setq method (gnus-find-method-for-group
5234 (and (equal (car nth4) (car method))
5235 (equal (nth 1 nth4) (nth 1 method))))
5236 gnus-use-cross-reference
5237 (or (not (eq gnus-use-cross-reference t))
5239 ;; Only do cross-references on subscribed
5240 ;; groups, if that is what is wanted.
5241 (<= (gnus-info-level info) gnus-level-subscribed))
5242 (gnus-group-make-articles-read name idlist))))
5245 (defun gnus-compute-read-articles (group articles)
5246 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5247 (info (nth 2 entry))
5248 (active (gnus-active group))
5251 ;; First peel off all invalid article numbers.
5253 (let ((ids articles)
5255 (while (setq id (pop ids))
5256 (when (and first (> id (cdr active)))
5257 ;; We'll end up in this situation in one particular
5258 ;; obscure situation. If you re-scan a group and get
5259 ;; a new article that is cross-posted to a different
5260 ;; group that has not been re-scanned, you might get
5261 ;; crossposted article that has a higher number than
5262 ;; Gnus believes possible. So we re-activate this
5263 ;; group as well. This might mean doing the
5264 ;; crossposting thingy will *increase* the number
5265 ;; of articles in some groups. Tsk, tsk.
5266 (setq active (or (gnus-activate-group group) active)))
5267 (when (or (> id (cdr active))
5268 (< id (car active)))
5269 (setq articles (delq id articles))))))
5270 ;; If the read list is nil, we init it.
5272 (null (gnus-info-read info))
5274 (setq ninfo (cons 1 (1- (car active))))
5275 (setq ninfo (gnus-info-read info)))
5276 ;; Then we add the read articles to the range.
5278 ninfo (setq articles (sort articles '<))))))
5280 (defun gnus-group-make-articles-read (group articles)
5281 "Update the info of GROUP to say that ARTICLES are read."
5283 (entry (gnus-gethash group gnus-newsrc-hashtb))
5284 (info (nth 2 entry))
5285 (active (gnus-active group))
5288 (setq range (gnus-compute-read-articles group articles))
5290 (set-buffer gnus-group-buffer)
5293 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5294 (gnus-info-set-read ',info ',(gnus-info-read info))
5295 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5296 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5297 (gnus-group-update-group ,group t))))
5298 ;; Add the read articles to the range.
5299 (gnus-info-set-read info range)
5300 (gnus-request-set-mark group (list (list range 'add '(read))))
5301 ;; Then we have to re-compute how many unread
5302 ;; articles there are in this group.
5306 (setq num (- (1+ (cdr active)) (car active))))
5307 ((not (listp (cdr range)))
5308 (setq num (- (cdr active) (- (1+ (cdr range))
5312 (if (numberp (car range))
5314 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5315 (setq range (cdr range)))
5316 (setq num (- (cdr active) num))))
5317 ;; Update the number of unread articles.
5319 ;; Update the group buffer.
5320 (gnus-group-update-group group t)))))
5322 (defvar gnus-newsgroup-none-id 0)
5324 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5325 (let ((cur nntp-server-buffer)
5328 (save-excursion (set-buffer gnus-summary-buffer)
5329 gnus-newsgroup-dependencies)))
5331 (mail-parse-charset gnus-newsgroup-charset)
5332 (mail-parse-ignored-charsets
5333 (save-excursion (condition-case nil
5334 (set-buffer gnus-summary-buffer)
5336 gnus-newsgroup-ignored-charsets)))
5338 (set-buffer nntp-server-buffer)
5339 ;; Translate all TAB characters into SPACE characters.
5340 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5341 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5342 (gnus-run-hooks 'gnus-parse-headers-hook)
5343 (let ((case-fold-search t)
5344 in-reply-to header p lines chars)
5345 (goto-char (point-min))
5346 ;; Search to the beginning of the next header. Error messages
5347 ;; do not begin with 2 or 3.
5348 (while (re-search-forward "^[23][0-9]+ " nil t)
5351 ;; This implementation of this function, with nine
5352 ;; search-forwards instead of the one re-search-forward and
5353 ;; a case (which basically was the old function) is actually
5354 ;; about twice as fast, even though it looks messier. You
5355 ;; can't have everything, I guess. Speed and elegance
5356 ;; doesn't always go hand in hand.
5365 (narrow-to-region (point)
5366 (or (and (search-forward "\n.\n" nil t)
5372 (if (search-forward "\nsubject:" nil t)
5373 (funcall gnus-decode-encoded-word-function
5374 (nnheader-header-value))
5379 (if (search-forward "\nfrom:" nil t)
5380 (funcall gnus-decode-encoded-word-function
5381 (nnheader-header-value))
5386 (if (search-forward "\ndate:" nil t)
5387 (nnheader-header-value) ""))
5391 (setq id (if (re-search-forward
5392 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5393 ;; We do it this way to make sure the Message-ID
5394 ;; is (somewhat) syntactically valid.
5395 (buffer-substring (match-beginning 1)
5397 ;; If there was no message-id, we just fake one
5398 ;; to make subsequent routines simpler.
5399 (nnheader-generate-fake-message-id))))
5403 (if (search-forward "\nreferences:" nil t)
5407 (nnheader-header-value)
5412 (search-backward ">" end t)
5415 (search-backward "<" end t)
5417 ;; Get the references from the in-reply-to header if there
5418 ;; were no references and the in-reply-to header looks
5420 (if (and (search-forward "\nin-reply-to:" nil t)
5421 (setq in-reply-to (nnheader-header-value))
5422 (string-match "<[^>]+>" in-reply-to))
5424 (setq ref (substring in-reply-to (match-beginning 0)
5426 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5427 (setq ref2 (substring in-reply-to (match-beginning 0)
5429 (when (> (length ref2) (length ref))
5436 (if (search-forward "\nchars: " nil t)
5437 (if (numberp (setq chars (ignore-errors (read cur))))
5443 (if (search-forward "\nlines: " nil t)
5444 (if (numberp (setq lines (ignore-errors (read cur))))
5450 (and (search-forward "\nxref:" nil t)
5451 (nnheader-header-value)))
5453 (when gnus-extra-headers
5454 (let ((extra gnus-extra-headers)
5458 (when (search-forward
5459 (concat "\n" (symbol-name (car extra)) ":") nil t)
5460 (push (cons (car extra) (nnheader-header-value))
5464 (when (equal id ref)
5467 (when gnus-alter-header-function
5468 (funcall gnus-alter-header-function header)
5469 (setq id (mail-header-id header)
5470 ref (gnus-parent-id (mail-header-references header))))
5473 (gnus-dependencies-add-header
5474 header dependencies force-new))
5475 (push header headers))
5476 (goto-char (point-max))
5478 (nreverse headers)))))
5480 ;; Goes through the xover lines and returns a list of vectors
5481 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5482 force-new dependencies
5483 group also-fetch-heads)
5484 "Parse the news overview data in the server buffer.
5485 Return a list of headers that match SEQUENCE (see
5486 `nntp-retrieve-headers')."
5487 ;; Get the Xref when the users reads the articles since most/some
5488 ;; NNTP servers do not include Xrefs when using XOVER.
5489 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5490 (let ((mail-parse-charset gnus-newsgroup-charset)
5491 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5492 (cur nntp-server-buffer)
5493 (dependencies (or dependencies gnus-newsgroup-dependencies))
5495 ((eq gnus-read-all-available-headers t)
5497 ((stringp gnus-read-all-available-headers)
5498 (string-match gnus-read-all-available-headers group))
5501 number headers header)
5503 (set-buffer nntp-server-buffer)
5504 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5505 ;; Allow the user to mangle the headers before parsing them.
5506 (gnus-run-hooks 'gnus-parse-headers-hook)
5507 (goto-char (point-min))
5508 (gnus-parse-without-error
5509 (while (and (or sequence allp)
5511 (setq number (read cur))
5513 (while (and sequence
5514 (< (car sequence) number))
5515 (setq sequence (cdr sequence))))
5518 (eq number (car sequence))))
5520 (setq sequence (cdr sequence))
5521 (setq header (inline
5522 (gnus-nov-parse-line
5523 number dependencies force-new)))))
5524 (push header headers))
5526 ;; A common bug in inn is that if you have posted an article and
5527 ;; then retrieves the active file, it will answer correctly --
5528 ;; the new article is included. However, a NOV entry for the
5529 ;; article may not have been generated yet, so this may fail.
5530 ;; We work around this problem by retrieving the last few
5531 ;; headers using HEAD.
5532 (if (or (not also-fetch-heads)
5534 ;; We (probably) got all the headers.
5536 (let ((gnus-nov-is-evil t))
5539 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5540 (gnus-get-newsgroup-headers))))))))
5542 (defun gnus-article-get-xrefs ()
5543 "Fill in the Xref value in `gnus-current-headers', if necessary.
5544 This is meant to be called in `gnus-article-internal-prepare-hook'."
5545 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5546 gnus-current-headers)))
5547 (or (not gnus-use-cross-reference)
5549 (and (mail-header-xref headers)
5550 (not (string= (mail-header-xref headers) "")))
5551 (let ((case-fold-search t)
5554 (nnheader-narrow-to-headers)
5555 (goto-char (point-min))
5556 (when (or (and (not (eobp))
5557 (eq (downcase (char-after)) ?x)
5558 (looking-at "Xref:"))
5559 (search-forward "\nXref:" nil t))
5560 (goto-char (1+ (match-end 0)))
5561 (setq xref (buffer-substring (point)
5562 (progn (end-of-line) (point))))
5563 (mail-header-set-xref headers xref)))))))
5565 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5566 "Find article ID and insert the summary line for that article.
5567 OLD-HEADER can either be a header or a line number to insert
5568 the subject line on."
5569 (let* ((line (and (numberp old-header) old-header))
5570 (old-header (and (vectorp old-header) old-header))
5571 (header (cond ((and old-header use-old-header)
5574 (gnus-number-to-header id))
5575 (gnus-number-to-header id))
5577 (gnus-read-header id))))
5578 (number (and (numberp id) id))
5581 ;; Rebuild the thread that this article is part of and go to the
5582 ;; article we have fetched.
5583 (when (and (not gnus-show-threads)
5586 (setq d (gnus-data-find (mail-header-number old-header))))
5587 (goto-char (gnus-data-pos d))
5590 (- (gnus-point-at-bol)
5592 (1+ (gnus-point-at-eol))
5593 (gnus-delete-line))))))
5595 (mail-header-set-number header (mail-header-number old-header)))
5596 (setq gnus-newsgroup-sparse
5597 (delq (setq number (mail-header-number header))
5598 gnus-newsgroup-sparse))
5599 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5600 (push number gnus-newsgroup-limit)
5601 (gnus-rebuild-thread (mail-header-id header) line)
5602 (gnus-summary-goto-subject number nil t))
5603 (when (and (numberp number)
5605 ;; We have to update the boundaries even if we can't fetch the
5606 ;; article if ID is a number -- so that the next `P' or `N'
5607 ;; command will fetch the previous (or next) article even
5608 ;; if the one we tried to fetch this time has been canceled.
5609 (when (> number gnus-newsgroup-end)
5610 (setq gnus-newsgroup-end number))
5611 (when (< number gnus-newsgroup-begin)
5612 (setq gnus-newsgroup-begin number))
5613 (setq gnus-newsgroup-unselected
5614 (delq number gnus-newsgroup-unselected)))
5615 ;; Report back a success?
5616 (and header (mail-header-number header))))
5618 ;;; Process/prefix in the summary buffer
5620 (defun gnus-summary-work-articles (n)
5621 "Return a list of articles to be worked upon.
5622 The prefix argument, the list of process marked articles, and the
5623 current article will be taken into consideration."
5625 (set-buffer gnus-summary-buffer)
5628 ;; A numerical prefix has been given.
5629 (setq n (prefix-numeric-value n))
5630 (let ((backward (< n 0))
5631 (n (abs (prefix-numeric-value n)))
5636 (push (setq article (gnus-summary-article-number))
5639 (gnus-summary-find-prev nil article)
5640 (gnus-summary-find-next nil article)))
5642 (nreverse articles)))
5643 ((and (gnus-region-active-p) (mark))
5644 (message "region active")
5645 ;; Work on the region between point and mark.
5646 (let ((max (max (point) (mark)))
5649 (goto-char (min (min (point) (mark))))
5652 (push (setq article (gnus-summary-article-number)) articles)
5653 (gnus-summary-find-next nil article)
5655 (nreverse articles))))
5656 (gnus-newsgroup-processable
5657 ;; There are process-marked articles present.
5658 ;; Save current state.
5659 (gnus-summary-save-process-mark)
5661 (reverse gnus-newsgroup-processable))
5663 ;; Just return the current article.
5664 (list (gnus-summary-article-number))))))
5666 (defmacro gnus-summary-iterate (arg &rest forms)
5667 "Iterate over the process/prefixed articles and do FORMS.
5668 ARG is the interactive prefix given to the command. FORMS will be
5669 executed with point over the summary line of the articles."
5670 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5671 `(let ((,articles (gnus-summary-work-articles ,arg)))
5673 (gnus-summary-goto-subject (car ,articles))
5677 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5678 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5680 (defun gnus-summary-save-process-mark ()
5681 "Push the current set of process marked articles on the stack."
5683 (push (copy-sequence gnus-newsgroup-processable)
5684 gnus-newsgroup-process-stack))
5686 (defun gnus-summary-kill-process-mark ()
5687 "Push the current set of process marked articles on the stack and unmark."
5689 (gnus-summary-save-process-mark)
5690 (gnus-summary-unmark-all-processable))
5692 (defun gnus-summary-yank-process-mark ()
5693 "Pop the last process mark state off the stack and restore it."
5695 (unless gnus-newsgroup-process-stack
5696 (error "Empty mark stack"))
5697 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5699 (defun gnus-summary-process-mark-set (set)
5700 "Make SET into the current process marked articles."
5701 (gnus-summary-unmark-all-processable)
5703 (gnus-summary-set-process-mark (pop set))))
5705 ;;; Searching and stuff
5707 (defun gnus-summary-search-group (&optional backward use-level)
5708 "Search for next unread newsgroup.
5709 If optional argument BACKWARD is non-nil, search backward instead."
5711 (set-buffer gnus-group-buffer)
5712 (when (gnus-group-search-forward
5713 backward nil (if use-level (gnus-group-group-level) nil))
5714 (gnus-group-group-name))))
5716 (defun gnus-summary-best-group (&optional exclude-group)
5717 "Find the name of the best unread group.
5718 If EXCLUDE-GROUP, do not go to this group."
5720 (set-buffer gnus-group-buffer)
5722 (gnus-group-best-unread-group exclude-group))))
5724 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5725 (if backward (gnus-summary-find-prev)
5726 (let* ((dummy (gnus-summary-article-intangible-p))
5727 (article (or article (gnus-summary-article-number)))
5728 (arts (gnus-data-find-list article))
5730 (when (and (not dummy)
5731 (or (not gnus-summary-check-current)
5733 (not (gnus-data-unread-p (car arts)))))
5734 (setq arts (cdr arts)))
5739 (when (or (and undownloaded
5740 (eq gnus-undownloaded-mark
5741 (gnus-data-mark (car arts))))
5742 (gnus-data-unread-p (car arts)))
5743 (setq result (car arts)
5745 (setq arts (cdr arts)))
5748 (goto-char (gnus-data-pos result))
5749 (gnus-data-number result)))))
5751 (defun gnus-summary-find-prev (&optional unread article)
5752 (let* ((eobp (eobp))
5753 (article (or article (gnus-summary-article-number)))
5754 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5756 (when (and (not eobp)
5757 (or (not gnus-summary-check-current)
5759 (not (gnus-data-unread-p (car arts)))))
5760 (setq arts (cdr arts)))
5765 (when (gnus-data-unread-p (car arts))
5766 (setq result (car arts)
5768 (setq arts (cdr arts)))
5771 (goto-char (gnus-data-pos result))
5772 (gnus-data-number result))))
5774 (defun gnus-summary-find-subject (subject &optional unread backward article)
5775 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5776 (article (or article (gnus-summary-article-number)))
5777 (articles (gnus-data-list backward))
5778 (arts (gnus-data-find-list article articles))
5780 (when (or (not gnus-summary-check-current)
5782 (not (gnus-data-unread-p (car arts))))
5783 (setq arts (cdr arts)))
5785 (and (or (not unread)
5786 (gnus-data-unread-p (car arts)))
5787 (vectorp (gnus-data-header (car arts)))
5789 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5790 (setq result (car arts)
5792 (setq arts (cdr arts)))
5794 (goto-char (gnus-data-pos result))
5795 (gnus-data-number result))))
5797 (defun gnus-summary-search-forward (&optional unread subject backward)
5798 "Search forward for an article.
5799 If UNREAD, look for unread articles. If SUBJECT, look for
5800 articles with that subject. If BACKWARD, search backward instead."
5801 (cond (subject (gnus-summary-find-subject subject unread backward))
5802 (backward (gnus-summary-find-prev unread))
5803 (t (gnus-summary-find-next unread))))
5805 (defun gnus-recenter (&optional n)
5806 "Center point in window and redisplay frame.
5807 Also do horizontal recentering."
5809 (when (and gnus-auto-center-summary
5810 (not (eq gnus-auto-center-summary 'vertical)))
5811 (gnus-horizontal-recenter))
5814 (defun gnus-summary-recenter ()
5815 "Center point in the summary window.
5816 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5817 displayed, no centering will be performed."
5818 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5819 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5821 (let* ((top (cond ((< (window-height) 4) 0)
5822 ((< (window-height) 7) 1)
5823 (t (if (numberp gnus-auto-center-summary)
5824 gnus-auto-center-summary
5826 (height (1- (window-height)))
5827 (bottom (save-excursion (goto-char (point-max))
5828 (forward-line (- height))
5830 (window (get-buffer-window (current-buffer))))
5831 ;; The user has to want it.
5832 (when gnus-auto-center-summary
5833 (when (get-buffer-window gnus-article-buffer)
5834 ;; Only do recentering when the article buffer is displayed,
5835 ;; Set the window start to either `bottom', which is the biggest
5836 ;; possible valid number, or the second line from the top,
5837 ;; whichever is the least.
5838 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5839 (if (> bottom top-pos)
5840 ;; Keep the second line from the top visible
5841 (set-window-start window top-pos t)
5842 ;; Try to keep the bottom line visible; if it's partially
5843 ;; obscured, either scroll one more line to make it fully
5844 ;; visible, or revert to using TOP-POS.
5846 (goto-char (point-max))
5848 (let ((last-line-start (point)))
5850 (set-window-start window (point) t)
5851 (when (not (pos-visible-in-window-p last-line-start window))
5853 (set-window-start window (min (point) top-pos) t)))))))
5854 ;; Do horizontal recentering while we're at it.
5855 (when (and (get-buffer-window (current-buffer) t)
5856 (not (eq gnus-auto-center-summary 'vertical)))
5857 (let ((selected (selected-window)))
5858 (select-window (get-buffer-window (current-buffer) t))
5859 (gnus-summary-position-point)
5860 (gnus-horizontal-recenter)
5861 (select-window selected))))))
5863 (defun gnus-summary-jump-to-group (newsgroup)
5864 "Move point to NEWSGROUP in group mode buffer."
5865 ;; Keep update point of group mode buffer if visible.
5866 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5867 (save-window-excursion
5868 ;; Take care of tree window mode.
5869 (when (get-buffer-window gnus-group-buffer)
5870 (pop-to-buffer gnus-group-buffer))
5871 (gnus-group-jump-to-group newsgroup))
5873 ;; Take care of tree window mode.
5874 (if (get-buffer-window gnus-group-buffer)
5875 (pop-to-buffer gnus-group-buffer)
5876 (set-buffer gnus-group-buffer))
5877 (gnus-group-jump-to-group newsgroup))))
5879 ;; This function returns a list of article numbers based on the
5880 ;; difference between the ranges of read articles in this group and
5881 ;; the range of active articles.
5882 (defun gnus-list-of-unread-articles (group)
5883 (let* ((read (gnus-info-read (gnus-get-info group)))
5884 (active (or (gnus-active group) (gnus-activate-group group)))
5887 ;; If none are read, then all are unread.
5889 (setq first (car active))
5890 ;; If the range of read articles is a single range, then the
5891 ;; first unread article is the article after the last read
5892 ;; article. Sounds logical, doesn't it?
5893 (if (and (not (listp (cdr read)))
5894 (or (< (car read) (car active))
5895 (progn (setq read (list read))
5897 (setq first (max (car active) (1+ (cdr read))))
5898 ;; `read' is a list of ranges.
5899 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5902 (setq first (car active)))
5905 (while (< first nlast)
5907 (setq first (1+ first))))
5908 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5909 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5910 (setq read (cdr read)))))
5911 ;; And add the last unread articles.
5912 (while (<= first last)
5914 (setq first (1+ first)))
5915 ;; Return the list of unread articles.
5916 (delq 0 (nreverse unread))))
5918 (defun gnus-list-of-read-articles (group)
5919 "Return a list of unread, unticked and non-dormant articles."
5920 (let* ((info (gnus-get-info group))
5921 (marked (gnus-info-marks info))
5922 (active (gnus-active group)))
5924 (gnus-list-range-difference
5925 (gnus-list-range-difference
5926 (gnus-sorted-complement
5927 (gnus-uncompress-range active)
5928 (gnus-list-of-unread-articles group))
5929 (cdr (assq 'dormant marked)))
5930 (cdr (assq 'tick marked))))))
5932 ;; Various summary commands
5934 (defun gnus-summary-select-article-buffer ()
5935 "Reconfigure windows to show article buffer."
5937 (if (not (gnus-buffer-live-p gnus-article-buffer))
5938 (error "There is no article buffer for this summary buffer")
5939 (gnus-configure-windows 'article)
5940 (select-window (get-buffer-window gnus-article-buffer))))
5942 (defun gnus-summary-universal-argument (arg)
5943 "Perform any operation on all articles that are process/prefixed."
5945 (let ((articles (gnus-summary-work-articles arg))
5952 (substitute-command-keys
5953 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5955 (gnus-error 1 "Undefined key")
5958 (gnus-summary-goto-subject (setq article (pop articles)))
5959 (let (gnus-newsgroup-processable)
5960 (command-execute func))
5961 (gnus-summary-remove-process-mark article)))))
5962 (gnus-summary-position-point))
5964 (defun gnus-summary-toggle-truncation (&optional arg)
5965 "Toggle truncation of summary lines.
5966 With arg, turn line truncation on iff arg is positive."
5968 (setq truncate-lines
5969 (if (null arg) (not truncate-lines)
5970 (> (prefix-numeric-value arg) 0)))
5973 (defun gnus-summary-reselect-current-group (&optional all rescan)
5974 "Exit and then reselect the current newsgroup.
5975 The prefix argument ALL means to select all articles."
5977 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5978 (error "Ephemeral groups can't be reselected"))
5979 (let ((current-subject (gnus-summary-article-number))
5980 (group gnus-newsgroup-name))
5981 (setq gnus-newsgroup-begin nil)
5983 ;; We have to adjust the point of group mode buffer because
5984 ;; point was moved to the next unread newsgroup by exiting.
5985 (gnus-summary-jump-to-group group)
5988 (gnus-group-get-new-news-this-group 1)))
5989 (gnus-group-read-group all t)
5990 (gnus-summary-goto-subject current-subject nil t)))
5992 (defun gnus-summary-rescan-group (&optional all)
5993 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5995 (gnus-summary-reselect-current-group all t))
5997 (defun gnus-summary-update-info (&optional non-destructive)
5999 (let ((group gnus-newsgroup-name))
6001 (when gnus-newsgroup-kill-headers
6002 (setq gnus-newsgroup-killed
6003 (gnus-compress-sequence
6005 (gnus-list-range-intersection
6006 gnus-newsgroup-unselected gnus-newsgroup-killed)
6007 gnus-newsgroup-unreads)
6009 (unless (listp (cdr gnus-newsgroup-killed))
6010 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6011 (let ((headers gnus-newsgroup-headers))
6012 ;; Set the new ranges of read articles.
6014 (set-buffer gnus-group-buffer)
6015 (gnus-undo-force-boundary))
6016 (gnus-update-read-articles
6017 group (gnus-sorted-union
6018 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6019 ;; Set the current article marks.
6020 (let ((gnus-newsgroup-scored
6021 (if (and (not gnus-save-score)
6022 (not non-destructive))
6024 gnus-newsgroup-scored)))
6026 (gnus-update-marks)))
6027 ;; Do the cross-ref thing.
6028 (when gnus-use-cross-reference
6029 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6030 ;; Do not switch windows but change the buffer to work.
6031 (set-buffer gnus-group-buffer)
6032 (unless (gnus-ephemeral-group-p group)
6033 (gnus-group-update-group group)))))))
6035 (defun gnus-summary-save-newsrc (&optional force)
6036 "Save the current number of read/marked articles in the dribble buffer.
6037 The dribble buffer will then be saved.
6038 If FORCE (the prefix), also save the .newsrc file(s)."
6040 (gnus-summary-update-info t)
6042 (gnus-save-newsrc-file)
6043 (gnus-dribble-save)))
6045 (defun gnus-summary-exit (&optional temporary)
6046 "Exit reading current newsgroup, and then return to group selection mode.
6047 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6049 (gnus-set-global-variables)
6050 (when (gnus-buffer-live-p gnus-article-buffer)
6052 (set-buffer gnus-article-buffer)
6053 (mm-destroy-parts gnus-article-mime-handles)
6054 ;; Set it to nil for safety reason.
6055 (setq gnus-article-mime-handle-alist nil)
6056 (setq gnus-article-mime-handles nil)))
6057 (gnus-kill-save-kill-buffer)
6058 (gnus-async-halt-prefetch)
6059 (let* ((group gnus-newsgroup-name)
6060 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6063 (buf (current-buffer)))
6065 ;; Do adaptive scoring, and possibly save score files.
6066 (when gnus-newsgroup-adaptive
6067 (gnus-score-adaptive))
6068 (when gnus-use-scoring
6070 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6071 ;; If we have several article buffers, we kill them at exit.
6072 (unless gnus-single-article-buffer
6073 (gnus-kill-buffer gnus-original-article-buffer)
6074 (setq gnus-article-current nil))
6075 (when gnus-use-cache
6076 (gnus-cache-possibly-remove-articles)
6077 (gnus-cache-save-buffers))
6078 (gnus-async-prefetch-remove-group group)
6079 (when gnus-suppress-duplicates
6080 (gnus-dup-enter-articles))
6081 (when gnus-use-trees
6082 (gnus-tree-close group))
6083 (when gnus-use-cache
6084 (gnus-cache-write-active))
6085 ;; Remove entries for this group.
6086 (nnmail-purge-split-history (gnus-group-real-name group))
6087 ;; Make all changes in this group permanent.
6089 (gnus-run-hooks 'gnus-exit-group-hook)
6090 (gnus-summary-update-info))
6091 (gnus-close-group group)
6092 ;; Make sure where we were, and go to next newsgroup.
6093 (set-buffer gnus-group-buffer)
6095 (gnus-group-jump-to-group group))
6096 (gnus-run-hooks 'gnus-summary-exit-hook)
6097 (unless (or quit-config
6098 ;; If this group has disappeared from the summary
6099 ;; buffer, don't skip forwards.
6100 (not (string= group (gnus-group-group-name))))
6101 (gnus-group-next-unread-group 1))
6102 (setq group-point (point))
6105 ;; If we have several article buffers, we kill them at exit.
6106 (unless gnus-single-article-buffer
6107 (gnus-kill-buffer gnus-article-buffer)
6108 (gnus-kill-buffer gnus-original-article-buffer)
6109 (setq gnus-article-current nil))
6111 (if (not gnus-kill-summary-on-exit)
6113 (gnus-deaden-summary)
6115 ;; We set all buffer-local variables to nil. It is unclear why
6116 ;; this is needed, but if we don't, buffer-local variables are
6117 ;; not garbage-collected, it seems. This would the lead to en
6118 ;; ever-growing Emacs.
6119 (gnus-summary-clear-local-variables)
6120 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6121 (gnus-summary-clear-local-variables))
6122 (when (get-buffer gnus-article-buffer)
6123 (bury-buffer gnus-article-buffer))
6124 ;; We clear the global counterparts of the buffer-local
6125 ;; variables as well, just to be on the safe side.
6126 (set-buffer gnus-group-buffer)
6127 (gnus-summary-clear-local-variables)
6128 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6129 (gnus-summary-clear-local-variables)))
6130 (setq gnus-current-select-method gnus-select-method)
6131 (pop-to-buffer gnus-group-buffer)
6132 (if (not quit-config)
6134 (goto-char group-point)
6135 (gnus-configure-windows 'group 'force))
6136 (gnus-handle-ephemeral-exit quit-config))
6137 ;; Return to group mode buffer.
6138 (when (eq mode 'gnus-summary-mode)
6139 (gnus-kill-buffer buf))
6140 ;; Clear the current group name.
6142 (setq gnus-newsgroup-name nil)))))
6144 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6145 (defun gnus-summary-exit-no-update (&optional no-questions)
6146 "Quit reading current newsgroup without updating read article info."
6148 (let* ((group gnus-newsgroup-name)
6149 (quit-config (gnus-group-quit-config group)))
6150 (when (or no-questions
6152 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6153 (gnus-async-halt-prefetch)
6155 (delq 'gnus-summary-expire-articles
6156 (copy-sequence gnus-summary-prepare-exit-hook)))
6157 (when (gnus-buffer-live-p gnus-article-buffer)
6159 (set-buffer gnus-article-buffer)
6160 (mm-destroy-parts gnus-article-mime-handles)
6161 ;; Set it to nil for safety reason.
6162 (setq gnus-article-mime-handle-alist nil)
6163 (setq gnus-article-mime-handles nil)))
6164 ;; If we have several article buffers, we kill them at exit.
6165 (unless gnus-single-article-buffer
6166 (gnus-kill-buffer gnus-article-buffer)
6167 (gnus-kill-buffer gnus-original-article-buffer)
6168 (setq gnus-article-current nil))
6169 (if (not gnus-kill-summary-on-exit)
6170 (gnus-deaden-summary)
6171 (gnus-close-group group)
6172 (gnus-summary-clear-local-variables)
6173 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6174 (gnus-summary-clear-local-variables))
6175 (set-buffer gnus-group-buffer)
6176 (gnus-summary-clear-local-variables)
6177 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6178 (gnus-summary-clear-local-variables))
6179 (when (get-buffer gnus-summary-buffer)
6180 (kill-buffer gnus-summary-buffer)))
6181 (unless gnus-single-article-buffer
6182 (setq gnus-article-current nil))
6183 (when gnus-use-trees
6184 (gnus-tree-close group))
6185 (gnus-async-prefetch-remove-group group)
6186 (when (get-buffer gnus-article-buffer)
6187 (bury-buffer gnus-article-buffer))
6188 ;; Return to the group buffer.
6189 (gnus-configure-windows 'group 'force)
6190 ;; Clear the current group name.
6191 (setq gnus-newsgroup-name nil)
6192 (when (equal (gnus-group-group-name) group)
6193 (gnus-group-next-unread-group 1))
6195 (gnus-handle-ephemeral-exit quit-config)))))
6197 (defun gnus-handle-ephemeral-exit (quit-config)
6198 "Handle movement when leaving an ephemeral group.
6199 The state which existed when entering the ephemeral is reset."
6200 (if (not (buffer-name (car quit-config)))
6201 (gnus-configure-windows 'group 'force)
6202 (set-buffer (car quit-config))
6203 (cond ((eq major-mode 'gnus-summary-mode)
6204 (gnus-set-global-variables))
6205 ((eq major-mode 'gnus-article-mode)
6207 ;; The `gnus-summary-buffer' variable may point
6208 ;; to the old summary buffer when using a single
6210 (unless (gnus-buffer-live-p gnus-summary-buffer)
6211 (set-buffer gnus-group-buffer))
6212 (set-buffer gnus-summary-buffer)
6213 (gnus-set-global-variables))))
6214 (if (or (eq (cdr quit-config) 'article)
6215 (eq (cdr quit-config) 'pick))
6217 ;; The current article may be from the ephemeral group
6218 ;; thus it is best that we reload this article
6219 (gnus-summary-show-article)
6220 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6221 (gnus-configure-windows 'pick 'force)
6222 (gnus-configure-windows (cdr quit-config) 'force)))
6223 (gnus-configure-windows (cdr quit-config) 'force))
6224 (when (eq major-mode 'gnus-summary-mode)
6225 (gnus-summary-next-subject 1 nil t)
6226 (gnus-summary-recenter)
6227 (gnus-summary-position-point))))
6231 (defvar gnus-dead-summary-mode-map nil)
6233 (unless gnus-dead-summary-mode-map
6234 (setq gnus-dead-summary-mode-map (make-keymap))
6235 (suppress-keymap gnus-dead-summary-mode-map)
6236 (substitute-key-definition
6237 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6238 (dolist (key '("\C-d" "\r" "\177" [delete]))
6239 (define-key gnus-dead-summary-mode-map
6240 key 'gnus-summary-wake-up-the-dead))
6241 (dolist (key '("q" "Q"))
6242 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6244 (defvar gnus-dead-summary-mode nil
6245 "Minor mode for Gnus summary buffers.")
6247 (defun gnus-dead-summary-mode (&optional arg)
6248 "Minor mode for Gnus summary buffers."
6250 (when (eq major-mode 'gnus-summary-mode)
6251 (make-local-variable 'gnus-dead-summary-mode)
6252 (setq gnus-dead-summary-mode
6253 (if (null arg) (not gnus-dead-summary-mode)
6254 (> (prefix-numeric-value arg) 0)))
6255 (when gnus-dead-summary-mode
6256 (gnus-add-minor-mode
6257 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6259 (defun gnus-deaden-summary ()
6260 "Make the current summary buffer into a dead summary buffer."
6261 ;; Kill any previous dead summary buffer.
6262 (when (and gnus-dead-summary
6263 (buffer-name gnus-dead-summary))
6265 (set-buffer gnus-dead-summary)
6266 (when gnus-dead-summary-mode
6267 (kill-buffer (current-buffer)))))
6268 ;; Make this the current dead summary.
6269 (setq gnus-dead-summary (current-buffer))
6270 (gnus-dead-summary-mode 1)
6271 (let ((name (buffer-name)))
6272 (when (string-match "Summary" name)
6274 (concat (substring name 0 (match-beginning 0)) "Dead "
6275 (substring name (match-beginning 0)))
6279 (defun gnus-kill-or-deaden-summary (buffer)
6280 "Kill or deaden the summary BUFFER."
6282 (when (and (buffer-name buffer)
6283 (not gnus-single-article-buffer))
6286 (gnus-kill-buffer gnus-article-buffer)
6287 (gnus-kill-buffer gnus-original-article-buffer)))
6290 (gnus-kill-summary-on-exit
6291 (when (and gnus-use-trees
6292 (gnus-buffer-exists-p buffer))
6295 (gnus-tree-close gnus-newsgroup-name)))
6296 (gnus-kill-buffer buffer))
6297 ;; Deaden the buffer.
6298 ((gnus-buffer-exists-p buffer)
6301 (gnus-deaden-summary))))))
6303 (defun gnus-summary-wake-up-the-dead (&rest args)
6304 "Wake up the dead summary buffer."
6306 (gnus-dead-summary-mode -1)
6307 (let ((name (buffer-name)))
6308 (when (string-match "Dead " name)
6310 (concat (substring name 0 (match-beginning 0))
6311 (substring name (match-end 0)))
6313 (gnus-message 3 "This dead summary is now alive again"))
6315 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6316 (defun gnus-summary-fetch-faq (&optional faq-dir)
6317 "Fetch the FAQ for the current group.
6318 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6322 (when current-prefix-arg
6324 "Faq dir: " (and (listp gnus-group-faq-directory)
6325 (mapcar (lambda (file) (list file))
6326 gnus-group-faq-directory))))))
6327 (let (gnus-faq-buffer)
6328 (when (setq gnus-faq-buffer
6329 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6330 (gnus-configure-windows 'summary-faq))))
6332 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6333 (defun gnus-summary-describe-group (&optional force)
6334 "Describe the current newsgroup."
6336 (gnus-group-describe-group force gnus-newsgroup-name))
6338 (defun gnus-summary-describe-briefly ()
6339 "Describe summary mode commands briefly."
6341 (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")))
6343 ;; Walking around group mode buffer from summary mode.
6345 (defun gnus-summary-next-group (&optional no-article target-group backward)
6346 "Exit current newsgroup and then select next unread newsgroup.
6347 If prefix argument NO-ARTICLE is non-nil, no article is selected
6348 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6349 previous group instead."
6351 ;; Stop pre-fetching.
6352 (gnus-async-halt-prefetch)
6353 (let ((current-group gnus-newsgroup-name)
6354 (current-buffer (current-buffer))
6356 ;; First we semi-exit this group to update Xrefs and all variables.
6357 ;; We can't do a real exit, because the window conf must remain
6358 ;; the same in case the user is prompted for info, and we don't
6359 ;; want the window conf to change before that...
6360 (gnus-summary-exit t)
6361 (while (not entered)
6362 ;; Then we find what group we are supposed to enter.
6363 (set-buffer gnus-group-buffer)
6364 (gnus-group-jump-to-group current-group)
6367 (if (eq gnus-keep-same-level 'best)
6368 (gnus-summary-best-group gnus-newsgroup-name)
6369 (gnus-summary-search-group backward gnus-keep-same-level))))
6370 (if (not target-group)
6371 ;; There are no further groups, so we return to the group
6374 (gnus-message 5 "Returning to the group buffer")
6376 (when (gnus-buffer-live-p current-buffer)
6377 (set-buffer current-buffer)
6378 (gnus-summary-exit))
6379 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6380 ;; We try to enter the target group.
6381 (gnus-group-jump-to-group target-group)
6382 (let ((unreads (gnus-group-group-unread)))
6383 (if (and (or (eq t unreads)
6384 (and unreads (not (zerop unreads))))
6385 (gnus-summary-read-group
6386 target-group nil no-article
6387 (and (buffer-name current-buffer) current-buffer)
6390 (setq current-group target-group
6391 target-group nil)))))))
6393 (defun gnus-summary-prev-group (&optional no-article)
6394 "Exit current newsgroup and then select previous unread newsgroup.
6395 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6397 (gnus-summary-next-group no-article nil t))
6399 ;; Walking around summary lines.
6401 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6402 "Go to the first unread subject.
6403 If UNREAD is non-nil, go to the first unread article.
6404 Returns the article selected or nil if there are no unread articles."
6409 ((null gnus-newsgroup-data)
6410 (gnus-message 3 "No articles in the group")
6412 ;; Pick the first article.
6414 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6415 (gnus-data-number (car gnus-newsgroup-data)))
6416 ;; No unread articles.
6417 ((null gnus-newsgroup-unreads)
6418 (gnus-message 3 "No more unread articles")
6420 ;; Find the first unread article.
6422 (let ((data gnus-newsgroup-data))
6424 (and (not (and undownloaded
6425 (eq gnus-undownloaded-mark
6426 (gnus-data-mark (car data)))))
6429 (gnus-data-number (car data))
6430 gnus-newsgroup-unseen))
6431 (not (gnus-data-unread-p (car data))))
6432 (not (gnus-data-unread-p (car data))))))
6433 (setq data (cdr data)))
6435 (goto-char (gnus-data-pos (car data)))
6436 (gnus-data-number (car data))))))
6437 (gnus-summary-position-point)))
6439 (defun gnus-summary-next-subject (n &optional unread dont-display)
6440 "Go to next N'th summary line.
6441 If N is negative, go to the previous N'th subject line.
6442 If UNREAD is non-nil, only unread articles are selected.
6443 The difference between N and the actual number of steps taken is
6446 (let ((backward (< n 0))
6450 (gnus-summary-find-prev unread)
6451 (gnus-summary-find-next unread)))
6452 (unless (zerop (setq n (1- n)))
6453 (gnus-summary-show-thread)))
6455 (gnus-message 7 "No more%s articles"
6456 (if unread " unread" "")))
6457 (unless dont-display
6458 (gnus-summary-recenter)
6459 (gnus-summary-position-point))
6462 (defun gnus-summary-next-unread-subject (n)
6463 "Go to next N'th unread summary line."
6465 (gnus-summary-next-subject n t))
6467 (defun gnus-summary-prev-subject (n &optional unread)
6468 "Go to previous N'th summary line.
6469 If optional argument UNREAD is non-nil, only unread article is selected."
6471 (gnus-summary-next-subject (- n) unread))
6473 (defun gnus-summary-prev-unread-subject (n)
6474 "Go to previous N'th unread summary line."
6476 (gnus-summary-next-subject (- n) t))
6478 (defun gnus-summary-goto-subject (article &optional force silent)
6479 "Go the subject line of ARTICLE.
6480 If FORCE, also allow jumping to articles not currently shown."
6481 (interactive "nArticle number: ")
6482 (unless (numberp article)
6483 (error "Article %s is not a number" article))
6485 (data (gnus-data-find article)))
6486 ;; We read in the article if we have to.
6489 (gnus-summary-insert-subject
6491 (if (or (numberp force) (vectorp force)) force)
6493 (setq data (gnus-data-find article)))
6498 (gnus-message 3 "Can't find article %d" article))
6500 (let ((pt (gnus-data-pos data)))
6502 (gnus-summary-set-article-display-arrow pt))
6503 (gnus-summary-position-point)
6506 ;; Walking around summary lines with displaying articles.
6508 (defun gnus-summary-expand-window (&optional arg)
6509 "Make the summary buffer take up the entire Emacs frame.
6510 Given a prefix, will force an `article' buffer configuration."
6513 (gnus-configure-windows 'article 'force)
6514 (gnus-configure-windows 'summary 'force)))
6516 (defun gnus-summary-display-article (article &optional all-header)
6517 "Display ARTICLE in article buffer."
6518 (when (gnus-buffer-live-p gnus-article-buffer)
6519 (with-current-buffer gnus-article-buffer
6520 (mm-enable-multibyte)))
6521 (gnus-set-global-variables)
6522 (when (gnus-buffer-live-p gnus-article-buffer)
6523 (with-current-buffer gnus-article-buffer
6524 (setq gnus-article-charset gnus-newsgroup-charset)
6525 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6526 (mm-enable-multibyte)))
6530 (if gnus-summary-display-article-function
6531 (funcall gnus-summary-display-article-function article all-header)
6532 (gnus-article-prepare article all-header))
6533 (gnus-run-hooks 'gnus-select-article-hook)
6534 (when (and gnus-current-article
6535 (not (zerop gnus-current-article)))
6536 (gnus-summary-goto-subject gnus-current-article))
6537 (gnus-summary-recenter)
6538 (when (and gnus-use-trees gnus-show-threads)
6539 (gnus-possibly-generate-tree article)
6540 (gnus-highlight-selected-tree article))
6541 ;; Successfully display article.
6542 (gnus-article-set-window-start
6543 (cdr (assq article gnus-newsgroup-bookmarks))))))
6545 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6546 "Select the current article.
6547 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6548 non-nil, the article will be re-fetched even if it already present in
6549 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6551 ;; Make sure we are in the summary buffer to work around bbdb bug.
6552 (unless (eq major-mode 'gnus-summary-mode)
6553 (set-buffer gnus-summary-buffer))
6554 (let ((article (or article (gnus-summary-article-number)))
6555 (all-headers (not (not all-headers))) ;Must be t or nil.
6556 gnus-summary-display-article-function)
6558 (gnus-summary-article-pseudo-p article)
6559 (error "This is a pseudo-article"))
6561 (set-buffer gnus-summary-buffer)
6562 (if (or (and gnus-single-article-buffer
6563 (or (null gnus-current-article)
6564 (null gnus-article-current)
6565 (null (get-buffer gnus-article-buffer))
6566 (not (eq article (cdr gnus-article-current)))
6567 (not (equal (car gnus-article-current)
6568 gnus-newsgroup-name))))
6569 (and (not gnus-single-article-buffer)
6570 (or (null gnus-current-article)
6571 (not (eq gnus-current-article article))))
6573 ;; The requested article is different from the current article.
6575 (gnus-summary-display-article article all-headers)
6576 (when (gnus-buffer-live-p gnus-article-buffer)
6577 (with-current-buffer gnus-article-buffer
6578 (if (not gnus-article-decoded-p) ;; a local variable
6579 (mm-disable-multibyte))))
6580 ;;; Hidden headers are not hidden text any more.
6581 ;; (when (or all-headers gnus-show-all-headers)
6582 ;; (gnus-article-show-all-headers))
6583 (gnus-article-set-window-start
6584 (cdr (assq article gnus-newsgroup-bookmarks)))
6586 ;; (when (or all-headers gnus-show-all-headers)
6587 ;; (gnus-article-show-all-headers))
6590 (defun gnus-summary-force-verify-and-decrypt ()
6592 (let ((mm-verify-option 'known)
6593 (mm-decrypt-option 'known))
6594 (gnus-summary-select-article nil 'force)))
6596 (defun gnus-summary-set-current-mark (&optional current-mark)
6597 "Obsolete function."
6600 (defun gnus-summary-next-article (&optional unread subject backward push)
6601 "Select the next article.
6602 If UNREAD, only unread articles are selected.
6603 If SUBJECT, only articles with SUBJECT are selected.
6604 If BACKWARD, the previous article is selected instead of the next."
6607 ;; Is there such an article?
6608 ((and (gnus-summary-search-forward unread subject backward)
6609 (or (gnus-summary-display-article (gnus-summary-article-number))
6610 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6611 (gnus-summary-position-point))
6612 ;; If not, we try the first unread, if that is wanted.
6614 gnus-auto-select-same
6615 (gnus-summary-first-unread-article))
6616 (gnus-summary-position-point)
6617 (gnus-message 6 "Wrapped"))
6618 ;; Try to get next/previous article not displayed in this group.
6619 ((and gnus-auto-extend-newsgroup
6620 (not unread) (not subject))
6621 (gnus-summary-goto-article
6622 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6623 nil (count-lines (point-min) (point))))
6624 ;; Go to next/previous group.
6626 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6627 (gnus-summary-jump-to-group gnus-newsgroup-name))
6628 (let ((cmd last-command-char)
6631 (set-buffer gnus-group-buffer)
6634 (if (eq gnus-keep-same-level 'best)
6635 (gnus-summary-best-group gnus-newsgroup-name)
6636 (gnus-summary-search-group backward gnus-keep-same-level))))
6637 ;; For some reason, the group window gets selected. We change
6639 (select-window (get-buffer-window (current-buffer)))
6640 ;; Select next unread newsgroup automagically.
6642 ((or (not gnus-auto-select-next)
6644 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6645 ((or (eq gnus-auto-select-next 'quietly)
6646 (and (eq gnus-auto-select-next 'slightly-quietly)
6648 (and (eq gnus-auto-select-next 'almost-quietly)
6649 (gnus-summary-last-article-p)))
6651 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6653 (gnus-message 7 "No more%s articles (%s)..."
6654 (if unread " unread" "")
6655 (if group (concat "selecting " group)
6657 (gnus-summary-next-group nil group backward)))
6659 (when (gnus-key-press-event-p last-input-event)
6660 (gnus-summary-walk-group-buffer
6661 gnus-newsgroup-name cmd unread backward point))))))))
6663 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6664 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6665 (?\C-p (gnus-group-prev-unread-group 1))))
6666 (cursor-in-echo-area t)
6667 keve key group ended)
6669 (set-buffer gnus-group-buffer)
6672 (if (eq gnus-keep-same-level 'best)
6673 (gnus-summary-best-group gnus-newsgroup-name)
6674 (gnus-summary-search-group backward gnus-keep-same-level))))
6677 5 "No more%s articles%s" (if unread " unread" "")
6679 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6680 (format " (Type %s for %s [%s])"
6681 (single-key-description cmd) group
6682 (car (gnus-gethash group gnus-newsrc-hashtb)))
6683 (format " (Type %s to exit %s)"
6684 (single-key-description cmd)
6685 gnus-newsgroup-name)))
6686 ;; Confirm auto selection.
6687 (setq key (car (setq keve (gnus-read-event-char))))
6690 ((assq key keystrokes)
6691 (let ((obuf (current-buffer)))
6692 (switch-to-buffer gnus-group-buffer)
6694 (gnus-group-jump-to-group group))
6695 (eval (cadr (assq key keystrokes)))
6696 (setq group (gnus-group-group-name))
6697 (switch-to-buffer obuf))
6701 (gnus-ephemeral-group-p gnus-newsgroup-name))
6703 (gnus-summary-next-group nil group backward)))
6705 (push (cdr keve) unread-command-events))))))
6707 (defun gnus-summary-next-unread-article ()
6708 "Select unread article after current one."
6710 (gnus-summary-next-article
6711 (or (not (eq gnus-summary-goto-unread 'never))
6712 (gnus-summary-last-article-p (gnus-summary-article-number)))
6713 (and gnus-auto-select-same
6714 (gnus-summary-article-subject))))
6716 (defun gnus-summary-prev-article (&optional unread subject)
6717 "Select the article after the current one.
6718 If UNREAD is non-nil, only unread articles are selected."
6720 (gnus-summary-next-article unread subject t))
6722 (defun gnus-summary-prev-unread-article ()
6723 "Select unread article before current one."
6725 (gnus-summary-prev-article
6726 (or (not (eq gnus-summary-goto-unread 'never))
6727 (gnus-summary-first-article-p (gnus-summary-article-number)))
6728 (and gnus-auto-select-same
6729 (gnus-summary-article-subject))))
6731 (defun gnus-summary-next-page (&optional lines circular)
6732 "Show next page of the selected article.
6733 If at the end of the current article, select the next article.
6734 LINES says how many lines should be scrolled up.
6736 If CIRCULAR is non-nil, go to the start of the article instead of
6737 selecting the next article when reaching the end of the current
6740 (setq gnus-summary-buffer (current-buffer))
6741 (gnus-set-global-variables)
6742 (let ((article (gnus-summary-article-number))
6743 (article-window (get-buffer-window gnus-article-buffer t))
6745 ;; If the buffer is empty, we have no article.
6747 (error "No article to select"))
6748 (gnus-configure-windows 'article)
6749 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6750 (if (and (eq gnus-summary-goto-unread 'never)
6751 (not (gnus-summary-last-article-p article)))
6752 (gnus-summary-next-article)
6753 (gnus-summary-next-unread-article))
6754 (if (or (null gnus-current-article)
6755 (null gnus-article-current)
6756 (/= article (cdr gnus-article-current))
6757 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6758 ;; Selected subject is different from current article's.
6759 (gnus-summary-display-article article)
6760 (when article-window
6761 (gnus-eval-in-buffer-window gnus-article-buffer
6762 (setq endp (gnus-article-next-page lines)))
6765 (gnus-summary-beginning-of-article))
6767 (gnus-message 3 "End of message"))
6769 (if (and (eq gnus-summary-goto-unread 'never)
6770 (not (gnus-summary-last-article-p article)))
6771 (gnus-summary-next-article)
6772 (gnus-summary-next-unread-article))))))))
6773 (gnus-summary-recenter)
6774 (gnus-summary-position-point)))
6776 (defun gnus-summary-prev-page (&optional lines move)
6777 "Show previous page of selected article.
6778 Argument LINES specifies lines to be scrolled down.
6779 If MOVE, move to the previous unread article if point is at
6780 the beginning of the buffer."
6782 (let ((article (gnus-summary-article-number))
6783 (article-window (get-buffer-window gnus-article-buffer t))
6785 (gnus-configure-windows 'article)
6786 (if (or (null gnus-current-article)
6787 (null gnus-article-current)
6788 (/= article (cdr gnus-article-current))
6789 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6790 ;; Selected subject is different from current article's.
6791 (gnus-summary-display-article article)
6792 (gnus-summary-recenter)
6793 (when article-window
6794 (gnus-eval-in-buffer-window gnus-article-buffer
6795 (setq endp (gnus-article-prev-page lines)))
6796 (when (and move endp)
6798 (gnus-message 3 "Beginning of message"))
6800 (if (and (eq gnus-summary-goto-unread 'never)
6801 (not (gnus-summary-first-article-p article)))
6802 (gnus-summary-prev-article)
6803 (gnus-summary-prev-unread-article))))))))
6804 (gnus-summary-position-point))
6806 (defun gnus-summary-prev-page-or-article (&optional lines)
6807 "Show previous page of selected article.
6808 Argument LINES specifies lines to be scrolled down.
6809 If at the beginning of the article, go to the next article."
6811 (gnus-summary-prev-page lines t))
6813 (defun gnus-summary-scroll-up (lines)
6814 "Scroll up (or down) one line current article.
6815 Argument LINES specifies lines to be scrolled up (or down if negative)."
6817 (gnus-configure-windows 'article)
6818 (gnus-summary-show-thread)
6819 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6820 (gnus-eval-in-buffer-window gnus-article-buffer
6822 (when (gnus-article-next-page lines)
6823 (gnus-message 3 "End of message")))
6825 (gnus-article-prev-page (- lines))))))
6826 (gnus-summary-recenter)
6827 (gnus-summary-position-point))
6829 (defun gnus-summary-scroll-down (lines)
6830 "Scroll down (or up) one line current article.
6831 Argument LINES specifies lines to be scrolled down (or up if negative)."
6833 (gnus-summary-scroll-up (- lines)))
6835 (defun gnus-summary-next-same-subject ()
6836 "Select next article which has the same subject as current one."
6838 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6840 (defun gnus-summary-prev-same-subject ()
6841 "Select previous article which has the same subject as current one."
6843 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6845 (defun gnus-summary-next-unread-same-subject ()
6846 "Select next unread article which has the same subject as current one."
6848 (gnus-summary-next-article t (gnus-summary-article-subject)))
6850 (defun gnus-summary-prev-unread-same-subject ()
6851 "Select previous unread article which has the same subject as current one."
6853 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6855 (defun gnus-summary-first-unread-article ()
6856 "Select the first unread article.
6857 Return nil if there are no unread articles."
6860 (when (gnus-summary-first-subject t)
6861 (gnus-summary-show-thread)
6862 (gnus-summary-first-subject t)
6863 (gnus-summary-display-article (gnus-summary-article-number)))
6864 (gnus-summary-position-point)))
6866 (defun gnus-summary-first-unread-subject ()
6867 "Place the point on the subject line of the first unread article.
6868 Return nil if there are no unread articles."
6871 (when (gnus-summary-first-subject t)
6872 (gnus-summary-show-thread)
6873 (gnus-summary-first-subject t))
6874 (gnus-summary-position-point)))
6876 (defun gnus-summary-first-unseen-subject ()
6877 "Place the point on the subject line of the first unseen article.
6878 Return nil if there are no unseen articles."
6881 (when (gnus-summary-first-subject t t t)
6882 (gnus-summary-show-thread)
6883 (gnus-summary-first-subject t t t))
6884 (gnus-summary-position-point)))
6886 (defun gnus-summary-first-unseen-or-unread-subject ()
6887 "Place the point on the subject line of the first unseen article.
6888 Return nil if there are no unseen articles."
6891 (unless (when (gnus-summary-first-subject t t t)
6892 (gnus-summary-show-thread)
6893 (gnus-summary-first-subject t t t))
6894 (when (gnus-summary-first-subject t)
6895 (gnus-summary-show-thread)
6896 (gnus-summary-first-subject t)))
6897 (gnus-summary-position-point)))
6899 (defun gnus-summary-first-article ()
6900 "Select the first article.
6901 Return nil if there are no articles."
6904 (when (gnus-summary-first-subject)
6905 (gnus-summary-show-thread)
6906 (gnus-summary-first-subject)
6907 (gnus-summary-display-article (gnus-summary-article-number)))
6908 (gnus-summary-position-point)))
6910 (defun gnus-summary-best-unread-article (&optional arg)
6911 "Select the unread article with the highest score.
6912 If given a prefix argument, select the next unread article that has a
6913 score higher than the default score."
6915 (let ((article (if arg
6916 (gnus-summary-better-unread-subject)
6917 (gnus-summary-best-unread-subject))))
6919 (gnus-summary-goto-article article)
6920 (error "No unread articles"))))
6922 (defun gnus-summary-best-unread-subject ()
6923 "Select the unread subject with the highest score."
6925 (let ((best -1000000)
6926 (data gnus-newsgroup-data)
6929 (and (gnus-data-unread-p (car data))
6931 (gnus-summary-article-score (gnus-data-number (car data))))
6934 article (gnus-data-number (car data))))
6935 (setq data (cdr data)))
6937 (gnus-summary-goto-subject article))
6938 (gnus-summary-position-point)
6941 (defun gnus-summary-better-unread-subject ()
6942 "Select the first unread subject that has a score over the default score."
6944 (let ((data gnus-newsgroup-data)
6946 (while (and (setq article (gnus-data-number (car data)))
6947 (or (gnus-data-read-p (car data))
6948 (not (> (gnus-summary-article-score article)
6949 gnus-summary-default-score))))
6950 (setq data (cdr data)))
6952 (gnus-summary-goto-subject article))
6953 (gnus-summary-position-point)
6956 (defun gnus-summary-last-subject ()
6957 "Go to the last displayed subject line in the group."
6958 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6960 (gnus-summary-goto-subject article))))
6962 (defun gnus-summary-goto-article (article &optional all-headers force)
6963 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6964 If ALL-HEADERS is non-nil, no header lines are hidden.
6965 If FORCE, go to the article even if it isn't displayed. If FORCE
6966 is a number, it is the line the article is to be displayed on."
6970 "Article number or Message-ID: "
6971 (mapcar (lambda (number) (list (int-to-string number)))
6972 gnus-newsgroup-limit))
6976 (if (and (stringp article)
6977 (string-match "@" article))
6978 (gnus-summary-refer-article article)
6979 (when (stringp article)
6980 (setq article (string-to-number article)))
6981 (if (gnus-summary-goto-subject article force)
6982 (gnus-summary-display-article article all-headers)
6983 (gnus-message 4 "Couldn't go to article %s" article) nil))
6984 (gnus-summary-position-point)))
6986 (defun gnus-summary-goto-last-article ()
6987 "Go to the previously read article."
6990 (when gnus-last-article
6991 (gnus-summary-goto-article gnus-last-article nil t))
6992 (gnus-summary-position-point)))
6994 (defun gnus-summary-pop-article (number)
6995 "Pop one article off the history and go to the previous.
6996 NUMBER articles will be popped off."
6999 (setq gnus-newsgroup-history
7000 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7002 (gnus-summary-goto-article (car to) nil t)
7003 (error "Article history empty")))
7004 (gnus-summary-position-point))
7006 ;; Summary commands and functions for limiting the summary buffer.
7008 (defun gnus-summary-limit-to-articles (n)
7009 "Limit the summary buffer to the next N articles.
7010 If not given a prefix, use the process marked articles instead."
7013 (let ((articles (gnus-summary-work-articles n)))
7014 (setq gnus-newsgroup-processable nil)
7015 (gnus-summary-limit articles))
7016 (gnus-summary-position-point)))
7018 (defun gnus-summary-pop-limit (&optional total)
7019 "Restore the previous limit.
7020 If given a prefix, remove all limits."
7023 (setq gnus-newsgroup-limits
7024 (list (mapcar (lambda (h) (mail-header-number h))
7025 gnus-newsgroup-headers))))
7026 (unless gnus-newsgroup-limits
7027 (error "No limit to pop"))
7029 (gnus-summary-limit nil 'pop)
7030 (gnus-summary-position-point)))
7032 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7033 "Limit the summary buffer to articles that have subjects that match a regexp.
7034 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7036 (list (read-string (if current-prefix-arg
7037 "Exclude subject (regexp): "
7038 "Limit to subject (regexp): "))
7039 nil current-prefix-arg))
7041 (setq header "subject"))
7042 (when (not (equal "" subject))
7044 (let ((articles (gnus-summary-find-matching
7045 (or header "subject") subject 'all nil nil
7048 (error "Found no matches for \"%s\"" subject))
7049 (gnus-summary-limit articles))
7050 (gnus-summary-position-point))))
7052 (defun gnus-summary-limit-to-author (from &optional not-matching)
7053 "Limit the summary buffer to articles that have authors that match a regexp.
7054 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7056 (list (read-string (if current-prefix-arg
7057 "Exclude author (regexp): "
7058 "Limit to author (regexp): "))
7059 current-prefix-arg))
7060 (gnus-summary-limit-to-subject from "from" not-matching))
7062 (defun gnus-summary-limit-to-age (age &optional younger-p)
7063 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7064 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7065 articles that are younger than AGE days."
7067 (let ((younger current-prefix-arg)
7070 (while (not days-got)
7071 (setq days (if younger
7072 (read-string "Limit to articles within (in days): ")
7073 (read-string "Limit to articles older than (in days): ")))
7074 (when (> (length days) 0)
7075 (setq days (read days)))
7081 (setq younger (not younger))
7082 (setq days (* days -1)))))
7083 (message "Please enter a number.")
7085 (list days younger)))
7087 (let ((data gnus-newsgroup-data)
7088 (cutoff (days-to-time age))
7089 articles d date is-younger)
7090 (while (setq d (pop data))
7091 (when (and (vectorp (gnus-data-header d))
7092 (setq date (mail-header-date (gnus-data-header d))))
7093 (setq is-younger (time-less-p
7094 (time-since (condition-case ()
7101 (push (gnus-data-number d) articles))))
7102 (gnus-summary-limit (nreverse articles)))
7103 (gnus-summary-position-point)))
7105 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7106 "Limit the summary buffer to articles that match an 'extra' header."
7110 (gnus-completing-read-with-default
7111 (symbol-name (car gnus-extra-headers))
7112 (if current-prefix-arg
7113 "Exclude extra header:"
7114 "Limit extra header:")
7116 (cons (symbol-name x) x))
7121 (read-string (format "%s header %s (regexp): "
7122 (if current-prefix-arg "Exclude" "Limit to")
7124 current-prefix-arg)))
7125 (when (not (equal "" regexp))
7127 (let ((articles (gnus-summary-find-matching
7128 (cons 'extra header) regexp 'all nil nil
7131 (error "Found no matches for \"%s\"" regexp))
7132 (gnus-summary-limit articles))
7133 (gnus-summary-position-point))))
7135 (defun gnus-summary-limit-to-display-predicate ()
7136 "Limit the summary buffer to the predicated in the `display' group parameter."
7138 (unless gnus-newsgroup-display
7139 (error "There is no `display' group parameter"))
7141 (dolist (number gnus-newsgroup-articles)
7142 (when (funcall gnus-newsgroup-display)
7143 (push number articles)))
7144 (gnus-summary-limit articles))
7145 (gnus-summary-position-point))
7147 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7149 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7151 (defun gnus-summary-limit-to-unread (&optional all)
7152 "Limit the summary buffer to articles that are not marked as read.
7153 If ALL is non-nil, limit strictly to unread articles."
7156 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7157 (gnus-summary-limit-to-marks
7158 ;; Concat all the marks that say that an article is read and have
7160 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7161 gnus-killed-mark gnus-kill-file-mark
7162 gnus-low-score-mark gnus-expirable-mark
7163 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7164 gnus-duplicate-mark gnus-souped-mark)
7167 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7168 (make-obsolete 'gnus-summary-delete-marked-with
7169 'gnus-summary-limit-exlude-marks)
7171 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7172 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7173 If REVERSE, limit the summary buffer to articles that are marked
7174 with MARKS. MARKS can either be a string of marks or a list of marks.
7175 Returns how many articles were removed."
7176 (interactive "sMarks: ")
7177 (gnus-summary-limit-to-marks marks t))
7179 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7180 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7181 If REVERSE (the prefix), limit the summary buffer to articles that are
7182 not marked with MARKS. MARKS can either be a string of marks or a
7184 Returns how many articles were removed."
7185 (interactive "sMarks: \nP")
7187 (let ((data gnus-newsgroup-data)
7188 (marks (if (listp marks) marks
7189 (append marks nil))) ; Transform to list.
7192 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7193 (memq (gnus-data-mark (car data)) marks))
7194 (push (gnus-data-number (car data)) articles))
7195 (setq data (cdr data)))
7196 (gnus-summary-limit articles))
7197 (gnus-summary-position-point)))
7199 (defun gnus-summary-limit-to-score (score)
7200 "Limit to articles with score at or above SCORE."
7201 (interactive "NLimit to articles with score of at least: ")
7202 (let ((data gnus-newsgroup-data)
7205 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7207 (push (gnus-data-number (car data)) articles))
7208 (setq data (cdr data)))
7210 (gnus-summary-limit articles)
7211 (gnus-summary-position-point))))
7213 (defun gnus-summary-limit-include-thread (id)
7214 "Display all the hidden articles that is in the thread with ID in it.
7215 When called interactively, ID is the Message-ID of the current
7217 (interactive (list (mail-header-id (gnus-summary-article-header))))
7218 (let ((articles (gnus-articles-in-thread
7219 (gnus-id-to-thread (gnus-root-id id)))))
7221 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7222 (gnus-summary-limit-include-matching-articles
7224 (regexp-quote (gnus-simplify-subject-re
7225 (mail-header-subject (gnus-id-to-header id)))))
7226 (gnus-summary-position-point))))
7228 (defun gnus-summary-limit-include-matching-articles (header regexp)
7229 "Display all the hidden articles that have HEADERs that match REGEXP."
7230 (interactive (list (read-string "Match on header: ")
7231 (read-string "Regexp: ")))
7232 (let ((articles (gnus-find-matching-articles header regexp)))
7234 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7235 (gnus-summary-position-point))))
7237 (defun gnus-summary-limit-include-dormant ()
7238 "Display all the hidden articles that are marked as dormant.
7239 Note that this command only works on a subset of the articles currently
7240 fetched for this group."
7242 (unless gnus-newsgroup-dormant
7243 (error "There are no dormant articles in this group"))
7245 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7246 (gnus-summary-position-point)))
7248 (defun gnus-summary-limit-exclude-dormant ()
7249 "Hide all dormant articles."
7252 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7253 (gnus-summary-position-point)))
7255 (defun gnus-summary-limit-exclude-childless-dormant ()
7256 "Hide all dormant articles that have no children."
7258 (let ((data (gnus-data-list t))
7259 articles d children)
7260 ;; Find all articles that are either not dormant or have
7262 (while (setq d (pop data))
7263 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7265 (gnus-article-children (gnus-data-number d)))
7268 (when (memq (car children) articles)
7273 (push (gnus-data-number d) articles)))
7276 (gnus-summary-limit articles)
7277 (gnus-summary-position-point))))
7279 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7280 "Mark all unread excluded articles as read.
7281 If ALL, mark even excluded ticked and dormants as read."
7283 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7284 (let ((articles (gnus-sorted-ndifference
7286 (mapcar (lambda (h) (mail-header-number h))
7287 gnus-newsgroup-headers)
7289 gnus-newsgroup-limit))
7291 (setq gnus-newsgroup-unreads
7292 (gnus-sorted-intersection gnus-newsgroup-unreads
7293 gnus-newsgroup-limit))
7295 (setq gnus-newsgroup-dormant nil
7296 gnus-newsgroup-marked nil
7297 gnus-newsgroup-reads
7299 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7300 gnus-newsgroup-reads))
7301 (while (setq article (pop articles))
7302 (unless (or (memq article gnus-newsgroup-dormant)
7303 (memq article gnus-newsgroup-marked))
7304 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7306 (defun gnus-summary-limit (articles &optional pop)
7308 ;; We pop the previous limit off the stack and use that.
7309 (setq articles (car gnus-newsgroup-limits)
7310 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7311 ;; We use the new limit, so we push the old limit on the stack.
7312 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7314 (setq gnus-newsgroup-limit articles)
7315 (let ((total (length gnus-newsgroup-data))
7316 (data (gnus-data-find-list (gnus-summary-article-number)))
7317 (gnus-summary-mark-below nil) ; Inhibit this.
7319 ;; This will do all the work of generating the new summary buffer
7320 ;; according to the new limit.
7321 (gnus-summary-prepare)
7322 ;; Hide any threads, possibly.
7323 (gnus-summary-maybe-hide-threads)
7324 ;; Try to return to the article you were at, or one in the
7327 ;; We try to find some article after the current one.
7329 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7332 (setq data (cdr data))))
7334 ;; If there is no data, that means that we were after the last
7335 ;; article. The same goes when we can't find any articles
7336 ;; after the current one.
7337 (goto-char (point-max))
7338 (gnus-summary-find-prev))
7339 (gnus-set-mode-line 'summary)
7340 ;; We return how many articles were removed from the summary
7341 ;; buffer as a result of the new limit.
7342 (- total (length gnus-newsgroup-data))))
7344 (defsubst gnus-invisible-cut-children (threads)
7347 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7352 (defsubst gnus-cut-thread (thread)
7353 "Go forwards in the thread until we find an article that we want to display."
7354 (when (or (eq gnus-fetch-old-headers 'some)
7355 (eq gnus-fetch-old-headers 'invisible)
7356 (numberp gnus-fetch-old-headers)
7357 (eq gnus-build-sparse-threads 'some)
7358 (eq gnus-build-sparse-threads 'more))
7359 ;; Deal with old-fetched headers and sparse threads.
7363 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7364 (gnus-summary-article-ancient-p
7365 (mail-header-number (car thread))))
7366 (if (or (<= (length (cdr thread)) 1)
7367 (eq gnus-fetch-old-headers 'invisible))
7368 (setq gnus-newsgroup-limit
7369 (delq (mail-header-number (car thread))
7370 gnus-newsgroup-limit)
7371 thread (cadr thread))
7372 (when (gnus-invisible-cut-children (cdr thread))
7373 (let ((th (cdr thread)))
7375 (if (memq (mail-header-number (caar th))
7376 gnus-newsgroup-limit)
7377 (setq thread (car th)
7379 (setq th (cdr th))))))))))
7382 (defun gnus-cut-threads (threads)
7383 "Cut off all uninteresting articles from the beginning of threads."
7384 (when (or (eq gnus-fetch-old-headers 'some)
7385 (eq gnus-fetch-old-headers 'invisible)
7386 (numberp gnus-fetch-old-headers)
7387 (eq gnus-build-sparse-threads 'some)
7388 (eq gnus-build-sparse-threads 'more))
7391 (setcar th (gnus-cut-thread (car th)))
7392 (setq th (cdr th)))))
7393 ;; Remove nixed out threads.
7396 (defun gnus-summary-initial-limit (&optional show-if-empty)
7397 "Figure out what the initial limit is supposed to be on group entry.
7398 This entails weeding out unwanted dormants, low-scored articles,
7399 fetch-old-headers verbiage, and so on."
7400 ;; Most groups have nothing to remove.
7401 (if (or gnus-inhibit-limiting
7402 (and (null gnus-newsgroup-dormant)
7403 (eq gnus-newsgroup-display 'gnus-not-ignore)
7404 (not (eq gnus-fetch-old-headers 'some))
7405 (not (numberp gnus-fetch-old-headers))
7406 (not (eq gnus-fetch-old-headers 'invisible))
7407 (null gnus-summary-expunge-below)
7408 (not (eq gnus-build-sparse-threads 'some))
7409 (not (eq gnus-build-sparse-threads 'more))
7410 (null gnus-thread-expunge-below)
7411 (not gnus-use-nocem)))
7413 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7414 (setq gnus-newsgroup-limit nil)
7417 (unless (car (symbol-value node))
7418 ;; These threads have no parents -- they are roots.
7419 (let ((nodes (cdr (symbol-value node)))
7422 (if (and gnus-thread-expunge-below
7423 (< (gnus-thread-total-score (car nodes))
7424 gnus-thread-expunge-below))
7425 (gnus-expunge-thread (pop nodes))
7426 (setq thread (pop nodes))
7427 (gnus-summary-limit-children thread))))))
7428 gnus-newsgroup-dependencies)
7429 ;; If this limitation resulted in an empty group, we might
7430 ;; pop the previous limit and use it instead.
7431 (when (and (not gnus-newsgroup-limit)
7433 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7434 gnus-newsgroup-limit))
7436 (defun gnus-summary-limit-children (thread)
7437 "Return 1 if this subthread is visible and 0 if it is not."
7438 ;; First we get the number of visible children to this thread. This
7439 ;; is done by recursing down the thread using this function, so this
7440 ;; will really go down to a leaf article first, before slowly
7441 ;; working its way up towards the root.
7445 (apply '+ (mapcar 'gnus-summary-limit-children
7448 (number (mail-header-number (car thread)))
7451 (not (memq number gnus-newsgroup-marked))
7453 ;; If this article is dormant and has absolutely no visible
7454 ;; children, then this article isn't visible.
7455 (and (memq number gnus-newsgroup-dormant)
7457 ;; If this is "fetch-old-headered" and there is no
7458 ;; visible children, then we don't want this article.
7459 (and (or (eq gnus-fetch-old-headers 'some)
7460 (numberp gnus-fetch-old-headers))
7461 (gnus-summary-article-ancient-p number)
7463 ;; If this is "fetch-old-headered" and `invisible', then
7464 ;; we don't want this article.
7465 (and (eq gnus-fetch-old-headers 'invisible)
7466 (gnus-summary-article-ancient-p number))
7467 ;; If this is a sparsely inserted article with no children,
7468 ;; we don't want it.
7469 (and (eq gnus-build-sparse-threads 'some)
7470 (gnus-summary-article-sparse-p number)
7472 ;; If we use expunging, and this article is really
7473 ;; low-scored, then we don't want this article.
7474 (when (and gnus-summary-expunge-below
7476 (or (cdr (assq number gnus-newsgroup-scored))
7477 gnus-summary-default-score))
7478 gnus-summary-expunge-below))
7479 ;; We increase the expunge-tally here, but that has
7480 ;; nothing to do with the limits, really.
7481 (incf gnus-newsgroup-expunged-tally)
7482 ;; We also mark as read here, if that's wanted.
7483 (when (and gnus-summary-mark-below
7484 (< score gnus-summary-mark-below))
7485 (setq gnus-newsgroup-unreads
7486 (delq number gnus-newsgroup-unreads))
7487 (if gnus-newsgroup-auto-expire
7488 (push number gnus-newsgroup-expirable)
7489 (push (cons number gnus-low-score-mark)
7490 gnus-newsgroup-reads)))
7492 ;; Do the `display' group parameter.
7493 (and gnus-newsgroup-display
7494 (not (funcall gnus-newsgroup-display)))
7495 ;; Check NoCeM things.
7496 (if (and gnus-use-nocem
7497 (gnus-nocem-unwanted-article-p
7498 (mail-header-id (car thread))))
7500 (setq gnus-newsgroup-unreads
7501 (delq number gnus-newsgroup-unreads))
7503 ;; Nope, invisible article.
7505 ;; Ok, this article is to be visible, so we add it to the limit
7507 (push number gnus-newsgroup-limit)
7510 (defun gnus-expunge-thread (thread)
7511 "Mark all articles in THREAD as read."
7512 (let* ((number (mail-header-number (car thread))))
7513 (incf gnus-newsgroup-expunged-tally)
7514 ;; We also mark as read here, if that's wanted.
7515 (setq gnus-newsgroup-unreads
7516 (delq number gnus-newsgroup-unreads))
7517 (if gnus-newsgroup-auto-expire
7518 (push number gnus-newsgroup-expirable)
7519 (push (cons number gnus-low-score-mark)
7520 gnus-newsgroup-reads)))
7521 ;; Go recursively through all subthreads.
7522 (mapcar 'gnus-expunge-thread (cdr thread)))
7524 ;; Summary article oriented commands
7526 (defun gnus-summary-refer-parent-article (n)
7527 "Refer parent article N times.
7528 If N is negative, go to ancestor -N instead.
7529 The difference between N and the number of articles fetched is returned."
7533 (when (not (natnump n))
7538 (setq header (gnus-summary-article-header))
7539 (if (and (eq (mail-header-number header)
7540 (cdr gnus-article-current))
7541 (equal gnus-newsgroup-name
7542 (car gnus-article-current)))
7543 ;; If we try to find the parent of the currently
7544 ;; displayed article, then we take a look at the actual
7545 ;; References header, since this is slightly more
7546 ;; reliable than the References field we got from the
7549 (set-buffer gnus-original-article-buffer)
7550 (nnheader-narrow-to-headers)
7551 (unless (setq ref (message-fetch-field "references"))
7552 (setq ref (message-fetch-field "in-reply-to")))
7555 ;; It's not the current article, so we take a bet on
7556 ;; the value we got from the server.
7557 (mail-header-references header)))
7559 (not (equal ref "")))
7560 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7561 (gnus-message 1 "Couldn't find parent"))
7562 (gnus-message 1 "No references in article %d"
7563 (gnus-summary-article-number))
7566 (gnus-summary-position-point)
7569 (defun gnus-summary-refer-references ()
7570 "Fetch all articles mentioned in the References header.
7571 Return the number of articles fetched."
7573 (let ((ref (mail-header-references (gnus-summary-article-header)))
7574 (current (gnus-summary-article-number))
7578 (error "No References in the current article")
7579 ;; For each Message-ID in the References header...
7580 (while (string-match "<[^>]*>" ref)
7582 ;; ... fetch that article.
7583 (gnus-summary-refer-article
7584 (prog1 (match-string 0 ref)
7585 (setq ref (substring ref (match-end 0))))))
7586 (gnus-summary-goto-subject current)
7587 (gnus-summary-position-point)
7590 (defun gnus-summary-refer-thread (&optional limit)
7591 "Fetch all articles in the current thread.
7592 If LIMIT (the numerical prefix), fetch that many old headers instead
7593 of what's specified by the `gnus-refer-thread-limit' variable."
7595 (let ((id (mail-header-id (gnus-summary-article-header)))
7596 (limit (if limit (prefix-numeric-value limit)
7597 gnus-refer-thread-limit)))
7598 ;; We want to fetch LIMIT *old* headers, but we also have to
7599 ;; re-fetch all the headers in the current buffer, because many of
7600 ;; them may be undisplayed. So we adjust LIMIT.
7601 (when (numberp limit)
7602 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7603 (unless (eq gnus-fetch-old-headers 'invisible)
7604 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7605 ;; Retrieve the headers and read them in.
7606 (if (eq (gnus-retrieve-headers
7607 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7609 (gnus-build-all-threads)
7610 (error "Can't fetch thread from backends that don't support NOV"))
7611 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7612 (gnus-summary-limit-include-thread id)))
7614 (defun gnus-summary-refer-article (message-id)
7615 "Fetch an article specified by MESSAGE-ID."
7616 (interactive "sMessage-ID: ")
7617 (when (and (stringp message-id)
7618 (not (zerop (length message-id))))
7619 ;; Construct the correct Message-ID if necessary.
7620 ;; Suggested by tale@pawl.rpi.edu.
7621 (unless (string-match "^<" message-id)
7622 (setq message-id (concat "<" message-id)))
7623 (unless (string-match ">$" message-id)
7624 (setq message-id (concat message-id ">")))
7625 (let* ((header (gnus-id-to-header message-id))
7627 (gnus-summary-article-sparse-p
7628 (mail-header-number header))
7629 (memq (mail-header-number header)
7630 gnus-newsgroup-limit)))
7633 ;; If the article is present in the buffer we just go to it.
7635 (or (not (gnus-summary-article-sparse-p
7636 (mail-header-number header)))
7639 (gnus-summary-goto-article
7640 (mail-header-number header) nil t)
7642 (gnus-summary-update-article (mail-header-number header)))))
7644 ;; We fetch the article.
7646 (dolist (gnus-override-method (gnus-refer-article-methods))
7647 (gnus-check-server gnus-override-method)
7648 ;; Fetch the header, and display the article.
7649 (when (setq number (gnus-summary-insert-subject message-id))
7650 (gnus-summary-select-article nil nil nil number)
7652 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7654 (defun gnus-refer-article-methods ()
7655 "Return a list of referrable methods."
7657 ;; No method, so we default to current and native.
7658 ((null gnus-refer-article-method)
7659 (list gnus-current-select-method gnus-select-method))
7661 ((eq 'current gnus-refer-article-method)
7662 (list gnus-current-select-method))
7663 ;; List of select methods.
7664 ((not (and (symbolp (car gnus-refer-article-method))
7665 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7667 (dolist (method gnus-refer-article-method)
7668 (push (if (eq 'current method)
7669 gnus-current-select-method
7673 ;; One single select method.
7675 (list gnus-refer-article-method))))
7677 (defun gnus-summary-edit-parameters ()
7678 "Edit the group parameters of the current group."
7680 (gnus-group-edit-group gnus-newsgroup-name 'params))
7682 (defun gnus-summary-customize-parameters ()
7683 "Customize the group parameters of the current group."
7685 (gnus-group-customize gnus-newsgroup-name))
7687 (defun gnus-summary-enter-digest-group (&optional force)
7688 "Enter an nndoc group based on the current article.
7689 If FORCE, force a digest interpretation. If not, try
7690 to guess what the document format is."
7692 (let ((conf gnus-current-window-configuration))
7694 (gnus-summary-select-article))
7695 (setq gnus-current-window-configuration conf)
7696 (let* ((name (format "%s-%d"
7697 (gnus-group-prefixed-name
7698 gnus-newsgroup-name (list 'nndoc ""))
7700 (set-buffer gnus-summary-buffer)
7701 gnus-current-article)))
7702 (ogroup gnus-newsgroup-name)
7703 (params (append (gnus-info-params (gnus-get-info ogroup))
7704 (list (cons 'to-group ogroup))
7705 (list (cons 'save-article-group ogroup))))
7706 (case-fold-search t)
7707 (buf (current-buffer))
7710 (set-buffer gnus-original-article-buffer)
7711 ;; Have the digest group inherit the main mail address of
7712 ;; the parent article.
7713 (when (setq to-address (or (message-fetch-field "reply-to")
7714 (message-fetch-field "from")))
7715 (setq params (append
7716 (list (cons 'to-address
7717 (funcall gnus-decode-encoded-word-function
7719 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7720 (insert-buffer-substring gnus-original-article-buffer)
7721 ;; Remove lines that may lead nndoc to misinterpret the
7724 (goto-char (point-min))
7725 (or (search-forward "\n\n" nil t) (point)))
7726 (goto-char (point-min))
7727 (delete-matching-lines "^Path:\\|^From ")
7730 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7731 (gnus-newsgroup-ephemeral-ignored-charsets
7732 gnus-newsgroup-ignored-charsets))
7733 (gnus-group-read-ephemeral-group
7734 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7736 ,(if force 'mbox 'guess)))
7738 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7740 ;; Make all postings to this group go to the parent group.
7741 (nconc (gnus-info-params (gnus-get-info name))
7743 ;; Couldn't select this doc group.
7744 (switch-to-buffer buf)
7745 (gnus-set-global-variables)
7746 (gnus-configure-windows 'summary)
7747 (gnus-message 3 "Article couldn't be entered?"))
7748 (kill-buffer dig)))))
7750 (defun gnus-summary-read-document (n)
7751 "Open a new group based on the current article(s).
7752 This will allow you to read digests and other similar
7753 documents as newsgroups.
7754 Obeys the standard process/prefix convention."
7756 (let* ((articles (gnus-summary-work-articles n))
7757 (ogroup gnus-newsgroup-name)
7758 (params (append (gnus-info-params (gnus-get-info ogroup))
7759 (list (cons 'to-group ogroup))))
7760 article group egroup groups vgroup)
7761 (while (setq article (pop articles))
7762 (setq group (format "%s-%d" gnus-newsgroup-name article))
7763 (gnus-summary-remove-process-mark article)
7764 (when (gnus-summary-display-article article)
7767 (insert-buffer-substring gnus-original-article-buffer)
7768 ;; Remove some headers that may lead nndoc to make
7770 (message-narrow-to-head)
7771 (goto-char (point-min))
7772 (delete-matching-lines "^\\(Path\\):\\|^From ")
7775 (gnus-group-read-ephemeral-group
7776 group `(nndoc ,group (nndoc-address ,(current-buffer))
7777 (nndoc-article-type guess))
7780 ;; Make all postings to this group go to the parent group.
7781 (nconc (gnus-info-params (gnus-get-info egroup))
7783 (push egroup groups))
7784 ;; Couldn't select this doc group.
7785 (gnus-error 3 "Article couldn't be entered"))))))
7786 ;; Now we have selected all the documents.
7789 (error "None of the articles could be interpreted as documents"))
7790 ((gnus-group-read-ephemeral-group
7791 (setq vgroup (format
7792 "nnvirtual:%s-%s" gnus-newsgroup-name
7793 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7794 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7796 (cons (current-buffer) 'summary)))
7798 (error "Couldn't select virtual nndoc group")))))
7800 (defun gnus-summary-isearch-article (&optional regexp-p)
7801 "Do incremental search forward on the current article.
7802 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7804 (gnus-summary-select-article)
7805 (gnus-configure-windows 'article)
7806 (gnus-eval-in-buffer-window gnus-article-buffer
7809 (isearch-forward regexp-p))))
7811 (defun gnus-summary-search-article-forward (regexp &optional backward)
7812 "Search for an article containing REGEXP forward.
7813 If BACKWARD, search backward instead."
7816 (format "Search article %s (regexp%s): "
7817 (if current-prefix-arg "backward" "forward")
7818 (if gnus-last-search-regexp
7819 (concat ", default " gnus-last-search-regexp)
7821 current-prefix-arg))
7822 (if (string-equal regexp "")
7823 (setq regexp (or gnus-last-search-regexp ""))
7824 (setq gnus-last-search-regexp regexp)
7825 (setq gnus-article-before-search gnus-current-article))
7826 ;; Intentionally set gnus-last-article.
7827 (setq gnus-last-article gnus-article-before-search)
7828 (let ((gnus-last-article gnus-last-article))
7829 (if (gnus-summary-search-article regexp backward)
7830 (gnus-summary-show-thread)
7831 (error "Search failed: \"%s\"" regexp))))
7833 (defun gnus-summary-search-article-backward (regexp)
7834 "Search for an article containing REGEXP backward."
7837 (format "Search article backward (regexp%s): "
7838 (if gnus-last-search-regexp
7839 (concat ", default " gnus-last-search-regexp)
7841 (gnus-summary-search-article-forward regexp 'backward))
7843 (defun gnus-summary-search-article (regexp &optional backward)
7844 "Search for an article containing REGEXP.
7845 Optional argument BACKWARD means do search for backward.
7846 `gnus-select-article-hook' is not called during the search."
7847 ;; We have to require this here to make sure that the following
7848 ;; dynamic binding isn't shadowed by autoloading.
7849 (require 'gnus-async)
7851 (let ((gnus-select-article-hook nil) ;Disable hook.
7852 (gnus-article-prepare-hook nil)
7853 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7854 (gnus-use-article-prefetch nil)
7855 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7856 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7857 (sum (current-buffer))
7858 (gnus-display-mime-function nil)
7861 (gnus-save-hidden-threads
7862 (gnus-summary-select-article)
7863 (set-buffer gnus-article-buffer)
7864 (goto-char (window-point (get-buffer-window (current-buffer))))
7868 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7870 (re-search-backward regexp nil t)
7871 (re-search-forward regexp nil t))
7872 ;; We found the regexp.
7877 (get-buffer-window (current-buffer))
7881 (get-buffer-window (current-buffer))
7884 (setq point (point)))
7885 ;; We didn't find it, so we go to the next article.
7888 (while (eq found 'not)
7889 (if (not (if backward (gnus-summary-find-prev)
7890 (gnus-summary-find-next)))
7891 ;; No more articles.
7893 ;; Select the next article and adjust point.
7894 (unless (gnus-summary-article-sparse-p
7895 (gnus-summary-article-number))
7897 (gnus-summary-select-article)
7898 (set-buffer gnus-article-buffer)
7900 (goto-char (if backward (point-max) (point-min))))))))
7901 (gnus-message 7 ""))
7902 ;; Return whether we found the regexp.
7903 (when (eq found 'found)
7905 (gnus-summary-show-thread)
7906 (gnus-summary-goto-subject gnus-current-article)
7907 (gnus-summary-position-point)
7910 (defun gnus-find-matching-articles (header regexp)
7911 "Return a list of all articles that match REGEXP on HEADER.
7912 This search includes all articles in the current group that Gnus has
7913 fetched headers for, whether they are displayed or not."
7914 (let ((articles nil)
7915 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7916 (case-fold-search t))
7917 (dolist (header gnus-newsgroup-headers)
7918 (when (string-match regexp (funcall func header))
7919 (push (mail-header-number header) articles)))
7920 (nreverse articles)))
7922 (defun gnus-summary-find-matching (header regexp &optional backward unread
7923 not-case-fold not-matching)
7924 "Return a list of all articles that match REGEXP on HEADER.
7925 The search stars on the current article and goes forwards unless
7926 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7927 If UNREAD is non-nil, only unread articles will
7928 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7929 in the comparisons. If NOT-MATCHING, return a list of all articles that
7930 not match REGEXP on HEADER."
7931 (let ((case-fold-search (not not-case-fold))
7934 (if (eq (car header) 'extra)
7937 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7939 (error "%s is an invalid header" header))
7940 (unless (fboundp (intern (concat "mail-header-" header)))
7941 (error "%s is not a valid header" header))
7942 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7943 (dolist (d (if (eq backward 'all)
7945 (gnus-data-find-list
7946 (gnus-summary-article-number)
7947 (gnus-data-list backward))))
7948 (when (and (or (not unread) ; We want all articles...
7949 (gnus-data-unread-p d)) ; Or just unreads.
7950 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7954 (funcall func (gnus-data-header d))))
7955 (string-match regexp
7956 (funcall func (gnus-data-header d)))))
7957 (push (gnus-data-number d) articles))) ; Success!
7958 (nreverse articles)))
7960 (defun gnus-summary-execute-command (header regexp command &optional backward)
7961 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7962 If HEADER is an empty string (or nil), the match is done on the entire
7963 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7965 (list (let ((completion-ignore-case t))
7968 (mapcar (lambda (header) (list (format "%s" header)))
7970 '("Number" "Subject" "From" "Lines" "Date"
7971 "Message-ID" "Xref" "References" "Body")
7972 gnus-extra-headers))
7973 nil 'require-match))
7974 (read-string "Regexp: ")
7975 (read-key-sequence "Command: ")
7976 current-prefix-arg))
7977 (when (equal header "Body")
7979 ;; Hidden thread subtrees must be searched as well.
7980 (gnus-summary-show-all-threads)
7981 ;; We don't want to change current point nor window configuration.
7983 (save-window-excursion
7984 (gnus-message 6 "Executing %s..." (key-description command))
7985 ;; We'd like to execute COMMAND interactively so as to give arguments.
7986 (gnus-execute header regexp
7987 `(call-interactively ',(key-binding command))
7989 (gnus-message 6 "Executing %s...done" (key-description command)))))
7991 (defun gnus-summary-beginning-of-article ()
7992 "Scroll the article back to the beginning."
7994 (gnus-summary-select-article)
7995 (gnus-configure-windows 'article)
7996 (gnus-eval-in-buffer-window gnus-article-buffer
7998 (goto-char (point-min))
7999 (when gnus-page-broken
8000 (gnus-narrow-to-page))))
8002 (defun gnus-summary-end-of-article ()
8003 "Scroll to the end of the article."
8005 (gnus-summary-select-article)
8006 (gnus-configure-windows 'article)
8007 (gnus-eval-in-buffer-window gnus-article-buffer
8009 (goto-char (point-max))
8011 (when gnus-page-broken
8012 (gnus-narrow-to-page))))
8014 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8015 "Truncate to LEN and quote all \"(\"'s in STRING."
8016 (gnus-replace-in-string (if (and len (> (length string) len))
8017 (substring string 0 len)
8021 (defun gnus-summary-print-article (&optional filename n)
8022 "Generate and print a PostScript image of the N next (mail) articles.
8024 If N is negative, print the N previous articles. If N is nil and articles
8025 have been marked with the process mark, print these instead.
8027 If the optional first argument FILENAME is nil, send the image to the
8028 printer. If FILENAME is a string, save the PostScript image in a file with
8029 that name. If FILENAME is a number, prompt the user for the name of the file
8031 (interactive (list (ps-print-preprint current-prefix-arg)))
8032 (dolist (article (gnus-summary-work-articles n))
8033 (gnus-summary-select-article nil nil 'pseudo article)
8034 (gnus-eval-in-buffer-window gnus-article-buffer
8035 (gnus-print-buffer))
8036 (gnus-summary-remove-process-mark article))
8037 (ps-despool filename))
8039 (defun gnus-print-buffer ()
8040 (let ((buffer (generate-new-buffer " *print*")))
8043 (copy-to-buffer buffer (point-min) (point-max))
8045 (gnus-article-delete-invisible-text)
8046 (when (gnus-visual-p 'article-highlight 'highlight)
8047 ;; Copy-to-buffer doesn't copy overlay. So redo
8049 (let ((gnus-article-buffer buffer))
8050 (gnus-article-highlight-citation t)
8051 (gnus-article-highlight-signature)))
8052 (let ((ps-left-header
8055 (gnus-summary-print-truncate-and-quote
8056 (mail-header-subject gnus-current-headers)
8059 (gnus-summary-print-truncate-and-quote
8060 (mail-header-from gnus-current-headers)
8064 "/pagenumberstring load"
8066 (mail-header-date gnus-current-headers) ")"))))
8067 (gnus-run-hooks 'gnus-ps-print-hook)
8070 (ps-spool-buffer-with-faces)
8071 (ps-spool-buffer)))))
8072 (kill-buffer buffer))))
8074 (defun gnus-summary-show-article (&optional arg)
8075 "Force redisplaying of the current article.
8076 If ARG (the prefix) is a number, show the article with the charset
8077 defined in `gnus-summary-show-article-charset-alist', or the charset
8079 If ARG (the prefix) is non-nil and not a number, show the raw article
8080 without any article massaging functions being run. Normally, the key strokes
8085 (gnus-summary-show-article t)
8086 (let ((gnus-newsgroup-charset
8087 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8088 (mm-read-coding-system
8089 "View as charset: " ;; actually it is coding system.
8091 (set-buffer gnus-article-buffer)
8092 (mm-detect-coding-region (point) (point-max))))))
8093 (gnus-newsgroup-ignored-charsets 'gnus-all))
8094 (gnus-summary-select-article nil 'force)
8095 (let ((deps gnus-newsgroup-dependencies)
8098 (set-buffer gnus-original-article-buffer)
8100 (message-narrow-to-head)
8101 (setq head (buffer-string))
8102 (goto-char (point-min))
8103 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8104 (goto-char (point-max))
8106 (setq lines (1- (count-lines (point) (point-max))))))
8108 (insert (format "211 %d Article retrieved.\n"
8109 (cdr gnus-article-current)))
8111 (if lines (insert (format "Lines: %d\n" lines)))
8113 (let ((nntp-server-buffer (current-buffer)))
8114 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8115 (gnus-data-set-header
8116 (gnus-data-find (cdr gnus-article-current))
8118 (gnus-summary-update-article-line
8119 (cdr gnus-article-current) header)
8120 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8121 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8123 ;; Select the article the normal way.
8124 (gnus-summary-select-article nil 'force))
8126 ;; We have to require this here to make sure that the following
8127 ;; dynamic binding isn't shadowed by autoloading.
8128 (require 'gnus-async)
8130 ;; Bind the article treatment functions to nil.
8131 (let ((gnus-have-all-headers t)
8132 gnus-article-prepare-hook
8133 gnus-article-decode-hook
8134 gnus-display-mime-function
8136 ;; Destroy any MIME parts.
8137 (when (gnus-buffer-live-p gnus-article-buffer)
8139 (set-buffer gnus-article-buffer)
8140 (mm-destroy-parts gnus-article-mime-handles)
8141 ;; Set it to nil for safety reason.
8142 (setq gnus-article-mime-handle-alist nil)
8143 (setq gnus-article-mime-handles nil)))
8144 (gnus-summary-select-article nil 'force))))
8145 (gnus-summary-goto-subject gnus-current-article)
8146 (gnus-summary-position-point))
8148 (defun gnus-summary-show-raw-article ()
8149 "Show the raw article without any article massaging functions being run."
8151 (gnus-summary-show-article t))
8153 (defun gnus-summary-verbose-headers (&optional arg)
8154 "Toggle permanent full header display.
8155 If ARG is a positive number, turn header display on.
8156 If ARG is a negative number, turn header display off."
8158 (setq gnus-show-all-headers
8159 (cond ((or (not (numberp arg))
8161 (not gnus-show-all-headers))
8164 (gnus-summary-show-article))
8166 (defun gnus-summary-toggle-header (&optional arg)
8167 "Show the headers if they are hidden, or hide them if they are shown.
8168 If ARG is a positive number, show the entire header.
8169 If ARG is a negative number, hide the unwanted header lines."
8172 (set-buffer gnus-article-buffer)
8174 (let* ((buffer-read-only nil)
8175 (inhibit-point-motion-hooks t)
8181 (article-narrow-to-head)
8182 (gnus-article-hidden-text-p 'headers))))
8183 (goto-char (point-min))
8184 (when (search-forward "\n\n" nil t)
8185 (delete-region (point-min) (1- (point))))
8186 (goto-char (point-min))
8188 (set-buffer gnus-original-article-buffer)
8189 (goto-char (point-min))
8190 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8191 (insert-buffer-substring gnus-original-article-buffer 1 e)
8193 (narrow-to-region (point-min) (point))
8194 (article-decode-encoded-words)
8196 (let ((gnus-treat-hide-headers nil)
8197 (gnus-treat-hide-boring-headers nil))
8198 (gnus-delete-wash-type 'headers)
8199 (gnus-treat-article 'head))
8200 (gnus-treat-article 'head)))
8201 (gnus-set-mode-line 'article)))))
8203 (defun gnus-summary-show-all-headers ()
8204 "Make all header lines visible."
8206 (gnus-summary-toggle-header 1))
8208 (defun gnus-summary-caesar-message (&optional arg)
8209 "Caesar rotate the current article by 13.
8210 The numerical prefix specifies how many places to rotate each letter
8213 (gnus-summary-select-article)
8214 (let ((mail-header-separator ""))
8215 (gnus-eval-in-buffer-window gnus-article-buffer
8218 (let ((start (window-start))
8220 (message-caesar-buffer-body arg)
8221 (set-window-start (get-buffer-window (current-buffer)) start))))))
8223 (defun gnus-summary-stop-page-breaking ()
8224 "Stop page breaking in the current article."
8226 (gnus-summary-select-article)
8227 (gnus-eval-in-buffer-window gnus-article-buffer
8229 (when (gnus-visual-p 'page-marker)
8230 (let ((buffer-read-only nil))
8231 (gnus-remove-text-with-property 'gnus-prev)
8232 (gnus-remove-text-with-property 'gnus-next))
8233 (setq gnus-page-broken nil))))
8235 (defun gnus-summary-move-article (&optional n to-newsgroup
8236 select-method action)
8237 "Move the current article to a different newsgroup.
8238 If N is a positive number, move the N next articles.
8239 If N is a negative number, move the N previous articles.
8240 If N is nil and any articles have been marked with the process mark,
8241 move those articles instead.
8242 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8243 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8244 re-spool using this method.
8246 For this function to work, both the current newsgroup and the
8247 newsgroup that you want to move to have to support the `request-move'
8248 and `request-accept' functions.
8250 ACTION can be either `move' (the default), `crosspost' or `copy'."
8253 (setq action 'move))
8254 ;; Check whether the source group supports the required functions.
8255 (cond ((and (eq action 'move)
8256 (not (gnus-check-backend-function
8257 'request-move-article gnus-newsgroup-name)))
8258 (error "The current group does not support article moving"))
8259 ((and (eq action 'crosspost)
8260 (not (gnus-check-backend-function
8261 'request-replace-article gnus-newsgroup-name)))
8262 (error "The current group does not support article editing")))
8263 (let ((articles (gnus-summary-work-articles n))
8264 (prefix (if (gnus-check-backend-function
8265 'request-move-article gnus-newsgroup-name)
8266 (gnus-group-real-prefix gnus-newsgroup-name)
8268 (names '((move "Move" "Moving")
8269 (copy "Copy" "Copying")
8270 (crosspost "Crosspost" "Crossposting")))
8271 (copy-buf (save-excursion
8272 (nnheader-set-temp-buffer " *copy article*")))
8273 art-group to-method new-xref article to-groups)
8274 (unless (assq action names)
8275 (error "Unknown action %s" action))
8276 ;; We have to select an article to give
8277 ;; `gnus-read-move-group-name' an opportunity to suggest an
8278 ;; appropriate default.
8279 (unless (gnus-buffer-live-p gnus-original-article-buffer)
8280 (let ((gnus-display-mime-function nil)
8281 (gnus-article-prepare-hook nil))
8282 (gnus-summary-select-article nil nil nil (car articles))))
8283 ;; Read the newsgroup name.
8284 (when (and (not to-newsgroup)
8285 (not select-method))
8287 (gnus-read-move-group-name
8288 (cadr (assq action names))
8289 (symbol-value (intern (format "gnus-current-%s-group" action)))
8291 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8292 (setq to-method (or select-method
8293 (gnus-server-to-method
8294 (gnus-group-method to-newsgroup))))
8295 ;; Check the method we are to move this article to...
8296 (unless (gnus-check-backend-function
8297 'request-accept-article (car to-method))
8298 (error "%s does not support article copying" (car to-method)))
8299 (unless (gnus-check-server to-method)
8300 (error "Can't open server %s" (car to-method)))
8301 (gnus-message 6 "%s to %s: %s..."
8302 (caddr (assq action names))
8303 (or (car select-method) to-newsgroup) articles)
8305 (setq article (pop articles))
8309 ;; Move the article.
8311 ;; Remove this article from future suppression.
8312 (gnus-dup-unsuppress-article article)
8313 (gnus-request-move-article
8314 article ; Article to move
8315 gnus-newsgroup-name ; From newsgroup
8316 (nth 1 (gnus-find-method-for-group
8317 gnus-newsgroup-name)) ; Server
8318 (list 'gnus-request-accept-article
8319 to-newsgroup (list 'quote select-method)
8320 (not articles) t) ; Accept form
8321 (not articles))) ; Only save nov last time
8322 ;; Copy the article.
8325 (set-buffer copy-buf)
8326 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8327 (gnus-request-accept-article
8328 to-newsgroup select-method (not articles) t))))
8329 ;; Crosspost the article.
8330 ((eq action 'crosspost)
8331 (let ((xref (message-tokenize-header
8332 (mail-header-xref (gnus-summary-article-header article))
8334 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8335 ":" (number-to-string article)))
8337 (setq xref (list (system-name))))
8340 (mapconcat 'identity
8341 (delete "Xref:" (delete new-xref xref))
8345 (set-buffer copy-buf)
8346 ;; First put the article in the destination group.
8347 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8348 (when (consp (setq art-group
8349 (gnus-request-accept-article
8350 to-newsgroup select-method (not articles))))
8351 (setq new-xref (concat new-xref " " (car art-group)
8353 (number-to-string (cdr art-group))))
8354 ;; Now we have the new Xrefs header, so we insert
8355 ;; it and replace the new article.
8356 (nnheader-replace-header "Xref" new-xref)
8357 (gnus-request-replace-article
8358 (cdr art-group) to-newsgroup (current-buffer))
8362 (gnus-message 1 "Couldn't %s article %s: %s"
8363 (cadr (assq action names)) article
8364 (nnheader-get-report (car to-method))))
8365 ((eq art-group 'junk)
8366 (when (eq action 'move)
8367 (gnus-summary-mark-article article gnus-canceled-mark)
8368 (gnus-message 4 "Deleted article %s" article)))
8370 (let* ((pto-group (gnus-group-prefixed-name
8371 (car art-group) to-method))
8373 (gnus-gethash pto-group gnus-newsrc-hashtb))
8374 (info (nth 2 entry))
8375 (to-group (gnus-info-group info))
8377 ;; Update the group that has been moved to.
8379 (memq action '(move copy)))
8380 (unless (member to-group to-groups)
8381 (push to-group to-groups))
8383 (unless (memq article gnus-newsgroup-unreads)
8384 (push 'read to-marks)
8386 info (gnus-add-to-range (gnus-info-read info)
8387 (list (cdr art-group)))))
8389 ;; See whether the article is to be put in the cache.
8390 (let ((marks gnus-article-mark-lists)
8391 (to-article (cdr art-group)))
8393 ;; Enter the article into the cache in the new group,
8394 ;; if that is required.
8395 (when gnus-use-cache
8396 (gnus-cache-possibly-enter-article
8398 (memq article gnus-newsgroup-marked)
8399 (memq article gnus-newsgroup-dormant)
8400 (memq article gnus-newsgroup-unreads)))
8402 (when gnus-preserve-marks
8403 ;; Copy any marks over to the new group.
8404 (when (and (equal to-group gnus-newsgroup-name)
8405 (not (memq article gnus-newsgroup-unreads)))
8406 ;; Mark this article as read in this group.
8407 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8408 (setcdr (gnus-active to-group) to-article)
8409 (setcdr gnus-newsgroup-active to-article))
8412 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8413 (when (memq article (symbol-value
8414 (intern (format "gnus-newsgroup-%s"
8416 (push (cdar marks) to-marks)
8417 ;; If the other group is the same as this group,
8418 ;; then we have to add the mark to the list.
8419 (when (equal to-group gnus-newsgroup-name)
8420 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8423 (intern (format "gnus-newsgroup-%s"
8425 ;; Copy the marks to other group.
8426 (gnus-add-marked-articles
8427 to-group (cdar marks) (list to-article) info)))
8428 (setq marks (cdr marks)))
8430 (gnus-request-set-mark to-group (list (list (list to-article)
8435 (concat "(gnus-group-set-info '"
8436 (gnus-prin1-to-string (gnus-get-info to-group))
8439 ;; Update the Xref header in this article to point to
8440 ;; the new crossposted article we have just created.
8441 (when (eq action 'crosspost)
8443 (set-buffer copy-buf)
8444 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8445 (nnheader-replace-header "Xref" new-xref)
8446 (gnus-request-replace-article
8447 article gnus-newsgroup-name (current-buffer)))))
8449 ;;;!!!Why is this necessary?
8450 (set-buffer gnus-summary-buffer)
8452 (gnus-summary-goto-subject article)
8453 (when (eq action 'move)
8454 (gnus-summary-mark-article article gnus-canceled-mark))))
8455 (gnus-summary-remove-process-mark article))
8456 ;; Re-activate all groups that have been moved to.
8458 (set-buffer gnus-group-buffer)
8459 (let ((gnus-group-marked to-groups))
8460 (gnus-group-get-new-news-this-group nil t)))
8462 (gnus-kill-buffer copy-buf)
8463 (gnus-summary-position-point)
8464 (gnus-set-mode-line 'summary)))
8466 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8467 "Move the current article to a different newsgroup.
8468 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8469 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8470 re-spool using this method."
8472 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8474 (defun gnus-summary-crosspost-article (&optional n)
8475 "Crosspost the current article to some other group."
8477 (gnus-summary-move-article n nil nil 'crosspost))
8479 (defcustom gnus-summary-respool-default-method nil
8480 "Default method type for respooling an article.
8481 If nil, use to the current newsgroup method."
8483 :group 'gnus-summary-mail)
8485 (defun gnus-summary-respool-article (&optional n method)
8486 "Respool the current article.
8487 The article will be squeezed through the mail spooling process again,
8488 which means that it will be put in some mail newsgroup or other
8489 depending on `nnmail-split-methods'.
8490 If N is a positive number, respool the N next articles.
8491 If N is a negative number, respool the N previous articles.
8492 If N is nil and any articles have been marked with the process mark,
8493 respool those articles instead.
8495 Respooling can be done both from mail groups and \"real\" newsgroups.
8496 In the former case, the articles in question will be moved from the
8497 current group into whatever groups they are destined to. In the
8498 latter case, they will be copied into the relevant groups."
8500 (list current-prefix-arg
8501 (let* ((methods (gnus-methods-using 'respool))
8503 (symbol-name (or gnus-summary-respool-default-method
8504 (car (gnus-find-method-for-group
8505 gnus-newsgroup-name)))))
8507 (gnus-completing-read-with-default
8508 methname "What backend do you want to use when respooling?"
8509 methods nil t nil 'gnus-mail-method-history))
8512 ((zerop (length (setq ms (gnus-servers-using-backend
8514 (list (intern method) ""))
8518 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8519 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8522 (error "No method given for respooling"))
8523 (if (assoc (symbol-name
8524 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8525 (gnus-methods-using 'respool))
8526 (gnus-summary-move-article n nil method)
8527 (gnus-summary-copy-article n nil method)))
8529 (defun gnus-summary-import-article (file &optional edit)
8530 "Import an arbitrary file into a mail newsgroup."
8531 (interactive "fImport file: \nP")
8532 (let ((group gnus-newsgroup-name)
8533 (now (current-time))
8534 atts lines group-art)
8535 (unless (gnus-check-backend-function 'request-accept-article group)
8536 (error "%s does not support article importing" group))
8537 (or (file-readable-p file)
8538 (not (file-regular-p file))
8539 (error "Can't read %s" file))
8541 (set-buffer (gnus-get-buffer-create " *import file*"))
8543 (nnheader-insert-file-contents file)
8544 (goto-char (point-min))
8545 (if (nnheader-article-p)
8547 (goto-char (point-min))
8548 (search-forward "\n\n" nil t)
8549 (narrow-to-region (point-min) (1- (point)))
8550 (goto-char (point-min))
8551 (unless (re-search-forward "^date:" nil t)
8552 (goto-char (point-max))
8553 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8554 ;; This doesn't look like an article, so we fudge some headers.
8555 (setq atts (file-attributes file)
8556 lines (count-lines (point-min) (point-max)))
8557 (insert "From: " (read-string "From: ") "\n"
8558 "Subject: " (read-string "Subject: ") "\n"
8559 "Date: " (message-make-date (nth 5 atts)) "\n"
8560 "Message-ID: " (message-make-message-id) "\n"
8561 "Lines: " (int-to-string lines) "\n"
8562 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8563 (setq group-art (gnus-request-accept-article group nil t))
8564 (kill-buffer (current-buffer)))
8565 (setq gnus-newsgroup-active (gnus-activate-group group))
8567 (gnus-summary-goto-article (cdr group-art) nil t)
8569 (gnus-summary-edit-article))))
8571 (defun gnus-summary-create-article ()
8572 "Create an article in a mail newsgroup."
8574 (let ((group gnus-newsgroup-name)
8575 (now (current-time))
8577 (unless (gnus-check-backend-function 'request-accept-article group)
8578 (error "%s does not support article importing" group))
8580 (set-buffer (gnus-get-buffer-create " *import file*"))
8582 (goto-char (point-min))
8583 ;; This doesn't look like an article, so we fudge some headers.
8584 (insert "From: " (read-string "From: ") "\n"
8585 "Subject: " (read-string "Subject: ") "\n"
8586 "Date: " (message-make-date now) "\n"
8587 "Message-ID: " (message-make-message-id) "\n")
8588 (setq group-art (gnus-request-accept-article group nil t))
8589 (kill-buffer (current-buffer)))
8590 (setq gnus-newsgroup-active (gnus-activate-group group))
8592 (gnus-summary-goto-article (cdr group-art) nil t)
8593 (gnus-summary-edit-article)))
8595 (defun gnus-summary-article-posted-p ()
8596 "Say whether the current (mail) article is available from news as well.
8597 This will be the case if the article has both been mailed and posted."
8599 (let ((id (mail-header-references (gnus-summary-article-header)))
8600 (gnus-override-method (car (gnus-refer-article-methods))))
8601 (if (gnus-request-head id "")
8602 (gnus-message 2 "The current message was found on %s"
8603 gnus-override-method)
8604 (gnus-message 2 "The current message couldn't be found on %s"
8605 gnus-override-method)
8608 (defun gnus-summary-expire-articles (&optional now)
8609 "Expire all articles that are marked as expirable in the current group."
8611 (when (gnus-check-backend-function
8612 'request-expire-articles gnus-newsgroup-name)
8613 ;; This backend supports expiry.
8614 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8615 (expirable (if total
8617 ;; We need to update the info for
8618 ;; this group for `gnus-list-of-read-articles'
8619 ;; to give us the right answer.
8620 (gnus-run-hooks 'gnus-exit-group-hook)
8621 (gnus-summary-update-info)
8622 (gnus-list-of-read-articles gnus-newsgroup-name))
8623 (setq gnus-newsgroup-expirable
8624 (sort gnus-newsgroup-expirable '<))))
8625 (expiry-wait (if now 'immediate
8626 (gnus-group-find-parameter
8627 gnus-newsgroup-name 'expiry-wait)))
8628 (nnmail-expiry-target
8629 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8630 nnmail-expiry-target))
8633 ;; There are expirable articles in this group, so we run them
8634 ;; through the expiry process.
8635 (gnus-message 6 "Expiring articles...")
8636 (unless (gnus-check-group gnus-newsgroup-name)
8637 (error "Can't open server for %s" gnus-newsgroup-name))
8638 ;; The list of articles that weren't expired is returned.
8641 (let ((nnmail-expiry-wait-function nil)
8642 (nnmail-expiry-wait expiry-wait))
8643 (setq es (gnus-request-expire-articles
8644 expirable gnus-newsgroup-name)))
8645 (setq es (gnus-request-expire-articles
8646 expirable gnus-newsgroup-name)))
8648 (setq gnus-newsgroup-expirable es))
8649 ;; We go through the old list of expirable, and mark all
8650 ;; really expired articles as nonexistent.
8651 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8652 (let ((gnus-use-cache nil))
8653 (dolist (article expirable)
8654 (when (and (not (memq article es))
8655 (gnus-data-find article))
8656 (gnus-summary-mark-article article gnus-canceled-mark))))))
8657 (gnus-message 6 "Expiring articles...done")))))
8659 (defun gnus-summary-expire-articles-now ()
8660 "Expunge all expirable articles in the current group.
8661 This means that *all* articles that are marked as expirable will be
8662 deleted forever, right now."
8664 (or gnus-expert-user
8666 "Are you really, really, really sure you want to delete all these messages? ")
8668 (gnus-summary-expire-articles t))
8670 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8671 (defun gnus-summary-delete-article (&optional n)
8672 "Delete the N next (mail) articles.
8673 This command actually deletes articles. This is not a marking
8674 command. The article will disappear forever from your life, never to
8676 If N is negative, delete backwards.
8677 If N is nil and articles have been marked with the process mark,
8678 delete these instead."
8680 (unless (gnus-check-backend-function 'request-expire-articles
8681 gnus-newsgroup-name)
8682 (error "The current newsgroup does not support article deletion"))
8683 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8684 (error "Couldn't open server"))
8685 ;; Compute the list of articles to delete.
8686 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8688 (if (and gnus-novice-user
8689 (not (gnus-yes-or-no-p
8690 (format "Do you really want to delete %s forever? "
8691 (if (> (length articles) 1)
8692 (format "these %s articles" (length articles))
8695 ;; Delete the articles.
8696 (setq not-deleted (gnus-request-expire-articles
8697 articles gnus-newsgroup-name 'force))
8699 (gnus-summary-remove-process-mark (car articles))
8700 ;; The backend might not have been able to delete the article
8702 (unless (memq (car articles) not-deleted)
8703 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8704 (setq articles (cdr articles)))
8706 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8707 (gnus-summary-position-point)
8708 (gnus-set-mode-line 'summary)
8711 (defun gnus-summary-edit-article (&optional arg)
8712 "Edit the current article.
8713 This will have permanent effect only in mail groups.
8714 If ARG is nil, edit the decoded articles.
8715 If ARG is 1, edit the raw articles.
8716 If ARG is 2, edit the raw articles even in read-only groups.
8717 If ARG is 3, edit the articles with the current handles.
8718 Otherwise, allow editing of articles even in read-only
8721 (let (force raw current-handles)
8730 (setq current-handles
8731 (and (gnus-buffer-live-p gnus-article-buffer)
8732 (with-current-buffer gnus-article-buffer
8734 gnus-article-mime-handles
8735 (setq gnus-article-mime-handles nil))))))
8738 (when (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8739 (error "Can't edit the raw article in group nndraft:drafts"))
8741 (set-buffer gnus-summary-buffer)
8742 (let ((mail-parse-charset gnus-newsgroup-charset)
8743 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8744 (gnus-set-global-variables)
8745 (when (and (not force)
8746 (gnus-group-read-only-p))
8747 (error "The current newsgroup does not support article editing"))
8748 (gnus-summary-show-article t)
8749 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8750 (with-current-buffer gnus-article-buffer
8751 (mm-enable-multibyte)))
8752 (if (equal gnus-newsgroup-name "nndraft:drafts")
8754 (gnus-article-edit-article
8757 (let ((mbl mml-buffer-list))
8758 (setq mml-buffer-list nil)
8759 (mime-to-mml ,'current-handles)
8760 (let ((mbl1 mml-buffer-list))
8761 (setq mml-buffer-list mbl)
8762 (set (make-local-variable 'mml-buffer-list) mbl1))
8763 (make-local-hook 'kill-buffer-hook)
8764 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8765 `(lambda (no-highlight)
8766 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8767 (message-options message-options)
8768 (message-options-set-recipient)
8769 (mail-parse-ignored-charsets
8770 ',gnus-newsgroup-ignored-charsets))
8771 ,(if (not raw) '(progn
8773 (mml-destroy-buffers)
8774 (remove-hook 'kill-buffer-hook
8775 'mml-destroy-buffers t)
8776 (kill-local-variable 'mml-buffer-list)))
8777 (gnus-summary-edit-article-done
8778 ,(or (mail-header-references gnus-current-headers) "")
8779 ,(gnus-group-read-only-p)
8780 ,gnus-summary-buffer no-highlight))))))))
8782 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8784 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8786 "Make edits to the current article permanent."
8789 ;; The buffer restriction contains the entire article if it exists.
8790 (when (article-goto-body)
8791 (let ((lines (count-lines (point) (point-max)))
8792 (length (- (point-max) (point)))
8793 (case-fold-search t)
8794 (body (copy-marker (point))))
8795 (goto-char (point-min))
8796 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8797 (delete-region (match-beginning 1) (match-end 1))
8798 (insert (number-to-string length)))
8799 (goto-char (point-min))
8800 (when (re-search-forward
8801 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8802 (delete-region (match-beginning 1) (match-end 1))
8803 (insert (number-to-string length)))
8804 (goto-char (point-min))
8805 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8806 (delete-region (match-beginning 1) (match-end 1))
8807 (insert (number-to-string lines))))))
8808 ;; Replace the article.
8809 (let ((buf (current-buffer)))
8811 (insert-buffer-substring buf)
8813 (if (and (not read-only)
8814 (not (gnus-request-replace-article
8815 (cdr gnus-article-current) (car gnus-article-current)
8816 (current-buffer) t)))
8817 (error "Couldn't replace article")
8818 ;; Update the summary buffer.
8820 (equal (message-tokenize-header references " ")
8821 (message-tokenize-header
8822 (or (message-fetch-field "references") "") " ")))
8823 ;; We only have to update this line.
8826 (message-narrow-to-head)
8827 (let ((head (buffer-string))
8830 (insert (format "211 %d Article retrieved.\n"
8831 (cdr gnus-article-current)))
8834 (let ((nntp-server-buffer (current-buffer)))
8835 (setq header (car (gnus-get-newsgroup-headers
8837 (set-buffer gnus-summary-buffer)
8838 gnus-newsgroup-dependencies)
8841 (set-buffer gnus-summary-buffer)
8842 (gnus-data-set-header
8843 (gnus-data-find (cdr gnus-article-current))
8845 (gnus-summary-update-article-line
8846 (cdr gnus-article-current) header)
8847 (if (gnus-summary-goto-subject
8848 (cdr gnus-article-current) nil t)
8849 (gnus-summary-update-secondary-mark
8850 (cdr gnus-article-current))))))))
8852 (set-buffer (or buffer gnus-summary-buffer))
8853 (gnus-summary-update-article (cdr gnus-article-current))
8854 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8855 (gnus-summary-update-secondary-mark
8856 (cdr gnus-article-current))))
8857 ;; Prettify the article buffer again.
8858 (unless no-highlight
8860 (set-buffer gnus-article-buffer)
8861 ;;;!!! Fix this -- article should be rehighlighted.
8862 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8863 (set-buffer gnus-original-article-buffer)
8864 (gnus-request-article
8865 (cdr gnus-article-current)
8866 (car gnus-article-current) (current-buffer))))
8867 ;; Prettify the summary buffer line.
8868 (when (gnus-visual-p 'summary-highlight 'highlight)
8869 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8871 (defun gnus-summary-edit-wash (key)
8872 "Perform editing command KEY in the article buffer."
8876 (message "%s" (concat (this-command-keys) "- "))
8879 (gnus-summary-edit-article)
8880 (execute-kbd-macro (concat (this-command-keys) key))
8881 (gnus-article-edit-done))
8885 (defun gnus-summary-respool-query (&optional silent trace)
8886 "Query where the respool algorithm would put this article."
8888 (let (gnus-mark-article-hook)
8889 (gnus-summary-select-article)
8891 (set-buffer gnus-original-article-buffer)
8893 (message-narrow-to-head)
8894 (let ((groups (nnmail-article-group 'identity trace)))
8897 (message "This message would go to %s"
8898 (mapconcat 'car groups ", "))
8899 (message "This message would go to no groups"))
8902 (defun gnus-summary-respool-trace ()
8903 "Trace where the respool algorithm would put this article.
8904 Display a buffer showing all fancy splitting patterns which matched."
8906 (gnus-summary-respool-query nil t))
8908 ;; Summary marking commands.
8910 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8911 "Mark articles which has the same subject as read, and then select the next.
8912 If UNMARK is positive, remove any kind of mark.
8913 If UNMARK is negative, tick articles."
8916 (setq unmark (prefix-numeric-value unmark)))
8918 (gnus-summary-mark-same-subject
8919 (gnus-summary-article-subject) unmark)))
8920 ;; Select next unread article. If auto-select-same mode, should
8921 ;; select the first unread article.
8922 (gnus-summary-next-article t (and gnus-auto-select-same
8923 (gnus-summary-article-subject)))
8924 (gnus-message 7 "%d article%s marked as %s"
8925 count (if (= count 1) " is" "s are")
8926 (if unmark "unread" "read"))))
8928 (defun gnus-summary-kill-same-subject (&optional unmark)
8929 "Mark articles which has the same subject as read.
8930 If UNMARK is positive, remove any kind of mark.
8931 If UNMARK is negative, tick articles."
8934 (setq unmark (prefix-numeric-value unmark)))
8936 (gnus-summary-mark-same-subject
8937 (gnus-summary-article-subject) unmark)))
8938 ;; If marked as read, go to next unread subject.
8940 ;; Go to next unread subject.
8941 (gnus-summary-next-subject 1 t))
8942 (gnus-message 7 "%d articles are marked as %s"
8943 count (if unmark "unread" "read"))))
8945 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8946 "Mark articles with same SUBJECT as read, and return marked number.
8947 If optional argument UNMARK is positive, remove any kinds of marks.
8948 If optional argument UNMARK is negative, mark articles as unread instead."
8952 ((null unmark) ; Mark as read.
8955 (gnus-summary-mark-article-as-read gnus-killed-mark)
8956 (gnus-summary-show-thread) t)
8957 (gnus-summary-find-subject subject))
8958 (setq count (1+ count))))
8959 ((> unmark 0) ; Tick.
8962 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8963 (gnus-summary-show-thread) t)
8964 (gnus-summary-find-subject subject))
8965 (setq count (1+ count))))
8966 (t ; Mark as unread.
8969 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8970 (gnus-summary-show-thread) t)
8971 (gnus-summary-find-subject subject))
8972 (setq count (1+ count)))))
8973 (gnus-set-mode-line 'summary)
8974 ;; Return the number of marked articles.
8977 (defun gnus-summary-mark-as-processable (n &optional unmark)
8978 "Set the process mark on the next N articles.
8979 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8980 the process mark instead. The difference between N and the actual
8981 number of articles marked is returned."
8983 (if (and (null n) (gnus-region-active-p))
8984 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8985 (setq n (prefix-numeric-value n))
8986 (let ((backward (< n 0))
8991 (gnus-summary-remove-process-mark
8992 (gnus-summary-article-number))
8993 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8994 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8997 (gnus-message 7 "No more articles"))
8998 (gnus-summary-recenter)
8999 (gnus-summary-position-point)
9002 (defun gnus-summary-unmark-as-processable (n)
9003 "Remove the process mark from the next N articles.
9004 If N is negative, unmark backward instead. The difference between N and
9005 the actual number of articles unmarked is returned."
9007 (gnus-summary-mark-as-processable n t))
9009 (defun gnus-summary-unmark-all-processable ()
9010 "Remove the process mark from all articles."
9013 (while gnus-newsgroup-processable
9014 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9015 (gnus-summary-position-point))
9017 (defun gnus-summary-add-mark (article type)
9018 "Mark ARTICLE with a mark of TYPE."
9019 (let ((vtype (car (assq type gnus-article-mark-lists)))
9022 (error "No such mark type: %s" type)
9023 (setq var (intern (format "gnus-newsgroup-%s" type)))
9024 (set var (cons article (symbol-value var)))
9025 (if (memq type '(processable cached replied forwarded recent saved))
9026 (gnus-summary-update-secondary-mark article)
9027 ;;; !!! This is bogus. We should find out what primary
9028 ;;; !!! mark we want to set.
9029 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9031 (defun gnus-summary-mark-as-expirable (n)
9032 "Mark N articles forward as expirable.
9033 If N is negative, mark backward instead. The difference between N and
9034 the actual number of articles marked is returned."
9036 (gnus-summary-mark-forward n gnus-expirable-mark))
9038 (defun gnus-summary-mark-article-as-replied (article)
9039 "Mark ARTICLE as replied to and update the summary line.
9040 ARTICLE can also be a list of articles."
9041 (interactive (list (gnus-summary-article-number)))
9042 (let ((articles (if (listp article) article (list article))))
9043 (dolist (article articles)
9044 (push article gnus-newsgroup-replied)
9045 (let ((buffer-read-only nil))
9046 (when (gnus-summary-goto-subject article nil t)
9047 (gnus-summary-update-secondary-mark article))))))
9049 (defun gnus-summary-mark-article-as-forwarded (article)
9050 "Mark ARTICLE as forwarded and update the summary line.
9051 ARTICLE can also be a list of articles."
9052 (let ((articles (if (listp article) article (list article))))
9053 (dolist (article articles)
9054 (push article gnus-newsgroup-forwarded)
9055 (let ((buffer-read-only nil))
9056 (when (gnus-summary-goto-subject article nil t)
9057 (gnus-summary-update-secondary-mark article))))))
9059 (defun gnus-summary-set-bookmark (article)
9060 "Set a bookmark in current article."
9061 (interactive (list (gnus-summary-article-number)))
9062 (when (or (not (get-buffer gnus-article-buffer))
9063 (not gnus-current-article)
9064 (not gnus-article-current)
9065 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9066 (error "No current article selected"))
9067 ;; Remove old bookmark, if one exists.
9068 (let ((old (assq article gnus-newsgroup-bookmarks)))
9070 (setq gnus-newsgroup-bookmarks
9071 (delq old gnus-newsgroup-bookmarks))))
9072 ;; Set the new bookmark, which is on the form
9073 ;; (article-number . line-number-in-body).
9077 (set-buffer gnus-article-buffer)
9081 (goto-char (point-min))
9082 (search-forward "\n\n" nil t)
9085 gnus-newsgroup-bookmarks)
9086 (gnus-message 6 "A bookmark has been added to the current article."))
9088 (defun gnus-summary-remove-bookmark (article)
9089 "Remove the bookmark from the current article."
9090 (interactive (list (gnus-summary-article-number)))
9091 ;; Remove old bookmark, if one exists.
9092 (let ((old (assq article gnus-newsgroup-bookmarks)))
9095 (setq gnus-newsgroup-bookmarks
9096 (delq old gnus-newsgroup-bookmarks))
9097 (gnus-message 6 "Removed bookmark."))
9098 (gnus-message 6 "No bookmark in current article."))))
9100 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9101 (defun gnus-summary-mark-as-dormant (n)
9102 "Mark N articles forward as dormant.
9103 If N is negative, mark backward instead. The difference between N and
9104 the actual number of articles marked is returned."
9106 (gnus-summary-mark-forward n gnus-dormant-mark))
9108 (defun gnus-summary-set-process-mark (article)
9109 "Set the process mark on ARTICLE and update the summary line."
9110 (setq gnus-newsgroup-processable
9112 (delq article gnus-newsgroup-processable)))
9113 (when (gnus-summary-goto-subject article)
9114 (gnus-summary-show-thread)
9115 (gnus-summary-goto-subject article)
9116 (gnus-summary-update-secondary-mark article)))
9118 (defun gnus-summary-remove-process-mark (article)
9119 "Remove the process mark from ARTICLE and update the summary line."
9120 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9121 (when (gnus-summary-goto-subject article)
9122 (gnus-summary-show-thread)
9123 (gnus-summary-goto-subject article)
9124 (gnus-summary-update-secondary-mark article)))
9126 (defun gnus-summary-set-saved-mark (article)
9127 "Set the process mark on ARTICLE and update the summary line."
9128 (push article gnus-newsgroup-saved)
9129 (when (gnus-summary-goto-subject article)
9130 (gnus-summary-update-secondary-mark article)))
9132 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9133 "Mark N articles as read forwards.
9134 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9135 The difference between N and the actual number of articles marked is
9137 Iff NO-EXPIRE, auto-expiry will be inhibited."
9139 (gnus-summary-show-thread)
9140 (let ((backward (< n 0))
9141 (gnus-summary-goto-unread
9142 (and gnus-summary-goto-unread
9143 (not (eq gnus-summary-goto-unread 'never))
9144 (not (memq mark (list gnus-unread-mark
9145 gnus-ticked-mark gnus-dormant-mark)))))
9147 (mark (or mark gnus-del-mark)))
9149 (gnus-summary-mark-article nil mark no-expire)
9150 (zerop (gnus-summary-next-subject
9152 (and gnus-summary-goto-unread
9153 (not (eq gnus-summary-goto-unread 'never)))
9157 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9158 (gnus-summary-recenter)
9159 (gnus-summary-position-point)
9160 (gnus-set-mode-line 'summary)
9163 (defun gnus-summary-mark-article-as-read (mark)
9164 "Mark the current article quickly as read with MARK."
9165 (let ((article (gnus-summary-article-number)))
9166 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9167 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9168 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9169 (push (cons article mark) gnus-newsgroup-reads)
9170 ;; Possibly remove from cache, if that is used.
9171 (when gnus-use-cache
9172 (gnus-cache-enter-remove-article article))
9173 ;; Allow the backend to change the mark.
9174 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9175 ;; Check for auto-expiry.
9176 (when (and gnus-newsgroup-auto-expire
9177 (memq mark gnus-auto-expirable-marks))
9178 (setq mark gnus-expirable-mark)
9179 ;; Let the backend know about the mark change.
9180 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9181 (push article gnus-newsgroup-expirable))
9182 ;; Set the mark in the buffer.
9183 (gnus-summary-update-mark mark 'unread)
9186 (defun gnus-summary-mark-article-as-unread (mark)
9187 "Mark the current article quickly as unread with MARK."
9188 (let* ((article (gnus-summary-article-number))
9189 (old-mark (gnus-summary-article-mark article)))
9190 ;; Allow the backend to change the mark.
9191 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9192 (if (eq mark old-mark)
9196 (gnus-error 1 "Can't mark negative article numbers")
9198 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9199 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9200 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9201 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9202 (cond ((= mark gnus-ticked-mark)
9203 (setq gnus-newsgroup-marked
9204 (gnus-add-to-sorted-list gnus-newsgroup-marked
9206 ((= mark gnus-dormant-mark)
9207 (setq gnus-newsgroup-dormant
9208 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9211 (setq gnus-newsgroup-unreads
9212 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9214 (gnus-pull article gnus-newsgroup-reads)
9216 ;; See whether the article is to be put in the cache.
9218 (vectorp (gnus-summary-article-header article))
9220 (gnus-cache-possibly-enter-article
9221 gnus-newsgroup-name article
9222 (= mark gnus-ticked-mark)
9223 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9226 (gnus-summary-update-mark mark 'unread)
9229 (defun gnus-summary-mark-article (&optional article mark no-expire)
9230 "Mark ARTICLE with MARK. MARK can be any character.
9231 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9232 `??' (dormant) and `?E' (expirable).
9233 If MARK is nil, then the default character `?r' is used.
9234 If ARTICLE is nil, then the article on the current line will be
9236 Iff NO-EXPIRE, auto-expiry will be inhibited."
9237 ;; The mark might be a string.
9238 (when (stringp mark)
9239 (setq mark (aref mark 0)))
9240 ;; If no mark is given, then we check auto-expiring.
9242 (setq mark gnus-del-mark))
9243 (when (and (not no-expire)
9244 gnus-newsgroup-auto-expire
9245 (memq mark gnus-auto-expirable-marks))
9246 (setq mark gnus-expirable-mark))
9247 (let ((article (or article (gnus-summary-article-number)))
9248 (old-mark (gnus-summary-article-mark article)))
9249 ;; Allow the backend to change the mark.
9250 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9251 (if (eq mark old-mark)
9254 (error "No article on current line"))
9255 (if (not (if (or (= mark gnus-unread-mark)
9256 (= mark gnus-ticked-mark)
9257 (= mark gnus-dormant-mark))
9258 (gnus-mark-article-as-unread article mark)
9259 (gnus-mark-article-as-read article mark)))
9261 ;; See whether the article is to be put in the cache.
9263 (not (= mark gnus-canceled-mark))
9264 (vectorp (gnus-summary-article-header article))
9266 (gnus-cache-possibly-enter-article
9267 gnus-newsgroup-name article
9268 (= mark gnus-ticked-mark)
9269 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9271 (when (gnus-summary-goto-subject article nil t)
9272 (let ((buffer-read-only nil))
9273 (gnus-summary-show-thread)
9275 (gnus-summary-update-mark mark 'unread)
9278 (defun gnus-summary-update-secondary-mark (article)
9279 "Update the secondary (read, process, cache) mark."
9280 (gnus-summary-update-mark
9281 (cond ((memq article gnus-newsgroup-processable)
9283 ((memq article gnus-newsgroup-cached)
9285 ((memq article gnus-newsgroup-replied)
9287 ((memq article gnus-newsgroup-forwarded)
9288 gnus-forwarded-mark)
9289 ((memq article gnus-newsgroup-saved)
9291 ((memq article gnus-newsgroup-recent)
9293 ((memq article gnus-newsgroup-unseen)
9297 (when (gnus-visual-p 'summary-highlight 'highlight)
9298 (gnus-run-hooks 'gnus-summary-update-hook))
9301 (defun gnus-summary-update-mark (mark type)
9302 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9303 (buffer-read-only nil))
9304 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9306 (when (looking-at "\r")
9308 (when (<= (+ forward (point)) (point-max))
9309 ;; Go to the right position on the line.
9310 (goto-char (+ forward (point)))
9311 ;; Replace the old mark with the new mark.
9312 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9313 ;; Optionally update the marks by some user rule.
9314 (when (eq type 'unread)
9316 (gnus-data-find (gnus-summary-article-number)) mark)
9317 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9319 (defun gnus-mark-article-as-read (article &optional mark)
9320 "Enter ARTICLE in the pertinent lists and remove it from others."
9321 ;; Make the article expirable.
9322 (let ((mark (or mark gnus-del-mark)))
9323 (setq gnus-newsgroup-expirable
9324 (if (= mark gnus-expirable-mark)
9325 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9326 (delq article gnus-newsgroup-expirable)))
9327 ;; Remove from unread and marked lists.
9328 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9329 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9330 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9331 (push (cons article mark) gnus-newsgroup-reads)
9332 ;; Possibly remove from cache, if that is used.
9333 (when gnus-use-cache
9334 (gnus-cache-enter-remove-article article))
9337 (defun gnus-mark-article-as-unread (article &optional mark)
9338 "Enter ARTICLE in the pertinent lists and remove it from others."
9339 (let ((mark (or mark gnus-ticked-mark)))
9342 (gnus-error 1 "Can't mark negative article numbers")
9344 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9345 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9346 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9347 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9349 ;; Unsuppress duplicates?
9350 (when gnus-suppress-duplicates
9351 (gnus-dup-unsuppress-article article))
9353 (cond ((= mark gnus-ticked-mark)
9354 (setq gnus-newsgroup-marked
9355 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9356 ((= mark gnus-dormant-mark)
9357 (setq gnus-newsgroup-dormant
9358 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9360 (setq gnus-newsgroup-unreads
9361 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9362 (gnus-pull article gnus-newsgroup-reads)
9365 (defalias 'gnus-summary-mark-as-unread-forward
9366 'gnus-summary-tick-article-forward)
9367 (make-obsolete 'gnus-summary-mark-as-unread-forward
9368 'gnus-summary-tick-article-forward)
9369 (defun gnus-summary-tick-article-forward (n)
9370 "Tick N articles forwards.
9371 If N is negative, tick backwards instead.
9372 The difference between N and the number of articles ticked is returned."
9374 (gnus-summary-mark-forward n gnus-ticked-mark))
9376 (defalias 'gnus-summary-mark-as-unread-backward
9377 'gnus-summary-tick-article-backward)
9378 (make-obsolete 'gnus-summary-mark-as-unread-backward
9379 'gnus-summary-tick-article-backward)
9380 (defun gnus-summary-tick-article-backward (n)
9381 "Tick N articles backwards.
9382 The difference between N and the number of articles ticked is returned."
9384 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9386 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9387 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9388 (defun gnus-summary-tick-article (&optional article clear-mark)
9389 "Mark current article as unread.
9390 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9391 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9393 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9396 (defun gnus-summary-mark-as-read-forward (n)
9397 "Mark N articles as read forwards.
9398 If N is negative, mark backwards instead.
9399 The difference between N and the actual number of articles marked is
9402 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9404 (defun gnus-summary-mark-as-read-backward (n)
9405 "Mark the N articles as read backwards.
9406 The difference between N and the actual number of articles marked is
9409 (gnus-summary-mark-forward
9410 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9412 (defun gnus-summary-mark-as-read (&optional article mark)
9413 "Mark current article as read.
9414 ARTICLE specifies the article to be marked as read.
9415 MARK specifies a string to be inserted at the beginning of the line."
9416 (gnus-summary-mark-article article mark))
9418 (defun gnus-summary-clear-mark-forward (n)
9419 "Clear marks from N articles forward.
9420 If N is negative, clear backward instead.
9421 The difference between N and the number of marks cleared is returned."
9423 (gnus-summary-mark-forward n gnus-unread-mark))
9425 (defun gnus-summary-clear-mark-backward (n)
9426 "Clear marks from N articles backward.
9427 The difference between N and the number of marks cleared is returned."
9429 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9431 (defun gnus-summary-mark-unread-as-read ()
9432 "Intended to be used by `gnus-summary-mark-article-hook'."
9433 (when (memq gnus-current-article gnus-newsgroup-unreads)
9434 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9436 (defun gnus-summary-mark-read-and-unread-as-read ()
9437 "Intended to be used by `gnus-summary-mark-article-hook'."
9438 (let ((mark (gnus-summary-article-mark)))
9439 (when (or (gnus-unread-mark-p mark)
9440 (gnus-read-mark-p mark))
9441 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9443 (defun gnus-summary-mark-unread-as-ticked ()
9444 "Intended to be used by `gnus-summary-mark-article-hook'."
9445 (when (memq gnus-current-article gnus-newsgroup-unreads)
9446 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9448 (defun gnus-summary-mark-region-as-read (point mark all)
9449 "Mark all unread articles between point and mark as read.
9450 If given a prefix, mark all articles between point and mark as read,
9451 even ticked and dormant ones."
9452 (interactive "r\nP")
9461 (memq (setq article (gnus-summary-article-number))
9462 gnus-newsgroup-unreads))
9463 (gnus-summary-mark-article article gnus-del-mark))
9465 (gnus-summary-find-next))))))
9467 (defun gnus-summary-mark-below (score mark)
9468 "Mark articles with score less than SCORE with MARK."
9469 (interactive "P\ncMark: ")
9470 (setq score (if score
9471 (prefix-numeric-value score)
9472 (or gnus-summary-default-score 0)))
9474 (set-buffer gnus-summary-buffer)
9475 (goto-char (point-min))
9478 (and (< (gnus-summary-article-score) score)
9479 (gnus-summary-mark-article nil mark))
9480 (gnus-summary-find-next)))))
9482 (defun gnus-summary-kill-below (&optional score)
9483 "Mark articles with score below SCORE as read."
9485 (gnus-summary-mark-below score gnus-killed-mark))
9487 (defun gnus-summary-clear-above (&optional score)
9488 "Clear all marks from articles with score above SCORE."
9490 (gnus-summary-mark-above score gnus-unread-mark))
9492 (defun gnus-summary-tick-above (&optional score)
9493 "Tick all articles with score above SCORE."
9495 (gnus-summary-mark-above score gnus-ticked-mark))
9497 (defun gnus-summary-mark-above (score mark)
9498 "Mark articles with score over SCORE with MARK."
9499 (interactive "P\ncMark: ")
9500 (setq score (if score
9501 (prefix-numeric-value score)
9502 (or gnus-summary-default-score 0)))
9504 (set-buffer gnus-summary-buffer)
9505 (goto-char (point-min))
9507 (when (> (gnus-summary-article-score) score)
9508 (gnus-summary-mark-article nil mark))
9510 (gnus-summary-find-next)))))
9512 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9513 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9514 (defun gnus-summary-limit-include-expunged (&optional no-error)
9515 "Display all the hidden articles that were expunged for low scores."
9517 (let ((buffer-read-only nil))
9518 (let ((scored gnus-newsgroup-scored)
9521 (unless (gnus-summary-article-header (caar scored))
9522 (and (setq h (gnus-number-to-header (caar scored)))
9523 (< (cdar scored) gnus-summary-expunge-below)
9525 (setq scored (cdr scored)))
9527 (when (not no-error)
9528 (error "No expunged articles hidden"))
9529 (goto-char (point-min))
9530 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9531 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9532 (mapcar (lambda (x) (push (mail-header-number x)
9533 gnus-newsgroup-limit))
9535 (gnus-summary-prepare-unthreaded (nreverse headers))
9536 (goto-char (point-min))
9537 (gnus-summary-position-point)
9540 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9541 "Mark all unread articles in this newsgroup as read.
9542 If prefix argument ALL is non-nil, ticked and dormant articles will
9543 also be marked as read.
9544 If QUIETLY is non-nil, no questions will be asked.
9545 If TO-HERE is non-nil, it should be a point in the buffer. All
9546 articles before (after, if REVERSE is set) this point will be marked as read.
9547 Note that this function will only catch up the unread article
9548 in the current summary buffer limitation.
9549 The number of articles marked as read is returned."
9554 (not gnus-interactive-catchup) ;Without confirmation?
9558 "Mark absolutely all articles as read? "
9559 "Mark all unread articles as read? ")))
9561 (not gnus-newsgroup-adaptive)
9562 (not gnus-newsgroup-auto-expire)
9563 (not gnus-suppress-duplicates)
9564 (or (not gnus-use-cache)
9565 (eq gnus-use-cache 'passive)))
9568 (setq gnus-newsgroup-marked nil
9569 gnus-newsgroup-dormant nil))
9570 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9571 ;; We actually mark all articles as canceled, which we
9572 ;; have to do when using auto-expiry or adaptive scoring.
9573 (gnus-summary-show-all-threads)
9574 (if (and to-here reverse)
9578 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9579 (gnus-summary-find-next (not all) nil nil t))))
9580 (when (gnus-summary-first-subject (not all) t)
9582 (if to-here (< (point) to-here) t)
9583 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9584 (gnus-summary-find-next (not all) nil nil t)))))
9585 (gnus-set-mode-line 'summary))
9587 (gnus-summary-position-point)))
9589 (defun gnus-summary-catchup-to-here (&optional all)
9590 "Mark all unticked articles before the current one as read.
9591 If ALL is non-nil, also mark ticked and dormant articles as read."
9594 (gnus-save-hidden-threads
9595 (let ((beg (point)))
9596 ;; We check that there are unread articles.
9597 (when (or all (gnus-summary-find-prev))
9598 (gnus-summary-catchup all t beg)))))
9599 (gnus-summary-position-point))
9601 (defun gnus-summary-catchup-from-here (&optional all)
9602 "Mark all unticked articles after the current one as read.
9603 If ALL is non-nil, also mark ticked and dormant articles as read."
9606 (gnus-save-hidden-threads
9607 (let ((beg (point)))
9608 ;; We check that there are unread articles.
9609 (when (or all (gnus-summary-find-next))
9610 (gnus-summary-catchup all t beg nil t)))))
9612 (gnus-summary-position-point))
9613 (defun gnus-summary-catchup-all (&optional quietly)
9614 "Mark all articles in this newsgroup as read."
9616 (gnus-summary-catchup t quietly))
9618 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9619 "Mark all unread articles in this group as read, then exit.
9620 If prefix argument ALL is non-nil, all articles are marked as read.
9621 If QUIETLY is non-nil, no questions will be asked."
9623 (when (gnus-summary-catchup all quietly nil 'fast)
9624 ;; Select next newsgroup or exit.
9625 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9626 (eq gnus-auto-select-next 'quietly))
9627 (gnus-summary-next-group nil)
9628 (gnus-summary-exit))))
9630 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9631 "Mark all articles in this newsgroup as read, and then exit."
9633 (gnus-summary-catchup-and-exit t quietly))
9635 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9636 "Mark all articles in this group as read and select the next group.
9637 If given a prefix, mark all articles, unread as well as ticked, as
9641 (gnus-summary-catchup all))
9642 (gnus-summary-next-group))
9648 (defmacro gnus-with-article (article &rest forms)
9649 "Select ARTICLE and perform FORMS in the original article buffer.
9650 Then replace the article with the result."
9652 ;; We don't want the article to be marked as read.
9653 (let (gnus-mark-article-hook)
9654 (gnus-summary-select-article t t nil ,article))
9655 (set-buffer gnus-original-article-buffer)
9657 (if (not (gnus-check-backend-function
9658 'request-replace-article (car gnus-article-current)))
9659 (gnus-message 5 "Read-only group; not replacing")
9660 (unless (gnus-request-replace-article
9661 ,article (car gnus-article-current)
9663 (error "Couldn't replace article")))
9664 ;; The cache and backlog have to be flushed somewhat.
9665 (when gnus-keep-backlog
9666 (gnus-backlog-remove-article
9667 (car gnus-article-current) (cdr gnus-article-current)))
9668 (when gnus-use-cache
9669 (gnus-cache-update-article
9670 (car gnus-article-current) (cdr gnus-article-current)))))
9672 (put 'gnus-with-article 'lisp-indent-function 1)
9673 (put 'gnus-with-article 'edebug-form-spec '(form body))
9675 ;; Thread-based commands.
9677 (defun gnus-summary-articles-in-thread (&optional article)
9678 "Return a list of all articles in the current thread.
9679 If ARTICLE is non-nil, return all articles in the thread that starts
9681 (let* ((article (or article (gnus-summary-article-number)))
9682 (data (gnus-data-find-list article))
9683 (top-level (gnus-data-level (car data)))
9685 (cond ((null gnus-thread-operation-ignore-subject)
9686 (gnus-simplify-subject-re
9687 (mail-header-subject (gnus-data-header (car data)))))
9688 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9689 (gnus-simplify-subject-fuzzy
9690 (mail-header-subject (gnus-data-header (car data)))))
9692 (end-point (save-excursion
9693 (if (gnus-summary-go-to-next-thread)
9694 (point) (point-max))))
9697 (< (gnus-data-pos (car data)) end-point))
9698 (when (or (not top-subject)
9699 (string= top-subject
9700 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9701 (gnus-simplify-subject-fuzzy
9702 (mail-header-subject
9703 (gnus-data-header (car data))))
9704 (gnus-simplify-subject-re
9705 (mail-header-subject
9706 (gnus-data-header (car data)))))))
9707 (push (gnus-data-number (car data)) articles))
9708 (unless (and (setq data (cdr data))
9709 (> (gnus-data-level (car data)) top-level))
9711 ;; Return the list of articles.
9712 (nreverse articles)))
9714 (defun gnus-summary-rethread-current ()
9715 "Rethread the thread the current article is part of."
9717 (let* ((gnus-show-threads t)
9718 (article (gnus-summary-article-number))
9719 (id (mail-header-id (gnus-summary-article-header)))
9720 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9722 (error "No article on the current line"))
9723 (gnus-rebuild-thread id)
9724 (gnus-summary-goto-subject article)))
9726 (defun gnus-summary-reparent-thread ()
9727 "Make the current article child of the marked (or previous) article.
9729 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9730 is non-nil or the Subject: of both articles are the same."
9732 (unless (not (gnus-group-read-only-p))
9733 (error "The current newsgroup does not support article editing"))
9734 (unless (<= (length gnus-newsgroup-processable) 1)
9735 (error "No more than one article may be marked"))
9736 (save-window-excursion
9737 (let ((gnus-article-buffer " *reparent*")
9738 (current-article (gnus-summary-article-number))
9739 ;; First grab the marked article, otherwise one line up.
9740 (parent-article (if (not (null gnus-newsgroup-processable))
9741 (car gnus-newsgroup-processable)
9743 (if (eq (forward-line -1) 0)
9744 (gnus-summary-article-number)
9745 (error "Beginning of summary buffer"))))))
9746 (unless (not (eq current-article parent-article))
9747 (error "An article may not be self-referential"))
9748 (let ((message-id (mail-header-id
9749 (gnus-summary-article-header parent-article))))
9750 (unless (and message-id (not (equal message-id "")))
9751 (error "No message-id in desired parent"))
9752 (gnus-with-article current-article
9754 (goto-char (point-min))
9755 (message-narrow-to-head)
9756 (if (re-search-forward "^References: " nil t)
9758 (re-search-forward "^[^ \t]" nil t)
9761 (insert " " message-id))
9762 (insert "References: " message-id "\n"))))
9763 (set-buffer gnus-summary-buffer)
9764 (gnus-summary-unmark-all-processable)
9765 (gnus-summary-update-article current-article)
9766 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9767 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9768 (gnus-summary-rethread-current)
9769 (gnus-message 3 "Article %d is now the child of article %d"
9770 current-article parent-article)))))
9772 (defun gnus-summary-toggle-threads (&optional arg)
9773 "Toggle showing conversation threads.
9774 If ARG is positive number, turn showing conversation threads on."
9776 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9777 (setq gnus-show-threads
9778 (if (null arg) (not gnus-show-threads)
9779 (> (prefix-numeric-value arg) 0)))
9780 (gnus-summary-prepare)
9781 (gnus-summary-goto-subject current)
9782 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9783 (gnus-summary-position-point)))
9785 (defun gnus-summary-show-all-threads ()
9789 (let ((buffer-read-only nil))
9790 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9791 (gnus-summary-position-point))
9793 (defun gnus-summary-show-thread ()
9794 "Show thread subtrees.
9795 Returns nil if no thread was there to be shown."
9797 (let ((buffer-read-only nil)
9799 ;; first goto end then to beg, to have point at beg after let
9800 (end (progn (end-of-line) (point)))
9801 (beg (progn (beginning-of-line) (point))))
9803 ;; Any hidden lines here?
9804 (search-forward "\r" end t)
9805 (subst-char-in-region beg end ?\^M ?\n t)
9807 (gnus-summary-position-point))))
9809 (defun gnus-summary-maybe-hide-threads ()
9810 "If requested, hide the threads that should be hidden."
9811 (when (and gnus-show-threads
9812 gnus-thread-hide-subtree)
9813 (gnus-summary-hide-all-threads
9814 (if (or (consp gnus-thread-hide-subtree)
9815 (gnus-functionp gnus-thread-hide-subtree))
9816 (gnus-make-predicate gnus-thread-hide-subtree)
9819 ;;; Hiding predicates.
9821 (defun gnus-article-unread-p (header)
9822 (memq (mail-header-number header) gnus-newsgroup-unreads))
9824 (defun gnus-article-unseen-p (header)
9825 (memq (mail-header-number header) gnus-newsgroup-unseen))
9827 (defun gnus-map-articles (predicate articles)
9828 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
9829 (apply 'gnus-or (mapcar predicate
9830 (mapcar 'gnus-summary-article-header articles))))
9832 (defun gnus-summary-hide-all-threads (&optional predicate)
9833 "Hide all thread subtrees.
9834 If PREDICATE is supplied, threads that satisfy this predicate
9835 will not be hidden."
9838 (goto-char (point-min))
9841 (when (or (not predicate)
9843 predicate (gnus-summary-article-children)))
9844 (gnus-summary-hide-thread))
9845 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
9846 (gnus-summary-position-point))
9848 (defun gnus-summary-hide-thread ()
9849 "Hide thread subtrees.
9850 If PREDICATE is supplied, threads that satisfy this predicate
9852 Returns nil if no threads were there to be hidden."
9854 (let ((buffer-read-only nil)
9856 (article (gnus-summary-article-number)))
9858 ;; Go forward until either the buffer ends or the subthread
9860 (when (and (not (eobp))
9861 (or (zerop (gnus-summary-next-thread 1 t))
9862 (goto-char (point-max))))
9864 (if (and (> (point) start)
9865 (search-backward "\n" start t))
9867 (subst-char-in-region start (point) ?\n ?\^M)
9868 (gnus-summary-goto-subject article))
9872 (defun gnus-summary-go-to-next-thread (&optional previous)
9873 "Go to the same level (or less) next thread.
9874 If PREVIOUS is non-nil, go to previous thread instead.
9875 Return the article number moved to, or nil if moving was impossible."
9876 (let ((level (gnus-summary-thread-level))
9877 (way (if previous -1 1))
9880 (while (and (not (eobp))
9881 (< level (gnus-summary-thread-level)))
9889 (gnus-summary-article-number)
9892 (defun gnus-summary-next-thread (n &optional silent)
9893 "Go to the same level next N'th thread.
9894 If N is negative, search backward instead.
9895 Returns the difference between N and the number of skips actually
9898 If SILENT, don't output messages."
9900 (let ((backward (< n 0))
9903 (gnus-summary-go-to-next-thread backward))
9906 (gnus-summary-position-point))
9907 (when (and (not silent) (/= 0 n))
9908 (gnus-message 7 "No more threads"))
9911 (defun gnus-summary-prev-thread (n)
9912 "Go to the same level previous N'th thread.
9913 Returns the difference between N and the number of skips actually
9916 (gnus-summary-next-thread (- n)))
9918 (defun gnus-summary-go-down-thread ()
9919 "Go down one level in the current thread."
9920 (let ((children (gnus-summary-article-children)))
9922 (gnus-summary-goto-subject (car children)))))
9924 (defun gnus-summary-go-up-thread ()
9925 "Go up one level in the current thread."
9926 (let ((parent (gnus-summary-article-parent)))
9928 (gnus-summary-goto-subject parent))))
9930 (defun gnus-summary-down-thread (n)
9931 "Go down thread N steps.
9932 If N is negative, go up instead.
9933 Returns the difference between N and how many steps down that were
9939 (if up (gnus-summary-go-up-thread)
9940 (gnus-summary-go-down-thread)))
9942 (gnus-summary-position-point)
9944 (gnus-message 7 "Can't go further"))
9947 (defun gnus-summary-up-thread (n)
9948 "Go up thread N steps.
9949 If N is negative, go down instead.
9950 Returns the difference between N and how many steps down that were
9953 (gnus-summary-down-thread (- n)))
9955 (defun gnus-summary-top-thread ()
9956 "Go to the top of the thread."
9958 (while (gnus-summary-go-up-thread))
9959 (gnus-summary-article-number))
9961 (defun gnus-summary-kill-thread (&optional unmark)
9962 "Mark articles under current thread as read.
9963 If the prefix argument is positive, remove any kinds of marks.
9964 If the prefix argument is negative, tick articles instead."
9967 (setq unmark (prefix-numeric-value unmark)))
9968 (let ((articles (gnus-summary-articles-in-thread)))
9970 ;; Expand the thread.
9971 (gnus-summary-show-thread)
9972 ;; Mark all the articles.
9974 (gnus-summary-goto-subject (car articles))
9975 (cond ((null unmark)
9976 (gnus-summary-mark-article-as-read gnus-killed-mark))
9978 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9980 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9981 (setq articles (cdr articles))))
9982 ;; Hide killed subtrees.
9984 gnus-thread-hide-killed
9985 (gnus-summary-hide-thread))
9986 ;; If marked as read, go to next unread subject.
9988 ;; Go to next unread subject.
9989 (gnus-summary-next-subject 1 t)))
9990 (gnus-set-mode-line 'summary))
9992 ;; Summary sorting commands
9994 (defun gnus-summary-sort-by-number (&optional reverse)
9995 "Sort the summary buffer by article number.
9996 Argument REVERSE means reverse order."
9998 (gnus-summary-sort 'number reverse))
10000 (defun gnus-summary-sort-by-author (&optional reverse)
10001 "Sort the summary buffer by author name alphabetically.
10002 If `case-fold-search' is non-nil, case of letters is ignored.
10003 Argument REVERSE means reverse order."
10005 (gnus-summary-sort 'author reverse))
10007 (defun gnus-summary-sort-by-subject (&optional reverse)
10008 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10009 If `case-fold-search' is non-nil, case of letters is ignored.
10010 Argument REVERSE means reverse order."
10012 (gnus-summary-sort 'subject reverse))
10014 (defun gnus-summary-sort-by-date (&optional reverse)
10015 "Sort the summary buffer by date.
10016 Argument REVERSE means reverse order."
10018 (gnus-summary-sort 'date reverse))
10020 (defun gnus-summary-sort-by-score (&optional reverse)
10021 "Sort the summary buffer by score.
10022 Argument REVERSE means reverse order."
10024 (gnus-summary-sort 'score reverse))
10026 (defun gnus-summary-sort-by-lines (&optional reverse)
10027 "Sort the summary buffer by the number of lines.
10028 Argument REVERSE means reverse order."
10030 (gnus-summary-sort 'lines reverse))
10032 (defun gnus-summary-sort-by-chars (&optional reverse)
10033 "Sort the summary buffer by article length.
10034 Argument REVERSE means reverse order."
10036 (gnus-summary-sort 'chars reverse))
10038 (defun gnus-summary-sort-by-original (&optional reverse)
10039 "Sort the summary buffer using the default sorting method.
10040 Argument REVERSE means reverse order."
10042 (let* ((buffer-read-only)
10043 (gnus-summary-prepare-hook nil))
10044 ;; We do the sorting by regenerating the threads.
10045 (gnus-summary-prepare)
10046 ;; Hide subthreads if needed.
10047 (gnus-summary-maybe-hide-threads)))
10049 (defun gnus-summary-sort (predicate reverse)
10050 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10051 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10052 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10053 (gnus-thread-sort-functions
10058 (gnus-sort-gathered-threads-function
10059 gnus-thread-sort-functions)
10060 (gnus-article-sort-functions
10064 (,article t2 t1))))
10066 (gnus-summary-prepare-hook nil))
10067 ;; We do the sorting by regenerating the threads.
10068 (gnus-summary-prepare)
10069 ;; Hide subthreads if needed.
10070 (gnus-summary-maybe-hide-threads)))
10072 ;; Summary saving commands.
10074 (defun gnus-summary-save-article (&optional n not-saved)
10075 "Save the current article using the default saver function.
10076 If N is a positive number, save the N next articles.
10077 If N is a negative number, save the N previous articles.
10078 If N is nil and any articles have been marked with the process mark,
10079 save those articles instead.
10080 The variable `gnus-default-article-saver' specifies the saver function."
10082 (let* ((articles (gnus-summary-work-articles n))
10083 (save-buffer (save-excursion
10084 (nnheader-set-temp-buffer " *Gnus Save*")))
10085 (num (length articles))
10087 (dolist (article articles)
10088 (setq header (gnus-summary-article-header article))
10089 (if (not (vectorp header))
10090 ;; This is a pseudo-article.
10091 (if (assq 'name header)
10092 (gnus-copy-file (cdr (assq 'name header)))
10093 (gnus-message 1 "Article %d is unsaveable" article))
10094 ;; This is a real article.
10095 (save-window-excursion
10096 (let ((gnus-display-mime-function nil)
10097 (gnus-article-prepare-hook nil))
10098 (gnus-summary-select-article t nil nil article)))
10100 (set-buffer save-buffer)
10102 (insert-buffer-substring gnus-original-article-buffer))
10103 (setq file (gnus-article-save save-buffer file num))
10104 (gnus-summary-remove-process-mark article)
10106 (gnus-summary-set-saved-mark article))))
10107 (gnus-kill-buffer save-buffer)
10108 (gnus-summary-position-point)
10109 (gnus-set-mode-line 'summary)
10112 (defun gnus-summary-pipe-output (&optional arg)
10113 "Pipe the current article to a subprocess.
10114 If N is a positive number, pipe the N next articles.
10115 If N is a negative number, pipe the N previous articles.
10116 If N is nil and any articles have been marked with the process mark,
10117 pipe those articles instead."
10119 (require 'gnus-art)
10120 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10121 (gnus-summary-save-article arg t))
10122 (let ((buffer (get-buffer "*Shell Command Output*")))
10124 (with-current-buffer buffer (> (point-max) (point-min))))
10125 (gnus-configure-windows 'pipe))))
10127 (defun gnus-summary-save-article-mail (&optional arg)
10128 "Append the current article to an mail file.
10129 If N is a positive number, save the N next articles.
10130 If N is a negative number, save the N previous articles.
10131 If N is nil and any articles have been marked with the process mark,
10132 save those articles instead."
10134 (require 'gnus-art)
10135 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10136 (gnus-summary-save-article arg)))
10138 (defun gnus-summary-save-article-rmail (&optional arg)
10139 "Append the current article to an rmail file.
10140 If N is a positive number, save the N next articles.
10141 If N is a negative number, save the N previous articles.
10142 If N is nil and any articles have been marked with the process mark,
10143 save those articles instead."
10145 (require 'gnus-art)
10146 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10147 (gnus-summary-save-article arg)))
10149 (defun gnus-summary-save-article-file (&optional arg)
10150 "Append the current article to a file.
10151 If N is a positive number, save the N next articles.
10152 If N is a negative number, save the N previous articles.
10153 If N is nil and any articles have been marked with the process mark,
10154 save those articles instead."
10156 (require 'gnus-art)
10157 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10158 (gnus-summary-save-article arg)))
10160 (defun gnus-summary-write-article-file (&optional arg)
10161 "Write the current article to a file, deleting the previous file.
10162 If N is a positive number, save the N next articles.
10163 If N is a negative number, save the N previous articles.
10164 If N is nil and any articles have been marked with the process mark,
10165 save those articles instead."
10167 (require 'gnus-art)
10168 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10169 (gnus-summary-save-article arg)))
10171 (defun gnus-summary-save-article-body-file (&optional arg)
10172 "Append the current article body to a file.
10173 If N is a positive number, save the N next articles.
10174 If N is a negative number, save the N previous articles.
10175 If N is nil and any articles have been marked with the process mark,
10176 save those articles instead."
10178 (require 'gnus-art)
10179 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10180 (gnus-summary-save-article arg)))
10182 (defun gnus-summary-muttprint (&optional arg)
10183 "Print the current article using Muttprint.
10184 If N is a positive number, save the N next articles.
10185 If N is a negative number, save the N previous articles.
10186 If N is nil and any articles have been marked with the process mark,
10187 save those articles instead."
10189 (require 'gnus-art)
10190 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10191 (gnus-summary-save-article arg t)))
10193 (defun gnus-summary-pipe-message (program)
10194 "Pipe the current article through PROGRAM."
10195 (interactive "sProgram: ")
10196 (gnus-summary-select-article)
10197 (let ((mail-header-separator ""))
10198 (gnus-eval-in-buffer-window gnus-article-buffer
10201 (let ((start (window-start))
10203 (message-pipe-buffer-body program)
10204 (set-window-start (get-buffer-window (current-buffer)) start))))))
10206 (defun gnus-get-split-value (methods)
10207 "Return a value based on the split METHODS."
10208 (let (split-name method result match)
10211 (set-buffer gnus-original-article-buffer)
10213 (nnheader-narrow-to-headers)
10214 (while (and methods (not split-name))
10215 (goto-char (point-min))
10216 (setq method (pop methods))
10217 (setq match (car method))
10220 ;; Regular expression.
10222 (re-search-forward match nil t)))
10223 ((gnus-functionp match)
10227 (setq result (funcall match gnus-newsgroup-name))))
10232 (setq result (eval match)))))
10233 (setq split-name (cdr method))
10234 (cond ((stringp result)
10235 (push (expand-file-name
10236 result gnus-article-save-directory)
10239 (setq split-name (append result split-name)))))))))
10240 (nreverse split-name)))
10242 (defun gnus-valid-move-group-p (group)
10243 (and (boundp group)
10244 (symbol-name group)
10245 (symbol-value group)
10246 (gnus-get-function (gnus-find-method-for-group
10247 (symbol-name group)) 'request-accept-article t)))
10249 (defun gnus-read-move-group-name (prompt default articles prefix)
10250 "Read a group name."
10251 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10252 (minibuffer-confirm-incomplete nil) ; XEmacs
10254 (format "%s %s to:"
10256 (if (> (length articles) 1)
10257 (format "these %d articles" (length articles))
10262 (gnus-completing-read-with-default
10265 'gnus-valid-move-group-p
10267 'gnus-group-history))
10268 ((= 1 (length split-name))
10269 (gnus-completing-read-with-default
10270 (car split-name) prom
10272 'gnus-valid-move-group-p
10274 'gnus-group-history))
10276 (gnus-completing-read-with-default
10278 (mapcar (lambda (el) (list el))
10279 (nreverse split-name))
10281 'gnus-group-history))))
10282 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10284 (if (or (string= to-newsgroup "")
10285 (string= to-newsgroup prefix))
10286 (setq to-newsgroup default))
10287 (unless to-newsgroup
10288 (error "No group name entered"))
10289 (or (gnus-active to-newsgroup)
10290 (gnus-activate-group to-newsgroup nil nil to-method)
10291 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10293 (or (and (gnus-request-create-group to-newsgroup to-method)
10294 (gnus-activate-group
10295 to-newsgroup nil nil to-method)
10296 (gnus-subscribe-group to-newsgroup))
10297 (error "Couldn't create group %s" to-newsgroup)))
10298 (error "No such group: %s" to-newsgroup)))
10301 (defun gnus-summary-save-parts (type dir n &optional reverse)
10302 "Save parts matching TYPE to DIR.
10303 If REVERSE, save parts that do not match TYPE."
10305 (list (read-string "Save parts of type: "
10306 (or (car gnus-summary-save-parts-type-history)
10307 gnus-summary-save-parts-default-mime)
10308 'gnus-summary-save-parts-type-history)
10309 (setq gnus-summary-save-parts-last-directory
10310 (read-file-name "Save to directory: "
10311 gnus-summary-save-parts-last-directory
10313 current-prefix-arg))
10314 (gnus-summary-iterate n
10315 (let ((gnus-display-mime-function nil)
10316 (gnus-inhibit-treatment t))
10317 (gnus-summary-select-article))
10319 (set-buffer gnus-article-buffer)
10320 (let ((handles (or gnus-article-mime-handles
10322 gnus-article-no-strict-mime)
10325 (gnus-summary-save-parts-1 type dir handles reverse)
10326 (unless gnus-article-mime-handles ;; Don't destroy this case.
10327 (mm-destroy-parts handles)))))))
10329 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10330 (if (stringp (car handle))
10331 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10334 (not (string-match type (mm-handle-media-type handle)))
10335 (string-match type (mm-handle-media-type handle)))
10336 (let ((file (expand-file-name
10337 (file-name-nondirectory
10339 (mail-content-type-get
10340 (mm-handle-disposition handle) 'filename)
10341 (concat gnus-newsgroup-name
10342 "." (number-to-string
10343 (cdr gnus-article-current)))))
10345 (unless (file-exists-p file)
10346 (mm-save-part-to-file handle file))))))
10348 ;; Summary extract commands
10350 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10351 (let ((buffer-read-only nil)
10352 (article (gnus-summary-article-number))
10354 (unless (gnus-summary-goto-subject article)
10355 (error "No such article: %d" article))
10356 (gnus-summary-position-point)
10357 ;; If all commands are to be bunched up on one line, we collect
10359 (unless gnus-view-pseudos-separately
10360 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10363 (setq action (cdr (assq 'action (car ps))))
10364 (setq files (list (cdr (assq 'name (car ps)))))
10365 (while (and ps (cdr ps)
10366 (string= (or action "1")
10367 (or (cdr (assq 'action (cadr ps))) "2")))
10368 (push (cdr (assq 'name (cadr ps))) files)
10369 (setcdr ps (cddr ps)))
10371 (when (not (string-match "%s" action))
10374 (when (assq 'execute (car ps))
10375 (setcdr (assq 'execute (car ps))
10376 (funcall (if (string-match "%s" action)
10385 (setq ps (cdr ps)))))
10386 (if (and gnus-view-pseudos (not not-view))
10388 (when (assq 'execute (car pslist))
10389 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10390 (eq gnus-view-pseudos 'not-confirm)))
10391 (setq pslist (cdr pslist)))
10394 (setq after-article (or (cdr (assq 'article (car pslist)))
10395 (gnus-summary-article-number)))
10396 (gnus-summary-goto-subject after-article)
10399 (insert " " (file-name-nondirectory
10400 (cdr (assq 'name (car pslist))))
10401 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10403 (forward-line -1) ; back to `b'
10404 (gnus-add-text-properties
10405 b (1- e) (list 'gnus-number gnus-reffed-article-number
10406 gnus-mouse-face-prop gnus-mouse-face))
10408 after-article gnus-reffed-article-number
10409 gnus-unread-mark b (car pslist) 0 (- e b))
10410 (setq gnus-newsgroup-unreads
10411 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10412 gnus-reffed-article-number))
10413 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10414 (setq pslist (cdr pslist)))))))
10416 (defun gnus-pseudos< (p1 p2)
10417 (let ((c1 (cdr (assq 'action p1)))
10418 (c2 (cdr (assq 'action p2))))
10419 (and c1 c2 (string< c1 c2))))
10421 (defun gnus-request-pseudo-article (props)
10422 (cond ((assq 'execute props)
10423 (gnus-execute-command (cdr (assq 'execute props)))))
10424 (let ((gnus-current-article (gnus-summary-article-number)))
10425 (gnus-run-hooks 'gnus-mark-article-hook)))
10427 (defun gnus-execute-command (command &optional automatic)
10429 (gnus-article-setup-buffer)
10430 (set-buffer gnus-article-buffer)
10431 (setq buffer-read-only nil)
10432 (let ((command (if automatic command
10433 (read-string "Command: " (cons command 0)))))
10435 (insert "$ " command "\n\n")
10436 (if gnus-view-pseudo-asynchronously
10437 (start-process "gnus-execute" (current-buffer) shell-file-name
10438 shell-command-switch command)
10439 (call-process shell-file-name nil t nil
10440 shell-command-switch command)))))
10442 ;; Summary kill commands.
10444 (defun gnus-summary-edit-global-kill (article)
10445 "Edit the \"global\" kill file."
10446 (interactive (list (gnus-summary-article-number)))
10447 (gnus-group-edit-global-kill article))
10449 (defun gnus-summary-edit-local-kill ()
10450 "Edit a local kill file applied to the current newsgroup."
10452 (setq gnus-current-headers (gnus-summary-article-header))
10453 (gnus-group-edit-local-kill
10454 (gnus-summary-article-number) gnus-newsgroup-name))
10456 ;;; Header reading.
10458 (defun gnus-read-header (id &optional header)
10459 "Read the headers of article ID and enter them into the Gnus system."
10460 (let ((group gnus-newsgroup-name)
10461 (gnus-override-method
10463 gnus-override-method
10464 (and (gnus-news-group-p gnus-newsgroup-name)
10465 (car (gnus-refer-article-methods)))))
10467 ;; First we check to see whether the header in question is already
10470 ;; This is a Message-ID.
10471 (setq header (or header (gnus-id-to-header id)))
10472 ;; This is an article number.
10473 (setq header (or header (gnus-summary-article-header id))))
10475 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10476 ;; We have found the header.
10478 ;; If this is a sparse article, we have to nix out its
10479 ;; previous entry in the thread hashtb.
10481 (gnus-summary-article-sparse-p (mail-header-number header)))
10482 (let* ((parent (gnus-parent-id (mail-header-references header)))
10483 (thread (and parent (gnus-id-to-thread parent))))
10485 (delq (assq header thread) thread))))
10486 ;; We have to really fetch the header to this article.
10488 (set-buffer nntp-server-buffer)
10489 (when (setq where (gnus-request-head id group))
10490 (nnheader-fold-continuation-lines)
10491 (goto-char (point-max))
10493 (goto-char (point-min))
10497 ((cdr where) (cdr where))
10498 (header (mail-header-number header))
10499 (t gnus-reffed-article-number))
10501 (insert " Article retrieved.\n"))
10502 (if (or (not where)
10503 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10504 () ; Malformed head.
10505 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10506 (when (and (stringp id)
10507 (not (string= (gnus-group-real-name group)
10509 ;; If we fetched by Message-ID and the article came
10510 ;; from a different group, we fudge some bogus article
10511 ;; numbers for this article.
10512 (mail-header-set-number header gnus-reffed-article-number))
10514 (set-buffer gnus-summary-buffer)
10515 (decf gnus-reffed-article-number)
10516 (gnus-remove-header (mail-header-number header))
10517 (push header gnus-newsgroup-headers)
10518 (setq gnus-current-headers header)
10519 (push (mail-header-number header) gnus-newsgroup-limit)))
10522 (defun gnus-remove-header (number)
10523 "Remove header NUMBER from `gnus-newsgroup-headers'."
10524 (if (and gnus-newsgroup-headers
10525 (= number (mail-header-number (car gnus-newsgroup-headers))))
10526 (pop gnus-newsgroup-headers)
10527 (let ((headers gnus-newsgroup-headers))
10528 (while (and (cdr headers)
10529 (not (= number (mail-header-number (cadr headers)))))
10531 (when (cdr headers)
10532 (setcdr headers (cddr headers))))))
10535 ;;; summary highlights
10538 (defun gnus-highlight-selected-summary ()
10539 "Highlight selected article in summary buffer."
10540 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10541 (when gnus-summary-selected-face
10543 (let* ((beg (progn (beginning-of-line) (point)))
10544 (end (progn (end-of-line) (point)))
10545 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10546 (from (if (get-text-property beg gnus-mouse-face-prop)
10548 (or (next-single-property-change
10549 beg gnus-mouse-face-prop nil end)
10554 (or (next-single-property-change
10555 from gnus-mouse-face-prop nil end)
10557 ;; If no mouse-face prop on line we will have to = from = end,
10558 ;; so we highlight the entire line instead.
10559 (when (= (+ to 2) from)
10562 (if gnus-newsgroup-selected-overlay
10563 ;; Move old overlay.
10565 gnus-newsgroup-selected-overlay from to (current-buffer))
10566 ;; Create new overlay.
10568 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10569 'face gnus-summary-selected-face))))))
10571 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10572 (defun gnus-summary-highlight-line ()
10573 "Highlight current line according to `gnus-summary-highlight'."
10574 (let* ((list gnus-summary-highlight)
10576 (end (progn (end-of-line) (point)))
10577 ;; now find out where the line starts and leave point there.
10578 (beg (progn (beginning-of-line) (point)))
10579 (article (gnus-summary-article-number))
10580 (score (or (cdr (assq (or article gnus-current-article)
10581 gnus-newsgroup-scored))
10582 gnus-summary-default-score 0))
10583 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10584 (inhibit-read-only t))
10585 ;; Eval the cars of the lists until we find a match.
10586 (let ((default gnus-summary-default-score)
10587 (default-high gnus-summary-default-high-score)
10588 (default-low gnus-summary-default-low-score))
10590 (not (eval (caar list))))
10591 (setq list (cdr list))))
10592 (let ((face (cdar list)))
10593 (unless (eq face (get-text-property beg 'face))
10594 (gnus-put-text-property-excluding-characters-with-faces
10596 (setq face (if (boundp face) (symbol-value face) face)))
10597 (when gnus-summary-highlight-line-function
10598 (funcall gnus-summary-highlight-line-function article face))))
10601 (defun gnus-update-read-articles (group unread &optional compute)
10602 "Update the list of read articles in GROUP.
10603 UNREAD is a sorted list."
10604 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10605 (entry (gnus-gethash group gnus-newsrc-hashtb))
10606 (info (nth 2 entry))
10609 (if (or (not info) (not active))
10610 ;; There is no info on this group if it was, in fact,
10611 ;; killed. Gnus stores no information on killed groups, so
10612 ;; there's nothing to be done.
10613 ;; One could store the information somewhere temporarily,
10614 ;; perhaps... Hmmm...
10616 ;; Remove any negative articles numbers.
10617 (while (and unread (< (car unread) 0))
10618 (setq unread (cdr unread)))
10619 ;; Remove any expired article numbers
10620 (while (and unread (< (car unread) (car active)))
10621 (setq unread (cdr unread)))
10622 ;; Compute the ranges of read articles by looking at the list of
10623 ;; unread articles.
10625 (when (/= (car unread) prev)
10626 (push (if (= prev (1- (car unread))) prev
10627 (cons prev (1- (car unread))))
10629 (setq prev (1+ (car unread)))
10630 (setq unread (cdr unread)))
10631 (when (<= prev (cdr active))
10632 (push (cons prev (cdr active)) read))
10633 (setq read (if (> (length read) 1) (nreverse read) read))
10638 ;; Propagate the read marks to the backend.
10639 (when (gnus-check-backend-function 'request-set-mark group)
10640 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10641 (add (gnus-remove-from-range read (gnus-info-read info))))
10643 (unless (gnus-check-group group)
10644 (error "Can't open server for %s" group))
10645 (gnus-request-set-mark
10646 group (delq nil (list (if add (list add 'add '(read)))
10647 (if del (list del 'del '(read))))))
10649 `(gnus-request-set-mark
10652 (if del (list del 'add '(read)))
10653 (if add (list add 'del '(read))))))))))
10654 (set-buffer gnus-group-buffer)
10655 (gnus-undo-register
10657 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10658 (gnus-info-set-read ',info ',(gnus-info-read info))
10659 (gnus-get-unread-articles-in-group ',info
10660 (gnus-active ,group))
10661 (gnus-group-update-group ,group t)
10663 ;; Enter this list into the group info.
10664 (gnus-info-set-read info read)
10665 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10666 (gnus-get-unread-articles-in-group info (gnus-active group))
10669 (defun gnus-offer-save-summaries ()
10670 "Offer to save all active summary buffers."
10672 ;; Go through all buffers and find all summaries.
10673 (dolist (buffer (buffer-list))
10674 (when (and (setq buffer (buffer-name buffer))
10675 (string-match "Summary" buffer)
10677 (set-buffer buffer)
10678 ;; We check that this is, indeed, a summary buffer.
10679 (and (eq major-mode 'gnus-summary-mode)
10680 ;; Also make sure this isn't bogus.
10681 gnus-newsgroup-prepared
10682 ;; Also make sure that this isn't a
10683 ;; dead summary buffer.
10684 (not gnus-dead-summary-mode))))
10685 (push buffer buffers)))
10686 ;; Go through all these summary buffers and offer to save them.
10690 "Update summary buffer %s? "
10692 (switch-to-buffer buf)
10693 (gnus-summary-exit))
10696 (defun gnus-summary-setup-default-charset ()
10697 "Setup newsgroup default charset."
10698 (if (equal gnus-newsgroup-name "nndraft:drafts")
10699 (setq gnus-newsgroup-charset nil)
10700 (let* ((ignored-charsets
10701 (or gnus-newsgroup-ephemeral-ignored-charsets
10703 (and gnus-newsgroup-name
10704 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10705 gnus-newsgroup-ignored-charsets))))
10706 (setq gnus-newsgroup-charset
10707 (or gnus-newsgroup-ephemeral-charset
10708 (and gnus-newsgroup-name
10709 (gnus-parameter-charset gnus-newsgroup-name))
10710 gnus-default-charset))
10711 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10712 ignored-charsets))))
10718 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10719 "Display the current article buffer fully MIME-buttonized.
10720 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10721 treated as multipart/mixed."
10723 (require 'gnus-art)
10724 (let ((gnus-unbuttonized-mime-types nil)
10725 (gnus-mime-display-multipart-as-mixed show-all-parts))
10726 (gnus-summary-show-article)))
10728 (defun gnus-summary-repair-multipart (article)
10729 "Add a Content-Type header to a multipart article without one."
10730 (interactive (list (gnus-summary-article-number)))
10731 (gnus-with-article article
10732 (message-narrow-to-head)
10733 (message-remove-header "Mime-Version")
10734 (goto-char (point-max))
10735 (insert "Mime-Version: 1.0\n")
10737 (when (search-forward "\n--" nil t)
10738 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10739 (message-narrow-to-head)
10740 (message-remove-header "Content-Type")
10741 (goto-char (point-max))
10742 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10745 (let (gnus-mark-article-hook)
10746 (gnus-summary-select-article t t nil article)))
10748 (defun gnus-summary-toggle-display-buttonized ()
10749 "Toggle the buttonizing of the article buffer."
10751 (require 'gnus-art)
10752 (if (setq gnus-inhibit-mime-unbuttonizing
10753 (not gnus-inhibit-mime-unbuttonizing))
10754 (let ((gnus-unbuttonized-mime-types nil))
10755 (gnus-summary-show-article))
10756 (gnus-summary-show-article)))
10759 ;;; Generic summary marking commands
10762 (defvar gnus-summary-marking-alist
10763 '((read gnus-del-mark "d")
10764 (unread gnus-unread-mark "u")
10765 (ticked gnus-ticked-mark "!")
10766 (dormant gnus-dormant-mark "?")
10767 (expirable gnus-expirable-mark "e"))
10768 "An alist of names/marks/keystrokes.")
10770 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10771 (defvar gnus-summary-mark-map)
10773 (defun gnus-summary-make-all-marking-commands ()
10774 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10775 (dolist (elem gnus-summary-marking-alist)
10776 (apply 'gnus-summary-make-marking-command elem)))
10778 (defun gnus-summary-make-marking-command (name mark keystroke)
10779 (let ((map (make-sparse-keymap)))
10780 (define-key gnus-summary-generic-mark-map keystroke map)
10781 (dolist (lway `((next "next" next nil "n")
10782 (next-unread "next unread" next t "N")
10783 (prev "previous" prev nil "p")
10784 (prev-unread "previous unread" prev t "P")
10785 (nomove "" nil nil ,keystroke)))
10786 (let ((func (gnus-summary-make-marking-command-1
10787 mark (car lway) lway name)))
10788 (setq func (eval func))
10789 (define-key map (nth 4 lway) func)))))
10791 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10793 (format "gnus-summary-put-mark-as-%s%s"
10794 name (if (eq way 'nomove)
10796 (concat "-" (symbol-name way)))))
10799 "Mark the current article as %s%s.
10800 If N, the prefix, then repeat N times.
10801 If N is negative, move in reverse order.
10802 The difference between N and the actual number of articles marked is
10806 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10808 (defun gnus-summary-generic-mark (n mark move unread)
10809 "Mark N articles with MARK."
10810 (unless (eq major-mode 'gnus-summary-mode)
10811 (error "This command can only be used in the summary buffer"))
10812 (gnus-summary-show-thread)
10815 ((eq move 'next) 1)
10816 ((eq move 'prev) -1)
10818 (if (zerop nummove)
10822 nummove (* -1 nummove))))
10823 (while (and (> n 0)
10824 (gnus-summary-mark-article nil mark)
10825 (zerop (gnus-summary-next-subject nummove unread t)))
10828 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10829 (gnus-summary-recenter)
10830 (gnus-summary-position-point)
10831 (gnus-set-mode-line 'summary)
10834 (defun gnus-summary-insert-articles (articles)
10835 (when (setq articles
10836 (gnus-sorted-difference articles
10837 (mapcar (lambda (h)
10838 (mail-header-number h))
10839 gnus-newsgroup-headers)))
10840 (setq gnus-newsgroup-headers
10842 gnus-newsgroup-headers
10843 (gnus-fetch-headers articles)
10844 'gnus-article-sort-by-number))
10845 ;; Suppress duplicates?
10846 (when gnus-suppress-duplicates
10847 (gnus-dup-suppress-articles))
10849 ;; We might want to build some more threads first.
10850 (when (and gnus-fetch-old-headers
10851 (eq gnus-headers-retrieved-by 'nov))
10852 (if (eq gnus-fetch-old-headers 'invisible)
10853 (gnus-build-all-threads)
10854 (gnus-build-old-threads)))
10855 ;; Let the Gnus agent mark articles as read.
10857 (gnus-agent-get-undownloaded-list))
10858 ;; Remove list identifiers from subject
10859 (when gnus-list-identifiers
10860 (gnus-summary-remove-list-identifiers))
10861 ;; First and last article in this newsgroup.
10862 (when gnus-newsgroup-headers
10863 (setq gnus-newsgroup-begin
10864 (mail-header-number (car gnus-newsgroup-headers))
10866 (mail-header-number
10867 (gnus-last-element gnus-newsgroup-headers))))
10868 (when gnus-use-scoring
10869 (gnus-possibly-score-headers))))
10871 (defun gnus-summary-insert-old-articles (&optional all)
10872 "Insert all old articles in this group.
10873 If ALL is non-nil, already read articles become readable.
10874 If ALL is a number, fetch this number of articles."
10877 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
10880 (gnus-sorted-difference
10881 (gnus-uncompress-range (list gnus-newsgroup-active))
10883 (setq len (length older))
10888 (setq older (last older all))))
10891 (if (and (numberp gnus-large-newsgroup)
10892 (> len gnus-large-newsgroup))
10896 "How many articles from %s (default %d): "
10898 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10900 (unless (string-match "^[ \t]*$" input)
10901 (setq all (string-to-number input))
10903 (setq older (last older all))))))))
10905 (message "No old news.")
10906 (gnus-summary-insert-articles older)
10907 (gnus-summary-limit (gnus-sorted-nunion old older))))
10908 (gnus-summary-position-point)))
10910 (defun gnus-summary-insert-new-articles ()
10911 "Insert all new articles in this group."
10914 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
10915 (old-active gnus-newsgroup-active)
10916 (nnmail-fetched-sources (list t))
10918 (setq gnus-newsgroup-active
10919 (gnus-activate-group gnus-newsgroup-name 'scan))
10920 (setq i (1+ (cdr old-active)))
10921 (while (<= i (cdr gnus-newsgroup-active))
10925 (message "No gnus is bad news.")
10926 (setq new (nreverse new))
10927 (gnus-summary-insert-articles new)
10928 (setq gnus-newsgroup-unreads
10929 (gnus-sorted-nunion gnus-newsgroup-unreads new))
10930 (gnus-summary-limit (gnus-sorted-nunion old new))))
10931 (gnus-summary-position-point)))
10933 (gnus-summary-make-all-marking-commands)
10935 (gnus-ems-redefine)
10937 (provide 'gnus-sum)
10939 (run-hooks 'gnus-sum-load-hook)
10941 ;;; gnus-sum.el ends here