1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
46 (autoload 'gnus-cache-articles-in-group "gnus-cache"))
48 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
49 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
51 (defcustom gnus-kill-summary-on-exit t
52 "*If non-nil, kill the summary buffer when you exit from it.
53 If nil, the summary will become a \"*Dead Summary*\" buffer, and
54 it will be killed sometime later."
55 :group 'gnus-summary-exit
58 (defcustom gnus-fetch-old-headers nil
59 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
60 If an unread article in the group refers to an older, already read (or
61 just marked as read) article, the old article will not normally be
62 displayed in the Summary buffer. If this variable is non-nil, Gnus
63 will attempt to grab the headers to the old articles, and thereby
64 build complete threads. If it has the value `some', only enough
65 headers to connect otherwise loose threads will be displayed. This
66 variable can also be a number. In that case, no more than that number
67 of old headers will be fetched. If it has the value `invisible', all
68 old headers will be fetched, but none will be displayed.
70 The server has to support NOV for any of this to work."
72 :type '(choice (const :tag "off" nil)
75 (sexp :menu-tag "other" t)))
77 (defcustom gnus-refer-thread-limit 200
78 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
79 If t, fetch all the available old headers."
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-summary-make-false-root 'adopt
85 "*nil means that Gnus won't gather loose threads.
86 If the root of a thread has expired or been read in a previous
87 session, the information necessary to build a complete thread has been
88 lost. Instead of having many small sub-threads from this original thread
89 scattered all over the summary buffer, Gnus can gather them.
91 If non-nil, Gnus will try to gather all loose sub-threads from an
92 original thread into one large thread.
94 If this variable is non-nil, it should be one of `none', `adopt',
97 If this variable is `none', Gnus will not make a false root, but just
98 present the sub-threads after another.
99 If this variable is `dummy', Gnus will create a dummy root that will
100 have all the sub-threads as children.
101 If this variable is `adopt', Gnus will make one of the \"children\"
102 the parent and mark all the step-children as such.
103 If this variable is `empty', the \"children\" are printed with empty
104 subject fields. (Or rather, they will be printed with a string
105 given by the `gnus-summary-same-subject' variable.)"
107 :type '(choice (const :tag "off" nil)
113 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
114 "*A regexp to match subjects to be excluded from loose thread gathering.
115 As loose thread gathering is done on subjects only, that means that
116 there can be many false gatherings performed. By rooting out certain
117 common subjects, gathering might become saner."
121 (defcustom gnus-summary-gather-subject-limit nil
122 "*Maximum length of subject comparisons when gathering loose threads.
123 Use nil to compare full subjects. Setting this variable to a low
124 number will help gather threads that have been corrupted by
125 newsreaders chopping off subject lines, but it might also mean that
126 unrelated articles that have subject that happen to begin with the
127 same few characters will be incorrectly gathered.
129 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
132 :type '(choice (const :tag "off" nil)
134 (sexp :menu-tag "on" t)))
136 (defcustom gnus-simplify-subject-functions nil
137 "List of functions taking a string argument that simplify subjects.
138 The functions are applied recursively.
140 Useful functions to put in this list include: `gnus-simplify-subject-re',
141 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
143 :type '(repeat function))
145 (defcustom gnus-simplify-ignored-prefixes nil
146 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
148 :type '(choice (const :tag "off" nil)
151 (defcustom gnus-build-sparse-threads nil
152 "*If non-nil, fill in the gaps in threads.
153 If `some', only fill in the gaps that are needed to tie loose threads
154 together. If `more', fill in all leaf nodes that Gnus can find. If
155 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
157 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "all" t)))
162 (defcustom gnus-summary-thread-gathering-function
163 'gnus-gather-threads-by-subject
164 "*Function used for gathering loose threads.
165 There are two pre-defined functions: `gnus-gather-threads-by-subject',
166 which only takes Subjects into consideration; and
167 `gnus-gather-threads-by-references', which compared the References
168 headers of the articles to find matches."
170 :type '(radio (function-item gnus-gather-threads-by-subject)
171 (function-item gnus-gather-threads-by-references)
172 (function :tag "other")))
174 (defcustom gnus-summary-same-subject ""
175 "*String indicating that the current article has the same subject as the previous.
176 This variable will only be used if the value of
177 `gnus-summary-make-false-root' is `empty'."
178 :group 'gnus-summary-format
181 (defcustom gnus-summary-goto-unread t
182 "*If t, marking commands will go to the next unread article.
183 If `never', commands that usually go to the next unread article, will
184 go to the next article, whether it is read or not.
185 If nil, only the marking commands will go to the next (un)read article."
186 :group 'gnus-summary-marks
187 :link '(custom-manual "(gnus)Setting Marks")
188 :type '(choice (const :tag "off" nil)
190 (sexp :menu-tag "on" t)))
192 (defcustom gnus-summary-default-score 0
193 "*Default article score level.
194 All scores generated by the score files will be added to this score.
195 If this variable is nil, scoring will be disabled."
196 :group 'gnus-score-default
197 :type '(choice (const :tag "disable")
200 (defcustom gnus-summary-zcore-fuzz 0
201 "*Fuzziness factor for the zcore in the summary buffer.
202 Articles with scores closer than this to `gnus-summary-default-score'
204 :group 'gnus-summary-format
207 (defcustom gnus-simplify-subject-fuzzy-regexp nil
208 "*Strings to be removed when doing fuzzy matches.
209 This can either be a regular expression or list of regular expressions
210 that will be removed from subject strings if fuzzy subject
211 simplification is selected."
213 :type '(repeat regexp))
215 (defcustom gnus-show-threads t
216 "*If non-nil, display threads in summary mode."
220 (defcustom gnus-thread-hide-subtree nil
221 "*If non-nil, hide all threads initially.
222 If threads are hidden, you have to run the command
223 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
224 to expose hidden threads."
228 (defcustom gnus-thread-hide-killed t
229 "*If non-nil, hide killed threads automatically."
233 (defcustom gnus-thread-ignore-subject t
234 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
235 If nil, articles that have different subjects from their parents will
236 start separate threads."
240 (defcustom gnus-thread-operation-ignore-subject t
241 "*If non-nil, subjects will be ignored when doing thread commands.
242 This affects commands like `gnus-summary-kill-thread' and
243 `gnus-summary-lower-thread'.
245 If this variable is nil, articles in the same thread with different
246 subjects will not be included in the operation in question. If this
247 variable is `fuzzy', only articles that have subjects that are fuzzily
248 equal will be included."
250 :type '(choice (const :tag "off" nil)
254 (defcustom gnus-thread-indent-level 4
255 "*Number that says how much each sub-thread should be indented."
259 (defcustom gnus-auto-extend-newsgroup t
260 "*If non-nil, extend newsgroup forward and backward when requested."
261 :group 'gnus-summary-choose
264 (defcustom gnus-auto-select-first t
265 "*If nil, don't select the first unread article when entering a group.
266 If this variable is `best', select the highest-scored unread article
267 in the group. If t, select the first unread article.
269 This variable can also be a function to place point on a likely
270 subject line. Useful values include `gnus-summary-first-unread-subject',
271 `gnus-summary-first-unread-article' and
272 `gnus-summary-best-unread-article'.
274 If you want to prevent automatic selection of the first unread article
275 in some newsgroups, set the variable to nil in
276 `gnus-select-group-hook'."
277 :group 'gnus-group-select
278 :type '(choice (const :tag "none" nil)
280 (sexp :menu-tag "first" t)
281 (function-item gnus-summary-first-unread-subject)
282 (function-item gnus-summary-first-unread-article)
283 (function-item gnus-summary-best-unread-article)))
285 (defcustom gnus-dont-select-after-jump-to-other-group nil
286 "If non-nil, don't select the first unread article after entering the
287 other group by the command `gnus-summary-jump-to-other-group'. If nil,
288 it is depend on the value of `gnus-auto-select-first' whether to select
290 :group 'gnus-group-select
293 (defcustom gnus-auto-select-next t
294 "*If non-nil, offer to go to the next group from the end of the previous.
295 If the value is t and the next newsgroup is empty, Gnus will exit
296 summary mode and go back to group mode. If the value is neither nil
297 nor t, Gnus will select the following unread newsgroup. In
298 particular, if the value is the symbol `quietly', the next unread
299 newsgroup will be selected without any confirmation, and if it is
300 `almost-quietly', the next group will be selected without any
301 confirmation if you are located on the last article in the group.
302 Finally, if this variable is `slightly-quietly', the `Z n' command
303 will go to the next group without confirmation."
304 :group 'gnus-summary-maneuvering
305 :type '(choice (const :tag "off" nil)
307 (const almost-quietly)
308 (const slightly-quietly)
309 (sexp :menu-tag "on" t)))
311 (defcustom gnus-auto-select-same nil
312 "*If non-nil, select the next article with the same subject.
313 If there are no more articles with the same subject, go to
314 the first unread article."
315 :group 'gnus-summary-maneuvering
318 (defcustom gnus-summary-check-current nil
319 "*If non-nil, consider the current article when moving.
320 The \"unread\" movement commands will stay on the same line if the
321 current article is unread."
322 :group 'gnus-summary-maneuvering
325 (defcustom gnus-auto-center-summary t
326 "*If non-nil, always center the current summary buffer.
327 In particular, if `vertical' do only vertical recentering. If non-nil
328 and non-`vertical', do both horizontal and vertical recentering."
329 :group 'gnus-summary-maneuvering
330 :type '(choice (const :tag "none" nil)
332 (integer :tag "height")
333 (sexp :menu-tag "both" t)))
335 (defcustom gnus-show-all-headers nil
336 "*If non-nil, don't hide any headers."
337 :group 'gnus-article-hiding
338 :group 'gnus-article-headers
341 (defcustom gnus-summary-ignore-duplicates nil
342 "*If non-nil, ignore articles with identical Message-ID headers."
346 (defcustom gnus-single-article-buffer t
347 "*If non-nil, display all articles in the same buffer.
348 If nil, each group will get its own article buffer."
349 :group 'gnus-article-various
352 (defcustom gnus-break-pages t
353 "*If non-nil, do page breaking on articles.
354 The page delimiter is specified by the `gnus-page-delimiter'
356 :group 'gnus-article-various
359 (defcustom gnus-show-mime t
360 "*If non-nil, do mime processing of articles.
361 The articles will simply be fed to the function given by
362 `gnus-article-display-method-for-mime'."
363 :group 'gnus-article-mime
366 (defcustom gnus-move-split-methods nil
367 "*Variable used to suggest where articles are to be moved to.
368 It uses the same syntax as the `gnus-split-methods' variable."
369 :group 'gnus-summary-mail
370 :type '(repeat (choice (list :value (fun) function)
371 (cons :value ("" "") regexp (repeat string))
374 (defcustom gnus-unread-mark ? ;Whitespace
375 "*Mark used for unread articles."
376 :group 'gnus-summary-marks
379 (defcustom gnus-ticked-mark ?!
380 "*Mark used for ticked articles."
381 :group 'gnus-summary-marks
384 (defcustom gnus-dormant-mark ??
385 "*Mark used for dormant articles."
386 :group 'gnus-summary-marks
389 (defcustom gnus-del-mark ?r
390 "*Mark used for del'd articles."
391 :group 'gnus-summary-marks
394 (defcustom gnus-read-mark ?R
395 "*Mark used for read articles."
396 :group 'gnus-summary-marks
399 (defcustom gnus-expirable-mark ?E
400 "*Mark used for expirable articles."
401 :group 'gnus-summary-marks
404 (defcustom gnus-killed-mark ?K
405 "*Mark used for killed articles."
406 :group 'gnus-summary-marks
409 (defcustom gnus-souped-mark ?F
410 "*Mark used for killed articles."
411 :group 'gnus-summary-marks
414 (defcustom gnus-kill-file-mark ?X
415 "*Mark used for articles killed by kill files."
416 :group 'gnus-summary-marks
419 (defcustom gnus-low-score-mark ?Y
420 "*Mark used for articles with a low score."
421 :group 'gnus-summary-marks
424 (defcustom gnus-catchup-mark ?C
425 "*Mark used for articles that are caught up."
426 :group 'gnus-summary-marks
429 (defcustom gnus-replied-mark ?A
430 "*Mark used for articles that have been replied to."
431 :group 'gnus-summary-marks
434 (defcustom gnus-cached-mark ?*
435 "*Mark used for articles that are in the cache."
436 :group 'gnus-summary-marks
439 (defcustom gnus-saved-mark ?S
440 "*Mark used for articles that have been saved to."
441 :group 'gnus-summary-marks
444 (defcustom gnus-ancient-mark ?O
445 "*Mark used for ancient articles."
446 :group 'gnus-summary-marks
449 (defcustom gnus-sparse-mark ?Q
450 "*Mark used for sparsely reffed articles."
451 :group 'gnus-summary-marks
454 (defcustom gnus-canceled-mark ?G
455 "*Mark used for canceled articles."
456 :group 'gnus-summary-marks
459 (defcustom gnus-duplicate-mark ?M
460 "*Mark used for duplicate articles."
461 :group 'gnus-summary-marks
464 (defcustom gnus-undownloaded-mark ?@
465 "*Mark used for articles that weren't downloaded."
466 :group 'gnus-summary-marks
469 (defcustom gnus-downloadable-mark ?%
470 "*Mark used for articles that are to be downloaded."
471 :group 'gnus-summary-marks
474 (defcustom gnus-unsendable-mark ?=
475 "*Mark used for articles that won't be sent."
476 :group 'gnus-summary-marks
479 (defcustom gnus-score-over-mark ?+
480 "*Score mark used for articles with high scores."
481 :group 'gnus-summary-marks
484 (defcustom gnus-score-below-mark ?-
485 "*Score mark used for articles with low scores."
486 :group 'gnus-summary-marks
489 (defcustom gnus-empty-thread-mark ? ;Whitespace
490 "*There is no thread under the article."
491 :group 'gnus-summary-marks
494 (defcustom gnus-not-empty-thread-mark ?=
495 "*There is a thread under the article."
496 :group 'gnus-summary-marks
499 (defcustom gnus-view-pseudo-asynchronously nil
500 "*If non-nil, Gnus will view pseudo-articles asynchronously."
501 :group 'gnus-extract-view
504 (defcustom gnus-auto-expirable-marks
505 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
506 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
507 gnus-souped-mark gnus-duplicate-mark)
508 "*The list of marks converted into expiration if a group is auto-expirable."
510 :type '(repeat character))
512 (defcustom gnus-inhibit-user-auto-expire t
513 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
517 (defcustom gnus-view-pseudos nil
518 "*If `automatic', pseudo-articles will be viewed automatically.
519 If `not-confirm', pseudos will be viewed automatically, and the user
520 will not be asked to confirm the command."
521 :group 'gnus-extract-view
522 :type '(choice (const :tag "off" nil)
524 (const not-confirm)))
526 (defcustom gnus-view-pseudos-separately t
527 "*If non-nil, one pseudo-article will be created for each file to be viewed.
528 If nil, all files that use the same viewing command will be given as a
529 list of parameters to that command."
530 :group 'gnus-extract-view
533 (defcustom gnus-insert-pseudo-articles t
534 "*If non-nil, insert pseudo-articles when decoding articles."
535 :group 'gnus-extract-view
538 (defcustom gnus-summary-dummy-line-format
540 "*The format specification for the dummy roots in the summary buffer.
541 It works along the same lines as a normal formatting string,
542 with some simple extensions.
545 :group 'gnus-threading
548 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
549 "*The format specification for the summary mode line.
550 It works along the same lines as a normal formatting string,
551 with some simple extensions:
554 %p Unprefixed group name
555 %A Current article number
556 %z Current article score
558 %U Number of unread articles in the group
559 %e Number of unselected articles in the group
560 %Z A string with unread/unselected article counts
561 %g Shortish group name
562 %S Subject of the current article
564 %s Current score file name
565 %d Number of dormant articles
566 %r Number of articles that have been marked as read in this session
567 %E Number of articles expunged by the score files"
568 :group 'gnus-summary-format
571 (defcustom gnus-summary-mark-below 0
572 "*Mark all articles with a score below this variable as read.
573 This variable is local to each summary buffer and usually set by the
575 :group 'gnus-score-default
578 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
579 "*List of functions used for sorting articles in the summary buffer.
580 This variable is only used when not using a threaded display."
581 :group 'gnus-summary-sort
582 :type '(repeat (choice (function-item gnus-article-sort-by-number)
583 (function-item gnus-article-sort-by-author)
584 (function-item gnus-article-sort-by-subject)
585 (function-item gnus-article-sort-by-date)
586 (function-item gnus-article-sort-by-score)
587 (function :tag "other"))))
589 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
590 "*List of functions used for sorting threads in the summary buffer.
591 By default, threads are sorted by article number.
593 Each function takes two threads and return non-nil if the first thread
594 should be sorted before the other. If you use more than one function,
595 the primary sort function should be the last. You should probably
596 always include `gnus-thread-sort-by-number' in the list of sorting
597 functions -- preferably first.
599 Ready-made functions include `gnus-thread-sort-by-number',
600 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
601 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
602 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
603 :group 'gnus-summary-sort
604 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
605 (function-item gnus-thread-sort-by-author)
606 (function-item gnus-thread-sort-by-subject)
607 (function-item gnus-thread-sort-by-date)
608 (function-item gnus-thread-sort-by-score)
609 (function-item gnus-thread-sort-by-total-score)
610 (function :tag "other"))))
612 (defcustom gnus-thread-score-function '+
613 "*Function used for calculating the total score of a thread.
615 The function is called with the scores of the article and each
616 subthread and should then return the score of the thread.
618 Some functions you can use are `+', `max', or `min'."
619 :group 'gnus-summary-sort
622 (defcustom gnus-summary-expunge-below nil
623 "All articles that have a score less than this variable will be expunged.
624 This variable is local to the summary buffers."
625 :group 'gnus-score-default
626 :type '(choice (const :tag "off" nil)
629 (defcustom gnus-thread-expunge-below nil
630 "All threads that have a total score less than this variable will be expunged.
631 See `gnus-thread-score-function' for en explanation of what a
634 This variable is local to the summary buffers."
635 :group 'gnus-threading
636 :group 'gnus-score-default
637 :type '(choice (const :tag "off" nil)
640 (defcustom gnus-summary-mode-hook nil
641 "*A hook for Gnus summary mode.
642 This hook is run before any variables are set in the summary buffer."
643 :group 'gnus-summary-various
646 (defcustom gnus-summary-menu-hook nil
647 "*Hook run after the creation of the summary mode menu."
648 :group 'gnus-summary-visual
651 (defcustom gnus-summary-exit-hook nil
652 "*A hook called on exit from the summary buffer.
653 It will be called with point in the group buffer."
654 :group 'gnus-summary-exit
657 (defcustom gnus-summary-prepare-hook nil
658 "*A hook called after the summary buffer has been generated.
659 If you want to modify the summary buffer, you can use this hook."
660 :group 'gnus-summary-various
663 (defcustom gnus-summary-prepared-hook nil
664 "*A hook called as the last thing after the summary buffer has been generated."
665 :group 'gnus-summary-various
668 (defcustom gnus-summary-generate-hook nil
669 "*A hook run just before generating the summary buffer.
670 This hook is commonly used to customize threading variables and the
672 :group 'gnus-summary-various
675 (defcustom gnus-select-group-hook nil
676 "*A hook called when a newsgroup is selected.
678 If you'd like to simplify subjects like the
679 `gnus-summary-next-same-subject' command does, you can use the
682 (setq gnus-select-group-hook
685 (mapcar (lambda (header)
686 (mail-header-set-subject
688 (gnus-simplify-subject
689 (mail-header-subject header) 're-only)))
690 gnus-newsgroup-headers))))"
691 :group 'gnus-group-select
694 (defcustom gnus-select-article-hook nil
695 "*A hook called when an article is selected."
696 :group 'gnus-summary-choose
699 (defcustom gnus-visual-mark-article-hook
700 (list 'gnus-highlight-selected-summary)
701 "*Hook run after selecting an article in the summary buffer.
702 It is meant to be used for highlighting the article in some way. It
703 is not run if `gnus-visual' is nil."
704 :group 'gnus-summary-visual
707 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
708 "*A hook called before parsing the headers."
712 (defcustom gnus-exit-group-hook nil
713 "*A hook called when exiting (not quitting) summary mode."
717 (defcustom gnus-summary-update-hook
718 (list 'gnus-summary-highlight-line)
719 "*A hook called when a summary line is changed.
720 The hook will not be called if `gnus-visual' is nil.
722 The default function `gnus-summary-highlight-line' will
723 highlight the line according to the `gnus-summary-highlight'
725 :group 'gnus-summary-visual
728 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
729 "*A hook called when an article is selected for the first time.
730 The hook is intended to mark an article as read (or unread)
731 automatically when it is selected."
732 :group 'gnus-summary-choose
735 (defcustom gnus-group-no-more-groups-hook nil
736 "*A hook run when returning to group mode having no more (unread) groups."
737 :group 'gnus-group-select
740 (defcustom gnus-ps-print-hook nil
741 "*A hook run before ps-printing something from Gnus."
745 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
746 "Face used for highlighting the current article in the summary buffer."
747 :group 'gnus-summary-visual
750 (defcustom gnus-summary-highlight
751 '(((= mark gnus-canceled-mark)
752 . gnus-summary-cancelled-face)
753 ((and (> score default)
754 (or (= mark gnus-dormant-mark)
755 (= mark gnus-ticked-mark)))
756 . gnus-summary-high-ticked-face)
757 ((and (< score default)
758 (or (= mark gnus-dormant-mark)
759 (= mark gnus-ticked-mark)))
760 . gnus-summary-low-ticked-face)
761 ((or (= mark gnus-dormant-mark)
762 (= mark gnus-ticked-mark))
763 . gnus-summary-normal-ticked-face)
764 ((and (> score default) (= mark gnus-ancient-mark))
765 . gnus-summary-high-ancient-face)
766 ((and (< score default) (= mark gnus-ancient-mark))
767 . gnus-summary-low-ancient-face)
768 ((= mark gnus-ancient-mark)
769 . gnus-summary-normal-ancient-face)
770 ((and (> score default) (= mark gnus-unread-mark))
771 . gnus-summary-high-unread-face)
772 ((and (< score default) (= mark gnus-unread-mark))
773 . gnus-summary-low-unread-face)
774 ((= mark gnus-unread-mark)
775 . gnus-summary-normal-unread-face)
776 ((and (> score default) (memq mark (list gnus-downloadable-mark
777 gnus-undownloaded-mark)))
778 . gnus-summary-high-unread-face)
779 ((and (< score default) (memq mark (list gnus-downloadable-mark
780 gnus-undownloaded-mark)))
781 . gnus-summary-low-unread-face)
782 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
783 . gnus-summary-normal-unread-face)
785 . gnus-summary-high-read-face)
787 . gnus-summary-low-read-face)
789 . gnus-summary-normal-read-face))
790 "*Controls the highlighting of summary buffer lines.
792 A list of (FORM . FACE) pairs. When deciding how a a particular
793 summary line should be displayed, each form is evaluated. The content
794 of the face field after the first true form is used. You can change
795 how those summary lines are displayed, by editing the face field.
797 You can use the following variables in the FORM field.
799 score: The articles score
800 default: The default article score.
801 below: The score below which articles are automatically marked as read.
802 mark: The articles mark."
803 :group 'gnus-summary-visual
804 :type '(repeat (cons (sexp :tag "Form" nil)
807 (defcustom gnus-alter-header-function nil
808 "Function called to allow alteration of article header structures.
809 The function is called with one parameter, the article header vector,
810 which it may alter in any way.")
812 (defvar gnus-decode-encoded-word-function
813 (mime-find-field-decoder 'From 'nov)
814 "Variable that says which function should be used to decode a string with encoded words.")
816 (defcustom gnus-extra-headers nil
817 "*Extra headers to parse."
819 :type '(repeat symbol))
821 (defcustom gnus-ignored-from-addresses
822 (and user-mail-address (regexp-quote user-mail-address))
823 "*Regexp of From headers that may be suppressed in favor of To headers."
827 (defcustom gnus-group-charset-alist
828 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
829 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
830 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
831 ("^relcom\\>" koi8-r)
832 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
833 ("^israel\\>" iso-8859-1)
835 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
837 "Alist of regexps (to match group names) and default charsets to be used when reading."
838 :type '(repeat (list (regexp :tag "Group")
839 (symbol :tag "Charset")))
840 :group 'gnus-charset)
842 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
843 "List of charsets that should be ignored.
844 When these charsets are used in the \"charset\" parameter, the
845 default charset will be used instead."
846 :type '(repeat symbol)
847 :group 'gnus-charset)
849 (defcustom gnus-group-ignored-charsets-alist
850 '(("alt\\.chinese\\.text" iso-8859-1))
851 "Alist of regexps (to match group names) and charsets that should be ignored.
852 When these charsets are used in the \"charset\" parameter, the
853 default charset will be used instead."
854 :type '(repeat (cons (regexp :tag "Group")
856 :group 'gnus-charset)
858 (defcustom gnus-group-highlight-words-alist nil
859 "Alist of group regexps and highlight regexps.
860 This variable uses the same syntax as `gnus-emphasis-alist'."
861 :type '(repeat (cons (regexp :tag "Group")
862 (repeat (list (regexp :tag "Highlight regexp")
863 (number :tag "Group for entire word" 0)
864 (number :tag "Group for displayed part" 0)
866 gnus-emphasis-highlight-words)))))
867 :group 'gnus-summary-visual)
869 ;;; Internal variables
871 (defvar gnus-scores-exclude-files nil)
872 (defvar gnus-page-broken nil)
873 (defvar gnus-inhibit-mime-unbuttonizing nil)
875 (defvar gnus-original-article nil)
876 (defvar gnus-article-internal-prepare-hook nil)
877 (defvar gnus-newsgroup-process-stack nil)
879 (defvar gnus-thread-indent-array nil)
880 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
882 ;; Avoid highlighting in kill files.
883 (defvar gnus-summary-inhibit-highlight nil)
884 (defvar gnus-newsgroup-selected-overlay nil)
885 (defvar gnus-inhibit-limiting nil)
886 (defvar gnus-newsgroup-adaptive-score-file nil)
887 (defvar gnus-current-score-file nil)
888 (defvar gnus-current-move-group nil)
889 (defvar gnus-current-copy-group nil)
890 (defvar gnus-current-crosspost-group nil)
892 (defvar gnus-newsgroup-dependencies nil)
893 (defvar gnus-newsgroup-adaptive nil)
894 (defvar gnus-summary-display-article-function nil)
895 (defvar gnus-summary-highlight-line-function nil
896 "Function called after highlighting a summary line.")
898 (defvar gnus-summary-line-format-alist
899 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
900 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
901 (?s gnus-tmp-subject-or-nil ?s)
902 (?n gnus-tmp-name ?s)
903 (?A (std11-address-string
904 (car (mime-read-field 'From gnus-tmp-header))) ?s)
905 (?a (or (std11-full-name-string
906 (car (mime-read-field 'From gnus-tmp-header)))
908 (?F gnus-tmp-from ?s)
909 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
910 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
911 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
912 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
913 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
914 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
915 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
916 (?L gnus-tmp-lines ?d)
917 (?I gnus-tmp-indentation ?s)
918 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
919 (?R gnus-tmp-replied ?c)
920 (?\[ gnus-tmp-opening-bracket ?c)
921 (?\] gnus-tmp-closing-bracket ?c)
922 (?\> (make-string gnus-tmp-level ? ) ?s)
923 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
924 (?i gnus-tmp-score ?d)
925 (?z gnus-tmp-score-char ?c)
926 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
927 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
928 (?U gnus-tmp-unread ?c)
929 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
930 (?t (gnus-summary-number-of-articles-in-thread
931 (and (boundp 'thread) (car thread)) gnus-tmp-level)
933 (?e (gnus-summary-number-of-articles-in-thread
934 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
936 (?u gnus-tmp-user-defined ?s)
937 (?P (gnus-pick-line-number) ?d))
938 "An alist of format specifications that can appear in summary lines,
939 and what variables they correspond with, along with the type of the
940 variable (string, integer, character, etc).")
942 (defvar gnus-summary-dummy-line-format-alist
943 `((?S gnus-tmp-subject ?s)
944 (?N gnus-tmp-number ?d)
945 (?u gnus-tmp-user-defined ?s)))
947 (defvar gnus-summary-mode-line-format-alist
948 `((?G gnus-tmp-group-name ?s)
949 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
950 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
951 (?A gnus-tmp-article-number ?d)
952 (?Z gnus-tmp-unread-and-unselected ?s)
954 (?U gnus-tmp-unread-and-unticked ?d)
955 (?S gnus-tmp-subject ?s)
956 (?e gnus-tmp-unselected ?d)
957 (?u gnus-tmp-user-defined ?s)
958 (?d (length gnus-newsgroup-dormant) ?d)
959 (?t (length gnus-newsgroup-marked) ?d)
960 (?r (length gnus-newsgroup-reads) ?d)
961 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
962 (?E gnus-newsgroup-expunged-tally ?d)
963 (?s (gnus-current-score-file-nondirectory) ?s)))
965 (defvar gnus-last-search-regexp nil
966 "Default regexp for article search command.")
968 (defvar gnus-last-shell-command nil
969 "Default shell command on article.")
971 (defvar gnus-newsgroup-begin nil)
972 (defvar gnus-newsgroup-end nil)
973 (defvar gnus-newsgroup-last-rmail nil)
974 (defvar gnus-newsgroup-last-mail nil)
975 (defvar gnus-newsgroup-last-folder nil)
976 (defvar gnus-newsgroup-last-file nil)
977 (defvar gnus-newsgroup-auto-expire nil)
978 (defvar gnus-newsgroup-active nil)
980 (defvar gnus-newsgroup-data nil)
981 (defvar gnus-newsgroup-data-reverse nil)
982 (defvar gnus-newsgroup-limit nil)
983 (defvar gnus-newsgroup-limits nil)
985 (defvar gnus-newsgroup-unreads nil
986 "List of unread articles in the current newsgroup.")
988 (defvar gnus-newsgroup-unselected nil
989 "List of unselected unread articles in the current newsgroup.")
991 (defvar gnus-newsgroup-reads nil
992 "Alist of read articles and article marks in the current newsgroup.")
994 (defvar gnus-newsgroup-expunged-tally nil)
996 (defvar gnus-newsgroup-marked nil
997 "List of ticked articles in the current newsgroup (a subset of unread art).")
999 (defvar gnus-newsgroup-killed nil
1000 "List of ranges of articles that have been through the scoring process.")
1002 (defvar gnus-newsgroup-cached nil
1003 "List of articles that come from the article cache.")
1005 (defvar gnus-newsgroup-saved nil
1006 "List of articles that have been saved.")
1008 (defvar gnus-newsgroup-kill-headers nil)
1010 (defvar gnus-newsgroup-replied nil
1011 "List of articles that have been replied to in the current newsgroup.")
1013 (defvar gnus-newsgroup-expirable nil
1014 "List of articles in the current newsgroup that can be expired.")
1016 (defvar gnus-newsgroup-processable nil
1017 "List of articles in the current newsgroup that can be processed.")
1019 (defvar gnus-newsgroup-downloadable nil
1020 "List of articles in the current newsgroup that can be processed.")
1022 (defvar gnus-newsgroup-undownloaded nil
1023 "List of articles in the current newsgroup that haven't been downloaded..")
1025 (defvar gnus-newsgroup-unsendable nil
1026 "List of articles in the current newsgroup that won't be sent.")
1028 (defvar gnus-newsgroup-bookmarks nil
1029 "List of articles in the current newsgroup that have bookmarks.")
1031 (defvar gnus-newsgroup-dormant nil
1032 "List of dormant articles in the current newsgroup.")
1034 (defvar gnus-newsgroup-scored nil
1035 "List of scored articles in the current newsgroup.")
1037 (defvar gnus-newsgroup-headers nil
1038 "List of article headers in the current newsgroup.")
1040 (defvar gnus-newsgroup-threads nil)
1042 (defvar gnus-newsgroup-prepared nil
1043 "Whether the current group has been prepared properly.")
1045 (defvar gnus-newsgroup-ancient nil
1046 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1048 (defvar gnus-newsgroup-sparse nil)
1050 (defvar gnus-current-article nil)
1051 (defvar gnus-article-current nil)
1052 (defvar gnus-current-headers nil)
1053 (defvar gnus-have-all-headers nil)
1054 (defvar gnus-last-article nil)
1055 (defvar gnus-newsgroup-history nil)
1056 (defvar gnus-newsgroup-charset nil)
1057 (defvar gnus-newsgroup-ephemeral-charset nil)
1058 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1060 (defconst gnus-summary-local-variables
1061 '(gnus-newsgroup-name
1062 gnus-newsgroup-begin gnus-newsgroup-end
1063 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1064 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1065 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1066 gnus-newsgroup-unselected gnus-newsgroup-marked
1067 gnus-newsgroup-reads gnus-newsgroup-saved
1068 gnus-newsgroup-replied gnus-newsgroup-expirable
1069 gnus-newsgroup-processable gnus-newsgroup-killed
1070 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1071 gnus-newsgroup-unsendable
1072 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1073 gnus-newsgroup-headers gnus-newsgroup-threads
1074 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1075 gnus-current-article gnus-current-headers gnus-have-all-headers
1076 gnus-last-article gnus-article-internal-prepare-hook
1077 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1078 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1079 gnus-thread-expunge-below
1080 gnus-score-alist gnus-current-score-file
1081 (gnus-summary-expunge-below . global)
1082 (gnus-summary-mark-below . global)
1083 gnus-newsgroup-active gnus-scores-exclude-files
1084 gnus-newsgroup-history gnus-newsgroup-ancient
1085 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1086 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1087 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1088 (gnus-newsgroup-expunged-tally . 0)
1089 gnus-cache-removable-articles gnus-newsgroup-cached
1090 gnus-newsgroup-data gnus-newsgroup-data-reverse
1091 gnus-newsgroup-limit gnus-newsgroup-limits
1092 gnus-newsgroup-charset)
1093 "Variables that are buffer-local to the summary buffers.")
1095 ;; Byte-compiler warning.
1096 (defvar gnus-article-mode-map)
1098 ;; Subject simplification.
1100 (defun gnus-simplify-whitespace (str)
1101 "Remove excessive whitespace."
1104 (while (string-match "[ \t][ \t]+" mystr)
1105 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1107 (substring mystr (match-end 0)))))
1109 (when (string-match "^[ \t]+" mystr)
1110 (setq mystr (substring mystr (match-end 0))))
1112 (when (string-match "[ \t]+$" mystr)
1113 (setq mystr (substring mystr 0 (match-beginning 0))))
1116 (defsubst gnus-simplify-subject-re (subject)
1117 "Remove \"Re:\" from subject lines."
1118 (if (string-match "^[Rr][Ee]: *" subject)
1119 (substring subject (match-end 0))
1122 (defun gnus-simplify-subject (subject &optional re-only)
1123 "Remove `Re:' and words in parentheses.
1124 If RE-ONLY is non-nil, strip leading `Re:'s only."
1125 (let ((case-fold-search t)) ;Ignore case.
1126 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1127 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1128 (setq subject (substring subject (match-end 0))))
1129 ;; Remove uninteresting prefixes.
1130 (when (and (not re-only)
1131 gnus-simplify-ignored-prefixes
1132 (string-match gnus-simplify-ignored-prefixes subject))
1133 (setq subject (substring subject (match-end 0))))
1134 ;; Remove words in parentheses from end.
1136 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1137 (setq subject (substring subject 0 (match-beginning 0)))))
1138 ;; Return subject string.
1141 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1143 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1144 (goto-char (point-min))
1145 (while (re-search-forward regexp nil t)
1146 (replace-match (or newtext ""))))
1148 (defun gnus-simplify-buffer-fuzzy ()
1149 "Simplify string in the buffer fuzzily.
1150 The string in the accessible portion of the current buffer is simplified.
1151 It is assumed to be a single-line subject.
1152 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1153 matter is removed. Additional things can be deleted by setting
1154 gnus-simplify-subject-fuzzy-regexp."
1155 (let ((case-fold-search t)
1157 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1159 (while (not (eq modified-tick (buffer-modified-tick)))
1160 (setq modified-tick (buffer-modified-tick))
1162 ((listp gnus-simplify-subject-fuzzy-regexp)
1163 (mapcar 'gnus-simplify-buffer-fuzzy-step
1164 gnus-simplify-subject-fuzzy-regexp))
1165 (gnus-simplify-subject-fuzzy-regexp
1166 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1167 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1168 (gnus-simplify-buffer-fuzzy-step
1169 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1170 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1172 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1173 (gnus-simplify-buffer-fuzzy-step " +" " ")
1174 (gnus-simplify-buffer-fuzzy-step " $")
1175 (gnus-simplify-buffer-fuzzy-step "^ +")))
1177 (defun gnus-simplify-subject-fuzzy (subject)
1178 "Simplify a subject string fuzzily.
1179 See `gnus-simplify-buffer-fuzzy' for details."
1181 (gnus-set-work-buffer)
1182 (let ((case-fold-search t))
1183 ;; Remove uninteresting prefixes.
1184 (when (and gnus-simplify-ignored-prefixes
1185 (string-match gnus-simplify-ignored-prefixes subject))
1186 (setq subject (substring subject (match-end 0))))
1188 (inline (gnus-simplify-buffer-fuzzy))
1191 (defsubst gnus-simplify-subject-fully (subject)
1192 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1194 (gnus-simplify-subject-functions
1195 (gnus-map-function gnus-simplify-subject-functions subject))
1196 ((null gnus-summary-gather-subject-limit)
1197 (gnus-simplify-subject-re subject))
1198 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1199 (gnus-simplify-subject-fuzzy subject))
1200 ((numberp gnus-summary-gather-subject-limit)
1201 (gnus-limit-string (gnus-simplify-subject-re subject)
1202 gnus-summary-gather-subject-limit))
1206 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1207 "Check whether two subjects are equal.
1208 If optional argument simple-first is t, first argument is already
1211 ((null simple-first)
1212 (equal (gnus-simplify-subject-fully s1)
1213 (gnus-simplify-subject-fully s2)))
1216 (gnus-simplify-subject-fully s2)))))
1218 (defun gnus-summary-bubble-group ()
1219 "Increase the score of the current group.
1220 This is a handy function to add to `gnus-summary-exit-hook' to
1221 increase the score of each group you read."
1222 (gnus-group-add-score gnus-newsgroup-name))
1226 ;;; Gnus summary mode
1229 (put 'gnus-summary-mode 'mode-class 'special)
1232 ;; Non-orthogonal keys
1234 (gnus-define-keys gnus-summary-mode-map
1235 " " gnus-summary-next-page
1236 "\177" gnus-summary-prev-page
1237 [delete] gnus-summary-prev-page
1238 [backspace] gnus-summary-prev-page
1239 "\r" gnus-summary-scroll-up
1240 "\M-\r" gnus-summary-scroll-down
1241 "n" gnus-summary-next-unread-article
1242 "p" gnus-summary-prev-unread-article
1243 "N" gnus-summary-next-article
1244 "P" gnus-summary-prev-article
1245 "\M-\C-n" gnus-summary-next-same-subject
1246 "\M-\C-p" gnus-summary-prev-same-subject
1247 "\M-n" gnus-summary-next-unread-subject
1248 "\M-p" gnus-summary-prev-unread-subject
1249 "." gnus-summary-first-unread-article
1250 "," gnus-summary-best-unread-article
1251 "\M-s" gnus-summary-search-article-forward
1252 "\M-r" gnus-summary-search-article-backward
1253 "<" gnus-summary-beginning-of-article
1254 ">" gnus-summary-end-of-article
1255 "j" gnus-summary-goto-article
1256 "^" gnus-summary-refer-parent-article
1257 "\M-^" gnus-summary-refer-article
1258 "u" gnus-summary-tick-article-forward
1259 "!" gnus-summary-tick-article-forward
1260 "U" gnus-summary-tick-article-backward
1261 "d" gnus-summary-mark-as-read-forward
1262 "D" gnus-summary-mark-as-read-backward
1263 "E" gnus-summary-mark-as-expirable
1264 "\M-u" gnus-summary-clear-mark-forward
1265 "\M-U" gnus-summary-clear-mark-backward
1266 "k" gnus-summary-kill-same-subject-and-select
1267 "\C-k" gnus-summary-kill-same-subject
1268 "\M-\C-k" gnus-summary-kill-thread
1269 "\M-\C-l" gnus-summary-lower-thread
1270 "e" gnus-summary-edit-article
1271 "#" gnus-summary-mark-as-processable
1272 "\M-#" gnus-summary-unmark-as-processable
1273 "\M-\C-t" gnus-summary-toggle-threads
1274 "\M-\C-s" gnus-summary-show-thread
1275 "\M-\C-h" gnus-summary-hide-thread
1276 "\M-\C-f" gnus-summary-next-thread
1277 "\M-\C-b" gnus-summary-prev-thread
1278 "\M-\C-u" gnus-summary-up-thread
1279 "\M-\C-d" gnus-summary-down-thread
1280 "&" gnus-summary-execute-command
1281 "c" gnus-summary-catchup-and-exit
1282 "\C-w" gnus-summary-mark-region-as-read
1283 "\C-t" gnus-summary-toggle-truncation
1284 "?" gnus-summary-mark-as-dormant
1285 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1286 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1287 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1288 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1289 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1290 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1291 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1292 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1293 "=" gnus-summary-expand-window
1294 "\C-x\C-s" gnus-summary-reselect-current-group
1295 "\M-g" gnus-summary-rescan-group
1296 "w" gnus-summary-stop-page-breaking
1297 "\C-c\C-r" gnus-summary-caesar-message
1298 "\M-t" gnus-summary-toggle-mime
1299 "f" gnus-summary-followup
1300 "F" gnus-summary-followup-with-original
1301 "C" gnus-summary-cancel-article
1302 "r" gnus-summary-reply
1303 "R" gnus-summary-reply-with-original
1304 "\C-c\C-f" gnus-summary-mail-forward
1305 "o" gnus-summary-save-article
1306 "\C-o" gnus-summary-save-article-mail
1307 "|" gnus-summary-pipe-output
1308 "\M-k" gnus-summary-edit-local-kill
1309 "\M-K" gnus-summary-edit-global-kill
1311 "\C-c\C-d" gnus-summary-describe-group
1312 "q" gnus-summary-exit
1313 "Q" gnus-summary-exit-no-update
1314 "\C-c\C-i" gnus-info-find-node
1315 gnus-mouse-2 gnus-mouse-pick-article
1316 "m" gnus-summary-mail-other-window
1317 "a" gnus-summary-post-news
1318 "x" gnus-summary-limit-to-unread
1319 "s" gnus-summary-isearch-article
1320 "t" gnus-article-toggle-headers
1321 "g" gnus-summary-show-article
1322 "l" gnus-summary-goto-last-article
1323 "v" gnus-summary-preview-mime-message
1324 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1325 "\C-d" gnus-summary-enter-digest-group
1326 "\M-\C-d" gnus-summary-read-document
1327 "\M-\C-e" gnus-summary-edit-parameters
1328 "\M-\C-g" gnus-summary-customize-parameters
1330 "*" gnus-cache-enter-article
1331 "\M-*" gnus-cache-remove-article
1332 "\M-&" gnus-summary-universal-argument
1333 "\C-l" gnus-recenter
1334 "I" gnus-summary-increase-score
1335 "L" gnus-summary-lower-score
1336 "\M-i" gnus-symbolic-argument
1337 "h" gnus-summary-select-article-buffer
1339 "V" gnus-summary-score-map
1340 "X" gnus-uu-extract-map
1341 "S" gnus-summary-send-map)
1343 ;; Sort of orthogonal keymap
1344 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1345 "t" gnus-summary-tick-article-forward
1346 "!" gnus-summary-tick-article-forward
1347 "d" gnus-summary-mark-as-read-forward
1348 "r" gnus-summary-mark-as-read-forward
1349 "c" gnus-summary-clear-mark-forward
1350 " " gnus-summary-clear-mark-forward
1351 "e" gnus-summary-mark-as-expirable
1352 "x" gnus-summary-mark-as-expirable
1353 "?" gnus-summary-mark-as-dormant
1354 "b" gnus-summary-set-bookmark
1355 "B" gnus-summary-remove-bookmark
1356 "#" gnus-summary-mark-as-processable
1357 "\M-#" gnus-summary-unmark-as-processable
1358 "S" gnus-summary-limit-include-expunged
1359 "C" gnus-summary-catchup
1360 "H" gnus-summary-catchup-to-here
1361 "\C-c" gnus-summary-catchup-all
1362 "k" gnus-summary-kill-same-subject-and-select
1363 "K" gnus-summary-kill-same-subject
1364 "P" gnus-uu-mark-map)
1366 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1367 "c" gnus-summary-clear-above
1368 "u" gnus-summary-tick-above
1369 "m" gnus-summary-mark-above
1370 "k" gnus-summary-kill-below)
1372 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1373 "/" gnus-summary-limit-to-subject
1374 "n" gnus-summary-limit-to-articles
1375 "w" gnus-summary-pop-limit
1376 "s" gnus-summary-limit-to-subject
1377 "a" gnus-summary-limit-to-author
1378 "u" gnus-summary-limit-to-unread
1379 "m" gnus-summary-limit-to-marks
1380 "M" gnus-summary-limit-exclude-marks
1381 "v" gnus-summary-limit-to-score
1382 "*" gnus-summary-limit-include-cached
1383 "D" gnus-summary-limit-include-dormant
1384 "T" gnus-summary-limit-include-thread
1385 "d" gnus-summary-limit-exclude-dormant
1386 "t" gnus-summary-limit-to-age
1387 "x" gnus-summary-limit-to-extra
1388 "E" gnus-summary-limit-include-expunged
1389 "c" gnus-summary-limit-exclude-childless-dormant
1390 "C" gnus-summary-limit-mark-excluded-as-read)
1392 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1393 "n" gnus-summary-next-unread-article
1394 "p" gnus-summary-prev-unread-article
1395 "N" gnus-summary-next-article
1396 "P" gnus-summary-prev-article
1397 "\C-n" gnus-summary-next-same-subject
1398 "\C-p" gnus-summary-prev-same-subject
1399 "\M-n" gnus-summary-next-unread-subject
1400 "\M-p" gnus-summary-prev-unread-subject
1401 "f" gnus-summary-first-unread-article
1402 "b" gnus-summary-best-unread-article
1403 "j" gnus-summary-goto-article
1404 "g" gnus-summary-goto-subject
1405 "l" gnus-summary-goto-last-article
1406 "o" gnus-summary-pop-article)
1408 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1409 "k" gnus-summary-kill-thread
1410 "l" gnus-summary-lower-thread
1411 "i" gnus-summary-raise-thread
1412 "T" gnus-summary-toggle-threads
1413 "t" gnus-summary-rethread-current
1414 "^" gnus-summary-reparent-thread
1415 "s" gnus-summary-show-thread
1416 "S" gnus-summary-show-all-threads
1417 "h" gnus-summary-hide-thread
1418 "H" gnus-summary-hide-all-threads
1419 "n" gnus-summary-next-thread
1420 "p" gnus-summary-prev-thread
1421 "u" gnus-summary-up-thread
1422 "o" gnus-summary-top-thread
1423 "d" gnus-summary-down-thread
1424 "#" gnus-uu-mark-thread
1425 "\M-#" gnus-uu-unmark-thread)
1427 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1428 "g" gnus-summary-prepare
1429 "c" gnus-summary-insert-cached-articles)
1431 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1432 "c" gnus-summary-catchup-and-exit
1433 "C" gnus-summary-catchup-all-and-exit
1434 "E" gnus-summary-exit-no-update
1435 "J" gnus-summary-jump-to-other-group
1436 "Q" gnus-summary-exit
1437 "Z" gnus-summary-exit
1438 "n" gnus-summary-catchup-and-goto-next-group
1439 "R" gnus-summary-reselect-current-group
1440 "G" gnus-summary-rescan-group
1441 "N" gnus-summary-next-group
1442 "s" gnus-summary-save-newsrc
1443 "P" gnus-summary-prev-group)
1445 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1446 " " gnus-summary-next-page
1447 "n" gnus-summary-next-page
1448 "\177" gnus-summary-prev-page
1449 [delete] gnus-summary-prev-page
1450 "p" gnus-summary-prev-page
1451 "\r" gnus-summary-scroll-up
1452 "\M-\r" gnus-summary-scroll-down
1453 "<" gnus-summary-beginning-of-article
1454 ">" gnus-summary-end-of-article
1455 "b" gnus-summary-beginning-of-article
1456 "e" gnus-summary-end-of-article
1457 "^" gnus-summary-refer-parent-article
1458 "r" gnus-summary-refer-parent-article
1459 "D" gnus-summary-enter-digest-group
1460 "R" gnus-summary-refer-references
1461 "T" gnus-summary-refer-thread
1462 "g" gnus-summary-show-article
1463 "s" gnus-summary-isearch-article
1464 "P" gnus-summary-print-article
1465 "t" gnus-article-babel)
1467 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1468 "b" gnus-article-add-buttons
1469 "B" gnus-article-add-buttons-to-head
1470 "o" gnus-article-treat-overstrike
1471 "e" gnus-article-emphasize
1472 "w" gnus-article-fill-cited-article
1473 "Q" gnus-article-fill-long-lines
1474 "C" gnus-article-capitalize-sentences
1475 "c" gnus-article-remove-cr
1476 "f" gnus-article-display-x-face
1477 "l" gnus-summary-stop-page-breaking
1478 "r" gnus-summary-caesar-message
1479 "t" gnus-article-toggle-headers
1480 "v" gnus-summary-verbose-headers
1481 "m" gnus-summary-toggle-mime
1482 "H" gnus-article-strip-headers-in-body
1483 "d" gnus-article-treat-dumbquotes)
1485 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1486 "a" gnus-article-hide
1487 "h" gnus-article-toggle-headers
1488 "b" gnus-article-hide-boring-headers
1489 "s" gnus-article-hide-signature
1490 "c" gnus-article-hide-citation
1491 "C" gnus-article-hide-citation-in-followups
1492 "p" gnus-article-hide-pgp
1493 "B" gnus-article-strip-banner
1494 "P" gnus-article-hide-pem
1495 "\C-c" gnus-article-hide-citation-maybe)
1497 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1498 "a" gnus-article-highlight
1499 "h" gnus-article-highlight-headers
1500 "c" gnus-article-highlight-citation
1501 "s" gnus-article-highlight-signature)
1503 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1504 "z" gnus-article-date-ut
1505 "u" gnus-article-date-ut
1506 "l" gnus-article-date-local
1507 "e" gnus-article-date-lapsed
1508 "o" gnus-article-date-original
1509 "i" gnus-article-date-iso8601
1510 "s" gnus-article-date-user)
1512 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1513 "t" gnus-article-remove-trailing-blank-lines
1514 "l" gnus-article-strip-leading-blank-lines
1515 "m" gnus-article-strip-multiple-blank-lines
1516 "a" gnus-article-strip-blank-lines
1517 "A" gnus-article-strip-all-blank-lines
1518 "s" gnus-article-strip-leading-space
1519 "e" gnus-article-strip-trailing-space)
1521 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1523 "f" gnus-summary-fetch-faq
1524 "d" gnus-summary-describe-group
1525 "h" gnus-summary-describe-briefly
1526 "i" gnus-info-find-node)
1528 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1529 "e" gnus-summary-expire-articles
1530 "\M-\C-e" gnus-summary-expire-articles-now
1531 "\177" gnus-summary-delete-article
1532 [delete] gnus-summary-delete-article
1533 [backspace] gnus-summary-delete-article
1534 "m" gnus-summary-move-article
1535 "r" gnus-summary-respool-article
1536 "w" gnus-summary-edit-article
1537 "c" gnus-summary-copy-article
1538 "B" gnus-summary-crosspost-article
1539 "q" gnus-summary-respool-query
1540 "t" gnus-summary-respool-trace
1541 "i" gnus-summary-import-article
1542 "p" gnus-summary-article-posted-p)
1544 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1545 "o" gnus-summary-save-article
1546 "m" gnus-summary-save-article-mail
1547 "F" gnus-summary-write-article-file
1548 "r" gnus-summary-save-article-rmail
1549 "f" gnus-summary-save-article-file
1550 "b" gnus-summary-save-article-body-file
1551 "h" gnus-summary-save-article-folder
1552 "v" gnus-summary-save-article-vm
1553 "p" gnus-summary-pipe-output
1554 "s" gnus-soup-add-article)
1556 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1557 "b" gnus-summary-display-buttonized
1558 "m" gnus-summary-repair-multipart
1559 "v" gnus-article-view-part
1560 "o" gnus-article-save-part
1561 "c" gnus-article-copy-part
1562 "e" gnus-article-externalize-part
1563 "i" gnus-article-inline-part
1564 "|" gnus-article-pipe-part)
1567 (defun gnus-summary-make-menu-bar ()
1568 (gnus-turn-off-edit-menu 'summary)
1570 (unless (boundp 'gnus-summary-misc-menu)
1573 gnus-summary-kill-menu gnus-summary-mode-map ""
1578 ["Enter score..." gnus-summary-score-entry t]
1579 ["Customize" gnus-score-customize t])
1580 (gnus-make-score-map 'increase)
1581 (gnus-make-score-map 'lower)
1583 ["Kill below" gnus-summary-kill-below t]
1584 ["Mark above" gnus-summary-mark-above t]
1585 ["Tick above" gnus-summary-tick-above t]
1586 ["Clear above" gnus-summary-clear-above t])
1587 ["Current score" gnus-summary-current-score t]
1588 ["Set score" gnus-summary-set-score t]
1589 ["Switch current score file..." gnus-score-change-score-file t]
1590 ["Set mark below..." gnus-score-set-mark-below t]
1591 ["Set expunge below..." gnus-score-set-expunge-below t]
1592 ["Edit current score file" gnus-score-edit-current-scores t]
1593 ["Edit score file" gnus-score-edit-file t]
1594 ["Trace score" gnus-score-find-trace t]
1595 ["Find words" gnus-score-find-favourite-words t]
1596 ["Rescore buffer" gnus-summary-rescore t]
1597 ["Increase score..." gnus-summary-increase-score t]
1598 ["Lower score..." gnus-summary-lower-score t]))))
1600 ;; Define both the Article menu in the summary buffer and the equivalent
1601 ;; Commands menu in the article buffer here for consistency.
1604 ["All" gnus-article-hide t]
1605 ["Headers" gnus-article-toggle-headers t]
1606 ["Signature" gnus-article-hide-signature t]
1607 ["Citation" gnus-article-hide-citation t]
1608 ["PGP" gnus-article-hide-pgp t]
1609 ["Banner" gnus-article-strip-banner t]
1610 ["Boring headers" gnus-article-hide-boring-headers t])
1612 ["All" gnus-article-highlight t]
1613 ["Headers" gnus-article-highlight-headers t]
1614 ["Signature" gnus-article-highlight-signature t]
1615 ["Citation" gnus-article-highlight-citation t])
1617 ["Local" gnus-article-date-local t]
1618 ["ISO8601" gnus-article-date-iso8601 t]
1619 ["UT" gnus-article-date-ut t]
1620 ["Original" gnus-article-date-original t]
1621 ["Lapsed" gnus-article-date-lapsed t]
1622 ["User-defined" gnus-article-date-user t])
1625 ["Leading" gnus-article-strip-leading-blank-lines t]
1626 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1627 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1628 ["All of the above" gnus-article-strip-blank-lines t]
1629 ["All" gnus-article-strip-all-blank-lines t]
1630 ["Leading space" gnus-article-strip-leading-space t]
1631 ["Trailing space" gnus-article-strip-trailing-space t])
1632 ["Overstrike" gnus-article-treat-overstrike t]
1633 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1634 ["Emphasis" gnus-article-emphasize t]
1635 ["Word wrap" gnus-article-fill-cited-article t]
1636 ["Fill long lines" gnus-article-fill-long-lines t]
1637 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1638 ["CR" gnus-article-remove-cr t]
1639 ["Show X-Face" gnus-article-display-x-face t]
1640 ["Rot 13" gnus-summary-caesar-message t]
1641 ["Unix pipe" gnus-summary-pipe-message t]
1642 ["Add buttons" gnus-article-add-buttons t]
1643 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1644 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1645 ["Toggle MIME" gnus-summary-toggle-mime t]
1646 ["Verbose header" gnus-summary-verbose-headers t]
1647 ["Toggle header" gnus-summary-toggle-header t])
1649 ["Save in default format" gnus-summary-save-article t]
1650 ["Save in file" gnus-summary-save-article-file t]
1651 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1652 ["Save in MH folder" gnus-summary-save-article-folder t]
1653 ["Save in VM folder" gnus-summary-save-article-vm t]
1654 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1655 ["Save body in file" gnus-summary-save-article-body-file t]
1656 ["Pipe through a filter" gnus-summary-pipe-output t]
1657 ["Add to SOUP packet" gnus-soup-add-article t]
1658 ["Print" gnus-summary-print-article t])
1660 ["Respool article..." gnus-summary-respool-article t]
1661 ["Move article..." gnus-summary-move-article
1662 (gnus-check-backend-function
1663 'request-move-article gnus-newsgroup-name)]
1664 ["Copy article..." gnus-summary-copy-article t]
1665 ["Crosspost article..." gnus-summary-crosspost-article
1666 (gnus-check-backend-function
1667 'request-replace-article gnus-newsgroup-name)]
1668 ["Import file..." gnus-summary-import-article t]
1669 ["Check if posted" gnus-summary-article-posted-p t]
1670 ["Edit article" gnus-summary-edit-article
1671 (not (gnus-group-read-only-p))]
1672 ["Delete article" gnus-summary-delete-article
1673 (gnus-check-backend-function
1674 'request-expire-articles gnus-newsgroup-name)]
1675 ["Query respool" gnus-summary-respool-query t]
1676 ["Trace respool" gnus-summary-respool-trace t]
1677 ["Delete expirable articles" gnus-summary-expire-articles-now
1678 (gnus-check-backend-function
1679 'request-expire-articles gnus-newsgroup-name)])
1681 ["Uudecode" gnus-uu-decode-uu t]
1682 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1683 ["Unshar" gnus-uu-decode-unshar t]
1684 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1685 ["Save" gnus-uu-decode-save t]
1686 ["Binhex" gnus-uu-decode-binhex t]
1687 ["Postscript" gnus-uu-decode-postscript t])
1689 ["Enter article" gnus-cache-enter-article t]
1690 ["Remove article" gnus-cache-remove-article t])
1691 ["Translate" gnus-article-babel t]
1692 ["Select article buffer" gnus-summary-select-article-buffer t]
1693 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1694 ["Isearch article..." gnus-summary-isearch-article t]
1695 ["Beginning of the article" gnus-summary-beginning-of-article t]
1696 ["End of the article" gnus-summary-end-of-article t]
1697 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1698 ["Fetch referenced articles" gnus-summary-refer-references t]
1699 ["Fetch current thread" gnus-summary-refer-thread t]
1700 ["Fetch article with id..." gnus-summary-refer-article t]
1701 ["Redisplay" gnus-summary-show-article t])))
1703 gnus-summary-article-menu gnus-summary-mode-map ""
1704 (cons "Article" innards))
1707 gnus-article-commands-menu gnus-article-mode-map ""
1708 (cons "Commands" innards)))
1711 gnus-summary-thread-menu gnus-summary-mode-map ""
1713 ["Toggle threading" gnus-summary-toggle-threads t]
1714 ["Hide threads" gnus-summary-hide-all-threads t]
1715 ["Show threads" gnus-summary-show-all-threads t]
1716 ["Hide thread" gnus-summary-hide-thread t]
1717 ["Show thread" gnus-summary-show-thread t]
1718 ["Go to next thread" gnus-summary-next-thread t]
1719 ["Go to previous thread" gnus-summary-prev-thread t]
1720 ["Go down thread" gnus-summary-down-thread t]
1721 ["Go up thread" gnus-summary-up-thread t]
1722 ["Top of thread" gnus-summary-top-thread t]
1723 ["Mark thread as read" gnus-summary-kill-thread t]
1724 ["Lower thread score" gnus-summary-lower-thread t]
1725 ["Raise thread score" gnus-summary-raise-thread t]
1726 ["Rethread current" gnus-summary-rethread-current t]
1730 gnus-summary-post-menu gnus-summary-mode-map ""
1732 ["Post an article" gnus-summary-post-news t]
1733 ["Followup" gnus-summary-followup t]
1734 ["Followup and yank" gnus-summary-followup-with-original t]
1735 ["Supersede article" gnus-summary-supersede-article t]
1736 ["Cancel article" gnus-summary-cancel-article t]
1737 ["Reply" gnus-summary-reply t]
1738 ["Reply and yank" gnus-summary-reply-with-original t]
1739 ["Wide reply" gnus-summary-wide-reply t]
1740 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1741 ["Mail forward" gnus-summary-mail-forward t]
1742 ["Post forward" gnus-summary-post-forward t]
1743 ["Digest and mail" gnus-summary-mail-digest t]
1744 ["Digest and post" gnus-summary-post-digest t]
1745 ["Resend message" gnus-summary-resend-message t]
1746 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1747 ["Send a mail" gnus-summary-mail-other-window t]
1748 ["Uuencode and post" gnus-uu-post-news t]
1749 ["Followup via news" gnus-summary-followup-to-mail t]
1750 ["Followup via news and yank"
1751 gnus-summary-followup-to-mail-with-original t]
1753 ;;["Send" gnus-summary-send-draft t]
1754 ;;["Send bounced" gnus-resend-bounced-mail t])
1758 gnus-summary-misc-menu gnus-summary-mode-map ""
1761 ["Mark as read" gnus-summary-mark-as-read-forward t]
1762 ["Mark same subject and select"
1763 gnus-summary-kill-same-subject-and-select t]
1764 ["Mark same subject" gnus-summary-kill-same-subject t]
1765 ["Catchup" gnus-summary-catchup t]
1766 ["Catchup all" gnus-summary-catchup-all t]
1767 ["Catchup to here" gnus-summary-catchup-to-here t]
1768 ["Catchup region" gnus-summary-mark-region-as-read t]
1769 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1771 ["Tick" gnus-summary-tick-article-forward t]
1772 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1773 ["Remove marks" gnus-summary-clear-mark-forward t]
1774 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1775 ["Set bookmark" gnus-summary-set-bookmark t]
1776 ["Remove bookmark" gnus-summary-remove-bookmark t])
1778 ["Marks..." gnus-summary-limit-to-marks t]
1779 ["Subject..." gnus-summary-limit-to-subject t]
1780 ["Author..." gnus-summary-limit-to-author t]
1781 ["Age..." gnus-summary-limit-to-age t]
1782 ["Extra..." gnus-summary-limit-to-extra t]
1783 ["Score" gnus-summary-limit-to-score t]
1784 ["Unread" gnus-summary-limit-to-unread t]
1785 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1786 ["Articles" gnus-summary-limit-to-articles t]
1787 ["Pop limit" gnus-summary-pop-limit t]
1788 ["Show dormant" gnus-summary-limit-include-dormant t]
1789 ["Hide childless dormant"
1790 gnus-summary-limit-exclude-childless-dormant t]
1791 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1792 ["Hide marked" gnus-summary-limit-exclude-marks t]
1793 ["Show expunged" gnus-summary-show-all-expunged t])
1795 ["Set mark" gnus-summary-mark-as-processable t]
1796 ["Remove mark" gnus-summary-unmark-as-processable t]
1797 ["Remove all marks" gnus-summary-unmark-all-processable t]
1798 ["Mark above" gnus-uu-mark-over t]
1799 ["Mark series" gnus-uu-mark-series t]
1800 ["Mark region" gnus-uu-mark-region t]
1801 ["Unmark region" gnus-uu-unmark-region t]
1802 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1803 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1804 ["Mark all" gnus-uu-mark-all t]
1805 ["Mark buffer" gnus-uu-mark-buffer t]
1806 ["Mark sparse" gnus-uu-mark-sparse t]
1807 ["Mark thread" gnus-uu-mark-thread t]
1808 ["Unmark thread" gnus-uu-unmark-thread t]
1809 ("Process Mark Sets"
1810 ["Kill" gnus-summary-kill-process-mark t]
1811 ["Yank" gnus-summary-yank-process-mark
1812 gnus-newsgroup-process-stack]
1813 ["Save" gnus-summary-save-process-mark t]))
1815 ["Page forward" gnus-summary-next-page t]
1816 ["Page backward" gnus-summary-prev-page t]
1817 ["Line forward" gnus-summary-scroll-up t])
1819 ["Next unread article" gnus-summary-next-unread-article t]
1820 ["Previous unread article" gnus-summary-prev-unread-article t]
1821 ["Next article" gnus-summary-next-article t]
1822 ["Previous article" gnus-summary-prev-article t]
1823 ["Next unread subject" gnus-summary-next-unread-subject t]
1824 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1825 ["Next article same subject" gnus-summary-next-same-subject t]
1826 ["Previous article same subject" gnus-summary-prev-same-subject t]
1827 ["First unread article" gnus-summary-first-unread-article t]
1828 ["Best unread article" gnus-summary-best-unread-article t]
1829 ["Go to subject number..." gnus-summary-goto-subject t]
1830 ["Go to article number..." gnus-summary-goto-article t]
1831 ["Go to the last article" gnus-summary-goto-last-article t]
1832 ["Pop article off history" gnus-summary-pop-article t])
1834 ["Sort by number" gnus-summary-sort-by-number t]
1835 ["Sort by author" gnus-summary-sort-by-author t]
1836 ["Sort by subject" gnus-summary-sort-by-subject t]
1837 ["Sort by date" gnus-summary-sort-by-date t]
1838 ["Sort by score" gnus-summary-sort-by-score t]
1839 ["Sort by lines" gnus-summary-sort-by-lines t]
1840 ["Sort by characters" gnus-summary-sort-by-chars t])
1842 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1843 ["Describe group" gnus-summary-describe-group t]
1844 ["Read manual" gnus-info-find-node t])
1846 ["Pick and read" gnus-pick-mode t]
1847 ["Binary" gnus-binary-mode t])
1849 ["Regenerate" gnus-summary-prepare t]
1850 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1851 ["Toggle threading" gnus-summary-toggle-threads t])
1852 ["Filter articles..." gnus-summary-execute-command t]
1853 ["Run command on subjects..." gnus-summary-universal-argument t]
1854 ["Search articles forward..." gnus-summary-search-article-forward t]
1855 ["Search articles backward..." gnus-summary-search-article-backward t]
1856 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1857 ["Expand window" gnus-summary-expand-window t]
1858 ["Expire expirable articles" gnus-summary-expire-articles
1859 (gnus-check-backend-function
1860 'request-expire-articles gnus-newsgroup-name)]
1861 ["Edit local kill file" gnus-summary-edit-local-kill t]
1862 ["Edit main kill file" gnus-summary-edit-global-kill t]
1863 ["Edit group parameters" gnus-summary-edit-parameters t]
1864 ["Customize group parameters" gnus-summary-customize-parameters t]
1865 ["Send a bug report" gnus-bug t]
1867 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1868 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1869 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1870 ["Exit group" gnus-summary-exit t]
1871 ["Exit group without updating" gnus-summary-exit-no-update t]
1872 ["Exit and goto next group" gnus-summary-next-group t]
1873 ["Exit and goto prev group" gnus-summary-prev-group t]
1874 ["Reselect group" gnus-summary-reselect-current-group t]
1875 ["Rescan group" gnus-summary-rescan-group t]
1876 ["Update dribble" gnus-summary-save-newsrc t])))
1878 (gnus-run-hooks 'gnus-summary-menu-hook)))
1880 (defun gnus-score-set-default (var value)
1881 "A version of set that updates the GNU Emacs menu-bar."
1883 ;; It is the message that forces the active status to be updated.
1886 (defun gnus-make-score-map (type)
1887 "Make a summary score map of type TYPE."
1890 (let ((headers '(("author" "from" string)
1891 ("subject" "subject" string)
1892 ("article body" "body" string)
1893 ("article head" "head" string)
1894 ("xref" "xref" string)
1895 ("extra header" "extra" string)
1896 ("lines" "lines" number)
1897 ("followups to author" "followup" string)))
1898 (types '((number ("less than" <)
1901 (string ("substring" s)
1905 (perms '(("temporary" (current-time-string))
1913 (if (eq type 'lower)
1918 (setq header (car headers))
1924 (let ((ts (cdr (assoc (nth 2 header) types)))
1940 'gnus-summary-score-entry
1942 (if (or (string= (nth 1 header)
1944 (string= (nth 1 header)
1947 (list 'gnus-summary-header
1949 (list 'quote (nth 1 (car ts)))
1950 (list 'gnus-score-default nil)
1956 (list (nreverse outp))))
1959 (list (nreverse outt))))
1961 (setq headers (cdr headers)))
1962 (list (nreverse outh))))))))
1966 (defun gnus-summary-mode (&optional group)
1967 "Major mode for reading articles.
1969 All normal editing commands are switched off.
1970 \\<gnus-summary-mode-map>
1971 Each line in this buffer represents one article. To read an
1972 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1973 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1976 You can also post articles and send mail from this buffer. To
1977 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1978 of an article, type `\\[gnus-summary-reply]'.
1980 There are approx. one gazillion commands you can execute in this
1981 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1983 The following commands are available:
1985 \\{gnus-summary-mode-map}"
1987 (when (gnus-visual-p 'summary-menu 'menu)
1988 (gnus-summary-make-menu-bar))
1989 (kill-all-local-variables)
1990 (gnus-summary-make-local-variables)
1991 (gnus-make-thread-indent-array)
1992 (gnus-simplify-mode-line)
1993 (setq major-mode 'gnus-summary-mode)
1994 (setq mode-name "Summary")
1995 (make-local-variable 'minor-mode-alist)
1996 (use-local-map gnus-summary-mode-map)
1997 (buffer-disable-undo)
1998 (setq buffer-read-only t) ;Disable modification
1999 (setq truncate-lines t)
2000 (setq selective-display t)
2001 (setq selective-display-ellipses t) ;Display `...'
2002 (gnus-summary-set-display-table)
2003 (gnus-set-default-directory)
2004 (setq gnus-newsgroup-name group)
2005 (make-local-variable 'gnus-summary-line-format)
2006 (make-local-variable 'gnus-summary-line-format-spec)
2007 (make-local-variable 'gnus-summary-dummy-line-format)
2008 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2009 (make-local-variable 'gnus-summary-mark-positions)
2010 (make-local-hook 'pre-command-hook)
2011 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2012 (gnus-run-hooks 'gnus-summary-mode-hook)
2013 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2014 (gnus-update-summary-mark-positions))
2016 (defun gnus-summary-make-local-variables ()
2017 "Make all the local summary buffer variables."
2019 (dolist (local gnus-summary-local-variables)
2022 (if (eq (cdr local) 'global)
2023 ;; Copy the global value of the variable.
2024 (setq global (symbol-value (car local)))
2025 ;; Use the value from the list.
2026 (setq global (eval (cdr local))))
2027 (set (make-local-variable (car local)) global))
2028 ;; Simple nil-valued local variable.
2029 (set (make-local-variable local) nil)))))
2031 (defun gnus-summary-clear-local-variables ()
2032 (let ((locals gnus-summary-local-variables))
2034 (if (consp (car locals))
2035 (and (vectorp (caar locals))
2036 (set (caar locals) nil))
2037 (and (vectorp (car locals))
2038 (set (car locals) nil)))
2039 (setq locals (cdr locals)))))
2041 ;; Summary data functions.
2043 (defmacro gnus-data-number (data)
2046 (defmacro gnus-data-set-number (data number)
2047 `(setcar ,data ,number))
2049 (defmacro gnus-data-mark (data)
2052 (defmacro gnus-data-set-mark (data mark)
2053 `(setcar (nthcdr 1 ,data) ,mark))
2055 (defmacro gnus-data-pos (data)
2058 (defmacro gnus-data-set-pos (data pos)
2059 `(setcar (nthcdr 2 ,data) ,pos))
2061 (defmacro gnus-data-header (data)
2064 (defmacro gnus-data-set-header (data header)
2065 `(setf (nth 3 ,data) ,header))
2067 (defmacro gnus-data-level (data)
2070 (defmacro gnus-data-unread-p (data)
2071 `(= (nth 1 ,data) gnus-unread-mark))
2073 (defmacro gnus-data-read-p (data)
2074 `(/= (nth 1 ,data) gnus-unread-mark))
2076 (defmacro gnus-data-pseudo-p (data)
2077 `(consp (nth 3 ,data)))
2079 (defmacro gnus-data-find (number)
2080 `(assq ,number gnus-newsgroup-data))
2082 (defmacro gnus-data-find-list (number &optional data)
2083 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2084 (memq (assq ,number bdata)
2087 (defmacro gnus-data-make (number mark pos header level)
2088 `(list ,number ,mark ,pos ,header ,level))
2090 (defun gnus-data-enter (after-article number mark pos header level offset)
2091 (let ((data (gnus-data-find-list after-article)))
2093 (error "No such article: %d" after-article))
2094 (setcdr data (cons (gnus-data-make number mark pos header level)
2096 (setq gnus-newsgroup-data-reverse nil)
2097 (gnus-data-update-list (cddr data) offset)))
2099 (defun gnus-data-enter-list (after-article list &optional offset)
2101 (let ((data (and after-article (gnus-data-find-list after-article)))
2105 (let ((odata gnus-newsgroup-data))
2106 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2108 (gnus-data-update-list odata offset)))
2109 ;; Find the last element in the list to be spliced into the main
2112 (setq list (cdr list)))
2115 (setcdr list gnus-newsgroup-data)
2116 (setq gnus-newsgroup-data ilist)
2118 (gnus-data-update-list (cdr list) offset)))
2119 (setcdr list (cdr data))
2122 (gnus-data-update-list (cdr list) offset))))
2123 (setq gnus-newsgroup-data-reverse nil))))
2125 (defun gnus-data-remove (article &optional offset)
2126 (let ((data gnus-newsgroup-data))
2127 (if (= (gnus-data-number (car data)) article)
2129 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2130 gnus-newsgroup-data-reverse nil)
2132 (gnus-data-update-list gnus-newsgroup-data offset)))
2134 (when (= (gnus-data-number (cadr data)) article)
2135 (setcdr data (cddr data))
2137 (gnus-data-update-list (cdr data) offset))
2139 gnus-newsgroup-data-reverse nil))
2140 (setq data (cdr data))))))
2142 (defmacro gnus-data-list (backward)
2144 (or gnus-newsgroup-data-reverse
2145 (setq gnus-newsgroup-data-reverse
2146 (reverse gnus-newsgroup-data)))
2147 gnus-newsgroup-data))
2149 (defun gnus-data-update-list (data offset)
2150 "Add OFFSET to the POS of all data entries in DATA."
2151 (setq gnus-newsgroup-data-reverse nil)
2153 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2154 (setq data (cdr data))))
2156 (defun gnus-summary-article-pseudo-p (article)
2157 "Say whether this article is a pseudo article or not."
2158 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2160 (defmacro gnus-summary-article-sparse-p (article)
2161 "Say whether this article is a sparse article or not."
2162 `(memq ,article gnus-newsgroup-sparse))
2164 (defmacro gnus-summary-article-ancient-p (article)
2165 "Say whether this article is a sparse article or not."
2166 `(memq ,article gnus-newsgroup-ancient))
2168 (defun gnus-article-parent-p (number)
2169 "Say whether this article is a parent or not."
2170 (let ((data (gnus-data-find-list number)))
2171 (and (cdr data) ; There has to be an article after...
2172 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2173 (gnus-data-level (nth 1 data))))))
2175 (defun gnus-article-children (number)
2176 "Return a list of all children to NUMBER."
2177 (let* ((data (gnus-data-find-list number))
2178 (level (gnus-data-level (car data)))
2180 (setq data (cdr data))
2182 (= (gnus-data-level (car data)) (1+ level)))
2183 (push (gnus-data-number (car data)) children)
2184 (setq data (cdr data)))
2187 (defmacro gnus-summary-skip-intangible ()
2188 "If the current article is intangible, then jump to a different article."
2189 '(let ((to (get-text-property (point) 'gnus-intangible)))
2190 (and to (gnus-summary-goto-subject to))))
2192 (defmacro gnus-summary-article-intangible-p ()
2193 "Say whether this article is intangible or not."
2194 '(get-text-property (point) 'gnus-intangible))
2196 (defun gnus-article-read-p (article)
2197 "Say whether ARTICLE is read or not."
2198 (not (or (memq article gnus-newsgroup-marked)
2199 (memq article gnus-newsgroup-unreads)
2200 (memq article gnus-newsgroup-unselected)
2201 (memq article gnus-newsgroup-dormant))))
2203 ;; Some summary mode macros.
2205 (defmacro gnus-summary-article-number ()
2206 "The article number of the article on the current line.
2207 If there isn's an article number here, then we return the current
2210 (gnus-summary-skip-intangible)
2211 (or (get-text-property (point) 'gnus-number)
2212 (gnus-summary-last-subject))))
2214 (defmacro gnus-summary-article-header (&optional number)
2215 "Return the header of article NUMBER."
2216 `(gnus-data-header (gnus-data-find
2217 ,(or number '(gnus-summary-article-number)))))
2219 (defmacro gnus-summary-thread-level (&optional number)
2220 "Return the level of thread that starts with article NUMBER."
2221 `(if (and (eq gnus-summary-make-false-root 'dummy)
2222 (get-text-property (point) 'gnus-intangible))
2224 (gnus-data-level (gnus-data-find
2225 ,(or number '(gnus-summary-article-number))))))
2227 (defmacro gnus-summary-article-mark (&optional number)
2228 "Return the mark of article NUMBER."
2229 `(gnus-data-mark (gnus-data-find
2230 ,(or number '(gnus-summary-article-number)))))
2232 (defmacro gnus-summary-article-pos (&optional number)
2233 "Return the position of the line of article NUMBER."
2234 `(gnus-data-pos (gnus-data-find
2235 ,(or number '(gnus-summary-article-number)))))
2237 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2238 (defmacro gnus-summary-article-subject (&optional number)
2239 "Return current subject string or nil if nothing."
2242 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2243 '(gnus-data-header (assq (gnus-summary-article-number)
2244 gnus-newsgroup-data)))))
2247 (mail-header-subject headers))))
2249 (defmacro gnus-summary-article-score (&optional number)
2250 "Return current article score."
2251 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2252 gnus-newsgroup-scored))
2253 gnus-summary-default-score 0))
2255 (defun gnus-summary-article-children (&optional number)
2256 "Return a list of article numbers that are children of article NUMBER."
2257 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2258 (level (gnus-data-level (car data)))
2260 (while (and (setq data (cdr data))
2261 (> (setq l (gnus-data-level (car data))) level))
2262 (and (= (1+ level) l)
2263 (push (gnus-data-number (car data))
2265 (nreverse children)))
2267 (defun gnus-summary-article-parent (&optional number)
2268 "Return the article number of the parent of article NUMBER."
2269 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2270 (gnus-data-list t)))
2271 (level (gnus-data-level (car data))))
2273 () ; This is a root.
2274 ;; We search until we find an article with a level less than
2275 ;; this one. That function has to be the parent.
2276 (while (and (setq data (cdr data))
2277 (not (< (gnus-data-level (car data)) level))))
2278 (and data (gnus-data-number (car data))))))
2280 (defun gnus-unread-mark-p (mark)
2281 "Say whether MARK is the unread mark."
2282 (= mark gnus-unread-mark))
2284 (defun gnus-read-mark-p (mark)
2285 "Say whether MARK is one of the marks that mark as read.
2286 This is all marks except unread, ticked, dormant, and expirable."
2287 (not (or (= mark gnus-unread-mark)
2288 (= mark gnus-ticked-mark)
2289 (= mark gnus-dormant-mark)
2290 (= mark gnus-expirable-mark))))
2292 (defmacro gnus-article-mark (number)
2293 "Return the MARK of article NUMBER.
2294 This macro should only be used when computing the mark the \"first\"
2295 time; i.e., when generating the summary lines. After that,
2296 `gnus-summary-article-mark' should be used to examine the
2299 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2300 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2301 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2302 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2303 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2304 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2305 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2306 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2307 gnus-ancient-mark))))
2309 ;; Saving hidden threads.
2311 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2312 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2314 (defmacro gnus-save-hidden-threads (&rest forms)
2315 "Save hidden threads, eval FORMS, and restore the hidden threads."
2316 (let ((config (make-symbol "config")))
2317 `(let ((,config (gnus-hidden-threads-configuration)))
2321 (gnus-restore-hidden-threads-configuration ,config)))))
2323 (defun gnus-data-compute-positions ()
2324 "Compute the positions of all articles."
2325 (setq gnus-newsgroup-data-reverse nil)
2326 (let ((data gnus-newsgroup-data))
2328 (gnus-save-hidden-threads
2329 (gnus-summary-show-all-threads)
2330 (goto-char (point-min))
2332 (while (get-text-property (point) 'gnus-intangible)
2334 (gnus-data-set-pos (car data) (+ (point) 3))
2335 (setq data (cdr data))
2336 (forward-line 1))))))
2338 (defun gnus-hidden-threads-configuration ()
2339 "Return the current hidden threads configuration."
2342 (goto-char (point-min))
2343 (while (search-forward "\r" nil t)
2344 (push (1- (point)) config))
2347 (defun gnus-restore-hidden-threads-configuration (config)
2348 "Restore hidden threads configuration from CONFIG."
2349 (let (point buffer-read-only)
2350 (while (setq point (pop config))
2351 (when (and (< point (point-max))
2353 (eq (char-after) ?\n))
2354 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2356 ;; Various summary mode internalish functions.
2358 (defun gnus-mouse-pick-article (e)
2361 (gnus-summary-next-page nil t))
2363 (defun gnus-summary-set-display-table ()
2364 ;; Change the display table. Odd characters have a tendency to mess
2365 ;; up nicely formatted displays - we make all possible glyphs
2366 ;; display only a single character.
2368 ;; We start from the standard display table, if any.
2369 (let ((table (or (copy-sequence standard-display-table)
2370 (make-display-table)))
2372 ;; Nix out all the control chars...
2373 (while (>= (setq i (1- i)) 0)
2374 (aset table i [??]))
2375 ;; ... but not newline and cr, of course. (cr is necessary for the
2376 ;; selective display).
2377 (aset table ?\n nil)
2378 (aset table ?\r nil)
2379 ;; We keep TAB as well.
2380 (aset table ?\t nil)
2381 ;; We nix out any glyphs over 126 that are not set already.
2383 (while (>= (setq i (1- i)) 127)
2384 ;; Only modify if the entry is nil.
2385 (unless (aref table i)
2386 (aset table i [??]))))
2387 (setq buffer-display-table table)))
2389 (defun gnus-summary-setup-buffer (group)
2390 "Initialize summary buffer."
2391 (let ((buffer (concat "*Summary " group "*")))
2392 (if (get-buffer buffer)
2395 (setq gnus-summary-buffer (current-buffer))
2396 (not gnus-newsgroup-prepared))
2397 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2398 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2399 (gnus-summary-mode group)
2401 (gnus-carpal-setup-buffer 'summary))
2402 (unless gnus-single-article-buffer
2403 (make-local-variable 'gnus-article-buffer)
2404 (make-local-variable 'gnus-article-current)
2405 (make-local-variable 'gnus-original-article-buffer))
2406 (setq gnus-newsgroup-name group)
2409 (defun gnus-set-global-variables ()
2410 ;; Set the global equivalents of the summary buffer-local variables
2411 ;; to the latest values they had. These reflect the summary buffer
2412 ;; that was in action when the last article was fetched.
2413 (when (eq major-mode 'gnus-summary-mode)
2414 (setq gnus-summary-buffer (current-buffer))
2415 (let ((name gnus-newsgroup-name)
2416 (marked gnus-newsgroup-marked)
2417 (unread gnus-newsgroup-unreads)
2418 (headers gnus-current-headers)
2419 (data gnus-newsgroup-data)
2420 (summary gnus-summary-buffer)
2421 (article-buffer gnus-article-buffer)
2422 (original gnus-original-article-buffer)
2423 (gac gnus-article-current)
2424 (reffed gnus-reffed-article-number)
2425 (score-file gnus-current-score-file)
2426 (default-charset gnus-newsgroup-charset))
2428 (set-buffer gnus-group-buffer)
2429 (setq gnus-newsgroup-name name
2430 gnus-newsgroup-marked marked
2431 gnus-newsgroup-unreads unread
2432 gnus-current-headers headers
2433 gnus-newsgroup-data data
2434 gnus-article-current gac
2435 gnus-summary-buffer summary
2436 gnus-article-buffer article-buffer
2437 gnus-original-article-buffer original
2438 gnus-reffed-article-number reffed
2439 gnus-current-score-file score-file
2440 gnus-newsgroup-charset default-charset)
2441 ;; The article buffer also has local variables.
2442 (when (gnus-buffer-live-p gnus-article-buffer)
2443 (set-buffer gnus-article-buffer)
2444 (setq gnus-summary-buffer summary))))))
2446 (defun gnus-summary-article-unread-p (article)
2447 "Say whether ARTICLE is unread or not."
2448 (memq article gnus-newsgroup-unreads))
2450 (defun gnus-summary-first-article-p (&optional article)
2451 "Return whether ARTICLE is the first article in the buffer."
2452 (if (not (setq article (or article (gnus-summary-article-number))))
2454 (eq article (caar gnus-newsgroup-data))))
2456 (defun gnus-summary-last-article-p (&optional article)
2457 "Return whether ARTICLE is the last article in the buffer."
2458 (if (not (setq article (or article (gnus-summary-article-number))))
2459 ;; All non-existent numbers are the last article. :-)
2461 (not (cdr (gnus-data-find-list article)))))
2463 (defun gnus-make-thread-indent-array ()
2465 (unless (and gnus-thread-indent-array
2466 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2467 (setq gnus-thread-indent-array (make-vector 201 "")
2468 gnus-thread-indent-array-level gnus-thread-indent-level)
2470 (aset gnus-thread-indent-array n
2471 (make-string (* n gnus-thread-indent-level) ? ))
2474 (defun gnus-update-summary-mark-positions ()
2475 "Compute where the summary marks are to go."
2477 (when (gnus-buffer-exists-p gnus-summary-buffer)
2478 (set-buffer gnus-summary-buffer))
2479 (let ((gnus-replied-mark 129)
2480 (gnus-score-below-mark 130)
2481 (gnus-score-over-mark 130)
2482 (gnus-download-mark 131)
2483 (spec gnus-summary-line-format-spec)
2486 (gnus-set-work-buffer)
2487 (let ((gnus-summary-line-format-spec spec)
2488 (gnus-newsgroup-downloadable '((0 . t))))
2489 (gnus-summary-insert-line
2490 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2491 0 nil 128 t nil "" nil 1)
2492 (goto-char (point-min))
2493 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2495 (goto-char (point-min))
2496 (push (cons 'replied (and (search-forward "\201" nil t)
2499 (goto-char (point-min))
2500 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2502 (goto-char (point-min))
2503 (push (cons 'download
2504 (and (search-forward "\203" nil t) (- (point) 2)))
2506 (setq gnus-summary-mark-positions pos))))
2508 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2509 "Insert a dummy root in the summary buffer."
2511 (gnus-add-text-properties
2512 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2513 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2515 (defun gnus-summary-from-or-to-or-newsgroups (header)
2516 (let ((to (cdr (assq 'To (mail-header-extra header))))
2517 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2518 (default-mime-charset (with-current-buffer gnus-summary-buffer
2519 default-mime-charset)))
2522 gnus-ignored-from-addresses
2523 (string-match gnus-ignored-from-addresses
2524 (mail-header-from header)))
2526 (or (car (funcall gnus-extract-address-components
2528 gnus-decode-encoded-word-function to)))
2529 (funcall gnus-decode-encoded-word-function to))))
2531 gnus-ignored-from-addresses
2532 (string-match gnus-ignored-from-addresses
2533 (mail-header-from header)))
2534 (concat "=> " newsgroups))
2536 (or (car (funcall gnus-extract-address-components
2537 (mail-header-from header)))
2538 (mail-header-from header))))))
2540 (defun gnus-summary-insert-line (gnus-tmp-header
2541 gnus-tmp-level gnus-tmp-current
2542 gnus-tmp-unread gnus-tmp-replied
2543 gnus-tmp-expirable gnus-tmp-subject-or-nil
2544 &optional gnus-tmp-dummy gnus-tmp-score
2546 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2547 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2548 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2549 (gnus-tmp-score-char
2550 (if (or (null gnus-summary-default-score)
2551 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2552 gnus-summary-zcore-fuzz))
2554 (if (< gnus-tmp-score gnus-summary-default-score)
2555 gnus-score-below-mark gnus-score-over-mark)))
2557 (cond (gnus-tmp-process gnus-process-mark)
2558 ((memq gnus-tmp-current gnus-newsgroup-cached)
2560 (gnus-tmp-replied gnus-replied-mark)
2561 ((memq gnus-tmp-current gnus-newsgroup-saved)
2563 (t gnus-unread-mark)))
2564 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2567 ((string-match "<[^>]+> *$" gnus-tmp-from)
2568 (let ((beg (match-beginning 0)))
2569 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2570 (substring gnus-tmp-from (1+ (match-beginning 0))
2571 (1- (match-end 0))))
2572 (substring gnus-tmp-from 0 beg))))
2573 ((string-match "(.+)" gnus-tmp-from)
2574 (substring gnus-tmp-from
2575 (1+ (match-beginning 0)) (1- (match-end 0))))
2577 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2578 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2579 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2580 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2581 (buffer-read-only nil))
2582 (when (string= gnus-tmp-name "")
2583 (setq gnus-tmp-name gnus-tmp-from))
2584 (unless (numberp gnus-tmp-lines)
2585 (setq gnus-tmp-lines 0))
2586 (gnus-put-text-property-excluding-characters-with-faces
2588 (progn (eval gnus-summary-line-format-spec) (point))
2589 'gnus-number gnus-tmp-number)
2590 (when (gnus-visual-p 'summary-highlight 'highlight)
2592 (gnus-run-hooks 'gnus-summary-update-hook)
2595 (defun gnus-summary-update-line (&optional dont-update)
2596 ;; Update summary line after change.
2597 (when (and gnus-summary-default-score
2598 (not gnus-summary-inhibit-highlight))
2599 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2600 (article (gnus-summary-article-number))
2601 (score (gnus-summary-article-score article)))
2603 (if (and gnus-summary-mark-below
2604 (< (gnus-summary-article-score)
2605 gnus-summary-mark-below))
2606 ;; This article has a low score, so we mark it as read.
2607 (when (memq article gnus-newsgroup-unreads)
2608 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2609 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2610 ;; This article was previously marked as read on account
2611 ;; of a low score, but now it has risen, so we mark it as
2613 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2614 (gnus-summary-update-mark
2615 (if (or (null gnus-summary-default-score)
2616 (<= (abs (- score gnus-summary-default-score))
2617 gnus-summary-zcore-fuzz))
2619 (if (< score gnus-summary-default-score)
2620 gnus-score-below-mark gnus-score-over-mark))
2622 ;; Do visual highlighting.
2623 (when (gnus-visual-p 'summary-highlight 'highlight)
2624 (gnus-run-hooks 'gnus-summary-update-hook)))))
2626 (defvar gnus-tmp-new-adopts nil)
2628 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2629 "Return the number of articles in THREAD.
2630 This may be 0 in some cases -- if none of the articles in
2631 the thread are to be displayed."
2633 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2635 ((not (listp thread))
2637 ((and (consp thread) (cdr thread))
2640 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2643 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2646 (when (and level (zerop level) gnus-tmp-new-adopts)
2649 'gnus-summary-number-of-articles-in-thread
2650 gnus-tmp-new-adopts))))
2652 (if (> number 1) gnus-not-empty-thread-mark
2653 gnus-empty-thread-mark)
2656 (defun gnus-summary-set-local-parameters (group)
2657 "Go through the local params of GROUP and set all variable specs in that list."
2658 (let ((params (gnus-group-find-parameter group))
2661 (setq elem (car params)
2662 params (cdr params))
2663 (and (consp elem) ; Has to be a cons.
2664 (consp (cdr elem)) ; The cdr has to be a list.
2665 (symbolp (car elem)) ; Has to be a symbol in there.
2666 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2667 (ignore-errors ; So we set it.
2668 (make-local-variable (car elem))
2669 (set (car elem) (eval (nth 1 elem))))))))
2671 (defun gnus-summary-read-group (group &optional show-all no-article
2672 kill-buffer no-display backward
2674 "Start reading news in newsgroup GROUP.
2675 If SHOW-ALL is non-nil, already read articles are also listed.
2676 If NO-ARTICLE is non-nil, no article is selected initially.
2677 If NO-DISPLAY, don't generate a summary buffer."
2681 (let ((gnus-auto-select-next nil))
2682 (or (gnus-summary-read-group-1
2683 group show-all no-article
2684 kill-buffer no-display
2687 select-articles nil)))))
2688 (eq gnus-auto-select-next 'quietly))
2689 (set-buffer gnus-group-buffer)
2690 ;; The entry function called above goes to the next
2691 ;; group automatically, so we go two groups back
2692 ;; if we are searching for the previous group.
2694 (gnus-group-prev-unread-group 2))
2695 (if (not (equal group (gnus-group-group-name)))
2696 (setq group (gnus-group-group-name))
2700 (defun gnus-summary-jump-to-other-group (group &optional show-all)
2701 "Directly jump to the other GROUP from summary buffer.
2702 If SHOW-ALL is non-nil, already read articles are also listed."
2704 (if (eq gnus-summary-buffer (current-buffer))
2705 (list (completing-read
2706 "Group: " gnus-active-hashtb nil t
2707 (when (and gnus-newsgroup-name
2708 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
2709 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
2710 'gnus-group-history)
2712 (error "%s must be invoked from a gnus summary buffer." this-command)))
2713 (unless (or (zerop (length group))
2714 (and gnus-newsgroup-name
2715 (string-equal gnus-newsgroup-name group)))
2717 (gnus-summary-read-group group show-all
2718 gnus-dont-select-after-jump-to-other-group)))
2720 (defun gnus-summary-read-group-1 (group show-all no-article
2721 kill-buffer no-display
2722 &optional select-articles)
2723 ;; Killed foreign groups can't be entered.
2724 (when (and (not (gnus-group-native-p group))
2725 (not (gnus-gethash group gnus-newsrc-hashtb)))
2726 (error "Dead non-native groups can't be entered"))
2727 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2728 (let* ((new-group (gnus-summary-setup-buffer group))
2729 (quit-config (gnus-group-quit-config group))
2730 (did-select (and new-group (gnus-select-newsgroup
2731 group show-all select-articles))))
2733 ;; This summary buffer exists already, so we just select it.
2735 (gnus-set-global-variables)
2737 (gnus-kill-or-deaden-summary kill-buffer))
2738 (gnus-configure-windows 'summary 'force)
2739 (gnus-set-mode-line 'summary)
2740 (gnus-summary-position-point)
2743 ;; We couldn't select this group.
2745 (when (and (eq major-mode 'gnus-summary-mode)
2746 (not (equal (current-buffer) kill-buffer)))
2747 (kill-buffer (current-buffer))
2748 (if (not quit-config)
2750 ;; Update the info -- marks might need to be removed,
2752 (gnus-summary-update-info)
2753 (set-buffer gnus-group-buffer)
2754 (gnus-group-jump-to-group group)
2755 (gnus-group-next-unread-group 1))
2756 (gnus-handle-ephemeral-exit quit-config)))
2757 (gnus-message 3 "Can't select group")
2759 ;; The user did a `C-g' while prompting for number of articles,
2760 ;; so we exit this group.
2761 ((eq did-select 'quit)
2762 (and (eq major-mode 'gnus-summary-mode)
2763 (not (equal (current-buffer) kill-buffer))
2764 (kill-buffer (current-buffer)))
2766 (gnus-kill-or-deaden-summary kill-buffer))
2767 (if (not quit-config)
2769 (set-buffer gnus-group-buffer)
2770 (gnus-group-jump-to-group group)
2771 (gnus-group-next-unread-group 1)
2772 (gnus-configure-windows 'group 'force))
2773 (gnus-handle-ephemeral-exit quit-config))
2774 ;; Finally signal the quit.
2776 ;; The group was successfully selected.
2778 (gnus-set-global-variables)
2779 ;; Save the active value in effect when the group was entered.
2780 (setq gnus-newsgroup-active
2782 (gnus-active gnus-newsgroup-name)))
2783 ;; You can change the summary buffer in some way with this hook.
2784 (gnus-run-hooks 'gnus-select-group-hook)
2785 ;; Set any local variables in the group parameters.
2786 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2787 (gnus-update-format-specifications
2788 nil 'summary 'summary-mode 'summary-dummy)
2789 (gnus-update-summary-mark-positions)
2790 ;; Do score processing.
2791 (when gnus-use-scoring
2792 (gnus-possibly-score-headers))
2793 ;; Check whether to fill in the gaps in the threads.
2794 (when gnus-build-sparse-threads
2795 (gnus-build-sparse-threads))
2796 ;; Find the initial limit.
2797 (if gnus-show-threads
2799 (let ((gnus-newsgroup-dormant nil))
2800 (gnus-summary-initial-limit show-all))
2801 (gnus-summary-initial-limit show-all))
2802 (setq gnus-newsgroup-limit
2804 (lambda (header) (mail-header-number header))
2805 gnus-newsgroup-headers)))
2806 ;; Generate the summary buffer.
2808 (gnus-summary-prepare))
2809 (when gnus-use-trees
2810 (gnus-tree-open group)
2811 (setq gnus-summary-highlight-line-function
2812 'gnus-tree-highlight-article))
2813 ;; If the summary buffer is empty, but there are some low-scored
2814 ;; articles or some excluded dormants, we include these in the
2816 (when (and (zerop (buffer-size))
2818 (cond (gnus-newsgroup-dormant
2819 (gnus-summary-limit-include-dormant))
2820 ((and gnus-newsgroup-scored show-all)
2821 (gnus-summary-limit-include-expunged t))))
2822 ;; Function `gnus-apply-kill-file' must be called in this hook.
2823 (gnus-run-hooks 'gnus-apply-kill-hook)
2824 (if (and (zerop (buffer-size))
2827 ;; This newsgroup is empty.
2828 (gnus-summary-catchup-and-exit nil t)
2829 (gnus-message 6 "No unread news")
2831 (gnus-kill-or-deaden-summary kill-buffer))
2832 ;; Return nil from this function.
2834 ;; Hide conversation thread subtrees. We cannot do this in
2835 ;; gnus-summary-prepare-hook since kill processing may not
2836 ;; work with hidden articles.
2837 (and gnus-show-threads
2838 gnus-thread-hide-subtree
2839 (gnus-summary-hide-all-threads))
2841 (gnus-kill-or-deaden-summary kill-buffer))
2842 ;; Show first unread article if requested.
2843 (if (and (not no-article)
2845 gnus-newsgroup-unreads
2846 gnus-auto-select-first)
2848 (gnus-configure-windows 'summary)
2850 ((eq gnus-auto-select-first 'best)
2851 (gnus-summary-best-unread-article))
2852 ((eq gnus-auto-select-first t)
2853 (gnus-summary-first-unread-article))
2854 ((gnus-functionp gnus-auto-select-first)
2855 (funcall gnus-auto-select-first))))
2856 ;; Don't select any articles, just move point to the first
2857 ;; article in the group.
2858 (goto-char (point-min))
2859 (gnus-summary-position-point)
2860 (gnus-configure-windows 'summary 'force)
2861 (gnus-set-mode-line 'summary))
2862 (when (get-buffer-window gnus-group-buffer t)
2863 ;; Gotta use windows, because recenter does weird stuff if
2864 ;; the current buffer ain't the displayed window.
2865 (let ((owin (selected-window)))
2866 (select-window (get-buffer-window gnus-group-buffer t))
2867 (when (gnus-group-goto-group group)
2869 (select-window owin)))
2870 ;; Mark this buffer as "prepared".
2871 (setq gnus-newsgroup-prepared t)
2872 (gnus-run-hooks 'gnus-summary-prepared-hook)
2875 (defun gnus-summary-prepare ()
2876 "Generate the summary buffer."
2878 (let ((buffer-read-only nil))
2880 (setq gnus-newsgroup-data nil
2881 gnus-newsgroup-data-reverse nil)
2882 (gnus-run-hooks 'gnus-summary-generate-hook)
2883 ;; Generate the buffer, either with threads or without.
2884 (when gnus-newsgroup-headers
2885 (gnus-summary-prepare-threads
2886 (if gnus-show-threads
2887 (gnus-sort-gathered-threads
2888 (funcall gnus-summary-thread-gathering-function
2890 (gnus-cut-threads (gnus-make-threads)))))
2891 ;; Unthreaded display.
2892 (gnus-sort-articles gnus-newsgroup-headers))))
2893 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2894 ;; Call hooks for modifying summary buffer.
2895 (goto-char (point-min))
2896 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2898 (defsubst gnus-general-simplify-subject (subject)
2899 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2902 ;; Truncate the subject.
2903 (gnus-simplify-subject-functions
2904 (gnus-map-function gnus-simplify-subject-functions subject))
2905 ((numberp gnus-summary-gather-subject-limit)
2906 (setq subject (gnus-simplify-subject-re subject))
2907 (if (> (length subject) gnus-summary-gather-subject-limit)
2908 (substring subject 0 gnus-summary-gather-subject-limit)
2910 ;; Fuzzily simplify it.
2911 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2912 (gnus-simplify-subject-fuzzy subject))
2913 ;; Just remove the leading "Re:".
2915 (gnus-simplify-subject-re subject))))
2917 (if (and gnus-summary-gather-exclude-subject
2918 (string-match gnus-summary-gather-exclude-subject subject))
2919 nil ; This article shouldn't be gathered
2922 (defun gnus-summary-simplify-subject-query ()
2923 "Query where the respool algorithm would put this article."
2925 (gnus-summary-select-article)
2926 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2928 (defun gnus-gather-threads-by-subject (threads)
2929 "Gather threads by looking at Subject headers."
2930 (if (not gnus-summary-make-false-root)
2932 (let ((hashtb (gnus-make-hashtable 1024))
2935 subject hthread whole-subject)
2937 (setq subject (gnus-general-simplify-subject
2938 (setq whole-subject (mail-header-subject
2941 (if (setq hthread (gnus-gethash subject hashtb))
2943 ;; We enter a dummy root into the thread, if we
2944 ;; haven't done that already.
2945 (unless (stringp (caar hthread))
2946 (setcar hthread (list whole-subject (car hthread))))
2947 ;; We add this new gathered thread to this gathered
2949 (setcdr (car hthread)
2950 (nconc (cdar hthread) (list (car threads))))
2951 ;; Remove it from the list of threads.
2952 (setcdr prev (cdr threads))
2953 (setq threads prev))
2954 ;; Enter this thread into the hash table.
2955 (gnus-sethash subject threads hashtb)))
2957 (setq threads (cdr threads)))
2960 (defun gnus-gather-threads-by-references (threads)
2961 "Gather threads by looking at References headers."
2962 (let ((idhashtb (gnus-make-hashtable 1024))
2963 (thhashtb (gnus-make-hashtable 1024))
2966 ids references id gthread gid entered ref)
2968 (when (setq references (mail-header-references (caar threads)))
2969 (setq id (mail-header-id (caar threads))
2970 ids (gnus-split-references references)
2972 (while (setq ref (pop ids))
2973 (setq ids (delete ref ids))
2974 (if (not (setq gid (gnus-gethash ref idhashtb)))
2976 (gnus-sethash ref id idhashtb)
2977 (gnus-sethash id threads thhashtb))
2978 (setq gthread (gnus-gethash gid thhashtb))
2980 ;; We enter a dummy root into the thread, if we
2981 ;; haven't done that already.
2982 (unless (stringp (caar gthread))
2983 (setcar gthread (list (mail-header-subject (caar gthread))
2985 ;; We add this new gathered thread to this gathered
2987 (setcdr (car gthread)
2988 (nconc (cdar gthread) (list (car threads)))))
2989 ;; Add it into the thread hash table.
2990 (gnus-sethash id gthread thhashtb)
2992 ;; Remove it from the list of threads.
2993 (setcdr prev (cdr threads))
2994 (setq threads prev))))
2996 (setq threads (cdr threads)))
2999 (defun gnus-sort-gathered-threads (threads)
3000 "Sort subtreads inside each gathered thread by article number."
3001 (let ((result threads))
3003 (when (stringp (caar threads))
3004 (setcdr (car threads)
3005 (sort (cdar threads) 'gnus-thread-sort-by-number)))
3006 (setq threads (cdr threads)))
3009 (defun gnus-thread-loop-p (root thread)
3010 "Say whether ROOT is in THREAD."
3011 (let ((stack (list thread))
3014 (while (setq thread (pop stack))
3015 (setq th (cdr thread))
3017 (not (eq (caar th) root)))
3020 ;; We have found a loop.
3022 (setcdr thread (delq (car th) (cdr thread)))
3023 (if (boundp (setq ref-dep (intern "none"
3024 gnus-newsgroup-dependencies)))
3025 (setcdr (symbol-value ref-dep)
3026 (nconc (cdr (symbol-value ref-dep))
3028 (set ref-dep (list nil (car th))))
3031 ;; Push all the subthreads onto the stack.
3032 (push (cdr thread) stack)))
3035 (defun gnus-make-threads ()
3036 "Go through the dependency hashtb and find the roots. Return all threads."
3038 (while (catch 'infloop
3041 ;; Deal with self-referencing References loops.
3042 (when (and (car (symbol-value refs))
3049 (car (symbol-value refs)) thread))
3050 (cdr (symbol-value refs)))))))
3053 (unless (car (symbol-value refs))
3054 ;; These threads do not refer back to any other articles,
3055 ;; so they're roots.
3056 (setq threads (append (cdr (symbol-value refs)) threads))))
3057 gnus-newsgroup-dependencies)))
3060 ;; Build the thread tree.
3061 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3062 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3064 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3065 if it was already present.
3067 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3068 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3069 Message-IDs will be renamed be renamed to a unique Message-ID before
3072 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3073 (let* ((id (mail-header-id header))
3074 (id-dep (and id (intern id dependencies)))
3075 ref ref-dep ref-header)
3076 ;; Enter this `header' in the `dependencies' table.
3080 ;; The first two cases do the normal part: enter a new `header'
3081 ;; in the `dependencies' table.
3082 ((not (boundp id-dep))
3083 (set id-dep (list header)))
3084 ((null (car (symbol-value id-dep)))
3085 (setcar (symbol-value id-dep) header))
3087 ;; From here the `header' was already present in the
3088 ;; `dependencies' table.
3090 ;; Overrides an existing entry;
3091 ;; just set the header part of the entry.
3092 (setcar (symbol-value id-dep) header))
3094 ;; Renames the existing `header' to a unique Message-ID.
3095 ((not gnus-summary-ignore-duplicates)
3096 ;; An article with this Message-ID has already been seen.
3097 ;; We rename the Message-ID.
3098 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3100 (mail-header-set-id header id))
3102 ;; The last case ignores an existing entry, except it adds any
3103 ;; additional Xrefs (in case the two articles came from different
3105 ;; Also sets `header' to `nil' meaning that the `dependencies'
3106 ;; table was *not* modified.
3108 (mail-header-set-xref
3109 (car (symbol-value id-dep))
3110 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3112 (or (mail-header-xref header) "")))
3116 ;; First check if that we are not creating a References loop.
3117 (setq ref (gnus-parent-id (mail-header-references header)))
3119 (setq ref-dep (intern-soft ref dependencies))
3121 (setq ref-header (car (symbol-value ref-dep))))
3122 (if (string= id ref)
3123 ;; Yuk! This is a reference loop. Make the article be a
3126 (mail-header-set-references (car (symbol-value id-dep)) "none")
3128 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3129 (setq ref (gnus-parent-id (mail-header-references header)))
3130 (setq ref-dep (intern (or ref "none") dependencies))
3131 (if (boundp ref-dep)
3132 (setcdr (symbol-value ref-dep)
3133 (nconc (cdr (symbol-value ref-dep))
3134 (list (symbol-value id-dep))))
3135 (set ref-dep (list nil (symbol-value id-dep)))))
3138 (defun gnus-build-sparse-threads ()
3139 (let ((headers gnus-newsgroup-headers)
3140 (gnus-summary-ignore-duplicates t)
3141 header references generation relations
3142 subject child end new-child date)
3143 ;; First we create an alist of generations/relations, where
3144 ;; generations is how much we trust the relation, and the relation
3146 (gnus-message 7 "Making sparse threads...")
3148 (nnheader-set-temp-buffer " *gnus sparse threads*")
3149 (while (setq header (pop headers))
3150 (when (and (setq references (mail-header-references header))
3151 (not (string= references "")))
3153 (setq child (mail-header-id header)
3154 subject (mail-header-subject header)
3155 date (mail-header-date header)
3157 (while (search-backward ">" nil t)
3158 (setq end (1+ (point)))
3159 (when (search-backward "<" nil t)
3160 (setq new-child (buffer-substring (point) end))
3161 (push (list (incf generation)
3162 child (setq child new-child)
3166 (push (list (1+ generation) child nil subject) relations))
3168 (kill-buffer (current-buffer)))
3169 ;; Sort over trustworthiness.
3172 (when (gnus-dependencies-add-header
3173 (make-full-mail-header
3174 gnus-reffed-article-number
3175 (nth 3 relation) "" (or (nth 4 relation) "")
3177 (or (nth 2 relation) "") 0 0 "")
3178 gnus-newsgroup-dependencies nil)
3179 (push gnus-reffed-article-number gnus-newsgroup-limit)
3180 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3181 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3182 gnus-newsgroup-reads)
3183 (decf gnus-reffed-article-number)))
3184 (sort relations 'car-less-than-car))
3185 (gnus-message 7 "Making sparse threads...done")))
3187 (defun gnus-build-old-threads ()
3188 ;; Look at all the articles that refer back to old articles, and
3189 ;; fetch the headers for the articles that aren't there. This will
3190 ;; build complete threads - if the roots haven't been expired by the
3195 (when (not (car (symbol-value refs)))
3196 (setq heads (cdr (symbol-value refs)))
3198 (if (memq (mail-header-number (caar heads))
3199 gnus-newsgroup-dormant)
3200 (setq heads (cdr heads))
3201 (setq id (symbol-name refs))
3202 (while (and (setq id (gnus-build-get-header id))
3203 (not (car (gnus-id-to-thread id)))))
3204 (setq heads nil)))))
3205 gnus-newsgroup-dependencies)))
3207 ;; This function has to be called with point after the article number
3208 ;; on the beginning of the line.
3209 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3210 (let ((eol (gnus-point-at-eol))
3211 (buffer (current-buffer))
3214 ;; overview: [num subject from date id refs chars lines misc]
3219 (make-full-mail-header
3221 (nnheader-nov-field) ; subject
3222 (nnheader-nov-field) ; from
3223 (nnheader-nov-field) ; date
3224 (nnheader-nov-read-message-id) ; id
3225 (nnheader-nov-field) ; refs
3226 (nnheader-nov-read-integer) ; chars
3227 (nnheader-nov-read-integer) ; lines
3229 (nnheader-nov-field)) ; misc
3230 (nnheader-nov-parse-extra))) ; extra
3232 (when gnus-alter-header-function
3233 (funcall gnus-alter-header-function header))
3234 (gnus-dependencies-add-header header dependencies force-new)))
3236 (defun gnus-build-get-header (id)
3237 ;; Look through the buffer of NOV lines and find the header to
3238 ;; ID. Enter this line into the dependencies hash table, and return
3239 ;; the id of the parent article (if any).
3240 (let ((deps gnus-newsgroup-dependencies)
3244 (set-buffer nntp-server-buffer)
3245 (let ((case-fold-search nil))
3246 (goto-char (point-min))
3247 (while (and (not found)
3248 (search-forward id nil t))
3250 (setq found (looking-at
3251 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3252 (regexp-quote id))))
3253 (or found (beginning-of-line 2)))
3257 (setq header (gnus-nov-parse-line
3258 (read (current-buffer)) deps))
3259 (gnus-parent-id (mail-header-references header))))))
3261 (let ((number (mail-header-number header)))
3262 (push number gnus-newsgroup-limit)
3263 (push header gnus-newsgroup-headers)
3264 (if (memq number gnus-newsgroup-unselected)
3266 (push number gnus-newsgroup-unreads)
3267 (setq gnus-newsgroup-unselected
3268 (delq number gnus-newsgroup-unselected)))
3269 (push number gnus-newsgroup-ancient)))))))
3271 (defun gnus-build-all-threads ()
3272 "Read all the headers."
3273 (let ((gnus-summary-ignore-duplicates t)
3274 (dependencies gnus-newsgroup-dependencies)
3277 (set-buffer nntp-server-buffer)
3278 (let ((case-fold-search nil))
3279 (goto-char (point-min))
3282 (setq article (read (current-buffer))
3283 header (gnus-nov-parse-line
3284 article dependencies)))
3287 (set-buffer gnus-summary-buffer)
3288 (push header gnus-newsgroup-headers)
3289 (if (memq (setq article (mail-header-number header))
3290 gnus-newsgroup-unselected)
3292 (push article gnus-newsgroup-unreads)
3293 (setq gnus-newsgroup-unselected
3294 (delq article gnus-newsgroup-unselected)))
3295 (push article gnus-newsgroup-ancient)))
3296 (forward-line 1)))))))
3298 (defun gnus-summary-update-article-line (article header)
3299 "Update the line for ARTICLE using HEADERS."
3300 (let* ((id (mail-header-id header))
3301 (thread (gnus-id-to-thread id)))
3303 (error "Article in no thread"))
3304 ;; Update the thread.
3305 (setcar thread header)
3306 (gnus-summary-goto-subject article)
3307 (let* ((datal (gnus-data-find-list article))
3309 (length (when (cdr datal)
3310 (- (gnus-data-pos data)
3311 (gnus-data-pos (cadr datal)))))
3312 (buffer-read-only nil)
3313 (level (gnus-summary-thread-level)))
3315 (gnus-summary-insert-line
3316 header level nil (gnus-article-mark article)
3317 (memq article gnus-newsgroup-replied)
3318 (memq article gnus-newsgroup-expirable)
3319 ;; Only insert the Subject string when it's different
3320 ;; from the previous Subject string.
3321 (if (gnus-subject-equal
3323 (mail-header-subject
3326 (gnus-data-find-list
3328 (gnus-data-list t)))))
3329 ;; Error on the side of excessive subjects.
3331 (mail-header-subject header))
3333 (mail-header-subject header))
3334 nil (cdr (assq article gnus-newsgroup-scored))
3335 (memq article gnus-newsgroup-processable))
3337 (gnus-data-update-list
3338 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3340 (defun gnus-summary-update-article (article &optional iheader)
3341 "Update ARTICLE in the summary buffer."
3342 (set-buffer gnus-summary-buffer)
3343 (let* ((header (gnus-summary-article-header article))
3344 (id (mail-header-id header))
3345 (data (gnus-data-find article))
3346 (thread (gnus-id-to-thread id))
3347 (references (mail-header-references header))
3351 (when (and references
3352 (not (equal "" references)))
3355 (buffer-read-only nil)
3361 (delq thread parent)))
3362 (if (gnus-summary-insert-subject id header)
3363 ;; Set the (possibly) new article number in the data structure.
3364 (gnus-data-set-number data (gnus-id-to-article id))
3368 (defun gnus-rebuild-thread (id &optional line)
3369 "Rebuild the thread containing ID.
3370 If LINE, insert the rebuilt thread starting on line LINE."
3371 (let ((buffer-read-only nil)
3372 old-pos current thread data)
3373 (if (not gnus-show-threads)
3374 (setq thread (list (car (gnus-id-to-thread id))))
3375 ;; Get the thread this article is part of.
3376 (setq thread (gnus-remove-thread id)))
3377 (setq old-pos (gnus-point-at-bol))
3378 (setq current (save-excursion
3379 (and (zerop (forward-line -1))
3380 (gnus-summary-article-number))))
3381 ;; If this is a gathered thread, we have to go some re-gathering.
3382 (when (stringp (car thread))
3383 (let ((subject (car thread))
3385 (setq thread (cdr thread))
3387 (unless (memq (setq thr (gnus-id-to-thread
3389 (mail-header-id (caar thread)))))
3392 (setq thread (cdr thread)))
3393 ;; We now have all (unique) roots.
3394 (if (= (length roots) 1)
3395 ;; All the loose roots are now one solid root.
3396 (setq thread (car roots))
3397 (setq thread (cons subject (gnus-sort-threads roots))))))
3399 ;; We then insert this thread into the summary buffer.
3401 (goto-char (point-min))
3402 (forward-line (1- line)))
3403 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3404 (if gnus-show-threads
3405 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3406 (gnus-summary-prepare-unthreaded thread))
3407 (setq data (nreverse gnus-newsgroup-data))
3408 (setq threads gnus-newsgroup-threads))
3409 ;; We splice the new data into the data structure.
3410 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3411 ;;!!! then we want to insert at the beginning of the buffer.
3412 ;;!!! That happens to be true with Gnus now, but that may
3413 ;;!!! change in the future. Perhaps.
3414 (gnus-data-enter-list
3415 (if line nil current) data (- (point) old-pos))
3416 (setq gnus-newsgroup-threads
3417 (nconc threads gnus-newsgroup-threads))
3418 (gnus-data-compute-positions))))
3420 (defun gnus-number-to-header (number)
3421 "Return the header for article NUMBER."
3422 (let ((headers gnus-newsgroup-headers))
3424 (not (= number (mail-header-number (car headers)))))
3429 (defun gnus-parent-headers (in-headers &optional generation)
3430 "Return the headers of the GENERATIONeth parent of HEADERS."
3432 (setq generation 1))
3434 (headers in-headers)
3437 (not (zerop generation))
3438 (setq references (mail-header-references headers)))
3439 (setq headers (if (and references
3440 (setq parent (gnus-parent-id references)))
3441 (car (gnus-id-to-thread parent))
3444 (and (not (eq headers in-headers))
3447 (defun gnus-id-to-thread (id)
3448 "Return the (sub-)thread where ID appears."
3449 (gnus-gethash id gnus-newsgroup-dependencies))
3451 (defun gnus-id-to-article (id)
3452 "Return the article number of ID."
3453 (let ((thread (gnus-id-to-thread id)))
3456 (mail-header-number (car thread)))))
3458 (defun gnus-id-to-header (id)
3459 "Return the article headers of ID."
3460 (car (gnus-id-to-thread id)))
3462 (defun gnus-article-displayed-root-p (article)
3463 "Say whether ARTICLE is a root(ish) article."
3464 (let ((level (gnus-summary-thread-level article))
3465 (refs (mail-header-references (gnus-summary-article-header article)))
3471 ((null (gnus-parent-id refs)) t)
3473 (null (setq particle (gnus-id-to-article
3474 (gnus-parent-id refs))))
3475 (null (gnus-summary-thread-level particle)))))))
3477 (defun gnus-root-id (id)
3478 "Return the id of the root of the thread where ID appears."
3480 (while (and id (setq prev (car (gnus-id-to-thread id))))
3482 id (gnus-parent-id (mail-header-references prev))))
3485 (defun gnus-articles-in-thread (thread)
3486 "Return the list of articles in THREAD."
3487 (cons (mail-header-number (car thread))
3488 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3490 (defun gnus-remove-thread (id &optional dont-remove)
3491 "Remove the thread that has ID in it."
3492 (let (headers thread last-id)
3493 ;; First go up in this thread until we find the root.
3494 (setq last-id (gnus-root-id id)
3495 headers (message-flatten-list (gnus-id-to-thread last-id)))
3496 ;; We have now found the real root of this thread. It might have
3497 ;; been gathered into some loose thread, so we have to search
3498 ;; through the threads to find the thread we wanted.
3499 (let ((threads gnus-newsgroup-threads)
3502 (setq sub (car threads))
3503 (if (stringp (car sub))
3504 ;; This is a gathered thread, so we look at the roots
3505 ;; below it to find whether this article is in this
3508 (setq sub (cdr sub))
3510 (when (member (caar sub) headers)
3511 (setq thread (car threads)
3514 (setq sub (cdr sub))))
3515 ;; It's an ordinary thread, so we check it.
3516 (when (eq (car sub) (car headers))
3519 (setq threads (cdr threads)))
3520 ;; If this article is in no thread, then it's a root.
3523 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3524 (setq thread (gnus-id-to-thread last-id)))
3527 thread ; We return this thread.
3529 (if (stringp (car thread))
3531 ;; If we use dummy roots, then we have to remove the
3532 ;; dummy root as well.
3533 (when (eq gnus-summary-make-false-root 'dummy)
3534 ;; We go to the dummy root by going to
3535 ;; the first sub-"thread", and then one line up.
3536 (gnus-summary-goto-article
3537 (mail-header-number (caadr thread)))
3540 (gnus-data-compute-positions))
3541 (setq thread (cdr thread))
3543 (gnus-remove-thread-1 (car thread))
3544 (setq thread (cdr thread))))
3545 (gnus-summary-show-all-threads)
3546 (gnus-remove-thread-1 thread))))))))
3548 (defun gnus-remove-thread-1 (thread)
3549 "Remove the thread THREAD recursively."
3550 (let ((number (mail-header-number (pop thread)))
3552 (setq thread (reverse thread))
3554 (gnus-remove-thread-1 (pop thread)))
3555 (when (setq d (gnus-data-find number))
3556 (goto-char (gnus-data-pos d))
3559 (- (gnus-point-at-bol)
3561 (1+ (gnus-point-at-eol))
3562 (gnus-delete-line)))))))
3564 (defun gnus-sort-threads (threads)
3566 (if (not gnus-thread-sort-functions)
3568 (gnus-message 8 "Sorting threads...")
3570 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3571 (gnus-message 8 "Sorting threads...done"))))
3573 (defun gnus-sort-articles (articles)
3575 (when gnus-article-sort-functions
3576 (gnus-message 7 "Sorting articles...")
3578 (setq gnus-newsgroup-headers
3579 (sort articles (gnus-make-sort-function
3580 gnus-article-sort-functions)))
3581 (gnus-message 7 "Sorting articles...done"))))
3583 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3584 (defmacro gnus-thread-header (thread)
3585 ;; Return header of first article in THREAD.
3586 ;; Note that THREAD must never, ever be anything else than a variable -
3587 ;; using some other form will lead to serious barfage.
3588 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3589 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3590 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3593 (defsubst gnus-article-sort-by-number (h1 h2)
3594 "Sort articles by article number."
3595 (< (mail-header-number h1)
3596 (mail-header-number h2)))
3598 (defun gnus-thread-sort-by-number (h1 h2)
3599 "Sort threads by root article number."
3600 (gnus-article-sort-by-number
3601 (gnus-thread-header h1) (gnus-thread-header h2)))
3603 (defsubst gnus-article-sort-by-lines (h1 h2)
3604 "Sort articles by article Lines header."
3605 (< (mail-header-lines h1)
3606 (mail-header-lines h2)))
3608 (defun gnus-thread-sort-by-lines (h1 h2)
3609 "Sort threads by root article Lines header."
3610 (gnus-article-sort-by-lines
3611 (gnus-thread-header h1) (gnus-thread-header h2)))
3613 (defsubst gnus-article-sort-by-chars (h1 h2)
3614 "Sort articles by octet length."
3615 (< (mail-header-chars h1)
3616 (mail-header-chars h2)))
3618 (defun gnus-thread-sort-by-chars (h1 h2)
3619 "Sort threads by root article octet length."
3620 (gnus-article-sort-by-chars
3621 (gnus-thread-header h1) (gnus-thread-header h2)))
3623 (defsubst gnus-article-sort-by-author (h1 h2)
3624 "Sort articles by root author."
3626 (let ((addr (car (mime-read-field 'From h1))))
3627 (or (std11-full-name-string addr)
3628 (std11-address-string addr)
3630 (let ((addr (car (mime-read-field 'From h2))))
3631 (or (std11-full-name-string addr)
3632 (std11-address-string addr)
3636 (defun gnus-thread-sort-by-author (h1 h2)
3637 "Sort threads by root author."
3638 (gnus-article-sort-by-author
3639 (gnus-thread-header h1) (gnus-thread-header h2)))
3641 (defsubst gnus-article-sort-by-subject (h1 h2)
3642 "Sort articles by root subject."
3644 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3645 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3647 (defun gnus-thread-sort-by-subject (h1 h2)
3648 "Sort threads by root subject."
3649 (gnus-article-sort-by-subject
3650 (gnus-thread-header h1) (gnus-thread-header h2)))
3652 (defsubst gnus-article-sort-by-date (h1 h2)
3653 "Sort articles by root article date."
3655 (gnus-date-get-time (mail-header-date h1))
3656 (gnus-date-get-time (mail-header-date h2))))
3658 (defun gnus-thread-sort-by-date (h1 h2)
3659 "Sort threads by root article date."
3660 (gnus-article-sort-by-date
3661 (gnus-thread-header h1) (gnus-thread-header h2)))
3663 (defsubst gnus-article-sort-by-score (h1 h2)
3664 "Sort articles by root article score.
3665 Unscored articles will be counted as having a score of zero."
3666 (> (or (cdr (assq (mail-header-number h1)
3667 gnus-newsgroup-scored))
3668 gnus-summary-default-score 0)
3669 (or (cdr (assq (mail-header-number h2)
3670 gnus-newsgroup-scored))
3671 gnus-summary-default-score 0)))
3673 (defun gnus-thread-sort-by-score (h1 h2)
3674 "Sort threads by root article score."
3675 (gnus-article-sort-by-score
3676 (gnus-thread-header h1) (gnus-thread-header h2)))
3678 (defun gnus-thread-sort-by-total-score (h1 h2)
3679 "Sort threads by the sum of all scores in the thread.
3680 Unscored articles will be counted as having a score of zero."
3681 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3683 (defun gnus-thread-total-score (thread)
3684 ;; This function find the total score of THREAD.
3685 (cond ((null thread)
3688 (if (stringp (car thread))
3689 (apply gnus-thread-score-function 0
3690 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3691 (gnus-thread-total-score-1 thread)))
3693 (gnus-thread-total-score-1 (list thread)))))
3695 (defun gnus-thread-total-score-1 (root)
3696 ;; This function find the total score of the thread below ROOT.
3697 (setq root (car root))
3698 (apply gnus-thread-score-function
3700 (mapcar 'gnus-thread-total-score
3701 (cdr (gnus-id-to-thread (mail-header-id root))))
3702 (when (> (mail-header-number root) 0)
3703 (list (or (cdr (assq (mail-header-number root)
3704 gnus-newsgroup-scored))
3705 gnus-summary-default-score 0))))
3706 (list gnus-summary-default-score)
3709 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3710 (defvar gnus-tmp-prev-subject nil)
3711 (defvar gnus-tmp-false-parent nil)
3712 (defvar gnus-tmp-root-expunged nil)
3713 (defvar gnus-tmp-dummy-line nil)
3715 (defvar gnus-tmp-header)
3716 (defun gnus-extra-header (type &optional header)
3717 "Return the extra header of TYPE."
3718 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3721 (defun gnus-summary-prepare-threads (threads)
3722 "Prepare summary buffer from THREADS and indentation LEVEL.
3723 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3724 or a straight list of headers."
3725 (gnus-message 7 "Generating summary...")
3727 (setq gnus-newsgroup-threads threads)
3730 (let ((gnus-tmp-level 0)
3731 (default-score (or gnus-summary-default-score 0))
3732 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3733 thread number subject stack state gnus-tmp-gathered beg-match
3734 new-roots gnus-tmp-new-adopts thread-end
3735 gnus-tmp-header gnus-tmp-unread
3736 gnus-tmp-replied gnus-tmp-subject-or-nil
3737 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3738 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3739 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3741 (setq gnus-tmp-prev-subject nil)
3743 (if (vectorp (car threads))
3744 ;; If this is a straight (sic) list of headers, then a
3745 ;; threaded summary display isn't required, so we just create
3746 ;; an unthreaded one.
3747 (gnus-summary-prepare-unthreaded threads)
3749 ;; Do the threaded display.
3751 (while (or threads stack gnus-tmp-new-adopts new-roots)
3753 (if (and (= gnus-tmp-level 0)
3756 (not gnus-tmp-false-parent)
3757 (or gnus-tmp-new-adopts new-roots))
3758 (if gnus-tmp-new-adopts
3759 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3760 thread (list (car gnus-tmp-new-adopts))
3761 gnus-tmp-header (caar thread)
3762 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3764 (setq thread (list (car new-roots))
3765 gnus-tmp-header (caar thread)
3766 new-roots (cdr new-roots))))
3769 ;; If there are some threads, we do them before the
3770 ;; threads on the stack.
3771 (setq thread threads
3772 gnus-tmp-header (caar thread))
3773 ;; There were no current threads, so we pop something off
3775 (setq state (car stack)
3776 gnus-tmp-level (car state)
3779 gnus-tmp-header (caar thread))))
3781 (setq gnus-tmp-false-parent nil)
3782 (setq gnus-tmp-root-expunged nil)
3783 (setq thread-end nil)
3785 (if (stringp gnus-tmp-header)
3786 ;; The header is a dummy root.
3788 ((eq gnus-summary-make-false-root 'adopt)
3789 ;; We let the first article adopt the rest.
3790 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3792 (setq gnus-tmp-gathered
3794 (lambda (h) (mail-header-number (car h)))
3797 (setq thread (cons (list (caar thread)
3800 (setq gnus-tmp-level -1
3801 gnus-tmp-false-parent t))
3802 ((eq gnus-summary-make-false-root 'empty)
3803 ;; We print adopted articles with empty subject fields.
3804 (setq gnus-tmp-gathered
3806 (lambda (h) (mail-header-number (car h)))
3809 (setq gnus-tmp-level -1))
3810 ((eq gnus-summary-make-false-root 'dummy)
3811 ;; We remember that we probably want to output a dummy
3813 (setq gnus-tmp-dummy-line gnus-tmp-header)
3814 (setq gnus-tmp-prev-subject gnus-tmp-header))
3816 ;; We do not make a root for the gathered
3817 ;; sub-threads at all.
3818 (setq gnus-tmp-level -1)))
3820 (setq number (mail-header-number gnus-tmp-header)
3821 subject (mail-header-subject gnus-tmp-header))
3824 ;; If the thread has changed subject, we might want to make
3825 ;; this subthread into a root.
3826 ((and (null gnus-thread-ignore-subject)
3827 (not (zerop gnus-tmp-level))
3828 gnus-tmp-prev-subject
3830 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3831 (setq new-roots (nconc new-roots (list (car thread)))
3833 gnus-tmp-header nil))
3834 ;; If the article lies outside the current limit,
3835 ;; then we do not display it.
3836 ((not (memq number gnus-newsgroup-limit))
3837 (setq gnus-tmp-gathered
3839 (lambda (h) (mail-header-number (car h)))
3842 (setq gnus-tmp-new-adopts (if (cdar thread)
3843 (append gnus-tmp-new-adopts
3845 gnus-tmp-new-adopts)
3847 gnus-tmp-header nil)
3848 (when (zerop gnus-tmp-level)
3849 (setq gnus-tmp-root-expunged t)))
3850 ;; Perhaps this article is to be marked as read?
3851 ((and gnus-summary-mark-below
3852 (< (or (cdr (assq number gnus-newsgroup-scored))
3854 gnus-summary-mark-below)
3855 ;; Don't touch sparse articles.
3856 (not (gnus-summary-article-sparse-p number))
3857 (not (gnus-summary-article-ancient-p number)))
3858 (setq gnus-newsgroup-unreads
3859 (delq number gnus-newsgroup-unreads))
3860 (if gnus-newsgroup-auto-expire
3861 (push number gnus-newsgroup-expirable)
3862 (push (cons number gnus-low-score-mark)
3863 gnus-newsgroup-reads))))
3865 (when gnus-tmp-header
3866 ;; We may have an old dummy line to output before this
3868 (when (and gnus-tmp-dummy-line
3871 (mail-header-subject gnus-tmp-header)))
3872 (gnus-summary-insert-dummy-line
3873 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3874 (setq gnus-tmp-dummy-line nil))
3876 ;; Compute the mark.
3877 (setq gnus-tmp-unread (gnus-article-mark number))
3879 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3880 gnus-tmp-header gnus-tmp-level)
3881 gnus-newsgroup-data)
3883 ;; Actually insert the line.
3885 gnus-tmp-subject-or-nil
3887 ((and gnus-thread-ignore-subject
3888 gnus-tmp-prev-subject
3889 (not (inline (gnus-subject-equal
3890 gnus-tmp-prev-subject subject))))
3892 ((zerop gnus-tmp-level)
3893 (if (and (eq gnus-summary-make-false-root 'empty)
3894 (memq number gnus-tmp-gathered)
3895 gnus-tmp-prev-subject
3896 (inline (gnus-subject-equal
3897 gnus-tmp-prev-subject subject)))
3898 gnus-summary-same-subject
3900 (t gnus-summary-same-subject)))
3901 (if (and (eq gnus-summary-make-false-root 'adopt)
3902 (= gnus-tmp-level 1)
3903 (memq number gnus-tmp-gathered))
3904 (setq gnus-tmp-opening-bracket ?\<
3905 gnus-tmp-closing-bracket ?\>)
3906 (setq gnus-tmp-opening-bracket ?\[
3907 gnus-tmp-closing-bracket ?\]))
3909 gnus-tmp-indentation
3910 (aref gnus-thread-indent-array gnus-tmp-level)
3911 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3912 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3913 gnus-summary-default-score 0)
3915 (if (or (null gnus-summary-default-score)
3916 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3917 gnus-summary-zcore-fuzz))
3919 (if (< gnus-tmp-score gnus-summary-default-score)
3920 gnus-score-below-mark gnus-score-over-mark))
3922 (cond ((memq number gnus-newsgroup-processable)
3924 ((memq number gnus-newsgroup-cached)
3926 ((memq number gnus-newsgroup-replied)
3928 ((memq number gnus-newsgroup-saved)
3930 (t gnus-unread-mark))
3931 gnus-tmp-from (mail-header-from gnus-tmp-header)
3934 ((string-match "<[^>]+> *$" gnus-tmp-from)
3935 (setq beg-match (match-beginning 0))
3936 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3937 (substring gnus-tmp-from (1+ (match-beginning 0))
3938 (1- (match-end 0))))
3939 (substring gnus-tmp-from 0 beg-match)))
3940 ((string-match "(.+)" gnus-tmp-from)
3941 (substring gnus-tmp-from
3942 (1+ (match-beginning 0)) (1- (match-end 0))))
3944 (when (string= gnus-tmp-name "")
3945 (setq gnus-tmp-name gnus-tmp-from))
3946 (unless (numberp gnus-tmp-lines)
3947 (setq gnus-tmp-lines 0))
3948 (gnus-put-text-property
3950 (progn (eval gnus-summary-line-format-spec) (point))
3951 'gnus-number number)
3954 (gnus-run-hooks 'gnus-summary-update-hook)
3957 (setq gnus-tmp-prev-subject subject)))
3959 (when (nth 1 thread)
3960 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3961 (incf gnus-tmp-level)
3962 (setq threads (if thread-end nil (cdar thread)))
3964 (setq gnus-tmp-level 0)))))
3965 (gnus-message 7 "Generating summary...done"))
3967 (defun gnus-summary-prepare-unthreaded (headers)
3968 "Generate an unthreaded summary buffer based on HEADERS."
3969 (let (header number mark)
3974 ;; We may have to root out some bad articles...
3975 (when (memq (setq number (mail-header-number
3976 (setq header (pop headers))))
3977 gnus-newsgroup-limit)
3978 ;; Mark article as read when it has a low score.
3979 (when (and gnus-summary-mark-below
3980 (< (or (cdr (assq number gnus-newsgroup-scored))
3981 gnus-summary-default-score 0)
3982 gnus-summary-mark-below)
3983 (not (gnus-summary-article-ancient-p number)))
3984 (setq gnus-newsgroup-unreads
3985 (delq number gnus-newsgroup-unreads))
3986 (if gnus-newsgroup-auto-expire
3987 (push number gnus-newsgroup-expirable)
3988 (push (cons number gnus-low-score-mark)
3989 gnus-newsgroup-reads)))
3991 (setq mark (gnus-article-mark number))
3992 (push (gnus-data-make number mark (1+ (point)) header 0)
3993 gnus-newsgroup-data)
3994 (gnus-summary-insert-line
3996 mark (memq number gnus-newsgroup-replied)
3997 (memq number gnus-newsgroup-expirable)
3998 (mail-header-subject header) nil
3999 (cdr (assq number gnus-newsgroup-scored))
4000 (memq number gnus-newsgroup-processable))))))
4002 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4003 "Select newsgroup GROUP.
4004 If READ-ALL is non-nil, all articles in the group are selected.
4005 If SELECT-ARTICLES, only select those articles from GROUP."
4006 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4007 ;;!!! Dirty hack; should be removed.
4008 (gnus-summary-ignore-duplicates
4009 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4011 gnus-summary-ignore-duplicates))
4012 (info (nth 2 entry))
4013 articles fetched-articles cached)
4015 (unless (gnus-check-server
4016 (setq gnus-current-select-method
4017 (gnus-find-method-for-group group)))
4018 (error "Couldn't open server"))
4020 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4021 (gnus-activate-group group) ; Or we can activate it...
4022 (progn ; Or we bug out.
4023 (when (equal major-mode 'gnus-summary-mode)
4024 (kill-buffer (current-buffer)))
4025 (error "Couldn't request group %s: %s"
4026 group (gnus-status-message group))))
4028 (unless (gnus-request-group group t)
4029 (when (equal major-mode 'gnus-summary-mode)
4030 (kill-buffer (current-buffer)))
4031 (error "Couldn't request group %s: %s"
4032 group (gnus-status-message group)))
4034 (setq gnus-newsgroup-name group)
4035 (setq gnus-newsgroup-unselected nil)
4036 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4037 (gnus-summary-setup-default-charset)
4039 ;; Adjust and set lists of article marks.
4041 (gnus-adjust-marked-articles info))
4043 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4045 (if (gnus-virtual-group-p group)
4046 gnus-newsgroup-cached
4047 (gnus-cache-articles-in-group group)))
4049 (setq gnus-newsgroup-unreads
4050 (gnus-set-difference
4051 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4052 gnus-newsgroup-dormant))
4054 (setq gnus-newsgroup-processable nil)
4056 (gnus-update-read-articles group gnus-newsgroup-unreads)
4058 (if (setq articles select-articles)
4059 (setq gnus-newsgroup-unselected
4060 (gnus-sorted-intersection
4061 gnus-newsgroup-unreads
4062 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4063 (setq articles (gnus-articles-to-read group read-all)))
4067 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4069 ((eq articles 0) nil)
4071 ;; Init the dependencies hash table.
4072 (setq gnus-newsgroup-dependencies
4073 (gnus-make-hashtable (length articles)))
4074 (gnus-set-global-variables)
4075 ;; Retrieve the headers and read them in.
4076 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4077 (setq gnus-newsgroup-headers
4078 (gnus-retrieve-parsed-headers
4079 articles gnus-newsgroup-name
4080 ;; We might want to fetch old headers, but
4081 ;; not if there is only 1 article.
4082 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4083 (not (numberp gnus-fetch-old-headers)))
4084 (> (length articles) 1))
4085 gnus-fetch-old-headers)))
4086 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4088 ;; Suppress duplicates?
4089 (when gnus-suppress-duplicates
4090 (gnus-dup-suppress-articles))
4092 ;; Set the initial limit.
4093 (setq gnus-newsgroup-limit (copy-sequence articles))
4094 ;; Remove canceled articles from the list of unread articles.
4095 (setq gnus-newsgroup-unreads
4096 (gnus-set-sorted-intersection
4097 gnus-newsgroup-unreads
4098 (setq fetched-articles
4099 (mapcar (lambda (headers) (mail-header-number headers))
4100 gnus-newsgroup-headers))))
4101 ;; Removed marked articles that do not exist.
4102 (gnus-update-missing-marks
4103 (gnus-sorted-complement fetched-articles articles))
4105 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4107 (setq gnus-newsgroup-cached cached))
4109 ;; We might want to build some more threads first.
4110 (when (and gnus-fetch-old-headers
4111 (eq gnus-headers-retrieved-by 'nov))
4112 (if (eq gnus-fetch-old-headers 'invisible)
4113 (gnus-build-all-threads)
4114 (gnus-build-old-threads)))
4115 ;; Let the Gnus agent mark articles as read.
4117 (gnus-agent-get-undownloaded-list))
4118 ;; Check whether auto-expire is to be done in this group.
4119 (setq gnus-newsgroup-auto-expire
4120 (gnus-group-auto-expirable-p group))
4121 ;; Set up the article buffer now, if necessary.
4122 (unless gnus-single-article-buffer
4123 (gnus-article-setup-buffer))
4124 ;; First and last article in this newsgroup.
4125 (when gnus-newsgroup-headers
4126 (setq gnus-newsgroup-begin
4127 (mail-header-number (car gnus-newsgroup-headers))
4130 (gnus-last-element gnus-newsgroup-headers))))
4131 ;; GROUP is successfully selected.
4132 (or gnus-newsgroup-headers t)))))
4134 (defun gnus-articles-to-read (group &optional read-all)
4135 ;; Find out what articles the user wants to read.
4137 ;; Select all articles if `read-all' is non-nil, or if there
4138 ;; are no unread articles.
4140 (and (zerop (length gnus-newsgroup-marked))
4141 (zerop (length gnus-newsgroup-unreads)))
4142 (eq (gnus-group-find-parameter group 'display)
4144 (gnus-uncompress-range (gnus-active group))
4145 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4146 (copy-sequence gnus-newsgroup-unreads))
4148 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4149 (scored (length scored-list))
4150 (number (length articles))
4151 (marked (+ (length gnus-newsgroup-marked)
4152 (length gnus-newsgroup-dormant)))
4160 ((and (or (<= scored marked) (= scored number))
4161 (natnump gnus-large-newsgroup)
4162 (> number gnus-large-newsgroup))
4163 (let ((input (read-from-minibuffer
4165 "How many articles from %s (max %d): "
4166 (gnus-limit-string gnus-newsgroup-name 35)
4168 (static-if (< emacs-major-version 20)
4169 (number-to-string gnus-large-newsgroup)
4171 (number-to-string gnus-large-newsgroup)
4173 (if (string-match "^[ \t]*$" input)
4176 ((and (> scored marked) (< scored number)
4177 (> (- scored number) 20))
4180 (format "%s %s (%d scored, %d total): "
4181 "How many articles from"
4182 group scored number))))
4183 (if (string-match "^[ \t]*$" input)
4187 (setq select (if (stringp select) (string-to-number select) select))
4188 (if (or (null select) (zerop select))
4190 (if (and (not (zerop scored)) (<= (abs select) scored))
4192 (setq articles (sort scored-list '<))
4193 (setq number (length articles)))
4194 (setq articles (copy-sequence articles)))
4196 (when (< (abs select) number)
4198 ;; Select the N oldest articles.
4199 (setcdr (nthcdr (1- (abs select)) articles) nil)
4200 ;; Select the N most recent articles.
4201 (setq articles (nthcdr (- number select) articles))))
4202 (setq gnus-newsgroup-unselected
4203 (gnus-sorted-intersection
4204 gnus-newsgroup-unreads
4205 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4208 (defun gnus-killed-articles (killed articles)
4211 (when (inline (gnus-member-of-range (car articles) killed))
4212 (push (car articles) out))
4213 (setq articles (cdr articles)))
4216 (defun gnus-uncompress-marks (marks)
4217 "Uncompress the mark ranges in MARKS."
4218 (let ((uncompressed '(score bookmark))
4221 (if (memq (caar marks) uncompressed)
4222 (push (car marks) out)
4223 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4224 (setq marks (cdr marks)))
4227 (defun gnus-adjust-marked-articles (info)
4228 "Set all article lists and remove all marks that are no longer valid."
4229 (let* ((marked-lists (gnus-info-marks info))
4230 (active (gnus-active (gnus-info-group info)))
4233 (types gnus-article-mark-lists)
4234 (uncompressed '(score bookmark killed))
4235 marks var articles article mark)
4238 (setq marks (pop marked-lists))
4239 (set (setq var (intern (format "gnus-newsgroup-%s"
4240 (car (rassq (setq mark (car marks))
4242 (if (memq (car marks) uncompressed) (cdr marks)
4243 (gnus-uncompress-range (cdr marks))))
4245 (setq articles (symbol-value var))
4247 ;; All articles have to be subsets of the active articles.
4249 ;; Adjust "simple" lists.
4250 ((memq mark '(tick dormant expire reply save))
4252 (when (or (< (setq article (pop articles)) min) (> article max))
4253 (set var (delq article (symbol-value var))))))
4255 ((memq mark uncompressed)
4256 (when (not (listp (cdr (symbol-value var))))
4257 (set var (list (symbol-value var))))
4258 (when (not (listp (cdr articles)))
4259 (setq articles (list articles)))
4261 (when (or (not (consp (setq article (pop articles))))
4262 (< (car article) min)
4263 (> (car article) max))
4264 (set var (delq article (symbol-value var))))))))))
4266 (defun gnus-update-missing-marks (missing)
4267 "Go through the list of MISSING articles and remove them from the mark lists."
4269 (let ((types gnus-article-mark-lists)
4271 ;; Go through all types.
4273 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4274 (when (symbol-value var)
4275 ;; This list has articles. So we delete all missing articles
4279 (set var (delq (pop m) (symbol-value var)))))))))
4281 (defun gnus-update-marks ()
4282 "Enter the various lists of marked articles into the newsgroup info list."
4283 (let ((types gnus-article-mark-lists)
4284 (info (gnus-get-info gnus-newsgroup-name))
4285 (uncompressed '(score bookmark killed))
4286 type list newmarked symbol delta-marks)
4288 ;; Add all marks lists to the list of marks lists.
4289 (while (setq type (pop types))
4290 (setq list (symbol-value
4292 (intern (format "gnus-newsgroup-%s"
4296 ;; Get rid of the entries of the articles that have the
4298 (when (and (eq (cdr type) 'score)
4302 (prev (cons nil list))
4305 (if (or (not (consp (car arts)))
4306 (= (cdar arts) gnus-summary-default-score))
4307 (setcdr prev (cdr arts))
4309 (setq arts (cdr arts)))
4310 (setq list (cdr all)))))
4312 (or (memq (cdr type) uncompressed)
4313 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4315 (when (gnus-check-backend-function 'request-set-mark
4316 gnus-newsgroup-name)
4317 ;; uncompressed:s are not proper flags (they are cons cells)
4318 ;; cache is a internal gnus flag
4319 (unless (memq (cdr type) (cons 'cache uncompressed))
4320 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4321 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4322 (add (gnus-remove-from-range (gnus-copy-sequence list) old)))
4324 (push (list add 'add (list (cdr type))) delta-marks))
4326 (push (list del 'del (list (cdr type))) delta-marks)))))
4329 (push (cons (cdr type) list) newmarked)))
4332 (unless (gnus-check-group gnus-newsgroup-name)
4333 (error "Can't open server for %s" gnus-newsgroup-name))
4334 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4336 ;; Enter these new marks into the info of the group.
4338 (setcar (nthcdr 3 info) newmarked)
4339 ;; Add the marks lists to the end of the info.
4341 (setcdr (nthcdr 2 info) (list newmarked))))
4343 ;; Cut off the end of the info if there's nothing else there.
4347 (when (nthcdr (decf i) info)
4348 (setcdr (nthcdr i info) nil)))))))
4350 (defun gnus-set-mode-line (where)
4351 "This function sets the mode line of the article or summary buffers.
4352 If WHERE is `summary', the summary mode line format will be used."
4353 ;; Is this mode line one we keep updated?
4354 (when (and (memq where gnus-updated-mode-lines)
4356 (intern (format "gnus-%s-mode-line-format-spec" where))))
4359 ;; We evaluate this in the summary buffer since these
4360 ;; variables are buffer-local to that buffer.
4361 (set-buffer gnus-summary-buffer)
4362 ;; We bind all these variables that are used in the `eval' form
4364 (let* ((mformat (symbol-value
4366 (format "gnus-%s-mode-line-format-spec" where))))
4367 (gnus-tmp-group-name gnus-newsgroup-name)
4368 (gnus-tmp-article-number (or gnus-current-article 0))
4369 (gnus-tmp-unread gnus-newsgroup-unreads)
4370 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4371 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4372 (gnus-tmp-unread-and-unselected
4373 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4374 (zerop gnus-tmp-unselected))
4376 ((zerop gnus-tmp-unselected)
4377 (format "{%d more}" gnus-tmp-unread-and-unticked))
4378 (t (format "{%d(+%d) more}"
4379 gnus-tmp-unread-and-unticked
4380 gnus-tmp-unselected))))
4382 (if (and gnus-current-headers
4383 (vectorp gnus-current-headers))
4384 (gnus-mode-string-quote
4385 (mail-header-subject gnus-current-headers))
4387 bufname-length max-len
4388 gnus-tmp-header);; passed as argument to any user-format-funcs
4389 (setq mode-string (eval mformat))
4390 (setq bufname-length (if (string-match "%b" mode-string)
4393 (if (eq where 'summary)
4395 (get-buffer gnus-article-buffer))))
4398 (setq max-len (max 4 (if gnus-mode-non-string-length
4400 gnus-mode-non-string-length
4402 (length mode-string))))
4403 ;; We might have to chop a bit of the string off...
4404 (when (> (length mode-string) max-len)
4406 (concat (gnus-truncate-string mode-string (- max-len 3))
4408 ;; Pad the mode string a bit.
4409 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4410 ;; Update the mode line.
4411 (setq mode-line-buffer-identification
4412 (gnus-mode-line-buffer-identification (list mode-string)))
4413 (set-buffer-modified-p t))))
4415 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4416 "Go through the HEADERS list and add all Xrefs to a hash table.
4417 The resulting hash table is returned, or nil if no Xrefs were found."
4418 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4419 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4420 (xref-hashtb (gnus-make-hashtable))
4421 start group entry number xrefs header)
4423 (setq header (pop headers))
4424 (when (and (setq xrefs (mail-header-xref header))
4425 (not (memq (setq number (mail-header-number header))
4428 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4429 (setq start (match-end 0))
4430 (setq group (if prefix
4431 (concat prefix (substring xrefs (match-beginning 1)
4433 (substring xrefs (match-beginning 1) (match-end 1))))
4435 (string-to-int (substring xrefs (match-beginning 2)
4437 (if (setq entry (gnus-gethash group xref-hashtb))
4438 (setcdr entry (cons number (cdr entry)))
4439 (gnus-sethash group (cons number nil) xref-hashtb)))))
4440 (and start xref-hashtb)))
4442 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4443 "Look through all the headers and mark the Xrefs as read."
4444 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4445 name entry info xref-hashtb idlist method nth4)
4447 (set-buffer gnus-group-buffer)
4448 (when (setq xref-hashtb
4449 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4452 (unless (string= from-newsgroup (setq name (symbol-name group)))
4453 (setq idlist (symbol-value group))
4454 ;; Dead groups are not updated.
4456 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4458 (when (stringp (setq nth4 (gnus-info-method info)))
4459 (setq nth4 (gnus-server-to-method nth4))))
4460 ;; Only do the xrefs if the group has the same
4461 ;; select method as the group we have just read.
4462 (or (gnus-methods-equal-p
4463 nth4 (gnus-find-method-for-group from-newsgroup))
4465 (equal nth4 (setq method (gnus-find-method-for-group
4467 (and (equal (car nth4) (car method))
4468 (equal (nth 1 nth4) (nth 1 method))))
4469 gnus-use-cross-reference
4470 (or (not (eq gnus-use-cross-reference t))
4472 ;; Only do cross-references on subscribed
4473 ;; groups, if that is what is wanted.
4474 (<= (gnus-info-level info) gnus-level-subscribed))
4475 (gnus-group-make-articles-read name idlist))))
4478 (defun gnus-compute-read-articles (group articles)
4479 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4480 (info (nth 2 entry))
4481 (active (gnus-active group))
4484 ;; First peel off all invalid article numbers.
4486 (let ((ids articles)
4488 (while (setq id (pop ids))
4489 (when (and first (> id (cdr active)))
4490 ;; We'll end up in this situation in one particular
4491 ;; obscure situation. If you re-scan a group and get
4492 ;; a new article that is cross-posted to a different
4493 ;; group that has not been re-scanned, you might get
4494 ;; crossposted article that has a higher number than
4495 ;; Gnus believes possible. So we re-activate this
4496 ;; group as well. This might mean doing the
4497 ;; crossposting thingy will *increase* the number
4498 ;; of articles in some groups. Tsk, tsk.
4499 (setq active (or (gnus-activate-group group) active)))
4500 (when (or (> id (cdr active))
4501 (< id (car active)))
4502 (setq articles (delq id articles))))))
4503 ;; If the read list is nil, we init it.
4505 (null (gnus-info-read info))
4507 (setq ninfo (cons 1 (1- (car active))))
4508 (setq ninfo (gnus-info-read info)))
4509 ;; Then we add the read articles to the range.
4511 ninfo (setq articles (sort articles '<))))))
4513 (defun gnus-group-make-articles-read (group articles)
4514 "Update the info of GROUP to say that ARTICLES are read."
4516 (entry (gnus-gethash group gnus-newsrc-hashtb))
4517 (info (nth 2 entry))
4518 (active (gnus-active group))
4521 (setq range (gnus-compute-read-articles group articles))
4523 (set-buffer gnus-group-buffer)
4526 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4527 (gnus-info-set-read ',info ',(gnus-info-read info))
4528 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4529 (gnus-group-update-group ,group t))))
4530 ;; Add the read articles to the range.
4531 (gnus-info-set-read info range)
4532 ;; Then we have to re-compute how many unread
4533 ;; articles there are in this group.
4537 (setq num (- (1+ (cdr active)) (car active))))
4538 ((not (listp (cdr range)))
4539 (setq num (- (cdr active) (- (1+ (cdr range))
4543 (if (numberp (car range))
4545 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4546 (setq range (cdr range)))
4547 (setq num (- (cdr active) num))))
4548 ;; Update the number of unread articles.
4550 ;; Update the group buffer.
4551 (gnus-group-update-group group t)))))
4553 (defvar gnus-newsgroup-none-id 0)
4555 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4556 (let ((cur nntp-server-buffer)
4559 (save-excursion (set-buffer gnus-summary-buffer)
4560 gnus-newsgroup-dependencies)))
4562 (mail-parse-charset gnus-newsgroup-charset)
4563 (mail-parse-ignored-charsets
4564 (save-excursion (condition-case nil
4565 (set-buffer gnus-summary-buffer)
4567 gnus-newsgroup-ignored-charsets)))
4569 (set-buffer nntp-server-buffer)
4570 ;; Translate all TAB characters into SPACE characters.
4571 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4572 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4573 (gnus-run-hooks 'gnus-parse-headers-hook)
4574 (let ((case-fold-search t)
4575 in-reply-to header p lines chars ctype)
4576 (goto-char (point-min))
4577 ;; Search to the beginning of the next header. Error messages
4578 ;; do not begin with 2 or 3.
4579 (while (re-search-forward "^[23][0-9]+ " nil t)
4582 ;; This implementation of this function, with nine
4583 ;; search-forwards instead of the one re-search-forward and
4584 ;; a case (which basically was the old function) is actually
4585 ;; about twice as fast, even though it looks messier. You
4586 ;; can't have everything, I guess. Speed and elegance
4587 ;; doesn't always go hand in hand.
4590 (make-full-mail-header
4596 (narrow-to-region (point)
4597 (or (and (search-forward "\n.\n" nil t)
4603 (if (search-forward "\nsubject: " nil t)
4604 (buffer-substring (match-end 0) (std11-field-end))
4609 (if (search-forward "\nfrom: " nil t)
4610 (buffer-substring (match-end 0) (std11-field-end))
4615 (if (search-forward "\ndate: " nil t)
4616 (buffer-substring (match-end 0) (std11-field-end))
4621 (setq id (if (re-search-forward
4622 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4623 ;; We do it this way to make sure the Message-ID
4624 ;; is (somewhat) syntactically valid.
4625 (buffer-substring (match-beginning 1)
4627 ;; If there was no message-id, we just fake one
4628 ;; to make subsequent routines simpler.
4629 (nnheader-generate-fake-message-id))))
4633 (if (search-forward "\nreferences: " nil t)
4637 (buffer-substring (match-end 0) (std11-field-end))
4642 (search-backward ">" end t)
4645 (search-backward "<" end t)
4647 ;; Get the references from the in-reply-to header if there
4648 ;; were no references and the in-reply-to header looks
4650 (if (and (search-forward "\nin-reply-to: " nil t)
4652 (buffer-substring (match-end 0)
4654 (string-match "<[^>]+>" in-reply-to))
4656 (setq ref (substring in-reply-to (match-beginning 0)
4658 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4659 (setq ref2 (substring in-reply-to (match-beginning 0)
4661 (when (> (length ref2) (length ref))
4668 (if (search-forward "\nchars: " nil t)
4669 (if (numberp (setq chars (ignore-errors (read cur))))
4675 (if (search-forward "\nlines: " nil t)
4676 (if (numberp (setq lines (ignore-errors (read cur))))
4682 (and (search-forward "\nxref: " nil t)
4683 (buffer-substring (match-end 0) (std11-field-end))))
4685 (when gnus-extra-headers
4686 (let ((extra gnus-extra-headers)
4690 (when (search-forward
4691 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4692 (push (cons (car extra)
4693 (buffer-substring (match-end 0)
4699 (if (and (search-forward "\ncontent-type: " nil t)
4701 (buffer-substring (match-end 0) (std11-field-end))))
4702 (mime-entity-set-content-type-internal
4703 header (mime-parse-Content-Type ctype)))
4704 (when (equal id ref)
4707 (when gnus-alter-header-function
4708 (funcall gnus-alter-header-function header)
4709 (setq id (mail-header-id header)
4710 ref (gnus-parent-id (mail-header-references header))))
4713 (gnus-dependencies-add-header
4714 header dependencies force-new))
4715 (push header headers))
4716 (goto-char (point-max))
4718 (nreverse headers)))))
4720 ;; Goes through the xover lines and returns a list of vectors
4721 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4722 force-new dependencies
4723 group also-fetch-heads)
4724 "Parse the news overview data in the server buffer, and return a
4725 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4726 ;; Get the Xref when the users reads the articles since most/some
4727 ;; NNTP servers do not include Xrefs when using XOVER.
4728 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4729 (let ((mail-parse-charset gnus-newsgroup-charset)
4730 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4731 (cur nntp-server-buffer)
4732 (dependencies (or dependencies gnus-newsgroup-dependencies))
4733 number headers header)
4735 (set-buffer nntp-server-buffer)
4736 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4737 ;; Allow the user to mangle the headers before parsing them.
4738 (gnus-run-hooks 'gnus-parse-headers-hook)
4739 (goto-char (point-min))
4742 (while (and sequence (not (eobp)))
4743 (setq number (read cur))
4744 (while (and sequence
4745 (< (car sequence) number))
4746 (setq sequence (cdr sequence)))
4748 (eq number (car sequence))
4750 (setq sequence (cdr sequence))
4751 (setq header (inline
4752 (gnus-nov-parse-line
4753 number dependencies force-new))))
4754 (push header headers))
4757 (gnus-error 4 "Strange nov line (%d)"
4758 (count-lines (point-min) (point)))))
4760 ;; A common bug in inn is that if you have posted an article and
4761 ;; then retrieves the active file, it will answer correctly --
4762 ;; the new article is included. However, a NOV entry for the
4763 ;; article may not have been generated yet, so this may fail.
4764 ;; We work around this problem by retrieving the last few
4765 ;; headers using HEAD.
4766 (if (or (not also-fetch-heads)
4768 ;; We (probably) got all the headers.
4770 (let ((gnus-nov-is-evil t))
4773 (gnus-retrieve-parsed-headers sequence group)
4776 (defun gnus-article-get-xrefs ()
4777 "Fill in the Xref value in `gnus-current-headers', if necessary.
4778 This is meant to be called in `gnus-article-internal-prepare-hook'."
4779 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4780 gnus-current-headers)))
4781 (or (not gnus-use-cross-reference)
4783 (and (mail-header-xref headers)
4784 (not (string= (mail-header-xref headers) "")))
4785 (let ((case-fold-search t)
4788 (nnheader-narrow-to-headers)
4789 (goto-char (point-min))
4790 (when (or (and (eq (downcase (char-after)) ?x)
4791 (looking-at "Xref:"))
4792 (search-forward "\nXref:" nil t))
4793 (goto-char (1+ (match-end 0)))
4794 (setq xref (buffer-substring (point)
4795 (progn (end-of-line) (point))))
4796 (mail-header-set-xref headers xref)))))))
4798 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4799 "Find article ID and insert the summary line for that article.
4800 OLD-HEADER can either be a header or a line number to insert
4801 the subject line on."
4802 (let* ((line (and (numberp old-header) old-header))
4803 (old-header (and (vectorp old-header) old-header))
4804 (header (cond ((and old-header use-old-header)
4807 (gnus-number-to-header id))
4808 (gnus-number-to-header id))
4810 (gnus-read-header id))))
4811 (number (and (numberp id) id))
4814 ;; Rebuild the thread that this article is part of and go to the
4815 ;; article we have fetched.
4816 (when (and (not gnus-show-threads)
4819 (setq d (gnus-data-find (mail-header-number old-header))))
4820 (goto-char (gnus-data-pos d))
4823 (- (gnus-point-at-bol)
4825 (1+ (gnus-point-at-eol))
4826 (gnus-delete-line))))))
4828 (mail-header-set-number header (mail-header-number old-header)))
4829 (setq gnus-newsgroup-sparse
4830 (delq (setq number (mail-header-number header))
4831 gnus-newsgroup-sparse))
4832 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4833 (push number gnus-newsgroup-limit)
4834 (gnus-rebuild-thread (mail-header-id header) line)
4835 (gnus-summary-goto-subject number nil t))
4836 (when (and (numberp number)
4838 ;; We have to update the boundaries even if we can't fetch the
4839 ;; article if ID is a number -- so that the next `P' or `N'
4840 ;; command will fetch the previous (or next) article even
4841 ;; if the one we tried to fetch this time has been canceled.
4842 (when (> number gnus-newsgroup-end)
4843 (setq gnus-newsgroup-end number))
4844 (when (< number gnus-newsgroup-begin)
4845 (setq gnus-newsgroup-begin number))
4846 (setq gnus-newsgroup-unselected
4847 (delq number gnus-newsgroup-unselected)))
4848 ;; Report back a success?
4849 (and header (mail-header-number header))))
4851 ;;; Process/prefix in the summary buffer
4853 (defun gnus-summary-work-articles (n)
4854 "Return a list of articles to be worked upon.
4855 The prefix argument, the list of process marked articles, and the
4856 current article will be taken into consideration."
4858 (set-buffer gnus-summary-buffer)
4861 ;; A numerical prefix has been given.
4862 (setq n (prefix-numeric-value n))
4863 (let ((backward (< n 0))
4864 (n (abs (prefix-numeric-value n)))
4869 (push (setq article (gnus-summary-article-number))
4872 (gnus-summary-find-prev nil article)
4873 (gnus-summary-find-next nil article)))
4875 (nreverse articles)))
4876 ((and (gnus-region-active-p) (mark))
4877 (message "region active")
4878 ;; Work on the region between point and mark.
4879 (let ((max (max (point) (mark)))
4882 (goto-char (min (point) (mark)))
4885 (push (setq article (gnus-summary-article-number)) articles)
4886 (gnus-summary-find-next nil article)
4888 (nreverse articles))))
4889 (gnus-newsgroup-processable
4890 ;; There are process-marked articles present.
4891 ;; Save current state.
4892 (gnus-summary-save-process-mark)
4894 (reverse gnus-newsgroup-processable))
4896 ;; Just return the current article.
4897 (list (gnus-summary-article-number))))))
4899 (defmacro gnus-summary-iterate (arg &rest forms)
4900 "Iterate over the process/prefixed articles and do FORMS.
4901 ARG is the interactive prefix given to the command. FORMS will be
4902 executed with point over the summary line of the articles."
4903 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4904 `(let ((,articles (gnus-summary-work-articles ,arg)))
4906 (gnus-summary-goto-subject (car ,articles))
4910 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4911 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4913 (defun gnus-summary-save-process-mark ()
4914 "Push the current set of process marked articles on the stack."
4916 (push (copy-sequence gnus-newsgroup-processable)
4917 gnus-newsgroup-process-stack))
4919 (defun gnus-summary-kill-process-mark ()
4920 "Push the current set of process marked articles on the stack and unmark."
4922 (gnus-summary-save-process-mark)
4923 (gnus-summary-unmark-all-processable))
4925 (defun gnus-summary-yank-process-mark ()
4926 "Pop the last process mark state off the stack and restore it."
4928 (unless gnus-newsgroup-process-stack
4929 (error "Empty mark stack"))
4930 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4932 (defun gnus-summary-process-mark-set (set)
4933 "Make SET into the current process marked articles."
4934 (gnus-summary-unmark-all-processable)
4936 (gnus-summary-set-process-mark (pop set))))
4938 ;;; Searching and stuff
4940 (defun gnus-summary-search-group (&optional backward use-level)
4941 "Search for next unread newsgroup.
4942 If optional argument BACKWARD is non-nil, search backward instead."
4944 (set-buffer gnus-group-buffer)
4945 (when (gnus-group-search-forward
4946 backward nil (if use-level (gnus-group-group-level) nil))
4947 (gnus-group-group-name))))
4949 (defun gnus-summary-best-group (&optional exclude-group)
4950 "Find the name of the best unread group.
4951 If EXCLUDE-GROUP, do not go to this group."
4953 (set-buffer gnus-group-buffer)
4955 (gnus-group-best-unread-group exclude-group))))
4957 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4958 (if backward (gnus-summary-find-prev)
4959 (let* ((dummy (gnus-summary-article-intangible-p))
4960 (article (or article (gnus-summary-article-number)))
4961 (arts (gnus-data-find-list article))
4963 (when (and (not dummy)
4964 (or (not gnus-summary-check-current)
4966 (not (gnus-data-unread-p (car arts)))))
4967 (setq arts (cdr arts)))
4972 (when (or (and undownloaded
4973 (eq gnus-undownloaded-mark
4974 (gnus-data-mark (car arts))))
4975 (gnus-data-unread-p (car arts)))
4976 (setq result (car arts)
4978 (setq arts (cdr arts)))
4981 (goto-char (gnus-data-pos result))
4982 (gnus-data-number result)))))
4984 (defun gnus-summary-find-prev (&optional unread article)
4985 (let* ((eobp (eobp))
4986 (article (or article (gnus-summary-article-number)))
4987 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4989 (when (and (not eobp)
4990 (or (not gnus-summary-check-current)
4992 (not (gnus-data-unread-p (car arts)))))
4993 (setq arts (cdr arts)))
4998 (when (gnus-data-unread-p (car arts))
4999 (setq result (car arts)
5001 (setq arts (cdr arts)))
5004 (goto-char (gnus-data-pos result))
5005 (gnus-data-number result))))
5007 (defun gnus-summary-find-subject (subject &optional unread backward article)
5008 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5009 (article (or article (gnus-summary-article-number)))
5010 (articles (gnus-data-list backward))
5011 (arts (gnus-data-find-list article articles))
5013 (when (or (not gnus-summary-check-current)
5015 (not (gnus-data-unread-p (car arts))))
5016 (setq arts (cdr arts)))
5018 (and (or (not unread)
5019 (gnus-data-unread-p (car arts)))
5020 (vectorp (gnus-data-header (car arts)))
5022 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5023 (setq result (car arts)
5025 (setq arts (cdr arts)))
5027 (goto-char (gnus-data-pos result))
5028 (gnus-data-number result))))
5030 (defun gnus-summary-search-forward (&optional unread subject backward)
5031 "Search forward for an article.
5032 If UNREAD, look for unread articles. If SUBJECT, look for
5033 articles with that subject. If BACKWARD, search backward instead."
5034 (cond (subject (gnus-summary-find-subject subject unread backward))
5035 (backward (gnus-summary-find-prev unread))
5036 (t (gnus-summary-find-next unread))))
5038 (defun gnus-recenter (&optional n)
5039 "Center point in window and redisplay frame.
5040 Also do horizontal recentering."
5042 (when (and gnus-auto-center-summary
5043 (not (eq gnus-auto-center-summary 'vertical)))
5044 (gnus-horizontal-recenter))
5047 (defun gnus-summary-recenter ()
5048 "Center point in the summary window.
5049 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5050 displayed, no centering will be performed."
5051 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5052 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5053 (let* ((top (cond ((< (window-height) 4) 0)
5054 ((< (window-height) 7) 1)
5055 (t (if (numberp gnus-auto-center-summary)
5056 gnus-auto-center-summary
5058 (height (1- (window-height)))
5059 (bottom (save-excursion (goto-char (point-max))
5060 (forward-line (- height))
5062 (window (get-buffer-window (current-buffer))))
5063 ;; The user has to want it.
5064 (when gnus-auto-center-summary
5065 (when (get-buffer-window gnus-article-buffer)
5066 ;; Only do recentering when the article buffer is displayed,
5067 ;; Set the window start to either `bottom', which is the biggest
5068 ;; possible valid number, or the second line from the top,
5069 ;; whichever is the least.
5071 window (min bottom (save-excursion
5072 (forward-line (- top)) (point)))))
5073 ;; Do horizontal recentering while we're at it.
5074 (when (and (get-buffer-window (current-buffer) t)
5075 (not (eq gnus-auto-center-summary 'vertical)))
5076 (let ((selected (selected-window)))
5077 (select-window (get-buffer-window (current-buffer) t))
5078 (gnus-summary-position-point)
5079 (gnus-horizontal-recenter)
5080 (select-window selected))))))
5082 (defun gnus-summary-jump-to-group (newsgroup)
5083 "Move point to NEWSGROUP in group mode buffer."
5084 ;; Keep update point of group mode buffer if visible.
5085 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5086 (save-window-excursion
5087 ;; Take care of tree window mode.
5088 (when (get-buffer-window gnus-group-buffer)
5089 (pop-to-buffer gnus-group-buffer))
5090 (gnus-group-jump-to-group newsgroup))
5092 ;; Take care of tree window mode.
5093 (if (get-buffer-window gnus-group-buffer)
5094 (pop-to-buffer gnus-group-buffer)
5095 (set-buffer gnus-group-buffer))
5096 (gnus-group-jump-to-group newsgroup))))
5098 ;; This function returns a list of article numbers based on the
5099 ;; difference between the ranges of read articles in this group and
5100 ;; the range of active articles.
5101 (defun gnus-list-of-unread-articles (group)
5102 (let* ((read (gnus-info-read (gnus-get-info group)))
5103 (active (or (gnus-active group) (gnus-activate-group group)))
5106 ;; If none are read, then all are unread.
5108 (setq first (car active))
5109 ;; If the range of read articles is a single range, then the
5110 ;; first unread article is the article after the last read
5111 ;; article. Sounds logical, doesn't it?
5112 (if (not (listp (cdr read)))
5113 (setq first (max (car active) (1+ (cdr read))))
5114 ;; `read' is a list of ranges.
5115 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5118 (setq first (car active)))
5121 (while (< first nlast)
5123 (setq first (1+ first))))
5124 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5125 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5126 (setq read (cdr read)))))
5127 ;; And add the last unread articles.
5128 (while (<= first last)
5130 (setq first (1+ first)))
5131 ;; Return the list of unread articles.
5132 (delq 0 (nreverse unread))))
5134 (defun gnus-list-of-read-articles (group)
5135 "Return a list of unread, unticked and non-dormant articles."
5136 (let* ((info (gnus-get-info group))
5137 (marked (gnus-info-marks info))
5138 (active (gnus-active group)))
5140 (gnus-set-difference
5141 (gnus-sorted-complement
5142 (gnus-uncompress-range active)
5143 (gnus-list-of-unread-articles group))
5145 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5146 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5148 ;; Various summary commands
5150 (defun gnus-summary-select-article-buffer ()
5151 "Reconfigure windows to show article buffer."
5153 (if (not (gnus-buffer-live-p gnus-article-buffer))
5154 (error "There is no article buffer for this summary buffer")
5155 (gnus-configure-windows 'article)
5156 (select-window (get-buffer-window gnus-article-buffer))))
5158 (defun gnus-summary-universal-argument (arg)
5159 "Perform any operation on all articles that are process/prefixed."
5161 (let ((articles (gnus-summary-work-articles arg))
5168 (substitute-command-keys
5169 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5172 (gnus-error 1 "Undefined key")
5175 (gnus-summary-goto-subject (setq article (pop articles)))
5176 (let (gnus-newsgroup-processable)
5177 (command-execute func))
5178 (gnus-summary-remove-process-mark article)))))
5179 (gnus-summary-position-point))
5181 (defun gnus-summary-toggle-truncation (&optional arg)
5182 "Toggle truncation of summary lines.
5183 With arg, turn line truncation on iff arg is positive."
5185 (setq truncate-lines
5186 (if (null arg) (not truncate-lines)
5187 (> (prefix-numeric-value arg) 0)))
5190 (defun gnus-summary-reselect-current-group (&optional all rescan)
5191 "Rescan the current newsgroup, exit and then reselect it.
5192 The prefix argument ALL means to select all articles."
5194 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5195 (error "Ephemeral groups can't be reselected"))
5196 (let ((current-subject (gnus-summary-article-number))
5197 (group gnus-newsgroup-name))
5199 (set-buffer gnus-group-buffer)
5200 ;; We have to adjust the point of group mode buffer because
5201 ;; point was moved to the next unread newsgroup by exiting.
5202 (gnus-summary-jump-to-group group)
5205 (gnus-group-get-new-news-this-group 1))))
5206 (setq gnus-newsgroup-begin nil)
5208 (gnus-group-read-group all t group)
5209 (gnus-summary-goto-subject current-subject nil t)))
5211 (defun gnus-summary-rescan-group (&optional all)
5212 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5214 (gnus-summary-reselect-current-group all t))
5216 (defun gnus-summary-update-info (&optional non-destructive)
5218 (let ((group gnus-newsgroup-name))
5220 (when gnus-newsgroup-kill-headers
5221 (setq gnus-newsgroup-killed
5222 (gnus-compress-sequence
5224 (gnus-set-sorted-intersection
5225 (gnus-uncompress-range gnus-newsgroup-killed)
5226 (setq gnus-newsgroup-unselected
5227 (sort gnus-newsgroup-unselected '<)))
5228 (setq gnus-newsgroup-unreads
5229 (sort gnus-newsgroup-unreads '<)))
5231 (unless (listp (cdr gnus-newsgroup-killed))
5232 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5233 (let ((headers gnus-newsgroup-headers))
5234 ;; Set the new ranges of read articles.
5236 (set-buffer gnus-group-buffer)
5237 (gnus-undo-force-boundary))
5238 (gnus-update-read-articles
5239 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5240 ;; Set the current article marks.
5241 (let ((gnus-newsgroup-scored
5242 (if (and (not gnus-save-score)
5243 (not non-destructive))
5245 gnus-newsgroup-scored)))
5247 (gnus-update-marks)))
5248 ;; Do the cross-ref thing.
5249 (when gnus-use-cross-reference
5250 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5251 ;; Do not switch windows but change the buffer to work.
5252 (set-buffer gnus-group-buffer)
5253 (unless (gnus-ephemeral-group-p group)
5254 (gnus-group-update-group group)))))))
5256 (defun gnus-summary-save-newsrc (&optional force)
5257 "Save the current number of read/marked articles in the dribble buffer.
5258 The dribble buffer will then be saved.
5259 If FORCE (the prefix), also save the .newsrc file(s)."
5261 (gnus-summary-update-info t)
5263 (gnus-save-newsrc-file)
5264 (gnus-dribble-save)))
5266 (defun gnus-summary-exit (&optional temporary)
5267 "Exit reading current newsgroup, and then return to group selection mode.
5268 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5270 (gnus-set-global-variables)
5271 (gnus-kill-save-kill-buffer)
5272 (gnus-async-halt-prefetch)
5273 (let* ((group gnus-newsgroup-name)
5274 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5277 (buf (current-buffer)))
5279 ;; Do adaptive scoring, and possibly save score files.
5280 (when gnus-newsgroup-adaptive
5281 (gnus-score-adaptive))
5282 (when gnus-use-scoring
5284 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5285 ;; If we have several article buffers, we kill them at exit.
5286 (unless gnus-single-article-buffer
5287 (gnus-kill-buffer gnus-original-article-buffer)
5288 (setq gnus-article-current nil))
5289 (when gnus-use-cache
5290 (gnus-cache-possibly-remove-articles)
5291 (gnus-cache-save-buffers))
5292 (gnus-async-prefetch-remove-group group)
5293 (when gnus-suppress-duplicates
5294 (gnus-dup-enter-articles))
5295 (when gnus-use-trees
5296 (gnus-tree-close group))
5297 ;; Remove entries for this group.
5298 (nnmail-purge-split-history (gnus-group-real-name group))
5299 ;; Make all changes in this group permanent.
5301 (gnus-run-hooks 'gnus-exit-group-hook)
5302 (gnus-summary-update-info))
5303 (gnus-close-group group)
5304 ;; Make sure where we were, and go to next newsgroup.
5305 (set-buffer gnus-group-buffer)
5307 (gnus-group-jump-to-group group))
5308 (gnus-run-hooks 'gnus-summary-exit-hook)
5309 (unless (or quit-config
5310 ;; If this group has disappeared from the summary
5311 ;; buffer, don't skip forwards.
5312 (not (string= group (gnus-group-group-name))))
5313 (gnus-group-next-unread-group 1))
5314 (setq group-point (point))
5317 ;; If we have several article buffers, we kill them at exit.
5318 (unless gnus-single-article-buffer
5319 (gnus-kill-buffer gnus-article-buffer)
5320 (gnus-kill-buffer gnus-original-article-buffer)
5321 (setq gnus-article-current nil))
5323 (if (not gnus-kill-summary-on-exit)
5324 (gnus-deaden-summary)
5325 ;; We set all buffer-local variables to nil. It is unclear why
5326 ;; this is needed, but if we don't, buffer-local variables are
5327 ;; not garbage-collected, it seems. This would the lead to en
5328 ;; ever-growing Emacs.
5329 (gnus-summary-clear-local-variables)
5330 (when (get-buffer gnus-article-buffer)
5331 (bury-buffer gnus-article-buffer))
5332 ;; We clear the global counterparts of the buffer-local
5333 ;; variables as well, just to be on the safe side.
5334 (set-buffer gnus-group-buffer)
5335 (gnus-summary-clear-local-variables)
5336 ;; Return to group mode buffer.
5337 (when (eq mode 'gnus-summary-mode)
5338 (gnus-kill-buffer buf)))
5339 (setq gnus-current-select-method gnus-select-method)
5340 (pop-to-buffer gnus-group-buffer)
5341 (if (not quit-config)
5343 (goto-char group-point)
5344 (gnus-configure-windows 'group 'force))
5345 (gnus-handle-ephemeral-exit quit-config))
5346 ;; Clear the current group name.
5348 (setq gnus-newsgroup-name nil)))))
5350 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5351 (defun gnus-summary-exit-no-update (&optional no-questions)
5352 "Quit reading current newsgroup without updating read article info."
5354 (let* ((group gnus-newsgroup-name)
5355 (quit-config (gnus-group-quit-config group)))
5356 (when (or no-questions
5358 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5359 (gnus-async-halt-prefetch)
5361 (delq 'gnus-summary-expire-articles
5362 (copy-list gnus-summary-prepare-exit-hook)))
5363 ;; If we have several article buffers, we kill them at exit.
5364 (unless gnus-single-article-buffer
5365 (gnus-kill-buffer gnus-article-buffer)
5366 (gnus-kill-buffer gnus-original-article-buffer)
5367 (setq gnus-article-current nil))
5368 (if (not gnus-kill-summary-on-exit)
5369 (gnus-deaden-summary)
5370 (gnus-close-group group)
5371 (gnus-summary-clear-local-variables)
5372 (set-buffer gnus-group-buffer)
5373 (gnus-summary-clear-local-variables)
5374 (when (get-buffer gnus-summary-buffer)
5375 (kill-buffer gnus-summary-buffer)))
5376 (unless gnus-single-article-buffer
5377 (setq gnus-article-current nil))
5378 (when gnus-use-trees
5379 (gnus-tree-close group))
5380 (gnus-async-prefetch-remove-group group)
5381 (when (get-buffer gnus-article-buffer)
5382 (bury-buffer gnus-article-buffer))
5383 ;; Return to the group buffer.
5384 (gnus-configure-windows 'group 'force)
5385 ;; Clear the current group name.
5386 (setq gnus-newsgroup-name nil)
5387 (when (equal (gnus-group-group-name) group)
5388 (gnus-group-next-unread-group 1))
5390 (gnus-handle-ephemeral-exit quit-config)))))
5392 (defun gnus-handle-ephemeral-exit (quit-config)
5393 "Handle movement when leaving an ephemeral group.
5394 The state which existed when entering the ephemeral is reset."
5395 (if (not (buffer-name (car quit-config)))
5396 (gnus-configure-windows 'group 'force)
5397 (set-buffer (car quit-config))
5398 (cond ((eq major-mode 'gnus-summary-mode)
5399 (gnus-set-global-variables))
5400 ((eq major-mode 'gnus-article-mode)
5402 ;; The `gnus-summary-buffer' variable may point
5403 ;; to the old summary buffer when using a single
5405 (unless (gnus-buffer-live-p gnus-summary-buffer)
5406 (set-buffer gnus-group-buffer))
5407 (set-buffer gnus-summary-buffer)
5408 (gnus-set-global-variables))))
5409 (if (or (eq (cdr quit-config) 'article)
5410 (eq (cdr quit-config) 'pick))
5412 ;; The current article may be from the ephemeral group
5413 ;; thus it is best that we reload this article
5414 (gnus-summary-show-article)
5415 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5416 (gnus-configure-windows 'pick 'force)
5417 (gnus-configure-windows (cdr quit-config) 'force)))
5418 (gnus-configure-windows (cdr quit-config) 'force))
5419 (when (eq major-mode 'gnus-summary-mode)
5420 (gnus-summary-next-subject 1 nil t)
5421 (gnus-summary-recenter)
5422 (gnus-summary-position-point))))
5424 (defun gnus-summary-preview-mime-message ()
5425 "MIME decode and play this message."
5427 (let ((gnus-break-pages nil)
5429 (gnus-summary-select-article gnus-show-all-headers t))
5430 (select-window (get-buffer-window gnus-article-buffer)))
5434 (defvar gnus-dead-summary-mode-map nil)
5436 (unless gnus-dead-summary-mode-map
5437 (setq gnus-dead-summary-mode-map (make-keymap))
5438 (suppress-keymap gnus-dead-summary-mode-map)
5439 (substitute-key-definition
5440 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5441 (let ((keys '("\C-d" "\r" "\177" [delete])))
5443 (define-key gnus-dead-summary-mode-map
5444 (pop keys) 'gnus-summary-wake-up-the-dead))))
5446 (defvar gnus-dead-summary-mode nil
5447 "Minor mode for Gnus summary buffers.")
5449 (defun gnus-dead-summary-mode (&optional arg)
5450 "Minor mode for Gnus summary buffers."
5452 (when (eq major-mode 'gnus-summary-mode)
5453 (make-local-variable 'gnus-dead-summary-mode)
5454 (setq gnus-dead-summary-mode
5455 (if (null arg) (not gnus-dead-summary-mode)
5456 (> (prefix-numeric-value arg) 0)))
5457 (when gnus-dead-summary-mode
5458 (gnus-add-minor-mode
5459 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5461 (defun gnus-deaden-summary ()
5462 "Make the current summary buffer into a dead summary buffer."
5463 ;; Kill any previous dead summary buffer.
5464 (when (and gnus-dead-summary
5465 (buffer-name gnus-dead-summary))
5467 (set-buffer gnus-dead-summary)
5468 (when gnus-dead-summary-mode
5469 (kill-buffer (current-buffer)))))
5470 ;; Make this the current dead summary.
5471 (setq gnus-dead-summary (current-buffer))
5472 (gnus-dead-summary-mode 1)
5473 (let ((name (buffer-name)))
5474 (when (string-match "Summary" name)
5476 (concat (substring name 0 (match-beginning 0)) "Dead "
5477 (substring name (match-beginning 0)))
5480 (defun gnus-kill-or-deaden-summary (buffer)
5481 "Kill or deaden the summary BUFFER."
5483 (when (and (buffer-name buffer)
5484 (not gnus-single-article-buffer))
5487 (gnus-kill-buffer gnus-article-buffer)
5488 (gnus-kill-buffer gnus-original-article-buffer)))
5489 (cond (gnus-kill-summary-on-exit
5490 (when (and gnus-use-trees
5491 (gnus-buffer-exists-p buffer))
5494 (gnus-tree-close gnus-newsgroup-name)))
5495 (gnus-kill-buffer buffer))
5496 ((gnus-buffer-exists-p buffer)
5499 (gnus-deaden-summary))))))
5501 (defun gnus-summary-wake-up-the-dead (&rest args)
5502 "Wake up the dead summary buffer."
5504 (gnus-dead-summary-mode -1)
5505 (let ((name (buffer-name)))
5506 (when (string-match "Dead " name)
5508 (concat (substring name 0 (match-beginning 0))
5509 (substring name (match-end 0)))
5511 (gnus-message 3 "This dead summary is now alive again"))
5513 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5514 (defun gnus-summary-fetch-faq (&optional faq-dir)
5515 "Fetch the FAQ for the current group.
5516 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5520 (when current-prefix-arg
5522 "Faq dir: " (and (listp gnus-group-faq-directory)
5523 (mapcar (lambda (file) (list file))
5524 gnus-group-faq-directory))))))
5525 (let (gnus-faq-buffer)
5526 (when (setq gnus-faq-buffer
5527 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5528 (gnus-configure-windows 'summary-faq))))
5530 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5531 (defun gnus-summary-describe-group (&optional force)
5532 "Describe the current newsgroup."
5534 (gnus-group-describe-group force gnus-newsgroup-name))
5536 (defun gnus-summary-describe-briefly ()
5537 "Describe summary mode commands briefly."
5539 (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")))
5541 ;; Walking around group mode buffer from summary mode.
5543 (defun gnus-summary-next-group (&optional no-article target-group backward)
5544 "Exit current newsgroup and then select next unread newsgroup.
5545 If prefix argument NO-ARTICLE is non-nil, no article is selected
5546 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5547 previous group instead."
5549 ;; Stop pre-fetching.
5550 (gnus-async-halt-prefetch)
5551 (let ((current-group gnus-newsgroup-name)
5552 (current-buffer (current-buffer))
5554 ;; First we semi-exit this group to update Xrefs and all variables.
5555 ;; We can't do a real exit, because the window conf must remain
5556 ;; the same in case the user is prompted for info, and we don't
5557 ;; want the window conf to change before that...
5558 (gnus-summary-exit t)
5559 (while (not entered)
5560 ;; Then we find what group we are supposed to enter.
5561 (set-buffer gnus-group-buffer)
5562 (gnus-group-jump-to-group current-group)
5565 (if (eq gnus-keep-same-level 'best)
5566 (gnus-summary-best-group gnus-newsgroup-name)
5567 (gnus-summary-search-group backward gnus-keep-same-level))))
5568 (if (not target-group)
5569 ;; There are no further groups, so we return to the group
5572 (gnus-message 5 "Returning to the group buffer")
5574 (when (gnus-buffer-live-p current-buffer)
5575 (set-buffer current-buffer)
5576 (gnus-summary-exit))
5577 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5578 ;; We try to enter the target group.
5579 (gnus-group-jump-to-group target-group)
5580 (let ((unreads (gnus-group-group-unread)))
5581 (if (and (or (eq t unreads)
5582 (and unreads (not (zerop unreads))))
5583 (gnus-summary-read-group
5584 target-group nil no-article
5585 (and (buffer-name current-buffer) current-buffer)
5588 (setq current-group target-group
5589 target-group nil)))))))
5591 (defun gnus-summary-prev-group (&optional no-article)
5592 "Exit current newsgroup and then select previous unread newsgroup.
5593 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5595 (gnus-summary-next-group no-article nil t))
5597 ;; Walking around summary lines.
5599 (defun gnus-summary-first-subject (&optional unread undownloaded)
5600 "Go to the first unread subject.
5601 If UNREAD is non-nil, go to the first unread article.
5602 Returns the article selected or nil if there are no unread articles."
5607 ((null gnus-newsgroup-data)
5608 (gnus-message 3 "No articles in the group")
5610 ;; Pick the first article.
5612 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5613 (gnus-data-number (car gnus-newsgroup-data)))
5614 ;; No unread articles.
5615 ((null gnus-newsgroup-unreads)
5616 (gnus-message 3 "No more unread articles")
5618 ;; Find the first unread article.
5620 (let ((data gnus-newsgroup-data))
5622 (and (not (and undownloaded
5623 (eq gnus-undownloaded-mark
5624 (gnus-data-mark (car data)))))
5625 (not (gnus-data-unread-p (car data)))))
5626 (setq data (cdr data)))
5628 (goto-char (gnus-data-pos (car data)))
5629 (gnus-data-number (car data))))))
5630 (gnus-summary-position-point)))
5632 (defun gnus-summary-next-subject (n &optional unread dont-display)
5633 "Go to next N'th summary line.
5634 If N is negative, go to the previous N'th subject line.
5635 If UNREAD is non-nil, only unread articles are selected.
5636 The difference between N and the actual number of steps taken is
5639 (let ((backward (< n 0))
5643 (gnus-summary-find-prev unread)
5644 (gnus-summary-find-next unread)))
5645 (gnus-summary-show-thread)
5648 (gnus-message 7 "No more%s articles"
5649 (if unread " unread" "")))
5650 (unless dont-display
5651 (gnus-summary-recenter)
5652 (gnus-summary-position-point))
5655 (defun gnus-summary-next-unread-subject (n)
5656 "Go to next N'th unread summary line."
5658 (gnus-summary-next-subject n t))
5660 (defun gnus-summary-prev-subject (n &optional unread)
5661 "Go to previous N'th summary line.
5662 If optional argument UNREAD is non-nil, only unread article is selected."
5664 (gnus-summary-next-subject (- n) unread))
5666 (defun gnus-summary-prev-unread-subject (n)
5667 "Go to previous N'th unread summary line."
5669 (gnus-summary-next-subject (- n) t))
5671 (defun gnus-summary-goto-subject (article &optional force silent)
5672 "Go the subject line of ARTICLE.
5673 If FORCE, also allow jumping to articles not currently shown."
5674 (interactive "nArticle number: ")
5676 (data (gnus-data-find article)))
5677 ;; We read in the article if we have to.
5680 (gnus-summary-insert-subject
5682 (if (or (numberp force) (vectorp force)) force)
5684 (setq data (gnus-data-find article)))
5689 (gnus-message 3 "Can't find article %d" article))
5691 (goto-char (gnus-data-pos data))
5692 (gnus-summary-position-point)
5695 ;; Walking around summary lines with displaying articles.
5697 (defun gnus-summary-expand-window (&optional arg)
5698 "Make the summary buffer take up the entire Emacs frame.
5699 Given a prefix, will force an `article' buffer configuration."
5702 (gnus-configure-windows 'article 'force)
5703 (gnus-configure-windows 'summary 'force)))
5705 (defun gnus-summary-display-article (article &optional all-header)
5706 "Display ARTICLE in article buffer."
5707 (gnus-set-global-variables)
5711 (if gnus-summary-display-article-function
5712 (funcall gnus-summary-display-article-function article all-header)
5713 (gnus-article-prepare article all-header))
5714 (gnus-run-hooks 'gnus-select-article-hook)
5715 (when (and gnus-current-article
5716 (not (zerop gnus-current-article)))
5717 (gnus-summary-goto-subject gnus-current-article))
5718 (gnus-summary-recenter)
5719 (when (and gnus-use-trees gnus-show-threads)
5720 (gnus-possibly-generate-tree article)
5721 (gnus-highlight-selected-tree article))
5722 ;; Successfully display article.
5723 (gnus-article-set-window-start
5724 (cdr (assq article gnus-newsgroup-bookmarks))))))
5726 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5727 "Select the current article.
5728 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5729 non-nil, the article will be re-fetched even if it already present in
5730 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5732 ;; Make sure we are in the summary buffer to work around bbdb bug.
5733 (unless (eq major-mode 'gnus-summary-mode)
5734 (set-buffer gnus-summary-buffer))
5735 (let ((article (or article (gnus-summary-article-number)))
5736 (all-headers (not (not all-headers))) ;Must be T or NIL.
5737 gnus-summary-display-article-function
5740 (gnus-summary-article-pseudo-p article)
5741 (error "This is a pseudo-article"))
5744 (set-buffer gnus-summary-buffer)
5745 (if (or (and gnus-single-article-buffer
5746 (or (null gnus-current-article)
5747 (null gnus-article-current)
5748 (null (get-buffer gnus-article-buffer))
5749 (not (eq article (cdr gnus-article-current)))
5750 (not (equal (car gnus-article-current)
5751 gnus-newsgroup-name))))
5752 (and (not gnus-single-article-buffer)
5753 (or (null gnus-current-article)
5754 (not (eq gnus-current-article article))))
5756 ;; The requested article is different from the current article.
5758 (gnus-summary-display-article article all-headers)
5760 (when (or all-headers gnus-show-all-headers)
5761 (gnus-article-show-all-headers)))
5762 (when (or all-headers gnus-show-all-headers)
5763 (gnus-article-show-all-headers))
5766 (gnus-article-set-window-start
5767 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5769 (defun gnus-summary-set-current-mark (&optional current-mark)
5770 "Obsolete function."
5773 (defun gnus-summary-next-article (&optional unread subject backward push)
5774 "Select the next article.
5775 If UNREAD, only unread articles are selected.
5776 If SUBJECT, only articles with SUBJECT are selected.
5777 If BACKWARD, the previous article is selected instead of the next."
5780 ;; Is there such an article?
5781 ((and (gnus-summary-search-forward unread subject backward)
5782 (or (gnus-summary-display-article (gnus-summary-article-number))
5783 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5784 (gnus-summary-position-point))
5785 ;; If not, we try the first unread, if that is wanted.
5787 gnus-auto-select-same
5788 (gnus-summary-first-unread-article))
5789 (gnus-summary-position-point)
5790 (gnus-message 6 "Wrapped"))
5791 ;; Try to get next/previous article not displayed in this group.
5792 ((and gnus-auto-extend-newsgroup
5793 (not unread) (not subject))
5794 (gnus-summary-goto-article
5795 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5796 nil (count-lines (point-min) (point))))
5797 ;; Go to next/previous group.
5799 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5800 (gnus-summary-jump-to-group gnus-newsgroup-name))
5801 (let ((cmd last-command-char)
5804 (set-buffer gnus-group-buffer)
5807 (if (eq gnus-keep-same-level 'best)
5808 (gnus-summary-best-group gnus-newsgroup-name)
5809 (gnus-summary-search-group backward gnus-keep-same-level))))
5810 ;; For some reason, the group window gets selected. We change
5812 (select-window (get-buffer-window (current-buffer)))
5813 ;; Select next unread newsgroup automagically.
5815 ((or (not gnus-auto-select-next)
5817 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5818 ((or (eq gnus-auto-select-next 'quietly)
5819 (and (eq gnus-auto-select-next 'slightly-quietly)
5821 (and (eq gnus-auto-select-next 'almost-quietly)
5822 (gnus-summary-last-article-p)))
5824 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5826 (gnus-message 7 "No more%s articles (%s)..."
5827 (if unread " unread" "")
5828 (if group (concat "selecting " group)
5830 (gnus-summary-next-group nil group backward)))
5832 (when (gnus-key-press-event-p last-input-event)
5833 (gnus-summary-walk-group-buffer
5834 gnus-newsgroup-name cmd unread backward point))))))))
5836 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5837 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5838 (?\C-p (gnus-group-prev-unread-group 1))))
5839 (cursor-in-echo-area t)
5840 keve key group ended)
5842 (set-buffer gnus-group-buffer)
5845 (if (eq gnus-keep-same-level 'best)
5846 (gnus-summary-best-group gnus-newsgroup-name)
5847 (gnus-summary-search-group backward gnus-keep-same-level))))
5850 5 "No more%s articles%s" (if unread " unread" "")
5852 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5853 (format " (Type %s for %s [%s])"
5854 (single-key-description cmd) group
5855 (car (gnus-gethash group gnus-newsrc-hashtb)))
5856 (format " (Type %s to exit %s)"
5857 (single-key-description cmd)
5858 gnus-newsgroup-name)))
5859 ;; Confirm auto selection.
5860 (setq key (car (setq keve (gnus-read-event-char))))
5863 ((assq key keystrokes)
5864 (let ((obuf (current-buffer)))
5865 (switch-to-buffer gnus-group-buffer)
5867 (gnus-group-jump-to-group group))
5868 (eval (cadr (assq key keystrokes)))
5869 (setq group (gnus-group-group-name))
5870 (switch-to-buffer obuf))
5874 (gnus-ephemeral-group-p gnus-newsgroup-name))
5876 (gnus-summary-next-group nil group backward)))
5878 (push (cdr keve) unread-command-events))))))
5880 (defun gnus-summary-next-unread-article ()
5881 "Select unread article after current one."
5883 (gnus-summary-next-article
5884 (or (not (eq gnus-summary-goto-unread 'never))
5885 (gnus-summary-last-article-p (gnus-summary-article-number)))
5886 (and gnus-auto-select-same
5887 (gnus-summary-article-subject))))
5889 (defun gnus-summary-prev-article (&optional unread subject)
5890 "Select the article after the current one.
5891 If UNREAD is non-nil, only unread articles are selected."
5893 (gnus-summary-next-article unread subject t))
5895 (defun gnus-summary-prev-unread-article ()
5896 "Select unread article before current one."
5898 (gnus-summary-prev-article
5899 (or (not (eq gnus-summary-goto-unread 'never))
5900 (gnus-summary-first-article-p (gnus-summary-article-number)))
5901 (and gnus-auto-select-same
5902 (gnus-summary-article-subject))))
5904 (defun gnus-summary-next-page (&optional lines circular)
5905 "Show next page of the selected article.
5906 If at the end of the current article, select the next article.
5907 LINES says how many lines should be scrolled up.
5909 If CIRCULAR is non-nil, go to the start of the article instead of
5910 selecting the next article when reaching the end of the current
5913 (setq gnus-summary-buffer (current-buffer))
5914 (gnus-set-global-variables)
5915 (let ((article (gnus-summary-article-number))
5916 (article-window (get-buffer-window gnus-article-buffer t))
5918 ;; If the buffer is empty, we have no article.
5920 (error "No article to select"))
5921 (gnus-configure-windows 'article)
5922 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5923 (if (and (eq gnus-summary-goto-unread 'never)
5924 (not (gnus-summary-last-article-p article)))
5925 (gnus-summary-next-article)
5926 (gnus-summary-next-unread-article))
5927 (if (or (null gnus-current-article)
5928 (null gnus-article-current)
5929 (/= article (cdr gnus-article-current))
5930 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5931 ;; Selected subject is different from current article's.
5932 (gnus-summary-display-article article)
5933 (when article-window
5934 (gnus-eval-in-buffer-window gnus-article-buffer
5935 (setq endp (gnus-article-next-page lines)))
5938 (gnus-summary-beginning-of-article))
5940 (gnus-message 3 "End of message"))
5942 (if (and (eq gnus-summary-goto-unread 'never)
5943 (not (gnus-summary-last-article-p article)))
5944 (gnus-summary-next-article)
5945 (gnus-summary-next-unread-article))))))))
5946 (gnus-summary-recenter)
5947 (gnus-summary-position-point)))
5949 (defun gnus-summary-prev-page (&optional lines move)
5950 "Show previous page of selected article.
5951 Argument LINES specifies lines to be scrolled down.
5952 If MOVE, move to the previous unread article if point is at
5953 the beginning of the buffer."
5955 (let ((article (gnus-summary-article-number))
5956 (article-window (get-buffer-window gnus-article-buffer t))
5958 (gnus-configure-windows 'article)
5959 (if (or (null gnus-current-article)
5960 (null gnus-article-current)
5961 (/= article (cdr gnus-article-current))
5962 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5963 ;; Selected subject is different from current article's.
5964 (gnus-summary-display-article article)
5965 (gnus-summary-recenter)
5966 (when article-window
5967 (gnus-eval-in-buffer-window gnus-article-buffer
5968 (setq endp (gnus-article-prev-page lines)))
5969 (when (and move endp)
5971 (gnus-message 3 "Beginning of message"))
5973 (if (and (eq gnus-summary-goto-unread 'never)
5974 (not (gnus-summary-first-article-p article)))
5975 (gnus-summary-prev-article)
5976 (gnus-summary-prev-unread-article))))))))
5977 (gnus-summary-position-point))
5979 (defun gnus-summary-prev-page-or-article (&optional lines)
5980 "Show previous page of selected article.
5981 Argument LINES specifies lines to be scrolled down.
5982 If at the beginning of the article, go to the next article."
5984 (gnus-summary-prev-page lines t))
5986 (defun gnus-summary-scroll-up (lines)
5987 "Scroll up (or down) one line current article.
5988 Argument LINES specifies lines to be scrolled up (or down if negative)."
5990 (gnus-configure-windows 'article)
5991 (gnus-summary-show-thread)
5992 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5993 (gnus-eval-in-buffer-window gnus-article-buffer
5995 (when (gnus-article-next-page lines)
5996 (gnus-message 3 "End of message")))
5998 (gnus-article-prev-page (- lines))))))
5999 (gnus-summary-recenter)
6000 (gnus-summary-position-point))
6002 (defun gnus-summary-scroll-down (lines)
6003 "Scroll down (or up) one line current article.
6004 Argument LINES specifies lines to be scrolled down (or up if negative)."
6006 (gnus-summary-scroll-up (- lines)))
6008 (defun gnus-summary-next-same-subject ()
6009 "Select next article which has the same subject as current one."
6011 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6013 (defun gnus-summary-prev-same-subject ()
6014 "Select previous article which has the same subject as current one."
6016 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6018 (defun gnus-summary-next-unread-same-subject ()
6019 "Select next unread article which has the same subject as current one."
6021 (gnus-summary-next-article t (gnus-summary-article-subject)))
6023 (defun gnus-summary-prev-unread-same-subject ()
6024 "Select previous unread article which has the same subject as current one."
6026 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6028 (defun gnus-summary-first-unread-article ()
6029 "Select the first unread article.
6030 Return nil if there are no unread articles."
6033 (when (gnus-summary-first-subject t)
6034 (gnus-summary-show-thread)
6035 (gnus-summary-first-subject t)
6036 (gnus-summary-display-article (gnus-summary-article-number)))
6037 (gnus-summary-position-point)))
6039 (defun gnus-summary-first-unread-subject ()
6040 "Place the point on the subject line of the first unread article.
6041 Return nil if there are no unread articles."
6044 (when (gnus-summary-first-subject t)
6045 (gnus-summary-show-thread)
6046 (gnus-summary-first-subject t))
6047 (gnus-summary-position-point)))
6049 (defun gnus-summary-first-article ()
6050 "Select the first article.
6051 Return nil if there are no articles."
6054 (when (gnus-summary-first-subject)
6055 (gnus-summary-show-thread)
6056 (gnus-summary-first-subject)
6057 (gnus-summary-display-article (gnus-summary-article-number)))
6058 (gnus-summary-position-point)))
6060 (defun gnus-summary-best-unread-article ()
6061 "Select the unread article with the highest score."
6063 (let ((best -1000000)
6064 (data gnus-newsgroup-data)
6067 (and (gnus-data-unread-p (car data))
6069 (gnus-summary-article-score (gnus-data-number (car data))))
6072 article (gnus-data-number (car data))))
6073 (setq data (cdr data)))
6076 (gnus-summary-goto-article article)
6077 (error "No unread articles"))
6078 (gnus-summary-position-point))))
6080 (defun gnus-summary-last-subject ()
6081 "Go to the last displayed subject line in the group."
6082 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6084 (gnus-summary-goto-subject article))))
6086 (defun gnus-summary-goto-article (article &optional all-headers force)
6087 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6088 If ALL-HEADERS is non-nil, no header lines are hidden.
6089 If FORCE, go to the article even if it isn't displayed. If FORCE
6090 is a number, it is the line the article is to be displayed on."
6094 "Article number or Message-ID: "
6095 (mapcar (lambda (number) (list (int-to-string number)))
6096 gnus-newsgroup-limit))
6100 (if (and (stringp article)
6101 (string-match "@" article))
6102 (gnus-summary-refer-article article)
6103 (when (stringp article)
6104 (setq article (string-to-number article)))
6105 (if (gnus-summary-goto-subject article force)
6106 (gnus-summary-display-article article all-headers)
6107 (gnus-message 4 "Couldn't go to article %s" article) nil))
6108 (gnus-summary-position-point)))
6110 (defun gnus-summary-goto-last-article ()
6111 "Go to the previously read article."
6114 (when gnus-last-article
6115 (gnus-summary-goto-article gnus-last-article nil t))
6116 (gnus-summary-position-point)))
6118 (defun gnus-summary-pop-article (number)
6119 "Pop one article off the history and go to the previous.
6120 NUMBER articles will be popped off."
6123 (setq gnus-newsgroup-history
6124 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6126 (gnus-summary-goto-article (car to) nil t)
6127 (error "Article history empty")))
6128 (gnus-summary-position-point))
6130 ;; Summary commands and functions for limiting the summary buffer.
6132 (defun gnus-summary-limit-to-articles (n)
6133 "Limit the summary buffer to the next N articles.
6134 If not given a prefix, use the process marked articles instead."
6137 (let ((articles (gnus-summary-work-articles n)))
6138 (setq gnus-newsgroup-processable nil)
6139 (gnus-summary-limit articles))
6140 (gnus-summary-position-point)))
6142 (defun gnus-summary-pop-limit (&optional total)
6143 "Restore the previous limit.
6144 If given a prefix, remove all limits."
6147 (setq gnus-newsgroup-limits
6148 (list (mapcar (lambda (h) (mail-header-number h))
6149 gnus-newsgroup-headers))))
6150 (unless gnus-newsgroup-limits
6151 (error "No limit to pop"))
6153 (gnus-summary-limit nil 'pop)
6154 (gnus-summary-position-point)))
6156 (defun gnus-summary-limit-to-subject (subject &optional header)
6157 "Limit the summary buffer to articles that have subjects that match a regexp."
6158 (interactive "sLimit to subject (regexp): ")
6160 (setq header "subject"))
6161 (when (not (equal "" subject))
6163 (let ((articles (gnus-summary-find-matching
6164 (or header "subject") subject 'all)))
6166 (error "Found no matches for \"%s\"" subject))
6167 (gnus-summary-limit articles))
6168 (gnus-summary-position-point))))
6170 (defun gnus-summary-limit-to-author (from)
6171 "Limit the summary buffer to articles that have authors that match a regexp."
6172 (interactive "sLimit to author (regexp): ")
6173 (gnus-summary-limit-to-subject from "from"))
6175 (defun gnus-summary-limit-to-age (age &optional younger-p)
6176 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6177 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6178 articles that are younger than AGE days."
6179 (interactive "nLimit to articles older than (in days): \nP")
6181 (let ((data gnus-newsgroup-data)
6182 (cutoff (days-to-time age))
6183 articles d date is-younger)
6184 (while (setq d (pop data))
6185 (when (and (vectorp (gnus-data-header d))
6186 (setq date (mail-header-date (gnus-data-header d))))
6187 (setq is-younger (time-less-p
6188 (time-since (date-to-time date))
6193 (push (gnus-data-number d) articles))))
6194 (gnus-summary-limit (nreverse articles)))
6195 (gnus-summary-position-point)))
6197 (defun gnus-summary-limit-to-extra (header regexp)
6198 "Limit the summary buffer to articles that match an 'extra' header."
6202 (gnus-completing-read
6203 (symbol-name (car gnus-extra-headers))
6204 "Limit extra header:"
6206 (cons (symbol-name x) x))
6211 (read-string (format "Limit to header %s (regexp): " header)))))
6212 (when (not (equal "" regexp))
6214 (let ((articles (gnus-summary-find-matching
6215 (cons 'extra header) regexp 'all)))
6217 (error "Found no matches for \"%s\"" regexp))
6218 (gnus-summary-limit articles))
6219 (gnus-summary-position-point))))
6221 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6223 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6225 (defun gnus-summary-limit-to-unread (&optional all)
6226 "Limit the summary buffer to articles that are not marked as read.
6227 If ALL is non-nil, limit strictly to unread articles."
6230 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6231 (gnus-summary-limit-to-marks
6232 ;; Concat all the marks that say that an article is read and have
6234 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6235 gnus-killed-mark gnus-kill-file-mark
6236 gnus-low-score-mark gnus-expirable-mark
6237 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6238 gnus-duplicate-mark gnus-souped-mark)
6241 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6242 (make-obsolete 'gnus-summary-delete-marked-with
6243 'gnus-summary-limit-exlude-marks)
6245 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6246 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6247 If REVERSE, limit the summary buffer to articles that are marked
6248 with MARKS. MARKS can either be a string of marks or a list of marks.
6249 Returns how many articles were removed."
6250 (interactive "sMarks: ")
6251 (gnus-summary-limit-to-marks marks t))
6253 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6254 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6255 If REVERSE (the prefix), limit the summary buffer to articles that are
6256 not marked with MARKS. MARKS can either be a string of marks or a
6258 Returns how many articles were removed."
6259 (interactive "sMarks: \nP")
6261 (let ((data gnus-newsgroup-data)
6262 (marks (if (listp marks) marks
6263 (append marks nil))) ; Transform to list.
6266 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6267 (memq (gnus-data-mark (car data)) marks))
6268 (push (gnus-data-number (car data)) articles))
6269 (setq data (cdr data)))
6270 (gnus-summary-limit articles))
6271 (gnus-summary-position-point)))
6273 (defun gnus-summary-limit-to-score (&optional score)
6274 "Limit to articles with score at or above SCORE."
6276 (setq score (if score
6277 (prefix-numeric-value score)
6278 (or gnus-summary-default-score 0)))
6279 (let ((data gnus-newsgroup-data)
6282 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6284 (push (gnus-data-number (car data)) articles))
6285 (setq data (cdr data)))
6287 (gnus-summary-limit articles)
6288 (gnus-summary-position-point))))
6290 (defun gnus-summary-limit-include-thread (id)
6291 "Display all the hidden articles that in the current thread."
6292 (interactive (list (mail-header-id (gnus-summary-article-header))))
6293 (let ((articles (gnus-articles-in-thread
6294 (gnus-id-to-thread (gnus-root-id id)))))
6296 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6297 (gnus-summary-position-point))))
6299 (defun gnus-summary-limit-include-dormant ()
6300 "Display all the hidden articles that are marked as dormant.
6301 Note that this command only works on a subset of the articles currently
6302 fetched for this group."
6304 (unless gnus-newsgroup-dormant
6305 (error "There are no dormant articles in this group"))
6307 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6308 (gnus-summary-position-point)))
6310 (defun gnus-summary-limit-exclude-dormant ()
6311 "Hide all dormant articles."
6314 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6315 (gnus-summary-position-point)))
6317 (defun gnus-summary-limit-exclude-childless-dormant ()
6318 "Hide all dormant articles that have no children."
6320 (let ((data (gnus-data-list t))
6321 articles d children)
6322 ;; Find all articles that are either not dormant or have
6324 (while (setq d (pop data))
6325 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6327 (gnus-article-children (gnus-data-number d)))
6330 (when (memq (car children) articles)
6335 (push (gnus-data-number d) articles)))
6338 (gnus-summary-limit articles)
6339 (gnus-summary-position-point))))
6341 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6342 "Mark all unread excluded articles as read.
6343 If ALL, mark even excluded ticked and dormants as read."
6345 (let ((articles (gnus-sorted-complement
6347 (mapcar (lambda (h) (mail-header-number h))
6348 gnus-newsgroup-headers)
6350 (sort gnus-newsgroup-limit '<)))
6352 (setq gnus-newsgroup-unreads
6353 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6355 (setq gnus-newsgroup-dormant nil
6356 gnus-newsgroup-marked nil
6357 gnus-newsgroup-reads
6359 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6360 gnus-newsgroup-reads))
6361 (while (setq article (pop articles))
6362 (unless (or (memq article gnus-newsgroup-dormant)
6363 (memq article gnus-newsgroup-marked))
6364 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6366 (defun gnus-summary-limit (articles &optional pop)
6368 ;; We pop the previous limit off the stack and use that.
6369 (setq articles (car gnus-newsgroup-limits)
6370 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6371 ;; We use the new limit, so we push the old limit on the stack.
6372 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6374 (setq gnus-newsgroup-limit articles)
6375 (let ((total (length gnus-newsgroup-data))
6376 (data (gnus-data-find-list (gnus-summary-article-number)))
6377 (gnus-summary-mark-below nil) ; Inhibit this.
6379 ;; This will do all the work of generating the new summary buffer
6380 ;; according to the new limit.
6381 (gnus-summary-prepare)
6382 ;; Hide any threads, possibly.
6383 (and gnus-show-threads
6384 gnus-thread-hide-subtree
6385 (gnus-summary-hide-all-threads))
6386 ;; Try to return to the article you were at, or one in the
6389 ;; We try to find some article after the current one.
6391 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6394 (setq data (cdr data))))
6396 ;; If there is no data, that means that we were after the last
6397 ;; article. The same goes when we can't find any articles
6398 ;; after the current one.
6399 (goto-char (point-max))
6400 (gnus-summary-find-prev))
6401 (gnus-set-mode-line 'summary)
6402 ;; We return how many articles were removed from the summary
6403 ;; buffer as a result of the new limit.
6404 (- total (length gnus-newsgroup-data))))
6406 (defsubst gnus-invisible-cut-children (threads)
6409 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6414 (defsubst gnus-cut-thread (thread)
6415 "Go forwards in the thread until we find an article that we want to display."
6416 (when (or (eq gnus-fetch-old-headers 'some)
6417 (eq gnus-fetch-old-headers 'invisible)
6418 (eq gnus-build-sparse-threads 'some)
6419 (eq gnus-build-sparse-threads 'more))
6420 ;; Deal with old-fetched headers and sparse threads.
6424 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6425 (gnus-summary-article-ancient-p
6426 (mail-header-number (car thread))))
6427 (if (or (<= (length (cdr thread)) 1)
6428 (eq gnus-fetch-old-headers 'invisible))
6429 (setq gnus-newsgroup-limit
6430 (delq (mail-header-number (car thread))
6431 gnus-newsgroup-limit)
6432 thread (cadr thread))
6433 (when (gnus-invisible-cut-children (cdr thread))
6434 (let ((th (cdr thread)))
6436 (if (memq (mail-header-number (caar th))
6437 gnus-newsgroup-limit)
6438 (setq thread (car th)
6440 (setq th (cdr th))))))))))
6443 (defun gnus-cut-threads (threads)
6444 "Cut off all uninteresting articles from the beginning of threads."
6445 (when (or (eq gnus-fetch-old-headers 'some)
6446 (eq gnus-fetch-old-headers 'invisible)
6447 (eq gnus-build-sparse-threads 'some)
6448 (eq gnus-build-sparse-threads 'more))
6451 (setcar th (gnus-cut-thread (car th)))
6452 (setq th (cdr th)))))
6453 ;; Remove nixed out threads.
6456 (defun gnus-summary-initial-limit (&optional show-if-empty)
6457 "Figure out what the initial limit is supposed to be on group entry.
6458 This entails weeding out unwanted dormants, low-scored articles,
6459 fetch-old-headers verbiage, and so on."
6460 ;; Most groups have nothing to remove.
6461 (if (or gnus-inhibit-limiting
6462 (and (null gnus-newsgroup-dormant)
6463 (not (eq gnus-fetch-old-headers 'some))
6464 (not (eq gnus-fetch-old-headers 'invisible))
6465 (null gnus-summary-expunge-below)
6466 (not (eq gnus-build-sparse-threads 'some))
6467 (not (eq gnus-build-sparse-threads 'more))
6468 (null gnus-thread-expunge-below)
6469 (not gnus-use-nocem)))
6471 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6472 (setq gnus-newsgroup-limit nil)
6475 (unless (car (symbol-value node))
6476 ;; These threads have no parents -- they are roots.
6477 (let ((nodes (cdr (symbol-value node)))
6480 (if (and gnus-thread-expunge-below
6481 (< (gnus-thread-total-score (car nodes))
6482 gnus-thread-expunge-below))
6483 (gnus-expunge-thread (pop nodes))
6484 (setq thread (pop nodes))
6485 (gnus-summary-limit-children thread))))))
6486 gnus-newsgroup-dependencies)
6487 ;; If this limitation resulted in an empty group, we might
6488 ;; pop the previous limit and use it instead.
6489 (when (and (not gnus-newsgroup-limit)
6491 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6492 gnus-newsgroup-limit))
6494 (defun gnus-summary-limit-children (thread)
6495 "Return 1 if this subthread is visible and 0 if it is not."
6496 ;; First we get the number of visible children to this thread. This
6497 ;; is done by recursing down the thread using this function, so this
6498 ;; will really go down to a leaf article first, before slowly
6499 ;; working its way up towards the root.
6503 (apply '+ (mapcar 'gnus-summary-limit-children
6506 (number (mail-header-number (car thread)))
6509 (not (memq number gnus-newsgroup-marked))
6511 ;; If this article is dormant and has absolutely no visible
6512 ;; children, then this article isn't visible.
6513 (and (memq number gnus-newsgroup-dormant)
6515 ;; If this is "fetch-old-headered" and there is no
6516 ;; visible children, then we don't want this article.
6517 (and (eq gnus-fetch-old-headers 'some)
6518 (gnus-summary-article-ancient-p number)
6520 ;; If this is "fetch-old-headered" and `invisible', then
6521 ;; we don't want this article.
6522 (and (eq gnus-fetch-old-headers 'invisible)
6523 (gnus-summary-article-ancient-p number))
6524 ;; If this is a sparsely inserted article with no children,
6525 ;; we don't want it.
6526 (and (eq gnus-build-sparse-threads 'some)
6527 (gnus-summary-article-sparse-p number)
6529 ;; If we use expunging, and this article is really
6530 ;; low-scored, then we don't want this article.
6531 (when (and gnus-summary-expunge-below
6533 (or (cdr (assq number gnus-newsgroup-scored))
6534 gnus-summary-default-score))
6535 gnus-summary-expunge-below))
6536 ;; We increase the expunge-tally here, but that has
6537 ;; nothing to do with the limits, really.
6538 (incf gnus-newsgroup-expunged-tally)
6539 ;; We also mark as read here, if that's wanted.
6540 (when (and gnus-summary-mark-below
6541 (< score gnus-summary-mark-below))
6542 (setq gnus-newsgroup-unreads
6543 (delq number gnus-newsgroup-unreads))
6544 (if gnus-newsgroup-auto-expire
6545 (push number gnus-newsgroup-expirable)
6546 (push (cons number gnus-low-score-mark)
6547 gnus-newsgroup-reads)))
6549 ;; Check NoCeM things.
6550 (if (and gnus-use-nocem
6551 (gnus-nocem-unwanted-article-p
6552 (mail-header-id (car thread))))
6554 (setq gnus-newsgroup-unreads
6555 (delq number gnus-newsgroup-unreads))
6557 ;; Nope, invisible article.
6559 ;; Ok, this article is to be visible, so we add it to the limit
6561 (push number gnus-newsgroup-limit)
6564 (defun gnus-expunge-thread (thread)
6565 "Mark all articles in THREAD as read."
6566 (let* ((number (mail-header-number (car thread))))
6567 (incf gnus-newsgroup-expunged-tally)
6568 ;; We also mark as read here, if that's wanted.
6569 (setq gnus-newsgroup-unreads
6570 (delq number gnus-newsgroup-unreads))
6571 (if gnus-newsgroup-auto-expire
6572 (push number gnus-newsgroup-expirable)
6573 (push (cons number gnus-low-score-mark)
6574 gnus-newsgroup-reads)))
6575 ;; Go recursively through all subthreads.
6576 (mapcar 'gnus-expunge-thread (cdr thread)))
6578 ;; Summary article oriented commands
6580 (defun gnus-summary-refer-parent-article (n)
6581 "Refer parent article N times.
6582 If N is negative, go to ancestor -N instead.
6583 The difference between N and the number of articles fetched is returned."
6587 (when (not (natnump n))
6592 (setq header (gnus-summary-article-header))
6593 (if (and (eq (mail-header-number header)
6594 (cdr gnus-article-current))
6595 (equal gnus-newsgroup-name
6596 (car gnus-article-current)))
6597 ;; If we try to find the parent of the currently
6598 ;; displayed article, then we take a look at the actual
6599 ;; References header, since this is slightly more
6600 ;; reliable than the References field we got from the
6603 (set-buffer gnus-original-article-buffer)
6604 (nnheader-narrow-to-headers)
6605 (unless (setq ref (message-fetch-field "references"))
6606 (setq ref (message-fetch-field "in-reply-to")))
6609 ;; It's not the current article, so we take a bet on
6610 ;; the value we got from the server.
6611 (mail-header-references header)))
6613 (not (equal ref "")))
6614 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6615 (gnus-message 1 "Couldn't find parent"))
6616 (gnus-message 1 "No references in article %d"
6617 (gnus-summary-article-number))
6620 (gnus-summary-position-point)
6623 (defun gnus-summary-refer-references ()
6624 "Fetch all articles mentioned in the References header.
6625 Return the number of articles fetched."
6627 (let ((ref (mail-header-references (gnus-summary-article-header)))
6628 (current (gnus-summary-article-number))
6632 (error "No References in the current article")
6633 ;; For each Message-ID in the References header...
6634 (while (string-match "<[^>]*>" ref)
6636 ;; ... fetch that article.
6637 (gnus-summary-refer-article
6638 (prog1 (match-string 0 ref)
6639 (setq ref (substring ref (match-end 0))))))
6640 (gnus-summary-goto-subject current)
6641 (gnus-summary-position-point)
6644 (defun gnus-summary-refer-thread (&optional limit)
6645 "Fetch all articles in the current thread.
6646 If LIMIT (the numerical prefix), fetch that many old headers instead
6647 of what's specified by the `gnus-refer-thread-limit' variable."
6649 (let ((id (mail-header-id (gnus-summary-article-header)))
6650 (limit (if limit (prefix-numeric-value limit)
6651 gnus-refer-thread-limit)))
6652 ;; We want to fetch LIMIT *old* headers, but we also have to
6653 ;; re-fetch all the headers in the current buffer, because many of
6654 ;; them may be undisplayed. So we adjust LIMIT.
6655 (when (numberp limit)
6656 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6657 (unless (eq gnus-fetch-old-headers 'invisible)
6658 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6659 ;; Retrieve the headers and read them in.
6660 (if (eq (gnus-retrieve-headers
6661 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6663 (gnus-build-all-threads)
6664 (error "Can't fetch thread from backends that don't support NOV"))
6665 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6666 (gnus-summary-limit-include-thread id)))
6668 (defun gnus-summary-refer-article (message-id &optional arg)
6669 "Fetch an article specified by MESSAGE-ID.
6670 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6671 or `gnus-select-method', no matter what backend the article comes from."
6672 (interactive "sMessage-ID: \nP")
6673 (when (and (stringp message-id)
6674 (not (zerop (length message-id))))
6675 ;; Construct the correct Message-ID if necessary.
6676 ;; Suggested by tale@pawl.rpi.edu.
6677 (unless (string-match "^<" message-id)
6678 (setq message-id (concat "<" message-id)))
6679 (unless (string-match ">$" message-id)
6680 (setq message-id (concat message-id ">")))
6681 (let* ((header (gnus-id-to-header message-id))
6683 (gnus-summary-article-sparse-p
6684 (mail-header-number header))
6685 (memq (mail-header-number header)
6686 gnus-newsgroup-limit))))
6688 ;; If the article is present in the buffer we just go to it.
6690 (or (not (gnus-summary-article-sparse-p
6691 (mail-header-number header)))
6694 (gnus-summary-goto-article
6695 (mail-header-number header) nil t)
6697 (gnus-summary-update-article (mail-header-number header)))))
6699 ;; We fetch the article
6700 (let ((gnus-override-method
6701 (cond ((gnus-news-group-p gnus-newsgroup-name)
6702 gnus-refer-article-method)
6704 (or gnus-refer-article-method gnus-select-method))
6707 ;; Start the special refer-article method, if necessary.
6708 (when (and gnus-refer-article-method
6709 (gnus-news-group-p gnus-newsgroup-name))
6710 (gnus-check-server gnus-refer-article-method))
6711 ;; Fetch the header, and display the article.
6712 (if (setq number (gnus-summary-insert-subject message-id))
6713 (gnus-summary-select-article nil nil nil number)
6714 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6716 (defun gnus-summary-edit-parameters ()
6717 "Edit the group parameters of the current group."
6719 (gnus-group-edit-group gnus-newsgroup-name 'params))
6721 (defun gnus-summary-customize-parameters ()
6722 "Customize the group parameters of the current group."
6724 (gnus-group-customize gnus-newsgroup-name))
6726 (defun gnus-summary-enter-digest-group (&optional force)
6727 "Enter an nndoc group based on the current article.
6728 If FORCE, force a digest interpretation. If not, try
6729 to guess what the document format is."
6731 (let ((conf gnus-current-window-configuration))
6733 (gnus-summary-select-article))
6734 (setq gnus-current-window-configuration conf)
6735 (let* ((name (format "%s-%d"
6736 (gnus-group-prefixed-name
6737 gnus-newsgroup-name (list 'nndoc ""))
6739 (set-buffer gnus-summary-buffer)
6740 gnus-current-article)))
6741 (ogroup gnus-newsgroup-name)
6742 (params (append (gnus-info-params (gnus-get-info ogroup))
6743 (list (cons 'to-group ogroup))
6744 (list (cons 'save-article-group ogroup))))
6745 (case-fold-search t)
6746 (buf (current-buffer))
6749 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6750 (insert-buffer-substring gnus-original-article-buffer)
6751 ;; Remove lines that may lead nndoc to misinterpret the
6754 (goto-char (point-min))
6755 (or (search-forward "\n\n" nil t) (point)))
6756 (goto-char (point-min))
6757 (delete-matching-lines "^Path:\\|^From ")
6760 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6761 (gnus-newsgroup-ephemeral-ignored-charsets
6762 gnus-newsgroup-ignored-charsets))
6763 (gnus-group-read-ephemeral-group
6764 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6766 ,(if force 'digest 'guess))) t))
6767 ;; Make all postings to this group go to the parent group.
6768 (nconc (gnus-info-params (gnus-get-info name))
6770 ;; Couldn't select this doc group.
6771 (switch-to-buffer buf)
6772 (gnus-set-global-variables)
6773 (gnus-configure-windows 'summary)
6774 (gnus-message 3 "Article couldn't be entered?"))
6775 (kill-buffer dig)))))
6777 (defun gnus-summary-read-document (n)
6778 "Open a new group based on the current article(s).
6779 This will allow you to read digests and other similar
6780 documents as newsgroups.
6781 Obeys the standard process/prefix convention."
6783 (let* ((articles (gnus-summary-work-articles n))
6784 (ogroup gnus-newsgroup-name)
6785 (params (append (gnus-info-params (gnus-get-info ogroup))
6786 (list (cons 'to-group ogroup))))
6787 article group egroup groups vgroup)
6788 (while (setq article (pop articles))
6789 (setq group (format "%s-%d" gnus-newsgroup-name article))
6790 (gnus-summary-remove-process-mark article)
6791 (when (gnus-summary-display-article article)
6794 (insert-buffer-substring gnus-original-article-buffer)
6795 ;; Remove some headers that may lead nndoc to make
6797 (message-narrow-to-head)
6798 (goto-char (point-min))
6799 (delete-matching-lines "^\\(Path\\):\\|^From ")
6802 (gnus-group-read-ephemeral-group
6803 group `(nndoc ,group (nndoc-address ,(current-buffer))
6804 (nndoc-article-type guess))
6807 ;; Make all postings to this group go to the parent group.
6808 (nconc (gnus-info-params (gnus-get-info egroup))
6810 (push egroup groups))
6811 ;; Couldn't select this doc group.
6812 (gnus-error 3 "Article couldn't be entered"))))))
6813 ;; Now we have selected all the documents.
6816 (error "None of the articles could be interpreted as documents"))
6817 ((gnus-group-read-ephemeral-group
6818 (setq vgroup (format
6819 "nnvirtual:%s-%s" gnus-newsgroup-name
6820 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6821 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6823 (cons (current-buffer) 'summary)))
6825 (error "Couldn't select virtual nndoc group")))))
6827 (defun gnus-summary-isearch-article (&optional regexp-p)
6828 "Do incremental search forward on the current article.
6829 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6831 (gnus-summary-select-article)
6832 (gnus-configure-windows 'article)
6833 (gnus-eval-in-buffer-window gnus-article-buffer
6836 (isearch-forward regexp-p))))
6838 (defun gnus-summary-search-article-forward (regexp &optional backward)
6839 "Search for an article containing REGEXP forward.
6840 If BACKWARD, search backward instead."
6843 (format "Search article %s (regexp%s): "
6844 (if current-prefix-arg "backward" "forward")
6845 (if gnus-last-search-regexp
6846 (concat ", default " gnus-last-search-regexp)
6848 current-prefix-arg))
6849 (if (string-equal regexp "")
6850 (setq regexp (or gnus-last-search-regexp ""))
6851 (setq gnus-last-search-regexp regexp))
6852 (if (gnus-summary-search-article regexp backward)
6853 (gnus-summary-show-thread)
6854 (error "Search failed: \"%s\"" regexp)))
6856 (defun gnus-summary-search-article-backward (regexp)
6857 "Search for an article containing REGEXP backward."
6860 (format "Search article backward (regexp%s): "
6861 (if gnus-last-search-regexp
6862 (concat ", default " gnus-last-search-regexp)
6864 (gnus-summary-search-article-forward regexp 'backward))
6866 (defun gnus-summary-search-article (regexp &optional backward)
6867 "Search for an article containing REGEXP.
6868 Optional argument BACKWARD means do search for backward.
6869 `gnus-select-article-hook' is not called during the search."
6870 ;; We have to require this here to make sure that the following
6871 ;; dynamic binding isn't shadowed by autoloading.
6872 (require 'gnus-async)
6874 (let ((gnus-select-article-hook nil) ;Disable hook.
6875 (gnus-article-display-hook nil)
6876 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6877 (gnus-use-article-prefetch nil)
6878 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6879 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6880 (sum (current-buffer))
6883 (gnus-save-hidden-threads
6884 (gnus-summary-select-article)
6885 (set-buffer gnus-article-buffer)
6889 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6891 (re-search-backward regexp nil t)
6892 (re-search-forward regexp nil t))
6893 ;; We found the regexp.
6898 (get-buffer-window (current-buffer))
6902 (setq point (point)))
6903 ;; We didn't find it, so we go to the next article.
6906 (while (eq found 'not)
6907 (if (not (if backward (gnus-summary-find-prev)
6908 (gnus-summary-find-next)))
6909 ;; No more articles.
6911 ;; Select the next article and adjust point.
6912 (unless (gnus-summary-article-sparse-p
6913 (gnus-summary-article-number))
6915 (gnus-summary-select-article)
6916 (set-buffer gnus-article-buffer)
6918 (goto-char (if backward (point-max) (point-min))))))))
6919 (gnus-message 7 ""))
6920 ;; Return whether we found the regexp.
6921 (when (eq found 'found)
6923 (gnus-summary-show-thread)
6924 (gnus-summary-goto-subject gnus-current-article)
6925 (gnus-summary-position-point)
6928 (defun gnus-summary-find-matching (header regexp &optional backward unread
6930 "Return a list of all articles that match REGEXP on HEADER.
6931 The search stars on the current article and goes forwards unless
6932 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6933 If UNREAD is non-nil, only unread articles will
6934 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6935 in the comparisons."
6936 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6937 (gnus-data-find-list
6938 (gnus-summary-article-number) (gnus-data-list backward))))
6939 (case-fold-search (not not-case-fold))
6942 (if (eq (car header) 'extra)
6945 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
6947 (error "%s is an invalid header" header))
6948 (unless (fboundp (intern (concat "mail-header-" header)))
6949 (error "%s is not a valid header" header))
6950 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
6953 (and (or (not unread) ; We want all articles...
6954 (gnus-data-unread-p d)) ; Or just unreads.
6955 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6956 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6957 (push (gnus-data-number d) articles)) ; Success!
6958 (setq data (cdr data)))
6959 (nreverse articles)))
6961 (defun gnus-summary-execute-command (header regexp command &optional backward)
6962 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6963 If HEADER is an empty string (or nil), the match is done on the entire
6964 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6966 (list (let ((completion-ignore-case t))
6969 (mapcar (lambda (string) (list string))
6970 '("Number" "Subject" "From" "Lines" "Date"
6971 "Message-ID" "Xref" "References" "Body"))
6972 nil 'require-match))
6973 (read-string "Regexp: ")
6974 (read-key-sequence "Command: ")
6975 current-prefix-arg))
6976 (when (equal header "Body")
6978 ;; Hidden thread subtrees must be searched as well.
6979 (gnus-summary-show-all-threads)
6980 ;; We don't want to change current point nor window configuration.
6982 (save-window-excursion
6983 (gnus-message 6 "Executing %s..." (key-description command))
6984 ;; We'd like to execute COMMAND interactively so as to give arguments.
6985 (gnus-execute header regexp
6986 `(call-interactively ',(key-binding command))
6988 (gnus-message 6 "Executing %s...done" (key-description command)))))
6990 (defun gnus-summary-beginning-of-article ()
6991 "Scroll the article back to the beginning."
6993 (gnus-summary-select-article)
6994 (gnus-configure-windows 'article)
6995 (gnus-eval-in-buffer-window gnus-article-buffer
6997 (goto-char (point-min))
6998 (when gnus-page-broken
6999 (gnus-narrow-to-page))))
7001 (defun gnus-summary-end-of-article ()
7002 "Scroll to the end of the article."
7004 (gnus-summary-select-article)
7005 (gnus-configure-windows 'article)
7006 (gnus-eval-in-buffer-window gnus-article-buffer
7008 (goto-char (point-max))
7010 (when gnus-page-broken
7011 (gnus-narrow-to-page))))
7013 (defun gnus-summary-print-article (&optional filename n)
7014 "Generate and print a PostScript image of the N next (mail) articles.
7016 If N is negative, print the N previous articles. If N is nil and articles
7017 have been marked with the process mark, print these instead.
7019 If the optional first argument FILENAME is nil, send the image to the
7020 printer. If FILENAME is a string, save the PostScript image in a file with
7021 that name. If FILENAME is a number, prompt the user for the name of the file
7023 (interactive (list (ps-print-preprint current-prefix-arg)
7024 current-prefix-arg))
7025 (dolist (article (gnus-summary-work-articles n))
7026 (gnus-summary-select-article nil nil 'pseudo article)
7027 (gnus-eval-in-buffer-window gnus-article-buffer
7028 (let ((buffer (generate-new-buffer " *print*")))
7031 (copy-to-buffer buffer (point-min) (point-max))
7033 (gnus-article-delete-invisible-text)
7034 (let ((ps-left-header
7037 (mail-header-subject gnus-current-headers) ")")
7039 (mail-header-from gnus-current-headers) ")")))
7042 "/pagenumberstring load"
7044 (mail-header-date gnus-current-headers) ")"))))
7045 (gnus-run-hooks 'gnus-ps-print-hook)
7047 (ps-print-buffer-with-faces filename))))
7048 (kill-buffer buffer))))))
7050 (defun gnus-summary-show-article (&optional arg)
7051 "Force re-fetching of the current article.
7052 If ARG (the prefix) is non-nil, show the raw article without any
7053 article massaging functions being run."
7056 ;; Select the article the normal way.
7057 (gnus-summary-select-article nil 'force)
7058 ;; We have to require this here to make sure that the following
7059 ;; dynamic binding isn't shadowed by autoloading.
7060 (require 'gnus-async)
7062 ;; Bind the article treatment functions to nil.
7063 (let ((gnus-have-all-headers t)
7064 gnus-article-display-hook
7065 gnus-article-prepare-hook
7066 gnus-article-decode-hook
7070 (gnus-summary-select-article nil 'force)))
7071 (gnus-summary-goto-subject gnus-current-article)
7072 (gnus-summary-position-point))
7074 (defun gnus-summary-verbose-headers (&optional arg)
7075 "Toggle permanent full header display.
7076 If ARG is a positive number, turn header display on.
7077 If ARG is a negative number, turn header display off."
7079 (setq gnus-show-all-headers
7080 (cond ((or (not (numberp arg))
7082 (not gnus-show-all-headers))
7085 (gnus-summary-show-article))
7087 (defun gnus-summary-toggle-header (&optional arg)
7088 "Show the headers if they are hidden, or hide them if they are shown.
7089 If ARG is a positive number, show the entire header.
7090 If ARG is a negative number, hide the unwanted header lines."
7093 (set-buffer gnus-article-buffer)
7095 (let* ((buffer-read-only nil)
7096 (inhibit-point-motion-hooks t)
7099 (article-narrow-to-head)
7100 (setq hidden (gnus-article-hidden-text-p 'headers)))
7101 (goto-char (point-min))
7102 (when (search-forward "\n\n" nil t)
7103 (delete-region (point-min) (1- (point))))
7104 (goto-char (point-min))
7106 (set-buffer gnus-original-article-buffer)
7107 (goto-char (point-min))
7108 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7109 (insert-buffer-substring gnus-original-article-buffer 1 e)
7111 (narrow-to-region (point-min) (point))
7112 (article-decode-encoded-words)
7114 (and (numberp arg) (< arg 0)))
7115 (let ((gnus-treat-hide-headers nil)
7116 (gnus-treat-hide-boring-headers nil))
7117 (gnus-treat-article 'head))
7118 (gnus-treat-article 'head)))))))
7120 (defun gnus-summary-show-all-headers ()
7121 "Make all header lines visible."
7123 (gnus-article-show-all-headers))
7125 (defun gnus-summary-toggle-mime (&optional arg)
7126 "Toggle MIME processing.
7127 If ARG is a positive number, turn MIME processing on."
7129 (setq gnus-show-mime
7131 (not gnus-show-mime)
7132 (> (prefix-numeric-value arg) 0)))
7133 (gnus-summary-select-article t 'force))
7135 (defun gnus-summary-caesar-message (&optional arg)
7136 "Caesar rotate the current article by 13.
7137 The numerical prefix specifies how many places to rotate each letter
7140 (gnus-summary-select-article)
7141 (let ((mail-header-separator ""))
7142 (gnus-eval-in-buffer-window gnus-article-buffer
7145 (let ((start (window-start))
7147 (message-caesar-buffer-body arg)
7148 (set-window-start (get-buffer-window (current-buffer)) start))))))
7150 (defun gnus-summary-stop-page-breaking ()
7151 "Stop page breaking in the current article."
7153 (gnus-summary-select-article)
7154 (gnus-eval-in-buffer-window gnus-article-buffer
7156 (when (gnus-visual-p 'page-marker)
7157 (let ((buffer-read-only nil))
7158 (gnus-remove-text-with-property 'gnus-prev)
7159 (gnus-remove-text-with-property 'gnus-next))
7160 (setq gnus-page-broken nil))))
7162 (defun gnus-summary-move-article (&optional n to-newsgroup
7163 select-method action)
7164 "Move the current article to a different newsgroup.
7165 If N is a positive number, move the N next articles.
7166 If N is a negative number, move the N previous articles.
7167 If N is nil and any articles have been marked with the process mark,
7168 move those articles instead.
7169 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7170 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7171 re-spool using this method.
7173 For this function to work, both the current newsgroup and the
7174 newsgroup that you want to move to have to support the `request-move'
7175 and `request-accept' functions."
7178 (setq action 'move))
7179 ;; Disable marking as read.
7180 (let (gnus-mark-article-hook)
7181 (save-window-excursion
7182 (gnus-summary-select-article)))
7183 ;; Check whether the source group supports the required functions.
7184 (cond ((and (eq action 'move)
7185 (not (gnus-check-backend-function
7186 'request-move-article gnus-newsgroup-name)))
7187 (error "The current group does not support article moving"))
7188 ((and (eq action 'crosspost)
7189 (not (gnus-check-backend-function
7190 'request-replace-article gnus-newsgroup-name)))
7191 (error "The current group does not support article editing")))
7192 (let ((articles (gnus-summary-work-articles n))
7193 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7194 (names '((move "Move" "Moving")
7195 (copy "Copy" "Copying")
7196 (crosspost "Crosspost" "Crossposting")))
7197 (copy-buf (save-excursion
7198 (nnheader-set-temp-buffer " *copy article*")))
7199 (default-marks gnus-article-mark-lists)
7200 (no-expire-marks (delete '(expirable . expire)
7201 (copy-sequence gnus-article-mark-lists)))
7202 art-group to-method new-xref article to-groups)
7203 (unless (assq action names)
7204 (error "Unknown action %s" action))
7205 ;; Read the newsgroup name.
7206 (when (and (not to-newsgroup)
7207 (not select-method))
7209 (gnus-read-move-group-name
7210 (cadr (assq action names))
7211 (symbol-value (intern (format "gnus-current-%s-group" action)))
7213 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7214 (setq to-method (or select-method
7215 (gnus-group-name-to-method to-newsgroup)))
7216 ;; Check the method we are to move this article to...
7217 (unless (gnus-check-backend-function
7218 'request-accept-article (car to-method))
7219 (error "%s does not support article copying" (car to-method)))
7220 (unless (gnus-check-server to-method)
7221 (error "Can't open server %s" (car to-method)))
7222 (gnus-message 6 "%s to %s: %s..."
7223 (caddr (assq action names))
7224 (or (car select-method) to-newsgroup) articles)
7226 (setq article (pop articles))
7230 ;; Move the article.
7232 ;; Remove this article from future suppression.
7233 (gnus-dup-unsuppress-article article)
7234 (gnus-request-move-article
7235 article ; Article to move
7236 gnus-newsgroup-name ; From newsgroup
7237 (nth 1 (gnus-find-method-for-group
7238 gnus-newsgroup-name)) ; Server
7239 (list 'gnus-request-accept-article
7240 to-newsgroup (list 'quote select-method)
7241 (not articles) t) ; Accept form
7242 (not articles))) ; Only save nov last time
7243 ;; Copy the article.
7246 (set-buffer copy-buf)
7247 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7248 (gnus-request-accept-article
7249 to-newsgroup select-method (not articles) t))))
7250 ;; Crosspost the article.
7251 ((eq action 'crosspost)
7252 (let ((xref (message-tokenize-header
7253 (mail-header-xref (gnus-summary-article-header article))
7255 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7258 (setq xref (list (system-name))))
7261 (mapconcat 'identity
7262 (delete "Xref:" (delete new-xref xref))
7266 (set-buffer copy-buf)
7267 ;; First put the article in the destination group.
7268 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7269 (when (consp (setq art-group
7270 (gnus-request-accept-article
7271 to-newsgroup select-method (not articles))))
7272 (setq new-xref (concat new-xref " " (car art-group)
7273 ":" (cdr art-group)))
7274 ;; Now we have the new Xrefs header, so we insert
7275 ;; it and replace the new article.
7276 (nnheader-replace-header "Xref" new-xref)
7277 (gnus-request-replace-article
7278 (cdr art-group) to-newsgroup (current-buffer))
7282 (gnus-message 1 "Couldn't %s article %s"
7283 (cadr (assq action names)) article))
7284 ((and (eq art-group 'junk)
7286 (gnus-summary-mark-article article gnus-canceled-mark)
7287 (gnus-message 4 "Deleted article %s" article))
7289 (let* ((pto-group (gnus-group-prefixed-name
7290 (car art-group) to-method))
7292 (gnus-gethash pto-group gnus-newsrc-hashtb))
7293 (info (nth 2 entry))
7294 (to-group (gnus-info-group info))
7296 ;; Update the group that has been moved to.
7298 (memq action '(move copy)))
7299 (unless (member to-group to-groups)
7300 (push to-group to-groups))
7302 (unless (memq article gnus-newsgroup-unreads)
7303 (push 'read to-marks)
7305 info (gnus-add-to-range (gnus-info-read info)
7306 (list (cdr art-group)))))
7308 ;; Copy any marks over to the new group.
7309 (let ((marks (if (gnus-group-auto-expirable-p to-group)
7312 (to-article (cdr art-group)))
7314 ;; See whether the article is to be put in the cache.
7315 (when gnus-use-cache
7316 (gnus-cache-possibly-enter-article
7318 (let ((header (copy-sequence
7319 (gnus-summary-article-header article))))
7320 (mail-header-set-number header to-article)
7322 (memq article gnus-newsgroup-marked)
7323 (memq article gnus-newsgroup-dormant)
7324 (memq article gnus-newsgroup-unreads)))
7326 (when (and (equal to-group gnus-newsgroup-name)
7327 (not (memq article gnus-newsgroup-unreads)))
7328 ;; Mark this article as read in this group.
7329 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7330 (setcdr (gnus-active to-group) to-article)
7331 (setcdr gnus-newsgroup-active to-article))
7334 (when (memq article (symbol-value
7335 (intern (format "gnus-newsgroup-%s"
7337 (push (cdar marks) to-marks)
7338 ;; If the other group is the same as this group,
7339 ;; then we have to add the mark to the list.
7340 (when (equal to-group gnus-newsgroup-name)
7341 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7344 (intern (format "gnus-newsgroup-%s"
7346 ;; Copy the marks to other group.
7347 (gnus-add-marked-articles
7348 to-group (cdar marks) (list to-article) info))
7349 (setq marks (cdr marks)))
7351 (gnus-request-set-mark to-group (list (list (list to-article)
7356 (concat "(gnus-group-set-info '"
7357 (gnus-prin1-to-string (gnus-get-info to-group))
7360 ;; Update the Xref header in this article to point to
7361 ;; the new crossposted article we have just created.
7362 (when (eq action 'crosspost)
7364 (set-buffer copy-buf)
7365 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7366 (nnheader-replace-header "Xref" new-xref)
7367 (gnus-request-replace-article
7368 article gnus-newsgroup-name (current-buffer)))))
7370 ;;;!!!Why is this necessary?
7371 (set-buffer gnus-summary-buffer)
7373 (gnus-summary-goto-subject article)
7374 (when (eq action 'move)
7375 (gnus-summary-mark-article article gnus-canceled-mark))))
7376 (gnus-summary-remove-process-mark article))
7377 ;; Re-activate all groups that have been moved to.
7380 (set-buffer gnus-group-buffer)
7381 (when (gnus-group-goto-group (car to-groups) t)
7382 (gnus-group-get-new-news-this-group 1 t))
7385 (gnus-kill-buffer copy-buf)
7386 (gnus-summary-position-point)
7387 (gnus-set-mode-line 'summary)))
7389 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7390 "Move the current article to a different newsgroup.
7391 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7392 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7393 re-spool using this method."
7395 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7397 (defun gnus-summary-crosspost-article (&optional n)
7398 "Crosspost the current article to some other group."
7400 (gnus-summary-move-article n nil nil 'crosspost))
7402 (defcustom gnus-summary-respool-default-method nil
7403 "Default method for respooling an article.
7404 If nil, use to the current newsgroup method."
7405 :type '(choice (gnus-select-method :value (nnml ""))
7407 :group 'gnus-summary-mail)
7409 (defun gnus-summary-respool-article (&optional n method)
7410 "Respool the current article.
7411 The article will be squeezed through the mail spooling process again,
7412 which means that it will be put in some mail newsgroup or other
7413 depending on `nnmail-split-methods'.
7414 If N is a positive number, respool the N next articles.
7415 If N is a negative number, respool the N previous articles.
7416 If N is nil and any articles have been marked with the process mark,
7417 respool those articles instead.
7419 Respooling can be done both from mail groups and \"real\" newsgroups.
7420 In the former case, the articles in question will be moved from the
7421 current group into whatever groups they are destined to. In the
7422 latter case, they will be copied into the relevant groups."
7424 (list current-prefix-arg
7425 (let* ((methods (gnus-methods-using 'respool))
7427 (symbol-name (or gnus-summary-respool-default-method
7428 (car (gnus-find-method-for-group
7429 gnus-newsgroup-name)))))
7431 (gnus-completing-read
7432 methname "What backend do you want to use when respooling?"
7433 methods nil t nil 'gnus-mail-method-history))
7436 ((zerop (length (setq ms (gnus-servers-using-backend
7438 (list (intern method) ""))
7442 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7443 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7446 (error "No method given for respooling"))
7447 (if (assoc (symbol-name
7448 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7449 (gnus-methods-using 'respool))
7450 (gnus-summary-move-article n nil method)
7451 (gnus-summary-copy-article n nil method)))
7453 (defun gnus-summary-import-article (file)
7454 "Import an arbitrary file into a mail newsgroup."
7455 (interactive "fImport file: ")
7456 (let ((group gnus-newsgroup-name)
7457 (now (current-time))
7459 (unless (gnus-check-backend-function 'request-accept-article group)
7460 (error "%s does not support article importing" group))
7461 (or (file-readable-p file)
7462 (not (file-regular-p file))
7463 (error "Can't read %s" file))
7465 (set-buffer (gnus-get-buffer-create " *import file*"))
7467 (nnheader-insert-file-contents file)
7468 (goto-char (point-min))
7469 (unless (nnheader-article-p)
7470 ;; This doesn't look like an article, so we fudge some headers.
7471 (setq atts (file-attributes file)
7472 lines (count-lines (point-min) (point-max)))
7473 (insert "From: " (read-string "From: ") "\n"
7474 "Subject: " (read-string "Subject: ") "\n"
7475 "Date: " (message-make-date (nth 5 atts))
7477 "Message-ID: " (message-make-message-id) "\n"
7478 "Lines: " (int-to-string lines) "\n"
7479 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7480 (gnus-request-accept-article group nil t)
7481 (kill-buffer (current-buffer)))))
7483 (defun gnus-summary-article-posted-p ()
7484 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7485 This will be the case if the article has both been mailed and posted."
7487 (let ((id (mail-header-references (gnus-summary-article-header)))
7488 (gnus-override-method
7489 (or gnus-refer-article-method gnus-select-method)))
7490 (if (gnus-request-head id "")
7491 (gnus-message 2 "The current message was found on %s"
7492 gnus-override-method)
7493 (gnus-message 2 "The current message couldn't be found on %s"
7494 gnus-override-method)
7497 (defun gnus-summary-expire-articles (&optional now)
7498 "Expire all articles that are marked as expirable in the current group."
7500 (when (gnus-check-backend-function
7501 'request-expire-articles gnus-newsgroup-name)
7502 ;; This backend supports expiry.
7503 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7504 (expirable (if total
7506 ;; We need to update the info for
7507 ;; this group for `gnus-list-of-read-articles'
7508 ;; to give us the right answer.
7509 (gnus-run-hooks 'gnus-exit-group-hook)
7510 (gnus-summary-update-info)
7511 (gnus-list-of-read-articles gnus-newsgroup-name))
7512 (setq gnus-newsgroup-expirable
7513 (sort gnus-newsgroup-expirable '<))))
7514 (expiry-wait (if now 'immediate
7515 (gnus-group-find-parameter
7516 gnus-newsgroup-name 'expiry-wait)))
7519 ;; There are expirable articles in this group, so we run them
7520 ;; through the expiry process.
7521 (gnus-message 6 "Expiring articles...")
7522 (unless (gnus-check-group gnus-newsgroup-name)
7523 (error "Can't open server for %s" gnus-newsgroup-name))
7524 ;; The list of articles that weren't expired is returned.
7527 (let ((nnmail-expiry-wait-function nil)
7528 (nnmail-expiry-wait expiry-wait))
7529 (setq es (gnus-request-expire-articles
7530 expirable gnus-newsgroup-name)))
7531 (setq es (gnus-request-expire-articles
7532 expirable gnus-newsgroup-name))))
7534 (setq gnus-newsgroup-expirable es))
7535 ;; We go through the old list of expirable, and mark all
7536 ;; really expired articles as nonexistent.
7537 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7538 (let ((gnus-use-cache nil))
7540 (unless (memq (car expirable) es)
7541 (when (gnus-data-find (car expirable))
7542 (gnus-summary-mark-article
7543 (car expirable) gnus-canceled-mark)))
7544 (setq expirable (cdr expirable)))))
7545 (gnus-message 6 "Expiring articles...done")))))
7547 (defun gnus-summary-expire-articles-now ()
7548 "Expunge all expirable articles in the current group.
7549 This means that *all* articles that are marked as expirable will be
7550 deleted forever, right now."
7552 (or gnus-expert-user
7554 "Are you really, really, really sure you want to delete all these messages? ")
7556 (gnus-summary-expire-articles t))
7558 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7559 (defun gnus-summary-delete-article (&optional n)
7560 "Delete the N next (mail) articles.
7561 This command actually deletes articles. This is not a marking
7562 command. The article will disappear forever from your life, never to
7564 If N is negative, delete backwards.
7565 If N is nil and articles have been marked with the process mark,
7566 delete these instead."
7568 (unless (gnus-check-backend-function 'request-expire-articles
7569 gnus-newsgroup-name)
7570 (error "The current newsgroup does not support article deletion"))
7571 ;; Compute the list of articles to delete.
7572 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7574 (if (and gnus-novice-user
7575 (not (gnus-yes-or-no-p
7576 (format "Do you really want to delete %s forever? "
7577 (if (> (length articles) 1)
7578 (format "these %s articles" (length articles))
7581 ;; Delete the articles.
7582 (setq not-deleted (gnus-request-expire-articles
7583 articles gnus-newsgroup-name 'force))
7585 (gnus-summary-remove-process-mark (car articles))
7586 ;; The backend might not have been able to delete the article
7588 (unless (memq (car articles) not-deleted)
7589 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7590 (setq articles (cdr articles)))
7592 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7593 (gnus-summary-position-point)
7594 (gnus-set-mode-line 'summary)
7597 (defun gnus-summary-edit-article (&optional force)
7598 "Edit the current article.
7599 This will have permanent effect only in mail groups.
7600 If FORCE is non-nil, allow editing of articles even in read-only
7604 (set-buffer gnus-summary-buffer)
7605 (let ((mail-parse-charset gnus-newsgroup-charset)
7606 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7607 (gnus-set-global-variables)
7608 (when (and (not force)
7609 (gnus-group-read-only-p))
7610 (error "The current newsgroup does not support article editing"))
7611 (gnus-summary-show-article t)
7612 (gnus-article-edit-article
7614 `(lambda (no-highlight)
7615 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7616 (mail-parse-ignored-charsets
7617 ',gnus-newsgroup-ignored-charsets))
7618 (gnus-summary-edit-article-done
7619 ,(or (mail-header-references gnus-current-headers) "")
7620 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7622 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7624 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7626 "Make edits to the current article permanent."
7628 ;; Replace the article.
7629 (let ((buf (current-buffer)))
7631 (insert-buffer-substring buf)
7632 (if (and (not read-only)
7633 (not (gnus-request-replace-article
7634 (cdr gnus-article-current) (car gnus-article-current)
7635 (current-buffer) t)))
7636 (error "Couldn't replace article")
7637 ;; Update the summary buffer.
7639 (equal (message-tokenize-header references " ")
7640 (message-tokenize-header
7641 (or (message-fetch-field "references") "") " ")))
7642 ;; We only have to update this line.
7645 (message-narrow-to-head)
7646 (let ((head (buffer-string))
7649 (insert (format "211 %d Article retrieved.\n"
7650 (cdr gnus-article-current)))
7653 (let ((nntp-server-buffer (current-buffer)))
7654 (setq header (car (gnus-get-newsgroup-headers
7656 (set-buffer gnus-summary-buffer)
7657 gnus-newsgroup-dependencies)
7660 (set-buffer gnus-summary-buffer)
7661 (gnus-data-set-header
7662 (gnus-data-find (cdr gnus-article-current))
7664 (gnus-summary-update-article-line
7665 (cdr gnus-article-current) header))))))
7667 (set-buffer (or buffer gnus-summary-buffer))
7668 (gnus-summary-update-article (cdr gnus-article-current)))
7669 ;; Prettify the article buffer again.
7670 (unless no-highlight
7672 (set-buffer gnus-article-buffer)
7673 ;;;!!! Fix this -- article should be rehighlighted.
7674 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7675 (set-buffer gnus-original-article-buffer)
7676 (gnus-request-article
7677 (cdr gnus-article-current)
7678 (car gnus-article-current) (current-buffer))))
7679 ;; Prettify the summary buffer line.
7680 (when (gnus-visual-p 'summary-highlight 'highlight)
7681 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7683 (defun gnus-summary-edit-wash (key)
7684 "Perform editing command KEY in the article buffer."
7688 (message "%s" (concat (this-command-keys) "- "))
7691 (gnus-summary-edit-article)
7692 (execute-kbd-macro (concat (this-command-keys) key))
7693 (gnus-article-edit-done))
7697 (defun gnus-summary-respool-query (&optional silent trace)
7698 "Query where the respool algorithm would put this article."
7700 (let (gnus-mark-article-hook)
7701 (gnus-summary-select-article)
7703 (set-buffer gnus-original-article-buffer)
7705 (message-narrow-to-head)
7706 (let ((groups (nnmail-article-group 'identity trace)))
7709 (message "This message would go to %s"
7710 (mapconcat 'car groups ", "))
7711 (message "This message would go to no groups"))
7714 (defun gnus-summary-respool-trace ()
7715 "Trace where the respool algorithm would put this article.
7716 Display a buffer showing all fancy splitting patterns which matched."
7718 (gnus-summary-respool-query nil t))
7720 ;; Summary marking commands.
7722 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7723 "Mark articles which has the same subject as read, and then select the next.
7724 If UNMARK is positive, remove any kind of mark.
7725 If UNMARK is negative, tick articles."
7728 (setq unmark (prefix-numeric-value unmark)))
7730 (gnus-summary-mark-same-subject
7731 (gnus-summary-article-subject) unmark)))
7732 ;; Select next unread article. If auto-select-same mode, should
7733 ;; select the first unread article.
7734 (gnus-summary-next-article t (and gnus-auto-select-same
7735 (gnus-summary-article-subject)))
7736 (gnus-message 7 "%d article%s marked as %s"
7737 count (if (= count 1) " is" "s are")
7738 (if unmark "unread" "read"))))
7740 (defun gnus-summary-kill-same-subject (&optional unmark)
7741 "Mark articles which has the same subject as read.
7742 If UNMARK is positive, remove any kind of mark.
7743 If UNMARK is negative, tick articles."
7746 (setq unmark (prefix-numeric-value unmark)))
7748 (gnus-summary-mark-same-subject
7749 (gnus-summary-article-subject) unmark)))
7750 ;; If marked as read, go to next unread subject.
7752 ;; Go to next unread subject.
7753 (gnus-summary-next-subject 1 t))
7754 (gnus-message 7 "%d articles are marked as %s"
7755 count (if unmark "unread" "read"))))
7757 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7758 "Mark articles with same SUBJECT as read, and return marked number.
7759 If optional argument UNMARK is positive, remove any kinds of marks.
7760 If optional argument UNMARK is negative, mark articles as unread instead."
7764 ((null unmark) ; Mark as read.
7767 (gnus-summary-mark-article-as-read gnus-killed-mark)
7768 (gnus-summary-show-thread) t)
7769 (gnus-summary-find-subject subject))
7770 (setq count (1+ count))))
7771 ((> unmark 0) ; Tick.
7774 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7775 (gnus-summary-show-thread) t)
7776 (gnus-summary-find-subject subject))
7777 (setq count (1+ count))))
7778 (t ; Mark as unread.
7781 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7782 (gnus-summary-show-thread) t)
7783 (gnus-summary-find-subject subject))
7784 (setq count (1+ count)))))
7785 (gnus-set-mode-line 'summary)
7786 ;; Return the number of marked articles.
7789 (defun gnus-summary-mark-as-processable (n &optional unmark)
7790 "Set the process mark on the next N articles.
7791 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7792 the process mark instead. The difference between N and the actual
7793 number of articles marked is returned."
7795 (let ((backward (< n 0))
7800 (gnus-summary-remove-process-mark
7801 (gnus-summary-article-number))
7802 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7803 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7806 (gnus-message 7 "No more articles"))
7807 (gnus-summary-recenter)
7808 (gnus-summary-position-point)
7811 (defun gnus-summary-unmark-as-processable (n)
7812 "Remove the process mark from the next N articles.
7813 If N is negative, unmark backward instead. The difference between N and
7814 the actual number of articles unmarked is returned."
7816 (gnus-summary-mark-as-processable n t))
7818 (defun gnus-summary-unmark-all-processable ()
7819 "Remove the process mark from all articles."
7822 (while gnus-newsgroup-processable
7823 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7824 (gnus-summary-position-point))
7826 (defun gnus-summary-mark-as-expirable (n)
7827 "Mark N articles forward as expirable.
7828 If N is negative, mark backward instead. The difference between N and
7829 the actual number of articles marked is returned."
7831 (gnus-summary-mark-forward n gnus-expirable-mark))
7833 (defun gnus-summary-mark-article-as-replied (article)
7834 "Mark ARTICLE replied and update the summary line."
7835 (push article gnus-newsgroup-replied)
7836 (let ((buffer-read-only nil))
7837 (when (gnus-summary-goto-subject article nil t)
7838 (gnus-summary-update-secondary-mark article))))
7840 (defun gnus-summary-set-bookmark (article)
7841 "Set a bookmark in current article."
7842 (interactive (list (gnus-summary-article-number)))
7843 (when (or (not (get-buffer gnus-article-buffer))
7844 (not gnus-current-article)
7845 (not gnus-article-current)
7846 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7847 (error "No current article selected"))
7848 ;; Remove old bookmark, if one exists.
7849 (let ((old (assq article gnus-newsgroup-bookmarks)))
7851 (setq gnus-newsgroup-bookmarks
7852 (delq old gnus-newsgroup-bookmarks))))
7853 ;; Set the new bookmark, which is on the form
7854 ;; (article-number . line-number-in-body).
7858 (set-buffer gnus-article-buffer)
7862 (goto-char (point-min))
7863 (search-forward "\n\n" nil t)
7866 gnus-newsgroup-bookmarks)
7867 (gnus-message 6 "A bookmark has been added to the current article."))
7869 (defun gnus-summary-remove-bookmark (article)
7870 "Remove the bookmark from the current article."
7871 (interactive (list (gnus-summary-article-number)))
7872 ;; Remove old bookmark, if one exists.
7873 (let ((old (assq article gnus-newsgroup-bookmarks)))
7876 (setq gnus-newsgroup-bookmarks
7877 (delq old gnus-newsgroup-bookmarks))
7878 (gnus-message 6 "Removed bookmark."))
7879 (gnus-message 6 "No bookmark in current article."))))
7881 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7882 (defun gnus-summary-mark-as-dormant (n)
7883 "Mark N articles forward as dormant.
7884 If N is negative, mark backward instead. The difference between N and
7885 the actual number of articles marked is returned."
7887 (gnus-summary-mark-forward n gnus-dormant-mark))
7889 (defun gnus-summary-set-process-mark (article)
7890 "Set the process mark on ARTICLE and update the summary line."
7891 (setq gnus-newsgroup-processable
7893 (delq article gnus-newsgroup-processable)))
7894 (when (gnus-summary-goto-subject article)
7895 (gnus-summary-show-thread)
7896 (gnus-summary-goto-subject article)
7897 (gnus-summary-update-secondary-mark article)))
7899 (defun gnus-summary-remove-process-mark (article)
7900 "Remove the process mark from ARTICLE and update the summary line."
7901 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7902 (when (gnus-summary-goto-subject article)
7903 (gnus-summary-show-thread)
7904 (gnus-summary-goto-subject article)
7905 (gnus-summary-update-secondary-mark article)))
7907 (defun gnus-summary-set-saved-mark (article)
7908 "Set the process mark on ARTICLE and update the summary line."
7909 (push article gnus-newsgroup-saved)
7910 (when (gnus-summary-goto-subject article)
7911 (gnus-summary-update-secondary-mark article)))
7913 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7914 "Mark N articles as read forwards.
7915 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7916 The difference between N and the actual number of articles marked is
7919 (gnus-summary-show-thread)
7920 (let ((backward (< n 0))
7921 (gnus-summary-goto-unread
7922 (and gnus-summary-goto-unread
7923 (not (eq gnus-summary-goto-unread 'never))
7924 (not (memq mark (list gnus-unread-mark
7925 gnus-ticked-mark gnus-dormant-mark)))))
7927 (mark (or mark gnus-del-mark)))
7929 (gnus-summary-mark-article nil mark no-expire)
7930 (zerop (gnus-summary-next-subject
7932 (and gnus-summary-goto-unread
7933 (not (eq gnus-summary-goto-unread 'never)))
7937 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7938 (gnus-summary-recenter)
7939 (gnus-summary-position-point)
7940 (gnus-set-mode-line 'summary)
7943 (defun gnus-summary-mark-article-as-read (mark)
7944 "Mark the current article quickly as read with MARK."
7945 (let ((article (gnus-summary-article-number)))
7946 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7947 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7948 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7949 (push (cons article mark) gnus-newsgroup-reads)
7950 ;; Possibly remove from cache, if that is used.
7951 (when gnus-use-cache
7952 (gnus-cache-enter-remove-article article))
7953 ;; Allow the backend to change the mark.
7954 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7955 ;; Check for auto-expiry.
7956 (when (and gnus-newsgroup-auto-expire
7957 (memq mark gnus-auto-expirable-marks))
7958 (setq mark gnus-expirable-mark)
7959 ;; Let the backend know about the mark change.
7960 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7961 (push article gnus-newsgroup-expirable))
7962 ;; Set the mark in the buffer.
7963 (gnus-summary-update-mark mark 'unread)
7966 (defun gnus-summary-mark-article-as-unread (mark)
7967 "Mark the current article quickly as unread with MARK."
7968 (let* ((article (gnus-summary-article-number))
7969 (old-mark (gnus-summary-article-mark article)))
7970 ;; Allow the backend to change the mark.
7971 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7972 (if (eq mark old-mark)
7976 (gnus-error 1 "Can't mark negative article numbers")
7978 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7979 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7980 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7981 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7982 (cond ((= mark gnus-ticked-mark)
7983 (push article gnus-newsgroup-marked))
7984 ((= mark gnus-dormant-mark)
7985 (push article gnus-newsgroup-dormant))
7987 (push article gnus-newsgroup-unreads)))
7988 (gnus-pull article gnus-newsgroup-reads)
7990 ;; See whether the article is to be put in the cache.
7992 (vectorp (gnus-summary-article-header article))
7994 (gnus-cache-possibly-enter-article
7995 gnus-newsgroup-name article
7996 (gnus-summary-article-header article)
7997 (= mark gnus-ticked-mark)
7998 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8001 (gnus-summary-update-mark mark 'unread)
8004 (defun gnus-summary-mark-article (&optional article mark no-expire)
8005 "Mark ARTICLE with MARK. MARK can be any character.
8006 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8007 `??' (dormant) and `?E' (expirable).
8008 If MARK is nil, then the default character `?r' is used.
8009 If ARTICLE is nil, then the article on the current line will be
8011 ;; The mark might be a string.
8012 (when (stringp mark)
8013 (setq mark (aref mark 0)))
8014 ;; If no mark is given, then we check auto-expiring.
8016 (setq mark gnus-del-mark))
8017 (when (and (not no-expire)
8018 gnus-newsgroup-auto-expire
8019 (memq mark gnus-auto-expirable-marks))
8020 (setq mark gnus-expirable-mark))
8021 (let ((article (or article (gnus-summary-article-number)))
8022 (old-mark (gnus-summary-article-mark article)))
8023 ;; Allow the backend to change the mark.
8024 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8025 (if (eq mark old-mark)
8028 (error "No article on current line"))
8029 (if (not (if (or (= mark gnus-unread-mark)
8030 (= mark gnus-ticked-mark)
8031 (= mark gnus-dormant-mark))
8032 (gnus-mark-article-as-unread article mark)
8033 (gnus-mark-article-as-read article mark)))
8035 ;; See whether the article is to be put in the cache.
8037 (not (= mark gnus-canceled-mark))
8038 (vectorp (gnus-summary-article-header article))
8040 (gnus-cache-possibly-enter-article
8041 gnus-newsgroup-name article
8042 (gnus-summary-article-header article)
8043 (= mark gnus-ticked-mark)
8044 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8046 (when (gnus-summary-goto-subject article nil t)
8047 (let ((buffer-read-only nil))
8048 (gnus-summary-show-thread)
8050 (gnus-summary-update-mark mark 'unread)
8053 (defun gnus-summary-update-secondary-mark (article)
8054 "Update the secondary (read, process, cache) mark."
8055 (gnus-summary-update-mark
8056 (cond ((memq article gnus-newsgroup-processable)
8058 ((memq article gnus-newsgroup-cached)
8060 ((memq article gnus-newsgroup-replied)
8062 ((memq article gnus-newsgroup-saved)
8064 (t gnus-unread-mark))
8066 (when (gnus-visual-p 'summary-highlight 'highlight)
8067 (gnus-run-hooks 'gnus-summary-update-hook))
8070 (defun gnus-summary-update-mark (mark type)
8071 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8072 (buffer-read-only nil))
8073 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8075 (when (looking-at "\r")
8077 (when (<= (+ forward (point)) (point-max))
8078 ;; Go to the right position on the line.
8079 (goto-char (+ forward (point)))
8080 ;; Replace the old mark with the new mark.
8081 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8082 ;; Optionally update the marks by some user rule.
8083 (when (eq type 'unread)
8085 (gnus-data-find (gnus-summary-article-number)) mark)
8086 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8088 (defun gnus-mark-article-as-read (article &optional mark)
8089 "Enter ARTICLE in the pertinent lists and remove it from others."
8090 ;; Make the article expirable.
8091 (let ((mark (or mark gnus-del-mark)))
8092 (if (= mark gnus-expirable-mark)
8093 (push article gnus-newsgroup-expirable)
8094 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8095 ;; Remove from unread and marked lists.
8096 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8097 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8098 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8099 (push (cons article mark) gnus-newsgroup-reads)
8100 ;; Possibly remove from cache, if that is used.
8101 (when gnus-use-cache
8102 (gnus-cache-enter-remove-article article))
8105 (defun gnus-mark-article-as-unread (article &optional mark)
8106 "Enter ARTICLE in the pertinent lists and remove it from others."
8107 (let ((mark (or mark gnus-ticked-mark)))
8110 (gnus-error 1 "Can't mark negative article numbers")
8112 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8113 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8114 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8115 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8117 ;; Unsuppress duplicates?
8118 (when gnus-suppress-duplicates
8119 (gnus-dup-unsuppress-article article))
8121 (cond ((= mark gnus-ticked-mark)
8122 (push article gnus-newsgroup-marked))
8123 ((= mark gnus-dormant-mark)
8124 (push article gnus-newsgroup-dormant))
8126 (push article gnus-newsgroup-unreads)))
8127 (gnus-pull article gnus-newsgroup-reads)
8130 (defalias 'gnus-summary-mark-as-unread-forward
8131 'gnus-summary-tick-article-forward)
8132 (make-obsolete 'gnus-summary-mark-as-unread-forward
8133 'gnus-summary-tick-article-forward)
8134 (defun gnus-summary-tick-article-forward (n)
8135 "Tick N articles forwards.
8136 If N is negative, tick backwards instead.
8137 The difference between N and the number of articles ticked is returned."
8139 (gnus-summary-mark-forward n gnus-ticked-mark))
8141 (defalias 'gnus-summary-mark-as-unread-backward
8142 'gnus-summary-tick-article-backward)
8143 (make-obsolete 'gnus-summary-mark-as-unread-backward
8144 'gnus-summary-tick-article-backward)
8145 (defun gnus-summary-tick-article-backward (n)
8146 "Tick N articles backwards.
8147 The difference between N and the number of articles ticked is returned."
8149 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8151 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8152 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8153 (defun gnus-summary-tick-article (&optional article clear-mark)
8154 "Mark current article as unread.
8155 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8156 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8158 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8161 (defun gnus-summary-mark-as-read-forward (n)
8162 "Mark N articles as read forwards.
8163 If N is negative, mark backwards instead.
8164 The difference between N and the actual number of articles marked is
8167 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8169 (defun gnus-summary-mark-as-read-backward (n)
8170 "Mark the N articles as read backwards.
8171 The difference between N and the actual number of articles marked is
8174 (gnus-summary-mark-forward
8175 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8177 (defun gnus-summary-mark-as-read (&optional article mark)
8178 "Mark current article as read.
8179 ARTICLE specifies the article to be marked as read.
8180 MARK specifies a string to be inserted at the beginning of the line."
8181 (gnus-summary-mark-article article mark))
8183 (defun gnus-summary-clear-mark-forward (n)
8184 "Clear marks from N articles forward.
8185 If N is negative, clear backward instead.
8186 The difference between N and the number of marks cleared is returned."
8188 (gnus-summary-mark-forward n gnus-unread-mark))
8190 (defun gnus-summary-clear-mark-backward (n)
8191 "Clear marks from N articles backward.
8192 The difference between N and the number of marks cleared is returned."
8194 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8196 (defun gnus-summary-mark-unread-as-read ()
8197 "Intended to be used by `gnus-summary-mark-article-hook'."
8198 (when (memq gnus-current-article gnus-newsgroup-unreads)
8199 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8201 (defun gnus-summary-mark-read-and-unread-as-read ()
8202 "Intended to be used by `gnus-summary-mark-article-hook'."
8203 (let ((mark (gnus-summary-article-mark)))
8204 (when (or (gnus-unread-mark-p mark)
8205 (gnus-read-mark-p mark))
8206 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8208 (defun gnus-summary-mark-region-as-read (point mark all)
8209 "Mark all unread articles between point and mark as read.
8210 If given a prefix, mark all articles between point and mark as read,
8211 even ticked and dormant ones."
8212 (interactive "r\nP")
8221 (memq (setq article (gnus-summary-article-number))
8222 gnus-newsgroup-unreads))
8223 (gnus-summary-mark-article article gnus-del-mark))
8225 (gnus-summary-find-next))))))
8227 (defun gnus-summary-mark-below (score mark)
8228 "Mark articles with score less than SCORE with MARK."
8229 (interactive "P\ncMark: ")
8230 (setq score (if score
8231 (prefix-numeric-value score)
8232 (or gnus-summary-default-score 0)))
8234 (set-buffer gnus-summary-buffer)
8235 (goto-char (point-min))
8238 (and (< (gnus-summary-article-score) score)
8239 (gnus-summary-mark-article nil mark))
8240 (gnus-summary-find-next)))))
8242 (defun gnus-summary-kill-below (&optional score)
8243 "Mark articles with score below SCORE as read."
8245 (gnus-summary-mark-below score gnus-killed-mark))
8247 (defun gnus-summary-clear-above (&optional score)
8248 "Clear all marks from articles with score above SCORE."
8250 (gnus-summary-mark-above score gnus-unread-mark))
8252 (defun gnus-summary-tick-above (&optional score)
8253 "Tick all articles with score above SCORE."
8255 (gnus-summary-mark-above score gnus-ticked-mark))
8257 (defun gnus-summary-mark-above (score mark)
8258 "Mark articles with score over SCORE with MARK."
8259 (interactive "P\ncMark: ")
8260 (setq score (if score
8261 (prefix-numeric-value score)
8262 (or gnus-summary-default-score 0)))
8264 (set-buffer gnus-summary-buffer)
8265 (goto-char (point-min))
8267 (when (> (gnus-summary-article-score) score)
8268 (gnus-summary-mark-article nil mark))
8270 (gnus-summary-find-next)))))
8272 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8273 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8274 (defun gnus-summary-limit-include-expunged (&optional no-error)
8275 "Display all the hidden articles that were expunged for low scores."
8277 (let ((buffer-read-only nil))
8278 (let ((scored gnus-newsgroup-scored)
8281 (unless (gnus-summary-goto-subject (caar scored))
8282 (and (setq h (gnus-summary-article-header (caar scored)))
8283 (< (cdar scored) gnus-summary-expunge-below)
8285 (setq scored (cdr scored)))
8287 (when (not no-error)
8288 (error "No expunged articles hidden"))
8289 (goto-char (point-min))
8290 (gnus-summary-prepare-unthreaded (nreverse headers))
8291 (goto-char (point-min))
8292 (gnus-summary-position-point)
8295 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8296 "Mark all unread articles in this newsgroup as read.
8297 If prefix argument ALL is non-nil, ticked and dormant articles will
8298 also be marked as read.
8299 If QUIETLY is non-nil, no questions will be asked.
8300 If TO-HERE is non-nil, it should be a point in the buffer. All
8301 articles before this point will be marked as read.
8302 Note that this function will only catch up the unread article
8303 in the current summary buffer limitation.
8304 The number of articles marked as read is returned."
8309 (not gnus-interactive-catchup) ;Without confirmation?
8313 "Mark absolutely all articles as read? "
8314 "Mark all unread articles as read? ")))
8316 (not gnus-newsgroup-adaptive)
8317 (not gnus-newsgroup-auto-expire)
8318 (not gnus-suppress-duplicates)
8319 (or (not gnus-use-cache)
8320 (eq gnus-use-cache 'passive)))
8323 (setq gnus-newsgroup-marked nil
8324 gnus-newsgroup-dormant nil))
8325 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8326 ;; We actually mark all articles as canceled, which we
8327 ;; have to do when using auto-expiry or adaptive scoring.
8328 (gnus-summary-show-all-threads)
8329 (when (gnus-summary-first-subject (not all) t)
8331 (if to-here (< (point) to-here) t)
8332 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8333 (gnus-summary-find-next (not all) nil nil t))))
8334 (gnus-set-mode-line 'summary))
8336 (gnus-summary-position-point)))
8338 (defun gnus-summary-catchup-to-here (&optional all)
8339 "Mark all unticked articles before the current one as read.
8340 If ALL is non-nil, also mark ticked and dormant articles as read."
8343 (gnus-save-hidden-threads
8344 (let ((beg (point)))
8345 ;; We check that there are unread articles.
8346 (when (or all (gnus-summary-find-prev))
8347 (gnus-summary-catchup all t beg)))))
8348 (gnus-summary-position-point))
8350 (defun gnus-summary-catchup-all (&optional quietly)
8351 "Mark all articles in this newsgroup as read."
8353 (gnus-summary-catchup t quietly))
8355 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8356 "Mark all unread articles in this group as read, then exit.
8357 If prefix argument ALL is non-nil, all articles are marked as read."
8359 (when (gnus-summary-catchup all quietly nil 'fast)
8360 ;; Select next newsgroup or exit.
8361 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8362 (eq gnus-auto-select-next 'quietly))
8363 (gnus-summary-next-group nil)
8364 (gnus-summary-exit))))
8366 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8367 "Mark all articles in this newsgroup as read, and then exit."
8369 (gnus-summary-catchup-and-exit t quietly))
8371 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8372 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8373 "Mark all articles in this group as read and select the next group.
8374 If given a prefix, mark all articles, unread as well as ticked, as
8378 (gnus-summary-catchup all))
8379 (gnus-summary-next-article t nil nil t))
8381 ;; Thread-based commands.
8383 (defun gnus-summary-articles-in-thread (&optional article)
8384 "Return a list of all articles in the current thread.
8385 If ARTICLE is non-nil, return all articles in the thread that starts
8387 (let* ((article (or article (gnus-summary-article-number)))
8388 (data (gnus-data-find-list article))
8389 (top-level (gnus-data-level (car data)))
8391 (cond ((null gnus-thread-operation-ignore-subject)
8392 (gnus-simplify-subject-re
8393 (mail-header-subject (gnus-data-header (car data)))))
8394 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8395 (gnus-simplify-subject-fuzzy
8396 (mail-header-subject (gnus-data-header (car data)))))
8398 (end-point (save-excursion
8399 (if (gnus-summary-go-to-next-thread)
8400 (point) (point-max))))
8403 (< (gnus-data-pos (car data)) end-point))
8404 (when (or (not top-subject)
8405 (string= top-subject
8406 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8407 (gnus-simplify-subject-fuzzy
8408 (mail-header-subject
8409 (gnus-data-header (car data))))
8410 (gnus-simplify-subject-re
8411 (mail-header-subject
8412 (gnus-data-header (car data)))))))
8413 (push (gnus-data-number (car data)) articles))
8414 (unless (and (setq data (cdr data))
8415 (> (gnus-data-level (car data)) top-level))
8417 ;; Return the list of articles.
8418 (nreverse articles)))
8420 (defun gnus-summary-rethread-current ()
8421 "Rethread the thread the current article is part of."
8423 (let* ((gnus-show-threads t)
8424 (article (gnus-summary-article-number))
8425 (id (mail-header-id (gnus-summary-article-header)))
8426 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8428 (error "No article on the current line"))
8429 (gnus-rebuild-thread id)
8430 (gnus-summary-goto-subject article)))
8432 (defun gnus-summary-reparent-thread ()
8433 "Make the current article child of the marked (or previous) article.
8435 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8436 is non-nil or the Subject: of both articles are the same."
8438 (unless (not (gnus-group-read-only-p))
8439 (error "The current newsgroup does not support article editing"))
8440 (unless (<= (length gnus-newsgroup-processable) 1)
8441 (error "No more than one article may be marked"))
8442 (save-window-excursion
8443 (let ((gnus-article-buffer " *reparent*")
8444 (current-article (gnus-summary-article-number))
8445 ;; First grab the marked article, otherwise one line up.
8446 (parent-article (if (not (null gnus-newsgroup-processable))
8447 (car gnus-newsgroup-processable)
8449 (if (eq (forward-line -1) 0)
8450 (gnus-summary-article-number)
8451 (error "Beginning of summary buffer"))))))
8452 (unless (not (eq current-article parent-article))
8453 (error "An article may not be self-referential"))
8454 (let ((message-id (mail-header-id
8455 (gnus-summary-article-header parent-article))))
8456 (unless (and message-id (not (equal message-id "")))
8457 (error "No message-id in desired parent"))
8458 (gnus-with-article current-article
8459 (goto-char (point-min))
8460 (if (re-search-forward "^References: " nil t)
8462 (re-search-forward "^[^ \t]" nil t)
8465 (insert " " message-id))
8466 (insert "References: " message-id "\n")))
8467 (set-buffer gnus-summary-buffer)
8468 (gnus-summary-unmark-all-processable)
8469 (gnus-summary-update-article current-article)
8470 (gnus-summary-rethread-current)
8471 (gnus-message 3 "Article %d is now the child of article %d"
8472 current-article parent-article)))))
8474 (defun gnus-summary-toggle-threads (&optional arg)
8475 "Toggle showing conversation threads.
8476 If ARG is positive number, turn showing conversation threads on."
8478 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8479 (setq gnus-show-threads
8480 (if (null arg) (not gnus-show-threads)
8481 (> (prefix-numeric-value arg) 0)))
8482 (gnus-summary-prepare)
8483 (gnus-summary-goto-subject current)
8484 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8485 (gnus-summary-position-point)))
8487 (defun gnus-summary-show-all-threads ()
8491 (let ((buffer-read-only nil))
8492 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8493 (gnus-summary-position-point))
8495 (defun gnus-summary-show-thread ()
8496 "Show thread subtrees.
8497 Returns nil if no thread was there to be shown."
8499 (let ((buffer-read-only nil)
8501 ;; first goto end then to beg, to have point at beg after let
8502 (end (progn (end-of-line) (point)))
8503 (beg (progn (beginning-of-line) (point))))
8505 ;; Any hidden lines here?
8506 (search-forward "\r" end t)
8507 (subst-char-in-region beg end ?\^M ?\n t)
8509 (gnus-summary-position-point))))
8511 (defun gnus-summary-hide-all-threads ()
8512 "Hide all thread subtrees."
8515 (goto-char (point-min))
8516 (gnus-summary-hide-thread)
8517 (while (zerop (gnus-summary-next-thread 1 t))
8518 (gnus-summary-hide-thread)))
8519 (gnus-summary-position-point))
8521 (defun gnus-summary-hide-thread ()
8522 "Hide thread subtrees.
8523 Returns nil if no threads were there to be hidden."
8525 (let ((buffer-read-only nil)
8527 (article (gnus-summary-article-number)))
8529 ;; Go forward until either the buffer ends or the subthread
8531 (when (and (not (eobp))
8532 (or (zerop (gnus-summary-next-thread 1 t))
8533 (goto-char (point-max))))
8535 (if (and (> (point) start)
8536 (search-backward "\n" start t))
8538 (subst-char-in-region start (point) ?\n ?\^M)
8539 (gnus-summary-goto-subject article))
8542 ;;(gnus-summary-position-point)
8545 (defun gnus-summary-go-to-next-thread (&optional previous)
8546 "Go to the same level (or less) next thread.
8547 If PREVIOUS is non-nil, go to previous thread instead.
8548 Return the article number moved to, or nil if moving was impossible."
8549 (let ((level (gnus-summary-thread-level))
8550 (way (if previous -1 1))
8553 (while (and (not (eobp))
8554 (< level (gnus-summary-thread-level)))
8562 (gnus-summary-article-number)
8565 (defun gnus-summary-next-thread (n &optional silent)
8566 "Go to the same level next N'th thread.
8567 If N is negative, search backward instead.
8568 Returns the difference between N and the number of skips actually
8571 If SILENT, don't output messages."
8573 (let ((backward (< n 0))
8576 (gnus-summary-go-to-next-thread backward))
8579 (gnus-summary-position-point))
8580 (when (and (not silent) (/= 0 n))
8581 (gnus-message 7 "No more threads"))
8584 (defun gnus-summary-prev-thread (n)
8585 "Go to the same level previous N'th thread.
8586 Returns the difference between N and the number of skips actually
8589 (gnus-summary-next-thread (- n)))
8591 (defun gnus-summary-go-down-thread ()
8592 "Go down one level in the current thread."
8593 (let ((children (gnus-summary-article-children)))
8595 (gnus-summary-goto-subject (car children)))))
8597 (defun gnus-summary-go-up-thread ()
8598 "Go up one level in the current thread."
8599 (let ((parent (gnus-summary-article-parent)))
8601 (gnus-summary-goto-subject parent))))
8603 (defun gnus-summary-down-thread (n)
8604 "Go down thread N steps.
8605 If N is negative, go up instead.
8606 Returns the difference between N and how many steps down that were
8612 (if up (gnus-summary-go-up-thread)
8613 (gnus-summary-go-down-thread)))
8615 (gnus-summary-position-point)
8617 (gnus-message 7 "Can't go further"))
8620 (defun gnus-summary-up-thread (n)
8621 "Go up thread N steps.
8622 If N is negative, go up instead.
8623 Returns the difference between N and how many steps down that were
8626 (gnus-summary-down-thread (- n)))
8628 (defun gnus-summary-top-thread ()
8629 "Go to the top of the thread."
8631 (while (gnus-summary-go-up-thread))
8632 (gnus-summary-article-number))
8634 (defun gnus-summary-kill-thread (&optional unmark)
8635 "Mark articles under current thread as read.
8636 If the prefix argument is positive, remove any kinds of marks.
8637 If the prefix argument is negative, tick articles instead."
8640 (setq unmark (prefix-numeric-value unmark)))
8641 (let ((articles (gnus-summary-articles-in-thread)))
8643 ;; Expand the thread.
8644 (gnus-summary-show-thread)
8645 ;; Mark all the articles.
8647 (gnus-summary-goto-subject (car articles))
8648 (cond ((null unmark)
8649 (gnus-summary-mark-article-as-read gnus-killed-mark))
8651 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8653 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8654 (setq articles (cdr articles))))
8655 ;; Hide killed subtrees.
8657 gnus-thread-hide-killed
8658 (gnus-summary-hide-thread))
8659 ;; If marked as read, go to next unread subject.
8661 ;; Go to next unread subject.
8662 (gnus-summary-next-subject 1 t)))
8663 (gnus-set-mode-line 'summary))
8665 ;; Summary sorting commands
8667 (defun gnus-summary-sort-by-number (&optional reverse)
8668 "Sort the summary buffer by article number.
8669 Argument REVERSE means reverse order."
8671 (gnus-summary-sort 'number reverse))
8673 (defun gnus-summary-sort-by-author (&optional reverse)
8674 "Sort the summary buffer by author name alphabetically.
8675 If case-fold-search is non-nil, case of letters is ignored.
8676 Argument REVERSE means reverse order."
8678 (gnus-summary-sort 'author reverse))
8680 (defun gnus-summary-sort-by-subject (&optional reverse)
8681 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8682 If case-fold-search is non-nil, case of letters is ignored.
8683 Argument REVERSE means reverse order."
8685 (gnus-summary-sort 'subject reverse))
8687 (defun gnus-summary-sort-by-date (&optional reverse)
8688 "Sort the summary buffer by date.
8689 Argument REVERSE means reverse order."
8691 (gnus-summary-sort 'date reverse))
8693 (defun gnus-summary-sort-by-score (&optional reverse)
8694 "Sort the summary buffer by score.
8695 Argument REVERSE means reverse order."
8697 (gnus-summary-sort 'score reverse))
8699 (defun gnus-summary-sort-by-lines (&optional reverse)
8700 "Sort the summary buffer by the number of lines.
8701 Argument REVERSE means reverse order."
8703 (gnus-summary-sort 'lines reverse))
8705 (defun gnus-summary-sort-by-chars (&optional reverse)
8706 "Sort the summary buffer by article length.
8707 Argument REVERSE means reverse order."
8709 (gnus-summary-sort 'chars reverse))
8711 (defun gnus-summary-sort (predicate reverse)
8712 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8713 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8714 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8715 (gnus-thread-sort-functions
8720 (gnus-article-sort-functions
8726 (gnus-summary-prepare-hook nil))
8727 ;; We do the sorting by regenerating the threads.
8728 (gnus-summary-prepare)
8729 ;; Hide subthreads if needed.
8730 (when (and gnus-show-threads gnus-thread-hide-subtree)
8731 (gnus-summary-hide-all-threads))))
8733 ;; Summary saving commands.
8735 (defun gnus-summary-save-article (&optional n not-saved)
8736 "Save the current article using the default saver function.
8737 If N is a positive number, save the N next articles.
8738 If N is a negative number, save the N previous articles.
8739 If N is nil and any articles have been marked with the process mark,
8740 save those articles instead.
8741 The variable `gnus-default-article-saver' specifies the saver function."
8743 (let* ((articles (gnus-summary-work-articles n))
8744 (save-buffer (save-excursion
8745 (nnheader-set-temp-buffer " *Gnus Save*")))
8746 (num (length articles))
8748 (dolist (article articles)
8749 (setq header (gnus-summary-article-header article))
8750 (if (not (vectorp header))
8751 ;; This is a pseudo-article.
8752 (if (assq 'name header)
8753 (gnus-copy-file (cdr (assq 'name header)))
8754 (gnus-message 1 "Article %d is unsaveable" article))
8755 ;; This is a real article.
8756 (save-window-excursion
8757 (gnus-summary-select-article t nil nil article))
8759 (set-buffer save-buffer)
8761 (insert-buffer-substring gnus-original-article-buffer))
8762 (setq file (gnus-article-save save-buffer file num))
8763 (gnus-summary-remove-process-mark article)
8765 (gnus-summary-set-saved-mark article))))
8766 (gnus-kill-buffer save-buffer)
8767 (gnus-summary-position-point)
8768 (gnus-set-mode-line 'summary)
8771 (defun gnus-summary-pipe-output (&optional arg)
8772 "Pipe the current article to a subprocess.
8773 If N is a positive number, pipe the N next articles.
8774 If N is a negative number, pipe the N previous articles.
8775 If N is nil and any articles have been marked with the process mark,
8776 pipe those articles instead."
8778 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8779 (gnus-summary-save-article arg t))
8780 (gnus-configure-windows 'pipe))
8782 (defun gnus-summary-save-article-mail (&optional arg)
8783 "Append the current article to an mail file.
8784 If N is a positive number, save the N next articles.
8785 If N is a negative number, save the N previous articles.
8786 If N is nil and any articles have been marked with the process mark,
8787 save those articles instead."
8789 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8790 (gnus-summary-save-article arg)))
8792 (defun gnus-summary-save-article-rmail (&optional arg)
8793 "Append the current article to an rmail file.
8794 If N is a positive number, save the N next articles.
8795 If N is a negative number, save the N previous articles.
8796 If N is nil and any articles have been marked with the process mark,
8797 save those articles instead."
8799 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8800 (gnus-summary-save-article arg)))
8802 (defun gnus-summary-save-article-file (&optional arg)
8803 "Append the current article to a file.
8804 If N is a positive number, save the N next articles.
8805 If N is a negative number, save the N previous articles.
8806 If N is nil and any articles have been marked with the process mark,
8807 save those articles instead."
8809 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8810 (gnus-summary-save-article arg)))
8812 (defun gnus-summary-write-article-file (&optional arg)
8813 "Write the current article to a file, deleting the previous file.
8814 If N is a positive number, save the N next articles.
8815 If N is a negative number, save the N previous articles.
8816 If N is nil and any articles have been marked with the process mark,
8817 save those articles instead."
8819 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8820 (gnus-summary-save-article arg)))
8822 (defun gnus-summary-save-article-body-file (&optional arg)
8823 "Append the current article body to a file.
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."
8829 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8830 (gnus-summary-save-article arg)))
8832 (defun gnus-summary-pipe-message (program)
8833 "Pipe the current article through PROGRAM."
8834 (interactive "sProgram: ")
8835 (gnus-summary-select-article)
8836 (let ((mail-header-separator ""))
8837 (gnus-eval-in-buffer-window gnus-article-buffer
8840 (let ((start (window-start))
8842 (message-pipe-buffer-body program)
8843 (set-window-start (get-buffer-window (current-buffer)) start))))))
8845 (defun gnus-get-split-value (methods)
8846 "Return a value based on the split METHODS."
8847 (let (split-name method result match)
8850 (set-buffer gnus-original-article-buffer)
8852 (nnheader-narrow-to-headers)
8854 (goto-char (point-min))
8855 (setq method (pop methods))
8856 (setq match (car method))
8859 ;; Regular expression.
8861 (re-search-forward match nil t)))
8862 ((gnus-functionp match)
8866 (setq result (funcall match gnus-newsgroup-name))))
8871 (setq result (eval match)))))
8872 (setq split-name (append (cdr method) split-name))
8873 (cond ((stringp result)
8874 (push (expand-file-name
8875 result gnus-article-save-directory)
8878 (setq split-name (append result split-name)))))))))
8879 (nreverse split-name)))
8881 (defun gnus-valid-move-group-p (group)
8884 (symbol-value group)
8885 (gnus-get-function (gnus-find-method-for-group
8886 (symbol-name group)) 'request-accept-article t)))
8888 (defun gnus-read-move-group-name (prompt default articles prefix)
8889 "Read a group name."
8890 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8891 (minibuffer-confirm-incomplete nil) ; XEmacs
8895 (if (> (length articles) 1)
8896 (format "these %d articles" (length articles))
8901 (gnus-completing-read default prom
8903 'gnus-valid-move-group-p
8905 'gnus-group-history))
8906 ((= 1 (length split-name))
8907 (gnus-completing-read (car split-name) prom
8909 'gnus-valid-move-group-p
8911 'gnus-group-history))
8913 (gnus-completing-read nil prom
8914 (mapcar (lambda (el) (list el))
8915 (nreverse split-name))
8917 'gnus-group-history)))))
8919 (if (or (string= to-newsgroup "")
8920 (string= to-newsgroup prefix))
8921 (setq to-newsgroup default))
8922 (unless to-newsgroup
8923 (error "No group name entered"))
8924 (or (gnus-active to-newsgroup)
8925 (gnus-activate-group to-newsgroup)
8926 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8928 (or (and (gnus-request-create-group
8929 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8930 (gnus-activate-group to-newsgroup nil nil
8931 (gnus-group-name-to-method
8933 (error "Couldn't create group %s" to-newsgroup)))
8934 (error "No such group: %s" to-newsgroup)))
8937 (defun gnus-summary-save-parts (type dir n reverse)
8938 "Save parts matching TYPE to DIR.
8939 If REVERSE, save parts that do not match TYPE."
8941 (list (read-string "Save parts of type: " "image/.*")
8942 (read-file-name "Save to directory: " t nil t)
8943 current-prefix-arg))
8944 (gnus-summary-iterate n
8945 (let ((gnus-display-mime-function nil)
8946 (gnus-inhibit-treatment t))
8947 (gnus-summary-select-article))
8949 (set-buffer gnus-article-buffer)
8950 (let ((handles (or (mm-dissect-buffer) (mm-uu-dissect))))
8952 (gnus-summary-save-parts-1 type dir handles reverse)
8953 (mm-destroy-parts handles))))))
8955 (defun gnus-summary-save-parts-1 (type dir handle reverse)
8956 (if (stringp (car handle))
8957 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
8960 (not (string-match type (mm-handle-media-type handle)))
8961 (string-match type (mm-handle-media-type handle)))
8962 (let ((file (expand-file-name
8963 (file-name-nondirectory
8965 (mail-content-type-get
8966 (mm-handle-disposition handle) 'filename)
8967 (concat gnus-newsgroup-name "." gnus-current-article)))
8969 (unless (file-exists-p file)
8970 (mm-save-part-to-file handle file))))))
8972 ;; Summary extract commands
8974 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8975 (let ((buffer-read-only nil)
8976 (article (gnus-summary-article-number))
8978 (unless (gnus-summary-goto-subject article)
8979 (error "No such article: %d" article))
8980 (gnus-summary-position-point)
8981 ;; If all commands are to be bunched up on one line, we collect
8983 (unless gnus-view-pseudos-separately
8984 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8987 (setq action (cdr (assq 'action (car ps))))
8988 (setq files (list (cdr (assq 'name (car ps)))))
8989 (while (and ps (cdr ps)
8990 (string= (or action "1")
8991 (or (cdr (assq 'action (cadr ps))) "2")))
8992 (push (cdr (assq 'name (cadr ps))) files)
8993 (setcdr ps (cddr ps)))
8995 (when (not (string-match "%s" action))
8998 (when (assq 'execute (car ps))
8999 (setcdr (assq 'execute (car ps))
9000 (funcall (if (string-match "%s" action)
9007 (gnus-quote-arg-for-sh-or-csh f)))
9009 (setq ps (cdr ps)))))
9010 (if (and gnus-view-pseudos (not not-view))
9012 (when (assq 'execute (car pslist))
9013 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9014 (eq gnus-view-pseudos 'not-confirm)))
9015 (setq pslist (cdr pslist)))
9018 (setq after-article (or (cdr (assq 'article (car pslist)))
9019 (gnus-summary-article-number)))
9020 (gnus-summary-goto-subject after-article)
9023 (insert " " (file-name-nondirectory
9024 (cdr (assq 'name (car pslist))))
9025 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9027 (forward-line -1) ; back to `b'
9028 (gnus-add-text-properties
9029 b (1- e) (list 'gnus-number gnus-reffed-article-number
9030 gnus-mouse-face-prop gnus-mouse-face))
9032 after-article gnus-reffed-article-number
9033 gnus-unread-mark b (car pslist) 0 (- e b))
9034 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9035 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9036 (setq pslist (cdr pslist)))))))
9038 (defun gnus-pseudos< (p1 p2)
9039 (let ((c1 (cdr (assq 'action p1)))
9040 (c2 (cdr (assq 'action p2))))
9041 (and c1 c2 (string< c1 c2))))
9043 (defun gnus-request-pseudo-article (props)
9044 (cond ((assq 'execute props)
9045 (gnus-execute-command (cdr (assq 'execute props)))))
9046 (let ((gnus-current-article (gnus-summary-article-number)))
9047 (gnus-run-hooks 'gnus-mark-article-hook)))
9049 (defun gnus-execute-command (command &optional automatic)
9051 (gnus-article-setup-buffer)
9052 (set-buffer gnus-article-buffer)
9053 (setq buffer-read-only nil)
9054 (let ((command (if automatic command
9055 (read-string "Command: " (cons command 0)))))
9057 (insert "$ " command "\n\n")
9058 (if gnus-view-pseudo-asynchronously
9059 (start-process "gnus-execute" (current-buffer) shell-file-name
9060 shell-command-switch command)
9061 (call-process shell-file-name nil t nil
9062 shell-command-switch command)))))
9064 ;; Summary kill commands.
9066 (defun gnus-summary-edit-global-kill (article)
9067 "Edit the \"global\" kill file."
9068 (interactive (list (gnus-summary-article-number)))
9069 (gnus-group-edit-global-kill article))
9071 (defun gnus-summary-edit-local-kill ()
9072 "Edit a local kill file applied to the current newsgroup."
9074 (setq gnus-current-headers (gnus-summary-article-header))
9075 (gnus-group-edit-local-kill
9076 (gnus-summary-article-number) gnus-newsgroup-name))
9080 (defun gnus-read-header (id &optional header)
9081 "Read the headers of article ID and enter them into the Gnus system."
9082 (let ((group gnus-newsgroup-name)
9083 (gnus-override-method
9084 (and (gnus-news-group-p gnus-newsgroup-name)
9085 gnus-refer-article-method))
9087 ;; First we check to see whether the header in question is already
9090 ;; This is a Message-ID.
9091 (setq header (or header (gnus-id-to-header id)))
9092 ;; This is an article number.
9093 (setq header (or header (gnus-summary-article-header id))))
9095 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9096 ;; We have found the header.
9098 ;; If this is a sparse article, we have to nix out its
9099 ;; previous entry in the thread hashtb.
9101 (gnus-summary-article-sparse-p (mail-header-number header)))
9102 (let* ((parent (gnus-parent-id (mail-header-references header)))
9103 (thread (and parent (gnus-id-to-thread parent))))
9105 (delq (assq header thread) thread))))
9106 ;; We have to really fetch the header to this article.
9108 (set-buffer nntp-server-buffer)
9109 (when (setq where (gnus-request-head id group))
9110 (nnheader-fold-continuation-lines)
9111 (goto-char (point-max))
9113 (goto-char (point-min))
9117 ((cdr where) (cdr where))
9118 (header (mail-header-number header))
9119 (t gnus-reffed-article-number))
9121 (insert " Article retrieved.\n"))
9123 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9124 () ; Malformed head.
9125 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9126 (when (and (stringp id)
9127 (not (string= (gnus-group-real-name group)
9129 ;; If we fetched by Message-ID and the article came
9130 ;; from a different group, we fudge some bogus article
9131 ;; numbers for this article.
9132 (mail-header-set-number header gnus-reffed-article-number))
9134 (set-buffer gnus-summary-buffer)
9135 (decf gnus-reffed-article-number)
9136 (gnus-remove-header (mail-header-number header))
9137 (push header gnus-newsgroup-headers)
9138 (setq gnus-current-headers header)
9139 (push (mail-header-number header) gnus-newsgroup-limit)))
9142 (defun gnus-remove-header (number)
9143 "Remove header NUMBER from `gnus-newsgroup-headers'."
9144 (if (and gnus-newsgroup-headers
9145 (= number (mail-header-number (car gnus-newsgroup-headers))))
9146 (pop gnus-newsgroup-headers)
9147 (let ((headers gnus-newsgroup-headers))
9148 (while (and (cdr headers)
9149 (not (= number (mail-header-number (cadr headers)))))
9152 (setcdr headers (cddr headers))))))
9155 ;;; summary highlights
9158 (defun gnus-highlight-selected-summary ()
9159 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9160 ;; Highlight selected article in summary buffer
9161 (when gnus-summary-selected-face
9163 (let* ((beg (progn (beginning-of-line) (point)))
9164 (end (progn (end-of-line) (point)))
9165 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9166 (from (if (get-text-property beg gnus-mouse-face-prop)
9168 (or (next-single-property-change
9169 beg gnus-mouse-face-prop nil end)
9174 (or (next-single-property-change
9175 from gnus-mouse-face-prop nil end)
9177 ;; If no mouse-face prop on line we will have to = from = end,
9178 ;; so we highlight the entire line instead.
9179 (when (= (+ to 2) from)
9182 (if gnus-newsgroup-selected-overlay
9183 ;; Move old overlay.
9185 gnus-newsgroup-selected-overlay from to (current-buffer))
9186 ;; Create new overlay.
9188 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9189 'face gnus-summary-selected-face))))))
9191 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9192 (defun gnus-summary-highlight-line ()
9193 "Highlight current line according to `gnus-summary-highlight'."
9194 (let* ((list gnus-summary-highlight)
9196 (end (progn (end-of-line) (point)))
9197 ;; now find out where the line starts and leave point there.
9198 (beg (progn (beginning-of-line) (point)))
9199 (article (gnus-summary-article-number))
9200 (score (or (cdr (assq (or article gnus-current-article)
9201 gnus-newsgroup-scored))
9202 gnus-summary-default-score 0))
9203 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9204 (inhibit-read-only t))
9205 ;; Eval the cars of the lists until we find a match.
9206 (let ((default gnus-summary-default-score))
9208 (not (eval (caar list))))
9209 (setq list (cdr list))))
9210 (let ((face (cdar list)))
9211 (unless (eq face (get-text-property beg 'face))
9212 (gnus-put-text-property-excluding-characters-with-faces
9214 (setq face (if (boundp face) (symbol-value face) face)))
9215 (when gnus-summary-highlight-line-function
9216 (funcall gnus-summary-highlight-line-function article face))))
9219 (defun gnus-update-read-articles (group unread &optional compute)
9220 "Update the list of read articles in GROUP."
9221 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9222 (entry (gnus-gethash group gnus-newsrc-hashtb))
9223 (info (nth 2 entry))
9225 (unread (sort (copy-sequence unread) '<))
9227 (if (or (not info) (not active))
9228 ;; There is no info on this group if it was, in fact,
9229 ;; killed. Gnus stores no information on killed groups, so
9230 ;; there's nothing to be done.
9231 ;; One could store the information somewhere temporarily,
9232 ;; perhaps... Hmmm...
9234 ;; Remove any negative articles numbers.
9235 (while (and unread (< (car unread) 0))
9236 (setq unread (cdr unread)))
9237 ;; Remove any expired article numbers
9238 (while (and unread (< (car unread) (car active)))
9239 (setq unread (cdr unread)))
9240 ;; Compute the ranges of read articles by looking at the list of
9243 (when (/= (car unread) prev)
9244 (push (if (= prev (1- (car unread))) prev
9245 (cons prev (1- (car unread))))
9247 (setq prev (1+ (car unread)))
9248 (setq unread (cdr unread)))
9249 (when (<= prev (cdr active))
9250 (push (cons prev (cdr active)) read))
9251 (setq read (if (> (length read) 1) (nreverse read) read))
9255 (set-buffer gnus-group-buffer)
9258 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9259 (gnus-info-set-read ',info ',(gnus-info-read info))
9260 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9261 (gnus-group-update-group ,group t))))
9262 ;; Propagate the read marks to the backend.
9263 (if (gnus-check-backend-function 'request-set-mark group)
9264 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9265 (add (gnus-remove-from-range read (gnus-info-read info))))
9267 (unless (gnus-check-group group)
9268 (error "Can't open server for %s" group))
9269 (gnus-request-set-mark
9270 group (delq nil (list (if add (list add 'add '(read)))
9271 (if del (list del 'del '(read)))))))))
9272 ;; Enter this list into the group info.
9273 (gnus-info-set-read info read)
9274 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9275 (gnus-get-unread-articles-in-group info (gnus-active group))
9278 (defun gnus-offer-save-summaries ()
9279 "Offer to save all active summary buffers."
9281 (let ((buflist (buffer-list))
9283 ;; Go through all buffers and find all summaries.
9285 (and (setq bufname (buffer-name (car buflist)))
9286 (string-match "Summary" bufname)
9288 (set-buffer bufname)
9289 ;; We check that this is, indeed, a summary buffer.
9290 (and (eq major-mode 'gnus-summary-mode)
9291 ;; Also make sure this isn't bogus.
9292 gnus-newsgroup-prepared
9293 ;; Also make sure that this isn't a dead summary buffer.
9294 (not gnus-dead-summary-mode)))
9295 (push bufname buffers))
9296 (setq buflist (cdr buflist)))
9297 ;; Go through all these summary buffers and offer to save them.
9300 "Update summary buffer %s? "
9302 (switch-to-buffer buf)
9303 (gnus-summary-exit))
9307 ;;; @ for mime-partial
9310 (defun gnus-request-partial-message ()
9312 (let ((number (gnus-summary-article-number))
9313 (group gnus-newsgroup-name)
9314 (mother gnus-article-buffer))
9315 (set-buffer (get-buffer-create " *Partial Article*"))
9317 (setq mime-preview-buffer mother)
9318 (gnus-request-article-this-buffer number group)
9322 (autoload 'mime-combine-message/partial-pieces-automatically
9324 "Internal method to combine message/partial messages automatically.")
9327 'action '((type . message)(subtype . partial)
9328 (major-mode . gnus-original-article-mode)
9329 (method . mime-combine-message/partial-pieces-automatically)
9330 (summary-buffer-exp . gnus-summary-buffer)
9331 (request-partial-message-method . gnus-request-partial-message)
9335 ;;; @ for message/rfc822
9338 (defun gnus-mime-extract-message/rfc822 (entity situation)
9339 (let (group article num cwin swin cur)
9340 (with-current-buffer (mime-entity-buffer entity)
9342 (narrow-to-region (mime-entity-body-start entity)
9343 (mime-entity-body-end entity))
9344 (setq group (or (cdr (assq 'group situation))
9345 (completing-read "Group: "
9348 (gnus-read-active-file-p)
9349 gnus-newsgroup-name))
9350 article (gnus-request-accept-article group)
9353 (when (and (consp article)
9354 (numberp (setq article (cdr article))))
9355 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9356 cwin (get-buffer-window (current-buffer) t)
9358 (save-window-excursion
9359 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9360 (select-window swin)
9361 (set-buffer gnus-summary-buffer)
9363 (setq cur gnus-current-article)
9365 (let (gnus-show-threads)
9366 (gnus-summary-goto-subject article t)
9368 (gnus-summary-clear-mark-forward 1)
9369 (gnus-summary-goto-subject cur)
9371 (when (and cwin (window-frame cwin))
9372 (select-frame (window-frame cwin))
9374 (when (boundp 'mime-acting-situation-to-override)
9375 (set-alist 'mime-acting-situation-to-override
9378 (set-alist 'mime-acting-situation-to-override
9381 (save-current-buffer
9382 (set-buffer gnus-group-buffer)
9383 (gnus-activate-group ,group)
9385 (gnus-summary-goto-article ,cur
9386 gnus-show-all-headers)
9388 (set-alist 'mime-acting-situation-to-override
9394 'action '((type . message)(subtype . rfc822)
9395 (major-mode . gnus-original-article-mode)
9396 (method . gnus-mime-extract-message/rfc822)
9401 'action '((type . message)(subtype . news)
9402 (major-mode . gnus-original-article-mode)
9403 (method . gnus-mime-extract-message/rfc822)
9407 (defun gnus-mime-extract-multipart (entity situation)
9408 (let ((children (mime-entity-children entity))
9409 mime-acting-situation-to-override
9412 (mime-play-entity (car children)
9413 (cons (assq 'mode situation)
9414 mime-acting-situation-to-override))
9415 (setq children (cdr children)))
9416 (if (setq f (cdr (assq 'after-method
9417 mime-acting-situation-to-override)))
9422 'action '((type . multipart)
9423 (method . gnus-mime-extract-multipart)
9432 (defun gnus-summary-setup-default-charset ()
9433 "Setup newsgroup default charset."
9434 (if (equal gnus-newsgroup-name "nndraft:drafts")
9435 (setq gnus-newsgroup-charset nil)
9436 (let* ((name (and gnus-newsgroup-name
9437 (gnus-group-real-name gnus-newsgroup-name)))
9439 (or gnus-newsgroup-ephemeral-ignored-charsets
9441 (and gnus-newsgroup-name
9442 (or (gnus-group-find-parameter gnus-newsgroup-name
9443 'ignored-charsets t)
9444 (let ((alist gnus-group-ignored-charsets-alist)
9445 elem (charsets nil))
9446 (while (setq elem (pop alist))
9448 (string-match (car elem) name))
9450 charsets (cdr elem))))
9452 gnus-newsgroup-ignored-charsets)))
9453 (setq gnus-newsgroup-charset
9454 (or gnus-newsgroup-ephemeral-charset
9455 (and gnus-newsgroup-name
9456 (or (gnus-group-find-parameter gnus-newsgroup-name
9458 (let ((alist gnus-group-charset-alist)
9460 (while (setq elem (pop alist))
9462 (string-match (car elem) name))
9464 charset (cadr elem))))
9466 gnus-default-charset))
9467 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9468 ignored-charsets))))
9474 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9475 "Display the current article buffer fully MIME-buttonized.
9476 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9477 treated as multipart/mixed."
9480 (let ((gnus-unbuttonized-mime-types nil)
9481 (gnus-mime-display-multipart-as-mixed show-all-parts))
9482 (gnus-summary-show-article)))
9484 (defun gnus-summary-repair-multipart (article)
9485 "Add a Content-Type header to a multipart article without one."
9486 (interactive (list (gnus-summary-article-number)))
9487 (gnus-with-article article
9488 (message-narrow-to-head)
9489 (goto-char (point-max))
9491 (when (search-forward "\n--" nil t)
9492 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9493 (message-narrow-to-head)
9494 (message-remove-header "Mime-Version")
9495 (message-remove-header "Content-Type")
9496 (goto-char (point-max))
9497 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9499 (insert "Mime-Version: 1.0\n")
9501 (let (gnus-mark-article-hook)
9502 (gnus-summary-select-article t t nil article)))
9504 (defun gnus-summary-toggle-display-buttonized ()
9505 "Toggle the buttonizing of the article buffer."
9508 (if (setq gnus-inhibit-mime-unbuttonizing
9509 (not gnus-inhibit-mime-unbuttonizing))
9510 (let ((gnus-unbuttonized-mime-types nil))
9511 (gnus-summary-show-article))
9512 (gnus-summary-show-article)))
9518 (defmacro gnus-with-article (article &rest forms)
9519 "Select ARTICLE and perform FORMS in the original article buffer.
9520 Then replace the article with the result."
9522 ;; We don't want the article to be marked as read.
9523 (let (gnus-mark-article-hook)
9524 (gnus-summary-select-article t t nil ,article))
9525 (set-buffer gnus-original-article-buffer)
9527 (if (not (gnus-check-backend-function
9528 'request-replace-article (car gnus-article-current)))
9529 (gnus-message 5 "Read-only group; not replacing")
9530 (unless (gnus-request-replace-article
9531 ,article (car gnus-article-current)
9533 (error "Couldn't replace article")))
9534 ;; The cache and backlog have to be flushed somewhat.
9535 (when gnus-keep-backlog
9536 (gnus-backlog-remove-article
9537 (car gnus-article-current) (cdr gnus-article-current)))
9538 (when gnus-use-cache
9539 (gnus-cache-update-article
9540 (car gnus-article-current) (cdr gnus-article-current)))))
9542 (put 'gnus-with-article 'lisp-indent-function 1)
9543 (put 'gnus-with-article 'edebug-form-spec '(form body))
9546 ;;; Generic summary marking commands
9549 (defvar gnus-summary-marking-alist
9550 '((read gnus-del-mark "d")
9551 (unread gnus-unread-mark "u")
9552 (ticked gnus-ticked-mark "!")
9553 (dormant gnus-dormant-mark "?")
9554 (expirable gnus-expirable-mark "e"))
9555 "An alist of names/marks/keystrokes.")
9557 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9558 (defvar gnus-summary-mark-map)
9560 (defun gnus-summary-make-all-marking-commands ()
9561 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9562 (dolist (elem gnus-summary-marking-alist)
9563 (apply 'gnus-summary-make-marking-command elem)))
9565 (defun gnus-summary-make-marking-command (name mark keystroke)
9566 (let ((map (make-sparse-keymap)))
9567 (define-key gnus-summary-generic-mark-map keystroke map)
9568 (dolist (lway `((next "next" next nil "n")
9569 (next-unread "next unread" next t "N")
9570 (prev "previous" prev nil "p")
9571 (prev-unread "previous unread" prev t "P")
9572 (nomove "" nil nil ,keystroke)))
9573 (let ((func (gnus-summary-make-marking-command-1
9574 mark (car lway) lway name)))
9575 (setq func (eval func))
9576 (define-key map (nth 4 lway) func)))))
9578 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9580 (format "gnus-summary-put-mark-as-%s%s"
9581 name (if (eq way 'nomove)
9583 (concat "-" (symbol-name way)))))
9586 "Mark the current article as %s%s.
9587 If N, the prefix, then repeat N times.
9588 If N is negative, move in reverse order.
9589 The difference between N and the actual number of articles marked is
9593 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9595 (defun gnus-summary-generic-mark (n mark move unread)
9596 "Mark N articles with MARK."
9597 (unless (eq major-mode 'gnus-summary-mode)
9598 (error "This command can only be used in the summary buffer"))
9599 (gnus-summary-show-thread)
9603 ((eq move 'prev) -1)
9609 nummove (* -1 nummove))))
9611 (gnus-summary-mark-article nil mark)
9612 (zerop (gnus-summary-next-subject nummove unread t)))
9615 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9616 (gnus-summary-recenter)
9617 (gnus-summary-position-point)
9618 (gnus-set-mode-line 'summary)
9621 (gnus-summary-make-all-marking-commands)
9627 (run-hooks 'gnus-sum-load-hook)
9629 ;;; gnus-sum.el ends here