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))
39 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (defcustom gnus-kill-summary-on-exit t
42 "*If non-nil, kill the summary buffer when you exit from it.
43 If nil, the summary will become a \"*Dead Summary*\" buffer, and
44 it will be killed sometime later."
45 :group 'gnus-summary-exit
48 (defcustom gnus-fetch-old-headers nil
49 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
50 If an unread article in the group refers to an older, already read (or
51 just marked as read) article, the old article will not normally be
52 displayed in the Summary buffer. If this variable is non-nil, Gnus
53 will attempt to grab the headers to the old articles, and thereby
54 build complete threads. If it has the value `some', only enough
55 headers to connect otherwise loose threads will be displayed. This
56 variable can also be a number. In that case, no more than that number
57 of old headers will be fetched. If it has the value `invisible', all
58 old headers will be fetched, but none will be displayed.
60 The server has to support NOV for any of this to work."
62 :type '(choice (const :tag "off" nil)
65 (sexp :menu-tag "other" t)))
67 (defcustom gnus-refer-thread-limit 200
68 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
69 If t, fetch all the available old headers."
72 (sexp :menu-tag "other" t)))
74 (defcustom gnus-summary-make-false-root 'adopt
75 "*nil means that Gnus won't gather loose threads.
76 If the root of a thread has expired or been read in a previous
77 session, the information necessary to build a complete thread has been
78 lost. Instead of having many small sub-threads from this original thread
79 scattered all over the summary buffer, Gnus can gather them.
81 If non-nil, Gnus will try to gather all loose sub-threads from an
82 original thread into one large thread.
84 If this variable is non-nil, it should be one of `none', `adopt',
87 If this variable is `none', Gnus will not make a false root, but just
88 present the sub-threads after another.
89 If this variable is `dummy', Gnus will create a dummy root that will
90 have all the sub-threads as children.
91 If this variable is `adopt', Gnus will make one of the \"children\"
92 the parent and mark all the step-children as such.
93 If this variable is `empty', the \"children\" are printed with empty
94 subject fields. (Or rather, they will be printed with a string
95 given by the `gnus-summary-same-subject' variable.)"
97 :type '(choice (const :tag "off" nil)
103 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
104 "*A regexp to match subjects to be excluded from loose thread gathering.
105 As loose thread gathering is done on subjects only, that means that
106 there can be many false gatherings performed. By rooting out certain
107 common subjects, gathering might become saner."
111 (defcustom gnus-summary-gather-subject-limit nil
112 "*Maximum length of subject comparisons when gathering loose threads.
113 Use nil to compare full subjects. Setting this variable to a low
114 number will help gather threads that have been corrupted by
115 newsreaders chopping off subject lines, but it might also mean that
116 unrelated articles that have subject that happen to begin with the
117 same few characters will be incorrectly gathered.
119 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
122 :type '(choice (const :tag "off" nil)
124 (sexp :menu-tag "on" t)))
126 (defcustom gnus-simplify-subject-functions nil
127 "List of functions taking a string argument that simplify subjects.
128 The functions are applied recursively.
130 Useful functions to put in this list include: `gnus-simplify-subject-re',
131 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
133 :type '(repeat function))
135 (defcustom gnus-simplify-ignored-prefixes nil
136 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
138 :type '(choice (const :tag "off" nil)
141 (defcustom gnus-build-sparse-threads nil
142 "*If non-nil, fill in the gaps in threads.
143 If `some', only fill in the gaps that are needed to tie loose threads
144 together. If `more', fill in all leaf nodes that Gnus can find. If
145 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
147 :type '(choice (const :tag "off" nil)
150 (sexp :menu-tag "all" t)))
152 (defcustom gnus-summary-thread-gathering-function
153 'gnus-gather-threads-by-subject
154 "*Function used for gathering loose threads.
155 There are two pre-defined functions: `gnus-gather-threads-by-subject',
156 which only takes Subjects into consideration; and
157 `gnus-gather-threads-by-references', which compared the References
158 headers of the articles to find matches."
160 :type '(radio (function-item gnus-gather-threads-by-subject)
161 (function-item gnus-gather-threads-by-references)
162 (function :tag "other")))
164 (defcustom gnus-summary-same-subject ""
165 "*String indicating that the current article has the same subject as the previous.
166 This variable will only be used if the value of
167 `gnus-summary-make-false-root' is `empty'."
168 :group 'gnus-summary-format
171 (defcustom gnus-summary-goto-unread t
172 "*If t, many commands will go to the next unread article.
173 This applies to marking commands as well as other commands that
174 \"naturally\" select the next article, like, for instance, `SPC' at
175 the end of an article.
177 If nil, the marking commands do NOT go to the next unread article
178 (they go to the next article instead). If `never', commands that
179 usually go to the next unread article, will go to the next article,
180 whether it is read or not."
181 :group 'gnus-summary-marks
182 :link '(custom-manual "(gnus)Setting Marks")
183 :type '(choice (const :tag "off" nil)
185 (sexp :menu-tag "on" t)))
187 (defcustom gnus-summary-default-score 0
188 "*Default article score level.
189 All scores generated by the score files will be added to this score.
190 If this variable is nil, scoring will be disabled."
191 :group 'gnus-score-default
192 :type '(choice (const :tag "disable")
195 (defcustom gnus-summary-zcore-fuzz 0
196 "*Fuzziness factor for the zcore in the summary buffer.
197 Articles with scores closer than this to `gnus-summary-default-score'
199 :group 'gnus-summary-format
202 (defcustom gnus-simplify-subject-fuzzy-regexp nil
203 "*Strings to be removed when doing fuzzy matches.
204 This can either be a regular expression or list of regular expressions
205 that will be removed from subject strings if fuzzy subject
206 simplification is selected."
208 :type '(repeat regexp))
210 (defcustom gnus-show-threads t
211 "*If non-nil, display threads in summary mode."
215 (defcustom gnus-thread-hide-subtree nil
216 "*If non-nil, hide all threads initially.
217 If threads are hidden, you have to run the command
218 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
219 to expose hidden threads."
223 (defcustom gnus-thread-hide-killed t
224 "*If non-nil, hide killed threads automatically."
228 (defcustom gnus-thread-ignore-subject t
229 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
230 If nil, articles that have different subjects from their parents will
231 start separate threads."
235 (defcustom gnus-thread-operation-ignore-subject t
236 "*If non-nil, subjects will be ignored when doing thread commands.
237 This affects commands like `gnus-summary-kill-thread' and
238 `gnus-summary-lower-thread'.
240 If this variable is nil, articles in the same thread with different
241 subjects will not be included in the operation in question. If this
242 variable is `fuzzy', only articles that have subjects that are fuzzily
243 equal will be included."
245 :type '(choice (const :tag "off" nil)
249 (defcustom gnus-thread-indent-level 4
250 "*Number that says how much each sub-thread should be indented."
254 (defcustom gnus-auto-extend-newsgroup t
255 "*If non-nil, extend newsgroup forward and backward when requested."
256 :group 'gnus-summary-choose
259 (defcustom gnus-auto-select-first t
260 "*If nil, don't select the first unread article when entering a group.
261 If this variable is `best', select the highest-scored unread article
262 in the group. If t, select the first unread article.
264 This variable can also be a function to place point on a likely
265 subject line. Useful values include `gnus-summary-first-unread-subject',
266 `gnus-summary-first-unread-article' and
267 `gnus-summary-best-unread-article'.
269 If you want to prevent automatic selection of the first unread article
270 in some newsgroups, set the variable to nil in
271 `gnus-select-group-hook'."
272 :group 'gnus-group-select
273 :type '(choice (const :tag "none" nil)
275 (sexp :menu-tag "first" t)
276 (function-item gnus-summary-first-unread-subject)
277 (function-item gnus-summary-first-unread-article)
278 (function-item gnus-summary-best-unread-article)))
280 (defcustom gnus-auto-select-next t
281 "*If non-nil, offer to go to the next group from the end of the previous.
282 If the value is t and the next newsgroup is empty, Gnus will exit
283 summary mode and go back to group mode. If the value is neither nil
284 nor t, Gnus will select the following unread newsgroup. In
285 particular, if the value is the symbol `quietly', the next unread
286 newsgroup will be selected without any confirmation, and if it is
287 `almost-quietly', the next group will be selected without any
288 confirmation if you are located on the last article in the group.
289 Finally, if this variable is `slightly-quietly', the `Z n' command
290 will go to the next group without confirmation."
291 :group 'gnus-summary-maneuvering
292 :type '(choice (const :tag "off" nil)
294 (const almost-quietly)
295 (const slightly-quietly)
296 (sexp :menu-tag "on" t)))
298 (defcustom gnus-auto-select-same nil
299 "*If non-nil, select the next article with the same subject.
300 If there are no more articles with the same subject, go to
301 the first unread article."
302 :group 'gnus-summary-maneuvering
305 (defcustom gnus-summary-check-current nil
306 "*If non-nil, consider the current article when moving.
307 The \"unread\" movement commands will stay on the same line if the
308 current article is unread."
309 :group 'gnus-summary-maneuvering
312 (defcustom gnus-auto-center-summary t
313 "*If non-nil, always center the current summary buffer.
314 In particular, if `vertical' do only vertical recentering. If non-nil
315 and non-`vertical', do both horizontal and vertical recentering."
316 :group 'gnus-summary-maneuvering
317 :type '(choice (const :tag "none" nil)
319 (integer :tag "height")
320 (sexp :menu-tag "both" t)))
322 (defcustom gnus-show-all-headers nil
323 "*If non-nil, don't hide any headers."
324 :group 'gnus-article-hiding
325 :group 'gnus-article-headers
328 (defcustom gnus-summary-ignore-duplicates nil
329 "*If non-nil, ignore articles with identical Message-ID headers."
333 (defcustom gnus-single-article-buffer t
334 "*If non-nil, display all articles in the same buffer.
335 If nil, each group will get its own article buffer."
336 :group 'gnus-article-various
339 (defcustom gnus-break-pages t
340 "*If non-nil, do page breaking on articles.
341 The page delimiter is specified by the `gnus-page-delimiter'
343 :group 'gnus-article-various
346 (defcustom gnus-move-split-methods nil
347 "*Variable used to suggest where articles are to be moved to.
348 It uses the same syntax as the `gnus-split-methods' variable."
349 :group 'gnus-summary-mail
350 :type '(repeat (choice (list :value (fun) function)
351 (cons :value ("" "") regexp (repeat string))
354 (defcustom gnus-unread-mark ? ;Whitespace
355 "*Mark used for unread articles."
356 :group 'gnus-summary-marks
359 (defcustom gnus-ticked-mark ?!
360 "*Mark used for ticked articles."
361 :group 'gnus-summary-marks
364 (defcustom gnus-dormant-mark ??
365 "*Mark used for dormant articles."
366 :group 'gnus-summary-marks
369 (defcustom gnus-del-mark ?r
370 "*Mark used for del'd articles."
371 :group 'gnus-summary-marks
374 (defcustom gnus-read-mark ?R
375 "*Mark used for read articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-expirable-mark ?E
380 "*Mark used for expirable articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-killed-mark ?K
385 "*Mark used for killed articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-souped-mark ?F
390 "*Mark used for killed articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-kill-file-mark ?X
395 "*Mark used for articles killed by kill files."
396 :group 'gnus-summary-marks
399 (defcustom gnus-low-score-mark ?Y
400 "*Mark used for articles with a low score."
401 :group 'gnus-summary-marks
404 (defcustom gnus-catchup-mark ?C
405 "*Mark used for articles that are caught up."
406 :group 'gnus-summary-marks
409 (defcustom gnus-replied-mark ?A
410 "*Mark used for articles that have been replied to."
411 :group 'gnus-summary-marks
414 (defcustom gnus-cached-mark ?*
415 "*Mark used for articles that are in the cache."
416 :group 'gnus-summary-marks
419 (defcustom gnus-saved-mark ?S
420 "*Mark used for articles that have been saved to."
421 :group 'gnus-summary-marks
424 (defcustom gnus-ancient-mark ?O
425 "*Mark used for ancient articles."
426 :group 'gnus-summary-marks
429 (defcustom gnus-sparse-mark ?Q
430 "*Mark used for sparsely reffed articles."
431 :group 'gnus-summary-marks
434 (defcustom gnus-canceled-mark ?G
435 "*Mark used for canceled articles."
436 :group 'gnus-summary-marks
439 (defcustom gnus-duplicate-mark ?M
440 "*Mark used for duplicate articles."
441 :group 'gnus-summary-marks
444 (defcustom gnus-undownloaded-mark ?@
445 "*Mark used for articles that weren't downloaded."
446 :group 'gnus-summary-marks
449 (defcustom gnus-downloadable-mark ?%
450 "*Mark used for articles that are to be downloaded."
451 :group 'gnus-summary-marks
454 (defcustom gnus-unsendable-mark ?=
455 "*Mark used for articles that won't be sent."
456 :group 'gnus-summary-marks
459 (defcustom gnus-score-over-mark ?+
460 "*Score mark used for articles with high scores."
461 :group 'gnus-summary-marks
464 (defcustom gnus-score-below-mark ?-
465 "*Score mark used for articles with low scores."
466 :group 'gnus-summary-marks
469 (defcustom gnus-empty-thread-mark ? ;Whitespace
470 "*There is no thread under the article."
471 :group 'gnus-summary-marks
474 (defcustom gnus-not-empty-thread-mark ?=
475 "*There is a thread under the article."
476 :group 'gnus-summary-marks
479 (defcustom gnus-view-pseudo-asynchronously nil
480 "*If non-nil, Gnus will view pseudo-articles asynchronously."
481 :group 'gnus-extract-view
484 (defcustom gnus-auto-expirable-marks
485 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
486 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
487 gnus-souped-mark gnus-duplicate-mark)
488 "*The list of marks converted into expiration if a group is auto-expirable."
490 :type '(repeat character))
492 (defcustom gnus-inhibit-user-auto-expire t
493 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
497 (defcustom gnus-view-pseudos nil
498 "*If `automatic', pseudo-articles will be viewed automatically.
499 If `not-confirm', pseudos will be viewed automatically, and the user
500 will not be asked to confirm the command."
501 :group 'gnus-extract-view
502 :type '(choice (const :tag "off" nil)
504 (const not-confirm)))
506 (defcustom gnus-view-pseudos-separately t
507 "*If non-nil, one pseudo-article will be created for each file to be viewed.
508 If nil, all files that use the same viewing command will be given as a
509 list of parameters to that command."
510 :group 'gnus-extract-view
513 (defcustom gnus-insert-pseudo-articles t
514 "*If non-nil, insert pseudo-articles when decoding articles."
515 :group 'gnus-extract-view
518 (defcustom gnus-summary-dummy-line-format
520 "*The format specification for the dummy roots in the summary buffer.
521 It works along the same lines as a normal formatting string,
522 with some simple extensions.
525 :group 'gnus-threading
528 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
529 "*The format specification for the summary mode line.
530 It works along the same lines as a normal formatting string,
531 with some simple extensions:
534 %p Unprefixed group name
535 %A Current article number
536 %z Current article score
538 %U Number of unread articles in the group
539 %e Number of unselected articles in the group
540 %Z A string with unread/unselected article counts
541 %g Shortish group name
542 %S Subject of the current article
544 %s Current score file name
545 %d Number of dormant articles
546 %r Number of articles that have been marked as read in this session
547 %E Number of articles expunged by the score files"
548 :group 'gnus-summary-format
551 (defcustom gnus-list-identifiers nil
552 "Regexp that matches list identifiers to be removed from subject.
553 This can also be a list of regexps."
554 :group 'gnus-summary-format
555 :group 'gnus-article-hiding
556 :type '(choice (const :tag "none" nil)
558 (repeat :value (".*") regexp)))
560 (defcustom gnus-summary-mark-below 0
561 "*Mark all articles with a score below this variable as read.
562 This variable is local to each summary buffer and usually set by the
564 :group 'gnus-score-default
567 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
568 "*List of functions used for sorting articles in the summary buffer.
569 This variable is only used when not using a threaded display."
570 :group 'gnus-summary-sort
571 :type '(repeat (choice (function-item gnus-article-sort-by-number)
572 (function-item gnus-article-sort-by-author)
573 (function-item gnus-article-sort-by-subject)
574 (function-item gnus-article-sort-by-date)
575 (function-item gnus-article-sort-by-score)
576 (function :tag "other"))))
578 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
579 "*List of functions used for sorting threads in the summary buffer.
580 By default, threads are sorted by article number.
582 Each function takes two threads and return non-nil if the first thread
583 should be sorted before the other. If you use more than one function,
584 the primary sort function should be the last. You should probably
585 always include `gnus-thread-sort-by-number' in the list of sorting
586 functions -- preferably first.
588 Ready-made functions include `gnus-thread-sort-by-number',
589 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
590 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
591 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
592 :group 'gnus-summary-sort
593 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
594 (function-item gnus-thread-sort-by-author)
595 (function-item gnus-thread-sort-by-subject)
596 (function-item gnus-thread-sort-by-date)
597 (function-item gnus-thread-sort-by-score)
598 (function-item gnus-thread-sort-by-total-score)
599 (function :tag "other"))))
601 (defcustom gnus-thread-score-function '+
602 "*Function used for calculating the total score of a thread.
604 The function is called with the scores of the article and each
605 subthread and should then return the score of the thread.
607 Some functions you can use are `+', `max', or `min'."
608 :group 'gnus-summary-sort
611 (defcustom gnus-summary-expunge-below nil
612 "All articles that have a score less than this variable will be expunged.
613 This variable is local to the summary buffers."
614 :group 'gnus-score-default
615 :type '(choice (const :tag "off" nil)
618 (defcustom gnus-thread-expunge-below nil
619 "All threads that have a total score less than this variable will be expunged.
620 See `gnus-thread-score-function' for en explanation of what a
623 This variable is local to the summary buffers."
624 :group 'gnus-threading
625 :group 'gnus-score-default
626 :type '(choice (const :tag "off" nil)
629 (defcustom gnus-summary-mode-hook nil
630 "*A hook for Gnus summary mode.
631 This hook is run before any variables are set in the summary buffer."
632 :group 'gnus-summary-various
635 (defcustom gnus-summary-menu-hook nil
636 "*Hook run after the creation of the summary mode menu."
637 :group 'gnus-summary-visual
640 (defcustom gnus-summary-exit-hook nil
641 "*A hook called on exit from the summary buffer.
642 It will be called with point in the group buffer."
643 :group 'gnus-summary-exit
646 (defcustom gnus-summary-prepare-hook nil
647 "*A hook called after the summary buffer has been generated.
648 If you want to modify the summary buffer, you can use this hook."
649 :group 'gnus-summary-various
652 (defcustom gnus-summary-prepared-hook nil
653 "*A hook called as the last thing after the summary buffer has been generated."
654 :group 'gnus-summary-various
657 (defcustom gnus-summary-generate-hook nil
658 "*A hook run just before generating the summary buffer.
659 This hook is commonly used to customize threading variables and the
661 :group 'gnus-summary-various
664 (defcustom gnus-select-group-hook nil
665 "*A hook called when a newsgroup is selected.
667 If you'd like to simplify subjects like the
668 `gnus-summary-next-same-subject' command does, you can use the
671 (setq gnus-select-group-hook
674 (mapcar (lambda (header)
675 (mail-header-set-subject
677 (gnus-simplify-subject
678 (mail-header-subject header) 're-only)))
679 gnus-newsgroup-headers))))"
680 :group 'gnus-group-select
683 (defcustom gnus-select-article-hook nil
684 "*A hook called when an article is selected."
685 :group 'gnus-summary-choose
688 (defcustom gnus-visual-mark-article-hook
689 (list 'gnus-highlight-selected-summary)
690 "*Hook run after selecting an article in the summary buffer.
691 It is meant to be used for highlighting the article in some way. It
692 is not run if `gnus-visual' is nil."
693 :group 'gnus-summary-visual
696 (defcustom gnus-parse-headers-hook nil
697 "*A hook called before parsing the headers."
701 (defcustom gnus-exit-group-hook nil
702 "*A hook called when exiting summary mode.
703 This hook is not called from the non-updating exit commands like `Q'."
707 (defcustom gnus-summary-update-hook
708 (list 'gnus-summary-highlight-line)
709 "*A hook called when a summary line is changed.
710 The hook will not be called if `gnus-visual' is nil.
712 The default function `gnus-summary-highlight-line' will
713 highlight the line according to the `gnus-summary-highlight'
715 :group 'gnus-summary-visual
718 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
719 "*A hook called when an article is selected for the first time.
720 The hook is intended to mark an article as read (or unread)
721 automatically when it is selected."
722 :group 'gnus-summary-choose
725 (defcustom gnus-group-no-more-groups-hook nil
726 "*A hook run when returning to group mode having no more (unread) groups."
727 :group 'gnus-group-select
730 (defcustom gnus-ps-print-hook nil
731 "*A hook run before ps-printing something from Gnus."
735 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
736 "Face used for highlighting the current article in the summary buffer."
737 :group 'gnus-summary-visual
740 (defcustom gnus-summary-highlight
741 '(((= mark gnus-canceled-mark)
742 . gnus-summary-cancelled-face)
743 ((and (> score default)
744 (or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark)))
746 . gnus-summary-high-ticked-face)
747 ((and (< score default)
748 (or (= mark gnus-dormant-mark)
749 (= mark gnus-ticked-mark)))
750 . gnus-summary-low-ticked-face)
751 ((or (= mark gnus-dormant-mark)
752 (= mark gnus-ticked-mark))
753 . gnus-summary-normal-ticked-face)
754 ((and (> score default) (= mark gnus-ancient-mark))
755 . gnus-summary-high-ancient-face)
756 ((and (< score default) (= mark gnus-ancient-mark))
757 . gnus-summary-low-ancient-face)
758 ((= mark gnus-ancient-mark)
759 . gnus-summary-normal-ancient-face)
760 ((and (> score default) (= mark gnus-unread-mark))
761 . gnus-summary-high-unread-face)
762 ((and (< score default) (= mark gnus-unread-mark))
763 . gnus-summary-low-unread-face)
764 ((= mark gnus-unread-mark)
765 . gnus-summary-normal-unread-face)
766 ((and (> score default) (memq mark (list gnus-downloadable-mark
767 gnus-undownloaded-mark)))
768 . gnus-summary-high-unread-face)
769 ((and (< score default) (memq mark (list gnus-downloadable-mark
770 gnus-undownloaded-mark)))
771 . gnus-summary-low-unread-face)
772 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
773 . gnus-summary-normal-unread-face)
775 . gnus-summary-high-read-face)
777 . gnus-summary-low-read-face)
779 . gnus-summary-normal-read-face))
780 "*Controls the highlighting of summary buffer lines.
782 A list of (FORM . FACE) pairs. When deciding how a a particular
783 summary line should be displayed, each form is evaluated. The content
784 of the face field after the first true form is used. You can change
785 how those summary lines are displayed, by editing the face field.
787 You can use the following variables in the FORM field.
789 score: The articles score
790 default: The default article score.
791 below: The score below which articles are automatically marked as read.
792 mark: The articles mark."
793 :group 'gnus-summary-visual
794 :type '(repeat (cons (sexp :tag "Form" nil)
797 (defcustom gnus-alter-header-function nil
798 "Function called to allow alteration of article header structures.
799 The function is called with one parameter, the article header vector,
800 which it may alter in any way.")
802 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
803 "Variable that says which function should be used to decode a string with encoded words.")
805 (defcustom gnus-extra-headers nil
806 "*Extra headers to parse."
808 :type '(repeat symbol))
810 (defcustom gnus-ignored-from-addresses
811 (and user-mail-address (regexp-quote user-mail-address))
812 "*Regexp of From headers that may be suppressed in favor of To headers."
816 (defcustom gnus-group-charset-alist
817 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
818 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
819 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
820 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
821 ("^relcom\\>" koi8-r)
823 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
824 ("^israel\\>" iso-8859-1)
826 ("^alt.chinese.text.big5\\>" chinese-big5)
827 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
828 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
830 "Alist of regexps (to match group names) and default charsets to be used when reading."
831 :type '(repeat (list (regexp :tag "Group")
832 (symbol :tag "Charset")))
833 :group 'gnus-charset)
835 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
836 "List of charsets that should be ignored.
837 When these charsets are used in the \"charset\" parameter, the
838 default charset will be used instead."
839 :type '(repeat symbol)
840 :group 'gnus-charset)
842 (defcustom gnus-group-ignored-charsets-alist
843 '(("alt\\.chinese\\.text" iso-8859-1))
844 "Alist of regexps (to match group names) and charsets that should be ignored.
845 When these charsets are used in the \"charset\" parameter, the
846 default charset will be used instead."
847 :type '(repeat (cons (regexp :tag "Group")
849 :group 'gnus-charset)
851 (defcustom gnus-group-highlight-words-alist nil
852 "Alist of group regexps and highlight regexps.
853 This variable uses the same syntax as `gnus-emphasis-alist'."
854 :type '(repeat (cons (regexp :tag "Group")
855 (repeat (list (regexp :tag "Highlight regexp")
856 (number :tag "Group for entire word" 0)
857 (number :tag "Group for displayed part" 0)
859 gnus-emphasis-highlight-words)))))
860 :group 'gnus-summary-visual)
862 (defcustom gnus-summary-show-article-charset-alist
864 "Alist of number and charset.
865 The article will be shown with the charset corresponding to the
867 For example: ((1 . cn-gb-2312) (2 . big5))."
868 :type '(repeat (cons (number :tag "Argument" 1)
869 (symbol :tag "Charset")))
870 :group 'gnus-charset)
872 (defcustom gnus-preserve-marks t
873 "Whether marks are preserved when moving, copying and respooling messages."
875 :group 'gnus-summary-marks)
877 (defcustom gnus-alter-articles-to-read-function nil
878 "Function to be called to alter the list of articles to be selected."
880 :group 'gnus-summary)
882 ;;; Internal variables
884 (defvar gnus-article-mime-handles nil)
885 (defvar gnus-article-decoded-p nil)
886 (defvar gnus-scores-exclude-files nil)
887 (defvar gnus-page-broken nil)
888 (defvar gnus-inhibit-mime-unbuttonizing nil)
890 (defvar gnus-original-article nil)
891 (defvar gnus-article-internal-prepare-hook nil)
892 (defvar gnus-newsgroup-process-stack nil)
894 (defvar gnus-thread-indent-array nil)
895 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
896 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
897 "Function called to sort the articles within a thread after it has been gathered together.")
899 ;; Avoid highlighting in kill files.
900 (defvar gnus-summary-inhibit-highlight nil)
901 (defvar gnus-newsgroup-selected-overlay nil)
902 (defvar gnus-inhibit-limiting nil)
903 (defvar gnus-newsgroup-adaptive-score-file nil)
904 (defvar gnus-current-score-file nil)
905 (defvar gnus-current-move-group nil)
906 (defvar gnus-current-copy-group nil)
907 (defvar gnus-current-crosspost-group nil)
909 (defvar gnus-newsgroup-dependencies nil)
910 (defvar gnus-newsgroup-adaptive nil)
911 (defvar gnus-summary-display-article-function nil)
912 (defvar gnus-summary-highlight-line-function nil
913 "Function called after highlighting a summary line.")
915 (defvar gnus-summary-line-format-alist
916 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
917 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
918 (?s gnus-tmp-subject-or-nil ?s)
919 (?n gnus-tmp-name ?s)
920 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
922 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
924 (?F gnus-tmp-from ?s)
925 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
926 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
927 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
928 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
929 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
930 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
931 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
932 (?L gnus-tmp-lines ?d)
933 (?I gnus-tmp-indentation ?s)
934 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
935 (?R gnus-tmp-replied ?c)
936 (?\[ gnus-tmp-opening-bracket ?c)
937 (?\] gnus-tmp-closing-bracket ?c)
938 (?\> (make-string gnus-tmp-level ? ) ?s)
939 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
940 (?i gnus-tmp-score ?d)
941 (?z gnus-tmp-score-char ?c)
942 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
943 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
944 (?U gnus-tmp-unread ?c)
945 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
946 (?t (gnus-summary-number-of-articles-in-thread
947 (and (boundp 'thread) (car thread)) gnus-tmp-level)
949 (?e (gnus-summary-number-of-articles-in-thread
950 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
952 (?u gnus-tmp-user-defined ?s)
953 (?P (gnus-pick-line-number) ?d))
954 "An alist of format specifications that can appear in summary lines,
955 and what variables they correspond with, along with the type of the
956 variable (string, integer, character, etc).")
958 (defvar gnus-summary-dummy-line-format-alist
959 `((?S gnus-tmp-subject ?s)
960 (?N gnus-tmp-number ?d)
961 (?u gnus-tmp-user-defined ?s)))
963 (defvar gnus-summary-mode-line-format-alist
964 `((?G gnus-tmp-group-name ?s)
965 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
966 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
967 (?A gnus-tmp-article-number ?d)
968 (?Z gnus-tmp-unread-and-unselected ?s)
970 (?U gnus-tmp-unread-and-unticked ?d)
971 (?S gnus-tmp-subject ?s)
972 (?e gnus-tmp-unselected ?d)
973 (?u gnus-tmp-user-defined ?s)
974 (?d (length gnus-newsgroup-dormant) ?d)
975 (?t (length gnus-newsgroup-marked) ?d)
976 (?r (length gnus-newsgroup-reads) ?d)
977 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
978 (?E gnus-newsgroup-expunged-tally ?d)
979 (?s (gnus-current-score-file-nondirectory) ?s)))
981 (defvar gnus-last-search-regexp nil
982 "Default regexp for article search command.")
984 (defvar gnus-last-shell-command nil
985 "Default shell command on article.")
987 (defvar gnus-newsgroup-begin nil)
988 (defvar gnus-newsgroup-end nil)
989 (defvar gnus-newsgroup-last-rmail nil)
990 (defvar gnus-newsgroup-last-mail nil)
991 (defvar gnus-newsgroup-last-folder nil)
992 (defvar gnus-newsgroup-last-file nil)
993 (defvar gnus-newsgroup-auto-expire nil)
994 (defvar gnus-newsgroup-active nil)
996 (defvar gnus-newsgroup-data nil)
997 (defvar gnus-newsgroup-data-reverse nil)
998 (defvar gnus-newsgroup-limit nil)
999 (defvar gnus-newsgroup-limits nil)
1001 (defvar gnus-newsgroup-unreads nil
1002 "List of unread articles in the current newsgroup.")
1004 (defvar gnus-newsgroup-unselected nil
1005 "List of unselected unread articles in the current newsgroup.")
1007 (defvar gnus-newsgroup-reads nil
1008 "Alist of read articles and article marks in the current newsgroup.")
1010 (defvar gnus-newsgroup-expunged-tally nil)
1012 (defvar gnus-newsgroup-marked nil
1013 "List of ticked articles in the current newsgroup (a subset of unread art).")
1015 (defvar gnus-newsgroup-killed nil
1016 "List of ranges of articles that have been through the scoring process.")
1018 (defvar gnus-newsgroup-cached nil
1019 "List of articles that come from the article cache.")
1021 (defvar gnus-newsgroup-saved nil
1022 "List of articles that have been saved.")
1024 (defvar gnus-newsgroup-kill-headers nil)
1026 (defvar gnus-newsgroup-replied nil
1027 "List of articles that have been replied to in the current newsgroup.")
1029 (defvar gnus-newsgroup-expirable nil
1030 "List of articles in the current newsgroup that can be expired.")
1032 (defvar gnus-newsgroup-processable nil
1033 "List of articles in the current newsgroup that can be processed.")
1035 (defvar gnus-newsgroup-downloadable nil
1036 "List of articles in the current newsgroup that can be processed.")
1038 (defvar gnus-newsgroup-undownloaded nil
1039 "List of articles in the current newsgroup that haven't been downloaded..")
1041 (defvar gnus-newsgroup-unsendable nil
1042 "List of articles in the current newsgroup that won't be sent.")
1044 (defvar gnus-newsgroup-bookmarks nil
1045 "List of articles in the current newsgroup that have bookmarks.")
1047 (defvar gnus-newsgroup-dormant nil
1048 "List of dormant articles in the current newsgroup.")
1050 (defvar gnus-newsgroup-scored nil
1051 "List of scored articles in the current newsgroup.")
1053 (defvar gnus-newsgroup-headers nil
1054 "List of article headers in the current newsgroup.")
1056 (defvar gnus-newsgroup-threads nil)
1058 (defvar gnus-newsgroup-prepared nil
1059 "Whether the current group has been prepared properly.")
1061 (defvar gnus-newsgroup-ancient nil
1062 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1064 (defvar gnus-newsgroup-sparse nil)
1066 (defvar gnus-current-article nil)
1067 (defvar gnus-article-current nil)
1068 (defvar gnus-current-headers nil)
1069 (defvar gnus-have-all-headers nil)
1070 (defvar gnus-last-article nil)
1071 (defvar gnus-newsgroup-history nil)
1072 (defvar gnus-newsgroup-charset nil)
1073 (defvar gnus-newsgroup-ephemeral-charset nil)
1074 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1076 (defconst gnus-summary-local-variables
1077 '(gnus-newsgroup-name
1078 gnus-newsgroup-begin gnus-newsgroup-end
1079 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1080 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1081 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1082 gnus-newsgroup-unselected gnus-newsgroup-marked
1083 gnus-newsgroup-reads gnus-newsgroup-saved
1084 gnus-newsgroup-replied gnus-newsgroup-expirable
1085 gnus-newsgroup-processable gnus-newsgroup-killed
1086 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1087 gnus-newsgroup-unsendable
1088 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1089 gnus-newsgroup-headers gnus-newsgroup-threads
1090 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1091 gnus-current-article gnus-current-headers gnus-have-all-headers
1092 gnus-last-article gnus-article-internal-prepare-hook
1093 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1094 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1095 gnus-thread-expunge-below
1096 gnus-score-alist gnus-current-score-file
1097 (gnus-summary-expunge-below . global)
1098 (gnus-summary-mark-below . global)
1099 gnus-newsgroup-active gnus-scores-exclude-files
1100 gnus-newsgroup-history gnus-newsgroup-ancient
1101 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1102 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1103 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1104 (gnus-newsgroup-expunged-tally . 0)
1105 gnus-cache-removable-articles gnus-newsgroup-cached
1106 gnus-newsgroup-data gnus-newsgroup-data-reverse
1107 gnus-newsgroup-limit gnus-newsgroup-limits
1108 gnus-newsgroup-charset)
1109 "Variables that are buffer-local to the summary buffers.")
1111 ;; Byte-compiler warning.
1112 (defvar gnus-article-mode-map)
1116 (defvar gnus-decode-encoded-word-methods
1117 '(mail-decode-encoded-word-string)
1118 "List of methods used to decode encoded words.
1120 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1121 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1122 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1123 whose names match REGEXP.
1126 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1127 mail-decode-encoded-word-string
1128 (\"chinese\" . rfc1843-decode-string))
1131 (defvar gnus-decode-encoded-word-methods-cache nil)
1133 (defun gnus-multi-decode-encoded-word-string (string)
1134 "Apply the functions from `gnus-encoded-word-methods' that match."
1135 (unless (and gnus-decode-encoded-word-methods-cache
1136 (eq gnus-newsgroup-name
1137 (car gnus-decode-encoded-word-methods-cache)))
1138 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1141 (nconc gnus-decode-encoded-word-methods-cache (list x))
1142 (if (and gnus-newsgroup-name
1143 (string-match (car x) gnus-newsgroup-name))
1144 (nconc gnus-decode-encoded-word-methods-cache
1146 gnus-decode-encoded-word-methods))
1147 (let ((xlist gnus-decode-encoded-word-methods-cache))
1150 (setq string (funcall (pop xlist) string))))
1153 ;; Subject simplification.
1155 (defun gnus-simplify-whitespace (str)
1156 "Remove excessive whitespace."
1159 (while (string-match "[ \t][ \t]+" mystr)
1160 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1162 (substring mystr (match-end 0)))))
1164 (when (string-match "^[ \t]+" mystr)
1165 (setq mystr (substring mystr (match-end 0))))
1167 (when (string-match "[ \t]+$" mystr)
1168 (setq mystr (substring mystr 0 (match-beginning 0))))
1171 (defsubst gnus-simplify-subject-re (subject)
1172 "Remove \"Re:\" from subject lines."
1173 (if (string-match "^[Rr][Ee]: *" subject)
1174 (substring subject (match-end 0))
1177 (defun gnus-simplify-subject (subject &optional re-only)
1178 "Remove `Re:' and words in parentheses.
1179 If RE-ONLY is non-nil, strip leading `Re:'s only."
1180 (let ((case-fold-search t)) ;Ignore case.
1181 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1182 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1183 (setq subject (substring subject (match-end 0))))
1184 ;; Remove uninteresting prefixes.
1185 (when (and (not re-only)
1186 gnus-simplify-ignored-prefixes
1187 (string-match gnus-simplify-ignored-prefixes subject))
1188 (setq subject (substring subject (match-end 0))))
1189 ;; Remove words in parentheses from end.
1191 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1192 (setq subject (substring subject 0 (match-beginning 0)))))
1193 ;; Return subject string.
1196 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1198 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1199 (goto-char (point-min))
1200 (while (re-search-forward regexp nil t)
1201 (replace-match (or newtext ""))))
1203 (defun gnus-simplify-buffer-fuzzy ()
1204 "Simplify string in the buffer fuzzily.
1205 The string in the accessible portion of the current buffer is simplified.
1206 It is assumed to be a single-line subject.
1207 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1208 matter is removed. Additional things can be deleted by setting
1209 gnus-simplify-subject-fuzzy-regexp."
1210 (let ((case-fold-search t)
1212 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1214 (while (not (eq modified-tick (buffer-modified-tick)))
1215 (setq modified-tick (buffer-modified-tick))
1217 ((listp gnus-simplify-subject-fuzzy-regexp)
1218 (mapcar 'gnus-simplify-buffer-fuzzy-step
1219 gnus-simplify-subject-fuzzy-regexp))
1220 (gnus-simplify-subject-fuzzy-regexp
1221 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1222 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1223 (gnus-simplify-buffer-fuzzy-step
1224 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1225 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1227 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1228 (gnus-simplify-buffer-fuzzy-step " +" " ")
1229 (gnus-simplify-buffer-fuzzy-step " $")
1230 (gnus-simplify-buffer-fuzzy-step "^ +")))
1232 (defun gnus-simplify-subject-fuzzy (subject)
1233 "Simplify a subject string fuzzily.
1234 See `gnus-simplify-buffer-fuzzy' for details."
1236 (gnus-set-work-buffer)
1237 (let ((case-fold-search t))
1238 ;; Remove uninteresting prefixes.
1239 (when (and gnus-simplify-ignored-prefixes
1240 (string-match gnus-simplify-ignored-prefixes subject))
1241 (setq subject (substring subject (match-end 0))))
1243 (inline (gnus-simplify-buffer-fuzzy))
1246 (defsubst gnus-simplify-subject-fully (subject)
1247 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1249 (gnus-simplify-subject-functions
1250 (gnus-map-function gnus-simplify-subject-functions subject))
1251 ((null gnus-summary-gather-subject-limit)
1252 (gnus-simplify-subject-re subject))
1253 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1254 (gnus-simplify-subject-fuzzy subject))
1255 ((numberp gnus-summary-gather-subject-limit)
1256 (gnus-limit-string (gnus-simplify-subject-re subject)
1257 gnus-summary-gather-subject-limit))
1261 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1262 "Check whether two subjects are equal.
1263 If optional argument simple-first is t, first argument is already
1266 ((null simple-first)
1267 (equal (gnus-simplify-subject-fully s1)
1268 (gnus-simplify-subject-fully s2)))
1271 (gnus-simplify-subject-fully s2)))))
1273 (defun gnus-summary-bubble-group ()
1274 "Increase the score of the current group.
1275 This is a handy function to add to `gnus-summary-exit-hook' to
1276 increase the score of each group you read."
1277 (gnus-group-add-score gnus-newsgroup-name))
1281 ;;; Gnus summary mode
1284 (put 'gnus-summary-mode 'mode-class 'special)
1287 ;; Non-orthogonal keys
1289 (gnus-define-keys gnus-summary-mode-map
1290 " " gnus-summary-next-page
1291 "\177" gnus-summary-prev-page
1292 [delete] gnus-summary-prev-page
1293 [backspace] gnus-summary-prev-page
1294 "\r" gnus-summary-scroll-up
1295 "\M-\r" gnus-summary-scroll-down
1296 "n" gnus-summary-next-unread-article
1297 "p" gnus-summary-prev-unread-article
1298 "N" gnus-summary-next-article
1299 "P" gnus-summary-prev-article
1300 "\M-\C-n" gnus-summary-next-same-subject
1301 "\M-\C-p" gnus-summary-prev-same-subject
1302 "\M-n" gnus-summary-next-unread-subject
1303 "\M-p" gnus-summary-prev-unread-subject
1304 "." gnus-summary-first-unread-article
1305 "," gnus-summary-best-unread-article
1306 "\M-s" gnus-summary-search-article-forward
1307 "\M-r" gnus-summary-search-article-backward
1308 "<" gnus-summary-beginning-of-article
1309 ">" gnus-summary-end-of-article
1310 "j" gnus-summary-goto-article
1311 "^" gnus-summary-refer-parent-article
1312 "\M-^" gnus-summary-refer-article
1313 "u" gnus-summary-tick-article-forward
1314 "!" gnus-summary-tick-article-forward
1315 "U" gnus-summary-tick-article-backward
1316 "d" gnus-summary-mark-as-read-forward
1317 "D" gnus-summary-mark-as-read-backward
1318 "E" gnus-summary-mark-as-expirable
1319 "\M-u" gnus-summary-clear-mark-forward
1320 "\M-U" gnus-summary-clear-mark-backward
1321 "k" gnus-summary-kill-same-subject-and-select
1322 "\C-k" gnus-summary-kill-same-subject
1323 "\M-\C-k" gnus-summary-kill-thread
1324 "\M-\C-l" gnus-summary-lower-thread
1325 "e" gnus-summary-edit-article
1326 "#" gnus-summary-mark-as-processable
1327 "\M-#" gnus-summary-unmark-as-processable
1328 "\M-\C-t" gnus-summary-toggle-threads
1329 "\M-\C-s" gnus-summary-show-thread
1330 "\M-\C-h" gnus-summary-hide-thread
1331 "\M-\C-f" gnus-summary-next-thread
1332 "\M-\C-b" gnus-summary-prev-thread
1333 [(meta down)] gnus-summary-next-thread
1334 [(meta up)] gnus-summary-prev-thread
1335 "\M-\C-u" gnus-summary-up-thread
1336 "\M-\C-d" gnus-summary-down-thread
1337 "&" gnus-summary-execute-command
1338 "c" gnus-summary-catchup-and-exit
1339 "\C-w" gnus-summary-mark-region-as-read
1340 "\C-t" gnus-summary-toggle-truncation
1341 "?" gnus-summary-mark-as-dormant
1342 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1343 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1344 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1345 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1346 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1347 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1348 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1349 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1350 "=" gnus-summary-expand-window
1351 "\C-x\C-s" gnus-summary-reselect-current-group
1352 "\M-g" gnus-summary-rescan-group
1353 "w" gnus-summary-stop-page-breaking
1354 "\C-c\C-r" gnus-summary-caesar-message
1355 "f" gnus-summary-followup
1356 "F" gnus-summary-followup-with-original
1357 "C" gnus-summary-cancel-article
1358 "r" gnus-summary-reply
1359 "R" gnus-summary-reply-with-original
1360 "\C-c\C-f" gnus-summary-mail-forward
1361 "o" gnus-summary-save-article
1362 "\C-o" gnus-summary-save-article-mail
1363 "|" gnus-summary-pipe-output
1364 "\M-k" gnus-summary-edit-local-kill
1365 "\M-K" gnus-summary-edit-global-kill
1367 "\C-c\C-d" gnus-summary-describe-group
1368 "q" gnus-summary-exit
1369 "Q" gnus-summary-exit-no-update
1370 "\C-c\C-i" gnus-info-find-node
1371 gnus-mouse-2 gnus-mouse-pick-article
1372 "m" gnus-summary-mail-other-window
1373 "a" gnus-summary-post-news
1374 "x" gnus-summary-limit-to-unread
1375 "s" gnus-summary-isearch-article
1376 "t" gnus-summary-toggle-header
1377 "g" gnus-summary-show-article
1378 "l" gnus-summary-goto-last-article
1379 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1380 "\C-d" gnus-summary-enter-digest-group
1381 "\M-\C-d" gnus-summary-read-document
1382 "\M-\C-e" gnus-summary-edit-parameters
1383 "\M-\C-a" gnus-summary-customize-parameters
1385 "*" gnus-cache-enter-article
1386 "\M-*" gnus-cache-remove-article
1387 "\M-&" gnus-summary-universal-argument
1388 "\C-l" gnus-recenter
1389 "I" gnus-summary-increase-score
1390 "L" gnus-summary-lower-score
1391 "\M-i" gnus-symbolic-argument
1392 "h" gnus-summary-select-article-buffer
1394 "b" gnus-article-view-part
1395 "\M-t" gnus-summary-toggle-display-buttonized
1397 "V" gnus-summary-score-map
1398 "X" gnus-uu-extract-map
1399 "S" gnus-summary-send-map)
1401 ;; Sort of orthogonal keymap
1402 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1403 "t" gnus-summary-tick-article-forward
1404 "!" gnus-summary-tick-article-forward
1405 "d" gnus-summary-mark-as-read-forward
1406 "r" gnus-summary-mark-as-read-forward
1407 "c" gnus-summary-clear-mark-forward
1408 " " gnus-summary-clear-mark-forward
1409 "e" gnus-summary-mark-as-expirable
1410 "x" gnus-summary-mark-as-expirable
1411 "?" gnus-summary-mark-as-dormant
1412 "b" gnus-summary-set-bookmark
1413 "B" gnus-summary-remove-bookmark
1414 "#" gnus-summary-mark-as-processable
1415 "\M-#" gnus-summary-unmark-as-processable
1416 "S" gnus-summary-limit-include-expunged
1417 "C" gnus-summary-catchup
1418 "H" gnus-summary-catchup-to-here
1419 "\C-c" gnus-summary-catchup-all
1420 "k" gnus-summary-kill-same-subject-and-select
1421 "K" gnus-summary-kill-same-subject
1422 "P" gnus-uu-mark-map)
1424 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1425 "c" gnus-summary-clear-above
1426 "u" gnus-summary-tick-above
1427 "m" gnus-summary-mark-above
1428 "k" gnus-summary-kill-below)
1430 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1431 "/" gnus-summary-limit-to-subject
1432 "n" gnus-summary-limit-to-articles
1433 "w" gnus-summary-pop-limit
1434 "s" gnus-summary-limit-to-subject
1435 "a" gnus-summary-limit-to-author
1436 "u" gnus-summary-limit-to-unread
1437 "m" gnus-summary-limit-to-marks
1438 "M" gnus-summary-limit-exclude-marks
1439 "v" gnus-summary-limit-to-score
1440 "*" gnus-summary-limit-include-cached
1441 "D" gnus-summary-limit-include-dormant
1442 "T" gnus-summary-limit-include-thread
1443 "d" gnus-summary-limit-exclude-dormant
1444 "t" gnus-summary-limit-to-age
1445 "x" gnus-summary-limit-to-extra
1446 "E" gnus-summary-limit-include-expunged
1447 "c" gnus-summary-limit-exclude-childless-dormant
1448 "C" gnus-summary-limit-mark-excluded-as-read)
1450 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1451 "n" gnus-summary-next-unread-article
1452 "p" gnus-summary-prev-unread-article
1453 "N" gnus-summary-next-article
1454 "P" gnus-summary-prev-article
1455 "\C-n" gnus-summary-next-same-subject
1456 "\C-p" gnus-summary-prev-same-subject
1457 "\M-n" gnus-summary-next-unread-subject
1458 "\M-p" gnus-summary-prev-unread-subject
1459 "f" gnus-summary-first-unread-article
1460 "b" gnus-summary-best-unread-article
1461 "j" gnus-summary-goto-article
1462 "g" gnus-summary-goto-subject
1463 "l" gnus-summary-goto-last-article
1464 "o" gnus-summary-pop-article)
1466 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1467 "k" gnus-summary-kill-thread
1468 "l" gnus-summary-lower-thread
1469 "i" gnus-summary-raise-thread
1470 "T" gnus-summary-toggle-threads
1471 "t" gnus-summary-rethread-current
1472 "^" gnus-summary-reparent-thread
1473 "s" gnus-summary-show-thread
1474 "S" gnus-summary-show-all-threads
1475 "h" gnus-summary-hide-thread
1476 "H" gnus-summary-hide-all-threads
1477 "n" gnus-summary-next-thread
1478 "p" gnus-summary-prev-thread
1479 "u" gnus-summary-up-thread
1480 "o" gnus-summary-top-thread
1481 "d" gnus-summary-down-thread
1482 "#" gnus-uu-mark-thread
1483 "\M-#" gnus-uu-unmark-thread)
1485 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1486 "g" gnus-summary-prepare
1487 "c" gnus-summary-insert-cached-articles)
1489 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1490 "c" gnus-summary-catchup-and-exit
1491 "C" gnus-summary-catchup-all-and-exit
1492 "E" gnus-summary-exit-no-update
1493 "Q" gnus-summary-exit
1494 "Z" gnus-summary-exit
1495 "n" gnus-summary-catchup-and-goto-next-group
1496 "R" gnus-summary-reselect-current-group
1497 "G" gnus-summary-rescan-group
1498 "N" gnus-summary-next-group
1499 "s" gnus-summary-save-newsrc
1500 "P" gnus-summary-prev-group)
1502 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1503 " " gnus-summary-next-page
1504 "n" gnus-summary-next-page
1505 "\177" gnus-summary-prev-page
1506 [delete] gnus-summary-prev-page
1507 "p" gnus-summary-prev-page
1508 "\r" gnus-summary-scroll-up
1509 "\M-\r" gnus-summary-scroll-down
1510 "<" gnus-summary-beginning-of-article
1511 ">" gnus-summary-end-of-article
1512 "b" gnus-summary-beginning-of-article
1513 "e" gnus-summary-end-of-article
1514 "^" gnus-summary-refer-parent-article
1515 "r" gnus-summary-refer-parent-article
1516 "D" gnus-summary-enter-digest-group
1517 "R" gnus-summary-refer-references
1518 "T" gnus-summary-refer-thread
1519 "g" gnus-summary-show-article
1520 "s" gnus-summary-isearch-article
1521 "P" gnus-summary-print-article
1522 "t" gnus-article-babel)
1524 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1525 "b" gnus-article-add-buttons
1526 "B" gnus-article-add-buttons-to-head
1527 "o" gnus-article-treat-overstrike
1528 "e" gnus-article-emphasize
1529 "w" gnus-article-fill-cited-article
1530 "Q" gnus-article-fill-long-lines
1531 "C" gnus-article-capitalize-sentences
1532 "c" gnus-article-remove-cr
1533 "q" gnus-article-de-quoted-unreadable
1534 "f" gnus-article-display-x-face
1535 "l" gnus-summary-stop-page-breaking
1536 "r" gnus-summary-caesar-message
1537 "t" gnus-article-hide-headers
1538 "v" gnus-summary-verbose-headers
1539 "H" gnus-article-strip-headers-in-body
1540 "d" gnus-article-treat-dumbquotes)
1542 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1543 "a" gnus-article-hide
1544 "h" gnus-article-hide-headers
1545 "b" gnus-article-hide-boring-headers
1546 "s" gnus-article-hide-signature
1547 "c" gnus-article-hide-citation
1548 "C" gnus-article-hide-citation-in-followups
1549 "l" gnus-article-hide-list-identifiers
1550 "p" gnus-article-hide-pgp
1551 "B" gnus-article-strip-banner
1552 "P" gnus-article-hide-pem
1553 "\C-c" gnus-article-hide-citation-maybe)
1555 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1556 "a" gnus-article-highlight
1557 "h" gnus-article-highlight-headers
1558 "c" gnus-article-highlight-citation
1559 "s" gnus-article-highlight-signature)
1561 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1562 "w" gnus-article-decode-mime-words
1563 "c" gnus-article-decode-charset
1564 "v" gnus-mime-view-all-parts
1565 "b" gnus-article-view-part)
1567 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1568 "z" gnus-article-date-ut
1569 "u" gnus-article-date-ut
1570 "l" gnus-article-date-local
1571 "e" gnus-article-date-lapsed
1572 "o" gnus-article-date-original
1573 "i" gnus-article-date-iso8601
1574 "s" gnus-article-date-user)
1576 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1577 "t" gnus-article-remove-trailing-blank-lines
1578 "l" gnus-article-strip-leading-blank-lines
1579 "m" gnus-article-strip-multiple-blank-lines
1580 "a" gnus-article-strip-blank-lines
1581 "A" gnus-article-strip-all-blank-lines
1582 "s" gnus-article-strip-leading-space
1583 "e" gnus-article-strip-trailing-space)
1585 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1587 "f" gnus-summary-fetch-faq
1588 "d" gnus-summary-describe-group
1589 "h" gnus-summary-describe-briefly
1590 "i" gnus-info-find-node)
1592 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1593 "e" gnus-summary-expire-articles
1594 "\M-\C-e" gnus-summary-expire-articles-now
1595 "\177" gnus-summary-delete-article
1596 [delete] gnus-summary-delete-article
1597 [backspace] gnus-summary-delete-article
1598 "m" gnus-summary-move-article
1599 "r" gnus-summary-respool-article
1600 "w" gnus-summary-edit-article
1601 "c" gnus-summary-copy-article
1602 "B" gnus-summary-crosspost-article
1603 "q" gnus-summary-respool-query
1604 "t" gnus-summary-respool-trace
1605 "i" gnus-summary-import-article
1606 "p" gnus-summary-article-posted-p)
1608 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1609 "o" gnus-summary-save-article
1610 "m" gnus-summary-save-article-mail
1611 "F" gnus-summary-write-article-file
1612 "r" gnus-summary-save-article-rmail
1613 "f" gnus-summary-save-article-file
1614 "b" gnus-summary-save-article-body-file
1615 "h" gnus-summary-save-article-folder
1616 "v" gnus-summary-save-article-vm
1617 "p" gnus-summary-pipe-output
1618 "s" gnus-soup-add-article)
1620 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1621 "b" gnus-summary-display-buttonized
1622 "m" gnus-summary-repair-multipart
1623 "v" gnus-article-view-part
1624 "o" gnus-article-save-part
1625 "c" gnus-article-copy-part
1626 "e" gnus-article-externalize-part
1627 "i" gnus-article-inline-part
1628 "|" gnus-article-pipe-part))
1630 (defun gnus-summary-make-menu-bar ()
1631 (gnus-turn-off-edit-menu 'summary)
1633 (unless (boundp 'gnus-summary-misc-menu)
1636 gnus-summary-kill-menu gnus-summary-mode-map ""
1641 ["Enter score..." gnus-summary-score-entry t]
1642 ["Customize" gnus-score-customize t])
1643 (gnus-make-score-map 'increase)
1644 (gnus-make-score-map 'lower)
1646 ["Kill below" gnus-summary-kill-below t]
1647 ["Mark above" gnus-summary-mark-above t]
1648 ["Tick above" gnus-summary-tick-above t]
1649 ["Clear above" gnus-summary-clear-above t])
1650 ["Current score" gnus-summary-current-score t]
1651 ["Set score" gnus-summary-set-score t]
1652 ["Switch current score file..." gnus-score-change-score-file t]
1653 ["Set mark below..." gnus-score-set-mark-below t]
1654 ["Set expunge below..." gnus-score-set-expunge-below t]
1655 ["Edit current score file" gnus-score-edit-current-scores t]
1656 ["Edit score file" gnus-score-edit-file t]
1657 ["Trace score" gnus-score-find-trace t]
1658 ["Find words" gnus-score-find-favourite-words t]
1659 ["Rescore buffer" gnus-summary-rescore t]
1660 ["Increase score..." gnus-summary-increase-score t]
1661 ["Lower score..." gnus-summary-lower-score t]))))
1663 ;; Define both the Article menu in the summary buffer and the equivalent
1664 ;; Commands menu in the article buffer here for consistency.
1667 ["All" gnus-article-hide t]
1668 ["Headers" gnus-article-hide-headers t]
1669 ["Signature" gnus-article-hide-signature t]
1670 ["Citation" gnus-article-hide-citation t]
1671 ["List identifiers" gnus-article-hide-list-identifiers t]
1672 ["PGP" gnus-article-hide-pgp t]
1673 ["Banner" gnus-article-strip-banner t]
1674 ["Boring headers" gnus-article-hide-boring-headers t])
1676 ["All" gnus-article-highlight t]
1677 ["Headers" gnus-article-highlight-headers t]
1678 ["Signature" gnus-article-highlight-signature t]
1679 ["Citation" gnus-article-highlight-citation t])
1681 ["Words" gnus-article-decode-mime-words t]
1682 ["Charset" gnus-article-decode-charset t]
1683 ["QP" gnus-article-de-quoted-unreadable t]
1684 ["View all" gnus-mime-view-all-parts t])
1686 ["Local" gnus-article-date-local t]
1687 ["ISO8601" gnus-article-date-iso8601 t]
1688 ["UT" gnus-article-date-ut t]
1689 ["Original" gnus-article-date-original t]
1690 ["Lapsed" gnus-article-date-lapsed t]
1691 ["User-defined" gnus-article-date-user t])
1694 ["Leading" gnus-article-strip-leading-blank-lines t]
1695 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1696 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1697 ["All of the above" gnus-article-strip-blank-lines t]
1698 ["All" gnus-article-strip-all-blank-lines t]
1699 ["Leading space" gnus-article-strip-leading-space t]
1700 ["Trailing space" gnus-article-strip-trailing-space t])
1701 ["Overstrike" gnus-article-treat-overstrike t]
1702 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1703 ["Emphasis" gnus-article-emphasize t]
1704 ["Word wrap" gnus-article-fill-cited-article t]
1705 ["Fill long lines" gnus-article-fill-long-lines t]
1706 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1707 ["CR" gnus-article-remove-cr t]
1708 ["Show X-Face" gnus-article-display-x-face t]
1709 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1710 ["Rot 13" gnus-summary-caesar-message t]
1711 ["Unix pipe" gnus-summary-pipe-message t]
1712 ["Add buttons" gnus-article-add-buttons t]
1713 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1714 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1715 ["Verbose header" gnus-summary-verbose-headers t]
1716 ["Toggle header" gnus-summary-toggle-header t]
1717 ["HZ" gnus-article-decode-HZ t])
1719 ["Save in default format" gnus-summary-save-article t]
1720 ["Save in file" gnus-summary-save-article-file t]
1721 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1722 ["Save in MH folder" gnus-summary-save-article-folder t]
1723 ["Save in VM folder" gnus-summary-save-article-vm t]
1724 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1725 ["Save body in file" gnus-summary-save-article-body-file t]
1726 ["Pipe through a filter" gnus-summary-pipe-output t]
1727 ["Add to SOUP packet" gnus-soup-add-article t]
1728 ["Print" gnus-summary-print-article t])
1730 ["Respool article..." gnus-summary-respool-article t]
1731 ["Move article..." gnus-summary-move-article
1732 (gnus-check-backend-function
1733 'request-move-article gnus-newsgroup-name)]
1734 ["Copy article..." gnus-summary-copy-article t]
1735 ["Crosspost article..." gnus-summary-crosspost-article
1736 (gnus-check-backend-function
1737 'request-replace-article gnus-newsgroup-name)]
1738 ["Import file..." gnus-summary-import-article t]
1739 ["Check if posted" gnus-summary-article-posted-p t]
1740 ["Edit article" gnus-summary-edit-article
1741 (not (gnus-group-read-only-p))]
1742 ["Delete article" gnus-summary-delete-article
1743 (gnus-check-backend-function
1744 'request-expire-articles gnus-newsgroup-name)]
1745 ["Query respool" gnus-summary-respool-query t]
1746 ["Trace respool" gnus-summary-respool-trace t]
1747 ["Delete expirable articles" gnus-summary-expire-articles-now
1748 (gnus-check-backend-function
1749 'request-expire-articles gnus-newsgroup-name)])
1751 ["Uudecode" gnus-uu-decode-uu t]
1752 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1753 ["Unshar" gnus-uu-decode-unshar t]
1754 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1755 ["Save" gnus-uu-decode-save t]
1756 ["Binhex" gnus-uu-decode-binhex t]
1757 ["Postscript" gnus-uu-decode-postscript t])
1759 ["Enter article" gnus-cache-enter-article t]
1760 ["Remove article" gnus-cache-remove-article t])
1761 ["Translate" gnus-article-babel t]
1762 ["Select article buffer" gnus-summary-select-article-buffer t]
1763 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1764 ["Isearch article..." gnus-summary-isearch-article t]
1765 ["Beginning of the article" gnus-summary-beginning-of-article t]
1766 ["End of the article" gnus-summary-end-of-article t]
1767 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1768 ["Fetch referenced articles" gnus-summary-refer-references t]
1769 ["Fetch current thread" gnus-summary-refer-thread t]
1770 ["Fetch article with id..." gnus-summary-refer-article t]
1771 ["Redisplay" gnus-summary-show-article t])))
1773 gnus-summary-article-menu gnus-summary-mode-map ""
1774 (cons "Article" innards))
1777 gnus-article-commands-menu gnus-article-mode-map ""
1778 (cons "Commands" innards)))
1781 gnus-summary-thread-menu gnus-summary-mode-map ""
1783 ["Toggle threading" gnus-summary-toggle-threads t]
1784 ["Hide threads" gnus-summary-hide-all-threads t]
1785 ["Show threads" gnus-summary-show-all-threads t]
1786 ["Hide thread" gnus-summary-hide-thread t]
1787 ["Show thread" gnus-summary-show-thread t]
1788 ["Go to next thread" gnus-summary-next-thread t]
1789 ["Go to previous thread" gnus-summary-prev-thread t]
1790 ["Go down thread" gnus-summary-down-thread t]
1791 ["Go up thread" gnus-summary-up-thread t]
1792 ["Top of thread" gnus-summary-top-thread t]
1793 ["Mark thread as read" gnus-summary-kill-thread t]
1794 ["Lower thread score" gnus-summary-lower-thread t]
1795 ["Raise thread score" gnus-summary-raise-thread t]
1796 ["Rethread current" gnus-summary-rethread-current t]))
1799 gnus-summary-post-menu gnus-summary-mode-map ""
1801 ["Post an article" gnus-summary-post-news t]
1802 ["Followup" gnus-summary-followup t]
1803 ["Followup and yank" gnus-summary-followup-with-original t]
1804 ["Supersede article" gnus-summary-supersede-article t]
1805 ["Cancel article" gnus-summary-cancel-article t]
1806 ["Reply" gnus-summary-reply t]
1807 ["Reply and yank" gnus-summary-reply-with-original t]
1808 ["Wide reply" gnus-summary-wide-reply t]
1809 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1810 ["Mail forward" gnus-summary-mail-forward t]
1811 ["Post forward" gnus-summary-post-forward t]
1812 ["Digest and mail" gnus-uu-digest-mail-forward t]
1813 ["Digest and post" gnus-uu-digest-post-forward t]
1814 ["Resend message" gnus-summary-resend-message t]
1815 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1816 ["Send a mail" gnus-summary-mail-other-window t]
1817 ["Uuencode and post" gnus-uu-post-news t]
1818 ["Followup via news" gnus-summary-followup-to-mail t]
1819 ["Followup via news and yank"
1820 gnus-summary-followup-to-mail-with-original t]
1822 ;;["Send" gnus-summary-send-draft t]
1823 ;;["Send bounced" gnus-resend-bounced-mail t])
1827 gnus-summary-misc-menu gnus-summary-mode-map ""
1830 ["Mark as read" gnus-summary-mark-as-read-forward t]
1831 ["Mark same subject and select"
1832 gnus-summary-kill-same-subject-and-select t]
1833 ["Mark same subject" gnus-summary-kill-same-subject t]
1834 ["Catchup" gnus-summary-catchup t]
1835 ["Catchup all" gnus-summary-catchup-all t]
1836 ["Catchup to here" gnus-summary-catchup-to-here t]
1837 ["Catchup region" gnus-summary-mark-region-as-read t]
1838 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1840 ["Tick" gnus-summary-tick-article-forward t]
1841 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1842 ["Remove marks" gnus-summary-clear-mark-forward t]
1843 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1844 ["Set bookmark" gnus-summary-set-bookmark t]
1845 ["Remove bookmark" gnus-summary-remove-bookmark t])
1847 ["Marks..." gnus-summary-limit-to-marks t]
1848 ["Subject..." gnus-summary-limit-to-subject t]
1849 ["Author..." gnus-summary-limit-to-author t]
1850 ["Age..." gnus-summary-limit-to-age t]
1851 ["Extra..." gnus-summary-limit-to-extra t]
1852 ["Score" gnus-summary-limit-to-score t]
1853 ["Unread" gnus-summary-limit-to-unread t]
1854 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1855 ["Articles" gnus-summary-limit-to-articles t]
1856 ["Pop limit" gnus-summary-pop-limit t]
1857 ["Show dormant" gnus-summary-limit-include-dormant t]
1858 ["Hide childless dormant"
1859 gnus-summary-limit-exclude-childless-dormant t]
1860 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1861 ["Hide marked" gnus-summary-limit-exclude-marks t]
1862 ["Show expunged" gnus-summary-show-all-expunged t])
1864 ["Set mark" gnus-summary-mark-as-processable t]
1865 ["Remove mark" gnus-summary-unmark-as-processable t]
1866 ["Remove all marks" gnus-summary-unmark-all-processable t]
1867 ["Mark above" gnus-uu-mark-over t]
1868 ["Mark series" gnus-uu-mark-series t]
1869 ["Mark region" gnus-uu-mark-region t]
1870 ["Unmark region" gnus-uu-unmark-region t]
1871 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1872 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1873 ["Mark all" gnus-uu-mark-all t]
1874 ["Mark buffer" gnus-uu-mark-buffer t]
1875 ["Mark sparse" gnus-uu-mark-sparse t]
1876 ["Mark thread" gnus-uu-mark-thread t]
1877 ["Unmark thread" gnus-uu-unmark-thread t]
1878 ("Process Mark Sets"
1879 ["Kill" gnus-summary-kill-process-mark t]
1880 ["Yank" gnus-summary-yank-process-mark
1881 gnus-newsgroup-process-stack]
1882 ["Save" gnus-summary-save-process-mark t]))
1884 ["Page forward" gnus-summary-next-page t]
1885 ["Page backward" gnus-summary-prev-page t]
1886 ["Line forward" gnus-summary-scroll-up t])
1888 ["Next unread article" gnus-summary-next-unread-article t]
1889 ["Previous unread article" gnus-summary-prev-unread-article t]
1890 ["Next article" gnus-summary-next-article t]
1891 ["Previous article" gnus-summary-prev-article t]
1892 ["Next unread subject" gnus-summary-next-unread-subject t]
1893 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1894 ["Next article same subject" gnus-summary-next-same-subject t]
1895 ["Previous article same subject" gnus-summary-prev-same-subject t]
1896 ["First unread article" gnus-summary-first-unread-article t]
1897 ["Best unread article" gnus-summary-best-unread-article t]
1898 ["Go to subject number..." gnus-summary-goto-subject t]
1899 ["Go to article number..." gnus-summary-goto-article t]
1900 ["Go to the last article" gnus-summary-goto-last-article t]
1901 ["Pop article off history" gnus-summary-pop-article t])
1903 ["Sort by number" gnus-summary-sort-by-number t]
1904 ["Sort by author" gnus-summary-sort-by-author t]
1905 ["Sort by subject" gnus-summary-sort-by-subject t]
1906 ["Sort by date" gnus-summary-sort-by-date t]
1907 ["Sort by score" gnus-summary-sort-by-score t]
1908 ["Sort by lines" gnus-summary-sort-by-lines t]
1909 ["Sort by characters" gnus-summary-sort-by-chars t])
1911 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1912 ["Describe group" gnus-summary-describe-group t]
1913 ["Read manual" gnus-info-find-node t])
1915 ["Pick and read" gnus-pick-mode t]
1916 ["Binary" gnus-binary-mode t])
1918 ["Regenerate" gnus-summary-prepare t]
1919 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1920 ["Toggle threading" gnus-summary-toggle-threads t])
1921 ["Filter articles..." gnus-summary-execute-command t]
1922 ["Run command on subjects..." gnus-summary-universal-argument t]
1923 ["Search articles forward..." gnus-summary-search-article-forward t]
1924 ["Search articles backward..." gnus-summary-search-article-backward t]
1925 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1926 ["Expand window" gnus-summary-expand-window t]
1927 ["Expire expirable articles" gnus-summary-expire-articles
1928 (gnus-check-backend-function
1929 'request-expire-articles gnus-newsgroup-name)]
1930 ["Edit local kill file" gnus-summary-edit-local-kill t]
1931 ["Edit main kill file" gnus-summary-edit-global-kill t]
1932 ["Edit group parameters" gnus-summary-edit-parameters t]
1933 ["Customize group parameters" gnus-summary-customize-parameters t]
1934 ["Send a bug report" gnus-bug t]
1936 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1937 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1938 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1939 ["Exit group" gnus-summary-exit t]
1940 ["Exit group without updating" gnus-summary-exit-no-update t]
1941 ["Exit and goto next group" gnus-summary-next-group t]
1942 ["Exit and goto prev group" gnus-summary-prev-group t]
1943 ["Reselect group" gnus-summary-reselect-current-group t]
1944 ["Rescan group" gnus-summary-rescan-group t]
1945 ["Update dribble" gnus-summary-save-newsrc t])))
1947 (gnus-run-hooks 'gnus-summary-menu-hook)))
1949 (defun gnus-score-set-default (var value)
1950 "A version of set that updates the GNU Emacs menu-bar."
1952 ;; It is the message that forces the active status to be updated.
1955 (defun gnus-make-score-map (type)
1956 "Make a summary score map of type TYPE."
1959 (let ((headers '(("author" "from" string)
1960 ("subject" "subject" string)
1961 ("article body" "body" string)
1962 ("article head" "head" string)
1963 ("xref" "xref" string)
1964 ("extra header" "extra" string)
1965 ("lines" "lines" number)
1966 ("followups to author" "followup" string)))
1967 (types '((number ("less than" <)
1970 (string ("substring" s)
1974 (perms '(("temporary" (current-time-string))
1982 (if (eq type 'lower)
1987 (setq header (car headers))
1993 (let ((ts (cdr (assoc (nth 2 header) types)))
2009 'gnus-summary-score-entry
2011 (if (or (string= (nth 1 header)
2013 (string= (nth 1 header)
2016 (list 'gnus-summary-header
2018 (list 'quote (nth 1 (car ts)))
2019 (list 'gnus-score-delta-default
2026 (list (nreverse outp))))
2029 (list (nreverse outt))))
2031 (setq headers (cdr headers)))
2032 (list (nreverse outh))))))))
2036 (defun gnus-summary-mode (&optional group)
2037 "Major mode for reading articles.
2039 All normal editing commands are switched off.
2040 \\<gnus-summary-mode-map>
2041 Each line in this buffer represents one article. To read an
2042 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2043 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2046 You can also post articles and send mail from this buffer. To
2047 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2048 of an article, type `\\[gnus-summary-reply]'.
2050 There are approx. one gazillion commands you can execute in this
2051 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2053 The following commands are available:
2055 \\{gnus-summary-mode-map}"
2057 (when (gnus-visual-p 'summary-menu 'menu)
2058 (gnus-summary-make-menu-bar))
2059 (kill-all-local-variables)
2060 (gnus-summary-make-local-variables)
2061 (gnus-make-thread-indent-array)
2062 (gnus-simplify-mode-line)
2063 (setq major-mode 'gnus-summary-mode)
2064 (setq mode-name "Summary")
2065 (make-local-variable 'minor-mode-alist)
2066 (use-local-map gnus-summary-mode-map)
2067 (buffer-disable-undo)
2068 (setq buffer-read-only t) ;Disable modification
2069 (setq truncate-lines t)
2070 (setq selective-display t)
2071 (setq selective-display-ellipses t) ;Display `...'
2072 (gnus-summary-set-display-table)
2073 (gnus-set-default-directory)
2074 (setq gnus-newsgroup-name group)
2075 (make-local-variable 'gnus-summary-line-format)
2076 (make-local-variable 'gnus-summary-line-format-spec)
2077 (make-local-variable 'gnus-summary-dummy-line-format)
2078 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2079 (make-local-variable 'gnus-summary-mark-positions)
2080 (make-local-hook 'pre-command-hook)
2081 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2082 (gnus-run-hooks 'gnus-summary-mode-hook)
2083 (mm-enable-multibyte)
2084 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2085 (gnus-update-summary-mark-positions))
2087 (defun gnus-summary-make-local-variables ()
2088 "Make all the local summary buffer variables."
2090 (dolist (local gnus-summary-local-variables)
2093 (if (eq (cdr local) 'global)
2094 ;; Copy the global value of the variable.
2095 (setq global (symbol-value (car local)))
2096 ;; Use the value from the list.
2097 (setq global (eval (cdr local))))
2098 (set (make-local-variable (car local)) global))
2099 ;; Simple nil-valued local variable.
2100 (set (make-local-variable local) nil)))))
2102 (defun gnus-summary-clear-local-variables ()
2103 (let ((locals gnus-summary-local-variables))
2105 (if (consp (car locals))
2106 (and (vectorp (caar locals))
2107 (set (caar locals) nil))
2108 (and (vectorp (car locals))
2109 (set (car locals) nil)))
2110 (setq locals (cdr locals)))))
2112 ;; Summary data functions.
2114 (defmacro gnus-data-number (data)
2117 (defmacro gnus-data-set-number (data number)
2118 `(setcar ,data ,number))
2120 (defmacro gnus-data-mark (data)
2123 (defmacro gnus-data-set-mark (data mark)
2124 `(setcar (nthcdr 1 ,data) ,mark))
2126 (defmacro gnus-data-pos (data)
2129 (defmacro gnus-data-set-pos (data pos)
2130 `(setcar (nthcdr 2 ,data) ,pos))
2132 (defmacro gnus-data-header (data)
2135 (defmacro gnus-data-set-header (data header)
2136 `(setf (nth 3 ,data) ,header))
2138 (defmacro gnus-data-level (data)
2141 (defmacro gnus-data-unread-p (data)
2142 `(= (nth 1 ,data) gnus-unread-mark))
2144 (defmacro gnus-data-read-p (data)
2145 `(/= (nth 1 ,data) gnus-unread-mark))
2147 (defmacro gnus-data-pseudo-p (data)
2148 `(consp (nth 3 ,data)))
2150 (defmacro gnus-data-find (number)
2151 `(assq ,number gnus-newsgroup-data))
2153 (defmacro gnus-data-find-list (number &optional data)
2154 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2155 (memq (assq ,number bdata)
2158 (defmacro gnus-data-make (number mark pos header level)
2159 `(list ,number ,mark ,pos ,header ,level))
2161 (defun gnus-data-enter (after-article number mark pos header level offset)
2162 (let ((data (gnus-data-find-list after-article)))
2164 (error "No such article: %d" after-article))
2165 (setcdr data (cons (gnus-data-make number mark pos header level)
2167 (setq gnus-newsgroup-data-reverse nil)
2168 (gnus-data-update-list (cddr data) offset)))
2170 (defun gnus-data-enter-list (after-article list &optional offset)
2172 (let ((data (and after-article (gnus-data-find-list after-article)))
2176 (let ((odata gnus-newsgroup-data))
2177 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2179 (gnus-data-update-list odata offset)))
2180 ;; Find the last element in the list to be spliced into the main
2183 (setq list (cdr list)))
2186 (setcdr list gnus-newsgroup-data)
2187 (setq gnus-newsgroup-data ilist)
2189 (gnus-data-update-list (cdr list) offset)))
2190 (setcdr list (cdr data))
2193 (gnus-data-update-list (cdr list) offset))))
2194 (setq gnus-newsgroup-data-reverse nil))))
2196 (defun gnus-data-remove (article &optional offset)
2197 (let ((data gnus-newsgroup-data))
2198 (if (= (gnus-data-number (car data)) article)
2200 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2201 gnus-newsgroup-data-reverse nil)
2203 (gnus-data-update-list gnus-newsgroup-data offset)))
2205 (when (= (gnus-data-number (cadr data)) article)
2206 (setcdr data (cddr data))
2208 (gnus-data-update-list (cdr data) offset))
2210 gnus-newsgroup-data-reverse nil))
2211 (setq data (cdr data))))))
2213 (defmacro gnus-data-list (backward)
2215 (or gnus-newsgroup-data-reverse
2216 (setq gnus-newsgroup-data-reverse
2217 (reverse gnus-newsgroup-data)))
2218 gnus-newsgroup-data))
2220 (defun gnus-data-update-list (data offset)
2221 "Add OFFSET to the POS of all data entries in DATA."
2222 (setq gnus-newsgroup-data-reverse nil)
2224 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2225 (setq data (cdr data))))
2227 (defun gnus-summary-article-pseudo-p (article)
2228 "Say whether this article is a pseudo article or not."
2229 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2231 (defmacro gnus-summary-article-sparse-p (article)
2232 "Say whether this article is a sparse article or not."
2233 `(memq ,article gnus-newsgroup-sparse))
2235 (defmacro gnus-summary-article-ancient-p (article)
2236 "Say whether this article is a sparse article or not."
2237 `(memq ,article gnus-newsgroup-ancient))
2239 (defun gnus-article-parent-p (number)
2240 "Say whether this article is a parent or not."
2241 (let ((data (gnus-data-find-list number)))
2242 (and (cdr data) ; There has to be an article after...
2243 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2244 (gnus-data-level (nth 1 data))))))
2246 (defun gnus-article-children (number)
2247 "Return a list of all children to NUMBER."
2248 (let* ((data (gnus-data-find-list number))
2249 (level (gnus-data-level (car data)))
2251 (setq data (cdr data))
2253 (= (gnus-data-level (car data)) (1+ level)))
2254 (push (gnus-data-number (car data)) children)
2255 (setq data (cdr data)))
2258 (defmacro gnus-summary-skip-intangible ()
2259 "If the current article is intangible, then jump to a different article."
2260 '(let ((to (get-text-property (point) 'gnus-intangible)))
2261 (and to (gnus-summary-goto-subject to))))
2263 (defmacro gnus-summary-article-intangible-p ()
2264 "Say whether this article is intangible or not."
2265 '(get-text-property (point) 'gnus-intangible))
2267 (defun gnus-article-read-p (article)
2268 "Say whether ARTICLE is read or not."
2269 (not (or (memq article gnus-newsgroup-marked)
2270 (memq article gnus-newsgroup-unreads)
2271 (memq article gnus-newsgroup-unselected)
2272 (memq article gnus-newsgroup-dormant))))
2274 ;; Some summary mode macros.
2276 (defmacro gnus-summary-article-number ()
2277 "The article number of the article on the current line.
2278 If there isn's an article number here, then we return the current
2281 (gnus-summary-skip-intangible)
2282 (or (get-text-property (point) 'gnus-number)
2283 (gnus-summary-last-subject))))
2285 (defmacro gnus-summary-article-header (&optional number)
2286 "Return the header of article NUMBER."
2287 `(gnus-data-header (gnus-data-find
2288 ,(or number '(gnus-summary-article-number)))))
2290 (defmacro gnus-summary-thread-level (&optional number)
2291 "Return the level of thread that starts with article NUMBER."
2292 `(if (and (eq gnus-summary-make-false-root 'dummy)
2293 (get-text-property (point) 'gnus-intangible))
2295 (gnus-data-level (gnus-data-find
2296 ,(or number '(gnus-summary-article-number))))))
2298 (defmacro gnus-summary-article-mark (&optional number)
2299 "Return the mark of article NUMBER."
2300 `(gnus-data-mark (gnus-data-find
2301 ,(or number '(gnus-summary-article-number)))))
2303 (defmacro gnus-summary-article-pos (&optional number)
2304 "Return the position of the line of article NUMBER."
2305 `(gnus-data-pos (gnus-data-find
2306 ,(or number '(gnus-summary-article-number)))))
2308 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2309 (defmacro gnus-summary-article-subject (&optional number)
2310 "Return current subject string or nil if nothing."
2313 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2314 '(gnus-data-header (assq (gnus-summary-article-number)
2315 gnus-newsgroup-data)))))
2318 (mail-header-subject headers))))
2320 (defmacro gnus-summary-article-score (&optional number)
2321 "Return current article score."
2322 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2323 gnus-newsgroup-scored))
2324 gnus-summary-default-score 0))
2326 (defun gnus-summary-article-children (&optional number)
2327 "Return a list of article numbers that are children of article NUMBER."
2328 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2329 (level (gnus-data-level (car data)))
2331 (while (and (setq data (cdr data))
2332 (> (setq l (gnus-data-level (car data))) level))
2333 (and (= (1+ level) l)
2334 (push (gnus-data-number (car data))
2336 (nreverse children)))
2338 (defun gnus-summary-article-parent (&optional number)
2339 "Return the article number of the parent of article NUMBER."
2340 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2341 (gnus-data-list t)))
2342 (level (gnus-data-level (car data))))
2344 () ; This is a root.
2345 ;; We search until we find an article with a level less than
2346 ;; this one. That function has to be the parent.
2347 (while (and (setq data (cdr data))
2348 (not (< (gnus-data-level (car data)) level))))
2349 (and data (gnus-data-number (car data))))))
2351 (defun gnus-unread-mark-p (mark)
2352 "Say whether MARK is the unread mark."
2353 (= mark gnus-unread-mark))
2355 (defun gnus-read-mark-p (mark)
2356 "Say whether MARK is one of the marks that mark as read.
2357 This is all marks except unread, ticked, dormant, and expirable."
2358 (not (or (= mark gnus-unread-mark)
2359 (= mark gnus-ticked-mark)
2360 (= mark gnus-dormant-mark)
2361 (= mark gnus-expirable-mark))))
2363 (defmacro gnus-article-mark (number)
2364 "Return the MARK of article NUMBER.
2365 This macro should only be used when computing the mark the \"first\"
2366 time; i.e., when generating the summary lines. After that,
2367 `gnus-summary-article-mark' should be used to examine the
2370 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2371 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2372 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2373 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2374 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2375 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2376 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2377 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2378 gnus-ancient-mark))))
2380 ;; Saving hidden threads.
2382 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2383 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2385 (defmacro gnus-save-hidden-threads (&rest forms)
2386 "Save hidden threads, eval FORMS, and restore the hidden threads."
2387 (let ((config (make-symbol "config")))
2388 `(let ((,config (gnus-hidden-threads-configuration)))
2392 (gnus-restore-hidden-threads-configuration ,config)))))
2394 (defun gnus-data-compute-positions ()
2395 "Compute the positions of all articles."
2396 (setq gnus-newsgroup-data-reverse nil)
2397 (let ((data gnus-newsgroup-data))
2399 (gnus-save-hidden-threads
2400 (gnus-summary-show-all-threads)
2401 (goto-char (point-min))
2403 (while (get-text-property (point) 'gnus-intangible)
2405 (gnus-data-set-pos (car data) (+ (point) 3))
2406 (setq data (cdr data))
2407 (forward-line 1))))))
2409 (defun gnus-hidden-threads-configuration ()
2410 "Return the current hidden threads configuration."
2413 (goto-char (point-min))
2414 (while (search-forward "\r" nil t)
2415 (push (1- (point)) config))
2418 (defun gnus-restore-hidden-threads-configuration (config)
2419 "Restore hidden threads configuration from CONFIG."
2420 (let (point buffer-read-only)
2421 (while (setq point (pop config))
2422 (when (and (< point (point-max))
2424 (eq (char-after) ?\n))
2425 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2427 ;; Various summary mode internalish functions.
2429 (defun gnus-mouse-pick-article (e)
2432 (gnus-summary-next-page nil t))
2434 (defun gnus-summary-set-display-table ()
2435 ;; Change the display table. Odd characters have a tendency to mess
2436 ;; up nicely formatted displays - we make all possible glyphs
2437 ;; display only a single character.
2439 ;; We start from the standard display table, if any.
2440 (let ((table (or (copy-sequence standard-display-table)
2441 (make-display-table)))
2443 ;; Nix out all the control chars...
2444 (while (>= (setq i (1- i)) 0)
2445 (aset table i [??]))
2446 ;; ... but not newline and cr, of course. (cr is necessary for the
2447 ;; selective display).
2448 (aset table ?\n nil)
2449 (aset table ?\r nil)
2450 ;; We keep TAB as well.
2451 (aset table ?\t nil)
2452 ;; We nix out any glyphs over 126 that are not set already.
2454 (while (>= (setq i (1- i)) 127)
2455 ;; Only modify if the entry is nil.
2456 (unless (aref table i)
2457 (aset table i [??]))))
2458 (setq buffer-display-table table)))
2460 (defun gnus-summary-setup-buffer (group)
2461 "Initialize summary buffer."
2462 (let ((buffer (concat "*Summary " group "*")))
2463 (if (get-buffer buffer)
2466 (setq gnus-summary-buffer (current-buffer))
2467 (not gnus-newsgroup-prepared))
2468 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2469 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2470 (gnus-summary-mode group)
2472 (gnus-carpal-setup-buffer 'summary))
2473 (unless gnus-single-article-buffer
2474 (make-local-variable 'gnus-article-buffer)
2475 (make-local-variable 'gnus-article-current)
2476 (make-local-variable 'gnus-original-article-buffer))
2477 (setq gnus-newsgroup-name group)
2480 (defun gnus-set-global-variables ()
2481 ;; Set the global equivalents of the summary buffer-local variables
2482 ;; to the latest values they had. These reflect the summary buffer
2483 ;; that was in action when the last article was fetched.
2484 (when (eq major-mode 'gnus-summary-mode)
2485 (setq gnus-summary-buffer (current-buffer))
2486 (let ((name gnus-newsgroup-name)
2487 (marked gnus-newsgroup-marked)
2488 (unread gnus-newsgroup-unreads)
2489 (headers gnus-current-headers)
2490 (data gnus-newsgroup-data)
2491 (summary gnus-summary-buffer)
2492 (article-buffer gnus-article-buffer)
2493 (original gnus-original-article-buffer)
2494 (gac gnus-article-current)
2495 (reffed gnus-reffed-article-number)
2496 (score-file gnus-current-score-file)
2497 (default-charset gnus-newsgroup-charset))
2499 (set-buffer gnus-group-buffer)
2500 (setq gnus-newsgroup-name name
2501 gnus-newsgroup-marked marked
2502 gnus-newsgroup-unreads unread
2503 gnus-current-headers headers
2504 gnus-newsgroup-data data
2505 gnus-article-current gac
2506 gnus-summary-buffer summary
2507 gnus-article-buffer article-buffer
2508 gnus-original-article-buffer original
2509 gnus-reffed-article-number reffed
2510 gnus-current-score-file score-file
2511 gnus-newsgroup-charset default-charset)
2512 ;; The article buffer also has local variables.
2513 (when (gnus-buffer-live-p gnus-article-buffer)
2514 (set-buffer gnus-article-buffer)
2515 (setq gnus-summary-buffer summary))))))
2517 (defun gnus-summary-article-unread-p (article)
2518 "Say whether ARTICLE is unread or not."
2519 (memq article gnus-newsgroup-unreads))
2521 (defun gnus-summary-first-article-p (&optional article)
2522 "Return whether ARTICLE is the first article in the buffer."
2523 (if (not (setq article (or article (gnus-summary-article-number))))
2525 (eq article (caar gnus-newsgroup-data))))
2527 (defun gnus-summary-last-article-p (&optional article)
2528 "Return whether ARTICLE is the last article in the buffer."
2529 (if (not (setq article (or article (gnus-summary-article-number))))
2530 ;; All non-existent numbers are the last article. :-)
2532 (not (cdr (gnus-data-find-list article)))))
2534 (defun gnus-make-thread-indent-array ()
2536 (unless (and gnus-thread-indent-array
2537 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2538 (setq gnus-thread-indent-array (make-vector 201 "")
2539 gnus-thread-indent-array-level gnus-thread-indent-level)
2541 (aset gnus-thread-indent-array n
2542 (make-string (* n gnus-thread-indent-level) ? ))
2545 (defun gnus-update-summary-mark-positions ()
2546 "Compute where the summary marks are to go."
2548 (when (gnus-buffer-exists-p gnus-summary-buffer)
2549 (set-buffer gnus-summary-buffer))
2550 (let ((gnus-replied-mark 129)
2551 (gnus-score-below-mark 130)
2552 (gnus-score-over-mark 130)
2553 (gnus-download-mark 131)
2554 (spec gnus-summary-line-format-spec)
2557 (gnus-set-work-buffer)
2558 (let ((gnus-summary-line-format-spec spec)
2559 (gnus-newsgroup-downloadable '((0 . t))))
2560 (gnus-summary-insert-line
2561 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2562 (goto-char (point-min))
2563 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2565 (goto-char (point-min))
2566 (push (cons 'replied (and (search-forward "\201" nil t)
2569 (goto-char (point-min))
2570 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2572 (goto-char (point-min))
2573 (push (cons 'download
2574 (and (search-forward "\203" nil t) (- (point) 2)))
2576 (setq gnus-summary-mark-positions pos))))
2578 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2579 "Insert a dummy root in the summary buffer."
2581 (gnus-add-text-properties
2582 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2583 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2585 (defun gnus-summary-from-or-to-or-newsgroups (header)
2586 (let ((to (cdr (assq 'To (mail-header-extra header))))
2587 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2588 (mail-parse-charset gnus-newsgroup-charset)
2589 (mail-parse-ignored-charsets
2590 (save-excursion (set-buffer gnus-summary-buffer)
2591 gnus-newsgroup-ignored-charsets)))
2594 gnus-ignored-from-addresses
2595 (string-match gnus-ignored-from-addresses
2596 (mail-header-from header)))
2598 (or (car (funcall gnus-extract-address-components
2600 gnus-decode-encoded-word-function to)))
2601 (funcall gnus-decode-encoded-word-function to))))
2603 gnus-ignored-from-addresses
2604 (string-match gnus-ignored-from-addresses
2605 (mail-header-from header)))
2606 (concat "=> " newsgroups))
2608 (or (car (funcall gnus-extract-address-components
2609 (mail-header-from header)))
2610 (mail-header-from header))))))
2612 (defun gnus-summary-insert-line (gnus-tmp-header
2613 gnus-tmp-level gnus-tmp-current
2614 gnus-tmp-unread gnus-tmp-replied
2615 gnus-tmp-expirable gnus-tmp-subject-or-nil
2616 &optional gnus-tmp-dummy gnus-tmp-score
2618 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2619 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2620 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2621 (gnus-tmp-score-char
2622 (if (or (null gnus-summary-default-score)
2623 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2624 gnus-summary-zcore-fuzz))
2626 (if (< gnus-tmp-score gnus-summary-default-score)
2627 gnus-score-below-mark gnus-score-over-mark)))
2629 (cond (gnus-tmp-process gnus-process-mark)
2630 ((memq gnus-tmp-current gnus-newsgroup-cached)
2632 (gnus-tmp-replied gnus-replied-mark)
2633 ((memq gnus-tmp-current gnus-newsgroup-saved)
2635 (t gnus-unread-mark)))
2636 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2639 ((string-match "<[^>]+> *$" gnus-tmp-from)
2640 (let ((beg (match-beginning 0)))
2641 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2642 (substring gnus-tmp-from (1+ (match-beginning 0))
2643 (1- (match-end 0))))
2644 (substring gnus-tmp-from 0 beg))))
2645 ((string-match "(.+)" gnus-tmp-from)
2646 (substring gnus-tmp-from
2647 (1+ (match-beginning 0)) (1- (match-end 0))))
2649 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2650 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2651 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2652 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2653 (buffer-read-only nil))
2654 (when (string= gnus-tmp-name "")
2655 (setq gnus-tmp-name gnus-tmp-from))
2656 (unless (numberp gnus-tmp-lines)
2657 (setq gnus-tmp-lines 0))
2658 (gnus-put-text-property
2660 (progn (eval gnus-summary-line-format-spec) (point))
2661 'gnus-number gnus-tmp-number)
2662 (when (gnus-visual-p 'summary-highlight 'highlight)
2664 (gnus-run-hooks 'gnus-summary-update-hook)
2667 (defun gnus-summary-update-line (&optional dont-update)
2668 ;; Update summary line after change.
2669 (when (and gnus-summary-default-score
2670 (not gnus-summary-inhibit-highlight))
2671 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2672 (article (gnus-summary-article-number))
2673 (score (gnus-summary-article-score article)))
2675 (if (and gnus-summary-mark-below
2676 (< (gnus-summary-article-score)
2677 gnus-summary-mark-below))
2678 ;; This article has a low score, so we mark it as read.
2679 (when (memq article gnus-newsgroup-unreads)
2680 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2681 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2682 ;; This article was previously marked as read on account
2683 ;; of a low score, but now it has risen, so we mark it as
2685 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2686 (gnus-summary-update-mark
2687 (if (or (null gnus-summary-default-score)
2688 (<= (abs (- score gnus-summary-default-score))
2689 gnus-summary-zcore-fuzz))
2691 (if (< score gnus-summary-default-score)
2692 gnus-score-below-mark gnus-score-over-mark))
2694 ;; Do visual highlighting.
2695 (when (gnus-visual-p 'summary-highlight 'highlight)
2696 (gnus-run-hooks 'gnus-summary-update-hook)))))
2698 (defvar gnus-tmp-new-adopts nil)
2700 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2701 "Return the number of articles in THREAD.
2702 This may be 0 in some cases -- if none of the articles in
2703 the thread are to be displayed."
2705 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2707 ((not (listp thread))
2709 ((and (consp thread) (cdr thread))
2712 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2715 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2718 (when (and level (zerop level) gnus-tmp-new-adopts)
2721 'gnus-summary-number-of-articles-in-thread
2722 gnus-tmp-new-adopts))))
2724 (if (> number 1) gnus-not-empty-thread-mark
2725 gnus-empty-thread-mark)
2728 (defun gnus-summary-set-local-parameters (group)
2729 "Go through the local params of GROUP and set all variable specs in that list."
2730 (let ((params (gnus-group-find-parameter group))
2733 (setq elem (car params)
2734 params (cdr params))
2735 (and (consp elem) ; Has to be a cons.
2736 (consp (cdr elem)) ; The cdr has to be a list.
2737 (symbolp (car elem)) ; Has to be a symbol in there.
2738 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2739 (ignore-errors ; So we set it.
2740 (make-local-variable (car elem))
2741 (set (car elem) (eval (nth 1 elem))))))))
2743 (defun gnus-summary-read-group (group &optional show-all no-article
2744 kill-buffer no-display backward
2746 "Start reading news in newsgroup GROUP.
2747 If SHOW-ALL is non-nil, already read articles are also listed.
2748 If NO-ARTICLE is non-nil, no article is selected initially.
2749 If NO-DISPLAY, don't generate a summary buffer."
2753 (let ((gnus-auto-select-next nil))
2754 (or (gnus-summary-read-group-1
2755 group show-all no-article
2756 kill-buffer no-display
2759 select-articles nil)))))
2760 (eq gnus-auto-select-next 'quietly))
2761 (set-buffer gnus-group-buffer)
2762 ;; The entry function called above goes to the next
2763 ;; group automatically, so we go two groups back
2764 ;; if we are searching for the previous group.
2766 (gnus-group-prev-unread-group 2))
2767 (if (not (equal group (gnus-group-group-name)))
2768 (setq group (gnus-group-group-name))
2772 (defun gnus-summary-read-group-1 (group show-all no-article
2773 kill-buffer no-display
2774 &optional select-articles)
2775 ;; Killed foreign groups can't be entered.
2776 (when (and (not (gnus-group-native-p group))
2777 (not (gnus-gethash group gnus-newsrc-hashtb)))
2778 (error "Dead non-native groups can't be entered"))
2779 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2780 (let* ((new-group (gnus-summary-setup-buffer group))
2781 (quit-config (gnus-group-quit-config group))
2782 (did-select (and new-group (gnus-select-newsgroup
2783 group show-all select-articles))))
2785 ;; This summary buffer exists already, so we just select it.
2787 (gnus-set-global-variables)
2789 (gnus-kill-or-deaden-summary kill-buffer))
2790 (gnus-configure-windows 'summary 'force)
2791 (gnus-set-mode-line 'summary)
2792 (gnus-summary-position-point)
2795 ;; We couldn't select this group.
2797 (when (and (eq major-mode 'gnus-summary-mode)
2798 (not (equal (current-buffer) kill-buffer)))
2799 (kill-buffer (current-buffer))
2800 (if (not quit-config)
2802 ;; Update the info -- marks might need to be removed,
2804 (gnus-summary-update-info)
2805 (set-buffer gnus-group-buffer)
2806 (gnus-group-jump-to-group group)
2807 (gnus-group-next-unread-group 1))
2808 (gnus-handle-ephemeral-exit quit-config)))
2809 (gnus-message 3 "Can't select group")
2811 ;; The user did a `C-g' while prompting for number of articles,
2812 ;; so we exit this group.
2813 ((eq did-select 'quit)
2814 (and (eq major-mode 'gnus-summary-mode)
2815 (not (equal (current-buffer) kill-buffer))
2816 (kill-buffer (current-buffer)))
2818 (gnus-kill-or-deaden-summary kill-buffer))
2819 (if (not quit-config)
2821 (set-buffer gnus-group-buffer)
2822 (gnus-group-jump-to-group group)
2823 (gnus-group-next-unread-group 1)
2824 (gnus-configure-windows 'group 'force))
2825 (gnus-handle-ephemeral-exit quit-config))
2826 ;; Finally signal the quit.
2828 ;; The group was successfully selected.
2830 (gnus-set-global-variables)
2831 ;; Save the active value in effect when the group was entered.
2832 (setq gnus-newsgroup-active
2834 (gnus-active gnus-newsgroup-name)))
2835 ;; You can change the summary buffer in some way with this hook.
2836 (gnus-run-hooks 'gnus-select-group-hook)
2837 ;; Set any local variables in the group parameters.
2838 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2839 (gnus-update-format-specifications
2840 nil 'summary 'summary-mode 'summary-dummy)
2841 (gnus-update-summary-mark-positions)
2842 ;; Do score processing.
2843 (when gnus-use-scoring
2844 (gnus-possibly-score-headers))
2845 ;; Check whether to fill in the gaps in the threads.
2846 (when gnus-build-sparse-threads
2847 (gnus-build-sparse-threads))
2848 ;; Find the initial limit.
2849 (if gnus-show-threads
2851 (let ((gnus-newsgroup-dormant nil))
2852 (gnus-summary-initial-limit show-all))
2853 (gnus-summary-initial-limit show-all))
2854 ;; When untreaded, all articles are always shown.
2855 (setq gnus-newsgroup-limit
2857 (lambda (header) (mail-header-number header))
2858 gnus-newsgroup-headers)))
2859 ;; Generate the summary buffer.
2861 (gnus-summary-prepare))
2862 (when gnus-use-trees
2863 (gnus-tree-open group)
2864 (setq gnus-summary-highlight-line-function
2865 'gnus-tree-highlight-article))
2866 ;; If the summary buffer is empty, but there are some low-scored
2867 ;; articles or some excluded dormants, we include these in the
2869 (when (and (zerop (buffer-size))
2871 (cond (gnus-newsgroup-dormant
2872 (gnus-summary-limit-include-dormant))
2873 ((and gnus-newsgroup-scored show-all)
2874 (gnus-summary-limit-include-expunged t))))
2875 ;; Function `gnus-apply-kill-file' must be called in this hook.
2876 (gnus-run-hooks 'gnus-apply-kill-hook)
2877 (if (and (zerop (buffer-size))
2880 ;; This newsgroup is empty.
2881 (gnus-summary-catchup-and-exit nil t)
2882 (gnus-message 6 "No unread news")
2884 (gnus-kill-or-deaden-summary kill-buffer))
2885 ;; Return nil from this function.
2887 ;; Hide conversation thread subtrees. We cannot do this in
2888 ;; gnus-summary-prepare-hook since kill processing may not
2889 ;; work with hidden articles.
2890 (and gnus-show-threads
2891 gnus-thread-hide-subtree
2892 (gnus-summary-hide-all-threads))
2894 (gnus-kill-or-deaden-summary kill-buffer))
2895 ;; Show first unread article if requested.
2896 (if (and (not no-article)
2898 gnus-newsgroup-unreads
2899 gnus-auto-select-first)
2901 (gnus-configure-windows 'summary)
2903 ((eq gnus-auto-select-first 'best)
2904 (gnus-summary-best-unread-article))
2905 ((eq gnus-auto-select-first t)
2906 (gnus-summary-first-unread-article))
2907 ((gnus-functionp gnus-auto-select-first)
2908 (funcall gnus-auto-select-first))))
2909 ;; Don't select any articles, just move point to the first
2910 ;; article in the group.
2911 (goto-char (point-min))
2912 (gnus-summary-position-point)
2913 (gnus-configure-windows 'summary 'force)
2914 (gnus-set-mode-line 'summary))
2915 (when (get-buffer-window gnus-group-buffer t)
2916 ;; Gotta use windows, because recenter does weird stuff if
2917 ;; the current buffer ain't the displayed window.
2918 (let ((owin (selected-window)))
2919 (select-window (get-buffer-window gnus-group-buffer t))
2920 (when (gnus-group-goto-group group)
2922 (select-window owin)))
2923 ;; Mark this buffer as "prepared".
2924 (setq gnus-newsgroup-prepared t)
2925 (gnus-run-hooks 'gnus-summary-prepared-hook)
2928 (defun gnus-summary-prepare ()
2929 "Generate the summary buffer."
2931 (let ((buffer-read-only nil))
2933 (setq gnus-newsgroup-data nil
2934 gnus-newsgroup-data-reverse nil)
2935 (gnus-run-hooks 'gnus-summary-generate-hook)
2936 ;; Generate the buffer, either with threads or without.
2937 (when gnus-newsgroup-headers
2938 (gnus-summary-prepare-threads
2939 (if gnus-show-threads
2940 (gnus-sort-gathered-threads
2941 (funcall gnus-summary-thread-gathering-function
2943 (gnus-cut-threads (gnus-make-threads)))))
2944 ;; Unthreaded display.
2945 (gnus-sort-articles gnus-newsgroup-headers))))
2946 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2947 ;; Call hooks for modifying summary buffer.
2948 (goto-char (point-min))
2949 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2951 (defsubst gnus-general-simplify-subject (subject)
2952 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2955 ;; Truncate the subject.
2956 (gnus-simplify-subject-functions
2957 (gnus-map-function gnus-simplify-subject-functions subject))
2958 ((numberp gnus-summary-gather-subject-limit)
2959 (setq subject (gnus-simplify-subject-re subject))
2960 (if (> (length subject) gnus-summary-gather-subject-limit)
2961 (substring subject 0 gnus-summary-gather-subject-limit)
2963 ;; Fuzzily simplify it.
2964 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2965 (gnus-simplify-subject-fuzzy subject))
2966 ;; Just remove the leading "Re:".
2968 (gnus-simplify-subject-re subject))))
2970 (if (and gnus-summary-gather-exclude-subject
2971 (string-match gnus-summary-gather-exclude-subject subject))
2972 nil ; This article shouldn't be gathered
2975 (defun gnus-summary-simplify-subject-query ()
2976 "Query where the respool algorithm would put this article."
2978 (gnus-summary-select-article)
2979 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2981 (defun gnus-gather-threads-by-subject (threads)
2982 "Gather threads by looking at Subject headers."
2983 (if (not gnus-summary-make-false-root)
2985 (let ((hashtb (gnus-make-hashtable 1024))
2988 subject hthread whole-subject)
2990 (setq subject (gnus-general-simplify-subject
2991 (setq whole-subject (mail-header-subject
2994 (if (setq hthread (gnus-gethash subject hashtb))
2996 ;; We enter a dummy root into the thread, if we
2997 ;; haven't done that already.
2998 (unless (stringp (caar hthread))
2999 (setcar hthread (list whole-subject (car hthread))))
3000 ;; We add this new gathered thread to this gathered
3002 (setcdr (car hthread)
3003 (nconc (cdar hthread) (list (car threads))))
3004 ;; Remove it from the list of threads.
3005 (setcdr prev (cdr threads))
3006 (setq threads prev))
3007 ;; Enter this thread into the hash table.
3008 (gnus-sethash subject threads hashtb)))
3010 (setq threads (cdr threads)))
3013 (defun gnus-gather-threads-by-references (threads)
3014 "Gather threads by looking at References headers."
3015 (let ((idhashtb (gnus-make-hashtable 1024))
3016 (thhashtb (gnus-make-hashtable 1024))
3019 ids references id gthread gid entered ref)
3021 (when (setq references (mail-header-references (caar threads)))
3022 (setq id (mail-header-id (caar threads))
3023 ids (gnus-split-references references)
3025 (while (setq ref (pop ids))
3026 (setq ids (delete ref ids))
3027 (if (not (setq gid (gnus-gethash ref idhashtb)))
3029 (gnus-sethash ref id idhashtb)
3030 (gnus-sethash id threads thhashtb))
3031 (setq gthread (gnus-gethash gid thhashtb))
3033 ;; We enter a dummy root into the thread, if we
3034 ;; haven't done that already.
3035 (unless (stringp (caar gthread))
3036 (setcar gthread (list (mail-header-subject (caar gthread))
3038 ;; We add this new gathered thread to this gathered
3040 (setcdr (car gthread)
3041 (nconc (cdar gthread) (list (car threads)))))
3042 ;; Add it into the thread hash table.
3043 (gnus-sethash id gthread thhashtb)
3045 ;; Remove it from the list of threads.
3046 (setcdr prev (cdr threads))
3047 (setq threads prev))))
3049 (setq threads (cdr threads)))
3052 (defun gnus-sort-gathered-threads (threads)
3053 "Sort subtreads inside each gathered thread by article number."
3054 (let ((result threads))
3056 (when (stringp (caar threads))
3057 (setcdr (car threads)
3058 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3059 (setq threads (cdr threads)))
3062 (defun gnus-thread-loop-p (root thread)
3063 "Say whether ROOT is in THREAD."
3064 (let ((stack (list thread))
3067 (while (setq thread (pop stack))
3068 (setq th (cdr thread))
3070 (not (eq (caar th) root)))
3073 ;; We have found a loop.
3075 (setcdr thread (delq (car th) (cdr thread)))
3076 (if (boundp (setq ref-dep (intern "none"
3077 gnus-newsgroup-dependencies)))
3078 (setcdr (symbol-value ref-dep)
3079 (nconc (cdr (symbol-value ref-dep))
3081 (set ref-dep (list nil (car th))))
3084 ;; Push all the subthreads onto the stack.
3085 (push (cdr thread) stack)))
3088 (defun gnus-make-threads ()
3089 "Go through the dependency hashtb and find the roots. Return all threads."
3091 (while (catch 'infloop
3094 ;; Deal with self-referencing References loops.
3095 (when (and (car (symbol-value refs))
3102 (car (symbol-value refs)) thread))
3103 (cdr (symbol-value refs)))))))
3106 (unless (car (symbol-value refs))
3107 ;; These threads do not refer back to any other articles,
3108 ;; so they're roots.
3109 (setq threads (append (cdr (symbol-value refs)) threads))))
3110 gnus-newsgroup-dependencies)))
3113 ;; Build the thread tree.
3114 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3115 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3117 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3118 if it was already present.
3120 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3121 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3122 Message-IDs will be renamed be renamed to a unique Message-ID before
3125 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3126 (let* ((id (mail-header-id header))
3127 (id-dep (and id (intern id dependencies)))
3128 ref ref-dep ref-header)
3129 ;; Enter this `header' in the `dependencies' table.
3133 ;; The first two cases do the normal part: enter a new `header'
3134 ;; in the `dependencies' table.
3135 ((not (boundp id-dep))
3136 (set id-dep (list header)))
3137 ((null (car (symbol-value id-dep)))
3138 (setcar (symbol-value id-dep) header))
3140 ;; From here the `header' was already present in the
3141 ;; `dependencies' table.
3143 ;; Overrides an existing entry;
3144 ;; just set the header part of the entry.
3145 (setcar (symbol-value id-dep) header))
3147 ;; Renames the existing `header' to a unique Message-ID.
3148 ((not gnus-summary-ignore-duplicates)
3149 ;; An article with this Message-ID has already been seen.
3150 ;; We rename the Message-ID.
3151 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3153 (mail-header-set-id header id))
3155 ;; The last case ignores an existing entry, except it adds any
3156 ;; additional Xrefs (in case the two articles came from different
3158 ;; Also sets `header' to `nil' meaning that the `dependencies'
3159 ;; table was *not* modified.
3161 (mail-header-set-xref
3162 (car (symbol-value id-dep))
3163 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3165 (or (mail-header-xref header) "")))
3169 ;; First check if that we are not creating a References loop.
3170 (setq ref (gnus-parent-id (mail-header-references header)))
3172 (setq ref-dep (intern-soft ref dependencies))
3174 (setq ref-header (car (symbol-value ref-dep))))
3175 (if (string= id ref)
3176 ;; Yuk! This is a reference loop. Make the article be a
3179 (mail-header-set-references (car (symbol-value id-dep)) "none")
3181 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3182 (setq ref (gnus-parent-id (mail-header-references header)))
3183 (setq ref-dep (intern (or ref "none") dependencies))
3184 (if (boundp ref-dep)
3185 (setcdr (symbol-value ref-dep)
3186 (nconc (cdr (symbol-value ref-dep))
3187 (list (symbol-value id-dep))))
3188 (set ref-dep (list nil (symbol-value id-dep)))))
3191 (defun gnus-build-sparse-threads ()
3192 (let ((headers gnus-newsgroup-headers)
3193 (mail-parse-charset gnus-newsgroup-charset)
3194 (gnus-summary-ignore-duplicates t)
3195 header references generation relations
3196 subject child end new-child date)
3197 ;; First we create an alist of generations/relations, where
3198 ;; generations is how much we trust the relation, and the relation
3200 (gnus-message 7 "Making sparse threads...")
3202 (nnheader-set-temp-buffer " *gnus sparse threads*")
3203 (while (setq header (pop headers))
3204 (when (and (setq references (mail-header-references header))
3205 (not (string= references "")))
3207 (setq child (mail-header-id header)
3208 subject (mail-header-subject header)
3209 date (mail-header-date header)
3211 (while (search-backward ">" nil t)
3212 (setq end (1+ (point)))
3213 (when (search-backward "<" nil t)
3214 (setq new-child (buffer-substring (point) end))
3215 (push (list (incf generation)
3216 child (setq child new-child)
3220 (push (list (1+ generation) child nil subject) relations))
3222 (kill-buffer (current-buffer)))
3223 ;; Sort over trustworthiness.
3226 (when (gnus-dependencies-add-header
3227 (make-full-mail-header
3228 gnus-reffed-article-number
3229 (nth 3 relation) "" (or (nth 4 relation) "")
3231 (or (nth 2 relation) "") 0 0 "")
3232 gnus-newsgroup-dependencies nil)
3233 (push gnus-reffed-article-number gnus-newsgroup-limit)
3234 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3235 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3236 gnus-newsgroup-reads)
3237 (decf gnus-reffed-article-number)))
3238 (sort relations 'car-less-than-car))
3239 (gnus-message 7 "Making sparse threads...done")))
3241 (defun gnus-build-old-threads ()
3242 ;; Look at all the articles that refer back to old articles, and
3243 ;; fetch the headers for the articles that aren't there. This will
3244 ;; build complete threads - if the roots haven't been expired by the
3246 (let ((mail-parse-charset gnus-newsgroup-charset)
3250 (when (not (car (symbol-value refs)))
3251 (setq heads (cdr (symbol-value refs)))
3253 (if (memq (mail-header-number (caar heads))
3254 gnus-newsgroup-dormant)
3255 (setq heads (cdr heads))
3256 (setq id (symbol-name refs))
3257 (while (and (setq id (gnus-build-get-header id))
3258 (not (car (gnus-id-to-thread id)))))
3259 (setq heads nil)))))
3260 gnus-newsgroup-dependencies)))
3262 ;; This function has to be called with point after the article number
3263 ;; on the beginning of the line.
3264 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3265 (let ((eol (gnus-point-at-eol))
3266 (buffer (current-buffer))
3269 ;; overview: [num subject from date id refs chars lines misc]
3272 (narrow-to-region (point) eol)
3277 (make-full-mail-header
3279 (funcall gnus-decode-encoded-word-function
3280 (nnheader-nov-field)) ; subject
3281 (funcall gnus-decode-encoded-word-function
3282 (nnheader-nov-field)) ; from
3283 (nnheader-nov-field) ; date
3284 (nnheader-nov-read-message-id) ; id
3285 (nnheader-nov-field) ; refs
3286 (nnheader-nov-read-integer) ; chars
3287 (nnheader-nov-read-integer) ; lines
3289 (nnheader-nov-field)) ; misc
3290 (nnheader-nov-parse-extra)))) ; extra
3294 (when gnus-alter-header-function
3295 (funcall gnus-alter-header-function header))
3296 (gnus-dependencies-add-header header dependencies force-new)))
3298 (defun gnus-build-get-header (id)
3299 ;; Look through the buffer of NOV lines and find the header to
3300 ;; ID. Enter this line into the dependencies hash table, and return
3301 ;; the id of the parent article (if any).
3302 (let ((deps gnus-newsgroup-dependencies)
3306 (set-buffer nntp-server-buffer)
3307 (let ((case-fold-search nil))
3308 (goto-char (point-min))
3309 (while (and (not found)
3310 (search-forward id nil t))
3312 (setq found (looking-at
3313 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3314 (regexp-quote id))))
3315 (or found (beginning-of-line 2)))
3319 (setq header (gnus-nov-parse-line
3320 (read (current-buffer)) deps))
3321 (gnus-parent-id (mail-header-references header))))))
3323 (let ((number (mail-header-number header)))
3324 (push number gnus-newsgroup-limit)
3325 (push header gnus-newsgroup-headers)
3326 (if (memq number gnus-newsgroup-unselected)
3328 (push number gnus-newsgroup-unreads)
3329 (setq gnus-newsgroup-unselected
3330 (delq number gnus-newsgroup-unselected)))
3331 (push number gnus-newsgroup-ancient)))))))
3333 (defun gnus-build-all-threads ()
3334 "Read all the headers."
3335 (let ((gnus-summary-ignore-duplicates t)
3336 (mail-parse-charset gnus-newsgroup-charset)
3337 (dependencies gnus-newsgroup-dependencies)
3340 (set-buffer nntp-server-buffer)
3341 (let ((case-fold-search nil))
3342 (goto-char (point-min))
3345 (setq article (read (current-buffer))
3346 header (gnus-nov-parse-line article dependencies)))
3349 (set-buffer gnus-summary-buffer)
3350 (push header gnus-newsgroup-headers)
3351 (if (memq (setq article (mail-header-number header))
3352 gnus-newsgroup-unselected)
3354 (push article gnus-newsgroup-unreads)
3355 (setq gnus-newsgroup-unselected
3356 (delq article gnus-newsgroup-unselected)))
3357 (push article gnus-newsgroup-ancient)))
3358 (forward-line 1)))))))
3360 (defun gnus-summary-update-article-line (article header)
3361 "Update the line for ARTICLE using HEADERS."
3362 (let* ((id (mail-header-id header))
3363 (thread (gnus-id-to-thread id)))
3365 (error "Article in no thread"))
3366 ;; Update the thread.
3367 (setcar thread header)
3368 (gnus-summary-goto-subject article)
3369 (let* ((datal (gnus-data-find-list article))
3371 (length (when (cdr datal)
3372 (- (gnus-data-pos data)
3373 (gnus-data-pos (cadr datal)))))
3374 (buffer-read-only nil)
3375 (level (gnus-summary-thread-level)))
3377 (gnus-summary-insert-line
3378 header level nil (gnus-article-mark article)
3379 (memq article gnus-newsgroup-replied)
3380 (memq article gnus-newsgroup-expirable)
3381 ;; Only insert the Subject string when it's different
3382 ;; from the previous Subject string.
3387 (mail-header-subject
3390 (gnus-data-find-list
3392 (gnus-data-list t)))))
3393 ;; Error on the side of excessive subjects.
3395 (mail-header-subject header)))
3397 (mail-header-subject header))
3398 nil (cdr (assq article gnus-newsgroup-scored))
3399 (memq article gnus-newsgroup-processable))
3401 (gnus-data-update-list
3402 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3404 (defun gnus-summary-update-article (article &optional iheader)
3405 "Update ARTICLE in the summary buffer."
3406 (set-buffer gnus-summary-buffer)
3407 (let* ((header (gnus-summary-article-header article))
3408 (id (mail-header-id header))
3409 (data (gnus-data-find article))
3410 (thread (gnus-id-to-thread id))
3411 (references (mail-header-references header))
3415 (when (and references
3416 (not (equal "" references)))
3419 (buffer-read-only nil)
3425 (delq thread parent)))
3426 (if (gnus-summary-insert-subject id header)
3427 ;; Set the (possibly) new article number in the data structure.
3428 (gnus-data-set-number data (gnus-id-to-article id))
3432 (defun gnus-rebuild-thread (id &optional line)
3433 "Rebuild the thread containing ID.
3434 If LINE, insert the rebuilt thread starting on line LINE."
3435 (let ((buffer-read-only nil)
3436 old-pos current thread data)
3437 (if (not gnus-show-threads)
3438 (setq thread (list (car (gnus-id-to-thread id))))
3439 ;; Get the thread this article is part of.
3440 (setq thread (gnus-remove-thread id)))
3441 (setq old-pos (gnus-point-at-bol))
3442 (setq current (save-excursion
3443 (and (zerop (forward-line -1))
3444 (gnus-summary-article-number))))
3445 ;; If this is a gathered thread, we have to go some re-gathering.
3446 (when (stringp (car thread))
3447 (let ((subject (car thread))
3449 (setq thread (cdr thread))
3451 (unless (memq (setq thr (gnus-id-to-thread
3453 (mail-header-id (caar thread)))))
3456 (setq thread (cdr thread)))
3457 ;; We now have all (unique) roots.
3458 (if (= (length roots) 1)
3459 ;; All the loose roots are now one solid root.
3460 (setq thread (car roots))
3461 (setq thread (cons subject (gnus-sort-threads roots))))))
3463 ;; We then insert this thread into the summary buffer.
3465 (goto-char (point-min))
3466 (forward-line (1- line)))
3467 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3468 (if gnus-show-threads
3469 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3470 (gnus-summary-prepare-unthreaded thread))
3471 (setq data (nreverse gnus-newsgroup-data))
3472 (setq threads gnus-newsgroup-threads))
3473 ;; We splice the new data into the data structure.
3474 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3475 ;;!!! then we want to insert at the beginning of the buffer.
3476 ;;!!! That happens to be true with Gnus now, but that may
3477 ;;!!! change in the future. Perhaps.
3478 (gnus-data-enter-list
3479 (if line nil current) data (- (point) old-pos))
3480 (setq gnus-newsgroup-threads
3481 (nconc threads gnus-newsgroup-threads))
3482 (gnus-data-compute-positions))))
3484 (defun gnus-number-to-header (number)
3485 "Return the header for article NUMBER."
3486 (let ((headers gnus-newsgroup-headers))
3488 (not (= number (mail-header-number (car headers)))))
3493 (defun gnus-parent-headers (in-headers &optional generation)
3494 "Return the headers of the GENERATIONeth parent of HEADERS."
3496 (setq generation 1))
3498 (headers in-headers)
3501 (not (zerop generation))
3502 (setq references (mail-header-references headers)))
3503 (setq headers (if (and references
3504 (setq parent (gnus-parent-id references)))
3505 (car (gnus-id-to-thread parent))
3508 (and (not (eq headers in-headers))
3511 (defun gnus-id-to-thread (id)
3512 "Return the (sub-)thread where ID appears."
3513 (gnus-gethash id gnus-newsgroup-dependencies))
3515 (defun gnus-id-to-article (id)
3516 "Return the article number of ID."
3517 (let ((thread (gnus-id-to-thread id)))
3520 (mail-header-number (car thread)))))
3522 (defun gnus-id-to-header (id)
3523 "Return the article headers of ID."
3524 (car (gnus-id-to-thread id)))
3526 (defun gnus-article-displayed-root-p (article)
3527 "Say whether ARTICLE is a root(ish) article."
3528 (let ((level (gnus-summary-thread-level article))
3529 (refs (mail-header-references (gnus-summary-article-header article)))
3535 ((null (gnus-parent-id refs)) t)
3537 (null (setq particle (gnus-id-to-article
3538 (gnus-parent-id refs))))
3539 (null (gnus-summary-thread-level particle)))))))
3541 (defun gnus-root-id (id)
3542 "Return the id of the root of the thread where ID appears."
3544 (while (and id (setq prev (car (gnus-id-to-thread id))))
3546 id (gnus-parent-id (mail-header-references prev))))
3549 (defun gnus-articles-in-thread (thread)
3550 "Return the list of articles in THREAD."
3551 (cons (mail-header-number (car thread))
3552 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3554 (defun gnus-remove-thread (id &optional dont-remove)
3555 "Remove the thread that has ID in it."
3556 (let (headers thread last-id)
3557 ;; First go up in this thread until we find the root.
3558 (setq last-id (gnus-root-id id)
3559 headers (message-flatten-list (gnus-id-to-thread last-id)))
3560 ;; We have now found the real root of this thread. It might have
3561 ;; been gathered into some loose thread, so we have to search
3562 ;; through the threads to find the thread we wanted.
3563 (let ((threads gnus-newsgroup-threads)
3566 (setq sub (car threads))
3567 (if (stringp (car sub))
3568 ;; This is a gathered thread, so we look at the roots
3569 ;; below it to find whether this article is in this
3572 (setq sub (cdr sub))
3574 (when (member (caar sub) headers)
3575 (setq thread (car threads)
3578 (setq sub (cdr sub))))
3579 ;; It's an ordinary thread, so we check it.
3580 (when (eq (car sub) (car headers))
3583 (setq threads (cdr threads)))
3584 ;; If this article is in no thread, then it's a root.
3587 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3588 (setq thread (gnus-id-to-thread last-id)))
3591 thread ; We return this thread.
3593 (if (stringp (car thread))
3595 ;; If we use dummy roots, then we have to remove the
3596 ;; dummy root as well.
3597 (when (eq gnus-summary-make-false-root 'dummy)
3598 ;; We go to the dummy root by going to
3599 ;; the first sub-"thread", and then one line up.
3600 (gnus-summary-goto-article
3601 (mail-header-number (caadr thread)))
3604 (gnus-data-compute-positions))
3605 (setq thread (cdr thread))
3607 (gnus-remove-thread-1 (car thread))
3608 (setq thread (cdr thread))))
3609 (gnus-remove-thread-1 thread))))))))
3611 (defun gnus-remove-thread-1 (thread)
3612 "Remove the thread THREAD recursively."
3613 (let ((number (mail-header-number (pop thread)))
3615 (setq thread (reverse thread))
3617 (gnus-remove-thread-1 (pop thread)))
3618 (when (setq d (gnus-data-find number))
3619 (goto-char (gnus-data-pos d))
3620 (gnus-summary-show-thread)
3623 (- (gnus-point-at-bol)
3625 (1+ (gnus-point-at-eol))
3626 (gnus-delete-line)))))))
3628 (defun gnus-sort-threads (threads)
3630 (if (not gnus-thread-sort-functions)
3632 (gnus-message 8 "Sorting threads...")
3634 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3635 (gnus-message 8 "Sorting threads...done"))))
3637 (defun gnus-sort-articles (articles)
3639 (when gnus-article-sort-functions
3640 (gnus-message 7 "Sorting articles...")
3642 (setq gnus-newsgroup-headers
3643 (sort articles (gnus-make-sort-function
3644 gnus-article-sort-functions)))
3645 (gnus-message 7 "Sorting articles...done"))))
3647 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3648 (defmacro gnus-thread-header (thread)
3649 ;; Return header of first article in THREAD.
3650 ;; Note that THREAD must never, ever be anything else than a variable -
3651 ;; using some other form will lead to serious barfage.
3652 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3653 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3654 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3657 (defsubst gnus-article-sort-by-number (h1 h2)
3658 "Sort articles by article number."
3659 (< (mail-header-number h1)
3660 (mail-header-number h2)))
3662 (defun gnus-thread-sort-by-number (h1 h2)
3663 "Sort threads by root article number."
3664 (gnus-article-sort-by-number
3665 (gnus-thread-header h1) (gnus-thread-header h2)))
3667 (defsubst gnus-article-sort-by-lines (h1 h2)
3668 "Sort articles by article Lines header."
3669 (< (mail-header-lines h1)
3670 (mail-header-lines h2)))
3672 (defun gnus-thread-sort-by-lines (h1 h2)
3673 "Sort threads by root article Lines header."
3674 (gnus-article-sort-by-lines
3675 (gnus-thread-header h1) (gnus-thread-header h2)))
3677 (defsubst gnus-article-sort-by-chars (h1 h2)
3678 "Sort articles by octet length."
3679 (< (mail-header-chars h1)
3680 (mail-header-chars h2)))
3682 (defun gnus-thread-sort-by-chars (h1 h2)
3683 "Sort threads by root article octet length."
3684 (gnus-article-sort-by-chars
3685 (gnus-thread-header h1) (gnus-thread-header h2)))
3687 (defsubst gnus-article-sort-by-author (h1 h2)
3688 "Sort articles by root author."
3690 (let ((extract (funcall
3691 gnus-extract-address-components
3692 (mail-header-from h1))))
3693 (or (car extract) (cadr extract) ""))
3694 (let ((extract (funcall
3695 gnus-extract-address-components
3696 (mail-header-from h2))))
3697 (or (car extract) (cadr extract) ""))))
3699 (defun gnus-thread-sort-by-author (h1 h2)
3700 "Sort threads by root author."
3701 (gnus-article-sort-by-author
3702 (gnus-thread-header h1) (gnus-thread-header h2)))
3704 (defsubst gnus-article-sort-by-subject (h1 h2)
3705 "Sort articles by root subject."
3707 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3708 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3710 (defun gnus-thread-sort-by-subject (h1 h2)
3711 "Sort threads by root subject."
3712 (gnus-article-sort-by-subject
3713 (gnus-thread-header h1) (gnus-thread-header h2)))
3715 (defsubst gnus-article-sort-by-date (h1 h2)
3716 "Sort articles by root article date."
3718 (gnus-date-get-time (mail-header-date h1))
3719 (gnus-date-get-time (mail-header-date h2))))
3721 (defun gnus-thread-sort-by-date (h1 h2)
3722 "Sort threads by root article date."
3723 (gnus-article-sort-by-date
3724 (gnus-thread-header h1) (gnus-thread-header h2)))
3726 (defsubst gnus-article-sort-by-score (h1 h2)
3727 "Sort articles by root article score.
3728 Unscored articles will be counted as having a score of zero."
3729 (> (or (cdr (assq (mail-header-number h1)
3730 gnus-newsgroup-scored))
3731 gnus-summary-default-score 0)
3732 (or (cdr (assq (mail-header-number h2)
3733 gnus-newsgroup-scored))
3734 gnus-summary-default-score 0)))
3736 (defun gnus-thread-sort-by-score (h1 h2)
3737 "Sort threads by root article score."
3738 (gnus-article-sort-by-score
3739 (gnus-thread-header h1) (gnus-thread-header h2)))
3741 (defun gnus-thread-sort-by-total-score (h1 h2)
3742 "Sort threads by the sum of all scores in the thread.
3743 Unscored articles will be counted as having a score of zero."
3744 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3746 (defun gnus-thread-total-score (thread)
3747 ;; This function find the total score of THREAD.
3748 (cond ((null thread)
3751 (if (stringp (car thread))
3752 (apply gnus-thread-score-function 0
3753 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3754 (gnus-thread-total-score-1 thread)))
3756 (gnus-thread-total-score-1 (list thread)))))
3758 (defun gnus-thread-total-score-1 (root)
3759 ;; This function find the total score of the thread below ROOT.
3760 (setq root (car root))
3761 (apply gnus-thread-score-function
3763 (mapcar 'gnus-thread-total-score
3764 (cdr (gnus-id-to-thread (mail-header-id root))))
3765 (when (> (mail-header-number root) 0)
3766 (list (or (cdr (assq (mail-header-number root)
3767 gnus-newsgroup-scored))
3768 gnus-summary-default-score 0))))
3769 (list gnus-summary-default-score)
3772 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3773 (defvar gnus-tmp-prev-subject nil)
3774 (defvar gnus-tmp-false-parent nil)
3775 (defvar gnus-tmp-root-expunged nil)
3776 (defvar gnus-tmp-dummy-line nil)
3778 (defvar gnus-tmp-header)
3779 (defun gnus-extra-header (type &optional header)
3780 "Return the extra header of TYPE."
3781 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3784 (defun gnus-summary-prepare-threads (threads)
3785 "Prepare summary buffer from THREADS and indentation LEVEL.
3786 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3787 or a straight list of headers."
3788 (gnus-message 7 "Generating summary...")
3790 (setq gnus-newsgroup-threads threads)
3793 (let ((gnus-tmp-level 0)
3794 (default-score (or gnus-summary-default-score 0))
3795 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3796 thread number subject stack state gnus-tmp-gathered beg-match
3797 new-roots gnus-tmp-new-adopts thread-end
3798 gnus-tmp-header gnus-tmp-unread
3799 gnus-tmp-replied gnus-tmp-subject-or-nil
3800 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3801 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3802 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3804 (setq gnus-tmp-prev-subject nil)
3806 (if (vectorp (car threads))
3807 ;; If this is a straight (sic) list of headers, then a
3808 ;; threaded summary display isn't required, so we just create
3809 ;; an unthreaded one.
3810 (gnus-summary-prepare-unthreaded threads)
3812 ;; Do the threaded display.
3814 (while (or threads stack gnus-tmp-new-adopts new-roots)
3816 (if (and (= gnus-tmp-level 0)
3819 (not gnus-tmp-false-parent)
3820 (or gnus-tmp-new-adopts new-roots))
3821 (if gnus-tmp-new-adopts
3822 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3823 thread (list (car gnus-tmp-new-adopts))
3824 gnus-tmp-header (caar thread)
3825 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3827 (setq thread (list (car new-roots))
3828 gnus-tmp-header (caar thread)
3829 new-roots (cdr new-roots))))
3832 ;; If there are some threads, we do them before the
3833 ;; threads on the stack.
3834 (setq thread threads
3835 gnus-tmp-header (caar thread))
3836 ;; There were no current threads, so we pop something off
3838 (setq state (car stack)
3839 gnus-tmp-level (car state)
3842 gnus-tmp-header (caar thread))))
3844 (setq gnus-tmp-false-parent nil)
3845 (setq gnus-tmp-root-expunged nil)
3846 (setq thread-end nil)
3848 (if (stringp gnus-tmp-header)
3849 ;; The header is a dummy root.
3851 ((eq gnus-summary-make-false-root 'adopt)
3852 ;; We let the first article adopt the rest.
3853 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3855 (setq gnus-tmp-gathered
3857 (lambda (h) (mail-header-number (car h)))
3860 (setq thread (cons (list (caar thread)
3863 (setq gnus-tmp-level -1
3864 gnus-tmp-false-parent t))
3865 ((eq gnus-summary-make-false-root 'empty)
3866 ;; We print adopted articles with empty subject fields.
3867 (setq gnus-tmp-gathered
3869 (lambda (h) (mail-header-number (car h)))
3872 (setq gnus-tmp-level -1))
3873 ((eq gnus-summary-make-false-root 'dummy)
3874 ;; We remember that we probably want to output a dummy
3876 (setq gnus-tmp-dummy-line gnus-tmp-header)
3877 (setq gnus-tmp-prev-subject gnus-tmp-header))
3879 ;; We do not make a root for the gathered
3880 ;; sub-threads at all.
3881 (setq gnus-tmp-level -1)))
3883 (setq number (mail-header-number gnus-tmp-header)
3884 subject (mail-header-subject gnus-tmp-header))
3887 ;; If the thread has changed subject, we might want to make
3888 ;; this subthread into a root.
3889 ((and (null gnus-thread-ignore-subject)
3890 (not (zerop gnus-tmp-level))
3891 gnus-tmp-prev-subject
3893 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3894 (setq new-roots (nconc new-roots (list (car thread)))
3896 gnus-tmp-header nil))
3897 ;; If the article lies outside the current limit,
3898 ;; then we do not display it.
3899 ((not (memq number gnus-newsgroup-limit))
3900 (setq gnus-tmp-gathered
3902 (lambda (h) (mail-header-number (car h)))
3905 (setq gnus-tmp-new-adopts (if (cdar thread)
3906 (append gnus-tmp-new-adopts
3908 gnus-tmp-new-adopts)
3910 gnus-tmp-header nil)
3911 (when (zerop gnus-tmp-level)
3912 (setq gnus-tmp-root-expunged t)))
3913 ;; Perhaps this article is to be marked as read?
3914 ((and gnus-summary-mark-below
3915 (< (or (cdr (assq number gnus-newsgroup-scored))
3917 gnus-summary-mark-below)
3918 ;; Don't touch sparse articles.
3919 (not (gnus-summary-article-sparse-p number))
3920 (not (gnus-summary-article-ancient-p number)))
3921 (setq gnus-newsgroup-unreads
3922 (delq number gnus-newsgroup-unreads))
3923 (if gnus-newsgroup-auto-expire
3924 (push number gnus-newsgroup-expirable)
3925 (push (cons number gnus-low-score-mark)
3926 gnus-newsgroup-reads))))
3928 (when gnus-tmp-header
3929 ;; We may have an old dummy line to output before this
3931 (when (and gnus-tmp-dummy-line
3934 (mail-header-subject gnus-tmp-header)))
3935 (gnus-summary-insert-dummy-line
3936 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3937 (setq gnus-tmp-dummy-line nil))
3939 ;; Compute the mark.
3940 (setq gnus-tmp-unread (gnus-article-mark number))
3942 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3943 gnus-tmp-header gnus-tmp-level)
3944 gnus-newsgroup-data)
3946 ;; Actually insert the line.
3948 gnus-tmp-subject-or-nil
3950 ((and gnus-thread-ignore-subject
3951 gnus-tmp-prev-subject
3952 (not (inline (gnus-subject-equal
3953 gnus-tmp-prev-subject subject))))
3955 ((zerop gnus-tmp-level)
3956 (if (and (eq gnus-summary-make-false-root 'empty)
3957 (memq number gnus-tmp-gathered)
3958 gnus-tmp-prev-subject
3959 (inline (gnus-subject-equal
3960 gnus-tmp-prev-subject subject)))
3961 gnus-summary-same-subject
3963 (t gnus-summary-same-subject)))
3964 (if (and (eq gnus-summary-make-false-root 'adopt)
3965 (= gnus-tmp-level 1)
3966 (memq number gnus-tmp-gathered))
3967 (setq gnus-tmp-opening-bracket ?\<
3968 gnus-tmp-closing-bracket ?\>)
3969 (setq gnus-tmp-opening-bracket ?\[
3970 gnus-tmp-closing-bracket ?\]))
3972 gnus-tmp-indentation
3973 (aref gnus-thread-indent-array gnus-tmp-level)
3974 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3975 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3976 gnus-summary-default-score 0)
3978 (if (or (null gnus-summary-default-score)
3979 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3980 gnus-summary-zcore-fuzz))
3982 (if (< gnus-tmp-score gnus-summary-default-score)
3983 gnus-score-below-mark gnus-score-over-mark))
3985 (cond ((memq number gnus-newsgroup-processable)
3987 ((memq number gnus-newsgroup-cached)
3989 ((memq number gnus-newsgroup-replied)
3991 ((memq number gnus-newsgroup-saved)
3993 (t gnus-unread-mark))
3994 gnus-tmp-from (mail-header-from gnus-tmp-header)
3997 ((string-match "<[^>]+> *$" gnus-tmp-from)
3998 (setq beg-match (match-beginning 0))
3999 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4000 (substring gnus-tmp-from (1+ (match-beginning 0))
4001 (1- (match-end 0))))
4002 (substring gnus-tmp-from 0 beg-match)))
4003 ((string-match "(.+)" gnus-tmp-from)
4004 (substring gnus-tmp-from
4005 (1+ (match-beginning 0)) (1- (match-end 0))))
4007 (when (string= gnus-tmp-name "")
4008 (setq gnus-tmp-name gnus-tmp-from))
4009 (unless (numberp gnus-tmp-lines)
4010 (setq gnus-tmp-lines 0))
4011 (gnus-put-text-property
4013 (progn (eval gnus-summary-line-format-spec) (point))
4014 'gnus-number number)
4017 (gnus-run-hooks 'gnus-summary-update-hook)
4020 (setq gnus-tmp-prev-subject subject)))
4022 (when (nth 1 thread)
4023 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4024 (incf gnus-tmp-level)
4025 (setq threads (if thread-end nil (cdar thread)))
4027 (setq gnus-tmp-level 0)))))
4028 (gnus-message 7 "Generating summary...done"))
4030 (defun gnus-summary-prepare-unthreaded (headers)
4031 "Generate an unthreaded summary buffer based on HEADERS."
4032 (let (header number mark)
4037 ;; We may have to root out some bad articles...
4038 (when (memq (setq number (mail-header-number
4039 (setq header (pop headers))))
4040 gnus-newsgroup-limit)
4041 ;; Mark article as read when it has a low score.
4042 (when (and gnus-summary-mark-below
4043 (< (or (cdr (assq number gnus-newsgroup-scored))
4044 gnus-summary-default-score 0)
4045 gnus-summary-mark-below)
4046 (not (gnus-summary-article-ancient-p number)))
4047 (setq gnus-newsgroup-unreads
4048 (delq number gnus-newsgroup-unreads))
4049 (if gnus-newsgroup-auto-expire
4050 (push number gnus-newsgroup-expirable)
4051 (push (cons number gnus-low-score-mark)
4052 gnus-newsgroup-reads)))
4054 (setq mark (gnus-article-mark number))
4055 (push (gnus-data-make number mark (1+ (point)) header 0)
4056 gnus-newsgroup-data)
4057 (gnus-summary-insert-line
4059 mark (memq number gnus-newsgroup-replied)
4060 (memq number gnus-newsgroup-expirable)
4061 (mail-header-subject header) nil
4062 (cdr (assq number gnus-newsgroup-scored))
4063 (memq number gnus-newsgroup-processable))))))
4065 (defun gnus-summary-remove-list-identifiers ()
4066 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4067 (let ((regexp (if (stringp gnus-list-identifiers)
4068 gnus-list-identifiers
4069 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4070 (dolist (header gnus-newsgroup-headers)
4071 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4072 (mail-header-subject header))
4073 (mail-header-set-subject
4074 header (concat (substring (mail-header-subject header)
4075 0 (match-beginning 2))
4076 (substring (mail-header-subject header)
4077 (match-end 2))))))))
4079 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4080 "Select newsgroup GROUP.
4081 If READ-ALL is non-nil, all articles in the group are selected.
4082 If SELECT-ARTICLES, only select those articles from GROUP."
4083 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4084 ;;!!! Dirty hack; should be removed.
4085 (gnus-summary-ignore-duplicates
4086 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4088 gnus-summary-ignore-duplicates))
4089 (info (nth 2 entry))
4090 articles fetched-articles cached)
4092 (unless (gnus-check-server
4093 (setq gnus-current-select-method
4094 (gnus-find-method-for-group group)))
4095 (error "Couldn't open server"))
4097 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4098 (gnus-activate-group group) ; Or we can activate it...
4099 (progn ; Or we bug out.
4100 (when (equal major-mode 'gnus-summary-mode)
4101 (kill-buffer (current-buffer)))
4102 (error "Couldn't request group %s: %s"
4103 group (gnus-status-message group))))
4105 (unless (gnus-request-group group t)
4106 (when (equal major-mode 'gnus-summary-mode)
4107 (kill-buffer (current-buffer)))
4108 (error "Couldn't request group %s: %s"
4109 group (gnus-status-message group)))
4111 (setq gnus-newsgroup-name group)
4112 (setq gnus-newsgroup-unselected nil)
4113 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4114 (gnus-summary-setup-default-charset)
4116 ;; Adjust and set lists of article marks.
4118 (gnus-adjust-marked-articles info))
4120 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4121 (when (gnus-virtual-group-p group)
4122 (setq cached gnus-newsgroup-cached))
4124 (setq gnus-newsgroup-unreads
4125 (gnus-set-difference
4126 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4127 gnus-newsgroup-dormant))
4129 (setq gnus-newsgroup-processable nil)
4131 (gnus-update-read-articles group gnus-newsgroup-unreads)
4133 (if (setq articles select-articles)
4134 (setq gnus-newsgroup-unselected
4135 (gnus-sorted-intersection
4136 gnus-newsgroup-unreads
4137 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4138 (setq articles (gnus-articles-to-read group read-all)))
4142 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4144 ((eq articles 0) nil)
4146 ;; Init the dependencies hash table.
4147 (setq gnus-newsgroup-dependencies
4148 (gnus-make-hashtable (length articles)))
4149 (gnus-set-global-variables)
4150 ;; Retrieve the headers and read them in.
4151 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4152 (setq gnus-newsgroup-headers
4154 (setq gnus-headers-retrieved-by
4155 (gnus-retrieve-headers
4156 articles gnus-newsgroup-name
4157 ;; We might want to fetch old headers, but
4158 ;; not if there is only 1 article.
4160 (not (eq gnus-fetch-old-headers 'some))
4161 (not (numberp gnus-fetch-old-headers)))
4162 (> (length articles) 1))
4163 gnus-fetch-old-headers))))
4164 (gnus-get-newsgroup-headers-xover
4165 articles nil nil gnus-newsgroup-name t)
4166 (gnus-get-newsgroup-headers)))
4167 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4169 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4171 (setq gnus-newsgroup-cached cached))
4173 ;; Suppress duplicates?
4174 (when gnus-suppress-duplicates
4175 (gnus-dup-suppress-articles))
4177 ;; Set the initial limit.
4178 (setq gnus-newsgroup-limit (copy-sequence articles))
4179 ;; Remove canceled articles from the list of unread articles.
4180 (setq gnus-newsgroup-unreads
4181 (gnus-set-sorted-intersection
4182 gnus-newsgroup-unreads
4183 (setq fetched-articles
4184 (mapcar (lambda (headers) (mail-header-number headers))
4185 gnus-newsgroup-headers))))
4186 ;; Removed marked articles that do not exist.
4187 (gnus-update-missing-marks
4188 (gnus-sorted-complement fetched-articles articles))
4189 ;; We might want to build some more threads first.
4190 (when (and gnus-fetch-old-headers
4191 (eq gnus-headers-retrieved-by 'nov))
4192 (if (eq gnus-fetch-old-headers 'invisible)
4193 (gnus-build-all-threads)
4194 (gnus-build-old-threads)))
4195 ;; Let the Gnus agent mark articles as read.
4197 (gnus-agent-get-undownloaded-list))
4198 ;; Remove list identifiers from subject
4199 (when gnus-list-identifiers
4200 (gnus-summary-remove-list-identifiers))
4201 ;; Check whether auto-expire is to be done in this group.
4202 (setq gnus-newsgroup-auto-expire
4203 (gnus-group-auto-expirable-p group))
4204 ;; Set up the article buffer now, if necessary.
4205 (unless gnus-single-article-buffer
4206 (gnus-article-setup-buffer))
4207 ;; First and last article in this newsgroup.
4208 (when gnus-newsgroup-headers
4209 (setq gnus-newsgroup-begin
4210 (mail-header-number (car gnus-newsgroup-headers))
4213 (gnus-last-element gnus-newsgroup-headers))))
4214 ;; GROUP is successfully selected.
4215 (or gnus-newsgroup-headers t)))))
4217 (defun gnus-articles-to-read (group &optional read-all)
4218 ;; Find out what articles the user wants to read.
4220 ;; Select all articles if `read-all' is non-nil, or if there
4221 ;; are no unread articles.
4223 (and (zerop (length gnus-newsgroup-marked))
4224 (zerop (length gnus-newsgroup-unreads)))
4225 (eq (gnus-group-find-parameter group 'display)
4228 (gnus-uncompress-range (gnus-active group))
4229 (gnus-cache-articles-in-group group))
4230 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4231 (copy-sequence gnus-newsgroup-unreads))
4233 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4234 (scored (length scored-list))
4235 (number (length articles))
4236 (marked (+ (length gnus-newsgroup-marked)
4237 (length gnus-newsgroup-dormant)))
4245 ((and (or (<= scored marked) (= scored number))
4246 (numberp gnus-large-newsgroup)
4247 (> number gnus-large-newsgroup))
4251 "How many articles from %s (default %d): "
4252 (gnus-limit-string gnus-newsgroup-name 35)
4254 (if (string-match "^[ \t]*$" input) number input)))
4255 ((and (> scored marked) (< scored number)
4256 (> (- scored number) 20))
4259 (format "%s %s (%d scored, %d total): "
4260 "How many articles from"
4261 group scored number))))
4262 (if (string-match "^[ \t]*$" input)
4266 (setq select (if (stringp select) (string-to-number select) select))
4267 (if (or (null select) (zerop select))
4269 (if (and (not (zerop scored)) (<= (abs select) scored))
4271 (setq articles (sort scored-list '<))
4272 (setq number (length articles)))
4273 (setq articles (copy-sequence articles)))
4275 (when (< (abs select) number)
4277 ;; Select the N oldest articles.
4278 (setcdr (nthcdr (1- (abs select)) articles) nil)
4279 ;; Select the N most recent articles.
4280 (setq articles (nthcdr (- number select) articles))))
4281 (setq gnus-newsgroup-unselected
4282 (gnus-sorted-intersection
4283 gnus-newsgroup-unreads
4284 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4285 (when gnus-alter-articles-to-read-function
4286 (setq gnus-newsgroup-unreads
4288 (funcall gnus-alter-articles-to-read-function
4289 gnus-newsgroup-name gnus-newsgroup-unreads)
4293 (defun gnus-killed-articles (killed articles)
4296 (when (inline (gnus-member-of-range (car articles) killed))
4297 (push (car articles) out))
4298 (setq articles (cdr articles)))
4301 (defun gnus-uncompress-marks (marks)
4302 "Uncompress the mark ranges in MARKS."
4303 (let ((uncompressed '(score bookmark))
4306 (if (memq (caar marks) uncompressed)
4307 (push (car marks) out)
4308 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4309 (setq marks (cdr marks)))
4312 (defun gnus-adjust-marked-articles (info)
4313 "Set all article lists and remove all marks that are no longer valid."
4314 (let* ((marked-lists (gnus-info-marks info))
4315 (active (gnus-active (gnus-info-group info)))
4318 (types gnus-article-mark-lists)
4319 (uncompressed '(score bookmark killed))
4320 marks var articles article mark)
4323 (setq marks (pop marked-lists))
4324 (set (setq var (intern (format "gnus-newsgroup-%s"
4325 (car (rassq (setq mark (car marks))
4327 (if (memq (car marks) uncompressed) (cdr marks)
4328 (gnus-uncompress-range (cdr marks))))
4330 (setq articles (symbol-value var))
4332 ;; All articles have to be subsets of the active articles.
4334 ;; Adjust "simple" lists.
4335 ((memq mark '(tick dormant expire reply save))
4337 (when (or (< (setq article (pop articles)) min) (> article max))
4338 (set var (delq article (symbol-value var))))))
4340 ((memq mark uncompressed)
4341 (when (not (listp (cdr (symbol-value var))))
4342 (set var (list (symbol-value var))))
4343 (when (not (listp (cdr articles)))
4344 (setq articles (list articles)))
4346 (when (or (not (consp (setq article (pop articles))))
4347 (< (car article) min)
4348 (> (car article) max))
4349 (set var (delq article (symbol-value var))))))))))
4351 (defun gnus-update-missing-marks (missing)
4352 "Go through the list of MISSING articles and remove them from the mark lists."
4354 (let ((types gnus-article-mark-lists)
4356 ;; Go through all types.
4358 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4359 (when (symbol-value var)
4360 ;; This list has articles. So we delete all missing articles
4364 (set var (delq (pop m) (symbol-value var)))))))))
4366 (defun gnus-update-marks ()
4367 "Enter the various lists of marked articles into the newsgroup info list."
4368 (let ((types gnus-article-mark-lists)
4369 (info (gnus-get-info gnus-newsgroup-name))
4370 (uncompressed '(score bookmark killed))
4371 type list newmarked symbol delta-marks)
4373 ;; Add all marks lists to the list of marks lists.
4374 (while (setq type (pop types))
4375 (setq list (symbol-value
4377 (intern (format "gnus-newsgroup-%s"
4381 ;; Get rid of the entries of the articles that have the
4383 (when (and (eq (cdr type) 'score)
4387 (prev (cons nil list))
4390 (if (or (not (consp (car arts)))
4391 (= (cdar arts) gnus-summary-default-score))
4392 (setcdr prev (cdr arts))
4394 (setq arts (cdr arts)))
4395 (setq list (cdr all)))))
4397 (unless (memq (cdr type) uncompressed)
4398 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4400 (when (gnus-check-backend-function
4401 'request-set-mark gnus-newsgroup-name)
4402 ;; uncompressed:s are not proper flags (they are cons cells)
4403 ;; cache is a internal gnus flag
4404 (unless (memq (cdr type) (cons 'cache uncompressed))
4405 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4406 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4407 (add (gnus-remove-from-range
4408 (gnus-copy-sequence list) old)))
4410 (push (list add 'add (list (cdr type))) delta-marks))
4412 (push (list del 'del (list (cdr type))) delta-marks)))))
4415 (push (cons (cdr type) list) newmarked)))
4418 (unless (gnus-check-group gnus-newsgroup-name)
4419 (error "Can't open server for %s" gnus-newsgroup-name))
4420 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4422 ;; Enter these new marks into the info of the group.
4424 (setcar (nthcdr 3 info) newmarked)
4425 ;; Add the marks lists to the end of the info.
4427 (setcdr (nthcdr 2 info) (list newmarked))))
4429 ;; Cut off the end of the info if there's nothing else there.
4433 (when (nthcdr (decf i) info)
4434 (setcdr (nthcdr i info) nil)))))))
4436 (defun gnus-set-mode-line (where)
4437 "This function sets the mode line of the article or summary buffers.
4438 If WHERE is `summary', the summary mode line format will be used."
4439 ;; Is this mode line one we keep updated?
4440 (when (and (memq where gnus-updated-mode-lines)
4442 (intern (format "gnus-%s-mode-line-format-spec" where))))
4445 ;; We evaluate this in the summary buffer since these
4446 ;; variables are buffer-local to that buffer.
4447 (set-buffer gnus-summary-buffer)
4448 ;; We bind all these variables that are used in the `eval' form
4450 (let* ((mformat (symbol-value
4452 (format "gnus-%s-mode-line-format-spec" where))))
4453 (gnus-tmp-group-name gnus-newsgroup-name)
4454 (gnus-tmp-article-number (or gnus-current-article 0))
4455 (gnus-tmp-unread gnus-newsgroup-unreads)
4456 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4457 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4458 (gnus-tmp-unread-and-unselected
4459 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4460 (zerop gnus-tmp-unselected))
4462 ((zerop gnus-tmp-unselected)
4463 (format "{%d more}" gnus-tmp-unread-and-unticked))
4464 (t (format "{%d(+%d) more}"
4465 gnus-tmp-unread-and-unticked
4466 gnus-tmp-unselected))))
4468 (if (and gnus-current-headers
4469 (vectorp gnus-current-headers))
4470 (gnus-mode-string-quote
4471 (mail-header-subject gnus-current-headers))
4473 bufname-length max-len
4474 gnus-tmp-header);; passed as argument to any user-format-funcs
4475 (setq mode-string (eval mformat))
4476 (setq bufname-length (if (string-match "%b" mode-string)
4479 (if (eq where 'summary)
4481 (get-buffer gnus-article-buffer))))
4484 (setq max-len (max 4 (if gnus-mode-non-string-length
4486 gnus-mode-non-string-length
4488 (length mode-string))))
4489 ;; We might have to chop a bit of the string off...
4490 (when (> (length mode-string) max-len)
4492 (concat (truncate-string-to-width mode-string (- max-len 3))
4494 ;; Pad the mode string a bit.
4495 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4496 ;; Update the mode line.
4497 (setq mode-line-buffer-identification
4498 (gnus-mode-line-buffer-identification (list mode-string)))
4499 (set-buffer-modified-p t))))
4501 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4502 "Go through the HEADERS list and add all Xrefs to a hash table.
4503 The resulting hash table is returned, or nil if no Xrefs were found."
4504 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4505 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4506 (xref-hashtb (gnus-make-hashtable))
4507 start group entry number xrefs header)
4509 (setq header (pop headers))
4510 (when (and (setq xrefs (mail-header-xref header))
4511 (not (memq (setq number (mail-header-number header))
4514 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4515 (setq start (match-end 0))
4516 (setq group (if prefix
4517 (concat prefix (substring xrefs (match-beginning 1)
4519 (substring xrefs (match-beginning 1) (match-end 1))))
4521 (string-to-int (substring xrefs (match-beginning 2)
4523 (if (setq entry (gnus-gethash group xref-hashtb))
4524 (setcdr entry (cons number (cdr entry)))
4525 (gnus-sethash group (cons number nil) xref-hashtb)))))
4526 (and start xref-hashtb)))
4528 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4529 "Look through all the headers and mark the Xrefs as read."
4530 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4531 name entry info xref-hashtb idlist method nth4)
4533 (set-buffer gnus-group-buffer)
4534 (when (setq xref-hashtb
4535 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4538 (unless (string= from-newsgroup (setq name (symbol-name group)))
4539 (setq idlist (symbol-value group))
4540 ;; Dead groups are not updated.
4542 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4544 (when (stringp (setq nth4 (gnus-info-method info)))
4545 (setq nth4 (gnus-server-to-method nth4))))
4546 ;; Only do the xrefs if the group has the same
4547 ;; select method as the group we have just read.
4548 (or (gnus-methods-equal-p
4549 nth4 (gnus-find-method-for-group from-newsgroup))
4551 (equal nth4 (setq method (gnus-find-method-for-group
4553 (and (equal (car nth4) (car method))
4554 (equal (nth 1 nth4) (nth 1 method))))
4555 gnus-use-cross-reference
4556 (or (not (eq gnus-use-cross-reference t))
4558 ;; Only do cross-references on subscribed
4559 ;; groups, if that is what is wanted.
4560 (<= (gnus-info-level info) gnus-level-subscribed))
4561 (gnus-group-make-articles-read name idlist))))
4564 (defun gnus-compute-read-articles (group articles)
4565 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4566 (info (nth 2 entry))
4567 (active (gnus-active group))
4570 ;; First peel off all invalid article numbers.
4572 (let ((ids articles)
4574 (while (setq id (pop ids))
4575 (when (and first (> id (cdr active)))
4576 ;; We'll end up in this situation in one particular
4577 ;; obscure situation. If you re-scan a group and get
4578 ;; a new article that is cross-posted to a different
4579 ;; group that has not been re-scanned, you might get
4580 ;; crossposted article that has a higher number than
4581 ;; Gnus believes possible. So we re-activate this
4582 ;; group as well. This might mean doing the
4583 ;; crossposting thingy will *increase* the number
4584 ;; of articles in some groups. Tsk, tsk.
4585 (setq active (or (gnus-activate-group group) active)))
4586 (when (or (> id (cdr active))
4587 (< id (car active)))
4588 (setq articles (delq id articles))))))
4589 ;; If the read list is nil, we init it.
4591 (null (gnus-info-read info))
4593 (setq ninfo (cons 1 (1- (car active))))
4594 (setq ninfo (gnus-info-read info)))
4595 ;; Then we add the read articles to the range.
4597 ninfo (setq articles (sort articles '<))))))
4599 (defun gnus-group-make-articles-read (group articles)
4600 "Update the info of GROUP to say that ARTICLES are read."
4602 (entry (gnus-gethash group gnus-newsrc-hashtb))
4603 (info (nth 2 entry))
4604 (active (gnus-active group))
4607 (setq range (gnus-compute-read-articles group articles))
4609 (set-buffer gnus-group-buffer)
4612 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4613 (gnus-info-set-read ',info ',(gnus-info-read info))
4614 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4615 (gnus-group-update-group ,group t))))
4616 ;; Add the read articles to the range.
4617 (gnus-info-set-read info range)
4618 ;; Then we have to re-compute how many unread
4619 ;; articles there are in this group.
4623 (setq num (- (1+ (cdr active)) (car active))))
4624 ((not (listp (cdr range)))
4625 (setq num (- (cdr active) (- (1+ (cdr range))
4629 (if (numberp (car range))
4631 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4632 (setq range (cdr range)))
4633 (setq num (- (cdr active) num))))
4634 ;; Update the number of unread articles.
4636 ;; Update the group buffer.
4637 (gnus-group-update-group group t)))))
4639 (defvar gnus-newsgroup-none-id 0)
4641 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4642 (let ((cur nntp-server-buffer)
4645 (save-excursion (set-buffer gnus-summary-buffer)
4646 gnus-newsgroup-dependencies)))
4648 (mail-parse-charset gnus-newsgroup-charset)
4649 (mail-parse-ignored-charsets
4650 (save-excursion (condition-case nil
4651 (set-buffer gnus-summary-buffer)
4653 gnus-newsgroup-ignored-charsets)))
4655 (set-buffer nntp-server-buffer)
4656 ;; Translate all TAB characters into SPACE characters.
4657 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4658 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4659 (gnus-run-hooks 'gnus-parse-headers-hook)
4660 (let ((case-fold-search t)
4661 in-reply-to header p lines chars)
4662 (goto-char (point-min))
4663 ;; Search to the beginning of the next header. Error messages
4664 ;; do not begin with 2 or 3.
4665 (while (re-search-forward "^[23][0-9]+ " nil t)
4668 ;; This implementation of this function, with nine
4669 ;; search-forwards instead of the one re-search-forward and
4670 ;; a case (which basically was the old function) is actually
4671 ;; about twice as fast, even though it looks messier. You
4672 ;; can't have everything, I guess. Speed and elegance
4673 ;; doesn't always go hand in hand.
4682 (narrow-to-region (point)
4683 (or (and (search-forward "\n.\n" nil t)
4689 (if (search-forward "\nsubject: " nil t)
4690 (funcall gnus-decode-encoded-word-function
4691 (nnheader-header-value))
4696 (if (search-forward "\nfrom: " nil t)
4697 (funcall gnus-decode-encoded-word-function
4698 (nnheader-header-value))
4703 (if (search-forward "\ndate: " nil t)
4704 (nnheader-header-value) ""))
4708 (setq id (if (re-search-forward
4709 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4710 ;; We do it this way to make sure the Message-ID
4711 ;; is (somewhat) syntactically valid.
4712 (buffer-substring (match-beginning 1)
4714 ;; If there was no message-id, we just fake one
4715 ;; to make subsequent routines simpler.
4716 (nnheader-generate-fake-message-id))))
4720 (if (search-forward "\nreferences: " nil t)
4724 (nnheader-header-value)
4729 (search-backward ">" end t)
4732 (search-backward "<" end t)
4734 ;; Get the references from the in-reply-to header if there
4735 ;; were no references and the in-reply-to header looks
4737 (if (and (search-forward "\nin-reply-to: " nil t)
4738 (setq in-reply-to (nnheader-header-value))
4739 (string-match "<[^>]+>" in-reply-to))
4741 (setq ref (substring in-reply-to (match-beginning 0)
4743 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4744 (setq ref2 (substring in-reply-to (match-beginning 0)
4746 (when (> (length ref2) (length ref))
4753 (if (search-forward "\nchars: " nil t)
4754 (if (numberp (setq chars (ignore-errors (read cur))))
4760 (if (search-forward "\nlines: " nil t)
4761 (if (numberp (setq lines (ignore-errors (read cur))))
4767 (and (search-forward "\nxref: " nil t)
4768 (nnheader-header-value)))
4770 (when gnus-extra-headers
4771 (let ((extra gnus-extra-headers)
4775 (when (search-forward
4776 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4777 (push (cons (car extra) (nnheader-header-value))
4781 (when (equal id ref)
4784 (when gnus-alter-header-function
4785 (funcall gnus-alter-header-function header)
4786 (setq id (mail-header-id header)
4787 ref (gnus-parent-id (mail-header-references header))))
4790 (gnus-dependencies-add-header
4791 header dependencies force-new))
4792 (push header headers))
4793 (goto-char (point-max))
4795 (nreverse headers)))))
4797 ;; Goes through the xover lines and returns a list of vectors
4798 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4799 force-new dependencies
4800 group also-fetch-heads)
4801 "Parse the news overview data in the server buffer, and return a
4802 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4803 ;; Get the Xref when the users reads the articles since most/some
4804 ;; NNTP servers do not include Xrefs when using XOVER.
4805 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4806 (let ((mail-parse-charset gnus-newsgroup-charset)
4807 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4808 (cur nntp-server-buffer)
4809 (dependencies (or dependencies gnus-newsgroup-dependencies))
4810 number headers header)
4812 (set-buffer nntp-server-buffer)
4813 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4814 ;; Allow the user to mangle the headers before parsing them.
4815 (gnus-run-hooks 'gnus-parse-headers-hook)
4816 (goto-char (point-min))
4819 (while (and sequence (not (eobp)))
4820 (setq number (read cur))
4821 (while (and sequence
4822 (< (car sequence) number))
4823 (setq sequence (cdr sequence)))
4825 (eq number (car sequence))
4827 (setq sequence (cdr sequence))
4828 (setq header (inline
4829 (gnus-nov-parse-line
4830 number dependencies force-new))))
4831 (push header headers))
4834 (gnus-error 4 "Strange nov line (%d)"
4835 (count-lines (point-min) (point)))))
4837 ;; A common bug in inn is that if you have posted an article and
4838 ;; then retrieves the active file, it will answer correctly --
4839 ;; the new article is included. However, a NOV entry for the
4840 ;; article may not have been generated yet, so this may fail.
4841 ;; We work around this problem by retrieving the last few
4842 ;; headers using HEAD.
4843 (if (or (not also-fetch-heads)
4845 ;; We (probably) got all the headers.
4847 (let ((gnus-nov-is-evil t))
4850 (when (gnus-retrieve-headers sequence group)
4851 (gnus-get-newsgroup-headers))))))))
4853 (defun gnus-article-get-xrefs ()
4854 "Fill in the Xref value in `gnus-current-headers', if necessary.
4855 This is meant to be called in `gnus-article-internal-prepare-hook'."
4856 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4857 gnus-current-headers)))
4858 (or (not gnus-use-cross-reference)
4860 (and (mail-header-xref headers)
4861 (not (string= (mail-header-xref headers) "")))
4862 (let ((case-fold-search t)
4865 (nnheader-narrow-to-headers)
4866 (goto-char (point-min))
4867 (when (or (and (not (eobp))
4868 (eq (downcase (char-after)) ?x)
4869 (looking-at "Xref:"))
4870 (search-forward "\nXref:" nil t))
4871 (goto-char (1+ (match-end 0)))
4872 (setq xref (buffer-substring (point)
4873 (progn (end-of-line) (point))))
4874 (mail-header-set-xref headers xref)))))))
4876 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4877 "Find article ID and insert the summary line for that article.
4878 OLD-HEADER can either be a header or a line number to insert
4879 the subject line on."
4880 (let* ((line (and (numberp old-header) old-header))
4881 (old-header (and (vectorp old-header) old-header))
4882 (header (cond ((and old-header use-old-header)
4885 (gnus-number-to-header id))
4886 (gnus-number-to-header id))
4888 (gnus-read-header id))))
4889 (number (and (numberp id) id))
4892 ;; Rebuild the thread that this article is part of and go to the
4893 ;; article we have fetched.
4894 (when (and (not gnus-show-threads)
4897 (setq d (gnus-data-find (mail-header-number old-header))))
4898 (goto-char (gnus-data-pos d))
4901 (- (gnus-point-at-bol)
4903 (1+ (gnus-point-at-eol))
4904 (gnus-delete-line))))))
4906 (mail-header-set-number header (mail-header-number old-header)))
4907 (setq gnus-newsgroup-sparse
4908 (delq (setq number (mail-header-number header))
4909 gnus-newsgroup-sparse))
4910 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4911 (push number gnus-newsgroup-limit)
4912 (gnus-rebuild-thread (mail-header-id header) line)
4913 (gnus-summary-goto-subject number nil t))
4914 (when (and (numberp number)
4916 ;; We have to update the boundaries even if we can't fetch the
4917 ;; article if ID is a number -- so that the next `P' or `N'
4918 ;; command will fetch the previous (or next) article even
4919 ;; if the one we tried to fetch this time has been canceled.
4920 (when (> number gnus-newsgroup-end)
4921 (setq gnus-newsgroup-end number))
4922 (when (< number gnus-newsgroup-begin)
4923 (setq gnus-newsgroup-begin number))
4924 (setq gnus-newsgroup-unselected
4925 (delq number gnus-newsgroup-unselected)))
4926 ;; Report back a success?
4927 (and header (mail-header-number header))))
4929 ;;; Process/prefix in the summary buffer
4931 (defun gnus-summary-work-articles (n)
4932 "Return a list of articles to be worked upon.
4933 The prefix argument, the list of process marked articles, and the
4934 current article will be taken into consideration."
4936 (set-buffer gnus-summary-buffer)
4939 ;; A numerical prefix has been given.
4940 (setq n (prefix-numeric-value n))
4941 (let ((backward (< n 0))
4942 (n (abs (prefix-numeric-value n)))
4947 (push (setq article (gnus-summary-article-number))
4950 (gnus-summary-find-prev nil article)
4951 (gnus-summary-find-next nil article)))
4953 (nreverse articles)))
4954 ((and (gnus-region-active-p) (mark))
4955 (message "region active")
4956 ;; Work on the region between point and mark.
4957 (let ((max (max (point) (mark)))
4960 (goto-char (min (min (point) (mark))))
4963 (push (setq article (gnus-summary-article-number)) articles)
4964 (gnus-summary-find-next nil article)
4966 (nreverse articles))))
4967 (gnus-newsgroup-processable
4968 ;; There are process-marked articles present.
4969 ;; Save current state.
4970 (gnus-summary-save-process-mark)
4972 (reverse gnus-newsgroup-processable))
4974 ;; Just return the current article.
4975 (list (gnus-summary-article-number))))))
4977 (defmacro gnus-summary-iterate (arg &rest forms)
4978 "Iterate over the process/prefixed articles and do FORMS.
4979 ARG is the interactive prefix given to the command. FORMS will be
4980 executed with point over the summary line of the articles."
4981 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4982 `(let ((,articles (gnus-summary-work-articles ,arg)))
4984 (gnus-summary-goto-subject (car ,articles))
4988 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4989 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4991 (defun gnus-summary-save-process-mark ()
4992 "Push the current set of process marked articles on the stack."
4994 (push (copy-sequence gnus-newsgroup-processable)
4995 gnus-newsgroup-process-stack))
4997 (defun gnus-summary-kill-process-mark ()
4998 "Push the current set of process marked articles on the stack and unmark."
5000 (gnus-summary-save-process-mark)
5001 (gnus-summary-unmark-all-processable))
5003 (defun gnus-summary-yank-process-mark ()
5004 "Pop the last process mark state off the stack and restore it."
5006 (unless gnus-newsgroup-process-stack
5007 (error "Empty mark stack"))
5008 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5010 (defun gnus-summary-process-mark-set (set)
5011 "Make SET into the current process marked articles."
5012 (gnus-summary-unmark-all-processable)
5014 (gnus-summary-set-process-mark (pop set))))
5016 ;;; Searching and stuff
5018 (defun gnus-summary-search-group (&optional backward use-level)
5019 "Search for next unread newsgroup.
5020 If optional argument BACKWARD is non-nil, search backward instead."
5022 (set-buffer gnus-group-buffer)
5023 (when (gnus-group-search-forward
5024 backward nil (if use-level (gnus-group-group-level) nil))
5025 (gnus-group-group-name))))
5027 (defun gnus-summary-best-group (&optional exclude-group)
5028 "Find the name of the best unread group.
5029 If EXCLUDE-GROUP, do not go to this group."
5031 (set-buffer gnus-group-buffer)
5033 (gnus-group-best-unread-group exclude-group))))
5035 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5036 (if backward (gnus-summary-find-prev)
5037 (let* ((dummy (gnus-summary-article-intangible-p))
5038 (article (or article (gnus-summary-article-number)))
5039 (arts (gnus-data-find-list article))
5041 (when (and (not dummy)
5042 (or (not gnus-summary-check-current)
5044 (not (gnus-data-unread-p (car arts)))))
5045 (setq arts (cdr arts)))
5050 (when (or (and undownloaded
5051 (eq gnus-undownloaded-mark
5052 (gnus-data-mark (car arts))))
5053 (gnus-data-unread-p (car arts)))
5054 (setq result (car arts)
5056 (setq arts (cdr arts)))
5059 (goto-char (gnus-data-pos result))
5060 (gnus-data-number result)))))
5062 (defun gnus-summary-find-prev (&optional unread article)
5063 (let* ((eobp (eobp))
5064 (article (or article (gnus-summary-article-number)))
5065 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5067 (when (and (not eobp)
5068 (or (not gnus-summary-check-current)
5070 (not (gnus-data-unread-p (car arts)))))
5071 (setq arts (cdr arts)))
5076 (when (gnus-data-unread-p (car arts))
5077 (setq result (car arts)
5079 (setq arts (cdr arts)))
5082 (goto-char (gnus-data-pos result))
5083 (gnus-data-number result))))
5085 (defun gnus-summary-find-subject (subject &optional unread backward article)
5086 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5087 (article (or article (gnus-summary-article-number)))
5088 (articles (gnus-data-list backward))
5089 (arts (gnus-data-find-list article articles))
5091 (when (or (not gnus-summary-check-current)
5093 (not (gnus-data-unread-p (car arts))))
5094 (setq arts (cdr arts)))
5096 (and (or (not unread)
5097 (gnus-data-unread-p (car arts)))
5098 (vectorp (gnus-data-header (car arts)))
5100 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5101 (setq result (car arts)
5103 (setq arts (cdr arts)))
5105 (goto-char (gnus-data-pos result))
5106 (gnus-data-number result))))
5108 (defun gnus-summary-search-forward (&optional unread subject backward)
5109 "Search forward for an article.
5110 If UNREAD, look for unread articles. If SUBJECT, look for
5111 articles with that subject. If BACKWARD, search backward instead."
5112 (cond (subject (gnus-summary-find-subject subject unread backward))
5113 (backward (gnus-summary-find-prev unread))
5114 (t (gnus-summary-find-next unread))))
5116 (defun gnus-recenter (&optional n)
5117 "Center point in window and redisplay frame.
5118 Also do horizontal recentering."
5121 gnus-auto-center-summary
5122 (not (eq gnus-auto-center-summary 'vertical)))
5123 (gnus-horizontal-recenter))
5126 (defun gnus-summary-recenter ()
5127 "Center point in the summary window.
5128 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5129 displayed, no centering will be performed."
5130 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5131 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5133 (let* ((top (cond ((< (window-height) 4) 0)
5134 ((< (window-height) 7) 1)
5135 (t (if (numberp gnus-auto-center-summary)
5136 gnus-auto-center-summary
5138 (height (1- (window-height)))
5139 (bottom (save-excursion (goto-char (point-max))
5140 (forward-line (- height))
5142 (window (get-buffer-window (current-buffer))))
5143 ;; The user has to want it.
5144 (when gnus-auto-center-summary
5145 (when (get-buffer-window gnus-article-buffer)
5146 ;; Only do recentering when the article buffer is displayed,
5147 ;; Set the window start to either `bottom', which is the biggest
5148 ;; possible valid number, or the second line from the top,
5149 ;; whichever is the least.
5151 window (min bottom (save-excursion
5152 (forward-line (- top)) (point)))
5154 ;; Do horizontal recentering while we're at it.
5155 (when (and (get-buffer-window (current-buffer) t)
5156 (not (eq gnus-auto-center-summary 'vertical)))
5157 (let ((selected (selected-window)))
5158 (select-window (get-buffer-window (current-buffer) t))
5159 (gnus-summary-position-point)
5160 (gnus-horizontal-recenter)
5161 (select-window selected))))))
5163 (defun gnus-summary-jump-to-group (newsgroup)
5164 "Move point to NEWSGROUP in group mode buffer."
5165 ;; Keep update point of group mode buffer if visible.
5166 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5167 (save-window-excursion
5168 ;; Take care of tree window mode.
5169 (when (get-buffer-window gnus-group-buffer)
5170 (pop-to-buffer gnus-group-buffer))
5171 (gnus-group-jump-to-group newsgroup))
5173 ;; Take care of tree window mode.
5174 (if (get-buffer-window gnus-group-buffer)
5175 (pop-to-buffer gnus-group-buffer)
5176 (set-buffer gnus-group-buffer))
5177 (gnus-group-jump-to-group newsgroup))))
5179 ;; This function returns a list of article numbers based on the
5180 ;; difference between the ranges of read articles in this group and
5181 ;; the range of active articles.
5182 (defun gnus-list-of-unread-articles (group)
5183 (let* ((read (gnus-info-read (gnus-get-info group)))
5184 (active (or (gnus-active group) (gnus-activate-group group)))
5187 ;; If none are read, then all are unread.
5189 (setq first (car active))
5190 ;; If the range of read articles is a single range, then the
5191 ;; first unread article is the article after the last read
5192 ;; article. Sounds logical, doesn't it?
5193 (if (and (not (listp (cdr read)))
5194 (or (< (car read) (car active))
5195 (progn (setq read (list read))
5197 (setq first (max (car active) (1+ (cdr read))))
5198 ;; `read' is a list of ranges.
5199 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5202 (setq first (car active)))
5205 (while (< first nlast)
5207 (setq first (1+ first))))
5208 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5209 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5210 (setq read (cdr read)))))
5211 ;; And add the last unread articles.
5212 (while (<= first last)
5214 (setq first (1+ first)))
5215 ;; Return the list of unread articles.
5216 (delq 0 (nreverse unread))))
5218 (defun gnus-list-of-read-articles (group)
5219 "Return a list of unread, unticked and non-dormant articles."
5220 (let* ((info (gnus-get-info group))
5221 (marked (gnus-info-marks info))
5222 (active (gnus-active group)))
5224 (gnus-set-difference
5225 (gnus-sorted-complement
5226 (gnus-uncompress-range active)
5227 (gnus-list-of-unread-articles group))
5229 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5230 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5232 ;; Various summary commands
5234 (defun gnus-summary-select-article-buffer ()
5235 "Reconfigure windows to show article buffer."
5237 (if (not (gnus-buffer-live-p gnus-article-buffer))
5238 (error "There is no article buffer for this summary buffer")
5239 (gnus-configure-windows 'article)
5240 (select-window (get-buffer-window gnus-article-buffer))))
5242 (defun gnus-summary-universal-argument (arg)
5243 "Perform any operation on all articles that are process/prefixed."
5245 (let ((articles (gnus-summary-work-articles arg))
5252 (substitute-command-keys
5253 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5255 (gnus-error 1 "Undefined key")
5258 (gnus-summary-goto-subject (setq article (pop articles)))
5259 (let (gnus-newsgroup-processable)
5260 (command-execute func))
5261 (gnus-summary-remove-process-mark article)))))
5262 (gnus-summary-position-point))
5264 (defun gnus-summary-toggle-truncation (&optional arg)
5265 "Toggle truncation of summary lines.
5266 With arg, turn line truncation on iff arg is positive."
5268 (setq truncate-lines
5269 (if (null arg) (not truncate-lines)
5270 (> (prefix-numeric-value arg) 0)))
5273 (defun gnus-summary-reselect-current-group (&optional all rescan)
5274 "Exit and then reselect the current newsgroup.
5275 The prefix argument ALL means to select all articles."
5277 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5278 (error "Ephemeral groups can't be reselected"))
5279 (let ((current-subject (gnus-summary-article-number))
5280 (group gnus-newsgroup-name))
5281 (setq gnus-newsgroup-begin nil)
5283 ;; We have to adjust the point of group mode buffer because
5284 ;; point was moved to the next unread newsgroup by exiting.
5285 (gnus-summary-jump-to-group group)
5288 (gnus-group-get-new-news-this-group 1)))
5289 (gnus-group-read-group all t)
5290 (gnus-summary-goto-subject current-subject nil t)))
5292 (defun gnus-summary-rescan-group (&optional all)
5293 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5295 (gnus-summary-reselect-current-group all t))
5297 (defun gnus-summary-update-info (&optional non-destructive)
5299 (let ((group gnus-newsgroup-name))
5301 (when gnus-newsgroup-kill-headers
5302 (setq gnus-newsgroup-killed
5303 (gnus-compress-sequence
5305 (gnus-set-sorted-intersection
5306 (gnus-uncompress-range gnus-newsgroup-killed)
5307 (setq gnus-newsgroup-unselected
5308 (sort gnus-newsgroup-unselected '<)))
5309 (setq gnus-newsgroup-unreads
5310 (sort gnus-newsgroup-unreads '<)))
5312 (unless (listp (cdr gnus-newsgroup-killed))
5313 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5314 (let ((headers gnus-newsgroup-headers))
5315 ;; Set the new ranges of read articles.
5317 (set-buffer gnus-group-buffer)
5318 (gnus-undo-force-boundary))
5319 (gnus-update-read-articles
5320 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5321 ;; Set the current article marks.
5322 (let ((gnus-newsgroup-scored
5323 (if (and (not gnus-save-score)
5324 (not non-destructive))
5326 gnus-newsgroup-scored)))
5328 (gnus-update-marks)))
5329 ;; Do the cross-ref thing.
5330 (when gnus-use-cross-reference
5331 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5332 ;; Do not switch windows but change the buffer to work.
5333 (set-buffer gnus-group-buffer)
5334 (unless (gnus-ephemeral-group-p group)
5335 (gnus-group-update-group group)))))))
5337 (defun gnus-summary-save-newsrc (&optional force)
5338 "Save the current number of read/marked articles in the dribble buffer.
5339 The dribble buffer will then be saved.
5340 If FORCE (the prefix), also save the .newsrc file(s)."
5342 (gnus-summary-update-info t)
5344 (gnus-save-newsrc-file)
5345 (gnus-dribble-save)))
5347 (defun gnus-summary-exit (&optional temporary)
5348 "Exit reading current newsgroup, and then return to group selection mode.
5349 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5351 (gnus-set-global-variables)
5352 (when (gnus-buffer-live-p gnus-article-buffer)
5354 (set-buffer gnus-article-buffer)
5355 (mm-destroy-parts gnus-article-mime-handles)))
5356 (gnus-kill-save-kill-buffer)
5357 (gnus-async-halt-prefetch)
5358 (let* ((group gnus-newsgroup-name)
5359 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5362 (buf (current-buffer)))
5364 ;; Do adaptive scoring, and possibly save score files.
5365 (when gnus-newsgroup-adaptive
5366 (gnus-score-adaptive))
5367 (when gnus-use-scoring
5369 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5370 ;; If we have several article buffers, we kill them at exit.
5371 (unless gnus-single-article-buffer
5372 (gnus-kill-buffer gnus-original-article-buffer)
5373 (setq gnus-article-current nil))
5374 (when gnus-use-cache
5375 (gnus-cache-possibly-remove-articles)
5376 (gnus-cache-save-buffers))
5377 (gnus-async-prefetch-remove-group group)
5378 (when gnus-suppress-duplicates
5379 (gnus-dup-enter-articles))
5380 (when gnus-use-trees
5381 (gnus-tree-close group))
5382 (when gnus-use-cache
5383 (gnus-cache-write-active))
5384 ;; Remove entries for this group.
5385 (nnmail-purge-split-history (gnus-group-real-name group))
5386 ;; Make all changes in this group permanent.
5388 (gnus-run-hooks 'gnus-exit-group-hook)
5389 (gnus-summary-update-info))
5390 (gnus-close-group group)
5391 ;; Make sure where we were, and go to next newsgroup.
5392 (set-buffer gnus-group-buffer)
5394 (gnus-group-jump-to-group group))
5395 (gnus-run-hooks 'gnus-summary-exit-hook)
5396 (unless (or quit-config
5397 ;; If this group has disappeared from the summary
5398 ;; buffer, don't skip forwards.
5399 (not (string= group (gnus-group-group-name))))
5400 (gnus-group-next-unread-group 1))
5401 (setq group-point (point))
5404 ;; If we have several article buffers, we kill them at exit.
5405 (unless gnus-single-article-buffer
5406 (gnus-kill-buffer gnus-article-buffer)
5407 (gnus-kill-buffer gnus-original-article-buffer)
5408 (setq gnus-article-current nil))
5410 (if (not gnus-kill-summary-on-exit)
5411 (gnus-deaden-summary)
5412 ;; We set all buffer-local variables to nil. It is unclear why
5413 ;; this is needed, but if we don't, buffer-local variables are
5414 ;; not garbage-collected, it seems. This would the lead to en
5415 ;; ever-growing Emacs.
5416 (gnus-summary-clear-local-variables)
5417 (when (get-buffer gnus-article-buffer)
5418 (bury-buffer gnus-article-buffer))
5419 ;; We clear the global counterparts of the buffer-local
5420 ;; variables as well, just to be on the safe side.
5421 (set-buffer gnus-group-buffer)
5422 (gnus-summary-clear-local-variables)
5423 ;; Return to group mode buffer.
5424 (when (eq mode 'gnus-summary-mode)
5425 (gnus-kill-buffer buf)))
5426 (setq gnus-current-select-method gnus-select-method)
5427 (pop-to-buffer gnus-group-buffer)
5428 (if (not quit-config)
5430 (goto-char group-point)
5431 (gnus-configure-windows 'group 'force))
5432 (gnus-handle-ephemeral-exit quit-config))
5433 ;; Clear the current group name.
5435 (setq gnus-newsgroup-name nil)))))
5437 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5438 (defun gnus-summary-exit-no-update (&optional no-questions)
5439 "Quit reading current newsgroup without updating read article info."
5441 (let* ((group gnus-newsgroup-name)
5442 (quit-config (gnus-group-quit-config group)))
5443 (when (or no-questions
5445 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5446 (gnus-async-halt-prefetch)
5448 (delq 'gnus-summary-expire-articles
5449 (copy-sequence gnus-summary-prepare-exit-hook)))
5450 (when (gnus-buffer-live-p gnus-article-buffer)
5452 (set-buffer gnus-article-buffer)
5453 (mm-destroy-parts gnus-article-mime-handles)))
5454 ;; If we have several article buffers, we kill them at exit.
5455 (unless gnus-single-article-buffer
5456 (gnus-kill-buffer gnus-article-buffer)
5457 (gnus-kill-buffer gnus-original-article-buffer)
5458 (setq gnus-article-current nil))
5459 (if (not gnus-kill-summary-on-exit)
5460 (gnus-deaden-summary)
5461 (gnus-close-group group)
5462 (gnus-summary-clear-local-variables)
5463 (set-buffer gnus-group-buffer)
5464 (gnus-summary-clear-local-variables)
5465 (when (get-buffer gnus-summary-buffer)
5466 (kill-buffer gnus-summary-buffer)))
5467 (unless gnus-single-article-buffer
5468 (setq gnus-article-current nil))
5469 (when gnus-use-trees
5470 (gnus-tree-close group))
5471 (gnus-async-prefetch-remove-group group)
5472 (when (get-buffer gnus-article-buffer)
5473 (bury-buffer gnus-article-buffer))
5474 ;; Return to the group buffer.
5475 (gnus-configure-windows 'group 'force)
5476 ;; Clear the current group name.
5477 (setq gnus-newsgroup-name nil)
5478 (when (equal (gnus-group-group-name) group)
5479 (gnus-group-next-unread-group 1))
5481 (gnus-handle-ephemeral-exit quit-config)))))
5483 (defun gnus-handle-ephemeral-exit (quit-config)
5484 "Handle movement when leaving an ephemeral group.
5485 The state which existed when entering the ephemeral is reset."
5486 (if (not (buffer-name (car quit-config)))
5487 (gnus-configure-windows 'group 'force)
5488 (set-buffer (car quit-config))
5489 (cond ((eq major-mode 'gnus-summary-mode)
5490 (gnus-set-global-variables))
5491 ((eq major-mode 'gnus-article-mode)
5493 ;; The `gnus-summary-buffer' variable may point
5494 ;; to the old summary buffer when using a single
5496 (unless (gnus-buffer-live-p gnus-summary-buffer)
5497 (set-buffer gnus-group-buffer))
5498 (set-buffer gnus-summary-buffer)
5499 (gnus-set-global-variables))))
5500 (if (or (eq (cdr quit-config) 'article)
5501 (eq (cdr quit-config) 'pick))
5503 ;; The current article may be from the ephemeral group
5504 ;; thus it is best that we reload this article
5505 (gnus-summary-show-article)
5506 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5507 (gnus-configure-windows 'pick 'force)
5508 (gnus-configure-windows (cdr quit-config) 'force)))
5509 (gnus-configure-windows (cdr quit-config) 'force))
5510 (when (eq major-mode 'gnus-summary-mode)
5511 (gnus-summary-next-subject 1 nil t)
5512 (gnus-summary-recenter)
5513 (gnus-summary-position-point))))
5517 (defvar gnus-dead-summary-mode-map nil)
5519 (unless gnus-dead-summary-mode-map
5520 (setq gnus-dead-summary-mode-map (make-keymap))
5521 (suppress-keymap gnus-dead-summary-mode-map)
5522 (substitute-key-definition
5523 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5524 (let ((keys '("\C-d" "\r" "\177" [delete])))
5526 (define-key gnus-dead-summary-mode-map
5527 (pop keys) 'gnus-summary-wake-up-the-dead))))
5529 (defvar gnus-dead-summary-mode nil
5530 "Minor mode for Gnus summary buffers.")
5532 (defun gnus-dead-summary-mode (&optional arg)
5533 "Minor mode for Gnus summary buffers."
5535 (when (eq major-mode 'gnus-summary-mode)
5536 (make-local-variable 'gnus-dead-summary-mode)
5537 (setq gnus-dead-summary-mode
5538 (if (null arg) (not gnus-dead-summary-mode)
5539 (> (prefix-numeric-value arg) 0)))
5540 (when gnus-dead-summary-mode
5541 (gnus-add-minor-mode
5542 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5544 (defun gnus-deaden-summary ()
5545 "Make the current summary buffer into a dead summary buffer."
5546 ;; Kill any previous dead summary buffer.
5547 (when (and gnus-dead-summary
5548 (buffer-name gnus-dead-summary))
5550 (set-buffer gnus-dead-summary)
5551 (when gnus-dead-summary-mode
5552 (kill-buffer (current-buffer)))))
5553 ;; Make this the current dead summary.
5554 (setq gnus-dead-summary (current-buffer))
5555 (gnus-dead-summary-mode 1)
5556 (let ((name (buffer-name)))
5557 (when (string-match "Summary" name)
5559 (concat (substring name 0 (match-beginning 0)) "Dead "
5560 (substring name (match-beginning 0)))
5564 (defun gnus-kill-or-deaden-summary (buffer)
5565 "Kill or deaden the summary BUFFER."
5567 (when (and (buffer-name buffer)
5568 (not gnus-single-article-buffer))
5571 (gnus-kill-buffer gnus-article-buffer)
5572 (gnus-kill-buffer gnus-original-article-buffer)))
5573 (cond (gnus-kill-summary-on-exit
5574 (when (and gnus-use-trees
5575 (gnus-buffer-exists-p buffer))
5578 (gnus-tree-close gnus-newsgroup-name)))
5579 (gnus-kill-buffer buffer))
5580 ((gnus-buffer-exists-p buffer)
5583 (gnus-deaden-summary))))))
5585 (defun gnus-summary-wake-up-the-dead (&rest args)
5586 "Wake up the dead summary buffer."
5588 (gnus-dead-summary-mode -1)
5589 (let ((name (buffer-name)))
5590 (when (string-match "Dead " name)
5592 (concat (substring name 0 (match-beginning 0))
5593 (substring name (match-end 0)))
5595 (gnus-message 3 "This dead summary is now alive again"))
5597 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5598 (defun gnus-summary-fetch-faq (&optional faq-dir)
5599 "Fetch the FAQ for the current group.
5600 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5604 (when current-prefix-arg
5606 "Faq dir: " (and (listp gnus-group-faq-directory)
5607 (mapcar (lambda (file) (list file))
5608 gnus-group-faq-directory))))))
5609 (let (gnus-faq-buffer)
5610 (when (setq gnus-faq-buffer
5611 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5612 (gnus-configure-windows 'summary-faq))))
5614 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5615 (defun gnus-summary-describe-group (&optional force)
5616 "Describe the current newsgroup."
5618 (gnus-group-describe-group force gnus-newsgroup-name))
5620 (defun gnus-summary-describe-briefly ()
5621 "Describe summary mode commands briefly."
5623 (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")))
5625 ;; Walking around group mode buffer from summary mode.
5627 (defun gnus-summary-next-group (&optional no-article target-group backward)
5628 "Exit current newsgroup and then select next unread newsgroup.
5629 If prefix argument NO-ARTICLE is non-nil, no article is selected
5630 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5631 previous group instead."
5633 ;; Stop pre-fetching.
5634 (gnus-async-halt-prefetch)
5635 (let ((current-group gnus-newsgroup-name)
5636 (current-buffer (current-buffer))
5638 ;; First we semi-exit this group to update Xrefs and all variables.
5639 ;; We can't do a real exit, because the window conf must remain
5640 ;; the same in case the user is prompted for info, and we don't
5641 ;; want the window conf to change before that...
5642 (gnus-summary-exit t)
5643 (while (not entered)
5644 ;; Then we find what group we are supposed to enter.
5645 (set-buffer gnus-group-buffer)
5646 (gnus-group-jump-to-group current-group)
5649 (if (eq gnus-keep-same-level 'best)
5650 (gnus-summary-best-group gnus-newsgroup-name)
5651 (gnus-summary-search-group backward gnus-keep-same-level))))
5652 (if (not target-group)
5653 ;; There are no further groups, so we return to the group
5656 (gnus-message 5 "Returning to the group buffer")
5658 (when (gnus-buffer-live-p current-buffer)
5659 (set-buffer current-buffer)
5660 (gnus-summary-exit))
5661 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5662 ;; We try to enter the target group.
5663 (gnus-group-jump-to-group target-group)
5664 (let ((unreads (gnus-group-group-unread)))
5665 (if (and (or (eq t unreads)
5666 (and unreads (not (zerop unreads))))
5667 (gnus-summary-read-group
5668 target-group nil no-article
5669 (and (buffer-name current-buffer) current-buffer)
5672 (setq current-group target-group
5673 target-group nil)))))))
5675 (defun gnus-summary-prev-group (&optional no-article)
5676 "Exit current newsgroup and then select previous unread newsgroup.
5677 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5679 (gnus-summary-next-group no-article nil t))
5681 ;; Walking around summary lines.
5683 (defun gnus-summary-first-subject (&optional unread undownloaded)
5684 "Go to the first unread subject.
5685 If UNREAD is non-nil, go to the first unread article.
5686 Returns the article selected or nil if there are no unread articles."
5691 ((null gnus-newsgroup-data)