1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
42 ;; (require 'gnus-art)
51 (autoload 'pgg-decrypt-region "pgg" nil t)
52 (autoload 'pgg-verify-region "pgg" nil t))
54 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
55 (autoload 'gnus-cache-write-active "gnus-cache")
56 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
57 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
58 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
59 (autoload 'mm-uu-dissect "mm-uu")
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include: `gnus-simplify-subject-re',
151 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
153 :type '(repeat function))
155 (defcustom gnus-simplify-ignored-prefixes nil
156 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
158 :type '(choice (const :tag "off" nil)
161 (defcustom gnus-build-sparse-threads nil
162 "*If non-nil, fill in the gaps in threads.
163 If `some', only fill in the gaps that are needed to tie loose threads
164 together. If `more', fill in all leaf nodes that Gnus can find. If
165 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
167 :type '(choice (const :tag "off" nil)
170 (sexp :menu-tag "all" t)))
172 (defcustom gnus-summary-thread-gathering-function
173 'gnus-gather-threads-by-subject
174 "*Function used for gathering loose threads.
175 There are two pre-defined functions: `gnus-gather-threads-by-subject',
176 which only takes Subjects into consideration; and
177 `gnus-gather-threads-by-references', which compared the References
178 headers of the articles to find matches."
180 :type '(radio (function-item gnus-gather-threads-by-subject)
181 (function-item gnus-gather-threads-by-references)
182 (function :tag "other")))
184 (defcustom gnus-summary-same-subject ""
185 "*String indicating that the current article has the same subject as the previous.
186 This variable will only be used if the value of
187 `gnus-summary-make-false-root' is `empty'."
188 :group 'gnus-summary-format
191 (defcustom gnus-summary-goto-unread t
192 "*If t, many commands will go to the next unread article.
193 This applies to marking commands as well as other commands that
194 \"naturally\" select the next article, like, for instance, `SPC' at
195 the end of an article.
197 If nil, the marking commands do NOT go to the next unread article
198 (they go to the next article instead). If `never', commands that
199 usually go to the next unread article, will go to the next article,
200 whether it is read or not."
201 :group 'gnus-summary-marks
202 :link '(custom-manual "(gnus)Setting Marks")
203 :type '(choice (const :tag "off" nil)
205 (sexp :menu-tag "on" t)))
207 (defcustom gnus-summary-default-score 0
208 "*Default article score level.
209 All scores generated by the score files will be added to this score.
210 If this variable is nil, scoring will be disabled."
211 :group 'gnus-score-default
212 :type '(choice (const :tag "disable")
215 (defcustom gnus-summary-default-high-score 0
216 "*Default threshold for a high scored article.
217 An article will be highlighted as high scored if its score is greater
219 :group 'gnus-score-default
222 (defcustom gnus-summary-default-low-score 0
223 "*Default threshold for a low scored article.
224 An article will be highlighted as low scored if its score is smaller
226 :group 'gnus-score-default
229 (defcustom gnus-summary-zcore-fuzz 0
230 "*Fuzziness factor for the zcore in the summary buffer.
231 Articles with scores closer than this to `gnus-summary-default-score'
233 :group 'gnus-summary-format
236 (defcustom gnus-simplify-subject-fuzzy-regexp nil
237 "*Strings to be removed when doing fuzzy matches.
238 This can either be a regular expression or list of regular expressions
239 that will be removed from subject strings if fuzzy subject
240 simplification is selected."
242 :type '(repeat regexp))
244 (defcustom gnus-show-threads t
245 "*If non-nil, display threads in summary mode."
249 (defcustom gnus-thread-hide-subtree nil
250 "*If non-nil, hide all threads initially.
251 If threads are hidden, you have to run the command
252 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
253 to expose hidden threads."
257 (defcustom gnus-thread-hide-killed t
258 "*If non-nil, hide killed threads automatically."
262 (defcustom gnus-thread-ignore-subject t
263 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
264 If nil, articles that have different subjects from their parents will
265 start separate threads."
269 (defcustom gnus-thread-operation-ignore-subject t
270 "*If non-nil, subjects will be ignored when doing thread commands.
271 This affects commands like `gnus-summary-kill-thread' and
272 `gnus-summary-lower-thread'.
274 If this variable is nil, articles in the same thread with different
275 subjects will not be included in the operation in question. If this
276 variable is `fuzzy', only articles that have subjects that are fuzzily
277 equal will be included."
279 :type '(choice (const :tag "off" nil)
283 (defcustom gnus-thread-indent-level 4
284 "*Number that says how much each sub-thread should be indented."
288 (defcustom gnus-auto-extend-newsgroup t
289 "*If non-nil, extend newsgroup forward and backward when requested."
290 :group 'gnus-summary-choose
293 (defcustom gnus-auto-select-first t
294 "*If nil, don't select the first unread article when entering a group.
295 If this variable is `best', select the highest-scored unread article
296 in the group. If t, select the first unread article.
298 This variable can also be a function to place point on a likely
299 subject line. Useful values include `gnus-summary-first-unread-subject',
300 `gnus-summary-first-unread-article' and
301 `gnus-summary-best-unread-article'.
303 If you want to prevent automatic selection of the first unread article
304 in some newsgroups, set the variable to nil in
305 `gnus-select-group-hook'."
306 :group 'gnus-group-select
307 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)
310 (function-item gnus-summary-first-unread-subject)
311 (function-item gnus-summary-first-unread-article)
312 (function-item gnus-summary-best-unread-article)))
314 (defcustom gnus-dont-select-after-jump-to-other-group nil
315 "If non-nil, don't select the first unread article after entering the
316 other group by the command `gnus-summary-jump-to-other-group'. If nil,
317 it is depend on the value of `gnus-auto-select-first' whether to select
319 :group 'gnus-group-select
322 (defcustom gnus-auto-select-next t
323 "*If non-nil, offer to go to the next group from the end of the previous.
324 If the value is t and the next newsgroup is empty, Gnus will exit
325 summary mode and go back to group mode. If the value is neither nil
326 nor t, Gnus will select the following unread newsgroup. In
327 particular, if the value is the symbol `quietly', the next unread
328 newsgroup will be selected without any confirmation, and if it is
329 `almost-quietly', the next group will be selected without any
330 confirmation if you are located on the last article in the group.
331 Finally, if this variable is `slightly-quietly', the `Z n' command
332 will go to the next group without confirmation."
333 :group 'gnus-summary-maneuvering
334 :type '(choice (const :tag "off" nil)
336 (const almost-quietly)
337 (const slightly-quietly)
338 (sexp :menu-tag "on" t)))
340 (defcustom gnus-auto-select-same nil
341 "*If non-nil, select the next article with the same subject.
342 If there are no more articles with the same subject, go to
343 the first unread article."
344 :group 'gnus-summary-maneuvering
347 (defcustom gnus-summary-check-current nil
348 "*If non-nil, consider the current article when moving.
349 The \"unread\" movement commands will stay on the same line if the
350 current article is unread."
351 :group 'gnus-summary-maneuvering
354 (defcustom gnus-auto-center-summary t
355 "*If non-nil, always center the current summary buffer.
356 In particular, if `vertical' do only vertical recentering. If non-nil
357 and non-`vertical', do both horizontal and vertical recentering."
358 :group 'gnus-summary-maneuvering
359 :type '(choice (const :tag "none" nil)
361 (integer :tag "height")
362 (sexp :menu-tag "both" t)))
364 (defcustom gnus-show-all-headers nil
365 "*If non-nil, don't hide any headers."
366 :group 'gnus-article-hiding
367 :group 'gnus-article-headers
370 (defcustom gnus-summary-ignore-duplicates nil
371 "*If non-nil, ignore articles with identical Message-ID headers."
375 (defcustom gnus-single-article-buffer t
376 "*If non-nil, display all articles in the same buffer.
377 If nil, each group will get its own article buffer."
378 :group 'gnus-article-various
381 (defcustom gnus-break-pages t
382 "*If non-nil, do page breaking on articles.
383 The page delimiter is specified by the `gnus-page-delimiter'
385 :group 'gnus-article-various
388 (defcustom gnus-show-mime t
389 "*If non-nil, do mime processing of articles.
390 The articles will simply be fed to the function given by
391 `gnus-article-display-method-for-mime'."
392 :group 'gnus-article-mime
395 (defcustom gnus-move-split-methods nil
396 "*Variable used to suggest where articles are to be moved to.
397 It uses the same syntax as the `gnus-split-methods' variable.
398 However, whereas `gnus-split-methods' specifies file names as targets,
399 this variable specifies group names."
400 :group 'gnus-summary-mail
401 :type '(repeat (choice (list :value (fun) function)
402 (cons :value ("" "") regexp (repeat string))
405 (defcustom gnus-unread-mark ?\ ;;;Whitespace
406 "*Mark used for unread articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-ticked-mark ?!
411 "*Mark used for ticked articles."
412 :group 'gnus-summary-marks
415 (defcustom gnus-dormant-mark ??
416 "*Mark used for dormant articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-del-mark ?r
421 "*Mark used for del'd articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-read-mark ?R
426 "*Mark used for read articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-expirable-mark ?E
431 "*Mark used for expirable articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-killed-mark ?K
436 "*Mark used for killed articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-souped-mark ?F
441 "*Mark used for souped articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-kill-file-mark ?X
446 "*Mark used for articles killed by kill files."
447 :group 'gnus-summary-marks
450 (defcustom gnus-low-score-mark ?Y
451 "*Mark used for articles with a low score."
452 :group 'gnus-summary-marks
455 (defcustom gnus-catchup-mark ?C
456 "*Mark used for articles that are caught up."
457 :group 'gnus-summary-marks
460 (defcustom gnus-replied-mark ?A
461 "*Mark used for articles that have been replied to."
462 :group 'gnus-summary-marks
465 (defcustom gnus-forwarded-mark ?F
466 "*Mark used for articles that have been forwarded."
467 :group 'gnus-summary-marks
470 (defcustom gnus-recent-mark ?N
471 "*Mark used for articles that are recent."
472 :group 'gnus-summary-marks
475 (defcustom gnus-cached-mark ?*
476 "*Mark used for articles that are in the cache."
477 :group 'gnus-summary-marks
480 (defcustom gnus-saved-mark ?S
481 "*Mark used for articles that have been saved."
482 :group 'gnus-summary-marks
485 (defcustom gnus-unseen-mark ?.
486 "*Mark used for articles that haven't been seen."
487 :group 'gnus-summary-marks
490 (defcustom gnus-no-mark ?\ ;;;Whitespace
491 "*Mark used for articles that have no other secondary mark."
492 :group 'gnus-summary-marks
495 (defcustom gnus-ancient-mark ?O
496 "*Mark used for ancient articles."
497 :group 'gnus-summary-marks
500 (defcustom gnus-sparse-mark ?Q
501 "*Mark used for sparsely reffed articles."
502 :group 'gnus-summary-marks
505 (defcustom gnus-canceled-mark ?G
506 "*Mark used for canceled articles."
507 :group 'gnus-summary-marks
510 (defcustom gnus-duplicate-mark ?M
511 "*Mark used for duplicate articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-undownloaded-mark ?@
516 "*Mark used for articles that weren't downloaded."
517 :group 'gnus-summary-marks
520 (defcustom gnus-downloadable-mark ?%
521 "*Mark used for articles that are to be downloaded."
522 :group 'gnus-summary-marks
525 (defcustom gnus-unsendable-mark ?=
526 "*Mark used for articles that won't be sent."
527 :group 'gnus-summary-marks
530 (defcustom gnus-score-over-mark ?+
531 "*Score mark used for articles with high scores."
532 :group 'gnus-summary-marks
535 (defcustom gnus-score-below-mark ?-
536 "*Score mark used for articles with low scores."
537 :group 'gnus-summary-marks
540 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
541 "*There is no thread under the article."
542 :group 'gnus-summary-marks
545 (defcustom gnus-not-empty-thread-mark ?=
546 "*There is a thread under the article."
547 :group 'gnus-summary-marks
550 (defcustom gnus-view-pseudo-asynchronously nil
551 "*If non-nil, Gnus will view pseudo-articles asynchronously."
552 :group 'gnus-extract-view
555 (defcustom gnus-auto-expirable-marks
556 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
557 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
558 gnus-souped-mark gnus-duplicate-mark)
559 "*The list of marks converted into expiration if a group is auto-expirable."
562 :type '(repeat character))
564 (defcustom gnus-inhibit-user-auto-expire t
565 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
570 (defcustom gnus-view-pseudos nil
571 "*If `automatic', pseudo-articles will be viewed automatically.
572 If `not-confirm', pseudos will be viewed automatically, and the user
573 will not be asked to confirm the command."
574 :group 'gnus-extract-view
575 :type '(choice (const :tag "off" nil)
577 (const not-confirm)))
579 (defcustom gnus-view-pseudos-separately t
580 "*If non-nil, one pseudo-article will be created for each file to be viewed.
581 If nil, all files that use the same viewing command will be given as a
582 list of parameters to that command."
583 :group 'gnus-extract-view
586 (defcustom gnus-insert-pseudo-articles t
587 "*If non-nil, insert pseudo-articles when decoding articles."
588 :group 'gnus-extract-view
591 (defcustom gnus-summary-dummy-line-format
593 "*The format specification for the dummy roots in the summary buffer.
594 It works along the same lines as a normal formatting string,
595 with some simple extensions.
598 :group 'gnus-threading
601 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
602 "*The format specification for the summary mode line.
603 It works along the same lines as a normal formatting string,
604 with some simple extensions:
607 %p Unprefixed group name
608 %A Current article number
609 %z Current article score
611 %U Number of unread articles in the group
612 %e Number of unselected articles in the group
613 %Z A string with unread/unselected article counts
614 %g Shortish group name
615 %S Subject of the current article
617 %s Current score file name
618 %d Number of dormant articles
619 %r Number of articles that have been marked as read in this session
620 %E Number of articles expunged by the score files"
621 :group 'gnus-summary-format
624 (defcustom gnus-list-identifiers nil
625 "Regexp that matches list identifiers to be removed from subject.
626 This can also be a list of regexps."
628 :group 'gnus-summary-format
629 :group 'gnus-article-hiding
630 :type '(choice (const :tag "none" nil)
632 (repeat :value (".*") regexp)))
634 (defcustom gnus-summary-mark-below 0
635 "*Mark all articles with a score below this variable as read.
636 This variable is local to each summary buffer and usually set by the
638 :group 'gnus-score-default
641 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
642 "*List of functions used for sorting articles in the summary buffer.
644 Each function takes two articles and returns non-nil if the first
645 article should be sorted before the other. If you use more than one
646 function, the primary sort function should be the last. You should
647 probably always include `gnus-article-sort-by-number' in the list of
648 sorting functions -- preferably first. Also note that sorting by date
649 is often much slower than sorting by number, and the sorting order is
650 very similar. (Sorting by date means sorting by the time the message
651 was sent, sorting by number means sorting by arrival time.)
653 Ready-made functions include `gnus-article-sort-by-number',
654 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
655 `gnus-article-sort-by-date' and `gnus-article-sort-by-score'.
657 When threading is turned on, the variable `gnus-thread-sort-functions'
658 controls how articles are sorted."
659 :group 'gnus-summary-sort
660 :type '(repeat (choice (function-item gnus-article-sort-by-number)
661 (function-item gnus-article-sort-by-author)
662 (function-item gnus-article-sort-by-subject)
663 (function-item gnus-article-sort-by-date)
664 (function-item gnus-article-sort-by-score)
665 (function :tag "other"))))
667 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
668 "*List of functions used for sorting threads in the summary buffer.
669 By default, threads are sorted by article number.
671 Each function takes two threads and returns non-nil if the first
672 thread should be sorted before the other. If you use more than one
673 function, the primary sort function should be the last. You should
674 probably always include `gnus-thread-sort-by-number' in the list of
675 sorting functions -- preferably first. Also note that sorting by date
676 is often much slower than sorting by number, and the sorting order is
677 very similar. (Sorting by date means sorting by the time the message
678 was sent, sorting by number means sorting by arrival time.)
680 Ready-made functions include `gnus-thread-sort-by-number',
681 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
682 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
683 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
685 When threading is turned off, the variable
686 `gnus-article-sort-functions' controls how articles are sorted."
687 :group 'gnus-summary-sort
688 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
689 (function-item gnus-thread-sort-by-author)
690 (function-item gnus-thread-sort-by-subject)
691 (function-item gnus-thread-sort-by-date)
692 (function-item gnus-thread-sort-by-score)
693 (function-item gnus-thread-sort-by-total-score)
694 (function :tag "other"))))
696 (defcustom gnus-thread-score-function '+
697 "*Function used for calculating the total score of a thread.
699 The function is called with the scores of the article and each
700 subthread and should then return the score of the thread.
702 Some functions you can use are `+', `max', or `min'."
703 :group 'gnus-summary-sort
706 (defcustom gnus-summary-expunge-below nil
707 "All articles that have a score less than this variable will be expunged.
708 This variable is local to the summary buffers."
709 :group 'gnus-score-default
710 :type '(choice (const :tag "off" nil)
713 (defcustom gnus-thread-expunge-below nil
714 "All threads that have a total score less than this variable will be expunged.
715 See `gnus-thread-score-function' for en explanation of what a
718 This variable is local to the summary buffers."
719 :group 'gnus-threading
720 :group 'gnus-score-default
721 :type '(choice (const :tag "off" nil)
724 (defcustom gnus-summary-mode-hook nil
725 "*A hook for Gnus summary mode.
726 This hook is run before any variables are set in the summary buffer."
727 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
728 :group 'gnus-summary-various
731 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
732 (when (featurep 'xemacs)
733 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
734 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
735 (add-hook 'gnus-summary-mode-hook
736 'gnus-xmas-switch-horizontal-scrollbar-off))
738 (defcustom gnus-summary-menu-hook nil
739 "*Hook run after the creation of the summary mode menu."
740 :group 'gnus-summary-visual
743 (defcustom gnus-summary-exit-hook nil
744 "*A hook called on exit from the summary buffer.
745 It will be called with point in the group buffer."
746 :group 'gnus-summary-exit
749 (defcustom gnus-summary-prepare-hook nil
750 "*A hook called after the summary buffer has been generated.
751 If you want to modify the summary buffer, you can use this hook."
752 :group 'gnus-summary-various
755 (defcustom gnus-summary-prepared-hook nil
756 "*A hook called as the last thing after the summary buffer has been generated."
757 :group 'gnus-summary-various
760 (defcustom gnus-summary-generate-hook nil
761 "*A hook run just before generating the summary buffer.
762 This hook is commonly used to customize threading variables and the
764 :group 'gnus-summary-various
767 (defcustom gnus-select-group-hook nil
768 "*A hook called when a newsgroup is selected.
770 If you'd like to simplify subjects like the
771 `gnus-summary-next-same-subject' command does, you can use the
774 (setq gnus-select-group-hook
777 (mapcar (lambda (header)
778 (mail-header-set-subject
780 (gnus-simplify-subject
781 (mail-header-subject header) 're-only)))
782 gnus-newsgroup-headers))))"
783 :group 'gnus-group-select
786 (defcustom gnus-select-article-hook nil
787 "*A hook called when an article is selected."
788 :group 'gnus-summary-choose
791 (defcustom gnus-visual-mark-article-hook
792 (list 'gnus-highlight-selected-summary)
793 "*Hook run after selecting an article in the summary buffer.
794 It is meant to be used for highlighting the article in some way. It
795 is not run if `gnus-visual' is nil."
796 :group 'gnus-summary-visual
799 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
800 "*A hook called before parsing the headers."
804 (defcustom gnus-exit-group-hook nil
805 "*A hook called when exiting summary mode.
806 This hook is not called from the non-updating exit commands like `Q'."
810 (defcustom gnus-summary-update-hook
811 (list 'gnus-summary-highlight-line)
812 "*A hook called when a summary line is changed.
813 The hook will not be called if `gnus-visual' is nil.
815 The default function `gnus-summary-highlight-line' will
816 highlight the line according to the `gnus-summary-highlight'
818 :group 'gnus-summary-visual
821 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
822 "*A hook called when an article is selected for the first time.
823 The hook is intended to mark an article as read (or unread)
824 automatically when it is selected."
825 :group 'gnus-summary-choose
828 (defcustom gnus-group-no-more-groups-hook nil
829 "*A hook run when returning to group mode having no more (unread) groups."
830 :group 'gnus-group-select
833 (defcustom gnus-ps-print-hook nil
834 "*A hook run before ps-printing something from Gnus."
838 (defcustom gnus-summary-display-arrow
839 (and (fboundp 'display-graphic-p)
841 "*If non-nil, display an arrow highlighting the current article."
846 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
847 "Face used for highlighting the current article in the summary buffer."
848 :group 'gnus-summary-visual
851 (defcustom gnus-summary-highlight
852 '(((= mark gnus-canceled-mark)
853 . gnus-summary-cancelled-face)
854 ((and (> score default-high)
855 (or (= mark gnus-dormant-mark)
856 (= mark gnus-ticked-mark)))
857 . gnus-summary-high-ticked-face)
858 ((and (< score default-low)
859 (or (= mark gnus-dormant-mark)
860 (= mark gnus-ticked-mark)))
861 . gnus-summary-low-ticked-face)
862 ((or (= mark gnus-dormant-mark)
863 (= mark gnus-ticked-mark))
864 . gnus-summary-normal-ticked-face)
865 ((and (> score default-high) (= mark gnus-ancient-mark))
866 . gnus-summary-high-ancient-face)
867 ((and (< score default-low) (= mark gnus-ancient-mark))
868 . gnus-summary-low-ancient-face)
869 ((= mark gnus-ancient-mark)
870 . gnus-summary-normal-ancient-face)
871 ((and (> score default-high) (= mark gnus-unread-mark))
872 . gnus-summary-high-unread-face)
873 ((and (< score default-low) (= mark gnus-unread-mark))
874 . gnus-summary-low-unread-face)
875 ((= mark gnus-unread-mark)
876 . gnus-summary-normal-unread-face)
877 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
878 gnus-undownloaded-mark)))
879 . gnus-summary-high-unread-face)
880 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
881 gnus-undownloaded-mark)))
882 . gnus-summary-low-unread-face)
883 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
884 (memq article gnus-newsgroup-unreads))
885 . gnus-summary-normal-unread-face)
886 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
887 . gnus-summary-normal-read-face)
888 ((> score default-high)
889 . gnus-summary-high-read-face)
890 ((< score default-low)
891 . gnus-summary-low-read-face)
893 . gnus-summary-normal-read-face))
894 "*Controls the highlighting of summary buffer lines.
896 A list of (FORM . FACE) pairs. When deciding how a a particular
897 summary line should be displayed, each form is evaluated. The content
898 of the face field after the first true form is used. You can change
899 how those summary lines are displayed, by editing the face field.
901 You can use the following variables in the FORM field.
903 score: The article's score
904 default: The default article score.
905 default-high: The default score for high scored articles.
906 default-low: The default score for low scored articles.
907 below: The score below which articles are automatically marked as read.
908 mark: The articles mark."
909 :group 'gnus-summary-visual
910 :type '(repeat (cons (sexp :tag "Form" nil)
913 (defcustom gnus-alter-header-function nil
914 "Function called to allow alteration of article header structures.
915 The function is called with one parameter, the article header vector,
916 which it may alter in any way.")
918 (defvar gnus-decode-encoded-word-function
919 (mime-find-field-decoder 'From 'nov)
920 "Variable that says which function should be used to decode a string with encoded words.")
922 (defcustom gnus-extra-headers nil
923 "*Extra headers to parse."
926 :type '(repeat symbol))
928 (defcustom gnus-ignored-from-addresses
929 (and user-mail-address (regexp-quote user-mail-address))
930 "*Regexp of From headers that may be suppressed in favor of To headers."
935 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
936 "List of charsets that should be ignored.
937 When these charsets are used in the \"charset\" parameter, the
938 default charset will be used instead."
940 :type '(repeat symbol)
941 :group 'gnus-charset)
943 (gnus-define-group-parameter
947 "Return the ignored charsets of GROUP."
948 :variable gnus-group-ignored-charsets-alist
950 '(("alt\\.chinese\\.text" iso-8859-1))
952 "Alist of regexps (to match group names) and charsets that should be ignored.
953 When these charsets are used in the \"charset\" parameter, the
954 default charset will be used instead."
955 :variable-group gnus-charset
956 :variable-type '(repeat (cons (regexp :tag "Group")
958 :parameter-type '(choice :tag "Ignored charsets"
961 :parameter-document "\
962 List of charsets that should be ignored.
964 When these charsets are used in the \"charset\" parameter, the
965 default charset will be used instead.")
967 (defcustom gnus-group-highlight-words-alist nil
968 "Alist of group regexps and highlight regexps.
969 This variable uses the same syntax as `gnus-emphasis-alist'."
971 :type '(repeat (cons (regexp :tag "Group")
972 (repeat (list (regexp :tag "Highlight regexp")
973 (number :tag "Group for entire word" 0)
974 (number :tag "Group for displayed part" 0)
976 gnus-emphasis-highlight-words)))))
977 :group 'gnus-summary-visual)
979 (defcustom gnus-use-wheel nil
980 "Use Intelli-mouse on summary movement"
982 :group 'gnus-summary-maneuvering)
984 (defcustom gnus-wheel-scroll-amount '(5 . 1)
985 "Amount to scroll messages by spinning the mouse wheel.
986 This is actually a cons cell, where the first item is the amount to scroll
987 on a normal wheel event, and the second is the amount to scroll when the
988 wheel is moved with the shift key depressed."
989 :type '(cons (integer :tag "Shift") integer)
990 :group 'gnus-summary-maneuvering)
992 (defcustom gnus-wheel-edge-resistance 2
993 "How hard it should be to change the current article
994 by moving the mouse over the edge of the article window."
996 :group 'gnus-summary-maneuvering)
998 (defcustom gnus-summary-show-article-charset-alist
1000 "Alist of number and charset.
1001 The article will be shown with the charset corresponding to the
1003 For example: ((1 . cn-gb-2312) (2 . big5))."
1005 :type '(repeat (cons (number :tag "Argument" 1)
1006 (symbol :tag "Charset")))
1007 :group 'gnus-charset)
1009 (defcustom gnus-preserve-marks t
1010 "Whether marks are preserved when moving, copying and respooling messages."
1013 :group 'gnus-summary-marks)
1015 (defcustom gnus-alter-articles-to-read-function nil
1016 "Function to be called to alter the list of articles to be selected."
1017 :type '(choice (const nil) function)
1018 :group 'gnus-summary)
1020 (defcustom gnus-orphan-score nil
1021 "*All orphans get this score added. Set in the score file."
1022 :group 'gnus-score-default
1023 :type '(choice (const nil)
1026 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1027 "*A regexp to match MIME parts when saving multiple parts of a message
1028 with gnus-summary-save-parts (X m). This regexp will be used by default
1029 when prompting the user for which type of files to save."
1030 :group 'gnus-summary
1034 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1035 "*A regexp to match MIME parts when saving multiple parts of a message
1036 with gnus-summary-save-parts (X m). This regexp will be used by default
1037 when prompting the user for which type of files to save."
1038 :group 'gnus-summary
1041 (defcustom gnus-read-all-available-headers nil
1042 "Whether Gnus should parse all headers made available to it.
1043 This is mostly relevant for slow backends where the user may
1044 wish to widen the summary buffer to include all headers
1045 that were fetched. Say, for nnultimate groups."
1046 :group 'gnus-summary
1047 :type '(choice boolean regexp))
1049 ;;; Internal variables
1051 (defvar gnus-summary-display-cache nil)
1052 (defvar gnus-article-mime-handles nil)
1053 (defvar gnus-article-decoded-p nil)
1054 (defvar gnus-article-charset nil)
1055 (defvar gnus-article-ignored-charsets nil)
1056 (defvar gnus-scores-exclude-files nil)
1057 (defvar gnus-page-broken nil)
1058 (defvar gnus-inhibit-mime-unbuttonizing nil)
1060 (defvar gnus-original-article nil)
1061 (defvar gnus-article-internal-prepare-hook nil)
1062 (defvar gnus-newsgroup-process-stack nil)
1064 (defvar gnus-thread-indent-array nil)
1065 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1066 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1067 "Function called to sort the articles within a thread after it has been gathered together.")
1069 (defvar gnus-summary-save-parts-type-history nil)
1070 (defvar gnus-summary-save-parts-last-directory nil)
1072 (defvar gnus-summary-save-parts-type-history nil)
1073 (defvar gnus-summary-save-parts-last-directory nil)
1075 ;; Avoid highlighting in kill files.
1076 (defvar gnus-summary-inhibit-highlight nil)
1077 (defvar gnus-newsgroup-selected-overlay nil)
1078 (defvar gnus-inhibit-limiting nil)
1079 (defvar gnus-newsgroup-adaptive-score-file nil)
1080 (defvar gnus-current-score-file nil)
1081 (defvar gnus-current-move-group nil)
1082 (defvar gnus-current-copy-group nil)
1083 (defvar gnus-current-crosspost-group nil)
1084 (defvar gnus-newsgroup-display nil)
1086 (defvar gnus-newsgroup-dependencies nil)
1087 (defvar gnus-newsgroup-adaptive nil)
1088 (defvar gnus-summary-display-article-function nil)
1089 (defvar gnus-summary-highlight-line-function nil
1090 "Function called after highlighting a summary line.")
1092 (defvar gnus-summary-line-format-alist
1093 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1094 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1095 (?s gnus-tmp-subject-or-nil ?s)
1096 (?n gnus-tmp-name ?s)
1097 (?A (std11-address-string
1098 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1099 (?a (or (std11-full-name-string
1100 (car (mime-entity-read-field gnus-tmp-header 'From)))
1102 (?F gnus-tmp-from ?s)
1103 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1104 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1105 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1106 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1107 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1108 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1109 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1110 (?L gnus-tmp-lines ?s)
1111 (?I gnus-tmp-indentation ?s)
1112 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1113 (?R gnus-tmp-replied ?c)
1114 (?\[ gnus-tmp-opening-bracket ?c)
1115 (?\] gnus-tmp-closing-bracket ?c)
1116 (?\> (make-string gnus-tmp-level ? ) ?s)
1117 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1118 (?i gnus-tmp-score ?d)
1119 (?z gnus-tmp-score-char ?c)
1120 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1121 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1122 (?U gnus-tmp-unread ?c)
1123 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1125 (?t (gnus-summary-number-of-articles-in-thread
1126 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1128 (?e (gnus-summary-number-of-articles-in-thread
1129 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1131 (?u gnus-tmp-user-defined ?s)
1132 (?P (gnus-pick-line-number) ?d)
1133 (?B gnus-tmp-thread-tree-header-string ?s)
1134 (user-date (gnus-user-date
1135 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1136 "An alist of format specifications that can appear in summary lines.
1137 These are paired with what variables they correspond with, along with
1138 the type of the variable (string, integer, character, etc).")
1140 (defvar gnus-summary-dummy-line-format-alist
1141 `((?S gnus-tmp-subject ?s)
1142 (?N gnus-tmp-number ?d)
1143 (?u gnus-tmp-user-defined ?s)))
1145 (defvar gnus-summary-mode-line-format-alist
1146 `((?G gnus-tmp-group-name ?s)
1147 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1148 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1149 (?A gnus-tmp-article-number ?d)
1150 (?Z gnus-tmp-unread-and-unselected ?s)
1151 (?V gnus-version ?s)
1152 (?U gnus-tmp-unread-and-unticked ?d)
1153 (?S gnus-tmp-subject ?s)
1154 (?e gnus-tmp-unselected ?d)
1155 (?u gnus-tmp-user-defined ?s)
1156 (?d (length gnus-newsgroup-dormant) ?d)
1157 (?t (length gnus-newsgroup-marked) ?d)
1158 (?r (length gnus-newsgroup-reads) ?d)
1159 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1160 (?E gnus-newsgroup-expunged-tally ?d)
1161 (?s (gnus-current-score-file-nondirectory) ?s)))
1163 (defvar gnus-last-search-regexp nil
1164 "Default regexp for article search command.")
1166 (defvar gnus-summary-search-article-matched-data nil
1167 "Last matched data of article search command. It is the local variable
1168 in `gnus-article-buffer' which consists of the list of start position,
1169 end position and text.")
1171 (defvar gnus-last-shell-command nil
1172 "Default shell command on article.")
1174 (defvar gnus-newsgroup-begin nil)
1175 (defvar gnus-newsgroup-end nil)
1176 (defvar gnus-newsgroup-last-rmail nil)
1177 (defvar gnus-newsgroup-last-mail nil)
1178 (defvar gnus-newsgroup-last-folder nil)
1179 (defvar gnus-newsgroup-last-file nil)
1180 (defvar gnus-newsgroup-auto-expire nil)
1181 (defvar gnus-newsgroup-active nil)
1183 (defvar gnus-newsgroup-data nil)
1184 (defvar gnus-newsgroup-data-reverse nil)
1185 (defvar gnus-newsgroup-limit nil)
1186 (defvar gnus-newsgroup-limits nil)
1188 (defvar gnus-newsgroup-unreads nil
1189 "List of unread articles in the current newsgroup.")
1191 (defvar gnus-newsgroup-unselected nil
1192 "List of unselected unread articles in the current newsgroup.")
1194 (defvar gnus-newsgroup-reads nil
1195 "Alist of read articles and article marks in the current newsgroup.")
1197 (defvar gnus-newsgroup-expunged-tally nil)
1199 (defvar gnus-newsgroup-marked nil
1200 "List of ticked articles in the current newsgroup (a subset of unread art).")
1202 (defvar gnus-newsgroup-killed nil
1203 "List of ranges of articles that have been through the scoring process.")
1205 (defvar gnus-newsgroup-cached nil
1206 "List of articles that come from the article cache.")
1208 (defvar gnus-newsgroup-saved nil
1209 "List of articles that have been saved.")
1211 (defvar gnus-newsgroup-kill-headers nil)
1213 (defvar gnus-newsgroup-replied nil
1214 "List of articles that have been replied to in the current newsgroup.")
1216 (defvar gnus-newsgroup-forwarded nil
1217 "List of articles that have been forwarded in the current newsgroup.")
1219 (defvar gnus-newsgroup-recent nil
1220 "List of articles that have are recent in the current newsgroup.")
1222 (defvar gnus-newsgroup-expirable nil
1223 "List of articles in the current newsgroup that can be expired.")
1225 (defvar gnus-newsgroup-processable nil
1226 "List of articles in the current newsgroup that can be processed.")
1228 (defvar gnus-newsgroup-downloadable nil
1229 "List of articles in the current newsgroup that can be processed.")
1231 (defvar gnus-newsgroup-undownloaded nil
1232 "List of articles in the current newsgroup that haven't been downloaded..")
1234 (defvar gnus-newsgroup-unsendable nil
1235 "List of articles in the current newsgroup that won't be sent.")
1237 (defvar gnus-newsgroup-bookmarks nil
1238 "List of articles in the current newsgroup that have bookmarks.")
1240 (defvar gnus-newsgroup-dormant nil
1241 "List of dormant articles in the current newsgroup.")
1243 (defvar gnus-newsgroup-unseen nil
1244 "List of unseen articles in the current newsgroup.")
1246 (defvar gnus-newsgroup-seen nil
1247 "Range of seen articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-articles nil
1250 "List of articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-scored nil
1253 "List of scored articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-incorporated nil
1256 "List of incorporated articles in the current newsgroup.")
1258 (defvar gnus-newsgroup-headers nil
1259 "List of article headers in the current newsgroup.")
1261 (defvar gnus-newsgroup-threads nil)
1263 (defvar gnus-newsgroup-prepared nil
1264 "Whether the current group has been prepared properly.")
1266 (defvar gnus-newsgroup-ancient nil
1267 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1269 (defvar gnus-newsgroup-sparse nil)
1271 (defvar gnus-current-article nil)
1272 (defvar gnus-article-current nil)
1273 (defvar gnus-current-headers nil)
1274 (defvar gnus-have-all-headers nil)
1275 (defvar gnus-last-article nil)
1276 (defvar gnus-newsgroup-history nil)
1277 (defvar gnus-newsgroup-charset nil)
1278 (defvar gnus-newsgroup-ephemeral-charset nil)
1279 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1281 (defvar gnus-article-before-search nil)
1283 (defconst gnus-summary-local-variables
1284 '(gnus-newsgroup-name
1285 gnus-newsgroup-begin gnus-newsgroup-end
1286 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1287 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1288 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1289 gnus-newsgroup-unselected gnus-newsgroup-marked
1290 gnus-newsgroup-reads gnus-newsgroup-saved
1291 gnus-newsgroup-replied gnus-newsgroup-forwarded
1292 gnus-newsgroup-recent
1293 gnus-newsgroup-expirable
1294 gnus-newsgroup-processable gnus-newsgroup-killed
1295 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1296 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1297 gnus-newsgroup-seen gnus-newsgroup-articles
1298 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1299 gnus-newsgroup-headers gnus-newsgroup-threads
1300 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1301 gnus-current-article gnus-current-headers gnus-have-all-headers
1302 gnus-last-article gnus-article-internal-prepare-hook
1303 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1304 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1305 gnus-thread-expunge-below
1306 gnus-score-alist gnus-current-score-file
1307 (gnus-summary-expunge-below . global)
1308 (gnus-summary-mark-below . global)
1309 (gnus-orphan-score . global)
1310 gnus-newsgroup-active gnus-scores-exclude-files
1311 gnus-newsgroup-history gnus-newsgroup-ancient
1312 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1313 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1314 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1315 (gnus-newsgroup-expunged-tally . 0)
1316 gnus-cache-removable-articles gnus-newsgroup-cached
1317 gnus-newsgroup-data gnus-newsgroup-data-reverse
1318 gnus-newsgroup-limit gnus-newsgroup-limits
1319 gnus-newsgroup-charset gnus-newsgroup-display
1320 gnus-newsgroup-incorporated)
1321 "Variables that are buffer-local to the summary buffers.")
1323 (defvar gnus-newsgroup-variables nil
1324 "A list of variables that have separate values in different newsgroups.
1325 A list of newsgroup (summary buffer) local variables, or cons of
1326 variables and their default values (when the default values are not
1327 nil), that should be made global while the summary buffer is active.
1328 These variables can be used to set variables in the group parameters
1329 while still allowing them to affect operations done in other
1330 buffers. For example:
1332 (setq gnus-newsgroup-variables
1333 '(message-use-followup-to
1334 (gnus-visible-headers .
1335 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1338 ;; Byte-compiler warning.
1339 (eval-when-compile (defvar gnus-article-mode-map))
1341 ;; Subject simplification.
1343 (defun gnus-simplify-whitespace (str)
1344 "Remove excessive whitespace from STR."
1347 (while (string-match "[ \t][ \t]+" mystr)
1348 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1350 (substring mystr (match-end 0)))))
1352 (when (string-match "^[ \t]+" mystr)
1353 (setq mystr (substring mystr (match-end 0))))
1355 (when (string-match "[ \t]+$" mystr)
1356 (setq mystr (substring mystr 0 (match-beginning 0))))
1359 (defsubst gnus-simplify-subject-re (subject)
1360 "Remove \"Re:\" from subject lines."
1361 (if (string-match message-subject-re-regexp subject)
1362 (substring subject (match-end 0))
1365 (defun gnus-simplify-subject (subject &optional re-only)
1366 "Remove `Re:' and words in parentheses.
1367 If RE-ONLY is non-nil, strip leading `Re:'s only."
1368 (let ((case-fold-search t)) ;Ignore case.
1369 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1370 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1371 (setq subject (substring subject (match-end 0))))
1372 ;; Remove uninteresting prefixes.
1373 (when (and (not re-only)
1374 gnus-simplify-ignored-prefixes
1375 (string-match gnus-simplify-ignored-prefixes subject))
1376 (setq subject (substring subject (match-end 0))))
1377 ;; Remove words in parentheses from end.
1379 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1380 (setq subject (substring subject 0 (match-beginning 0)))))
1381 ;; Return subject string.
1384 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1386 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1387 (goto-char (point-min))
1388 (while (re-search-forward regexp nil t)
1389 (replace-match (or newtext ""))))
1391 (defun gnus-simplify-buffer-fuzzy ()
1392 "Simplify string in the buffer fuzzily.
1393 The string in the accessible portion of the current buffer is simplified.
1394 It is assumed to be a single-line subject.
1395 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1396 matter is removed. Additional things can be deleted by setting
1397 `gnus-simplify-subject-fuzzy-regexp'."
1398 (let ((case-fold-search t)
1400 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1402 (while (not (eq modified-tick (buffer-modified-tick)))
1403 (setq modified-tick (buffer-modified-tick))
1405 ((listp gnus-simplify-subject-fuzzy-regexp)
1406 (mapcar 'gnus-simplify-buffer-fuzzy-step
1407 gnus-simplify-subject-fuzzy-regexp))
1408 (gnus-simplify-subject-fuzzy-regexp
1409 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1410 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1411 (gnus-simplify-buffer-fuzzy-step
1412 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1413 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1415 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1416 (gnus-simplify-buffer-fuzzy-step " +" " ")
1417 (gnus-simplify-buffer-fuzzy-step " $")
1418 (gnus-simplify-buffer-fuzzy-step "^ +")))
1420 (defun gnus-simplify-subject-fuzzy (subject)
1421 "Simplify a subject string fuzzily.
1422 See `gnus-simplify-buffer-fuzzy' for details."
1424 (gnus-set-work-buffer)
1425 (let ((case-fold-search t))
1426 ;; Remove uninteresting prefixes.
1427 (when (and gnus-simplify-ignored-prefixes
1428 (string-match gnus-simplify-ignored-prefixes subject))
1429 (setq subject (substring subject (match-end 0))))
1431 (inline (gnus-simplify-buffer-fuzzy))
1434 (defsubst gnus-simplify-subject-fully (subject)
1435 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1437 (gnus-simplify-subject-functions
1438 (gnus-map-function gnus-simplify-subject-functions subject))
1439 ((null gnus-summary-gather-subject-limit)
1440 (gnus-simplify-subject-re subject))
1441 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1442 (gnus-simplify-subject-fuzzy subject))
1443 ((numberp gnus-summary-gather-subject-limit)
1444 (gnus-limit-string (gnus-simplify-subject-re subject)
1445 gnus-summary-gather-subject-limit))
1449 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1450 "Check whether two subjects are equal.
1451 If optional argument simple-first is t, first argument is already
1454 ((null simple-first)
1455 (equal (gnus-simplify-subject-fully s1)
1456 (gnus-simplify-subject-fully s2)))
1459 (gnus-simplify-subject-fully s2)))))
1461 (defun gnus-summary-bubble-group ()
1462 "Increase the score of the current group.
1463 This is a handy function to add to `gnus-summary-exit-hook' to
1464 increase the score of each group you read."
1465 (gnus-group-add-score gnus-newsgroup-name))
1469 ;;; Gnus summary mode
1472 (put 'gnus-summary-mode 'mode-class 'special)
1474 (defvar gnus-article-commands-menu)
1477 ;; Non-orthogonal keys
1479 (gnus-define-keys gnus-summary-mode-map
1480 " " gnus-summary-next-page
1481 "\177" gnus-summary-prev-page
1482 [delete] gnus-summary-prev-page
1483 [backspace] gnus-summary-prev-page
1484 "\r" gnus-summary-scroll-up
1485 "\M-\r" gnus-summary-scroll-down
1486 "n" gnus-summary-next-unread-article
1487 "p" gnus-summary-prev-unread-article
1488 "N" gnus-summary-next-article
1489 "P" gnus-summary-prev-article
1490 "\M-\C-n" gnus-summary-next-same-subject
1491 "\M-\C-p" gnus-summary-prev-same-subject
1492 "\M-n" gnus-summary-next-unread-subject
1493 "\M-p" gnus-summary-prev-unread-subject
1494 "." gnus-summary-first-unread-article
1495 "," gnus-summary-best-unread-article
1496 "\M-s" gnus-summary-search-article-forward
1497 "\M-r" gnus-summary-search-article-backward
1498 "<" gnus-summary-beginning-of-article
1499 ">" gnus-summary-end-of-article
1500 "j" gnus-summary-goto-article
1501 "^" gnus-summary-refer-parent-article
1502 "\M-^" gnus-summary-refer-article
1503 "u" gnus-summary-tick-article-forward
1504 "!" gnus-summary-tick-article-forward
1505 "U" gnus-summary-tick-article-backward
1506 "d" gnus-summary-mark-as-read-forward
1507 "D" gnus-summary-mark-as-read-backward
1508 "E" gnus-summary-mark-as-expirable
1509 "\M-u" gnus-summary-clear-mark-forward
1510 "\M-U" gnus-summary-clear-mark-backward
1511 "k" gnus-summary-kill-same-subject-and-select
1512 "\C-k" gnus-summary-kill-same-subject
1513 "\M-\C-k" gnus-summary-kill-thread
1514 "\M-\C-l" gnus-summary-lower-thread
1515 "e" gnus-summary-edit-article
1516 "#" gnus-summary-mark-as-processable
1517 "\M-#" gnus-summary-unmark-as-processable
1518 "\M-\C-t" gnus-summary-toggle-threads
1519 "\M-\C-s" gnus-summary-show-thread
1520 "\M-\C-h" gnus-summary-hide-thread
1521 "\M-\C-f" gnus-summary-next-thread
1522 "\M-\C-b" gnus-summary-prev-thread
1523 [(meta down)] gnus-summary-next-thread
1524 [(meta up)] gnus-summary-prev-thread
1525 "\M-\C-u" gnus-summary-up-thread
1526 "\M-\C-d" gnus-summary-down-thread
1527 "&" gnus-summary-execute-command
1528 "c" gnus-summary-catchup-and-exit
1529 "\C-w" gnus-summary-mark-region-as-read
1530 "\C-t" gnus-summary-toggle-truncation
1531 "?" gnus-summary-mark-as-dormant
1532 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1533 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1534 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1535 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1536 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1537 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1538 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1539 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1540 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1541 "=" gnus-summary-expand-window
1542 "\C-x\C-s" gnus-summary-reselect-current-group
1543 "\M-g" gnus-summary-rescan-group
1544 "w" gnus-summary-stop-page-breaking
1545 "\C-c\C-r" gnus-summary-caesar-message
1546 "\M-t" gnus-summary-toggle-mime
1547 "f" gnus-summary-followup
1548 "F" gnus-summary-followup-with-original
1549 "C" gnus-summary-cancel-article
1550 "r" gnus-summary-reply
1551 "R" gnus-summary-reply-with-original
1552 "\C-c\C-f" gnus-summary-mail-forward
1553 "o" gnus-summary-save-article
1554 "\C-o" gnus-summary-save-article-mail
1555 "|" gnus-summary-pipe-output
1556 "\M-k" gnus-summary-edit-local-kill
1557 "\M-K" gnus-summary-edit-global-kill
1559 "\C-c\C-d" gnus-summary-describe-group
1560 "q" gnus-summary-exit
1561 "Q" gnus-summary-exit-no-update
1562 "\C-c\C-i" gnus-info-find-node
1563 gnus-mouse-2 gnus-mouse-pick-article
1564 "m" gnus-summary-mail-other-window
1565 "a" gnus-summary-post-news
1566 "x" gnus-summary-limit-to-unread
1567 "s" gnus-summary-isearch-article
1568 "t" gnus-article-toggle-headers
1569 "g" gnus-summary-show-article
1570 "l" gnus-summary-goto-last-article
1571 "v" gnus-summary-preview-mime-message
1572 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1573 "\C-d" gnus-summary-enter-digest-group
1574 "\M-\C-d" gnus-summary-read-document
1575 "\M-\C-e" gnus-summary-edit-parameters
1576 "\M-\C-a" gnus-summary-customize-parameters
1578 "\C-c\C-n" gnus-namazu-search
1579 "*" gnus-cache-enter-article
1580 "\M-*" gnus-cache-remove-article
1581 "\M-&" gnus-summary-universal-argument
1582 "\C-l" gnus-recenter
1583 "I" gnus-summary-increase-score
1584 "L" gnus-summary-lower-score
1585 "\M-i" gnus-symbolic-argument
1586 "h" gnus-summary-select-article-buffer
1588 "V" gnus-summary-score-map
1589 "X" gnus-uu-extract-map
1590 "S" gnus-summary-send-map)
1592 ;; Sort of orthogonal keymap
1593 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1594 "t" gnus-summary-tick-article-forward
1595 "!" gnus-summary-tick-article-forward
1596 "d" gnus-summary-mark-as-read-forward
1597 "r" gnus-summary-mark-as-read-forward
1598 "c" gnus-summary-clear-mark-forward
1599 " " gnus-summary-clear-mark-forward
1600 "e" gnus-summary-mark-as-expirable
1601 "x" gnus-summary-mark-as-expirable
1602 "?" gnus-summary-mark-as-dormant
1603 "b" gnus-summary-set-bookmark
1604 "B" gnus-summary-remove-bookmark
1605 "#" gnus-summary-mark-as-processable
1606 "\M-#" gnus-summary-unmark-as-processable
1607 "S" gnus-summary-limit-include-expunged
1608 "C" gnus-summary-catchup
1609 "H" gnus-summary-catchup-to-here
1610 "h" gnus-summary-catchup-from-here
1611 "\C-c" gnus-summary-catchup-all
1612 "k" gnus-summary-kill-same-subject-and-select
1613 "K" gnus-summary-kill-same-subject
1614 "P" gnus-uu-mark-map)
1616 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1617 "c" gnus-summary-clear-above
1618 "u" gnus-summary-tick-above
1619 "m" gnus-summary-mark-above
1620 "k" gnus-summary-kill-below)
1622 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1623 "/" gnus-summary-limit-to-subject
1624 "n" gnus-summary-limit-to-articles
1625 "w" gnus-summary-pop-limit
1626 "s" gnus-summary-limit-to-subject
1627 "a" gnus-summary-limit-to-author
1628 "u" gnus-summary-limit-to-unread
1629 "m" gnus-summary-limit-to-marks
1630 "M" gnus-summary-limit-exclude-marks
1631 "v" gnus-summary-limit-to-score
1632 "*" gnus-summary-limit-include-cached
1633 "D" gnus-summary-limit-include-dormant
1634 "T" gnus-summary-limit-include-thread
1635 "d" gnus-summary-limit-exclude-dormant
1636 "t" gnus-summary-limit-to-age
1637 "x" gnus-summary-limit-to-extra
1638 "p" gnus-summary-limit-to-display-predicate
1639 "E" gnus-summary-limit-include-expunged
1640 "c" gnus-summary-limit-exclude-childless-dormant
1641 "C" gnus-summary-limit-mark-excluded-as-read
1642 "o" gnus-summary-insert-old-articles
1643 "N" gnus-summary-insert-new-articles)
1645 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1646 "n" gnus-summary-next-unread-article
1647 "p" gnus-summary-prev-unread-article
1648 "N" gnus-summary-next-article
1649 "P" gnus-summary-prev-article
1650 "\C-n" gnus-summary-next-same-subject
1651 "\C-p" gnus-summary-prev-same-subject
1652 "\M-n" gnus-summary-next-unread-subject
1653 "\M-p" gnus-summary-prev-unread-subject
1654 "f" gnus-summary-first-unread-article
1655 "b" gnus-summary-best-unread-article
1656 "j" gnus-summary-goto-article
1657 "g" gnus-summary-goto-subject
1658 "l" gnus-summary-goto-last-article
1659 "o" gnus-summary-pop-article)
1661 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1662 "k" gnus-summary-kill-thread
1663 "l" gnus-summary-lower-thread
1664 "i" gnus-summary-raise-thread
1665 "T" gnus-summary-toggle-threads
1666 "t" gnus-summary-rethread-current
1667 "^" gnus-summary-reparent-thread
1668 "s" gnus-summary-show-thread
1669 "S" gnus-summary-show-all-threads
1670 "h" gnus-summary-hide-thread
1671 "H" gnus-summary-hide-all-threads
1672 "n" gnus-summary-next-thread
1673 "p" gnus-summary-prev-thread
1674 "u" gnus-summary-up-thread
1675 "o" gnus-summary-top-thread
1676 "d" gnus-summary-down-thread
1677 "#" gnus-uu-mark-thread
1678 "\M-#" gnus-uu-unmark-thread)
1680 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1681 "g" gnus-summary-prepare
1682 "c" gnus-summary-insert-cached-articles)
1684 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1685 "c" gnus-summary-catchup-and-exit
1686 "C" gnus-summary-catchup-all-and-exit
1687 "E" gnus-summary-exit-no-update
1688 "J" gnus-summary-jump-to-other-group
1689 "Q" gnus-summary-exit
1690 "Z" gnus-summary-exit
1691 "n" gnus-summary-catchup-and-goto-next-group
1692 "R" gnus-summary-reselect-current-group
1693 "G" gnus-summary-rescan-group
1694 "N" gnus-summary-next-group
1695 "s" gnus-summary-save-newsrc
1696 "P" gnus-summary-prev-group)
1698 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1699 " " gnus-summary-next-page
1700 "n" gnus-summary-next-page
1701 "\177" gnus-summary-prev-page
1702 [delete] gnus-summary-prev-page
1703 "p" gnus-summary-prev-page
1704 "\r" gnus-summary-scroll-up
1705 "\M-\r" gnus-summary-scroll-down
1706 "<" gnus-summary-beginning-of-article
1707 ">" gnus-summary-end-of-article
1708 "b" gnus-summary-beginning-of-article
1709 "e" gnus-summary-end-of-article
1710 "^" gnus-summary-refer-parent-article
1711 "r" gnus-summary-refer-parent-article
1712 "D" gnus-summary-enter-digest-group
1713 "R" gnus-summary-refer-references
1714 "T" gnus-summary-refer-thread
1715 "g" gnus-summary-show-article
1716 "s" gnus-summary-isearch-article
1717 "P" gnus-summary-print-article
1718 "M" gnus-mailing-list-insinuate
1719 "t" gnus-article-babel)
1721 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1722 "b" gnus-article-add-buttons
1723 "B" gnus-article-add-buttons-to-head
1724 "o" gnus-article-treat-overstrike
1725 "e" gnus-article-emphasize
1726 "w" gnus-article-fill-cited-article
1727 "Q" gnus-article-fill-long-lines
1728 "C" gnus-article-capitalize-sentences
1729 "c" gnus-article-remove-cr
1730 "Z" gnus-article-decode-HZ
1731 "f" gnus-article-display-x-face
1732 "l" gnus-summary-stop-page-breaking
1733 "r" gnus-summary-caesar-message
1734 "t" gnus-article-toggle-headers
1735 "g" gnus-summary-toggle-smiley
1736 "v" gnus-summary-verbose-headers
1737 "m" gnus-summary-toggle-mime
1738 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1739 "p" gnus-article-verify-x-pgp-sig
1740 "d" gnus-article-treat-dumbquotes)
1742 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1743 "a" gnus-article-hide
1744 "h" gnus-article-toggle-headers
1745 "b" gnus-article-hide-boring-headers
1746 "s" gnus-article-hide-signature
1747 "c" gnus-article-hide-citation
1748 "C" gnus-article-hide-citation-in-followups
1749 "l" gnus-article-hide-list-identifiers
1750 "p" gnus-article-hide-pgp
1751 "B" gnus-article-strip-banner
1752 "P" gnus-article-hide-pem
1753 "\C-c" gnus-article-hide-citation-maybe)
1755 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1756 "a" gnus-article-highlight
1757 "h" gnus-article-highlight-headers
1758 "c" gnus-article-highlight-citation
1759 "s" gnus-article-highlight-signature)
1761 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1762 "z" gnus-article-date-ut
1763 "u" gnus-article-date-ut
1764 "l" gnus-article-date-local
1765 "p" gnus-article-date-english
1766 "e" gnus-article-date-lapsed
1767 "o" gnus-article-date-original
1768 "i" gnus-article-date-iso8601
1769 "s" gnus-article-date-user)
1771 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1772 "t" gnus-article-remove-trailing-blank-lines
1773 "l" gnus-article-strip-leading-blank-lines
1774 "m" gnus-article-strip-multiple-blank-lines
1775 "a" gnus-article-strip-blank-lines
1776 "A" gnus-article-strip-all-blank-lines
1777 "s" gnus-article-strip-leading-space
1778 "e" gnus-article-strip-trailing-space
1779 "w" gnus-article-remove-leading-whitespace)
1781 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1783 "f" gnus-summary-fetch-faq
1784 "d" gnus-summary-describe-group
1785 "h" gnus-summary-describe-briefly
1786 "i" gnus-info-find-node)
1788 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1789 "e" gnus-summary-expire-articles
1790 "\M-\C-e" gnus-summary-expire-articles-now
1791 "\177" gnus-summary-delete-article
1792 [delete] gnus-summary-delete-article
1793 [backspace] gnus-summary-delete-article
1794 "m" gnus-summary-move-article
1795 "r" gnus-summary-respool-article
1796 "w" gnus-summary-edit-article
1797 "c" gnus-summary-copy-article
1798 "B" gnus-summary-crosspost-article
1799 "q" gnus-summary-respool-query
1800 "t" gnus-summary-respool-trace
1801 "i" gnus-summary-import-article
1802 "I" gnus-summary-create-article
1803 "p" gnus-summary-article-posted-p)
1805 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1806 "o" gnus-summary-save-article
1807 "m" gnus-summary-save-article-mail
1808 "F" gnus-summary-write-article-file
1809 "r" gnus-summary-save-article-rmail
1810 "f" gnus-summary-save-article-file
1811 "b" gnus-summary-save-article-body-file
1812 "h" gnus-summary-save-article-folder
1813 "v" gnus-summary-save-article-vm
1814 "p" gnus-summary-pipe-output
1815 "s" gnus-soup-add-article)
1817 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1818 "b" gnus-summary-display-buttonized
1819 "m" gnus-summary-repair-multipart
1820 "v" gnus-article-view-part
1821 "o" gnus-article-save-part
1822 "c" gnus-article-copy-part
1823 "C" gnus-article-view-part-as-charset
1824 "e" gnus-article-externalize-part
1825 "E" gnus-article-encrypt-body
1826 "i" gnus-article-inline-part
1827 "|" gnus-article-pipe-part))
1829 (defvar gnus-article-post-menu nil)
1831 (defun gnus-summary-make-menu-bar ()
1832 (gnus-turn-off-edit-menu 'summary)
1834 (unless (boundp 'gnus-summary-misc-menu)
1837 gnus-summary-kill-menu gnus-summary-mode-map ""
1842 ["Customize" gnus-score-customize t])
1843 (gnus-make-score-map 'increase)
1844 (gnus-make-score-map 'lower)
1846 ["Kill below" gnus-summary-kill-below t]
1847 ["Mark above" gnus-summary-mark-above t]
1848 ["Tick above" gnus-summary-tick-above t]
1849 ["Clear above" gnus-summary-clear-above t])
1850 ["Current score" gnus-summary-current-score t]
1851 ["Set score" gnus-summary-set-score t]
1852 ["Switch current score file..." gnus-score-change-score-file t]
1853 ["Set mark below..." gnus-score-set-mark-below t]
1854 ["Set expunge below..." gnus-score-set-expunge-below t]
1855 ["Edit current score file" gnus-score-edit-current-scores t]
1856 ["Edit score file" gnus-score-edit-file t]
1857 ["Trace score" gnus-score-find-trace t]
1858 ["Find words" gnus-score-find-favourite-words t]
1859 ["Rescore buffer" gnus-summary-rescore t]
1860 ["Increase score..." gnus-summary-increase-score t]
1861 ["Lower score..." gnus-summary-lower-score t]))))
1863 ;; Define both the Article menu in the summary buffer and the equivalent
1864 ;; Commands menu in the article buffer here for consistency.
1867 ["All" gnus-article-hide t]
1868 ["Headers" gnus-article-toggle-headers t]
1869 ["Signature" gnus-article-hide-signature t]
1870 ["Citation" gnus-article-hide-citation t]
1871 ["List identifiers" gnus-article-hide-list-identifiers t]
1872 ["PGP" gnus-article-hide-pgp t]
1873 ["Banner" gnus-article-strip-banner t]
1874 ["Boring headers" gnus-article-hide-boring-headers t])
1876 ["All" gnus-article-highlight t]
1877 ["Headers" gnus-article-highlight-headers t]
1878 ["Signature" gnus-article-highlight-signature t]
1879 ["Citation" gnus-article-highlight-citation t])
1881 ["Local" gnus-article-date-local t]
1882 ["ISO8601" gnus-article-date-iso8601 t]
1883 ["UT" gnus-article-date-ut t]
1884 ["Original" gnus-article-date-original t]
1885 ["Lapsed" gnus-article-date-lapsed t]
1886 ["User-defined" gnus-article-date-user t])
1889 ["Leading" gnus-article-strip-leading-blank-lines t]
1890 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1891 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1892 ["All of the above" gnus-article-strip-blank-lines t]
1893 ["All" gnus-article-strip-all-blank-lines t]
1894 ["Leading space" gnus-article-strip-leading-space t]
1895 ["Trailing space" gnus-article-strip-trailing-space t]
1896 ["Leading space in headers"
1897 gnus-article-remove-leading-whitespace t])
1898 ["Overstrike" gnus-article-treat-overstrike t]
1899 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1900 ["Emphasis" gnus-article-emphasize t]
1901 ["Word wrap" gnus-article-fill-cited-article t]
1902 ["Fill long lines" gnus-article-fill-long-lines t]
1903 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1904 ["CR" gnus-article-remove-cr t]
1905 ["Show X-Face" gnus-article-display-x-face t]
1906 ["Rot 13" gnus-summary-caesar-message
1907 ,@(if (featurep 'xemacs) '(t)
1908 '(:help "\"Caesar rotate\" article by 13"))]
1909 ["Unix pipe" gnus-summary-pipe-message t]
1910 ["Add buttons" gnus-article-add-buttons t]
1911 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1912 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1913 ["Toggle MIME" gnus-summary-toggle-mime t]
1914 ["Verbose header" gnus-summary-verbose-headers t]
1915 ["Toggle header" gnus-summary-toggle-header t]
1916 ["Toggle smiley" gnus-summary-toggle-smiley t]
1917 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1918 ["HZ" gnus-article-decode-HZ t])
1920 ["Save in default format" gnus-summary-save-article
1921 ,@(if (featurep 'xemacs) '(t)
1922 '(:help "Save article using default method"))]
1923 ["Save in file" gnus-summary-save-article-file
1924 ,@(if (featurep 'xemacs) '(t)
1925 '(:help "Save article in file"))]
1926 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1927 ["Save in MH folder" gnus-summary-save-article-folder t]
1928 ["Save in VM folder" gnus-summary-save-article-vm t]
1929 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1930 ["Save body in file" gnus-summary-save-article-body-file t]
1931 ["Pipe through a filter" gnus-summary-pipe-output t]
1932 ["Add to SOUP packet" gnus-soup-add-article t]
1933 ["Print" gnus-summary-print-article t])
1935 ["Respool article..." gnus-summary-respool-article t]
1936 ["Move article..." gnus-summary-move-article
1937 (gnus-check-backend-function
1938 'request-move-article gnus-newsgroup-name)]
1939 ["Copy article..." gnus-summary-copy-article t]
1940 ["Crosspost article..." gnus-summary-crosspost-article
1941 (gnus-check-backend-function
1942 'request-replace-article gnus-newsgroup-name)]
1943 ["Import file..." gnus-summary-import-article t]
1944 ["Create article..." gnus-summary-create-article t]
1945 ["Check if posted" gnus-summary-article-posted-p t]
1946 ["Edit article" gnus-summary-edit-article
1947 (not (gnus-group-read-only-p))]
1948 ["Delete article" gnus-summary-delete-article
1949 (gnus-check-backend-function
1950 'request-expire-articles gnus-newsgroup-name)]
1951 ["Query respool" gnus-summary-respool-query t]
1952 ["Trace respool" gnus-summary-respool-trace t]
1953 ["Delete expirable articles" gnus-summary-expire-articles-now
1954 (gnus-check-backend-function
1955 'request-expire-articles gnus-newsgroup-name)])
1957 ["Uudecode" gnus-uu-decode-uu
1958 ,@(if (featurep 'xemacs) '(t)
1959 '(:help "Decode uuencoded article(s)"))]
1960 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1961 ["Unshar" gnus-uu-decode-unshar t]
1962 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1963 ["Save" gnus-uu-decode-save t]
1964 ["Binhex" gnus-uu-decode-binhex t]
1965 ["Postscript" gnus-uu-decode-postscript t])
1967 ["Enter article" gnus-cache-enter-article t]
1968 ["Remove article" gnus-cache-remove-article t])
1969 ["Translate" gnus-article-babel t]
1970 ["Select article buffer" gnus-summary-select-article-buffer t]
1971 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1972 ["Isearch article..." gnus-summary-isearch-article t]
1973 ["Beginning of the article" gnus-summary-beginning-of-article t]
1974 ["End of the article" gnus-summary-end-of-article t]
1975 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1976 ["Fetch referenced articles" gnus-summary-refer-references t]
1977 ["Fetch current thread" gnus-summary-refer-thread t]
1978 ["Fetch article with id..." gnus-summary-refer-article t]
1979 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1980 ["Redisplay" gnus-summary-show-article t]
1981 ["Raw article" gnus-summary-show-raw-article t])))
1983 gnus-summary-article-menu gnus-summary-mode-map ""
1984 (cons "Article" innards))
1986 (if (not (keymapp gnus-summary-article-menu))
1988 gnus-article-commands-menu gnus-article-mode-map ""
1989 (cons "Commands" innards))
1990 ;; in Emacs, don't share menu.
1991 (setq gnus-article-commands-menu
1992 (copy-keymap gnus-summary-article-menu))
1993 (define-key gnus-article-mode-map [menu-bar commands]
1994 (cons "Commands" gnus-article-commands-menu))))
1997 gnus-summary-thread-menu gnus-summary-mode-map ""
1999 ["Toggle threading" gnus-summary-toggle-threads t]
2000 ["Hide threads" gnus-summary-hide-all-threads t]
2001 ["Show threads" gnus-summary-show-all-threads t]
2002 ["Hide thread" gnus-summary-hide-thread t]
2003 ["Show thread" gnus-summary-show-thread t]
2004 ["Go to next thread" gnus-summary-next-thread t]
2005 ["Go to previous thread" gnus-summary-prev-thread t]
2006 ["Go down thread" gnus-summary-down-thread t]
2007 ["Go up thread" gnus-summary-up-thread t]
2008 ["Top of thread" gnus-summary-top-thread t]
2009 ["Mark thread as read" gnus-summary-kill-thread t]
2010 ["Lower thread score" gnus-summary-lower-thread t]
2011 ["Raise thread score" gnus-summary-raise-thread t]
2012 ["Rethread current" gnus-summary-rethread-current t]))
2015 gnus-summary-post-menu gnus-summary-mode-map ""
2017 ["Post an article" gnus-summary-post-news
2018 ,@(if (featurep 'xemacs) '(t)
2019 '(:help "Post an article"))]
2020 ["Followup" gnus-summary-followup
2021 ,@(if (featurep 'xemacs) '(t)
2022 '(:help "Post followup to this article"))]
2023 ["Followup and yank" gnus-summary-followup-with-original
2024 ,@(if (featurep 'xemacs) '(t)
2025 '(:help "Post followup to this article, quoting its contents"))]
2026 ["Supersede article" gnus-summary-supersede-article t]
2027 ["Cancel article" gnus-summary-cancel-article
2028 ,@(if (featurep 'xemacs) '(t)
2029 '(:help "Cancel an article you posted"))]
2030 ["Reply" gnus-summary-reply t]
2031 ["Reply and yank" gnus-summary-reply-with-original t]
2032 ["Wide reply" gnus-summary-wide-reply t]
2033 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2034 ,@(if (featurep 'xemacs) '(t)
2035 '(:help "Mail a reply, quoting this article"))]
2036 ["Mail forward" gnus-summary-mail-forward t]
2037 ["Post forward" gnus-summary-post-forward t]
2038 ["Digest and mail" gnus-summary-digest-mail-forward t]
2039 ["Digest and post" gnus-summary-digest-post-forward t]
2040 ["Resend message" gnus-summary-resend-message t]
2041 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2042 ["Send a mail" gnus-summary-mail-other-window t]
2043 ["Uuencode and post" gnus-uu-post-news
2044 ,@(if (featurep 'xemacs) '(t)
2045 '(:help "Post a uuencoded article"))]
2046 ["Followup via news" gnus-summary-followup-to-mail t]
2047 ["Followup via news and yank"
2048 gnus-summary-followup-to-mail-with-original t]
2050 ;;["Send" gnus-summary-send-draft t]
2051 ;;["Send bounced" gnus-resend-bounced-mail t])
2055 ((not (keymapp gnus-summary-post-menu))
2056 (setq gnus-article-post-menu gnus-summary-post-menu))
2057 ((not gnus-article-post-menu)
2058 ;; Don't share post menu.
2059 (setq gnus-article-post-menu
2060 (copy-keymap gnus-summary-post-menu))))
2061 (define-key gnus-article-mode-map [menu-bar post]
2062 (cons "Post" gnus-article-post-menu))
2065 gnus-summary-misc-menu gnus-summary-mode-map ""
2068 ["Mark as read" gnus-summary-mark-as-read-forward t]
2069 ["Mark same subject and select"
2070 gnus-summary-kill-same-subject-and-select t]
2071 ["Mark same subject" gnus-summary-kill-same-subject t]
2072 ["Catchup" gnus-summary-catchup
2073 ,@(if (featurep 'xemacs) '(t)
2074 '(:help "Mark unread articles in this group as read"))]
2075 ["Catchup all" gnus-summary-catchup-all t]
2076 ["Catchup to here" gnus-summary-catchup-to-here t]
2077 ["Catchup from here" gnus-summary-catchup-from-here t]
2078 ["Catchup region" gnus-summary-mark-region-as-read t]
2079 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2081 ["Tick" gnus-summary-tick-article-forward t]
2082 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2083 ["Remove marks" gnus-summary-clear-mark-forward t]
2084 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2085 ["Set bookmark" gnus-summary-set-bookmark t]
2086 ["Remove bookmark" gnus-summary-remove-bookmark t])
2088 ["Marks..." gnus-summary-limit-to-marks t]
2089 ["Subject..." gnus-summary-limit-to-subject t]
2090 ["Author..." gnus-summary-limit-to-author t]
2091 ["Age..." gnus-summary-limit-to-age t]
2092 ["Extra..." gnus-summary-limit-to-extra t]
2093 ["Score" gnus-summary-limit-to-score t]
2094 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2095 ["Unread" gnus-summary-limit-to-unread t]
2096 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2097 ["Articles" gnus-summary-limit-to-articles t]
2098 ["Pop limit" gnus-summary-pop-limit t]
2099 ["Show dormant" gnus-summary-limit-include-dormant t]
2100 ["Hide childless dormant"
2101 gnus-summary-limit-exclude-childless-dormant t]
2102 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2103 ["Hide marked" gnus-summary-limit-exclude-marks t]
2104 ["Show expunged" gnus-summary-limit-include-expunged t])
2106 ["Set mark" gnus-summary-mark-as-processable t]
2107 ["Remove mark" gnus-summary-unmark-as-processable t]
2108 ["Remove all marks" gnus-summary-unmark-all-processable t]
2109 ["Mark above" gnus-uu-mark-over t]
2110 ["Mark series" gnus-uu-mark-series t]
2111 ["Mark region" gnus-uu-mark-region t]
2112 ["Unmark region" gnus-uu-unmark-region t]
2113 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2114 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2115 ["Mark all" gnus-uu-mark-all t]
2116 ["Mark buffer" gnus-uu-mark-buffer t]
2117 ["Mark sparse" gnus-uu-mark-sparse t]
2118 ["Mark thread" gnus-uu-mark-thread t]
2119 ["Unmark thread" gnus-uu-unmark-thread t]
2120 ("Process Mark Sets"
2121 ["Kill" gnus-summary-kill-process-mark t]
2122 ["Yank" gnus-summary-yank-process-mark
2123 gnus-newsgroup-process-stack]
2124 ["Save" gnus-summary-save-process-mark t]))
2126 ["Page forward" gnus-summary-next-page
2127 ,@(if (featurep 'xemacs) '(t)
2128 '(:help "Show next page of article"))]
2129 ["Page backward" gnus-summary-prev-page
2130 ,@(if (featurep 'xemacs) '(t)
2131 '(:help "Show previous page of article"))]
2132 ["Line forward" gnus-summary-scroll-up t])
2134 ["Next unread article" gnus-summary-next-unread-article t]
2135 ["Previous unread article" gnus-summary-prev-unread-article t]
2136 ["Next article" gnus-summary-next-article t]
2137 ["Previous article" gnus-summary-prev-article t]
2138 ["Next unread subject" gnus-summary-next-unread-subject t]
2139 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2140 ["Next article same subject" gnus-summary-next-same-subject t]
2141 ["Previous article same subject" gnus-summary-prev-same-subject t]
2142 ["First unread article" gnus-summary-first-unread-article t]
2143 ["Best unread article" gnus-summary-best-unread-article t]
2144 ["Go to subject number..." gnus-summary-goto-subject t]
2145 ["Go to article number..." gnus-summary-goto-article t]
2146 ["Go to the last article" gnus-summary-goto-last-article t]
2147 ["Pop article off history" gnus-summary-pop-article t])
2149 ["Sort by number" gnus-summary-sort-by-number t]
2150 ["Sort by author" gnus-summary-sort-by-author t]
2151 ["Sort by subject" gnus-summary-sort-by-subject t]
2152 ["Sort by date" gnus-summary-sort-by-date t]
2153 ["Sort by score" gnus-summary-sort-by-score t]
2154 ["Sort by lines" gnus-summary-sort-by-lines t]
2155 ["Sort by characters" gnus-summary-sort-by-chars t]
2156 ["Original sort" gnus-summary-sort-by-original t])
2158 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2159 ["Describe group" gnus-summary-describe-group t]
2160 ["Read manual" gnus-info-find-node t])
2162 ["Pick and read" gnus-pick-mode t]
2163 ["Binary" gnus-binary-mode t])
2165 ["Regenerate" gnus-summary-prepare t]
2166 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2167 ["Toggle threading" gnus-summary-toggle-threads t])
2168 ["See old articles" gnus-summary-insert-old-articles t]
2169 ["See new articles" gnus-summary-insert-new-articles t]
2170 ["Filter articles..." gnus-summary-execute-command t]
2171 ["Run command on subjects..." gnus-summary-universal-argument t]
2172 ["Search articles forward..." gnus-summary-search-article-forward t]
2173 ["Search articles backward..." gnus-summary-search-article-backward t]
2174 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2175 ["Expand window" gnus-summary-expand-window t]
2176 ["Expire expirable articles" gnus-summary-expire-articles
2177 (gnus-check-backend-function
2178 'request-expire-articles gnus-newsgroup-name)]
2179 ["Edit local kill file" gnus-summary-edit-local-kill t]
2180 ["Edit main kill file" gnus-summary-edit-global-kill t]
2181 ["Edit group parameters" gnus-summary-edit-parameters t]
2182 ["Customize group parameters" gnus-summary-customize-parameters t]
2183 ["Send a bug report" gnus-bug t]
2185 ["Catchup and exit" gnus-summary-catchup-and-exit
2186 ,@(if (featurep 'xemacs) '(t)
2187 '(:help "Mark unread articles in this group as read, then exit"))]
2188 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2189 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2190 ["Exit group" gnus-summary-exit
2191 ,@(if (featurep 'xemacs) '(t)
2192 '(:help "Exit current group, return to group selection mode"))]
2193 ["Exit group without updating" gnus-summary-exit-no-update t]
2194 ["Exit and goto next group" gnus-summary-next-group t]
2195 ["Exit and goto prev group" gnus-summary-prev-group t]
2196 ["Reselect group" gnus-summary-reselect-current-group t]
2197 ["Rescan group" gnus-summary-rescan-group t]
2198 ["Update dribble" gnus-summary-save-newsrc t])))
2200 (gnus-run-hooks 'gnus-summary-menu-hook)))
2202 (defvar gnus-summary-tool-bar-map nil)
2204 ;; Emacs 21 tool bar. Should be no-op otherwise.
2205 (defun gnus-summary-make-tool-bar ()
2206 (if (and (fboundp 'tool-bar-add-item-from-menu)
2207 (default-value 'tool-bar-mode)
2208 (not gnus-summary-tool-bar-map))
2209 (setq gnus-summary-tool-bar-map
2210 (let ((tool-bar-map (make-sparse-keymap))
2211 (load-path (mm-image-load-path)))
2212 (tool-bar-add-item-from-menu
2213 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2214 (tool-bar-add-item-from-menu
2215 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-summary-post-news "post" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-summary-followup "followup" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2224 (tool-bar-add-item-from-menu
2225 'gnus-summary-reply "reply" gnus-summary-mode-map)
2226 (tool-bar-add-item-from-menu
2227 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2228 (tool-bar-add-item-from-menu
2229 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2230 (tool-bar-add-item-from-menu
2231 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2232 (tool-bar-add-item-from-menu
2233 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2234 (tool-bar-add-item-from-menu
2235 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2236 (tool-bar-add-item-from-menu
2237 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2238 (tool-bar-add-item-from-menu
2239 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2240 (tool-bar-add-item-from-menu
2241 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2243 (if gnus-summary-tool-bar-map
2244 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2246 (defun gnus-score-set-default (var value)
2247 "A version of set that updates the GNU Emacs menu-bar."
2249 ;; It is the message that forces the active status to be updated.
2252 (defun gnus-make-score-map (type)
2253 "Make a summary score map of type TYPE."
2256 (let ((headers '(("author" "from" string)
2257 ("subject" "subject" string)
2258 ("article body" "body" string)
2259 ("article head" "head" string)
2260 ("xref" "xref" string)
2261 ("extra header" "extra" string)
2262 ("lines" "lines" number)
2263 ("followups to author" "followup" string)))
2264 (types '((number ("less than" <)
2267 (string ("substring" s)
2271 (perms '(("temporary" (current-time-string))
2279 (if (eq type 'lower)
2284 (setq header (car headers))
2290 (let ((ts (cdr (assoc (nth 2 header) types)))
2306 'gnus-summary-score-entry
2308 (if (or (string= (nth 1 header)
2310 (string= (nth 1 header)
2313 (list 'gnus-summary-header
2315 (list 'quote (nth 1 (car ts)))
2316 (list 'gnus-score-delta-default
2323 (list (nreverse outp))))
2326 (list (nreverse outt))))
2328 (setq headers (cdr headers)))
2329 (list (nreverse outh))))))))
2333 (defun gnus-summary-mode (&optional group)
2334 "Major mode for reading articles.
2336 All normal editing commands are switched off.
2337 \\<gnus-summary-mode-map>
2338 Each line in this buffer represents one article. To read an
2339 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2340 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2343 You can also post articles and send mail from this buffer. To
2344 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2345 of an article, type `\\[gnus-summary-reply]'.
2347 There are approx. one gazillion commands you can execute in this
2348 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2350 The following commands are available:
2352 \\{gnus-summary-mode-map}"
2354 (kill-all-local-variables)
2355 (when (gnus-visual-p 'summary-menu 'menu)
2356 (gnus-summary-make-menu-bar)
2357 (gnus-summary-make-tool-bar))
2358 (gnus-summary-make-local-variables)
2359 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2360 (gnus-summary-make-local-variables))
2361 (gnus-make-thread-indent-array)
2362 (gnus-simplify-mode-line)
2363 (setq major-mode 'gnus-summary-mode)
2364 (setq mode-name "Summary")
2365 (make-local-variable 'minor-mode-alist)
2366 (use-local-map gnus-summary-mode-map)
2367 (buffer-disable-undo)
2368 (setq buffer-read-only t) ;Disable modification
2369 (setq truncate-lines t)
2370 (setq selective-display t)
2371 (setq selective-display-ellipses t) ;Display `...'
2372 (gnus-summary-set-display-table)
2373 (gnus-set-default-directory)
2374 (setq gnus-newsgroup-name group)
2375 (unless (gnus-news-group-p group)
2376 (setq gnus-newsgroup-incorporated
2377 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2378 (make-local-variable 'gnus-summary-line-format)
2379 (make-local-variable 'gnus-summary-line-format-spec)
2380 (make-local-variable 'gnus-summary-dummy-line-format)
2381 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2382 (make-local-variable 'gnus-summary-mark-positions)
2383 (make-local-hook 'pre-command-hook)
2384 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2385 (gnus-run-hooks 'gnus-summary-mode-hook)
2386 (turn-on-gnus-mailing-list-mode)
2387 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2388 (gnus-update-summary-mark-positions))
2390 (defun gnus-summary-make-local-variables ()
2391 "Make all the local summary buffer variables."
2393 (dolist (local gnus-summary-local-variables)
2396 (if (eq (cdr local) 'global)
2397 ;; Copy the global value of the variable.
2398 (setq global (symbol-value (car local)))
2399 ;; Use the value from the list.
2400 (setq global (eval (cdr local))))
2401 (set (make-local-variable (car local)) global))
2402 ;; Simple nil-valued local variable.
2403 (set (make-local-variable local) nil)))))
2405 (defun gnus-summary-clear-local-variables ()
2406 (let ((locals gnus-summary-local-variables))
2408 (if (consp (car locals))
2409 (and (vectorp (caar locals))
2410 (set (caar locals) nil))
2411 (and (vectorp (car locals))
2412 (set (car locals) nil)))
2413 (setq locals (cdr locals)))))
2415 ;; Summary data functions.
2417 (defmacro gnus-data-number (data)
2420 (defmacro gnus-data-set-number (data number)
2421 `(setcar ,data ,number))
2423 (defmacro gnus-data-mark (data)
2426 (defmacro gnus-data-set-mark (data mark)
2427 `(setcar (nthcdr 1 ,data) ,mark))
2429 (defmacro gnus-data-pos (data)
2432 (defmacro gnus-data-set-pos (data pos)
2433 `(setcar (nthcdr 2 ,data) ,pos))
2435 (defmacro gnus-data-header (data)
2438 (defmacro gnus-data-set-header (data header)
2439 `(setcar (nthcdr 3 ,data) ,header))
2441 (defmacro gnus-data-level (data)
2444 (defmacro gnus-data-unread-p (data)
2445 `(= (nth 1 ,data) gnus-unread-mark))
2447 (defmacro gnus-data-read-p (data)
2448 `(/= (nth 1 ,data) gnus-unread-mark))
2450 (defmacro gnus-data-pseudo-p (data)
2451 `(consp (nth 3 ,data)))
2453 (defmacro gnus-data-find (number)
2454 `(assq ,number gnus-newsgroup-data))
2456 (defmacro gnus-data-find-list (number &optional data)
2457 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2458 (memq (assq ,number bdata)
2461 (defmacro gnus-data-make (number mark pos header level)
2462 `(list ,number ,mark ,pos ,header ,level))
2464 (defun gnus-data-enter (after-article number mark pos header level offset)
2465 (let ((data (gnus-data-find-list after-article)))
2467 (error "No such article: %d" after-article))
2468 (setcdr data (cons (gnus-data-make number mark pos header level)
2470 (setq gnus-newsgroup-data-reverse nil)
2471 (gnus-data-update-list (cddr data) offset)))
2473 (defun gnus-data-enter-list (after-article list &optional offset)
2475 (let ((data (and after-article (gnus-data-find-list after-article)))
2479 (let ((odata gnus-newsgroup-data))
2480 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2482 (gnus-data-update-list odata offset)))
2483 ;; Find the last element in the list to be spliced into the main
2486 (setq list (cdr list)))
2489 (setcdr list gnus-newsgroup-data)
2490 (setq gnus-newsgroup-data ilist)
2492 (gnus-data-update-list (cdr list) offset)))
2493 (setcdr list (cdr data))
2496 (gnus-data-update-list (cdr list) offset))))
2497 (setq gnus-newsgroup-data-reverse nil))))
2499 (defun gnus-data-remove (article &optional offset)
2500 (let ((data gnus-newsgroup-data))
2501 (if (= (gnus-data-number (car data)) article)
2503 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2504 gnus-newsgroup-data-reverse nil)
2506 (gnus-data-update-list gnus-newsgroup-data offset)))
2508 (when (= (gnus-data-number (cadr data)) article)
2509 (setcdr data (cddr data))
2511 (gnus-data-update-list (cdr data) offset))
2513 gnus-newsgroup-data-reverse nil))
2514 (setq data (cdr data))))))
2516 (defmacro gnus-data-list (backward)
2518 (or gnus-newsgroup-data-reverse
2519 (setq gnus-newsgroup-data-reverse
2520 (reverse gnus-newsgroup-data)))
2521 gnus-newsgroup-data))
2523 (defun gnus-data-update-list (data offset)
2524 "Add OFFSET to the POS of all data entries in DATA."
2525 (setq gnus-newsgroup-data-reverse nil)
2527 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2528 (setq data (cdr data))))
2530 (defun gnus-summary-article-pseudo-p (article)
2531 "Say whether this article is a pseudo article or not."
2532 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2534 (defmacro gnus-summary-article-sparse-p (article)
2535 "Say whether this article is a sparse article or not."
2536 `(memq ,article gnus-newsgroup-sparse))
2538 (defmacro gnus-summary-article-ancient-p (article)
2539 "Say whether this article is a sparse article or not."
2540 `(memq ,article gnus-newsgroup-ancient))
2542 (defun gnus-article-parent-p (number)
2543 "Say whether this article is a parent or not."
2544 (let ((data (gnus-data-find-list number)))
2545 (and (cdr data) ; There has to be an article after...
2546 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2547 (gnus-data-level (nth 1 data))))))
2549 (defun gnus-article-children (number)
2550 "Return a list of all children to NUMBER."
2551 (let* ((data (gnus-data-find-list number))
2552 (level (gnus-data-level (car data)))
2554 (setq data (cdr data))
2556 (= (gnus-data-level (car data)) (1+ level)))
2557 (push (gnus-data-number (car data)) children)
2558 (setq data (cdr data)))
2561 (defmacro gnus-summary-skip-intangible ()
2562 "If the current article is intangible, then jump to a different article."
2563 '(let ((to (get-text-property (point) 'gnus-intangible)))
2564 (and to (gnus-summary-goto-subject to))))
2566 (defmacro gnus-summary-article-intangible-p ()
2567 "Say whether this article is intangible or not."
2568 '(get-text-property (point) 'gnus-intangible))
2570 (defun gnus-article-read-p (article)
2571 "Say whether ARTICLE is read or not."
2572 (not (or (memq article gnus-newsgroup-marked)
2573 (memq article gnus-newsgroup-unreads)
2574 (memq article gnus-newsgroup-unselected)
2575 (memq article gnus-newsgroup-dormant))))
2577 ;; Some summary mode macros.
2579 (defmacro gnus-summary-article-number ()
2580 "The article number of the article on the current line.
2581 If there isn's an article number here, then we return the current
2584 (gnus-summary-skip-intangible)
2585 (or (get-text-property (point) 'gnus-number)
2586 (gnus-summary-last-subject))))
2588 (defmacro gnus-summary-article-header (&optional number)
2589 "Return the header of article NUMBER."
2590 `(gnus-data-header (gnus-data-find
2591 ,(or number '(gnus-summary-article-number)))))
2593 (defmacro gnus-summary-thread-level (&optional number)
2594 "Return the level of thread that starts with article NUMBER."
2595 `(if (and (eq gnus-summary-make-false-root 'dummy)
2596 (get-text-property (point) 'gnus-intangible))
2598 (gnus-data-level (gnus-data-find
2599 ,(or number '(gnus-summary-article-number))))))
2601 (defmacro gnus-summary-article-mark (&optional number)
2602 "Return the mark of article NUMBER."
2603 `(gnus-data-mark (gnus-data-find
2604 ,(or number '(gnus-summary-article-number)))))
2606 (defmacro gnus-summary-article-pos (&optional number)
2607 "Return the position of the line of article NUMBER."
2608 `(gnus-data-pos (gnus-data-find
2609 ,(or number '(gnus-summary-article-number)))))
2611 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2612 (defmacro gnus-summary-article-subject (&optional number)
2613 "Return current subject string or nil if nothing."
2616 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2617 '(gnus-data-header (assq (gnus-summary-article-number)
2618 gnus-newsgroup-data)))))
2621 (mail-header-subject headers))))
2623 (defmacro gnus-summary-article-score (&optional number)
2624 "Return current article score."
2625 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2626 gnus-newsgroup-scored))
2627 gnus-summary-default-score 0))
2629 (defun gnus-summary-article-children (&optional number)
2630 "Return a list of article numbers that are children of article NUMBER."
2631 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2632 (level (gnus-data-level (car data)))
2634 (while (and (setq data (cdr data))
2635 (> (setq l (gnus-data-level (car data))) level))
2636 (and (= (1+ level) l)
2637 (push (gnus-data-number (car data))
2639 (nreverse children)))
2641 (defun gnus-summary-article-parent (&optional number)
2642 "Return the article number of the parent of article NUMBER."
2643 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2644 (gnus-data-list t)))
2645 (level (gnus-data-level (car data))))
2647 () ; This is a root.
2648 ;; We search until we find an article with a level less than
2649 ;; this one. That function has to be the parent.
2650 (while (and (setq data (cdr data))
2651 (not (< (gnus-data-level (car data)) level))))
2652 (and data (gnus-data-number (car data))))))
2654 (defun gnus-unread-mark-p (mark)
2655 "Say whether MARK is the unread mark."
2656 (= mark gnus-unread-mark))
2658 (defun gnus-read-mark-p (mark)
2659 "Say whether MARK is one of the marks that mark as read.
2660 This is all marks except unread, ticked, dormant, and expirable."
2661 (not (or (= mark gnus-unread-mark)
2662 (= mark gnus-ticked-mark)
2663 (= mark gnus-dormant-mark)
2664 (= mark gnus-expirable-mark))))
2666 (defmacro gnus-article-mark (number)
2667 "Return the MARK of article NUMBER.
2668 This macro should only be used when computing the mark the \"first\"
2669 time; i.e., when generating the summary lines. After that,
2670 `gnus-summary-article-mark' should be used to examine the
2673 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2674 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2675 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2676 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2677 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2678 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2679 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2680 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2681 gnus-ancient-mark))))
2683 ;; Saving hidden threads.
2685 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2686 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2688 (defmacro gnus-save-hidden-threads (&rest forms)
2689 "Save hidden threads, eval FORMS, and restore the hidden threads."
2690 (let ((config (make-symbol "config")))
2691 `(let ((,config (gnus-hidden-threads-configuration)))
2695 (gnus-restore-hidden-threads-configuration ,config)))))
2697 (defun gnus-data-compute-positions ()
2698 "Compute the positions of all articles."
2699 (setq gnus-newsgroup-data-reverse nil)
2700 (let ((data gnus-newsgroup-data))
2702 (gnus-save-hidden-threads
2703 (gnus-summary-show-all-threads)
2704 (goto-char (point-min))
2706 (while (get-text-property (point) 'gnus-intangible)
2708 (gnus-data-set-pos (car data) (+ (point) 3))
2709 (setq data (cdr data))
2710 (forward-line 1))))))
2712 (defun gnus-hidden-threads-configuration ()
2713 "Return the current hidden threads configuration."
2716 (goto-char (point-min))
2717 (while (search-forward "\r" nil t)
2718 (push (1- (point)) config))
2721 (defun gnus-restore-hidden-threads-configuration (config)
2722 "Restore hidden threads configuration from CONFIG."
2724 (let (point buffer-read-only)
2725 (while (setq point (pop config))
2726 (when (and (< point (point-max))
2728 (eq (char-after) ?\n))
2729 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2731 ;; Various summary mode internalish functions.
2733 (defun gnus-mouse-pick-article (e)
2736 (gnus-summary-next-page nil t))
2738 (defun gnus-summary-set-display-table ()
2739 "Change the display table.
2740 Odd characters have a tendency to mess
2741 up nicely formatted displays - we make all possible glyphs
2742 display only a single character."
2744 ;; We start from the standard display table, if any.
2745 (let ((table (or (copy-sequence standard-display-table)
2746 (make-display-table)))
2748 ;; Nix out all the control chars...
2749 (while (>= (setq i (1- i)) 0)
2750 (aset table i [??]))
2751 ;; ... but not newline and cr, of course. (cr is necessary for the
2752 ;; selective display).
2753 (aset table ?\n nil)
2754 (aset table ?\r nil)
2755 ;; We keep TAB as well.
2756 (aset table ?\t nil)
2757 ;; We nix out any glyphs over 126 that are not set already.
2759 (while (>= (setq i (1- i)) 127)
2760 ;; Only modify if the entry is nil.
2761 (unless (aref table i)
2762 (aset table i [??]))))
2763 (setq buffer-display-table table)))
2765 (defun gnus-summary-set-article-display-arrow (pos)
2766 "Update the overlay arrow to point to line at position POS."
2767 (when (and gnus-summary-display-arrow
2768 (boundp 'overlay-arrow-position)
2769 (boundp 'overlay-arrow-string))
2773 (unless overlay-arrow-position
2774 (setq overlay-arrow-position (make-marker)))
2775 (setq overlay-arrow-string "=>"
2776 overlay-arrow-position (set-marker overlay-arrow-position
2778 (current-buffer))))))
2780 (defun gnus-summary-buffer-name (group)
2781 "Return the summary buffer name of GROUP."
2782 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2784 (defun gnus-summary-setup-buffer (group)
2785 "Initialize summary buffer."
2786 (let ((buffer (gnus-summary-buffer-name group)))
2787 (if (get-buffer buffer)
2790 (setq gnus-summary-buffer (current-buffer))
2791 (not gnus-newsgroup-prepared))
2792 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2793 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2794 (gnus-summary-mode group)
2796 (gnus-carpal-setup-buffer 'summary))
2797 (unless gnus-single-article-buffer
2798 (make-local-variable 'gnus-article-buffer)
2799 (make-local-variable 'gnus-article-current)
2800 (make-local-variable 'gnus-original-article-buffer))
2801 (setq gnus-newsgroup-name group)
2802 ;; Set any local variables in the group parameters.
2803 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2806 (defun gnus-set-global-variables ()
2807 "Set the global equivalents of the buffer-local variables.
2808 They are set to the latest values they had. These reflect the summary
2809 buffer that was in action when the last article was fetched."
2810 (when (eq major-mode 'gnus-summary-mode)
2811 (setq gnus-summary-buffer (current-buffer))
2812 (let ((name gnus-newsgroup-name)
2813 (marked gnus-newsgroup-marked)
2814 (unread gnus-newsgroup-unreads)
2815 (headers gnus-current-headers)
2816 (data gnus-newsgroup-data)
2817 (summary gnus-summary-buffer)
2818 (article-buffer gnus-article-buffer)
2819 (original gnus-original-article-buffer)
2820 (gac gnus-article-current)
2821 (reffed gnus-reffed-article-number)
2822 (score-file gnus-current-score-file)
2823 (default-charset gnus-newsgroup-charset)
2825 (let ((locals gnus-newsgroup-variables))
2827 (if (consp (car locals))
2828 (push (eval (caar locals)) vlist)
2829 (push (eval (car locals)) vlist))
2830 (setq locals (cdr locals)))
2831 (setq vlist (nreverse vlist)))
2833 (set-buffer gnus-group-buffer)
2834 (setq gnus-newsgroup-name name
2835 gnus-newsgroup-marked marked
2836 gnus-newsgroup-unreads unread
2837 gnus-current-headers headers
2838 gnus-newsgroup-data data
2839 gnus-article-current gac
2840 gnus-summary-buffer summary
2841 gnus-article-buffer article-buffer
2842 gnus-original-article-buffer original
2843 gnus-reffed-article-number reffed
2844 gnus-current-score-file score-file
2845 gnus-newsgroup-charset default-charset)
2846 (let ((locals gnus-newsgroup-variables))
2848 (if (consp (car locals))
2849 (set (caar locals) (pop vlist))
2850 (set (car locals) (pop vlist)))
2851 (setq locals (cdr locals))))
2852 ;; The article buffer also has local variables.
2853 (when (gnus-buffer-live-p gnus-article-buffer)
2854 (set-buffer gnus-article-buffer)
2855 (setq gnus-summary-buffer summary))))))
2857 (defun gnus-summary-article-unread-p (article)
2858 "Say whether ARTICLE is unread or not."
2859 (memq article gnus-newsgroup-unreads))
2861 (defun gnus-summary-first-article-p (&optional article)
2862 "Return whether ARTICLE is the first article in the buffer."
2863 (if (not (setq article (or article (gnus-summary-article-number))))
2865 (eq article (caar gnus-newsgroup-data))))
2867 (defun gnus-summary-last-article-p (&optional article)
2868 "Return whether ARTICLE is the last article in the buffer."
2869 (if (not (setq article (or article (gnus-summary-article-number))))
2870 ;; All non-existent numbers are the last article. :-)
2872 (not (cdr (gnus-data-find-list article)))))
2874 (defun gnus-make-thread-indent-array ()
2876 (unless (and gnus-thread-indent-array
2877 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2878 (setq gnus-thread-indent-array (make-vector 201 "")
2879 gnus-thread-indent-array-level gnus-thread-indent-level)
2881 (aset gnus-thread-indent-array n
2882 (make-string (* n gnus-thread-indent-level) ? ))
2885 (defun gnus-update-summary-mark-positions ()
2886 "Compute where the summary marks are to go."
2888 (when (gnus-buffer-exists-p gnus-summary-buffer)
2889 (set-buffer gnus-summary-buffer))
2890 (let ((gnus-replied-mark 129)
2891 (gnus-score-below-mark 130)
2892 (gnus-score-over-mark 130)
2893 (gnus-download-mark 131)
2894 (spec gnus-summary-line-format-spec)
2897 (gnus-set-work-buffer)
2898 (let ((gnus-summary-line-format-spec spec)
2899 (gnus-newsgroup-downloadable '((0 . t))))
2900 (gnus-summary-insert-line
2901 (make-full-mail-header 0 "" "nobody"
2902 "05 Apr 2001 23:33:09 +0400"
2904 0 nil 128 t nil "" nil 1)
2905 (goto-char (point-min))
2906 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2908 (goto-char (point-min))
2909 (push (cons 'replied (and (search-forward "\201" nil t)
2912 (goto-char (point-min))
2913 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2915 (goto-char (point-min))
2916 (push (cons 'download
2917 (and (search-forward "\203" nil t) (- (point) 2)))
2919 (setq gnus-summary-mark-positions pos))))
2921 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2922 "Insert a dummy root in the summary buffer."
2924 (gnus-add-text-properties
2925 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2926 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2928 (defun gnus-summary-extract-address-component (from)
2929 (or (car (funcall gnus-extract-address-components from))
2932 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
2933 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
2934 default-mime-charset)))
2935 ;; Is it really necessary to do this next part for each summary line?
2936 ;; Luckily, doesn't seem to slow things down much.
2938 (and gnus-ignored-from-addresses
2939 (string-match gnus-ignored-from-addresses gnus-tmp-from)
2940 (let ((extra-headers (mail-header-extra header))
2944 ((setq to (cdr (assq 'To extra-headers)))
2946 (gnus-summary-extract-address-component
2947 (funcall gnus-decode-encoded-word-function to))))
2948 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
2949 (concat "=> " newsgroups)))))
2950 (gnus-summary-extract-address-component gnus-tmp-from))))
2952 (defun gnus-summary-insert-line (gnus-tmp-header
2953 gnus-tmp-level gnus-tmp-current
2954 gnus-tmp-unread gnus-tmp-replied
2955 gnus-tmp-expirable gnus-tmp-subject-or-nil
2956 &optional gnus-tmp-dummy gnus-tmp-score
2958 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2959 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2960 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2961 (gnus-tmp-score-char
2962 (if (or (null gnus-summary-default-score)
2963 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2964 gnus-summary-zcore-fuzz))
2966 (if (< gnus-tmp-score gnus-summary-default-score)
2967 gnus-score-below-mark gnus-score-over-mark)))
2968 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2970 (cond (gnus-tmp-process gnus-process-mark)
2971 ((memq gnus-tmp-current gnus-newsgroup-cached)
2973 (gnus-tmp-replied gnus-replied-mark)
2974 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2975 gnus-forwarded-mark)
2976 ((memq gnus-tmp-current gnus-newsgroup-saved)
2978 ((memq gnus-tmp-number gnus-newsgroup-recent)
2980 ((memq gnus-tmp-number gnus-newsgroup-unseen)
2983 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2986 ((string-match "<[^>]+> *$" gnus-tmp-from)
2987 (let ((beg (match-beginning 0)))
2988 (or (and (string-match "^\".+\"" gnus-tmp-from)
2989 (substring gnus-tmp-from 1 (1- (match-end 0))))
2990 (substring gnus-tmp-from 0 beg))))
2991 ((string-match "(.+)" gnus-tmp-from)
2992 (substring gnus-tmp-from
2993 (1+ (match-beginning 0)) (1- (match-end 0))))
2995 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2996 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2997 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2998 (buffer-read-only nil))
2999 (when (string= gnus-tmp-name "")
3000 (setq gnus-tmp-name gnus-tmp-from))
3001 (unless (numberp gnus-tmp-lines)
3002 (setq gnus-tmp-lines -1))
3003 (if (= gnus-tmp-lines -1)
3004 (setq gnus-tmp-lines "?")
3005 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3006 (gnus-put-text-property-excluding-characters-with-faces
3008 (progn (eval gnus-summary-line-format-spec) (point))
3009 'gnus-number gnus-tmp-number)
3010 (when (gnus-visual-p 'summary-highlight 'highlight)
3012 (gnus-run-hooks 'gnus-summary-update-hook)
3015 (defun gnus-summary-update-line (&optional dont-update)
3016 "Update summary line after change."
3017 (when (and gnus-summary-default-score
3018 (not gnus-summary-inhibit-highlight))
3019 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3020 (article (gnus-summary-article-number))
3021 (score (gnus-summary-article-score article)))
3023 (if (and gnus-summary-mark-below
3024 (< (gnus-summary-article-score)
3025 gnus-summary-mark-below))
3026 ;; This article has a low score, so we mark it as read.
3027 (when (memq article gnus-newsgroup-unreads)
3028 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3029 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3030 ;; This article was previously marked as read on account
3031 ;; of a low score, but now it has risen, so we mark it as
3033 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3034 (gnus-summary-update-mark
3035 (if (or (null gnus-summary-default-score)
3036 (<= (abs (- score gnus-summary-default-score))
3037 gnus-summary-zcore-fuzz))
3039 (if (< score gnus-summary-default-score)
3040 gnus-score-below-mark gnus-score-over-mark))
3042 ;; Do visual highlighting.
3043 (when (gnus-visual-p 'summary-highlight 'highlight)
3044 (gnus-run-hooks 'gnus-summary-update-hook)))))
3046 (defvar gnus-tmp-new-adopts nil)
3048 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3049 "Return the number of articles in THREAD.
3050 This may be 0 in some cases -- if none of the articles in
3051 the thread are to be displayed."
3053 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3055 ((not (listp thread))
3057 ((and (consp thread) (cdr thread))
3060 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3063 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3066 (when (and level (zerop level) gnus-tmp-new-adopts)
3069 'gnus-summary-number-of-articles-in-thread
3070 gnus-tmp-new-adopts))))
3072 (if (> number 1) gnus-not-empty-thread-mark
3073 gnus-empty-thread-mark)
3076 (defun gnus-summary-set-local-parameters (group)
3077 "Go through the local params of GROUP and set all variable specs in that list."
3078 (let ((params (gnus-group-find-parameter group))
3079 (vars '(quit-config)) ; Ignore quit-config.
3082 (setq elem (car params)
3083 params (cdr params))
3084 (and (consp elem) ; Has to be a cons.
3085 (consp (cdr elem)) ; The cdr has to be a list.
3086 (symbolp (car elem)) ; Has to be a symbol in there.
3087 (not (memq (car elem) vars))
3088 (ignore-errors ; So we set it.
3089 (push (car elem) vars)
3090 (make-local-variable (car elem))
3091 (set (car elem) (eval (nth 1 elem))))))))
3093 (defun gnus-summary-read-group (group &optional show-all no-article
3094 kill-buffer no-display backward
3096 "Start reading news in newsgroup GROUP.
3097 If SHOW-ALL is non-nil, already read articles are also listed.
3098 If NO-ARTICLE is non-nil, no article is selected initially.
3099 If NO-DISPLAY, don't generate a summary buffer."
3103 (let ((gnus-auto-select-next nil))
3104 (or (gnus-summary-read-group-1
3105 group show-all no-article
3106 kill-buffer no-display
3109 select-articles nil)))))
3110 (eq gnus-auto-select-next 'quietly))
3111 (set-buffer gnus-group-buffer)
3112 ;; The entry function called above goes to the next
3113 ;; group automatically, so we go two groups back
3114 ;; if we are searching for the previous group.
3116 (gnus-group-prev-unread-group 2))
3117 (if (not (equal group (gnus-group-group-name)))
3118 (setq group (gnus-group-group-name))
3122 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3123 "Directly jump to the other GROUP from summary buffer.
3124 If SHOW-ALL is non-nil, already read articles are also listed."
3126 (if (eq gnus-summary-buffer (current-buffer))
3127 (list (completing-read
3128 "Group: " gnus-active-hashtb nil t
3129 (when (and gnus-newsgroup-name
3130 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3131 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3132 'gnus-group-history)
3134 (error "%s must be invoked from a gnus summary buffer." this-command)))
3135 (unless (or (zerop (length group))
3136 (and gnus-newsgroup-name
3137 (string-equal gnus-newsgroup-name group)))
3139 (gnus-summary-read-group group show-all
3140 gnus-dont-select-after-jump-to-other-group)))
3142 (defun gnus-summary-read-group-1 (group show-all no-article
3143 kill-buffer no-display
3144 &optional select-articles)
3145 ;; Killed foreign groups can't be entered.
3146 ;; (when (and (not (gnus-group-native-p group))
3147 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3148 ;; (error "Dead non-native groups can't be entered"))
3149 (gnus-message 5 "Retrieving newsgroup: %s..."
3150 (gnus-group-decoded-name group))
3151 (let* ((new-group (gnus-summary-setup-buffer group))
3152 (quit-config (gnus-group-quit-config group))
3153 (did-select (and new-group (gnus-select-newsgroup
3154 group show-all select-articles))))
3156 ;; This summary buffer exists already, so we just select it.
3158 (gnus-set-global-variables)
3160 (gnus-kill-or-deaden-summary kill-buffer))
3161 (gnus-configure-windows 'summary 'force)
3162 (gnus-set-mode-line 'summary)
3163 (gnus-summary-position-point)
3166 ;; We couldn't select this group.
3168 (when (and (eq major-mode 'gnus-summary-mode)
3169 (not (equal (current-buffer) kill-buffer)))
3170 (kill-buffer (current-buffer))
3171 (if (not quit-config)
3173 ;; Update the info -- marks might need to be removed,
3175 (gnus-summary-update-info)
3176 (set-buffer gnus-group-buffer)
3177 (gnus-group-jump-to-group group)
3178 (gnus-group-next-unread-group 1))
3179 (gnus-handle-ephemeral-exit quit-config)))
3180 (let ((grpinfo (gnus-get-info group)))
3181 (if (null (gnus-info-read grpinfo))
3182 (gnus-message 3 "Group %s contains no messages"
3183 (gnus-group-decoded-name group))
3184 (gnus-message 3 "Can't select group")))
3186 ;; The user did a `C-g' while prompting for number of articles,
3187 ;; so we exit this group.
3188 ((eq did-select 'quit)
3189 (and (eq major-mode 'gnus-summary-mode)
3190 (not (equal (current-buffer) kill-buffer))
3191 (kill-buffer (current-buffer)))
3193 (gnus-kill-or-deaden-summary kill-buffer))
3194 (if (not quit-config)
3196 (set-buffer gnus-group-buffer)
3197 (gnus-group-jump-to-group group)
3198 (gnus-group-next-unread-group 1)
3199 (gnus-configure-windows 'group 'force))
3200 (gnus-handle-ephemeral-exit quit-config))
3201 ;; Finally signal the quit.
3203 ;; The group was successfully selected.
3205 (gnus-set-global-variables)
3206 ;; Save the active value in effect when the group was entered.
3207 (setq gnus-newsgroup-active
3209 (gnus-active gnus-newsgroup-name)))
3210 ;; You can change the summary buffer in some way with this hook.
3211 (gnus-run-hooks 'gnus-select-group-hook)
3212 (gnus-update-format-specifications
3213 nil 'summary 'summary-mode 'summary-dummy)
3214 (gnus-update-summary-mark-positions)
3215 ;; Do score processing.
3216 (when gnus-use-scoring
3217 (gnus-possibly-score-headers))
3218 ;; Check whether to fill in the gaps in the threads.
3219 (when gnus-build-sparse-threads
3220 (gnus-build-sparse-threads))
3221 ;; Find the initial limit.
3222 (if gnus-show-threads
3224 (let ((gnus-newsgroup-dormant nil))
3225 (gnus-summary-initial-limit show-all))
3226 (gnus-summary-initial-limit show-all))
3227 ;; When untreaded, all articles are always shown.
3228 (setq gnus-newsgroup-limit
3230 (lambda (header) (mail-header-number header))
3231 gnus-newsgroup-headers)))
3232 ;; Generate the summary buffer.
3234 (gnus-summary-prepare))
3235 (when gnus-use-trees
3236 (gnus-tree-open group)
3237 (setq gnus-summary-highlight-line-function
3238 'gnus-tree-highlight-article))
3239 ;; If the summary buffer is empty, but there are some low-scored
3240 ;; articles or some excluded dormants, we include these in the
3242 (when (and (zerop (buffer-size))
3244 (cond (gnus-newsgroup-dormant
3245 (gnus-summary-limit-include-dormant))
3246 ((and gnus-newsgroup-scored show-all)
3247 (gnus-summary-limit-include-expunged t))))
3248 ;; Function `gnus-apply-kill-file' must be called in this hook.
3249 (gnus-run-hooks 'gnus-apply-kill-hook)
3250 (if (and (zerop (buffer-size))
3253 ;; This newsgroup is empty.
3254 (gnus-summary-catchup-and-exit nil t)
3255 (gnus-message 6 "No unread news")
3257 (gnus-kill-or-deaden-summary kill-buffer))
3258 ;; Return nil from this function.
3260 ;; Hide conversation thread subtrees. We cannot do this in
3261 ;; gnus-summary-prepare-hook since kill processing may not
3262 ;; work with hidden articles.
3263 (and gnus-show-threads
3264 gnus-thread-hide-subtree
3265 (gnus-summary-hide-all-threads))
3267 (gnus-kill-or-deaden-summary kill-buffer))
3268 ;; Show first unread article if requested.
3269 (if (and (not no-article)
3271 gnus-newsgroup-unreads
3272 gnus-auto-select-first)
3274 (gnus-configure-windows 'summary)
3276 ((eq gnus-auto-select-first 'best)
3277 (gnus-summary-best-unread-article))
3278 ((eq gnus-auto-select-first t)
3279 (gnus-summary-first-unread-article))
3280 ((gnus-functionp gnus-auto-select-first)
3281 (funcall gnus-auto-select-first))))
3282 ;; Don't select any articles, just move point to the first
3283 ;; article in the group.
3284 (goto-char (point-min))
3285 (gnus-summary-position-point)
3286 (gnus-configure-windows 'summary 'force)
3287 (gnus-set-mode-line 'summary))
3288 (when (get-buffer-window gnus-group-buffer t)
3289 ;; Gotta use windows, because recenter does weird stuff if
3290 ;; the current buffer ain't the displayed window.
3291 (let ((owin (selected-window)))
3292 (select-window (get-buffer-window gnus-group-buffer t))
3293 (when (gnus-group-goto-group group)
3295 (select-window owin)))
3296 ;; Mark this buffer as "prepared".
3297 (setq gnus-newsgroup-prepared t)
3298 (gnus-run-hooks 'gnus-summary-prepared-hook)
3301 (defun gnus-summary-prepare ()
3302 "Generate the summary buffer."
3304 (let ((buffer-read-only nil))
3306 (setq gnus-newsgroup-data nil
3307 gnus-newsgroup-data-reverse nil)
3308 (gnus-run-hooks 'gnus-summary-generate-hook)
3309 ;; Generate the buffer, either with threads or without.
3310 (when gnus-newsgroup-headers
3311 (gnus-summary-prepare-threads
3312 (if gnus-show-threads
3313 (gnus-sort-gathered-threads
3314 (funcall gnus-summary-thread-gathering-function
3316 (gnus-cut-threads (gnus-make-threads)))))
3317 ;; Unthreaded display.
3318 (gnus-sort-articles gnus-newsgroup-headers))))
3319 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3320 ;; Call hooks for modifying summary buffer.
3321 (goto-char (point-min))
3322 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3324 (defsubst gnus-general-simplify-subject (subject)
3325 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3328 ;; Truncate the subject.
3329 (gnus-simplify-subject-functions
3330 (gnus-map-function gnus-simplify-subject-functions subject))
3331 ((numberp gnus-summary-gather-subject-limit)
3332 (setq subject (gnus-simplify-subject-re subject))
3333 (if (> (length subject) gnus-summary-gather-subject-limit)
3334 (substring subject 0 gnus-summary-gather-subject-limit)
3336 ;; Fuzzily simplify it.
3337 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3338 (gnus-simplify-subject-fuzzy subject))
3339 ;; Just remove the leading "Re:".
3341 (gnus-simplify-subject-re subject))))
3343 (if (and gnus-summary-gather-exclude-subject
3344 (string-match gnus-summary-gather-exclude-subject subject))
3345 nil ; This article shouldn't be gathered
3348 (defun gnus-summary-simplify-subject-query ()
3349 "Query where the respool algorithm would put this article."
3351 (gnus-summary-select-article)
3353 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3355 (defun gnus-gather-threads-by-subject (threads)
3356 "Gather threads by looking at Subject headers."
3357 (if (not gnus-summary-make-false-root)
3359 (let ((hashtb (gnus-make-hashtable 1024))
3362 subject hthread whole-subject)
3364 (setq subject (gnus-general-simplify-subject
3365 (setq whole-subject (mail-header-subject
3368 (if (setq hthread (gnus-gethash subject hashtb))
3370 ;; We enter a dummy root into the thread, if we
3371 ;; haven't done that already.
3372 (unless (stringp (caar hthread))
3373 (setcar hthread (list whole-subject (car hthread))))
3374 ;; We add this new gathered thread to this gathered
3376 (setcdr (car hthread)
3377 (nconc (cdar hthread) (list (car threads))))
3378 ;; Remove it from the list of threads.
3379 (setcdr prev (cdr threads))
3380 (setq threads prev))
3381 ;; Enter this thread into the hash table.
3382 (gnus-sethash subject threads hashtb)))
3384 (setq threads (cdr threads)))
3387 (defun gnus-gather-threads-by-references (threads)
3388 "Gather threads by looking at References headers."
3389 (let ((idhashtb (gnus-make-hashtable 1024))
3390 (thhashtb (gnus-make-hashtable 1024))
3393 ids references id gthread gid entered ref)
3395 (when (setq references (mail-header-references (caar threads)))
3396 (setq id (mail-header-id (caar threads))
3397 ids (gnus-split-references references)
3399 (while (setq ref (pop ids))
3400 (setq ids (delete ref ids))
3401 (if (not (setq gid (gnus-gethash ref idhashtb)))
3403 (gnus-sethash ref id idhashtb)
3404 (gnus-sethash id threads thhashtb))
3405 (setq gthread (gnus-gethash gid thhashtb))
3407 ;; We enter a dummy root into the thread, if we
3408 ;; haven't done that already.
3409 (unless (stringp (caar gthread))
3410 (setcar gthread (list (mail-header-subject (caar gthread))
3412 ;; We add this new gathered thread to this gathered
3414 (setcdr (car gthread)
3415 (nconc (cdar gthread) (list (car threads)))))
3416 ;; Add it into the thread hash table.
3417 (gnus-sethash id gthread thhashtb)
3419 ;; Remove it from the list of threads.
3420 (setcdr prev (cdr threads))
3421 (setq threads prev))))
3423 (setq threads (cdr threads)))
3426 (defun gnus-sort-gathered-threads (threads)
3427 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3428 (let ((result threads))
3430 (when (stringp (caar threads))
3431 (setcdr (car threads)
3432 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3433 (setq threads (cdr threads)))
3436 (defun gnus-thread-loop-p (root thread)
3437 "Say whether ROOT is in THREAD."
3438 (let ((stack (list thread))
3441 (while (setq thread (pop stack))
3442 (setq th (cdr thread))
3444 (not (eq (caar th) root)))
3447 ;; We have found a loop.
3449 (setcdr thread (delq (car th) (cdr thread)))
3450 (if (boundp (setq ref-dep (intern "none"
3451 gnus-newsgroup-dependencies)))
3452 (setcdr (symbol-value ref-dep)
3453 (nconc (cdr (symbol-value ref-dep))
3455 (set ref-dep (list nil (car th))))
3458 ;; Push all the subthreads onto the stack.
3459 (push (cdr thread) stack)))
3462 (defun gnus-make-threads ()
3463 "Go through the dependency hashtb and find the roots. Return all threads."
3465 (while (catch 'infloop
3468 ;; Deal with self-referencing References loops.
3469 (when (and (car (symbol-value refs))
3476 (car (symbol-value refs)) thread))
3477 (cdr (symbol-value refs)))))))
3480 (unless (car (symbol-value refs))
3481 ;; These threads do not refer back to any other articles,
3482 ;; so they're roots.
3483 (setq threads (append (cdr (symbol-value refs)) threads))))
3484 gnus-newsgroup-dependencies)))
3487 ;; Build the thread tree.
3488 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3489 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3491 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3492 if it was already present.
3494 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3495 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3496 Message-IDs will be renamed be renamed to a unique Message-ID before
3499 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3500 (let* ((id (mail-header-id header))
3501 (id-dep (and id (intern id dependencies)))
3502 ref ref-dep ref-header)
3503 ;; Enter this `header' in the `dependencies' table.
3507 ;; The first two cases do the normal part: enter a new `header'
3508 ;; in the `dependencies' table.
3509 ((not (boundp id-dep))
3510 (set id-dep (list header)))
3511 ((null (car (symbol-value id-dep)))
3512 (setcar (symbol-value id-dep) header))
3514 ;; From here the `header' was already present in the
3515 ;; `dependencies' table.
3517 ;; Overrides an existing entry;
3518 ;; just set the header part of the entry.
3519 (setcar (symbol-value id-dep) header))
3521 ;; Renames the existing `header' to a unique Message-ID.
3522 ((not gnus-summary-ignore-duplicates)
3523 ;; An article with this Message-ID has already been seen.
3524 ;; We rename the Message-ID.
3525 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3527 (mail-header-set-id header id))
3529 ;; The last case ignores an existing entry, except it adds any
3530 ;; additional Xrefs (in case the two articles came from different
3532 ;; Also sets `header' to `nil' meaning that the `dependencies'
3533 ;; table was *not* modified.
3535 (mail-header-set-xref
3536 (car (symbol-value id-dep))
3537 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3539 (or (mail-header-xref header) "")))
3543 ;; First check if that we are not creating a References loop.
3544 (setq ref (gnus-parent-id (mail-header-references header)))
3546 (setq ref-dep (intern-soft ref dependencies))
3548 (setq ref-header (car (symbol-value ref-dep))))
3549 (if (string= id ref)
3550 ;; Yuk! This is a reference loop. Make the article be a
3553 (mail-header-set-references (car (symbol-value id-dep)) "none")
3555 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3556 (setq ref (gnus-parent-id (mail-header-references header)))
3557 (setq ref-dep (intern (or ref "none") dependencies))
3558 (if (boundp ref-dep)
3559 (setcdr (symbol-value ref-dep)
3560 (nconc (cdr (symbol-value ref-dep))
3561 (list (symbol-value id-dep))))
3562 (set ref-dep (list nil (symbol-value id-dep)))))
3565 (defun gnus-build-sparse-threads ()
3566 (let ((headers gnus-newsgroup-headers)
3567 (mail-parse-charset gnus-newsgroup-charset)
3568 (gnus-summary-ignore-duplicates t)
3569 header references generation relations
3570 subject child end new-child date)
3571 ;; First we create an alist of generations/relations, where
3572 ;; generations is how much we trust the relation, and the relation
3574 (gnus-message 7 "Making sparse threads...")
3576 (nnheader-set-temp-buffer " *gnus sparse threads*")
3577 (while (setq header (pop headers))
3578 (when (and (setq references (mail-header-references header))
3579 (not (string= references "")))
3581 (setq child (mail-header-id header)
3582 subject (mail-header-subject header)
3583 date (mail-header-date header)
3585 (while (search-backward ">" nil t)
3586 (setq end (1+ (point)))
3587 (when (search-backward "<" nil t)
3588 (setq new-child (buffer-substring (point) end))
3589 (push (list (incf generation)
3590 child (setq child new-child)
3594 (push (list (1+ generation) child nil subject) relations))
3596 (kill-buffer (current-buffer)))
3597 ;; Sort over trustworthiness.
3600 (when (gnus-dependencies-add-header
3601 (make-full-mail-header-from-decoded-header
3602 gnus-reffed-article-number
3603 (nth 3 relation) "" (or (nth 4 relation) "")
3605 (or (nth 2 relation) "") 0 0 "")
3606 gnus-newsgroup-dependencies nil)
3607 (push gnus-reffed-article-number gnus-newsgroup-limit)
3608 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3609 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3610 gnus-newsgroup-reads)
3611 (decf gnus-reffed-article-number)))
3612 (sort relations 'car-less-than-car))
3613 (gnus-message 7 "Making sparse threads...done")))
3615 (defun gnus-build-old-threads ()
3616 ;; Look at all the articles that refer back to old articles, and
3617 ;; fetch the headers for the articles that aren't there. This will
3618 ;; build complete threads - if the roots haven't been expired by the
3620 (let ((mail-parse-charset gnus-newsgroup-charset)
3624 (when (not (car (symbol-value refs)))
3625 (setq heads (cdr (symbol-value refs)))
3627 (if (memq (mail-header-number (caar heads))
3628 gnus-newsgroup-dormant)
3629 (setq heads (cdr heads))
3630 (setq id (symbol-name refs))
3631 (while (and (setq id (gnus-build-get-header id))
3632 (not (car (gnus-id-to-thread id)))))
3633 (setq heads nil)))))
3634 gnus-newsgroup-dependencies)))
3636 ;; This function has to be called with point after the article number
3637 ;; on the beginning of the line.
3638 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3639 (let ((eol (gnus-point-at-eol))
3640 (buffer (current-buffer))
3643 ;; overview: [num subject from date id refs chars lines misc]
3646 (narrow-to-region (point) eol)
3651 (make-full-mail-header
3653 (nnheader-nov-field) ; subject
3654 (nnheader-nov-field) ; from
3655 (nnheader-nov-field) ; date
3656 (nnheader-nov-read-message-id) ; id
3657 (nnheader-nov-field) ; refs
3658 (nnheader-nov-read-integer) ; chars
3659 (nnheader-nov-read-integer) ; lines
3661 (if (looking-at "Xref: ")
3662 (goto-char (match-end 0)))
3663 (nnheader-nov-field)) ; Xref
3664 (nnheader-nov-parse-extra)))) ; extra
3668 (when gnus-alter-header-function
3669 (funcall gnus-alter-header-function header))
3670 (gnus-dependencies-add-header header dependencies force-new)))
3672 (defun gnus-build-get-header (id)
3673 "Look through the buffer of NOV lines and find the header to ID.
3674 Enter this line into the dependencies hash table, and return
3675 the id of the parent article (if any)."
3676 (let ((deps gnus-newsgroup-dependencies)
3680 (set-buffer nntp-server-buffer)
3681 (let ((case-fold-search nil))
3682 (goto-char (point-min))
3683 (while (and (not found)
3684 (search-forward id nil t))
3686 (setq found (looking-at
3687 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3688 (regexp-quote id))))
3689 (or found (beginning-of-line 2)))
3693 (setq header (gnus-nov-parse-line
3694 (read (current-buffer)) deps))
3695 (gnus-parent-id (mail-header-references header))))))
3697 (let ((number (mail-header-number header)))
3698 (push number gnus-newsgroup-limit)
3699 (push header gnus-newsgroup-headers)
3700 (if (memq number gnus-newsgroup-unselected)
3702 (push number gnus-newsgroup-unreads)
3703 (setq gnus-newsgroup-unselected
3704 (delq number gnus-newsgroup-unselected)))
3705 (push number gnus-newsgroup-ancient)))))))
3707 (defun gnus-build-all-threads ()
3708 "Read all the headers."
3709 (let ((gnus-summary-ignore-duplicates t)
3710 (mail-parse-charset gnus-newsgroup-charset)
3711 (dependencies gnus-newsgroup-dependencies)
3714 (set-buffer nntp-server-buffer)
3715 (let ((case-fold-search nil))
3716 (goto-char (point-min))
3719 (setq article (read (current-buffer))
3720 header (gnus-nov-parse-line article dependencies)))
3723 (set-buffer gnus-summary-buffer)
3724 (push header gnus-newsgroup-headers)
3725 (if (memq (setq article (mail-header-number header))
3726 gnus-newsgroup-unselected)
3728 (push article gnus-newsgroup-unreads)
3729 (setq gnus-newsgroup-unselected
3730 (delq article gnus-newsgroup-unselected)))
3731 (push article gnus-newsgroup-ancient)))
3732 (forward-line 1)))))))
3734 (defun gnus-summary-update-article-line (article header)
3735 "Update the line for ARTICLE using HEADERS."
3736 (let* ((id (mail-header-id header))
3737 (thread (gnus-id-to-thread id)))
3739 (error "Article in no thread"))
3740 ;; Update the thread.
3741 (setcar thread header)
3742 (gnus-summary-goto-subject article)
3743 (let* ((datal (gnus-data-find-list article))
3745 (length (when (cdr datal)
3746 (- (gnus-data-pos data)
3747 (gnus-data-pos (cadr datal)))))
3748 (buffer-read-only nil)
3749 (level (gnus-summary-thread-level)))
3751 (gnus-summary-insert-line
3752 header level nil (gnus-article-mark article)
3753 (memq article gnus-newsgroup-replied)
3754 (memq article gnus-newsgroup-expirable)
3755 ;; Only insert the Subject string when it's different
3756 ;; from the previous Subject string.
3761 (mail-header-subject
3764 (gnus-data-find-list
3766 (gnus-data-list t)))))
3767 ;; Error on the side of excessive subjects.
3769 (mail-header-subject header)))
3771 (mail-header-subject header))
3772 nil (cdr (assq article gnus-newsgroup-scored))
3773 (memq article gnus-newsgroup-processable))
3775 (gnus-data-update-list
3776 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3778 (defun gnus-summary-update-article (article &optional iheader)
3779 "Update ARTICLE in the summary buffer."
3780 (set-buffer gnus-summary-buffer)
3781 (let* ((header (gnus-summary-article-header article))
3782 (id (mail-header-id header))
3783 (data (gnus-data-find article))
3784 (thread (gnus-id-to-thread id))
3785 (references (mail-header-references header))
3789 (when (and references
3790 (not (equal "" references)))
3793 (buffer-read-only nil)
3799 (delq thread parent)))
3800 (if (gnus-summary-insert-subject id header)
3801 ;; Set the (possibly) new article number in the data structure.
3802 (gnus-data-set-number data (gnus-id-to-article id))
3806 (defun gnus-rebuild-thread (id &optional line)
3807 "Rebuild the thread containing ID.
3808 If LINE, insert the rebuilt thread starting on line LINE."
3809 (let ((buffer-read-only nil)
3810 old-pos current thread data)
3811 (if (not gnus-show-threads)
3812 (setq thread (list (car (gnus-id-to-thread id))))
3813 ;; Get the thread this article is part of.
3814 (setq thread (gnus-remove-thread id)))
3815 (setq old-pos (gnus-point-at-bol))
3816 (setq current (save-excursion
3817 (and (re-search-backward "[\r\n]" nil t)
3818 (gnus-summary-article-number))))
3819 ;; If this is a gathered thread, we have to go some re-gathering.
3820 (when (stringp (car thread))
3821 (let ((subject (car thread))
3823 (setq thread (cdr thread))
3825 (unless (memq (setq thr (gnus-id-to-thread
3827 (mail-header-id (caar thread)))))
3830 (setq thread (cdr thread)))
3831 ;; We now have all (unique) roots.
3832 (if (= (length roots) 1)
3833 ;; All the loose roots are now one solid root.
3834 (setq thread (car roots))
3835 (setq thread (cons subject (gnus-sort-threads roots))))))
3837 ;; We then insert this thread into the summary buffer.
3839 (goto-char (point-min))
3840 (forward-line (1- line)))
3841 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3842 (if gnus-show-threads
3843 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3844 (gnus-summary-prepare-unthreaded thread))
3845 (setq data (nreverse gnus-newsgroup-data))
3846 (setq threads gnus-newsgroup-threads))
3847 ;; We splice the new data into the data structure.
3848 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3849 ;;!!! then we want to insert at the beginning of the buffer.
3850 ;;!!! That happens to be true with Gnus now, but that may
3851 ;;!!! change in the future. Perhaps.
3852 (gnus-data-enter-list
3853 (if line nil current) data (- (point) old-pos))
3854 (setq gnus-newsgroup-threads
3855 (nconc threads gnus-newsgroup-threads))
3856 (gnus-data-compute-positions))))
3858 (defun gnus-number-to-header (number)
3859 "Return the header for article NUMBER."
3860 (let ((headers gnus-newsgroup-headers))
3862 (not (= number (mail-header-number (car headers)))))
3867 (defun gnus-parent-headers (in-headers &optional generation)
3868 "Return the headers of the GENERATIONeth parent of HEADERS."
3870 (setq generation 1))
3872 (headers in-headers)
3875 (not (zerop generation))
3876 (setq references (mail-header-references headers)))
3877 (setq headers (if (and references
3878 (setq parent (gnus-parent-id references)))
3879 (car (gnus-id-to-thread parent))
3882 (and (not (eq headers in-headers))
3885 (defun gnus-id-to-thread (id)
3886 "Return the (sub-)thread where ID appears."
3887 (gnus-gethash id gnus-newsgroup-dependencies))
3889 (defun gnus-id-to-article (id)
3890 "Return the article number of ID."
3891 (let ((thread (gnus-id-to-thread id)))
3894 (mail-header-number (car thread)))))
3896 (defun gnus-id-to-header (id)
3897 "Return the article headers of ID."
3898 (car (gnus-id-to-thread id)))
3900 (defun gnus-article-displayed-root-p (article)
3901 "Say whether ARTICLE is a root(ish) article."
3902 (let ((level (gnus-summary-thread-level article))
3903 (refs (mail-header-references (gnus-summary-article-header article)))
3909 ((null (gnus-parent-id refs)) t)
3911 (null (setq particle (gnus-id-to-article
3912 (gnus-parent-id refs))))
3913 (null (gnus-summary-thread-level particle)))))))
3915 (defun gnus-root-id (id)
3916 "Return the id of the root of the thread where ID appears."
3918 (while (and id (setq prev (car (gnus-id-to-thread id))))
3920 id (gnus-parent-id (mail-header-references prev))))
3923 (defun gnus-articles-in-thread (thread)
3924 "Return the list of articles in THREAD."
3925 (cons (mail-header-number (car thread))
3926 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3928 (defun gnus-remove-thread (id &optional dont-remove)
3929 "Remove the thread that has ID in it."
3930 (let (headers thread last-id)
3931 ;; First go up in this thread until we find the root.
3932 (setq last-id (gnus-root-id id)
3933 headers (message-flatten-list (gnus-id-to-thread last-id)))
3934 ;; We have now found the real root of this thread. It might have
3935 ;; been gathered into some loose thread, so we have to search
3936 ;; through the threads to find the thread we wanted.
3937 (let ((threads gnus-newsgroup-threads)
3940 (setq sub (car threads))
3941 (if (stringp (car sub))
3942 ;; This is a gathered thread, so we look at the roots
3943 ;; below it to find whether this article is in this
3946 (setq sub (cdr sub))
3948 (when (member (caar sub) headers)
3949 (setq thread (car threads)
3952 (setq sub (cdr sub))))
3953 ;; It's an ordinary thread, so we check it.
3954 (when (eq (car sub) (car headers))
3957 (setq threads (cdr threads)))
3958 ;; If this article is in no thread, then it's a root.
3961 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3962 (setq thread (gnus-id-to-thread last-id)))
3965 thread ; We return this thread.
3967 (if (stringp (car thread))
3969 ;; If we use dummy roots, then we have to remove the
3970 ;; dummy root as well.
3971 (when (eq gnus-summary-make-false-root 'dummy)
3972 ;; We go to the dummy root by going to
3973 ;; the first sub-"thread", and then one line up.
3974 (gnus-summary-goto-article
3975 (mail-header-number (caadr thread)))
3978 (gnus-data-compute-positions))
3979 (setq thread (cdr thread))
3981 (gnus-remove-thread-1 (car thread))
3982 (setq thread (cdr thread))))
3983 (gnus-remove-thread-1 thread))))))))
3985 (defun gnus-remove-thread-1 (thread)
3986 "Remove the thread THREAD recursively."
3987 (let ((number (mail-header-number (pop thread)))
3989 (setq thread (reverse thread))
3991 (gnus-remove-thread-1 (pop thread)))
3992 (when (setq d (gnus-data-find number))
3993 (goto-char (gnus-data-pos d))
3994 (gnus-summary-show-thread)
3997 (- (gnus-point-at-bol)
3999 (1+ (gnus-point-at-eol))
4000 (gnus-delete-line)))))))
4002 (defun gnus-sort-threads-1 (threads func)
4003 (sort (mapcar (lambda (thread)
4006 (gnus-sort-threads-1 (cdr thread) func))))
4009 (defun gnus-sort-threads (threads)
4011 (if (not gnus-thread-sort-functions)
4013 (gnus-message 8 "Sorting threads...")
4015 (gnus-sort-threads-1
4017 (gnus-make-sort-function gnus-thread-sort-functions))
4018 (gnus-message 8 "Sorting threads...done"))))
4020 (defun gnus-sort-articles (articles)
4022 (when gnus-article-sort-functions
4023 (gnus-message 7 "Sorting articles...")
4025 (setq gnus-newsgroup-headers
4026 (sort articles (gnus-make-sort-function
4027 gnus-article-sort-functions)))
4028 (gnus-message 7 "Sorting articles...done"))))
4030 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4031 (defmacro gnus-thread-header (thread)
4032 "Return header of first article in THREAD.
4033 Note that THREAD must never, ever be anything else than a variable -
4034 using some other form will lead to serious barfage."
4035 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4036 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4037 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4040 (defsubst gnus-article-sort-by-number (h1 h2)
4041 "Sort articles by article number."
4042 (< (mail-header-number h1)
4043 (mail-header-number h2)))
4045 (defun gnus-thread-sort-by-number (h1 h2)
4046 "Sort threads by root article number."
4047 (gnus-article-sort-by-number
4048 (gnus-thread-header h1) (gnus-thread-header h2)))
4050 (defsubst gnus-article-sort-by-lines (h1 h2)
4051 "Sort articles by article Lines header."
4052 (< (mail-header-lines h1)
4053 (mail-header-lines h2)))
4055 (defun gnus-thread-sort-by-lines (h1 h2)
4056 "Sort threads by root article Lines header."
4057 (gnus-article-sort-by-lines
4058 (gnus-thread-header h1) (gnus-thread-header h2)))
4060 (defsubst gnus-article-sort-by-chars (h1 h2)
4061 "Sort articles by octet length."
4062 (< (mail-header-chars h1)
4063 (mail-header-chars h2)))
4065 (defun gnus-thread-sort-by-chars (h1 h2)
4066 "Sort threads by root article octet length."
4067 (gnus-article-sort-by-chars
4068 (gnus-thread-header h1) (gnus-thread-header h2)))
4070 (defsubst gnus-article-sort-by-author (h1 h2)
4071 "Sort articles by root author."
4073 (let ((addr (car (mime-entity-read-field h1 'From))))
4074 (or (std11-full-name-string addr)
4075 (std11-address-string addr)
4077 (let ((addr (car (mime-entity-read-field h2 'From))))
4078 (or (std11-full-name-string addr)
4079 (std11-address-string addr)
4083 (defun gnus-thread-sort-by-author (h1 h2)
4084 "Sort threads by root author."
4085 (gnus-article-sort-by-author
4086 (gnus-thread-header h1) (gnus-thread-header h2)))
4088 (defsubst gnus-article-sort-by-subject (h1 h2)
4089 "Sort articles by root subject."
4091 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4092 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4094 (defun gnus-thread-sort-by-subject (h1 h2)
4095 "Sort threads by root subject."
4096 (gnus-article-sort-by-subject
4097 (gnus-thread-header h1) (gnus-thread-header h2)))
4099 (defsubst gnus-article-sort-by-date (h1 h2)
4100 "Sort articles by root article date."
4102 (gnus-date-get-time (mail-header-date h1))
4103 (gnus-date-get-time (mail-header-date h2))))
4105 (defun gnus-thread-sort-by-date (h1 h2)
4106 "Sort threads by root article date."
4107 (gnus-article-sort-by-date
4108 (gnus-thread-header h1) (gnus-thread-header h2)))
4110 (defsubst gnus-article-sort-by-score (h1 h2)
4111 "Sort articles by root article score.
4112 Unscored articles will be counted as having a score of zero."
4113 (> (or (cdr (assq (mail-header-number h1)
4114 gnus-newsgroup-scored))
4115 gnus-summary-default-score 0)
4116 (or (cdr (assq (mail-header-number h2)
4117 gnus-newsgroup-scored))
4118 gnus-summary-default-score 0)))
4120 (defun gnus-thread-sort-by-score (h1 h2)
4121 "Sort threads by root article score."
4122 (gnus-article-sort-by-score
4123 (gnus-thread-header h1) (gnus-thread-header h2)))
4125 (defun gnus-thread-sort-by-total-score (h1 h2)
4126 "Sort threads by the sum of all scores in the thread.
4127 Unscored articles will be counted as having a score of zero."
4128 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4130 (defun gnus-thread-total-score (thread)
4131 ;; This function find the total score of THREAD.
4132 (cond ((null thread)
4135 (if (stringp (car thread))
4136 (apply gnus-thread-score-function 0
4137 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4138 (gnus-thread-total-score-1 thread)))
4140 (gnus-thread-total-score-1 (list thread)))))
4142 (defun gnus-thread-total-score-1 (root)
4143 ;; This function find the total score of the thread below ROOT.
4144 (setq root (car root))
4145 (apply gnus-thread-score-function
4147 (mapcar 'gnus-thread-total-score
4148 (cdr (gnus-id-to-thread (mail-header-id root))))
4149 (when (> (mail-header-number root) 0)
4150 (list (or (cdr (assq (mail-header-number root)
4151 gnus-newsgroup-scored))
4152 gnus-summary-default-score 0))))
4153 (list gnus-summary-default-score)
4156 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4157 (defvar gnus-tmp-prev-subject nil)
4158 (defvar gnus-tmp-false-parent nil)
4159 (defvar gnus-tmp-root-expunged nil)
4160 (defvar gnus-tmp-dummy-line nil)
4162 (eval-when-compile (defvar gnus-tmp-header))
4163 (defun gnus-extra-header (type &optional header)
4164 "Return the extra header of TYPE."
4165 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4168 (defvar gnus-tmp-thread-tree-header-string "")
4170 (defvar gnus-sum-thread-tree-root "> "
4171 "With %B spec, used for the root of a thread.
4172 If nil, use subject instead.")
4173 (defvar gnus-sum-thread-tree-single-indent ""
4174 "With %B spec, used for a thread with just one message.
4175 If nil, use subject instead.")
4176 (defvar gnus-sum-thread-tree-vertical "| "
4177 "With %B spec, used for drawing a vertical line.")
4178 (defvar gnus-sum-thread-tree-indent " "
4179 "With %B spec, used for indenting.")
4180 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4181 "With %B spec, used for a leaf with brothers.")
4182 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4183 "With %B spec, used for a leaf without brothers.")
4185 (defun gnus-summary-prepare-threads (threads)
4186 "Prepare summary buffer from THREADS and indentation LEVEL.
4187 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4188 or a straight list of headers."
4189 (gnus-message 7 "Generating summary...")
4191 (setq gnus-newsgroup-threads threads)
4194 (let ((gnus-tmp-level 0)
4195 (default-score (or gnus-summary-default-score 0))
4196 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4197 thread number subject stack state gnus-tmp-gathered beg-match
4198 new-roots gnus-tmp-new-adopts thread-end
4199 gnus-tmp-header gnus-tmp-unread
4200 gnus-tmp-replied gnus-tmp-subject-or-nil
4201 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4202 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4203 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4206 (setq gnus-tmp-prev-subject nil)
4208 (if (vectorp (car threads))
4209 ;; If this is a straight (sic) list of headers, then a
4210 ;; threaded summary display isn't required, so we just create
4211 ;; an unthreaded one.
4212 (gnus-summary-prepare-unthreaded threads)
4214 ;; Do the threaded display.
4216 (while (or threads stack gnus-tmp-new-adopts new-roots)
4218 (if (and (= gnus-tmp-level 0)
4221 (not gnus-tmp-false-parent)
4222 (or gnus-tmp-new-adopts new-roots))
4223 (if gnus-tmp-new-adopts
4224 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4225 thread (list (car gnus-tmp-new-adopts))
4226 gnus-tmp-header (caar thread)
4227 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4229 (setq thread (list (car new-roots))
4230 gnus-tmp-header (caar thread)
4231 new-roots (cdr new-roots))))
4234 ;; If there are some threads, we do them before the
4235 ;; threads on the stack.
4236 (setq thread threads
4237 gnus-tmp-header (caar thread))
4238 ;; There were no current threads, so we pop something off
4240 (setq state (car stack)
4241 gnus-tmp-level (car state)
4242 tree-stack (cadr state)
4243 thread (caddr state)
4245 gnus-tmp-header (caar thread))))
4247 (setq gnus-tmp-false-parent nil)
4248 (setq gnus-tmp-root-expunged nil)
4249 (setq thread-end nil)
4251 (if (stringp gnus-tmp-header)
4252 ;; The header is a dummy root.
4254 ((eq gnus-summary-make-false-root 'adopt)
4255 ;; We let the first article adopt the rest.
4256 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4258 (setq gnus-tmp-gathered
4260 (lambda (h) (mail-header-number (car h)))
4263 (setq thread (cons (list (caar thread)
4266 (setq gnus-tmp-level -1
4267 gnus-tmp-false-parent t))
4268 ((eq gnus-summary-make-false-root 'empty)
4269 ;; We print adopted articles with empty subject fields.
4270 (setq gnus-tmp-gathered
4272 (lambda (h) (mail-header-number (car h)))
4275 (setq gnus-tmp-level -1))
4276 ((eq gnus-summary-make-false-root 'dummy)
4277 ;; We remember that we probably want to output a dummy
4279 (setq gnus-tmp-dummy-line gnus-tmp-header)
4280 (setq gnus-tmp-prev-subject gnus-tmp-header))
4282 ;; We do not make a root for the gathered
4283 ;; sub-threads at all.
4284 (setq gnus-tmp-level -1)))
4286 (setq number (mail-header-number gnus-tmp-header)
4287 subject (mail-header-subject gnus-tmp-header))
4290 ;; If the thread has changed subject, we might want to make
4291 ;; this subthread into a root.
4292 ((and (null gnus-thread-ignore-subject)
4293 (not (zerop gnus-tmp-level))
4294 gnus-tmp-prev-subject
4296 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4297 (setq new-roots (nconc new-roots (list (car thread)))
4299 gnus-tmp-header nil))
4300 ;; If the article lies outside the current limit,
4301 ;; then we do not display it.
4302 ((not (memq number gnus-newsgroup-limit))
4303 (setq gnus-tmp-gathered
4305 (lambda (h) (mail-header-number (car h)))
4308 (setq gnus-tmp-new-adopts (if (cdar thread)
4309 (append gnus-tmp-new-adopts
4311 gnus-tmp-new-adopts)
4313 gnus-tmp-header nil)
4314 (when (zerop gnus-tmp-level)
4315 (setq gnus-tmp-root-expunged t)))
4316 ;; Perhaps this article is to be marked as read?
4317 ((and gnus-summary-mark-below
4318 (< (or (cdr (assq number gnus-newsgroup-scored))
4320 gnus-summary-mark-below)
4321 ;; Don't touch sparse articles.
4322 (not (gnus-summary-article-sparse-p number))
4323 (not (gnus-summary-article-ancient-p number)))
4324 (setq gnus-newsgroup-unreads
4325 (delq number gnus-newsgroup-unreads))
4326 (if gnus-newsgroup-auto-expire
4327 (push number gnus-newsgroup-expirable)
4328 (push (cons number gnus-low-score-mark)
4329 gnus-newsgroup-reads))))
4331 (when gnus-tmp-header
4332 ;; We may have an old dummy line to output before this
4334 (when (and gnus-tmp-dummy-line
4337 (mail-header-subject gnus-tmp-header)))
4338 (gnus-summary-insert-dummy-line
4339 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4340 (setq gnus-tmp-dummy-line nil))
4342 ;; Compute the mark.
4343 (setq gnus-tmp-unread (gnus-article-mark number))
4345 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4346 gnus-tmp-header gnus-tmp-level)
4347 gnus-newsgroup-data)
4349 ;; Actually insert the line.
4351 gnus-tmp-subject-or-nil
4353 ((and gnus-thread-ignore-subject
4354 gnus-tmp-prev-subject
4355 (not (inline (gnus-subject-equal
4356 gnus-tmp-prev-subject subject))))
4358 ((zerop gnus-tmp-level)
4359 (if (and (eq gnus-summary-make-false-root 'empty)
4360 (memq number gnus-tmp-gathered)
4361 gnus-tmp-prev-subject
4362 (inline (gnus-subject-equal
4363 gnus-tmp-prev-subject subject)))
4364 gnus-summary-same-subject
4366 (t gnus-summary-same-subject)))
4367 (if (and (eq gnus-summary-make-false-root 'adopt)
4368 (= gnus-tmp-level 1)
4369 (memq number gnus-tmp-gathered))
4370 (setq gnus-tmp-opening-bracket ?\<
4371 gnus-tmp-closing-bracket ?\>)
4372 (setq gnus-tmp-opening-bracket ?\[
4373 gnus-tmp-closing-bracket ?\]))
4375 gnus-tmp-indentation
4376 (aref gnus-thread-indent-array gnus-tmp-level)
4377 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4378 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4379 gnus-summary-default-score 0)
4381 (if (or (null gnus-summary-default-score)
4382 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4383 gnus-summary-zcore-fuzz))
4385 (if (< gnus-tmp-score gnus-summary-default-score)
4386 gnus-score-below-mark gnus-score-over-mark))
4388 (cond ((memq number gnus-newsgroup-processable)
4390 ((memq number gnus-newsgroup-cached)
4392 ((memq number gnus-newsgroup-replied)
4394 ((memq number gnus-newsgroup-forwarded)
4395 gnus-forwarded-mark)
4396 ((memq number gnus-newsgroup-saved)
4398 ((memq number gnus-newsgroup-recent)
4400 ((memq number gnus-newsgroup-unseen)
4403 gnus-tmp-from (mail-header-from gnus-tmp-header)
4406 ((string-match "<[^>]+> *$" gnus-tmp-from)
4407 (setq beg-match (match-beginning 0))
4408 (or (and (string-match "^\".+\"" gnus-tmp-from)
4409 (substring gnus-tmp-from 1 (1- (match-end 0))))
4410 (substring gnus-tmp-from 0 beg-match)))
4411 ((string-match "(.+)" gnus-tmp-from)
4412 (substring gnus-tmp-from
4413 (1+ (match-beginning 0)) (1- (match-end 0))))
4415 gnus-tmp-thread-tree-header-string
4417 ((not gnus-show-threads) "")
4418 ((zerop gnus-tmp-level)
4420 (or gnus-sum-thread-tree-root subject)
4421 (or gnus-sum-thread-tree-single-indent subject)))
4423 (concat (apply 'concat
4424 (mapcar (lambda (item)
4426 gnus-sum-thread-tree-vertical
4427 gnus-sum-thread-tree-indent))
4428 (cdr (reverse tree-stack))))
4430 gnus-sum-thread-tree-leaf-with-other
4431 gnus-sum-thread-tree-single-leaf)))))
4432 (when (string= gnus-tmp-name "")
4433 (setq gnus-tmp-name gnus-tmp-from))
4434 (unless (numberp gnus-tmp-lines)
4435 (setq gnus-tmp-lines -1))
4436 (if (= gnus-tmp-lines -1)
4437 (setq gnus-tmp-lines "?")
4438 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4439 (gnus-put-text-property
4441 (progn (eval gnus-summary-line-format-spec) (point))
4442 'gnus-number number)
4445 (gnus-run-hooks 'gnus-summary-update-hook)
4448 (setq gnus-tmp-prev-subject subject)))
4450 (when (nth 1 thread)
4451 (push (list (max 0 gnus-tmp-level)
4452 (copy-list tree-stack)
4455 (push (if (nth 1 thread) 1 0) tree-stack)
4456 (incf gnus-tmp-level)
4457 (setq threads (if thread-end nil (cdar thread)))
4459 (setq gnus-tmp-level 0)))))
4460 (gnus-message 7 "Generating summary...done"))
4462 (defun gnus-summary-prepare-unthreaded (headers)
4463 "Generate an unthreaded summary buffer based on HEADERS."
4464 (let (header number mark)
4469 ;; We may have to root out some bad articles...
4470 (when (memq (setq number (mail-header-number
4471 (setq header (pop headers))))
4472 gnus-newsgroup-limit)
4473 ;; Mark article as read when it has a low score.
4474 (when (and gnus-summary-mark-below
4475 (< (or (cdr (assq number gnus-newsgroup-scored))
4476 gnus-summary-default-score 0)
4477 gnus-summary-mark-below)
4478 (not (gnus-summary-article-ancient-p number)))
4479 (setq gnus-newsgroup-unreads
4480 (delq number gnus-newsgroup-unreads))
4481 (if gnus-newsgroup-auto-expire
4482 (push number gnus-newsgroup-expirable)
4483 (push (cons number gnus-low-score-mark)
4484 gnus-newsgroup-reads)))
4486 (setq mark (gnus-article-mark number))
4487 (push (gnus-data-make number mark (1+ (point)) header 0)
4488 gnus-newsgroup-data)
4489 (gnus-summary-insert-line
4491 mark (memq number gnus-newsgroup-replied)
4492 (memq number gnus-newsgroup-expirable)
4493 (mail-header-subject header) nil
4494 (cdr (assq number gnus-newsgroup-scored))
4495 (memq number gnus-newsgroup-processable))))))
4497 (defun gnus-summary-remove-list-identifiers ()
4498 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4499 (let ((regexp (if (consp gnus-list-identifiers)
4500 (mapconcat 'identity gnus-list-identifiers " *\\|")
4501 gnus-list-identifiers))
4504 (dolist (header gnus-newsgroup-headers)
4505 (setq subject (mail-header-subject header)
4507 (while (string-match
4508 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4511 (concat (substring subject 0 (match-beginning 2))
4512 (substring subject (match-end 0)))
4516 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4518 (concat (substring subject 0 (match-beginning 1))
4519 (substring subject (match-end 1)))))
4521 (mail-header-set-subject header subject))))))
4523 (defun gnus-fetch-headers (articles)
4524 "Fetch headers of ARTICLES."
4525 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4526 (gnus-message 5 "Fetching headers for %s..." name)
4529 (setq gnus-headers-retrieved-by
4530 (gnus-retrieve-headers
4531 articles gnus-newsgroup-name
4532 ;; We might want to fetch old headers, but
4533 ;; not if there is only 1 article.
4535 (not (eq gnus-fetch-old-headers 'some))
4536 (not (numberp gnus-fetch-old-headers)))
4537 (> (length articles) 1))
4538 gnus-fetch-old-headers))))
4539 (gnus-get-newsgroup-headers-xover
4540 articles nil nil gnus-newsgroup-name t)
4541 (gnus-get-newsgroup-headers))
4542 (gnus-message 5 "Fetching headers for %s...done" name))))
4544 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4545 "Select newsgroup GROUP.
4546 If READ-ALL is non-nil, all articles in the group are selected.
4547 If SELECT-ARTICLES, only select those articles from GROUP."
4548 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4549 ;;!!! Dirty hack; should be removed.
4550 (gnus-summary-ignore-duplicates
4551 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4553 gnus-summary-ignore-duplicates))
4554 (info (nth 2 entry))
4555 articles fetched-articles cached)
4557 (unless (gnus-check-server
4558 (set (make-local-variable 'gnus-current-select-method)
4559 (gnus-find-method-for-group group)))
4560 (error "Couldn't open server"))
4562 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4563 (gnus-activate-group group) ; Or we can activate it...
4564 (progn ; Or we bug out.
4565 (when (equal major-mode 'gnus-summary-mode)
4566 (kill-buffer (current-buffer)))
4567 (error "Couldn't activate group %s: %s"
4568 group (gnus-status-message group))))
4570 (unless (gnus-request-group group t)
4571 (when (equal major-mode 'gnus-summary-mode)
4572 (kill-buffer (current-buffer)))
4573 (error "Couldn't request group %s: %s"
4574 group (gnus-status-message group)))
4576 (setq gnus-newsgroup-name group
4577 gnus-newsgroup-unselected nil
4578 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4580 (let ((display (gnus-group-find-parameter group 'display)))
4581 (setq gnus-newsgroup-display
4583 ((not (zerop (or (car-safe read-all) 0)))
4584 ;; The user entered the group with C-u SPC/RET, let's show
4590 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4592 ;; The following is probably the "correct" solution, but
4593 ;; it makes Gnus fetch all headers and then limit the
4594 ;; articles (which is slow), so instead we hack the
4595 ;; select-articles parameter instead. -- Simon Josefsson
4598 ;; (gnus-byte-compile
4599 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4601 (setq select-articles
4602 (gnus-uncompress-range
4603 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4607 (cdr (gnus-active group)))))
4612 (gnus-summary-setup-default-charset)
4614 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4615 (when (gnus-virtual-group-p group)
4616 (setq cached gnus-newsgroup-cached))
4618 (setq gnus-newsgroup-unreads
4619 (gnus-set-difference
4620 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4621 gnus-newsgroup-dormant))
4623 (setq gnus-newsgroup-processable nil)
4625 (gnus-update-read-articles group gnus-newsgroup-unreads)
4627 ;; Adjust and set lists of article marks.
4629 (gnus-adjust-marked-articles info))
4631 (if (setq articles select-articles)
4632 (setq gnus-newsgroup-unselected
4633 (gnus-sorted-intersection
4634 gnus-newsgroup-unreads
4635 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4636 (setq articles (gnus-articles-to-read group read-all)))
4640 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4642 ((eq articles 0) nil)
4644 ;; Init the dependencies hash table.
4645 (setq gnus-newsgroup-dependencies
4646 (gnus-make-hashtable (length articles)))
4647 (gnus-set-global-variables)
4648 ;; Retrieve the headers and read them in.
4649 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4651 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4653 (setq gnus-newsgroup-cached cached))
4655 ;; Suppress duplicates?
4656 (when gnus-suppress-duplicates
4657 (gnus-dup-suppress-articles))
4659 ;; Set the initial limit.
4660 (setq gnus-newsgroup-limit (copy-sequence articles))
4661 ;; Remove canceled articles from the list of unread articles.
4662 (setq fetched-articles
4663 (mapcar (lambda (headers) (mail-header-number headers))
4664 gnus-newsgroup-headers))
4665 (setq gnus-newsgroup-articles fetched-articles)
4666 (setq gnus-newsgroup-unreads
4667 (gnus-set-sorted-intersection
4668 gnus-newsgroup-unreads fetched-articles))
4670 (let ((marks (assq 'seen (gnus-info-marks info))))
4671 ;; The `seen' marks are treated specially.
4672 (when (setq gnus-newsgroup-seen (cdr marks))
4673 (dolist (article gnus-newsgroup-articles)
4674 (unless (gnus-member-of-range
4675 article gnus-newsgroup-seen)
4676 (push article gnus-newsgroup-unseen)))))
4678 ;; Removed marked articles that do not exist.
4679 (gnus-update-missing-marks
4680 (gnus-sorted-complement fetched-articles articles))
4681 ;; We might want to build some more threads first.
4682 (when (and gnus-fetch-old-headers
4683 (eq gnus-headers-retrieved-by 'nov))
4684 (if (eq gnus-fetch-old-headers 'invisible)
4685 (gnus-build-all-threads)
4686 (gnus-build-old-threads)))
4687 ;; Let the Gnus agent mark articles as read.
4689 (gnus-agent-get-undownloaded-list))
4690 ;; Remove list identifiers from subject
4691 (when gnus-list-identifiers
4692 (gnus-summary-remove-list-identifiers))
4693 ;; Check whether auto-expire is to be done in this group.
4694 (setq gnus-newsgroup-auto-expire
4695 (gnus-group-auto-expirable-p group))
4696 ;; Set up the article buffer now, if necessary.
4697 (unless gnus-single-article-buffer
4698 (gnus-article-setup-buffer))
4699 ;; First and last article in this newsgroup.
4700 (when gnus-newsgroup-headers
4701 (setq gnus-newsgroup-begin
4702 (mail-header-number (car gnus-newsgroup-headers))
4705 (gnus-last-element gnus-newsgroup-headers))))
4706 ;; GROUP is successfully selected.
4707 (or gnus-newsgroup-headers t)))))
4709 (defun gnus-summary-display-make-predicate (display)
4710 (require 'gnus-agent)
4711 (when (= (length display) 1)
4712 (setq display (car display)))
4713 (unless gnus-summary-display-cache
4714 (dolist (elem (append (list (cons 'read 'read)
4715 (cons 'unseen 'unseen))
4716 gnus-article-mark-lists))
4717 (push (cons (cdr elem)
4719 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4720 gnus-summary-display-cache)))
4721 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4722 (gnus-get-predicate display)))
4724 ;; Uses the dynamically bound `number' variable.
4726 (defun gnus-article-marked-p (type &optional article)
4727 (let ((article (or article number)))
4730 (memq article gnus-newsgroup-marked))
4732 (memq article gnus-newsgroup-unsendable))
4733 ((eq type 'undownload)
4734 (memq article gnus-newsgroup-undownloaded))
4735 ((eq type 'download)
4736 (memq article gnus-newsgroup-downloadable))
4738 (memq article gnus-newsgroup-unreads))
4740 (memq article gnus-newsgroup-reads))
4742 (memq article gnus-newsgroup-dormant) )
4744 (memq article gnus-newsgroup-expirable))
4746 (memq article gnus-newsgroup-replied))
4748 (memq article gnus-newsgroup-killed))
4749 ((eq type 'bookmark)
4750 (assq article gnus-newsgroup-bookmarks))
4752 (assq article gnus-newsgroup-scored))
4754 (memq article gnus-newsgroup-saved))
4756 (memq article gnus-newsgroup-cached))
4758 (memq article gnus-newsgroup-forwarded))
4760 (not (memq article gnus-newsgroup-unseen)))
4762 (memq article gnus-newsgroup-recent))
4765 (defun gnus-articles-to-read (group &optional read-all)
4766 "Find out what articles the user wants to read."
4768 ;; Select all articles if `read-all' is non-nil, or if there
4769 ;; are no unread articles.
4771 (and (zerop (length gnus-newsgroup-marked))
4772 (zerop (length gnus-newsgroup-unreads)))
4773 (eq gnus-newsgroup-display 'gnus-not-ignore))
4774 ;; We want to select the headers for all the articles in
4775 ;; the group, so we select either all the active
4776 ;; articles in the group, or (if that's nil), the
4777 ;; articles in the cache.
4779 (gnus-uncompress-range (gnus-active group))
4780 (gnus-cache-articles-in-group group))
4781 ;; Select only the "normal" subset of articles.
4782 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4783 (copy-sequence gnus-newsgroup-unreads))
4785 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4786 (scored (length scored-list))
4787 (number (length articles))
4788 (marked (+ (length gnus-newsgroup-marked)
4789 (length gnus-newsgroup-dormant)))
4797 ((and (or (<= scored marked) (= scored number))
4798 (natnump gnus-large-newsgroup)
4799 (> number gnus-large-newsgroup))
4800 (let* ((cursor-in-echo-area nil)
4802 (read-from-minibuffer
4804 "How many articles from %s (max %d): "
4806 (gnus-group-decoded-name gnus-newsgroup-name)
4809 (cons (number-to-string gnus-large-newsgroup)
4811 (if (string-match "^[ \t]*$" input)
4814 ((and (> scored marked) (< scored number)
4815 (> (- scored number) 20))
4818 (format "%s %s (%d scored, %d total): "
4819 "How many articles from"
4820 (gnus-group-decoded-name group)
4822 (if (string-match "^[ \t]*$" input)
4826 (message "Quit getting the articles to read")
4828 (setq select (if (stringp select) (string-to-number select) select))
4829 (if (or (null select) (zerop select))
4831 (if (and (not (zerop scored)) (<= (abs select) scored))
4833 (setq articles (sort scored-list '<))
4834 (setq number (length articles)))
4835 (setq articles (copy-sequence articles)))
4837 (when (< (abs select) number)
4839 ;; Select the N oldest articles.
4840 (setcdr (nthcdr (1- (abs select)) articles) nil)
4841 ;; Select the N most recent articles.
4842 (setq articles (nthcdr (- number select) articles))))
4843 (setq gnus-newsgroup-unselected
4844 (gnus-sorted-intersection
4845 gnus-newsgroup-unreads
4846 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4847 (when gnus-alter-articles-to-read-function
4848 (setq gnus-newsgroup-unreads
4850 (funcall gnus-alter-articles-to-read-function
4851 gnus-newsgroup-name gnus-newsgroup-unreads)
4855 (defun gnus-killed-articles (killed articles)
4858 (when (inline (gnus-member-of-range (car articles) killed))
4859 (push (car articles) out))
4860 (setq articles (cdr articles)))
4863 (defun gnus-uncompress-marks (marks)
4864 "Uncompress the mark ranges in MARKS."
4865 (let ((uncompressed '(score bookmark))
4868 (if (memq (caar marks) uncompressed)
4869 (push (car marks) out)
4870 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4871 (setq marks (cdr marks)))
4874 (defun gnus-article-mark-to-type (mark)
4875 "Return the type of MARK."
4876 (or (cadr (assq mark gnus-article-special-mark-lists))
4879 (defun gnus-article-unpropagatable-p (mark)
4880 "Return whether MARK should be propagated to backend."
4881 (memq mark gnus-article-unpropagated-mark-lists))
4883 (defun gnus-adjust-marked-articles (info)
4884 "Set all article lists and remove all marks that are no longer valid."
4885 (let* ((marked-lists (gnus-info-marks info))
4886 (active (gnus-active (gnus-info-group info)))
4889 (types gnus-article-mark-lists)
4890 marks var articles article mark mark-type)
4892 (dolist (marks marked-lists)
4893 (setq mark (car marks)
4894 mark-type (gnus-article-mark-to-type mark)
4895 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4897 ;; We set the variable according to the type of the marks list,
4898 ;; and then adjust the marks to a subset of the active articles.
4900 ;; Adjust "simple" lists.
4901 ((eq mark-type 'list)
4902 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4903 (when (memq mark '(tick dormant expire reply save))
4905 (when (or (< (setq article (pop articles)) min) (> article max))
4906 (set var (delq article (symbol-value var)))))))
4908 ((eq mark-type 'tuple)
4909 (set var (setq articles (cdr marks)))
4910 (when (not (listp (cdr (symbol-value var))))
4911 (set var (list (symbol-value var))))
4912 (when (not (listp (cdr articles)))
4913 (setq articles (list articles)))
4915 (when (or (not (consp (setq article (pop articles))))
4916 (< (car article) min)
4917 (> (car article) max))
4918 (set var (delq article (symbol-value var))))))
4919 ((eq mark-type 'range)
4921 ((eq mark 'seen))))))))
4923 (defun gnus-update-missing-marks (missing)
4924 "Go through the list of MISSING articles and remove them from the mark lists."
4927 ;; Go through all types.
4928 (dolist (elem gnus-article-mark-lists)
4929 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4930 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4931 (when (symbol-value var)
4932 ;; This list has articles. So we delete all missing
4933 ;; articles from it.
4936 (set var (delq (pop m) (symbol-value var))))))))))
4938 (defun gnus-update-marks ()
4939 "Enter the various lists of marked articles into the newsgroup info list."
4940 (let ((types gnus-article-mark-lists)
4941 (info (gnus-get-info gnus-newsgroup-name))
4942 type list newmarked symbol delta-marks)
4944 ;; Add all marks lists to the list of marks lists.
4945 (while (setq type (pop types))
4946 (setq list (symbol-value
4948 (intern (format "gnus-newsgroup-%s" (car type))))))
4951 ;; Get rid of the entries of the articles that have the
4953 (when (and (eq (cdr type) 'score)
4957 (prev (cons nil list))
4960 (if (or (not (consp (car arts)))
4961 (= (cdar arts) gnus-summary-default-score))
4962 (setcdr prev (cdr arts))
4964 (setq arts (cdr arts)))
4965 (setq list (cdr all)))))
4967 (when (eq (cdr type) 'seen)
4970 (gnus-add-to-range list gnus-newsgroup-unseen)
4971 (gnus-compress-sequence gnus-newsgroup-articles))))
4973 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
4974 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4976 (when (and (gnus-check-backend-function
4977 'request-set-mark gnus-newsgroup-name)
4978 (not (gnus-article-unpropagatable-p (cdr type))))
4979 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4980 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4981 (add (gnus-remove-from-range
4982 (gnus-copy-sequence list) old)))
4984 (push (list add 'add (list (cdr type))) delta-marks))
4986 (push (list del 'del (list (cdr type))) delta-marks))))
4989 (push (cons (cdr type) list) newmarked)))
4992 (unless (gnus-check-group gnus-newsgroup-name)
4993 (error "Can't open server for %s" gnus-newsgroup-name))
4994 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4996 ;; Enter these new marks into the info of the group.
4998 (setcar (nthcdr 3 info) newmarked)
4999 ;; Add the marks lists to the end of the info.
5001 (setcdr (nthcdr 2 info) (list newmarked))))
5003 ;; Cut off the end of the info if there's nothing else there.
5007 (when (nthcdr (decf i) info)
5008 (setcdr (nthcdr i info) nil)))))))
5010 (defun gnus-set-mode-line (where)
5011 "Set the mode line of the article or summary buffers.
5012 If WHERE is `summary', the summary mode line format will be used."
5013 ;; Is this mode line one we keep updated?
5014 (when (and (memq where gnus-updated-mode-lines)
5016 (intern (format "gnus-%s-mode-line-format-spec" where))))
5019 ;; We evaluate this in the summary buffer since these
5020 ;; variables are buffer-local to that buffer.
5021 (set-buffer gnus-summary-buffer)
5022 ;; We bind all these variables that are used in the `eval' form
5024 (let* ((mformat (symbol-value
5026 (format "gnus-%s-mode-line-format-spec" where))))
5027 (gnus-tmp-group-name (gnus-group-decoded-name
5028 gnus-newsgroup-name))
5029 (gnus-tmp-article-number (or gnus-current-article 0))
5030 (gnus-tmp-unread gnus-newsgroup-unreads)
5031 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5032 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5033 (gnus-tmp-unread-and-unselected
5034 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5035 (zerop gnus-tmp-unselected))
5037 ((zerop gnus-tmp-unselected)
5038 (format "{%d more}" gnus-tmp-unread-and-unticked))
5039 (t (format "{%d(+%d) more}"
5040 gnus-tmp-unread-and-unticked
5041 gnus-tmp-unselected))))
5043 (if (and gnus-current-headers
5044 (vectorp gnus-current-headers))
5045 (gnus-mode-string-quote
5046 (mail-header-subject gnus-current-headers))
5048 bufname-length max-len
5049 gnus-tmp-header);; passed as argument to any user-format-funcs
5050 (setq mode-string (eval mformat))
5051 (setq bufname-length (if (string-match "%b" mode-string)
5054 (if (eq where 'summary)
5056 (get-buffer gnus-article-buffer))))
5059 (setq max-len (max 4 (if gnus-mode-non-string-length
5061 gnus-mode-non-string-length
5063 (length mode-string))))
5064 ;; We might have to chop a bit of the string off...
5065 (when (> (length mode-string) max-len)
5067 (concat (gnus-truncate-string mode-string (- max-len 3))
5069 ;; Pad the mode string a bit.
5070 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5071 ;; Update the mode line.
5072 (setq mode-line-buffer-identification
5073 (gnus-mode-line-buffer-identification (list mode-string)))
5074 (set-buffer-modified-p t))))
5076 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5077 "Go through the HEADERS list and add all Xrefs to a hash table.
5078 The resulting hash table is returned, or nil if no Xrefs were found."
5079 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5080 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5081 (xref-hashtb (gnus-make-hashtable))
5082 start group entry number xrefs header)
5084 (setq header (pop headers))
5085 (when (and (setq xrefs (mail-header-xref header))
5086 (not (memq (setq number (mail-header-number header))
5089 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5090 (setq start (match-end 0))
5091 (setq group (if prefix
5092 (concat prefix (substring xrefs (match-beginning 1)
5094 (substring xrefs (match-beginning 1) (match-end 1))))
5096 (string-to-int (substring xrefs (match-beginning 2)
5098 (if (setq entry (gnus-gethash group xref-hashtb))
5099 (setcdr entry (cons number (cdr entry)))
5100 (gnus-sethash group (cons number nil) xref-hashtb)))))
5101 (and start xref-hashtb)))
5103 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5104 "Look through all the headers and mark the Xrefs as read."
5105 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5106 name entry info xref-hashtb idlist method nth4)
5108 (set-buffer gnus-group-buffer)
5109 (when (setq xref-hashtb
5110 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5113 (unless (string= from-newsgroup (setq name (symbol-name group)))
5114 (setq idlist (symbol-value group))
5115 ;; Dead groups are not updated.
5117 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5119 (when (stringp (setq nth4 (gnus-info-method info)))
5120 (setq nth4 (gnus-server-to-method nth4))))
5121 ;; Only do the xrefs if the group has the same
5122 ;; select method as the group we have just read.
5123 (or (gnus-methods-equal-p
5124 nth4 (gnus-find-method-for-group from-newsgroup))
5126 (equal nth4 (setq method (gnus-find-method-for-group
5128 (and (equal (car nth4) (car method))
5129 (equal (nth 1 nth4) (nth 1 method))))
5130 gnus-use-cross-reference
5131 (or (not (eq gnus-use-cross-reference t))
5133 ;; Only do cross-references on subscribed
5134 ;; groups, if that is what is wanted.
5135 (<= (gnus-info-level info) gnus-level-subscribed))
5136 (gnus-group-make-articles-read name idlist))))
5139 (defun gnus-compute-read-articles (group articles)
5140 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5141 (info (nth 2 entry))
5142 (active (gnus-active group))
5145 ;; First peel off all invalid article numbers.
5147 (let ((ids articles)
5149 (while (setq id (pop ids))
5150 (when (and first (> id (cdr active)))
5151 ;; We'll end up in this situation in one particular
5152 ;; obscure situation. If you re-scan a group and get
5153 ;; a new article that is cross-posted to a different
5154 ;; group that has not been re-scanned, you might get
5155 ;; crossposted article that has a higher number than
5156 ;; Gnus believes possible. So we re-activate this
5157 ;; group as well. This might mean doing the
5158 ;; crossposting thingy will *increase* the number
5159 ;; of articles in some groups. Tsk, tsk.
5160 (setq active (or (gnus-activate-group group) active)))
5161 (when (or (> id (cdr active))
5162 (< id (car active)))
5163 (setq articles (delq id articles))))))
5164 ;; If the read list is nil, we init it.
5166 (null (gnus-info-read info))
5168 (setq ninfo (cons 1 (1- (car active))))
5169 (setq ninfo (gnus-info-read info)))
5170 ;; Then we add the read articles to the range.
5172 ninfo (setq articles (sort articles '<))))))
5174 (defun gnus-group-make-articles-read (group articles)
5175 "Update the info of GROUP to say that ARTICLES are read."
5177 (entry (gnus-gethash group gnus-newsrc-hashtb))
5178 (info (nth 2 entry))
5179 (active (gnus-active group))
5182 (setq range (gnus-compute-read-articles group articles))
5184 (set-buffer gnus-group-buffer)
5187 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5188 (gnus-info-set-read ',info ',(gnus-info-read info))
5189 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5190 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5191 (gnus-group-update-group ,group t))))
5192 ;; Add the read articles to the range.
5193 (gnus-info-set-read info range)
5194 (gnus-request-set-mark group (list (list range 'add '(read))))
5195 ;; Then we have to re-compute how many unread
5196 ;; articles there are in this group.
5200 (setq num (- (1+ (cdr active)) (car active))))
5201 ((not (listp (cdr range)))
5202 (setq num (- (cdr active) (- (1+ (cdr range))
5206 (if (numberp (car range))
5208 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5209 (setq range (cdr range)))
5210 (setq num (- (cdr active) num))))
5211 ;; Update the number of unread articles.
5213 ;; Update the group buffer.
5214 (gnus-group-update-group group t)))))
5216 (defvar gnus-newsgroup-none-id 0)
5218 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5219 (let ((cur nntp-server-buffer)
5222 (save-excursion (set-buffer gnus-summary-buffer)
5223 gnus-newsgroup-dependencies)))
5225 (mail-parse-charset gnus-newsgroup-charset)
5226 (mail-parse-ignored-charsets
5227 (save-excursion (condition-case nil
5228 (set-buffer gnus-summary-buffer)
5230 gnus-newsgroup-ignored-charsets)))
5232 (set-buffer nntp-server-buffer)
5233 ;; Translate all TAB characters into SPACE characters.
5234 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5235 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5236 (gnus-run-hooks 'gnus-parse-headers-hook)
5237 (let ((case-fold-search t)
5238 in-reply-to header p lines chars ctype)
5239 (goto-char (point-min))
5240 ;; Search to the beginning of the next header. Error messages
5241 ;; do not begin with 2 or 3.
5242 (while (re-search-forward "^[23][0-9]+ " nil t)
5245 ;; This implementation of this function, with nine
5246 ;; search-forwards instead of the one re-search-forward and
5247 ;; a case (which basically was the old function) is actually
5248 ;; about twice as fast, even though it looks messier. You
5249 ;; can't have everything, I guess. Speed and elegance
5250 ;; doesn't always go hand in hand.
5253 (make-full-mail-header
5259 (narrow-to-region (point)
5260 (or (and (search-forward "\n.\n" nil t)
5266 (if (search-forward "\nsubject:" nil t)
5267 (nnheader-header-value)
5272 (if (search-forward "\nfrom:" nil t)
5273 (nnheader-header-value)
5278 (if (search-forward "\ndate:" nil t)
5279 (nnheader-header-value) ""))
5283 (setq id (if (re-search-forward
5284 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5285 ;; We do it this way to make sure the Message-ID
5286 ;; is (somewhat) syntactically valid.
5287 (buffer-substring (match-beginning 1)
5289 ;; If there was no message-id, we just fake one
5290 ;; to make subsequent routines simpler.
5291 (nnheader-generate-fake-message-id))))
5295 (if (search-forward "\nreferences:" nil t)
5299 (nnheader-header-value)
5304 (search-backward ">" end t)
5307 (search-backward "<" end t)
5309 ;; Get the references from the in-reply-to header if there
5310 ;; were no references and the in-reply-to header looks
5312 (if (and (search-forward "\nin-reply-to:" nil t)
5313 (setq in-reply-to (nnheader-header-value))
5314 (string-match "<[^>]+>" in-reply-to))
5316 (setq ref (substring in-reply-to (match-beginning 0)
5318 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5319 (setq ref2 (substring in-reply-to (match-beginning 0)
5321 (when (> (length ref2) (length ref))
5328 (if (search-forward "\nchars: " nil t)
5329 (if (numberp (setq chars (ignore-errors (read cur))))
5335 (if (search-forward "\nlines: " nil t)
5336 (if (numberp (setq lines (ignore-errors (read cur))))
5342 (and (search-forward "\nxref:" nil t)
5343 (nnheader-header-value)))
5345 (when gnus-extra-headers
5346 (let ((extra gnus-extra-headers)
5350 (when (search-forward
5351 (concat "\n" (symbol-name (car extra)) ":") nil t)
5352 (push (cons (car extra) (nnheader-header-value)) out))
5356 (if (and (search-forward "\ncontent-type: " nil t)
5357 (setq ctype (nnheader-header-value)))
5358 (mime-entity-set-content-type-internal
5359 header (mime-parse-Content-Type ctype)))
5360 (when (equal id ref)
5363 (when gnus-alter-header-function
5364 (funcall gnus-alter-header-function header)
5365 (setq id (mail-header-id header)
5366 ref (gnus-parent-id (mail-header-references header))))
5369 (gnus-dependencies-add-header
5370 header dependencies force-new))
5371 (push header headers))
5372 (goto-char (point-max))
5374 (nreverse headers)))))
5376 ;; Goes through the xover lines and returns a list of vectors
5377 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5378 force-new dependencies
5379 group also-fetch-heads)
5380 "Parse the news overview data in the server buffer.
5381 Return a list of headers that match SEQUENCE (see
5382 `nntp-retrieve-headers')."
5383 ;; Get the Xref when the users reads the articles since most/some
5384 ;; NNTP servers do not include Xrefs when using XOVER.
5385 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5386 (let ((mail-parse-charset gnus-newsgroup-charset)
5387 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5388 (cur nntp-server-buffer)
5389 (dependencies (or dependencies gnus-newsgroup-dependencies))
5391 ((eq gnus-read-all-available-headers t)
5393 ((stringp gnus-read-all-available-headers)
5394 (string-match gnus-read-all-available-headers group))
5397 number headers header)
5399 (set-buffer nntp-server-buffer)
5400 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5401 ;; Allow the user to mangle the headers before parsing them.
5402 (gnus-run-hooks 'gnus-parse-headers-hook)
5403 (goto-char (point-min))
5406 (while (and (or sequence allp)
5408 (setq number (read cur))
5410 (while (and sequence
5411 (< (car sequence) number))
5412 (setq sequence (cdr sequence))))
5415 (eq number (car sequence))))
5417 (setq sequence (cdr sequence))
5418 (setq header (inline
5419 (gnus-nov-parse-line
5420 number dependencies force-new)))))
5421 (push header headers))
5424 (gnus-error 4 "Strange nov line (%d)"
5425 (count-lines (point-min) (point)))))
5427 ;; A common bug in inn is that if you have posted an article and
5428 ;; then retrieves the active file, it will answer correctly --
5429 ;; the new article is included. However, a NOV entry for the
5430 ;; article may not have been generated yet, so this may fail.
5431 ;; We work around this problem by retrieving the last few
5432 ;; headers using HEAD.
5433 (if (or (not also-fetch-heads)
5435 ;; We (probably) got all the headers.
5437 (let ((gnus-nov-is-evil t))
5440 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5441 (gnus-get-newsgroup-headers))))))))
5443 (defun gnus-article-get-xrefs ()
5444 "Fill in the Xref value in `gnus-current-headers', if necessary.
5445 This is meant to be called in `gnus-article-internal-prepare-hook'."
5446 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5447 gnus-current-headers)))
5448 (or (not gnus-use-cross-reference)
5450 (and (mail-header-xref headers)
5451 (not (string= (mail-header-xref headers) "")))
5452 (let ((case-fold-search t)
5455 (nnheader-narrow-to-headers)
5456 (goto-char (point-min))
5457 (when (or (and (not (eobp))
5458 (eq (downcase (char-after)) ?x)
5459 (looking-at "Xref:"))
5460 (search-forward "\nXref:" nil t))
5461 (goto-char (1+ (match-end 0)))
5462 (setq xref (buffer-substring (point)
5463 (progn (end-of-line) (point))))
5464 (mail-header-set-xref headers xref)))))))
5466 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5467 "Find article ID and insert the summary line for that article.
5468 OLD-HEADER can either be a header or a line number to insert
5469 the subject line on."
5470 (let* ((line (and (numberp old-header) old-header))
5471 (old-header (and (vectorp old-header) old-header))
5472 (header (cond ((and old-header use-old-header)
5475 (gnus-number-to-header id))
5476 (gnus-number-to-header id))
5478 (gnus-read-header id))))
5479 (number (and (numberp id) id))
5482 ;; Rebuild the thread that this article is part of and go to the
5483 ;; article we have fetched.
5484 (when (and (not gnus-show-threads)
5487 (setq d (gnus-data-find (mail-header-number old-header))))
5488 (goto-char (gnus-data-pos d))
5491 (- (gnus-point-at-bol)
5493 (1+ (gnus-point-at-eol))
5494 (gnus-delete-line))))))
5496 (mail-header-set-number header (mail-header-number old-header)))
5497 (setq gnus-newsgroup-sparse
5498 (delq (setq number (mail-header-number header))
5499 gnus-newsgroup-sparse))
5500 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5501 (push number gnus-newsgroup-limit)
5502 (gnus-rebuild-thread (mail-header-id header) line)
5503 (gnus-summary-goto-subject number nil t))
5504 (when (and (numberp number)
5506 ;; We have to update the boundaries even if we can't fetch the
5507 ;; article if ID is a number -- so that the next `P' or `N'
5508 ;; command will fetch the previous (or next) article even
5509 ;; if the one we tried to fetch this time has been canceled.
5510 (when (> number gnus-newsgroup-end)
5511 (setq gnus-newsgroup-end number))
5512 (when (< number gnus-newsgroup-begin)
5513 (setq gnus-newsgroup-begin number))
5514 (setq gnus-newsgroup-unselected
5515 (delq number gnus-newsgroup-unselected)))
5516 ;; Report back a success?
5517 (and header (mail-header-number header))))
5519 ;;; Process/prefix in the summary buffer
5521 (defun gnus-summary-work-articles (n)
5522 "Return a list of articles to be worked upon.
5523 The prefix argument, the list of process marked articles, and the
5524 current article will be taken into consideration."
5526 (set-buffer gnus-summary-buffer)
5529 ;; A numerical prefix has been given.
5530 (setq n (prefix-numeric-value n))
5531 (let ((backward (< n 0))
5532 (n (abs (prefix-numeric-value n)))
5537 (push (setq article (gnus-summary-article-number))
5540 (gnus-summary-find-prev nil article)
5541 (gnus-summary-find-next nil article)))
5543 (nreverse articles)))
5544 ((and (gnus-region-active-p) (mark))
5545 (message "region active")
5546 ;; Work on the region between point and mark.
5547 (let ((max (max (point) (mark)))
5550 (goto-char (min (point) (mark)))
5553 (push (setq article (gnus-summary-article-number)) articles)
5554 (gnus-summary-find-next nil article)
5556 (nreverse articles))))
5557 (gnus-newsgroup-processable
5558 ;; There are process-marked articles present.
5559 ;; Save current state.
5560 (gnus-summary-save-process-mark)
5562 (reverse gnus-newsgroup-processable))
5564 ;; Just return the current article.
5565 (list (gnus-summary-article-number))))))
5567 (defmacro gnus-summary-iterate (arg &rest forms)
5568 "Iterate over the process/prefixed articles and do FORMS.
5569 ARG is the interactive prefix given to the command. FORMS will be
5570 executed with point over the summary line of the articles."
5571 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5572 `(let ((,articles (gnus-summary-work-articles ,arg)))
5574 (gnus-summary-goto-subject (car ,articles))
5578 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5579 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5581 (defun gnus-summary-save-process-mark ()
5582 "Push the current set of process marked articles on the stack."
5584 (push (copy-sequence gnus-newsgroup-processable)
5585 gnus-newsgroup-process-stack))
5587 (defun gnus-summary-kill-process-mark ()
5588 "Push the current set of process marked articles on the stack and unmark."
5590 (gnus-summary-save-process-mark)
5591 (gnus-summary-unmark-all-processable))
5593 (defun gnus-summary-yank-process-mark ()
5594 "Pop the last process mark state off the stack and restore it."
5596 (unless gnus-newsgroup-process-stack
5597 (error "Empty mark stack"))
5598 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5600 (defun gnus-summary-process-mark-set (set)
5601 "Make SET into the current process marked articles."
5602 (gnus-summary-unmark-all-processable)
5604 (gnus-summary-set-process-mark (pop set))))
5606 ;;; Searching and stuff
5608 (defun gnus-summary-search-group (&optional backward use-level)
5609 "Search for next unread newsgroup.
5610 If optional argument BACKWARD is non-nil, search backward instead."
5612 (set-buffer gnus-group-buffer)
5613 (when (gnus-group-search-forward
5614 backward nil (if use-level (gnus-group-group-level) nil))
5615 (gnus-group-group-name))))
5617 (defun gnus-summary-best-group (&optional exclude-group)
5618 "Find the name of the best unread group.
5619 If EXCLUDE-GROUP, do not go to this group."
5621 (set-buffer gnus-group-buffer)
5623 (gnus-group-best-unread-group exclude-group))))
5625 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5626 (if backward (gnus-summary-find-prev)
5627 (let* ((dummy (gnus-summary-article-intangible-p))
5628 (article (or article (gnus-summary-article-number)))
5629 (arts (gnus-data-find-list article))
5631 (when (and (not dummy)
5632 (or (not gnus-summary-check-current)
5634 (not (gnus-data-unread-p (car arts)))))
5635 (setq arts (cdr arts)))
5640 (when (or (and undownloaded
5641 (eq gnus-undownloaded-mark
5642 (gnus-data-mark (car arts))))
5643 (gnus-data-unread-p (car arts)))
5644 (setq result (car arts)
5646 (setq arts (cdr arts)))
5649 (goto-char (gnus-data-pos result))
5650 (gnus-data-number result)))))
5652 (defun gnus-summary-find-prev (&optional unread article)
5653 (let* ((eobp (eobp))
5654 (article (or article (gnus-summary-article-number)))
5655 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5657 (when (and (not eobp)
5658 (or (not gnus-summary-check-current)
5660 (not (gnus-data-unread-p (car arts)))))
5661 (setq arts (cdr arts)))
5666 (when (gnus-data-unread-p (car arts))
5667 (setq result (car arts)
5669 (setq arts (cdr arts)))
5672 (goto-char (gnus-data-pos result))
5673 (gnus-data-number result))))
5675 (defun gnus-summary-find-subject (subject &optional unread backward article)
5676 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5677 (article (or article (gnus-summary-article-number)))
5678 (articles (gnus-data-list backward))
5679 (arts (gnus-data-find-list article articles))
5681 (when (or (not gnus-summary-check-current)
5683 (not (gnus-data-unread-p (car arts))))
5684 (setq arts (cdr arts)))
5686 (and (or (not unread)
5687 (gnus-data-unread-p (car arts)))
5688 (vectorp (gnus-data-header (car arts)))
5690 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5691 (setq result (car arts)
5693 (setq arts (cdr arts)))
5695 (goto-char (gnus-data-pos result))
5696 (gnus-data-number result))))
5698 (defun gnus-summary-search-forward (&optional unread subject backward)
5699 "Search forward for an article.
5700 If UNREAD, look for unread articles. If SUBJECT, look for
5701 articles with that subject. If BACKWARD, search backward instead."
5702 (cond (subject (gnus-summary-find-subject subject unread backward))
5703 (backward (gnus-summary-find-prev unread))
5704 (t (gnus-summary-find-next unread))))
5706 (defun gnus-recenter (&optional n)
5707 "Center point in window and redisplay frame.
5708 Also do horizontal recentering."
5710 (when (and gnus-auto-center-summary
5711 (not (eq gnus-auto-center-summary 'vertical)))
5712 (gnus-horizontal-recenter))
5715 (defun gnus-summary-recenter ()
5716 "Center point in the summary window.
5717 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5718 displayed, no centering will be performed."
5719 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5720 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5722 (let* ((top (cond ((< (window-height) 4) 0)
5723 ((< (window-height) 7) 1)
5724 (t (if (numberp gnus-auto-center-summary)
5725 gnus-auto-center-summary
5727 (height (1- (window-height)))
5728 (bottom (save-excursion (goto-char (point-max))
5729 (forward-line (- height))
5731 (window (get-buffer-window (current-buffer))))
5732 ;; The user has to want it.
5733 (when gnus-auto-center-summary
5734 (when (get-buffer-window gnus-article-buffer)
5735 ;; Only do recentering when the article buffer is displayed,
5736 ;; Set the window start to either `bottom', which is the biggest
5737 ;; possible valid number, or the second line from the top,
5738 ;; whichever is the least.
5739 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5740 (if (> bottom top-pos)
5741 ;; Keep the second line from the top visible
5742 (set-window-start window top-pos t)
5743 ;; Try to keep the bottom line visible; if it's partially
5744 ;; obscured, either scroll one more line to make it fully
5745 ;; visible, or revert to using TOP-POS.
5747 (goto-char (point-max))
5749 (let ((last-line-start (point)))
5751 (set-window-start window (point) t)
5752 (when (not (pos-visible-in-window-p last-line-start window))
5754 (set-window-start window (min (point) top-pos) t)))))))
5755 ;; Do horizontal recentering while we're at it.
5756 (when (and (get-buffer-window (current-buffer) t)
5757 (not (eq gnus-auto-center-summary 'vertical)))
5758 (let ((selected (selected-window)))
5759 (select-window (get-buffer-window (current-buffer) t))
5760 (gnus-summary-position-point)
5761 (gnus-horizontal-recenter)
5762 (select-window selected))))))
5764 (defun gnus-summary-jump-to-group (newsgroup)
5765 "Move point to NEWSGROUP in group mode buffer."
5766 ;; Keep update point of group mode buffer if visible.
5767 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5768 (save-window-excursion
5769 ;; Take care of tree window mode.
5770 (when (get-buffer-window gnus-group-buffer)
5771 (pop-to-buffer gnus-group-buffer))
5772 (gnus-group-jump-to-group newsgroup))
5774 ;; Take care of tree window mode.
5775 (if (get-buffer-window gnus-group-buffer)
5776 (pop-to-buffer gnus-group-buffer)
5777 (set-buffer gnus-group-buffer))
5778 (gnus-group-jump-to-group newsgroup))))
5780 ;; This function returns a list of article numbers based on the
5781 ;; difference between the ranges of read articles in this group and
5782 ;; the range of active articles.
5783 (defun gnus-list-of-unread-articles (group)
5784 (let* ((read (gnus-info-read (gnus-get-info group)))
5785 (active (or (gnus-active group) (gnus-activate-group group)))
5788 ;; If none are read, then all are unread.
5790 (setq first (car active))
5791 ;; If the range of read articles is a single range, then the
5792 ;; first unread article is the article after the last read
5793 ;; article. Sounds logical, doesn't it?
5794 (if (and (not (listp (cdr read)))
5795 (or (< (car read) (car active))
5796 (progn (setq read (list read))
5798 (setq first (max (car active) (1+ (cdr read))))
5799 ;; `read' is a list of ranges.
5800 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5803 (setq first (car active)))
5806 (while (< first nlast)
5808 (setq first (1+ first))))
5809 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5810 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5811 (setq read (cdr read)))))
5812 ;; And add the last unread articles.
5813 (while (<= first last)
5815 (setq first (1+ first)))
5816 ;; Return the list of unread articles.
5817 (delq 0 (nreverse unread))))
5819 (defun gnus-list-of-read-articles (group)
5820 "Return a list of unread, unticked and non-dormant articles."
5821 (let* ((info (gnus-get-info group))
5822 (marked (gnus-info-marks info))
5823 (active (gnus-active group)))
5825 (gnus-set-difference
5826 (gnus-sorted-complement
5827 (gnus-uncompress-range active)
5828 (gnus-list-of-unread-articles group))
5830 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5831 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5833 ;; Various summary commands
5835 (defun gnus-summary-select-article-buffer ()
5836 "Reconfigure windows to show article buffer."
5838 (if (not (gnus-buffer-live-p gnus-article-buffer))
5839 (error "There is no article buffer for this summary buffer")
5840 (gnus-configure-windows 'article)
5841 (select-window (get-buffer-window gnus-article-buffer))))
5843 (defun gnus-summary-universal-argument (arg)
5844 "Perform any operation on all articles that are process/prefixed."
5846 (let ((articles (gnus-summary-work-articles arg))
5853 (substitute-command-keys
5854 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5856 (gnus-error 1 "Undefined key")
5859 (gnus-summary-goto-subject (setq article (pop articles)))
5860 (let (gnus-newsgroup-processable)
5861 (command-execute func))
5862 (gnus-summary-remove-process-mark article)))))
5863 (gnus-summary-position-point))
5865 (defun gnus-summary-toggle-truncation (&optional arg)
5866 "Toggle truncation of summary lines.
5867 With arg, turn line truncation on iff arg is positive."
5869 (setq truncate-lines
5870 (if (null arg) (not truncate-lines)
5871 (> (prefix-numeric-value arg) 0)))
5874 (defun gnus-summary-reselect-current-group (&optional all rescan)
5875 "Exit and then reselect the current newsgroup.
5876 The prefix argument ALL means to select all articles."
5878 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5879 (error "Ephemeral groups can't be reselected"))
5880 (let ((current-subject (gnus-summary-article-number))
5881 (group gnus-newsgroup-name))
5882 (setq gnus-newsgroup-begin nil)
5884 ;; We have to adjust the point of group mode buffer because
5885 ;; point was moved to the next unread newsgroup by exiting.
5886 (gnus-summary-jump-to-group group)
5889 (save-window-excursion
5890 ;; Don't show group contents.
5891 (set-window-start (selected-window) (point-max))
5892 (gnus-group-get-new-news-this-group 1))))
5893 (gnus-group-read-group all t)
5894 (gnus-summary-goto-subject current-subject nil t)))
5896 (defun gnus-summary-rescan-group (&optional all)
5897 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5899 (gnus-summary-reselect-current-group all t))
5901 (defun gnus-summary-update-info (&optional non-destructive)
5903 (let ((group gnus-newsgroup-name))
5905 (when gnus-newsgroup-kill-headers
5906 (setq gnus-newsgroup-killed
5907 (gnus-compress-sequence
5909 (gnus-set-sorted-intersection
5910 (gnus-uncompress-range gnus-newsgroup-killed)
5911 (setq gnus-newsgroup-unselected
5912 (sort gnus-newsgroup-unselected '<)))
5913 (setq gnus-newsgroup-unreads
5914 (sort gnus-newsgroup-unreads '<)))
5916 (unless (listp (cdr gnus-newsgroup-killed))
5917 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5918 (let ((headers gnus-newsgroup-headers))
5919 ;; Set the new ranges of read articles.
5921 (set-buffer gnus-group-buffer)
5922 (gnus-undo-force-boundary))
5923 (gnus-update-read-articles
5924 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5925 ;; Set the current article marks.
5926 (let ((gnus-newsgroup-scored
5927 (if (and (not gnus-save-score)
5928 (not non-destructive))
5930 gnus-newsgroup-scored)))
5932 (gnus-update-marks)))
5933 ;; Do the cross-ref thing.
5934 (when gnus-use-cross-reference
5935 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5936 ;; Do not switch windows but change the buffer to work.
5937 (set-buffer gnus-group-buffer)
5938 (unless (gnus-ephemeral-group-p group)
5939 (gnus-group-update-group group)))))))
5941 (defun gnus-summary-save-newsrc (&optional force)
5942 "Save the current number of read/marked articles in the dribble buffer.
5943 The dribble buffer will then be saved.
5944 If FORCE (the prefix), also save the .newsrc file(s)."
5946 (gnus-summary-update-info t)
5948 (gnus-save-newsrc-file)
5949 (gnus-dribble-save)))
5951 (defun gnus-summary-exit (&optional temporary)
5952 "Exit reading current newsgroup, and then return to group selection mode.
5953 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5955 (gnus-set-global-variables)
5956 (gnus-kill-save-kill-buffer)
5957 (gnus-async-halt-prefetch)
5958 (let* ((group gnus-newsgroup-name)
5959 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5962 (buf (current-buffer)))
5964 ;; Do adaptive scoring, and possibly save score files.
5965 (when gnus-newsgroup-adaptive
5966 (gnus-score-adaptive))
5967 (when gnus-use-scoring
5969 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5970 ;; If we have several article buffers, we kill them at exit.
5971 (unless gnus-single-article-buffer
5972 (gnus-kill-buffer gnus-original-article-buffer)
5973 (setq gnus-article-current nil))
5974 (when gnus-use-cache
5975 (gnus-cache-possibly-remove-articles)
5976 (gnus-cache-save-buffers))
5977 (gnus-async-prefetch-remove-group group)
5978 (when gnus-suppress-duplicates
5979 (gnus-dup-enter-articles))
5980 (when gnus-use-trees
5981 (gnus-tree-close group))
5982 (when gnus-use-cache
5983 (gnus-cache-write-active))
5984 ;; Remove entries for this group.
5985 (nnmail-purge-split-history (gnus-group-real-name group))
5986 ;; Make all changes in this group permanent.
5988 (gnus-run-hooks 'gnus-exit-group-hook)
5989 (gnus-summary-update-info))
5990 (gnus-close-group group)
5991 ;; Make sure where we were, and go to next newsgroup.
5992 (set-buffer gnus-group-buffer)
5994 (gnus-group-jump-to-group group))
5995 (gnus-run-hooks 'gnus-summary-exit-hook)
5996 (unless (or quit-config
5997 ;; If this group has disappeared from the summary
5998 ;; buffer, don't skip forwards.
5999 (not (string= group (gnus-group-group-name))))
6000 (gnus-group-next-unread-group 1))
6001 (setq group-point (point))
6004 ;; If we have several article buffers, we kill them at exit.
6005 (unless gnus-single-article-buffer
6006 (gnus-kill-buffer gnus-article-buffer)
6007 (gnus-kill-buffer gnus-original-article-buffer)
6008 (setq gnus-article-current nil))
6010 (if (not gnus-kill-summary-on-exit)
6012 (gnus-deaden-summary)
6014 ;; We set all buffer-local variables to nil. It is unclear why
6015 ;; this is needed, but if we don't, buffer-local variables are
6016 ;; not garbage-collected, it seems. This would the lead to en
6017 ;; ever-growing Emacs.
6018 (gnus-summary-clear-local-variables)
6019 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6020 (gnus-summary-clear-local-variables))
6021 (when (get-buffer gnus-article-buffer)
6022 (bury-buffer gnus-article-buffer))
6023 ;; We clear the global counterparts of the buffer-local
6024 ;; variables as well, just to be on the safe side.
6025 (set-buffer gnus-group-buffer)
6026 (gnus-summary-clear-local-variables)
6027 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6028 (gnus-summary-clear-local-variables)))
6029 (setq gnus-current-select-method gnus-select-method)
6030 (pop-to-buffer gnus-group-buffer)
6031 (if (not quit-config)
6033 (goto-char group-point)
6034 (gnus-configure-windows 'group 'force)
6035 (unless (pos-visible-in-window-p)
6036 (forward-line (/ (static-if (featurep 'xemacs)
6037 (window-displayed-height)
6038 (1- (window-height)))
6040 (set-window-start (selected-window) (point))
6041 (goto-char group-point)))
6042 (gnus-handle-ephemeral-exit quit-config))
6043 ;; Return to group mode buffer.
6044 (when (eq mode 'gnus-summary-mode)
6045 (gnus-kill-buffer buf))
6046 ;; Clear the current group name.
6048 (setq gnus-newsgroup-name nil)))))
6050 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6051 (defun gnus-summary-exit-no-update (&optional no-questions)
6052 "Quit reading current newsgroup without updating read article info."
6054 (let* ((group gnus-newsgroup-name)
6055 (quit-config (gnus-group-quit-config group)))
6056 (when (or no-questions
6058 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6059 (gnus-async-halt-prefetch)
6061 (delq 'gnus-summary-expire-articles
6062 (copy-sequence gnus-summary-prepare-exit-hook)))
6063 ;; If we have several article buffers, we kill them at exit.
6064 (unless gnus-single-article-buffer
6065 (gnus-kill-buffer gnus-article-buffer)
6066 (gnus-kill-buffer gnus-original-article-buffer)
6067 (setq gnus-article-current nil))
6068 (if (not gnus-kill-summary-on-exit)
6069 (gnus-deaden-summary)
6070 (gnus-close-group group)
6071 (gnus-summary-clear-local-variables)
6072 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6073 (gnus-summary-clear-local-variables))
6074 (set-buffer gnus-group-buffer)
6075 (gnus-summary-clear-local-variables)
6076 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6077 (gnus-summary-clear-local-variables))
6078 (when (get-buffer gnus-summary-buffer)
6079 (kill-buffer gnus-summary-buffer)))
6080 (unless gnus-single-article-buffer
6081 (setq gnus-article-current nil))
6082 (when gnus-use-trees
6083 (gnus-tree-close group))
6084 (gnus-async-prefetch-remove-group group)
6085 (when (get-buffer gnus-article-buffer)
6086 (bury-buffer gnus-article-buffer))
6087 ;; Return to the group buffer.
6088 (gnus-configure-windows 'group 'force)
6089 ;; Clear the current group name.
6090 (setq gnus-newsgroup-name nil)
6091 (when (equal (gnus-group-group-name) group)
6092 (gnus-group-next-unread-group 1))
6094 (gnus-handle-ephemeral-exit quit-config)))))
6096 (defun gnus-handle-ephemeral-exit (quit-config)
6097 "Handle movement when leaving an ephemeral group.
6098 The state which existed when entering the ephemeral is reset."
6099 (if (not (buffer-name (car quit-config)))
6100 (gnus-configure-windows 'group 'force)
6101 (set-buffer (car quit-config))
6102 (cond ((eq major-mode 'gnus-summary-mode)
6103 (gnus-set-global-variables))
6104 ((eq major-mode 'gnus-article-mode)
6106 ;; The `gnus-summary-buffer' variable may point
6107 ;; to the old summary buffer when using a single
6109 (unless (gnus-buffer-live-p gnus-summary-buffer)
6110 (set-buffer gnus-group-buffer))
6111 (set-buffer gnus-summary-buffer)
6112 (gnus-set-global-variables))))
6113 (if (or (eq (cdr quit-config) 'article)
6114 (eq (cdr quit-config) 'pick))
6116 ;; The current article may be from the ephemeral group
6117 ;; thus it is best that we reload this article
6118 (gnus-summary-show-article)
6119 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6120 (gnus-configure-windows 'pick 'force)
6121 (gnus-configure-windows (cdr quit-config) 'force)))
6122 (gnus-configure-windows (cdr quit-config) 'force))
6123 (when (eq major-mode 'gnus-summary-mode)
6124 (gnus-summary-next-subject 1 nil t)
6125 (gnus-summary-recenter)
6126 (gnus-summary-position-point))))
6128 (defun gnus-summary-preview-mime-message ()
6129 "MIME decode and play this message."
6131 (let ((gnus-break-pages nil)
6133 (gnus-summary-select-article gnus-show-all-headers t))
6134 (select-window (get-buffer-window gnus-article-buffer)))
6138 (defvar gnus-dead-summary-mode-map nil)
6140 (unless gnus-dead-summary-mode-map
6141 (setq gnus-dead-summary-mode-map (make-keymap))
6142 (suppress-keymap gnus-dead-summary-mode-map)
6143 (substitute-key-definition
6144 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6145 (let ((keys '("\C-d" "\r" "\177" [delete])))
6147 (define-key gnus-dead-summary-mode-map
6148 (pop keys) 'gnus-summary-wake-up-the-dead))))
6150 (defvar gnus-dead-summary-mode nil
6151 "Minor mode for Gnus summary buffers.")
6153 (defun gnus-dead-summary-mode (&optional arg)
6154 "Minor mode for Gnus summary buffers."
6156 (when (eq major-mode 'gnus-summary-mode)
6157 (make-local-variable 'gnus-dead-summary-mode)
6158 (setq gnus-dead-summary-mode
6159 (if (null arg) (not gnus-dead-summary-mode)
6160 (> (prefix-numeric-value arg) 0)))
6161 (when gnus-dead-summary-mode
6162 (gnus-add-minor-mode
6163 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6165 (defun gnus-deaden-summary ()
6166 "Make the current summary buffer into a dead summary buffer."
6167 ;; Kill any previous dead summary buffer.
6168 (when (and gnus-dead-summary
6169 (buffer-name gnus-dead-summary))
6171 (set-buffer gnus-dead-summary)
6172 (when gnus-dead-summary-mode
6173 (kill-buffer (current-buffer)))))
6174 ;; Make this the current dead summary.
6175 (setq gnus-dead-summary (current-buffer))
6176 (gnus-dead-summary-mode 1)
6177 (let ((name (buffer-name)))
6178 (when (string-match "Summary" name)
6180 (concat (substring name 0 (match-beginning 0)) "Dead "
6181 (substring name (match-beginning 0)))
6185 (defun gnus-kill-or-deaden-summary (buffer)
6186 "Kill or deaden the summary BUFFER."
6188 (when (and (buffer-name buffer)
6189 (not gnus-single-article-buffer))
6192 (gnus-kill-buffer gnus-article-buffer)
6193 (gnus-kill-buffer gnus-original-article-buffer)))
6194 (cond (gnus-kill-summary-on-exit
6195 (when (and gnus-use-trees
6196 (gnus-buffer-exists-p buffer))
6199 (gnus-tree-close gnus-newsgroup-name)))
6200 (gnus-kill-buffer buffer))
6201 ((gnus-buffer-exists-p buffer)
6204 (gnus-deaden-summary))))))
6206 (defun gnus-summary-wake-up-the-dead (&rest args)
6207 "Wake up the dead summary buffer."
6209 (gnus-dead-summary-mode -1)
6210 (let ((name (buffer-name)))
6211 (when (string-match "Dead " name)
6213 (concat (substring name 0 (match-beginning 0))
6214 (substring name (match-end 0)))
6216 (gnus-message 3 "This dead summary is now alive again"))
6218 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6219 (defun gnus-summary-fetch-faq (&optional faq-dir)
6220 "Fetch the FAQ for the current group.
6221 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6225 (when current-prefix-arg
6227 "Faq dir: " (and (listp gnus-group-faq-directory)
6228 (mapcar (lambda (file) (list file))
6229 gnus-group-faq-directory))))))
6230 (let (gnus-faq-buffer)
6231 (when (setq gnus-faq-buffer
6232 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6233 (gnus-configure-windows 'summary-faq))))
6235 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6236 (defun gnus-summary-describe-group (&optional force)
6237 "Describe the current newsgroup."
6239 (gnus-group-describe-group force gnus-newsgroup-name))
6241 (defun gnus-summary-describe-briefly ()
6242 "Describe summary mode commands briefly."
6244 (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")))
6246 ;; Walking around group mode buffer from summary mode.
6248 (defun gnus-summary-next-group (&optional no-article target-group backward)
6249 "Exit current newsgroup and then select next unread newsgroup.
6250 If prefix argument NO-ARTICLE is non-nil, no article is selected
6251 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6252 previous group instead."
6254 ;; Stop pre-fetching.
6255 (gnus-async-halt-prefetch)
6256 (let ((current-group gnus-newsgroup-name)
6257 (current-buffer (current-buffer))
6259 ;; First we semi-exit this group to update Xrefs and all variables.
6260 ;; We can't do a real exit, because the window conf must remain
6261 ;; the same in case the user is prompted for info, and we don't
6262 ;; want the window conf to change before that...
6263 (gnus-summary-exit t)
6264 (while (not entered)
6265 ;; Then we find what group we are supposed to enter.
6266 (set-buffer gnus-group-buffer)
6267 (gnus-group-jump-to-group current-group)
6270 (if (eq gnus-keep-same-level 'best)
6271 (gnus-summary-best-group gnus-newsgroup-name)
6272 (gnus-summary-search-group backward gnus-keep-same-level))))
6273 (if (not target-group)
6274 ;; There are no further groups, so we return to the group
6277 (gnus-message 5 "Returning to the group buffer")
6279 (when (gnus-buffer-live-p current-buffer)
6280 (set-buffer current-buffer)
6281 (gnus-summary-exit))
6282 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6283 ;; We try to enter the target group.
6284 (gnus-group-jump-to-group target-group)
6285 (let ((unreads (gnus-group-group-unread)))
6286 (if (and (or (eq t unreads)
6287 (and unreads (not (zerop unreads))))
6288 (gnus-summary-read-group
6289 target-group nil no-article
6290 (and (buffer-name current-buffer) current-buffer)
6293 (setq current-group target-group
6294 target-group nil)))))))
6296 (defun gnus-summary-prev-group (&optional no-article)
6297 "Exit current newsgroup and then select previous unread newsgroup.
6298 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6300 (gnus-summary-next-group no-article nil t))
6302 ;; Walking around summary lines.
6304 (defun gnus-summary-first-subject (&optional unread undownloaded)
6305 "Go to the first unread subject.
6306 If UNREAD is non-nil, go to the first unread article.
6307 Returns the article selected or nil if there are no unread articles."
6312 ((null gnus-newsgroup-data)
6313 (gnus-message 3 "No articles in the group")
6315 ;; Pick the first article.
6317 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6318 (gnus-data-number (car gnus-newsgroup-data)))
6319 ;; No unread articles.
6320 ((null gnus-newsgroup-unreads)
6321 (gnus-message 3 "No more unread articles")
6323 ;; Find the first unread article.
6325 (let ((data gnus-newsgroup-data))
6327 (and (not (and undownloaded
6328 (eq gnus-undownloaded-mark
6329 (gnus-data-mark (car data)))))
6330 (not (gnus-data-unread-p (car data)))))
6331 (setq data (cdr data)))
6333 (goto-char (gnus-data-pos (car data)))
6334 (gnus-data-number (car data))))))
6335 (gnus-summary-position-point)))
6337 (defun gnus-summary-next-subject (n &optional unread dont-display)
6338 "Go to next N'th summary line.
6339 If N is negative, go to the previous N'th subject line.
6340 If UNREAD is non-nil, only unread articles are selected.
6341 The difference between N and the actual number of steps taken is
6344 (let ((backward (< n 0))
6348 (gnus-summary-find-prev unread)
6349 (gnus-summary-find-next unread)))
6350 (unless (zerop (setq n (1- n)))
6351 (gnus-summary-show-thread)))
6353 (gnus-message 7 "No more%s articles"
6354 (if unread " unread" "")))
6355 (unless dont-display
6356 (gnus-summary-recenter)
6357 (gnus-summary-position-point))
6360 (defun gnus-summary-next-unread-subject (n)
6361 "Go to next N'th unread summary line."
6363 (gnus-summary-next-subject n t))
6365 (defun gnus-summary-prev-subject (n &optional unread)
6366 "Go to previous N'th summary line.
6367 If optional argument UNREAD is non-nil, only unread article is selected."
6369 (gnus-summary-next-subject (- n) unread))
6371 (defun gnus-summary-prev-unread-subject (n)
6372 "Go to previous N'th unread summary line."
6374 (gnus-summary-next-subject (- n) t))
6376 (defun gnus-summary-goto-subject (article &optional force silent)
6377 "Go the subject line of ARTICLE.
6378 If FORCE, also allow jumping to articles not currently shown."
6379 (interactive "nArticle number: ")
6381 (data (gnus-data-find article)))
6382 ;; We read in the article if we have to.
6385 (gnus-summary-insert-subject
6387 (if (or (numberp force) (vectorp force)) force)
6389 (setq data (gnus-data-find article)))
6394 (gnus-message 3 "Can't find article %d" article))
6396 (let ((pt (gnus-data-pos data)))
6398 (gnus-summary-set-article-display-arrow pt))
6399 (gnus-summary-position-point)
6402 ;; Walking around summary lines with displaying articles.
6404 (defun gnus-summary-expand-window (&optional arg)
6405 "Make the summary buffer take up the entire Emacs frame.
6406 Given a prefix, will force an `article' buffer configuration."
6409 (gnus-configure-windows 'article 'force)
6410 (gnus-configure-windows 'summary 'force)))
6412 (defun gnus-summary-display-article (article &optional all-header)
6413 "Display ARTICLE in article buffer."
6414 (when (gnus-buffer-live-p gnus-article-buffer)
6415 (with-current-buffer gnus-article-buffer
6416 (set-buffer-multibyte t)))
6417 (gnus-set-global-variables)
6418 (when (gnus-buffer-live-p gnus-article-buffer)
6419 (with-current-buffer gnus-article-buffer
6420 (setq gnus-article-charset gnus-newsgroup-charset)
6421 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6425 (if gnus-summary-display-article-function
6426 (funcall gnus-summary-display-article-function article all-header)
6427 (gnus-article-prepare article all-header))
6428 (with-current-buffer gnus-article-buffer
6429 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6431 (gnus-run-hooks 'gnus-select-article-hook)
6432 (when (and gnus-current-article
6433 (not (zerop gnus-current-article)))
6434 (gnus-summary-goto-subject gnus-current-article))
6435 (gnus-summary-recenter)
6436 (when (and gnus-use-trees gnus-show-threads)
6437 (gnus-possibly-generate-tree article)
6438 (gnus-highlight-selected-tree article))
6439 ;; Successfully display article.
6440 (gnus-article-set-window-start
6441 (cdr (assq article gnus-newsgroup-bookmarks))))))
6443 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6444 "Select the current article.
6445 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6446 non-nil, the article will be re-fetched even if it already present in
6447 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6449 ;; Make sure we are in the summary buffer to work around bbdb bug.
6450 (unless (eq major-mode 'gnus-summary-mode)
6451 (set-buffer gnus-summary-buffer))
6452 (let ((article (or article (gnus-summary-article-number)))
6453 (all-headers (not (not all-headers))) ;Must be T or NIL.
6454 gnus-summary-display-article-function)
6456 (gnus-summary-article-pseudo-p article)
6457 (error "This is a pseudo-article"))
6459 (set-buffer gnus-summary-buffer)
6460 (if (or (and gnus-single-article-buffer
6461 (or (null gnus-current-article)
6462 (null gnus-article-current)
6463 (null (get-buffer gnus-article-buffer))
6464 (not (eq article (cdr gnus-article-current)))
6465 (not (equal (car gnus-article-current)
6466 gnus-newsgroup-name))))
6467 (and (not gnus-single-article-buffer)
6468 (or (null gnus-current-article)
6469 (not (eq gnus-current-article article))))
6471 ;; The requested article is different from the current article.
6473 (gnus-summary-display-article article all-headers)
6474 (when (or all-headers gnus-show-all-headers)
6475 (gnus-article-show-all-headers))
6476 (gnus-article-set-window-start
6477 (cdr (assq article gnus-newsgroup-bookmarks)))
6479 (when (or all-headers gnus-show-all-headers)
6480 (gnus-article-show-all-headers))
6483 (defun gnus-summary-force-verify-and-decrypt ()
6485 (let ((mm-verify-option 'known)
6486 (mm-decrypt-option 'known))
6487 (gnus-summary-select-article nil 'force)))
6489 (defun gnus-summary-set-current-mark (&optional current-mark)
6490 "Obsolete function."
6493 (defun gnus-summary-next-article (&optional unread subject backward push)
6494 "Select the next article.
6495 If UNREAD, only unread articles are selected.
6496 If SUBJECT, only articles with SUBJECT are selected.
6497 If BACKWARD, the previous article is selected instead of the next."
6500 ;; Is there such an article?
6501 ((and (gnus-summary-search-forward unread subject backward)
6502 (or (gnus-summary-display-article (gnus-summary-article-number))
6503 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6504 (gnus-summary-position-point))
6505 ;; If not, we try the first unread, if that is wanted.
6507 gnus-auto-select-same
6508 (gnus-summary-first-unread-article))
6509 (gnus-summary-position-point)
6510 (gnus-message 6 "Wrapped"))
6511 ;; Try to get next/previous article not displayed in this group.
6512 ((and gnus-auto-extend-newsgroup
6513 (not unread) (not subject))
6514 (gnus-summary-goto-article
6515 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6516 nil (count-lines (point-min) (point))))
6517 ;; Go to next/previous group.
6519 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6520 (gnus-summary-jump-to-group gnus-newsgroup-name))
6521 (let ((cmd last-command-char)
6524 (set-buffer gnus-group-buffer)
6527 (if (eq gnus-keep-same-level 'best)
6528 (gnus-summary-best-group gnus-newsgroup-name)
6529 (gnus-summary-search-group backward gnus-keep-same-level))))
6530 ;; For some reason, the group window gets selected. We change
6532 (select-window (get-buffer-window (current-buffer)))
6533 ;; Select next unread newsgroup automagically.
6535 ((or (not gnus-auto-select-next)
6537 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6538 ((or (eq gnus-auto-select-next 'quietly)
6539 (and (eq gnus-auto-select-next 'slightly-quietly)
6541 (and (eq gnus-auto-select-next 'almost-quietly)
6542 (gnus-summary-last-article-p)))
6544 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6546 (gnus-message 7 "No more%s articles (%s)..."
6547 (if unread " unread" "")
6548 (if group (concat "selecting " group)
6550 (gnus-summary-next-group nil group backward)))
6552 (when (gnus-key-press-event-p last-input-event)
6553 (gnus-summary-walk-group-buffer
6554 gnus-newsgroup-name cmd unread backward point))))))))
6556 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6557 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6558 (?\C-p (gnus-group-prev-unread-group 1))))
6559 (cursor-in-echo-area t)
6560 keve key group ended)
6562 (set-buffer gnus-group-buffer)
6565 (if (eq gnus-keep-same-level 'best)
6566 (gnus-summary-best-group gnus-newsgroup-name)
6567 (gnus-summary-search-group backward gnus-keep-same-level))))
6570 5 "No more%s articles%s" (if unread " unread" "")
6572 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6573 (format " (Type %s for %s [%s])"
6574 (single-key-description cmd) group
6575 (car (gnus-gethash group gnus-newsrc-hashtb)))
6576 (format " (Type %s to exit %s)"
6577 (single-key-description cmd)
6578 gnus-newsgroup-name)))
6579 ;; Confirm auto selection.
6580 (setq key (car (setq keve (gnus-read-event-char))))
6583 ((assq key keystrokes)
6584 (let ((obuf (current-buffer)))
6585 (switch-to-buffer gnus-group-buffer)
6587 (gnus-group-jump-to-group group))
6588 (eval (cadr (assq key keystrokes)))
6589 (setq group (gnus-group-group-name))
6590 (switch-to-buffer obuf))
6594 (gnus-ephemeral-group-p gnus-newsgroup-name))
6596 (gnus-summary-next-group nil group backward)))
6598 (push (cdr keve) unread-command-events))))))
6600 (defun gnus-summary-next-unread-article ()
6601 "Select unread article after current one."
6603 (gnus-summary-next-article
6604 (or (not (eq gnus-summary-goto-unread 'never))
6605 (gnus-summary-last-article-p (gnus-summary-article-number)))
6606 (and gnus-auto-select-same
6607 (gnus-summary-article-subject))))
6609 (defun gnus-summary-prev-article (&optional unread subject)
6610 "Select the article after the current one.
6611 If UNREAD is non-nil, only unread articles are selected."
6613 (gnus-summary-next-article unread subject t))
6615 (defun gnus-summary-prev-unread-article ()
6616 "Select unread article before current one."
6618 (gnus-summary-prev-article
6619 (or (not (eq gnus-summary-goto-unread 'never))
6620 (gnus-summary-first-article-p (gnus-summary-article-number)))
6621 (and gnus-auto-select-same
6622 (gnus-summary-article-subject))))
6624 (defun gnus-summary-next-page (&optional lines circular)
6625 "Show next page of the selected article.
6626 If at the end of the current article, select the next article.
6627 LINES says how many lines should be scrolled up.
6629 If CIRCULAR is non-nil, go to the start of the article instead of
6630 selecting the next article when reaching the end of the current
6633 (setq gnus-summary-buffer (current-buffer))
6634 (gnus-set-global-variables)
6635 (let ((article (gnus-summary-article-number))
6636 (article-window (get-buffer-window gnus-article-buffer t))
6638 ;; If the buffer is empty, we have no article.
6640 (error "No article to select"))
6641 (gnus-configure-windows 'article)
6642 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6643 (if (and (eq gnus-summary-goto-unread 'never)
6644 (not (gnus-summary-last-article-p article)))
6645 (gnus-summary-next-article)
6646 (gnus-summary-next-unread-article))
6647 (if (or (null gnus-current-article)
6648 (null gnus-article-current)
6649 (/= article (cdr gnus-article-current))
6650 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6651 ;; Selected subject is different from current article's.
6652 (gnus-summary-display-article article)
6653 (when article-window
6654 (gnus-eval-in-buffer-window gnus-article-buffer
6655 (setq endp (gnus-article-next-page lines)))
6658 (gnus-summary-beginning-of-article))
6660 (gnus-message 3 "End of message"))
6662 (if (and (eq gnus-summary-goto-unread 'never)
6663 (not (gnus-summary-last-article-p article)))
6664 (gnus-summary-next-article)
6665 (gnus-summary-next-unread-article))))))))
6666 (gnus-summary-recenter)
6667 (gnus-summary-position-point)))
6669 (defun gnus-summary-prev-page (&optional lines move)
6670 "Show previous page of selected article.
6671 Argument LINES specifies lines to be scrolled down.
6672 If MOVE, move to the previous unread article if point is at
6673 the beginning of the buffer."
6675 (let ((article (gnus-summary-article-number))
6676 (article-window (get-buffer-window gnus-article-buffer t))
6678 (gnus-configure-windows 'article)
6679 (if (or (null gnus-current-article)
6680 (null gnus-article-current)
6681 (/= article (cdr gnus-article-current))
6682 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6683 ;; Selected subject is different from current article's.
6684 (gnus-summary-display-article article)
6685 (gnus-summary-recenter)
6686 (when article-window
6687 (gnus-eval-in-buffer-window gnus-article-buffer
6688 (setq endp (gnus-article-prev-page lines)))
6689 (when (and move endp)
6691 (gnus-message 3 "Beginning of message"))
6693 (if (and (eq gnus-summary-goto-unread 'never)
6694 (not (gnus-summary-first-article-p article)))
6695 (gnus-summary-prev-article)
6696 (gnus-summary-prev-unread-article))))))))
6697 (gnus-summary-position-point))
6699 (defun gnus-summary-prev-page-or-article (&optional lines)
6700 "Show previous page of selected article.
6701 Argument LINES specifies lines to be scrolled down.
6702 If at the beginning of the article, go to the next article."
6704 (gnus-summary-prev-page lines t))
6706 (defun gnus-summary-scroll-up (lines)
6707 "Scroll up (or down) one line current article.
6708 Argument LINES specifies lines to be scrolled up (or down if negative)."
6710 (gnus-configure-windows 'article)
6711 (gnus-summary-show-thread)
6712 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6713 (gnus-eval-in-buffer-window gnus-article-buffer
6715 (when (gnus-article-next-page lines)
6716 (gnus-message 3 "End of message")))
6718 (gnus-article-prev-page (- lines))))))
6719 (gnus-summary-recenter)
6720 (gnus-summary-position-point))
6722 (defun gnus-summary-scroll-down (lines)
6723 "Scroll down (or up) one line current article.
6724 Argument LINES specifies lines to be scrolled down (or up if negative)."
6726 (gnus-summary-scroll-up (- lines)))
6728 (defun gnus-summary-next-same-subject ()
6729 "Select next article which has the same subject as current one."
6731 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6733 (defun gnus-summary-prev-same-subject ()
6734 "Select previous article which has the same subject as current one."
6736 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6738 (defun gnus-summary-next-unread-same-subject ()
6739 "Select next unread article which has the same subject as current one."
6741 (gnus-summary-next-article t (gnus-summary-article-subject)))
6743 (defun gnus-summary-prev-unread-same-subject ()
6744 "Select previous unread article which has the same subject as current one."
6746 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6748 (defun gnus-summary-first-unread-article ()
6749 "Select the first unread article.
6750 Return nil if there are no unread articles."
6753 (when (gnus-summary-first-subject t)
6754 (gnus-summary-show-thread)
6755 (gnus-summary-first-subject t)
6756 (gnus-summary-display-article (gnus-summary-article-number)))
6757 (gnus-summary-position-point)))
6759 (defun gnus-summary-first-unread-subject ()
6760 "Place the point on the subject line of the first unread article.
6761 Return nil if there are no unread articles."
6764 (when (gnus-summary-first-subject t)
6765 (gnus-summary-show-thread)
6766 (gnus-summary-first-subject t))
6767 (gnus-summary-position-point)))
6769 (defun gnus-summary-first-article ()
6770 "Select the first article.
6771 Return nil if there are no articles."
6774 (when (gnus-summary-first-subject)
6775 (gnus-summary-show-thread)
6776 (gnus-summary-first-subject)
6777 (gnus-summary-display-article (gnus-summary-article-number)))
6778 (gnus-summary-position-point)))
6780 (defun gnus-summary-best-unread-article ()
6781 "Select the unread article with the highest score."
6783 (let ((best -1000000)
6784 (data gnus-newsgroup-data)
6787 (and (gnus-data-unread-p (car data))
6789 (gnus-summary-article-score (gnus-data-number (car data))))
6792 article (gnus-data-number (car data))))
6793 (setq data (cdr data)))
6796 (gnus-summary-goto-article article)
6797 (error "No unread articles"))
6798 (gnus-summary-position-point))))
6800 (defun gnus-summary-last-subject ()
6801 "Go to the last displayed subject line in the group."
6802 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6804 (gnus-summary-goto-subject article))))
6806 (defun gnus-summary-goto-article (article &optional all-headers force)
6807 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6808 If ALL-HEADERS is non-nil, no header lines are hidden.
6809 If FORCE, go to the article even if it isn't displayed. If FORCE
6810 is a number, it is the line the article is to be displayed on."
6814 "Article number or Message-ID: "
6815 (mapcar (lambda (number) (list (int-to-string number)))
6816 gnus-newsgroup-limit))
6820 (if (and (stringp article)
6821 (string-match "@" article))
6822 (gnus-summary-refer-article article)
6823 (when (stringp article)
6824 (setq article (string-to-number article)))
6825 (if (gnus-summary-goto-subject article force)
6826 (gnus-summary-display-article article all-headers)
6827 (gnus-message 4 "Couldn't go to article %s" article) nil))
6828 (gnus-summary-position-point)))
6830 (defun gnus-summary-goto-last-article ()
6831 "Go to the previously read article."
6834 (when gnus-last-article
6835 (gnus-summary-goto-article gnus-last-article nil t))
6836 (gnus-summary-position-point)))
6838 (defun gnus-summary-pop-article (number)
6839 "Pop one article off the history and go to the previous.
6840 NUMBER articles will be popped off."
6843 (setq gnus-newsgroup-history
6844 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6846 (gnus-summary-goto-article (car to) nil t)
6847 (error "Article history empty")))
6848 (gnus-summary-position-point))
6850 ;; Summary commands and functions for limiting the summary buffer.
6852 (defun gnus-summary-limit-to-articles (n)
6853 "Limit the summary buffer to the next N articles.
6854 If not given a prefix, use the process marked articles instead."
6857 (let ((articles (gnus-summary-work-articles n)))
6858 (setq gnus-newsgroup-processable nil)
6859 (gnus-summary-limit articles))
6860 (gnus-summary-position-point)))
6862 (defun gnus-summary-pop-limit (&optional total)
6863 "Restore the previous limit.
6864 If given a prefix, remove all limits."
6867 (setq gnus-newsgroup-limits
6868 (list (mapcar (lambda (h) (mail-header-number h))
6869 gnus-newsgroup-headers))))
6870 (unless gnus-newsgroup-limits
6871 (error "No limit to pop"))
6873 (gnus-summary-limit nil 'pop)
6874 (gnus-summary-position-point)))
6876 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
6877 "Limit the summary buffer to articles that have subjects that match a regexp.
6878 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
6880 (list (read-string (if current-prefix-arg
6881 "Exclude subject (regexp): "
6882 "Limit to subject (regexp): "))
6883 nil current-prefix-arg))
6885 (setq header "subject"))
6886 (when (not (equal "" subject))
6888 (let ((articles (gnus-summary-find-matching
6889 (or header "subject") subject 'all nil nil
6892 (error "Found no matches for \"%s\"" subject))
6893 (gnus-summary-limit articles))
6894 (gnus-summary-position-point))))
6896 (defun gnus-summary-limit-to-author (from &optional not-matching)
6897 "Limit the summary buffer to articles that have authors that match a regexp.
6898 If NOT-MATCHING, excluding articles that have authors that match a regexp."
6900 (list (read-string (if current-prefix-arg
6901 "Exclude author (regexp): "
6902 "Limit to author (regexp): "))
6903 current-prefix-arg))
6904 (gnus-summary-limit-to-subject from "from" not-matching))
6906 (defun gnus-summary-limit-to-age (age &optional younger-p)
6907 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6908 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6909 articles that are younger than AGE days."
6911 (let ((younger current-prefix-arg)
6914 (while (not days-got)
6915 (setq days (if younger
6916 (read-string "Limit to articles within (in days): ")
6917 (read-string "Limit to articles older than (in days): ")))
6918 (when (> (length days) 0)
6919 (setq days (read days)))
6922 (message "Please enter a number.")
6924 (list days younger)))
6926 (let ((data gnus-newsgroup-data)
6927 (cutoff (days-to-time age))
6928 articles d date is-younger)
6929 (while (setq d (pop data))
6930 (when (and (vectorp (gnus-data-header d))
6931 (setq date (mail-header-date (gnus-data-header d))))
6932 (setq is-younger (time-less-p
6933 (time-since (condition-case ()
6940 (push (gnus-data-number d) articles))))
6941 (gnus-summary-limit (nreverse articles)))
6942 (gnus-summary-position-point)))
6944 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
6945 "Limit the summary buffer to articles that match an 'extra' header."
6949 (gnus-completing-read
6950 (symbol-name (car gnus-extra-headers))
6951 (if current-prefix-arg
6952 "Exclude extra header:"
6953 "Limit extra header:")
6955 (cons (symbol-name x) x))
6960 (read-string (format "%s header %s (regexp): "
6961 (if current-prefix-arg "Exclude" "Limit to")
6963 current-prefix-arg)))
6964 (when (not (equal "" regexp))
6966 (let ((articles (gnus-summary-find-matching
6967 (cons 'extra header) regexp 'all nil nil
6970 (error "Found no matches for \"%s\"" regexp))
6971 (gnus-summary-limit articles))
6972 (gnus-summary-position-point))))
6974 (defun gnus-summary-limit-to-display-predicate ()
6975 "Limit the summary buffer to the predicated in the `display' group parameter."
6977 (unless gnus-newsgroup-display
6978 (error "There is no `display' group parameter"))
6980 (dolist (number gnus-newsgroup-articles)
6981 (when (funcall gnus-newsgroup-display)
6982 (push number articles)))
6983 (gnus-summary-limit articles))
6984 (gnus-summary-position-point))
6986 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6988 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6990 (defun gnus-summary-limit-to-unread (&optional all)
6991 "Limit the summary buffer to articles that are not marked as read.
6992 If ALL is non-nil, limit strictly to unread articles."
6995 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6996 (gnus-summary-limit-to-marks
6997 ;; Concat all the marks that say that an article is read and have
6999 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7000 gnus-killed-mark gnus-kill-file-mark
7001 gnus-low-score-mark gnus-expirable-mark
7002 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7003 gnus-duplicate-mark gnus-souped-mark)
7006 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7007 (make-obsolete 'gnus-summary-delete-marked-with
7008 'gnus-summary-limit-exlude-marks)
7010 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7011 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7012 If REVERSE, limit the summary buffer to articles that are marked
7013 with MARKS. MARKS can either be a string of marks or a list of marks.
7014 Returns how many articles were removed."
7015 (interactive "sMarks: ")
7016 (gnus-summary-limit-to-marks marks t))
7018 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7019 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7020 If REVERSE (the prefix), limit the summary buffer to articles that are
7021 not marked with MARKS. MARKS can either be a string of marks or a
7023 Returns how many articles were removed."
7024 (interactive "sMarks: \nP")
7026 (let ((data gnus-newsgroup-data)
7027 (marks (if (listp marks) marks
7028 (append marks nil))) ; Transform to list.
7031 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7032 (memq (gnus-data-mark (car data)) marks))
7033 (push (gnus-data-number (car data)) articles))
7034 (setq data (cdr data)))
7035 (gnus-summary-limit articles))
7036 (gnus-summary-position-point)))
7038 (defun gnus-summary-limit-to-score (score)
7039 "Limit to articles with score at or above SCORE."
7040 (interactive "NLimit to articles with score of at least: ")
7041 (let ((data gnus-newsgroup-data)
7044 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7046 (push (gnus-data-number (car data)) articles))
7047 (setq data (cdr data)))
7049 (gnus-summary-limit articles)
7050 (gnus-summary-position-point))))
7052 (defun gnus-summary-limit-include-thread (id)
7053 "Display all the hidden articles that is in the thread with ID in it.
7054 When called interactively, ID is the Message-ID of the current
7056 (interactive (list (mail-header-id (gnus-summary-article-header))))
7057 (let ((articles (gnus-articles-in-thread
7058 (gnus-id-to-thread (gnus-root-id id)))))
7060 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7061 (gnus-summary-limit-include-matching-articles
7063 (regexp-quote (gnus-simplify-subject-re
7064 (mail-header-subject (gnus-id-to-header id)))))
7065 (gnus-summary-position-point))))
7067 (defun gnus-summary-limit-include-matching-articles (header regexp)
7068 "Display all the hidden articles that have HEADERs that match REGEXP."
7069 (interactive (list (read-string "Match on header: ")
7070 (read-string "Regexp: ")))
7071 (let ((articles (gnus-find-matching-articles header regexp)))
7073 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7074 (gnus-summary-position-point))))
7076 (defun gnus-summary-limit-include-dormant ()
7077 "Display all the hidden articles that are marked as dormant.
7078 Note that this command only works on a subset of the articles currently
7079 fetched for this group."
7081 (unless gnus-newsgroup-dormant
7082 (error "There are no dormant articles in this group"))
7084 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7085 (gnus-summary-position-point)))
7087 (defun gnus-summary-limit-exclude-dormant ()
7088 "Hide all dormant articles."
7091 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7092 (gnus-summary-position-point)))
7094 (defun gnus-summary-limit-exclude-childless-dormant ()
7095 "Hide all dormant articles that have no children."
7097 (let ((data (gnus-data-list t))
7098 articles d children)
7099 ;; Find all articles that are either not dormant or have
7101 (while (setq d (pop data))
7102 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7104 (gnus-article-children (gnus-data-number d)))
7107 (when (memq (car children) articles)
7112 (push (gnus-data-number d) articles)))
7115 (gnus-summary-limit articles)
7116 (gnus-summary-position-point))))
7118 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7119 "Mark all unread excluded articles as read.
7120 If ALL, mark even excluded ticked and dormants as read."
7122 (let ((articles (gnus-sorted-complement
7124 (mapcar (lambda (h) (mail-header-number h))
7125 gnus-newsgroup-headers)
7127 (sort gnus-newsgroup-limit '<)))
7129 (setq gnus-newsgroup-unreads
7130 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7132 (setq gnus-newsgroup-dormant nil
7133 gnus-newsgroup-marked nil
7134 gnus-newsgroup-reads
7136 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7137 gnus-newsgroup-reads))
7138 (while (setq article (pop articles))
7139 (unless (or (memq article gnus-newsgroup-dormant)
7140 (memq article gnus-newsgroup-marked))
7141 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7143 (defun gnus-summary-limit (articles &optional pop)
7145 ;; We pop the previous limit off the stack and use that.
7146 (setq articles (car gnus-newsgroup-limits)
7147 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7148 ;; We use the new limit, so we push the old limit on the stack.
7149 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7151 (setq gnus-newsgroup-limit articles)
7152 (let ((total (length gnus-newsgroup-data))
7153 (data (gnus-data-find-list (gnus-summary-article-number)))
7154 (gnus-summary-mark-below nil) ; Inhibit this.
7156 ;; This will do all the work of generating the new summary buffer
7157 ;; according to the new limit.
7158 (gnus-summary-prepare)
7159 ;; Hide any threads, possibly.
7160 (and gnus-show-threads
7161 gnus-thread-hide-subtree
7162 (gnus-summary-hide-all-threads))
7163 ;; Try to return to the article you were at, or one in the
7166 ;; We try to find some article after the current one.
7168 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7171 (setq data (cdr data))))
7173 ;; If there is no data, that means that we were after the last
7174 ;; article. The same goes when we can't find any articles
7175 ;; after the current one.
7176 (goto-char (point-max))
7177 (gnus-summary-find-prev))
7178 (gnus-set-mode-line 'summary)
7179 ;; We return how many articles were removed from the summary
7180 ;; buffer as a result of the new limit.
7181 (- total (length gnus-newsgroup-data))))
7183 (defsubst gnus-invisible-cut-children (threads)
7186 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7191 (defsubst gnus-cut-thread (thread)
7192 "Go forwards in the thread until we find an article that we want to display."
7193 (when (or (eq gnus-fetch-old-headers 'some)
7194 (eq gnus-fetch-old-headers 'invisible)
7195 (numberp gnus-fetch-old-headers)
7196 (eq gnus-build-sparse-threads 'some)
7197 (eq gnus-build-sparse-threads 'more))
7198 ;; Deal with old-fetched headers and sparse threads.
7202 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7203 (gnus-summary-article-ancient-p
7204 (mail-header-number (car thread))))
7205 (if (or (<= (length (cdr thread)) 1)
7206 (eq gnus-fetch-old-headers 'invisible))
7207 (setq gnus-newsgroup-limit
7208 (delq (mail-header-number (car thread))
7209 gnus-newsgroup-limit)
7210 thread (cadr thread))
7211 (when (gnus-invisible-cut-children (cdr thread))
7212 (let ((th (cdr thread)))
7214 (if (memq (mail-header-number (caar th))
7215 gnus-newsgroup-limit)
7216 (setq thread (car th)
7218 (setq th (cdr th))))))))))
7221 (defun gnus-cut-threads (threads)
7222 "Cut off all uninteresting articles from the beginning of threads."
7223 (when (or (eq gnus-fetch-old-headers 'some)
7224 (eq gnus-fetch-old-headers 'invisible)
7225 (numberp gnus-fetch-old-headers)
7226 (eq gnus-build-sparse-threads 'some)
7227 (eq gnus-build-sparse-threads 'more))
7230 (setcar th (gnus-cut-thread (car th)))
7231 (setq th (cdr th)))))
7232 ;; Remove nixed out threads.
7235 (defun gnus-summary-initial-limit (&optional show-if-empty)
7236 "Figure out what the initial limit is supposed to be on group entry.
7237 This entails weeding out unwanted dormants, low-scored articles,
7238 fetch-old-headers verbiage, and so on."
7239 ;; Most groups have nothing to remove.
7240 (if (or gnus-inhibit-limiting
7241 (and (null gnus-newsgroup-dormant)
7242 (eq gnus-newsgroup-display 'gnus-not-ignore)
7243 (not (eq gnus-fetch-old-headers 'some))
7244 (not (numberp gnus-fetch-old-headers))
7245 (not (eq gnus-fetch-old-headers 'invisible))
7246 (null gnus-summary-expunge-below)
7247 (not (eq gnus-build-sparse-threads 'some))
7248 (not (eq gnus-build-sparse-threads 'more))
7249 (null gnus-thread-expunge-below)
7250 (not gnus-use-nocem)))
7252 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7253 (setq gnus-newsgroup-limit nil)
7256 (unless (car (symbol-value node))
7257 ;; These threads have no parents -- they are roots.
7258 (let ((nodes (cdr (symbol-value node)))
7261 (if (and gnus-thread-expunge-below
7262 (< (gnus-thread-total-score (car nodes))
7263 gnus-thread-expunge-below))
7264 (gnus-expunge-thread (pop nodes))
7265 (setq thread (pop nodes))
7266 (gnus-summary-limit-children thread))))))
7267 gnus-newsgroup-dependencies)
7268 ;; If this limitation resulted in an empty group, we might
7269 ;; pop the previous limit and use it instead.
7270 (when (and (not gnus-newsgroup-limit)
7272 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7273 gnus-newsgroup-limit))
7275 (defun gnus-summary-limit-children (thread)
7276 "Return 1 if this subthread is visible and 0 if it is not."
7277 ;; First we get the number of visible children to this thread. This
7278 ;; is done by recursing down the thread using this function, so this
7279 ;; will really go down to a leaf article first, before slowly
7280 ;; working its way up towards the root.
7284 (apply '+ (mapcar 'gnus-summary-limit-children
7287 (number (mail-header-number (car thread)))
7290 (not (memq number gnus-newsgroup-marked))
7292 ;; If this article is dormant and has absolutely no visible
7293 ;; children, then this article isn't visible.
7294 (and (memq number gnus-newsgroup-dormant)
7296 ;; If this is "fetch-old-headered" and there is no
7297 ;; visible children, then we don't want this article.
7298 (and (or (eq gnus-fetch-old-headers 'some)
7299 (numberp gnus-fetch-old-headers))
7300 (gnus-summary-article-ancient-p number)
7302 ;; If this is "fetch-old-headered" and `invisible', then
7303 ;; we don't want this article.
7304 (and (eq gnus-fetch-old-headers 'invisible)
7305 (gnus-summary-article-ancient-p number))
7306 ;; If this is a sparsely inserted article with no children,
7307 ;; we don't want it.
7308 (and (eq gnus-build-sparse-threads 'some)
7309 (gnus-summary-article-sparse-p number)
7311 ;; If we use expunging, and this article is really
7312 ;; low-scored, then we don't want this article.
7313 (when (and gnus-summary-expunge-below
7315 (or (cdr (assq number gnus-newsgroup-scored))
7316 gnus-summary-default-score))
7317 gnus-summary-expunge-below))
7318 ;; We increase the expunge-tally here, but that has
7319 ;; nothing to do with the limits, really.
7320 (incf gnus-newsgroup-expunged-tally)
7321 ;; We also mark as read here, if that's wanted.
7322 (when (and gnus-summary-mark-below
7323 (< score gnus-summary-mark-below))
7324 (setq gnus-newsgroup-unreads
7325 (delq number gnus-newsgroup-unreads))
7326 (if gnus-newsgroup-auto-expire
7327 (push number gnus-newsgroup-expirable)
7328 (push (cons number gnus-low-score-mark)
7329 gnus-newsgroup-reads)))
7331 ;; Do the `display' group parameter.
7332 (and gnus-newsgroup-display
7333 (not (funcall gnus-newsgroup-display)))
7334 ;; Check NoCeM things.
7335 (if (and gnus-use-nocem
7336 (gnus-nocem-unwanted-article-p
7337 (mail-header-id (car thread))))
7339 (setq gnus-newsgroup-unreads
7340 (delq number gnus-newsgroup-unreads))
7342 ;; Nope, invisible article.
7344 ;; Ok, this article is to be visible, so we add it to the limit
7346 (push number gnus-newsgroup-limit)
7349 (defun gnus-expunge-thread (thread)
7350 "Mark all articles in THREAD as read."
7351 (let* ((number (mail-header-number (car thread))))
7352 (incf gnus-newsgroup-expunged-tally)
7353 ;; We also mark as read here, if that's wanted.
7354 (setq gnus-newsgroup-unreads
7355 (delq number gnus-newsgroup-unreads))
7356 (if gnus-newsgroup-auto-expire
7357 (push number gnus-newsgroup-expirable)
7358 (push (cons number gnus-low-score-mark)
7359 gnus-newsgroup-reads)))
7360 ;; Go recursively through all subthreads.
7361 (mapcar 'gnus-expunge-thread (cdr thread)))
7363 ;; Summary article oriented commands
7365 (defun gnus-summary-refer-parent-article (n)
7366 "Refer parent article N times.
7367 If N is negative, go to ancestor -N instead.
7368 The difference between N and the number of articles fetched is returned."
7372 (when (not (natnump n))
7377 (setq header (gnus-summary-article-header))
7378 (if (and (eq (mail-header-number header)
7379 (cdr gnus-article-current))
7380 (equal gnus-newsgroup-name
7381 (car gnus-article-current)))
7382 ;; If we try to find the parent of the currently
7383 ;; displayed article, then we take a look at the actual
7384 ;; References header, since this is slightly more
7385 ;; reliable than the References field we got from the
7388 (set-buffer gnus-original-article-buffer)
7389 (nnheader-narrow-to-headers)
7390 (unless (setq ref (message-fetch-field "references"))
7391 (setq ref (message-fetch-field "in-reply-to")))
7394 ;; It's not the current article, so we take a bet on
7395 ;; the value we got from the server.
7396 (mail-header-references header)))
7398 (not (equal ref "")))
7399 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7400 (gnus-message 1 "Couldn't find parent"))
7401 (gnus-message 1 "No references in article %d"
7402 (gnus-summary-article-number))
7405 (gnus-summary-position-point)
7408 (defun gnus-summary-refer-references ()
7409 "Fetch all articles mentioned in the References header.
7410 Return the number of articles fetched."
7412 (let ((ref (mail-header-references (gnus-summary-article-header)))
7413 (current (gnus-summary-article-number))
7417 (error "No References in the current article")
7418 ;; For each Message-ID in the References header...
7419 (while (string-match "<[^>]*>" ref)
7421 ;; ... fetch that article.
7422 (gnus-summary-refer-article
7423 (prog1 (match-string 0 ref)
7424 (setq ref (substring ref (match-end 0))))))
7425 (gnus-summary-goto-subject current)
7426 (gnus-summary-position-point)
7429 (defun gnus-summary-refer-thread (&optional limit)
7430 "Fetch all articles in the current thread.
7431 If LIMIT (the numerical prefix), fetch that many old headers instead
7432 of what's specified by the `gnus-refer-thread-limit' variable."
7434 (let ((id (mail-header-id (gnus-summary-article-header)))
7435 (limit (if limit (prefix-numeric-value limit)
7436 gnus-refer-thread-limit)))
7437 ;; We want to fetch LIMIT *old* headers, but we also have to
7438 ;; re-fetch all the headers in the current buffer, because many of
7439 ;; them may be undisplayed. So we adjust LIMIT.
7440 (when (numberp limit)
7441 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7442 (unless (eq gnus-fetch-old-headers 'invisible)
7443 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7444 ;; Retrieve the headers and read them in.
7445 (if (eq (gnus-retrieve-headers
7446 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7448 (gnus-build-all-threads)
7449 (error "Can't fetch thread from backends that don't support NOV"))
7450 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7451 (gnus-summary-limit-include-thread id)))
7453 (defun gnus-summary-refer-article (message-id)
7454 "Fetch an article specified by MESSAGE-ID."
7455 (interactive "sMessage-ID: ")
7456 (when (and (stringp message-id)
7457 (not (zerop (length message-id))))
7458 ;; Construct the correct Message-ID if necessary.
7459 ;; Suggested by tale@pawl.rpi.edu.
7460 (unless (string-match "^<" message-id)
7461 (setq message-id (concat "<" message-id)))
7462 (unless (string-match ">$" message-id)
7463 (setq message-id (concat message-id ">")))
7464 (let* ((header (gnus-id-to-header message-id))
7466 (gnus-summary-article-sparse-p
7467 (mail-header-number header))
7468 (memq (mail-header-number header)
7469 gnus-newsgroup-limit)))
7472 ;; If the article is present in the buffer we just go to it.
7474 (or (not (gnus-summary-article-sparse-p
7475 (mail-header-number header)))
7478 (gnus-summary-goto-article
7479 (mail-header-number header) nil t)
7481 (gnus-summary-update-article (mail-header-number header)))))
7483 ;; We fetch the article.
7485 (dolist (gnus-override-method (gnus-refer-article-methods))
7486 (gnus-check-server gnus-override-method)
7487 ;; Fetch the header, and display the article.
7488 (when (setq number (gnus-summary-insert-subject message-id))
7489 (gnus-summary-select-article nil nil nil number)
7491 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7493 (defun gnus-refer-article-methods ()
7494 "Return a list of referrable methods."
7496 ;; No method, so we default to current and native.
7497 ((null gnus-refer-article-method)
7498 (list gnus-current-select-method gnus-select-method))
7500 ((eq 'current gnus-refer-article-method)
7501 (list gnus-current-select-method))
7502 ;; List of select methods.
7503 ((not (and (symbolp (car gnus-refer-article-method))
7504 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7506 (dolist (method gnus-refer-article-method)
7507 (push (if (eq 'current method)
7508 gnus-current-select-method
7512 ;; One single select method.
7514 (list gnus-refer-article-method))))
7516 (defun gnus-summary-edit-parameters ()
7517 "Edit the group parameters of the current group."
7519 (gnus-group-edit-group gnus-newsgroup-name 'params))
7521 (defun gnus-summary-customize-parameters ()
7522 "Customize the group parameters of the current group."
7524 (gnus-group-customize gnus-newsgroup-name))
7526 (defun gnus-summary-enter-digest-group (&optional force)
7527 "Enter an nndoc group based on the current article.
7528 If FORCE, force a digest interpretation. If not, try
7529 to guess what the document format is."
7531 (let ((conf gnus-current-window-configuration))
7533 (gnus-summary-select-article))
7534 (setq gnus-current-window-configuration conf)
7535 (let* ((name (format "%s-%d"
7536 (gnus-group-prefixed-name
7537 gnus-newsgroup-name (list 'nndoc ""))
7539 (set-buffer gnus-summary-buffer)
7540 gnus-current-article)))
7541 (ogroup gnus-newsgroup-name)
7542 (params (append (gnus-info-params (gnus-get-info ogroup))
7543 (list (cons 'to-group ogroup))
7544 (list (cons 'save-article-group ogroup))))
7545 (case-fold-search t)
7546 (buf (current-buffer))
7549 (set-buffer gnus-original-article-buffer)
7550 ;; Have the digest group inherit the main mail address of
7551 ;; the parent article.
7552 (when (setq to-address (or (message-fetch-field "reply-to")
7553 (message-fetch-field "from")))
7554 (setq params (append
7555 (list (cons 'to-address
7556 (funcall gnus-decode-encoded-word-function
7558 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7559 (insert-buffer-substring gnus-original-article-buffer)
7560 ;; Remove lines that may lead nndoc to misinterpret the
7563 (goto-char (point-min))
7564 (or (search-forward "\n\n" nil t) (point)))
7565 (goto-char (point-min))
7566 (delete-matching-lines "^Path:\\|^From ")
7569 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7570 (gnus-newsgroup-ephemeral-ignored-charsets
7571 gnus-newsgroup-ignored-charsets))
7572 (gnus-group-read-ephemeral-group
7573 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7575 ,(if force 'mbox 'guess))) t))
7576 ;; Make all postings to this group go to the parent group.
7577 (nconc (gnus-info-params (gnus-get-info name))
7579 ;; Couldn't select this doc group.
7580 (switch-to-buffer buf)
7581 (gnus-set-global-variables)
7582 (gnus-configure-windows 'summary)
7583 (gnus-message 3 "Article couldn't be entered?"))
7584 (kill-buffer dig)))))
7586 (defun gnus-summary-read-document (n)
7587 "Open a new group based on the current article(s).
7588 This will allow you to read digests and other similar
7589 documents as newsgroups.
7590 Obeys the standard process/prefix convention."
7592 (let* ((articles (gnus-summary-work-articles n))
7593 (ogroup gnus-newsgroup-name)
7594 (params (append (gnus-info-params (gnus-get-info ogroup))
7595 (list (cons 'to-group ogroup))))
7596 article group egroup groups vgroup)
7597 (while (setq article (pop articles))
7598 (setq group (format "%s-%d" gnus-newsgroup-name article))
7599 (gnus-summary-remove-process-mark article)
7600 (when (gnus-summary-display-article article)
7603 (insert-buffer-substring gnus-original-article-buffer)
7604 ;; Remove some headers that may lead nndoc to make
7606 (message-narrow-to-head)
7607 (goto-char (point-min))
7608 (delete-matching-lines "^\\(Path\\):\\|^From ")
7611 (gnus-group-read-ephemeral-group
7612 group `(nndoc ,group (nndoc-address ,(current-buffer))
7613 (nndoc-article-type guess))
7616 ;; Make all postings to this group go to the parent group.
7617 (nconc (gnus-info-params (gnus-get-info egroup))
7619 (push egroup groups))
7620 ;; Couldn't select this doc group.
7621 (gnus-error 3 "Article couldn't be entered"))))))
7622 ;; Now we have selected all the documents.
7625 (error "None of the articles could be interpreted as documents"))
7626 ((gnus-group-read-ephemeral-group
7627 (setq vgroup (format
7628 "nnvirtual:%s-%s" gnus-newsgroup-name
7629 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7630 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7632 (cons (current-buffer) 'summary)))
7634 (error "Couldn't select virtual nndoc group")))))
7636 (defun gnus-summary-isearch-article (&optional regexp-p)
7637 "Do incremental search forward on the current article.
7638 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7640 (let* ((gnus-inhibit-treatment t)
7641 (old (gnus-summary-select-article)))
7642 (gnus-configure-windows 'article)
7643 (gnus-eval-in-buffer-window gnus-article-buffer
7647 (gnus-article-show-all-headers))
7648 (goto-char (point-min))
7649 (isearch-forward regexp-p)))))
7651 (defun gnus-summary-search-article-forward (regexp &optional backward)
7652 "Search for an article containing REGEXP forward.
7653 If BACKWARD, search backward instead."
7656 (format "Search article %s (regexp%s): "
7657 (if current-prefix-arg "backward" "forward")
7658 (if gnus-last-search-regexp
7659 (concat ", default " gnus-last-search-regexp)
7661 current-prefix-arg))
7662 (if (string-equal regexp "")
7663 (setq regexp (or gnus-last-search-regexp ""))
7664 (setq gnus-last-search-regexp regexp)
7665 (setq gnus-article-before-search gnus-current-article))
7666 ;; Intentionally set gnus-last-article.
7667 (setq gnus-last-article gnus-article-before-search)
7668 (let ((gnus-last-article gnus-last-article))
7669 (if (gnus-summary-search-article regexp backward)
7670 (gnus-summary-show-thread)
7671 (error "Search failed: \"%s\"" regexp))))
7673 (defun gnus-summary-search-article-backward (regexp)
7674 "Search for an article containing REGEXP backward."
7677 (format "Search article backward (regexp%s): "
7678 (if gnus-last-search-regexp
7679 (concat ", default " gnus-last-search-regexp)
7681 (gnus-summary-search-article-forward regexp 'backward))
7684 (defmacro gnus-summary-search-article-position-point (regexp backward)
7685 "Dehighlight the last matched text and goto the beginning position."
7686 (` (if (and gnus-summary-search-article-matched-data
7687 (let ((text (caddr gnus-summary-search-article-matched-data))
7688 (inhibit-read-only t)
7691 (goto-char (car gnus-summary-search-article-matched-data))
7692 (cadr gnus-summary-search-article-matched-data))
7694 (string-match (, regexp) text)))
7695 (if (, backward) (beginning-of-line) (end-of-line))
7696 (goto-char (if (, backward) (point-max) (point-min))))))
7698 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7699 "Place point where X-Face image is displayed."
7700 (if (featurep 'xemacs)
7701 (` (let ((end (if (search-forward "\n\n" nil t)
7702 (goto-char (1- (point)))
7705 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7706 (unless (and (re-search-forward "^From:" end t)
7707 (setq extent (extent-at (point)))
7708 (extent-begin-glyph extent))
7709 (goto-char (, opoint)))))
7710 (` (let ((end (if (search-forward "\n\n" nil t)
7711 (goto-char (1- (point)))
7713 (start (or (search-backward "\n\n" nil t) (point-min))))
7715 (or (text-property-any start end 'x-face-image t);; x-face-e21
7716 (text-property-any start end 'x-face-mule-bitmap-image t)
7719 (defmacro gnus-summary-search-article-highlight-matched-text
7720 (backward treated x-face)
7721 "Highlight matched text in the function `gnus-summary-search-article'."
7722 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7723 (end (set-marker (make-marker) (match-end 0)))
7724 (inhibit-read-only t)
7728 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7730 (lambda (item) (setq items (delq item items)))
7731 '(gnus-treat-buttonize
7732 gnus-treat-fill-article
7733 gnus-treat-fill-long-lines
7734 gnus-treat-emphasize
7735 gnus-treat-highlight-headers
7736 gnus-treat-highlight-citation
7737 gnus-treat-highlight-signature
7738 gnus-treat-overstrike
7739 gnus-treat-display-xface
7740 gnus-treat-buttonize-head
7741 gnus-treat-decode-article-as-default-mime-charset))
7742 (static-if (featurep 'xemacs)
7744 (cons '(x-face-mule-delete-x-face-field
7747 (gnus-treat-display-xface
7748 (when (, x-face) gnus-treat-display-xface)))
7749 (gnus-article-prepare-mime-display)))
7750 (goto-char (if (, backward) start end))
7752 (gnus-summary-search-article-highlight-goto-x-face (point)))
7753 (setq gnus-summary-search-article-matched-data
7754 (list start end (buffer-substring start end)))
7755 (unless (eq start end);; matched text has been deleted. :-<
7756 (put-text-property start end 'face
7757 (or (find-face 'isearch)
7758 'secondary-selection))))))
7761 (defun gnus-summary-search-article (regexp &optional backward)
7762 "Search for an article containing REGEXP.
7763 Optional argument BACKWARD means do search for backward.
7764 `gnus-select-article-hook' is not called during the search."
7765 ;; We have to require this here to make sure that the following
7766 ;; dynamic binding isn't shadowed by autoloading.
7767 (require 'gnus-async)
7769 (let ((gnus-select-article-hook nil) ;Disable hook.
7770 (gnus-article-prepare-hook nil)
7771 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7772 (gnus-use-article-prefetch nil)
7773 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7774 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7775 (sum (current-buffer))
7778 (gnus-save-hidden-threads
7779 (static-if (featurep 'xemacs)
7780 (let ((gnus-inhibit-treatment t))
7781 (setq treated (eq 'old (gnus-summary-select-article)))
7783 (not (and (gnus-buffer-live-p gnus-article-buffer)
7784 (window-live-p (get-buffer-window
7785 gnus-article-buffer t)))))
7786 (gnus-summary-select-article nil t)
7787 (setq treated nil)))
7788 (let ((gnus-inhibit-treatment t)
7789 (x-face-mule-delete-x-face-field 'never))
7790 (setq treated (eq 'old (gnus-summary-select-article)))
7793 (and (gnus-buffer-live-p gnus-article-buffer)
7794 (window-live-p (get-buffer-window
7795 gnus-article-buffer t))
7796 (or (not (string-match "^\\^X-Face:" regexp))
7797 (with-current-buffer gnus-article-buffer
7798 gnus-summary-search-article-matched-data)))))
7799 (gnus-summary-select-article nil t)
7800 (setq treated nil))))
7801 (set-buffer gnus-article-buffer)
7805 (gnus-article-show-all-headers)
7806 (gnus-summary-search-article-position-point regexp backward))
7807 (goto-char (if backward (point-max) (point-min))))
7809 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7811 (re-search-backward regexp nil t)
7812 (re-search-forward regexp nil t))
7813 ;; We found the regexp.
7815 (gnus-summary-search-article-highlight-matched-text
7816 backward treated (string-match "^\\^X-Face:" regexp))
7819 (/ (- 2 (window-height
7820 (get-buffer-window gnus-article-buffer t)))
7823 (get-buffer-window (current-buffer))
7826 (setq point (point)))
7827 ;; We didn't find it, so we go to the next article.
7830 (while (eq found 'not)
7831 (if (not (if backward (gnus-summary-find-prev)
7832 (gnus-summary-find-next)))
7833 ;; No more articles.
7835 ;; Select the next article and adjust point.
7836 (unless (gnus-summary-article-sparse-p
7837 (gnus-summary-article-number))
7839 (let ((gnus-inhibit-treatment t))
7840 (gnus-summary-select-article))
7842 (set-buffer gnus-article-buffer)
7844 (goto-char (if backward (point-max) (point-min))))))))
7845 (gnus-message 7 ""))
7846 ;; Return whether we found the regexp.
7847 (when (eq found 'found)
7849 (gnus-summary-show-thread)
7850 (gnus-summary-goto-subject gnus-current-article)
7851 (gnus-summary-position-point)
7854 (defun gnus-find-matching-articles (header regexp)
7855 "Return a list of all articles that match REGEXP on HEADER.
7856 This search includes all articles in the current group that Gnus has
7857 fetched headers for, whether they are displayed or not."
7858 (let ((articles nil)
7859 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7860 (case-fold-search t))
7861 (dolist (header gnus-newsgroup-headers)
7862 (when (string-match regexp (funcall func header))
7863 (push (mail-header-number header) articles)))
7864 (nreverse articles)))
7866 (defun gnus-summary-find-matching (header regexp &optional backward unread
7867 not-case-fold not-matching)
7868 "Return a list of all articles that match REGEXP on HEADER.
7869 The search stars on the current article and goes forwards unless
7870 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7871 If UNREAD is non-nil, only unread articles will
7872 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7873 in the comparisons. If NOT-MATCHING, return a list of all articles that
7874 not match REGEXP on HEADER."
7875 (let ((case-fold-search (not not-case-fold))
7878 (if (eq (car header) 'extra)
7881 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7883 (error "%s is an invalid header" header))
7884 (unless (fboundp (intern (concat "mail-header-" header)))
7885 (error "%s is not a valid header" header))
7886 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7887 (dolist (d (if (eq backward 'all)
7889 (gnus-data-find-list
7890 (gnus-summary-article-number)
7891 (gnus-data-list backward))))
7892 (when (and (or (not unread) ; We want all articles...
7893 (gnus-data-unread-p d)) ; Or just unreads.
7894 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7898 (funcall func (gnus-data-header d))))
7899 (string-match regexp
7900 (funcall func (gnus-data-header d)))))
7901 (push (gnus-data-number d) articles))) ; Success!
7902 (nreverse articles)))
7904 (defun gnus-summary-execute-command (header regexp command &optional backward)
7905 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7906 If HEADER is an empty string (or nil), the match is done on the entire
7907 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7909 (list (let ((completion-ignore-case t))
7912 (mapcar (lambda (header) (list (format "%s" header)))
7914 '("Number" "Subject" "From" "Lines" "Date"
7915 "Message-ID" "Xref" "References" "Body")
7916 gnus-extra-headers))
7917 nil 'require-match))
7918 (read-string "Regexp: ")
7919 (read-key-sequence "Command: ")
7920 current-prefix-arg))
7921 (when (equal header "Body")
7923 ;; Hidden thread subtrees must be searched as well.
7924 (gnus-summary-show-all-threads)
7925 ;; We don't want to change current point nor window configuration.
7927 (save-window-excursion
7928 (gnus-message 6 "Executing %s..." (key-description command))
7929 ;; We'd like to execute COMMAND interactively so as to give arguments.
7930 (gnus-execute header regexp
7931 `(call-interactively ',(key-binding command))
7933 (gnus-message 6 "Executing %s...done" (key-description command)))))
7935 (defun gnus-summary-beginning-of-article ()
7936 "Scroll the article back to the beginning."
7938 (gnus-summary-select-article)
7939 (gnus-configure-windows 'article)
7940 (gnus-eval-in-buffer-window gnus-article-buffer
7942 (goto-char (point-min))
7943 (when gnus-page-broken
7944 (gnus-narrow-to-page))))
7946 (defun gnus-summary-end-of-article ()
7947 "Scroll to the end of the article."
7949 (gnus-summary-select-article)
7950 (gnus-configure-windows 'article)
7951 (gnus-eval-in-buffer-window gnus-article-buffer
7953 (goto-char (point-max))
7955 (when gnus-page-broken
7956 (gnus-narrow-to-page))))
7958 (defun gnus-summary-print-truncate-and-quote (string &optional len)
7959 "Truncate to LEN and quote all \"(\"'s in STRING."
7960 (gnus-replace-in-string (if (and len (> (length string) len))
7961 (substring string 0 len)
7965 (defun gnus-summary-print-article (&optional filename n)
7966 "Generate and print a PostScript image of the N next (mail) articles.
7968 If N is negative, print the N previous articles. If N is nil and articles
7969 have been marked with the process mark, print these instead.
7971 If the optional first argument FILENAME is nil, send the image to the
7972 printer. If FILENAME is a string, save the PostScript image in a file with
7973 that name. If FILENAME is a number, prompt the user for the name of the file
7975 (interactive (list (ps-print-preprint current-prefix-arg)))
7976 (dolist (article (gnus-summary-work-articles n))
7977 (gnus-summary-select-article nil nil 'pseudo article)
7978 (gnus-eval-in-buffer-window gnus-article-buffer
7979 (let ((buffer (generate-new-buffer " *print*")))
7982 (copy-to-buffer buffer (point-min) (point-max))
7984 (gnus-article-delete-invisible-text)
7985 (when (gnus-visual-p 'article-highlight 'highlight)
7986 ;; Copy-to-buffer doesn't copy overlay. So redo
7988 (let ((gnus-article-buffer buffer))
7989 (gnus-article-highlight-citation t)
7990 (gnus-article-highlight-signature)))
7991 (let ((ps-left-header
7994 (gnus-summary-print-truncate-and-quote
7995 (mail-header-subject gnus-current-headers)
7998 (gnus-summary-print-truncate-and-quote
7999 (mail-header-from gnus-current-headers)
8003 "/pagenumberstring load"
8005 (mail-header-date gnus-current-headers) ")"))))
8006 (gnus-run-hooks 'gnus-ps-print-hook)
8009 (ps-spool-buffer-with-faces)
8010 (ps-spool-buffer)))))
8011 (kill-buffer buffer))))
8012 (gnus-summary-remove-process-mark article))
8013 (ps-despool filename))
8015 (defun gnus-summary-show-article (&optional arg)
8016 "Force redisplaying of the current article.
8017 If ARG (the prefix) is a number, show the article with the charset
8018 defined in `gnus-summary-show-article-charset-alist', or the charset
8020 If ARG (the prefix) is non-nil and not a number, show the raw article
8021 without any article massaging functions being run. Normally, the key strokes
8026 (gnus-summary-show-article t)
8027 (let ((gnus-newsgroup-charset
8028 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8029 (mm-read-coding-system
8032 (set-buffer gnus-article-buffer)
8033 (let ((coding-systems
8034 (detect-coding-region (point) (point-max))))
8035 (or (car-safe coding-systems)
8036 coding-systems))))))
8037 (gnus-newsgroup-ignored-charsets 'gnus-all))
8038 (gnus-summary-select-article nil 'force)
8039 (let ((deps gnus-newsgroup-dependencies)
8042 (set-buffer gnus-original-article-buffer)
8044 (message-narrow-to-head)
8045 (setq head (buffer-string))
8046 (goto-char (point-min))
8047 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8048 (goto-char (point-max))
8050 (setq lines (1- (count-lines (point) (point-max))))))
8052 (insert (format "211 %d Article retrieved.\n"
8053 (cdr gnus-article-current)))
8055 (if lines (insert (format "Lines: %d\n" lines)))
8057 (let ((nntp-server-buffer (current-buffer)))
8058 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8059 (gnus-data-set-header
8060 (gnus-data-find (cdr gnus-article-current))
8062 (gnus-summary-update-article-line
8063 (cdr gnus-article-current) header)
8064 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8065 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8067 ;; Select the article the normal way.
8068 (gnus-summary-select-article nil 'force))
8070 ;; We have to require this here to make sure that the following
8071 ;; dynamic binding isn't shadowed by autoloading.
8072 (require 'gnus-async)
8074 ;; Bind the article treatment functions to nil.
8075 (let ((gnus-have-all-headers t)
8076 gnus-article-prepare-hook
8077 gnus-article-decode-hook
8080 (gnus-inhibit-treatment t))
8081 (gnus-summary-select-article nil 'force))))
8082 (gnus-summary-goto-subject gnus-current-article)
8083 (gnus-summary-position-point))
8085 (defun gnus-summary-show-raw-article ()
8086 "Show the raw article without any article massaging functions being run."
8088 (gnus-summary-show-article t))
8090 (defun gnus-summary-verbose-headers (&optional arg)
8091 "Toggle permanent full header display.
8092 If ARG is a positive number, turn header display on.
8093 If ARG is a negative number, turn header display off."
8095 (setq gnus-show-all-headers
8096 (cond ((or (not (numberp arg))
8098 (not gnus-show-all-headers))
8101 (gnus-summary-show-article))
8103 (defun gnus-summary-toggle-header (&optional arg)
8104 "Show the headers if they are hidden, or hide them if they are shown.
8105 If ARG is a positive number, show the entire header.
8106 If ARG is a negative number, hide the unwanted header lines."
8109 (set-buffer gnus-article-buffer)
8111 (let* ((buffer-read-only nil)
8112 (inhibit-point-motion-hooks t)
8118 (article-narrow-to-head)
8119 (gnus-article-hidden-text-p 'headers))))
8120 (goto-char (point-min))
8121 (when (search-forward "\n\n" nil t)
8122 (delete-region (point-min) (1- (point))))
8123 (goto-char (point-min))
8125 (set-buffer gnus-original-article-buffer)
8126 (goto-char (point-min))
8127 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8128 (insert-buffer-substring gnus-original-article-buffer 1 e)
8130 (narrow-to-region (point-min) (point))
8131 (article-decode-encoded-words)
8133 (let ((gnus-treat-hide-headers nil)
8134 (gnus-treat-hide-boring-headers nil))
8135 (setq gnus-article-wash-types
8136 (delq 'headers gnus-article-wash-types))
8137 (gnus-treat-article 'head))
8138 (gnus-treat-article 'head)))
8139 (gnus-set-mode-line 'article)))))
8141 (defun gnus-summary-show-all-headers ()
8142 "Make all header lines visible."
8144 (gnus-summary-toggle-header 1))
8146 (defun gnus-summary-toggle-mime (&optional arg)
8147 "Toggle MIME processing.
8148 If ARG is a positive number, turn MIME processing on."
8150 (setq gnus-show-mime
8152 (not gnus-show-mime)
8153 (> (prefix-numeric-value arg) 0)))
8154 (gnus-summary-select-article t 'force))
8156 (defun gnus-summary-caesar-message (&optional arg)
8157 "Caesar rotate the current article by 13.
8158 The numerical prefix specifies how many places to rotate each letter
8161 (gnus-summary-select-article)
8162 (let ((mail-header-separator ""))
8163 (gnus-eval-in-buffer-window gnus-article-buffer
8166 (let ((start (window-start))
8168 (message-caesar-buffer-body arg)
8169 (set-window-start (get-buffer-window (current-buffer)) start))))))
8171 (defun gnus-summary-stop-page-breaking ()
8172 "Stop page breaking in the current article."
8174 (gnus-summary-select-article)
8175 (gnus-eval-in-buffer-window gnus-article-buffer
8177 (when (gnus-visual-p 'page-marker)
8178 (let ((buffer-read-only nil))
8179 (gnus-remove-text-with-property 'gnus-prev)
8180 (gnus-remove-text-with-property 'gnus-next))
8181 (setq gnus-page-broken nil))))
8183 (defun gnus-summary-move-article (&optional n to-newsgroup
8184 select-method action)
8185 "Move the current article to a different newsgroup.
8186 If N is a positive number, move the N next articles.
8187 If N is a negative number, move the N previous articles.
8188 If N is nil and any articles have been marked with the process mark,
8189 move those articles instead.
8190 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8191 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8192 re-spool using this method.
8194 For this function to work, both the current newsgroup and the
8195 newsgroup that you want to move to have to support the `request-move'
8196 and `request-accept' functions.
8198 ACTION can be either `move' (the default), `crosspost' or `copy'."
8201 (setq action 'move))
8202 ;; Check whether the source group supports the required functions.
8203 (cond ((and (eq action 'move)
8204 (not (gnus-check-backend-function
8205 'request-move-article gnus-newsgroup-name)))
8206 (error "The current group does not support article moving"))
8207 ((and (eq action 'crosspost)
8208 (not (gnus-check-backend-function
8209 'request-replace-article gnus-newsgroup-name)))
8210 (error "The current group does not support article editing")))
8211 (let ((articles (gnus-summary-work-articles n))
8212 (prefix (if (gnus-check-backend-function
8213 'request-move-article gnus-newsgroup-name)
8214 (gnus-group-real-prefix gnus-newsgroup-name)
8216 (names '((move "Move" "Moving")
8217 (copy "Copy" "Copying")
8218 (crosspost "Crosspost" "Crossposting")))
8219 (copy-buf (save-excursion
8220 (nnheader-set-temp-buffer " *copy article*")))
8221 (default-marks gnus-article-mark-lists)
8222 (no-expire-marks (delete '(expirable . expire)
8223 (copy-sequence gnus-article-mark-lists)))
8224 art-group to-method new-xref article to-groups)
8225 (unless (assq action names)
8226 (error "Unknown action %s" action))
8227 ;; Read the newsgroup name.
8228 (when (and (not to-newsgroup)
8229 (not select-method))
8231 (gnus-read-move-group-name
8232 (cadr (assq action names))
8233 (symbol-value (intern (format "gnus-current-%s-group" action)))
8235 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8236 (setq to-method (or select-method
8237 (gnus-server-to-method
8238 (gnus-group-method to-newsgroup))))
8239 ;; Check the method we are to move this article to...
8240 (unless (gnus-check-backend-function
8241 'request-accept-article (car to-method))
8242 (error "%s does not support article copying" (car to-method)))
8243 (unless (gnus-check-server to-method)
8244 (error "Can't open server %s" (car to-method)))
8245 (gnus-message 6 "%s to %s: %s..."
8246 (caddr (assq action names))
8247 (or (car select-method) to-newsgroup) articles)
8249 (setq article (pop articles))
8253 ;; Move the article.
8255 ;; Remove this article from future suppression.
8256 (gnus-dup-unsuppress-article article)
8257 (gnus-request-move-article
8258 article ; Article to move
8259 gnus-newsgroup-name ; From newsgroup
8260 (nth 1 (gnus-find-method-for-group
8261 gnus-newsgroup-name)) ; Server
8262 (list 'gnus-request-accept-article
8263 to-newsgroup (list 'quote select-method)
8264 (not articles) t) ; Accept form
8265 (not articles))) ; Only save nov last time
8266 ;; Copy the article.
8269 (set-buffer copy-buf)
8270 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8271 (gnus-request-accept-article
8272 to-newsgroup select-method (not articles) t))))
8273 ;; Crosspost the article.
8274 ((eq action 'crosspost)
8275 (let ((xref (message-tokenize-header
8276 (mail-header-xref (gnus-summary-article-header article))
8278 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8279 ":" (number-to-string article)))
8281 (setq xref (list (system-name))))
8284 (mapconcat 'identity
8285 (delete "Xref:" (delete new-xref xref))
8289 (set-buffer copy-buf)
8290 ;; First put the article in the destination group.
8291 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8292 (when (consp (setq art-group
8293 (gnus-request-accept-article
8294 to-newsgroup select-method (not articles))))
8295 (setq new-xref (concat new-xref " " (car art-group)
8297 (number-to-string (cdr art-group))))
8298 ;; Now we have the new Xrefs header, so we insert
8299 ;; it and replace the new article.
8300 (nnheader-replace-header "Xref" new-xref)
8301 (gnus-request-replace-article
8302 (cdr art-group) to-newsgroup (current-buffer))
8306 (gnus-message 1 "Couldn't %s article %s: %s"
8307 (cadr (assq action names)) article
8308 (nnheader-get-report (car to-method))))
8309 ((eq art-group 'junk)
8310 (when (eq action 'move)
8311 (gnus-summary-mark-article article gnus-canceled-mark)
8312 (gnus-message 4 "Deleted article %s" article)))
8314 (let* ((pto-group (gnus-group-prefixed-name
8315 (car art-group) to-method))
8317 (gnus-gethash pto-group gnus-newsrc-hashtb))
8318 (info (nth 2 entry))
8319 (to-group (gnus-info-group info))
8321 ;; Update the group that has been moved to.
8323 (memq action '(move copy)))
8324 (unless (member to-group to-groups)
8325 (push to-group to-groups))
8327 (unless (memq article gnus-newsgroup-unreads)
8328 (push 'read to-marks)
8330 info (gnus-add-to-range (gnus-info-read info)
8331 (list (cdr art-group)))))
8333 ;; See whether the article is to be put in the cache.
8334 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8337 (to-article (cdr art-group)))
8339 ;; Enter the article into the cache in the new group,
8340 ;; if that is required.
8341 (when gnus-use-cache
8342 (gnus-cache-possibly-enter-article
8344 (let ((header (copy-sequence
8345 (gnus-summary-article-header article))))
8346 (mail-header-set-number header to-article)
8348 (memq article gnus-newsgroup-marked)
8349 (memq article gnus-newsgroup-dormant)
8350 (memq article gnus-newsgroup-unreads)))
8352 (when gnus-preserve-marks
8353 ;; Copy any marks over to the new group.
8354 (when (and (equal to-group gnus-newsgroup-name)
8355 (not (memq article gnus-newsgroup-unreads)))
8356 ;; Mark this article as read in this group.
8357 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8358 (setcdr (gnus-active to-group) to-article)
8359 (setcdr gnus-newsgroup-active to-article))
8362 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8363 (when (memq article (symbol-value
8364 (intern (format "gnus-newsgroup-%s"
8366 (push (cdar marks) to-marks)
8367 ;; If the other group is the same as this group,
8368 ;; then we have to add the mark to the list.
8369 (when (equal to-group gnus-newsgroup-name)
8370 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8373 (intern (format "gnus-newsgroup-%s"
8375 ;; Copy the marks to other group.
8376 (gnus-add-marked-articles
8377 to-group (cdar marks) (list to-article) info)))
8378 (setq marks (cdr marks)))
8380 (gnus-request-set-mark to-group (list (list (list to-article)
8385 (concat "(gnus-group-set-info '"
8386 (gnus-prin1-to-string (gnus-get-info to-group))
8389 ;; Update the Xref header in this article to point to
8390 ;; the new crossposted article we have just created.
8391 (when (eq action 'crosspost)
8393 (set-buffer copy-buf)
8394 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8395 (nnheader-replace-header "Xref" new-xref)
8396 (gnus-request-replace-article
8397 article gnus-newsgroup-name (current-buffer)))))
8399 ;;;!!!Why is this necessary?
8400 (set-buffer gnus-summary-buffer)
8402 (gnus-summary-goto-subject article)
8403 (when (eq action 'move)
8404 (gnus-summary-mark-article article gnus-canceled-mark))))
8405 (gnus-summary-remove-process-mark article))
8406 ;; Re-activate all groups that have been moved to.
8408 (set-buffer gnus-group-buffer)
8409 (let ((gnus-group-marked to-groups))
8410 (gnus-group-get-new-news-this-group nil t)))
8412 (gnus-kill-buffer copy-buf)
8413 (gnus-summary-position-point)
8414 (gnus-set-mode-line 'summary)))
8416 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8417 "Move the current article to a different newsgroup.
8418 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8419 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8420 re-spool using this method."
8422 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8424 (defun gnus-summary-crosspost-article (&optional n)
8425 "Crosspost the current article to some other group."
8427 (gnus-summary-move-article n nil nil 'crosspost))
8429 (defcustom gnus-summary-respool-default-method nil
8430 "Default method type for respooling an article.
8431 If nil, use to the current newsgroup method."
8433 :group 'gnus-summary-mail)
8435 (defun gnus-summary-respool-article (&optional n method)
8436 "Respool the current article.
8437 The article will be squeezed through the mail spooling process again,
8438 which means that it will be put in some mail newsgroup or other
8439 depending on `nnmail-split-methods'.
8440 If N is a positive number, respool the N next articles.
8441 If N is a negative number, respool the N previous articles.
8442 If N is nil and any articles have been marked with the process mark,
8443 respool those articles instead.
8445 Respooling can be done both from mail groups and \"real\" newsgroups.
8446 In the former case, the articles in question will be moved from the
8447 current group into whatever groups they are destined to. In the
8448 latter case, they will be copied into the relevant groups."
8450 (list current-prefix-arg
8451 (let* ((methods (gnus-methods-using 'respool))
8453 (symbol-name (or gnus-summary-respool-default-method
8454 (car (gnus-find-method-for-group
8455 gnus-newsgroup-name)))))
8457 (gnus-completing-read
8458 methname "What backend do you want to use when respooling?"
8459 methods nil t nil 'gnus-mail-method-history))
8462 ((zerop (length (setq ms (gnus-servers-using-backend
8464 (list (intern method) ""))
8468 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8469 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8472 (error "No method given for respooling"))
8473 (if (assoc (symbol-name
8474 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8475 (gnus-methods-using 'respool))
8476 (gnus-summary-move-article n nil method)
8477 (gnus-summary-copy-article n nil method)))
8479 (defun gnus-summary-import-article (file &optional edit)
8480 "Import an arbitrary file into a mail newsgroup."
8481 (interactive "fImport file: \nP")
8482 (let ((group gnus-newsgroup-name)
8483 (now (current-time))
8484 atts lines group-art)
8485 (unless (gnus-check-backend-function 'request-accept-article group)
8486 (error "%s does not support article importing" group))
8487 (or (file-readable-p file)
8488 (not (file-regular-p file))
8489 (error "Can't read %s" file))
8491 (set-buffer (gnus-get-buffer-create " *import file*"))
8493 (nnheader-insert-file-contents file)
8494 (goto-char (point-min))
8495 (if (nnheader-article-p)
8497 (goto-char (point-min))
8498 (search-forward "\n\n" nil t)
8499 (narrow-to-region (point-min) (1- (point)))
8500 (goto-char (point-min))
8501 (unless (re-search-forward "^date:" nil t)
8502 (goto-char (point-max))
8503 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8504 ;; This doesn't look like an article, so we fudge some headers.
8505 (setq atts (file-attributes file)
8506 lines (count-lines (point-min) (point-max)))
8507 (insert "From: " (read-string "From: ") "\n"
8508 "Subject: " (read-string "Subject: ") "\n"
8509 "Date: " (message-make-date (nth 5 atts)) "\n"
8510 "Message-ID: " (message-make-message-id) "\n"
8511 "Lines: " (int-to-string lines) "\n"
8512 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8513 (setq group-art (gnus-request-accept-article group nil t))
8514 (kill-buffer (current-buffer)))
8515 (setq gnus-newsgroup-active (gnus-activate-group group))
8517 (gnus-summary-goto-article (cdr group-art) nil t)
8519 (gnus-summary-edit-article))))
8521 (defun gnus-summary-create-article ()
8522 "Create an article in a mail newsgroup."
8524 (let ((group gnus-newsgroup-name)
8525 (now (current-time))
8527 (unless (gnus-check-backend-function 'request-accept-article group)
8528 (error "%s does not support article importing" group))
8530 (set-buffer (gnus-get-buffer-create " *import file*"))
8532 (goto-char (point-min))
8533 ;; This doesn't look like an article, so we fudge some headers.
8534 (insert "From: " (read-string "From: ") "\n"
8535 "Subject: " (read-string "Subject: ") "\n"
8536 "Date: " (message-make-date now) "\n"
8537 "Message-ID: " (message-make-message-id) "\n")
8538 (setq group-art (gnus-request-accept-article group nil t))
8539 (kill-buffer (current-buffer)))
8540 (setq gnus-newsgroup-active (gnus-activate-group group))
8542 (gnus-summary-goto-article (cdr group-art) nil t)
8543 (gnus-summary-edit-article)))
8545 (defun gnus-summary-article-posted-p ()
8546 "Say whether the current (mail) article is available from news as well.
8547 This will be the case if the article has both been mailed and posted."
8549 (let ((id (mail-header-references (gnus-summary-article-header)))
8550 (gnus-override-method (car (gnus-refer-article-methods))))
8551 (if (gnus-request-head id "")
8552 (gnus-message 2 "The current message was found on %s"
8553 gnus-override-method)
8554 (gnus-message 2 "The current message couldn't be found on %s"
8555 gnus-override-method)
8558 (defun gnus-summary-expire-articles (&optional now)
8559 "Expire all articles that are marked as expirable in the current group."
8561 (when (gnus-check-backend-function
8562 'request-expire-articles gnus-newsgroup-name)
8563 ;; This backend supports expiry.
8564 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8565 (expirable (if total
8567 ;; We need to update the info for
8568 ;; this group for `gnus-list-of-read-articles'
8569 ;; to give us the right answer.
8570 (gnus-run-hooks 'gnus-exit-group-hook)
8571 (gnus-summary-update-info)
8572 (gnus-list-of-read-articles gnus-newsgroup-name))
8573 (setq gnus-newsgroup-expirable
8574 (sort gnus-newsgroup-expirable '<))))
8575 (expiry-wait (if now 'immediate
8576 (gnus-group-find-parameter
8577 gnus-newsgroup-name 'expiry-wait)))
8578 (nnmail-expiry-target
8579 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8580 nnmail-expiry-target))
8583 ;; There are expirable articles in this group, so we run them
8584 ;; through the expiry process.
8585 (gnus-message 6 "Expiring articles...")
8586 (unless (gnus-check-group gnus-newsgroup-name)
8587 (error "Can't open server for %s" gnus-newsgroup-name))
8588 ;; The list of articles that weren't expired is returned.
8591 (let ((nnmail-expiry-wait-function nil)
8592 (nnmail-expiry-wait expiry-wait))
8593 (setq es (gnus-request-expire-articles
8594 expirable gnus-newsgroup-name)))
8595 (setq es (gnus-request-expire-articles
8596 expirable gnus-newsgroup-name)))
8598 (setq gnus-newsgroup-expirable es))
8599 ;; We go through the old list of expirable, and mark all
8600 ;; really expired articles as nonexistent.
8601 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8602 (let ((gnus-use-cache nil))
8604 (unless (memq (car expirable) es)
8605 (when (gnus-data-find (car expirable))
8606 (gnus-summary-mark-article
8607 (car expirable) gnus-canceled-mark)))
8608 (setq expirable (cdr expirable))))))
8609 (gnus-message 6 "Expiring articles...done")))))
8611 (defun gnus-summary-expire-articles-now ()
8612 "Expunge all expirable articles in the current group.
8613 This means that *all* articles that are marked as expirable will be
8614 deleted forever, right now."
8616 (or gnus-expert-user
8618 "Are you really, really, really sure you want to delete all these messages? ")
8620 (gnus-summary-expire-articles t))
8622 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8623 (defun gnus-summary-delete-article (&optional n)
8624 "Delete the N next (mail) articles.
8625 This command actually deletes articles. This is not a marking
8626 command. The article will disappear forever from your life, never to
8628 If N is negative, delete backwards.
8629 If N is nil and articles have been marked with the process mark,
8630 delete these instead."
8632 (unless (gnus-check-backend-function 'request-expire-articles
8633 gnus-newsgroup-name)
8634 (error "The current newsgroup does not support article deletion"))
8635 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8636 (error "Couldn't open server"))
8637 ;; Compute the list of articles to delete.
8638 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8640 (if (and gnus-novice-user
8641 (not (gnus-yes-or-no-p
8642 (format "Do you really want to delete %s forever? "
8643 (if (> (length articles) 1)
8644 (format "these %s articles" (length articles))
8647 ;; Delete the articles.
8648 (setq not-deleted (gnus-request-expire-articles
8649 articles gnus-newsgroup-name 'force))
8651 (gnus-summary-remove-process-mark (car articles))
8652 ;; The backend might not have been able to delete the article
8654 (unless (memq (car articles) not-deleted)
8655 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8656 (setq articles (cdr articles)))
8658 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8659 (gnus-summary-position-point)
8660 (gnus-set-mode-line 'summary)
8663 (defun gnus-summary-edit-article (&optional force)
8664 "Edit the current article.
8665 This will have permanent effect only in mail groups.
8666 If FORCE is non-nil, allow editing of articles even in read-only
8670 (set-buffer gnus-summary-buffer)
8671 (let ((mail-parse-charset gnus-newsgroup-charset)
8672 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8673 (gnus-set-global-variables)
8674 (when (and (not force)
8675 (gnus-group-read-only-p))
8676 (error "The current newsgroup does not support article editing"))
8677 (gnus-summary-show-article t)
8678 (gnus-article-edit-article
8680 `(lambda (no-highlight)
8681 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8682 (message-options message-options)
8683 (message-options-set-recipient)
8684 (mail-parse-ignored-charsets
8685 ',gnus-newsgroup-ignored-charsets))
8686 (gnus-summary-edit-article-done
8687 ,(or (mail-header-references gnus-current-headers) "")
8688 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8690 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8692 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8694 "Make edits to the current article permanent."
8697 ;; The buffer restriction contains the entire article if it exists.
8698 (when (article-goto-body)
8699 (let ((lines (count-lines (point) (point-max)))
8700 (length (- (point-max) (point)))
8701 (case-fold-search t)
8702 (body (copy-marker (point))))
8703 (goto-char (point-min))
8704 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8705 (delete-region (match-beginning 1) (match-end 1))
8706 (insert (number-to-string length)))
8707 (goto-char (point-min))
8708 (when (re-search-forward
8709 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8710 (delete-region (match-beginning 1) (match-end 1))
8711 (insert (number-to-string length)))
8712 (goto-char (point-min))
8713 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8714 (delete-region (match-beginning 1) (match-end 1))
8715 (insert (number-to-string lines))))))
8716 ;; Replace the article.
8717 (let ((buf (current-buffer)))
8719 (insert-buffer-substring buf)
8721 (if (and (not read-only)
8722 (not (gnus-request-replace-article
8723 (cdr gnus-article-current) (car gnus-article-current)
8724 (current-buffer) t)))
8725 (error "Couldn't replace article")
8726 ;; Update the summary buffer.
8728 (equal (message-tokenize-header references " ")
8729 (message-tokenize-header
8730 (or (message-fetch-field "references") "") " ")))
8731 ;; We only have to update this line.
8734 (message-narrow-to-head)
8735 (let ((head (buffer-string))
8738 (insert (format "211 %d Article retrieved.\n"
8739 (cdr gnus-article-current)))
8742 (let ((nntp-server-buffer (current-buffer)))
8743 (setq header (car (gnus-get-newsgroup-headers
8745 (set-buffer gnus-summary-buffer)
8746 gnus-newsgroup-dependencies)
8749 (set-buffer gnus-summary-buffer)
8750 (gnus-data-set-header
8751 (gnus-data-find (cdr gnus-article-current))
8753 (gnus-summary-update-article-line
8754 (cdr gnus-article-current) header)
8755 (if (gnus-summary-goto-subject
8756 (cdr gnus-article-current) nil t)
8757 (gnus-summary-update-secondary-mark
8758 (cdr gnus-article-current))))))))
8760 (set-buffer (or buffer gnus-summary-buffer))
8761 (gnus-summary-update-article (cdr gnus-article-current))
8762 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8763 (gnus-summary-update-secondary-mark
8764 (cdr gnus-article-current))))
8765 ;; Prettify the article buffer again.
8766 (unless no-highlight
8768 (set-buffer gnus-article-buffer)
8769 ;;;!!! Fix this -- article should be rehighlighted.
8770 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8771 (set-buffer gnus-original-article-buffer)
8772 (gnus-request-article
8773 (cdr gnus-article-current)
8774 (car gnus-article-current) (current-buffer))))
8775 ;; Prettify the summary buffer line.
8776 (when (gnus-visual-p 'summary-highlight 'highlight)
8777 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8779 (defun gnus-summary-edit-wash (key)
8780 "Perform editing command KEY in the article buffer."
8784 (message "%s" (concat (this-command-keys) "- "))
8787 (gnus-summary-edit-article)
8788 (execute-kbd-macro (concat (this-command-keys) key))
8789 (gnus-article-edit-done))
8791 (defun gnus-summary-toggle-smiley (&optional arg)
8792 "Toggle the display of smilies as small graphical icons."
8795 (set-buffer gnus-article-buffer)
8796 (gnus-smiley-display arg)))
8800 (defun gnus-summary-respool-query (&optional silent trace)
8801 "Query where the respool algorithm would put this article."
8803 (let (gnus-mark-article-hook)
8804 (gnus-summary-select-article)
8806 (set-buffer gnus-original-article-buffer)
8808 (message-narrow-to-head)
8809 (let ((groups (nnmail-article-group 'identity trace)))
8812 (message "This message would go to %s"
8813 (mapconcat 'car groups ", "))
8814 (message "This message would go to no groups"))
8817 (defun gnus-summary-respool-trace ()
8818 "Trace where the respool algorithm would put this article.
8819 Display a buffer showing all fancy splitting patterns which matched."
8821 (gnus-summary-respool-query nil t))
8823 ;; Summary marking commands.
8825 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8826 "Mark articles which has the same subject as read, and then select the next.
8827 If UNMARK is positive, remove any kind of mark.
8828 If UNMARK is negative, tick articles."
8831 (setq unmark (prefix-numeric-value unmark)))
8833 (gnus-summary-mark-same-subject
8834 (gnus-summary-article-subject) unmark)))
8835 ;; Select next unread article. If auto-select-same mode, should
8836 ;; select the first unread article.
8837 (gnus-summary-next-article t (and gnus-auto-select-same
8838 (gnus-summary-article-subject)))
8839 (gnus-message 7 "%d article%s marked as %s"
8840 count (if (= count 1) " is" "s are")
8841 (if unmark "unread" "read"))))
8843 (defun gnus-summary-kill-same-subject (&optional unmark)
8844 "Mark articles which has the same subject as read.
8845 If UNMARK is positive, remove any kind of mark.
8846 If UNMARK is negative, tick articles."
8849 (setq unmark (prefix-numeric-value unmark)))
8851 (gnus-summary-mark-same-subject
8852 (gnus-summary-article-subject) unmark)))
8853 ;; If marked as read, go to next unread subject.
8855 ;; Go to next unread subject.
8856 (gnus-summary-next-subject 1 t))
8857 (gnus-message 7 "%d articles are marked as %s"
8858 count (if unmark "unread" "read"))))
8860 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8861 "Mark articles with same SUBJECT as read, and return marked number.
8862 If optional argument UNMARK is positive, remove any kinds of marks.
8863 If optional argument UNMARK is negative, mark articles as unread instead."
8867 ((null unmark) ; Mark as read.
8870 (gnus-summary-mark-article-as-read gnus-killed-mark)
8871 (gnus-summary-show-thread) t)
8872 (gnus-summary-find-subject subject))
8873 (setq count (1+ count))))
8874 ((> unmark 0) ; Tick.
8877 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8878 (gnus-summary-show-thread) t)
8879 (gnus-summary-find-subject subject))
8880 (setq count (1+ count))))
8881 (t ; Mark as unread.
8884 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8885 (gnus-summary-show-thread) t)
8886 (gnus-summary-find-subject subject))
8887 (setq count (1+ count)))))
8888 (gnus-set-mode-line 'summary)
8889 ;; Return the number of marked articles.
8892 (defun gnus-summary-mark-as-processable (n &optional unmark)
8893 "Set the process mark on the next N articles.
8894 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8895 the process mark instead. The difference between N and the actual
8896 number of articles marked is returned."
8898 (if (and (null n) (gnus-region-active-p))
8899 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8900 (setq n (prefix-numeric-value n))
8901 (let ((backward (< n 0))
8906 (gnus-summary-remove-process-mark
8907 (gnus-summary-article-number))
8908 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8909 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8912 (gnus-message 7 "No more articles"))
8913 (gnus-summary-recenter)
8914 (gnus-summary-position-point)
8917 (defun gnus-summary-unmark-as-processable (n)
8918 "Remove the process mark from the next N articles.
8919 If N is negative, unmark backward instead. The difference between N and
8920 the actual number of articles unmarked is returned."
8922 (gnus-summary-mark-as-processable n t))
8924 (defun gnus-summary-unmark-all-processable ()
8925 "Remove the process mark from all articles."
8928 (while gnus-newsgroup-processable
8929 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8930 (gnus-summary-position-point))
8932 (defun gnus-summary-add-mark (article type)
8933 "Mark ARTICLE with a mark of TYPE."
8934 (let ((vtype (car (assq type gnus-article-mark-lists)))
8937 (error "No such mark type: %s" type)
8938 (setq var (intern (format "gnus-newsgroup-%s" type)))
8939 (set var (cons article (symbol-value var)))
8940 (if (memq type '(processable cached replied forwarded recent saved))
8941 (gnus-summary-update-secondary-mark article)
8942 ;;; !!! This is bogus. We should find out what primary
8943 ;;; !!! mark we want to set.
8944 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8946 (defun gnus-summary-mark-as-expirable (n)
8947 "Mark N articles forward as expirable.
8948 If N is negative, mark backward instead. The difference between N and
8949 the actual number of articles marked is returned."
8951 (gnus-summary-mark-forward n gnus-expirable-mark))
8953 (defun gnus-summary-mark-article-as-replied (article)
8954 "Mark ARTICLE as replied to and update the summary line.
8955 ARTICLE can also be a list of articles."
8956 (interactive (list (gnus-summary-article-number)))
8957 (let ((articles (if (listp article) article (list article))))
8958 (dolist (article articles)
8959 (push article gnus-newsgroup-replied)
8960 (let ((buffer-read-only nil))
8961 (when (gnus-summary-goto-subject article nil t)
8962 (gnus-summary-update-secondary-mark article))))))
8964 (defun gnus-summary-mark-article-as-forwarded (article)
8965 "Mark ARTICLE as forwarded and update the summary line.
8966 ARTICLE can also be a list of articles."
8967 (let ((articles (if (listp article) article (list article))))
8968 (dolist (article articles)
8969 (push article gnus-newsgroup-forwarded)
8970 (let ((buffer-read-only nil))
8971 (when (gnus-summary-goto-subject article nil t)
8972 (gnus-summary-update-secondary-mark article))))))
8974 (defun gnus-summary-set-bookmark (article)
8975 "Set a bookmark in current article."
8976 (interactive (list (gnus-summary-article-number)))
8977 (when (or (not (get-buffer gnus-article-buffer))
8978 (not gnus-current-article)
8979 (not gnus-article-current)
8980 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8981 (error "No current article selected"))
8982 ;; Remove old bookmark, if one exists.
8983 (let ((old (assq article gnus-newsgroup-bookmarks)))
8985 (setq gnus-newsgroup-bookmarks
8986 (delq old gnus-newsgroup-bookmarks))))
8987 ;; Set the new bookmark, which is on the form
8988 ;; (article-number . line-number-in-body).
8992 (set-buffer gnus-article-buffer)
8996 (goto-char (point-min))
8997 (search-forward "\n\n" nil t)
9000 gnus-newsgroup-bookmarks)
9001 (gnus-message 6 "A bookmark has been added to the current article."))
9003 (defun gnus-summary-remove-bookmark (article)
9004 "Remove the bookmark from the current article."
9005 (interactive (list (gnus-summary-article-number)))
9006 ;; Remove old bookmark, if one exists.
9007 (let ((old (assq article gnus-newsgroup-bookmarks)))
9010 (setq gnus-newsgroup-bookmarks
9011 (delq old gnus-newsgroup-bookmarks))
9012 (gnus-message 6 "Removed bookmark."))
9013 (gnus-message 6 "No bookmark in current article."))))
9015 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9016 (defun gnus-summary-mark-as-dormant (n)
9017 "Mark N articles forward as dormant.
9018 If N is negative, mark backward instead. The difference between N and
9019 the actual number of articles marked is returned."
9021 (gnus-summary-mark-forward n gnus-dormant-mark))
9023 (defun gnus-summary-set-process-mark (article)
9024 "Set the process mark on ARTICLE and update the summary line."
9025 (setq gnus-newsgroup-processable
9027 (delq article gnus-newsgroup-processable)))
9028 (when (gnus-summary-goto-subject article)
9029 (gnus-summary-show-thread)
9030 (gnus-summary-goto-subject article)
9031 (gnus-summary-update-secondary-mark article)))
9033 (defun gnus-summary-remove-process-mark (article)
9034 "Remove the process mark from ARTICLE and update the summary line."
9035 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9036 (when (gnus-summary-goto-subject article)
9037 (gnus-summary-show-thread)
9038 (gnus-summary-goto-subject article)
9039 (gnus-summary-update-secondary-mark article)))
9041 (defun gnus-summary-set-saved-mark (article)
9042 "Set the process mark on ARTICLE and update the summary line."
9043 (push article gnus-newsgroup-saved)
9044 (when (gnus-summary-goto-subject article)
9045 (gnus-summary-update-secondary-mark article)))
9047 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9048 "Mark N articles as read forwards.
9049 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9050 The difference between N and the actual number of articles marked is
9052 Iff NO-EXPIRE, auto-expiry will be inhibited."
9054 (gnus-summary-show-thread)
9055 (let ((backward (< n 0))
9056 (gnus-summary-goto-unread
9057 (and gnus-summary-goto-unread
9058 (not (eq gnus-summary-goto-unread 'never))
9059 (not (memq mark (list gnus-unread-mark
9060 gnus-ticked-mark gnus-dormant-mark)))))
9062 (mark (or mark gnus-del-mark)))
9064 (gnus-summary-mark-article nil mark no-expire)
9065 (zerop (gnus-summary-next-subject
9067 (and gnus-summary-goto-unread
9068 (not (eq gnus-summary-goto-unread 'never)))
9072 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9073 (gnus-summary-recenter)
9074 (gnus-summary-position-point)
9075 (gnus-set-mode-line 'summary)
9078 (defun gnus-summary-mark-article-as-read (mark)
9079 "Mark the current article quickly as read with MARK."
9080 (let ((article (gnus-summary-article-number)))
9081 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9082 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9083 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9084 (push (cons article mark) gnus-newsgroup-reads)
9085 ;; Possibly remove from cache, if that is used.
9086 (when gnus-use-cache
9087 (gnus-cache-enter-remove-article article))
9088 ;; Allow the backend to change the mark.
9089 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9090 ;; Check for auto-expiry.
9091 (when (and gnus-newsgroup-auto-expire
9092 (memq mark gnus-auto-expirable-marks))
9093 (setq mark gnus-expirable-mark)
9094 ;; Let the backend know about the mark change.
9095 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9096 (push article gnus-newsgroup-expirable))
9097 ;; Set the mark in the buffer.
9098 (gnus-summary-update-mark mark 'unread)
9101 (defun gnus-summary-mark-article-as-unread (mark)
9102 "Mark the current article quickly as unread with MARK."
9103 (let* ((article (gnus-summary-article-number))
9104 (old-mark (gnus-summary-article-mark article)))
9105 ;; Allow the backend to change the mark.
9106 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9107 (if (eq mark old-mark)
9111 (gnus-error 1 "Can't mark negative article numbers")
9113 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9114 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9115 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9116 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9117 (cond ((= mark gnus-ticked-mark)
9118 (push article gnus-newsgroup-marked))
9119 ((= mark gnus-dormant-mark)
9120 (push article gnus-newsgroup-dormant))
9122 (push article gnus-newsgroup-unreads)))
9123 (gnus-pull article gnus-newsgroup-reads)
9125 ;; See whether the article is to be put in the cache.
9127 (vectorp (gnus-summary-article-header article))
9129 (gnus-cache-possibly-enter-article
9130 gnus-newsgroup-name article
9131 (gnus-summary-article-header article)
9132 (= mark gnus-ticked-mark)
9133 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9136 (gnus-summary-update-mark mark 'unread)
9139 (defun gnus-summary-mark-article (&optional article mark no-expire)
9140 "Mark ARTICLE with MARK. MARK can be any character.
9141 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9142 `??' (dormant) and `?E' (expirable).
9143 If MARK is nil, then the default character `?r' is used.
9144 If ARTICLE is nil, then the article on the current line will be
9146 Iff NO-EXPIRE, auto-expiry will be inhibited."
9147 ;; The mark might be a string.
9148 (when (stringp mark)
9149 (setq mark (aref mark 0)))
9150 ;; If no mark is given, then we check auto-expiring.
9152 (setq mark gnus-del-mark))
9153 (when (and (not no-expire)
9154 gnus-newsgroup-auto-expire
9155 (memq mark gnus-auto-expirable-marks))
9156 (setq mark gnus-expirable-mark))
9157 (let ((article (or article (gnus-summary-article-number)))
9158 (old-mark (gnus-summary-article-mark article)))
9159 ;; Allow the backend to change the mark.
9160 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9161 (if (eq mark old-mark)
9164 (error "No article on current line"))
9165 (if (not (if (or (= mark gnus-unread-mark)
9166 (= mark gnus-ticked-mark)
9167 (= mark gnus-dormant-mark))
9168 (gnus-mark-article-as-unread article mark)
9169 (gnus-mark-article-as-read article mark)))
9171 ;; See whether the article is to be put in the cache.
9173 (not (= mark gnus-canceled-mark))
9174 (vectorp (gnus-summary-article-header article))
9176 (gnus-cache-possibly-enter-article
9177 gnus-newsgroup-name article
9178 (gnus-summary-article-header article)
9179 (= mark gnus-ticked-mark)
9180 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9182 (when (gnus-summary-goto-subject article nil t)
9183 (let ((buffer-read-only nil))
9184 (gnus-summary-show-thread)
9186 (gnus-summary-update-mark mark 'unread)
9189 (defun gnus-summary-update-secondary-mark (article)
9190 "Update the secondary (read, process, cache) mark."
9191 (gnus-summary-update-mark
9192 (cond ((memq article gnus-newsgroup-processable)
9194 ((memq article gnus-newsgroup-cached)
9196 ((memq article gnus-newsgroup-replied)
9198 ((memq article gnus-newsgroup-forwarded)
9199 gnus-forwarded-mark)
9200 ((memq article gnus-newsgroup-saved)
9202 ((memq article gnus-newsgroup-recent)
9204 ((memq article gnus-newsgroup-unseen)
9208 (when (gnus-visual-p 'summary-highlight 'highlight)
9209 (gnus-run-hooks 'gnus-summary-update-hook))
9212 (defun gnus-summary-update-mark (mark type)
9213 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9214 (buffer-read-only nil))
9215 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9217 (when (looking-at "\r")
9219 (when (<= (+ forward (point)) (point-max))
9220 ;; Go to the right position on the line.
9221 (goto-char (+ forward (point)))
9222 ;; Replace the old mark with the new mark.
9223 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9224 ;; Optionally update the marks by some user rule.
9225 (when (eq type 'unread)
9227 (gnus-data-find (gnus-summary-article-number)) mark)
9228 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9230 (defun gnus-mark-article-as-read (article &optional mark)
9231 "Enter ARTICLE in the pertinent lists and remove it from others."
9232 ;; Make the article expirable.
9233 (let ((mark (or mark gnus-del-mark)))
9234 (if (= mark gnus-expirable-mark)
9235 (push article gnus-newsgroup-expirable)
9236 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9237 ;; Remove from unread and marked lists.
9238 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9239 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9240 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9241 (push (cons article mark) gnus-newsgroup-reads)
9242 ;; Possibly remove from cache, if that is used.
9243 (when gnus-use-cache
9244 (gnus-cache-enter-remove-article article))
9247 (defun gnus-mark-article-as-unread (article &optional mark)
9248 "Enter ARTICLE in the pertinent lists and remove it from others."
9249 (let ((mark (or mark gnus-ticked-mark)))
9252 (gnus-error 1 "Can't mark negative article numbers")
9254 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9255 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9256 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9257 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9259 ;; Unsuppress duplicates?
9260 (when gnus-suppress-duplicates
9261 (gnus-dup-unsuppress-article article))
9263 (cond ((= mark gnus-ticked-mark)
9264 (push article gnus-newsgroup-marked))
9265 ((= mark gnus-dormant-mark)
9266 (push article gnus-newsgroup-dormant))
9268 (push article gnus-newsgroup-unreads)))
9269 (gnus-pull article gnus-newsgroup-reads)
9272 (defalias 'gnus-summary-mark-as-unread-forward
9273 'gnus-summary-tick-article-forward)
9274 (make-obsolete 'gnus-summary-mark-as-unread-forward
9275 'gnus-summary-tick-article-forward)
9276 (defun gnus-summary-tick-article-forward (n)
9277 "Tick N articles forwards.
9278 If N is negative, tick backwards instead.
9279 The difference between N and the number of articles ticked is returned."
9281 (gnus-summary-mark-forward n gnus-ticked-mark))
9283 (defalias 'gnus-summary-mark-as-unread-backward
9284 'gnus-summary-tick-article-backward)
9285 (make-obsolete 'gnus-summary-mark-as-unread-backward
9286 'gnus-summary-tick-article-backward)
9287 (defun gnus-summary-tick-article-backward (n)
9288 "Tick N articles backwards.
9289 The difference between N and the number of articles ticked is returned."
9291 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9293 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9294 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9295 (defun gnus-summary-tick-article (&optional article clear-mark)
9296 "Mark current article as unread.
9297 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9298 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9300 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9303 (defun gnus-summary-mark-as-read-forward (n)
9304 "Mark N articles as read forwards.
9305 If N is negative, mark backwards instead.
9306 The difference between N and the actual number of articles marked is
9309 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9311 (defun gnus-summary-mark-as-read-backward (n)
9312 "Mark the N articles as read backwards.
9313 The difference between N and the actual number of articles marked is
9316 (gnus-summary-mark-forward
9317 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9319 (defun gnus-summary-mark-as-read (&optional article mark)
9320 "Mark current article as read.
9321 ARTICLE specifies the article to be marked as read.
9322 MARK specifies a string to be inserted at the beginning of the line."
9323 (gnus-summary-mark-article article mark))
9325 (defun gnus-summary-clear-mark-forward (n)
9326 "Clear marks from N articles forward.
9327 If N is negative, clear backward instead.
9328 The difference between N and the number of marks cleared is returned."
9330 (gnus-summary-mark-forward n gnus-unread-mark))
9332 (defun gnus-summary-clear-mark-backward (n)
9333 "Clear marks from N articles backward.
9334 The difference between N and the number of marks cleared is returned."
9336 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9338 (defun gnus-summary-mark-unread-as-read ()
9339 "Intended to be used by `gnus-summary-mark-article-hook'."
9340 (when (memq gnus-current-article gnus-newsgroup-unreads)
9341 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9343 (defun gnus-summary-mark-read-and-unread-as-read ()
9344 "Intended to be used by `gnus-summary-mark-article-hook'."
9345 (let ((mark (gnus-summary-article-mark)))
9346 (when (or (gnus-unread-mark-p mark)
9347 (gnus-read-mark-p mark))
9348 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9350 (defun gnus-summary-mark-unread-as-ticked ()
9351 "Intended to be used by `gnus-summary-mark-article-hook'."
9352 (when (memq gnus-current-article gnus-newsgroup-unreads)
9353 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9355 (defun gnus-summary-mark-region-as-read (point mark all)
9356 "Mark all unread articles between point and mark as read.
9357 If given a prefix, mark all articles between point and mark as read,
9358 even ticked and dormant ones."
9359 (interactive "r\nP")
9368 (memq (setq article (gnus-summary-article-number))
9369 gnus-newsgroup-unreads))
9370 (gnus-summary-mark-article article gnus-del-mark))
9372 (gnus-summary-find-next))))))
9374 (defun gnus-summary-mark-below (score mark)
9375 "Mark articles with score less than SCORE with MARK."
9376 (interactive "P\ncMark: ")
9377 (setq score (if score
9378 (prefix-numeric-value score)
9379 (or gnus-summary-default-score 0)))
9381 (set-buffer gnus-summary-buffer)
9382 (goto-char (point-min))
9385 (and (< (gnus-summary-article-score) score)
9386 (gnus-summary-mark-article nil mark))
9387 (gnus-summary-find-next)))))
9389 (defun gnus-summary-kill-below (&optional score)
9390 "Mark articles with score below SCORE as read."
9392 (gnus-summary-mark-below score gnus-killed-mark))
9394 (defun gnus-summary-clear-above (&optional score)
9395 "Clear all marks from articles with score above SCORE."
9397 (gnus-summary-mark-above score gnus-unread-mark))
9399 (defun gnus-summary-tick-above (&optional score)
9400 "Tick all articles with score above SCORE."
9402 (gnus-summary-mark-above score gnus-ticked-mark))
9404 (defun gnus-summary-mark-above (score mark)
9405 "Mark articles with score over SCORE with MARK."
9406 (interactive "P\ncMark: ")
9407 (setq score (if score
9408 (prefix-numeric-value score)
9409 (or gnus-summary-default-score 0)))
9411 (set-buffer gnus-summary-buffer)
9412 (goto-char (point-min))
9414 (when (> (gnus-summary-article-score) score)
9415 (gnus-summary-mark-article nil mark))
9417 (gnus-summary-find-next)))))
9419 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9420 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9421 (defun gnus-summary-limit-include-expunged (&optional no-error)
9422 "Display all the hidden articles that were expunged for low scores."
9424 (let ((buffer-read-only nil))
9425 (let ((scored gnus-newsgroup-scored)
9428 (unless (gnus-summary-article-header (caar scored))
9429 (and (setq h (gnus-number-to-header (caar scored)))
9430 (< (cdar scored) gnus-summary-expunge-below)
9432 (setq scored (cdr scored)))
9434 (when (not no-error)
9435 (error "No expunged articles hidden"))
9436 (goto-char (point-min))
9437 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9438 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9439 (mapcar (lambda (x) (push (mail-header-number x)
9440 gnus-newsgroup-limit))
9442 (gnus-summary-prepare-unthreaded (nreverse headers))
9443 (goto-char (point-min))
9444 (gnus-summary-position-point)
9447 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9448 "Mark all unread articles in this newsgroup as read.
9449 If prefix argument ALL is non-nil, ticked and dormant articles will
9450 also be marked as read.
9451 If QUIETLY is non-nil, no questions will be asked.
9452 If TO-HERE is non-nil, it should be a point in the buffer. All
9453 articles before (after, if REVERSE is set) this point will be marked as read.
9454 Note that this function will only catch up the unread article
9455 in the current summary buffer limitation.
9456 The number of articles marked as read is returned."
9461 (not gnus-interactive-catchup) ;Without confirmation?
9465 "Mark absolutely all articles as read? "
9466 "Mark all unread articles as read? ")))
9468 (not gnus-newsgroup-adaptive)
9469 (not gnus-newsgroup-auto-expire)
9470 (not gnus-suppress-duplicates)
9471 (or (not gnus-use-cache)
9472 (eq gnus-use-cache 'passive)))
9475 (setq gnus-newsgroup-marked nil
9476 gnus-newsgroup-dormant nil))
9477 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9478 ;; We actually mark all articles as canceled, which we
9479 ;; have to do when using auto-expiry or adaptive scoring.
9480 (gnus-summary-show-all-threads)
9481 (if (and to-here reverse)
9485 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9486 (gnus-summary-find-next (not all) nil nil t))))
9487 (when (gnus-summary-first-subject (not all) t)
9489 (if to-here (< (point) to-here) t)
9490 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9491 (gnus-summary-find-next (not all) nil nil t)))))
9492 (gnus-set-mode-line 'summary))
9494 (gnus-summary-position-point)))
9496 (defun gnus-summary-catchup-to-here (&optional all)
9497 "Mark all unticked articles before the current one as read.
9498 If ALL is non-nil, also mark ticked and dormant articles as read."
9501 (gnus-save-hidden-threads
9502 (let ((beg (point)))
9503 ;; We check that there are unread articles.
9504 (when (or all (gnus-summary-find-prev))
9505 (gnus-summary-catchup all t beg)))))
9506 (gnus-summary-position-point))
9508 (defun gnus-summary-catchup-from-here (&optional all)
9509 "Mark all unticked articles after the current one as read.
9510 If ALL is non-nil, also mark ticked and dormant articles as read."
9513 (gnus-save-hidden-threads
9514 (let ((beg (point)))
9515 ;; We check that there are unread articles.
9516 (when (or all (gnus-summary-find-next))
9517 (gnus-summary-catchup all t beg nil t)))))
9518 (gnus-summary-position-point))
9520 (defun gnus-summary-catchup-all (&optional quietly)
9521 "Mark all articles in this newsgroup as read."
9523 (gnus-summary-catchup t quietly))
9525 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9526 "Mark all unread articles in this group as read, then exit.
9527 If prefix argument ALL is non-nil, all articles are marked as read.
9528 If QUIETLY is non-nil, no questions will be asked."
9530 (when (gnus-summary-catchup all quietly nil 'fast)
9531 ;; Select next newsgroup or exit.
9532 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9533 (eq gnus-auto-select-next 'quietly))
9534 (gnus-summary-next-group nil)
9535 (gnus-summary-exit))))
9537 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9538 "Mark all articles in this newsgroup as read, and then exit."
9540 (gnus-summary-catchup-and-exit t quietly))
9542 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9543 "Mark all articles in this group as read and select the next group.
9544 If given a prefix, mark all articles, unread as well as ticked, as
9548 (gnus-summary-catchup all))
9549 (gnus-summary-next-group))
9555 (defmacro gnus-with-article (article &rest forms)
9556 "Select ARTICLE and perform FORMS in the original article buffer.
9557 Then replace the article with the result."
9559 ;; We don't want the article to be marked as read.
9560 (let (gnus-mark-article-hook)
9561 (gnus-summary-select-article t t nil ,article))
9562 (set-buffer gnus-original-article-buffer)
9564 (if (not (gnus-check-backend-function
9565 'request-replace-article (car gnus-article-current)))
9566 (gnus-message 5 "Read-only group; not replacing")
9567 (unless (gnus-request-replace-article
9568 ,article (car gnus-article-current)
9570 (error "Couldn't replace article")))
9571 ;; The cache and backlog have to be flushed somewhat.
9572 (when gnus-keep-backlog
9573 (gnus-backlog-remove-article
9574 (car gnus-article-current) (cdr gnus-article-current)))
9575 (when gnus-use-cache
9576 (gnus-cache-update-article
9577 (car gnus-article-current) (cdr gnus-article-current)))))
9579 (put 'gnus-with-article 'lisp-indent-function 1)
9580 (put 'gnus-with-article 'edebug-form-spec '(form body))
9582 ;; Thread-based commands.
9584 (defun gnus-summary-articles-in-thread (&optional article)
9585 "Return a list of all articles in the current thread.
9586 If ARTICLE is non-nil, return all articles in the thread that starts
9588 (let* ((article (or article (gnus-summary-article-number)))
9589 (data (gnus-data-find-list article))
9590 (top-level (gnus-data-level (car data)))
9592 (cond ((null gnus-thread-operation-ignore-subject)
9593 (gnus-simplify-subject-re
9594 (mail-header-subject (gnus-data-header (car data)))))
9595 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9596 (gnus-simplify-subject-fuzzy
9597 (mail-header-subject (gnus-data-header (car data)))))
9599 (end-point (save-excursion
9600 (if (gnus-summary-go-to-next-thread)
9601 (point) (point-max))))
9604 (< (gnus-data-pos (car data)) end-point))
9605 (when (or (not top-subject)
9606 (string= top-subject
9607 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9608 (gnus-simplify-subject-fuzzy
9609 (mail-header-subject
9610 (gnus-data-header (car data))))
9611 (gnus-simplify-subject-re
9612 (mail-header-subject
9613 (gnus-data-header (car data)))))))
9614 (push (gnus-data-number (car data)) articles))
9615 (unless (and (setq data (cdr data))
9616 (> (gnus-data-level (car data)) top-level))
9618 ;; Return the list of articles.
9619 (nreverse articles)))
9621 (defun gnus-summary-rethread-current ()
9622 "Rethread the thread the current article is part of."
9624 (let* ((gnus-show-threads t)
9625 (article (gnus-summary-article-number))
9626 (id (mail-header-id (gnus-summary-article-header)))
9627 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9629 (error "No article on the current line"))
9630 (gnus-rebuild-thread id)
9631 (gnus-summary-goto-subject article)))
9633 (defun gnus-summary-reparent-thread ()
9634 "Make the current article child of the marked (or previous) article.
9636 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9637 is non-nil or the Subject: of both articles are the same."
9639 (unless (not (gnus-group-read-only-p))
9640 (error "The current newsgroup does not support article editing"))
9641 (unless (<= (length gnus-newsgroup-processable) 1)
9642 (error "No more than one article may be marked"))
9643 (save-window-excursion
9644 (let ((gnus-article-buffer " *reparent*")
9645 (current-article (gnus-summary-article-number))
9646 ;; First grab the marked article, otherwise one line up.
9647 (parent-article (if (not (null gnus-newsgroup-processable))
9648 (car gnus-newsgroup-processable)
9650 (if (eq (forward-line -1) 0)
9651 (gnus-summary-article-number)
9652 (error "Beginning of summary buffer"))))))
9653 (unless (not (eq current-article parent-article))
9654 (error "An article may not be self-referential"))
9655 (let ((message-id (mail-header-id
9656 (gnus-summary-article-header parent-article))))
9657 (unless (and message-id (not (equal message-id "")))
9658 (error "No message-id in desired parent"))
9659 (gnus-with-article current-article
9661 (goto-char (point-min))
9662 (message-narrow-to-head)
9663 (if (re-search-forward "^References: " nil t)
9665 (re-search-forward "^[^ \t]" nil t)
9668 (insert " " message-id))
9669 (insert "References: " message-id "\n"))))
9670 (set-buffer gnus-summary-buffer)
9671 (gnus-summary-unmark-all-processable)
9672 (gnus-summary-update-article current-article)
9673 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9674 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9675 (gnus-summary-rethread-current)
9676 (gnus-message 3 "Article %d is now the child of article %d"
9677 current-article parent-article)))))
9679 (defun gnus-summary-toggle-threads (&optional arg)
9680 "Toggle showing conversation threads.
9681 If ARG is positive number, turn showing conversation threads on."
9683 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9684 (setq gnus-show-threads
9685 (if (null arg) (not gnus-show-threads)
9686 (> (prefix-numeric-value arg) 0)))
9687 (gnus-summary-prepare)
9688 (gnus-summary-goto-subject current)
9689 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9690 (gnus-summary-position-point)))
9692 (defun gnus-summary-show-all-threads ()
9696 (let ((buffer-read-only nil))
9697 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9698 (gnus-summary-position-point))
9700 (defun gnus-summary-show-thread ()
9701 "Show thread subtrees.
9702 Returns nil if no thread was there to be shown."
9704 (let ((buffer-read-only nil)
9706 ;; first goto end then to beg, to have point at beg after let
9707 (end (progn (end-of-line) (point)))
9708 (beg (progn (beginning-of-line) (point))))
9710 ;; Any hidden lines here?
9711 (search-forward "\r" end t)
9712 (subst-char-in-region beg end ?\^M ?\n t)
9714 (gnus-summary-position-point))))
9716 (defun gnus-summary-hide-all-threads ()
9717 "Hide all thread subtrees."
9720 (goto-char (point-min))
9721 (gnus-summary-hide-thread)
9722 (while (zerop (gnus-summary-next-thread 1 t))
9723 (gnus-summary-hide-thread)))
9724 (gnus-summary-position-point))
9726 (defun gnus-summary-hide-thread ()
9727 "Hide thread subtrees.
9728 Returns nil if no threads were there to be hidden."
9730 (let ((buffer-read-only nil)
9732 (article (gnus-summary-article-number)))
9734 ;; Go forward until either the buffer ends or the subthread
9736 (when (and (not (eobp))
9737 (or (zerop (gnus-summary-next-thread 1 t))
9738 (goto-char (point-max))))
9740 (if (and (> (point) start)
9741 (search-backward "\n" start t))
9743 (subst-char-in-region start (point) ?\n ?\^M)
9744 (gnus-summary-goto-subject article))
9748 (defun gnus-summary-go-to-next-thread (&optional previous)
9749 "Go to the same level (or less) next thread.
9750 If PREVIOUS is non-nil, go to previous thread instead.
9751 Return the article number moved to, or nil if moving was impossible."
9752 (let ((level (gnus-summary-thread-level))
9753 (way (if previous -1 1))
9756 (while (and (not (eobp))
9757 (< level (gnus-summary-thread-level)))
9765 (gnus-summary-article-number)
9768 (defun gnus-summary-next-thread (n &optional silent)
9769 "Go to the same level next N'th thread.
9770 If N is negative, search backward instead.
9771 Returns the difference between N and the number of skips actually
9774 If SILENT, don't output messages."
9776 (let ((backward (< n 0))
9779 (gnus-summary-go-to-next-thread backward))
9782 (gnus-summary-position-point))
9783 (when (and (not silent) (/= 0 n))
9784 (gnus-message 7 "No more threads"))
9787 (defun gnus-summary-prev-thread (n)
9788 "Go to the same level previous N'th thread.
9789 Returns the difference between N and the number of skips actually
9792 (gnus-summary-next-thread (- n)))
9794 (defun gnus-summary-go-down-thread ()
9795 "Go down one level in the current thread."
9796 (let ((children (gnus-summary-article-children)))
9798 (gnus-summary-goto-subject (car children)))))
9800 (defun gnus-summary-go-up-thread ()
9801 "Go up one level in the current thread."
9802 (let ((parent (gnus-summary-article-parent)))
9804 (gnus-summary-goto-subject parent))))
9806 (defun gnus-summary-down-thread (n)
9807 "Go down thread N steps.
9808 If N is negative, go up instead.
9809 Returns the difference between N and how many steps down that were
9815 (if up (gnus-summary-go-up-thread)
9816 (gnus-summary-go-down-thread)))
9818 (gnus-summary-position-point)
9820 (gnus-message 7 "Can't go further"))
9823 (defun gnus-summary-up-thread (n)
9824 "Go up thread N steps.
9825 If N is negative, go down instead.
9826 Returns the difference between N and how many steps down that were
9829 (gnus-summary-down-thread (- n)))
9831 (defun gnus-summary-top-thread ()
9832 "Go to the top of the thread."
9834 (while (gnus-summary-go-up-thread))
9835 (gnus-summary-article-number))
9837 (defun gnus-summary-kill-thread (&optional unmark)
9838 "Mark articles under current thread as read.
9839 If the prefix argument is positive, remove any kinds of marks.
9840 If the prefix argument is negative, tick articles instead."
9843 (setq unmark (prefix-numeric-value unmark)))
9844 (let ((articles (gnus-summary-articles-in-thread)))
9846 ;; Expand the thread.
9847 (gnus-summary-show-thread)
9848 ;; Mark all the articles.
9850 (gnus-summary-goto-subject (car articles))
9851 (cond ((null unmark)
9852 (gnus-summary-mark-article-as-read gnus-killed-mark))
9854 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9856 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9857 (setq articles (cdr articles))))
9858 ;; Hide killed subtrees.
9860 gnus-thread-hide-killed
9861 (gnus-summary-hide-thread))
9862 ;; If marked as read, go to next unread subject.
9864 ;; Go to next unread subject.
9865 (gnus-summary-next-subject 1 t)))
9866 (gnus-set-mode-line 'summary))
9868 ;; Summary sorting commands
9870 (defun gnus-summary-sort-by-number (&optional reverse)
9871 "Sort the summary buffer by article number.
9872 Argument REVERSE means reverse order."
9874 (gnus-summary-sort 'number reverse))
9876 (defun gnus-summary-sort-by-author (&optional reverse)
9877 "Sort the summary buffer by author name alphabetically.
9878 If `case-fold-search' is non-nil, case of letters is ignored.
9879 Argument REVERSE means reverse order."
9881 (gnus-summary-sort 'author reverse))
9883 (defun gnus-summary-sort-by-subject (&optional reverse)
9884 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9885 If `case-fold-search' is non-nil, case of letters is ignored.
9886 Argument REVERSE means reverse order."
9888 (gnus-summary-sort 'subject reverse))
9890 (defun gnus-summary-sort-by-date (&optional reverse)
9891 "Sort the summary buffer by date.
9892 Argument REVERSE means reverse order."
9894 (gnus-summary-sort 'date reverse))
9896 (defun gnus-summary-sort-by-score (&optional reverse)
9897 "Sort the summary buffer by score.
9898 Argument REVERSE means reverse order."
9900 (gnus-summary-sort 'score reverse))
9902 (defun gnus-summary-sort-by-lines (&optional reverse)
9903 "Sort the summary buffer by the number of lines.
9904 Argument REVERSE means reverse order."
9906 (gnus-summary-sort 'lines reverse))
9908 (defun gnus-summary-sort-by-chars (&optional reverse)
9909 "Sort the summary buffer by article length.
9910 Argument REVERSE means reverse order."
9912 (gnus-summary-sort 'chars reverse))
9914 (defun gnus-summary-sort-by-original (&optional reverse)
9915 "Sort the summary buffer using the default sorting method.
9916 Argument REVERSE means reverse order."
9918 (let* ((buffer-read-only)
9919 (gnus-summary-prepare-hook nil))
9920 ;; We do the sorting by regenerating the threads.
9921 (gnus-summary-prepare)
9922 ;; Hide subthreads if needed.
9923 (when (and gnus-show-threads gnus-thread-hide-subtree)
9924 (gnus-summary-hide-all-threads))))
9926 (defun gnus-summary-sort (predicate reverse)
9927 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9928 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9929 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9930 (gnus-thread-sort-functions
9935 (gnus-sort-gathered-threads-function
9936 gnus-thread-sort-functions)
9937 (gnus-article-sort-functions
9943 (gnus-summary-prepare-hook nil))
9944 ;; We do the sorting by regenerating the threads.
9945 (gnus-summary-prepare)
9946 ;; Hide subthreads if needed.
9947 (when (and gnus-show-threads gnus-thread-hide-subtree)
9948 (gnus-summary-hide-all-threads))))
9950 ;; Summary saving commands.
9952 (defun gnus-summary-save-article (&optional n not-saved)
9953 "Save the current article using the default saver function.
9954 If N is a positive number, save the N next articles.
9955 If N is a negative number, save the N previous articles.
9956 If N is nil and any articles have been marked with the process mark,
9957 save those articles instead.
9958 The variable `gnus-default-article-saver' specifies the saver function."
9960 (let* ((articles (gnus-summary-work-articles n))
9961 (save-buffer (save-excursion
9962 (nnheader-set-temp-buffer " *Gnus Save*")))
9963 (num (length articles))
9965 (dolist (article articles)
9966 (setq header (gnus-summary-article-header article))
9967 (if (not (vectorp header))
9968 ;; This is a pseudo-article.
9969 (if (assq 'name header)
9970 (gnus-copy-file (cdr (assq 'name header)))
9971 (gnus-message 1 "Article %d is unsaveable" article))
9972 ;; This is a real article.
9973 (save-window-excursion
9974 (let ((gnus-display-mime-function nil)
9975 (gnus-article-prepare-hook nil))
9976 (gnus-summary-select-article t nil nil article)))
9978 (set-buffer save-buffer)
9980 (insert-buffer-substring gnus-original-article-buffer))
9981 (setq file (gnus-article-save save-buffer file num))
9982 (gnus-summary-remove-process-mark article)
9984 (gnus-summary-set-saved-mark article))))
9985 (gnus-kill-buffer save-buffer)
9986 (gnus-summary-position-point)
9987 (gnus-set-mode-line 'summary)
9990 (defun gnus-summary-pipe-output (&optional arg)
9991 "Pipe the current article to a subprocess.
9992 If N is a positive number, pipe the N next articles.
9993 If N is a negative number, pipe the N previous articles.
9994 If N is nil and any articles have been marked with the process mark,
9995 pipe those articles instead."
9998 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9999 (gnus-summary-save-article arg t))
10000 (let ((buffer (get-buffer "*Shell Command Output*")))
10002 (with-current-buffer buffer (> (point-max) (point-min))))
10003 (gnus-configure-windows 'pipe))))
10005 (defun gnus-summary-save-article-mail (&optional arg)
10006 "Append the current article to an mail file.
10007 If N is a positive number, save the N next articles.
10008 If N is a negative number, save the N previous articles.
10009 If N is nil and any articles have been marked with the process mark,
10010 save those articles instead."
10012 (require 'gnus-art)
10013 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10014 (gnus-summary-save-article arg)))
10016 (defun gnus-summary-save-article-rmail (&optional arg)
10017 "Append the current article to an rmail file.
10018 If N is a positive number, save the N next articles.
10019 If N is a negative number, save the N previous articles.
10020 If N is nil and any articles have been marked with the process mark,
10021 save those articles instead."
10023 (require 'gnus-art)
10024 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10025 (gnus-summary-save-article arg)))
10027 (defun gnus-summary-save-article-file (&optional arg)
10028 "Append the current article to a file.
10029 If N is a positive number, save the N next articles.
10030 If N is a negative number, save the N previous articles.
10031 If N is nil and any articles have been marked with the process mark,
10032 save those articles instead."
10034 (require 'gnus-art)
10035 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10036 (gnus-summary-save-article arg)))
10038 (defun gnus-summary-write-article-file (&optional arg)
10039 "Write the current article to a file, deleting the previous file.
10040 If N is a positive number, save the N next articles.
10041 If N is a negative number, save the N previous articles.
10042 If N is nil and any articles have been marked with the process mark,
10043 save those articles instead."
10045 (require 'gnus-art)
10046 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10047 (gnus-summary-save-article arg)))
10049 (defun gnus-summary-save-article-body-file (&optional arg)
10050 "Append the current article body to a file.
10051 If N is a positive number, save the N next articles.
10052 If N is a negative number, save the N previous articles.
10053 If N is nil and any articles have been marked with the process mark,
10054 save those articles instead."
10056 (require 'gnus-art)
10057 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10058 (gnus-summary-save-article arg)))
10060 (defun gnus-summary-pipe-message (program)
10061 "Pipe the current article through PROGRAM."
10062 (interactive "sProgram: ")
10063 (gnus-summary-select-article)
10064 (let ((mail-header-separator ""))
10065 (gnus-eval-in-buffer-window gnus-article-buffer
10068 (let ((start (window-start))
10070 (message-pipe-buffer-body program)
10071 (set-window-start (get-buffer-window (current-buffer)) start))))))
10073 (defun gnus-get-split-value (methods)
10074 "Return a value based on the split METHODS."
10075 (let (split-name method result match)
10078 (set-buffer gnus-original-article-buffer)
10080 (nnheader-narrow-to-headers)
10081 (while (and methods (not split-name))
10082 (goto-char (point-min))
10083 (setq method (pop methods))
10084 (setq match (car method))
10087 ;; Regular expression.
10089 (re-search-forward match nil t)))
10090 ((gnus-functionp match)
10094 (setq result (funcall match gnus-newsgroup-name))))
10099 (setq result (eval match)))))
10100 (setq split-name (cdr method))
10101 (cond ((stringp result)
10102 (push (expand-file-name
10103 result gnus-article-save-directory)
10106 (setq split-name (append result split-name)))))))))
10107 (nreverse split-name)))
10109 (defun gnus-valid-move-group-p (group)
10110 (and (boundp group)
10111 (symbol-name group)
10112 (symbol-value group)
10113 (gnus-get-function (gnus-find-method-for-group
10114 (symbol-name group)) 'request-accept-article t)))
10116 (defun gnus-read-move-group-name (prompt default articles prefix)
10117 "Read a group name."
10118 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10119 (minibuffer-confirm-incomplete nil) ; XEmacs
10121 (format "%s %s to:"
10123 (if (> (length articles) 1)
10124 (format "these %d articles" (length articles))
10129 (gnus-completing-read default prom
10131 'gnus-valid-move-group-p
10133 'gnus-group-history))
10134 ((= 1 (length split-name))
10135 (gnus-completing-read (car split-name) prom
10137 'gnus-valid-move-group-p
10139 'gnus-group-history))
10141 (gnus-completing-read nil prom
10142 (mapcar (lambda (el) (list el))
10143 (nreverse split-name))
10145 'gnus-group-history))))
10146 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10148 (if (or (string= to-newsgroup "")
10149 (string= to-newsgroup prefix))
10150 (setq to-newsgroup default))
10151 (unless to-newsgroup
10152 (error "No group name entered"))
10153 (or (gnus-active to-newsgroup)
10154 (gnus-activate-group to-newsgroup nil nil to-method)
10155 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10157 (or (and (gnus-request-create-group to-newsgroup to-method)
10158 (gnus-activate-group
10159 to-newsgroup nil nil to-method)
10160 (gnus-subscribe-group to-newsgroup))
10161 (error "Couldn't create group %s" to-newsgroup)))
10162 (error "No such group: %s" to-newsgroup)))
10165 (defun gnus-summary-save-parts (type dir n &optional reverse)
10166 "Save parts matching TYPE to DIR.
10167 If REVERSE, save parts that do not match TYPE."
10169 (list (read-string "Save parts of type: "
10170 (or (car gnus-summary-save-parts-type-history)
10171 gnus-summary-save-parts-default-mime)
10172 'gnus-summary-save-parts-type-history)
10173 (setq gnus-summary-save-parts-last-directory
10174 (read-file-name "Save to directory: "
10175 gnus-summary-save-parts-last-directory
10177 current-prefix-arg))
10178 (gnus-summary-iterate n
10179 (let ((gnus-display-mime-function nil)
10180 (gnus-inhibit-treatment t))
10181 (gnus-summary-select-article))
10183 (set-buffer gnus-article-buffer)
10184 (let ((handles (or gnus-article-mime-handles
10185 (mm-dissect-buffer) (mm-uu-dissect))))
10187 (gnus-summary-save-parts-1 type dir handles reverse)
10188 (unless gnus-article-mime-handles ;; Don't destroy this case.
10189 (mm-destroy-parts handles)))))))
10191 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10192 (if (stringp (car handle))
10193 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10196 (not (string-match type (mm-handle-media-type handle)))
10197 (string-match type (mm-handle-media-type handle)))
10198 (let ((file (expand-file-name
10199 (file-name-nondirectory
10201 (mail-content-type-get
10202 (mm-handle-disposition handle) 'filename)
10203 (concat gnus-newsgroup-name
10204 "." (number-to-string
10205 (cdr gnus-article-current)))))
10207 (unless (file-exists-p file)
10208 (mm-save-part-to-file handle file))))))
10210 ;; Summary extract commands
10212 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10213 (let ((buffer-read-only nil)
10214 (article (gnus-summary-article-number))
10216 (unless (gnus-summary-goto-subject article)
10217 (error "No such article: %d" article))
10218 (gnus-summary-position-point)
10219 ;; If all commands are to be bunched up on one line, we collect
10221 (unless gnus-view-pseudos-separately
10222 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10225 (setq action (cdr (assq 'action (car ps))))
10226 (setq files (list (cdr (assq 'name (car ps)))))
10227 (while (and ps (cdr ps)
10228 (string= (or action "1")
10229 (or (cdr (assq 'action (cadr ps))) "2")))
10230 (push (cdr (assq 'name (cadr ps))) files)
10231 (setcdr ps (cddr ps)))
10233 (when (not (string-match "%s" action))
10236 (when (assq 'execute (car ps))
10237 (setcdr (assq 'execute (car ps))
10238 (funcall (if (string-match "%s" action)
10245 (gnus-quote-arg-for-sh-or-csh f)))
10247 (setq ps (cdr ps)))))
10248 (if (and gnus-view-pseudos (not not-view))
10250 (when (assq 'execute (car pslist))
10251 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10252 (eq gnus-view-pseudos 'not-confirm)))
10253 (setq pslist (cdr pslist)))
10256 (setq after-article (or (cdr (assq 'article (car pslist)))
10257 (gnus-summary-article-number)))
10258 (gnus-summary-goto-subject after-article)
10261 (insert " " (file-name-nondirectory
10262 (cdr (assq 'name (car pslist))))
10263 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10265 (forward-line -1) ; back to `b'
10266 (gnus-add-text-properties
10267 b (1- e) (list 'gnus-number gnus-reffed-article-number
10268 gnus-mouse-face-prop gnus-mouse-face))
10270 after-article gnus-reffed-article-number
10271 gnus-unread-mark b (car pslist) 0 (- e b))
10272 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10273 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10274 (setq pslist (cdr pslist)))))))
10276 (defun gnus-pseudos< (p1 p2)
10277 (let ((c1 (cdr (assq 'action p1)))
10278 (c2 (cdr (assq 'action p2))))
10279 (and c1 c2 (string< c1 c2))))
10281 (defun gnus-request-pseudo-article (props)
10282 (cond ((assq 'execute props)
10283 (gnus-execute-command (cdr (assq 'execute props)))))
10284 (let ((gnus-current-article (gnus-summary-article-number)))
10285 (gnus-run-hooks 'gnus-mark-article-hook)))
10287 (defun gnus-execute-command (command &optional automatic)
10289 (gnus-article-setup-buffer)
10290 (set-buffer gnus-article-buffer)
10291 (setq buffer-read-only nil)
10292 (let ((command (if automatic command
10293 (read-string "Command: " (cons command 0)))))
10295 (insert "$ " command "\n\n")
10296 (if gnus-view-pseudo-asynchronously
10297 (start-process "gnus-execute" (current-buffer) shell-file-name
10298 shell-command-switch command)
10299 (call-process shell-file-name nil t nil
10300 shell-command-switch command)))))
10302 ;; Summary kill commands.
10304 (defun gnus-summary-edit-global-kill (article)
10305 "Edit the \"global\" kill file."
10306 (interactive (list (gnus-summary-article-number)))
10307 (gnus-group-edit-global-kill article))
10309 (defun gnus-summary-edit-local-kill ()
10310 "Edit a local kill file applied to the current newsgroup."
10312 (setq gnus-current-headers (gnus-summary-article-header))
10313 (gnus-group-edit-local-kill
10314 (gnus-summary-article-number) gnus-newsgroup-name))
10316 ;;; Header reading.
10318 (defun gnus-read-header (id &optional header)
10319 "Read the headers of article ID and enter them into the Gnus system."
10320 (let ((group gnus-newsgroup-name)
10321 (gnus-override-method
10323 gnus-override-method
10324 (and (gnus-news-group-p gnus-newsgroup-name)
10325 (car (gnus-refer-article-methods)))))
10327 ;; First we check to see whether the header in question is already
10330 ;; This is a Message-ID.
10331 (setq header (or header (gnus-id-to-header id)))
10332 ;; This is an article number.
10333 (setq header (or header (gnus-summary-article-header id))))
10335 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10336 ;; We have found the header.
10338 ;; If this is a sparse article, we have to nix out its
10339 ;; previous entry in the thread hashtb.
10341 (gnus-summary-article-sparse-p (mail-header-number header)))
10342 (let* ((parent (gnus-parent-id (mail-header-references header)))
10343 (thread (and parent (gnus-id-to-thread parent))))
10345 (delq (assq header thread) thread))))
10346 ;; We have to really fetch the header to this article.
10348 (set-buffer nntp-server-buffer)
10349 (when (setq where (gnus-request-head id group))
10350 (nnheader-fold-continuation-lines)
10351 (goto-char (point-max))
10353 (goto-char (point-min))
10357 ((cdr where) (cdr where))
10358 (header (mail-header-number header))
10359 (t gnus-reffed-article-number))
10361 (insert " Article retrieved.\n"))
10362 (if (or (not where)
10363 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10364 () ; Malformed head.
10365 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10366 (when (and (stringp id)
10367 (not (string= (gnus-group-real-name group)
10369 ;; If we fetched by Message-ID and the article came
10370 ;; from a different group, we fudge some bogus article
10371 ;; numbers for this article.
10372 (mail-header-set-number header gnus-reffed-article-number))
10374 (set-buffer gnus-summary-buffer)
10375 (decf gnus-reffed-article-number)
10376 (gnus-remove-header (mail-header-number header))
10377 (push header gnus-newsgroup-headers)
10378 (setq gnus-current-headers header)
10379 (push (mail-header-number header) gnus-newsgroup-limit)))
10382 (defun gnus-remove-header (number)
10383 "Remove header NUMBER from `gnus-newsgroup-headers'."
10384 (if (and gnus-newsgroup-headers
10385 (= number (mail-header-number (car gnus-newsgroup-headers))))
10386 (pop gnus-newsgroup-headers)
10387 (let ((headers gnus-newsgroup-headers))
10388 (while (and (cdr headers)
10389 (not (= number (mail-header-number (cadr headers)))))
10391 (when (cdr headers)
10392 (setcdr headers (cddr headers))))))
10395 ;;; summary highlights
10398 (defun gnus-highlight-selected-summary ()
10399 "Highlight selected article in summary buffer."
10400 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10401 (when gnus-summary-selected-face
10403 (let* ((beg (progn (beginning-of-line) (point)))
10404 (end (progn (end-of-line) (point)))
10405 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10406 (from (if (get-text-property beg gnus-mouse-face-prop)
10408 (or (next-single-property-change
10409 beg gnus-mouse-face-prop nil end)
10414 (or (next-single-property-change
10415 from gnus-mouse-face-prop nil end)
10417 ;; If no mouse-face prop on line we will have to = from = end,
10418 ;; so we highlight the entire line instead.
10419 (when (= (+ to 2) from)
10422 (if gnus-newsgroup-selected-overlay
10423 ;; Move old overlay.
10425 gnus-newsgroup-selected-overlay from to (current-buffer))
10426 ;; Create new overlay.
10428 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10429 'face gnus-summary-selected-face))))))
10431 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10432 (defun gnus-summary-highlight-line ()
10433 "Highlight current line according to `gnus-summary-highlight'."
10434 (let* ((list gnus-summary-highlight)
10436 (end (progn (end-of-line) (point)))
10437 ;; now find out where the line starts and leave point there.
10438 (beg (progn (beginning-of-line) (point)))
10439 (article (gnus-summary-article-number))
10440 (score (or (cdr (assq (or article gnus-current-article)
10441 gnus-newsgroup-scored))
10442 gnus-summary-default-score 0))
10443 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10444 (inhibit-read-only t))
10445 ;; Eval the cars of the lists until we find a match.
10446 (let ((default gnus-summary-default-score)
10447 (default-high gnus-summary-default-high-score)
10448 (default-low gnus-summary-default-low-score))
10450 (not (eval (caar list))))
10451 (setq list (cdr list))))
10452 (let ((face (cdar list)))
10453 (unless (eq face (get-text-property beg 'face))
10454 (gnus-put-text-property-excluding-characters-with-faces
10456 (setq face (if (boundp face) (symbol-value face) face)))
10457 (when gnus-summary-highlight-line-function
10458 (funcall gnus-summary-highlight-line-function article face))))
10461 (defun gnus-update-read-articles (group unread &optional compute)
10462 "Update the list of read articles in GROUP."
10463 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10464 (entry (gnus-gethash group gnus-newsrc-hashtb))
10465 (info (nth 2 entry))
10467 (unread (sort (copy-sequence unread) '<))
10469 (if (or (not info) (not active))
10470 ;; There is no info on this group if it was, in fact,
10471 ;; killed. Gnus stores no information on killed groups, so
10472 ;; there's nothing to be done.
10473 ;; One could store the information somewhere temporarily,
10474 ;; perhaps... Hmmm...
10476 ;; Remove any negative articles numbers.
10477 (while (and unread (< (car unread) 0))
10478 (setq unread (cdr unread)))
10479 ;; Remove any expired article numbers
10480 (while (and unread (< (car unread) (car active)))
10481 (setq unread (cdr unread)))
10482 ;; Compute the ranges of read articles by looking at the list of
10483 ;; unread articles.
10485 (when (/= (car unread) prev)
10486 (push (if (= prev (1- (car unread))) prev
10487 (cons prev (1- (car unread))))
10489 (setq prev (1+ (car unread)))
10490 (setq unread (cdr unread)))
10491 (when (<= prev (cdr active))
10492 (push (cons prev (cdr active)) read))
10493 (setq read (if (> (length read) 1) (nreverse read) read))
10498 ;; Propagate the read marks to the backend.
10499 (when (gnus-check-backend-function 'request-set-mark group)
10500 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10501 (add (gnus-remove-from-range read (gnus-info-read info))))
10503 (unless (gnus-check-group group)
10504 (error "Can't open server for %s" group))
10505 (gnus-request-set-mark
10506 group (delq nil (list (if add (list add 'add '(read)))
10507 (if del (list del 'del '(read))))))
10509 `(gnus-request-set-mark
10512 (if del (list del 'add '(read)))
10513 (if add (list add 'del '(read))))))))))
10514 (set-buffer gnus-group-buffer)
10515 (gnus-undo-register
10517 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10518 (gnus-info-set-read ',info ',(gnus-info-read info))
10519 (gnus-get-unread-articles-in-group ',info
10520 (gnus-active ,group))
10521 (gnus-group-update-group ,group t)
10523 ;; Enter this list into the group info.
10524 (gnus-info-set-read info read)
10525 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10526 (gnus-get-unread-articles-in-group info (gnus-active group))
10529 (defun gnus-offer-save-summaries ()
10530 "Offer to save all active summary buffers."
10532 ;; Go through all buffers and find all summaries.
10533 (dolist (buffer (buffer-list))
10534 (when (and (setq buffer (buffer-name buffer))
10535 (string-match "Summary" buffer)
10537 (set-buffer buffer)
10538 ;; We check that this is, indeed, a summary buffer.
10539 (and (eq major-mode 'gnus-summary-mode)
10540 ;; Also make sure this isn't bogus.
10541 gnus-newsgroup-prepared
10542 ;; Also make sure that this isn't a
10543 ;; dead summary buffer.
10544 (not gnus-dead-summary-mode))))
10545 (push buffer buffers)))
10546 ;; Go through all these summary buffers and offer to save them.
10550 "Update summary buffer %s? "
10552 (switch-to-buffer buf)
10553 (gnus-summary-exit))
10557 ;;; @ for mime-partial
10560 (defun gnus-request-partial-message ()
10562 (let ((number (gnus-summary-article-number))
10563 (group gnus-newsgroup-name)
10564 (mother gnus-article-buffer))
10565 (set-buffer (get-buffer-create " *Partial Article*"))
10567 (setq mime-preview-buffer mother)
10568 (gnus-request-article-this-buffer number group)
10569 (mime-parse-buffer)
10572 (autoload 'mime-combine-message/partial-pieces-automatically
10574 "Internal method to combine message/partial messages automatically.")
10576 (mime-add-condition
10577 'action '((type . message)(subtype . partial)
10578 (major-mode . gnus-original-article-mode)
10579 (method . mime-combine-message/partial-pieces-automatically)
10580 (summary-buffer-exp . gnus-summary-buffer)
10581 (request-partial-message-method . gnus-request-partial-message)
10585 ;;; @ for message/rfc822
10588 (defun gnus-mime-extract-message/rfc822 (entity situation)
10589 (let (group article num cwin swin cur)
10591 (mime-insert-entity-content entity)
10592 (setq group (or (cdr (assq 'group situation))
10593 (completing-read "Group: "
10596 (gnus-read-active-file-p)
10597 gnus-newsgroup-name))
10598 article (gnus-request-accept-article group)))
10599 (when (and (consp article)
10600 (numberp (setq article (cdr article))))
10601 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10602 cwin (get-buffer-window (current-buffer) t))
10603 (save-window-excursion
10604 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10605 (select-window swin)
10606 (set-buffer gnus-summary-buffer))
10607 (setq cur gnus-current-article)
10609 (let (gnus-show-threads)
10610 (gnus-summary-goto-subject article t))
10611 (gnus-summary-clear-mark-forward 1)
10612 (gnus-summary-goto-subject cur))
10613 (when (and cwin (window-frame cwin))
10614 (select-frame (window-frame cwin)))
10615 (when (boundp 'mime-acting-situation-to-override)
10616 (set-alist 'mime-acting-situation-to-override
10619 (set-alist 'mime-acting-situation-to-override
10622 (save-current-buffer
10623 (set-buffer gnus-group-buffer)
10624 (gnus-activate-group ,group))
10625 (gnus-summary-goto-article ,cur
10626 gnus-show-all-headers)))
10627 (set-alist 'mime-acting-situation-to-override
10630 (mime-add-condition
10631 'action '((type . message)(subtype . rfc822)
10632 (major-mode . gnus-original-article-mode)
10633 (method . gnus-mime-extract-message/rfc822)
10637 (mime-add-condition
10638 'action '((type . message)(subtype . news)
10639 (major-mode . gnus-original-article-mode)
10640 (method . gnus-mime-extract-message/rfc822)
10644 (defun gnus-mime-extract-multipart (entity situation)
10645 (let ((children (mime-entity-children entity))
10646 mime-acting-situation-to-override
10649 (mime-play-entity (car children)
10650 (cons (assq 'mode situation)
10651 mime-acting-situation-to-override))
10652 (setq children (cdr children)))
10653 (if (setq f (cdr (assq 'after-method
10654 mime-acting-situation-to-override)))
10658 (mime-add-condition
10659 'action '((type . multipart)
10660 (method . gnus-mime-extract-multipart)
10669 (defun gnus-summary-setup-default-charset ()
10670 "Setup newsgroup default charset."
10671 (if (equal gnus-newsgroup-name "nndraft:drafts")
10672 (setq gnus-newsgroup-charset nil)
10673 (let* ((ignored-charsets
10674 (or gnus-newsgroup-ephemeral-ignored-charsets
10676 (and gnus-newsgroup-name
10677 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10678 gnus-newsgroup-ignored-charsets))))
10679 (setq gnus-newsgroup-charset
10680 (or gnus-newsgroup-ephemeral-charset
10681 (and gnus-newsgroup-name
10682 (gnus-parameter-charset gnus-newsgroup-name))
10683 gnus-default-charset))
10684 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10685 ignored-charsets))))
10691 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10692 "Display the current article buffer fully MIME-buttonized.
10693 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10694 treated as multipart/mixed."
10696 (require 'gnus-art)
10697 (let ((gnus-unbuttonized-mime-types nil)
10698 (gnus-mime-display-multipart-as-mixed show-all-parts))
10699 (gnus-summary-show-article)))
10701 (defun gnus-summary-repair-multipart (article)
10702 "Add a Content-Type header to a multipart article without one."
10703 (interactive (list (gnus-summary-article-number)))
10704 (gnus-with-article article
10705 (message-narrow-to-head)
10706 (message-remove-header "Mime-Version")
10707 (goto-char (point-max))
10708 (insert "Mime-Version: 1.0\n")
10710 (when (search-forward "\n--" nil t)
10711 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10712 (message-narrow-to-head)
10713 (message-remove-header "Content-Type")
10714 (goto-char (point-max))
10715 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10718 (let (gnus-mark-article-hook)
10719 (gnus-summary-select-article t t nil article)))
10721 (defun gnus-summary-toggle-display-buttonized ()
10722 "Toggle the buttonizing of the article buffer."
10724 (require 'gnus-art)
10725 (if (setq gnus-inhibit-mime-unbuttonizing
10726 (not gnus-inhibit-mime-unbuttonizing))
10727 (let ((gnus-unbuttonized-mime-types nil))
10728 (gnus-summary-show-article))
10729 (gnus-summary-show-article)))
10732 ;;; Intelli-mouse commmands
10735 (defun gnus-wheel-summary-scroll (event)
10737 (let ((amount (if (memq 'shift (event-modifiers event))
10738 (car gnus-wheel-scroll-amount)
10739 (cdr gnus-wheel-scroll-amount)))
10740 (direction (- (* (static-if (featurep 'xemacs)
10741 (event-button event)
10742 (cond ((eq 'mouse-4 (event-basic-type event))
10744 ((eq 'mouse-5 (event-basic-type event))
10748 (gnus-summary-scroll-up (* amount direction))
10749 (when (gnus-eval-in-buffer-window gnus-article-buffer
10752 (and (if (< 0 direction)
10753 (gnus-article-next-page 0)
10754 (gnus-article-prev-page 0)
10756 (if (setq edge (get-text-property
10757 (point-min) 'gnus-wheel-edge))
10758 (setq edge (* edge direction))
10761 (let ((buffer-read-only nil)
10762 (inhibit-read-only t))
10763 (put-text-property (point-min) (point-max)
10764 'gnus-wheel-edge direction)
10766 (or (> edge gnus-wheel-edge-resistance)
10767 (let ((buffer-read-only nil)
10768 (inhibit-read-only t))
10769 (put-text-property (point-min) (point-max)
10771 (* (1+ edge) direction))
10773 (eq last-command 'gnus-wheel-summary-scroll))))
10774 (gnus-summary-next-article nil nil (minusp direction)))))
10776 (defun gnus-wheel-install ()
10777 "Enable mouse wheel support on summary window."
10778 (when gnus-use-wheel
10780 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10782 (define-key gnus-summary-mode-map key
10783 'gnus-wheel-summary-scroll)))))
10785 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10788 ;;; Traditional PGP commmands
10791 (defun gnus-summary-decrypt-article (&optional force)
10792 "Decrypt the current article in traditional PGP way.
10793 This will have permanent effect only in mail groups.
10794 If FORCE is non-nil, allow editing of articles even in read-only
10797 (gnus-summary-select-article t)
10798 (gnus-eval-in-buffer-window gnus-article-buffer
10802 (goto-char (point-min))
10803 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10804 (error "Not a traditional PGP message!"))
10805 (let ((armor-start (match-beginning 0)))
10806 (if (and (pgg-decrypt-region armor-start (point-max))
10807 (or force (not (gnus-group-read-only-p))))
10808 (let ((inhibit-read-only t)
10810 (delete-region armor-start
10812 (re-search-forward "^-+END PGP" nil t)
10813 (beginning-of-line 2)
10815 (insert-buffer-substring pgg-output-buffer))))))))
10817 (defun gnus-summary-verify-article ()
10818 "Verify the current article in traditional PGP way."
10821 (set-buffer gnus-original-article-buffer)
10822 (goto-char (point-min))
10823 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10824 (error "Not a traditional PGP message!"))
10825 (re-search-forward "^-+END PGP" nil t)
10826 (beginning-of-line 2)
10827 (call-interactively (function pgg-verify-region))))
10830 ;;; Generic summary marking commands
10833 (defvar gnus-summary-marking-alist
10834 '((read gnus-del-mark "d")
10835 (unread gnus-unread-mark "u")
10836 (ticked gnus-ticked-mark "!")
10837 (dormant gnus-dormant-mark "?")
10838 (expirable gnus-expirable-mark "e"))
10839 "An alist of names/marks/keystrokes.")
10841 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10842 (defvar gnus-summary-mark-map)
10844 (defun gnus-summary-make-all-marking-commands ()
10845 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10846 (dolist (elem gnus-summary-marking-alist)
10847 (apply 'gnus-summary-make-marking-command elem)))
10849 (defun gnus-summary-make-marking-command (name mark keystroke)
10850 (let ((map (make-sparse-keymap)))
10851 (define-key gnus-summary-generic-mark-map keystroke map)
10852 (dolist (lway `((next "next" next nil "n")
10853 (next-unread "next unread" next t "N")
10854 (prev "previous" prev nil "p")
10855 (prev-unread "previous unread" prev t "P")
10856 (nomove "" nil nil ,keystroke)))
10857 (let ((func (gnus-summary-make-marking-command-1
10858 mark (car lway) lway name)))
10859 (setq func (eval func))
10860 (define-key map (nth 4 lway) func)))))
10862 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10864 (format "gnus-summary-put-mark-as-%s%s"
10865 name (if (eq way 'nomove)
10867 (concat "-" (symbol-name way)))))
10870 "Mark the current article as %s%s.
10871 If N, the prefix, then repeat N times.
10872 If N is negative, move in reverse order.
10873 The difference between N and the actual number of articles marked is
10875 name (car (cdr lway)))
10877 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10879 (defun gnus-summary-generic-mark (n mark move unread)
10880 "Mark N articles with MARK."
10881 (unless (eq major-mode 'gnus-summary-mode)
10882 (error "This command can only be used in the summary buffer"))
10883 (gnus-summary-show-thread)
10886 ((eq move 'next) 1)
10887 ((eq move 'prev) -1)
10889 (if (zerop nummove)
10893 nummove (* -1 nummove))))
10894 (while (and (> n 0)
10895 (gnus-summary-mark-article nil mark)
10896 (zerop (gnus-summary-next-subject nummove unread t)))
10899 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10900 (gnus-summary-recenter)
10901 (gnus-summary-position-point)
10902 (gnus-set-mode-line 'summary)
10905 (defun gnus-summary-insert-articles (articles)
10906 (when (setq articles
10907 (gnus-set-difference articles
10908 (mapcar (lambda (h) (mail-header-number h))
10909 gnus-newsgroup-headers)))
10910 (setq gnus-newsgroup-headers
10912 gnus-newsgroup-headers
10913 (gnus-fetch-headers articles)
10914 'gnus-article-sort-by-number))
10915 ;; Suppress duplicates?
10916 (when gnus-suppress-duplicates
10917 (gnus-dup-suppress-articles))
10919 ;; We might want to build some more threads first.
10920 (when (and gnus-fetch-old-headers
10921 (eq gnus-headers-retrieved-by 'nov))
10922 (if (eq gnus-fetch-old-headers 'invisible)
10923 (gnus-build-all-threads)
10924 (gnus-build-old-threads)))
10925 ;; Let the Gnus agent mark articles as read.
10927 (gnus-agent-get-undownloaded-list))
10928 ;; Remove list identifiers from subject
10929 (when gnus-list-identifiers
10930 (gnus-summary-remove-list-identifiers))
10931 ;; First and last article in this newsgroup.
10932 (when gnus-newsgroup-headers
10933 (setq gnus-newsgroup-begin
10934 (mail-header-number (car gnus-newsgroup-headers))
10936 (mail-header-number
10937 (gnus-last-element gnus-newsgroup-headers))))
10938 (when gnus-use-scoring
10939 (gnus-possibly-score-headers))))
10941 (defun gnus-summary-insert-old-articles (&optional all)
10942 "Insert all old articles in this group.
10943 If ALL is non-nil, already read articles become readable.
10944 If ALL is a number, fetch this number of articles."
10947 (let ((old (mapcar 'car gnus-newsgroup-data))
10948 (i (car gnus-newsgroup-active))
10950 (while (<= i (cdr gnus-newsgroup-active))
10951 (or (memq i old) (push i older))
10953 (setq len (length older))
10958 (setq older (subseq older 0 all))))
10961 (if (and (numberp gnus-large-newsgroup)
10962 (> len gnus-large-newsgroup))
10966 "How many articles from %s (default %d): "
10968 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10970 (unless (string-match "^[ \t]*$" input)
10971 (setq all (string-to-number input))
10973 (setq older (subseq older 0 all))))))))
10975 (message "No old news.")
10976 (gnus-summary-insert-articles older)
10977 (gnus-summary-limit (gnus-union older old))))
10978 (gnus-summary-position-point)))
10980 (defun gnus-summary-insert-new-articles ()
10981 "Insert all new articles in this group."
10984 (let ((old (mapcar 'car gnus-newsgroup-data))
10985 (old-active gnus-newsgroup-active)
10986 (nnmail-fetched-sources (list t))
10988 (setq gnus-newsgroup-active
10989 (gnus-activate-group gnus-newsgroup-name 'scan))
10990 (setq i (1+ (cdr old-active)))
10991 (while (<= i (cdr gnus-newsgroup-active))
10995 (message "No gnus is bad news.")
10996 (setq new (nreverse new))
10997 (gnus-summary-insert-articles new)
10998 (setq gnus-newsgroup-unreads
10999 (append gnus-newsgroup-unreads new))
11000 (gnus-summary-limit (gnus-union old new))))
11001 (gnus-summary-position-point)))
11003 (gnus-summary-make-all-marking-commands)
11005 (gnus-ems-redefine)
11007 (provide 'gnus-sum)
11009 (run-hooks 'gnus-sum-load-hook)
11011 ;;; gnus-sum.el ends here