1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
38 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
40 (defcustom gnus-kill-summary-on-exit t
41 "*If non-nil, kill the summary buffer when you exit from it.
42 If nil, the summary will become a \"*Dead Summary*\" buffer, and
43 it will be killed sometime later."
44 :group 'gnus-summary-exit
47 (defcustom gnus-fetch-old-headers nil
48 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
49 If an unread article in the group refers to an older, already read (or
50 just marked as read) article, the old article will not normally be
51 displayed in the Summary buffer. If this variable is non-nil, Gnus
52 will attempt to grab the headers to the old articles, and thereby
53 build complete threads. If it has the value `some', only enough
54 headers to connect otherwise loose threads will be displayed. This
55 variable can also be a number. In that case, no more than that number
56 of old headers will be fetched. If it has the value `invisible', all
57 old headers will be fetched, but none will be displayed.
59 The server has to support NOV for any of this to work."
61 :type '(choice (const :tag "off" nil)
64 (sexp :menu-tag "other" t)))
66 (defcustom gnus-refer-thread-limit 200
67 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
68 If t, fetch all the available old headers."
71 (sexp :menu-tag "other" t)))
73 (defcustom gnus-summary-make-false-root 'adopt
74 "*nil means that Gnus won't gather loose threads.
75 If the root of a thread has expired or been read in a previous
76 session, the information necessary to build a complete thread has been
77 lost. Instead of having many small sub-threads from this original thread
78 scattered all over the summary buffer, Gnus can gather them.
80 If non-nil, Gnus will try to gather all loose sub-threads from an
81 original thread into one large thread.
83 If this variable is non-nil, it should be one of `none', `adopt',
86 If this variable is `none', Gnus will not make a false root, but just
87 present the sub-threads after another.
88 If this variable is `dummy', Gnus will create a dummy root that will
89 have all the sub-threads as children.
90 If this variable is `adopt', Gnus will make one of the \"children\"
91 the parent and mark all the step-children as such.
92 If this variable is `empty', the \"children\" are printed with empty
93 subject fields. (Or rather, they will be printed with a string
94 given by the `gnus-summary-same-subject' variable.)"
96 :type '(choice (const :tag "off" nil)
102 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
103 "*A regexp to match subjects to be excluded from loose thread gathering.
104 As loose thread gathering is done on subjects only, that means that
105 there can be many false gatherings performed. By rooting out certain
106 common subjects, gathering might become saner."
110 (defcustom gnus-summary-gather-subject-limit nil
111 "*Maximum length of subject comparisons when gathering loose threads.
112 Use nil to compare full subjects. Setting this variable to a low
113 number will help gather threads that have been corrupted by
114 newsreaders chopping off subject lines, but it might also mean that
115 unrelated articles that have subject that happen to begin with the
116 same few characters will be incorrectly gathered.
118 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
121 :type '(choice (const :tag "off" nil)
123 (sexp :menu-tag "on" t)))
125 (defcustom gnus-simplify-subject-functions nil
126 "List of functions taking a string argument that simplify subjects.
127 The functions are applied recursively.
129 Useful functions to put in this list include: `gnus-simplify-subject-re',
130 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :type '(repeat function))
134 (defcustom gnus-simplify-ignored-prefixes nil
135 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :type '(choice (const :tag "off" nil)
140 (defcustom gnus-build-sparse-threads nil
141 "*If non-nil, fill in the gaps in threads.
142 If `some', only fill in the gaps that are needed to tie loose threads
143 together. If `more', fill in all leaf nodes that Gnus can find. If
144 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "all" t)))
151 (defcustom gnus-summary-thread-gathering-function
152 'gnus-gather-threads-by-subject
153 "*Function used for gathering loose threads.
154 There are two pre-defined functions: `gnus-gather-threads-by-subject',
155 which only takes Subjects into consideration; and
156 `gnus-gather-threads-by-references', which compared the References
157 headers of the articles to find matches."
159 :type '(radio (function-item gnus-gather-threads-by-subject)
160 (function-item gnus-gather-threads-by-references)
161 (function :tag "other")))
163 (defcustom gnus-summary-same-subject ""
164 "*String indicating that the current article has the same subject as the previous.
165 This variable will only be used if the value of
166 `gnus-summary-make-false-root' is `empty'."
167 :group 'gnus-summary-format
170 (defcustom gnus-summary-goto-unread t
171 "*If t, marking commands will go to the next unread article.
172 If `never', commands that usually go to the next unread article, will
173 go to the next article, whether it is read or not.
174 If nil, only the marking commands will go to the next (un)read article."
175 :group 'gnus-summary-marks
176 :link '(custom-manual "(gnus)Setting Marks")
177 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "on" t)))
181 (defcustom gnus-summary-default-score 0
182 "*Default article score level.
183 All scores generated by the score files will be added to this score.
184 If this variable is nil, scoring will be disabled."
185 :group 'gnus-score-default
186 :type '(choice (const :tag "disable")
189 (defcustom gnus-summary-zcore-fuzz 0
190 "*Fuzziness factor for the zcore in the summary buffer.
191 Articles with scores closer than this to `gnus-summary-default-score'
193 :group 'gnus-summary-format
196 (defcustom gnus-simplify-subject-fuzzy-regexp nil
197 "*Strings to be removed when doing fuzzy matches.
198 This can either be a regular expression or list of regular expressions
199 that will be removed from subject strings if fuzzy subject
200 simplification is selected."
202 :type '(repeat regexp))
204 (defcustom gnus-show-threads t
205 "*If non-nil, display threads in summary mode."
209 (defcustom gnus-thread-hide-subtree nil
210 "*If non-nil, hide all threads initially.
211 If threads are hidden, you have to run the command
212 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
213 to expose hidden threads."
217 (defcustom gnus-thread-hide-killed t
218 "*If non-nil, hide killed threads automatically."
222 (defcustom gnus-thread-ignore-subject t
223 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
224 If nil, articles that have different subjects from their parents will
225 start separate threads."
229 (defcustom gnus-thread-operation-ignore-subject t
230 "*If non-nil, subjects will be ignored when doing thread commands.
231 This affects commands like `gnus-summary-kill-thread' and
232 `gnus-summary-lower-thread'.
234 If this variable is nil, articles in the same thread with different
235 subjects will not be included in the operation in question. If this
236 variable is `fuzzy', only articles that have subjects that are fuzzily
237 equal will be included."
239 :type '(choice (const :tag "off" nil)
243 (defcustom gnus-thread-indent-level 4
244 "*Number that says how much each sub-thread should be indented."
248 (defcustom gnus-auto-extend-newsgroup t
249 "*If non-nil, extend newsgroup forward and backward when requested."
250 :group 'gnus-summary-choose
253 (defcustom gnus-auto-select-first t
254 "*If nil, don't select the first unread article when entering a group.
255 If this variable is `best', select the highest-scored unread article
256 in the group. If t, select the first unread article.
258 This variable can also be a function to place point on a likely
259 subject line. Useful values include `gnus-summary-first-unread-subject',
260 `gnus-summary-first-unread-article' and
261 `gnus-summary-best-unread-article'.
263 If you want to prevent automatic selection of the first unread article
264 in some newsgroups, set the variable to nil in
265 `gnus-select-group-hook'."
266 :group 'gnus-group-select
267 :type '(choice (const :tag "none" nil)
269 (sexp :menu-tag "first" t)
270 (function-item gnus-summary-first-unread-subject)
271 (function-item gnus-summary-first-unread-article)
272 (function-item gnus-summary-best-unread-article)))
274 (defcustom gnus-auto-select-next t
275 "*If non-nil, offer to go to the next group from the end of the previous.
276 If the value is t and the next newsgroup is empty, Gnus will exit
277 summary mode and go back to group mode. If the value is neither nil
278 nor t, Gnus will select the following unread newsgroup. In
279 particular, if the value is the symbol `quietly', the next unread
280 newsgroup will be selected without any confirmation, and if it is
281 `almost-quietly', the next group will be selected without any
282 confirmation if you are located on the last article in the group.
283 Finally, if this variable is `slightly-quietly', the `Z n' command
284 will go to the next group without confirmation."
285 :group 'gnus-summary-maneuvering
286 :type '(choice (const :tag "off" nil)
288 (const almost-quietly)
289 (const slightly-quietly)
290 (sexp :menu-tag "on" t)))
292 (defcustom gnus-auto-select-same nil
293 "*If non-nil, select the next article with the same subject.
294 If there are no more articles with the same subject, go to
295 the first unread article."
296 :group 'gnus-summary-maneuvering
299 (defcustom gnus-summary-check-current nil
300 "*If non-nil, consider the current article when moving.
301 The \"unread\" movement commands will stay on the same line if the
302 current article is unread."
303 :group 'gnus-summary-maneuvering
306 (defcustom gnus-auto-center-summary t
307 "*If non-nil, always center the current summary buffer.
308 In particular, if `vertical' do only vertical recentering. If non-nil
309 and non-`vertical', do both horizontal and vertical recentering."
310 :group 'gnus-summary-maneuvering
311 :type '(choice (const :tag "none" nil)
313 (integer :tag "height")
314 (sexp :menu-tag "both" t)))
316 (defcustom gnus-show-all-headers nil
317 "*If non-nil, don't hide any headers."
318 :group 'gnus-article-hiding
319 :group 'gnus-article-headers
322 (defcustom gnus-summary-ignore-duplicates nil
323 "*If non-nil, ignore articles with identical Message-ID headers."
327 (defcustom gnus-single-article-buffer t
328 "*If non-nil, display all articles in the same buffer.
329 If nil, each group will get its own article buffer."
330 :group 'gnus-article-various
333 (defcustom gnus-break-pages t
334 "*If non-nil, do page breaking on articles.
335 The page delimiter is specified by the `gnus-page-delimiter'
337 :group 'gnus-article-various
340 (defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342 It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
348 (defcustom gnus-unread-mark ? ;Whitespace
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
353 (defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
358 (defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
363 (defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
368 (defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
373 (defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
378 (defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
383 (defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
388 (defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
393 (defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
398 (defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
403 (defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
408 (defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
413 (defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
418 (defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
423 (defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
428 (defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
433 (defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
438 (defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
443 (defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
448 (defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
453 (defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
458 (defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
463 (defcustom gnus-empty-thread-mark ? ;Whitespace
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
468 (defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
473 (defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
478 (defcustom gnus-auto-expirable-marks
479 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
480 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
481 gnus-souped-mark gnus-duplicate-mark)
482 "*The list of marks converted into expiration if a group is auto-expirable."
484 :type '(repeat character))
486 (defcustom gnus-inhibit-user-auto-expire t
487 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
491 (defcustom gnus-view-pseudos nil
492 "*If `automatic', pseudo-articles will be viewed automatically.
493 If `not-confirm', pseudos will be viewed automatically, and the user
494 will not be asked to confirm the command."
495 :group 'gnus-extract-view
496 :type '(choice (const :tag "off" nil)
498 (const not-confirm)))
500 (defcustom gnus-view-pseudos-separately t
501 "*If non-nil, one pseudo-article will be created for each file to be viewed.
502 If nil, all files that use the same viewing command will be given as a
503 list of parameters to that command."
504 :group 'gnus-extract-view
507 (defcustom gnus-insert-pseudo-articles t
508 "*If non-nil, insert pseudo-articles when decoding articles."
509 :group 'gnus-extract-view
512 (defcustom gnus-summary-dummy-line-format
514 "*The format specification for the dummy roots in the summary buffer.
515 It works along the same lines as a normal formatting string,
516 with some simple extensions.
519 :group 'gnus-threading
522 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
523 "*The format specification for the summary mode line.
524 It works along the same lines as a normal formatting string,
525 with some simple extensions:
528 %p Unprefixed group name
529 %A Current article number
530 %z Current article score
532 %U Number of unread articles in the group
533 %e Number of unselected articles in the group
534 %Z A string with unread/unselected article counts
535 %g Shortish group name
536 %S Subject of the current article
538 %s Current score file name
539 %d Number of dormant articles
540 %r Number of articles that have been marked as read in this session
541 %E Number of articles expunged by the score files"
542 :group 'gnus-summary-format
545 (defcustom gnus-list-identifiers nil
546 "Regexp that matches list identifiers to be removed from subject.
547 This can also be a list of regexps."
548 :group 'gnus-summary-format
549 :group 'gnus-article-hiding
550 :type '(choice (const :tag "none" nil)
552 (repeat :value (".*") regexp)))
554 (defcustom gnus-summary-mark-below 0
555 "*Mark all articles with a score below this variable as read.
556 This variable is local to each summary buffer and usually set by the
558 :group 'gnus-score-default
561 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
562 "*List of functions used for sorting articles in the summary buffer.
563 This variable is only used when not using a threaded display."
564 :group 'gnus-summary-sort
565 :type '(repeat (choice (function-item gnus-article-sort-by-number)
566 (function-item gnus-article-sort-by-author)
567 (function-item gnus-article-sort-by-subject)
568 (function-item gnus-article-sort-by-date)
569 (function-item gnus-article-sort-by-score)
570 (function :tag "other"))))
572 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
573 "*List of functions used for sorting threads in the summary buffer.
574 By default, threads are sorted by article number.
576 Each function takes two threads and return non-nil if the first thread
577 should be sorted before the other. If you use more than one function,
578 the primary sort function should be the last. You should probably
579 always include `gnus-thread-sort-by-number' in the list of sorting
580 functions -- preferably first.
582 Ready-made functions include `gnus-thread-sort-by-number',
583 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
584 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
585 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
586 :group 'gnus-summary-sort
587 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
588 (function-item gnus-thread-sort-by-author)
589 (function-item gnus-thread-sort-by-subject)
590 (function-item gnus-thread-sort-by-date)
591 (function-item gnus-thread-sort-by-score)
592 (function-item gnus-thread-sort-by-total-score)
593 (function :tag "other"))))
595 (defcustom gnus-thread-score-function '+
596 "*Function used for calculating the total score of a thread.
598 The function is called with the scores of the article and each
599 subthread and should then return the score of the thread.
601 Some functions you can use are `+', `max', or `min'."
602 :group 'gnus-summary-sort
605 (defcustom gnus-summary-expunge-below nil
606 "All articles that have a score less than this variable will be expunged.
607 This variable is local to the summary buffers."
608 :group 'gnus-score-default
609 :type '(choice (const :tag "off" nil)
612 (defcustom gnus-thread-expunge-below nil
613 "All threads that have a total score less than this variable will be expunged.
614 See `gnus-thread-score-function' for en explanation of what a
617 This variable is local to the summary buffers."
618 :group 'gnus-threading
619 :group 'gnus-score-default
620 :type '(choice (const :tag "off" nil)
623 (defcustom gnus-summary-mode-hook nil
624 "*A hook for Gnus summary mode.
625 This hook is run before any variables are set in the summary buffer."
626 :group 'gnus-summary-various
629 (defcustom gnus-summary-menu-hook nil
630 "*Hook run after the creation of the summary mode menu."
631 :group 'gnus-summary-visual
634 (defcustom gnus-summary-exit-hook nil
635 "*A hook called on exit from the summary buffer.
636 It will be called with point in the group buffer."
637 :group 'gnus-summary-exit
640 (defcustom gnus-summary-prepare-hook nil
641 "*A hook called after the summary buffer has been generated.
642 If you want to modify the summary buffer, you can use this hook."
643 :group 'gnus-summary-various
646 (defcustom gnus-summary-prepared-hook nil
647 "*A hook called as the last thing after the summary buffer has been generated."
648 :group 'gnus-summary-various
651 (defcustom gnus-summary-generate-hook nil
652 "*A hook run just before generating the summary buffer.
653 This hook is commonly used to customize threading variables and the
655 :group 'gnus-summary-various
658 (defcustom gnus-select-group-hook nil
659 "*A hook called when a newsgroup is selected.
661 If you'd like to simplify subjects like the
662 `gnus-summary-next-same-subject' command does, you can use the
665 (setq gnus-select-group-hook
668 (mapcar (lambda (header)
669 (mail-header-set-subject
671 (gnus-simplify-subject
672 (mail-header-subject header) 're-only)))
673 gnus-newsgroup-headers))))"
674 :group 'gnus-group-select
677 (defcustom gnus-select-article-hook nil
678 "*A hook called when an article is selected."
679 :group 'gnus-summary-choose
682 (defcustom gnus-visual-mark-article-hook
683 (list 'gnus-highlight-selected-summary)
684 "*Hook run after selecting an article in the summary buffer.
685 It is meant to be used for highlighting the article in some way. It
686 is not run if `gnus-visual' is nil."
687 :group 'gnus-summary-visual
690 (defcustom gnus-parse-headers-hook nil
691 "*A hook called before parsing the headers."
695 (defcustom gnus-exit-group-hook nil
696 "*A hook called when exiting (not quitting) summary mode."
700 (defcustom gnus-summary-update-hook
701 (list 'gnus-summary-highlight-line)
702 "*A hook called when a summary line is changed.
703 The hook will not be called if `gnus-visual' is nil.
705 The default function `gnus-summary-highlight-line' will
706 highlight the line according to the `gnus-summary-highlight'
708 :group 'gnus-summary-visual
711 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
712 "*A hook called when an article is selected for the first time.
713 The hook is intended to mark an article as read (or unread)
714 automatically when it is selected."
715 :group 'gnus-summary-choose
718 (defcustom gnus-group-no-more-groups-hook nil
719 "*A hook run when returning to group mode having no more (unread) groups."
720 :group 'gnus-group-select
723 (defcustom gnus-ps-print-hook nil
724 "*A hook run before ps-printing something from Gnus."
728 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
729 "Face used for highlighting the current article in the summary buffer."
730 :group 'gnus-summary-visual
733 (defcustom gnus-summary-highlight
734 '(((= mark gnus-canceled-mark)
735 . gnus-summary-cancelled-face)
736 ((and (> score default)
737 (or (= mark gnus-dormant-mark)
738 (= mark gnus-ticked-mark)))
739 . gnus-summary-high-ticked-face)
740 ((and (< score default)
741 (or (= mark gnus-dormant-mark)
742 (= mark gnus-ticked-mark)))
743 . gnus-summary-low-ticked-face)
744 ((or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark))
746 . gnus-summary-normal-ticked-face)
747 ((and (> score default) (= mark gnus-ancient-mark))
748 . gnus-summary-high-ancient-face)
749 ((and (< score default) (= mark gnus-ancient-mark))
750 . gnus-summary-low-ancient-face)
751 ((= mark gnus-ancient-mark)
752 . gnus-summary-normal-ancient-face)
753 ((and (> score default) (= mark gnus-unread-mark))
754 . gnus-summary-high-unread-face)
755 ((and (< score default) (= mark gnus-unread-mark))
756 . gnus-summary-low-unread-face)
757 ((= mark gnus-unread-mark)
758 . gnus-summary-normal-unread-face)
759 ((and (> score default) (memq mark (list gnus-downloadable-mark
760 gnus-undownloaded-mark)))
761 . gnus-summary-high-unread-face)
762 ((and (< score default) (memq mark (list gnus-downloadable-mark
763 gnus-undownloaded-mark)))
764 . gnus-summary-low-unread-face)
765 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
766 . gnus-summary-normal-unread-face)
768 . gnus-summary-high-read-face)
770 . gnus-summary-low-read-face)
772 . gnus-summary-normal-read-face))
773 "*Controls the highlighting of summary buffer lines.
775 A list of (FORM . FACE) pairs. When deciding how a a particular
776 summary line should be displayed, each form is evaluated. The content
777 of the face field after the first true form is used. You can change
778 how those summary lines are displayed, by editing the face field.
780 You can use the following variables in the FORM field.
782 score: The articles score
783 default: The default article score.
784 below: The score below which articles are automatically marked as read.
785 mark: The articles mark."
786 :group 'gnus-summary-visual
787 :type '(repeat (cons (sexp :tag "Form" nil)
790 (defcustom gnus-alter-header-function nil
791 "Function called to allow alteration of article header structures.
792 The function is called with one parameter, the article header vector,
793 which it may alter in any way.")
795 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
796 "Variable that says which function should be used to decode a string with encoded words.")
798 (defcustom gnus-extra-headers nil
799 "*Extra headers to parse."
801 :type '(repeat symbol))
803 (defcustom gnus-ignored-from-addresses
804 (and user-mail-address (regexp-quote user-mail-address))
805 "*Regexp of From headers that may be suppressed in favor of To headers."
809 (defcustom gnus-group-charset-alist
810 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
811 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
812 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
813 ("^relcom\\>" koi8-r)
815 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
816 ("^israel\\>" iso-8859-1)
818 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
820 "Alist of regexps (to match group names) and default charsets to be used when reading."
821 :type '(repeat (list (regexp :tag "Group")
822 (symbol :tag "Charset")))
823 :group 'gnus-charset)
825 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
826 "List of charsets that should be ignored.
827 When these charsets are used in the \"charset\" parameter, the
828 default charset will be used instead."
829 :type '(repeat symbol)
830 :group 'gnus-charset)
832 (defcustom gnus-group-ignored-charsets-alist
833 '(("alt\\.chinese\\.text" iso-8859-1))
834 "Alist of regexps (to match group names) and charsets that should be ignored.
835 When these charsets are used in the \"charset\" parameter, the
836 default charset will be used instead."
837 :type '(repeat (cons (regexp :tag "Group")
839 :group 'gnus-charset)
841 (defcustom gnus-group-highlight-words-alist nil
842 "Alist of group regexps and highlight regexps.
843 This variable uses the same syntax as `gnus-emphasis-alist'."
844 :type '(repeat (cons (regexp :tag "Group")
845 (repeat (list (regexp :tag "Highlight regexp")
846 (number :tag "Group for entire word" 0)
847 (number :tag "Group for displayed part" 0)
849 gnus-emphasis-highlight-words)))))
850 :group 'gnus-summary-visual)
852 (defcustom gnus-summary-show-article-charset-alist
854 "Alist of number and charset.
855 The article will be shown with the charset corresponding to the
857 For example: ((1 . cn-gb-2312) (2 . big5))."
858 :type '(repeat (cons (number :tag "Argument" 1)
859 (symbol :tag "Charset")))
860 :group 'gnus-charset)
863 ;;; Internal variables
865 (defvar gnus-article-mime-handles nil)
866 (defvar gnus-article-decoded-p nil)
867 (defvar gnus-scores-exclude-files nil)
868 (defvar gnus-page-broken nil)
869 (defvar gnus-inhibit-mime-unbuttonizing nil)
871 (defvar gnus-original-article nil)
872 (defvar gnus-article-internal-prepare-hook nil)
873 (defvar gnus-newsgroup-process-stack nil)
875 (defvar gnus-thread-indent-array nil)
876 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
877 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
878 "Function called to sort the articles within a thread after it has been gathered together.")
880 ;; Avoid highlighting in kill files.
881 (defvar gnus-summary-inhibit-highlight nil)
882 (defvar gnus-newsgroup-selected-overlay nil)
883 (defvar gnus-inhibit-limiting nil)
884 (defvar gnus-newsgroup-adaptive-score-file nil)
885 (defvar gnus-current-score-file nil)
886 (defvar gnus-current-move-group nil)
887 (defvar gnus-current-copy-group nil)
888 (defvar gnus-current-crosspost-group nil)
890 (defvar gnus-newsgroup-dependencies nil)
891 (defvar gnus-newsgroup-adaptive nil)
892 (defvar gnus-summary-display-article-function nil)
893 (defvar gnus-summary-highlight-line-function nil
894 "Function called after highlighting a summary line.")
896 (defvar gnus-summary-line-format-alist
897 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
898 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
899 (?s gnus-tmp-subject-or-nil ?s)
900 (?n gnus-tmp-name ?s)
901 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
903 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
905 (?F gnus-tmp-from ?s)
906 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
907 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
908 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
909 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
910 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
911 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
912 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
913 (?L gnus-tmp-lines ?d)
914 (?I gnus-tmp-indentation ?s)
915 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
916 (?R gnus-tmp-replied ?c)
917 (?\[ gnus-tmp-opening-bracket ?c)
918 (?\] gnus-tmp-closing-bracket ?c)
919 (?\> (make-string gnus-tmp-level ? ) ?s)
920 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
921 (?i gnus-tmp-score ?d)
922 (?z gnus-tmp-score-char ?c)
923 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
924 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
925 (?U gnus-tmp-unread ?c)
926 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
927 (?t (gnus-summary-number-of-articles-in-thread
928 (and (boundp 'thread) (car thread)) gnus-tmp-level)
930 (?e (gnus-summary-number-of-articles-in-thread
931 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
933 (?u gnus-tmp-user-defined ?s)
934 (?P (gnus-pick-line-number) ?d))
935 "An alist of format specifications that can appear in summary lines,
936 and what variables they correspond with, along with the type of the
937 variable (string, integer, character, etc).")
939 (defvar gnus-summary-dummy-line-format-alist
940 `((?S gnus-tmp-subject ?s)
941 (?N gnus-tmp-number ?d)
942 (?u gnus-tmp-user-defined ?s)))
944 (defvar gnus-summary-mode-line-format-alist
945 `((?G gnus-tmp-group-name ?s)
946 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
947 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
948 (?A gnus-tmp-article-number ?d)
949 (?Z gnus-tmp-unread-and-unselected ?s)
951 (?U gnus-tmp-unread-and-unticked ?d)
952 (?S gnus-tmp-subject ?s)
953 (?e gnus-tmp-unselected ?d)
954 (?u gnus-tmp-user-defined ?s)
955 (?d (length gnus-newsgroup-dormant) ?d)
956 (?t (length gnus-newsgroup-marked) ?d)
957 (?r (length gnus-newsgroup-reads) ?d)
958 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
959 (?E gnus-newsgroup-expunged-tally ?d)
960 (?s (gnus-current-score-file-nondirectory) ?s)))
962 (defvar gnus-last-search-regexp nil
963 "Default regexp for article search command.")
965 (defvar gnus-last-shell-command nil
966 "Default shell command on article.")
968 (defvar gnus-newsgroup-begin nil)
969 (defvar gnus-newsgroup-end nil)
970 (defvar gnus-newsgroup-last-rmail nil)
971 (defvar gnus-newsgroup-last-mail nil)
972 (defvar gnus-newsgroup-last-folder nil)
973 (defvar gnus-newsgroup-last-file nil)
974 (defvar gnus-newsgroup-auto-expire nil)
975 (defvar gnus-newsgroup-active nil)
977 (defvar gnus-newsgroup-data nil)
978 (defvar gnus-newsgroup-data-reverse nil)
979 (defvar gnus-newsgroup-limit nil)
980 (defvar gnus-newsgroup-limits nil)
982 (defvar gnus-newsgroup-unreads nil
983 "List of unread articles in the current newsgroup.")
985 (defvar gnus-newsgroup-unselected nil
986 "List of unselected unread articles in the current newsgroup.")
988 (defvar gnus-newsgroup-reads nil
989 "Alist of read articles and article marks in the current newsgroup.")
991 (defvar gnus-newsgroup-expunged-tally nil)
993 (defvar gnus-newsgroup-marked nil
994 "List of ticked articles in the current newsgroup (a subset of unread art).")
996 (defvar gnus-newsgroup-killed nil
997 "List of ranges of articles that have been through the scoring process.")
999 (defvar gnus-newsgroup-cached nil
1000 "List of articles that come from the article cache.")
1002 (defvar gnus-newsgroup-saved nil
1003 "List of articles that have been saved.")
1005 (defvar gnus-newsgroup-kill-headers nil)
1007 (defvar gnus-newsgroup-replied nil
1008 "List of articles that have been replied to in the current newsgroup.")
1010 (defvar gnus-newsgroup-expirable nil
1011 "List of articles in the current newsgroup that can be expired.")
1013 (defvar gnus-newsgroup-processable nil
1014 "List of articles in the current newsgroup that can be processed.")
1016 (defvar gnus-newsgroup-downloadable nil
1017 "List of articles in the current newsgroup that can be processed.")
1019 (defvar gnus-newsgroup-undownloaded nil
1020 "List of articles in the current newsgroup that haven't been downloaded..")
1022 (defvar gnus-newsgroup-unsendable nil
1023 "List of articles in the current newsgroup that won't be sent.")
1025 (defvar gnus-newsgroup-bookmarks nil
1026 "List of articles in the current newsgroup that have bookmarks.")
1028 (defvar gnus-newsgroup-dormant nil
1029 "List of dormant articles in the current newsgroup.")
1031 (defvar gnus-newsgroup-scored nil
1032 "List of scored articles in the current newsgroup.")
1034 (defvar gnus-newsgroup-headers nil
1035 "List of article headers in the current newsgroup.")
1037 (defvar gnus-newsgroup-threads nil)
1039 (defvar gnus-newsgroup-prepared nil
1040 "Whether the current group has been prepared properly.")
1042 (defvar gnus-newsgroup-ancient nil
1043 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1045 (defvar gnus-newsgroup-sparse nil)
1047 (defvar gnus-current-article nil)
1048 (defvar gnus-article-current nil)
1049 (defvar gnus-current-headers nil)
1050 (defvar gnus-have-all-headers nil)
1051 (defvar gnus-last-article nil)
1052 (defvar gnus-newsgroup-history nil)
1053 (defvar gnus-newsgroup-charset nil)
1054 (defvar gnus-newsgroup-ephemeral-charset nil)
1055 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1057 (defconst gnus-summary-local-variables
1058 '(gnus-newsgroup-name
1059 gnus-newsgroup-begin gnus-newsgroup-end
1060 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1061 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1062 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1063 gnus-newsgroup-unselected gnus-newsgroup-marked
1064 gnus-newsgroup-reads gnus-newsgroup-saved
1065 gnus-newsgroup-replied gnus-newsgroup-expirable
1066 gnus-newsgroup-processable gnus-newsgroup-killed
1067 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1068 gnus-newsgroup-unsendable
1069 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1070 gnus-newsgroup-headers gnus-newsgroup-threads
1071 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1072 gnus-current-article gnus-current-headers gnus-have-all-headers
1073 gnus-last-article gnus-article-internal-prepare-hook
1074 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1075 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1076 gnus-thread-expunge-below
1077 gnus-score-alist gnus-current-score-file
1078 (gnus-summary-expunge-below . global)
1079 (gnus-summary-mark-below . global)
1080 gnus-newsgroup-active gnus-scores-exclude-files
1081 gnus-newsgroup-history gnus-newsgroup-ancient
1082 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1083 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1084 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1085 (gnus-newsgroup-expunged-tally . 0)
1086 gnus-cache-removable-articles gnus-newsgroup-cached
1087 gnus-newsgroup-data gnus-newsgroup-data-reverse
1088 gnus-newsgroup-limit gnus-newsgroup-limits
1089 gnus-newsgroup-charset)
1090 "Variables that are buffer-local to the summary buffers.")
1092 ;; Byte-compiler warning.
1093 (defvar gnus-article-mode-map)
1097 (defvar gnus-decode-encoded-word-methods
1098 '(mail-decode-encoded-word-string)
1099 "List of methods used to decode encoded words.
1101 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1102 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1103 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1104 whose names match REGEXP.
1107 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1108 mail-decode-encoded-word-string
1109 (\"chinese\" . rfc1843-decode-string))
1112 (defvar gnus-decode-encoded-word-methods-cache nil)
1114 (defun gnus-multi-decode-encoded-word-string (string)
1115 "Apply the functions from `gnus-encoded-word-methods' that match."
1116 (unless (and gnus-decode-encoded-word-methods-cache
1117 (eq gnus-newsgroup-name
1118 (car gnus-decode-encoded-word-methods-cache)))
1119 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1122 (nconc gnus-decode-encoded-word-methods-cache (list x))
1123 (if (and gnus-newsgroup-name
1124 (string-match (car x) gnus-newsgroup-name))
1125 (nconc gnus-decode-encoded-word-methods-cache
1127 gnus-decode-encoded-word-methods))
1128 (let ((xlist gnus-decode-encoded-word-methods-cache))
1131 (setq string (funcall (pop xlist) string))))
1134 ;; Subject simplification.
1136 (defun gnus-simplify-whitespace (str)
1137 "Remove excessive whitespace."
1140 (while (string-match "[ \t][ \t]+" mystr)
1141 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1143 (substring mystr (match-end 0)))))
1145 (when (string-match "^[ \t]+" mystr)
1146 (setq mystr (substring mystr (match-end 0))))
1148 (when (string-match "[ \t]+$" mystr)
1149 (setq mystr (substring mystr 0 (match-beginning 0))))
1152 (defsubst gnus-simplify-subject-re (subject)
1153 "Remove \"Re:\" from subject lines."
1154 (if (string-match "^[Rr][Ee]: *" subject)
1155 (substring subject (match-end 0))
1158 (defun gnus-simplify-subject (subject &optional re-only)
1159 "Remove `Re:' and words in parentheses.
1160 If RE-ONLY is non-nil, strip leading `Re:'s only."
1161 (let ((case-fold-search t)) ;Ignore case.
1162 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1163 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1164 (setq subject (substring subject (match-end 0))))
1165 ;; Remove uninteresting prefixes.
1166 (when (and (not re-only)
1167 gnus-simplify-ignored-prefixes
1168 (string-match gnus-simplify-ignored-prefixes subject))
1169 (setq subject (substring subject (match-end 0))))
1170 ;; Remove words in parentheses from end.
1172 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1173 (setq subject (substring subject 0 (match-beginning 0)))))
1174 ;; Return subject string.
1177 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1179 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1180 (goto-char (point-min))
1181 (while (re-search-forward regexp nil t)
1182 (replace-match (or newtext ""))))
1184 (defun gnus-simplify-buffer-fuzzy ()
1185 "Simplify string in the buffer fuzzily.
1186 The string in the accessible portion of the current buffer is simplified.
1187 It is assumed to be a single-line subject.
1188 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1189 matter is removed. Additional things can be deleted by setting
1190 gnus-simplify-subject-fuzzy-regexp."
1191 (let ((case-fold-search t)
1193 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1195 (while (not (eq modified-tick (buffer-modified-tick)))
1196 (setq modified-tick (buffer-modified-tick))
1198 ((listp gnus-simplify-subject-fuzzy-regexp)
1199 (mapcar 'gnus-simplify-buffer-fuzzy-step
1200 gnus-simplify-subject-fuzzy-regexp))
1201 (gnus-simplify-subject-fuzzy-regexp
1202 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1203 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1204 (gnus-simplify-buffer-fuzzy-step
1205 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1206 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1208 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1209 (gnus-simplify-buffer-fuzzy-step " +" " ")
1210 (gnus-simplify-buffer-fuzzy-step " $")
1211 (gnus-simplify-buffer-fuzzy-step "^ +")))
1213 (defun gnus-simplify-subject-fuzzy (subject)
1214 "Simplify a subject string fuzzily.
1215 See `gnus-simplify-buffer-fuzzy' for details."
1217 (gnus-set-work-buffer)
1218 (let ((case-fold-search t))
1219 ;; Remove uninteresting prefixes.
1220 (when (and gnus-simplify-ignored-prefixes
1221 (string-match gnus-simplify-ignored-prefixes subject))
1222 (setq subject (substring subject (match-end 0))))
1224 (inline (gnus-simplify-buffer-fuzzy))
1227 (defsubst gnus-simplify-subject-fully (subject)
1228 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1230 (gnus-simplify-subject-functions
1231 (gnus-map-function gnus-simplify-subject-functions subject))
1232 ((null gnus-summary-gather-subject-limit)
1233 (gnus-simplify-subject-re subject))
1234 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1235 (gnus-simplify-subject-fuzzy subject))
1236 ((numberp gnus-summary-gather-subject-limit)
1237 (gnus-limit-string (gnus-simplify-subject-re subject)
1238 gnus-summary-gather-subject-limit))
1242 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1243 "Check whether two subjects are equal.
1244 If optional argument simple-first is t, first argument is already
1247 ((null simple-first)
1248 (equal (gnus-simplify-subject-fully s1)
1249 (gnus-simplify-subject-fully s2)))
1252 (gnus-simplify-subject-fully s2)))))
1254 (defun gnus-summary-bubble-group ()
1255 "Increase the score of the current group.
1256 This is a handy function to add to `gnus-summary-exit-hook' to
1257 increase the score of each group you read."
1258 (gnus-group-add-score gnus-newsgroup-name))
1262 ;;; Gnus summary mode
1265 (put 'gnus-summary-mode 'mode-class 'special)
1268 ;; Non-orthogonal keys
1270 (gnus-define-keys gnus-summary-mode-map
1271 " " gnus-summary-next-page
1272 "\177" gnus-summary-prev-page
1273 [delete] gnus-summary-prev-page
1274 [backspace] gnus-summary-prev-page
1275 "\r" gnus-summary-scroll-up
1276 "\M-\r" gnus-summary-scroll-down
1277 "n" gnus-summary-next-unread-article
1278 "p" gnus-summary-prev-unread-article
1279 "N" gnus-summary-next-article
1280 "P" gnus-summary-prev-article
1281 "\M-\C-n" gnus-summary-next-same-subject
1282 "\M-\C-p" gnus-summary-prev-same-subject
1283 "\M-n" gnus-summary-next-unread-subject
1284 "\M-p" gnus-summary-prev-unread-subject
1285 "." gnus-summary-first-unread-article
1286 "," gnus-summary-best-unread-article
1287 "\M-s" gnus-summary-search-article-forward
1288 "\M-r" gnus-summary-search-article-backward
1289 "<" gnus-summary-beginning-of-article
1290 ">" gnus-summary-end-of-article
1291 "j" gnus-summary-goto-article
1292 "^" gnus-summary-refer-parent-article
1293 "\M-^" gnus-summary-refer-article
1294 "u" gnus-summary-tick-article-forward
1295 "!" gnus-summary-tick-article-forward
1296 "U" gnus-summary-tick-article-backward
1297 "d" gnus-summary-mark-as-read-forward
1298 "D" gnus-summary-mark-as-read-backward
1299 "E" gnus-summary-mark-as-expirable
1300 "\M-u" gnus-summary-clear-mark-forward
1301 "\M-U" gnus-summary-clear-mark-backward
1302 "k" gnus-summary-kill-same-subject-and-select
1303 "\C-k" gnus-summary-kill-same-subject
1304 "\M-\C-k" gnus-summary-kill-thread
1305 "\M-\C-l" gnus-summary-lower-thread
1306 "e" gnus-summary-edit-article
1307 "#" gnus-summary-mark-as-processable
1308 "\M-#" gnus-summary-unmark-as-processable
1309 "\M-\C-t" gnus-summary-toggle-threads
1310 "\M-\C-s" gnus-summary-show-thread
1311 "\M-\C-h" gnus-summary-hide-thread
1312 "\M-\C-f" gnus-summary-next-thread
1313 "\M-\C-b" gnus-summary-prev-thread
1314 "\M-\C-u" gnus-summary-up-thread
1315 "\M-\C-d" gnus-summary-down-thread
1316 "&" gnus-summary-execute-command
1317 "c" gnus-summary-catchup-and-exit
1318 "\C-w" gnus-summary-mark-region-as-read
1319 "\C-t" gnus-summary-toggle-truncation
1320 "?" gnus-summary-mark-as-dormant
1321 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1322 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1323 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1324 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1325 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1326 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1327 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1328 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1329 "=" gnus-summary-expand-window
1330 "\C-x\C-s" gnus-summary-reselect-current-group
1331 "\M-g" gnus-summary-rescan-group
1332 "w" gnus-summary-stop-page-breaking
1333 "\C-c\C-r" gnus-summary-caesar-message
1334 "f" gnus-summary-followup
1335 "F" gnus-summary-followup-with-original
1336 "C" gnus-summary-cancel-article
1337 "r" gnus-summary-reply
1338 "R" gnus-summary-reply-with-original
1339 "\C-c\C-f" gnus-summary-mail-forward
1340 "o" gnus-summary-save-article
1341 "\C-o" gnus-summary-save-article-mail
1342 "|" gnus-summary-pipe-output
1343 "\M-k" gnus-summary-edit-local-kill
1344 "\M-K" gnus-summary-edit-global-kill
1346 "\C-c\C-d" gnus-summary-describe-group
1347 "q" gnus-summary-exit
1348 "Q" gnus-summary-exit-no-update
1349 "\C-c\C-i" gnus-info-find-node
1350 gnus-mouse-2 gnus-mouse-pick-article
1351 "m" gnus-summary-mail-other-window
1352 "a" gnus-summary-post-news
1353 "x" gnus-summary-limit-to-unread
1354 "s" gnus-summary-isearch-article
1355 "t" gnus-summary-toggle-header
1356 "g" gnus-summary-show-article
1357 "l" gnus-summary-goto-last-article
1358 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1359 "\C-d" gnus-summary-enter-digest-group
1360 "\M-\C-d" gnus-summary-read-document
1361 "\M-\C-e" gnus-summary-edit-parameters
1362 "\M-\C-g" gnus-summary-customize-parameters
1364 "*" gnus-cache-enter-article
1365 "\M-*" gnus-cache-remove-article
1366 "\M-&" gnus-summary-universal-argument
1367 "\C-l" gnus-recenter
1368 "I" gnus-summary-increase-score
1369 "L" gnus-summary-lower-score
1370 "\M-i" gnus-symbolic-argument
1371 "h" gnus-summary-select-article-buffer
1373 "b" gnus-article-view-part
1374 "\M-t" gnus-summary-toggle-display-buttonized
1376 "V" gnus-summary-score-map
1377 "X" gnus-uu-extract-map
1378 "S" gnus-summary-send-map)
1380 ;; Sort of orthogonal keymap
1381 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1382 "t" gnus-summary-tick-article-forward
1383 "!" gnus-summary-tick-article-forward
1384 "d" gnus-summary-mark-as-read-forward
1385 "r" gnus-summary-mark-as-read-forward
1386 "c" gnus-summary-clear-mark-forward
1387 " " gnus-summary-clear-mark-forward
1388 "e" gnus-summary-mark-as-expirable
1389 "x" gnus-summary-mark-as-expirable
1390 "?" gnus-summary-mark-as-dormant
1391 "b" gnus-summary-set-bookmark
1392 "B" gnus-summary-remove-bookmark
1393 "#" gnus-summary-mark-as-processable
1394 "\M-#" gnus-summary-unmark-as-processable
1395 "S" gnus-summary-limit-include-expunged
1396 "C" gnus-summary-catchup
1397 "H" gnus-summary-catchup-to-here
1398 "\C-c" gnus-summary-catchup-all
1399 "k" gnus-summary-kill-same-subject-and-select
1400 "K" gnus-summary-kill-same-subject
1401 "P" gnus-uu-mark-map)
1403 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1404 "c" gnus-summary-clear-above
1405 "u" gnus-summary-tick-above
1406 "m" gnus-summary-mark-above
1407 "k" gnus-summary-kill-below)
1409 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1410 "/" gnus-summary-limit-to-subject
1411 "n" gnus-summary-limit-to-articles
1412 "w" gnus-summary-pop-limit
1413 "s" gnus-summary-limit-to-subject
1414 "a" gnus-summary-limit-to-author
1415 "u" gnus-summary-limit-to-unread
1416 "m" gnus-summary-limit-to-marks
1417 "M" gnus-summary-limit-exclude-marks
1418 "v" gnus-summary-limit-to-score
1419 "*" gnus-summary-limit-include-cached
1420 "D" gnus-summary-limit-include-dormant
1421 "T" gnus-summary-limit-include-thread
1422 "d" gnus-summary-limit-exclude-dormant
1423 "t" gnus-summary-limit-to-age
1424 "x" gnus-summary-limit-to-extra
1425 "E" gnus-summary-limit-include-expunged
1426 "c" gnus-summary-limit-exclude-childless-dormant
1427 "C" gnus-summary-limit-mark-excluded-as-read)
1429 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1430 "n" gnus-summary-next-unread-article
1431 "p" gnus-summary-prev-unread-article
1432 "N" gnus-summary-next-article
1433 "P" gnus-summary-prev-article
1434 "\C-n" gnus-summary-next-same-subject
1435 "\C-p" gnus-summary-prev-same-subject
1436 "\M-n" gnus-summary-next-unread-subject
1437 "\M-p" gnus-summary-prev-unread-subject
1438 "f" gnus-summary-first-unread-article
1439 "b" gnus-summary-best-unread-article
1440 "j" gnus-summary-goto-article
1441 "g" gnus-summary-goto-subject
1442 "l" gnus-summary-goto-last-article
1443 "o" gnus-summary-pop-article)
1445 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1446 "k" gnus-summary-kill-thread
1447 "l" gnus-summary-lower-thread
1448 "i" gnus-summary-raise-thread
1449 "T" gnus-summary-toggle-threads
1450 "t" gnus-summary-rethread-current
1451 "^" gnus-summary-reparent-thread
1452 "s" gnus-summary-show-thread
1453 "S" gnus-summary-show-all-threads
1454 "h" gnus-summary-hide-thread
1455 "H" gnus-summary-hide-all-threads
1456 "n" gnus-summary-next-thread
1457 "p" gnus-summary-prev-thread
1458 "u" gnus-summary-up-thread
1459 "o" gnus-summary-top-thread
1460 "d" gnus-summary-down-thread
1461 "#" gnus-uu-mark-thread
1462 "\M-#" gnus-uu-unmark-thread)
1464 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1465 "g" gnus-summary-prepare
1466 "c" gnus-summary-insert-cached-articles)
1468 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1469 "c" gnus-summary-catchup-and-exit
1470 "C" gnus-summary-catchup-all-and-exit
1471 "E" gnus-summary-exit-no-update
1472 "Q" gnus-summary-exit
1473 "Z" gnus-summary-exit
1474 "n" gnus-summary-catchup-and-goto-next-group
1475 "R" gnus-summary-reselect-current-group
1476 "G" gnus-summary-rescan-group
1477 "N" gnus-summary-next-group
1478 "s" gnus-summary-save-newsrc
1479 "P" gnus-summary-prev-group)
1481 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1482 " " gnus-summary-next-page
1483 "n" gnus-summary-next-page
1484 "\177" gnus-summary-prev-page
1485 [delete] gnus-summary-prev-page
1486 "p" gnus-summary-prev-page
1487 "\r" gnus-summary-scroll-up
1488 "\M-\r" gnus-summary-scroll-down
1489 "<" gnus-summary-beginning-of-article
1490 ">" gnus-summary-end-of-article
1491 "b" gnus-summary-beginning-of-article
1492 "e" gnus-summary-end-of-article
1493 "^" gnus-summary-refer-parent-article
1494 "r" gnus-summary-refer-parent-article
1495 "D" gnus-summary-enter-digest-group
1496 "R" gnus-summary-refer-references
1497 "T" gnus-summary-refer-thread
1498 "g" gnus-summary-show-article
1499 "s" gnus-summary-isearch-article
1500 "P" gnus-summary-print-article
1501 "t" gnus-article-babel)
1503 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1504 "b" gnus-article-add-buttons
1505 "B" gnus-article-add-buttons-to-head
1506 "o" gnus-article-treat-overstrike
1507 "e" gnus-article-emphasize
1508 "w" gnus-article-fill-cited-article
1509 "Q" gnus-article-fill-long-lines
1510 "C" gnus-article-capitalize-sentences
1511 "c" gnus-article-remove-cr
1512 "q" gnus-article-de-quoted-unreadable
1513 "f" gnus-article-display-x-face
1514 "l" gnus-summary-stop-page-breaking
1515 "r" gnus-summary-caesar-message
1516 "t" gnus-article-hide-headers
1517 "v" gnus-summary-verbose-headers
1518 "H" gnus-article-strip-headers-in-body
1519 "d" gnus-article-treat-dumbquotes)
1521 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1522 "a" gnus-article-hide
1523 "h" gnus-article-hide-headers
1524 "b" gnus-article-hide-boring-headers
1525 "s" gnus-article-hide-signature
1526 "c" gnus-article-hide-citation
1527 "C" gnus-article-hide-citation-in-followups
1528 "l" gnus-article-hide-list-identifiers
1529 "p" gnus-article-hide-pgp
1530 "B" gnus-article-strip-banner
1531 "P" gnus-article-hide-pem
1532 "\C-c" gnus-article-hide-citation-maybe)
1534 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1535 "a" gnus-article-highlight
1536 "h" gnus-article-highlight-headers
1537 "c" gnus-article-highlight-citation
1538 "s" gnus-article-highlight-signature)
1540 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1541 "w" gnus-article-decode-mime-words
1542 "c" gnus-article-decode-charset
1543 "v" gnus-mime-view-all-parts
1544 "b" gnus-article-view-part)
1546 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1547 "z" gnus-article-date-ut
1548 "u" gnus-article-date-ut
1549 "l" gnus-article-date-local
1550 "e" gnus-article-date-lapsed
1551 "o" gnus-article-date-original
1552 "i" gnus-article-date-iso8601
1553 "s" gnus-article-date-user)
1555 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1556 "t" gnus-article-remove-trailing-blank-lines
1557 "l" gnus-article-strip-leading-blank-lines
1558 "m" gnus-article-strip-multiple-blank-lines
1559 "a" gnus-article-strip-blank-lines
1560 "A" gnus-article-strip-all-blank-lines
1561 "s" gnus-article-strip-leading-space
1562 "e" gnus-article-strip-trailing-space)
1564 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1566 "f" gnus-summary-fetch-faq
1567 "d" gnus-summary-describe-group
1568 "h" gnus-summary-describe-briefly
1569 "i" gnus-info-find-node)
1571 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1572 "e" gnus-summary-expire-articles
1573 "\M-\C-e" gnus-summary-expire-articles-now
1574 "\177" gnus-summary-delete-article
1575 [delete] gnus-summary-delete-article
1576 [backspace] gnus-summary-delete-article
1577 "m" gnus-summary-move-article
1578 "r" gnus-summary-respool-article
1579 "w" gnus-summary-edit-article
1580 "c" gnus-summary-copy-article
1581 "B" gnus-summary-crosspost-article
1582 "q" gnus-summary-respool-query
1583 "t" gnus-summary-respool-trace
1584 "i" gnus-summary-import-article
1585 "p" gnus-summary-article-posted-p)
1587 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1588 "o" gnus-summary-save-article
1589 "m" gnus-summary-save-article-mail
1590 "F" gnus-summary-write-article-file
1591 "r" gnus-summary-save-article-rmail
1592 "f" gnus-summary-save-article-file
1593 "b" gnus-summary-save-article-body-file
1594 "h" gnus-summary-save-article-folder
1595 "v" gnus-summary-save-article-vm
1596 "p" gnus-summary-pipe-output
1597 "s" gnus-soup-add-article)
1599 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1600 "b" gnus-summary-display-buttonized
1601 "m" gnus-summary-repair-multipart
1602 "v" gnus-article-view-part
1603 "o" gnus-article-save-part
1604 "c" gnus-article-copy-part
1605 "e" gnus-article-externalize-part
1606 "i" gnus-article-inline-part
1607 "|" gnus-article-pipe-part))
1609 (defun gnus-summary-make-menu-bar ()
1610 (gnus-turn-off-edit-menu 'summary)
1612 (unless (boundp 'gnus-summary-misc-menu)
1615 gnus-summary-kill-menu gnus-summary-mode-map ""
1620 ["Enter score..." gnus-summary-score-entry t]
1621 ["Customize" gnus-score-customize t])
1622 (gnus-make-score-map 'increase)
1623 (gnus-make-score-map 'lower)
1625 ["Kill below" gnus-summary-kill-below t]
1626 ["Mark above" gnus-summary-mark-above t]
1627 ["Tick above" gnus-summary-tick-above t]
1628 ["Clear above" gnus-summary-clear-above t])
1629 ["Current score" gnus-summary-current-score t]
1630 ["Set score" gnus-summary-set-score t]
1631 ["Switch current score file..." gnus-score-change-score-file t]
1632 ["Set mark below..." gnus-score-set-mark-below t]
1633 ["Set expunge below..." gnus-score-set-expunge-below t]
1634 ["Edit current score file" gnus-score-edit-current-scores t]
1635 ["Edit score file" gnus-score-edit-file t]
1636 ["Trace score" gnus-score-find-trace t]
1637 ["Find words" gnus-score-find-favourite-words t]
1638 ["Rescore buffer" gnus-summary-rescore t]
1639 ["Increase score..." gnus-summary-increase-score t]
1640 ["Lower score..." gnus-summary-lower-score t]))))
1642 ;; Define both the Article menu in the summary buffer and the equivalent
1643 ;; Commands menu in the article buffer here for consistency.
1646 ["All" gnus-article-hide t]
1647 ["Headers" gnus-article-hide-headers t]
1648 ["Signature" gnus-article-hide-signature t]
1649 ["Citation" gnus-article-hide-citation t]
1650 ["List identifiers" gnus-article-hide-list-identifiers t]
1651 ["PGP" gnus-article-hide-pgp t]
1652 ["Banner" gnus-article-strip-banner t]
1653 ["Boring headers" gnus-article-hide-boring-headers t])
1655 ["All" gnus-article-highlight t]
1656 ["Headers" gnus-article-highlight-headers t]
1657 ["Signature" gnus-article-highlight-signature t]
1658 ["Citation" gnus-article-highlight-citation t])
1660 ["Words" gnus-article-decode-mime-words t]
1661 ["Charset" gnus-article-decode-charset t]
1662 ["QP" gnus-article-de-quoted-unreadable t]
1663 ["View all" gnus-mime-view-all-parts t])
1665 ["Local" gnus-article-date-local t]
1666 ["ISO8601" gnus-article-date-iso8601 t]
1667 ["UT" gnus-article-date-ut t]
1668 ["Original" gnus-article-date-original t]
1669 ["Lapsed" gnus-article-date-lapsed t]
1670 ["User-defined" gnus-article-date-user t])
1673 ["Leading" gnus-article-strip-leading-blank-lines t]
1674 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1675 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1676 ["All of the above" gnus-article-strip-blank-lines t]
1677 ["All" gnus-article-strip-all-blank-lines t]
1678 ["Leading space" gnus-article-strip-leading-space t]
1679 ["Trailing space" gnus-article-strip-trailing-space t])
1680 ["Overstrike" gnus-article-treat-overstrike t]
1681 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1682 ["Emphasis" gnus-article-emphasize t]
1683 ["Word wrap" gnus-article-fill-cited-article t]
1684 ["Fill long lines" gnus-article-fill-long-lines t]
1685 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1686 ["CR" gnus-article-remove-cr t]
1687 ["Show X-Face" gnus-article-display-x-face t]
1688 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1689 ["Rot 13" gnus-summary-caesar-message t]
1690 ["Unix pipe" gnus-summary-pipe-message t]
1691 ["Add buttons" gnus-article-add-buttons t]
1692 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1693 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1694 ["Verbose header" gnus-summary-verbose-headers t]
1695 ["Toggle header" gnus-summary-toggle-header t]
1696 ["HZ" gnus-article-decode-HZ t])
1698 ["Save in default format" gnus-summary-save-article t]
1699 ["Save in file" gnus-summary-save-article-file t]
1700 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1701 ["Save in MH folder" gnus-summary-save-article-folder t]
1702 ["Save in VM folder" gnus-summary-save-article-vm t]
1703 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1704 ["Save body in file" gnus-summary-save-article-body-file t]
1705 ["Pipe through a filter" gnus-summary-pipe-output t]
1706 ["Add to SOUP packet" gnus-soup-add-article t]
1707 ["Print" gnus-summary-print-article t])
1709 ["Respool article..." gnus-summary-respool-article t]
1710 ["Move article..." gnus-summary-move-article
1711 (gnus-check-backend-function
1712 'request-move-article gnus-newsgroup-name)]
1713 ["Copy article..." gnus-summary-copy-article t]
1714 ["Crosspost article..." gnus-summary-crosspost-article
1715 (gnus-check-backend-function
1716 'request-replace-article gnus-newsgroup-name)]
1717 ["Import file..." gnus-summary-import-article t]
1718 ["Check if posted" gnus-summary-article-posted-p t]
1719 ["Edit article" gnus-summary-edit-article
1720 (not (gnus-group-read-only-p))]
1721 ["Delete article" gnus-summary-delete-article
1722 (gnus-check-backend-function
1723 'request-expire-articles gnus-newsgroup-name)]
1724 ["Query respool" gnus-summary-respool-query t]
1725 ["Trace respool" gnus-summary-respool-trace t]
1726 ["Delete expirable articles" gnus-summary-expire-articles-now
1727 (gnus-check-backend-function
1728 'request-expire-articles gnus-newsgroup-name)])
1730 ["Uudecode" gnus-uu-decode-uu t]
1731 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1732 ["Unshar" gnus-uu-decode-unshar t]
1733 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1734 ["Save" gnus-uu-decode-save t]
1735 ["Binhex" gnus-uu-decode-binhex t]
1736 ["Postscript" gnus-uu-decode-postscript t])
1738 ["Enter article" gnus-cache-enter-article t]
1739 ["Remove article" gnus-cache-remove-article t])
1740 ["Translate" gnus-article-babel t]
1741 ["Select article buffer" gnus-summary-select-article-buffer t]
1742 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1743 ["Isearch article..." gnus-summary-isearch-article t]
1744 ["Beginning of the article" gnus-summary-beginning-of-article t]
1745 ["End of the article" gnus-summary-end-of-article t]
1746 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1747 ["Fetch referenced articles" gnus-summary-refer-references t]
1748 ["Fetch current thread" gnus-summary-refer-thread t]
1749 ["Fetch article with id..." gnus-summary-refer-article t]
1750 ["Redisplay" gnus-summary-show-article t])))
1752 gnus-summary-article-menu gnus-summary-mode-map ""
1753 (cons "Article" innards))
1756 gnus-article-commands-menu gnus-article-mode-map ""
1757 (cons "Commands" innards)))
1760 gnus-summary-thread-menu gnus-summary-mode-map ""
1762 ["Toggle threading" gnus-summary-toggle-threads t]
1763 ["Hide threads" gnus-summary-hide-all-threads t]
1764 ["Show threads" gnus-summary-show-all-threads t]
1765 ["Hide thread" gnus-summary-hide-thread t]
1766 ["Show thread" gnus-summary-show-thread t]
1767 ["Go to next thread" gnus-summary-next-thread t]
1768 ["Go to previous thread" gnus-summary-prev-thread t]
1769 ["Go down thread" gnus-summary-down-thread t]
1770 ["Go up thread" gnus-summary-up-thread t]
1771 ["Top of thread" gnus-summary-top-thread t]
1772 ["Mark thread as read" gnus-summary-kill-thread t]
1773 ["Lower thread score" gnus-summary-lower-thread t]
1774 ["Raise thread score" gnus-summary-raise-thread t]
1775 ["Rethread current" gnus-summary-rethread-current t]))
1778 gnus-summary-post-menu gnus-summary-mode-map ""
1780 ["Post an article" gnus-summary-post-news t]
1781 ["Followup" gnus-summary-followup t]
1782 ["Followup and yank" gnus-summary-followup-with-original t]
1783 ["Supersede article" gnus-summary-supersede-article t]
1784 ["Cancel article" gnus-summary-cancel-article t]
1785 ["Reply" gnus-summary-reply t]
1786 ["Reply and yank" gnus-summary-reply-with-original t]
1787 ["Wide reply" gnus-summary-wide-reply t]
1788 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1789 ["Mail forward" gnus-summary-mail-forward t]
1790 ["Post forward" gnus-summary-post-forward t]
1791 ["Digest and mail" gnus-uu-digest-mail-forward t]
1792 ["Digest and post" gnus-uu-digest-post-forward t]
1793 ["Resend message" gnus-summary-resend-message t]
1794 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1795 ["Send a mail" gnus-summary-mail-other-window t]
1796 ["Uuencode and post" gnus-uu-post-news t]
1797 ["Followup via news" gnus-summary-followup-to-mail t]
1798 ["Followup via news and yank"
1799 gnus-summary-followup-to-mail-with-original t]
1801 ;;["Send" gnus-summary-send-draft t]
1802 ;;["Send bounced" gnus-resend-bounced-mail t])
1806 gnus-summary-misc-menu gnus-summary-mode-map ""
1809 ["Mark as read" gnus-summary-mark-as-read-forward t]
1810 ["Mark same subject and select"
1811 gnus-summary-kill-same-subject-and-select t]
1812 ["Mark same subject" gnus-summary-kill-same-subject t]
1813 ["Catchup" gnus-summary-catchup t]
1814 ["Catchup all" gnus-summary-catchup-all t]
1815 ["Catchup to here" gnus-summary-catchup-to-here t]
1816 ["Catchup region" gnus-summary-mark-region-as-read t]
1817 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1819 ["Tick" gnus-summary-tick-article-forward t]
1820 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1821 ["Remove marks" gnus-summary-clear-mark-forward t]
1822 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1823 ["Set bookmark" gnus-summary-set-bookmark t]
1824 ["Remove bookmark" gnus-summary-remove-bookmark t])
1826 ["Marks..." gnus-summary-limit-to-marks t]
1827 ["Subject..." gnus-summary-limit-to-subject t]
1828 ["Author..." gnus-summary-limit-to-author t]
1829 ["Age..." gnus-summary-limit-to-age t]
1830 ["Extra..." gnus-summary-limit-to-extra t]
1831 ["Score" gnus-summary-limit-to-score t]
1832 ["Unread" gnus-summary-limit-to-unread t]
1833 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1834 ["Articles" gnus-summary-limit-to-articles t]
1835 ["Pop limit" gnus-summary-pop-limit t]
1836 ["Show dormant" gnus-summary-limit-include-dormant t]
1837 ["Hide childless dormant"
1838 gnus-summary-limit-exclude-childless-dormant t]
1839 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1840 ["Hide marked" gnus-summary-limit-exclude-marks t]
1841 ["Show expunged" gnus-summary-show-all-expunged t])
1843 ["Set mark" gnus-summary-mark-as-processable t]
1844 ["Remove mark" gnus-summary-unmark-as-processable t]
1845 ["Remove all marks" gnus-summary-unmark-all-processable t]
1846 ["Mark above" gnus-uu-mark-over t]
1847 ["Mark series" gnus-uu-mark-series t]
1848 ["Mark region" gnus-uu-mark-region t]
1849 ["Unmark region" gnus-uu-unmark-region t]
1850 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1851 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1852 ["Mark all" gnus-uu-mark-all t]
1853 ["Mark buffer" gnus-uu-mark-buffer t]
1854 ["Mark sparse" gnus-uu-mark-sparse t]
1855 ["Mark thread" gnus-uu-mark-thread t]
1856 ["Unmark thread" gnus-uu-unmark-thread t]
1857 ("Process Mark Sets"
1858 ["Kill" gnus-summary-kill-process-mark t]
1859 ["Yank" gnus-summary-yank-process-mark
1860 gnus-newsgroup-process-stack]
1861 ["Save" gnus-summary-save-process-mark t]))
1863 ["Page forward" gnus-summary-next-page t]
1864 ["Page backward" gnus-summary-prev-page t]
1865 ["Line forward" gnus-summary-scroll-up t])
1867 ["Next unread article" gnus-summary-next-unread-article t]
1868 ["Previous unread article" gnus-summary-prev-unread-article t]
1869 ["Next article" gnus-summary-next-article t]
1870 ["Previous article" gnus-summary-prev-article t]
1871 ["Next unread subject" gnus-summary-next-unread-subject t]
1872 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1873 ["Next article same subject" gnus-summary-next-same-subject t]
1874 ["Previous article same subject" gnus-summary-prev-same-subject t]
1875 ["First unread article" gnus-summary-first-unread-article t]
1876 ["Best unread article" gnus-summary-best-unread-article t]
1877 ["Go to subject number..." gnus-summary-goto-subject t]
1878 ["Go to article number..." gnus-summary-goto-article t]
1879 ["Go to the last article" gnus-summary-goto-last-article t]
1880 ["Pop article off history" gnus-summary-pop-article t])
1882 ["Sort by number" gnus-summary-sort-by-number t]
1883 ["Sort by author" gnus-summary-sort-by-author t]
1884 ["Sort by subject" gnus-summary-sort-by-subject t]
1885 ["Sort by date" gnus-summary-sort-by-date t]
1886 ["Sort by score" gnus-summary-sort-by-score t]
1887 ["Sort by lines" gnus-summary-sort-by-lines t]
1888 ["Sort by characters" gnus-summary-sort-by-chars t])
1890 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1891 ["Describe group" gnus-summary-describe-group t]
1892 ["Read manual" gnus-info-find-node t])
1894 ["Pick and read" gnus-pick-mode t]
1895 ["Binary" gnus-binary-mode t])
1897 ["Regenerate" gnus-summary-prepare t]
1898 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1899 ["Toggle threading" gnus-summary-toggle-threads t])
1900 ["Filter articles..." gnus-summary-execute-command t]
1901 ["Run command on subjects..." gnus-summary-universal-argument t]
1902 ["Search articles forward..." gnus-summary-search-article-forward t]
1903 ["Search articles backward..." gnus-summary-search-article-backward t]
1904 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1905 ["Expand window" gnus-summary-expand-window t]
1906 ["Expire expirable articles" gnus-summary-expire-articles
1907 (gnus-check-backend-function
1908 'request-expire-articles gnus-newsgroup-name)]
1909 ["Edit local kill file" gnus-summary-edit-local-kill t]
1910 ["Edit main kill file" gnus-summary-edit-global-kill t]
1911 ["Edit group parameters" gnus-summary-edit-parameters t]
1912 ["Customize group parameters" gnus-summary-customize-parameters t]
1913 ["Send a bug report" gnus-bug t]
1915 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1916 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1917 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1918 ["Exit group" gnus-summary-exit t]
1919 ["Exit group without updating" gnus-summary-exit-no-update t]
1920 ["Exit and goto next group" gnus-summary-next-group t]
1921 ["Exit and goto prev group" gnus-summary-prev-group t]
1922 ["Reselect group" gnus-summary-reselect-current-group t]
1923 ["Rescan group" gnus-summary-rescan-group t]
1924 ["Update dribble" gnus-summary-save-newsrc t])))
1926 (gnus-run-hooks 'gnus-summary-menu-hook)))
1928 (defun gnus-score-set-default (var value)
1929 "A version of set that updates the GNU Emacs menu-bar."
1931 ;; It is the message that forces the active status to be updated.
1934 (defun gnus-make-score-map (type)
1935 "Make a summary score map of type TYPE."
1938 (let ((headers '(("author" "from" string)
1939 ("subject" "subject" string)
1940 ("article body" "body" string)
1941 ("article head" "head" string)
1942 ("xref" "xref" string)
1943 ("extra header" "extra" string)
1944 ("lines" "lines" number)
1945 ("followups to author" "followup" string)))
1946 (types '((number ("less than" <)
1949 (string ("substring" s)
1953 (perms '(("temporary" (current-time-string))
1961 (if (eq type 'lower)
1966 (setq header (car headers))
1972 (let ((ts (cdr (assoc (nth 2 header) types)))
1988 'gnus-summary-score-entry
1990 (if (or (string= (nth 1 header)
1992 (string= (nth 1 header)
1995 (list 'gnus-summary-header
1997 (list 'quote (nth 1 (car ts)))
1998 (list 'gnus-score-default nil)
2004 (list (nreverse outp))))
2007 (list (nreverse outt))))
2009 (setq headers (cdr headers)))
2010 (list (nreverse outh))))))))
2014 (defun gnus-summary-mode (&optional group)
2015 "Major mode for reading articles.
2017 All normal editing commands are switched off.
2018 \\<gnus-summary-mode-map>
2019 Each line in this buffer represents one article. To read an
2020 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2021 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2024 You can also post articles and send mail from this buffer. To
2025 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2026 of an article, type `\\[gnus-summary-reply]'.
2028 There are approx. one gazillion commands you can execute in this
2029 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2031 The following commands are available:
2033 \\{gnus-summary-mode-map}"
2035 (when (gnus-visual-p 'summary-menu 'menu)
2036 (gnus-summary-make-menu-bar))
2037 (kill-all-local-variables)
2038 (gnus-summary-make-local-variables)
2039 (gnus-make-thread-indent-array)
2040 (gnus-simplify-mode-line)
2041 (setq major-mode 'gnus-summary-mode)
2042 (setq mode-name "Summary")
2043 (make-local-variable 'minor-mode-alist)
2044 (use-local-map gnus-summary-mode-map)
2045 (buffer-disable-undo)
2046 (setq buffer-read-only t) ;Disable modification
2047 (setq truncate-lines t)
2048 (setq selective-display t)
2049 (setq selective-display-ellipses t) ;Display `...'
2050 (gnus-summary-set-display-table)
2051 (gnus-set-default-directory)
2052 (setq gnus-newsgroup-name group)
2053 (make-local-variable 'gnus-summary-line-format)
2054 (make-local-variable 'gnus-summary-line-format-spec)
2055 (make-local-variable 'gnus-summary-dummy-line-format)
2056 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2057 (make-local-variable 'gnus-summary-mark-positions)
2058 (make-local-hook 'pre-command-hook)
2059 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2060 (gnus-run-hooks 'gnus-summary-mode-hook)
2061 (mm-enable-multibyte)
2062 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2063 (gnus-update-summary-mark-positions))
2065 (defun gnus-summary-make-local-variables ()
2066 "Make all the local summary buffer variables."
2068 (dolist (local gnus-summary-local-variables)
2071 (if (eq (cdr local) 'global)
2072 ;; Copy the global value of the variable.
2073 (setq global (symbol-value (car local)))
2074 ;; Use the value from the list.
2075 (setq global (eval (cdr local))))
2076 (set (make-local-variable (car local)) global))
2077 ;; Simple nil-valued local variable.
2078 (set (make-local-variable local) nil)))))
2080 (defun gnus-summary-clear-local-variables ()
2081 (let ((locals gnus-summary-local-variables))
2083 (if (consp (car locals))
2084 (and (vectorp (caar locals))
2085 (set (caar locals) nil))
2086 (and (vectorp (car locals))
2087 (set (car locals) nil)))
2088 (setq locals (cdr locals)))))
2090 ;; Summary data functions.
2092 (defmacro gnus-data-number (data)
2095 (defmacro gnus-data-set-number (data number)
2096 `(setcar ,data ,number))
2098 (defmacro gnus-data-mark (data)
2101 (defmacro gnus-data-set-mark (data mark)
2102 `(setcar (nthcdr 1 ,data) ,mark))
2104 (defmacro gnus-data-pos (data)
2107 (defmacro gnus-data-set-pos (data pos)
2108 `(setcar (nthcdr 2 ,data) ,pos))
2110 (defmacro gnus-data-header (data)
2113 (defmacro gnus-data-set-header (data header)
2114 `(setf (nth 3 ,data) ,header))
2116 (defmacro gnus-data-level (data)
2119 (defmacro gnus-data-unread-p (data)
2120 `(= (nth 1 ,data) gnus-unread-mark))
2122 (defmacro gnus-data-read-p (data)
2123 `(/= (nth 1 ,data) gnus-unread-mark))
2125 (defmacro gnus-data-pseudo-p (data)
2126 `(consp (nth 3 ,data)))
2128 (defmacro gnus-data-find (number)
2129 `(assq ,number gnus-newsgroup-data))
2131 (defmacro gnus-data-find-list (number &optional data)
2132 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2133 (memq (assq ,number bdata)
2136 (defmacro gnus-data-make (number mark pos header level)
2137 `(list ,number ,mark ,pos ,header ,level))
2139 (defun gnus-data-enter (after-article number mark pos header level offset)
2140 (let ((data (gnus-data-find-list after-article)))
2142 (error "No such article: %d" after-article))
2143 (setcdr data (cons (gnus-data-make number mark pos header level)
2145 (setq gnus-newsgroup-data-reverse nil)
2146 (gnus-data-update-list (cddr data) offset)))
2148 (defun gnus-data-enter-list (after-article list &optional offset)
2150 (let ((data (and after-article (gnus-data-find-list after-article)))
2154 (let ((odata gnus-newsgroup-data))
2155 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2157 (gnus-data-update-list odata offset)))
2158 ;; Find the last element in the list to be spliced into the main
2161 (setq list (cdr list)))
2164 (setcdr list gnus-newsgroup-data)
2165 (setq gnus-newsgroup-data ilist)
2167 (gnus-data-update-list (cdr list) offset)))
2168 (setcdr list (cdr data))
2171 (gnus-data-update-list (cdr list) offset))))
2172 (setq gnus-newsgroup-data-reverse nil))))
2174 (defun gnus-data-remove (article &optional offset)
2175 (let ((data gnus-newsgroup-data))
2176 (if (= (gnus-data-number (car data)) article)
2178 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2179 gnus-newsgroup-data-reverse nil)
2181 (gnus-data-update-list gnus-newsgroup-data offset)))
2183 (when (= (gnus-data-number (cadr data)) article)
2184 (setcdr data (cddr data))
2186 (gnus-data-update-list (cdr data) offset))
2188 gnus-newsgroup-data-reverse nil))
2189 (setq data (cdr data))))))
2191 (defmacro gnus-data-list (backward)
2193 (or gnus-newsgroup-data-reverse
2194 (setq gnus-newsgroup-data-reverse
2195 (reverse gnus-newsgroup-data)))
2196 gnus-newsgroup-data))
2198 (defun gnus-data-update-list (data offset)
2199 "Add OFFSET to the POS of all data entries in DATA."
2200 (setq gnus-newsgroup-data-reverse nil)
2202 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2203 (setq data (cdr data))))
2205 (defun gnus-summary-article-pseudo-p (article)
2206 "Say whether this article is a pseudo article or not."
2207 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2209 (defmacro gnus-summary-article-sparse-p (article)
2210 "Say whether this article is a sparse article or not."
2211 `(memq ,article gnus-newsgroup-sparse))
2213 (defmacro gnus-summary-article-ancient-p (article)
2214 "Say whether this article is a sparse article or not."
2215 `(memq ,article gnus-newsgroup-ancient))
2217 (defun gnus-article-parent-p (number)
2218 "Say whether this article is a parent or not."
2219 (let ((data (gnus-data-find-list number)))
2220 (and (cdr data) ; There has to be an article after...
2221 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2222 (gnus-data-level (nth 1 data))))))
2224 (defun gnus-article-children (number)
2225 "Return a list of all children to NUMBER."
2226 (let* ((data (gnus-data-find-list number))
2227 (level (gnus-data-level (car data)))
2229 (setq data (cdr data))
2231 (= (gnus-data-level (car data)) (1+ level)))
2232 (push (gnus-data-number (car data)) children)
2233 (setq data (cdr data)))
2236 (defmacro gnus-summary-skip-intangible ()
2237 "If the current article is intangible, then jump to a different article."
2238 '(let ((to (get-text-property (point) 'gnus-intangible)))
2239 (and to (gnus-summary-goto-subject to))))
2241 (defmacro gnus-summary-article-intangible-p ()
2242 "Say whether this article is intangible or not."
2243 '(get-text-property (point) 'gnus-intangible))
2245 (defun gnus-article-read-p (article)
2246 "Say whether ARTICLE is read or not."
2247 (not (or (memq article gnus-newsgroup-marked)
2248 (memq article gnus-newsgroup-unreads)
2249 (memq article gnus-newsgroup-unselected)
2250 (memq article gnus-newsgroup-dormant))))
2252 ;; Some summary mode macros.
2254 (defmacro gnus-summary-article-number ()
2255 "The article number of the article on the current line.
2256 If there isn's an article number here, then we return the current
2259 (gnus-summary-skip-intangible)
2260 (or (get-text-property (point) 'gnus-number)
2261 (gnus-summary-last-subject))))
2263 (defmacro gnus-summary-article-header (&optional number)
2264 "Return the header of article NUMBER."
2265 `(gnus-data-header (gnus-data-find
2266 ,(or number '(gnus-summary-article-number)))))
2268 (defmacro gnus-summary-thread-level (&optional number)
2269 "Return the level of thread that starts with article NUMBER."
2270 `(if (and (eq gnus-summary-make-false-root 'dummy)
2271 (get-text-property (point) 'gnus-intangible))
2273 (gnus-data-level (gnus-data-find
2274 ,(or number '(gnus-summary-article-number))))))
2276 (defmacro gnus-summary-article-mark (&optional number)
2277 "Return the mark of article NUMBER."
2278 `(gnus-data-mark (gnus-data-find
2279 ,(or number '(gnus-summary-article-number)))))
2281 (defmacro gnus-summary-article-pos (&optional number)
2282 "Return the position of the line of article NUMBER."
2283 `(gnus-data-pos (gnus-data-find
2284 ,(or number '(gnus-summary-article-number)))))
2286 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2287 (defmacro gnus-summary-article-subject (&optional number)
2288 "Return current subject string or nil if nothing."
2291 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2292 '(gnus-data-header (assq (gnus-summary-article-number)
2293 gnus-newsgroup-data)))))
2296 (mail-header-subject headers))))
2298 (defmacro gnus-summary-article-score (&optional number)
2299 "Return current article score."
2300 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2301 gnus-newsgroup-scored))
2302 gnus-summary-default-score 0))
2304 (defun gnus-summary-article-children (&optional number)
2305 "Return a list of article numbers that are children of article NUMBER."
2306 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2307 (level (gnus-data-level (car data)))
2309 (while (and (setq data (cdr data))
2310 (> (setq l (gnus-data-level (car data))) level))
2311 (and (= (1+ level) l)
2312 (push (gnus-data-number (car data))
2314 (nreverse children)))
2316 (defun gnus-summary-article-parent (&optional number)
2317 "Return the article number of the parent of article NUMBER."
2318 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2319 (gnus-data-list t)))
2320 (level (gnus-data-level (car data))))
2322 () ; This is a root.
2323 ;; We search until we find an article with a level less than
2324 ;; this one. That function has to be the parent.
2325 (while (and (setq data (cdr data))
2326 (not (< (gnus-data-level (car data)) level))))
2327 (and data (gnus-data-number (car data))))))
2329 (defun gnus-unread-mark-p (mark)
2330 "Say whether MARK is the unread mark."
2331 (= mark gnus-unread-mark))
2333 (defun gnus-read-mark-p (mark)
2334 "Say whether MARK is one of the marks that mark as read.
2335 This is all marks except unread, ticked, dormant, and expirable."
2336 (not (or (= mark gnus-unread-mark)
2337 (= mark gnus-ticked-mark)
2338 (= mark gnus-dormant-mark)
2339 (= mark gnus-expirable-mark))))
2341 (defmacro gnus-article-mark (number)
2342 "Return the MARK of article NUMBER.
2343 This macro should only be used when computing the mark the \"first\"
2344 time; i.e., when generating the summary lines. After that,
2345 `gnus-summary-article-mark' should be used to examine the
2348 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2349 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2350 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2351 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2352 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2353 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2354 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2355 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2356 gnus-ancient-mark))))
2358 ;; Saving hidden threads.
2360 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2361 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2363 (defmacro gnus-save-hidden-threads (&rest forms)
2364 "Save hidden threads, eval FORMS, and restore the hidden threads."
2365 (let ((config (make-symbol "config")))
2366 `(let ((,config (gnus-hidden-threads-configuration)))
2370 (gnus-restore-hidden-threads-configuration ,config)))))
2372 (defun gnus-data-compute-positions ()
2373 "Compute the positions of all articles."
2374 (setq gnus-newsgroup-data-reverse nil)
2375 (let ((data gnus-newsgroup-data))
2377 (gnus-save-hidden-threads
2378 (gnus-summary-show-all-threads)
2379 (goto-char (point-min))
2381 (while (get-text-property (point) 'gnus-intangible)
2383 (gnus-data-set-pos (car data) (+ (point) 3))
2384 (setq data (cdr data))
2385 (forward-line 1))))))
2387 (defun gnus-hidden-threads-configuration ()
2388 "Return the current hidden threads configuration."
2391 (goto-char (point-min))
2392 (while (search-forward "\r" nil t)
2393 (push (1- (point)) config))
2396 (defun gnus-restore-hidden-threads-configuration (config)
2397 "Restore hidden threads configuration from CONFIG."
2398 (let (point buffer-read-only)
2399 (while (setq point (pop config))
2400 (when (and (< point (point-max))
2402 (eq (char-after) ?\n))
2403 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2405 ;; Various summary mode internalish functions.
2407 (defun gnus-mouse-pick-article (e)
2410 (gnus-summary-next-page nil t))
2412 (defun gnus-summary-set-display-table ()
2413 ;; Change the display table. Odd characters have a tendency to mess
2414 ;; up nicely formatted displays - we make all possible glyphs
2415 ;; display only a single character.
2417 ;; We start from the standard display table, if any.
2418 (let ((table (or (copy-sequence standard-display-table)
2419 (make-display-table)))
2421 ;; Nix out all the control chars...
2422 (while (>= (setq i (1- i)) 0)
2423 (aset table i [??]))
2424 ;; ... but not newline and cr, of course. (cr is necessary for the
2425 ;; selective display).
2426 (aset table ?\n nil)
2427 (aset table ?\r nil)
2428 ;; We keep TAB as well.
2429 (aset table ?\t nil)
2430 ;; We nix out any glyphs over 126 that are not set already.
2432 (while (>= (setq i (1- i)) 127)
2433 ;; Only modify if the entry is nil.
2434 (unless (aref table i)
2435 (aset table i [??]))))
2436 (setq buffer-display-table table)))
2438 (defun gnus-summary-setup-buffer (group)
2439 "Initialize summary buffer."
2440 (let ((buffer (concat "*Summary " group "*")))
2441 (if (get-buffer buffer)
2444 (setq gnus-summary-buffer (current-buffer))
2445 (not gnus-newsgroup-prepared))
2446 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2447 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2448 (gnus-summary-mode group)
2450 (gnus-carpal-setup-buffer 'summary))
2451 (unless gnus-single-article-buffer
2452 (make-local-variable 'gnus-article-buffer)
2453 (make-local-variable 'gnus-article-current)
2454 (make-local-variable 'gnus-original-article-buffer))
2455 (setq gnus-newsgroup-name group)
2458 (defun gnus-set-global-variables ()
2459 ;; Set the global equivalents of the summary buffer-local variables
2460 ;; to the latest values they had. These reflect the summary buffer
2461 ;; that was in action when the last article was fetched.
2462 (when (eq major-mode 'gnus-summary-mode)
2463 (setq gnus-summary-buffer (current-buffer))
2464 (let ((name gnus-newsgroup-name)
2465 (marked gnus-newsgroup-marked)
2466 (unread gnus-newsgroup-unreads)
2467 (headers gnus-current-headers)
2468 (data gnus-newsgroup-data)
2469 (summary gnus-summary-buffer)
2470 (article-buffer gnus-article-buffer)
2471 (original gnus-original-article-buffer)
2472 (gac gnus-article-current)
2473 (reffed gnus-reffed-article-number)
2474 (score-file gnus-current-score-file)
2475 (default-charset gnus-newsgroup-charset))
2477 (set-buffer gnus-group-buffer)
2478 (setq gnus-newsgroup-name name
2479 gnus-newsgroup-marked marked
2480 gnus-newsgroup-unreads unread
2481 gnus-current-headers headers
2482 gnus-newsgroup-data data
2483 gnus-article-current gac
2484 gnus-summary-buffer summary
2485 gnus-article-buffer article-buffer
2486 gnus-original-article-buffer original
2487 gnus-reffed-article-number reffed
2488 gnus-current-score-file score-file
2489 gnus-newsgroup-charset default-charset)
2490 ;; The article buffer also has local variables.
2491 (when (gnus-buffer-live-p gnus-article-buffer)
2492 (set-buffer gnus-article-buffer)
2493 (setq gnus-summary-buffer summary))))))
2495 (defun gnus-summary-article-unread-p (article)
2496 "Say whether ARTICLE is unread or not."
2497 (memq article gnus-newsgroup-unreads))
2499 (defun gnus-summary-first-article-p (&optional article)
2500 "Return whether ARTICLE is the first article in the buffer."
2501 (if (not (setq article (or article (gnus-summary-article-number))))
2503 (eq article (caar gnus-newsgroup-data))))
2505 (defun gnus-summary-last-article-p (&optional article)
2506 "Return whether ARTICLE is the last article in the buffer."
2507 (if (not (setq article (or article (gnus-summary-article-number))))
2508 ;; All non-existent numbers are the last article. :-)
2510 (not (cdr (gnus-data-find-list article)))))
2512 (defun gnus-make-thread-indent-array ()
2514 (unless (and gnus-thread-indent-array
2515 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2516 (setq gnus-thread-indent-array (make-vector 201 "")
2517 gnus-thread-indent-array-level gnus-thread-indent-level)
2519 (aset gnus-thread-indent-array n
2520 (make-string (* n gnus-thread-indent-level) ? ))
2523 (defun gnus-update-summary-mark-positions ()
2524 "Compute where the summary marks are to go."
2526 (when (gnus-buffer-exists-p gnus-summary-buffer)
2527 (set-buffer gnus-summary-buffer))
2528 (let ((gnus-replied-mark 129)
2529 (gnus-score-below-mark 130)
2530 (gnus-score-over-mark 130)
2531 (gnus-download-mark 131)
2532 (spec gnus-summary-line-format-spec)
2535 (gnus-set-work-buffer)
2536 (let ((gnus-summary-line-format-spec spec)
2537 (gnus-newsgroup-downloadable '((0 . t))))
2538 (gnus-summary-insert-line
2539 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2540 (goto-char (point-min))
2541 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2543 (goto-char (point-min))
2544 (push (cons 'replied (and (search-forward "\201" nil t)
2547 (goto-char (point-min))
2548 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2550 (goto-char (point-min))
2551 (push (cons 'download
2552 (and (search-forward "\203" nil t) (- (point) 2)))
2554 (setq gnus-summary-mark-positions pos))))
2556 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2557 "Insert a dummy root in the summary buffer."
2559 (gnus-add-text-properties
2560 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2561 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2563 (defun gnus-summary-from-or-to-or-newsgroups (header)
2564 (let ((to (cdr (assq 'To (mail-header-extra header))))
2565 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2566 (mail-parse-charset gnus-newsgroup-charset)
2567 (mail-parse-ignored-charsets
2568 (save-excursion (set-buffer gnus-summary-buffer)
2569 gnus-newsgroup-ignored-charsets)))
2572 gnus-ignored-from-addresses
2573 (string-match gnus-ignored-from-addresses
2574 (mail-header-from header)))
2576 (or (car (funcall gnus-extract-address-components
2578 gnus-decode-encoded-word-function to)))
2579 (funcall gnus-decode-encoded-word-function to))))
2581 gnus-ignored-from-addresses
2582 (string-match gnus-ignored-from-addresses
2583 (mail-header-from header)))
2584 (concat "=> " newsgroups))
2586 (or (car (funcall gnus-extract-address-components
2587 (mail-header-from header)))
2588 (mail-header-from header))))))
2590 (defun gnus-summary-insert-line (gnus-tmp-header
2591 gnus-tmp-level gnus-tmp-current
2592 gnus-tmp-unread gnus-tmp-replied
2593 gnus-tmp-expirable gnus-tmp-subject-or-nil
2594 &optional gnus-tmp-dummy gnus-tmp-score
2596 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2597 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2598 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2599 (gnus-tmp-score-char
2600 (if (or (null gnus-summary-default-score)
2601 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2602 gnus-summary-zcore-fuzz))
2604 (if (< gnus-tmp-score gnus-summary-default-score)
2605 gnus-score-below-mark gnus-score-over-mark)))
2607 (cond (gnus-tmp-process gnus-process-mark)
2608 ((memq gnus-tmp-current gnus-newsgroup-cached)
2610 (gnus-tmp-replied gnus-replied-mark)
2611 ((memq gnus-tmp-current gnus-newsgroup-saved)
2613 (t gnus-unread-mark)))
2614 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2617 ((string-match "<[^>]+> *$" gnus-tmp-from)
2618 (let ((beg (match-beginning 0)))
2619 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2620 (substring gnus-tmp-from (1+ (match-beginning 0))
2621 (1- (match-end 0))))
2622 (substring gnus-tmp-from 0 beg))))
2623 ((string-match "(.+)" gnus-tmp-from)
2624 (substring gnus-tmp-from
2625 (1+ (match-beginning 0)) (1- (match-end 0))))
2627 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2628 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2629 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2630 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2631 (buffer-read-only nil))
2632 (when (string= gnus-tmp-name "")
2633 (setq gnus-tmp-name gnus-tmp-from))
2634 (unless (numberp gnus-tmp-lines)
2635 (setq gnus-tmp-lines 0))
2636 (gnus-put-text-property
2638 (progn (eval gnus-summary-line-format-spec) (point))
2639 'gnus-number gnus-tmp-number)
2640 (when (gnus-visual-p 'summary-highlight 'highlight)
2642 (gnus-run-hooks 'gnus-summary-update-hook)
2645 (defun gnus-summary-update-line (&optional dont-update)
2646 ;; Update summary line after change.
2647 (when (and gnus-summary-default-score
2648 (not gnus-summary-inhibit-highlight))
2649 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2650 (article (gnus-summary-article-number))
2651 (score (gnus-summary-article-score article)))
2653 (if (and gnus-summary-mark-below
2654 (< (gnus-summary-article-score)
2655 gnus-summary-mark-below))
2656 ;; This article has a low score, so we mark it as read.
2657 (when (memq article gnus-newsgroup-unreads)
2658 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2659 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2660 ;; This article was previously marked as read on account
2661 ;; of a low score, but now it has risen, so we mark it as
2663 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2664 (gnus-summary-update-mark
2665 (if (or (null gnus-summary-default-score)
2666 (<= (abs (- score gnus-summary-default-score))
2667 gnus-summary-zcore-fuzz))
2669 (if (< score gnus-summary-default-score)
2670 gnus-score-below-mark gnus-score-over-mark))
2672 ;; Do visual highlighting.
2673 (when (gnus-visual-p 'summary-highlight 'highlight)
2674 (gnus-run-hooks 'gnus-summary-update-hook)))))
2676 (defvar gnus-tmp-new-adopts nil)
2678 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2679 "Return the number of articles in THREAD.
2680 This may be 0 in some cases -- if none of the articles in
2681 the thread are to be displayed."
2683 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2685 ((not (listp thread))
2687 ((and (consp thread) (cdr thread))
2690 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2693 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2696 (when (and level (zerop level) gnus-tmp-new-adopts)
2699 'gnus-summary-number-of-articles-in-thread
2700 gnus-tmp-new-adopts))))
2702 (if (> number 1) gnus-not-empty-thread-mark
2703 gnus-empty-thread-mark)
2706 (defun gnus-summary-set-local-parameters (group)
2707 "Go through the local params of GROUP and set all variable specs in that list."
2708 (let ((params (gnus-group-find-parameter group))
2711 (setq elem (car params)
2712 params (cdr params))
2713 (and (consp elem) ; Has to be a cons.
2714 (consp (cdr elem)) ; The cdr has to be a list.
2715 (symbolp (car elem)) ; Has to be a symbol in there.
2716 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2717 (ignore-errors ; So we set it.
2718 (make-local-variable (car elem))
2719 (set (car elem) (eval (nth 1 elem))))))))
2721 (defun gnus-summary-read-group (group &optional show-all no-article
2722 kill-buffer no-display backward
2724 "Start reading news in newsgroup GROUP.
2725 If SHOW-ALL is non-nil, already read articles are also listed.
2726 If NO-ARTICLE is non-nil, no article is selected initially.
2727 If NO-DISPLAY, don't generate a summary buffer."
2731 (let ((gnus-auto-select-next nil))
2732 (or (gnus-summary-read-group-1
2733 group show-all no-article
2734 kill-buffer no-display
2737 select-articles nil)))))
2738 (eq gnus-auto-select-next 'quietly))
2739 (set-buffer gnus-group-buffer)
2740 ;; The entry function called above goes to the next
2741 ;; group automatically, so we go two groups back
2742 ;; if we are searching for the previous group.
2744 (gnus-group-prev-unread-group 2))
2745 (if (not (equal group (gnus-group-group-name)))
2746 (setq group (gnus-group-group-name))
2750 (defun gnus-summary-read-group-1 (group show-all no-article
2751 kill-buffer no-display
2752 &optional select-articles)
2753 ;; Killed foreign groups can't be entered.
2754 (when (and (not (gnus-group-native-p group))
2755 (not (gnus-gethash group gnus-newsrc-hashtb)))
2756 (error "Dead non-native groups can't be entered"))
2757 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2758 (let* ((new-group (gnus-summary-setup-buffer group))
2759 (quit-config (gnus-group-quit-config group))
2760 (did-select (and new-group (gnus-select-newsgroup
2761 group show-all select-articles))))
2763 ;; This summary buffer exists already, so we just select it.
2765 (gnus-set-global-variables)
2767 (gnus-kill-or-deaden-summary kill-buffer))
2768 (gnus-configure-windows 'summary 'force)
2769 (gnus-set-mode-line 'summary)
2770 (gnus-summary-position-point)
2773 ;; We couldn't select this group.
2775 (when (and (eq major-mode 'gnus-summary-mode)
2776 (not (equal (current-buffer) kill-buffer)))
2777 (kill-buffer (current-buffer))
2778 (if (not quit-config)
2780 ;; Update the info -- marks might need to be removed,
2782 (gnus-summary-update-info)
2783 (set-buffer gnus-group-buffer)
2784 (gnus-group-jump-to-group group)
2785 (gnus-group-next-unread-group 1))
2786 (gnus-handle-ephemeral-exit quit-config)))
2787 (gnus-message 3 "Can't select group")
2789 ;; The user did a `C-g' while prompting for number of articles,
2790 ;; so we exit this group.
2791 ((eq did-select 'quit)
2792 (and (eq major-mode 'gnus-summary-mode)
2793 (not (equal (current-buffer) kill-buffer))
2794 (kill-buffer (current-buffer)))
2796 (gnus-kill-or-deaden-summary kill-buffer))
2797 (if (not quit-config)
2799 (set-buffer gnus-group-buffer)
2800 (gnus-group-jump-to-group group)
2801 (gnus-group-next-unread-group 1)
2802 (gnus-configure-windows 'group 'force))
2803 (gnus-handle-ephemeral-exit quit-config))
2804 ;; Finally signal the quit.
2806 ;; The group was successfully selected.
2808 (gnus-set-global-variables)
2809 ;; Save the active value in effect when the group was entered.
2810 (setq gnus-newsgroup-active
2812 (gnus-active gnus-newsgroup-name)))
2813 ;; You can change the summary buffer in some way with this hook.
2814 (gnus-run-hooks 'gnus-select-group-hook)
2815 ;; Set any local variables in the group parameters.
2816 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2817 (gnus-update-format-specifications
2818 nil 'summary 'summary-mode 'summary-dummy)
2819 (gnus-update-summary-mark-positions)
2820 ;; Do score processing.
2821 (when gnus-use-scoring
2822 (gnus-possibly-score-headers))
2823 ;; Check whether to fill in the gaps in the threads.
2824 (when gnus-build-sparse-threads
2825 (gnus-build-sparse-threads))
2826 ;; Find the initial limit.
2827 (if gnus-show-threads
2829 (let ((gnus-newsgroup-dormant nil))
2830 (gnus-summary-initial-limit show-all))
2831 (gnus-summary-initial-limit show-all))
2832 ;; When untreaded, all articles are always shown.
2833 (setq gnus-newsgroup-limit
2835 (lambda (header) (mail-header-number header))
2836 gnus-newsgroup-headers)))
2837 ;; Generate the summary buffer.
2839 (gnus-summary-prepare))
2840 (when gnus-use-trees
2841 (gnus-tree-open group)
2842 (setq gnus-summary-highlight-line-function
2843 'gnus-tree-highlight-article))
2844 ;; If the summary buffer is empty, but there are some low-scored
2845 ;; articles or some excluded dormants, we include these in the
2847 (when (and (zerop (buffer-size))
2849 (cond (gnus-newsgroup-dormant
2850 (gnus-summary-limit-include-dormant))
2851 ((and gnus-newsgroup-scored show-all)
2852 (gnus-summary-limit-include-expunged t))))
2853 ;; Function `gnus-apply-kill-file' must be called in this hook.
2854 (gnus-run-hooks 'gnus-apply-kill-hook)
2855 (if (and (zerop (buffer-size))
2858 ;; This newsgroup is empty.
2859 (gnus-summary-catchup-and-exit nil t)
2860 (gnus-message 6 "No unread news")
2862 (gnus-kill-or-deaden-summary kill-buffer))
2863 ;; Return nil from this function.
2865 ;; Hide conversation thread subtrees. We cannot do this in
2866 ;; gnus-summary-prepare-hook since kill processing may not
2867 ;; work with hidden articles.
2868 (and gnus-show-threads
2869 gnus-thread-hide-subtree
2870 (gnus-summary-hide-all-threads))
2872 (gnus-kill-or-deaden-summary kill-buffer))
2873 ;; Show first unread article if requested.
2874 (if (and (not no-article)
2876 gnus-newsgroup-unreads
2877 gnus-auto-select-first)
2879 (gnus-configure-windows 'summary)
2881 ((eq gnus-auto-select-first 'best)
2882 (gnus-summary-best-unread-article))
2883 ((eq gnus-auto-select-first t)
2884 (gnus-summary-first-unread-article))
2885 ((gnus-functionp gnus-auto-select-first)
2886 (funcall gnus-auto-select-first))))
2887 ;; Don't select any articles, just move point to the first
2888 ;; article in the group.
2889 (goto-char (point-min))
2890 (gnus-summary-position-point)
2891 (gnus-configure-windows 'summary 'force)
2892 (gnus-set-mode-line 'summary))
2893 (when (get-buffer-window gnus-group-buffer t)
2894 ;; Gotta use windows, because recenter does weird stuff if
2895 ;; the current buffer ain't the displayed window.
2896 (let ((owin (selected-window)))
2897 (select-window (get-buffer-window gnus-group-buffer t))
2898 (when (gnus-group-goto-group group)
2900 (select-window owin)))
2901 ;; Mark this buffer as "prepared".
2902 (setq gnus-newsgroup-prepared t)
2903 (gnus-run-hooks 'gnus-summary-prepared-hook)
2906 (defun gnus-summary-prepare ()
2907 "Generate the summary buffer."
2909 (let ((buffer-read-only nil))
2911 (setq gnus-newsgroup-data nil
2912 gnus-newsgroup-data-reverse nil)
2913 (gnus-run-hooks 'gnus-summary-generate-hook)
2914 ;; Generate the buffer, either with threads or without.
2915 (when gnus-newsgroup-headers
2916 (gnus-summary-prepare-threads
2917 (if gnus-show-threads
2918 (gnus-sort-gathered-threads
2919 (funcall gnus-summary-thread-gathering-function
2921 (gnus-cut-threads (gnus-make-threads)))))
2922 ;; Unthreaded display.
2923 (gnus-sort-articles gnus-newsgroup-headers))))
2924 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2925 ;; Call hooks for modifying summary buffer.
2926 (goto-char (point-min))
2927 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2929 (defsubst gnus-general-simplify-subject (subject)
2930 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2933 ;; Truncate the subject.
2934 (gnus-simplify-subject-functions
2935 (gnus-map-function gnus-simplify-subject-functions subject))
2936 ((numberp gnus-summary-gather-subject-limit)
2937 (setq subject (gnus-simplify-subject-re subject))
2938 (if (> (length subject) gnus-summary-gather-subject-limit)
2939 (substring subject 0 gnus-summary-gather-subject-limit)
2941 ;; Fuzzily simplify it.
2942 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2943 (gnus-simplify-subject-fuzzy subject))
2944 ;; Just remove the leading "Re:".
2946 (gnus-simplify-subject-re subject))))
2948 (if (and gnus-summary-gather-exclude-subject
2949 (string-match gnus-summary-gather-exclude-subject subject))
2950 nil ; This article shouldn't be gathered
2953 (defun gnus-summary-simplify-subject-query ()
2954 "Query where the respool algorithm would put this article."
2956 (gnus-summary-select-article)
2957 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2959 (defun gnus-gather-threads-by-subject (threads)
2960 "Gather threads by looking at Subject headers."
2961 (if (not gnus-summary-make-false-root)
2963 (let ((hashtb (gnus-make-hashtable 1024))
2966 subject hthread whole-subject)
2968 (setq subject (gnus-general-simplify-subject
2969 (setq whole-subject (mail-header-subject
2972 (if (setq hthread (gnus-gethash subject hashtb))
2974 ;; We enter a dummy root into the thread, if we
2975 ;; haven't done that already.
2976 (unless (stringp (caar hthread))
2977 (setcar hthread (list whole-subject (car hthread))))
2978 ;; We add this new gathered thread to this gathered
2980 (setcdr (car hthread)
2981 (nconc (cdar hthread) (list (car threads))))
2982 ;; Remove it from the list of threads.
2983 (setcdr prev (cdr threads))
2984 (setq threads prev))
2985 ;; Enter this thread into the hash table.
2986 (gnus-sethash subject threads hashtb)))
2988 (setq threads (cdr threads)))
2991 (defun gnus-gather-threads-by-references (threads)
2992 "Gather threads by looking at References headers."
2993 (let ((idhashtb (gnus-make-hashtable 1024))
2994 (thhashtb (gnus-make-hashtable 1024))
2997 ids references id gthread gid entered ref)
2999 (when (setq references (mail-header-references (caar threads)))
3000 (setq id (mail-header-id (caar threads))
3001 ids (gnus-split-references references)
3003 (while (setq ref (pop ids))
3004 (setq ids (delete ref ids))
3005 (if (not (setq gid (gnus-gethash ref idhashtb)))
3007 (gnus-sethash ref id idhashtb)
3008 (gnus-sethash id threads thhashtb))
3009 (setq gthread (gnus-gethash gid thhashtb))
3011 ;; We enter a dummy root into the thread, if we
3012 ;; haven't done that already.
3013 (unless (stringp (caar gthread))
3014 (setcar gthread (list (mail-header-subject (caar gthread))
3016 ;; We add this new gathered thread to this gathered
3018 (setcdr (car gthread)
3019 (nconc (cdar gthread) (list (car threads)))))
3020 ;; Add it into the thread hash table.
3021 (gnus-sethash id gthread thhashtb)
3023 ;; Remove it from the list of threads.
3024 (setcdr prev (cdr threads))
3025 (setq threads prev))))
3027 (setq threads (cdr threads)))
3030 (defun gnus-sort-gathered-threads (threads)
3031 "Sort subtreads inside each gathered thread by article number."
3032 (let ((result threads))
3034 (when (stringp (caar threads))
3035 (setcdr (car threads)
3036 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3037 (setq threads (cdr threads)))
3040 (defun gnus-thread-loop-p (root thread)
3041 "Say whether ROOT is in THREAD."
3042 (let ((stack (list thread))
3045 (while (setq thread (pop stack))
3046 (setq th (cdr thread))
3048 (not (eq (caar th) root)))
3051 ;; We have found a loop.
3053 (setcdr thread (delq (car th) (cdr thread)))
3054 (if (boundp (setq ref-dep (intern "none"
3055 gnus-newsgroup-dependencies)))
3056 (setcdr (symbol-value ref-dep)
3057 (nconc (cdr (symbol-value ref-dep))
3059 (set ref-dep (list nil (car th))))
3062 ;; Push all the subthreads onto the stack.
3063 (push (cdr thread) stack)))
3066 (defun gnus-make-threads ()
3067 "Go through the dependency hashtb and find the roots. Return all threads."
3069 (while (catch 'infloop
3072 ;; Deal with self-referencing References loops.
3073 (when (and (car (symbol-value refs))
3080 (car (symbol-value refs)) thread))
3081 (cdr (symbol-value refs)))))))
3084 (unless (car (symbol-value refs))
3085 ;; These threads do not refer back to any other articles,
3086 ;; so they're roots.
3087 (setq threads (append (cdr (symbol-value refs)) threads))))
3088 gnus-newsgroup-dependencies)))
3091 ;; Build the thread tree.
3092 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3093 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3095 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3096 if it was already present.
3098 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3099 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3100 Message-IDs will be renamed be renamed to a unique Message-ID before
3103 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3104 (let* ((id (mail-header-id header))
3105 (id-dep (and id (intern id dependencies)))
3106 ref ref-dep ref-header)
3107 ;; Enter this `header' in the `dependencies' table.
3111 ;; The first two cases do the normal part: enter a new `header'
3112 ;; in the `dependencies' table.
3113 ((not (boundp id-dep))
3114 (set id-dep (list header)))
3115 ((null (car (symbol-value id-dep)))
3116 (setcar (symbol-value id-dep) header))
3118 ;; From here the `header' was already present in the
3119 ;; `dependencies' table.
3121 ;; Overrides an existing entry;
3122 ;; just set the header part of the entry.
3123 (setcar (symbol-value id-dep) header))
3125 ;; Renames the existing `header' to a unique Message-ID.
3126 ((not gnus-summary-ignore-duplicates)
3127 ;; An article with this Message-ID has already been seen.
3128 ;; We rename the Message-ID.
3129 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3131 (mail-header-set-id header id))
3133 ;; The last case ignores an existing entry, except it adds any
3134 ;; additional Xrefs (in case the two articles came from different
3136 ;; Also sets `header' to `nil' meaning that the `dependencies'
3137 ;; table was *not* modified.
3139 (mail-header-set-xref
3140 (car (symbol-value id-dep))
3141 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3143 (or (mail-header-xref header) "")))
3147 ;; First check if that we are not creating a References loop.
3148 (setq ref (gnus-parent-id (mail-header-references header)))
3150 (setq ref-dep (intern-soft ref dependencies))
3152 (setq ref-header (car (symbol-value ref-dep))))
3153 (if (string= id ref)
3154 ;; Yuk! This is a reference loop. Make the article be a
3157 (mail-header-set-references (car (symbol-value id-dep)) "none")
3159 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3160 (setq ref (gnus-parent-id (mail-header-references header)))
3161 (setq ref-dep (intern (or ref "none") dependencies))
3162 (if (boundp ref-dep)
3163 (setcdr (symbol-value ref-dep)
3164 (nconc (cdr (symbol-value ref-dep))
3165 (list (symbol-value id-dep))))
3166 (set ref-dep (list nil (symbol-value id-dep)))))
3169 (defun gnus-build-sparse-threads ()
3170 (let ((headers gnus-newsgroup-headers)
3171 (mail-parse-charset gnus-newsgroup-charset)
3172 (gnus-summary-ignore-duplicates t)
3173 header references generation relations
3174 subject child end new-child date)
3175 ;; First we create an alist of generations/relations, where
3176 ;; generations is how much we trust the relation, and the relation
3178 (gnus-message 7 "Making sparse threads...")
3180 (nnheader-set-temp-buffer " *gnus sparse threads*")
3181 (while (setq header (pop headers))
3182 (when (and (setq references (mail-header-references header))
3183 (not (string= references "")))
3185 (setq child (mail-header-id header)
3186 subject (mail-header-subject header)
3187 date (mail-header-date header)
3189 (while (search-backward ">" nil t)
3190 (setq end (1+ (point)))
3191 (when (search-backward "<" nil t)
3192 (setq new-child (buffer-substring (point) end))
3193 (push (list (incf generation)
3194 child (setq child new-child)
3198 (push (list (1+ generation) child nil subject) relations))
3200 (kill-buffer (current-buffer)))
3201 ;; Sort over trustworthiness.
3204 (when (gnus-dependencies-add-header
3205 (make-full-mail-header
3206 gnus-reffed-article-number
3207 (nth 3 relation) "" (or (nth 4 relation) "")
3209 (or (nth 2 relation) "") 0 0 "")
3210 gnus-newsgroup-dependencies nil)
3211 (push gnus-reffed-article-number gnus-newsgroup-limit)
3212 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3213 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3214 gnus-newsgroup-reads)
3215 (decf gnus-reffed-article-number)))
3216 (sort relations 'car-less-than-car))
3217 (gnus-message 7 "Making sparse threads...done")))
3219 (defun gnus-build-old-threads ()
3220 ;; Look at all the articles that refer back to old articles, and
3221 ;; fetch the headers for the articles that aren't there. This will
3222 ;; build complete threads - if the roots haven't been expired by the
3224 (let ((mail-parse-charset gnus-newsgroup-charset)
3228 (when (not (car (symbol-value refs)))
3229 (setq heads (cdr (symbol-value refs)))
3231 (if (memq (mail-header-number (caar heads))
3232 gnus-newsgroup-dormant)
3233 (setq heads (cdr heads))
3234 (setq id (symbol-name refs))
3235 (while (and (setq id (gnus-build-get-header id))
3236 (not (car (gnus-id-to-thread id)))))
3237 (setq heads nil)))))
3238 gnus-newsgroup-dependencies)))
3240 ;; This function has to be called with point after the article number
3241 ;; on the beginning of the line.
3242 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3243 (let ((eol (gnus-point-at-eol))
3244 (buffer (current-buffer))
3247 ;; overview: [num subject from date id refs chars lines misc]
3250 (narrow-to-region (point) eol)
3255 (make-full-mail-header
3257 (funcall gnus-decode-encoded-word-function
3258 (nnheader-nov-field)) ; subject
3259 (funcall gnus-decode-encoded-word-function
3260 (nnheader-nov-field)) ; from
3261 (nnheader-nov-field) ; date
3262 (nnheader-nov-read-message-id) ; id
3263 (nnheader-nov-field) ; refs
3264 (nnheader-nov-read-integer) ; chars
3265 (nnheader-nov-read-integer) ; lines
3267 (nnheader-nov-field)) ; misc
3268 (nnheader-nov-parse-extra)))) ; extra
3272 (when gnus-alter-header-function
3273 (funcall gnus-alter-header-function header))
3274 (gnus-dependencies-add-header header dependencies force-new)))
3276 (defun gnus-build-get-header (id)
3277 ;; Look through the buffer of NOV lines and find the header to
3278 ;; ID. Enter this line into the dependencies hash table, and return
3279 ;; the id of the parent article (if any).
3280 (let ((deps gnus-newsgroup-dependencies)
3284 (set-buffer nntp-server-buffer)
3285 (let ((case-fold-search nil))
3286 (goto-char (point-min))
3287 (while (and (not found)
3288 (search-forward id nil t))
3290 (setq found (looking-at
3291 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3292 (regexp-quote id))))
3293 (or found (beginning-of-line 2)))
3297 (setq header (gnus-nov-parse-line
3298 (read (current-buffer)) deps))
3299 (gnus-parent-id (mail-header-references header))))))
3301 (let ((number (mail-header-number header)))
3302 (push number gnus-newsgroup-limit)
3303 (push header gnus-newsgroup-headers)
3304 (if (memq number gnus-newsgroup-unselected)
3306 (push number gnus-newsgroup-unreads)
3307 (setq gnus-newsgroup-unselected
3308 (delq number gnus-newsgroup-unselected)))
3309 (push number gnus-newsgroup-ancient)))))))
3311 (defun gnus-build-all-threads ()
3312 "Read all the headers."
3313 (let ((gnus-summary-ignore-duplicates t)
3314 (mail-parse-charset gnus-newsgroup-charset)
3315 (dependencies gnus-newsgroup-dependencies)
3318 (set-buffer nntp-server-buffer)
3319 (let ((case-fold-search nil))
3320 (goto-char (point-min))
3323 (setq article (read (current-buffer))
3324 header (gnus-nov-parse-line article dependencies)))
3327 (set-buffer gnus-summary-buffer)
3328 (push header gnus-newsgroup-headers)
3329 (if (memq (setq article (mail-header-number header))
3330 gnus-newsgroup-unselected)
3332 (push article gnus-newsgroup-unreads)
3333 (setq gnus-newsgroup-unselected
3334 (delq article gnus-newsgroup-unselected)))
3335 (push article gnus-newsgroup-ancient)))
3336 (forward-line 1)))))))
3338 (defun gnus-summary-update-article-line (article header)
3339 "Update the line for ARTICLE using HEADERS."
3340 (let* ((id (mail-header-id header))
3341 (thread (gnus-id-to-thread id)))
3343 (error "Article in no thread"))
3344 ;; Update the thread.
3345 (setcar thread header)
3346 (gnus-summary-goto-subject article)
3347 (let* ((datal (gnus-data-find-list article))
3349 (length (when (cdr datal)
3350 (- (gnus-data-pos data)
3351 (gnus-data-pos (cadr datal)))))
3352 (buffer-read-only nil)
3353 (level (gnus-summary-thread-level)))
3355 (gnus-summary-insert-line
3356 header level nil (gnus-article-mark article)
3357 (memq article gnus-newsgroup-replied)
3358 (memq article gnus-newsgroup-expirable)
3359 ;; Only insert the Subject string when it's different
3360 ;; from the previous Subject string.
3361 (if (gnus-subject-equal
3363 (mail-header-subject
3366 (gnus-data-find-list
3368 (gnus-data-list t)))))
3369 ;; Error on the side of excessive subjects.
3371 (mail-header-subject header))
3373 (mail-header-subject header))
3374 nil (cdr (assq article gnus-newsgroup-scored))
3375 (memq article gnus-newsgroup-processable))
3377 (gnus-data-update-list
3378 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3380 (defun gnus-summary-update-article (article &optional iheader)
3381 "Update ARTICLE in the summary buffer."
3382 (set-buffer gnus-summary-buffer)
3383 (let* ((header (gnus-summary-article-header article))
3384 (id (mail-header-id header))
3385 (data (gnus-data-find article))
3386 (thread (gnus-id-to-thread id))
3387 (references (mail-header-references header))
3391 (when (and references
3392 (not (equal "" references)))
3395 (buffer-read-only nil)
3401 (delq thread parent)))
3402 (if (gnus-summary-insert-subject id header)
3403 ;; Set the (possibly) new article number in the data structure.
3404 (gnus-data-set-number data (gnus-id-to-article id))
3408 (defun gnus-rebuild-thread (id &optional line)
3409 "Rebuild the thread containing ID.
3410 If LINE, insert the rebuilt thread starting on line LINE."
3411 (let ((buffer-read-only nil)
3412 old-pos current thread data)
3413 (if (not gnus-show-threads)
3414 (setq thread (list (car (gnus-id-to-thread id))))
3415 ;; Get the thread this article is part of.
3416 (setq thread (gnus-remove-thread id)))
3417 (setq old-pos (gnus-point-at-bol))
3418 (setq current (save-excursion
3419 (and (zerop (forward-line -1))
3420 (gnus-summary-article-number))))
3421 ;; If this is a gathered thread, we have to go some re-gathering.
3422 (when (stringp (car thread))
3423 (let ((subject (car thread))
3425 (setq thread (cdr thread))
3427 (unless (memq (setq thr (gnus-id-to-thread
3429 (mail-header-id (caar thread)))))
3432 (setq thread (cdr thread)))
3433 ;; We now have all (unique) roots.
3434 (if (= (length roots) 1)
3435 ;; All the loose roots are now one solid root.
3436 (setq thread (car roots))
3437 (setq thread (cons subject (gnus-sort-threads roots))))))
3439 ;; We then insert this thread into the summary buffer.
3441 (goto-char (point-min))
3442 (forward-line (1- line)))
3443 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3444 (if gnus-show-threads
3445 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3446 (gnus-summary-prepare-unthreaded thread))
3447 (setq data (nreverse gnus-newsgroup-data))
3448 (setq threads gnus-newsgroup-threads))
3449 ;; We splice the new data into the data structure.
3450 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3451 ;;!!! then we want to insert at the beginning of the buffer.
3452 ;;!!! That happens to be true with Gnus now, but that may
3453 ;;!!! change in the future. Perhaps.
3454 (gnus-data-enter-list
3455 (if line nil current) data (- (point) old-pos))
3456 (setq gnus-newsgroup-threads
3457 (nconc threads gnus-newsgroup-threads))
3458 (gnus-data-compute-positions))))
3460 (defun gnus-number-to-header (number)
3461 "Return the header for article NUMBER."
3462 (let ((headers gnus-newsgroup-headers))
3464 (not (= number (mail-header-number (car headers)))))
3469 (defun gnus-parent-headers (in-headers &optional generation)
3470 "Return the headers of the GENERATIONeth parent of HEADERS."
3472 (setq generation 1))
3474 (headers in-headers)
3477 (not (zerop generation))
3478 (setq references (mail-header-references headers)))
3479 (setq headers (if (and references
3480 (setq parent (gnus-parent-id references)))
3481 (car (gnus-id-to-thread parent))
3484 (and (not (eq headers in-headers))
3487 (defun gnus-id-to-thread (id)
3488 "Return the (sub-)thread where ID appears."
3489 (gnus-gethash id gnus-newsgroup-dependencies))
3491 (defun gnus-id-to-article (id)
3492 "Return the article number of ID."
3493 (let ((thread (gnus-id-to-thread id)))
3496 (mail-header-number (car thread)))))
3498 (defun gnus-id-to-header (id)
3499 "Return the article headers of ID."
3500 (car (gnus-id-to-thread id)))
3502 (defun gnus-article-displayed-root-p (article)
3503 "Say whether ARTICLE is a root(ish) article."
3504 (let ((level (gnus-summary-thread-level article))
3505 (refs (mail-header-references (gnus-summary-article-header article)))
3511 ((null (gnus-parent-id refs)) t)
3513 (null (setq particle (gnus-id-to-article
3514 (gnus-parent-id refs))))
3515 (null (gnus-summary-thread-level particle)))))))
3517 (defun gnus-root-id (id)
3518 "Return the id of the root of the thread where ID appears."
3520 (while (and id (setq prev (car (gnus-id-to-thread id))))
3522 id (gnus-parent-id (mail-header-references prev))))
3525 (defun gnus-articles-in-thread (thread)
3526 "Return the list of articles in THREAD."
3527 (cons (mail-header-number (car thread))
3528 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3530 (defun gnus-remove-thread (id &optional dont-remove)
3531 "Remove the thread that has ID in it."
3532 (let (headers thread last-id)
3533 ;; First go up in this thread until we find the root.
3534 (setq last-id (gnus-root-id id)
3535 headers (message-flatten-list (gnus-id-to-thread last-id)))
3536 ;; We have now found the real root of this thread. It might have
3537 ;; been gathered into some loose thread, so we have to search
3538 ;; through the threads to find the thread we wanted.
3539 (let ((threads gnus-newsgroup-threads)
3542 (setq sub (car threads))
3543 (if (stringp (car sub))
3544 ;; This is a gathered thread, so we look at the roots
3545 ;; below it to find whether this article is in this
3548 (setq sub (cdr sub))
3550 (when (member (caar sub) headers)
3551 (setq thread (car threads)
3554 (setq sub (cdr sub))))
3555 ;; It's an ordinary thread, so we check it.
3556 (when (eq (car sub) (car headers))
3559 (setq threads (cdr threads)))
3560 ;; If this article is in no thread, then it's a root.
3563 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3564 (setq thread (gnus-id-to-thread last-id)))
3567 thread ; We return this thread.
3569 (if (stringp (car thread))
3571 ;; If we use dummy roots, then we have to remove the
3572 ;; dummy root as well.
3573 (when (eq gnus-summary-make-false-root 'dummy)
3574 ;; We go to the dummy root by going to
3575 ;; the first sub-"thread", and then one line up.
3576 (gnus-summary-goto-article
3577 (mail-header-number (caadr thread)))
3580 (gnus-data-compute-positions))
3581 (setq thread (cdr thread))
3583 (gnus-remove-thread-1 (car thread))
3584 (setq thread (cdr thread))))
3585 (gnus-summary-show-all-threads)
3586 (gnus-remove-thread-1 thread))))))))
3588 (defun gnus-remove-thread-1 (thread)
3589 "Remove the thread THREAD recursively."
3590 (let ((number (mail-header-number (pop thread)))
3592 (setq thread (reverse thread))
3594 (gnus-remove-thread-1 (pop thread)))
3595 (when (setq d (gnus-data-find number))
3596 (goto-char (gnus-data-pos d))
3599 (- (gnus-point-at-bol)
3601 (1+ (gnus-point-at-eol))
3602 (gnus-delete-line)))))))
3604 (defun gnus-sort-threads (threads)
3606 (if (not gnus-thread-sort-functions)
3608 (gnus-message 8 "Sorting threads...")
3610 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3611 (gnus-message 8 "Sorting threads...done"))))
3613 (defun gnus-sort-articles (articles)
3615 (when gnus-article-sort-functions
3616 (gnus-message 7 "Sorting articles...")
3618 (setq gnus-newsgroup-headers
3619 (sort articles (gnus-make-sort-function
3620 gnus-article-sort-functions)))
3621 (gnus-message 7 "Sorting articles...done"))))
3623 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3624 (defmacro gnus-thread-header (thread)
3625 ;; Return header of first article in THREAD.
3626 ;; Note that THREAD must never, ever be anything else than a variable -
3627 ;; using some other form will lead to serious barfage.
3628 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3629 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3630 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3633 (defsubst gnus-article-sort-by-number (h1 h2)
3634 "Sort articles by article number."
3635 (< (mail-header-number h1)
3636 (mail-header-number h2)))
3638 (defun gnus-thread-sort-by-number (h1 h2)
3639 "Sort threads by root article number."
3640 (gnus-article-sort-by-number
3641 (gnus-thread-header h1) (gnus-thread-header h2)))
3643 (defsubst gnus-article-sort-by-lines (h1 h2)
3644 "Sort articles by article Lines header."
3645 (< (mail-header-lines h1)
3646 (mail-header-lines h2)))
3648 (defun gnus-thread-sort-by-lines (h1 h2)
3649 "Sort threads by root article Lines header."
3650 (gnus-article-sort-by-lines
3651 (gnus-thread-header h1) (gnus-thread-header h2)))
3653 (defsubst gnus-article-sort-by-chars (h1 h2)
3654 "Sort articles by octet length."
3655 (< (mail-header-chars h1)
3656 (mail-header-chars h2)))
3658 (defun gnus-thread-sort-by-chars (h1 h2)
3659 "Sort threads by root article octet length."
3660 (gnus-article-sort-by-chars
3661 (gnus-thread-header h1) (gnus-thread-header h2)))
3663 (defsubst gnus-article-sort-by-author (h1 h2)
3664 "Sort articles by root author."
3666 (let ((extract (funcall
3667 gnus-extract-address-components
3668 (mail-header-from h1))))
3669 (or (car extract) (cadr extract) ""))
3670 (let ((extract (funcall
3671 gnus-extract-address-components
3672 (mail-header-from h2))))
3673 (or (car extract) (cadr extract) ""))))
3675 (defun gnus-thread-sort-by-author (h1 h2)
3676 "Sort threads by root author."
3677 (gnus-article-sort-by-author
3678 (gnus-thread-header h1) (gnus-thread-header h2)))
3680 (defsubst gnus-article-sort-by-subject (h1 h2)
3681 "Sort articles by root subject."
3683 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3684 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3686 (defun gnus-thread-sort-by-subject (h1 h2)
3687 "Sort threads by root subject."
3688 (gnus-article-sort-by-subject
3689 (gnus-thread-header h1) (gnus-thread-header h2)))
3691 (defsubst gnus-article-sort-by-date (h1 h2)
3692 "Sort articles by root article date."
3694 (gnus-date-get-time (mail-header-date h1))
3695 (gnus-date-get-time (mail-header-date h2))))
3697 (defun gnus-thread-sort-by-date (h1 h2)
3698 "Sort threads by root article date."
3699 (gnus-article-sort-by-date
3700 (gnus-thread-header h1) (gnus-thread-header h2)))
3702 (defsubst gnus-article-sort-by-score (h1 h2)
3703 "Sort articles by root article score.
3704 Unscored articles will be counted as having a score of zero."
3705 (> (or (cdr (assq (mail-header-number h1)
3706 gnus-newsgroup-scored))
3707 gnus-summary-default-score 0)
3708 (or (cdr (assq (mail-header-number h2)
3709 gnus-newsgroup-scored))
3710 gnus-summary-default-score 0)))
3712 (defun gnus-thread-sort-by-score (h1 h2)
3713 "Sort threads by root article score."
3714 (gnus-article-sort-by-score
3715 (gnus-thread-header h1) (gnus-thread-header h2)))
3717 (defun gnus-thread-sort-by-total-score (h1 h2)
3718 "Sort threads by the sum of all scores in the thread.
3719 Unscored articles will be counted as having a score of zero."
3720 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3722 (defun gnus-thread-total-score (thread)
3723 ;; This function find the total score of THREAD.
3724 (cond ((null thread)
3727 (if (stringp (car thread))
3728 (apply gnus-thread-score-function 0
3729 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3730 (gnus-thread-total-score-1 thread)))
3732 (gnus-thread-total-score-1 (list thread)))))
3734 (defun gnus-thread-total-score-1 (root)
3735 ;; This function find the total score of the thread below ROOT.
3736 (setq root (car root))
3737 (apply gnus-thread-score-function
3739 (mapcar 'gnus-thread-total-score
3740 (cdr (gnus-id-to-thread (mail-header-id root))))
3741 (when (> (mail-header-number root) 0)
3742 (list (or (cdr (assq (mail-header-number root)
3743 gnus-newsgroup-scored))
3744 gnus-summary-default-score 0))))
3745 (list gnus-summary-default-score)
3748 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3749 (defvar gnus-tmp-prev-subject nil)
3750 (defvar gnus-tmp-false-parent nil)
3751 (defvar gnus-tmp-root-expunged nil)
3752 (defvar gnus-tmp-dummy-line nil)
3754 (defvar gnus-tmp-header)
3755 (defun gnus-extra-header (type &optional header)
3756 "Return the extra header of TYPE."
3757 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3760 (defun gnus-summary-prepare-threads (threads)
3761 "Prepare summary buffer from THREADS and indentation LEVEL.
3762 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3763 or a straight list of headers."
3764 (gnus-message 7 "Generating summary...")
3766 (setq gnus-newsgroup-threads threads)
3769 (let ((gnus-tmp-level 0)
3770 (default-score (or gnus-summary-default-score 0))
3771 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3772 thread number subject stack state gnus-tmp-gathered beg-match
3773 new-roots gnus-tmp-new-adopts thread-end
3774 gnus-tmp-header gnus-tmp-unread
3775 gnus-tmp-replied gnus-tmp-subject-or-nil
3776 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3777 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3778 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3780 (setq gnus-tmp-prev-subject nil)
3782 (if (vectorp (car threads))
3783 ;; If this is a straight (sic) list of headers, then a
3784 ;; threaded summary display isn't required, so we just create
3785 ;; an unthreaded one.
3786 (gnus-summary-prepare-unthreaded threads)
3788 ;; Do the threaded display.
3790 (while (or threads stack gnus-tmp-new-adopts new-roots)
3792 (if (and (= gnus-tmp-level 0)
3795 (not gnus-tmp-false-parent)
3796 (or gnus-tmp-new-adopts new-roots))
3797 (if gnus-tmp-new-adopts
3798 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3799 thread (list (car gnus-tmp-new-adopts))
3800 gnus-tmp-header (caar thread)
3801 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3803 (setq thread (list (car new-roots))
3804 gnus-tmp-header (caar thread)
3805 new-roots (cdr new-roots))))
3808 ;; If there are some threads, we do them before the
3809 ;; threads on the stack.
3810 (setq thread threads
3811 gnus-tmp-header (caar thread))
3812 ;; There were no current threads, so we pop something off
3814 (setq state (car stack)
3815 gnus-tmp-level (car state)
3818 gnus-tmp-header (caar thread))))
3820 (setq gnus-tmp-false-parent nil)
3821 (setq gnus-tmp-root-expunged nil)
3822 (setq thread-end nil)
3824 (if (stringp gnus-tmp-header)
3825 ;; The header is a dummy root.
3827 ((eq gnus-summary-make-false-root 'adopt)
3828 ;; We let the first article adopt the rest.
3829 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3831 (setq gnus-tmp-gathered
3833 (lambda (h) (mail-header-number (car h)))
3836 (setq thread (cons (list (caar thread)
3839 (setq gnus-tmp-level -1
3840 gnus-tmp-false-parent t))
3841 ((eq gnus-summary-make-false-root 'empty)
3842 ;; We print adopted articles with empty subject fields.
3843 (setq gnus-tmp-gathered
3845 (lambda (h) (mail-header-number (car h)))
3848 (setq gnus-tmp-level -1))
3849 ((eq gnus-summary-make-false-root 'dummy)
3850 ;; We remember that we probably want to output a dummy
3852 (setq gnus-tmp-dummy-line gnus-tmp-header)
3853 (setq gnus-tmp-prev-subject gnus-tmp-header))
3855 ;; We do not make a root for the gathered
3856 ;; sub-threads at all.
3857 (setq gnus-tmp-level -1)))
3859 (setq number (mail-header-number gnus-tmp-header)
3860 subject (mail-header-subject gnus-tmp-header))
3863 ;; If the thread has changed subject, we might want to make
3864 ;; this subthread into a root.
3865 ((and (null gnus-thread-ignore-subject)
3866 (not (zerop gnus-tmp-level))
3867 gnus-tmp-prev-subject
3869 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3870 (setq new-roots (nconc new-roots (list (car thread)))
3872 gnus-tmp-header nil))
3873 ;; If the article lies outside the current limit,
3874 ;; then we do not display it.
3875 ((not (memq number gnus-newsgroup-limit))
3876 (setq gnus-tmp-gathered
3878 (lambda (h) (mail-header-number (car h)))
3881 (setq gnus-tmp-new-adopts (if (cdar thread)
3882 (append gnus-tmp-new-adopts
3884 gnus-tmp-new-adopts)
3886 gnus-tmp-header nil)
3887 (when (zerop gnus-tmp-level)
3888 (setq gnus-tmp-root-expunged t)))
3889 ;; Perhaps this article is to be marked as read?
3890 ((and gnus-summary-mark-below
3891 (< (or (cdr (assq number gnus-newsgroup-scored))
3893 gnus-summary-mark-below)
3894 ;; Don't touch sparse articles.
3895 (not (gnus-summary-article-sparse-p number))
3896 (not (gnus-summary-article-ancient-p number)))
3897 (setq gnus-newsgroup-unreads
3898 (delq number gnus-newsgroup-unreads))
3899 (if gnus-newsgroup-auto-expire
3900 (push number gnus-newsgroup-expirable)
3901 (push (cons number gnus-low-score-mark)
3902 gnus-newsgroup-reads))))
3904 (when gnus-tmp-header
3905 ;; We may have an old dummy line to output before this
3907 (when (and gnus-tmp-dummy-line
3910 (mail-header-subject gnus-tmp-header)))
3911 (gnus-summary-insert-dummy-line
3912 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3913 (setq gnus-tmp-dummy-line nil))
3915 ;; Compute the mark.
3916 (setq gnus-tmp-unread (gnus-article-mark number))
3918 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3919 gnus-tmp-header gnus-tmp-level)
3920 gnus-newsgroup-data)
3922 ;; Actually insert the line.
3924 gnus-tmp-subject-or-nil
3926 ((and gnus-thread-ignore-subject
3927 gnus-tmp-prev-subject
3928 (not (inline (gnus-subject-equal
3929 gnus-tmp-prev-subject subject))))
3931 ((zerop gnus-tmp-level)
3932 (if (and (eq gnus-summary-make-false-root 'empty)
3933 (memq number gnus-tmp-gathered)
3934 gnus-tmp-prev-subject
3935 (inline (gnus-subject-equal
3936 gnus-tmp-prev-subject subject)))
3937 gnus-summary-same-subject
3939 (t gnus-summary-same-subject)))
3940 (if (and (eq gnus-summary-make-false-root 'adopt)
3941 (= gnus-tmp-level 1)
3942 (memq number gnus-tmp-gathered))
3943 (setq gnus-tmp-opening-bracket ?\<
3944 gnus-tmp-closing-bracket ?\>)
3945 (setq gnus-tmp-opening-bracket ?\[
3946 gnus-tmp-closing-bracket ?\]))
3948 gnus-tmp-indentation
3949 (aref gnus-thread-indent-array gnus-tmp-level)
3950 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3951 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3952 gnus-summary-default-score 0)
3954 (if (or (null gnus-summary-default-score)
3955 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3956 gnus-summary-zcore-fuzz))
3958 (if (< gnus-tmp-score gnus-summary-default-score)
3959 gnus-score-below-mark gnus-score-over-mark))
3961 (cond ((memq number gnus-newsgroup-processable)
3963 ((memq number gnus-newsgroup-cached)
3965 ((memq number gnus-newsgroup-replied)
3967 ((memq number gnus-newsgroup-saved)
3969 (t gnus-unread-mark))
3970 gnus-tmp-from (mail-header-from gnus-tmp-header)
3973 ((string-match "<[^>]+> *$" gnus-tmp-from)
3974 (setq beg-match (match-beginning 0))
3975 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3976 (substring gnus-tmp-from (1+ (match-beginning 0))
3977 (1- (match-end 0))))
3978 (substring gnus-tmp-from 0 beg-match)))
3979 ((string-match "(.+)" gnus-tmp-from)
3980 (substring gnus-tmp-from
3981 (1+ (match-beginning 0)) (1- (match-end 0))))
3983 (when (string= gnus-tmp-name "")
3984 (setq gnus-tmp-name gnus-tmp-from))
3985 (unless (numberp gnus-tmp-lines)
3986 (setq gnus-tmp-lines 0))
3987 (gnus-put-text-property
3989 (progn (eval gnus-summary-line-format-spec) (point))
3990 'gnus-number number)
3993 (gnus-run-hooks 'gnus-summary-update-hook)
3996 (setq gnus-tmp-prev-subject subject)))
3998 (when (nth 1 thread)
3999 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4000 (incf gnus-tmp-level)
4001 (setq threads (if thread-end nil (cdar thread)))
4003 (setq gnus-tmp-level 0)))))
4004 (gnus-message 7 "Generating summary...done"))
4006 (defun gnus-summary-prepare-unthreaded (headers)
4007 "Generate an unthreaded summary buffer based on HEADERS."
4008 (let (header number mark)
4013 ;; We may have to root out some bad articles...
4014 (when (memq (setq number (mail-header-number
4015 (setq header (pop headers))))
4016 gnus-newsgroup-limit)
4017 ;; Mark article as read when it has a low score.
4018 (when (and gnus-summary-mark-below
4019 (< (or (cdr (assq number gnus-newsgroup-scored))
4020 gnus-summary-default-score 0)
4021 gnus-summary-mark-below)
4022 (not (gnus-summary-article-ancient-p number)))
4023 (setq gnus-newsgroup-unreads
4024 (delq number gnus-newsgroup-unreads))
4025 (if gnus-newsgroup-auto-expire
4026 (push number gnus-newsgroup-expirable)
4027 (push (cons number gnus-low-score-mark)
4028 gnus-newsgroup-reads)))
4030 (setq mark (gnus-article-mark number))
4031 (push (gnus-data-make number mark (1+ (point)) header 0)
4032 gnus-newsgroup-data)
4033 (gnus-summary-insert-line
4035 mark (memq number gnus-newsgroup-replied)
4036 (memq number gnus-newsgroup-expirable)
4037 (mail-header-subject header) nil
4038 (cdr (assq number gnus-newsgroup-scored))
4039 (memq number gnus-newsgroup-processable))))))
4041 (defun gnus-summary-remove-list-identifiers ()
4042 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4043 (let ((regexp (if (stringp gnus-list-identifiers)
4044 gnus-list-identifiers
4045 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4046 (dolist (header gnus-newsgroup-headers)
4047 (when (string-match (concat "\\(Re: +\\)?\\(" regexp " *\\)")
4048 (mail-header-subject header))
4049 (mail-header-set-subject
4050 header (concat (substring (mail-header-subject header)
4051 0 (match-beginning 2))
4052 (substring (mail-header-subject header)
4053 (match-end 2))))))))
4055 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4056 "Select newsgroup GROUP.
4057 If READ-ALL is non-nil, all articles in the group are selected.
4058 If SELECT-ARTICLES, only select those articles from GROUP."
4059 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4060 ;;!!! Dirty hack; should be removed.
4061 (gnus-summary-ignore-duplicates
4062 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4064 gnus-summary-ignore-duplicates))
4065 (info (nth 2 entry))
4066 articles fetched-articles cached)
4068 (unless (gnus-check-server
4069 (setq gnus-current-select-method
4070 (gnus-find-method-for-group group)))
4071 (error "Couldn't open server"))
4073 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4074 (gnus-activate-group group) ; Or we can activate it...
4075 (progn ; Or we bug out.
4076 (when (equal major-mode 'gnus-summary-mode)
4077 (kill-buffer (current-buffer)))
4078 (error "Couldn't request group %s: %s"
4079 group (gnus-status-message group))))
4081 (unless (gnus-request-group group t)
4082 (when (equal major-mode 'gnus-summary-mode)
4083 (kill-buffer (current-buffer)))
4084 (error "Couldn't request group %s: %s"
4085 group (gnus-status-message group)))
4087 (setq gnus-newsgroup-name group)
4088 (setq gnus-newsgroup-unselected nil)
4089 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4090 (gnus-summary-setup-default-charset)
4092 ;; Adjust and set lists of article marks.
4094 (gnus-adjust-marked-articles info))
4096 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4097 (when (gnus-virtual-group-p group)
4098 (setq cached gnus-newsgroup-cached))
4100 (setq gnus-newsgroup-unreads
4101 (gnus-set-difference
4102 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4103 gnus-newsgroup-dormant))
4105 (setq gnus-newsgroup-processable nil)
4107 (gnus-update-read-articles group gnus-newsgroup-unreads)
4109 (if (setq articles select-articles)
4110 (setq gnus-newsgroup-unselected
4111 (gnus-sorted-intersection
4112 gnus-newsgroup-unreads
4113 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4114 (setq articles (gnus-articles-to-read group read-all)))
4118 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4120 ((eq articles 0) nil)
4122 ;; Init the dependencies hash table.
4123 (setq gnus-newsgroup-dependencies
4124 (gnus-make-hashtable (length articles)))
4125 (gnus-set-global-variables)
4126 ;; Retrieve the headers and read them in.
4127 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4128 (setq gnus-newsgroup-headers
4130 (setq gnus-headers-retrieved-by
4131 (gnus-retrieve-headers
4132 articles gnus-newsgroup-name
4133 ;; We might want to fetch old headers, but
4134 ;; not if there is only 1 article.
4136 (not (eq gnus-fetch-old-headers 'some))
4137 (not (numberp gnus-fetch-old-headers)))
4138 (> (length articles) 1))
4139 gnus-fetch-old-headers))))
4140 (gnus-get-newsgroup-headers-xover
4141 articles nil nil gnus-newsgroup-name t)
4142 (gnus-get-newsgroup-headers)))
4143 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4145 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4147 (setq gnus-newsgroup-cached cached))
4149 ;; Suppress duplicates?
4150 (when gnus-suppress-duplicates
4151 (gnus-dup-suppress-articles))
4153 ;; Set the initial limit.
4154 (setq gnus-newsgroup-limit (copy-sequence articles))
4155 ;; Remove canceled articles from the list of unread articles.
4156 (setq gnus-newsgroup-unreads
4157 (gnus-set-sorted-intersection
4158 gnus-newsgroup-unreads
4159 (setq fetched-articles
4160 (mapcar (lambda (headers) (mail-header-number headers))
4161 gnus-newsgroup-headers))))
4162 ;; Removed marked articles that do not exist.
4163 (gnus-update-missing-marks
4164 (gnus-sorted-complement fetched-articles articles))
4165 ;; We might want to build some more threads first.
4166 (when (and gnus-fetch-old-headers
4167 (eq gnus-headers-retrieved-by 'nov))
4168 (if (eq gnus-fetch-old-headers 'invisible)
4169 (gnus-build-all-threads)
4170 (gnus-build-old-threads)))
4171 ;; Let the Gnus agent mark articles as read.
4173 (gnus-agent-get-undownloaded-list))
4174 ;; Remove list identifiers from subject
4175 (when gnus-list-identifiers
4176 (gnus-summary-remove-list-identifiers))
4177 ;; Check whether auto-expire is to be done in this group.
4178 (setq gnus-newsgroup-auto-expire
4179 (gnus-group-auto-expirable-p group))
4180 ;; Set up the article buffer now, if necessary.
4181 (unless gnus-single-article-buffer
4182 (gnus-article-setup-buffer))
4183 ;; First and last article in this newsgroup.
4184 (when gnus-newsgroup-headers
4185 (setq gnus-newsgroup-begin
4186 (mail-header-number (car gnus-newsgroup-headers))
4189 (gnus-last-element gnus-newsgroup-headers))))
4190 ;; GROUP is successfully selected.
4191 (or gnus-newsgroup-headers t)))))
4193 (defun gnus-articles-to-read (group &optional read-all)
4194 ;; Find out what articles the user wants to read.
4196 ;; Select all articles if `read-all' is non-nil, or if there
4197 ;; are no unread articles.
4199 (and (zerop (length gnus-newsgroup-marked))
4200 (zerop (length gnus-newsgroup-unreads)))
4201 (eq (gnus-group-find-parameter group 'display)
4204 (gnus-uncompress-range (gnus-active group))
4205 (gnus-cache-articles-in-group group))
4206 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4207 (copy-sequence gnus-newsgroup-unreads))
4209 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4210 (scored (length scored-list))
4211 (number (length articles))
4212 (marked (+ (length gnus-newsgroup-marked)
4213 (length gnus-newsgroup-dormant)))
4221 ((and (or (<= scored marked) (= scored number))
4222 (numberp gnus-large-newsgroup)
4223 (> number gnus-large-newsgroup))
4227 "How many articles from %s (default %d): "
4228 (gnus-limit-string gnus-newsgroup-name 35)
4230 (if (string-match "^[ \t]*$" input) number input)))
4231 ((and (> scored marked) (< scored number)
4232 (> (- scored number) 20))
4235 (format "%s %s (%d scored, %d total): "
4236 "How many articles from"
4237 group scored number))))
4238 (if (string-match "^[ \t]*$" input)
4242 (setq select (if (stringp select) (string-to-number select) select))
4243 (if (or (null select) (zerop select))
4245 (if (and (not (zerop scored)) (<= (abs select) scored))
4247 (setq articles (sort scored-list '<))
4248 (setq number (length articles)))
4249 (setq articles (copy-sequence articles)))
4251 (when (< (abs select) number)
4253 ;; Select the N oldest articles.
4254 (setcdr (nthcdr (1- (abs select)) articles) nil)
4255 ;; Select the N most recent articles.
4256 (setq articles (nthcdr (- number select) articles))))
4257 (setq gnus-newsgroup-unselected
4258 (gnus-sorted-intersection
4259 gnus-newsgroup-unreads
4260 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4263 (defun gnus-killed-articles (killed articles)
4266 (when (inline (gnus-member-of-range (car articles) killed))
4267 (push (car articles) out))
4268 (setq articles (cdr articles)))
4271 (defun gnus-uncompress-marks (marks)
4272 "Uncompress the mark ranges in MARKS."
4273 (let ((uncompressed '(score bookmark))
4276 (if (memq (caar marks) uncompressed)
4277 (push (car marks) out)
4278 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4279 (setq marks (cdr marks)))
4282 (defun gnus-adjust-marked-articles (info)
4283 "Set all article lists and remove all marks that are no longer valid."
4284 (let* ((marked-lists (gnus-info-marks info))
4285 (active (gnus-active (gnus-info-group info)))
4288 (types gnus-article-mark-lists)
4289 (uncompressed '(score bookmark killed))
4290 marks var articles article mark)
4293 (setq marks (pop marked-lists))
4294 (set (setq var (intern (format "gnus-newsgroup-%s"
4295 (car (rassq (setq mark (car marks))
4297 (if (memq (car marks) uncompressed) (cdr marks)
4298 (gnus-uncompress-range (cdr marks))))
4300 (setq articles (symbol-value var))
4302 ;; All articles have to be subsets of the active articles.
4304 ;; Adjust "simple" lists.
4305 ((memq mark '(tick dormant expire reply save))
4307 (when (or (< (setq article (pop articles)) min) (> article max))
4308 (set var (delq article (symbol-value var))))))
4310 ((memq mark uncompressed)
4311 (when (not (listp (cdr (symbol-value var))))
4312 (set var (list (symbol-value var))))
4313 (when (not (listp (cdr articles)))
4314 (setq articles (list articles)))
4316 (when (or (not (consp (setq article (pop articles))))
4317 (< (car article) min)
4318 (> (car article) max))
4319 (set var (delq article (symbol-value var))))))))))
4321 (defun gnus-update-missing-marks (missing)
4322 "Go through the list of MISSING articles and remove them from the mark lists."
4324 (let ((types gnus-article-mark-lists)
4326 ;; Go through all types.
4328 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4329 (when (symbol-value var)
4330 ;; This list has articles. So we delete all missing articles
4334 (set var (delq (pop m) (symbol-value var)))))))))
4336 (defun gnus-update-marks ()
4337 "Enter the various lists of marked articles into the newsgroup info list."
4338 (let ((types gnus-article-mark-lists)
4339 (info (gnus-get-info gnus-newsgroup-name))
4340 (uncompressed '(score bookmark killed))
4341 type list newmarked symbol delta-marks)
4343 ;; Add all marks lists to the list of marks lists.
4344 (while (setq type (pop types))
4345 (setq list (symbol-value
4347 (intern (format "gnus-newsgroup-%s"
4351 ;; Get rid of the entries of the articles that have the
4353 (when (and (eq (cdr type) 'score)
4357 (prev (cons nil list))
4360 (if (or (not (consp (car arts)))
4361 (= (cdar arts) gnus-summary-default-score))
4362 (setcdr prev (cdr arts))
4364 (setq arts (cdr arts)))
4365 (setq list (cdr all)))))
4367 (or (memq (cdr type) uncompressed)
4368 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4370 (when (gnus-check-backend-function 'request-set-mark
4371 gnus-newsgroup-name)
4372 ;; uncompressed:s are not proper flags (they are cons cells)
4373 ;; cache is a internal gnus flag
4374 (unless (memq (cdr type) (cons 'cache uncompressed))
4375 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4376 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4377 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4379 (push (list add 'add (list (cdr type))) delta-marks))
4381 (push (list del 'del (list (cdr type))) delta-marks)))))
4384 (push (cons (cdr type) list) newmarked)))
4387 (unless (gnus-check-group gnus-newsgroup-name)
4388 (error "Can't open server for %s" gnus-newsgroup-name))
4389 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4391 ;; Enter these new marks into the info of the group.
4393 (setcar (nthcdr 3 info) newmarked)
4394 ;; Add the marks lists to the end of the info.
4396 (setcdr (nthcdr 2 info) (list newmarked))))
4398 ;; Cut off the end of the info if there's nothing else there.
4402 (when (nthcdr (decf i) info)
4403 (setcdr (nthcdr i info) nil)))))))
4405 (defun gnus-set-mode-line (where)
4406 "This function sets the mode line of the article or summary buffers.
4407 If WHERE is `summary', the summary mode line format will be used."
4408 ;; Is this mode line one we keep updated?
4409 (when (and (memq where gnus-updated-mode-lines)
4411 (intern (format "gnus-%s-mode-line-format-spec" where))))
4414 ;; We evaluate this in the summary buffer since these
4415 ;; variables are buffer-local to that buffer.
4416 (set-buffer gnus-summary-buffer)
4417 ;; We bind all these variables that are used in the `eval' form
4419 (let* ((mformat (symbol-value
4421 (format "gnus-%s-mode-line-format-spec" where))))
4422 (gnus-tmp-group-name gnus-newsgroup-name)
4423 (gnus-tmp-article-number (or gnus-current-article 0))
4424 (gnus-tmp-unread gnus-newsgroup-unreads)
4425 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4426 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4427 (gnus-tmp-unread-and-unselected
4428 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4429 (zerop gnus-tmp-unselected))
4431 ((zerop gnus-tmp-unselected)
4432 (format "{%d more}" gnus-tmp-unread-and-unticked))
4433 (t (format "{%d(+%d) more}"
4434 gnus-tmp-unread-and-unticked
4435 gnus-tmp-unselected))))
4437 (if (and gnus-current-headers
4438 (vectorp gnus-current-headers))
4439 (gnus-mode-string-quote
4440 (mail-header-subject gnus-current-headers))
4442 bufname-length max-len
4443 gnus-tmp-header);; passed as argument to any user-format-funcs
4444 (setq mode-string (eval mformat))
4445 (setq bufname-length (if (string-match "%b" mode-string)
4448 (if (eq where 'summary)
4450 (get-buffer gnus-article-buffer))))
4453 (setq max-len (max 4 (if gnus-mode-non-string-length
4455 gnus-mode-non-string-length
4457 (length mode-string))))
4458 ;; We might have to chop a bit of the string off...
4459 (when (> (length mode-string) max-len)
4461 (concat (truncate-string-to-width mode-string (- max-len 3))
4463 ;; Pad the mode string a bit.
4464 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4465 ;; Update the mode line.
4466 (setq mode-line-buffer-identification
4467 (gnus-mode-line-buffer-identification (list mode-string)))
4468 (set-buffer-modified-p t))))
4470 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4471 "Go through the HEADERS list and add all Xrefs to a hash table.
4472 The resulting hash table is returned, or nil if no Xrefs were found."
4473 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4474 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4475 (xref-hashtb (gnus-make-hashtable))
4476 start group entry number xrefs header)
4478 (setq header (pop headers))
4479 (when (and (setq xrefs (mail-header-xref header))
4480 (not (memq (setq number (mail-header-number header))
4483 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4484 (setq start (match-end 0))
4485 (setq group (if prefix
4486 (concat prefix (substring xrefs (match-beginning 1)
4488 (substring xrefs (match-beginning 1) (match-end 1))))
4490 (string-to-int (substring xrefs (match-beginning 2)
4492 (if (setq entry (gnus-gethash group xref-hashtb))
4493 (setcdr entry (cons number (cdr entry)))
4494 (gnus-sethash group (cons number nil) xref-hashtb)))))
4495 (and start xref-hashtb)))
4497 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4498 "Look through all the headers and mark the Xrefs as read."
4499 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4500 name entry info xref-hashtb idlist method nth4)
4502 (set-buffer gnus-group-buffer)
4503 (when (setq xref-hashtb
4504 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4507 (unless (string= from-newsgroup (setq name (symbol-name group)))
4508 (setq idlist (symbol-value group))
4509 ;; Dead groups are not updated.
4511 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4513 (when (stringp (setq nth4 (gnus-info-method info)))
4514 (setq nth4 (gnus-server-to-method nth4))))
4515 ;; Only do the xrefs if the group has the same
4516 ;; select method as the group we have just read.
4517 (or (gnus-methods-equal-p
4518 nth4 (gnus-find-method-for-group from-newsgroup))
4520 (equal nth4 (setq method (gnus-find-method-for-group
4522 (and (equal (car nth4) (car method))
4523 (equal (nth 1 nth4) (nth 1 method))))
4524 gnus-use-cross-reference
4525 (or (not (eq gnus-use-cross-reference t))
4527 ;; Only do cross-references on subscribed
4528 ;; groups, if that is what is wanted.
4529 (<= (gnus-info-level info) gnus-level-subscribed))
4530 (gnus-group-make-articles-read name idlist))))
4533 (defun gnus-compute-read-articles (group articles)
4534 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4535 (info (nth 2 entry))
4536 (active (gnus-active group))
4539 ;; First peel off all invalid article numbers.
4541 (let ((ids articles)
4543 (while (setq id (pop ids))
4544 (when (and first (> id (cdr active)))
4545 ;; We'll end up in this situation in one particular
4546 ;; obscure situation. If you re-scan a group and get
4547 ;; a new article that is cross-posted to a different
4548 ;; group that has not been re-scanned, you might get
4549 ;; crossposted article that has a higher number than
4550 ;; Gnus believes possible. So we re-activate this
4551 ;; group as well. This might mean doing the
4552 ;; crossposting thingy will *increase* the number
4553 ;; of articles in some groups. Tsk, tsk.
4554 (setq active (or (gnus-activate-group group) active)))
4555 (when (or (> id (cdr active))
4556 (< id (car active)))
4557 (setq articles (delq id articles))))))
4558 ;; If the read list is nil, we init it.
4560 (null (gnus-info-read info))
4562 (setq ninfo (cons 1 (1- (car active))))
4563 (setq ninfo (gnus-info-read info)))
4564 ;; Then we add the read articles to the range.
4566 ninfo (setq articles (sort articles '<))))))
4568 (defun gnus-group-make-articles-read (group articles)
4569 "Update the info of GROUP to say that ARTICLES are read."
4571 (entry (gnus-gethash group gnus-newsrc-hashtb))
4572 (info (nth 2 entry))
4573 (active (gnus-active group))
4576 (setq range (gnus-compute-read-articles group articles))
4578 (set-buffer gnus-group-buffer)
4581 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4582 (gnus-info-set-read ',info ',(gnus-info-read info))
4583 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4584 (gnus-group-update-group ,group t))))
4585 ;; Add the read articles to the range.
4586 (gnus-info-set-read info range)
4587 ;; Then we have to re-compute how many unread
4588 ;; articles there are in this group.
4592 (setq num (- (1+ (cdr active)) (car active))))
4593 ((not (listp (cdr range)))
4594 (setq num (- (cdr active) (- (1+ (cdr range))
4598 (if (numberp (car range))
4600 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4601 (setq range (cdr range)))
4602 (setq num (- (cdr active) num))))
4603 ;; Update the number of unread articles.
4605 ;; Update the group buffer.
4606 (gnus-group-update-group group t)))))
4608 (defvar gnus-newsgroup-none-id 0)
4610 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4611 (let ((cur nntp-server-buffer)
4614 (save-excursion (set-buffer gnus-summary-buffer)
4615 gnus-newsgroup-dependencies)))
4617 (mail-parse-charset gnus-newsgroup-charset)
4618 (mail-parse-ignored-charsets
4619 (save-excursion (condition-case nil
4620 (set-buffer gnus-summary-buffer)
4622 gnus-newsgroup-ignored-charsets)))
4624 (set-buffer nntp-server-buffer)
4625 ;; Translate all TAB characters into SPACE characters.
4626 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4627 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4628 (gnus-run-hooks 'gnus-parse-headers-hook)
4629 (let ((case-fold-search t)
4630 in-reply-to header p lines chars)
4631 (goto-char (point-min))
4632 ;; Search to the beginning of the next header. Error messages
4633 ;; do not begin with 2 or 3.
4634 (while (re-search-forward "^[23][0-9]+ " nil t)
4637 ;; This implementation of this function, with nine
4638 ;; search-forwards instead of the one re-search-forward and
4639 ;; a case (which basically was the old function) is actually
4640 ;; about twice as fast, even though it looks messier. You
4641 ;; can't have everything, I guess. Speed and elegance
4642 ;; doesn't always go hand in hand.
4651 (narrow-to-region (point)
4652 (or (and (search-forward "\n.\n" nil t)
4658 (if (search-forward "\nsubject: " nil t)
4659 (funcall gnus-decode-encoded-word-function
4660 (nnheader-header-value))
4665 (if (search-forward "\nfrom: " nil t)
4666 (funcall gnus-decode-encoded-word-function
4667 (nnheader-header-value))
4672 (if (search-forward "\ndate: " nil t)
4673 (nnheader-header-value) ""))
4677 (setq id (if (re-search-forward
4678 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4679 ;; We do it this way to make sure the Message-ID
4680 ;; is (somewhat) syntactically valid.
4681 (buffer-substring (match-beginning 1)
4683 ;; If there was no message-id, we just fake one
4684 ;; to make subsequent routines simpler.
4685 (nnheader-generate-fake-message-id))))
4689 (if (search-forward "\nreferences: " nil t)
4693 (nnheader-header-value)
4698 (search-backward ">" end t)
4701 (search-backward "<" end t)
4703 ;; Get the references from the in-reply-to header if there
4704 ;; were no references and the in-reply-to header looks
4706 (if (and (search-forward "\nin-reply-to: " nil t)
4707 (setq in-reply-to (nnheader-header-value))
4708 (string-match "<[^>]+>" in-reply-to))
4710 (setq ref (substring in-reply-to (match-beginning 0)
4712 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4713 (setq ref2 (substring in-reply-to (match-beginning 0)
4715 (when (> (length ref2) (length ref))
4722 (if (search-forward "\nchars: " nil t)
4723 (if (numberp (setq chars (ignore-errors (read cur))))
4729 (if (search-forward "\nlines: " nil t)
4730 (if (numberp (setq lines (ignore-errors (read cur))))
4736 (and (search-forward "\nxref: " nil t)
4737 (nnheader-header-value)))
4739 (when gnus-extra-headers
4740 (let ((extra gnus-extra-headers)
4744 (when (search-forward
4745 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4746 (push (cons (car extra) (nnheader-header-value))
4750 (when (equal id ref)
4753 (when gnus-alter-header-function
4754 (funcall gnus-alter-header-function header)
4755 (setq id (mail-header-id header)
4756 ref (gnus-parent-id (mail-header-references header))))
4759 (gnus-dependencies-add-header
4760 header dependencies force-new))
4761 (push header headers))
4762 (goto-char (point-max))
4764 (nreverse headers)))))
4766 ;; Goes through the xover lines and returns a list of vectors
4767 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4768 force-new dependencies
4769 group also-fetch-heads)
4770 "Parse the news overview data in the server buffer, and return a
4771 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4772 ;; Get the Xref when the users reads the articles since most/some
4773 ;; NNTP servers do not include Xrefs when using XOVER.
4774 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4775 (let ((mail-parse-charset gnus-newsgroup-charset)
4776 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4777 (cur nntp-server-buffer)
4778 (dependencies (or dependencies gnus-newsgroup-dependencies))
4779 number headers header)
4781 (set-buffer nntp-server-buffer)
4782 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4783 ;; Allow the user to mangle the headers before parsing them.
4784 (gnus-run-hooks 'gnus-parse-headers-hook)
4785 (goto-char (point-min))
4788 (while (and sequence (not (eobp)))
4789 (setq number (read cur))
4790 (while (and sequence
4791 (< (car sequence) number))
4792 (setq sequence (cdr sequence)))
4794 (eq number (car sequence))
4796 (setq sequence (cdr sequence))
4797 (setq header (inline
4798 (gnus-nov-parse-line
4799 number dependencies force-new))))
4800 (push header headers))
4803 (gnus-error 4 "Strange nov line (%d)"
4804 (count-lines (point-min) (point)))))
4806 ;; A common bug in inn is that if you have posted an article and
4807 ;; then retrieves the active file, it will answer correctly --
4808 ;; the new article is included. However, a NOV entry for the
4809 ;; article may not have been generated yet, so this may fail.
4810 ;; We work around this problem by retrieving the last few
4811 ;; headers using HEAD.
4812 (if (or (not also-fetch-heads)
4814 ;; We (probably) got all the headers.
4816 (let ((gnus-nov-is-evil t))
4819 (when (gnus-retrieve-headers sequence group)
4820 (gnus-get-newsgroup-headers))))))))
4822 (defun gnus-article-get-xrefs ()
4823 "Fill in the Xref value in `gnus-current-headers', if necessary.
4824 This is meant to be called in `gnus-article-internal-prepare-hook'."
4825 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4826 gnus-current-headers)))
4827 (or (not gnus-use-cross-reference)
4829 (and (mail-header-xref headers)
4830 (not (string= (mail-header-xref headers) "")))
4831 (let ((case-fold-search t)
4834 (nnheader-narrow-to-headers)
4835 (goto-char (point-min))
4836 (when (or (and (not (eobp))
4837 (eq (downcase (char-after)) ?x)
4838 (looking-at "Xref:"))
4839 (search-forward "\nXref:" nil t))
4840 (goto-char (1+ (match-end 0)))
4841 (setq xref (buffer-substring (point)
4842 (progn (end-of-line) (point))))
4843 (mail-header-set-xref headers xref)))))))
4845 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4846 "Find article ID and insert the summary line for that article.
4847 OLD-HEADER can either be a header or a line number to insert
4848 the subject line on."
4849 (let* ((line (and (numberp old-header) old-header))
4850 (old-header (and (vectorp old-header) old-header))
4851 (header (cond ((and old-header use-old-header)
4854 (gnus-number-to-header id))
4855 (gnus-number-to-header id))
4857 (gnus-read-header id))))
4858 (number (and (numberp id) id))
4861 ;; Rebuild the thread that this article is part of and go to the
4862 ;; article we have fetched.
4863 (when (and (not gnus-show-threads)
4866 (setq d (gnus-data-find (mail-header-number old-header))))
4867 (goto-char (gnus-data-pos d))
4870 (- (gnus-point-at-bol)
4872 (1+ (gnus-point-at-eol))
4873 (gnus-delete-line))))))
4875 (mail-header-set-number header (mail-header-number old-header)))
4876 (setq gnus-newsgroup-sparse
4877 (delq (setq number (mail-header-number header))
4878 gnus-newsgroup-sparse))
4879 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4880 (push number gnus-newsgroup-limit)
4881 (gnus-rebuild-thread (mail-header-id header) line)
4882 (gnus-summary-goto-subject number nil t))
4883 (when (and (numberp number)
4885 ;; We have to update the boundaries even if we can't fetch the
4886 ;; article if ID is a number -- so that the next `P' or `N'
4887 ;; command will fetch the previous (or next) article even
4888 ;; if the one we tried to fetch this time has been canceled.
4889 (when (> number gnus-newsgroup-end)
4890 (setq gnus-newsgroup-end number))
4891 (when (< number gnus-newsgroup-begin)
4892 (setq gnus-newsgroup-begin number))
4893 (setq gnus-newsgroup-unselected
4894 (delq number gnus-newsgroup-unselected)))
4895 ;; Report back a success?
4896 (and header (mail-header-number header))))
4898 ;;; Process/prefix in the summary buffer
4900 (defun gnus-summary-work-articles (n)
4901 "Return a list of articles to be worked upon.
4902 The prefix argument, the list of process marked articles, and the
4903 current article will be taken into consideration."
4905 (set-buffer gnus-summary-buffer)
4908 ;; A numerical prefix has been given.
4909 (setq n (prefix-numeric-value n))
4910 (let ((backward (< n 0))
4911 (n (abs (prefix-numeric-value n)))
4916 (push (setq article (gnus-summary-article-number))
4919 (gnus-summary-find-prev nil article)
4920 (gnus-summary-find-next nil article)))
4922 (nreverse articles)))
4923 ((and (gnus-region-active-p) (mark))
4924 (message "region active")
4925 ;; Work on the region between point and mark.
4926 (let ((max (max (point) (mark)))
4929 (goto-char (min (min (point) (mark))))
4932 (push (setq article (gnus-summary-article-number)) articles)
4933 (gnus-summary-find-next nil article)
4935 (nreverse articles))))
4936 (gnus-newsgroup-processable
4937 ;; There are process-marked articles present.
4938 ;; Save current state.
4939 (gnus-summary-save-process-mark)
4941 (reverse gnus-newsgroup-processable))
4943 ;; Just return the current article.
4944 (list (gnus-summary-article-number))))))
4946 (defmacro gnus-summary-iterate (arg &rest forms)
4947 "Iterate over the process/prefixed articles and do FORMS.
4948 ARG is the interactive prefix given to the command. FORMS will be
4949 executed with point over the summary line of the articles."
4950 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4951 `(let ((,articles (gnus-summary-work-articles ,arg)))
4953 (gnus-summary-goto-subject (car ,articles))
4957 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4958 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4960 (defun gnus-summary-save-process-mark ()
4961 "Push the current set of process marked articles on the stack."
4963 (push (copy-sequence gnus-newsgroup-processable)
4964 gnus-newsgroup-process-stack))
4966 (defun gnus-summary-kill-process-mark ()
4967 "Push the current set of process marked articles on the stack and unmark."
4969 (gnus-summary-save-process-mark)
4970 (gnus-summary-unmark-all-processable))
4972 (defun gnus-summary-yank-process-mark ()
4973 "Pop the last process mark state off the stack and restore it."
4975 (unless gnus-newsgroup-process-stack
4976 (error "Empty mark stack"))
4977 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4979 (defun gnus-summary-process-mark-set (set)
4980 "Make SET into the current process marked articles."
4981 (gnus-summary-unmark-all-processable)
4983 (gnus-summary-set-process-mark (pop set))))
4985 ;;; Searching and stuff
4987 (defun gnus-summary-search-group (&optional backward use-level)
4988 "Search for next unread newsgroup.
4989 If optional argument BACKWARD is non-nil, search backward instead."
4991 (set-buffer gnus-group-buffer)
4992 (when (gnus-group-search-forward
4993 backward nil (if use-level (gnus-group-group-level) nil))
4994 (gnus-group-group-name))))
4996 (defun gnus-summary-best-group (&optional exclude-group)
4997 "Find the name of the best unread group.
4998 If EXCLUDE-GROUP, do not go to this group."
5000 (set-buffer gnus-group-buffer)
5002 (gnus-group-best-unread-group exclude-group))))
5004 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5005 (if backward (gnus-summary-find-prev)
5006 (let* ((dummy (gnus-summary-article-intangible-p))
5007 (article (or article (gnus-summary-article-number)))
5008 (arts (gnus-data-find-list article))
5010 (when (and (not dummy)
5011 (or (not gnus-summary-check-current)
5013 (not (gnus-data-unread-p (car arts)))))
5014 (setq arts (cdr arts)))
5019 (when (or (and undownloaded
5020 (eq gnus-undownloaded-mark
5021 (gnus-data-mark (car arts))))
5022 (gnus-data-unread-p (car arts)))
5023 (setq result (car arts)
5025 (setq arts (cdr arts)))
5028 (goto-char (gnus-data-pos result))
5029 (gnus-data-number result)))))
5031 (defun gnus-summary-find-prev (&optional unread article)
5032 (let* ((eobp (eobp))
5033 (article (or article (gnus-summary-article-number)))
5034 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5036 (when (and (not eobp)
5037 (or (not gnus-summary-check-current)
5039 (not (gnus-data-unread-p (car arts)))))
5040 (setq arts (cdr arts)))
5045 (when (gnus-data-unread-p (car arts))
5046 (setq result (car arts)
5048 (setq arts (cdr arts)))
5051 (goto-char (gnus-data-pos result))
5052 (gnus-data-number result))))
5054 (defun gnus-summary-find-subject (subject &optional unread backward article)
5055 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5056 (article (or article (gnus-summary-article-number)))
5057 (articles (gnus-data-list backward))
5058 (arts (gnus-data-find-list article articles))
5060 (when (or (not gnus-summary-check-current)
5062 (not (gnus-data-unread-p (car arts))))
5063 (setq arts (cdr arts)))
5065 (and (or (not unread)
5066 (gnus-data-unread-p (car arts)))
5067 (vectorp (gnus-data-header (car arts)))
5069 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5070 (setq result (car arts)
5072 (setq arts (cdr arts)))
5074 (goto-char (gnus-data-pos result))
5075 (gnus-data-number result))))
5077 (defun gnus-summary-search-forward (&optional unread subject backward)
5078 "Search forward for an article.
5079 If UNREAD, look for unread articles. If SUBJECT, look for
5080 articles with that subject. If BACKWARD, search backward instead."
5081 (cond (subject (gnus-summary-find-subject subject unread backward))
5082 (backward (gnus-summary-find-prev unread))
5083 (t (gnus-summary-find-next unread))))
5085 (defun gnus-recenter (&optional n)
5086 "Center point in window and redisplay frame.
5087 Also do horizontal recentering."
5089 (when (and gnus-auto-center-summary
5090 (not (eq gnus-auto-center-summary 'vertical)))
5091 (gnus-horizontal-recenter))
5094 (defun gnus-summary-recenter ()
5095 "Center point in the summary window.
5096 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5097 displayed, no centering will be performed."
5098 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5099 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5100 (let* ((top (cond ((< (window-height) 4) 0)
5101 ((< (window-height) 7) 1)
5102 (t (if (numberp gnus-auto-center-summary)
5103 gnus-auto-center-summary
5105 (height (1- (window-height)))
5106 (bottom (save-excursion (goto-char (point-max))
5107 (forward-line (- height))
5109 (window (get-buffer-window (current-buffer))))
5110 ;; The user has to want it.
5111 (when gnus-auto-center-summary
5112 (when (get-buffer-window gnus-article-buffer)
5113 ;; Only do recentering when the article buffer is displayed,
5114 ;; Set the window start to either `bottom', which is the biggest
5115 ;; possible valid number, or the second line from the top,
5116 ;; whichever is the least.
5118 window (min bottom (save-excursion
5119 (forward-line (- top)) (point)))
5121 ;; Do horizontal recentering while we're at it.
5122 (when (and (get-buffer-window (current-buffer) t)
5123 (not (eq gnus-auto-center-summary 'vertical)))
5124 (let ((selected (selected-window)))
5125 (select-window (get-buffer-window (current-buffer) t))
5126 (gnus-summary-position-point)
5127 (gnus-horizontal-recenter)
5128 (select-window selected))))))
5130 (defun gnus-summary-jump-to-group (newsgroup)
5131 "Move point to NEWSGROUP in group mode buffer."
5132 ;; Keep update point of group mode buffer if visible.
5133 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5134 (save-window-excursion
5135 ;; Take care of tree window mode.
5136 (when (get-buffer-window gnus-group-buffer)
5137 (pop-to-buffer gnus-group-buffer))
5138 (gnus-group-jump-to-group newsgroup))
5140 ;; Take care of tree window mode.
5141 (if (get-buffer-window gnus-group-buffer)
5142 (pop-to-buffer gnus-group-buffer)
5143 (set-buffer gnus-group-buffer))
5144 (gnus-group-jump-to-group newsgroup))))
5146 ;; This function returns a list of article numbers based on the
5147 ;; difference between the ranges of read articles in this group and
5148 ;; the range of active articles.
5149 (defun gnus-list-of-unread-articles (group)
5150 (let* ((read (gnus-info-read (gnus-get-info group)))
5151 (active (or (gnus-active group) (gnus-activate-group group)))
5154 ;; If none are read, then all are unread.
5156 (setq first (car active))
5157 ;; If the range of read articles is a single range, then the
5158 ;; first unread article is the article after the last read
5159 ;; article. Sounds logical, doesn't it?
5160 (if (and (not (listp (cdr read)))
5161 (or (< (car read) (car active))
5162 (progn (setq read (list read))
5164 (setq first (max (car active) (1+ (cdr read))))
5165 ;; `read' is a list of ranges.
5166 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5169 (setq first (car active)))
5172 (while (< first nlast)
5174 (setq first (1+ first))))
5175 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5176 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5177 (setq read (cdr read)))))
5178 ;; And add the last unread articles.
5179 (while (<= first last)
5181 (setq first (1+ first)))
5182 ;; Return the list of unread articles.
5183 (delq 0 (nreverse unread))))
5185 (defun gnus-list-of-read-articles (group)
5186 "Return a list of unread, unticked and non-dormant articles."
5187 (let* ((info (gnus-get-info group))
5188 (marked (gnus-info-marks info))
5189 (active (gnus-active group)))
5191 (gnus-set-difference
5192 (gnus-sorted-complement
5193 (gnus-uncompress-range active)
5194 (gnus-list-of-unread-articles group))
5196 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5197 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5199 ;; Various summary commands
5201 (defun gnus-summary-select-article-buffer ()
5202 "Reconfigure windows to show article buffer."
5204 (if (not (gnus-buffer-live-p gnus-article-buffer))
5205 (error "There is no article buffer for this summary buffer")
5206 (gnus-configure-windows 'article)
5207 (select-window (get-buffer-window gnus-article-buffer))))
5209 (defun gnus-summary-universal-argument (arg)
5210 "Perform any operation on all articles that are process/prefixed."
5212 (let ((articles (gnus-summary-work-articles arg))
5219 (substitute-command-keys
5220 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5222 (gnus-error 1 "Undefined key")
5225 (gnus-summary-goto-subject (setq article (pop articles)))
5226 (let (gnus-newsgroup-processable)
5227 (command-execute func))
5228 (gnus-summary-remove-process-mark article)))))
5229 (gnus-summary-position-point))
5231 (defun gnus-summary-toggle-truncation (&optional arg)
5232 "Toggle truncation of summary lines.
5233 With arg, turn line truncation on iff arg is positive."
5235 (setq truncate-lines
5236 (if (null arg) (not truncate-lines)
5237 (> (prefix-numeric-value arg) 0)))
5240 (defun gnus-summary-reselect-current-group (&optional all rescan)
5241 "Exit and then reselect the current newsgroup.
5242 The prefix argument ALL means to select all articles."
5244 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5245 (error "Ephemeral groups can't be reselected"))
5246 (let ((current-subject (gnus-summary-article-number))
5247 (group gnus-newsgroup-name))
5248 (setq gnus-newsgroup-begin nil)
5250 ;; We have to adjust the point of group mode buffer because
5251 ;; point was moved to the next unread newsgroup by exiting.
5252 (gnus-summary-jump-to-group group)
5255 (gnus-group-get-new-news-this-group 1)))
5256 (gnus-group-read-group all t)
5257 (gnus-summary-goto-subject current-subject nil t)))
5259 (defun gnus-summary-rescan-group (&optional all)
5260 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5262 (gnus-summary-reselect-current-group all t))
5264 (defun gnus-summary-update-info (&optional non-destructive)
5266 (let ((group gnus-newsgroup-name))
5268 (when gnus-newsgroup-kill-headers
5269 (setq gnus-newsgroup-killed
5270 (gnus-compress-sequence
5272 (gnus-set-sorted-intersection
5273 (gnus-uncompress-range gnus-newsgroup-killed)
5274 (setq gnus-newsgroup-unselected
5275 (sort gnus-newsgroup-unselected '<)))
5276 (setq gnus-newsgroup-unreads
5277 (sort gnus-newsgroup-unreads '<)))
5279 (unless (listp (cdr gnus-newsgroup-killed))
5280 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5281 (let ((headers gnus-newsgroup-headers))
5282 ;; Set the new ranges of read articles.
5284 (set-buffer gnus-group-buffer)
5285 (gnus-undo-force-boundary))
5286 (gnus-update-read-articles
5287 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5288 ;; Set the current article marks.
5289 (let ((gnus-newsgroup-scored
5290 (if (and (not gnus-save-score)
5291 (not non-destructive))
5293 gnus-newsgroup-scored)))
5295 (gnus-update-marks)))
5296 ;; Do the cross-ref thing.
5297 (when gnus-use-cross-reference
5298 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5299 ;; Do not switch windows but change the buffer to work.
5300 (set-buffer gnus-group-buffer)
5301 (unless (gnus-ephemeral-group-p group)
5302 (gnus-group-update-group group)))))))
5304 (defun gnus-summary-save-newsrc (&optional force)
5305 "Save the current number of read/marked articles in the dribble buffer.
5306 The dribble buffer will then be saved.
5307 If FORCE (the prefix), also save the .newsrc file(s)."
5309 (gnus-summary-update-info t)
5311 (gnus-save-newsrc-file)
5312 (gnus-dribble-save)))
5314 (defun gnus-summary-exit (&optional temporary)
5315 "Exit reading current newsgroup, and then return to group selection mode.
5316 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5318 (gnus-set-global-variables)
5319 (when (gnus-buffer-live-p gnus-article-buffer)
5321 (set-buffer gnus-article-buffer)
5322 (mm-destroy-parts gnus-article-mime-handles)))
5323 (gnus-kill-save-kill-buffer)
5324 (gnus-async-halt-prefetch)
5325 (let* ((group gnus-newsgroup-name)
5326 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5329 (buf (current-buffer)))
5331 ;; Do adaptive scoring, and possibly save score files.
5332 (when gnus-newsgroup-adaptive
5333 (gnus-score-adaptive))
5334 (when gnus-use-scoring
5336 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5337 ;; If we have several article buffers, we kill them at exit.
5338 (unless gnus-single-article-buffer
5339 (gnus-kill-buffer gnus-original-article-buffer)
5340 (setq gnus-article-current nil))
5341 (when gnus-use-cache
5342 (gnus-cache-possibly-remove-articles)
5343 (gnus-cache-save-buffers))
5344 (gnus-async-prefetch-remove-group group)
5345 (when gnus-suppress-duplicates
5346 (gnus-dup-enter-articles))
5347 (when gnus-use-trees
5348 (gnus-tree-close group))
5349 (when gnus-use-cache
5350 (gnus-cache-write-active))
5351 ;; Remove entries for this group.
5352 (nnmail-purge-split-history (gnus-group-real-name group))
5353 ;; Make all changes in this group permanent.
5355 (gnus-run-hooks 'gnus-exit-group-hook)
5356 (gnus-summary-update-info))
5357 (gnus-close-group group)
5358 ;; Make sure where we were, and go to next newsgroup.
5359 (set-buffer gnus-group-buffer)
5361 (gnus-group-jump-to-group group))
5362 (gnus-run-hooks 'gnus-summary-exit-hook)
5363 (unless (or quit-config
5364 ;; If this group has disappeared from the summary
5365 ;; buffer, don't skip forwards.
5366 (not (string= group (gnus-group-group-name))))
5367 (gnus-group-next-unread-group 1))
5368 (setq group-point (point))
5371 ;; If we have several article buffers, we kill them at exit.
5372 (unless gnus-single-article-buffer
5373 (gnus-kill-buffer gnus-article-buffer)
5374 (gnus-kill-buffer gnus-original-article-buffer)
5375 (setq gnus-article-current nil))
5377 (if (not gnus-kill-summary-on-exit)
5378 (gnus-deaden-summary)
5379 ;; We set all buffer-local variables to nil. It is unclear why
5380 ;; this is needed, but if we don't, buffer-local variables are
5381 ;; not garbage-collected, it seems. This would the lead to en
5382 ;; ever-growing Emacs.
5383 (gnus-summary-clear-local-variables)
5384 (when (get-buffer gnus-article-buffer)
5385 (bury-buffer gnus-article-buffer))
5386 ;; We clear the global counterparts of the buffer-local
5387 ;; variables as well, just to be on the safe side.
5388 (set-buffer gnus-group-buffer)
5389 (gnus-summary-clear-local-variables)
5390 ;; Return to group mode buffer.
5391 (when (eq mode 'gnus-summary-mode)
5392 (gnus-kill-buffer buf)))
5393 (setq gnus-current-select-method gnus-select-method)
5394 (pop-to-buffer gnus-group-buffer)
5395 (if (not quit-config)
5397 (goto-char group-point)
5398 (gnus-configure-windows 'group 'force))
5399 (gnus-handle-ephemeral-exit quit-config))
5400 ;; Clear the current group name.
5402 (setq gnus-newsgroup-name nil)))))
5404 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5405 (defun gnus-summary-exit-no-update (&optional no-questions)
5406 "Quit reading current newsgroup without updating read article info."
5408 (let* ((group gnus-newsgroup-name)
5409 (quit-config (gnus-group-quit-config group)))
5410 (when (or no-questions
5412 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5413 (gnus-async-halt-prefetch)
5415 (delq 'gnus-summary-expire-articles
5416 (copy-sequence gnus-summary-prepare-exit-hook)))
5417 (when (gnus-buffer-live-p gnus-article-buffer)
5419 (set-buffer gnus-article-buffer)
5420 (mm-destroy-parts gnus-article-mime-handles)))
5421 ;; If we have several article buffers, we kill them at exit.
5422 (unless gnus-single-article-buffer
5423 (gnus-kill-buffer gnus-article-buffer)
5424 (gnus-kill-buffer gnus-original-article-buffer)
5425 (setq gnus-article-current nil))
5426 (if (not gnus-kill-summary-on-exit)
5427 (gnus-deaden-summary)
5428 (gnus-close-group group)
5429 (gnus-summary-clear-local-variables)
5430 (set-buffer gnus-group-buffer)
5431 (gnus-summary-clear-local-variables)
5432 (when (get-buffer gnus-summary-buffer)
5433 (kill-buffer gnus-summary-buffer)))
5434 (unless gnus-single-article-buffer
5435 (setq gnus-article-current nil))
5436 (when gnus-use-trees
5437 (gnus-tree-close group))
5438 (gnus-async-prefetch-remove-group group)
5439 (when (get-buffer gnus-article-buffer)
5440 (bury-buffer gnus-article-buffer))
5441 ;; Return to the group buffer.
5442 (gnus-configure-windows 'group 'force)
5443 ;; Clear the current group name.
5444 (setq gnus-newsgroup-name nil)
5445 (when (equal (gnus-group-group-name) group)
5446 (gnus-group-next-unread-group 1))
5448 (gnus-handle-ephemeral-exit quit-config)))))
5450 (defun gnus-handle-ephemeral-exit (quit-config)
5451 "Handle movement when leaving an ephemeral group.
5452 The state which existed when entering the ephemeral is reset."
5453 (if (not (buffer-name (car quit-config)))
5454 (gnus-configure-windows 'group 'force)
5455 (set-buffer (car quit-config))
5456 (cond ((eq major-mode 'gnus-summary-mode)
5457 (gnus-set-global-variables))
5458 ((eq major-mode 'gnus-article-mode)
5460 ;; The `gnus-summary-buffer' variable may point
5461 ;; to the old summary buffer when using a single
5463 (unless (gnus-buffer-live-p gnus-summary-buffer)
5464 (set-buffer gnus-group-buffer))
5465 (set-buffer gnus-summary-buffer)
5466 (gnus-set-global-variables))))
5467 (if (or (eq (cdr quit-config) 'article)
5468 (eq (cdr quit-config) 'pick))
5470 ;; The current article may be from the ephemeral group
5471 ;; thus it is best that we reload this article
5472 (gnus-summary-show-article)
5473 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5474 (gnus-configure-windows 'pick 'force)
5475 (gnus-configure-windows (cdr quit-config) 'force)))
5476 (gnus-configure-windows (cdr quit-config) 'force))
5477 (when (eq major-mode 'gnus-summary-mode)
5478 (gnus-summary-next-subject 1 nil t)
5479 (gnus-summary-recenter)
5480 (gnus-summary-position-point))))
5484 (defvar gnus-dead-summary-mode-map nil)
5486 (unless gnus-dead-summary-mode-map
5487 (setq gnus-dead-summary-mode-map (make-keymap))
5488 (suppress-keymap gnus-dead-summary-mode-map)
5489 (substitute-key-definition
5490 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5491 (let ((keys '("\C-d" "\r" "\177" [delete])))
5493 (define-key gnus-dead-summary-mode-map
5494 (pop keys) 'gnus-summary-wake-up-the-dead))))
5496 (defvar gnus-dead-summary-mode nil
5497 "Minor mode for Gnus summary buffers.")
5499 (defun gnus-dead-summary-mode (&optional arg)
5500 "Minor mode for Gnus summary buffers."
5502 (when (eq major-mode 'gnus-summary-mode)
5503 (make-local-variable 'gnus-dead-summary-mode)
5504 (setq gnus-dead-summary-mode
5505 (if (null arg) (not gnus-dead-summary-mode)
5506 (> (prefix-numeric-value arg) 0)))
5507 (when gnus-dead-summary-mode
5508 (gnus-add-minor-mode
5509 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5511 (defun gnus-deaden-summary ()
5512 "Make the current summary buffer into a dead summary buffer."
5513 ;; Kill any previous dead summary buffer.
5514 (when (and gnus-dead-summary
5515 (buffer-name gnus-dead-summary))
5517 (set-buffer gnus-dead-summary)
5518 (when gnus-dead-summary-mode
5519 (kill-buffer (current-buffer)))))
5520 ;; Make this the current dead summary.
5521 (setq gnus-dead-summary (current-buffer))
5522 (gnus-dead-summary-mode 1)
5523 (let ((name (buffer-name)))
5524 (when (string-match "Summary" name)
5526 (concat (substring name 0 (match-beginning 0)) "Dead "
5527 (substring name (match-beginning 0)))
5530 (defun gnus-kill-or-deaden-summary (buffer)
5531 "Kill or deaden the summary BUFFER."
5533 (when (and (buffer-name buffer)
5534 (not gnus-single-article-buffer))
5537 (gnus-kill-buffer gnus-article-buffer)
5538 (gnus-kill-buffer gnus-original-article-buffer)))
5539 (cond (gnus-kill-summary-on-exit
5540 (when (and gnus-use-trees
5541 (gnus-buffer-exists-p buffer))
5544 (gnus-tree-close gnus-newsgroup-name)))
5545 (gnus-kill-buffer buffer))
5546 ((gnus-buffer-exists-p buffer)
5549 (gnus-deaden-summary))))))
5551 (defun gnus-summary-wake-up-the-dead (&rest args)
5552 "Wake up the dead summary buffer."
5554 (gnus-dead-summary-mode -1)
5555 (let ((name (buffer-name)))
5556 (when (string-match "Dead " name)
5558 (concat (substring name 0 (match-beginning 0))
5559 (substring name (match-end 0)))
5561 (gnus-message 3 "This dead summary is now alive again"))
5563 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5564 (defun gnus-summary-fetch-faq (&optional faq-dir)
5565 "Fetch the FAQ for the current group.
5566 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5570 (when current-prefix-arg
5572 "Faq dir: " (and (listp gnus-group-faq-directory)
5573 (mapcar (lambda (file) (list file))
5574 gnus-group-faq-directory))))))
5575 (let (gnus-faq-buffer)
5576 (when (setq gnus-faq-buffer
5577 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5578 (gnus-configure-windows 'summary-faq))))
5580 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5581 (defun gnus-summary-describe-group (&optional force)
5582 "Describe the current newsgroup."
5584 (gnus-group-describe-group force gnus-newsgroup-name))
5586 (defun gnus-summary-describe-briefly ()
5587 "Describe summary mode commands briefly."
5589 (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")))
5591 ;; Walking around group mode buffer from summary mode.
5593 (defun gnus-summary-next-group (&optional no-article target-group backward)
5594 "Exit current newsgroup and then select next unread newsgroup.
5595 If prefix argument NO-ARTICLE is non-nil, no article is selected
5596 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5597 previous group instead."
5599 ;; Stop pre-fetching.
5600 (gnus-async-halt-prefetch)
5601 (let ((current-group gnus-newsgroup-name)
5602 (current-buffer (current-buffer))
5604 ;; First we semi-exit this group to update Xrefs and all variables.
5605 ;; We can't do a real exit, because the window conf must remain
5606 ;; the same in case the user is prompted for info, and we don't
5607 ;; want the window conf to change before that...
5608 (gnus-summary-exit t)
5609 (while (not entered)
5610 ;; Then we find what group we are supposed to enter.
5611 (set-buffer gnus-group-buffer)
5612 (gnus-group-jump-to-group current-group)
5615 (if (eq gnus-keep-same-level 'best)
5616 (gnus-summary-best-group gnus-newsgroup-name)
5617 (gnus-summary-search-group backward gnus-keep-same-level))))
5618 (if (not target-group)
5619 ;; There are no further groups, so we return to the group
5622 (gnus-message 5 "Returning to the group buffer")
5624 (when (gnus-buffer-live-p current-buffer)
5625 (set-buffer current-buffer)
5626 (gnus-summary-exit))
5627 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5628 ;; We try to enter the target group.
5629 (gnus-group-jump-to-group target-group)
5630 (let ((unreads (gnus-group-group-unread)))
5631 (if (and (or (eq t unreads)
5632 (and unreads (not (zerop unreads))))
5633 (gnus-summary-read-group
5634 target-group nil no-article
5635 (and (buffer-name current-buffer) current-buffer)
5638 (setq current-group target-group
5639 target-group nil)))))))
5641 (defun gnus-summary-prev-group (&optional no-article)
5642 "Exit current newsgroup and then select previous unread newsgroup.
5643 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5645 (gnus-summary-next-group no-article nil t))
5647 ;; Walking around summary lines.
5649 (defun gnus-summary-first-subject (&optional unread undownloaded)
5650 "Go to the first unread subject.
5651 If UNREAD is non-nil, go to the first unread article.
5652 Returns the article selected or nil if there are no unread articles."
5657 ((null gnus-newsgroup-data)
5658 (gnus-message 3 "No articles in the group")
5660 ;; Pick the first article.
5662 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5663 (gnus-data-number (car gnus-newsgroup-data)))
5664 ;; No unread articles.
5665 ((null gnus-newsgroup-unreads)
5666 (gnus-message 3 "No more unread articles")
5668 ;; Find the first unread article.
5670 (let ((data gnus-newsgroup-data))
5672 (and (not (and undownloaded
5673 (eq gnus-undownloaded-mark
5674 (gnus-data-mark (car data)))))
5675 (not (gnus-data-unread-p (car data)))))
5676 (setq data (cdr data)))
5678 (goto-char (gnus-data-pos (car data)))
5679 (gnus-data-number (car data))))))
5680 (gnus-summary-position-point)))
5682 (defun gnus-summary-next-subject (n &optional unread dont-display)
5683 "Go to next N'th summary line.
5684 If N is negative, go to the previous N'th subject line.
5685 If UNREAD is non-nil, only unread articles are selected.
5686 The difference between N and the actual number of steps taken is
5689 (let ((backward (< n 0))
5693 (gnus-summary-find-prev unread)
5694 (gnus-summary-find-next unread)))
5695 (gnus-summary-show-thread)
5698 (gnus-message 7 "No more%s articles"
5699 (if unread " unread" "")))
5700 (unless dont-display
5701 (gnus-summary-recenter)
5702 (gnus-summary-position-point))
5705 (defun gnus-summary-next-unread-subject (n)
5706 "Go to next N'th unread summary line."
5708 (gnus-summary-next-subject n t))
5710 (defun gnus-summary-prev-subject (n &optional unread)
5711 "Go to previous N'th summary line.
5712 If optional argument UNREAD is non-nil, only unread article is selected."
5714 (gnus-summary-next-subject (- n) unread))
5716 (defun gnus-summary-prev-unread-subject (n)
5717 "Go to previous N'th unread summary line."
5719 (gnus-summary-next-subject (- n) t))
5721 (defun gnus-summary-goto-subject (article &optional force silent)
5722 "Go the subject line of ARTICLE.
5723 If FORCE, also allow jumping to articles not currently shown."
5724 (interactive "nArticle number: ")
5726 (data (gnus-data-find article)))
5727 ;; We read in the article if we have to.
5730 (gnus-summary-insert-subject
5732 (if (or (numberp force) (vectorp force)) force)
5734 (setq data (gnus-data-find article)))
5739 (gnus-message 3 "Can't find article %d" article))
5741 (goto-char (gnus-data-pos data))
5742 (gnus-summary-position-point)
5745 ;; Walking around summary lines with displaying articles.
5747 (defun gnus-summary-expand-window (&optional arg)
5748 "Make the summary buffer take up the entire Emacs frame.
5749 Given a prefix, will force an `article' buffer configuration."
5752 (gnus-configure-windows 'article 'force)
5753 (gnus-configure-windows 'summary 'force)))
5755 (defun gnus-summary-display-article (article &optional all-header)
5756 "Display ARTICLE in article buffer."
5757 (gnus-set-global-variables)
5761 (if gnus-summary-display-article-function
5762 (funcall gnus-summary-display-article-function article all-header)
5763 (gnus-article-prepare article all-header))
5764 (gnus-run-hooks 'gnus-select-article-hook)
5765 (when (and gnus-current-article
5766 (not (zerop gnus-current-article)))
5767 (gnus-summary-goto-subject gnus-current-article))
5768 (gnus-summary-recenter)
5769 (when (and gnus-use-trees gnus-show-threads)
5770 (gnus-possibly-generate-tree article)
5771 (gnus-highlight-selected-tree article))
5772 ;; Successfully display article.
5773 (gnus-article-set-window-start
5774 (cdr (assq article gnus-newsgroup-bookmarks))))))
5776 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5777 "Select the current article.
5778 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5779 non-nil, the article will be re-fetched even if it already present in
5780 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5782 ;; Make sure we are in the summary buffer to work around bbdb bug.
5783 (unless (eq major-mode 'gnus-summary-mode)
5784 (set-buffer gnus-summary-buffer))
5785 (let ((article (or article (gnus-summary-article-number)))
5786 (all-headers (not (not all-headers))) ;Must be T or NIL.
5787 gnus-summary-display-article-function
5790 (gnus-summary-article-pseudo-p article)
5791 (error "This is a pseudo-article"))
5794 (set-buffer gnus-summary-buffer)
5795 (if (or (and gnus-single-article-buffer
5796 (or (null gnus-current-article)
5797 (null gnus-article-current)
5798 (null (get-buffer gnus-article-buffer))
5799 (not (eq article (cdr gnus-article-current)))
5800 (not (equal (car gnus-article-current)
5801 gnus-newsgroup-name))))
5802 (and (not gnus-single-article-buffer)
5803 (or (null gnus-current-article)
5804 (not (eq gnus-current-article article))))
5806 ;; The requested article is different from the current article.
5808 (gnus-summary-display-article article all-headers)
5810 (when (or all-headers gnus-show-all-headers)
5811 (gnus-article-show-all-headers)))
5812 (when (or all-headers gnus-show-all-headers)
5813 (gnus-article-show-all-headers))
5816 (gnus-article-set-window-start
5817 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5819 (defun gnus-summary-set-current-mark (&optional current-mark)
5820 "Obsolete function."
5823 (defun gnus-summary-next-article (&optional unread subject backward push)
5824 "Select the next article.
5825 If UNREAD, only unread articles are selected.
5826 If SUBJECT, only articles with SUBJECT are selected.
5827 If BACKWARD, the previous article is selected instead of the next."
5830 ;; Is there such an article?
5831 ((and (gnus-summary-search-forward unread subject backward)
5832 (or (gnus-summary-display-article (gnus-summary-article-number))
5833 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5834 (gnus-summary-position-point))
5835 ;; If not, we try the first unread, if that is wanted.
5837 gnus-auto-select-same
5838 (gnus-summary-first-unread-article))
5839 (gnus-summary-position-point)
5840 (gnus-message 6 "Wrapped"))
5841 ;; Try to get next/previous article not displayed in this group.
5842 ((and gnus-auto-extend-newsgroup
5843 (not unread) (not subject))
5844 (gnus-summary-goto-article
5845 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5846 nil (count-lines (point-min) (point))))
5847 ;; Go to next/previous group.
5849 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5850 (gnus-summary-jump-to-group gnus-newsgroup-name))
5851 (let ((cmd last-command-char)
5854 (set-buffer gnus-group-buffer)
5857 (if (eq gnus-keep-same-level 'best)
5858 (gnus-summary-best-group gnus-newsgroup-name)
5859 (gnus-summary-search-group backward gnus-keep-same-level))))
5860 ;; For some reason, the group window gets selected. We change
5862 (select-window (get-buffer-window (current-buffer)))
5863 ;; Select next unread newsgroup automagically.
5865 ((or (not gnus-auto-select-next)
5867 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5868 ((or (eq gnus-auto-select-next 'quietly)
5869 (and (eq gnus-auto-select-next 'slightly-quietly)
5871 (and (eq gnus-auto-select-next 'almost-quietly)
5872 (gnus-summary-last-article-p)))
5874 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5876 (gnus-message 7 "No more%s articles (%s)..."
5877 (if unread " unread" "")
5878 (if group (concat "selecting " group)
5880 (gnus-summary-next-group nil group backward)))
5882 (when (gnus-key-press-event-p last-input-event)
5883 (gnus-summary-walk-group-buffer
5884 gnus-newsgroup-name cmd unread backward point))))))))
5886 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5887 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5888 (?\C-p (gnus-group-prev-unread-group 1))))
5889 (cursor-in-echo-area t)
5890 keve key group ended)
5892 (set-buffer gnus-group-buffer)
5895 (if (eq gnus-keep-same-level 'best)
5896 (gnus-summary-best-group gnus-newsgroup-name)
5897 (gnus-summary-search-group backward gnus-keep-same-level))))
5900 5 "No more%s articles%s" (if unread " unread" "")
5902 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5903 (format " (Type %s for %s [%s])"
5904 (single-key-description cmd) group
5905 (car (gnus-gethash group gnus-newsrc-hashtb)))
5906 (format " (Type %s to exit %s)"
5907 (single-key-description cmd)
5908 gnus-newsgroup-name)))
5909 ;; Confirm auto selection.
5910 (setq key (car (setq keve (gnus-read-event-char))))
5913 ((assq key keystrokes)
5914 (let ((obuf (current-buffer)))
5915 (switch-to-buffer gnus-group-buffer)
5917 (gnus-group-jump-to-group group))
5918 (eval (cadr (assq key keystrokes)))
5919 (setq group (gnus-group-group-name))
5920 (switch-to-buffer obuf))
5924 (gnus-ephemeral-group-p gnus-newsgroup-name))
5926 (gnus-summary-next-group nil group backward)))
5928 (push (cdr keve) unread-command-events))))))
5930 (defun gnus-summary-next-unread-article ()
5931 "Select unread article after current one."
5933 (gnus-summary-next-article
5934 (or (not (eq gnus-summary-goto-unread 'never))
5935 (gnus-summary-last-article-p (gnus-summary-article-number)))
5936 (and gnus-auto-select-same
5937 (gnus-summary-article-subject))))
5939 (defun gnus-summary-prev-article (&optional unread subject)
5940 "Select the article after the current one.
5941 If UNREAD is non-nil, only unread articles are selected."
5943 (gnus-summary-next-article unread subject t))
5945 (defun gnus-summary-prev-unread-article ()
5946 "Select unread article before current one."
5948 (gnus-summary-prev-article
5949 (or (not (eq gnus-summary-goto-unread 'never))
5950 (gnus-summary-first-article-p (gnus-summary-article-number)))
5951 (and gnus-auto-select-same
5952 (gnus-summary-article-subject))))
5954 (defun gnus-summary-next-page (&optional lines circular)
5955 "Show next page of the selected article.
5956 If at the end of the current article, select the next article.
5957 LINES says how many lines should be scrolled up.
5959 If CIRCULAR is non-nil, go to the start of the article instead of
5960 selecting the next article when reaching the end of the current
5963 (setq gnus-summary-buffer (current-buffer))
5964 (gnus-set-global-variables)
5965 (let ((article (gnus-summary-article-number))
5966 (article-window (get-buffer-window gnus-article-buffer t))
5968 ;; If the buffer is empty, we have no article.
5970 (error "No article to select"))
5971 (gnus-configure-windows 'article)
5972 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5973 (if (and (eq gnus-summary-goto-unread 'never)
5974 (not (gnus-summary-last-article-p article)))
5975 (gnus-summary-next-article)
5976 (gnus-summary-next-unread-article))
5977 (if (or (null gnus-current-article)
5978 (null gnus-article-current)
5979 (/= article (cdr gnus-article-current))
5980 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5981 ;; Selected subject is different from current article's.
5982 (gnus-summary-display-article article)
5983 (when article-window
5984 (gnus-eval-in-buffer-window gnus-article-buffer
5985 (setq endp (gnus-article-next-page lines)))
5988 (gnus-summary-beginning-of-article))
5990 (gnus-message 3 "End of message"))
5992 (if (and (eq gnus-summary-goto-unread 'never)
5993 (not (gnus-summary-last-article-p article)))
5994 (gnus-summary-next-article)
5995 (gnus-summary-next-unread-article))))))))
5996 (gnus-summary-recenter)
5997 (gnus-summary-position-point)))
5999 (defun gnus-summary-prev-page (&optional lines move)
6000 "Show previous page of selected article.
6001 Argument LINES specifies lines to be scrolled down.
6002 If MOVE, move to the previous unread article if point is at
6003 the beginning of the buffer."
6005 (let ((article (gnus-summary-article-number))
6006 (article-window (get-buffer-window gnus-article-buffer t))
6008 (gnus-configure-windows 'article)
6009 (if (or (null gnus-current-article)
6010 (null gnus-article-current)
6011 (/= article (cdr gnus-article-current))
6012 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6013 ;; Selected subject is different from current article's.
6014 (gnus-summary-display-article article)
6015 (gnus-summary-recenter)
6016 (when article-window
6017 (gnus-eval-in-buffer-window gnus-article-buffer
6018 (setq endp (gnus-article-prev-page lines)))
6019 (when (and move endp)
6021 (gnus-message 3 "Beginning of message"))
6023 (if (and (eq gnus-summary-goto-unread 'never)
6024 (not (gnus-summary-first-article-p article)))
6025 (gnus-summary-prev-article)
6026 (gnus-summary-prev-unread-article))))))))
6027 (gnus-summary-position-point))
6029 (defun gnus-summary-prev-page-or-article (&optional lines)
6030 "Show previous page of selected article.
6031 Argument LINES specifies lines to be scrolled down.
6032 If at the beginning of the article, go to the next article."
6034 (gnus-summary-prev-page lines t))
6036 (defun gnus-summary-scroll-up (lines)
6037 "Scroll up (or down) one line current article.
6038 Argument LINES specifies lines to be scrolled up (or down if negative)."
6040 (gnus-configure-windows 'article)
6041 (gnus-summary-show-thread)
6042 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6043 (gnus-eval-in-buffer-window gnus-article-buffer
6045 (when (gnus-article-next-page lines)
6046 (gnus-message 3 "End of message")))
6048 (gnus-article-prev-page (- lines))))))
6049 (gnus-summary-recenter)
6050 (gnus-summary-position-point))
6052 (defun gnus-summary-scroll-down (lines)
6053 "Scroll down (or up) one line current article.
6054 Argument LINES specifies lines to be scrolled down (or up if negative)."
6056 (gnus-summary-scroll-up (- lines)))
6058 (defun gnus-summary-next-same-subject ()
6059 "Select next article which has the same subject as current one."
6061 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6063 (defun gnus-summary-prev-same-subject ()
6064 "Select previous article which has the same subject as current one."
6066 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6068 (defun gnus-summary-next-unread-same-subject ()
6069 "Select next unread article which has the same subject as current one."
6071 (gnus-summary-next-article t (gnus-summary-article-subject)))
6073 (defun gnus-summary-prev-unread-same-subject ()
6074 "Select previous unread article which has the same subject as current one."
6076 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6078 (defun gnus-summary-first-unread-article ()
6079 "Select the first unread article.
6080 Return nil if there are no unread articles."
6083 (when (gnus-summary-first-subject t)
6084 (gnus-summary-show-thread)
6085 (gnus-summary-first-subject t)
6086 (gnus-summary-display-article (gnus-summary-article-number)))
6087 (gnus-summary-position-point)))
6089 (defun gnus-summary-first-unread-subject ()
6090 "Place the point on the subject line of the first unread article.
6091 Return nil if there are no unread articles."
6094 (when (gnus-summary-first-subject t)
6095 (gnus-summary-show-thread)
6096 (gnus-summary-first-subject t))
6097 (gnus-summary-position-point)))
6099 (defun gnus-summary-first-article ()
6100 "Select the first article.
6101 Return nil if there are no articles."
6104 (when (gnus-summary-first-subject)
6105 (gnus-summary-show-thread)
6106 (gnus-summary-first-subject)
6107 (gnus-summary-display-article (gnus-summary-article-number)))
6108 (gnus-summary-position-point)))
6110 (defun gnus-summary-best-unread-article ()
6111 "Select the unread article with the highest score."
6113 (let ((best -1000000)
6114 (data gnus-newsgroup-data)
6117 (and (gnus-data-unread-p (car data))
6119 (gnus-summary-article-score (gnus-data-number (car data))))
6122 article (gnus-data-number (car data))))
6123 (setq data (cdr data)))
6126 (gnus-summary-goto-article article)
6127 (error "No unread articles"))
6128 (gnus-summary-position-point))))
6130 (defun gnus-summary-last-subject ()
6131 "Go to the last displayed subject line in the group."
6132 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6134 (gnus-summary-goto-subject article))))
6136 (defun gnus-summary-goto-article (article &optional all-headers force)
6137 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6138 If ALL-HEADERS is non-nil, no header lines are hidden.
6139 If FORCE, go to the article even if it isn't displayed. If FORCE
6140 is a number, it is the line the article is to be displayed on."
6144 "Article number or Message-ID: "
6145 (mapcar (lambda (number) (list (int-to-string number)))
6146 gnus-newsgroup-limit))
6150 (if (and (stringp article)
6151 (string-match "@" article))
6152 (gnus-summary-refer-article article)
6153 (when (stringp article)
6154 (setq article (string-to-number article)))
6155 (if (gnus-summary-goto-subject article force)
6156 (gnus-summary-display-article article all-headers)
6157 (gnus-message 4 "Couldn't go to article %s" article) nil))
6158 (gnus-summary-position-point)))
6160 (defun gnus-summary-goto-last-article ()
6161 "Go to the previously read article."
6164 (when gnus-last-article
6165 (gnus-summary-goto-article gnus-last-article nil t))
6166 (gnus-summary-position-point)))
6168 (defun gnus-summary-pop-article (number)
6169 "Pop one article off the history and go to the previous.
6170 NUMBER articles will be popped off."
6173 (setq gnus-newsgroup-history
6174 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6176 (gnus-summary-goto-article (car to) nil t)
6177 (error "Article history empty")))
6178 (gnus-summary-position-point))
6180 ;; Summary commands and functions for limiting the summary buffer.
6182 (defun gnus-summary-limit-to-articles (n)
6183 "Limit the summary buffer to the next N articles.
6184 If not given a prefix, use the process marked articles instead."
6187 (let ((articles (gnus-summary-work-articles n)))
6188 (setq gnus-newsgroup-processable nil)
6189 (gnus-summary-limit articles))
6190 (gnus-summary-position-point)))
6192 (defun gnus-summary-pop-limit (&optional total)
6193 "Restore the previous limit.
6194 If given a prefix, remove all limits."
6197 (setq gnus-newsgroup-limits
6198 (list (mapcar (lambda (h) (mail-header-number h))
6199 gnus-newsgroup-headers))))
6200 (unless gnus-newsgroup-limits
6201 (error "No limit to pop"))
6203 (gnus-summary-limit nil 'pop)
6204 (gnus-summary-position-point)))
6206 (defun gnus-summary-limit-to-subject (subject &optional header)
6207 "Limit the summary buffer to articles that have subjects that match a regexp."
6208 (interactive "sLimit to subject (regexp): ")
6210 (setq header "subject"))
6211 (when (not (equal "" subject))
6213 (let ((articles (gnus-summary-find-matching
6214 (or header "subject") subject 'all)))
6216 (error "Found no matches for \"%s\"" subject))
6217 (gnus-summary-limit articles))
6218 (gnus-summary-position-point))))
6220 (defun gnus-summary-limit-to-author (from)
6221 "Limit the summary buffer to articles that have authors that match a regexp."
6222 (interactive "sLimit to author (regexp): ")
6223 (gnus-summary-limit-to-subject from "from"))
6225 (defun gnus-summary-limit-to-age (age &optional younger-p)
6226 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6227 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6228 articles that are younger than AGE days."
6230 (let ((younger current-prefix-arg)
6233 (while (not days-got)
6234 (setq days (if younger
6235 (read-string "Limit to articles within (in days): ")
6236 (read-string "Limit to articles old than (in days): ")))
6237 (when (> (length days) 0)
6238 (setq days (read days)))
6241 (message "Please enter a number.")
6243 (list days younger)))
6245 (let ((data gnus-newsgroup-data)
6246 (cutoff (days-to-time age))
6247 articles d date is-younger)
6248 (while (setq d (pop data))
6249 (when (and (vectorp (gnus-data-header d))
6250 (setq date (mail-header-date (gnus-data-header d))))
6251 (setq is-younger (time-less-p
6252 (time-since (condition-case ()
6259 (push (gnus-data-number d) articles))))
6260 (gnus-summary-limit (nreverse articles)))
6261 (gnus-summary-position-point)))
6263 (defun gnus-summary-limit-to-extra (header regexp)
6264 "Limit the summary buffer to articles that match an 'extra' header."
6268 (gnus-completing-read
6269 (symbol-name (car gnus-extra-headers))
6270 "Limit extra header:"
6272 (cons (symbol-name x) x))
6277 (read-string (format "Limit to header %s (regexp): " header)))))
6278 (when (not (equal "" regexp))
6280 (let ((articles (gnus-summary-find-matching
6281 (cons 'extra header) regexp 'all)))
6283 (error "Found no matches for \"%s\"" regexp))
6284 (gnus-summary-limit articles))
6285 (gnus-summary-position-point))))
6287 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6289 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6291 (defun gnus-summary-limit-to-unread (&optional all)
6292 "Limit the summary buffer to articles that are not marked as read.
6293 If ALL is non-nil, limit strictly to unread articles."
6296 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6297 (gnus-summary-limit-to-marks
6298 ;; Concat all the marks that say that an article is read and have
6300 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6301 gnus-killed-mark gnus-kill-file-mark
6302 gnus-low-score-mark gnus-expirable-mark
6303 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6304 gnus-duplicate-mark gnus-souped-mark)
6307 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6308 (make-obsolete 'gnus-summary-delete-marked-with
6309 'gnus-summary-limit-exlude-marks)
6311 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6312 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6313 If REVERSE, limit the summary buffer to articles that are marked
6314 with MARKS. MARKS can either be a string of marks or a list of marks.
6315 Returns how many articles were removed."
6316 (interactive "sMarks: ")
6317 (gnus-summary-limit-to-marks marks t))
6319 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6320 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6321 If REVERSE (the prefix), limit the summary buffer to articles that are
6322 not marked with MARKS. MARKS can either be a string of marks or a
6324 Returns how many articles were removed."
6325 (interactive "sMarks: \nP")
6327 (let ((data gnus-newsgroup-data)
6328 (marks (if (listp marks) marks
6329 (append marks nil))) ; Transform to list.
6332 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6333 (memq (gnus-data-mark (car data)) marks))
6334 (push (gnus-data-number (car data)) articles))
6335 (setq data (cdr data)))
6336 (gnus-summary-limit articles))
6337 (gnus-summary-position-point)))
6339 (defun gnus-summary-limit-to-score (&optional score)
6340 "Limit to articles with score at or above SCORE."
6342 (setq score (if score
6343 (prefix-numeric-value score)
6344 (or gnus-summary-default-score 0)))
6345 (let ((data gnus-newsgroup-data)
6348 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6350 (push (gnus-data-number (car data)) articles))
6351 (setq data (cdr data)))
6353 (gnus-summary-limit articles)
6354 (gnus-summary-position-point))))
6356 (defun gnus-summary-limit-include-thread (id)
6357 "Display all the hidden articles that in the current thread."
6358 (interactive (list (mail-header-id (gnus-summary-article-header))))
6359 (let ((articles (gnus-articles-in-thread
6360 (gnus-id-to-thread (gnus-root-id id)))))
6362 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6363 (gnus-summary-position-point))))
6365 (defun gnus-summary-limit-include-dormant ()
6366 "Display all the hidden articles that are marked as dormant.
6367 Note that this command only works on a subset of the articles currently
6368 fetched for this group."
6370 (unless gnus-newsgroup-dormant
6371 (error "There are no dormant articles in this group"))
6373 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6374 (gnus-summary-position-point)))
6376 (defun gnus-summary-limit-exclude-dormant ()
6377 "Hide all dormant articles."
6380 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6381 (gnus-summary-position-point)))
6383 (defun gnus-summary-limit-exclude-childless-dormant ()
6384 "Hide all dormant articles that have no children."
6386 (let ((data (gnus-data-list t))
6387 articles d children)
6388 ;; Find all articles that are either not dormant or have
6390 (while (setq d (pop data))
6391 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6393 (gnus-article-children (gnus-data-number d)))
6396 (when (memq (car children) articles)
6401 (push (gnus-data-number d) articles)))
6404 (gnus-summary-limit articles)
6405 (gnus-summary-position-point))))
6407 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6408 "Mark all unread excluded articles as read.
6409 If ALL, mark even excluded ticked and dormants as read."
6411 (let ((articles (gnus-sorted-complement
6413 (mapcar (lambda (h) (mail-header-number h))
6414 gnus-newsgroup-headers)
6416 (sort gnus-newsgroup-limit '<)))
6418 (setq gnus-newsgroup-unreads
6419 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6421 (setq gnus-newsgroup-dormant nil
6422 gnus-newsgroup-marked nil
6423 gnus-newsgroup-reads
6425 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6426 gnus-newsgroup-reads))
6427 (while (setq article (pop articles))
6428 (unless (or (memq article gnus-newsgroup-dormant)
6429 (memq article gnus-newsgroup-marked))
6430 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6432 (defun gnus-summary-limit (articles &optional pop)
6434 ;; We pop the previous limit off the stack and use that.
6435 (setq articles (car gnus-newsgroup-limits)
6436 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6437 ;; We use the new limit, so we push the old limit on the stack.
6438 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6440 (setq gnus-newsgroup-limit articles)
6441 (let ((total (length gnus-newsgroup-data))
6442 (data (gnus-data-find-list (gnus-summary-article-number)))
6443 (gnus-summary-mark-below nil) ; Inhibit this.
6445 ;; This will do all the work of generating the new summary buffer
6446 ;; according to the new limit.
6447 (gnus-summary-prepare)
6448 ;; Hide any threads, possibly.
6449 (and gnus-show-threads
6450 gnus-thread-hide-subtree
6451 (gnus-summary-hide-all-threads))
6452 ;; Try to return to the article you were at, or one in the
6455 ;; We try to find some article after the current one.
6457 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6460 (setq data (cdr data))))
6462 ;; If there is no data, that means that we were after the last
6463 ;; article. The same goes when we can't find any articles
6464 ;; after the current one.
6465 (goto-char (point-max))
6466 (gnus-summary-find-prev))
6467 (gnus-set-mode-line 'summary)
6468 ;; We return how many articles were removed from the summary
6469 ;; buffer as a result of the new limit.
6470 (- total (length gnus-newsgroup-data))))
6472 (defsubst gnus-invisible-cut-children (threads)
6475 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6480 (defsubst gnus-cut-thread (thread)
6481 "Go forwards in the thread until we find an article that we want to display."
6482 (when (or (eq gnus-fetch-old-headers 'some)
6483 (eq gnus-fetch-old-headers 'invisible)
6484 (numberp gnus-fetch-old-headers)
6485 (eq gnus-build-sparse-threads 'some)
6486 (eq gnus-build-sparse-threads 'more))
6487 ;; Deal with old-fetched headers and sparse threads.
6491 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6492 (gnus-summary-article-ancient-p
6493 (mail-header-number (car thread))))
6494 (if (or (<= (length (cdr thread)) 1)
6495 (eq gnus-fetch-old-headers 'invisible))
6496 (setq gnus-newsgroup-limit
6497 (delq (mail-header-number (car thread))
6498 gnus-newsgroup-limit)
6499 thread (cadr thread))
6500 (when (gnus-invisible-cut-children (cdr thread))
6501 (let ((th (cdr thread)))
6503 (if (memq (mail-header-number (caar th))
6504 gnus-newsgroup-limit)
6505 (setq thread (car th)
6507 (setq th (cdr th))))))))))
6510 (defun gnus-cut-threads (threads)
6511 "Cut off all uninteresting articles from the beginning of threads."
6512 (when (or (eq gnus-fetch-old-headers 'some)
6513 (eq gnus-fetch-old-headers 'invisible)
6514 (numberp gnus-fetch-old-headers)
6515 (eq gnus-build-sparse-threads 'some)
6516 (eq gnus-build-sparse-threads 'more))
6519 (setcar th (gnus-cut-thread (car th)))
6520 (setq th (cdr th)))))
6521 ;; Remove nixed out threads.
6524 (defun gnus-summary-initial-limit (&optional show-if-empty)
6525 "Figure out what the initial limit is supposed to be on group entry.
6526 This entails weeding out unwanted dormants, low-scored articles,
6527 fetch-old-headers verbiage, and so on."
6528 ;; Most groups have nothing to remove.
6529 (if (or gnus-inhibit-limiting
6530 (and (null gnus-newsgroup-dormant)
6531 (not (eq gnus-fetch-old-headers 'some))
6532 (not (numberp gnus-fetch-old-headers))
6533 (not (eq gnus-fetch-old-headers 'invisible))
6534 (null gnus-summary-expunge-below)
6535 (not (eq gnus-build-sparse-threads 'some))
6536 (not (eq gnus-build-sparse-threads 'more))
6537 (null gnus-thread-expunge-below)
6538 (not gnus-use-nocem)))
6540 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6541 (setq gnus-newsgroup-limit nil)
6544 (unless (car (symbol-value node))
6545 ;; These threads have no parents -- they are roots.
6546 (let ((nodes (cdr (symbol-value node)))
6549 (if (and gnus-thread-expunge-below
6550 (< (gnus-thread-total-score (car nodes))
6551 gnus-thread-expunge-below))
6552 (gnus-expunge-thread (pop nodes))
6553 (setq thread (pop nodes))
6554 (gnus-summary-limit-children thread))))))
6555 gnus-newsgroup-dependencies)
6556 ;; If this limitation resulted in an empty group, we might
6557 ;; pop the previous limit and use it instead.
6558 (when (and (not gnus-newsgroup-limit)
6560 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6561 gnus-newsgroup-limit))
6563 (defun gnus-summary-limit-children (thread)
6564 "Return 1 if this subthread is visible and 0 if it is not."
6565 ;; First we get the number of visible children to this thread. This
6566 ;; is done by recursing down the thread using this function, so this
6567 ;; will really go down to a leaf article first, before slowly
6568 ;; working its way up towards the root.
6572 (apply '+ (mapcar 'gnus-summary-limit-children
6575 (number (mail-header-number (car thread)))
6578 (not (memq number gnus-newsgroup-marked))
6580 ;; If this article is dormant and has absolutely no visible
6581 ;; children, then this article isn't visible.
6582 (and (memq number gnus-newsgroup-dormant)
6584 ;; If this is "fetch-old-headered" and there is no
6585 ;; visible children, then we don't want this article.
6586 (and (or (eq gnus-fetch-old-headers 'some)
6587 (numberp gnus-fetch-old-headers))
6588 (gnus-summary-article-ancient-p number)
6590 ;; If this is "fetch-old-headered" and `invisible', then
6591 ;; we don't want this article.
6592 (and (eq gnus-fetch-old-headers 'invisible)
6593 (gnus-summary-article-ancient-p number))
6594 ;; If this is a sparsely inserted article with no children,
6595 ;; we don't want it.
6596 (and (eq gnus-build-sparse-threads 'some)
6597 (gnus-summary-article-sparse-p number)
6599 ;; If we use expunging, and this article is really
6600 ;; low-scored, then we don't want this article.
6601 (when (and gnus-summary-expunge-below
6603 (or (cdr (assq number gnus-newsgroup-scored))
6604 gnus-summary-default-score))
6605 gnus-summary-expunge-below))
6606 ;; We increase the expunge-tally here, but that has
6607 ;; nothing to do with the limits, really.
6608 (incf gnus-newsgroup-expunged-tally)
6609 ;; We also mark as read here, if that's wanted.
6610 (when (and gnus-summary-mark-below
6611 (< score gnus-summary-mark-below))
6612 (setq gnus-newsgroup-unreads
6613 (delq number gnus-newsgroup-unreads))
6614 (if gnus-newsgroup-auto-expire
6615 (push number gnus-newsgroup-expirable)
6616 (push (cons number gnus-low-score-mark)
6617 gnus-newsgroup-reads)))
6619 ;; Check NoCeM things.
6620 (if (and gnus-use-nocem
6621 (gnus-nocem-unwanted-article-p
6622 (mail-header-id (car thread))))
6624 (setq gnus-newsgroup-unreads
6625 (delq number gnus-newsgroup-unreads))
6627 ;; Nope, invisible article.
6629 ;; Ok, this article is to be visible, so we add it to the limit
6631 (push number gnus-newsgroup-limit)
6634 (defun gnus-expunge-thread (thread)
6635 "Mark all articles in THREAD as read."
6636 (let* ((number (mail-header-number (car thread))))
6637 (incf gnus-newsgroup-expunged-tally)
6638 ;; We also mark as read here, if that's wanted.
6639 (setq gnus-newsgroup-unreads
6640 (delq number gnus-newsgroup-unreads))
6641 (if gnus-newsgroup-auto-expire
6642 (push number gnus-newsgroup-expirable)
6643 (push (cons number gnus-low-score-mark)
6644 gnus-newsgroup-reads)))
6645 ;; Go recursively through all subthreads.
6646 (mapcar 'gnus-expunge-thread (cdr thread)))
6648 ;; Summary article oriented commands
6650 (defun gnus-summary-refer-parent-article (n)
6651 "Refer parent article N times.
6652 If N is negative, go to ancestor -N instead.
6653 The difference between N and the number of articles fetched is returned."
6657 (when (not (natnump n))
6662 (setq header (gnus-summary-article-header))
6663 (if (and (eq (mail-header-number header)
6664 (cdr gnus-article-current))
6665 (equal gnus-newsgroup-name
6666 (car gnus-article-current)))
6667 ;; If we try to find the parent of the currently
6668 ;; displayed article, then we take a look at the actual
6669 ;; References header, since this is slightly more
6670 ;; reliable than the References field we got from the
6673 (set-buffer gnus-original-article-buffer)
6674 (nnheader-narrow-to-headers)
6675 (unless (setq ref (message-fetch-field "references"))
6676 (setq ref (message-fetch-field "in-reply-to")))
6679 ;; It's not the current article, so we take a bet on
6680 ;; the value we got from the server.
6681 (mail-header-references header)))
6683 (not (equal ref "")))
6684 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6685 (gnus-message 1 "Couldn't find parent"))
6686 (gnus-message 1 "No references in article %d"
6687 (gnus-summary-article-number))
6690 (gnus-summary-position-point)
6693 (defun gnus-summary-refer-references ()
6694 "Fetch all articles mentioned in the References header.
6695 Return the number of articles fetched."
6697 (let ((ref (mail-header-references (gnus-summary-article-header)))
6698 (current (gnus-summary-article-number))
6702 (error "No References in the current article")
6703 ;; For each Message-ID in the References header...
6704 (while (string-match "<[^>]*>" ref)
6706 ;; ... fetch that article.
6707 (gnus-summary-refer-article
6708 (prog1 (match-string 0 ref)
6709 (setq ref (substring ref (match-end 0))))))
6710 (gnus-summary-goto-subject current)
6711 (gnus-summary-position-point)
6714 (defun gnus-summary-refer-thread (&optional limit)
6715 "Fetch all articles in the current thread.
6716 If LIMIT (the numerical prefix), fetch that many old headers instead
6717 of what's specified by the `gnus-refer-thread-limit' variable."
6719 (let ((id (mail-header-id (gnus-summary-article-header)))
6720 (limit (if limit (prefix-numeric-value limit)
6721 gnus-refer-thread-limit)))
6722 ;; We want to fetch LIMIT *old* headers, but we also have to
6723 ;; re-fetch all the headers in the current buffer, because many of
6724 ;; them may be undisplayed. So we adjust LIMIT.
6725 (when (numberp limit)
6726 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6727 (unless (eq gnus-fetch-old-headers 'invisible)
6728 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6729 ;; Retrieve the headers and read them in.
6730 (if (eq (gnus-retrieve-headers
6731 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6733 (gnus-build-all-threads)
6734 (error "Can't fetch thread from backends that don't support NOV"))
6735 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6736 (gnus-summary-limit-include-thread id)))
6738 (defun gnus-summary-refer-article (message-id)
6739 "Fetch an article specified by MESSAGE-ID."
6740 (interactive "sMessage-ID: ")
6741 (when (and (stringp message-id)
6742 (not (zerop (length message-id))))
6743 ;; Construct the correct Message-ID if necessary.
6744 ;; Suggested by tale@pawl.rpi.edu.
6745 (unless (string-match "^<" message-id)
6746 (setq message-id (concat "<" message-id)))
6747 (unless (string-match ">$" message-id)
6748 (setq message-id (concat message-id ">")))
6749 (let* ((header (gnus-id-to-header message-id))
6751 (gnus-summary-article-sparse-p
6752 (mail-header-number header))
6753 (memq (mail-header-number header)
6754 gnus-newsgroup-limit)))
6757 ;; If the article is present in the buffer we just go to it.
6759 (or (not (gnus-summary-article-sparse-p
6760 (mail-header-number header)))
6763 (gnus-summary-goto-article
6764 (mail-header-number header) nil t)
6766 (gnus-summary-update-article (mail-header-number header)))))
6768 ;; We fetch the article.
6770 (dolist (gnus-override-method (gnus-refer-article-methods))
6771 (gnus-check-server gnus-override-method)
6772 ;; Fetch the header, and display the article.
6773 (when (setq number (gnus-summary-insert-subject message-id))
6774 (gnus-summary-select-article nil nil nil number)
6776 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6778 (defun gnus-refer-article-methods ()
6779 "Return a list of referrable methods."
6781 ;; No method, so we default to current and native.
6782 ((null gnus-refer-article-method)
6783 (list gnus-current-select-method gnus-select-method))
6785 ((eq 'current gnus-refer-article-method)
6786 (list gnus-current-select-method))
6787 ;; List of select methods.
6788 ((not (stringp (cadr gnus-refer-article-method)))
6790 (dolist (method gnus-refer-article-method)
6791 (push (if (eq 'current method)
6792 gnus-current-select-method
6796 ;; One single select method.
6798 (list gnus-refer-article-method))))
6800 (defun gnus-summary-edit-parameters ()
6801 "Edit the group parameters of the current group."
6803 (gnus-group-edit-group gnus-newsgroup-name 'params))
6805 (defun gnus-summary-customize-parameters ()
6806 "Customize the group parameters of the current group."
6808 (gnus-group-customize gnus-newsgroup-name))
6810 (defun gnus-summary-enter-digest-group (&optional force)
6811 "Enter an nndoc group based on the current article.
6812 If FORCE, force a digest interpretation. If not, try
6813 to guess what the document format is."
6815 (let ((conf gnus-current-window-configuration))
6817 (gnus-summary-select-article))
6818 (setq gnus-current-window-configuration conf)
6819 (let* ((name (format "%s-%d"
6820 (gnus-group-prefixed-name
6821 gnus-newsgroup-name (list 'nndoc ""))
6823 (set-buffer gnus-summary-buffer)
6824 gnus-current-article)))
6825 (ogroup gnus-newsgroup-name)
6826 (params (append (gnus-info-params (gnus-get-info ogroup))
6827 (list (cons 'to-group ogroup))
6828 (list (cons 'save-article-group ogroup))))
6829 (case-fold-search t)
6830 (buf (current-buffer))
6833 (set-buffer gnus-original-article-buffer)
6834 ;; Have the digest group inherit the main mail address of
6835 ;; the parent article.
6836 (when (setq to-address (or (message-fetch-field "reply-to")
6837 (message-fetch-field "from")))
6838 (setq params (append (list (cons 'to-address to-address)))))
6839 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6840 (insert-buffer-substring gnus-original-article-buffer)
6841 ;; Remove lines that may lead nndoc to misinterpret the
6844 (goto-char (point-min))
6845 (or (search-forward "\n\n" nil t) (point)))
6846 (goto-char (point-min))
6847 (delete-matching-lines "^Path:\\|^From ")
6850 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6851 (gnus-newsgroup-ephemeral-ignored-charsets
6852 gnus-newsgroup-ignored-charsets))
6853 (gnus-group-read-ephemeral-group
6854 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6856 ,(if force 'mbox 'guess))) t))
6857 ;; Make all postings to this group go to the parent group.
6858 (nconc (gnus-info-params (gnus-get-info name))
6860 ;; Couldn't select this doc group.
6861 (switch-to-buffer buf)
6862 (gnus-set-global-variables)
6863 (gnus-configure-windows 'summary)
6864 (gnus-message 3 "Article couldn't be entered?"))
6865 (kill-buffer dig)))))
6867 (defun gnus-summary-read-document (n)
6868 "Open a new group based on the current article(s).
6869 This will allow you to read digests and other similar
6870 documents as newsgroups.
6871 Obeys the standard process/prefix convention."
6873 (let* ((articles (gnus-summary-work-articles n))
6874 (ogroup gnus-newsgroup-name)
6875 (params (append (gnus-info-params (gnus-get-info ogroup))
6876 (list (cons 'to-group ogroup))))
6877 article group egroup groups vgroup)
6878 (while (setq article (pop articles))
6879 (setq group (format "%s-%d" gnus-newsgroup-name article))
6880 (gnus-summary-remove-process-mark article)
6881 (when (gnus-summary-display-article article)
6884 (insert-buffer-substring gnus-original-article-buffer)
6885 ;; Remove some headers that may lead nndoc to make
6887 (message-narrow-to-head)
6888 (goto-char (point-min))
6889 (delete-matching-lines "^\\(Path\\):\\|^From ")
6892 (gnus-group-read-ephemeral-group
6893 group `(nndoc ,group (nndoc-address ,(current-buffer))
6894 (nndoc-article-type guess))
6897 ;; Make all postings to this group go to the parent group.
6898 (nconc (gnus-info-params (gnus-get-info egroup))
6900 (push egroup groups))
6901 ;; Couldn't select this doc group.
6902 (gnus-error 3 "Article couldn't be entered"))))))
6903 ;; Now we have selected all the documents.
6906 (error "None of the articles could be interpreted as documents"))
6907 ((gnus-group-read-ephemeral-group
6908 (setq vgroup (format
6909 "nnvirtual:%s-%s" gnus-newsgroup-name
6910 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6911 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6913 (cons (current-buffer) 'summary)))
6915 (error "Couldn't select virtual nndoc group")))))
6917 (defun gnus-summary-isearch-article (&optional regexp-p)
6918 "Do incremental search forward on the current article.
6919 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6921 (gnus-summary-select-article)
6922 (gnus-configure-windows 'article)
6923 (gnus-eval-in-buffer-window gnus-article-buffer
6926 (isearch-forward regexp-p))))
6928 (defun gnus-summary-search-article-forward (regexp &optional backward)
6929 "Search for an article containing REGEXP forward.
6930 If BACKWARD, search backward instead."
6933 (format "Search article %s (regexp%s): "
6934 (if current-prefix-arg "backward" "forward")
6935 (if gnus-last-search-regexp
6936 (concat ", default " gnus-last-search-regexp)
6938 current-prefix-arg))
6939 (if (string-equal regexp "")
6940 (setq regexp (or gnus-last-search-regexp ""))
6941 (setq gnus-last-search-regexp regexp))
6942 (if (gnus-summary-search-article regexp backward)
6943 (gnus-summary-show-thread)
6944 (error "Search failed: \"%s\"" regexp)))
6946 (defun gnus-summary-search-article-backward (regexp)
6947 "Search for an article containing REGEXP backward."
6950 (format "Search article backward (regexp%s): "
6951 (if gnus-last-search-regexp
6952 (concat ", default " gnus-last-search-regexp)
6954 (gnus-summary-search-article-forward regexp 'backward))
6956 (defun gnus-summary-search-article (regexp &optional backward)
6957 "Search for an article containing REGEXP.
6958 Optional argument BACKWARD means do search for backward.
6959 `gnus-select-article-hook' is not called during the search."
6960 ;; We have to require this here to make sure that the following
6961 ;; dynamic binding isn't shadowed by autoloading.
6962 (require 'gnus-async)
6964 (let ((gnus-select-article-hook nil) ;Disable hook.
6965 (gnus-article-prepare-hook nil)
6966 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6967 (gnus-use-article-prefetch nil)
6968 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6969 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6970 (sum (current-buffer))
6971 (gnus-display-mime-function nil)
6974 (gnus-save-hidden-threads
6975 (gnus-summary-select-article)
6976 (set-buffer gnus-article-buffer)
6980 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6982 (re-search-backward regexp nil t)
6983 (re-search-forward regexp nil t))
6984 ;; We found the regexp.
6989 (get-buffer-window (current-buffer))
6993 (get-buffer-window (current-buffer))
6996 (setq point (point)))
6997 ;; We didn't find it, so we go to the next article.
7000 (while (eq found 'not)
7001 (if (not (if backward (gnus-summary-find-prev)
7002 (gnus-summary-find-next)))
7003 ;; No more articles.
7005 ;; Select the next article and adjust point.
7006 (unless (gnus-summary-article-sparse-p
7007 (gnus-summary-article-number))
7009 (gnus-summary-select-article)
7010 (set-buffer gnus-article-buffer)
7012 (goto-char (if backward (point-max) (point-min))))))))
7013 (gnus-message 7 ""))
7014 ;; Return whether we found the regexp.
7015 (when (eq found 'found)
7017 (gnus-summary-show-thread)
7018 (gnus-summary-goto-subject gnus-current-article)
7019 (gnus-summary-position-point)
7022 (defun gnus-summary-find-matching (header regexp &optional backward unread
7024 "Return a list of all articles that match REGEXP on HEADER.
7025 The search stars on the current article and goes forwards unless
7026 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7027 If UNREAD is non-nil, only unread articles will
7028 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7029 in the comparisons."
7030 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7031 (gnus-data-find-list
7032 (gnus-summary-article-number) (gnus-data-list backward))))
7033 (case-fold-search (not not-case-fold))
7036 (if (eq (car header) 'extra)
7039 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7041 (error "%s is an invalid header" header))
7042 (unless (fboundp (intern (concat "mail-header-" header)))
7043 (error "%s is not a valid header" header))
7044 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7047 (and (or (not unread) ; We want all articles...
7048 (gnus-data-unread-p d)) ; Or just unreads.
7049 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7050 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7051 (push (gnus-data-number d) articles)) ; Success!
7052 (setq data (cdr data)))
7053 (nreverse articles)))
7055 (defun gnus-summary-execute-command (header regexp command &optional backward)
7056 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7057 If HEADER is an empty string (or nil), the match is done on the entire
7058 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7060 (list (let ((completion-ignore-case t))
7063 (mapcar (lambda (string) (list string))
7064 '("Number" "Subject" "From" "Lines" "Date"
7065 "Message-ID" "Xref" "References" "Body"))
7066 nil 'require-match))
7067 (read-string "Regexp: ")
7068 (read-key-sequence "Command: ")
7069 current-prefix-arg))
7070 (when (equal header "Body")
7072 ;; Hidden thread subtrees must be searched as well.
7073 (gnus-summary-show-all-threads)
7074 ;; We don't want to change current point nor window configuration.
7076 (save-window-excursion
7077 (gnus-message 6 "Executing %s..." (key-description command))
7078 ;; We'd like to execute COMMAND interactively so as to give arguments.
7079 (gnus-execute header regexp
7080 `(call-interactively ',(key-binding command))
7082 (gnus-message 6 "Executing %s...done" (key-description command)))))
7084 (defun gnus-summary-beginning-of-article ()
7085 "Scroll the article back to the beginning."
7087 (gnus-summary-select-article)
7088 (gnus-configure-windows 'article)
7089 (gnus-eval-in-buffer-window gnus-article-buffer
7091 (goto-char (point-min))
7092 (when gnus-page-broken
7093 (gnus-narrow-to-page))))
7095 (defun gnus-summary-end-of-article ()
7096 "Scroll to the end of the article."
7098 (gnus-summary-select-article)
7099 (gnus-configure-windows 'article)
7100 (gnus-eval-in-buffer-window gnus-article-buffer
7102 (goto-char (point-max))
7104 (when gnus-page-broken
7105 (gnus-narrow-to-page))))
7107 (defun gnus-summary-print-article (&optional filename n)
7108 "Generate and print a PostScript image of the N next (mail) articles.
7110 If N is negative, print the N previous articles. If N is nil and articles
7111 have been marked with the process mark, print these instead.
7113 If the optional first argument FILENAME is nil, send the image to the
7114 printer. If FILENAME is a string, save the PostScript image in a file with
7115 that name. If FILENAME is a number, prompt the user for the name of the file
7117 (interactive (list (ps-print-preprint current-prefix-arg)
7118 current-prefix-arg))
7119 (dolist (article (gnus-summary-work-articles n))
7120 (gnus-summary-select-article nil nil 'pseudo article)
7121 (gnus-eval-in-buffer-window gnus-article-buffer
7122 (let ((buffer (generate-new-buffer " *print*")))
7125 (copy-to-buffer buffer (point-min) (point-max))
7127 (gnus-article-delete-invisible-text)
7128 (let ((ps-left-header
7131 (mail-header-subject gnus-current-headers) ")")
7133 (mail-header-from gnus-current-headers) ")")))
7136 "/pagenumberstring load"
7138 (mail-header-date gnus-current-headers) ")"))))
7139 (gnus-run-hooks 'gnus-ps-print-hook)
7141 (ps-print-buffer-with-faces filename))))
7142 (kill-buffer buffer))))))
7144 (defun gnus-summary-show-article (&optional arg)
7145 "Force re-fetching of the current article.
7146 If ARG (the prefix) is a number, show the article with the charset
7147 defined in `gnus-summary-show-article-charset-alist', or the charset
7149 If ARG (the prefix) is non-nil and not a number, show the raw article
7150 without any article massaging functions being run."
7154 (let ((gnus-newsgroup-charset
7155 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7156 (read-coding-system "Charset: ")))
7157 (gnus-newsgroup-ignored-charsets 'gnus-all))
7158 (gnus-summary-select-article nil 'force)))
7160 ;; Select the article the normal way.
7161 (gnus-summary-select-article nil 'force))
7163 ;; We have to require this here to make sure that the following
7164 ;; dynamic binding isn't shadowed by autoloading.
7165 (require 'gnus-async)
7167 ;; Bind the article treatment functions to nil.
7168 (let ((gnus-have-all-headers t)
7169 gnus-article-prepare-hook
7170 gnus-article-decode-hook
7171 gnus-display-mime-function
7173 ;; Destroy any MIME parts.
7174 (when (gnus-buffer-live-p gnus-article-buffer)
7176 (set-buffer gnus-article-buffer)
7177 (mm-destroy-parts gnus-article-mime-handles)))
7178 (gnus-summary-select-article nil 'force))))
7179 (gnus-summary-goto-subject gnus-current-article)
7180 (gnus-summary-position-point))
7182 (defun gnus-summary-verbose-headers (&optional arg)
7183 "Toggle permanent full header display.
7184 If ARG is a positive number, turn header display on.
7185 If ARG is a negative number, turn header display off."
7187 (setq gnus-show-all-headers
7188 (cond ((or (not (numberp arg))
7190 (not gnus-show-all-headers))
7193 (gnus-summary-show-article))
7195 (defun gnus-summary-toggle-header (&optional arg)
7196 "Show the headers if they are hidden, or hide them if they are shown.
7197 If ARG is a positive number, show the entire header.
7198 If ARG is a negative number, hide the unwanted header lines."
7201 (set-buffer gnus-article-buffer)
7203 (let* ((buffer-read-only nil)
7204 (inhibit-point-motion-hooks t)
7210 (article-narrow-to-head)
7211 (gnus-article-hidden-text-p 'headers))))
7212 (goto-char (point-min))
7213 (when (search-forward "\n\n" nil t)
7214 (delete-region (point-min) (1- (point))))
7215 (goto-char (point-min))
7217 (set-buffer gnus-original-article-buffer)
7218 (goto-char (point-min))
7219 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7220 (insert-buffer-substring gnus-original-article-buffer 1 e)
7222 (narrow-to-region (point-min) (point))
7223 (article-decode-encoded-words)
7225 (let ((gnus-treat-hide-headers nil)
7226 (gnus-treat-hide-boring-headers nil))
7227 (gnus-treat-article 'head))
7228 (gnus-treat-article 'head)))))))
7230 (defun gnus-summary-show-all-headers ()
7231 "Make all header lines visible."
7233 (gnus-article-show-all-headers))
7235 (defun gnus-summary-caesar-message (&optional arg)
7236 "Caesar rotate the current article by 13.
7237 The numerical prefix specifies how many places to rotate each letter
7240 (gnus-summary-select-article)
7241 (let ((mail-header-separator ""))
7242 (gnus-eval-in-buffer-window gnus-article-buffer
7245 (let ((start (window-start))
7247 (message-caesar-buffer-body arg)
7248 (set-window-start (get-buffer-window (current-buffer)) start))))))
7250 (defun gnus-summary-stop-page-breaking ()
7251 "Stop page breaking in the current article."
7253 (gnus-summary-select-article)
7254 (gnus-eval-in-buffer-window gnus-article-buffer
7256 (when (gnus-visual-p 'page-marker)
7257 (let ((buffer-read-only nil))
7258 (gnus-remove-text-with-property 'gnus-prev)
7259 (gnus-remove-text-with-property 'gnus-next))
7260 (setq gnus-page-broken nil))))
7262 (defun gnus-summary-move-article (&optional n to-newsgroup
7263 select-method action)
7264 "Move the current article to a different newsgroup.
7265 If N is a positive number, move the N next articles.
7266 If N is a negative number, move the N previous articles.
7267 If N is nil and any articles have been marked with the process mark,
7268 move those articles instead.
7269 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7270 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7271 re-spool using this method.
7273 For this function to work, both the current newsgroup and the
7274 newsgroup that you want to move to have to support the `request-move'
7275 and `request-accept' functions."
7278 (setq action 'move))
7279 ;; Disable marking as read.
7280 (let (gnus-mark-article-hook)
7281 (save-window-excursion
7282 (gnus-summary-select-article)))
7283 ;; Check whether the source group supports the required functions.
7284 (cond ((and (eq action 'move)
7285 (not (gnus-check-backend-function
7286 'request-move-article gnus-newsgroup-name)))
7287 (error "The current group does not support article moving"))
7288 ((and (eq action 'crosspost)
7289 (not (gnus-check-backend-function
7290 'request-replace-article gnus-newsgroup-name)))
7291 (error "The current group does not support article editing")))
7292 (let ((articles (gnus-summary-work-articles n))
7293 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7294 (names '((move "Move" "Moving")
7295 (copy "Copy" "Copying")
7296 (crosspost "Crosspost" "Crossposting")))
7297 (copy-buf (save-excursion
7298 (nnheader-set-temp-buffer " *copy article*")))
7299 art-group to-method new-xref article to-groups)
7300 (unless (assq action names)
7301 (error "Unknown action %s" action))
7302 ;; Read the newsgroup name.
7303 (when (and (not to-newsgroup)
7304 (not select-method))
7306 (gnus-read-move-group-name
7307 (cadr (assq action names))
7308 (symbol-value (intern (format "gnus-current-%s-group" action)))
7310 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7311 (setq to-method (or select-method
7312 (gnus-group-name-to-method to-newsgroup)))
7313 ;; Check the method we are to move this article to...
7314 (unless (gnus-check-backend-function
7315 'request-accept-article (car to-method))
7316 (error "%s does not support article copying" (car to-method)))
7317 (unless (gnus-check-server to-method)
7318 (error "Can't open server %s" (car to-method)))
7319 (gnus-message 6 "%s to %s: %s..."
7320 (caddr (assq action names))
7321 (or (car select-method) to-newsgroup) articles)
7323 (setq article (pop articles))
7327 ;; Move the article.
7329 ;; Remove this article from future suppression.
7330 (gnus-dup-unsuppress-article article)
7331 (gnus-request-move-article
7332 article ; Article to move
7333 gnus-newsgroup-name ; From newsgroup
7334 (nth 1 (gnus-find-method-for-group
7335 gnus-newsgroup-name)) ; Server
7336 (list 'gnus-request-accept-article
7337 to-newsgroup (list 'quote select-method)
7338 (not articles) t) ; Accept form
7339 (not articles))) ; Only save nov last time
7340 ;; Copy the article.
7343 (set-buffer copy-buf)
7344 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7345 (gnus-request-accept-article
7346 to-newsgroup select-method (not articles) t))))
7347 ;; Crosspost the article.
7348 ((eq action 'crosspost)
7349 (let ((xref (message-tokenize-header
7350 (mail-header-xref (gnus-summary-article-header article))
7352 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7355 (setq xref (list (system-name))))
7358 (mapconcat 'identity
7359 (delete "Xref:" (delete new-xref xref))
7363 (set-buffer copy-buf)
7364 ;; First put the article in the destination group.
7365 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7366 (when (consp (setq art-group
7367 (gnus-request-accept-article
7368 to-newsgroup select-method (not articles))))
7369 (setq new-xref (concat new-xref " " (car art-group)
7370 ":" (cdr art-group)))
7371 ;; Now we have the new Xrefs header, so we insert
7372 ;; it and replace the new article.
7373 (nnheader-replace-header "Xref" new-xref)
7374 (gnus-request-replace-article
7375 (cdr art-group) to-newsgroup (current-buffer))
7379 (gnus-message 1 "Couldn't %s article %s: %s"
7380 (cadr (assq action names)) article
7381 (nnheader-get-report (car to-method))))
7382 ((and (eq art-group 'junk)
7384 (gnus-summary-mark-article article gnus-canceled-mark)
7385 (gnus-message 4 "Deleted article %s" article))
7387 (let* ((pto-group (gnus-group-prefixed-name
7388 (car art-group) to-method))
7390 (gnus-gethash pto-group gnus-newsrc-hashtb))
7391 (info (nth 2 entry))
7392 (to-group (gnus-info-group info))
7394 ;; Update the group that has been moved to.
7396 (memq action '(move copy)))
7397 (unless (member to-group to-groups)
7398 (push to-group to-groups))
7400 (unless (memq article gnus-newsgroup-unreads)
7401 (push 'read to-marks)
7403 info (gnus-add-to-range (gnus-info-read info)
7404 (list (cdr art-group)))))
7406 ;; Copy any marks over to the new group.
7407 (let ((marks gnus-article-mark-lists)
7408 (to-article (cdr art-group)))
7410 ;; See whether the article is to be put in the cache.
7411 (when gnus-use-cache
7412 (gnus-cache-possibly-enter-article
7414 (memq article gnus-newsgroup-marked)
7415 (memq article gnus-newsgroup-dormant)
7416 (memq article gnus-newsgroup-unreads)))
7418 (when (and (equal to-group gnus-newsgroup-name)
7419 (not (memq article gnus-newsgroup-unreads)))
7420 ;; Mark this article as read in this group.
7421 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7422 (setcdr (gnus-active to-group) to-article)
7423 (setcdr gnus-newsgroup-active to-article))
7426 (when (memq article (symbol-value
7427 (intern (format "gnus-newsgroup-%s"
7429 (push (cdar marks) to-marks)
7430 ;; If the other group is the same as this group,
7431 ;; then we have to add the mark to the list.
7432 (when (equal to-group gnus-newsgroup-name)
7433 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7436 (intern (format "gnus-newsgroup-%s"
7438 ;; Copy the marks to other group.
7439 (gnus-add-marked-articles
7440 to-group (cdar marks) (list to-article) info))
7441 (setq marks (cdr marks)))
7443 (gnus-request-set-mark to-group (list (list (list to-article)
7448 (concat "(gnus-group-set-info '"
7449 (gnus-prin1-to-string (gnus-get-info to-group))
7452 ;; Update the Xref header in this article to point to
7453 ;; the new crossposted article we have just created.
7454 (when (eq action 'crosspost)
7456 (set-buffer copy-buf)
7457 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7458 (nnheader-replace-header "Xref" new-xref)
7459 (gnus-request-replace-article
7460 article gnus-newsgroup-name (current-buffer)))))
7462 ;;;!!!Why is this necessary?
7463 (set-buffer gnus-summary-buffer)
7465 (gnus-summary-goto-subject article)
7466 (when (eq action 'move)
7467 (gnus-summary-mark-article article gnus-canceled-mark))))
7468 (gnus-summary-remove-process-mark article))
7469 ;; Re-activate all groups that have been moved to.
7472 (set-buffer gnus-group-buffer)
7473 (when (gnus-group-goto-group (car to-groups) t)
7474 (gnus-group-get-new-news-this-group 1 t))
7477 (gnus-kill-buffer copy-buf)
7478 (gnus-summary-position-point)
7479 (gnus-set-mode-line 'summary)))
7481 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7482 "Move the current article to a different newsgroup.
7483 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7484 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7485 re-spool using this method."
7487 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7489 (defun gnus-summary-crosspost-article (&optional n)
7490 "Crosspost the current article to some other group."
7492 (gnus-summary-move-article n nil nil 'crosspost))
7494 (defcustom gnus-summary-respool-default-method nil
7495 "Default method for respooling an article.
7496 If nil, use to the current newsgroup method."
7497 :type '(choice (gnus-select-method :value (nnml ""))
7499 :group 'gnus-summary-mail)
7501 (defun gnus-summary-respool-article (&optional n method)
7502 "Respool the current article.
7503 The article will be squeezed through the mail spooling process again,
7504 which means that it will be put in some mail newsgroup or other
7505 depending on `nnmail-split-methods'.
7506 If N is a positive number, respool the N next articles.
7507 If N is a negative number, respool the N previous articles.
7508 If N is nil and any articles have been marked with the process mark,
7509 respool those articles instead.
7511 Respooling can be done both from mail groups and \"real\" newsgroups.
7512 In the former case, the articles in question will be moved from the
7513 current group into whatever groups they are destined to. In the
7514 latter case, they will be copied into the relevant groups."
7516 (list current-prefix-arg
7517 (let* ((methods (gnus-methods-using 'respool))
7519 (symbol-name (or gnus-summary-respool-default-method
7520 (car (gnus-find-method-for-group
7521 gnus-newsgroup-name)))))
7523 (gnus-completing-read
7524 methname "What backend do you want to use when respooling?"
7525 methods nil t nil 'gnus-mail-method-history))
7528 ((zerop (length (setq ms (gnus-servers-using-backend
7530 (list (intern method) ""))
7534 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7535 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7538 (error "No method given for respooling"))
7539 (if (assoc (symbol-name
7540 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7541 (gnus-methods-using 'respool))
7542 (gnus-summary-move-article n nil method)
7543 (gnus-summary-copy-article n nil method)))
7545 (defun gnus-summary-import-article (file)
7546 "Import an arbitrary file into a mail newsgroup."
7547 (interactive "fImport file: ")
7548 (let ((group gnus-newsgroup-name)
7549 (now (current-time))
7551 (unless (gnus-check-backend-function 'request-accept-article group)
7552 (error "%s does not support article importing" group))
7553 (or (file-readable-p file)
7554 (not (file-regular-p file))
7555 (error "Can't read %s" file))
7557 (set-buffer (gnus-get-buffer-create " *import file*"))
7559 (insert-file-contents file)
7560 (goto-char (point-min))
7561 (unless (nnheader-article-p)
7562 ;; This doesn't look like an article, so we fudge some headers.
7563 (setq atts (file-attributes file)
7564 lines (count-lines (point-min) (point-max)))
7565 (insert "From: " (read-string "From: ") "\n"
7566 "Subject: " (read-string "Subject: ") "\n"
7567 "Date: " (message-make-date (nth 5 atts))
7569 "Message-ID: " (message-make-message-id) "\n"
7570 "Lines: " (int-to-string lines) "\n"
7571 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7572 (gnus-request-accept-article group nil t)
7573 (kill-buffer (current-buffer)))))
7575 (defun gnus-summary-article-posted-p ()
7576 "Say whether the current (mail) article is available from news as well.
7577 This will be the case if the article has both been mailed and posted."
7579 (let ((id (mail-header-references (gnus-summary-article-header)))
7580 (gnus-override-method (car (gnus-refer-article-methods))))
7581 (if (gnus-request-head id "")
7582 (gnus-message 2 "The current message was found on %s"
7583 gnus-override-method)
7584 (gnus-message 2 "The current message couldn't be found on %s"
7585 gnus-override-method)
7588 (defun gnus-summary-expire-articles (&optional now)
7589 "Expire all articles that are marked as expirable in the current group."
7591 (when (gnus-check-backend-function
7592 'request-expire-articles gnus-newsgroup-name)
7593 ;; This backend supports expiry.
7594 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7595 (expirable (if total
7597 ;; We need to update the info for
7598 ;; this group for `gnus-list-of-read-articles'
7599 ;; to give us the right answer.
7600 (gnus-run-hooks 'gnus-exit-group-hook)
7601 (gnus-summary-update-info)
7602 (gnus-list-of-read-articles gnus-newsgroup-name))
7603 (setq gnus-newsgroup-expirable
7604 (sort gnus-newsgroup-expirable '<))))
7605 (expiry-wait (if now 'immediate
7606 (gnus-group-find-parameter
7607 gnus-newsgroup-name 'expiry-wait)))
7610 ;; There are expirable articles in this group, so we run them
7611 ;; through the expiry process.
7612 (gnus-message 6 "Expiring articles...")
7613 (unless (gnus-check-group gnus-newsgroup-name)
7614 (error "Can't open server for %s" gnus-newsgroup-name))
7615 ;; The list of articles that weren't expired is returned.
7618 (let ((nnmail-expiry-wait-function nil)
7619 (nnmail-expiry-wait expiry-wait))
7620 (setq es (gnus-request-expire-articles
7621 expirable gnus-newsgroup-name)))
7622 (setq es (gnus-request-expire-articles
7623 expirable gnus-newsgroup-name))))
7625 (setq gnus-newsgroup-expirable es))
7626 ;; We go through the old list of expirable, and mark all
7627 ;; really expired articles as nonexistent.
7628 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7629 (let ((gnus-use-cache nil))
7631 (unless (memq (car expirable) es)
7632 (when (gnus-data-find (car expirable))
7633 (gnus-summary-mark-article
7634 (car expirable) gnus-canceled-mark)))
7635 (setq expirable (cdr expirable)))))
7636 (gnus-message 6 "Expiring articles...done")))))
7638 (defun gnus-summary-expire-articles-now ()
7639 "Expunge all expirable articles in the current group.
7640 This means that *all* articles that are marked as expirable will be
7641 deleted forever, right now."
7643 (or gnus-expert-user
7645 "Are you really, really, really sure you want to delete all these messages? ")
7647 (gnus-summary-expire-articles t))
7649 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7650 (defun gnus-summary-delete-article (&optional n)
7651 "Delete the N next (mail) articles.
7652 This command actually deletes articles. This is not a marking
7653 command. The article will disappear forever from your life, never to
7655 If N is negative, delete backwards.
7656 If N is nil and articles have been marked with the process mark,
7657 delete these instead."
7659 (unless (gnus-check-backend-function 'request-expire-articles
7660 gnus-newsgroup-name)
7661 (error "The current newsgroup does not support article deletion"))
7662 ;; Compute the list of articles to delete.
7663 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7665 (if (and gnus-novice-user
7666 (not (gnus-yes-or-no-p
7667 (format "Do you really want to delete %s forever? "
7668 (if (> (length articles) 1)
7669 (format "these %s articles" (length articles))
7672 ;; Delete the articles.
7673 (setq not-deleted (gnus-request-expire-articles
7674 articles gnus-newsgroup-name 'force))
7676 (gnus-summary-remove-process-mark (car articles))
7677 ;; The backend might not have been able to delete the article
7679 (unless (memq (car articles) not-deleted)
7680 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7681 (setq articles (cdr articles)))
7683 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7684 (gnus-summary-position-point)
7685 (gnus-set-mode-line 'summary)
7688 (defun gnus-summary-edit-article (&optional force)
7689 "Edit the current article.
7690 This will have permanent effect only in mail groups.
7691 If FORCE is non-nil, allow editing of articles even in read-only
7695 (set-buffer gnus-summary-buffer)
7696 (let ((mail-parse-charset gnus-newsgroup-charset)
7697 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7698 (gnus-set-global-variables)
7699 (when (and (not force)
7700 (gnus-group-read-only-p))
7701 (error "The current newsgroup does not support article editing"))
7702 (gnus-summary-show-article t)
7703 (gnus-article-edit-article
7705 `(lambda (no-highlight)
7706 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7707 (mail-parse-ignored-charsets
7708 ',gnus-newsgroup-ignored-charsets))
7710 (gnus-summary-edit-article-done
7711 ,(or (mail-header-references gnus-current-headers) "")
7712 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7714 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7716 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7718 "Make edits to the current article permanent."
7720 ;; Replace the article.
7721 (let ((buf (current-buffer)))
7723 (insert-buffer-substring buf)
7724 (if (and (not read-only)
7725 (not (gnus-request-replace-article
7726 (cdr gnus-article-current) (car gnus-article-current)
7727 (current-buffer) t)))
7728 (error "Couldn't replace article")
7729 ;; Update the summary buffer.
7731 (equal (message-tokenize-header references " ")
7732 (message-tokenize-header
7733 (or (message-fetch-field "references") "") " ")))
7734 ;; We only have to update this line.
7737 (message-narrow-to-head)
7738 (let ((head (buffer-string))
7741 (insert (format "211 %d Article retrieved.\n"
7742 (cdr gnus-article-current)))
7745 (let ((nntp-server-buffer (current-buffer)))
7746 (setq header (car (gnus-get-newsgroup-headers
7748 (set-buffer gnus-summary-buffer)
7749 gnus-newsgroup-dependencies)
7752 (set-buffer gnus-summary-buffer)
7753 (gnus-data-set-header
7754 (gnus-data-find (cdr gnus-article-current))
7756 (gnus-summary-update-article-line
7757 (cdr gnus-article-current) header))))))
7759 (set-buffer (or buffer gnus-summary-buffer))
7760 (gnus-summary-update-article (cdr gnus-article-current)))
7761 ;; Prettify the article buffer again.
7762 (unless no-highlight
7764 (set-buffer gnus-article-buffer)
7765 ;;;!!! Fix this -- article should be rehighlighted.
7766 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7767 (set-buffer gnus-original-article-buffer)
7768 (gnus-request-article
7769 (cdr gnus-article-current)
7770 (car gnus-article-current) (current-buffer))))
7771 ;; Prettify the summary buffer line.
7772 (when (gnus-visual-p 'summary-highlight 'highlight)
7773 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7775 (defun gnus-summary-edit-wash (key)
7776 "Perform editing command KEY in the article buffer."
7780 (message "%s" (concat (this-command-keys) "- "))
7783 (gnus-summary-edit-article)
7784 (execute-kbd-macro (concat (this-command-keys) key))
7785 (gnus-article-edit-done))
7789 (defun gnus-summary-respool-query (&optional silent trace)
7790 "Query where the respool algorithm would put this article."
7792 (let (gnus-mark-article-hook)
7793 (gnus-summary-select-article)
7795 (set-buffer gnus-original-article-buffer)
7797 (message-narrow-to-head)
7798 (let ((groups (nnmail-article-group 'identity trace)))
7801 (message "This message would go to %s"
7802 (mapconcat 'car groups ", "))
7803 (message "This message would go to no groups"))
7806 (defun gnus-summary-respool-trace ()
7807 "Trace where the respool algorithm would put this article.
7808 Display a buffer showing all fancy splitting patterns which matched."
7810 (gnus-summary-respool-query nil t))
7812 ;; Summary marking commands.
7814 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7815 "Mark articles which has the same subject as read, and then select the next.
7816 If UNMARK is positive, remove any kind of mark.
7817 If UNMARK is negative, tick articles."
7820 (setq unmark (prefix-numeric-value unmark)))
7822 (gnus-summary-mark-same-subject
7823 (gnus-summary-article-subject) unmark)))
7824 ;; Select next unread article. If auto-select-same mode, should
7825 ;; select the first unread article.
7826 (gnus-summary-next-article t (and gnus-auto-select-same
7827 (gnus-summary-article-subject)))
7828 (gnus-message 7 "%d article%s marked as %s"
7829 count (if (= count 1) " is" "s are")
7830 (if unmark "unread" "read"))))
7832 (defun gnus-summary-kill-same-subject (&optional unmark)
7833 "Mark articles which has the same subject as read.
7834 If UNMARK is positive, remove any kind of mark.
7835 If UNMARK is negative, tick articles."
7838 (setq unmark (prefix-numeric-value unmark)))
7840 (gnus-summary-mark-same-subject
7841 (gnus-summary-article-subject) unmark)))
7842 ;; If marked as read, go to next unread subject.
7844 ;; Go to next unread subject.
7845 (gnus-summary-next-subject 1 t))
7846 (gnus-message 7 "%d articles are marked as %s"
7847 count (if unmark "unread" "read"))))
7849 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7850 "Mark articles with same SUBJECT as read, and return marked number.
7851 If optional argument UNMARK is positive, remove any kinds of marks.
7852 If optional argument UNMARK is negative, mark articles as unread instead."
7856 ((null unmark) ; Mark as read.
7859 (gnus-summary-mark-article-as-read gnus-killed-mark)
7860 (gnus-summary-show-thread) t)
7861 (gnus-summary-find-subject subject))
7862 (setq count (1+ count))))
7863 ((> unmark 0) ; Tick.
7866 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7867 (gnus-summary-show-thread) t)
7868 (gnus-summary-find-subject subject))
7869 (setq count (1+ count))))
7870 (t ; Mark as unread.
7873 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7874 (gnus-summary-show-thread) t)
7875 (gnus-summary-find-subject subject))
7876 (setq count (1+ count)))))
7877 (gnus-set-mode-line 'summary)
7878 ;; Return the number of marked articles.
7881 (defun gnus-summary-mark-as-processable (n &optional unmark)
7882 "Set the process mark on the next N articles.
7883 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7884 the process mark instead. The difference between N and the actual
7885 number of articles marked is returned."
7887 (let ((backward (< n 0))
7892 (gnus-summary-remove-process-mark
7893 (gnus-summary-article-number))
7894 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7895 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7898 (gnus-message 7 "No more articles"))
7899 (gnus-summary-recenter)
7900 (gnus-summary-position-point)
7903 (defun gnus-summary-unmark-as-processable (n)
7904 "Remove the process mark from the next N articles.
7905 If N is negative, unmark backward instead. The difference between N and
7906 the actual number of articles unmarked is returned."
7908 (gnus-summary-mark-as-processable n t))
7910 (defun gnus-summary-unmark-all-processable ()
7911 "Remove the process mark from all articles."
7914 (while gnus-newsgroup-processable
7915 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7916 (gnus-summary-position-point))
7918 (defun gnus-summary-mark-as-expirable (n)
7919 "Mark N articles forward as expirable.
7920 If N is negative, mark backward instead. The difference between N and
7921 the actual number of articles marked is returned."
7923 (gnus-summary-mark-forward n gnus-expirable-mark))
7925 (defun gnus-summary-mark-article-as-replied (article)
7926 "Mark ARTICLE replied and update the summary line."
7927 (push article gnus-newsgroup-replied)
7928 (let ((buffer-read-only nil))
7929 (when (gnus-summary-goto-subject article nil t)
7930 (gnus-summary-update-secondary-mark article))))
7932 (defun gnus-summary-set-bookmark (article)
7933 "Set a bookmark in current article."
7934 (interactive (list (gnus-summary-article-number)))
7935 (when (or (not (get-buffer gnus-article-buffer))
7936 (not gnus-current-article)
7937 (not gnus-article-current)
7938 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7939 (error "No current article selected"))
7940 ;; Remove old bookmark, if one exists.
7941 (let ((old (assq article gnus-newsgroup-bookmarks)))
7943 (setq gnus-newsgroup-bookmarks
7944 (delq old gnus-newsgroup-bookmarks))))
7945 ;; Set the new bookmark, which is on the form
7946 ;; (article-number . line-number-in-body).
7950 (set-buffer gnus-article-buffer)
7954 (goto-char (point-min))
7955 (search-forward "\n\n" nil t)
7958 gnus-newsgroup-bookmarks)
7959 (gnus-message 6 "A bookmark has been added to the current article."))
7961 (defun gnus-summary-remove-bookmark (article)
7962 "Remove the bookmark from the current article."
7963 (interactive (list (gnus-summary-article-number)))
7964 ;; Remove old bookmark, if one exists.
7965 (let ((old (assq article gnus-newsgroup-bookmarks)))
7968 (setq gnus-newsgroup-bookmarks
7969 (delq old gnus-newsgroup-bookmarks))
7970 (gnus-message 6 "Removed bookmark."))
7971 (gnus-message 6 "No bookmark in current article."))))
7973 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7974 (defun gnus-summary-mark-as-dormant (n)
7975 "Mark N articles forward as dormant.
7976 If N is negative, mark backward instead. The difference between N and
7977 the actual number of articles marked is returned."
7979 (gnus-summary-mark-forward n gnus-dormant-mark))
7981 (defun gnus-summary-set-process-mark (article)
7982 "Set the process mark on ARTICLE and update the summary line."
7983 (setq gnus-newsgroup-processable
7985 (delq article gnus-newsgroup-processable)))
7986 (when (gnus-summary-goto-subject article)
7987 (gnus-summary-show-thread)
7988 (gnus-summary-goto-subject article)
7989 (gnus-summary-update-secondary-mark article)))
7991 (defun gnus-summary-remove-process-mark (article)
7992 "Remove the process mark from ARTICLE and update the summary line."
7993 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7994 (when (gnus-summary-goto-subject article)
7995 (gnus-summary-show-thread)
7996 (gnus-summary-goto-subject article)
7997 (gnus-summary-update-secondary-mark article)))
7999 (defun gnus-summary-set-saved-mark (article)
8000 "Set the process mark on ARTICLE and update the summary line."
8001 (push article gnus-newsgroup-saved)
8002 (when (gnus-summary-goto-subject article)
8003 (gnus-summary-update-secondary-mark article)))
8005 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8006 "Mark N articles as read forwards.
8007 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8008 The difference between N and the actual number of articles marked is
8011 (gnus-summary-show-thread)
8012 (let ((backward (< n 0))
8013 (gnus-summary-goto-unread
8014 (and gnus-summary-goto-unread
8015 (not (eq gnus-summary-goto-unread 'never))
8016 (not (memq mark (list gnus-unread-mark
8017 gnus-ticked-mark gnus-dormant-mark)))))
8019 (mark (or mark gnus-del-mark)))
8021 (gnus-summary-mark-article nil mark no-expire)
8022 (zerop (gnus-summary-next-subject
8024 (and gnus-summary-goto-unread
8025 (not (eq gnus-summary-goto-unread 'never)))
8029 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8030 (gnus-summary-recenter)
8031 (gnus-summary-position-point)
8032 (gnus-set-mode-line 'summary)
8035 (defun gnus-summary-mark-article-as-read (mark)
8036 "Mark the current article quickly as read with MARK."
8037 (let ((article (gnus-summary-article-number)))
8038 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8039 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8040 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8041 (push (cons article mark) gnus-newsgroup-reads)
8042 ;; Possibly remove from cache, if that is used.
8043 (when gnus-use-cache
8044 (gnus-cache-enter-remove-article article))
8045 ;; Allow the backend to change the mark.
8046 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8047 ;; Check for auto-expiry.
8048 (when (and gnus-newsgroup-auto-expire
8049 (memq mark gnus-auto-expirable-marks))
8050 (setq mark gnus-expirable-mark)
8051 ;; Let the backend know about the mark change.
8052 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8053 (push article gnus-newsgroup-expirable))
8054 ;; Set the mark in the buffer.
8055 (gnus-summary-update-mark mark 'unread)
8058 (defun gnus-summary-mark-article-as-unread (mark)
8059 "Mark the current article quickly as unread with MARK."
8060 (let* ((article (gnus-summary-article-number))
8061 (old-mark (gnus-summary-article-mark article)))
8062 ;; Allow the backend to change the mark.
8063 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8064 (if (eq mark old-mark)
8068 (gnus-error 1 "Can't mark negative article numbers")
8070 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8071 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8072 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8073 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8074 (cond ((= mark gnus-ticked-mark)
8075 (push article gnus-newsgroup-marked))
8076 ((= mark gnus-dormant-mark)
8077 (push article gnus-newsgroup-dormant))
8079 (push article gnus-newsgroup-unreads)))
8080 (gnus-pull article gnus-newsgroup-reads)
8082 ;; See whether the article is to be put in the cache.
8084 (vectorp (gnus-summary-article-header article))
8086 (gnus-cache-possibly-enter-article
8087 gnus-newsgroup-name article
8088 (= mark gnus-ticked-mark)
8089 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8092 (gnus-summary-update-mark mark 'unread)
8095 (defun gnus-summary-mark-article (&optional article mark no-expire)
8096 "Mark ARTICLE with MARK. MARK can be any character.
8097 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8098 `??' (dormant) and `?E' (expirable).
8099 If MARK is nil, then the default character `?r' is used.
8100 If ARTICLE is nil, then the article on the current line will be
8102 ;; The mark might be a string.
8103 (when (stringp mark)
8104 (setq mark (aref mark 0)))
8105 ;; If no mark is given, then we check auto-expiring.
8107 (setq mark gnus-del-mark))
8108 (when (and (not no-expire)
8109 gnus-newsgroup-auto-expire
8110 (memq mark gnus-auto-expirable-marks))
8111 (setq mark gnus-expirable-mark))
8112 (let ((article (or article (gnus-summary-article-number)))
8113 (old-mark (gnus-summary-article-mark article)))
8114 ;; Allow the backend to change the mark.
8115 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8116 (if (eq mark old-mark)
8119 (error "No article on current line"))
8120 (if (not (if (or (= mark gnus-unread-mark)
8121 (= mark gnus-ticked-mark)
8122 (= mark gnus-dormant-mark))
8123 (gnus-mark-article-as-unread article mark)
8124 (gnus-mark-article-as-read article mark)))
8126 ;; See whether the article is to be put in the cache.
8128 (not (= mark gnus-canceled-mark))
8129 (vectorp (gnus-summary-article-header article))
8131 (gnus-cache-possibly-enter-article
8132 gnus-newsgroup-name article
8133 (= mark gnus-ticked-mark)
8134 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8136 (when (gnus-summary-goto-subject article nil t)
8137 (let ((buffer-read-only nil))
8138 (gnus-summary-show-thread)
8140 (gnus-summary-update-mark mark 'unread)
8143 (defun gnus-summary-update-secondary-mark (article)
8144 "Update the secondary (read, process, cache) mark."
8145 (gnus-summary-update-mark
8146 (cond ((memq article gnus-newsgroup-processable)
8148 ((memq article gnus-newsgroup-cached)
8150 ((memq article gnus-newsgroup-replied)
8152 ((memq article gnus-newsgroup-saved)
8154 (t gnus-unread-mark))
8156 (when (gnus-visual-p 'summary-highlight 'highlight)
8157 (gnus-run-hooks 'gnus-summary-update-hook))
8160 (defun gnus-summary-update-mark (mark type)
8161 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8162 (buffer-read-only nil))
8163 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8165 (when (looking-at "\r")
8167 (when (<= (+ forward (point)) (point-max))
8168 ;; Go to the right position on the line.
8169 (goto-char (+ forward (point)))
8170 ;; Replace the old mark with the new mark.
8171 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8172 ;; Optionally update the marks by some user rule.
8173 (when (eq type 'unread)
8175 (gnus-data-find (gnus-summary-article-number)) mark)
8176 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8178 (defun gnus-mark-article-as-read (article &optional mark)
8179 "Enter ARTICLE in the pertinent lists and remove it from others."
8180 ;; Make the article expirable.
8181 (let ((mark (or mark gnus-del-mark)))
8182 (if (= mark gnus-expirable-mark)
8183 (push article gnus-newsgroup-expirable)
8184 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8185 ;; Remove from unread and marked lists.
8186 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8187 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8188 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8189 (push (cons article mark) gnus-newsgroup-reads)
8190 ;; Possibly remove from cache, if that is used.
8191 (when gnus-use-cache
8192 (gnus-cache-enter-remove-article article))
8195 (defun gnus-mark-article-as-unread (article &optional mark)
8196 "Enter ARTICLE in the pertinent lists and remove it from others."
8197 (let ((mark (or mark gnus-ticked-mark)))
8200 (gnus-error 1 "Can't mark negative article numbers")
8202 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8203 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8204 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8205 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8207 ;; Unsuppress duplicates?
8208 (when gnus-suppress-duplicates
8209 (gnus-dup-unsuppress-article article))
8211 (cond ((= mark gnus-ticked-mark)
8212 (push article gnus-newsgroup-marked))
8213 ((= mark gnus-dormant-mark)
8214 (push article gnus-newsgroup-dormant))
8216 (push article gnus-newsgroup-unreads)))
8217 (gnus-pull article gnus-newsgroup-reads)
8220 (defalias 'gnus-summary-mark-as-unread-forward
8221 'gnus-summary-tick-article-forward)
8222 (make-obsolete 'gnus-summary-mark-as-unread-forward
8223 'gnus-summary-tick-article-forward)
8224 (defun gnus-summary-tick-article-forward (n)
8225 "Tick N articles forwards.
8226 If N is negative, tick backwards instead.
8227 The difference between N and the number of articles ticked is returned."
8229 (gnus-summary-mark-forward n gnus-ticked-mark))
8231 (defalias 'gnus-summary-mark-as-unread-backward
8232 'gnus-summary-tick-article-backward)
8233 (make-obsolete 'gnus-summary-mark-as-unread-backward
8234 'gnus-summary-tick-article-backward)
8235 (defun gnus-summary-tick-article-backward (n)
8236 "Tick N articles backwards.
8237 The difference between N and the number of articles ticked is returned."
8239 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8241 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8242 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8243 (defun gnus-summary-tick-article (&optional article clear-mark)
8244 "Mark current article as unread.
8245 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8246 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8248 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8251 (defun gnus-summary-mark-as-read-forward (n)
8252 "Mark N articles as read forwards.
8253 If N is negative, mark backwards instead.
8254 The difference between N and the actual number of articles marked is
8257 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8259 (defun gnus-summary-mark-as-read-backward (n)
8260 "Mark the N articles as read backwards.
8261 The difference between N and the actual number of articles marked is
8264 (gnus-summary-mark-forward
8265 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8267 (defun gnus-summary-mark-as-read (&optional article mark)
8268 "Mark current article as read.
8269 ARTICLE specifies the article to be marked as read.
8270 MARK specifies a string to be inserted at the beginning of the line."
8271 (gnus-summary-mark-article article mark))
8273 (defun gnus-summary-clear-mark-forward (n)
8274 "Clear marks from N articles forward.
8275 If N is negative, clear backward instead.
8276 The difference between N and the number of marks cleared is returned."
8278 (gnus-summary-mark-forward n gnus-unread-mark))
8280 (defun gnus-summary-clear-mark-backward (n)
8281 "Clear marks from N articles backward.
8282 The difference between N and the number of marks cleared is returned."
8284 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8286 (defun gnus-summary-mark-unread-as-read ()
8287 "Intended to be used by `gnus-summary-mark-article-hook'."
8288 (when (memq gnus-current-article gnus-newsgroup-unreads)
8289 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8291 (defun gnus-summary-mark-read-and-unread-as-read ()
8292 "Intended to be used by `gnus-summary-mark-article-hook'."
8293 (let ((mark (gnus-summary-article-mark)))
8294 (when (or (gnus-unread-mark-p mark)
8295 (gnus-read-mark-p mark))
8296 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8298 (defun gnus-summary-mark-region-as-read (point mark all)
8299 "Mark all unread articles between point and mark as read.
8300 If given a prefix, mark all articles between point and mark as read,
8301 even ticked and dormant ones."
8302 (interactive "r\nP")
8311 (memq (setq article (gnus-summary-article-number))
8312 gnus-newsgroup-unreads))
8313 (gnus-summary-mark-article article gnus-del-mark))
8315 (gnus-summary-find-next))))))
8317 (defun gnus-summary-mark-below (score mark)
8318 "Mark articles with score less than SCORE with MARK."
8319 (interactive "P\ncMark: ")
8320 (setq score (if score
8321 (prefix-numeric-value score)
8322 (or gnus-summary-default-score 0)))
8324 (set-buffer gnus-summary-buffer)
8325 (goto-char (point-min))
8328 (and (< (gnus-summary-article-score) score)
8329 (gnus-summary-mark-article nil mark))
8330 (gnus-summary-find-next)))))
8332 (defun gnus-summary-kill-below (&optional score)
8333 "Mark articles with score below SCORE as read."
8335 (gnus-summary-mark-below score gnus-killed-mark))
8337 (defun gnus-summary-clear-above (&optional score)
8338 "Clear all marks from articles with score above SCORE."
8340 (gnus-summary-mark-above score gnus-unread-mark))
8342 (defun gnus-summary-tick-above (&optional score)
8343 "Tick all articles with score above SCORE."
8345 (gnus-summary-mark-above score gnus-ticked-mark))
8347 (defun gnus-summary-mark-above (score mark)
8348 "Mark articles with score over SCORE with MARK."
8349 (interactive "P\ncMark: ")
8350 (setq score (if score
8351 (prefix-numeric-value score)
8352 (or gnus-summary-default-score 0)))
8354 (set-buffer gnus-summary-buffer)
8355 (goto-char (point-min))
8357 (when (> (gnus-summary-article-score) score)
8358 (gnus-summary-mark-article nil mark))
8360 (gnus-summary-find-next)))))
8362 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8363 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8364 (defun gnus-summary-limit-include-expunged (&optional no-error)
8365 "Display all the hidden articles that were expunged for low scores."
8367 (let ((buffer-read-only nil))
8368 (let ((scored gnus-newsgroup-scored)
8371 (unless (gnus-summary-goto-subject (caar scored))
8372 (and (setq h (gnus-summary-article-header (caar scored)))
8373 (< (cdar scored) gnus-summary-expunge-below)
8375 (setq scored (cdr scored)))
8377 (when (not no-error)
8378 (error "No expunged articles hidden"))
8379 (goto-char (point-min))
8380 (gnus-summary-prepare-unthreaded (nreverse headers))
8381 (goto-char (point-min))
8382 (gnus-summary-position-point)
8385 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8386 "Mark all unread articles in this newsgroup as read.
8387 If prefix argument ALL is non-nil, ticked and dormant articles will
8388 also be marked as read.
8389 If QUIETLY is non-nil, no questions will be asked.
8390 If TO-HERE is non-nil, it should be a point in the buffer. All
8391 articles before this point will be marked as read.
8392 Note that this function will only catch up the unread article
8393 in the current summary buffer limitation.
8394 The number of articles marked as read is returned."
8399 (not gnus-interactive-catchup) ;Without confirmation?
8403 "Mark absolutely all articles as read? "
8404 "Mark all unread articles as read? ")))
8406 (not gnus-newsgroup-adaptive)
8407 (not gnus-newsgroup-auto-expire)
8408 (not gnus-suppress-duplicates)
8409 (or (not gnus-use-cache)
8410 (eq gnus-use-cache 'passive)))
8413 (setq gnus-newsgroup-marked nil
8414 gnus-newsgroup-dormant nil))
8415 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8416 ;; We actually mark all articles as canceled, which we
8417 ;; have to do when using auto-expiry or adaptive scoring.
8418 (gnus-summary-show-all-threads)
8419 (when (gnus-summary-first-subject (not all) t)
8421 (if to-here (< (point) to-here) t)
8422 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8423 (gnus-summary-find-next (not all) nil nil t))))
8424 (gnus-set-mode-line 'summary))
8426 (gnus-summary-position-point)))
8428 (defun gnus-summary-catchup-to-here (&optional all)
8429 "Mark all unticked articles before the current one as read.
8430 If ALL is non-nil, also mark ticked and dormant articles as read."
8433 (gnus-save-hidden-threads
8434 (let ((beg (point)))
8435 ;; We check that there are unread articles.
8436 (when (or all (gnus-summary-find-prev))
8437 (gnus-summary-catchup all t beg)))))
8438 (gnus-summary-position-point))
8440 (defun gnus-summary-catchup-all (&optional quietly)
8441 "Mark all articles in this newsgroup as read."
8443 (gnus-summary-catchup t quietly))
8445 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8446 "Mark all unread articles in this group as read, then exit.
8447 If prefix argument ALL is non-nil, all articles are marked as read."
8449 (when (gnus-summary-catchup all quietly nil 'fast)
8450 ;; Select next newsgroup or exit.
8451 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8452 (eq gnus-auto-select-next 'quietly))
8453 (gnus-summary-next-group nil)
8454 (gnus-summary-exit))))
8456 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8457 "Mark all articles in this newsgroup as read, and then exit."
8459 (gnus-summary-catchup-and-exit t quietly))
8461 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8462 "Mark all articles in this group as read and select the next group.
8463 If given a prefix, mark all articles, unread as well as ticked, as
8467 (gnus-summary-catchup all))
8468 (gnus-summary-next-group))
8470 ;; Thread-based commands.
8472 (defun gnus-summary-articles-in-thread (&optional article)
8473 "Return a list of all articles in the current thread.
8474 If ARTICLE is non-nil, return all articles in the thread that starts
8476 (let* ((article (or article (gnus-summary-article-number)))
8477 (data (gnus-data-find-list article))
8478 (top-level (gnus-data-level (car data)))
8480 (cond ((null gnus-thread-operation-ignore-subject)
8481 (gnus-simplify-subject-re
8482 (mail-header-subject (gnus-data-header (car data)))))
8483 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8484 (gnus-simplify-subject-fuzzy
8485 (mail-header-subject (gnus-data-header (car data)))))
8487 (end-point (save-excursion
8488 (if (gnus-summary-go-to-next-thread)
8489 (point) (point-max))))
8492 (< (gnus-data-pos (car data)) end-point))
8493 (when (or (not top-subject)
8494 (string= top-subject
8495 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8496 (gnus-simplify-subject-fuzzy
8497 (mail-header-subject
8498 (gnus-data-header (car data))))
8499 (gnus-simplify-subject-re
8500 (mail-header-subject
8501 (gnus-data-header (car data)))))))
8502 (push (gnus-data-number (car data)) articles))
8503 (unless (and (setq data (cdr data))
8504 (> (gnus-data-level (car data)) top-level))
8506 ;; Return the list of articles.
8507 (nreverse articles)))
8509 (defun gnus-summary-rethread-current ()
8510 "Rethread the thread the current article is part of."
8512 (let* ((gnus-show-threads t)
8513 (article (gnus-summary-article-number))
8514 (id (mail-header-id (gnus-summary-article-header)))
8515 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8517 (error "No article on the current line"))
8518 (gnus-rebuild-thread id)
8519 (gnus-summary-goto-subject article)))
8521 (defun gnus-summary-reparent-thread ()
8522 "Make the current article child of the marked (or previous) article.
8524 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8525 is non-nil or the Subject: of both articles are the same."
8527 (unless (not (gnus-group-read-only-p))
8528 (error "The current newsgroup does not support article editing"))
8529 (unless (<= (length gnus-newsgroup-processable) 1)
8530 (error "No more than one article may be marked"))
8531 (save-window-excursion
8532 (let ((gnus-article-buffer " *reparent*")
8533 (current-article (gnus-summary-article-number))
8534 ;; First grab the marked article, otherwise one line up.
8535 (parent-article (if (not (null gnus-newsgroup-processable))
8536 (car gnus-newsgroup-processable)
8538 (if (eq (forward-line -1) 0)
8539 (gnus-summary-article-number)
8540 (error "Beginning of summary buffer"))))))
8541 (unless (not (eq current-article parent-article))
8542 (error "An article may not be self-referential"))
8543 (let ((message-id (mail-header-id
8544 (gnus-summary-article-header parent-article))))
8545 (unless (and message-id (not (equal message-id "")))
8546 (error "No message-id in desired parent"))
8547 (gnus-with-article current-article
8548 (goto-char (point-min))
8549 (if (re-search-forward "^References: " nil t)
8551 (re-search-forward "^[^ \t]" nil t)
8554 (insert " " message-id))
8555 (insert "References: " message-id "\n")))
8556 (set-buffer gnus-summary-buffer)
8557 (gnus-summary-unmark-all-processable)
8558 (gnus-summary-update-article current-article)
8559 (gnus-summary-rethread-current)
8560 (gnus-message 3 "Article %d is now the child of article %d"
8561 current-article parent-article)))))
8563 (defun gnus-summary-toggle-threads (&optional arg)
8564 "Toggle showing conversation threads.
8565 If ARG is positive number, turn showing conversation threads on."
8567 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8568 (setq gnus-show-threads
8569 (if (null arg) (not gnus-show-threads)
8570 (> (prefix-numeric-value arg) 0)))
8571 (gnus-summary-prepare)
8572 (gnus-summary-goto-subject current)
8573 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8574 (gnus-summary-position-point)))
8576 (defun gnus-summary-show-all-threads ()
8580 (let ((buffer-read-only nil))
8581 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8582 (gnus-summary-position-point))
8584 (defun gnus-summary-show-thread ()
8585 "Show thread subtrees.
8586 Returns nil if no thread was there to be shown."
8588 (let ((buffer-read-only nil)
8590 ;; first goto end then to beg, to have point at beg after let
8591 (end (progn (end-of-line) (point)))
8592 (beg (progn (beginning-of-line) (point))))
8594 ;; Any hidden lines here?
8595 (search-forward "\r" end t)
8596 (subst-char-in-region beg end ?\^M ?\n t)
8598 (gnus-summary-position-point))))
8600 (defun gnus-summary-hide-all-threads ()
8601 "Hide all thread subtrees."
8604 (goto-char (point-min))
8605 (gnus-summary-hide-thread)
8606 (while (zerop (gnus-summary-next-thread 1 t))
8607 (gnus-summary-hide-thread)))
8608 (gnus-summary-position-point))
8610 (defun gnus-summary-hide-thread ()
8611 "Hide thread subtrees.
8612 Returns nil if no threads were there to be hidden."
8614 (let ((buffer-read-only nil)
8616 (article (gnus-summary-article-number)))
8618 ;; Go forward until either the buffer ends or the subthread
8620 (when (and (not (eobp))
8621 (or (zerop (gnus-summary-next-thread 1 t))
8622 (goto-char (point-max))))
8624 (if (and (> (point) start)
8625 (search-backward "\n" start t))
8627 (subst-char-in-region start (point) ?\n ?\^M)
8628 (gnus-summary-goto-subject article))
8632 (defun gnus-summary-go-to-next-thread (&optional previous)
8633 "Go to the same level (or less) next thread.
8634 If PREVIOUS is non-nil, go to previous thread instead.
8635 Return the article number moved to, or nil if moving was impossible."
8636 (let ((level (gnus-summary-thread-level))
8637 (way (if previous -1 1))
8640 (while (and (not (eobp))
8641 (< level (gnus-summary-thread-level)))
8649 (gnus-summary-article-number)
8652 (defun gnus-summary-next-thread (n &optional silent)
8653 "Go to the same level next N'th thread.
8654 If N is negative, search backward instead.
8655 Returns the difference between N and the number of skips actually
8658 If SILENT, don't output messages."
8660 (let ((backward (< n 0))
8663 (gnus-summary-go-to-next-thread backward))
8666 (gnus-summary-position-point))
8667 (when (and (not silent) (/= 0 n))
8668 (gnus-message 7 "No more threads"))
8671 (defun gnus-summary-prev-thread (n)
8672 "Go to the same level previous N'th thread.
8673 Returns the difference between N and the number of skips actually
8676 (gnus-summary-next-thread (- n)))
8678 (defun gnus-summary-go-down-thread ()
8679 "Go down one level in the current thread."
8680 (let ((children (gnus-summary-article-children)))
8682 (gnus-summary-goto-subject (car children)))))
8684 (defun gnus-summary-go-up-thread ()
8685 "Go up one level in the current thread."
8686 (let ((parent (gnus-summary-article-parent)))
8688 (gnus-summary-goto-subject parent))))
8690 (defun gnus-summary-down-thread (n)
8691 "Go down thread N steps.
8692 If N is negative, go up instead.
8693 Returns the difference between N and how many steps down that were
8699 (if up (gnus-summary-go-up-thread)
8700 (gnus-summary-go-down-thread)))
8702 (gnus-summary-position-point)
8704 (gnus-message 7 "Can't go further"))
8707 (defun gnus-summary-up-thread (n)
8708 "Go up thread N steps.
8709 If N is negative, go up instead.
8710 Returns the difference between N and how many steps down that were
8713 (gnus-summary-down-thread (- n)))
8715 (defun gnus-summary-top-thread ()
8716 "Go to the top of the thread."
8718 (while (gnus-summary-go-up-thread))
8719 (gnus-summary-article-number))
8721 (defun gnus-summary-kill-thread (&optional unmark)
8722 "Mark articles under current thread as read.
8723 If the prefix argument is positive, remove any kinds of marks.
8724 If the prefix argument is negative, tick articles instead."
8727 (setq unmark (prefix-numeric-value unmark)))
8728 (let ((articles (gnus-summary-articles-in-thread)))
8730 ;; Expand the thread.
8731 (gnus-summary-show-thread)
8732 ;; Mark all the articles.
8734 (gnus-summary-goto-subject (car articles))
8735 (cond ((null unmark)
8736 (gnus-summary-mark-article-as-read gnus-killed-mark))
8738 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8740 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8741 (setq articles (cdr articles))))
8742 ;; Hide killed subtrees.
8744 gnus-thread-hide-killed
8745 (gnus-summary-hide-thread))
8746 ;; If marked as read, go to next unread subject.
8748 ;; Go to next unread subject.
8749 (gnus-summary-next-subject 1 t)))
8750 (gnus-set-mode-line 'summary))
8752 ;; Summary sorting commands
8754 (defun gnus-summary-sort-by-number (&optional reverse)
8755 "Sort the summary buffer by article number.
8756 Argument REVERSE means reverse order."
8758 (gnus-summary-sort 'number reverse))
8760 (defun gnus-summary-sort-by-author (&optional reverse)
8761 "Sort the summary buffer by author name alphabetically.
8762 If case-fold-search is non-nil, case of letters is ignored.
8763 Argument REVERSE means reverse order."
8765 (gnus-summary-sort 'author reverse))
8767 (defun gnus-summary-sort-by-subject (&optional reverse)
8768 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8769 If case-fold-search is non-nil, case of letters is ignored.
8770 Argument REVERSE means reverse order."
8772 (gnus-summary-sort 'subject reverse))
8774 (defun gnus-summary-sort-by-date (&optional reverse)
8775 "Sort the summary buffer by date.
8776 Argument REVERSE means reverse order."
8778 (gnus-summary-sort 'date reverse))
8780 (defun gnus-summary-sort-by-score (&optional reverse)
8781 "Sort the summary buffer by score.
8782 Argument REVERSE means reverse order."
8784 (gnus-summary-sort 'score reverse))
8786 (defun gnus-summary-sort-by-lines (&optional reverse)
8787 "Sort the summary buffer by the number of lines.
8788 Argument REVERSE means reverse order."
8790 (gnus-summary-sort 'lines reverse))
8792 (defun gnus-summary-sort-by-chars (&optional reverse)
8793 "Sort the summary buffer by article length.
8794 Argument REVERSE means reverse order."
8796 (gnus-summary-sort 'chars reverse))
8798 (defun gnus-summary-sort (predicate reverse)
8799 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8800 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8801 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8802 (gnus-thread-sort-functions
8807 (gnus-article-sort-functions
8813 (gnus-summary-prepare-hook nil))
8814 ;; We do the sorting by regenerating the threads.
8815 (gnus-summary-prepare)
8816 ;; Hide subthreads if needed.
8817 (when (and gnus-show-threads gnus-thread-hide-subtree)
8818 (gnus-summary-hide-all-threads))))
8820 ;; Summary saving commands.
8822 (defun gnus-summary-save-article (&optional n not-saved)
8823 "Save the current article using the default saver function.
8824 If N is a positive number, save the N next articles.
8825 If N is a negative number, save the N previous articles.
8826 If N is nil and any articles have been marked with the process mark,
8827 save those articles instead.
8828 The variable `gnus-default-article-saver' specifies the saver function."
8830 (let* ((articles (gnus-summary-work-articles n))
8831 (save-buffer (save-excursion
8832 (nnheader-set-temp-buffer " *Gnus Save*")))
8833 (num (length articles))
8835 (dolist (article articles)
8836 (setq header (gnus-summary-article-header article))
8837 (if (not (vectorp header))
8838 ;; This is a pseudo-article.
8839 (if (assq 'name header)
8840 (gnus-copy-file (cdr (assq 'name header)))
8841 (gnus-message 1 "Article %d is unsaveable" article))
8842 ;; This is a real article.
8843 (save-window-excursion
8844 (gnus-summary-select-article t nil nil article))
8846 (set-buffer save-buffer)
8848 (insert-buffer-substring gnus-original-article-buffer))
8849 (setq file (gnus-article-save save-buffer file num))
8850 (gnus-summary-remove-process-mark article)
8852 (gnus-summary-set-saved-mark article))))
8853 (gnus-kill-buffer save-buffer)
8854 (gnus-summary-position-point)
8855 (gnus-set-mode-line 'summary)
8858 (defun gnus-summary-pipe-output (&optional arg)
8859 "Pipe the current article to a subprocess.
8860 If N is a positive number, pipe the N next articles.
8861 If N is a negative number, pipe the N previous articles.
8862 If N is nil and any articles have been marked with the process mark,
8863 pipe those articles instead."
8865 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8866 (gnus-summary-save-article arg t))
8867 (gnus-configure-windows 'pipe))
8869 (defun gnus-summary-save-article-mail (&optional arg)
8870 "Append the current article to an mail file.
8871 If N is a positive number, save the N next articles.
8872 If N is a negative number, save the N previous articles.
8873 If N is nil and any articles have been marked with the process mark,
8874 save those articles instead."
8876 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8877 (gnus-summary-save-article arg)))
8879 (defun gnus-summary-save-article-rmail (&optional arg)
8880 "Append the current article to an rmail file.
8881 If N is a positive number, save the N next articles.
8882 If N is a negative number, save the N previous articles.
8883 If N is nil and any articles have been marked with the process mark,
8884 save those articles instead."
8886 (let ((gnus-default-article-saver 'rmail-output-to-rmail-file))
8887 (gnus-summary-save-article arg)))
8889 (defun gnus-summary-save-article-file (&optional arg)
8890 "Append the current article to a file.
8891 If N is a positive number, save the N next articles.
8892 If N is a negative number, save the N previous articles.
8893 If N is nil and any articles have been marked with the process mark,
8894 save those articles instead."
8896 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8897 (gnus-summary-save-article arg)))
8899 (defun gnus-summary-write-article-file (&optional arg)
8900 "Write the current article to a file, deleting the previous file.
8901 If N is a positive number, save the N next articles.
8902 If N is a negative number, save the N previous articles.
8903 If N is nil and any articles have been marked with the process mark,
8904 save those articles instead."
8906 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8907 (gnus-summary-save-article arg)))
8909 (defun gnus-summary-save-article-body-file (&optional arg)
8910 "Append the current article body to a file.
8911 If N is a positive number, save the N next articles.
8912 If N is a negative number, save the N previous articles.
8913 If N is nil and any articles have been marked with the process mark,
8914 save those articles instead."
8916 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8917 (gnus-summary-save-article arg)))
8919 (defun gnus-summary-pipe-message (program)
8920 "Pipe the current article through PROGRAM."
8921 (interactive "sProgram: ")
8922 (gnus-summary-select-article)
8923 (let ((mail-header-separator ""))
8924 (gnus-eval-in-buffer-window gnus-article-buffer
8927 (let ((start (window-start))
8929 (message-pipe-buffer-body program)
8930 (set-window-start (get-buffer-window (current-buffer)) start))))))
8932 (defun gnus-get-split-value (methods)
8933 "Return a value based on the split METHODS."
8934 (let (split-name method result match)
8937 (set-buffer gnus-original-article-buffer)
8939 (nnheader-narrow-to-headers)
8941 (goto-char (point-min))
8942 (setq method (pop methods))
8943 (setq match (car method))
8946 ;; Regular expression.
8948 (re-search-forward match nil t)))
8949 ((gnus-functionp match)
8953 (setq result (funcall match gnus-newsgroup-name))))
8958 (setq result (eval match)))))
8959 (setq split-name (append (cdr method) split-name))
8960 (cond ((stringp result)
8961 (push (expand-file-name
8962 result gnus-article-save-directory)
8965 (setq split-name (append result split-name)))))))))
8966 (nreverse split-name)))
8968 (defun gnus-valid-move-group-p (group)
8971 (symbol-value group)
8972 (gnus-get-function (gnus-find-method-for-group
8973 (symbol-name group)) 'request-accept-article t)))
8975 (defun gnus-read-move-group-name (prompt default articles prefix)
8976 "Read a group name."
8977 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8978 (minibuffer-confirm-incomplete nil) ; XEmacs
8982 (if (> (length articles) 1)
8983 (format "these %d articles" (length articles))
8988 (gnus-completing-read default prom
8990 'gnus-valid-move-group-p
8992 'gnus-group-history))
8993 ((= 1 (length split-name))
8994 (gnus-completing-read (car split-name) prom
8996 'gnus-valid-move-group-p
8998 'gnus-group-history))
9000 (gnus-completing-read nil prom
9001 (mapcar (lambda (el) (list el))
9002 (nreverse split-name))
9004 'gnus-group-history)))))
9006 (if (or (string= to-newsgroup "")
9007 (string= to-newsgroup prefix))
9008 (setq to-newsgroup default))
9009 (unless to-newsgroup
9010 (error "No group name entered"))
9011 (or (gnus-active to-newsgroup)
9012 (gnus-activate-group to-newsgroup)
9013 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9015 (or (and (gnus-request-create-group
9016 to-newsgroup (gnus-group-name-to-method to-newsgroup))
9017 (gnus-activate-group
9018 to-newsgroup nil nil
9019 (gnus-group-name-to-method to-newsgroup))
9020 (gnus-subscribe-group to-newsgroup))
9021 (error "Couldn't create group %s" to-newsgroup)))
9022 (error "No such group: %s" to-newsgroup)))
9025 (defun gnus-summary-save-parts (type dir n reverse)
9026 "Save parts matching TYPE to DIR.
9027 If REVERSE, save parts that do not match TYPE."
9029 (list (read-string "Save parts of type: " "image/.*")
9030 (read-file-name "Save to directory: " t nil t)
9031 current-prefix-arg))
9032 (gnus-summary-iterate n
9033 (let ((gnus-display-mime-function nil)
9034 (gnus-inhibit-treatment t))
9035 (gnus-summary-select-article))
9037 (set-buffer gnus-article-buffer)
9038 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
9040 (gnus-summary-save-parts-1 type dir handles reverse)
9041 (mm-destroy-parts handles))))))
9043 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9044 (if (stringp (car handle))
9045 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9048 (not (string-match type (mm-handle-media-type handle)))
9049 (string-match type (mm-handle-media-type handle)))
9050 (let ((file (expand-file-name
9051 (file-name-nondirectory
9053 (mail-content-type-get
9054 (mm-handle-disposition handle) 'filename)
9055 (concat gnus-newsgroup-name "." gnus-current-article)))
9057 (unless (file-exists-p file)
9058 (mm-save-part-to-file handle file))))))
9060 ;; Summary extract commands
9062 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9063 (let ((buffer-read-only nil)
9064 (article (gnus-summary-article-number))
9066 (unless (gnus-summary-goto-subject article)
9067 (error "No such article: %d" article))
9068 (gnus-summary-position-point)
9069 ;; If all commands are to be bunched up on one line, we collect
9071 (unless gnus-view-pseudos-separately
9072 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9075 (setq action (cdr (assq 'action (car ps))))
9076 (setq files (list (cdr (assq 'name (car ps)))))
9077 (while (and ps (cdr ps)
9078 (string= (or action "1")
9079 (or (cdr (assq 'action (cadr ps))) "2")))
9080 (push (cdr (assq 'name (cadr ps))) files)
9081 (setcdr ps (cddr ps)))
9083 (when (not (string-match "%s" action))
9086 (when (assq 'execute (car ps))
9087 (setcdr (assq 'execute (car ps))
9088 (funcall (if (string-match "%s" action)
9097 (setq ps (cdr ps)))))
9098 (if (and gnus-view-pseudos (not not-view))
9100 (when (assq 'execute (car pslist))
9101 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9102 (eq gnus-view-pseudos 'not-confirm)))
9103 (setq pslist (cdr pslist)))
9106 (setq after-article (or (cdr (assq 'article (car pslist)))
9107 (gnus-summary-article-number)))
9108 (gnus-summary-goto-subject after-article)
9111 (insert " " (file-name-nondirectory
9112 (cdr (assq 'name (car pslist))))
9113 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9115 (forward-line -1) ; back to `b'
9116 (gnus-add-text-properties
9117 b (1- e) (list 'gnus-number gnus-reffed-article-number
9118 gnus-mouse-face-prop gnus-mouse-face))
9120 after-article gnus-reffed-article-number
9121 gnus-unread-mark b (car pslist) 0 (- e b))
9122 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9123 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9124 (setq pslist (cdr pslist)))))))
9126 (defun gnus-pseudos< (p1 p2)
9127 (let ((c1 (cdr (assq 'action p1)))
9128 (c2 (cdr (assq 'action p2))))
9129 (and c1 c2 (string< c1 c2))))
9131 (defun gnus-request-pseudo-article (props)
9132 (cond ((assq 'execute props)
9133 (gnus-execute-command (cdr (assq 'execute props)))))
9134 (let ((gnus-current-article (gnus-summary-article-number)))
9135 (gnus-run-hooks 'gnus-mark-article-hook)))
9137 (defun gnus-execute-command (command &optional automatic)
9139 (gnus-article-setup-buffer)
9140 (set-buffer gnus-article-buffer)
9141 (setq buffer-read-only nil)
9142 (let ((command (if automatic command
9143 (read-string "Command: " (cons command 0)))))
9145 (insert "$ " command "\n\n")
9146 (if gnus-view-pseudo-asynchronously
9147 (start-process "gnus-execute" (current-buffer) shell-file-name
9148 shell-command-switch command)
9149 (call-process shell-file-name nil t nil
9150 shell-command-switch command)))))
9152 ;; Summary kill commands.
9154 (defun gnus-summary-edit-global-kill (article)
9155 "Edit the \"global\" kill file."
9156 (interactive (list (gnus-summary-article-number)))
9157 (gnus-group-edit-global-kill article))
9159 (defun gnus-summary-edit-local-kill ()
9160 "Edit a local kill file applied to the current newsgroup."
9162 (setq gnus-current-headers (gnus-summary-article-header))
9163 (gnus-group-edit-local-kill
9164 (gnus-summary-article-number) gnus-newsgroup-name))
9168 (defun gnus-read-header (id &optional header)
9169 "Read the headers of article ID and enter them into the Gnus system."
9170 (let ((group gnus-newsgroup-name)
9171 (gnus-override-method
9173 gnus-override-method
9174 (and (gnus-news-group-p gnus-newsgroup-name)
9175 (car (gnus-refer-article-methods)))))
9177 ;; First we check to see whether the header in question is already
9180 ;; This is a Message-ID.
9181 (setq header (or header (gnus-id-to-header id)))
9182 ;; This is an article number.
9183 (setq header (or header (gnus-summary-article-header id))))
9185 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9186 ;; We have found the header.
9188 ;; If this is a sparse article, we have to nix out its
9189 ;; previous entry in the thread hashtb.
9191 (gnus-summary-article-sparse-p (mail-header-number header)))
9192 (let* ((parent (gnus-parent-id (mail-header-references header)))
9193 (thread (and parent (gnus-id-to-thread parent))))
9195 (delq (assq header thread) thread))))
9196 ;; We have to really fetch the header to this article.
9198 (set-buffer nntp-server-buffer)
9199 (when (setq where (gnus-request-head id group))
9200 (nnheader-fold-continuation-lines)
9201 (goto-char (point-max))
9203 (goto-char (point-min))
9207 ((cdr where) (cdr where))
9208 (header (mail-header-number header))
9209 (t gnus-reffed-article-number))
9211 (insert " Article retrieved.\n"))
9213 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9214 () ; Malformed head.
9215 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9216 (when (and (stringp id)
9217 (not (string= (gnus-group-real-name group)
9219 ;; If we fetched by Message-ID and the article came
9220 ;; from a different group, we fudge some bogus article
9221 ;; numbers for this article.
9222 (mail-header-set-number header gnus-reffed-article-number))
9224 (set-buffer gnus-summary-buffer)
9225 (decf gnus-reffed-article-number)
9226 (gnus-remove-header (mail-header-number header))
9227 (push header gnus-newsgroup-headers)
9228 (setq gnus-current-headers header)
9229 (push (mail-header-number header) gnus-newsgroup-limit)))
9232 (defun gnus-remove-header (number)
9233 "Remove header NUMBER from `gnus-newsgroup-headers'."
9234 (if (and gnus-newsgroup-headers
9235 (= number (mail-header-number (car gnus-newsgroup-headers))))
9236 (pop gnus-newsgroup-headers)
9237 (let ((headers gnus-newsgroup-headers))
9238 (while (and (cdr headers)
9239 (not (= number (mail-header-number (cadr headers)))))
9242 (setcdr headers (cddr headers))))))
9245 ;;; summary highlights
9248 (defun gnus-highlight-selected-summary ()
9249 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9250 ;; Highlight selected article in summary buffer
9251 (when gnus-summary-selected-face
9253 (let* ((beg (progn (beginning-of-line) (point)))
9254 (end (progn (end-of-line) (point)))
9255 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9256 (from (if (get-text-property beg gnus-mouse-face-prop)
9258 (or (next-single-property-change
9259 beg gnus-mouse-face-prop nil end)
9264 (or (next-single-property-change
9265 from gnus-mouse-face-prop nil end)
9267 ;; If no mouse-face prop on line we will have to = from = end,
9268 ;; so we highlight the entire line instead.
9269 (when (= (+ to 2) from)
9272 (if gnus-newsgroup-selected-overlay
9273 ;; Move old overlay.
9275 gnus-newsgroup-selected-overlay from to (current-buffer))
9276 ;; Create new overlay.
9278 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9279 'face gnus-summary-selected-face))))))
9281 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9282 (defun gnus-summary-highlight-line ()
9283 "Highlight current line according to `gnus-summary-highlight'."
9284 (let* ((list gnus-summary-highlight)
9286 (end (progn (end-of-line) (point)))
9287 ;; now find out where the line starts and leave point there.
9288 (beg (progn (beginning-of-line) (point)))
9289 (article (gnus-summary-article-number))
9290 (score (or (cdr (assq (or article gnus-current-article)
9291 gnus-newsgroup-scored))
9292 gnus-summary-default-score 0))
9293 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9294 (inhibit-read-only t))
9295 ;; Eval the cars of the lists until we find a match.
9296 (let ((default gnus-summary-default-score))
9298 (not (eval (caar list))))
9299 (setq list (cdr list))))
9300 (let ((face (cdar list)))
9301 (unless (eq face (get-text-property beg 'face))
9302 (gnus-put-text-property-excluding-characters-with-faces
9304 (setq face (if (boundp face) (symbol-value face) face)))
9305 (when gnus-summary-highlight-line-function
9306 (funcall gnus-summary-highlight-line-function article face))))
9309 (defun gnus-update-read-articles (group unread &optional compute)
9310 "Update the list of read articles in GROUP."
9311 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9312 (entry (gnus-gethash group gnus-newsrc-hashtb))
9313 (info (nth 2 entry))
9315 (unread (sort (copy-sequence unread) '<))
9317 (if (or (not info) (not active))
9318 ;; There is no info on this group if it was, in fact,
9319 ;; killed. Gnus stores no information on killed groups, so
9320 ;; there's nothing to be done.
9321 ;; One could store the information somewhere temporarily,
9322 ;; perhaps... Hmmm...
9324 ;; Remove any negative articles numbers.
9325 (while (and unread (< (car unread) 0))
9326 (setq unread (cdr unread)))
9327 ;; Remove any expired article numbers
9328 (while (and unread (< (car unread) (car active)))
9329 (setq unread (cdr unread)))
9330 ;; Compute the ranges of read articles by looking at the list of
9333 (when (/= (car unread) prev)
9334 (push (if (= prev (1- (car unread))) prev
9335 (cons prev (1- (car unread))))
9337 (setq prev (1+ (car unread)))
9338 (setq unread (cdr unread)))
9339 (when (<= prev (cdr active))
9340 (push (cons prev (cdr active)) read))
9341 (setq read (if (> (length read) 1) (nreverse read) read))
9345 (set-buffer gnus-group-buffer)
9348 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9349 (gnus-info-set-read ',info ',(gnus-info-read info))
9350 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9351 (gnus-group-update-group ,group t))))
9352 ;; Propagate the read marks to the backend.
9353 (if (gnus-check-backend-function 'request-set-mark group)
9354 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9355 (add (gnus-remove-from-range read (gnus-info-read info))))
9357 (unless (gnus-check-group group)
9358 (error "Can't open server for %s" group))
9359 (gnus-request-set-mark
9360 group (delq nil (list (if add (list add 'add '(read)))
9361 (if del (list del 'del '(read)))))))))
9362 ;; Enter this list into the group info.
9363 (gnus-info-set-read info read)
9364 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9365 (gnus-get-unread-articles-in-group info (gnus-active group))
9368 (defun gnus-offer-save-summaries ()
9369 "Offer to save all active summary buffers."
9371 (let ((buflist (buffer-list))
9373 ;; Go through all buffers and find all summaries.
9375 (and (setq bufname (buffer-name (car buflist)))
9376 (string-match "Summary" bufname)
9378 (set-buffer bufname)
9379 ;; We check that this is, indeed, a summary buffer.
9380 (and (eq major-mode 'gnus-summary-mode)
9381 ;; Also make sure this isn't bogus.
9382 gnus-newsgroup-prepared
9383 ;; Also make sure that this isn't a dead summary buffer.
9384 (not gnus-dead-summary-mode)))
9385 (push bufname buffers))
9386 (setq buflist (cdr buflist)))
9387 ;; Go through all these summary buffers and offer to save them.
9390 "Update summary buffer %s? "
9392 (switch-to-buffer buf)
9393 (gnus-summary-exit))
9396 (defun gnus-summary-setup-default-charset ()
9397 "Setup newsgroup default charset."
9398 (if (equal gnus-newsgroup-name "nndraft:drafts")
9399 (setq gnus-newsgroup-charset nil)
9400 (let* ((name (and gnus-newsgroup-name
9401 (gnus-group-real-name gnus-newsgroup-name)))
9403 (or gnus-newsgroup-ephemeral-ignored-charsets
9405 (and gnus-newsgroup-name
9406 (or (gnus-group-find-parameter gnus-newsgroup-name
9407 'ignored-charsets t)
9408 (let ((alist gnus-group-ignored-charsets-alist)
9409 elem (charsets nil))
9410 (while (setq elem (pop alist))
9412 (string-match (car elem) name))
9414 charsets (cdr elem))))
9416 gnus-newsgroup-ignored-charsets))))
9417 (setq gnus-newsgroup-charset
9418 (or gnus-newsgroup-ephemeral-charset
9419 (and gnus-newsgroup-name
9420 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9421 (let ((alist gnus-group-charset-alist)
9423 (while (setq elem (pop alist))
9425 (string-match (car elem) name))
9427 charset (cadr elem))))
9429 gnus-default-charset))
9430 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9431 ignored-charsets))))
9437 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9438 "Display the current article buffer fully MIME-buttonized.
9439 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9440 treated as multipart/mixed."
9443 (let ((gnus-unbuttonized-mime-types nil)
9444 (gnus-mime-display-multipart-as-mixed show-all-parts))
9445 (gnus-summary-show-article)))
9447 (defun gnus-summary-repair-multipart (article)
9448 "Add a Content-Type header to a multipart article without one."
9449 (interactive (list (gnus-summary-article-number)))
9450 (gnus-with-article article
9451 (message-narrow-to-head)
9452 (goto-char (point-max))
9454 (when (search-forward "\n--" nil t)
9455 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9456 (message-narrow-to-head)
9457 (message-remove-header "Mime-Version")
9458 (message-remove-header "Content-Type")
9459 (goto-char (point-max))
9460 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9462 (insert "Mime-Version: 1.0\n")
9464 (let (gnus-mark-article-hook)
9465 (gnus-summary-select-article t t nil article)))
9467 (defun gnus-summary-toggle-display-buttonized ()
9468 "Toggle the buttonizing of the article buffer."
9471 (if (setq gnus-inhibit-mime-unbuttonizing
9472 (not gnus-inhibit-mime-unbuttonizing))
9473 (let ((gnus-unbuttonized-mime-types nil))
9474 (gnus-summary-show-article))
9475 (gnus-summary-show-article)))
9481 (defmacro gnus-with-article (article &rest forms)
9482 "Select ARTICLE and perform FORMS in the original article buffer.
9483 Then replace the article with the result."
9485 ;; We don't want the article to be marked as read.
9486 (let (gnus-mark-article-hook)
9487 (gnus-summary-select-article t t nil ,article))
9488 (set-buffer gnus-original-article-buffer)
9490 (if (not (gnus-check-backend-function
9491 'request-replace-article (car gnus-article-current)))
9492 (gnus-message 5 "Read-only group; not replacing")
9493 (unless (gnus-request-replace-article
9494 ,article (car gnus-article-current)
9496 (error "Couldn't replace article")))
9497 ;; The cache and backlog have to be flushed somewhat.
9498 (when gnus-keep-backlog
9499 (gnus-backlog-remove-article
9500 (car gnus-article-current) (cdr gnus-article-current)))
9501 (when gnus-use-cache
9502 (gnus-cache-update-article
9503 (car gnus-article-current) (cdr gnus-article-current)))))
9505 (put 'gnus-with-article 'lisp-indent-function 1)
9506 (put 'gnus-with-article 'edebug-form-spec '(form body))
9509 ;;; Generic summary marking commands
9512 (defvar gnus-summary-marking-alist
9513 '((read gnus-del-mark "d")
9514 (unread gnus-unread-mark "u")
9515 (ticked gnus-ticked-mark "!")
9516 (dormant gnus-dormant-mark "?")
9517 (expirable gnus-expirable-mark "e"))
9518 "An alist of names/marks/keystrokes.")
9520 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9521 (defvar gnus-summary-mark-map)
9523 (defun gnus-summary-make-all-marking-commands ()
9524 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9525 (dolist (elem gnus-summary-marking-alist)
9526 (apply 'gnus-summary-make-marking-command elem)))
9528 (defun gnus-summary-make-marking-command (name mark keystroke)
9529 (let ((map (make-sparse-keymap)))
9530 (define-key gnus-summary-generic-mark-map keystroke map)
9531 (dolist (lway `((next "next" next nil "n")
9532 (next-unread "next unread" next t "N")
9533 (prev "previous" prev nil "p")
9534 (prev-unread "previous unread" prev t "P")
9535 (nomove "" nil nil ,keystroke)))
9536 (let ((func (gnus-summary-make-marking-command-1
9537 mark (car lway) lway name)))
9538 (setq func (eval func))
9539 (define-key map (nth 4 lway) func)))))
9541 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9543 (format "gnus-summary-put-mark-as-%s%s"
9544 name (if (eq way 'nomove)
9546 (concat "-" (symbol-name way)))))
9549 "Mark the current article as %s%s.
9550 If N, the prefix, then repeat N times.
9551 If N is negative, move in reverse order.
9552 The difference between N and the actual number of articles marked is
9556 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9558 (defun gnus-summary-generic-mark (n mark move unread)
9559 "Mark N articles with MARK."
9560 (unless (eq major-mode 'gnus-summary-mode)
9561 (error "This command can only be used in the summary buffer"))
9562 (gnus-summary-show-thread)
9566 ((eq move 'prev) -1)
9572 nummove (* -1 nummove))))
9574 (gnus-summary-mark-article nil mark)
9575 (zerop (gnus-summary-next-subject nummove unread t)))
9578 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9579 (gnus-summary-recenter)
9580 (gnus-summary-position-point)
9581 (gnus-set-mode-line 'summary)
9584 (gnus-summary-make-all-marking-commands)
9590 (run-hooks 'gnus-sum-load-hook)
9592 ;;; gnus-sum.el ends here