1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 ;; (require 'gnus-art)
42 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
43 (autoload 'gnus-cache-write-active "gnus-cache")
44 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
45 (autoload 'mm-uu-dissect "mm-uu")
47 (defcustom gnus-kill-summary-on-exit t
48 "*If non-nil, kill the summary buffer when you exit from it.
49 If nil, the summary will become a \"*Dead Summary*\" buffer, and
50 it will be killed sometime later."
51 :group 'gnus-summary-exit
54 (defcustom gnus-fetch-old-headers nil
55 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
56 If an unread article in the group refers to an older, already read (or
57 just marked as read) article, the old article will not normally be
58 displayed in the Summary buffer. If this variable is non-nil, Gnus
59 will attempt to grab the headers to the old articles, and thereby
60 build complete threads. If it has the value `some', only enough
61 headers to connect otherwise loose threads will be displayed. This
62 variable can also be a number. In that case, no more than that number
63 of old headers will be fetched. If it has the value `invisible', all
64 old headers will be fetched, but none will be displayed.
66 The server has to support NOV for any of this to work."
68 :type '(choice (const :tag "off" nil)
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-refer-thread-limit 200
74 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
75 If t, fetch all the available old headers."
78 (sexp :menu-tag "other" t)))
80 (defcustom gnus-summary-make-false-root 'adopt
81 "*nil means that Gnus won't gather loose threads.
82 If the root of a thread has expired or been read in a previous
83 session, the information necessary to build a complete thread has been
84 lost. Instead of having many small sub-threads from this original thread
85 scattered all over the summary buffer, Gnus can gather them.
87 If non-nil, Gnus will try to gather all loose sub-threads from an
88 original thread into one large thread.
90 If this variable is non-nil, it should be one of `none', `adopt',
93 If this variable is `none', Gnus will not make a false root, but just
94 present the sub-threads after another.
95 If this variable is `dummy', Gnus will create a dummy root that will
96 have all the sub-threads as children.
97 If this variable is `adopt', Gnus will make one of the \"children\"
98 the parent and mark all the step-children as such.
99 If this variable is `empty', the \"children\" are printed with empty
100 subject fields. (Or rather, they will be printed with a string
101 given by the `gnus-summary-same-subject' variable.)"
103 :type '(choice (const :tag "off" nil)
109 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
110 "*A regexp to match subjects to be excluded from loose thread gathering.
111 As loose thread gathering is done on subjects only, that means that
112 there can be many false gatherings performed. By rooting out certain
113 common subjects, gathering might become saner."
117 (defcustom gnus-summary-gather-subject-limit nil
118 "*Maximum length of subject comparisons when gathering loose threads.
119 Use nil to compare full subjects. Setting this variable to a low
120 number will help gather threads that have been corrupted by
121 newsreaders chopping off subject lines, but it might also mean that
122 unrelated articles that have subject that happen to begin with the
123 same few characters will be incorrectly gathered.
125 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
128 :type '(choice (const :tag "off" nil)
130 (sexp :menu-tag "on" t)))
132 (defcustom gnus-simplify-subject-functions nil
133 "List of functions taking a string argument that simplify subjects.
134 The functions are applied recursively.
136 Useful functions to put in this list include: `gnus-simplify-subject-re',
137 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
139 :type '(repeat function))
141 (defcustom gnus-simplify-ignored-prefixes nil
142 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
144 :type '(choice (const :tag "off" nil)
147 (defcustom gnus-build-sparse-threads nil
148 "*If non-nil, fill in the gaps in threads.
149 If `some', only fill in the gaps that are needed to tie loose threads
150 together. If `more', fill in all leaf nodes that Gnus can find. If
151 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
153 :type '(choice (const :tag "off" nil)
156 (sexp :menu-tag "all" t)))
158 (defcustom gnus-summary-thread-gathering-function
159 'gnus-gather-threads-by-subject
160 "*Function used for gathering loose threads.
161 There are two pre-defined functions: `gnus-gather-threads-by-subject',
162 which only takes Subjects into consideration; and
163 `gnus-gather-threads-by-references', which compared the References
164 headers of the articles to find matches."
166 :type '(radio (function-item gnus-gather-threads-by-subject)
167 (function-item gnus-gather-threads-by-references)
168 (function :tag "other")))
170 (defcustom gnus-summary-same-subject ""
171 "*String indicating that the current article has the same subject as the previous.
172 This variable will only be used if the value of
173 `gnus-summary-make-false-root' is `empty'."
174 :group 'gnus-summary-format
177 (defcustom gnus-summary-goto-unread t
178 "*If t, many commands will go to the next unread article.
179 This applies to marking commands as well as other commands that
180 \"naturally\" select the next article, like, for instance, `SPC' at
181 the end of an article.
183 If nil, the marking commands do NOT go to the next unread article
184 (they go to the next article instead). If `never', commands that
185 usually go to the next unread article, will go to the next article,
186 whether it is read or not."
187 :group 'gnus-summary-marks
188 :link '(custom-manual "(gnus)Setting Marks")
189 :type '(choice (const :tag "off" nil)
191 (sexp :menu-tag "on" t)))
193 (defcustom gnus-summary-default-score 0
194 "*Default article score level.
195 All scores generated by the score files will be added to this score.
196 If this variable is nil, scoring will be disabled."
197 :group 'gnus-score-default
198 :type '(choice (const :tag "disable")
201 (defcustom gnus-summary-zcore-fuzz 0
202 "*Fuzziness factor for the zcore in the summary buffer.
203 Articles with scores closer than this to `gnus-summary-default-score'
205 :group 'gnus-summary-format
208 (defcustom gnus-simplify-subject-fuzzy-regexp nil
209 "*Strings to be removed when doing fuzzy matches.
210 This can either be a regular expression or list of regular expressions
211 that will be removed from subject strings if fuzzy subject
212 simplification is selected."
214 :type '(repeat regexp))
216 (defcustom gnus-show-threads t
217 "*If non-nil, display threads in summary mode."
221 (defcustom gnus-thread-hide-subtree nil
222 "*If non-nil, hide all threads initially.
223 If threads are hidden, you have to run the command
224 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
225 to expose hidden threads."
229 (defcustom gnus-thread-hide-killed t
230 "*If non-nil, hide killed threads automatically."
234 (defcustom gnus-thread-ignore-subject t
235 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
236 If nil, articles that have different subjects from their parents will
237 start separate threads."
241 (defcustom gnus-thread-operation-ignore-subject t
242 "*If non-nil, subjects will be ignored when doing thread commands.
243 This affects commands like `gnus-summary-kill-thread' and
244 `gnus-summary-lower-thread'.
246 If this variable is nil, articles in the same thread with different
247 subjects will not be included in the operation in question. If this
248 variable is `fuzzy', only articles that have subjects that are fuzzily
249 equal will be included."
251 :type '(choice (const :tag "off" nil)
255 (defcustom gnus-thread-indent-level 4
256 "*Number that says how much each sub-thread should be indented."
260 (defcustom gnus-auto-extend-newsgroup t
261 "*If non-nil, extend newsgroup forward and backward when requested."
262 :group 'gnus-summary-choose
265 (defcustom gnus-auto-select-first t
266 "*If nil, don't select the first unread article when entering a group.
267 If this variable is `best', select the highest-scored unread article
268 in the group. If t, select the first unread article.
270 This variable can also be a function to place point on a likely
271 subject line. Useful values include `gnus-summary-first-unread-subject',
272 `gnus-summary-first-unread-article' and
273 `gnus-summary-best-unread-article'.
275 If you want to prevent automatic selection of the first unread article
276 in some newsgroups, set the variable to nil in
277 `gnus-select-group-hook'."
278 :group 'gnus-group-select
279 :type '(choice (const :tag "none" nil)
281 (sexp :menu-tag "first" t)
282 (function-item gnus-summary-first-unread-subject)
283 (function-item gnus-summary-first-unread-article)
284 (function-item gnus-summary-best-unread-article)))
286 (defcustom gnus-auto-select-next t
287 "*If non-nil, offer to go to the next group from the end of the previous.
288 If the value is t and the next newsgroup is empty, Gnus will exit
289 summary mode and go back to group mode. If the value is neither nil
290 nor t, Gnus will select the following unread newsgroup. In
291 particular, if the value is the symbol `quietly', the next unread
292 newsgroup will be selected without any confirmation, and if it is
293 `almost-quietly', the next group will be selected without any
294 confirmation if you are located on the last article in the group.
295 Finally, if this variable is `slightly-quietly', the `Z n' command
296 will go to the next group without confirmation."
297 :group 'gnus-summary-maneuvering
298 :type '(choice (const :tag "off" nil)
300 (const almost-quietly)
301 (const slightly-quietly)
302 (sexp :menu-tag "on" t)))
304 (defcustom gnus-auto-select-same nil
305 "*If non-nil, select the next article with the same subject.
306 If there are no more articles with the same subject, go to
307 the first unread article."
308 :group 'gnus-summary-maneuvering
311 (defcustom gnus-summary-check-current nil
312 "*If non-nil, consider the current article when moving.
313 The \"unread\" movement commands will stay on the same line if the
314 current article is unread."
315 :group 'gnus-summary-maneuvering
318 (defcustom gnus-auto-center-summary t
319 "*If non-nil, always center the current summary buffer.
320 In particular, if `vertical' do only vertical recentering. If non-nil
321 and non-`vertical', do both horizontal and vertical recentering."
322 :group 'gnus-summary-maneuvering
323 :type '(choice (const :tag "none" nil)
325 (integer :tag "height")
326 (sexp :menu-tag "both" t)))
328 (defcustom gnus-show-all-headers nil
329 "*If non-nil, don't hide any headers."
330 :group 'gnus-article-hiding
331 :group 'gnus-article-headers
334 (defcustom gnus-summary-ignore-duplicates nil
335 "*If non-nil, ignore articles with identical Message-ID headers."
339 (defcustom gnus-single-article-buffer t
340 "*If non-nil, display all articles in the same buffer.
341 If nil, each group will get its own article buffer."
342 :group 'gnus-article-various
345 (defcustom gnus-break-pages t
346 "*If non-nil, do page breaking on articles.
347 The page delimiter is specified by the `gnus-page-delimiter'
349 :group 'gnus-article-various
352 (defcustom gnus-move-split-methods nil
353 "*Variable used to suggest where articles are to be moved to.
354 It uses the same syntax as the `gnus-split-methods' variable.
355 However, whereas `gnus-split-methods' specifies file names as targets,
356 this variable specifies group names."
357 :group 'gnus-summary-mail
358 :type '(repeat (choice (list :value (fun) function)
359 (cons :value ("" "") regexp (repeat string))
362 (defcustom gnus-unread-mark ? ;Whitespace
363 "*Mark used for unread articles."
364 :group 'gnus-summary-marks
367 (defcustom gnus-ticked-mark ?!
368 "*Mark used for ticked articles."
369 :group 'gnus-summary-marks
372 (defcustom gnus-dormant-mark ??
373 "*Mark used for dormant articles."
374 :group 'gnus-summary-marks
377 (defcustom gnus-del-mark ?r
378 "*Mark used for del'd articles."
379 :group 'gnus-summary-marks
382 (defcustom gnus-read-mark ?R
383 "*Mark used for read articles."
384 :group 'gnus-summary-marks
387 (defcustom gnus-expirable-mark ?E
388 "*Mark used for expirable articles."
389 :group 'gnus-summary-marks
392 (defcustom gnus-killed-mark ?K
393 "*Mark used for killed articles."
394 :group 'gnus-summary-marks
397 (defcustom gnus-souped-mark ?F
398 "*Mark used for killed articles."
399 :group 'gnus-summary-marks
402 (defcustom gnus-kill-file-mark ?X
403 "*Mark used for articles killed by kill files."
404 :group 'gnus-summary-marks
407 (defcustom gnus-low-score-mark ?Y
408 "*Mark used for articles with a low score."
409 :group 'gnus-summary-marks
412 (defcustom gnus-catchup-mark ?C
413 "*Mark used for articles that are caught up."
414 :group 'gnus-summary-marks
417 (defcustom gnus-replied-mark ?A
418 "*Mark used for articles that have been replied to."
419 :group 'gnus-summary-marks
422 (defcustom gnus-cached-mark ?*
423 "*Mark used for articles that are in the cache."
424 :group 'gnus-summary-marks
427 (defcustom gnus-saved-mark ?S
428 "*Mark used for articles that have been saved to."
429 :group 'gnus-summary-marks
432 (defcustom gnus-ancient-mark ?O
433 "*Mark used for ancient articles."
434 :group 'gnus-summary-marks
437 (defcustom gnus-sparse-mark ?Q
438 "*Mark used for sparsely reffed articles."
439 :group 'gnus-summary-marks
442 (defcustom gnus-canceled-mark ?G
443 "*Mark used for canceled articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-duplicate-mark ?M
448 "*Mark used for duplicate articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-undownloaded-mark ?@
453 "*Mark used for articles that weren't downloaded."
454 :group 'gnus-summary-marks
457 (defcustom gnus-downloadable-mark ?%
458 "*Mark used for articles that are to be downloaded."
459 :group 'gnus-summary-marks
462 (defcustom gnus-unsendable-mark ?=
463 "*Mark used for articles that won't be sent."
464 :group 'gnus-summary-marks
467 (defcustom gnus-score-over-mark ?+
468 "*Score mark used for articles with high scores."
469 :group 'gnus-summary-marks
472 (defcustom gnus-score-below-mark ?-
473 "*Score mark used for articles with low scores."
474 :group 'gnus-summary-marks
477 (defcustom gnus-empty-thread-mark ? ;Whitespace
478 "*There is no thread under the article."
479 :group 'gnus-summary-marks
482 (defcustom gnus-not-empty-thread-mark ?=
483 "*There is a thread under the article."
484 :group 'gnus-summary-marks
487 (defcustom gnus-view-pseudo-asynchronously nil
488 "*If non-nil, Gnus will view pseudo-articles asynchronously."
489 :group 'gnus-extract-view
492 (defcustom gnus-auto-expirable-marks
493 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
494 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
495 gnus-souped-mark gnus-duplicate-mark)
496 "*The list of marks converted into expiration if a group is auto-expirable."
499 :type '(repeat character))
501 (defcustom gnus-inhibit-user-auto-expire t
502 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
507 (defcustom gnus-view-pseudos nil
508 "*If `automatic', pseudo-articles will be viewed automatically.
509 If `not-confirm', pseudos will be viewed automatically, and the user
510 will not be asked to confirm the command."
511 :group 'gnus-extract-view
512 :type '(choice (const :tag "off" nil)
514 (const not-confirm)))
516 (defcustom gnus-view-pseudos-separately t
517 "*If non-nil, one pseudo-article will be created for each file to be viewed.
518 If nil, all files that use the same viewing command will be given as a
519 list of parameters to that command."
520 :group 'gnus-extract-view
523 (defcustom gnus-insert-pseudo-articles t
524 "*If non-nil, insert pseudo-articles when decoding articles."
525 :group 'gnus-extract-view
528 (defcustom gnus-summary-dummy-line-format
530 "*The format specification for the dummy roots in the summary buffer.
531 It works along the same lines as a normal formatting string,
532 with some simple extensions.
535 :group 'gnus-threading
538 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
539 "*The format specification for the summary mode line.
540 It works along the same lines as a normal formatting string,
541 with some simple extensions:
544 %p Unprefixed group name
545 %A Current article number
546 %z Current article score
548 %U Number of unread articles in the group
549 %e Number of unselected articles in the group
550 %Z A string with unread/unselected article counts
551 %g Shortish group name
552 %S Subject of the current article
554 %s Current score file name
555 %d Number of dormant articles
556 %r Number of articles that have been marked as read in this session
557 %E Number of articles expunged by the score files"
558 :group 'gnus-summary-format
561 (defcustom gnus-list-identifiers nil
562 "Regexp that matches list identifiers to be removed from subject.
563 This can also be a list of regexps."
565 :group 'gnus-summary-format
566 :group 'gnus-article-hiding
567 :type '(choice (const :tag "none" nil)
569 (repeat :value (".*") regexp)))
571 (defcustom gnus-summary-mark-below 0
572 "*Mark all articles with a score below this variable as read.
573 This variable is local to each summary buffer and usually set by the
575 :group 'gnus-score-default
578 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
579 "*List of functions used for sorting articles in the summary buffer.
580 This variable is only used when not using a threaded display."
581 :group 'gnus-summary-sort
582 :type '(repeat (choice (function-item gnus-article-sort-by-number)
583 (function-item gnus-article-sort-by-author)
584 (function-item gnus-article-sort-by-subject)
585 (function-item gnus-article-sort-by-date)
586 (function-item gnus-article-sort-by-score)
587 (function :tag "other"))))
589 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
590 "*List of functions used for sorting threads in the summary buffer.
591 By default, threads are sorted by article number.
593 Each function takes two threads and return non-nil if the first thread
594 should be sorted before the other. If you use more than one function,
595 the primary sort function should be the last. You should probably
596 always include `gnus-thread-sort-by-number' in the list of sorting
597 functions -- preferably first.
599 Ready-made functions include `gnus-thread-sort-by-number',
600 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
601 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
602 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
603 :group 'gnus-summary-sort
604 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
605 (function-item gnus-thread-sort-by-author)
606 (function-item gnus-thread-sort-by-subject)
607 (function-item gnus-thread-sort-by-date)
608 (function-item gnus-thread-sort-by-score)
609 (function-item gnus-thread-sort-by-total-score)
610 (function :tag "other"))))
612 (defcustom gnus-thread-score-function '+
613 "*Function used for calculating the total score of a thread.
615 The function is called with the scores of the article and each
616 subthread and should then return the score of the thread.
618 Some functions you can use are `+', `max', or `min'."
619 :group 'gnus-summary-sort
622 (defcustom gnus-summary-expunge-below nil
623 "All articles that have a score less than this variable will be expunged.
624 This variable is local to the summary buffers."
625 :group 'gnus-score-default
626 :type '(choice (const :tag "off" nil)
629 (defcustom gnus-thread-expunge-below nil
630 "All threads that have a total score less than this variable will be expunged.
631 See `gnus-thread-score-function' for en explanation of what a
634 This variable is local to the summary buffers."
635 :group 'gnus-threading
636 :group 'gnus-score-default
637 :type '(choice (const :tag "off" nil)
640 (defcustom gnus-summary-mode-hook nil
641 "*A hook for Gnus summary mode.
642 This hook is run before any variables are set in the summary buffer."
643 :options '(turn-on-gnus-mailing-list-mode)
644 :group 'gnus-summary-various
647 (defcustom gnus-summary-menu-hook nil
648 "*Hook run after the creation of the summary mode menu."
649 :group 'gnus-summary-visual
652 (defcustom gnus-summary-exit-hook nil
653 "*A hook called on exit from the summary buffer.
654 It will be called with point in the group buffer."
655 :group 'gnus-summary-exit
658 (defcustom gnus-summary-prepare-hook nil
659 "*A hook called after the summary buffer has been generated.
660 If you want to modify the summary buffer, you can use this hook."
661 :group 'gnus-summary-various
664 (defcustom gnus-summary-prepared-hook nil
665 "*A hook called as the last thing after the summary buffer has been generated."
666 :group 'gnus-summary-various
669 (defcustom gnus-summary-generate-hook nil
670 "*A hook run just before generating the summary buffer.
671 This hook is commonly used to customize threading variables and the
673 :group 'gnus-summary-various
676 (defcustom gnus-select-group-hook nil
677 "*A hook called when a newsgroup is selected.
679 If you'd like to simplify subjects like the
680 `gnus-summary-next-same-subject' command does, you can use the
683 (setq gnus-select-group-hook
686 (mapcar (lambda (header)
687 (mail-header-set-subject
689 (gnus-simplify-subject
690 (mail-header-subject header) 're-only)))
691 gnus-newsgroup-headers))))"
692 :group 'gnus-group-select
695 (defcustom gnus-select-article-hook nil
696 "*A hook called when an article is selected."
697 :group 'gnus-summary-choose
700 (defcustom gnus-visual-mark-article-hook
701 (list 'gnus-highlight-selected-summary)
702 "*Hook run after selecting an article in the summary buffer.
703 It is meant to be used for highlighting the article in some way. It
704 is not run if `gnus-visual' is nil."
705 :group 'gnus-summary-visual
708 (defcustom gnus-parse-headers-hook nil
709 "*A hook called before parsing the headers."
713 (defcustom gnus-exit-group-hook nil
714 "*A hook called when exiting summary mode.
715 This hook is not called from the non-updating exit commands like `Q'."
719 (defcustom gnus-summary-update-hook
720 (list 'gnus-summary-highlight-line)
721 "*A hook called when a summary line is changed.
722 The hook will not be called if `gnus-visual' is nil.
724 The default function `gnus-summary-highlight-line' will
725 highlight the line according to the `gnus-summary-highlight'
727 :group 'gnus-summary-visual
730 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
731 "*A hook called when an article is selected for the first time.
732 The hook is intended to mark an article as read (or unread)
733 automatically when it is selected."
734 :group 'gnus-summary-choose
737 (defcustom gnus-group-no-more-groups-hook nil
738 "*A hook run when returning to group mode having no more (unread) groups."
739 :group 'gnus-group-select
742 (defcustom gnus-ps-print-hook nil
743 "*A hook run before ps-printing something from Gnus."
747 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
748 "Face used for highlighting the current article in the summary buffer."
749 :group 'gnus-summary-visual
752 (defcustom gnus-summary-highlight
753 '(((= mark gnus-canceled-mark)
754 . gnus-summary-cancelled-face)
755 ((and (> score default)
756 (or (= mark gnus-dormant-mark)
757 (= mark gnus-ticked-mark)))
758 . gnus-summary-high-ticked-face)
759 ((and (< score default)
760 (or (= mark gnus-dormant-mark)
761 (= mark gnus-ticked-mark)))
762 . gnus-summary-low-ticked-face)
763 ((or (= mark gnus-dormant-mark)
764 (= mark gnus-ticked-mark))
765 . gnus-summary-normal-ticked-face)
766 ((and (> score default) (= mark gnus-ancient-mark))
767 . gnus-summary-high-ancient-face)
768 ((and (< score default) (= mark gnus-ancient-mark))
769 . gnus-summary-low-ancient-face)
770 ((= mark gnus-ancient-mark)
771 . gnus-summary-normal-ancient-face)
772 ((and (> score default) (= mark gnus-unread-mark))
773 . gnus-summary-high-unread-face)
774 ((and (< score default) (= mark gnus-unread-mark))
775 . gnus-summary-low-unread-face)
776 ((= mark gnus-unread-mark)
777 . gnus-summary-normal-unread-face)
778 ((and (> score default) (memq mark (list gnus-downloadable-mark
779 gnus-undownloaded-mark)))
780 . gnus-summary-high-unread-face)
781 ((and (< score default) (memq mark (list gnus-downloadable-mark
782 gnus-undownloaded-mark)))
783 . gnus-summary-low-unread-face)
784 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
785 . gnus-summary-normal-unread-face)
787 . gnus-summary-high-read-face)
789 . gnus-summary-low-read-face)
791 . gnus-summary-normal-read-face))
792 "*Controls the highlighting of summary buffer lines.
794 A list of (FORM . FACE) pairs. When deciding how a a particular
795 summary line should be displayed, each form is evaluated. The content
796 of the face field after the first true form is used. You can change
797 how those summary lines are displayed, by editing the face field.
799 You can use the following variables in the FORM field.
801 score: The articles score
802 default: The default article score.
803 below: The score below which articles are automatically marked as read.
804 mark: The articles mark."
805 :group 'gnus-summary-visual
806 :type '(repeat (cons (sexp :tag "Form" nil)
809 (defcustom gnus-alter-header-function nil
810 "Function called to allow alteration of article header structures.
811 The function is called with one parameter, the article header vector,
812 which it may alter in any way.")
814 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
815 "Variable that says which function should be used to decode a string with encoded words.")
817 (defcustom gnus-extra-headers nil
818 "*Extra headers to parse."
821 :type '(repeat symbol))
823 (defcustom gnus-ignored-from-addresses
824 (and user-mail-address (regexp-quote user-mail-address))
825 "*Regexp of From headers that may be suppressed in favor of To headers."
830 (defcustom gnus-group-charset-alist
831 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
832 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
833 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
834 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
835 ("^relcom\\>" koi8-r)
837 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
838 ("^israel\\>" iso-8859-1)
840 ("^alt.chinese.text.big5\\>" chinese-big5)
841 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
842 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
844 "Alist of regexps (to match group names) and default charsets to be used when reading."
845 :type '(repeat (list (regexp :tag "Group")
846 (symbol :tag "Charset")))
847 :group 'gnus-charset)
849 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
850 "List of charsets that should be ignored.
851 When these charsets are used in the \"charset\" parameter, the
852 default charset will be used instead."
854 :type '(repeat symbol)
855 :group 'gnus-charset)
857 (defcustom gnus-group-ignored-charsets-alist
858 '(("alt\\.chinese\\.text" iso-8859-1))
859 "Alist of regexps (to match group names) and charsets that should be ignored.
860 When these charsets are used in the \"charset\" parameter, the
861 default charset will be used instead."
862 :type '(repeat (cons (regexp :tag "Group")
864 :group 'gnus-charset)
866 (defcustom gnus-group-highlight-words-alist nil
867 "Alist of group regexps and highlight regexps.
868 This variable uses the same syntax as `gnus-emphasis-alist'."
870 :type '(repeat (cons (regexp :tag "Group")
871 (repeat (list (regexp :tag "Highlight regexp")
872 (number :tag "Group for entire word" 0)
873 (number :tag "Group for displayed part" 0)
875 gnus-emphasis-highlight-words)))))
876 :group 'gnus-summary-visual)
878 (defcustom gnus-summary-show-article-charset-alist
880 "Alist of number and charset.
881 The article will be shown with the charset corresponding to the
883 For example: ((1 . cn-gb-2312) (2 . big5))."
885 :type '(repeat (cons (number :tag "Argument" 1)
886 (symbol :tag "Charset")))
887 :group 'gnus-charset)
889 (defcustom gnus-preserve-marks t
890 "Whether marks are preserved when moving, copying and respooling messages."
893 :group 'gnus-summary-marks)
895 (defcustom gnus-alter-articles-to-read-function nil
896 "Function to be called to alter the list of articles to be selected."
898 :group 'gnus-summary)
900 (defcustom gnus-orphan-score nil
901 "*All orphans get this score added. Set in the score file."
902 :group 'gnus-score-default
903 :type '(choice (const nil)
906 (defcustom gnus-summary-save-parts-default-mime "image/.*"
907 "*A regexp to match MIME parts when saving multiple parts of a message
908 with gnus-summary-save-parts (X m). This regexp will be used by default
909 when prompting the user for which type of files to save."
914 (defcustom gnus-summary-save-parts-default-mime "image/.*"
915 "*A regexp to match MIME parts when saving multiple parts of a message
916 with gnus-summary-save-parts (X m). This regexp will be used by default
917 when prompting the user for which type of files to save."
922 ;;; Internal variables
924 (defvar gnus-article-mime-handles nil)
925 (defvar gnus-article-decoded-p nil)
926 (defvar gnus-article-charset nil)
927 (defvar gnus-article-ignored-charsets nil)
928 (defvar gnus-scores-exclude-files nil)
929 (defvar gnus-page-broken nil)
930 (defvar gnus-inhibit-mime-unbuttonizing nil)
932 (defvar gnus-original-article nil)
933 (defvar gnus-article-internal-prepare-hook nil)
934 (defvar gnus-newsgroup-process-stack nil)
936 (defvar gnus-thread-indent-array nil)
937 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
938 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
939 "Function called to sort the articles within a thread after it has been gathered together.")
941 (defvar gnus-summary-save-parts-type-history nil)
942 (defvar gnus-summary-save-parts-last-directory nil)
944 (defvar gnus-summary-save-parts-type-history nil)
945 (defvar gnus-summary-save-parts-last-directory nil)
947 ;; Avoid highlighting in kill files.
948 (defvar gnus-summary-inhibit-highlight nil)
949 (defvar gnus-newsgroup-selected-overlay nil)
950 (defvar gnus-inhibit-limiting nil)
951 (defvar gnus-newsgroup-adaptive-score-file nil)
952 (defvar gnus-current-score-file nil)
953 (defvar gnus-current-move-group nil)
954 (defvar gnus-current-copy-group nil)
955 (defvar gnus-current-crosspost-group nil)
957 (defvar gnus-newsgroup-dependencies nil)
958 (defvar gnus-newsgroup-adaptive nil)
959 (defvar gnus-summary-display-article-function nil)
960 (defvar gnus-summary-highlight-line-function nil
961 "Function called after highlighting a summary line.")
963 (defvar gnus-summary-line-format-alist
964 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
965 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
966 (?s gnus-tmp-subject-or-nil ?s)
967 (?n gnus-tmp-name ?s)
968 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
970 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
972 (?F gnus-tmp-from ?s)
973 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
974 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
975 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
976 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
977 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
978 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
979 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
980 (?L gnus-tmp-lines ?d)
981 (?I gnus-tmp-indentation ?s)
982 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
983 (?R gnus-tmp-replied ?c)
984 (?\[ gnus-tmp-opening-bracket ?c)
985 (?\] gnus-tmp-closing-bracket ?c)
986 (?\> (make-string gnus-tmp-level ? ) ?s)
987 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
988 (?i gnus-tmp-score ?d)
989 (?z gnus-tmp-score-char ?c)
990 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
991 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
992 (?U gnus-tmp-unread ?c)
993 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
994 (?t (gnus-summary-number-of-articles-in-thread
995 (and (boundp 'thread) (car thread)) gnus-tmp-level)
997 (?e (gnus-summary-number-of-articles-in-thread
998 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1000 (?u gnus-tmp-user-defined ?s)
1001 (?P (gnus-pick-line-number) ?d))
1002 "An alist of format specifications that can appear in summary lines.
1003 These are paired with what variables they correspond with, along with
1004 the type of the variable (string, integer, character, etc).")
1006 (defvar gnus-summary-dummy-line-format-alist
1007 `((?S gnus-tmp-subject ?s)
1008 (?N gnus-tmp-number ?d)
1009 (?u gnus-tmp-user-defined ?s)))
1011 (defvar gnus-summary-mode-line-format-alist
1012 `((?G gnus-tmp-group-name ?s)
1013 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1014 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1015 (?A gnus-tmp-article-number ?d)
1016 (?Z gnus-tmp-unread-and-unselected ?s)
1017 (?V gnus-version ?s)
1018 (?U gnus-tmp-unread-and-unticked ?d)
1019 (?S gnus-tmp-subject ?s)
1020 (?e gnus-tmp-unselected ?d)
1021 (?u gnus-tmp-user-defined ?s)
1022 (?d (length gnus-newsgroup-dormant) ?d)
1023 (?t (length gnus-newsgroup-marked) ?d)
1024 (?r (length gnus-newsgroup-reads) ?d)
1025 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1026 (?E gnus-newsgroup-expunged-tally ?d)
1027 (?s (gnus-current-score-file-nondirectory) ?s)))
1029 (defvar gnus-last-search-regexp nil
1030 "Default regexp for article search command.")
1032 (defvar gnus-last-shell-command nil
1033 "Default shell command on article.")
1035 (defvar gnus-newsgroup-begin nil)
1036 (defvar gnus-newsgroup-end nil)
1037 (defvar gnus-newsgroup-last-rmail nil)
1038 (defvar gnus-newsgroup-last-mail nil)
1039 (defvar gnus-newsgroup-last-folder nil)
1040 (defvar gnus-newsgroup-last-file nil)
1041 (defvar gnus-newsgroup-auto-expire nil)
1042 (defvar gnus-newsgroup-active nil)
1044 (defvar gnus-newsgroup-data nil)
1045 (defvar gnus-newsgroup-data-reverse nil)
1046 (defvar gnus-newsgroup-limit nil)
1047 (defvar gnus-newsgroup-limits nil)
1049 (defvar gnus-newsgroup-unreads nil
1050 "List of unread articles in the current newsgroup.")
1052 (defvar gnus-newsgroup-unselected nil
1053 "List of unselected unread articles in the current newsgroup.")
1055 (defvar gnus-newsgroup-reads nil
1056 "Alist of read articles and article marks in the current newsgroup.")
1058 (defvar gnus-newsgroup-expunged-tally nil)
1060 (defvar gnus-newsgroup-marked nil
1061 "List of ticked articles in the current newsgroup (a subset of unread art).")
1063 (defvar gnus-newsgroup-killed nil
1064 "List of ranges of articles that have been through the scoring process.")
1066 (defvar gnus-newsgroup-cached nil
1067 "List of articles that come from the article cache.")
1069 (defvar gnus-newsgroup-saved nil
1070 "List of articles that have been saved.")
1072 (defvar gnus-newsgroup-kill-headers nil)
1074 (defvar gnus-newsgroup-replied nil
1075 "List of articles that have been replied to in the current newsgroup.")
1077 (defvar gnus-newsgroup-expirable nil
1078 "List of articles in the current newsgroup that can be expired.")
1080 (defvar gnus-newsgroup-processable nil
1081 "List of articles in the current newsgroup that can be processed.")
1083 (defvar gnus-newsgroup-downloadable nil
1084 "List of articles in the current newsgroup that can be processed.")
1086 (defvar gnus-newsgroup-undownloaded nil
1087 "List of articles in the current newsgroup that haven't been downloaded..")
1089 (defvar gnus-newsgroup-unsendable nil
1090 "List of articles in the current newsgroup that won't be sent.")
1092 (defvar gnus-newsgroup-bookmarks nil
1093 "List of articles in the current newsgroup that have bookmarks.")
1095 (defvar gnus-newsgroup-dormant nil
1096 "List of dormant articles in the current newsgroup.")
1098 (defvar gnus-newsgroup-scored nil
1099 "List of scored articles in the current newsgroup.")
1101 (defvar gnus-newsgroup-headers nil
1102 "List of article headers in the current newsgroup.")
1104 (defvar gnus-newsgroup-threads nil)
1106 (defvar gnus-newsgroup-prepared nil
1107 "Whether the current group has been prepared properly.")
1109 (defvar gnus-newsgroup-ancient nil
1110 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1112 (defvar gnus-newsgroup-sparse nil)
1114 (defvar gnus-current-article nil)
1115 (defvar gnus-article-current nil)
1116 (defvar gnus-current-headers nil)
1117 (defvar gnus-have-all-headers nil)
1118 (defvar gnus-last-article nil)
1119 (defvar gnus-newsgroup-history nil)
1120 (defvar gnus-newsgroup-charset nil)
1121 (defvar gnus-newsgroup-ephemeral-charset nil)
1122 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1124 (defvar gnus-article-before-search nil)
1126 (defconst gnus-summary-local-variables
1127 '(gnus-newsgroup-name
1128 gnus-newsgroup-begin gnus-newsgroup-end
1129 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1130 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1131 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1132 gnus-newsgroup-unselected gnus-newsgroup-marked
1133 gnus-newsgroup-reads gnus-newsgroup-saved
1134 gnus-newsgroup-replied gnus-newsgroup-expirable
1135 gnus-newsgroup-processable gnus-newsgroup-killed
1136 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1137 gnus-newsgroup-unsendable
1138 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1139 gnus-newsgroup-headers gnus-newsgroup-threads
1140 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1141 gnus-current-article gnus-current-headers gnus-have-all-headers
1142 gnus-last-article gnus-article-internal-prepare-hook
1143 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1144 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1145 gnus-thread-expunge-below
1146 gnus-score-alist gnus-current-score-file
1147 (gnus-summary-expunge-below . global)
1148 (gnus-summary-mark-below . global)
1149 (gnus-orphan-score . global)
1150 gnus-newsgroup-active gnus-scores-exclude-files
1151 gnus-newsgroup-history gnus-newsgroup-ancient
1152 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1153 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1154 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1155 (gnus-newsgroup-expunged-tally . 0)
1156 gnus-cache-removable-articles gnus-newsgroup-cached
1157 gnus-newsgroup-data gnus-newsgroup-data-reverse
1158 gnus-newsgroup-limit gnus-newsgroup-limits
1159 gnus-newsgroup-charset)
1160 "Variables that are buffer-local to the summary buffers.")
1162 (defvar gnus-newsgroup-variables nil
1163 "Variables that have separate values in the newsgroups.")
1165 ;; Byte-compiler warning.
1166 (eval-when-compile (defvar gnus-article-mode-map))
1170 (defvar gnus-decode-encoded-word-methods
1171 '(mail-decode-encoded-word-string)
1172 "List of methods used to decode encoded words.
1174 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1175 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1176 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1177 whose names match REGEXP.
1180 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1181 mail-decode-encoded-word-string
1182 (\"chinese\" . rfc1843-decode-string))")
1184 (defvar gnus-decode-encoded-word-methods-cache nil)
1186 (defun gnus-multi-decode-encoded-word-string (string)
1187 "Apply the functions from `gnus-encoded-word-methods' that match."
1188 (unless (and gnus-decode-encoded-word-methods-cache
1189 (eq gnus-newsgroup-name
1190 (car gnus-decode-encoded-word-methods-cache)))
1191 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1194 (nconc gnus-decode-encoded-word-methods-cache (list x))
1195 (if (and gnus-newsgroup-name
1196 (string-match (car x) gnus-newsgroup-name))
1197 (nconc gnus-decode-encoded-word-methods-cache
1199 gnus-decode-encoded-word-methods))
1200 (let ((xlist gnus-decode-encoded-word-methods-cache))
1203 (setq string (funcall (pop xlist) string))))
1206 ;; Subject simplification.
1208 (defun gnus-simplify-whitespace (str)
1209 "Remove excessive whitespace from STR."
1212 (while (string-match "[ \t][ \t]+" mystr)
1213 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1215 (substring mystr (match-end 0)))))
1217 (when (string-match "^[ \t]+" mystr)
1218 (setq mystr (substring mystr (match-end 0))))
1220 (when (string-match "[ \t]+$" mystr)
1221 (setq mystr (substring mystr 0 (match-beginning 0))))
1224 (defsubst gnus-simplify-subject-re (subject)
1225 "Remove \"Re:\" from subject lines."
1226 (if (string-match "^[Rr][Ee]: *" subject)
1227 (substring subject (match-end 0))
1230 (defun gnus-simplify-subject (subject &optional re-only)
1231 "Remove `Re:' and words in parentheses.
1232 If RE-ONLY is non-nil, strip leading `Re:'s only."
1233 (let ((case-fold-search t)) ;Ignore case.
1234 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1235 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1236 (setq subject (substring subject (match-end 0))))
1237 ;; Remove uninteresting prefixes.
1238 (when (and (not re-only)
1239 gnus-simplify-ignored-prefixes
1240 (string-match gnus-simplify-ignored-prefixes subject))
1241 (setq subject (substring subject (match-end 0))))
1242 ;; Remove words in parentheses from end.
1244 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1245 (setq subject (substring subject 0 (match-beginning 0)))))
1246 ;; Return subject string.
1249 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1251 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1252 (goto-char (point-min))
1253 (while (re-search-forward regexp nil t)
1254 (replace-match (or newtext ""))))
1256 (defun gnus-simplify-buffer-fuzzy ()
1257 "Simplify string in the buffer fuzzily.
1258 The string in the accessible portion of the current buffer is simplified.
1259 It is assumed to be a single-line subject.
1260 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1261 matter is removed. Additional things can be deleted by setting
1262 `gnus-simplify-subject-fuzzy-regexp'."
1263 (let ((case-fold-search t)
1265 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1267 (while (not (eq modified-tick (buffer-modified-tick)))
1268 (setq modified-tick (buffer-modified-tick))
1270 ((listp gnus-simplify-subject-fuzzy-regexp)
1271 (mapcar 'gnus-simplify-buffer-fuzzy-step
1272 gnus-simplify-subject-fuzzy-regexp))
1273 (gnus-simplify-subject-fuzzy-regexp
1274 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1275 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1276 (gnus-simplify-buffer-fuzzy-step
1277 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1278 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1280 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1281 (gnus-simplify-buffer-fuzzy-step " +" " ")
1282 (gnus-simplify-buffer-fuzzy-step " $")
1283 (gnus-simplify-buffer-fuzzy-step "^ +")))
1285 (defun gnus-simplify-subject-fuzzy (subject)
1286 "Simplify a subject string fuzzily.
1287 See `gnus-simplify-buffer-fuzzy' for details."
1289 (gnus-set-work-buffer)
1290 (let ((case-fold-search t))
1291 ;; Remove uninteresting prefixes.
1292 (when (and gnus-simplify-ignored-prefixes
1293 (string-match gnus-simplify-ignored-prefixes subject))
1294 (setq subject (substring subject (match-end 0))))
1296 (inline (gnus-simplify-buffer-fuzzy))
1299 (defsubst gnus-simplify-subject-fully (subject)
1300 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1302 (gnus-simplify-subject-functions
1303 (gnus-map-function gnus-simplify-subject-functions subject))
1304 ((null gnus-summary-gather-subject-limit)
1305 (gnus-simplify-subject-re subject))
1306 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1307 (gnus-simplify-subject-fuzzy subject))
1308 ((numberp gnus-summary-gather-subject-limit)
1309 (gnus-limit-string (gnus-simplify-subject-re subject)
1310 gnus-summary-gather-subject-limit))
1314 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1315 "Check whether two subjects are equal.
1316 If optional argument simple-first is t, first argument is already
1319 ((null simple-first)
1320 (equal (gnus-simplify-subject-fully s1)
1321 (gnus-simplify-subject-fully s2)))
1324 (gnus-simplify-subject-fully s2)))))
1326 (defun gnus-summary-bubble-group ()
1327 "Increase the score of the current group.
1328 This is a handy function to add to `gnus-summary-exit-hook' to
1329 increase the score of each group you read."
1330 (gnus-group-add-score gnus-newsgroup-name))
1334 ;;; Gnus summary mode
1337 (put 'gnus-summary-mode 'mode-class 'special)
1340 ;; Non-orthogonal keys
1342 (gnus-define-keys gnus-summary-mode-map
1343 " " gnus-summary-next-page
1344 "\177" gnus-summary-prev-page
1345 [delete] gnus-summary-prev-page
1346 [backspace] gnus-summary-prev-page
1347 "\r" gnus-summary-scroll-up
1348 "\M-\r" gnus-summary-scroll-down
1349 "n" gnus-summary-next-unread-article
1350 "p" gnus-summary-prev-unread-article
1351 "N" gnus-summary-next-article
1352 "P" gnus-summary-prev-article
1353 "\M-\C-n" gnus-summary-next-same-subject
1354 "\M-\C-p" gnus-summary-prev-same-subject
1355 "\M-n" gnus-summary-next-unread-subject
1356 "\M-p" gnus-summary-prev-unread-subject
1357 "." gnus-summary-first-unread-article
1358 "," gnus-summary-best-unread-article
1359 "\M-s" gnus-summary-search-article-forward
1360 "\M-r" gnus-summary-search-article-backward
1361 "<" gnus-summary-beginning-of-article
1362 ">" gnus-summary-end-of-article
1363 "j" gnus-summary-goto-article
1364 "^" gnus-summary-refer-parent-article
1365 "\M-^" gnus-summary-refer-article
1366 "u" gnus-summary-tick-article-forward
1367 "!" gnus-summary-tick-article-forward
1368 "U" gnus-summary-tick-article-backward
1369 "d" gnus-summary-mark-as-read-forward
1370 "D" gnus-summary-mark-as-read-backward
1371 "E" gnus-summary-mark-as-expirable
1372 "\M-u" gnus-summary-clear-mark-forward
1373 "\M-U" gnus-summary-clear-mark-backward
1374 "k" gnus-summary-kill-same-subject-and-select
1375 "\C-k" gnus-summary-kill-same-subject
1376 "\M-\C-k" gnus-summary-kill-thread
1377 "\M-\C-l" gnus-summary-lower-thread
1378 "e" gnus-summary-edit-article
1379 "#" gnus-summary-mark-as-processable
1380 "\M-#" gnus-summary-unmark-as-processable
1381 "\M-\C-t" gnus-summary-toggle-threads
1382 "\M-\C-s" gnus-summary-show-thread
1383 "\M-\C-h" gnus-summary-hide-thread
1384 "\M-\C-f" gnus-summary-next-thread
1385 "\M-\C-b" gnus-summary-prev-thread
1386 [(meta down)] gnus-summary-next-thread
1387 [(meta up)] gnus-summary-prev-thread
1388 "\M-\C-u" gnus-summary-up-thread
1389 "\M-\C-d" gnus-summary-down-thread
1390 "&" gnus-summary-execute-command
1391 "c" gnus-summary-catchup-and-exit
1392 "\C-w" gnus-summary-mark-region-as-read
1393 "\C-t" gnus-summary-toggle-truncation
1394 "?" gnus-summary-mark-as-dormant
1395 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1396 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1397 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1398 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1399 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1400 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1401 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1402 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1403 "=" gnus-summary-expand-window
1404 "\C-x\C-s" gnus-summary-reselect-current-group
1405 "\M-g" gnus-summary-rescan-group
1406 "w" gnus-summary-stop-page-breaking
1407 "\C-c\C-r" gnus-summary-caesar-message
1408 "f" gnus-summary-followup
1409 "F" gnus-summary-followup-with-original
1410 "C" gnus-summary-cancel-article
1411 "r" gnus-summary-reply
1412 "R" gnus-summary-reply-with-original
1413 "\C-c\C-f" gnus-summary-mail-forward
1414 "o" gnus-summary-save-article
1415 "\C-o" gnus-summary-save-article-mail
1416 "|" gnus-summary-pipe-output
1417 "\M-k" gnus-summary-edit-local-kill
1418 "\M-K" gnus-summary-edit-global-kill
1420 "\C-c\C-d" gnus-summary-describe-group
1421 "q" gnus-summary-exit
1422 "Q" gnus-summary-exit-no-update
1423 "\C-c\C-i" gnus-info-find-node
1424 gnus-mouse-2 gnus-mouse-pick-article
1425 "m" gnus-summary-mail-other-window
1426 "a" gnus-summary-post-news
1427 "x" gnus-summary-limit-to-unread
1428 "s" gnus-summary-isearch-article
1429 "t" gnus-summary-toggle-header
1430 "g" gnus-summary-show-article
1431 "l" gnus-summary-goto-last-article
1432 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1433 "\C-d" gnus-summary-enter-digest-group
1434 "\M-\C-d" gnus-summary-read-document
1435 "\M-\C-e" gnus-summary-edit-parameters
1436 "\M-\C-a" gnus-summary-customize-parameters
1438 "*" gnus-cache-enter-article
1439 "\M-*" gnus-cache-remove-article
1440 "\M-&" gnus-summary-universal-argument
1441 "\C-l" gnus-recenter
1442 "I" gnus-summary-increase-score
1443 "L" gnus-summary-lower-score
1444 "\M-i" gnus-symbolic-argument
1445 "h" gnus-summary-select-article-buffer
1447 "b" gnus-article-view-part
1448 "\M-t" gnus-summary-toggle-display-buttonized
1450 "V" gnus-summary-score-map
1451 "X" gnus-uu-extract-map
1452 "S" gnus-summary-send-map)
1454 ;; Sort of orthogonal keymap
1455 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1456 "t" gnus-summary-tick-article-forward
1457 "!" gnus-summary-tick-article-forward
1458 "d" gnus-summary-mark-as-read-forward
1459 "r" gnus-summary-mark-as-read-forward
1460 "c" gnus-summary-clear-mark-forward
1461 " " gnus-summary-clear-mark-forward
1462 "e" gnus-summary-mark-as-expirable
1463 "x" gnus-summary-mark-as-expirable
1464 "?" gnus-summary-mark-as-dormant
1465 "b" gnus-summary-set-bookmark
1466 "B" gnus-summary-remove-bookmark
1467 "#" gnus-summary-mark-as-processable
1468 "\M-#" gnus-summary-unmark-as-processable
1469 "S" gnus-summary-limit-include-expunged
1470 "C" gnus-summary-catchup
1471 "H" gnus-summary-catchup-to-here
1472 "\C-c" gnus-summary-catchup-all
1473 "k" gnus-summary-kill-same-subject-and-select
1474 "K" gnus-summary-kill-same-subject
1475 "P" gnus-uu-mark-map)
1477 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1478 "c" gnus-summary-clear-above
1479 "u" gnus-summary-tick-above
1480 "m" gnus-summary-mark-above
1481 "k" gnus-summary-kill-below)
1483 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1484 "/" gnus-summary-limit-to-subject
1485 "n" gnus-summary-limit-to-articles
1486 "w" gnus-summary-pop-limit
1487 "s" gnus-summary-limit-to-subject
1488 "a" gnus-summary-limit-to-author
1489 "u" gnus-summary-limit-to-unread
1490 "m" gnus-summary-limit-to-marks
1491 "M" gnus-summary-limit-exclude-marks
1492 "v" gnus-summary-limit-to-score
1493 "*" gnus-summary-limit-include-cached
1494 "D" gnus-summary-limit-include-dormant
1495 "T" gnus-summary-limit-include-thread
1496 "d" gnus-summary-limit-exclude-dormant
1497 "t" gnus-summary-limit-to-age
1498 "x" gnus-summary-limit-to-extra
1499 "E" gnus-summary-limit-include-expunged
1500 "c" gnus-summary-limit-exclude-childless-dormant
1501 "C" gnus-summary-limit-mark-excluded-as-read)
1503 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1504 "n" gnus-summary-next-unread-article
1505 "p" gnus-summary-prev-unread-article
1506 "N" gnus-summary-next-article
1507 "P" gnus-summary-prev-article
1508 "\C-n" gnus-summary-next-same-subject
1509 "\C-p" gnus-summary-prev-same-subject
1510 "\M-n" gnus-summary-next-unread-subject
1511 "\M-p" gnus-summary-prev-unread-subject
1512 "f" gnus-summary-first-unread-article
1513 "b" gnus-summary-best-unread-article
1514 "j" gnus-summary-goto-article
1515 "g" gnus-summary-goto-subject
1516 "l" gnus-summary-goto-last-article
1517 "o" gnus-summary-pop-article)
1519 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1520 "k" gnus-summary-kill-thread
1521 "l" gnus-summary-lower-thread
1522 "i" gnus-summary-raise-thread
1523 "T" gnus-summary-toggle-threads
1524 "t" gnus-summary-rethread-current
1525 "^" gnus-summary-reparent-thread
1526 "s" gnus-summary-show-thread
1527 "S" gnus-summary-show-all-threads
1528 "h" gnus-summary-hide-thread
1529 "H" gnus-summary-hide-all-threads
1530 "n" gnus-summary-next-thread
1531 "p" gnus-summary-prev-thread
1532 "u" gnus-summary-up-thread
1533 "o" gnus-summary-top-thread
1534 "d" gnus-summary-down-thread
1535 "#" gnus-uu-mark-thread
1536 "\M-#" gnus-uu-unmark-thread)
1538 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1539 "g" gnus-summary-prepare
1540 "c" gnus-summary-insert-cached-articles)
1542 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1543 "c" gnus-summary-catchup-and-exit
1544 "C" gnus-summary-catchup-all-and-exit
1545 "E" gnus-summary-exit-no-update
1546 "Q" gnus-summary-exit
1547 "Z" gnus-summary-exit
1548 "n" gnus-summary-catchup-and-goto-next-group
1549 "R" gnus-summary-reselect-current-group
1550 "G" gnus-summary-rescan-group
1551 "N" gnus-summary-next-group
1552 "s" gnus-summary-save-newsrc
1553 "P" gnus-summary-prev-group)
1555 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1556 " " gnus-summary-next-page
1557 "n" gnus-summary-next-page
1558 "\177" gnus-summary-prev-page
1559 [delete] gnus-summary-prev-page
1560 "p" gnus-summary-prev-page
1561 "\r" gnus-summary-scroll-up
1562 "\M-\r" gnus-summary-scroll-down
1563 "<" gnus-summary-beginning-of-article
1564 ">" gnus-summary-end-of-article
1565 "b" gnus-summary-beginning-of-article
1566 "e" gnus-summary-end-of-article
1567 "^" gnus-summary-refer-parent-article
1568 "r" gnus-summary-refer-parent-article
1569 "D" gnus-summary-enter-digest-group
1570 "R" gnus-summary-refer-references
1571 "T" gnus-summary-refer-thread
1572 "g" gnus-summary-show-article
1573 "s" gnus-summary-isearch-article
1574 "P" gnus-summary-print-article
1575 "M" gnus-mailing-list-insinuate
1576 "t" gnus-article-babel)
1578 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1579 "b" gnus-article-add-buttons
1580 "B" gnus-article-add-buttons-to-head
1581 "o" gnus-article-treat-overstrike
1582 "e" gnus-article-emphasize
1583 "w" gnus-article-fill-cited-article
1584 "Q" gnus-article-fill-long-lines
1585 "C" gnus-article-capitalize-sentences
1586 "c" gnus-article-remove-cr
1587 "q" gnus-article-de-quoted-unreadable
1588 "6" gnus-article-de-base64-unreadable
1589 "Z" gnus-article-decode-HZ
1590 "h" gnus-article-wash-html
1591 "s" gnus-summary-force-verify-and-decrypt
1592 "f" gnus-article-display-x-face
1593 "l" gnus-summary-stop-page-breaking
1594 "r" gnus-summary-caesar-message
1595 "t" gnus-summary-toggle-header
1596 "v" gnus-summary-verbose-headers
1597 "H" gnus-article-strip-headers-in-body
1598 "p" gnus-article-verify-x-pgp-sig
1599 "d" gnus-article-treat-dumbquotes)
1601 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1602 "a" gnus-article-hide
1603 "h" gnus-article-hide-headers
1604 "b" gnus-article-hide-boring-headers
1605 "s" gnus-article-hide-signature
1606 "c" gnus-article-hide-citation
1607 "C" gnus-article-hide-citation-in-followups
1608 "l" gnus-article-hide-list-identifiers
1609 "p" gnus-article-hide-pgp
1610 "B" gnus-article-strip-banner
1611 "P" gnus-article-hide-pem
1612 "\C-c" gnus-article-hide-citation-maybe)
1614 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1615 "a" gnus-article-highlight
1616 "h" gnus-article-highlight-headers
1617 "c" gnus-article-highlight-citation
1618 "s" gnus-article-highlight-signature)
1620 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1621 "w" gnus-article-decode-mime-words
1622 "c" gnus-article-decode-charset
1623 "v" gnus-mime-view-all-parts
1624 "b" gnus-article-view-part)
1626 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1627 "z" gnus-article-date-ut
1628 "u" gnus-article-date-ut
1629 "l" gnus-article-date-local
1630 "e" gnus-article-date-lapsed
1631 "o" gnus-article-date-original
1632 "i" gnus-article-date-iso8601
1633 "s" gnus-article-date-user)
1635 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1636 "t" gnus-article-remove-trailing-blank-lines
1637 "l" gnus-article-strip-leading-blank-lines
1638 "m" gnus-article-strip-multiple-blank-lines
1639 "a" gnus-article-strip-blank-lines
1640 "A" gnus-article-strip-all-blank-lines
1641 "s" gnus-article-strip-leading-space
1642 "e" gnus-article-strip-trailing-space)
1644 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1646 "f" gnus-summary-fetch-faq
1647 "d" gnus-summary-describe-group
1648 "h" gnus-summary-describe-briefly
1649 "i" gnus-info-find-node)
1651 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1652 "e" gnus-summary-expire-articles
1653 "\M-\C-e" gnus-summary-expire-articles-now
1654 "\177" gnus-summary-delete-article
1655 [delete] gnus-summary-delete-article
1656 [backspace] gnus-summary-delete-article
1657 "m" gnus-summary-move-article
1658 "r" gnus-summary-respool-article
1659 "w" gnus-summary-edit-article
1660 "c" gnus-summary-copy-article
1661 "B" gnus-summary-crosspost-article
1662 "q" gnus-summary-respool-query
1663 "t" gnus-summary-respool-trace
1664 "i" gnus-summary-import-article
1665 "p" gnus-summary-article-posted-p)
1667 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1668 "o" gnus-summary-save-article
1669 "m" gnus-summary-save-article-mail
1670 "F" gnus-summary-write-article-file
1671 "r" gnus-summary-save-article-rmail
1672 "f" gnus-summary-save-article-file
1673 "b" gnus-summary-save-article-body-file
1674 "h" gnus-summary-save-article-folder
1675 "v" gnus-summary-save-article-vm
1676 "p" gnus-summary-pipe-output
1677 "s" gnus-soup-add-article)
1679 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1680 "b" gnus-summary-display-buttonized
1681 "m" gnus-summary-repair-multipart
1682 "v" gnus-article-view-part
1683 "o" gnus-article-save-part
1684 "c" gnus-article-copy-part
1685 "C" gnus-article-view-part-as-charset
1686 "e" gnus-article-externalize-part
1687 "E" gnus-article-encrypt-body
1688 "i" gnus-article-inline-part
1689 "|" gnus-article-pipe-part))
1691 (defun gnus-summary-make-menu-bar ()
1692 (gnus-turn-off-edit-menu 'summary)
1694 (unless (boundp 'gnus-summary-misc-menu)
1697 gnus-summary-kill-menu gnus-summary-mode-map ""
1702 ["Enter score..." gnus-summary-score-entry t]
1703 ["Customize" gnus-score-customize t])
1704 (gnus-make-score-map 'increase)
1705 (gnus-make-score-map 'lower)
1707 ["Kill below" gnus-summary-kill-below t]
1708 ["Mark above" gnus-summary-mark-above t]
1709 ["Tick above" gnus-summary-tick-above t]
1710 ["Clear above" gnus-summary-clear-above t])
1711 ["Current score" gnus-summary-current-score t]
1712 ["Set score" gnus-summary-set-score t]
1713 ["Switch current score file..." gnus-score-change-score-file t]
1714 ["Set mark below..." gnus-score-set-mark-below t]
1715 ["Set expunge below..." gnus-score-set-expunge-below t]
1716 ["Edit current score file" gnus-score-edit-current-scores t]
1717 ["Edit score file" gnus-score-edit-file t]
1718 ["Trace score" gnus-score-find-trace t]
1719 ["Find words" gnus-score-find-favourite-words t]
1720 ["Rescore buffer" gnus-summary-rescore t]
1721 ["Increase score..." gnus-summary-increase-score t]
1722 ["Lower score..." gnus-summary-lower-score t]))))
1724 ;; Define both the Article menu in the summary buffer and the equivalent
1725 ;; Commands menu in the article buffer here for consistency.
1728 ["All" gnus-article-hide t]
1729 ["Headers" gnus-article-hide-headers t]
1730 ["Signature" gnus-article-hide-signature t]
1731 ["Citation" gnus-article-hide-citation t]
1732 ["List identifiers" gnus-article-hide-list-identifiers t]
1733 ["PGP" gnus-article-hide-pgp t]
1734 ["Banner" gnus-article-strip-banner t]
1735 ["Boring headers" gnus-article-hide-boring-headers t])
1737 ["All" gnus-article-highlight t]
1738 ["Headers" gnus-article-highlight-headers t]
1739 ["Signature" gnus-article-highlight-signature t]
1740 ["Citation" gnus-article-highlight-citation t])
1742 ["Words" gnus-article-decode-mime-words t]
1743 ["Charset" gnus-article-decode-charset t]
1744 ["QP" gnus-article-de-quoted-unreadable t]
1745 ["Base64" gnus-article-de-base64-unreadable t]
1746 ["View all" gnus-mime-view-all-parts t]
1747 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
1748 ["Encrypt body" gnus-article-encrypt-body t])
1750 ["Local" gnus-article-date-local t]
1751 ["ISO8601" gnus-article-date-iso8601 t]
1752 ["UT" gnus-article-date-ut t]
1753 ["Original" gnus-article-date-original t]
1754 ["Lapsed" gnus-article-date-lapsed t]
1755 ["User-defined" gnus-article-date-user t])
1758 ["Leading" gnus-article-strip-leading-blank-lines t]
1759 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1760 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1761 ["All of the above" gnus-article-strip-blank-lines t]
1762 ["All" gnus-article-strip-all-blank-lines t]
1763 ["Leading space" gnus-article-strip-leading-space t]
1764 ["Trailing space" gnus-article-strip-trailing-space t])
1765 ["Overstrike" gnus-article-treat-overstrike t]
1766 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1767 ["Emphasis" gnus-article-emphasize t]
1768 ["Word wrap" gnus-article-fill-cited-article t]
1769 ["Fill long lines" gnus-article-fill-long-lines t]
1770 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1771 ["CR" gnus-article-remove-cr t]
1772 ["Show X-Face" gnus-article-display-x-face t]
1773 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1774 ["Base64" gnus-article-de-base64-unreadable t]
1775 ["Rot 13" gnus-summary-caesar-message
1776 :help "\"Caesar rotate\" article by 13"]
1777 ["Unix pipe" gnus-summary-pipe-message t]
1778 ["Add buttons" gnus-article-add-buttons t]
1779 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1780 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1781 ["Verbose header" gnus-summary-verbose-headers t]
1782 ["Toggle header" gnus-summary-toggle-header t]
1783 ["Html" gnus-article-wash-html t]
1784 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
1785 ["HZ" gnus-article-decode-HZ t])
1787 ["Save in default format" gnus-summary-save-article
1788 :help "Save article using default method"]
1789 ["Save in file" gnus-summary-save-article-file
1790 :help "Save article in file"]
1791 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1792 ["Save in MH folder" gnus-summary-save-article-folder t]
1793 ["Save in VM folder" gnus-summary-save-article-vm t]
1794 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1795 ["Save body in file" gnus-summary-save-article-body-file t]
1796 ["Pipe through a filter" gnus-summary-pipe-output t]
1797 ["Add to SOUP packet" gnus-soup-add-article t]
1798 ["Print" gnus-summary-print-article t])
1800 ["Respool article..." gnus-summary-respool-article t]
1801 ["Move article..." gnus-summary-move-article
1802 (gnus-check-backend-function
1803 'request-move-article gnus-newsgroup-name)]
1804 ["Copy article..." gnus-summary-copy-article t]
1805 ["Crosspost article..." gnus-summary-crosspost-article
1806 (gnus-check-backend-function
1807 'request-replace-article gnus-newsgroup-name)]
1808 ["Import file..." gnus-summary-import-article t]
1809 ["Check if posted" gnus-summary-article-posted-p t]
1810 ["Edit article" gnus-summary-edit-article
1811 (not (gnus-group-read-only-p))]
1812 ["Delete article" gnus-summary-delete-article
1813 (gnus-check-backend-function
1814 'request-expire-articles gnus-newsgroup-name)]
1815 ["Query respool" gnus-summary-respool-query t]
1816 ["Trace respool" gnus-summary-respool-trace t]
1817 ["Delete expirable articles" gnus-summary-expire-articles-now
1818 (gnus-check-backend-function
1819 'request-expire-articles gnus-newsgroup-name)])
1821 ["Uudecode" gnus-uu-decode-uu
1822 :help "Decode uuencoded article(s)"]
1823 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1824 ["Unshar" gnus-uu-decode-unshar t]
1825 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1826 ["Save" gnus-uu-decode-save t]
1827 ["Binhex" gnus-uu-decode-binhex t]
1828 ["Postscript" gnus-uu-decode-postscript t])
1830 ["Enter article" gnus-cache-enter-article t]
1831 ["Remove article" gnus-cache-remove-article t])
1832 ["Translate" gnus-article-babel t]
1833 ["Select article buffer" gnus-summary-select-article-buffer t]
1834 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1835 ["Isearch article..." gnus-summary-isearch-article t]
1836 ["Beginning of the article" gnus-summary-beginning-of-article t]
1837 ["End of the article" gnus-summary-end-of-article t]
1838 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1839 ["Fetch referenced articles" gnus-summary-refer-references t]
1840 ["Fetch current thread" gnus-summary-refer-thread t]
1841 ["Fetch article with id..." gnus-summary-refer-article t]
1842 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
1843 ["Redisplay" gnus-summary-show-article t])))
1845 gnus-summary-article-menu gnus-summary-mode-map ""
1846 (cons "Article" innards))
1849 gnus-article-commands-menu gnus-article-mode-map ""
1850 (cons "Commands" innards)))
1853 gnus-summary-thread-menu gnus-summary-mode-map ""
1855 ["Toggle threading" gnus-summary-toggle-threads t]
1856 ["Hide threads" gnus-summary-hide-all-threads t]
1857 ["Show threads" gnus-summary-show-all-threads t]
1858 ["Hide thread" gnus-summary-hide-thread t]
1859 ["Show thread" gnus-summary-show-thread t]
1860 ["Go to next thread" gnus-summary-next-thread t]
1861 ["Go to previous thread" gnus-summary-prev-thread t]
1862 ["Go down thread" gnus-summary-down-thread t]
1863 ["Go up thread" gnus-summary-up-thread t]
1864 ["Top of thread" gnus-summary-top-thread t]
1865 ["Mark thread as read" gnus-summary-kill-thread t]
1866 ["Lower thread score" gnus-summary-lower-thread t]
1867 ["Raise thread score" gnus-summary-raise-thread t]
1868 ["Rethread current" gnus-summary-rethread-current t]))
1871 gnus-summary-post-menu gnus-summary-mode-map ""
1873 ["Post an article" gnus-summary-post-news
1874 :help "Post an article"]
1875 ["Followup" gnus-summary-followup
1876 :help "Post followup to this article"]
1877 ["Followup and yank" gnus-summary-followup-with-original
1878 :help "Post followup to this article, quoting its contents"]
1879 ["Supersede article" gnus-summary-supersede-article t]
1880 ["Cancel article" gnus-summary-cancel-article
1881 :help "Cancel an article you posted"]
1882 ["Reply" gnus-summary-reply t]
1883 ["Reply and yank" gnus-summary-reply-with-original t]
1884 ["Wide reply" gnus-summary-wide-reply t]
1885 ["Wide reply and yank" gnus-summary-wide-reply-with-original
1886 :help "Mail a reply, quoting this article"]
1887 ["Mail forward" gnus-summary-mail-forward t]
1888 ["Post forward" gnus-summary-post-forward t]
1889 ["Digest and mail" gnus-uu-digest-mail-forward t]
1890 ["Digest and post" gnus-uu-digest-post-forward t]
1891 ["Resend message" gnus-summary-resend-message t]
1892 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1893 ["Send a mail" gnus-summary-mail-other-window t]
1894 ["Uuencode and post" gnus-uu-post-news
1895 :help "Post a uuencoded article"]
1896 ["Followup via news" gnus-summary-followup-to-mail t]
1897 ["Followup via news and yank"
1898 gnus-summary-followup-to-mail-with-original t]
1900 ;;["Send" gnus-summary-send-draft t]
1901 ;;["Send bounced" gnus-resend-bounced-mail t])
1905 gnus-summary-misc-menu gnus-summary-mode-map ""
1908 ["Mark as read" gnus-summary-mark-as-read-forward t]
1909 ["Mark same subject and select"
1910 gnus-summary-kill-same-subject-and-select t]
1911 ["Mark same subject" gnus-summary-kill-same-subject t]
1912 ["Catchup" gnus-summary-catchup
1913 :help "Mark unread articles in this group as read"]
1914 ["Catchup all" gnus-summary-catchup-all t]
1915 ["Catchup to here" gnus-summary-catchup-to-here t]
1916 ["Catchup region" gnus-summary-mark-region-as-read t]
1917 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1919 ["Tick" gnus-summary-tick-article-forward t]
1920 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1921 ["Remove marks" gnus-summary-clear-mark-forward t]
1922 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1923 ["Set bookmark" gnus-summary-set-bookmark t]
1924 ["Remove bookmark" gnus-summary-remove-bookmark t])
1926 ["Marks..." gnus-summary-limit-to-marks t]
1927 ["Subject..." gnus-summary-limit-to-subject t]
1928 ["Author..." gnus-summary-limit-to-author t]
1929 ["Age..." gnus-summary-limit-to-age t]
1930 ["Extra..." gnus-summary-limit-to-extra t]
1931 ["Score" gnus-summary-limit-to-score t]
1932 ["Unread" gnus-summary-limit-to-unread t]
1933 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1934 ["Articles" gnus-summary-limit-to-articles t]
1935 ["Pop limit" gnus-summary-pop-limit t]
1936 ["Show dormant" gnus-summary-limit-include-dormant t]
1937 ["Hide childless dormant"
1938 gnus-summary-limit-exclude-childless-dormant t]
1939 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1940 ["Hide marked" gnus-summary-limit-exclude-marks t]
1941 ["Show expunged" gnus-summary-show-all-expunged t])
1943 ["Set mark" gnus-summary-mark-as-processable t]
1944 ["Remove mark" gnus-summary-unmark-as-processable t]
1945 ["Remove all marks" gnus-summary-unmark-all-processable t]
1946 ["Mark above" gnus-uu-mark-over t]
1947 ["Mark series" gnus-uu-mark-series t]
1948 ["Mark region" gnus-uu-mark-region t]
1949 ["Unmark region" gnus-uu-unmark-region t]
1950 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1951 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1952 ["Mark all" gnus-uu-mark-all t]
1953 ["Mark buffer" gnus-uu-mark-buffer t]
1954 ["Mark sparse" gnus-uu-mark-sparse t]
1955 ["Mark thread" gnus-uu-mark-thread t]
1956 ["Unmark thread" gnus-uu-unmark-thread t]
1957 ("Process Mark Sets"
1958 ["Kill" gnus-summary-kill-process-mark t]
1959 ["Yank" gnus-summary-yank-process-mark
1960 gnus-newsgroup-process-stack]
1961 ["Save" gnus-summary-save-process-mark t]))
1963 ["Page forward" gnus-summary-next-page
1964 :help "Show next page of article"]
1965 ["Page backward" gnus-summary-prev-page
1966 :help "Show previous page of article"]
1967 ["Line forward" gnus-summary-scroll-up t])
1969 ["Next unread article" gnus-summary-next-unread-article t]
1970 ["Previous unread article" gnus-summary-prev-unread-article t]
1971 ["Next article" gnus-summary-next-article t]
1972 ["Previous article" gnus-summary-prev-article t]
1973 ["Next unread subject" gnus-summary-next-unread-subject t]
1974 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1975 ["Next article same subject" gnus-summary-next-same-subject t]
1976 ["Previous article same subject" gnus-summary-prev-same-subject t]
1977 ["First unread article" gnus-summary-first-unread-article t]
1978 ["Best unread article" gnus-summary-best-unread-article t]
1979 ["Go to subject number..." gnus-summary-goto-subject t]
1980 ["Go to article number..." gnus-summary-goto-article t]
1981 ["Go to the last article" gnus-summary-goto-last-article t]
1982 ["Pop article off history" gnus-summary-pop-article t])
1984 ["Sort by number" gnus-summary-sort-by-number t]
1985 ["Sort by author" gnus-summary-sort-by-author t]
1986 ["Sort by subject" gnus-summary-sort-by-subject t]
1987 ["Sort by date" gnus-summary-sort-by-date t]
1988 ["Sort by score" gnus-summary-sort-by-score t]
1989 ["Sort by lines" gnus-summary-sort-by-lines t]
1990 ["Sort by characters" gnus-summary-sort-by-chars t])
1992 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1993 ["Describe group" gnus-summary-describe-group t]
1994 ["Read manual" gnus-info-find-node t])
1996 ["Pick and read" gnus-pick-mode t]
1997 ["Binary" gnus-binary-mode t])
1999 ["Regenerate" gnus-summary-prepare t]
2000 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2001 ["Toggle threading" gnus-summary-toggle-threads t])
2002 ["Filter articles..." gnus-summary-execute-command t]
2003 ["Run command on subjects..." gnus-summary-universal-argument t]
2004 ["Search articles forward..." gnus-summary-search-article-forward t]
2005 ["Search articles backward..." gnus-summary-search-article-backward t]
2006 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2007 ["Expand window" gnus-summary-expand-window t]
2008 ["Expire expirable articles" gnus-summary-expire-articles
2009 (gnus-check-backend-function
2010 'request-expire-articles gnus-newsgroup-name)]
2011 ["Edit local kill file" gnus-summary-edit-local-kill t]
2012 ["Edit main kill file" gnus-summary-edit-global-kill t]
2013 ["Edit group parameters" gnus-summary-edit-parameters t]
2014 ["Customize group parameters" gnus-summary-customize-parameters t]
2015 ["Send a bug report" gnus-bug t]
2017 ["Catchup and exit" gnus-summary-catchup-and-exit
2018 :help "Mark unread articles in this group as read, then exit"]
2019 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2020 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2021 ["Exit group" gnus-summary-exit
2022 :help "Exit current group, return to group selection mode"]
2023 ["Exit group without updating" gnus-summary-exit-no-update t]
2024 ["Exit and goto next group" gnus-summary-next-group t]
2025 ["Exit and goto prev group" gnus-summary-prev-group t]
2026 ["Reselect group" gnus-summary-reselect-current-group t]
2027 ["Rescan group" gnus-summary-rescan-group t]
2028 ["Update dribble" gnus-summary-save-newsrc t])))
2030 (gnus-run-hooks 'gnus-summary-menu-hook)))
2032 (defvar gnus-summary-tool-bar-map nil)
2034 ;; Emacs 21 tool bar. Should be no-op otherwise.
2035 (defun gnus-summary-make-tool-bar ()
2036 (if (and (fboundp 'tool-bar-add-item-from-menu)
2037 (default-value 'tool-bar-mode)
2038 (not gnus-summary-tool-bar-map))
2039 (setq gnus-summary-tool-bar-map
2040 (let ((tool-bar-map (make-sparse-keymap)))
2041 (tool-bar-add-item-from-menu
2042 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2043 (tool-bar-add-item-from-menu
2044 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2045 (tool-bar-add-item-from-menu
2046 'gnus-summary-post-news "post" gnus-summary-mode-map)
2047 (tool-bar-add-item-from-menu
2048 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2049 (tool-bar-add-item-from-menu
2050 'gnus-summary-followup "followup" gnus-summary-mode-map)
2051 (tool-bar-add-item-from-menu
2052 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2053 (tool-bar-add-item-from-menu
2054 'gnus-summary-reply "reply" gnus-summary-mode-map)
2055 (tool-bar-add-item-from-menu
2056 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2057 (tool-bar-add-item-from-menu
2058 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2059 (tool-bar-add-item-from-menu
2060 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2061 (tool-bar-add-item-from-menu
2062 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2063 (tool-bar-add-item-from-menu
2064 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2065 (tool-bar-add-item-from-menu
2066 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2067 (tool-bar-add-item-from-menu
2068 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2069 (tool-bar-add-item-from-menu
2070 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2072 (if gnus-summary-tool-bar-map
2073 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2075 (defun gnus-score-set-default (var value)
2076 "A version of set that updates the GNU Emacs menu-bar."
2078 ;; It is the message that forces the active status to be updated.
2081 (defun gnus-make-score-map (type)
2082 "Make a summary score map of type TYPE."
2085 (let ((headers '(("author" "from" string)
2086 ("subject" "subject" string)
2087 ("article body" "body" string)
2088 ("article head" "head" string)
2089 ("xref" "xref" string)
2090 ("extra header" "extra" string)
2091 ("lines" "lines" number)
2092 ("followups to author" "followup" string)))
2093 (types '((number ("less than" <)
2096 (string ("substring" s)
2100 (perms '(("temporary" (current-time-string))
2108 (if (eq type 'lower)
2113 (setq header (car headers))
2119 (let ((ts (cdr (assoc (nth 2 header) types)))
2135 'gnus-summary-score-entry
2137 (if (or (string= (nth 1 header)
2139 (string= (nth 1 header)
2142 (list 'gnus-summary-header
2144 (list 'quote (nth 1 (car ts)))
2145 (list 'gnus-score-delta-default
2152 (list (nreverse outp))))
2155 (list (nreverse outt))))
2157 (setq headers (cdr headers)))
2158 (list (nreverse outh))))))))
2162 (defun gnus-summary-mode (&optional group)
2163 "Major mode for reading articles.
2165 All normal editing commands are switched off.
2166 \\<gnus-summary-mode-map>
2167 Each line in this buffer represents one article. To read an
2168 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2169 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2172 You can also post articles and send mail from this buffer. To
2173 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2174 of an article, type `\\[gnus-summary-reply]'.
2176 There are approx. one gazillion commands you can execute in this
2177 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2179 The following commands are available:
2181 \\{gnus-summary-mode-map}"
2183 (kill-all-local-variables)
2184 (when (gnus-visual-p 'summary-menu 'menu)
2185 (gnus-summary-make-menu-bar)
2186 (gnus-summary-make-tool-bar))
2187 (gnus-summary-make-local-variables)
2188 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2189 (gnus-summary-make-local-variables))
2190 (gnus-make-thread-indent-array)
2191 (gnus-simplify-mode-line)
2192 (setq major-mode 'gnus-summary-mode)
2193 (setq mode-name "Summary")
2194 (make-local-variable 'minor-mode-alist)
2195 (use-local-map gnus-summary-mode-map)
2196 (buffer-disable-undo)
2197 (setq buffer-read-only t) ;Disable modification
2198 (setq truncate-lines t)
2199 (setq selective-display t)
2200 (setq selective-display-ellipses t) ;Display `...'
2201 (gnus-summary-set-display-table)
2202 (gnus-set-default-directory)
2203 (setq gnus-newsgroup-name group)
2204 (make-local-variable 'gnus-summary-line-format)
2205 (make-local-variable 'gnus-summary-line-format-spec)
2206 (make-local-variable 'gnus-summary-dummy-line-format)
2207 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2208 (make-local-variable 'gnus-summary-mark-positions)
2209 (make-local-hook 'pre-command-hook)
2210 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2211 (gnus-run-hooks 'gnus-summary-mode-hook)
2212 (mm-enable-multibyte-mule4)
2213 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2214 (gnus-update-summary-mark-positions))
2216 (defun gnus-summary-make-local-variables ()
2217 "Make all the local summary buffer variables."
2219 (dolist (local gnus-summary-local-variables)
2222 (if (eq (cdr local) 'global)
2223 ;; Copy the global value of the variable.
2224 (setq global (symbol-value (car local)))
2225 ;; Use the value from the list.
2226 (setq global (eval (cdr local))))
2227 (set (make-local-variable (car local)) global))
2228 ;; Simple nil-valued local variable.
2229 (set (make-local-variable local) nil)))))
2231 (defun gnus-summary-clear-local-variables ()
2232 (let ((locals gnus-summary-local-variables))
2234 (if (consp (car locals))
2235 (and (vectorp (caar locals))
2236 (set (caar locals) nil))
2237 (and (vectorp (car locals))
2238 (set (car locals) nil)))
2239 (setq locals (cdr locals)))))
2241 ;; Summary data functions.
2243 (defmacro gnus-data-number (data)
2246 (defmacro gnus-data-set-number (data number)
2247 `(setcar ,data ,number))
2249 (defmacro gnus-data-mark (data)
2252 (defmacro gnus-data-set-mark (data mark)
2253 `(setcar (nthcdr 1 ,data) ,mark))
2255 (defmacro gnus-data-pos (data)
2258 (defmacro gnus-data-set-pos (data pos)
2259 `(setcar (nthcdr 2 ,data) ,pos))
2261 (defmacro gnus-data-header (data)
2264 (defmacro gnus-data-set-header (data header)
2265 `(setf (nth 3 ,data) ,header))
2267 (defmacro gnus-data-level (data)
2270 (defmacro gnus-data-unread-p (data)
2271 `(= (nth 1 ,data) gnus-unread-mark))
2273 (defmacro gnus-data-read-p (data)
2274 `(/= (nth 1 ,data) gnus-unread-mark))
2276 (defmacro gnus-data-pseudo-p (data)
2277 `(consp (nth 3 ,data)))
2279 (defmacro gnus-data-find (number)
2280 `(assq ,number gnus-newsgroup-data))
2282 (defmacro gnus-data-find-list (number &optional data)
2283 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2284 (memq (assq ,number bdata)
2287 (defmacro gnus-data-make (number mark pos header level)
2288 `(list ,number ,mark ,pos ,header ,level))
2290 (defun gnus-data-enter (after-article number mark pos header level offset)
2291 (let ((data (gnus-data-find-list after-article)))
2293 (error "No such article: %d" after-article))
2294 (setcdr data (cons (gnus-data-make number mark pos header level)
2296 (setq gnus-newsgroup-data-reverse nil)
2297 (gnus-data-update-list (cddr data) offset)))
2299 (defun gnus-data-enter-list (after-article list &optional offset)
2301 (let ((data (and after-article (gnus-data-find-list after-article)))
2305 (let ((odata gnus-newsgroup-data))
2306 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2308 (gnus-data-update-list odata offset)))
2309 ;; Find the last element in the list to be spliced into the main
2312 (setq list (cdr list)))
2315 (setcdr list gnus-newsgroup-data)
2316 (setq gnus-newsgroup-data ilist)
2318 (gnus-data-update-list (cdr list) offset)))
2319 (setcdr list (cdr data))
2322 (gnus-data-update-list (cdr list) offset))))
2323 (setq gnus-newsgroup-data-reverse nil))))
2325 (defun gnus-data-remove (article &optional offset)
2326 (let ((data gnus-newsgroup-data))
2327 (if (= (gnus-data-number (car data)) article)
2329 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2330 gnus-newsgroup-data-reverse nil)
2332 (gnus-data-update-list gnus-newsgroup-data offset)))
2334 (when (= (gnus-data-number (cadr data)) article)
2335 (setcdr data (cddr data))
2337 (gnus-data-update-list (cdr data) offset))
2339 gnus-newsgroup-data-reverse nil))
2340 (setq data (cdr data))))))
2342 (defmacro gnus-data-list (backward)
2344 (or gnus-newsgroup-data-reverse
2345 (setq gnus-newsgroup-data-reverse
2346 (reverse gnus-newsgroup-data)))
2347 gnus-newsgroup-data))
2349 (defun gnus-data-update-list (data offset)
2350 "Add OFFSET to the POS of all data entries in DATA."
2351 (setq gnus-newsgroup-data-reverse nil)
2353 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2354 (setq data (cdr data))))
2356 (defun gnus-summary-article-pseudo-p (article)
2357 "Say whether this article is a pseudo article or not."
2358 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2360 (defmacro gnus-summary-article-sparse-p (article)
2361 "Say whether this article is a sparse article or not."
2362 `(memq ,article gnus-newsgroup-sparse))
2364 (defmacro gnus-summary-article-ancient-p (article)
2365 "Say whether this article is a sparse article or not."
2366 `(memq ,article gnus-newsgroup-ancient))
2368 (defun gnus-article-parent-p (number)
2369 "Say whether this article is a parent or not."
2370 (let ((data (gnus-data-find-list number)))
2371 (and (cdr data) ; There has to be an article after...
2372 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2373 (gnus-data-level (nth 1 data))))))
2375 (defun gnus-article-children (number)
2376 "Return a list of all children to NUMBER."
2377 (let* ((data (gnus-data-find-list number))
2378 (level (gnus-data-level (car data)))
2380 (setq data (cdr data))
2382 (= (gnus-data-level (car data)) (1+ level)))
2383 (push (gnus-data-number (car data)) children)
2384 (setq data (cdr data)))
2387 (defmacro gnus-summary-skip-intangible ()
2388 "If the current article is intangible, then jump to a different article."
2389 '(let ((to (get-text-property (point) 'gnus-intangible)))
2390 (and to (gnus-summary-goto-subject to))))
2392 (defmacro gnus-summary-article-intangible-p ()
2393 "Say whether this article is intangible or not."
2394 '(get-text-property (point) 'gnus-intangible))
2396 (defun gnus-article-read-p (article)
2397 "Say whether ARTICLE is read or not."
2398 (not (or (memq article gnus-newsgroup-marked)
2399 (memq article gnus-newsgroup-unreads)
2400 (memq article gnus-newsgroup-unselected)
2401 (memq article gnus-newsgroup-dormant))))
2403 ;; Some summary mode macros.
2405 (defmacro gnus-summary-article-number ()
2406 "The article number of the article on the current line.
2407 If there isn's an article number here, then we return the current
2410 (gnus-summary-skip-intangible)
2411 (or (get-text-property (point) 'gnus-number)
2412 (gnus-summary-last-subject))))
2414 (defmacro gnus-summary-article-header (&optional number)
2415 "Return the header of article NUMBER."
2416 `(gnus-data-header (gnus-data-find
2417 ,(or number '(gnus-summary-article-number)))))
2419 (defmacro gnus-summary-thread-level (&optional number)
2420 "Return the level of thread that starts with article NUMBER."
2421 `(if (and (eq gnus-summary-make-false-root 'dummy)
2422 (get-text-property (point) 'gnus-intangible))
2424 (gnus-data-level (gnus-data-find
2425 ,(or number '(gnus-summary-article-number))))))
2427 (defmacro gnus-summary-article-mark (&optional number)
2428 "Return the mark of article NUMBER."
2429 `(gnus-data-mark (gnus-data-find
2430 ,(or number '(gnus-summary-article-number)))))
2432 (defmacro gnus-summary-article-pos (&optional number)
2433 "Return the position of the line of article NUMBER."
2434 `(gnus-data-pos (gnus-data-find
2435 ,(or number '(gnus-summary-article-number)))))
2437 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2438 (defmacro gnus-summary-article-subject (&optional number)
2439 "Return current subject string or nil if nothing."
2442 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2443 '(gnus-data-header (assq (gnus-summary-article-number)
2444 gnus-newsgroup-data)))))
2447 (mail-header-subject headers))))
2449 (defmacro gnus-summary-article-score (&optional number)
2450 "Return current article score."
2451 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2452 gnus-newsgroup-scored))
2453 gnus-summary-default-score 0))
2455 (defun gnus-summary-article-children (&optional number)
2456 "Return a list of article numbers that are children of article NUMBER."
2457 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2458 (level (gnus-data-level (car data)))
2460 (while (and (setq data (cdr data))
2461 (> (setq l (gnus-data-level (car data))) level))
2462 (and (= (1+ level) l)
2463 (push (gnus-data-number (car data))
2465 (nreverse children)))
2467 (defun gnus-summary-article-parent (&optional number)
2468 "Return the article number of the parent of article NUMBER."
2469 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2470 (gnus-data-list t)))
2471 (level (gnus-data-level (car data))))
2473 () ; This is a root.
2474 ;; We search until we find an article with a level less than
2475 ;; this one. That function has to be the parent.
2476 (while (and (setq data (cdr data))
2477 (not (< (gnus-data-level (car data)) level))))
2478 (and data (gnus-data-number (car data))))))
2480 (defun gnus-unread-mark-p (mark)
2481 "Say whether MARK is the unread mark."
2482 (= mark gnus-unread-mark))
2484 (defun gnus-read-mark-p (mark)
2485 "Say whether MARK is one of the marks that mark as read.
2486 This is all marks except unread, ticked, dormant, and expirable."
2487 (not (or (= mark gnus-unread-mark)
2488 (= mark gnus-ticked-mark)
2489 (= mark gnus-dormant-mark)
2490 (= mark gnus-expirable-mark))))
2492 (defmacro gnus-article-mark (number)
2493 "Return the MARK of article NUMBER.
2494 This macro should only be used when computing the mark the \"first\"
2495 time; i.e., when generating the summary lines. After that,
2496 `gnus-summary-article-mark' should be used to examine the
2499 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2500 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2501 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2502 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2503 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2504 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2505 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2506 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2507 gnus-ancient-mark))))
2509 ;; Saving hidden threads.
2511 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2512 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2514 (defmacro gnus-save-hidden-threads (&rest forms)
2515 "Save hidden threads, eval FORMS, and restore the hidden threads."
2516 (let ((config (make-symbol "config")))
2517 `(let ((,config (gnus-hidden-threads-configuration)))
2521 (gnus-restore-hidden-threads-configuration ,config)))))
2523 (defun gnus-data-compute-positions ()
2524 "Compute the positions of all articles."
2525 (setq gnus-newsgroup-data-reverse nil)
2526 (let ((data gnus-newsgroup-data))
2528 (gnus-save-hidden-threads
2529 (gnus-summary-show-all-threads)
2530 (goto-char (point-min))
2532 (while (get-text-property (point) 'gnus-intangible)
2534 (gnus-data-set-pos (car data) (+ (point) 3))
2535 (setq data (cdr data))
2536 (forward-line 1))))))
2538 (defun gnus-hidden-threads-configuration ()
2539 "Return the current hidden threads configuration."
2542 (goto-char (point-min))
2543 (while (search-forward "\r" nil t)
2544 (push (1- (point)) config))
2547 (defun gnus-restore-hidden-threads-configuration (config)
2548 "Restore hidden threads configuration from CONFIG."
2550 (let (point buffer-read-only)
2551 (while (setq point (pop config))
2552 (when (and (< point (point-max))
2554 (eq (char-after) ?\n))
2555 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2557 ;; Various summary mode internalish functions.
2559 (defun gnus-mouse-pick-article (e)
2562 (gnus-summary-next-page nil t))
2564 (defun gnus-summary-set-display-table ()
2565 "Change the display table.
2566 Odd characters have a tendency to mess
2567 up nicely formatted displays - we make all possible glyphs
2568 display only a single character."
2570 ;; We start from the standard display table, if any.
2571 (let ((table (or (copy-sequence standard-display-table)
2572 (make-display-table)))
2574 ;; Nix out all the control chars...
2575 (while (>= (setq i (1- i)) 0)
2576 (aset table i [??]))
2577 ;; ... but not newline and cr, of course. (cr is necessary for the
2578 ;; selective display).
2579 (aset table ?\n nil)
2580 (aset table ?\r nil)
2581 ;; We keep TAB as well.
2582 (aset table ?\t nil)
2583 ;; We nix out any glyphs over 126 that are not set already.
2585 (while (>= (setq i (1- i)) 127)
2586 ;; Only modify if the entry is nil.
2587 (unless (aref table i)
2588 (aset table i [??]))))
2589 (setq buffer-display-table table)))
2591 (defun gnus-summary-setup-buffer (group)
2592 "Initialize summary buffer."
2593 (let ((buffer (concat "*Summary " group "*")))
2594 (if (get-buffer buffer)
2597 (setq gnus-summary-buffer (current-buffer))
2598 (not gnus-newsgroup-prepared))
2599 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2600 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2601 (gnus-summary-mode group)
2603 (gnus-carpal-setup-buffer 'summary))
2604 (unless gnus-single-article-buffer
2605 (make-local-variable 'gnus-article-buffer)
2606 (make-local-variable 'gnus-article-current)
2607 (make-local-variable 'gnus-original-article-buffer))
2608 (setq gnus-newsgroup-name group)
2611 (defun gnus-set-global-variables ()
2612 "Set the global equivalents of the buffer-local variables.
2613 They are set to the latest values they had. These reflect the summary
2614 buffer that was in action when the last article was fetched."
2615 (when (eq major-mode 'gnus-summary-mode)
2616 (setq gnus-summary-buffer (current-buffer))
2617 (let ((name gnus-newsgroup-name)
2618 (marked gnus-newsgroup-marked)
2619 (unread gnus-newsgroup-unreads)
2620 (headers gnus-current-headers)
2621 (data gnus-newsgroup-data)
2622 (summary gnus-summary-buffer)
2623 (article-buffer gnus-article-buffer)
2624 (original gnus-original-article-buffer)
2625 (gac gnus-article-current)
2626 (reffed gnus-reffed-article-number)
2627 (score-file gnus-current-score-file)
2628 (default-charset gnus-newsgroup-charset)
2630 (let ((locals gnus-newsgroup-variables))
2632 (if (consp (car locals))
2633 (push (eval (caar locals)) vlist)
2634 (push (eval (car locals)) vlist))
2635 (setq locals (cdr locals)))
2636 (setq vlist (nreverse vlist)))
2638 (set-buffer gnus-group-buffer)
2639 (setq gnus-newsgroup-name name
2640 gnus-newsgroup-marked marked
2641 gnus-newsgroup-unreads unread
2642 gnus-current-headers headers
2643 gnus-newsgroup-data data
2644 gnus-article-current gac
2645 gnus-summary-buffer summary
2646 gnus-article-buffer article-buffer
2647 gnus-original-article-buffer original
2648 gnus-reffed-article-number reffed
2649 gnus-current-score-file score-file
2650 gnus-newsgroup-charset default-charset)
2651 (let ((locals gnus-newsgroup-variables))
2653 (if (consp (car locals))
2654 (set (caar locals) (pop vlist))
2655 (set (car locals) (pop vlist)))
2656 (setq locals (cdr locals))))
2657 ;; The article buffer also has local variables.
2658 (when (gnus-buffer-live-p gnus-article-buffer)
2659 (set-buffer gnus-article-buffer)
2660 (setq gnus-summary-buffer summary))))))
2662 (defun gnus-summary-article-unread-p (article)
2663 "Say whether ARTICLE is unread or not."
2664 (memq article gnus-newsgroup-unreads))
2666 (defun gnus-summary-first-article-p (&optional article)
2667 "Return whether ARTICLE is the first article in the buffer."
2668 (if (not (setq article (or article (gnus-summary-article-number))))
2670 (eq article (caar gnus-newsgroup-data))))
2672 (defun gnus-summary-last-article-p (&optional article)
2673 "Return whether ARTICLE is the last article in the buffer."
2674 (if (not (setq article (or article (gnus-summary-article-number))))
2675 ;; All non-existent numbers are the last article. :-)
2677 (not (cdr (gnus-data-find-list article)))))
2679 (defun gnus-make-thread-indent-array ()
2681 (unless (and gnus-thread-indent-array
2682 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2683 (setq gnus-thread-indent-array (make-vector 201 "")
2684 gnus-thread-indent-array-level gnus-thread-indent-level)
2686 (aset gnus-thread-indent-array n
2687 (make-string (* n gnus-thread-indent-level) ? ))
2690 (defun gnus-update-summary-mark-positions ()
2691 "Compute where the summary marks are to go."
2693 (when (gnus-buffer-exists-p gnus-summary-buffer)
2694 (set-buffer gnus-summary-buffer))
2695 (let ((gnus-replied-mark 129)
2696 (gnus-score-below-mark 130)
2697 (gnus-score-over-mark 130)
2698 (gnus-download-mark 131)
2699 (spec gnus-summary-line-format-spec)
2702 (gnus-set-work-buffer)
2703 (let ((gnus-summary-line-format-spec spec)
2704 (gnus-newsgroup-downloadable '((0 . t))))
2705 (gnus-summary-insert-line
2706 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2707 (goto-char (point-min))
2708 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2710 (goto-char (point-min))
2711 (push (cons 'replied (and (search-forward "\201" nil t)
2714 (goto-char (point-min))
2715 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2717 (goto-char (point-min))
2718 (push (cons 'download
2719 (and (search-forward "\203" nil t) (- (point) 2)))
2721 (setq gnus-summary-mark-positions pos))))
2723 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2724 "Insert a dummy root in the summary buffer."
2726 (gnus-add-text-properties
2727 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2728 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2730 (defun gnus-summary-from-or-to-or-newsgroups (header)
2731 (let ((to (cdr (assq 'To (mail-header-extra header))))
2732 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2733 (mail-parse-charset gnus-newsgroup-charset)
2734 (mail-parse-ignored-charsets
2735 (save-excursion (set-buffer gnus-summary-buffer)
2736 gnus-newsgroup-ignored-charsets)))
2739 gnus-ignored-from-addresses
2740 (string-match gnus-ignored-from-addresses
2741 (mail-header-from header)))
2743 (or (car (funcall gnus-extract-address-components
2745 gnus-decode-encoded-word-function to)))
2746 (funcall gnus-decode-encoded-word-function to))))
2748 gnus-ignored-from-addresses
2749 (string-match gnus-ignored-from-addresses
2750 (mail-header-from header)))
2751 (concat "=> " newsgroups))
2753 (or (car (funcall gnus-extract-address-components
2754 (mail-header-from header)))
2755 (mail-header-from header))))))
2757 (defun gnus-summary-insert-line (gnus-tmp-header
2758 gnus-tmp-level gnus-tmp-current
2759 gnus-tmp-unread gnus-tmp-replied
2760 gnus-tmp-expirable gnus-tmp-subject-or-nil
2761 &optional gnus-tmp-dummy gnus-tmp-score
2763 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2764 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2765 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2766 (gnus-tmp-score-char
2767 (if (or (null gnus-summary-default-score)
2768 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2769 gnus-summary-zcore-fuzz))
2771 (if (< gnus-tmp-score gnus-summary-default-score)
2772 gnus-score-below-mark gnus-score-over-mark)))
2774 (cond (gnus-tmp-process gnus-process-mark)
2775 ((memq gnus-tmp-current gnus-newsgroup-cached)
2777 (gnus-tmp-replied gnus-replied-mark)
2778 ((memq gnus-tmp-current gnus-newsgroup-saved)
2780 (t gnus-unread-mark)))
2781 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2784 ((string-match "<[^>]+> *$" gnus-tmp-from)
2785 (let ((beg (match-beginning 0)))
2786 (or (and (string-match "^\".+\"" gnus-tmp-from)
2787 (substring gnus-tmp-from 1 (1- (match-end 0))))
2788 (substring gnus-tmp-from 0 beg))))
2789 ((string-match "(.+)" gnus-tmp-from)
2790 (substring gnus-tmp-from
2791 (1+ (match-beginning 0)) (1- (match-end 0))))
2793 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2794 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2795 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2796 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2797 (buffer-read-only nil))
2798 (when (string= gnus-tmp-name "")
2799 (setq gnus-tmp-name gnus-tmp-from))
2800 (unless (numberp gnus-tmp-lines)
2801 (setq gnus-tmp-lines 0))
2802 (gnus-put-text-property
2804 (progn (eval gnus-summary-line-format-spec) (point))
2805 'gnus-number gnus-tmp-number)
2806 (when (gnus-visual-p 'summary-highlight 'highlight)
2808 (gnus-run-hooks 'gnus-summary-update-hook)
2811 (defun gnus-summary-update-line (&optional dont-update)
2812 "Update summary line after change."
2813 (when (and gnus-summary-default-score
2814 (not gnus-summary-inhibit-highlight))
2815 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2816 (article (gnus-summary-article-number))
2817 (score (gnus-summary-article-score article)))
2819 (if (and gnus-summary-mark-below
2820 (< (gnus-summary-article-score)
2821 gnus-summary-mark-below))
2822 ;; This article has a low score, so we mark it as read.
2823 (when (memq article gnus-newsgroup-unreads)
2824 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2825 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2826 ;; This article was previously marked as read on account
2827 ;; of a low score, but now it has risen, so we mark it as
2829 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2830 (gnus-summary-update-mark
2831 (if (or (null gnus-summary-default-score)
2832 (<= (abs (- score gnus-summary-default-score))
2833 gnus-summary-zcore-fuzz))
2835 (if (< score gnus-summary-default-score)
2836 gnus-score-below-mark gnus-score-over-mark))
2838 ;; Do visual highlighting.
2839 (when (gnus-visual-p 'summary-highlight 'highlight)
2840 (gnus-run-hooks 'gnus-summary-update-hook)))))
2842 (defvar gnus-tmp-new-adopts nil)
2844 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2845 "Return the number of articles in THREAD.
2846 This may be 0 in some cases -- if none of the articles in
2847 the thread are to be displayed."
2849 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2851 ((not (listp thread))
2853 ((and (consp thread) (cdr thread))
2856 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2859 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2862 (when (and level (zerop level) gnus-tmp-new-adopts)
2865 'gnus-summary-number-of-articles-in-thread
2866 gnus-tmp-new-adopts))))
2868 (if (> number 1) gnus-not-empty-thread-mark
2869 gnus-empty-thread-mark)
2872 (defun gnus-summary-set-local-parameters (group)
2873 "Go through the local params of GROUP and set all variable specs in that list."
2874 (let ((params (gnus-group-find-parameter group))
2877 (setq elem (car params)
2878 params (cdr params))
2879 (and (consp elem) ; Has to be a cons.
2880 (consp (cdr elem)) ; The cdr has to be a list.
2881 (symbolp (car elem)) ; Has to be a symbol in there.
2882 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2883 (ignore-errors ; So we set it.
2884 (make-local-variable (car elem))
2885 (set (car elem) (eval (nth 1 elem))))))))
2887 (defun gnus-summary-read-group (group &optional show-all no-article
2888 kill-buffer no-display backward
2890 "Start reading news in newsgroup GROUP.
2891 If SHOW-ALL is non-nil, already read articles are also listed.
2892 If NO-ARTICLE is non-nil, no article is selected initially.
2893 If NO-DISPLAY, don't generate a summary buffer."
2897 (let ((gnus-auto-select-next nil))
2898 (or (gnus-summary-read-group-1
2899 group show-all no-article
2900 kill-buffer no-display
2903 select-articles nil)))))
2904 (eq gnus-auto-select-next 'quietly))
2905 (set-buffer gnus-group-buffer)
2906 ;; The entry function called above goes to the next
2907 ;; group automatically, so we go two groups back
2908 ;; if we are searching for the previous group.
2910 (gnus-group-prev-unread-group 2))
2911 (if (not (equal group (gnus-group-group-name)))
2912 (setq group (gnus-group-group-name))
2916 (defun gnus-summary-read-group-1 (group show-all no-article
2917 kill-buffer no-display
2918 &optional select-articles)
2919 ;; Killed foreign groups can't be entered.
2920 (when (and (not (gnus-group-native-p group))
2921 (not (gnus-gethash group gnus-newsrc-hashtb)))
2922 (error "Dead non-native groups can't be entered"))
2923 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2924 (let* ((new-group (gnus-summary-setup-buffer group))
2925 (quit-config (gnus-group-quit-config group))
2926 (did-select (and new-group (gnus-select-newsgroup
2927 group show-all select-articles))))
2929 ;; This summary buffer exists already, so we just select it.
2931 (gnus-set-global-variables)
2933 (gnus-kill-or-deaden-summary kill-buffer))
2934 (gnus-configure-windows 'summary 'force)
2935 (gnus-set-mode-line 'summary)
2936 (gnus-summary-position-point)
2939 ;; We couldn't select this group.
2941 (when (and (eq major-mode 'gnus-summary-mode)
2942 (not (equal (current-buffer) kill-buffer)))
2943 (kill-buffer (current-buffer))
2944 (if (not quit-config)
2946 ;; Update the info -- marks might need to be removed,
2948 (gnus-summary-update-info)
2949 (set-buffer gnus-group-buffer)
2950 (gnus-group-jump-to-group group)
2951 (gnus-group-next-unread-group 1))
2952 (gnus-handle-ephemeral-exit quit-config)))
2953 (gnus-message 3 "Can't select group")
2955 ;; The user did a `C-g' while prompting for number of articles,
2956 ;; so we exit this group.
2957 ((eq did-select 'quit)
2958 (and (eq major-mode 'gnus-summary-mode)
2959 (not (equal (current-buffer) kill-buffer))
2960 (kill-buffer (current-buffer)))
2962 (gnus-kill-or-deaden-summary kill-buffer))
2963 (if (not quit-config)
2965 (set-buffer gnus-group-buffer)
2966 (gnus-group-jump-to-group group)
2967 (gnus-group-next-unread-group 1)
2968 (gnus-configure-windows 'group 'force))
2969 (gnus-handle-ephemeral-exit quit-config))
2970 ;; Finally signal the quit.
2972 ;; The group was successfully selected.
2974 (gnus-set-global-variables)
2975 ;; Save the active value in effect when the group was entered.
2976 (setq gnus-newsgroup-active
2978 (gnus-active gnus-newsgroup-name)))
2979 ;; You can change the summary buffer in some way with this hook.
2980 (gnus-run-hooks 'gnus-select-group-hook)
2981 ;; Set any local variables in the group parameters.
2982 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2983 (gnus-update-format-specifications
2984 nil 'summary 'summary-mode 'summary-dummy)
2985 (gnus-update-summary-mark-positions)
2986 ;; Do score processing.
2987 (when gnus-use-scoring
2988 (gnus-possibly-score-headers))
2989 ;; Check whether to fill in the gaps in the threads.
2990 (when gnus-build-sparse-threads
2991 (gnus-build-sparse-threads))
2992 ;; Find the initial limit.
2993 (if gnus-show-threads
2995 (let ((gnus-newsgroup-dormant nil))
2996 (gnus-summary-initial-limit show-all))
2997 (gnus-summary-initial-limit show-all))
2998 ;; When untreaded, all articles are always shown.
2999 (setq gnus-newsgroup-limit
3001 (lambda (header) (mail-header-number header))
3002 gnus-newsgroup-headers)))
3003 ;; Generate the summary buffer.
3005 (gnus-summary-prepare))
3006 (when gnus-use-trees
3007 (gnus-tree-open group)
3008 (setq gnus-summary-highlight-line-function
3009 'gnus-tree-highlight-article))
3010 ;; If the summary buffer is empty, but there are some low-scored
3011 ;; articles or some excluded dormants, we include these in the
3013 (when (and (zerop (buffer-size))
3015 (cond (gnus-newsgroup-dormant
3016 (gnus-summary-limit-include-dormant))
3017 ((and gnus-newsgroup-scored show-all)
3018 (gnus-summary-limit-include-expunged t))))
3019 ;; Function `gnus-apply-kill-file' must be called in this hook.
3020 (gnus-run-hooks 'gnus-apply-kill-hook)
3021 (if (and (zerop (buffer-size))
3024 ;; This newsgroup is empty.
3025 (gnus-summary-catchup-and-exit nil t)
3026 (gnus-message 6 "No unread news")
3028 (gnus-kill-or-deaden-summary kill-buffer))
3029 ;; Return nil from this function.
3031 ;; Hide conversation thread subtrees. We cannot do this in
3032 ;; gnus-summary-prepare-hook since kill processing may not
3033 ;; work with hidden articles.
3034 (and gnus-show-threads
3035 gnus-thread-hide-subtree
3036 (gnus-summary-hide-all-threads))
3038 (gnus-kill-or-deaden-summary kill-buffer))
3039 ;; Show first unread article if requested.
3040 (if (and (not no-article)
3042 gnus-newsgroup-unreads
3043 gnus-auto-select-first)
3045 (gnus-configure-windows 'summary)
3047 ((eq gnus-auto-select-first 'best)
3048 (gnus-summary-best-unread-article))
3049 ((eq gnus-auto-select-first t)
3050 (gnus-summary-first-unread-article))
3051 ((gnus-functionp gnus-auto-select-first)
3052 (funcall gnus-auto-select-first))))
3053 ;; Don't select any articles, just move point to the first
3054 ;; article in the group.
3055 (goto-char (point-min))
3056 (gnus-summary-position-point)
3057 (gnus-configure-windows 'summary 'force)
3058 (gnus-set-mode-line 'summary))
3059 (when (get-buffer-window gnus-group-buffer t)
3060 ;; Gotta use windows, because recenter does weird stuff if
3061 ;; the current buffer ain't the displayed window.
3062 (let ((owin (selected-window)))
3063 (select-window (get-buffer-window gnus-group-buffer t))
3064 (when (gnus-group-goto-group group)
3066 (select-window owin)))
3067 ;; Mark this buffer as "prepared".
3068 (setq gnus-newsgroup-prepared t)
3069 (gnus-run-hooks 'gnus-summary-prepared-hook)
3072 (defun gnus-summary-prepare ()
3073 "Generate the summary buffer."
3075 (let ((buffer-read-only nil))
3077 (setq gnus-newsgroup-data nil
3078 gnus-newsgroup-data-reverse nil)
3079 (gnus-run-hooks 'gnus-summary-generate-hook)
3080 ;; Generate the buffer, either with threads or without.
3081 (when gnus-newsgroup-headers
3082 (gnus-summary-prepare-threads
3083 (if gnus-show-threads
3084 (gnus-sort-gathered-threads
3085 (funcall gnus-summary-thread-gathering-function
3087 (gnus-cut-threads (gnus-make-threads)))))
3088 ;; Unthreaded display.
3089 (gnus-sort-articles gnus-newsgroup-headers))))
3090 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3091 ;; Call hooks for modifying summary buffer.
3092 (goto-char (point-min))
3093 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3095 (defsubst gnus-general-simplify-subject (subject)
3096 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3099 ;; Truncate the subject.
3100 (gnus-simplify-subject-functions
3101 (gnus-map-function gnus-simplify-subject-functions subject))
3102 ((numberp gnus-summary-gather-subject-limit)
3103 (setq subject (gnus-simplify-subject-re subject))
3104 (if (> (length subject) gnus-summary-gather-subject-limit)
3105 (substring subject 0 gnus-summary-gather-subject-limit)
3107 ;; Fuzzily simplify it.
3108 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3109 (gnus-simplify-subject-fuzzy subject))
3110 ;; Just remove the leading "Re:".
3112 (gnus-simplify-subject-re subject))))
3114 (if (and gnus-summary-gather-exclude-subject
3115 (string-match gnus-summary-gather-exclude-subject subject))
3116 nil ; This article shouldn't be gathered
3119 (defun gnus-summary-simplify-subject-query ()
3120 "Query where the respool algorithm would put this article."
3122 (gnus-summary-select-article)
3123 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3125 (defun gnus-gather-threads-by-subject (threads)
3126 "Gather threads by looking at Subject headers."
3127 (if (not gnus-summary-make-false-root)
3129 (let ((hashtb (gnus-make-hashtable 1024))
3132 subject hthread whole-subject)
3134 (setq subject (gnus-general-simplify-subject
3135 (setq whole-subject (mail-header-subject
3138 (if (setq hthread (gnus-gethash subject hashtb))
3140 ;; We enter a dummy root into the thread, if we
3141 ;; haven't done that already.
3142 (unless (stringp (caar hthread))
3143 (setcar hthread (list whole-subject (car hthread))))
3144 ;; We add this new gathered thread to this gathered
3146 (setcdr (car hthread)
3147 (nconc (cdar hthread) (list (car threads))))
3148 ;; Remove it from the list of threads.
3149 (setcdr prev (cdr threads))
3150 (setq threads prev))
3151 ;; Enter this thread into the hash table.
3152 (gnus-sethash subject threads hashtb)))
3154 (setq threads (cdr threads)))
3157 (defun gnus-gather-threads-by-references (threads)
3158 "Gather threads by looking at References headers."
3159 (let ((idhashtb (gnus-make-hashtable 1024))
3160 (thhashtb (gnus-make-hashtable 1024))
3163 ids references id gthread gid entered ref)
3165 (when (setq references (mail-header-references (caar threads)))
3166 (setq id (mail-header-id (caar threads))
3167 ids (gnus-split-references references)
3169 (while (setq ref (pop ids))
3170 (setq ids (delete ref ids))
3171 (if (not (setq gid (gnus-gethash ref idhashtb)))
3173 (gnus-sethash ref id idhashtb)
3174 (gnus-sethash id threads thhashtb))
3175 (setq gthread (gnus-gethash gid thhashtb))
3177 ;; We enter a dummy root into the thread, if we
3178 ;; haven't done that already.
3179 (unless (stringp (caar gthread))
3180 (setcar gthread (list (mail-header-subject (caar gthread))
3182 ;; We add this new gathered thread to this gathered
3184 (setcdr (car gthread)
3185 (nconc (cdar gthread) (list (car threads)))))
3186 ;; Add it into the thread hash table.
3187 (gnus-sethash id gthread thhashtb)
3189 ;; Remove it from the list of threads.
3190 (setcdr prev (cdr threads))
3191 (setq threads prev))))
3193 (setq threads (cdr threads)))
3196 (defun gnus-sort-gathered-threads (threads)
3197 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3198 (let ((result threads))
3200 (when (stringp (caar threads))
3201 (setcdr (car threads)
3202 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3203 (setq threads (cdr threads)))
3206 (defun gnus-thread-loop-p (root thread)
3207 "Say whether ROOT is in THREAD."
3208 (let ((stack (list thread))
3211 (while (setq thread (pop stack))
3212 (setq th (cdr thread))
3214 (not (eq (caar th) root)))
3217 ;; We have found a loop.
3219 (setcdr thread (delq (car th) (cdr thread)))
3220 (if (boundp (setq ref-dep (intern "none"
3221 gnus-newsgroup-dependencies)))
3222 (setcdr (symbol-value ref-dep)
3223 (nconc (cdr (symbol-value ref-dep))
3225 (set ref-dep (list nil (car th))))
3228 ;; Push all the subthreads onto the stack.
3229 (push (cdr thread) stack)))
3232 (defun gnus-make-threads ()
3233 "Go through the dependency hashtb and find the roots. Return all threads."
3235 (while (catch 'infloop
3238 ;; Deal with self-referencing References loops.
3239 (when (and (car (symbol-value refs))
3246 (car (symbol-value refs)) thread))
3247 (cdr (symbol-value refs)))))))
3250 (unless (car (symbol-value refs))
3251 ;; These threads do not refer back to any other articles,
3252 ;; so they're roots.
3253 (setq threads (append (cdr (symbol-value refs)) threads))))
3254 gnus-newsgroup-dependencies)))
3257 ;; Build the thread tree.
3258 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3259 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3261 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3262 if it was already present.
3264 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3265 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3266 Message-IDs will be renamed be renamed to a unique Message-ID before
3269 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3270 (let* ((id (mail-header-id header))
3271 (id-dep (and id (intern id dependencies)))
3272 ref ref-dep ref-header)
3273 ;; Enter this `header' in the `dependencies' table.
3277 ;; The first two cases do the normal part: enter a new `header'
3278 ;; in the `dependencies' table.
3279 ((not (boundp id-dep))
3280 (set id-dep (list header)))
3281 ((null (car (symbol-value id-dep)))
3282 (setcar (symbol-value id-dep) header))
3284 ;; From here the `header' was already present in the
3285 ;; `dependencies' table.
3287 ;; Overrides an existing entry;
3288 ;; just set the header part of the entry.
3289 (setcar (symbol-value id-dep) header))
3291 ;; Renames the existing `header' to a unique Message-ID.
3292 ((not gnus-summary-ignore-duplicates)
3293 ;; An article with this Message-ID has already been seen.
3294 ;; We rename the Message-ID.
3295 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3297 (mail-header-set-id header id))
3299 ;; The last case ignores an existing entry, except it adds any
3300 ;; additional Xrefs (in case the two articles came from different
3302 ;; Also sets `header' to `nil' meaning that the `dependencies'
3303 ;; table was *not* modified.
3305 (mail-header-set-xref
3306 (car (symbol-value id-dep))
3307 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3309 (or (mail-header-xref header) "")))
3313 ;; First check if that we are not creating a References loop.
3314 (setq ref (gnus-parent-id (mail-header-references header)))
3316 (setq ref-dep (intern-soft ref dependencies))
3318 (setq ref-header (car (symbol-value ref-dep))))
3319 (if (string= id ref)
3320 ;; Yuk! This is a reference loop. Make the article be a
3323 (mail-header-set-references (car (symbol-value id-dep)) "none")
3325 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3326 (setq ref (gnus-parent-id (mail-header-references header)))
3327 (setq ref-dep (intern (or ref "none") dependencies))
3328 (if (boundp ref-dep)
3329 (setcdr (symbol-value ref-dep)
3330 (nconc (cdr (symbol-value ref-dep))
3331 (list (symbol-value id-dep))))
3332 (set ref-dep (list nil (symbol-value id-dep)))))
3335 (defun gnus-build-sparse-threads ()
3336 (let ((headers gnus-newsgroup-headers)
3337 (mail-parse-charset gnus-newsgroup-charset)
3338 (gnus-summary-ignore-duplicates t)
3339 header references generation relations
3340 subject child end new-child date)
3341 ;; First we create an alist of generations/relations, where
3342 ;; generations is how much we trust the relation, and the relation
3344 (gnus-message 7 "Making sparse threads...")
3346 (nnheader-set-temp-buffer " *gnus sparse threads*")
3347 (while (setq header (pop headers))
3348 (when (and (setq references (mail-header-references header))
3349 (not (string= references "")))
3351 (setq child (mail-header-id header)
3352 subject (mail-header-subject header)
3353 date (mail-header-date header)
3355 (while (search-backward ">" nil t)
3356 (setq end (1+ (point)))
3357 (when (search-backward "<" nil t)
3358 (setq new-child (buffer-substring (point) end))
3359 (push (list (incf generation)
3360 child (setq child new-child)
3364 (push (list (1+ generation) child nil subject) relations))
3366 (kill-buffer (current-buffer)))
3367 ;; Sort over trustworthiness.
3370 (when (gnus-dependencies-add-header
3371 (make-full-mail-header
3372 gnus-reffed-article-number
3373 (nth 3 relation) "" (or (nth 4 relation) "")
3375 (or (nth 2 relation) "") 0 0 "")
3376 gnus-newsgroup-dependencies nil)
3377 (push gnus-reffed-article-number gnus-newsgroup-limit)
3378 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3379 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3380 gnus-newsgroup-reads)
3381 (decf gnus-reffed-article-number)))
3382 (sort relations 'car-less-than-car))
3383 (gnus-message 7 "Making sparse threads...done")))
3385 (defun gnus-build-old-threads ()
3386 ;; Look at all the articles that refer back to old articles, and
3387 ;; fetch the headers for the articles that aren't there. This will
3388 ;; build complete threads - if the roots haven't been expired by the
3390 (let ((mail-parse-charset gnus-newsgroup-charset)
3394 (when (not (car (symbol-value refs)))
3395 (setq heads (cdr (symbol-value refs)))
3397 (if (memq (mail-header-number (caar heads))
3398 gnus-newsgroup-dormant)
3399 (setq heads (cdr heads))
3400 (setq id (symbol-name refs))
3401 (while (and (setq id (gnus-build-get-header id))
3402 (not (car (gnus-id-to-thread id)))))
3403 (setq heads nil)))))
3404 gnus-newsgroup-dependencies)))
3406 ;; This function has to be called with point after the article number
3407 ;; on the beginning of the line.
3408 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3409 (let ((eol (gnus-point-at-eol))
3410 (buffer (current-buffer))
3413 ;; overview: [num subject from date id refs chars lines misc]
3416 (narrow-to-region (point) eol)
3421 (make-full-mail-header
3423 (funcall gnus-decode-encoded-word-function
3424 (nnheader-nov-field)) ; subject
3425 (funcall gnus-decode-encoded-word-function
3426 (nnheader-nov-field)) ; from
3427 (nnheader-nov-field) ; date
3428 (nnheader-nov-read-message-id) ; id
3429 (nnheader-nov-field) ; refs
3430 (nnheader-nov-read-integer) ; chars
3431 (nnheader-nov-read-integer) ; lines
3433 (if (looking-at "Xref: ")
3434 (goto-char (match-end 0)))
3435 (nnheader-nov-field)) ; Xref
3436 (nnheader-nov-parse-extra)))) ; extra
3440 (when gnus-alter-header-function
3441 (funcall gnus-alter-header-function header))
3442 (gnus-dependencies-add-header header dependencies force-new)))
3444 (defun gnus-build-get-header (id)
3445 "Look through the buffer of NOV lines and find the header to ID.
3446 Enter this line into the dependencies hash table, and return
3447 the id of the parent article (if any)."
3448 (let ((deps gnus-newsgroup-dependencies)
3452 (set-buffer nntp-server-buffer)
3453 (let ((case-fold-search nil))
3454 (goto-char (point-min))
3455 (while (and (not found)
3456 (search-forward id nil t))
3458 (setq found (looking-at
3459 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3460 (regexp-quote id))))
3461 (or found (beginning-of-line 2)))
3465 (setq header (gnus-nov-parse-line
3466 (read (current-buffer)) deps))
3467 (gnus-parent-id (mail-header-references header))))))
3469 (let ((number (mail-header-number header)))
3470 (push number gnus-newsgroup-limit)
3471 (push header gnus-newsgroup-headers)
3472 (if (memq number gnus-newsgroup-unselected)
3474 (push number gnus-newsgroup-unreads)
3475 (setq gnus-newsgroup-unselected
3476 (delq number gnus-newsgroup-unselected)))
3477 (push number gnus-newsgroup-ancient)))))))
3479 (defun gnus-build-all-threads ()
3480 "Read all the headers."
3481 (let ((gnus-summary-ignore-duplicates t)
3482 (mail-parse-charset gnus-newsgroup-charset)
3483 (dependencies gnus-newsgroup-dependencies)
3486 (set-buffer nntp-server-buffer)
3487 (let ((case-fold-search nil))
3488 (goto-char (point-min))
3491 (setq article (read (current-buffer))
3492 header (gnus-nov-parse-line article dependencies)))
3495 (set-buffer gnus-summary-buffer)
3496 (push header gnus-newsgroup-headers)
3497 (if (memq (setq article (mail-header-number header))
3498 gnus-newsgroup-unselected)
3500 (push article gnus-newsgroup-unreads)
3501 (setq gnus-newsgroup-unselected
3502 (delq article gnus-newsgroup-unselected)))
3503 (push article gnus-newsgroup-ancient)))
3504 (forward-line 1)))))))
3506 (defun gnus-summary-update-article-line (article header)
3507 "Update the line for ARTICLE using HEADERS."
3508 (let* ((id (mail-header-id header))
3509 (thread (gnus-id-to-thread id)))
3511 (error "Article in no thread"))
3512 ;; Update the thread.
3513 (setcar thread header)
3514 (gnus-summary-goto-subject article)
3515 (let* ((datal (gnus-data-find-list article))
3517 (length (when (cdr datal)
3518 (- (gnus-data-pos data)
3519 (gnus-data-pos (cadr datal)))))
3520 (buffer-read-only nil)
3521 (level (gnus-summary-thread-level)))
3523 (gnus-summary-insert-line
3524 header level nil (gnus-article-mark article)
3525 (memq article gnus-newsgroup-replied)
3526 (memq article gnus-newsgroup-expirable)
3527 ;; Only insert the Subject string when it's different
3528 ;; from the previous Subject string.
3533 (mail-header-subject
3536 (gnus-data-find-list
3538 (gnus-data-list t)))))
3539 ;; Error on the side of excessive subjects.
3541 (mail-header-subject header)))
3543 (mail-header-subject header))
3544 nil (cdr (assq article gnus-newsgroup-scored))
3545 (memq article gnus-newsgroup-processable))
3547 (gnus-data-update-list
3548 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3550 (defun gnus-summary-update-article (article &optional iheader)
3551 "Update ARTICLE in the summary buffer."
3552 (set-buffer gnus-summary-buffer)
3553 (let* ((header (gnus-summary-article-header article))
3554 (id (mail-header-id header))
3555 (data (gnus-data-find article))
3556 (thread (gnus-id-to-thread id))
3557 (references (mail-header-references header))
3561 (when (and references
3562 (not (equal "" references)))
3565 (buffer-read-only nil)
3571 (delq thread parent)))
3572 (if (gnus-summary-insert-subject id header)
3573 ;; Set the (possibly) new article number in the data structure.
3574 (gnus-data-set-number data (gnus-id-to-article id))
3578 (defun gnus-rebuild-thread (id &optional line)
3579 "Rebuild the thread containing ID.
3580 If LINE, insert the rebuilt thread starting on line LINE."
3581 (let ((buffer-read-only nil)
3582 old-pos current thread data)
3583 (if (not gnus-show-threads)
3584 (setq thread (list (car (gnus-id-to-thread id))))
3585 ;; Get the thread this article is part of.
3586 (setq thread (gnus-remove-thread id)))
3587 (setq old-pos (gnus-point-at-bol))
3588 (setq current (save-excursion
3589 (and (zerop (forward-line -1))
3590 (gnus-summary-article-number))))
3591 ;; If this is a gathered thread, we have to go some re-gathering.
3592 (when (stringp (car thread))
3593 (let ((subject (car thread))
3595 (setq thread (cdr thread))
3597 (unless (memq (setq thr (gnus-id-to-thread
3599 (mail-header-id (caar thread)))))
3602 (setq thread (cdr thread)))
3603 ;; We now have all (unique) roots.
3604 (if (= (length roots) 1)
3605 ;; All the loose roots are now one solid root.
3606 (setq thread (car roots))
3607 (setq thread (cons subject (gnus-sort-threads roots))))))
3609 ;; We then insert this thread into the summary buffer.
3611 (goto-char (point-min))
3612 (forward-line (1- line)))
3613 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3614 (if gnus-show-threads
3615 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3616 (gnus-summary-prepare-unthreaded thread))
3617 (setq data (nreverse gnus-newsgroup-data))
3618 (setq threads gnus-newsgroup-threads))
3619 ;; We splice the new data into the data structure.
3620 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3621 ;;!!! then we want to insert at the beginning of the buffer.
3622 ;;!!! That happens to be true with Gnus now, but that may
3623 ;;!!! change in the future. Perhaps.
3624 (gnus-data-enter-list
3625 (if line nil current) data (- (point) old-pos))
3626 (setq gnus-newsgroup-threads
3627 (nconc threads gnus-newsgroup-threads))
3628 (gnus-data-compute-positions))))
3630 (defun gnus-number-to-header (number)
3631 "Return the header for article NUMBER."
3632 (let ((headers gnus-newsgroup-headers))
3634 (not (= number (mail-header-number (car headers)))))
3639 (defun gnus-parent-headers (in-headers &optional generation)
3640 "Return the headers of the GENERATIONeth parent of HEADERS."
3642 (setq generation 1))
3644 (headers in-headers)
3647 (not (zerop generation))
3648 (setq references (mail-header-references headers)))
3649 (setq headers (if (and references
3650 (setq parent (gnus-parent-id references)))
3651 (car (gnus-id-to-thread parent))
3654 (and (not (eq headers in-headers))
3657 (defun gnus-id-to-thread (id)
3658 "Return the (sub-)thread where ID appears."
3659 (gnus-gethash id gnus-newsgroup-dependencies))
3661 (defun gnus-id-to-article (id)
3662 "Return the article number of ID."
3663 (let ((thread (gnus-id-to-thread id)))
3666 (mail-header-number (car thread)))))
3668 (defun gnus-id-to-header (id)
3669 "Return the article headers of ID."
3670 (car (gnus-id-to-thread id)))
3672 (defun gnus-article-displayed-root-p (article)
3673 "Say whether ARTICLE is a root(ish) article."
3674 (let ((level (gnus-summary-thread-level article))
3675 (refs (mail-header-references (gnus-summary-article-header article)))
3681 ((null (gnus-parent-id refs)) t)
3683 (null (setq particle (gnus-id-to-article
3684 (gnus-parent-id refs))))
3685 (null (gnus-summary-thread-level particle)))))))
3687 (defun gnus-root-id (id)
3688 "Return the id of the root of the thread where ID appears."
3690 (while (and id (setq prev (car (gnus-id-to-thread id))))
3692 id (gnus-parent-id (mail-header-references prev))))
3695 (defun gnus-articles-in-thread (thread)
3696 "Return the list of articles in THREAD."
3697 (cons (mail-header-number (car thread))
3698 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3700 (defun gnus-remove-thread (id &optional dont-remove)
3701 "Remove the thread that has ID in it."
3702 (let (headers thread last-id)
3703 ;; First go up in this thread until we find the root.
3704 (setq last-id (gnus-root-id id)
3705 headers (message-flatten-list (gnus-id-to-thread last-id)))
3706 ;; We have now found the real root of this thread. It might have
3707 ;; been gathered into some loose thread, so we have to search
3708 ;; through the threads to find the thread we wanted.
3709 (let ((threads gnus-newsgroup-threads)
3712 (setq sub (car threads))
3713 (if (stringp (car sub))
3714 ;; This is a gathered thread, so we look at the roots
3715 ;; below it to find whether this article is in this
3718 (setq sub (cdr sub))
3720 (when (member (caar sub) headers)
3721 (setq thread (car threads)
3724 (setq sub (cdr sub))))
3725 ;; It's an ordinary thread, so we check it.
3726 (when (eq (car sub) (car headers))
3729 (setq threads (cdr threads)))
3730 ;; If this article is in no thread, then it's a root.
3733 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3734 (setq thread (gnus-id-to-thread last-id)))
3737 thread ; We return this thread.
3739 (if (stringp (car thread))
3741 ;; If we use dummy roots, then we have to remove the
3742 ;; dummy root as well.
3743 (when (eq gnus-summary-make-false-root 'dummy)
3744 ;; We go to the dummy root by going to
3745 ;; the first sub-"thread", and then one line up.
3746 (gnus-summary-goto-article
3747 (mail-header-number (caadr thread)))
3750 (gnus-data-compute-positions))
3751 (setq thread (cdr thread))
3753 (gnus-remove-thread-1 (car thread))
3754 (setq thread (cdr thread))))
3755 (gnus-remove-thread-1 thread))))))))
3757 (defun gnus-remove-thread-1 (thread)
3758 "Remove the thread THREAD recursively."
3759 (let ((number (mail-header-number (pop thread)))
3761 (setq thread (reverse thread))
3763 (gnus-remove-thread-1 (pop thread)))
3764 (when (setq d (gnus-data-find number))
3765 (goto-char (gnus-data-pos d))
3766 (gnus-summary-show-thread)
3769 (- (gnus-point-at-bol)
3771 (1+ (gnus-point-at-eol))
3772 (gnus-delete-line)))))))
3774 (defun gnus-sort-threads-1 (threads func)
3775 (sort (mapcar (lambda (thread)
3778 (gnus-sort-threads-1 (cdr thread) func))))
3781 (defun gnus-sort-threads (threads)
3783 (if (not gnus-thread-sort-functions)
3785 (gnus-message 8 "Sorting threads...")
3787 (gnus-sort-threads-1
3789 (gnus-make-sort-function gnus-thread-sort-functions))
3790 (gnus-message 8 "Sorting threads...done"))))
3792 (defun gnus-sort-articles (articles)
3794 (when gnus-article-sort-functions
3795 (gnus-message 7 "Sorting articles...")
3797 (setq gnus-newsgroup-headers
3798 (sort articles (gnus-make-sort-function
3799 gnus-article-sort-functions)))
3800 (gnus-message 7 "Sorting articles...done"))))
3802 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3803 (defmacro gnus-thread-header (thread)
3804 "Return header of first article in THREAD.
3805 Note that THREAD must never, ever be anything else than a variable -
3806 using some other form will lead to serious barfage."
3807 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3808 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3809 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3812 (defsubst gnus-article-sort-by-number (h1 h2)
3813 "Sort articles by article number."
3814 (< (mail-header-number h1)
3815 (mail-header-number h2)))
3817 (defun gnus-thread-sort-by-number (h1 h2)
3818 "Sort threads by root article number."
3819 (gnus-article-sort-by-number
3820 (gnus-thread-header h1) (gnus-thread-header h2)))
3822 (defsubst gnus-article-sort-by-lines (h1 h2)
3823 "Sort articles by article Lines header."
3824 (< (mail-header-lines h1)
3825 (mail-header-lines h2)))
3827 (defun gnus-thread-sort-by-lines (h1 h2)
3828 "Sort threads by root article Lines header."
3829 (gnus-article-sort-by-lines
3830 (gnus-thread-header h1) (gnus-thread-header h2)))
3832 (defsubst gnus-article-sort-by-chars (h1 h2)
3833 "Sort articles by octet length."
3834 (< (mail-header-chars h1)
3835 (mail-header-chars h2)))
3837 (defun gnus-thread-sort-by-chars (h1 h2)
3838 "Sort threads by root article octet length."
3839 (gnus-article-sort-by-chars
3840 (gnus-thread-header h1) (gnus-thread-header h2)))
3842 (defsubst gnus-article-sort-by-author (h1 h2)
3843 "Sort articles by root author."
3845 (let ((extract (funcall
3846 gnus-extract-address-components
3847 (mail-header-from h1))))
3848 (or (car extract) (cadr extract) ""))
3849 (let ((extract (funcall
3850 gnus-extract-address-components
3851 (mail-header-from h2))))
3852 (or (car extract) (cadr extract) ""))))
3854 (defun gnus-thread-sort-by-author (h1 h2)
3855 "Sort threads by root author."
3856 (gnus-article-sort-by-author
3857 (gnus-thread-header h1) (gnus-thread-header h2)))
3859 (defsubst gnus-article-sort-by-subject (h1 h2)
3860 "Sort articles by root subject."
3862 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3863 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3865 (defun gnus-thread-sort-by-subject (h1 h2)
3866 "Sort threads by root subject."
3867 (gnus-article-sort-by-subject
3868 (gnus-thread-header h1) (gnus-thread-header h2)))
3870 (defsubst gnus-article-sort-by-date (h1 h2)
3871 "Sort articles by root article date."
3873 (gnus-date-get-time (mail-header-date h1))
3874 (gnus-date-get-time (mail-header-date h2))))
3876 (defun gnus-thread-sort-by-date (h1 h2)
3877 "Sort threads by root article date."
3878 (gnus-article-sort-by-date
3879 (gnus-thread-header h1) (gnus-thread-header h2)))
3881 (defsubst gnus-article-sort-by-score (h1 h2)
3882 "Sort articles by root article score.
3883 Unscored articles will be counted as having a score of zero."
3884 (> (or (cdr (assq (mail-header-number h1)
3885 gnus-newsgroup-scored))
3886 gnus-summary-default-score 0)
3887 (or (cdr (assq (mail-header-number h2)
3888 gnus-newsgroup-scored))
3889 gnus-summary-default-score 0)))
3891 (defun gnus-thread-sort-by-score (h1 h2)
3892 "Sort threads by root article score."
3893 (gnus-article-sort-by-score
3894 (gnus-thread-header h1) (gnus-thread-header h2)))
3896 (defun gnus-thread-sort-by-total-score (h1 h2)
3897 "Sort threads by the sum of all scores in the thread.
3898 Unscored articles will be counted as having a score of zero."
3899 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3901 (defun gnus-thread-total-score (thread)
3902 ;; This function find the total score of THREAD.
3903 (cond ((null thread)
3906 (if (stringp (car thread))
3907 (apply gnus-thread-score-function 0
3908 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3909 (gnus-thread-total-score-1 thread)))
3911 (gnus-thread-total-score-1 (list thread)))))
3913 (defun gnus-thread-total-score-1 (root)
3914 ;; This function find the total score of the thread below ROOT.
3915 (setq root (car root))
3916 (apply gnus-thread-score-function
3918 (mapcar 'gnus-thread-total-score
3919 (cdr (gnus-id-to-thread (mail-header-id root))))
3920 (when (> (mail-header-number root) 0)
3921 (list (or (cdr (assq (mail-header-number root)
3922 gnus-newsgroup-scored))
3923 gnus-summary-default-score 0))))
3924 (list gnus-summary-default-score)
3927 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3928 (defvar gnus-tmp-prev-subject nil)
3929 (defvar gnus-tmp-false-parent nil)
3930 (defvar gnus-tmp-root-expunged nil)
3931 (defvar gnus-tmp-dummy-line nil)
3933 (eval-when-compile (defvar gnus-tmp-header))
3934 (defun gnus-extra-header (type &optional header)
3935 "Return the extra header of TYPE."
3936 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3939 (defun gnus-summary-prepare-threads (threads)
3940 "Prepare summary buffer from THREADS and indentation LEVEL.
3941 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3942 or a straight list of headers."
3943 (gnus-message 7 "Generating summary...")
3945 (setq gnus-newsgroup-threads threads)
3948 (let ((gnus-tmp-level 0)
3949 (default-score (or gnus-summary-default-score 0))
3950 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3951 thread number subject stack state gnus-tmp-gathered beg-match
3952 new-roots gnus-tmp-new-adopts thread-end
3953 gnus-tmp-header gnus-tmp-unread
3954 gnus-tmp-replied gnus-tmp-subject-or-nil
3955 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3956 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3957 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3959 (setq gnus-tmp-prev-subject nil)
3961 (if (vectorp (car threads))
3962 ;; If this is a straight (sic) list of headers, then a
3963 ;; threaded summary display isn't required, so we just create
3964 ;; an unthreaded one.
3965 (gnus-summary-prepare-unthreaded threads)
3967 ;; Do the threaded display.
3969 (while (or threads stack gnus-tmp-new-adopts new-roots)
3971 (if (and (= gnus-tmp-level 0)
3974 (not gnus-tmp-false-parent)
3975 (or gnus-tmp-new-adopts new-roots))
3976 (if gnus-tmp-new-adopts
3977 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3978 thread (list (car gnus-tmp-new-adopts))
3979 gnus-tmp-header (caar thread)
3980 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3982 (setq thread (list (car new-roots))
3983 gnus-tmp-header (caar thread)
3984 new-roots (cdr new-roots))))
3987 ;; If there are some threads, we do them before the
3988 ;; threads on the stack.
3989 (setq thread threads
3990 gnus-tmp-header (caar thread))
3991 ;; There were no current threads, so we pop something off
3993 (setq state (car stack)
3994 gnus-tmp-level (car state)
3997 gnus-tmp-header (caar thread))))
3999 (setq gnus-tmp-false-parent nil)
4000 (setq gnus-tmp-root-expunged nil)
4001 (setq thread-end nil)
4003 (if (stringp gnus-tmp-header)
4004 ;; The header is a dummy root.
4006 ((eq gnus-summary-make-false-root 'adopt)
4007 ;; We let the first article adopt the rest.
4008 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4010 (setq gnus-tmp-gathered
4012 (lambda (h) (mail-header-number (car h)))
4015 (setq thread (cons (list (caar thread)
4018 (setq gnus-tmp-level -1
4019 gnus-tmp-false-parent t))
4020 ((eq gnus-summary-make-false-root 'empty)
4021 ;; We print adopted articles with empty subject fields.
4022 (setq gnus-tmp-gathered
4024 (lambda (h) (mail-header-number (car h)))
4027 (setq gnus-tmp-level -1))
4028 ((eq gnus-summary-make-false-root 'dummy)
4029 ;; We remember that we probably want to output a dummy
4031 (setq gnus-tmp-dummy-line gnus-tmp-header)
4032 (setq gnus-tmp-prev-subject gnus-tmp-header))
4034 ;; We do not make a root for the gathered
4035 ;; sub-threads at all.
4036 (setq gnus-tmp-level -1)))
4038 (setq number (mail-header-number gnus-tmp-header)
4039 subject (mail-header-subject gnus-tmp-header))
4042 ;; If the thread has changed subject, we might want to make
4043 ;; this subthread into a root.
4044 ((and (null gnus-thread-ignore-subject)
4045 (not (zerop gnus-tmp-level))
4046 gnus-tmp-prev-subject
4048 (gnus-subject-equal gnus-tmp-prev-subject subject))))
4049 (setq new-roots (nconc new-roots (list (car thread)))
4051 gnus-tmp-header nil))
4052 ;; If the article lies outside the current limit,
4053 ;; then we do not display it.
4054 ((not (memq number gnus-newsgroup-limit))
4055 (setq gnus-tmp-gathered
4057 (lambda (h) (mail-header-number (car h)))
4060 (setq gnus-tmp-new-adopts (if (cdar thread)
4061 (append gnus-tmp-new-adopts
4063 gnus-tmp-new-adopts)
4065 gnus-tmp-header nil)
4066 (when (zerop gnus-tmp-level)
4067 (setq gnus-tmp-root-expunged t)))
4068 ;; Perhaps this article is to be marked as read?
4069 ((and gnus-summary-mark-below
4070 (< (or (cdr (assq number gnus-newsgroup-scored))
4072 gnus-summary-mark-below)
4073 ;; Don't touch sparse articles.
4074 (not (gnus-summary-article-sparse-p number))
4075 (not (gnus-summary-article-ancient-p number)))
4076 (setq gnus-newsgroup-unreads
4077 (delq number gnus-newsgroup-unreads))
4078 (if gnus-newsgroup-auto-expire
4079 (push number gnus-newsgroup-expirable)
4080 (push (cons number gnus-low-score-mark)
4081 gnus-newsgroup-reads))))
4083 (when gnus-tmp-header
4084 ;; We may have an old dummy line to output before this
4086 (when (and gnus-tmp-dummy-line
4089 (mail-header-subject gnus-tmp-header)))
4090 (gnus-summary-insert-dummy-line
4091 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4092 (setq gnus-tmp-dummy-line nil))
4094 ;; Compute the mark.
4095 (setq gnus-tmp-unread (gnus-article-mark number))
4097 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4098 gnus-tmp-header gnus-tmp-level)
4099 gnus-newsgroup-data)
4101 ;; Actually insert the line.
4103 gnus-tmp-subject-or-nil
4105 ((and gnus-thread-ignore-subject
4106 gnus-tmp-prev-subject
4107 (not (inline (gnus-subject-equal
4108 gnus-tmp-prev-subject subject))))
4110 ((zerop gnus-tmp-level)
4111 (if (and (eq gnus-summary-make-false-root 'empty)
4112 (memq number gnus-tmp-gathered)
4113 gnus-tmp-prev-subject
4114 (inline (gnus-subject-equal
4115 gnus-tmp-prev-subject subject)))
4116 gnus-summary-same-subject
4118 (t gnus-summary-same-subject)))
4119 (if (and (eq gnus-summary-make-false-root 'adopt)
4120 (= gnus-tmp-level 1)
4121 (memq number gnus-tmp-gathered))
4122 (setq gnus-tmp-opening-bracket ?\<
4123 gnus-tmp-closing-bracket ?\>)
4124 (setq gnus-tmp-opening-bracket ?\[
4125 gnus-tmp-closing-bracket ?\]))
4127 gnus-tmp-indentation
4128 (aref gnus-thread-indent-array gnus-tmp-level)
4129 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4130 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4131 gnus-summary-default-score 0)
4133 (if (or (null gnus-summary-default-score)
4134 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4135 gnus-summary-zcore-fuzz))
4137 (if (< gnus-tmp-score gnus-summary-default-score)
4138 gnus-score-below-mark gnus-score-over-mark))
4140 (cond ((memq number gnus-newsgroup-processable)
4142 ((memq number gnus-newsgroup-cached)
4144 ((memq number gnus-newsgroup-replied)
4146 ((memq number gnus-newsgroup-saved)
4148 (t gnus-unread-mark))
4149 gnus-tmp-from (mail-header-from gnus-tmp-header)
4152 ((string-match "<[^>]+> *$" gnus-tmp-from)
4153 (setq beg-match (match-beginning 0))
4154 (or (and (string-match "^\".+\"" gnus-tmp-from)
4155 (substring gnus-tmp-from 1 (1- (match-end 0))))
4156 (substring gnus-tmp-from 0 beg-match)))
4157 ((string-match "(.+)" gnus-tmp-from)
4158 (substring gnus-tmp-from
4159 (1+ (match-beginning 0)) (1- (match-end 0))))
4161 (when (string= gnus-tmp-name "")
4162 (setq gnus-tmp-name gnus-tmp-from))
4163 (unless (numberp gnus-tmp-lines)
4164 (setq gnus-tmp-lines 0))
4165 (gnus-put-text-property
4167 (progn (eval gnus-summary-line-format-spec) (point))
4168 'gnus-number number)
4171 (gnus-run-hooks 'gnus-summary-update-hook)
4174 (setq gnus-tmp-prev-subject subject)))
4176 (when (nth 1 thread)
4177 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4178 (incf gnus-tmp-level)
4179 (setq threads (if thread-end nil (cdar thread)))
4181 (setq gnus-tmp-level 0)))))
4182 (gnus-message 7 "Generating summary...done"))
4184 (defun gnus-summary-prepare-unthreaded (headers)
4185 "Generate an unthreaded summary buffer based on HEADERS."
4186 (let (header number mark)
4191 ;; We may have to root out some bad articles...
4192 (when (memq (setq number (mail-header-number
4193 (setq header (pop headers))))
4194 gnus-newsgroup-limit)
4195 ;; Mark article as read when it has a low score.
4196 (when (and gnus-summary-mark-below
4197 (< (or (cdr (assq number gnus-newsgroup-scored))
4198 gnus-summary-default-score 0)
4199 gnus-summary-mark-below)
4200 (not (gnus-summary-article-ancient-p number)))
4201 (setq gnus-newsgroup-unreads
4202 (delq number gnus-newsgroup-unreads))
4203 (if gnus-newsgroup-auto-expire
4204 (push number gnus-newsgroup-expirable)
4205 (push (cons number gnus-low-score-mark)
4206 gnus-newsgroup-reads)))
4208 (setq mark (gnus-article-mark number))
4209 (push (gnus-data-make number mark (1+ (point)) header 0)
4210 gnus-newsgroup-data)
4211 (gnus-summary-insert-line
4213 mark (memq number gnus-newsgroup-replied)
4214 (memq number gnus-newsgroup-expirable)
4215 (mail-header-subject header) nil
4216 (cdr (assq number gnus-newsgroup-scored))
4217 (memq number gnus-newsgroup-processable))))))
4219 (defun gnus-summary-remove-list-identifiers ()
4220 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4221 (let ((regexp (if (stringp gnus-list-identifiers)
4222 gnus-list-identifiers
4223 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4224 (dolist (header gnus-newsgroup-headers)
4225 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4226 " *\\)\\)+\\(Re: +\\)?\\)")
4227 (mail-header-subject header))
4228 (mail-header-set-subject
4229 header (concat (substring (mail-header-subject header)
4230 0 (match-beginning 1))
4232 (match-string 3 (mail-header-subject header))
4233 (match-string 5 (mail-header-subject header)))
4234 (substring (mail-header-subject header)
4235 (match-end 1))))))))
4237 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4238 "Select newsgroup GROUP.
4239 If READ-ALL is non-nil, all articles in the group are selected.
4240 If SELECT-ARTICLES, only select those articles from GROUP."
4241 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4242 ;;!!! Dirty hack; should be removed.
4243 (gnus-summary-ignore-duplicates
4244 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4246 gnus-summary-ignore-duplicates))
4247 (info (nth 2 entry))
4248 articles fetched-articles cached)
4250 (unless (gnus-check-server
4251 (setq gnus-current-select-method
4252 (gnus-find-method-for-group group)))
4253 (error "Couldn't open server"))
4255 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4256 (gnus-activate-group group) ; Or we can activate it...
4257 (progn ; Or we bug out.
4258 (when (equal major-mode 'gnus-summary-mode)
4259 (kill-buffer (current-buffer)))
4260 (error "Couldn't activate group %s: %s"
4261 group (gnus-status-message group))))
4263 (unless (gnus-request-group group t)
4264 (when (equal major-mode 'gnus-summary-mode)
4265 (kill-buffer (current-buffer)))
4266 (error "Couldn't request group %s: %s"
4267 group (gnus-status-message group)))
4269 (setq gnus-newsgroup-name group)
4270 (setq gnus-newsgroup-unselected nil)
4271 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4272 (gnus-summary-setup-default-charset)
4274 ;; Adjust and set lists of article marks.
4276 (gnus-adjust-marked-articles info))
4278 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4279 (when (gnus-virtual-group-p group)
4280 (setq cached gnus-newsgroup-cached))
4282 (setq gnus-newsgroup-unreads
4283 (gnus-set-difference
4284 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4285 gnus-newsgroup-dormant))
4287 (setq gnus-newsgroup-processable nil)
4289 (gnus-update-read-articles group gnus-newsgroup-unreads)
4291 (if (setq articles select-articles)
4292 (setq gnus-newsgroup-unselected
4293 (gnus-sorted-intersection
4294 gnus-newsgroup-unreads
4295 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4296 (setq articles (gnus-articles-to-read group read-all)))
4300 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4302 ((eq articles 0) nil)
4304 ;; Init the dependencies hash table.
4305 (setq gnus-newsgroup-dependencies
4306 (gnus-make-hashtable (length articles)))
4307 (gnus-set-global-variables)
4308 ;; Retrieve the headers and read them in.
4309 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4310 (setq gnus-newsgroup-headers
4312 (setq gnus-headers-retrieved-by
4313 (gnus-retrieve-headers
4314 articles gnus-newsgroup-name
4315 ;; We might want to fetch old headers, but
4316 ;; not if there is only 1 article.
4318 (not (eq gnus-fetch-old-headers 'some))
4319 (not (numberp gnus-fetch-old-headers)))
4320 (> (length articles) 1))
4321 gnus-fetch-old-headers))))
4322 (gnus-get-newsgroup-headers-xover
4323 articles nil nil gnus-newsgroup-name t)
4324 (gnus-get-newsgroup-headers)))
4325 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4327 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4329 (setq gnus-newsgroup-cached cached))
4331 ;; Suppress duplicates?
4332 (when gnus-suppress-duplicates
4333 (gnus-dup-suppress-articles))
4335 ;; Set the initial limit.
4336 (setq gnus-newsgroup-limit (copy-sequence articles))
4337 ;; Remove canceled articles from the list of unread articles.
4338 (setq gnus-newsgroup-unreads
4339 (gnus-set-sorted-intersection
4340 gnus-newsgroup-unreads
4341 (setq fetched-articles
4342 (mapcar (lambda (headers) (mail-header-number headers))
4343 gnus-newsgroup-headers))))
4344 ;; Removed marked articles that do not exist.
4345 (gnus-update-missing-marks
4346 (gnus-sorted-complement fetched-articles articles))
4347 ;; We might want to build some more threads first.
4348 (when (and gnus-fetch-old-headers
4349 (eq gnus-headers-retrieved-by 'nov))
4350 (if (eq gnus-fetch-old-headers 'invisible)
4351 (gnus-build-all-threads)
4352 (gnus-build-old-threads)))
4353 ;; Let the Gnus agent mark articles as read.
4355 (gnus-agent-get-undownloaded-list))
4356 ;; Remove list identifiers from subject
4357 (when gnus-list-identifiers
4358 (gnus-summary-remove-list-identifiers))
4359 ;; Check whether auto-expire is to be done in this group.
4360 (setq gnus-newsgroup-auto-expire
4361 (gnus-group-auto-expirable-p group))
4362 ;; Set up the article buffer now, if necessary.
4363 (unless gnus-single-article-buffer
4364 (gnus-article-setup-buffer))
4365 ;; First and last article in this newsgroup.
4366 (when gnus-newsgroup-headers
4367 (setq gnus-newsgroup-begin
4368 (mail-header-number (car gnus-newsgroup-headers))
4371 (gnus-last-element gnus-newsgroup-headers))))
4372 ;; GROUP is successfully selected.
4373 (or gnus-newsgroup-headers t)))))
4375 (defun gnus-articles-to-read (group &optional read-all)
4376 "Find out what articles the user wants to read."
4378 ;; Select all articles if `read-all' is non-nil, or if there
4379 ;; are no unread articles.
4381 (and (zerop (length gnus-newsgroup-marked))
4382 (zerop (length gnus-newsgroup-unreads)))
4383 (eq (gnus-group-find-parameter group 'display)
4386 (gnus-uncompress-range (gnus-active group))
4387 (gnus-cache-articles-in-group group))
4388 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4389 (copy-sequence gnus-newsgroup-unreads))
4391 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4392 (scored (length scored-list))
4393 (number (length articles))
4394 (marked (+ (length gnus-newsgroup-marked)
4395 (length gnus-newsgroup-dormant)))
4403 ((and (or (<= scored marked) (= scored number))
4404 (numberp gnus-large-newsgroup)
4405 (> number gnus-large-newsgroup))
4409 "How many articles from %s (default %d): "
4410 (gnus-limit-string gnus-newsgroup-name 35)
4412 (if (string-match "^[ \t]*$" input) number input)))
4413 ((and (> scored marked) (< scored number)
4414 (> (- scored number) 20))
4417 (format "%s %s (%d scored, %d total): "
4418 "How many articles from"
4419 group scored number))))
4420 (if (string-match "^[ \t]*$" input)
4424 (message "Quit getting the articles to read")
4426 (setq select (if (stringp select) (string-to-number select) select))
4427 (if (or (null select) (zerop select))
4429 (if (and (not (zerop scored)) (<= (abs select) scored))
4431 (setq articles (sort scored-list '<))
4432 (setq number (length articles)))
4433 (setq articles (copy-sequence articles)))
4435 (when (< (abs select) number)
4437 ;; Select the N oldest articles.
4438 (setcdr (nthcdr (1- (abs select)) articles) nil)
4439 ;; Select the N most recent articles.
4440 (setq articles (nthcdr (- number select) articles))))
4441 (setq gnus-newsgroup-unselected
4442 (gnus-sorted-intersection
4443 gnus-newsgroup-unreads
4444 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4445 (when gnus-alter-articles-to-read-function
4446 (setq gnus-newsgroup-unreads
4448 (funcall gnus-alter-articles-to-read-function
4449 gnus-newsgroup-name gnus-newsgroup-unreads)
4453 (defun gnus-killed-articles (killed articles)
4456 (when (inline (gnus-member-of-range (car articles) killed))
4457 (push (car articles) out))
4458 (setq articles (cdr articles)))
4461 (defun gnus-uncompress-marks (marks)
4462 "Uncompress the mark ranges in MARKS."
4463 (let ((uncompressed '(score bookmark))
4466 (if (memq (caar marks) uncompressed)
4467 (push (car marks) out)
4468 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4469 (setq marks (cdr marks)))
4472 (defun gnus-adjust-marked-articles (info)
4473 "Set all article lists and remove all marks that are no longer valid."
4474 (let* ((marked-lists (gnus-info-marks info))
4475 (active (gnus-active (gnus-info-group info)))
4478 (types gnus-article-mark-lists)
4479 (uncompressed '(score bookmark killed))
4480 marks var articles article mark)
4483 (setq marks (pop marked-lists))
4484 (set (setq var (intern (format "gnus-newsgroup-%s"
4485 (car (rassq (setq mark (car marks))
4487 (if (memq (car marks) uncompressed) (cdr marks)
4488 (gnus-uncompress-range (cdr marks))))
4490 (setq articles (symbol-value var))
4492 ;; All articles have to be subsets of the active articles.
4494 ;; Adjust "simple" lists.
4495 ((memq mark '(tick dormant expire reply save))
4497 (when (or (< (setq article (pop articles)) min) (> article max))
4498 (set var (delq article (symbol-value var))))))
4500 ((memq mark uncompressed)
4501 (when (not (listp (cdr (symbol-value var))))
4502 (set var (list (symbol-value var))))
4503 (when (not (listp (cdr articles)))
4504 (setq articles (list articles)))
4506 (when (or (not (consp (setq article (pop articles))))
4507 (< (car article) min)
4508 (> (car article) max))
4509 (set var (delq article (symbol-value var))))))))))
4511 (defun gnus-update-missing-marks (missing)
4512 "Go through the list of MISSING articles and remove them from the mark lists."
4514 (let ((types gnus-article-mark-lists)
4516 ;; Go through all types.
4518 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4519 (when (symbol-value var)
4520 ;; This list has articles. So we delete all missing articles
4524 (set var (delq (pop m) (symbol-value var)))))))))
4526 (defun gnus-update-marks ()
4527 "Enter the various lists of marked articles into the newsgroup info list."
4528 (let ((types gnus-article-mark-lists)
4529 (info (gnus-get-info gnus-newsgroup-name))
4530 (uncompressed '(score bookmark killed))
4531 type list newmarked symbol delta-marks)
4533 ;; Add all marks lists to the list of marks lists.
4534 (while (setq type (pop types))
4535 (setq list (symbol-value
4537 (intern (format "gnus-newsgroup-%s"
4541 ;; Get rid of the entries of the articles that have the
4543 (when (and (eq (cdr type) 'score)
4547 (prev (cons nil list))
4550 (if (or (not (consp (car arts)))
4551 (= (cdar arts) gnus-summary-default-score))
4552 (setcdr prev (cdr arts))
4554 (setq arts (cdr arts)))
4555 (setq list (cdr all)))))
4557 (unless (memq (cdr type) uncompressed)
4558 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4560 (when (gnus-check-backend-function
4561 'request-set-mark gnus-newsgroup-name)
4562 ;; propagate flags to server, with the following exceptions:
4563 ;; uncompressed:s are not proper flags (they are cons cells)
4564 ;; cache is a internal gnus flag
4565 ;; download are local to one gnus installation (well)
4566 ;; unsend are for nndraft groups only
4567 ;; xxx: generality of this? this suits nnimap anyway
4568 (unless (memq (cdr type) (append '(cache download unsend)
4570 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4571 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4572 (add (gnus-remove-from-range
4573 (gnus-copy-sequence list) old)))
4575 (push (list add 'add (list (cdr type))) delta-marks))
4577 (push (list del 'del (list (cdr type))) delta-marks)))))
4580 (push (cons (cdr type) list) newmarked)))
4583 (unless (gnus-check-group gnus-newsgroup-name)
4584 (error "Can't open server for %s" gnus-newsgroup-name))
4585 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4587 ;; Enter these new marks into the info of the group.
4589 (setcar (nthcdr 3 info) newmarked)
4590 ;; Add the marks lists to the end of the info.
4592 (setcdr (nthcdr 2 info) (list newmarked))))
4594 ;; Cut off the end of the info if there's nothing else there.
4598 (when (nthcdr (decf i) info)
4599 (setcdr (nthcdr i info) nil)))))))
4601 (defun gnus-set-mode-line (where)
4602 "Set the mode line of the article or summary buffers.
4603 If WHERE is `summary', the summary mode line format will be used."
4604 ;; Is this mode line one we keep updated?
4605 (when (and (memq where gnus-updated-mode-lines)
4607 (intern (format "gnus-%s-mode-line-format-spec" where))))
4610 ;; We evaluate this in the summary buffer since these
4611 ;; variables are buffer-local to that buffer.
4612 (set-buffer gnus-summary-buffer)
4613 ;; We bind all these variables that are used in the `eval' form
4615 (let* ((mformat (symbol-value
4617 (format "gnus-%s-mode-line-format-spec" where))))
4618 (gnus-tmp-group-name (gnus-group-name-decode
4620 (gnus-group-name-charset
4622 gnus-newsgroup-name)))
4623 (gnus-tmp-article-number (or gnus-current-article 0))
4624 (gnus-tmp-unread gnus-newsgroup-unreads)
4625 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4626 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4627 (gnus-tmp-unread-and-unselected
4628 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4629 (zerop gnus-tmp-unselected))
4631 ((zerop gnus-tmp-unselected)
4632 (format "{%d more}" gnus-tmp-unread-and-unticked))
4633 (t (format "{%d(+%d) more}"
4634 gnus-tmp-unread-and-unticked
4635 gnus-tmp-unselected))))
4637 (if (and gnus-current-headers
4638 (vectorp gnus-current-headers))
4639 (gnus-mode-string-quote
4640 (mail-header-subject gnus-current-headers))
4642 bufname-length max-len
4643 gnus-tmp-header);; passed as argument to any user-format-funcs
4644 (setq mode-string (eval mformat))
4645 (setq bufname-length (if (string-match "%b" mode-string)
4648 (if (eq where 'summary)
4650 (get-buffer gnus-article-buffer))))
4653 (setq max-len (max 4 (if gnus-mode-non-string-length
4655 gnus-mode-non-string-length
4657 (length mode-string))))
4658 ;; We might have to chop a bit of the string off...
4659 (when (> (length mode-string) max-len)
4661 (concat (truncate-string-to-width mode-string (- max-len 3))
4663 ;; Pad the mode string a bit.
4664 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4665 ;; Update the mode line.
4666 (setq mode-line-buffer-identification
4667 (gnus-mode-line-buffer-identification (list mode-string)))
4668 (set-buffer-modified-p t))))
4670 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4671 "Go through the HEADERS list and add all Xrefs to a hash table.
4672 The resulting hash table is returned, or nil if no Xrefs were found."
4673 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4674 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4675 (xref-hashtb (gnus-make-hashtable))
4676 start group entry number xrefs header)
4678 (setq header (pop headers))
4679 (when (and (setq xrefs (mail-header-xref header))
4680 (not (memq (setq number (mail-header-number header))
4683 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4684 (setq start (match-end 0))
4685 (setq group (if prefix
4686 (concat prefix (substring xrefs (match-beginning 1)
4688 (substring xrefs (match-beginning 1) (match-end 1))))
4690 (string-to-int (substring xrefs (match-beginning 2)
4692 (if (setq entry (gnus-gethash group xref-hashtb))
4693 (setcdr entry (cons number (cdr entry)))
4694 (gnus-sethash group (cons number nil) xref-hashtb)))))
4695 (and start xref-hashtb)))
4697 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4698 "Look through all the headers and mark the Xrefs as read."
4699 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4700 name entry info xref-hashtb idlist method nth4)
4702 (set-buffer gnus-group-buffer)
4703 (when (setq xref-hashtb
4704 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4707 (unless (string= from-newsgroup (setq name (symbol-name group)))
4708 (setq idlist (symbol-value group))
4709 ;; Dead groups are not updated.
4711 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4713 (when (stringp (setq nth4 (gnus-info-method info)))
4714 (setq nth4 (gnus-server-to-method nth4))))
4715 ;; Only do the xrefs if the group has the same
4716 ;; select method as the group we have just read.
4717 (or (gnus-methods-equal-p
4718 nth4 (gnus-find-method-for-group from-newsgroup))
4720 (equal nth4 (setq method (gnus-find-method-for-group
4722 (and (equal (car nth4) (car method))
4723 (equal (nth 1 nth4) (nth 1 method))))
4724 gnus-use-cross-reference
4725 (or (not (eq gnus-use-cross-reference t))
4727 ;; Only do cross-references on subscribed
4728 ;; groups, if that is what is wanted.
4729 (<= (gnus-info-level info) gnus-level-subscribed))
4730 (gnus-group-make-articles-read name idlist))))
4733 (defun gnus-compute-read-articles (group articles)
4734 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4735 (info (nth 2 entry))
4736 (active (gnus-active group))
4739 ;; First peel off all invalid article numbers.
4741 (let ((ids articles)
4743 (while (setq id (pop ids))
4744 (when (and first (> id (cdr active)))
4745 ;; We'll end up in this situation in one particular
4746 ;; obscure situation. If you re-scan a group and get
4747 ;; a new article that is cross-posted to a different
4748 ;; group that has not been re-scanned, you might get
4749 ;; crossposted article that has a higher number than
4750 ;; Gnus believes possible. So we re-activate this
4751 ;; group as well. This might mean doing the
4752 ;; crossposting thingy will *increase* the number
4753 ;; of articles in some groups. Tsk, tsk.
4754 (setq active (or (gnus-activate-group group) active)))
4755 (when (or (> id (cdr active))
4756 (< id (car active)))
4757 (setq articles (delq id articles))))))
4758 ;; If the read list is nil, we init it.
4760 (null (gnus-info-read info))
4762 (setq ninfo (cons 1 (1- (car active))))
4763 (setq ninfo (gnus-info-read info)))
4764 ;; Then we add the read articles to the range.
4766 ninfo (setq articles (sort articles '<))))))
4768 (defun gnus-group-make-articles-read (group articles)
4769 "Update the info of GROUP to say that ARTICLES are read."
4771 (entry (gnus-gethash group gnus-newsrc-hashtb))
4772 (info (nth 2 entry))
4773 (active (gnus-active group))
4776 (setq range (gnus-compute-read-articles group articles))
4778 (set-buffer gnus-group-buffer)
4781 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4782 (gnus-info-set-read ',info ',(gnus-info-read info))
4783 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4784 (gnus-group-update-group ,group t))))
4785 ;; Add the read articles to the range.
4786 (gnus-info-set-read info range)
4787 ;; Then we have to re-compute how many unread
4788 ;; articles there are in this group.
4792 (setq num (- (1+ (cdr active)) (car active))))
4793 ((not (listp (cdr range)))
4794 (setq num (- (cdr active) (- (1+ (cdr range))
4798 (if (numberp (car range))
4800 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4801 (setq range (cdr range)))
4802 (setq num (- (cdr active) num))))
4803 ;; Update the number of unread articles.
4805 ;; Update the group buffer.
4806 (gnus-group-update-group group t)))))
4808 (defvar gnus-newsgroup-none-id 0)
4810 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4811 (let ((cur nntp-server-buffer)
4814 (save-excursion (set-buffer gnus-summary-buffer)
4815 gnus-newsgroup-dependencies)))
4817 (mail-parse-charset gnus-newsgroup-charset)
4818 (mail-parse-ignored-charsets
4819 (save-excursion (condition-case nil
4820 (set-buffer gnus-summary-buffer)
4822 gnus-newsgroup-ignored-charsets)))
4824 (set-buffer nntp-server-buffer)
4825 ;; Translate all TAB characters into SPACE characters.
4826 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4827 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4828 (gnus-run-hooks 'gnus-parse-headers-hook)
4829 (let ((case-fold-search t)
4830 in-reply-to header p lines chars)
4831 (goto-char (point-min))
4832 ;; Search to the beginning of the next header. Error messages
4833 ;; do not begin with 2 or 3.
4834 (while (re-search-forward "^[23][0-9]+ " nil t)
4837 ;; This implementation of this function, with nine
4838 ;; search-forwards instead of the one re-search-forward and
4839 ;; a case (which basically was the old function) is actually
4840 ;; about twice as fast, even though it looks messier. You
4841 ;; can't have everything, I guess. Speed and elegance
4842 ;; doesn't always go hand in hand.
4851 (narrow-to-region (point)
4852 (or (and (search-forward "\n.\n" nil t)
4858 (if (search-forward "\nsubject: " nil t)
4859 (funcall gnus-decode-encoded-word-function
4860 (nnheader-header-value))
4865 (if (or (search-forward "\nfrom: " nil t)
4866 (search-forward "\nfrom:" nil t))
4867 (funcall gnus-decode-encoded-word-function
4868 (nnheader-header-value))
4873 (if (search-forward "\ndate: " nil t)
4874 (nnheader-header-value) ""))
4878 (setq id (if (re-search-forward
4879 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4880 ;; We do it this way to make sure the Message-ID
4881 ;; is (somewhat) syntactically valid.
4882 (buffer-substring (match-beginning 1)
4884 ;; If there was no message-id, we just fake one
4885 ;; to make subsequent routines simpler.
4886 (nnheader-generate-fake-message-id))))
4890 (if (search-forward "\nreferences: " nil t)
4894 (nnheader-header-value)
4899 (search-backward ">" end t)
4902 (search-backward "<" end t)
4904 ;; Get the references from the in-reply-to header if there
4905 ;; were no references and the in-reply-to header looks
4907 (if (and (search-forward "\nin-reply-to: " nil t)
4908 (setq in-reply-to (nnheader-header-value))
4909 (string-match "<[^>]+>" in-reply-to))
4911 (setq ref (substring in-reply-to (match-beginning 0)
4913 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4914 (setq ref2 (substring in-reply-to (match-beginning 0)
4916 (when (> (length ref2) (length ref))
4923 (if (search-forward "\nchars: " nil t)
4924 (if (numberp (setq chars (ignore-errors (read cur))))
4930 (if (search-forward "\nlines: " nil t)
4931 (if (numberp (setq lines (ignore-errors (read cur))))
4937 (and (search-forward "\nxref: " nil t)
4938 (nnheader-header-value)))
4940 (when gnus-extra-headers
4941 (let ((extra gnus-extra-headers)
4945 (when (search-forward
4946 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4947 (push (cons (car extra) (nnheader-header-value))
4951 (when (equal id ref)
4954 (when gnus-alter-header-function
4955 (funcall gnus-alter-header-function header)
4956 (setq id (mail-header-id header)
4957 ref (gnus-parent-id (mail-header-references header))))
4960 (gnus-dependencies-add-header
4961 header dependencies force-new))
4962 (push header headers))
4963 (goto-char (point-max))
4965 (nreverse headers)))))
4967 ;; Goes through the xover lines and returns a list of vectors
4968 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4969 force-new dependencies
4970 group also-fetch-heads)
4971 "Parse the news overview data in the server buffer.
4972 Return a list of headers that match SEQUENCE (see
4973 `nntp-retrieve-headers')."
4974 ;; Get the Xref when the users reads the articles since most/some
4975 ;; NNTP servers do not include Xrefs when using XOVER.
4976 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4977 (let ((mail-parse-charset gnus-newsgroup-charset)
4978 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4979 (cur nntp-server-buffer)
4980 (dependencies (or dependencies gnus-newsgroup-dependencies))
4981 number headers header)
4983 (set-buffer nntp-server-buffer)
4984 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4985 ;; Allow the user to mangle the headers before parsing them.
4986 (gnus-run-hooks 'gnus-parse-headers-hook)
4987 (goto-char (point-min))
4990 (while (and sequence (not (eobp)))
4991 (setq number (read cur))
4992 (while (and sequence
4993 (< (car sequence) number))
4994 (setq sequence (cdr sequence)))
4996 (eq number (car sequence))
4998 (setq sequence (cdr sequence))
4999 (setq header (inline
5000 (gnus-nov-parse-line
5001 number dependencies force-new))))
5002 (push header headers))
5005 (gnus-error 4 "Strange nov line (%d)"
5006 (count-lines (point-min) (point)))))
5008 ;; A common bug in inn is that if you have posted an article and
5009 ;; then retrieves the active file, it will answer correctly --
5010 ;; the new article is included. However, a NOV entry for the
5011 ;; article may not have been generated yet, so this may fail.
5012 ;; We work around this problem by retrieving the last few
5013 ;; headers using HEAD.
5014 (if (or (not also-fetch-heads)
5016 ;; We (probably) got all the headers.
5018 (let ((gnus-nov-is-evil t))
5021 (when (gnus-retrieve-headers sequence group)
5022 (gnus-get-newsgroup-headers))))))))
5024 (defun gnus-article-get-xrefs ()
5025 "Fill in the Xref value in `gnus-current-headers', if necessary.
5026 This is meant to be called in `gnus-article-internal-prepare-hook'."
5027 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5028 gnus-current-headers)))
5029 (or (not gnus-use-cross-reference)
5031 (and (mail-header-xref headers)
5032 (not (string= (mail-header-xref headers) "")))
5033 (let ((case-fold-search t)
5036 (nnheader-narrow-to-headers)
5037 (goto-char (point-min))
5038 (when (or (and (not (eobp))
5039 (eq (downcase (char-after)) ?x)
5040 (looking-at "Xref:"))
5041 (search-forward "\nXref:" nil t))
5042 (goto-char (1+ (match-end 0)))
5043 (setq xref (buffer-substring (point)
5044 (progn (end-of-line) (point))))
5045 (mail-header-set-xref headers xref)))))))
5047 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5048 "Find article ID and insert the summary line for that article.
5049 OLD-HEADER can either be a header or a line number to insert
5050 the subject line on."
5051 (let* ((line (and (numberp old-header) old-header))
5052 (old-header (and (vectorp old-header) old-header))
5053 (header (cond ((and old-header use-old-header)
5056 (gnus-number-to-header id))
5057 (gnus-number-to-header id))
5059 (gnus-read-header id))))
5060 (number (and (numberp id) id))
5063 ;; Rebuild the thread that this article is part of and go to the
5064 ;; article we have fetched.
5065 (when (and (not gnus-show-threads)
5068 (setq d (gnus-data-find (mail-header-number old-header))))
5069 (goto-char (gnus-data-pos d))
5072 (- (gnus-point-at-bol)
5074 (1+ (gnus-point-at-eol))
5075 (gnus-delete-line))))))
5077 (mail-header-set-number header (mail-header-number old-header)))
5078 (setq gnus-newsgroup-sparse
5079 (delq (setq number (mail-header-number header))
5080 gnus-newsgroup-sparse))
5081 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5082 (push number gnus-newsgroup-limit)
5083 (gnus-rebuild-thread (mail-header-id header) line)
5084 (gnus-summary-goto-subject number nil t))
5085 (when (and (numberp number)
5087 ;; We have to update the boundaries even if we can't fetch the
5088 ;; article if ID is a number -- so that the next `P' or `N'
5089 ;; command will fetch the previous (or next) article even
5090 ;; if the one we tried to fetch this time has been canceled.
5091 (when (> number gnus-newsgroup-end)
5092 (setq gnus-newsgroup-end number))
5093 (when (< number gnus-newsgroup-begin)
5094 (setq gnus-newsgroup-begin number))
5095 (setq gnus-newsgroup-unselected
5096 (delq number gnus-newsgroup-unselected)))
5097 ;; Report back a success?
5098 (and header (mail-header-number header))))
5100 ;;; Process/prefix in the summary buffer
5102 (defun gnus-summary-work-articles (n)
5103 "Return a list of articles to be worked upon.
5104 The prefix argument, the list of process marked articles, and the
5105 current article will be taken into consideration."
5107 (set-buffer gnus-summary-buffer)
5110 ;; A numerical prefix has been given.
5111 (setq n (prefix-numeric-value n))
5112 (let ((backward (< n 0))
5113 (n (abs (prefix-numeric-value n)))
5118 (push (setq article (gnus-summary-article-number))
5121 (gnus-summary-find-prev nil article)
5122 (gnus-summary-find-next nil article)))
5124 (nreverse articles)))
5125 ((and (gnus-region-active-p) (mark))
5126 (message "region active")
5127 ;; Work on the region between point and mark.
5128 (let ((max (max (point) (mark)))
5131 (goto-char (min (min (point) (mark))))
5134 (push (setq article (gnus-summary-article-number)) articles)
5135 (gnus-summary-find-next nil article)
5137 (nreverse articles))))
5138 (gnus-newsgroup-processable
5139 ;; There are process-marked articles present.
5140 ;; Save current state.
5141 (gnus-summary-save-process-mark)
5143 (reverse gnus-newsgroup-processable))
5145 ;; Just return the current article.
5146 (list (gnus-summary-article-number))))))
5148 (defmacro gnus-summary-iterate (arg &rest forms)
5149 "Iterate over the process/prefixed articles and do FORMS.
5150 ARG is the interactive prefix given to the command. FORMS will be
5151 executed with point over the summary line of the articles."
5152 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5153 `(let ((,articles (gnus-summary-work-articles ,arg)))
5155 (gnus-summary-goto-subject (car ,articles))
5159 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5160 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5162 (defun gnus-summary-save-process-mark ()
5163 "Push the current set of process marked articles on the stack."
5165 (push (copy-sequence gnus-newsgroup-processable)
5166 gnus-newsgroup-process-stack))
5168 (defun gnus-summary-kill-process-mark ()
5169 "Push the current set of process marked articles on the stack and unmark."
5171 (gnus-summary-save-process-mark)
5172 (gnus-summary-unmark-all-processable))
5174 (defun gnus-summary-yank-process-mark ()
5175 "Pop the last process mark state off the stack and restore it."
5177 (unless gnus-newsgroup-process-stack
5178 (error "Empty mark stack"))
5179 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5181 (defun gnus-summary-process-mark-set (set)
5182 "Make SET into the current process marked articles."
5183 (gnus-summary-unmark-all-processable)
5185 (gnus-summary-set-process-mark (pop set))))
5187 ;;; Searching and stuff
5189 (defun gnus-summary-search-group (&optional backward use-level)
5190 "Search for next unread newsgroup.
5191 If optional argument BACKWARD is non-nil, search backward instead."
5193 (set-buffer gnus-group-buffer)
5194 (when (gnus-group-search-forward
5195 backward nil (if use-level (gnus-group-group-level) nil))
5196 (gnus-group-group-name))))
5198 (defun gnus-summary-best-group (&optional exclude-group)
5199 "Find the name of the best unread group.
5200 If EXCLUDE-GROUP, do not go to this group."
5202 (set-buffer gnus-group-buffer)
5204 (gnus-group-best-unread-group exclude-group))))
5206 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5207 (if backward (gnus-summary-find-prev)
5208 (let* ((dummy (gnus-summary-article-intangible-p))
5209 (article (or article (gnus-summary-article-number)))
5210 (arts (gnus-data-find-list article))
5212 (when (and (not dummy)
5213 (or (not gnus-summary-check-current)
5215 (not (gnus-data-unread-p (car arts)))))
5216 (setq arts (cdr arts)))
5221 (when (or (and undownloaded
5222 (eq gnus-undownloaded-mark
5223 (gnus-data-mark (car arts))))
5224 (gnus-data-unread-p (car arts)))
5225 (setq result (car arts)
5227 (setq arts (cdr arts)))
5230 (goto-char (gnus-data-pos result))
5231 (gnus-data-number result)))))
5233 (defun gnus-summary-find-prev (&optional unread article)
5234 (let* ((eobp (eobp))
5235 (article (or article (gnus-summary-article-number)))
5236 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5238 (when (and (not eobp)
5239 (or (not gnus-summary-check-current)
5241 (not (gnus-data-unread-p (car arts)))))
5242 (setq arts (cdr arts)))
5247 (when (gnus-data-unread-p (car arts))
5248 (setq result (car arts)
5250 (setq arts (cdr arts)))
5253 (goto-char (gnus-data-pos result))
5254 (gnus-data-number result))))
5256 (defun gnus-summary-find-subject (subject &optional unread backward article)
5257 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5258 (article (or article (gnus-summary-article-number)))
5259 (articles (gnus-data-list backward))
5260 (arts (gnus-data-find-list article articles))
5262 (when (or (not gnus-summary-check-current)
5264 (not (gnus-data-unread-p (car arts))))
5265 (setq arts (cdr arts)))
5267 (and (or (not unread)
5268 (gnus-data-unread-p (car arts)))
5269 (vectorp (gnus-data-header (car arts)))
5271 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5272 (setq result (car arts)
5274 (setq arts (cdr arts)))
5276 (goto-char (gnus-data-pos result))
5277 (gnus-data-number result))))
5279 (defun gnus-summary-search-forward (&optional unread subject backward)
5280 "Search forward for an article.
5281 If UNREAD, look for unread articles. If SUBJECT, look for
5282 articles with that subject. If BACKWARD, search backward instead."
5283 (cond (subject (gnus-summary-find-subject subject unread backward))
5284 (backward (gnus-summary-find-prev unread))
5285 (t (gnus-summary-find-next unread))))
5287 (defun gnus-recenter (&optional n)
5288 "Center point in window and redisplay frame.
5289 Also do horizontal recentering."
5291 (when (and gnus-auto-center-summary
5292 (not (eq gnus-auto-center-summary 'vertical)))
5293 (gnus-horizontal-recenter))
5296 (defun gnus-summary-recenter ()
5297 "Center point in the summary window.
5298 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5299 displayed, no centering will be performed."
5300 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5301 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5303 (let* ((top (cond ((< (window-height) 4) 0)
5304 ((< (window-height) 7) 1)
5305 (t (if (numberp gnus-auto-center-summary)
5306 gnus-auto-center-summary
5308 (height (1- (window-height)))
5309 (bottom (save-excursion (goto-char (point-max))
5310 (forward-line (- height))
5312 (window (get-buffer-window (current-buffer))))
5313 ;; The user has to want it.
5314 (when gnus-auto-center-summary
5315 (when (get-buffer-window gnus-article-buffer)
5316 ;; Only do recentering when the article buffer is displayed,
5317 ;; Set the window start to either `bottom', which is the biggest
5318 ;; possible valid number, or the second line from the top,
5319 ;; whichever is the least.
5320 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
5321 (if (> bottom top-pos)
5322 ;; Keep the second line from the top visible
5323 (set-window-start window top-pos t)
5324 ;; Try to keep the bottom line visible; if it's partially
5325 ;; obscured, either scroll one more line to make it fully
5326 ;; visible, or revert to using TOP-POS.
5328 (goto-char (point-max))
5330 (let ((last-line-start (point)))
5332 (set-window-start window (point) t)
5333 (when (not (pos-visible-in-window-p last-line-start window))
5335 (set-window-start window (min (point) top-pos) t)))))))
5336 ;; Do horizontal recentering while we're at it.
5337 (when (and (get-buffer-window (current-buffer) t)
5338 (not (eq gnus-auto-center-summary 'vertical)))
5339 (let ((selected (selected-window)))
5340 (select-window (get-buffer-window (current-buffer) t))
5341 (gnus-summary-position-point)
5342 (gnus-horizontal-recenter)
5343 (select-window selected))))))
5345 (defun gnus-summary-jump-to-group (newsgroup)
5346 "Move point to NEWSGROUP in group mode buffer."
5347 ;; Keep update point of group mode buffer if visible.
5348 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5349 (save-window-excursion
5350 ;; Take care of tree window mode.
5351 (when (get-buffer-window gnus-group-buffer)
5352 (pop-to-buffer gnus-group-buffer))
5353 (gnus-group-jump-to-group newsgroup))
5355 ;; Take care of tree window mode.
5356 (if (get-buffer-window gnus-group-buffer)
5357 (pop-to-buffer gnus-group-buffer)
5358 (set-buffer gnus-group-buffer))
5359 (gnus-group-jump-to-group newsgroup))))
5361 ;; This function returns a list of article numbers based on the
5362 ;; difference between the ranges of read articles in this group and
5363 ;; the range of active articles.
5364 (defun gnus-list-of-unread-articles (group)
5365 (let* ((read (gnus-info-read (gnus-get-info group)))
5366 (active (or (gnus-active group) (gnus-activate-group group)))
5369 ;; If none are read, then all are unread.
5371 (setq first (car active))
5372 ;; If the range of read articles is a single range, then the
5373 ;; first unread article is the article after the last read
5374 ;; article. Sounds logical, doesn't it?
5375 (if (and (not (listp (cdr read)))
5376 (or (< (car read) (car active))
5377 (progn (setq read (list read))
5379 (setq first (max (car active) (1+ (cdr read))))
5380 ;; `read' is a list of ranges.
5381 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5384 (setq first (car active)))
5387 (while (< first nlast)
5389 (setq first (1+ first))))
5390 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5391 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5392 (setq read (cdr read)))))
5393 ;; And add the last unread articles.
5394 (while (<= first last)
5396 (setq first (1+ first)))
5397 ;; Return the list of unread articles.
5398 (delq 0 (nreverse unread))))
5400 (defun gnus-list-of-read-articles (group)
5401 "Return a list of unread, unticked and non-dormant articles."
5402 (let* ((info (gnus-get-info group))
5403 (marked (gnus-info-marks info))
5404 (active (gnus-active group)))
5406 (gnus-set-difference
5407 (gnus-sorted-complement
5408 (gnus-uncompress-range active)
5409 (gnus-list-of-unread-articles group))
5411 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5412 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5414 ;; Various summary commands
5416 (defun gnus-summary-select-article-buffer ()
5417 "Reconfigure windows to show article buffer."
5419 (if (not (gnus-buffer-live-p gnus-article-buffer))
5420 (error "There is no article buffer for this summary buffer")
5421 (gnus-configure-windows 'article)
5422 (select-window (get-buffer-window gnus-article-buffer))))
5424 (defun gnus-summary-universal-argument (arg)
5425 "Perform any operation on all articles that are process/prefixed."
5427 (let ((articles (gnus-summary-work-articles arg))
5434 (substitute-command-keys
5435 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5437 (gnus-error 1 "Undefined key")
5440 (gnus-summary-goto-subject (setq article (pop articles)))
5441 (let (gnus-newsgroup-processable)
5442 (command-execute func))
5443 (gnus-summary-remove-process-mark article)))))
5444 (gnus-summary-position-point))
5446 (defun gnus-summary-toggle-truncation (&optional arg)
5447 "Toggle truncation of summary lines.
5448 With arg, turn line truncation on iff arg is positive."
5450 (setq truncate-lines
5451 (if (null arg) (not truncate-lines)
5452 (> (prefix-numeric-value arg) 0)))
5455 (defun gnus-summary-reselect-current-group (&optional all rescan)
5456 "Exit and then reselect the current newsgroup.
5457 The prefix argument ALL means to select all articles."
5459 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5460 (error "Ephemeral groups can't be reselected"))
5461 (let ((current-subject (gnus-summary-article-number))
5462 (group gnus-newsgroup-name))
5463 (setq gnus-newsgroup-begin nil)
5465 ;; We have to adjust the point of group mode buffer because
5466 ;; point was moved to the next unread newsgroup by exiting.
5467 (gnus-summary-jump-to-group group)
5470 (gnus-group-get-new-news-this-group 1)))
5471 (gnus-group-read-group all t)
5472 (gnus-summary-goto-subject current-subject nil t)))
5474 (defun gnus-summary-rescan-group (&optional all)
5475 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5477 (gnus-summary-reselect-current-group all t))
5479 (defun gnus-summary-update-info (&optional non-destructive)
5481 (let ((group gnus-newsgroup-name))
5483 (when gnus-newsgroup-kill-headers
5484 (setq gnus-newsgroup-killed
5485 (gnus-compress-sequence
5487 (gnus-set-sorted-intersection
5488 (gnus-uncompress-range gnus-newsgroup-killed)
5489 (setq gnus-newsgroup-unselected
5490 (sort gnus-newsgroup-unselected '<)))
5491 (setq gnus-newsgroup-unreads
5492 (sort gnus-newsgroup-unreads '<)))
5494 (unless (listp (cdr gnus-newsgroup-killed))
5495 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5496 (let ((headers gnus-newsgroup-headers))
5497 ;; Set the new ranges of read articles.
5499 (set-buffer gnus-group-buffer)
5500 (gnus-undo-force-boundary))
5501 (gnus-update-read-articles
5502 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5503 ;; Set the current article marks.
5504 (let ((gnus-newsgroup-scored
5505 (if (and (not gnus-save-score)
5506 (not non-destructive))
5508 gnus-newsgroup-scored)))
5510 (gnus-update-marks)))
5511 ;; Do the cross-ref thing.
5512 (when gnus-use-cross-reference
5513 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5514 ;; Do not switch windows but change the buffer to work.
5515 (set-buffer gnus-group-buffer)
5516 (unless (gnus-ephemeral-group-p group)
5517 (gnus-group-update-group group)))))))
5519 (defun gnus-summary-save-newsrc (&optional force)
5520 "Save the current number of read/marked articles in the dribble buffer.
5521 The dribble buffer will then be saved.
5522 If FORCE (the prefix), also save the .newsrc file(s)."
5524 (gnus-summary-update-info t)
5526 (gnus-save-newsrc-file)
5527 (gnus-dribble-save)))
5529 (defun gnus-summary-exit (&optional temporary)
5530 "Exit reading current newsgroup, and then return to group selection mode.
5531 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5533 (gnus-set-global-variables)
5534 (when (gnus-buffer-live-p gnus-article-buffer)
5536 (set-buffer gnus-article-buffer)
5537 (mm-destroy-parts gnus-article-mime-handles)
5538 ;; Set it to nil for safety reason.
5539 (setq gnus-article-mime-handle-alist nil)
5540 (setq gnus-article-mime-handles nil)))
5541 (gnus-kill-save-kill-buffer)
5542 (gnus-async-halt-prefetch)
5543 (let* ((group gnus-newsgroup-name)
5544 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5547 (buf (current-buffer)))
5549 ;; Do adaptive scoring, and possibly save score files.
5550 (when gnus-newsgroup-adaptive
5551 (gnus-score-adaptive))
5552 (when gnus-use-scoring
5554 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5555 ;; If we have several article buffers, we kill them at exit.
5556 (unless gnus-single-article-buffer
5557 (gnus-kill-buffer gnus-original-article-buffer)
5558 (setq gnus-article-current nil))
5559 (when gnus-use-cache
5560 (gnus-cache-possibly-remove-articles)
5561 (gnus-cache-save-buffers))
5562 (gnus-async-prefetch-remove-group group)
5563 (when gnus-suppress-duplicates
5564 (gnus-dup-enter-articles))
5565 (when gnus-use-trees
5566 (gnus-tree-close group))
5567 (when gnus-use-cache
5568 (gnus-cache-write-active))
5569 ;; Remove entries for this group.
5570 (nnmail-purge-split-history (gnus-group-real-name group))
5571 ;; Make all changes in this group permanent.
5573 (gnus-run-hooks 'gnus-exit-group-hook)
5574 (gnus-summary-update-info))
5575 (gnus-close-group group)
5576 ;; Make sure where we were, and go to next newsgroup.
5577 (set-buffer gnus-group-buffer)
5579 (gnus-group-jump-to-group group))
5580 (gnus-run-hooks 'gnus-summary-exit-hook)
5581 (unless (or quit-config
5582 ;; If this group has disappeared from the summary
5583 ;; buffer, don't skip forwards.
5584 (not (string= group (gnus-group-group-name))))
5585 (gnus-group-next-unread-group 1))
5586 (setq group-point (point))
5589 ;; If we have several article buffers, we kill them at exit.
5590 (unless gnus-single-article-buffer
5591 (gnus-kill-buffer gnus-article-buffer)
5592 (gnus-kill-buffer gnus-original-article-buffer)
5593 (setq gnus-article-current nil))
5595 (if (not gnus-kill-summary-on-exit)
5596 (gnus-deaden-summary)
5597 ;; We set all buffer-local variables to nil. It is unclear why
5598 ;; this is needed, but if we don't, buffer-local variables are
5599 ;; not garbage-collected, it seems. This would the lead to en
5600 ;; ever-growing Emacs.
5601 (gnus-summary-clear-local-variables)
5602 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5603 (gnus-summary-clear-local-variables))
5604 (when (get-buffer gnus-article-buffer)
5605 (bury-buffer gnus-article-buffer))
5606 ;; We clear the global counterparts of the buffer-local
5607 ;; variables as well, just to be on the safe side.
5608 (set-buffer gnus-group-buffer)
5609 (gnus-summary-clear-local-variables)
5610 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5611 (gnus-summary-clear-local-variables))
5612 ;; Return to group mode buffer.
5613 (when (eq mode 'gnus-summary-mode)
5614 (gnus-kill-buffer buf)))
5615 (setq gnus-current-select-method gnus-select-method)
5616 (pop-to-buffer gnus-group-buffer)
5617 (if (not quit-config)
5619 (goto-char group-point)
5620 (gnus-configure-windows 'group 'force))
5621 (gnus-handle-ephemeral-exit quit-config))
5622 ;; Clear the current group name.
5624 (setq gnus-newsgroup-name nil)))))
5626 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5627 (defun gnus-summary-exit-no-update (&optional no-questions)
5628 "Quit reading current newsgroup without updating read article info."
5630 (let* ((group gnus-newsgroup-name)
5631 (quit-config (gnus-group-quit-config group)))
5632 (when (or no-questions
5634 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5635 (gnus-async-halt-prefetch)
5637 (delq 'gnus-summary-expire-articles
5638 (copy-sequence gnus-summary-prepare-exit-hook)))
5639 (when (gnus-buffer-live-p gnus-article-buffer)
5641 (set-buffer gnus-article-buffer)
5642 (mm-destroy-parts gnus-article-mime-handles)
5643 ;; Set it to nil for safety reason.
5644 (setq gnus-article-mime-handle-alist nil)
5645 (setq gnus-article-mime-handles nil)))
5646 ;; If we have several article buffers, we kill them at exit.
5647 (unless gnus-single-article-buffer
5648 (gnus-kill-buffer gnus-article-buffer)
5649 (gnus-kill-buffer gnus-original-article-buffer)
5650 (setq gnus-article-current nil))
5651 (if (not gnus-kill-summary-on-exit)
5652 (gnus-deaden-summary)
5653 (gnus-close-group group)
5654 (gnus-summary-clear-local-variables)
5655 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5656 (gnus-summary-clear-local-variables))
5657 (set-buffer gnus-group-buffer)
5658 (gnus-summary-clear-local-variables)
5659 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
5660 (gnus-summary-clear-local-variables))
5661 (when (get-buffer gnus-summary-buffer)
5662 (kill-buffer gnus-summary-buffer)))
5663 (unless gnus-single-article-buffer
5664 (setq gnus-article-current nil))
5665 (when gnus-use-trees
5666 (gnus-tree-close group))
5667 (gnus-async-prefetch-remove-group group)
5668 (when (get-buffer gnus-article-buffer)
5669 (bury-buffer gnus-article-buffer))
5670 ;; Return to the group buffer.
5671 (gnus-configure-windows 'group 'force)
5672 ;; Clear the current group name.
5673 (setq gnus-newsgroup-name nil)
5674 (when (equal (gnus-group-group-name) group)
5675 (gnus-group-next-unread-group 1))
5677 (gnus-handle-ephemeral-exit quit-config)))))
5679 (defun gnus-handle-ephemeral-exit (quit-config)
5680 "Handle movement when leaving an ephemeral group.
5681 The state which existed when entering the ephemeral is reset."
5682 (if (not (buffer-name (car quit-config)))
5683 (gnus-configure-windows 'group 'force)
5684 (set-buffer (car quit-config))
5685 (cond ((eq major-mode 'gnus-summary-mode)
5686 (gnus-set-global-variables))
5687 ((eq major-mode 'gnus-article-mode)
5689 ;; The `gnus-summary-buffer' variable may point
5690 ;; to the old summary buffer when using a single
5692 (unless (gnus-buffer-live-p gnus-summary-buffer)
5693 (set-buffer gnus-group-buffer))
5694 (set-buffer gnus-summary-buffer)
5695 (gnus-set-global-variables))))
5696 (if (or (eq (cdr quit-config) 'article)
5697 (eq (cdr quit-config) 'pick))
5699 ;; The current article may be from the ephemeral group
5700 ;; thus it is best that we reload this article
5701 (gnus-summary-show-article)
5702 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5703 (gnus-configure-windows 'pick 'force)
5704 (gnus-configure-windows (cdr quit-config) 'force)))
5705 (gnus-configure-windows (cdr quit-config) 'force))
5706 (when (eq major-mode 'gnus-summary-mode)
5707 (gnus-summary-next-subject 1 nil t)
5708 (gnus-summary-recenter)
5709 (gnus-summary-position-point))))
5713 (defvar gnus-dead-summary-mode-map nil)
5715 (unless gnus-dead-summary-mode-map
5716 (setq gnus-dead-summary-mode-map (make-keymap))
5717 (suppress-keymap gnus-dead-summary-mode-map)
5718 (substitute-key-definition
5719 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5720 (let ((keys '("\C-d" "\r" "\177" [delete])))
5722 (define-key gnus-dead-summary-mode-map
5723 (pop keys) 'gnus-summary-wake-up-the-dead))))
5725 (defvar gnus-dead-summary-mode nil
5726 "Minor mode for Gnus summary buffers.")
5728 (defun gnus-dead-summary-mode (&optional arg)
5729 "Minor mode for Gnus summary buffers."
5731 (when (eq major-mode 'gnus-summary-mode)
5732 (make-local-variable 'gnus-dead-summary-mode)
5733 (setq gnus-dead-summary-mode
5734 (if (null arg) (not gnus-dead-summary-mode)
5735 (> (prefix-numeric-value arg) 0)))
5736 (when gnus-dead-summary-mode
5737 (gnus-add-minor-mode
5738 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5740 (defun gnus-deaden-summary ()
5741 "Make the current summary buffer into a dead summary buffer."
5742 ;; Kill any previous dead summary buffer.
5743 (when (and gnus-dead-summary
5744 (buffer-name gnus-dead-summary))
5746 (set-buffer gnus-dead-summary)
5747 (when gnus-dead-summary-mode
5748 (kill-buffer (current-buffer)))))
5749 ;; Make this the current dead summary.
5750 (setq gnus-dead-summary (current-buffer))
5751 (gnus-dead-summary-mode 1)
5752 (let ((name (buffer-name)))
5753 (when (string-match "Summary" name)
5755 (concat (substring name 0 (match-beginning 0)) "Dead "
5756 (substring name (match-beginning 0)))
5760 (defun gnus-kill-or-deaden-summary (buffer)
5761 "Kill or deaden the summary BUFFER."
5763 (when (and (buffer-name buffer)
5764 (not gnus-single-article-buffer))
5767 (gnus-kill-buffer gnus-article-buffer)
5768 (gnus-kill-buffer gnus-original-article-buffer)))
5769 (cond (gnus-kill-summary-on-exit
5770 (when (and gnus-use-trees
5771 (gnus-buffer-exists-p buffer))
5774 (gnus-tree-close gnus-newsgroup-name)))
5775 (gnus-kill-buffer buffer))
5776 ((gnus-buffer-exists-p buffer)
5779 (gnus-deaden-summary))))))
5781 (defun gnus-summary-wake-up-the-dead (&rest args)
5782 "Wake up the dead summary buffer."
5784 (gnus-dead-summary-mode -1)
5785 (let ((name (buffer-name)))
5786 (when (string-match "Dead " name)
5788 (concat (substring name 0 (match-beginning 0))
5789 (substring name (match-end 0)))
5791 (gnus-message 3 "This dead summary is now alive again"))
5793 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5794 (defun gnus-summary-fetch-faq (&optional faq-dir)
5795 "Fetch the FAQ for the current group.
5796 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5800 (when current-prefix-arg
5802 "Faq dir: " (and (listp gnus-group-faq-directory)
5803 (mapcar (lambda (file) (list file))
5804 gnus-group-faq-directory))))))
5805 (let (gnus-faq-buffer)
5806 (when (setq gnus-faq-buffer
5807 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5808 (gnus-configure-windows 'summary-faq))))
5810 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5811 (defun gnus-summary-describe-group (&optional force)
5812 "Describe the current newsgroup."
5814 (gnus-group-describe-group force gnus-newsgroup-name))
5816 (defun gnus-summary-describe-briefly ()
5817 "Describe summary mode commands briefly."
5819 (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")))
5821 ;; Walking around group mode buffer from summary mode.
5823 (defun gnus-summary-next-group (&optional no-article target-group backward)
5824 "Exit current newsgroup and then select next unread newsgroup.
5825 If prefix argument NO-ARTICLE is non-nil, no article is selected
5826 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5827 previous group instead."
5829 ;; Stop pre-fetching.
5830 (gnus-async-halt-prefetch)
5831 (let ((current-group gnus-newsgroup-name)
5832 (current-buffer (current-buffer))
5834 ;; First we semi-exit this group to update Xrefs and all variables.
5835 ;; We can't do a real exit, because the window conf must remain
5836 ;; the same in case the user is prompted for info, and we don't
5837 ;; want the window conf to change before that...
5838 (gnus-summary-exit t)
5839 (while (not entered)
5840 ;; Then we find what group we are supposed to enter.
5841 (set-buffer gnus-group-buffer)
5842 (gnus-group-jump-to-group current-group)
5845 (if (eq gnus-keep-same-level 'best)
5846 (gnus-summary-best-group gnus-newsgroup-name)
5847 (gnus-summary-search-group backward gnus-keep-same-level))))
5848 (if (not target-group)
5849 ;; There are no further groups, so we return to the group
5852 (gnus-message 5 "Returning to the group buffer")
5854 (when (gnus-buffer-live-p current-buffer)
5855 (set-buffer current-buffer)
5856 (gnus-summary-exit))
5857 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5858 ;; We try to enter the target group.
5859 (gnus-group-jump-to-group target-group)
5860 (let ((unreads (gnus-group-group-unread)))
5861 (if (and (or (eq t unreads)
5862 (and unreads (not (zerop unreads))))
5863 (gnus-summary-read-group
5864 target-group nil no-article
5865 (and (buffer-name current-buffer) current-buffer)
5868 (setq current-group target-group
5869 target-group nil)))))))
5871 (defun gnus-summary-prev-group (&optional no-article)
5872 "Exit current newsgroup and then select previous unread newsgroup.
5873 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5875 (gnus-summary-next-group no-article nil t))
5877 ;; Walking around summary lines.
5879 (defun gnus-summary-first-subject (&optional unread undownloaded)
5880 "Go to the first unread subject.
5881 If UNREAD is non-nil, go to the first unread article.
5882 Returns the article selected or nil if there are no unread articles."
5887 ((null gnus-newsgroup-data)
5888 (gnus-message 3 "No articles in the group")
5890 ;; Pick the first article.
5892 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5893 (gnus-data-number (car gnus-newsgroup-data)))
5894 ;; No unread articles.
5895 ((null gnus-newsgroup-unreads)
5896 (gnus-message 3 "No more unread articles")
5898 ;; Find the first unread article.
5900 (let ((data gnus-newsgroup-data))
5902 (and (not (and undownloaded
5903 (eq gnus-undownloaded-mark
5904 (gnus-data-mark (car data)))))
5905 (not (gnus-data-unread-p (car data)))))
5906 (setq data (cdr data)))
5908 (goto-char (gnus-data-pos (car data)))
5909 (gnus-data-number (car data))))))
5910 (gnus-summary-position-point)))
5912 (defun gnus-summary-next-subject (n &optional unread dont-display)
5913 "Go to next N'th summary line.
5914 If N is negative, go to the previous N'th subject line.
5915 If UNREAD is non-nil, only unread articles are selected.
5916 The difference between N and the actual number of steps taken is
5919 (let ((backward (< n 0))
5923 (gnus-summary-find-prev unread)
5924 (gnus-summary-find-next unread)))
5925 (unless (zerop (setq n (1- n)))
5926 (gnus-summary-show-thread)))
5928 (gnus-message 7 "No more%s articles"
5929 (if unread " unread" "")))
5930 (unless dont-display
5931 (gnus-summary-recenter)
5932 (gnus-summary-position-point))
5935 (defun gnus-summary-next-unread-subject (n)
5936 "Go to next N'th unread summary line."
5938 (gnus-summary-next-subject n t))
5940 (defun gnus-summary-prev-subject (n &optional unread)
5941 "Go to previous N'th summary line.
5942 If optional argument UNREAD is non-nil, only unread article is selected."
5944 (gnus-summary-next-subject (- n) unread))
5946 (defun gnus-summary-prev-unread-subject (n)
5947 "Go to previous N'th unread summary line."
5949 (gnus-summary-next-subject (- n) t))
5951 (defun gnus-summary-goto-subject (article &optional force silent)
5952 "Go the subject line of ARTICLE.
5953 If FORCE, also allow jumping to articles not currently shown."
5954 (interactive "nArticle number: ")
5956 (data (gnus-data-find article)))
5957 ;; We read in the article if we have to.
5960 (gnus-summary-insert-subject
5962 (if (or (numberp force) (vectorp force)) force)
5964 (setq data (gnus-data-find article)))
5969 (gnus-message 3 "Can't find article %d" article))
5971 (goto-char (gnus-data-pos data))
5972 (gnus-summary-position-point)
5975 ;; Walking around summary lines with displaying articles.
5977 (defun gnus-summary-expand-window (&optional arg)
5978 "Make the summary buffer take up the entire Emacs frame.
5979 Given a prefix, will force an `article' buffer configuration."
5982 (gnus-configure-windows 'article 'force)
5983 (gnus-configure-windows 'summary 'force)))
5985 (defun gnus-summary-display-article (article &optional all-header)
5986 "Display ARTICLE in article buffer."
5987 (when (gnus-buffer-live-p gnus-article-buffer)
5988 (with-current-buffer gnus-article-buffer
5989 (mm-enable-multibyte-mule4)))
5990 (gnus-set-global-variables)
5991 (when (gnus-buffer-live-p gnus-article-buffer)
5992 (with-current-buffer gnus-article-buffer
5993 (setq gnus-article-charset gnus-newsgroup-charset)
5994 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
5995 (mm-enable-multibyte-mule4)))
5999 (if gnus-summary-display-article-function
6000 (funcall gnus-summary-display-article-function article all-header)
6001 (gnus-article-prepare article all-header))
6002 (gnus-run-hooks 'gnus-select-article-hook)
6003 (when (and gnus-current-article
6004 (not (zerop gnus-current-article)))
6005 (gnus-summary-goto-subject gnus-current-article))
6006 (gnus-summary-recenter)
6007 (when (and gnus-use-trees gnus-show-threads)
6008 (gnus-possibly-generate-tree article)
6009 (gnus-highlight-selected-tree article))
6010 ;; Successfully display article.
6011 (gnus-article-set-window-start
6012 (cdr (assq article gnus-newsgroup-bookmarks))))))
6014 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6015 "Select the current article.
6016 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6017 non-nil, the article will be re-fetched even if it already present in
6018 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6020 ;; Make sure we are in the summary buffer to work around bbdb bug.
6021 (unless (eq major-mode 'gnus-summary-mode)
6022 (set-buffer gnus-summary-buffer))
6023 (let ((article (or article (gnus-summary-article-number)))
6024 (all-headers (not (not all-headers))) ;Must be T or NIL.
6025 gnus-summary-display-article-function)
6027 (gnus-summary-article-pseudo-p article)
6028 (error "This is a pseudo-article"))
6030 (set-buffer gnus-summary-buffer)
6031 (if (or (and gnus-single-article-buffer
6032 (or (null gnus-current-article)
6033 (null gnus-article-current)
6034 (null (get-buffer gnus-article-buffer))
6035 (not (eq article (cdr gnus-article-current)))
6036 (not (equal (car gnus-article-current)
6037 gnus-newsgroup-name))))
6038 (and (not gnus-single-article-buffer)
6039 (or (null gnus-current-article)
6040 (not (eq gnus-current-article article))))
6042 ;; The requested article is different from the current article.
6044 (gnus-summary-display-article article all-headers)
6045 (when (gnus-buffer-live-p gnus-article-buffer)
6046 (with-current-buffer gnus-article-buffer
6047 (if (not gnus-article-decoded-p) ;; a local variable
6048 (mm-disable-multibyte-mule4))))
6049 (when (or all-headers gnus-show-all-headers)
6050 (gnus-article-show-all-headers))
6051 (gnus-article-set-window-start
6052 (cdr (assq article gnus-newsgroup-bookmarks)))
6054 (when (or all-headers gnus-show-all-headers)
6055 (gnus-article-show-all-headers))
6058 (defun gnus-summary-force-verify-and-decrypt ()
6060 (let ((mm-verify-option 'known)
6061 (mm-decrypt-option 'known))
6062 (gnus-summary-select-article nil 'force)))
6064 (defun gnus-summary-set-current-mark (&optional current-mark)
6065 "Obsolete function."
6068 (defun gnus-summary-next-article (&optional unread subject backward push)
6069 "Select the next article.
6070 If UNREAD, only unread articles are selected.
6071 If SUBJECT, only articles with SUBJECT are selected.
6072 If BACKWARD, the previous article is selected instead of the next."
6075 ;; Is there such an article?
6076 ((and (gnus-summary-search-forward unread subject backward)
6077 (or (gnus-summary-display-article (gnus-summary-article-number))
6078 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6079 (gnus-summary-position-point))
6080 ;; If not, we try the first unread, if that is wanted.
6082 gnus-auto-select-same
6083 (gnus-summary-first-unread-article))
6084 (gnus-summary-position-point)
6085 (gnus-message 6 "Wrapped"))
6086 ;; Try to get next/previous article not displayed in this group.
6087 ((and gnus-auto-extend-newsgroup
6088 (not unread) (not subject))
6089 (gnus-summary-goto-article
6090 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6091 nil (count-lines (point-min) (point))))
6092 ;; Go to next/previous group.
6094 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6095 (gnus-summary-jump-to-group gnus-newsgroup-name))
6096 (let ((cmd last-command-char)
6099 (set-buffer gnus-group-buffer)
6102 (if (eq gnus-keep-same-level 'best)
6103 (gnus-summary-best-group gnus-newsgroup-name)
6104 (gnus-summary-search-group backward gnus-keep-same-level))))
6105 ;; For some reason, the group window gets selected. We change
6107 (select-window (get-buffer-window (current-buffer)))
6108 ;; Select next unread newsgroup automagically.
6110 ((or (not gnus-auto-select-next)
6112 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6113 ((or (eq gnus-auto-select-next 'quietly)
6114 (and (eq gnus-auto-select-next 'slightly-quietly)
6116 (and (eq gnus-auto-select-next 'almost-quietly)
6117 (gnus-summary-last-article-p)))
6119 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6121 (gnus-message 7 "No more%s articles (%s)..."
6122 (if unread " unread" "")
6123 (if group (concat "selecting " group)
6125 (gnus-summary-next-group nil group backward)))
6127 (when (gnus-key-press-event-p last-input-event)
6128 (gnus-summary-walk-group-buffer
6129 gnus-newsgroup-name cmd unread backward point))))))))
6131 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6132 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6133 (?\C-p (gnus-group-prev-unread-group 1))))
6134 (cursor-in-echo-area t)
6135 keve key group ended)
6137 (set-buffer gnus-group-buffer)
6140 (if (eq gnus-keep-same-level 'best)
6141 (gnus-summary-best-group gnus-newsgroup-name)
6142 (gnus-summary-search-group backward gnus-keep-same-level))))
6145 5 "No more%s articles%s" (if unread " unread" "")
6147 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6148 (format " (Type %s for %s [%s])"
6149 (single-key-description cmd) group
6150 (car (gnus-gethash group gnus-newsrc-hashtb)))
6151 (format " (Type %s to exit %s)"
6152 (single-key-description cmd)
6153 gnus-newsgroup-name)))
6154 ;; Confirm auto selection.
6155 (setq key (car (setq keve (gnus-read-event-char))))
6158 ((assq key keystrokes)
6159 (let ((obuf (current-buffer)))
6160 (switch-to-buffer gnus-group-buffer)
6162 (gnus-group-jump-to-group group))
6163 (eval (cadr (assq key keystrokes)))
6164 (setq group (gnus-group-group-name))
6165 (switch-to-buffer obuf))
6169 (gnus-ephemeral-group-p gnus-newsgroup-name))
6171 (gnus-summary-next-group nil group backward)))
6173 (push (cdr keve) unread-command-events))))))
6175 (defun gnus-summary-next-unread-article ()
6176 "Select unread article after current one."
6178 (gnus-summary-next-article
6179 (or (not (eq gnus-summary-goto-unread 'never))
6180 (gnus-summary-last-article-p (gnus-summary-article-number)))
6181 (and gnus-auto-select-same
6182 (gnus-summary-article-subject))))
6184 (defun gnus-summary-prev-article (&optional unread subject)
6185 "Select the article after the current one.
6186 If UNREAD is non-nil, only unread articles are selected."
6188 (gnus-summary-next-article unread subject t))
6190 (defun gnus-summary-prev-unread-article ()
6191 "Select unread article before current one."
6193 (gnus-summary-prev-article
6194 (or (not (eq gnus-summary-goto-unread 'never))
6195 (gnus-summary-first-article-p (gnus-summary-article-number)))
6196 (and gnus-auto-select-same
6197 (gnus-summary-article-subject))))
6199 (defun gnus-summary-next-page (&optional lines circular)
6200 "Show next page of the selected article.
6201 If at the end of the current article, select the next article.
6202 LINES says how many lines should be scrolled up.
6204 If CIRCULAR is non-nil, go to the start of the article instead of
6205 selecting the next article when reaching the end of the current
6208 (setq gnus-summary-buffer (current-buffer))
6209 (gnus-set-global-variables)
6210 (let ((article (gnus-summary-article-number))
6211 (article-window (get-buffer-window gnus-article-buffer t))
6213 ;; If the buffer is empty, we have no article.
6215 (error "No article to select"))
6216 (gnus-configure-windows 'article)
6217 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6218 (if (and (eq gnus-summary-goto-unread 'never)
6219 (not (gnus-summary-last-article-p article)))
6220 (gnus-summary-next-article)
6221 (gnus-summary-next-unread-article))
6222 (if (or (null gnus-current-article)
6223 (null gnus-article-current)
6224 (/= article (cdr gnus-article-current))
6225 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6226 ;; Selected subject is different from current article's.
6227 (gnus-summary-display-article article)
6228 (when article-window
6229 (gnus-eval-in-buffer-window gnus-article-buffer
6230 (setq endp (gnus-article-next-page lines)))
6233 (gnus-summary-beginning-of-article))
6235 (gnus-message 3 "End of message"))
6237 (if (and (eq gnus-summary-goto-unread 'never)
6238 (not (gnus-summary-last-article-p article)))
6239 (gnus-summary-next-article)
6240 (gnus-summary-next-unread-article))))))))
6241 (gnus-summary-recenter)
6242 (gnus-summary-position-point)))
6244 (defun gnus-summary-prev-page (&optional lines move)
6245 "Show previous page of selected article.
6246 Argument LINES specifies lines to be scrolled down.
6247 If MOVE, move to the previous unread article if point is at
6248 the beginning of the buffer."
6250 (let ((article (gnus-summary-article-number))
6251 (article-window (get-buffer-window gnus-article-buffer t))
6253 (gnus-configure-windows 'article)
6254 (if (or (null gnus-current-article)
6255 (null gnus-article-current)
6256 (/= article (cdr gnus-article-current))
6257 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6258 ;; Selected subject is different from current article's.
6259 (gnus-summary-display-article article)
6260 (gnus-summary-recenter)
6261 (when article-window
6262 (gnus-eval-in-buffer-window gnus-article-buffer
6263 (setq endp (gnus-article-prev-page lines)))
6264 (when (and move endp)
6266 (gnus-message 3 "Beginning of message"))
6268 (if (and (eq gnus-summary-goto-unread 'never)
6269 (not (gnus-summary-first-article-p article)))
6270 (gnus-summary-prev-article)
6271 (gnus-summary-prev-unread-article))))))))
6272 (gnus-summary-position-point))
6274 (defun gnus-summary-prev-page-or-article (&optional lines)
6275 "Show previous page of selected article.
6276 Argument LINES specifies lines to be scrolled down.
6277 If at the beginning of the article, go to the next article."
6279 (gnus-summary-prev-page lines t))
6281 (defun gnus-summary-scroll-up (lines)
6282 "Scroll up (or down) one line current article.
6283 Argument LINES specifies lines to be scrolled up (or down if negative)."
6285 (gnus-configure-windows 'article)
6286 (gnus-summary-show-thread)
6287 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6288 (gnus-eval-in-buffer-window gnus-article-buffer
6290 (when (gnus-article-next-page lines)
6291 (gnus-message 3 "End of message")))
6293 (gnus-article-prev-page (- lines))))))
6294 (gnus-summary-recenter)
6295 (gnus-summary-position-point))
6297 (defun gnus-summary-scroll-down (lines)
6298 "Scroll down (or up) one line current article.
6299 Argument LINES specifies lines to be scrolled down (or up if negative)."
6301 (gnus-summary-scroll-up (- lines)))
6303 (defun gnus-summary-next-same-subject ()
6304 "Select next article which has the same subject as current one."
6306 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6308 (defun gnus-summary-prev-same-subject ()
6309 "Select previous article which has the same subject as current one."
6311 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6313 (defun gnus-summary-next-unread-same-subject ()
6314 "Select next unread article which has the same subject as current one."
6316 (gnus-summary-next-article t (gnus-summary-article-subject)))
6318 (defun gnus-summary-prev-unread-same-subject ()
6319 "Select previous unread article which has the same subject as current one."
6321 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6323 (defun gnus-summary-first-unread-article ()
6324 "Select the first unread article.
6325 Return nil if there are no unread articles."
6328 (when (gnus-summary-first-subject t)
6329 (gnus-summary-show-thread)
6330 (gnus-summary-first-subject t)
6331 (gnus-summary-display-article (gnus-summary-article-number)))
6332 (gnus-summary-position-point)))
6334 (defun gnus-summary-first-unread-subject ()
6335 "Place the point on the subject line of the first unread article.
6336 Return nil if there are no unread articles."
6339 (when (gnus-summary-first-subject t)
6340 (gnus-summary-show-thread)
6341 (gnus-summary-first-subject t))
6342 (gnus-summary-position-point)))
6344 (defun gnus-summary-first-article ()
6345 "Select the first article.
6346 Return nil if there are no articles."
6349 (when (gnus-summary-first-subject)
6350 (gnus-summary-show-thread)
6351 (gnus-summary-first-subject)
6352 (gnus-summary-display-article (gnus-summary-article-number)))
6353 (gnus-summary-position-point)))
6355 (defun gnus-summary-best-unread-article ()
6356 "Select the unread article with the highest score."
6358 (let ((best -1000000)
6359 (data gnus-newsgroup-data)
6362 (and (gnus-data-unread-p (car data))
6364 (gnus-summary-article-score (gnus-data-number (car data))))
6367 article (gnus-data-number (car data))))
6368 (setq data (cdr data)))
6371 (gnus-summary-goto-article article)
6372 (error "No unread articles"))
6373 (gnus-summary-position-point))))
6375 (defun gnus-summary-last-subject ()
6376 "Go to the last displayed subject line in the group."
6377 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6379 (gnus-summary-goto-subject article))))
6381 (defun gnus-summary-goto-article (article &optional all-headers force)
6382 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6383 If ALL-HEADERS is non-nil, no header lines are hidden.
6384 If FORCE, go to the article even if it isn't displayed. If FORCE
6385 is a number, it is the line the article is to be displayed on."
6389 "Article number or Message-ID: "
6390 (mapcar (lambda (number) (list (int-to-string number)))
6391 gnus-newsgroup-limit))
6395 (if (and (stringp article)
6396 (string-match "@" article))
6397 (gnus-summary-refer-article article)
6398 (when (stringp article)
6399 (setq article (string-to-number article)))
6400 (if (gnus-summary-goto-subject article force)
6401 (gnus-summary-display-article article all-headers)
6402 (gnus-message 4 "Couldn't go to article %s" article) nil))
6403 (gnus-summary-position-point)))
6405 (defun gnus-summary-goto-last-article ()
6406 "Go to the previously read article."
6409 (when gnus-last-article
6410 (gnus-summary-goto-article gnus-last-article nil t))
6411 (gnus-summary-position-point)))
6413 (defun gnus-summary-pop-article (number)
6414 "Pop one article off the history and go to the previous.
6415 NUMBER articles will be popped off."
6418 (setq gnus-newsgroup-history
6419 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6421 (gnus-summary-goto-article (car to) nil t)
6422 (error "Article history empty")))
6423 (gnus-summary-position-point))
6425 ;; Summary commands and functions for limiting the summary buffer.
6427 (defun gnus-summary-limit-to-articles (n)
6428 "Limit the summary buffer to the next N articles.
6429 If not given a prefix, use the process marked articles instead."
6432 (let ((articles (gnus-summary-work-articles n)))
6433 (setq gnus-newsgroup-processable nil)
6434 (gnus-summary-limit articles))
6435 (gnus-summary-position-point)))
6437 (defun gnus-summary-pop-limit (&optional total)
6438 "Restore the previous limit.
6439 If given a prefix, remove all limits."
6442 (setq gnus-newsgroup-limits
6443 (list (mapcar (lambda (h) (mail-header-number h))
6444 gnus-newsgroup-headers))))
6445 (unless gnus-newsgroup-limits
6446 (error "No limit to pop"))
6448 (gnus-summary-limit nil 'pop)
6449 (gnus-summary-position-point)))
6451 (defun gnus-summary-limit-to-subject (subject &optional header)
6452 "Limit the summary buffer to articles that have subjects that match a regexp."
6453 (interactive "sLimit to subject (regexp): ")
6455 (setq header "subject"))
6456 (when (not (equal "" subject))
6458 (let ((articles (gnus-summary-find-matching
6459 (or header "subject") subject 'all)))
6461 (error "Found no matches for \"%s\"" subject))
6462 (gnus-summary-limit articles))
6463 (gnus-summary-position-point))))
6465 (defun gnus-summary-limit-to-author (from)
6466 "Limit the summary buffer to articles that have authors that match a regexp."
6467 (interactive "sLimit to author (regexp): ")
6468 (gnus-summary-limit-to-subject from "from"))
6470 (defun gnus-summary-limit-to-age (age &optional younger-p)
6471 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6472 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6473 articles that are younger than AGE days."
6475 (let ((younger current-prefix-arg)
6478 (while (not days-got)
6479 (setq days (if younger
6480 (read-string "Limit to articles within (in days): ")
6481 (read-string "Limit to articles older than (in days): ")))
6482 (when (> (length days) 0)
6483 (setq days (read days)))
6486 (message "Please enter a number.")
6488 (list days younger)))
6490 (let ((data gnus-newsgroup-data)
6491 (cutoff (days-to-time age))
6492 articles d date is-younger)
6493 (while (setq d (pop data))
6494 (when (and (vectorp (gnus-data-header d))
6495 (setq date (mail-header-date (gnus-data-header d))))
6496 (setq is-younger (time-less-p
6497 (time-since (condition-case ()
6504 (push (gnus-data-number d) articles))))
6505 (gnus-summary-limit (nreverse articles)))
6506 (gnus-summary-position-point)))
6508 (defun gnus-summary-limit-to-extra (header regexp)
6509 "Limit the summary buffer to articles that match an 'extra' header."
6513 (gnus-completing-read
6514 (symbol-name (car gnus-extra-headers))
6515 "Limit extra header:"
6517 (cons (symbol-name x) x))
6522 (read-string (format "Limit to header %s (regexp): " header)))))
6523 (when (not (equal "" regexp))
6525 (let ((articles (gnus-summary-find-matching
6526 (cons 'extra header) regexp 'all)))
6528 (error "Found no matches for \"%s\"" regexp))
6529 (gnus-summary-limit articles))
6530 (gnus-summary-position-point))))
6532 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6534 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6536 (defun gnus-summary-limit-to-unread (&optional all)
6537 "Limit the summary buffer to articles that are not marked as read.
6538 If ALL is non-nil, limit strictly to unread articles."
6541 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6542 (gnus-summary-limit-to-marks
6543 ;; Concat all the marks that say that an article is read and have
6545 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6546 gnus-killed-mark gnus-kill-file-mark
6547 gnus-low-score-mark gnus-expirable-mark
6548 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6549 gnus-duplicate-mark gnus-souped-mark)
6552 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6553 (make-obsolete 'gnus-summary-delete-marked-with
6554 'gnus-summary-limit-exlude-marks)
6556 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6557 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6558 If REVERSE, limit the summary buffer to articles that are marked
6559 with MARKS. MARKS can either be a string of marks or a list of marks.
6560 Returns how many articles were removed."
6561 (interactive "sMarks: ")
6562 (gnus-summary-limit-to-marks marks t))
6564 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6565 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6566 If REVERSE (the prefix), limit the summary buffer to articles that are
6567 not marked with MARKS. MARKS can either be a string of marks or a
6569 Returns how many articles were removed."
6570 (interactive "sMarks: \nP")
6572 (let ((data gnus-newsgroup-data)
6573 (marks (if (listp marks) marks
6574 (append marks nil))) ; Transform to list.
6577 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6578 (memq (gnus-data-mark (car data)) marks))
6579 (push (gnus-data-number (car data)) articles))
6580 (setq data (cdr data)))
6581 (gnus-summary-limit articles))
6582 (gnus-summary-position-point)))
6584 (defun gnus-summary-limit-to-score (&optional score)
6585 "Limit to articles with score at or above SCORE."
6587 (setq score (if score
6588 (prefix-numeric-value score)
6589 (or gnus-summary-default-score 0)))
6590 (let ((data gnus-newsgroup-data)
6593 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6595 (push (gnus-data-number (car data)) articles))
6596 (setq data (cdr data)))
6598 (gnus-summary-limit articles)
6599 (gnus-summary-position-point))))
6601 (defun gnus-summary-limit-include-thread (id)
6602 "Display all the hidden articles that in the current thread."
6603 (interactive (list (mail-header-id (gnus-summary-article-header))))
6604 (let ((articles (gnus-articles-in-thread
6605 (gnus-id-to-thread (gnus-root-id id)))))
6607 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6608 (gnus-summary-position-point))))
6610 (defun gnus-summary-limit-include-dormant ()
6611 "Display all the hidden articles that are marked as dormant.
6612 Note that this command only works on a subset of the articles currently
6613 fetched for this group."
6615 (unless gnus-newsgroup-dormant
6616 (error "There are no dormant articles in this group"))
6618 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6619 (gnus-summary-position-point)))
6621 (defun gnus-summary-limit-exclude-dormant ()
6622 "Hide all dormant articles."
6625 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6626 (gnus-summary-position-point)))
6628 (defun gnus-summary-limit-exclude-childless-dormant ()
6629 "Hide all dormant articles that have no children."
6631 (let ((data (gnus-data-list t))
6632 articles d children)
6633 ;; Find all articles that are either not dormant or have
6635 (while (setq d (pop data))
6636 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6638 (gnus-article-children (gnus-data-number d)))
6641 (when (memq (car children) articles)
6646 (push (gnus-data-number d) articles)))
6649 (gnus-summary-limit articles)
6650 (gnus-summary-position-point))))
6652 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6653 "Mark all unread excluded articles as read.
6654 If ALL, mark even excluded ticked and dormants as read."
6656 (let ((articles (gnus-sorted-complement
6658 (mapcar (lambda (h) (mail-header-number h))
6659 gnus-newsgroup-headers)
6661 (sort gnus-newsgroup-limit '<)))
6663 (setq gnus-newsgroup-unreads
6664 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6666 (setq gnus-newsgroup-dormant nil
6667 gnus-newsgroup-marked nil
6668 gnus-newsgroup-reads
6670 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6671 gnus-newsgroup-reads))
6672 (while (setq article (pop articles))
6673 (unless (or (memq article gnus-newsgroup-dormant)
6674 (memq article gnus-newsgroup-marked))
6675 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6677 (defun gnus-summary-limit (articles &optional pop)
6679 ;; We pop the previous limit off the stack and use that.
6680 (setq articles (car gnus-newsgroup-limits)
6681 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6682 ;; We use the new limit, so we push the old limit on the stack.
6683 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6685 (setq gnus-newsgroup-limit articles)
6686 (let ((total (length gnus-newsgroup-data))
6687 (data (gnus-data-find-list (gnus-summary-article-number)))
6688 (gnus-summary-mark-below nil) ; Inhibit this.
6690 ;; This will do all the work of generating the new summary buffer
6691 ;; according to the new limit.
6692 (gnus-summary-prepare)
6693 ;; Hide any threads, possibly.
6694 (and gnus-show-threads
6695 gnus-thread-hide-subtree
6696 (gnus-summary-hide-all-threads))
6697 ;; Try to return to the article you were at, or one in the
6700 ;; We try to find some article after the current one.
6702 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6705 (setq data (cdr data))))
6707 ;; If there is no data, that means that we were after the last
6708 ;; article. The same goes when we can't find any articles
6709 ;; after the current one.
6710 (goto-char (point-max))
6711 (gnus-summary-find-prev))
6712 (gnus-set-mode-line 'summary)
6713 ;; We return how many articles were removed from the summary
6714 ;; buffer as a result of the new limit.
6715 (- total (length gnus-newsgroup-data))))
6717 (defsubst gnus-invisible-cut-children (threads)
6720 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6725 (defsubst gnus-cut-thread (thread)
6726 "Go forwards in the thread until we find an article that we want to display."
6727 (when (or (eq gnus-fetch-old-headers 'some)
6728 (eq gnus-fetch-old-headers 'invisible)
6729 (numberp gnus-fetch-old-headers)
6730 (eq gnus-build-sparse-threads 'some)
6731 (eq gnus-build-sparse-threads 'more))
6732 ;; Deal with old-fetched headers and sparse threads.
6736 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6737 (gnus-summary-article-ancient-p
6738 (mail-header-number (car thread))))
6739 (if (or (<= (length (cdr thread)) 1)
6740 (eq gnus-fetch-old-headers 'invisible))
6741 (setq gnus-newsgroup-limit
6742 (delq (mail-header-number (car thread))
6743 gnus-newsgroup-limit)
6744 thread (cadr thread))
6745 (when (gnus-invisible-cut-children (cdr thread))
6746 (let ((th (cdr thread)))
6748 (if (memq (mail-header-number (caar th))
6749 gnus-newsgroup-limit)
6750 (setq thread (car th)
6752 (setq th (cdr th))))))))))
6755 (defun gnus-cut-threads (threads)
6756 "Cut off all uninteresting articles from the beginning of threads."
6757 (when (or (eq gnus-fetch-old-headers 'some)
6758 (eq gnus-fetch-old-headers 'invisible)
6759 (numberp gnus-fetch-old-headers)
6760 (eq gnus-build-sparse-threads 'some)
6761 (eq gnus-build-sparse-threads 'more))
6764 (setcar th (gnus-cut-thread (car th)))
6765 (setq th (cdr th)))))
6766 ;; Remove nixed out threads.
6769 (defun gnus-summary-initial-limit (&optional show-if-empty)
6770 "Figure out what the initial limit is supposed to be on group entry.
6771 This entails weeding out unwanted dormants, low-scored articles,
6772 fetch-old-headers verbiage, and so on."
6773 ;; Most groups have nothing to remove.
6774 (if (or gnus-inhibit-limiting
6775 (and (null gnus-newsgroup-dormant)
6776 (not (eq gnus-fetch-old-headers 'some))
6777 (not (numberp gnus-fetch-old-headers))
6778 (not (eq gnus-fetch-old-headers 'invisible))
6779 (null gnus-summary-expunge-below)
6780 (not (eq gnus-build-sparse-threads 'some))
6781 (not (eq gnus-build-sparse-threads 'more))
6782 (null gnus-thread-expunge-below)
6783 (not gnus-use-nocem)))
6785 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6786 (setq gnus-newsgroup-limit nil)
6789 (unless (car (symbol-value node))
6790 ;; These threads have no parents -- they are roots.
6791 (let ((nodes (cdr (symbol-value node)))
6794 (if (and gnus-thread-expunge-below
6795 (< (gnus-thread-total-score (car nodes))
6796 gnus-thread-expunge-below))
6797 (gnus-expunge-thread (pop nodes))
6798 (setq thread (pop nodes))
6799 (gnus-summary-limit-children thread))))))
6800 gnus-newsgroup-dependencies)
6801 ;; If this limitation resulted in an empty group, we might
6802 ;; pop the previous limit and use it instead.
6803 (when (and (not gnus-newsgroup-limit)
6805 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6806 gnus-newsgroup-limit))
6808 (defun gnus-summary-limit-children (thread)
6809 "Return 1 if this subthread is visible and 0 if it is not."
6810 ;; First we get the number of visible children to this thread. This
6811 ;; is done by recursing down the thread using this function, so this
6812 ;; will really go down to a leaf article first, before slowly
6813 ;; working its way up towards the root.
6817 (apply '+ (mapcar 'gnus-summary-limit-children
6820 (number (mail-header-number (car thread)))
6823 (not (memq number gnus-newsgroup-marked))
6825 ;; If this article is dormant and has absolutely no visible
6826 ;; children, then this article isn't visible.
6827 (and (memq number gnus-newsgroup-dormant)
6829 ;; If this is "fetch-old-headered" and there is no
6830 ;; visible children, then we don't want this article.
6831 (and (or (eq gnus-fetch-old-headers 'some)
6832 (numberp gnus-fetch-old-headers))
6833 (gnus-summary-article-ancient-p number)
6835 ;; If this is "fetch-old-headered" and `invisible', then
6836 ;; we don't want this article.
6837 (and (eq gnus-fetch-old-headers 'invisible)
6838 (gnus-summary-article-ancient-p number))
6839 ;; If this is a sparsely inserted article with no children,
6840 ;; we don't want it.
6841 (and (eq gnus-build-sparse-threads 'some)
6842 (gnus-summary-article-sparse-p number)
6844 ;; If we use expunging, and this article is really
6845 ;; low-scored, then we don't want this article.
6846 (when (and gnus-summary-expunge-below
6848 (or (cdr (assq number gnus-newsgroup-scored))
6849 gnus-summary-default-score))
6850 gnus-summary-expunge-below))
6851 ;; We increase the expunge-tally here, but that has
6852 ;; nothing to do with the limits, really.
6853 (incf gnus-newsgroup-expunged-tally)
6854 ;; We also mark as read here, if that's wanted.
6855 (when (and gnus-summary-mark-below
6856 (< score gnus-summary-mark-below))
6857 (setq gnus-newsgroup-unreads
6858 (delq number gnus-newsgroup-unreads))
6859 (if gnus-newsgroup-auto-expire
6860 (push number gnus-newsgroup-expirable)
6861 (push (cons number gnus-low-score-mark)
6862 gnus-newsgroup-reads)))
6864 ;; Check NoCeM things.
6865 (if (and gnus-use-nocem
6866 (gnus-nocem-unwanted-article-p
6867 (mail-header-id (car thread))))
6869 (setq gnus-newsgroup-unreads
6870 (delq number gnus-newsgroup-unreads))
6872 ;; Nope, invisible article.
6874 ;; Ok, this article is to be visible, so we add it to the limit
6876 (push number gnus-newsgroup-limit)
6879 (defun gnus-expunge-thread (thread)
6880 "Mark all articles in THREAD as read."
6881 (let* ((number (mail-header-number (car thread))))
6882 (incf gnus-newsgroup-expunged-tally)
6883 ;; We also mark as read here, if that's wanted.
6884 (setq gnus-newsgroup-unreads
6885 (delq number gnus-newsgroup-unreads))
6886 (if gnus-newsgroup-auto-expire
6887 (push number gnus-newsgroup-expirable)
6888 (push (cons number gnus-low-score-mark)
6889 gnus-newsgroup-reads)))
6890 ;; Go recursively through all subthreads.
6891 (mapcar 'gnus-expunge-thread (cdr thread)))
6893 ;; Summary article oriented commands
6895 (defun gnus-summary-refer-parent-article (n)
6896 "Refer parent article N times.
6897 If N is negative, go to ancestor -N instead.
6898 The difference between N and the number of articles fetched is returned."
6902 (when (not (natnump n))
6907 (setq header (gnus-summary-article-header))
6908 (if (and (eq (mail-header-number header)
6909 (cdr gnus-article-current))
6910 (equal gnus-newsgroup-name
6911 (car gnus-article-current)))
6912 ;; If we try to find the parent of the currently
6913 ;; displayed article, then we take a look at the actual
6914 ;; References header, since this is slightly more
6915 ;; reliable than the References field we got from the
6918 (set-buffer gnus-original-article-buffer)
6919 (nnheader-narrow-to-headers)
6920 (unless (setq ref (message-fetch-field "references"))
6921 (setq ref (message-fetch-field "in-reply-to")))
6924 ;; It's not the current article, so we take a bet on
6925 ;; the value we got from the server.
6926 (mail-header-references header)))
6928 (not (equal ref "")))
6929 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6930 (gnus-message 1 "Couldn't find parent"))
6931 (gnus-message 1 "No references in article %d"
6932 (gnus-summary-article-number))
6935 (gnus-summary-position-point)
6938 (defun gnus-summary-refer-references ()
6939 "Fetch all articles mentioned in the References header.
6940 Return the number of articles fetched."
6942 (let ((ref (mail-header-references (gnus-summary-article-header)))
6943 (current (gnus-summary-article-number))
6947 (error "No References in the current article")
6948 ;; For each Message-ID in the References header...
6949 (while (string-match "<[^>]*>" ref)
6951 ;; ... fetch that article.
6952 (gnus-summary-refer-article
6953 (prog1 (match-string 0 ref)
6954 (setq ref (substring ref (match-end 0))))))
6955 (gnus-summary-goto-subject current)
6956 (gnus-summary-position-point)
6959 (defun gnus-summary-refer-thread (&optional limit)
6960 "Fetch all articles in the current thread.
6961 If LIMIT (the numerical prefix), fetch that many old headers instead
6962 of what's specified by the `gnus-refer-thread-limit' variable."
6964 (let ((id (mail-header-id (gnus-summary-article-header)))
6965 (limit (if limit (prefix-numeric-value limit)
6966 gnus-refer-thread-limit)))
6967 ;; We want to fetch LIMIT *old* headers, but we also have to
6968 ;; re-fetch all the headers in the current buffer, because many of
6969 ;; them may be undisplayed. So we adjust LIMIT.
6970 (when (numberp limit)
6971 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6972 (unless (eq gnus-fetch-old-headers 'invisible)
6973 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6974 ;; Retrieve the headers and read them in.
6975 (if (eq (gnus-retrieve-headers
6976 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6978 (gnus-build-all-threads)
6979 (error "Can't fetch thread from backends that don't support NOV"))
6980 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6981 (gnus-summary-limit-include-thread id)))
6983 (defun gnus-summary-refer-article (message-id)
6984 "Fetch an article specified by MESSAGE-ID."
6985 (interactive "sMessage-ID: ")
6986 (when (and (stringp message-id)
6987 (not (zerop (length message-id))))
6988 ;; Construct the correct Message-ID if necessary.
6989 ;; Suggested by tale@pawl.rpi.edu.
6990 (unless (string-match "^<" message-id)
6991 (setq message-id (concat "<" message-id)))
6992 (unless (string-match ">$" message-id)
6993 (setq message-id (concat message-id ">")))
6994 (let* ((header (gnus-id-to-header message-id))
6996 (gnus-summary-article-sparse-p
6997 (mail-header-number header))
6998 (memq (mail-header-number header)
6999 gnus-newsgroup-limit)))
7002 ;; If the article is present in the buffer we just go to it.
7004 (or (not (gnus-summary-article-sparse-p
7005 (mail-header-number header)))
7008 (gnus-summary-goto-article
7009 (mail-header-number header) nil t)
7011 (gnus-summary-update-article (mail-header-number header)))))
7013 ;; We fetch the article.
7015 (dolist (gnus-override-method (gnus-refer-article-methods))
7016 (gnus-check-server gnus-override-method)
7017 ;; Fetch the header, and display the article.
7018 (when (setq number (gnus-summary-insert-subject message-id))
7019 (gnus-summary-select-article nil nil nil number)
7021 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7023 (defun gnus-refer-article-methods ()
7024 "Return a list of referrable methods."
7026 ;; No method, so we default to current and native.
7027 ((null gnus-refer-article-method)
7028 (list gnus-current-select-method gnus-select-method))
7030 ((eq 'current gnus-refer-article-method)
7031 (list gnus-current-select-method))
7032 ;; List of select methods.
7033 ((not (and (symbolp (car gnus-refer-article-method))
7034 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7036 (dolist (method gnus-refer-article-method)
7037 (push (if (eq 'current method)
7038 gnus-current-select-method
7042 ;; One single select method.
7044 (list gnus-refer-article-method))))
7046 (defun gnus-summary-edit-parameters ()
7047 "Edit the group parameters of the current group."
7049 (gnus-group-edit-group gnus-newsgroup-name 'params))
7051 (defun gnus-summary-customize-parameters ()
7052 "Customize the group parameters of the current group."
7054 (gnus-group-customize gnus-newsgroup-name))
7056 (defun gnus-summary-enter-digest-group (&optional force)
7057 "Enter an nndoc group based on the current article.
7058 If FORCE, force a digest interpretation. If not, try
7059 to guess what the document format is."
7061 (let ((conf gnus-current-window-configuration))
7063 (gnus-summary-select-article))
7064 (setq gnus-current-window-configuration conf)
7065 (let* ((name (format "%s-%d"
7066 (gnus-group-prefixed-name
7067 gnus-newsgroup-name (list 'nndoc ""))
7069 (set-buffer gnus-summary-buffer)
7070 gnus-current-article)))
7071 (ogroup gnus-newsgroup-name)
7072 (params (append (gnus-info-params (gnus-get-info ogroup))
7073 (list (cons 'to-group ogroup))
7074 (list (cons 'save-article-group ogroup))))
7075 (case-fold-search t)
7076 (buf (current-buffer))
7079 (set-buffer gnus-original-article-buffer)
7080 ;; Have the digest group inherit the main mail address of
7081 ;; the parent article.
7082 (when (setq to-address (or (message-fetch-field "reply-to")
7083 (message-fetch-field "from")))
7084 (setq params (append
7085 (list (cons 'to-address
7086 (funcall gnus-decode-encoded-word-function
7088 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7089 (insert-buffer-substring gnus-original-article-buffer)
7090 ;; Remove lines that may lead nndoc to misinterpret the
7093 (goto-char (point-min))
7094 (or (search-forward "\n\n" nil t) (point)))
7095 (goto-char (point-min))
7096 (delete-matching-lines "^Path:\\|^From ")
7099 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7100 (gnus-newsgroup-ephemeral-ignored-charsets
7101 gnus-newsgroup-ignored-charsets))
7102 (gnus-group-read-ephemeral-group
7103 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7105 ,(if force 'mbox 'guess))) t))
7106 ;; Make all postings to this group go to the parent group.
7107 (nconc (gnus-info-params (gnus-get-info name))
7109 ;; Couldn't select this doc group.
7110 (switch-to-buffer buf)
7111 (gnus-set-global-variables)
7112 (gnus-configure-windows 'summary)
7113 (gnus-message 3 "Article couldn't be entered?"))
7114 (kill-buffer dig)))))
7116 (defun gnus-summary-read-document (n)
7117 "Open a new group based on the current article(s).
7118 This will allow you to read digests and other similar
7119 documents as newsgroups.
7120 Obeys the standard process/prefix convention."
7122 (let* ((articles (gnus-summary-work-articles n))
7123 (ogroup gnus-newsgroup-name)
7124 (params (append (gnus-info-params (gnus-get-info ogroup))
7125 (list (cons 'to-group ogroup))))
7126 article group egroup groups vgroup)
7127 (while (setq article (pop articles))
7128 (setq group (format "%s-%d" gnus-newsgroup-name article))
7129 (gnus-summary-remove-process-mark article)
7130 (when (gnus-summary-display-article article)
7133 (insert-buffer-substring gnus-original-article-buffer)
7134 ;; Remove some headers that may lead nndoc to make
7136 (message-narrow-to-head)
7137 (goto-char (point-min))
7138 (delete-matching-lines "^\\(Path\\):\\|^From ")
7141 (gnus-group-read-ephemeral-group
7142 group `(nndoc ,group (nndoc-address ,(current-buffer))
7143 (nndoc-article-type guess))
7146 ;; Make all postings to this group go to the parent group.
7147 (nconc (gnus-info-params (gnus-get-info egroup))
7149 (push egroup groups))
7150 ;; Couldn't select this doc group.
7151 (gnus-error 3 "Article couldn't be entered"))))))
7152 ;; Now we have selected all the documents.
7155 (error "None of the articles could be interpreted as documents"))
7156 ((gnus-group-read-ephemeral-group
7157 (setq vgroup (format
7158 "nnvirtual:%s-%s" gnus-newsgroup-name
7159 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7160 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7162 (cons (current-buffer) 'summary)))
7164 (error "Couldn't select virtual nndoc group")))))
7166 (defun gnus-summary-isearch-article (&optional regexp-p)
7167 "Do incremental search forward on the current article.
7168 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7170 (gnus-summary-select-article)
7171 (gnus-configure-windows 'article)
7172 (gnus-eval-in-buffer-window gnus-article-buffer
7175 (isearch-forward regexp-p))))
7177 (defun gnus-summary-search-article-forward (regexp &optional backward)
7178 "Search for an article containing REGEXP forward.
7179 If BACKWARD, search backward instead."
7182 (format "Search article %s (regexp%s): "
7183 (if current-prefix-arg "backward" "forward")
7184 (if gnus-last-search-regexp
7185 (concat ", default " gnus-last-search-regexp)
7187 current-prefix-arg))
7188 (if (string-equal regexp "")
7189 (setq regexp (or gnus-last-search-regexp ""))
7190 (setq gnus-last-search-regexp regexp)
7191 (setq gnus-article-before-search gnus-current-article))
7192 ;; Intentionally set gnus-last-article.
7193 (setq gnus-last-article gnus-article-before-search)
7194 (let ((gnus-last-article gnus-last-article))
7195 (if (gnus-summary-search-article regexp backward)
7196 (gnus-summary-show-thread)
7197 (error "Search failed: \"%s\"" regexp))))
7199 (defun gnus-summary-search-article-backward (regexp)
7200 "Search for an article containing REGEXP backward."
7203 (format "Search article backward (regexp%s): "
7204 (if gnus-last-search-regexp
7205 (concat ", default " gnus-last-search-regexp)
7207 (gnus-summary-search-article-forward regexp 'backward))
7209 (defun gnus-summary-search-article (regexp &optional backward)
7210 "Search for an article containing REGEXP.
7211 Optional argument BACKWARD means do search for backward.
7212 `gnus-select-article-hook' is not called during the search."
7213 ;; We have to require this here to make sure that the following
7214 ;; dynamic binding isn't shadowed by autoloading.
7215 (require 'gnus-async)
7217 (let ((gnus-select-article-hook nil) ;Disable hook.
7218 (gnus-article-prepare-hook nil)
7219 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7220 (gnus-use-article-prefetch nil)
7221 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7222 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7223 (sum (current-buffer))
7224 (gnus-display-mime-function nil)
7227 (gnus-save-hidden-threads
7228 (gnus-summary-select-article)
7229 (set-buffer gnus-article-buffer)
7230 (goto-char (window-point (get-buffer-window (current-buffer))))
7234 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7236 (re-search-backward regexp nil t)
7237 (re-search-forward regexp nil t))
7238 ;; We found the regexp.
7243 (get-buffer-window (current-buffer))
7247 (get-buffer-window (current-buffer))
7250 (setq point (point)))
7251 ;; We didn't find it, so we go to the next article.
7254 (while (eq found 'not)
7255 (if (not (if backward (gnus-summary-find-prev)
7256 (gnus-summary-find-next)))
7257 ;; No more articles.
7259 ;; Select the next article and adjust point.
7260 (unless (gnus-summary-article-sparse-p
7261 (gnus-summary-article-number))
7263 (gnus-summary-select-article)
7264 (set-buffer gnus-article-buffer)
7266 (goto-char (if backward (point-max) (point-min))))))))
7267 (gnus-message 7 ""))
7268 ;; Return whether we found the regexp.
7269 (when (eq found 'found)
7271 (gnus-summary-show-thread)
7272 (gnus-summary-goto-subject gnus-current-article)
7273 (gnus-summary-position-point)
7276 (defun gnus-summary-find-matching (header regexp &optional backward unread
7278 "Return a list of all articles that match REGEXP on HEADER.
7279 The search stars on the current article and goes forwards unless
7280 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7281 If UNREAD is non-nil, only unread articles will
7282 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7283 in the comparisons."
7284 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7285 (gnus-data-find-list
7286 (gnus-summary-article-number) (gnus-data-list backward))))
7287 (case-fold-search (not not-case-fold))
7290 (if (eq (car header) 'extra)
7293 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7295 (error "%s is an invalid header" header))
7296 (unless (fboundp (intern (concat "mail-header-" header)))
7297 (error "%s is not a valid header" header))
7298 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7301 (and (or (not unread) ; We want all articles...
7302 (gnus-data-unread-p d)) ; Or just unreads.
7303 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7304 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7305 (push (gnus-data-number d) articles)) ; Success!
7306 (setq data (cdr data)))
7307 (nreverse articles)))
7309 (defun gnus-summary-execute-command (header regexp command &optional backward)
7310 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7311 If HEADER is an empty string (or nil), the match is done on the entire
7312 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7314 (list (let ((completion-ignore-case t))
7317 (mapcar (lambda (string) (list string))
7318 '("Number" "Subject" "From" "Lines" "Date"
7319 "Message-ID" "Xref" "References" "Body"))
7320 nil 'require-match))
7321 (read-string "Regexp: ")
7322 (read-key-sequence "Command: ")
7323 current-prefix-arg))
7324 (when (equal header "Body")
7326 ;; Hidden thread subtrees must be searched as well.
7327 (gnus-summary-show-all-threads)
7328 ;; We don't want to change current point nor window configuration.
7330 (save-window-excursion
7331 (gnus-message 6 "Executing %s..." (key-description command))
7332 ;; We'd like to execute COMMAND interactively so as to give arguments.
7333 (gnus-execute header regexp
7334 `(call-interactively ',(key-binding command))
7336 (gnus-message 6 "Executing %s...done" (key-description command)))))
7338 (defun gnus-summary-beginning-of-article ()
7339 "Scroll the article back to the beginning."
7341 (gnus-summary-select-article)
7342 (gnus-configure-windows 'article)
7343 (gnus-eval-in-buffer-window gnus-article-buffer
7345 (goto-char (point-min))
7346 (when gnus-page-broken
7347 (gnus-narrow-to-page))))
7349 (defun gnus-summary-end-of-article ()
7350 "Scroll to the end of the article."
7352 (gnus-summary-select-article)
7353 (gnus-configure-windows 'article)
7354 (gnus-eval-in-buffer-window gnus-article-buffer
7356 (goto-char (point-max))
7358 (when gnus-page-broken
7359 (gnus-narrow-to-page))))
7361 (defun gnus-summary-print-article (&optional filename n)
7362 "Generate and print a PostScript image of the N next (mail) articles.
7364 If N is negative, print the N previous articles. If N is nil and articles
7365 have been marked with the process mark, print these instead.
7367 If the optional first argument FILENAME is nil, send the image to the
7368 printer. If FILENAME is a string, save the PostScript image in a file with
7369 that name. If FILENAME is a number, prompt the user for the name of the file
7371 (interactive (list (ps-print-preprint current-prefix-arg)
7372 current-prefix-arg))
7373 (dolist (article (gnus-summary-work-articles n))
7374 (gnus-summary-select-article nil nil 'pseudo article)
7375 (gnus-eval-in-buffer-window gnus-article-buffer
7376 (let ((buffer (generate-new-buffer " *print*")))
7379 (copy-to-buffer buffer (point-min) (point-max))
7381 (gnus-article-delete-invisible-text)
7382 (let ((ps-left-header
7385 (mail-header-subject gnus-current-headers) ")")
7387 (mail-header-from gnus-current-headers) ")")))
7390 "/pagenumberstring load"
7392 (mail-header-date gnus-current-headers) ")"))))
7393 (gnus-run-hooks 'gnus-ps-print-hook)
7395 (ps-print-buffer-with-faces filename))))
7396 (kill-buffer buffer))))))
7398 (defun gnus-summary-show-article (&optional arg)
7399 "Force re-fetching of the current article.
7400 If ARG (the prefix) is a number, show the article with the charset
7401 defined in `gnus-summary-show-article-charset-alist', or the charset
7403 If ARG (the prefix) is non-nil and not a number, show the raw article
7404 without any article massaging functions being run."
7408 (let ((gnus-newsgroup-charset
7409 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7410 (read-coding-system "Charset: ")))
7411 (gnus-newsgroup-ignored-charsets 'gnus-all))
7412 (gnus-summary-select-article nil 'force)
7413 (let ((deps gnus-newsgroup-dependencies)
7416 (set-buffer gnus-original-article-buffer)
7418 (message-narrow-to-head)
7419 (setq head (buffer-string)))
7421 (insert (format "211 %d Article retrieved.\n"
7422 (cdr gnus-article-current)))
7425 (let ((nntp-server-buffer (current-buffer)))
7426 (setq header (car (gnus-get-newsgroup-headers deps t))))))
7427 (gnus-data-set-header
7428 (gnus-data-find (cdr gnus-article-current))
7430 (gnus-summary-update-article-line
7431 (cdr gnus-article-current) header))))
7433 ;; Select the article the normal way.
7434 (gnus-summary-select-article nil 'force))
7436 ;; We have to require this here to make sure that the following
7437 ;; dynamic binding isn't shadowed by autoloading.
7438 (require 'gnus-async)
7440 ;; Bind the article treatment functions to nil.
7441 (let ((gnus-have-all-headers t)
7442 gnus-article-prepare-hook
7443 gnus-article-decode-hook
7444 gnus-display-mime-function
7446 ;; Destroy any MIME parts.
7447 (when (gnus-buffer-live-p gnus-article-buffer)
7449 (set-buffer gnus-article-buffer)
7450 (mm-destroy-parts gnus-article-mime-handles)
7451 ;; Set it to nil for safety reason.
7452 (setq gnus-article-mime-handle-alist nil)
7453 (setq gnus-article-mime-handles nil)))
7454 (gnus-summary-select-article nil 'force))))
7455 (gnus-summary-goto-subject gnus-current-article)
7456 (gnus-summary-position-point))
7458 (defun gnus-summary-verbose-headers (&optional arg)
7459 "Toggle permanent full header display.
7460 If ARG is a positive number, turn header display on.
7461 If ARG is a negative number, turn header display off."
7463 (setq gnus-show-all-headers
7464 (cond ((or (not (numberp arg))
7466 (not gnus-show-all-headers))
7469 (gnus-summary-show-article))
7471 (defun gnus-summary-toggle-header (&optional arg)
7472 "Show the headers if they are hidden, or hide them if they are shown.
7473 If ARG is a positive number, show the entire header.
7474 If ARG is a negative number, hide the unwanted header lines."
7477 (set-buffer gnus-article-buffer)
7479 (let* ((buffer-read-only nil)
7480 (inhibit-point-motion-hooks t)
7486 (article-narrow-to-head)
7487 (gnus-article-hidden-text-p 'headers))))
7488 (goto-char (point-min))
7489 (when (search-forward "\n\n" nil t)
7490 (delete-region (point-min) (1- (point))))
7491 (goto-char (point-min))
7493 (set-buffer gnus-original-article-buffer)
7494 (goto-char (point-min))
7495 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7496 (insert-buffer-substring gnus-original-article-buffer 1 e)
7498 (narrow-to-region (point-min) (point))
7499 (article-decode-encoded-words)
7501 (let ((gnus-treat-hide-headers nil)
7502 (gnus-treat-hide-boring-headers nil))
7503 (setq gnus-article-wash-types
7504 (delq 'headers gnus-article-wash-types))
7505 (gnus-treat-article 'head))
7506 (gnus-treat-article 'head)))
7507 (gnus-set-mode-line 'article)))))
7509 (defun gnus-summary-show-all-headers ()
7510 "Make all header lines visible."
7512 (gnus-article-show-all-headers))
7514 (defun gnus-summary-caesar-message (&optional arg)
7515 "Caesar rotate the current article by 13.
7516 The numerical prefix specifies how many places to rotate each letter
7519 (gnus-summary-select-article)
7520 (let ((mail-header-separator ""))
7521 (gnus-eval-in-buffer-window gnus-article-buffer
7524 (let ((start (window-start))
7526 (message-caesar-buffer-body arg)
7527 (set-window-start (get-buffer-window (current-buffer)) start))))))
7529 (defun gnus-summary-stop-page-breaking ()
7530 "Stop page breaking in the current article."
7532 (gnus-summary-select-article)
7533 (gnus-eval-in-buffer-window gnus-article-buffer
7535 (when (gnus-visual-p 'page-marker)
7536 (let ((buffer-read-only nil))
7537 (gnus-remove-text-with-property 'gnus-prev)
7538 (gnus-remove-text-with-property 'gnus-next))
7539 (setq gnus-page-broken nil))))
7541 (defun gnus-summary-move-article (&optional n to-newsgroup
7542 select-method action)
7543 "Move the current article to a different newsgroup.
7544 If N is a positive number, move the N next articles.
7545 If N is a negative number, move the N previous articles.
7546 If N is nil and any articles have been marked with the process mark,
7547 move those articles instead.
7548 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7549 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7550 re-spool using this method.
7552 For this function to work, both the current newsgroup and the
7553 newsgroup that you want to move to have to support the `request-move'
7554 and `request-accept' functions.
7556 ACTION can be either `move' (the default), `crosspost' or `copy'."
7559 (setq action 'move))
7560 ;; Disable marking as read.
7561 (let (gnus-mark-article-hook)
7562 (save-window-excursion
7563 (gnus-summary-select-article)))
7564 ;; Check whether the source group supports the required functions.
7565 (cond ((and (eq action 'move)
7566 (not (gnus-check-backend-function
7567 'request-move-article gnus-newsgroup-name)))
7568 (error "The current group does not support article moving"))
7569 ((and (eq action 'crosspost)
7570 (not (gnus-check-backend-function
7571 'request-replace-article gnus-newsgroup-name)))
7572 (error "The current group does not support article editing")))
7573 (let ((articles (gnus-summary-work-articles n))
7574 (prefix (if (gnus-check-backend-function
7575 'request-move-article gnus-newsgroup-name)
7576 (gnus-group-real-prefix gnus-newsgroup-name)
7578 (names '((move "Move" "Moving")
7579 (copy "Copy" "Copying")
7580 (crosspost "Crosspost" "Crossposting")))
7581 (copy-buf (save-excursion
7582 (nnheader-set-temp-buffer " *copy article*")))
7583 art-group to-method new-xref article to-groups)
7584 (unless (assq action names)
7585 (error "Unknown action %s" action))
7586 ;; Read the newsgroup name.
7587 (when (and (not to-newsgroup)
7588 (not select-method))
7590 (gnus-read-move-group-name
7591 (cadr (assq action names))
7592 (symbol-value (intern (format "gnus-current-%s-group" action)))
7594 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7595 (setq to-method (or select-method
7596 (gnus-server-to-method
7597 (gnus-group-method to-newsgroup))))
7598 ;; Check the method we are to move this article to...
7599 (unless (gnus-check-backend-function
7600 'request-accept-article (car to-method))
7601 (error "%s does not support article copying" (car to-method)))
7602 (unless (gnus-check-server to-method)
7603 (error "Can't open server %s" (car to-method)))
7604 (gnus-message 6 "%s to %s: %s..."
7605 (caddr (assq action names))
7606 (or (car select-method) to-newsgroup) articles)
7608 (setq article (pop articles))
7612 ;; Move the article.
7614 ;; Remove this article from future suppression.
7615 (gnus-dup-unsuppress-article article)
7616 (gnus-request-move-article
7617 article ; Article to move
7618 gnus-newsgroup-name ; From newsgroup
7619 (nth 1 (gnus-find-method-for-group
7620 gnus-newsgroup-name)) ; Server
7621 (list 'gnus-request-accept-article
7622 to-newsgroup (list 'quote select-method)
7623 (not articles) t) ; Accept form
7624 (not articles))) ; Only save nov last time
7625 ;; Copy the article.
7628 (set-buffer copy-buf)
7629 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7630 (gnus-request-accept-article
7631 to-newsgroup select-method (not articles) t))))
7632 ;; Crosspost the article.
7633 ((eq action 'crosspost)
7634 (let ((xref (message-tokenize-header
7635 (mail-header-xref (gnus-summary-article-header article))
7637 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7640 (setq xref (list (system-name))))
7643 (mapconcat 'identity
7644 (delete "Xref:" (delete new-xref xref))
7648 (set-buffer copy-buf)
7649 ;; First put the article in the destination group.
7650 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7651 (when (consp (setq art-group
7652 (gnus-request-accept-article
7653 to-newsgroup select-method (not articles))))
7654 (setq new-xref (concat new-xref " " (car art-group)
7655 ":" (cdr art-group)))
7656 ;; Now we have the new Xrefs header, so we insert
7657 ;; it and replace the new article.
7658 (nnheader-replace-header "Xref" new-xref)
7659 (gnus-request-replace-article
7660 (cdr art-group) to-newsgroup (current-buffer))
7664 (gnus-message 1 "Couldn't %s article %s: %s"
7665 (cadr (assq action names)) article
7666 (nnheader-get-report (car to-method))))
7667 ((eq art-group 'junk)
7668 (when (eq action 'move)
7669 (gnus-summary-mark-article article gnus-canceled-mark)
7670 (gnus-message 4 "Deleted article %s" article)))
7672 (let* ((pto-group (gnus-group-prefixed-name
7673 (car art-group) to-method))
7675 (gnus-gethash pto-group gnus-newsrc-hashtb))
7676 (info (nth 2 entry))
7677 (to-group (gnus-info-group info))
7679 ;; Update the group that has been moved to.
7681 (memq action '(move copy)))
7682 (unless (member to-group to-groups)
7683 (push to-group to-groups))
7685 (unless (memq article gnus-newsgroup-unreads)
7686 (push 'read to-marks)
7688 info (gnus-add-to-range (gnus-info-read info)
7689 (list (cdr art-group)))))
7691 ;; See whether the article is to be put in the cache.
7692 (let ((marks gnus-article-mark-lists)
7693 (to-article (cdr art-group)))
7695 ;; Enter the article into the cache in the new group,
7696 ;; if that is required.
7697 (when gnus-use-cache
7698 (gnus-cache-possibly-enter-article
7700 (memq article gnus-newsgroup-marked)
7701 (memq article gnus-newsgroup-dormant)
7702 (memq article gnus-newsgroup-unreads)))
7704 (when gnus-preserve-marks
7705 ;; Copy any marks over to the new group.
7706 (when (and (equal to-group gnus-newsgroup-name)
7707 (not (memq article gnus-newsgroup-unreads)))
7708 ;; Mark this article as read in this group.
7709 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7710 (setcdr (gnus-active to-group) to-article)
7711 (setcdr gnus-newsgroup-active to-article))
7714 (when (memq article (symbol-value
7715 (intern (format "gnus-newsgroup-%s"
7717 (push (cdar marks) to-marks)
7718 ;; If the other group is the same as this group,
7719 ;; then we have to add the mark to the list.
7720 (when (equal to-group gnus-newsgroup-name)
7721 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7724 (intern (format "gnus-newsgroup-%s"
7726 ;; Copy the marks to other group.
7727 (gnus-add-marked-articles
7728 to-group (cdar marks) (list to-article) info))
7729 (setq marks (cdr marks)))
7731 (gnus-request-set-mark to-group (list (list (list to-article)
7736 (concat "(gnus-group-set-info '"
7737 (gnus-prin1-to-string (gnus-get-info to-group))
7740 ;; Update the Xref header in this article to point to
7741 ;; the new crossposted article we have just created.
7742 (when (eq action 'crosspost)
7744 (set-buffer copy-buf)
7745 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7746 (nnheader-replace-header "Xref" new-xref)
7747 (gnus-request-replace-article
7748 article gnus-newsgroup-name (current-buffer)))))
7750 ;;;!!!Why is this necessary?
7751 (set-buffer gnus-summary-buffer)
7753 (gnus-summary-goto-subject article)
7754 (when (eq action 'move)
7755 (gnus-summary-mark-article article gnus-canceled-mark))))
7756 (gnus-summary-remove-process-mark article))
7757 ;; Re-activate all groups that have been moved to.
7760 (set-buffer gnus-group-buffer)
7761 (when (gnus-group-goto-group (car to-groups) t)
7762 (gnus-group-get-new-news-this-group 1 t))
7765 (gnus-kill-buffer copy-buf)
7766 (gnus-summary-position-point)
7767 (gnus-set-mode-line 'summary)))
7769 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7770 "Move the current article to a different newsgroup.
7771 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7772 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7773 re-spool using this method."
7775 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7777 (defun gnus-summary-crosspost-article (&optional n)
7778 "Crosspost the current article to some other group."
7780 (gnus-summary-move-article n nil nil 'crosspost))
7782 (defcustom gnus-summary-respool-default-method nil
7783 "Default method for respooling an article.
7784 If nil, use to the current newsgroup method."
7785 :type '(choice (gnus-select-method :value (nnml ""))
7787 :group 'gnus-summary-mail)
7789 (defun gnus-summary-respool-article (&optional n method)
7790 "Respool the current article.
7791 The article will be squeezed through the mail spooling process again,
7792 which means that it will be put in some mail newsgroup or other
7793 depending on `nnmail-split-methods'.
7794 If N is a positive number, respool the N next articles.
7795 If N is a negative number, respool the N previous articles.
7796 If N is nil and any articles have been marked with the process mark,
7797 respool those articles instead.
7799 Respooling can be done both from mail groups and \"real\" newsgroups.
7800 In the former case, the articles in question will be moved from the
7801 current group into whatever groups they are destined to. In the
7802 latter case, they will be copied into the relevant groups."
7804 (list current-prefix-arg
7805 (let* ((methods (gnus-methods-using 'respool))
7807 (symbol-name (or gnus-summary-respool-default-method
7808 (car (gnus-find-method-for-group
7809 gnus-newsgroup-name)))))
7811 (gnus-completing-read
7812 methname "What backend do you want to use when respooling?"
7813 methods nil t nil 'gnus-mail-method-history))
7816 ((zerop (length (setq ms (gnus-servers-using-backend
7818 (list (intern method) ""))
7822 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7823 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7826 (error "No method given for respooling"))
7827 (if (assoc (symbol-name
7828 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7829 (gnus-methods-using 'respool))
7830 (gnus-summary-move-article n nil method)
7831 (gnus-summary-copy-article n nil method)))
7833 (defun gnus-summary-import-article (file)
7834 "Import an arbitrary file into a mail newsgroup."
7835 (interactive "fImport file: ")
7836 (let ((group gnus-newsgroup-name)
7837 (now (current-time))
7839 (unless (gnus-check-backend-function 'request-accept-article group)
7840 (error "%s does not support article importing" group))
7841 (or (file-readable-p file)
7842 (not (file-regular-p file))
7843 (error "Can't read %s" file))
7845 (set-buffer (gnus-get-buffer-create " *import file*"))
7847 (nnheader-insert-file-contents file)
7848 (goto-char (point-min))
7849 (unless (nnheader-article-p)
7850 ;; This doesn't look like an article, so we fudge some headers.
7851 (setq atts (file-attributes file)
7852 lines (count-lines (point-min) (point-max)))
7853 (insert "From: " (read-string "From: ") "\n"
7854 "Subject: " (read-string "Subject: ") "\n"
7855 "Date: " (message-make-date (nth 5 atts))
7857 "Message-ID: " (message-make-message-id) "\n"
7858 "Lines: " (int-to-string lines) "\n"
7859 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7860 (gnus-request-accept-article group nil t)
7861 (kill-buffer (current-buffer)))))
7863 (defun gnus-summary-article-posted-p ()
7864 "Say whether the current (mail) article is available from news as well.
7865 This will be the case if the article has both been mailed and posted."
7867 (let ((id (mail-header-references (gnus-summary-article-header)))
7868 (gnus-override-method (car (gnus-refer-article-methods))))
7869 (if (gnus-request-head id "")
7870 (gnus-message 2 "The current message was found on %s"
7871 gnus-override-method)
7872 (gnus-message 2 "The current message couldn't be found on %s"
7873 gnus-override-method)
7876 (defun gnus-summary-expire-articles (&optional now)
7877 "Expire all articles that are marked as expirable in the current group."
7879 (when (gnus-check-backend-function
7880 'request-expire-articles gnus-newsgroup-name)
7881 ;; This backend supports expiry.
7882 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7883 (expirable (if total
7885 ;; We need to update the info for
7886 ;; this group for `gnus-list-of-read-articles'
7887 ;; to give us the right answer.
7888 (gnus-run-hooks 'gnus-exit-group-hook)
7889 (gnus-summary-update-info)
7890 (gnus-list-of-read-articles gnus-newsgroup-name))
7891 (setq gnus-newsgroup-expirable
7892 (sort gnus-newsgroup-expirable '<))))
7893 (expiry-wait (if now 'immediate
7894 (gnus-group-find-parameter
7895 gnus-newsgroup-name 'expiry-wait)))
7896 (nnmail-expiry-target
7897 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7898 nnmail-expiry-target))
7901 ;; There are expirable articles in this group, so we run them
7902 ;; through the expiry process.
7903 (gnus-message 6 "Expiring articles...")
7904 (unless (gnus-check-group gnus-newsgroup-name)
7905 (error "Can't open server for %s" gnus-newsgroup-name))
7906 ;; The list of articles that weren't expired is returned.
7909 (let ((nnmail-expiry-wait-function nil)
7910 (nnmail-expiry-wait expiry-wait))
7911 (setq es (gnus-request-expire-articles
7912 expirable gnus-newsgroup-name)))
7913 (setq es (gnus-request-expire-articles
7914 expirable gnus-newsgroup-name)))
7916 (setq gnus-newsgroup-expirable es))
7917 ;; We go through the old list of expirable, and mark all
7918 ;; really expired articles as nonexistent.
7919 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7920 (let ((gnus-use-cache nil))
7922 (unless (memq (car expirable) es)
7923 (when (gnus-data-find (car expirable))
7924 (gnus-summary-mark-article
7925 (car expirable) gnus-canceled-mark)))
7926 (setq expirable (cdr expirable))))))
7927 (gnus-message 6 "Expiring articles...done")))))
7929 (defun gnus-summary-expire-articles-now ()
7930 "Expunge all expirable articles in the current group.
7931 This means that *all* articles that are marked as expirable will be
7932 deleted forever, right now."
7934 (or gnus-expert-user
7936 "Are you really, really, really sure you want to delete all these messages? ")
7938 (gnus-summary-expire-articles t))
7940 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7941 (defun gnus-summary-delete-article (&optional n)
7942 "Delete the N next (mail) articles.
7943 This command actually deletes articles. This is not a marking
7944 command. The article will disappear forever from your life, never to
7946 If N is negative, delete backwards.
7947 If N is nil and articles have been marked with the process mark,
7948 delete these instead."
7950 (unless (gnus-check-backend-function 'request-expire-articles
7951 gnus-newsgroup-name)
7952 (error "The current newsgroup does not support article deletion"))
7953 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7954 (error "Couldn't open server"))
7955 ;; Compute the list of articles to delete.
7956 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7958 (if (and gnus-novice-user
7959 (not (gnus-yes-or-no-p
7960 (format "Do you really want to delete %s forever? "
7961 (if (> (length articles) 1)
7962 (format "these %s articles" (length articles))
7965 ;; Delete the articles.
7966 (setq not-deleted (gnus-request-expire-articles
7967 articles gnus-newsgroup-name 'force))
7969 (gnus-summary-remove-process-mark (car articles))
7970 ;; The backend might not have been able to delete the article
7972 (unless (memq (car articles) not-deleted)
7973 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7974 (setq articles (cdr articles)))
7976 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7977 (gnus-summary-position-point)
7978 (gnus-set-mode-line 'summary)
7981 (defun gnus-summary-edit-article (&optional arg)
7982 "Edit the current article.
7983 This will have permanent effect only in mail groups.
7984 If ARG is nil, edit the decoded articles.
7985 If ARG is 1, edit the raw articles.
7986 If ARG is 2, edit the raw articles even in read-only groups.
7987 If ARG is 3, edit the articles with the current handles.
7988 Otherwise, allow editing of articles even in read-only
7991 (let (force raw current-handles)
7994 ((eq arg 1) (setq raw t))
7995 ((eq arg 2) (setq raw t
7997 ((eq arg 3) (setq current-handles
7998 (and (gnus-buffer-live-p gnus-article-buffer)
7999 (with-current-buffer gnus-article-buffer
8001 gnus-article-mime-handles
8002 (setq gnus-article-mime-handles nil))))))
8004 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
8005 (error "Can't edit the raw article in group nndraft:drafts."))
8007 (set-buffer gnus-summary-buffer)
8008 (let ((mail-parse-charset gnus-newsgroup-charset)
8009 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
8010 (gnus-set-global-variables)
8011 (when (and (not force)
8012 (gnus-group-read-only-p))
8013 (error "The current newsgroup does not support article editing"))
8014 (gnus-summary-show-article t)
8015 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
8016 (with-current-buffer gnus-article-buffer
8017 (mm-enable-multibyte-mule4)))
8018 (if (equal gnus-newsgroup-name "nndraft:drafts")
8020 (gnus-article-edit-article
8023 (let ((mbl mml-buffer-list))
8024 (setq mml-buffer-list nil)
8025 (mime-to-mml ,'current-handles)
8026 (make-local-hook 'kill-buffer-hook)
8027 (let ((mbl1 mml-buffer-list))
8028 (setq mml-buffer-list mbl)
8029 (set (make-local-variable 'mml-buffer-list) mbl1))
8030 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
8031 `(lambda (no-highlight)
8032 (let ((mail-parse-charset ',gnus-newsgroup-charset)
8033 (message-options message-options)
8034 (message-options-set-recipient)
8035 (mail-parse-ignored-charsets
8036 ',gnus-newsgroup-ignored-charsets))
8037 ,(if (not raw) '(progn
8039 (mml-destroy-buffers)
8040 (remove-hook 'kill-buffer-hook
8041 'mml-destroy-buffers t)
8042 (kill-local-variable 'mml-buffer-list)))
8043 (gnus-summary-edit-article-done
8044 ,(or (mail-header-references gnus-current-headers) "")
8045 ,(gnus-group-read-only-p)
8046 ,gnus-summary-buffer no-highlight))))))))
8048 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
8050 (defun gnus-summary-edit-article-done (&optional references read-only buffer
8052 "Make edits to the current article permanent."
8055 ;; The buffer restriction contains the entire article if it exists.
8056 (when (article-goto-body)
8057 (let ((lines (count-lines (point) (point-max)))
8058 (length (- (point-max) (point)))
8059 (case-fold-search t)
8060 (body (copy-marker (point))))
8061 (goto-char (point-min))
8062 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
8063 (delete-region (match-beginning 1) (match-end 1))
8064 (insert (number-to-string length)))
8065 (goto-char (point-min))
8066 (when (re-search-forward
8067 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
8068 (delete-region (match-beginning 1) (match-end 1))
8069 (insert (number-to-string length)))
8070 (goto-char (point-min))
8071 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
8072 (delete-region (match-beginning 1) (match-end 1))
8073 (insert (number-to-string lines))))))
8074 ;; Replace the article.
8075 (let ((buf (current-buffer)))
8077 (insert-buffer-substring buf)
8079 (if (and (not read-only)
8080 (not (gnus-request-replace-article
8081 (cdr gnus-article-current) (car gnus-article-current)
8082 (current-buffer) t)))
8083 (error "Couldn't replace article")
8084 ;; Update the summary buffer.
8086 (equal (message-tokenize-header references " ")
8087 (message-tokenize-header
8088 (or (message-fetch-field "references") "") " ")))
8089 ;; We only have to update this line.
8092 (message-narrow-to-head)
8093 (let ((head (buffer-string))
8096 (insert (format "211 %d Article retrieved.\n"
8097 (cdr gnus-article-current)))
8100 (let ((nntp-server-buffer (current-buffer)))
8101 (setq header (car (gnus-get-newsgroup-headers
8103 (set-buffer gnus-summary-buffer)
8104 gnus-newsgroup-dependencies)
8107 (set-buffer gnus-summary-buffer)
8108 (gnus-data-set-header
8109 (gnus-data-find (cdr gnus-article-current))
8111 (gnus-summary-update-article-line
8112 (cdr gnus-article-current) header))))))
8114 (set-buffer (or buffer gnus-summary-buffer))
8115 (gnus-summary-update-article (cdr gnus-article-current)))
8116 ;; Prettify the article buffer again.
8117 (unless no-highlight
8119 (set-buffer gnus-article-buffer)
8120 ;;;!!! Fix this -- article should be rehighlighted.
8121 ;;;(gnus-run-hooks 'gnus-article-display-hook)
8122 (set-buffer gnus-original-article-buffer)
8123 (gnus-request-article
8124 (cdr gnus-article-current)
8125 (car gnus-article-current) (current-buffer))))
8126 ;; Prettify the summary buffer line.
8127 (when (gnus-visual-p 'summary-highlight 'highlight)
8128 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
8130 (defun gnus-summary-edit-wash (key)
8131 "Perform editing command KEY in the article buffer."
8135 (message "%s" (concat (this-command-keys) "- "))
8138 (gnus-summary-edit-article)
8139 (execute-kbd-macro (concat (this-command-keys) key))
8140 (gnus-article-edit-done))
8144 (defun gnus-summary-respool-query (&optional silent trace)
8145 "Query where the respool algorithm would put this article."
8147 (let (gnus-mark-article-hook)
8148 (gnus-summary-select-article)
8150 (set-buffer gnus-original-article-buffer)
8152 (message-narrow-to-head)
8153 (let ((groups (nnmail-article-group 'identity trace)))
8156 (message "This message would go to %s"
8157 (mapconcat 'car groups ", "))
8158 (message "This message would go to no groups"))
8161 (defun gnus-summary-respool-trace ()
8162 "Trace where the respool algorithm would put this article.
8163 Display a buffer showing all fancy splitting patterns which matched."
8165 (gnus-summary-respool-query nil t))
8167 ;; Summary marking commands.
8169 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
8170 "Mark articles which has the same subject as read, and then select the next.
8171 If UNMARK is positive, remove any kind of mark.
8172 If UNMARK is negative, tick articles."
8175 (setq unmark (prefix-numeric-value unmark)))
8177 (gnus-summary-mark-same-subject
8178 (gnus-summary-article-subject) unmark)))
8179 ;; Select next unread article. If auto-select-same mode, should
8180 ;; select the first unread article.
8181 (gnus-summary-next-article t (and gnus-auto-select-same
8182 (gnus-summary-article-subject)))
8183 (gnus-message 7 "%d article%s marked as %s"
8184 count (if (= count 1) " is" "s are")
8185 (if unmark "unread" "read"))))
8187 (defun gnus-summary-kill-same-subject (&optional unmark)
8188 "Mark articles which has the same subject as read.
8189 If UNMARK is positive, remove any kind of mark.
8190 If UNMARK is negative, tick articles."
8193 (setq unmark (prefix-numeric-value unmark)))
8195 (gnus-summary-mark-same-subject
8196 (gnus-summary-article-subject) unmark)))
8197 ;; If marked as read, go to next unread subject.
8199 ;; Go to next unread subject.
8200 (gnus-summary-next-subject 1 t))
8201 (gnus-message 7 "%d articles are marked as %s"
8202 count (if unmark "unread" "read"))))
8204 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8205 "Mark articles with same SUBJECT as read, and return marked number.
8206 If optional argument UNMARK is positive, remove any kinds of marks.
8207 If optional argument UNMARK is negative, mark articles as unread instead."
8211 ((null unmark) ; Mark as read.
8214 (gnus-summary-mark-article-as-read gnus-killed-mark)
8215 (gnus-summary-show-thread) t)
8216 (gnus-summary-find-subject subject))
8217 (setq count (1+ count))))
8218 ((> unmark 0) ; Tick.
8221 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8222 (gnus-summary-show-thread) t)
8223 (gnus-summary-find-subject subject))
8224 (setq count (1+ count))))
8225 (t ; Mark as unread.
8228 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8229 (gnus-summary-show-thread) t)
8230 (gnus-summary-find-subject subject))
8231 (setq count (1+ count)))))
8232 (gnus-set-mode-line 'summary)
8233 ;; Return the number of marked articles.
8236 (defun gnus-summary-mark-as-processable (n &optional unmark)
8237 "Set the process mark on the next N articles.
8238 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8239 the process mark instead. The difference between N and the actual
8240 number of articles marked is returned."
8242 (let ((backward (< n 0))
8247 (gnus-summary-remove-process-mark
8248 (gnus-summary-article-number))
8249 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8250 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8253 (gnus-message 7 "No more articles"))
8254 (gnus-summary-recenter)
8255 (gnus-summary-position-point)
8258 (defun gnus-summary-unmark-as-processable (n)
8259 "Remove the process mark from the next N articles.
8260 If N is negative, unmark backward instead. The difference between N and
8261 the actual number of articles unmarked is returned."
8263 (gnus-summary-mark-as-processable n t))
8265 (defun gnus-summary-unmark-all-processable ()
8266 "Remove the process mark from all articles."
8269 (while gnus-newsgroup-processable
8270 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8271 (gnus-summary-position-point))
8273 (defun gnus-summary-mark-as-expirable (n)
8274 "Mark N articles forward as expirable.
8275 If N is negative, mark backward instead. The difference between N and
8276 the actual number of articles marked is returned."
8278 (gnus-summary-mark-forward n gnus-expirable-mark))
8280 (defun gnus-summary-mark-article-as-replied (article)
8281 "Mark ARTICLE replied and update the summary line."
8282 (push article gnus-newsgroup-replied)
8283 (let ((buffer-read-only nil))
8284 (when (gnus-summary-goto-subject article nil t)
8285 (gnus-summary-update-secondary-mark article))))
8287 (defun gnus-summary-set-bookmark (article)
8288 "Set a bookmark in current article."
8289 (interactive (list (gnus-summary-article-number)))
8290 (when (or (not (get-buffer gnus-article-buffer))
8291 (not gnus-current-article)
8292 (not gnus-article-current)
8293 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8294 (error "No current article selected"))
8295 ;; Remove old bookmark, if one exists.
8296 (let ((old (assq article gnus-newsgroup-bookmarks)))
8298 (setq gnus-newsgroup-bookmarks
8299 (delq old gnus-newsgroup-bookmarks))))
8300 ;; Set the new bookmark, which is on the form
8301 ;; (article-number . line-number-in-body).
8305 (set-buffer gnus-article-buffer)
8309 (goto-char (point-min))
8310 (search-forward "\n\n" nil t)
8313 gnus-newsgroup-bookmarks)
8314 (gnus-message 6 "A bookmark has been added to the current article."))
8316 (defun gnus-summary-remove-bookmark (article)
8317 "Remove the bookmark from the current article."
8318 (interactive (list (gnus-summary-article-number)))
8319 ;; Remove old bookmark, if one exists.
8320 (let ((old (assq article gnus-newsgroup-bookmarks)))
8323 (setq gnus-newsgroup-bookmarks
8324 (delq old gnus-newsgroup-bookmarks))
8325 (gnus-message 6 "Removed bookmark."))
8326 (gnus-message 6 "No bookmark in current article."))))
8328 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8329 (defun gnus-summary-mark-as-dormant (n)
8330 "Mark N articles forward as dormant.
8331 If N is negative, mark backward instead. The difference between N and
8332 the actual number of articles marked is returned."
8334 (gnus-summary-mark-forward n gnus-dormant-mark))
8336 (defun gnus-summary-set-process-mark (article)
8337 "Set the process mark on ARTICLE and update the summary line."
8338 (setq gnus-newsgroup-processable
8340 (delq article gnus-newsgroup-processable)))
8341 (when (gnus-summary-goto-subject article)
8342 (gnus-summary-show-thread)
8343 (gnus-summary-goto-subject article)
8344 (gnus-summary-update-secondary-mark article)))
8346 (defun gnus-summary-remove-process-mark (article)
8347 "Remove the process mark from ARTICLE and update the summary line."
8348 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8349 (when (gnus-summary-goto-subject article)
8350 (gnus-summary-show-thread)
8351 (gnus-summary-goto-subject article)
8352 (gnus-summary-update-secondary-mark article)))
8354 (defun gnus-summary-set-saved-mark (article)
8355 "Set the process mark on ARTICLE and update the summary line."
8356 (push article gnus-newsgroup-saved)
8357 (when (gnus-summary-goto-subject article)
8358 (gnus-summary-update-secondary-mark article)))
8360 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8361 "Mark N articles as read forwards.
8362 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8363 The difference between N and the actual number of articles marked is
8365 Iff NO-EXPIRE, auto-expiry will be inhibited."
8367 (gnus-summary-show-thread)
8368 (let ((backward (< n 0))
8369 (gnus-summary-goto-unread
8370 (and gnus-summary-goto-unread
8371 (not (eq gnus-summary-goto-unread 'never))
8372 (not (memq mark (list gnus-unread-mark
8373 gnus-ticked-mark gnus-dormant-mark)))))
8375 (mark (or mark gnus-del-mark)))
8377 (gnus-summary-mark-article nil mark no-expire)
8378 (zerop (gnus-summary-next-subject
8380 (and gnus-summary-goto-unread
8381 (not (eq gnus-summary-goto-unread 'never)))
8385 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8386 (gnus-summary-recenter)
8387 (gnus-summary-position-point)
8388 (gnus-set-mode-line 'summary)
8391 (defun gnus-summary-mark-article-as-read (mark)
8392 "Mark the current article quickly as read with MARK."
8393 (let ((article (gnus-summary-article-number)))
8394 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8395 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8396 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8397 (push (cons article mark) gnus-newsgroup-reads)
8398 ;; Possibly remove from cache, if that is used.
8399 (when gnus-use-cache
8400 (gnus-cache-enter-remove-article article))
8401 ;; Allow the backend to change the mark.
8402 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8403 ;; Check for auto-expiry.
8404 (when (and gnus-newsgroup-auto-expire
8405 (memq mark gnus-auto-expirable-marks))
8406 (setq mark gnus-expirable-mark)
8407 ;; Let the backend know about the mark change.
8408 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8409 (push article gnus-newsgroup-expirable))
8410 ;; Set the mark in the buffer.
8411 (gnus-summary-update-mark mark 'unread)
8414 (defun gnus-summary-mark-article-as-unread (mark)
8415 "Mark the current article quickly as unread with MARK."
8416 (let* ((article (gnus-summary-article-number))
8417 (old-mark (gnus-summary-article-mark article)))
8418 ;; Allow the backend to change the mark.
8419 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8420 (if (eq mark old-mark)
8424 (gnus-error 1 "Can't mark negative article numbers")
8426 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8427 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8428 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8429 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8430 (cond ((= mark gnus-ticked-mark)
8431 (push article gnus-newsgroup-marked))
8432 ((= mark gnus-dormant-mark)
8433 (push article gnus-newsgroup-dormant))
8435 (push article gnus-newsgroup-unreads)))
8436 (gnus-pull article gnus-newsgroup-reads)
8438 ;; See whether the article is to be put in the cache.
8440 (vectorp (gnus-summary-article-header article))
8442 (gnus-cache-possibly-enter-article
8443 gnus-newsgroup-name article
8444 (= mark gnus-ticked-mark)
8445 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8448 (gnus-summary-update-mark mark 'unread)
8451 (defun gnus-summary-mark-article (&optional article mark no-expire)
8452 "Mark ARTICLE with MARK. MARK can be any character.
8453 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8454 `??' (dormant) and `?E' (expirable).
8455 If MARK is nil, then the default character `?r' is used.
8456 If ARTICLE is nil, then the article on the current line will be
8458 Iff NO-EXPIRE, auto-expiry will be inhibited."
8459 ;; The mark might be a string.
8460 (when (stringp mark)
8461 (setq mark (aref mark 0)))
8462 ;; If no mark is given, then we check auto-expiring.
8464 (setq mark gnus-del-mark))
8465 (when (and (not no-expire)
8466 gnus-newsgroup-auto-expire
8467 (memq mark gnus-auto-expirable-marks))
8468 (setq mark gnus-expirable-mark))
8469 (let ((article (or article (gnus-summary-article-number)))
8470 (old-mark (gnus-summary-article-mark article)))
8471 ;; Allow the backend to change the mark.
8472 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8473 (if (eq mark old-mark)
8476 (error "No article on current line"))
8477 (if (not (if (or (= mark gnus-unread-mark)
8478 (= mark gnus-ticked-mark)
8479 (= mark gnus-dormant-mark))
8480 (gnus-mark-article-as-unread article mark)
8481 (gnus-mark-article-as-read article mark)))
8483 ;; See whether the article is to be put in the cache.
8485 (not (= mark gnus-canceled-mark))
8486 (vectorp (gnus-summary-article-header article))
8488 (gnus-cache-possibly-enter-article
8489 gnus-newsgroup-name article
8490 (= mark gnus-ticked-mark)
8491 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8493 (when (gnus-summary-goto-subject article nil t)
8494 (let ((buffer-read-only nil))
8495 (gnus-summary-show-thread)
8497 (gnus-summary-update-mark mark 'unread)
8500 (defun gnus-summary-update-secondary-mark (article)
8501 "Update the secondary (read, process, cache) mark."
8502 (gnus-summary-update-mark
8503 (cond ((memq article gnus-newsgroup-processable)
8505 ((memq article gnus-newsgroup-cached)
8507 ((memq article gnus-newsgroup-replied)
8509 ((memq article gnus-newsgroup-saved)
8511 (t gnus-unread-mark))
8513 (when (gnus-visual-p 'summary-highlight 'highlight)
8514 (gnus-run-hooks 'gnus-summary-update-hook))
8517 (defun gnus-summary-update-mark (mark type)
8518 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8519 (buffer-read-only nil))
8520 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8522 (when (looking-at "\r")
8524 (when (<= (+ forward (point)) (point-max))
8525 ;; Go to the right position on the line.
8526 (goto-char (+ forward (point)))
8527 ;; Replace the old mark with the new mark.
8528 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8529 ;; Optionally update the marks by some user rule.
8530 (when (eq type 'unread)
8532 (gnus-data-find (gnus-summary-article-number)) mark)
8533 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8535 (defun gnus-mark-article-as-read (article &optional mark)
8536 "Enter ARTICLE in the pertinent lists and remove it from others."
8537 ;; Make the article expirable.
8538 (let ((mark (or mark gnus-del-mark)))
8539 (if (= mark gnus-expirable-mark)
8540 (push article gnus-newsgroup-expirable)
8541 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8542 ;; Remove from unread and marked lists.
8543 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8544 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8545 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8546 (push (cons article mark) gnus-newsgroup-reads)
8547 ;; Possibly remove from cache, if that is used.
8548 (when gnus-use-cache
8549 (gnus-cache-enter-remove-article article))
8552 (defun gnus-mark-article-as-unread (article &optional mark)
8553 "Enter ARTICLE in the pertinent lists and remove it from others."
8554 (let ((mark (or mark gnus-ticked-mark)))
8557 (gnus-error 1 "Can't mark negative article numbers")
8559 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8560 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8561 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8562 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8564 ;; Unsuppress duplicates?
8565 (when gnus-suppress-duplicates
8566 (gnus-dup-unsuppress-article article))
8568 (cond ((= mark gnus-ticked-mark)
8569 (push article gnus-newsgroup-marked))
8570 ((= mark gnus-dormant-mark)
8571 (push article gnus-newsgroup-dormant))
8573 (push article gnus-newsgroup-unreads)))
8574 (gnus-pull article gnus-newsgroup-reads)
8577 (defalias 'gnus-summary-mark-as-unread-forward
8578 'gnus-summary-tick-article-forward)
8579 (make-obsolete 'gnus-summary-mark-as-unread-forward
8580 'gnus-summary-tick-article-forward)
8581 (defun gnus-summary-tick-article-forward (n)
8582 "Tick N articles forwards.
8583 If N is negative, tick backwards instead.
8584 The difference between N and the number of articles ticked is returned."
8586 (gnus-summary-mark-forward n gnus-ticked-mark))
8588 (defalias 'gnus-summary-mark-as-unread-backward
8589 'gnus-summary-tick-article-backward)
8590 (make-obsolete 'gnus-summary-mark-as-unread-backward
8591 'gnus-summary-tick-article-backward)
8592 (defun gnus-summary-tick-article-backward (n)
8593 "Tick N articles backwards.
8594 The difference between N and the number of articles ticked is returned."
8596 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8598 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8599 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8600 (defun gnus-summary-tick-article (&optional article clear-mark)
8601 "Mark current article as unread.
8602 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8603 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8605 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8608 (defun gnus-summary-mark-as-read-forward (n)
8609 "Mark N articles as read forwards.
8610 If N is negative, mark backwards instead.
8611 The difference between N and the actual number of articles marked is
8614 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8616 (defun gnus-summary-mark-as-read-backward (n)
8617 "Mark the N articles as read backwards.
8618 The difference between N and the actual number of articles marked is
8621 (gnus-summary-mark-forward
8622 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8624 (defun gnus-summary-mark-as-read (&optional article mark)
8625 "Mark current article as read.
8626 ARTICLE specifies the article to be marked as read.
8627 MARK specifies a string to be inserted at the beginning of the line."
8628 (gnus-summary-mark-article article mark))
8630 (defun gnus-summary-clear-mark-forward (n)
8631 "Clear marks from N articles forward.
8632 If N is negative, clear backward instead.
8633 The difference between N and the number of marks cleared is returned."
8635 (gnus-summary-mark-forward n gnus-unread-mark))
8637 (defun gnus-summary-clear-mark-backward (n)
8638 "Clear marks from N articles backward.
8639 The difference between N and the number of marks cleared is returned."
8641 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8643 (defun gnus-summary-mark-unread-as-read ()
8644 "Intended to be used by `gnus-summary-mark-article-hook'."
8645 (when (memq gnus-current-article gnus-newsgroup-unreads)
8646 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8648 (defun gnus-summary-mark-read-and-unread-as-read ()
8649 "Intended to be used by `gnus-summary-mark-article-hook'."
8650 (let ((mark (gnus-summary-article-mark)))
8651 (when (or (gnus-unread-mark-p mark)
8652 (gnus-read-mark-p mark))
8653 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8655 (defun gnus-summary-mark-region-as-read (point mark all)
8656 "Mark all unread articles between point and mark as read.
8657 If given a prefix, mark all articles between point and mark as read,
8658 even ticked and dormant ones."
8659 (interactive "r\nP")
8668 (memq (setq article (gnus-summary-article-number))
8669 gnus-newsgroup-unreads))
8670 (gnus-summary-mark-article article gnus-del-mark))
8672 (gnus-summary-find-next))))))
8674 (defun gnus-summary-mark-below (score mark)
8675 "Mark articles with score less than SCORE with MARK."
8676 (interactive "P\ncMark: ")
8677 (setq score (if score
8678 (prefix-numeric-value score)
8679 (or gnus-summary-default-score 0)))
8681 (set-buffer gnus-summary-buffer)
8682 (goto-char (point-min))
8685 (and (< (gnus-summary-article-score) score)
8686 (gnus-summary-mark-article nil mark))
8687 (gnus-summary-find-next)))))
8689 (defun gnus-summary-kill-below (&optional score)
8690 "Mark articles with score below SCORE as read."
8692 (gnus-summary-mark-below score gnus-killed-mark))
8694 (defun gnus-summary-clear-above (&optional score)
8695 "Clear all marks from articles with score above SCORE."
8697 (gnus-summary-mark-above score gnus-unread-mark))
8699 (defun gnus-summary-tick-above (&optional score)
8700 "Tick all articles with score above SCORE."
8702 (gnus-summary-mark-above score gnus-ticked-mark))
8704 (defun gnus-summary-mark-above (score mark)
8705 "Mark articles with score over SCORE with MARK."
8706 (interactive "P\ncMark: ")
8707 (setq score (if score
8708 (prefix-numeric-value score)
8709 (or gnus-summary-default-score 0)))
8711 (set-buffer gnus-summary-buffer)
8712 (goto-char (point-min))
8714 (when (> (gnus-summary-article-score) score)
8715 (gnus-summary-mark-article nil mark))
8717 (gnus-summary-find-next)))))
8719 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8720 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8721 (defun gnus-summary-limit-include-expunged (&optional no-error)
8722 "Display all the hidden articles that were expunged for low scores."
8724 (let ((buffer-read-only nil))
8725 (let ((scored gnus-newsgroup-scored)
8728 (unless (gnus-summary-goto-subject (caar scored))
8729 (and (setq h (gnus-summary-article-header (caar scored)))
8730 (< (cdar scored) gnus-summary-expunge-below)
8732 (setq scored (cdr scored)))
8734 (when (not no-error)
8735 (error "No expunged articles hidden"))
8736 (goto-char (point-min))
8737 (gnus-summary-prepare-unthreaded (nreverse headers))
8738 (goto-char (point-min))
8739 (gnus-summary-position-point)
8742 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8743 "Mark all unread articles in this newsgroup as read.
8744 If prefix argument ALL is non-nil, ticked and dormant articles will
8745 also be marked as read.
8746 If QUIETLY is non-nil, no questions will be asked.
8747 If TO-HERE is non-nil, it should be a point in the buffer. All
8748 articles before this point will be marked as read.
8749 Note that this function will only catch up the unread article
8750 in the current summary buffer limitation.
8751 The number of articles marked as read is returned."
8756 (not gnus-interactive-catchup) ;Without confirmation?
8760 "Mark absolutely all articles as read? "
8761 "Mark all unread articles as read? ")))
8763 (not gnus-newsgroup-adaptive)
8764 (not gnus-newsgroup-auto-expire)
8765 (not gnus-suppress-duplicates)
8766 (or (not gnus-use-cache)
8767 (eq gnus-use-cache 'passive)))
8770 (setq gnus-newsgroup-marked nil
8771 gnus-newsgroup-dormant nil))
8772 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8773 ;; We actually mark all articles as canceled, which we
8774 ;; have to do when using auto-expiry or adaptive scoring.
8775 (gnus-summary-show-all-threads)
8776 (when (gnus-summary-first-subject (not all) t)
8778 (if to-here (< (point) to-here) t)
8779 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8780 (gnus-summary-find-next (not all) nil nil t))))
8781 (gnus-set-mode-line 'summary))
8783 (gnus-summary-position-point)))
8785 (defun gnus-summary-catchup-to-here (&optional all)
8786 "Mark all unticked articles before the current one as read.
8787 If ALL is non-nil, also mark ticked and dormant articles as read."
8790 (gnus-save-hidden-threads
8791 (let ((beg (point)))
8792 ;; We check that there are unread articles.
8793 (when (or all (gnus-summary-find-prev))
8794 (gnus-summary-catchup all t beg)))))
8795 (gnus-summary-position-point))
8797 (defun gnus-summary-catchup-all (&optional quietly)
8798 "Mark all articles in this newsgroup as read."
8800 (gnus-summary-catchup t quietly))
8802 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8803 "Mark all unread articles in this group as read, then exit.
8804 If prefix argument ALL is non-nil, all articles are marked as read."
8806 (when (gnus-summary-catchup all quietly nil 'fast)
8807 ;; Select next newsgroup or exit.
8808 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8809 (eq gnus-auto-select-next 'quietly))
8810 (gnus-summary-next-group nil)
8811 (gnus-summary-exit))))
8813 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8814 "Mark all articles in this newsgroup as read, and then exit."
8816 (gnus-summary-catchup-and-exit t quietly))
8818 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8819 "Mark all articles in this group as read and select the next group.
8820 If given a prefix, mark all articles, unread as well as ticked, as
8824 (gnus-summary-catchup all))
8825 (gnus-summary-next-group))
8831 (defmacro gnus-with-article (article &rest forms)
8832 "Select ARTICLE and perform FORMS in the original article buffer.
8833 Then replace the article with the result."
8835 ;; We don't want the article to be marked as read.
8836 (let (gnus-mark-article-hook)
8837 (gnus-summary-select-article t t nil ,article))
8838 (set-buffer gnus-original-article-buffer)
8840 (if (not (gnus-check-backend-function
8841 'request-replace-article (car gnus-article-current)))
8842 (gnus-message 5 "Read-only group; not replacing")
8843 (unless (gnus-request-replace-article
8844 ,article (car gnus-article-current)
8846 (error "Couldn't replace article")))
8847 ;; The cache and backlog have to be flushed somewhat.
8848 (when gnus-keep-backlog
8849 (gnus-backlog-remove-article
8850 (car gnus-article-current) (cdr gnus-article-current)))
8851 (when gnus-use-cache
8852 (gnus-cache-update-article
8853 (car gnus-article-current) (cdr gnus-article-current)))))
8855 (put 'gnus-with-article 'lisp-indent-function 1)
8856 (put 'gnus-with-article 'edebug-form-spec '(form body))
8858 ;; Thread-based commands.
8860 (defun gnus-summary-articles-in-thread (&optional article)
8861 "Return a list of all articles in the current thread.
8862 If ARTICLE is non-nil, return all articles in the thread that starts
8864 (let* ((article (or article (gnus-summary-article-number)))
8865 (data (gnus-data-find-list article))
8866 (top-level (gnus-data-level (car data)))
8868 (cond ((null gnus-thread-operation-ignore-subject)
8869 (gnus-simplify-subject-re
8870 (mail-header-subject (gnus-data-header (car data)))))
8871 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8872 (gnus-simplify-subject-fuzzy
8873 (mail-header-subject (gnus-data-header (car data)))))
8875 (end-point (save-excursion
8876 (if (gnus-summary-go-to-next-thread)
8877 (point) (point-max))))
8880 (< (gnus-data-pos (car data)) end-point))
8881 (when (or (not top-subject)
8882 (string= top-subject
8883 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8884 (gnus-simplify-subject-fuzzy
8885 (mail-header-subject
8886 (gnus-data-header (car data))))
8887 (gnus-simplify-subject-re
8888 (mail-header-subject
8889 (gnus-data-header (car data)))))))
8890 (push (gnus-data-number (car data)) articles))
8891 (unless (and (setq data (cdr data))
8892 (> (gnus-data-level (car data)) top-level))
8894 ;; Return the list of articles.
8895 (nreverse articles)))
8897 (defun gnus-summary-rethread-current ()
8898 "Rethread the thread the current article is part of."
8900 (let* ((gnus-show-threads t)
8901 (article (gnus-summary-article-number))
8902 (id (mail-header-id (gnus-summary-article-header)))
8903 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8905 (error "No article on the current line"))
8906 (gnus-rebuild-thread id)
8907 (gnus-summary-goto-subject article)))
8909 (defun gnus-summary-reparent-thread ()
8910 "Make the current article child of the marked (or previous) article.
8912 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8913 is non-nil or the Subject: of both articles are the same."
8915 (unless (not (gnus-group-read-only-p))
8916 (error "The current newsgroup does not support article editing"))
8917 (unless (<= (length gnus-newsgroup-processable) 1)
8918 (error "No more than one article may be marked"))
8919 (save-window-excursion
8920 (let ((gnus-article-buffer " *reparent*")
8921 (current-article (gnus-summary-article-number))
8922 ;; First grab the marked article, otherwise one line up.
8923 (parent-article (if (not (null gnus-newsgroup-processable))
8924 (car gnus-newsgroup-processable)
8926 (if (eq (forward-line -1) 0)
8927 (gnus-summary-article-number)
8928 (error "Beginning of summary buffer"))))))
8929 (unless (not (eq current-article parent-article))
8930 (error "An article may not be self-referential"))
8931 (let ((message-id (mail-header-id
8932 (gnus-summary-article-header parent-article))))
8933 (unless (and message-id (not (equal message-id "")))
8934 (error "No message-id in desired parent"))
8935 (gnus-with-article current-article
8937 (goto-char (point-min))
8938 (message-narrow-to-head)
8939 (if (re-search-forward "^References: " nil t)
8941 (re-search-forward "^[^ \t]" nil t)
8944 (insert " " message-id))
8945 (insert "References: " message-id "\n"))))
8946 (set-buffer gnus-summary-buffer)
8947 (gnus-summary-unmark-all-processable)
8948 (gnus-summary-update-article current-article)
8949 (gnus-summary-rethread-current)
8950 (gnus-message 3 "Article %d is now the child of article %d"
8951 current-article parent-article)))))
8953 (defun gnus-summary-toggle-threads (&optional arg)
8954 "Toggle showing conversation threads.
8955 If ARG is positive number, turn showing conversation threads on."
8957 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8958 (setq gnus-show-threads
8959 (if (null arg) (not gnus-show-threads)
8960 (> (prefix-numeric-value arg) 0)))
8961 (gnus-summary-prepare)
8962 (gnus-summary-goto-subject current)
8963 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8964 (gnus-summary-position-point)))
8966 (defun gnus-summary-show-all-threads ()
8970 (let ((buffer-read-only nil))
8971 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8972 (gnus-summary-position-point))
8974 (defun gnus-summary-show-thread ()
8975 "Show thread subtrees.
8976 Returns nil if no thread was there to be shown."
8978 (let ((buffer-read-only nil)
8980 ;; first goto end then to beg, to have point at beg after let
8981 (end (progn (end-of-line) (point)))
8982 (beg (progn (beginning-of-line) (point))))
8984 ;; Any hidden lines here?
8985 (search-forward "\r" end t)
8986 (subst-char-in-region beg end ?\^M ?\n t)
8988 (gnus-summary-position-point))))
8990 (defun gnus-summary-hide-all-threads ()
8991 "Hide all thread subtrees."
8994 (goto-char (point-min))
8995 (gnus-summary-hide-thread)
8996 (while (zerop (gnus-summary-next-thread 1 t))
8997 (gnus-summary-hide-thread)))
8998 (gnus-summary-position-point))
9000 (defun gnus-summary-hide-thread ()
9001 "Hide thread subtrees.
9002 Returns nil if no threads were there to be hidden."
9004 (let ((buffer-read-only nil)
9006 (article (gnus-summary-article-number)))
9008 ;; Go forward until either the buffer ends or the subthread
9010 (when (and (not (eobp))
9011 (or (zerop (gnus-summary-next-thread 1 t))
9012 (goto-char (point-max))))
9014 (if (and (> (point) start)
9015 (search-backward "\n" start t))
9017 (subst-char-in-region start (point) ?\n ?\^M)
9018 (gnus-summary-goto-subject article))
9022 (defun gnus-summary-go-to-next-thread (&optional previous)
9023 "Go to the same level (or less) next thread.
9024 If PREVIOUS is non-nil, go to previous thread instead.
9025 Return the article number moved to, or nil if moving was impossible."
9026 (let ((level (gnus-summary-thread-level))
9027 (way (if previous -1 1))
9030 (while (and (not (eobp))
9031 (< level (gnus-summary-thread-level)))
9039 (gnus-summary-article-number)
9042 (defun gnus-summary-next-thread (n &optional silent)
9043 "Go to the same level next N'th thread.
9044 If N is negative, search backward instead.
9045 Returns the difference between N and the number of skips actually
9048 If SILENT, don't output messages."
9050 (let ((backward (< n 0))
9053 (gnus-summary-go-to-next-thread backward))
9056 (gnus-summary-position-point))
9057 (when (and (not silent) (/= 0 n))
9058 (gnus-message 7 "No more threads"))
9061 (defun gnus-summary-prev-thread (n)
9062 "Go to the same level previous N'th thread.
9063 Returns the difference between N and the number of skips actually
9066 (gnus-summary-next-thread (- n)))
9068 (defun gnus-summary-go-down-thread ()
9069 "Go down one level in the current thread."
9070 (let ((children (gnus-summary-article-children)))
9072 (gnus-summary-goto-subject (car children)))))
9074 (defun gnus-summary-go-up-thread ()
9075 "Go up one level in the current thread."
9076 (let ((parent (gnus-summary-article-parent)))
9078 (gnus-summary-goto-subject parent))))
9080 (defun gnus-summary-down-thread (n)
9081 "Go down thread N steps.
9082 If N is negative, go up instead.
9083 Returns the difference between N and how many steps down that were
9089 (if up (gnus-summary-go-up-thread)
9090 (gnus-summary-go-down-thread)))
9092 (gnus-summary-position-point)
9094 (gnus-message 7 "Can't go further"))
9097 (defun gnus-summary-up-thread (n)
9098 "Go up thread N steps.
9099 If N is negative, go up instead.
9100 Returns the difference between N and how many steps down that were
9103 (gnus-summary-down-thread (- n)))
9105 (defun gnus-summary-top-thread ()
9106 "Go to the top of the thread."
9108 (while (gnus-summary-go-up-thread))
9109 (gnus-summary-article-number))
9111 (defun gnus-summary-kill-thread (&optional unmark)
9112 "Mark articles under current thread as read.
9113 If the prefix argument is positive, remove any kinds of marks.
9114 If the prefix argument is negative, tick articles instead."
9117 (setq unmark (prefix-numeric-value unmark)))
9118 (let ((articles (gnus-summary-articles-in-thread)))
9120 ;; Expand the thread.
9121 (gnus-summary-show-thread)
9122 ;; Mark all the articles.
9124 (gnus-summary-goto-subject (car articles))
9125 (cond ((null unmark)
9126 (gnus-summary-mark-article-as-read gnus-killed-mark))
9128 (gnus-summary-mark-article-as-unread gnus-unread-mark))
9130 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
9131 (setq articles (cdr articles))))
9132 ;; Hide killed subtrees.
9134 gnus-thread-hide-killed
9135 (gnus-summary-hide-thread))
9136 ;; If marked as read, go to next unread subject.
9138 ;; Go to next unread subject.
9139 (gnus-summary-next-subject 1 t)))
9140 (gnus-set-mode-line 'summary))
9142 ;; Summary sorting commands
9144 (defun gnus-summary-sort-by-number (&optional reverse)
9145 "Sort the summary buffer by article number.
9146 Argument REVERSE means reverse order."
9148 (gnus-summary-sort 'number reverse))
9150 (defun gnus-summary-sort-by-author (&optional reverse)
9151 "Sort the summary buffer by author name alphabetically.
9152 If `case-fold-search' is non-nil, case of letters is ignored.
9153 Argument REVERSE means reverse order."
9155 (gnus-summary-sort 'author reverse))
9157 (defun gnus-summary-sort-by-subject (&optional reverse)
9158 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
9159 If `case-fold-search' is non-nil, case of letters is ignored.
9160 Argument REVERSE means reverse order."
9162 (gnus-summary-sort 'subject reverse))
9164 (defun gnus-summary-sort-by-date (&optional reverse)
9165 "Sort the summary buffer by date.
9166 Argument REVERSE means reverse order."
9168 (gnus-summary-sort 'date reverse))
9170 (defun gnus-summary-sort-by-score (&optional reverse)
9171 "Sort the summary buffer by score.
9172 Argument REVERSE means reverse order."
9174 (gnus-summary-sort 'score reverse))
9176 (defun gnus-summary-sort-by-lines (&optional reverse)
9177 "Sort the summary buffer by the number of lines.
9178 Argument REVERSE means reverse order."
9180 (gnus-summary-sort 'lines reverse))
9182 (defun gnus-summary-sort-by-chars (&optional reverse)
9183 "Sort the summary buffer by article length.
9184 Argument REVERSE means reverse order."
9186 (gnus-summary-sort 'chars reverse))
9188 (defun gnus-summary-sort (predicate reverse)
9189 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
9190 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
9191 (article (intern (format "gnus-article-sort-by-%s" predicate)))
9192 (gnus-thread-sort-functions
9197 (gnus-sort-gathered-threads-function
9198 gnus-thread-sort-functions)
9199 (gnus-article-sort-functions
9205 (gnus-summary-prepare-hook nil))
9206 ;; We do the sorting by regenerating the threads.
9207 (gnus-summary-prepare)
9208 ;; Hide subthreads if needed.
9209 (when (and gnus-show-threads gnus-thread-hide-subtree)
9210 (gnus-summary-hide-all-threads))))
9212 ;; Summary saving commands.
9214 (defun gnus-summary-save-article (&optional n not-saved)
9215 "Save the current article using the default saver function.
9216 If N is a positive number, save the N next articles.
9217 If N is a negative number, save the N previous articles.
9218 If N is nil and any articles have been marked with the process mark,
9219 save those articles instead.
9220 The variable `gnus-default-article-saver' specifies the saver function."
9222 (let* ((articles (gnus-summary-work-articles n))
9223 (save-buffer (save-excursion
9224 (nnheader-set-temp-buffer " *Gnus Save*")))
9225 (num (length articles))
9227 (dolist (article articles)
9228 (setq header (gnus-summary-article-header article))
9229 (if (not (vectorp header))
9230 ;; This is a pseudo-article.
9231 (if (assq 'name header)
9232 (gnus-copy-file (cdr (assq 'name header)))
9233 (gnus-message 1 "Article %d is unsaveable" article))
9234 ;; This is a real article.
9235 (save-window-excursion
9236 (gnus-summary-select-article t nil nil article))
9238 (set-buffer save-buffer)
9240 (insert-buffer-substring gnus-original-article-buffer))
9241 (setq file (gnus-article-save save-buffer file num))
9242 (gnus-summary-remove-process-mark article)
9244 (gnus-summary-set-saved-mark article))))
9245 (gnus-kill-buffer save-buffer)
9246 (gnus-summary-position-point)
9247 (gnus-set-mode-line 'summary)
9250 (defun gnus-summary-pipe-output (&optional arg)
9251 "Pipe the current article to a subprocess.
9252 If N is a positive number, pipe the N next articles.
9253 If N is a negative number, pipe the N previous articles.
9254 If N is nil and any articles have been marked with the process mark,
9255 pipe those articles instead."
9257 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9258 (gnus-summary-save-article arg t))
9259 (gnus-configure-windows 'pipe))
9261 (defun gnus-summary-save-article-mail (&optional arg)
9262 "Append the current article to an mail file.
9263 If N is a positive number, save the N next articles.
9264 If N is a negative number, save the N previous articles.
9265 If N is nil and any articles have been marked with the process mark,
9266 save those articles instead."
9268 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9269 (gnus-summary-save-article arg)))
9271 (defun gnus-summary-save-article-rmail (&optional arg)
9272 "Append the current article to an rmail file.
9273 If N is a positive number, save the N next articles.
9274 If N is a negative number, save the N previous articles.
9275 If N is nil and any articles have been marked with the process mark,
9276 save those articles instead."
9278 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9279 (gnus-summary-save-article arg)))
9281 (defun gnus-summary-save-article-file (&optional arg)
9282 "Append the current article to a file.
9283 If N is a positive number, save the N next articles.
9284 If N is a negative number, save the N previous articles.
9285 If N is nil and any articles have been marked with the process mark,
9286 save those articles instead."
9288 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9289 (gnus-summary-save-article arg)))
9291 (defun gnus-summary-write-article-file (&optional arg)
9292 "Write the current article to a file, deleting the previous file.
9293 If N is a positive number, save the N next articles.
9294 If N is a negative number, save the N previous articles.
9295 If N is nil and any articles have been marked with the process mark,
9296 save those articles instead."
9298 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9299 (gnus-summary-save-article arg)))
9301 (defun gnus-summary-save-article-body-file (&optional arg)
9302 "Append the current article body to a file.
9303 If N is a positive number, save the N next articles.
9304 If N is a negative number, save the N previous articles.
9305 If N is nil and any articles have been marked with the process mark,
9306 save those articles instead."
9308 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9309 (gnus-summary-save-article arg)))
9311 (defun gnus-summary-pipe-message (program)
9312 "Pipe the current article through PROGRAM."
9313 (interactive "sProgram: ")
9314 (gnus-summary-select-article)
9315 (let ((mail-header-separator ""))
9316 (gnus-eval-in-buffer-window gnus-article-buffer
9319 (let ((start (window-start))
9321 (message-pipe-buffer-body program)
9322 (set-window-start (get-buffer-window (current-buffer)) start))))))
9324 (defun gnus-get-split-value (methods)
9325 "Return a value based on the split METHODS."
9326 (let (split-name method result match)
9329 (set-buffer gnus-original-article-buffer)
9331 (nnheader-narrow-to-headers)
9332 (while (and methods (not split-name))
9333 (goto-char (point-min))
9334 (setq method (pop methods))
9335 (setq match (car method))
9338 ;; Regular expression.
9340 (re-search-forward match nil t)))
9341 ((gnus-functionp match)
9345 (setq result (funcall match gnus-newsgroup-name))))
9350 (setq result (eval match)))))
9351 (setq split-name (cdr method))
9352 (cond ((stringp result)
9353 (push (expand-file-name
9354 result gnus-article-save-directory)
9357 (setq split-name (append result split-name)))))))))
9358 (nreverse split-name)))
9360 (defun gnus-valid-move-group-p (group)
9363 (symbol-value group)
9364 (gnus-get-function (gnus-find-method-for-group
9365 (symbol-name group)) 'request-accept-article t)))
9367 (defun gnus-read-move-group-name (prompt default articles prefix)
9368 "Read a group name."
9369 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9370 (minibuffer-confirm-incomplete nil) ; XEmacs
9374 (if (> (length articles) 1)
9375 (format "these %d articles" (length articles))
9380 (gnus-completing-read default prom
9382 'gnus-valid-move-group-p
9384 'gnus-group-history))
9385 ((= 1 (length split-name))
9386 (gnus-completing-read (car split-name) prom
9388 'gnus-valid-move-group-p
9390 'gnus-group-history))
9392 (gnus-completing-read nil prom
9393 (mapcar (lambda (el) (list el))
9394 (nreverse split-name))
9396 'gnus-group-history))))
9397 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9399 (if (or (string= to-newsgroup "")
9400 (string= to-newsgroup prefix))
9401 (setq to-newsgroup default))
9402 (unless to-newsgroup
9403 (error "No group name entered"))
9404 (or (gnus-active to-newsgroup)
9405 (gnus-activate-group to-newsgroup nil nil to-method)
9406 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9408 (or (and (gnus-request-create-group to-newsgroup to-method)
9409 (gnus-activate-group
9410 to-newsgroup nil nil to-method)
9411 (gnus-subscribe-group to-newsgroup))
9412 (error "Couldn't create group %s" to-newsgroup)))
9413 (error "No such group: %s" to-newsgroup)))
9416 (defun gnus-summary-save-parts (type dir n &optional reverse)
9417 "Save parts matching TYPE to DIR.
9418 If REVERSE, save parts that do not match TYPE."
9420 (list (read-string "Save parts of type: "
9421 (or (car gnus-summary-save-parts-type-history)
9422 gnus-summary-save-parts-default-mime)
9423 'gnus-summary-save-parts-type-history)
9424 (setq gnus-summary-save-parts-last-directory
9425 (read-file-name "Save to directory: "
9426 gnus-summary-save-parts-last-directory
9428 current-prefix-arg))
9429 (gnus-summary-iterate n
9430 (let ((gnus-display-mime-function nil)
9431 (gnus-inhibit-treatment t))
9432 (gnus-summary-select-article))
9434 (set-buffer gnus-article-buffer)
9435 (let ((handles (or gnus-article-mime-handles
9436 (mm-dissect-buffer) (mm-uu-dissect))))
9438 (gnus-summary-save-parts-1 type dir handles reverse)
9439 (unless gnus-article-mime-handles ;; Don't destroy this case.
9440 (mm-destroy-parts handles)))))))
9442 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9443 (if (stringp (car handle))
9444 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9447 (not (string-match type (mm-handle-media-type handle)))
9448 (string-match type (mm-handle-media-type handle)))
9449 (let ((file (expand-file-name
9450 (file-name-nondirectory
9452 (mail-content-type-get
9453 (mm-handle-disposition handle) 'filename)
9454 (concat gnus-newsgroup-name
9455 "." (number-to-string
9456 (cdr gnus-article-current)))))
9458 (unless (file-exists-p file)
9459 (mm-save-part-to-file handle file))))))
9461 ;; Summary extract commands
9463 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9464 (let ((buffer-read-only nil)
9465 (article (gnus-summary-article-number))
9467 (unless (gnus-summary-goto-subject article)
9468 (error "No such article: %d" article))
9469 (gnus-summary-position-point)
9470 ;; If all commands are to be bunched up on one line, we collect
9472 (unless gnus-view-pseudos-separately
9473 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9476 (setq action (cdr (assq 'action (car ps))))
9477 (setq files (list (cdr (assq 'name (car ps)))))
9478 (while (and ps (cdr ps)
9479 (string= (or action "1")
9480 (or (cdr (assq 'action (cadr ps))) "2")))
9481 (push (cdr (assq 'name (cadr ps))) files)
9482 (setcdr ps (cddr ps)))
9484 (when (not (string-match "%s" action))
9487 (when (assq 'execute (car ps))
9488 (setcdr (assq 'execute (car ps))
9489 (funcall (if (string-match "%s" action)
9498 (setq ps (cdr ps)))))
9499 (if (and gnus-view-pseudos (not not-view))
9501 (when (assq 'execute (car pslist))
9502 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9503 (eq gnus-view-pseudos 'not-confirm)))
9504 (setq pslist (cdr pslist)))
9507 (setq after-article (or (cdr (assq 'article (car pslist)))
9508 (gnus-summary-article-number)))
9509 (gnus-summary-goto-subject after-article)
9512 (insert " " (file-name-nondirectory
9513 (cdr (assq 'name (car pslist))))
9514 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9516 (forward-line -1) ; back to `b'
9517 (gnus-add-text-properties
9518 b (1- e) (list 'gnus-number gnus-reffed-article-number
9519 gnus-mouse-face-prop gnus-mouse-face))
9521 after-article gnus-reffed-article-number
9522 gnus-unread-mark b (car pslist) 0 (- e b))
9523 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9524 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9525 (setq pslist (cdr pslist)))))))
9527 (defun gnus-pseudos< (p1 p2)
9528 (let ((c1 (cdr (assq 'action p1)))
9529 (c2 (cdr (assq 'action p2))))
9530 (and c1 c2 (string< c1 c2))))
9532 (defun gnus-request-pseudo-article (props)
9533 (cond ((assq 'execute props)
9534 (gnus-execute-command (cdr (assq 'execute props)))))
9535 (let ((gnus-current-article (gnus-summary-article-number)))
9536 (gnus-run-hooks 'gnus-mark-article-hook)))
9538 (defun gnus-execute-command (command &optional automatic)
9540 (gnus-article-setup-buffer)
9541 (set-buffer gnus-article-buffer)
9542 (setq buffer-read-only nil)
9543 (let ((command (if automatic command
9544 (read-string "Command: " (cons command 0)))))
9546 (insert "$ " command "\n\n")
9547 (if gnus-view-pseudo-asynchronously
9548 (start-process "gnus-execute" (current-buffer) shell-file-name
9549 shell-command-switch command)
9550 (call-process shell-file-name nil t nil
9551 shell-command-switch command)))))
9553 ;; Summary kill commands.
9555 (defun gnus-summary-edit-global-kill (article)
9556 "Edit the \"global\" kill file."
9557 (interactive (list (gnus-summary-article-number)))
9558 (gnus-group-edit-global-kill article))
9560 (defun gnus-summary-edit-local-kill ()
9561 "Edit a local kill file applied to the current newsgroup."
9563 (setq gnus-current-headers (gnus-summary-article-header))
9564 (gnus-group-edit-local-kill
9565 (gnus-summary-article-number) gnus-newsgroup-name))
9569 (defun gnus-read-header (id &optional header)
9570 "Read the headers of article ID and enter them into the Gnus system."
9571 (let ((group gnus-newsgroup-name)
9572 (gnus-override-method
9574 gnus-override-method
9575 (and (gnus-news-group-p gnus-newsgroup-name)
9576 (car (gnus-refer-article-methods)))))
9578 ;; First we check to see whether the header in question is already
9581 ;; This is a Message-ID.
9582 (setq header (or header (gnus-id-to-header id)))
9583 ;; This is an article number.
9584 (setq header (or header (gnus-summary-article-header id))))
9586 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9587 ;; We have found the header.
9589 ;; If this is a sparse article, we have to nix out its
9590 ;; previous entry in the thread hashtb.
9592 (gnus-summary-article-sparse-p (mail-header-number header)))
9593 (let* ((parent (gnus-parent-id (mail-header-references header)))
9594 (thread (and parent (gnus-id-to-thread parent))))
9596 (delq (assq header thread) thread))))
9597 ;; We have to really fetch the header to this article.
9599 (set-buffer nntp-server-buffer)
9600 (when (setq where (gnus-request-head id group))
9601 (nnheader-fold-continuation-lines)
9602 (goto-char (point-max))
9604 (goto-char (point-min))
9608 ((cdr where) (cdr where))
9609 (header (mail-header-number header))
9610 (t gnus-reffed-article-number))
9612 (insert " Article retrieved.\n"))
9614 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9615 () ; Malformed head.
9616 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9617 (when (and (stringp id)
9618 (not (string= (gnus-group-real-name group)
9620 ;; If we fetched by Message-ID and the article came
9621 ;; from a different group, we fudge some bogus article
9622 ;; numbers for this article.
9623 (mail-header-set-number header gnus-reffed-article-number))
9625 (set-buffer gnus-summary-buffer)
9626 (decf gnus-reffed-article-number)
9627 (gnus-remove-header (mail-header-number header))
9628 (push header gnus-newsgroup-headers)
9629 (setq gnus-current-headers header)
9630 (push (mail-header-number header) gnus-newsgroup-limit)))
9633 (defun gnus-remove-header (number)
9634 "Remove header NUMBER from `gnus-newsgroup-headers'."
9635 (if (and gnus-newsgroup-headers
9636 (= number (mail-header-number (car gnus-newsgroup-headers))))
9637 (pop gnus-newsgroup-headers)
9638 (let ((headers gnus-newsgroup-headers))
9639 (while (and (cdr headers)
9640 (not (= number (mail-header-number (cadr headers)))))
9643 (setcdr headers (cddr headers))))))
9646 ;;; summary highlights
9649 (defun gnus-highlight-selected-summary ()
9650 "Highlight selected article in summary buffer."
9651 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9652 (when gnus-summary-selected-face
9654 (let* ((beg (progn (beginning-of-line) (point)))
9655 (end (progn (end-of-line) (point)))
9656 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9657 (from (if (get-text-property beg gnus-mouse-face-prop)
9659 (or (next-single-property-change
9660 beg gnus-mouse-face-prop nil end)
9665 (or (next-single-property-change
9666 from gnus-mouse-face-prop nil end)
9668 ;; If no mouse-face prop on line we will have to = from = end,
9669 ;; so we highlight the entire line instead.
9670 (when (= (+ to 2) from)
9673 (if gnus-newsgroup-selected-overlay
9674 ;; Move old overlay.
9676 gnus-newsgroup-selected-overlay from to (current-buffer))
9677 ;; Create new overlay.
9679 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9680 'face gnus-summary-selected-face))))))
9682 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9683 (defun gnus-summary-highlight-line ()
9684 "Highlight current line according to `gnus-summary-highlight'."
9685 (let* ((list gnus-summary-highlight)
9687 (end (progn (end-of-line) (point)))
9688 ;; now find out where the line starts and leave point there.
9689 (beg (progn (beginning-of-line) (point)))
9690 (article (gnus-summary-article-number))
9691 (score (or (cdr (assq (or article gnus-current-article)
9692 gnus-newsgroup-scored))
9693 gnus-summary-default-score 0))
9694 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9695 (inhibit-read-only t))
9696 ;; Eval the cars of the lists until we find a match.
9697 (let ((default gnus-summary-default-score))
9699 (not (eval (caar list))))
9700 (setq list (cdr list))))
9701 (let ((face (cdar list)))
9702 (unless (eq face (get-text-property beg 'face))
9703 (gnus-put-text-property-excluding-characters-with-faces
9705 (setq face (if (boundp face) (symbol-value face) face)))
9706 (when gnus-summary-highlight-line-function
9707 (funcall gnus-summary-highlight-line-function article face))))
9710 (defun gnus-update-read-articles (group unread &optional compute)
9711 "Update the list of read articles in GROUP."
9712 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9713 (entry (gnus-gethash group gnus-newsrc-hashtb))
9714 (info (nth 2 entry))
9716 (unread (sort (copy-sequence unread) '<))
9718 (if (or (not info) (not active))
9719 ;; There is no info on this group if it was, in fact,
9720 ;; killed. Gnus stores no information on killed groups, so
9721 ;; there's nothing to be done.
9722 ;; One could store the information somewhere temporarily,
9723 ;; perhaps... Hmmm...
9725 ;; Remove any negative articles numbers.
9726 (while (and unread (< (car unread) 0))
9727 (setq unread (cdr unread)))
9728 ;; Remove any expired article numbers
9729 (while (and unread (< (car unread) (car active)))
9730 (setq unread (cdr unread)))
9731 ;; Compute the ranges of read articles by looking at the list of
9734 (when (/= (car unread) prev)
9735 (push (if (= prev (1- (car unread))) prev
9736 (cons prev (1- (car unread))))
9738 (setq prev (1+ (car unread)))
9739 (setq unread (cdr unread)))
9740 (when (<= prev (cdr active))
9741 (push (cons prev (cdr active)) read))
9742 (setq read (if (> (length read) 1) (nreverse read) read))
9747 ;; Propagate the read marks to the backend.
9748 (when (gnus-check-backend-function 'request-set-mark group)
9749 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9750 (add (gnus-remove-from-range read (gnus-info-read info))))
9752 (unless (gnus-check-group group)
9753 (error "Can't open server for %s" group))
9754 (gnus-request-set-mark
9755 group (delq nil (list (if add (list add 'add '(read)))
9756 (if del (list del 'del '(read))))))
9758 `(gnus-request-set-mark
9761 (if del (list del 'add '(read)))
9762 (if add (list add 'del '(read))))))))))
9763 (set-buffer gnus-group-buffer)
9766 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9767 (gnus-info-set-read ',info ',(gnus-info-read info))
9768 (gnus-get-unread-articles-in-group ',info
9769 (gnus-active ,group))
9770 (gnus-group-update-group ,group t)
9772 ;; Enter this list into the group info.
9773 (gnus-info-set-read info read)
9774 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9775 (gnus-get-unread-articles-in-group info (gnus-active group))
9778 (defun gnus-offer-save-summaries ()
9779 "Offer to save all active summary buffers."
9781 (let ((buflist (buffer-list))
9783 ;; Go through all buffers and find all summaries.
9785 (and (setq bufname (buffer-name (car buflist)))
9786 (string-match "Summary" bufname)
9788 (set-buffer bufname)
9789 ;; We check that this is, indeed, a summary buffer.
9790 (and (eq major-mode 'gnus-summary-mode)
9791 ;; Also make sure this isn't bogus.
9792 gnus-newsgroup-prepared
9793 ;; Also make sure that this isn't a dead summary buffer.
9794 (not gnus-dead-summary-mode)))
9795 (push bufname buffers))
9796 (setq buflist (cdr buflist)))
9797 ;; Go through all these summary buffers and offer to save them.
9800 "Update summary buffer %s? "
9802 (switch-to-buffer buf)
9803 (gnus-summary-exit))
9806 (defun gnus-summary-setup-default-charset ()
9807 "Setup newsgroup default charset."
9808 (if (equal gnus-newsgroup-name "nndraft:drafts")
9809 (setq gnus-newsgroup-charset nil)
9810 (let* ((name (and gnus-newsgroup-name
9811 (gnus-group-real-name gnus-newsgroup-name)))
9813 (or gnus-newsgroup-ephemeral-ignored-charsets
9815 (and gnus-newsgroup-name
9816 (or (gnus-group-find-parameter gnus-newsgroup-name
9817 'ignored-charsets t)
9818 (let ((alist gnus-group-ignored-charsets-alist)
9819 elem (charsets nil))
9820 (while (setq elem (pop alist))
9822 (string-match (car elem) name))
9824 charsets (cdr elem))))
9826 gnus-newsgroup-ignored-charsets))))
9827 (setq gnus-newsgroup-charset
9828 (or gnus-newsgroup-ephemeral-charset
9829 (and gnus-newsgroup-name
9830 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9831 (let ((alist gnus-group-charset-alist)
9833 (while (setq elem (pop alist))
9835 (string-match (car elem) name))
9837 charset (cadr elem))))
9839 gnus-default-charset))
9840 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9841 ignored-charsets))))
9847 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9848 "Display the current article buffer fully MIME-buttonized.
9849 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9850 treated as multipart/mixed."
9853 (let ((gnus-unbuttonized-mime-types nil)
9854 (gnus-mime-display-multipart-as-mixed show-all-parts))
9855 (gnus-summary-show-article)))
9857 (defun gnus-summary-repair-multipart (article)
9858 "Add a Content-Type header to a multipart article without one."
9859 (interactive (list (gnus-summary-article-number)))
9860 (gnus-with-article article
9861 (message-narrow-to-head)
9862 (message-remove-header "Mime-Version")
9863 (goto-char (point-max))
9864 (insert "Mime-Version: 1.0\n")
9866 (when (search-forward "\n--" nil t)
9867 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9868 (message-narrow-to-head)
9869 (message-remove-header "Content-Type")
9870 (goto-char (point-max))
9871 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9874 (let (gnus-mark-article-hook)
9875 (gnus-summary-select-article t t nil article)))
9877 (defun gnus-summary-toggle-display-buttonized ()
9878 "Toggle the buttonizing of the article buffer."
9881 (if (setq gnus-inhibit-mime-unbuttonizing
9882 (not gnus-inhibit-mime-unbuttonizing))
9883 (let ((gnus-unbuttonized-mime-types nil))
9884 (gnus-summary-show-article))
9885 (gnus-summary-show-article)))
9888 ;;; Generic summary marking commands
9891 (defvar gnus-summary-marking-alist
9892 '((read gnus-del-mark "d")
9893 (unread gnus-unread-mark "u")
9894 (ticked gnus-ticked-mark "!")
9895 (dormant gnus-dormant-mark "?")
9896 (expirable gnus-expirable-mark "e"))
9897 "An alist of names/marks/keystrokes.")
9899 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9900 (defvar gnus-summary-mark-map)
9902 (defun gnus-summary-make-all-marking-commands ()
9903 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9904 (dolist (elem gnus-summary-marking-alist)
9905 (apply 'gnus-summary-make-marking-command elem)))
9907 (defun gnus-summary-make-marking-command (name mark keystroke)
9908 (let ((map (make-sparse-keymap)))
9909 (define-key gnus-summary-generic-mark-map keystroke map)
9910 (dolist (lway `((next "next" next nil "n")
9911 (next-unread "next unread" next t "N")
9912 (prev "previous" prev nil "p")
9913 (prev-unread "previous unread" prev t "P")
9914 (nomove "" nil nil ,keystroke)))
9915 (let ((func (gnus-summary-make-marking-command-1
9916 mark (car lway) lway name)))
9917 (setq func (eval func))
9918 (define-key map (nth 4 lway) func)))))
9920 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9922 (format "gnus-summary-put-mark-as-%s%s"
9923 name (if (eq way 'nomove)
9925 (concat "-" (symbol-name way)))))
9928 "Mark the current article as %s%s.
9929 If N, the prefix, then repeat N times.
9930 If N is negative, move in reverse order.
9931 The difference between N and the actual number of articles marked is
9935 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9937 (defun gnus-summary-generic-mark (n mark move unread)
9938 "Mark N articles with MARK."
9939 (unless (eq major-mode 'gnus-summary-mode)
9940 (error "This command can only be used in the summary buffer"))
9941 (gnus-summary-show-thread)
9945 ((eq move 'prev) -1)
9951 nummove (* -1 nummove))))
9953 (gnus-summary-mark-article nil mark)
9954 (zerop (gnus-summary-next-subject nummove unread t)))
9957 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9958 (gnus-summary-recenter)
9959 (gnus-summary-position-point)
9960 (gnus-set-mode-line 'summary)
9963 (gnus-summary-make-all-marking-commands)
9969 (run-hooks 'gnus-sum-load-hook)
9971 ;;; gnus-sum.el ends here