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)
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) ?s)
1124 (?t (gnus-summary-number-of-articles-in-thread
1125 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1127 (?e (gnus-summary-number-of-articles-in-thread
1128 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1130 (?u gnus-tmp-user-defined ?s)
1131 (?P (gnus-pick-line-number) ?d)
1132 (?B gnus-tmp-thread-tree-header-string ?s))
1133 "An alist of format specifications that can appear in summary lines.
1134 These are paired with what variables they correspond with, along with
1135 the type of the variable (string, integer, character, etc).")
1137 (defvar gnus-summary-dummy-line-format-alist
1138 `((?S gnus-tmp-subject ?s)
1139 (?N gnus-tmp-number ?d)
1140 (?u gnus-tmp-user-defined ?s)))
1142 (defvar gnus-summary-mode-line-format-alist
1143 `((?G gnus-tmp-group-name ?s)
1144 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1145 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1146 (?A gnus-tmp-article-number ?d)
1147 (?Z gnus-tmp-unread-and-unselected ?s)
1148 (?V gnus-version ?s)
1149 (?U gnus-tmp-unread-and-unticked ?d)
1150 (?S gnus-tmp-subject ?s)
1151 (?e gnus-tmp-unselected ?d)
1152 (?u gnus-tmp-user-defined ?s)
1153 (?d (length gnus-newsgroup-dormant) ?d)
1154 (?t (length gnus-newsgroup-marked) ?d)
1155 (?r (length gnus-newsgroup-reads) ?d)
1156 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1157 (?E gnus-newsgroup-expunged-tally ?d)
1158 (?s (gnus-current-score-file-nondirectory) ?s)))
1160 (defvar gnus-last-search-regexp nil
1161 "Default regexp for article search command.")
1163 (defvar gnus-summary-search-article-matched-data nil
1164 "Last matched data of article search command. It is the local variable
1165 in `gnus-article-buffer' which consists of the list of start position,
1166 end position and text.")
1168 (defvar gnus-last-shell-command nil
1169 "Default shell command on article.")
1171 (defvar gnus-newsgroup-begin nil)
1172 (defvar gnus-newsgroup-end nil)
1173 (defvar gnus-newsgroup-last-rmail nil)
1174 (defvar gnus-newsgroup-last-mail nil)
1175 (defvar gnus-newsgroup-last-folder nil)
1176 (defvar gnus-newsgroup-last-file nil)
1177 (defvar gnus-newsgroup-auto-expire nil)
1178 (defvar gnus-newsgroup-active nil)
1180 (defvar gnus-newsgroup-data nil)
1181 (defvar gnus-newsgroup-data-reverse nil)
1182 (defvar gnus-newsgroup-limit nil)
1183 (defvar gnus-newsgroup-limits nil)
1185 (defvar gnus-newsgroup-unreads nil
1186 "List of unread articles in the current newsgroup.")
1188 (defvar gnus-newsgroup-unselected nil
1189 "List of unselected unread articles in the current newsgroup.")
1191 (defvar gnus-newsgroup-reads nil
1192 "Alist of read articles and article marks in the current newsgroup.")
1194 (defvar gnus-newsgroup-expunged-tally nil)
1196 (defvar gnus-newsgroup-marked nil
1197 "List of ticked articles in the current newsgroup (a subset of unread art).")
1199 (defvar gnus-newsgroup-killed nil
1200 "List of ranges of articles that have been through the scoring process.")
1202 (defvar gnus-newsgroup-cached nil
1203 "List of articles that come from the article cache.")
1205 (defvar gnus-newsgroup-saved nil
1206 "List of articles that have been saved.")
1208 (defvar gnus-newsgroup-kill-headers nil)
1210 (defvar gnus-newsgroup-replied nil
1211 "List of articles that have been replied to in the current newsgroup.")
1213 (defvar gnus-newsgroup-forwarded nil
1214 "List of articles that have been forwarded in the current newsgroup.")
1216 (defvar gnus-newsgroup-recent nil
1217 "List of articles that have are recent in the current newsgroup.")
1219 (defvar gnus-newsgroup-expirable nil
1220 "List of articles in the current newsgroup that can be expired.")
1222 (defvar gnus-newsgroup-processable nil
1223 "List of articles in the current newsgroup that can be processed.")
1225 (defvar gnus-newsgroup-downloadable nil
1226 "List of articles in the current newsgroup that can be processed.")
1228 (defvar gnus-newsgroup-undownloaded nil
1229 "List of articles in the current newsgroup that haven't been downloaded..")
1231 (defvar gnus-newsgroup-unsendable nil
1232 "List of articles in the current newsgroup that won't be sent.")
1234 (defvar gnus-newsgroup-bookmarks nil
1235 "List of articles in the current newsgroup that have bookmarks.")
1237 (defvar gnus-newsgroup-dormant nil
1238 "List of dormant articles in the current newsgroup.")
1240 (defvar gnus-newsgroup-unseen nil
1241 "List of unseen articles in the current newsgroup.")
1243 (defvar gnus-newsgroup-seen nil
1244 "Range of seen articles in the current newsgroup.")
1246 (defvar gnus-newsgroup-articles nil
1247 "List of articles in the current newsgroup.")
1249 (defvar gnus-newsgroup-scored nil
1250 "List of scored articles in the current newsgroup.")
1252 (defvar gnus-newsgroup-incorporated nil
1253 "List of incorporated articles in the current newsgroup.")
1255 (defvar gnus-newsgroup-headers nil
1256 "List of article headers in the current newsgroup.")
1258 (defvar gnus-newsgroup-threads nil)
1260 (defvar gnus-newsgroup-prepared nil
1261 "Whether the current group has been prepared properly.")
1263 (defvar gnus-newsgroup-ancient nil
1264 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1266 (defvar gnus-newsgroup-sparse nil)
1268 (defvar gnus-current-article nil)
1269 (defvar gnus-article-current nil)
1270 (defvar gnus-current-headers nil)
1271 (defvar gnus-have-all-headers nil)
1272 (defvar gnus-last-article nil)
1273 (defvar gnus-newsgroup-history nil)
1274 (defvar gnus-newsgroup-charset nil)
1275 (defvar gnus-newsgroup-ephemeral-charset nil)
1276 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1278 (defvar gnus-article-before-search nil)
1280 (defconst gnus-summary-local-variables
1281 '(gnus-newsgroup-name
1282 gnus-newsgroup-begin gnus-newsgroup-end
1283 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1284 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1285 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1286 gnus-newsgroup-unselected gnus-newsgroup-marked
1287 gnus-newsgroup-reads gnus-newsgroup-saved
1288 gnus-newsgroup-replied gnus-newsgroup-forwarded
1289 gnus-newsgroup-recent
1290 gnus-newsgroup-expirable
1291 gnus-newsgroup-processable gnus-newsgroup-killed
1292 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1293 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1294 gnus-newsgroup-seen gnus-newsgroup-articles
1295 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1296 gnus-newsgroup-headers gnus-newsgroup-threads
1297 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1298 gnus-current-article gnus-current-headers gnus-have-all-headers
1299 gnus-last-article gnus-article-internal-prepare-hook
1300 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1301 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1302 gnus-thread-expunge-below
1303 gnus-score-alist gnus-current-score-file
1304 (gnus-summary-expunge-below . global)
1305 (gnus-summary-mark-below . global)
1306 (gnus-orphan-score . global)
1307 gnus-newsgroup-active gnus-scores-exclude-files
1308 gnus-newsgroup-history gnus-newsgroup-ancient
1309 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1310 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1311 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1312 (gnus-newsgroup-expunged-tally . 0)
1313 gnus-cache-removable-articles gnus-newsgroup-cached
1314 gnus-newsgroup-data gnus-newsgroup-data-reverse
1315 gnus-newsgroup-limit gnus-newsgroup-limits
1316 gnus-newsgroup-charset gnus-newsgroup-display
1317 gnus-newsgroup-incorporated)
1318 "Variables that are buffer-local to the summary buffers.")
1320 (defvar gnus-newsgroup-variables nil
1321 "Variables that have separate values in the newsgroups.")
1323 ;; Byte-compiler warning.
1324 (eval-when-compile (defvar gnus-article-mode-map))
1326 ;; Subject simplification.
1328 (defun gnus-simplify-whitespace (str)
1329 "Remove excessive whitespace from STR."
1332 (while (string-match "[ \t][ \t]+" mystr)
1333 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1335 (substring mystr (match-end 0)))))
1337 (when (string-match "^[ \t]+" mystr)
1338 (setq mystr (substring mystr (match-end 0))))
1340 (when (string-match "[ \t]+$" mystr)
1341 (setq mystr (substring mystr 0 (match-beginning 0))))
1344 (defsubst gnus-simplify-subject-re (subject)
1345 "Remove \"Re:\" from subject lines."
1346 (if (string-match message-subject-re-regexp subject)
1347 (substring subject (match-end 0))
1350 (defun gnus-simplify-subject (subject &optional re-only)
1351 "Remove `Re:' and words in parentheses.
1352 If RE-ONLY is non-nil, strip leading `Re:'s only."
1353 (let ((case-fold-search t)) ;Ignore case.
1354 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1355 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1356 (setq subject (substring subject (match-end 0))))
1357 ;; Remove uninteresting prefixes.
1358 (when (and (not re-only)
1359 gnus-simplify-ignored-prefixes
1360 (string-match gnus-simplify-ignored-prefixes subject))
1361 (setq subject (substring subject (match-end 0))))
1362 ;; Remove words in parentheses from end.
1364 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1365 (setq subject (substring subject 0 (match-beginning 0)))))
1366 ;; Return subject string.
1369 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1371 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1372 (goto-char (point-min))
1373 (while (re-search-forward regexp nil t)
1374 (replace-match (or newtext ""))))
1376 (defun gnus-simplify-buffer-fuzzy ()
1377 "Simplify string in the buffer fuzzily.
1378 The string in the accessible portion of the current buffer is simplified.
1379 It is assumed to be a single-line subject.
1380 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1381 matter is removed. Additional things can be deleted by setting
1382 `gnus-simplify-subject-fuzzy-regexp'."
1383 (let ((case-fold-search t)
1385 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1387 (while (not (eq modified-tick (buffer-modified-tick)))
1388 (setq modified-tick (buffer-modified-tick))
1390 ((listp gnus-simplify-subject-fuzzy-regexp)
1391 (mapcar 'gnus-simplify-buffer-fuzzy-step
1392 gnus-simplify-subject-fuzzy-regexp))
1393 (gnus-simplify-subject-fuzzy-regexp
1394 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1395 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1396 (gnus-simplify-buffer-fuzzy-step
1397 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1398 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1400 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1401 (gnus-simplify-buffer-fuzzy-step " +" " ")
1402 (gnus-simplify-buffer-fuzzy-step " $")
1403 (gnus-simplify-buffer-fuzzy-step "^ +")))
1405 (defun gnus-simplify-subject-fuzzy (subject)
1406 "Simplify a subject string fuzzily.
1407 See `gnus-simplify-buffer-fuzzy' for details."
1409 (gnus-set-work-buffer)
1410 (let ((case-fold-search t))
1411 ;; Remove uninteresting prefixes.
1412 (when (and gnus-simplify-ignored-prefixes
1413 (string-match gnus-simplify-ignored-prefixes subject))
1414 (setq subject (substring subject (match-end 0))))
1416 (inline (gnus-simplify-buffer-fuzzy))
1419 (defsubst gnus-simplify-subject-fully (subject)
1420 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1422 (gnus-simplify-subject-functions
1423 (gnus-map-function gnus-simplify-subject-functions subject))
1424 ((null gnus-summary-gather-subject-limit)
1425 (gnus-simplify-subject-re subject))
1426 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1427 (gnus-simplify-subject-fuzzy subject))
1428 ((numberp gnus-summary-gather-subject-limit)
1429 (gnus-limit-string (gnus-simplify-subject-re subject)
1430 gnus-summary-gather-subject-limit))
1434 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1435 "Check whether two subjects are equal.
1436 If optional argument simple-first is t, first argument is already
1439 ((null simple-first)
1440 (equal (gnus-simplify-subject-fully s1)
1441 (gnus-simplify-subject-fully s2)))
1444 (gnus-simplify-subject-fully s2)))))
1446 (defun gnus-summary-bubble-group ()
1447 "Increase the score of the current group.
1448 This is a handy function to add to `gnus-summary-exit-hook' to
1449 increase the score of each group you read."
1450 (gnus-group-add-score gnus-newsgroup-name))
1454 ;;; Gnus summary mode
1457 (put 'gnus-summary-mode 'mode-class 'special)
1459 (defvar gnus-article-commands-menu)
1462 ;; Non-orthogonal keys
1464 (gnus-define-keys gnus-summary-mode-map
1465 " " gnus-summary-next-page
1466 "\177" gnus-summary-prev-page
1467 [delete] gnus-summary-prev-page
1468 [backspace] gnus-summary-prev-page
1469 "\r" gnus-summary-scroll-up
1470 "\M-\r" gnus-summary-scroll-down
1471 "n" gnus-summary-next-unread-article
1472 "p" gnus-summary-prev-unread-article
1473 "N" gnus-summary-next-article
1474 "P" gnus-summary-prev-article
1475 "\M-\C-n" gnus-summary-next-same-subject
1476 "\M-\C-p" gnus-summary-prev-same-subject
1477 "\M-n" gnus-summary-next-unread-subject
1478 "\M-p" gnus-summary-prev-unread-subject
1479 "." gnus-summary-first-unread-article
1480 "," gnus-summary-best-unread-article
1481 "\M-s" gnus-summary-search-article-forward
1482 "\M-r" gnus-summary-search-article-backward
1483 "<" gnus-summary-beginning-of-article
1484 ">" gnus-summary-end-of-article
1485 "j" gnus-summary-goto-article
1486 "^" gnus-summary-refer-parent-article
1487 "\M-^" gnus-summary-refer-article
1488 "u" gnus-summary-tick-article-forward
1489 "!" gnus-summary-tick-article-forward
1490 "U" gnus-summary-tick-article-backward
1491 "d" gnus-summary-mark-as-read-forward
1492 "D" gnus-summary-mark-as-read-backward
1493 "E" gnus-summary-mark-as-expirable
1494 "\M-u" gnus-summary-clear-mark-forward
1495 "\M-U" gnus-summary-clear-mark-backward
1496 "k" gnus-summary-kill-same-subject-and-select
1497 "\C-k" gnus-summary-kill-same-subject
1498 "\M-\C-k" gnus-summary-kill-thread
1499 "\M-\C-l" gnus-summary-lower-thread
1500 "e" gnus-summary-edit-article
1501 "#" gnus-summary-mark-as-processable
1502 "\M-#" gnus-summary-unmark-as-processable
1503 "\M-\C-t" gnus-summary-toggle-threads
1504 "\M-\C-s" gnus-summary-show-thread
1505 "\M-\C-h" gnus-summary-hide-thread
1506 "\M-\C-f" gnus-summary-next-thread
1507 "\M-\C-b" gnus-summary-prev-thread
1508 [(meta down)] gnus-summary-next-thread
1509 [(meta up)] gnus-summary-prev-thread
1510 "\M-\C-u" gnus-summary-up-thread
1511 "\M-\C-d" gnus-summary-down-thread
1512 "&" gnus-summary-execute-command
1513 "c" gnus-summary-catchup-and-exit
1514 "\C-w" gnus-summary-mark-region-as-read
1515 "\C-t" gnus-summary-toggle-truncation
1516 "?" gnus-summary-mark-as-dormant
1517 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1518 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1519 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1520 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1521 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1522 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1523 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1524 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1525 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1526 "=" gnus-summary-expand-window
1527 "\C-x\C-s" gnus-summary-reselect-current-group
1528 "\M-g" gnus-summary-rescan-group
1529 "w" gnus-summary-stop-page-breaking
1530 "\C-c\C-r" gnus-summary-caesar-message
1531 "\M-t" gnus-summary-toggle-mime
1532 "f" gnus-summary-followup
1533 "F" gnus-summary-followup-with-original
1534 "C" gnus-summary-cancel-article
1535 "r" gnus-summary-reply
1536 "R" gnus-summary-reply-with-original
1537 "\C-c\C-f" gnus-summary-mail-forward
1538 "o" gnus-summary-save-article
1539 "\C-o" gnus-summary-save-article-mail
1540 "|" gnus-summary-pipe-output
1541 "\M-k" gnus-summary-edit-local-kill
1542 "\M-K" gnus-summary-edit-global-kill
1544 "\C-c\C-d" gnus-summary-describe-group
1545 "q" gnus-summary-exit
1546 "Q" gnus-summary-exit-no-update
1547 "\C-c\C-i" gnus-info-find-node
1548 gnus-mouse-2 gnus-mouse-pick-article
1549 "m" gnus-summary-mail-other-window
1550 "a" gnus-summary-post-news
1551 "x" gnus-summary-limit-to-unread
1552 "s" gnus-summary-isearch-article
1553 "t" gnus-article-toggle-headers
1554 "g" gnus-summary-show-article
1555 "l" gnus-summary-goto-last-article
1556 "v" gnus-summary-preview-mime-message
1557 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1558 "\C-d" gnus-summary-enter-digest-group
1559 "\M-\C-d" gnus-summary-read-document
1560 "\M-\C-e" gnus-summary-edit-parameters
1561 "\M-\C-a" gnus-summary-customize-parameters
1563 "*" gnus-cache-enter-article
1564 "\M-*" gnus-cache-remove-article
1565 "\M-&" gnus-summary-universal-argument
1566 "\C-l" gnus-recenter
1567 "I" gnus-summary-increase-score
1568 "L" gnus-summary-lower-score
1569 "\M-i" gnus-symbolic-argument
1570 "h" gnus-summary-select-article-buffer
1572 "V" gnus-summary-score-map
1573 "X" gnus-uu-extract-map
1574 "S" gnus-summary-send-map)
1576 ;; Sort of orthogonal keymap
1577 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1578 "t" gnus-summary-tick-article-forward
1579 "!" gnus-summary-tick-article-forward
1580 "d" gnus-summary-mark-as-read-forward
1581 "r" gnus-summary-mark-as-read-forward
1582 "c" gnus-summary-clear-mark-forward
1583 " " gnus-summary-clear-mark-forward
1584 "e" gnus-summary-mark-as-expirable
1585 "x" gnus-summary-mark-as-expirable
1586 "?" gnus-summary-mark-as-dormant
1587 "b" gnus-summary-set-bookmark
1588 "B" gnus-summary-remove-bookmark
1589 "#" gnus-summary-mark-as-processable
1590 "\M-#" gnus-summary-unmark-as-processable
1591 "S" gnus-summary-limit-include-expunged
1592 "C" gnus-summary-catchup
1593 "H" gnus-summary-catchup-to-here
1594 "h" gnus-summary-catchup-from-here
1595 "\C-c" gnus-summary-catchup-all
1596 "k" gnus-summary-kill-same-subject-and-select
1597 "K" gnus-summary-kill-same-subject
1598 "P" gnus-uu-mark-map)
1600 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1601 "c" gnus-summary-clear-above
1602 "u" gnus-summary-tick-above
1603 "m" gnus-summary-mark-above
1604 "k" gnus-summary-kill-below)
1606 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1607 "/" gnus-summary-limit-to-subject
1608 "n" gnus-summary-limit-to-articles
1609 "w" gnus-summary-pop-limit
1610 "s" gnus-summary-limit-to-subject
1611 "a" gnus-summary-limit-to-author
1612 "u" gnus-summary-limit-to-unread
1613 "m" gnus-summary-limit-to-marks
1614 "M" gnus-summary-limit-exclude-marks
1615 "v" gnus-summary-limit-to-score
1616 "*" gnus-summary-limit-include-cached
1617 "D" gnus-summary-limit-include-dormant
1618 "T" gnus-summary-limit-include-thread
1619 "d" gnus-summary-limit-exclude-dormant
1620 "t" gnus-summary-limit-to-age
1621 "x" gnus-summary-limit-to-extra
1622 "p" gnus-summary-limit-to-display-predicate
1623 "E" gnus-summary-limit-include-expunged
1624 "c" gnus-summary-limit-exclude-childless-dormant
1625 "C" gnus-summary-limit-mark-excluded-as-read
1626 "o" gnus-summary-insert-old-articles
1627 "N" gnus-summary-insert-new-articles)
1629 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1630 "n" gnus-summary-next-unread-article
1631 "p" gnus-summary-prev-unread-article
1632 "N" gnus-summary-next-article
1633 "P" gnus-summary-prev-article
1634 "\C-n" gnus-summary-next-same-subject
1635 "\C-p" gnus-summary-prev-same-subject
1636 "\M-n" gnus-summary-next-unread-subject
1637 "\M-p" gnus-summary-prev-unread-subject
1638 "f" gnus-summary-first-unread-article
1639 "b" gnus-summary-best-unread-article
1640 "j" gnus-summary-goto-article
1641 "g" gnus-summary-goto-subject
1642 "l" gnus-summary-goto-last-article
1643 "o" gnus-summary-pop-article)
1645 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1646 "k" gnus-summary-kill-thread
1647 "l" gnus-summary-lower-thread
1648 "i" gnus-summary-raise-thread
1649 "T" gnus-summary-toggle-threads
1650 "t" gnus-summary-rethread-current
1651 "^" gnus-summary-reparent-thread
1652 "s" gnus-summary-show-thread
1653 "S" gnus-summary-show-all-threads
1654 "h" gnus-summary-hide-thread
1655 "H" gnus-summary-hide-all-threads
1656 "n" gnus-summary-next-thread
1657 "p" gnus-summary-prev-thread
1658 "u" gnus-summary-up-thread
1659 "o" gnus-summary-top-thread
1660 "d" gnus-summary-down-thread
1661 "#" gnus-uu-mark-thread
1662 "\M-#" gnus-uu-unmark-thread)
1664 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1665 "g" gnus-summary-prepare
1666 "c" gnus-summary-insert-cached-articles)
1668 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1669 "c" gnus-summary-catchup-and-exit
1670 "C" gnus-summary-catchup-all-and-exit
1671 "E" gnus-summary-exit-no-update
1672 "J" gnus-summary-jump-to-other-group
1673 "Q" gnus-summary-exit
1674 "Z" gnus-summary-exit
1675 "n" gnus-summary-catchup-and-goto-next-group
1676 "R" gnus-summary-reselect-current-group
1677 "G" gnus-summary-rescan-group
1678 "N" gnus-summary-next-group
1679 "s" gnus-summary-save-newsrc
1680 "P" gnus-summary-prev-group)
1682 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1683 " " gnus-summary-next-page
1684 "n" gnus-summary-next-page
1685 "\177" gnus-summary-prev-page
1686 [delete] gnus-summary-prev-page
1687 "p" gnus-summary-prev-page
1688 "\r" gnus-summary-scroll-up
1689 "\M-\r" gnus-summary-scroll-down
1690 "<" gnus-summary-beginning-of-article
1691 ">" gnus-summary-end-of-article
1692 "b" gnus-summary-beginning-of-article
1693 "e" gnus-summary-end-of-article
1694 "^" gnus-summary-refer-parent-article
1695 "r" gnus-summary-refer-parent-article
1696 "D" gnus-summary-enter-digest-group
1697 "R" gnus-summary-refer-references
1698 "T" gnus-summary-refer-thread
1699 "g" gnus-summary-show-article
1700 "s" gnus-summary-isearch-article
1701 "P" gnus-summary-print-article
1702 "M" gnus-mailing-list-insinuate
1703 "t" gnus-article-babel)
1705 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1706 "b" gnus-article-add-buttons
1707 "B" gnus-article-add-buttons-to-head
1708 "o" gnus-article-treat-overstrike
1709 "e" gnus-article-emphasize
1710 "w" gnus-article-fill-cited-article
1711 "Q" gnus-article-fill-long-lines
1712 "C" gnus-article-capitalize-sentences
1713 "c" gnus-article-remove-cr
1714 "Z" gnus-article-decode-HZ
1715 "f" gnus-article-display-x-face
1716 "l" gnus-summary-stop-page-breaking
1717 "r" gnus-summary-caesar-message
1718 "t" gnus-article-toggle-headers
1719 "v" gnus-summary-verbose-headers
1720 "m" gnus-summary-toggle-mime
1721 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1722 "p" gnus-article-verify-x-pgp-sig
1723 "d" gnus-article-treat-dumbquotes
1724 "s" gnus-smiley-display)
1726 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1727 "a" gnus-article-hide
1728 "h" gnus-article-toggle-headers
1729 "b" gnus-article-hide-boring-headers
1730 "s" gnus-article-hide-signature
1731 "c" gnus-article-hide-citation
1732 "C" gnus-article-hide-citation-in-followups
1733 "l" gnus-article-hide-list-identifiers
1734 "p" gnus-article-hide-pgp
1735 "B" gnus-article-strip-banner
1736 "P" gnus-article-hide-pem
1737 "\C-c" gnus-article-hide-citation-maybe)
1739 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1740 "a" gnus-article-highlight
1741 "h" gnus-article-highlight-headers
1742 "c" gnus-article-highlight-citation
1743 "s" gnus-article-highlight-signature)
1745 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1746 "z" gnus-article-date-ut
1747 "u" gnus-article-date-ut
1748 "l" gnus-article-date-local
1749 "p" gnus-article-date-english
1750 "e" gnus-article-date-lapsed
1751 "o" gnus-article-date-original
1752 "i" gnus-article-date-iso8601
1753 "s" gnus-article-date-user)
1755 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1756 "t" gnus-article-remove-trailing-blank-lines
1757 "l" gnus-article-strip-leading-blank-lines
1758 "m" gnus-article-strip-multiple-blank-lines
1759 "a" gnus-article-strip-blank-lines
1760 "A" gnus-article-strip-all-blank-lines
1761 "s" gnus-article-strip-leading-space
1762 "e" gnus-article-strip-trailing-space
1763 "w" gnus-article-remove-leading-whitespace)
1765 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1767 "f" gnus-summary-fetch-faq
1768 "d" gnus-summary-describe-group
1769 "h" gnus-summary-describe-briefly
1770 "i" gnus-info-find-node)
1772 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1773 "e" gnus-summary-expire-articles
1774 "\M-\C-e" gnus-summary-expire-articles-now
1775 "\177" gnus-summary-delete-article
1776 [delete] gnus-summary-delete-article
1777 [backspace] gnus-summary-delete-article
1778 "m" gnus-summary-move-article
1779 "r" gnus-summary-respool-article
1780 "w" gnus-summary-edit-article
1781 "c" gnus-summary-copy-article
1782 "B" gnus-summary-crosspost-article
1783 "q" gnus-summary-respool-query
1784 "t" gnus-summary-respool-trace
1785 "i" gnus-summary-import-article
1786 "I" gnus-summary-create-article
1787 "p" gnus-summary-article-posted-p)
1789 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1790 "o" gnus-summary-save-article
1791 "m" gnus-summary-save-article-mail
1792 "F" gnus-summary-write-article-file
1793 "r" gnus-summary-save-article-rmail
1794 "f" gnus-summary-save-article-file
1795 "b" gnus-summary-save-article-body-file
1796 "h" gnus-summary-save-article-folder
1797 "v" gnus-summary-save-article-vm
1798 "p" gnus-summary-pipe-output
1799 "s" gnus-soup-add-article)
1801 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1802 "b" gnus-summary-display-buttonized
1803 "m" gnus-summary-repair-multipart
1804 "v" gnus-article-view-part
1805 "o" gnus-article-save-part
1806 "c" gnus-article-copy-part
1807 "C" gnus-article-view-part-as-charset
1808 "e" gnus-article-externalize-part
1809 "E" gnus-article-encrypt-body
1810 "i" gnus-article-inline-part
1811 "|" gnus-article-pipe-part))
1813 (defvar gnus-article-post-menu nil)
1815 (defun gnus-summary-make-menu-bar ()
1816 (gnus-turn-off-edit-menu 'summary)
1818 (unless (boundp 'gnus-summary-misc-menu)
1821 gnus-summary-kill-menu gnus-summary-mode-map ""
1826 ["Customize" gnus-score-customize t])
1827 (gnus-make-score-map 'increase)
1828 (gnus-make-score-map 'lower)
1830 ["Kill below" gnus-summary-kill-below t]
1831 ["Mark above" gnus-summary-mark-above t]
1832 ["Tick above" gnus-summary-tick-above t]
1833 ["Clear above" gnus-summary-clear-above t])
1834 ["Current score" gnus-summary-current-score t]
1835 ["Set score" gnus-summary-set-score t]
1836 ["Switch current score file..." gnus-score-change-score-file t]
1837 ["Set mark below..." gnus-score-set-mark-below t]
1838 ["Set expunge below..." gnus-score-set-expunge-below t]
1839 ["Edit current score file" gnus-score-edit-current-scores t]
1840 ["Edit score file" gnus-score-edit-file t]
1841 ["Trace score" gnus-score-find-trace t]
1842 ["Find words" gnus-score-find-favourite-words t]
1843 ["Rescore buffer" gnus-summary-rescore t]
1844 ["Increase score..." gnus-summary-increase-score t]
1845 ["Lower score..." gnus-summary-lower-score t]))))
1847 ;; Define both the Article menu in the summary buffer and the equivalent
1848 ;; Commands menu in the article buffer here for consistency.
1851 ["All" gnus-article-hide t]
1852 ["Headers" gnus-article-toggle-headers t]
1853 ["Signature" gnus-article-hide-signature t]
1854 ["Citation" gnus-article-hide-citation t]
1855 ["List identifiers" gnus-article-hide-list-identifiers t]
1856 ["PGP" gnus-article-hide-pgp t]
1857 ["Banner" gnus-article-strip-banner t]
1858 ["Boring headers" gnus-article-hide-boring-headers t])
1860 ["All" gnus-article-highlight t]
1861 ["Headers" gnus-article-highlight-headers t]
1862 ["Signature" gnus-article-highlight-signature t]
1863 ["Citation" gnus-article-highlight-citation t])
1865 ["Local" gnus-article-date-local t]
1866 ["ISO8601" gnus-article-date-iso8601 t]
1867 ["UT" gnus-article-date-ut t]
1868 ["Original" gnus-article-date-original t]
1869 ["Lapsed" gnus-article-date-lapsed t]
1870 ["User-defined" gnus-article-date-user t])
1873 ["Leading" gnus-article-strip-leading-blank-lines t]
1874 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1875 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1876 ["All of the above" gnus-article-strip-blank-lines t]
1877 ["All" gnus-article-strip-all-blank-lines t]
1878 ["Leading space" gnus-article-strip-leading-space t]
1879 ["Trailing space" gnus-article-strip-trailing-space t]
1880 ["Leading space in headers"
1881 gnus-article-remove-leading-whitespace t])
1882 ["Overstrike" gnus-article-treat-overstrike t]
1883 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1884 ["Emphasis" gnus-article-emphasize t]
1885 ["Word wrap" gnus-article-fill-cited-article t]
1886 ["Fill long lines" gnus-article-fill-long-lines t]
1887 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1888 ["CR" gnus-article-remove-cr t]
1889 ["Show X-Face" gnus-article-display-x-face t]
1890 ["Rot 13" gnus-summary-caesar-message
1891 ,@(if (featurep 'xemacs) '(t)
1892 '(:help "\"Caesar rotate\" article by 13"))]
1893 ["Unix pipe" gnus-summary-pipe-message t]
1894 ["Add buttons" gnus-article-add-buttons t]
1895 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1896 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1897 ["Toggle MIME" gnus-summary-toggle-mime t]
1898 ["Verbose header" gnus-summary-verbose-headers t]
1899 ["Toggle header" gnus-summary-toggle-header t]
1900 ["Toggle smileys" gnus-smiley-display t]
1901 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1902 ["HZ" gnus-article-decode-HZ t])
1904 ["Save in default format" gnus-summary-save-article
1905 ,@(if (featurep 'xemacs) '(t)
1906 '(:help "Save article using default method"))]
1907 ["Save in file" gnus-summary-save-article-file
1908 ,@(if (featurep 'xemacs) '(t)
1909 '(:help "Save article in file"))]
1910 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1911 ["Save in MH folder" gnus-summary-save-article-folder t]
1912 ["Save in VM folder" gnus-summary-save-article-vm t]
1913 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1914 ["Save body in file" gnus-summary-save-article-body-file t]
1915 ["Pipe through a filter" gnus-summary-pipe-output t]
1916 ["Add to SOUP packet" gnus-soup-add-article t]
1917 ["Print" gnus-summary-print-article t])
1919 ["Respool article..." gnus-summary-respool-article t]
1920 ["Move article..." gnus-summary-move-article
1921 (gnus-check-backend-function
1922 'request-move-article gnus-newsgroup-name)]
1923 ["Copy article..." gnus-summary-copy-article t]
1924 ["Crosspost article..." gnus-summary-crosspost-article
1925 (gnus-check-backend-function
1926 'request-replace-article gnus-newsgroup-name)]
1927 ["Import file..." gnus-summary-import-article t]
1928 ["Create article..." gnus-summary-create-article t]
1929 ["Check if posted" gnus-summary-article-posted-p t]
1930 ["Edit article" gnus-summary-edit-article
1931 (not (gnus-group-read-only-p))]
1932 ["Delete article" gnus-summary-delete-article
1933 (gnus-check-backend-function
1934 'request-expire-articles gnus-newsgroup-name)]
1935 ["Query respool" gnus-summary-respool-query t]
1936 ["Trace respool" gnus-summary-respool-trace t]
1937 ["Delete expirable articles" gnus-summary-expire-articles-now
1938 (gnus-check-backend-function
1939 'request-expire-articles gnus-newsgroup-name)])
1941 ["Uudecode" gnus-uu-decode-uu
1942 ,@(if (featurep 'xemacs) '(t)
1943 '(:help "Decode uuencoded article(s)"))]
1944 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1945 ["Unshar" gnus-uu-decode-unshar t]
1946 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1947 ["Save" gnus-uu-decode-save t]
1948 ["Binhex" gnus-uu-decode-binhex t]
1949 ["Postscript" gnus-uu-decode-postscript t])
1951 ["Enter article" gnus-cache-enter-article t]
1952 ["Remove article" gnus-cache-remove-article t])
1953 ["Translate" gnus-article-babel t]
1954 ["Select article buffer" gnus-summary-select-article-buffer t]
1955 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1956 ["Isearch article..." gnus-summary-isearch-article t]
1957 ["Beginning of the article" gnus-summary-beginning-of-article t]
1958 ["End of the article" gnus-summary-end-of-article t]
1959 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1960 ["Fetch referenced articles" gnus-summary-refer-references t]
1961 ["Fetch current thread" gnus-summary-refer-thread t]
1962 ["Fetch article with id..." gnus-summary-refer-article t]
1963 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1964 ["Redisplay" gnus-summary-show-article t]
1965 ["Raw article" gnus-summary-show-raw-article t])))
1967 gnus-summary-article-menu gnus-summary-mode-map ""
1968 (cons "Article" innards))
1970 (if (not (keymapp gnus-summary-article-menu))
1972 gnus-article-commands-menu gnus-article-mode-map ""
1973 (cons "Commands" innards))
1974 ;; in Emacs, don't share menu.
1975 (setq gnus-article-commands-menu
1976 (copy-keymap gnus-summary-article-menu))
1977 (define-key gnus-article-mode-map [menu-bar commands]
1978 (cons "Commands" gnus-article-commands-menu))))
1981 gnus-summary-thread-menu gnus-summary-mode-map ""
1983 ["Toggle threading" gnus-summary-toggle-threads t]
1984 ["Hide threads" gnus-summary-hide-all-threads t]
1985 ["Show threads" gnus-summary-show-all-threads t]
1986 ["Hide thread" gnus-summary-hide-thread t]
1987 ["Show thread" gnus-summary-show-thread t]
1988 ["Go to next thread" gnus-summary-next-thread t]
1989 ["Go to previous thread" gnus-summary-prev-thread t]
1990 ["Go down thread" gnus-summary-down-thread t]
1991 ["Go up thread" gnus-summary-up-thread t]
1992 ["Top of thread" gnus-summary-top-thread t]
1993 ["Mark thread as read" gnus-summary-kill-thread t]
1994 ["Lower thread score" gnus-summary-lower-thread t]
1995 ["Raise thread score" gnus-summary-raise-thread t]
1996 ["Rethread current" gnus-summary-rethread-current t]))
1999 gnus-summary-post-menu gnus-summary-mode-map ""
2001 ["Post an article" gnus-summary-post-news
2002 ,@(if (featurep 'xemacs) '(t)
2003 '(:help "Post an article"))]
2004 ["Followup" gnus-summary-followup
2005 ,@(if (featurep 'xemacs) '(t)
2006 '(:help "Post followup to this article"))]
2007 ["Followup and yank" gnus-summary-followup-with-original
2008 ,@(if (featurep 'xemacs) '(t)
2009 '(:help "Post followup to this article, quoting its contents"))]
2010 ["Supersede article" gnus-summary-supersede-article t]
2011 ["Cancel article" gnus-summary-cancel-article
2012 ,@(if (featurep 'xemacs) '(t)
2013 '(:help "Cancel an article you posted"))]
2014 ["Reply" gnus-summary-reply t]
2015 ["Reply and yank" gnus-summary-reply-with-original t]
2016 ["Wide reply" gnus-summary-wide-reply t]
2017 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2018 ,@(if (featurep 'xemacs) '(t)
2019 '(:help "Mail a reply, quoting this article"))]
2020 ["Mail forward" gnus-summary-mail-forward t]
2021 ["Post forward" gnus-summary-post-forward t]
2022 ["Digest and mail" gnus-summary-digest-mail-forward t]
2023 ["Digest and post" gnus-summary-digest-post-forward t]
2024 ["Resend message" gnus-summary-resend-message t]
2025 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2026 ["Send a mail" gnus-summary-mail-other-window t]
2027 ["Uuencode and post" gnus-uu-post-news
2028 ,@(if (featurep 'xemacs) '(t)
2029 '(:help "Post a uuencoded article"))]
2030 ["Followup via news" gnus-summary-followup-to-mail t]
2031 ["Followup via news and yank"
2032 gnus-summary-followup-to-mail-with-original t]
2034 ;;["Send" gnus-summary-send-draft t]
2035 ;;["Send bounced" gnus-resend-bounced-mail t])
2039 ((not (keymapp gnus-summary-post-menu))
2040 (setq gnus-article-post-menu gnus-summary-post-menu))
2041 ((not gnus-article-post-menu)
2042 ;; Don't share post menu.
2043 (setq gnus-article-post-menu
2044 (copy-keymap gnus-summary-post-menu))))
2045 (define-key gnus-article-mode-map [menu-bar post]
2046 (cons "Post" gnus-article-post-menu))
2049 gnus-summary-misc-menu gnus-summary-mode-map ""
2052 ["Mark as read" gnus-summary-mark-as-read-forward t]
2053 ["Mark same subject and select"
2054 gnus-summary-kill-same-subject-and-select t]
2055 ["Mark same subject" gnus-summary-kill-same-subject t]
2056 ["Catchup" gnus-summary-catchup
2057 ,@(if (featurep 'xemacs) '(t)
2058 '(:help "Mark unread articles in this group as read"))]
2059 ["Catchup all" gnus-summary-catchup-all t]
2060 ["Catchup to here" gnus-summary-catchup-to-here t]
2061 ["Catchup from here" gnus-summary-catchup-from-here t]
2062 ["Catchup region" gnus-summary-mark-region-as-read t]
2063 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2065 ["Tick" gnus-summary-tick-article-forward t]
2066 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2067 ["Remove marks" gnus-summary-clear-mark-forward t]
2068 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2069 ["Set bookmark" gnus-summary-set-bookmark t]
2070 ["Remove bookmark" gnus-summary-remove-bookmark t])
2072 ["Marks..." gnus-summary-limit-to-marks t]
2073 ["Subject..." gnus-summary-limit-to-subject t]
2074 ["Author..." gnus-summary-limit-to-author t]
2075 ["Age..." gnus-summary-limit-to-age t]
2076 ["Extra..." gnus-summary-limit-to-extra t]
2077 ["Score" gnus-summary-limit-to-score t]
2078 ["Score" gnus-summary-limit-to-display-predicate t]
2079 ["Unread" gnus-summary-limit-to-unread t]
2080 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2081 ["Articles" gnus-summary-limit-to-articles t]
2082 ["Pop limit" gnus-summary-pop-limit t]
2083 ["Show dormant" gnus-summary-limit-include-dormant t]
2084 ["Hide childless dormant"
2085 gnus-summary-limit-exclude-childless-dormant t]
2086 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2087 ["Hide marked" gnus-summary-limit-exclude-marks t]
2088 ["Show expunged" gnus-summary-limit-include-expunged t])
2090 ["Set mark" gnus-summary-mark-as-processable t]
2091 ["Remove mark" gnus-summary-unmark-as-processable t]
2092 ["Remove all marks" gnus-summary-unmark-all-processable t]
2093 ["Mark above" gnus-uu-mark-over t]
2094 ["Mark series" gnus-uu-mark-series t]
2095 ["Mark region" gnus-uu-mark-region t]
2096 ["Unmark region" gnus-uu-unmark-region t]
2097 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2098 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2099 ["Mark all" gnus-uu-mark-all t]
2100 ["Mark buffer" gnus-uu-mark-buffer t]
2101 ["Mark sparse" gnus-uu-mark-sparse t]
2102 ["Mark thread" gnus-uu-mark-thread t]
2103 ["Unmark thread" gnus-uu-unmark-thread t]
2104 ("Process Mark Sets"
2105 ["Kill" gnus-summary-kill-process-mark t]
2106 ["Yank" gnus-summary-yank-process-mark
2107 gnus-newsgroup-process-stack]
2108 ["Save" gnus-summary-save-process-mark t]))
2110 ["Page forward" gnus-summary-next-page
2111 ,@(if (featurep 'xemacs) '(t)
2112 '(:help "Show next page of article"))]
2113 ["Page backward" gnus-summary-prev-page
2114 ,@(if (featurep 'xemacs) '(t)
2115 '(:help "Show previous page of article"))]
2116 ["Line forward" gnus-summary-scroll-up t])
2118 ["Next unread article" gnus-summary-next-unread-article t]
2119 ["Previous unread article" gnus-summary-prev-unread-article t]
2120 ["Next article" gnus-summary-next-article t]
2121 ["Previous article" gnus-summary-prev-article t]
2122 ["Next unread subject" gnus-summary-next-unread-subject t]
2123 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2124 ["Next article same subject" gnus-summary-next-same-subject t]
2125 ["Previous article same subject" gnus-summary-prev-same-subject t]
2126 ["First unread article" gnus-summary-first-unread-article t]
2127 ["Best unread article" gnus-summary-best-unread-article t]
2128 ["Go to subject number..." gnus-summary-goto-subject t]
2129 ["Go to article number..." gnus-summary-goto-article t]
2130 ["Go to the last article" gnus-summary-goto-last-article t]
2131 ["Pop article off history" gnus-summary-pop-article t])
2133 ["Sort by number" gnus-summary-sort-by-number t]
2134 ["Sort by author" gnus-summary-sort-by-author t]
2135 ["Sort by subject" gnus-summary-sort-by-subject t]
2136 ["Sort by date" gnus-summary-sort-by-date t]
2137 ["Sort by score" gnus-summary-sort-by-score t]
2138 ["Sort by lines" gnus-summary-sort-by-lines t]
2139 ["Sort by characters" gnus-summary-sort-by-chars t]
2140 ["Original sort" gnus-summary-sort-by-original t])
2142 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2143 ["Describe group" gnus-summary-describe-group t]
2144 ["Read manual" gnus-info-find-node t])
2146 ["Pick and read" gnus-pick-mode t]
2147 ["Binary" gnus-binary-mode t])
2149 ["Regenerate" gnus-summary-prepare t]
2150 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2151 ["Toggle threading" gnus-summary-toggle-threads t])
2152 ["See old articles" gnus-summary-insert-old-articles t]
2153 ["See new articles" gnus-summary-insert-new-articles t]
2154 ["Filter articles..." gnus-summary-execute-command t]
2155 ["Run command on subjects..." gnus-summary-universal-argument t]
2156 ["Search articles forward..." gnus-summary-search-article-forward t]
2157 ["Search articles backward..." gnus-summary-search-article-backward t]
2158 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2159 ["Expand window" gnus-summary-expand-window t]
2160 ["Expire expirable articles" gnus-summary-expire-articles
2161 (gnus-check-backend-function
2162 'request-expire-articles gnus-newsgroup-name)]
2163 ["Edit local kill file" gnus-summary-edit-local-kill t]
2164 ["Edit main kill file" gnus-summary-edit-global-kill t]
2165 ["Edit group parameters" gnus-summary-edit-parameters t]
2166 ["Customize group parameters" gnus-summary-customize-parameters t]
2167 ["Send a bug report" gnus-bug t]
2169 ["Catchup and exit" gnus-summary-catchup-and-exit
2170 ,@(if (featurep 'xemacs) '(t)
2171 '(:help "Mark unread articles in this group as read, then exit"))]
2172 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2173 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2174 ["Exit group" gnus-summary-exit
2175 ,@(if (featurep 'xemacs) '(t)
2176 '(:help "Exit current group, return to group selection mode"))]
2177 ["Exit group without updating" gnus-summary-exit-no-update t]
2178 ["Exit and goto next group" gnus-summary-next-group t]
2179 ["Exit and goto prev group" gnus-summary-prev-group t]
2180 ["Reselect group" gnus-summary-reselect-current-group t]
2181 ["Rescan group" gnus-summary-rescan-group t]
2182 ["Update dribble" gnus-summary-save-newsrc t])))
2184 (gnus-run-hooks 'gnus-summary-menu-hook)))
2186 (defvar gnus-summary-tool-bar-map nil)
2188 ;; Emacs 21 tool bar. Should be no-op otherwise.
2189 (defun gnus-summary-make-tool-bar ()
2190 (if (and (fboundp 'tool-bar-add-item-from-menu)
2191 (default-value 'tool-bar-mode)
2192 (not gnus-summary-tool-bar-map))
2193 (setq gnus-summary-tool-bar-map
2194 (let ((tool-bar-map (make-sparse-keymap))
2195 (load-path (mm-image-load-path)))
2196 (tool-bar-add-item-from-menu
2197 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2198 (tool-bar-add-item-from-menu
2199 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2200 (tool-bar-add-item-from-menu
2201 'gnus-summary-post-news "post" gnus-summary-mode-map)
2202 (tool-bar-add-item-from-menu
2203 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2204 (tool-bar-add-item-from-menu
2205 'gnus-summary-followup "followup" gnus-summary-mode-map)
2206 (tool-bar-add-item-from-menu
2207 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2208 (tool-bar-add-item-from-menu
2209 'gnus-summary-reply "reply" gnus-summary-mode-map)
2210 (tool-bar-add-item-from-menu
2211 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2212 (tool-bar-add-item-from-menu
2213 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2214 (tool-bar-add-item-from-menu
2215 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2216 (tool-bar-add-item-from-menu
2217 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2218 (tool-bar-add-item-from-menu
2219 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2220 (tool-bar-add-item-from-menu
2221 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2222 (tool-bar-add-item-from-menu
2223 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2224 (tool-bar-add-item-from-menu
2225 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2227 (if gnus-summary-tool-bar-map
2228 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2230 (defun gnus-score-set-default (var value)
2231 "A version of set that updates the GNU Emacs menu-bar."
2233 ;; It is the message that forces the active status to be updated.
2236 (defun gnus-make-score-map (type)
2237 "Make a summary score map of type TYPE."
2240 (let ((headers '(("author" "from" string)
2241 ("subject" "subject" string)
2242 ("article body" "body" string)
2243 ("article head" "head" string)
2244 ("xref" "xref" string)
2245 ("extra header" "extra" string)
2246 ("lines" "lines" number)
2247 ("followups to author" "followup" string)))
2248 (types '((number ("less than" <)
2251 (string ("substring" s)
2255 (perms '(("temporary" (current-time-string))
2263 (if (eq type 'lower)
2268 (setq header (car headers))
2274 (let ((ts (cdr (assoc (nth 2 header) types)))
2290 'gnus-summary-score-entry
2292 (if (or (string= (nth 1 header)
2294 (string= (nth 1 header)
2297 (list 'gnus-summary-header
2299 (list 'quote (nth 1 (car ts)))
2300 (list 'gnus-score-delta-default
2307 (list (nreverse outp))))
2310 (list (nreverse outt))))
2312 (setq headers (cdr headers)))
2313 (list (nreverse outh))))))))
2317 (defun gnus-summary-mode (&optional group)
2318 "Major mode for reading articles.
2320 All normal editing commands are switched off.
2321 \\<gnus-summary-mode-map>
2322 Each line in this buffer represents one article. To read an
2323 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2324 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2327 You can also post articles and send mail from this buffer. To
2328 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2329 of an article, type `\\[gnus-summary-reply]'.
2331 There are approx. one gazillion commands you can execute in this
2332 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2334 The following commands are available:
2336 \\{gnus-summary-mode-map}"
2338 (kill-all-local-variables)
2339 (when (gnus-visual-p 'summary-menu 'menu)
2340 (gnus-summary-make-menu-bar)
2341 (gnus-summary-make-tool-bar))
2342 (gnus-summary-make-local-variables)
2343 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2344 (gnus-summary-make-local-variables))
2345 (gnus-make-thread-indent-array)
2346 (gnus-simplify-mode-line)
2347 (setq major-mode 'gnus-summary-mode)
2348 (setq mode-name "Summary")
2349 (make-local-variable 'minor-mode-alist)
2350 (use-local-map gnus-summary-mode-map)
2351 (buffer-disable-undo)
2352 (setq buffer-read-only t) ;Disable modification
2353 (setq truncate-lines t)
2354 (setq selective-display t)
2355 (setq selective-display-ellipses t) ;Display `...'
2356 (gnus-summary-set-display-table)
2357 (gnus-set-default-directory)
2358 (setq gnus-newsgroup-name group)
2359 (unless (gnus-news-group-p group)
2360 (setq gnus-newsgroup-incorporated
2361 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2362 (make-local-variable 'gnus-summary-line-format)
2363 (make-local-variable 'gnus-summary-line-format-spec)
2364 (make-local-variable 'gnus-summary-dummy-line-format)
2365 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2366 (make-local-variable 'gnus-summary-mark-positions)
2367 (make-local-hook 'pre-command-hook)
2368 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2369 (gnus-run-hooks 'gnus-summary-mode-hook)
2370 (turn-on-gnus-mailing-list-mode)
2371 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2372 (gnus-update-summary-mark-positions))
2374 (defun gnus-summary-make-local-variables ()
2375 "Make all the local summary buffer variables."
2377 (dolist (local gnus-summary-local-variables)
2380 (if (eq (cdr local) 'global)
2381 ;; Copy the global value of the variable.
2382 (setq global (symbol-value (car local)))
2383 ;; Use the value from the list.
2384 (setq global (eval (cdr local))))
2385 (set (make-local-variable (car local)) global))
2386 ;; Simple nil-valued local variable.
2387 (set (make-local-variable local) nil)))))
2389 (defun gnus-summary-clear-local-variables ()
2390 (let ((locals gnus-summary-local-variables))
2392 (if (consp (car locals))
2393 (and (vectorp (caar locals))
2394 (set (caar locals) nil))
2395 (and (vectorp (car locals))
2396 (set (car locals) nil)))
2397 (setq locals (cdr locals)))))
2399 ;; Summary data functions.
2401 (defmacro gnus-data-number (data)
2404 (defmacro gnus-data-set-number (data number)
2405 `(setcar ,data ,number))
2407 (defmacro gnus-data-mark (data)
2410 (defmacro gnus-data-set-mark (data mark)
2411 `(setcar (nthcdr 1 ,data) ,mark))
2413 (defmacro gnus-data-pos (data)
2416 (defmacro gnus-data-set-pos (data pos)
2417 `(setcar (nthcdr 2 ,data) ,pos))
2419 (defmacro gnus-data-header (data)
2422 (defmacro gnus-data-set-header (data header)
2423 `(setcar (nthcdr 3 ,data) ,header))
2425 (defmacro gnus-data-level (data)
2428 (defmacro gnus-data-unread-p (data)
2429 `(= (nth 1 ,data) gnus-unread-mark))
2431 (defmacro gnus-data-read-p (data)
2432 `(/= (nth 1 ,data) gnus-unread-mark))
2434 (defmacro gnus-data-pseudo-p (data)
2435 `(consp (nth 3 ,data)))
2437 (defmacro gnus-data-find (number)
2438 `(assq ,number gnus-newsgroup-data))
2440 (defmacro gnus-data-find-list (number &optional data)
2441 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2442 (memq (assq ,number bdata)
2445 (defmacro gnus-data-make (number mark pos header level)
2446 `(list ,number ,mark ,pos ,header ,level))
2448 (defun gnus-data-enter (after-article number mark pos header level offset)
2449 (let ((data (gnus-data-find-list after-article)))
2451 (error "No such article: %d" after-article))
2452 (setcdr data (cons (gnus-data-make number mark pos header level)
2454 (setq gnus-newsgroup-data-reverse nil)
2455 (gnus-data-update-list (cddr data) offset)))
2457 (defun gnus-data-enter-list (after-article list &optional offset)
2459 (let ((data (and after-article (gnus-data-find-list after-article)))
2463 (let ((odata gnus-newsgroup-data))
2464 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2466 (gnus-data-update-list odata offset)))
2467 ;; Find the last element in the list to be spliced into the main
2470 (setq list (cdr list)))
2473 (setcdr list gnus-newsgroup-data)
2474 (setq gnus-newsgroup-data ilist)
2476 (gnus-data-update-list (cdr list) offset)))
2477 (setcdr list (cdr data))
2480 (gnus-data-update-list (cdr list) offset))))
2481 (setq gnus-newsgroup-data-reverse nil))))
2483 (defun gnus-data-remove (article &optional offset)
2484 (let ((data gnus-newsgroup-data))
2485 (if (= (gnus-data-number (car data)) article)
2487 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2488 gnus-newsgroup-data-reverse nil)
2490 (gnus-data-update-list gnus-newsgroup-data offset)))
2492 (when (= (gnus-data-number (cadr data)) article)
2493 (setcdr data (cddr data))
2495 (gnus-data-update-list (cdr data) offset))
2497 gnus-newsgroup-data-reverse nil))
2498 (setq data (cdr data))))))
2500 (defmacro gnus-data-list (backward)
2502 (or gnus-newsgroup-data-reverse
2503 (setq gnus-newsgroup-data-reverse
2504 (reverse gnus-newsgroup-data)))
2505 gnus-newsgroup-data))
2507 (defun gnus-data-update-list (data offset)
2508 "Add OFFSET to the POS of all data entries in DATA."
2509 (setq gnus-newsgroup-data-reverse nil)
2511 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2512 (setq data (cdr data))))
2514 (defun gnus-summary-article-pseudo-p (article)
2515 "Say whether this article is a pseudo article or not."
2516 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2518 (defmacro gnus-summary-article-sparse-p (article)
2519 "Say whether this article is a sparse article or not."
2520 `(memq ,article gnus-newsgroup-sparse))
2522 (defmacro gnus-summary-article-ancient-p (article)
2523 "Say whether this article is a sparse article or not."
2524 `(memq ,article gnus-newsgroup-ancient))
2526 (defun gnus-article-parent-p (number)
2527 "Say whether this article is a parent or not."
2528 (let ((data (gnus-data-find-list number)))
2529 (and (cdr data) ; There has to be an article after...
2530 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2531 (gnus-data-level (nth 1 data))))))
2533 (defun gnus-article-children (number)
2534 "Return a list of all children to NUMBER."
2535 (let* ((data (gnus-data-find-list number))
2536 (level (gnus-data-level (car data)))
2538 (setq data (cdr data))
2540 (= (gnus-data-level (car data)) (1+ level)))
2541 (push (gnus-data-number (car data)) children)
2542 (setq data (cdr data)))
2545 (defmacro gnus-summary-skip-intangible ()
2546 "If the current article is intangible, then jump to a different article."
2547 '(let ((to (get-text-property (point) 'gnus-intangible)))
2548 (and to (gnus-summary-goto-subject to))))
2550 (defmacro gnus-summary-article-intangible-p ()
2551 "Say whether this article is intangible or not."
2552 '(get-text-property (point) 'gnus-intangible))
2554 (defun gnus-article-read-p (article)
2555 "Say whether ARTICLE is read or not."
2556 (not (or (memq article gnus-newsgroup-marked)
2557 (memq article gnus-newsgroup-unreads)
2558 (memq article gnus-newsgroup-unselected)
2559 (memq article gnus-newsgroup-dormant))))
2561 ;; Some summary mode macros.
2563 (defmacro gnus-summary-article-number ()
2564 "The article number of the article on the current line.
2565 If there isn's an article number here, then we return the current
2568 (gnus-summary-skip-intangible)
2569 (or (get-text-property (point) 'gnus-number)
2570 (gnus-summary-last-subject))))
2572 (defmacro gnus-summary-article-header (&optional number)
2573 "Return the header of article NUMBER."
2574 `(gnus-data-header (gnus-data-find
2575 ,(or number '(gnus-summary-article-number)))))
2577 (defmacro gnus-summary-thread-level (&optional number)
2578 "Return the level of thread that starts with article NUMBER."
2579 `(if (and (eq gnus-summary-make-false-root 'dummy)
2580 (get-text-property (point) 'gnus-intangible))
2582 (gnus-data-level (gnus-data-find
2583 ,(or number '(gnus-summary-article-number))))))
2585 (defmacro gnus-summary-article-mark (&optional number)
2586 "Return the mark of article NUMBER."
2587 `(gnus-data-mark (gnus-data-find
2588 ,(or number '(gnus-summary-article-number)))))
2590 (defmacro gnus-summary-article-pos (&optional number)
2591 "Return the position of the line of article NUMBER."
2592 `(gnus-data-pos (gnus-data-find
2593 ,(or number '(gnus-summary-article-number)))))
2595 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2596 (defmacro gnus-summary-article-subject (&optional number)
2597 "Return current subject string or nil if nothing."
2600 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2601 '(gnus-data-header (assq (gnus-summary-article-number)
2602 gnus-newsgroup-data)))))
2605 (mail-header-subject headers))))
2607 (defmacro gnus-summary-article-score (&optional number)
2608 "Return current article score."
2609 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2610 gnus-newsgroup-scored))
2611 gnus-summary-default-score 0))
2613 (defun gnus-summary-article-children (&optional number)
2614 "Return a list of article numbers that are children of article NUMBER."
2615 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2616 (level (gnus-data-level (car data)))
2618 (while (and (setq data (cdr data))
2619 (> (setq l (gnus-data-level (car data))) level))
2620 (and (= (1+ level) l)
2621 (push (gnus-data-number (car data))
2623 (nreverse children)))
2625 (defun gnus-summary-article-parent (&optional number)
2626 "Return the article number of the parent of article NUMBER."
2627 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2628 (gnus-data-list t)))
2629 (level (gnus-data-level (car data))))
2631 () ; This is a root.
2632 ;; We search until we find an article with a level less than
2633 ;; this one. That function has to be the parent.
2634 (while (and (setq data (cdr data))
2635 (not (< (gnus-data-level (car data)) level))))
2636 (and data (gnus-data-number (car data))))))
2638 (defun gnus-unread-mark-p (mark)
2639 "Say whether MARK is the unread mark."
2640 (= mark gnus-unread-mark))
2642 (defun gnus-read-mark-p (mark)
2643 "Say whether MARK is one of the marks that mark as read.
2644 This is all marks except unread, ticked, dormant, and expirable."
2645 (not (or (= mark gnus-unread-mark)
2646 (= mark gnus-ticked-mark)
2647 (= mark gnus-dormant-mark)
2648 (= mark gnus-expirable-mark))))
2650 (defmacro gnus-article-mark (number)
2651 "Return the MARK of article NUMBER.
2652 This macro should only be used when computing the mark the \"first\"
2653 time; i.e., when generating the summary lines. After that,
2654 `gnus-summary-article-mark' should be used to examine the
2657 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2658 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2659 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2660 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2661 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2662 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2663 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2664 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2665 gnus-ancient-mark))))
2667 ;; Saving hidden threads.
2669 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2670 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2672 (defmacro gnus-save-hidden-threads (&rest forms)
2673 "Save hidden threads, eval FORMS, and restore the hidden threads."
2674 (let ((config (make-symbol "config")))
2675 `(let ((,config (gnus-hidden-threads-configuration)))
2679 (gnus-restore-hidden-threads-configuration ,config)))))
2681 (defun gnus-data-compute-positions ()
2682 "Compute the positions of all articles."
2683 (setq gnus-newsgroup-data-reverse nil)
2684 (let ((data gnus-newsgroup-data))
2686 (gnus-save-hidden-threads
2687 (gnus-summary-show-all-threads)
2688 (goto-char (point-min))
2690 (while (get-text-property (point) 'gnus-intangible)
2692 (gnus-data-set-pos (car data) (+ (point) 3))
2693 (setq data (cdr data))
2694 (forward-line 1))))))
2696 (defun gnus-hidden-threads-configuration ()
2697 "Return the current hidden threads configuration."
2700 (goto-char (point-min))
2701 (while (search-forward "\r" nil t)
2702 (push (1- (point)) config))
2705 (defun gnus-restore-hidden-threads-configuration (config)
2706 "Restore hidden threads configuration from CONFIG."
2708 (let (point buffer-read-only)
2709 (while (setq point (pop config))
2710 (when (and (< point (point-max))
2712 (eq (char-after) ?\n))
2713 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2715 ;; Various summary mode internalish functions.
2717 (defun gnus-mouse-pick-article (e)
2720 (gnus-summary-next-page nil t))
2722 (defun gnus-summary-set-display-table ()
2723 "Change the display table.
2724 Odd characters have a tendency to mess
2725 up nicely formatted displays - we make all possible glyphs
2726 display only a single character."
2728 ;; We start from the standard display table, if any.
2729 (let ((table (or (copy-sequence standard-display-table)
2730 (make-display-table)))
2732 ;; Nix out all the control chars...
2733 (while (>= (setq i (1- i)) 0)
2734 (aset table i [??]))
2735 ;; ... but not newline and cr, of course. (cr is necessary for the
2736 ;; selective display).
2737 (aset table ?\n nil)
2738 (aset table ?\r nil)
2739 ;; We keep TAB as well.
2740 (aset table ?\t nil)
2741 ;; We nix out any glyphs over 126 that are not set already.
2743 (while (>= (setq i (1- i)) 127)
2744 ;; Only modify if the entry is nil.
2745 (unless (aref table i)
2746 (aset table i [??]))))
2747 (setq buffer-display-table table)))
2749 (defun gnus-summary-set-article-display-arrow (pos)
2750 "Update the overlay arrow to point to line at position POS."
2751 (when (and gnus-summary-display-arrow
2752 (boundp 'overlay-arrow-position)
2753 (boundp 'overlay-arrow-string))
2757 (unless overlay-arrow-position
2758 (setq overlay-arrow-position (make-marker)))
2759 (setq overlay-arrow-string "=>"
2760 overlay-arrow-position (set-marker overlay-arrow-position
2762 (current-buffer))))))
2764 (defun gnus-summary-buffer-name (group)
2765 "Return the summary buffer name of GROUP."
2766 (concat "*Summary " group "*"))
2768 (defun gnus-summary-setup-buffer (group)
2769 "Initialize summary buffer."
2770 (let ((buffer (gnus-summary-buffer-name group)))
2771 (if (get-buffer buffer)
2774 (setq gnus-summary-buffer (current-buffer))
2775 (not gnus-newsgroup-prepared))
2776 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2777 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2778 (gnus-summary-mode group)
2780 (gnus-carpal-setup-buffer 'summary))
2781 (unless gnus-single-article-buffer
2782 (make-local-variable 'gnus-article-buffer)
2783 (make-local-variable 'gnus-article-current)
2784 (make-local-variable 'gnus-original-article-buffer))
2785 (setq gnus-newsgroup-name group)
2786 ;; Set any local variables in the group parameters.
2787 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2790 (defun gnus-set-global-variables ()
2791 "Set the global equivalents of the buffer-local variables.
2792 They are set to the latest values they had. These reflect the summary
2793 buffer that was in action when the last article was fetched."
2794 (when (eq major-mode 'gnus-summary-mode)
2795 (setq gnus-summary-buffer (current-buffer))
2796 (let ((name gnus-newsgroup-name)
2797 (marked gnus-newsgroup-marked)
2798 (unread gnus-newsgroup-unreads)
2799 (headers gnus-current-headers)
2800 (data gnus-newsgroup-data)
2801 (summary gnus-summary-buffer)
2802 (article-buffer gnus-article-buffer)
2803 (original gnus-original-article-buffer)
2804 (gac gnus-article-current)
2805 (reffed gnus-reffed-article-number)
2806 (score-file gnus-current-score-file)
2807 (default-charset gnus-newsgroup-charset)
2809 (let ((locals gnus-newsgroup-variables))
2811 (if (consp (car locals))
2812 (push (eval (caar locals)) vlist)
2813 (push (eval (car locals)) vlist))
2814 (setq locals (cdr locals)))
2815 (setq vlist (nreverse vlist)))
2817 (set-buffer gnus-group-buffer)
2818 (setq gnus-newsgroup-name name
2819 gnus-newsgroup-marked marked
2820 gnus-newsgroup-unreads unread
2821 gnus-current-headers headers
2822 gnus-newsgroup-data data
2823 gnus-article-current gac
2824 gnus-summary-buffer summary
2825 gnus-article-buffer article-buffer
2826 gnus-original-article-buffer original
2827 gnus-reffed-article-number reffed
2828 gnus-current-score-file score-file
2829 gnus-newsgroup-charset default-charset)
2830 (let ((locals gnus-newsgroup-variables))
2832 (if (consp (car locals))
2833 (set (caar locals) (pop vlist))
2834 (set (car locals) (pop vlist)))
2835 (setq locals (cdr locals))))
2836 ;; The article buffer also has local variables.
2837 (when (gnus-buffer-live-p gnus-article-buffer)
2838 (set-buffer gnus-article-buffer)
2839 (setq gnus-summary-buffer summary))))))
2841 (defun gnus-summary-article-unread-p (article)
2842 "Say whether ARTICLE is unread or not."
2843 (memq article gnus-newsgroup-unreads))
2845 (defun gnus-summary-first-article-p (&optional article)
2846 "Return whether ARTICLE is the first article in the buffer."
2847 (if (not (setq article (or article (gnus-summary-article-number))))
2849 (eq article (caar gnus-newsgroup-data))))
2851 (defun gnus-summary-last-article-p (&optional article)
2852 "Return whether ARTICLE is the last article in the buffer."
2853 (if (not (setq article (or article (gnus-summary-article-number))))
2854 ;; All non-existent numbers are the last article. :-)
2856 (not (cdr (gnus-data-find-list article)))))
2858 (defun gnus-make-thread-indent-array ()
2860 (unless (and gnus-thread-indent-array
2861 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2862 (setq gnus-thread-indent-array (make-vector 201 "")
2863 gnus-thread-indent-array-level gnus-thread-indent-level)
2865 (aset gnus-thread-indent-array n
2866 (make-string (* n gnus-thread-indent-level) ? ))
2869 (defun gnus-update-summary-mark-positions ()
2870 "Compute where the summary marks are to go."
2872 (when (gnus-buffer-exists-p gnus-summary-buffer)
2873 (set-buffer gnus-summary-buffer))
2874 (let ((gnus-replied-mark 129)
2875 (gnus-score-below-mark 130)
2876 (gnus-score-over-mark 130)
2877 (gnus-download-mark 131)
2878 (spec gnus-summary-line-format-spec)
2881 (gnus-set-work-buffer)
2882 (let ((gnus-summary-line-format-spec spec)
2883 (gnus-newsgroup-downloadable '((0 . t))))
2884 (gnus-summary-insert-line
2885 (make-full-mail-header 0 "" "nobody"
2886 "05 Apr 2001 23:33:09 +0400"
2888 0 nil 128 t nil "" nil 1)
2889 (goto-char (point-min))
2890 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2892 (goto-char (point-min))
2893 (push (cons 'replied (and (search-forward "\201" nil t)
2896 (goto-char (point-min))
2897 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2899 (goto-char (point-min))
2900 (push (cons 'download
2901 (and (search-forward "\203" nil t) (- (point) 2)))
2903 (setq gnus-summary-mark-positions pos))))
2905 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2906 "Insert a dummy root in the summary buffer."
2908 (gnus-add-text-properties
2909 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2910 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2912 (defun gnus-summary-from-or-to-or-newsgroups (header)
2913 (let ((to (cdr (assq 'To (mail-header-extra header))))
2914 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2915 (default-mime-charset (with-current-buffer gnus-summary-buffer
2916 default-mime-charset)))
2919 gnus-ignored-from-addresses
2920 (string-match gnus-ignored-from-addresses
2921 (mail-header-from header)))
2923 (or (car (funcall gnus-extract-address-components
2925 gnus-decode-encoded-word-function to)))
2926 (funcall gnus-decode-encoded-word-function to))))
2928 gnus-ignored-from-addresses
2929 (string-match gnus-ignored-from-addresses
2930 (mail-header-from header)))
2931 (concat "=> " newsgroups))
2933 (or (car (funcall gnus-extract-address-components
2934 (mail-header-from header)))
2935 (mail-header-from header))))))
2937 (defun gnus-summary-insert-line (gnus-tmp-header
2938 gnus-tmp-level gnus-tmp-current
2939 gnus-tmp-unread gnus-tmp-replied
2940 gnus-tmp-expirable gnus-tmp-subject-or-nil
2941 &optional gnus-tmp-dummy gnus-tmp-score
2943 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2944 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2945 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2946 (gnus-tmp-score-char
2947 (if (or (null gnus-summary-default-score)
2948 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2949 gnus-summary-zcore-fuzz))
2951 (if (< gnus-tmp-score gnus-summary-default-score)
2952 gnus-score-below-mark gnus-score-over-mark)))
2954 (cond (gnus-tmp-process gnus-process-mark)
2955 ((memq gnus-tmp-current gnus-newsgroup-cached)
2957 (gnus-tmp-replied gnus-replied-mark)
2958 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
2959 gnus-forwarded-mark)
2960 ((memq gnus-tmp-current gnus-newsgroup-saved)
2962 ((memq number gnus-newsgroup-recent)
2964 ((memq number gnus-newsgroup-unseen)
2967 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2970 ((string-match "<[^>]+> *$" gnus-tmp-from)
2971 (let ((beg (match-beginning 0)))
2972 (or (and (string-match "^\".+\"" gnus-tmp-from)
2973 (substring gnus-tmp-from 1 (1- (match-end 0))))
2974 (substring gnus-tmp-from 0 beg))))
2975 ((string-match "(.+)" gnus-tmp-from)
2976 (substring gnus-tmp-from
2977 (1+ (match-beginning 0)) (1- (match-end 0))))
2979 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2980 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2981 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2982 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2983 (buffer-read-only nil))
2984 (when (string= gnus-tmp-name "")
2985 (setq gnus-tmp-name gnus-tmp-from))
2986 (unless (numberp gnus-tmp-lines)
2987 (setq gnus-tmp-lines -1))
2988 (if (= gnus-tmp-lines -1)
2989 (setq gnus-tmp-lines "?")
2990 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
2991 (gnus-put-text-property-excluding-characters-with-faces
2993 (progn (eval gnus-summary-line-format-spec) (point))
2994 'gnus-number gnus-tmp-number)
2995 (when (gnus-visual-p 'summary-highlight 'highlight)
2997 (gnus-run-hooks 'gnus-summary-update-hook)
3000 (defun gnus-summary-update-line (&optional dont-update)
3001 "Update summary line after change."
3002 (when (and gnus-summary-default-score
3003 (not gnus-summary-inhibit-highlight))
3004 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3005 (article (gnus-summary-article-number))
3006 (score (gnus-summary-article-score article)))
3008 (if (and gnus-summary-mark-below
3009 (< (gnus-summary-article-score)
3010 gnus-summary-mark-below))
3011 ;; This article has a low score, so we mark it as read.
3012 (when (memq article gnus-newsgroup-unreads)
3013 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3014 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3015 ;; This article was previously marked as read on account
3016 ;; of a low score, but now it has risen, so we mark it as
3018 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3019 (gnus-summary-update-mark
3020 (if (or (null gnus-summary-default-score)
3021 (<= (abs (- score gnus-summary-default-score))
3022 gnus-summary-zcore-fuzz))
3024 (if (< score gnus-summary-default-score)
3025 gnus-score-below-mark gnus-score-over-mark))
3027 ;; Do visual highlighting.
3028 (when (gnus-visual-p 'summary-highlight 'highlight)
3029 (gnus-run-hooks 'gnus-summary-update-hook)))))
3031 (defvar gnus-tmp-new-adopts nil)
3033 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3034 "Return the number of articles in THREAD.
3035 This may be 0 in some cases -- if none of the articles in
3036 the thread are to be displayed."
3038 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3040 ((not (listp thread))
3042 ((and (consp thread) (cdr thread))
3045 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3048 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3051 (when (and level (zerop level) gnus-tmp-new-adopts)
3054 'gnus-summary-number-of-articles-in-thread
3055 gnus-tmp-new-adopts))))
3057 (if (> number 1) gnus-not-empty-thread-mark
3058 gnus-empty-thread-mark)
3061 (defun gnus-summary-set-local-parameters (group)
3062 "Go through the local params of GROUP and set all variable specs in that list."
3063 (let ((params (gnus-group-find-parameter group))
3064 (vars '(quit-config)) ; Ignore quit-config.
3067 (setq elem (car params)
3068 params (cdr params))
3069 (and (consp elem) ; Has to be a cons.
3070 (consp (cdr elem)) ; The cdr has to be a list.
3071 (symbolp (car elem)) ; Has to be a symbol in there.
3072 (not (memq (car elem) vars))
3073 (ignore-errors ; So we set it.
3074 (push (car elem) vars)
3075 (make-local-variable (car elem))
3076 (set (car elem) (eval (nth 1 elem))))))))
3078 (defun gnus-summary-read-group (group &optional show-all no-article
3079 kill-buffer no-display backward
3081 "Start reading news in newsgroup GROUP.
3082 If SHOW-ALL is non-nil, already read articles are also listed.
3083 If NO-ARTICLE is non-nil, no article is selected initially.
3084 If NO-DISPLAY, don't generate a summary buffer."
3088 (let ((gnus-auto-select-next nil))
3089 (or (gnus-summary-read-group-1
3090 group show-all no-article
3091 kill-buffer no-display
3094 select-articles nil)))))
3095 (eq gnus-auto-select-next 'quietly))
3096 (set-buffer gnus-group-buffer)
3097 ;; The entry function called above goes to the next
3098 ;; group automatically, so we go two groups back
3099 ;; if we are searching for the previous group.
3101 (gnus-group-prev-unread-group 2))
3102 (if (not (equal group (gnus-group-group-name)))
3103 (setq group (gnus-group-group-name))
3107 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3108 "Directly jump to the other GROUP from summary buffer.
3109 If SHOW-ALL is non-nil, already read articles are also listed."
3111 (if (eq gnus-summary-buffer (current-buffer))
3112 (list (completing-read
3113 "Group: " gnus-active-hashtb nil t
3114 (when (and gnus-newsgroup-name
3115 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3116 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3117 'gnus-group-history)
3119 (error "%s must be invoked from a gnus summary buffer." this-command)))
3120 (unless (or (zerop (length group))
3121 (and gnus-newsgroup-name
3122 (string-equal gnus-newsgroup-name group)))
3124 (gnus-summary-read-group group show-all
3125 gnus-dont-select-after-jump-to-other-group)))
3127 (defun gnus-summary-read-group-1 (group show-all no-article
3128 kill-buffer no-display
3129 &optional select-articles)
3130 ;; Killed foreign groups can't be entered.
3131 ;; (when (and (not (gnus-group-native-p group))
3132 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3133 ;; (error "Dead non-native groups can't be entered"))
3134 (gnus-message 5 "Retrieving newsgroup: %s..."
3135 (gnus-group-decoded-name group))
3136 (let* ((new-group (gnus-summary-setup-buffer group))
3137 (quit-config (gnus-group-quit-config group))
3138 (did-select (and new-group (gnus-select-newsgroup
3139 group show-all select-articles))))
3141 ;; This summary buffer exists already, so we just select it.
3143 (gnus-set-global-variables)
3145 (gnus-kill-or-deaden-summary kill-buffer))
3146 (gnus-configure-windows 'summary 'force)
3147 (gnus-set-mode-line 'summary)
3148 (gnus-summary-position-point)
3151 ;; We couldn't select this group.
3153 (when (and (eq major-mode 'gnus-summary-mode)
3154 (not (equal (current-buffer) kill-buffer)))
3155 (kill-buffer (current-buffer))
3156 (if (not quit-config)
3158 ;; Update the info -- marks might need to be removed,
3160 (gnus-summary-update-info)
3161 (set-buffer gnus-group-buffer)
3162 (gnus-group-jump-to-group group)
3163 (gnus-group-next-unread-group 1))
3164 (gnus-handle-ephemeral-exit quit-config)))
3165 (let ((grpinfo (gnus-get-info group)))
3166 (if (null (gnus-info-read grpinfo))
3167 (gnus-message 3 "Group %s contains no messages"
3168 (gnus-group-decoded-name group))
3169 (gnus-message 3 "Can't select group")))
3171 ;; The user did a `C-g' while prompting for number of articles,
3172 ;; so we exit this group.
3173 ((eq did-select 'quit)
3174 (and (eq major-mode 'gnus-summary-mode)
3175 (not (equal (current-buffer) kill-buffer))
3176 (kill-buffer (current-buffer)))
3178 (gnus-kill-or-deaden-summary kill-buffer))
3179 (if (not quit-config)
3181 (set-buffer gnus-group-buffer)
3182 (gnus-group-jump-to-group group)
3183 (gnus-group-next-unread-group 1)
3184 (gnus-configure-windows 'group 'force))
3185 (gnus-handle-ephemeral-exit quit-config))
3186 ;; Finally signal the quit.
3188 ;; The group was successfully selected.
3190 (gnus-set-global-variables)
3191 ;; Save the active value in effect when the group was entered.
3192 (setq gnus-newsgroup-active
3194 (gnus-active gnus-newsgroup-name)))
3195 ;; You can change the summary buffer in some way with this hook.
3196 (gnus-run-hooks 'gnus-select-group-hook)
3197 (gnus-update-format-specifications
3198 nil 'summary 'summary-mode 'summary-dummy)
3199 (gnus-update-summary-mark-positions)
3200 ;; Do score processing.
3201 (when gnus-use-scoring
3202 (gnus-possibly-score-headers))
3203 ;; Check whether to fill in the gaps in the threads.
3204 (when gnus-build-sparse-threads
3205 (gnus-build-sparse-threads))
3206 ;; Find the initial limit.
3207 (if gnus-show-threads
3209 (let ((gnus-newsgroup-dormant nil))
3210 (gnus-summary-initial-limit show-all))
3211 (gnus-summary-initial-limit show-all))
3212 ;; When untreaded, all articles are always shown.
3213 (setq gnus-newsgroup-limit
3215 (lambda (header) (mail-header-number header))
3216 gnus-newsgroup-headers)))
3217 ;; Generate the summary buffer.
3219 (gnus-summary-prepare))
3220 (when gnus-use-trees
3221 (gnus-tree-open group)
3222 (setq gnus-summary-highlight-line-function
3223 'gnus-tree-highlight-article))
3224 ;; If the summary buffer is empty, but there are some low-scored
3225 ;; articles or some excluded dormants, we include these in the
3227 (when (and (zerop (buffer-size))
3229 (cond (gnus-newsgroup-dormant
3230 (gnus-summary-limit-include-dormant))
3231 ((and gnus-newsgroup-scored show-all)
3232 (gnus-summary-limit-include-expunged t))))
3233 ;; Function `gnus-apply-kill-file' must be called in this hook.
3234 (gnus-run-hooks 'gnus-apply-kill-hook)
3235 (if (and (zerop (buffer-size))
3238 ;; This newsgroup is empty.
3239 (gnus-summary-catchup-and-exit nil t)
3240 (gnus-message 6 "No unread news")
3242 (gnus-kill-or-deaden-summary kill-buffer))
3243 ;; Return nil from this function.
3245 ;; Hide conversation thread subtrees. We cannot do this in
3246 ;; gnus-summary-prepare-hook since kill processing may not
3247 ;; work with hidden articles.
3248 (and gnus-show-threads
3249 gnus-thread-hide-subtree
3250 (gnus-summary-hide-all-threads))
3252 (gnus-kill-or-deaden-summary kill-buffer))
3253 ;; Show first unread article if requested.
3254 (if (and (not no-article)
3256 gnus-newsgroup-unreads
3257 gnus-auto-select-first)
3259 (gnus-configure-windows 'summary)
3261 ((eq gnus-auto-select-first 'best)
3262 (gnus-summary-best-unread-article))
3263 ((eq gnus-auto-select-first t)
3264 (gnus-summary-first-unread-article))
3265 ((gnus-functionp gnus-auto-select-first)
3266 (funcall gnus-auto-select-first))))
3267 ;; Don't select any articles, just move point to the first
3268 ;; article in the group.
3269 (goto-char (point-min))
3270 (gnus-summary-position-point)
3271 (gnus-configure-windows 'summary 'force)
3272 (gnus-set-mode-line 'summary))
3273 (when (get-buffer-window gnus-group-buffer t)
3274 ;; Gotta use windows, because recenter does weird stuff if
3275 ;; the current buffer ain't the displayed window.
3276 (let ((owin (selected-window)))
3277 (select-window (get-buffer-window gnus-group-buffer t))
3278 (when (gnus-group-goto-group group)
3280 (select-window owin)))
3281 ;; Mark this buffer as "prepared".
3282 (setq gnus-newsgroup-prepared t)
3283 (gnus-run-hooks 'gnus-summary-prepared-hook)
3286 (defun gnus-summary-prepare ()
3287 "Generate the summary buffer."
3289 (let ((buffer-read-only nil))
3291 (setq gnus-newsgroup-data nil
3292 gnus-newsgroup-data-reverse nil)
3293 (gnus-run-hooks 'gnus-summary-generate-hook)
3294 ;; Generate the buffer, either with threads or without.
3295 (when gnus-newsgroup-headers
3296 (gnus-summary-prepare-threads
3297 (if gnus-show-threads
3298 (gnus-sort-gathered-threads
3299 (funcall gnus-summary-thread-gathering-function
3301 (gnus-cut-threads (gnus-make-threads)))))
3302 ;; Unthreaded display.
3303 (gnus-sort-articles gnus-newsgroup-headers))))
3304 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3305 ;; Call hooks for modifying summary buffer.
3306 (goto-char (point-min))
3307 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3309 (defsubst gnus-general-simplify-subject (subject)
3310 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3313 ;; Truncate the subject.
3314 (gnus-simplify-subject-functions
3315 (gnus-map-function gnus-simplify-subject-functions subject))
3316 ((numberp gnus-summary-gather-subject-limit)
3317 (setq subject (gnus-simplify-subject-re subject))
3318 (if (> (length subject) gnus-summary-gather-subject-limit)
3319 (substring subject 0 gnus-summary-gather-subject-limit)
3321 ;; Fuzzily simplify it.
3322 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3323 (gnus-simplify-subject-fuzzy subject))
3324 ;; Just remove the leading "Re:".
3326 (gnus-simplify-subject-re subject))))
3328 (if (and gnus-summary-gather-exclude-subject
3329 (string-match gnus-summary-gather-exclude-subject subject))
3330 nil ; This article shouldn't be gathered
3333 (defun gnus-summary-simplify-subject-query ()
3334 "Query where the respool algorithm would put this article."
3336 (gnus-summary-select-article)
3338 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3340 (defun gnus-gather-threads-by-subject (threads)
3341 "Gather threads by looking at Subject headers."
3342 (if (not gnus-summary-make-false-root)
3344 (let ((hashtb (gnus-make-hashtable 1024))
3347 subject hthread whole-subject)
3349 (setq subject (gnus-general-simplify-subject
3350 (setq whole-subject (mail-header-subject
3353 (if (setq hthread (gnus-gethash subject hashtb))
3355 ;; We enter a dummy root into the thread, if we
3356 ;; haven't done that already.
3357 (unless (stringp (caar hthread))
3358 (setcar hthread (list whole-subject (car hthread))))
3359 ;; We add this new gathered thread to this gathered
3361 (setcdr (car hthread)
3362 (nconc (cdar hthread) (list (car threads))))
3363 ;; Remove it from the list of threads.
3364 (setcdr prev (cdr threads))
3365 (setq threads prev))
3366 ;; Enter this thread into the hash table.
3367 (gnus-sethash subject threads hashtb)))
3369 (setq threads (cdr threads)))
3372 (defun gnus-gather-threads-by-references (threads)
3373 "Gather threads by looking at References headers."
3374 (let ((idhashtb (gnus-make-hashtable 1024))
3375 (thhashtb (gnus-make-hashtable 1024))
3378 ids references id gthread gid entered ref)
3380 (when (setq references (mail-header-references (caar threads)))
3381 (setq id (mail-header-id (caar threads))
3382 ids (gnus-split-references references)
3384 (while (setq ref (pop ids))
3385 (setq ids (delete ref ids))
3386 (if (not (setq gid (gnus-gethash ref idhashtb)))
3388 (gnus-sethash ref id idhashtb)
3389 (gnus-sethash id threads thhashtb))
3390 (setq gthread (gnus-gethash gid thhashtb))
3392 ;; We enter a dummy root into the thread, if we
3393 ;; haven't done that already.
3394 (unless (stringp (caar gthread))
3395 (setcar gthread (list (mail-header-subject (caar gthread))
3397 ;; We add this new gathered thread to this gathered
3399 (setcdr (car gthread)
3400 (nconc (cdar gthread) (list (car threads)))))
3401 ;; Add it into the thread hash table.
3402 (gnus-sethash id gthread thhashtb)
3404 ;; Remove it from the list of threads.
3405 (setcdr prev (cdr threads))
3406 (setq threads prev))))
3408 (setq threads (cdr threads)))
3411 (defun gnus-sort-gathered-threads (threads)
3412 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3413 (let ((result threads))
3415 (when (stringp (caar threads))
3416 (setcdr (car threads)
3417 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3418 (setq threads (cdr threads)))
3421 (defun gnus-thread-loop-p (root thread)
3422 "Say whether ROOT is in THREAD."
3423 (let ((stack (list thread))
3426 (while (setq thread (pop stack))
3427 (setq th (cdr thread))
3429 (not (eq (caar th) root)))
3432 ;; We have found a loop.
3434 (setcdr thread (delq (car th) (cdr thread)))
3435 (if (boundp (setq ref-dep (intern "none"
3436 gnus-newsgroup-dependencies)))
3437 (setcdr (symbol-value ref-dep)
3438 (nconc (cdr (symbol-value ref-dep))
3440 (set ref-dep (list nil (car th))))
3443 ;; Push all the subthreads onto the stack.
3444 (push (cdr thread) stack)))
3447 (defun gnus-make-threads ()
3448 "Go through the dependency hashtb and find the roots. Return all threads."
3450 (while (catch 'infloop
3453 ;; Deal with self-referencing References loops.
3454 (when (and (car (symbol-value refs))
3461 (car (symbol-value refs)) thread))
3462 (cdr (symbol-value refs)))))))
3465 (unless (car (symbol-value refs))
3466 ;; These threads do not refer back to any other articles,
3467 ;; so they're roots.
3468 (setq threads (append (cdr (symbol-value refs)) threads))))
3469 gnus-newsgroup-dependencies)))
3472 ;; Build the thread tree.
3473 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3474 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3476 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3477 if it was already present.
3479 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3480 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3481 Message-IDs will be renamed be renamed to a unique Message-ID before
3484 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3485 (let* ((id (mail-header-id header))
3486 (id-dep (and id (intern id dependencies)))
3487 ref ref-dep ref-header)
3488 ;; Enter this `header' in the `dependencies' table.
3492 ;; The first two cases do the normal part: enter a new `header'
3493 ;; in the `dependencies' table.
3494 ((not (boundp id-dep))
3495 (set id-dep (list header)))
3496 ((null (car (symbol-value id-dep)))
3497 (setcar (symbol-value id-dep) header))
3499 ;; From here the `header' was already present in the
3500 ;; `dependencies' table.
3502 ;; Overrides an existing entry;
3503 ;; just set the header part of the entry.
3504 (setcar (symbol-value id-dep) header))
3506 ;; Renames the existing `header' to a unique Message-ID.
3507 ((not gnus-summary-ignore-duplicates)
3508 ;; An article with this Message-ID has already been seen.
3509 ;; We rename the Message-ID.
3510 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3512 (mail-header-set-id header id))
3514 ;; The last case ignores an existing entry, except it adds any
3515 ;; additional Xrefs (in case the two articles came from different
3517 ;; Also sets `header' to `nil' meaning that the `dependencies'
3518 ;; table was *not* modified.
3520 (mail-header-set-xref
3521 (car (symbol-value id-dep))
3522 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3524 (or (mail-header-xref header) "")))
3528 ;; First check if that we are not creating a References loop.
3529 (setq ref (gnus-parent-id (mail-header-references header)))
3531 (setq ref-dep (intern-soft ref dependencies))
3533 (setq ref-header (car (symbol-value ref-dep))))
3534 (if (string= id ref)
3535 ;; Yuk! This is a reference loop. Make the article be a
3538 (mail-header-set-references (car (symbol-value id-dep)) "none")
3540 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3541 (setq ref (gnus-parent-id (mail-header-references header)))
3542 (setq ref-dep (intern (or ref "none") dependencies))
3543 (if (boundp ref-dep)
3544 (setcdr (symbol-value ref-dep)
3545 (nconc (cdr (symbol-value ref-dep))
3546 (list (symbol-value id-dep))))
3547 (set ref-dep (list nil (symbol-value id-dep)))))
3550 (defun gnus-build-sparse-threads ()
3551 (let ((headers gnus-newsgroup-headers)
3552 (mail-parse-charset gnus-newsgroup-charset)
3553 (gnus-summary-ignore-duplicates t)
3554 header references generation relations
3555 subject child end new-child date)
3556 ;; First we create an alist of generations/relations, where
3557 ;; generations is how much we trust the relation, and the relation
3559 (gnus-message 7 "Making sparse threads...")
3561 (nnheader-set-temp-buffer " *gnus sparse threads*")
3562 (while (setq header (pop headers))
3563 (when (and (setq references (mail-header-references header))
3564 (not (string= references "")))
3566 (setq child (mail-header-id header)
3567 subject (mail-header-subject header)
3568 date (mail-header-date header)
3570 (while (search-backward ">" nil t)
3571 (setq end (1+ (point)))
3572 (when (search-backward "<" nil t)
3573 (setq new-child (buffer-substring (point) end))
3574 (push (list (incf generation)
3575 child (setq child new-child)
3579 (push (list (1+ generation) child nil subject) relations))
3581 (kill-buffer (current-buffer)))
3582 ;; Sort over trustworthiness.
3585 (when (gnus-dependencies-add-header
3586 (make-full-mail-header-from-decoded-header
3587 gnus-reffed-article-number
3588 (nth 3 relation) "" (or (nth 4 relation) "")
3590 (or (nth 2 relation) "") 0 0 "")
3591 gnus-newsgroup-dependencies nil)
3592 (push gnus-reffed-article-number gnus-newsgroup-limit)
3593 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3594 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3595 gnus-newsgroup-reads)
3596 (decf gnus-reffed-article-number)))
3597 (sort relations 'car-less-than-car))
3598 (gnus-message 7 "Making sparse threads...done")))
3600 (defun gnus-build-old-threads ()
3601 ;; Look at all the articles that refer back to old articles, and
3602 ;; fetch the headers for the articles that aren't there. This will
3603 ;; build complete threads - if the roots haven't been expired by the
3605 (let ((mail-parse-charset gnus-newsgroup-charset)
3609 (when (not (car (symbol-value refs)))
3610 (setq heads (cdr (symbol-value refs)))
3612 (if (memq (mail-header-number (caar heads))
3613 gnus-newsgroup-dormant)
3614 (setq heads (cdr heads))
3615 (setq id (symbol-name refs))
3616 (while (and (setq id (gnus-build-get-header id))
3617 (not (car (gnus-id-to-thread id)))))
3618 (setq heads nil)))))
3619 gnus-newsgroup-dependencies)))
3621 ;; This function has to be called with point after the article number
3622 ;; on the beginning of the line.
3623 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3624 (let ((eol (gnus-point-at-eol))
3625 (buffer (current-buffer))
3628 ;; overview: [num subject from date id refs chars lines misc]
3631 (narrow-to-region (point) eol)
3636 (make-full-mail-header
3638 (nnheader-nov-field) ; subject
3639 (nnheader-nov-field) ; from
3640 (nnheader-nov-field) ; date
3641 (nnheader-nov-read-message-id) ; id
3642 (nnheader-nov-field) ; refs
3643 (nnheader-nov-read-integer) ; chars
3644 (nnheader-nov-read-integer) ; lines
3646 (if (looking-at "Xref: ")
3647 (goto-char (match-end 0)))
3648 (nnheader-nov-field)) ; Xref
3649 (nnheader-nov-parse-extra)))) ; extra
3653 (when gnus-alter-header-function
3654 (funcall gnus-alter-header-function header))
3655 (gnus-dependencies-add-header header dependencies force-new)))
3657 (defun gnus-build-get-header (id)
3658 "Look through the buffer of NOV lines and find the header to ID.
3659 Enter this line into the dependencies hash table, and return
3660 the id of the parent article (if any)."
3661 (let ((deps gnus-newsgroup-dependencies)
3665 (set-buffer nntp-server-buffer)
3666 (let ((case-fold-search nil))
3667 (goto-char (point-min))
3668 (while (and (not found)
3669 (search-forward id nil t))
3671 (setq found (looking-at
3672 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3673 (regexp-quote id))))
3674 (or found (beginning-of-line 2)))
3678 (setq header (gnus-nov-parse-line
3679 (read (current-buffer)) deps))
3680 (gnus-parent-id (mail-header-references header))))))
3682 (let ((number (mail-header-number header)))
3683 (push number gnus-newsgroup-limit)
3684 (push header gnus-newsgroup-headers)
3685 (if (memq number gnus-newsgroup-unselected)
3687 (push number gnus-newsgroup-unreads)
3688 (setq gnus-newsgroup-unselected
3689 (delq number gnus-newsgroup-unselected)))
3690 (push number gnus-newsgroup-ancient)))))))
3692 (defun gnus-build-all-threads ()
3693 "Read all the headers."
3694 (let ((gnus-summary-ignore-duplicates t)
3695 (mail-parse-charset gnus-newsgroup-charset)
3696 (dependencies gnus-newsgroup-dependencies)
3699 (set-buffer nntp-server-buffer)
3700 (let ((case-fold-search nil))
3701 (goto-char (point-min))
3704 (setq article (read (current-buffer))
3705 header (gnus-nov-parse-line article dependencies)))
3708 (set-buffer gnus-summary-buffer)
3709 (push header gnus-newsgroup-headers)
3710 (if (memq (setq article (mail-header-number header))
3711 gnus-newsgroup-unselected)
3713 (push article gnus-newsgroup-unreads)
3714 (setq gnus-newsgroup-unselected
3715 (delq article gnus-newsgroup-unselected)))
3716 (push article gnus-newsgroup-ancient)))
3717 (forward-line 1)))))))
3719 (defun gnus-summary-update-article-line (article header)
3720 "Update the line for ARTICLE using HEADERS."
3721 (let* ((id (mail-header-id header))
3722 (thread (gnus-id-to-thread id)))
3724 (error "Article in no thread"))
3725 ;; Update the thread.
3726 (setcar thread header)
3727 (gnus-summary-goto-subject article)
3728 (let* ((datal (gnus-data-find-list article))
3730 (length (when (cdr datal)
3731 (- (gnus-data-pos data)
3732 (gnus-data-pos (cadr datal)))))
3733 (buffer-read-only nil)
3734 (level (gnus-summary-thread-level)))
3736 (gnus-summary-insert-line
3737 header level nil (gnus-article-mark article)
3738 (memq article gnus-newsgroup-replied)
3739 (memq article gnus-newsgroup-expirable)
3740 ;; Only insert the Subject string when it's different
3741 ;; from the previous Subject string.
3746 (mail-header-subject
3749 (gnus-data-find-list
3751 (gnus-data-list t)))))
3752 ;; Error on the side of excessive subjects.
3754 (mail-header-subject header)))
3756 (mail-header-subject header))
3757 nil (cdr (assq article gnus-newsgroup-scored))
3758 (memq article gnus-newsgroup-processable))
3760 (gnus-data-update-list
3761 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3763 (defun gnus-summary-update-article (article &optional iheader)
3764 "Update ARTICLE in the summary buffer."
3765 (set-buffer gnus-summary-buffer)
3766 (let* ((header (gnus-summary-article-header article))
3767 (id (mail-header-id header))
3768 (data (gnus-data-find article))
3769 (thread (gnus-id-to-thread id))
3770 (references (mail-header-references header))
3774 (when (and references
3775 (not (equal "" references)))
3778 (buffer-read-only nil)
3784 (delq thread parent)))
3785 (if (gnus-summary-insert-subject id header)
3786 ;; Set the (possibly) new article number in the data structure.
3787 (gnus-data-set-number data (gnus-id-to-article id))
3791 (defun gnus-rebuild-thread (id &optional line)
3792 "Rebuild the thread containing ID.
3793 If LINE, insert the rebuilt thread starting on line LINE."
3794 (let ((buffer-read-only nil)
3795 old-pos current thread data)
3796 (if (not gnus-show-threads)
3797 (setq thread (list (car (gnus-id-to-thread id))))
3798 ;; Get the thread this article is part of.
3799 (setq thread (gnus-remove-thread id)))
3800 (setq old-pos (gnus-point-at-bol))
3801 (setq current (save-excursion
3802 (and (re-search-backward "[\r\n]" nil t)
3803 (gnus-summary-article-number))))
3804 ;; If this is a gathered thread, we have to go some re-gathering.
3805 (when (stringp (car thread))
3806 (let ((subject (car thread))
3808 (setq thread (cdr thread))
3810 (unless (memq (setq thr (gnus-id-to-thread
3812 (mail-header-id (caar thread)))))
3815 (setq thread (cdr thread)))
3816 ;; We now have all (unique) roots.
3817 (if (= (length roots) 1)
3818 ;; All the loose roots are now one solid root.
3819 (setq thread (car roots))
3820 (setq thread (cons subject (gnus-sort-threads roots))))))
3822 ;; We then insert this thread into the summary buffer.
3824 (goto-char (point-min))
3825 (forward-line (1- line)))
3826 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3827 (if gnus-show-threads
3828 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3829 (gnus-summary-prepare-unthreaded thread))
3830 (setq data (nreverse gnus-newsgroup-data))
3831 (setq threads gnus-newsgroup-threads))
3832 ;; We splice the new data into the data structure.
3833 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3834 ;;!!! then we want to insert at the beginning of the buffer.
3835 ;;!!! That happens to be true with Gnus now, but that may
3836 ;;!!! change in the future. Perhaps.
3837 (gnus-data-enter-list
3838 (if line nil current) data (- (point) old-pos))
3839 (setq gnus-newsgroup-threads
3840 (nconc threads gnus-newsgroup-threads))
3841 (gnus-data-compute-positions))))
3843 (defun gnus-number-to-header (number)
3844 "Return the header for article NUMBER."
3845 (let ((headers gnus-newsgroup-headers))
3847 (not (= number (mail-header-number (car headers)))))
3852 (defun gnus-parent-headers (in-headers &optional generation)
3853 "Return the headers of the GENERATIONeth parent of HEADERS."
3855 (setq generation 1))
3857 (headers in-headers)
3860 (not (zerop generation))
3861 (setq references (mail-header-references headers)))
3862 (setq headers (if (and references
3863 (setq parent (gnus-parent-id references)))
3864 (car (gnus-id-to-thread parent))
3867 (and (not (eq headers in-headers))
3870 (defun gnus-id-to-thread (id)
3871 "Return the (sub-)thread where ID appears."
3872 (gnus-gethash id gnus-newsgroup-dependencies))
3874 (defun gnus-id-to-article (id)
3875 "Return the article number of ID."
3876 (let ((thread (gnus-id-to-thread id)))
3879 (mail-header-number (car thread)))))
3881 (defun gnus-id-to-header (id)
3882 "Return the article headers of ID."
3883 (car (gnus-id-to-thread id)))
3885 (defun gnus-article-displayed-root-p (article)
3886 "Say whether ARTICLE is a root(ish) article."
3887 (let ((level (gnus-summary-thread-level article))
3888 (refs (mail-header-references (gnus-summary-article-header article)))
3894 ((null (gnus-parent-id refs)) t)
3896 (null (setq particle (gnus-id-to-article
3897 (gnus-parent-id refs))))
3898 (null (gnus-summary-thread-level particle)))))))
3900 (defun gnus-root-id (id)
3901 "Return the id of the root of the thread where ID appears."
3903 (while (and id (setq prev (car (gnus-id-to-thread id))))
3905 id (gnus-parent-id (mail-header-references prev))))
3908 (defun gnus-articles-in-thread (thread)
3909 "Return the list of articles in THREAD."
3910 (cons (mail-header-number (car thread))
3911 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3913 (defun gnus-remove-thread (id &optional dont-remove)
3914 "Remove the thread that has ID in it."
3915 (let (headers thread last-id)
3916 ;; First go up in this thread until we find the root.
3917 (setq last-id (gnus-root-id id)
3918 headers (message-flatten-list (gnus-id-to-thread last-id)))
3919 ;; We have now found the real root of this thread. It might have
3920 ;; been gathered into some loose thread, so we have to search
3921 ;; through the threads to find the thread we wanted.
3922 (let ((threads gnus-newsgroup-threads)
3925 (setq sub (car threads))
3926 (if (stringp (car sub))
3927 ;; This is a gathered thread, so we look at the roots
3928 ;; below it to find whether this article is in this
3931 (setq sub (cdr sub))
3933 (when (member (caar sub) headers)
3934 (setq thread (car threads)
3937 (setq sub (cdr sub))))
3938 ;; It's an ordinary thread, so we check it.
3939 (when (eq (car sub) (car headers))
3942 (setq threads (cdr threads)))
3943 ;; If this article is in no thread, then it's a root.
3946 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3947 (setq thread (gnus-id-to-thread last-id)))
3950 thread ; We return this thread.
3952 (if (stringp (car thread))
3954 ;; If we use dummy roots, then we have to remove the
3955 ;; dummy root as well.
3956 (when (eq gnus-summary-make-false-root 'dummy)
3957 ;; We go to the dummy root by going to
3958 ;; the first sub-"thread", and then one line up.
3959 (gnus-summary-goto-article
3960 (mail-header-number (caadr thread)))
3963 (gnus-data-compute-positions))
3964 (setq thread (cdr thread))
3966 (gnus-remove-thread-1 (car thread))
3967 (setq thread (cdr thread))))
3968 (gnus-remove-thread-1 thread))))))))
3970 (defun gnus-remove-thread-1 (thread)
3971 "Remove the thread THREAD recursively."
3972 (let ((number (mail-header-number (pop thread)))
3974 (setq thread (reverse thread))
3976 (gnus-remove-thread-1 (pop thread)))
3977 (when (setq d (gnus-data-find number))
3978 (goto-char (gnus-data-pos d))
3979 (gnus-summary-show-thread)
3982 (- (gnus-point-at-bol)
3984 (1+ (gnus-point-at-eol))
3985 (gnus-delete-line)))))))
3987 (defun gnus-sort-threads-1 (threads func)
3988 (sort (mapcar (lambda (thread)
3991 (gnus-sort-threads-1 (cdr thread) func))))
3994 (defun gnus-sort-threads (threads)
3996 (if (not gnus-thread-sort-functions)
3998 (gnus-message 8 "Sorting threads...")
4000 (gnus-sort-threads-1
4002 (gnus-make-sort-function gnus-thread-sort-functions))
4003 (gnus-message 8 "Sorting threads...done"))))
4005 (defun gnus-sort-articles (articles)
4007 (when gnus-article-sort-functions
4008 (gnus-message 7 "Sorting articles...")
4010 (setq gnus-newsgroup-headers
4011 (sort articles (gnus-make-sort-function
4012 gnus-article-sort-functions)))
4013 (gnus-message 7 "Sorting articles...done"))))
4015 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4016 (defmacro gnus-thread-header (thread)
4017 "Return header of first article in THREAD.
4018 Note that THREAD must never, ever be anything else than a variable -
4019 using some other form will lead to serious barfage."
4020 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4021 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4022 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4025 (defsubst gnus-article-sort-by-number (h1 h2)
4026 "Sort articles by article number."
4027 (< (mail-header-number h1)
4028 (mail-header-number h2)))
4030 (defun gnus-thread-sort-by-number (h1 h2)
4031 "Sort threads by root article number."
4032 (gnus-article-sort-by-number
4033 (gnus-thread-header h1) (gnus-thread-header h2)))
4035 (defsubst gnus-article-sort-by-lines (h1 h2)
4036 "Sort articles by article Lines header."
4037 (< (mail-header-lines h1)
4038 (mail-header-lines h2)))
4040 (defun gnus-thread-sort-by-lines (h1 h2)
4041 "Sort threads by root article Lines header."
4042 (gnus-article-sort-by-lines
4043 (gnus-thread-header h1) (gnus-thread-header h2)))
4045 (defsubst gnus-article-sort-by-chars (h1 h2)
4046 "Sort articles by octet length."
4047 (< (mail-header-chars h1)
4048 (mail-header-chars h2)))
4050 (defun gnus-thread-sort-by-chars (h1 h2)
4051 "Sort threads by root article octet length."
4052 (gnus-article-sort-by-chars
4053 (gnus-thread-header h1) (gnus-thread-header h2)))
4055 (defsubst gnus-article-sort-by-author (h1 h2)
4056 "Sort articles by root author."
4058 (let ((addr (car (mime-entity-read-field h1 'From))))
4059 (or (std11-full-name-string addr)
4060 (std11-address-string addr)
4062 (let ((addr (car (mime-entity-read-field h2 'From))))
4063 (or (std11-full-name-string addr)
4064 (std11-address-string addr)
4068 (defun gnus-thread-sort-by-author (h1 h2)
4069 "Sort threads by root author."
4070 (gnus-article-sort-by-author
4071 (gnus-thread-header h1) (gnus-thread-header h2)))
4073 (defsubst gnus-article-sort-by-subject (h1 h2)
4074 "Sort articles by root subject."
4076 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4077 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4079 (defun gnus-thread-sort-by-subject (h1 h2)
4080 "Sort threads by root subject."
4081 (gnus-article-sort-by-subject
4082 (gnus-thread-header h1) (gnus-thread-header h2)))
4084 (defsubst gnus-article-sort-by-date (h1 h2)
4085 "Sort articles by root article date."
4087 (gnus-date-get-time (mail-header-date h1))
4088 (gnus-date-get-time (mail-header-date h2))))
4090 (defun gnus-thread-sort-by-date (h1 h2)
4091 "Sort threads by root article date."
4092 (gnus-article-sort-by-date
4093 (gnus-thread-header h1) (gnus-thread-header h2)))
4095 (defsubst gnus-article-sort-by-score (h1 h2)
4096 "Sort articles by root article score.
4097 Unscored articles will be counted as having a score of zero."
4098 (> (or (cdr (assq (mail-header-number h1)
4099 gnus-newsgroup-scored))
4100 gnus-summary-default-score 0)
4101 (or (cdr (assq (mail-header-number h2)
4102 gnus-newsgroup-scored))
4103 gnus-summary-default-score 0)))
4105 (defun gnus-thread-sort-by-score (h1 h2)
4106 "Sort threads by root article score."
4107 (gnus-article-sort-by-score
4108 (gnus-thread-header h1) (gnus-thread-header h2)))
4110 (defun gnus-thread-sort-by-total-score (h1 h2)
4111 "Sort threads by the sum of all scores in the thread.
4112 Unscored articles will be counted as having a score of zero."
4113 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4115 (defun gnus-thread-total-score (thread)
4116 ;; This function find the total score of THREAD.
4117 (cond ((null thread)
4120 (if (stringp (car thread))
4121 (apply gnus-thread-score-function 0
4122 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4123 (gnus-thread-total-score-1 thread)))
4125 (gnus-thread-total-score-1 (list thread)))))
4127 (defun gnus-thread-total-score-1 (root)
4128 ;; This function find the total score of the thread below ROOT.
4129 (setq root (car root))
4130 (apply gnus-thread-score-function
4132 (mapcar 'gnus-thread-total-score
4133 (cdr (gnus-id-to-thread (mail-header-id root))))
4134 (when (> (mail-header-number root) 0)
4135 (list (or (cdr (assq (mail-header-number root)
4136 gnus-newsgroup-scored))
4137 gnus-summary-default-score 0))))
4138 (list gnus-summary-default-score)
4141 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4142 (defvar gnus-tmp-prev-subject nil)
4143 (defvar gnus-tmp-false-parent nil)
4144 (defvar gnus-tmp-root-expunged nil)
4145 (defvar gnus-tmp-dummy-line nil)
4147 (eval-when-compile (defvar gnus-tmp-header))
4148 (defun gnus-extra-header (type &optional header)
4149 "Return the extra header of TYPE."
4150 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4153 (defvar gnus-tmp-thread-tree-header-string "")
4155 (defvar gnus-sum-thread-tree-root "> "
4156 "With %B spec, used for the root of a thread.
4157 If nil, use subject instead.")
4158 (defvar gnus-sum-thread-tree-single-indent ""
4159 "With %B spec, used for a thread with just one message.
4160 If nil, use subject instead.")
4161 (defvar gnus-sum-thread-tree-vertical "| "
4162 "With %B spec, used for drawing a vertical line.")
4163 (defvar gnus-sum-thread-tree-indent " "
4164 "With %B spec, used for indenting.")
4165 (defvar gnus-sum-thread-tree-leaf-with-other "+-> "
4166 "With %B spec, used for a leaf with brothers.")
4167 (defvar gnus-sum-thread-tree-single-leaf "\\-> "
4168 "With %B spec, used for a leaf without brothers.")
4170 (defun gnus-summary-prepare-threads (threads)
4171 "Prepare summary buffer from THREADS and indentation LEVEL.
4172 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4173 or a straight list of headers."
4174 (gnus-message 7 "Generating summary...")
4176 (setq gnus-newsgroup-threads threads)
4179 (let ((gnus-tmp-level 0)
4180 (default-score (or gnus-summary-default-score 0))
4181 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4182 thread number subject stack state gnus-tmp-gathered beg-match
4183 new-roots gnus-tmp-new-adopts thread-end
4184 gnus-tmp-header gnus-tmp-unread
4185 gnus-tmp-replied gnus-tmp-subject-or-nil
4186 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4187 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4188 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4191 (setq gnus-tmp-prev-subject nil)
4193 (if (vectorp (car threads))
4194 ;; If this is a straight (sic) list of headers, then a
4195 ;; threaded summary display isn't required, so we just create
4196 ;; an unthreaded one.
4197 (gnus-summary-prepare-unthreaded threads)
4199 ;; Do the threaded display.
4201 (while (or threads stack gnus-tmp-new-adopts new-roots)
4203 (if (and (= gnus-tmp-level 0)
4206 (not gnus-tmp-false-parent)
4207 (or gnus-tmp-new-adopts new-roots))
4208 (if gnus-tmp-new-adopts
4209 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4210 thread (list (car gnus-tmp-new-adopts))
4211 gnus-tmp-header (caar thread)
4212 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4214 (setq thread (list (car new-roots))
4215 gnus-tmp-header (caar thread)
4216 new-roots (cdr new-roots))))
4219 ;; If there are some threads, we do them before the
4220 ;; threads on the stack.
4221 (setq thread threads
4222 gnus-tmp-header (caar thread))
4223 ;; There were no current threads, so we pop something off
4225 (setq state (car stack)
4226 gnus-tmp-level (car state)
4227 tree-stack (cadr state)
4228 thread (caddr state)
4230 gnus-tmp-header (caar thread))))
4232 (setq gnus-tmp-false-parent nil)
4233 (setq gnus-tmp-root-expunged nil)
4234 (setq thread-end nil)
4236 (if (stringp gnus-tmp-header)
4237 ;; The header is a dummy root.
4239 ((eq gnus-summary-make-false-root 'adopt)
4240 ;; We let the first article adopt the rest.
4241 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4243 (setq gnus-tmp-gathered
4245 (lambda (h) (mail-header-number (car h)))
4248 (setq thread (cons (list (caar thread)
4251 (setq gnus-tmp-level -1
4252 gnus-tmp-false-parent t))
4253 ((eq gnus-summary-make-false-root 'empty)
4254 ;; We print adopted articles with empty subject fields.
4255 (setq gnus-tmp-gathered
4257 (lambda (h) (mail-header-number (car h)))
4260 (setq gnus-tmp-level -1))
4261 ((eq gnus-summary-make-false-root 'dummy)
4262 ;; We remember that we probably want to output a dummy
4264 (setq gnus-tmp-dummy-line gnus-tmp-header)
4265 (setq gnus-tmp-prev-subject gnus-tmp-header))
4267 ;; We do not make a root for the gathered
4268 ;; sub-threads at all.
4269 (setq gnus-tmp-level -1)))
4271 (setq number (mail-header-number gnus-tmp-header)
4272 subject (mail-header-subject gnus-tmp-header))
4275 ;; If the thread has changed subject, we might want to make
4276 ;; this subthread into a root.
4277 ((and (null gnus-thread-ignore-subject)
4278 (not (zerop gnus-tmp-level))
4279 gnus-tmp-prev-subject
4281 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4282 (setq new-roots (nconc new-roots (list (car thread)))
4284 gnus-tmp-header nil))
4285 ;; If the article lies outside the current limit,
4286 ;; then we do not display it.
4287 ((not (memq number gnus-newsgroup-limit))
4288 (setq gnus-tmp-gathered
4290 (lambda (h) (mail-header-number (car h)))
4293 (setq gnus-tmp-new-adopts (if (cdar thread)
4294 (append gnus-tmp-new-adopts
4296 gnus-tmp-new-adopts)
4298 gnus-tmp-header nil)
4299 (when (zerop gnus-tmp-level)
4300 (setq gnus-tmp-root-expunged t)))
4301 ;; Perhaps this article is to be marked as read?
4302 ((and gnus-summary-mark-below
4303 (< (or (cdr (assq number gnus-newsgroup-scored))
4305 gnus-summary-mark-below)
4306 ;; Don't touch sparse articles.
4307 (not (gnus-summary-article-sparse-p number))
4308 (not (gnus-summary-article-ancient-p number)))
4309 (setq gnus-newsgroup-unreads
4310 (delq number gnus-newsgroup-unreads))
4311 (if gnus-newsgroup-auto-expire
4312 (push number gnus-newsgroup-expirable)
4313 (push (cons number gnus-low-score-mark)
4314 gnus-newsgroup-reads))))
4316 (when gnus-tmp-header
4317 ;; We may have an old dummy line to output before this
4319 (when (and gnus-tmp-dummy-line
4322 (mail-header-subject gnus-tmp-header)))
4323 (gnus-summary-insert-dummy-line
4324 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4325 (setq gnus-tmp-dummy-line nil))
4327 ;; Compute the mark.
4328 (setq gnus-tmp-unread (gnus-article-mark number))
4330 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4331 gnus-tmp-header gnus-tmp-level)
4332 gnus-newsgroup-data)
4334 ;; Actually insert the line.
4336 gnus-tmp-subject-or-nil
4338 ((and gnus-thread-ignore-subject
4339 gnus-tmp-prev-subject
4340 (not (inline (gnus-subject-equal
4341 gnus-tmp-prev-subject subject))))
4343 ((zerop gnus-tmp-level)
4344 (if (and (eq gnus-summary-make-false-root 'empty)
4345 (memq number gnus-tmp-gathered)
4346 gnus-tmp-prev-subject
4347 (inline (gnus-subject-equal
4348 gnus-tmp-prev-subject subject)))
4349 gnus-summary-same-subject
4351 (t gnus-summary-same-subject)))
4352 (if (and (eq gnus-summary-make-false-root 'adopt)
4353 (= gnus-tmp-level 1)
4354 (memq number gnus-tmp-gathered))
4355 (setq gnus-tmp-opening-bracket ?\<
4356 gnus-tmp-closing-bracket ?\>)
4357 (setq gnus-tmp-opening-bracket ?\[
4358 gnus-tmp-closing-bracket ?\]))
4360 gnus-tmp-indentation
4361 (aref gnus-thread-indent-array gnus-tmp-level)
4362 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4363 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4364 gnus-summary-default-score 0)
4366 (if (or (null gnus-summary-default-score)
4367 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4368 gnus-summary-zcore-fuzz))
4370 (if (< gnus-tmp-score gnus-summary-default-score)
4371 gnus-score-below-mark gnus-score-over-mark))
4373 (cond ((memq number gnus-newsgroup-processable)
4375 ((memq number gnus-newsgroup-cached)
4377 ((memq number gnus-newsgroup-replied)
4379 ((memq number gnus-newsgroup-forwarded)
4380 gnus-forwarded-mark)
4381 ((memq number gnus-newsgroup-saved)
4383 ((memq number gnus-newsgroup-recent)
4385 ((memq number gnus-newsgroup-unseen)
4388 gnus-tmp-from (mail-header-from gnus-tmp-header)
4391 ((string-match "<[^>]+> *$" gnus-tmp-from)
4392 (setq beg-match (match-beginning 0))
4393 (or (and (string-match "^\".+\"" gnus-tmp-from)
4394 (substring gnus-tmp-from 1 (1- (match-end 0))))
4395 (substring gnus-tmp-from 0 beg-match)))
4396 ((string-match "(.+)" gnus-tmp-from)
4397 (substring gnus-tmp-from
4398 (1+ (match-beginning 0)) (1- (match-end 0))))
4400 gnus-tmp-thread-tree-header-string
4402 ((not gnus-show-threads) "")
4403 ((zerop gnus-tmp-level)
4405 (or gnus-sum-thread-tree-root subject)
4406 (or gnus-sum-thread-tree-single-indent subject)))
4408 (concat (apply 'concat
4409 (mapcar (lambda (item)
4411 gnus-sum-thread-tree-vertical
4412 gnus-sum-thread-tree-indent))
4413 (cdr (reverse tree-stack))))
4415 gnus-sum-thread-tree-leaf-with-other
4416 gnus-sum-thread-tree-single-leaf)))))
4417 (when (string= gnus-tmp-name "")
4418 (setq gnus-tmp-name gnus-tmp-from))
4419 (unless (numberp gnus-tmp-lines)
4420 (setq gnus-tmp-lines -1))
4421 (if (= gnus-tmp-lines -1)
4422 (setq gnus-tmp-lines "?")
4423 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4424 (gnus-put-text-property
4426 (progn (eval gnus-summary-line-format-spec) (point))
4427 'gnus-number number)
4430 (gnus-run-hooks 'gnus-summary-update-hook)
4433 (setq gnus-tmp-prev-subject subject)))
4435 (when (nth 1 thread)
4436 (push (list (max 0 gnus-tmp-level)
4437 (copy-list tree-stack)
4440 (push (if (nth 1 thread) 1 0) tree-stack)
4441 (incf gnus-tmp-level)
4442 (setq threads (if thread-end nil (cdar thread)))
4444 (setq gnus-tmp-level 0)))))
4445 (gnus-message 7 "Generating summary...done"))
4447 (defun gnus-summary-prepare-unthreaded (headers)
4448 "Generate an unthreaded summary buffer based on HEADERS."
4449 (let (header number mark)
4454 ;; We may have to root out some bad articles...
4455 (when (memq (setq number (mail-header-number
4456 (setq header (pop headers))))
4457 gnus-newsgroup-limit)
4458 ;; Mark article as read when it has a low score.
4459 (when (and gnus-summary-mark-below
4460 (< (or (cdr (assq number gnus-newsgroup-scored))
4461 gnus-summary-default-score 0)
4462 gnus-summary-mark-below)
4463 (not (gnus-summary-article-ancient-p number)))
4464 (setq gnus-newsgroup-unreads
4465 (delq number gnus-newsgroup-unreads))
4466 (if gnus-newsgroup-auto-expire
4467 (push number gnus-newsgroup-expirable)
4468 (push (cons number gnus-low-score-mark)
4469 gnus-newsgroup-reads)))
4471 (setq mark (gnus-article-mark number))
4472 (push (gnus-data-make number mark (1+ (point)) header 0)
4473 gnus-newsgroup-data)
4474 (gnus-summary-insert-line
4476 mark (memq number gnus-newsgroup-replied)
4477 (memq number gnus-newsgroup-expirable)
4478 (mail-header-subject header) nil
4479 (cdr (assq number gnus-newsgroup-scored))
4480 (memq number gnus-newsgroup-processable))))))
4482 (defun gnus-summary-remove-list-identifiers ()
4483 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4484 (let ((regexp (if (consp gnus-list-identifiers)
4485 (mapconcat 'identity gnus-list-identifiers " *\\|")
4486 gnus-list-identifiers))
4489 (dolist (header gnus-newsgroup-headers)
4490 (setq subject (mail-header-subject header)
4492 (while (string-match
4493 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4496 (concat (substring subject 0 (match-beginning 2))
4497 (substring subject (match-end 0)))
4501 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4503 (concat (substring subject 0 (match-beginning 1))
4504 (substring subject (match-end 1)))))
4506 (mail-header-set-subject header subject))))))
4508 (defun gnus-fetch-headers (articles)
4509 "Fetch headers of ARTICLES."
4510 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4511 (gnus-message 5 "Fetching headers for %s..." name)
4514 (setq gnus-headers-retrieved-by
4515 (gnus-retrieve-headers
4516 articles gnus-newsgroup-name
4517 ;; We might want to fetch old headers, but
4518 ;; not if there is only 1 article.
4520 (not (eq gnus-fetch-old-headers 'some))
4521 (not (numberp gnus-fetch-old-headers)))
4522 (> (length articles) 1))
4523 gnus-fetch-old-headers))))
4524 (gnus-get-newsgroup-headers-xover
4525 articles nil nil gnus-newsgroup-name t)
4526 (gnus-get-newsgroup-headers))
4527 (gnus-message 5 "Fetching headers for %s...done" name))))
4529 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4530 "Select newsgroup GROUP.
4531 If READ-ALL is non-nil, all articles in the group are selected.
4532 If SELECT-ARTICLES, only select those articles from GROUP."
4533 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4534 ;;!!! Dirty hack; should be removed.
4535 (gnus-summary-ignore-duplicates
4536 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4538 gnus-summary-ignore-duplicates))
4539 (info (nth 2 entry))
4540 articles fetched-articles cached)
4542 (unless (gnus-check-server
4543 (setq gnus-current-select-method
4544 (gnus-find-method-for-group group)))
4545 (error "Couldn't open server"))
4547 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4548 (gnus-activate-group group) ; Or we can activate it...
4549 (progn ; Or we bug out.
4550 (when (equal major-mode 'gnus-summary-mode)
4551 (kill-buffer (current-buffer)))
4552 (error "Couldn't activate group %s: %s"
4553 group (gnus-status-message group))))
4555 (unless (gnus-request-group group t)
4556 (when (equal major-mode 'gnus-summary-mode)
4557 (kill-buffer (current-buffer)))
4558 (error "Couldn't request group %s: %s"
4559 group (gnus-status-message group)))
4561 (setq gnus-newsgroup-name group
4562 gnus-newsgroup-unselected nil
4563 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4565 (let ((display (gnus-group-find-parameter group 'display)))
4566 (setq gnus-newsgroup-display
4571 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4575 (gnus-summary-setup-default-charset)
4577 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4578 (when (gnus-virtual-group-p group)
4579 (setq cached gnus-newsgroup-cached))
4581 (setq gnus-newsgroup-unreads
4582 (gnus-set-difference
4583 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4584 gnus-newsgroup-dormant))
4586 (setq gnus-newsgroup-processable nil)
4588 (gnus-update-read-articles group gnus-newsgroup-unreads)
4590 ;; Adjust and set lists of article marks.
4592 (gnus-adjust-marked-articles info))
4594 (if (setq articles select-articles)
4595 (setq gnus-newsgroup-unselected
4596 (gnus-sorted-intersection
4597 gnus-newsgroup-unreads
4598 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4599 (setq articles (gnus-articles-to-read group read-all)))
4603 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4605 ((eq articles 0) nil)
4607 ;; Init the dependencies hash table.
4608 (setq gnus-newsgroup-dependencies
4609 (gnus-make-hashtable (length articles)))
4610 (gnus-set-global-variables)
4611 ;; Retrieve the headers and read them in.
4612 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4614 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4616 (setq gnus-newsgroup-cached cached))
4618 ;; Suppress duplicates?
4619 (when gnus-suppress-duplicates
4620 (gnus-dup-suppress-articles))
4622 ;; Set the initial limit.
4623 (setq gnus-newsgroup-limit (copy-sequence articles))
4624 ;; Remove canceled articles from the list of unread articles.
4625 (setq fetched-articles
4626 (mapcar (lambda (headers) (mail-header-number headers))
4627 gnus-newsgroup-headers))
4628 (setq gnus-newsgroup-articles fetched-articles)
4629 (setq gnus-newsgroup-unreads
4630 (gnus-set-sorted-intersection
4631 gnus-newsgroup-unreads fetched-articles))
4633 (let ((marks (assq 'seen (gnus-info-marks info))))
4634 ;; The `seen' marks are treated specially.
4635 (when (setq gnus-newsgroup-seen (cdr marks))
4636 (dolist (article gnus-newsgroup-articles)
4637 (unless (gnus-member-of-range
4638 article gnus-newsgroup-seen)
4639 (push article gnus-newsgroup-unseen)))))
4641 ;; Removed marked articles that do not exist.
4642 (gnus-update-missing-marks
4643 (gnus-sorted-complement fetched-articles articles))
4644 ;; We might want to build some more threads first.
4645 (when (and gnus-fetch-old-headers
4646 (eq gnus-headers-retrieved-by 'nov))
4647 (if (eq gnus-fetch-old-headers 'invisible)
4648 (gnus-build-all-threads)
4649 (gnus-build-old-threads)))
4650 ;; Let the Gnus agent mark articles as read.
4652 (gnus-agent-get-undownloaded-list))
4653 ;; Remove list identifiers from subject
4654 (when gnus-list-identifiers
4655 (gnus-summary-remove-list-identifiers))
4656 ;; Check whether auto-expire is to be done in this group.
4657 (setq gnus-newsgroup-auto-expire
4658 (gnus-group-auto-expirable-p group))
4659 ;; Set up the article buffer now, if necessary.
4660 (unless gnus-single-article-buffer
4661 (gnus-article-setup-buffer))
4662 ;; First and last article in this newsgroup.
4663 (when gnus-newsgroup-headers
4664 (setq gnus-newsgroup-begin
4665 (mail-header-number (car gnus-newsgroup-headers))
4668 (gnus-last-element gnus-newsgroup-headers))))
4669 ;; GROUP is successfully selected.
4670 (or gnus-newsgroup-headers t)))))
4672 (defun gnus-summary-display-make-predicate (display)
4673 (require 'gnus-agent)
4674 (when (= (length display) 1)
4675 (setq display (car display)))
4676 (unless gnus-summary-display-cache
4677 (dolist (elem (append (list (cons 'read 'read)
4678 (cons 'unseen 'unseen))
4679 gnus-article-mark-lists))
4680 (push (cons (cdr elem)
4682 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4683 gnus-summary-display-cache)))
4684 (let ((gnus-category-predicate-alist gnus-summary-display-cache))
4685 (gnus-get-predicate display)))
4687 ;; Uses the dynamically bound `number' variable.
4689 (defun gnus-article-marked-p (type &optional article)
4690 (let ((article (or article number)))
4693 (memq article gnus-newsgroup-marked))
4695 (memq article gnus-newsgroup-unsendable))
4696 ((eq type 'undownload)
4697 (memq article gnus-newsgroup-undownloaded))
4698 ((eq type 'download)
4699 (memq article gnus-newsgroup-downloadable))
4701 (memq article gnus-newsgroup-unreads))
4703 (memq article gnus-newsgroup-reads))
4705 (memq article gnus-newsgroup-dormant) )
4707 (memq article gnus-newsgroup-expirable))
4709 (memq article gnus-newsgroup-replied))
4711 (memq article gnus-newsgroup-killed))
4712 ((eq type 'bookmark)
4713 (assq article gnus-newsgroup-bookmarks))
4715 (assq article gnus-newsgroup-scored))
4717 (memq article gnus-newsgroup-saved))
4719 (memq article gnus-newsgroup-cached))
4721 (memq article gnus-newsgroup-forwarded))
4723 (not (memq article gnus-newsgroup-unseen)))
4725 (memq article gnus-newsgroup-recent))
4728 (defun gnus-articles-to-read (group &optional read-all)
4729 "Find out what articles the user wants to read."
4731 ;; Select all articles if `read-all' is non-nil, or if there
4732 ;; are no unread articles.
4734 (and (zerop (length gnus-newsgroup-marked))
4735 (zerop (length gnus-newsgroup-unreads)))
4736 (eq gnus-newsgroup-display 'gnus-not-ignore))
4737 ;; We want to select the headers for all the articles in
4738 ;; the group, so we select either all the active
4739 ;; articles in the group, or (if that's nil), the
4740 ;; articles in the cache.
4742 (gnus-uncompress-range (gnus-active group))
4743 (gnus-cache-articles-in-group group))
4744 ;; Select only the "normal" subset of articles.
4745 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4746 (copy-sequence gnus-newsgroup-unreads))
4748 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4749 (scored (length scored-list))
4750 (number (length articles))
4751 (marked (+ (length gnus-newsgroup-marked)
4752 (length gnus-newsgroup-dormant)))
4760 ((and (or (<= scored marked) (= scored number))
4761 (natnump gnus-large-newsgroup)
4762 (> number gnus-large-newsgroup))
4763 (let* ((cursor-in-echo-area nil)
4765 (read-from-minibuffer
4767 "How many articles from %s (max %d): "
4769 (gnus-group-decoded-name gnus-newsgroup-name)
4772 (cons (number-to-string gnus-large-newsgroup)
4774 (if (string-match "^[ \t]*$" input)
4777 ((and (> scored marked) (< scored number)
4778 (> (- scored number) 20))
4781 (format "%s %s (%d scored, %d total): "
4782 "How many articles from"
4783 (gnus-group-decoded-name group)
4785 (if (string-match "^[ \t]*$" input)
4789 (message "Quit getting the articles to read")
4791 (setq select (if (stringp select) (string-to-number select) select))
4792 (if (or (null select) (zerop select))
4794 (if (and (not (zerop scored)) (<= (abs select) scored))
4796 (setq articles (sort scored-list '<))
4797 (setq number (length articles)))
4798 (setq articles (copy-sequence articles)))
4800 (when (< (abs select) number)
4802 ;; Select the N oldest articles.
4803 (setcdr (nthcdr (1- (abs select)) articles) nil)
4804 ;; Select the N most recent articles.
4805 (setq articles (nthcdr (- number select) articles))))
4806 (setq gnus-newsgroup-unselected
4807 (gnus-sorted-intersection
4808 gnus-newsgroup-unreads
4809 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4810 (when gnus-alter-articles-to-read-function
4811 (setq gnus-newsgroup-unreads
4813 (funcall gnus-alter-articles-to-read-function
4814 gnus-newsgroup-name gnus-newsgroup-unreads)
4818 (defun gnus-killed-articles (killed articles)
4821 (when (inline (gnus-member-of-range (car articles) killed))
4822 (push (car articles) out))
4823 (setq articles (cdr articles)))
4826 (defun gnus-uncompress-marks (marks)
4827 "Uncompress the mark ranges in MARKS."
4828 (let ((uncompressed '(score bookmark))
4831 (if (memq (caar marks) uncompressed)
4832 (push (car marks) out)
4833 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4834 (setq marks (cdr marks)))
4837 (defun gnus-article-mark-to-type (mark)
4838 "Return the type of MARK."
4839 (or (cadr (assq mark gnus-article-special-mark-lists))
4842 (defun gnus-adjust-marked-articles (info)
4843 "Set all article lists and remove all marks that are no longer valid."
4844 (let* ((marked-lists (gnus-info-marks info))
4845 (active (gnus-active (gnus-info-group info)))
4848 (types gnus-article-mark-lists)
4849 marks var articles article mark mark-type)
4851 (dolist (marks marked-lists)
4852 (setq mark (car marks)
4853 mark-type (gnus-article-mark-to-type mark)
4854 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
4856 ;; We set the variable according to the type of the marks list,
4857 ;; and then adjust the marks to a subset of the active articles.
4859 ;; Adjust "simple" lists.
4860 ((eq mark-type 'list)
4861 (set var (setq articles (gnus-uncompress-range (cdr marks))))
4862 (when (memq mark '(tick dormant expire reply save))
4864 (when (or (< (setq article (pop articles)) min) (> article max))
4865 (set var (delq article (symbol-value var)))))))
4867 ((eq mark-type 'tuple)
4868 (set var (setq articles (cdr marks)))
4869 (when (not (listp (cdr (symbol-value var))))
4870 (set var (list (symbol-value var))))
4871 (when (not (listp (cdr articles)))
4872 (setq articles (list articles)))
4874 (when (or (not (consp (setq article (pop articles))))
4875 (< (car article) min)
4876 (> (car article) max))
4877 (set var (delq article (symbol-value var))))))
4878 ((eq mark-type 'range)
4880 ((eq mark 'seen))))))))
4882 (defun gnus-update-missing-marks (missing)
4883 "Go through the list of MISSING articles and remove them from the mark lists."
4886 ;; Go through all types.
4887 (dolist (elem gnus-article-mark-lists)
4888 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
4889 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
4890 (when (symbol-value var)
4891 ;; This list has articles. So we delete all missing
4892 ;; articles from it.
4895 (set var (delq (pop m) (symbol-value var))))))))))
4897 (defun gnus-update-marks ()
4898 "Enter the various lists of marked articles into the newsgroup info list."
4899 (let ((types gnus-article-mark-lists)
4900 (info (gnus-get-info gnus-newsgroup-name))
4901 (uncompressed '(score bookmark killed seen))
4902 type list newmarked symbol delta-marks)
4904 ;; Add all marks lists to the list of marks lists.
4905 (while (setq type (pop types))
4906 (setq list (symbol-value
4908 (intern (format "gnus-newsgroup-%s" (car type))))))
4911 ;; Get rid of the entries of the articles that have the
4913 (when (and (eq (cdr type) 'score)
4917 (prev (cons nil list))
4920 (if (or (not (consp (car arts)))
4921 (= (cdar arts) gnus-summary-default-score))
4922 (setcdr prev (cdr arts))
4924 (setq arts (cdr arts)))
4925 (setq list (cdr all)))))
4927 (when (eq (cdr type) 'seen)
4930 (gnus-add-to-range list gnus-newsgroup-unseen)
4931 (gnus-compress-sequence gnus-newsgroup-articles))))
4933 (unless (memq (cdr type) uncompressed)
4934 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4936 (when (gnus-check-backend-function
4937 'request-set-mark gnus-newsgroup-name)
4938 ;; propagate flags to server, with the following exceptions:
4939 ;; uncompressed:s are not proper flags (they are cons cells)
4940 ;; cache is a internal gnus flag
4941 ;; download are local to one gnus installation (well)
4942 ;; unsend are for nndraft groups only
4943 ;; xxx: generality of this? this suits nnimap anyway
4944 (unless (memq (cdr type) (append '(cache download unsend)
4946 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4947 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4948 (add (gnus-remove-from-range
4949 (gnus-copy-sequence list) old)))
4951 (push (list add 'add (list (cdr type))) delta-marks))
4953 (push (list del 'del (list (cdr type))) delta-marks)))))
4956 (push (cons (cdr type) list) newmarked)))
4959 (unless (gnus-check-group gnus-newsgroup-name)
4960 (error "Can't open server for %s" gnus-newsgroup-name))
4961 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4963 ;; Enter these new marks into the info of the group.
4965 (setcar (nthcdr 3 info) newmarked)
4966 ;; Add the marks lists to the end of the info.
4968 (setcdr (nthcdr 2 info) (list newmarked))))
4970 ;; Cut off the end of the info if there's nothing else there.
4974 (when (nthcdr (decf i) info)
4975 (setcdr (nthcdr i info) nil)))))))
4977 (defun gnus-set-mode-line (where)
4978 "Set the mode line of the article or summary buffers.
4979 If WHERE is `summary', the summary mode line format will be used."
4980 ;; Is this mode line one we keep updated?
4981 (when (and (memq where gnus-updated-mode-lines)
4983 (intern (format "gnus-%s-mode-line-format-spec" where))))
4986 ;; We evaluate this in the summary buffer since these
4987 ;; variables are buffer-local to that buffer.
4988 (set-buffer gnus-summary-buffer)
4989 ;; We bind all these variables that are used in the `eval' form
4991 (let* ((mformat (symbol-value
4993 (format "gnus-%s-mode-line-format-spec" where))))
4994 (gnus-tmp-group-name (gnus-group-decoded-name
4995 gnus-newsgroup-name))
4996 (gnus-tmp-article-number (or gnus-current-article 0))
4997 (gnus-tmp-unread gnus-newsgroup-unreads)
4998 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4999 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5000 (gnus-tmp-unread-and-unselected
5001 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5002 (zerop gnus-tmp-unselected))
5004 ((zerop gnus-tmp-unselected)
5005 (format "{%d more}" gnus-tmp-unread-and-unticked))
5006 (t (format "{%d(+%d) more}"
5007 gnus-tmp-unread-and-unticked
5008 gnus-tmp-unselected))))
5010 (if (and gnus-current-headers
5011 (vectorp gnus-current-headers))
5012 (gnus-mode-string-quote
5013 (mail-header-subject gnus-current-headers))
5015 bufname-length max-len
5016 gnus-tmp-header);; passed as argument to any user-format-funcs
5017 (setq mode-string (eval mformat))
5018 (setq bufname-length (if (string-match "%b" mode-string)
5021 (if (eq where 'summary)
5023 (get-buffer gnus-article-buffer))))
5026 (setq max-len (max 4 (if gnus-mode-non-string-length
5028 gnus-mode-non-string-length
5030 (length mode-string))))
5031 ;; We might have to chop a bit of the string off...
5032 (when (> (length mode-string) max-len)
5034 (concat (gnus-truncate-string mode-string (- max-len 3))
5036 ;; Pad the mode string a bit.
5037 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5038 ;; Update the mode line.
5039 (setq mode-line-buffer-identification
5040 (gnus-mode-line-buffer-identification (list mode-string)))
5041 (set-buffer-modified-p t))))
5043 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5044 "Go through the HEADERS list and add all Xrefs to a hash table.
5045 The resulting hash table is returned, or nil if no Xrefs were found."
5046 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5047 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5048 (xref-hashtb (gnus-make-hashtable))
5049 start group entry number xrefs header)
5051 (setq header (pop headers))
5052 (when (and (setq xrefs (mail-header-xref header))
5053 (not (memq (setq number (mail-header-number header))
5056 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5057 (setq start (match-end 0))
5058 (setq group (if prefix
5059 (concat prefix (substring xrefs (match-beginning 1)
5061 (substring xrefs (match-beginning 1) (match-end 1))))
5063 (string-to-int (substring xrefs (match-beginning 2)
5065 (if (setq entry (gnus-gethash group xref-hashtb))
5066 (setcdr entry (cons number (cdr entry)))
5067 (gnus-sethash group (cons number nil) xref-hashtb)))))
5068 (and start xref-hashtb)))
5070 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5071 "Look through all the headers and mark the Xrefs as read."
5072 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5073 name entry info xref-hashtb idlist method nth4)
5075 (set-buffer gnus-group-buffer)
5076 (when (setq xref-hashtb
5077 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5080 (unless (string= from-newsgroup (setq name (symbol-name group)))
5081 (setq idlist (symbol-value group))
5082 ;; Dead groups are not updated.
5084 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5086 (when (stringp (setq nth4 (gnus-info-method info)))
5087 (setq nth4 (gnus-server-to-method nth4))))
5088 ;; Only do the xrefs if the group has the same
5089 ;; select method as the group we have just read.
5090 (or (gnus-methods-equal-p
5091 nth4 (gnus-find-method-for-group from-newsgroup))
5093 (equal nth4 (setq method (gnus-find-method-for-group
5095 (and (equal (car nth4) (car method))
5096 (equal (nth 1 nth4) (nth 1 method))))
5097 gnus-use-cross-reference
5098 (or (not (eq gnus-use-cross-reference t))
5100 ;; Only do cross-references on subscribed
5101 ;; groups, if that is what is wanted.
5102 (<= (gnus-info-level info) gnus-level-subscribed))
5103 (gnus-group-make-articles-read name idlist))))
5106 (defun gnus-compute-read-articles (group articles)
5107 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5108 (info (nth 2 entry))
5109 (active (gnus-active group))
5112 ;; First peel off all invalid article numbers.
5114 (let ((ids articles)
5116 (while (setq id (pop ids))
5117 (when (and first (> id (cdr active)))
5118 ;; We'll end up in this situation in one particular
5119 ;; obscure situation. If you re-scan a group and get
5120 ;; a new article that is cross-posted to a different
5121 ;; group that has not been re-scanned, you might get
5122 ;; crossposted article that has a higher number than
5123 ;; Gnus believes possible. So we re-activate this
5124 ;; group as well. This might mean doing the
5125 ;; crossposting thingy will *increase* the number
5126 ;; of articles in some groups. Tsk, tsk.
5127 (setq active (or (gnus-activate-group group) active)))
5128 (when (or (> id (cdr active))
5129 (< id (car active)))
5130 (setq articles (delq id articles))))))
5131 ;; If the read list is nil, we init it.
5133 (null (gnus-info-read info))
5135 (setq ninfo (cons 1 (1- (car active))))
5136 (setq ninfo (gnus-info-read info)))
5137 ;; Then we add the read articles to the range.
5139 ninfo (setq articles (sort articles '<))))))
5141 (defun gnus-group-make-articles-read (group articles)
5142 "Update the info of GROUP to say that ARTICLES are read."
5144 (entry (gnus-gethash group gnus-newsrc-hashtb))
5145 (info (nth 2 entry))
5146 (active (gnus-active group))
5149 (setq range (gnus-compute-read-articles group articles))
5151 (set-buffer gnus-group-buffer)
5154 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5155 (gnus-info-set-read ',info ',(gnus-info-read info))
5156 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5157 (gnus-group-update-group ,group t))))
5158 ;; Add the read articles to the range.
5159 (gnus-info-set-read info range)
5160 (gnus-request-set-mark group (list (list range 'add '(read))))
5161 ;; Then we have to re-compute how many unread
5162 ;; articles there are in this group.
5166 (setq num (- (1+ (cdr active)) (car active))))
5167 ((not (listp (cdr range)))
5168 (setq num (- (cdr active) (- (1+ (cdr range))
5172 (if (numberp (car range))
5174 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5175 (setq range (cdr range)))
5176 (setq num (- (cdr active) num))))
5177 ;; Update the number of unread articles.
5179 ;; Update the group buffer.
5180 (gnus-group-update-group group t)))))
5182 (defvar gnus-newsgroup-none-id 0)
5184 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5185 (let ((cur nntp-server-buffer)
5188 (save-excursion (set-buffer gnus-summary-buffer)
5189 gnus-newsgroup-dependencies)))
5191 (mail-parse-charset gnus-newsgroup-charset)
5192 (mail-parse-ignored-charsets
5193 (save-excursion (condition-case nil
5194 (set-buffer gnus-summary-buffer)
5196 gnus-newsgroup-ignored-charsets)))
5198 (set-buffer nntp-server-buffer)
5199 ;; Translate all TAB characters into SPACE characters.
5200 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5201 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5202 (gnus-run-hooks 'gnus-parse-headers-hook)
5203 (let ((case-fold-search t)
5204 in-reply-to header p lines chars ctype)
5205 (goto-char (point-min))
5206 ;; Search to the beginning of the next header. Error messages
5207 ;; do not begin with 2 or 3.
5208 (while (re-search-forward "^[23][0-9]+ " nil t)
5211 ;; This implementation of this function, with nine
5212 ;; search-forwards instead of the one re-search-forward and
5213 ;; a case (which basically was the old function) is actually
5214 ;; about twice as fast, even though it looks messier. You
5215 ;; can't have everything, I guess. Speed and elegance
5216 ;; doesn't always go hand in hand.
5219 (make-full-mail-header
5225 (narrow-to-region (point)
5226 (or (and (search-forward "\n.\n" nil t)
5232 (if (search-forward "\nsubject:" nil t)
5233 (nnheader-header-value)
5238 (if (search-forward "\nfrom:" nil t)
5239 (nnheader-header-value)
5244 (if (search-forward "\ndate:" nil t)
5245 (nnheader-header-value) ""))
5249 (setq id (if (re-search-forward
5250 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5251 ;; We do it this way to make sure the Message-ID
5252 ;; is (somewhat) syntactically valid.
5253 (buffer-substring (match-beginning 1)
5255 ;; If there was no message-id, we just fake one
5256 ;; to make subsequent routines simpler.
5257 (nnheader-generate-fake-message-id))))
5261 (if (search-forward "\nreferences:" nil t)
5265 (nnheader-header-value)
5270 (search-backward ">" end t)
5273 (search-backward "<" end t)
5275 ;; Get the references from the in-reply-to header if there
5276 ;; were no references and the in-reply-to header looks
5278 (if (and (search-forward "\nin-reply-to:" nil t)
5279 (setq in-reply-to (nnheader-header-value))
5280 (string-match "<[^>]+>" in-reply-to))
5282 (setq ref (substring in-reply-to (match-beginning 0)
5284 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5285 (setq ref2 (substring in-reply-to (match-beginning 0)
5287 (when (> (length ref2) (length ref))
5294 (if (search-forward "\nchars: " nil t)
5295 (if (numberp (setq chars (ignore-errors (read cur))))
5301 (if (search-forward "\nlines: " nil t)
5302 (if (numberp (setq lines (ignore-errors (read cur))))
5308 (and (search-forward "\nxref:" nil t)
5309 (nnheader-header-value)))
5311 (when gnus-extra-headers
5312 (let ((extra gnus-extra-headers)
5316 (when (search-forward
5317 (concat "\n" (symbol-name (car extra)) ":") nil t)
5318 (push (cons (car extra) (nnheader-header-value)) out))
5322 (if (and (search-forward "\ncontent-type: " nil t)
5323 (setq ctype (nnheader-header-value)))
5324 (mime-entity-set-content-type-internal
5325 header (mime-parse-Content-Type ctype)))
5326 (when (equal id ref)
5329 (when gnus-alter-header-function
5330 (funcall gnus-alter-header-function header)
5331 (setq id (mail-header-id header)
5332 ref (gnus-parent-id (mail-header-references header))))
5335 (gnus-dependencies-add-header
5336 header dependencies force-new))
5337 (push header headers))
5338 (goto-char (point-max))
5340 (nreverse headers)))))
5342 ;; Goes through the xover lines and returns a list of vectors
5343 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5344 force-new dependencies
5345 group also-fetch-heads)
5346 "Parse the news overview data in the server buffer.
5347 Return a list of headers that match SEQUENCE (see
5348 `nntp-retrieve-headers')."
5349 ;; Get the Xref when the users reads the articles since most/some
5350 ;; NNTP servers do not include Xrefs when using XOVER.
5351 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5352 (let ((mail-parse-charset gnus-newsgroup-charset)
5353 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5354 (cur nntp-server-buffer)
5355 (dependencies (or dependencies gnus-newsgroup-dependencies))
5357 ((eq gnus-read-all-available-headers t)
5359 ((stringp gnus-read-all-available-headers)
5360 (string-match gnus-read-all-available-headers group))
5363 number headers header)
5365 (set-buffer nntp-server-buffer)
5366 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5367 ;; Allow the user to mangle the headers before parsing them.
5368 (gnus-run-hooks 'gnus-parse-headers-hook)
5369 (goto-char (point-min))
5372 (while (and (or sequence allp)
5374 (setq number (read cur))
5376 (while (and sequence
5377 (< (car sequence) number))
5378 (setq sequence (cdr sequence))))
5381 (eq number (car sequence))))
5383 (setq sequence (cdr sequence))
5384 (setq header (inline
5385 (gnus-nov-parse-line
5386 number dependencies force-new)))))
5387 (push header headers))
5390 (gnus-error 4 "Strange nov line (%d)"
5391 (count-lines (point-min) (point)))))
5393 ;; A common bug in inn is that if you have posted an article and
5394 ;; then retrieves the active file, it will answer correctly --
5395 ;; the new article is included. However, a NOV entry for the
5396 ;; article may not have been generated yet, so this may fail.
5397 ;; We work around this problem by retrieving the last few
5398 ;; headers using HEAD.
5399 (if (or (not also-fetch-heads)
5401 ;; We (probably) got all the headers.
5403 (let ((gnus-nov-is-evil t))
5406 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5407 (gnus-get-newsgroup-headers))))))))
5409 (defun gnus-article-get-xrefs ()
5410 "Fill in the Xref value in `gnus-current-headers', if necessary.
5411 This is meant to be called in `gnus-article-internal-prepare-hook'."
5412 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5413 gnus-current-headers)))
5414 (or (not gnus-use-cross-reference)
5416 (and (mail-header-xref headers)
5417 (not (string= (mail-header-xref headers) "")))
5418 (let ((case-fold-search t)
5421 (nnheader-narrow-to-headers)
5422 (goto-char (point-min))
5423 (when (or (and (not (eobp))
5424 (eq (downcase (char-after)) ?x)
5425 (looking-at "Xref:"))
5426 (search-forward "\nXref:" nil t))
5427 (goto-char (1+ (match-end 0)))
5428 (setq xref (buffer-substring (point)
5429 (progn (end-of-line) (point))))
5430 (mail-header-set-xref headers xref)))))))
5432 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5433 "Find article ID and insert the summary line for that article.
5434 OLD-HEADER can either be a header or a line number to insert
5435 the subject line on."
5436 (let* ((line (and (numberp old-header) old-header))
5437 (old-header (and (vectorp old-header) old-header))
5438 (header (cond ((and old-header use-old-header)
5441 (gnus-number-to-header id))
5442 (gnus-number-to-header id))
5444 (gnus-read-header id))))
5445 (number (and (numberp id) id))
5448 ;; Rebuild the thread that this article is part of and go to the
5449 ;; article we have fetched.
5450 (when (and (not gnus-show-threads)
5453 (setq d (gnus-data-find (mail-header-number old-header))))
5454 (goto-char (gnus-data-pos d))
5457 (- (gnus-point-at-bol)
5459 (1+ (gnus-point-at-eol))
5460 (gnus-delete-line))))))
5462 (mail-header-set-number header (mail-header-number old-header)))
5463 (setq gnus-newsgroup-sparse
5464 (delq (setq number (mail-header-number header))
5465 gnus-newsgroup-sparse))
5466 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5467 (push number gnus-newsgroup-limit)
5468 (gnus-rebuild-thread (mail-header-id header) line)
5469 (gnus-summary-goto-subject number nil t))
5470 (when (and (numberp number)
5472 ;; We have to update the boundaries even if we can't fetch the
5473 ;; article if ID is a number -- so that the next `P' or `N'
5474 ;; command will fetch the previous (or next) article even
5475 ;; if the one we tried to fetch this time has been canceled.
5476 (when (> number gnus-newsgroup-end)
5477 (setq gnus-newsgroup-end number))
5478 (when (< number gnus-newsgroup-begin)
5479 (setq gnus-newsgroup-begin number))
5480 (setq gnus-newsgroup-unselected
5481 (delq number gnus-newsgroup-unselected)))
5482 ;; Report back a success?
5483 (and header (mail-header-number header))))
5485 ;;; Process/prefix in the summary buffer
5487 (defun gnus-summary-work-articles (n)
5488 "Return a list of articles to be worked upon.
5489 The prefix argument, the list of process marked articles, and the
5490 current article will be taken into consideration."
5492 (set-buffer gnus-summary-buffer)
5495 ;; A numerical prefix has been given.
5496 (setq n (prefix-numeric-value n))
5497 (let ((backward (< n 0))
5498 (n (abs (prefix-numeric-value n)))
5503 (push (setq article (gnus-summary-article-number))
5506 (gnus-summary-find-prev nil article)
5507 (gnus-summary-find-next nil article)))
5509 (nreverse articles)))
5510 ((and (gnus-region-active-p) (mark))
5511 (message "region active")
5512 ;; Work on the region between point and mark.
5513 (let ((max (max (point) (mark)))
5516 (goto-char (min (point) (mark)))
5519 (push (setq article (gnus-summary-article-number)) articles)
5520 (gnus-summary-find-next nil article)
5522 (nreverse articles))))
5523 (gnus-newsgroup-processable
5524 ;; There are process-marked articles present.
5525 ;; Save current state.
5526 (gnus-summary-save-process-mark)
5528 (reverse gnus-newsgroup-processable))
5530 ;; Just return the current article.
5531 (list (gnus-summary-article-number))))))
5533 (defmacro gnus-summary-iterate (arg &rest forms)
5534 "Iterate over the process/prefixed articles and do FORMS.
5535 ARG is the interactive prefix given to the command. FORMS will be
5536 executed with point over the summary line of the articles."
5537 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5538 `(let ((,articles (gnus-summary-work-articles ,arg)))
5540 (gnus-summary-goto-subject (car ,articles))
5544 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5545 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5547 (defun gnus-summary-save-process-mark ()
5548 "Push the current set of process marked articles on the stack."
5550 (push (copy-sequence gnus-newsgroup-processable)
5551 gnus-newsgroup-process-stack))
5553 (defun gnus-summary-kill-process-mark ()
5554 "Push the current set of process marked articles on the stack and unmark."
5556 (gnus-summary-save-process-mark)
5557 (gnus-summary-unmark-all-processable))
5559 (defun gnus-summary-yank-process-mark ()
5560 "Pop the last process mark state off the stack and restore it."
5562 (unless gnus-newsgroup-process-stack
5563 (error "Empty mark stack"))
5564 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5566 (defun gnus-summary-process-mark-set (set)
5567 "Make SET into the current process marked articles."
5568 (gnus-summary-unmark-all-processable)
5570 (gnus-summary-set-process-mark (pop set))))
5572 ;;; Searching and stuff
5574 (defun gnus-summary-search-group (&optional backward use-level)
5575 "Search for next unread newsgroup.
5576 If optional argument BACKWARD is non-nil, search backward instead."
5578 (set-buffer gnus-group-buffer)
5579 (when (gnus-group-search-forward
5580 backward nil (if use-level (gnus-group-group-level) nil))
5581 (gnus-group-group-name))))
5583 (defun gnus-summary-best-group (&optional exclude-group)
5584 "Find the name of the best unread group.
5585 If EXCLUDE-GROUP, do not go to this group."
5587 (set-buffer gnus-group-buffer)
5589 (gnus-group-best-unread-group exclude-group))))
5591 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5592 (if backward (gnus-summary-find-prev)
5593 (let* ((dummy (gnus-summary-article-intangible-p))
5594 (article (or article (gnus-summary-article-number)))
5595 (arts (gnus-data-find-list article))
5597 (when (and (not dummy)
5598 (or (not gnus-summary-check-current)
5600 (not (gnus-data-unread-p (car arts)))))
5601 (setq arts (cdr arts)))
5606 (when (or (and undownloaded
5607 (eq gnus-undownloaded-mark
5608 (gnus-data-mark (car arts))))
5609 (gnus-data-unread-p (car arts)))
5610 (setq result (car arts)
5612 (setq arts (cdr arts)))
5615 (goto-char (gnus-data-pos result))
5616 (gnus-data-number result)))))
5618 (defun gnus-summary-find-prev (&optional unread article)
5619 (let* ((eobp (eobp))
5620 (article (or article (gnus-summary-article-number)))
5621 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5623 (when (and (not eobp)
5624 (or (not gnus-summary-check-current)
5626 (not (gnus-data-unread-p (car arts)))))
5627 (setq arts (cdr arts)))
5632 (when (gnus-data-unread-p (car arts))
5633 (setq result (car arts)
5635 (setq arts (cdr arts)))
5638 (goto-char (gnus-data-pos result))
5639 (gnus-data-number result))))
5641 (defun gnus-summary-find-subject (subject &optional unread backward article)
5642 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5643 (article (or article (gnus-summary-article-number)))
5644 (articles (gnus-data-list backward))
5645 (arts (gnus-data-find-list article articles))
5647 (when (or (not gnus-summary-check-current)
5649 (not (gnus-data-unread-p (car arts))))
5650 (setq arts (cdr arts)))
5652 (and (or (not unread)
5653 (gnus-data-unread-p (car arts)))
5654 (vectorp (gnus-data-header (car arts)))
5656 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5657 (setq result (car arts)
5659 (setq arts (cdr arts)))
5661 (goto-char (gnus-data-pos result))
5662 (gnus-data-number result))))
5664 (defun gnus-summary-search-forward (&optional unread subject backward)
5665 "Search forward for an article.
5666 If UNREAD, look for unread articles. If SUBJECT, look for
5667 articles with that subject. If BACKWARD, search backward instead."
5668 (cond (subject (gnus-summary-find-subject subject unread backward))
5669 (backward (gnus-summary-find-prev unread))
5670 (t (gnus-summary-find-next unread))))
5672 (defun gnus-recenter (&optional n)
5673 "Center point in window and redisplay frame.
5674 Also do horizontal recentering."
5676 (when (and gnus-auto-center-summary
5677 (not (eq gnus-auto-center-summary 'vertical)))
5678 (gnus-horizontal-recenter))
5681 (defun gnus-summary-recenter ()
5682 "Center point in the summary window.
5683 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5684 displayed, no centering will be performed."
5685 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5686 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5688 (let* ((top (cond ((< (window-height) 4) 0)
5689 ((< (window-height) 7) 1)
5690 (t (if (numberp gnus-auto-center-summary)
5691 gnus-auto-center-summary
5693 (height (1- (window-height)))
5694 (bottom (save-excursion (goto-char (point-max))
5695 (forward-line (- height))
5697 (window (get-buffer-window (current-buffer))))
5698 ;; The user has to want it.
5699 (when gnus-auto-center-summary
5700 (when (get-buffer-window gnus-article-buffer)
5701 ;; Only do recentering when the article buffer is displayed,
5702 ;; Set the window start to either `bottom', which is the biggest
5703 ;; possible valid number, or the second line from the top,
5704 ;; whichever is the least.
5705 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5706 (if (> bottom top-pos)
5707 ;; Keep the second line from the top visible
5708 (set-window-start window top-pos t)
5709 ;; Try to keep the bottom line visible; if it's partially
5710 ;; obscured, either scroll one more line to make it fully
5711 ;; visible, or revert to using TOP-POS.
5713 (goto-char (point-max))
5715 (let ((last-line-start (point)))
5717 (set-window-start window (point) t)
5718 (when (not (pos-visible-in-window-p last-line-start window))
5720 (set-window-start window (min (point) top-pos) t)))))))
5721 ;; Do horizontal recentering while we're at it.
5722 (when (and (get-buffer-window (current-buffer) t)
5723 (not (eq gnus-auto-center-summary 'vertical)))
5724 (let ((selected (selected-window)))
5725 (select-window (get-buffer-window (current-buffer) t))
5726 (gnus-summary-position-point)
5727 (gnus-horizontal-recenter)
5728 (select-window selected))))))
5730 (defun gnus-summary-jump-to-group (newsgroup)
5731 "Move point to NEWSGROUP in group mode buffer."
5732 ;; Keep update point of group mode buffer if visible.
5733 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5734 (save-window-excursion
5735 ;; Take care of tree window mode.
5736 (when (get-buffer-window gnus-group-buffer)
5737 (pop-to-buffer gnus-group-buffer))
5738 (gnus-group-jump-to-group newsgroup))
5740 ;; Take care of tree window mode.
5741 (if (get-buffer-window gnus-group-buffer)
5742 (pop-to-buffer gnus-group-buffer)
5743 (set-buffer gnus-group-buffer))
5744 (gnus-group-jump-to-group newsgroup))))
5746 ;; This function returns a list of article numbers based on the
5747 ;; difference between the ranges of read articles in this group and
5748 ;; the range of active articles.
5749 (defun gnus-list-of-unread-articles (group)
5750 (let* ((read (gnus-info-read (gnus-get-info group)))
5751 (active (or (gnus-active group) (gnus-activate-group group)))
5754 ;; If none are read, then all are unread.
5756 (setq first (car active))
5757 ;; If the range of read articles is a single range, then the
5758 ;; first unread article is the article after the last read
5759 ;; article. Sounds logical, doesn't it?
5760 (if (and (not (listp (cdr read)))
5761 (or (< (car read) (car active))
5762 (progn (setq read (list read))
5764 (setq first (max (car active) (1+ (cdr read))))
5765 ;; `read' is a list of ranges.
5766 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5769 (setq first (car active)))
5772 (while (< first nlast)
5774 (setq first (1+ first))))
5775 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5776 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5777 (setq read (cdr read)))))
5778 ;; And add the last unread articles.
5779 (while (<= first last)
5781 (setq first (1+ first)))
5782 ;; Return the list of unread articles.
5783 (delq 0 (nreverse unread))))
5785 (defun gnus-list-of-read-articles (group)
5786 "Return a list of unread, unticked and non-dormant articles."
5787 (let* ((info (gnus-get-info group))
5788 (marked (gnus-info-marks info))
5789 (active (gnus-active group)))
5791 (gnus-set-difference
5792 (gnus-sorted-complement
5793 (gnus-uncompress-range active)
5794 (gnus-list-of-unread-articles group))
5796 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5797 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5799 ;; Various summary commands
5801 (defun gnus-summary-select-article-buffer ()
5802 "Reconfigure windows to show article buffer."
5804 (if (not (gnus-buffer-live-p gnus-article-buffer))
5805 (error "There is no article buffer for this summary buffer")
5806 (gnus-configure-windows 'article)
5807 (select-window (get-buffer-window gnus-article-buffer))))
5809 (defun gnus-summary-universal-argument (arg)
5810 "Perform any operation on all articles that are process/prefixed."
5812 (let ((articles (gnus-summary-work-articles arg))
5819 (substitute-command-keys
5820 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5822 (gnus-error 1 "Undefined key")
5825 (gnus-summary-goto-subject (setq article (pop articles)))
5826 (let (gnus-newsgroup-processable)
5827 (command-execute func))
5828 (gnus-summary-remove-process-mark article)))))
5829 (gnus-summary-position-point))
5831 (defun gnus-summary-toggle-truncation (&optional arg)
5832 "Toggle truncation of summary lines.
5833 With arg, turn line truncation on iff arg is positive."
5835 (setq truncate-lines
5836 (if (null arg) (not truncate-lines)
5837 (> (prefix-numeric-value arg) 0)))
5840 (defun gnus-summary-reselect-current-group (&optional all rescan)
5841 "Exit and then reselect the current newsgroup.
5842 The prefix argument ALL means to select all articles."
5844 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5845 (error "Ephemeral groups can't be reselected"))
5846 (let ((current-subject (gnus-summary-article-number))
5847 (group gnus-newsgroup-name))
5848 (setq gnus-newsgroup-begin nil)
5850 ;; We have to adjust the point of group mode buffer because
5851 ;; point was moved to the next unread newsgroup by exiting.
5852 (gnus-summary-jump-to-group group)
5855 (save-window-excursion
5856 ;; Don't show group contents.
5857 (set-window-start (selected-window) (point-max))
5858 (gnus-group-get-new-news-this-group 1))))
5859 (gnus-group-read-group all t)
5860 (gnus-summary-goto-subject current-subject nil t)))
5862 (defun gnus-summary-rescan-group (&optional all)
5863 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5865 (gnus-summary-reselect-current-group all t))
5867 (defun gnus-summary-update-info (&optional non-destructive)
5869 (let ((group gnus-newsgroup-name))
5871 (when gnus-newsgroup-kill-headers
5872 (setq gnus-newsgroup-killed
5873 (gnus-compress-sequence
5875 (gnus-set-sorted-intersection
5876 (gnus-uncompress-range gnus-newsgroup-killed)
5877 (setq gnus-newsgroup-unselected
5878 (sort gnus-newsgroup-unselected '<)))
5879 (setq gnus-newsgroup-unreads
5880 (sort gnus-newsgroup-unreads '<)))
5882 (unless (listp (cdr gnus-newsgroup-killed))
5883 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5884 (let ((headers gnus-newsgroup-headers))
5885 ;; Set the new ranges of read articles.
5887 (set-buffer gnus-group-buffer)
5888 (gnus-undo-force-boundary))
5889 (gnus-update-read-articles
5890 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5891 ;; Set the current article marks.
5892 (let ((gnus-newsgroup-scored
5893 (if (and (not gnus-save-score)
5894 (not non-destructive))
5896 gnus-newsgroup-scored)))
5898 (gnus-update-marks)))
5899 ;; Do the cross-ref thing.
5900 (when gnus-use-cross-reference
5901 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5902 ;; Do not switch windows but change the buffer to work.
5903 (set-buffer gnus-group-buffer)
5904 (unless (gnus-ephemeral-group-p group)
5905 (gnus-group-update-group group)))))))
5907 (defun gnus-summary-save-newsrc (&optional force)
5908 "Save the current number of read/marked articles in the dribble buffer.
5909 The dribble buffer will then be saved.
5910 If FORCE (the prefix), also save the .newsrc file(s)."
5912 (gnus-summary-update-info t)
5914 (gnus-save-newsrc-file)
5915 (gnus-dribble-save)))
5917 (defun gnus-summary-exit (&optional temporary)
5918 "Exit reading current newsgroup, and then return to group selection mode.
5919 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5921 (gnus-set-global-variables)
5922 (gnus-kill-save-kill-buffer)
5923 (gnus-async-halt-prefetch)
5924 (let* ((group gnus-newsgroup-name)
5925 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5928 (buf (current-buffer)))
5930 ;; Do adaptive scoring, and possibly save score files.
5931 (when gnus-newsgroup-adaptive
5932 (gnus-score-adaptive))
5933 (when gnus-use-scoring
5935 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5936 ;; If we have several article buffers, we kill them at exit.
5937 (unless gnus-single-article-buffer
5938 (gnus-kill-buffer gnus-original-article-buffer)
5939 (setq gnus-article-current nil))
5940 (when gnus-use-cache
5941 (gnus-cache-possibly-remove-articles)
5942 (gnus-cache-save-buffers))
5943 (gnus-async-prefetch-remove-group group)
5944 (when gnus-suppress-duplicates
5945 (gnus-dup-enter-articles))
5946 (when gnus-use-trees
5947 (gnus-tree-close group))
5948 (when gnus-use-cache
5949 (gnus-cache-write-active))
5950 ;; Remove entries for this group.
5951 (nnmail-purge-split-history (gnus-group-real-name group))
5952 ;; Make all changes in this group permanent.
5954 (gnus-run-hooks 'gnus-exit-group-hook)
5955 (gnus-summary-update-info))
5956 (gnus-close-group group)
5957 ;; Make sure where we were, and go to next newsgroup.
5958 (set-buffer gnus-group-buffer)
5960 (gnus-group-jump-to-group group))
5961 (gnus-run-hooks 'gnus-summary-exit-hook)
5962 (unless (or quit-config
5963 ;; If this group has disappeared from the summary
5964 ;; buffer, don't skip forwards.
5965 (not (string= group (gnus-group-group-name))))
5966 (gnus-group-next-unread-group 1))
5967 (setq group-point (point))
5970 ;; If we have several article buffers, we kill them at exit.
5971 (unless gnus-single-article-buffer
5972 (gnus-kill-buffer gnus-article-buffer)
5973 (gnus-kill-buffer gnus-original-article-buffer)
5974 (setq gnus-article-current nil))
5976 (if (not gnus-kill-summary-on-exit)
5978 (gnus-deaden-summary)
5980 ;; We set all buffer-local variables to nil. It is unclear why
5981 ;; this is needed, but if we don't, buffer-local variables are
5982 ;; not garbage-collected, it seems. This would the lead to en
5983 ;; ever-growing Emacs.
5984 (gnus-summary-clear-local-variables)
5985 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5986 (gnus-summary-clear-local-variables))
5987 (when (get-buffer gnus-article-buffer)
5988 (bury-buffer gnus-article-buffer))
5989 ;; We clear the global counterparts of the buffer-local
5990 ;; variables as well, just to be on the safe side.
5991 (set-buffer gnus-group-buffer)
5992 (gnus-summary-clear-local-variables)
5993 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5994 (gnus-summary-clear-local-variables)))
5995 (setq gnus-current-select-method gnus-select-method)
5996 (pop-to-buffer gnus-group-buffer)
5997 (if (not quit-config)
5999 (goto-char group-point)
6000 (gnus-configure-windows 'group 'force)
6001 (unless (pos-visible-in-window-p)
6002 (forward-line (/ (static-if (featurep 'xemacs)
6003 (window-displayed-height)
6004 (1- (window-height)))
6006 (set-window-start (selected-window) (point))
6007 (goto-char group-point)))
6008 (gnus-handle-ephemeral-exit quit-config))
6009 ;; Return to group mode buffer.
6010 (when (eq mode 'gnus-summary-mode)
6011 (gnus-kill-buffer buf))
6012 ;; Clear the current group name.
6014 (setq gnus-newsgroup-name nil)))))
6016 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6017 (defun gnus-summary-exit-no-update (&optional no-questions)
6018 "Quit reading current newsgroup without updating read article info."
6020 (let* ((group gnus-newsgroup-name)
6021 (quit-config (gnus-group-quit-config group)))
6022 (when (or no-questions
6024 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6025 (gnus-async-halt-prefetch)
6027 (delq 'gnus-summary-expire-articles
6028 (copy-sequence gnus-summary-prepare-exit-hook)))
6029 ;; If we have several article buffers, we kill them at exit.
6030 (unless gnus-single-article-buffer
6031 (gnus-kill-buffer gnus-article-buffer)
6032 (gnus-kill-buffer gnus-original-article-buffer)
6033 (setq gnus-article-current nil))
6034 (if (not gnus-kill-summary-on-exit)
6035 (gnus-deaden-summary)
6036 (gnus-close-group group)
6037 (gnus-summary-clear-local-variables)
6038 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6039 (gnus-summary-clear-local-variables))
6040 (set-buffer gnus-group-buffer)
6041 (gnus-summary-clear-local-variables)
6042 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6043 (gnus-summary-clear-local-variables))
6044 (when (get-buffer gnus-summary-buffer)
6045 (kill-buffer gnus-summary-buffer)))
6046 (unless gnus-single-article-buffer
6047 (setq gnus-article-current nil))
6048 (when gnus-use-trees
6049 (gnus-tree-close group))
6050 (gnus-async-prefetch-remove-group group)
6051 (when (get-buffer gnus-article-buffer)
6052 (bury-buffer gnus-article-buffer))
6053 ;; Return to the group buffer.
6054 (gnus-configure-windows 'group 'force)
6055 ;; Clear the current group name.
6056 (setq gnus-newsgroup-name nil)
6057 (when (equal (gnus-group-group-name) group)
6058 (gnus-group-next-unread-group 1))
6060 (gnus-handle-ephemeral-exit quit-config)))))
6062 (defun gnus-handle-ephemeral-exit (quit-config)
6063 "Handle movement when leaving an ephemeral group.
6064 The state which existed when entering the ephemeral is reset."
6065 (if (not (buffer-name (car quit-config)))
6066 (gnus-configure-windows 'group 'force)
6067 (set-buffer (car quit-config))
6068 (cond ((eq major-mode 'gnus-summary-mode)
6069 (gnus-set-global-variables))
6070 ((eq major-mode 'gnus-article-mode)
6072 ;; The `gnus-summary-buffer' variable may point
6073 ;; to the old summary buffer when using a single
6075 (unless (gnus-buffer-live-p gnus-summary-buffer)
6076 (set-buffer gnus-group-buffer))
6077 (set-buffer gnus-summary-buffer)
6078 (gnus-set-global-variables))))
6079 (if (or (eq (cdr quit-config) 'article)
6080 (eq (cdr quit-config) 'pick))
6082 ;; The current article may be from the ephemeral group
6083 ;; thus it is best that we reload this article
6084 (gnus-summary-show-article)
6085 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6086 (gnus-configure-windows 'pick 'force)
6087 (gnus-configure-windows (cdr quit-config) 'force)))
6088 (gnus-configure-windows (cdr quit-config) 'force))
6089 (when (eq major-mode 'gnus-summary-mode)
6090 (gnus-summary-next-subject 1 nil t)
6091 (gnus-summary-recenter)
6092 (gnus-summary-position-point))))
6094 (defun gnus-summary-preview-mime-message ()
6095 "MIME decode and play this message."
6097 (let ((gnus-break-pages nil)
6099 (gnus-summary-select-article gnus-show-all-headers t))
6100 (select-window (get-buffer-window gnus-article-buffer)))
6104 (defvar gnus-dead-summary-mode-map nil)
6106 (unless gnus-dead-summary-mode-map
6107 (setq gnus-dead-summary-mode-map (make-keymap))
6108 (suppress-keymap gnus-dead-summary-mode-map)
6109 (substitute-key-definition
6110 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6111 (let ((keys '("\C-d" "\r" "\177" [delete])))
6113 (define-key gnus-dead-summary-mode-map
6114 (pop keys) 'gnus-summary-wake-up-the-dead))))
6116 (defvar gnus-dead-summary-mode nil
6117 "Minor mode for Gnus summary buffers.")
6119 (defun gnus-dead-summary-mode (&optional arg)
6120 "Minor mode for Gnus summary buffers."
6122 (when (eq major-mode 'gnus-summary-mode)
6123 (make-local-variable 'gnus-dead-summary-mode)
6124 (setq gnus-dead-summary-mode
6125 (if (null arg) (not gnus-dead-summary-mode)
6126 (> (prefix-numeric-value arg) 0)))
6127 (when gnus-dead-summary-mode
6128 (gnus-add-minor-mode
6129 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6131 (defun gnus-deaden-summary ()
6132 "Make the current summary buffer into a dead summary buffer."
6133 ;; Kill any previous dead summary buffer.
6134 (when (and gnus-dead-summary
6135 (buffer-name gnus-dead-summary))
6137 (set-buffer gnus-dead-summary)
6138 (when gnus-dead-summary-mode
6139 (kill-buffer (current-buffer)))))
6140 ;; Make this the current dead summary.
6141 (setq gnus-dead-summary (current-buffer))
6142 (gnus-dead-summary-mode 1)
6143 (let ((name (buffer-name)))
6144 (when (string-match "Summary" name)
6146 (concat (substring name 0 (match-beginning 0)) "Dead "
6147 (substring name (match-beginning 0)))
6151 (defun gnus-kill-or-deaden-summary (buffer)
6152 "Kill or deaden the summary BUFFER."
6154 (when (and (buffer-name buffer)
6155 (not gnus-single-article-buffer))
6158 (gnus-kill-buffer gnus-article-buffer)
6159 (gnus-kill-buffer gnus-original-article-buffer)))
6160 (cond (gnus-kill-summary-on-exit
6161 (when (and gnus-use-trees
6162 (gnus-buffer-exists-p buffer))
6165 (gnus-tree-close gnus-newsgroup-name)))
6166 (gnus-kill-buffer buffer))
6167 ((gnus-buffer-exists-p buffer)
6170 (gnus-deaden-summary))))))
6172 (defun gnus-summary-wake-up-the-dead (&rest args)
6173 "Wake up the dead summary buffer."
6175 (gnus-dead-summary-mode -1)
6176 (let ((name (buffer-name)))
6177 (when (string-match "Dead " name)
6179 (concat (substring name 0 (match-beginning 0))
6180 (substring name (match-end 0)))
6182 (gnus-message 3 "This dead summary is now alive again"))
6184 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6185 (defun gnus-summary-fetch-faq (&optional faq-dir)
6186 "Fetch the FAQ for the current group.
6187 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6191 (when current-prefix-arg
6193 "Faq dir: " (and (listp gnus-group-faq-directory)
6194 (mapcar (lambda (file) (list file))
6195 gnus-group-faq-directory))))))
6196 (let (gnus-faq-buffer)
6197 (when (setq gnus-faq-buffer
6198 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6199 (gnus-configure-windows 'summary-faq))))
6201 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6202 (defun gnus-summary-describe-group (&optional force)
6203 "Describe the current newsgroup."
6205 (gnus-group-describe-group force gnus-newsgroup-name))
6207 (defun gnus-summary-describe-briefly ()
6208 "Describe summary mode commands briefly."
6210 (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")))
6212 ;; Walking around group mode buffer from summary mode.
6214 (defun gnus-summary-next-group (&optional no-article target-group backward)
6215 "Exit current newsgroup and then select next unread newsgroup.
6216 If prefix argument NO-ARTICLE is non-nil, no article is selected
6217 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6218 previous group instead."
6220 ;; Stop pre-fetching.
6221 (gnus-async-halt-prefetch)
6222 (let ((current-group gnus-newsgroup-name)
6223 (current-buffer (current-buffer))
6225 ;; First we semi-exit this group to update Xrefs and all variables.
6226 ;; We can't do a real exit, because the window conf must remain
6227 ;; the same in case the user is prompted for info, and we don't
6228 ;; want the window conf to change before that...
6229 (gnus-summary-exit t)
6230 (while (not entered)
6231 ;; Then we find what group we are supposed to enter.
6232 (set-buffer gnus-group-buffer)
6233 (gnus-group-jump-to-group current-group)
6236 (if (eq gnus-keep-same-level 'best)
6237 (gnus-summary-best-group gnus-newsgroup-name)
6238 (gnus-summary-search-group backward gnus-keep-same-level))))
6239 (if (not target-group)
6240 ;; There are no further groups, so we return to the group
6243 (gnus-message 5 "Returning to the group buffer")
6245 (when (gnus-buffer-live-p current-buffer)
6246 (set-buffer current-buffer)
6247 (gnus-summary-exit))
6248 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6249 ;; We try to enter the target group.
6250 (gnus-group-jump-to-group target-group)
6251 (let ((unreads (gnus-group-group-unread)))
6252 (if (and (or (eq t unreads)
6253 (and unreads (not (zerop unreads))))
6254 (gnus-summary-read-group
6255 target-group nil no-article
6256 (and (buffer-name current-buffer) current-buffer)
6259 (setq current-group target-group
6260 target-group nil)))))))
6262 (defun gnus-summary-prev-group (&optional no-article)
6263 "Exit current newsgroup and then select previous unread newsgroup.
6264 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6266 (gnus-summary-next-group no-article nil t))
6268 ;; Walking around summary lines.
6270 (defun gnus-summary-first-subject (&optional unread undownloaded)
6271 "Go to the first unread subject.
6272 If UNREAD is non-nil, go to the first unread article.
6273 Returns the article selected or nil if there are no unread articles."
6278 ((null gnus-newsgroup-data)
6279 (gnus-message 3 "No articles in the group")
6281 ;; Pick the first article.
6283 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6284 (gnus-data-number (car gnus-newsgroup-data)))
6285 ;; No unread articles.
6286 ((null gnus-newsgroup-unreads)
6287 (gnus-message 3 "No more unread articles")
6289 ;; Find the first unread article.
6291 (let ((data gnus-newsgroup-data))
6293 (and (not (and undownloaded
6294 (eq gnus-undownloaded-mark
6295 (gnus-data-mark (car data)))))
6296 (not (gnus-data-unread-p (car data)))))
6297 (setq data (cdr data)))
6299 (goto-char (gnus-data-pos (car data)))
6300 (gnus-data-number (car data))))))
6301 (gnus-summary-position-point)))
6303 (defun gnus-summary-next-subject (n &optional unread dont-display)
6304 "Go to next N'th summary line.
6305 If N is negative, go to the previous N'th subject line.
6306 If UNREAD is non-nil, only unread articles are selected.
6307 The difference between N and the actual number of steps taken is
6310 (let ((backward (< n 0))
6314 (gnus-summary-find-prev unread)
6315 (gnus-summary-find-next unread)))
6316 (unless (zerop (setq n (1- n)))
6317 (gnus-summary-show-thread)))
6319 (gnus-message 7 "No more%s articles"
6320 (if unread " unread" "")))
6321 (unless dont-display
6322 (gnus-summary-recenter)
6323 (gnus-summary-position-point))
6326 (defun gnus-summary-next-unread-subject (n)
6327 "Go to next N'th unread summary line."
6329 (gnus-summary-next-subject n t))
6331 (defun gnus-summary-prev-subject (n &optional unread)
6332 "Go to previous N'th summary line.
6333 If optional argument UNREAD is non-nil, only unread article is selected."
6335 (gnus-summary-next-subject (- n) unread))
6337 (defun gnus-summary-prev-unread-subject (n)
6338 "Go to previous N'th unread summary line."
6340 (gnus-summary-next-subject (- n) t))
6342 (defun gnus-summary-goto-subject (article &optional force silent)
6343 "Go the subject line of ARTICLE.
6344 If FORCE, also allow jumping to articles not currently shown."
6345 (interactive "nArticle number: ")
6347 (data (gnus-data-find article)))
6348 ;; We read in the article if we have to.
6351 (gnus-summary-insert-subject
6353 (if (or (numberp force) (vectorp force)) force)
6355 (setq data (gnus-data-find article)))
6360 (gnus-message 3 "Can't find article %d" article))
6362 (let ((pt (gnus-data-pos data)))
6364 (gnus-summary-set-article-display-arrow pt))
6365 (gnus-summary-position-point)
6368 ;; Walking around summary lines with displaying articles.
6370 (defun gnus-summary-expand-window (&optional arg)
6371 "Make the summary buffer take up the entire Emacs frame.
6372 Given a prefix, will force an `article' buffer configuration."
6375 (gnus-configure-windows 'article 'force)
6376 (gnus-configure-windows 'summary 'force)))
6378 (defun gnus-summary-display-article (article &optional all-header)
6379 "Display ARTICLE in article buffer."
6380 (when (gnus-buffer-live-p gnus-article-buffer)
6381 (with-current-buffer gnus-article-buffer
6382 (set-buffer-multibyte t)))
6383 (gnus-set-global-variables)
6384 (when (gnus-buffer-live-p gnus-article-buffer)
6385 (with-current-buffer gnus-article-buffer
6386 (setq gnus-article-charset gnus-newsgroup-charset)
6387 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)))
6391 (if gnus-summary-display-article-function
6392 (funcall gnus-summary-display-article-function article all-header)
6393 (gnus-article-prepare article all-header))
6394 (with-current-buffer gnus-article-buffer
6395 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6397 (gnus-run-hooks 'gnus-select-article-hook)
6398 (when (and gnus-current-article
6399 (not (zerop gnus-current-article)))
6400 (gnus-summary-goto-subject gnus-current-article))
6401 (gnus-summary-recenter)
6402 (when (and gnus-use-trees gnus-show-threads)
6403 (gnus-possibly-generate-tree article)
6404 (gnus-highlight-selected-tree article))
6405 ;; Successfully display article.
6406 (gnus-article-set-window-start
6407 (cdr (assq article gnus-newsgroup-bookmarks))))))
6409 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6410 "Select the current article.
6411 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6412 non-nil, the article will be re-fetched even if it already present in
6413 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6415 ;; Make sure we are in the summary buffer to work around bbdb bug.
6416 (unless (eq major-mode 'gnus-summary-mode)
6417 (set-buffer gnus-summary-buffer))
6418 (let ((article (or article (gnus-summary-article-number)))
6419 (all-headers (not (not all-headers))) ;Must be T or NIL.
6420 gnus-summary-display-article-function)
6422 (gnus-summary-article-pseudo-p article)
6423 (error "This is a pseudo-article"))
6425 (set-buffer gnus-summary-buffer)
6426 (if (or (and gnus-single-article-buffer
6427 (or (null gnus-current-article)
6428 (null gnus-article-current)
6429 (null (get-buffer gnus-article-buffer))
6430 (not (eq article (cdr gnus-article-current)))
6431 (not (equal (car gnus-article-current)
6432 gnus-newsgroup-name))))
6433 (and (not gnus-single-article-buffer)
6434 (or (null gnus-current-article)
6435 (not (eq gnus-current-article article))))
6437 ;; The requested article is different from the current article.
6439 (gnus-summary-display-article article all-headers)
6440 (when (or all-headers gnus-show-all-headers)
6441 (gnus-article-show-all-headers))
6442 (gnus-article-set-window-start
6443 (cdr (assq article gnus-newsgroup-bookmarks)))
6445 (when (or all-headers gnus-show-all-headers)
6446 (gnus-article-show-all-headers))
6449 (defun gnus-summary-force-verify-and-decrypt ()
6451 (let ((mm-verify-option 'known)
6452 (mm-decrypt-option 'known))
6453 (gnus-summary-select-article nil 'force)))
6455 (defun gnus-summary-set-current-mark (&optional current-mark)
6456 "Obsolete function."
6459 (defun gnus-summary-next-article (&optional unread subject backward push)
6460 "Select the next article.
6461 If UNREAD, only unread articles are selected.
6462 If SUBJECT, only articles with SUBJECT are selected.
6463 If BACKWARD, the previous article is selected instead of the next."
6466 ;; Is there such an article?
6467 ((and (gnus-summary-search-forward unread subject backward)
6468 (or (gnus-summary-display-article (gnus-summary-article-number))
6469 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6470 (gnus-summary-position-point))
6471 ;; If not, we try the first unread, if that is wanted.
6473 gnus-auto-select-same
6474 (gnus-summary-first-unread-article))
6475 (gnus-summary-position-point)
6476 (gnus-message 6 "Wrapped"))
6477 ;; Try to get next/previous article not displayed in this group.
6478 ((and gnus-auto-extend-newsgroup
6479 (not unread) (not subject))
6480 (gnus-summary-goto-article
6481 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6482 nil (count-lines (point-min) (point))))
6483 ;; Go to next/previous group.
6485 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6486 (gnus-summary-jump-to-group gnus-newsgroup-name))
6487 (let ((cmd last-command-char)
6490 (set-buffer gnus-group-buffer)
6493 (if (eq gnus-keep-same-level 'best)
6494 (gnus-summary-best-group gnus-newsgroup-name)
6495 (gnus-summary-search-group backward gnus-keep-same-level))))
6496 ;; For some reason, the group window gets selected. We change
6498 (select-window (get-buffer-window (current-buffer)))
6499 ;; Select next unread newsgroup automagically.
6501 ((or (not gnus-auto-select-next)
6503 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6504 ((or (eq gnus-auto-select-next 'quietly)
6505 (and (eq gnus-auto-select-next 'slightly-quietly)
6507 (and (eq gnus-auto-select-next 'almost-quietly)
6508 (gnus-summary-last-article-p)))
6510 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6512 (gnus-message 7 "No more%s articles (%s)..."
6513 (if unread " unread" "")
6514 (if group (concat "selecting " group)
6516 (gnus-summary-next-group nil group backward)))
6518 (when (gnus-key-press-event-p last-input-event)
6519 (gnus-summary-walk-group-buffer
6520 gnus-newsgroup-name cmd unread backward point))))))))
6522 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6523 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6524 (?\C-p (gnus-group-prev-unread-group 1))))
6525 (cursor-in-echo-area t)
6526 keve key group ended)
6528 (set-buffer gnus-group-buffer)
6531 (if (eq gnus-keep-same-level 'best)
6532 (gnus-summary-best-group gnus-newsgroup-name)
6533 (gnus-summary-search-group backward gnus-keep-same-level))))
6536 5 "No more%s articles%s" (if unread " unread" "")
6538 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6539 (format " (Type %s for %s [%s])"
6540 (single-key-description cmd) group
6541 (car (gnus-gethash group gnus-newsrc-hashtb)))
6542 (format " (Type %s to exit %s)"
6543 (single-key-description cmd)
6544 gnus-newsgroup-name)))
6545 ;; Confirm auto selection.
6546 (setq key (car (setq keve (gnus-read-event-char))))
6549 ((assq key keystrokes)
6550 (let ((obuf (current-buffer)))
6551 (switch-to-buffer gnus-group-buffer)
6553 (gnus-group-jump-to-group group))
6554 (eval (cadr (assq key keystrokes)))
6555 (setq group (gnus-group-group-name))
6556 (switch-to-buffer obuf))
6560 (gnus-ephemeral-group-p gnus-newsgroup-name))
6562 (gnus-summary-next-group nil group backward)))
6564 (push (cdr keve) unread-command-events))))))
6566 (defun gnus-summary-next-unread-article ()
6567 "Select unread article after current one."
6569 (gnus-summary-next-article
6570 (or (not (eq gnus-summary-goto-unread 'never))
6571 (gnus-summary-last-article-p (gnus-summary-article-number)))
6572 (and gnus-auto-select-same
6573 (gnus-summary-article-subject))))
6575 (defun gnus-summary-prev-article (&optional unread subject)
6576 "Select the article after the current one.
6577 If UNREAD is non-nil, only unread articles are selected."
6579 (gnus-summary-next-article unread subject t))
6581 (defun gnus-summary-prev-unread-article ()
6582 "Select unread article before current one."
6584 (gnus-summary-prev-article
6585 (or (not (eq gnus-summary-goto-unread 'never))
6586 (gnus-summary-first-article-p (gnus-summary-article-number)))
6587 (and gnus-auto-select-same
6588 (gnus-summary-article-subject))))
6590 (defun gnus-summary-next-page (&optional lines circular)
6591 "Show next page of the selected article.
6592 If at the end of the current article, select the next article.
6593 LINES says how many lines should be scrolled up.
6595 If CIRCULAR is non-nil, go to the start of the article instead of
6596 selecting the next article when reaching the end of the current
6599 (setq gnus-summary-buffer (current-buffer))
6600 (gnus-set-global-variables)
6601 (let ((article (gnus-summary-article-number))
6602 (article-window (get-buffer-window gnus-article-buffer t))
6604 ;; If the buffer is empty, we have no article.
6606 (error "No article to select"))
6607 (gnus-configure-windows 'article)
6608 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6609 (if (and (eq gnus-summary-goto-unread 'never)
6610 (not (gnus-summary-last-article-p article)))
6611 (gnus-summary-next-article)
6612 (gnus-summary-next-unread-article))
6613 (if (or (null gnus-current-article)
6614 (null gnus-article-current)
6615 (/= article (cdr gnus-article-current))
6616 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6617 ;; Selected subject is different from current article's.
6618 (gnus-summary-display-article article)
6619 (when article-window
6620 (gnus-eval-in-buffer-window gnus-article-buffer
6621 (setq endp (gnus-article-next-page lines)))
6624 (gnus-summary-beginning-of-article))
6626 (gnus-message 3 "End of message"))
6628 (if (and (eq gnus-summary-goto-unread 'never)
6629 (not (gnus-summary-last-article-p article)))
6630 (gnus-summary-next-article)
6631 (gnus-summary-next-unread-article))))))))
6632 (gnus-summary-recenter)
6633 (gnus-summary-position-point)))
6635 (defun gnus-summary-prev-page (&optional lines move)
6636 "Show previous page of selected article.
6637 Argument LINES specifies lines to be scrolled down.
6638 If MOVE, move to the previous unread article if point is at
6639 the beginning of the buffer."
6641 (let ((article (gnus-summary-article-number))
6642 (article-window (get-buffer-window gnus-article-buffer t))
6644 (gnus-configure-windows 'article)
6645 (if (or (null gnus-current-article)
6646 (null gnus-article-current)
6647 (/= article (cdr gnus-article-current))
6648 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6649 ;; Selected subject is different from current article's.
6650 (gnus-summary-display-article article)
6651 (gnus-summary-recenter)
6652 (when article-window
6653 (gnus-eval-in-buffer-window gnus-article-buffer
6654 (setq endp (gnus-article-prev-page lines)))
6655 (when (and move endp)
6657 (gnus-message 3 "Beginning of message"))
6659 (if (and (eq gnus-summary-goto-unread 'never)
6660 (not (gnus-summary-first-article-p article)))
6661 (gnus-summary-prev-article)
6662 (gnus-summary-prev-unread-article))))))))
6663 (gnus-summary-position-point))
6665 (defun gnus-summary-prev-page-or-article (&optional lines)
6666 "Show previous page of selected article.
6667 Argument LINES specifies lines to be scrolled down.
6668 If at the beginning of the article, go to the next article."
6670 (gnus-summary-prev-page lines t))
6672 (defun gnus-summary-scroll-up (lines)
6673 "Scroll up (or down) one line current article.
6674 Argument LINES specifies lines to be scrolled up (or down if negative)."
6676 (gnus-configure-windows 'article)
6677 (gnus-summary-show-thread)
6678 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6679 (gnus-eval-in-buffer-window gnus-article-buffer
6681 (when (gnus-article-next-page lines)
6682 (gnus-message 3 "End of message")))
6684 (gnus-article-prev-page (- lines))))))
6685 (gnus-summary-recenter)
6686 (gnus-summary-position-point))
6688 (defun gnus-summary-scroll-down (lines)
6689 "Scroll down (or up) one line current article.
6690 Argument LINES specifies lines to be scrolled down (or up if negative)."
6692 (gnus-summary-scroll-up (- lines)))
6694 (defun gnus-summary-next-same-subject ()
6695 "Select next article which has the same subject as current one."
6697 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6699 (defun gnus-summary-prev-same-subject ()
6700 "Select previous article which has the same subject as current one."
6702 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6704 (defun gnus-summary-next-unread-same-subject ()
6705 "Select next unread article which has the same subject as current one."
6707 (gnus-summary-next-article t (gnus-summary-article-subject)))
6709 (defun gnus-summary-prev-unread-same-subject ()
6710 "Select previous unread article which has the same subject as current one."
6712 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6714 (defun gnus-summary-first-unread-article ()
6715 "Select the first unread article.
6716 Return nil if there are no unread articles."
6719 (when (gnus-summary-first-subject t)
6720 (gnus-summary-show-thread)
6721 (gnus-summary-first-subject t)
6722 (gnus-summary-display-article (gnus-summary-article-number)))
6723 (gnus-summary-position-point)))
6725 (defun gnus-summary-first-unread-subject ()
6726 "Place the point on the subject line of the first unread article.
6727 Return nil if there are no unread articles."
6730 (when (gnus-summary-first-subject t)
6731 (gnus-summary-show-thread)
6732 (gnus-summary-first-subject t))
6733 (gnus-summary-position-point)))
6735 (defun gnus-summary-first-article ()
6736 "Select the first article.
6737 Return nil if there are no articles."
6740 (when (gnus-summary-first-subject)
6741 (gnus-summary-show-thread)
6742 (gnus-summary-first-subject)
6743 (gnus-summary-display-article (gnus-summary-article-number)))
6744 (gnus-summary-position-point)))
6746 (defun gnus-summary-best-unread-article ()
6747 "Select the unread article with the highest score."
6749 (let ((best -1000000)
6750 (data gnus-newsgroup-data)
6753 (and (gnus-data-unread-p (car data))
6755 (gnus-summary-article-score (gnus-data-number (car data))))
6758 article (gnus-data-number (car data))))
6759 (setq data (cdr data)))
6762 (gnus-summary-goto-article article)
6763 (error "No unread articles"))
6764 (gnus-summary-position-point))))
6766 (defun gnus-summary-last-subject ()
6767 "Go to the last displayed subject line in the group."
6768 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6770 (gnus-summary-goto-subject article))))
6772 (defun gnus-summary-goto-article (article &optional all-headers force)
6773 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6774 If ALL-HEADERS is non-nil, no header lines are hidden.
6775 If FORCE, go to the article even if it isn't displayed. If FORCE
6776 is a number, it is the line the article is to be displayed on."
6780 "Article number or Message-ID: "
6781 (mapcar (lambda (number) (list (int-to-string number)))
6782 gnus-newsgroup-limit))
6786 (if (and (stringp article)
6787 (string-match "@" article))
6788 (gnus-summary-refer-article article)
6789 (when (stringp article)
6790 (setq article (string-to-number article)))
6791 (if (gnus-summary-goto-subject article force)
6792 (gnus-summary-display-article article all-headers)
6793 (gnus-message 4 "Couldn't go to article %s" article) nil))
6794 (gnus-summary-position-point)))
6796 (defun gnus-summary-goto-last-article ()
6797 "Go to the previously read article."
6800 (when gnus-last-article
6801 (gnus-summary-goto-article gnus-last-article nil t))
6802 (gnus-summary-position-point)))
6804 (defun gnus-summary-pop-article (number)
6805 "Pop one article off the history and go to the previous.
6806 NUMBER articles will be popped off."
6809 (setq gnus-newsgroup-history
6810 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6812 (gnus-summary-goto-article (car to) nil t)
6813 (error "Article history empty")))
6814 (gnus-summary-position-point))
6816 ;; Summary commands and functions for limiting the summary buffer.
6818 (defun gnus-summary-limit-to-articles (n)
6819 "Limit the summary buffer to the next N articles.
6820 If not given a prefix, use the process marked articles instead."
6823 (let ((articles (gnus-summary-work-articles n)))
6824 (setq gnus-newsgroup-processable nil)
6825 (gnus-summary-limit articles))
6826 (gnus-summary-position-point)))
6828 (defun gnus-summary-pop-limit (&optional total)
6829 "Restore the previous limit.
6830 If given a prefix, remove all limits."
6833 (setq gnus-newsgroup-limits
6834 (list (mapcar (lambda (h) (mail-header-number h))
6835 gnus-newsgroup-headers))))
6836 (unless gnus-newsgroup-limits
6837 (error "No limit to pop"))
6839 (gnus-summary-limit nil 'pop)
6840 (gnus-summary-position-point)))
6842 (defun gnus-summary-limit-to-subject (subject &optional header)
6843 "Limit the summary buffer to articles that have subjects that match a regexp."
6844 (interactive "sLimit to subject (regexp): ")
6846 (setq header "subject"))
6847 (when (not (equal "" subject))
6849 (let ((articles (gnus-summary-find-matching
6850 (or header "subject") subject 'all)))
6852 (error "Found no matches for \"%s\"" subject))
6853 (gnus-summary-limit articles))
6854 (gnus-summary-position-point))))
6856 (defun gnus-summary-limit-to-author (from)
6857 "Limit the summary buffer to articles that have authors that match a regexp."
6858 (interactive "sLimit to author (regexp): ")
6859 (gnus-summary-limit-to-subject from "from"))
6861 (defun gnus-summary-limit-to-age (age &optional younger-p)
6862 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6863 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6864 articles that are younger than AGE days."
6866 (let ((younger current-prefix-arg)
6869 (while (not days-got)
6870 (setq days (if younger
6871 (read-string "Limit to articles within (in days): ")
6872 (read-string "Limit to articles older than (in days): ")))
6873 (when (> (length days) 0)
6874 (setq days (read days)))
6877 (message "Please enter a number.")
6879 (list days younger)))
6881 (let ((data gnus-newsgroup-data)
6882 (cutoff (days-to-time age))
6883 articles d date is-younger)
6884 (while (setq d (pop data))
6885 (when (and (vectorp (gnus-data-header d))
6886 (setq date (mail-header-date (gnus-data-header d))))
6887 (setq is-younger (time-less-p
6888 (time-since (condition-case ()
6895 (push (gnus-data-number d) articles))))
6896 (gnus-summary-limit (nreverse articles)))
6897 (gnus-summary-position-point)))
6899 (defun gnus-summary-limit-to-extra (header regexp)
6900 "Limit the summary buffer to articles that match an 'extra' header."
6904 (gnus-completing-read
6905 (symbol-name (car gnus-extra-headers))
6906 "Limit extra header:"
6908 (cons (symbol-name x) x))
6913 (read-string (format "Limit to header %s (regexp): " header)))))
6914 (when (not (equal "" regexp))
6916 (let ((articles (gnus-summary-find-matching
6917 (cons 'extra header) regexp 'all)))
6919 (error "Found no matches for \"%s\"" regexp))
6920 (gnus-summary-limit articles))
6921 (gnus-summary-position-point))))
6923 (defun gnus-summary-limit-to-display-predicate ()
6924 "Limit the summary buffer to the predicated in the `display' group parameter."
6926 (unless gnus-newsgroup-display
6927 (error "There is no `diplay' group parameter"))
6929 (dolist (number gnus-newsgroup-articles)
6930 (when (funcall gnus-newsgroup-display)
6931 (push number articles)))
6932 (gnus-summary-limit articles))
6933 (gnus-summary-position-point))
6935 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6937 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6939 (defun gnus-summary-limit-to-unread (&optional all)
6940 "Limit the summary buffer to articles that are not marked as read.
6941 If ALL is non-nil, limit strictly to unread articles."
6944 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6945 (gnus-summary-limit-to-marks
6946 ;; Concat all the marks that say that an article is read and have
6948 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6949 gnus-killed-mark gnus-kill-file-mark
6950 gnus-low-score-mark gnus-expirable-mark
6951 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6952 gnus-duplicate-mark gnus-souped-mark)
6955 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6956 (make-obsolete 'gnus-summary-delete-marked-with
6957 'gnus-summary-limit-exlude-marks)
6959 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6960 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6961 If REVERSE, limit the summary buffer to articles that are marked
6962 with MARKS. MARKS can either be a string of marks or a list of marks.
6963 Returns how many articles were removed."
6964 (interactive "sMarks: ")
6965 (gnus-summary-limit-to-marks marks t))
6967 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6968 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6969 If REVERSE (the prefix), limit the summary buffer to articles that are
6970 not marked with MARKS. MARKS can either be a string of marks or a
6972 Returns how many articles were removed."
6973 (interactive "sMarks: \nP")
6975 (let ((data gnus-newsgroup-data)
6976 (marks (if (listp marks) marks
6977 (append marks nil))) ; Transform to list.
6980 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6981 (memq (gnus-data-mark (car data)) marks))
6982 (push (gnus-data-number (car data)) articles))
6983 (setq data (cdr data)))
6984 (gnus-summary-limit articles))
6985 (gnus-summary-position-point)))
6987 (defun gnus-summary-limit-to-score (&optional score)
6988 "Limit to articles with score at or above SCORE."
6990 (setq score (if score
6991 (prefix-numeric-value score)
6992 (or gnus-summary-default-score 0)))
6993 (let ((data gnus-newsgroup-data)
6996 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6998 (push (gnus-data-number (car data)) articles))
6999 (setq data (cdr data)))
7001 (gnus-summary-limit articles)
7002 (gnus-summary-position-point))))
7004 (defun gnus-summary-limit-include-thread (id)
7005 "Display all the hidden articles that is in the thread with ID in it.
7006 When called interactively, ID is the Message-ID of the current
7008 (interactive (list (mail-header-id (gnus-summary-article-header))))
7009 (let ((articles (gnus-articles-in-thread
7010 (gnus-id-to-thread (gnus-root-id id)))))
7012 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7013 (gnus-summary-limit-include-matching-articles
7015 (regexp-quote (gnus-simplify-subject-re
7016 (mail-header-subject (gnus-id-to-header id)))))
7017 (gnus-summary-position-point))))
7019 (defun gnus-summary-limit-include-matching-articles (header regexp)
7020 "Display all the hidden articles that have HEADERs that match REGEXP."
7021 (interactive (list (read-string "Match on header: ")
7022 (read-string "Regexp: ")))
7023 (let ((articles (gnus-find-matching-articles header regexp)))
7025 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7026 (gnus-summary-position-point))))
7028 (defun gnus-summary-limit-include-dormant ()
7029 "Display all the hidden articles that are marked as dormant.
7030 Note that this command only works on a subset of the articles currently
7031 fetched for this group."
7033 (unless gnus-newsgroup-dormant
7034 (error "There are no dormant articles in this group"))
7036 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7037 (gnus-summary-position-point)))
7039 (defun gnus-summary-limit-exclude-dormant ()
7040 "Hide all dormant articles."
7043 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7044 (gnus-summary-position-point)))
7046 (defun gnus-summary-limit-exclude-childless-dormant ()
7047 "Hide all dormant articles that have no children."
7049 (let ((data (gnus-data-list t))
7050 articles d children)
7051 ;; Find all articles that are either not dormant or have
7053 (while (setq d (pop data))
7054 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7056 (gnus-article-children (gnus-data-number d)))
7059 (when (memq (car children) articles)
7064 (push (gnus-data-number d) articles)))
7067 (gnus-summary-limit articles)
7068 (gnus-summary-position-point))))
7070 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7071 "Mark all unread excluded articles as read.
7072 If ALL, mark even excluded ticked and dormants as read."
7074 (let ((articles (gnus-sorted-complement
7076 (mapcar (lambda (h) (mail-header-number h))
7077 gnus-newsgroup-headers)
7079 (sort gnus-newsgroup-limit '<)))
7081 (setq gnus-newsgroup-unreads
7082 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
7084 (setq gnus-newsgroup-dormant nil
7085 gnus-newsgroup-marked nil
7086 gnus-newsgroup-reads
7088 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7089 gnus-newsgroup-reads))
7090 (while (setq article (pop articles))
7091 (unless (or (memq article gnus-newsgroup-dormant)
7092 (memq article gnus-newsgroup-marked))
7093 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7095 (defun gnus-summary-limit (articles &optional pop)
7097 ;; We pop the previous limit off the stack and use that.
7098 (setq articles (car gnus-newsgroup-limits)
7099 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7100 ;; We use the new limit, so we push the old limit on the stack.
7101 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7103 (setq gnus-newsgroup-limit articles)
7104 (let ((total (length gnus-newsgroup-data))
7105 (data (gnus-data-find-list (gnus-summary-article-number)))
7106 (gnus-summary-mark-below nil) ; Inhibit this.
7108 ;; This will do all the work of generating the new summary buffer
7109 ;; according to the new limit.
7110 (gnus-summary-prepare)
7111 ;; Hide any threads, possibly.
7112 (and gnus-show-threads
7113 gnus-thread-hide-subtree
7114 (gnus-summary-hide-all-threads))
7115 ;; Try to return to the article you were at, or one in the
7118 ;; We try to find some article after the current one.
7120 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7123 (setq data (cdr data))))
7125 ;; If there is no data, that means that we were after the last
7126 ;; article. The same goes when we can't find any articles
7127 ;; after the current one.
7128 (goto-char (point-max))
7129 (gnus-summary-find-prev))
7130 (gnus-set-mode-line 'summary)
7131 ;; We return how many articles were removed from the summary
7132 ;; buffer as a result of the new limit.
7133 (- total (length gnus-newsgroup-data))))
7135 (defsubst gnus-invisible-cut-children (threads)
7138 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7143 (defsubst gnus-cut-thread (thread)
7144 "Go forwards in the thread until we find an article that we want to display."
7145 (when (or (eq gnus-fetch-old-headers 'some)
7146 (eq gnus-fetch-old-headers 'invisible)
7147 (numberp gnus-fetch-old-headers)
7148 (eq gnus-build-sparse-threads 'some)
7149 (eq gnus-build-sparse-threads 'more))
7150 ;; Deal with old-fetched headers and sparse threads.
7154 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7155 (gnus-summary-article-ancient-p
7156 (mail-header-number (car thread))))
7157 (if (or (<= (length (cdr thread)) 1)
7158 (eq gnus-fetch-old-headers 'invisible))
7159 (setq gnus-newsgroup-limit
7160 (delq (mail-header-number (car thread))
7161 gnus-newsgroup-limit)
7162 thread (cadr thread))
7163 (when (gnus-invisible-cut-children (cdr thread))
7164 (let ((th (cdr thread)))
7166 (if (memq (mail-header-number (caar th))
7167 gnus-newsgroup-limit)
7168 (setq thread (car th)
7170 (setq th (cdr th))))))))))
7173 (defun gnus-cut-threads (threads)
7174 "Cut off all uninteresting articles from the beginning of threads."
7175 (when (or (eq gnus-fetch-old-headers 'some)
7176 (eq gnus-fetch-old-headers 'invisible)
7177 (numberp gnus-fetch-old-headers)
7178 (eq gnus-build-sparse-threads 'some)
7179 (eq gnus-build-sparse-threads 'more))
7182 (setcar th (gnus-cut-thread (car th)))
7183 (setq th (cdr th)))))
7184 ;; Remove nixed out threads.
7187 (defun gnus-summary-initial-limit (&optional show-if-empty)
7188 "Figure out what the initial limit is supposed to be on group entry.
7189 This entails weeding out unwanted dormants, low-scored articles,
7190 fetch-old-headers verbiage, and so on."
7191 ;; Most groups have nothing to remove.
7192 (if (or gnus-inhibit-limiting
7193 (and (null gnus-newsgroup-dormant)
7194 (eq gnus-newsgroup-display 'gnus-not-ignore)
7195 (not (eq gnus-fetch-old-headers 'some))
7196 (not (numberp gnus-fetch-old-headers))
7197 (not (eq gnus-fetch-old-headers 'invisible))
7198 (null gnus-summary-expunge-below)
7199 (not (eq gnus-build-sparse-threads 'some))
7200 (not (eq gnus-build-sparse-threads 'more))
7201 (null gnus-thread-expunge-below)
7202 (not gnus-use-nocem)))
7204 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7205 (setq gnus-newsgroup-limit nil)
7208 (unless (car (symbol-value node))
7209 ;; These threads have no parents -- they are roots.
7210 (let ((nodes (cdr (symbol-value node)))
7213 (if (and gnus-thread-expunge-below
7214 (< (gnus-thread-total-score (car nodes))
7215 gnus-thread-expunge-below))
7216 (gnus-expunge-thread (pop nodes))
7217 (setq thread (pop nodes))
7218 (gnus-summary-limit-children thread))))))
7219 gnus-newsgroup-dependencies)
7220 ;; If this limitation resulted in an empty group, we might
7221 ;; pop the previous limit and use it instead.
7222 (when (and (not gnus-newsgroup-limit)
7224 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7225 gnus-newsgroup-limit))
7227 (defun gnus-summary-limit-children (thread)
7228 "Return 1 if this subthread is visible and 0 if it is not."
7229 ;; First we get the number of visible children to this thread. This
7230 ;; is done by recursing down the thread using this function, so this
7231 ;; will really go down to a leaf article first, before slowly
7232 ;; working its way up towards the root.
7236 (apply '+ (mapcar 'gnus-summary-limit-children
7239 (number (mail-header-number (car thread)))
7242 (not (memq number gnus-newsgroup-marked))
7244 ;; If this article is dormant and has absolutely no visible
7245 ;; children, then this article isn't visible.
7246 (and (memq number gnus-newsgroup-dormant)
7248 ;; If this is "fetch-old-headered" and there is no
7249 ;; visible children, then we don't want this article.
7250 (and (or (eq gnus-fetch-old-headers 'some)
7251 (numberp gnus-fetch-old-headers))
7252 (gnus-summary-article-ancient-p number)
7254 ;; If this is "fetch-old-headered" and `invisible', then
7255 ;; we don't want this article.
7256 (and (eq gnus-fetch-old-headers 'invisible)
7257 (gnus-summary-article-ancient-p number))
7258 ;; If this is a sparsely inserted article with no children,
7259 ;; we don't want it.
7260 (and (eq gnus-build-sparse-threads 'some)
7261 (gnus-summary-article-sparse-p number)
7263 ;; If we use expunging, and this article is really
7264 ;; low-scored, then we don't want this article.
7265 (when (and gnus-summary-expunge-below
7267 (or (cdr (assq number gnus-newsgroup-scored))
7268 gnus-summary-default-score))
7269 gnus-summary-expunge-below))
7270 ;; We increase the expunge-tally here, but that has
7271 ;; nothing to do with the limits, really.
7272 (incf gnus-newsgroup-expunged-tally)
7273 ;; We also mark as read here, if that's wanted.
7274 (when (and gnus-summary-mark-below
7275 (< score gnus-summary-mark-below))
7276 (setq gnus-newsgroup-unreads
7277 (delq number gnus-newsgroup-unreads))
7278 (if gnus-newsgroup-auto-expire
7279 (push number gnus-newsgroup-expirable)
7280 (push (cons number gnus-low-score-mark)
7281 gnus-newsgroup-reads)))
7283 ;; Do the `display' group parameter.
7284 (and gnus-newsgroup-display
7285 (not (funcall gnus-newsgroup-display)))
7286 ;; Check NoCeM things.
7287 (if (and gnus-use-nocem
7288 (gnus-nocem-unwanted-article-p
7289 (mail-header-id (car thread))))
7291 (setq gnus-newsgroup-unreads
7292 (delq number gnus-newsgroup-unreads))
7294 ;; Nope, invisible article.
7296 ;; Ok, this article is to be visible, so we add it to the limit
7298 (push number gnus-newsgroup-limit)
7301 (defun gnus-expunge-thread (thread)
7302 "Mark all articles in THREAD as read."
7303 (let* ((number (mail-header-number (car thread))))
7304 (incf gnus-newsgroup-expunged-tally)
7305 ;; We also mark as read here, if that's wanted.
7306 (setq gnus-newsgroup-unreads
7307 (delq number gnus-newsgroup-unreads))
7308 (if gnus-newsgroup-auto-expire
7309 (push number gnus-newsgroup-expirable)
7310 (push (cons number gnus-low-score-mark)
7311 gnus-newsgroup-reads)))
7312 ;; Go recursively through all subthreads.
7313 (mapcar 'gnus-expunge-thread (cdr thread)))
7315 ;; Summary article oriented commands
7317 (defun gnus-summary-refer-parent-article (n)
7318 "Refer parent article N times.
7319 If N is negative, go to ancestor -N instead.
7320 The difference between N and the number of articles fetched is returned."
7324 (when (not (natnump n))
7329 (setq header (gnus-summary-article-header))
7330 (if (and (eq (mail-header-number header)
7331 (cdr gnus-article-current))
7332 (equal gnus-newsgroup-name
7333 (car gnus-article-current)))
7334 ;; If we try to find the parent of the currently
7335 ;; displayed article, then we take a look at the actual
7336 ;; References header, since this is slightly more
7337 ;; reliable than the References field we got from the
7340 (set-buffer gnus-original-article-buffer)
7341 (nnheader-narrow-to-headers)
7342 (unless (setq ref (message-fetch-field "references"))
7343 (setq ref (message-fetch-field "in-reply-to")))
7346 ;; It's not the current article, so we take a bet on
7347 ;; the value we got from the server.
7348 (mail-header-references header)))
7350 (not (equal ref "")))
7351 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7352 (gnus-message 1 "Couldn't find parent"))
7353 (gnus-message 1 "No references in article %d"
7354 (gnus-summary-article-number))
7357 (gnus-summary-position-point)
7360 (defun gnus-summary-refer-references ()
7361 "Fetch all articles mentioned in the References header.
7362 Return the number of articles fetched."
7364 (let ((ref (mail-header-references (gnus-summary-article-header)))
7365 (current (gnus-summary-article-number))
7369 (error "No References in the current article")
7370 ;; For each Message-ID in the References header...
7371 (while (string-match "<[^>]*>" ref)
7373 ;; ... fetch that article.
7374 (gnus-summary-refer-article
7375 (prog1 (match-string 0 ref)
7376 (setq ref (substring ref (match-end 0))))))
7377 (gnus-summary-goto-subject current)
7378 (gnus-summary-position-point)
7381 (defun gnus-summary-refer-thread (&optional limit)
7382 "Fetch all articles in the current thread.
7383 If LIMIT (the numerical prefix), fetch that many old headers instead
7384 of what's specified by the `gnus-refer-thread-limit' variable."
7386 (let ((id (mail-header-id (gnus-summary-article-header)))
7387 (limit (if limit (prefix-numeric-value limit)
7388 gnus-refer-thread-limit)))
7389 ;; We want to fetch LIMIT *old* headers, but we also have to
7390 ;; re-fetch all the headers in the current buffer, because many of
7391 ;; them may be undisplayed. So we adjust LIMIT.
7392 (when (numberp limit)
7393 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7394 (unless (eq gnus-fetch-old-headers 'invisible)
7395 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7396 ;; Retrieve the headers and read them in.
7397 (if (eq (gnus-retrieve-headers
7398 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7400 (gnus-build-all-threads)
7401 (error "Can't fetch thread from backends that don't support NOV"))
7402 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7403 (gnus-summary-limit-include-thread id)))
7405 (defun gnus-summary-refer-article (message-id)
7406 "Fetch an article specified by MESSAGE-ID."
7407 (interactive "sMessage-ID: ")
7408 (when (and (stringp message-id)
7409 (not (zerop (length message-id))))
7410 ;; Construct the correct Message-ID if necessary.
7411 ;; Suggested by tale@pawl.rpi.edu.
7412 (unless (string-match "^<" message-id)
7413 (setq message-id (concat "<" message-id)))
7414 (unless (string-match ">$" message-id)
7415 (setq message-id (concat message-id ">")))
7416 (let* ((header (gnus-id-to-header message-id))
7418 (gnus-summary-article-sparse-p
7419 (mail-header-number header))
7420 (memq (mail-header-number header)
7421 gnus-newsgroup-limit)))
7424 ;; If the article is present in the buffer we just go to it.
7426 (or (not (gnus-summary-article-sparse-p
7427 (mail-header-number header)))
7430 (gnus-summary-goto-article
7431 (mail-header-number header) nil t)
7433 (gnus-summary-update-article (mail-header-number header)))))
7435 ;; We fetch the article.
7437 (dolist (gnus-override-method (gnus-refer-article-methods))
7438 (gnus-check-server gnus-override-method)
7439 ;; Fetch the header, and display the article.
7440 (when (setq number (gnus-summary-insert-subject message-id))
7441 (gnus-summary-select-article nil nil nil number)
7443 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7445 (defun gnus-refer-article-methods ()
7446 "Return a list of referrable methods."
7448 ;; No method, so we default to current and native.
7449 ((null gnus-refer-article-method)
7450 (list gnus-current-select-method gnus-select-method))
7452 ((eq 'current gnus-refer-article-method)
7453 (list gnus-current-select-method))
7454 ;; List of select methods.
7455 ((not (and (symbolp (car gnus-refer-article-method))
7456 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7458 (dolist (method gnus-refer-article-method)
7459 (push (if (eq 'current method)
7460 gnus-current-select-method
7464 ;; One single select method.
7466 (list gnus-refer-article-method))))
7468 (defun gnus-summary-edit-parameters ()
7469 "Edit the group parameters of the current group."
7471 (gnus-group-edit-group gnus-newsgroup-name 'params))
7473 (defun gnus-summary-customize-parameters ()
7474 "Customize the group parameters of the current group."
7476 (gnus-group-customize gnus-newsgroup-name))
7478 (defun gnus-summary-enter-digest-group (&optional force)
7479 "Enter an nndoc group based on the current article.
7480 If FORCE, force a digest interpretation. If not, try
7481 to guess what the document format is."
7483 (let ((conf gnus-current-window-configuration))
7485 (gnus-summary-select-article))
7486 (setq gnus-current-window-configuration conf)
7487 (let* ((name (format "%s-%d"
7488 (gnus-group-prefixed-name
7489 gnus-newsgroup-name (list 'nndoc ""))
7491 (set-buffer gnus-summary-buffer)
7492 gnus-current-article)))
7493 (ogroup gnus-newsgroup-name)
7494 (params (append (gnus-info-params (gnus-get-info ogroup))
7495 (list (cons 'to-group ogroup))
7496 (list (cons 'save-article-group ogroup))))
7497 (case-fold-search t)
7498 (buf (current-buffer))
7501 (set-buffer gnus-original-article-buffer)
7502 ;; Have the digest group inherit the main mail address of
7503 ;; the parent article.
7504 (when (setq to-address (or (message-fetch-field "reply-to")
7505 (message-fetch-field "from")))
7506 (setq params (append
7507 (list (cons 'to-address
7508 (funcall gnus-decode-encoded-word-function
7510 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7511 (insert-buffer-substring gnus-original-article-buffer)
7512 ;; Remove lines that may lead nndoc to misinterpret the
7515 (goto-char (point-min))
7516 (or (search-forward "\n\n" nil t) (point)))
7517 (goto-char (point-min))
7518 (delete-matching-lines "^Path:\\|^From ")
7521 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7522 (gnus-newsgroup-ephemeral-ignored-charsets
7523 gnus-newsgroup-ignored-charsets))
7524 (gnus-group-read-ephemeral-group
7525 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7527 ,(if force 'mbox 'guess))) t))
7528 ;; Make all postings to this group go to the parent group.
7529 (nconc (gnus-info-params (gnus-get-info name))
7531 ;; Couldn't select this doc group.
7532 (switch-to-buffer buf)
7533 (gnus-set-global-variables)
7534 (gnus-configure-windows 'summary)
7535 (gnus-message 3 "Article couldn't be entered?"))
7536 (kill-buffer dig)))))
7538 (defun gnus-summary-read-document (n)
7539 "Open a new group based on the current article(s).
7540 This will allow you to read digests and other similar
7541 documents as newsgroups.
7542 Obeys the standard process/prefix convention."
7544 (let* ((articles (gnus-summary-work-articles n))
7545 (ogroup gnus-newsgroup-name)
7546 (params (append (gnus-info-params (gnus-get-info ogroup))
7547 (list (cons 'to-group ogroup))))
7548 article group egroup groups vgroup)
7549 (while (setq article (pop articles))
7550 (setq group (format "%s-%d" gnus-newsgroup-name article))
7551 (gnus-summary-remove-process-mark article)
7552 (when (gnus-summary-display-article article)
7555 (insert-buffer-substring gnus-original-article-buffer)
7556 ;; Remove some headers that may lead nndoc to make
7558 (message-narrow-to-head)
7559 (goto-char (point-min))
7560 (delete-matching-lines "^\\(Path\\):\\|^From ")
7563 (gnus-group-read-ephemeral-group
7564 group `(nndoc ,group (nndoc-address ,(current-buffer))
7565 (nndoc-article-type guess))
7568 ;; Make all postings to this group go to the parent group.
7569 (nconc (gnus-info-params (gnus-get-info egroup))
7571 (push egroup groups))
7572 ;; Couldn't select this doc group.
7573 (gnus-error 3 "Article couldn't be entered"))))))
7574 ;; Now we have selected all the documents.
7577 (error "None of the articles could be interpreted as documents"))
7578 ((gnus-group-read-ephemeral-group
7579 (setq vgroup (format
7580 "nnvirtual:%s-%s" gnus-newsgroup-name
7581 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7582 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7584 (cons (current-buffer) 'summary)))
7586 (error "Couldn't select virtual nndoc group")))))
7588 (defun gnus-summary-isearch-article (&optional regexp-p)
7589 "Do incremental search forward on the current article.
7590 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7592 (let* ((gnus-inhibit-treatment t)
7593 (old (gnus-summary-select-article)))
7594 (gnus-configure-windows 'article)
7595 (gnus-eval-in-buffer-window gnus-article-buffer
7599 (gnus-article-show-all-headers))
7600 (goto-char (point-min))
7601 (isearch-forward regexp-p)))))
7603 (defun gnus-summary-search-article-forward (regexp &optional backward)
7604 "Search for an article containing REGEXP forward.
7605 If BACKWARD, search backward instead."
7608 (format "Search article %s (regexp%s): "
7609 (if current-prefix-arg "backward" "forward")
7610 (if gnus-last-search-regexp
7611 (concat ", default " gnus-last-search-regexp)
7613 current-prefix-arg))
7614 (if (string-equal regexp "")
7615 (setq regexp (or gnus-last-search-regexp ""))
7616 (setq gnus-last-search-regexp regexp)
7617 (setq gnus-article-before-search gnus-current-article))
7618 ;; Intentionally set gnus-last-article.
7619 (setq gnus-last-article gnus-article-before-search)
7620 (let ((gnus-last-article gnus-last-article))
7621 (if (gnus-summary-search-article regexp backward)
7622 (gnus-summary-show-thread)
7623 (error "Search failed: \"%s\"" regexp))))
7625 (defun gnus-summary-search-article-backward (regexp)
7626 "Search for an article containing REGEXP backward."
7629 (format "Search article backward (regexp%s): "
7630 (if gnus-last-search-regexp
7631 (concat ", default " gnus-last-search-regexp)
7633 (gnus-summary-search-article-forward regexp 'backward))
7636 (defmacro gnus-summary-search-article-position-point (regexp backward)
7637 "Dehighlight the last matched text and goto the beginning position."
7638 (` (if (and gnus-summary-search-article-matched-data
7639 (let ((text (caddr gnus-summary-search-article-matched-data))
7640 (inhibit-read-only t)
7643 (goto-char (car gnus-summary-search-article-matched-data))
7644 (cadr gnus-summary-search-article-matched-data))
7646 (string-match (, regexp) text)))
7647 (if (, backward) (beginning-of-line) (end-of-line))
7648 (goto-char (if (, backward) (point-max) (point-min))))))
7650 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
7651 "Place point where X-Face image is displayed."
7652 (if (featurep 'xemacs)
7653 (` (let ((end (if (search-forward "\n\n" nil t)
7654 (goto-char (1- (point)))
7657 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
7658 (unless (and (re-search-forward "^From:" end t)
7659 (setq extent (extent-at (point)))
7660 (extent-begin-glyph extent))
7661 (goto-char (, opoint)))))
7662 (` (let ((end (if (search-forward "\n\n" nil t)
7663 (goto-char (1- (point)))
7665 (start (or (search-backward "\n\n" nil t) (point-min))))
7667 (or (text-property-any start end 'x-face-image t);; x-face-e21
7668 (text-property-any start end 'x-face-mule-bitmap-image t)
7671 (defmacro gnus-summary-search-article-highlight-matched-text
7672 (backward treated x-face)
7673 "Highlight matched text in the function `gnus-summary-search-article'."
7674 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
7675 (end (set-marker (make-marker) (match-end 0)))
7676 (inhibit-read-only t)
7680 (let ((items (mapcar 'car gnus-treatment-function-alist)))
7682 (lambda (item) (setq items (delq item items)))
7683 '(gnus-treat-buttonize
7684 gnus-treat-fill-article
7685 gnus-treat-fill-long-lines
7686 gnus-treat-emphasize
7687 gnus-treat-highlight-headers
7688 gnus-treat-highlight-citation
7689 gnus-treat-highlight-signature
7690 gnus-treat-overstrike
7691 gnus-treat-display-xface
7692 gnus-treat-buttonize-head
7693 gnus-treat-decode-article-as-default-mime-charset))
7694 (static-if (featurep 'xemacs)
7696 (cons '(x-face-mule-delete-x-face-field
7699 (gnus-treat-display-xface
7700 (when (, x-face) gnus-treat-display-xface)))
7701 (gnus-article-prepare-mime-display)))
7702 (goto-char (if (, backward) start end))
7704 (gnus-summary-search-article-highlight-goto-x-face (point)))
7705 (setq gnus-summary-search-article-matched-data
7706 (list start end (buffer-substring start end)))
7707 (unless (eq start end);; matched text has been deleted. :-<
7708 (put-text-property start end 'face
7709 (or (find-face 'isearch)
7710 'secondary-selection))))))
7713 (defun gnus-summary-search-article (regexp &optional backward)
7714 "Search for an article containing REGEXP.
7715 Optional argument BACKWARD means do search for backward.
7716 `gnus-select-article-hook' is not called during the search."
7717 ;; We have to require this here to make sure that the following
7718 ;; dynamic binding isn't shadowed by autoloading.
7719 (require 'gnus-async)
7721 (let ((gnus-select-article-hook nil) ;Disable hook.
7722 (gnus-article-prepare-hook nil)
7723 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7724 (gnus-use-article-prefetch nil)
7725 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7726 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7727 (sum (current-buffer))
7730 (gnus-save-hidden-threads
7731 (static-if (featurep 'xemacs)
7732 (let ((gnus-inhibit-treatment t))
7733 (setq treated (eq 'old (gnus-summary-select-article)))
7735 (not (and (gnus-buffer-live-p gnus-article-buffer)
7736 (window-live-p (get-buffer-window
7737 gnus-article-buffer t)))))
7738 (gnus-summary-select-article nil t)
7739 (setq treated nil)))
7740 (let ((gnus-inhibit-treatment t)
7741 (x-face-mule-delete-x-face-field 'never))
7742 (setq treated (eq 'old (gnus-summary-select-article)))
7745 (and (gnus-buffer-live-p gnus-article-buffer)
7746 (window-live-p (get-buffer-window
7747 gnus-article-buffer t))
7748 (or (not (string-match "^\\^X-Face:" regexp))
7749 (with-current-buffer gnus-article-buffer
7750 gnus-summary-search-article-matched-data)))))
7751 (gnus-summary-select-article nil t)
7752 (setq treated nil))))
7753 (set-buffer gnus-article-buffer)
7757 (gnus-article-show-all-headers)
7758 (gnus-summary-search-article-position-point regexp backward))
7759 (goto-char (if backward (point-max) (point-min))))
7761 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7763 (re-search-backward regexp nil t)
7764 (re-search-forward regexp nil t))
7765 ;; We found the regexp.
7767 (gnus-summary-search-article-highlight-matched-text
7768 backward treated (string-match "^\\^X-Face:" regexp))
7771 (/ (- 2 (window-height
7772 (get-buffer-window gnus-article-buffer t)))
7775 (get-buffer-window (current-buffer))
7778 (setq point (point)))
7779 ;; We didn't find it, so we go to the next article.
7782 (while (eq found 'not)
7783 (if (not (if backward (gnus-summary-find-prev)
7784 (gnus-summary-find-next)))
7785 ;; No more articles.
7787 ;; Select the next article and adjust point.
7788 (unless (gnus-summary-article-sparse-p
7789 (gnus-summary-article-number))
7791 (let ((gnus-inhibit-treatment t))
7792 (gnus-summary-select-article))
7794 (set-buffer gnus-article-buffer)
7796 (goto-char (if backward (point-max) (point-min))))))))
7797 (gnus-message 7 ""))
7798 ;; Return whether we found the regexp.
7799 (when (eq found 'found)
7801 (gnus-summary-show-thread)
7802 (gnus-summary-goto-subject gnus-current-article)
7803 (gnus-summary-position-point)
7806 (defun gnus-find-matching-articles (header regexp)
7807 "Return a list of all articles that match REGEXP on HEADER.
7808 This search includes all articles in the current group that Gnus has
7809 fetched headers for, whether they are displayed or not."
7810 (let ((articles nil)
7811 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
7812 (case-fold-search t))
7813 (dolist (header gnus-newsgroup-headers)
7814 (when (string-match regexp (funcall func header))
7815 (push (mail-header-number header) articles)))
7816 (nreverse articles)))
7818 (defun gnus-summary-find-matching (header regexp &optional backward unread
7820 "Return a list of all articles that match REGEXP on HEADER.
7821 The search stars on the current article and goes forwards unless
7822 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7823 If UNREAD is non-nil, only unread articles will
7824 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7825 in the comparisons."
7826 (let ((case-fold-search (not not-case-fold))
7829 (if (eq (car header) 'extra)
7832 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7834 (error "%s is an invalid header" header))
7835 (unless (fboundp (intern (concat "mail-header-" header)))
7836 (error "%s is not a valid header" header))
7837 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7838 (dolist (d (if (eq backward 'all)
7840 (gnus-data-find-list
7841 (gnus-summary-article-number)
7842 (gnus-data-list backward))))
7843 (when (and (or (not unread) ; We want all articles...
7844 (gnus-data-unread-p d)) ; Or just unreads.
7845 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7846 (string-match regexp
7847 (funcall func (gnus-data-header d)))) ; Match.
7848 (push (gnus-data-number d) articles))) ; Success!
7849 (nreverse articles)))
7851 (defun gnus-summary-execute-command (header regexp command &optional backward)
7852 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7853 If HEADER is an empty string (or nil), the match is done on the entire
7854 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7856 (list (let ((completion-ignore-case t))
7859 (mapcar (lambda (header) (list (format "%s" header)))
7861 '("Number" "Subject" "From" "Lines" "Date"
7862 "Message-ID" "Xref" "References" "Body")
7863 gnus-extra-headers))
7864 nil 'require-match))
7865 (read-string "Regexp: ")
7866 (read-key-sequence "Command: ")
7867 current-prefix-arg))
7868 (when (equal header "Body")
7870 ;; Hidden thread subtrees must be searched as well.
7871 (gnus-summary-show-all-threads)
7872 ;; We don't want to change current point nor window configuration.
7874 (save-window-excursion
7875 (gnus-message 6 "Executing %s..." (key-description command))
7876 ;; We'd like to execute COMMAND interactively so as to give arguments.
7877 (gnus-execute header regexp
7878 `(call-interactively ',(key-binding command))
7880 (gnus-message 6 "Executing %s...done" (key-description command)))))
7882 (defun gnus-summary-beginning-of-article ()
7883 "Scroll the article back to the beginning."
7885 (gnus-summary-select-article)
7886 (gnus-configure-windows 'article)
7887 (gnus-eval-in-buffer-window gnus-article-buffer
7889 (goto-char (point-min))
7890 (when gnus-page-broken
7891 (gnus-narrow-to-page))))
7893 (defun gnus-summary-end-of-article ()
7894 "Scroll to the end of the article."
7896 (gnus-summary-select-article)
7897 (gnus-configure-windows 'article)
7898 (gnus-eval-in-buffer-window gnus-article-buffer
7900 (goto-char (point-max))
7902 (when gnus-page-broken
7903 (gnus-narrow-to-page))))
7905 (defun gnus-summary-print-article (&optional filename n)
7906 "Generate and print a PostScript image of the N next (mail) articles.
7908 If N is negative, print the N previous articles. If N is nil and articles
7909 have been marked with the process mark, print these instead.
7911 If the optional first argument FILENAME is nil, send the image to the
7912 printer. If FILENAME is a string, save the PostScript image in a file with
7913 that name. If FILENAME is a number, prompt the user for the name of the file
7915 (interactive (list (ps-print-preprint current-prefix-arg)))
7916 (dolist (article (gnus-summary-work-articles n))
7917 (gnus-summary-select-article nil nil 'pseudo article)
7918 (gnus-eval-in-buffer-window gnus-article-buffer
7919 (let ((buffer (generate-new-buffer " *print*")))
7922 (copy-to-buffer buffer (point-min) (point-max))
7924 (gnus-article-delete-invisible-text)
7925 (when (gnus-visual-p 'article-highlight 'highlight)
7926 ;; Copy-to-buffer doesn't copy overlay. So redo
7928 (let ((gnus-article-buffer buffer))
7929 (gnus-article-highlight-citation t)
7930 (gnus-article-highlight-signature)))
7931 (let ((ps-left-header
7934 (mail-header-subject gnus-current-headers) ")")
7936 (mail-header-from gnus-current-headers) ")")))
7939 "/pagenumberstring load"
7941 (mail-header-date gnus-current-headers) ")"))))
7942 (gnus-run-hooks 'gnus-ps-print-hook)
7945 (ps-spool-buffer-with-faces)
7946 (ps-spool-buffer)))))
7947 (kill-buffer buffer))))
7948 (gnus-summary-remove-process-mark article))
7949 (ps-despool filename))
7951 (defun gnus-summary-show-article (&optional arg)
7952 "Force re-fetching of the current article.
7953 If ARG (the prefix) is a number, show the article with the charset
7954 defined in `gnus-summary-show-article-charset-alist', or the charset
7956 If ARG (the prefix) is non-nil and not a number, show the raw article
7957 without any article massaging functions being run."
7961 (gnus-summary-show-article t)
7962 (let ((gnus-newsgroup-charset
7963 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7964 (mm-read-coding-system
7967 (set-buffer gnus-article-buffer)
7968 (detect-coding-region (point) (point-max) t)))))
7969 (gnus-newsgroup-ignored-charsets 'gnus-all))
7970 (gnus-summary-select-article nil 'force)
7971 (let ((deps gnus-newsgroup-dependencies)
7974 (set-buffer gnus-original-article-buffer)
7976 (message-narrow-to-head)
7977 (setq head (buffer-string)))
7979 (insert (format "211 %d Article retrieved.\n"
7980 (cdr gnus-article-current)))
7983 (let ((nntp-server-buffer (current-buffer)))
7984 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7985 (gnus-data-set-header
7986 (gnus-data-find (cdr gnus-article-current))
7988 (gnus-summary-update-article-line
7989 (cdr gnus-article-current) header)
7990 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
7991 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
7993 ;; Select the article the normal way.
7994 (gnus-summary-select-article nil 'force))
7996 ;; We have to require this here to make sure that the following
7997 ;; dynamic binding isn't shadowed by autoloading.
7998 (require 'gnus-async)
8000 ;; Bind the article treatment functions to nil.
8001 (let ((gnus-have-all-headers t)
8002 gnus-article-prepare-hook
8003 gnus-article-decode-hook
8006 (gnus-inhibit-treatment t))
8007 (gnus-summary-select-article nil 'force))))
8008 (gnus-summary-goto-subject gnus-current-article)
8009 (gnus-summary-position-point))
8011 (defun gnus-summary-show-raw-article ()
8012 "Show the raw article without any article massaging functions being run."
8014 (gnus-summary-show-article t))
8016 (defun gnus-summary-verbose-headers (&optional arg)
8017 "Toggle permanent full header display.
8018 If ARG is a positive number, turn header display on.
8019 If ARG is a negative number, turn header display off."
8021 (setq gnus-show-all-headers
8022 (cond ((or (not (numberp arg))
8024 (not gnus-show-all-headers))
8027 (gnus-summary-show-article))
8029 (defun gnus-summary-toggle-header (&optional arg)
8030 "Show the headers if they are hidden, or hide them if they are shown.
8031 If ARG is a positive number, show the entire header.
8032 If ARG is a negative number, hide the unwanted header lines."
8035 (set-buffer gnus-article-buffer)
8037 (let* ((buffer-read-only nil)
8038 (inhibit-point-motion-hooks t)
8044 (article-narrow-to-head)
8045 (gnus-article-hidden-text-p 'headers))))
8046 (goto-char (point-min))
8047 (when (search-forward "\n\n" nil t)
8048 (delete-region (point-min) (1- (point))))
8049 (goto-char (point-min))
8051 (set-buffer gnus-original-article-buffer)
8052 (goto-char (point-min))
8053 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
8054 (insert-buffer-substring gnus-original-article-buffer 1 e)
8056 (narrow-to-region (point-min) (point))
8057 (article-decode-encoded-words)
8059 (let ((gnus-treat-hide-headers nil)
8060 (gnus-treat-hide-boring-headers nil))
8061 (setq gnus-article-wash-types
8062 (delq 'headers gnus-article-wash-types))
8063 (gnus-treat-article 'head))
8064 (gnus-treat-article 'head)))
8065 (gnus-set-mode-line 'article)))))
8067 (defun gnus-summary-show-all-headers ()
8068 "Make all header lines visible."
8070 (gnus-summary-toggle-header 1))
8072 (defun gnus-summary-toggle-mime (&optional arg)
8073 "Toggle MIME processing.
8074 If ARG is a positive number, turn MIME processing on."
8076 (setq gnus-show-mime
8078 (not gnus-show-mime)
8079 (> (prefix-numeric-value arg) 0)))
8080 (gnus-summary-select-article t 'force))
8082 (defun gnus-summary-caesar-message (&optional arg)
8083 "Caesar rotate the current article by 13.
8084 The numerical prefix specifies how many places to rotate each letter
8087 (gnus-summary-select-article)
8088 (let ((mail-header-separator ""))
8089 (gnus-eval-in-buffer-window gnus-article-buffer
8092 (let ((start (window-start))
8094 (message-caesar-buffer-body arg)
8095 (set-window-start (get-buffer-window (current-buffer)) start))))))
8097 (defun gnus-summary-stop-page-breaking ()
8098 "Stop page breaking in the current article."
8100 (gnus-summary-select-article)
8101 (gnus-eval-in-buffer-window gnus-article-buffer
8103 (when (gnus-visual-p 'page-marker)
8104 (let ((buffer-read-only nil))
8105 (gnus-remove-text-with-property 'gnus-prev)
8106 (gnus-remove-text-with-property 'gnus-next))
8107 (setq gnus-page-broken nil))))
8109 (defun gnus-summary-move-article (&optional n to-newsgroup
8110 select-method action)
8111 "Move the current article to a different newsgroup.
8112 If N is a positive number, move the N next articles.
8113 If N is a negative number, move the N previous articles.
8114 If N is nil and any articles have been marked with the process mark,
8115 move those articles instead.
8116 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8117 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8118 re-spool using this method.
8120 For this function to work, both the current newsgroup and the
8121 newsgroup that you want to move to have to support the `request-move'
8122 and `request-accept' functions.
8124 ACTION can be either `move' (the default), `crosspost' or `copy'."
8127 (setq action 'move))
8128 ;; Check whether the source group supports the required functions.
8129 (cond ((and (eq action 'move)
8130 (not (gnus-check-backend-function
8131 'request-move-article gnus-newsgroup-name)))
8132 (error "The current group does not support article moving"))
8133 ((and (eq action 'crosspost)
8134 (not (gnus-check-backend-function
8135 'request-replace-article gnus-newsgroup-name)))
8136 (error "The current group does not support article editing")))
8137 (let ((articles (gnus-summary-work-articles n))
8138 (prefix (if (gnus-check-backend-function
8139 'request-move-article gnus-newsgroup-name)
8140 (gnus-group-real-prefix gnus-newsgroup-name)
8142 (names '((move "Move" "Moving")
8143 (copy "Copy" "Copying")
8144 (crosspost "Crosspost" "Crossposting")))
8145 (copy-buf (save-excursion
8146 (nnheader-set-temp-buffer " *copy article*")))
8147 (default-marks gnus-article-mark-lists)
8148 (no-expire-marks (delete '(expirable . expire)
8149 (copy-sequence gnus-article-mark-lists)))
8150 art-group to-method new-xref article to-groups)
8151 (unless (assq action names)
8152 (error "Unknown action %s" action))
8153 ;; Read the newsgroup name.
8154 (when (and (not to-newsgroup)
8155 (not select-method))
8157 (gnus-read-move-group-name
8158 (cadr (assq action names))
8159 (symbol-value (intern (format "gnus-current-%s-group" action)))
8161 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8162 (setq to-method (or select-method
8163 (gnus-server-to-method
8164 (gnus-group-method to-newsgroup))))
8165 ;; Check the method we are to move this article to...
8166 (unless (gnus-check-backend-function
8167 'request-accept-article (car to-method))
8168 (error "%s does not support article copying" (car to-method)))
8169 (unless (gnus-check-server to-method)
8170 (error "Can't open server %s" (car to-method)))
8171 (gnus-message 6 "%s to %s: %s..."
8172 (caddr (assq action names))
8173 (or (car select-method) to-newsgroup) articles)
8175 (setq article (pop articles))
8179 ;; Move the article.
8181 ;; Remove this article from future suppression.
8182 (gnus-dup-unsuppress-article article)
8183 (gnus-request-move-article
8184 article ; Article to move
8185 gnus-newsgroup-name ; From newsgroup
8186 (nth 1 (gnus-find-method-for-group
8187 gnus-newsgroup-name)) ; Server
8188 (list 'gnus-request-accept-article
8189 to-newsgroup (list 'quote select-method)
8190 (not articles) t) ; Accept form
8191 (not articles))) ; Only save nov last time
8192 ;; Copy the article.
8195 (set-buffer copy-buf)
8196 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8197 (gnus-request-accept-article
8198 to-newsgroup select-method (not articles) t))))
8199 ;; Crosspost the article.
8200 ((eq action 'crosspost)
8201 (let ((xref (message-tokenize-header
8202 (mail-header-xref (gnus-summary-article-header article))
8204 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8207 (setq xref (list (system-name))))
8210 (mapconcat 'identity
8211 (delete "Xref:" (delete new-xref xref))
8215 (set-buffer copy-buf)
8216 ;; First put the article in the destination group.
8217 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8218 (when (consp (setq art-group
8219 (gnus-request-accept-article
8220 to-newsgroup select-method (not articles))))
8221 (setq new-xref (concat new-xref " " (car art-group)
8222 ":" (cdr art-group)))
8223 ;; Now we have the new Xrefs header, so we insert
8224 ;; it and replace the new article.
8225 (nnheader-replace-header "Xref" new-xref)
8226 (gnus-request-replace-article
8227 (cdr art-group) to-newsgroup (current-buffer))
8231 (gnus-message 1 "Couldn't %s article %s: %s"
8232 (cadr (assq action names)) article
8233 (nnheader-get-report (car to-method))))
8234 ((eq art-group 'junk)
8235 (when (eq action 'move)
8236 (gnus-summary-mark-article article gnus-canceled-mark)
8237 (gnus-message 4 "Deleted article %s" article)))
8239 (let* ((pto-group (gnus-group-prefixed-name
8240 (car art-group) to-method))
8242 (gnus-gethash pto-group gnus-newsrc-hashtb))
8243 (info (nth 2 entry))
8244 (to-group (gnus-info-group info))
8246 ;; Update the group that has been moved to.
8248 (memq action '(move copy)))
8249 (unless (member to-group to-groups)
8250 (push to-group to-groups))
8252 (unless (memq article gnus-newsgroup-unreads)
8253 (push 'read to-marks)
8255 info (gnus-add-to-range (gnus-info-read info)
8256 (list (cdr art-group)))))
8258 ;; See whether the article is to be put in the cache.
8259 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8262 (to-article (cdr art-group)))
8264 ;; Enter the article into the cache in the new group,
8265 ;; if that is required.
8266 (when gnus-use-cache
8267 (gnus-cache-possibly-enter-article
8269 (let ((header (copy-sequence
8270 (gnus-summary-article-header article))))
8271 (mail-header-set-number header to-article)
8273 (memq article gnus-newsgroup-marked)
8274 (memq article gnus-newsgroup-dormant)
8275 (memq article gnus-newsgroup-unreads)))
8277 (when gnus-preserve-marks
8278 ;; Copy any marks over to the new group.
8279 (when (and (equal to-group gnus-newsgroup-name)
8280 (not (memq article gnus-newsgroup-unreads)))
8281 ;; Mark this article as read in this group.
8282 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8283 (setcdr (gnus-active to-group) to-article)
8284 (setcdr gnus-newsgroup-active to-article))
8287 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8288 (when (memq article (symbol-value
8289 (intern (format "gnus-newsgroup-%s"
8291 (push (cdar marks) to-marks)
8292 ;; If the other group is the same as this group,
8293 ;; then we have to add the mark to the list.
8294 (when (equal to-group gnus-newsgroup-name)
8295 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8298 (intern (format "gnus-newsgroup-%s"
8300 ;; Copy the marks to other group.
8301 (gnus-add-marked-articles
8302 to-group (cdar marks) (list to-article) info)))
8303 (setq marks (cdr marks)))
8305 (gnus-request-set-mark to-group (list (list (list to-article)
8310 (concat "(gnus-group-set-info '"
8311 (gnus-prin1-to-string (gnus-get-info to-group))
8314 ;; Update the Xref header in this article to point to
8315 ;; the new crossposted article we have just created.
8316 (when (eq action 'crosspost)
8318 (set-buffer copy-buf)
8319 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8320 (nnheader-replace-header "Xref" new-xref)
8321 (gnus-request-replace-article
8322 article gnus-newsgroup-name (current-buffer)))))
8324 ;;;!!!Why is this necessary?
8325 (set-buffer gnus-summary-buffer)
8327 (gnus-summary-goto-subject article)
8328 (when (eq action 'move)
8329 (gnus-summary-mark-article article gnus-canceled-mark))))
8330 (gnus-summary-remove-process-mark article))
8331 ;; Re-activate all groups that have been moved to.
8334 (set-buffer gnus-group-buffer)
8335 (when (gnus-group-goto-group (car to-groups) t)
8336 (gnus-group-get-new-news-this-group 1 t))
8339 (gnus-kill-buffer copy-buf)
8340 (gnus-summary-position-point)
8341 (gnus-set-mode-line 'summary)))
8343 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8344 "Move the current article to a different newsgroup.
8345 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8346 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8347 re-spool using this method."
8349 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8351 (defun gnus-summary-crosspost-article (&optional n)
8352 "Crosspost the current article to some other group."
8354 (gnus-summary-move-article n nil nil 'crosspost))
8356 (defcustom gnus-summary-respool-default-method nil
8357 "Default method for respooling an article.
8358 If nil, use to the current newsgroup method."
8359 :type '(choice (gnus-select-method :value (nnml ""))
8361 :group 'gnus-summary-mail)
8363 (defun gnus-summary-respool-article (&optional n method)
8364 "Respool the current article.
8365 The article will be squeezed through the mail spooling process again,
8366 which means that it will be put in some mail newsgroup or other
8367 depending on `nnmail-split-methods'.
8368 If N is a positive number, respool the N next articles.
8369 If N is a negative number, respool the N previous articles.
8370 If N is nil and any articles have been marked with the process mark,
8371 respool those articles instead.
8373 Respooling can be done both from mail groups and \"real\" newsgroups.
8374 In the former case, the articles in question will be moved from the
8375 current group into whatever groups they are destined to. In the
8376 latter case, they will be copied into the relevant groups."
8378 (list current-prefix-arg
8379 (let* ((methods (gnus-methods-using 'respool))
8381 (symbol-name (or gnus-summary-respool-default-method
8382 (car (gnus-find-method-for-group
8383 gnus-newsgroup-name)))))
8385 (gnus-completing-read
8386 methname "What backend do you want to use when respooling?"
8387 methods nil t nil 'gnus-mail-method-history))
8390 ((zerop (length (setq ms (gnus-servers-using-backend
8392 (list (intern method) ""))
8396 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8397 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8400 (error "No method given for respooling"))
8401 (if (assoc (symbol-name
8402 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8403 (gnus-methods-using 'respool))
8404 (gnus-summary-move-article n nil method)
8405 (gnus-summary-copy-article n nil method)))
8407 (defun gnus-summary-import-article (file &optional edit)
8408 "Import an arbitrary file into a mail newsgroup."
8409 (interactive "fImport file: \nP")
8410 (let ((group gnus-newsgroup-name)
8411 (now (current-time))
8412 atts lines group-art)
8413 (unless (gnus-check-backend-function 'request-accept-article group)
8414 (error "%s does not support article importing" group))
8415 (or (file-readable-p file)
8416 (not (file-regular-p file))
8417 (error "Can't read %s" file))
8419 (set-buffer (gnus-get-buffer-create " *import file*"))
8421 (nnheader-insert-file-contents file)
8422 (goto-char (point-min))
8423 (if (nnheader-article-p)
8425 (goto-char (point-min))
8426 (search-forward "\n\n" nil t)
8427 (narrow-to-region (point-min) (1- (point)))
8428 (goto-char (point-min))
8429 (unless (re-search-forward "^date:" nil t)
8430 (goto-char (point-max))
8431 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8432 ;; This doesn't look like an article, so we fudge some headers.
8433 (setq atts (file-attributes file)
8434 lines (count-lines (point-min) (point-max)))
8435 (insert "From: " (read-string "From: ") "\n"
8436 "Subject: " (read-string "Subject: ") "\n"
8437 "Date: " (message-make-date (nth 5 atts)) "\n"
8438 "Message-ID: " (message-make-message-id) "\n"
8439 "Lines: " (int-to-string lines) "\n"
8440 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8441 (setq group-art (gnus-request-accept-article group nil t))
8442 (kill-buffer (current-buffer)))
8443 (setq gnus-newsgroup-active (gnus-activate-group group))
8445 (gnus-summary-goto-article (cdr group-art) nil t)
8447 (gnus-summary-edit-article))))
8449 (defun gnus-summary-create-article ()
8450 "Create an article in a mail newsgroup."
8452 (let ((group gnus-newsgroup-name)
8453 (now (current-time))
8455 (unless (gnus-check-backend-function 'request-accept-article group)
8456 (error "%s does not support article importing" group))
8458 (set-buffer (gnus-get-buffer-create " *import file*"))
8460 (goto-char (point-min))
8461 ;; This doesn't look like an article, so we fudge some headers.
8462 (insert "From: " (read-string "From: ") "\n"
8463 "Subject: " (read-string "Subject: ") "\n"
8464 "Date: " (message-make-date now) "\n"
8465 "Message-ID: " (message-make-message-id) "\n")
8466 (setq group-art (gnus-request-accept-article group nil t))
8467 (kill-buffer (current-buffer)))
8468 (setq gnus-newsgroup-active (gnus-activate-group group))
8470 (gnus-summary-goto-article (cdr group-art) nil t)
8471 (gnus-summary-edit-article)))
8473 (defun gnus-summary-article-posted-p ()
8474 "Say whether the current (mail) article is available from news as well.
8475 This will be the case if the article has both been mailed and posted."
8477 (let ((id (mail-header-references (gnus-summary-article-header)))
8478 (gnus-override-method (car (gnus-refer-article-methods))))
8479 (if (gnus-request-head id "")
8480 (gnus-message 2 "The current message was found on %s"
8481 gnus-override-method)
8482 (gnus-message 2 "The current message couldn't be found on %s"
8483 gnus-override-method)
8486 (defun gnus-summary-expire-articles (&optional now)
8487 "Expire all articles that are marked as expirable in the current group."
8489 (when (gnus-check-backend-function
8490 'request-expire-articles gnus-newsgroup-name)
8491 ;; This backend supports expiry.
8492 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8493 (expirable (if total
8495 ;; We need to update the info for
8496 ;; this group for `gnus-list-of-read-articles'
8497 ;; to give us the right answer.
8498 (gnus-run-hooks 'gnus-exit-group-hook)
8499 (gnus-summary-update-info)
8500 (gnus-list-of-read-articles gnus-newsgroup-name))
8501 (setq gnus-newsgroup-expirable
8502 (sort gnus-newsgroup-expirable '<))))
8503 (expiry-wait (if now 'immediate
8504 (gnus-group-find-parameter
8505 gnus-newsgroup-name 'expiry-wait)))
8506 (nnmail-expiry-target
8507 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8508 nnmail-expiry-target))
8511 ;; There are expirable articles in this group, so we run them
8512 ;; through the expiry process.
8513 (gnus-message 6 "Expiring articles...")
8514 (unless (gnus-check-group gnus-newsgroup-name)
8515 (error "Can't open server for %s" gnus-newsgroup-name))
8516 ;; The list of articles that weren't expired is returned.
8519 (let ((nnmail-expiry-wait-function nil)
8520 (nnmail-expiry-wait expiry-wait))
8521 (setq es (gnus-request-expire-articles
8522 expirable gnus-newsgroup-name)))
8523 (setq es (gnus-request-expire-articles
8524 expirable gnus-newsgroup-name)))
8526 (setq gnus-newsgroup-expirable es))
8527 ;; We go through the old list of expirable, and mark all
8528 ;; really expired articles as nonexistent.
8529 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8530 (let ((gnus-use-cache nil))
8532 (unless (memq (car expirable) es)
8533 (when (gnus-data-find (car expirable))
8534 (gnus-summary-mark-article
8535 (car expirable) gnus-canceled-mark)))
8536 (setq expirable (cdr expirable))))))
8537 (gnus-message 6 "Expiring articles...done")))))
8539 (defun gnus-summary-expire-articles-now ()
8540 "Expunge all expirable articles in the current group.
8541 This means that *all* articles that are marked as expirable will be
8542 deleted forever, right now."
8544 (or gnus-expert-user
8546 "Are you really, really, really sure you want to delete all these messages? ")
8548 (gnus-summary-expire-articles t))
8550 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8551 (defun gnus-summary-delete-article (&optional n)
8552 "Delete the N next (mail) articles.
8553 This command actually deletes articles. This is not a marking
8554 command. The article will disappear forever from your life, never to
8556 If N is negative, delete backwards.
8557 If N is nil and articles have been marked with the process mark,
8558 delete these instead."
8560 (unless (gnus-check-backend-function 'request-expire-articles
8561 gnus-newsgroup-name)
8562 (error "The current newsgroup does not support article deletion"))
8563 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
8564 (error "Couldn't open server"))
8565 ;; Compute the list of articles to delete.
8566 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
8568 (if (and gnus-novice-user
8569 (not (gnus-yes-or-no-p
8570 (format "Do you really want to delete %s forever? "
8571 (if (> (length articles) 1)
8572 (format "these %s articles" (length articles))
8575 ;; Delete the articles.
8576 (setq not-deleted (gnus-request-expire-articles
8577 articles gnus-newsgroup-name 'force))
8579 (gnus-summary-remove-process-mark (car articles))
8580 ;; The backend might not have been able to delete the article
8582 (unless (memq (car articles) not-deleted)
8583 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
8584 (setq articles (cdr articles)))
8586 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
8587 (gnus-summary-position-point)
8588 (gnus-set-mode-line 'summary)
8591 (defun gnus-summary-edit-article (&optional force)
8592 "Edit the current article.
8593 This will have permanent effect only in mail groups.
8594 If FORCE is non-nil, allow editing of articles even in read-only
8598 (set-buffer gnus-summary-buffer)
8599 (let ((mail-parse-charset gnus-newsgroup-charset)
8600 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8601 (gnus-set-global-variables)
8602 (when (and (not force)
8603 (gnus-group-read-only-p))
8604 (error "The current newsgroup does not support article editing"))
8605 (gnus-summary-show-article t)
8606 (gnus-article-edit-article
8608 `(lambda (no-highlight)
8609 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8610 (message-options message-options)
8611 (message-options-set-recipient)
8612 (mail-parse-ignored-charsets
8613 ',gnus-newsgroup-ignored-charsets))
8614 (gnus-summary-edit-article-done
8615 ,(or (mail-header-references gnus-current-headers) "")
8616 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
8618 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8620 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8622 "Make edits to the current article permanent."
8625 ;; The buffer restriction contains the entire article if it exists.
8626 (when (article-goto-body)
8627 (let ((lines (count-lines (point) (point-max)))
8628 (length (- (point-max) (point)))
8629 (case-fold-search t)
8630 (body (copy-marker (point))))
8631 (goto-char (point-min))
8632 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8633 (delete-region (match-beginning 1) (match-end 1))
8634 (insert (number-to-string length)))
8635 (goto-char (point-min))
8636 (when (re-search-forward
8637 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8638 (delete-region (match-beginning 1) (match-end 1))
8639 (insert (number-to-string length)))
8640 (goto-char (point-min))
8641 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8642 (delete-region (match-beginning 1) (match-end 1))
8643 (insert (number-to-string lines))))))
8644 ;; Replace the article.
8645 (let ((buf (current-buffer)))
8647 (insert-buffer-substring buf)
8649 (if (and (not read-only)
8650 (not (gnus-request-replace-article
8651 (cdr gnus-article-current) (car gnus-article-current)
8652 (current-buffer) t)))
8653 (error "Couldn't replace article")
8654 ;; Update the summary buffer.
8656 (equal (message-tokenize-header references " ")
8657 (message-tokenize-header
8658 (or (message-fetch-field "references") "") " ")))
8659 ;; We only have to update this line.
8662 (message-narrow-to-head)
8663 (let ((head (buffer-string))
8666 (insert (format "211 %d Article retrieved.\n"
8667 (cdr gnus-article-current)))
8670 (let ((nntp-server-buffer (current-buffer)))
8671 (setq header (car (gnus-get-newsgroup-headers
8673 (set-buffer gnus-summary-buffer)
8674 gnus-newsgroup-dependencies)
8677 (set-buffer gnus-summary-buffer)
8678 (gnus-data-set-header
8679 (gnus-data-find (cdr gnus-article-current))
8681 (gnus-summary-update-article-line
8682 (cdr gnus-article-current) header)
8683 (if (gnus-summary-goto-subject
8684 (cdr gnus-article-current) nil t)
8685 (gnus-summary-update-secondary-mark
8686 (cdr gnus-article-current))))))))
8688 (set-buffer (or buffer gnus-summary-buffer))
8689 (gnus-summary-update-article (cdr gnus-article-current))
8690 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8691 (gnus-summary-update-secondary-mark
8692 (cdr gnus-article-current))))
8693 ;; Prettify the article buffer again.
8694 (unless no-highlight
8696 (set-buffer gnus-article-buffer)
8697 ;;;!!! Fix this -- article should be rehighlighted.
8698 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8699 (set-buffer gnus-original-article-buffer)
8700 (gnus-request-article
8701 (cdr gnus-article-current)
8702 (car gnus-article-current) (current-buffer))))
8703 ;; Prettify the summary buffer line.
8704 (when (gnus-visual-p 'summary-highlight 'highlight)
8705 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8707 (defun gnus-summary-edit-wash (key)
8708 "Perform editing command KEY in the article buffer."
8712 (message "%s" (concat (this-command-keys) "- "))
8715 (gnus-summary-edit-article)
8716 (execute-kbd-macro (concat (this-command-keys) key))
8717 (gnus-article-edit-done))
8721 (defun gnus-summary-respool-query (&optional silent trace)
8722 "Query where the respool algorithm would put this article."
8724 (let (gnus-mark-article-hook)
8725 (gnus-summary-select-article)
8727 (set-buffer gnus-original-article-buffer)
8729 (message-narrow-to-head)
8730 (let ((groups (nnmail-article-group 'identity trace)))
8733 (message "This message would go to %s"
8734 (mapconcat 'car groups ", "))
8735 (message "This message would go to no groups"))
8738 (defun gnus-summary-respool-trace ()
8739 "Trace where the respool algorithm would put this article.
8740 Display a buffer showing all fancy splitting patterns which matched."
8742 (gnus-summary-respool-query nil t))
8744 ;; Summary marking commands.
8746 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8747 "Mark articles which has the same subject as read, and then select the next.
8748 If UNMARK is positive, remove any kind of mark.
8749 If UNMARK is negative, tick articles."
8752 (setq unmark (prefix-numeric-value unmark)))
8754 (gnus-summary-mark-same-subject
8755 (gnus-summary-article-subject) unmark)))
8756 ;; Select next unread article. If auto-select-same mode, should
8757 ;; select the first unread article.
8758 (gnus-summary-next-article t (and gnus-auto-select-same
8759 (gnus-summary-article-subject)))
8760 (gnus-message 7 "%d article%s marked as %s"
8761 count (if (= count 1) " is" "s are")
8762 (if unmark "unread" "read"))))
8764 (defun gnus-summary-kill-same-subject (&optional unmark)
8765 "Mark articles which has the same subject as read.
8766 If UNMARK is positive, remove any kind of mark.
8767 If UNMARK is negative, tick articles."
8770 (setq unmark (prefix-numeric-value unmark)))
8772 (gnus-summary-mark-same-subject
8773 (gnus-summary-article-subject) unmark)))
8774 ;; If marked as read, go to next unread subject.
8776 ;; Go to next unread subject.
8777 (gnus-summary-next-subject 1 t))
8778 (gnus-message 7 "%d articles are marked as %s"
8779 count (if unmark "unread" "read"))))
8781 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8782 "Mark articles with same SUBJECT as read, and return marked number.
8783 If optional argument UNMARK is positive, remove any kinds of marks.
8784 If optional argument UNMARK is negative, mark articles as unread instead."
8788 ((null unmark) ; Mark as read.
8791 (gnus-summary-mark-article-as-read gnus-killed-mark)
8792 (gnus-summary-show-thread) t)
8793 (gnus-summary-find-subject subject))
8794 (setq count (1+ count))))
8795 ((> unmark 0) ; Tick.
8798 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8799 (gnus-summary-show-thread) t)
8800 (gnus-summary-find-subject subject))
8801 (setq count (1+ count))))
8802 (t ; Mark as unread.
8805 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8806 (gnus-summary-show-thread) t)
8807 (gnus-summary-find-subject subject))
8808 (setq count (1+ count)))))
8809 (gnus-set-mode-line 'summary)
8810 ;; Return the number of marked articles.
8813 (defun gnus-summary-mark-as-processable (n &optional unmark)
8814 "Set the process mark on the next N articles.
8815 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8816 the process mark instead. The difference between N and the actual
8817 number of articles marked is returned."
8819 (if (and (null n) (gnus-region-active-p))
8820 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
8821 (setq n (prefix-numeric-value n))
8822 (let ((backward (< n 0))
8827 (gnus-summary-remove-process-mark
8828 (gnus-summary-article-number))
8829 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8830 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8833 (gnus-message 7 "No more articles"))
8834 (gnus-summary-recenter)
8835 (gnus-summary-position-point)
8838 (defun gnus-summary-unmark-as-processable (n)
8839 "Remove the process mark from the next N articles.
8840 If N is negative, unmark backward instead. The difference between N and
8841 the actual number of articles unmarked is returned."
8843 (gnus-summary-mark-as-processable n t))
8845 (defun gnus-summary-unmark-all-processable ()
8846 "Remove the process mark from all articles."
8849 (while gnus-newsgroup-processable
8850 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8851 (gnus-summary-position-point))
8853 (defun gnus-summary-add-mark (article type)
8854 "Mark ARTICLE with a mark of TYPE."
8855 (let ((vtype (car (assq type gnus-article-mark-lists)))
8858 (error "No such mark type: %s" type)
8859 (setq var (intern (format "gnus-newsgroup-%s" type)))
8860 (set var (cons article (symbol-value var)))
8861 (if (memq type '(processable cached replied forwarded recent saved))
8862 (gnus-summary-update-secondary-mark article)
8863 ;;; !!! This is bogus. We should find out what primary
8864 ;;; !!! mark we want to set.
8865 (gnus-summary-update-mark gnus-del-mark 'unread)))))
8867 (defun gnus-summary-mark-as-expirable (n)
8868 "Mark N articles forward as expirable.
8869 If N is negative, mark backward instead. The difference between N and
8870 the actual number of articles marked is returned."
8872 (gnus-summary-mark-forward n gnus-expirable-mark))
8874 (defun gnus-summary-mark-article-as-replied (article)
8875 "Mark ARTICLE as replied to and update the summary line.
8876 ARTICLE can also be a list of articles."
8877 (interactive (list (gnus-summary-article-number)))
8878 (let ((articles (if (listp article) article (list article))))
8879 (dolist (article articles)
8880 (push article gnus-newsgroup-replied)
8881 (let ((buffer-read-only nil))
8882 (when (gnus-summary-goto-subject article nil t)
8883 (gnus-summary-update-secondary-mark article))))))
8885 (defun gnus-summary-mark-article-as-forwarded (article)
8886 "Mark ARTICLE as forwarded and update the summary line.
8887 ARTICLE can also be a list of articles."
8888 (let ((articles (if (listp article) article (list article))))
8889 (dolist (article articles)
8890 (push article gnus-newsgroup-forwarded)
8891 (let ((buffer-read-only nil))
8892 (when (gnus-summary-goto-subject article nil t)
8893 (gnus-summary-update-secondary-mark article))))))
8895 (defun gnus-summary-set-bookmark (article)
8896 "Set a bookmark in current article."
8897 (interactive (list (gnus-summary-article-number)))
8898 (when (or (not (get-buffer gnus-article-buffer))
8899 (not gnus-current-article)
8900 (not gnus-article-current)
8901 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8902 (error "No current article selected"))
8903 ;; Remove old bookmark, if one exists.
8904 (let ((old (assq article gnus-newsgroup-bookmarks)))
8906 (setq gnus-newsgroup-bookmarks
8907 (delq old gnus-newsgroup-bookmarks))))
8908 ;; Set the new bookmark, which is on the form
8909 ;; (article-number . line-number-in-body).
8913 (set-buffer gnus-article-buffer)
8917 (goto-char (point-min))
8918 (search-forward "\n\n" nil t)
8921 gnus-newsgroup-bookmarks)
8922 (gnus-message 6 "A bookmark has been added to the current article."))
8924 (defun gnus-summary-remove-bookmark (article)
8925 "Remove the bookmark from the current article."
8926 (interactive (list (gnus-summary-article-number)))
8927 ;; Remove old bookmark, if one exists.
8928 (let ((old (assq article gnus-newsgroup-bookmarks)))
8931 (setq gnus-newsgroup-bookmarks
8932 (delq old gnus-newsgroup-bookmarks))
8933 (gnus-message 6 "Removed bookmark."))
8934 (gnus-message 6 "No bookmark in current article."))))
8936 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8937 (defun gnus-summary-mark-as-dormant (n)
8938 "Mark N articles forward as dormant.
8939 If N is negative, mark backward instead. The difference between N and
8940 the actual number of articles marked is returned."
8942 (gnus-summary-mark-forward n gnus-dormant-mark))
8944 (defun gnus-summary-set-process-mark (article)
8945 "Set the process mark on ARTICLE and update the summary line."
8946 (setq gnus-newsgroup-processable
8948 (delq article gnus-newsgroup-processable)))
8949 (when (gnus-summary-goto-subject article)
8950 (gnus-summary-show-thread)
8951 (gnus-summary-goto-subject article)
8952 (gnus-summary-update-secondary-mark article)))
8954 (defun gnus-summary-remove-process-mark (article)
8955 "Remove the process mark from ARTICLE and update the summary line."
8956 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8957 (when (gnus-summary-goto-subject article)
8958 (gnus-summary-show-thread)
8959 (gnus-summary-goto-subject article)
8960 (gnus-summary-update-secondary-mark article)))
8962 (defun gnus-summary-set-saved-mark (article)
8963 "Set the process mark on ARTICLE and update the summary line."
8964 (push article gnus-newsgroup-saved)
8965 (when (gnus-summary-goto-subject article)
8966 (gnus-summary-update-secondary-mark article)))
8968 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8969 "Mark N articles as read forwards.
8970 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8971 The difference between N and the actual number of articles marked is
8973 Iff NO-EXPIRE, auto-expiry will be inhibited."
8975 (gnus-summary-show-thread)
8976 (let ((backward (< n 0))
8977 (gnus-summary-goto-unread
8978 (and gnus-summary-goto-unread
8979 (not (eq gnus-summary-goto-unread 'never))
8980 (not (memq mark (list gnus-unread-mark
8981 gnus-ticked-mark gnus-dormant-mark)))))
8983 (mark (or mark gnus-del-mark)))
8985 (gnus-summary-mark-article nil mark no-expire)
8986 (zerop (gnus-summary-next-subject
8988 (and gnus-summary-goto-unread
8989 (not (eq gnus-summary-goto-unread 'never)))
8993 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8994 (gnus-summary-recenter)
8995 (gnus-summary-position-point)
8996 (gnus-set-mode-line 'summary)
8999 (defun gnus-summary-mark-article-as-read (mark)
9000 "Mark the current article quickly as read with MARK."
9001 (let ((article (gnus-summary-article-number)))
9002 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9003 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9004 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9005 (push (cons article mark) gnus-newsgroup-reads)
9006 ;; Possibly remove from cache, if that is used.
9007 (when gnus-use-cache
9008 (gnus-cache-enter-remove-article article))
9009 ;; Allow the backend to change the mark.
9010 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9011 ;; Check for auto-expiry.
9012 (when (and gnus-newsgroup-auto-expire
9013 (memq mark gnus-auto-expirable-marks))
9014 (setq mark gnus-expirable-mark)
9015 ;; Let the backend know about the mark change.
9016 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9017 (push article gnus-newsgroup-expirable))
9018 ;; Set the mark in the buffer.
9019 (gnus-summary-update-mark mark 'unread)
9022 (defun gnus-summary-mark-article-as-unread (mark)
9023 "Mark the current article quickly as unread with MARK."
9024 (let* ((article (gnus-summary-article-number))
9025 (old-mark (gnus-summary-article-mark article)))
9026 ;; Allow the backend to change the mark.
9027 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9028 (if (eq mark old-mark)
9032 (gnus-error 1 "Can't mark negative article numbers")
9034 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9035 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9036 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9037 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9038 (cond ((= mark gnus-ticked-mark)
9039 (push article gnus-newsgroup-marked))
9040 ((= mark gnus-dormant-mark)
9041 (push article gnus-newsgroup-dormant))
9043 (push article gnus-newsgroup-unreads)))
9044 (gnus-pull article gnus-newsgroup-reads)
9046 ;; See whether the article is to be put in the cache.
9048 (vectorp (gnus-summary-article-header article))
9050 (gnus-cache-possibly-enter-article
9051 gnus-newsgroup-name article
9052 (gnus-summary-article-header article)
9053 (= mark gnus-ticked-mark)
9054 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9057 (gnus-summary-update-mark mark 'unread)
9060 (defun gnus-summary-mark-article (&optional article mark no-expire)
9061 "Mark ARTICLE with MARK. MARK can be any character.
9062 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9063 `??' (dormant) and `?E' (expirable).
9064 If MARK is nil, then the default character `?r' is used.
9065 If ARTICLE is nil, then the article on the current line will be
9067 Iff NO-EXPIRE, auto-expiry will be inhibited."
9068 ;; The mark might be a string.
9069 (when (stringp mark)
9070 (setq mark (aref mark 0)))
9071 ;; If no mark is given, then we check auto-expiring.
9073 (setq mark gnus-del-mark))
9074 (when (and (not no-expire)
9075 gnus-newsgroup-auto-expire
9076 (memq mark gnus-auto-expirable-marks))
9077 (setq mark gnus-expirable-mark))
9078 (let ((article (or article (gnus-summary-article-number)))
9079 (old-mark (gnus-summary-article-mark article)))
9080 ;; Allow the backend to change the mark.
9081 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9082 (if (eq mark old-mark)
9085 (error "No article on current line"))
9086 (if (not (if (or (= mark gnus-unread-mark)
9087 (= mark gnus-ticked-mark)
9088 (= mark gnus-dormant-mark))
9089 (gnus-mark-article-as-unread article mark)
9090 (gnus-mark-article-as-read article mark)))
9092 ;; See whether the article is to be put in the cache.
9094 (not (= mark gnus-canceled-mark))
9095 (vectorp (gnus-summary-article-header article))
9097 (gnus-cache-possibly-enter-article
9098 gnus-newsgroup-name article
9099 (gnus-summary-article-header article)
9100 (= mark gnus-ticked-mark)
9101 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9103 (when (gnus-summary-goto-subject article nil t)
9104 (let ((buffer-read-only nil))
9105 (gnus-summary-show-thread)
9107 (gnus-summary-update-mark mark 'unread)
9110 (defun gnus-summary-update-secondary-mark (article)
9111 "Update the secondary (read, process, cache) mark."
9112 (gnus-summary-update-mark
9113 (cond ((memq article gnus-newsgroup-processable)
9115 ((memq article gnus-newsgroup-cached)
9117 ((memq article gnus-newsgroup-replied)
9119 ((memq article gnus-newsgroup-forwarded)
9120 gnus-forwarded-mark)
9121 ((memq article gnus-newsgroup-saved)
9123 ((memq article gnus-newsgroup-recent)
9125 ((memq article gnus-newsgroup-unseen)
9129 (when (gnus-visual-p 'summary-highlight 'highlight)
9130 (gnus-run-hooks 'gnus-summary-update-hook))
9133 (defun gnus-summary-update-mark (mark type)
9134 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9135 (buffer-read-only nil))
9136 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9138 (when (looking-at "\r")
9140 (when (<= (+ forward (point)) (point-max))
9141 ;; Go to the right position on the line.
9142 (goto-char (+ forward (point)))
9143 ;; Replace the old mark with the new mark.
9144 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9145 ;; Optionally update the marks by some user rule.
9146 (when (eq type 'unread)
9148 (gnus-data-find (gnus-summary-article-number)) mark)
9149 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9151 (defun gnus-mark-article-as-read (article &optional mark)
9152 "Enter ARTICLE in the pertinent lists and remove it from others."
9153 ;; Make the article expirable.
9154 (let ((mark (or mark gnus-del-mark)))
9155 (if (= mark gnus-expirable-mark)
9156 (push article gnus-newsgroup-expirable)
9157 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
9158 ;; Remove from unread and marked lists.
9159 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9160 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9161 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9162 (push (cons article mark) gnus-newsgroup-reads)
9163 ;; Possibly remove from cache, if that is used.
9164 (when gnus-use-cache
9165 (gnus-cache-enter-remove-article article))
9168 (defun gnus-mark-article-as-unread (article &optional mark)
9169 "Enter ARTICLE in the pertinent lists and remove it from others."
9170 (let ((mark (or mark gnus-ticked-mark)))
9173 (gnus-error 1 "Can't mark negative article numbers")
9175 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9176 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9177 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9178 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9180 ;; Unsuppress duplicates?
9181 (when gnus-suppress-duplicates
9182 (gnus-dup-unsuppress-article article))
9184 (cond ((= mark gnus-ticked-mark)
9185 (push article gnus-newsgroup-marked))
9186 ((= mark gnus-dormant-mark)
9187 (push article gnus-newsgroup-dormant))
9189 (push article gnus-newsgroup-unreads)))
9190 (gnus-pull article gnus-newsgroup-reads)
9193 (defalias 'gnus-summary-mark-as-unread-forward
9194 'gnus-summary-tick-article-forward)
9195 (make-obsolete 'gnus-summary-mark-as-unread-forward
9196 'gnus-summary-tick-article-forward)
9197 (defun gnus-summary-tick-article-forward (n)
9198 "Tick N articles forwards.
9199 If N is negative, tick backwards instead.
9200 The difference between N and the number of articles ticked is returned."
9202 (gnus-summary-mark-forward n gnus-ticked-mark))
9204 (defalias 'gnus-summary-mark-as-unread-backward
9205 'gnus-summary-tick-article-backward)
9206 (make-obsolete 'gnus-summary-mark-as-unread-backward
9207 'gnus-summary-tick-article-backward)
9208 (defun gnus-summary-tick-article-backward (n)
9209 "Tick N articles backwards.
9210 The difference between N and the number of articles ticked is returned."
9212 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9214 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9215 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9216 (defun gnus-summary-tick-article (&optional article clear-mark)
9217 "Mark current article as unread.
9218 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9219 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9221 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9224 (defun gnus-summary-mark-as-read-forward (n)
9225 "Mark N articles as read forwards.
9226 If N is negative, mark backwards instead.
9227 The difference between N and the actual number of articles marked is
9230 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9232 (defun gnus-summary-mark-as-read-backward (n)
9233 "Mark the N articles as read backwards.
9234 The difference between N and the actual number of articles marked is
9237 (gnus-summary-mark-forward
9238 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9240 (defun gnus-summary-mark-as-read (&optional article mark)
9241 "Mark current article as read.
9242 ARTICLE specifies the article to be marked as read.
9243 MARK specifies a string to be inserted at the beginning of the line."
9244 (gnus-summary-mark-article article mark))
9246 (defun gnus-summary-clear-mark-forward (n)
9247 "Clear marks from N articles forward.
9248 If N is negative, clear backward instead.
9249 The difference between N and the number of marks cleared is returned."
9251 (gnus-summary-mark-forward n gnus-unread-mark))
9253 (defun gnus-summary-clear-mark-backward (n)
9254 "Clear marks from N articles backward.
9255 The difference between N and the number of marks cleared is returned."
9257 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9259 (defun gnus-summary-mark-unread-as-read ()
9260 "Intended to be used by `gnus-summary-mark-article-hook'."
9261 (when (memq gnus-current-article gnus-newsgroup-unreads)
9262 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9264 (defun gnus-summary-mark-read-and-unread-as-read ()
9265 "Intended to be used by `gnus-summary-mark-article-hook'."
9266 (let ((mark (gnus-summary-article-mark)))
9267 (when (or (gnus-unread-mark-p mark)
9268 (gnus-read-mark-p mark))
9269 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9271 (defun gnus-summary-mark-unread-as-ticked ()
9272 "Intended to be used by `gnus-summary-mark-article-hook'."
9273 (when (memq gnus-current-article gnus-newsgroup-unreads)
9274 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9276 (defun gnus-summary-mark-region-as-read (point mark all)
9277 "Mark all unread articles between point and mark as read.
9278 If given a prefix, mark all articles between point and mark as read,
9279 even ticked and dormant ones."
9280 (interactive "r\nP")
9289 (memq (setq article (gnus-summary-article-number))
9290 gnus-newsgroup-unreads))
9291 (gnus-summary-mark-article article gnus-del-mark))
9293 (gnus-summary-find-next))))))
9295 (defun gnus-summary-mark-below (score mark)
9296 "Mark articles with score less than SCORE with MARK."
9297 (interactive "P\ncMark: ")
9298 (setq score (if score
9299 (prefix-numeric-value score)
9300 (or gnus-summary-default-score 0)))
9302 (set-buffer gnus-summary-buffer)
9303 (goto-char (point-min))
9306 (and (< (gnus-summary-article-score) score)
9307 (gnus-summary-mark-article nil mark))
9308 (gnus-summary-find-next)))))
9310 (defun gnus-summary-kill-below (&optional score)
9311 "Mark articles with score below SCORE as read."
9313 (gnus-summary-mark-below score gnus-killed-mark))
9315 (defun gnus-summary-clear-above (&optional score)
9316 "Clear all marks from articles with score above SCORE."
9318 (gnus-summary-mark-above score gnus-unread-mark))
9320 (defun gnus-summary-tick-above (&optional score)
9321 "Tick all articles with score above SCORE."
9323 (gnus-summary-mark-above score gnus-ticked-mark))
9325 (defun gnus-summary-mark-above (score mark)
9326 "Mark articles with score over SCORE with MARK."
9327 (interactive "P\ncMark: ")
9328 (setq score (if score
9329 (prefix-numeric-value score)
9330 (or gnus-summary-default-score 0)))
9332 (set-buffer gnus-summary-buffer)
9333 (goto-char (point-min))
9335 (when (> (gnus-summary-article-score) score)
9336 (gnus-summary-mark-article nil mark))
9338 (gnus-summary-find-next)))))
9340 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9341 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9342 (defun gnus-summary-limit-include-expunged (&optional no-error)
9343 "Display all the hidden articles that were expunged for low scores."
9345 (let ((buffer-read-only nil))
9346 (let ((scored gnus-newsgroup-scored)
9349 (unless (gnus-summary-article-header (caar scored))
9350 (and (setq h (gnus-number-to-header (caar scored)))
9351 (< (cdar scored) gnus-summary-expunge-below)
9353 (setq scored (cdr scored)))
9355 (when (not no-error)
9356 (error "No expunged articles hidden"))
9357 (goto-char (point-min))
9358 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9359 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9360 (mapcar (lambda (x) (push (mail-header-number x)
9361 gnus-newsgroup-limit))
9363 (gnus-summary-prepare-unthreaded (nreverse headers))
9364 (goto-char (point-min))
9365 (gnus-summary-position-point)
9368 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9369 "Mark all unread articles in this newsgroup as read.
9370 If prefix argument ALL is non-nil, ticked and dormant articles will
9371 also be marked as read.
9372 If QUIETLY is non-nil, no questions will be asked.
9373 If TO-HERE is non-nil, it should be a point in the buffer. All
9374 articles before (after, if REVERSE is set) this point will be marked as read.
9375 Note that this function will only catch up the unread article
9376 in the current summary buffer limitation.
9377 The number of articles marked as read is returned."
9382 (not gnus-interactive-catchup) ;Without confirmation?
9386 "Mark absolutely all articles as read? "
9387 "Mark all unread articles as read? ")))
9389 (not gnus-newsgroup-adaptive)
9390 (not gnus-newsgroup-auto-expire)
9391 (not gnus-suppress-duplicates)
9392 (or (not gnus-use-cache)
9393 (eq gnus-use-cache 'passive)))
9396 (setq gnus-newsgroup-marked nil
9397 gnus-newsgroup-dormant nil))
9398 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9399 ;; We actually mark all articles as canceled, which we
9400 ;; have to do when using auto-expiry or adaptive scoring.
9401 (gnus-summary-show-all-threads)
9402 (if (and to-here reverse)
9406 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9407 (gnus-summary-find-next (not all) nil nil t))))
9408 (when (gnus-summary-first-subject (not all) t)
9410 (if to-here (< (point) to-here) t)
9411 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9412 (gnus-summary-find-next (not all) nil nil t)))))
9413 (gnus-set-mode-line 'summary))
9415 (gnus-summary-position-point)))
9417 (defun gnus-summary-catchup-to-here (&optional all)
9418 "Mark all unticked articles before the current one as read.
9419 If ALL is non-nil, also mark ticked and dormant articles as read."
9422 (gnus-save-hidden-threads
9423 (let ((beg (point)))
9424 ;; We check that there are unread articles.
9425 (when (or all (gnus-summary-find-prev))
9426 (gnus-summary-catchup all t beg)))))
9427 (gnus-summary-position-point))
9429 (defun gnus-summary-catchup-from-here (&optional all)
9430 "Mark all unticked articles after the current one as read.
9431 If ALL is non-nil, also mark ticked and dormant articles as read."
9434 (gnus-save-hidden-threads
9435 (let ((beg (point)))
9436 ;; We check that there are unread articles.
9437 (when (or all (gnus-summary-find-next))
9438 (gnus-summary-catchup all t beg nil t)))))
9439 (gnus-summary-position-point))
9441 (defun gnus-summary-catchup-all (&optional quietly)
9442 "Mark all articles in this newsgroup as read."
9444 (gnus-summary-catchup t quietly))
9446 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9447 "Mark all unread articles in this group as read, then exit.
9448 If prefix argument ALL is non-nil, all articles are marked as read.
9449 If QUIETLY is non-nil, no questions will be asked."
9451 (when (gnus-summary-catchup all quietly nil 'fast)
9452 ;; Select next newsgroup or exit.
9453 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9454 (eq gnus-auto-select-next 'quietly))
9455 (gnus-summary-next-group nil)
9456 (gnus-summary-exit))))
9458 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9459 "Mark all articles in this newsgroup as read, and then exit."
9461 (gnus-summary-catchup-and-exit t quietly))
9463 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9464 "Mark all articles in this group as read and select the next group.
9465 If given a prefix, mark all articles, unread as well as ticked, as
9469 (gnus-summary-catchup all))
9470 (gnus-summary-next-group))
9476 (defmacro gnus-with-article (article &rest forms)
9477 "Select ARTICLE and perform FORMS in the original article buffer.
9478 Then replace the article with the result."
9480 ;; We don't want the article to be marked as read.
9481 (let (gnus-mark-article-hook)
9482 (gnus-summary-select-article t t nil ,article))
9483 (set-buffer gnus-original-article-buffer)
9485 (if (not (gnus-check-backend-function
9486 'request-replace-article (car gnus-article-current)))
9487 (gnus-message 5 "Read-only group; not replacing")
9488 (unless (gnus-request-replace-article
9489 ,article (car gnus-article-current)
9491 (error "Couldn't replace article")))
9492 ;; The cache and backlog have to be flushed somewhat.
9493 (when gnus-keep-backlog
9494 (gnus-backlog-remove-article
9495 (car gnus-article-current) (cdr gnus-article-current)))
9496 (when gnus-use-cache
9497 (gnus-cache-update-article
9498 (car gnus-article-current) (cdr gnus-article-current)))))
9500 (put 'gnus-with-article 'lisp-indent-function 1)
9501 (put 'gnus-with-article 'edebug-form-spec '(form body))
9503 ;; Thread-based commands.
9505 (defun gnus-summary-articles-in-thread (&optional article)
9506 "Return a list of all articles in the current thread.
9507 If ARTICLE is non-nil, return all articles in the thread that starts
9509 (let* ((article (or article (gnus-summary-article-number)))
9510 (data (gnus-data-find-list article))
9511 (top-level (gnus-data-level (car data)))
9513 (cond ((null gnus-thread-operation-ignore-subject)
9514 (gnus-simplify-subject-re
9515 (mail-header-subject (gnus-data-header (car data)))))
9516 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9517 (gnus-simplify-subject-fuzzy
9518 (mail-header-subject (gnus-data-header (car data)))))
9520 (end-point (save-excursion
9521 (if (gnus-summary-go-to-next-thread)
9522 (point) (point-max))))
9525 (< (gnus-data-pos (car data)) end-point))
9526 (when (or (not top-subject)
9527 (string= top-subject
9528 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9529 (gnus-simplify-subject-fuzzy
9530 (mail-header-subject
9531 (gnus-data-header (car data))))
9532 (gnus-simplify-subject-re
9533 (mail-header-subject
9534 (gnus-data-header (car data)))))))
9535 (push (gnus-data-number (car data)) articles))
9536 (unless (and (setq data (cdr data))
9537 (> (gnus-data-level (car data)) top-level))
9539 ;; Return the list of articles.
9540 (nreverse articles)))
9542 (defun gnus-summary-rethread-current ()
9543 "Rethread the thread the current article is part of."
9545 (let* ((gnus-show-threads t)
9546 (article (gnus-summary-article-number))
9547 (id (mail-header-id (gnus-summary-article-header)))
9548 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
9550 (error "No article on the current line"))
9551 (gnus-rebuild-thread id)
9552 (gnus-summary-goto-subject article)))
9554 (defun gnus-summary-reparent-thread ()
9555 "Make the current article child of the marked (or previous) article.
9557 Note that the re-threading will only work if `gnus-thread-ignore-subject'
9558 is non-nil or the Subject: of both articles are the same."
9560 (unless (not (gnus-group-read-only-p))
9561 (error "The current newsgroup does not support article editing"))
9562 (unless (<= (length gnus-newsgroup-processable) 1)
9563 (error "No more than one article may be marked"))
9564 (save-window-excursion
9565 (let ((gnus-article-buffer " *reparent*")
9566 (current-article (gnus-summary-article-number))
9567 ;; First grab the marked article, otherwise one line up.
9568 (parent-article (if (not (null gnus-newsgroup-processable))
9569 (car gnus-newsgroup-processable)
9571 (if (eq (forward-line -1) 0)
9572 (gnus-summary-article-number)
9573 (error "Beginning of summary buffer"))))))
9574 (unless (not (eq current-article parent-article))
9575 (error "An article may not be self-referential"))
9576 (let ((message-id (mail-header-id
9577 (gnus-summary-article-header parent-article))))
9578 (unless (and message-id (not (equal message-id "")))
9579 (error "No message-id in desired parent"))
9580 (gnus-with-article current-article
9582 (goto-char (point-min))
9583 (message-narrow-to-head)
9584 (if (re-search-forward "^References: " nil t)
9586 (re-search-forward "^[^ \t]" nil t)
9589 (insert " " message-id))
9590 (insert "References: " message-id "\n"))))
9591 (set-buffer gnus-summary-buffer)
9592 (gnus-summary-unmark-all-processable)
9593 (gnus-summary-update-article current-article)
9594 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9595 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
9596 (gnus-summary-rethread-current)
9597 (gnus-message 3 "Article %d is now the child of article %d"
9598 current-article parent-article)))))
9600 (defun gnus-summary-toggle-threads (&optional arg)
9601 "Toggle showing conversation threads.
9602 If ARG is positive number, turn showing conversation threads on."
9604 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
9605 (setq gnus-show-threads
9606 (if (null arg) (not gnus-show-threads)
9607 (> (prefix-numeric-value arg) 0)))
9608 (gnus-summary-prepare)
9609 (gnus-summary-goto-subject current)
9610 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
9611 (gnus-summary-position-point)))
9613 (defun gnus-summary-show-all-threads ()
9617 (let ((buffer-read-only nil))
9618 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
9619 (gnus-summary-position-point))
9621 (defun gnus-summary-show-thread ()
9622 "Show thread subtrees.
9623 Returns nil if no thread was there to be shown."
9625 (let ((buffer-read-only nil)
9627 ;; first goto end then to beg, to have point at beg after let
9628 (end (progn (end-of-line) (point)))
9629 (beg (progn (beginning-of-line) (point))))
9631 ;; Any hidden lines here?
9632 (search-forward "\r" end t)
9633 (subst-char-in-region beg end ?\^M ?\n t)
9635 (gnus-summary-position-point))))
9637 (defun gnus-summary-hide-all-threads ()
9638 "Hide all thread subtrees."
9641 (goto-char (point-min))
9642 (gnus-summary-hide-thread)
9643 (while (zerop (gnus-summary-next-thread 1 t))
9644 (gnus-summary-hide-thread)))
9645 (gnus-summary-position-point))
9647 (defun gnus-summary-hide-thread ()
9648 "Hide thread subtrees.
9649 Returns nil if no threads were there to be hidden."
9651 (let ((buffer-read-only nil)
9653 (article (gnus-summary-article-number)))
9655 ;; Go forward until either the buffer ends or the subthread
9657 (when (and (not (eobp))
9658 (or (zerop (gnus-summary-next-thread 1 t))
9659 (goto-char (point-max))))
9661 (if (and (> (point) start)
9662 (search-backward "\n" start t))
9664 (subst-char-in-region start (point) ?\n ?\^M)
9665 (gnus-summary-goto-subject article))
9669 (defun gnus-summary-go-to-next-thread (&optional previous)
9670 "Go to the same level (or less) next thread.
9671 If PREVIOUS is non-nil, go to previous thread instead.
9672 Return the article number moved to, or nil if moving was impossible."
9673 (let ((level (gnus-summary-thread-level))
9674 (way (if previous -1 1))
9677 (while (and (not (eobp))
9678 (< level (gnus-summary-thread-level)))
9686 (gnus-summary-article-number)
9689 (defun gnus-summary-next-thread (n &optional silent)
9690 "Go to the same level next N'th thread.
9691 If N is negative, search backward instead.
9692 Returns the difference between N and the number of skips actually
9695 If SILENT, don't output messages."
9697 (let ((backward (< n 0))
9700 (gnus-summary-go-to-next-thread backward))
9703 (gnus-summary-position-point))
9704 (when (and (not silent) (/= 0 n))
9705 (gnus-message 7 "No more threads"))
9708 (defun gnus-summary-prev-thread (n)
9709 "Go to the same level previous N'th thread.
9710 Returns the difference between N and the number of skips actually
9713 (gnus-summary-next-thread (- n)))
9715 (defun gnus-summary-go-down-thread ()
9716 "Go down one level in the current thread."
9717 (let ((children (gnus-summary-article-children)))
9719 (gnus-summary-goto-subject (car children)))))
9721 (defun gnus-summary-go-up-thread ()
9722 "Go up one level in the current thread."
9723 (let ((parent (gnus-summary-article-parent)))
9725 (gnus-summary-goto-subject parent))))
9727 (defun gnus-summary-down-thread (n)
9728 "Go down thread N steps.
9729 If N is negative, go up instead.
9730 Returns the difference between N and how many steps down that were
9736 (if up (gnus-summary-go-up-thread)
9737 (gnus-summary-go-down-thread)))
9739 (gnus-summary-position-point)
9741 (gnus-message 7 "Can't go further"))
9744 (defun gnus-summary-up-thread (n)
9745 "Go up thread N steps.
9746 If N is negative, go down instead.
9747 Returns the difference between N and how many steps down that were
9750 (gnus-summary-down-thread (- n)))
9752 (defun gnus-summary-top-thread ()
9753 "Go to the top of the thread."
9755 (while (gnus-summary-go-up-thread))
9756 (gnus-summary-article-number))
9758 (defun gnus-summary-kill-thread (&optional unmark)
9759 "Mark articles under current thread as read.
9760 If the prefix argument is positive, remove any kinds of marks.
9761 If the prefix argument is negative, tick articles instead."
9764 (setq unmark (prefix-numeric-value unmark)))
9765 (let ((articles (gnus-summary-articles-in-thread)))
9767 ;; Expand the thread.
9768 (gnus-summary-show-thread)
9769 ;; Mark all the articles.
9771 (gnus-summary-goto-subject (car articles))
9772 (cond ((null unmark)
9773 (gnus-summary-mark-article-as-read gnus-killed-mark))
9775 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9777 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9778 (setq articles (cdr articles))))
9779 ;; Hide killed subtrees.
9781 gnus-thread-hide-killed
9782 (gnus-summary-hide-thread))
9783 ;; If marked as read, go to next unread subject.
9785 ;; Go to next unread subject.
9786 (gnus-summary-next-subject 1 t)))
9787 (gnus-set-mode-line 'summary))
9789 ;; Summary sorting commands
9791 (defun gnus-summary-sort-by-number (&optional reverse)
9792 "Sort the summary buffer by article number.
9793 Argument REVERSE means reverse order."
9795 (gnus-summary-sort 'number reverse))
9797 (defun gnus-summary-sort-by-author (&optional reverse)
9798 "Sort the summary buffer by author name alphabetically.
9799 If `case-fold-search' is non-nil, case of letters is ignored.
9800 Argument REVERSE means reverse order."
9802 (gnus-summary-sort 'author reverse))
9804 (defun gnus-summary-sort-by-subject (&optional reverse)
9805 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9806 If `case-fold-search' is non-nil, case of letters is ignored.
9807 Argument REVERSE means reverse order."
9809 (gnus-summary-sort 'subject reverse))
9811 (defun gnus-summary-sort-by-date (&optional reverse)
9812 "Sort the summary buffer by date.
9813 Argument REVERSE means reverse order."
9815 (gnus-summary-sort 'date reverse))
9817 (defun gnus-summary-sort-by-score (&optional reverse)
9818 "Sort the summary buffer by score.
9819 Argument REVERSE means reverse order."
9821 (gnus-summary-sort 'score reverse))
9823 (defun gnus-summary-sort-by-lines (&optional reverse)
9824 "Sort the summary buffer by the number of lines.
9825 Argument REVERSE means reverse order."
9827 (gnus-summary-sort 'lines reverse))
9829 (defun gnus-summary-sort-by-chars (&optional reverse)
9830 "Sort the summary buffer by article length.
9831 Argument REVERSE means reverse order."
9833 (gnus-summary-sort 'chars reverse))
9835 (defun gnus-summary-sort-by-original (&optional reverse)
9836 "Sort the summary buffer using the default sorting method.
9837 Argument REVERSE means reverse order."
9839 (let* ((buffer-read-only)
9840 (gnus-summary-prepare-hook nil))
9841 ;; We do the sorting by regenerating the threads.
9842 (gnus-summary-prepare)
9843 ;; Hide subthreads if needed.
9844 (when (and gnus-show-threads gnus-thread-hide-subtree)
9845 (gnus-summary-hide-all-threads))))
9847 (defun gnus-summary-sort (predicate reverse)
9848 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9849 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9850 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9851 (gnus-thread-sort-functions
9856 (gnus-sort-gathered-threads-function
9857 gnus-thread-sort-functions)
9858 (gnus-article-sort-functions
9864 (gnus-summary-prepare-hook nil))
9865 ;; We do the sorting by regenerating the threads.
9866 (gnus-summary-prepare)
9867 ;; Hide subthreads if needed.
9868 (when (and gnus-show-threads gnus-thread-hide-subtree)
9869 (gnus-summary-hide-all-threads))))
9871 ;; Summary saving commands.
9873 (defun gnus-summary-save-article (&optional n not-saved)
9874 "Save the current article using the default saver function.
9875 If N is a positive number, save the N next articles.
9876 If N is a negative number, save the N previous articles.
9877 If N is nil and any articles have been marked with the process mark,
9878 save those articles instead.
9879 The variable `gnus-default-article-saver' specifies the saver function."
9881 (let* ((articles (gnus-summary-work-articles n))
9882 (save-buffer (save-excursion
9883 (nnheader-set-temp-buffer " *Gnus Save*")))
9884 (num (length articles))
9886 (dolist (article articles)
9887 (setq header (gnus-summary-article-header article))
9888 (if (not (vectorp header))
9889 ;; This is a pseudo-article.
9890 (if (assq 'name header)
9891 (gnus-copy-file (cdr (assq 'name header)))
9892 (gnus-message 1 "Article %d is unsaveable" article))
9893 ;; This is a real article.
9894 (save-window-excursion
9895 (gnus-summary-select-article t nil nil article))
9897 (set-buffer save-buffer)
9899 (insert-buffer-substring gnus-original-article-buffer))
9900 (setq file (gnus-article-save save-buffer file num))
9901 (gnus-summary-remove-process-mark article)
9903 (gnus-summary-set-saved-mark article))))
9904 (gnus-kill-buffer save-buffer)
9905 (gnus-summary-position-point)
9906 (gnus-set-mode-line 'summary)
9909 (defun gnus-summary-pipe-output (&optional arg)
9910 "Pipe the current article to a subprocess.
9911 If N is a positive number, pipe the N next articles.
9912 If N is a negative number, pipe the N previous articles.
9913 If N is nil and any articles have been marked with the process mark,
9914 pipe those articles instead."
9917 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9918 (gnus-summary-save-article arg t))
9919 (let ((buffer (get-buffer "*Shell Command Output*")))
9921 (with-current-buffer buffer (> (point-max) (point-min))))
9922 (gnus-configure-windows 'pipe))))
9924 (defun gnus-summary-save-article-mail (&optional arg)
9925 "Append the current article to an mail file.
9926 If N is a positive number, save the N next articles.
9927 If N is a negative number, save the N previous articles.
9928 If N is nil and any articles have been marked with the process mark,
9929 save those articles instead."
9932 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9933 (gnus-summary-save-article arg)))
9935 (defun gnus-summary-save-article-rmail (&optional arg)
9936 "Append the current article to an rmail file.
9937 If N is a positive number, save the N next articles.
9938 If N is a negative number, save the N previous articles.
9939 If N is nil and any articles have been marked with the process mark,
9940 save those articles instead."
9943 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9944 (gnus-summary-save-article arg)))
9946 (defun gnus-summary-save-article-file (&optional arg)
9947 "Append the current article to a file.
9948 If N is a positive number, save the N next articles.
9949 If N is a negative number, save the N previous articles.
9950 If N is nil and any articles have been marked with the process mark,
9951 save those articles instead."
9954 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9955 (gnus-summary-save-article arg)))
9957 (defun gnus-summary-write-article-file (&optional arg)
9958 "Write the current article to a file, deleting the previous file.
9959 If N is a positive number, save the N next articles.
9960 If N is a negative number, save the N previous articles.
9961 If N is nil and any articles have been marked with the process mark,
9962 save those articles instead."
9965 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9966 (gnus-summary-save-article arg)))
9968 (defun gnus-summary-save-article-body-file (&optional arg)
9969 "Append the current article body to a file.
9970 If N is a positive number, save the N next articles.
9971 If N is a negative number, save the N previous articles.
9972 If N is nil and any articles have been marked with the process mark,
9973 save those articles instead."
9976 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9977 (gnus-summary-save-article arg)))
9979 (defun gnus-summary-pipe-message (program)
9980 "Pipe the current article through PROGRAM."
9981 (interactive "sProgram: ")
9982 (gnus-summary-select-article)
9983 (let ((mail-header-separator ""))
9984 (gnus-eval-in-buffer-window gnus-article-buffer
9987 (let ((start (window-start))
9989 (message-pipe-buffer-body program)
9990 (set-window-start (get-buffer-window (current-buffer)) start))))))
9992 (defun gnus-get-split-value (methods)
9993 "Return a value based on the split METHODS."
9994 (let (split-name method result match)
9997 (set-buffer gnus-original-article-buffer)
9999 (nnheader-narrow-to-headers)
10000 (while (and methods (not split-name))
10001 (goto-char (point-min))
10002 (setq method (pop methods))
10003 (setq match (car method))
10006 ;; Regular expression.
10008 (re-search-forward match nil t)))
10009 ((gnus-functionp match)
10013 (setq result (funcall match gnus-newsgroup-name))))
10018 (setq result (eval match)))))
10019 (setq split-name (cdr method))
10020 (cond ((stringp result)
10021 (push (expand-file-name
10022 result gnus-article-save-directory)
10025 (setq split-name (append result split-name)))))))))
10026 (nreverse split-name)))
10028 (defun gnus-valid-move-group-p (group)
10029 (and (boundp group)
10030 (symbol-name group)
10031 (symbol-value group)
10032 (gnus-get-function (gnus-find-method-for-group
10033 (symbol-name group)) 'request-accept-article t)))
10035 (defun gnus-read-move-group-name (prompt default articles prefix)
10036 "Read a group name."
10037 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10038 (minibuffer-confirm-incomplete nil) ; XEmacs
10040 (format "%s %s to:"
10042 (if (> (length articles) 1)
10043 (format "these %d articles" (length articles))
10048 (gnus-completing-read default prom
10050 'gnus-valid-move-group-p
10052 'gnus-group-history))
10053 ((= 1 (length split-name))
10054 (gnus-completing-read (car split-name) prom
10056 'gnus-valid-move-group-p
10058 'gnus-group-history))
10060 (gnus-completing-read nil prom
10061 (mapcar (lambda (el) (list el))
10062 (nreverse split-name))
10064 'gnus-group-history))))
10065 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10067 (if (or (string= to-newsgroup "")
10068 (string= to-newsgroup prefix))
10069 (setq to-newsgroup default))
10070 (unless to-newsgroup
10071 (error "No group name entered"))
10072 (or (gnus-active to-newsgroup)
10073 (gnus-activate-group to-newsgroup nil nil to-method)
10074 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10076 (or (and (gnus-request-create-group to-newsgroup to-method)
10077 (gnus-activate-group
10078 to-newsgroup nil nil to-method)
10079 (gnus-subscribe-group to-newsgroup))
10080 (error "Couldn't create group %s" to-newsgroup)))
10081 (error "No such group: %s" to-newsgroup)))
10084 (defun gnus-summary-save-parts (type dir n &optional reverse)
10085 "Save parts matching TYPE to DIR.
10086 If REVERSE, save parts that do not match TYPE."
10088 (list (read-string "Save parts of type: "
10089 (or (car gnus-summary-save-parts-type-history)
10090 gnus-summary-save-parts-default-mime)
10091 'gnus-summary-save-parts-type-history)
10092 (setq gnus-summary-save-parts-last-directory
10093 (read-file-name "Save to directory: "
10094 gnus-summary-save-parts-last-directory
10096 current-prefix-arg))
10097 (gnus-summary-iterate n
10098 (let ((gnus-display-mime-function nil)
10099 (gnus-inhibit-treatment t))
10100 (gnus-summary-select-article))
10102 (set-buffer gnus-article-buffer)
10103 (let ((handles (or gnus-article-mime-handles
10104 (mm-dissect-buffer) (mm-uu-dissect))))
10106 (gnus-summary-save-parts-1 type dir handles reverse)
10107 (unless gnus-article-mime-handles ;; Don't destroy this case.
10108 (mm-destroy-parts handles)))))))
10110 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10111 (if (stringp (car handle))
10112 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10115 (not (string-match type (mm-handle-media-type handle)))
10116 (string-match type (mm-handle-media-type handle)))
10117 (let ((file (expand-file-name
10118 (file-name-nondirectory
10120 (mail-content-type-get
10121 (mm-handle-disposition handle) 'filename)
10122 (concat gnus-newsgroup-name
10123 "." (number-to-string
10124 (cdr gnus-article-current)))))
10126 (unless (file-exists-p file)
10127 (mm-save-part-to-file handle file))))))
10129 ;; Summary extract commands
10131 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10132 (let ((buffer-read-only nil)
10133 (article (gnus-summary-article-number))
10135 (unless (gnus-summary-goto-subject article)
10136 (error "No such article: %d" article))
10137 (gnus-summary-position-point)
10138 ;; If all commands are to be bunched up on one line, we collect
10140 (unless gnus-view-pseudos-separately
10141 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10144 (setq action (cdr (assq 'action (car ps))))
10145 (setq files (list (cdr (assq 'name (car ps)))))
10146 (while (and ps (cdr ps)
10147 (string= (or action "1")
10148 (or (cdr (assq 'action (cadr ps))) "2")))
10149 (push (cdr (assq 'name (cadr ps))) files)
10150 (setcdr ps (cddr ps)))
10152 (when (not (string-match "%s" action))
10155 (when (assq 'execute (car ps))
10156 (setcdr (assq 'execute (car ps))
10157 (funcall (if (string-match "%s" action)
10164 (gnus-quote-arg-for-sh-or-csh f)))
10166 (setq ps (cdr ps)))))
10167 (if (and gnus-view-pseudos (not not-view))
10169 (when (assq 'execute (car pslist))
10170 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10171 (eq gnus-view-pseudos 'not-confirm)))
10172 (setq pslist (cdr pslist)))
10175 (setq after-article (or (cdr (assq 'article (car pslist)))
10176 (gnus-summary-article-number)))
10177 (gnus-summary-goto-subject after-article)
10180 (insert " " (file-name-nondirectory
10181 (cdr (assq 'name (car pslist))))
10182 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10184 (forward-line -1) ; back to `b'
10185 (gnus-add-text-properties
10186 b (1- e) (list 'gnus-number gnus-reffed-article-number
10187 gnus-mouse-face-prop gnus-mouse-face))
10189 after-article gnus-reffed-article-number
10190 gnus-unread-mark b (car pslist) 0 (- e b))
10191 (push gnus-reffed-article-number gnus-newsgroup-unreads)
10192 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10193 (setq pslist (cdr pslist)))))))
10195 (defun gnus-pseudos< (p1 p2)
10196 (let ((c1 (cdr (assq 'action p1)))
10197 (c2 (cdr (assq 'action p2))))
10198 (and c1 c2 (string< c1 c2))))
10200 (defun gnus-request-pseudo-article (props)
10201 (cond ((assq 'execute props)
10202 (gnus-execute-command (cdr (assq 'execute props)))))
10203 (let ((gnus-current-article (gnus-summary-article-number)))
10204 (gnus-run-hooks 'gnus-mark-article-hook)))
10206 (defun gnus-execute-command (command &optional automatic)
10208 (gnus-article-setup-buffer)
10209 (set-buffer gnus-article-buffer)
10210 (setq buffer-read-only nil)
10211 (let ((command (if automatic command
10212 (read-string "Command: " (cons command 0)))))
10214 (insert "$ " command "\n\n")
10215 (if gnus-view-pseudo-asynchronously
10216 (start-process "gnus-execute" (current-buffer) shell-file-name
10217 shell-command-switch command)
10218 (call-process shell-file-name nil t nil
10219 shell-command-switch command)))))
10221 ;; Summary kill commands.
10223 (defun gnus-summary-edit-global-kill (article)
10224 "Edit the \"global\" kill file."
10225 (interactive (list (gnus-summary-article-number)))
10226 (gnus-group-edit-global-kill article))
10228 (defun gnus-summary-edit-local-kill ()
10229 "Edit a local kill file applied to the current newsgroup."
10231 (setq gnus-current-headers (gnus-summary-article-header))
10232 (gnus-group-edit-local-kill
10233 (gnus-summary-article-number) gnus-newsgroup-name))
10235 ;;; Header reading.
10237 (defun gnus-read-header (id &optional header)
10238 "Read the headers of article ID and enter them into the Gnus system."
10239 (let ((group gnus-newsgroup-name)
10240 (gnus-override-method
10242 gnus-override-method
10243 (and (gnus-news-group-p gnus-newsgroup-name)
10244 (car (gnus-refer-article-methods)))))
10246 ;; First we check to see whether the header in question is already
10249 ;; This is a Message-ID.
10250 (setq header (or header (gnus-id-to-header id)))
10251 ;; This is an article number.
10252 (setq header (or header (gnus-summary-article-header id))))
10254 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10255 ;; We have found the header.
10257 ;; If this is a sparse article, we have to nix out its
10258 ;; previous entry in the thread hashtb.
10260 (gnus-summary-article-sparse-p (mail-header-number header)))
10261 (let* ((parent (gnus-parent-id (mail-header-references header)))
10262 (thread (and parent (gnus-id-to-thread parent))))
10264 (delq (assq header thread) thread))))
10265 ;; We have to really fetch the header to this article.
10267 (set-buffer nntp-server-buffer)
10268 (when (setq where (gnus-request-head id group))
10269 (nnheader-fold-continuation-lines)
10270 (goto-char (point-max))
10272 (goto-char (point-min))
10276 ((cdr where) (cdr where))
10277 (header (mail-header-number header))
10278 (t gnus-reffed-article-number))
10280 (insert " Article retrieved.\n"))
10281 (if (or (not where)
10282 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10283 () ; Malformed head.
10284 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10285 (when (and (stringp id)
10286 (not (string= (gnus-group-real-name group)
10288 ;; If we fetched by Message-ID and the article came
10289 ;; from a different group, we fudge some bogus article
10290 ;; numbers for this article.
10291 (mail-header-set-number header gnus-reffed-article-number))
10293 (set-buffer gnus-summary-buffer)
10294 (decf gnus-reffed-article-number)
10295 (gnus-remove-header (mail-header-number header))
10296 (push header gnus-newsgroup-headers)
10297 (setq gnus-current-headers header)
10298 (push (mail-header-number header) gnus-newsgroup-limit)))
10301 (defun gnus-remove-header (number)
10302 "Remove header NUMBER from `gnus-newsgroup-headers'."
10303 (if (and gnus-newsgroup-headers
10304 (= number (mail-header-number (car gnus-newsgroup-headers))))
10305 (pop gnus-newsgroup-headers)
10306 (let ((headers gnus-newsgroup-headers))
10307 (while (and (cdr headers)
10308 (not (= number (mail-header-number (cadr headers)))))
10310 (when (cdr headers)
10311 (setcdr headers (cddr headers))))))
10314 ;;; summary highlights
10317 (defun gnus-highlight-selected-summary ()
10318 "Highlight selected article in summary buffer."
10319 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10320 (when gnus-summary-selected-face
10322 (let* ((beg (progn (beginning-of-line) (point)))
10323 (end (progn (end-of-line) (point)))
10324 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10325 (from (if (get-text-property beg gnus-mouse-face-prop)
10327 (or (next-single-property-change
10328 beg gnus-mouse-face-prop nil end)
10333 (or (next-single-property-change
10334 from gnus-mouse-face-prop nil end)
10336 ;; If no mouse-face prop on line we will have to = from = end,
10337 ;; so we highlight the entire line instead.
10338 (when (= (+ to 2) from)
10341 (if gnus-newsgroup-selected-overlay
10342 ;; Move old overlay.
10344 gnus-newsgroup-selected-overlay from to (current-buffer))
10345 ;; Create new overlay.
10347 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10348 'face gnus-summary-selected-face))))))
10350 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10351 (defun gnus-summary-highlight-line ()
10352 "Highlight current line according to `gnus-summary-highlight'."
10353 (let* ((list gnus-summary-highlight)
10355 (end (progn (end-of-line) (point)))
10356 ;; now find out where the line starts and leave point there.
10357 (beg (progn (beginning-of-line) (point)))
10358 (article (gnus-summary-article-number))
10359 (score (or (cdr (assq (or article gnus-current-article)
10360 gnus-newsgroup-scored))
10361 gnus-summary-default-score 0))
10362 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10363 (inhibit-read-only t))
10364 ;; Eval the cars of the lists until we find a match.
10365 (let ((default gnus-summary-default-score)
10366 (default-high gnus-summary-default-high-score)
10367 (default-low gnus-summary-default-low-score))
10369 (not (eval (caar list))))
10370 (setq list (cdr list))))
10371 (let ((face (cdar list)))
10372 (unless (eq face (get-text-property beg 'face))
10373 (gnus-put-text-property-excluding-characters-with-faces
10375 (setq face (if (boundp face) (symbol-value face) face)))
10376 (when gnus-summary-highlight-line-function
10377 (funcall gnus-summary-highlight-line-function article face))))
10380 (defun gnus-update-read-articles (group unread &optional compute)
10381 "Update the list of read articles in GROUP."
10382 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10383 (entry (gnus-gethash group gnus-newsrc-hashtb))
10384 (info (nth 2 entry))
10386 (unread (sort (copy-sequence unread) '<))
10388 (if (or (not info) (not active))
10389 ;; There is no info on this group if it was, in fact,
10390 ;; killed. Gnus stores no information on killed groups, so
10391 ;; there's nothing to be done.
10392 ;; One could store the information somewhere temporarily,
10393 ;; perhaps... Hmmm...
10395 ;; Remove any negative articles numbers.
10396 (while (and unread (< (car unread) 0))
10397 (setq unread (cdr unread)))
10398 ;; Remove any expired article numbers
10399 (while (and unread (< (car unread) (car active)))
10400 (setq unread (cdr unread)))
10401 ;; Compute the ranges of read articles by looking at the list of
10402 ;; unread articles.
10404 (when (/= (car unread) prev)
10405 (push (if (= prev (1- (car unread))) prev
10406 (cons prev (1- (car unread))))
10408 (setq prev (1+ (car unread)))
10409 (setq unread (cdr unread)))
10410 (when (<= prev (cdr active))
10411 (push (cons prev (cdr active)) read))
10412 (setq read (if (> (length read) 1) (nreverse read) read))
10417 ;; Propagate the read marks to the backend.
10418 (when (gnus-check-backend-function 'request-set-mark group)
10419 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10420 (add (gnus-remove-from-range read (gnus-info-read info))))
10422 (unless (gnus-check-group group)
10423 (error "Can't open server for %s" group))
10424 (gnus-request-set-mark
10425 group (delq nil (list (if add (list add 'add '(read)))
10426 (if del (list del 'del '(read))))))
10428 `(gnus-request-set-mark
10431 (if del (list del 'add '(read)))
10432 (if add (list add 'del '(read))))))))))
10433 (set-buffer gnus-group-buffer)
10434 (gnus-undo-register
10436 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10437 (gnus-info-set-read ',info ',(gnus-info-read info))
10438 (gnus-get-unread-articles-in-group ',info
10439 (gnus-active ,group))
10440 (gnus-group-update-group ,group t)
10442 ;; Enter this list into the group info.
10443 (gnus-info-set-read info read)
10444 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10445 (gnus-get-unread-articles-in-group info (gnus-active group))
10448 (defun gnus-offer-save-summaries ()
10449 "Offer to save all active summary buffers."
10451 ;; Go through all buffers and find all summaries.
10452 (dolist (buffer (buffer-list))
10453 (when (and (setq buffer (buffer-name buffer))
10454 (string-match "Summary" buffer)
10456 (set-buffer buffer)
10457 ;; We check that this is, indeed, a summary buffer.
10458 (and (eq major-mode 'gnus-summary-mode)
10459 ;; Also make sure this isn't bogus.
10460 gnus-newsgroup-prepared
10461 ;; Also make sure that this isn't a
10462 ;; dead summary buffer.
10463 (not gnus-dead-summary-mode))))
10464 (push buffer buffers)))
10465 ;; Go through all these summary buffers and offer to save them.
10469 "Update summary buffer %s? "
10471 (switch-to-buffer buf)
10472 (gnus-summary-exit))
10476 ;;; @ for mime-partial
10479 (defun gnus-request-partial-message ()
10481 (let ((number (gnus-summary-article-number))
10482 (group gnus-newsgroup-name)
10483 (mother gnus-article-buffer))
10484 (set-buffer (get-buffer-create " *Partial Article*"))
10486 (setq mime-preview-buffer mother)
10487 (gnus-request-article-this-buffer number group)
10488 (mime-parse-buffer)
10491 (autoload 'mime-combine-message/partial-pieces-automatically
10493 "Internal method to combine message/partial messages automatically.")
10495 (mime-add-condition
10496 'action '((type . message)(subtype . partial)
10497 (major-mode . gnus-original-article-mode)
10498 (method . mime-combine-message/partial-pieces-automatically)
10499 (summary-buffer-exp . gnus-summary-buffer)
10500 (request-partial-message-method . gnus-request-partial-message)
10504 ;;; @ for message/rfc822
10507 (defun gnus-mime-extract-message/rfc822 (entity situation)
10508 (let (group article num cwin swin cur)
10510 (mime-insert-entity-content entity)
10511 (setq group (or (cdr (assq 'group situation))
10512 (completing-read "Group: "
10515 (gnus-read-active-file-p)
10516 gnus-newsgroup-name))
10517 article (gnus-request-accept-article group)))
10518 (when (and (consp article)
10519 (numberp (setq article (cdr article))))
10520 (setq num (1+ (or (cdr (assq 'number situation)) 0))
10521 cwin (get-buffer-window (current-buffer) t))
10522 (save-window-excursion
10523 (if (setq swin (get-buffer-window gnus-summary-buffer t))
10524 (select-window swin)
10525 (set-buffer gnus-summary-buffer))
10526 (setq cur gnus-current-article)
10528 (let (gnus-show-threads)
10529 (gnus-summary-goto-subject article t))
10530 (gnus-summary-clear-mark-forward 1)
10531 (gnus-summary-goto-subject cur))
10532 (when (and cwin (window-frame cwin))
10533 (select-frame (window-frame cwin)))
10534 (when (boundp 'mime-acting-situation-to-override)
10535 (set-alist 'mime-acting-situation-to-override
10538 (set-alist 'mime-acting-situation-to-override
10541 (save-current-buffer
10542 (set-buffer gnus-group-buffer)
10543 (gnus-activate-group ,group))
10544 (gnus-summary-goto-article ,cur
10545 gnus-show-all-headers)))
10546 (set-alist 'mime-acting-situation-to-override
10549 (mime-add-condition
10550 'action '((type . message)(subtype . rfc822)
10551 (major-mode . gnus-original-article-mode)
10552 (method . gnus-mime-extract-message/rfc822)
10556 (mime-add-condition
10557 'action '((type . message)(subtype . news)
10558 (major-mode . gnus-original-article-mode)
10559 (method . gnus-mime-extract-message/rfc822)
10563 (defun gnus-mime-extract-multipart (entity situation)
10564 (let ((children (mime-entity-children entity))
10565 mime-acting-situation-to-override
10568 (mime-play-entity (car children)
10569 (cons (assq 'mode situation)
10570 mime-acting-situation-to-override))
10571 (setq children (cdr children)))
10572 (if (setq f (cdr (assq 'after-method
10573 mime-acting-situation-to-override)))
10577 (mime-add-condition
10578 'action '((type . multipart)
10579 (method . gnus-mime-extract-multipart)
10588 (defun gnus-summary-setup-default-charset ()
10589 "Setup newsgroup default charset."
10590 (if (equal gnus-newsgroup-name "nndraft:drafts")
10591 (setq gnus-newsgroup-charset nil)
10592 (let* ((ignored-charsets
10593 (or gnus-newsgroup-ephemeral-ignored-charsets
10595 (and gnus-newsgroup-name
10596 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
10597 gnus-newsgroup-ignored-charsets))))
10598 (setq gnus-newsgroup-charset
10599 (or gnus-newsgroup-ephemeral-charset
10600 (and gnus-newsgroup-name
10601 (gnus-parameter-charset gnus-newsgroup-name))
10602 gnus-default-charset))
10603 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
10604 ignored-charsets))))
10610 (defun gnus-summary-display-buttonized (&optional show-all-parts)
10611 "Display the current article buffer fully MIME-buttonized.
10612 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
10613 treated as multipart/mixed."
10615 (require 'gnus-art)
10616 (let ((gnus-unbuttonized-mime-types nil)
10617 (gnus-mime-display-multipart-as-mixed show-all-parts))
10618 (gnus-summary-show-article)))
10620 (defun gnus-summary-repair-multipart (article)
10621 "Add a Content-Type header to a multipart article without one."
10622 (interactive (list (gnus-summary-article-number)))
10623 (gnus-with-article article
10624 (message-narrow-to-head)
10625 (message-remove-header "Mime-Version")
10626 (goto-char (point-max))
10627 (insert "Mime-Version: 1.0\n")
10629 (when (search-forward "\n--" nil t)
10630 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
10631 (message-narrow-to-head)
10632 (message-remove-header "Content-Type")
10633 (goto-char (point-max))
10634 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
10637 (let (gnus-mark-article-hook)
10638 (gnus-summary-select-article t t nil article)))
10640 (defun gnus-summary-toggle-display-buttonized ()
10641 "Toggle the buttonizing of the article buffer."
10643 (require 'gnus-art)
10644 (if (setq gnus-inhibit-mime-unbuttonizing
10645 (not gnus-inhibit-mime-unbuttonizing))
10646 (let ((gnus-unbuttonized-mime-types nil))
10647 (gnus-summary-show-article))
10648 (gnus-summary-show-article)))
10651 ;;; Intelli-mouse commmands
10654 (defun gnus-wheel-summary-scroll (event)
10656 (let ((amount (if (memq 'shift (event-modifiers event))
10657 (car gnus-wheel-scroll-amount)
10658 (cdr gnus-wheel-scroll-amount)))
10659 (direction (- (* (static-if (featurep 'xemacs)
10660 (event-button event)
10661 (cond ((eq 'mouse-4 (event-basic-type event))
10663 ((eq 'mouse-5 (event-basic-type event))
10667 (gnus-summary-scroll-up (* amount direction))
10668 (when (gnus-eval-in-buffer-window gnus-article-buffer
10671 (and (if (< 0 direction)
10672 (gnus-article-next-page 0)
10673 (gnus-article-prev-page 0)
10675 (if (setq edge (get-text-property
10676 (point-min) 'gnus-wheel-edge))
10677 (setq edge (* edge direction))
10680 (let ((buffer-read-only nil)
10681 (inhibit-read-only t))
10682 (put-text-property (point-min) (point-max)
10683 'gnus-wheel-edge direction)
10685 (or (> edge gnus-wheel-edge-resistance)
10686 (let ((buffer-read-only nil)
10687 (inhibit-read-only t))
10688 (put-text-property (point-min) (point-max)
10690 (* (1+ edge) direction))
10692 (eq last-command 'gnus-wheel-summary-scroll))))
10693 (gnus-summary-next-article nil nil (minusp direction)))))
10695 (defun gnus-wheel-install ()
10696 "Enable mouse wheel support on summary window."
10697 (when gnus-use-wheel
10699 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
10701 (define-key gnus-summary-mode-map key
10702 'gnus-wheel-summary-scroll)))))
10704 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
10707 ;;; Traditional PGP commmands
10710 (defun gnus-summary-decrypt-article (&optional force)
10711 "Decrypt the current article in traditional PGP way.
10712 This will have permanent effect only in mail groups.
10713 If FORCE is non-nil, allow editing of articles even in read-only
10716 (gnus-summary-select-article t)
10717 (gnus-eval-in-buffer-window gnus-article-buffer
10721 (goto-char (point-min))
10722 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
10723 (error "Not a traditional PGP message!"))
10724 (let ((armor-start (match-beginning 0)))
10725 (if (and (pgg-decrypt-region armor-start (point-max))
10726 (or force (not (gnus-group-read-only-p))))
10727 (let ((inhibit-read-only t)
10729 (delete-region armor-start
10731 (re-search-forward "^-+END PGP" nil t)
10732 (beginning-of-line 2)
10734 (insert-buffer-substring pgg-output-buffer))))))))
10736 (defun gnus-summary-verify-article ()
10737 "Verify the current article in traditional PGP way."
10740 (set-buffer gnus-original-article-buffer)
10741 (goto-char (point-min))
10742 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
10743 (error "Not a traditional PGP message!"))
10744 (re-search-forward "^-+END PGP" nil t)
10745 (beginning-of-line 2)
10746 (call-interactively (function pgg-verify-region))))
10749 ;;; Generic summary marking commands
10752 (defvar gnus-summary-marking-alist
10753 '((read gnus-del-mark "d")
10754 (unread gnus-unread-mark "u")
10755 (ticked gnus-ticked-mark "!")
10756 (dormant gnus-dormant-mark "?")
10757 (expirable gnus-expirable-mark "e"))
10758 "An alist of names/marks/keystrokes.")
10760 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
10761 (defvar gnus-summary-mark-map)
10763 (defun gnus-summary-make-all-marking-commands ()
10764 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
10765 (dolist (elem gnus-summary-marking-alist)
10766 (apply 'gnus-summary-make-marking-command elem)))
10768 (defun gnus-summary-make-marking-command (name mark keystroke)
10769 (let ((map (make-sparse-keymap)))
10770 (define-key gnus-summary-generic-mark-map keystroke map)
10771 (dolist (lway `((next "next" next nil "n")
10772 (next-unread "next unread" next t "N")
10773 (prev "previous" prev nil "p")
10774 (prev-unread "previous unread" prev t "P")
10775 (nomove "" nil nil ,keystroke)))
10776 (let ((func (gnus-summary-make-marking-command-1
10777 mark (car lway) lway name)))
10778 (setq func (eval func))
10779 (define-key map (nth 4 lway) func)))))
10781 (defun gnus-summary-make-marking-command-1 (mark way lway name)
10783 (format "gnus-summary-put-mark-as-%s%s"
10784 name (if (eq way 'nomove)
10786 (concat "-" (symbol-name way)))))
10789 "Mark the current article as %s%s.
10790 If N, the prefix, then repeat N times.
10791 If N is negative, move in reverse order.
10792 The difference between N and the actual number of articles marked is
10794 name (car (cdr lway)))
10796 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
10798 (defun gnus-summary-generic-mark (n mark move unread)
10799 "Mark N articles with MARK."
10800 (unless (eq major-mode 'gnus-summary-mode)
10801 (error "This command can only be used in the summary buffer"))
10802 (gnus-summary-show-thread)
10805 ((eq move 'next) 1)
10806 ((eq move 'prev) -1)
10808 (if (zerop nummove)
10812 nummove (* -1 nummove))))
10813 (while (and (> n 0)
10814 (gnus-summary-mark-article nil mark)
10815 (zerop (gnus-summary-next-subject nummove unread t)))
10818 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10819 (gnus-summary-recenter)
10820 (gnus-summary-position-point)
10821 (gnus-set-mode-line 'summary)
10824 (defun gnus-summary-insert-articles (articles)
10825 (when (setq articles
10826 (gnus-set-difference articles
10827 (mapcar (lambda (h) (mail-header-number h))
10828 gnus-newsgroup-headers)))
10829 (setq gnus-newsgroup-headers
10831 gnus-newsgroup-headers
10832 (gnus-fetch-headers articles)
10833 'gnus-article-sort-by-number))
10834 ;; Suppress duplicates?
10835 (when gnus-suppress-duplicates
10836 (gnus-dup-suppress-articles))
10838 ;; We might want to build some more threads first.
10839 (when (and gnus-fetch-old-headers
10840 (eq gnus-headers-retrieved-by 'nov))
10841 (if (eq gnus-fetch-old-headers 'invisible)
10842 (gnus-build-all-threads)
10843 (gnus-build-old-threads)))
10844 ;; Let the Gnus agent mark articles as read.
10846 (gnus-agent-get-undownloaded-list))
10847 ;; Remove list identifiers from subject
10848 (when gnus-list-identifiers
10849 (gnus-summary-remove-list-identifiers))
10850 ;; First and last article in this newsgroup.
10851 (when gnus-newsgroup-headers
10852 (setq gnus-newsgroup-begin
10853 (mail-header-number (car gnus-newsgroup-headers))
10855 (mail-header-number
10856 (gnus-last-element gnus-newsgroup-headers))))
10857 (when gnus-use-scoring
10858 (gnus-possibly-score-headers))))
10860 (defun gnus-summary-insert-old-articles (&optional all)
10861 "Insert all old articles in this group.
10862 If ALL is non-nil, already read articles become readable.
10863 If ALL is a number, fetch this number of articles."
10866 (let ((old (mapcar 'car gnus-newsgroup-data))
10867 (i (car gnus-newsgroup-active))
10869 (while (<= i (cdr gnus-newsgroup-active))
10870 (or (memq i old) (push i older))
10872 (setq len (length older))
10877 (setq older (subseq older 0 all))))
10880 (if (and (numberp gnus-large-newsgroup)
10881 (> len gnus-large-newsgroup))
10885 "How many articles from %s (default %d): "
10887 (gnus-group-decoded-name gnus-newsgroup-name) 35)
10889 (unless (string-match "^[ \t]*$" input)
10890 (setq all (string-to-number input))
10892 (setq older (subseq older 0 all))))))))
10894 (message "No old news.")
10895 (gnus-summary-insert-articles older)
10896 (gnus-summary-limit (gnus-union older old))))
10897 (gnus-summary-position-point)))
10899 (defun gnus-summary-insert-new-articles ()
10900 "Insert all new articles in this group."
10903 (let ((old (mapcar 'car gnus-newsgroup-data))
10904 (old-active gnus-newsgroup-active)
10905 (nnmail-fetched-sources (list t))
10907 (setq gnus-newsgroup-active
10908 (gnus-activate-group gnus-newsgroup-name 'scan))
10909 (setq i (1+ (cdr old-active)))
10910 (while (<= i (cdr gnus-newsgroup-active))
10914 (message "No gnus is bad news.")
10915 (setq new (nreverse new))
10916 (gnus-summary-insert-articles new)
10917 (setq gnus-newsgroup-unreads
10918 (append gnus-newsgroup-unreads new))
10919 (gnus-summary-limit (gnus-union old new))))
10920 (gnus-summary-position-point)))
10922 (gnus-summary-make-all-marking-commands)
10924 (gnus-ems-redefine)
10926 (provide 'gnus-sum)
10928 (run-hooks 'gnus-sum-load-hook)
10930 ;;; gnus-sum.el ends here